@surething/cockpit 1.0.227 → 1.0.228

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.
Files changed (38) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +2 -2
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next-prod/server/app/_global-error.html +1 -1
  7. package/.next-prod/server/app/_global-error.rsc +1 -1
  8. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next-prod/server/app/_not-found.html +2 -2
  16. package/.next-prod/server/app/_not-found.rsc +2 -2
  17. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +2 -2
  20. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
  24. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  25. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  26. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  27. package/.next-prod/server/app-paths-manifest.json +2 -2
  28. package/.next-prod/server/chunks/9658.js +1 -1
  29. package/.next-prod/server/middleware-build-manifest.js +1 -1
  30. package/.next-prod/server/pages/404.html +2 -2
  31. package/.next-prod/server/pages/500.html +1 -1
  32. package/.next-prod/server/server-reference-manifest.json +1 -1
  33. package/.next-prod/static/chunks/{217-259a6d7d3cac75d8.js → 217-ee98c428d2c2630a.js} +1 -1
  34. package/.next-prod/trace +13 -13
  35. package/.next-prod/trace-build +1 -1
  36. package/package.json +1 -1
  37. /package/.next-prod/static/{t45T3Imr0gQh7MYDeURiy → u_R4oaNwWvzUpY5No5EIX}/_buildManifest.js +0 -0
  38. /package/.next-prod/static/{t45T3Imr0gQh7MYDeURiy → u_R4oaNwWvzUpY5No5EIX}/_ssgManifest.js +0 -0
@@ -22,7 +22,7 @@ Error: ${b.message}`,exitCode:1,isRunning:!1,pid:void 0}:c))}},[G,u,E,c,a,Y,ad,Z
22
22
  Error: ${a}`,exitCode:1,isRunning:!1,pid:void 0}:d))}})}catch(c){let a=ad(b);Z(b),p(d=>d.map(d=>d.id===b?{...d,output:a+`
23
23
  Error: ${c.message}`,exitCode:1,isRunning:!1,pid:void 0}:d))}},[l,G,u,E,c,a,Y,ad,Z]),an=(0,e.useCallback)(async b=>{p(a=>a.filter(a=>a.id!==b)),Z(b),c&&await i.t4.runPromise((0,k.SN)(a,c,b,V.current).pipe(h.tapError(a=>h.sync(()=>console.error("Failed to delete command:",a))),h.orElse(()=>h.void)))},[a,c,Z]),ao=(0,e.useCallback)((b,d,e)=>{let f=(0,g.sd)(b);if(!f)return;let j=f.parse(d);"cwd"in j&&!j.cwd&&(j.cwd=u);let l={id:(0,g.lf)(f.idPrefix),_type:b,timestamp:new Date().toISOString(),...j};if(r(a=>[...a,l]),D(l.id),setTimeout(ae,100),e){let b=I&&I.length>0?[...I]:U.current.map(a=>a.data.id),d=b.indexOf(e);-1!==d?b.splice(d+1,0,l.id):b.push(l.id),J(b),c&&i.t4.runFork((0,k.cm)(a,c,b,V.current).pipe(h.orElse(()=>h.void)))}if(c){let d=f.toHistory(l);i.t4.runFork((0,k.AJ)(a,c,{type:b,id:l.id,timestamp:l.timestamp,...d},V.current).pipe(h.tapError(a=>h.sync(()=>console.error(`Failed to save ${b} item:`,a))),h.orElse(()=>h.void)))}},[ae,a,c,I]),ap=(0,e.useCallback)(async b=>{let d=q.find(a=>a.id===b);if(r(a=>a.filter(a=>a.id!==b)),D(a=>a===b?null:a),t(a=>{let c=new Set(a);return c.delete(b),c}),d){let a=(0,g.sd)(d._type);a?.onClose?.(d)}c&&i.t4.runFork((0,k.SN)(a,c,b,V.current).pipe(h.tapError(a=>h.sync(()=>console.error("Failed to delete plugin item:",a))),h.orElse(()=>h.void)))},[q,a,c]);T.current=ao,S.current=ak;let aq=(0,e.useCallback)((b,d)=>{c&&i.t4.runFork((0,k.bv)(a,c,b,{sleeping:d},V.current).pipe(h.orElse(()=>h.void)))},[a,c]),ar=(0,e.useCallback)(a=>{t(b=>new Set(b).add(a)),aq(a,!0)},[aq]),as=(0,e.useCallback)(a=>{t(b=>{let c=new Set(b);return c.delete(a),c}),aq(a,!1)},[aq]),at=(0,e.useCallback)(async b=>{J(b),c&&await i.t4.runPromise((0,k.cm)(a,c,b,V.current).pipe(h.orElse(()=>h.void)))},[a,c]),au=(0,e.useMemo)(()=>{let a=[...l.map(a=>({type:"command",data:a})),...q.map(a=>({type:a._type,data:a}))];if(!I||0===I.length)return a.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime());let b=new Map(I.map((a,b)=>[a,b])),c=[],d=[];for(let e of a)b.has(e.data.id)?c.push(e):d.push(e);return c.sort((a,c)=>b.get(a.data.id)-b.get(c.data.id)),d.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime()),[...c,...d]},[l,q,I]);return U.current=au,{commands:l,pluginItems:q,sleepingBubbles:s,consoleItems:au,currentCwd:u,selectedCommandId:C,setSelectedCommandId:D,customEnv:E,setCustomEnv:F,aliases:G,setAliases:H,isLoadingHistory:w,hasMoreHistory:y,currentPage:A,scrollRef:W,commandHistoryRef:O,ptySizeRef:P,executeCommandRef:S,executeCommand:ak,interruptCommand:al,rerunCommand:am,deleteCommand:an,addPluginItem:ao,closePluginItem:ap,handleBubbleSleep:ar,handleBubbleWake:as,loadHistory:af,scrollToBottom:ae,saveBubbleOrder:at,sendStdin:f.tr,resizePty:f.mO,subscribePtyOutput:$,subscribePtyReset:aa,subscribePtyRefresh:ac}}d()}catch(a){d(a)}})},18482:(a,b,c)=>{"use strict";c.a(a,async(a,b)=>{try{var d=c(48249),e=c(3560),f=c(98420),g=a([f]);f=(g.then?(await g)():g)[0],(0,e.Aq)({type:"browser",idPrefix:"browser",match(a){let b=a.trim().toLowerCase();return b.startsWith("http://")||b.startsWith("https://")},parse:a=>({url:a.trim()}),fromHistory:a=>({url:a.url}),toHistory:a=>({url:a.url}),Component:function({item:a,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l,extra:m}){return(0,d.jsx)(f.V,{id:a.id,url:a.url,selected:b,maximized:c,expandedHeight:e,bubbleContentHeight:g,timestamp:h,onSelect:i,onClose:j,onToggleMaximize:k,onTitleMouseDown:l,onNewTab:m?.addBrowserItem,initialSleeping:m?.initialSleeping,onSleep:m?.onSleep,onWake:m?.onWake,projectCwd:m?.projectCwd,tabId:m?.tabId})}}),b()}catch(a){b(a)}})},18499:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({collapsed:a,pinnedSessions:b,onSwitchProject:c,onUnpin:h,onUpdateTitle:i,onReorder:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(!1),n=(0,e.useRef)(null),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(""),s=(0,e.useRef)(null),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(null),x=(0,e.useCallback)(a=>{o||(c(a.cwd,a.sessionId),m(!1))},[c,o]),y=(0,e.useCallback)((a,b)=>{b.stopPropagation(),p(a.sessionId),r(a.customTitle||"")},[]),z=(0,e.useCallback)(()=>{o&&q.trim()&&i(o,q.trim()),p(null)},[o,q,i]),A=(0,e.useCallback)(a=>{u(a)},[]),B=(0,e.useCallback)((a,b)=>{a.preventDefault(),w(b)},[]),C=(0,e.useCallback)(a=>{if(null===t||t===a){u(null),w(null);return}let c=[...b],[d]=c.splice(t,1);c.splice(a,0,d),j(c),u(null),w(null)},[t,b,j]),D=(0,e.useCallback)(()=>{u(null),w(null)},[]);return(0,d.jsxs)("div",{className:"relative",ref:n,children:[(0,d.jsxs)("button",{onClick:()=>m(!l),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:k("sessions.pinnedSessions"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:k("sessions.pinnedSessions")}),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})]}),l&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:(0,d.jsx)("span",{className:"text-sm font-medium",children:k("sessions.pinnedSessions")})}),(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:k("sessions.noPinnedSessions")}):b.map((a,c)=>{let e;return(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>A(c),onDragOver:a=>B(a,c),onDrop:()=>C(c),onDragEnd:D,onClick:()=>x(a),className:`group w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 cursor-pointer ${c!==b.length-1?"border-b border-border/50":""} ${t===c?"opacity-50":""} ${v===c?"border-t-2 border-brand":""}`,children:[(0,d.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,d.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,d.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",title:a.cwd,children:[(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsx)("span",{className:"font-medium text-sm truncate",children:(e=a.cwd).split("/").pop()||e})}),o===a.sessionId?(0,d.jsx)("input",{ref:s,type:"text",value:q,onChange:a=>r(a.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||("Enter"===a.key&&z(),"Escape"===a.key&&p(null))},onBlur:z,onClick:a=>a.stopPropagation(),className:"w-full text-xs px-1 py-0.5 border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring mt-0.5"}):(0,d.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:a.customTitle||a.sessionId.slice(0,8)})]}),o!==a.sessionId&&(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:[(0,d.jsx)("button",{onClick:b=>y(a,b),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:k("sessions.editTitle"),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:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),h(a.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:k("sessions.remove"),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.sessionId)})})]})]})}},18792:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{P:()=>m});var e=c(48249),f=c(67484),g=c(36295),h=c(28602),i=c(74493),j=a([g]);g=(j.then?(await j)():j)[0];let n=["#4C8BF5","#E74C3C","#2ECC71","#F39C12","#9B59B6","#1ABC9C","#E67E22","#3498DB","#E91E63","#00BCD4"];function k(a){if(!a)return"";let b=new Date(a);return isNaN(b.getTime())?"":`${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")} ${String(b.getHours()).padStart(2,"0")}:${String(b.getMinutes()).padStart(2,"0")}`}function l({nodes:a,rels:b,allLabels:c}){let d=(0,f.useRef)(null),g=(0,f.useRef)(null),h=(0,f.useRef)([]);(0,f.useRef)(0);let i=(0,f.useRef)(null);(0,f.useRef)({w:0,h:0}),(0,f.useRef)(new Map);let[j,k]=(0,f.useState)(null),m=(0,f.useRef)(null),n=(0,f.useCallback)(a=>{let b=g.current?.getBoundingClientRect();if(!b)return null;let c=a.clientX-b.left,d=a.clientY-b.top;return h.current.find(a=>{let b=(a.x||0)-c,e=(a.y||0)-d;return b*b+e*e<400})||null},[]);return(0,e.jsxs)("div",{ref:d,className:"relative w-full h-full",children:[(0,e.jsx)("canvas",{ref:g,className:"cursor-grab active:cursor-grabbing absolute inset-0",onMouseDown:a=>{let b=n(a);if(b){let c=g.current.getBoundingClientRect();i.current={nodeId:b.id,offsetX:a.clientX-c.left-(b.x||0),offsetY:a.clientY-c.top-(b.y||0)}}},onMouseMove:a=>{if(i.current){let b=g.current.getBoundingClientRect(),c=h.current.find(a=>a.id===i.current.nodeId);c&&(c.x=a.clientX-b.left-i.current.offsetX,c.y=a.clientY-b.top-i.current.offsetY,c.vx=0,c.vy=0)}else{let b=n(a);m.current=b,k(b)}},onMouseUp:()=>{i.current=null},onMouseLeave:()=>{i.current=null,m.current=null,k(null)}}),j&&!i.current&&(0,e.jsxs)("div",{className:"absolute top-2 left-2 bg-popover text-popover-foreground border border-border rounded px-2 py-1 text-xs max-w-[300px] pointer-events-none",children:[(0,e.jsxs)("div",{className:"font-medium",children:[j.labels.join(", ")," #",String(j.id)]}),Object.entries(j.properties).slice(0,8).map(([a,b])=>(0,e.jsxs)("div",{className:"truncate",children:[(0,e.jsxs)("span",{className:"text-muted-foreground",children:[a,":"]})," ",String(b)]},a))]})]})}function m({id:a,connectionString:b,displayName:c,selected:d,maximized:j,expandedHeight:o,bubbleContentHeight:p,onSelect:q,onClose:r,onToggleMaximize:s,timestamp:t,onTitleMouseDown:u}){let[v,w]=(0,f.useState)("connecting"),[x,y]=(0,f.useState)(""),[z,A]=(0,f.useState)(null),[B,C]=(0,f.useState)(null),[D,E]=(0,f.useState)(!1),[F,G]=(0,f.useState)("labels"),[H,I]=(0,f.useState)(""),[J,K]=(0,f.useState)(null),[L,M]=(0,f.useState)(!1),[N,O]=(0,f.useState)(""),P=(0,f.useRef)(null),[Q,R]=(0,f.useState)([]),[S,T]=(0,f.useState)([]),[U,V]=(0,f.useState)("schema"),W=j&&o?o-41:p??g.p,X=(0,f.useCallback)(async()=>{w("connecting");try{let c=await (0,i.GW)("/api/neo4j/connect",{id:a,connectionString:b});A(c),w("connected")}catch(a){y(a instanceof Error?a.message:String(a)),w("error")}},[a,b]),Y=(0,f.useCallback)(async()=>{E(!0);try{let c=await (0,i.GW)("/api/neo4j/schema",{id:a,connectionString:b});C(c)}catch{}E(!1)},[a,b]),Z=(0,f.useCallback)(async c=>{let d=c||H.trim();if(d){M(!0),O("");try{var e;let c,f,g=await (0,i.GW)("/api/neo4j/query",{id:a,connectionString:b,cypher:d});K(g);let{nodes:h,rels:j}=(e=g.records,c=new Map,f=[],e.forEach(a=>Object.values(a).forEach(function a(b){if(b&&"object"==typeof b)if("node"===b._type){let a=b._id;c.has(a)||c.set(a,{id:a,labels:b._labels||[],properties:Object.fromEntries(Object.entries(b).filter(([a])=>!a.startsWith("_")))})}else if("relationship"===b._type)f.push({id:b._id,type:b._relType,startId:b._start,endId:b._end,properties:Object.fromEntries(Object.entries(b).filter(([a])=>!a.startsWith("_")))});else if("path"===b._type){let c=b.segments;c?.forEach(b=>{a(b.start),a(b.relationship),a(b.end)})}else Array.isArray(b)&&b.forEach(a)})),{nodes:Array.from(c.values()),rels:f});h.length>0&&(R(h),T(j))}catch(a){O(a instanceof Error?a.message:String(a))}M(!1)}},[a,b,H]),$=(0,f.useCallback)(a=>{let b=`MATCH (n:\`${a}\`) RETURN n LIMIT 25`;I(b),V("cypher"),Z(b)},[Z]),_=(0,f.useCallback)(a=>{let b=`MATCH (a)-[r:\`${a}\`]->(b) RETURN a, r, b LIMIT 25`;I(b),V("graph"),Z(b)},[Z]);return(0,e.jsx)("div",{className:"flex flex-col items-start",onClick:q,children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground relative transition-colors ${d?"ring-1 ring-ring":""} rounded-lg overflow-hidden`,children:[(0,e.jsxs)("div",{"data-drag-handle":!0,onDoubleClick:s,onMouseDown:u,className:"flex items-center gap-2 px-4 py-1.5 border-b border-border cursor-grab active:cursor-grabbing select-none",children:[(0,e.jsx)("span",{className:"text-sm flex-shrink-0",children:"⬡"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate font-mono font-medium",children:c}),"connecting"===v&&(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),"connected"===v&&(0,e.jsx)("span",{className:"text-[10px] text-emerald-500 flex-shrink-0",children:"Connected"}),"error"===v&&(0,e.jsx)("span",{className:"text-[10px] text-destructive flex-shrink-0",children:"Error"}),t&&(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:k(t)}),"connected"===v&&z&&(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:["v",z.version," \xb7 ",z.nodeCount.toLocaleString(),"n \xb7 ",z.relationshipCount.toLocaleString(),"r"]}),(0,e.jsx)("span",{className:"flex-1"}),"connected"===v&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),Y(),X()},disabled:D,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 disabled:opacity-40",title:"Refresh",children:(0,e.jsx)("svg",{className:`w-3.5 h-3.5 ${D?"animate-spin":""}`,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:a=>{a.stopPropagation(),s()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground 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:j?(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"}):(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),r()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground 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:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{style:{height:W},className:"flex flex-col overflow-hidden",children:["connecting"===v&&(0,e.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Connecting..."]}),"error"===v&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-xs p-4 gap-2",children:[(0,e.jsx)("p",{className:"text-destructive",children:x}),(0,e.jsx)("button",{onClick:X,className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Retry"})]}),"connected"===v&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex items-center gap-0 border-b border-border bg-card/30 flex-shrink-0",children:["schema","cypher","graph"].map(a=>(0,e.jsx)("button",{onClick:()=>V(a),className:`px-3 py-1.5 text-xs transition-colors ${U===a?"text-brand border-b-2 border-brand font-medium":"text-muted-foreground hover:text-foreground"}`,children:{schema:"Schema",cypher:"Cypher",graph:"Graph"}[a]},a))}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex",children:["schema"===U&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-40 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:(0,e.jsx)("div",{className:"flex-1 overflow-y-auto text-xs",children:[{key:"labels",label:"Labels",count:B?.labels.length},{key:"relationships",label:"Relationships",count:B?.relationshipTypes.length},{key:"properties",label:"Properties",count:B?.propertyKeys.length},{key:"indexes",label:"Indexes",count:B?.indexes.length},{key:"constraints",label:"Constraints",count:B?.constraints.length}].map(a=>(0,e.jsxs)("div",{onClick:()=>G(a.key),className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer truncate transition-colors ${F===a.key?"bg-brand/10 text-brand":"hover:bg-white/10 text-foreground"}`,children:[(0,e.jsx)("span",{className:"truncate min-w-0 flex-1",children:a.label}),(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count??0})]},a.key))})}),(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto text-xs",children:[D&&(0,e.jsxs)("div",{className:"flex items-center justify-center p-4 gap-2 text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"})," Loading..."]}),!D&&"labels"===F&&B?.labels.map(a=>{var b;return(0,e.jsxs)("div",{onClick:()=>$(a.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,e.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:(b=a.name,n[B.labels.map(a=>a.name).indexOf(b)%n.length])}}),(0,e.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:a.name}),(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count.toLocaleString()})]},a.name)}),!D&&"relationships"===F&&B?.relationshipTypes.map(a=>(0,e.jsxs)("div",{onClick:()=>_(a.name),className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer hover:bg-brand/10 transition-colors",children:[(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:"→"}),(0,e.jsx)("span",{className:"truncate min-w-0 flex-1 font-mono",children:a.name}),(0,e.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground flex-shrink-0",children:a.count.toLocaleString()})]},a.name)),!D&&"properties"===F&&B?.propertyKeys.map(a=>(0,e.jsx)("div",{className:"px-2 py-1 font-mono text-muted-foreground hover:bg-brand/10 transition-colors",children:a},a)),!D&&"indexes"===F&&B?.indexes.map(a=>(0,e.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,e.jsx)("div",{className:"font-mono text-foreground",children:a.name}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[a.type," \xb7 ",a.labelsOrTypes?.join(", ")," \xb7 (",a.properties?.join(", "),") \xb7 ",a.state]})]},a.name)),!D&&"constraints"===F&&B?.constraints.map(a=>(0,e.jsxs)("div",{className:"px-2 py-1 border-b border-border/50 hover:bg-brand/10 transition-colors",children:[(0,e.jsx)("div",{className:"font-mono text-foreground",children:a.name}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[a.type," \xb7 ",a.labelsOrTypes?.join(", ")," \xb7 (",a.properties?.join(", "),")"]})]},a.name))]})]}),"cypher"===U&&(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-2 border-b border-border flex-shrink-0",children:[(0,e.jsx)("textarea",{ref:P,value:H,onChange:a=>I(a.target.value),onKeyDown:a=>{(a.metaKey||a.ctrlKey)&&"Enter"===a.key&&(a.preventDefault(),Z())},placeholder:`Enter Cypher query (${(0,h.Mu)()}+Enter to run)`,className:"w-full h-20 px-2 py-1.5 text-xs font-mono bg-background border border-input rounded resize-y focus:outline-none focus:ring-1 focus:ring-ring",spellCheck:!1}),(0,e.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[(0,h.Mu)(),"+Enter to execute"]}),(0,e.jsx)("button",{onClick:()=>Z(),disabled:L||!H.trim(),className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 transition-colors",children:L?"Running...":"Execute"})]})]}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto",children:[N&&(0,e.jsx)("div",{className:"p-2 text-xs text-destructive",children:N}),J&&!N&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-2 py-1 text-[10px] text-muted-foreground border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("span",{children:[J.records.length," rows"]}),(0,e.jsxs)("span",{children:[J.duration,"ms"]}),Object.entries(J.counters).filter(([,a])=>a>0).map(([a,b])=>(0,e.jsxs)("span",{children:[a,": ",b]},a))]}),J.records.length>0&&(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:J.keys.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},a))})}),(0,e.jsx)("tbody",{children:J.records.map((a,b)=>(0,e.jsx)("tr",{className:"hover:bg-accent/50",children:J.keys.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",children:null===a[b]?(0,e.jsx)("span",{className:"text-muted-foreground italic",children:"NULL"}):function(a){if(null==a)return"null";if("object"==typeof a){if("node"===a._type){let b=a._labels?.[0]||"",c=a.name||a.title||a.id||"";return`(${b}${c?": "+c:""})`}return"relationship"===a._type?`[${a._relType}]`:JSON.stringify(a)}return String(a)}(a[b])},b))},b))})]})]})]})]}),"graph"===U&&(0,e.jsx)("div",{className:"flex-1 relative",children:0===Q.length?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-xs text-muted-foreground gap-2",children:[(0,e.jsx)("p",{children:"Run a Cypher query that returns nodes to visualize"}),(0,e.jsx)("button",{onClick:()=>{let a="MATCH (a)-[r]->(b) RETURN a, r, b LIMIT 50";I(a),Z(a)},className:"px-3 py-1 rounded text-xs bg-brand text-white hover:bg-brand/90 transition-colors",children:"Load sample graph"})]}):(0,e.jsx)(l,{nodes:Q,rels:S,allLabels:B?.labels.map(a=>a.name)||[]})})]})]})]}),!j&&(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"===v?"bg-green-500":"error"===v?"bg-red-500":"bg-yellow-500 animate-pulse"}`}),(0,e.jsx)("span",{children:{connecting:"Connecting",connected:"Connected",error:"Error"}[v]}),"connected"===v&&z&&(0,e.jsx)("span",{className:"text-muted-foreground/70",children:z.edition}),(0,e.jsx)("span",{className:"flex-1"}),t&&(0,e.jsx)("span",{className:"text-[11px] flex-shrink-0",children:k(t)})]})]})})}d()}catch(a){d(a)}})},18921:(a,b,c)=>{"use strict";c.d(b,{_:()=>i,o:()=>h});var d=c(67484),e=c.n(d),f=c(208);let g="json-search-highlight-style";function h(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[h,i]=(0,d.useState)(!1),[j,k]=(0,d.useState)(0),[l,m]=(0,d.useState)(0),n=(0,d.useRef)(null),o=(0,d.useRef)([]);(0,d.useCallback)(()=>{let b;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),o.current=[];let c=a.current;if(!c||!e){k(0),m(0);return}!function(){if(document.getElementById(g))return;let a=document.createElement("style");a.id=g,a.textContent="::highlight(json-search){background:rgba(217,119,6,.3)}::highlight(json-search-current){background:rgba(217,119,6,.5)}",document.head.appendChild(a)}();let d=c.textContent||"",f=h?e:e.toLowerCase(),i=h?d:d.toLowerCase(),j=[],l=0;for(;l<i.length;){let a=i.indexOf(f,l);if(-1===a)break;j.push([a,a+f.length]),l=a+1}if(0===j.length){k(0),m(0);return}let n=document.createTreeWalker(c,NodeFilter.SHOW_TEXT),p=0,q=0,r=[],s=null,t=0;for(;(b=n.nextNode())&&q<j.length;){let a=b.textContent?.length||0,c=p,d=p+a;for(;q<j.length;){let[a,e]=j[q];if(a>=d)break;if(!s)if(a>=c)(s=document.createRange()).setStart(b,a-c),t=e;else break;if(t<=d)s.setEnd(b,t-c),r.push(s),s=null,q++;else break}p=d}o.current=r,k(r.length),m(a=>r.length>0?Math.min(a,r.length-1):0),CSS.highlights&&r.length>0&&CSS.highlights.set("json-search",new Highlight(...r))},[a,e,h]);let p=(0,d.useCallback)((a,b)=>{let c=a.getBoundingClientRect();(b.top<c.top||b.bottom>c.bottom)&&(a.scrollTop+=b.top-c.top-c.height/2+b.height/2)},[]);(0,d.useCallback)(b=>{CSS.highlights?.delete("json-search-current");let c=o.current[b];if(!c||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(c));let d=c.getBoundingClientRect(),e=a.current?.parentElement;e&&p(e,d)},[a,p]);let q=(0,d.useCallback)(()=>{0!==j&&m(a=>(a+1)%j)},[j]),r=(0,d.useCallback)(()=>{0!==j&&m(a=>(a-1+j)%j)},[j]),s=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>n.current?.focus(),0)},[]),t=(0,d.useCallback)(()=>{c(!1),f(""),m(0)},[]),u=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?r():q()),"Escape"===a.key&&(a.preventDefault(),t())},[q,r,t]);return{isVisible:b,query:e,setQuery:f,caseSensitive:h,setCaseSensitive:i,matchCount:j,currentIndex:l,searchInputRef:n,open:s,close:t,goToNext:q,goToPrev:r,handleKeyDown:u}}function i({search:a}){return a.isVisible?e().createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},e().createElement("input",{ref:a.searchInputRef,type:"text",value:a.query,onChange:b=>a.setQuery(b.target.value),onKeyDown:a.handleKeyDown,placeholder:f.A.t("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e().createElement("button",{onClick:()=>a.setCaseSensitive(a=>!a),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${a.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:f.A.t("codeViewer.caseSensitive")},"Aa"),e().createElement("span",{className:"text-xs text-muted-foreground"},a.matchCount>0?`${a.currentIndex+1}/${a.matchCount}`:f.A.t("common.noMatch")),e().createElement("button",{onClick:a.goToPrev,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.previous")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),e().createElement("button",{onClick:a.goToNext,disabled:0===a.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:f.A.t("common.next")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),e().createElement("button",{onClick:a.close,className:"p-1 rounded hover:bg-accent",title:f.A.t("common.close")},e().createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},e().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}},18946:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{X:()=>i});var e=c(48249),f=c(67484),g=c(58554),h=a([g]);function i({tabId:a,cwd:b,sessionId:c,engine:d,ollamaModel:h,onOllamaModelChange:j,deepseekModel:k,onDeepseekModelChange:l,chatMode:m,onChatModeChange:n,planMode:o,onPlanModeChange:p,isActive:q,onStateChange:r,onShowGitStatus:s,onOpenNote:t,onCreateScheduledTask:u,onOpenSession:v,onContentSearch:w}){let x=(0,f.useCallback)(b=>{r(a,{isLoading:b})},[a,r]),y=(0,f.useCallback)(b=>{r(a,{sessionId:b})},[a,r]),z=(0,f.useCallback)(b=>{r(a,{title:b})},[a,r]),A=(0,f.useCallback)(b=>{j?.(a,b)},[a,j]),B=(0,f.useCallback)(b=>{l?.(a,b)},[a,l]),C=(0,f.useCallback)(b=>{n?.(a,b)},[a,n]),D=(0,f.useCallback)(b=>{p?.(a,b)},[a,p]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,engine:d,ollamaModel:h,onOllamaModelChange:A,deepseekModel:k,onDeepseekModelChange:B,chatMode:m,onChatModeChange:C,planMode:o,onPlanModeChange:D,hideHeader:!0,hideSidebar:!0,isActive:q,onLoadingChange:x,onSessionIdChange:y,onTitleChange:z,onShowGitStatus:s,onOpenNote:t,onCreateScheduledTask:u,onOpenSession:v,onContentSearch:w})}g=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},19545:(a,b,c)=>{"use strict";c.d(b,{Qe:()=>f,up:()=>e});var d=c(208);function e(a){return a.storage.markdown.getMarkdown()}function f(){return[{label:d.A.t("slashCommands.heading1"),icon:"H1",description:d.A.t("slashCommands.heading1Desc"),action:a=>a.chain().focus().toggleHeading({level:1}).run()},{label:d.A.t("slashCommands.heading2"),icon:"H2",description:d.A.t("slashCommands.heading2Desc"),action:a=>a.chain().focus().toggleHeading({level:2}).run()},{label:d.A.t("slashCommands.heading3"),icon:"H3",description:d.A.t("slashCommands.heading3Desc"),action:a=>a.chain().focus().toggleHeading({level:3}).run()},{label:d.A.t("slashCommands.bulletList"),icon:"•",description:d.A.t("slashCommands.bulletListDesc"),action:a=>a.chain().focus().toggleBulletList().run()},{label:d.A.t("slashCommands.orderedList"),icon:"1.",description:d.A.t("slashCommands.orderedListDesc"),action:a=>a.chain().focus().toggleOrderedList().run()},{label:d.A.t("slashCommands.taskList"),icon:"☑",description:d.A.t("slashCommands.taskListDesc"),action:a=>a.chain().focus().toggleTaskList().run()},{label:d.A.t("slashCommands.blockquote"),icon:"❝",description:d.A.t("slashCommands.blockquoteDesc"),action:a=>a.chain().focus().toggleBlockquote().run()},{label:d.A.t("slashCommands.codeBlock"),icon:"<>",description:d.A.t("slashCommands.codeBlockDesc"),action:a=>a.chain().focus().toggleCodeBlock().run()},{label:d.A.t("slashCommands.table"),icon:"▦",description:d.A.t("slashCommands.tableDesc"),action:a=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{label:d.A.t("slashCommands.horizontalRule"),icon:"──",description:d.A.t("slashCommands.horizontalRuleDesc"),action:a=>a.chain().focus().setHorizontalRule().run()},{label:d.A.t("slashCommands.link"),icon:"\uD83D\uDD17",description:d.A.t("slashCommands.linkDesc"),action:a=>{window.dispatchEvent(new CustomEvent("tiptap-insert-link"))}}]}f()},19562:(a,b,c)=>{"use strict";c.d(b,{SettingsModal:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call SettingsModal() from the server but SettingsModal 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/SettingsModal.tsx","SettingsModal")},19872:(a,b,c)=>{"use strict";function d(a,b,c){let{engine:d,assistantId:e}=c;if("stream_event"===b.type){let c=b.event;if(c?.type==="content_block_delta"&&c.delta?.type==="text_delta"&&c.delta.text){let b=c.delta.text;return a.map(a=>a.id===e?{...a,content:(a.content||"")+b}:a)}return a}if("assistant"===b.type){let c=b.message?.content;if(!Array.isArray(c))return a;let f=a,g=b.message?.model==="<synthetic>";if("codex"===d||"kimi"===d||"ollama"===d||g){let a=c.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("");a&&(f=f.map(b=>b.id===e?{...b,content:(b.content||"")+a}:b))}for(let a of c)if(a.name){let b={id:a.id||`tool-${e}-${a.name}`,name:a.name,input:a.input||{},isLoading:!0};f=f.map(a=>a.id!==e||a.toolCalls?.some(a=>a.id===b.id)?a:{...a,toolCalls:[...a.toolCalls||[],b]})}return f}if("user"===b.type){let c=b.message?.content;if(!Array.isArray(c))return a;let d=a;for(let a of c)if(a.tool_use_id){let b=a.tool_use_id,c="string"==typeof a.content?a.content:JSON.stringify(a.content);d=d.map(a=>a.id===e?{...a,toolCalls:a.toolCalls?.map(a=>a.id===b?{...a,result:c,isLoading:!1}:a)}:a)}return d}if("error"===b.type){let c=b.error||"An error occurred. Please try again.";return a.map(a=>a.id===e?{...a,content:a.content?`${a.content}
24
24
 
25
- ⚠️ ${c}`:`⚠️ ${c}`,isStreaming:!1}:a)}if("result"===b.type){let c="string"==typeof b.result?b.result.trim():"";return a.map(a=>a.id===e?{...a,content:!a.content&&c?c:a.content,isStreaming:!1,toolCalls:a.toolCalls?.map(a=>({...a,isLoading:!1}))}:a)}return a}c.d(b,{F:()=>d})},20291:(a,b,c)=>{"use strict";c.d(b,{p:()=>i});var d=c(67484),e=c(208),f=c(79606),g=c(33281),h=c(71192);function i({cwd:a,onSearchComplete:b}){let[c,j]=(0,d.useState)(""),[k,l]=(0,d.useState)([]),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(new Set),[s,t]=(0,d.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[u,v]=(0,d.useState)(null),w=(0,d.useRef)(null),x=(0,d.useCallback)(async c=>{let d=c.trim();if(!d){l([]),v(null);return}if(d.length<2)return void p(e.A.t("fileBrowser.searchMinChars"));n(!0),p(null);let i=new URLSearchParams({cwd:a,q:c,caseSensitive:String(s.caseSensitive),wholeWord:String(s.wholeWord),regex:String(s.regex),fileType:s.fileType}),j=f.tryPromise({try:async()=>{let a=await fetch(`/api/files/search?${i}`),b=await a.json();if(b.error)throw Error(b.error);return b},catch:a=>new h.uV({message:"content search failed",cause:a})});await g.t4.runPromise(j.pipe(f.match({onSuccess:a=>{l(a.results),v({totalFiles:a.totalFiles,totalMatches:a.totalMatches,truncated:a.truncated}),r(new Set(a.results.map(a=>a.path))),a.results.length>0&&b?.()},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Search failed"),l([])}}))),n(!1)},[a,s,b]);return{contentSearchQuery:c,setContentSearchQuery:j,contentSearchResults:k,isSearching:m,searchError:o,searchExpandedPaths:q,searchOptions:s,setSearchOptions:t,searchStats:u,contentSearchInputRef:w,performContentSearch:x,handleSearchToggle:(0,d.useCallback)(a=>{r(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},20586:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var e=c(48249),f=c(67484),g=c.n(f),h=c(44384),i=c(7122),j=c(61591);function k({status:a}){let{label:b,className:c}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[a]||{label:"?",className:"text-muted-foreground"};return(0,e.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let a=g().memo(function a({node:b,level:c,selectedPath:d,expandedPaths:g,onSelect:h,onToggle:i,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=d===b.path,p=g.has(b.path),q=(0,f.useCallback)(()=>{b.isDirectory?i(b.path):h(b)},[b,h,i]),r=(0,f.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);return b.isDirectory?(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,e.jsx)("span",{className:"text-slate-9 text-xs",children:p?"▼":"▶"}),(0,e.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,e.jsx)(a,{node:b,level:c+1,selectedPath:d,expandedPaths:g,onSelect:h,onToggle:i,onContextMenu:l,showChanges:m,renderActions:n},b.path))]}):(0,e.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${o?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,e.jsx)(j.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,e.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,e.jsx)(k,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,e.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]}),n&&n(b)]})});function l({files:b,selectedPath:c,expandedPaths:d,onSelect:f,onToggle:g,cwd:j,showChanges:k=!1,renderActions:m,emptyMessage:n,className:o}){let{t:p}=(0,h.Bd)(),q=n??p("gitFileTree.noFiles"),{contextMenu:r,showContextMenu:s,hideContextMenu:t}=(0,i.Ee)();return 0===b.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:q}):(0,e.jsxs)("div",{className:o||"py-1",children:[b.map(b=>(0,e.jsx)(a,{node:b,level:0,selectedPath:c,expandedPaths:d,onSelect:f,onToggle:g,onContextMenu:s,showChanges:k,renderActions:m},b.path)),r&&(0,e.jsx)(i.ft,{x:r.x,y:r.y,path:r.path,cwd:j,isDirectory:r.isDirectory,onClose:t})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),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("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}d()}catch(a){d(a)}})},21482:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(36984),j=a([i]);function k({results:a,loading:b,totalMatches:c,onSelect:d,onClose:i,scope:j,onScopeChange:l,selectedPath:m}){let{t:n}=(0,g.Bd)(),o=function(){let[a,b]=(0,f.useState)(new Map),[c,d]=(0,f.useState)(!1);return(0,f.useRef)(0),a}(),p="selected"===j?a.filter(a=>a.path===m):a,q=p.reduce((a,b)=>a+b.matches.length,0);return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground truncate",children:[n("searchResults.title")," ",!b&&n("searchResults.nMatches",{count:"selected"===j?q:c})]}),(0,e.jsxs)("div",{className:"flex items-center rounded border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,e.jsx)("button",{onClick:()=>l("selected"),className:`px-2 py-0.5 ${"selected"===j?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-accent"}`,children:n("searchResults.scopeSelected")}),(0,e.jsx)("button",{onClick:()=>l("all"),className:`px-2 py-0.5 border-l border-border ${"all"===j?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-accent"}`,children:n("searchResults.scopeAll")})]})]}),(0,e.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-accent text-muted-foreground flex-shrink-0",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.searching")}):0===p.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.noResults")}):p.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a.path}),a.matches.map((b,c)=>{let f=`${a.path}:${b.lineNumber}`,g=o.get(f);return(0,e.jsxs)("button",{onClick:()=>d(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),g?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:g}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},21538:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(35208),i=c(20586),j=c(33281),k=c(85655),l=c(60591),m=c(18921),n=a([i,h]);function o({isOpen:a,onClose:b,commit:c,cwd:d,embedded:n=!1,initialFilePath:p,onContentSearch:q}){let{t:r}=(0,g.Bd)(),[s,t]=(0,f.useState)([]),[u,v]=(0,f.useState)([]),[w,x]=(0,f.useState)(new Set),[y,z]=(0,f.useState)(null),[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=(0,f.useRef)(null),J=(0,m.o)(I),K=(0,f.useCallback)(a=>{c&&(z(a),F(!0),j.t4.runPromiseExit((0,k.Zi)(d,c.hash,a.path)).then(a=>{"Success"===a._tag?B(a.value):console.error(a.cause),F(!1)}))},[d,c]),L=(0,f.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=(0,f.useMemo)(()=>{if(!c)return"";if(c.date){var a;let b,d,e,f,g,h,i;return a=c.date,b=new Date(a),d=new Date,e=b.getFullYear()===d.getFullYear(),f=String(b.getMonth()+1).padStart(2,"0"),g=String(b.getDate()).padStart(2,"0"),h=String(b.getHours()).padStart(2,"0"),i=String(b.getMinutes()).padStart(2,"0"),e?`${f}-${g} ${h}:${i}`:`${b.getFullYear()}-${f}-${g} ${h}:${i}`}return c.time?new Date(1e3*c.time).toLocaleString():""},[c]);if(!a||!c)return null;let N=(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border bg-secondary flex-shrink-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:c.subject}),c.body&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap mb-3 max-h-32 overflow-y-auto border-l-2 border-border pl-3",children:c.body}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.hash")}),(0,e.jsx)("span",{className:"font-mono bg-accent px-1.5 py-0.5 rounded",children:c.hash})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.author")}),(0,e.jsx)("span",{children:c.author}),(0,e.jsxs)("span",{className:"text-slate-9",children:["<",c.authorEmail,">"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.date")}),(0,e.jsx)("span",{children:M}),c.relativeDate&&(0,e.jsxs)("span",{className:"text-slate-9",children:["(",c.relativeDate,")"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.files")}),(0,e.jsx)("span",{children:r("commitDetail.nChanges",{count:s.length})})]})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:C?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:r("commitDetail.loadingFiles")}):(0,e.jsx)(i.VO,{files:u,selectedPath:y?.path||null,expandedPaths:w,onSelect:a=>a.file&&K(a.file),onToggle:L,cwd:d,showChanges:!0,emptyMessage:r("commitDetail.noFileChanges"),className:"py-1"})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:E?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:r("commitDetail.loadingDiff")}):A?(0,e.jsx)(h.xZ,{oldContent:A.oldContent,newContent:A.newContent,filePath:A.filePath,isNew:A.isNew,isDeleted:A.isDeleted,cwd:d,enableComments:!0,onPreview:!A.isDeleted&&A.filePath.endsWith(".json")?()=>H({content:A.newContent,filePath:A.filePath}):void 0,previewLabel:r("common.readable"),onContentSearch:q}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:r("commitDetail.selectFileToView")})})]})]}),O=G&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>H(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:G.filePath}),(0,e.jsx)("button",{onClick:()=>H(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)(m._,{search:J}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:I,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,l.xb)(G.content)})})]})});return n?(0,e.jsxs)("div",{className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsx)("button",{onClick:b,className:"absolute top-2 right-2 z-10 p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",title:r("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"})})}),N,O]}):(0,e.jsx)("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card w-full h-full 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",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r("commitDetail.title")}),(0,e.jsx)("button",{onClick:b,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"})})})]}),N,O]})})}[i,h]=n.then?(await n)():n,d()}catch(a){d(a)}})},21672:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(36984),j=a([i]);function k({references:a,loading:b,onSelect:c,onClose:d}){let{t:i}=(0,g.Bd)(),j=function(){let[a,b]=(0,f.useState)(new Map),[c,d]=(0,f.useState)(!1);return(0,f.useRef)(0),a}(),l=[],m=new Map;for(let b=0;b<a.length;b++){let c=a[b],d=m.get(c.file);void 0===d&&(d=l.length,m.set(c.file,d),l.push({file:c.file,items:[]})),l[d].items.push({ref:c,idx:b})}return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[i("references.title")," ",!b&&`(${a.length})`]}),(0,e.jsx)("button",{onClick:d,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("references.searching")}):0===a.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("references.notFound")}):l.map(({file:a,items:b})=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a}),b.map(({ref:a,idx:b})=>(0,e.jsxs)("button",{onClick:()=>c(a),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:a.line}),j.has(b)?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:j.get(b)}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:a.lineText||""})]},`${a.line}-${a.column}-${b}`))]},a))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},23328:(a,b,c)=>{"use strict";c.d(b,{AJ:()=>n,Cb:()=>z,D0:()=>v,DN:()=>k,Jn:()=>j,Ok:()=>s,QF:()=>i,SN:()=>o,UV:()=>y,Vv:()=>q,Yj:()=>x,Yn:()=>w,bv:()=>p,cm:()=>l,cv:()=>r,jO:()=>t,tp:()=>u,uc:()=>m});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`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,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>g(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>d.gen(function*(){let c=new URLSearchParams({cwd:a});return b&&c.set("tabId",b),(yield*f(`/api/terminal/env?${c}`)).env||{}}),j=()=>f("/api/terminal/aliases").pipe(d.map(a=>a.aliases||{})),k=(a,b)=>f(`/api/terminal/bubble-order?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}`).pipe(d.map(a=>a.order||[])),l=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,order:c,sourceId:d}),m=(a,b,c,d=100)=>f(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&page=${c}&pageSize=${d}`),n=(a,b,c,d)=>h("/api/terminal/history",{cwd:a,tabId:b,entry:c,sourceId:d}),o=(a,b,c,d)=>g(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&commandId=${encodeURIComponent(c)}${d?`&sourceId=${encodeURIComponent(d)}`:""}`,{method:"DELETE"}),p=(a,b,c,d,e)=>g("/api/terminal/history",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:b,id:c,fields:d,sourceId:e})}),q=a=>h("/api/terminal/env",a),r=a=>h("/api/terminal/aliases",{aliases:a}),s=a=>h("/api/terminal/register",a),t=a=>h("/api/terminal/unregister",a),u=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"POST /api/terminal/autocomplete failed",cause:a})}),v=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),w=a=>h("/api/project-settings",a),x=()=>f("/api/services/config?scope=global"),y=a=>f(`/api/services/config?cwd=${encodeURIComponent(a)}`),z=a=>h("/api/services/config",a)},23700:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(2929),k=c(38087),l=a([j]);function m({cwd:a,sessionId:b,toolCall:c,workflowRef:d,onClose:l}){let{t:n}=(0,g.Bd)(),[o,p]=(0,f.useState)(null),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!1),u=(0,f.useRef)(void 0),v=d?!!d.running:!c?.result;(0,f.useCallback)(async()=>{let e=await i.t4.runPromiseExit((0,k.z)({cwd:a,sessionId:b,...d?{workflowId:d.runId,workflowAgentId:d.agentId}:{toolUseId:c?.id},ifFingerprint:u.current}));if(t(!0),"Success"!==e._tag||!e.value)return;let f=e.value;f.fingerprint&&(u.current=f.fingerprint),!f.notModified&&(f.messages&&p(f.messages),f.subagent&&r(f.subagent))},[a,b,c?.id,d?.runId,d?.agentId]);let w=(0,f.useRef)(null),x=(0,f.useRef)(!0),y="string"==typeof c?.input?.description?c.input.description:"",z=d?d.label||"":[q?.agentType,y].filter(Boolean).join(" \xb7 ");return(0,e.jsx)(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\uDD16"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:n("chat.subagent")}),z&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:z,children:z}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[v&&(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:n("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",{ref:w,onScroll:()=>{let a=w.current;a&&(x.current=a.scrollTop+a.clientHeight>=a.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===o?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:n(s?"chat.subagentEmpty":"common.loading")}):o.map(b=>(0,e.jsx)(j.s,{message:b,cwd:a},b.id))})]})})})}j=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},23734:(a,b,c)=>{"use strict";c.d(b,{R:()=>e,d:()=>f});var d=c(28031);let e=(a,b)=>({id:a,legacyType:b??a.replace(/-/g,"_").toUpperCase()}),f=d.Io("@cockpit/IframeBus")},23860:(a,b,c)=>{"use strict";c.d(b,{F:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return a}},23881:(a,b,c)=>{"use strict";c.d(b,{s:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g(a){return a.replace(/^\([^)]+\)\s*/,"")}let h=(0,e.forwardRef)(function({displayString:a,documentation:b,x:c,y:h,container:i,onMouseEnter:j,onMouseLeave:k,onFindReferences:l,onSearch:m},n){let{t:o}=(0,f.Bd)(),p=(0,e.useRef)(null);(0,e.useImperativeHandle)(n,()=>p.current,[]);let q=i.getBoundingClientRect(),r=c-q.left,s=h-q.top,t=(0,e.useMemo)(()=>g(a),[a]),u=(0,e.useMemo)(()=>(function(a){let b,c=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b/g,e=[],f=0,g=0,h=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b|"[^"]*"|'[^']*'|\b\d+\b/g;for(;null!==(b=h.exec(a));){b.index>f&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f,b.index)},g++));let h=b[0];/^["']/.test(h)?e.push((0,d.jsx)("span",{className:"text-green-400",children:h},g++)):/^\d+$/.test(h)?e.push((0,d.jsx)("span",{className:"text-orange-300",children:h},g++)):c.test(h)?(c.lastIndex=0,e.push((0,d.jsx)("span",{className:"text-pink-400",children:h},g++))):e.push((0,d.jsx)("span",{className:"text-foreground",children:h},g++)),f=b.index+h.length}return f<a.length&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f)},g++)),e})(t),[t]);return(0,e.useEffect)(()=>{if(!p.current)return;let a=p.current,b=i.getBoundingClientRect(),d=a.getBoundingClientRect(),e=c-b.left,f=h-b.top;e+d.width>b.width-8&&(e=b.width-d.width-8),e<8&&(e=8),f+d.height>b.height-8&&(f=f-d.height-24),a.style.left=`${e}px`,a.style.top=`${f}px`},[c,h,i]),(0,d.jsxs)("div",{ref:p,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-xl px-3 py-2 pointer-events-none",style:{left:r,top:s},children:[(0,d.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:u}),b&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:b})]}),(l||m)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1.5"}),(0,d.jsxs)("div",{className:"flex items-center gap-3 pointer-events-auto",onMouseEnter:j,onMouseLeave:k,children:[l&&(0,d.jsx)("button",{onClick:l,className:"text-[11px] text-brand hover:underline cursor-pointer",children:o("hoverTooltip.findReferences")}),m&&(0,d.jsx)("button",{onClick:()=>m(function(a){let b=g(a),c=b.match(/^(?:function|const|let|var|class|interface|type|enum|async function)\s+([a-zA-Z_$][\w$]*)/);if(c)return c[1];let d=a.match(/\([^)]+\)\s+(?:[\w$]+\.)*([a-zA-Z_$][\w$]*)/);if(d)return d[1];let e=b.match(/([a-zA-Z_$][\w$]*)/);return e?e[1]:b.split(/[(\s:]/)[0]}(a)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:o("hoverTooltip.search")})]})]})]})})},24680:(a,b,c)=>{"use strict";c.d(b,{l:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(72529);function h({content:a,containerRef:b,width:c="w-80"}){let{t:i}=(0,f.Bd)(),j=(0,e.useMemo)(()=>(function(a){let b=[],c=a.split("\n"),d=!1;for(let a=0;a<c.length;a++){let e=c[a];if(e.trimStart().startsWith("```")){d=!d;continue}if(d)continue;let f=/^(#{1,6})\s+(.+)$/.exec(e);f&&b.push({level:f[1].length,text:f[2].replace(/\s*#+\s*$/,"").replace(/\\([!-\/:-@[-`{-~])/g,"$1"),sourceLine:a+1})}return b})(a),[a]),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),o=(0,e.useCallback)(a=>{let c=b.current;if(!c)return;let d=c.querySelector(`h1[data-source-start="${a}"], h2[data-source-start="${a}"], h3[data-source-start="${a}"], h4[data-source-start="${a}"], h5[data-source-start="${a}"], h6[data-source-start="${a}"]`);d&&d.scrollIntoView({behavior:"smooth",block:"start"})},[b]);return 0===j.length?null:(0,d.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${k?"w-8":c}`,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border flex-shrink-0",children:[!k&&(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("editor.toc")}),(0,d.jsx)("button",{onClick:()=>l(a=>!a),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:i(k?"editor.expandToc":"editor.collapseToc"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k?(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}):(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),!k&&(0,d.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:j.map((a,b)=>(0,d.jsx)(g.m,{content:a.text,delay:400,children:(0,d.jsx)("button",{onClick:()=>o(a.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-accent ${m===a.sourceLine?"text-brand font-medium bg-brand/5":"text-muted-foreground"}`,style:{paddingLeft:`${(a.level-1)*12+8}px`},children:a.text})},b))})]})}},24724:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{h:()=>k});var e=c(48249),f=c(67484),g=c.n(f),h=c(36043),i=c(7122),j=c(61591);let a={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},l=g().memo(function({item:b,isSelected:c,isExpanded:d,isLoading:g,onSelect:h,onToggle:i,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=b,q=o?a[o]:null,r=(0,f.useCallback)(()=>{m.isDirectory?i(m.path):h(m.path)},[m.isDirectory,m.path,h,i]),s=(0,f.useCallback)(a=>{k(a,m.path,m.isDirectory)},[m.path,m.isDirectory,k]),t=!m.isDirectory&&(".env"===m.name||m.name.startsWith(".env.")),u=o?q.text:p?"text-amber-11":t?"text-yellow-600 dark:text-yellow-500":c&&!m.isDirectory?"text-brand":"text-foreground";return(0,e.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-accent ${c?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?g?(0,e.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,e.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,e.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${d?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,e.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,e.jsx)(j.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,e.jsx)("span",{className:`text-sm truncate flex-1 ${u}`,"data-tooltip":m.isSymlink&&m.symlinkTarget?`${m.path} → ${m.symlinkTarget}`:m.path,children:m.name}),m.isSymlink&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,e.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function k({files:a,selectedPath:b,expandedPaths:c,matchedPaths:d=null,gitStatusMap:g=null,loadingDirs:j,onSelect:m,onToggle:n,cwd:o,shouldScrollToSelected:p=!1,onScrolledToSelected:q,className:r,renderActions:s,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x}){let y=(0,f.useRef)(null),{contextMenu:z,showContextMenu:A,hideContextMenu:B}=(0,i.Ee)(),C=(0,f.useMemo)(()=>(function a(b,c,d,e=null,f=0){let g=[];for(let h of b){if(null!==d&&!d.has(h.path))continue;let b=e?.get(h.path),i=h.isDirectory?function(a,b){if(!b)return!1;let c=a+"/";for(let a of b.keys())if(a.startsWith(c))return!0;return!1}(h.path,e):void 0;g.push({node:h,level:f,gitStatus:b,hasChangedChildren:i}),h.isDirectory&&h.children&&c.has(h.path)&&g.push(...a(h.children,c,d,e,f+1))}return g})(a,c,d,g),[a,c,d,g]),D=(0,h.Te)({count:C.length,getScrollElement:()=>y.current,estimateSize:()=>26,overscan:10});return((0,f.useRef)(q).current=q,0===C.length)?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,e.jsxs)("div",{ref:y,className:r||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,e.jsx)("div",{style:{height:`${D.getTotalSize()}px`,width:"100%",position:"relative"},children:D.getVirtualItems().map(a=>{let d=C[a.index];return(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,e.jsx)(l,{item:d,isSelected:b===d.node.path,isExpanded:c.has(d.node.path),isLoading:j?.has(d.node.path),onSelect:m,onToggle:n,onContextMenu:A,renderActions:s})},d.node.path)})}),z&&(0,e.jsx)(i.ft,{x:z.x,y:z.y,path:z.path,cwd:o,isDirectory:z.isDirectory,onClose:B,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x})]})}d()}catch(a){d(a)}})},24943:(a,b,c)=>{"use strict";c.d(b,{NoteModal:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteModal() from the server but NoteModal 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/NoteModal.tsx","NoteModal")},25465:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ShareReviewToggle:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(33281),j=c(83120);function k({content:a,sourceFile:b}){var c;let d,l,m,n,o,{t:p}=(0,g.Bd)(),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!0),[u,v]=(0,f.useState)(!1),w=q?.active===!0,x=(0,f.useCallback)(async()=>{v(!0);let c=b.split("/").pop()||b,d=await i.t4.runPromiseExit((0,j.bx)({title:c,content:a,sourceFile:b}));if("Success"!==d._tag||!d.value.review){(0,h.oR)(p("toast.reviewCreateFailed"),"error"),v(!1);return}let e=d.value.review;r({id:e.id,active:!0,updatedAt:e.updatedAt||e.createdAt});let f=await i.t4.runPromiseExit((0,j._c)()),g="Success"===f._tag&&f.value.shareBase?`${f.value.shareBase}/review/${e.id}`:`${window.location.origin}/review/${e.id}`;try{await navigator.clipboard.writeText(g)}catch{}(0,h.oR)(e.existing?p("toast.reviewUpdated"):p("toast.reviewCreated"),"success"),v(!1)},[a,b,p]),y=(0,f.useCallback)(async()=>{if(!q)return;v(!0);let a=await i.t4.runPromiseExit((0,j.Gm)(q.id,{active:!1}));"Success"===a._tag?(r(a=>a?{...a,active:!1}:null),(0,h.oR)(p("toast.sharingClosed"),"success")):(0,h.oR)(p("toast.sharingCloseFailed"),"error"),v(!1)},[q,p]),z=(0,f.useCallback)(()=>{u||(w?y():x())},[u,w,x,y]),A=(0,f.useCallback)(()=>{q&&window.open(`${window.location.origin}/review/${q.id}`,"_blank")},[q]);return s?null:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:z,disabled:u,className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${u?"opacity-50 cursor-wait":"cursor-pointer"} ${w?"bg-green-500":"bg-muted-foreground/30"}`,title:w?p("review.closeSharing"):p("review.enableSharing"),children:(0,e.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white transition-transform ${w?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsx)("span",{className:`text-[11px] ${w?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,children:w?p("review.sharing"):p("review.notShared")}),w&&q&&q.updatedAt&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(c=q.updatedAt,d=new Date(c),l=String(d.getMonth()+1).padStart(2,"0"),m=String(d.getDate()).padStart(2,"0"),n=String(d.getHours()).padStart(2,"0"),o=String(d.getMinutes()).padStart(2,"0"),`${l}-${m} ${n}:${o}`)}),(0,e.jsx)("button",{onClick:A,className:"text-[11px] text-brand hover:underline",children:p("review.view")})]})]})}d()}catch(a){d(a)}})},25608:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ProjectItem:()=>l});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(29939),j=c(85655);function k({number:a,isActive:b}){return(0,e.jsxs)("svg",{className:`w-6 h-6 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,e.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),(0,e.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function l({index:a,name:b,cwd:c,isActive:d,collapsed:m,hasUnread:n,isLoading:o,onClick:p,onRemove:q,onOpenNote:r}){let{t:s}=(0,g.Bd)(),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useCallback)(()=>{h.t4.runPromiseExit((0,j.ue)(c)).then(a=>{"Success"===a._tag&&w(a.value.branch)})},[c]),y=(0,f.useCallback)(a=>{a?.type==="watch"&&Array.isArray(a.data)&&a.data.some(a=>"git"===a.type)&&x()},[x]);(0,i.h)({url:`/ws/watch?cwd=${encodeURIComponent(c)}`,onMessage:y});let z=v?m?`${b} \xb7 ${v}`:v:c;return(0,e.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${m?"justify-center":""} ${d?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:p,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),"data-tooltip":z,children:[(0,e.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,e.jsx)(k,{number:a+1,isActive:d}),n&&!d&&!o&&(0,e.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),o&&(0,e.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"})]}),!m&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:`flex-1 truncate text-sm ${d?"text-brand":""}`,children:b}),!o&&d?(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]}),t&&!m&&(0,e.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[r&&(0,e.jsx)("button",{className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),r()},title:s("workspace.projectNotes"),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:"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,e.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors",onClick:a=>{a.stopPropagation(),q()},title:s("workspace.closeProject"),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"})})})]})]})}d()}catch(a){d(a)}})},25667:(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(90018);c(33281),c(85655);var h=c(17966),i=a([h,g]);function j({cwd:a,filePath:b,oldContent:c,newContent:d,isNew:h=!1,isDeleted:i=!1,changedFiles:k,fileGitStatusMap:l,enableComments:m=!1,onContentSearch:n,headerExtraLeft:o,headerExtraRight:p}){let[q,r]=(0,f.useState)(b),[s,t]=(0,f.useState)(null);return(0,e.jsx)(g.O,{cwd:a,highlightedFilePath:b,changedFiles:k,enableComments:m,qnameFilter:s?.changedQnames,qnameFilterFile:q,accentQnames:s?.changedQnames,accentFile:q,addedLines:s?.addedLines,addedLinesFile:q,onFocalChange:a=>a&&r(a),onContentSearch:n,headerExtraLeft:o,headerExtraRight:p})}[h,g]=i.then?(await i)():i,d()}catch(a){d(a)}})},25702:(a,b,c)=>{"use strict";c.d(b,{Providers:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Providers() from the server but Providers 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/Providers.tsx","Providers")},28602:(a,b,c)=>{"use strict";function d(){return!("u"<typeof navigator)&&(/Mac|iPhone|iPad/.test(navigator.platform||"")||navigator.userAgentData?.platform==="macOS")}function e(){return d()?"⌘":"Ctrl+"}c.d(b,{L:()=>d,Mu:()=>e}),process.platform,process.platform,process.platform},28797:(a,b,c)=>{"use strict";function d(a){let b=a.split(".").pop()?.toLowerCase();return b?["ts","tsx","js","jsx","mjs","cjs"].includes(b)?"typescript":["py","pyi"].includes(b)?"python":null:null}c.d(b,{c:()=>d})},29412:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>m});var e=c(48249),f=c(67484),g=c(7833),h=c(2633),i=c(62751),j=c(33281),k=c(80532),l=a([h]);function m({isOpen:a,onClose:b}){let[c,d]=(0,f.useState)([]),[l,o]=(0,f.useState)(!1),[p,q]=(0,f.useState)(""),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(""),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(null),z=(0,f.useCallback)(async()=>{o(!0);let a=await j.t4.runPromiseExit((0,k.Hy)());"Success"===a._tag?d(a.value):console.error("Failed to load skills",a.cause),o(!1)},[]),A=(0,f.useMemo)(()=>{let a=p.trim().toLowerCase();return a?c.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):c},[c,p]),B=(0,f.useCallback)(async()=>{let a=t.trim();if(!a)return;w(!0);let b=await j.t4.runPromiseExit((0,k.L5)(a));if("Success"===b._tag)(0,g.oR)("Skill added","success"),u(""),s(!1),await z(),(0,i.k)();else{let a="Fail"===b.cause._tag?b.cause.error:null,c=a?.cause,d=c instanceof Error?c.message:"Failed to add skill";(0,g.oR)(d,"error")}w(!1)},[t,z]),C=(0,f.useCallback)(async a=>{let b=await j.t4.runPromiseExit((0,k.hp)(a));"Success"===b._tag?(d(b=>b.filter(b=>b.id!==a)),(0,i.k)()):(0,g.oR)("Failed to delete","error")},[]),D=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,g.oR)("Path copied","success")}catch{(0,g.oR)("Failed to copy","error")}},[]);return a?(0,e.jsxs)(e.Fragment,{children:[(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-3xl h-[80vh] mx-4 flex flex-col overflow-hidden",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.jsx)("h2",{className:"text-sm font-medium text-foreground",children:"Skills"}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"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 items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsxs)("svg",{className:"w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"11",cy:"11",r:"7",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-4.35-4.35"})]}),(0,e.jsx)("input",{type:"text",value:p,onChange:a=>q(a.target.value),placeholder:"Search skills...",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsx)("button",{onClick:()=>s(!0),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 active:scale-95 transition-all",children:"+ Add Skill"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:l?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:"Loading..."}):0===A.length?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:0===c.length?'No skills yet. Click "Add Skill" to add one.':"No skills match your search."}):A.map(a=>(0,e.jsx)(n,{skill:a,onPreview:()=>y(a.id),onDelete:()=>C(a.id),onCopyPath:()=>D(a.path)},a.id))})]})]}),r&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:()=>{v||(s(!1),u(""))}}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-lg mx-4 p-5",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:"Add Skill"}),(0,e.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:"Absolute path to SKILL.md"}),(0,e.jsx)("input",{type:"text",value:t,onChange:a=>u(a.target.value),onKeyDown:a=>{"Enter"!==a.key||v||B()},placeholder:"/Users/you/.../skills/foo/SKILL.md",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,e.jsx)("button",{onClick:()=>{s(!1),u("")},disabled:v,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50",children:"Cancel"}),(0,e.jsx)("button",{onClick:B,disabled:v||!t.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:v?"Adding...":"Add"})]})]})]}),x&&(0,e.jsx)(h.d,{skillId:x,onClose:()=>y(null)})]}):null}function n({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let[g,h]=(0,f.useState)(!1);return(0,e.jsx)("div",{className:`border border-border rounded-lg p-3 bg-card hover:bg-accent/30 transition-colors ${a.valid?"":"opacity-60"}`,children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:a.icon?(0,e.jsx)("span",{children:a.icon}):(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 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,e.jsxs)("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",a.name]}),a.description&&(0,e.jsx)("span",{className:"text-sm text-muted-foreground line-clamp-2",children:a.description}),!a.valid&&(0,e.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:"Invalid"})]}),a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 truncate",children:a.argumentHint}),(0,e.jsx)("div",{className:"flex items-center gap-1 mt-1",children:(0,e.jsx)("button",{onClick:d,className:"text-xs text-muted-foreground hover:text-foreground font-mono truncate text-left",title:"Copy path",children:a.path})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,e.jsx)("button",{onClick:b,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:"Preview",children:(0,e.jsxs)("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:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),g?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>{h(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:"Confirm"}),(0,e.jsx)("button",{onClick:()=>h(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:"Cancel"})]}):(0,e.jsx)("button",{onClick:()=>h(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:"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 7h22M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3"})})})]})]})})}h=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},29491:(a,b,c)=>{"use strict";c.d(b,{I18nProvider:()=>g});var d=c(48249);c(67484);var e=c(44384),f=c(208);function g({children:a}){return(0,d.jsx)(e.xC,{i18n:f.A,children:a})}c(33281),c(65484)},29939:(a,b,c)=>{"use strict";c.d(b,{h:()=>g});var d=c(67484),e=c(88055),f=c(21586);function g({url:a,onMessage:b,enabled:c=!0}){(0,d.useRef)(b)}e.EV(f.YA(1),1.5).pipe(e.gP(e.ji(f.YA(10))),e.y$(e.t5(10))),e.EV(f.ne(200),2).pipe(e.gP(e.ji(f.YA(5))),e.y$(e.t5(5))),e.EV(f.YA(1),2).pipe(e.et,e.gP(e.ji(f.YA(30))),e.y$(e.t5(8))),e.ji(f.YA(30)),e.ji(f.YA(1)),e.ji(f.YA(30)),f.ne(50),e.BW},30337:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,15098,23)),Promise.resolve().then(c.t.bind(c,47644,23)),Promise.resolve().then(c.t.bind(c,33859,23)),Promise.resolve().then(c.t.bind(c,98099,23)),Promise.resolve().then(c.t.bind(c,16237,23)),Promise.resolve().then(c.t.bind(c,98562,23)),Promise.resolve().then(c.t.bind(c,36675,23))},30458:(a,b,c)=>{"use strict";c.d(b,{E:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(28602);let i={once:[{labelKey:"scheduledTasks.5minLater",value:5},{labelKey:"scheduledTasks.15minLater",value:15},{labelKey:"scheduledTasks.30minLater",value:30},{labelKey:"scheduledTasks.1hourLater",value:60}],interval:[{labelKey:"scheduledTasks.every15min",value:15},{labelKey:"scheduledTasks.every30min",value:30},{labelKey:"scheduledTasks.every1hour",value:60},{labelKey:"scheduledTasks.every2hours",value:120}],cron:[{labelKey:"scheduledTasks.daily9am",value:"0 9 * * *"},{labelKey:"scheduledTasks.daily6pm",value:"0 18 * * *"},{labelKey:"scheduledTasks.weeklyMon9am",value:"0 9 * * 1"},{labelKey:"scheduledTasks.monthly1st9am",value:"0 9 1 * *"}]};function j({onClose:a,onCreate:b,editTask:c,onUpdate:k}){let{t:l}=(0,f.Bd)(),m=!!c,[n,o]=(0,e.useState)(c?.type||"once"),[p,q]=(0,e.useState)(c?.message||""),[r,s]=(0,e.useState)(c?String(c.delayMinutes||c.intervalMinutes||""):""),[t,u]=(0,e.useState)(c?.cron||""),[v,w]=(0,e.useState)(c?.activeFrom||"09:00"),[x,y]=(0,e.useState)(c?.activeTo||"18:00"),[z,A]=(0,e.useState)(!!(c?.activeFrom&&c?.activeTo)),[B,C]=(0,e.useState)(null),D=(0,e.useRef)(null),E=(0,e.useRef)(null),F=(0,e.useCallback)(()=>{if(!p.trim())return;let d=null;if("once"===n){let a=B||parseInt(r,10);if(!a||a<=0)return;d={message:p.trim(),type:"once",delayMinutes:a}}else if("interval"===n){let a=B||parseInt(r,10);if(!a||a<=0)return;d={message:p.trim(),type:"interval",intervalMinutes:a,...z?{activeFrom:v,activeTo:x}:{}}}else if("cron"===n){let a=B||t.trim();if(!a)return;d={message:p.trim(),type:"cron",cron:a}}d&&(m&&c&&k?k(c.id,d):b(d),a())},[p,n,B,r,t,z,v,x,b,a,m,c,k]);return(0,d.jsxs)("div",{ref:D,className:`w-[28rem] max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lg z-50 ${m?"":"absolute bottom-full left-0 mb-2"}`,onKeyDown:b=>{"Escape"===b.key?a():"Enter"===b.key&&(b.metaKey||b.ctrlKey)&&F()},children:[(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 rounded-t-lg",children:(0,d.jsx)("span",{className:"text-sm font-medium",children:m?l("scheduledTasks.editTask"):l("scheduledTasks.createTask")})}),(0,d.jsxs)("div",{className:"p-4 space-y-4 max-h-[min(52rem,calc(100vh-3rem))] overflow-y-auto",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:l("scheduledTasks.sendMessage")}),(0,d.jsx)("textarea",{ref:E,value:p,onChange:a=>q(a.target.value),placeholder:l("scheduledTasks.messagePlaceholder"),rows:5,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring resize-y min-h-[6rem]"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:l("scheduledTasks.type")}),(0,d.jsx)("div",{className:"flex gap-1",children:["once","interval","cron"].map(a=>(0,d.jsx)("button",{onClick:()=>{o(a),C(null),s(""),u("")},className:`flex-1 px-2 py-1 text-xs rounded transition-colors ${n===a?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"once"===a?l("scheduledTasks.once"):"interval"===a?l("scheduledTasks.interval"):"Cron"},a))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:l("scheduledTasks.quickSelect")}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1",children:i[n].map(a=>(0,d.jsx)("button",{onClick:()=>{C(a.value),"cron"===n?u(String(a.value)):s(String(a.value))},className:`px-2 py-1 text-xs rounded border transition-colors ${B===a.value?"border-brand bg-brand/10 text-brand":"border-border text-muted-foreground hover:text-foreground hover:border-foreground/30"}`,children:l(a.labelKey)},a.labelKey))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:"cron"===n?l("scheduledTasks.customCron"):l("scheduledTasks.customMinutes")}),"cron"===n?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{type:"text",value:t,onChange:a=>{u(a.target.value),C(null)},placeholder:l("scheduledTasks.cronPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring font-mono"}),t.trim()&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:function(a){let b=g.A.t,c=a.trim().split(/\s+/);if(5!==c.length)return null;let[d,e,f,h,i]=c,j={0:b("cron.dowSun"),1:b("cron.dowMon"),2:b("cron.dowTue"),3:b("cron.dowWed"),4:b("cron.dowThu"),5:b("cron.dowFri"),6:b("cron.dowSat")},k={1:`1${b("cron.monthPrefix")}`,2:`2${b("cron.monthPrefix")}`,3:`3${b("cron.monthPrefix")}`,4:`4${b("cron.monthPrefix")}`,5:`5${b("cron.monthPrefix")}`,6:`6${b("cron.monthPrefix")}`,7:`7${b("cron.monthPrefix")}`,8:`8${b("cron.monthPrefix")}`,9:`9${b("cron.monthPrefix")}`,10:`10${b("cron.monthPrefix")}`,11:`11${b("cron.monthPrefix")}`,12:`12${b("cron.monthPrefix")}`};try{let a="";if(d.includes("/")||e.includes("/")){if("*"===e&&d.includes("/"))return b("cron.everyNMinutes",{n:d.split("/")[1]});if("0"===d&&e.includes("/"))return b("cron.everyNHours",{n:e.split("/")[1]});return null}let c=parseInt(e,10),g=parseInt(d,10);if(isNaN(c)&&"*"!==e||isNaN(g)&&"*"!==d)return null;a="*"===e&&"*"===d?b("cron.everyMinute"):"*"===e?b("cron.everyHourAtMin",{m:g}):"*"===d?b("cron.hourlyEveryMin",{h:c}):`${String(c).padStart(2,"0")}:${String(g).padStart(2,"0")}`;let l=[];if("*"!==h){let a=h.split(",").map(a=>k[a]||`${a}${b("cron.monthPrefix")}`);l.push(a.join(", "))}if("*"!==f)if(f.includes("-")){let[a,c]=f.split("-");l.push(b("cron.dayRange",{a,b:c}))}else f.includes(",")?l.push(f.split(",").map(a=>`${a}${b("cron.dayOfMonth")}`).join(", ")):l.push(`${f}${b("cron.dayOfMonth")}`);if("*"!==i)if("1-5"===i)l.push(b("cron.weekdays"));else if("0,6"===i||"6,0"===i)l.push(b("cron.weekends"));else{let a=i.split(",").map(a=>{if(a.includes("-")){let[c,d]=a.split("-");return b("cron.weekdayRange",{a:j[c]||c,b:j[d]||d})}return`${b("cron.weekdayPrefix")}${j[a]||a}`});l.push(a.join(", "))}if(0===l.length&&"*"===f&&"*"===h&&"*"===i)return b("cron.daily",{time:a});return`${l.join(" ")} ${a}`}catch{return null}}(t.trim())||(0,d.jsx)("span",{className:"text-destructive",children:l("scheduledTasks.cronFormat")})})]}):(0,d.jsx)("input",{type:"number",value:r,onChange:a=>{s(a.target.value),C(null)},placeholder:l("scheduledTasks.minutesPlaceholder"),min:1,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]}),"interval"===n&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-1 cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:z,onChange:a=>A(a.target.checked),className:"rounded border-border"}),l("scheduledTasks.limitTimeRange")]}),z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("input",{type:"time",value:v,onChange:a=>w(a.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("scheduledTasks.to")}),(0,d.jsx)("input",{type:"time",value:x,onChange:a=>y(a.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,d.jsx)("button",{onClick:F,disabled:!(p.trim()&&("once"===n||"interval"===n?!!(B||r&&parseInt(r,10)>0):"cron"===n&&!!(B||t.trim()))),className:"w-full py-1.5 text-sm font-medium rounded bg-brand text-white hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:m?l("scheduledTasks.saveBtn",{modKey:(0,h.Mu)()}):l("scheduledTasks.createBtn",{modKey:(0,h.Mu)()})})]})]})}},30894:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{j:()=>a});var e=c(48249),f=c(67484),g=c(44384),h=c(29939),i=c(7833),j=c(95388);let a=(0,f.memo)(function({shortId:a,type:b,onRegister:c,onUnregister:d,fullId:k,projectCwd:l,tabId:m}){let{t:n}=(0,g.Bd)(),[o,p]=(0,f.useState)(!1),[q,r]=(0,f.useState)(""),[s,t]=(0,f.useState)(!1),u=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!k||!l||!m)return;let a=!1,b=new URLSearchParams({cwd:l,tabId:m});return fetch(`/api/terminal/bubble-order?${b.toString()}`).then(a=>a.ok?a.json():null).then(b=>{if(a)return;let c=(b?.data?.titles??{})[k];"string"==typeof c&&r(c)}).catch(()=>{}),()=>{a=!0}},[k,l,m]),(0,h.h)({url:"/ws/global-state",enabled:!!k&&!!l&&!!m,onMessage:a=>{"console-delta"!==a.type||"rename"!==a.op||a.cwd!==l||a.tabId!==m||a.titles&&k&&Object.prototype.hasOwnProperty.call(a.titles,k)&&r(a.titles[k]??"")}});let v=(0,f.useCallback)(async e=>{if(e.stopPropagation(),o)await d(),p(!1),(0,i.oR)(n("toast.disconnected",{id:a}));else{await c(),p(!0);let d=`cockpit ${b} ${a}`;navigator.clipboard.writeText(d),(0,i.oR)(n("toast.copiedCommand",{command:d}))}},[o,a,b,c,d,n]),w=!!(k&&l&&m),x=(0,f.useCallback)(a=>{a.stopPropagation(),w&&t(!0)},[w]),y=(0,f.useCallback)(async a=>{if(k&&l&&m)try{await fetch("/api/terminal/bubble-order",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:l,tabId:m,titles:{[k]:a}})}),r(a),t(!1)}catch{t(!1)}},[k,l,m]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{onClick:v,onDoubleClick:a=>a.stopPropagation(),className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:o?n("shortIdBadge.clickToDisconnect"):n("shortIdBadge.clickToRegister"),children:[(0,e.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${o?"bg-green-500":"bg-muted-foreground/40"}`}),a]}),w&&(q?(0,e.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground",title:n("shortIdBadge.titleSet",{title:q})||q,children:[(0,e.jsx)("span",{className:"px-1 py-0.5 rounded bg-muted/40 max-w-[120px] truncate",children:q}),(0,e.jsx)("button",{ref:u,onClick:x,className:"opacity-50 hover:opacity-100 transition-opacity","aria-label":n("shortIdBadge.editTitle"),title:n("shortIdBadge.editTitle"),children:"✎"})]}):(0,e.jsxs)("button",{ref:u,onClick:x,className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground/50 hover:text-muted-foreground italic transition-colors",title:n("shortIdBadge.setTitle"),children:["(",n("shortIdBadge.setTitlePlaceholder"),") ✎"]})),(0,e.jsx)(j.V,{open:s,anchorRef:u,initialValue:q,onCancel:()=>t(!1),onSave:y})]})});d()}catch(a){d(a)}})},32459:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>j});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(85655);function j({currentCwd:a,onSwitchProject:b,collapsed:c,sessions:d}){let{t:k}=(0,g.Bd)(),[l,m]=(0,f.useState)(!1),[n,o]=(0,f.useState)(0),p=(0,f.useRef)(null),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)({}),u=(0,f.useCallback)((a,b)=>{let c=b.currentTarget.getBoundingClientRect(),d=c.top;d+260>window.innerHeight&&(d=Math.max(8,window.innerHeight-260-8)),r({session:a,top:d,left:c.right+8}),t(b=>a.cwd in b?b:(h.t4.runPromiseExit((0,i.ue)(a.cwd)).then(b=>{"Success"===b._tag&&t(c=>({...c,[a.cwd]:b.value.branch}))}),{...b,[a.cwd]:null}))},[]),v=(0,f.useCallback)(()=>r(null),[]),w=(0,f.useCallback)(a=>{b(a.cwd,a.sessionId),m(!1),r(null)},[b]),x=d.filter(a=>"loading"===a.status).length,y=d.filter(a=>"unread"===a.status).length,z=(0,f.useCallback)(a=>{let b=n-a,c=Math.floor(b/6e4);if(c<1)return k("common.justNow");if(c<60)return k("common.minutesAgo",{count:c});let d=Math.floor(c/60);return d<24?k("common.hoursAgo",{count:d}):k("common.daysAgo",{count:Math.floor(d/24)})},[k,n]),A=a=>a.split("/").pop()||a;return(0,e.jsxs)("div",{className:"relative",ref:p,children:[(0,e.jsxs)("button",{onClick:()=>{o(Date.now()),m(!l)},className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"w-full justify-center":"w-full"}`,title:k("sessions.recentSessions"),children:[(0,e.jsx)("svg",{className:"w-5 h-5 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"})}),!c&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:k("sessions.recentSessions")}),x>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-orange-9 animate-pulse ${c?"absolute -top-1 -right-1":""}`,children:x}),y>0&&(0,e.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 ${c&&!x?"absolute -top-1 -right-1":""}`,children:y})]}),l&&(0,e.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,e.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:k("sessions.recentSessions")}),x>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",k("sessions.runningCount",{count:x}),")"]}),y>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-red-500",children:["(",k("sessions.unreadCount",{count:y}),")"]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===d.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:k("sessions.noSessions")}):d.map((b,c)=>(0,e.jsxs)("button",{onClick:()=>w(b),onMouseEnter:a=>u(b,a),onMouseLeave:v,className:`w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 ${c!==d.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:[(0,e.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${"loading"===b.status?"bg-orange-9 animate-pulse":"unread"===b.status?"bg-red-500":"bg-muted-foreground/30"}`}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:A(b.cwd)}),"loading"===b.status&&(0,e.jsx)("span",{className:"text-xs text-orange-11 flex-shrink-0",children:k("sessions.running")}),"unread"===b.status&&(0,e.jsx)("span",{className:"text-xs text-red-500 flex-shrink-0",children:k("sessions.done")}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:z(b.lastActive)})]}),(b.lastUserMessage||b.title)&&(0,e.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:b.lastUserMessage||b.title})]})]},`${b.cwd}-${b.sessionId}`))})]}),q&&(0,e.jsxs)("div",{className:"fixed z-[60] w-72 max-h-[260px] overflow-y-auto bg-popover border border-border rounded-lg shadow-lg p-3 pointer-events-none",style:{top:q.top,left:q.left},children:[(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:A(q.session.cwd)}),s[q.session.cwd]&&(0,e.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-normal min-w-0",children:[(0,e.jsxs)("svg",{className:"w-3 h-3 flex-shrink-0 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"6",cy:"6",r:"2.5"}),(0,e.jsx)("circle",{cx:"6",cy:"18",r:"2.5"}),(0,e.jsx)("circle",{cx:"18",cy:"7",r:"2.5"}),(0,e.jsx)("path",{strokeLinecap:"round",d:"M6 8.5v7M8.5 6.5h4.5a3 3 0 013 3v0"})]}),(0,e.jsx)("span",{className:"truncate",children:s[q.session.cwd]})]}),(q.session.firstMessages?.length??0)>0||(q.session.lastMessages?.length??0)>0?(0,e.jsxs)("div",{className:"space-y-0.5 text-xs border-t border-border/50 mt-2 pt-2",children:[q.session.firstMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`f-${b}`)),(q.session.lastMessages?.length??0)>0&&(0,e.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),q.session.lastMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`l-${b}`))]}):q.session.lastUserMessage||q.session.title?(0,e.jsx)("div",{className:"text-xs text-foreground/90 border-t border-border/50 mt-2 pt-2 line-clamp-3 break-words",children:q.session.lastUserMessage||q.session.title}):null]})]})}d()}catch(a){d(a)}})},32465:(a,b,c)=>{"use strict";c.d(b,{Y:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(76592),h=c(46674),i=c(59347),j=c(24520),k=c(33281),l=c(23328);function m({onClose:a,onSave:b}){let{t:c}=(0,f.Bd)(),[n,o]=(0,e.useState)({}),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!0);(0,e.useCallback)(async()=>{u(!0);let a=await k.t4.runPromiseExit((0,l.Jn)());"Success"===a._tag?o(a.value):console.error("Failed to load aliases:",a.cause),u(!1)},[]);let v=()=>{p.trim()&&r.trim()&&(o(a=>({...a,[p.trim()]:r.trim()})),q(""),s(""))},w=async()=>{let c=await k.t4.runPromiseExit((0,l.cv)(n));"Success"===c._tag?(b(n),a()):console.error("Failed to save aliases:",c.cause)};return(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,d.jsx)(g.A,{className:"w-5 h-5"}),c("aliasManager.title")]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("aliasManager.description")})]}),(0,d.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,d.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:t?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:c("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(n).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void o(b=>({...b,[a]:c}))},placeholder:c("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,d.jsx)("button",{onClick:()=>{o(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:p,onChange:a=>q(a.target.value),placeholder:c("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),v())}})]}),(0,d.jsx)("input",{type:"text",value:r,onChange:a=>s(a.target.value),placeholder:c("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),v())}})]}),(0,d.jsx)("button",{onClick:v,disabled:!p.trim()||!r.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,d.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,d.jsx)("strong",{children:c("aliasManager.usage")}),c("aliasManager.usageDesc")]}),(0,d.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(n).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:c("aliasManager.noAliases")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:c("common.cancel")}),(0,d.jsx)("button",{onClick:w,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:c("common.save")})]})]})})}},32580:(a,b,c)=>{"use strict";function d(a,b){let c=a.split("\n"),d=b.split("\n"),e=[],f=c.length,g=d.length,h=Array(f+1).fill(null).map(()=>Array(g+1).fill(0));for(let a=1;a<=f;a++)for(let b=1;b<=g;b++)c[a-1]===d[b-1]?h[a][b]=h[a-1][b-1]+1:h[a][b]=Math.max(h[a-1][b],h[a][b-1]);let i=f,j=g,k=[];for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(k.push({type:"unchanged",content:c[i-1],oldLineNum:i,newLineNum:j}),i--,j--):j>0&&(0===i||h[i][j-1]>=h[i-1][j])?(k.push({type:"added",content:d[j-1],newLineNum:j}),j--):(k.push({type:"removed",content:c[i-1],oldLineNum:i}),i--);for(;k.length>0;)e.push(k.pop());return e}c.d(b,{X:()=>d})},33281:(a,b,c)=>{"use strict";c.d(b,{t4:()=>F});var d=c(95753),e=c(88512),f=c(79606),g=c(28582),h=c(61808);let i=d.Um(h.j9,h.dl((a=>{switch((a??"").toLowerCase()){case"all":return g.u8;case"trace":return g.Cn;case"debug":return g.y;case"info":default:return g.R2;case"warning":case"warn":return g.N5;case"error":return g.$D;case"fatal":return g.Lj;case"none":return g.NV}})(process.env.COCKPIT_LOG_LEVEL)));var j=c(1239),k=c(69063);let l=globalThis,m=l.__cockpitSpanRing??={buffer:[],index:new Map},n=a=>{let b="abcdef0123456789",c="";for(let d=0;d<a;d++)c+=b.charAt(Math.floor(Math.random()*b.length));return c};class o{constructor(a,b,c,d,e,f){this.name=a,this.parent=b,this.context=c,this.startTime=e,this.kind=f,this._tag="Span",this.sampled=!0,this.attributes=new Map,this.events=[],this.traceId=j.Ru(b)?b.value.traceId:n(32),this.spanId=n(16),this.status={_tag:"Started",startTime:e},this.links=Array.from(d),function(a){if(m.buffer.push(a),m.index.set(a.spanId,m.buffer.length-1),m.buffer.length>500){m.buffer.shift(),m.index.clear();for(let a=0;a<m.buffer.length;a++)m.index.set(m.buffer[a].spanId,a)}}(function(a,b,c,d,e,f){return{traceId:b,spanId:a,parentSpanId:c,name:d,kind:e,startTimeNs:f.toString(),endTimeNs:null,durationMs:null,attributes:{},events:[],status:"started"}}(this.spanId,this.traceId,function(a){return j.Ru(a)?a.value.spanId:null}(b),a,f,e))}end(a,b){this.status={_tag:"Ended",endTime:a,exit:b,startTime:this.status.startTime},function(a,b,c){let d=m.index.get(a);if(void 0===d)return;let e=m.buffer[d];if(!e)return;let f=Number(b-BigInt(e.startTimeNs))/1e6;m.buffer[d]={...e,endTimeNs:b.toString(),durationMs:Math.round(100*f)/100,status:"Success"===c._tag?"ok":"error",errorMessage:"Failure"===c._tag?function(a){if(a instanceof Error)return a.message;if("string"==typeof a)return a;try{return JSON.stringify(a)}catch{return String(a)}}(c.cause):void 0}}(this.spanId,a,"Success"===b._tag?{_tag:"Success"}:{_tag:"Failure",cause:b.cause})}attribute(a,b){this.attributes.set(a,b),function(a,b,c){let d=m.index.get(a);if(void 0===d)return;let e=m.buffer[d];e&&(m.buffer[d]={...e,attributes:{...e.attributes,[b]:c}})}(this.spanId,a,b)}event(a,b,c){this.events.push([a,b,c??{}]),function(a,b,c,d){let e=m.index.get(a);if(void 0===e)return;let f=m.buffer[e];f&&(m.buffer[e]={...f,events:[...f.events,{name:b,timeNs:c.toString(),attributes:d}]})}(this.spanId,a,b,c)}addLinks(a){this.links.push(...a)}}let p=k.L8({span:(a,b,c,d,e,f)=>new o(a,b,c,d,e,f),context:a=>a()}),q=d.Py(k.sh,p);d.Ie;var r=c(66473);let s=r.eu("dev","prod")("COCKPIT_ENV").pipe(r.IQ("prod")),t=r.Yj("COCKPIT_HOST").pipe(r.IQ("127.0.0.1")),u=r.nd("COCKPIT_PORT").pipe(r.NW(()=>r.nd("PORT")),r.IQ(3457)),v=r.uK(r.Yj("COCKPIT_OPEN_PROJECT")).pipe(r.Tj(a=>"Some"===a._tag?a.value:void 0)),w=r.zM("COCKPIT_NO_OPEN").pipe(r.IQ(!1)),x=r.Yj("COCKPIT_LOG_LEVEL").pipe(r.IQ("info"));f.gen(function*(){let a=yield*s,b=yield*t,c=yield*u,d=yield*v,e=yield*w,g=yield*x,h=yield*f.sync(()=>{let a="u">typeof process?process.env:void 0,b=a?.HOME||a?.USERPROFILE||".",c=a?.COCKPIT_HOME;return c?c.replace(/^~(?=$|\/)/,b):b+"/.cockpit"});return{env:a,host:b,port:3457===c&&"dev"===a?3456:c,cockpitDir:h,openProject:d,openBrowser:!e,logLevel:g,logFile:h+"/logs/cockpit.log"}}).pipe(f.orDie);let y=d.Ie;var z=c(7846),A=c(55805),B=c(23734);let C=d.P1(B.d,f.gen(function*(){let a=yield*z.dT();return yield*f.acquireRelease(f.sync(()=>b=>{f.runFork(z.mk(a,b))}),a=>f.sync(()=>{})),B.d.of({publish:(a,b)=>f.sync(()=>{}),subscribe:b=>A.qdp(a).pipe(A.pbD(a=>{var c;return c=a.data,!!c&&"object"==typeof c&&(c.topic===b.id||c.type===b.legacyType)}),A.TjK(a=>((a,b)=>{if(a.topic===b.id)return a.msg;let{type:c,...d}=a;return d})(a.data,b)))})})),D=d.Um(i,q,y),E=d.Um(D,C),F=e.L8(E);f.void},33988:(a,b,c)=>{"use strict";c.d(b,{B:()=>f});var d=c(67484);c(57031),c(88214);var e=c(76334);function f(a,b,c,f,g){let h=(0,d.useMemo)(()=>(0,e.p)(a),[a]),[i,j]=(0,d.useState)(!1),k=(0,d.useRef)(null);(0,d.useRef)([]),(0,d.useRef)(null),(0,d.useRef)(!1),(0,d.useRef)(c);let l=(0,d.useRef)([]);(0,d.useCallback)(a=>{let c=b.current;if(!c?.contentWindow){let b=k.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"browser:cmd-result",reqId:a.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}c.contentWindow.postMessage({type:"cockpit:cmd",reqId:a.reqId,action:a.action,params:a.params},"*")},[b]);let m=(0,d.useCallback)(()=>i&&k.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(a=>{l.current.push(a),i||j(!0)}),[i]);return{shortId:h,connected:i,connect:m,disconnect:(0,d.useCallback)(()=>{j(!1)},[])}}},34001:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{NoteModal:()=>z});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(13191),j=c(63831),k=c(19043),l=c(48197),m=c(9731),n=c(44551),o=c(53116),p=c(16512),q=c(6993),r=c(11537),s=c(73555),t=c(19545),u=c(92451),v=c(83179),w=c(33281),x=c(79606),y=c(65484);function z({isOpen:a,onClose:b,projectCwd:c,projectName:d}){let{t:A}=(0,g.Bd)(),[B,C]=(0,f.useState)(!0),[D,E]=(0,f.useState)(!1),F=(0,f.useRef)(null),G=(0,f.useRef)(!1),[H,I]=(0,f.useState)(null),J=(0,f.useRef)(null),K=(0,f.useCallback)(async a=>{E(!0);let b=await w.t4.runPromiseExit((0,y.Cq)(c,a).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to save note:",a)))));"Success"===b._tag&&(G.current=!1),E(!1)},[c]),L=(0,f.useCallback)(a=>{G.current=!0,F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{K(a)},5e3)},[K]),M=(0,i.hG)({immediatelyRender:!1,extensions:[j.A.configure({heading:{levels:[1,2,3]}}),k.A.configure({placeholder:()=>h.A.t("editor.placeholder")}),l.XI.configure({resizable:!0}),m.H,n.n,o.A,p._,r.Ay.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),q.L.configure({nested:!0}),s.o.configure({html:!0,transformCopiedText:!0,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},handleClick:(a,b,c)=>{if(c.metaKey||c.ctrlKey){let c=a.state.doc.resolve(b).marks().find(a=>"link"===a.type.name)?.attrs;if(c?.href)return window.open(c.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(a,b)=>{if("Backspace"===b.key&&N.current){let a=N.current;if(a.isActive("codeBlock")){let{$from:b}=a.state.selection,c=b.node(b.depth);if("codeBlock"===c.type.name&&""===c.textContent)return a.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==b.key||H||setTimeout(()=>{if(!N.current)return;let{from:a}=N.current.state.selection,b=N.current.state.doc.textBetween(Math.max(0,a-1),a,"\n");if("/"===b){J.current=a;let b=N.current.view.coordsAtPos(a);I({query:"",position:{top:b.bottom+4,left:b.left}})}},0),!1}},onUpdate:({editor:a})=>{let b=(0,t.up)(a);if(L(b),null!==J.current){let{from:b}=a.state.selection;if(b<J.current)I(null),J.current=null;else{let c=a.state.doc.textBetween(J.current,b,"\n");c.includes(" ")||c.includes("\n")?(I(null),J.current=null):I(a=>a?{...a,query:c}:null)}}}}),N=(0,f.useRef)(M),O=(0,f.useCallback)(()=>{if(F.current&&(clearTimeout(F.current),F.current=null),G.current&&M){let a=(0,t.up)(M);K(a)}I(null),J.current=null,b()},[M,K,b]);return a?(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:O}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",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-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:d?A("editor.noteTitle",{name:d}):A("editor.noteUntitled")}),D&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:A("editor.saving")})]}),(0,e.jsx)("button",{onClick:O,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)(v.NoteToolbar,{editor:M}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:B?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,e.jsx)("span",{children:A("common.loading")})}):(0,e.jsx)(i.$Z,{editor:M})})]}),H&&M&&(0,e.jsx)(u.U,{editor:M,query:H.query,position:H.position,onClose:()=>{I(null),J.current=null}})]}):null}d()}catch(a){d(a)}})},34102:(a,b,c)=>{"use strict";c.d(b,{B:()=>g});var d=c(48249),e=c(67484),f=c(74429);function g(){let[a,b]=(0,e.useState)(null);(0,e.useRef)(null).current=a,(0,e.useRef)(null);let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({left:0,top:0}),[i,j]=(0,e.useState)(!1);return i&&a?(0,f.createPortal)((0,d.jsx)("div",{ref:c,className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none max-w-[80vw] overflow-hidden text-ellipsis",style:{left:g.left,top:g.top},children:a.text}),document.body):null}},35208:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{xU:()=>A,xZ:()=>z});var e=c(48249),f=c(67484),g=c(74429),h=c(44384),i=c(36043),j=c(74754),k=c(91579),l=c(7122),m=c(7031),n=c(41051),o=c(42140),p=c(32580),q=c(73414),r=c(7833),s=c(38896),t=c(36984),u=c(74542),v=c(70596),w=c(37690),x=a([s,t]);function y(a){return a.params?`${a.name}(${a.params.join(", ")})`:a.name}function z({oldContent:a,newContent:b,filePath:c,isNew:d=!1,isDeleted:x=!1,cwd:A,enableComments:B=!1,onPreview:C,previewLabel:D,onContentSearch:E,targetLine:F,compact:G=!1,symbols:H}){let{t:I}=(0,h.Bd)(),J=D??I("common.preview"),K=(0,f.useMemo)(()=>(0,p.X)(a,b),[a,b]),L=(0,f.useRef)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useRef)(!1);let[O,P]=(0,f.useState)(!1),Q=(0,l.iN)(),R=(0,m.r)(),S=B&&!!A,{comments:T,addComment:U,updateComment:V,deleteComment:W,refresh:X}=(0,j._)({cwd:A||"",filePath:c}),[Y,Z]=(0,f.useState)(null),[$,_]=(0,f.useState)(null),{toolbarRef:aa,bumpRef:ab,clearToolbar:ac}=(0,w.L)({enabled:S,container:$,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-new-line]");if(!c)return null;let d=parseInt(c.getAttribute("data-new-line")||"0",10);return!Number.isFinite(d)||d<=0?null:{start:d,end:d}},buildLineSnapshot:({start:a,end:b})=>{let c=[],d=0;for(let e of K)("unchanged"===e.type||"added"===e.type)&&++d>=a&&d<=b&&c.push(e.content);return c.join("\n")}}),[ad,ae]=(0,f.useState)(null),[af,ag]=(0,f.useState)(null),ah=(0,f.useMemo)(()=>{let a=new Set;for(let b of T)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[T]),ai=(0,f.useMemo)(()=>{let a=new Map;for(let b of T){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[T]),aj=(0,f.useCallback)((a,b)=>{b.stopPropagation(),Z({comment:a,x:b.clientX,y:b.clientY}),ac(),ae(null),ag(null)},[ac]),ak=(0,f.useCallback)(()=>{let a=aa.current;a&&(ae({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ac())},[ac,aa]),al=(0,f.useCallback)(()=>{let a=aa.current;a&&(ag({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ac())},[ac,aa]),am=(0,f.useCallback)(()=>{let a=aa.current;if(!a||!E)return;let b=a.selectedText.trim();ac(),b&&E(b)},[E,ac,aa]),an=(0,f.useCallback)(async a=>{if(af&&R&&A)try{let b=await (0,k.$3)(A),d=[];for(let a of b)d.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});d.push({filePath:c,startLine:af.range.start,endLine:af.range.end,codeContent:af.lineSnapshot});let e=(0,k.Gw)(d,a);R.sendMessage(e),await (0,k.RP)(A),X(),ag(null)}catch(a){console.error("Failed to send to AI:",a)}},[af,R,c,A,X]),ao=(0,f.useCallback)(async a=>{ad&&(await U(ad.range.start,ad.range.end,a,ad.selectedText),ae(null))},[ad,U]),{leftLines:ap,rightLines:aq}=(0,f.useMemo)(()=>{let a=[],b=[],c=0,d=0;for(let e=0;e<K.length;e++){let f=K[e];if("unchanged"===f.type){for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});c++,d++,a.push({lineNum:c,content:f.content,type:"unchanged",originalIdx:e}),b.push({lineNum:d,content:f.content,type:"unchanged",originalIdx:e})}else"removed"===f.type?(c++,a.push({lineNum:c,content:f.content,type:"removed",originalIdx:e})):"added"===f.type&&(d++,b.push({lineNum:d,content:f.content,type:"added",originalIdx:e}))}for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:a,rightLines:b}},[K]),ar=(0,f.useMemo)(()=>K.map(a=>a.content),[K]),as=(0,s.C)(ar,c),[at,au]=(0,f.useState)(()=>new Map),av=(0,f.useMemo)(()=>H??[],[H]),{rows:aw,gaps:ax}=(0,f.useMemo)(()=>G?(0,q.pU)(ap,aq,at,av):{rows:ap.map((a,b)=>({kind:"diff",idx:b})),gaps:[]},[G,ap,ap,aq,at,av]),ay=(0,f.useCallback)((a,b)=>{let c=ax.find(b=>b.id===a);c&&au(d=>{let e=d.get(a)??{topRevealed:0,bottomRevealed:0},f=c.endIdx-c.startIdx+1-e.topRevealed-e.bottomRevealed;if(f<=0)return d;let g=Math.min(q.YO,f),h="up"===b?{...e,topRevealed:e.topRevealed+g}:{...e,bottomRevealed:e.bottomRevealed+g};return new Map(d).set(a,h)})},[ax]);(0,f.useCallback)(a=>{for(let b of ax)if(a>=b.startIdx&&a<=b.endIdx)return b.id;return null},[ax]);let az=(0,f.useCallback)(a=>aw[a]?.kind==="gap-label"?28:20,[aw]),aA=(0,f.useCallback)(a=>{let b=aw[a];if(!b)return a;if("gap-label"===b.kind)return`gl:${b.gapId}`;if("gap-expand"===b.kind)return`ge:${b.gapId}:${b.direction}`;let c=ap[b.idx],d=aq[b.idx];return`d:${c?.lineNum??"x"}:${c?.type??"x"}:${d?.lineNum??"x"}:${d?.type??"x"}`},[aw,ap,aq]),aB=(0,i.Te)({count:aw.length,getScrollElement:()=>L.current,estimateSize:az,getItemKey:aA,overscan:20}),aC=d?"w-1/4":x?"w-3/4":"w-1/2",aD=d?"w-3/4":x?"w-1/4":"w-1/2",aE=(0,f.useMemo)(()=>aw.map(a=>{if("diff"!==a.kind)return{type:"unchanged"};let b=ap[a.idx],c=aq[a.idx];return"removed"===b.type?{type:"removed"}:c?.type==="added"?{type:"added"}:{type:"unchanged"}}),[aw,ap,aq]),aF=aB.getTotalSize(),aG=aB.getVirtualItems();return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,e.jsx)("div",{className:`${aC} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:d?"(New File)":x?"Deleted":"Old"}),(0,e.jsxs)("div",{className:`${aD} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,e.jsx)("span",{className:"block text-center",children:x?"(Deleted)":"New"}),(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[C&&(0,e.jsx)("button",{onClick:C,className:"text-muted-foreground hover:text-foreground transition-colors",children:J}),!x&&b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,r.oR)(I("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:I("common.copy")})]})]}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:L,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,e.jsxs)("div",{className:"flex",style:{height:`${aF}px`},children:[(0,e.jsx)("div",{ref:M,className:`${aC} overflow-x-auto border-r border-border`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:aG.map(a=>{let b=aw[a.index];if("gap-expand"===b.kind||"gap-label"===b.kind){let c="gap-label"===b.kind;return(0,e.jsx)("div",{ref:aB.measureElement,"data-index":a.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:c?"bg-accent border-y border-border":""},a.key)}let c=ap[b.idx];return(0,e.jsxs)("div",{ref:aB.measureElement,"data-index":a.index,"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===c.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:c.lineNum||""}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c.originalIdx>=0&&as[c.originalIdx]||(0,t.ZD)(c.content||" ")}})]},a.key)})})}),(0,e.jsx)("div",{ref:N,className:`${aD} overflow-x-auto`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:aG.map(a=>{let b=aw[a.index];if("gap-expand"===b.kind)return(0,e.jsx)("button",{ref:aB.measureElement,"data-index":a.index,type:"button",onClick:()=>ay(b.gapId,b.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-accent hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:I("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),"aria-label":I("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),children:(0,e.jsx)("span",{className:"select-none",children:I("diffViewer.gap.more",{count:b.revealCount})})},a.key);if("gap-label"===b.kind)return(0,e.jsxs)("div",{ref:aB.measureElement,"data-index":a.index,"data-gap-id":b.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,e.jsx)("span",{className:"flex-shrink-0",children:I("diffViewer.gap.hidden",{count:b.hiddenCount})}),b.enclosingFn&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,e.jsx)("span",{className:"truncate min-w-0 font-medium",title:y(b.enclosingFn),children:y(b.enclosingFn)})]})]},a.key);let c=aq[b.idx],d=c?.lineNum||0,f=d>0&&ah.has(d),g=ai.get(d),h=g?.[0],i=ad&&d>=ad.range.start&&d<=ad.range.end,j=af&&d>=af.range.start&&d<=af.range.end,k=i||j;return(0,e.jsxs)("div",{ref:aB.measureElement,"data-index":a.index,"data-new-line":d||void 0,"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:`flex ${k?"bg-blue-9/20":f?"bg-amber-9/10":c?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${k?"bg-blue-9/30":""}`,style:{width:S?"52px":"40px"},children:[S&&d>0&&f&&h&&(0,e.jsx)("button",{onClick:a=>aj(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:I("codeViewer.nComments",{count:g?.length}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),S&&d>0&&!f&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"flex-1 text-right pr-1",children:d||""})]}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c?.originalIdx>=0&&as[c.originalIdx]||(0,t.ZD)(c?.content||" ")}})]},a.key)})})})]})}),(0,e.jsx)(u.b,{lines:aE,containerRef:L})]}),O&&Q&&(0,g.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(n.f,{floatingToolbarRef:aa,bumpRef:ab,container:Q,onAddComment:ak,onSendToAI:al,onSearch:E?am:void 0,isChatLoading:R?.isLoading??!1}),ad&&(0,e.jsx)(o.t,{x:ad.x,y:ad.y,range:ad.range,lineSnapshot:ad.lineSnapshot,container:Q,onSubmit:ao,onClose:()=>ae(null)}),af&&(0,e.jsx)(o.G,{x:af.x,y:af.y,range:af.range,filePath:c,lineSnapshot:af.lineSnapshot,container:Q,onSubmit:an,onClose:()=>ag(null),isChatLoading:R?.isLoading}),Y&&(0,e.jsx)(v.t,{x:Y.x,y:Y.y,comment:Y.comment,container:Q,onClose:()=>Z(null),onUpdateComment:V,onDeleteComment:W})]}),Q)]})}function A({oldContent:a,newContent:b,filePath:c}){let d=(0,f.useMemo)(()=>(0,p.X)(a,b),[a,b]),g=(0,f.useRef)(null),h=(0,f.useMemo)(()=>d.map(a=>a.content),[d]),j=(0,s.C)(h,c),k=(0,f.useCallback)(a=>{let b=d[a];return b?`${b.type}:${b.oldLineNum??"x"}:${b.newLineNum??"x"}`:a},[d]),l=(0,i.Te)({count:d.length,getScrollElement:()=>g.current,estimateSize:()=>20,getItemKey:k,overscan:20});return(0,e.jsx)("div",{ref:g,className:"font-mono text-sm overflow-auto h-full",children:(0,e.jsx)("div",{style:{height:`${l.getTotalSize()}px`,position:"relative"},children:l.getVirtualItems().map(a=>{let b=d[a.index];return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===b.type?"bg-red-9/15 dark:bg-red-9/25":"added"===b.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==b.type?b.oldLineNum:""}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==b.type?b.newLineNum:""}),(0,e.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===b.type?"text-red-11":"added"===b.type?"text-green-11":"text-slate-9"}`,children:"removed"===b.type?"-":"added"===b.type?"+":" "}),(0,e.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:j[a.index]||(0,t.ZD)(b.content||" ")}})]},a.key)})})})}[s,t]=x.then?(await x)():x,d()}catch(a){d(a)}})},36295:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{G:()=>C,p:()=>A});var e=c(48249),f=c(67484),g=c(46674),h=c(15273),i=c(62956),j=c(82594),k=c(10316),l=c(72419),m=c(44218),n=c(7833),o=c(44384),p=c(34678),q=c(76334),r=c(30894),s=c(28602),t=c(79606),u=c(33281),v=c(23328),w=a([r]);r=(w.then?(await w)():w)[0];let y=(0,f.lazy)(()=>c.e(3792).then(c.bind(c,33792)).then(a=>({default:a.XtermRenderer}))),z={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},A=360,B=/\x1b\[[0-9;]*m/g;function x({output:a,query:b,mode:c,currentIdx:d,matchListRef:g}){let h=(0,f.useRef)(null);h.current||(h.current=new p.v,h.current.use_classes=!0);let i=a.split("\n"),j=b.toLowerCase(),k=0;return g.current=[],(0,e.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:i.map((a,b)=>{let f=a.replace(B,""),i=f.toLowerCase().includes(j);if("filter"===c&&!i)return null;if(!i){let c=h.current.ansi_to_html(a);return(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:c}},b)}let l=[],m=0,n=f.toLowerCase(),o=0;for(;o<n.length;){let a=n.indexOf(j,o);if(-1===a)break;a>m&&l.push((0,e.jsx)("span",{children:f.slice(m,a)},`t${m}`));let b=k++,c=b===d;l.push((0,e.jsx)("mark",{ref:a=>{g.current[b]=a},className:c?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:f.slice(a,a+j.length)},`m${a}`)),o=m=a+j.length}return m<f.length&&l.push((0,e.jsx)("span",{children:f.slice(m)},`t${m}`)),(0,e.jsx)("div",{children:l},b)})})}let C=(0,f.memo)(function({commandId:a,tabId:b,projectCwd:c,command:d,output:w,exitCode:B,isRunning:C,selected:D,onSelect:E,onInterrupt:F,onStdin:G,onDelete:H,onRerun:I,timestamp:J,usePty:K,subscribePtyOutput:L,subscribePtyReset:M,subscribePtyRefresh:N,onPtyResize:O,onToggleMaximize:P,maximized:Q,expandedHeight:R,bubbleContentHeight:S,onTitleMouseDown:T}){let{t:U}=(0,o.Bd)(),V=(0,f.useRef)(null),W=(0,f.useRef)(null),X=(0,f.useRef)(!0),Y=(0,f.useRef)(null),Z=(0,f.useRef)(null),$=(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}`})(J),_=a&&b?(0,q.p)(b+a):void 0,[aa,ab]=(0,f.useState)(!1),[ac,ad]=(0,f.useState)(""),ae=(0,f.useRef)(null),af=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!L||!a)return;let b=()=>{if(ae.current){let b=ae.current.write;return L(a,b)}return null},c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[L,a]),(0,f.useEffect)(()=>{if(!M||!a)return;let b=()=>{if(ae.current){let b=ae.current.reset;return M(a,b)}return null},c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[M,a]),(0,f.useEffect)(()=>{if(!N||!a)return;let b=()=>{if(ae.current){let b=ae.current.refresh;return N(a,b)}return null},c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[N,a]);let[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(""),[ak,al]=(0,f.useState)("search"),[am,an]=(0,f.useState)(0),ao=(0,f.useRef)([]),ap=(0,f.useRef)(null),aq=(0,f.useRef)(0);(0,f.useEffect)(()=>{ap.current||(ap.current=new p.v,ap.current.use_classes=!0)},[]),(0,f.useLayoutEffect)(()=>{let a=W.current;if(a&&ap.current){if(w.length<aq.current&&(ap.current=new p.v,ap.current.use_classes=!0,aq.current=0,a.innerHTML=""),w.length>aq.current){let b=w.slice(aq.current),c=ap.current.ansi_to_html(b);aq.current=w.length,a.insertAdjacentHTML("beforeend",c)}if(V.current){let a=V.current.scrollHeight>V.current.clientHeight;ab(a),a&&(V.current.scrollTop=V.current.scrollHeight)}}},[w]),(0,f.useEffect)(()=>(C&&X.current&&V.current&&(null!==Y.current&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=V.current.scrollHeight),Y.current=null})),()=>{null!==Y.current&&cancelAnimationFrame(Y.current)}),[w,C]),(0,f.useEffect)(()=>{if(!Q)return;let a=a=>{"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),P?.())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[Q,P]);let ar=w?w.split("\n").length:0,as=(0,f.useCallback)(()=>{ah(!0),requestAnimationFrame(()=>af.current?.focus())},[]),at=(0,f.useCallback)(()=>{ah(!1),aj(""),an(0),ae.current?.clearSearch()},[]),au=(0,f.useCallback)(a=>{a.trim()&&(K?ae.current?.findNext(a):an(a=>{let b=a+1,c=ao.current[b];return c?(c.scrollIntoView({block:"nearest"}),b):(ao.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[K]),av=(0,f.useCallback)(a=>{a.trim()&&(K?ae.current?.findPrevious(a):an(a=>{let b=a-1;if(b>=0)return ao.current[b]?.scrollIntoView({block:"nearest"}),b;let c=ao.current.length-1;return c>=0&&ao.current[c]?.scrollIntoView({block:"nearest"}),Math.max(c,0)}))},[K]);(0,f.useEffect)(()=>{if(!D)return;let a=a=>{if((a.metaKey||a.ctrlKey)&&"f"===a.key){a.preventDefault(),a.stopPropagation(),as();return}if("Escape"===a.key&&ag){a.preventDefault(),a.stopPropagation(),at();return}};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[D,ag,as,at]);let aw=Q&&R?R-41:S??A;return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${Q?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${Q?"":D?"border-brand":"border-brand/30"}`,onClick:E,children:[Q?(0,e.jsxs)("div",{onDoubleClick:()=>P?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,e.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,e.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:d}),C&&(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),U("console.runningText")]}),C&&F&&(0,e.jsx)("button",{onClick:F,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,e.jsx)("button",{onClick:()=>P?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:U("console.restoreTooltip",{modKey:(0,s.Mu)()}),children:(0,e.jsx)(g.A,{className:"w-4 h-4"})})]}):(0,e.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>T?.(),onDoubleClick:a=>{a.stopPropagation(),P?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${D?"border-brand":"border-brand/30"}`,children:[(0,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:">_"}),_&&a&&b&&(0,e.jsx)(r.j,{shortId:_,type:"terminal",onRegister:()=>{u.t4.runFork((0,v.Ok)({tabId:b,commandId:a,command:d,projectCwd:c}).pipe(t.orElse(()=>t.void)))},onUnregister:()=>{u.t4.runFork((0,v.jO)({commandId:a}).pipe(t.orElse(()=>t.void)))},fullId:a,projectCwd:c,tabId:b}),(0,e.jsx)("span",{className:"font-mono text-foreground truncate",children:d}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(d),(0,n.oR)(U("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:U("console.copyCommand"),children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"flex-1"}),aa&&!C&&(0,e.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:U("console.totalLines",{count:ar})}),w&&(0,e.jsx)("button",{onClick:a=>{let b;a.stopPropagation(),b=w.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(b),(0,n.oR)(U("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:U("console.copyOutput"),children:(0,e.jsx)(i.A,{className:"w-3.5 h-3.5"})}),I&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),I()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:U("console.rerun"),children:(0,e.jsx)(j.A,{className:"w-3.5 h-3.5"})}),H&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),H()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:U("console.deleteRecord"),children:(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),ag&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,e.jsx)(k.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,e.jsx)("input",{ref:af,value:ai,onChange:a=>{let b=a.target.value;aj(b),an(0),K&&(b.trim()?ae.current?.findNext(b):ae.current?.clearSearch())},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?av(ai):au(ai))},placeholder:U("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}),!K&&(0,e.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,e.jsx)("button",{onClick:()=>al("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===ak?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:U("console.searchMode")}),(0,e.jsx)("button",{onClick:()=>al("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===ak?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:U("console.filterMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>av(ai),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:U("console.prevShiftEnter"),children:(0,e.jsx)(l.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>au(ai),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:U("console.nextEnter"),children:(0,e.jsx)(m.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("button",{onClick:at,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),K?(0,e.jsxs)("div",{className:"relative group",style:{height:aw,overflow:"hidden"},children:[(0,e.jsx)(f.Suspense,{fallback:(0,e.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:aw},children:U("console.loadingTerminal")}),children:(0,e.jsx)(y,{ref:ae,output:w,isRunning:C,onInput:G,onResize:O,maximized:Q,height:aw,directWrite:!!L})}),!C&&I&&(0,e.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",onClick:a=>{a.stopPropagation(),I()},title:U("console.rerun"),children:(0,e.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-black/60 text-white text-xs",children:[(0,e.jsx)(j.A,{className:"w-3.5 h-3.5"}),U("console.rerun")]})})]}):(0,e.jsx)("div",{ref:V,className:"overflow-auto px-4 py-2",style:{height:aw},onScroll:()=>{if(V.current){let{scrollTop:a,scrollHeight:b,clientHeight:c}=V.current;X.current=b-a-c<50}},children:ag&&ai.trim()?(0,e.jsx)(x,{output:w,query:ai,mode:ak,currentIdx:am,matchListRef:ao}):(0,e.jsx)("pre",{ref:W,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),C&&!Q&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),K?(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:U("console.clickToInput")}):G?(0,e.jsx)("input",{ref:Z,value:ac,onChange:a=>ad(a.target.value),onKeyDown:a=>{if(a.ctrlKey&&!a.metaKey&&!a.altKey){let b=z[a.key.toLowerCase()];if(b){a.preventDefault(),a.stopPropagation(),G(b);return}}"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),G(ac+"\n"),ad("")),"Tab"===a.key&&(a.preventDefault(),G(" "))},placeholder:U("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:U("console.runningText")}),F&&(0,e.jsx)("button",{onClick:F,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),$&&(0,e.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:$})]}),!C&&void 0!==B&&!Q&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===B?"bg-green-500":"bg-red-500"}`}),(0,e.jsx)("span",{children:U("console.exitCode",{code:B})}),(0,e.jsx)("span",{className:"flex-1"}),$&&(0,e.jsx)("span",{className:"text-[11px] flex-shrink-0",children:$})]})]})})});d()}catch(a){d(a)}})},36984:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Np:()=>k,ZD:()=>i,b8:()=>j,kS:()=>g,sQ:()=>h});var e=c(78908),f=a([e]);e=(f.then?(await f)():f)[0];let l=null,m=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function g(){return l||(l=(0,e.createHighlighter)({themes:["github-dark","github-light"],langs:[...m]})),l}function h(a){let b=a.split("/").pop()?.toLowerCase()||"",c=b.split(".").pop()?.toLowerCase();if(".env"===b||b.startsWith(".env.")||"dockerfile"===b||b.startsWith("dockerfile.")||"makefile"===b)return"bash";let d={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[c||""]||"text";return m.includes(d)?d:"text"}function i(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function j(a){return a.map(a=>a.color?`<span style="color:${a.color}">${i(a.content)}</span>`:i(a.content)).join("")}function k(a,b,c,d){if(!b)return[];let e=[],f=c?b:b.toLowerCase();for(let b=0;b<a.length;b++){let g=c?a[b]:a[b].toLowerCase(),h=0;for(;;){let a=g.indexOf(f,h);if(-1===a)break;let c=a+f.length;if(d){let d=a>0?g[a-1]:" ",f=c<g.length?g[c]:" ",h=!/\w/.test(d),i=!/\w/.test(f);h&&i&&e.push({lineIndex:b,startCol:a,endCol:c})}else e.push({lineIndex:b,startCol:a,endCol:c});h=a+1}}return e}d()}catch(a){d(a)}})},37129:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{useTabState:()=>k});var e=c(67484),f=c(23860),g=c(29939);c(57031),c(88214);var h=c(79606),i=c(33281),j=c(37388);function k({initialCwd:a,initialSessionId:b,activeView:c}){(0,e.useRef)(!1);let d=(0,e.useRef)(!0),l=(0,e.useRef)(c),m=(0,f.F)(),n=(0,e.useRef)(m),[o,p]=(0,e.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),[q,r]=(0,e.useState)(o[0]?.id??""),[s,t]=(0,e.useState)(new Set),u=(0,e.useRef)(o),v=(0,e.useRef)(q),w=(0,e.useRef)(new Set),x=(0,e.useCallback)((b,c)=>{a&&b&&i.t4.runFork((0,j.KJ)(a,b,c).pipe(h.catchAll(()=>h.void)))},[a]),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),C=(0,e.useCallback)(b=>{a&&i.t4.runPromise((0,j.n8)(a).pipe(h.catchAll(()=>h.succeed(null)))).then(c=>{if(!c)return;let d=c.sessions||[],e=c.engines||{},f=c.ollamaModels||{},g=c.deepseekModels||{},h=c.chatModes||{},i=c.planModes||{},j=u.current,k=new Set(b),l=j.filter(a=>!a.sessionId||!k.has(a.sessionId)),m=new Set(l.map(a=>a.sessionId).filter(Boolean)),n=d.filter(a=>!m.has(a));if(l.length===j.length&&0===n.length)return;let o=n.map((b,c)=>({id:`tab-${Date.now()}-sync-${c}`,cwd:a,sessionId:b,title:`Session ${b.slice(0,6)}...`,engine:e[b]||void 0,ollamaModel:f[b]||void 0,deepseekModel:g[b]||void 0,chatMode:h[b]||void 0,planMode:i[b]||void 0})),q=[...l,...o];0===q.length&&(q=[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),p(q),q.some(a=>a.id===v.current)||r(q[q.length-1].id)})},[a]);(0,g.h)({url:"/ws/global-state",enabled:!!a,onMessage:b=>{d.current||!a||"project-state-changed"===b.type&&b.cwd===a&&C(b.closedSessionIds??[])}});let D=(0,e.useCallback)((a,b,c,d,e,f,g=!1)=>{let h={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat"),engine:d,ollamaModel:e,deepseekModel:f};p(a=>{if(g)return[...a,h];let b=a.findIndex(a=>a.id===q);if(-1===b)return[...a,h];let c=[...a];return c.splice(b+1,0,h),c}),r(h.id)},[q]),E=(0,e.useCallback)(b=>{let c=u.current.find(a=>a.id===b);c?.sessionId&&w.current.add(c.sessionId),p(c=>{let d=c.filter(a=>a.id!==b);if(b===q&&d.length>0&&r(d[d.length-1].id),0===d.length){let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};return r(b.id),[b]}return d})},[q,a]),F=(0,e.useCallback)((b,c)=>{let d=o.find(a=>a.sessionId===b);d?r(d.id):D(a,b,c,void 0,void 0,void 0,!0)},[o,a,D]),G=(0,e.useCallback)(()=>{D(a,void 0,void 0,void 0,void 0,void 0,!0)},[a,D]),H=(0,e.useCallback)(()=>{D(a,void 0,"New Claude 2 Chat","claude2",void 0,void 0,!0)},[a,D]),I=(0,e.useCallback)(()=>{D(a,void 0,"New Codex Chat","codex",void 0,void 0,!0)},[a,D]),J=(0,e.useCallback)(()=>{D(a,void 0,"New Kimi Chat","kimi",void 0,void 0,!0)},[a,D]),K=(0,e.useCallback)(b=>{D(a,void 0,b?`New Ollama (${b})`:"New Ollama Chat","ollama",b,void 0,!0)},[a,D]),L=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,ollamaModel:b}:c))},[]),M=(0,e.useCallback)(()=>{D(a,void 0,"New DeepSeek Chat","deepseek",void 0,"deepseek-v4-flash",!0)},[a,D]),N=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,deepseekModel:b}:c))},[]),O=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,chatMode:b}:c))},[]),P=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,planMode:b}:c))},[]),Q=(0,e.useCallback)((b,c)=>{D(a,b,c)},[a,D]),R=(0,e.useCallback)((a,b)=>{p(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!l.current||"agent"===l.current;if(a===q&&c&&n.current){let a=d.sessionId||b.sessionId;a&&x(a,"normal")}else t(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[q,x]),S=(0,e.useCallback)(a=>{r(a),t(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=u.current.find(b=>b.id===a);return d?.sessionId&&(x(d.sessionId,"normal"),i.t4.runFork((0,j.M2)(d.sessionId).pipe(h.catchAll(()=>h.void)))),c})},[x]),T=(0,e.useCallback)(a=>{z(a)},[]),U=(0,e.useCallback)((a,b)=>{a.preventDefault(),null!==y&&y!==b&&B(b)},[y]),V=(0,e.useCallback)(a=>{null!==y&&y!==a&&p(b=>{let c=[...b],[d]=c.splice(y,1);return c.splice(a,0,d),c}),z(null),B(null)},[y]),W=(0,e.useCallback)(()=>{z(null),B(null)},[]),X=o.find(a=>a.id===q);return{tabs:o,activeTabId:q,activeTab:X,unreadTabs:s,dragTabIndex:y,dragOverTabIndex:A,addTab:D,closeTab:E,switchTab:S,handleSelectSession:F,handleNewTab:G,handleNewClaude2Tab:H,handleNewCodexTab:I,handleNewKimiTab:J,handleNewOllamaTab:K,handleNewDeepseekTab:M,handleOpenSession:Q,updateTabState:R,updateTabOllamaModel:L,updateTabDeepseekModel:N,updateTabChatMode:O,updateTabPlanMode:P,handleTabDragStart:T,handleTabDragOver:U,handleTabDrop:V,handleTabDragEnd:W}}d()}catch(a){d(a)}})},37202:(a,b,c)=>{"use strict";c.d(b,{M:()=>m,O:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(74429);let h=[],i=[];function j(){i.forEach(a=>a())}function k(a){let b=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;h=[...h,{...a,id:b}],j()}function l(a){h=h.filter(b=>b.id!==a),j()}function m({onNavigate:a}){let b=function(){let[,a]=(0,e.useState)(0);return h}();return 0===b.length?null:(0,g.createPortal)((0,d.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:b.map(b=>(0,d.jsx)(n,{item:b,onNavigate:a,onRemove:l},b.id))}),document.body)}function n({item:a,onNavigate:b,onRemove:c}){let{t:g}=(0,f.Bd)(),[h,i]=(0,e.useState)(!1),j=(0,e.useRef)(void 0),k=(0,e.useCallback)(()=>{i(!0),setTimeout(()=>c(a.id),300)},[a.id,c]),l=(0,e.useCallback)(()=>{clearTimeout(j.current),b(a.cwd,a.sessionId),c(a.id)},[a,b,c]),m=(0,e.useCallback)(()=>{clearTimeout(j.current)},[]),o=(0,e.useCallback)(()=>{j.current=setTimeout(k,2e3)},[k]);return(0,d.jsxs)("div",{className:`pointer-events-auto bg-card border border-border rounded-lg shadow-lg px-3 py-2.5 min-w-[260px] max-w-[340px] cursor-pointer hover:bg-accent transition-all ${h?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:h?void 0:"slideInLeft 0.3s ease-out"},onClick:l,onMouseEnter:m,onMouseLeave:o,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-green-9 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"})}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.projectName}),(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:g("common.done")}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k()},className:"ml-auto p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",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.message&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-1 ml-6",children:a.message})]})}},37388:(a,b,c)=>{"use strict";c.d(b,{KJ:()=>h,M2:()=>i,ej:()=>g,n8:()=>f});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(`/api/project-state?cwd=${encodeURIComponent(a)}`);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"loadProjectState failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/project-state",{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:"saveProjectState failed",cause:a})}),h=(a,b,c)=>d.tryPromise({try:async()=>{let d=await fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c})});if(!d.ok)throw Error(`HTTP ${d.status}`)},catch:a=>new e.uV({message:"updateSessionStatus failed",cause:a})}),i=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markReadBySessionId",fields:{sessionId:a}})});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"markScheduledTasksReadBySession failed",cause:a})})},37690:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(67484);function e({enabled:a,container:b,resolveLineRange:c,buildLineSnapshot:f,dragThresholdPx:g=5}){let h=(0,d.useRef)(null),i=(0,d.useRef)(()=>{}),j=(0,d.useRef)(c),k=(0,d.useRef)(f),l=(0,d.useRef)(g);return j.current=c,k.current=f,l.current=g,{toolbarRef:h,bumpRef:i,clearToolbar:()=>{h.current&&(h.current=null,i.current())}}}},38087:(a,b,c)=>{"use strict";c.d(b,{m:()=>i,z:()=>h});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=a=>e.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 g.uV({message:"session-by-path failed",cause:a})});function i(a,b,c,{cwd:j,initialSessionId:k,onSessionId:l,onTitleChange:m,onTokenUsage:n,liveRunningRef:o}){let[p,q]=(0,d.useState)(!1),[r,s]=(0,d.useState)(!1),[t,u]=(0,d.useState)(!1),[v,w]=(0,d.useState)(void 0),[x,y]=(0,d.useState)(0),[z,A]=(0,d.useState)(null),[B,C]=(0,d.useState)(null),D=(0,d.useRef)(m);D.current=m;let E=(0,d.useRef)(n);E.current=n;let F=(0,d.useRef)(void 0),G=(0,d.useRef)(0),H=(0,d.useCallback)(async(a,c,d=!1,e,g)=>{if(d){let a=Date.now();if(a-G.current<5e3)return;G.current=a}d||q(!0);try{let i={cwd:a,sessionId:c,limit:e,beforeTurnIndex:g};d&&F.current&&(i.ifFingerprint=F.current);let j=await f.t4.runPromiseExit(h(i));if("Success"===j._tag&&j.value){let a=j.value;if(a.notModified)return;a.fingerprint&&(F.current=a.fingerprint),void 0!==a.totalTurns&&y(a.totalTurns),void 0!==a.hasMore&&u(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>{let c=a.messages;if(b.length===c.length&&b.length>0&&b[b.length-1].content===c[c.length-1].content)return b;let d=0;for(let a=0;a<Math.min(b.length,c.length)&&b[a].id===c[a].id&&b[a].content===c[a].content;a++)d=a+1;return d===b.length&&d<c.length?[...b,...c.slice(d)]:c}):o?.current||b(a.messages),A(c)),a.sessionId&&l(a.sessionId),a.engine&&C(a.engine),a.title&&D.current?.(a.title),a.usage&&E.current?.({inputTokens:a.usage.input_tokens||0,outputTokens:a.usage.output_tokens||0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens||0,cacheReadInputTokens:a.usage.cache_read_input_tokens||0,totalCostUsd:0})}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||q(!1)}},[b,l]),I=(0,d.useCallback)(async()=>{if(j&&c&&!r&&t){s(!0);try{let d=void 0!==v?v:x-Math.ceil(a.filter(a=>"user"===a.role).length),e=await f.t4.runPromiseExit(h({cwd:j,sessionId:c,limit:10,beforeTurnIndex:d>0?d:void 0}));if("Success"===e._tag&&e.value){let a=e.value;if(a.messages&&a.messages.length>0){b(b=>[...a.messages,...b]);let e=a.messages.filter(a=>"user"===a.role).length;w(d-e),A(c)}void 0!==a.hasMore&&u(a.hasMore),a.fingerprint&&(F.current=a.fingerprint)}else"Failure"===e._tag&&console.error("Failed to load more history:",e.cause)}finally{s(!1)}}},[j,c,r,t,v,x,a,b]);return{isLoadingHistory:p,isLoadingMore:r,hasMoreHistory:t,loadMoreHistory:I,loadHistory:(0,d.useCallback)(async a=>{q(!0);let c=e.tryPromise({try:async()=>{let b=await fetch(`/api/session/${a}/history`);return b.ok?await b.json():null},catch:a=>new g.uV({message:"load session history failed",cause:a})}),d=await f.t4.runPromiseExit(c);"Success"===d._tag&&d.value?.messages&&d.value.messages.length>0?(b(d.value.messages),A(a)):"Failure"===d._tag&&console.error("Failed to load history:",d.cause),q(!1)},[b]),loadHistoryByCwdAndSessionId:H,loadedSessionId:z,loadedEngine:B}}},38878:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManagerTopBar:()=>s});var e=c(48249),f=c(67484),g=c(94192),h=c(12568),i=c(7833),j=c(44384),k=c(57031),l=c(88214),m=c(79606),n=c(33281),o=c(85655),p=c(65484),q=a([h]);function r({cwd:a,currentBranch:b,onSwitched:c}){let{t:d}=(0,j.Bd)(),[g,h]=(0,f.useState)(!1),[k,l]=(0,f.useState)([]),[m,q]=(0,f.useState)(!1),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(""),w=(0,f.useRef)(null),x=(0,f.useRef)(null),y=(0,f.useCallback)(async()=>{q(!0);let b=await n.t4.runPromiseExit((0,o.r4)(a));if("Success"===b._tag){let a=b.value,c=a.local??[],d=a.remote??[],e=[...c,...d.filter(a=>!c.includes(a.replace(/^origin\//,"")))];l(e)}else(0,i.oR)(d("toast.loadBranchFailed"),"error");q(!1)},[a,d]),z=(0,f.useCallback)(()=>{h(!0),v(""),y()},[y]),A=(0,f.useCallback)(()=>{h(!1)},[]),B=async b=>{t(!0);let e=await n.t4.runPromiseExit((0,p.Kl)({action:"checkout",cwd:a,path:a,branch:b}));if("Success"===e._tag){let a=b.replace(/^origin\//,"");(0,i.oR)(d("toast.switchedToBranch",{branch:a}),"success"),A(),c()}else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:d("toast.switchBranchFailed");(0,i.oR)(c,"error")}t(!1)},C=k.filter(a=>a!==b&&a.toLowerCase().includes(u.toLowerCase()));return(0,e.jsxs)("div",{className:"relative",ref:w,children:[(0,e.jsx)("button",{onClick:g?A:z,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:d("git.switchBranch"),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 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),g&&(0,e.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lg z-50 overflow-hidden",children:[(0,e.jsx)("div",{className:"p-2 border-b border-border",children:(0,e.jsx)("input",{ref:x,type:"text",value:u,onChange:a=>v(a.target.value),placeholder:d("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none placeholder:text-muted-foreground",onKeyDown:a=>{"Escape"===a.key&&A()}})}),(0,e.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:m?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("common.loading")}):0===C.length?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:u?d("git.noMatchingBranches"):d("git.noBranches")}):C.map(a=>(0,e.jsx)("button",{onClick:()=>B(a),disabled:s,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate disabled:opacity-50",children:(0,e.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function s({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:d,onOpenWorktree:f,onOpenAliasManager:o,onBranchSwitched:q}){let{t}=(0,j.Bd)();return(0,e.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:t("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,i.oR)(t("toast.copiedPageUrl"),"success")})}}),a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(t("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:t("tabManagerTopBar.copyDirPath"),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)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsxs)("button",{onClick:f,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:"Git Worktrees",children:[(0,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:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,e.jsx)("span",{className:"text-sm",children:d||"main"})]}),(0,e.jsx)(r,{cwd:a,currentBranch:d,onSwitched:()=>q?.()})]})]}),(0,e.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,e.jsx)(g.gT,{})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(h.ReviewDropdown,{cwd:a}),(0,e.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.refreshProject"),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 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:()=>{b?.cwd&&n.t4.runFork((0,p.em)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.openInVSCode"),children:(0,e.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,e.jsx)("path",{d:"M17.583 2.213L12 7.393 6.417 2.213 1 6.17v11.66l5.417 3.957L12 16.607l5.583 5.18L23 17.83V6.17l-5.417-3.957zM6.417 17.83L3 15.33V8.67l3.417-2.5v11.66zm11.166 0V6.17L21 8.67v6.66l-3.417 2.5z"})})}),(0,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,p.Q1)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.openInCursor"),children:(0,e.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,e.jsx)("path",{d:"M4.5 2L20.5 12L4.5 22V2Z"})})}),b?.sessionId&&(0,e.jsx)("button",{onClick:()=>{let a=`claude -r ${b.sessionId}`;navigator.clipboard.writeText(a).then(()=>{(0,i.oR)(t("toast.copiedCommand",{command:a}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("chat.copyCommandTooltip",{sessionId:b.sessionId}),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:"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:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.aliasesGlobal"),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:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,e.jsx)("button",{onClick:()=>(0,k.F)(l.n.OpenTokenStats,{}),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.tokenStats"),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:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,e.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.openSurething"),children:(0,e.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}h=(q.then?(await q)():q)[0],d()}catch(a){d(a)}})},38896:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{C:()=>h});var e=c(67484),f=c(36984),g=a([f]);function h(a,b){let[c,d]=(0,e.useState)(null),[g,h]=(0,e.useState)(!1),i=(0,e.useMemo)(()=>a.join("\n"),[a]),j=`${i}:${b}:${g}`;return(0,e.useMemo)(()=>c&&c.key===j?c.html:a.map(a=>(0,f.ZD)(a||" ")),[a,j,c])}f=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},39222:(a,b,c)=>{"use strict";c.d(b,{v:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(46674),h=c(59347),i=c(24520),j=c(33281),k=c(23328);function l({cwd:a,tabId:b,onClose:c,onSave:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)({}),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(!0);(0,e.useCallback)(async()=>{v(!0);let c=await j.t4.runPromiseExit((0,k.QF)(a,b));"Success"===c._tag?p(c.value):console.error("Failed to load env:",c.cause),v(!1)},[a,b]);let w=()=>{q.trim()&&(p(a=>({...a,[q.trim()]:s})),r(""),t(""))},x=async()=>{let d=await j.t4.runPromiseExit((0,k.Vv)({cwd:a,tabId:b,env:o}));"Success"===d._tag?(m(o),c()):console.error("Failed to save env:",d.cause)};return(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:n("envManager.title")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b?n("envManager.tabScope"):n("envManager.globalScope")})]}),(0,d.jsx)("button",{onClick:c,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,d.jsx)(g.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:u?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:n("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(o).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void p(b=>({...b,[a]:c}))},placeholder:n("envManager.valuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"}),(0,d.jsx)("button",{onClick:()=>{p(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,d.jsx)(h.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsx)("input",{type:"text",value:q,onChange:a=>r(a.target.value),placeholder:n("envManager.varNamePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),w())}}),(0,d.jsx)("input",{type:"text",value:s,onChange:a=>t(a.target.value),placeholder:n("envManager.varValuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),w())}}),(0,d.jsx)("button",{onClick:w,disabled:!q.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]}),0===Object.keys(o).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:n("envManager.noVars")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:c,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:n("common.cancel")}),(0,d.jsx)("button",{onClick:x,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:n("common.save")})]})]})})}},39712:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{w:()=>p});var e=c(48249),f=c(67484),g=c(50757),h=c(27454),i=c(37752),j=c(87844),k=c(34678),l=c(83768);let a=new k.v;function m(a){return a?Array.isArray(a)?a.join(""):a:""}function n(a,b){return a&&a[b]?m(a[b]):""}a.use_classes=!0;let o=(0,f.memo)(function({output:b}){if("stream"===b.output_type){let c=m(b.text);if(!c)return null;let d=a.ansi_to_html(c);return(0,e.jsx)("pre",{className:`text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 ${"stderr"===b.name?"text-amber-500":"text-foreground"}`,dangerouslySetInnerHTML:{__html:d}})}if("error"===b.output_type){let c=(b.traceback||[]).join("\n"),d=a.ansi_to_html(c);return(0,e.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-red-400 bg-red-500/5 rounded",dangerouslySetInnerHTML:{__html:d}})}if("execute_result"===b.output_type||"display_data"===b.output_type||"update_display_data"===b.output_type){let a=b.data;if(!a)return null;let c=n(a,"image/png"),d=n(a,"image/jpeg"),f=n(a,"image/svg+xml"),g=n(a,"text/html"),h=n(a,"text/markdown"),i=n(a,"text/latex"),k=n(a,"text/plain");if(c)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)("img",{src:`data:image/png;base64,${c}`,alt:"output",className:"max-w-full"})});if(d)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)("img",{src:`data:image/jpeg;base64,${d}`,alt:"output",className:"max-w-full"})});if(f)return(0,e.jsx)("div",{className:"px-3 py-1",dangerouslySetInnerHTML:{__html:f}});if(g)return(0,e.jsx)("div",{className:"px-3 py-1 overflow-x-auto notebook-html-output",dangerouslySetInnerHTML:{__html:g}});if(h)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)(j.T,{content:h})});if(i)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)(j.T,{content:`$$${i}$$`})});if(k)return(0,e.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-foreground",children:k})}return null}),p=(0,f.memo)(function({cell:a,isActive:b,isEditing:c,onSelect:d,onEdit:k,onStopEdit:m,onSourceChange:n,onRun:p,onDelete:q,onMoveUp:r,onMoveDown:s,onToggleType:t,isFirst:u,isLast:v}){let{resolvedTheme:w}=(0,l.D)(),x=(0,f.useRef)(null),[y,z]=(0,f.useState)(a.source),A=(0,f.useCallback)(()=>{z(a.source),k()},[a.source,k]);(0,f.useEffect)(()=>{if(c&&x.current){x.current.focus();let a=x.current.value.length;x.current.setSelectionRange(a,a)}},[c]);let B=(0,f.useCallback)(()=>{let a=x.current;a&&(a.style.height="auto",a.style.height=a.scrollHeight+"px")},[]);(0,f.useEffect)(()=>{c&&B()},[c,y,B]);let C=(0,f.useCallback)(a=>{z(a.target.value),B()},[B]),D=(0,f.useCallback)(()=>{y!==a.source&&n(y),m()},[y,a.source,n,m]),E=(0,f.useCallback)(b=>{if("Enter"===b.key&&b.shiftKey)b.preventDefault(),y!==a.source&&n(y),p();else if("Enter"===b.key&&(b.metaKey||b.ctrlKey))b.preventDefault(),y!==a.source&&n(y),p();else if("Escape"===b.key)b.preventDefault(),D();else if("Tab"===b.key){b.preventDefault();let a=x.current;if(a){let b=a.selectionStart,c=a.selectionEnd,d=y.substring(0,b)+" "+y.substring(c);z(d),requestAnimationFrame(()=>{a.selectionStart=a.selectionEnd=b+4})}}},[y,a.source,n,p,D]),F=a.isExecuting?"*":a.execution_count??" ",G="code"===a.cell_type?"Code":"markdown"===a.cell_type?"Md":"Raw";return(0,e.jsxs)("div",{className:`group relative border rounded-lg transition-colors ${b?"border-brand/50 bg-brand/5":"border-border/50 hover:border-border"}`,onClick:d,children:[(0,e.jsxs)("div",{className:`absolute -top-3 left-2 flex items-center gap-0.5 text-[10px] z-10 bg-surface-secondary rounded px-1 py-0.5 border border-border/50 transition-opacity ${b?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:[(0,e.jsx)("button",{onClick:p,className:"px-1 hover:text-brand",title:"Run (Shift+Enter)",children:a.isExecuting?"⬛":"▶"}),(0,e.jsx)("button",{onClick:t,className:"px-1 hover:text-brand",title:"Toggle type",children:G}),!u&&(0,e.jsx)("button",{onClick:r,className:"px-1 hover:text-brand",title:"Move up",children:"↑"}),!v&&(0,e.jsx)("button",{onClick:s,className:"px-1 hover:text-brand",title:"Move down",children:"↓"}),(0,e.jsx)("button",{onClick:q,className:"px-1 hover:text-red-400",title:"Delete",children:"\xd7"})]}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)("div",{className:"flex-shrink-0 w-10 text-center py-2 text-[10px] text-muted-foreground select-none cursor-pointer border-r border-border/30",onClick:a=>{a.stopPropagation(),p()},title:"code"===a.cell_type?"Click to run":void 0,children:"code"===a.cell_type?(0,e.jsxs)("span",{className:a.isExecuting?"text-brand animate-pulse":"",children:["[",F,"]"]}):(0,e.jsx)("span",{className:"text-muted-foreground/50",children:G})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"cursor-text",onDoubleClick:a=>{a.stopPropagation(),A()},children:c?(0,e.jsx)("textarea",{ref:x,value:y,onChange:C,onBlur:D,onKeyDown:E,className:"w-full bg-transparent text-xs font-mono leading-relaxed px-3 py-2 resize-none outline-none text-foreground",spellCheck:!1,style:{minHeight:"1.5rem"}}):"code"===a.cell_type?(0,e.jsx)("div",{className:"text-xs [&_pre]:!m-0 [&_pre]:!p-2 [&_pre]:!bg-transparent [&_code]:!bg-transparent",children:(0,e.jsx)(g.A,{language:"python",style:"dark"===w?h.A:i.A,customStyle:{margin:0,padding:"8px 12px",background:"transparent",fontSize:"12px"},wrapLongLines:!0,children:a.source||" "})}):"markdown"===a.cell_type?a.source.trim()?(0,e.jsx)("div",{className:"px-3 py-2 text-sm prose prose-sm dark:prose-invert max-w-none",children:(0,e.jsx)(j.T,{content:a.source})}):(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:"Empty markdown cell"}):(0,e.jsx)("pre",{className:"text-xs font-mono px-3 py-2 text-muted-foreground whitespace-pre-wrap",children:a.source||" "})}),a.outputs.length>0&&(0,e.jsx)("div",{className:"border-t border-border/30",children:a.outputs.map((a,b)=>(0,e.jsx)(o,{output:a},b))})]})]})]})});d()}catch(a){d(a)}})},40159:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{S:()=>l,j:()=>a});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(44256);function j({blame:a,onClick:b}){let{t:c}=(0,g.Bd)(),d=(0,f.useRef)(null),k=(0,f.useRef)(null),l=(0,i.F2)(),m=(0,f.useRef)(!1),n=(0,f.useRef)(!1),o=(0,f.useRef)(null),p=(0,f.useRef)(null),q=(0,f.useRef)(null),r=(0,f.useRef)(a),s=(0,f.useRef)(b),t=(0,f.useCallback)(()=>{let a,b=k.current,c=d.current;if(!b||!c)return;let e=c.getBoundingClientRect(),f=b.getBoundingClientRect(),g=l?.getBoundingClientRect(),h=g?.left??0,i=g?.top??0,j=g?.width??window.innerWidth,m=g?.height??window.innerHeight,n=e.left-h;n+f.width>j-8&&(n=j-f.width-8),n<8&&(n=8);let o=e.top-i,p=e.bottom-i;(a=o-f.height-4<0?p+4:o-f.height-4)+f.height>m-8&&(a=m-f.height-8),b.style.left=`${n}px`,b.style.top=`${a}px`},[l]),u=(0,f.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),p.current&&(clearTimeout(p.current),p.current=null),m.current=!1,n.current=!1,k.current&&(k.current.style.display="none"),q.current&&(document.removeEventListener("mousedown",q.current.down),document.removeEventListener("mouseup",q.current.up),q.current=null)},[]),v=(0,f.useCallback)(()=>{let a=k.current;if(!a||m.current)return;m.current=!0,a.style.left="-9999px",a.style.top="-9999px",a.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(t));let b=0,c=0,e=a=>{b=a.clientX,c=a.clientY},f=a=>{if(!(Math.abs(a.clientX-b)>5||Math.abs(a.clientY-c)>5)){let b;b=a.target,k.current?.contains(b)||d.current?.contains(b)||u()}};document.addEventListener("mousedown",e),document.addEventListener("mouseup",f),q.current={down:e,up:f}},[t,u]),w=(0,f.useCallback)(()=>{if(o.current&&clearTimeout(o.current),p.current&&(clearTimeout(p.current),p.current=null),m.current)return;let a=window.getSelection();(!a||a.isCollapsed)&&(o.current=setTimeout(v,500))},[v]),x=(0,f.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),m.current&&(p.current=setTimeout(()=>{n.current||u()},200))},[u]),y=(0,f.useCallback)(()=>{n.current=!0,p.current&&(clearTimeout(p.current),p.current=null)},[]),z=(0,f.useCallback)(()=>{n.current=!1,u()},[u]),A=(0,f.useCallback)(a=>{a.stopPropagation();let b=window.getSelection();b&&b.toString().length>0&&k.current?.contains(b.anchorNode)||(s.current?.(r.current),u())},[u]),B=a.message.split("\n")[0]||"",C=a.message.split("\n").slice(1).join("\n").trim();return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{ref:d,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:w,onMouseLeave:x,children:[a.author.split(" ")[0],", ",function(a){let b=h.A.t,c=Date.now(),d=Math.floor((c-1e3*a)/1e3);if(d<60)return b("common.justNow");let e=Math.floor(d/60);if(e<60)return b("common.minutesAgo",{count:e});let f=Math.floor(e/60);if(f<24)return b("common.hoursAgo",{count:f});let g=Math.floor(f/24);if(g<30)return b("common.daysAgo",{count:g});let i=Math.floor(g/30);if(i<12)return b("common.monthsAgo",{count:i});let j=Math.floor(i/12);return b("common.yearsAgo",{count:j})}(a.time)," \xb7 ",B]}),(0,e.jsx)(i.ZL,{children:(0,e.jsxs)("div",{ref:k,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-xl p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:y,onMouseLeave:z,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,e.jsx)("span",{className:"font-mono text-brand",children:a.hash}),(0,e.jsx)("span",{className:"text-muted-foreground",children:a.author}),(0,e.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*a.time).toLocaleString()})]}),(0,e.jsx)("div",{className:"font-medium",children:B}),C&&(0,e.jsx)("div",{className:"mt-1 text-muted-foreground",children:C}),(0,e.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:A,children:c("codeViewer.clickToViewDetails")})]})})]})}let a=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}];function k(a,b){let c,d=document.caretRangeFromPoint(a.clientX,a.clientY);if(!d||!b.contains(d.startContainer))return 1;let e=d.startContainer,f=d.startOffset,g=document.createTreeWalker(b,NodeFilter.SHOW_TEXT),h=1;for(;c=g.nextNode();){if(c===e){h+=f;break}h+=c.textContent?.length||0}return h}let l=(0,f.memo)(function({virtualKey:a,lineNum:b,highlightedHtml:c,hasComments:d,firstComment:h,lineCommentsCount:i,isInRange:l,showLineNumbers:m,lineNumChars:n,commentsEnabled:o,virtualItemSize:p,virtualItemStart:q,onCommentBubbleClick:r,onCmdClick:s,onTokenHover:t,onTokenHoverLeave:u,flashLine:v,blameLine:w,showBlameInfo:x,blameAuthorColor:y,isBlameHovered:z,onBlameClick:A,onBlameMouseEnter:B,onBlameMouseLeave:C,inlineBlameData:D,onInlineBlameClick:E,isCursorLine:F,cursorCol:G}){let{t:H}=(0,g.Bd)(),I=(0,f.useMemo)(()=>F&&null!=G?function(a,b){let c=0,d=0;for(;d<a.length;){if("<"===a[d]){let b=a.indexOf(">",d);if(-1!==b){d=b+1;continue}}if(c===b){let b;if("&"===a[d]){let c=a.indexOf(";",d);b=-1!==c&&c-d<10?c+1:d+1}else b=d+1;let c=a.substring(d,b);return a.substring(0,d)+'<span class="vi-char-cursor">'+c+"</span>"+a.substring(b)}if("&"===a[d]){let b=a.indexOf(";",d);d=-1!==b&&b-d<10?b+1:d+1}else d++;c++}return a+'<span class="vi-char-cursor"> </span>'}(c,G):c,[c,F,G]),J=(0,f.useCallback)(a=>{if(!a.metaKey||!s)return;a.preventDefault(),a.stopPropagation();let c=a.currentTarget,d=k(a,c);window.getSelection()?.removeAllRanges(),s(b,d)},[b,s]),K=(0,f.useCallback)(a=>{if(!t||0!==a.buttons)return;let c=window.getSelection();if(c&&!c.isCollapsed)return;let d=a.target;if("SPAN"!==d.tagName||!d.style.color)return;let e=a.currentTarget,f=k(a,e),g=d.getBoundingClientRect();t(b,f,{x:g.left,y:g.bottom+4})},[b,t]),L=(0,f.useCallback)(()=>{w&&A&&A(w)},[w,A]),M=(0,f.useCallback)(a=>{w&&B&&B(w,a)},[w,B]);return(0,e.jsxs)("div",{"data-line":b,style:{position:"absolute",top:0,left:0,width:"100%",height:`${p}px`,transform:`translateY(${q}px)`,backgroundColor:z&&y?y.bg:void 0},className:`flex ${v===b?"flash-line":""} ${F?"vi-cursor-line":""} ${l?"bg-blue-9/20":d?"bg-amber-9/10":"hover:bg-accent/50"}`,children:[(0,e.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-secondary",style:{backgroundColor:z&&y?y.bg:void 0},children:[w&&y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,e.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-accent/50",onMouseEnter:M,onMouseLeave:C,onClick:L,title:H("codeViewer.clickToViewCommit"),children:x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-medium",style:{color:y.border},children:w.hash}),(0,e.jsx)("span",{className:"truncate flex-1",children:w.author.split(" ")[0]})]}):null})]}),m&&(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${l?"bg-blue-9/30 text-blue-11":"bg-card/50 text-slate-9"}`,children:[o&&d&&h&&(0,e.jsx)("button",{onClick:a=>r(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:H("codeViewer.nComments",{count:i}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),o&&!d&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"text-right",style:{minWidth:`${n}ch`},children:b})]})]}),(0,e.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:J,onMouseOver:K,onMouseLeave:u,"data-code-content":!0,children:[(0,e.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),D&&(0,e.jsx)(j,{blame:D,onClick:E})]})]},a)});d()}catch(a){d(a)}})},40699:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{u:()=>h});var e=c(67484),f=c(29939),g=c(19872);function h(a,b,c,d,h){let i=(0,e.useRef)(null),j=(0,e.useRef)(0),k=()=>{let a=`live-asst-${++j.current}`;return i.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",isStreaming:!0}]),a},l=a=>{if("system"===a.type&&"init"===a.subtype)return void k();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}let c=i.current??k();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:"";for(let c of(b(a=>{let b=a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("live-")));if(e){let a=b[b.length-1];if(a&&"user"===a.role&&a.content===e)return b.slice(0,b.length-1)}return b}),i.current=null,j.current=0,a.events))l(c);h?.onRunningChange?.(!0)}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){h?.onRunningChange?.(!1),h?.onComplete?.();return}l(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:()=>s,JC:()=>l,M5:()=>j,QW:()=>o,Zr:()=>n,an:()=>r,em:()=>i,l1:()=>k,n_:()=>m,qD:()=>q,td:()=>h});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=()=>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})}),q=a=>d.gen(function*(){let b=yield*p();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*p();return"not-running"===f._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:f}),r=a=>f(`/api/file?path=${encodeURIComponent(a)}`),s=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")})]})]})}},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]);function t({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d,onOpenNote:s}){let{t:u}=(0,g.Bd)(),{consoleItems:v,scrollRef:w,selectedCommandId:x,setSelectedCommandId:y,interruptCommand:z,sendStdin:A,deleteCommand:B,rerunCommand:C,ptySizeRef:D,resizePty:E,executeCommand:F,addPluginItem:G,closePluginItem:H,sleepingBubbles:I,handleBubbleSleep:J,handleBubbleWake:K,scrollToBottom:L,currentCwd:M,commandHistoryRef:N,setCustomEnv:O,setAliases:P,saveBubbleOrder:Q,hasMoreHistory:R,loadHistory:S,currentPage:T,isLoadingHistory:U,subscribePtyOutput:V,subscribePtyReset:W,subscribePtyRefresh:X}=(0,m.cK)({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d}),[Y,Z]=(0,f.useState)(null),[$,_]=(0,f.useState)(0),[aa,ab]=(0,f.useState)(0),[ac,ad]=(0,f.useState)(!0),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(!1),[ak,al]=(0,f.useState)(!1),am=(0,f.useRef)(null),an=(0,f.useRef)(null),ao=(0,f.useRef)(null),ap=(0,f.useRef)(!1),aq=(0,f.useRef)(null),ar=(0,f.useRef)(null),as=(0,f.useRef)([]),at=(0,f.useCallback)(()=>{let a=w.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[w]),au=(0,f.useCallback)(()=>{let a=w.current;return!a||a.scrollTop<50},[w]),av=(0,f.useCallback)(()=>{aj(!au()),al(!at())},[at,au]),aw=(0,f.useCallback)(()=>{an.current?.scrollIntoView({behavior:"smooth"})},[]),ax=(0,f.useCallback)(()=>{ap.current=!0},[]),ay=(0,f.useCallback)((a,b)=>{if(!ap.current)return void a.preventDefault();ap.current=!1,aq.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))}},[]),az=(0,f.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",ar.current=b},[]),aA=(0,f.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.add("ring-2","ring-brand")},[]),aB=(0,f.useCallback)(a=>{a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aC=(0,f.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aD=(0,f.useCallback)(a=>{a.currentTarget.style.opacity="1";let b=aq.current,c=ar.current;if(aq.current=null,ar.current=null,!b||!c||b===c)return;let d=as.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,Q(g)},[Q]),aE=(0,f.useCallback)(a=>{Z(b=>b===a?null:a)},[]),aF=aa>0?Math.floor((aa-32-12)/2-41):void 0;return(0,e.jsxs)("div",{ref:am,className:"h-full flex flex-col bg-background relative",children:[(0,e.jsx)("div",{ref:w,onScroll:av,className:`console-scroll-root flex-1 overflow-y-auto ${Y?"":"py-4 px-4"}`,children:0===v.length?(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:u("console.enterCommandOrUrl")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{ref:an}),R&&(0,e.jsx)("div",{className:"flex justify-center mb-4",children:(0,e.jsx)("button",{onClick:()=>S(T+1),disabled:U,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-50",children:u(U?"console.loadingMore":"console.loadMoreHistory")})}),(0,e.jsx)("div",{className:Y?"flex flex-col gap-3":ac?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:v.map(b=>{let d={draggable:!0,onDragStart:a=>ay(a,b.data.id),onDragOver:a=>az(a,b.data.id),onDragEnter:aA,onDragLeave:aB,onDrop:aC,onDragEnd:aD};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:x===f.id,onSelect:()=>{y(f.id)},onInterrupt:f.isRunning?()=>z(f.id):void 0,onStdin:f.isRunning?a=>A(f.id,a):void 0,onDelete:()=>{f.isRunning&&f.pid&&(0,n.HV)(f.pid),B(f.id)},onRerun:()=>C(f.id),timestamp:f.timestamp,usePty:f.usePty,subscribePtyOutput:f.usePty?V:void 0,subscribePtyReset:f.usePty?W:void 0,subscribePtyRefresh:f.usePty?X:void 0,onPtyResize:(a,b)=>{D.current.set(f.id,{cols:a,rows:b}),E(f.id,a,b)},onToggleMaximize:()=>aE(f.id),maximized:Y===f.id,expandedHeight:$,bubbleContentHeight:aF,onTitleMouseDown:ax})},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:x===i.id,maximized:Y===i.id,expandedHeight:$,bubbleContentHeight:aF,timestamp:i.timestamp,onSelect:()=>{y(i.id)},onClose:()=>H(i.id),onToggleMaximize:()=>aE(i.id),onTitleMouseDown:ax,extra:{addBrowserItem:(a,b)=>G("browser",a,b),initialSleeping:I.has(i.id),onSleep:J,onWake:K,projectCwd:a,tabId:c}})},i.id)})}),(0,e.jsx)("div",{ref:ao})]})}),!Y&&v.length>0&&(0,e.jsx)(l.w,{showTop:ai,showBottom:ak,onScrollTop:aw,onScrollBottom:L}),(0,e.jsx)(k.D,{cwd:a,currentCwd:M,commandHistoryRef:N,gridLayout:ac,onGridLayoutChange:b=>{ad(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:F,onAddPluginItem:G,onShowEnvManager:()=>af(!0),onOpenZsh:()=>F("zsh"),onOpenNote:s}),ae&&(0,e.jsx)(i.v,{cwd:a,tabId:c,onClose:()=>af(!1),onSave:a=>O(a)}),ag&&(0,e.jsx)(j.Y,{onClose:()=>ah(!1),onSave:a=>P(a)})]})}[o,m,h,k]=s.then?(await s)():s,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
25
+ ⚠️ ${c}`:`⚠️ ${c}`,isStreaming:!1}:a)}if("result"===b.type){let c="string"==typeof b.result?b.result.trim():"";return a.map(a=>a.id===e?{...a,content:!a.content&&c?c:a.content,isStreaming:!1,toolCalls:a.toolCalls?.map(a=>({...a,isLoading:!1}))}:a)}return a}c.d(b,{F:()=>d})},20291:(a,b,c)=>{"use strict";c.d(b,{p:()=>i});var d=c(67484),e=c(208),f=c(79606),g=c(33281),h=c(71192);function i({cwd:a,onSearchComplete:b}){let[c,j]=(0,d.useState)(""),[k,l]=(0,d.useState)([]),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(new Set),[s,t]=(0,d.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[u,v]=(0,d.useState)(null),w=(0,d.useRef)(null),x=(0,d.useCallback)(async c=>{let d=c.trim();if(!d){l([]),v(null);return}if(d.length<2)return void p(e.A.t("fileBrowser.searchMinChars"));n(!0),p(null);let i=new URLSearchParams({cwd:a,q:c,caseSensitive:String(s.caseSensitive),wholeWord:String(s.wholeWord),regex:String(s.regex),fileType:s.fileType}),j=f.tryPromise({try:async()=>{let a=await fetch(`/api/files/search?${i}`),b=await a.json();if(b.error)throw Error(b.error);return b},catch:a=>new h.uV({message:"content search failed",cause:a})});await g.t4.runPromise(j.pipe(f.match({onSuccess:a=>{l(a.results),v({totalFiles:a.totalFiles,totalMatches:a.totalMatches,truncated:a.truncated}),r(new Set(a.results.map(a=>a.path))),a.results.length>0&&b?.()},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Search failed"),l([])}}))),n(!1)},[a,s,b]);return{contentSearchQuery:c,setContentSearchQuery:j,contentSearchResults:k,isSearching:m,searchError:o,searchExpandedPaths:q,searchOptions:s,setSearchOptions:t,searchStats:u,contentSearchInputRef:w,performContentSearch:x,handleSearchToggle:(0,d.useCallback)(a=>{r(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},20586:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var e=c(48249),f=c(67484),g=c.n(f),h=c(44384),i=c(7122),j=c(61591);function k({status:a}){let{label:b,className:c}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[a]||{label:"?",className:"text-muted-foreground"};return(0,e.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let a=g().memo(function a({node:b,level:c,selectedPath:d,expandedPaths:g,onSelect:h,onToggle:i,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=d===b.path,p=g.has(b.path),q=(0,f.useCallback)(()=>{b.isDirectory?i(b.path):h(b)},[b,h,i]),r=(0,f.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);return b.isDirectory?(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,e.jsx)("span",{className:"text-slate-9 text-xs",children:p?"▼":"▶"}),(0,e.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,e.jsx)(a,{node:b,level:c+1,selectedPath:d,expandedPaths:g,onSelect:h,onToggle:i,onContextMenu:l,showChanges:m,renderActions:n},b.path))]}):(0,e.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${o?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,e.jsx)(j.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,e.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,e.jsx)(k,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,e.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]}),n&&n(b)]})});function l({files:b,selectedPath:c,expandedPaths:d,onSelect:f,onToggle:g,cwd:j,showChanges:k=!1,renderActions:m,emptyMessage:n,className:o}){let{t:p}=(0,h.Bd)(),q=n??p("gitFileTree.noFiles"),{contextMenu:r,showContextMenu:s,hideContextMenu:t}=(0,i.Ee)();return 0===b.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:q}):(0,e.jsxs)("div",{className:o||"py-1",children:[b.map(b=>(0,e.jsx)(a,{node:b,level:0,selectedPath:c,expandedPaths:d,onSelect:f,onToggle:g,onContextMenu:s,showChanges:k,renderActions:m},b.path)),r&&(0,e.jsx)(i.ft,{x:r.x,y:r.y,path:r.path,cwd:j,isDirectory:r.isDirectory,onClose:t})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),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("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}d()}catch(a){d(a)}})},21482:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(36984),j=a([i]);function k({results:a,loading:b,totalMatches:c,onSelect:d,onClose:i,scope:j,onScopeChange:l,selectedPath:m}){let{t:n}=(0,g.Bd)(),o=function(){let[a,b]=(0,f.useState)(new Map),[c,d]=(0,f.useState)(!1);return(0,f.useRef)(0),a}(),p="selected"===j?a.filter(a=>a.path===m):a,q=p.reduce((a,b)=>a+b.matches.length,0);return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground truncate",children:[n("searchResults.title")," ",!b&&n("searchResults.nMatches",{count:"selected"===j?q:c})]}),(0,e.jsxs)("div",{className:"flex items-center rounded border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,e.jsx)("button",{onClick:()=>l("selected"),className:`px-2 py-0.5 ${"selected"===j?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-accent"}`,children:n("searchResults.scopeSelected")}),(0,e.jsx)("button",{onClick:()=>l("all"),className:`px-2 py-0.5 border-l border-border ${"all"===j?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-accent"}`,children:n("searchResults.scopeAll")})]})]}),(0,e.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-accent text-muted-foreground flex-shrink-0",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.searching")}):0===p.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.noResults")}):p.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a.path}),a.matches.map((b,c)=>{let f=`${a.path}:${b.lineNumber}`,g=o.get(f);return(0,e.jsxs)("button",{onClick:()=>d(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),g?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:g}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},21538:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(35208),i=c(20586),j=c(33281),k=c(85655),l=c(60591),m=c(18921),n=a([i,h]);function o({isOpen:a,onClose:b,commit:c,cwd:d,embedded:n=!1,initialFilePath:p,onContentSearch:q}){let{t:r}=(0,g.Bd)(),[s,t]=(0,f.useState)([]),[u,v]=(0,f.useState)([]),[w,x]=(0,f.useState)(new Set),[y,z]=(0,f.useState)(null),[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=(0,f.useRef)(null),J=(0,m.o)(I),K=(0,f.useCallback)(a=>{c&&(z(a),F(!0),j.t4.runPromiseExit((0,k.Zi)(d,c.hash,a.path)).then(a=>{"Success"===a._tag?B(a.value):console.error(a.cause),F(!1)}))},[d,c]),L=(0,f.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=(0,f.useMemo)(()=>{if(!c)return"";if(c.date){var a;let b,d,e,f,g,h,i;return a=c.date,b=new Date(a),d=new Date,e=b.getFullYear()===d.getFullYear(),f=String(b.getMonth()+1).padStart(2,"0"),g=String(b.getDate()).padStart(2,"0"),h=String(b.getHours()).padStart(2,"0"),i=String(b.getMinutes()).padStart(2,"0"),e?`${f}-${g} ${h}:${i}`:`${b.getFullYear()}-${f}-${g} ${h}:${i}`}return c.time?new Date(1e3*c.time).toLocaleString():""},[c]);if(!a||!c)return null;let N=(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border bg-secondary flex-shrink-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:c.subject}),c.body&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap mb-3 max-h-32 overflow-y-auto border-l-2 border-border pl-3",children:c.body}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.hash")}),(0,e.jsx)("span",{className:"font-mono bg-accent px-1.5 py-0.5 rounded",children:c.hash})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.author")}),(0,e.jsx)("span",{children:c.author}),(0,e.jsxs)("span",{className:"text-slate-9",children:["<",c.authorEmail,">"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.date")}),(0,e.jsx)("span",{children:M}),c.relativeDate&&(0,e.jsxs)("span",{className:"text-slate-9",children:["(",c.relativeDate,")"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-slate-9",children:r("commitDetail.files")}),(0,e.jsx)("span",{children:r("commitDetail.nChanges",{count:s.length})})]})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:C?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:r("commitDetail.loadingFiles")}):(0,e.jsx)(i.VO,{files:u,selectedPath:y?.path||null,expandedPaths:w,onSelect:a=>a.file&&K(a.file),onToggle:L,cwd:d,showChanges:!0,emptyMessage:r("commitDetail.noFileChanges"),className:"py-1"})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:E?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:r("commitDetail.loadingDiff")}):A?(0,e.jsx)(h.xZ,{oldContent:A.oldContent,newContent:A.newContent,filePath:A.filePath,isNew:A.isNew,isDeleted:A.isDeleted,cwd:d,enableComments:!0,onPreview:!A.isDeleted&&A.filePath.endsWith(".json")?()=>H({content:A.newContent,filePath:A.filePath}):void 0,previewLabel:r("common.readable"),onContentSearch:q}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:r("commitDetail.selectFileToView")})})]})]}),O=G&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>H(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:G.filePath}),(0,e.jsx)("button",{onClick:()=>H(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)(m._,{search:J}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,e.jsx)("pre",{ref:I,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,l.xb)(G.content)})})]})});return n?(0,e.jsxs)("div",{className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsx)("button",{onClick:b,className:"absolute top-2 right-2 z-10 p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",title:r("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"})})}),N,O]}):(0,e.jsx)("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:b,children:(0,e.jsxs)("div",{className:"bg-card w-full h-full 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",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r("commitDetail.title")}),(0,e.jsx)("button",{onClick:b,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"})})})]}),N,O]})})}[i,h]=n.then?(await n)():n,d()}catch(a){d(a)}})},21672:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{D:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(46674),i=c(36984),j=a([i]);function k({references:a,loading:b,onSelect:c,onClose:d}){let{t:i}=(0,g.Bd)(),j=function(){let[a,b]=(0,f.useState)(new Map),[c,d]=(0,f.useState)(!1);return(0,f.useRef)(0),a}(),l=[],m=new Map;for(let b=0;b<a.length;b++){let c=a[b],d=m.get(c.file);void 0===d&&(d=l.length,m.set(c.file,d),l.push({file:c.file,items:[]})),l[d].items.push({ref:c,idx:b})}return(0,e.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[i("references.title")," ",!b&&`(${a.length})`]}),(0,e.jsx)("button",{onClick:d,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("references.searching")}):0===a.length?(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("references.notFound")}):l.map(({file:a,items:b})=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:a}),b.map(({ref:a,idx:b})=>(0,e.jsxs)("button",{onClick:()=>c(a),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:a.line}),j.has(b)?(0,e.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:j.get(b)}}):(0,e.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:a.lineText||""})]},`${a.line}-${a.column}-${b}`))]},a))})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},23328:(a,b,c)=>{"use strict";c.d(b,{AJ:()=>n,Cb:()=>z,D0:()=>v,DN:()=>k,Jn:()=>j,Ok:()=>s,QF:()=>i,SN:()=>o,UV:()=>y,Vv:()=>q,Yj:()=>x,Yn:()=>w,bv:()=>p,cm:()=>l,cv:()=>r,jO:()=>t,tp:()=>u,uc:()=>m});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`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,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>g(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>d.gen(function*(){let c=new URLSearchParams({cwd:a});return b&&c.set("tabId",b),(yield*f(`/api/terminal/env?${c}`)).env||{}}),j=()=>f("/api/terminal/aliases").pipe(d.map(a=>a.aliases||{})),k=(a,b)=>f(`/api/terminal/bubble-order?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}`).pipe(d.map(a=>a.order||[])),l=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,order:c,sourceId:d}),m=(a,b,c,d=100)=>f(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&page=${c}&pageSize=${d}`),n=(a,b,c,d)=>h("/api/terminal/history",{cwd:a,tabId:b,entry:c,sourceId:d}),o=(a,b,c,d)=>g(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&commandId=${encodeURIComponent(c)}${d?`&sourceId=${encodeURIComponent(d)}`:""}`,{method:"DELETE"}),p=(a,b,c,d,e)=>g("/api/terminal/history",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,tabId:b,id:c,fields:d,sourceId:e})}),q=a=>h("/api/terminal/env",a),r=a=>h("/api/terminal/aliases",{aliases:a}),s=a=>h("/api/terminal/register",a),t=a=>h("/api/terminal/unregister",a),u=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"POST /api/terminal/autocomplete failed",cause:a})}),v=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),w=a=>h("/api/project-settings",a),x=()=>f("/api/services/config?scope=global"),y=a=>f(`/api/services/config?cwd=${encodeURIComponent(a)}`),z=a=>h("/api/services/config",a)},23700:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{f:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(2929),k=c(38087),l=a([j]);function m({cwd:a,sessionId:b,toolCall:c,workflowRef:d,onClose:l}){let{t:n}=(0,g.Bd)(),[o,p]=(0,f.useState)(null),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!1),u=(0,f.useRef)(void 0),v=d?!!d.running:!c?.result;(0,f.useCallback)(async()=>{let e=await i.t4.runPromiseExit((0,k.z)({cwd:a,sessionId:b,...d?{workflowId:d.runId,workflowAgentId:d.agentId}:{toolUseId:c?.id},ifFingerprint:u.current}));if(t(!0),"Success"!==e._tag||!e.value)return;let f=e.value;f.fingerprint&&(u.current=f.fingerprint),!f.notModified&&(f.messages&&p(f.messages),f.subagent&&r(f.subagent))},[a,b,c?.id,d?.runId,d?.agentId]);let w=(0,f.useRef)(null),x=(0,f.useRef)(!0),y="string"==typeof c?.input?.description?c.input.description:"",z=d?d.label||"":[q?.agentType,y].filter(Boolean).join(" \xb7 ");return(0,e.jsx)(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\uDD16"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:n("chat.subagent")}),z&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0",title:z,children:z}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[v&&(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:n("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",{ref:w,onScroll:()=>{let a=w.current;a&&(x.current=a.scrollTop+a.clientHeight>=a.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===o?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:n(s?"chat.subagentEmpty":"common.loading")}):o.map(b=>(0,e.jsx)(j.s,{message:b,cwd:a},b.id))})]})})})}j=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},23734:(a,b,c)=>{"use strict";c.d(b,{R:()=>e,d:()=>f});var d=c(28031);let e=(a,b)=>({id:a,legacyType:b??a.replace(/-/g,"_").toUpperCase()}),f=d.Io("@cockpit/IframeBus")},23860:(a,b,c)=>{"use strict";c.d(b,{F:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return a}},23881:(a,b,c)=>{"use strict";c.d(b,{s:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g(a){return a.replace(/^\([^)]+\)\s*/,"")}let h=(0,e.forwardRef)(function({displayString:a,documentation:b,x:c,y:h,container:i,onMouseEnter:j,onMouseLeave:k,onFindReferences:l,onSearch:m},n){let{t:o}=(0,f.Bd)(),p=(0,e.useRef)(null);(0,e.useImperativeHandle)(n,()=>p.current,[]);let q=i.getBoundingClientRect(),r=c-q.left,s=h-q.top,t=(0,e.useMemo)(()=>g(a),[a]),u=(0,e.useMemo)(()=>(function(a){let b,c=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b/g,e=[],f=0,g=0,h=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b|"[^"]*"|'[^']*'|\b\d+\b/g;for(;null!==(b=h.exec(a));){b.index>f&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f,b.index)},g++));let h=b[0];/^["']/.test(h)?e.push((0,d.jsx)("span",{className:"text-green-400",children:h},g++)):/^\d+$/.test(h)?e.push((0,d.jsx)("span",{className:"text-orange-300",children:h},g++)):c.test(h)?(c.lastIndex=0,e.push((0,d.jsx)("span",{className:"text-pink-400",children:h},g++))):e.push((0,d.jsx)("span",{className:"text-foreground",children:h},g++)),f=b.index+h.length}return f<a.length&&e.push((0,d.jsx)("span",{className:"text-foreground",children:a.slice(f)},g++)),e})(t),[t]);return(0,e.useEffect)(()=>{if(!p.current)return;let a=p.current,b=i.getBoundingClientRect(),d=a.getBoundingClientRect(),e=c-b.left,f=h-b.top;e+d.width>b.width-8&&(e=b.width-d.width-8),e<8&&(e=8),f+d.height>b.height-8&&(f=f-d.height-24),a.style.left=`${e}px`,a.style.top=`${f}px`},[c,h,i]),(0,d.jsxs)("div",{ref:p,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-xl px-3 py-2 pointer-events-none",style:{left:r,top:s},children:[(0,d.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:u}),b&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:b})]}),(l||m)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border my-1.5"}),(0,d.jsxs)("div",{className:"flex items-center gap-3 pointer-events-auto",onMouseEnter:j,onMouseLeave:k,children:[l&&(0,d.jsx)("button",{onClick:l,className:"text-[11px] text-brand hover:underline cursor-pointer",children:o("hoverTooltip.findReferences")}),m&&(0,d.jsx)("button",{onClick:()=>m(function(a){let b=g(a),c=b.match(/^(?:function|const|let|var|class|interface|type|enum|async function)\s+([a-zA-Z_$][\w$]*)/);if(c)return c[1];let d=a.match(/\([^)]+\)\s+(?:[\w$]+\.)*([a-zA-Z_$][\w$]*)/);if(d)return d[1];let e=b.match(/([a-zA-Z_$][\w$]*)/);return e?e[1]:b.split(/[(\s:]/)[0]}(a)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:o("hoverTooltip.search")})]})]})]})})},24680:(a,b,c)=>{"use strict";c.d(b,{l:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(72529);function h({content:a,containerRef:b,width:c="w-80"}){let{t:i}=(0,f.Bd)(),j=(0,e.useMemo)(()=>(function(a){let b=[],c=a.split("\n"),d=!1;for(let a=0;a<c.length;a++){let e=c[a];if(e.trimStart().startsWith("```")){d=!d;continue}if(d)continue;let f=/^(#{1,6})\s+(.+)$/.exec(e);f&&b.push({level:f[1].length,text:f[2].replace(/\s*#+\s*$/,"").replace(/\\([!-\/:-@[-`{-~])/g,"$1"),sourceLine:a+1})}return b})(a),[a]),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),o=(0,e.useCallback)(a=>{let c=b.current;if(!c)return;let d=c.querySelector(`h1[data-source-start="${a}"], h2[data-source-start="${a}"], h3[data-source-start="${a}"], h4[data-source-start="${a}"], h5[data-source-start="${a}"], h6[data-source-start="${a}"]`);d&&d.scrollIntoView({behavior:"smooth",block:"start"})},[b]);return 0===j.length?null:(0,d.jsxs)("div",{className:`border-r border-border flex-shrink-0 flex flex-col transition-[width] duration-200 ${k?"w-8":c}`,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border flex-shrink-0",children:[!k&&(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("editor.toc")}),(0,d.jsx)("button",{onClick:()=>l(a=>!a),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:i(k?"editor.expandToc":"editor.collapseToc"),children:(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:k?(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"}):(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),!k&&(0,d.jsx)("nav",{className:"flex-1 overflow-y-auto py-1",children:j.map((a,b)=>(0,d.jsx)(g.m,{content:a.text,delay:400,children:(0,d.jsx)("button",{onClick:()=>o(a.sourceLine),className:`block w-full text-left text-sm py-1 px-2 truncate transition-colors hover:bg-accent ${m===a.sourceLine?"text-brand font-medium bg-brand/5":"text-muted-foreground"}`,style:{paddingLeft:`${(a.level-1)*12+8}px`},children:a.text})},b))})]})}},24724:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{h:()=>k});var e=c(48249),f=c(67484),g=c.n(f),h=c(36043),i=c(7122),j=c(61591);let a={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},l=g().memo(function({item:b,isSelected:c,isExpanded:d,isLoading:g,onSelect:h,onToggle:i,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=b,q=o?a[o]:null,r=(0,f.useCallback)(()=>{m.isDirectory?i(m.path):h(m.path)},[m.isDirectory,m.path,h,i]),s=(0,f.useCallback)(a=>{k(a,m.path,m.isDirectory)},[m.path,m.isDirectory,k]),t=!m.isDirectory&&(".env"===m.name||m.name.startsWith(".env.")),u=o?q.text:p?"text-amber-11":t?"text-yellow-600 dark:text-yellow-500":c&&!m.isDirectory?"text-brand":"text-foreground";return(0,e.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-accent ${c?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?g?(0,e.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,e.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,e.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${d?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,e.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,e.jsx)(j.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,e.jsx)("span",{className:`text-sm truncate flex-1 ${u}`,"data-tooltip":m.isSymlink&&m.symlinkTarget?`${m.path} → ${m.symlinkTarget}`:m.path,children:m.name}),m.isSymlink&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,e.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function k({files:a,selectedPath:b,expandedPaths:c,matchedPaths:d=null,gitStatusMap:g=null,loadingDirs:j,onSelect:m,onToggle:n,cwd:o,shouldScrollToSelected:p=!1,onScrolledToSelected:q,className:r,renderActions:s,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x}){let y=(0,f.useRef)(null),{contextMenu:z,showContextMenu:A,hideContextMenu:B}=(0,i.Ee)(),C=(0,f.useMemo)(()=>(function a(b,c,d,e=null,f=0){let g=[];for(let h of b){if(null!==d&&!d.has(h.path))continue;let b=e?.get(h.path),i=h.isDirectory?function(a,b){if(!b)return!1;let c=a+"/";for(let a of b.keys())if(a.startsWith(c))return!0;return!1}(h.path,e):void 0;g.push({node:h,level:f,gitStatus:b,hasChangedChildren:i}),h.isDirectory&&h.children&&c.has(h.path)&&g.push(...a(h.children,c,d,e,f+1))}return g})(a,c,d,g),[a,c,d,g]),D=(0,h.Te)({count:C.length,getScrollElement:()=>y.current,estimateSize:()=>26,overscan:10});return((0,f.useRef)(q).current=q,0===C.length)?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,e.jsxs)("div",{ref:y,className:r||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,e.jsx)("div",{style:{height:`${D.getTotalSize()}px`,width:"100%",position:"relative"},children:D.getVirtualItems().map(a=>{let d=C[a.index];return(0,e.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,e.jsx)(l,{item:d,isSelected:b===d.node.path,isExpanded:c.has(d.node.path),isLoading:j?.has(d.node.path),onSelect:m,onToggle:n,onContextMenu:A,renderActions:s})},d.node.path)})}),z&&(0,e.jsx)(i.ft,{x:z.x,y:z.y,path:z.path,cwd:o,isDirectory:z.isDirectory,onClose:B,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x})]})}d()}catch(a){d(a)}})},24943:(a,b,c)=>{"use strict";c.d(b,{NoteModal:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteModal() from the server but NoteModal 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/NoteModal.tsx","NoteModal")},25465:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ShareReviewToggle:()=>k});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(33281),j=c(83120);function k({content:a,sourceFile:b}){var c;let d,l,m,n,o,{t:p}=(0,g.Bd)(),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!0),[u,v]=(0,f.useState)(!1),w=q?.active===!0,x=(0,f.useCallback)(async()=>{v(!0);let c=b.split("/").pop()||b,d=await i.t4.runPromiseExit((0,j.bx)({title:c,content:a,sourceFile:b}));if("Success"!==d._tag||!d.value.review){(0,h.oR)(p("toast.reviewCreateFailed"),"error"),v(!1);return}let e=d.value.review;r({id:e.id,active:!0,updatedAt:e.updatedAt||e.createdAt});let f=await i.t4.runPromiseExit((0,j._c)()),g="Success"===f._tag&&f.value.shareBase?`${f.value.shareBase}/review/${e.id}`:`${window.location.origin}/review/${e.id}`;try{await navigator.clipboard.writeText(g)}catch{}(0,h.oR)(e.existing?p("toast.reviewUpdated"):p("toast.reviewCreated"),"success"),v(!1)},[a,b,p]),y=(0,f.useCallback)(async()=>{if(!q)return;v(!0);let a=await i.t4.runPromiseExit((0,j.Gm)(q.id,{active:!1}));"Success"===a._tag?(r(a=>a?{...a,active:!1}:null),(0,h.oR)(p("toast.sharingClosed"),"success")):(0,h.oR)(p("toast.sharingCloseFailed"),"error"),v(!1)},[q,p]),z=(0,f.useCallback)(()=>{u||(w?y():x())},[u,w,x,y]),A=(0,f.useCallback)(()=>{q&&window.open(`${window.location.origin}/review/${q.id}`,"_blank")},[q]);return s?null:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:z,disabled:u,className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${u?"opacity-50 cursor-wait":"cursor-pointer"} ${w?"bg-green-500":"bg-muted-foreground/30"}`,title:w?p("review.closeSharing"):p("review.enableSharing"),children:(0,e.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white transition-transform ${w?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsx)("span",{className:`text-[11px] ${w?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,children:w?p("review.sharing"):p("review.notShared")}),w&&q&&q.updatedAt&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(c=q.updatedAt,d=new Date(c),l=String(d.getMonth()+1).padStart(2,"0"),m=String(d.getDate()).padStart(2,"0"),n=String(d.getHours()).padStart(2,"0"),o=String(d.getMinutes()).padStart(2,"0"),`${l}-${m} ${n}:${o}`)}),(0,e.jsx)("button",{onClick:A,className:"text-[11px] text-brand hover:underline",children:p("review.view")})]})]})}d()}catch(a){d(a)}})},25608:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ProjectItem:()=>l});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(29939),j=c(85655);function k({number:a,isActive:b}){return(0,e.jsxs)("svg",{className:`w-6 h-6 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,e.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),(0,e.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function l({index:a,name:b,cwd:c,isActive:d,collapsed:m,hasUnread:n,isLoading:o,onClick:p,onRemove:q,onOpenNote:r}){let{t:s}=(0,g.Bd)(),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useCallback)(()=>{h.t4.runPromiseExit((0,j.ue)(c)).then(a=>{"Success"===a._tag&&w(a.value.branch)})},[c]),y=(0,f.useCallback)(a=>{a?.type==="watch"&&Array.isArray(a.data)&&a.data.some(a=>"git"===a.type)&&x()},[x]);(0,i.h)({url:`/ws/watch?cwd=${encodeURIComponent(c)}`,onMessage:y});let z=v?m?`${b} \xb7 ${v}`:v:c;return(0,e.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${m?"justify-center":""} ${d?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:p,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),"data-tooltip":z,children:[(0,e.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,e.jsx)(k,{number:a+1,isActive:d}),n&&!d&&!o&&(0,e.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),o&&(0,e.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"})]}),!m&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:`flex-1 truncate text-sm ${d?"text-brand":""}`,children:b}),!o&&d?(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]}),t&&!m&&(0,e.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[r&&(0,e.jsx)("button",{className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),r()},title:s("workspace.projectNotes"),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:"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,e.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors",onClick:a=>{a.stopPropagation(),q()},title:s("workspace.closeProject"),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"})})})]})]})}d()}catch(a){d(a)}})},25667:(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(90018);c(33281),c(85655);var h=c(17966),i=a([h,g]);function j({cwd:a,filePath:b,oldContent:c,newContent:d,isNew:h=!1,isDeleted:i=!1,changedFiles:k,fileGitStatusMap:l,enableComments:m=!1,onContentSearch:n,headerExtraLeft:o,headerExtraRight:p}){let[q,r]=(0,f.useState)(b),[s,t]=(0,f.useState)(null);return(0,e.jsx)(g.O,{cwd:a,highlightedFilePath:b,changedFiles:k,enableComments:m,qnameFilter:s?.changedQnames,qnameFilterFile:q,accentQnames:s?.changedQnames,accentFile:q,addedLines:s?.addedLines,addedLinesFile:q,onFocalChange:a=>a&&r(a),onContentSearch:n,headerExtraLeft:o,headerExtraRight:p})}[h,g]=i.then?(await i)():i,d()}catch(a){d(a)}})},25702:(a,b,c)=>{"use strict";c.d(b,{Providers:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Providers() from the server but Providers 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/Providers.tsx","Providers")},28602:(a,b,c)=>{"use strict";function d(){return!("u"<typeof navigator)&&(/Mac|iPhone|iPad/.test(navigator.platform||"")||navigator.userAgentData?.platform==="macOS")}function e(){return d()?"⌘":"Ctrl+"}c.d(b,{L:()=>d,Mu:()=>e}),process.platform,process.platform,process.platform},28797:(a,b,c)=>{"use strict";function d(a){let b=a.split(".").pop()?.toLowerCase();return b?["ts","tsx","js","jsx","mjs","cjs"].includes(b)?"typescript":["py","pyi"].includes(b)?"python":null:null}c.d(b,{c:()=>d})},29412:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>m});var e=c(48249),f=c(67484),g=c(7833),h=c(2633),i=c(62751),j=c(33281),k=c(80532),l=a([h]);function m({isOpen:a,onClose:b}){let[c,d]=(0,f.useState)([]),[l,o]=(0,f.useState)(!1),[p,q]=(0,f.useState)(""),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(""),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(null),z=(0,f.useCallback)(async()=>{o(!0);let a=await j.t4.runPromiseExit((0,k.Hy)());"Success"===a._tag?d(a.value):console.error("Failed to load skills",a.cause),o(!1)},[]),A=(0,f.useMemo)(()=>{let a=p.trim().toLowerCase();return a?c.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):c},[c,p]),B=(0,f.useCallback)(async()=>{let a=t.trim();if(!a)return;w(!0);let b=await j.t4.runPromiseExit((0,k.L5)(a));if("Success"===b._tag)(0,g.oR)("Skill added","success"),u(""),s(!1),await z(),(0,i.k)();else{let a="Fail"===b.cause._tag?b.cause.error:null,c=a?.cause,d=c instanceof Error?c.message:"Failed to add skill";(0,g.oR)(d,"error")}w(!1)},[t,z]),C=(0,f.useCallback)(async a=>{let b=await j.t4.runPromiseExit((0,k.hp)(a));"Success"===b._tag?(d(b=>b.filter(b=>b.id!==a)),(0,i.k)()):(0,g.oR)("Failed to delete","error")},[]),D=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,g.oR)("Path copied","success")}catch{(0,g.oR)("Failed to copy","error")}},[]);return a?(0,e.jsxs)(e.Fragment,{children:[(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-3xl h-[80vh] mx-4 flex flex-col overflow-hidden",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.jsx)("h2",{className:"text-sm font-medium text-foreground",children:"Skills"}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"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 items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsxs)("svg",{className:"w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"11",cy:"11",r:"7",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-4.35-4.35"})]}),(0,e.jsx)("input",{type:"text",value:p,onChange:a=>q(a.target.value),placeholder:"Search skills...",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsx)("button",{onClick:()=>s(!0),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 active:scale-95 transition-all",children:"+ Add Skill"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:l?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:"Loading..."}):0===A.length?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:0===c.length?'No skills yet. Click "Add Skill" to add one.':"No skills match your search."}):A.map(a=>(0,e.jsx)(n,{skill:a,onPreview:()=>y(a.id),onDelete:()=>C(a.id),onCopyPath:()=>D(a.path)},a.id))})]})]}),r&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:()=>{v||(s(!1),u(""))}}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-lg mx-4 p-5",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:"Add Skill"}),(0,e.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:"Absolute path to SKILL.md"}),(0,e.jsx)("input",{type:"text",value:t,onChange:a=>u(a.target.value),onKeyDown:a=>{"Enter"!==a.key||v||B()},placeholder:"/Users/you/.../skills/foo/SKILL.md",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,e.jsx)("button",{onClick:()=>{s(!1),u("")},disabled:v,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50",children:"Cancel"}),(0,e.jsx)("button",{onClick:B,disabled:v||!t.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:v?"Adding...":"Add"})]})]})]}),x&&(0,e.jsx)(h.d,{skillId:x,onClose:()=>y(null)})]}):null}function n({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let[g,h]=(0,f.useState)(!1);return(0,e.jsx)("div",{className:`border border-border rounded-lg p-3 bg-card hover:bg-accent/30 transition-colors ${a.valid?"":"opacity-60"}`,children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:a.icon?(0,e.jsx)("span",{children:a.icon}):(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 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,e.jsxs)("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",a.name]}),a.description&&(0,e.jsx)("span",{className:"text-sm text-muted-foreground line-clamp-2",children:a.description}),!a.valid&&(0,e.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:"Invalid"})]}),a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 truncate",children:a.argumentHint}),(0,e.jsx)("div",{className:"flex items-center gap-1 mt-1",children:(0,e.jsx)("button",{onClick:d,className:"text-xs text-muted-foreground hover:text-foreground font-mono truncate text-left",title:"Copy path",children:a.path})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,e.jsx)("button",{onClick:b,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:"Preview",children:(0,e.jsxs)("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:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),g?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>{h(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:"Confirm"}),(0,e.jsx)("button",{onClick:()=>h(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:"Cancel"})]}):(0,e.jsx)("button",{onClick:()=>h(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:"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 7h22M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3"})})})]})]})})}h=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},29491:(a,b,c)=>{"use strict";c.d(b,{I18nProvider:()=>g});var d=c(48249);c(67484);var e=c(44384),f=c(208);function g({children:a}){return(0,d.jsx)(e.xC,{i18n:f.A,children:a})}c(33281),c(65484)},29939:(a,b,c)=>{"use strict";c.d(b,{h:()=>g});var d=c(67484),e=c(88055),f=c(21586);function g({url:a,onMessage:b,enabled:c=!0}){(0,d.useRef)(b)}e.EV(f.YA(1),1.5).pipe(e.gP(e.ji(f.YA(10))),e.y$(e.t5(10))),e.EV(f.ne(200),2).pipe(e.gP(e.ji(f.YA(5))),e.y$(e.t5(5))),e.EV(f.YA(1),2).pipe(e.et,e.gP(e.ji(f.YA(30))),e.y$(e.t5(8))),e.ji(f.YA(30)),e.ji(f.YA(1)),e.ji(f.YA(30)),f.ne(50),e.BW},30337:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,15098,23)),Promise.resolve().then(c.t.bind(c,47644,23)),Promise.resolve().then(c.t.bind(c,33859,23)),Promise.resolve().then(c.t.bind(c,98099,23)),Promise.resolve().then(c.t.bind(c,16237,23)),Promise.resolve().then(c.t.bind(c,98562,23)),Promise.resolve().then(c.t.bind(c,36675,23))},30458:(a,b,c)=>{"use strict";c.d(b,{E:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(28602);let i={once:[{labelKey:"scheduledTasks.5minLater",value:5},{labelKey:"scheduledTasks.15minLater",value:15},{labelKey:"scheduledTasks.30minLater",value:30},{labelKey:"scheduledTasks.1hourLater",value:60}],interval:[{labelKey:"scheduledTasks.every15min",value:15},{labelKey:"scheduledTasks.every30min",value:30},{labelKey:"scheduledTasks.every1hour",value:60},{labelKey:"scheduledTasks.every2hours",value:120}],cron:[{labelKey:"scheduledTasks.daily9am",value:"0 9 * * *"},{labelKey:"scheduledTasks.daily6pm",value:"0 18 * * *"},{labelKey:"scheduledTasks.weeklyMon9am",value:"0 9 * * 1"},{labelKey:"scheduledTasks.monthly1st9am",value:"0 9 1 * *"}]};function j({onClose:a,onCreate:b,editTask:c,onUpdate:k}){let{t:l}=(0,f.Bd)(),m=!!c,[n,o]=(0,e.useState)(c?.type||"once"),[p,q]=(0,e.useState)(c?.message||""),[r,s]=(0,e.useState)(c?String(c.delayMinutes||c.intervalMinutes||""):""),[t,u]=(0,e.useState)(c?.cron||""),[v,w]=(0,e.useState)(c?.activeFrom||"09:00"),[x,y]=(0,e.useState)(c?.activeTo||"18:00"),[z,A]=(0,e.useState)(!!(c?.activeFrom&&c?.activeTo)),[B,C]=(0,e.useState)(null),D=(0,e.useRef)(null),E=(0,e.useRef)(null),F=(0,e.useCallback)(()=>{if(!p.trim())return;let d=null;if("once"===n){let a=B||parseInt(r,10);if(!a||a<=0)return;d={message:p.trim(),type:"once",delayMinutes:a}}else if("interval"===n){let a=B||parseInt(r,10);if(!a||a<=0)return;d={message:p.trim(),type:"interval",intervalMinutes:a,...z?{activeFrom:v,activeTo:x}:{}}}else if("cron"===n){let a=B||t.trim();if(!a)return;d={message:p.trim(),type:"cron",cron:a}}d&&(m&&c&&k?k(c.id,d):b(d),a())},[p,n,B,r,t,z,v,x,b,a,m,c,k]);return(0,d.jsxs)("div",{ref:D,className:`w-[28rem] max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lg z-50 ${m?"":"absolute bottom-full left-0 mb-2"}`,onKeyDown:b=>{"Escape"===b.key?a():"Enter"===b.key&&(b.metaKey||b.ctrlKey)&&F()},children:[(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 rounded-t-lg",children:(0,d.jsx)("span",{className:"text-sm font-medium",children:m?l("scheduledTasks.editTask"):l("scheduledTasks.createTask")})}),(0,d.jsxs)("div",{className:"p-4 space-y-4 max-h-[min(52rem,calc(100vh-3rem))] overflow-y-auto",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:l("scheduledTasks.sendMessage")}),(0,d.jsx)("textarea",{ref:E,value:p,onChange:a=>q(a.target.value),placeholder:l("scheduledTasks.messagePlaceholder"),rows:5,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring resize-y min-h-[6rem]"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:l("scheduledTasks.type")}),(0,d.jsx)("div",{className:"flex gap-1",children:["once","interval","cron"].map(a=>(0,d.jsx)("button",{onClick:()=>{o(a),C(null),s(""),u("")},className:`flex-1 px-2 py-1 text-xs rounded transition-colors ${n===a?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"once"===a?l("scheduledTasks.once"):"interval"===a?l("scheduledTasks.interval"):"Cron"},a))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:l("scheduledTasks.quickSelect")}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1",children:i[n].map(a=>(0,d.jsx)("button",{onClick:()=>{C(a.value),"cron"===n?u(String(a.value)):s(String(a.value))},className:`px-2 py-1 text-xs rounded border transition-colors ${B===a.value?"border-brand bg-brand/10 text-brand":"border-border text-muted-foreground hover:text-foreground hover:border-foreground/30"}`,children:l(a.labelKey)},a.labelKey))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:"cron"===n?l("scheduledTasks.customCron"):l("scheduledTasks.customMinutes")}),"cron"===n?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{type:"text",value:t,onChange:a=>{u(a.target.value),C(null)},placeholder:l("scheduledTasks.cronPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring font-mono"}),t.trim()&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:function(a){let b=g.A.t,c=a.trim().split(/\s+/);if(5!==c.length)return null;let[d,e,f,h,i]=c,j={0:b("cron.dowSun"),1:b("cron.dowMon"),2:b("cron.dowTue"),3:b("cron.dowWed"),4:b("cron.dowThu"),5:b("cron.dowFri"),6:b("cron.dowSat")},k={1:`1${b("cron.monthPrefix")}`,2:`2${b("cron.monthPrefix")}`,3:`3${b("cron.monthPrefix")}`,4:`4${b("cron.monthPrefix")}`,5:`5${b("cron.monthPrefix")}`,6:`6${b("cron.monthPrefix")}`,7:`7${b("cron.monthPrefix")}`,8:`8${b("cron.monthPrefix")}`,9:`9${b("cron.monthPrefix")}`,10:`10${b("cron.monthPrefix")}`,11:`11${b("cron.monthPrefix")}`,12:`12${b("cron.monthPrefix")}`};try{let a="";if(d.includes("/")||e.includes("/")){if("*"===e&&d.includes("/"))return b("cron.everyNMinutes",{n:d.split("/")[1]});if("0"===d&&e.includes("/"))return b("cron.everyNHours",{n:e.split("/")[1]});return null}let c=parseInt(e,10),g=parseInt(d,10);if(isNaN(c)&&"*"!==e||isNaN(g)&&"*"!==d)return null;a="*"===e&&"*"===d?b("cron.everyMinute"):"*"===e?b("cron.everyHourAtMin",{m:g}):"*"===d?b("cron.hourlyEveryMin",{h:c}):`${String(c).padStart(2,"0")}:${String(g).padStart(2,"0")}`;let l=[];if("*"!==h){let a=h.split(",").map(a=>k[a]||`${a}${b("cron.monthPrefix")}`);l.push(a.join(", "))}if("*"!==f)if(f.includes("-")){let[a,c]=f.split("-");l.push(b("cron.dayRange",{a,b:c}))}else f.includes(",")?l.push(f.split(",").map(a=>`${a}${b("cron.dayOfMonth")}`).join(", ")):l.push(`${f}${b("cron.dayOfMonth")}`);if("*"!==i)if("1-5"===i)l.push(b("cron.weekdays"));else if("0,6"===i||"6,0"===i)l.push(b("cron.weekends"));else{let a=i.split(",").map(a=>{if(a.includes("-")){let[c,d]=a.split("-");return b("cron.weekdayRange",{a:j[c]||c,b:j[d]||d})}return`${b("cron.weekdayPrefix")}${j[a]||a}`});l.push(a.join(", "))}if(0===l.length&&"*"===f&&"*"===h&&"*"===i)return b("cron.daily",{time:a});return`${l.join(" ")} ${a}`}catch{return null}}(t.trim())||(0,d.jsx)("span",{className:"text-destructive",children:l("scheduledTasks.cronFormat")})})]}):(0,d.jsx)("input",{type:"number",value:r,onChange:a=>{s(a.target.value),C(null)},placeholder:l("scheduledTasks.minutesPlaceholder"),min:1,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]}),"interval"===n&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-1 cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:z,onChange:a=>A(a.target.checked),className:"rounded border-border"}),l("scheduledTasks.limitTimeRange")]}),z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("input",{type:"time",value:v,onChange:a=>w(a.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("scheduledTasks.to")}),(0,d.jsx)("input",{type:"time",value:x,onChange:a=>y(a.target.value),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,d.jsx)("button",{onClick:F,disabled:!(p.trim()&&("once"===n||"interval"===n?!!(B||r&&parseInt(r,10)>0):"cron"===n&&!!(B||t.trim()))),className:"w-full py-1.5 text-sm font-medium rounded bg-brand text-white hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:m?l("scheduledTasks.saveBtn",{modKey:(0,h.Mu)()}):l("scheduledTasks.createBtn",{modKey:(0,h.Mu)()})})]})]})}},30894:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{j:()=>a});var e=c(48249),f=c(67484),g=c(44384),h=c(29939),i=c(7833),j=c(95388);let a=(0,f.memo)(function({shortId:a,type:b,onRegister:c,onUnregister:d,fullId:k,projectCwd:l,tabId:m}){let{t:n}=(0,g.Bd)(),[o,p]=(0,f.useState)(!1),[q,r]=(0,f.useState)(""),[s,t]=(0,f.useState)(!1),u=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!k||!l||!m)return;let a=!1,b=new URLSearchParams({cwd:l,tabId:m});return fetch(`/api/terminal/bubble-order?${b.toString()}`).then(a=>a.ok?a.json():null).then(b=>{if(a)return;let c=(b?.data?.titles??{})[k];"string"==typeof c&&r(c)}).catch(()=>{}),()=>{a=!0}},[k,l,m]),(0,h.h)({url:"/ws/global-state",enabled:!!k&&!!l&&!!m,onMessage:a=>{"console-delta"!==a.type||"rename"!==a.op||a.cwd!==l||a.tabId!==m||a.titles&&k&&Object.prototype.hasOwnProperty.call(a.titles,k)&&r(a.titles[k]??"")}});let v=(0,f.useCallback)(async e=>{if(e.stopPropagation(),o)await d(),p(!1),(0,i.oR)(n("toast.disconnected",{id:a}));else{await c(),p(!0);let d=`cockpit ${b} ${a}`;navigator.clipboard.writeText(d),(0,i.oR)(n("toast.copiedCommand",{command:d}))}},[o,a,b,c,d,n]),w=!!(k&&l&&m),x=(0,f.useCallback)(a=>{a.stopPropagation(),w&&t(!0)},[w]),y=(0,f.useCallback)(async a=>{if(k&&l&&m)try{await fetch("/api/terminal/bubble-order",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:l,tabId:m,titles:{[k]:a}})}),r(a),t(!1)}catch{t(!1)}},[k,l,m]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{onClick:v,onDoubleClick:a=>a.stopPropagation(),className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:o?n("shortIdBadge.clickToDisconnect"):n("shortIdBadge.clickToRegister"),children:[(0,e.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${o?"bg-green-500":"bg-muted-foreground/40"}`}),a]}),w&&(q?(0,e.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground",title:n("shortIdBadge.titleSet",{title:q})||q,children:[(0,e.jsx)("span",{className:"px-1 py-0.5 rounded bg-muted/40 max-w-[120px] truncate",children:q}),(0,e.jsx)("button",{ref:u,onClick:x,className:"opacity-50 hover:opacity-100 transition-opacity","aria-label":n("shortIdBadge.editTitle"),title:n("shortIdBadge.editTitle"),children:"✎"})]}):(0,e.jsxs)("button",{ref:u,onClick:x,className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground/50 hover:text-muted-foreground italic transition-colors",title:n("shortIdBadge.setTitle"),children:["(",n("shortIdBadge.setTitlePlaceholder"),") ✎"]})),(0,e.jsx)(j.V,{open:s,anchorRef:u,initialValue:q,onCancel:()=>t(!1),onSave:y})]})});d()}catch(a){d(a)}})},32459:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>j});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(85655);function j({currentCwd:a,onSwitchProject:b,collapsed:c,sessions:d}){let{t:k}=(0,g.Bd)(),[l,m]=(0,f.useState)(!1),[n,o]=(0,f.useState)(0),p=(0,f.useRef)(null),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)({}),u=(0,f.useCallback)((a,b)=>{let c=b.currentTarget.getBoundingClientRect(),d=c.top;d+260>window.innerHeight&&(d=Math.max(8,window.innerHeight-260-8)),r({session:a,top:d,left:c.right+8}),t(b=>a.cwd in b?b:(h.t4.runPromiseExit((0,i.ue)(a.cwd)).then(b=>{"Success"===b._tag&&t(c=>({...c,[a.cwd]:b.value.branch}))}),{...b,[a.cwd]:null}))},[]),v=(0,f.useCallback)(()=>r(null),[]),w=(0,f.useCallback)(a=>{b(a.cwd,a.sessionId),m(!1),r(null)},[b]),x=d.filter(a=>"loading"===a.status).length,y=d.filter(a=>"unread"===a.status).length,z=(0,f.useCallback)(a=>{let b=n-a,c=Math.floor(b/6e4);if(c<1)return k("common.justNow");if(c<60)return k("common.minutesAgo",{count:c});let d=Math.floor(c/60);return d<24?k("common.hoursAgo",{count:d}):k("common.daysAgo",{count:Math.floor(d/24)})},[k,n]),A=a=>a.split("/").pop()||a;return(0,e.jsxs)("div",{className:"relative",ref:p,children:[(0,e.jsxs)("button",{onClick:()=>{o(Date.now()),m(!l)},className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"w-full justify-center":"w-full"}`,title:k("sessions.recentSessions"),children:[(0,e.jsx)("svg",{className:"w-5 h-5 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"})}),!c&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:k("sessions.recentSessions")}),x>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-orange-9 animate-pulse ${c?"absolute -top-1 -right-1":""}`,children:x}),y>0&&(0,e.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 ${c&&!x?"absolute -top-1 -right-1":""}`,children:y})]}),l&&(0,e.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,e.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:k("sessions.recentSessions")}),x>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",k("sessions.runningCount",{count:x}),")"]}),y>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-red-500",children:["(",k("sessions.unreadCount",{count:y}),")"]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===d.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:k("sessions.noSessions")}):d.map((b,c)=>(0,e.jsxs)("button",{onClick:()=>w(b),onMouseEnter:a=>u(b,a),onMouseLeave:v,className:`w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 ${c!==d.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:[(0,e.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${"loading"===b.status?"bg-orange-9 animate-pulse":"unread"===b.status?"bg-red-500":"bg-muted-foreground/30"}`}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:A(b.cwd)}),"loading"===b.status&&(0,e.jsx)("span",{className:"text-xs text-orange-11 flex-shrink-0",children:k("sessions.running")}),"unread"===b.status&&(0,e.jsx)("span",{className:"text-xs text-red-500 flex-shrink-0",children:k("sessions.done")}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:z(b.lastActive)})]}),(b.lastUserMessage||b.title)&&(0,e.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:b.lastUserMessage||b.title})]})]},`${b.cwd}-${b.sessionId}`))})]}),q&&(0,e.jsxs)("div",{className:"fixed z-[60] w-72 max-h-[260px] overflow-y-auto bg-popover border border-border rounded-lg shadow-lg p-3 pointer-events-none",style:{top:q.top,left:q.left},children:[(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:A(q.session.cwd)}),s[q.session.cwd]&&(0,e.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground font-normal min-w-0",children:[(0,e.jsxs)("svg",{className:"w-3 h-3 flex-shrink-0 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"6",cy:"6",r:"2.5"}),(0,e.jsx)("circle",{cx:"6",cy:"18",r:"2.5"}),(0,e.jsx)("circle",{cx:"18",cy:"7",r:"2.5"}),(0,e.jsx)("path",{strokeLinecap:"round",d:"M6 8.5v7M8.5 6.5h4.5a3 3 0 013 3v0"})]}),(0,e.jsx)("span",{className:"truncate",children:s[q.session.cwd]})]}),(q.session.firstMessages?.length??0)>0||(q.session.lastMessages?.length??0)>0?(0,e.jsxs)("div",{className:"space-y-0.5 text-xs border-t border-border/50 mt-2 pt-2",children:[q.session.firstMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`f-${b}`)),(q.session.lastMessages?.length??0)>0&&(0,e.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),q.session.lastMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),a]},`l-${b}`))]}):q.session.lastUserMessage||q.session.title?(0,e.jsx)("div",{className:"text-xs text-foreground/90 border-t border-border/50 mt-2 pt-2 line-clamp-3 break-words",children:q.session.lastUserMessage||q.session.title}):null]})]})}d()}catch(a){d(a)}})},32465:(a,b,c)=>{"use strict";c.d(b,{Y:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(76592),h=c(46674),i=c(59347),j=c(24520),k=c(33281),l=c(23328);function m({onClose:a,onSave:b}){let{t:c}=(0,f.Bd)(),[n,o]=(0,e.useState)({}),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!0);(0,e.useCallback)(async()=>{u(!0);let a=await k.t4.runPromiseExit((0,l.Jn)());"Success"===a._tag?o(a.value):console.error("Failed to load aliases:",a.cause),u(!1)},[]);let v=()=>{p.trim()&&r.trim()&&(o(a=>({...a,[p.trim()]:r.trim()})),q(""),s(""))},w=async()=>{let c=await k.t4.runPromiseExit((0,l.cv)(n));"Success"===c._tag?(b(n),a()):console.error("Failed to save aliases:",c.cause)};return(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,d.jsx)(g.A,{className:"w-5 h-5"}),c("aliasManager.title")]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("aliasManager.description")})]}),(0,d.jsx)("button",{onClick:a,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,d.jsx)(h.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:t?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:c("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(n).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void o(b=>({...b,[a]:c}))},placeholder:c("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,d.jsx)("button",{onClick:()=>{o(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,d.jsx)("input",{type:"text",value:p,onChange:a=>q(a.target.value),placeholder:c("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),v())}})]}),(0,d.jsx)("input",{type:"text",value:r,onChange:a=>s(a.target.value),placeholder:c("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),v())}})]}),(0,d.jsx)("button",{onClick:v,disabled:!p.trim()||!r.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,d.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,d.jsx)("strong",{children:c("aliasManager.usage")}),c("aliasManager.usageDesc")]}),(0,d.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,d.jsx)("span",{children:"→"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(n).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:c("aliasManager.noAliases")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:a,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:c("common.cancel")}),(0,d.jsx)("button",{onClick:w,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:c("common.save")})]})]})})}},32580:(a,b,c)=>{"use strict";function d(a,b){let c=a.split("\n"),d=b.split("\n"),e=[],f=c.length,g=d.length,h=Array(f+1).fill(null).map(()=>Array(g+1).fill(0));for(let a=1;a<=f;a++)for(let b=1;b<=g;b++)c[a-1]===d[b-1]?h[a][b]=h[a-1][b-1]+1:h[a][b]=Math.max(h[a-1][b],h[a][b-1]);let i=f,j=g,k=[];for(;i>0||j>0;)i>0&&j>0&&c[i-1]===d[j-1]?(k.push({type:"unchanged",content:c[i-1],oldLineNum:i,newLineNum:j}),i--,j--):j>0&&(0===i||h[i][j-1]>=h[i-1][j])?(k.push({type:"added",content:d[j-1],newLineNum:j}),j--):(k.push({type:"removed",content:c[i-1],oldLineNum:i}),i--);for(;k.length>0;)e.push(k.pop());return e}c.d(b,{X:()=>d})},33281:(a,b,c)=>{"use strict";c.d(b,{t4:()=>F});var d=c(95753),e=c(88512),f=c(79606),g=c(28582),h=c(61808);let i=d.Um(h.j9,h.dl((a=>{switch((a??"").toLowerCase()){case"all":return g.u8;case"trace":return g.Cn;case"debug":return g.y;case"info":default:return g.R2;case"warning":case"warn":return g.N5;case"error":return g.$D;case"fatal":return g.Lj;case"none":return g.NV}})(process.env.COCKPIT_LOG_LEVEL)));var j=c(1239),k=c(69063);let l=globalThis,m=l.__cockpitSpanRing??={buffer:[],index:new Map},n=a=>{let b="abcdef0123456789",c="";for(let d=0;d<a;d++)c+=b.charAt(Math.floor(Math.random()*b.length));return c};class o{constructor(a,b,c,d,e,f){this.name=a,this.parent=b,this.context=c,this.startTime=e,this.kind=f,this._tag="Span",this.sampled=!0,this.attributes=new Map,this.events=[],this.traceId=j.Ru(b)?b.value.traceId:n(32),this.spanId=n(16),this.status={_tag:"Started",startTime:e},this.links=Array.from(d),function(a){if(m.buffer.push(a),m.index.set(a.spanId,m.buffer.length-1),m.buffer.length>500){m.buffer.shift(),m.index.clear();for(let a=0;a<m.buffer.length;a++)m.index.set(m.buffer[a].spanId,a)}}(function(a,b,c,d,e,f){return{traceId:b,spanId:a,parentSpanId:c,name:d,kind:e,startTimeNs:f.toString(),endTimeNs:null,durationMs:null,attributes:{},events:[],status:"started"}}(this.spanId,this.traceId,function(a){return j.Ru(a)?a.value.spanId:null}(b),a,f,e))}end(a,b){this.status={_tag:"Ended",endTime:a,exit:b,startTime:this.status.startTime},function(a,b,c){let d=m.index.get(a);if(void 0===d)return;let e=m.buffer[d];if(!e)return;let f=Number(b-BigInt(e.startTimeNs))/1e6;m.buffer[d]={...e,endTimeNs:b.toString(),durationMs:Math.round(100*f)/100,status:"Success"===c._tag?"ok":"error",errorMessage:"Failure"===c._tag?function(a){if(a instanceof Error)return a.message;if("string"==typeof a)return a;try{return JSON.stringify(a)}catch{return String(a)}}(c.cause):void 0}}(this.spanId,a,"Success"===b._tag?{_tag:"Success"}:{_tag:"Failure",cause:b.cause})}attribute(a,b){this.attributes.set(a,b),function(a,b,c){let d=m.index.get(a);if(void 0===d)return;let e=m.buffer[d];e&&(m.buffer[d]={...e,attributes:{...e.attributes,[b]:c}})}(this.spanId,a,b)}event(a,b,c){this.events.push([a,b,c??{}]),function(a,b,c,d){let e=m.index.get(a);if(void 0===e)return;let f=m.buffer[e];f&&(m.buffer[e]={...f,events:[...f.events,{name:b,timeNs:c.toString(),attributes:d}]})}(this.spanId,a,b,c)}addLinks(a){this.links.push(...a)}}let p=k.L8({span:(a,b,c,d,e,f)=>new o(a,b,c,d,e,f),context:a=>a()}),q=d.Py(k.sh,p);d.Ie;var r=c(66473);let s=r.eu("dev","prod")("COCKPIT_ENV").pipe(r.IQ("prod")),t=r.Yj("COCKPIT_HOST").pipe(r.IQ("127.0.0.1")),u=r.nd("COCKPIT_PORT").pipe(r.NW(()=>r.nd("PORT")),r.IQ(3457)),v=r.uK(r.Yj("COCKPIT_OPEN_PROJECT")).pipe(r.Tj(a=>"Some"===a._tag?a.value:void 0)),w=r.zM("COCKPIT_NO_OPEN").pipe(r.IQ(!1)),x=r.Yj("COCKPIT_LOG_LEVEL").pipe(r.IQ("info"));f.gen(function*(){let a=yield*s,b=yield*t,c=yield*u,d=yield*v,e=yield*w,g=yield*x,h=yield*f.sync(()=>{let a="u">typeof process?process.env:void 0,b=a?.HOME||a?.USERPROFILE||".",c=a?.COCKPIT_HOME;return c?c.replace(/^~(?=$|\/)/,b):b+"/.cockpit"});return{env:a,host:b,port:3457===c&&"dev"===a?3456:c,cockpitDir:h,openProject:d,openBrowser:!e,logLevel:g,logFile:h+"/logs/cockpit.log"}}).pipe(f.orDie);let y=d.Ie;var z=c(7846),A=c(55805),B=c(23734);let C=d.P1(B.d,f.gen(function*(){let a=yield*z.dT();return yield*f.acquireRelease(f.sync(()=>b=>{f.runFork(z.mk(a,b))}),a=>f.sync(()=>{})),B.d.of({publish:(a,b)=>f.sync(()=>{}),subscribe:b=>A.qdp(a).pipe(A.pbD(a=>{var c;return c=a.data,!!c&&"object"==typeof c&&(c.topic===b.id||c.type===b.legacyType)}),A.TjK(a=>((a,b)=>{if(a.topic===b.id)return a.msg;let{type:c,...d}=a;return d})(a.data,b)))})})),D=d.Um(i,q,y),E=d.Um(D,C),F=e.L8(E);f.void},33988:(a,b,c)=>{"use strict";c.d(b,{B:()=>f});var d=c(67484);c(57031),c(88214);var e=c(76334);function f(a,b,c,f,g){let h=(0,d.useMemo)(()=>(0,e.p)(a),[a]),[i,j]=(0,d.useState)(!1),k=(0,d.useRef)(null);(0,d.useRef)([]),(0,d.useRef)(null),(0,d.useRef)(!1),(0,d.useRef)(c);let l=(0,d.useRef)([]);(0,d.useCallback)(a=>{let c=b.current;if(!c?.contentWindow){let b=k.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"browser:cmd-result",reqId:a.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}c.contentWindow.postMessage({type:"cockpit:cmd",reqId:a.reqId,action:a.action,params:a.params},"*")},[b]);let m=(0,d.useCallback)(()=>i&&k.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(a=>{l.current.push(a),i||j(!0)}),[i]);return{shortId:h,connected:i,connect:m,disconnect:(0,d.useCallback)(()=>{j(!1)},[])}}},34001:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{NoteModal:()=>z});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(13191),j=c(63831),k=c(19043),l=c(48197),m=c(9731),n=c(44551),o=c(53116),p=c(16512),q=c(6993),r=c(11537),s=c(73555),t=c(19545),u=c(92451),v=c(83179),w=c(33281),x=c(79606),y=c(65484);function z({isOpen:a,onClose:b,projectCwd:c,projectName:d}){let{t:A}=(0,g.Bd)(),[B,C]=(0,f.useState)(!0),[D,E]=(0,f.useState)(!1),F=(0,f.useRef)(null),G=(0,f.useRef)(!1),[H,I]=(0,f.useState)(null),J=(0,f.useRef)(null),K=(0,f.useCallback)(async a=>{E(!0);let b=await w.t4.runPromiseExit((0,y.Cq)(c,a).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to save note:",a)))));"Success"===b._tag&&(G.current=!1),E(!1)},[c]),L=(0,f.useCallback)(a=>{G.current=!0,F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{K(a)},5e3)},[K]),M=(0,i.hG)({immediatelyRender:!1,extensions:[j.A.configure({heading:{levels:[1,2,3]}}),k.A.configure({placeholder:()=>h.A.t("editor.placeholder")}),l.XI.configure({resizable:!0}),m.H,n.n,o.A,p._,r.Ay.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),q.L.configure({nested:!0}),s.o.configure({html:!0,transformCopiedText:!0,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},handleClick:(a,b,c)=>{if(c.metaKey||c.ctrlKey){let c=a.state.doc.resolve(b).marks().find(a=>"link"===a.type.name)?.attrs;if(c?.href)return window.open(c.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(a,b)=>{if("Backspace"===b.key&&N.current){let a=N.current;if(a.isActive("codeBlock")){let{$from:b}=a.state.selection,c=b.node(b.depth);if("codeBlock"===c.type.name&&""===c.textContent)return a.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==b.key||H||setTimeout(()=>{if(!N.current)return;let{from:a}=N.current.state.selection,b=N.current.state.doc.textBetween(Math.max(0,a-1),a,"\n");if("/"===b){J.current=a;let b=N.current.view.coordsAtPos(a);I({query:"",position:{top:b.bottom+4,left:b.left}})}},0),!1}},onUpdate:({editor:a})=>{let b=(0,t.up)(a);if(L(b),null!==J.current){let{from:b}=a.state.selection;if(b<J.current)I(null),J.current=null;else{let c=a.state.doc.textBetween(J.current,b,"\n");c.includes(" ")||c.includes("\n")?(I(null),J.current=null):I(a=>a?{...a,query:c}:null)}}}}),N=(0,f.useRef)(M),O=(0,f.useCallback)(()=>{if(F.current&&(clearTimeout(F.current),F.current=null),G.current&&M){let a=(0,t.up)(M);K(a)}I(null),J.current=null,b()},[M,K,b]);return a?(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:O}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",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-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:d?A("editor.noteTitle",{name:d}):A("editor.noteUntitled")}),D&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:A("editor.saving")})]}),(0,e.jsx)("button",{onClick:O,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)(v.NoteToolbar,{editor:M}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:B?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,e.jsx)("span",{children:A("common.loading")})}):(0,e.jsx)(i.$Z,{editor:M})})]}),H&&M&&(0,e.jsx)(u.U,{editor:M,query:H.query,position:H.position,onClose:()=>{I(null),J.current=null}})]}):null}d()}catch(a){d(a)}})},34102:(a,b,c)=>{"use strict";c.d(b,{B:()=>g});var d=c(48249),e=c(67484),f=c(74429);function g(){let[a,b]=(0,e.useState)(null);(0,e.useRef)(null).current=a,(0,e.useRef)(null);let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({left:0,top:0}),[i,j]=(0,e.useState)(!1);return i&&a?(0,f.createPortal)((0,d.jsx)("div",{ref:c,className:"fixed z-[9999] px-2 py-1 bg-popover text-popover-foreground text-xs font-mono rounded shadow-lg border border-brand whitespace-nowrap pointer-events-none max-w-[80vw] overflow-hidden text-ellipsis",style:{left:g.left,top:g.top},children:a.text}),document.body):null}},35208:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{xU:()=>A,xZ:()=>z});var e=c(48249),f=c(67484),g=c(74429),h=c(44384),i=c(36043),j=c(74754),k=c(91579),l=c(7122),m=c(7031),n=c(41051),o=c(42140),p=c(32580),q=c(73414),r=c(7833),s=c(38896),t=c(36984),u=c(74542),v=c(70596),w=c(37690),x=a([s,t]);function y(a){return a.params?`${a.name}(${a.params.join(", ")})`:a.name}function z({oldContent:a,newContent:b,filePath:c,isNew:d=!1,isDeleted:x=!1,cwd:A,enableComments:B=!1,onPreview:C,previewLabel:D,onContentSearch:E,targetLine:F,compact:G=!1,symbols:H}){let{t:I}=(0,h.Bd)(),J=D??I("common.preview"),K=(0,f.useMemo)(()=>(0,p.X)(a,b),[a,b]),L=(0,f.useRef)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useRef)(!1);let[O,P]=(0,f.useState)(!1),Q=(0,l.iN)(),R=(0,m.r)(),S=B&&!!A,{comments:T,addComment:U,updateComment:V,deleteComment:W,refresh:X}=(0,j._)({cwd:A||"",filePath:c}),[Y,Z]=(0,f.useState)(null),[$,_]=(0,f.useState)(null),{toolbarRef:aa,bumpRef:ab,clearToolbar:ac}=(0,w.L)({enabled:S,container:$,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-new-line]");if(!c)return null;let d=parseInt(c.getAttribute("data-new-line")||"0",10);return!Number.isFinite(d)||d<=0?null:{start:d,end:d}},buildLineSnapshot:({start:a,end:b})=>{let c=[],d=0;for(let e of K)("unchanged"===e.type||"added"===e.type)&&++d>=a&&d<=b&&c.push(e.content);return c.join("\n")}}),[ad,ae]=(0,f.useState)(null),[af,ag]=(0,f.useState)(null),ah=(0,f.useMemo)(()=>{let a=new Set;for(let b of T)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[T]),ai=(0,f.useMemo)(()=>{let a=new Map;for(let b of T){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[T]),aj=(0,f.useCallback)((a,b)=>{b.stopPropagation(),Z({comment:a,x:b.clientX,y:b.clientY}),ac(),ae(null),ag(null)},[ac]),ak=(0,f.useCallback)(()=>{let a=aa.current;a&&(ae({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ac())},[ac,aa]),al=(0,f.useCallback)(()=>{let a=aa.current;a&&(ag({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ac())},[ac,aa]),am=(0,f.useCallback)(()=>{let a=aa.current;if(!a||!E)return;let b=a.selectedText.trim();ac(),b&&E(b)},[E,ac,aa]),an=(0,f.useCallback)(async a=>{if(af&&R&&A)try{let b=await (0,k.$3)(A),d=[];for(let a of b)d.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});d.push({filePath:c,startLine:af.range.start,endLine:af.range.end,codeContent:af.lineSnapshot});let e=(0,k.Gw)(d,a);R.sendMessage(e),await (0,k.RP)(A),X(),ag(null)}catch(a){console.error("Failed to send to AI:",a)}},[af,R,c,A,X]),ao=(0,f.useCallback)(async a=>{ad&&(await U(ad.range.start,ad.range.end,a,ad.selectedText),ae(null))},[ad,U]),{leftLines:ap,rightLines:aq}=(0,f.useMemo)(()=>{let a=[],b=[],c=0,d=0;for(let e=0;e<K.length;e++){let f=K[e];if("unchanged"===f.type){for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});c++,d++,a.push({lineNum:c,content:f.content,type:"unchanged",originalIdx:e}),b.push({lineNum:d,content:f.content,type:"unchanged",originalIdx:e})}else"removed"===f.type?(c++,a.push({lineNum:c,content:f.content,type:"removed",originalIdx:e})):"added"===f.type&&(d++,b.push({lineNum:d,content:f.content,type:"added",originalIdx:e}))}for(;a.length<b.length;)a.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;b.length<a.length;)b.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:a,rightLines:b}},[K]),ar=(0,f.useMemo)(()=>K.map(a=>a.content),[K]),as=(0,s.C)(ar,c),[at,au]=(0,f.useState)(()=>new Map),av=(0,f.useMemo)(()=>H??[],[H]),{rows:aw,gaps:ax}=(0,f.useMemo)(()=>G?(0,q.pU)(ap,aq,at,av):{rows:ap.map((a,b)=>({kind:"diff",idx:b})),gaps:[]},[G,ap,ap,aq,at,av]),ay=(0,f.useCallback)((a,b)=>{let c=ax.find(b=>b.id===a);c&&au(d=>{let e=d.get(a)??{topRevealed:0,bottomRevealed:0},f=c.endIdx-c.startIdx+1-e.topRevealed-e.bottomRevealed;if(f<=0)return d;let g=Math.min(q.YO,f),h="up"===b?{...e,topRevealed:e.topRevealed+g}:{...e,bottomRevealed:e.bottomRevealed+g};return new Map(d).set(a,h)})},[ax]);(0,f.useCallback)(a=>{for(let b of ax)if(a>=b.startIdx&&a<=b.endIdx)return b.id;return null},[ax]);let az=(0,f.useCallback)(a=>aw[a]?.kind==="gap-label"?28:20,[aw]),aA=(0,f.useCallback)(a=>{let b=aw[a];if(!b)return a;if("gap-label"===b.kind)return`gl:${b.gapId}`;if("gap-expand"===b.kind)return`ge:${b.gapId}:${b.direction}`;let c=ap[b.idx],d=aq[b.idx];return`d:${c?.lineNum??"x"}:${c?.type??"x"}:${d?.lineNum??"x"}:${d?.type??"x"}`},[aw,ap,aq]),aB=(0,i.Te)({count:aw.length,getScrollElement:()=>L.current,estimateSize:az,getItemKey:aA,overscan:20}),aC=d?"w-1/4":x?"w-3/4":"w-1/2",aD=d?"w-3/4":x?"w-1/4":"w-1/2",aE=(0,f.useMemo)(()=>aw.map(a=>{if("diff"!==a.kind)return{type:"unchanged"};let b=ap[a.idx],c=aq[a.idx];return"removed"===b.type?{type:"removed"}:c?.type==="added"?{type:"added"}:{type:"unchanged"}}),[aw,ap,aq]),aF=aB.getTotalSize(),aG=aB.getVirtualItems();return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,e.jsx)("div",{className:`${aC} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:d?"(New File)":x?"Deleted":"Old"}),(0,e.jsxs)("div",{className:`${aD} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,e.jsx)("span",{className:"block text-center",children:x?"(Deleted)":"New"}),(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[C&&(0,e.jsx)("button",{onClick:C,className:"text-muted-foreground hover:text-foreground transition-colors",children:J}),!x&&b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,r.oR)(I("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:I("common.copy")})]})]}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:L,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,e.jsxs)("div",{className:"flex",style:{height:`${aF}px`},children:[(0,e.jsx)("div",{ref:M,className:`${aC} overflow-x-auto border-r border-border`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:aG.map(a=>{let b=aw[a.index];if("gap-expand"===b.kind||"gap-label"===b.kind){let c="gap-label"===b.kind;return(0,e.jsx)("div",{ref:aB.measureElement,"data-index":a.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:c?"bg-accent border-y border-border":""},a.key)}let c=ap[b.idx];return(0,e.jsxs)("div",{ref:aB.measureElement,"data-index":a.index,"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===c.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:c.lineNum||""}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c.originalIdx>=0&&as[c.originalIdx]||(0,t.ZD)(c.content||" ")}})]},a.key)})})}),(0,e.jsx)("div",{ref:N,className:`${aD} overflow-x-auto`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:aG.map(a=>{let b=aw[a.index];if("gap-expand"===b.kind)return(0,e.jsx)("button",{ref:aB.measureElement,"data-index":a.index,type:"button",onClick:()=>ay(b.gapId,b.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-accent hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:I("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),"aria-label":I("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),children:(0,e.jsx)("span",{className:"select-none",children:I("diffViewer.gap.more",{count:b.revealCount})})},a.key);if("gap-label"===b.kind)return(0,e.jsxs)("div",{ref:aB.measureElement,"data-index":a.index,"data-gap-id":b.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,e.jsx)("span",{className:"flex-shrink-0",children:I("diffViewer.gap.hidden",{count:b.hiddenCount})}),b.enclosingFn&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,e.jsx)("span",{className:"truncate min-w-0 font-medium",title:y(b.enclosingFn),children:y(b.enclosingFn)})]})]},a.key);let c=aq[b.idx],d=c?.lineNum||0,f=d>0&&ah.has(d),g=ai.get(d),h=g?.[0],i=ad&&d>=ad.range.start&&d<=ad.range.end,j=af&&d>=af.range.start&&d<=af.range.end,k=i||j;return(0,e.jsxs)("div",{ref:aB.measureElement,"data-index":a.index,"data-new-line":d||void 0,"data-row-idx":b.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(a.size,az(a.index))}px`,transform:`translateY(${a.start}px)`},className:`flex ${k?"bg-blue-9/20":f?"bg-amber-9/10":c?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${k?"bg-blue-9/30":""}`,style:{width:S?"52px":"40px"},children:[S&&d>0&&f&&h&&(0,e.jsx)("button",{onClick:a=>aj(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:I("codeViewer.nComments",{count:g?.length}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),S&&d>0&&!f&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"flex-1 text-right pr-1",children:d||""})]}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c?.originalIdx>=0&&as[c.originalIdx]||(0,t.ZD)(c?.content||" ")}})]},a.key)})})})]})}),(0,e.jsx)(u.b,{lines:aE,containerRef:L})]}),O&&Q&&(0,g.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(n.f,{floatingToolbarRef:aa,bumpRef:ab,container:Q,onAddComment:ak,onSendToAI:al,onSearch:E?am:void 0,isChatLoading:R?.isLoading??!1}),ad&&(0,e.jsx)(o.t,{x:ad.x,y:ad.y,range:ad.range,lineSnapshot:ad.lineSnapshot,container:Q,onSubmit:ao,onClose:()=>ae(null)}),af&&(0,e.jsx)(o.G,{x:af.x,y:af.y,range:af.range,filePath:c,lineSnapshot:af.lineSnapshot,container:Q,onSubmit:an,onClose:()=>ag(null),isChatLoading:R?.isLoading}),Y&&(0,e.jsx)(v.t,{x:Y.x,y:Y.y,comment:Y.comment,container:Q,onClose:()=>Z(null),onUpdateComment:V,onDeleteComment:W})]}),Q)]})}function A({oldContent:a,newContent:b,filePath:c}){let d=(0,f.useMemo)(()=>(0,p.X)(a,b),[a,b]),g=(0,f.useRef)(null),h=(0,f.useMemo)(()=>d.map(a=>a.content),[d]),j=(0,s.C)(h,c),k=(0,f.useCallback)(a=>{let b=d[a];return b?`${b.type}:${b.oldLineNum??"x"}:${b.newLineNum??"x"}`:a},[d]),l=(0,i.Te)({count:d.length,getScrollElement:()=>g.current,estimateSize:()=>20,getItemKey:k,overscan:20});return(0,e.jsx)("div",{ref:g,className:"font-mono text-sm overflow-auto h-full",children:(0,e.jsx)("div",{style:{height:`${l.getTotalSize()}px`,position:"relative"},children:l.getVirtualItems().map(a=>{let b=d[a.index];return(0,e.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`},className:`flex ${"removed"===b.type?"bg-red-9/15 dark:bg-red-9/25":"added"===b.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==b.type?b.oldLineNum:""}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==b.type?b.newLineNum:""}),(0,e.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===b.type?"text-red-11":"added"===b.type?"text-green-11":"text-slate-9"}`,children:"removed"===b.type?"-":"added"===b.type?"+":" "}),(0,e.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:j[a.index]||(0,t.ZD)(b.content||" ")}})]},a.key)})})})}[s,t]=x.then?(await x)():x,d()}catch(a){d(a)}})},36295:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{G:()=>C,p:()=>A});var e=c(48249),f=c(67484),g=c(46674),h=c(15273),i=c(62956),j=c(82594),k=c(10316),l=c(72419),m=c(44218),n=c(7833),o=c(44384),p=c(34678),q=c(76334),r=c(30894),s=c(28602),t=c(79606),u=c(33281),v=c(23328),w=a([r]);r=(w.then?(await w)():w)[0];let y=(0,f.lazy)(()=>c.e(3792).then(c.bind(c,33792)).then(a=>({default:a.XtermRenderer}))),z={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},A=360,B=/\x1b\[[0-9;]*m/g;function x({output:a,query:b,mode:c,currentIdx:d,matchListRef:g}){let h=(0,f.useRef)(null);h.current||(h.current=new p.v,h.current.use_classes=!0);let i=a.split("\n"),j=b.toLowerCase(),k=0;return g.current=[],(0,e.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:i.map((a,b)=>{let f=a.replace(B,""),i=f.toLowerCase().includes(j);if("filter"===c&&!i)return null;if(!i){let c=h.current.ansi_to_html(a);return(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:c}},b)}let l=[],m=0,n=f.toLowerCase(),o=0;for(;o<n.length;){let a=n.indexOf(j,o);if(-1===a)break;a>m&&l.push((0,e.jsx)("span",{children:f.slice(m,a)},`t${m}`));let b=k++,c=b===d;l.push((0,e.jsx)("mark",{ref:a=>{g.current[b]=a},className:c?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:f.slice(a,a+j.length)},`m${a}`)),o=m=a+j.length}return m<f.length&&l.push((0,e.jsx)("span",{children:f.slice(m)},`t${m}`)),(0,e.jsx)("div",{children:l},b)})})}let C=(0,f.memo)(function({commandId:a,tabId:b,projectCwd:c,command:d,output:w,exitCode:B,isRunning:C,selected:D,onSelect:E,onInterrupt:F,onStdin:G,onDelete:H,onRerun:I,timestamp:J,usePty:K,subscribePtyOutput:L,subscribePtyReset:M,subscribePtyRefresh:N,onPtyResize:O,onToggleMaximize:P,maximized:Q,expandedHeight:R,bubbleContentHeight:S,onTitleMouseDown:T}){let{t:U}=(0,o.Bd)(),V=(0,f.useRef)(null),W=(0,f.useRef)(null),X=(0,f.useRef)(!0),Y=(0,f.useRef)(null),Z=(0,f.useRef)(null),$=(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}`})(J),_=a&&b?(0,q.p)(b+a):void 0,[aa,ab]=(0,f.useState)(!1),[ac,ad]=(0,f.useState)(""),ae=(0,f.useRef)(null),af=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!L||!a)return;let b=()=>{if(ae.current){let b=ae.current.write;return L(a,b)}return null},c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[L,a]),(0,f.useEffect)(()=>{if(!M||!a)return;let b=()=>{if(ae.current){let b=ae.current.reset;return M(a,b)}return null},c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[M,a]),(0,f.useEffect)(()=>{if(!N||!a)return;let b=()=>{if(ae.current){let b=ae.current.refresh;return N(a,b)}return null},c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[N,a]);let[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(""),[ak,al]=(0,f.useState)("search"),[am,an]=(0,f.useState)(0),ao=(0,f.useRef)([]),ap=(0,f.useRef)(null),aq=(0,f.useRef)(0);(0,f.useEffect)(()=>{ap.current||(ap.current=new p.v,ap.current.use_classes=!0)},[]),(0,f.useLayoutEffect)(()=>{let a=W.current;if(a&&ap.current){if(w.length<aq.current&&(ap.current=new p.v,ap.current.use_classes=!0,aq.current=0,a.innerHTML=""),w.length>aq.current){let b=w.slice(aq.current),c=ap.current.ansi_to_html(b);aq.current=w.length,a.insertAdjacentHTML("beforeend",c)}if(V.current){let a=V.current.scrollHeight>V.current.clientHeight;ab(a),a&&(V.current.scrollTop=V.current.scrollHeight)}}},[w]),(0,f.useEffect)(()=>(C&&X.current&&V.current&&(null!==Y.current&&cancelAnimationFrame(Y.current),Y.current=requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=V.current.scrollHeight),Y.current=null})),()=>{null!==Y.current&&cancelAnimationFrame(Y.current)}),[w,C]),(0,f.useEffect)(()=>{if(!Q)return;let a=a=>{"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),P?.())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[Q,P]);let ar=w?w.split("\n").length:0,as=(0,f.useCallback)(()=>{ah(!0),requestAnimationFrame(()=>af.current?.focus())},[]),at=(0,f.useCallback)(()=>{ah(!1),aj(""),an(0),ae.current?.clearSearch()},[]),au=(0,f.useCallback)(a=>{a.trim()&&(K?ae.current?.findNext(a):an(a=>{let b=a+1,c=ao.current[b];return c?(c.scrollIntoView({block:"nearest"}),b):(ao.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[K]),av=(0,f.useCallback)(a=>{a.trim()&&(K?ae.current?.findPrevious(a):an(a=>{let b=a-1;if(b>=0)return ao.current[b]?.scrollIntoView({block:"nearest"}),b;let c=ao.current.length-1;return c>=0&&ao.current[c]?.scrollIntoView({block:"nearest"}),Math.max(c,0)}))},[K]);(0,f.useEffect)(()=>{if(!D)return;let a=a=>{if((a.metaKey||a.ctrlKey)&&"f"===a.key){a.preventDefault(),a.stopPropagation(),as();return}if("Escape"===a.key&&ag){a.preventDefault(),a.stopPropagation(),at();return}};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[D,ag,as,at]);let aw=Q&&R?R-41:S??A;return(0,e.jsx)("div",{className:"flex flex-col items-start",children:(0,e.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${Q?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${Q?"":D?"border-brand":"border-brand/30"}`,onClick:E,children:[Q?(0,e.jsxs)("div",{onDoubleClick:()=>P?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,e.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,e.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:d}),C&&(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),U("console.runningText")]}),C&&F&&(0,e.jsx)("button",{onClick:F,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,e.jsx)("button",{onClick:()=>P?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:U("console.restoreTooltip",{modKey:(0,s.Mu)()}),children:(0,e.jsx)(g.A,{className:"w-4 h-4"})})]}):(0,e.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>T?.(),onDoubleClick:a=>{a.stopPropagation(),P?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${D?"border-brand":"border-brand/30"}`,children:[(0,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:">_"}),_&&a&&b&&(0,e.jsx)(r.j,{shortId:_,type:"terminal",onRegister:()=>{u.t4.runFork((0,v.Ok)({tabId:b,commandId:a,command:d,projectCwd:c}).pipe(t.orElse(()=>t.void)))},onUnregister:()=>{u.t4.runFork((0,v.jO)({commandId:a}).pipe(t.orElse(()=>t.void)))},fullId:a,projectCwd:c,tabId:b}),(0,e.jsx)("span",{className:"font-mono text-foreground truncate",children:d}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(d),(0,n.oR)(U("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:U("console.copyCommand"),children:(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("span",{className:"flex-1"}),aa&&!C&&(0,e.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:U("console.totalLines",{count:ar})}),w&&(0,e.jsx)("button",{onClick:a=>{let b;a.stopPropagation(),b=w.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(b),(0,n.oR)(U("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:U("console.copyOutput"),children:(0,e.jsx)(i.A,{className:"w-3.5 h-3.5"})}),I&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),I()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:U("console.rerun"),children:(0,e.jsx)(j.A,{className:"w-3.5 h-3.5"})}),H&&(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),H()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:U("console.deleteRecord"),children:(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),ag&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,e.jsx)(k.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,e.jsx)("input",{ref:af,value:ai,onChange:a=>{let b=a.target.value;aj(b),an(0),K&&(b.trim()?ae.current?.findNext(b):ae.current?.clearSearch())},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?av(ai):au(ai))},placeholder:U("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}),!K&&(0,e.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,e.jsx)("button",{onClick:()=>al("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===ak?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:U("console.searchMode")}),(0,e.jsx)("button",{onClick:()=>al("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===ak?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:U("console.filterMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>av(ai),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:U("console.prevShiftEnter"),children:(0,e.jsx)(l.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>au(ai),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:U("console.nextEnter"),children:(0,e.jsx)(m.A,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("button",{onClick:at,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),K?(0,e.jsxs)("div",{className:"relative group",style:{height:aw,overflow:"hidden"},children:[(0,e.jsx)(f.Suspense,{fallback:(0,e.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:aw},children:U("console.loadingTerminal")}),children:(0,e.jsx)(y,{ref:ae,output:w,isRunning:C,onInput:G,onResize:O,maximized:Q,height:aw,directWrite:!!L})}),!C&&I&&(0,e.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",onClick:a=>{a.stopPropagation(),I()},title:U("console.rerun"),children:(0,e.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-black/60 text-white text-xs",children:[(0,e.jsx)(j.A,{className:"w-3.5 h-3.5"}),U("console.rerun")]})})]}):(0,e.jsx)("div",{ref:V,className:"overflow-auto px-4 py-2",style:{height:aw},onScroll:()=>{if(V.current){let{scrollTop:a,scrollHeight:b,clientHeight:c}=V.current;X.current=b-a-c<50}},children:ag&&ai.trim()?(0,e.jsx)(x,{output:w,query:ai,mode:ak,currentIdx:am,matchListRef:ao}):(0,e.jsx)("pre",{ref:W,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),C&&!Q&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),K?(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:U("console.clickToInput")}):G?(0,e.jsx)("input",{ref:Z,value:ac,onChange:a=>ad(a.target.value),onKeyDown:a=>{if(a.ctrlKey&&!a.metaKey&&!a.altKey){let b=z[a.key.toLowerCase()];if(b){a.preventDefault(),a.stopPropagation(),G(b);return}}"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),G(ac+"\n"),ad("")),"Tab"===a.key&&(a.preventDefault(),G(" "))},placeholder:U("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:U("console.runningText")}),F&&(0,e.jsx)("button",{onClick:F,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),$&&(0,e.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:$})]}),!C&&void 0!==B&&!Q&&(0,e.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===B?"bg-green-500":"bg-red-500"}`}),(0,e.jsx)("span",{children:U("console.exitCode",{code:B})}),(0,e.jsx)("span",{className:"flex-1"}),$&&(0,e.jsx)("span",{className:"text-[11px] flex-shrink-0",children:$})]})]})})});d()}catch(a){d(a)}})},36984:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Np:()=>k,ZD:()=>i,b8:()=>j,kS:()=>g,sQ:()=>h});var e=c(78908),f=a([e]);e=(f.then?(await f)():f)[0];let l=null,m=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function g(){return l||(l=(0,e.createHighlighter)({themes:["github-dark","github-light"],langs:[...m]})),l}function h(a){let b=a.split("/").pop()?.toLowerCase()||"",c=b.split(".").pop()?.toLowerCase();if(".env"===b||b.startsWith(".env.")||"dockerfile"===b||b.startsWith("dockerfile.")||"makefile"===b)return"bash";let d={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[c||""]||"text";return m.includes(d)?d:"text"}function i(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function j(a){return a.map(a=>a.color?`<span style="color:${a.color}">${i(a.content)}</span>`:i(a.content)).join("")}function k(a,b,c,d){if(!b)return[];let e=[],f=c?b:b.toLowerCase();for(let b=0;b<a.length;b++){let g=c?a[b]:a[b].toLowerCase(),h=0;for(;;){let a=g.indexOf(f,h);if(-1===a)break;let c=a+f.length;if(d){let d=a>0?g[a-1]:" ",f=c<g.length?g[c]:" ",h=!/\w/.test(d),i=!/\w/.test(f);h&&i&&e.push({lineIndex:b,startCol:a,endCol:c})}else e.push({lineIndex:b,startCol:a,endCol:c});h=a+1}}return e}d()}catch(a){d(a)}})},37129:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{useTabState:()=>k});var e=c(67484),f=c(23860),g=c(29939);c(57031),c(88214);var h=c(79606),i=c(33281),j=c(37388);function k({initialCwd:a,initialSessionId:b,activeView:c}){(0,e.useRef)(!1);let d=(0,e.useRef)(!0),l=(0,e.useRef)(c),m=(0,f.F)(),n=(0,e.useRef)(m),[o,p]=(0,e.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),[q,r]=(0,e.useState)(o[0]?.id??""),[s,t]=(0,e.useState)(new Set),u=(0,e.useRef)(o),v=(0,e.useRef)(q),w=(0,e.useRef)(new Set),x=(0,e.useCallback)((b,c)=>{a&&b&&i.t4.runFork((0,j.KJ)(a,b,c).pipe(h.catchAll(()=>h.void)))},[a]),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),C=(0,e.useCallback)(b=>{a&&i.t4.runPromise((0,j.n8)(a).pipe(h.catchAll(()=>h.succeed(null)))).then(c=>{if(!c)return;let d=c.sessions||[],e=c.engines||{},f=c.ollamaModels||{},g=c.deepseekModels||{},h=c.chatModes||{},i=c.planModes||{},j=u.current,k=new Set(b),l=j.filter(a=>!a.sessionId||!k.has(a.sessionId)),m=new Set(l.map(a=>a.sessionId).filter(Boolean)),n=d.filter(a=>!m.has(a));if(l.length===j.length&&0===n.length)return;let o=n.map((b,c)=>({id:`tab-${Date.now()}-sync-${c}`,cwd:a,sessionId:b,title:`Session ${b.slice(0,6)}...`,engine:e[b]||void 0,ollamaModel:f[b]||void 0,deepseekModel:g[b]||void 0,chatMode:h[b]||void 0,planMode:i[b]||void 0})),q=[...l,...o];0===q.length&&(q=[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),p(q),q.some(a=>a.id===v.current)||r(q[q.length-1].id)})},[a]);(0,g.h)({url:"/ws/global-state",enabled:!!a,onMessage:b=>{d.current||!a||"project-state-changed"===b.type&&b.cwd===a&&C(b.closedSessionIds??[])}});let D=(0,e.useCallback)((a,b,c,d,e,f,g=!1)=>{let h={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat"),engine:d,ollamaModel:e,deepseekModel:f};p(a=>{if(g)return[...a,h];let b=a.findIndex(a=>a.id===q);if(-1===b)return[...a,h];let c=[...a];return c.splice(b+1,0,h),c}),r(h.id)},[q]),E=(0,e.useCallback)(b=>{let c=u.current.find(a=>a.id===b);c?.sessionId&&w.current.add(c.sessionId),p(c=>{let d=c.filter(a=>a.id!==b);if(b===q&&d.length>0&&r(d[d.length-1].id),0===d.length){let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};return r(b.id),[b]}return d})},[q,a]),F=(0,e.useCallback)((b,c)=>{let d=o.find(a=>a.sessionId===b);d?r(d.id):D(a,b,c,void 0,void 0,void 0,!0)},[o,a,D]),G=(0,e.useCallback)(()=>{D(a,void 0,void 0,void 0,void 0,void 0,!0)},[a,D]),H=(0,e.useCallback)(()=>{D(a,void 0,"New Claude 2 Chat","claude2",void 0,void 0,!0)},[a,D]),I=(0,e.useCallback)(()=>{D(a,void 0,"New Codex Chat","codex",void 0,void 0,!0)},[a,D]),J=(0,e.useCallback)(()=>{D(a,void 0,"New Kimi Chat","kimi",void 0,void 0,!0)},[a,D]),K=(0,e.useCallback)(b=>{D(a,void 0,b?`New Ollama (${b})`:"New Ollama Chat","ollama",b,void 0,!0)},[a,D]),L=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,ollamaModel:b}:c))},[]),M=(0,e.useCallback)(()=>{D(a,void 0,"New DeepSeek Chat","deepseek",void 0,"deepseek-v4-flash",!0)},[a,D]),N=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,deepseekModel:b}:c))},[]),O=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,chatMode:b}:c))},[]),P=(0,e.useCallback)((a,b)=>{p(c=>c.map(c=>c.id===a?{...c,planMode:b}:c))},[]),Q=(0,e.useCallback)((b,c)=>{D(a,b,c)},[a,D]),R=(0,e.useCallback)((a,b)=>{p(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!l.current||"agent"===l.current;if(a===q&&c&&n.current){let a=d.sessionId||b.sessionId;a&&x(a,"normal")}else t(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[q,x]),S=(0,e.useCallback)(a=>{r(a),t(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=u.current.find(b=>b.id===a);return d?.sessionId&&(x(d.sessionId,"normal"),i.t4.runFork((0,j.M2)(d.sessionId).pipe(h.catchAll(()=>h.void)))),c})},[x]),T=(0,e.useCallback)(a=>{z(a)},[]),U=(0,e.useCallback)((a,b)=>{a.preventDefault(),null!==y&&y!==b&&B(b)},[y]),V=(0,e.useCallback)(a=>{null!==y&&y!==a&&p(b=>{let c=[...b],[d]=c.splice(y,1);return c.splice(a,0,d),c}),z(null),B(null)},[y]),W=(0,e.useCallback)(()=>{z(null),B(null)},[]),X=o.find(a=>a.id===q);return{tabs:o,activeTabId:q,activeTab:X,unreadTabs:s,dragTabIndex:y,dragOverTabIndex:A,addTab:D,closeTab:E,switchTab:S,handleSelectSession:F,handleNewTab:G,handleNewClaude2Tab:H,handleNewCodexTab:I,handleNewKimiTab:J,handleNewOllamaTab:K,handleNewDeepseekTab:M,handleOpenSession:Q,updateTabState:R,updateTabOllamaModel:L,updateTabDeepseekModel:N,updateTabChatMode:O,updateTabPlanMode:P,handleTabDragStart:T,handleTabDragOver:U,handleTabDrop:V,handleTabDragEnd:W}}d()}catch(a){d(a)}})},37202:(a,b,c)=>{"use strict";c.d(b,{M:()=>m,O:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(74429);let h=[],i=[];function j(){i.forEach(a=>a())}function k(a){let b=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;h=[...h,{...a,id:b}],j()}function l(a){h=h.filter(b=>b.id!==a),j()}function m({onNavigate:a}){let b=function(){let[,a]=(0,e.useState)(0);return h}();return 0===b.length?null:(0,g.createPortal)((0,d.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:b.map(b=>(0,d.jsx)(n,{item:b,onNavigate:a,onRemove:l},b.id))}),document.body)}function n({item:a,onNavigate:b,onRemove:c}){let{t:g}=(0,f.Bd)(),[h,i]=(0,e.useState)(!1),j=(0,e.useRef)(void 0),k=(0,e.useCallback)(()=>{i(!0),setTimeout(()=>c(a.id),300)},[a.id,c]),l=(0,e.useCallback)(()=>{clearTimeout(j.current),b(a.cwd,a.sessionId),c(a.id)},[a,b,c]),m=(0,e.useCallback)(()=>{clearTimeout(j.current)},[]),o=(0,e.useCallback)(()=>{j.current=setTimeout(k,2e3)},[k]);return(0,d.jsxs)("div",{className:`pointer-events-auto bg-card border border-border rounded-lg shadow-lg px-3 py-2.5 min-w-[260px] max-w-[340px] cursor-pointer hover:bg-accent transition-all ${h?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:h?void 0:"slideInLeft 0.3s ease-out"},onClick:l,onMouseEnter:m,onMouseLeave:o,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-green-9 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"})}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.projectName}),(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:g("common.done")}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k()},className:"ml-auto p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",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.message&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-1 ml-6",children:a.message})]})}},37388:(a,b,c)=>{"use strict";c.d(b,{KJ:()=>h,M2:()=>i,ej:()=>g,n8:()=>f});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(`/api/project-state?cwd=${encodeURIComponent(a)}`);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"loadProjectState failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/project-state",{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:"saveProjectState failed",cause:a})}),h=(a,b,c)=>d.tryPromise({try:async()=>{let d=await fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c})});if(!d.ok)throw Error(`HTTP ${d.status}`)},catch:a=>new e.uV({message:"updateSessionStatus failed",cause:a})}),i=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markReadBySessionId",fields:{sessionId:a}})});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"markScheduledTasksReadBySession failed",cause:a})})},37690:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(67484);function e({enabled:a,container:b,resolveLineRange:c,buildLineSnapshot:f,dragThresholdPx:g=5}){let h=(0,d.useRef)(null),i=(0,d.useRef)(()=>{}),j=(0,d.useRef)(c),k=(0,d.useRef)(f),l=(0,d.useRef)(g);return j.current=c,k.current=f,l.current=g,{toolbarRef:h,bumpRef:i,clearToolbar:()=>{h.current&&(h.current=null,i.current())}}}},38087:(a,b,c)=>{"use strict";c.d(b,{m:()=>i,z:()=>h});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=a=>e.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 g.uV({message:"session-by-path failed",cause:a})});function i(a,b,c,{cwd:j,initialSessionId:k,onSessionId:l,onTitleChange:m,onTokenUsage:n,liveRunningRef:o}){let[p,q]=(0,d.useState)(!1),[r,s]=(0,d.useState)(!1),[t,u]=(0,d.useState)(!1),[v,w]=(0,d.useState)(void 0),[x,y]=(0,d.useState)(0),[z,A]=(0,d.useState)(null),[B,C]=(0,d.useState)(null),D=(0,d.useRef)(m);D.current=m;let E=(0,d.useRef)(n);E.current=n;let F=(0,d.useRef)(void 0),G=(0,d.useRef)(0),H=(0,d.useCallback)(async(a,c,d=!1,e,g)=>{if(d){let a=Date.now();if(a-G.current<5e3)return;G.current=a}d||q(!0);try{let i={cwd:a,sessionId:c,limit:e,beforeTurnIndex:g};d&&F.current&&(i.ifFingerprint=F.current);let j=await f.t4.runPromiseExit(h(i));if("Success"===j._tag&&j.value){let a=j.value;if(a.notModified)return;a.fingerprint&&(F.current=a.fingerprint),void 0!==a.totalTurns&&y(a.totalTurns),void 0!==a.hasMore&&u(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>{let c=a.messages;if(b.length===c.length&&b.length>0&&b[b.length-1].content===c[c.length-1].content)return b;let d=0;for(let a=0;a<Math.min(b.length,c.length)&&b[a].id===c[a].id&&b[a].content===c[a].content;a++)d=a+1;return d===b.length&&d<c.length?[...b,...c.slice(d)]:c}):o?.current||b(a.messages),A(c)),a.sessionId&&l(a.sessionId),a.engine&&C(a.engine),a.title&&D.current?.(a.title),a.usage&&E.current?.({inputTokens:a.usage.input_tokens||0,outputTokens:a.usage.output_tokens||0,cacheCreationInputTokens:a.usage.cache_creation_input_tokens||0,cacheReadInputTokens:a.usage.cache_read_input_tokens||0,totalCostUsd:0})}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||q(!1)}},[b,l]),I=(0,d.useCallback)(async()=>{if(j&&c&&!r&&t){s(!0);try{let d=void 0!==v?v:x-Math.ceil(a.filter(a=>"user"===a.role).length),e=await f.t4.runPromiseExit(h({cwd:j,sessionId:c,limit:10,beforeTurnIndex:d>0?d:void 0}));if("Success"===e._tag&&e.value){let a=e.value;if(a.messages&&a.messages.length>0){b(b=>[...a.messages,...b]);let e=a.messages.filter(a=>"user"===a.role).length;w(d-e),A(c)}void 0!==a.hasMore&&u(a.hasMore),a.fingerprint&&(F.current=a.fingerprint)}else"Failure"===e._tag&&console.error("Failed to load more history:",e.cause)}finally{s(!1)}}},[j,c,r,t,v,x,a,b]);return{isLoadingHistory:p,isLoadingMore:r,hasMoreHistory:t,loadMoreHistory:I,loadHistory:(0,d.useCallback)(async a=>{q(!0);let c=e.tryPromise({try:async()=>{let b=await fetch(`/api/session/${a}/history`);return b.ok?await b.json():null},catch:a=>new g.uV({message:"load session history failed",cause:a})}),d=await f.t4.runPromiseExit(c);"Success"===d._tag&&d.value?.messages&&d.value.messages.length>0?(b(d.value.messages),A(a)):"Failure"===d._tag&&console.error("Failed to load history:",d.cause),q(!1)},[b]),loadHistoryByCwdAndSessionId:H,loadedSessionId:z,loadedEngine:B}}},38878:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManagerTopBar:()=>s});var e=c(48249),f=c(67484),g=c(94192),h=c(12568),i=c(7833),j=c(44384),k=c(57031),l=c(88214),m=c(79606),n=c(33281),o=c(85655),p=c(65484),q=a([h]);function r({cwd:a,currentBranch:b,onSwitched:c}){let{t:d}=(0,j.Bd)(),[g,h]=(0,f.useState)(!1),[k,l]=(0,f.useState)([]),[m,q]=(0,f.useState)(!1),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(""),w=(0,f.useRef)(null),x=(0,f.useRef)(null),y=(0,f.useCallback)(async()=>{q(!0);let b=await n.t4.runPromiseExit((0,o.r4)(a));if("Success"===b._tag){let a=b.value,c=a.local??[],d=a.remote??[],e=[...c,...d.filter(a=>!c.includes(a.replace(/^origin\//,"")))];l(e)}else(0,i.oR)(d("toast.loadBranchFailed"),"error");q(!1)},[a,d]),z=(0,f.useCallback)(()=>{h(!0),v(""),y()},[y]),A=(0,f.useCallback)(()=>{h(!1)},[]),B=async b=>{t(!0);let e=await n.t4.runPromiseExit((0,p.Kl)({action:"checkout",cwd:a,path:a,branch:b}));if("Success"===e._tag){let a=b.replace(/^origin\//,"");(0,i.oR)(d("toast.switchedToBranch",{branch:a}),"success"),A(),c()}else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:d("toast.switchBranchFailed");(0,i.oR)(c,"error")}t(!1)},C=k.filter(a=>a!==b&&a.toLowerCase().includes(u.toLowerCase()));return(0,e.jsxs)("div",{className:"relative",ref:w,children:[(0,e.jsx)("button",{onClick:g?A:z,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:d("git.switchBranch"),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 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),g&&(0,e.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lg z-50 overflow-hidden",children:[(0,e.jsx)("div",{className:"p-2 border-b border-border",children:(0,e.jsx)("input",{ref:x,type:"text",value:u,onChange:a=>v(a.target.value),placeholder:d("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none placeholder:text-muted-foreground",onKeyDown:a=>{"Escape"===a.key&&A()}})}),(0,e.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:m?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("common.loading")}):0===C.length?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:u?d("git.noMatchingBranches"):d("git.noBranches")}):C.map(a=>(0,e.jsx)("button",{onClick:()=>B(a),disabled:s,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate disabled:opacity-50",children:(0,e.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function s({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:d,onOpenWorktree:f,onOpenAliasManager:o,onBranchSwitched:q}){let{t}=(0,j.Bd)();return(0,e.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:t("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,i.oR)(t("toast.copiedPageUrl"),"success")})}}),a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help",title:`CWD: ${a}`,children:a}),(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(t("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:t("tabManagerTopBar.copyDirPath"),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)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsxs)("button",{onClick:f,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:"Git Worktrees",children:[(0,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:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,e.jsx)("span",{className:"text-sm",children:d||"main"})]}),(0,e.jsx)(r,{cwd:a,currentBranch:d,onSwitched:()=>q?.()})]})]}),(0,e.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,e.jsx)(g.gT,{})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(h.ReviewDropdown,{cwd:a}),(0,e.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.refreshProject"),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 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:()=>{b?.cwd&&n.t4.runFork((0,p.em)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.openInVSCode"),children:(0,e.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,e.jsx)("path",{d:"M17.583 2.213L12 7.393 6.417 2.213 1 6.17v11.66l5.417 3.957L12 16.607l5.583 5.18L23 17.83V6.17l-5.417-3.957zM6.417 17.83L3 15.33V8.67l3.417-2.5v11.66zm11.166 0V6.17L21 8.67v6.66l-3.417 2.5z"})})}),(0,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,p.Q1)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.openInCursor"),children:(0,e.jsx)("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,e.jsx)("path",{d:"M4.5 2L20.5 12L4.5 22V2Z"})})}),b?.sessionId&&(0,e.jsx)("button",{onClick:()=>{let a=`claude -r ${b.sessionId}`;navigator.clipboard.writeText(a).then(()=>{(0,i.oR)(t("toast.copiedCommand",{command:a}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("chat.copyCommandTooltip",{sessionId:b.sessionId}),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:"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:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.aliasesGlobal"),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:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,e.jsx)("button",{onClick:()=>(0,k.F)(l.n.OpenTokenStats,{}),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.tokenStats"),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:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,e.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",title:t("tabManagerTopBar.openSurething"),children:(0,e.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}h=(q.then?(await q)():q)[0],d()}catch(a){d(a)}})},38896:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{C:()=>h});var e=c(67484),f=c(36984),g=a([f]);function h(a,b){let[c,d]=(0,e.useState)(null),[g,h]=(0,e.useState)(!1),i=(0,e.useMemo)(()=>a.join("\n"),[a]),j=`${i}:${b}:${g}`;return(0,e.useMemo)(()=>c&&c.key===j?c.html:a.map(a=>(0,f.ZD)(a||" ")),[a,j,c])}f=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},39222:(a,b,c)=>{"use strict";c.d(b,{v:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(46674),h=c(59347),i=c(24520),j=c(33281),k=c(23328);function l({cwd:a,tabId:b,onClose:c,onSave:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)({}),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(!0);(0,e.useCallback)(async()=>{v(!0);let c=await j.t4.runPromiseExit((0,k.QF)(a,b));"Success"===c._tag?p(c.value):console.error("Failed to load env:",c.cause),v(!1)},[a,b]);let w=()=>{q.trim()&&(p(a=>({...a,[q.trim()]:s})),r(""),t(""))},x=async()=>{let d=await j.t4.runPromiseExit((0,k.Vv)({cwd:a,tabId:b,env:o}));"Success"===d._tag?(m(o),c()):console.error("Failed to save env:",d.cause)};return(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:n("envManager.title")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:b?n("envManager.tabScope"):n("envManager.globalScope")})]}),(0,d.jsx)("button",{onClick:c,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,d.jsx)(g.A,{className:"w-5 h-5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:u?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:n("common.loading")}):(0,d.jsxs)("div",{className:"space-y-3",children:[Object.entries(o).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("input",{type:"text",value:a,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,d.jsx)("input",{type:"text",value:b,onChange:b=>{var c;return c=b.target.value,void p(b=>({...b,[a]:c}))},placeholder:n("envManager.valuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"}),(0,d.jsx)("button",{onClick:()=>{p(b=>{let c={...b};return delete c[a],c})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,d.jsx)(h.A,{className:"w-4 h-4"})})]},a)),(0,d.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,d.jsx)("input",{type:"text",value:q,onChange:a=>r(a.target.value),placeholder:n("envManager.varNamePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),w())}}),(0,d.jsx)("input",{type:"text",value:s,onChange:a=>t(a.target.value),placeholder:n("envManager.varValuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),w())}}),(0,d.jsx)("button",{onClick:w,disabled:!q.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,d.jsx)(i.A,{className:"w-4 h-4"})})]}),0===Object.keys(o).length&&(0,d.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:n("envManager.noVars")})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:c,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:n("common.cancel")}),(0,d.jsx)("button",{onClick:x,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:n("common.save")})]})]})})}},39712:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{w:()=>p});var e=c(48249),f=c(67484),g=c(50757),h=c(27454),i=c(37752),j=c(87844),k=c(34678),l=c(83768);let a=new k.v;function m(a){return a?Array.isArray(a)?a.join(""):a:""}function n(a,b){return a&&a[b]?m(a[b]):""}a.use_classes=!0;let o=(0,f.memo)(function({output:b}){if("stream"===b.output_type){let c=m(b.text);if(!c)return null;let d=a.ansi_to_html(c);return(0,e.jsx)("pre",{className:`text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 ${"stderr"===b.name?"text-amber-500":"text-foreground"}`,dangerouslySetInnerHTML:{__html:d}})}if("error"===b.output_type){let c=(b.traceback||[]).join("\n"),d=a.ansi_to_html(c);return(0,e.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-red-400 bg-red-500/5 rounded",dangerouslySetInnerHTML:{__html:d}})}if("execute_result"===b.output_type||"display_data"===b.output_type||"update_display_data"===b.output_type){let a=b.data;if(!a)return null;let c=n(a,"image/png"),d=n(a,"image/jpeg"),f=n(a,"image/svg+xml"),g=n(a,"text/html"),h=n(a,"text/markdown"),i=n(a,"text/latex"),k=n(a,"text/plain");if(c)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)("img",{src:`data:image/png;base64,${c}`,alt:"output",className:"max-w-full"})});if(d)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)("img",{src:`data:image/jpeg;base64,${d}`,alt:"output",className:"max-w-full"})});if(f)return(0,e.jsx)("div",{className:"px-3 py-1",dangerouslySetInnerHTML:{__html:f}});if(g)return(0,e.jsx)("div",{className:"px-3 py-1 overflow-x-auto notebook-html-output",dangerouslySetInnerHTML:{__html:g}});if(h)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)(j.T,{content:h})});if(i)return(0,e.jsx)("div",{className:"px-3 py-1",children:(0,e.jsx)(j.T,{content:`$$${i}$$`})});if(k)return(0,e.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap break-all px-3 py-1 text-foreground",children:k})}return null}),p=(0,f.memo)(function({cell:a,isActive:b,isEditing:c,onSelect:d,onEdit:k,onStopEdit:m,onSourceChange:n,onRun:p,onDelete:q,onMoveUp:r,onMoveDown:s,onToggleType:t,isFirst:u,isLast:v}){let{resolvedTheme:w}=(0,l.D)(),x=(0,f.useRef)(null),[y,z]=(0,f.useState)(a.source),A=(0,f.useCallback)(()=>{z(a.source),k()},[a.source,k]);(0,f.useEffect)(()=>{if(c&&x.current){x.current.focus();let a=x.current.value.length;x.current.setSelectionRange(a,a)}},[c]);let B=(0,f.useCallback)(()=>{let a=x.current;a&&(a.style.height="auto",a.style.height=a.scrollHeight+"px")},[]);(0,f.useEffect)(()=>{c&&B()},[c,y,B]);let C=(0,f.useCallback)(a=>{z(a.target.value),B()},[B]),D=(0,f.useCallback)(()=>{y!==a.source&&n(y),m()},[y,a.source,n,m]),E=(0,f.useCallback)(b=>{if("Enter"===b.key&&b.shiftKey)b.preventDefault(),y!==a.source&&n(y),p();else if("Enter"===b.key&&(b.metaKey||b.ctrlKey))b.preventDefault(),y!==a.source&&n(y),p();else if("Escape"===b.key)b.preventDefault(),D();else if("Tab"===b.key){b.preventDefault();let a=x.current;if(a){let b=a.selectionStart,c=a.selectionEnd,d=y.substring(0,b)+" "+y.substring(c);z(d),requestAnimationFrame(()=>{a.selectionStart=a.selectionEnd=b+4})}}},[y,a.source,n,p,D]),F=a.isExecuting?"*":a.execution_count??" ",G="code"===a.cell_type?"Code":"markdown"===a.cell_type?"Md":"Raw";return(0,e.jsxs)("div",{className:`group relative border rounded-lg transition-colors ${b?"border-brand/50 bg-brand/5":"border-border/50 hover:border-border"}`,onClick:d,children:[(0,e.jsxs)("div",{className:`absolute -top-3 left-2 flex items-center gap-0.5 text-[10px] z-10 bg-surface-secondary rounded px-1 py-0.5 border border-border/50 transition-opacity ${b?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:[(0,e.jsx)("button",{onClick:p,className:"px-1 hover:text-brand",title:"Run (Shift+Enter)",children:a.isExecuting?"⬛":"▶"}),(0,e.jsx)("button",{onClick:t,className:"px-1 hover:text-brand",title:"Toggle type",children:G}),!u&&(0,e.jsx)("button",{onClick:r,className:"px-1 hover:text-brand",title:"Move up",children:"↑"}),!v&&(0,e.jsx)("button",{onClick:s,className:"px-1 hover:text-brand",title:"Move down",children:"↓"}),(0,e.jsx)("button",{onClick:q,className:"px-1 hover:text-red-400",title:"Delete",children:"\xd7"})]}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)("div",{className:"flex-shrink-0 w-10 text-center py-2 text-[10px] text-muted-foreground select-none cursor-pointer border-r border-border/30",onClick:a=>{a.stopPropagation(),p()},title:"code"===a.cell_type?"Click to run":void 0,children:"code"===a.cell_type?(0,e.jsxs)("span",{className:a.isExecuting?"text-brand animate-pulse":"",children:["[",F,"]"]}):(0,e.jsx)("span",{className:"text-muted-foreground/50",children:G})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("div",{className:"cursor-text",onDoubleClick:a=>{a.stopPropagation(),A()},children:c?(0,e.jsx)("textarea",{ref:x,value:y,onChange:C,onBlur:D,onKeyDown:E,className:"w-full bg-transparent text-xs font-mono leading-relaxed px-3 py-2 resize-none outline-none text-foreground",spellCheck:!1,style:{minHeight:"1.5rem"}}):"code"===a.cell_type?(0,e.jsx)("div",{className:"text-xs [&_pre]:!m-0 [&_pre]:!p-2 [&_pre]:!bg-transparent [&_code]:!bg-transparent",children:(0,e.jsx)(g.A,{language:"python",style:"dark"===w?h.A:i.A,customStyle:{margin:0,padding:"8px 12px",background:"transparent",fontSize:"12px"},wrapLongLines:!0,children:a.source||" "})}):"markdown"===a.cell_type?a.source.trim()?(0,e.jsx)("div",{className:"px-3 py-2 text-sm prose prose-sm dark:prose-invert max-w-none",children:(0,e.jsx)(j.T,{content:a.source})}):(0,e.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:"Empty markdown cell"}):(0,e.jsx)("pre",{className:"text-xs font-mono px-3 py-2 text-muted-foreground whitespace-pre-wrap",children:a.source||" "})}),a.outputs.length>0&&(0,e.jsx)("div",{className:"border-t border-border/30",children:a.outputs.map((a,b)=>(0,e.jsx)(o,{output:a},b))})]})]})]})});d()}catch(a){d(a)}})},40159:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{S:()=>l,j:()=>a});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(44256);function j({blame:a,onClick:b}){let{t:c}=(0,g.Bd)(),d=(0,f.useRef)(null),k=(0,f.useRef)(null),l=(0,i.F2)(),m=(0,f.useRef)(!1),n=(0,f.useRef)(!1),o=(0,f.useRef)(null),p=(0,f.useRef)(null),q=(0,f.useRef)(null),r=(0,f.useRef)(a),s=(0,f.useRef)(b),t=(0,f.useCallback)(()=>{let a,b=k.current,c=d.current;if(!b||!c)return;let e=c.getBoundingClientRect(),f=b.getBoundingClientRect(),g=l?.getBoundingClientRect(),h=g?.left??0,i=g?.top??0,j=g?.width??window.innerWidth,m=g?.height??window.innerHeight,n=e.left-h;n+f.width>j-8&&(n=j-f.width-8),n<8&&(n=8);let o=e.top-i,p=e.bottom-i;(a=o-f.height-4<0?p+4:o-f.height-4)+f.height>m-8&&(a=m-f.height-8),b.style.left=`${n}px`,b.style.top=`${a}px`},[l]),u=(0,f.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),p.current&&(clearTimeout(p.current),p.current=null),m.current=!1,n.current=!1,k.current&&(k.current.style.display="none"),q.current&&(document.removeEventListener("mousedown",q.current.down),document.removeEventListener("mouseup",q.current.up),q.current=null)},[]),v=(0,f.useCallback)(()=>{let a=k.current;if(!a||m.current)return;m.current=!0,a.style.left="-9999px",a.style.top="-9999px",a.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(t));let b=0,c=0,e=a=>{b=a.clientX,c=a.clientY},f=a=>{if(!(Math.abs(a.clientX-b)>5||Math.abs(a.clientY-c)>5)){let b;b=a.target,k.current?.contains(b)||d.current?.contains(b)||u()}};document.addEventListener("mousedown",e),document.addEventListener("mouseup",f),q.current={down:e,up:f}},[t,u]),w=(0,f.useCallback)(()=>{if(o.current&&clearTimeout(o.current),p.current&&(clearTimeout(p.current),p.current=null),m.current)return;let a=window.getSelection();(!a||a.isCollapsed)&&(o.current=setTimeout(v,500))},[v]),x=(0,f.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),m.current&&(p.current=setTimeout(()=>{n.current||u()},200))},[u]),y=(0,f.useCallback)(()=>{n.current=!0,p.current&&(clearTimeout(p.current),p.current=null)},[]),z=(0,f.useCallback)(()=>{n.current=!1,u()},[u]),A=(0,f.useCallback)(a=>{a.stopPropagation();let b=window.getSelection();b&&b.toString().length>0&&k.current?.contains(b.anchorNode)||(s.current?.(r.current),u())},[u]),B=a.message.split("\n")[0]||"",C=a.message.split("\n").slice(1).join("\n").trim();return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{ref:d,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:w,onMouseLeave:x,children:[a.author.split(" ")[0],", ",function(a){let b=h.A.t,c=Date.now(),d=Math.floor((c-1e3*a)/1e3);if(d<60)return b("common.justNow");let e=Math.floor(d/60);if(e<60)return b("common.minutesAgo",{count:e});let f=Math.floor(e/60);if(f<24)return b("common.hoursAgo",{count:f});let g=Math.floor(f/24);if(g<30)return b("common.daysAgo",{count:g});let i=Math.floor(g/30);if(i<12)return b("common.monthsAgo",{count:i});let j=Math.floor(i/12);return b("common.yearsAgo",{count:j})}(a.time)," \xb7 ",B]}),(0,e.jsx)(i.ZL,{children:(0,e.jsxs)("div",{ref:k,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-xl p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:y,onMouseLeave:z,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,e.jsx)("span",{className:"font-mono text-brand",children:a.hash}),(0,e.jsx)("span",{className:"text-muted-foreground",children:a.author}),(0,e.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*a.time).toLocaleString()})]}),(0,e.jsx)("div",{className:"font-medium",children:B}),C&&(0,e.jsx)("div",{className:"mt-1 text-muted-foreground",children:C}),(0,e.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:A,children:c("codeViewer.clickToViewDetails")})]})})]})}let a=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}];function k(a,b){let c,d=document.caretRangeFromPoint(a.clientX,a.clientY);if(!d||!b.contains(d.startContainer))return 1;let e=d.startContainer,f=d.startOffset,g=document.createTreeWalker(b,NodeFilter.SHOW_TEXT),h=1;for(;c=g.nextNode();){if(c===e){h+=f;break}h+=c.textContent?.length||0}return h}let l=(0,f.memo)(function({virtualKey:a,lineNum:b,highlightedHtml:c,hasComments:d,firstComment:h,lineCommentsCount:i,isInRange:l,showLineNumbers:m,lineNumChars:n,commentsEnabled:o,virtualItemSize:p,virtualItemStart:q,onCommentBubbleClick:r,onCmdClick:s,onTokenHover:t,onTokenHoverLeave:u,flashLine:v,blameLine:w,showBlameInfo:x,blameAuthorColor:y,isBlameHovered:z,onBlameClick:A,onBlameMouseEnter:B,onBlameMouseLeave:C,inlineBlameData:D,onInlineBlameClick:E,isCursorLine:F,cursorCol:G}){let{t:H}=(0,g.Bd)(),I=(0,f.useMemo)(()=>F&&null!=G?function(a,b){let c=0,d=0;for(;d<a.length;){if("<"===a[d]){let b=a.indexOf(">",d);if(-1!==b){d=b+1;continue}}if(c===b){let b;if("&"===a[d]){let c=a.indexOf(";",d);b=-1!==c&&c-d<10?c+1:d+1}else b=d+1;let c=a.substring(d,b);return a.substring(0,d)+'<span class="vi-char-cursor">'+c+"</span>"+a.substring(b)}if("&"===a[d]){let b=a.indexOf(";",d);d=-1!==b&&b-d<10?b+1:d+1}else d++;c++}return a+'<span class="vi-char-cursor"> </span>'}(c,G):c,[c,F,G]),J=(0,f.useCallback)(a=>{if(!a.metaKey||!s)return;a.preventDefault(),a.stopPropagation();let c=a.currentTarget,d=k(a,c);window.getSelection()?.removeAllRanges(),s(b,d)},[b,s]),K=(0,f.useCallback)(a=>{if(!t||0!==a.buttons)return;let c=window.getSelection();if(c&&!c.isCollapsed)return;let d=a.target;if("SPAN"!==d.tagName||!d.style.color)return;let e=a.currentTarget,f=k(a,e),g=d.getBoundingClientRect();t(b,f,{x:g.left,y:g.bottom+4})},[b,t]),L=(0,f.useCallback)(()=>{w&&A&&A(w)},[w,A]),M=(0,f.useCallback)(a=>{w&&B&&B(w,a)},[w,B]);return(0,e.jsxs)("div",{"data-line":b,style:{position:"absolute",top:0,left:0,width:"100%",height:`${p}px`,transform:`translateY(${q}px)`,backgroundColor:z&&y?y.bg:void 0},className:`flex ${v===b?"flash-line":""} ${F?"vi-cursor-line":""} ${l?"bg-blue-9/20":d?"bg-amber-9/10":"hover:bg-accent/50"}`,children:[(0,e.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-secondary",style:{backgroundColor:z&&y?y.bg:void 0},children:[w&&y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,e.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-accent/50",onMouseEnter:M,onMouseLeave:C,onClick:L,title:H("codeViewer.clickToViewCommit"),children:x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-medium",style:{color:y.border},children:w.hash}),(0,e.jsx)("span",{className:"truncate flex-1",children:w.author.split(" ")[0]})]}):null})]}),m&&(0,e.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${l?"bg-blue-9/30 text-blue-11":"bg-card/50 text-slate-9"}`,children:[o&&d&&h&&(0,e.jsx)("button",{onClick:a=>r(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:H("codeViewer.nComments",{count:i}),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),o&&!d&&(0,e.jsx)("span",{className:"w-4"}),(0,e.jsx)("span",{className:"text-right",style:{minWidth:`${n}ch`},children:b})]})]}),(0,e.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:J,onMouseOver:K,onMouseLeave:u,"data-code-content":!0,children:[(0,e.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),D&&(0,e.jsx)(j,{blame:D,onClick:E})]})]},a)});d()}catch(a){d(a)}})},40699:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{u:()=>h});var e=c(67484),f=c(29939),g=c(19872);function h(a,b,c,d,h){let i=(0,e.useRef)(null),j=(0,e.useRef)(0),k=()=>{let a=`live-asst-${++j.current}`;return i.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",isStreaming:!0}]),a},l=a=>{if("system"===a.type&&"init"===a.subtype)return void k();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}let c=i.current??k();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,a.events))l(c);h?.onRunningChange?.(!0)}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){h?.onRunningChange?.(!1),h?.onComplete?.();return}l(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:()=>s,JC:()=>l,M5:()=>j,QW:()=>o,Zr:()=>n,an:()=>r,em:()=>i,l1:()=>k,n_:()=>m,qD:()=>q,td:()=>h});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=()=>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})}),q=a=>d.gen(function*(){let b=yield*p();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*p();return"not-running"===f._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:f}),r=a=>f(`/api/file?path=${encodeURIComponent(a)}`),s=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")})]})]})}},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]);function t({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d,onOpenNote:s}){let{t:u}=(0,g.Bd)(),{consoleItems:v,scrollRef:w,selectedCommandId:x,setSelectedCommandId:y,interruptCommand:z,sendStdin:A,deleteCommand:B,rerunCommand:C,ptySizeRef:D,resizePty:E,executeCommand:F,addPluginItem:G,closePluginItem:H,sleepingBubbles:I,handleBubbleSleep:J,handleBubbleWake:K,scrollToBottom:L,currentCwd:M,commandHistoryRef:N,setCustomEnv:O,setAliases:P,saveBubbleOrder:Q,hasMoreHistory:R,loadHistory:S,currentPage:T,isLoadingHistory:U,subscribePtyOutput:V,subscribePtyReset:W,subscribePtyRefresh:X}=(0,m.cK)({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:d}),[Y,Z]=(0,f.useState)(null),[$,_]=(0,f.useState)(0),[aa,ab]=(0,f.useState)(0),[ac,ad]=(0,f.useState)(!0),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(!1),[ak,al]=(0,f.useState)(!1),am=(0,f.useRef)(null),an=(0,f.useRef)(null),ao=(0,f.useRef)(null),ap=(0,f.useRef)(!1),aq=(0,f.useRef)(null),ar=(0,f.useRef)(null),as=(0,f.useRef)([]),at=(0,f.useCallback)(()=>{let a=w.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[w]),au=(0,f.useCallback)(()=>{let a=w.current;return!a||a.scrollTop<50},[w]),av=(0,f.useCallback)(()=>{aj(!au()),al(!at())},[at,au]),aw=(0,f.useCallback)(()=>{an.current?.scrollIntoView({behavior:"smooth"})},[]),ax=(0,f.useCallback)(()=>{ap.current=!0},[]),ay=(0,f.useCallback)((a,b)=>{if(!ap.current)return void a.preventDefault();ap.current=!1,aq.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))}},[]),az=(0,f.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",ar.current=b},[]),aA=(0,f.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.add("ring-2","ring-brand")},[]),aB=(0,f.useCallback)(a=>{a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aC=(0,f.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aD=(0,f.useCallback)(a=>{a.currentTarget.style.opacity="1";let b=aq.current,c=ar.current;if(aq.current=null,ar.current=null,!b||!c||b===c)return;let d=as.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,Q(g)},[Q]),aE=(0,f.useCallback)(a=>{Z(b=>b===a?null:a)},[]),aF=aa>0?Math.floor((aa-32-12)/2-41):void 0;return(0,e.jsxs)("div",{ref:am,className:"h-full flex flex-col bg-background relative",children:[(0,e.jsx)("div",{ref:w,onScroll:av,className:`console-scroll-root flex-1 overflow-y-auto ${Y?"":"py-4 px-4"}`,children:0===v.length?(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:u("console.enterCommandOrUrl")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{ref:an}),R&&(0,e.jsx)("div",{className:"flex justify-center mb-4",children:(0,e.jsx)("button",{onClick:()=>S(T+1),disabled:U,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-50",children:u(U?"console.loadingMore":"console.loadMoreHistory")})}),(0,e.jsx)("div",{className:Y?"flex flex-col gap-3":ac?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:v.map(b=>{let d={draggable:!0,onDragStart:a=>ay(a,b.data.id),onDragOver:a=>az(a,b.data.id),onDragEnter:aA,onDragLeave:aB,onDrop:aC,onDragEnd:aD};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:x===f.id,onSelect:()=>{y(f.id)},onInterrupt:f.isRunning?()=>z(f.id):void 0,onStdin:f.isRunning?a=>A(f.id,a):void 0,onDelete:()=>{f.isRunning&&f.pid&&(0,n.HV)(f.pid),B(f.id)},onRerun:()=>C(f.id),timestamp:f.timestamp,usePty:f.usePty,subscribePtyOutput:f.usePty?V:void 0,subscribePtyReset:f.usePty?W:void 0,subscribePtyRefresh:f.usePty?X:void 0,onPtyResize:(a,b)=>{D.current.set(f.id,{cols:a,rows:b}),E(f.id,a,b)},onToggleMaximize:()=>aE(f.id),maximized:Y===f.id,expandedHeight:$,bubbleContentHeight:aF,onTitleMouseDown:ax})},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:x===i.id,maximized:Y===i.id,expandedHeight:$,bubbleContentHeight:aF,timestamp:i.timestamp,onSelect:()=>{y(i.id)},onClose:()=>H(i.id),onToggleMaximize:()=>aE(i.id),onTitleMouseDown:ax,extra:{addBrowserItem:(a,b)=>G("browser",a,b),initialSleeping:I.has(i.id),onSleep:J,onWake:K,projectCwd:a,tabId:c}})},i.id)})}),(0,e.jsx)("div",{ref:ao})]})}),!Y&&v.length>0&&(0,e.jsx)(l.w,{showTop:ai,showBottom:ak,onScrollTop:aw,onScrollBottom:L}),(0,e.jsx)(k.D,{cwd:a,currentCwd:M,commandHistoryRef:N,gridLayout:ac,onGridLayoutChange:b=>{ad(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:F,onAddPluginItem:G,onShowEnvManager:()=>af(!0),onOpenZsh:()=>F("zsh"),onOpenNote:s}),ae&&(0,e.jsx)(i.v,{cwd:a,tabId:c,onClose:()=>af(!1),onSave:a=>O(a)}),ag&&(0,e.jsx)(j.Y,{onClose:()=>ah(!1),onSave:a=>P(a)})]})}[o,m,h,k]=s.then?(await s)():s,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
26
26
  relative transition-colors cursor-pointer
27
27
  ${g?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
28
28
  ${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+=`