@surething/cockpit 1.0.280 → 1.0.281

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 (40) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +8 -8
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/cockpit-build.json +1 -1
  5. package/.next-prod/prerender-manifest.json +3 -3
  6. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next-prod/server/app/_global-error.html +1 -1
  8. package/.next-prod/server/app/_global-error.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next-prod/server/app/_not-found.html +2 -2
  14. package/.next-prod/server/app/_not-found.rsc +2 -2
  15. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +2 -2
  16. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  19. package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
  20. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  21. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  22. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  23. package/.next-prod/server/app-paths-manifest.json +8 -8
  24. package/.next-prod/server/chunks/7438.js +6 -6
  25. package/.next-prod/server/middleware-build-manifest.js +1 -1
  26. package/.next-prod/server/pages/404.html +2 -2
  27. package/.next-prod/server/pages/500.html +1 -1
  28. package/.next-prod/server/server-reference-manifest.json +1 -1
  29. package/.next-prod/static/chunks/{81016-71999ca5bd6a6b2f.js → 72550-9aedd46bd54f0be7.js} +16 -16
  30. package/.next-prod/static/chunks/{95313-af5cc33125d6c0ff.js → 95313-a6d8f9e8207d731c.js} +1 -1
  31. package/.next-prod/static/chunks/app/{layout-0c3dcac0764d9e97.js → layout-22f49ab92f208f15.js} +1 -1
  32. package/.next-prod/static/chunks/app/{page-b472e7f948959009.js → page-a196e139366e9958.js} +1 -1
  33. package/.next-prod/static/chunks/app/project/{page-b472e7f948959009.js → page-a196e139366e9958.js} +1 -1
  34. package/.next-prod/trace +15 -15
  35. package/.next-prod/trace-build +1 -1
  36. package/README.md +3 -3
  37. package/README.zh.md +3 -3
  38. package/package.json +11 -2
  39. /package/.next-prod/static/{_195_hPNVuma2vZS7bpTW → COnpPKy0RckqiixR3j42H}/_buildManifest.js +0 -0
  40. /package/.next-prod/static/{_195_hPNVuma2vZS7bpTW → COnpPKy0RckqiixR3j42H}/_ssgManifest.js +0 -0
@@ -13,7 +13,7 @@ exports.id=7438,exports.ids=[7438],exports.modules={208:(a,b,c)=>{"use strict";c
13
13
  <span class="text-sm">${a}</span>
14
14
  `,c.appendChild(d),setTimeout(()=>{d.style.animation="slideOut 0.3s ease-in",setTimeout(()=>{c.removeChild(d)},300)},3e3)}},8077:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ProjectSidebar:()=>A});var e=c(48249),f=c(67484),g=c(44384),h=c(37370),i=c(65255),j=c(25608),k=c(32459),l=c(18499),m=c(74991),n=c(36462),o=c(98982),p=c(13054),q=c(7833),r=c(29939),s=c(64340),t=c(42390),u=c(50514),v=c(24703),w=a([j,k,l,m]);[j,k,l,m]=w.then?(await w)():w;let B=a=>"unread"===a?0:"loading"===a?1:2;function x({className:a=""}){return(0,e.jsxs)("svg",{className:a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,e.jsx)("rect",{x:"4",y:"4",width:"6",height:"6",rx:"1.5"}),(0,e.jsx)("rect",{x:"4",y:"14",width:"6",height:"6",rx:"1.5"}),(0,e.jsx)("rect",{x:"14",y:"14",width:"6",height:"6",rx:"1.5"}),(0,e.jsx)("path",{d:"M17 3v8"}),(0,e.jsx)("path",{d:"M13 7h8"})]})}function y({item:a,active:b,onClick:c,className:d=""}){return(0,e.jsx)("button",{type:"button",onClick:c,className:`h-8 w-8 rounded-md border bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 active:scale-95 transition-all flex items-center justify-center ${b?"border-brand/80 text-brand":"border-border/70"} ${d}`,title:`${a.title}
15
15
  ${a.path}`,children:a.icon?(0,e.jsx)("span",{className:"text-base leading-none",children:a.icon}):(0,e.jsx)(u.A,{className:"w-4 h-4"})})}function z({collapsed:a,previews:b,activePath:c,onOpenApps:d,onShowPreview:h}){let{t:i}=(0,g.Bd)(),[j,k]=(0,f.useState)(null),l=(0,f.useRef)(null),m=b.length>4,n=m?b.slice(0,3):b.slice(0,4),o=m?b.slice(3):[],p=(0,e.jsxs)("button",{type:"button",onClick:()=>{d(),k(null)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:i("htmlApps.title"),children:[(0,e.jsx)("span",{className:"h-7 w-7 flex-shrink-0 rounded-md border border-border/70 bg-transparent flex items-center justify-center",children:(0,e.jsx)(x,{className:"w-4 h-4"})}),(0,e.jsx)("span",{className:"min-w-0 flex-1",children:(0,e.jsx)("span",{className:"block text-xs font-medium truncate",children:i("htmlApps.title")})})]},"html-apps-list"),q=a=>{h(a),k(null)},r=a=>(0,e.jsxs)("div",{className:"max-h-[19.75rem] overflow-y-auto p-1.5 space-y-1",children:[p,a.map(a=>(0,e.jsxs)("button",{type:"button",onClick:()=>q(a),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left hover:bg-hover transition-colors ${c===a.path?"text-brand":"text-muted-foreground hover:text-foreground"}`,title:a.path,children:[(0,e.jsx)("span",{className:"h-7 w-7 flex-shrink-0 rounded-md border border-border/70 bg-transparent flex items-center justify-center",children:a.icon?(0,e.jsx)("span",{className:"text-base leading-none",children:a.icon}):(0,e.jsx)(u.A,{className:"w-4 h-4"})}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"block text-xs font-medium truncate",children:a.title}),(0,e.jsx)("span",{className:"block text-[10px] font-mono text-muted-foreground truncate",children:a.path})]})]},a.path))]});return a?(0,e.jsxs)("div",{ref:l,className:"relative p-2 border-t border-border",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>"collapsed"===a?null:"collapsed"),className:`w-full h-8 rounded-md border bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 transition-colors flex items-center justify-center ${c?"border-brand/80 text-brand":"border-border/70"}`,title:i("htmlApps.title"),children:(0,e.jsx)(x,{className:"w-4 h-4"})}),"collapsed"===j&&(0,e.jsx)("div",{className:"absolute left-full bottom-0 ml-2 w-64 rounded-lg border border-border bg-card shadow-lv3 z-50",children:r(b)})]}):(0,e.jsx)("div",{ref:l,className:"p-2 border-t border-border",children:(0,e.jsxs)("div",{className:"grid grid-cols-5 gap-1.5",children:[(0,e.jsx)("button",{type:"button",onClick:d,className:"h-8 w-8 rounded-md border border-border/70 bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 active:scale-95 transition-all flex items-center justify-center",title:i("htmlApps.title"),children:(0,e.jsx)(x,{className:"w-4 h-4"})}),n.map(a=>(0,e.jsx)(y,{item:a,active:c===a.path,onClick:()=>q(a)},a.path)),m&&(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("button",{type:"button",onClick:()=>k(a=>"more"===a?null:"more"),className:"h-8 w-8 rounded-md border border-border/70 bg-transparent text-muted-foreground hover:text-brand hover:border-brand/70 transition-colors flex items-center justify-center",title:i("common.loadMore"),children:(0,e.jsx)(v.A,{className:"w-4 h-4"})}),"more"===j&&(0,e.jsx)("div",{className:"absolute left-0 bottom-full mb-2 w-64 rounded-lg border border-border bg-card shadow-lv3 z-50",children:r(o)})]})]})})}function A({projects:a,activeIndex:b,collapsed:c,currentCwd:d,onSelectProject:u,onRemoveProject:v,onReorderProjects:w,onToggleCollapse:x,onOpenSessionBrowser:y,onOpenSettings:C,onOpenNote:D,onOpenSkills:E,onOpenBots:F,onOpenApps:G,htmlAppPreviews:H,activeHtmlAppPreviewPath:I,onShowHtmlAppPreview:J,onSwitchProject:K,onFocusTerminal:L,onResolveSessionNumbers:M,sessionOrders:N,sessionNumbers:O}){let{t:P,i18n:Q}=(0,g.Bd)(),R=(0,f.useMemo)(()=>a.map(a=>a.cwd),[a]),{latest:S,hasUpdate:T}=(0,s.r)(),[U,V]=(0,f.useState)(!1),W=(0,f.useRef)(null),X=(0,f.useCallback)(()=>{navigator.clipboard.writeText("cockpit update"),(0,q.oR)(P("workspace.upgradeCommandCopied")),V(!1)},[P]),{isUpdating:Y,start:Z}=(0,t.P)(),$=(0,f.useCallback)(()=>{V(!1),Z()},[Z]),{pinnedSessions:_,unpinSession:aa,updateTitle:ab,reorder:ac}=(0,o.P)(),{tasks:ad,unreadCount:ae,reload:af,pauseTask:ag,resumeTask:ah,triggerTask:ai,deleteTask:aj,updateTask:ak,markRead:al}=(0,p.nS)(),[am,an]=(0,f.useState)(null),[ao,ap]=(0,f.useState)(null),[aq,ar]=(0,f.useState)([]);(0,f.useRef)(aq);let as=(0,f.useRef)(af),at=(0,f.useCallback)(a=>{try{if("task-fired"===a.type)return void as.current();let{data:b}=a;if(!b)return;ar(b.sessions||[])}catch{}},[]);(0,r.h)({url:"/ws/global-state",onMessage:at});let au=new Set(aq.filter(a=>"loading"===a.status).map(a=>a.cwd)),av=new Set(aq.filter(a=>"unread"===a.status).map(a=>a.cwd)),aw=(0,f.useMemo)(()=>{let b=new Map;for(let c of a){let a=N[c.cwd]??[],d=aq.filter(a=>a.cwd===c.cwd).map(b=>({session:b,position:a.indexOf(b.sessionId)})).filter(({session:a,position:b})=>b>=0||"loading"===a.status||"unread"===a.status).sort((a,b)=>{let c=B(a.session.status)-B(b.session.status);return 0!==c?c:b.session.lastActive-a.session.lastActive}),e=d.find(({session:a})=>2===B(a.status)),f=d.filter(({session:a})=>2>B(a.status)||a===e?.session).slice(0,3).sort((a,b)=>a.position<0?b.position<0?0:1:b.position<0?-1:a.position-b.position).map(({session:a,position:b})=>({sessionId:a.sessionId,label:b>=0?String(b+1):"\xb7",status:"loading"===a.status?"loading":"unread"===a.status?"unread":"normal",...a.bot?{bot:a.bot}:{}}));f.length>0&&b.set(c.cwd,f)}return b},[a,aq,N]),ax=(0,f.useCallback)(a=>{an(a)},[]),ay=(0,f.useCallback)((a,b)=>{a.preventDefault(),null!==am&&am!==b&&ap(b)},[am]),az=(0,f.useCallback)(b=>{if(null!==am&&am!==b){let c=[...a],[d]=c.splice(am,1);c.splice(b,0,d),w(c)}an(null),ap(null)},[am,a,w]),aA=(0,f.useCallback)(()=>{an(null),ap(null)},[]);return(0,e.jsxs)("div",{className:`h-full bg-card border-r border-border flex flex-col transition-all duration-200 ${c?"w-12":"w-56"}`,children:[(0,e.jsxs)("div",{className:"group p-2 border-b border-border relative",children:[(0,e.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:y,title:c?P("workspace.openProject"):void 0,children:[(0,e.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),!c&&(0,e.jsx)("span",{className:"text-sm",children:P("workspace.openProject")})]}),c?(0,e.jsx)("button",{className:"absolute inset-0 m-2 flex items-center justify-center px-2 py-2 rounded-lg bg-popover shadow-lv1 text-foreground transition z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:x,title:P("workspace.expandSidebar"),children:(0,e.jsx)("svg",{className:"w-5 h-5 flex-shrink-0 rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}):(0,e.jsx)("button",{className:"absolute top-1/2 -translate-y-1/2 right-2 p-2 rounded-lg bg-popover shadow-lv1 text-foreground transition z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:x,title:P("workspace.collapseSidebar"),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:"M15 19l-7-7 7-7"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:a.map((a,d)=>{var f;let g;return(0,e.jsx)("div",{draggable:!0,onDragStart:()=>ax(d),onDragOver:a=>ay(a,d),onDrop:()=>az(d),onDragEnd:aA,className:`${ao===d?"border-t-2 border-brand":""} ${am===d?"opacity-50":""}`,children:(0,e.jsx)(j.ProjectItem,{index:d,name:(g=(f=a.cwd).split("/").filter(Boolean))[g.length-1]||f,cwd:a.cwd,isActive:d===b,collapsed:c,hasUnread:av.has(a.cwd),isLoading:au.has(a.cwd),sessionBadges:aw.get(a.cwd),onClick:()=>u(d),onSelectSession:b=>K(a.cwd,b),onRemove:()=>v(d),onOpenNote:()=>D(a.cwd)})},a.cwd)})}),(0,e.jsx)(z,{collapsed:c,previews:H,activePath:I,onOpenApps:G,onShowPreview:J}),(0,e.jsxs)("div",{className:"p-2 border-t border-border space-y-1",children:[(0,e.jsx)(k.e,{currentCwd:d,onSwitchProject:K,onResolveSessionNumbers:M,collapsed:c,sessions:aq}),(0,e.jsx)(l._,{collapsed:c,pinnedSessions:_,sessionNumbers:O,currentCwd:d,onSwitchProject:K,onUnpin:aa,onUpdateTitle:ab,onReorder:ac}),(0,e.jsx)(m.I,{collapsed:c,tasks:ad,unreadCount:ae,sessionNumbers:O,onSwitchProject:K,onPause:ag,onResume:ah,onTrigger:ai,onDelete:aj,onMarkRead:al,onUpdateTask:ak}),(0,e.jsx)(n.p,{collapsed:c,currentCwd:d,projectOrder:R,onFocusTerminal:L}),(0,e.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:()=>D(),title:c?P("workspace.notes"):void 0,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:"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"})}),!c&&(0,e.jsx)("span",{className:"text-sm",children:P("workspace.notes")})]}),(0,e.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:E,title:c?P("workspace.skills"):void 0,children:[(0,e.jsx)(h.A,{className:"w-5 h-5 flex-shrink-0"}),!c&&(0,e.jsx)("span",{className:"text-sm",children:P("workspace.skills")})]}),(0,e.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:F,title:c?P("workspace.bots"):void 0,children:[(0,e.jsx)(i.A,{className:"w-5 h-5 flex-shrink-0"}),!c&&(0,e.jsx)("span",{className:"text-sm",children:P("workspace.bots")})]}),(0,e.jsxs)("div",{className:`relative flex items-center gap-2 px-2 py-2 rounded-lg cursor-pointer text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${c?"justify-center":""}`,onClick:C,title:P("workspace.settings"),children:[(0,e.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,e.jsxs)("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:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),c&&T&&(0,e.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500",title:S?P("workspace.updateAvailable",{version:S}):void 0})]}),!c&&(0,e.jsx)("span",{className:"flex-1 text-sm",children:P("workspace.settings")}),!c&&T&&S&&(0,e.jsxs)("div",{ref:W,className:"relative -mr-2",children:[(0,e.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),V(a=>!a)},className:"px-1.5 py-0.5 rounded text-xs font-mono font-medium text-brand hover:bg-brand/10 transition-colors",title:P("workspace.updateAvailable",{version:S}),"aria-label":P("workspace.updateAvailable",{version:S}),children:["v",S]}),U&&(0,e.jsxs)("div",{className:"absolute left-full bottom-full ml-2 mb-1 w-56 rounded-lg border border-border bg-popover shadow-lv2 p-2 z-50",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-2 px-1",children:P("workspace.updateAvailable",{version:S})}),(0,e.jsxs)("button",{type:"button",onClick:$,disabled:Y,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left\n hover:bg-hover transition-colors disabled:opacity-60 disabled:cursor-default",children:[Y?(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:4}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}):(0,e.jsx)("svg",{className:"w-3.5 h-3.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:"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)("span",{className:"flex-1",children:Y?P("workspace.updating"):P("workspace.updateNow")})]}),(0,e.jsxs)("button",{type:"button",onClick:X,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left hover:bg-hover transition-colors",children:[(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2}),(0,e.jsx)("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2})]}),(0,e.jsx)("span",{className:"flex-1",children:P("workspace.copyUpgradeCommand")})]}),(0,e.jsxs)("a",{href:`https://opencockpit.dev/${Q.language?.startsWith("zh")?"zh":"en"}/changelog/`,target:"_blank",rel:"noopener",onClick:()=>V(!1),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm hover:bg-hover transition-colors",children:[(0,e.jsx)("svg",{className:"w-3.5 h-3.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:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("span",{className:"flex-1",children:P("workspace.viewChangelog")}),(0,e.jsx)("svg",{className:"w-3 h-3 flex-shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]}),!c&&(0,e.jsx)("a",{href:`https://opencockpit.dev/${Q.language?.startsWith("zh")?"zh":"en"}/docs/get-started/quickstart/`,target:"_blank",rel:"noopener",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",onClick:a=>a.stopPropagation(),title:P("workspace.help"),"aria-label":P("workspace.help"),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",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),(0,e.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2})]})})]})]})]})}d()}catch(a){d(a)}})},8410:(a,b,c)=>{"use strict";c.d(b,{N:()=>e});var d=c(48249);function e({cls:a}){return(0,d.jsx)("span",{className:`text-[10px] px-1 py-px rounded flex-shrink-0 ${"test"===a?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400/80":"bg-sky-500/15 text-sky-600 dark:text-sky-400/80"}`,children:a})}},9804:(a,b,c)=>{"use strict";function d(a,b){for(let c of a){if(c.path===b)return c;if(c.children){let a=d(c.children,b);if(a)return a}}return null}function e(a,b){if(!a)return"";let c=d(b,a);if(c?.isDirectory)return a;let e=a.split("/");return e.pop(),e.join("/")}function f(a){let b=[];for(let c of a){let a=c.split("/"),d=b;for(let b=0;b<a.length;b++){let c=a[b],e=b===a.length-1,f=a.slice(0,b+1).join("/"),g=d.find(a=>a.name===c);g||(g={name:c,path:f,isDirectory:!e,children:e?void 0:[]},d.push(g)),!e&&g.children&&(d=g.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=>{a.children&&c(a.children)})};return c(b),b}function g(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),d.children&&c(d.children))};return c(a),b}c.d(b,{B_:()=>o,HR:()=>function a(b,c){if(0===c.length)return b;let d=new Map(c.map(a=>[a.path,a]));return b.map(b=>{let c=d.get(b.path);return c&&b.isDirectory?void 0===b.children&&void 0!==c.children?{...b,children:c.children}:void 0!==b.children&&void 0!==c.children?{...b,children:a(b.children,c.children)}:b:b})},KH:()=>k,MB:()=>d,S7:()=>e,fw:()=>l,q3:()=>j,r6:()=>m,tE:()=>n,tW:()=>g,u:()=>i,v3:()=>f});let h=new Set(["png","jpg","jpeg","gif","svg","webp","ico","bmp","avif"]);function i(a){let b=a.split(".").pop()?.toLowerCase();return h.has(b||"")}function j(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase(),f=a=>{if(d.add(a.path),a.children)for(let b of a.children)f(b)},g=(a,b)=>{let h=a.name.toLowerCase(),i=c?h===e:h.includes(e);if(i&&a.children)return f(a),b.forEach(a=>d.add(a)),!0;let j=!1;if(a.children)for(let c of a.children)g(c,[...b,a.path])&&(j=!0);return(!!i||!!j)&&(d.add(a.path),b.forEach(a=>d.add(a)),!0)};for(let b of a)g(b,[]);return d}function k(a,b,c=!1){let d=new Set;if(!b)return d;let e=b.toLowerCase();for(let b of a){let a=b.split("/");for(let b=0;b<a.length;b++){let f=a[b].toLowerCase();if(c?f===e:f.includes(e)){for(let b=0;b<=a.length-1;b++)d.add(a.slice(0,b+1).join("/"));break}}}return d}function l(a){let b=Math.floor(Math.floor((Date.now()-1e3*a)/1e3)/60),c=Math.floor(b/60),d=Math.floor(c/24),e=Math.floor(d/30),f=Math.floor(d/365);return f>0?`${f}y ago`:e>0?`${e}mo ago`:d>0?`${d}d ago`:c>0?`${c}h ago`:b>0?`${b}m ago`:"just now"}function m(a){let b=new Date(a),c=new Date,d=b.getFullYear()===c.getFullYear(),e=String(b.getMonth()+1).padStart(2,"0"),f=String(b.getDate()).padStart(2,"0"),g=String(b.getHours()).padStart(2,"0"),h=String(b.getMinutes()).padStart(2,"0");return d?`${e}-${f} ${g}:${h}`:`${b.getFullYear()}-${e}-${f} ${g}:${h}`}let n=()=>{},o=50},12568:(a,b,c)=>{"use strict";c.d(b,{ReviewDropdown:()=>o});var d=c(48249),e=c(67484),f=c(44384),g=c(29939),h=c(61130),i=c(79606),j=c(33281),k=c(83120);let l="review-last-viewed";function m(){try{return JSON.parse(localStorage.getItem(l)||"{}")}catch{return{}}}function n(a,b){if(!a.lastCommentAt)return!1;let c=b[a.id];return!c||a.lastCommentAt>c}function o({cwd:a}){let{t:b}=(0,f.Bd)(),[c,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)([]),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)({open:!1,comments:[],title:"",userNameMap:{}}),A=(0,e.useRef)(null),B=(0,e.useRef)(null),[C,D]=(0,e.useState)(null),E=(0,e.useCallback)(async()=>{t(!0);let a=await j.t4.runPromiseExit((0,k.Y_)());"Success"===a._tag&&r(a.value.reviews??[]),t(!1)},[]),F=(0,e.useCallback)(a=>{let{data:b}=a;Array.isArray(b)&&b.some(a=>"review"===a.type)&&E()},[E]);(0,g.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"/")}`,onMessage:F,enabled:!!a});let G=(0,e.useMemo)(()=>q.filter(a=>a.active),[q]),H=(0,e.useMemo)(()=>G.some(a=>n(a,w)),[G,w]),I=(0,e.useCallback)(a=>{let b;(b=m())[a]=Date.now(),localStorage.setItem(l,JSON.stringify(b)),x(m()),window.open(`${window.location.origin}/review/${a}`,"_blank")},[]),J=(0,e.useCallback)(async(a,b)=>{a.stopPropagation();let[c,d]=await Promise.all([j.t4.runPromiseExit((0,k.JK)(b)),j.t4.runPromiseExit((0,k.BL)())]);if("Success"!==c._tag)return;let e=c.value.review,f={};if("Success"===d._tag)for(let[a,b]of Object.entries(d.value.users))f[a]=b.name;z({open:!0,comments:e.comments||[],title:e.title??"",userNameMap:f})},[]),K=(0,e.useCallback)((a,b)=>{B.current=b,a.dataTransfer.effectAllowed="move";let c=a.currentTarget;requestAnimationFrame(()=>c.classList.add("opacity-30"))},[]),L=(0,e.useCallback)(a=>{B.current=null,D(null),a.currentTarget instanceof HTMLElement&&a.currentTarget.classList.remove("opacity-30")},[]),M=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",B.current&&B.current!==b&&D(b)},[]),N=(0,e.useCallback)((a,b)=>{a.preventDefault(),D(null);let c=B.current;B.current=null,c&&c!==b&&r(a=>{let d=[...a],e=d.findIndex(a=>a.id===c),f=d.findIndex(a=>a.id===b);if(-1===e||-1===f)return a;let[g]=d.splice(e,1);d.splice(f,0,g);let h=d.map(a=>a.id);return j.t4.runFork((0,k.z1)(h).pipe(i.NWQ(()=>i.rIH))),d})},[]);return(0,d.jsxs)("div",{ref:A,className:"relative",children:[(0,d.jsxs)("button",{onClick:()=>p(a=>!a),className:`relative p-2 rounded-lg transition-colors ${c?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:b("review.reviewManagement"),children:[(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),H&&(0,d.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full"})]}),c&&(0,d.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-popover border border-border rounded-lg shadow-lv3 z-50 overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:b("review.allReviews")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground/60 ml-1.5",children:G.length})]}),(0,d.jsx)("button",{onClick:E,className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",title:b("common.refresh"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 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,d.jsx)("div",{className:"max-h-80 overflow-y-auto",children:s&&0===q.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("common.loading")}):0===G.length?(0,d.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground/50 text-center",children:b("review.noOpenReviews")}):G.map(a=>{let c,e,f,g,h,i=n(a,w);return(0,d.jsxs)("div",{draggable:!0,onDragStart:b=>K(b,a.id),onDragEnd:L,onDragOver:b=>M(b,a.id),onDrop:b=>N(b,a.id),onMouseEnter:b=>{let c=b.currentTarget.getBoundingClientRect();v({id:a.id,text:a.title,top:c.top+c.height/2,left:c.left})},onMouseLeave:()=>v(b=>b?.id===a.id?null:b),onClick:()=>I(a.id),className:`group px-3 py-2 cursor-pointer border-b transition-colors ${C===a.id?"border-b-brand border-t border-t-transparent":"border-b-border/50"} hover:bg-hover`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i?"bg-red-500":"bg-green-500"}`}),(0,d.jsx)("span",{className:`text-xs truncate flex-1 ${i?"font-medium text-foreground":""}`,children:a.title}),a.commentCount>0&&(0,d.jsx)("button",{onClick:b=>J(b,a.id),className:"flex-shrink-0 p-0.5 rounded text-muted-foreground/0 group-hover:text-muted-foreground/60 hover:!text-brand hover:!bg-brand/10 transition-colors",title:b("review.viewComments"),children:(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/50 mt-0.5 pl-3",children:[(0,d.jsx)("span",{children:(e=String((c=new Date(a.updatedAt||a.createdAt)).getMonth()+1).padStart(2,"0"),f=String(c.getDate()).padStart(2,"0"),g=String(c.getHours()).padStart(2,"0"),h=String(c.getMinutes()).padStart(2,"0"),`${e}-${f} ${g}:${h}`)}),a.commentCount>0&&(0,d.jsx)("span",{children:b("review.nComments",{count:a.commentCount})})]})]},a.id)})})]}),u&&c&&(0,d.jsx)("div",{className:"fixed z-[60] px-2 py-1 text-xs bg-popover text-popover-foreground border border-border rounded shadow-lv2 whitespace-nowrap pointer-events-none",style:{top:u.top,left:u.left-8,transform:"translate(-100%, -50%)"},children:u.text}),(0,d.jsx)(h.ReviewCommentsListModal,{isOpen:y.open,onClose:()=>z(a=>({...a,open:!1})),comments:y.comments,reviewTitle:y.title,userNameMap:y.userNameMap})]})}},13054:(a,b,c)=>{"use strict";c.d(b,{P_:()=>m,Q_:()=>n,nS:()=>p});var d=c(67484),e=c(57031),f=c(88214),g=c(79606),h=c(208),i=c(7833),j=c(33281),k=c(71192);let l=(a,b,c)=>g.$mh({try:async()=>{let d=await fetch(a,{method:b,headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw Error(`HTTP ${d.status}`);return await d.json()},catch:c=>new k.uV({message:`${b} ${a} failed`,cause:c})});function m(a){return a.split("/").pop()||a}function n(a){return a.resolvedPrompt||a.message||a.taskFile||""}function o(){(0,e.F)(f.n.ScheduledTasksChanged,{}),document.querySelectorAll("iframe").forEach(a=>{try{a.contentWindow?.postMessage({type:"SCHEDULED_TASKS_CHANGED"},"*")}catch{}})}function p(){let[a,b]=(0,d.useState)([]),[c,e]=(0,d.useState)(0),f=(0,d.useCallback)(()=>{let a;j.t4.runPromise((a="/api/scheduled-tasks",g.$mh({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:b=>new k.uV({message:`fetch ${a} failed`,cause:b})})).pipe(g.YWq({onSuccess:a=>{b(a.tasks??[]),e(a.unreadCount??0)},onFailure:()=>{}})))},[]),m=(0,d.useCallback)(async a=>{let b=await j.t4.runPromiseExit(l("/api/scheduled-tasks","POST",{language:h.A.language,...a}));if("Success"!==b._tag)return null;let c=b.value;return c.task?(f(),o(),c.task):null},[f]),n=(0,d.useCallback)(async a=>{await j.t4.runPromise(l("/api/scheduled-tasks","PATCH",a).pipe(g.NLW).pipe(g.NWQ(()=>g.rIH))),f(),o()},[f]),p=(0,d.useCallback)(a=>n({id:a,action:"pause"}),[n]),q=(0,d.useCallback)(a=>n({id:a,action:"resume"}),[n]),r=(0,d.useCallback)(async a=>{await j.t4.runPromise(l("/api/scheduled-tasks","DELETE",{id:a}).pipe(g.NLW).pipe(g.as(!0),g.DM4(()=>!1)))||(0,i.oR)(h.A.t("scheduledTasks.deleteFailed"),"error"),f(),o()},[f]),s=(0,d.useCallback)((a,b)=>n({id:a,action:"update",fields:{...b,language:h.A.language}}),[n]),t=(0,d.useCallback)(a=>n({id:a,action:"trigger"}),[n]),u=(0,d.useCallback)(a=>n({id:a,action:"markRead"}),[n]);return{tasks:a,unreadCount:c,reload:f,createTask:m,pauseTask:p,resumeTask:q,triggerTask:t,deleteTask:r,updateTask:s,markRead:u,markAllRead:(0,d.useCallback)(()=>n({action:"markAllRead"}),[n]),reorderTasks:(0,d.useCallback)(a=>n({action:"reorder",fields:{orderedIds:a}}),[n])}}},13265:(a,b,c)=>{"use strict";c.d(b,{i:()=>e});let d="http://cockpit.invalid";function e(a,b){let c;if(!a)return null;let e=a.trim();try{if(e.startsWith("/")){if((c=new URL(e,d)).origin!==d)return null}else if(!b||(c=new URL(e)).origin!==b)return null}catch{return null}if("/project"!==c.pathname)return null;let f=c.searchParams.get("cwd"),g=c.searchParams.get("sessionId");return f&&g?{cwd:f,sessionId:g}:null}},13512:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{d:()=>o,o:()=>n});var e=c(67484),f=c(36043),g=c(74754),h=c(91579),i=c(208),j=c(7031),k=c(38896),l=c(36984),m=c(37690);function n(a,b){let c,d=document.createTreeWalker(a,NodeFilter.SHOW_TEXT),e=b,f=null;for(;c=d.nextNode();){f=c;let a=c.textContent.length;if(e<=a)return{node:c,offset:e};e-=a}return f?{node:f,offset:f.textContent.length}:null}function o({content:a,filePath:b,showSearch:c=!0,cwd:d,enableComments:n=!1,scrollToLine:p=null,scrollToLineAlign:q="center",onScrollToLineComplete:r,visibleLineRef:s,onContentSearch:t}){let[u,v]=(0,e.useState)(!1),w=(0,e.useRef)(null),x=(0,e.useRef)(null),y=(0,e.useRef)(null),z=(0,j.r)(),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(null);(0,e.useRef)(null);let[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(""),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(0),[O,P]=(0,e.useState)(0),Q=(0,e.useRef)(!1),[R,S]=(0,e.useState)(null),T=(0,e.useRef)(!1),U=(0,e.useRef)(null),[V,W]=(0,e.useState)(null),[X,Y]=(0,e.useState)(null),Z=(0,e.useMemo)(()=>a.split("\n"),[a]),[$,_]=(0,e.useState)(null),aa=n&&!!d,{toolbarRef:ab,bumpRef:ac,clearToolbar:ad}=(0,m.L)({enabled:aa,container:$,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-line]");if(!c)return null;let d=parseInt(c.getAttribute("data-line")||"0",10);return!Number.isFinite(d)||d<=0?null:{start:d,end:d}},buildLineSnapshot:({start:a,end:b})=>Z.slice(a-1,b).join("\n")}),ae=(0,e.useRef)(null),[af,ag]=(0,e.useState)(0),{comments:ah,addComment:ai,updateComment:aj,deleteComment:ak,refresh:al}=(0,g._)({cwd:d||"",filePath:b}),am=(0,k.C)(Z,b),an=(0,e.useMemo)(()=>{let a=new Map;for(let b of ah){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[ah]),ao=(0,e.useMemo)(()=>{let a=new Set;for(let b of ah)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[ah]),ap=(0,e.useMemo)(()=>(0,l.Np)(Z,G,I,K),[Z,G,I,K]),aq=(0,e.useMemo)(()=>{let a=[];for(let b=0;b<Z.length;b++)a.push({type:"code",lineIndex:b});return a},[Z.length]),ar=(0,f.Te)({count:aq.length,getScrollElement:()=>w.current,estimateSize:()=>20,overscan:10}),as=(0,e.useCallback)(()=>{0!==ap.length&&(N(a=>(a+1)%ap.length),P(a=>a+1))},[ap.length]),at=(0,e.useCallback)(()=>{0!==ap.length&&(N(a=>(a-1+ap.length)%ap.length),P(a=>a+1))},[ap.length]);(0,e.useRef)(p).current=p;let au=(0,e.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?at():as()),"Escape"===a.key&&(F(!1),H(""))},[as,at]),av=(0,e.useCallback)((a,b)=>{aa&&(b.stopPropagation(),S({comment:a,x:b.clientX,y:b.clientY}),ad(),W(null),Y(null))},[aa,ad]),aw=(0,e.useCallback)(()=>{let a=ab.current;a&&(W({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ad())},[ad,ab]),ax=(0,e.useCallback)(()=>{let a=ab.current;a&&(Y({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ad())},[ad,ab]),ay=(0,e.useCallback)(()=>{let a=ab.current;a&&z&&(ad(),(0,h.Ff)(z.sendMessage,{filePath:b,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},i.A.t("explain.selectionMessage")))},[z,b,ad,ab]),az=(0,e.useCallback)(()=>{let a=ab.current;if(!a||!t)return;let b=a.selectedText.trim();ad(),b&&t(b)},[t,ad,ab]),aA=(0,e.useCallback)(async a=>{V&&(await ai(V.range.start,V.range.end,a,V.selectedText),W(null))},[V,ai]),aB=(0,e.useCallback)(async(a,c)=>{if(z&&d)try{let e=await (0,h.$3)(d),f=[];for(let a of e)f.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});f.push({filePath:b,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot});let g=(0,h.Gw)(f,c);z.sendMessage(g),await (0,h.RP)(d),al()}catch(a){console.error("Failed to send to AI:",a)}},[z,b,d,al]),aC=(0,e.useCallback)(a=>{X&&aB(X,a)},[X,aB]),aD=(0,e.useCallback)(a=>{V&&aB(V,a)},[V,aB]),aE=(0,e.useCallback)((a,b,c)=>{let d=Z[a];if(!d)return b;let e=[];if(G&&ap.length>0)for(let b of ap.filter(b=>b.lineIndex===a)){let c=ap[M]?.lineIndex===a&&ap[M]?.startCol===b.startCol;e.push({start:b.startCol,end:b.endCol,cls:c?"hl-cur":"hl-m"})}if(c&&!G&&c.length>=1){let a=c.toLowerCase(),b=d.toLowerCase(),f=0;for(;-1!==(f=b.indexOf(a,f));)e.push({start:f,end:f+c.length,cls:"hl-kw"}),f+=1}if(0===e.length)return b;if(e.sort((a,b)=>a.start-b.start||a.end-b.end),e.length>l.ZR){let a=e.findIndex(a=>"hl-cur"===a.cls),b=e.slice(0,l.ZR);a>=l.ZR&&(b[b.length-1]=e[a]),e=b}let f=[],g=0;for(let a of e){if(a.start<g)continue;a.start>g&&f.push((0,l.ZD)(d.substring(g,a.start)));let b=(0,l.ZD)(d.substring(a.start,a.end));f.push(`<span class="${a.cls}">${b}</span>`),g=a.end}g<d.length&&f.push((0,l.ZD)(d.substring(g)));let h=(0,l.ZD)(d);if(b!==h){let a=b;for(let b of e){let c=d.substring(b.start,b.end),e=(0,l.ZD)(c),f=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=RegExp(`(?<=>)([^<]*?)(${f})`,""),h=`$1<span class="${b.cls}">${e}</span>`,i=a.replace(g,h);i.length>a.length+200||(a=i)}return a}return f.join("")},[G,ap,M,Z]);return{parentRef:w,containerRef:x,searchInputRef:y,floatingToolbarRef:ab,suppressHoverRef:T,savedSelectionRef:U,highlightedLines:am,isMounted:u,cmdHeld:A,flashLine:C,isSearchVisible:E,searchQuery:G,caseSensitive:I,wholeWord:K,currentMatchIndex:M,viewingComment:R,bumpToolbarRef:ac,addCommentInput:V,sendToAIInput:X,aiBridge:z,commentsEnabled:aa,comments:ah,updateComment:aj,deleteComment:ak,lines:Z,matches:ap,rowData:aq,virtualizer:ar,commentsByEndLine:an,linesWithComments:ao,setIsSearchVisible:F,setSearchQuery:H,suppressMatchScrollRef:Q,setCaseSensitive:J,setWholeWord:L,setViewingComment:S,setAddCommentInput:W,setSendToAIInput:Y,goToNextMatch:as,goToPrevMatch:at,handleSearchKeyDown:au,handleCommentBubbleClick:av,handleToolbarAddComment:aw,handleToolbarSendToAI:ax,handleToolbarExplain:ay,handleToolbarSearch:az,handleCommentSubmit:aA,handleSendToAISubmit:aC,handleCommentSendToAI:aD,getHighlightedLineHtml:aE,inlineBlameLineRef:ae,inlineBlameVersion:af}}d()}catch(a){d(a)}})},14222:(a,b,c)=>{"use strict";c.d(b,{c:()=>g,k:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g({value:a,children:b}){return(0,d.jsx)(f.Provider,{value:a,children:b})}function h(){return(0,e.useContext)(f)}},15105:(a,b,c)=>{"use strict";c.d(b,{G:()=>l,f:()=>m});var d=c(67484);function e(){if("u"<typeof document)return null;let a=document.querySelector('meta[name="cockpit-bridge"]');if(!a)return null;let b=a.dataset.id,c=a.dataset.version;return b?{id:b,version:c||"unknown"}:null}let f=null,g=new Set;function h(){g.forEach(a=>a())}function i(a){g.add(a);let b=e();return b&&!f&&(f=b,Promise.resolve().then(h)),()=>{g.delete(a)}}function j(){return f}function k(){return null}if("u">typeof document&&(f=e()),"u">typeof MutationObserver&&"u">typeof document){let a=new MutationObserver(()=>{let a=e();a&&(!f||a.id!==f.id||a.version!==f.version)&&(f=a,h())}),b=document.head||document.documentElement;b&&a.observe(b,{childList:!0})}function l(){return(0,d.useSyncExternalStore)(i,j,k)}function m(){return f??e()}},15332:(a,b,c)=>{"use strict";c.d(b,{Eo:()=>g,jm:()=>e,zB:()=>f});var d=c(27668);let e=()=>(0,d.zi)("/api/bots"),f=a=>(0,d.B2)("/api/bots",{path:a}),g=a=>(0,d.zi)(`/api/bots/${encodeURIComponent(a)}`,{method:"DELETE"})},15466:(a,b,c)=>{"use strict";function d(a){return a.trim().toLowerCase().replace(/[\s]+/g,"-").replace(/[^\w一-鿿぀-ヿ가-힯-]/g,"").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"")}function e(a,b){if(!a)return!1;let c=b;try{c=decodeURIComponent(b)}catch{}let e=d(c);if(!e)return!1;for(let b of a.querySelectorAll("h1, h2, h3, h4, h5, h6"))if(d(b.textContent||"")===e)return b.scrollIntoView({behavior:"smooth",block:"start"}),!0;return!1}c.d(b,{O:()=>e})},15565:(a,b,c)=>{Promise.resolve().then(c.bind(c,62397)),Promise.resolve().then(c.bind(c,55632)),Promise.resolve().then(c.bind(c,99829)),Promise.resolve().then(c.bind(c,24943)),Promise.resolve().then(c.bind(c,74837)),Promise.resolve().then(c.bind(c,85906)),Promise.resolve().then(c.bind(c,72399)),Promise.resolve().then(c.bind(c,25702)),Promise.resolve().then(c.bind(c,47938)),Promise.resolve().then(c.bind(c,19562)),Promise.resolve().then(c.bind(c,83022)),Promise.resolve().then(c.bind(c,6612)),Promise.resolve().then(c.bind(c,93448)),Promise.resolve().then(c.bind(c,65395)),Promise.resolve().then(c.bind(c,84747))},15790:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{x:()=>k});var e=c(48249),f=c(67484),g=c(44384);c(33281);var h=c(2929);c(81206);var i=c(13054),j=a([h]);function k({task:a,onOpenSession:b}){let{t:c}=(0,g.Bd)(),{cwd:d,sessionId:j}=a,[l,m]=(0,f.useState)(null);(0,f.useRef)(void 0);let n=(0,f.useRef)(null),o=(0,f.useRef)(null),p=(0,f.useRef)(!0),[q,r]=(0,f.useState)(!0),s=(0,f.useCallback)(()=>{let a=n.current;if(!a)return;let b=a.scrollTop+a.clientHeight>=a.scrollHeight-40;p.current=b,r(b||a.scrollTop<=40)},[]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[(0,e.jsx)("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border flex-shrink-0",children:(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":d,children:(0,i.P_)(d)}),(0,e.jsx)("div",{className:"text-[11px] text-muted-foreground truncate","data-tooltip":(0,i.Q_)(a),children:(0,i.Q_)(a)})]})}),(0,e.jsxs)("div",{className:"relative flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:n,onScroll:s,className:"flex-1 overflow-y-auto px-8 py-4",children:null===l||0===l.length?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-6",children:c(null===l?"common.loading":"scheduledTasks.noTaskMessages")}):(0,e.jsx)("div",{ref:o,className:"mx-auto w-full max-w-[var(--chat-column)] [&_a]:pointer-events-none",children:l.map(a=>(0,e.jsx)(h.s,{message:a,cwd:d,disableOverlays:!0},a.id))})}),(0,e.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pb-4",children:(0,e.jsxs)("button",{onClick:b,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-brand text-white text-sm font-medium shadow-lv3 hover:bg-brand/90 transition-opacity ${q?"opacity-100 pointer-events-auto":"opacity-0"}`,title:c("scheduledTasks.openSession"),children:[(0,e.jsx)("span",{children:c("scheduledTasks.openSession")}),(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:"M14 5l7 7-7 7M3 12h18"})})]})})]})]})}h=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},15819:(a,b,c)=>{"use strict";c.d(b,{aO:()=>d,iG:()=>e,jL:()=>f});let d="relative w-full max-w-[calc((100vw_-_28rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",e="relative w-full max-w-[calc((100vw_-_14rem)*0.9)] h-[90vh] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden",f="grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-3"},16618:(a,b,c)=>{"use strict";function d(a){let b=0xdeadbeef,c=0x41c6ce57;for(let d=0;d<a.length;d++){let e=a.charCodeAt(d);b=Math.imul(b^e,0x9e3779b1),c=Math.imul(c^e,0x5f356495)}return b=Math.imul(b^b>>>16,0x85ebca6b)^Math.imul(c^c>>>13,0xc2b2ae35),(0x100000000*(2097151&(c=Math.imul(c^c>>>16,0x85ebca6b)^Math.imul(b^b>>>13,0xc2b2ae35)))+(b>>>0)>>>0).toString(16)}function e(a){return a.replace(/\s+/g," ").trim()}function f(a,b){return a?`${a}>${b}`:b}function g(a){let b=a.childForFieldName("name");if(b)return b.text;for(let b=0;b<a.namedChildCount;b++){let c=a.namedChild(b);if(c&&("identifier"===c.type||"type_identifier"===c.type||"property_identifier"===c.type))return c.text}return"<anonymous>"}function h(a,b,c,g,i=[],j){return{qualifiedName:f(g,b),name:b,kind:c,startLine:a.startPosition.row+1,endLine:a.endPosition.row+1,contentHash:d(e(a.text)),children:i,params:j}}function i(a){let b=a.childForFieldName("parameter");if(b)return[b.text];let c=a.childForFieldName("parameters");if(!c)return;let d=[];for(let a=0;a<c.namedChildCount;a++){let b=c.namedChild(a);b&&d.push(function a(b){switch(b.type){case"required_parameter":case"optional_parameter":{let c=b.childForFieldName("pattern");return c?a(c):b.text}case"assignment_pattern":{let c=b.childForFieldName("left");return c?a(c):b.text}case"default_parameter":case"typed_default_parameter":{let a=b.childForFieldName("name");return a?a.text:b.text}case"typed_parameter":for(let a=0;a<b.namedChildCount;a++){let c=b.namedChild(a);if(c?.type==="identifier")return c.text}return b.text;default:return b.text}}(b))}return d}c.d(b,{Hs:()=>k});let j={theorem:"function",def:"function",abbrev:"function",example:"function",instance:"const",structure:"class",inductive:"type",axiom:"const",opaque:"const",constant:"const"};function k(a,b){var c;let k,l,m=[],n=function(a){let b=[],c=-1,f=-1;for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(e){if("import_statement"===e.type||"export_statement"===e.type&&null!==e.childForFieldName("source")||"import_from_statement"===e.type||"future_import_statement"===e.type||"import"===e.type)b.push(e),c<0&&(c=e.startPosition.row+1),f=e.endPosition.row+1;else if(c>=0)break}}return c<0?null:{qualifiedName:"__imports__",name:"imports",kind:"unknown",startLine:c,endLine:f,contentHash:d(e(b.map(a=>a.text).join("\n"))),children:[]}}(a);if(n&&m.push(n),"lean"===b)m.push(...function(a){let b=[],c=[];for(let f=0;f<a.namedChildCount;f++){let g=a.namedChild(f);if(!g)continue;switch(g.type){case"namespace":c.push(g.childForFieldName("name")?.text??null);continue;case"section":c.push(null);continue;case"end":c.pop();continue}let h=null;if("declaration"===g.type)for(let a=0;a<g.namedChildCount;a++){let b=g.namedChild(a);if(b&&b.type in j){h=b;break}}else g.type in j&&(h=g);if(!h)continue;let i=h.childForFieldName("name")?.text??h.type,k=c.filter(a=>null!==a);b.push({qualifiedName:[...k,i].join("."),name:i,kind:j[h.type],startLine:g.startPosition.row+1,endLine:function(a){let b=a.endPosition.row+1,c=a.text.replace(/\s+$/,""),d=a.text.slice(c.length);if(!d)return b;let e=d.split("\n").length-1;return Math.max(a.startPosition.row+1,b-e)}(g),contentHash:d(e(g.text)),children:[]})}return b}(a));else for(let b=0;b<a.namedChildCount;b++){let c=a.namedChild(b);c&&m.push(...function a(b,c,j=!1){switch(b.type){case"export_statement":case"export_default_declaration":{let d=[];for(let e=0;e<b.namedChildCount;e++){let f=b.namedChild(e);f&&d.push(...a(f,c,!0))}return d}case"function_declaration":case"generator_function_declaration":case"function_definition":return[h(b,g(b),"function",c,[],i(b))];case"class_declaration":case"abstract_class_declaration":{let a=g(b),d=f(c,a),e=function(a,b){if(!a)return[];let c=[];for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(e){if("method_definition"===e.type)c.push(h(e,g(e),"method",b,[],i(e)));else if("public_field_definition"===e.type){let a=e.childForFieldName("value");a&&("arrow_function"===a.type||"function_expression"===a.type)&&c.push(h(e,g(e),"method",b,[],i(a)))}}}return c}(b.childForFieldName("body"),d);return[h(b,a,"class",c,e)]}case"interface_declaration":return[h(b,g(b),"interface",c)];case"type_alias_declaration":return[h(b,g(b),"type",c)];case"enum_declaration":return[h(b,g(b),"enum",c)];case"lexical_declaration":case"variable_declaration":return function(a,b){let c=[];for(let d=0;d<a.namedChildCount;d++){let e=a.namedChild(d);if(!e||"variable_declarator"!==e.type)continue;let f=e.childForFieldName("name"),j=e.childForFieldName("value");if(!f)continue;let k=f.text,l=j&&("arrow_function"===j.type||"function_expression"===j.type),m=l&&j?i(j):void 0;if(c.push(h(a,k,l?"function":"const",b,[],m)),j&&"object"===j.type&&!l){let a=b?`${b}>${k}`:k;for(let b=0;b<j.namedChildCount;b++){let d=j.namedChild(b);if(d){if("pair"===d.type){let b=d.childForFieldName("key"),e=d.childForFieldName("value");if(!b||!e||"property_identifier"!==b.type&&"identifier"!==b.type||"arrow_function"!==e.type&&"function_expression"!==e.type)continue;c.push(h(d,b.text,"method",a,[],i(e)))}else if("method_definition"===d.type){let b=g(d);b&&c.push(h(d,b,"method",a,[],i(d)))}}}}}return c}(b,c);case"class_definition":{let a=g(b),j=f(c,a),k=function a(b,c){if(!b)return[];let j=[];for(let k=0;k<b.namedChildCount;k++){let l=b.namedChild(k);if(l){if("function_definition"===l.type)j.push(h(l,g(l),"method",c,[],i(l)));else if("decorated_definition"===l.type){let b=l.childForFieldName("definition");if(b?.type==="function_definition")j.push({...h(b,g(b),"method",c,[],i(b)),startLine:l.startPosition.row+1,contentHash:d(e(l.text))});else if(b?.type==="class_definition"){let i=g(b),k=f(c,i),m=a(b.childForFieldName("body"),k);j.push({...h(b,i,"class",c,m),startLine:l.startPosition.row+1,contentHash:d(e(l.text))})}}else if("class_definition"===l.type){let b=g(l),d=f(c,b),e=a(l.childForFieldName("body"),d);j.push(h(l,b,"class",c,e))}}}return j}(b.childForFieldName("body"),j);return[h(b,a,"class",c,k)]}case"decorated_definition":{let f=b.childForFieldName("definition");if(!f)return[];return a(f,c,!1).map(a=>({...a,startLine:b.startPosition.row+1,contentHash:d(e(b.text))}))}case"expression_statement":{let a=[];for(let g=0;g<b.namedChildCount;g++){let h=b.namedChild(g);if(h?.type==="assignment"){let g=function(a,b,c){let g=b.childForFieldName("left");if(!g||"identifier"!==g.type)return null;let h=g.text;return{qualifiedName:f(c,h),name:h,kind:"const",startLine:a.startPosition.row+1,endLine:a.endPosition.row+1,contentHash:d(e(a.text)),children:[]}}(b,h,c);g&&a.push(g)}}return a.push(...function(a,b){let c=null;for(let b=0;b<a.namedChildCount;b++){let d=a.namedChild(b);if(d){if("call_expression"===d.type){c=d;break}if("await_expression"===d.type){for(let a=0;a<d.namedChildCount;a++){let b=d.namedChild(a);if(b?.type==="call_expression"){c=b;break}}break}}}if(!c)return[];let d=c.childForFieldName("function"),e=c.childForFieldName("arguments");if(!d||!e)return[];let f=null,g=[];for(let a=0;a<e.namedChildCount;a++){let b=e.namedChild(a);if(b){if(null===f&&("string"===b.type||"template_string"===b.type)){let a=b.text;f=a.length>=2&&/^["'`]/.test(a)?a.slice(1,-1):a}("arrow_function"===b.type||"function_expression"===b.type)&&g.push(b)}}if(0===g.length||!f)return[];let j=function a(b){if("identifier"===b.type)return b.text;if("member_expression"===b.type){let a=b.childForFieldName("property");return a?.text??""}if("call_expression"===b.type){let c=b.childForFieldName("function");return c?a(c):""}return""}(d),k=j?`${j} ${f}`:f;return g.map((a,c)=>h(a,g.length>1?`${k} #${c+1}`:k,"function",b,[],i(a)))}(b,c)),a}default:return[]}}(c,void 0,!1))}return!function(a,b){let c=new Map;for(let b=0;b<a.namedChildCount;b++){let d=a.namedChild(b);d&&d.type.endsWith("comment")&&c.set(d.endPosition.row+1,d)}if(0===c.size)return;let d=new Set;for(let a of b)for(let b=a.startLine;b<=a.endLine;b++)d.add(b);for(let a of b){if("unknown"===a.kind)continue;let b=a.startLine;for(;;){let a=c.get(b-1);if(!a)break;let e=a.startPosition.row+1,f=!1;for(let a=e;a<=b-1;a++)if(d.has(a)){f=!0;break}if(f)break;b=e}if(b!==a.startLine){for(let c=b;c<a.startLine;c++)d.add(c);a.startLine=b}}}(a,m),m.push(...function(a,b){let c=a.text.split("\n"),f=c.length;if(0===f)return[];let g=new Uint8Array(f+2);for(let a of b){let b=Math.max(1,a.startLine),c=Math.min(f,a.endLine);for(let a=b;a<=c;a++)g[a]=1}let h=[],i=(a,b)=>{let f=!1;for(let d=a;d<=b;d++){let a=c[d-1];if(a&&a.trim().length>0){f=!0;break}}if(!f)return;let g=c.slice(a-1,b).join("\n");h.push({qualifiedName:`__code_${a}_${b}__`,name:"code",kind:"unknown",startLine:a,endLine:b,contentHash:d(e(g)),children:[]})},j=-1;for(let a=1;a<=f;a++)g[a]?j>=0&&(i(j,a-1),j=-1):j<0&&(j=a);return j>=0&&i(j,f),h}(a,m)),c=m,k=new Map,(l=a=>{for(let b of a){let a=(k.get(b.qualifiedName)??0)+1;k.set(b.qualifiedName,a),a>1&&(b.qualifiedName=`${b.qualifiedName}#${a}`),l(b.children)}})(c),m}},17966:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{i:()=>m});var e=c(32580),f=c(16618),g=c(84398),h=c(4263),i=a([h]);function j(a){return a.qualifiedName.startsWith("__code_")||a.qualifiedName.startsWith("__heading_")}function k(a){return!j(a)&&"__file__"!==a.qualifiedName}async function l(a,b){if(!a)return[];let c=(0,g.k)(b);if(!c)return null;let d=(await (0,h.$)(c)).parse(a);if(!d)return null;try{return(0,f.Hs)(d.rootNode,c)}finally{d.delete()}}async function m(a,b,c,d,f){let h=new Set;if(a!==b)for(let c of(0,e.X)(d?"":a,f?"":b))"added"===c.type&&void 0!==c.newLineNum&&h.add(c.newLineNum);if(!(0,g.k)(c))return{addedLines:h};let[i,m]=await Promise.all([l(d?"":a,c),l(f?"":b,c)]),n=m??[],o=function(a,b){let c=new Map;for(let b of a)c.set(b.qualifiedName,b);let d=new Map;for(let a of b)d.set(a.qualifiedName,a);let e=[];for(let a of b){let b=c.get(a.qualifiedName);b?b.contentHash!==a.contentHash&&e.push({id:`mod:${a.qualifiedName}`,changeKind:"modified",qname:a.qualifiedName}):e.push({id:`add:${a.qualifiedName}`,changeKind:"added",qname:a.qualifiedName})}for(let b of a)d.has(b.qualifiedName)||e.push({id:`del:${b.qualifiedName}`,changeKind:"deleted",qname:b.qualifiedName});return e}((i??[]).filter(k),n.filter(k)),p=new Set;for(let a of o)"deleted"!==a.changeKind&&p.add(a.qname);for(let a of function(a,b){if(0===b.size)return[];let c=[];for(let d of a)if(j(d)){for(let a of b)if(a>=d.startLine&&a<=d.endLine){c.push(d.qualifiedName);break}}return c}(n,h))p.add(a);return{changedQnames:p,addedLines:h}}h=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},18479:(a,b,c)=>{"use strict";c.d(b,{Tt:()=>i,se:()=>h,xK:()=>g});var d=c(79606),e=c(71192);let f=a=>d.$mh({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:`GET ${a} failed`,cause:b})}),g=(a,b,c)=>f(`/api/snapshots?cwd=${encodeURIComponent(a)}&toolIds=${encodeURIComponent(b.join(","))}${c?`&sessionKey=${encodeURIComponent(c)}`:""}`).pipe(d.TjK(a=>a.commits??[])),h=(a,b,c)=>g(a,b,c).pipe(d.qIB(b=>d.Q7R(b.map(b=>{let c;return c=b.hash,f(`/api/snapshots/diff?cwd=${encodeURIComponent(a)}&commit=${encodeURIComponent(c)}`)}),{concurrency:4}))),i=(a,b,c)=>f(`/api/snapshots/range-diff?cwd=${encodeURIComponent(a)}&head=${encodeURIComponent(c)}${b?`&base=${encodeURIComponent(b)}`:""}`)},18499:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{_:()=>l});var e=c(48249),f=c(67484),g=c(44384);c(79606),c(33281);var h=c(74228),i=c(32753);c(41224);var j=c(50508),k=a([j]);j=(k.then?(await k)():k)[0];let m=(a,b)=>`${a}
16
- ${b}`;function l({collapsed:a,pinnedSessions:b,sessionNumbers:c,currentCwd:d,onSwitchProject:k,onUnpin:n,onUpdateTitle:o,onReorder:p}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(!1),t=(0,f.useRef)(null),[u,v]=(0,f.useState)(null),[w,x]=(0,f.useState)(""),y=(0,f.useRef)(null),z=(0,j.o$)(),{show:A,hide:B}=z,[C,D]=(0,f.useState)(null),[E,F]=(0,f.useState)(null),[G,H]=(0,f.useState)({}),I=(0,f.useCallback)(a=>{u||(k(a.cwd,a.sessionId),s(!1))},[k,u]),J=(0,f.useCallback)((a,b)=>{b.stopPropagation(),B(),v(a.sessionId),x(a.customTitle||"")},[B]),K=(0,f.useCallback)(()=>{u&&w.trim()&&o(u,w.trim()),v(null)},[u,w,o]),L=(0,f.useCallback)(a=>{B(),D(a)},[B]),M=(0,f.useCallback)((a,b)=>{a.preventDefault(),F(b)},[]),N=(0,f.useCallback)(a=>{if(null===C||C===a){D(null),F(null);return}let c=[...b],[d]=c.splice(C,1);c.splice(a,0,d),p(c),D(null),F(null)},[C,b,p]),O=(0,f.useCallback)(()=>{D(null),F(null)},[]);return(0,e.jsxs)("div",{className:"relative",ref:t,children:[(0,e.jsxs)("button",{onClick:()=>s(!r),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${a?"w-full justify-center":"w-full"}`,title:a?q("sessions.favorites"):void 0,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:"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,e.jsx)("span",{className:"text-sm flex-1 text-left",children:q("sessions.favorites")}),a&&b.length>0&&(0,e.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-popover border border-border",children:b.length})]}),r&&(0,e.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lv2 z-50 flex flex-col",children:[(0,e.jsx)("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:q("sessions.favorites")})}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:q("sessions.noFavorites")}):b.map((a,f)=>{let g=G[m(a.cwd,a.sessionId)],k=u===a.sessionId;return(0,e.jsxs)("div",{draggable:!0,onDragStart:()=>L(f),onDragOver:a=>M(a,f),onDrop:()=>N(f),onDragEnd:O,onClick:()=>I(a),onMouseEnter:b=>{k||A(g??{cwd:a.cwd,sessionId:a.sessionId,title:a.customTitle},b)},onMouseLeave:B,className:`group w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 cursor-pointer ${f!==b.length-1?"border-b border-border/50":""} ${d===a.cwd?"bg-accent/50":""} ${C===f?"opacity-50":""} ${E===f?"border-t-2 border-brand":""}`,children:[(0,e.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,e.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,e.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(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)(i.S,{engine:g?.engine}),(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:(0,j.Qr)(a.cwd)}),g?.lastActive?(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(0,j.fw)(q,g.lastActive)}):null,(0,e.jsx)(h.l,{coordinate:c?.[m(a.cwd,a.sessionId)],status:(0,h.S)(g?.status),statusLabel:(0,j.Mm)(q,g?.status),bot:g?.bot,className:"ml-auto"})]}),k?(0,e.jsx)("input",{ref:y,type:"text",value:w,onChange:a=>x(a.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||("Enter"===a.key&&K(),"Escape"===a.key&&v(null))},onBlur:K,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,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:a.customTitle||g?.title||a.sessionId.slice(0,8)}),!k&&g?.lastUserMessage&&(0,e.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:g.lastUserMessage})]}),!k&&(0,e.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,e.jsx)("button",{onClick:b=>J(a,b),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:q("sessions.editTitle"),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:"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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),B(),n(a.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:q("sessions.removeFavorite"),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"})})})]})]},a.sessionId)})})]}),(0,e.jsx)(j.LD,{...z})]})}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:var(--highlight)}::highlight(json-search-current){background:var(--highlight-current)}",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,onEngineChange:h,ollamaModel:j,onOllamaModelChange:k,deepseekModel:l,onDeepseekModelChange:m,kimiModel:n,onKimiModelChange:o,glmModel:p,onGlmModelChange:q,claudeModel:r,onClaudeModelChange:s,claudeEffort:t,onClaudeEffortChange:u,claudeFastMode:v,onClaudeFastModeChange:w,claudeThinking:x,onClaudeThinkingChange:y,codexModel:z,onCodexModelChange:A,codexReasoningEffort:B,onCodexReasoningEffortChange:C,planMode:D,onPlanModeChange:E,noHistory:F,onNoHistoryChange:G,outputStyle:H,onOutputStyleChange:I,isActive:J,isFocused:K,peerTabId:L,peerSide:M,refreshSignal:N,onStateChange:O,onShowGitStatus:P,onOpenNote:Q,isFavorite:R,onToggleFavorite:S,onCreateScheduledTask:T,onOpenSession:U,onContentSearch:V,onShowFileDiff:W,onOpenFileLink:X}){let Y=(0,f.useCallback)(b=>{O(a,{isLoading:b})},[a,O]),Z=(0,f.useCallback)(b=>{O(a,{sessionId:b})},[a,O]),$=(0,f.useCallback)(b=>{O(a,{title:b})},[a,O]),_=(0,f.useCallback)(b=>{O(a,{bot:b??void 0})},[a,O]),aa=(0,f.useCallback)(b=>{h?.(a,b)},[a,h]),ab=(0,f.useCallback)(b=>{k?.(a,b)},[a,k]),ac=(0,f.useCallback)(b=>{m?.(a,b)},[a,m]),ad=(0,f.useCallback)(b=>{o?.(a,b)},[a,o]),ae=(0,f.useCallback)(b=>{q?.(a,b)},[a,q]),af=(0,f.useCallback)(b=>{s?.(a,b)},[a,s]),ag=(0,f.useCallback)(b=>{u?.(a,b)},[a,u]),ah=(0,f.useCallback)(b=>{w?.(a,b)},[a,w]),ai=(0,f.useCallback)(b=>{y?.(a,b)},[a,y]),aj=(0,f.useCallback)(b=>{A?.(a,b)},[a,A]),ak=(0,f.useCallback)(b=>{C?.(a,b)},[a,C]),al=(0,f.useCallback)(b=>{E?.(a,b)},[a,E]),am=(0,f.useCallback)(b=>{G?.(a,b)},[a,G]),an=(0,f.useCallback)(b=>{I?.(a,b)},[a,I]),ao=(0,f.useCallback)(()=>{S?.(a)},[a,S]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:aa,ollamaModel:j,onOllamaModelChange:ab,deepseekModel:l,onDeepseekModelChange:ac,kimiModel:n,onKimiModelChange:ad,glmModel:p,onGlmModelChange:ae,claudeModel:r,onClaudeModelChange:af,claudeEffort:t,onClaudeEffortChange:ag,claudeFastMode:v,onClaudeFastModeChange:ah,claudeThinking:x,onClaudeThinkingChange:ai,codexModel:z,onCodexModelChange:aj,codexReasoningEffort:B,onCodexReasoningEffortChange:ak,planMode:D,onPlanModeChange:al,noHistory:F,onNoHistoryChange:am,outputStyle:H,onOutputStyleChange:an,hideHeader:!0,hideSidebar:!0,isActive:J,isFocused:K,peerTabId:L,peerSide:M,refreshSignal:N,onLoadingChange:Y,onSessionIdChange:Z,onTitleChange:$,onBotChange:_,onShowGitStatus:P,onOpenNote:Q,isFavorite:R,onToggleFavorite:c&&S?ao:void 0,onCreateScheduledTask:T,onOpenSession:U,onContentSearch:V,onShowFileDiff:W,onOpenFileLink:X})}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")},19593:(a,b,c)=>{"use strict";c.d(b,{C0:()=>m});var d=c(48249),e=c(67484),f=c(10316),g=c(46674),h=c(72419),i=c(44218),j=c(44384);let k=/^-?[\d,]*\.?\d+%?$/;function l(a){return k.test(a)?parseFloat(a.replace(/,/g,"")):NaN}function m({content:a,filePath:b,className:c="",action:n}){let{t:o}=(0,j.Bd)(),[p,q]=(0,e.useState)(500),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(-1),[v,w]=(0,e.useState)(null),{header:x,body:y,columnCount:z}=(0,e.useMemo)(()=>{let c=(function(a,b){let c=[],d=[],e="",f=!1,g=!1,h=()=>{d.push(e),c.push(d),d=[],e="",g=!1};for(let c=0;c<a.length;c++){let i=a[c];if(f){if('"'!==i){e+=i;continue}'"'===a[c+1]?(e+='"',c++):f=!1;continue}if('"'===i&&""===e){f=!0,g=!0;continue}if(i===b){d.push(e),e="",g=!0;continue}if("\r"===i){"\n"===a[c+1]&&c++,h();continue}if("\n"===i){h();continue}e+=i,g=!0}return(g||""!==e||d.length>0)&&h(),c})(a,function(a,b){if(b&&/\.tsv$/i.test(b))return" ";let c=a.slice(0,65536),d={",":0,";":0," ":0,"|":0},e=!1,f=0;for(let a=0;a<c.length&&f<5;a++){let b=c[a];if('"'===b){e=!e;continue}if(!e){if("\n"===b){f++;continue}b in d&&d[b]++}}let g=Object.entries(d).sort((a,b)=>b[1]-a[1])[0];return g[1]>0?g[0]:","}(a,b)).filter(a=>a.length>1||""!==a[0]),d=c.reduce((a,b)=>Math.max(a,b.length),0),e=c.slice(1).map((a,b)=>({index:b,cells:a}));return{header:c[0]??[],body:e,columnCount:d}},[a,b]),A=(0,e.useMemo)(()=>{let a=r.trim().toLowerCase();return a?y.filter(b=>t>=0?(b.cells[t]??"").toLowerCase().includes(a):b.cells.some(b=>b.toLowerCase().includes(a))):y},[y,r,t]),B=(0,e.useMemo)(()=>{if(!v)return A;let a="asc"===v.dir?1:-1;return[...A].sort((b,c)=>(function(a,b,c){if(""===a||""===b)return a===b?0:""===a?1:-1;let d=l(a),e=l(b);return isNaN(d)||isNaN(e)?a.localeCompare(b,void 0,{numeric:!0})*c:(d-e)*c})(b.cells[v.col]??"",c.cells[v.col]??"",a))},[A,v]),C=(0,e.useCallback)(a=>{w(b=>b&&b.col===a?"asc"===b.dir?{col:a,dir:"desc"}:null:{col:a,dir:"asc"})},[]);if(0===z)return(0,d.jsx)("div",{className:`flex items-center justify-center ${c}`,children:(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:o("csv.empty")})});let D=B.slice(0,p);return(0,d.jsxs)("div",{className:`flex flex-col min-h-0 ${c}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-0.5 rounded border border-border bg-card focus-within:border-brand transition-colors",children:[(0,d.jsx)(f.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0","aria-hidden":!0}),(0,d.jsx)("input",{value:r,onChange:a=>s(a.target.value),placeholder:o("csv.filterPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs text-foreground placeholder:text-muted-foreground outline-none"}),r&&(0,d.jsx)("button",{onClick:()=>s(""),className:"text-muted-foreground hover:text-foreground flex-shrink-0",title:o("csv.clearFilter"),children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("select",{value:t,onChange:a=>u(Number(a.target.value)),className:"text-xs bg-card text-muted-foreground border border-border rounded px-1 py-1 max-w-[10rem] flex-shrink-0",title:o("csv.filterColumn"),children:[(0,d.jsx)("option",{value:-1,children:o("csv.allColumns")}),Array.from({length:z},(a,b)=>(0,d.jsx)("option",{value:b,children:x[b]||`#${b+1}`},b))]}),n&&(0,d.jsx)("button",{onClick:n.onClick,className:"text-xs px-2 py-1 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:n.label})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,d.jsxs)("table",{className:"text-xs border-collapse w-max min-w-full",children:[(0,d.jsx)("thead",{className:"sticky top-0 z-10",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"sticky left-0 z-20 bg-accent border-b border-r border-border px-2 py-1.5 text-right font-normal text-muted-foreground select-none",children:"#"}),Array.from({length:z},(a,b)=>(0,d.jsx)("th",{onClick:()=>C(b),className:"bg-accent border-b border-border px-2 py-1.5 text-left font-medium text-foreground whitespace-nowrap cursor-pointer select-none hover:bg-hover",title:o("csv.sortHint"),children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[x[b]??"",v?.col===b&&("asc"===v.dir?(0,d.jsx)(h.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}):(0,d.jsx)(i.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}))]})},b))]})}),(0,d.jsx)("tbody",{children:D.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-hover",children:[(0,d.jsx)("td",{className:"sticky left-0 bg-card border-b border-r border-border px-2 py-1 text-right text-muted-foreground tabular-nums select-none",children:a.index+1}),Array.from({length:z},(b,c)=>{let e=a.cells[c]??"";return(0,d.jsx)("td",{title:e.length>60?e:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${k.test(e)?"text-right tabular-nums":""}`,children:e},c)})]},a.index))})]}),0===D.length&&(0,d.jsx)("div",{className:"p-4 text-xs text-muted-foreground",children:o("csv.noMatch")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:[(0,d.jsx)("span",{children:A.length===y.length?o("csv.summary",{rows:y.length,cols:z}):o("csv.summaryFiltered",{rows:A.length,total:y.length,cols:z})}),D.length<B.length&&(0,d.jsx)("button",{onClick:()=>q(a=>a+500),className:"px-1.5 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:o("csv.loadMore",{shown:D.length,total:B.length})})]})]})}},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.$mh({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.YWq({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.d(b,{Do:()=>o,Sz:()=>p,VO:()=>n,wI:()=>q});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(61591),i=c(8410),j=c(7122),k=c(7093);function l({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,d.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let m=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:j,onToggle:m,onContextMenu:n,showChanges:o=!1,showChangeClass:p=!1,hideIndicatorsOnHover:q=!1,renderActions:r}){let s,t=f===b.path,u=g.has(b.path),v=(0,e.useCallback)(()=>{b.isDirectory?m(b.path):j(b)},[b,j,m]),w=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),n(a,b.path,b.isDirectory)},[b.path,b.isDirectory,n]);return b.isDirectory?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-hover cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:v,onContextMenu:w,children:[(0,d.jsx)("span",{className:"text-foreground-subtle text-xs",children:u?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),r&&r(b)]}),u&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:j,onToggle:m,onContextMenu:n,showChanges:o,showChangeClass:p,hideIndicatorsOnHover:q,renderActions:r},b.path))]}):(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${t?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*c+8}px`},onClick:v,onContextMenu:w,children:[(0,d.jsx)(h.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${t?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),p&&((s=(0,k.q)(b.path))?(0,d.jsx)("span",{className:q?"group-hover:hidden":void 0,children:(0,d.jsx)(i.N,{cls:s})}):null),r&&r(b),b.status&&(0,d.jsx)("span",{className:q?"group-hover:hidden":void 0,children:(0,d.jsx)(l,{status:b.status})}),o&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)("span",{className:`contents ${q?"group-hover:hidden":""}`,children:[(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,d.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]})]})});function n({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:h,showChanges:i=!1,showChangeClass:k=!1,hideIndicatorsOnHover:l=!1,renderActions:o,emptyMessage:p,className:q,onExplain:r,explainDisabled:s}){let{t}=(0,g.Bd)(),u=p??t("gitFileTree.noFiles"),{contextMenu:v,showContextMenu:w,hideContextMenu:x}=(0,j.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:u}):(0,d.jsxs)("div",{className:q||"py-1",children:[a.map(a=>(0,d.jsx)(m,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:w,showChanges:i,showChangeClass:k,hideIndicatorsOnHover:l,renderActions:o},a.path)),v&&(0,d.jsx)(j.ft,{x:v.x,y:v.y,path:v.path,cwd:h,isDirectory:v.isDirectory,onClose:x,onExplain:r,explainDisabled:s})]})}function o(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 p(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function q(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},21482:(a,b,c)=>{"use strict";c.d(b,{D:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(46674);function h({results:a,loading:b,totalMatches:c,onSelect:i,onClose:j,scope:k,onScopeChange:l,selectedPath:m}){let{t:n}=(0,f.Bd)(),o=function(){let[a,b]=(0,e.useState)(new Map),[c,d]=(0,e.useState)(!1);return(0,e.useRef)(0),a}(),p="selected"===k?a.filter(a=>a.path===m):a,q=p.reduce((a,b)=>a+b.matches.length,0);return(0,d.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,d.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,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsxs)("span",{className:"text-xs font-medium text-foreground truncate",children:[n("searchResults.title")," ",!b&&n("searchResults.nMatches",{count:"selected"===k?q:c})]}),(0,d.jsxs)("div",{className:"flex items-center rounded border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,d.jsx)("button",{onClick:()=>l("selected"),className:`px-2 py-0.5 ${"selected"===k?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:n("searchResults.scopeSelected")}),(0,d.jsx)("button",{onClick:()=>l("all"),className:`px-2 py-0.5 border-l border-border ${"all"===k?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:n("searchResults.scopeAll")})]})]}),(0,d.jsx)("button",{onClick:j,className:"p-0.5 rounded hover:bg-hover text-muted-foreground flex-shrink-0",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.searching")}):0===p.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.noResults")}):p.map(a=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:a.path}),a.matches.map((b,c)=>{let e=`${a.path}:${b.lineNumber}`,f=o.get(e);return(0,d.jsxs)("button",{onClick:()=>i(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),f?(0,d.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:f}}):(0,d.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}c(36984)},21538:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>x});var e=c(48249),f=c(67484),g=c(44384),h=c(35208),i=c(39238),j=c(73887),k=c(74691),l=c(60333),m=c(20586),n=c(46242),o=c(21787),p=c(9804),q=c(33281),r=c(85655),s=c(60591),t=c(69606),u=c(18921),v=c(7031);c(57063);var w=a([h,i,j]);function x({isOpen:a,onClose:b,commit:c,cwd:d,embedded:w=!1,initialFilePath:y,onContentSearch:z,onLocateInTree:A}){let{t:B}=(0,g.Bd)(),[C,D]=(0,f.useState)([]),[E,F]=(0,f.useState)([]),[G,H]=(0,f.useState)(new Set),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)(null),[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)(!1),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)(null),[U,V]=(0,f.useState)(null),W=(0,f.useCallback)(()=>V(null),[]),X=(0,f.useCallback)(()=>R(null),[]),[Y,Z]=(0,f.useState)("compact"),[$,_]=(0,f.useState)("unified"),aa=(0,f.useRef)(null),ab=(0,u.o)(aa),ac=(0,v.r)(),ad=c?.shortHash,ae=(0,f.useCallback)(a=>{ad&&ac?.sendMessage(B("explain.commitFileMessage",{hash:ad,path:a}))},[ac,B,ad]),af=(0,f.useCallback)(a=>{c&&(J(a),P(!0),q.t4.runPromiseExit((0,r.Zi)(d,c.hash,a.path)).then(a=>{"Success"===a._tag?L(a.value):console.error(a.cause),P(!1)}))},[d,c]),ag=(0,f.useCallback)(a=>{H(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ah=(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]),ai=K?.filePath,aj=(0,f.useMemo)(()=>ai?(0,e.jsx)(o.d,{cwd:d,filePath:ai,onLocateInTree:A}):null,[d,ai,A]);if(!a||!c)return null;let ak=!!K&&(!0===K.isImage||(0,p.u)(K.filePath)),al=(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 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-foreground-subtle",children:B("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-foreground-subtle",children:B("commitDetail.author")}),(0,e.jsx)("span",{children:c.author}),(0,e.jsxs)("span",{className:"text-foreground-subtle",children:["<",c.authorEmail,">"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:B("commitDetail.date")}),(0,e.jsx)("span",{children:ah}),c.relativeDate&&(0,e.jsxs)("span",{className:"text-foreground-subtle",children:["(",c.relativeDate,")"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:B("commitDetail.files")}),(0,e.jsx)("span",{children:B("commitDetail.nChanges",{count:C.length})})]}),!ak&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(k.y,{value:Y,onChange:Z}),(0,e.jsx)(l.q,{value:$,onChange:_})]})]})]}),(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:M?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:B("commitDetail.loadingFiles")}):(0,e.jsx)(m.VO,{files:E,selectedPath:I?.path||null,expandedPaths:G,onSelect:a=>a.file&&af(a.file),onToggle:ag,cwd:d,showChanges:!0,showChangeClass:!0,emptyMessage:B("commitDetail.noFileChanges"),className:"py-1",onExplain:ac&&ad?ae:void 0,explainDisabled:ac?.isLoading})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:O?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:B("commitDetail.loadingDiff")}):K?ak?(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:aj}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(n.M,{cwd:d,filePath:K.filePath,oldRev:K.oldRev??(K.isNew?null:`${c.hash}^1`),newRev:K.newRev??(K.isDeleted?null:c.hash)})})]}):"unified"===$?(0,e.jsx)(h.xU,{oldContent:K.oldContent,newContent:K.newContent,filePath:K.filePath,cwd:d,enableComments:!0,compact:"compact"===Y,headerLeading:aj,onPreview:K.isDeleted?void 0:(0,s.aR)(K.filePath)?()=>T({content:K.newContent,filePath:K.filePath}):(0,s.e$)(K.filePath)?()=>V({content:K.newContent,filePath:K.filePath}):K.filePath.endsWith(".json")?()=>R({content:K.newContent,filePath:K.filePath}):void 0,previewLabel:K.filePath.endsWith(".json")?B("common.readable"):B("common.preview"),onContentSearch:z}):(0,e.jsx)(h.xZ,{oldContent:K.oldContent,newContent:K.newContent,filePath:K.filePath,isNew:K.isNew,isDeleted:K.isDeleted,cwd:d,enableComments:!0,compact:"compact"===Y,headerLeading:aj,onPreview:K.isDeleted?void 0:(0,s.aR)(K.filePath)?()=>T({content:K.newContent,filePath:K.filePath}):(0,s.e$)(K.filePath)?()=>V({content:K.newContent,filePath:K.filePath}):K.filePath.endsWith(".json")?()=>R({content:K.newContent,filePath:K.filePath}):void 0,previewLabel:K.filePath.endsWith(".json")?B("common.readable"):B("common.preview"),onContentSearch:z}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:B("commitDetail.selectFileToView")})})]})]}),am=Q&&(0,e.jsx)(t.A,{preview:Q,onClose:X,search:ab,preRef:aa}),an=S&&(0,e.jsx)(i.N,{filePath:S.filePath,content:S.content,cwd:d,onClose:()=>T(null)}),ao=U&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:W,children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(j.M,{content:U.content,filePath:U.filePath,cwd:d,onClose:W})})});return w?(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-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:B("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),al,am,an,ao]}):(0,e.jsx)("div",{className:"fixed inset-0 z-[60] bg-scrim",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:B("commitDetail.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover 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"})})})]}),al,am,an,ao]})})}[h,i,j]=w.then?(await w)():w,d()}catch(a){d(a)}})},21672:(a,b,c)=>{"use strict";c.d(b,{D:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(46674);function h({references:a,loading:b,onSelect:c,onClose:i}){let{t:j}=(0,f.Bd)(),k=function(){let[a,b]=(0,e.useState)(new Map),[c,d]=(0,e.useState)(!1);return(0,e.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,d.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,d.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,d.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[j("references.title")," ",!b&&`(${a.length})`]}),(0,d.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("references.searching")}):0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("references.notFound")}):l.map(({file:a,items:b})=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:a}),b.map(({ref:a,idx:b})=>(0,d.jsxs)("button",{onClick:()=>c(a),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:a.line}),k.has(b)?(0,d.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:k.get(b)}}):(0,d.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:a.lineText||""})]},`${a.line}-${a.column}-${b}`))]},a))})]})}c(36984)},21787:(a,b,c)=>{"use strict";c.d(b,{d:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(72529),h=c(7833);let i=(0,e.memo)(function({cwd:a,filePath:b,onLocateInTree:c}){let{t:e}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground truncate",title:b,children:b}),(0,d.jsx)(g.m,{content:e("common.copyAbsPath"),children:(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(e("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 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"})})})}),c&&(0,d.jsx)(g.m,{content:e("fileBrowser.locateInTree"),children:(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),c(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})})]})})},23328:(a,b,c)=>{"use strict";c.d(b,{AJ:()=>r,Cb:()=>D,D0:()=>z,D5:()=>E,DN:()=>m,Jn:()=>k,MR:()=>n,Ok:()=>w,QF:()=>j,SN:()=>s,UV:()=>C,Vv:()=>u,Yj:()=>B,Yn:()=>A,bv:()=>t,cm:()=>o,cv:()=>v,jO:()=>x,px:()=>F,tp:()=>y,uc:()=>q,y8:()=>p});var d=c(79606),e=c(71192);let f=a=>d.$mh({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.$mh({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.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),j=(a,b)=>d.JkU(function*(){let c=new URLSearchParams({cwd:a});b&&c.set("tabId",b);let d=yield*f(`/api/terminal/env?${c}`);return{env:d.env||{},home:d.home||""}}),k=()=>f("/api/terminal/aliases").pipe(d.TjK(a=>a.aliases||{})),l=(a,b)=>`/api/terminal/bubble-order?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}`,m=(a,b)=>f(l(a,b)).pipe(d.TjK(a=>a.order||[])),n=(a,b)=>f(l(a,b)).pipe(d.TjK(a=>a.titles||{})),o=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,order:c,sourceId:d}),p=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,titles:{[c]:d}}),q=(a,b,c,d=100)=>f(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&page=${c}&pageSize=${d}`),r=(a,b,c,d)=>h("/api/terminal/history",{cwd:a,tabId:b,entry:c,sourceId:d}),s=(a,b,c,d)=>g(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&commandId=${encodeURIComponent(c)}${d?`&sourceId=${encodeURIComponent(d)}`:""}`,{method:"DELETE"}),t=(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})}),u=a=>h("/api/terminal/env",a),v=a=>h("/api/terminal/aliases",{aliases:a}),w=a=>h("/api/terminal/register",a),x=a=>h("/api/terminal/unregister",a),y=a=>d.$mh({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})}),z=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),A=a=>h("/api/project-settings",a),B=()=>f("/api/services/config?scope=global"),C=a=>f(`/api/services/config?cwd=${encodeURIComponent(a)}`),D=a=>i("/api/services/config",a),E=()=>f("/api/terminal/running"),F=a=>i("/api/terminal/running",{commandId:a})},23389:(a,b,c)=>{"use strict";function d(a){return/^~(?=$|[/\\])/.test(a.trim())}function e(a,b){return b&&d(a)?b.replace(/[/\\]+$/,"")+a.trim().slice(1):a}c.d(b,{D:()=>e,P:()=>d})},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(81206),l=a([j]);function m({cwd:a,sessionId:b,toolCall:c,workflowRef:d,running:l,onClose:n}){let{t:o}=(0,g.Bd)(),[p,q]=(0,f.useState)(null),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),v=(0,f.useRef)(void 0),w=d?!!d.running:l??!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:v.current}));if(u(!0),"Success"!==e._tag||!e.value)return;let f=e.value;f.fingerprint&&(v.current=f.fingerprint),!f.notModified&&(f.messages&&q(f.messages),f.subagent&&s(f.subagent))},[a,b,c?.id,d?.runId,d?.agentId]);let x=(0,f.useRef)(null),y=(0,f.useRef)(!0),z="string"==typeof c?.input?.description?c.input.description:"",A=d?d.label||"":[r?.agentType,z].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-scrim p-4",onClick:a=>{a.stopPropagation(),n()},children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 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:o("chat.subagent")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[w&&(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:n,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:o("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:x,onScroll:()=>{let a=x.current;a&&(y.current=a.scrollTop+a.clientHeight>=a.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===p?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:o(t?"chat.subagentEmpty":"common.loading")}):p.map(c=>(0,e.jsx)(j.s,{message:c,cwd:a,sessionId:b},c.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:()=>i});var d=c(48249),e=c(67484),f=c(44384);function g(a){return a.replace(/^\([^)]+\)\s*/,"")}function h(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]}let i=(0,e.forwardRef)(function({displayString:a,documentation:b,x:c,y:i,container:j,onMouseEnter:k,onMouseLeave:l,onFindReferences:m,onSearch:n,onExplain:o,explainDisabled:p},q){let{t:r}=(0,f.Bd)(),s=(0,e.useRef)(null);(0,e.useImperativeHandle)(q,()=>s.current,[]);let t=j.getBoundingClientRect(),u=c-t.left,v=i-t.top,w=(0,e.useMemo)(()=>g(a),[a]),x=(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-11",children:h},g++)):/^\d+$/.test(h)?e.push((0,d.jsx)("span",{className:"text-orange-11",children:h},g++)):c.test(h)?(c.lastIndex=0,e.push((0,d.jsx)("span",{className:"text-violet-11",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})(w),[w]);return(0,e.useEffect)(()=>{if(!s.current)return;let a=s.current,b=j.getBoundingClientRect(),d=a.getBoundingClientRect(),e=c-b.left,f=i-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,i,j]),(0,d.jsxs)("div",{ref:s,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-lv3 px-3 py-2 pointer-events-none",style:{left:u,top:v},children:[(0,d.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:x}),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})]}),(m||n||o)&&(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:k,onMouseLeave:l,children:[m&&(0,d.jsx)("button",{onClick:m,className:"text-[11px] text-brand hover:underline cursor-pointer",children:r("hoverTooltip.findReferences")}),n&&(0,d.jsx)("button",{onClick:()=>n(h(a)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:r("hoverTooltip.search")}),o&&(0,d.jsx)("button",{onClick:()=>o(h(a)),disabled:p,title:p?r("comments.aiResponding"):void 0,className:"text-[11px] text-brand hover:underline cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline",children:r("explain.action")})]})]})]})})},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-hover 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-hover ${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.d(b,{h:()=>l});var d=c(48249),e=c(67484),f=c.n(e),g=c(36043),h=c(7122),i=c(61591);let j={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"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},k=f().memo(function({item:a,isSelected:b,isExpanded:c,isLoading:f,onSelect:g,onToggle:h,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=a,q=o?j[o]:null,r=(0,e.useCallback)(()=>{m.isDirectory?h(m.path):g(m.path)},[m.isDirectory,m.path,g,h]),s=(0,e.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":b&&!m.isDirectory?"text-brand":"text-foreground";return(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-hover ${b?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?f?(0,d.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,d.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,d.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${c?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,d.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,d.jsx)(i.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,d.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,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,d.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function l({files:a,selectedPath:b,expandedPaths:c,matchedPaths:f=null,gitStatusMap:i=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,onExplain:y,explainDisabled:z}){let A=(0,e.useRef)(null),{contextMenu:B,showContextMenu:C,hideContextMenu:D}=(0,h.Ee)(),E=(0,e.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,f,i),[a,c,f,i]),F=(0,g.Te)({count:E.length,getScrollElement:()=>A.current,estimateSize:()=>26,overscan:10});return((0,e.useRef)(q).current=q,0===E.length)?(0,d.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,d.jsxs)("div",{ref:A,className:r||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,d.jsx)("div",{style:{height:`${F.getTotalSize()}px`,width:"100%",position:"relative"},children:F.getVirtualItems().map(a=>{let e=E[a.index];return(0,d.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,d.jsx)(k,{item:e,isSelected:b===e.node.path,isExpanded:c.has(e.node.path),isLoading:j?.has(e.node.path),onSelect:m,onToggle:n,onContextMenu:C,renderActions:s})},e.node.path)})}),B&&(0,d.jsx)(h.ft,{x:B.x,y:B.y,path:B.path,cwd:o,isDirectory:B.isDirectory,onClose:D,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x,onExplain:y,explainDisabled:z})]})}},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")},25414:(a,b,c)=>{"use strict";function d(a,b,c){return b?a?c?`${a.replace(/\n+$/,"")}
16
+ ${b}`;function l({collapsed:a,pinnedSessions:b,sessionNumbers:c,currentCwd:d,onSwitchProject:k,onUnpin:n,onUpdateTitle:o,onReorder:p}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(!1),t=(0,f.useRef)(null),[u,v]=(0,f.useState)(null),[w,x]=(0,f.useState)(""),y=(0,f.useRef)(null),z=(0,j.o$)(),{show:A,hide:B}=z,[C,D]=(0,f.useState)(null),[E,F]=(0,f.useState)(null),[G,H]=(0,f.useState)({}),I=(0,f.useCallback)(a=>{u||(k(a.cwd,a.sessionId),s(!1))},[k,u]),J=(0,f.useCallback)((a,b)=>{b.stopPropagation(),B(),v(a.sessionId),x(a.customTitle||"")},[B]),K=(0,f.useCallback)(()=>{u&&w.trim()&&o(u,w.trim()),v(null)},[u,w,o]),L=(0,f.useCallback)(a=>{B(),D(a)},[B]),M=(0,f.useCallback)((a,b)=>{a.preventDefault(),F(b)},[]),N=(0,f.useCallback)(a=>{if(null===C||C===a){D(null),F(null);return}let c=[...b],[d]=c.splice(C,1);c.splice(a,0,d),p(c),D(null),F(null)},[C,b,p]),O=(0,f.useCallback)(()=>{D(null),F(null)},[]);return(0,e.jsxs)("div",{className:"relative",ref:t,children:[(0,e.jsxs)("button",{onClick:()=>s(!r),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${a?"w-full justify-center":"w-full"}`,title:a?q("sessions.favorites"):void 0,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:"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,e.jsx)("span",{className:"text-sm flex-1 text-left",children:q("sessions.favorites")}),a&&b.length>0&&(0,e.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-popover border border-border",children:b.length})]}),r&&(0,e.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lv2 z-50 flex flex-col",children:[(0,e.jsx)("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:q("sessions.favorites")})}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:q("sessions.noFavorites")}):b.map((a,f)=>{let g=G[m(a.cwd,a.sessionId)],k=u===a.sessionId;return(0,e.jsxs)("div",{draggable:!0,onDragStart:()=>L(f),onDragOver:a=>M(a,f),onDrop:()=>N(f),onDragEnd:O,onClick:()=>I(a),onMouseEnter:b=>{k||A(g??{cwd:a.cwd,sessionId:a.sessionId,title:a.customTitle},b)},onMouseLeave:B,className:`group w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 cursor-pointer ${f!==b.length-1?"border-b border-border/50":""} ${d===a.cwd?"bg-accent/50":""} ${C===f?"opacity-50":""} ${E===f?"border-t-2 border-brand":""}`,children:[(0,e.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,e.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,e.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,e.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(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)(i.S,{engine:g?.engine}),(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:(0,j.Qr)(a.cwd)}),g?.lastActive?(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(0,j.fw)(q,g.lastActive)}):null,(0,e.jsx)(h.l,{coordinate:c?.[m(a.cwd,a.sessionId)],status:(0,h.S)(g?.status),statusLabel:(0,j.Mm)(q,g?.status),bot:g?.bot,className:"ml-auto"})]}),k?(0,e.jsx)("input",{ref:y,type:"text",value:w,onChange:a=>x(a.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||("Enter"===a.key&&K(),"Escape"===a.key&&v(null))},onBlur:K,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,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:a.customTitle||g?.title||a.sessionId.slice(0,8)}),!k&&g?.lastUserMessage&&(0,e.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:g.lastUserMessage})]}),!k&&(0,e.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,e.jsx)("button",{onClick:b=>J(a,b),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:q("sessions.editTitle"),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:"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,e.jsx)("button",{onClick:b=>{b.stopPropagation(),B(),n(a.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:q("sessions.removeFavorite"),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"})})})]})]},a.sessionId)})})]}),(0,e.jsx)(j.LD,{...z})]})}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:var(--highlight)}::highlight(json-search-current){background:var(--highlight-current)}",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,onEngineChange:h,ollamaModel:j,onOllamaModelChange:k,deepseekModel:l,onDeepseekModelChange:m,kimiModel:n,onKimiModelChange:o,glmModel:p,onGlmModelChange:q,claudeModel:r,onClaudeModelChange:s,claudeEffort:t,onClaudeEffortChange:u,claudeFastMode:v,onClaudeFastModeChange:w,claudeThinking:x,onClaudeThinkingChange:y,codexModel:z,onCodexModelChange:A,codexReasoningEffort:B,onCodexReasoningEffortChange:C,planMode:D,onPlanModeChange:E,noHistory:F,onNoHistoryChange:G,outputStyle:H,onOutputStyleChange:I,isActive:J,isFocused:K,peerTabId:L,peerSide:M,refreshSignal:N,onStateChange:O,onShowGitStatus:P,onOpenNote:Q,isFavorite:R,onToggleFavorite:S,onCreateScheduledTask:T,onOpenSession:U,onContentSearch:V,onShowFileDiff:W,onOpenFileLink:X}){let Y=(0,f.useCallback)(b=>{O(a,{isLoading:b})},[a,O]),Z=(0,f.useCallback)(b=>{O(a,{sessionId:b})},[a,O]),$=(0,f.useCallback)(b=>{O(a,{title:b})},[a,O]),_=(0,f.useCallback)(b=>{O(a,{bot:b??void 0})},[a,O]),aa=(0,f.useCallback)(b=>{h?.(a,b)},[a,h]),ab=(0,f.useCallback)(b=>{k?.(a,b)},[a,k]),ac=(0,f.useCallback)(b=>{m?.(a,b)},[a,m]),ad=(0,f.useCallback)(b=>{o?.(a,b)},[a,o]),ae=(0,f.useCallback)(b=>{q?.(a,b)},[a,q]),af=(0,f.useCallback)(b=>{s?.(a,b)},[a,s]),ag=(0,f.useCallback)(b=>{u?.(a,b)},[a,u]),ah=(0,f.useCallback)(b=>{w?.(a,b)},[a,w]),ai=(0,f.useCallback)(b=>{y?.(a,b)},[a,y]),aj=(0,f.useCallback)(b=>{A?.(a,b)},[a,A]),ak=(0,f.useCallback)(b=>{C?.(a,b)},[a,C]),al=(0,f.useCallback)(b=>{E?.(a,b)},[a,E]),am=(0,f.useCallback)(b=>{G?.(a,b)},[a,G]),an=(0,f.useCallback)(b=>{I?.(a,b)},[a,I]),ao=(0,f.useCallback)(()=>{S?.(a)},[a,S]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:aa,ollamaModel:j,onOllamaModelChange:ab,deepseekModel:l,onDeepseekModelChange:ac,kimiModel:n,onKimiModelChange:ad,glmModel:p,onGlmModelChange:ae,claudeModel:r,onClaudeModelChange:af,claudeEffort:t,onClaudeEffortChange:ag,claudeFastMode:v,onClaudeFastModeChange:ah,claudeThinking:x,onClaudeThinkingChange:ai,codexModel:z,onCodexModelChange:aj,codexReasoningEffort:B,onCodexReasoningEffortChange:ak,planMode:D,onPlanModeChange:al,noHistory:F,onNoHistoryChange:am,outputStyle:H,onOutputStyleChange:an,hideHeader:!0,hideSidebar:!0,isActive:J,isFocused:K,peerTabId:L,peerSide:M,refreshSignal:N,onLoadingChange:Y,onSessionIdChange:Z,onTitleChange:$,onBotChange:_,onShowGitStatus:P,onOpenNote:Q,isFavorite:R,onToggleFavorite:c&&S?ao:void 0,onCreateScheduledTask:T,onOpenSession:U,onContentSearch:V,onShowFileDiff:W,onOpenFileLink:X})}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")},19593:(a,b,c)=>{"use strict";c.d(b,{C0:()=>m});var d=c(48249),e=c(67484),f=c(10316),g=c(46674),h=c(72419),i=c(44218),j=c(44384);let k=/^-?[\d,]*\.?\d+%?$/;function l(a){return k.test(a)?parseFloat(a.replace(/,/g,"")):NaN}function m({content:a,filePath:b,className:c="",action:n}){let{t:o}=(0,j.Bd)(),[p,q]=(0,e.useState)(500),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(-1),[v,w]=(0,e.useState)(null),{header:x,body:y,columnCount:z}=(0,e.useMemo)(()=>{let c=(function(a,b){let c=[],d=[],e="",f=!1,g=!1,h=()=>{d.push(e),c.push(d),d=[],e="",g=!1};for(let c=0;c<a.length;c++){let i=a[c];if(f){if('"'!==i){e+=i;continue}'"'===a[c+1]?(e+='"',c++):f=!1;continue}if('"'===i&&""===e){f=!0,g=!0;continue}if(i===b){d.push(e),e="",g=!0;continue}if("\r"===i){"\n"===a[c+1]&&c++,h();continue}if("\n"===i){h();continue}e+=i,g=!0}return(g||""!==e||d.length>0)&&h(),c})(a,function(a,b){if(b&&/\.tsv$/i.test(b))return" ";let c=a.slice(0,65536),d={",":0,";":0," ":0,"|":0},e=!1,f=0;for(let a=0;a<c.length&&f<5;a++){let b=c[a];if('"'===b){e=!e;continue}if(!e){if("\n"===b){f++;continue}b in d&&d[b]++}}let g=Object.entries(d).sort((a,b)=>b[1]-a[1])[0];return g[1]>0?g[0]:","}(a,b)).filter(a=>a.length>1||""!==a[0]),d=c.reduce((a,b)=>Math.max(a,b.length),0),e=c.slice(1).map((a,b)=>({index:b,cells:a}));return{header:c[0]??[],body:e,columnCount:d}},[a,b]),A=(0,e.useMemo)(()=>{let a=r.trim().toLowerCase();return a?y.filter(b=>t>=0?(b.cells[t]??"").toLowerCase().includes(a):b.cells.some(b=>b.toLowerCase().includes(a))):y},[y,r,t]),B=(0,e.useMemo)(()=>{if(!v)return A;let a="asc"===v.dir?1:-1;return[...A].sort((b,c)=>(function(a,b,c){if(""===a||""===b)return a===b?0:""===a?1:-1;let d=l(a),e=l(b);return isNaN(d)||isNaN(e)?a.localeCompare(b,void 0,{numeric:!0})*c:(d-e)*c})(b.cells[v.col]??"",c.cells[v.col]??"",a))},[A,v]),C=(0,e.useCallback)(a=>{w(b=>b&&b.col===a?"asc"===b.dir?{col:a,dir:"desc"}:null:{col:a,dir:"asc"})},[]);if(0===z)return(0,d.jsx)("div",{className:`flex items-center justify-center ${c}`,children:(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:o("csv.empty")})});let D=B.slice(0,p);return(0,d.jsxs)("div",{className:`flex flex-col min-h-0 ${c}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-0.5 rounded border border-border bg-card focus-within:border-brand transition-colors",children:[(0,d.jsx)(f.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0","aria-hidden":!0}),(0,d.jsx)("input",{value:r,onChange:a=>s(a.target.value),placeholder:o("csv.filterPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs text-foreground placeholder:text-muted-foreground outline-none"}),r&&(0,d.jsx)("button",{onClick:()=>s(""),className:"text-muted-foreground hover:text-foreground flex-shrink-0",title:o("csv.clearFilter"),children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("select",{value:t,onChange:a=>u(Number(a.target.value)),className:"text-xs bg-card text-muted-foreground border border-border rounded px-1 py-1 max-w-[10rem] flex-shrink-0",title:o("csv.filterColumn"),children:[(0,d.jsx)("option",{value:-1,children:o("csv.allColumns")}),Array.from({length:z},(a,b)=>(0,d.jsx)("option",{value:b,children:x[b]||`#${b+1}`},b))]}),n&&(0,d.jsx)("button",{onClick:n.onClick,className:"text-xs px-2 py-1 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:n.label})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,d.jsxs)("table",{className:"text-xs border-collapse w-max min-w-full",children:[(0,d.jsx)("thead",{className:"sticky top-0 z-10",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"sticky left-0 z-20 bg-accent border-b border-r border-border px-2 py-1.5 text-right font-normal text-muted-foreground select-none",children:"#"}),Array.from({length:z},(a,b)=>(0,d.jsx)("th",{onClick:()=>C(b),className:"bg-accent border-b border-border px-2 py-1.5 text-left font-medium text-foreground whitespace-nowrap cursor-pointer select-none hover:bg-hover",title:o("csv.sortHint"),children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[x[b]??"",v?.col===b&&("asc"===v.dir?(0,d.jsx)(h.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}):(0,d.jsx)(i.A,{className:"w-3 h-3 text-brand","aria-hidden":!0}))]})},b))]})}),(0,d.jsx)("tbody",{children:D.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-hover",children:[(0,d.jsx)("td",{className:"sticky left-0 bg-card border-b border-r border-border px-2 py-1 text-right text-muted-foreground tabular-nums select-none",children:a.index+1}),Array.from({length:z},(b,c)=>{let e=a.cells[c]??"";return(0,d.jsx)("td",{title:e.length>60?e:void 0,className:`border-b border-border px-2 py-1 max-w-[28rem] truncate text-foreground ${k.test(e)?"text-right tabular-nums":""}`,children:e},c)})]},a.index))})]}),0===D.length&&(0,d.jsx)("div",{className:"p-4 text-xs text-muted-foreground",children:o("csv.noMatch")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:[(0,d.jsx)("span",{children:A.length===y.length?o("csv.summary",{rows:y.length,cols:z}):o("csv.summaryFiltered",{rows:A.length,total:y.length,cols:z})}),D.length<B.length&&(0,d.jsx)("button",{onClick:()=>q(a=>a+500),className:"px-1.5 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:o("csv.loadMore",{shown:D.length,total:B.length})})]})]})}},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.$mh({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.YWq({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})},[])}}},20580:(a,b,c)=>{"use strict";c.d(b,{a:()=>e});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1);return b}c(33281),c(91579),c(89800)},20586:(a,b,c)=>{"use strict";c.d(b,{Do:()=>o,Sz:()=>p,VO:()=>n,wI:()=>q});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(61591),i=c(8410),j=c(7122),k=c(7093);function l({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,d.jsx)("span",{className:`text-xs font-bold ${c}`,children:b})}let m=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:j,onToggle:m,onContextMenu:n,showChanges:o=!1,showChangeClass:p=!1,hideIndicatorsOnHover:q=!1,renderActions:r}){let s,t=f===b.path,u=g.has(b.path),v=(0,e.useCallback)(()=>{b.isDirectory?m(b.path):j(b)},[b,j,m]),w=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),n(a,b.path,b.isDirectory)},[b.path,b.isDirectory,n]);return b.isDirectory?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-hover cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*c+8}px`},onClick:v,onContextMenu:w,children:[(0,d.jsx)("span",{className:"text-foreground-subtle text-xs",children:u?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),r&&r(b)]}),u&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:j,onToggle:m,onContextMenu:n,showChanges:o,showChangeClass:p,hideIndicatorsOnHover:q,renderActions:r},b.path))]}):(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${t?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*c+8}px`},onClick:v,onContextMenu:w,children:[(0,d.jsx)(h.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${t?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),p&&((s=(0,k.q)(b.path))?(0,d.jsx)("span",{className:q?"group-hover:hidden":void 0,children:(0,d.jsx)(i.N,{cls:s})}):null),r&&r(b),b.status&&(0,d.jsx)("span",{className:q?"group-hover:hidden":void 0,children:(0,d.jsx)(l,{status:b.status})}),o&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)("span",{className:`contents ${q?"group-hover:hidden":""}`,children:[(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["+",b.additions]}),(0,d.jsxs)("span",{className:"text-xs text-red-11",children:["-",b.deletions]})]})]})});function n({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:h,showChanges:i=!1,showChangeClass:k=!1,hideIndicatorsOnHover:l=!1,renderActions:o,emptyMessage:p,className:q,onExplain:r,explainDisabled:s}){let{t}=(0,g.Bd)(),u=p??t("gitFileTree.noFiles"),{contextMenu:v,showContextMenu:w,hideContextMenu:x}=(0,j.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:u}):(0,d.jsxs)("div",{className:q||"py-1",children:[a.map(a=>(0,d.jsx)(m,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:w,showChanges:i,showChangeClass:k,hideIndicatorsOnHover:l,renderActions:o},a.path)),v&&(0,d.jsx)(j.ft,{x:v.x,y:v.y,path:v.path,cwd:h,isDirectory:v.isDirectory,onClose:x,onExplain:r,explainDisabled:s})]})}function o(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 p(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function q(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},21482:(a,b,c)=>{"use strict";c.d(b,{D:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(46674);function h({results:a,loading:b,totalMatches:c,onSelect:i,onClose:j,scope:k,onScopeChange:l,selectedPath:m}){let{t:n}=(0,f.Bd)(),o=function(){let[a,b]=(0,e.useState)(new Map),[c,d]=(0,e.useState)(!1);return(0,e.useRef)(0),a}(),p="selected"===k?a.filter(a=>a.path===m):a,q=p.reduce((a,b)=>a+b.matches.length,0);return(0,d.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,d.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,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsxs)("span",{className:"text-xs font-medium text-foreground truncate",children:[n("searchResults.title")," ",!b&&n("searchResults.nMatches",{count:"selected"===k?q:c})]}),(0,d.jsxs)("div",{className:"flex items-center rounded border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,d.jsx)("button",{onClick:()=>l("selected"),className:`px-2 py-0.5 ${"selected"===k?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:n("searchResults.scopeSelected")}),(0,d.jsx)("button",{onClick:()=>l("all"),className:`px-2 py-0.5 border-l border-border ${"all"===k?"bg-brand/15 text-brand":"text-muted-foreground hover:bg-hover"}`,children:n("searchResults.scopeAll")})]})]}),(0,d.jsx)("button",{onClick:j,className:"p-0.5 rounded hover:bg-hover text-muted-foreground flex-shrink-0",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.searching")}):0===p.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:n("searchResults.noResults")}):p.map(a=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:a.path}),a.matches.map((b,c)=>{let e=`${a.path}:${b.lineNumber}`,f=o.get(e);return(0,d.jsxs)("button",{onClick:()=>i(a.path,b.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:b.lineNumber}),f?(0,d.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:f}}):(0,d.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:b.content||""})]},`${b.lineNumber}-${c}`)})]},a.path))})]})}c(36984)},21538:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>x});var e=c(48249),f=c(67484),g=c(44384),h=c(35208),i=c(39238),j=c(73887),k=c(74691),l=c(60333),m=c(20586),n=c(46242),o=c(21787),p=c(9804),q=c(33281),r=c(85655),s=c(60591),t=c(69606),u=c(18921),v=c(7031);c(57063);var w=a([h,i,j]);function x({isOpen:a,onClose:b,commit:c,cwd:d,embedded:w=!1,initialFilePath:y,onContentSearch:z,onLocateInTree:A}){let{t:B}=(0,g.Bd)(),[C,D]=(0,f.useState)([]),[E,F]=(0,f.useState)([]),[G,H]=(0,f.useState)(new Set),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)(null),[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)(!1),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)(null),[U,V]=(0,f.useState)(null),W=(0,f.useCallback)(()=>V(null),[]),X=(0,f.useCallback)(()=>R(null),[]),[Y,Z]=(0,f.useState)("compact"),[$,_]=(0,f.useState)("unified"),aa=(0,f.useRef)(null),ab=(0,u.o)(aa),ac=(0,v.r)(),ad=c?.shortHash,ae=(0,f.useCallback)(a=>{ad&&ac?.sendMessage(B("explain.commitFileMessage",{hash:ad,path:a}))},[ac,B,ad]),af=(0,f.useCallback)(a=>{c&&(J(a),P(!0),q.t4.runPromiseExit((0,r.Zi)(d,c.hash,a.path)).then(a=>{"Success"===a._tag?L(a.value):console.error(a.cause),P(!1)}))},[d,c]),ag=(0,f.useCallback)(a=>{H(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ah=(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]),ai=K?.filePath,aj=(0,f.useMemo)(()=>ai?(0,e.jsx)(o.d,{cwd:d,filePath:ai,onLocateInTree:A}):null,[d,ai,A]);if(!a||!c)return null;let ak=!!K&&(!0===K.isImage||(0,p.u)(K.filePath)),al=(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 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-foreground-subtle",children:B("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-foreground-subtle",children:B("commitDetail.author")}),(0,e.jsx)("span",{children:c.author}),(0,e.jsxs)("span",{className:"text-foreground-subtle",children:["<",c.authorEmail,">"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:B("commitDetail.date")}),(0,e.jsx)("span",{children:ah}),c.relativeDate&&(0,e.jsxs)("span",{className:"text-foreground-subtle",children:["(",c.relativeDate,")"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("span",{className:"text-foreground-subtle",children:B("commitDetail.files")}),(0,e.jsx)("span",{children:B("commitDetail.nChanges",{count:C.length})})]}),!ak&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(k.y,{value:Y,onChange:Z}),(0,e.jsx)(l.q,{value:$,onChange:_})]})]})]}),(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:M?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:B("commitDetail.loadingFiles")}):(0,e.jsx)(m.VO,{files:E,selectedPath:I?.path||null,expandedPaths:G,onSelect:a=>a.file&&af(a.file),onToggle:ag,cwd:d,showChanges:!0,showChangeClass:!0,emptyMessage:B("commitDetail.noFileChanges"),className:"py-1",onExplain:ac&&ad?ae:void 0,explainDisabled:ac?.isLoading})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:O?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:B("commitDetail.loadingDiff")}):K?ak?(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:aj}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(n.M,{cwd:d,filePath:K.filePath,oldRev:K.oldRev??(K.isNew?null:`${c.hash}^1`),newRev:K.newRev??(K.isDeleted?null:c.hash)})})]}):"unified"===$?(0,e.jsx)(h.xU,{oldContent:K.oldContent,newContent:K.newContent,filePath:K.filePath,cwd:d,enableComments:!0,compact:"compact"===Y,headerLeading:aj,onPreview:K.isDeleted?void 0:(0,s.aR)(K.filePath)?()=>T({content:K.newContent,filePath:K.filePath}):(0,s.e$)(K.filePath)?()=>V({content:K.newContent,filePath:K.filePath}):K.filePath.endsWith(".json")?()=>R({content:K.newContent,filePath:K.filePath}):void 0,previewLabel:K.filePath.endsWith(".json")?B("common.readable"):B("common.preview"),onContentSearch:z}):(0,e.jsx)(h.xZ,{oldContent:K.oldContent,newContent:K.newContent,filePath:K.filePath,isNew:K.isNew,isDeleted:K.isDeleted,cwd:d,enableComments:!0,compact:"compact"===Y,headerLeading:aj,onPreview:K.isDeleted?void 0:(0,s.aR)(K.filePath)?()=>T({content:K.newContent,filePath:K.filePath}):(0,s.e$)(K.filePath)?()=>V({content:K.newContent,filePath:K.filePath}):K.filePath.endsWith(".json")?()=>R({content:K.newContent,filePath:K.filePath}):void 0,previewLabel:K.filePath.endsWith(".json")?B("common.readable"):B("common.preview"),onContentSearch:z}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:B("commitDetail.selectFileToView")})})]})]}),am=Q&&(0,e.jsx)(t.A,{preview:Q,onClose:X,search:ab,preRef:aa}),an=S&&(0,e.jsx)(i.N,{filePath:S.filePath,content:S.content,cwd:d,onClose:()=>T(null)}),ao=U&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:W,children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(j.M,{content:U.content,filePath:U.filePath,cwd:d,onClose:W})})});return w?(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-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:B("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),al,am,an,ao]}):(0,e.jsx)("div",{className:"fixed inset-0 z-[60] bg-scrim",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:B("commitDetail.title")}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover 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"})})})]}),al,am,an,ao]})})}[h,i,j]=w.then?(await w)():w,d()}catch(a){d(a)}})},21672:(a,b,c)=>{"use strict";c.d(b,{D:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(46674);function h({references:a,loading:b,onSelect:c,onClose:i}){let{t:j}=(0,f.Bd)(),k=function(){let[a,b]=(0,e.useState)(new Map),[c,d]=(0,e.useState)(!1);return(0,e.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,d.jsxs)("div",{className:"border-t border-border bg-card flex flex-col",style:{height:"300px"},children:[(0,d.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,d.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[j("references.title")," ",!b&&`(${a.length})`]}),(0,d.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:b?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("references.searching")}):0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:j("references.notFound")}):l.map(({file:a,items:b})=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card sticky top-0",children:a}),b.map(({ref:a,idx:b})=>(0,d.jsxs)("button",{onClick:()=>c(a),className:"w-full text-left px-3 py-0.5 hover:bg-hover flex items-baseline gap-2 group",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:a.line}),k.has(b)?(0,d.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:k.get(b)}}):(0,d.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:a.lineText||""})]},`${a.line}-${a.column}-${b}`))]},a))})]})}c(36984)},21787:(a,b,c)=>{"use strict";c.d(b,{d:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(72529),h=c(7833);let i=(0,e.memo)(function({cwd:a,filePath:b,onLocateInTree:c}){let{t:e}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground truncate",title:b,children:b}),(0,d.jsx)(g.m,{content:e("common.copyAbsPath"),children:(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(e("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 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"})})})}),c&&(0,d.jsx)(g.m,{content:e("fileBrowser.locateInTree"),children:(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),c(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})})]})})},23328:(a,b,c)=>{"use strict";c.d(b,{AJ:()=>r,Cb:()=>D,D0:()=>z,D5:()=>E,DN:()=>m,Jn:()=>k,MR:()=>n,Ok:()=>w,QF:()=>j,SN:()=>s,UV:()=>C,Vv:()=>u,Yj:()=>B,Yn:()=>A,bv:()=>t,cm:()=>o,cv:()=>v,jO:()=>x,px:()=>F,tp:()=>y,uc:()=>q,y8:()=>p});var d=c(79606),e=c(71192);let f=a=>d.$mh({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.$mh({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.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),j=(a,b)=>d.JkU(function*(){let c=new URLSearchParams({cwd:a});b&&c.set("tabId",b);let d=yield*f(`/api/terminal/env?${c}`);return{env:d.env||{},home:d.home||""}}),k=()=>f("/api/terminal/aliases").pipe(d.TjK(a=>a.aliases||{})),l=(a,b)=>`/api/terminal/bubble-order?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}`,m=(a,b)=>f(l(a,b)).pipe(d.TjK(a=>a.order||[])),n=(a,b)=>f(l(a,b)).pipe(d.TjK(a=>a.titles||{})),o=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,order:c,sourceId:d}),p=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,titles:{[c]:d}}),q=(a,b,c,d=100)=>f(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&page=${c}&pageSize=${d}`),r=(a,b,c,d)=>h("/api/terminal/history",{cwd:a,tabId:b,entry:c,sourceId:d}),s=(a,b,c,d)=>g(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&commandId=${encodeURIComponent(c)}${d?`&sourceId=${encodeURIComponent(d)}`:""}`,{method:"DELETE"}),t=(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})}),u=a=>h("/api/terminal/env",a),v=a=>h("/api/terminal/aliases",{aliases:a}),w=a=>h("/api/terminal/register",a),x=a=>h("/api/terminal/unregister",a),y=a=>d.$mh({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})}),z=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),A=a=>h("/api/project-settings",a),B=()=>f("/api/services/config?scope=global"),C=a=>f(`/api/services/config?cwd=${encodeURIComponent(a)}`),D=a=>i("/api/services/config",a),E=()=>f("/api/terminal/running"),F=a=>i("/api/terminal/running",{commandId:a})},23389:(a,b,c)=>{"use strict";function d(a){return/^~(?=$|[/\\])/.test(a.trim())}function e(a,b){return b&&d(a)?b.replace(/[/\\]+$/,"")+a.trim().slice(1):a}c.d(b,{D:()=>e,P:()=>d})},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(81206),l=a([j]);function m({cwd:a,sessionId:b,toolCall:c,workflowRef:d,running:l,onClose:n}){let{t:o}=(0,g.Bd)(),[p,q]=(0,f.useState)(null),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),v=(0,f.useRef)(void 0),w=d?!!d.running:l??!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:v.current}));if(u(!0),"Success"!==e._tag||!e.value)return;let f=e.value;f.fingerprint&&(v.current=f.fingerprint),!f.notModified&&(f.messages&&q(f.messages),f.subagent&&s(f.subagent))},[a,b,c?.id,d?.runId,d?.agentId]);let x=(0,f.useRef)(null),y=(0,f.useRef)(!0),z="string"==typeof c?.input?.description?c.input.description:"",A=d?d.label||"":[r?.agentType,z].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-scrim p-4",onClick:a=>{a.stopPropagation(),n()},children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 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:o("chat.subagent")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[w&&(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:n,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:o("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:x,onScroll:()=>{let a=x.current;a&&(y.current=a.scrollTop+a.clientHeight>=a.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===p?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:o(t?"chat.subagentEmpty":"common.loading")}):p.map(c=>(0,e.jsx)(j.s,{message:c,cwd:a,sessionId:b},c.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:()=>i});var d=c(48249),e=c(67484),f=c(44384);function g(a){return a.replace(/^\([^)]+\)\s*/,"")}function h(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]}let i=(0,e.forwardRef)(function({displayString:a,documentation:b,x:c,y:i,container:j,onMouseEnter:k,onMouseLeave:l,onFindReferences:m,onSearch:n,onExplain:o,explainDisabled:p},q){let{t:r}=(0,f.Bd)(),s=(0,e.useRef)(null);(0,e.useImperativeHandle)(q,()=>s.current,[]);let t=j.getBoundingClientRect(),u=c-t.left,v=i-t.top,w=(0,e.useMemo)(()=>g(a),[a]),x=(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-11",children:h},g++)):/^\d+$/.test(h)?e.push((0,d.jsx)("span",{className:"text-orange-11",children:h},g++)):c.test(h)?(c.lastIndex=0,e.push((0,d.jsx)("span",{className:"text-violet-11",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})(w),[w]);return(0,e.useEffect)(()=>{if(!s.current)return;let a=s.current,b=j.getBoundingClientRect(),d=a.getBoundingClientRect(),e=c-b.left,f=i-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,i,j]),(0,d.jsxs)("div",{ref:s,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-lv3 px-3 py-2 pointer-events-none",style:{left:u,top:v},children:[(0,d.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:x}),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})]}),(m||n||o)&&(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:k,onMouseLeave:l,children:[m&&(0,d.jsx)("button",{onClick:m,className:"text-[11px] text-brand hover:underline cursor-pointer",children:r("hoverTooltip.findReferences")}),n&&(0,d.jsx)("button",{onClick:()=>n(h(a)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:r("hoverTooltip.search")}),o&&(0,d.jsx)("button",{onClick:()=>o(h(a)),disabled:p,title:p?r("comments.aiResponding"):void 0,className:"text-[11px] text-brand hover:underline cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline",children:r("explain.action")})]})]})]})})},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-hover 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-hover ${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.d(b,{h:()=>l});var d=c(48249),e=c(67484),f=c.n(e),g=c(36043),h=c(7122),i=c(61591);let j={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"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},k=f().memo(function({item:a,isSelected:b,isExpanded:c,isLoading:f,onSelect:g,onToggle:h,onContextMenu:k,renderActions:l}){let{node:m,level:n,gitStatus:o,hasChangedChildren:p}=a,q=o?j[o]:null,r=(0,e.useCallback)(()=>{m.isDirectory?h(m.path):g(m.path)},[m.isDirectory,m.path,g,h]),s=(0,e.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":b&&!m.isDirectory?"text-brand":"text-foreground";return(0,d.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-hover ${b?"bg-brand/10":""}`,style:{paddingLeft:`${12*n+8}px`},onClick:r,onContextMenu:s,children:[m.isDirectory?f?(0,d.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,d.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,d.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${c?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,d.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,d.jsx)(i.o,{name:m.name,size:16,className:"flex-shrink-0 ml-4"}),(0,d.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,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),o&&(0,d.jsx)("span",{className:`text-xs font-mono px-1 rounded ${q.text} ${q.bg} flex-shrink-0`,children:o}),m.isDirectory&&p&&(0,d.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),l?.(m)]})});function l({files:a,selectedPath:b,expandedPaths:c,matchedPaths:f=null,gitStatusMap:i=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,onExplain:y,explainDisabled:z}){let A=(0,e.useRef)(null),{contextMenu:B,showContextMenu:C,hideContextMenu:D}=(0,h.Ee)(),E=(0,e.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,f,i),[a,c,f,i]),F=(0,g.Te)({count:E.length,getScrollElement:()=>A.current,estimateSize:()=>26,overscan:10});return((0,e.useRef)(q).current=q,0===E.length)?(0,d.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,d.jsxs)("div",{ref:A,className:r||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,d.jsx)("div",{style:{height:`${F.getTotalSize()}px`,width:"100%",position:"relative"},children:F.getVirtualItems().map(a=>{let e=E[a.index];return(0,d.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${a.size}px`,transform:`translateY(${a.start}px)`},children:(0,d.jsx)(k,{item:e,isSelected:b===e.node.path,isExpanded:c.has(e.node.path),isLoading:j?.has(e.node.path),onSelect:m,onToggle:n,onContextMenu:C,renderActions:s})},e.node.path)})}),B&&(0,d.jsx)(h.ft,{x:B.x,y:B.y,path:B.path,cwd:o,isDirectory:B.isDirectory,onClose:D,onCreateFile:t,onDelete:u,onRefresh:v,onCopyFile:w,onPaste:x,onExplain:y,explainDisabled:z})]})}},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")},25414:(a,b,c)=>{"use strict";function d(a,b,c){return b?a?c?`${a.replace(/\n+$/,"")}
17
17
 
18
18
  ${b}`:a+b:b:a}function e(a,b,c=!1){let d=a||[];if(!b)return d;let f=d[d.length-1];return c||f?.type!=="text"?[...d,{type:"text",text:b}]:[...d.slice(0,-1),{type:"text",text:f.text+b}]}function f(a){return null!=a.parent_tool_use_id}c.d(b,{FM:()=>k,Nn:()=>f,A7:()=>h,Uy:()=>i,fD:()=>j});let g=["task_started","task_progress","task_notification"];function h(a){return"system"===a.type&&g.includes(a.subtype??"")}function i(a,b){let c={status:"running",...a};return"task_notification"===b.subtype&&(c.status=b.status??"completed"),b.task_id&&(c.id=b.task_id),b.last_tool_name&&(c.lastToolName=b.last_tool_name),b.summary&&(c.summary=b.summary),"number"==typeof b.usage?.tool_uses&&(c.toolUses=b.usage.tool_uses),"number"==typeof b.usage?.duration_ms&&(c.durationMs=b.usage.duration_ms),c}function j(a){let b=!1,c=a.map(a=>a.toolCalls?.some(a=>a.task?.status==="running")?(b=!0,{...a,toolCalls:a.toolCalls.map(a=>a.task?.status==="running"?{...a,task:{...a.task,status:"unknown"}}:a)}):a);return b?c:a}function k(a,b,c){let{engine:g,assistantId:j}=c;if(f(b))return a;if(h(b)){let c=b.tool_use_id;if(!c||b.ambient)return a;let d=!1,e=a.map(a=>a.toolCalls?.some(a=>a.id===c)?(d=!0,{...a,toolCalls:a.toolCalls.map(a=>a.id===c?{...a,task:i(a.task,b)}:a)}):a);return d?e:a}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===j?{...a,content:d(a.content||"",b,!!a.pendingTextBreak),parts:e(a.parts,b,!!a.pendingTextBreak),pendingTextBreak:!1}:a)}return a}if("assistant"===b.type){let c=b.message?.content;if(!Array.isArray(c))return a;let f=a,h=b.message?.model==="<synthetic>";if("codex"===g||"ollama"===g||h){let a=c.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("");a&&(f=f.map(b=>b.id===j?{...b,content:d(b.content||"",a,!!b.pendingTextBreak),parts:e(b.parts,a,!!b.pendingTextBreak),pendingTextBreak:!1}:b))}for(let a of c)if(a.name){let b={id:a.id||`tool-${j}-${a.name}`,name:a.name,input:a.input||{},isLoading:!0};f=f.map(a=>a.id!==j||a.toolCalls?.some(a=>a.id===b.id)?a:{...a,toolCalls:[...a.toolCalls||[],b],parts:function(a,b){let c=a||[];return c.some(a=>"tool"===a.type&&a.id===b)?c:[...c,{type:"tool",id:b}]}(a.parts,b.id),pendingTextBreak:!0})}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===j?{...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.",f=`⚠️ ${c}`;return a.map(a=>a.id===j?{...a,content:d(a.content||"",f,!0),parts:e(a.parts,f,!0),isStreaming:!1}:a)}if("result"===b.type){let c="string"==typeof b.result?b.result.trim():"";return a.map(a=>a.id===j?{...a,content:!a.content&&c?c:a.content,parts:!a.content&&c?e(a.parts,c):a.parts,isStreaming:!1,toolCalls:a.toolCalls?.map(a=>({...a,isLoading:!1}))}:a)}return a}},25419:(a,b,c)=>{"use strict";c.d(b,{K:()=>f});var d=c(79606),e=c(71192);let f=(a,b)=>{let c,f;return c=`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,f={cache:"no-store"},d.$mh({try:async()=>{let a=await fetch(c,f),b=null;try{b=await a.json()}catch{}return{status:a.status,ok:a.ok,data:b}},catch:a=>new e.uV({message:`GET ${c} failed`,cause:a})})}},25608:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{ProjectItem:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(41233),j=c(40311),k=c(29939),l=c(82338),m=c(85655);function n({badge:a,onSelect:b}){return(0,e.jsx)("button",{type:"button",onClick:c=>{c.stopPropagation(),b(a.sessionId)},className:"flex flex-shrink-0 items-center justify-center rounded-full transition-transform hover:scale-125",title:a.bot?`@${a.bot}`:a.label,children:(0,e.jsx)(i.w,{wash:(0,j.JQ)(a.status,!1),ring:(0,j.QV)(a.status),bot:a.bot,children:a.label})})}let a=[],p=()=>{};function o({index:b,name:c,cwd:d,isActive:i,collapsed:j,hasUnread:q,isLoading:r,sessionBadges:s,onClick:t,onSelectSession:u,onRemove:v,onOpenNote:w}){let{t:x}=(0,g.Bd)(),[y,z]=(0,f.useState)(!1),[A,B]=(0,f.useState)(null),C=(0,f.useCallback)(()=>{h.t4.runPromiseExit((0,m.ue)(d)).then(a=>{"Success"===a._tag&&B(a.value.branch)})},[d]),D=(0,f.useCallback)(a=>{a?.type==="watch"&&Array.isArray(a.data)&&a.data.some(a=>"git"===a.type)&&C()},[C]);(0,k.h)({url:`/ws/watch?cwd=${encodeURIComponent(d)}`,onMessage:D});let E=s??a,F=A?j?`${c} \xb7 ${A}`:A:d;return(0,e.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${j?"justify-center":""} ${i?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:t,onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),"data-tooltip":F,children:[(0,e.jsx)(l.B,{number:b+1,status:j?r?"loading":q&&!i?"unread":"normal":"normal",isActive:i}),!j&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:`flex-1 truncate text-sm ${i?"text-brand":""}`,children:c}),y&&(0,e.jsxs)("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[w&&(0,e.jsx)("button",{className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),w()},title:x("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-11 transition-colors",onClick:a=>{a.stopPropagation(),v()},title:x("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"})})})]}),E.length>0&&(0,e.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0",children:E.map(a=>(0,e.jsx)(n,{badge:a,onSelect:u??p},a.sessionId))})]})]})}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(72899);c(33281),c(85655);var h=c(17966),i=a([h]);function j({cwd:a,filePath:b,oldContent:c,newContent:d,isNew:h=!1,isDeleted:i=!1,changedFiles:k,fileGitStatusMap:l,enableComments:m=!1,compact:n=!0,onContentSearch:o,onSwitchToCode:p,headerExtraLeft:q,headerExtraRight:r}){let[s,t]=(0,f.useState)(b),[u,v]=(0,f.useState)(null);return(0,e.jsx)(g.O,{cwd:a,highlightedFilePath:b,changedFiles:k,enableComments:m,qnameFilter:n?u?.changedQnames:void 0,qnameFilterFile:s,accentQnames:u?.changedQnames,accentFile:s,addedLines:u?.addedLines,addedLinesFile:s,compact:n,onFocalChange:a=>a&&t(a),onContentSearch:o,onSwitchToCode:p,headerExtraLeft:q,headerExtraRight:r})}h=(i.then?(await i)():i)[0],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")},26362:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{T:()=>q});var e=c(48249),f=c(67484),g=c(74429),h=c(74754),i=c(91579),j=c(208),k=c(7122),l=c(7031),m=c(41051),n=c(42140),o=c(70596),p=c(37690);function q({cwd:a,enableComments:b=!1,filePath:c,diffLines:d,containerEl:r,onContentSearch:s}){let t=(0,k.iN)(),u=(0,l.r)(),v=b&&!!a,{comments:w,addComment:x,updateComment:y,deleteComment:z,refresh:A}=(0,h._)({cwd:a||"",filePath:c}),[B,C]=(0,f.useState)(null),{toolbarRef:D,bumpRef:E,clearToolbar:F}=(0,p.L)({enabled:v,container:r,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=[],e=0;for(let f of d)("unchanged"===f.type||"added"===f.type)&&++e>=a&&e<=b&&c.push(f.content);return c.join("\n")}}),[G,H]=(0,f.useState)(null),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)(!1),M=(0,f.useMemo)(()=>{let a=new Set;for(let b of w)for(let c=b.startLine;c<=b.endLine;c++)a.add(c);return a},[w]),N=(0,f.useMemo)(()=>{let a=new Map;for(let b of w){let c=b.endLine;a.has(c)||a.set(c,[]),a.get(c).push(b)}return a},[w]),O=(0,f.useCallback)((a,b)=>{b.stopPropagation(),C({comment:a,x:b.clientX,y:b.clientY}),F(),H(null),J(null)},[F]),P=(0,f.useCallback)(()=>{let a=D.current;a&&(H({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),F())},[F,D]),Q=(0,f.useCallback)(()=>{let a=D.current;a&&(J({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),F())},[F,D]),R=(0,f.useCallback)(()=>{let a=D.current;a&&u&&(F(),(0,i.Ff)(u.sendMessage,{filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},j.A.t("explain.selectionMessage")))},[u,c,F,D]),S=(0,f.useCallback)(()=>{let a=D.current;if(!a||!s)return;let b=a.selectedText.trim();F(),b&&s(b)},[s,F,D]),T=(0,f.useCallback)(async(b,d)=>{if(u&&a)try{let e=await (0,i.$3)(a),f=[];for(let a of e)f.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});f.push({filePath:c,startLine:b.range.start,endLine:b.range.end,codeContent:b.lineSnapshot});let g=(0,i.Gw)(f,d);u.sendMessage(g),await (0,i.RP)(a),A()}catch(a){console.error("Failed to send to AI:",a)}},[u,c,a,A]),U=(0,f.useCallback)(a=>{I&&T(I,a)},[I,T]),V=(0,f.useCallback)(a=>{G&&T(G,a)},[G,T]),W=(0,f.useCallback)(async a=>{G&&(await x(G.range.start,G.range.end,a,G.selectedText),H(null))},[G,x]),X=K&&t?(0,g.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.fS,{floatingToolbarRef:D,bumpRef:E,container:t,onAddComment:P,onSendToAI:Q,onSearch:s?S:void 0,onExplain:u?R:void 0,isChatLoading:u?.isLoading??!1}),G&&(0,e.jsx)(n.t,{x:G.x,y:G.y,range:G.range,filePath:c,lineSnapshot:G.lineSnapshot,container:t,onSubmit:W,onSendToAI:u?V:void 0,onClose:()=>H(null),isChatLoading:u?.isLoading}),I&&(0,e.jsx)(n.G,{x:I.x,y:I.y,range:I.range,filePath:c,lineSnapshot:I.lineSnapshot,container:t,onSubmit:U,onClose:()=>J(null),isChatLoading:u?.isLoading}),B&&(0,e.jsx)(o.t,{x:B.x,y:B.y,comment:B.comment,container:t,onClose:()=>C(null),onUpdateComment:y,onDeleteComment:z})]}),t):null;return{commentsEnabled:v,linesWithComments:M,commentsByEndLine:N,handleCommentBubbleClick:O,addCommentRange:G?.range??null,sendToAIRange:I?.range??null,commentPortal:X}}d()}catch(a){d(a)}})},27668:(a,b,c)=>{"use strict";c.d(b,{B2:()=>g,oh:()=>h,zi:()=>f});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a=await c.json().catch(()=>null);throw Error(a?.error||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>{if(a&&"object"==typeof a&&"_tag"in a&&"Fail"===a._tag&&"error"in a){let b=a.error?.cause;if(b instanceof Error)return b.message}return b}},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:()=>p});var e=c(48249),f=c(67484),g=c(44384),h=c(37370),i=c(7833),j=c(15819),k=c(77156),l=c(59336),m=c(2633),n=c(33281),o=a([m]);function p({isOpen:a,onClose:b}){let{t:c,i18n:d}=(0,g.Bd)(),[h,o]=(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)(""),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(null),D=(0,f.useRef)(null),E=(0,f.useCallback)(async()=>{s(!0);let a=await n.t4.runPromiseExit((0,k.Hy)());"Success"===a._tag?o(a.value):console.error("Failed to load skills",a.cause),s(!1)},[]),F=(0,f.useMemo)(()=>{let a=t.trim().toLowerCase();return a?h.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):h},[h,t]),G=d.resolvedLanguage?.startsWith("zh")?"https://opencockpit.dev/zh/docs/agent/skills/":"https://opencockpit.dev/en/docs/agent/skills/",H=(0,f.useCallback)(async()=>{let a=x.trim();if(!a)return;A(!0);let b=await n.t4.runPromiseExit((0,k.L5)(a));if("Success"===b._tag)(0,i.oR)(b.value.alreadyExists?c("skills.alreadyAdded"):c("skills.added"),b.value.alreadyExists?"info":"success"),y(""),w(!1),await E(),b.value.alreadyExists||(0,l.k)();else{let a="Fail"===b.cause._tag?b.cause.error:null,d=a?.cause,e=d instanceof Error?d.message:c("skills.addFailed");(0,i.oR)(e,"error")}A(!1)},[x,E,c]),I=(0,f.useCallback)(async a=>{let b=await n.t4.runPromiseExit((0,k.hp)(a));"Success"===b._tag?(o(b=>b.filter(b=>b.id!==a)),(0,l.k)()):(0,i.oR)(c("common.deleteFailed"),"error")},[c]),J=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,i.oR)(c("common.copiedPath"),"success")}catch{(0,i.oR)(c("common.copyFailed"),"error")}},[c]);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-scrim",onClick:b}),(0,e.jsxs)("div",{className:j.aO,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:c("skills.title")}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("input",{ref:D,type:"text",value:t,onChange:a=>u(a.target.value),placeholder:c("skills.searchPlaceholder"),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),t&&(0,e.jsx)("button",{onClick:()=>{u(""),D.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:c("skills.clearSearch"),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)("button",{onClick:()=>w(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover 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:"M12 4v16m8-8H4"})}),c("skills.addSkill")]}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:c("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:r?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:c("common.loading")}):0===F.length?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm space-y-2",children:0===h.length?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{children:c("skills.emptyNoSkills")}),(0,e.jsxs)("p",{children:[c("skills.emptyIntroPrefix")," ",(0,e.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/skillify"})," ",c("skills.emptyIntroSuffix")]}),(0,e.jsxs)("p",{children:[(0,e.jsx)("button",{type:"button",onClick:()=>w(!0),className:"text-brand hover:underline",children:c("skills.addSkill")})," \xb7 ",(0,e.jsx)("a",{href:G,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline",children:c("skills.viewDocs")})]})]}):c("skills.emptyNoMatch")}):(0,e.jsx)("div",{className:j.jL,children:F.map(a=>(0,e.jsx)(q,{skill:a,onPreview:()=>C(a.id),onDelete:()=>I(a.id),onCopyPath:()=>J(a.path)},a.id))})})]})]}),v&&(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-scrim",onClick:()=>{z||(w(!1),y(""))}}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-lg mx-4 p-5",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:c("skills.addSkill")}),(0,e.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:c("skills.pathLabel")}),(0,e.jsx)("input",{type:"text",value:x,onChange:a=>y(a.target.value),onKeyDown:a=>{"Enter"!==a.key||z||H()},placeholder:c("skills.pathPlaceholder"),autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground 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:()=>{w(!1),y("")},disabled:z,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:c("common.cancel")}),(0,e.jsx)("button",{onClick:H,disabled:z||!x.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:z?c("skills.adding"):c("skills.add")})]})]})]}),B&&(0,e.jsx)(m.d,{skillId:B,onClose:()=>C(null)})]}):null}function q({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let{t:i}=(0,g.Bd)(),[j,k]=(0,f.useState)(!1);return(0,e.jsxs)("div",{onClick:a.valid?b:void 0,role:a.valid?"button":void 0,tabIndex:a.valid?0:void 0,onKeyDown:c=>{a.valid&&("Enter"===c.key||" "===c.key)&&(c.preventDefault(),b())},className:`group flex flex-col h-56 border border-border rounded-lg p-3 hover:border-brand hover:shadow-lv2 transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${a.valid?"cursor-pointer":"opacity-60"}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 flex-shrink-0",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)(h.A,{className:"w-5 h-5"})}),(0,e.jsxs)("span",{className:"font-mono text-sm font-medium text-foreground truncate flex-1 min-w-0","data-tooltip":`/${a.name}`,children:["/",a.name]}),!a.valid&&(0,e.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:i("skills.invalid")}),(0,e.jsx)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:j?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),k(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:i("common.confirm")}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),k(!1)},className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:i("common.cancel")})]}):(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),k(!0)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:i("common.delete"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 7h22M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3"})})})})]}),(0,e.jsxs)("div",{className:"font-mono text-xs text-muted-foreground mt-2 flex-shrink-0 break-all line-clamp-2","data-tooltip":a.path,children:[a.path,(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),d()},className:"inline-flex align-middle ml-1 p-0.5 hover:text-foreground hover:bg-hover rounded transition-colors",title:i("skills.copyPath"),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)("p",{className:"text-sm text-muted-foreground mt-2 pt-2 border-t border-border/60 break-words line-clamp-4","data-tooltip":a.description||void 0,children:a.description||(0,e.jsx)("span",{className:"italic opacity-60",children:i("skills.noDescription")})}),a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-auto pt-1 truncate flex-shrink-0","data-tooltip":a.argumentHint,children:a.argumentHint})]})}m=(o.then?(await o)():o)[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,{D:()=>h,h:()=>i});var d=c(67484),e=c(88055),f=c(21586);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;let g=new Set;function h(a){return g.add(a),()=>{g.delete(a)}}function i({url:a,onMessage:b,enabled:c=!0}){(0,d.useRef)(b)}},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:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(28602),i=c(71697);let j={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 k({onClose:a,onCreate:b,editTask:c,onUpdate:l}){let{t:m}=(0,f.Bd)(),n=!!c,[o,p]=(0,e.useState)(c?.type||"once"),[q,r]=(0,e.useState)(c?.message||""),[s,t]=(0,e.useState)(c?.taskFile?"file":"message"),[u,v]=(0,e.useState)(c?.taskFile||""),[w,x]=(0,e.useState)(c?String(c.delayMinutes||c.intervalMinutes||""):""),[y,z]=(0,e.useState)(c?.cron||""),[A,B]=(0,e.useState)(c?.activeFrom||"09:00"),[C,D]=(0,e.useState)(c?.activeTo||"18:00"),[E,F]=(0,e.useState)(!!(c?.activeFrom&&c?.activeTo)),[G,H]=(0,e.useState)(null),I=(0,e.useRef)(null),J=(0,e.useRef)(null),K=(0,i.n)({value:q,onChange:r,textareaRef:J}),L=(0,e.useCallback)(()=>{let d="file"===s,e=d?{message:"",taskFile:u.trim()}:{message:q.trim(),taskFile:""};if(d?!e.taskFile:!e.message)return;let f=null;if("once"===o){let a=G||parseInt(w,10);if(!a||a<=0)return;f={...e,type:"once",delayMinutes:a}}else if("interval"===o){let a=G||parseInt(w,10);if(!a||a<=0)return;f={...e,type:"interval",intervalMinutes:a,...E?{activeFrom:A,activeTo:C}:{}}}else if("cron"===o){let a=G||y.trim();if(!a)return;f={...e,type:"cron",cron:a}}f&&(n&&c&&l?l(c.id,f):b(f),a())},[q,s,u,o,G,w,y,E,A,C,b,a,n,c,l]);return(0,d.jsxs)("div",{ref:I,className:`w-[28rem] max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lv2 z-50 ${n?"":"absolute bottom-full left-0 mb-2"}`,onKeyDown:b=>{"Escape"===b.key?a():"Enter"===b.key&&(b.metaKey||b.ctrlKey)&&L()},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:n?m("scheduledTasks.editTask"):m("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)("div",{className:"flex gap-1 mb-1.5",children:["message","file"].map(a=>(0,d.jsx)("button",{onClick:()=>t(a),className:`px-2 py-1 text-xs rounded transition-colors ${s===a?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"message"===a?m("scheduledTasks.sendMessage"):m("scheduledTasks.taskFile")},a))}),"message"===s?(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("textarea",{ref:J,value:q,onChange:a=>{r(a.target.value),K.trackCaret(a.target)},onSelect:a=>K.trackCaret(a.currentTarget),onKeyDown:a=>{K.handleKeyDown(a)},placeholder:m("scheduledTasks.messagePlaceholder"),rows:5,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring resize-y min-h-[6rem]"}),(0,d.jsx)(i.V,{ac:K,className:"absolute top-full left-0 right-0 mt-1 max-h-48 z-10"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{type:"text",value:u,onChange:a=>v(a.target.value),placeholder:m("scheduledTasks.taskFilePlaceholder"),className:"w-full px-2 py-1.5 text-sm font-mono border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:m("scheduledTasks.taskFileHint")})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:m("scheduledTasks.type")}),(0,d.jsx)("div",{className:"flex gap-1",children:["once","interval","cron"].map(a=>(0,d.jsx)("button",{onClick:()=>{p(a),H(null),x(""),z("")},className:`flex-1 px-2 py-1 text-xs rounded transition-colors ${o===a?"bg-brand text-white":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"once"===a?m("scheduledTasks.once"):"interval"===a?m("scheduledTasks.interval"):"Cron"},a))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:m("scheduledTasks.quickSelect")}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1",children:j[o].map(a=>(0,d.jsx)("button",{onClick:()=>{H(a.value),"cron"===o?z(String(a.value)):x(String(a.value))},className:`px-2 py-1 text-xs rounded border transition-colors ${G===a.value?"border-brand bg-brand/10 text-brand":"border-border text-muted-foreground hover:text-foreground hover:border-foreground/30"}`,children:m(a.labelKey)},a.labelKey))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:"cron"===o?m("scheduledTasks.customCron"):m("scheduledTasks.customMinutes")}),"cron"===o?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{type:"text",value:y,onChange:a=>{z(a.target.value),H(null)},placeholder:m("scheduledTasks.cronPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring font-mono"}),y.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}}(y.trim())||(0,d.jsx)("span",{className:"text-destructive",children:m("scheduledTasks.cronFormat")})})]}):(0,d.jsx)("input",{type:"number",value:w,onChange:a=>{x(a.target.value),H(null)},placeholder:m("scheduledTasks.minutesPlaceholder"),min:1,className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]}),"interval"===o&&(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:E,onChange:a=>F(a.target.checked),className:"rounded border-border"}),m("scheduledTasks.limitTimeRange")]}),E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("input",{type:"time",value:A,onChange:a=>B(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:m("scheduledTasks.to")}),(0,d.jsx)("input",{type:"time",value:C,onChange:a=>D(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:L,disabled:!(("file"===s?!!u.trim():!!q.trim())&&("once"===o||"interval"===o?!!(G||w&&parseInt(w,10)>0):"cron"===o&&!!(G||y.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:n?m("scheduledTasks.saveBtn",{modKey:(0,h.Mu)()}):m("scheduledTasks.createBtn",{modKey:(0,h.Mu)()})})]})]})}},30905:(a,b,c)=>{"use strict";c.d(b,{C:()=>e});var d=c(208);function e(a,b){if("codex_resume_failed"!==a.notice)return null;let c=a.previous_session_id||"",e=d.A.t("chat.codexResumeFailed",{defaultValue:"Previous session is in use by another Codex client — started a new session; history was not carried over"}),f=[...c?[`${d.A.t("chat.codexResumeFailedPrevious",{defaultValue:"Previous session"})}: ${c}`]:[],...a.session_id?[`${d.A.t("chat.codexResumeFailedNew",{defaultValue:"New session"})}: ${a.session_id}`]:[]],g=[e,...f.length?["",...f]:[],...a.error?["",a.error]:[]].join("\n");return{id:b,role:"system",content:e,systemEvent:{kind:"meta",detail:g}}}},32459:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>p});var e=c(48249),f=c(67484),g=c(44384),h=c(96286),i=c(40311),j=c(82795),k=c(32753),l=c(74228),m=c(1512),n=c(50508),o=a([n]);function p({currentCwd:a,onSwitchProject:b,onResolveSessionNumbers:c,collapsed:d,sessions:o}){let{t:q}=(0,g.Bd)(),r=(0,f.useMemo)(()=>(0,m.H)(o),[o]),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)(!1),[w,x]=(0,f.useState)({}),y=(0,f.useRef)(0),z=(0,f.useRef)(null),A=(0,n.o$)(),{show:B,hide:C}=A,D=(0,f.useCallback)(a=>{b(a.cwd,a.sessionId),t(!1)},[b]),E=(0,f.useCallback)(()=>{let a=!s;if(t(a),a){let a=++y.current;x({}),c().then(b=>{y.current===a&&x(b)})}else y.current+=1},[s,c]),F=o.filter(a=>"loading"===a.status).length,G=o.filter(a=>"unread"===a.status).length;return(0,e.jsxs)("div",{className:"relative",ref:z,children:[(0,e.jsxs)("button",{onClick:E,className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${d?"w-full justify-center":"w-full"}`,title:d?q("sessions.recentSessions"):void 0,children:[(0,e.jsx)(h.A,{className:"w-5 h-5 flex-shrink-0"}),!d&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:q("sessions.recentSessions")}),F>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-xs font-medium rounded-full flex items-center justify-center ${(0,i.ci)("loading",!1)} ${d?"absolute -top-1 -right-1":""}`,children:F}),G>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 bg-orange-11/15 text-orange-11 text-xs font-medium rounded-full flex items-center justify-center ${d&&!F?"absolute -top-1 -right-1":""}`,children:G})]}),s&&(0,e.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[600px] bg-popover border border-border rounded-lg shadow-lv2 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 flex items-center",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:q("sessions.recentSessions")}),F>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",q("sessions.runningCount",{count:F}),")"]}),G>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",q("sessions.unreadCount",{count:G}),")"]}),(0,e.jsxs)("button",{onClick:()=>{t(!1),v(!0)},className:"ml-auto flex items-center gap-1 p-1 -mr-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:q("sessions.searchRecentSessions"),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:"m21 21-4.35-4.35m2.35-5.4a7.75 7.75 0 1 1-15.5 0 7.75 7.75 0 0 1 15.5 0Z"})}),(0,e.jsx)("span",{className:"text-xs",children:q("sessions.search")})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===r.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:q("sessions.noSessions")}):r.map((b,c)=>(0,e.jsx)("button",{onClick:()=>D(b),onMouseEnter:a=>B(b,a),onMouseLeave:C,className:`w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 ${c!==r.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:(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)(k.S,{engine:b.engine}),(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:(0,n.Qr)(b.cwd)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(0,n.fw)(q,b.lastActive)}),(0,e.jsx)(l.l,{coordinate:w[`${b.cwd}
19
19
  ${b.sessionId}`],status:(0,l.S)(b.status),statusLabel:(0,n.Mm)(q,b.status),bot:b.bot,className:"ml-auto"})]}),b.title&&(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate","data-tooltip":b.title,children:b.title}),b.lastUserMessage&&(0,e.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:b.lastUserMessage})]})},`${b.cwd}-${b.sessionId}`))})]}),(0,e.jsx)(n.LD,{...A}),(0,e.jsx)(j.e,{isOpen:u,onClose:()=>v(!1),onSwitchProject:b,sessionNumbers:w})]})}n=(o.then?(await o)():o)[0],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-scrim flex items-center justify-center z-50",children:(0,d.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-lv3 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-hover 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-hover 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})},32753:(a,b,c)=>{"use strict";c.d(b,{S:()=>f});var d=c(48249),e=c(63565);function f({engine:a,tooltip:b,size:c="md"}){let g=a||"claude";return(0,e.ch)(g)?(0,d.jsx)("span",{className:"shrink-0 inline-flex items-center","data-tooltip":b??e.H[g],children:(0,d.jsx)(e.eV,{engine:g,className:"sm"===c?"h-3 w-3":"h-3.5 w-3.5"})}):(0,d.jsx)("span",{className:"shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded bg-muted text-muted-foreground","data-tooltip":b??g,children:g})}},33281:(a,b,c)=>{"use strict";c.d(b,{t4:()=>K});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")),y=r.nd("COCKPIT_SNAPSHOT_KEEP_DAYS").pipe(r.IQ(7)),z=r.nd("COCKPIT_SNAPSHOT_REPO_TTL_DAYS").pipe(r.IQ(30)),A=r.nd("COCKPIT_SNAPSHOT_MAX_FILE_KB").pipe(r.IQ(2048)),B=r.nd("COCKPIT_SESSION_KEEP_DAYS").pipe(r.IQ(30)),C=r.nd("COCKPIT_DELEGATE_MAX").pipe(r.tf({message:"COCKPIT_DELEGATE_MAX must be >= 1",validation:a=>a>=1}),r.IQ(4));f.JkU(function*(){let a=yield*s,b=yield*t,c=yield*u,d=yield*v,e=yield*w,g=yield*x,h=yield*y,i=yield*z,j=yield*A,k=yield*B,l=yield*C,m=yield*f.OH5(()=>{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:m,openProject:d,openBrowser:!e,logLevel:g,logFile:m+"/logs/cockpit.log",snapshotKeepDays:h,snapshotRepoTtlDays:i,snapshotMaxFileKb:j,sessionKeepDays:k,delegateMaxConcurrent:l}}).pipe(f.QgK);let D=d.Ie;var E=c(7846),F=c(55805),G=c(23734);let H=d.P1(G.d,f.JkU(function*(){let a=yield*E.dT();return yield*f.Q56(f.OH5(()=>b=>{f.MY7(E.mk(a,b))}),a=>f.OH5(()=>{})),G.d.of({publish:(a,b)=>f.OH5(()=>{}),subscribe:b=>F.qdp(a).pipe(F.pbD(a=>{var c;return c=a.data,!!c&&"object"==typeof c&&(c.topic===b.id||c.type===b.legacyType)}),F.TjK(a=>((a,b)=>{if(a.topic===b.id)return a.msg;let{type:c,...d}=a;return d})(a.data,b)))})})),I=d.Um(i,q,D),J=d.Um(I,H),K=e.L8(J);f.rIH},34001:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{NoteModal:()=>G});var e=c(48249),f=c(67484),g=c(44384),h=c(208),i=c(13191),j=c(63229),k=c(19043),l=c(48197),m=c(9731),n=c(44551),o=c(53116),p=c(16512),q=c(56444),r=c(11537),s=c(73555),t=c(1370),u=c(80118),v=c(54727),w=c(19545),x=c(92451),y=c(83179),z=c(33281),A=c(79606),B=c(7833),C=c(65484),D=c(43321),E=c(43037),F=c(39031);function G({isOpen:a,onClose:b,projectCwd:c,projectName:d}){let{t:H}=(0,g.Bd)(),[I,J]=(0,f.useState)(!0),[K,L]=(0,f.useState)(!1),M=(0,f.useRef)(null),N=(0,f.useRef)(!1),O=(0,f.useRef)(void 0),[P,Q]=(0,f.useState)(null),R=(0,f.useRef)(null),S=(0,f.useCallback)(async a=>{let b=(0,D.D)(a);L(!0);let d=await z.t4.runPromiseExit((0,C.Cq)(c,b,O.current).pipe(A.sFT(a=>A.OH5(()=>console.error("Failed to save note:",a)))));if("Success"===d._tag){let a=d.value;a.conflict?(V.current?.commands.setContent(a.content,{emitUpdate:!1}),O.current=a.mtime,N.current=!1,(0,B.oR)(H("editor.conflictReloaded"),"info")):(O.current=a.mtime,N.current=!1)}L(!1)},[c,H]),T=(0,f.useCallback)(a=>{N.current=!0,M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{S(a)},5e3)},[S]),U=(0,i.hG)({immediatelyRender:!1,extensions:[j.A.configure({heading:!1,link:!1}),u.R.configure({levels:[1,2,3]}),v.y,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.$H.configure({nested:!0}),E.E3,F.IS,s.o.configure({html:!0,transformCopiedText:!1,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},clipboardTextSerializer:a=>a.content.textBetween(0,a.content.size,"\n").replace(/\n+$/,""),transformCopied:a=>{let b=a=>!!a&&a.isTextblock&&0===a.content.size,c=a.content,{openStart:d,openEnd:e}=a;for(;c.childCount>1&&b(c.lastChild);)c=c.cut(0,c.size-c.lastChild.nodeSize),e=0;for(;c.childCount>1&&b(c.firstChild);)c=c.cut(c.firstChild.nodeSize),d=0;return new t.Ji(c,d,e)},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&&V.current){let a=V.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||P||setTimeout(()=>{if(!V.current)return;let{from:a}=V.current.state.selection,b=V.current.state.doc.textBetween(Math.max(0,a-1),a,"\n");if("/"===b){R.current=a;let b=V.current.view.coordsAtPos(a);Q({query:"",position:{top:b.bottom+4,left:b.left}})}},0),!1}},onUpdate:({editor:a})=>{let b=(0,w.up)(a);if(T(b),null!==R.current){let{from:b}=a.state.selection;if(b<R.current)Q(null),R.current=null;else{let c=a.state.doc.textBetween(R.current,b,"\n");c.includes(" ")||c.includes("\n")?(Q(null),R.current=null):Q(a=>a?{...a,query:c}:null)}}}}),V=(0,f.useRef)(null),W=(0,f.useCallback)(()=>{if(M.current&&(clearTimeout(M.current),M.current=null),N.current&&U){let a=(0,w.up)(U);S(a)}Q(null),R.current=null,b()},[U,S,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-scrim",onClick:W}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 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?H("editor.noteTitle",{name:d}):H("editor.noteUntitled")}),K&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:H("editor.saving")})]}),(0,e.jsx)("button",{onClick:W,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover 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)(y.NoteToolbar,{editor:U}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:I?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,e.jsx)("span",{children:H("common.loading")})}):(0,e.jsx)(i.$Z,{editor:U})})]}),P&&U&&(0,e.jsx)(x.U,{editor:U,query:P.query,position:P.position,onClose:()=>{Q(null),R.current=null}})]}):null}d()}catch(a){d(a)}})},35208:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{xU:()=>u,xZ:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(36043),i=c(32580),j=c(73414),k=c(7833),l=c(38896),m=c(36984),n=c(74542),o=c(26362),p=c(89719),q=a([o]);function r(a){return(0,f.useCallback)((b,c)=>{if(!a||c<=0)return;let d=(0,p.A)(b,b.currentTarget);d&&a(c,d.column,d.rect)},[a])}function s(a){return a.params?`${a.name}(${a.params.join(", ")})`:a.name}function t({oldContent:a,newContent:b,filePath:c,isNew:d=!1,isDeleted:p=!1,cwd:q,enableComments:u=!1,onPreview:v,previewLabel:w,headerLeading:x,onContentSearch:y,targetLine:z,compact:A=!1,symbols:B,onTokenHover:C,onTokenHoverLeave:D,onTokenHoverCancel:E}){let{t:F}=(0,g.Bd)(),G=r(C),H=w??F("common.preview"),I=(0,f.useMemo)(()=>(0,i.X)(a,b),[a,b]),J=(0,f.useRef)(null),K=(0,f.useRef)(null),L=(0,f.useRef)(null);(0,f.useRef)(!1);let[M,N]=(0,f.useState)(null),{commentsEnabled:O,linesWithComments:P,commentsByEndLine:Q,handleCommentBubbleClick:R,addCommentRange:S,sendToAIRange:T,commentPortal:U}=(0,o.T)({cwd:q,enableComments:u,filePath:c,diffLines:I,containerEl:M,onContentSearch:y}),{leftLines:V,rightLines:W}=(0,f.useMemo)(()=>{let a=[],b=[],c=0,d=0;for(let e=0;e<I.length;e++){let f=I[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}},[I]),X=(0,f.useMemo)(()=>I.map(a=>a.content),[I]),Y=(0,l.C)(X,c),[Z,$]=(0,f.useState)(()=>new Map),_=(0,f.useMemo)(()=>B??[],[B]),{rows:aa,gaps:ab}=(0,f.useMemo)(()=>A?(0,j.pU)(V,W,Z,_):{rows:V.map((a,b)=>({kind:"diff",idx:b})),gaps:[]},[A,V,V,W,Z,_]),ac=(0,f.useCallback)((a,b)=>{let c=ab.find(b=>b.id===a);c&&$(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(j.YO,f),h="up"===b?{...e,topRevealed:e.topRevealed+g}:{...e,bottomRevealed:e.bottomRevealed+g};return new Map(d).set(a,h)})},[ab]);(0,f.useCallback)(a=>{for(let b of ab)if(a>=b.startIdx&&a<=b.endIdx)return b.id;return null},[ab]);let ad=(0,f.useCallback)(a=>aa[a]?.kind==="gap-label"?28:20,[aa]),ae=(0,f.useCallback)(a=>{let b=aa[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=V[b.idx],d=W[b.idx];return`d:${c?.lineNum??"x"}:${c?.type??"x"}:${d?.lineNum??"x"}:${d?.type??"x"}`},[aa,V,W]),af=(0,h.Te)({count:aa.length,getScrollElement:()=>J.current,estimateSize:ad,getItemKey:ae,overscan:20}),ag=d?"w-1/4":p?"w-3/4":"w-1/2",ah=d?"w-3/4":p?"w-1/4":"w-1/2",ai=(0,f.useMemo)(()=>aa.map(a=>{if("diff"!==a.kind)return{type:"unchanged"};let b=V[a.idx],c=W[a.idx];return"removed"===b.type?{type:"removed"}:c?.type==="added"?{type:"added"}:{type:"unchanged"}}),[aa,V,W]),aj=af.getTotalSize(),ak=af.getVirtualItems();return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[x&&(0,e.jsx)("div",{className:"flex-shrink-0 px-2 py-1 border-b border-border bg-accent",children:x}),(0,e.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,e.jsx)("div",{className:`${ag} 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)":p?"Deleted":"Old"}),(0,e.jsxs)("div",{className:`${ah} 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:p?"(Deleted)":"New"}),(0,e.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[v&&(0,e.jsx)("button",{onClick:v,className:"text-muted-foreground hover:text-foreground transition-colors",children:H}),!p&&b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,k.oR)(F("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:F("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:J,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,e.jsxs)("div",{className:"flex",style:{height:`${aj}px`},children:[(0,e.jsx)("div",{ref:K,className:`${ag} overflow-x-auto border-r border-border`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ak.map(a=>{let b=aa[a.index];if("gap-expand"===b.kind||"gap-label"===b.kind){let c="gap-label"===b.kind;return(0,e.jsx)("div",{ref:af.measureElement,"data-index":a.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,ad(a.index))}px`,transform:`translateY(${a.start}px)`},className:c?"bg-accent border-y border-border":""},a.key)}let c=V[b.idx];return(0,e.jsxs)("div",{ref:af.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,ad(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-foreground-subtle select-none border-r border-border",children:c.lineNum||""}),(0,e.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:c.originalIdx>=0&&Y[c.originalIdx]||(0,m.ZD)(c.content||" ")}})]},a.key)})})}),(0,e.jsx)("div",{ref:L,className:`${ah} overflow-x-auto`,children:(0,e.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:ak.map(a=>{let b=aa[a.index];if("gap-expand"===b.kind)return(0,e.jsx)("button",{ref:af.measureElement,"data-index":a.index,type:"button",onClick:()=>ac(b.gapId,b.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,ad(a.index))}px`,transform:`translateY(${a.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-hover hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:F("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),"aria-label":F("up"===b.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:b.revealCount}),children:(0,e.jsx)("span",{className:"select-none",children:F("diffViewer.gap.more",{count:b.revealCount})})},a.key);if("gap-label"===b.kind)return(0,e.jsxs)("div",{ref:af.measureElement,"data-index":a.index,"data-gap-id":b.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(a.size,ad(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:F("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","data-tooltip":s(b.enclosingFn),children:s(b.enclosingFn)})]})]},a.key);let c=W[b.idx],d=c?.lineNum||0,f=d>0&&P.has(d),g=Q.get(d),h=g?.[0],i=S&&d>=S.start&&d<=S.end,j=T&&d>=T.start&&d<=T.end,k=i||j;return(0,e.jsxs)("div",{ref:af.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,ad(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-foreground-subtle select-none border-r border-border ${k?"bg-blue-9/30":""}`,style:{width:O?"52px":"40px"},children:[O&&d>0&&f&&h&&(0,e.jsx)("button",{onClick:a=>R(h,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:F("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"})})}),O&&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",onMouseOver:C?a=>G(a,d):void 0,onMouseLeave:C?D:void 0,onMouseDown:C?E:void 0,dangerouslySetInnerHTML:{__html:c?.originalIdx>=0&&Y[c.originalIdx]||(0,m.ZD)(c?.content||" ")}})]},a.key)})})})]})}),(0,e.jsx)(n.b,{lines:ai,containerRef:J})]}),U]})}function u({oldContent:a,newContent:b,filePath:c,cwd:d,enableComments:p=!1,onPreview:q,previewLabel:s,headerLeading:t,onContentSearch:v,compact:w=!1,onTokenHover:x,onTokenHoverLeave:y,onTokenHoverCancel:z}){let{t:A}=(0,g.Bd)(),B=r(x),C=s??A("common.preview"),D=(0,f.useMemo)(()=>(0,i.X)(a,b),[a,b]),E=(0,f.useRef)(null),F=(0,f.useMemo)(()=>D.map(a=>a.content),[D]),G=(0,l.C)(F,c),[H,I]=(0,f.useState)(null),{commentsEnabled:J,linesWithComments:K,commentsByEndLine:L,handleCommentBubbleClick:M,addCommentRange:N,sendToAIRange:O,commentPortal:P}=(0,o.T)({cwd:d,enableComments:p,filePath:c,diffLines:D,containerEl:H,onContentSearch:v}),[Q,R]=(0,f.useState)(()=>new Set),S=(0,f.useMemo)(()=>w?function(a,b){let c=a.length,d=Array(c).fill(!1);for(let b=0;b<c;b++){if("unchanged"===a[b].type)continue;let e=Math.max(0,b-j.aj),f=Math.min(c-1,b+j.aj);for(let a=e;a<=f;a++)d[a]=!0}let e=[],f=0,g=0;for(;g<c;){if(d[g]){e.push({kind:"line",line:a[g],index:g}),g++;continue}let h=g;for(;h<c&&!d[h];)h++;let i=f++;if(b.has(i))for(let b=g;b<h;b++)e.push({kind:"line",line:a[b],index:b});else e.push({kind:"gap",id:i,count:h-g});g=h}return e}(D,Q):D.map((a,b)=>({kind:"line",line:a,index:b})),[w,D,Q]),T=(0,f.useCallback)(a=>{let b=S[a];if(!b)return a;if("gap"===b.kind)return`gap:${b.id}`;let c=b.line;return`${c.type}:${c.oldLineNum??"x"}:${c.newLineNum??"x"}`},[S]),U=(0,h.Te)({count:S.length,getScrollElement:()=>E.current,estimateSize:()=>20,getItemKey:T,overscan:20}),V=(0,f.useMemo)(()=>S.map(a=>"gap"===a.kind?{type:"unchanged"}:{type:a.line.type}),[S]);return(0,e.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(t||q||b)&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-end gap-2 px-2 py-1 border-b border-border bg-accent text-xs",children:[t&&(0,e.jsx)("div",{className:"mr-auto min-w-0",children:t}),q&&(0,e.jsx)("button",{onClick:q,className:"text-muted-foreground hover:text-foreground transition-colors",children:C}),b&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(b),(0,k.oR)(A("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:A("common.copy")}),(0,e.jsx)("div",{className:"w-4 flex-shrink-0"})]}),(0,e.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,e.jsx)("div",{ref:E,className:"flex-1 min-w-0 overflow-auto",children:(0,e.jsx)("div",{style:{height:`${U.getTotalSize()}px`,position:"relative"},children:U.getVirtualItems().map(a=>{let b=S[a.index];if(!b)return null;let c={position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${a.size}px`,transform:`translateY(${a.start}px)`};if("gap"===b.kind){let d=A("diffViewer.gap.hidden",{count:b.count});return(0,e.jsx)("div",{style:c,onClick:()=>R(a=>new Set(a).add(b.id)),className:"flex items-center cursor-pointer bg-slate-2 hover:bg-hover border-y border-border text-xs text-foreground-subtle select-none","data-tooltip":d,children:(0,e.jsx)("span",{className:"w-full text-center",children:d})},a.key)}let d=b.line,f="removed"!==d.type?d.newLineNum??0:0,g=f>0&&K.has(f),h=L.get(f),i=h?.[0],j=N&&f>=N.start&&f<=N.end,k=O&&f>=O.start&&f<=O.end;return(0,e.jsxs)("div",{style:c,"data-new-line":f||void 0,className:`flex ${j||k?"bg-blue-9/20":g?"bg-amber-9/10":"removed"===d.type?"bg-red-9/15 dark:bg-red-9/25":"added"===d.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[J&&(0,e.jsx)("span",{className:"w-5 flex-shrink-0 flex items-center justify-center select-none",children:f>0&&g&&i&&(0,e.jsx)("button",{onClick:a=>M(i,a),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-hover text-amber-9",title:A("codeViewer.nComments",{count:h?.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"})})})}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"added"!==d.type?d.oldLineNum:""}),(0,e.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-foreground-subtle select-none border-r border-border",children:"removed"!==d.type?d.newLineNum:""}),(0,e.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===d.type?"text-red-11":"added"===d.type?"text-green-11":"text-foreground-subtle"}`,children:"removed"===d.type?"-":"added"===d.type?"+":" "}),(0,e.jsx)("span",{className:"flex-1 whitespace-pre pl-1",onMouseOver:x?a=>B(a,f):void 0,onMouseLeave:x?y:void 0,onMouseDown:x?z:void 0,dangerouslySetInnerHTML:{__html:G[b.index]||(0,m.ZD)(d.content||" ")}})]},a.key)})})}),(0,e.jsx)(n.b,{lines:V,containerRef:E})]}),P]})}o=(q.then?(await q)():q)[0],d()}catch(a){d(a)}})},35606:(a,b,c)=>{"use strict";function d(a,b){switch(a){case"codex":return`codex resume ${b}`;case"kimi":case"glm":case"deepseek":case"ollama":return`${a} ${b}`;default:return`claude -r ${b}`}}c.d(b,{X:()=>d})},35857:(a,b,c)=>{"use strict";function d(){}c.d(b,{N:()=>d})},36462:(a,b,c)=>{"use strict";c.d(b,{p:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(66400),h=c(7833),i=c(82338),j=c(33281),k=c(29939),l=c(23328);function m({collapsed:a,currentCwd:b,projectOrder:c,onFocusTerminal:n}){let{t:o}=(0,f.Bd)(),{terminals:p,refresh:q}=function(){let[a,b]=(0,e.useState)([]),c=(0,e.useRef)(null),d=(0,e.useCallback)(()=>{j.t4.runPromiseExit((0,l.D5)()).then(a=>{"Success"===a._tag&&b(a.value)})},[]),f=(0,e.useCallback)(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,d()},150)},[d]);return(0,k.h)({url:"/ws/global-state",onMessage:a=>{("running-terminals-changed"===a.type||"console-delta"===a.type&&"rename"===a.op)&&f()}}),{terminals:a,refresh:d}}(),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(()=>Date.now()),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(null),[z,A]=(0,e.useState)(()=>new Set),B=(0,e.useRef)(new Map),C=(0,e.useMemo)(()=>{let a=new Map;for(let b of p){let c=a.get(b.projectCwd);c?c.push(b):a.set(b.projectCwd,[b])}let d=a=>{if(a===b)return -1;let d=c.indexOf(a);return d>=0?d:Number.MAX_SAFE_INTEGER};return[...a.entries()].sort(([a],[b])=>d(a)-d(b)||a.localeCompare(b)).map(([a,b])=>({cwd:a,number:c.indexOf(a)+1,items:[...b].sort((a,b)=>a.timestamp.localeCompare(b.timestamp))}))},[p,b,c]);(0,e.useMemo)(()=>C.flatMap(a=>a.items),[C]);let D=(0,e.useCallback)(()=>{s(!1),y(null)},[]),E=(0,e.useCallback)(()=>{q(),u(Date.now()),s(!0)},[q]),F=(0,e.useCallback)(a=>{D(),n(a.projectCwd,a.commandId)},[D,n]),G=(0,e.useCallback)(a=>{y(null),A(b=>new Set(b).add(a.commandId));let b=()=>{B.current.delete(a.commandId),A(b=>{let c=new Set(b);return c.delete(a.commandId),c}),(0,h.oR)(o("runningTerminals.stopFailed"),"error")};j.t4.runPromiseExit((0,l.px)(a.commandId)).then(c=>{"Success"!==c._tag?b():c.value.interrupted?B.current.set(a.commandId,setTimeout(b,3e3)):q()})},[q,o]),H=a=>{var b,c;let e,f,g,h,i=z.has(a.commandId),j=x===a.commandId,k=(b=a.cwd,c=a.projectCwd,b&&b!==c?b.startsWith(c+"/")?b.slice(c.length+1):b:""),l=a.title||a.command.split("\n")[0];return(0,d.jsxs)("div",{"data-running-terminal":a.commandId,onClick:()=>{i||F(a)},onMouseEnter:()=>w(a.commandId),title:`${a.command}
@@ -23,9 +23,9 @@ pid ${a.pid}`,className:`group rounded-md px-3 py-2 transition-colors ${i?"opaci
23
23
  `:"")+(a.status?`<status>${a.status}</status>
24
24
  `:"")+(a.summary?`<summary>${a.summary}</summary>
25
25
  `:"")+(a.output_file?`<output-file>${a.output_file}</output-file>
26
- `:"")+"</task-notification>";b(b=>[...b,{id:c,role:"system",content:a.summary||"",systemEvent:{kind:"task-notification",...a.status?{status:a.status}:{},detail:d}}])}return}if("system"===a.type&&"notice"===a.subtype){let c=(0,h.C)(a,`live-notice-${++l.current}`);c&&b(a=>[...a,c]);return}if("user"===a.type&&a._human){let c=a.message?.content,d="string"==typeof c?c:Array.isArray(c)?c.map(a=>a?.text||"").join(""):"",e="string"==typeof a._turnId?a._turnId:null;e&&(q.current=e);let f="number"==typeof a._ts?a._ts:null,g=e?`live-user-${e}`:`live-user-${++l.current}`;b(a=>{if(e&&a.some(a=>a.id===g))return a;for(let b=a.length-1;b>=0;b--){if("user"!==a[b].role)continue;let c=a[b].timestamp?Date.parse(a[b].timestamp):NaN;if(null===f||Number.isNaN(c)){if(a[b].content===d)return a}else if(c>=f)return a;break}return[...a,{id:g,role:"user",content:d}]});return}if("result"===a.type&&(p.current=!1,o.current=!0),"assistant"===a.type&&Array.isArray(a.message?.content))for(let b of a.message.content)b.text?d(b.text):b.name&&d(`${b.name} ${JSON.stringify(b.input??{})}`);if("user"===a.type&&Array.isArray(a.message?.content))for(let b of a.message.content)d("string"==typeof b.content?b.content:JSON.stringify(b.content??""));let e=k.current??r();b(b=>(0,g.FM)(b,a,{engine:i,assistantId:e}))};(0,e.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("string"==typeof a.runId&&a.runId&&(q.current=a.runId),"running"!==a.status){j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1;return}let c=a.events.find(a=>a?.type==="user"&&a?._human),d=c?.message?.content,e="string"==typeof d?d:"",f=new Set,h=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&&h.add(a.id)}let i="number"==typeof a.startedAt?a.startedAt:null;b(a=>{let b=a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("live-"))),c=b[b.length-1],d=c?.timestamp?Date.parse(c.timestamp):NaN;if(null!==i&&!Number.isNaN(d)){let a=b.length;for(;a>0;){let c=b[a-1],d=c.timestamp?Date.parse(c.timestamp):NaN;if(!Number.isNaN(d)&&d>=i)a--;else break}return a<b.length?b.slice(0,a):b}if(!e)return b;let g=-1;for(let a=b.length-1;a>=0;a--)if("user"===b[a].role){b[a].content===e&&(g=a);break}return -1===g?b:b.slice(g+1).every(a=>"assistant"===a.role&&("string"==typeof a.id&&f.has(a.id)||!!a.toolCalls?.length&&a.toolCalls.every(a=>h.has(a.id))))?b.slice(0,g):b}),k.current=null,l.current=0,m.current=0,n.current=!1,o.current=!1,p.current=!1;let r="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let b of(null!==r&&(m.current=r,n.current=!0,j?.onLiveOutputTokens?.({outputTokens:r})),a.events))s(b);j?.onRunningChange?.(!0),j?.onRunStartedAt?.("number"==typeof a.startedAt?a.startedAt:Date.now())}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1,j?.onComplete?.();return}s(a.message),j?.onRunningChange?.(!0)}else"run-idle"===a.type&&(j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1)}})}},40893:(a,b,c)=>{"use strict";c.d(b,{O:()=>m});var d=c(48249),e=c(67484),f=c(7031),g=c(41051),h=c(42140),i=c(64676),j=c(74754),k=c(91579),l=c(208);function m({content:a,filePath:b,cwd:c,onContentSearch:n,reloadKey:o=0}){let p=(0,f.r)(),q=!!c,r=(0,e.useMemo)(()=>(0,i.qF)(b,c)?{mode:"url",url:(0,i.Xe)(b,c)}:{mode:"srcdoc",html:a??""},[a,b,c]),{addComment:s,refresh:t}=(0,j._)({cwd:c||"",filePath:b}),[u,v]=(0,e.useState)(null),w=(0,e.useRef)(null),x=(0,e.useRef)(null),y=(0,e.useRef)(()=>{}),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(null),D=(0,e.useRef)(!1),E=(0,e.useCallback)(()=>{x.current&&(x.current=null,y.current())},[]),F=(0,e.useCallback)(()=>{let a=w.current,b=a?.contentWindow;if(b){let a=document.documentElement.classList.contains("dark");b.postMessage({type:"THEME_CHANGE",theme:a?"dark":"light"},"*"),b.postMessage({type:"cockpit:language-change",lang:l.A.language},"*")}if(!q)return;let c=a?.contentDocument;a&&c&&(c.addEventListener("mouseup",b=>{if(D.current)return;let c=a.contentWindow?.getSelection(),d=c&&!c.isCollapsed?c.toString().trim():"";if(!d)return void E();let e=a.getBoundingClientRect();x.current={x:e.left+b.clientX,y:e.top+b.clientY,range:{start:0,end:0},selectedText:d,lineSnapshot:d},y.current()}),c.addEventListener("mousedown",()=>{E(),A(null),C(null)}),c.addEventListener("scroll",()=>E(),{capture:!0,passive:!0}))},[q,E]),G=(0,e.useCallback)(()=>{let a=x.current;a&&(A({x:a.x,y:a.y,text:a.selectedText}),E(),w.current?.contentWindow?.getSelection()?.removeAllRanges())},[E]),H=(0,e.useCallback)(()=>{let a=x.current;a&&(C({x:a.x,y:a.y,text:a.selectedText}),E(),w.current?.contentWindow?.getSelection()?.removeAllRanges())},[E]),I=(0,e.useCallback)(()=>{let a=x.current;a&&p&&(E(),w.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,k.Ff)(p.sendMessage,{filePath:b,startLine:0,endLine:0,codeContent:a.selectedText},l.A.t("explain.selectionMessage")))},[p,b,E]),J=(0,e.useCallback)(()=>{let a=x.current;if(!a||!n)return;let b=a.selectedText.trim();E(),w.current?.contentWindow?.getSelection()?.removeAllRanges(),b&&n(b)},[n,E]),K=(0,e.useCallback)(async a=>{z&&(await s(0,0,a,z.text),A(null))},[z,s]),L=(0,e.useCallback)(async(a,d)=>{if(p&&c)try{let e=(await (0,k.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));e.push({filePath:b,startLine:0,endLine:0,codeContent:a});let f=(0,k.Gw)(e,d);p.sendMessage(f),await (0,k.RP)(c),t()}catch(a){console.error("[HtmlAppFrame] send to AI failed:",a)}},[p,c,b,t]),M=(0,e.useCallback)(a=>{B&&L(B.text,a)},[B,L]),N=(0,e.useCallback)(a=>{z&&L(z.text,a)},[z,L]);return(0,d.jsxs)("div",{ref:v,className:"relative h-full w-full bg-white",children:[(0,d.jsx)("iframe",{ref:w,..."url"===r.mode?{src:r.url}:{srcDoc:r.html},title:b,className:"h-full w-full border-0",onLoad:F},`${b}:${o}`),q&&u&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.fS,{floatingToolbarRef:x,bumpRef:y,container:u,onAddComment:G,onSendToAI:H,onSearch:n?J:void 0,onExplain:p?I:void 0,isChatLoading:p?.isLoading}),z&&(0,d.jsx)(h.t,{x:z.x,y:z.y,range:{start:0,end:0},filePath:b,lineSnapshot:z.text,container:u,onSubmit:K,onSendToAI:p?N:void 0,onClose:()=>A(null),isChatLoading:p?.isLoading}),B&&(0,d.jsx)(h.G,{x:B.x,y:B.y,range:{start:0,end:0},filePath:b,lineSnapshot:B.text,container:u,onSubmit:M,onClose:()=>C(null),isChatLoading:p?.isLoading})]})]})}},41051:(a,b,c)=>{"use strict";c.d(b,{SZ:()=>g,fS:()=>j});var d=c(48249),e=c(67484),f=c(44384);let g=[["quickReply.optionA","quickReply.optionB","quickReply.optionC","quickReply.optionD"],["quickReply.allRecommended","quickReply.thisOne","quickReply.notThis"],["quickReply.why","quickReply.elaborate","quickReply.example"],["quickReply.start","quickReply.continue","quickReply.ok","quickReply.done"]];function h({rows:a,placeAbove:b,onHeight:c,onPick:g,onEdit:i,onMouseEnter:j,onMouseLeave:k}){let{t:l}=(0,f.Bd)(),m=(0,e.useRef)(null);return(0,d.jsxs)("div",{ref:m,className:`absolute ${b?"bottom-full mb-1":"top-full mt-1"} left-0 z-[201] flex flex-col gap-1 bg-card border border-border rounded-lg shadow-lv3 p-1.5`,onMouseEnter:j,onMouseLeave:k,children:[i&&(0,d.jsx)("button",{className:"absolute top-0.5 right-0.5 p-1 text-muted-foreground hover:text-brand transition-colors",onClick:i,title:l("quickReply.edit"),"aria-label":l("quickReply.edit"),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.map((a,b)=>(0,d.jsx)("div",{className:`flex items-center gap-1${i&&0===b?" pr-5":""}`,children:a.map((a,c)=>(0,d.jsx)("button",{className:"px-2 py-1 text-xs whitespace-nowrap border border-border text-foreground rounded hover:border-brand hover:bg-hover transition-colors",onClick:()=>g(a),children:a},`${b}:${c}:${a}`))},b))]})}function i({x:a,y:b,visible:c,container:j,onAddComment:k,onSendToAI:l,onSearch:m,onExplain:n,onQuickReply:o,quickReplyRows:p,onEditQuickReplies:q,isChatLoading:r}){let{t:s}=(0,f.Bd)(),t=(0,e.useRef)(null),[u,v]=(0,e.useState)({w:0,h:0}),[w,x]=(0,e.useState)(0),[y,z]=(0,e.useState)(null),A=(0,e.useRef)(null),B=(0,e.useCallback)(a=>{x(b=>b===a?b:a)},[]),C=(0,e.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,e.useCallback)(a=>{C(),z(a)},[C]),E=(0,e.useCallback)(()=>{C(),A.current=setTimeout(()=>z(null),150)},[C]),F=j.getBoundingClientRect(),G=a-F.left,H=Math.max(0,b-F.top-40),I=Math.max(0,Math.min(G+8,F.width-u.w-8)),J=w>0&&H+u.h+8+w>F.height,K=(0,e.useMemo)(()=>p??g.map(a=>a.map(a=>s(a))),[p,s]),L=a=>o&&y===a?(0,d.jsx)(h,{rows:K,onEdit:q,placeAbove:J,onHeight:B,onPick:b=>{z(null),o(a,b)},onMouseEnter:C,onMouseLeave:E}):null;return(0,d.jsxs)("div",{ref:t,className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-lv3 p-1.5",style:{left:I,top:H,visibility:c?"visible":"hidden",pointerEvents:c?"auto":"none"},children:[(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>D("comment"),onMouseLeave:E,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:k,children:s("floatingToolbar.addComment")}),L("comment")]}),(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>{r||D("ai")},onMouseLeave:E,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 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,disabled:r,title:r?s("comments.aiResponding"):void 0,children:s("floatingToolbar.sendToAI")}),L("ai")]}),n&&(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:n,disabled:r,title:r?s("comments.aiResponding"):void 0,children:s("explain.action")}),m&&(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:m,children:s("floatingToolbar.search")})]})}let j=(0,e.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:f,onSendToAI:g,onSearch:h,onExplain:j,onQuickReply:k,quickReplyRows:l,onEditQuickReplies:m,isChatLoading:n}){let[o,p]=(0,e.useState)(0),q=(0,e.useMemo)(()=>a.current,[o]);return(0,d.jsx)(i,{x:q?.x??0,y:q?.y??0,visible:!!q,container:c,onAddComment:f,onSendToAI:g,onSearch:h,onExplain:j,onQuickReply:k,quickReplyRows:l,onEditQuickReplies:m,isChatLoading:n})})},41170:(a,b,c)=>{"use strict";c.d(b,{GR:()=>k,LM:()=>i,Ux:()=>l});let d={mode:"follow",pinTop:null},e={mode:"free",pinTop:null};function f(a){return Math.max(0,a.scrollHeight-a.spacer)}function g(a){return Math.max(0,f(a)-a.clientHeight)}function h(a,b){return a<=0?0:Math.max(0,a+b.clientHeight-f(b))}function i(a){return f(a)-a.scrollTop-a.clientHeight<50}function j(a,b="auto"){return{owner:d,spacer:0,scrollTo:g(a),behavior:b}}function k(a,b,c){if(!(c.clientHeight>0))return null;switch(b.type){case"reset":return{owner:d,spacer:0,scrollTo:null,behavior:"auto"};case"toEnd":return j(c,"smooth");case"readFrom":{let a=b.top;return{owner:{mode:"reading",pinTop:a},spacer:h(a,c),scrollTo:a,behavior:"auto"}}case"settle":{if("reading"===a.mode){let b=a.pinTop??c.scrollTop;return{owner:a,spacer:h(b,c),scrollTo:null,behavior:"auto"}}if(c.spacer<=0)return null;let b=Math.min(c.scrollTop,g(c));return{owner:b>=g(c)?d:e,spacer:0,scrollTo:b,behavior:"smooth",deferSpacer:!0}}case"pin":{let a=h(b.top,c);if(a<=0)return j(c);return{owner:{mode:"pinned",pinTop:b.top},spacer:a,scrollTo:b.top,behavior:"smooth"}}case"release":if("pinned"!==a.mode&&"reading"!==a.mode)return null;return{owner:e,spacer:h(c.scrollTop,c),scrollTo:null,behavior:"auto"};case"content":case"viewport":if("follow"===a.mode)return j(c);if("pinned"===a.mode){let d=a.pinTop??c.scrollTop,e=h(d,c);if(e<=0)return j(c);return{owner:a,spacer:e,scrollTo:"viewport"===b.type?d:null,behavior:"auto"}}if("reading"===a.mode){let d=a.pinTop??c.scrollTop;return{owner:a,spacer:h(d,c),scrollTo:"viewport"===b.type?d:null,behavior:"auto"}}return{owner:a,spacer:h(c.scrollTop,c),scrollTo:null,behavior:"auto"}}}function l(a,b){return"pinned"===a.mode||"reading"===a.mode?a:50>Math.abs(b.scrollTop-g(b))?d:e}},41224:(a,b,c)=>{"use strict";c.d(b,{$N:()=>y,$x:()=>I,Cr:()=>F,DF:()=>L,F4:()=>r,Fi:()=>o,Hw:()=>l,JC:()=>v,K4:()=>K,M5:()=>t,Ny:()=>m,QW:()=>z,Vm:()=>C,ZQ:()=>H,Zr:()=>x,_9:()=>G,an:()=>E,dM:()=>q,dQ:()=>n,em:()=>k,hZ:()=>J,he:()=>p,l1:()=>u,nM:()=>i,n_:()=>w,qD:()=>D,td:()=>j,yS:()=>s,z2:()=>A});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>g("/api/session/user-messages",{cwd:a,sessionId:b}),j=()=>f("/api/settings"),k=a=>h("/api/settings",a),l=a=>f(`/api/${a}/credentials`),m=a=>f(`/api/${a}/credentials?reveal=1`),n=(a,b)=>h(`/api/${a}/credentials`,{apiKey:b}),o=a=>f(`/api/${a}/models`),p=()=>f("/api/deepseek/balance"),q=a=>f(`/api/${a}/usage`),r=()=>f("/api/ollama/config"),s=a=>h("/api/ollama/config",a),t=()=>f("/api/commands"),u=()=>f("/api/skills"),v=a=>g("/api/bash",a),w=a=>d.$mh({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})}),x=(a,b)=>g(`/api/session/${encodeURIComponent(a)}/fork`,b),y=(a,b)=>f(`/api/session/${encodeURIComponent(a)}/turn`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),z=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),A=()=>f("/api/global-state").pipe(d.TjK(a=>a.sessions??[])),B=()=>d.$mh({try:async()=>{let a=await fetch("/api/ollama/models"),b=await a.json().catch(()=>({}));return 503===a.status?{_tag:"not-running",...b.error&&{reason:b.error}}:a.ok?{_tag:"ok",models:b.models??[]}:{_tag:"error",message:b.error||"Failed to fetch models"}},catch:a=>new e.uV({message:"fetch ollama models failed",cause:a})}),C=()=>d.ivC(async()=>{let a=await fetch("/api/ollama/default-model");if(a.ok)return(await a.json()).model||void 0}).pipe(d.DM4(()=>void 0)),D=a=>d.JkU(function*(){let b=yield*B();if("not-running"!==b._tag)return b;a&&(yield*d.OH5(a));let c=yield*d.$mh({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*B();return"not-running"===f._tag?{_tag:"error",message:f.reason??b.reason??"Ollama started but cannot fetch models"}:f}),E=a=>f(`/api/file?path=${encodeURIComponent(a)}`),F=()=>f("/api/claude-stats"),G=a=>Array.isArray(a.items),H=()=>f("/api/instructions/config?scope=global"),I=a=>f(`/api/instructions/config?cwd=${encodeURIComponent(a)}`),J=a=>g("/api/instructions/config",a),K=()=>f("/api/output-styles/config"),L=a=>g("/api/output-styles/config",{styles:a})},41233:(a,b,c)=>{"use strict";c.d(b,{w:()=>f});var d=c(48249);let e="font-mono text-[9px] font-medium leading-none tabular-nums transition-colors";function f({children:a,wash:b,ring:c="",bot:g,className:h="",tooltip:i,title:j,role:k,ariaLabel:l,ariaHidden:m}){let n={title:j,role:k,"aria-label":l,"aria-hidden":m?"true":void 0,"data-tooltip":i??(g?`@${g}`:void 0)};return g?(0,d.jsx)("span",{className:`relative -m-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center ${c} ${h}`,...n,children:(0,d.jsx)("span",{className:`session-number-bot flex h-full w-full items-center justify-center ${e} ${b}`,children:(0,d.jsx)("span",{className:"translate-y-[1.5px]",children:a})})}):(0,d.jsx)("span",{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border ${e} ${c} ${b} ${h}`,...n,children:a})}},41357:(a,b,c)=>{"use strict";c.d(b,{H:()=>e});var d=c(67484);function e({cwd:a,selectedPath:b,gitStatusMap:c,renameOldPaths:f,isText:g,refreshKey:h}){let i=b?c?.get(b):void 0,j=g&&("M"===i||"R"===i),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(()=>new Set);(0,d.useRef)(new Set);let q=j&&!!b&&o.has(b);return{canDiff:j,showDiff:q,toggleDiff:(0,d.useCallback)(()=>{b&&p(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},[b]),diff:k,isLoadingDiff:m}}c(79606),c(33281),c(85655)},41830:(a,b,c)=>{"use strict";c.d(b,{N:()=>d});let d=a=>({notify:()=>{!1},subscribe:a=>{!0;return()=>void 0}})},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,filePath:h,lineSnapshot:i,container:j,onSubmit:k,onSendToAI:l,onClose:m,isChatLoading:n}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(!1),t=(0,e.useRef)(null),u=(0,e.useRef)(null),[v,w]=(0,e.useState)({x:0,y:0}),x=i?.split("\n").slice(0,5).join("\n"),y=!!i&&i.split("\n").length>5,z=()=>{!r&&p.trim()&&(s(!0),k(p.trim()))};return(0,d.jsxs)("div",{ref:t,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:v.x,top:v.y},children:[(0,d.jsxs)("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:o("comments.addComment")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:o("comments.lineRange",{start:c.start,end:c.end})})]}),h&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:h})]}),i&&(0,d.jsx)("div",{className:"px-3 py-2 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:[x,y&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:u,value:p,onChange:a=>q(a.target.value),placeholder:o("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:r,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),z()),"Escape"!==a.key||r||m()}}),(0,d.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:o(r?"comments.submitting":"comments.enterSubmit")}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-amber-11 text-amber-11 rounded-md hover:bg-amber-9/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:z,disabled:r||!p.trim(),children:o("comments.submitComment")}),l&&(0,d.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>{!r&&!n&&l&&p.trim()&&(s(!0),l(p.trim()),m())},disabled:r||n||!p.trim(),title:n?o("comments.aiResponding"):void 0,children:o("comments.sendToAI")})]})]})]})]})}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-lv2 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 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")})]})]})}},42319:(a,b,c)=>{"use strict";function d(a,b){return a?.cwd&&a.sessionId&&(a.cwd!==b.cwd||b.sessionId&&a.sessionId!==b.sessionId)?{cwd:a.cwd,sessionId:a.sessionId}:null}c.d(b,{_:()=>d})},42390:(a,b,c)=>{"use strict";c.d(b,{P:()=>f});var d=c(67484),e=c(4325);function f(){let a=(0,d.useSyncExternalStore)(e.N4,e.fX,e.fX),b=(0,d.useCallback)(()=>{(0,e._I)()},[]);return{isUpdating:a.visible&&"done"!==a.stage&&"failed"!==a.stage,start:b}}},42910:(a,b,c)=>{"use strict";c.d(b,{Z:()=>k});var d=c(48249),e=c(67484),f=c(44256),g=c(63565),h=c(33281),i=c(41224);let j={deepseek:{label:"DeepSeek",apiKeysUrl:"https://platform.deepseek.com/api_keys",modelsEndpoint:"/v1/models"},kimi:{label:"Kimi",apiKeysUrl:"https://www.kimi.com/code/console",modelsEndpoint:"/coding/v1/models"},glm:{label:"GLM",apiKeysUrl:"https://bigmodel.cn/apikey/platform",modelsEndpoint:"/coding/paas/v4/models",regions:[{id:"cn",label:"中国大陆",hint:"open.bigmodel.cn"},{id:"global",label:"International",hint:"api.z.ai"}]}};function k({engine:a,currentModel:b,onModelChange:c,onHasKeyChange:l}){let m=j[a],[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)([]),[H,I]=(0,e.useState)(null),[J,K]=(0,e.useState)(null),L=(0,e.useRef)(null),M=(0,e.useRef)(null),N=(0,e.useRef)(null),O=(0,e.useRef)(null);(0,e.useRef)(b),(0,e.useRef)(c),(0,e.useRef)(l);let[P,Q]=(0,e.useState)({top:0,left:0}),R=(0,f.F2)(),S=(0,e.useCallback)(async()=>{y(!0),C(null),I(null);let[d,e]=await Promise.all([h.t4.runPromiseExit((0,i.Hw)(a)),h.t4.runPromiseExit((0,i.td)())]);if("Failure"===d._tag){C("Failed to load settings"),y(!1);return}q(d.value.hasKey),s(d.value.maskedKey),u(""),w(!1);let f="Success"===e._tag?e.value:void 0,g=f?.engines?.[a],j=g?.builtinModel;m.regions&&K(g?.region??("en"===f?.language?"global":"cn"));let k=[];if(d.value.hasKey){let b=await h.t4.runPromiseExit((0,i.Fi)(a));"Success"===b._tag?k=b.value.models:I("Failed to load models — check the API key")}G(k);let l=k.map(a=>a.id),n=j&&l.includes(j)?j:l[0];!n||b&&l.includes(b)||c(n),y(!1)},[a,b,c,m.regions]),T=(0,e.useCallback)(async b=>{let c=await h.t4.runPromiseExit((0,i.td)()),d=("Success"===c._tag?c.value:{}).engines||{},e={...d,[a]:{...d[a]||{},builtinModel:b}};if("Failure"===(await h.t4.runPromiseExit((0,i.em)({engines:e})))._tag)throw Error("Failed to save settings")},[a]),U=(0,e.useCallback)(async b=>{K(b);let c=await h.t4.runPromiseExit((0,i.td)()),d=("Success"===c._tag?c.value:{}).engines||{};"Failure"===(await h.t4.runPromiseExit((0,i.em)({engines:{...d,[a]:{...d[a]||{},region:b}}})))._tag?C("Failed to save region"):S()},[a,S]),V=async()=>{let b=t.trim();if(!b)return;A(!0),C(null);let c=await h.t4.runPromiseExit((0,i.dQ)(a,b));"Failure"===c._tag?C("Save failed"):(q(c.value.hasKey),s(c.value.maskedKey),u(""),w(!1),S()),A(!1)},W=async()=>{A(!0),C(null);let b=await h.t4.runPromiseExit((0,i.dQ)(a,""));"Failure"===b._tag?C("Clear failed"):(q(b.value.hasKey),s(b.value.maskedKey),u(""),w(!1),G([])),A(!1)},X=async()=>{let b=await h.t4.runPromiseExit((0,i.Ny)(a));if("Failure"===b._tag||!b.value.apiKey)return void C("Copy failed");try{await navigator.clipboard.writeText(b.value.apiKey)}catch{C("Clipboard unavailable");return}C(null),E(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>E(!1),1500)},Y=async a=>{c(a);try{await T(a)}catch{}},Z=p?b||"Select model":"Set API key",$=p?void 0:g.Aw,_=b||"",aa=n?(0,d.jsx)(f.ZL,{children:(0,d.jsx)("div",{ref:M,className:`${g.ys} min-w-[280px]`,style:{top:P.top,left:P.left},children:x?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),(0,d.jsx)("a",{href:m.apiKeysUrl,target:"_blank",rel:"noopener","data-testid":`${a}-api-keys-link`,title:`Open ${m.label} API keys page`,"aria-label":`Open ${m.label} API keys page`,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]}),p&&!v?(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:r}),(0,d.jsx)("button",{onClick:X,"data-testid":`${a}-copy-api-key`,title:D?"Copied":"Copy API key","aria-label":"Copy API key",className:`p-1 rounded transition-colors ${D?"text-green-11":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,disabled:z,children:D?(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:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 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,d.jsx)("button",{onClick:()=>{w(!0),u(""),setTimeout(()=>N.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:z,children:"Edit"}),(0,d.jsx)("button",{onClick:W,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:z,children:"Clear"})]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:N,type:"password",value:t,onChange:a=>u(a.target.value),onKeyDown:a=>{"Enter"===a.key&&V()},placeholder:"sk-...",className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${g.Fx}`,autoFocus:!0}),(0,d.jsx)("button",{onClick:V,disabled:z||!t.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${g.$T}`,children:z?"Saving...":"Save"}),p&&(0,d.jsx)("button",{onClick:()=>{w(!1),u("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),B&&(0,d.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:B})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"}),m.regions&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Region"}),(0,d.jsx)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":`${a}-region-toggle`,children:m.regions.map(b=>(0,d.jsx)("button",{type:"button","data-testid":`${a}-region-${b.id}`,onClick:()=>U(b.id),title:b.hint,className:`px-2 py-0.5 ${J===b.id?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-hover"}`,children:b.label},b.id))})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"})]}),(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),H&&(0,d.jsx)("div",{className:"mb-1 text-[11px] text-red-11",children:H}),!H&&0===F.length&&(0,d.jsx)("div",{className:"mb-1 text-[11px] text-muted-foreground",children:p?`No models returned by ${m.modelsEndpoint}`:"Save an API key to list models"}),(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:F.map(a=>{var b;let c=_===a.id,e=(b=a.contextTokens)&&!(b<=0)?b>=1048576?`${Math.round(b/1048576)}M`:`${Math.round(b/1024)}K`:null;return(0,d.jsxs)("button",{onClick:()=>Y(a.id),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${c?g.yI:"text-foreground hover:bg-hover"}`,children:[(0,d.jsx)(g.hG,{selected:c}),(0,d.jsx)("span",{className:"truncate",children:a.id}),a.label&&a.label!==a.id&&(0,d.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:a.label}),e&&(0,d.jsx)("span",{className:"ml-auto pl-2 text-[10px] text-muted-foreground flex-shrink-0",children:e})]},a.id)})})]})]})})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.XY,{buttonRef:L,label:Z,labelClassName:$,title:`Configure ${m.label}`,onClick:()=>{if(!n){if(L.current){let a=L.current.getBoundingClientRect(),b=R?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;Q({top:a.bottom+4-d,left:a.left-c})}S()}o(a=>!a)},icon:(0,d.jsx)(g.eV,{engine:a}),testId:`${a}-config-picker`}),aa]})}},43037:(a,b,c)=>{"use strict";c.d(b,{E3:()=>g});var d=c(32891);function e(a){return a.classList.contains("task-list-item")}let f=/^\s*\[\/\]\s?/,g=d.YY.create({name:"markdownTaskListFix",addStorage:()=>({markdown:{parse:{updateDOM(a){var b;for(let c of Array.from(a.querySelectorAll("li"))){if(e(c))continue;let a=c.parentElement;a&&"UL"===a.tagName&&(b=c.textContent||"",/^\s*\[\/\]/.test(b)&&(!function(a){let b=a.ownerDocument.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=b.nextNode();for(;c&&!(c.nodeValue&&""!==c.nodeValue.trim());)c=b.nextNode();c&&c.nodeValue&&(c.nodeValue=c.nodeValue.replace(f,""))}(c),c.classList.add("task-list-item"),c.setAttribute("data-type","taskItem"),c.setAttribute("data-status","doing"),a.classList.add("contains-task-list")))}!function(a){for(let b of Array.from(a.querySelectorAll("ul.contains-task-list"))){let a=Array.from(b.children).filter(a=>"LI"===a.tagName);if(0===a.length)continue;let c=function(a){let b=[];for(let c of a){let a=b[b.length-1];a&&a.isTask===c.isTask?a.items.push(c):b.push({isTask:c.isTask,items:[c]})}return b}(a.map(a=>({isTask:e(a),el:a})));if(c.length<=1){c[0]?.isTask&&b.setAttribute("data-type","taskList");continue}let d=b.ownerDocument,f=d.createDocumentFragment();for(let a of c){let b=d.createElement("ul");for(let{el:c}of(a.isTask&&(b.setAttribute("class","contains-task-list"),b.setAttribute("data-type","taskList")),a.items))b.appendChild(c);f.appendChild(b)}b.replaceWith(f)}}(a)}}}})})},43209:(a,b,c)=>{"use strict";c.d(b,{Q:()=>n});var d=c(48249),e=c(67484),f=c(44384),g=c(15819),h=c(57031),i=c(88214),j=c(33281),k=c(41224),l=c(32753),m=c(74228);function n({isOpen:a,onClose:b,cwd:c,onSelectSession:o,projectNumber:p,openSessionIds:q=[]}){let{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)([]),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(""),A=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a;if(!c)return;v(!0),x(null);let b=(a=c.replace(/[^a-zA-Z0-9]/g,"-")).length<=200?a:`${a.slice(0,200)}-${function(a){let b=0;for(let c=0;c<a.length;c++)b=(b<<5)-b+a.charCodeAt(c)|0;return Math.abs(b).toString(36)}(c)}`,d=await j.t4.runPromiseExit((0,k.QW)(b));"Success"===d._tag?t(d.value):x("Failed to load sessions"),v(!1)},[c]);let B=s.filter(a=>{if(!y)return!0;let b=y.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:g.iG,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate","data-tooltip":c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{ref:A,type:"text",placeholder:r("sessions.searchSessions"),value:y,onChange:a=>z(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),y&&(0,d.jsx)("button",{onClick:()=>{z(""),A.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:r("fileBrowser.clear"),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"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[u&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:r("sessions.loadingSessions")})]})}),w&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:w})}),!u&&!w&&0===B.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:r(y?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!u&&!w&&B.length>0&&(0,d.jsx)("div",{className:g.jL,children:B.map(a=>{let e=a.path.split("/").pop()||"",f=a.sessionId||e.replace(".jsonl",""),g=q.indexOf(f);return(0,d.jsxs)("div",{onClick:()=>{let d,e;return d=a.path.split("/").pop()||"",e=a.sessionId||d.replace(".jsonl",""),void(o?(o(e,a.title),b()):(0,h.F)(i.n.OpenProject,{cwd:c,sessionId:e}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)(l.S,{engine:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":a.title,children:a.title}),p&&g>=0&&(0,d.jsx)(m.l,{projectNumber:p,sessionNumber:g+1,bot:a.bot,className:"ml-auto"})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path)})})]})]})]}):null}},43321:(a,b,c)=>{"use strict";c.d(b,{D:()=>f});let d=/^\s*[-*+]\s+(?:\\?\[ \\?\]|\\?\[[xX/]\\?\])\s*$/,e=/^\s*(```|~~~)/;function f(a){if(!a)return a;let b=a.split("\n"),c=[],f=!1;for(let a of b){if(e.test(a)){f=!f,c.push(a);continue}if(f){c.push(a);continue}d.test(a)||c.push(a)}let g=[],h=0,i=!1;for(let a of c){if(e.test(a)){i=!i,g.push(a),h=0;continue}if(!i&&""===a.trim()){if((h+=1)>=2)continue;g.push(a);continue}h=0,g.push(a)}return g.join("\n")}},43489:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,60440,23)),Promise.resolve().then(c.t.bind(c,84342,23)),Promise.resolve().then(c.t.bind(c,82265,23)),Promise.resolve().then(c.t.bind(c,35421,23)),Promise.resolve().then(c.t.bind(c,61335,23)),Promise.resolve().then(c.t.bind(c,70664,23)),Promise.resolve().then(c.bind(c,74661))},44256:(a,b,c)=>{"use strict";c.d(b,{F2:()=>m,ZL:()=>k,a9:()=>l});var d=c(48249),e=c(67484),f=c(74429);let g=()=>()=>{},h=()=>document.body,i=()=>null,j=(0,e.createContext)(null);function k({children:a}){let b=(0,e.useContext)(j),c=(0,e.useSyncExternalStore)(g,h,i),d=b??c;return d?(0,f.createPortal)(a,d):null}function l({children:a}){let[b,c]=(0,e.useState)(null);return(0,d.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,d.jsx)(j.Provider,{value:b,children:a}),(0,d.jsx)("div",{ref:c,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function m(){return(0,e.useContext)(j)}},44616:(a,b,c)=>{Promise.resolve().then(c.bind(c,67045))},46242:(a,b,c)=>{"use strict";c.d(b,{M:()=>g});var d=c(48249),e=c(88018);let f=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function g({cwd:a,filePath:b,oldRev:c,newRev:h,newNode:i}){return(0,d.jsx)(e.K,{filePath:b,oldSrc:c?f(a,c,b):null,newSrc:h?f(a,h,b):null,newNode:i})}},47276:(a,b,c)=>{"use strict";c.d(b,{m3:()=>g,mi:()=>e,ot:()=>f});var d=c(27668);let e=()=>(0,d.zi)("/api/html-apps"),f=a=>(0,d.zi)("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),g=a=>(0,d.zi)(`/api/html-apps/${encodeURIComponent(a)}`,{method:"DELETE"})},47604:(a,b,c)=>{"use strict";c.d(b,{f:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(63565),i=c(41224);let j={CNY:"\xa5",USD:"$"};function k({hasKey:a}){let{t:b}=(0,f.Bd)(),[c,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(null),q=(0,e.useCallback)(async()=>{l(!0),p(null);let a=await g.t4.runPromiseExit((0,i.he)());"Failure"===a._tag?(n(null),p(b("chat.balanceFailed",{defaultValue:"Query failed — check the API key"}))):n(a.value),l(!1)},[b]),r=m?m.balances.map(a=>`${j[a.currency]??(a.currency?`${a.currency} `:"")}${a.totalBalance}`).join(" / "):"",s=!!(m&&!m.isAvailable);return(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[c&&(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!c&&o&&(0,d.jsx)("span",{className:"text-xs text-red-11",children:o}),!c&&!o&&m&&(0,d.jsx)("span",{className:`text-xs font-mono ${s?"text-red-11":h.pe.deepseek}`,"data-tooltip":s?b("chat.balanceUnavailable",{defaultValue:"Account is not available for requests"}):void 0,"data-testid":"deepseek-balance-value",children:r||b("chat.balanceEmpty",{defaultValue:"No balance returned"})}),(0,d.jsx)("button",{type:"button","data-testid":"deepseek-balance-button",disabled:!a||c,onClick:q,"data-tooltip":a?void 0:b("chat.balanceNeedsKey",{defaultValue:"Set a DeepSeek API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:b("chat.checkBalance",{defaultValue:"Check balance"})}),(0,d.jsx)("a",{href:"https://platform.deepseek.com/usage",target:"_blank",rel:"noopener","data-testid":"deepseek-usage-link",title:b("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),"aria-label":b("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}},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")},48587:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{y:()=>k});var e=c(48249),f=c(67484),g=c(33407),h=c(62742);c(33281);var i=c(55287);c(87808),c(25419);var j=a([i]);function k({entryPath:a,entryContent:b}){let c,d=(0,f.useMemo)(()=>{let b,c;return(c=(b=a.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":b.slice(0,c)},[a]),j=(0,f.useRef)(new Map),[l,m]=(0,f.useState)([]),[n,o]=(0,f.useState)(a),[p,q]=(0,f.useState)(!0),r=l.find(a=>a.abs===n),s=l.length>1||p;return(0,e.jsxs)("div",{className:"flex h-full",children:[s&&(0,e.jsxs)("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto",children:[l.map(a=>(0,e.jsxs)("button",{onClick:()=>o(a.abs),"data-tooltip":a.rel,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 min-w-0 transition-colors ${n===a.abs?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover"}`,children:["image"===a.kind?(0,e.jsx)(g.A,{className:"w-3.5 h-3.5 flex-shrink-0"}):(0,e.jsx)(h.A,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:a.rel})]},a.abs)),p&&(0,e.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"…"})]}),(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:r?.kind==="image"?(0,e.jsx)("div",{className:"h-full flex items-center justify-center p-4 overflow-auto bg-background",children:(0,e.jsx)("img",{src:`/api/file?path=${encodeURIComponent(n)}&raw=true`,alt:(c=n.replace(/\\/g,"/")).slice(c.lastIndexOf("/")+1),className:"max-w-full max-h-full object-contain"})}):(0,e.jsx)(i.Cv,{content:j.current.get(n)??"",filePath:n,cwd:d},n)})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},48830:(a,b,c)=>{"use strict";c.d(b,{n:()=>x});var d=c(48249),e=c(67484),f=c(44384),g=c(7833),h=c(15819),i=c(10316),j=c(46674),k=c(24520),l=c(50514),m=c(15273),n=c(45231),o=c(66400),p=c(86588),q=c(82594),r=c(59347),s=c(33281),t=c(64676),u=c(40893),v=c(35857),w=c(47276);function x({isOpen:a,htmlAppPreviews:b,activeHtmlAppPreviewPath:c,onShowHtmlAppPreview:r,onMinimizeHtmlAppPreview:z,onCloseHtmlAppPreview:A,onClose:B,onOpenApp:C}){let{t:D,i18n:E}=(0,f.Bd)(),[F,G]=(0,e.useState)([]),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(""),[L,M]=(0,e.useState)(!1),[N,O]=(0,e.useState)(""),[P,Q]=(0,e.useState)(!1),[R,S]=(0,e.useState)({}),T=(0,e.useRef)(null),U=(0,e.useCallback)(async()=>{I(!0);let a=await s.t4.runPromiseExit((0,w.mi)());"Success"===a._tag?G(a.value):console.error("Failed to load html apps",a.cause),I(!1)},[]),V=(0,e.useCallback)(()=>{M(!1),B()},[B]),W=(0,e.useMemo)(()=>{let a=J.trim().toLowerCase();return a?F.filter(b=>b.name.toLowerCase().includes(a)||b.title.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):F},[F,J]),X=(0,e.useMemo)(()=>F.filter(a=>!a.builtin).length,[F]),Y=J.trim().length>0,Z=E.resolvedLanguage?.startsWith("zh")?"https://opencockpit.dev/zh/docs/agent/html-apps/":"https://opencockpit.dev/en/docs/agent/html-apps/",$=(0,e.useCallback)(async()=>{let a=N.trim();if(!a)return;Q(!0);let b=await s.t4.runPromiseExit((0,w.ot)(a));if("Success"===b._tag)b.value.alreadyExists?(0,g.oR)(D("htmlApps.alreadyAdded"),"info"):((0,g.oR)(D("htmlApps.added"),"success"),(0,v.N)()),O(""),M(!1),await U();else{let a="Fail"===b.cause._tag?b.cause.error:null,c=a?.cause,d=c instanceof Error?c.message:D("htmlApps.addFailed");(0,g.oR)(d,"error")}Q(!1)},[N,U,D]),_=(0,e.useCallback)(async a=>{"Success"===(await s.t4.runPromiseExit((0,w.m3)(a)))._tag?(G(b=>b.filter(b=>b.id!==a)),(0,v.N)()):(0,g.oR)(D("common.deleteFailed"),"error")},[D]),aa=(0,e.useCallback)(a=>{C?C(a):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),V()},[V,C]),ab=(0,e.useCallback)(a=>{C?C(a):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),z()},[z,C]),ac=(0,e.useCallback)(a=>{let b=(0,t.Xe)(a);window.open((0,t.PB)(b,window.location.origin),"_blank")},[]),ad=(0,e.useCallback)(a=>{S(b=>({...b,[a]:(b[a]||0)+1}))},[]),ae=(0,e.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,g.oR)(D("common.copiedPath"),"success")}catch{(0,g.oR)(D("common.copyFailed"),"error")}},[D]);return(0,d.jsxs)(d.Fragment,{children:[a&&(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:V}),(0,d.jsxs)("div",{className:h.aO,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:D("htmlApps.title")}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(i.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-foreground-subtle pointer-events-none"}),(0,d.jsx)("input",{ref:T,type:"text",value:J,onChange:a=>K(a.target.value),placeholder:D("htmlApps.searchPlaceholder"),className:"pl-7 pr-6 py-1 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),J&&(0,d.jsx)("button",{onClick:()=>{K(""),T.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:D("fileBrowser.clear"),children:(0,d.jsx)(j.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("button",{onClick:()=>M(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:D("htmlApps.addHtmlApp"),children:[(0,d.jsx)(k.A,{className:"w-4 h-4"})," ",D("htmlApps.add")]}),(0,d.jsx)("button",{onClick:V,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:D("common.close"),children:(0,d.jsx)(j.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:H?(0,d.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:D("common.loading")}):(0,d.jsxs)(d.Fragment,{children:[W.length>0&&(0,d.jsx)("div",{className:h.jL,children:W.map(a=>(0,d.jsx)(y,{app:a,onOpenConsole:()=>aa(a.path),onOpenExternal:()=>ac(a.path),onPreview:()=>{r({path:a.path,title:a.title,icon:a.icon}),V()},onDelete:()=>_(a.id),onCopyPath:()=>ae(a.path)},a.id))}),0===W.length&&Y&&(0,d.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:D("htmlApps.emptyNoMatch")}),!Y&&0===X&&(0,d.jsxs)("div",{className:`text-center text-muted-foreground py-8 text-sm space-y-2${W.length>0?" mt-4 border-t border-border/60":""}`,children:[(0,d.jsx)("p",{children:D("htmlApps.emptyNoApps")}),(0,d.jsxs)("p",{children:[D("htmlApps.emptyCreatePrefix")," ",(0,d.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/html"})," ",D("htmlApps.emptyCreateSuffix")]}),(0,d.jsxs)("p",{children:[(0,d.jsx)("button",{type:"button",onClick:()=>M(!0),className:"text-brand hover:underline",children:D("htmlApps.addExisting")})," \xb7 ",(0,d.jsx)("a",{href:Z,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline",children:D("htmlApps.viewDocs")})]})]})]})})]})]}),a&&L&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:()=>{P||(M(!1),O(""))}}),(0,d.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-lg mx-4 p-5",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:D("htmlApps.addHtmlApp")}),(0,d.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:D("htmlApps.pathLabel")}),(0,d.jsx)("input",{type:"text",value:N,onChange:a=>O(a.target.value),onKeyDown:a=>{"Enter"!==a.key||P||$()},placeholder:"/Users/you/.../report.html",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,d.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,d.jsx)("button",{onClick:()=>{M(!1),O("")},disabled:P,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:D("common.cancel")}),(0,d.jsx)("button",{onClick:$,disabled:P||!N.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:P?D("htmlApps.adding"):D("htmlApps.add")})]})]})]}),b.map(a=>{let b=c===a.path;return(0,d.jsx)("div",{className:b?"fixed inset-0 z-[60] flex items-center justify-center bg-scrim p-0 md:p-4":"hidden",onClick:z,children:(0,d.jsxs)("div",{className:"bg-card shadow-lv3 border border-brand/30 w-full h-full md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.icon?(0,d.jsx)("span",{className:"text-base leading-none flex-shrink-0",children:a.icon}):(0,d.jsx)(l.A,{className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[35%]","data-tooltip":a.title,children:a.title}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground flex-shrink-0","aria-hidden":"true",children:"-"}),(0,d.jsx)("span",{className:"font-mono text-sm text-muted-foreground truncate min-w-0","data-tooltip":a.path,children:a.path}),(0,d.jsx)("button",{onClick:()=>ae(a.path),className:"text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.copyPath"),"aria-label":D("common.copyPath"),children:(0,d.jsx)(m.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("button",{onClick:z,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.minimize"),children:(0,d.jsx)(n.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ab(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.openInConsole"),children:(0,d.jsx)(o.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ac(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("browser.openInNewWindow"),children:(0,d.jsx)(p.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ad(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.refresh"),children:(0,d.jsx)(q.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>A(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,d.jsx)(u.O,{filePath:a.path,reloadKey:R[a.path]||0})})]})},a.path)})]})}function y({app:a,onOpenConsole:b,onOpenExternal:c,onPreview:g,onDelete:h,onCopyPath:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:`group flex flex-col h-full border border-border rounded-lg p-3 hover:border-brand hover:shadow-lv2 transition-all cursor-pointer ${a.valid?"":"opacity-60"}`,onClick:()=>a.valid&&g(),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,d.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,d.jsx)("span",{children:a.icon}):(0,d.jsx)(p.A,{className:"w-5 h-5"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground truncate","data-tooltip":a.title,children:a.title}),(0,d.jsxs)("div",{className:"font-mono text-[11px] text-muted-foreground truncate","data-tooltip":`/${a.name}`,children:["/",a.name]})]}),!a.valid&&(0,d.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:j("htmlApps.invalid")}),a.builtin&&(0,d.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:j("htmlApps.builtin")}),(0,d.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("button",{onClick:b,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:j("common.openInConsole"),children:(0,d.jsx)(o.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:c,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:j("browser.openInNewWindow"),children:(0,d.jsx)(p.A,{className:"w-4 h-4"})}),a.builtin?null:k?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>{l(!1),h()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:j("common.confirm")}),(0,d.jsx)("button",{onClick:()=>l(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:j("common.cancel")})]}):(0,d.jsx)("button",{onClick:()=>l(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:j("common.delete"),children:(0,d.jsx)(r.A,{className:"w-4 h-4"})})]})]}),(0,d.jsxs)("div",{className:"font-mono text-xs text-muted-foreground mt-2 break-all",children:[a.path,(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),i()},className:"inline-flex align-middle ml-1 p-0.5 hover:text-foreground hover:bg-hover rounded transition-colors",title:j("common.copyPath"),children:(0,d.jsx)(m.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("p",{className:"text-sm text-muted-foreground mt-2 pt-2 border-t border-border/60 break-words whitespace-pre-wrap",children:a.description||(0,d.jsx)("span",{className:"italic opacity-60",children:j("htmlApps.noDescription")})})]})}},50508:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{LD:()=>l,Mm:()=>j,Qr:()=>a,fw:()=>i,o$:()=>k});var e=c(48249),f=c(67484),g=c(33281),h=c(85655);let a=a=>a.split("/").pop()||a;function i(a,b){let c=Math.floor((Date.now()-b)/6e4);if(c<1)return a("common.justNow");if(c<60)return a("common.minutesAgo",{count:c});let d=Math.floor(c/60);return d<24?a("common.hoursAgo",{count:d}):a("common.daysAgo",{count:Math.floor(d/24)})}function j(a,b){return"loading"===b?a("sessions.running"):"unread"===b?a("sessions.done"):void 0}function k(){let[a,b]=(0,f.useState)(null),[c,d]=(0,f.useState)({}),e=(0,f.useCallback)((a,c)=>{let e=c.currentTarget.getBoundingClientRect(),f=e.top;f+260>window.innerHeight&&(f=Math.max(8,window.innerHeight-260-8)),b({session:a,top:f,left:e.right+8}),d(b=>a.cwd in b?b:(g.t4.runPromiseExit((0,h.ue)(a.cwd)).then(b=>{"Success"===b._tag&&d(c=>({...c,[a.cwd]:b.value.branch}))}),{...b,[a.cwd]:null}))},[]),i=(0,f.useCallback)(()=>b(null),[]);return{card:a,branch:a?c[a.session.cwd]??null:null,show:e,hide:i}}function l({card:b,branch:c}){if(!b)return null;let{session:d}=b,f=(d.firstMessages?.length??0)>0||(d.lastMessages?.length??0)>0;return(0,e.jsxs)("div",{className:"fixed z-[60] w-72 max-h-[260px] overflow-y-auto bg-popover border border-border rounded-lg shadow-lv2 p-3 pointer-events-none",style:{top:b.top,left:b.left},children:[(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:a(d.cwd)}),d.title&&(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate mt-0.5",children:d.title}),(0,e.jsx)("div",{className:"text-[10px] text-foreground-faint truncate mt-0.5",children:d.cwd}),c&&(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:c})]}),f?(0,e.jsxs)("div",{className:"space-y-0.5 text-xs border-t border-border/50 mt-2 pt-2",children:[d.firstMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`f-${b}`)),(d.lastMessages?.length??0)>0&&(0,e.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),d.lastMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`l-${b}`))]}):d.lastUserMessage?(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:d.lastUserMessage}):null]})}d()}catch(a){d(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)},53087:(a,b,c)=>{"use strict";c.d(b,{fz:()=>d,mg:()=>e});let d=50;function e(a){var b;let c=0;for(;c<a.length-1&&(!0===(b=a[c]).truncated||b.files.length>=d);)c++;return c}},53954:(a,b,c)=>{"use strict";c.d(b,{d:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(36043);c(33281),c(65484);let h=(0,e.memo)(function({entry:a,index:b,highlighted:c,top:e,onEnter:f,onPick:g,onHover:h}){return(0,d.jsxs)("div",{role:"option","aria-selected":c,onClick:()=>f(a.path),onDoubleClick:()=>g(a.path),onMouseMove:()=>h(b),style:{position:"absolute",top:e,left:0,right:0,height:30},className:`flex items-center gap-2 px-3 text-xs cursor-pointer select-none ${c?"bg-hover text-foreground":"text-foreground"} ${a.hidden?"opacity-60":""}`,children:[(0,d.jsx)("svg",{className:"w-4 h-4 shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,d.jsx)("span",{className:"flex-1 truncate",children:a.name}),a.git&&(0,d.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground border border-border rounded px-1",children:"git"})]})});function i({onPick:a}){let b,c,j,{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(-1),v=(0,e.useRef)(null),w=(0,e.useRef)(null);(0,e.useRef)(0);let x=n?.sep??"/",{base:y,prefix:z}=(b="\\"===x?Math.max(l.lastIndexOf("/"),l.lastIndexOf("\\")):l.lastIndexOf("/"),c=l.slice(0,b+1),j=l.slice(b+1),""===c&&"~"===j?{base:"~",prefix:""}:{base:c,prefix:j}),A=p!==y,B=(0,e.useMemo)(()=>{if(!n)return[];let a=z.toLowerCase(),b=n.dirs.filter(b=>r||!b.hidden||a.startsWith("."));return a?[...b.filter(b=>b.name.toLowerCase().startsWith(a)),...b.filter(b=>!b.name.toLowerCase().startsWith(a)&&b.name.toLowerCase().includes(a))]:b},[n,z,r]),C=(0,e.useMemo)(()=>!n||n.error||A?null:z?B.find(a=>a.name.toLowerCase()===z.toLowerCase())?.path??null:n.path,[n,z,B,A]),D=(0,e.useCallback)(a=>{m(a.endsWith(x)?a:a+x),v.current?.focus()},[x]),E=(0,g.Te)({count:B.length,getScrollElement:()=>w.current,estimateSize:()=>30,overscan:8}),F=n?.error&&!A?k(`folderPicker.${n.error}`):null;return(0,d.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col gap-2 p-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:v,type:"text",value:l,onChange:a=>m(a.target.value),onKeyDown:b=>{if("Enter"===b.key&&(b.metaKey||b.ctrlKey))b.preventDefault(),C&&a(C);else if("ArrowDown"===b.key)b.preventDefault(),u(a=>Math.min(a+1,B.length-1));else if("ArrowUp"===b.key)b.preventDefault(),u(a=>Math.max(a-1,0));else if("Tab"===b.key||"Enter"===b.key){let a=B[t];a?(b.preventDefault(),D(a.path)):"Tab"===b.key&&b.preventDefault()}},placeholder:k("folderPicker.placeholder"),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"flex-1 min-w-0 px-2.5 py-1.5 text-xs font-mono border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,d.jsx)("button",{onClick:()=>C&&a(C),disabled:!C,"data-tooltip":C??void 0,className:"shrink-0 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",children:k("folderPicker.open")})]}),(0,d.jsx)("div",{className:"flex items-center gap-0.5 min-h-6 overflow-x-auto text-xs text-muted-foreground whitespace-nowrap",children:n?.segments.map((a,b)=>(0,d.jsxs)("span",{className:"flex items-center",children:[b>1&&(0,d.jsx)("span",{className:"px-0.5 text-foreground-subtle",children:"›"}),(0,d.jsx)("button",{onClick:()=>D(a.path),className:"px-1 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:a.name})]},a.path))}),(0,d.jsx)("div",{ref:w,role:"listbox",className:`flex-1 min-h-0 overflow-y-auto border border-border rounded transition-opacity ${A?"opacity-60":""}`,children:F?(0,d.jsx)("div",{className:"p-3 text-xs text-red-11",children:F}):n&&0===B.length?(0,d.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:k(z?"folderPicker.noMatch":"folderPicker.empty")}):(0,d.jsx)("div",{style:{height:E.getTotalSize(),position:"relative"},children:E.getVirtualItems().map(b=>(0,d.jsx)(h,{entry:B[b.index],index:b.index,highlighted:b.index===t,top:b.start,onEnter:D,onPick:a,onHover:u},B[b.index].path))})}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[n&&(0,d.jsx)("button",{onClick:()=>D(n.home),className:"px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:"~"}),n?.roots.map(a=>(0,d.jsx)("button",{onClick:()=>D(a),className:"px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors font-mono",children:a},a))]}),(0,d.jsxs)("label",{className:"flex items-center gap-1 text-muted-foreground cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:r,onChange:a=>s(a.target.checked)}),k("folderPicker.showHidden")]}),(0,d.jsx)("span",{className:"hidden md:inline text-foreground-subtle",children:k("folderPicker.hint")})]})]})}},54727:(a,b,c)=>{"use strict";c.d(b,{y:()=>q});var d=c(32891),e=c(10259),f=c(1370);function g(a){let b=[];return a.forEach((a,c)=>b.push({node:a,start:c,end:c+a.nodeSize})),b}function h(a,b){return"heading"===a.type.name&&a.attrs.level<=b}function i(a){for(let b=a.depth;b>0;b--){let c=a.node(b).type.name;if("listItem"===c||"taskItem"===c)return b}return -1}function j(a,b,c,d,e){let f=b.slice(c,d),g=b.slice(d,e);a.replaceWith(c,e,g.content.append(f.content))}function k(a,b){let c=Math.max(0,Math.min(b,a.doc.content.size));a.setSelection(e.U3.near(a.doc.resolve(c)))}let l=new Set(["paragraph","bulletList","orderedList","taskList"]);function m(a,b,c){let{doc:d,selection:e}=a,h=e.$from,i=h.before(1),j=g(d),m=j.findIndex(a=>a.start===i);if(m<0)return!1;let n=m;for(;n>0&&l.has(j[n-1].node.type.name);)n--;let o=m;for(;o<j.length-1&&l.has(j[o+1].node.type.name);)o++;let p=[],q=-1,r="paragraph"===j[m].node.type.name?-1:h.index(1);for(let a=n;a<=o;a++){let b=j[a].node;if("paragraph"===b.type.name)a===m&&(q=p.length),p.push({kind:"paragraph",node:b});else{let c=b.type.name,d=0;b.forEach(b=>{a===m&&d===r&&(q=p.length),p.push({kind:c,node:b}),d++})}}if(q<0)return!1;let s=q+(c>0?1:-1);if(s<0||s>=p.length)return!1;if(b){let c,d,e,g=p[q];p[q]=p[s],p[s]=g;let i=function(a,b){let c=[],d=0;for(;d<a.length;){if("paragraph"===a[d].kind){c.push(a[d].node),d++;continue}let e=a[d].kind,f=[];for(;d<a.length&&a[d].kind===e;)f.push(a[d].node),d++;c.push(b.schema.nodes[e].create(null,f))}return f.FK.from(c)}(p,a),l=j[n].start,m=j[o].end,r=a.tr;r.replaceWith(l,m,i);let t=(c=0,d=0,e=-1,i.forEach(a=>{if(!(e>=0))if("paragraph"===a.type.name)c===s&&(e=d+1),c++,d+=a.nodeSize;else{let b=d+1;a.forEach(a=>{e>=0||(c===s&&(e=b+2),c++,b+=a.nodeSize)}),d+=a.nodeSize}}),e);k(r,t>=0?l+t+h.parentOffset:l),b(r.scrollIntoView())}return!0}function n(a,b,c){let d=a.selection.$from;if(1===d.depth&&"heading"===d.parent.type.name)return function(a,b,c){let{doc:d,selection:e}=a,f=e.$from.before(1),i=g(d),l=i.findIndex(a=>a.start===f);if(l<0)return!1;let m=i[l].node.attrs.level,n=l+1;for(;n<i.length&&!h(i[n].node,m);)n++;let o=i[l].start,p=i[n-1].end;if(c>0){if(n>=i.length)return!1;let c=i[n].node.attrs.level,f=n+1;for(;f<i.length&&!h(i[f].node,c);)f++;let g=i[f-1].end;if(b){let c=a.tr,f=d.slice(p,g).content.size;j(c,d,o,p,g),k(c,o+f+(e.from-o)),b(c.scrollIntoView())}return!0}if(0===l)return!1;let q=l-1;for(;q>=0&&!h(i[q].node,m);)q--;if(q<0||i[q].node.attrs.level<m)return!1;let r=i[q].start;if(b){let c=a.tr;j(c,d,r,o,p),k(c,r+(e.from-o)),b(c.scrollIntoView())}return!0}(a,b,c);let e=i(d);if(e>0){let f=d.node(e-1),g=d.index(e-1);return(c>0?g<f.childCount-1:g>0)?function(a,b,c,d){let{doc:e,selection:f}=a,g=f.$from,h=g.node(d),i=g.node(d-1),l=g.index(d-1),m=g.before(d),n=m+h.nodeSize;if(c>0){if(l>=i.childCount-1)return!1;let c=n+i.child(l+1).nodeSize;if(b){let d=a.tr,g=e.slice(n,c).content.size;j(d,e,m,n,c),k(d,m+g+(f.from-m)),b(d.scrollIntoView())}return!0}if(l<=0)return!1;let o=m-i.child(l-1).nodeSize;if(b){let c=a.tr;j(c,e,o,m,n),k(c,o+(f.from-m)),b(c.scrollIntoView())}return!0}(a,b,c,e):2===e&&m(a,b,c)}let f=d.depth>=1?d.node(d.depth-1).type.name:"doc";return"paragraph"===d.parent.type.name&&"doc"===f&&m(a,b,c)}function o(a,b){let{state:c}=a,d=c.selection.$from,e=d.parent.type.name;if("doc"===(d.depth>=1?d.node(d.depth-1).type.name:"doc")&&("heading"===e||"paragraph"===e)){let c=(("heading"===e?d.parent.attrs.level-1:3)+(b>0?1:-1)+4)%4;return 3===c?a.chain().setParagraph().run():a.chain().setHeading({level:c+1}).run()}let f=i(d);if(f>0){let c=d.node(f).type.name;return b<0?a.commands.liftListItem(c):a.commands.sinkListItem(c)}return!1}function p(a,b){let{state:c}=a,d=c.selection;if(!d.empty)return!1;let e=d.$from,f=b>0?1:-1;for(let b=e.depth;b>0;b--)if("taskItem"===e.node(b).type.name){let d=e.before(b),g=c.doc.nodeAt(d);if(!g)return!1;let h=g.attrs.status??"todo",i=(("doing"===h?2:"done"===h?3:1)+f+4)%4;if(0===i)return a.chain().toggleTaskList().run();let j=2===i?"doing":3===i?"done":"todo";return a.chain().command(({tr:a})=>{let b=a.doc.nodeAt(d);return!!b&&(a.setNodeMarkup(d,void 0,{...b.attrs,status:j}),!0)}).run()}if("paragraph"!==e.parent.type.name)return!1;let g=e.depth>=1?e.node(e.depth-1).type.name:"doc";return("doc"===g||"listItem"===g)&&(1==(0+f+4)%4?a.chain().toggleTaskList().run():a.chain().toggleTaskList().command(({tr:a})=>(function(a,b){let c=a.selection.$from;for(let d=c.depth;d>0;d--)if("taskItem"===c.node(d).type.name){let e=c.before(d),f=a.doc.nodeAt(e);f&&a.setNodeMarkup(e,void 0,{...f.attrs,status:b});break}return!0})(a,"done")).run())}let q=d.YY.create({name:"noteOrgKeymap",addKeyboardShortcuts(){return{"Alt-ArrowUp":()=>this.editor.commands.command(({state:a,dispatch:b})=>n(a,b,-1)),"Alt-ArrowDown":()=>this.editor.commands.command(({state:a,dispatch:b})=>n(a,b,1)),"Alt-ArrowLeft":()=>o(this.editor,-1),"Alt-ArrowRight":()=>o(this.editor,1),"Shift-ArrowRight":()=>p(this.editor,1),"Shift-ArrowLeft":()=>p(this.editor,-1)}}})},55287:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cv:()=>C,XO:()=>A});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(33281),j=c(87808),k=c(25419),l=c(7122),m=c(42140),n=c(38896),o=c(36984),p=c(41051),q=c(70596),r=c(40159),s=c(13512),t=c(9804),u=c(7833),v=c(83377),w=a([s]);s=(w.then?(await w)():w)[0];let B="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function x(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 y(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 z(a){return a.map(a=>`<div style="${B}">${a}</div>`).join("")}let C=(0,f.forwardRef)(function({content:a,filePath:b,showLineNumbers:c=!0,showSearch:d=!0,className:n="",cwd:w,enableComments:A=!1,scrollToLine:C=null,scrollToLineAlign:D="center",onScrollToLineComplete:E,highlightKeyword:F=null,visibleLineRef:G,onCmdClick:H,onTokenHover:I,onTokenHoverLeave:J,onTokenHoverCancel:K,blameLines:L,inlineBlameLines:M,onSelectCommit:N,editable:O=!1,initialMtime:P,onEditorClose:Q,onSaved:R,onEditorStateChange:S,viMode:T=!1,onContentMutate:U,onEnterInsertMode:V,onViSave:W,viStateRef:X,initialCursorLine:Y,initialCursorCol:Z,onInitialCursorSet:$,onContentSearch:_},aa){let{t:ab}=(0,g.Bd)(),ac=(0,f.useRef)(a),ad=(0,f.useRef)(!1),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(()=>a.split("\n").length),ak=(0,f.useRef)(a.split("\n").length),[al,am]=(0,f.useState)({show:!1}),an=(0,f.useRef)(null),ao=(0,f.useRef)(null),ap=(0,f.useRef)(P),aq=(0,f.useRef)(null),ar=(0,f.useRef)(!1),as=(0,f.useRef)(!1),{parentRef:at,containerRef:au,searchInputRef:av,floatingToolbarRef:aw,suppressHoverRef:ax,bumpToolbarRef:ay,savedSelectionRef:az,highlightedLines:aA,isMounted:aB,cmdHeld:aC,flashLine:aD,isSearchVisible:aE,searchQuery:aF,caseSensitive:aG,wholeWord:aH,currentMatchIndex:aI,viewingComment:aJ,addCommentInput:aK,sendToAIInput:aL,aiBridge:aM,commentsEnabled:aN,updateComment:aO,deleteComment:aP,lines:aQ,matches:aR,rowData:aS,virtualizer:aT,commentsByEndLine:aU,linesWithComments:aV,setIsSearchVisible:aW,setSearchQuery:aX,setCaseSensitive:aY,setWholeWord:aZ,setViewingComment:a$,setAddCommentInput:a_,setSendToAIInput:a0,goToNextMatch:a1,goToPrevMatch:a2,handleSearchKeyDown:a3,handleCommentBubbleClick:a4,handleToolbarAddComment:a5,handleToolbarSendToAI:a6,handleToolbarExplain:a7,handleToolbarSearch:a8,handleCommentSubmit:a9,handleSendToAISubmit:ba,handleCommentSendToAI:bb,getHighlightedLineHtml:bc,suppressMatchScrollRef:bd,inlineBlameLineRef:be,inlineBlameVersion:bf}=(0,s.d)({content:a,filePath:b,showSearch:d,cwd:w,enableComments:!O&&A,scrollToLine:O?null:C,scrollToLineAlign:O?"center":D,onScrollToLineComplete:O?void 0:E,visibleLineRef:O?void 0:G,onContentSearch:_}),bg=(0,l.iN)(),bh=(0,f.useRef)(null),bi=(0,f.useRef)(null),bj=(0,f.useRef)({line:0,col:0}),bk=(0,f.useRef)({line:0,col:0}),bl=(0,v.A)({lines:aQ,enabled:T&&!O,onContentChange:a=>{bj.current={line:bk.current.line,col:bk.current.col},U?.(a)},onEnterInsert:(a,b,c)=>{let d=b;if("a"===c)d=b+1;else if("A"===c)d=(aQ[a]??"").length;else if("I"===c){let b=(aQ[a]??"").search(/\S/);d=b>=0?b:0}else("o"===c||"O"===c)&&(d=0);bj.current={line:a,col:d},V?.(a)},onSave:W,getVisibleLineCount:()=>{let a=at.current;return a?Math.floor(a.clientHeight/20):20},scrollToLine:(a,b)=>{let c=aS.findIndex(b=>"code"===b.type&&b.lineIndex===a);c>=0&&aT.scrollToIndex(c,{align:b||"auto"})},onSearchExecute:a=>{aX(a),aW(!1)},onSearchNext:a1,onSearchPrev:a2,onSearchClear:()=>{aX("")}});(0,f.useEffect)(()=>{X&&(X.current={cursorLine:bl.state.cursorLine,cursorCol:bl.state.cursorCol}),bk.current={line:bl.state.cursorLine,col:bl.state.cursorCol}},[X,bl.state.cursorLine,bl.state.cursorCol]);let bm=(0,f.useRef)(null);(0,f.useEffect)(()=>{T&&!O&&null!=Y&&b&&bm.current!==b&&(bm.current=b,bl.setCursorLine(Y-1),null!=Z&&bl.setCursorCol(Z-1),$?.())},[T,O,Y,Z,b]),(0,f.useEffect)(()=>{if(!T||O)return;let a=au.current;if(!a)return;let b=a=>{let b=a.target;"TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable||bl.handleKeyDown(a)&&(a.preventDefault(),a.stopPropagation())};return a.addEventListener("keydown",b,!0),()=>a.removeEventListener("keydown",b,!0)},[T,O,bl.handleKeyDown]),(0,f.useEffect)(()=>{if(!T||O)return;let a=au.current;a&&"normal"===bl.state.mode&&requestAnimationFrame(()=>{let b=document.activeElement;b&&("TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable)||a.focus()})},[T,O,bl.state.mode,a]);let bn=(0,f.useCallback)(a=>{if(!T||O)return;let b=a.target.closest("[data-line]");if(b){let c=parseInt(b.getAttribute("data-line"),10);if(!isNaN(c)){bl.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=aQ[c-1]??"";bl.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=au.current;d&&d.focus()},[T,O,bl.setCursorLine,bl.setCursorCol,aQ]),bo=(0,f.useCallback)(a=>{T&&!O&&requestAnimationFrame(()=>{let a=window.getSelection(),b=a?.toString().trim();b&&/^\S+$/.test(b)&&(bd.current=!0,aX(b))})},[T,O,aX,bd]);(0,f.useEffect)(()=>{"command"===bl.state.mode?setTimeout(()=>bh.current?.focus(),0):"search"===bl.state.mode&&setTimeout(()=>bi.current?.focus(),0)},[bl.state.mode]),(0,f.useEffect)(()=>{let a=at.current;if(!a)return;let b=()=>{(K??J)?.()};return a.addEventListener("mousedown",b),()=>a.removeEventListener("mousedown",b)},[K,J]),(0,f.useEffect)(()=>{aK||aL?(ax.current=!0,J?.()):aw.current||(ax.current=!1)},[aK,aL,J]),(0,f.useLayoutEffect)(()=>{let a=az.current;if(!a)return;let b=window.getSelection();if(b&&!b.isCollapsed)return;let c=at.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,s.o)(d,a.startOffset),g=(0,s.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 bp=(0,f.useCallback)((a,b,c)=>{ax.current||I?.(a,b,c)},[I]),bq=(0,f.useCallback)((a,b)=>{ax.current||H?.(a,b)},[H]),br=Math.max(4,String(O?ai:aQ.length).length),bs=(0,f.useMemo)(()=>{let a=0;for(let b of aQ){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},[aQ]);(0,f.useEffect)(()=>{if(O){ac.current=a;let b=a.split("\n").length;ak.current=b,aj(b),ad.current=!1,af(!1),am({show:!1}),ap.current=P}},[O,a,P]),(0,f.useEffect)(()=>{if(!O)return;let b=an.current;if(!b)return;let c=a.split("\n"),d=c.map((a,b)=>aA[b]||(0,o.ZD)(a||" "));b.innerHTML=z(d),requestAnimationFrame(()=>{let a,d;T?(a=Math.max(0,Math.min(bj.current.line,c.length-1)),d=bj.current.col):(a=Math.max(0,Math.min((G?.current??1)-1,c.length-1)),d=0),b.focus(),y(b,{line:a,offset:d});let e=G?.current??1;ao.current&&(ao.current.scrollTop=(e-1)*20)})},[O]),(0,f.useEffect)(()=>{O&&S?.({isDirty:ae,isSaving:ag})},[O,ae,ag,S]);let bt=(0,f.useCallback)(()=>{let a=an.current;if(!a)return ac.current;let b=[];for(let c of a.childNodes){let a=c.textContent||"";b.push(" "===a?"":a)}return b.join("\n")},[]),bu=(0,f.useCallback)(()=>{aq.current&&clearTimeout(aq.current),aq.current=setTimeout(async()=>{let a=an.current;if(a&&!as.current){ac.current=bt();try{let c=await (0,o.kS)(),d=(0,o.sQ)(b),e=document.documentElement.classList.contains("dark"),f=ac.current.split("\n"),g=c.codeToTokens(f.join("\n"),{lang:d,theme:e?"github-dark":"github-light"}).tokens.map(a=>(0,o.b8)(a)),h=x(a);ar.current=!0,a.innerHTML=z(g),ar.current=!1,h&&y(a,h)}catch{}}},300)},[b,bt]);(0,f.useEffect)(()=>{if(O)return()=>{aq.current&&clearTimeout(aq.current)}},[O]);let bv=(0,f.useCallback)(()=>{let a=an.current;if(!a)return;ad.current||(ad.current=!0,af(!0));let b=a.children.length;b!==ak.current&&(ak.current=b,aj(b))},[]),bw=(0,f.useCallback)(()=>{ar.current||as.current||(bv(),bu())},[bv,bu]),bx=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing&&("Tab"===a.key&&(a.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===a.key)){a.preventDefault();let b=an.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=x(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,o.ZD)(j||" ");let l=document.createElement("div");l.setAttribute("style",B),l.innerHTML=(0,o.ZD)(k||" "),e.after(l),y(b,{line:g+1,offset:0}),bv(),bu()}},[bv,bu]),by=(0,f.useCallback)(a=>{a.preventDefault();let b=a.clipboardData.getData("text/plain");document.execCommand("insertText",!1,b)},[]),bz=(0,f.useCallback)(async(a=!1)=>{if(!w)return;ac.current=bt(),ah(!0);let c=await i.t4.runPromiseExit((0,j.OJ)({cwd:w,path:b,content:ac.current,expectedMtime:a?void 0:ap.current}));if("Failure"===c._tag){console.error("Error saving file:",c.cause),(0,u.oR)(ab("toast.saveFailed"),"error"),ah(!1);return}let d=c.value,e=d.data;if(409===d.status&&e?.conflict){let a=await i.t4.runPromiseExit((0,k.K)(w,b));"Success"===a._tag&&a.value.ok&&"string"==typeof a.value.data?.content?am({show:!0,diskContent:a.value.data.content}):am({show:!0}),ah(!1);return}if(!d.ok){console.error("Error saving file: status",d.status),(0,u.oR)(ab("toast.saveFailed"),"error"),ah(!1);return}let f=e?.mtime;f&&(ap.current=f),ad.current=!1,af(!1),am({show:!1}),(0,u.oR)(ab("toast.savedSuccess"),"success"),R?.(),ah(!1)},[w,b,bt,R,ab]),bA=(0,f.useCallback)(async()=>{ae&&!ag&&await bz(!1)},[ae,ag,bz]),bB=(0,f.useCallback)(async()=>{am({show:!1}),await bz(!0)},[bz]),bC=(0,f.useCallback)(()=>{if(void 0!==al.diskContent){ac.current=al.diskContent;let b=al.diskContent.split("\n").length;ak.current=b,aj(b);let c=al.diskContent!==a;ad.current=c,af(c);let d=an.current;if(d){let a=al.diskContent.split("\n");d.innerHTML=z(a.map(a=>(0,o.ZD)(a||" "))),bu()}}am({show:!1}),R?.()},[al.diskContent,a,R,bu]),bD=(0,f.useCallback)(()=>{let a=ao.current;return a?Math.floor(a.scrollTop/20)+1:G?.current??1},[G]),bE=(0,f.useCallback)(async()=>{(!ae||await (0,u.lJ)(ab("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ab("codeViewer.discardChanges"),cancelText:ab("codeViewer.continueEditing")}))&&Q?.(bD())},[ae,Q,bD]);(0,f.useEffect)(()=>{if(!O)return;let a=a=>{(a.metaKey||a.ctrlKey)&&"s"===a.key&&(a.preventDefault(),bA())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[O,bA]);let bF=(0,f.useCallback)(()=>{let a=bt();U?.(a);let b=an.current,c=b?x(b):null,d=bD();if(bl.enterNormal(),c){bl.setCursorLine(c.line);let b=a.split("\n")[c.line]??"";bl.setCursorCol(Math.max(0,Math.min(c.offset,Math.max(0,b.length-1))))}else bl.setCursorLine(Math.max(0,d-1));Q?.(d)},[bt,U,bD,Q,bl]);(0,f.useEffect)(()=>{if(!O)return;let a=a=>{let b="Escape"===a.key,c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;(b||T&&c)&&(a.preventDefault(),a.stopPropagation(),T?ad.current?(0,u.lJ)(ab("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ab("codeViewer.discardChanges"),cancelText:ab("codeViewer.continueEditing")}).then(a=>{a&&bF()}):bF():bE())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[O,T,bE,bF]);let bG=(0,f.useCallback)(()=>{ad.current||(ad.current=!0,af(!0))},[]);(0,f.useImperativeHandle)(aa,()=>({save:bA,close:bE,markDirty:bG,get isDirty(){return ad.current},get isSaving(){return ag}}),[bA,bE,bG,ag]);let bH=!!(L&&L.length>0),bI=(0,f.useMemo)(()=>{if(!L)return new Map;let a=[...new Set(L.map(a=>a.author))],b=new Map;return a.forEach((a,c)=>{b.set(a,r.j[c%r.j.length])}),b},[L]),[bJ,bK]=(0,f.useState)(null),[bL,bM]=(0,f.useState)(null);(0,f.useEffect)(()=>{bK(null),bM(null)},[L]);let bN=(0,f.useCallback)((a,b)=>{bK(a.author);let c=b.currentTarget.getBoundingClientRect();bM({line:a,x:c.right+8,y:c.top})},[]),bO=(0,f.useCallback)(()=>{bK(null),bM(null)},[]),bP=(0,f.useCallback)(a=>{if(!N)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};N(b),bM(null)},[N]),bQ=`${br+2}ch`;return(0,e.jsxs)("div",{ref:au,className:`h-full flex flex-col outline-none ${n}`,tabIndex:0,onClick:bn,onDoubleClick:bo,children:[O&&al.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-11 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:ab("codeViewer.fileModifiedExternally")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bC,className:"px-3 py-1 text-sm rounded border border-border hover:bg-hover transition-colors",children:ab("codeViewer.useDiskVersion")}),(0,e.jsx)("button",{onClick:bB,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ab("codeViewer.forceOverwrite")})]})]}),!O&&d&&aE&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)("input",{ref:av,type:"text",value:aF,onChange:a=>aX(a.target.value),onKeyDown:a3,placeholder:ab("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:()=>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-hover"}`,title:ab("codeViewer.caseSensitive"),children:"Aa"}),(0,e.jsx)("button",{onClick:()=>aZ(!aH),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aH?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ab("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aR.length>0?`${aI+1}/${aR.length}`:ab("common.noMatch")}),(0,e.jsx)("button",{onClick:a2,disabled:0===aR.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ab("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:a1,disabled:0===aR.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ab("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:()=>{aW(!1),aX("")},className:"p-1 rounded hover:bg-hover",title:ab("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"})})})]}),O?(0,e.jsx)("div",{ref:ao,className:"flex-1 overflow-auto bg-card",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-card",style:{width:bQ},children:Array.from({length:ai},(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:an,contentEditable:!0,suppressContentEditableWarning:!0,onInput:bw,onKeyDown:bx,onPaste:by,onCompositionStart:()=>{as.current=!0},onCompositionEnd:()=>{as.current=!1,bw()},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:at,className:`flex-1 overflow-auto font-mono text-sm bg-card${aC?" cmd-held-container":""}`,children:(0,e.jsx)("div",{style:{height:`${aT.getTotalSize()}px`,minWidth:"100%",width:bH?`calc(${br+bs+10}ch + 13rem)`:`${br+bs+10}ch`,position:"relative"},children:aT.getVirtualItems().map(a=>{let b=aS[a.index];if("code"!==b.type)return null;let d=b.lineIndex,f=d+1,g=aA[d]||(0,o.ZD)(aQ[d]||""),h=bc(d,g,F),i=aV.has(f),j=aU.get(f),k=j?.[0],l=!!(aK&&f>=aK.range.start&&f<=aK.range.end),m=bf>=0?be.current:null,n=!O&&M&&m===f?M[d]??null:null,p=bH?L[d]:void 0,q=bH&&d>0?L[d-1]:void 0,s=!!p&&(!q||q.hash!==p.hash),t=p?bI.get(p.author):void 0;return(0,e.jsx)(r.S,{virtualKey:a.key,lineNum:f,highlightedHtml:h,hasComments:i,firstComment:k,lineCommentsCount:j?.length,isInRange:l,showLineNumbers:c,lineNumChars:br,commentsEnabled:aN,virtualItemSize:a.size,virtualItemStart:a.start,onCommentBubbleClick:a4,onCmdClick:bq,onTokenHover:bp,onTokenHoverLeave:J,flashLine:aD,blameLine:p,showBlameInfo:s,blameAuthorColor:t,isBlameHovered:!!(p&&bJ===p.author),onBlameClick:bP,onBlameMouseEnter:bN,onBlameMouseLeave:bO,inlineBlameData:n,onInlineBlameClick:bP,isCursorLine:T&&!O&&bl.state.cursorLine===d,cursorCol:T&&!O&&bl.state.cursorLine===d?bl.state.cursorCol:void 0},a.key)})})}),T&&(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"===bl.state.mode&&(0,e.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===bl.state.mode&&(0,e.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===bl.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:bh,value:bl.state.commandInput,onChange:a=>bl.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(),bl.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===bl.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:bi,value:bl.state.searchInput,onChange:a=>bl.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(),bl.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),bl.state.keyBuffer&&"normal"===bl.state.mode&&(0,e.jsx)("span",{className:"ml-2 text-muted-foreground",children:bl.state.keyBuffer}),bl.state.isDirty&&("normal"===bl.state.mode||"command"===bl.state.mode)&&(0,e.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,e.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[bl.state.cursorLine+1,":",bl.state.cursorCol+1]})]}),aB&&bg&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[!O&&(0,e.jsx)(p.fS,{floatingToolbarRef:aw,bumpRef:ay,container:bg,onAddComment:a5,onSendToAI:a6,onSearch:_?a8:void 0,onExplain:aM?a7:void 0,isChatLoading:aM?.isLoading}),!O&&aK&&(0,e.jsx)(m.t,{x:aK.x,y:aK.y,range:aK.range,filePath:b,lineSnapshot:aK.lineSnapshot,container:bg,onSubmit:a9,onSendToAI:aM?bb:void 0,onClose:()=>a_(null),isChatLoading:aM?.isLoading}),!O&&aL&&(0,e.jsx)(m.G,{x:aL.x,y:aL.y,range:aL.range,filePath:b,lineSnapshot:aL.lineSnapshot,container:bg,onSubmit:ba,onClose:()=>a0(null),isChatLoading:aM?.isLoading}),!O&&aJ&&(0,e.jsx)(q.t,{x:aJ.x,y:aJ.y,comment:aJ.comment,container:bg,onClose:()=>a$(null),onUpdateComment:aO,onDeleteComment:aP}),bL&&(0,e.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lv2 p-3 max-w-lg",style:{left:Math.min(bL.x,window.innerWidth-450),top:Math.max(8,Math.min(bL.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:bI.get(bL.line.author)?.border||"#666"},children:bL.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:bL.line.author}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:bL.line.authorEmail})]})]}),(0,e.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:bL.line.message}),(0,e.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,t.fw)(bL.line.time)," \xb7 ",new Date(1e3*bL.line.time).toLocaleString(),(0,e.jsx)("span",{className:"ml-2 text-brand",children:ab("codeViewer.clickToViewDetails")})]})]})]}),bg)]})});function A({content:a,filePath:b,className:c=""}){let d=(0,f.useMemo)(()=>a.split("\n"),[a]),g=(0,n.C)(d,b),h=Math.max(4,String(d.length).length);return(0,e.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${c}`,children:d.map((a,b)=>(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)("span",{className:"text-foreground-subtle 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,o.ZD)(a||" ")}})]},b))})}d()}catch(a){d(a)}})},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")},56444:(a,b,c)=>{"use strict";c.d(b,{$H:()=>i});var d=c(32891),e=c(6993);let f={todo:"doing",doing:"done",done:"todo"},g={todo:"false",doing:"mixed",done:"true"},h=/^\s*(\[([ x/])?\])\s$/,i=e.L.extend({addAttributes:()=>({status:{default:"todo",keepOnSplit:!1,parseHTML:a=>(function(a){let b=a.getAttribute("data-status");if("todo"===b||"doing"===b||"done"===b)return b;let c=a.getAttribute("data-checked");return""===c||"true"===c?"done":"todo"})(a),renderHTML:a=>({"data-status":a.status,"data-checked":"done"===a.status?"true":"false"})}}),addStorage:()=>({markdown:{serialize(a,b){var c;a.write(`${"done"===(c=b.attrs.status)?"[x]":"doing"===c?"[/]":"[ ]"} `),a.renderContent(b)}}}),addInputRules(){return[(0,d.tG)({find:h,type:this.type,getAttributes:a=>{let b=a[a.length-1];return{status:"x"===b?"done":"/"===b?"doing":"todo"}}})]},renderHTML({HTMLAttributes:a}){return["li",(0,d.KV)(this.options.HTMLAttributes,a,{"data-type":this.name}),0]},addNodeView(){return({node:a,getPos:b,editor:c})=>{let d=document.createElement("li");d.setAttribute("data-type",this.name);let e=document.createElement("label");e.classList.add("task-marker"),e.contentEditable="false";let h=document.createElement("span");h.classList.add("task-marker-box"),h.setAttribute("role","checkbox"),e.appendChild(h);let i=document.createElement("div");d.append(e,i);let j=a=>{let b=a.attrs.status??"todo";d.dataset.status=b,d.dataset.checked="done"===b?"true":"false",h.setAttribute("aria-checked",g[b])};return j(a),e.addEventListener("mousedown",a=>a.preventDefault()),e.addEventListener("click",a=>{if(a.preventDefault(),!c.isEditable||"function"!=typeof b)return;let d=b();"number"==typeof d&&c.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:a})=>{let b=a.doc.nodeAt(d);if(!b)return!1;let c=b.attrs.status??"todo";return a.setNodeMarkup(d,void 0,{...b.attrs,status:f[c]}),!0}).run()}),{dom:d,contentDOM:i,update:b=>b.type===a.type&&(j(b),!0)}}}})},57014:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>w});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(35208),j=c(74691),k=c(60333),l=c(73887),m=c(39238),n=c(60591),o=c(72529),p=c(85984),q=c(65543),r=c(25667),s=c(53036),t=c(88018),u=c(9804),v=a([r,i,l,m]);[r,i,l,m]=v.then?(await v)():v;let x=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function w({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:v,changedFiles:y,fileGitStatusMap:z,onContentSearch:A,locateInTree:B,setJsonPreview:C,onTokenHover:D,onTokenHoverLeave:E,onTokenHoverCancel:F}){let{t:G}=(0,g.Bd)(),H="unstaged"===b.type?{onTokenHover:D,onTokenHoverLeave:E,onTokenHoverCancel:F}:{},[I,J]=(0,f.useState)(!1),[K,L]=(0,f.useState)("file"),[M,N]=(0,f.useState)("compact"),[O,P]=(0,f.useState)("unified"),Q=b.file.path,R=b.file.oldPath||Q,S=(0,u.u)(Q),T=Q.startsWith("/")?Q:a?`${a.replace(/\/$/,"")}/${Q}`:Q,{state:U}=(0,p.V)(a,Q),V=(0,f.useMemo)(()=>{if("ready"===U.state)return U.data.functions.filter(q._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[U]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[S||"map"!==K?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:Q}),(0,e.jsx)(o.m,{content:G("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${Q}`),(0,h.oR)(G("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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)(o.m,{content:G("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),B(Q)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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?G("fileBrowser.staged"):G("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!S&&(0,e.jsx)(j.y,{value:M,onChange:N}),!S&&"file"===K&&(0,e.jsx)(k.q,{value:O,onChange:P}),!S&&(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(),L(a)},className:`px-2 py-0.5 text-xs transition-colors ${K===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:G("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:S?(0,e.jsx)(t.K,{filePath:Q,oldSrc:c.isNew?null:x(a,"staged"===b.type?"HEAD":":0","staged"===b.type?R:Q),newSrc:c.isDeleted||"staged"!==b.type?null:x(a,":0",Q),newNode:c.isDeleted||"staged"===b.type?void 0:(0,e.jsx)(s.I,{cwd:a,path:Q,className:"flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:Q})}):"unified"===O?(0,e.jsx)(i.xU,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,cwd:a,enableComments:!0,compact:"compact"===M,onPreview:!c.isDeleted&&(0,n.e$)(Q)?()=>v(!0):!c.isDeleted&&(0,n.aR)(Q)?()=>J(!0):!c.isDeleted&&Q.endsWith(".json")?()=>C({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:Q.endsWith(".json")?G("common.readable"):G("common.preview"),onContentSearch:A,...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"===M,symbols:V,onPreview:!c.isDeleted&&(0,n.e$)(Q)?()=>v(!0):!c.isDeleted&&(0,n.aR)(Q)?()=>J(!0):!c.isDeleted&&Q.endsWith(".json")?()=>C({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:Q.endsWith(".json")?G("common.readable"):G("common.preview"),onContentSearch:A,...H})})]}):(0,e.jsx)(r.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:y,fileGitStatusMap:z,enableComments:!0,compact:"compact"===M,onContentSearch:A,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=z.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o.m,{content:G("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(G("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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)(o.m,{content:G("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),B(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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?G("fileBrowser.staged"):G("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.y,{value:M,onChange:N}),(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(),L(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${K===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:G("file"===a?"common.file":"common.codeMap")},a))})]})}),d&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>v(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(l.M,{content:c.newContent,filePath:c.filePath,cwd:a,onClose:()=>v(!1)})})}),I&&(0,e.jsx)(m.N,{filePath:T,content:c.newContent,cwd:a,onClose:()=>J(!1)})]})}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.qIB(e.d,c=>c.publish(a,b)))}},57063:(a,b,c)=>{"use strict";function d(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function e(a,b=!0){}c.d(b,{E:()=>e,k:()=>d}),c(67484)},57632:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e$:()=>P,vP:()=>L,zB:()=>Q});var e=c(48249),f=c(67484),g=c(44384),h=c(79606),i=c(87819);c(57063);var j=c(7122),k=c(8410),l=c(44256),m=c(7093),n=c(99191),o=c(46674),p=c(92340),q=c(52490),r=c(67216),s=c(86718),t=c(145),u=c(20586),v=c(74691),w=c(60333),x=c(88018),y=c(35208),z=c(60591),A=c(73887),B=c(39238),C=c(18479),D=c(39247),E=c(53087),F=a([y,A,B]);function G(a,b){return{path:a.path,status:a.status,additions:a.additions,deletions:a.deletions,old_string:a.oldContent??"",new_string:a.newContent??"",unviewable:!a.isImage&&(a.binary||null===a.oldContent&&null===a.newContent),isImage:a.isImage,oldRev:a.oldRev,newRev:a.newRev,external:null!==b&&b.size>0&&!b.has(a.path)}}[y,A,B]=F.then?(await F)():F;let R=(a,b,c)=>`/api/snapshots/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function H(a){return a.fullSubject||a.subject}function I(a,b,c){let d=H(a),e=d.split("\n"),f=e.length>c?e.slice(0,c).join("\n"):d,g=f.length>b?f.slice(0,b):f;return e.length>c||f.length>b?`${g.trimEnd()}…`:g}function J(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function K(a,b){let c=[];for(let d of a)if("Edit"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string){let e=J(a.file_path,b);c.push({key:d.id,toolName:"Edit",subject:`[Edit] ${e}`,legacy:!0,changeClass:(0,m.q)(e),files:[{path:e,status:"modified",old_string:a.old_string,new_string:a.new_string}]})}}else if("Write"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.content){let e=J(a.file_path,b);c.push({key:d.id,toolName:"Write",subject:`[Write] ${e}`,legacy:!0,changeClass:(0,m.q)(e),files:[{path:e,status:"added",old_string:"",new_string:a.content}]})}}return c}function L(a,b,c){var d;let e,f=a.map(a=>{let b=new Set(a.commit.toolFiles);return{key:a.commit.toolId??a.commit.hash,shortHash:a.commit.hash.slice(0,7),hash:a.commit.hash,parent:a.commit.parent,declared:a.commit.toolFiles,toolName:a.commit.toolName??"tool",subject:a.commit.subject,timestamp:a.commit.timestamp,truncated:!0===a.truncated,changeClass:(0,m.S)(a.files.map(a=>a.path)),files:a.files.map(a=>G(a,b))}});return d=f.length>0?f:K(b,c),e=new Map(b.map(a=>[a.id,a])),d.map(a=>{let b=function(a){if(!a)return;let b=a.input;return"string"==typeof b.description&&b.description?b.description:"string"==typeof b.command&&b.command?b.command:"string"==typeof b.prompt&&b.prompt?b.prompt:"string"==typeof b.file_path&&b.file_path?b.file_path:"string"==typeof b.notebook_path&&b.notebook_path?b.notebook_path:void 0}(e.get(a.key));return b?{...a,fullSubject:`[${a.toolName}] ${b}`}:a})}function M(a){let b=!1,c=0,d=0;for(let e of a)(void 0!==e.additions||void 0!==e.deletions)&&(b=!0),c+=e.additions??0,d+=e.deletions??0;return b?{additions:c,deletions:d}:null}function N({additions:a,deletions:b}){return(0,e.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,e.jsxs)("span",{className:"text-green-11",children:["+",a]}),(0,e.jsxs)("span",{className:"text-red-11",children:["-",b]})]})}function O(a){let b=new Date(1e3*a),c=new Date,d=String(b.getMonth()+1).padStart(2,"0"),e=String(b.getDate()).padStart(2,"0"),f=String(b.getHours()).padStart(2,"0"),g=String(b.getMinutes()).padStart(2,"0"),h=`${d}-${e} ${f}:${g}`;return b.getFullYear()===c.getFullYear()?h:`${b.getFullYear()}-${h}`}function P({toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:l,fullscreen:m,onToggleFullscreen:F}){let{t:J}=(0,g.Bd)(),Q=(0,f.useRef)(null),[S,T]=(0,f.useState)(null),U=(0,f.useMemo)(()=>a.map(a=>a.id).filter(Boolean),[a]),V=U.join(","),[W,X]=(0,f.useState)(0),Y=(0,i.Z)(b&&U.length>0?(0,C.se)(b,U,c):h.PyW([]),[b,c,V,W]);(0,f.useMemo)(()=>a.filter(a=>(0,D.h)(a.name)).map(a=>a.id),[a]);let Z=(0,f.useRef)([]),$="loading"===Y.status&&0===Z.current.length,_=(0,f.useMemo)(()=>{if("success"===Y.status){let c=L(Y.data,a,b);return c.length>0&&(Z.current=c),c}return"loading"===Y.status&&Z.current.length>0?Z.current:"loading"===Y.status?[]:K(a,b)},[Y,a,b]),[aa,ab]=(0,f.useState)(!1),[ac,ad]=(0,f.useState)(!1),ae=(0,f.useMemo)(()=>_.filter(a=>a.hash),[_]),af=(0,f.useMemo)(()=>(0,E.mg)(ae),[ae]),ag=(0,f.useMemo)(()=>ac?ae:ae.slice(af),[ae,ac,af]),ah=(0,f.useMemo)(()=>{if(ac||0===af)return _;let a=new Set(ae.slice(0,af).map(a=>a.key));return _.filter(b=>!a.has(b.key))},[_,ae,ac,af]),ai=(0,f.useMemo)(()=>0===ag.length||ag.length<2&&0===af?null:{base:ag[0].parent??null,head:ag[ag.length-1].hash},[ag,af]),aj=!!b&&_.length>=2,ak=null===ai,al=(0,i.Z)(aa&&b&&ai?(0,C.Tt)(b,ai.base,ai.head):h.PyW(null),[aa,b,ai?.base??"",ai?.head??""]),am=(0,f.useMemo)(()=>0===ag.length||ag.some(a=>!a.declared||0===a.declared.length)?null:new Set(ag.flatMap(a=>a.declared)),[ag]),an=(0,f.useMemo)(()=>"success"===al.status&&al.data?al.data.files.map(a=>G(a,am)):[],[al,am]),ao="success"===al.status&&al.data?.truncated===!0,ap=aa&&"loading"===al.status,aq=aa&&"error"===al.status,[ar,as]=(0,f.useState)(null),[at,au]=(0,f.useState)(null),[av,aw]=(0,f.useState)(new Set),[ax,ay]=(0,f.useState)(()=>!0),[az,aA]=(0,f.useState)("compact"),[aB,aC]=(0,f.useState)("unified"),[aD,aE]=(0,f.useState)(!1),[aF,aG]=(0,f.useState)(!1),[aH,aI]=(0,f.useState)(null),aJ=(0,f.useMemo)(()=>_.find(a=>a.key===ar)??null,[_,ar]),aK=(0,f.useRef)(null),aL=aJ??aK.current,aM=(0,f.useMemo)(()=>aa?an:aL?.files??[],[aa,an,aL]),aN=(0,f.useMemo)(()=>(0,u.Do)(aM),[aM]),aO=(0,f.useMemo)(()=>aM.find(a=>a.path===at)??null,[aM,at]),aP=(0,f.useMemo)(()=>M(aM),[aM]),aQ=(0,f.useCallback)(a=>{as(a.key),au(a.files[0]?.path??null),aw(new Set((0,u.Sz)((0,u.Do)(a.files))))},[]),aR=(0,f.useMemo)(()=>ah.reduce((a,b)=>a+b.files.length,0),[ah]),aS=a=>(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:a});return(0,e.jsx)(j.SU,{container:S,children:(0,e.jsxs)("div",{ref:Q,className:"relative bg-card shadow-lv3 w-full h-full flex flex-col rounded-lg",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:`${n.o} px-3`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:d,"aria-label":J("common.close"),title:J("common.close"),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(o.A,{className:"w-4 h-4"})}),F&&(0,e.jsx)("button",{onClick:F,"aria-label":m?J("diffViewer.exitFull"):J("diffViewer.expandFull"),title:m?J("diffViewer.exitFull"):J("diffViewer.expandFull"),"aria-pressed":!0===m,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:m?(0,e.jsx)(p.A,{className:"w-4 h-4"}):(0,e.jsx)(q.A,{className:"w-4 h-4"})}),aj&&(0,e.jsx)("button",{onClick:()=>ab(a=>!a),disabled:ak,"aria-pressed":aa,title:ak?J("diffViewer.aggregateUnavailable"):aa?J("diffViewer.aggregateOff"):J("diffViewer.aggregateOn"),className:`ml-0.5 px-2 py-0.5 text-xs rounded border transition-colors ${ak?"border-border text-foreground-subtle opacity-60 cursor-not-allowed":aa?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:J("diffViewer.aggregate")})]}),(0,e.jsx)("div",{className:"w-px h-4 bg-border flex-shrink-0"}),(0,e.jsx)("button",{onClick:()=>ay(a=>!a),"aria-label":J("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors flex-shrink-0 ${ax?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,e.jsx)(r.A,{className:"w-4 h-4"})}),(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",children:aa?J("diffViewer.fileChangesAggregate",{count:aM.length}):J("diffViewer.fileChanges",{count:aR})})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ax&&!aa&&(0,e.jsxs)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:[af>0&&(0,e.jsx)("button",{onClick:()=>ad(a=>!a),"data-tooltip":J("diffViewer.aggregateSkippedHint",{threshold:E.fz}),className:"w-full px-3 py-1.5 border-b border-border text-left text-xs bg-amber-500/10 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20 transition-colors",children:ac?J("diffViewer.callsBaselineShown",{count:af}):J("diffViewer.callsBaselineHidden",{count:af})}),ah.map(a=>{let b;return(0,e.jsxs)("div",{onClick:()=>aQ(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${ar===a.key?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[a.changeClass&&(0,e.jsx)(k.N,{cls:a.changeClass}),a.shortHash&&(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),void 0!==a.timestamp&&(0,e.jsx)("span",{className:"text-xs text-foreground-subtle",children:O(a.timestamp)})]}),(0,e.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":H(a),children:I(a,320,10)}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{children:J("commitDetail.nChanges",{count:a.files.length})}),(b=M(a.files))&&(b.additions>0||b.deletions>0)?(0,e.jsx)(N,{additions:b.additions,deletions:b.deletions}):null]})]},a.key)})]}),(0,e.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:$?aS(J("diffViewer.loadingSnapshots")):0===_.length?aS(J("diffViewer.noChanges")):aa||aL?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[aa?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(s.A,{className:"w-3.5 h-3.5"}),J("diffViewer.aggregateSummary",{count:aM.length,calls:ag.length})]}),af>0&&(0,e.jsx)("button",{onClick:()=>ad(a=>!a),"data-tooltip":J("diffViewer.aggregateSkippedHint",{threshold:E.fz}),className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors",children:ac?J("diffViewer.aggregateBaselineIncluded",{count:af}):J("diffViewer.aggregateBaselineSkipped",{count:af})}),aP&&(aP.additions>0||aP.deletions>0)&&(0,e.jsx)(N,{additions:aP.additions,deletions:aP.deletions}),ao&&(0,e.jsx)("span",{className:"text-amber-11",children:J("diffViewer.truncated")})]}):aL?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(t.A,{className:"w-3.5 h-3.5"}),aL.toolName]}),aL.shortHash&&(0,e.jsx)("span",{className:"font-mono text-brand",children:aL.shortHash}),void 0!==aL.timestamp&&(0,e.jsx)("span",{children:O(aL.timestamp)}),(0,e.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":H(aL),children:I(aL,640,6)}),aL.truncated&&(0,e.jsx)("span",{className:"text-amber-11",children:J("diffViewer.truncated")}),aL.legacy&&(0,e.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":J("diffViewer.reconstructedHint"),children:J("diffViewer.reconstructed")})]}):null,(0,e.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!aO?.isImage&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(v.y,{value:az,onChange:aA}),(0,e.jsx)(w.q,{value:aB,onChange:aC})]})})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ax&&(0,e.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:ap?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:J("diffViewer.aggregateLoading")}):(0,e.jsx)(u.VO,{files:aN,selectedPath:at,expandedPaths:av,onToggle:a=>aw(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c}),onSelect:a=>{!a.isDirectory&&a.file&&au(a.file.path)},cwd:b||"",showChanges:!0,showChangeClass:!0,renderActions:a=>{if(a.isDirectory)return null;let b=a.file;return b?(0,e.jsx)(e.Fragment,{children:b.external&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":J("diffViewer.externalChange")})}):null}})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:aO?aO.isImage?(0,e.jsx)(x.K,{filePath:aO.path,oldSrc:b&&aO.oldRev?R(b,aO.oldRev,aO.path):null,newSrc:b&&aO.newRev?R(b,aO.newRev,aO.path):null}):aO.unviewable?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:J("diffViewer.notViewable")}):"unified"===aB?(0,e.jsx)(y.xU,{oldContent:aO.old_string,newContent:aO.new_string,filePath:aO.path,cwd:b,enableComments:!0,onContentSearch:l,compact:"compact"===az,onPreview:"deleted"===aO.status?void 0:(0,z.e$)(aO.path)?()=>aE(!0):(0,z.aR)(aO.path)?()=>aG(!0):aO.path.endsWith(".json")?()=>aI({content:aO.new_string,filePath:aO.path}):void 0,previewLabel:aO.path.endsWith(".json")?J("common.readable"):J("common.preview")}):(0,e.jsx)(y.xZ,{oldContent:aO.old_string,newContent:aO.new_string,filePath:aO.path,isNew:"added"===aO.status,isDeleted:"deleted"===aO.status,cwd:b,enableComments:!0,onContentSearch:l,compact:"compact"===az,onPreview:"deleted"===aO.status?void 0:(0,z.e$)(aO.path)?()=>aE(!0):(0,z.aR)(aO.path)?()=>aG(!0):aO.path.endsWith(".json")?()=>aI({content:aO.new_string,filePath:aO.path}):void 0,previewLabel:aO.path.endsWith(".json")?J("common.readable"):J("common.preview")}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:ap?J("diffViewer.aggregateLoading"):aq?J("diffViewer.aggregateFailed"):aa&&0===aM.length?J("diffViewer.aggregateEmpty"):J("diffViewer.selectFileToView")})})]})]}):aS(J("diffViewer.selectFileToView"))})]}),aD&&aO&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>aE(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(A.M,{content:aO.new_string,filePath:aO.path,cwd:b||"",onClose:()=>aE(!1)})})}),aF&&aO&&(0,e.jsx)(B.N,{filePath:aO.path,content:aO.new_string,cwd:b,onClose:()=>aG(!1),onContentSearch:l}),aH&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>aI(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full 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:aH.filePath}),(0,e.jsx)("button",{onClick:()=>aI(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(o.A,{className:"w-4 h-4"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,z.xb)(aH.content)})})]})})]})})}function Q({toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:f}){return(0,e.jsx)(l.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:d,children:(0,e.jsx)(P,{toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:f?a=>{d(),f(a)}:void 0})})})}d()}catch(a){d(a)}})},58554:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>K});var e=c(48249),f=c(67484),g=c(60661),h=c(77949),i=c(7833),j=c(40699),k=c(33281),l=c(41224),m=c(57031),n=c(88214),o=c(63041),p=c(74429),q=c(62473),r=c(14222),s=c(86686),t=c(75513),u=c(81206),v=c(97951),w=c(93780),x=c(99843),y=c(80514),z=c(43209),A=c(95401),B=c(42910),C=c(65139),D=c(75389),E=c(47604),F=c(60812),G=c(99191),H=c(84844),I=c(44384),J=a([x]);x=(J.then?(await J)():J)[0];let L=`${G.o} pl-3 pr-14 bg-card/50`;function K({tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:G,ollamaModel:J,onOllamaModelChange:M,deepseekModel:N,onDeepseekModelChange:O,kimiModel:P,onKimiModelChange:Q,glmModel:R,onGlmModelChange:S,claudeModel:T,onClaudeModelChange:U,claudeEffort:V,onClaudeEffortChange:W,claudeFastMode:X,onClaudeFastModeChange:Y,claudeThinking:Z,onClaudeThinkingChange:$,codexModel:_,onCodexModelChange:aa,codexReasoningEffort:ab,onCodexReasoningEffortChange:ac,planMode:ad,onPlanModeChange:ae,noHistory:af,onNoHistoryChange:ag,outputStyle:ah,onOutputStyleChange:ai,hideHeader:aj,hideSidebar:ak,isActive:al=!0,isFocused:am=al,peerTabId:an,peerSide:ao,refreshSignal:ap,onLoadingChange:aq,onSessionIdChange:ar,onTitleChange:as,onBotChange:at,onShowGitStatus:au,onOpenNote:av,isFavorite:aw,onToggleFavorite:ax,onCreateScheduledTask:ay,onOpenSession:az,onContentSearch:aA,onShowFileDiff:aB,onOpenFileLink:aC,onOpenSessionBrowser:aD,onOpenSettings:aE}){let aF,{t:aG}=(0,I.Bd)(),aH=(0,r.k)(),[aI,aJ]=(0,f.useState)(""),[aK,aL]=(0,f.useState)([]),aM=(0,t.nH)(),[aN,aO]=(0,f.useState)([]),[aP,aQ]=(0,f.useState)(null),[aR,aS]=(0,f.useState)(!1),[aT,aU]=(0,f.useState)(!1),[aV,aW]=(0,f.useState)(!1),[aX,aY]=(0,f.useState)(!1),[aZ,a$]=(0,f.useState)(null),[a_,a0]=(0,f.useState)(!1),a1=ad??a_,a2=(0,f.useCallback)(a=>{a0(a),ae?.(a)},[ae]),[a3,a4]=(0,f.useState)(!1),a5=af??a3,a6=(0,f.useCallback)(a=>{a4(a),ag?.(a)},[ag]),[a7,a8]=(0,f.useState)(""),a9=ah??a7,ba=(0,f.useCallback)(a=>{a8(a),ai?.(a)},[ai]),[bb,bc]=(0,f.useState)(!1),bd=(0,f.useRef)(null);(0,f.useRef)(null);let be=(0,f.useCallback)(async a=>{if(!b)return;let c=await k.t4.runPromiseExit((0,l.n_)({cwd:b,sessionId:a}));"Success"===c._tag&&c.value&&"string"==typeof c.value.title?as?.(c.value.title):"Failure"===c._tag&&console.error("Failed to fetch session title:",c.cause)},[b,as]),bf=(0,f.useRef)(null),[bg,bh]=(0,f.useState)(!1),[bi,bj]=(0,f.useState)(null),[bk,bl]=(0,f.useState)(null),[bm,bn]=(0,f.useState)(v.R),bo=(0,f.useMemo)(()=>(0,w.hC)(),[]),bp=(0,f.useRef)(!1),{isLoadingHistory:bq,isLoadingMore:br,hasMoreHistory:bs,loadMoreHistory:bt,ensureTurnLoaded:bu,loadHistoryByCwdAndSessionId:bv,loadedSessionId:bw,loadedEngine:bx,loadedBot:by}=(0,u.m)(aN,aO,aP,{cwd:b,initialSessionId:c,onSessionId:aQ,onTitleChange:as,onTokenUsage:a$,liveRunningRef:bp}),bz=bx??d??void 0,bA=!bz||"claude"===bz,bB="codex"===bz,bC=T??C.BV,bD=(0,C.NR)(bC,V),bE=_??C.kn,bF=(0,C.oJ)(bE,ab),bG="deepseek"===bz||"kimi"===bz||"glm"===bz?bz:null,bH="kimi"===bG?P:"glm"===bG?R:N,bI="kimi"===bG?Q:"glm"===bG?S:O,bJ="ollama"===bz||null!==bG||bA||bB,{isLoading:bK,tokenUsage:bL,liveOutputTokens:bM,runningStartedAt:bN,rateLimitInfo:bO,apiRetryInfo:bP,backgroundTasks:bQ,handleSend:bR,handleStop:bS}=(0,v.e)(aN,aO,{sessionId:aP,cwd:b,engine:bz,planMode:a1,noHistory:a5,outputStyleId:a9,ollamaModel:J,engineModel:bH,claudeModel:bC,claudeEffort:bD,claudeFastMode:X,claudeThinking:Z,codexModel:bE,codexReasoningEffort:bF,onSessionId:aQ,onFetchTitle:be,onRunComplete:()=>bf.current?.(),taskStore:bo}),bT=(0,f.useCallback)((...a)=>(bd.current?.pinNextUserMessage(),bR(...a)),[bR]),bU=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(bA){let b=/^\/plan(?:\s+([\s\S]*))?$/.exec(a.trim());if(b){let a=(b[1]??"").trim();"off"===a.toLowerCase()?(a2(!1),(0,i.oR)(aG("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===a?(a2(!0),(0,i.oR)(aG("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(a2(!0),bT(a,c,{permissionMode:"plan"}));return}}if(d.startsWith("!")&&d.length>1){let e=d.slice(1).trim();if(!e)return void bT(a,c);let f=a.split("\n").slice(1).join("\n").trim(),g=await k.t4.runPromiseExit((0,l.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=aG("chat.executedCommand",{command:e,exitInfo:d,output:b});f&&(h+=`
26
+ `:"")+"</task-notification>";b(b=>[...b,{id:c,role:"system",content:a.summary||"",systemEvent:{kind:"task-notification",...a.status?{status:a.status}:{},detail:d}}])}return}if("system"===a.type&&"notice"===a.subtype){let c=(0,h.C)(a,`live-notice-${++l.current}`);c&&b(a=>[...a,c]);return}if("user"===a.type&&a._human){let c=a.message?.content,d="string"==typeof c?c:Array.isArray(c)?c.map(a=>a?.text||"").join(""):"",e="string"==typeof a._turnId?a._turnId:null;e&&(q.current=e);let f="number"==typeof a._ts?a._ts:null,g=e?`live-user-${e}`:`live-user-${++l.current}`;b(a=>{if(e&&a.some(a=>a.id===g))return a;for(let b=a.length-1;b>=0;b--){if("user"!==a[b].role)continue;let c=a[b].timestamp?Date.parse(a[b].timestamp):NaN;if(null===f||Number.isNaN(c)){if(a[b].content===d)return a}else if(c>=f)return a;break}return[...a,{id:g,role:"user",content:d}]});return}if("result"===a.type&&(p.current=!1,o.current=!0),"assistant"===a.type&&Array.isArray(a.message?.content))for(let b of a.message.content)b.text?d(b.text):b.name&&d(`${b.name} ${JSON.stringify(b.input??{})}`);if("user"===a.type&&Array.isArray(a.message?.content))for(let b of a.message.content)d("string"==typeof b.content?b.content:JSON.stringify(b.content??""));let e=k.current??r();b(b=>(0,g.FM)(b,a,{engine:i,assistantId:e}))};(0,e.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("string"==typeof a.runId&&a.runId&&(q.current=a.runId),"running"!==a.status){j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1;return}let c=a.events.find(a=>a?.type==="user"&&a?._human),d=c?.message?.content,e="string"==typeof d?d:"",f=new Set,h=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&&h.add(a.id)}let i="number"==typeof a.startedAt?a.startedAt:null;b(a=>{let b=a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("live-"))),c=b[b.length-1],d=c?.timestamp?Date.parse(c.timestamp):NaN;if(null!==i&&!Number.isNaN(d)){let a=b.length;for(;a>0;){let c=b[a-1],d=c.timestamp?Date.parse(c.timestamp):NaN;if(!Number.isNaN(d)&&d>=i)a--;else break}return a<b.length?b.slice(0,a):b}if(!e)return b;let g=-1;for(let a=b.length-1;a>=0;a--)if("user"===b[a].role){b[a].content===e&&(g=a);break}return -1===g?b:b.slice(g+1).every(a=>"assistant"===a.role&&("string"==typeof a.id&&f.has(a.id)||!!a.toolCalls?.length&&a.toolCalls.every(a=>h.has(a.id))))?b.slice(0,g):b}),k.current=null,l.current=0,m.current=0,n.current=!1,o.current=!1,p.current=!1;let r="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let b of(null!==r&&(m.current=r,n.current=!0,j?.onLiveOutputTokens?.({outputTokens:r})),a.events))s(b);j?.onRunningChange?.(!0),j?.onRunStartedAt?.("number"==typeof a.startedAt?a.startedAt:Date.now())}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1,j?.onComplete?.();return}s(a.message),j?.onRunningChange?.(!0)}else"run-idle"===a.type&&(j?.onRunningChange?.(!1),j?.onLiveOutputTokens?.(null),j?.onRunStartedAt?.(null),j?.onBackgroundTasks?.([]),b(g.fD),j?.taskStore?.settleRunning(),m.current=0,n.current=!1,o.current=!1)}})}},40893:(a,b,c)=>{"use strict";c.d(b,{O:()=>m});var d=c(48249),e=c(67484),f=c(7031),g=c(41051),h=c(42140),i=c(64676),j=c(74754),k=c(91579),l=c(208);function m({content:a,filePath:b,cwd:c,onContentSearch:n,reloadKey:o=0}){let p=(0,f.r)(),q=!!c,r=(0,e.useMemo)(()=>(0,i.qF)(b,c)?{mode:"url",url:(0,i.Xe)(b,c)}:{mode:"srcdoc",html:a??""},[a,b,c]),{addComment:s,refresh:t}=(0,j._)({cwd:c||"",filePath:b}),[u,v]=(0,e.useState)(null),w=(0,e.useRef)(null),x=(0,e.useRef)(null),y=(0,e.useRef)(()=>{}),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(null),D=(0,e.useRef)(!1),E=(0,e.useCallback)(()=>{x.current&&(x.current=null,y.current())},[]),F=(0,e.useCallback)(()=>{let a=w.current,b=a?.contentWindow;if(b){let a=document.documentElement.classList.contains("dark");b.postMessage({type:"THEME_CHANGE",theme:a?"dark":"light"},"*"),b.postMessage({type:"cockpit:language-change",lang:l.A.language},"*")}if(!q)return;let c=a?.contentDocument;a&&c&&(c.addEventListener("mouseup",b=>{if(D.current)return;let c=a.contentWindow?.getSelection(),d=c&&!c.isCollapsed?c.toString().trim():"";if(!d)return void E();let e=a.getBoundingClientRect();x.current={x:e.left+b.clientX,y:e.top+b.clientY,range:{start:0,end:0},selectedText:d,lineSnapshot:d},y.current()}),c.addEventListener("mousedown",()=>{E(),A(null),C(null)}),c.addEventListener("scroll",()=>E(),{capture:!0,passive:!0}))},[q,E]),G=(0,e.useCallback)(()=>{let a=x.current;a&&(A({x:a.x,y:a.y,text:a.selectedText}),E(),w.current?.contentWindow?.getSelection()?.removeAllRanges())},[E]),H=(0,e.useCallback)(()=>{let a=x.current;a&&(C({x:a.x,y:a.y,text:a.selectedText}),E(),w.current?.contentWindow?.getSelection()?.removeAllRanges())},[E]),I=(0,e.useCallback)(()=>{let a=x.current;a&&p&&(E(),w.current?.contentWindow?.getSelection()?.removeAllRanges(),(0,k.Ff)(p.sendMessage,{filePath:b,startLine:0,endLine:0,codeContent:a.selectedText},l.A.t("explain.selectionMessage")))},[p,b,E]),J=(0,e.useCallback)(()=>{let a=x.current;if(!a||!n)return;let b=a.selectedText.trim();E(),w.current?.contentWindow?.getSelection()?.removeAllRanges(),b&&n(b)},[n,E]),K=(0,e.useCallback)(async a=>{z&&(await s(0,0,a,z.text),A(null))},[z,s]),L=(0,e.useCallback)(async(a,d)=>{if(p&&c)try{let e=(await (0,k.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));e.push({filePath:b,startLine:0,endLine:0,codeContent:a});let f=(0,k.Gw)(e,d);p.sendMessage(f),await (0,k.RP)(c),t()}catch(a){console.error("[HtmlAppFrame] send to AI failed:",a)}},[p,c,b,t]),M=(0,e.useCallback)(a=>{B&&L(B.text,a)},[B,L]),N=(0,e.useCallback)(a=>{z&&L(z.text,a)},[z,L]);return(0,d.jsxs)("div",{ref:v,className:"relative h-full w-full bg-white",children:[(0,d.jsx)("iframe",{ref:w,..."url"===r.mode?{src:r.url}:{srcDoc:r.html},title:b,className:"h-full w-full border-0",onLoad:F},`${b}:${o}`),q&&u&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.fS,{floatingToolbarRef:x,bumpRef:y,container:u,onAddComment:G,onSendToAI:H,onSearch:n?J:void 0,onExplain:p?I:void 0,isChatLoading:p?.isLoading}),z&&(0,d.jsx)(h.t,{x:z.x,y:z.y,range:{start:0,end:0},filePath:b,lineSnapshot:z.text,container:u,onSubmit:K,onSendToAI:p?N:void 0,onClose:()=>A(null),isChatLoading:p?.isLoading}),B&&(0,d.jsx)(h.G,{x:B.x,y:B.y,range:{start:0,end:0},filePath:b,lineSnapshot:B.text,container:u,onSubmit:M,onClose:()=>C(null),isChatLoading:p?.isLoading})]})]})}},41051:(a,b,c)=>{"use strict";c.d(b,{SZ:()=>g,fS:()=>j});var d=c(48249),e=c(67484),f=c(44384);let g=[["quickReply.optionA","quickReply.optionB","quickReply.optionC","quickReply.optionD"],["quickReply.allRecommended","quickReply.thisOne","quickReply.notThis"],["quickReply.why","quickReply.elaborate","quickReply.example"],["quickReply.start","quickReply.continue","quickReply.ok","quickReply.done"]];function h({rows:a,placeAbove:b,onHeight:c,onPick:g,onEdit:i,onMouseEnter:j,onMouseLeave:k}){let{t:l}=(0,f.Bd)(),m=(0,e.useRef)(null);return(0,d.jsxs)("div",{ref:m,className:`absolute ${b?"bottom-full mb-1":"top-full mt-1"} left-0 z-[201] flex flex-col gap-1 bg-card border border-border rounded-lg shadow-lv3 p-1.5`,onMouseEnter:j,onMouseLeave:k,children:[i&&(0,d.jsx)("button",{className:"absolute top-0.5 right-0.5 p-1 text-muted-foreground hover:text-brand transition-colors",onClick:i,title:l("quickReply.edit"),"aria-label":l("quickReply.edit"),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.map((a,b)=>(0,d.jsx)("div",{className:`flex items-center gap-1${i&&0===b?" pr-5":""}`,children:a.map((a,c)=>(0,d.jsx)("button",{className:"px-2 py-1 text-xs whitespace-nowrap border border-border text-foreground rounded hover:border-brand hover:bg-hover transition-colors",onClick:()=>g(a),children:a},`${b}:${c}:${a}`))},b))]})}function i({x:a,y:b,visible:c,container:j,onAddComment:k,onSendToAI:l,onSearch:m,onExplain:n,onQuickReply:o,quickReplyRows:p,onEditQuickReplies:q,isChatLoading:r}){let{t:s}=(0,f.Bd)(),t=(0,e.useRef)(null),[u,v]=(0,e.useState)({w:0,h:0}),[w,x]=(0,e.useState)(0),[y,z]=(0,e.useState)(null),A=(0,e.useRef)(null),B=(0,e.useCallback)(a=>{x(b=>b===a?b:a)},[]),C=(0,e.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,e.useCallback)(a=>{C(),z(a)},[C]),E=(0,e.useCallback)(()=>{C(),A.current=setTimeout(()=>z(null),150)},[C]),F=j.getBoundingClientRect(),G=a-F.left,H=Math.max(0,b-F.top-40),I=Math.max(0,Math.min(G+8,F.width-u.w-8)),J=w>0&&H+u.h+8+w>F.height,K=(0,e.useMemo)(()=>p??g.map(a=>a.map(a=>s(a))),[p,s]),L=a=>o&&y===a?(0,d.jsx)(h,{rows:K,onEdit:q,placeAbove:J,onHeight:B,onPick:b=>{z(null),o(a,b)},onMouseEnter:C,onMouseLeave:E}):null;return(0,d.jsxs)("div",{ref:t,className:"floating-toolbar absolute z-[200] flex items-center gap-1.5 bg-card border border-border rounded-lg shadow-lv3 p-1.5",style:{left:I,top:H,visibility:c?"visible":"hidden",pointerEvents:c?"auto":"none"},children:[(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>D("comment"),onMouseLeave:E,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:k,children:s("floatingToolbar.addComment")}),L("comment")]}),(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>{r||D("ai")},onMouseLeave:E,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 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,disabled:r,title:r?s("comments.aiResponding"):void 0,children:s("floatingToolbar.sendToAI")}),L("ai")]}),n&&(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:n,disabled:r,title:r?s("comments.aiResponding"):void 0,children:s("explain.action")}),m&&(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:m,children:s("floatingToolbar.search")})]})}let j=(0,e.memo)(function({floatingToolbarRef:a,bumpRef:b,container:c,onAddComment:f,onSendToAI:g,onSearch:h,onExplain:j,onQuickReply:k,quickReplyRows:l,onEditQuickReplies:m,isChatLoading:n}){let[o,p]=(0,e.useState)(0),q=(0,e.useMemo)(()=>a.current,[o]);return(0,d.jsx)(i,{x:q?.x??0,y:q?.y??0,visible:!!q,container:c,onAddComment:f,onSendToAI:g,onSearch:h,onExplain:j,onQuickReply:k,quickReplyRows:l,onEditQuickReplies:m,isChatLoading:n})})},41170:(a,b,c)=>{"use strict";c.d(b,{GR:()=>k,LM:()=>i,Ux:()=>l});let d={mode:"follow",pinTop:null},e={mode:"free",pinTop:null};function f(a){return Math.max(0,a.scrollHeight-a.spacer)}function g(a){return Math.max(0,f(a)-a.clientHeight)}function h(a,b){return a<=0?0:Math.max(0,a+b.clientHeight-f(b))}function i(a){return f(a)-a.scrollTop-a.clientHeight<50}function j(a,b="auto"){return{owner:d,spacer:0,scrollTo:g(a),behavior:b}}function k(a,b,c){if(!(c.clientHeight>0))return null;switch(b.type){case"reset":return{owner:d,spacer:0,scrollTo:null,behavior:"auto"};case"toEnd":return j(c,"smooth");case"readFrom":{let a=b.top;return{owner:{mode:"reading",pinTop:a},spacer:h(a,c),scrollTo:a,behavior:"auto"}}case"settle":{if("reading"===a.mode){let b=a.pinTop??c.scrollTop;return{owner:a,spacer:h(b,c),scrollTo:null,behavior:"auto"}}if(c.spacer<=0)return null;let b=Math.min(c.scrollTop,g(c));return{owner:b>=g(c)?d:e,spacer:0,scrollTo:b,behavior:"smooth",deferSpacer:!0}}case"pin":{let a=h(b.top,c);if(a<=0)return j(c);return{owner:{mode:"pinned",pinTop:b.top},spacer:a,scrollTo:b.top,behavior:"smooth"}}case"release":if("pinned"!==a.mode&&"reading"!==a.mode)return null;return{owner:e,spacer:h(c.scrollTop,c),scrollTo:null,behavior:"auto"};case"content":case"viewport":if("follow"===a.mode)return j(c);if("pinned"===a.mode){let d=a.pinTop??c.scrollTop,e=h(d,c);if(e<=0)return j(c);return{owner:a,spacer:e,scrollTo:"viewport"===b.type?d:null,behavior:"auto"}}if("reading"===a.mode){let d=a.pinTop??c.scrollTop;return{owner:a,spacer:h(d,c),scrollTo:"viewport"===b.type?d:null,behavior:"auto"}}return{owner:a,spacer:h(c.scrollTop,c),scrollTo:null,behavior:"auto"}}}function l(a,b){return"pinned"===a.mode||"reading"===a.mode?a:50>Math.abs(b.scrollTop-g(b))?d:e}},41224:(a,b,c)=>{"use strict";c.d(b,{$N:()=>y,$x:()=>I,Cr:()=>F,DF:()=>L,F4:()=>r,Fi:()=>o,Hw:()=>l,JC:()=>v,K4:()=>K,M5:()=>t,Ny:()=>m,QW:()=>z,Vm:()=>C,ZQ:()=>H,Zr:()=>x,_9:()=>G,an:()=>E,dM:()=>q,dQ:()=>n,em:()=>k,hZ:()=>J,he:()=>p,l1:()=>u,nM:()=>i,n_:()=>w,qD:()=>D,td:()=>j,yS:()=>s,z2:()=>A});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>g("/api/session/user-messages",{cwd:a,sessionId:b}),j=()=>f("/api/settings"),k=a=>h("/api/settings",a),l=a=>f(`/api/${a}/credentials`),m=a=>f(`/api/${a}/credentials?reveal=1`),n=(a,b)=>h(`/api/${a}/credentials`,{apiKey:b}),o=a=>f(`/api/${a}/models`),p=()=>f("/api/deepseek/balance"),q=a=>f(`/api/${a}/usage`),r=()=>f("/api/ollama/config"),s=a=>h("/api/ollama/config",a),t=()=>f("/api/commands"),u=()=>f("/api/skills"),v=a=>g("/api/bash",a),w=a=>d.$mh({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})}),x=(a,b)=>g(`/api/session/${encodeURIComponent(a)}/fork`,b),y=(a,b)=>f(`/api/session/${encodeURIComponent(a)}/turn`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),z=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),A=()=>f("/api/global-state").pipe(d.TjK(a=>a.sessions??[])),B=()=>d.$mh({try:async()=>{let a=await fetch("/api/ollama/models"),b=await a.json().catch(()=>({}));return 503===a.status?{_tag:"not-running",...b.error&&{reason:b.error}}:a.ok?{_tag:"ok",models:b.models??[]}:{_tag:"error",message:b.error||"Failed to fetch models"}},catch:a=>new e.uV({message:"fetch ollama models failed",cause:a})}),C=()=>d.ivC(async()=>{let a=await fetch("/api/ollama/default-model");if(a.ok)return(await a.json()).model||void 0}).pipe(d.DM4(()=>void 0)),D=a=>d.JkU(function*(){let b=yield*B();if("not-running"!==b._tag)return b;a&&(yield*d.OH5(a));let c=yield*d.$mh({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*B();return"not-running"===f._tag?{_tag:"error",message:f.reason??b.reason??"Ollama started but cannot fetch models"}:f}),E=a=>f(`/api/file?path=${encodeURIComponent(a)}`),F=()=>f("/api/claude-stats"),G=a=>Array.isArray(a.items),H=()=>f("/api/instructions/config?scope=global"),I=a=>f(`/api/instructions/config?cwd=${encodeURIComponent(a)}`),J=a=>g("/api/instructions/config",a),K=()=>f("/api/output-styles/config"),L=a=>g("/api/output-styles/config",{styles:a})},41233:(a,b,c)=>{"use strict";c.d(b,{w:()=>f});var d=c(48249);let e="font-mono text-[9px] font-medium leading-none tabular-nums transition-colors";function f({children:a,wash:b,ring:c="",bot:g,className:h="",tooltip:i,title:j,role:k,ariaLabel:l,ariaHidden:m}){let n={title:j,role:k,"aria-label":l,"aria-hidden":m?"true":void 0,"data-tooltip":i??(g?`@${g}`:void 0)};return g?(0,d.jsx)("span",{className:`relative -m-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center ${c} ${h}`,...n,children:(0,d.jsx)("span",{className:`session-number-bot flex h-full w-full items-center justify-center ${e} ${b}`,children:(0,d.jsx)("span",{className:"translate-y-[1.5px]",children:a})})}):(0,d.jsx)("span",{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border ${e} ${c} ${b} ${h}`,...n,children:a})}},41357:(a,b,c)=>{"use strict";c.d(b,{H:()=>e});var d=c(67484);function e({cwd:a,selectedPath:b,gitStatusMap:c,renameOldPaths:f,isText:g,refreshKey:h}){let i=b?c?.get(b):void 0,j=g&&("M"===i||"R"===i),[k,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(()=>new Set);(0,d.useRef)(new Set);let q=j&&!!b&&o.has(b);return{canDiff:j,showDiff:q,toggleDiff:(0,d.useCallback)(()=>{b&&p(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},[b]),diff:k,isLoadingDiff:m}}c(79606),c(33281),c(85655)},41830:(a,b,c)=>{"use strict";c.d(b,{N:()=>d});let d=a=>({notify:()=>{!1},subscribe:a=>{!0;return()=>void 0}})},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,filePath:h,lineSnapshot:i,container:j,onSubmit:k,onSendToAI:l,onClose:m,isChatLoading:n}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(!1),t=(0,e.useRef)(null),u=(0,e.useRef)(null),[v,w]=(0,e.useState)({x:0,y:0}),x=i?.split("\n").slice(0,5).join("\n"),y=!!i&&i.split("\n").length>5,z=()=>{!r&&p.trim()&&(s(!0),k(p.trim()))};return(0,d.jsxs)("div",{ref:t,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:v.x,top:v.y},children:[(0,d.jsxs)("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:o("comments.addComment")}),(c.start>0||c.end>0)&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:o("comments.lineRange",{start:c.start,end:c.end})})]}),h&&(0,d.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:h})]}),i&&(0,d.jsx)("div",{className:"px-3 py-2 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:[x,y&&(0,d.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsx)("textarea",{ref:u,value:p,onChange:a=>q(a.target.value),placeholder:o("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:r,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),z()),"Escape"!==a.key||r||m()}}),(0,d.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:o(r?"comments.submitting":"comments.enterSubmit")}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-amber-11 text-amber-11 rounded-md hover:bg-amber-9/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:z,disabled:r||!p.trim(),children:o("comments.submitComment")}),l&&(0,d.jsx)("button",{className:"px-3 py-1 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>{!r&&!n&&l&&p.trim()&&(s(!0),l(p.trim()),m())},disabled:r||n||!p.trim(),title:n?o("comments.aiResponding"):void 0,children:o("comments.sendToAI")})]})]})]})]})}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-lv2 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 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")})]})]})}},42319:(a,b,c)=>{"use strict";function d(a,b){return a?.cwd&&a.sessionId&&(a.cwd!==b.cwd||b.sessionId&&a.sessionId!==b.sessionId)?{cwd:a.cwd,sessionId:a.sessionId}:null}c.d(b,{_:()=>d})},42390:(a,b,c)=>{"use strict";c.d(b,{P:()=>f});var d=c(67484),e=c(4325);function f(){let a=(0,d.useSyncExternalStore)(e.N4,e.fX,e.fX),b=(0,d.useCallback)(()=>{(0,e._I)()},[]);return{isUpdating:a.visible&&"done"!==a.stage&&"failed"!==a.stage,start:b}}},42910:(a,b,c)=>{"use strict";c.d(b,{Z:()=>k});var d=c(48249),e=c(67484),f=c(44256),g=c(63565),h=c(33281),i=c(41224);let j={deepseek:{label:"DeepSeek",apiKeysUrl:"https://platform.deepseek.com/api_keys",modelsEndpoint:"/v1/models"},kimi:{label:"Kimi",apiKeysUrl:"https://www.kimi.com/code/console",modelsEndpoint:"/coding/v1/models"},glm:{label:"GLM",apiKeysUrl:"https://bigmodel.cn/apikey/platform",modelsEndpoint:"/coding/paas/v4/models",regions:[{id:"cn",label:"中国大陆",hint:"open.bigmodel.cn"},{id:"global",label:"International",hint:"api.z.ai"}]}};function k({engine:a,currentModel:b,onModelChange:c,onHasKeyChange:l}){let m=j[a],[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)([]),[H,I]=(0,e.useState)(null),[J,K]=(0,e.useState)(null),L=(0,e.useRef)(null),M=(0,e.useRef)(null),N=(0,e.useRef)(null),O=(0,e.useRef)(null);(0,e.useRef)(b),(0,e.useRef)(c),(0,e.useRef)(l);let[P,Q]=(0,e.useState)({top:0,left:0}),R=(0,f.F2)(),S=(0,e.useCallback)(async()=>{y(!0),C(null),I(null);let[d,e]=await Promise.all([h.t4.runPromiseExit((0,i.Hw)(a)),h.t4.runPromiseExit((0,i.td)())]);if("Failure"===d._tag){C("Failed to load settings"),y(!1);return}q(d.value.hasKey),s(d.value.maskedKey),u(""),w(!1);let f="Success"===e._tag?e.value:void 0,g=f?.engines?.[a],j=g?.builtinModel;m.regions&&K(g?.region??("en"===f?.language?"global":"cn"));let k=[];if(d.value.hasKey){let b=await h.t4.runPromiseExit((0,i.Fi)(a));"Success"===b._tag?k=b.value.models:I("Failed to load models — check the API key")}G(k);let l=k.map(a=>a.id),n=j&&l.includes(j)?j:l[0];!n||b&&l.includes(b)||c(n),y(!1)},[a,b,c,m.regions]),T=(0,e.useCallback)(async b=>{let c=await h.t4.runPromiseExit((0,i.td)()),d=("Success"===c._tag?c.value:{}).engines||{},e={...d,[a]:{...d[a]||{},builtinModel:b}};if("Failure"===(await h.t4.runPromiseExit((0,i.em)({engines:e})))._tag)throw Error("Failed to save settings")},[a]),U=(0,e.useCallback)(async b=>{K(b);let c=await h.t4.runPromiseExit((0,i.td)()),d=("Success"===c._tag?c.value:{}).engines||{};"Failure"===(await h.t4.runPromiseExit((0,i.em)({engines:{...d,[a]:{...d[a]||{},region:b}}})))._tag?C("Failed to save region"):S()},[a,S]),V=async()=>{let b=t.trim();if(!b)return;A(!0),C(null);let c=await h.t4.runPromiseExit((0,i.dQ)(a,b));"Failure"===c._tag?C("Save failed"):(q(c.value.hasKey),s(c.value.maskedKey),u(""),w(!1),S()),A(!1)},W=async()=>{A(!0),C(null);let b=await h.t4.runPromiseExit((0,i.dQ)(a,""));"Failure"===b._tag?C("Clear failed"):(q(b.value.hasKey),s(b.value.maskedKey),u(""),w(!1),G([])),A(!1)},X=async()=>{let b=await h.t4.runPromiseExit((0,i.Ny)(a));if("Failure"===b._tag||!b.value.apiKey)return void C("Copy failed");try{await navigator.clipboard.writeText(b.value.apiKey)}catch{C("Clipboard unavailable");return}C(null),E(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>E(!1),1500)},Y=async a=>{c(a);try{await T(a)}catch{}},Z=p?b||"Select model":"Set API key",$=p?void 0:g.Aw,_=b||"",aa=n?(0,d.jsx)(f.ZL,{children:(0,d.jsx)("div",{ref:M,className:`${g.ys} min-w-[280px]`,style:{top:P.top,left:P.left},children:x?(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),"Loading..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),(0,d.jsx)("a",{href:m.apiKeysUrl,target:"_blank",rel:"noopener","data-testid":`${a}-api-keys-link`,title:`Open ${m.label} API keys page`,"aria-label":`Open ${m.label} API keys page`,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]}),p&&!v?(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("code",{className:"flex-1 min-w-0 truncate text-xs px-2 py-1 rounded bg-secondary text-foreground font-mono",children:r}),(0,d.jsx)("button",{onClick:X,"data-testid":`${a}-copy-api-key`,title:D?"Copied":"Copy API key","aria-label":"Copy API key",className:`p-1 rounded transition-colors ${D?"text-green-11":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,disabled:z,children:D?(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:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 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,d.jsx)("button",{onClick:()=>{w(!0),u(""),setTimeout(()=>N.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:z,children:"Edit"}),(0,d.jsx)("button",{onClick:W,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:z,children:"Clear"})]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:N,type:"password",value:t,onChange:a=>u(a.target.value),onKeyDown:a=>{"Enter"===a.key&&V()},placeholder:"sk-...",className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${g.Fx}`,autoFocus:!0}),(0,d.jsx)("button",{onClick:V,disabled:z||!t.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${g.$T}`,children:z?"Saving...":"Save"}),p&&(0,d.jsx)("button",{onClick:()=>{w(!1),u("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),B&&(0,d.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:B})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"}),m.regions&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Region"}),(0,d.jsx)("div",{className:"inline-flex rounded-md border border-border overflow-hidden text-xs",role:"group","data-testid":`${a}-region-toggle`,children:m.regions.map(b=>(0,d.jsx)("button",{type:"button","data-testid":`${a}-region-${b.id}`,onClick:()=>U(b.id),title:b.hint,className:`px-2 py-0.5 ${J===b.id?"bg-brand text-white":"bg-transparent text-muted-foreground hover:bg-hover"}`,children:b.label},b.id))})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"})]}),(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsx)("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:"Model"}),H&&(0,d.jsx)("div",{className:"mb-1 text-[11px] text-red-11",children:H}),!H&&0===F.length&&(0,d.jsx)("div",{className:"mb-1 text-[11px] text-muted-foreground",children:p?`No models returned by ${m.modelsEndpoint}`:"Save an API key to list models"}),(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:F.map(a=>{var b;let c=_===a.id,e=(b=a.contextTokens)&&!(b<=0)?b>=1048576?`${Math.round(b/1048576)}M`:`${Math.round(b/1024)}K`:null;return(0,d.jsxs)("button",{onClick:()=>Y(a.id),className:`flex items-center gap-2 px-2 py-1 text-xs rounded transition-colors ${c?g.yI:"text-foreground hover:bg-hover"}`,children:[(0,d.jsx)(g.hG,{selected:c}),(0,d.jsx)("span",{className:"truncate",children:a.id}),a.label&&a.label!==a.id&&(0,d.jsx)("span",{className:"truncate text-[10px] text-muted-foreground",children:a.label}),e&&(0,d.jsx)("span",{className:"ml-auto pl-2 text-[10px] text-muted-foreground flex-shrink-0",children:e})]},a.id)})})]})]})})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.XY,{buttonRef:L,label:Z,labelClassName:$,title:`Configure ${m.label}`,onClick:()=>{if(!n){if(L.current){let a=L.current.getBoundingClientRect(),b=R?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;Q({top:a.bottom+4-d,left:a.left-c})}S()}o(a=>!a)},icon:(0,d.jsx)(g.eV,{engine:a}),testId:`${a}-config-picker`}),aa]})}},43037:(a,b,c)=>{"use strict";c.d(b,{E3:()=>g});var d=c(32891);function e(a){return a.classList.contains("task-list-item")}let f=/^\s*\[\/\]\s?/,g=d.YY.create({name:"markdownTaskListFix",addStorage:()=>({markdown:{parse:{updateDOM(a){var b;for(let c of Array.from(a.querySelectorAll("li"))){if(e(c))continue;let a=c.parentElement;a&&"UL"===a.tagName&&(b=c.textContent||"",/^\s*\[\/\]/.test(b)&&(!function(a){let b=a.ownerDocument.createTreeWalker(a,NodeFilter.SHOW_TEXT),c=b.nextNode();for(;c&&!(c.nodeValue&&""!==c.nodeValue.trim());)c=b.nextNode();c&&c.nodeValue&&(c.nodeValue=c.nodeValue.replace(f,""))}(c),c.classList.add("task-list-item"),c.setAttribute("data-type","taskItem"),c.setAttribute("data-status","doing"),a.classList.add("contains-task-list")))}!function(a){for(let b of Array.from(a.querySelectorAll("ul.contains-task-list"))){let a=Array.from(b.children).filter(a=>"LI"===a.tagName);if(0===a.length)continue;let c=function(a){let b=[];for(let c of a){let a=b[b.length-1];a&&a.isTask===c.isTask?a.items.push(c):b.push({isTask:c.isTask,items:[c]})}return b}(a.map(a=>({isTask:e(a),el:a})));if(c.length<=1){c[0]?.isTask&&b.setAttribute("data-type","taskList");continue}let d=b.ownerDocument,f=d.createDocumentFragment();for(let a of c){let b=d.createElement("ul");for(let{el:c}of(a.isTask&&(b.setAttribute("class","contains-task-list"),b.setAttribute("data-type","taskList")),a.items))b.appendChild(c);f.appendChild(b)}b.replaceWith(f)}}(a)}}}})})},43209:(a,b,c)=>{"use strict";c.d(b,{Q:()=>n});var d=c(48249),e=c(67484),f=c(44384),g=c(15819),h=c(57031),i=c(88214),j=c(33281),k=c(41224),l=c(32753),m=c(74228);function n({isOpen:a,onClose:b,cwd:c,onSelectSession:o,projectNumber:p,openSessionIds:q=[]}){let{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)([]),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(""),A=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a;if(!c)return;v(!0),x(null);let b=(a=c.replace(/[^a-zA-Z0-9]/g,"-")).length<=200?a:`${a.slice(0,200)}-${function(a){let b=0;for(let c=0;c<a.length;c++)b=(b<<5)-b+a.charCodeAt(c)|0;return Math.abs(b).toString(36)}(c)}`,d=await j.t4.runPromiseExit((0,k.QW)(b));"Success"===d._tag?t(d.value):x("Failed to load sessions"),v(!1)},[c]);let B=s.filter(a=>{if(!y)return!0;let b=y.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.title.toLowerCase().includes(b)||a.firstMessages.some(a=>a.toLowerCase().includes(b))||a.lastMessages.some(a=>a.toLowerCase().includes(b))});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:g.iG,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("sessions.sessionList")}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground truncate","data-tooltip":c,children:c})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{ref:A,type:"text",placeholder:r("sessions.searchSessions"),value:y,onChange:a=>z(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),y&&(0,d.jsx)("button",{onClick:()=>{z(""),A.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:r("fileBrowser.clear"),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"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[u&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:r("sessions.loadingSessions")})]})}),w&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:w})}),!u&&!w&&0===B.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:r(y?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!u&&!w&&B.length>0&&(0,d.jsx)("div",{className:g.jL,children:B.map(a=>{let e=a.path.split("/").pop()||"",f=a.sessionId||e.replace(".jsonl",""),g=q.indexOf(f);return(0,d.jsxs)("div",{onClick:()=>{let d,e;return d=a.path.split("/").pop()||"",e=a.sessionId||d.replace(".jsonl",""),void(o?(o(e,a.title),b()):(0,h.F)(i.n.OpenProject,{cwd:c,sessionId:e}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)(l.S,{engine:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":a.title,children:a.title}),p&&g>=0&&(0,d.jsx)(m.l,{projectNumber:p,sessionNumber:g+1,bot:a.bot,className:"ml-auto"})]}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),a.lastMessages.length>0&&(0,d.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]})]},a.path)})})]})]})]}):null}},43321:(a,b,c)=>{"use strict";c.d(b,{D:()=>f});let d=/^\s*[-*+]\s+(?:\\?\[ \\?\]|\\?\[[xX/]\\?\])\s*$/,e=/^\s*(```|~~~)/;function f(a){if(!a)return a;let b=a.split("\n"),c=[],f=!1;for(let a of b){if(e.test(a)){f=!f,c.push(a);continue}if(f){c.push(a);continue}d.test(a)||c.push(a)}let g=[],h=0,i=!1;for(let a of c){if(e.test(a)){i=!i,g.push(a),h=0;continue}if(!i&&""===a.trim()){if((h+=1)>=2)continue;g.push(a);continue}h=0,g.push(a)}return g.join("\n")}},43489:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,60440,23)),Promise.resolve().then(c.t.bind(c,84342,23)),Promise.resolve().then(c.t.bind(c,82265,23)),Promise.resolve().then(c.t.bind(c,35421,23)),Promise.resolve().then(c.t.bind(c,61335,23)),Promise.resolve().then(c.t.bind(c,70664,23)),Promise.resolve().then(c.bind(c,74661))},44256:(a,b,c)=>{"use strict";c.d(b,{F2:()=>m,ZL:()=>k,a9:()=>l});var d=c(48249),e=c(67484),f=c(74429);let g=()=>()=>{},h=()=>document.body,i=()=>null,j=(0,e.createContext)(null);function k({children:a}){let b=(0,e.useContext)(j),c=(0,e.useSyncExternalStore)(g,h,i),d=b??c;return d?(0,f.createPortal)(a,d):null}function l({children:a}){let[b,c]=(0,e.useState)(null);return(0,d.jsxs)("div",{className:"relative w-full h-full",style:{transform:"translateZ(0)"},children:[(0,d.jsx)(j.Provider,{value:b,children:a}),(0,d.jsx)("div",{ref:c,className:"absolute inset-0 pointer-events-none [&>*]:pointer-events-auto"})]})}function m(){return(0,e.useContext)(j)}},44616:(a,b,c)=>{Promise.resolve().then(c.bind(c,67045))},46242:(a,b,c)=>{"use strict";c.d(b,{M:()=>g});var d=c(48249),e=c(88018);let f=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function g({cwd:a,filePath:b,oldRev:c,newRev:h,newNode:i}){return(0,d.jsx)(e.K,{filePath:b,oldSrc:c?f(a,c,b):null,newSrc:h?f(a,h,b):null,newNode:i})}},47276:(a,b,c)=>{"use strict";c.d(b,{m3:()=>g,mi:()=>e,ot:()=>f});var d=c(27668);let e=()=>(0,d.zi)("/api/html-apps"),f=a=>(0,d.zi)("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),g=a=>(0,d.zi)(`/api/html-apps/${encodeURIComponent(a)}`,{method:"DELETE"})},47604:(a,b,c)=>{"use strict";c.d(b,{f:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(63565),i=c(41224);let j={CNY:"\xa5",USD:"$"};function k({hasKey:a}){let{t:b}=(0,f.Bd)(),[c,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(null),q=(0,e.useCallback)(async()=>{l(!0),p(null);let a=await g.t4.runPromiseExit((0,i.he)());"Failure"===a._tag?(n(null),p(b("chat.balanceFailed",{defaultValue:"Query failed — check the API key"}))):n(a.value),l(!1)},[b]),r=m?m.balances.map(a=>`${j[a.currency]??(a.currency?`${a.currency} `:"")}${a.totalBalance}`).join(" / "):"",s=!!(m&&!m.isAvailable);return(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[c&&(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!c&&o&&(0,d.jsx)("span",{className:"text-xs text-red-11",children:o}),!c&&!o&&m&&(0,d.jsx)("span",{className:`text-xs font-mono ${s?"text-red-11":h.pe.deepseek}`,"data-tooltip":s?b("chat.balanceUnavailable",{defaultValue:"Account is not available for requests"}):void 0,"data-testid":"deepseek-balance-value",children:r||b("chat.balanceEmpty",{defaultValue:"No balance returned"})}),(0,d.jsx)("button",{type:"button","data-testid":"deepseek-balance-button",disabled:!a||c,onClick:q,"data-tooltip":a?void 0:b("chat.balanceNeedsKey",{defaultValue:"Set a DeepSeek API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:b("chat.checkBalance",{defaultValue:"Check balance"})}),(0,d.jsx)("a",{href:"https://platform.deepseek.com/usage",target:"_blank",rel:"noopener","data-testid":"deepseek-usage-link",title:b("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),"aria-label":b("chat.openUsagePage",{defaultValue:"Open DeepSeek usage console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}},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")},48587:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{y:()=>k});var e=c(48249),f=c(67484),g=c(33407),h=c(62742);c(33281);var i=c(55287);c(87808),c(25419);var j=a([i]);function k({entryPath:a,entryContent:b}){let c,d=(0,f.useMemo)(()=>{let b,c;return(c=(b=a.replace(/\\/g,"/")).lastIndexOf("/"))<=0?"/":b.slice(0,c)},[a]),j=(0,f.useRef)(new Map),[l,m]=(0,f.useState)([]),[n,o]=(0,f.useState)(a),[p,q]=(0,f.useState)(!0),r=l.find(a=>a.abs===n),s=l.length>1||p;return(0,e.jsxs)("div",{className:"flex h-full",children:[s&&(0,e.jsxs)("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto",children:[l.map(a=>(0,e.jsxs)("button",{onClick:()=>o(a.abs),"data-tooltip":a.rel,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 min-w-0 transition-colors ${n===a.abs?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover"}`,children:["image"===a.kind?(0,e.jsx)(g.A,{className:"w-3.5 h-3.5 flex-shrink-0"}):(0,e.jsx)(h.A,{className:"w-3.5 h-3.5 flex-shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:a.rel})]},a.abs)),p&&(0,e.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"…"})]}),(0,e.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:r?.kind==="image"?(0,e.jsx)("div",{className:"h-full flex items-center justify-center p-4 overflow-auto bg-background",children:(0,e.jsx)("img",{src:`/api/file?path=${encodeURIComponent(n)}&raw=true`,alt:(c=n.replace(/\\/g,"/")).slice(c.lastIndexOf("/")+1),className:"max-w-full max-h-full object-contain"})}):(0,e.jsx)(i.Cv,{content:j.current.get(n)??"",filePath:n,cwd:d},n)})]})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},48830:(a,b,c)=>{"use strict";c.d(b,{n:()=>x});var d=c(48249),e=c(67484),f=c(44384),g=c(7833),h=c(15819),i=c(10316),j=c(46674),k=c(24520),l=c(50514),m=c(15273),n=c(45231),o=c(66400),p=c(86588),q=c(82594),r=c(59347),s=c(33281),t=c(64676),u=c(40893),v=c(35857),w=c(47276);function x({isOpen:a,htmlAppPreviews:b,activeHtmlAppPreviewPath:c,onShowHtmlAppPreview:r,onMinimizeHtmlAppPreview:z,onCloseHtmlAppPreview:A,onClose:B,onOpenApp:C}){let{t:D,i18n:E}=(0,f.Bd)(),[F,G]=(0,e.useState)([]),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(""),[L,M]=(0,e.useState)(!1),[N,O]=(0,e.useState)(""),[P,Q]=(0,e.useState)(!1),[R,S]=(0,e.useState)({}),T=(0,e.useRef)(null),U=(0,e.useCallback)(async()=>{I(!0);let a=await s.t4.runPromiseExit((0,w.mi)());"Success"===a._tag?G(a.value):console.error("Failed to load html apps",a.cause),I(!1)},[]),V=(0,e.useCallback)(()=>{M(!1),B()},[B]),W=(0,e.useMemo)(()=>{let a=J.trim().toLowerCase();return a?F.filter(b=>b.name.toLowerCase().includes(a)||b.title.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):F},[F,J]),X=(0,e.useMemo)(()=>F.filter(a=>!a.builtin).length,[F]),Y=J.trim().length>0,Z=E.resolvedLanguage?.startsWith("zh")?"https://opencockpit.dev/zh/docs/agent/html-apps/":"https://opencockpit.dev/en/docs/agent/html-apps/",$=(0,e.useCallback)(async()=>{let a=N.trim();if(!a)return;Q(!0);let b=await s.t4.runPromiseExit((0,w.ot)(a));if("Success"===b._tag)b.value.alreadyExists?(0,g.oR)(D("htmlApps.alreadyAdded"),"info"):((0,g.oR)(D("htmlApps.added"),"success"),(0,v.N)()),O(""),M(!1),await U();else{let a="Fail"===b.cause._tag?b.cause.error:null,c=a?.cause,d=c instanceof Error?c.message:D("htmlApps.addFailed");(0,g.oR)(d,"error")}Q(!1)},[N,U,D]),_=(0,e.useCallback)(async a=>{"Success"===(await s.t4.runPromiseExit((0,w.m3)(a)))._tag?(G(b=>b.filter(b=>b.id!==a)),(0,v.N)()):(0,g.oR)(D("common.deleteFailed"),"error")},[D]),aa=(0,e.useCallback)(a=>{C?C(a):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),V()},[V,C]),ab=(0,e.useCallback)(a=>{C?C(a):window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),z()},[z,C]),ac=(0,e.useCallback)(a=>{let b=(0,t.Xe)(a);window.open((0,t.PB)(b,window.location.origin),"_blank")},[]),ad=(0,e.useCallback)(a=>{S(b=>({...b,[a]:(b[a]||0)+1}))},[]),ae=(0,e.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,g.oR)(D("common.copiedPath"),"success")}catch{(0,g.oR)(D("common.copyFailed"),"error")}},[D]);return(0,d.jsxs)(d.Fragment,{children:[a&&(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:V}),(0,d.jsxs)("div",{className:h.aO,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:D("htmlApps.title")}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(i.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-foreground-subtle pointer-events-none"}),(0,d.jsx)("input",{ref:T,type:"text",value:J,onChange:a=>K(a.target.value),placeholder:D("htmlApps.searchPlaceholder"),className:"pl-7 pr-6 py-1 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),J&&(0,d.jsx)("button",{onClick:()=>{K(""),T.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:D("fileBrowser.clear"),children:(0,d.jsx)(j.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("button",{onClick:()=>M(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:D("htmlApps.addHtmlApp"),children:[(0,d.jsx)(k.A,{className:"w-4 h-4"})," ",D("htmlApps.add")]}),(0,d.jsx)("button",{onClick:V,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",title:D("common.close"),children:(0,d.jsx)(j.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:H?(0,d.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:D("common.loading")}):(0,d.jsxs)(d.Fragment,{children:[W.length>0&&(0,d.jsx)("div",{className:h.jL,children:W.map(a=>(0,d.jsx)(y,{app:a,onOpenConsole:()=>aa(a.path),onOpenExternal:()=>ac(a.path),onPreview:()=>{r({path:a.path,title:a.title,icon:a.icon}),V()},onDelete:()=>_(a.id),onCopyPath:()=>ae(a.path)},a.id))}),0===W.length&&Y&&(0,d.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:D("htmlApps.emptyNoMatch")}),!Y&&0===X&&(0,d.jsxs)("div",{className:`text-center text-muted-foreground py-8 text-sm space-y-2${W.length>0?" mt-4 border-t border-border/60":""}`,children:[(0,d.jsx)("p",{children:D("htmlApps.emptyNoApps")}),(0,d.jsxs)("p",{children:[D("htmlApps.emptyCreatePrefix")," ",(0,d.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/html"})," ",D("htmlApps.emptyCreateSuffix")]}),(0,d.jsxs)("p",{children:[(0,d.jsx)("button",{type:"button",onClick:()=>M(!0),className:"text-brand hover:underline",children:D("htmlApps.addExisting")})," \xb7 ",(0,d.jsx)("a",{href:Z,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline",children:D("htmlApps.viewDocs")})]})]})]})})]})]}),a&&L&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:()=>{P||(M(!1),O(""))}}),(0,d.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-lg mx-4 p-5",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:D("htmlApps.addHtmlApp")}),(0,d.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:D("htmlApps.pathLabel")}),(0,d.jsx)("input",{type:"text",value:N,onChange:a=>O(a.target.value),onKeyDown:a=>{"Enter"!==a.key||P||$()},placeholder:"/Users/you/.../report.html",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,d.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,d.jsx)("button",{onClick:()=>{M(!1),O("")},disabled:P,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors disabled:opacity-50",children:D("common.cancel")}),(0,d.jsx)("button",{onClick:$,disabled:P||!N.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:P?D("htmlApps.adding"):D("htmlApps.add")})]})]})]}),b.map(a=>{let b=c===a.path;return(0,d.jsx)("div",{className:b?"fixed inset-0 z-[60] flex items-center justify-center bg-scrim p-0 md:p-4":"hidden",onClick:z,children:(0,d.jsxs)("div",{className:"bg-card shadow-lv3 border border-brand/30 w-full h-full md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.icon?(0,d.jsx)("span",{className:"text-base leading-none flex-shrink-0",children:a.icon}):(0,d.jsx)(l.A,{className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[35%]","data-tooltip":a.title,children:a.title}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground flex-shrink-0","aria-hidden":"true",children:"-"}),(0,d.jsx)("span",{className:"font-mono text-sm text-muted-foreground truncate min-w-0","data-tooltip":a.path,children:a.path}),(0,d.jsx)("button",{onClick:()=>ae(a.path),className:"text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.copyPath"),"aria-label":D("common.copyPath"),children:(0,d.jsx)(m.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("button",{onClick:z,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.minimize"),children:(0,d.jsx)(n.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ab(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.openInConsole"),children:(0,d.jsx)(o.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ac(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("browser.openInNewWindow"),children:(0,d.jsx)(p.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>ad(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",title:D("common.refresh"),children:(0,d.jsx)(q.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:()=>A(a.path),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,d.jsx)(u.O,{filePath:a.path,reloadKey:R[a.path]||0})})]})},a.path)})]})}function y({app:a,onOpenConsole:b,onOpenExternal:c,onPreview:g,onDelete:h,onCopyPath:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:`group flex flex-col h-full border border-border rounded-lg p-3 hover:border-brand hover:shadow-lv2 transition-all cursor-pointer ${a.valid?"":"opacity-60"}`,onClick:()=>a.valid&&g(),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,d.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,d.jsx)("span",{children:a.icon}):(0,d.jsx)(p.A,{className:"w-5 h-5"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground truncate","data-tooltip":a.title,children:a.title}),(0,d.jsxs)("div",{className:"font-mono text-[11px] text-muted-foreground truncate","data-tooltip":`/${a.name}`,children:["/",a.name]})]}),!a.valid&&(0,d.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:j("htmlApps.invalid")}),a.builtin&&(0,d.jsx)("span",{className:"flex-shrink-0 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:j("htmlApps.builtin")}),(0,d.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("button",{onClick:b,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:j("common.openInConsole"),children:(0,d.jsx)(o.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:c,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:j("browser.openInNewWindow"),children:(0,d.jsx)(p.A,{className:"w-4 h-4"})}),a.builtin?null:k?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>{l(!1),h()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:j("common.confirm")}),(0,d.jsx)("button",{onClick:()=>l(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:j("common.cancel")})]}):(0,d.jsx)("button",{onClick:()=>l(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:j("common.delete"),children:(0,d.jsx)(r.A,{className:"w-4 h-4"})})]})]}),(0,d.jsxs)("div",{className:"font-mono text-xs text-muted-foreground mt-2 break-all",children:[a.path,(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),i()},className:"inline-flex align-middle ml-1 p-0.5 hover:text-foreground hover:bg-hover rounded transition-colors",title:j("common.copyPath"),children:(0,d.jsx)(m.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("p",{className:"text-sm text-muted-foreground mt-2 pt-2 border-t border-border/60 break-words whitespace-pre-wrap",children:a.description||(0,d.jsx)("span",{className:"italic opacity-60",children:j("htmlApps.noDescription")})})]})}},50508:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{LD:()=>l,Mm:()=>j,Qr:()=>a,fw:()=>i,o$:()=>k});var e=c(48249),f=c(67484),g=c(33281),h=c(85655);let a=a=>a.split("/").pop()||a;function i(a,b){let c=Math.floor((Date.now()-b)/6e4);if(c<1)return a("common.justNow");if(c<60)return a("common.minutesAgo",{count:c});let d=Math.floor(c/60);return d<24?a("common.hoursAgo",{count:d}):a("common.daysAgo",{count:Math.floor(d/24)})}function j(a,b){return"loading"===b?a("sessions.running"):"unread"===b?a("sessions.done"):void 0}function k(){let[a,b]=(0,f.useState)(null),[c,d]=(0,f.useState)({}),e=(0,f.useCallback)((a,c)=>{let e=c.currentTarget.getBoundingClientRect(),f=e.top;f+260>window.innerHeight&&(f=Math.max(8,window.innerHeight-260-8)),b({session:a,top:f,left:e.right+8}),d(b=>a.cwd in b?b:(g.t4.runPromiseExit((0,h.ue)(a.cwd)).then(b=>{"Success"===b._tag&&d(c=>({...c,[a.cwd]:b.value.branch}))}),{...b,[a.cwd]:null}))},[]),i=(0,f.useCallback)(()=>b(null),[]);return{card:a,branch:a?c[a.session.cwd]??null:null,show:e,hide:i}}function l({card:b,branch:c}){if(!b)return null;let{session:d}=b,f=(d.firstMessages?.length??0)>0||(d.lastMessages?.length??0)>0;return(0,e.jsxs)("div",{className:"fixed z-[60] w-72 max-h-[260px] overflow-y-auto bg-popover border border-border rounded-lg shadow-lv2 p-3 pointer-events-none",style:{top:b.top,left:b.left},children:[(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate",children:a(d.cwd)}),d.title&&(0,e.jsx)("div",{className:"text-xs font-medium text-foreground truncate mt-0.5",children:d.title}),(0,e.jsx)("div",{className:"text-[10px] text-foreground-faint truncate mt-0.5",children:d.cwd}),c&&(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:c})]}),f?(0,e.jsxs)("div",{className:"space-y-0.5 text-xs border-t border-border/50 mt-2 pt-2",children:[d.firstMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`f-${b}`)),(d.lastMessages?.length??0)>0&&(0,e.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),d.lastMessages?.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground/90 truncate",children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`l-${b}`))]}):d.lastUserMessage?(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:d.lastUserMessage}):null]})}d()}catch(a){d(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)},53087:(a,b,c)=>{"use strict";c.d(b,{fz:()=>d,mg:()=>e});let d=50;function e(a){var b;let c=0;for(;c<a.length-1&&(!0===(b=a[c]).truncated||b.files.length>=d);)c++;return c}},53954:(a,b,c)=>{"use strict";c.d(b,{d:()=>i});var d=c(48249),e=c(67484),f=c(44384),g=c(36043);c(33281),c(65484);let h=(0,e.memo)(function({entry:a,index:b,highlighted:c,top:e,onEnter:f,onPick:g,onHover:h}){return(0,d.jsxs)("div",{role:"option","aria-selected":c,onClick:()=>f(a.path),onDoubleClick:()=>g(a.path),onMouseMove:()=>h(b),style:{position:"absolute",top:e,left:0,right:0,height:30},className:`flex items-center gap-2 px-3 text-xs cursor-pointer select-none ${c?"bg-hover text-foreground":"text-foreground"} ${a.hidden?"opacity-60":""}`,children:[(0,d.jsx)("svg",{className:"w-4 h-4 shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,d.jsx)("span",{className:"flex-1 truncate",children:a.name}),a.git&&(0,d.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground border border-border rounded px-1",children:"git"})]})});function i({onPick:a}){let b,c,j,{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(-1),v=(0,e.useRef)(null),w=(0,e.useRef)(null);(0,e.useRef)(0);let x=n?.sep??"/",{base:y,prefix:z}=(b="\\"===x?Math.max(l.lastIndexOf("/"),l.lastIndexOf("\\")):l.lastIndexOf("/"),c=l.slice(0,b+1),j=l.slice(b+1),""===c&&"~"===j?{base:"~",prefix:""}:{base:c,prefix:j}),A=p!==y,B=(0,e.useMemo)(()=>{if(!n)return[];let a=z.toLowerCase(),b=n.dirs.filter(b=>r||!b.hidden||a.startsWith("."));return a?[...b.filter(b=>b.name.toLowerCase().startsWith(a)),...b.filter(b=>!b.name.toLowerCase().startsWith(a)&&b.name.toLowerCase().includes(a))]:b},[n,z,r]),C=(0,e.useMemo)(()=>!n||n.error||A?null:z?B.find(a=>a.name.toLowerCase()===z.toLowerCase())?.path??null:n.path,[n,z,B,A]),D=(0,e.useCallback)(a=>{m(a.endsWith(x)?a:a+x),v.current?.focus()},[x]),E=(0,g.Te)({count:B.length,getScrollElement:()=>w.current,estimateSize:()=>30,overscan:8}),F=n?.error&&!A?k(`folderPicker.${n.error}`):null;return(0,d.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col gap-2 p-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:v,type:"text",value:l,onChange:a=>m(a.target.value),onKeyDown:b=>{if("Enter"===b.key&&(b.metaKey||b.ctrlKey))b.preventDefault(),C&&a(C);else if("ArrowDown"===b.key)b.preventDefault(),u(a=>Math.min(a+1,B.length-1));else if("ArrowUp"===b.key)b.preventDefault(),u(a=>Math.max(a-1,0));else if("Tab"===b.key||"Enter"===b.key){let a=B[t];a?(b.preventDefault(),D(a.path)):"Tab"===b.key&&b.preventDefault()}},placeholder:k("folderPicker.placeholder"),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"flex-1 min-w-0 px-2.5 py-1.5 text-xs font-mono border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,d.jsx)("button",{onClick:()=>C&&a(C),disabled:!C,"data-tooltip":C??void 0,className:"shrink-0 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",children:k("folderPicker.open")})]}),(0,d.jsx)("div",{className:"flex items-center gap-0.5 min-h-6 overflow-x-auto text-xs text-muted-foreground whitespace-nowrap",children:n?.segments.map((a,b)=>(0,d.jsxs)("span",{className:"flex items-center",children:[b>1&&(0,d.jsx)("span",{className:"px-0.5 text-foreground-subtle",children:"›"}),(0,d.jsx)("button",{onClick:()=>D(a.path),className:"px-1 py-0.5 rounded hover:bg-hover hover:text-foreground transition-colors",children:a.name})]},a.path))}),(0,d.jsx)("div",{ref:w,role:"listbox",className:`flex-1 min-h-0 overflow-y-auto border border-border rounded transition-opacity ${A?"opacity-60":""}`,children:F?(0,d.jsx)("div",{className:"p-3 text-xs text-red-11",children:F}):n&&0===B.length?(0,d.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:k(z?"folderPicker.noMatch":"folderPicker.empty")}):(0,d.jsx)("div",{style:{height:E.getTotalSize(),position:"relative"},children:E.getVirtualItems().map(b=>(0,d.jsx)(h,{entry:B[b.index],index:b.index,highlighted:b.index===t,top:b.start,onEnter:D,onPick:a,onHover:u},B[b.index].path))})}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[n&&(0,d.jsx)("button",{onClick:()=>D(n.home),className:"px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:"~"}),n?.roots.map(a=>(0,d.jsx)("button",{onClick:()=>D(a),className:"px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-hover transition-colors font-mono",children:a},a))]}),(0,d.jsxs)("label",{className:"flex items-center gap-1 text-muted-foreground cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:r,onChange:a=>s(a.target.checked)}),k("folderPicker.showHidden")]}),(0,d.jsx)("span",{className:"hidden md:inline text-foreground-subtle",children:k("folderPicker.hint")})]})]})}},54727:(a,b,c)=>{"use strict";c.d(b,{y:()=>q});var d=c(32891),e=c(10259),f=c(1370);function g(a){let b=[];return a.forEach((a,c)=>b.push({node:a,start:c,end:c+a.nodeSize})),b}function h(a,b){return"heading"===a.type.name&&a.attrs.level<=b}function i(a){for(let b=a.depth;b>0;b--){let c=a.node(b).type.name;if("listItem"===c||"taskItem"===c)return b}return -1}function j(a,b,c,d,e){let f=b.slice(c,d),g=b.slice(d,e);a.replaceWith(c,e,g.content.append(f.content))}function k(a,b){let c=Math.max(0,Math.min(b,a.doc.content.size));a.setSelection(e.U3.near(a.doc.resolve(c)))}let l=new Set(["paragraph","bulletList","orderedList","taskList"]);function m(a,b,c){let{doc:d,selection:e}=a,h=e.$from,i=h.before(1),j=g(d),m=j.findIndex(a=>a.start===i);if(m<0)return!1;let n=m;for(;n>0&&l.has(j[n-1].node.type.name);)n--;let o=m;for(;o<j.length-1&&l.has(j[o+1].node.type.name);)o++;let p=[],q=-1,r="paragraph"===j[m].node.type.name?-1:h.index(1);for(let a=n;a<=o;a++){let b=j[a].node;if("paragraph"===b.type.name)a===m&&(q=p.length),p.push({kind:"paragraph",node:b});else{let c=b.type.name,d=0;b.forEach(b=>{a===m&&d===r&&(q=p.length),p.push({kind:c,node:b}),d++})}}if(q<0)return!1;let s=q+(c>0?1:-1);if(s<0||s>=p.length)return!1;if(b){let c,d,e,g=p[q];p[q]=p[s],p[s]=g;let i=function(a,b){let c=[],d=0;for(;d<a.length;){if("paragraph"===a[d].kind){c.push(a[d].node),d++;continue}let e=a[d].kind,f=[];for(;d<a.length&&a[d].kind===e;)f.push(a[d].node),d++;c.push(b.schema.nodes[e].create(null,f))}return f.FK.from(c)}(p,a),l=j[n].start,m=j[o].end,r=a.tr;r.replaceWith(l,m,i);let t=(c=0,d=0,e=-1,i.forEach(a=>{if(!(e>=0))if("paragraph"===a.type.name)c===s&&(e=d+1),c++,d+=a.nodeSize;else{let b=d+1;a.forEach(a=>{e>=0||(c===s&&(e=b+2),c++,b+=a.nodeSize)}),d+=a.nodeSize}}),e);k(r,t>=0?l+t+h.parentOffset:l),b(r.scrollIntoView())}return!0}function n(a,b,c){let d=a.selection.$from;if(1===d.depth&&"heading"===d.parent.type.name)return function(a,b,c){let{doc:d,selection:e}=a,f=e.$from.before(1),i=g(d),l=i.findIndex(a=>a.start===f);if(l<0)return!1;let m=i[l].node.attrs.level,n=l+1;for(;n<i.length&&!h(i[n].node,m);)n++;let o=i[l].start,p=i[n-1].end;if(c>0){if(n>=i.length)return!1;let c=i[n].node.attrs.level,f=n+1;for(;f<i.length&&!h(i[f].node,c);)f++;let g=i[f-1].end;if(b){let c=a.tr,f=d.slice(p,g).content.size;j(c,d,o,p,g),k(c,o+f+(e.from-o)),b(c.scrollIntoView())}return!0}if(0===l)return!1;let q=l-1;for(;q>=0&&!h(i[q].node,m);)q--;if(q<0||i[q].node.attrs.level<m)return!1;let r=i[q].start;if(b){let c=a.tr;j(c,d,r,o,p),k(c,r+(e.from-o)),b(c.scrollIntoView())}return!0}(a,b,c);let e=i(d);if(e>0){let f=d.node(e-1),g=d.index(e-1);return(c>0?g<f.childCount-1:g>0)?function(a,b,c,d){let{doc:e,selection:f}=a,g=f.$from,h=g.node(d),i=g.node(d-1),l=g.index(d-1),m=g.before(d),n=m+h.nodeSize;if(c>0){if(l>=i.childCount-1)return!1;let c=n+i.child(l+1).nodeSize;if(b){let d=a.tr,g=e.slice(n,c).content.size;j(d,e,m,n,c),k(d,m+g+(f.from-m)),b(d.scrollIntoView())}return!0}if(l<=0)return!1;let o=m-i.child(l-1).nodeSize;if(b){let c=a.tr;j(c,e,o,m,n),k(c,o+(f.from-m)),b(c.scrollIntoView())}return!0}(a,b,c,e):2===e&&m(a,b,c)}let f=d.depth>=1?d.node(d.depth-1).type.name:"doc";return"paragraph"===d.parent.type.name&&"doc"===f&&m(a,b,c)}function o(a,b){let{state:c}=a,d=c.selection.$from,e=d.parent.type.name;if("doc"===(d.depth>=1?d.node(d.depth-1).type.name:"doc")&&("heading"===e||"paragraph"===e)){let c=(("heading"===e?d.parent.attrs.level-1:3)+(b>0?1:-1)+4)%4;return 3===c?a.chain().setParagraph().run():a.chain().setHeading({level:c+1}).run()}let f=i(d);if(f>0){let c=d.node(f).type.name;return b<0?a.commands.liftListItem(c):a.commands.sinkListItem(c)}return!1}function p(a,b){let{state:c}=a,d=c.selection;if(!d.empty)return!1;let e=d.$from,f=b>0?1:-1;for(let b=e.depth;b>0;b--)if("taskItem"===e.node(b).type.name){let d=e.before(b),g=c.doc.nodeAt(d);if(!g)return!1;let h=g.attrs.status??"todo",i=(("doing"===h?2:"done"===h?3:1)+f+4)%4;if(0===i)return a.chain().toggleTaskList().run();let j=2===i?"doing":3===i?"done":"todo";return a.chain().command(({tr:a})=>{let b=a.doc.nodeAt(d);return!!b&&(a.setNodeMarkup(d,void 0,{...b.attrs,status:j}),!0)}).run()}if("paragraph"!==e.parent.type.name)return!1;let g=e.depth>=1?e.node(e.depth-1).type.name:"doc";return("doc"===g||"listItem"===g)&&(1==(0+f+4)%4?a.chain().toggleTaskList().run():a.chain().toggleTaskList().command(({tr:a})=>(function(a,b){let c=a.selection.$from;for(let d=c.depth;d>0;d--)if("taskItem"===c.node(d).type.name){let e=c.before(d),f=a.doc.nodeAt(e);f&&a.setNodeMarkup(e,void 0,{...f.attrs,status:b});break}return!0})(a,"done")).run())}let q=d.YY.create({name:"noteOrgKeymap",addKeyboardShortcuts(){return{"Alt-ArrowUp":()=>this.editor.commands.command(({state:a,dispatch:b})=>n(a,b,-1)),"Alt-ArrowDown":()=>this.editor.commands.command(({state:a,dispatch:b})=>n(a,b,1)),"Alt-ArrowLeft":()=>o(this.editor,-1),"Alt-ArrowRight":()=>o(this.editor,1),"Shift-ArrowRight":()=>p(this.editor,1),"Shift-ArrowLeft":()=>p(this.editor,-1)}}})},55287:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Cv:()=>C,XO:()=>A});var e=c(48249),f=c(67484),g=c(44384),h=c(74429),i=c(33281),j=c(87808),k=c(25419),l=c(7122),m=c(42140),n=c(38896),o=c(36984),p=c(41051),q=c(70596),r=c(40159),s=c(13512),t=c(9804),u=c(7833),v=c(83377),w=a([s]);s=(w.then?(await w)():w)[0];let B="white-space:pre;padding:0 12px;min-height:20px;line-height:20px";function x(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 y(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 z(a){return a.map(a=>`<div style="${B}">${a}</div>`).join("")}let C=(0,f.forwardRef)(function({content:a,filePath:b,showLineNumbers:c=!0,showSearch:d=!0,className:n="",cwd:w,enableComments:A=!1,scrollToLine:C=null,scrollToLineAlign:D="center",onScrollToLineComplete:E,highlightKeyword:F=null,visibleLineRef:G,onCmdClick:H,onTokenHover:I,onTokenHoverLeave:J,onTokenHoverCancel:K,blameLines:L,inlineBlameLines:M,onSelectCommit:N,editable:O=!1,initialMtime:P,onEditorClose:Q,onSaved:R,onEditorStateChange:S,viMode:T=!1,onContentMutate:U,onEnterInsertMode:V,onViSave:W,viStateRef:X,initialCursorLine:Y,initialCursorCol:Z,onInitialCursorSet:$,onContentSearch:_},aa){let{t:ab}=(0,g.Bd)(),ac=(0,f.useRef)(a),ad=(0,f.useRef)(!1),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(()=>a.split("\n").length),ak=(0,f.useRef)(a.split("\n").length),[al,am]=(0,f.useState)({show:!1}),an=(0,f.useRef)(null),ao=(0,f.useRef)(null),ap=(0,f.useRef)(P),aq=(0,f.useRef)(null),ar=(0,f.useRef)(!1),as=(0,f.useRef)(!1),{parentRef:at,containerRef:au,searchInputRef:av,floatingToolbarRef:aw,suppressHoverRef:ax,bumpToolbarRef:ay,savedSelectionRef:az,highlightedLines:aA,isMounted:aB,cmdHeld:aC,flashLine:aD,isSearchVisible:aE,searchQuery:aF,caseSensitive:aG,wholeWord:aH,currentMatchIndex:aI,viewingComment:aJ,addCommentInput:aK,sendToAIInput:aL,aiBridge:aM,commentsEnabled:aN,updateComment:aO,deleteComment:aP,lines:aQ,matches:aR,rowData:aS,virtualizer:aT,commentsByEndLine:aU,linesWithComments:aV,setIsSearchVisible:aW,setSearchQuery:aX,setCaseSensitive:aY,setWholeWord:aZ,setViewingComment:a$,setAddCommentInput:a_,setSendToAIInput:a0,goToNextMatch:a1,goToPrevMatch:a2,handleSearchKeyDown:a3,handleCommentBubbleClick:a4,handleToolbarAddComment:a5,handleToolbarSendToAI:a6,handleToolbarExplain:a7,handleToolbarSearch:a8,handleCommentSubmit:a9,handleSendToAISubmit:ba,handleCommentSendToAI:bb,getHighlightedLineHtml:bc,suppressMatchScrollRef:bd,inlineBlameLineRef:be,inlineBlameVersion:bf}=(0,s.d)({content:a,filePath:b,showSearch:d,cwd:w,enableComments:!O&&A,scrollToLine:O?null:C,scrollToLineAlign:O?"center":D,onScrollToLineComplete:O?void 0:E,visibleLineRef:O?void 0:G,onContentSearch:_}),bg=(0,l.iN)(),bh=(0,f.useRef)(null),bi=(0,f.useRef)(null),bj=(0,f.useRef)({line:0,col:0}),bk=(0,f.useRef)({line:0,col:0}),bl=(0,v.A)({lines:aQ,enabled:T&&!O,onContentChange:a=>{bj.current={line:bk.current.line,col:bk.current.col},U?.(a)},onEnterInsert:(a,b,c)=>{let d=b;if("a"===c)d=b+1;else if("A"===c)d=(aQ[a]??"").length;else if("I"===c){let b=(aQ[a]??"").search(/\S/);d=b>=0?b:0}else("o"===c||"O"===c)&&(d=0);bj.current={line:a,col:d},V?.(a)},onSave:W,getVisibleLineCount:()=>{let a=at.current;return a?Math.floor(a.clientHeight/20):20},scrollToLine:(a,b)=>{let c=aS.findIndex(b=>"code"===b.type&&b.lineIndex===a);c>=0&&aT.scrollToIndex(c,{align:b||"auto"})},onSearchExecute:a=>{aX(a),aW(!1)},onSearchNext:a1,onSearchPrev:a2,onSearchClear:()=>{aX("")}});(0,f.useEffect)(()=>{X&&(X.current={cursorLine:bl.state.cursorLine,cursorCol:bl.state.cursorCol}),bk.current={line:bl.state.cursorLine,col:bl.state.cursorCol}},[X,bl.state.cursorLine,bl.state.cursorCol]);let bm=(0,f.useRef)(null);(0,f.useEffect)(()=>{T&&!O&&null!=Y&&b&&bm.current!==b&&(bm.current=b,bl.setCursorLine(Y-1),null!=Z&&bl.setCursorCol(Z-1),$?.())},[T,O,Y,Z,b]),(0,f.useEffect)(()=>{if(!T||O)return;let a=au.current;if(!a)return;let b=a=>{let b=a.target;"TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable||bl.handleKeyDown(a)&&(a.preventDefault(),a.stopPropagation())};return a.addEventListener("keydown",b,!0),()=>a.removeEventListener("keydown",b,!0)},[T,O,bl.handleKeyDown]),(0,f.useEffect)(()=>{if(!T||O)return;let a=au.current;a&&"normal"===bl.state.mode&&requestAnimationFrame(()=>{let b=document.activeElement;b&&("TEXTAREA"===b.tagName||"INPUT"===b.tagName||b.isContentEditable)||a.focus()})},[T,O,bl.state.mode,a]);let bn=(0,f.useCallback)(a=>{if(!T||O)return;let b=a.target.closest("[data-line]");if(b){let c=parseInt(b.getAttribute("data-line"),10);if(!isNaN(c)){bl.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=aQ[c-1]??"";bl.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=au.current;d&&d.focus()},[T,O,bl.setCursorLine,bl.setCursorCol,aQ]),bo=(0,f.useCallback)(a=>{T&&!O&&requestAnimationFrame(()=>{let a=window.getSelection(),b=a?.toString().trim();b&&/^\S+$/.test(b)&&(bd.current=!0,aX(b))})},[T,O,aX,bd]);(0,f.useEffect)(()=>{"command"===bl.state.mode?setTimeout(()=>bh.current?.focus(),0):"search"===bl.state.mode&&setTimeout(()=>bi.current?.focus(),0)},[bl.state.mode]),(0,f.useEffect)(()=>{let a=at.current;if(!a)return;let b=()=>{(K??J)?.()};return a.addEventListener("mousedown",b),()=>a.removeEventListener("mousedown",b)},[K,J]),(0,f.useEffect)(()=>{aK||aL?(ax.current=!0,J?.()):aw.current||(ax.current=!1)},[aK,aL,J]),(0,f.useLayoutEffect)(()=>{let a=az.current;if(!a)return;let b=window.getSelection();if(b&&!b.isCollapsed)return;let c=at.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,s.o)(d,a.startOffset),g=(0,s.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 bp=(0,f.useCallback)((a,b,c)=>{ax.current||I?.(a,b,c)},[I]),bq=(0,f.useCallback)((a,b)=>{ax.current||H?.(a,b)},[H]),br=Math.max(4,String(O?ai:aQ.length).length),bs=(0,f.useMemo)(()=>{let a=0;for(let b of aQ){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},[aQ]);(0,f.useEffect)(()=>{if(O){ac.current=a;let b=a.split("\n").length;ak.current=b,aj(b),ad.current=!1,af(!1),am({show:!1}),ap.current=P}},[O,a,P]),(0,f.useEffect)(()=>{if(!O)return;let b=an.current;if(!b)return;let c=a.split("\n"),d=c.map((a,b)=>aA[b]||(0,o.ZD)(a||" "));b.innerHTML=z(d),requestAnimationFrame(()=>{let a,d;T?(a=Math.max(0,Math.min(bj.current.line,c.length-1)),d=bj.current.col):(a=Math.max(0,Math.min((G?.current??1)-1,c.length-1)),d=0),b.focus(),y(b,{line:a,offset:d});let e=G?.current??1;ao.current&&(ao.current.scrollTop=(e-1)*20)})},[O]),(0,f.useEffect)(()=>{O&&S?.({isDirty:ae,isSaving:ag})},[O,ae,ag,S]);let bt=(0,f.useCallback)(()=>{let a=an.current;if(!a)return ac.current;let b=[];for(let c of a.childNodes){let a=c.textContent||"";b.push(" "===a?"":a)}return b.join("\n")},[]),bu=(0,f.useCallback)(()=>{aq.current&&clearTimeout(aq.current),aq.current=setTimeout(async()=>{let a=an.current;if(a&&!as.current){ac.current=bt();try{let c=await (0,o.kS)(),d=(0,o.sQ)(b),e=document.documentElement.classList.contains("dark"),f=ac.current.split("\n"),g=c.codeToTokens(f.join("\n"),{lang:d,theme:e?"github-dark":"github-light"}).tokens.map(a=>(0,o.b8)(a)),h=x(a);ar.current=!0,a.innerHTML=z(g),ar.current=!1,h&&y(a,h)}catch{}}},300)},[b,bt]);(0,f.useEffect)(()=>{if(O)return()=>{aq.current&&clearTimeout(aq.current)}},[O]);let bv=(0,f.useCallback)(()=>{let a=an.current;if(!a)return;ad.current||(ad.current=!0,af(!0));let b=a.children.length;b!==ak.current&&(ak.current=b,aj(b))},[]),bw=(0,f.useCallback)(()=>{ar.current||as.current||(bv(),bu())},[bv,bu]),bx=(0,f.useCallback)(a=>{if(!a.nativeEvent.isComposing&&("Tab"===a.key&&(a.preventDefault(),document.execCommand("insertText",!1," ")),"Enter"===a.key)){a.preventDefault();let b=an.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=x(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,o.ZD)(j||" ");let l=document.createElement("div");l.setAttribute("style",B),l.innerHTML=(0,o.ZD)(k||" "),e.after(l),y(b,{line:g+1,offset:0}),bv(),bu()}},[bv,bu]),by=(0,f.useCallback)(a=>{a.preventDefault();let b=a.clipboardData.getData("text/plain");document.execCommand("insertText",!1,b)},[]),bz=(0,f.useCallback)(async(a=!1)=>{if(!w)return;ac.current=bt(),ah(!0);let c=await i.t4.runPromiseExit((0,j.OJ)({cwd:w,path:b,content:ac.current,expectedMtime:a?void 0:ap.current}));if("Failure"===c._tag){console.error("Error saving file:",c.cause),(0,u.oR)(ab("toast.saveFailed"),"error"),ah(!1);return}let d=c.value,e=d.data;if(409===d.status&&e?.conflict){let a=await i.t4.runPromiseExit((0,k.K)(w,b));"Success"===a._tag&&a.value.ok&&"string"==typeof a.value.data?.content?am({show:!0,diskContent:a.value.data.content}):am({show:!0}),ah(!1);return}if(!d.ok){console.error("Error saving file: status",d.status),(0,u.oR)(ab("toast.saveFailed"),"error"),ah(!1);return}let f=e?.mtime;f&&(ap.current=f),ad.current=!1,af(!1),am({show:!1}),(0,u.oR)(ab("toast.savedSuccess"),"success"),R?.(),ah(!1)},[w,b,bt,R,ab]),bA=(0,f.useCallback)(async()=>{ae&&!ag&&await bz(!1)},[ae,ag,bz]),bB=(0,f.useCallback)(async()=>{am({show:!1}),await bz(!0)},[bz]),bC=(0,f.useCallback)(()=>{if(void 0!==al.diskContent){ac.current=al.diskContent;let b=al.diskContent.split("\n").length;ak.current=b,aj(b);let c=al.diskContent!==a;ad.current=c,af(c);let d=an.current;if(d){let a=al.diskContent.split("\n");d.innerHTML=z(a.map(a=>(0,o.ZD)(a||" "))),bu()}}am({show:!1}),R?.()},[al.diskContent,a,R,bu]),bD=(0,f.useCallback)(()=>{let a=ao.current;return a?Math.floor(a.scrollTop/20)+1:G?.current??1},[G]),bE=(0,f.useCallback)(async()=>{(!ae||await (0,u.lJ)(ab("codeViewer.unsavedConfirm"),{danger:!0,confirmText:ab("codeViewer.discardChanges"),cancelText:ab("codeViewer.continueEditing")}))&&Q?.(bD())},[ae,Q,bD]);(0,f.useEffect)(()=>{if(!O)return;let a=a=>{(a.metaKey||a.ctrlKey)&&"s"===a.key&&(a.preventDefault(),bA())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[O,bA]);let bF=(0,f.useCallback)(()=>{let a=bt();U?.(a);let b=an.current,c=b?x(b):null,d=bD();if(bl.enterNormal(),c){bl.setCursorLine(c.line);let b=a.split("\n")[c.line]??"";bl.setCursorCol(Math.max(0,Math.min(c.offset,Math.max(0,b.length-1))))}else bl.setCursorLine(Math.max(0,d-1));Q?.(d)},[bt,U,bD,Q,bl]);(0,f.useEffect)(()=>{if(!O)return;let a=a=>{let b="Escape"===a.key,c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;(b||T&&c)&&(a.preventDefault(),a.stopPropagation(),T?ad.current?(0,u.lJ)(ab("codeViewer.unsavedExitConfirm"),{danger:!0,confirmText:ab("codeViewer.discardChanges"),cancelText:ab("codeViewer.continueEditing")}).then(a=>{a&&bF()}):bF():bE())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[O,T,bE,bF]);let bG=(0,f.useCallback)(()=>{ad.current||(ad.current=!0,af(!0))},[]);(0,f.useImperativeHandle)(aa,()=>({save:bA,close:bE,markDirty:bG,get isDirty(){return ad.current},get isSaving(){return ag}}),[bA,bE,bG,ag]);let bH=!!(L&&L.length>0),bI=(0,f.useMemo)(()=>{if(!L)return new Map;let a=[...new Set(L.map(a=>a.author))],b=new Map;return a.forEach((a,c)=>{b.set(a,r.j[c%r.j.length])}),b},[L]),[bJ,bK]=(0,f.useState)(null),[bL,bM]=(0,f.useState)(null);(0,f.useEffect)(()=>{bK(null),bM(null)},[L]);let bN=(0,f.useCallback)((a,b)=>{bK(a.author);let c=b.currentTarget.getBoundingClientRect();bM({line:a,x:c.right+8,y:c.top})},[]),bO=(0,f.useCallback)(()=>{bK(null),bM(null)},[]),bP=(0,f.useCallback)(a=>{if(!N)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};N(b),bM(null)},[N]),bQ=`${br+2}ch`;return(0,e.jsxs)("div",{ref:au,className:`h-full flex flex-col outline-none ${n}`,tabIndex:0,onClick:bn,onDoubleClick:bo,children:[O&&al.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-11 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:ab("codeViewer.fileModifiedExternally")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bC,className:"px-3 py-1 text-sm rounded border border-border hover:bg-hover transition-colors",children:ab("codeViewer.useDiskVersion")}),(0,e.jsx)("button",{onClick:bB,className:"px-3 py-1 text-sm rounded bg-amber-500 text-white hover:bg-amber-600 transition-colors",children:ab("codeViewer.forceOverwrite")})]})]}),!O&&d&&aE&&(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)("input",{ref:av,type:"text",value:aF,onChange:a=>aX(a.target.value),onKeyDown:a3,placeholder:ab("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:()=>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-hover"}`,title:ab("codeViewer.caseSensitive"),children:"Aa"}),(0,e.jsx)("button",{onClick:()=>aZ(!aH),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${aH?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-hover"}`,title:ab("codeViewer.wholeWordMatch"),children:"[ab]"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:aR.length>0?`${aI+1}/${aR.length}`:ab("common.noMatch")}),(0,e.jsx)("button",{onClick:a2,disabled:0===aR.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ab("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:a1,disabled:0===aR.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:ab("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:()=>{aW(!1),aX("")},className:"p-1 rounded hover:bg-hover",title:ab("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"})})})]}),O?(0,e.jsx)("div",{ref:ao,className:"flex-1 overflow-auto bg-card",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-card",style:{width:bQ},children:Array.from({length:ai},(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:an,contentEditable:!0,suppressContentEditableWarning:!0,onInput:bw,onKeyDown:bx,onPaste:by,onCompositionStart:()=>{as.current=!0},onCompositionEnd:()=>{as.current=!1,bw()},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:at,className:`flex-1 overflow-auto font-mono text-sm bg-card${aC?" cmd-held-container":""}`,children:(0,e.jsx)("div",{style:{height:`${aT.getTotalSize()}px`,minWidth:"100%",width:bH?`calc(${br+bs+10}ch + 13rem)`:`${br+bs+10}ch`,position:"relative"},children:aT.getVirtualItems().map(a=>{let b=aS[a.index];if("code"!==b.type)return null;let d=b.lineIndex,f=d+1,g=aA[d]||(0,o.ZD)(aQ[d]||""),h=bc(d,g,F),i=aV.has(f),j=aU.get(f),k=j?.[0],l=!!(aK&&f>=aK.range.start&&f<=aK.range.end),m=bf>=0?be.current:null,n=!O&&M&&m===f?M[d]??null:null,p=bH?L[d]:void 0,q=bH&&d>0?L[d-1]:void 0,s=!!p&&(!q||q.hash!==p.hash),t=p?bI.get(p.author):void 0;return(0,e.jsx)(r.S,{virtualKey:a.key,lineNum:f,highlightedHtml:h,hasComments:i,firstComment:k,lineCommentsCount:j?.length,isInRange:l,showLineNumbers:c,lineNumChars:br,commentsEnabled:aN,virtualItemSize:a.size,virtualItemStart:a.start,onCommentBubbleClick:a4,onCmdClick:bq,onTokenHover:bp,onTokenHoverLeave:J,flashLine:aD,blameLine:p,showBlameInfo:s,blameAuthorColor:t,isBlameHovered:!!(p&&bJ===p.author),onBlameClick:bP,onBlameMouseEnter:bN,onBlameMouseLeave:bO,inlineBlameData:n,onInlineBlameClick:bP,isCursorLine:T&&!O&&bl.state.cursorLine===d,cursorCol:T&&!O&&bl.state.cursorLine===d?bl.state.cursorCol:void 0},a.key)})})}),T&&(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"===bl.state.mode&&(0,e.jsx)("span",{className:"text-green-11 font-medium",children:"NORMAL"}),"insert"===bl.state.mode&&(0,e.jsx)("span",{className:"text-blue-11 font-medium",children:"INSERT"}),"command"===bl.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:bh,value:bl.state.commandInput,onChange:a=>bl.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(),bl.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),"search"===bl.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:bi,value:bl.state.searchInput,onChange:a=>bl.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(),bl.handleKeyDown(a.nativeEvent))},className:"flex-1 bg-transparent outline-none text-foreground ml-0.5",spellCheck:!1,autoComplete:"off"})]}),bl.state.keyBuffer&&"normal"===bl.state.mode&&(0,e.jsx)("span",{className:"ml-2 text-muted-foreground",children:bl.state.keyBuffer}),bl.state.isDirty&&("normal"===bl.state.mode||"command"===bl.state.mode)&&(0,e.jsx)("span",{className:"ml-2 text-amber-11",children:"[+]"}),(0,e.jsxs)("span",{className:"ml-auto text-muted-foreground",children:[bl.state.cursorLine+1,":",bl.state.cursorCol+1]})]}),aB&&bg&&(0,h.createPortal)((0,e.jsxs)(e.Fragment,{children:[!O&&(0,e.jsx)(p.fS,{floatingToolbarRef:aw,bumpRef:ay,container:bg,onAddComment:a5,onSendToAI:a6,onSearch:_?a8:void 0,onExplain:aM?a7:void 0,isChatLoading:aM?.isLoading}),!O&&aK&&(0,e.jsx)(m.t,{x:aK.x,y:aK.y,range:aK.range,filePath:b,lineSnapshot:aK.lineSnapshot,container:bg,onSubmit:a9,onSendToAI:aM?bb:void 0,onClose:()=>a_(null),isChatLoading:aM?.isLoading}),!O&&aL&&(0,e.jsx)(m.G,{x:aL.x,y:aL.y,range:aL.range,filePath:b,lineSnapshot:aL.lineSnapshot,container:bg,onSubmit:ba,onClose:()=>a0(null),isChatLoading:aM?.isLoading}),!O&&aJ&&(0,e.jsx)(q.t,{x:aJ.x,y:aJ.y,comment:aJ.comment,container:bg,onClose:()=>a$(null),onUpdateComment:aO,onDeleteComment:aP}),bL&&(0,e.jsxs)("div",{className:"fixed z-50 bg-card border border-border rounded-lg shadow-lv2 p-3 max-w-lg",style:{left:Math.min(bL.x,window.innerWidth-450),top:Math.max(8,Math.min(bL.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:bI.get(bL.line.author)?.border||"#666"},children:bL.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:bL.line.author}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:bL.line.authorEmail})]})]}),(0,e.jsx)("div",{className:"mt-2 text-sm text-foreground whitespace-pre-wrap max-h-48 overflow-y-auto",children:bL.line.message}),(0,e.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground border-t border-border pt-2",children:[(0,t.fw)(bL.line.time)," \xb7 ",new Date(1e3*bL.line.time).toLocaleString(),(0,e.jsx)("span",{className:"ml-2 text-brand",children:ab("codeViewer.clickToViewDetails")})]})]})]}),bg)]})});function A({content:a,filePath:b,className:c=""}){let d=(0,f.useMemo)(()=>a.split("\n"),[a]),g=(0,n.C)(d,b),h=Math.max(4,String(d.length).length);return(0,e.jsx)("pre",{className:`overflow-auto text-sm font-mono bg-muted p-2 ${c}`,children:d.map((a,b)=>(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)("span",{className:"text-foreground-subtle 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,o.ZD)(a||" ")}})]},b))})}d()}catch(a){d(a)}})},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")},56444:(a,b,c)=>{"use strict";c.d(b,{$H:()=>i});var d=c(32891),e=c(6993);let f={todo:"doing",doing:"done",done:"todo"},g={todo:"false",doing:"mixed",done:"true"},h=/^\s*(\[([ x/])?\])\s$/,i=e.L.extend({addAttributes:()=>({status:{default:"todo",keepOnSplit:!1,parseHTML:a=>(function(a){let b=a.getAttribute("data-status");if("todo"===b||"doing"===b||"done"===b)return b;let c=a.getAttribute("data-checked");return""===c||"true"===c?"done":"todo"})(a),renderHTML:a=>({"data-status":a.status,"data-checked":"done"===a.status?"true":"false"})}}),addStorage:()=>({markdown:{serialize(a,b){var c;a.write(`${"done"===(c=b.attrs.status)?"[x]":"doing"===c?"[/]":"[ ]"} `),a.renderContent(b)}}}),addInputRules(){return[(0,d.tG)({find:h,type:this.type,getAttributes:a=>{let b=a[a.length-1];return{status:"x"===b?"done":"/"===b?"doing":"todo"}}})]},renderHTML({HTMLAttributes:a}){return["li",(0,d.KV)(this.options.HTMLAttributes,a,{"data-type":this.name}),0]},addNodeView(){return({node:a,getPos:b,editor:c})=>{let d=document.createElement("li");d.setAttribute("data-type",this.name);let e=document.createElement("label");e.classList.add("task-marker"),e.contentEditable="false";let h=document.createElement("span");h.classList.add("task-marker-box"),h.setAttribute("role","checkbox"),e.appendChild(h);let i=document.createElement("div");d.append(e,i);let j=a=>{let b=a.attrs.status??"todo";d.dataset.status=b,d.dataset.checked="done"===b?"true":"false",h.setAttribute("aria-checked",g[b])};return j(a),e.addEventListener("mousedown",a=>a.preventDefault()),e.addEventListener("click",a=>{if(a.preventDefault(),!c.isEditable||"function"!=typeof b)return;let d=b();"number"==typeof d&&c.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:a})=>{let b=a.doc.nodeAt(d);if(!b)return!1;let c=b.attrs.status??"todo";return a.setNodeMarkup(d,void 0,{...b.attrs,status:f[c]}),!0}).run()}),{dom:d,contentDOM:i,update:b=>b.type===a.type&&(j(b),!0)}}}})},57014:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{m:()=>w});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(35208),j=c(74691),k=c(60333),l=c(73887),m=c(39238),n=c(60591),o=c(72529),p=c(85984),q=c(65543),r=c(25667),s=c(53036),t=c(88018),u=c(9804),v=a([r,i,l,m]);[r,i,l,m]=v.then?(await v)():v;let x=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function w({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:v,changedFiles:y,fileGitStatusMap:z,onContentSearch:A,locateInTree:B,setJsonPreview:C,onTokenHover:D,onTokenHoverLeave:E,onTokenHoverCancel:F}){let{t:G}=(0,g.Bd)(),H="unstaged"===b.type?{onTokenHover:D,onTokenHoverLeave:E,onTokenHoverCancel:F}:{},[I,J]=(0,f.useState)(!1),[K,L]=(0,f.useState)("file"),[M,N]=(0,f.useState)("compact"),[O,P]=(0,f.useState)("unified"),Q=b.file.path,R=b.file.oldPath||Q,S=(0,u.u)(Q),T=Q.startsWith("/")?Q:a?`${a.replace(/\/$/,"")}/${Q}`:Q,{state:U}=(0,p.V)(a,Q),V=(0,f.useMemo)(()=>{if("ready"===U.state)return U.data.functions.filter(q._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[U]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[S||"map"!==K?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:Q}),(0,e.jsx)(o.m,{content:G("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${Q}`),(0,h.oR)(G("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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)(o.m,{content:G("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),B(Q)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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?G("fileBrowser.staged"):G("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!S&&(0,e.jsx)(j.y,{value:M,onChange:N}),!S&&"file"===K&&(0,e.jsx)(k.q,{value:O,onChange:P}),!S&&(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(),L(a)},className:`px-2 py-0.5 text-xs transition-colors ${K===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:G("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:S?(0,e.jsx)(t.K,{filePath:Q,oldSrc:c.isNew?null:x(a,"staged"===b.type?"HEAD":":0","staged"===b.type?R:Q),newSrc:c.isDeleted||"staged"!==b.type?null:x(a,":0",Q),newNode:c.isDeleted||"staged"===b.type?void 0:(0,e.jsx)(s.I,{cwd:a,path:Q,className:"flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:Q})}):"unified"===O?(0,e.jsx)(i.xU,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,cwd:a,enableComments:!0,compact:"compact"===M,onPreview:!c.isDeleted&&(0,n.e$)(Q)?()=>v(!0):!c.isDeleted&&(0,n.aR)(Q)?()=>J(!0):!c.isDeleted&&Q.endsWith(".json")?()=>C({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:Q.endsWith(".json")?G("common.readable"):G("common.preview"),onContentSearch:A,...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"===M,symbols:V,onPreview:!c.isDeleted&&(0,n.e$)(Q)?()=>v(!0):!c.isDeleted&&(0,n.aR)(Q)?()=>J(!0):!c.isDeleted&&Q.endsWith(".json")?()=>C({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:Q.endsWith(".json")?G("common.readable"):G("common.preview"),onContentSearch:A,...H})})]}):(0,e.jsx)(r.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:y,fileGitStatusMap:z,enableComments:!0,compact:"compact"===M,onContentSearch:A,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=z.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o.m,{content:G("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(G("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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)(o.m,{content:G("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),B(b)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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?G("fileBrowser.staged"):G("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.y,{value:M,onChange:N}),(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(),L(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${K===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:G("file"===a?"common.file":"common.codeMap")},a))})]})}),d&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>v(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(l.M,{content:c.newContent,filePath:c.filePath,cwd:a,onClose:()=>v(!1)})})}),I&&(0,e.jsx)(m.N,{filePath:T,content:c.newContent,cwd:a,onClose:()=>J(!1)})]})}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.qIB(e.d,c=>c.publish(a,b)))}},57063:(a,b,c)=>{"use strict";function d(){"u">typeof document&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function e(a,b=!0){}c.d(b,{E:()=>e,k:()=>d}),c(67484)},57632:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e$:()=>P,vP:()=>L,zB:()=>Q});var e=c(48249),f=c(67484),g=c(44384),h=c(79606),i=c(87819);c(57063);var j=c(7122),k=c(8410),l=c(44256),m=c(7093),n=c(99191),o=c(46674),p=c(92340),q=c(52490),r=c(67216),s=c(86718),t=c(145),u=c(20586),v=c(74691),w=c(60333),x=c(88018),y=c(35208),z=c(60591),A=c(73887),B=c(39238),C=c(18479),D=c(39247),E=c(53087),F=a([y,A,B]);function G(a,b){return{path:a.path,status:a.status,additions:a.additions,deletions:a.deletions,old_string:a.oldContent??"",new_string:a.newContent??"",unviewable:!a.isImage&&(a.binary||null===a.oldContent&&null===a.newContent),isImage:a.isImage,oldRev:a.oldRev,newRev:a.newRev,external:null!==b&&b.size>0&&!b.has(a.path)}}[y,A,B]=F.then?(await F)():F;let R=(a,b,c)=>`/api/snapshots/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function H(a){return a.fullSubject||a.subject}function I(a,b,c){let d=H(a),e=d.split("\n"),f=e.length>c?e.slice(0,c).join("\n"):d,g=f.length>b?f.slice(0,b):f;return e.length>c||f.length>b?`${g.trimEnd()}…`:g}function J(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function K(a,b){let c=[];for(let d of a)if("Edit"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.old_string&&"string"==typeof a.new_string){let e=J(a.file_path,b);c.push({key:d.id,toolName:"Edit",subject:`[Edit] ${e}`,legacy:!0,changeClass:(0,m.q)(e),files:[{path:e,status:"modified",old_string:a.old_string,new_string:a.new_string}]})}}else if("Write"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.content){let e=J(a.file_path,b);c.push({key:d.id,toolName:"Write",subject:`[Write] ${e}`,legacy:!0,changeClass:(0,m.q)(e),files:[{path:e,status:"added",old_string:"",new_string:a.content}]})}}return c}function L(a,b,c){var d;let e,f=a.map(a=>{let b=new Set(a.commit.toolFiles);return{key:a.commit.toolId??a.commit.hash,shortHash:a.commit.hash.slice(0,7),hash:a.commit.hash,parent:a.commit.parent,declared:a.commit.toolFiles,toolName:a.commit.toolName??"tool",subject:a.commit.subject,timestamp:a.commit.timestamp,truncated:!0===a.truncated,changeClass:(0,m.S)(a.files.map(a=>a.path)),files:a.files.map(a=>G(a,b))}});return d=f.length>0?f:K(b,c),e=new Map(b.map(a=>[a.id,a])),d.map(a=>{let b=function(a){if(!a)return;let b=a.input;return"string"==typeof b.description&&b.description?b.description:"string"==typeof b.command&&b.command?b.command:"string"==typeof b.prompt&&b.prompt?b.prompt:"string"==typeof b.file_path&&b.file_path?b.file_path:"string"==typeof b.notebook_path&&b.notebook_path?b.notebook_path:void 0}(e.get(a.key));return b?{...a,fullSubject:`[${a.toolName}] ${b}`}:a})}function M(a){let b=!1,c=0,d=0;for(let e of a)(void 0!==e.additions||void 0!==e.deletions)&&(b=!0),c+=e.additions??0,d+=e.deletions??0;return b?{additions:c,deletions:d}:null}function N({additions:a,deletions:b}){return(0,e.jsxs)("span",{className:"flex items-center gap-1 font-mono",children:[(0,e.jsxs)("span",{className:"text-green-11",children:["+",a]}),(0,e.jsxs)("span",{className:"text-red-11",children:["-",b]})]})}function O(a){let b=new Date(1e3*a),c=new Date,d=String(b.getMonth()+1).padStart(2,"0"),e=String(b.getDate()).padStart(2,"0"),f=String(b.getHours()).padStart(2,"0"),g=String(b.getMinutes()).padStart(2,"0"),h=`${d}-${e} ${f}:${g}`;return b.getFullYear()===c.getFullYear()?h:`${b.getFullYear()}-${h}`}function P({toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:l,fullscreen:m,onToggleFullscreen:F}){let{t:J}=(0,g.Bd)(),Q=(0,f.useRef)(null),[S,T]=(0,f.useState)(null),U=(0,f.useMemo)(()=>a.map(a=>a.id).filter(Boolean),[a]),V=U.join(","),[W,X]=(0,f.useState)(0),Y=(0,i.Z)(b&&U.length>0?(0,C.se)(b,U,c):h.PyW([]),[b,c,V,W]);(0,f.useMemo)(()=>a.filter(a=>(0,D.h)(a.name)).map(a=>a.id),[a]);let Z=(0,f.useRef)([]),$="loading"===Y.status&&0===Z.current.length,_=(0,f.useMemo)(()=>{if("success"===Y.status){let c=L(Y.data,a,b);return c.length>0&&(Z.current=c),c}return"loading"===Y.status&&Z.current.length>0?Z.current:"loading"===Y.status?[]:K(a,b)},[Y,a,b]),[aa,ab]=(0,f.useState)(!1),[ac,ad]=(0,f.useState)(!1),ae=(0,f.useMemo)(()=>_.filter(a=>a.hash),[_]),af=(0,f.useMemo)(()=>(0,E.mg)(ae),[ae]),ag=(0,f.useMemo)(()=>ac?ae:ae.slice(af),[ae,ac,af]),ah=(0,f.useMemo)(()=>{if(ac||0===af)return _;let a=new Set(ae.slice(0,af).map(a=>a.key));return _.filter(b=>!a.has(b.key))},[_,ae,ac,af]),ai=(0,f.useMemo)(()=>0===ag.length||ag.length<2&&0===af?null:{base:ag[0].parent??null,head:ag[ag.length-1].hash},[ag,af]),aj=!!b&&_.length>=2,ak=null===ai,al=(0,i.Z)(aa&&b&&ai?(0,C.Tt)(b,ai.base,ai.head):h.PyW(null),[aa,b,ai?.base??"",ai?.head??""]),am=(0,f.useMemo)(()=>0===ag.length||ag.some(a=>!a.declared||0===a.declared.length)?null:new Set(ag.flatMap(a=>a.declared)),[ag]),an=(0,f.useMemo)(()=>"success"===al.status&&al.data?al.data.files.map(a=>G(a,am)):[],[al,am]),ao="success"===al.status&&al.data?.truncated===!0,ap=aa&&"loading"===al.status,aq=aa&&"error"===al.status,[ar,as]=(0,f.useState)(null),[at,au]=(0,f.useState)(null),[av,aw]=(0,f.useState)(new Set),[ax,ay]=(0,f.useState)(()=>!0),[az,aA]=(0,f.useState)("compact"),[aB,aC]=(0,f.useState)("unified"),[aD,aE]=(0,f.useState)(!1),[aF,aG]=(0,f.useState)(!1),[aH,aI]=(0,f.useState)(null),aJ=(0,f.useMemo)(()=>_.find(a=>a.key===ar)??null,[_,ar]),aK=(0,f.useRef)(null),aL=aJ??aK.current,aM=(0,f.useMemo)(()=>aa?an:aL?.files??[],[aa,an,aL]),aN=(0,f.useMemo)(()=>(0,u.Do)(aM),[aM]),aO=(0,f.useMemo)(()=>aM.find(a=>a.path===at)??null,[aM,at]),aP=(0,f.useMemo)(()=>M(aM),[aM]),aQ=(0,f.useCallback)(a=>{as(a.key),au(a.files[0]?.path??null),aw(new Set((0,u.Sz)((0,u.Do)(a.files))))},[]),aR=(0,f.useMemo)(()=>ah.reduce((a,b)=>a+b.files.length,0),[ah]),aS=a=>(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:a});return(0,e.jsx)(j.SU,{container:S,children:(0,e.jsxs)("div",{ref:Q,className:"relative bg-card shadow-lv3 w-full h-full flex flex-col rounded-lg",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:`${n.o} px-3`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:d,"aria-label":J("common.close"),title:J("common.close"),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(o.A,{className:"w-4 h-4"})}),F&&(0,e.jsx)("button",{onClick:F,"aria-label":m?J("diffViewer.exitFull"):J("diffViewer.expandFull"),title:m?J("diffViewer.exitFull"):J("diffViewer.expandFull"),"aria-pressed":!0===m,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:m?(0,e.jsx)(p.A,{className:"w-4 h-4"}):(0,e.jsx)(q.A,{className:"w-4 h-4"})}),aj&&(0,e.jsx)("button",{onClick:()=>ab(a=>!a),disabled:ak,"aria-pressed":aa,title:ak?J("diffViewer.aggregateUnavailable"):aa?J("diffViewer.aggregateOff"):J("diffViewer.aggregateOn"),className:`ml-0.5 px-2 py-0.5 text-xs rounded border transition-colors ${ak?"border-border text-foreground-subtle opacity-60 cursor-not-allowed":aa?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:J("diffViewer.aggregate")})]}),(0,e.jsx)("div",{className:"w-px h-4 bg-border flex-shrink-0"}),(0,e.jsx)("button",{onClick:()=>ay(a=>!a),"aria-label":J("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors flex-shrink-0 ${ax?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,e.jsx)(r.A,{className:"w-4 h-4"})}),(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground truncate",children:aa?J("diffViewer.fileChangesAggregate",{count:aM.length}):J("diffViewer.fileChanges",{count:aR})})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ax&&!aa&&(0,e.jsxs)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:[af>0&&(0,e.jsx)("button",{onClick:()=>ad(a=>!a),"data-tooltip":J("diffViewer.aggregateSkippedHint",{threshold:E.fz}),className:"w-full px-3 py-1.5 border-b border-border text-left text-xs bg-amber-500/10 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20 transition-colors",children:ac?J("diffViewer.callsBaselineShown",{count:af}):J("diffViewer.callsBaselineHidden",{count:af})}),ah.map(a=>{let b;return(0,e.jsxs)("div",{onClick:()=>aQ(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${ar===a.key?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[a.changeClass&&(0,e.jsx)(k.N,{cls:a.changeClass}),a.shortHash&&(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),void 0!==a.timestamp&&(0,e.jsx)("span",{className:"text-xs text-foreground-subtle",children:O(a.timestamp)})]}),(0,e.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":H(a),children:I(a,320,10)}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{children:J("commitDetail.nChanges",{count:a.files.length})}),(b=M(a.files))&&(b.additions>0||b.deletions>0)?(0,e.jsx)(N,{additions:b.additions,deletions:b.deletions}):null]})]},a.key)})]}),(0,e.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:$?aS(J("diffViewer.loadingSnapshots")):0===_.length?aS(J("diffViewer.noChanges")):aa||aL?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border text-xs text-muted-foreground",children:[aa?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(s.A,{className:"w-3.5 h-3.5"}),J("diffViewer.aggregateSummary",{count:aM.length,calls:ag.length})]}),af>0&&(0,e.jsx)("button",{onClick:()=>ad(a=>!a),"data-tooltip":J("diffViewer.aggregateSkippedHint",{threshold:E.fz}),className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors",children:ac?J("diffViewer.aggregateBaselineIncluded",{count:af}):J("diffViewer.aggregateBaselineSkipped",{count:af})}),aP&&(aP.additions>0||aP.deletions>0)&&(0,e.jsx)(N,{additions:aP.additions,deletions:aP.deletions}),ao&&(0,e.jsx)("span",{className:"text-amber-11",children:J("diffViewer.truncated")})]}):aL?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(t.A,{className:"w-3.5 h-3.5"}),aL.toolName]}),aL.shortHash&&(0,e.jsx)("span",{className:"font-mono text-brand",children:aL.shortHash}),void 0!==aL.timestamp&&(0,e.jsx)("span",{children:O(aL.timestamp)}),(0,e.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":H(aL),children:I(aL,640,6)}),aL.truncated&&(0,e.jsx)("span",{className:"text-amber-11",children:J("diffViewer.truncated")}),aL.legacy&&(0,e.jsx)("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-400","data-tooltip":J("diffViewer.reconstructedHint"),children:J("diffViewer.reconstructed")})]}):null,(0,e.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!aO?.isImage&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(v.y,{value:az,onChange:aA}),(0,e.jsx)(w.q,{value:aB,onChange:aC})]})})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[ax&&(0,e.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:ap?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:J("diffViewer.aggregateLoading")}):(0,e.jsx)(u.VO,{files:aN,selectedPath:at,expandedPaths:av,onToggle:a=>aw(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c}),onSelect:a=>{!a.isDirectory&&a.file&&au(a.file.path)},cwd:b||"",showChanges:!0,showChangeClass:!0,renderActions:a=>{if(a.isDirectory)return null;let b=a.file;return b?(0,e.jsx)(e.Fragment,{children:b.external&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":J("diffViewer.externalChange")})}):null}})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:aO?aO.isImage?(0,e.jsx)(x.K,{filePath:aO.path,oldSrc:b&&aO.oldRev?R(b,aO.oldRev,aO.path):null,newSrc:b&&aO.newRev?R(b,aO.newRev,aO.path):null}):aO.unviewable?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:J("diffViewer.notViewable")}):"unified"===aB?(0,e.jsx)(y.xU,{oldContent:aO.old_string,newContent:aO.new_string,filePath:aO.path,cwd:b,enableComments:!0,onContentSearch:l,compact:"compact"===az,onPreview:"deleted"===aO.status?void 0:(0,z.e$)(aO.path)?()=>aE(!0):(0,z.aR)(aO.path)?()=>aG(!0):aO.path.endsWith(".json")?()=>aI({content:aO.new_string,filePath:aO.path}):void 0,previewLabel:aO.path.endsWith(".json")?J("common.readable"):J("common.preview")}):(0,e.jsx)(y.xZ,{oldContent:aO.old_string,newContent:aO.new_string,filePath:aO.path,isNew:"added"===aO.status,isDeleted:"deleted"===aO.status,cwd:b,enableComments:!0,onContentSearch:l,compact:"compact"===az,onPreview:"deleted"===aO.status?void 0:(0,z.e$)(aO.path)?()=>aE(!0):(0,z.aR)(aO.path)?()=>aG(!0):aO.path.endsWith(".json")?()=>aI({content:aO.new_string,filePath:aO.path}):void 0,previewLabel:aO.path.endsWith(".json")?J("common.readable"):J("common.preview")}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:ap?J("diffViewer.aggregateLoading"):aq?J("diffViewer.aggregateFailed"):aa&&0===aM.length?J("diffViewer.aggregateEmpty"):J("diffViewer.selectFileToView")})})]})]}):aS(J("diffViewer.selectFileToView"))})]}),aD&&aO&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>aE(!1),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(A.M,{content:aO.new_string,filePath:aO.path,cwd:b||"",onClose:()=>aE(!1)})})}),aF&&aO&&(0,e.jsx)(B.N,{filePath:aO.path,content:aO.new_string,cwd:b,onClose:()=>aG(!1),onContentSearch:l}),aH&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>aI(null),children:(0,e.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[95%] h-full 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:aH.filePath}),(0,e.jsx)("button",{onClick:()=>aI(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(o.A,{className:"w-4 h-4"})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,z.xb)(aH.content)})})]})})]})})}function Q({toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:f}){return(0,e.jsx)(l.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:d,children:(0,e.jsx)(P,{toolCalls:a,cwd:b,sessionId:c,onClose:d,onContentSearch:f?a=>{d(),f(a)}:void 0})})})}d()}catch(a){d(a)}})},58554:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{r:()=>L});var e=c(48249),f=c(67484),g=c(60661),h=c(77949),i=c(7833),j=c(40699),k=c(33281),l=c(41224),m=c(57031),n=c(88214),o=c(63041),p=c(74429),q=c(62473),r=c(14222),s=c(86686),t=c(75513),u=c(81206),v=c(97951),w=c(93780),x=c(99843),y=c(80514),z=c(43209),A=c(95401),B=c(42910),C=c(65139),D=c(75389),E=c(47604),F=c(60812),G=c(99191),H=c(20580),I=c(84844),J=c(44384),K=a([x]);x=(K.then?(await K)():K)[0];let M=`${G.o} pl-3 pr-14 bg-card/50`;function L({tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:G,ollamaModel:K,onOllamaModelChange:N,deepseekModel:O,onDeepseekModelChange:P,kimiModel:Q,onKimiModelChange:R,glmModel:S,onGlmModelChange:T,claudeModel:U,onClaudeModelChange:V,claudeEffort:W,onClaudeEffortChange:X,claudeFastMode:Y,onClaudeFastModeChange:Z,claudeThinking:$,onClaudeThinkingChange:_,codexModel:aa,onCodexModelChange:ab,codexReasoningEffort:ac,onCodexReasoningEffortChange:ad,planMode:ae,onPlanModeChange:af,noHistory:ag,onNoHistoryChange:ah,outputStyle:ai,onOutputStyleChange:aj,hideHeader:ak,hideSidebar:al,isActive:am=!0,isFocused:an=am,peerTabId:ao,peerSide:ap,refreshSignal:aq,onLoadingChange:ar,onSessionIdChange:as,onTitleChange:at,onBotChange:au,onShowGitStatus:av,onOpenNote:aw,isFavorite:ax,onToggleFavorite:ay,onCreateScheduledTask:az,onOpenSession:aA,onContentSearch:aB,onShowFileDiff:aC,onOpenFileLink:aD,onOpenSessionBrowser:aE,onOpenSettings:aF}){let aG,{t:aH}=(0,J.Bd)(),aI=(0,r.k)(),[aJ,aK]=(0,f.useState)(""),[aL,aM]=(0,f.useState)([]),aN=(0,t.nH)(),[aO,aP]=(0,f.useState)([]),[aQ,aR]=(0,f.useState)(null),[aS,aT]=(0,f.useState)(!1),[aU,aV]=(0,f.useState)(!1),[aW,aX]=(0,f.useState)(!1),aY=(0,H.a)(b),[aZ,a$]=(0,f.useState)(!1),[a_,a0]=(0,f.useState)(null),[a1,a2]=(0,f.useState)(!1),a3=ae??a1,a4=(0,f.useCallback)(a=>{a2(a),af?.(a)},[af]),[a5,a6]=(0,f.useState)(!1),a7=ag??a5,a8=(0,f.useCallback)(a=>{a6(a),ah?.(a)},[ah]),[a9,ba]=(0,f.useState)(""),bb=ai??a9,bc=(0,f.useCallback)(a=>{ba(a),aj?.(a)},[aj]),[bd,be]=(0,f.useState)(!1),bf=(0,f.useRef)(null);(0,f.useRef)(null);let bg=(0,f.useCallback)(async a=>{if(!b)return;let c=await k.t4.runPromiseExit((0,l.n_)({cwd:b,sessionId:a}));"Success"===c._tag&&c.value&&"string"==typeof c.value.title?at?.(c.value.title):"Failure"===c._tag&&console.error("Failed to fetch session title:",c.cause)},[b,at]),bh=(0,f.useRef)(null),[bi,bj]=(0,f.useState)(!1),[bk,bl]=(0,f.useState)(null),[bm,bn]=(0,f.useState)(null),[bo,bp]=(0,f.useState)(v.R),bq=(0,f.useMemo)(()=>(0,w.hC)(),[]),br=(0,f.useRef)(!1),{isLoadingHistory:bs,isLoadingMore:bt,hasMoreHistory:bu,loadMoreHistory:bv,ensureTurnLoaded:bw,loadHistoryByCwdAndSessionId:bx,loadedSessionId:by,loadedEngine:bz,loadedBot:bA}=(0,u.m)(aO,aP,aQ,{cwd:b,initialSessionId:c,onSessionId:aR,onTitleChange:at,onTokenUsage:a0,liveRunningRef:br}),bB=bz??d??void 0,bC=!bB||"claude"===bB,bD="codex"===bB,bE=U??C.BV,bF=(0,C.NR)(bE,W),bG=aa??C.kn,bH=(0,C.oJ)(bG,ac),bI="deepseek"===bB||"kimi"===bB||"glm"===bB?bB:null,bJ="kimi"===bI?Q:"glm"===bI?S:O,bK="kimi"===bI?R:"glm"===bI?T:P,bL="ollama"===bB||null!==bI||bC||bD,{isLoading:bM,tokenUsage:bN,liveOutputTokens:bO,runningStartedAt:bP,rateLimitInfo:bQ,apiRetryInfo:bR,backgroundTasks:bS,handleSend:bT,handleStop:bU}=(0,v.e)(aO,aP,{sessionId:aQ,cwd:b,engine:bB,planMode:a3,noHistory:a7,outputStyleId:bb,ollamaModel:K,engineModel:bJ,claudeModel:bE,claudeEffort:bF,claudeFastMode:Y,claudeThinking:$,codexModel:bG,codexReasoningEffort:bH,onSessionId:aR,onFetchTitle:bg,onRunComplete:()=>bh.current?.(),taskStore:bq}),bV=(0,f.useCallback)((...a)=>(bf.current?.pinNextUserMessage(),bT(...a)),[bT]),bW=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(bC){let b=/^\/plan(?:\s+([\s\S]*))?$/.exec(a.trim());if(b){let a=(b[1]??"").trim();"off"===a.toLowerCase()?(a4(!1),(0,i.oR)(aH("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===a?(a4(!0),(0,i.oR)(aH("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(a4(!0),bV(a,c,{permissionMode:"plan"}));return}}if(d.startsWith("!")&&d.length>1){let e=d.slice(1).trim();if(!e)return void bV(a,c);let f=a.split("\n").slice(1).join("\n").trim(),g=await k.t4.runPromiseExit((0,l.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=aH("chat.executedCommand",{command:e,exitInfo:d,output:b});f&&(h+=`
27
27
 
28
- ${f}`),bT(h,c)}else bT(aG("chat.executedCommandFailed",{command:e,error:g.cause}),c);return}bT(a,c)},[bT,b,aG,bA,a2]),bV=(0,f.useCallback)(()=>{a2(!1),bT(aG("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[bT,a2,aG]),bW=bw||aP,bX=al&&!bK&&!!bW;(0,j.u)(bW,aO,bX,bz,{onRunningChange:a=>{bp.current=a,bh(a)},onLiveOutputTokens:bj,onRunStartedAt:bl,onBackgroundTasks:a=>bn(a.length?a:v.R),taskStore:bo,onComplete:()=>{b&&bW&&bv(b,bW,!0,10)}}),(0,f.useRef)(al),(0,f.useRef)(0);let bY=bL||aZ,bZ=bK?bM:bg?bi:null,b$=bK?bN:bg?bk:null,b_=bK?bQ:bg?bm:v.R;(0,f.useRef)(!1);let b0=(0,f.useCallback)(async(a,c)=>{let d=bw??aP;if(!b||!d)return;let e=await k.t4.runPromiseExit((0,l.Zr)(d,{cwd:b,fromMessageUuid:a,scope:c}));if("Success"===e._tag&&e.value.newSessionId){let a=e.value.newSessionId;az?az(a,"single"===c?"Excerpt":"Fork"):(0,m.F)(n.n.OpenProject,{cwd:b,sessionId:a})}else"Failure"===e._tag&&(console.error("Fork failed:",e.cause),(0,i.oR)("single"===c?aG("toast.excerptFailed",{defaultValue:"Failed to excerpt this turn"}):aG("toast.forkFailed",{defaultValue:"Failed to fork session"}),"error"))},[b,bw,aP,az,aG]),b1=(0,f.useRef)(b0);b1.current=b0;let b2=(0,f.useRef)((a,b)=>b1.current(a,b)).current,b3=(0,f.useCallback)(async a=>{let c=bw??aP;if(!b||!c||bK||bg)return;let d=Math.max(10,aN.filter(a=>"user"===a.role).length),e=await k.t4.runPromiseExit((0,l.$N)(c,{cwd:b,messageUuid:a}));"Success"===e._tag?(aO(b=>{let c=b.findIndex(b=>b.id===a);if(c<0)return b;let d=c;for(;d>=0&&"user"!==b[d].role;)d-=1;if(d<0)return b;let e=d+1;for(;e<b.length&&"user"!==b[e].role;)e+=1;return[...b.slice(0,d),...b.slice(e)]}),await bv(b,c,!1,d,void 0,!0),(0,i.oR)(aG("toast.turnDeleted",{defaultValue:"Turn deleted"}),"success")):(console.error("Delete turn failed:",e.cause),(0,i.oR)(aG("toast.deleteTurnFailed",{defaultValue:"Failed to delete this turn"}),"error"))},[b,bw,aP,bK,bg,aN,bv,aG]),b4=(0,f.useRef)(b3);b4.current=b3;let b5=(0,f.useRef)(a=>b4.current(a)).current,b6=(0,f.useCallback)(a=>{if(an&&aM){if(!aM.sendToTab(an,a))return void(0,i.oR)(aG("toast.sendToPeerFailed",{defaultValue:"Failed to send to the other pane"}),"error");(0,i.oR)(aG("toast.sentToPeer",{defaultValue:"Sent to the other pane"}),"success")}},[an,aM,aG]),b7=(0,f.useRef)(b6);b7.current=b6;let b8=(0,f.useRef)(a=>b7.current(a)).current,b9=(0,f.useCallback)(()=>{aW(!0)},[]),ca=(0,f.useCallback)(()=>{aY(!0)},[]),cb=(0,f.useRef)(aN);cb.current=aN;let cc=(0,f.useCallback)(async a=>{if(cb.current.some(b=>b.id===a.id))return void bd.current?.scrollToMessage(a.id);await bu(a.turnIndex);for(let b=0;b<30;b++)if(await new Promise(a=>requestAnimationFrame(()=>a())),bd.current?.scrollToMessage(a.id))return},[bu]),cd=(0,f.useMemo)(()=>{if(ay&&b&&a)return c=>{ay({...c,cwd:b,tabId:a,sessionId:aP??crypto.randomUUID(),engine:bz,..."ollama"===bz&&J&&{model:J},...bG&&bH&&{model:bH},...bA&&{model:bC},...bB&&{model:bE}})}},[ay,b,a,aP,bz,J,bG,bH,bA,bC,bB,bE]),ce=bJ?(0,e.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer select-none","data-tooltip":aG("chat.noHistoryDesc",{defaultValue:"each prompt is independent"}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"nohistory-toggle",checked:a5,onChange:a=>a6(a.target.checked),className:"peer sr-only"}),(0,e.jsx)("span",{"aria-hidden":"true",className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-muted-foreground/30 transition-colors peer-checked:bg-brand peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring",children:(0,e.jsx)("span",{className:`h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${a5?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-foreground",children:[(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"}),aG("chat.noHistory",{defaultValue:"No history context"})]})]}):null,cf=(0,e.jsx)(D.T,{value:a9,onChange:ba});return(0,e.jsx)(w.I$.Provider,{value:bo,children:(0,e.jsxs)("div",{className:`flex ${aj&&ak?"h-full":"h-screen"} bg-card`,children:[(0,e.jsxs)("div",{id:"chat-screen",className:"flex-1 flex flex-col min-w-0 relative",onMouseEnter:()=>aS(!0),onMouseLeave:()=>aS(!1),children:[!aj&&(0,e.jsx)(o.e,{cwd:b,sessionId:aP,engine:bz,onOpenProjectSessions:()=>aU(!0),onOpenSessionBrowser:aD,onOpenSettings:aE}),(bA||bB)&&(0,e.jsxs)("div",{className:L,children:[(0,e.jsx)(C.Yd,{engine:bB?"codex":"claude",claudeModel:bC,onClaudeModelChange:U,claudeEffort:bD,onClaudeEffortChange:W,claudeFastMode:X,onClaudeFastModeChange:Y,claudeThinking:Z,onClaudeThinkingChange:$,codexModel:bE,onCodexModelChange:aa,codexReasoningEffort:bF,onCodexReasoningEffortChange:ac}),bA&&(0,e.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer select-none","data-tooltip":aG("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:a1,onChange:a=>a2(a.target.checked),className:"peer sr-only"}),(0,e.jsx)("span",{"aria-hidden":"true",className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-muted-foreground/30 transition-colors peer-checked:bg-brand peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring",children:(0,e.jsx)("span",{className:`h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${a1?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-foreground",children:[(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"}),aG("chat.planMode",{defaultValue:"Plan mode"})]})]}),ce,cf]}),"ollama"===bz&&(0,e.jsxs)("div",{className:L,children:[M&&(0,e.jsx)(A.m,{currentModel:J,onModelChange:M}),ce,cf]}),bG&&(0,e.jsxs)("div",{className:L,children:[bI&&(0,e.jsx)(B.Z,{engine:bG,currentModel:bH,onModelChange:bI,onHasKeyChange:bc}),ce,cf,(0,e.jsx)("div",{className:"ml-auto pl-2",children:"deepseek"===bG?(0,e.jsx)(E.f,{hasKey:bb}):(0,e.jsx)(F.J,{engine:bG,hasKey:bb})})]}),bq?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:aG("sessions.loadingHistory")})}):(0,e.jsx)(x.M,{ref:bd,messages:aN,isLoading:bK||bg,liveOutputTokens:bZ,runningStartedAt:b$,cwd:b,sessionId:aP,engine:bz,botName:by,apiRetryInfo:bP,backgroundTasks:b_,hasMoreHistory:bs,isLoadingMore:br,onLoadMore:bt,onFork:b2,onDeleteTurn:b5,onSendToPeer:b8,peerSide:ao,isActive:al,onContentSearch:aA,onShowFileDiff:aB,onOpenFileLink:aC,onApprovePlan:bV,onShowUserMessages:ca}),bY&&(0,e.jsx)(q.g,{tokenUsage:bY,rateLimitInfo:bO}),aH&&!am?null:(aF=(0,e.jsx)(y.V,{onSend:bU,disabled:bK||bg,cwd:b,engine:bz,onShowGitStatus:au,onShowComments:b?b9:void 0,onOpenNote:av,isFavorite:aw,onToggleFavorite:ax,onCreateScheduledTask:cd,draft:aI,setDraft:aJ,draftImages:aK,setDraftImages:aL}),aH?(0,p.createPortal)(aF,aH):aF)]}),!aj&&b&&(0,e.jsx)(z.Q,{isOpen:aT,onClose:()=>aU(!1),cwd:b}),b&&(0,e.jsx)(H.i,{isOpen:aV,onClose:()=>aW(!1),cwd:b}),(0,e.jsx)(s.f,{isOpen:aX,onClose:()=>aY(!1),cwd:b,sessionId:bw??aP,onSelectMessage:cc})]})})}d()}catch(a){d(a)}})},58904:(a,b,c)=>{"use strict";c.d(b,{e:()=>k});var d=c(67484),e=c(20586),f=c(7833),g=c(208),h=c(79606),i=c(33281),j=c(85655);function k({cwd:a,addToRecentFiles:b}){let[c,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)(null),[u,v]=(0,d.useState)(!1),[w,x]=(0,d.useState)(new Set),[y,z]=(0,d.useState)(new Set),[A,B]=(0,d.useState)([]),[C,D]=(0,d.useState)([]),E=(0,d.useMemo)(()=>{let a=new Set((0,e.Sz)(A));for(let b of w)a.delete(b);return a},[A,w]),F=(0,d.useMemo)(()=>{let a=new Set((0,e.Sz)(C));for(let b of y)a.delete(b);return a},[C,y]),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(0),K=(0,d.useCallback)(async()=>{n(!0),p(null),await i.t4.runPromise((0,j.lv)(a).pipe(h.YWq({onSuccess:a=>{l(a);let b=(0,e.Do)(a.staged),c=(0,e.Do)(a.unstaged);B(b),D(c)},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Unknown error")}}))),n(!1)},[a]),L=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=(0,d.useCallback)(a=>{z(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),N=(0,d.useCallback)((a,c)=>{r({file:a,type:c}),b(a.path)},[b]),O=(0,d.useCallback)(async(a,b,c,d)=>{let e=await i.t4.runPromiseExit(a);"Success"===e._tag?(await K(),(0,f.oR)(b,"success")):(console.error(c,e.cause),(0,f.oR)(d,"error"))},[K]),P=(0,d.useCallback)(b=>O((0,j.Iz)(a,[b]),g.A.t("toast.staged"),"Error staging file:",g.A.t("toast.stageFailed")),[a,O]),Q=(0,d.useCallback)(b=>O((0,j.X0)(a,[b]),g.A.t("toast.unstaged"),"Error unstaging file:",g.A.t("toast.unstageFailed")),[a,O]),R=(0,d.useCallback)(async b=>{0!==b.length&&await O((0,j.Iz)(a,b),g.A.t("toast.stagedNFiles",{count:b.length}),"Error staging files:",g.A.t("toast.stageFailed"))},[a,O]),S=(0,d.useCallback)(async b=>{0!==b.length&&await O((0,j.X0)(a,b),g.A.t("toast.unstagedNFiles",{count:b.length}),"Error unstaging files:",g.A.t("toast.unstageFailed"))},[a,O]),T=(0,d.useCallback)(async b=>{if(0===b.length)return;let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path),e=h.JkU(function*(){c.length>0&&(yield*(0,j.Ub)(a,c,!0)),d.length>0&&(yield*(0,j.Ub)(a,d,!1))});await O(e,g.A.t("toast.discardedNFiles",{count:b.length}),"Error discarding files:",g.A.t("toast.discardFailed"))},[a,O]),U=(0,d.useCallback)(async()=>{c?.unstaged.length&&await O((0,j.Iz)(a,c.unstaged.map(a=>a.path)),g.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"Error staging all files:",g.A.t("toast.stageFailed"))},[a,c,O]),V=(0,d.useCallback)(async()=>{c?.staged.length&&await O((0,j.X0)(a,c.staged.map(a=>a.path)),g.A.t("toast.unstagedNFiles",{count:c.staged.length}),"Error unstaging all files:",g.A.t("toast.unstageFailed"))},[a,c,O]),W=(0,d.useCallback)(async b=>{let c="untracked"===b.status;await O((0,j.Ub)(a,[b.path],c),c?g.A.t("toast.deletedFile"):g.A.t("toast.discardedChanges"),"Error discarding file:",g.A.t("toast.discardFailed"))},[a,O]),X=(0,d.useCallback)(async()=>{if(!c?.unstaged.length||!await (0,f.lJ)(g.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))return;let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path),e=c.unstaged.length,i=h.JkU(function*(){d.length>0&&(yield*(0,j.Ub)(a,d,!1)),b.length>0&&(yield*(0,j.Ub)(a,b,!0))});await O(i,g.A.t("toast.discardedNFiles",{count:e}),"Error discarding all:",g.A.t("toast.discardFailed"))},[a,c,O]);return{status:c,setStatus:l,statusLoading:m,statusError:o,statusSelectedFile:q,statusDiff:s,statusDiffLoading:u,stagedExpandedPaths:E,unstagedExpandedPaths:F,stagedTree:A,setStagedTree:B,unstagedTree:C,setUnstagedTree:D,showStatusDiffPreview:G,setShowStatusDiffPreview:H,fetchStatus:K,handleStagedToggle:L,handleUnstagedToggle:M,handleStatusFileSelect:N,handleStage:P,handleUnstage:Q,handleStageFiles:R,handleUnstageFiles:S,handleDiscardFiles:T,handleStageAll:U,handleUnstageAll:V,handleDiscardFile:W,handleDiscardAll:X,refreshDiff:(0,d.useCallback)(()=>J(a=>a+1),[])}}},59336:(a,b,c)=>{"use strict";c.d(b,{U:()=>f,k:()=>e});let d=(0,c(41830).N)("cockpit-skills"),e=d.notify,f=d.subscribe},59865:(a,b,c)=>{"use strict";c.d(b,{U:()=>h});var d=c(77156),e=c(59336),f=c(99884);let g={add:d.L5,notify:e.k,namespace:"skills",failureKey:"skills.addFailed"},h=()=>(0,f.X)(g)},60333:(a,b,c)=>{"use strict";c.d(b,{q:()=>f});var d=c(48249),e=c(44384);function f({value:a,onChange:b,className:c}){let{t:g}=(0,e.Bd)();return(0,d.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${c??""}`,children:["split","unified"].map(c=>(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),b(c)},className:`px-2 py-0.5 text-xs transition-colors ${a===c?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:g("split"===c?"diffViewer.viewSplit":"diffViewer.viewUnified")},c))})}},60540:(a,b,c)=>{"use strict";function d(a){let b,c=!1,d=Promise.resolve(),e=async()=>{if(!c){c=!0;try{for(;void 0!==b;){let c=b;b=void 0;try{await a(c)}catch{}}}finally{c=!1}}};return{enqueue(a){b=a,c||(d=e())},whenIdle:()=>d}}c.d(b,{j:()=>d})},60591:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,C_:()=>v,Hz:()=>u,OG:()=>w,WU:()=>x,Zy:()=>t,aR:()=>s,cG:()=>i,d9:()=>j,e$:()=>r,jU:()=>g,oK:()=>y,u:()=>q,xb:()=>k,zs:()=>o});var d=c(67484),e=c.n(d),f=c(208);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}let i={key:"hsl(var(--blue-11))",str:"hsl(var(--green-11))",num:"hsl(var(--violet-11))",bool:"hsl(var(--red-11))",punct:"hsl(var(--slate-11))",fold:"hsl(var(--slate-11))"},j=e().createContext({version:0,collapsed:!1});function k(a,b=i){try{let c=JSON.parse(a);return n(c,0,b)}catch{return a}}let l=(a,b)=>e().createElement("span",{style:{color:a}},b);function m({label:a,labelColor:b,value:c,indent:d,colors:g}){let h=e().useContext(j),[i,k]=e().useState(null),o=i&&i.version===h.version?i.collapsed:h.collapsed,[p,q]=e().useState({x:0,y:0}),r="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,s={onMouseDown:a=>{q({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-p.x,c=a.clientY-p.y;b*b+c*c>25||(a.stopPropagation(),k({version:h.version,collapsed:!o}))},style:{cursor:"pointer"}};if(r&&o&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],h=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",s,l(b,a),l(g.punct,": "),l(g.str,d),l(g.fold,` ${f.A.t("toolCall.foldedLines",{count:h})}`))}let t=e().createElement(e().Fragment,null,l(b,a),l(g.punct,": "),n(c,d,g));return r?e().createElement("span",s,t):t}function n(a,b,c){let d=" ".repeat(b);if(null===a)return l(c.bool,"null");if(void 0===a)return l(c.bool,"undefined");if("string"==typeof a){let b=a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+d);return l(c.str,b)}if("number"==typeof a)return l(c.num,String(a));if("boolean"==typeof a)return l(c.bool,String(a));if(Array.isArray(a))return 0===a.length?l(c.punct,"[]"):e().createElement(e().Fragment,null,l(c.punct,"["),"\n",...a.map((f,g)=>e().createElement("span",{key:g},d+" ",e().createElement(m,{label:`[${g}]`,labelColor:c.key,value:f,indent:b+1,colors:c}),g<a.length-1?e().createElement(e().Fragment,null,l(c.punct,","),"\n"):"\n")),d,l(c.punct,"]"));if("object"==typeof a){let f=Object.entries(a);return 0===f.length?l(c.punct,"{}"):e().createElement(e().Fragment,null,l(c.punct,"{"),"\n",...f.map(([a,g],h)=>e().createElement("span",{key:a},d+" ",e().createElement(m,{label:a,labelColor:c.key,value:g,indent:b+1,colors:c}),h<f.length-1?e().createElement(e().Fragment,null,l(c.punct,","),"\n"):"\n")),d,l(c.punct,"}"))}return String(a)}function o(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let p=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function q(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return p.has(b)}function r(a){return a.toLowerCase().endsWith(".md")}function s(a){let b=a.toLowerCase();return b.endsWith(".html")||b.endsWith(".htm")}function t(a){let b=a.toLowerCase();return b.endsWith(".csv")||b.endsWith(".tsv")}function u(a){return a.toLowerCase().endsWith(".json")}function v(a){return"skill.md"===a.slice(a.lastIndexOf("/")+1).toLowerCase()}function w(a){return"bot.md"===a.slice(a.lastIndexOf("/")+1).toLowerCase()}function x(a,b){let c=b.startsWith("/")?[]:a.split("/").slice(0,-1);for(let a of b.replace(/^\//,"").split("/"))""!==a&&"."!==a&&(".."===a?c.pop():c.push(a));return c.join("/")}function y(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},60812:(a,b,c)=>{"use strict";c.d(b,{J:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(63565),i=c(41224);let j={kimi:"https://www.kimi.com/code/console",glm:"https://bigmodel.cn/coding-plan/personal/usage"};function k(a){let b=a.remaining??"?",c=a.limit??"?";return`${a.label} ${b}/${c}`}function l({engine:a,hasKey:b}){let{t:c}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(null),s=(0,e.useCallback)(async()=>{n(!0),r(null);let b=await g.t4.runPromiseExit((0,i.dM)(a));"Failure"===b._tag?(p(null),r(c("chat.quotaFailed",{defaultValue:"Quota unavailable — check the API key"}))):p(b.value),n(!1)},[c,a]),t=o?.windows??[],u=[o?.tier,...t.map(k)].filter(Boolean).join(" \xb7 "),v=function(a){if(!a)return null;let b=new Date(a);return Number.isNaN(b.getTime())?null:`${b.getMonth()+1}/${b.getDate()} ${String(b.getHours()).padStart(2,"0")}:${String(b.getMinutes()).padStart(2,"0")}`}(t.reduce((a,b)=>b.resetTime&&(!a||b.resetTime>a)?b.resetTime:a,null)),w=t.some(a=>0===a.remaining);return(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[m&&(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!m&&q&&(0,d.jsx)("span",{className:"text-xs text-red-11",children:q}),!m&&!q&&o&&(0,d.jsx)("span",{className:`text-xs font-mono ${w?"text-red-11":h.pe[a]}`,"data-tooltip":v?c("chat.quotaResetAt",{defaultValue:"Resets {{time}}",time:v}):void 0,"data-testid":`${a}-quota-value`,children:u||c("chat.quotaEmpty",{defaultValue:"No quota returned"})}),(0,d.jsx)("button",{type:"button","data-testid":`${a}-quota-button`,disabled:!b||m,onClick:s,"data-tooltip":b?void 0:c("chat.quotaNeedsKey",{defaultValue:"Set an API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:c("chat.checkQuota",{defaultValue:"Check quota"})}),(0,d.jsx)("a",{href:j[a],target:"_blank",rel:"noopener","data-testid":`${a}-console-link`,title:c("chat.openProviderConsole",{defaultValue:"Open the provider console"}),"aria-label":c("chat.openProviderConsole",{defaultValue:"Open the provider console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}},61130:(a,b,c)=>{"use strict";c.d(b,{ReviewCommentsListModal:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(44256),h=c(7833),i=c(208);function j(a,b,c){let d=(a,c)=>b[a]||c,e=[],f=null!=c?`[${c+1}] `:"",g=a.anchor.selectedText.length>200?a.anchor.selectedText.slice(0,197)+"...":a.anchor.selectedText;for(let b of(e.push(`${f}${i.A.t("review.quoteRef",{text:g})}`),e.push(i.A.t("review.commentAuthor",{author:d(a.authorId,a.author),content:a.content})),a.replies))e.push(i.A.t("review.replyAuthor",{author:d(b.authorId,b.author),content:b.content}));return e.join("\n")}function k({isOpen:a,onClose:b,comments:c,reviewTitle:m,userNameMap:n,onCommentClick:o}){let{t:p}=(0,f.Bd)(),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1);if(!a)return null;let u=[...c].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),v=(a,b)=>n[a]||b,w=async a=>{r(a.id);try{let b=j(a,n);await navigator.clipboard.writeText(b),(0,h.oR)(p("toast.copiedComment"))}catch{(0,h.oR)(p("toast.copyFailed"),"error")}finally{r(null)}},x=async()=>{if(0!==c.length){t(!0);try{let a=function(a,b,c){if(0===a.length)return"";let d=[...a].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),e=[i.A.t("review.reviewSummary",{title:b}),""];return d.forEach((a,b)=>{e.push(j(a,c,b)),e.push("")}),e.push(i.A.t("review.totalNComments",{count:a.length})),e.join("\n").trim()}(c,m,n);await navigator.clipboard.writeText(a),(0,h.oR)(p("toast.copiedAllComments"))}catch{(0,h.oR)(p("toast.copyFailed"),"error")}finally{t(!1)}}},y=a=>{o?.(a),b()},z=u.filter(a=>!a.closed),A=u.filter(a=>a.closed),B=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-lv3 flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border ",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:p("review.allCommentsTitle")}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[p("review.commentsCountBrief",{count:c.length}),A.length>0&&` (${p("review.closedCount",{count:A.length})})`]}),c.length>0&&(0,d.jsx)("button",{onClick:x,disabled:s,className:"p-1 rounded hover:bg-hover text-muted-foreground disabled:opacity-50",title:p("review.copyAllComments"),children:s?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(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:"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,d.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:0===c.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,d.jsx)("div",{className:"text-2xl mb-2",children:"\uD83D\uDCAC"}),(0,d.jsx)("span",{className:"text-sm",children:p("review.noComments")})]}):(0,d.jsxs)("div",{className:"space-y-2",children:[z.map((a,b)=>(0,d.jsx)(l,{comment:a,index:b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y},a.id)),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"text-[11px] text-muted-foreground/60 pt-2 pb-1 px-1",children:p("review.closedComments",{count:A.length})}),A.map((a,b)=>(0,d.jsx)(l,{comment:a,index:z.length+b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y,closed:!0},a.id))]})]})})]})});return(0,d.jsx)(g.ZL,{children:B})}function l({comment:a,index:b,resolveAuthor:c,copyingId:e,onCopy:f,onClick:g,closed:h}){let j=a.anchor.selectedText.length>100?a.anchor.selectedText.slice(0,97)+"...":a.anchor.selectedText;return(0,d.jsxs)("div",{className:`rounded-lg border border-border hover:border-muted-foreground/30 transition-all cursor-pointer group ${h?"opacity-50":""}`,onClick:()=>g(a.id),children:[(0,d.jsx)("div",{className:"px-3 pt-2.5 pb-1",children:(0,d.jsx)("div",{className:"text-xs bg-yellow-500/10 border-l-2 border-yellow-500 px-2 py-1 rounded-r text-muted-foreground truncate",children:j})}),(0,d.jsxs)("div",{className:"px-3 pt-1.5 pb-2 flex items-start gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,d.jsx)("span",{className:"w-4 h-4 rounded-full bg-brand/20 text-brand flex items-center justify-center text-[9px] font-bold flex-shrink-0",children:c(a.authorId,a.author).charAt(0)}),(0,d.jsx)("span",{className:"text-xs font-medium",children:c(a.authorId,a.author)}),(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(a.createdAt).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}),h&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:i.A.t("review.closedLabel")})]}),(0,d.jsx)("p",{className:"text-sm text-foreground line-clamp-2 pl-6",children:a.content}),a.replies.length>0&&(0,d.jsxs)("div",{className:"pl-6 mt-1 space-y-0.5",children:[a.replies.slice(0,3).map(a=>(0,d.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[(0,d.jsx)("span",{className:"font-medium",children:c(a.authorId,a.author)}),": ",a.content]},a.id)),a.replies.length>3&&(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/60",children:i.A.t("review.moreReplies",{count:a.replies.length-3})})]})]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),f(a)},disabled:e===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground transition-opacity disabled:opacity-50 flex-shrink-0 mt-0.5",title:i.A.t("review.copyComment"),children:e===a.id?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(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:"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"})})})]})]})}},61135:()=>{},61349:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(44256);c(33281),c(87808);var i=c(35208),j=c(55287),k=c(5900),l=c(24680),m=c(84835),n=c(7833),o=c(64676),p=c(18921),q=c(53036),r=c(60591),s=a([j,i]);function t({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,r.e$)(a);return((0,r.u)(a),h)?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})}):d?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,r.u)(a)?(0,e.jsx)(q.I,{absPath:a,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:a.split("/").pop()||"image"}):b?k?(0,e.jsx)(u,{content:b,filePath:a}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[j,i]=s.then?(await s)():s;let w=[m.W];function u({content:a,filePath:b}){let c=(0,f.useRef)(null),d=(0,f.useMemo)(()=>(0,o.J4)(b),[b]);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:c}),(0,e.jsx)("div",{ref:c,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,basePath:d,rehypePlugins:w})})]})}function v({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,r.jU)(b),l=(0,r.zs)(b),m=(0,r.oK)(b),o=!!l,q=!!m,[s,u]=(0,f.useState)(("Read"===c||"Write"===c)&&q?"file":o?"diff-unified":k?"readable":"json"),w=(0,f.useRef)(null),x=(0,p.o)(w),y=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[o&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>u("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>u("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),q&&(0,e.jsx)("button",{onClick:()=>u("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>u("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>u("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===s&&m?(0,e.jsx)(t,{filePath:m}):"diff-unified"===s&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===s&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===s&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p._,{search:x}),(0,e.jsx)("pre",{ref:w,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,r.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,r.C6)(b):b})})]})});return(0,e.jsx)(h.ZL,{children:y})}d()}catch(a){d(a)}})},61591:(a,b,c)=>{"use strict";c.d(b,{o:()=>g});var d=c(48249);c(67484);let e={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",lean:"#448aff",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},f={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,d.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):"lean"===j?(0,d.jsx)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:(0,d.jsx)("path",{d:"M3.45 1.5 1.5 2.5 12 22.5 22.5 2.5 20.55 1.5 15.9 10.35H8.1ZM9 12h6l-3 6Z",fill:i,fillRule:"evenodd"})}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"env"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},61632:(a,b,c)=>{"use strict";c.d(b,{y:()=>k});var d=c(67484),e=c(20586),f=c(9804),g=c(208),h=c(79606),i=c(33281),j=c(85655);function k({cwd:a,addToRecentFiles:b}){let[c,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(""),[o,p]=(0,d.useState)([]),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)([]),[u,v]=(0,d.useState)([]),[w,x]=(0,d.useState)(new Set),[y,z]=(0,d.useState)(null),[A,B]=(0,d.useState)(null),[C,D]=(0,d.useState)(!1),[E,F]=(0,d.useState)(!1),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(!0),[K,L]=(0,d.useState)(!1),[M,N]=(0,d.useState)(!1),[O,P]=(0,d.useState)(null),Q=(0,d.useRef)(null),[R,S]=(0,d.useState)(null),[T,U]=(0,d.useState)(!1),[V,W]=(0,d.useState)(""),[X,Y]=(0,d.useState)(""),[Z,$]=(0,d.useState)([]),[_,aa]=(0,d.useState)([]),[ab,ac]=(0,d.useState)(new Set),[ad,ae]=(0,d.useState)(null),[af,ag]=(0,d.useState)(null),[ah,ai]=(0,d.useState)(!1),[aj,ak]=(0,d.useState)(!1),[al,am]=(0,d.useState)("worktree"),an=(0,d.useRef)(T);an.current=T;let ao=(0,d.useRef)(al);ao.current=al;let ap=(0,d.useRef)(X);ap.current=X;let aq=(0,d.useRef)(ad);aq.current=ad;let ar=(0,d.useCallback)(()=>{D(!0),P(null),i.t4.runPromise((0,j.r4)(a).pipe(h.YWq({onSuccess:a=>{a.local&&a.current?(l(a),n(a.current),a.upstream&&W(a.upstream)):(P(g.A.t("git.cannotGetBranches")),l(null))},onFailure:a=>{console.error(a),"NotFoundError"===a._tag?P(g.A.t("git.notGitRepo")):P(g.A.t("git.getBranchesFailed")),l(null)}}))).finally(()=>D(!1))},[a]),as=(0,d.useCallback)(b=>{F(!0),r(null),t([]),v([]),z(null),B(null),J(!0),i.t4.runPromise((0,j.Bj)(a,b,f.B_).pipe(h.YWq({onSuccess:a=>{let b=a.commits||[];p(b),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>F(!1))},[a]),at=(0,d.useCallback)(()=>{if(G||!I||!m)return;H(!0);let b=o.length;i.t4.runPromise((0,j.Bj)(a,m,f.B_,b).pipe(h.YWq({onSuccess:a=>{let b=a.commits||[];b.length>0&&p(a=>[...a,...b]),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>H(!1))},[a,m,o.length,G,I]),au=(0,d.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&at()},[at]),av=(0,d.useCallback)(b=>{r(b),z(null),B(null),L(!0),i.t4.runPromise((0,j.Zi)(a,b.hash).pipe(h.YWq({onSuccess:a=>{let b=a.files||[];t(b);let c=(0,e.Do)(b);v(c),x(new Set((0,e.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>L(!1))},[a]),aw=(0,d.useCallback)(c=>{q&&(z(c),b(c.path),N(!0),i.t4.runPromise((0,j.Zi)(a,q.hash,c.path).pipe(h.YWq({onSuccess:a=>B(a),onFailure:a=>{console.error(a)}}))).finally(()=>N(!1)))},[a,q,b]),ax=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ay=(0,d.useCallback)((b,c)=>{ai(!0),ae(null),ag(null),i.t4.runPromise((0,j.yy)(a,b,void 0,c??ao.current).pipe(h.YWq({onSuccess:a=>{let b=a.files||[];$(b);let c=(0,e.Do)(b);aa(c),ac(new Set((0,e.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>ai(!1))},[a]),az=(0,d.useCallback)(c=>{ae(c),b(c.path),ak(!0),i.t4.runPromise((0,j.yy)(a,X,c.path,ao.current).pipe(h.YWq({onSuccess:a=>ag(a),onFailure:a=>{console.error(a)}}))).finally(()=>ak(!1))},[a,X,b]),aA=(0,d.useCallback)(()=>{if(!an.current||"worktree"!==ao.current)return;let b=ap.current;if(!b)return;i.t4.runPromise((0,j.yy)(a,b,void 0,"worktree").pipe(h.YWq({onSuccess:a=>{let b=a.files||[];$(b);let c=(0,e.Do)(b);aa(c),ac(a=>{let b=new Set(a);for(let d of(0,e.Sz)(c))a.has(d)||b.add(d);return b})},onFailure:a=>console.error(a)})));let c=aq.current;c&&i.t4.runPromise((0,j.yy)(a,b,c.path,"worktree").pipe(h.YWq({onSuccess:a=>ag(a),onFailure:a=>console.error(a)})))},[a]),aB=(0,d.useCallback)(a=>{if(ao.current===a)return;ao.current=a,am(a);let b=ap.current;an.current&&b&&ay(b,a)},[ay]),aC=(0,d.useCallback)(a=>{ac(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aD=(0,d.useCallback)(a=>{if(U(a),a){let a="origin/main";Y(a),ay(a)}else $([]),aa([]),ae(null),ag(null),Y("")},[V,ay]);return{branches:c,selectedBranch:m,setSelectedBranch:n,commits:o,setCommits:p,selectedCommit:q,setSelectedCommit:r,historyFiles:s,historyFileTree:u,historyExpandedPaths:w,historySelectedFile:y,historyFileDiff:A,isLoadingBranches:C,isLoadingCommits:E,isLoadingMore:G,hasMoreCommits:I,setHasMoreCommits:J,isLoadingHistoryFiles:K,isLoadingHistoryDiff:M,historyError:O,commitListRef:Q,tooltipPos:R,loadBranches:ar,loadCommits:as,loadMoreCommits:at,handleCommitListScroll:au,handleSelectCommit:av,handleSelectHistoryFile:aw,handleHistoryToggle:ax,handleCommitInfoMouseMove:(0,d.useCallback)(a=>{S({x:a.clientX,y:a.clientY})},[]),handleCommitInfoMouseLeave:(0,d.useCallback)(()=>{S(null)},[]),compareMode:T,toggleCompareMode:aD,compareBaseBranch:X,setCompareBaseBranch:Y,upstreamBranch:V,compareFiles:Z,compareFileTree:_,compareExpandedPaths:ab,compareSelectedFile:ad,compareFileDiff:af,isLoadingCompareFiles:ah,isLoadingCompareDiff:aj,handleSelectCompareFile:az,handleCompareToggle:aC,loadCompareFiles:ay,compareDiffMode:al,setCompareDiffMode:aB,refreshCompare:aA}}},62397:(a,b,c)=>{"use strict";c.d(b,{BotsModal:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call BotsModal() from the server but BotsModal 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/BotsModal.tsx","BotsModal")},62473:(a,b,c)=>{"use strict";c.d(b,{g:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[h,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-11":b?.status==="allowed_warning"?"text-amber-11":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-h;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border ",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,"data-tooltip":[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5","data-tooltip":[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},63041:(a,b,c)=>{"use strict";c.d(b,{e:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(35606);function h({cwd:a,sessionId:b,engine:c,onOpenProjectSessions:i,onOpenSessionBrowser:j,onOpenSettings:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),o=b?(0,g.X)(c,b):null;return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:j,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),o&&(0,d.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(o).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${m?"text-green-11 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:m?l("chat.copiedCommandTooltip"):l("chat.copyCommandTooltip",{command:o}),children:m?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:k,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}},63565:(a,b,c)=>{"use strict";c.d(b,{$T:()=>n,Aw:()=>o,CX:()=>j,Fx:()=>m,H:()=>g,XY:()=>s,ch:()=>h,eV:()=>q,hG:()=>r,pe:()=>k,yI:()=>l,ys:()=>p});var d=c(48249);c(67484);var e=c(42742),f=c(44218);let g={claude:"Claude",codex:"Codex",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function h(a){return!!a&&a in g}let i={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5},j=Object.keys(i).sort((a,b)=>i[a]-i[b]),k={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",deepseek:"text-sky-600 dark:text-sky-400",kimi:"text-purple-600 dark:text-purple-400",glm:"text-amber-600 dark:text-amber-400",ollama:"text-violet-600 dark:text-violet-400"},l="bg-accent font-medium text-foreground",m="focus:border-brand",n="bg-brand text-white hover:bg-brand/90",o="text-rose-600 dark:text-rose-400",p="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function q({engine:a,className:b="h-3.5 w-3.5"}){return(0,d.jsx)("img",{alt:"","aria-hidden":"true",src:`/agent-icons/${a}.svg`,className:`${b} flex-shrink-0`})}function r({selected:a}){return(0,d.jsx)("span",{className:"flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center text-foreground",children:a&&(0,d.jsx)(e.A,{className:"h-3.5 w-3.5"})})}function s({label:a,title:b,onClick:c,buttonRef:e,icon:g,labelClassName:h,labelMaxWidth:i="max-w-[160px]",testId:j}){return(0,d.jsxs)("button",{ref:e,type:"button",onClick:c,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:b,"data-testid":j,children:[g,(0,d.jsx)("span",{className:`truncate ${i} ${h??""}`,children:a}),(0,d.jsx)(f.A,{className:"h-3 w-3 flex-shrink-0"})]})}},64340:(a,b,c)=>{"use strict";c.d(b,{r:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(),[c,e]=(0,d.useState)(),[f,g]=(0,d.useState)(!1),h=!!a&&!!c&&function(a,b){let c=a=>a.replace(/^v/,"").split("-")[0].split(".").map(a=>parseInt(a,10)||0),d=c(a),e=c(b),f=Math.max(d.length,e.length);for(let a=0;a<f;a++){let b=d[a]??0,c=e[a]??0;if(b!==c)return b-c}return 0}(c,a)>0;return{current:a,latest:f?c??"999.0.0":c,hasUpdate:!!f||h}}c(33281),c(65484)},64676:(a,b,c)=>{"use strict";c.d(b,{GV:()=>s,J4:()=>i,Kx:()=>t,OP:()=>w,PB:()=>v,Xe:()=>m,hE:()=>u,qF:()=>j,xh:()=>p});var d=c(23389);let e=`
28
+ ${f}`),bV(h,c)}else bV(aH("chat.executedCommandFailed",{command:e,error:g.cause}),c);return}bV(a,c)},[bV,b,aH,bC,a4]),bX=(0,f.useCallback)(()=>{a4(!1),bV(aH("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[bV,a4,aH]),bY=by||aQ,bZ=am&&!bM&&!!bY;(0,j.u)(bY,aP,bZ,bB,{onRunningChange:a=>{br.current=a,bj(a)},onLiveOutputTokens:bl,onRunStartedAt:bn,onBackgroundTasks:a=>bp(a.length?a:v.R),taskStore:bq,onComplete:()=>{b&&bY&&bx(b,bY,!0,10)}}),(0,f.useRef)(am),(0,f.useRef)(0);let b$=bN||a_,b_=bM?bO:bi?bk:null,b0=bM?bP:bi?bm:null,b1=bM?bS:bi?bo:v.R;(0,f.useRef)(!1);let b2=(0,f.useCallback)(async(a,c)=>{let d=by??aQ;if(!b||!d)return;let e=await k.t4.runPromiseExit((0,l.Zr)(d,{cwd:b,fromMessageUuid:a,scope:c}));if("Success"===e._tag&&e.value.newSessionId){let a=e.value.newSessionId;aA?aA(a,"single"===c?"Excerpt":"Fork"):(0,m.F)(n.n.OpenProject,{cwd:b,sessionId:a})}else"Failure"===e._tag&&(console.error("Fork failed:",e.cause),(0,i.oR)("single"===c?aH("toast.excerptFailed",{defaultValue:"Failed to excerpt this turn"}):aH("toast.forkFailed",{defaultValue:"Failed to fork session"}),"error"))},[b,by,aQ,aA,aH]),b3=(0,f.useRef)(b2);b3.current=b2;let b4=(0,f.useRef)((a,b)=>b3.current(a,b)).current,b5=(0,f.useCallback)(async a=>{let c=by??aQ;if(!b||!c||bM||bi)return;let d=Math.max(10,aO.filter(a=>"user"===a.role).length),e=await k.t4.runPromiseExit((0,l.$N)(c,{cwd:b,messageUuid:a}));"Success"===e._tag?(aP(b=>{let c=b.findIndex(b=>b.id===a);if(c<0)return b;let d=c;for(;d>=0&&"user"!==b[d].role;)d-=1;if(d<0)return b;let e=d+1;for(;e<b.length&&"user"!==b[e].role;)e+=1;return[...b.slice(0,d),...b.slice(e)]}),await bx(b,c,!1,d,void 0,!0),(0,i.oR)(aH("toast.turnDeleted",{defaultValue:"Turn deleted"}),"success")):(console.error("Delete turn failed:",e.cause),(0,i.oR)(aH("toast.deleteTurnFailed",{defaultValue:"Failed to delete this turn"}),"error"))},[b,by,aQ,bM,bi,aO,bx,aH]),b6=(0,f.useRef)(b5);b6.current=b5;let b7=(0,f.useRef)(a=>b6.current(a)).current,b8=(0,f.useCallback)(a=>{if(ao&&aN){if(!aN.sendToTab(ao,a))return void(0,i.oR)(aH("toast.sendToPeerFailed",{defaultValue:"Failed to send to the other pane"}),"error");(0,i.oR)(aH("toast.sentToPeer",{defaultValue:"Sent to the other pane"}),"success")}},[ao,aN,aH]),b9=(0,f.useRef)(b8);b9.current=b8;let ca=(0,f.useRef)(a=>b9.current(a)).current,cb=(0,f.useCallback)(()=>{aX(!0)},[]),cc=(0,f.useCallback)(()=>{a$(!0)},[]),cd=(0,f.useRef)(aO);cd.current=aO;let ce=(0,f.useCallback)(async a=>{if(cd.current.some(b=>b.id===a.id))return void bf.current?.scrollToMessage(a.id);await bw(a.turnIndex);for(let b=0;b<30;b++)if(await new Promise(a=>requestAnimationFrame(()=>a())),bf.current?.scrollToMessage(a.id))return},[bw]),cf=(0,f.useMemo)(()=>{if(az&&b&&a)return c=>{az({...c,cwd:b,tabId:a,sessionId:aQ??crypto.randomUUID(),engine:bB,..."ollama"===bB&&K&&{model:K},...bI&&bJ&&{model:bJ},...bC&&{model:bE},...bD&&{model:bG}})}},[az,b,a,aQ,bB,K,bI,bJ,bC,bE,bD,bG]),cg=bL?(0,e.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer select-none","data-tooltip":aH("chat.noHistoryDesc",{defaultValue:"each prompt is independent"}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"nohistory-toggle",checked:a7,onChange:a=>a8(a.target.checked),className:"peer sr-only"}),(0,e.jsx)("span",{"aria-hidden":"true",className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-muted-foreground/30 transition-colors peer-checked:bg-brand peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring",children:(0,e.jsx)("span",{className:`h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${a7?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-foreground",children:[(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"}),aH("chat.noHistory",{defaultValue:"No history context"})]})]}):null,ch=(0,e.jsx)(D.T,{value:bb,onChange:bc});return(0,e.jsx)(w.I$.Provider,{value:bq,children:(0,e.jsxs)("div",{className:`flex ${ak&&al?"h-full":"h-screen"} bg-card`,children:[(0,e.jsxs)("div",{id:"chat-screen",className:"flex-1 flex flex-col min-w-0 relative",onMouseEnter:()=>aT(!0),onMouseLeave:()=>aT(!1),children:[!ak&&(0,e.jsx)(o.e,{cwd:b,sessionId:aQ,engine:bB,onOpenProjectSessions:()=>aV(!0),onOpenSessionBrowser:aE,onOpenSettings:aF}),(bC||bD)&&(0,e.jsxs)("div",{className:M,children:[(0,e.jsx)(C.Yd,{engine:bD?"codex":"claude",claudeModel:bE,onClaudeModelChange:V,claudeEffort:bF,onClaudeEffortChange:X,claudeFastMode:Y,onClaudeFastModeChange:Z,claudeThinking:$,onClaudeThinkingChange:_,codexModel:bG,onCodexModelChange:ab,codexReasoningEffort:bH,onCodexReasoningEffortChange:ad}),bC&&(0,e.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer select-none","data-tooltip":aH("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:a3,onChange:a=>a4(a.target.checked),className:"peer sr-only"}),(0,e.jsx)("span",{"aria-hidden":"true",className:"relative inline-flex h-4 w-7 shrink-0 items-center rounded-full bg-muted-foreground/30 transition-colors peer-checked:bg-brand peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring",children:(0,e.jsx)("span",{className:`h-3 w-3 rounded-full bg-white shadow-sm transition-transform ${a3?"translate-x-3.5":"translate-x-0.5"}`})}),(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-foreground",children:[(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"}),aH("chat.planMode",{defaultValue:"Plan mode"})]})]}),cg,ch]}),"ollama"===bB&&(0,e.jsxs)("div",{className:M,children:[N&&(0,e.jsx)(A.m,{currentModel:K,onModelChange:N}),cg,ch]}),bI&&(0,e.jsxs)("div",{className:M,children:[bK&&(0,e.jsx)(B.Z,{engine:bI,currentModel:bJ,onModelChange:bK,onHasKeyChange:be}),cg,ch,(0,e.jsx)("div",{className:"ml-auto pl-2",children:"deepseek"===bI?(0,e.jsx)(E.f,{hasKey:bd}):(0,e.jsx)(F.J,{engine:bI,hasKey:bd})})]}),bs?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:aH("sessions.loadingHistory")})}):(0,e.jsx)(x.M,{ref:bf,messages:aO,isLoading:bM||bi,liveOutputTokens:b_,runningStartedAt:b0,cwd:b,sessionId:aQ,engine:bB,botName:bA,apiRetryInfo:bR,backgroundTasks:b1,hasMoreHistory:bu,isLoadingMore:bt,onLoadMore:bv,onFork:b4,onDeleteTurn:b7,onSendToPeer:ca,peerSide:ap,isActive:am,onContentSearch:aB,onShowFileDiff:aC,onOpenFileLink:aD,onApprovePlan:bX,onShowUserMessages:cc}),b$&&(0,e.jsx)(q.g,{tokenUsage:b$,rateLimitInfo:bQ}),aI&&!an?null:(aG=(0,e.jsx)(y.V,{onSend:bW,disabled:bM||bi,cwd:b,engine:bB,onShowGitStatus:av,onShowComments:b?cb:void 0,hasComments:aY,onOpenNote:aw,isFavorite:ax,onToggleFavorite:ay,onCreateScheduledTask:cf,draft:aJ,setDraft:aK,draftImages:aL,setDraftImages:aM}),aI?(0,p.createPortal)(aG,aI):aG)]}),!ak&&b&&(0,e.jsx)(z.Q,{isOpen:aU,onClose:()=>aV(!1),cwd:b}),b&&(0,e.jsx)(I.i,{isOpen:aW,onClose:()=>aX(!1),cwd:b}),(0,e.jsx)(s.f,{isOpen:aZ,onClose:()=>a$(!1),cwd:b,sessionId:by??aQ,onSelectMessage:ce})]})})}d()}catch(a){d(a)}})},58904:(a,b,c)=>{"use strict";c.d(b,{e:()=>k});var d=c(67484),e=c(20586),f=c(7833),g=c(208),h=c(79606),i=c(33281),j=c(85655);function k({cwd:a,addToRecentFiles:b}){let[c,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(!1),[o,p]=(0,d.useState)(null),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)(null),[u,v]=(0,d.useState)(!1),[w,x]=(0,d.useState)(new Set),[y,z]=(0,d.useState)(new Set),[A,B]=(0,d.useState)([]),[C,D]=(0,d.useState)([]),E=(0,d.useMemo)(()=>{let a=new Set((0,e.Sz)(A));for(let b of w)a.delete(b);return a},[A,w]),F=(0,d.useMemo)(()=>{let a=new Set((0,e.Sz)(C));for(let b of y)a.delete(b);return a},[C,y]),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(0),K=(0,d.useCallback)(async()=>{n(!0),p(null),await i.t4.runPromise((0,j.lv)(a).pipe(h.YWq({onSuccess:a=>{l(a);let b=(0,e.Do)(a.staged),c=(0,e.Do)(a.unstaged);B(b),D(c)},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Unknown error")}}))),n(!1)},[a]),L=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),M=(0,d.useCallback)(a=>{z(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),N=(0,d.useCallback)((a,c)=>{r({file:a,type:c}),b(a.path)},[b]),O=(0,d.useCallback)(async(a,b,c,d)=>{let e=await i.t4.runPromiseExit(a);"Success"===e._tag?(await K(),(0,f.oR)(b,"success")):(console.error(c,e.cause),(0,f.oR)(d,"error"))},[K]),P=(0,d.useCallback)(b=>O((0,j.Iz)(a,[b]),g.A.t("toast.staged"),"Error staging file:",g.A.t("toast.stageFailed")),[a,O]),Q=(0,d.useCallback)(b=>O((0,j.X0)(a,[b]),g.A.t("toast.unstaged"),"Error unstaging file:",g.A.t("toast.unstageFailed")),[a,O]),R=(0,d.useCallback)(async b=>{0!==b.length&&await O((0,j.Iz)(a,b),g.A.t("toast.stagedNFiles",{count:b.length}),"Error staging files:",g.A.t("toast.stageFailed"))},[a,O]),S=(0,d.useCallback)(async b=>{0!==b.length&&await O((0,j.X0)(a,b),g.A.t("toast.unstagedNFiles",{count:b.length}),"Error unstaging files:",g.A.t("toast.unstageFailed"))},[a,O]),T=(0,d.useCallback)(async b=>{if(0===b.length)return;let c=b.filter(a=>"untracked"===a.status).map(a=>a.path),d=b.filter(a=>"untracked"!==a.status).map(a=>a.path),e=h.JkU(function*(){c.length>0&&(yield*(0,j.Ub)(a,c,!0)),d.length>0&&(yield*(0,j.Ub)(a,d,!1))});await O(e,g.A.t("toast.discardedNFiles",{count:b.length}),"Error discarding files:",g.A.t("toast.discardFailed"))},[a,O]),U=(0,d.useCallback)(async()=>{c?.unstaged.length&&await O((0,j.Iz)(a,c.unstaged.map(a=>a.path)),g.A.t("toast.stagedNFiles",{count:c.unstaged.length}),"Error staging all files:",g.A.t("toast.stageFailed"))},[a,c,O]),V=(0,d.useCallback)(async()=>{c?.staged.length&&await O((0,j.X0)(a,c.staged.map(a=>a.path)),g.A.t("toast.unstagedNFiles",{count:c.staged.length}),"Error unstaging all files:",g.A.t("toast.unstageFailed"))},[a,c,O]),W=(0,d.useCallback)(async b=>{let c="untracked"===b.status;await O((0,j.Ub)(a,[b.path],c),c?g.A.t("toast.deletedFile"):g.A.t("toast.discardedChanges"),"Error discarding file:",g.A.t("toast.discardFailed"))},[a,O]),X=(0,d.useCallback)(async()=>{if(!c?.unstaged.length||!await (0,f.lJ)(g.A.t("git.discardAllConfirm",{count:c.unstaged.length}),{danger:!0}))return;let b=c.unstaged.filter(a=>"untracked"===a.status).map(a=>a.path),d=c.unstaged.filter(a=>"untracked"!==a.status).map(a=>a.path),e=c.unstaged.length,i=h.JkU(function*(){d.length>0&&(yield*(0,j.Ub)(a,d,!1)),b.length>0&&(yield*(0,j.Ub)(a,b,!0))});await O(i,g.A.t("toast.discardedNFiles",{count:e}),"Error discarding all:",g.A.t("toast.discardFailed"))},[a,c,O]);return{status:c,setStatus:l,statusLoading:m,statusError:o,statusSelectedFile:q,statusDiff:s,statusDiffLoading:u,stagedExpandedPaths:E,unstagedExpandedPaths:F,stagedTree:A,setStagedTree:B,unstagedTree:C,setUnstagedTree:D,showStatusDiffPreview:G,setShowStatusDiffPreview:H,fetchStatus:K,handleStagedToggle:L,handleUnstagedToggle:M,handleStatusFileSelect:N,handleStage:P,handleUnstage:Q,handleStageFiles:R,handleUnstageFiles:S,handleDiscardFiles:T,handleStageAll:U,handleUnstageAll:V,handleDiscardFile:W,handleDiscardAll:X,refreshDiff:(0,d.useCallback)(()=>J(a=>a+1),[])}}},59336:(a,b,c)=>{"use strict";c.d(b,{U:()=>f,k:()=>e});let d=(0,c(41830).N)("cockpit-skills"),e=d.notify,f=d.subscribe},59865:(a,b,c)=>{"use strict";c.d(b,{U:()=>h});var d=c(77156),e=c(59336),f=c(99884);let g={add:d.L5,notify:e.k,namespace:"skills",failureKey:"skills.addFailed"},h=()=>(0,f.X)(g)},60333:(a,b,c)=>{"use strict";c.d(b,{q:()=>f});var d=c(48249),e=c(44384);function f({value:a,onChange:b,className:c}){let{t:g}=(0,e.Bd)();return(0,d.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${c??""}`,children:["split","unified"].map(c=>(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),b(c)},className:`px-2 py-0.5 text-xs transition-colors ${a===c?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:g("split"===c?"diffViewer.viewSplit":"diffViewer.viewUnified")},c))})}},60540:(a,b,c)=>{"use strict";function d(a){let b,c=!1,d=Promise.resolve(),e=async()=>{if(!c){c=!0;try{for(;void 0!==b;){let c=b;b=void 0;try{await a(c)}catch{}}}finally{c=!1}}};return{enqueue(a){b=a,c||(d=e())},whenIdle:()=>d}}c.d(b,{j:()=>d})},60591:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,C_:()=>v,Hz:()=>u,OG:()=>w,WU:()=>x,Zy:()=>t,aR:()=>s,cG:()=>i,d9:()=>j,e$:()=>r,jU:()=>g,oK:()=>y,u:()=>q,xb:()=>k,zs:()=>o});var d=c(67484),e=c.n(d),f=c(208);function g(a){try{return JSON.parse(a),!0}catch{return!1}}function h(a){try{let b=JSON.parse(a);return JSON.stringify(b,null,2)}catch{return a}}let i={key:"hsl(var(--blue-11))",str:"hsl(var(--green-11))",num:"hsl(var(--violet-11))",bool:"hsl(var(--red-11))",punct:"hsl(var(--slate-11))",fold:"hsl(var(--slate-11))"},j=e().createContext({version:0,collapsed:!1});function k(a,b=i){try{let c=JSON.parse(a);return n(c,0,b)}catch{return a}}let l=(a,b)=>e().createElement("span",{style:{color:a}},b);function m({label:a,labelColor:b,value:c,indent:d,colors:g}){let h=e().useContext(j),[i,k]=e().useState(null),o=i&&i.version===h.version?i.collapsed:h.collapsed,[p,q]=e().useState({x:0,y:0}),r="string"==typeof c&&c.replace(/\\n/g,"\n").split("\n").length>3,s={onMouseDown:a=>{q({x:a.clientX,y:a.clientY})},onClick:a=>{let b=a.clientX-p.x,c=a.clientY-p.y;b*b+c*c>25||(a.stopPropagation(),k({version:h.version,collapsed:!o}))},style:{cursor:"pointer"}};if(r&&o&&"string"==typeof c){let d=c.replace(/\\n/g,"\n").split("\n")[0],h=c.replace(/\\n/g,"\n").split("\n").length;return e().createElement("span",s,l(b,a),l(g.punct,": "),l(g.str,d),l(g.fold,` ${f.A.t("toolCall.foldedLines",{count:h})}`))}let t=e().createElement(e().Fragment,null,l(b,a),l(g.punct,": "),n(c,d,g));return r?e().createElement("span",s,t):t}function n(a,b,c){let d=" ".repeat(b);if(null===a)return l(c.bool,"null");if(void 0===a)return l(c.bool,"undefined");if("string"==typeof a){let b=a.replace(/\\n/g,"\n").replace(/\n/g,"\n"+d);return l(c.str,b)}if("number"==typeof a)return l(c.num,String(a));if("boolean"==typeof a)return l(c.bool,String(a));if(Array.isArray(a))return 0===a.length?l(c.punct,"[]"):e().createElement(e().Fragment,null,l(c.punct,"["),"\n",...a.map((f,g)=>e().createElement("span",{key:g},d+" ",e().createElement(m,{label:`[${g}]`,labelColor:c.key,value:f,indent:b+1,colors:c}),g<a.length-1?e().createElement(e().Fragment,null,l(c.punct,","),"\n"):"\n")),d,l(c.punct,"]"));if("object"==typeof a){let f=Object.entries(a);return 0===f.length?l(c.punct,"{}"):e().createElement(e().Fragment,null,l(c.punct,"{"),"\n",...f.map(([a,g],h)=>e().createElement("span",{key:a},d+" ",e().createElement(m,{label:a,labelColor:c.key,value:g,indent:b+1,colors:c}),h<f.length-1?e().createElement(e().Fragment,null,l(c.punct,","),"\n"):"\n")),d,l(c.punct,"}"))}return String(a)}function o(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path&&"string"==typeof b.old_string&&"string"==typeof b.new_string)return b}catch{}return null}let p=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function q(a){let b=a.slice(a.lastIndexOf(".")).toLowerCase();return p.has(b)}function r(a){return a.toLowerCase().endsWith(".md")}function s(a){let b=a.toLowerCase();return b.endsWith(".html")||b.endsWith(".htm")}function t(a){let b=a.toLowerCase();return b.endsWith(".csv")||b.endsWith(".tsv")}function u(a){return a.toLowerCase().endsWith(".json")}function v(a){return"skill.md"===a.slice(a.lastIndexOf("/")+1).toLowerCase()}function w(a){return"bot.md"===a.slice(a.lastIndexOf("/")+1).toLowerCase()}function x(a,b){let c=b.startsWith("/")?[]:a.split("/").slice(0,-1);for(let a of b.replace(/^\//,"").split("/"))""!==a&&"."!==a&&(".."===a?c.pop():c.push(a));return c.join("/")}function y(a){try{let b=JSON.parse(a);if(b&&"string"==typeof b.file_path)return b.file_path}catch{let b=a.trim();if(b.startsWith("/")&&!b.includes("\n")&&b.length<500)return b}return null}},60812:(a,b,c)=>{"use strict";c.d(b,{J:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(33281),h=c(63565),i=c(41224);let j={kimi:"https://www.kimi.com/code/console",glm:"https://bigmodel.cn/coding-plan/personal/usage"};function k(a){let b=a.remaining??"?",c=a.limit??"?";return`${a.label} ${b}/${c}`}function l({engine:a,hasKey:b}){let{t:c}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(null),s=(0,e.useCallback)(async()=>{n(!0),r(null);let b=await g.t4.runPromiseExit((0,i.dM)(a));"Failure"===b._tag?(p(null),r(c("chat.quotaFailed",{defaultValue:"Quota unavailable — check the API key"}))):p(b.value),n(!1)},[c,a]),t=o?.windows??[],u=[o?.tier,...t.map(k)].filter(Boolean).join(" \xb7 "),v=function(a){if(!a)return null;let b=new Date(a);return Number.isNaN(b.getTime())?null:`${b.getMonth()+1}/${b.getDate()} ${String(b.getHours()).padStart(2,"0")}:${String(b.getMinutes()).padStart(2,"0")}`}(t.reduce((a,b)=>b.resetTime&&(!a||b.resetTime>a)?b.resetTime:a,null)),w=t.some(a=>0===a.remaining);return(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[m&&(0,d.jsx)("span",{className:"w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin"}),!m&&q&&(0,d.jsx)("span",{className:"text-xs text-red-11",children:q}),!m&&!q&&o&&(0,d.jsx)("span",{className:`text-xs font-mono ${w?"text-red-11":h.pe[a]}`,"data-tooltip":v?c("chat.quotaResetAt",{defaultValue:"Resets {{time}}",time:v}):void 0,"data-testid":`${a}-quota-value`,children:u||c("chat.quotaEmpty",{defaultValue:"No quota returned"})}),(0,d.jsx)("button",{type:"button","data-testid":`${a}-quota-button`,disabled:!b||m,onClick:s,"data-tooltip":b?void 0:c("chat.quotaNeedsKey",{defaultValue:"Set an API key first"}),className:"px-2 py-0.5 text-xs rounded border border-border text-muted-foreground hover:bg-hover hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:c("chat.checkQuota",{defaultValue:"Check quota"})}),(0,d.jsx)("a",{href:j[a],target:"_blank",rel:"noopener","data-testid":`${a}-console-link`,title:c("chat.openProviderConsole",{defaultValue:"Open the provider console"}),"aria-label":c("chat.openProviderConsole",{defaultValue:"Open the provider console"}),className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover 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:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}},61130:(a,b,c)=>{"use strict";c.d(b,{ReviewCommentsListModal:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(44256),h=c(7833),i=c(208);function j(a,b,c){let d=(a,c)=>b[a]||c,e=[],f=null!=c?`[${c+1}] `:"",g=a.anchor.selectedText.length>200?a.anchor.selectedText.slice(0,197)+"...":a.anchor.selectedText;for(let b of(e.push(`${f}${i.A.t("review.quoteRef",{text:g})}`),e.push(i.A.t("review.commentAuthor",{author:d(a.authorId,a.author),content:a.content})),a.replies))e.push(i.A.t("review.replyAuthor",{author:d(b.authorId,b.author),content:b.content}));return e.join("\n")}function k({isOpen:a,onClose:b,comments:c,reviewTitle:m,userNameMap:n,onCommentClick:o}){let{t:p}=(0,f.Bd)(),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1);if(!a)return null;let u=[...c].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),v=(a,b)=>n[a]||b,w=async a=>{r(a.id);try{let b=j(a,n);await navigator.clipboard.writeText(b),(0,h.oR)(p("toast.copiedComment"))}catch{(0,h.oR)(p("toast.copyFailed"),"error")}finally{r(null)}},x=async()=>{if(0!==c.length){t(!0);try{let a=function(a,b,c){if(0===a.length)return"";let d=[...a].sort((a,b)=>a.anchor.startOffset-b.anchor.startOffset),e=[i.A.t("review.reviewSummary",{title:b}),""];return d.forEach((a,b)=>{e.push(j(a,c,b)),e.push("")}),e.push(i.A.t("review.totalNComments",{count:a.length})),e.join("\n").trim()}(c,m,n);await navigator.clipboard.writeText(a),(0,h.oR)(p("toast.copiedAllComments"))}catch{(0,h.oR)(p("toast.copyFailed"),"error")}finally{t(!1)}}},y=a=>{o?.(a),b()},z=u.filter(a=>!a.closed),A=u.filter(a=>a.closed),B=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-lv3 flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border ",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:p("review.allCommentsTitle")}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[p("review.commentsCountBrief",{count:c.length}),A.length>0&&` (${p("review.closedCount",{count:A.length})})`]}),c.length>0&&(0,d.jsx)("button",{onClick:x,disabled:s,className:"p-1 rounded hover:bg-hover text-muted-foreground disabled:opacity-50",title:p("review.copyAllComments"),children:s?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(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:"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,d.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:0===c.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,d.jsx)("div",{className:"text-2xl mb-2",children:"\uD83D\uDCAC"}),(0,d.jsx)("span",{className:"text-sm",children:p("review.noComments")})]}):(0,d.jsxs)("div",{className:"space-y-2",children:[z.map((a,b)=>(0,d.jsx)(l,{comment:a,index:b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y},a.id)),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"text-[11px] text-muted-foreground/60 pt-2 pb-1 px-1",children:p("review.closedComments",{count:A.length})}),A.map((a,b)=>(0,d.jsx)(l,{comment:a,index:z.length+b,resolveAuthor:v,copyingId:q,onCopy:w,onClick:y,closed:!0},a.id))]})]})})]})});return(0,d.jsx)(g.ZL,{children:B})}function l({comment:a,index:b,resolveAuthor:c,copyingId:e,onCopy:f,onClick:g,closed:h}){let j=a.anchor.selectedText.length>100?a.anchor.selectedText.slice(0,97)+"...":a.anchor.selectedText;return(0,d.jsxs)("div",{className:`rounded-lg border border-border hover:border-muted-foreground/30 transition-all cursor-pointer group ${h?"opacity-50":""}`,onClick:()=>g(a.id),children:[(0,d.jsx)("div",{className:"px-3 pt-2.5 pb-1",children:(0,d.jsx)("div",{className:"text-xs bg-yellow-500/10 border-l-2 border-yellow-500 px-2 py-1 rounded-r text-muted-foreground truncate",children:j})}),(0,d.jsxs)("div",{className:"px-3 pt-1.5 pb-2 flex items-start gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,d.jsx)("span",{className:"w-4 h-4 rounded-full bg-brand/20 text-brand flex items-center justify-center text-[9px] font-bold flex-shrink-0",children:c(a.authorId,a.author).charAt(0)}),(0,d.jsx)("span",{className:"text-xs font-medium",children:c(a.authorId,a.author)}),(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(a.createdAt).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}),h&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:i.A.t("review.closedLabel")})]}),(0,d.jsx)("p",{className:"text-sm text-foreground line-clamp-2 pl-6",children:a.content}),a.replies.length>0&&(0,d.jsxs)("div",{className:"pl-6 mt-1 space-y-0.5",children:[a.replies.slice(0,3).map(a=>(0,d.jsxs)("div",{className:"text-xs text-muted-foreground truncate",children:[(0,d.jsx)("span",{className:"font-medium",children:c(a.authorId,a.author)}),": ",a.content]},a.id)),a.replies.length>3&&(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/60",children:i.A.t("review.moreReplies",{count:a.replies.length-3})})]})]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),f(a)},disabled:e===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground transition-opacity disabled:opacity-50 flex-shrink-0 mt-0.5",title:i.A.t("review.copyComment"),children:e===a.id?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(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:"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"})})})]})]})}},61135:()=>{},61349:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(44256);c(33281),c(87808);var i=c(35208),j=c(55287),k=c(5900),l=c(24680),m=c(84835),n=c(7833),o=c(64676),p=c(18921),q=c(53036),r=c(60591),s=a([j,i]);function t({filePath:a}){let[b,c]=(0,f.useState)(null),[d,g]=(0,f.useState)(!0),[h,i]=(0,f.useState)(null);(0,f.useRef)(!1);let k=(0,r.e$)(a);return((0,r.u)(a),h)?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:h})}):d?(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,r.u)(a)?(0,e.jsx)(q.I,{absPath:a,className:"flex items-center justify-center h-full overflow-auto",imgClassName:"max-w-full max-h-full object-contain",alt:a.split("/").pop()||"image"}):b?k?(0,e.jsx)(u,{content:b,filePath:a}):(0,e.jsx)(j.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"No content"})})}[j,i]=s.then?(await s)():s;let w=[m.W];function u({content:a,filePath:b}){let c=(0,f.useRef)(null),d=(0,f.useMemo)(()=>(0,o.J4)(b),[b]);return(0,e.jsxs)("div",{className:"h-full flex",children:[(0,e.jsx)(l.l,{content:a,containerRef:c}),(0,e.jsx)("div",{ref:c,className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(k.T,{content:a,basePath:d,rehypePlugins:w})})]})}function v({title:a,content:b,toolName:c,onClose:d}){let{t:j}=(0,g.Bd)(),k=(0,r.jU)(b),l=(0,r.zs)(b),m=(0,r.oK)(b),o=!!l,q=!!m,[s,u]=(0,f.useState)(("Read"===c||"Write"===c)&&q?"file":o?"diff-unified":k?"readable":"json"),w=(0,f.useRef)(null),x=(0,p.o)(w),y=(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full max-w-[90%] h-full md:h-[90vh] rounded-none md:rounded-lg flex flex-col transition-all",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a}),m&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(m),(0,n.oR)(j("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:j("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[k&&(0,e.jsxs)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5",children:[o&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>u("diff-split"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-split"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.sideBySide"),children:"Split"}),(0,e.jsx)("button",{onClick:()=>u("diff-unified"),className:`px-2 py-1 text-xs rounded transition-colors ${"diff-unified"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.unified"),children:"Unified"})]}),q&&(0,e.jsx)("button",{onClick:()=>u("file"),className:`px-2 py-1 text-xs rounded transition-colors ${"file"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,title:j("diffViewer.previewFile"),children:"File"}),(0,e.jsx)("button",{onClick:()=>u("readable"),className:`px-2 py-1 text-xs rounded transition-colors ${"readable"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:j("common.readable")}),(0,e.jsx)("button",{onClick:()=>u("json"),className:`px-2 py-1 text-xs rounded transition-colors ${"json"===s?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:"JSON"})]}),(0,e.jsx)("button",{onClick:d,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"file"===s&&m?(0,e.jsx)(t,{filePath:m}):"diff-unified"===s&&l?(0,e.jsx)(i.xU,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"diff-split"===s&&l?(0,e.jsx)(i.xZ,{oldContent:l.old_string,newContent:l.new_string,filePath:l.file_path}):"readable"===s&&k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p._,{search:x}),(0,e.jsx)("pre",{ref:w,className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:(0,r.xb)(b)})]}):(0,e.jsx)("pre",{className:"text-foreground whitespace-pre-wrap break-words",style:{fontSize:"0.8125rem"},children:k?(0,r.C6)(b):b})})]})});return(0,e.jsx)(h.ZL,{children:y})}d()}catch(a){d(a)}})},61591:(a,b,c)=>{"use strict";c.d(b,{o:()=>g});var d=c(48249);c(67484);let e={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",lean:"#448aff",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},f={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,d.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):"lean"===j?(0,d.jsx)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:(0,d.jsx)("path",{d:"M3.45 1.5 1.5 2.5 12 22.5 22.5 2.5 20.55 1.5 15.9 10.35H8.1ZM9 12h6l-3 6Z",fill:i,fillRule:"evenodd"})}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"env"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},61632:(a,b,c)=>{"use strict";c.d(b,{y:()=>k});var d=c(67484),e=c(20586),f=c(9804),g=c(208),h=c(79606),i=c(33281),j=c(85655);function k({cwd:a,addToRecentFiles:b}){let[c,l]=(0,d.useState)(null),[m,n]=(0,d.useState)(""),[o,p]=(0,d.useState)([]),[q,r]=(0,d.useState)(null),[s,t]=(0,d.useState)([]),[u,v]=(0,d.useState)([]),[w,x]=(0,d.useState)(new Set),[y,z]=(0,d.useState)(null),[A,B]=(0,d.useState)(null),[C,D]=(0,d.useState)(!1),[E,F]=(0,d.useState)(!1),[G,H]=(0,d.useState)(!1),[I,J]=(0,d.useState)(!0),[K,L]=(0,d.useState)(!1),[M,N]=(0,d.useState)(!1),[O,P]=(0,d.useState)(null),Q=(0,d.useRef)(null),[R,S]=(0,d.useState)(null),[T,U]=(0,d.useState)(!1),[V,W]=(0,d.useState)(""),[X,Y]=(0,d.useState)(""),[Z,$]=(0,d.useState)([]),[_,aa]=(0,d.useState)([]),[ab,ac]=(0,d.useState)(new Set),[ad,ae]=(0,d.useState)(null),[af,ag]=(0,d.useState)(null),[ah,ai]=(0,d.useState)(!1),[aj,ak]=(0,d.useState)(!1),[al,am]=(0,d.useState)("worktree"),an=(0,d.useRef)(T);an.current=T;let ao=(0,d.useRef)(al);ao.current=al;let ap=(0,d.useRef)(X);ap.current=X;let aq=(0,d.useRef)(ad);aq.current=ad;let ar=(0,d.useCallback)(()=>{D(!0),P(null),i.t4.runPromise((0,j.r4)(a).pipe(h.YWq({onSuccess:a=>{a.local&&a.current?(l(a),n(a.current),a.upstream&&W(a.upstream)):(P(g.A.t("git.cannotGetBranches")),l(null))},onFailure:a=>{console.error(a),"NotFoundError"===a._tag?P(g.A.t("git.notGitRepo")):P(g.A.t("git.getBranchesFailed")),l(null)}}))).finally(()=>D(!1))},[a]),as=(0,d.useCallback)(b=>{F(!0),r(null),t([]),v([]),z(null),B(null),J(!0),i.t4.runPromise((0,j.Bj)(a,b,f.B_).pipe(h.YWq({onSuccess:a=>{let b=a.commits||[];p(b),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>F(!1))},[a]),at=(0,d.useCallback)(()=>{if(G||!I||!m)return;H(!0);let b=o.length;i.t4.runPromise((0,j.Bj)(a,m,f.B_,b).pipe(h.YWq({onSuccess:a=>{let b=a.commits||[];b.length>0&&p(a=>[...a,...b]),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>H(!1))},[a,m,o.length,G,I]),au=(0,d.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&at()},[at]),av=(0,d.useCallback)(b=>{r(b),z(null),B(null),L(!0),i.t4.runPromise((0,j.Zi)(a,b.hash).pipe(h.YWq({onSuccess:a=>{let b=a.files||[];t(b);let c=(0,e.Do)(b);v(c),x(new Set((0,e.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>L(!1))},[a]),aw=(0,d.useCallback)(c=>{q&&(z(c),b(c.path),N(!0),i.t4.runPromise((0,j.Zi)(a,q.hash,c.path).pipe(h.YWq({onSuccess:a=>B(a),onFailure:a=>{console.error(a)}}))).finally(()=>N(!1)))},[a,q,b]),ax=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ay=(0,d.useCallback)((b,c)=>{ai(!0),ae(null),ag(null),i.t4.runPromise((0,j.yy)(a,b,void 0,c??ao.current).pipe(h.YWq({onSuccess:a=>{let b=a.files||[];$(b);let c=(0,e.Do)(b);aa(c),ac(new Set((0,e.Sz)(c)))},onFailure:a=>{console.error(a)}}))).finally(()=>ai(!1))},[a]),az=(0,d.useCallback)(c=>{ae(c),b(c.path),ak(!0),i.t4.runPromise((0,j.yy)(a,X,c.path,ao.current).pipe(h.YWq({onSuccess:a=>ag(a),onFailure:a=>{console.error(a)}}))).finally(()=>ak(!1))},[a,X,b]),aA=(0,d.useCallback)(()=>{if(!an.current||"worktree"!==ao.current)return;let b=ap.current;if(!b)return;i.t4.runPromise((0,j.yy)(a,b,void 0,"worktree").pipe(h.YWq({onSuccess:a=>{let b=a.files||[];$(b);let c=(0,e.Do)(b);aa(c),ac(a=>{let b=new Set(a);for(let d of(0,e.Sz)(c))a.has(d)||b.add(d);return b})},onFailure:a=>console.error(a)})));let c=aq.current;c&&i.t4.runPromise((0,j.yy)(a,b,c.path,"worktree").pipe(h.YWq({onSuccess:a=>ag(a),onFailure:a=>console.error(a)})))},[a]),aB=(0,d.useCallback)(a=>{if(ao.current===a)return;ao.current=a,am(a);let b=ap.current;an.current&&b&&ay(b,a)},[ay]),aC=(0,d.useCallback)(a=>{ac(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),aD=(0,d.useCallback)(a=>{if(U(a),a){let a="origin/main";Y(a),ay(a)}else $([]),aa([]),ae(null),ag(null),Y("")},[V,ay]);return{branches:c,selectedBranch:m,setSelectedBranch:n,commits:o,setCommits:p,selectedCommit:q,setSelectedCommit:r,historyFiles:s,historyFileTree:u,historyExpandedPaths:w,historySelectedFile:y,historyFileDiff:A,isLoadingBranches:C,isLoadingCommits:E,isLoadingMore:G,hasMoreCommits:I,setHasMoreCommits:J,isLoadingHistoryFiles:K,isLoadingHistoryDiff:M,historyError:O,commitListRef:Q,tooltipPos:R,loadBranches:ar,loadCommits:as,loadMoreCommits:at,handleCommitListScroll:au,handleSelectCommit:av,handleSelectHistoryFile:aw,handleHistoryToggle:ax,handleCommitInfoMouseMove:(0,d.useCallback)(a=>{S({x:a.clientX,y:a.clientY})},[]),handleCommitInfoMouseLeave:(0,d.useCallback)(()=>{S(null)},[]),compareMode:T,toggleCompareMode:aD,compareBaseBranch:X,setCompareBaseBranch:Y,upstreamBranch:V,compareFiles:Z,compareFileTree:_,compareExpandedPaths:ab,compareSelectedFile:ad,compareFileDiff:af,isLoadingCompareFiles:ah,isLoadingCompareDiff:aj,handleSelectCompareFile:az,handleCompareToggle:aC,loadCompareFiles:ay,compareDiffMode:al,setCompareDiffMode:aB,refreshCompare:aA}}},62397:(a,b,c)=>{"use strict";c.d(b,{BotsModal:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call BotsModal() from the server but BotsModal 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/BotsModal.tsx","BotsModal")},62473:(a,b,c)=>{"use strict";c.d(b,{g:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({tokenUsage:a,rateLimitInfo:b}){let{t:c}=(0,f.Bd)(),[h,i]=(0,e.useState)(()=>Date.now()),j=b?.status==="rejected"?"text-red-11":b?.status==="allowed_warning"?"text-amber-11":"text-muted-foreground",k=b?.status==="rejected"?c("chat.rateLimitRejected","Rate Limited"):b?.status==="allowed_warning"?c("chat.rateLimitWarning","Approaching Limit"):null,l=a=>{if(!a)return"";let b=(a<1e12?1e3*a:a)-h;if(b<=0)return"";let c=Math.ceil(b/6e4);if(c<60)return`${c}m`;let d=Math.floor(c/60),e=c%60;return e>0?`${d}h${e}m`:`${d}h`},m=a=>a?a.replace(/_/g," "):"";return(0,d.jsx)("div",{className:"px-4 py-1.5 border-t border-border ",children:(0,d.jsxs)("div",{className:"flex items-center justify-end gap-4 text-xs text-muted-foreground",children:[b&&k&&(0,d.jsxs)("span",{className:`flex items-center gap-1 ${j}`,"data-tooltip":[b.rateLimitType&&`Type: ${m(b.rateLimitType)}`,null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&`Resets in: ${l(b.resetsAt)}`,b.isUsingOverage&&"Using overage"].filter(Boolean).join(" \xb7 "),children:["rejected"===b.status?(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}):(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:[(0,d.jsx)("strong",{children:k}),null!=b.utilization&&` ${(100*b.utilization).toFixed(0)}%`,b.resetsAt&&` \xb7 ${l(b.resetsAt)}`]})]}),b&&!k&&b.resetsAt&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5","data-tooltip":[b.rateLimitType&&m(b.rateLimitType),null!=b.utilization&&`Usage: ${(100*b.utilization).toFixed(0)}%`,`Resets in: ${l(b.resetsAt)}`].filter(Boolean).join(" \xb7 "),children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),null!=b.utilization?(0,d.jsxs)("span",{children:[(100*b.utilization).toFixed(0),"%"]}):(0,d.jsx)("span",{children:l(b.resetsAt)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsxs)("span",{children:[c("chat.context"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens).toLocaleString()})]})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),(0,d.jsxs)("span",{children:[c("chat.output"),": ",(0,d.jsx)("strong",{className:"text-foreground",children:a.outputTokens.toLocaleString()})]})]}),(a.cacheReadInputTokens>0||a.cacheCreationInputTokens>0)&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-brand",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})}),(0,d.jsxs)("span",{children:["Cache: ",(a.cacheReadInputTokens/(a.inputTokens+a.cacheReadInputTokens+a.cacheCreationInputTokens)*100).toFixed(0),"%"]})]}),a.totalCostUsd>0&&(0,d.jsxs)("span",{className:"flex items-center gap-1 text-green-11",children:[(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,d.jsxs)("span",{children:["$",a.totalCostUsd.toFixed(4)]})]})]})})}},63041:(a,b,c)=>{"use strict";c.d(b,{e:()=>h});var d=c(48249),e=c(67484),f=c(44384),g=c(35606);function h({cwd:a,sessionId:b,engine:c,onOpenProjectSessions:i,onOpenSessionBrowser:j,onOpenSettings:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),o=b?(0,g.X)(c,b):null;return(0,d.jsx)("div",{className:"border-b border-border px-4 py-3 bg-card",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6"}),(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"One seat. One AI. Everything under control."})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a&&(0,d.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${a}`,children:a}),!a&&b&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Session: ",b.slice(0,8),"..."]}),a&&(0,d.jsx)("button",{onClick:i,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("sessions.projectSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),(0,d.jsx)("button",{onClick:j,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("sessions.browseAllSessions"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}),o&&(0,d.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(o).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},className:`p-2 rounded-lg transition-colors ${m?"text-green-11 bg-green-500/10":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:m?l("chat.copiedCommandTooltip"):l("chat.copyCommandTooltip",{command:o}),children:m?(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),(0,d.jsx)("button",{onClick:k,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:l("settings.title"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})]})})}},63565:(a,b,c)=>{"use strict";c.d(b,{$T:()=>n,Aw:()=>o,CX:()=>j,Fx:()=>m,H:()=>g,XY:()=>s,ch:()=>h,eV:()=>q,hG:()=>r,pe:()=>k,yI:()=>l,ys:()=>p});var d=c(48249);c(67484);var e=c(42742),f=c(44218);let g={claude:"Claude",codex:"Codex",deepseek:"DeepSeek",kimi:"Kimi",glm:"GLM",ollama:"Ollama"};function h(a){return!!a&&a in g}let i={claude:0,codex:1,deepseek:2,glm:3,kimi:4,ollama:5},j=Object.keys(i).sort((a,b)=>i[a]-i[b]),k={claude:"text-[#c6532d] dark:text-[#D97757]",codex:"text-emerald-600 dark:text-emerald-400",deepseek:"text-sky-600 dark:text-sky-400",kimi:"text-purple-600 dark:text-purple-400",glm:"text-amber-600 dark:text-amber-400",ollama:"text-violet-600 dark:text-violet-400"},l="bg-accent font-medium text-foreground",m="focus:border-brand",n="bg-brand text-white hover:bg-brand/90",o="text-rose-600 dark:text-rose-400",p="fixed z-[9999] max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover py-2 shadow-lv2";function q({engine:a,className:b="h-3.5 w-3.5"}){return(0,d.jsx)("img",{alt:"","aria-hidden":"true",src:`/agent-icons/${a}.svg`,className:`${b} flex-shrink-0`})}function r({selected:a}){return(0,d.jsx)("span",{className:"flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center text-foreground",children:a&&(0,d.jsx)(e.A,{className:"h-3.5 w-3.5"})})}function s({label:a,title:b,onClick:c,buttonRef:e,icon:g,labelClassName:h,labelMaxWidth:i="max-w-[160px]",testId:j}){return(0,d.jsxs)("button",{ref:e,type:"button",onClick:c,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:b,"data-testid":j,children:[g,(0,d.jsx)("span",{className:`truncate ${i} ${h??""}`,children:a}),(0,d.jsx)(f.A,{className:"h-3 w-3 flex-shrink-0"})]})}},64340:(a,b,c)=>{"use strict";c.d(b,{r:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(),[c,e]=(0,d.useState)(),[f,g]=(0,d.useState)(!1),h=!!a&&!!c&&function(a,b){let c=a=>a.replace(/^v/,"").split("-")[0].split(".").map(a=>parseInt(a,10)||0),d=c(a),e=c(b),f=Math.max(d.length,e.length);for(let a=0;a<f;a++){let b=d[a]??0,c=e[a]??0;if(b!==c)return b-c}return 0}(c,a)>0;return{current:a,latest:f?c??"999.0.0":c,hasUpdate:!!f||h}}c(33281),c(65484)},64676:(a,b,c)=>{"use strict";c.d(b,{GV:()=>s,J4:()=>i,Kx:()=>t,OP:()=>w,PB:()=>v,Xe:()=>m,hE:()=>u,qF:()=>j,xh:()=>p});var d=c(23389);let e=`
29
29
  (function () {
30
30
  if (window.cockpit) return;
31
31
 
@@ -727,13 +727,13 @@ ${f}`),bT(h,c)}else bT(aG("chat.executedCommandFailed",{command:e,error:g.cause}
727
727
  try { if (ws) ws.close(); } catch (e) {}
728
728
  });
729
729
  })();
730
- `;function f(a){return/^([/\\]|[A-Za-z]:)/.test(a)}function g(a){return f(a)||(0,d.P)(a)}function h(a,b){let c=a.replace(/[/\\]+$/,"");return b?`${c}/${b}`:c}function i(a,b){let c,d=(c=Math.max(a.lastIndexOf("/"),a.lastIndexOf("\\")))<0?"":0===c?"/":a.slice(0,c);return g(a)?d:b?h(b,d):d}function j(a,b){return g(a)||!!b}let k="/apps/local/",l="/apps/builtin/";function m(a,b){let c=a.trim();return k+n(g(c)?c:h(b??"",c)).replace(/\\/g,"/").split("/").map(encodeURIComponent).join("/").replace(/^\//,"")}function n(a){let b=/^[A-Za-z]:/.exec(a)?.[0]??"",c=b?a.slice(b.length):a,d=/^[/\\]/.test(c),e=[];for(let a of c.split(/[/\\]/))if(a&&"."!==a){if(".."===a){e.length&&".."!==e[e.length-1]?e.pop():d||b||e.push("..");continue}e.push(a)}return b+(d||b?"/":"")+e.join("/")}let o=/^([a-z][a-z0-9+.-]*:|\/\/|\/)/i;function p(a,b,c){let d=a.trim();if(!d||o.test(d)||!j(b,c))return a;let e=f(b)?b:h(c,b),g=d.search(/[?#]/),i=g<0?d:d.slice(0,g),k=g<0?"":d.slice(g);if(!i)return a;let l=i;try{l=decodeURIComponent(i)}catch{}return m(n(h(e,l)))+k}let q=[{chip:"*.md",exts:["md"]},{chip:"*.png/jpg/gif/webp/svg",exts:["png","jpg","jpeg","gif","webp","svg"]},{chip:"*.pdf",exts:["pdf"]},{chip:"*.json",exts:["json"]},{chip:"*.csv",exts:["csv"]},{chip:"*.tsv",exts:["tsv"]}],r=RegExp(`\\.(${q.flatMap(a=>a.exts).join("|")})$`,"i"),s=q.map(a=>a.chip);function t(a){return r.test(a.trim())}function u(a,b){let c=a.trim();return l+"file-viewer/index.html?file="+encodeURIComponent(n(g(c)?c:h(b??"",c)).replace(/\\/g,"/"))}function v(a,b){try{let c=new URL(a,b);if(!c.pathname.startsWith(l)&&!c.pathname.startsWith(k))return a;return"localhost"===c.hostname&&(c.hostname="127.0.0.1"),c.toString()}catch{return a}}function w(a,b){let c=a=>JSON.stringify(a).replace(/</g,"\\u003c"),d="<script>"+e.replaceAll("__CWD__",c(b.cwd)).replaceAll("__WS_URL__",c(b.wsUrl??""))+"<\/script>",f=a.match(/<head[^>]*>/i);if(f&&void 0!==f.index){let b=f.index+f[0].length;return a.slice(0,b)+d+a.slice(b)}let g=a.match(/<html[^>]*>/i);if(g&&void 0!==g.index){let b=g.index+g[0].length;return a.slice(0,b)+d+a.slice(b)}return d+a}},65139:(a,b,c)=>{"use strict";c.d(b,{BV:()=>i,NR:()=>u,Yd:()=>x,kn:()=>j,oJ:()=>p});var d=c(48249),e=c(67484),f=c(44256),g=c(63565),h=c(92545);let i="claude-opus-5-5",j="gpt-6.1-sol",k=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultracode",label:"Ultracode"},{id:"ultrathink",label:"Ultrathink"}],l=[{id:"claude-sonnet-5-5",label:"Claude Sonnet 5.5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"medium"},{id:"claude-sonnet-5",label:"Claude Sonnet 5",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"high"},{id:"claude-opus-5-5",label:"Claude Opus 5.5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"medium",fast:!0},{id:"claude-opus-5",label:"Claude Opus 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",fast:!0},{id:"claude-fable-5-1",label:"Claude Fable 5.1",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high"},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",thinking:!0}],m=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultra",label:"Ultra"}],n=[{id:"gpt-6-astra",label:"GPT-6-Astra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"},{id:"gpt-6.1-sol",label:"GPT-6.1-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"},{id:"gpt-6-sol",label:"GPT-6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-6-luna",label:"GPT-6-Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"},{id:"gpt-5.6-sol",label:"GPT-5.6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"}];function o(a){return n.find(b=>b.id===a)?.defaultReasoning??"low"}function p(a,b){let c=n.find(b=>b.id===a)?.reasoning;return b&&(!c||c.includes(b))?b:o(a)}function q(a,b){return a.find(a=>a.id===b)?.label??b}function r(a){return l.find(b=>b.id===a)?.fast===!0}function s(a){return l.find(b=>b.id===a)?.thinking===!0}function t(a){let b=l.find(b=>b.id===a);return b?b.defaultEffort:"high"}function u(a,b){let c=l.find(b=>b.id===a),d=c?.effort;return b&&(!c||d?.includes(b))?b:t(a)}function v({value:a,selected:b,label:c,defaultValue:e,onSelect:f}){return(0,d.jsxs)("button",{type:"button",onClick:()=>f(a),className:`flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition-colors ${b?g.yI:"text-muted-foreground hover:bg-hover hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"mt-0.5",children:(0,d.jsx)(g.hG,{selected:b})}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c}),(0,d.jsx)("span",{className:"shrink-0",children:e&&(0,d.jsx)("span",{className:"rounded bg-muted px-1.5 text-[10px] font-medium text-muted-foreground",children:"Default"})})]})}function w({title:a,selected:b,value:c,items:h,onSelect:i,icon:j,testId:k}){let l=(0,e.useRef)(null),m=(0,e.useRef)(null),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)({top:0,left:0}),r=(0,f.F2)();return(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(g.XY,{buttonRef:l,label:c,labelMaxWidth:"max-w-[180px]",title:`${a}: ${c}`,onClick:()=>{n||(()=>{let a=l.current?.getBoundingClientRect();if(!a)return;let b=r?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;q({top:a.bottom+4-d,left:a.left-c})})(),o(a=>!a)},icon:j,testId:k}),n&&(0,d.jsx)(f.ZL,{children:(0,d.jsxs)("div",{ref:m,className:`${g.ys} min-w-[190px]`,style:{top:p.top,left:p.left},children:[(0,d.jsx)("div",{className:"px-3 pb-1 text-[11px] font-medium text-muted-foreground",children:a}),(0,d.jsx)("div",{className:"flex flex-col",children:h.map(a=>(0,d.jsx)(v,{value:a.id,selected:b===a.id,label:a.label,defaultValue:a.defaultValue,onSelect:a=>{i(a),o(!1)}},a.id))})]})})]})}function x(a){let b,c,e,f=a.engine??"claude",v=a.claudeModel??i,x=t(v),y=(b=l.find(a=>a.id===v)?.effort)?b.map(a=>k.find(b=>b.id===a)??{id:a,label:a}):[],z=u(v,a.claudeEffort),A=a.claudeFastMode??!1,B=a.claudeThinking??!1,C=a.codexModel??j,D=o(C),E=(c=n.find(a=>a.id===C)?.reasoning)?c.map(a=>m.find(b=>b.id===a)??{id:a,label:a}):m,F=p(C,a.codexReasoningEffort);return"claude"!==f?(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(w,{title:"Model",selected:C,value:n.find(a=>a.id===C)?.label??(0,h.U)(C),items:n.map(a=>({id:a.id,label:a.label,defaultValue:a.id===j})),onSelect:b=>{a.onCodexModelChange?.(b),a.onCodexReasoningEffortChange?.(o(b))},icon:(0,d.jsx)(g.eV,{engine:"codex"}),testId:"codex-model-picker"}),(0,d.jsx)(w,{title:"Reasoning",selected:F,value:q(m,F),items:E.map(a=>({...a,defaultValue:a.id===D})),onSelect:b=>a.onCodexReasoningEffortChange?.(b),testId:"codex-reasoning-picker"})]}):(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(w,{title:"Model",selected:v,value:(e=l.find(a=>a.id===v))?e.label:v.startsWith("claude-")?`Claude ${(0,h.J)(v)}`:v,items:l.map(a=>({id:a.id,label:a.label,defaultValue:a.id===i})),onSelect:b=>{a.onClaudeModelChange?.(b);let c=t(b);c&&a.onClaudeEffortChange?.(c),r(b)||a.onClaudeFastModeChange?.(!1),s(b)||a.onClaudeThinkingChange?.(!1)},icon:(0,d.jsx)(g.eV,{engine:"claude"}),testId:"claude-model-picker"}),z&&y.length>0&&(0,d.jsx)(w,{title:"Reasoning",selected:z,value:q(k,z),items:y.map(a=>({...a,defaultValue:a.id===x})),onSelect:b=>a.onClaudeEffortChange?.(b),testId:"claude-reasoning-picker"}),r(v)&&(0,d.jsx)(w,{title:"Fast Mode",selected:A?"on":"off",value:A?"Fast On":"Fast Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:b=>a.onClaudeFastModeChange?.("on"===b),testId:"claude-fast-mode-picker"}),s(v)&&(0,d.jsx)(w,{title:"Thinking",selected:B?"on":"off",value:B?"Thinking On":"Thinking Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:b=>a.onClaudeThinkingChange?.("on"===b),testId:"claude-thinking-picker"})]})}},65395:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>e});var d=c(77943);(0,d.registerClientReference)(function(){throw Error("Attempted to call reconcileStatusTabIds() from the server but reconcileStatusTabIds is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","reconcileStatusTabIds"),(0,d.registerClientReference)(function(){throw Error("Attempted to call repairPanes() from the server but repairPanes is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","repairPanes");let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,fz:()=>s,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b,c)=>d.$mh({try:async()=>{let d=l(a),e=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b,baseMtime:c})});if(409===e.status){let a=await e.json();return{conflict:!0,content:a.content??"",mtime:a.mtime}}if(!e.ok)throw Error(`HTTP ${e.status}`);return{conflict:!1,mtime:(await e.json()).mtime}},catch:b=>new e.uV({message:`POST ${l(a)} failed`,cause:b})}),o=()=>f("/api/sessions/projects"),p=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),q=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),r=a=>g("/api/project-settings",a),s=a=>f(`/api/fs/dirs?path=${encodeURIComponent(a)}`),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},69424:(a,b,c)=>{"use strict";c.d(b,{$:()=>s});var d=c(48249),e=c(67484),f=c(44384),g=c(57063),h=c(7833),i=c(44256),j=c(74118),k=c(15273),l=c(46674),m=c(99941),n=c(44643),o=c(32026),p=c(11732),q=c(75513);function r(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function s({toolCalls:a,onClose:b}){let{t:c}=(0,f.Bd)(),t=(0,q.nH)(),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)({}),[A,B]=(0,e.useState)({});(0,g.E)(b);let C=a.reduce((a,b)=>{let{questions:c}=r(b);return a+c.length},0),D=Object.values(A).filter(Boolean).length,E=(0,e.useCallback)((a,b)=>{v(c=>({...c,[a]:b})),x(b=>({...b,[a]:!1}))},[]),F=(0,e.useCallback)(a=>{x(b=>{let c=!b[a];if(c){let b=y[a]||"";b&&v(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[y]),G=(0,e.useCallback)((a,b)=>{z(c=>({...c,[a]:b})),b&&v(c=>({...c,[a]:b}))},[]),H=(0,e.useCallback)(a=>{B(b=>({...b,[a]:!b[a]}))},[]),I=(0,e.useCallback)(()=>{let b=D>0,d=[];return a.forEach((a,e)=>{let{questions:f}=r(a);f.forEach((a,f)=>{let g=`${e}-${f}`;if(b&&!A[g])return;let h=u[g];d.push(`Q: ${a.question}`),d.push(`A: ${h||c("askQuestion.notSelected")}`),d.push("")})}),d.join("\n").trim()},[a,u,A,D,c]),J=(0,e.useCallback)(()=>{navigator.clipboard.writeText(I()),(0,h.oR)(D>0?c("toast.copiedQA",{count:D}):c("toast.copiedAllQA"))},[I,D,c]),K=(0,e.useCallback)(()=>{t?(t.sendMessage(I()),(0,h.oR)(c("toast.sentQA")),b()):(0,h.oR)(c("askQuestion.sendNoChat"))},[t,I,b,c]),L=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:C}),D>0&&` \xb7 ${c("askQuestion.checkedN",{count:D})}`]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:K,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:D>0?c("askQuestion.sendChecked",{count:D}):c("askQuestion.sendAll"),children:(0,d.jsx)(j.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:J,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:D>0?c("askQuestion.copyChecked",{count:D}):c("askQuestion.copyAll"),children:(0,d.jsx)(k.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,e)=>{let{questions:f}=r(b);return f.map((b,g)=>{let h=`${e}-${g}`,i=u[h],j=w[h]||!1,k=A[h]||!1;return(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("button",{onClick:()=>H(h),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-hover transition-colors",title:c("askQuestion.checkToCopy"),children:k?(0,d.jsx)(m.A,{className:"w-4 h-4 text-brand"}):(0,d.jsx)(n.A,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,d.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:b.header}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,d.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=i===a.label&&!j;return(0,d.jsxs)("button",{onClick:()=>E(h,a.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,d.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,d.jsxs)("button",{onClick:()=>F(h),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${j?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:j?(0,d.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(p.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),j&&(0,d.jsx)("div",{className:"ml-6 mt-1",children:(0,d.jsx)("input",{type:"text",autoFocus:!0,value:y[h]||"",onChange:a=>G(h,a.target.value),placeholder:c("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground"})})]}),(e!==a.length-1||g!==f.length-1)&&(0,d.jsx)("div",{className:"border-b border-border/50 mt-3"})]},h)})})})]})});return(0,d.jsx)(i.ZL,{children:L})}},69606:(a,b,c)=>{"use strict";c.d(b,{A:()=>g});var d=c(48249),e=c(18921),f=c(60591);function g({preview:a,onClose:b,search:c,preRef:h}){return(0,d.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:a.filePath}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",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:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)(e._,{search:c}),(0,d.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,d.jsx)("pre",{ref:h,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,f.xb)(a.content)})})]})})}},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>ak});var e=c(48249),f=c(67484),g=c.n(f),h=c(74429),i=c(8410),j=c(44256),k=c(33281),l=c(87808),m=c(25419),n=c(85655),o=c(21538),p=c(35208),q=c(74691),r=c(60333),s=c(7833),t=c(24724),u=c(20586),v=c(7122),w=c(55287),x=c(60591),y=c(19593),z=c(64825),A=c(66400),B=c(86588),C=c(64676),D=c(6478),E=c(59865),F=c(93321),G=c(9804),H=c(73887),I=c(40893),J=c(92608),K=c(94239),L=c(29939),M=c(23860),N=c(7031),O=c(72899),P=c(25667),Q=c(57014),R=c(69606),S=c(46242),T=c(21787),U=c(94308),V=c(53036),W=c(91975),X=c(6662),Y=c(20291),Z=c(58904),$=c(61632),_=c(41357),aa=c(76855),ab=c(4857),ac=c(44384),ad=c(18921),ae=c(28797),af=c(23881),ag=c(21672),ah=c(21482),ai=c(94192),aj=a([o,P,p,H,w,Q]);[o,P,p,H,w,Q]=aj.then?(await aj)():aj;let ak=g().memo(function({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:g,searchQueryTrigger:aj,fileOpenRequest:ak}){let al,am,an,ao,ap,aq,ar,{t:as}=(0,ac.Bd)(),at=(0,N.r)(),au=(0,f.useCallback)(a=>{at?.sendMessage(as("explain.fileMessage",{path:a}))},[at,as]),av=(0,f.useCallback)(a=>{at?.sendMessage(as("explain.stagedFileMessage",{path:a}))},[at,as]),aw=(0,f.useCallback)(a=>{at?.sendMessage(as("explain.unstagedFileMessage",{path:a}))},[at,as]),ax=(0,D.P)(),ay=(0,E.U)(),az=(0,F.Q)(),{activeView:aA,onViewChange:aB}=(0,ai.R8)(),[aC,aD]=(0,f.useState)(c),[aE,aF]=(0,f.useState)("code"),aG=(0,f.useRef)(null),aH=(0,f.useRef)(!1),[aI,aJ]=(0,f.useState)(null),[aK,aL]=(0,f.useState)(null),[aM,aN]=(0,f.useState)(!1),aO=(0,f.useRef)(1),aP=(0,f.useRef)(null),[aQ,aR]=(0,f.useState)(null),aS=(0,f.useRef)(null),[aT,aU]=(0,f.useState)({isDirty:!1,isSaving:!1}),[aV,aW]=(0,f.useState)(!1),[aX,aY]=(0,f.useState)(null),[aZ,a$]=(0,f.useState)(null),[a_,a0]=(0,f.useState)("compact"),[a1,a2]=(0,f.useState)("unified"),[a3,a4]=(0,f.useState)("full"),[a5,a6]=(0,f.useState)("unified"),[a7,a8]=(0,f.useState)(320),a9=(0,f.useRef)(null),ba=(0,f.useCallback)(a=>{"mouse"===a.pointerType&&0===a.button&&(a.preventDefault(),a9.current={startX:a.clientX,startWidth:a7},a.currentTarget.setPointerCapture(a.pointerId))},[a7]),bb=(0,f.useCallback)(a=>{let b=a9.current;if(!b)return;let c=b.startWidth+(a.clientX-b.startX);a8(Math.min(480,Math.max(320,c)))},[]),bc=(0,f.useCallback)(a=>{a9.current&&(a9.current=null,a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId))},[]),bd=(0,f.useRef)(null),be=(0,ad.o)(bd),bf=(0,f.useRef)(null),bg=(0,ad.o)(bf),bh=(0,aa.Sn)(b),bi=(0,aa.Xm)(b),bj=(0,aa.po)(b),bk=(0,ab.Q)(),bl=(0,M.F)(),bm=(0,X.W)({cwd:b});(0,aa.JL)(b,bm.selectedPath);let bn=(0,f.useMemo)(()=>{let a=bm.fileContent,b=bm.selectedPath;return a&&"text"===a.type&&"string"==typeof a.content&&b&&(0,x.Hz)(b)?(0,x.xb)(a.content,x.cG):null},[bm.fileContent,bm.selectedPath]),[bo,bp]=(0,f.useState)({version:0,collapsed:!1}),bq=(0,Y.p)({cwd:b,onSearchComplete:()=>aW(!0)}),br=(0,Z.e)({cwd:b,addToRecentFiles:bm.addToRecentFiles}),bs=(0,f.useMemo)(()=>{let a=new Set;if(br.status){for(let b of br.status.staged)a.add(b.path);for(let b of br.status.unstaged)a.add(b.path)}return a},[br.status]),bt=(0,f.useMemo)(()=>{let a=new Map;if(br.status){for(let b of br.status.staged)a.set(b.path,"staged");for(let b of br.status.unstaged)a.set(b.path,"unstaged")}return a},[br.status]),bu=(0,$.y)({cwd:b,addToRecentFiles:bm.addToRecentFiles}),bv=bu.compareFileDiff,bw=bv?.filePath??"",bx=(0,f.useMemo)(()=>{if(!bv||bv.isDeleted)return;let a={content:bv.newContent,filePath:bv.filePath};return(0,x.e$)(bv.filePath)?()=>a$(a):bv.filePath.endsWith(".json")?()=>aY(a):void 0},[bv]),by=(0,f.useCallback)(()=>a$(null),[]),bz=(0,f.useCallback)(()=>aY(null),[]),bA=(0,f.useMemo)(()=>{let a=0,b=0;for(let c of bu.compareFiles)a+=c.additions,b+=c.deletions;return{additions:a,deletions:b}},[bu.compareFiles]),bB=(0,f.useCallback)(a=>{at?.sendMessage(as("worktree"===bu.compareDiffMode?"explain.compareFileWorktreeMessage":"explain.compareFileMessage",{base:bu.compareBaseBranch,path:a}))},[at,as,bu.compareBaseBranch,bu.compareDiffMode]),bC=(0,f.useRef)(!1),bD=(0,f.useCallback)(a=>{bm.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),bm.showEditor||(bC.current=!0,bm.setShowEditor(!0))},[bm]),bE=(0,f.useCallback)(a=>{bm.setShowEditor(!0)},[bm]),bF=(0,f.useCallback)(async()=>{if(!bm.fileContent||"text"!==bm.fileContent.type||!bm.fileContent.content)return;let a=await k.t4.runPromiseExit((0,l.OJ)({cwd:b,path:bm.selectedPath,content:bm.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&bm.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,s.oR)(as("toast.savedSuccess"),"success")}catch{(0,s.oR)(as("toast.saveFailed"),"error")}},[b,bm]),bG=(0,f.useCallback)(()=>{if(!bm.selectedPath)return;let a=aO.current,b=aP.current;a>0&&bm.updateRecentFilePosition(bm.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[bm]),bH=(0,f.useCallback)(async(a,b)=>{let c=a!==bm.selectedPath;if(c&&bm.showEditor){if(aT.isDirty&&(!await (0,s.lJ)(as("fileBrowser.saveBeforeSwitch"),{confirmText:as("fileBrowser.saveAndSwitch"),cancelText:as("common.cancel")})||(await aS.current?.save(),aS.current?.isDirty)))return;bm.setShowEditor(!1)}c&&bG(),bm.handleSelectFile(a,b)},[bm,bG,aT.isDirty,as]),bI=(0,f.useMemo)(()=>{let a=bq.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,G.v3)(c),e=new Set((0,G.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[bq.contentSearchResults]),[bJ,bK]=(0,f.useState)(new Set),bL=(0,f.useCallback)(a=>{bK(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),bM=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=bI.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[bI.matchMap]),bN=aV&&bq.contentSearchResults.length>0,[bO,bP]=(0,f.useState)("selected"),bQ=!!bm.selectedPath&&null!==(0,ae.c)(bm.selectedPath),[bR,bS]=(0,f.useState)(!1),bT=(0,f.useCallback)(async(a,c)=>{if(!bm.selectedPath||!bQ)return;let d=await bh.goToDefinition(bm.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;bk.push({filePath:bm.selectedPath,lineNumber:aO.current}),g===bm.selectedPath?bm.setTargetLineNumber(e.line):bH(g,e.line)},[bm,b,bQ,bh,bk]),bU=(0,f.useCallback)((a,b,c,d,e)=>{a&&null!==(0,ae.c)(a)&&(bS(b),bi.onTokenMouseEnter(a,c,d,e))},[bi]),bV=(0,f.useCallback)((a,b,c)=>{bQ&&bU(bm.selectedPath,!1,a,b,c)},[bm.selectedPath,bQ,bU]),bW=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;bm.selectedPath&&bk.push({filePath:bm.selectedPath,lineNumber:aO.current}),d===bm.selectedPath?bm.setTargetLineNumber(a.line):bH(d,a.line)},[bm,b,bk]),bX=(0,f.useMemo)(()=>{if(!br.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":case"untracked":return"A";case"deleted":return"D";case"renamed":return"R"}};for(let c of br.status.staged)a.set(c.path,b(c.status));for(let c of br.status.unstaged)a.set(c.path,b(c.status));return a},[br.status]),bY=(0,f.useMemo)(()=>{if(!br.status)return null;let a=new Map;for(let b of br.status.staged)"renamed"===b.status&&b.oldPath&&a.set(b.path,b.oldPath);return a},[br.status]),bZ=(0,f.useCallback)(a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)},[bq.setContentSearchQuery,bq.performContentSearch]),b$=(0,_.H)({cwd:b,selectedPath:bm.selectedPath,gitStatusMap:bX,renameOldPaths:bY,isText:bm.fileContent?.type==="text",refreshKey:bm.fileContent?.mtime}),b_="tree"===aC&&b$.showDiff,b0=(0,f.useCallback)(a=>{aD(a),bm.setBlameSelectedCommit(null),"history"===a&&bu.selectedBranch&&bu.loadCommits(bu.selectedBranch)},[bm,bu.selectedBranch,bu.loadCommits]);(0,f.useCallback)(()=>{if(!bm.selectedPath)return;let a={filePath:bm.selectedPath,lineNumber:aO.current},b=bk.goBack(a);b&&(b.filePath===bm.selectedPath?bm.setTargetLineNumber(b.lineNumber):bH(b.filePath,b.lineNumber))},[bm,bk]),(0,f.useCallback)(()=>{if(!bm.selectedPath)return;let a={filePath:bm.selectedPath,lineNumber:aO.current},b=bk.goForward(a);b&&(b.filePath===bm.selectedPath?bm.setTargetLineNumber(b.lineNumber):bH(b.filePath,b.lineNumber))},[bm,bk]);let b1=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await k.t4.runPromiseExit((0,l.__)({cwd:b,path:a}));"Success"===d._tag?(0,s.oR)(as("toast.copiedName",{name:c}),"success"):(0,s.oR)(as("toast.copyFailed"),"error")},[b,as]),b2=(0,f.useCallback)(async a=>{let c=await k.t4.runPromiseExit((0,l.dt)());if("Success"!==c._tag||!c.value.path)return void(0,s.oR)(as("toast.noFileToPaste"),"info");let d=c.value.path,e=await k.t4.runPromiseExit((0,l.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,s.oR)(as("toast.pastedFile",{name:e.value.newName}),"success"),bm.loadDirectory(a),bm.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:as("toast.pasteFailed");(0,s.oR)(c,"error")}},[b,bm,as]);(0,f.useRef)(0),(0,f.useRef)(bl),(0,f.useRef)(aC),(0,f.useRef)(!1);let b3=(0,f.useRef)(bu.selectedBranch);b3.current=bu.selectedBranch;let b4=(0,f.useRef)(bm.selectedPath);b4.current=bm.selectedPath;let b5=(0,f.useRef)(bm.fileContent?.type);b5.current=bm.fileContent?.type;let b6=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!Array.isArray(c))return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(k.t4.runPromise((0,l.mP)(b)).then(a=>{a.error||bm.setFiles(b=>(0,G.HR)(a.files??[],b))}).catch(()=>{})),f.push(k.t4.runPromise((0,l.DZ)(b)).then(a=>{a.paths&&bm.setFileIndex(a.paths)}).catch(()=>{})),f.push(k.t4.runPromise((0,l.r9)(b)).then(a=>{bm.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(k.t4.runPromise((0,n.lv)(b)).then(a=>{br.setStatus(a);let b=(0,u.Do)(a.staged),c=(0,u.Do)(a.unstaged);br.setStagedTree(b),br.setUnstagedTree(c)}).catch(()=>{})),br.refreshDiff(),bu.refreshCompare(),d&&bu.loadBranches();let a=b3.current;a&&f.push(k.t4.runPromise((0,n.Bj)(b,a,G.B_)).then(a=>{let b=a.commits??[];bu.setCommits(b),bu.setHasMoreCommits(b.length>=G.B_)}).catch(()=>{}))}let g=b4.current,h=b5.current;g&&"text"===h&&f.push(k.t4.runPromise((0,m.K)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&bm.setFileContent({type:"text",content:b.content,size:b.size,mtime:b.mtimeMs,...b.isSymlink?{isSymlink:!0,symlinkTarget:b.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,L.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:b6,enabled:bl});let b7=(0,f.useCallback)(a=>{bH(a),bm.setShouldScrollToSelected(!0),aD("tree")},[bm,bH]);(0,f.useRef)(bH),(0,f.useRef)(null);let{setPreviewMarkdown:b8,setShouldScrollToSelected:b9}=bm,ca=(0,f.useCallback)(({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,s.oR)(as("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),b7(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),[b,b7,as]),cb=(0,f.useCallback)(({focalFile:a})=>"tree"===aC&&b$.canDiff&&a===bm.selectedPath?(0,e.jsxs)(e.Fragment,{children:[b$.showDiff&&(0,e.jsx)(q.y,{value:a3,onChange:a4}),(0,e.jsx)("button",{onClick:b$.toggleDiff,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${b$.showDiff?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,title:b$.showDiff?as("fileBrowser.exitDiff"):as("fileBrowser.viewDiff"),children:as("common.diff")})]}):null,[aC,b$.canDiff,b$.showDiff,b$.toggleDiff,bm.selectedPath,a3,as]),[cc,cd]=(0,f.useState)(null),ce=(0,f.useCallback)((a,b)=>{bm.setPreviewMarkdown(!0),b7(a),cd(b),b&&setTimeout(()=>cd(null),400)},[bm,b7]);return(0,e.jsxs)(v.SU,{container:aI,children:[(0,e.jsxs)("div",{ref:aG,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 flex flex-col overflow-hidden",style:{width:a7},children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>b0("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>b0("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>b0("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>b0("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>b0("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.historyTab")})]}),"tree"===aC&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:bm.searchInputRef,type:"text",value:bm.searchQuery,onChange:a=>bm.setSearchQuery(a.target.value),placeholder:as("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),bm.searchQuery&&(0,e.jsx)("button",{onClick:()=>{bm.setSearchQuery(""),bm.searchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:as("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>bm.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${bm.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:bm.searchExactMatch?as("fileBrowser.exactMatchOn"):as("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>bm.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:as("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>bm.searchTreeExpandedPaths?bm.setSearchTreeExpandedPaths(new Set):bm.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:as("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===aC&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:bq.contentSearchInputRef,type:"text",value:bq.contentSearchQuery,onChange:a=>bq.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bq.performContentSearch(bq.contentSearchQuery)},placeholder:as("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),bq.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>{bq.setContentSearchQuery(""),bq.contentSearchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:as("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>bq.performContentSearch(bq.contentSearchQuery),disabled:bq.isSearching||!bq.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:bq.isSearching?"...":as("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bq.searchOptions.caseSensitive,onChange:a=>bq.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:as("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bq.searchOptions.wholeWord,onChange:a=>bq.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:as("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bq.searchOptions.regex,onChange:a=>bq.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:as("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:bq.searchOptions.fileType,onChange:a=>bq.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:as("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground"})]})]}),"history"===aC&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:bu.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"flex-1 min-w-0 truncate",children:bu.branches?.current||"HEAD"}),(0,e.jsx)("div",{className:"flex flex-shrink-0 items-center rounded border border-border overflow-hidden text-xs",children:["head","worktree"].map(a=>(0,e.jsx)("button",{onClick:()=>bu.setCompareDiffMode(a),className:`px-1.5 py-0.5 transition-colors ${bu.compareDiffMode===a?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:as("head"===a?"fileBrowser.compareScopeHeadHint":"fileBrowser.compareScopeWorktreeHint"),children:as("head"===a?"fileBrowser.compareScopeHead":"fileBrowser.compareScopeWorktree")},a))})]}),(0,e.jsx)("button",{onClick:()=>bu.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:as("fileBrowser.compareModeOff"),children:as("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(U.e,{branches:bu.branches,selectedBranch:bu.compareBaseBranch,onSelect:a=>{bu.setCompareBaseBranch(a),bu.loadCompareFiles(a)},isLoading:bu.isLoadingBranches,pinnedBranches:["origin/main",...bu.upstreamBranch&&"origin/main"!==bu.upstreamBranch?[bu.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(U.e,{branches:bu.branches,selectedBranch:bu.selectedBranch,onSelect:a=>{bu.setSelectedBranch(a)},isLoading:bu.isLoadingBranches,pinnedBranches:["origin/main",...bu.upstreamBranch&&"origin/main"!==bu.upstreamBranch?[bu.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>bu.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-hover border border-border",title:as("fileBrowser.compareModeOn"),children:as("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===aC?"":"hidden"}`,children:[bm.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:bm.creatingItem.parentPath?as("fileBrowser.createFileIn",{path:bm.creatingItem.parentPath}):as("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:as("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{aH.current=!0},onCompositionEnd:()=>{aH.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(aH.current)return;let c=a.target.value.trim();if(!c)return;let d=bm.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await k.t4.runPromiseExit((0,l.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,s.oR)(as("toast.createdFile",{name:c}),"success"),bm.setCreatingItem(null),bm.loadDirectory(d),bm.loadFileIndex(),d&&bm.setExpandedPaths(a=>new Set([...a,d])),bH(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,s.oR)(a||as("toast.createFailed"),"error")}else(0,s.oR)(as("toast.createFailed"),"error")}else"Escape"===a.key&&bm.setCreatingItem(null)},onBlur:()=>bm.setCreatingItem(null)})]}),bm.isLoadingFiles&&0===bm.files.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("common.loading")}):bm.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bm.fileError}):(0,e.jsx)(t.h,{files:bm.files,selectedPath:bm.selectedPath,expandedPaths:bm.effectiveExpandedPaths,matchedPaths:bm.matchedPaths,gitStatusMap:bX,loadingDirs:bm.loadingDirs,onSelect:a=>{bm.setShouldScrollToSelected(!1),bH(a)},onToggle:bm.handleToggle,cwd:b,shouldScrollToSelected:bm.shouldScrollToSelected,onScrolledToSelected:()=>bm.setShouldScrollToSelected(!1),onCreateFile:a=>bm.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>aL({path:a,isDirectory:b,name:c}),onRefresh:()=>bm.loadFiles(),onCopyFile:b1,onPaste:b2,onExplain:at?au:void 0,explainDisabled:at?.isLoading})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===aC?"":"hidden"}`,children:bq.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bq.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bq.searchError}):0===bq.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:bq.contentSearchQuery?as("fileBrowser.noContentSearchResults"):as("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[bq.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b border-border flex-shrink-0",children:[as("fileBrowser.nFilesNMatches",{files:bq.searchStats.totalFiles,matches:bq.searchStats.totalMatches}),bq.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",as("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(t.h,{files:bI.files,selectedPath:bm.selectedPath,expandedPaths:bJ,onSelect:a=>{let b=bI.matchMap.get(a);bH(a,b?.matches[0]?.lineNumber),aV||aW(!0)},onToggle:bL,cwd:b,onExplain:at?au:void 0,explainDisabled:at?.isLoading,renderActions:bM,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===aC?"":"hidden"}`,children:0===bm.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.noRecentFiles")}):(0,e.jsx)(t.h,{files:bm.recentFilesTree,selectedPath:bm.selectedPath,expandedPaths:bm.recentTreeDirPaths,onSelect:bH,onToggle:G.tE,cwd:b,onExplain:at?au:void 0,explainDisabled:at?.isLoading})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===aC?"":"hidden"}`,children:br.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):br.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:br.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:as("fileBrowser.stagingArea",{count:br.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>br.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:as("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(br.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:br.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:as("fileBrowser.unstageAll")})]}),(0,e.jsx)(u.VO,{files:br.stagedTree,selectedPath:br.statusSelectedFile?.type==="staged"?br.statusSelectedFile.file.path:null,expandedPaths:br.stagedExpandedPaths,onSelect:a=>a.file&&br.handleStatusFileSelect(a.file,"staged"),onToggle:br.handleStagedToggle,cwd:b,showChangeClass:!0,hideIndicatorsOnHover:!0,emptyMessage:as("fileBrowser.noStagedFiles"),className:"py-1",onExplain:at?av:void 0,explainDisabled:at?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,u.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),br.handleUnstageFiles(b.map(a=>a.path))},className:"hidden group-hover:block p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-colors",title:as("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),br.handleUnstage(a.path)},className:"hidden group-hover:block p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-colors",title:as("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:as("fileBrowser.workspace",{count:br.status?.unstaged.length||0})}),(br.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:br.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:as("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:br.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:as("fileBrowser.stageAll")})]})]}),(0,e.jsx)(u.VO,{files:br.unstagedTree,selectedPath:br.statusSelectedFile?.type==="unstaged"?br.statusSelectedFile.file.path:null,expandedPaths:br.unstagedExpandedPaths,onSelect:a=>a.file&&br.handleStatusFileSelect(a.file,"unstaged"),onToggle:br.handleUnstagedToggle,cwd:b,showChangeClass:!0,hideIndicatorsOnHover:!0,emptyMessage:as("fileBrowser.noUnstagedChanges"),className:"py-1",onExplain:at?aw:void 0,explainDisabled:at?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,u.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"hidden group-hover:flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),br.handleDiscardFiles(c)},className:"p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-colors",title:as("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),br.handleStageFiles(b.map(a=>a.path))},className:"p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-colors",title:as("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"hidden group-hover:flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),br.handleDiscardFile(a.file)},className:"p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-colors",title:as("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),br.handleStage(a.path)},className:"p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-colors",title:as("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===aC?"":"hidden"}`,children:bu.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:bu.historyError})]})}):bu.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:bu.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.loadingDiff")}):0===bu.compareFiles.length?(0,e.jsxs)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:[(0,e.jsx)("div",{children:as("fileBrowser.noDiffFiles")}),"head"===bu.compareDiffMode&&(0,e.jsx)("button",{onClick:()=>bu.setCompareDiffMode("worktree"),className:"mt-2 text-xs text-brand hover:underline",children:as("fileBrowser.noDiffFilesHeadHint")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:as("worktree"===bu.compareDiffMode?"fileBrowser.nFilesChangedWorktree":"fileBrowser.nFilesChanged",{count:bu.compareFiles.length,branch:bu.compareBaseBranch})}),(0,e.jsxs)("span",{className:"flex flex-shrink-0 items-center gap-1.5 text-xs tabular-nums",children:[(0,e.jsxs)("span",{className:"text-green-11",children:["+",bA.additions]}),(0,e.jsxs)("span",{className:"text-red-11",children:["-",bA.deletions]})]})]}),(0,e.jsx)(u.VO,{files:bu.compareFileTree,expandedPaths:bu.compareExpandedPaths,onToggle:bu.handleCompareToggle,selectedPath:bu.compareSelectedFile?.path||null,onSelect:a=>{a.file&&bu.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0,showChangeClass:!0,onExplain:at?bB:void 0,explainDisabled:at?.isLoading})]})}):(0,e.jsx)("div",{ref:bu.commitListRef,className:"flex-1 overflow-y-auto",onScroll:bu.handleCommitListScroll,children:bu.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.loadingCommits")}):0===bu.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[bu.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>bu.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${bu.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[a.changeClass&&(0,e.jsx)(i.N,{cls:a.changeClass}),(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-foreground-subtle","data-tooltip":a.date,children:[a.relativeDate," \xb7 ",(0,G.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),bu.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!bu.hasMoreCommits&&bu.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-foreground-subtle",children:as("fileBrowser.allLoaded",{count:bu.commits.length})})]})})})]})]}),(0,e.jsx)("div",{onPointerDown:ba,onPointerMove:bb,onPointerUp:bc,onPointerCancel:bc,className:"w-[5px] flex-shrink-0 relative cursor-col-resize group",children:(0,e.jsx)("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover:bg-brand transition-colors"})}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[("tree"===aC||"search"===aC||"recent"===aC)&&(bm.blameSelectedCommit?(0,e.jsx)(o.n,{isOpen:!0,onClose:()=>bm.setBlameSelectedCommit(null),commit:bm.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:bm.selectedPath||void 0,onLocateInTree:b7,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):"map"===aE?b_&&b$.diff?(0,e.jsx)(P.r,{cwd:b,filePath:b$.diff.filePath,oldContent:b$.diff.oldContent,newContent:b$.diff.newContent,isNew:b$.diff.isNew,isDeleted:b$.diff.isDeleted,changedFiles:bs,fileGitStatusMap:bt,compact:"compact"===a3,enableComments:!0,onSwitchToCode:()=>aF("code"),onContentSearch:bZ,headerExtraLeft:ca,headerExtraRight:cb}):(0,e.jsx)(O.O,{cwd:b,highlightedFilePath:bm.selectedPath,changedFiles:bs,onSwitchToCode:()=>aF("code"),enableComments:!0,onContentSearch:bZ,headerExtraLeft:ca,headerExtraRight:cb}):bm.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:bm.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${bm.selectedPath}`),(0,s.oR)(as("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),b7(bm.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:bm.showEditor?(0,e.jsxs)(e.Fragment,{children:[aT.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:as("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>aS.current?.save(),disabled:!aT.isDirty||aT.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aT.isDirty&&!aT.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:aT.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):as("common.save")}),(0,e.jsx)("button",{onClick:()=>aS.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.closeEdit"),children:as("fileBrowser.closeBtn")})]}):b_?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(q.y,{value:a3,onChange:a4}),(0,e.jsx)(r.q,{value:a5,onChange:a6}),!(0,x.e$)(bm.selectedPath)&&!(0,x.aR)(bm.selectedPath)&&!(0,x.Hz)(bm.selectedPath)&&!(0,x.Zy)(bm.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aF("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("blockViewer.viewerToggle.toBlock"),children:as("common.codeMap")}),(0,e.jsx)("button",{onClick:b$.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors bg-brand text-white",children:as("fileBrowser.exitDiff")})]}):(0,e.jsxs)(e.Fragment,{children:["tree"===aC&&b$.canDiff&&(0,e.jsx)("button",{onClick:b$.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.viewDiff"),children:as("common.diff")}),bm.fileContent?.type==="text"&&(0,x.e$)(bm.selectedPath)&&(0,e.jsx)(J.ShareReviewToggle,{content:bm.fileContent.content||"",sourceFile:bm.selectedPath&&b&&bm.selectedPath.startsWith(b)?bm.selectedPath.slice(b.endsWith("/")?b.length:b.length+1):bm.selectedPath||""}),bm.fileContent?.type==="text"&&(0,x.Hz)(bm.selectedPath)&&bm.previewMarkdown&&!bm.showBlame&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:[!0,!1].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bp(b=>({version:b.version+1,collapsed:a}))},className:`px-2 py-0.5 text-xs transition-colors ${bo.collapsed===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:as(a?"fileBrowser.collapseAllJson":"fileBrowser.expandAllJson")},String(a)))}),bm.fileContent?.type==="text"&&((0,x.e$)(bm.selectedPath)||(0,x.aR)(bm.selectedPath)||(0,x.Hz)(bm.selectedPath)||(0,x.Zy)(bm.selectedPath))&&(am=(al=(0,x.aR)(bm.selectedPath))?bm.previewHtml:bm.previewMarkdown,(0,e.jsx)("button",{onClick:()=>al?bm.setPreviewHtml(a=>!a):bm.setPreviewMarkdown(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${am?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:am?as("fileBrowser.exitPreview"):as("common.preview")})),bm.fileContent?.type==="text"&&((0,x.C_)(bm.selectedPath||"")||(0,x.OG)(bm.selectedPath||""))&&(ao=(an=bm.selectedPath||"").startsWith("/")?an:b?`${b.replace(/\/$/,"")}/${an}`:an,ap=(0,x.OG)(an),(0,e.jsx)("button",{onClick:()=>void(ap?az(ao):ay(ao)),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as(ap?"bots.addTooltip":"skills.addTooltip"),children:(0,e.jsx)(z.A,{className:"w-3.5 h-3.5"})})),bm.fileContent?.type==="text"&&(0,x.aR)(bm.selectedPath)&&(ar=(aq=bm.selectedPath||"").startsWith("/")?aq:b?`${b.replace(/\/$/,"")}/${aq}`:aq,(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>ax(ar),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as("htmlApps.addTooltip"),children:(0,e.jsx)(z.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:ar}})),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as("common.openInConsole"),children:(0,e.jsx)(A.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>{let a=(0,C.Xe)(ar);window.open((0,C.PB)(a,window.location.origin),"_blank")},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as("browser.openInNewWindow"),children:(0,e.jsx)(B.A,{className:"w-3.5 h-3.5"})})]})),bm.fileContent?.type==="text"&&!(bm.previewMarkdown&&((0,x.e$)(bm.selectedPath)||(0,x.Hz)(bm.selectedPath)||(0,x.Zy)(bm.selectedPath))||bm.previewHtml&&(0,x.aR)(bm.selectedPath))&&(0,e.jsx)("button",{onClick:bm.handleToggleBlame,disabled:bm.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bm.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-hover"} disabled:opacity-50`,title:as("fileBrowser.viewBlame"),children:bm.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),bm.fileContent?.type==="text"&&!(bm.previewMarkdown&&((0,x.e$)(bm.selectedPath)||(0,x.Hz)(bm.selectedPath)||(0,x.Zy)(bm.selectedPath))||bm.previewHtml&&(0,x.aR)(bm.selectedPath))&&(0,e.jsx)("button",{onClick:()=>bm.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.editFile"),children:as("common.edit")}),bm.fileContent?.type==="text"&&bm.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(bm.fileContent.content),(0,s.oR)(as("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.copyFileContent"),children:as("common.copy")}),bm.fileContent?.type==="text"&&!(0,x.e$)(bm.selectedPath)&&!(0,x.aR)(bm.selectedPath)&&!(0,x.Hz)(bm.selectedPath)&&!(0,x.Zy)(bm.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aF("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("blockViewer.viewerToggle.toBlock"),children:as("common.codeMap")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:bm.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bm.fileContent?"text"===bm.fileContent.type&&"string"==typeof bm.fileContent.content?b_?b$.isLoadingDiff&&!b$.diff?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):b$.diff?"unified"===a5?(0,e.jsx)(p.xU,{oldContent:b$.diff.oldContent,newContent:b$.diff.newContent,filePath:b$.diff.filePath,cwd:b,enableComments:!0,compact:"compact"===a3,onContentSearch:bZ,onTokenHover:(a,b,c)=>bU(b$.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bi.onTokenMouseLeave,onTokenHoverCancel:bi.clearHover}):(0,e.jsx)(p.xZ,{oldContent:b$.diff.oldContent,newContent:b$.diff.newContent,filePath:b$.diff.filePath,isNew:b$.diff.isNew,isDeleted:b$.diff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===a3,onContentSearch:bZ,onTokenHover:(a,b,c)=>bU(b$.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bi.onTokenMouseLeave,onTokenHoverCancel:bi.clearHover}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{children:as("fileBrowser.diffLoadFailed")}),(0,e.jsx)("button",{onClick:b$.toggleDiff,className:"mt-2 text-brand hover:underline text-sm",children:as("fileBrowser.exitDiff")})]})}):bm.showBlame&&bm.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:bm.blameError}),(0,e.jsx)("button",{onClick:()=>bm.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:as("fileBrowser.backToPreview")})]})}):bm.showBlame&&0===bm.blameLines.length&&bm.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bm.previewMarkdown&&(0,x.Hz)(bm.selectedPath)&&!bm.showBlame?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-background text-foreground",children:[(0,e.jsx)(ad._,{search:be}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:bd,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,e.jsx)(x.d9.Provider,{value:bo,children:bn})})})]}):bm.previewMarkdown&&(0,x.Zy)(bm.selectedPath)&&!bm.showBlame?(0,e.jsx)(y.C0,{content:bm.fileContent.content,filePath:bm.selectedPath,className:"h-full"}):bm.previewMarkdown&&(0,x.e$)(bm.selectedPath)&&!bm.showBlame?(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(H.M,{content:bm.fileContent.content,filePath:bm.selectedPath,cwd:b,embedded:!0,onLocalMdLink:ce,scrollToAnchor:cc})}):bm.previewHtml&&(0,x.aR)(bm.selectedPath)&&!bm.showBlame?(0,e.jsx)(I.O,{content:bm.fileContent.content,filePath:bm.selectedPath,cwd:b,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):(0,e.jsx)(w.Cv,{ref:aS,content:bm.fileContent.content,filePath:bm.selectedPath,cwd:b,enableComments:!0,scrollToLine:aQ??bm.targetLineNumber,scrollToLineAlign:null!=aQ?"start":bm.targetScrollAlign,onScrollToLineComplete:()=>{aR(null),bm.setTargetLineNumber(null)},highlightKeyword:"search"===aC?bq.contentSearchQuery:null,visibleLineRef:aO,viStateRef:aP,initialCursorLine:bm.initialCursorLine,initialCursorCol:bm.initialCursorCol,onInitialCursorSet:()=>{bm.setInitialCursorLine(null),bm.setInitialCursorCol(null)},onCmdClick:bQ?bT:void 0,onTokenHover:bQ?bV:void 0,onTokenHoverLeave:bQ?bi.onTokenMouseLeave:void 0,onTokenHoverCancel:bQ?bi.clearHover:void 0,blameLines:bm.showBlame&&bm.blameLines.length>0?bm.blameLines:void 0,inlineBlameLines:bm.blameLines.length>0?bm.blameLines:void 0,onSelectCommit:bm.setBlameSelectedCommit,editable:bm.showEditor,initialMtime:bm.fileContent.mtime,onEditorClose:a=>{bm.setShowEditor(!1),aR(a)},onSaved:()=>{let a=aO.current??1;bm.loadFileContent(bm.selectedPath),bm.setShowEditor(!1),aR(a)},onEditorStateChange:aU,viMode:!0,onContentMutate:bD,onEnterInsertMode:bE,onViSave:bF,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):"image"===bm.fileContent.type&&bm.selectedPath?(0,e.jsx)(V.I,{cwd:b,path:bm.selectedPath,refreshKey:bm.fileContent.mtime,alt:bm.selectedPath}):"pdf"===bm.fileContent.type&&bm.selectedPath?(0,e.jsx)(W.t,{cwd:b,path:bm.selectedPath,refreshKey:bm.fileContent.mtime}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:bm.fileContent.message||as("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:as("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:as("fileBrowser.selectFileToPreview")})]})})),"status"===aC&&(br.statusSelectedFile&&br.statusDiff?(0,e.jsx)(Q.m,{cwd:b,selected:br.statusSelectedFile,diff:br.statusDiff,showMarkdownPreview:br.showStatusDiffPreview,setShowMarkdownPreview:br.setShowStatusDiffPreview,changedFiles:bs,fileGitStatusMap:bt,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)},locateInTree:b7,setJsonPreview:aY,onTokenHover:(a,b,c)=>bU(br.statusDiff?.filePath,!0,a,b,c),onTokenHoverLeave:bi.onTokenMouseLeave,onTokenHoverCancel:bi.clearHover}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:as("fileBrowser.selectFileToViewDiff")})})),"history"===aC&&!bu.historyError&&(bu.compareMode?bu.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:as("fileBrowser.loadingDiffContent")}):bu.compareFileDiff?(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border flex-shrink-0",children:[(0,e.jsx)(T.d,{cwd:b,filePath:bu.compareFileDiff.filePath,onLocateInTree:b7}),!(0,G.u)(bu.compareFileDiff.filePath)&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(q.y,{value:a_,onChange:a0}),(0,e.jsx)(r.q,{value:a1,onChange:a2})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,G.u)(bu.compareFileDiff.filePath)?(0,e.jsx)(S.M,{cwd:b,filePath:bu.compareFileDiff.filePath,oldRev:bu.compareFileDiff.oldRev??(bu.compareFileDiff.isNew?null:bu.compareBaseBranch),newRev:"worktree"===bu.compareDiffMode?null:bu.compareFileDiff.newRev??(bu.compareFileDiff.isDeleted?null:"HEAD"),newNode:bu.compareFileDiff.newWorktree?(0,e.jsx)(V.I,{cwd:b,path:bu.compareFileDiff.filePath}):void 0}):"unified"===a1?(0,e.jsx)(p.xU,{oldContent:bu.compareFileDiff.oldContent,newContent:bu.compareFileDiff.newContent,filePath:bu.compareFileDiff.filePath,cwd:b,enableComments:!0,compact:"compact"===a_,onPreview:bx,previewLabel:bw.endsWith(".json")?as("common.readable"):as("common.preview"),onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):(0,e.jsx)(p.xZ,{oldContent:bu.compareFileDiff.oldContent,newContent:bu.compareFileDiff.newContent,filePath:bu.compareFileDiff.filePath,isNew:bu.compareFileDiff.isNew,isDeleted:bu.compareFileDiff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===a_,onPreview:bx,previewLabel:bw.endsWith(".json")?as("common.readable"):as("common.preview"),onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}})}),aZ&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>a$(null),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(H.M,{content:aZ.content,filePath:aZ.filePath,cwd:b,onClose:by})})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:bu.compareFiles.length>0?as("fileBrowser.selectFileToViewDiff"):as("fileBrowser.clickCompareToLoad")})}):bu.selectedCommit?(0,e.jsx)(o.n,{isOpen:!0,onClose:()=>bu.setSelectedCommit(null),commit:bu.selectedCommit,cwd:b,embedded:!0,onLocateInTree:b7,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:as("fileBrowser.selectCommitToView")})})),aX&&(0,e.jsx)(R.A,{preview:aX,onClose:bz,search:bg,preRef:bf})]})]}),aM&&(0,e.jsx)(K.c,{files:bm.files,fileIndex:bm.fileIndex,recentFiles:bm.recentFilePaths,onSelectFile:a=>{bH(a),bm.setShouldScrollToSelected(!0),aD("tree")},onClose:()=>aN(!1)}),(bN||bj.visible)&&(0,e.jsxs)("div",{className:`flex ${bj.visible&&bN?"":"flex-col"}`,children:[bN&&(0,e.jsx)("div",{className:bj.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(ah.D,{results:bq.contentSearchResults,loading:bq.isSearching,totalMatches:bq.searchStats?.totalMatches??0,onSelect:(a,b)=>{bm.selectedPath&&bk.push({filePath:bm.selectedPath,lineNumber:aO.current}),aF("code"),bH(a,b)},onClose:()=>aW(!1),scope:bO,onScopeChange:bP,selectedPath:bm.selectedPath})}),bj.visible&&(0,e.jsx)("div",{className:bN?"flex-1 min-w-0":"",children:(0,e.jsx)(ag.D,{references:bj.references,loading:bj.loading,onSelect:bW,onClose:bj.closeReferences})})]})]}),aK&&(0,e.jsx)(j.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim",onClick:()=>aL(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:as("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:as("fileBrowser.confirmDeleteMessage",{name:aK.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>aL(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-hover transition-colors",children:as("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=aK;aL(null);let d=await k.t4.runPromiseExit((0,l.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,s.oR)(as("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";bm.loadDirectory(b),bm.loadFileIndex(),bm.selectedPath===a&&bH("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:as("toast.deleteFailed");(0,s.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:as("common.delete")})]})]})})}),bi.hoverInfo&&aI&&(0,h.createPortal)((0,e.jsx)(af.s,{ref:bi.setTooltipEl,displayString:bi.hoverInfo.displayString,documentation:bi.hoverInfo.documentation,x:bi.hoverInfo.x,y:bi.hoverInfo.y,container:aI,onMouseEnter:bi.onCardMouseEnter,onMouseLeave:bi.onCardMouseLeave,onFindReferences:bR?void 0:()=>{let{filePath:a,line:b,column:c}=bi.hoverInfo;bi.clearHover(),bj.findReferences(a,b,c)},onSearch:a=>{bi.clearHover(),aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)},onExplain:at?a=>{let{filePath:b,line:c}=bi.hoverInfo;bi.clearHover(),at.sendMessage(as("explain.symbolMessage",{name:a,path:b,lines:String(c)}))}:void 0,explainDisabled:at?.isLoading}),aI)]})});d()}catch(a){d(a)}})},70440:(a,b,c)=>{"use strict";function d(){return[{type:"image/x-icon",sizes:"16x16",url:"/favicon.ico?a49a3c8f7b751288"}]}c.r(b),c.d(b,{default:()=>d})},70596:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:h,onClose:i,onUpdateComment:j,onDeleteComment:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(c.content),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=async()=>{o.trim()&&(await j(c.id,o.trim()),n(!1))},u=async()=>{await k(c.id),i()};return(0,d.jsx)("div",{ref:q,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:r.x,top:r.y},children:(0,d.jsx)("div",{className:"p-3",children:m?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),t()),"Escape"===a.key&&(n(!1),p(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{n(!1),p(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:l("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:l("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>n(!0),className:"p-1 rounded hover:bg-hover text-muted-foreground",title:l("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{onClick:u,className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-red-9",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})})})}},71192:(a,b,c)=>{"use strict";c.d(b,{m_:()=>f,uV:()=>e});var d=c(81218);class e extends d.rN("AppError"){}d.rN("DBError"),d.rN("WSError"),d.rN("FSError"),d.rN("AgentError"),d.rN("ValidationError");class f extends d.rN("NotFoundError"){}d.rN("PermissionError")},71697:(a,b,c)=>{"use strict";c.d(b,{V:()=>k,n:()=>j});var d=c(48249),e=c(67484),f=c(44384);c(59336);var g=c(15332);c(81608);var h=c(33281),i=c(41224);function j({value:a,onChange:b,textareaRef:c,extraCommands:d}){let[f,k]=(0,e.useState)(a.length),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)(0),[t,u]=(0,e.useState)(()=>a.length>0),v=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a=await h.t4.runPromiseExit((0,i.l1)());if("Success"===a._tag){let b=a.value.skills??a.value;o((Array.isArray(b)?b:[]).filter(a=>a.valid&&!!a.name).map(a=>({name:`/${a.name}`,description:a.description||"",source:"skill",skillPath:a.path,argumentHint:a.argumentHint})))}else console.error("Failed to load skills:",a.cause)},[]),(0,e.useCallback)(async()=>{let a=await h.t4.runPromiseExit((0,g.jm)());"Success"===a._tag?q(a.value.flatMap(a=>a.valid?[{name:`@${a.name}`,description:a.description,source:"bot"}]:[])):console.error("Failed to load bots:",a.cause)},[]);let w=(0,e.useMemo)(()=>{let b=0===f?0:a.lastIndexOf("\n",f-1)+1,c=a.indexOf("\n",f),d=-1===c?a.length:c;return{text:a.slice(b,d),start:b,end:d}},[a,f]),x=(0,e.useMemo)(()=>{let a=w.text.match(/^\s*(\/@|\/|@)([a-zA-Z0-9-]*)$/);return a?{marker:a[1],verb:a[2].toLowerCase()}:null},[w.text]),y=(0,e.useMemo)(()=>{if(!x)return[];let{verb:a}=x,b=b=>b.name.slice(1).toLowerCase().startsWith(a);return"@"===x.marker?p.filter(b):[...(d??[]).filter(b),...l.filter(b),...n.filter(b)]},[x,d,l,n,p]),z=!t&&!!x&&y.length>0;(0,e.useRef)(a);let A=(0,e.useCallback)(a=>{k(a.selectionStart??0)},[]),B=(0,e.useCallback)(d=>{let e=x?.marker??"/",f=`${e}${d.name.slice(1)} `,g=a.slice(0,w.start),h=a.slice(w.end),i=g.length+f.length;b(g+f+h),k(i),requestAnimationFrame(()=>{let a=c.current;a&&(a.focus(),a.setSelectionRange(i,i))})},[a,w,x,b,c]),C=(0,e.useCallback)(a=>{if(a.nativeEvent.isComposing||!z||0===y.length)return!1;let b=()=>{a.preventDefault(),a.stopPropagation()};return"ArrowDown"===a.key?(b(),s(a=>(a+1)%y.length),!0):"ArrowUp"===a.key?(b(),s(a=>(a-1+y.length)%y.length),!0):"Enter"===a.key||"Tab"===a.key?(b(),B(y[r]),!0):"Escape"===a.key&&(b(),u(!0),!0)},[z,y,r,B]);return{isOpen:z,items:y,selectedIndex:r,marker:x?.marker??"/",listRef:v,selectCommand:B,handleKeyDown:C,trackCaret:A}}function k({ac:a,className:b=""}){let{t:c}=(0,f.Bd)(),{isOpen:e,items:g,selectedIndex:h,marker:i,listRef:j,selectCommand:l}=a;return e&&0!==g.length?(0,d.jsx)("div",{ref:j,className:`overflow-y-auto bg-card border border-border rounded-lg shadow-lv2 ${b}`,children:g.map((a,b)=>{let e=b>0?g[b-1]:null,f="skill"===a.source&&(!e||"skill"!==e.source),j="bot"===a.source&&(!e||"bot"!==e.source),k="builtin"===a.source&&0===b;return(0,d.jsxs)("div",{children:[k&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),f&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),j&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Bots"}),(0,d.jsxs)("div",{onClick:()=>l(a),className:`px-4 py-2 cursor-pointer ${b===h?"bg-brand/10":"hover:bg-hover"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:i+a.name.slice(1)}),(0,d.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:"builtin"===a.source?c(`commands.${a.name.slice(1)}`,{defaultValue:a.description}):a.description}),(0,d.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11";case"bot":return"bg-teal-9/15 text-teal-11 dark:bg-teal-9/25 dark:text-teal-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return c("common.builtin");case"skill":return"Skill";case"bot":return"Bot"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,d.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}):null}},72399:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectSidebar.tsx","ProjectSidebar")},72529:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(48249),e=c(67484);function f({content:a,children:b,className:c}){if(c)return(0,d.jsx)("div",{"data-tooltip":a,className:c,children:b});let g=e.Children.toArray(b);if(1===g.length&&(0,e.isValidElement)(g[0])){let b=g[0];return(0,e.cloneElement)(b,{"data-tooltip":a})}return(0,d.jsx)("div",{"data-tooltip":a,style:{display:"contents"},children:b})}},72899:(a,b,c)=>{"use strict";c.d(b,{O:()=>ab});var d=c(48249),e=c(67484),f=c(44384),g=c(10316),h=c(46674),i=c(80600),j=c(69924);c(33281),c(85655),c(87808);var k=c(33982),l=c(34622),m=c(34948),n=c(26875),o=c(87148),p=c(82633);function q({kind:a,qname:b,className:c}){let e=`${(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)(i.A,{className:e});if("__preamble__"===b)return(0,d.jsx)(k.A,{className:e});if(b&&b.startsWith("__heading_"))return(0,d.jsx)(l.A,{className:e});switch(a){case"function":case"method":return(0,d.jsx)(m.A,{className:e});case"class":return(0,d.jsx)(n.A,{className:e});case"interface":return(0,d.jsx)(o.A,{className:e});default:return(0,d.jsx)(p.A,{className:e})}}var r=c(85984),s=c(29939);function t({cwd:a}){let{t:b}=(0,f.Bd)(),[c,g]=(0,e.useState)(null),h=(0,e.useCallback)(b=>{b?.type==="graphProgress"&&b.data&&b.data.cwd===a&&g(b.data)},[a]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(a)}`,onMessage:h});let i=(0,e.useRef)("");if(c?.currentFile&&(i.current=c.currentFile),!c)return(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:b("blockViewer.fileMode.loading","Loading…")});let j=b(`blockViewer.buildProgress.${c.phase}`,u[c.phase]),k=Math.max(0,Math.min(100,Math.round(c.percent)));return(0,d.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-8",children:(0,d.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-baseline justify-between text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:j}),(0,d.jsx)("span",{className:"tabular-nums",children:"parsing"===c.phase&&c.filesTotal>0?`${c.filesDone} / ${c.filesTotal}`:`${k}%`})]}),(0,d.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:(0,d.jsx)("div",{className:"h-full rounded-full bg-primary transition-[width] duration-150 ease-linear",style:{width:`${k}%`}})}),(0,d.jsx)("div",{className:"h-4 truncate text-left font-mono text-[11px] leading-4 text-muted-foreground/70",dir:"rtl",title:"done"===c.phase?"":i.current,children:"done"===c.phase?"":i.current})]})})}let u={listing:"Listing files…",contexts:"Reading project config…",parsing:"Parsing files",resolving:"Resolving imports…",edges:"Building call graph…",done:"Finishing up…"};var v=c(7031),w=c(74754),x=c(91579),y=c(83768),z=c(36984),A=c(72529);function B({entries:a,onSelect:b,onClear:c}){let{t:e}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"function-history-drawer",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,d.jsx)("div",{className:"flex items-center text-xs text-muted-foreground font-mono min-w-0",children:(0,d.jsx)("span",{className:"truncate",children:0===a.length?e("blockViewer.history.title"):`${e("blockViewer.history.title")} \xb7 ${a.length}/15`})}),a.length>0&&(0,d.jsx)(A.m,{content:e("blockViewer.history.clear"),children:(0,d.jsx)("button",{onClick:c,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,d.jsx)(h.A,{className:"w-3 h-3"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===a.length?(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:e("blockViewer.history.empty")}):a.map((a,c)=>{var e;let f;return(0,d.jsx)(A.m,{content:`${a.qname} \xb7 ${a.filePath}`,children:(0,d.jsxs)("button",{onClick:()=>b(a),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:transition-colors group flex items-start gap-1.5",children:[(0,d.jsx)(q,{kind:a.kind??"unknown",qname:a.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:a.name}),(0,d.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(f=(e=a.filePath).lastIndexOf("/"))>=0?e.slice(f+1):e,a.kind&&(0,d.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",a.kind]})]})]})]})},`${a.filePath}::${a.qname}::${c}`)})})]})}function C(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}var D=c(65543);function E({functions:a,counts:b,totalLines:c,currentQname:g,onSelect:h,notIndexed:i,onRebuild:j}){let{t:k}=(0,f.Bd)(),l=(0,e.useMemo)(()=>a.filter(D._),[a]);return(0,d.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"file-toc-section",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:[k("blockViewer.toc.title"),l.length>0&&` \xb7 ${l.length}`,null!=c&&` \xb7 ${c} ${k("common.lines")}`]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===l.length?i?(0,d.jsxs)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/80 leading-relaxed flex flex-col gap-2",children:[(0,d.jsx)("span",{className:"italic",children:k("blockViewer.toc.notIndexed")}),j&&(0,d.jsx)("button",{type:"button",onClick:j,className:"self-start px-2 py-1 rounded border border-border bg-secondary/60 hover:bg-secondary text-[10px] text-foreground transition-colors",children:k("blockViewer.refresh")})]}):(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:k("blockViewer.toc.empty")}):l.map(a=>{let c=g===a.qualifiedName,e=b?.get(a.qualifiedName),f=e?[e.in>0&&["in",e.in,"text-amber-11/80"],e.out>0&&["out",e.out,"text-green-11/80"],e.self>0&&["self",e.self,"text-muted-foreground/60"]].filter(Boolean):[];return(0,d.jsx)(A.m,{content:`${a.qualifiedName} \xb7 L${a.startLine}`,children:(0,d.jsxs)("button",{onClick:()=>h(a.qualifiedName,a.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-start gap-1.5 min-w-0 ${c?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,d.jsx)(q,{kind:a.kind,qname:a.qualifiedName,className:"w-3 h-3 flex-shrink-0 mt-0.5"}),(0,d.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`flex-1 min-w-0 text-xs font-mono truncate ${c?"font-semibold text-brand":""}`,children:a.name}),(0,d.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground/50 tabular-nums",children:a.endLine-a.startLine+1})]}),f.length>0&&(0,d.jsx)("span",{className:"block text-[10px] font-mono truncate",children:f.map(([a,b,c],e)=>(0,d.jsxs)("span",{className:c,children:[e>0&&(0,d.jsx)("span",{className:"text-muted-foreground/30",children:" \xb7 "}),a," ",b]},a))})]})]})},a.qualifiedName)})})]})}var F=c(37690),G=c(22341);function H({comments:a,startLine:b,endLine:c,lineHeight:e,bodyTopOffset:f,rowOf:g,onCommentClick:h}){let i=new Map;for(let d of a){if(d.endLine<b||d.endLine>c)continue;let a=i.get(d.endLine);a?a.push(d):i.set(d.endLine,[d])}return 0===i.size?null:(0,d.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(i.entries()).map(([a,c])=>{let i=g?g(a):a-b,j=c[0],k=c.length-1;return(0,d.jsx)(A.m,{content:1===c.length?j.content:`${c.length} comments — click to view`,children:(0,d.jsxs)("button",{onClick:a=>h(j,a),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-lv1 transition-colors",style:{top:`${f+i*e+e/2-8}px`},children:[(0,d.jsx)(G.A,{className:"w-2.5 h-2.5"}),k>0&&(0,d.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:k+1})]})},a)})})}function I(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function J({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:f}){let g,h=(0,e.useRef)(null),i=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),j=(0,e.useMemo)(()=>{if(i.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=i.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,i]);if(i.total<=0)return null;let k=(a,b)=>{let c=I(i,a),d=I(i,b);return null===c||null===d?null:{top:c/i.total*100,heightPct:(d-c+1)/i.total*100}};return(0,d.jsxs)("div",{ref:h,onClick:a=>{let b=h.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(i,(a.clientY-c.top)/c.height*i.total);if(!d)return;let e=d.line,g=j.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void f(g.qname,e);if(j.length>0){let a=Math.max(2,Math.round(.05*i.total)),b=I(i,e);if(null!==b){let c=null,d=1/0;for(let a of j){let e=I(i,a.start),f=I(i,a.end);if(null===e||null===f)continue;let g=b<e?e-b:b>f?b-f:0;g<d&&(c=a,d=g)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;f(c.qname,a);return}}}let k=i.blocks.find(a=>a.qname===d.qname);k&&f(k.qname,k.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[j.map(a=>{let b=k(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((g=k(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${g.top}%`,height:`${Math.max(1.2,g.heightPct)}%`}}):null)]})}var K=c(73414),L=c(41051),M=c(42140),N=c(70596);function O(a){let b=a.lastIndexOf("/");return b>=0?a.slice(b+1):a}function P(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let Q="flex-shrink-0 h-4 leading-4 px-1.5 rounded text-[10px] text-brand hover:bg-brand/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent";function R({symbol:a,fileSource:b,hasChange:c,onHighlighted:g,comments:h,onCommentClick:i,addedLines:j,upstream:k,downstream:l,fold:m,onExpandGap:n}){let{resolvedTheme:o}=(0,y.DP)(),{t:p}=(0,f.Bd)(),r=(0,v.r)(),s=(k?.length??0)+(l?.length??0)>0;(0,e.useMemo)(()=>(0,z.sQ)(a.filePath),[a.filePath]);let[t,u]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),A=(0,e.useMemo)(()=>{if(!t)return null;let b=b=>{let c=t[b-a.startLine]??"",d=j?.has(b)?" bg-green-9/15":"";return`<div class="flex${d}" style="min-width:max-content" data-line="${b}"><span class="select-none pr-3 text-muted-foreground/60 tabular-nums" style="min-width:3.2rem;text-align:right">${b}</span><span class="whitespace-pre">${c}</span></div>`};return m?m.segments.map(a=>{if("gap"===a.kind){var c;let b,d,e;return c=a.startLine,d=P(p("diffViewer.gap.hidden",{count:b=a.endLine-c+1})),e=P(p("diffViewer.gap.expandAll",{count:b})),`<div class="flex items-center cursor-pointer select-none hover:bg-hover" style="min-width:max-content;height:${U}px" data-fold-gap="${c}" title="${e}"><span class="select-none pr-3 text-muted-foreground/40" style="min-width:3.2rem;text-align:right">⋯</span><span class="text-[10px] text-muted-foreground/60 whitespace-pre">${d}</span></div>`}let d="";for(let c=a.startLine;c<=a.endLine;c++)d+=b(c);return d}).join(""):t.map((c,d)=>b(a.startLine+d)).join("")},[t,m,j,a.startLine,p]),B=(0,e.useCallback)(b=>{if(!n)return;let c=b.target,d=c?.closest?.("[data-fold-gap]");if(!d)return;let e=Number(d.getAttribute("data-fold-gap"));Number.isFinite(e)&&n(a.qualifiedName,e)},[n,a.qualifiedName]);return(0,d.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,d.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border text-xs",children:[(0,d.jsx)(q,{kind:a.kind,qname:a.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),!a.qualifiedName.startsWith("__code_")&&(0,d.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,d.jsx)("span",{className:"font-medium",children:a.name}),void 0!==a.params&&(0,d.jsxs)("span",{className:"text-muted-foreground/80",children:["(",a.params.join(", "),")"]})]}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:["unknown"!==a.kind&&`${a.kind} \xb7 `,a.endLine-a.startLine+1," ",p("common.lines")]}),r&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>r.sendMessage(p("explain.symbolMessage",{name:a.name,path:a.filePath,lines:`${a.startLine}-${a.endLine}`})),disabled:r.isLoading,title:r.isLoading?p("comments.aiResponding"):void 0,className:Q,children:p("explain.action")}),s&&(0,d.jsx)("button",{onClick:()=>r.sendMessage(p("deps.symbolMessage",{name:a.name,path:a.filePath,lines:`${a.startLine}-${a.endLine}`,...function(a,b,c){let d=a=>{switch(a.kind){case"cross":case"self":return`${a.external.name} (${a.external.filePath})`;case"method":return`${a.receiverName}.${a.methodName}()`;case"ext":return null}},e=a=>{let b=a.map(d).filter(a=>null!==a);return b.length?b.join(", "):c},f=new Map;for(let a of b){if("ext"!==a.kind)continue;let b=f.get(a.packageSpec);b?b.push(a.name):f.set(a.packageSpec,[a.name])}let g=[...f].map(([a,b])=>`${a} (${b.join(", ")})`);return{callers:e(a),callees:e(b),externals:g.length?g.join("; "):c}}(k??[],l??[],p("deps.none"))})),disabled:r.isLoading,title:r.isLoading?p("comments.aiResponding"):void 0,className:Q,children:p("deps.action")})]}),(0,d.jsx)("span",{className:"flex-1"}),c&&(0,d.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,d.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${U}px`},onClick:B,children:[!b&&(0,d.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),w&&(0,d.jsx)("span",{className:"text-red-11",children:w}),A&&(0,d.jsx)("div",{dangerouslySetInnerHTML:{__html:A}})]}),h&&h.length>0&&i&&(0,d.jsx)(H,{comments:h,startLine:a.startLine,endLine:a.endLine,lineHeight:U,bodyTopOffset:V+W,rowOf:m?.rowOf,onCommentClick:i})]})}function S({side:a,pin:b,accent:c,onClick:e}){let f,g,h,i,j,k,l,m=b.lines.length;"ext"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="ext",h="text-muted-foreground/60",i=b.name,j=b.packageSpec,k="external",l=b.packageSpec):"method"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="method",h="text-muted-foreground/60",i=`${b.receiverName}.${b.methodName}`,j=null,k="method (unresolved)",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):"self"===b.kind?(f="bg-secondary/40 border-border hover:border-muted-foreground",g="self",h="text-muted-foreground/70",i=b.external.name,j=null,k="same-file",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):(f="in"===a?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",g=a,h="in"===a?"text-amber-11":"text-green-11",i=b.external.name,j=O(b.external.filePath),k="in"===a?"caller":"callee",l=b.external.filePath);let n=c&&"ext"!==b.kind&&"method"!==b.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),e()},className:`${f}${n} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors block`,"data-tooltip":`${k} \xb7 ${i}${l?" \xb7 "+l:""}`,children:(0,d.jsxs)("span",{className:"block h-[26px] leading-[13px] overflow-hidden",children:[(0,d.jsx)("span",{className:`${h} float-left mr-1.5 text-[9px] uppercase tracking-wider font-semibold`,children:g}),(j||m>1)&&(0,d.jsxs)("span",{className:"float-right clear-both ml-1.5 max-w-[60%] truncate text-muted-foreground/70",children:[j,m>1&&(0,d.jsxs)("span",{className:"text-muted-foreground/60",children:[j?" ":"","\xb7",m,"\xd7"]})]}),(0,d.jsx)("span",{className:"font-medium break-all",children:i})]})})}let T="w-44 @min-[900px]:w-52 @min-[1100px]:w-60 @min-[1400px]:w-72 @min-[1800px]:w-80 @min-[2400px]:w-96",U=18,V=29,W=8;function X(a,b){switch(b.kind){case"cross":return`${a}:x:${b.external.filePath}::${b.external.qualifiedName}`;case"self":return`${a}:s:${b.external.filePath}::${b.external.qualifiedName}`;case"ext":return`${a}:e:${b.packageSpec}::${b.name}`;case"method":return`${a}:m:${b.receiverName}::${b.methodName}`}}function Y(a,b){return"ext"!==a.kind&&"method"!==a.kind&&(b?.has(a.external.qualifiedName)??!1)}function Z(a){return{filePath:a.filePath,qname:a.qualifiedName,name:a.name,kind:a.kind}}function $({symbol:a,fileSource:b,hasChange:c,upstream:e,downstream:f,onPinClick:g,onHighlighted:h,comments:i,onCommentClick:j,accentQnames:k,addedLines:l,fold:m,onExpandGap:n}){let o=function(a,b,c){if(0===a.length)return[];let d=a.map((a,c)=>{var d,e;return{i:c,line:(d=a.lines[0]??b.startLine,e=b.startLine,Math.max(e,Math.min(b.endLine,d)))}});d.sort((a,b)=>a.line-b.line||a.i-b.i);let e=Array(a.length).fill(0),f=-1/0;for(let{i:a,line:g}of d){let d=Math.max(V+W+(c?c.rowOf(g):g-b.startLine)*U,f);e[a]=d,f=d+34}return e}(f,a,m);return(0,d.jsxs)("div",{"data-block-qname":a.qualifiedName,"data-start-line":a.startLine,"data-end-line":a.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,d.jsx)("div",{className:`${T} flex-shrink-0 flex flex-col gap-1 pt-1`,children:0===e.length?(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):e.map(b=>(0,d.jsx)(S,{side:"in",pin:b,accent:Y(b,k),onClick:()=>g(b,a)},X("in",b)))}),(0,d.jsx)(R,{symbol:a,fileSource:b,hasChange:c,onHighlighted:h,comments:i,onCommentClick:j,addedLines:l,upstream:e,downstream:f,fold:m,onExpandGap:n}),(0,d.jsx)("div",{className:`${T} flex-shrink-0 relative`,children:0===f.length?(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):f.map((b,c)=>(0,d.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${o[c]}px`},children:(0,d.jsx)(S,{side:"out",pin:b,accent:Y(b,k),onClick:()=>g(b,a)})},X("out",b)))})]})}function _({cwd:a,onSelect:b,onClose:c}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)({files:[],symbols:[]}),[n,o]=(0,e.useState)(0),[p,q]=(0,e.useState)(!1),r=(0,e.useMemo)(()=>[...l.files,...l.symbols],[l]),s=(0,e.useCallback)(a=>{if("Escape"===a.key)return void c();if(0!==r.length){if("ArrowDown"===a.key)a.preventDefault(),o(a=>Math.min(a+1,r.length-1));else if("ArrowUp"===a.key)a.preventDefault(),o(a=>Math.max(a-1,0));else if("Enter"===a.key){a.preventDefault();let c=r[n];c&&b(c)}}},[r,n,c,b]);return(0,d.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:c,children:(0,d.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-lv3 overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,d.jsx)(g.A,{className:"w-4 h-4 text-muted-foreground"}),(0,d.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),onKeyDown:s,placeholder:i("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),p&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,d.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground",children:(0,d.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===r.length&&j&&!p&&(0,d.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("blockViewer.search.noResults","No matches")}),(0,d.jsx)(aa,{label:i("blockViewer.search.files","Files"),hits:l.files,startIdx:0,activeIdx:n,onSelect:b,setActive:o}),(0,d.jsx)(aa,{label:i("blockViewer.search.symbols","Symbols"),hits:l.symbols,startIdx:l.files.length,activeIdx:n,onSelect:b,setActive:o})]})]})})}function aa({label:a,hits:b,startIdx:c,activeIdx:e,onSelect:f,setActive:g}){return 0===b.length?null:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:a}),b.map((a,b)=>{let h=c+b,j=h===e;return(0,d.jsxs)("button",{onMouseEnter:()=>g(h),onClick:()=>f(a),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${j?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===a.type?(0,d.jsx)(i.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,d.jsx)(q,{kind:a.target.kind,qname:a.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,d.jsx)("span",{className:"font-mono truncate",children:a.label}),a.hint&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:a.hint})]})]},`${a.type}:${a.label}:${b}`)})]})}function ab({cwd:a,highlightedFilePath:b,changedFiles:c,onSwitchToCode:g,enableComments:h=!1,onContentSearch:i,onFocalChange:j,qnameFilter:k,qnameFilterFile:l,accentQnames:m,accentFile:n,addedLines:o,addedLinesFile:p,compact:q=!1,headerExtraLeft:s,headerExtraRight:u}){let{t:y}=(0,f.Bd)(),[z,A]=(0,e.useState)("toc"),[D,G]=(0,e.useState)(null),H=D??b??null,{state:I,refresh:P}=(0,r.V)(a,H),[Q,R]=(0,e.useState)(null),S=(0,e.useMemo)(()=>Q?Q.content.split("\n").length:null,[Q]);(0,e.useRef)(null);let[U,V]=(0,e.useState)([]),[W,X]=(0,e.useState)(!1),[Y,aa]=(0,e.useState)(null),ae=(0,e.useRef)(0);(0,e.useRef)(0);let[af,ag]=(0,e.useState)(()=>new Set);"ready"===I.state&&I.data.filePath;let ah=(0,e.useCallback)(a=>{ag(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c})},[]),ai=(0,e.useCallback)((a,b)=>{if("ext"===a.kind||"method"===a.kind){let a=b.filePath;if(!a)return;ae.current+=1,aa({filePath:a,qname:"__imports__",nonce:ae.current});return}let c=Z(b),d=Z(a.external);V(a=>C(C(a,c),d)),G(d.filePath),ae.current+=1,aa({filePath:d.filePath,qname:d.qname,nonce:ae.current})},[]),aj=(0,e.useCallback)(a=>{G(a.filePath),ae.current+=1,aa({filePath:a.filePath,qname:a.qname,nonce:ae.current})},[]),ak=(0,e.useCallback)(a=>{X(!1),G(a.target.filePath),"symbol"===a.type&&(ae.current+=1,aa({filePath:a.target.filePath,qname:a.target.qualifiedName,line:a.target.startLine,nonce:ae.current}))},[]),al=(0,e.useCallback)((a,b)=>{H&&(ae.current+=1,aa({filePath:H,qname:a,line:b,nonce:ae.current}))},[H]),[am,an]=(0,e.useState)(()=>new Set),ao=(0,e.useCallback)((a,b)=>{an(c=>{let d=new Set(c);return d.add(`${H}#${a}#${b}`),d})},[H]),[ap,aq]=(0,e.useState)(null),[ar,as]=(0,e.useState)(null),at=(0,e.useMemo)(()=>{if("ready"!==I.state||!ar)return null;let a=I.data.functions;if(0===a.length)return null;let b=(ar.start+ar.end)/2;for(let c of a)if(c.startLine<=b&&b<=c.endLine)return c.qualifiedName;let c=null;for(let b of a)b.startLine<=ar.start&&(!c||b.startLine>c.startLine)&&(c=b);return c?.qualifiedName??null},[I,ar]),au=h&&!!a&&!!H,av=(0,v.r)(),{comments:aw,addComment:ax,updateComment:ay,deleteComment:az,refresh:aA}=(0,w._)({cwd:a,filePath:H??""}),[aB,aC]=(0,e.useState)(null),{toolbarRef:aD,bumpRef:aE,clearToolbar:aF}=(0,F.L)({enabled:au,container:aB,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-line]");if(!c||!aB||!aB.contains(c))return null;let d=c.getAttribute("data-line");if(!d)return null;let e=parseInt(d,10);return Number.isFinite(e)?{start:e,end:e}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Q?.content;return c?c.split("\n").slice(a-1,b).join("\n"):""}}),[aG,aH]=(0,e.useState)(null),[aI,aJ]=(0,e.useState)(null),[aK,aL]=(0,e.useState)(null),aM=(0,e.useCallback)(()=>{let a=aD.current;a&&(aH({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aF())},[aF,aD]),aN=(0,e.useCallback)(()=>{let a=aD.current;a&&(aJ({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aF())},[aF,aD]),aO=(0,e.useCallback)(()=>{let a=aD.current;a&&av&&H&&(aF(),(0,x.Ff)(av.sendMessage,{filePath:H,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},y("explain.selectionMessage")))},[av,H,aF,aD,y]),aP=(0,e.useCallback)(()=>{let a=aD.current;if(!a||!i)return;let b=a.selectedText.trim();aF(),b&&i(b)},[i,aF,aD]),aQ=(0,e.useCallback)(async a=>{aG&&(await ax(aG.range.start,aG.range.end,a,aG.selectedText),aH(null))},[aG,ax]),aR=(0,e.useCallback)(async(b,c)=>{if(av&&a&&H)try{let d=(await (0,x.$3)(a)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));d.push({filePath:H,startLine:b.range.start,endLine:b.range.end,codeContent:b.lineSnapshot});let e=(0,x.Gw)(d,c);av.sendMessage(e),await (0,x.RP)(a),aA()}catch(a){console.error("[BlockViewer] send to AI failed:",a)}},[av,a,H,aA]),aS=(0,e.useCallback)(a=>{aI&&aR(aI,a)},[aI,aR]),aT=(0,e.useCallback)(a=>{aG&&aR(aG,a)},[aG,aR]),aU=(0,e.useCallback)((a,b)=>{b.stopPropagation(),aL({comment:a,x:b.clientX,y:b.clientY}),aF(),aH(null),aJ(null)},[aF]);if(!H)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:null,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,refreshDisabled:!0,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,d.jsx)("span",{children:y("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,d.jsx)("span",{className:"text-xs",children:y("blockViewer.empty.hint","or press ⌘K to search.")})]}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]});if("idle"===I.state||"loading"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,refreshDisabled:!0,extraLeft:s,extraRight:u}),(0,d.jsx)(t,{cwd:a})]});if("notFound"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:y("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]});if("error"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,d.jsx)("span",{className:"text-red-11",children:I.message}),(0,d.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:y("blockViewer.retry","Retry")})]})]});let aV=I.data,aW=aV.functions;if(0===aW.length&&Q){let a=Math.max(1,S??1);aW=[{filePath:aV.filePath,qualifiedName:"__file__",name:O(aV.filePath),kind:"unknown",startLine:1,endLine:a}]}let aX=l&&l===aV.filePath,aY=n&&n===aV.filePath,aZ=p&&p===aV.filePath;aX&&k&&(aW=aW.filter(a=>k.has(a.qualifiedName)));let a$=aY?m:void 0,a_=aZ?o:void 0,a0=new Map;if(q&&a_)for(let a of aW)a0.set(a.qualifiedName,function(a,b,c,d,e=K.aj){if(b<a)return null;let f=[];for(let d of c)d>=a&&d<=b&&f.push(d);f.sort((a,b)=>a-b);let g=[];for(let c of f){let d=Math.max(a,c-e),f=Math.min(b,c+e),h=g[g.length-1];h&&d<=h.endLine+1?f>h.endLine&&(h.endLine=f):g.push({startLine:d,endLine:f})}let h=[],i=a;for(let a of g)a.startLine>i&&h.push({startLine:i,endLine:a.startLine-1}),i=a.endLine+1;i<=b&&h.push({startLine:i,endLine:b});let j=[],k=[];for(let a of h)a.endLine-a.startLine+1<2||d(a.startLine)?k.push(a):j.push(a);if(0===j.length)return null;g=function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[];for(let a of b){let b=c[c.length-1];b&&a.startLine<=b.endLine+1?a.endLine>b.endLine&&(b.endLine=a.endLine):c.push({...a})}return c}([...g,...k]);let l=[];for(let a of[...g.map(a=>({kind:"lines",...a})),...j.map(a=>({kind:"gap",...a}))].sort((a,b)=>a.startLine-b.startLine))l.push(a);let m=[],n=0;for(let a of l)m.push(n),n+="gap"===a.kind?1:a.endLine-a.startLine+1;let o=n;return{segments:l,visibleRuns:g,hiddenCount:j.reduce((a,b)=>a+(b.endLine-b.startLine+1),0),rowOf:b=>{for(let a=0;a<l.length;a++){let c=l[a];if(b<c.startLine)break;if(b<=c.endLine)return"gap"===c.kind?m[a]:m[a]+(b-c.startLine)}return b<a?0:Math.max(0,o-1)}}}(a.startLine,a.endLine,a_,b=>am.has(`${aV.filePath}#${a.qualifiedName}#${b}`)));let a1=ac(aV.upstreamCalls),a2=ac(aV.downstreamCalls),a3=new Map(aW.map(a=>[a.qualifiedName,a])),a4=new Map,a5=new Map;for(let a of aV.intraCalls){let b=a3.get(a.to),c=a3.get(a.from);if(b){let c=a4.get(a.from),d={kind:"self",external:b,lines:a.lines};c?c.push(d):a4.set(a.from,[d])}if(c){let b=a5.get(a.to),d={kind:"self",external:c,lines:a.lines};b?b.push(d):a5.set(a.to,[d])}}let a6=new Map;for(let a of aV.externalCalls??[]){let b=a6.get(a.focalQname),c={kind:"ext",name:a.external.name,packageSpec:a.external.packageSpec,lines:a.lines};b?b.push(c):a6.set(a.focalQname,[c])}let a7=new Map;for(let a of aV.methodCalls??[]){let b=a7.get(a.focalQname),c={kind:"method",receiverName:a.receiverName,methodName:a.methodName,lines:a.lines};b?b.push(c):a7.set(a.focalQname,[c])}let a8=new Map;for(let a of aW){let b=a.qualifiedName,c={in:a1.get(b)?.length??0,out:a2.get(b)?.length??0,self:(a5.get(b)?.length??0)+(a4.get(b)?.length??0)};(c.in||c.out||c.self)&&a8.set(b,c)}let a9=c.has(aV.filePath);return(0,d.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:aV.fileCount,functionCount:aV.functions.length,upstreamCount:aV.upstreamCalls.length,downstreamCount:aV.downstreamCalls.length,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{ref:aC,className:"@container flex-1 relative min-h-0 flex",children:[(0,d.jsxs)("div",{className:`${T} flex-shrink-0 border-r border-border flex flex-col`,children:[(0,d.jsx)("div",{className:"flex-shrink-0 flex border-b border-border",children:[["toc",y("blockViewer.tabs.toc")],["history",y("blockViewer.tabs.history")]].map(([a,b])=>(0,d.jsx)("button",{onClick:()=>A(a),className:`flex-1 px-2 py-1.5 text-xs font-medium transition-colors ${z===a?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground"}`,children:b},a))}),(0,d.jsx)("div",{className:"toc"===z?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(E,{functions:aW,counts:a8,totalLines:S,currentQname:at,onSelect:al,notIndexed:aV.notIndexed,onRebuild:P})}),(0,d.jsx)("div",{className:"history"===z?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(B,{entries:U,onSelect:aj,onClear:()=>V([])})})]}),(0,d.jsx)("div",{ref:aq,className:"@container flex-1 min-w-0 overflow-auto",children:(0,d.jsx)("div",{className:"flex flex-col gap-3 p-3",children:aW.map(a=>{let b,c,e,f,g,h;return(0,d.jsx)($,{symbol:a,fileSource:Q?.content??null,hasChange:a9,upstream:(b=a1.get(a.qualifiedName),c=a5.get(a.qualifiedName),[...(b??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...c??[]]),downstream:(e=a2.get(a.qualifiedName),f=a4.get(a.qualifiedName),g=a7.get(a.qualifiedName),h=a6.get(a.qualifiedName),[...(e??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...f??[],...g??[],...h??[]]),onPinClick:ai,onHighlighted:ah,comments:au?aw:void 0,onCommentClick:au?aU:void 0,accentQnames:a$,addedLines:a_,fold:a0.get(a.qualifiedName),onExpandGap:ao},`${a.qualifiedName}#${a.startLine}`)})})}),au&&aB&&(0,d.jsx)(L.fS,{floatingToolbarRef:aD,bumpRef:aE,container:aB,onAddComment:aM,onSendToAI:aN,onSearch:i?aP:void 0,onExplain:av&&H?aO:void 0,isChatLoading:av?.isLoading}),au&&aG&&(0,d.jsx)(M.t,{x:aG.x,y:aG.y,range:aG.range,filePath:H??void 0,lineSnapshot:aG.lineSnapshot,container:aB,onSubmit:aQ,onSendToAI:av&&H?aT:void 0,onClose:()=>aH(null),isChatLoading:av?.isLoading}),au&&aI&&H&&(0,d.jsx)(M.G,{x:aI.x,y:aI.y,range:aI.range,filePath:H,lineSnapshot:aI.lineSnapshot,container:aB,onSubmit:aS,onClose:()=>aJ(null),isChatLoading:av?.isLoading}),au&&aK&&(0,d.jsx)(N.t,{x:aK.x,y:aK.y,comment:aK.comment,container:aB,onClose:()=>aL(null),onUpdateComment:ay,onDeleteComment:az}),a_&&a_.size>0&&aW.length>0&&(0,d.jsx)(J,{addedLines:a_,blockRanges:aW.flatMap(a=>{let b=a0.get(a.qualifiedName);return b?b.visibleRuns.map(b=>({qname:a.qualifiedName,startLine:b.startLine,endLine:b.endLine})):[{qname:a.qualifiedName,startLine:a.startLine,endLine:a.endLine}]}),viewportRange:ar,onJumpToLine:al}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]})]})}function ac(a){let b=new Map;for(let c of a){let a=b.get(c.focalQname);if(!a){b.set(c.focalQname,[c]);continue}a.some(a=>a.external.filePath===c.external.filePath&&a.external.qualifiedName===c.external.qualifiedName)||a.push(c)}return b}function ad({focalFile:a,fileCount:b,functionCount:c,upstreamCount:e,downstreamCount:h,onSwitchToCode:i,onSearch:k,onRefresh:l,refreshDisabled:m,extraLeft:n,extraRight:o}){let{t:p}=(0,f.Bd)(),q={focalFile:a,blockCount:c??0,upstreamCount:e??0,downstreamCount:h??0};return(0,d.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,d.jsx)("span",{className:"truncate min-w-0",children:a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-foreground",children:a}),"number"==typeof c&&(0,d.jsxs)("span",{className:"ml-2",children:["\xb7 ",c," blocks"]}),"number"==typeof e&&"number"==typeof h&&(0,d.jsxs)("span",{className:"ml-2",children:["\xb7 ",e," in \xb7 ",h," out"]})]}):(0,d.jsx)("span",{children:null!==b?`${b} files`:"…"})}),n&&(0,d.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:n(q)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o&&(0,d.jsx)("span",{className:"flex items-center gap-1",children:o(q)}),(0,d.jsxs)("button",{onClick:k,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":p("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,d.jsx)(g.A,{className:"w-3 h-3"})," ⌘K"]}),(0,d.jsx)("button",{onClick:l,disabled:m,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":p("blockViewer.refresh","Rebuild project graph"),children:(0,d.jsx)(j.A,{className:"w-3 h-3"})}),i&&(0,d.jsx)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:p("common.code","Code")})]})]})}},73414:(a,b,c)=>{"use strict";c.d(b,{YO:()=>e,aj:()=>d,pU:()=>f});let d=3,e=20;function f(a,b,c,g=[]){let h=a.length,i=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,j=new Set;for(let a=0;a<h;a++){if(!i(a))continue;let b=Math.max(0,a-d),c=Math.min(h-1,a+d);for(let a=b;a<=c;a++)j.add(a)}let k=[];for(let a=0;a<h;a++){if(j.has(a))continue;let b=a;for(;a<h&&!j.has(a);)a++;k.push({id:k.length,startIdx:b,endIdx:a-1}),a--}for(let a of k){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)j.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)j.add(b)}let l=[];for(let a=0;a<h;a++){let c;if(j.has(a)){l.push({kind:"diff",idx:a});continue}let d=a;for(;a<h&&!j.has(a);)a++;let f=a-1;a--;let i=k.find(a=>a.startIdx<=d&&f<=a.endIdx);if(!i)continue;let m=f-d+1,n=Math.min(e,m);if(g.length>0&&f+1<h)for(let a=f+1;a<h;a++){let d=b[a].lineNum;if(!(d<=0)){c=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(g,d)??void 0;break}}l.push({kind:"gap-expand",gapId:i.id,direction:"up",revealCount:n}),l.push({kind:"gap-label",gapId:i.id,hiddenCount:m,enclosingFn:c}),l.push({kind:"gap-expand",gapId:i.id,direction:"down",revealCount:n})}return{rows:l,gaps:k}}},73887:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>B});var e=c(48249),f=c(67484),g=c(44384),h=c(64825),i=c(74429),j=c(7122),k=c(7833),l=c(41051),m=c(42140),n=c(70596),o=c(74754),p=c(7031),q=c(91579),r=c(208),s=c(5900),t=c(64676),u=c(84835);c(15466);var v=c(60591),w=c(59865),x=c(93321),y=c(24680),z=c(92608),A=c(37690);let a=[u.W];function B({content:b,filePath:c,cwd:d,onClose:u,sourceFile:C,embedded:D=!1,onLocalMdLink:E,scrollToAnchor:F}){let G=C||(d&&c.startsWith(d)?c.slice(d.endsWith("/")?d.length:d.length+1):c),{t:H}=(0,g.Bd)(),I=(0,j.iN)(),J=(0,p.r)(),K=(0,w.U)(),L=(0,x.Q)(),{comments:M,addComment:N,updateComment:O,deleteComment:P,refresh:Q}=(0,o._)({cwd:d,filePath:c}),[R,S]=(0,f.useState)(!1),[T,U]=(0,f.useState)(null),[V,W]=(0,f.useState)(null),[X,Y]=(0,f.useState)(null),Z=(0,f.useMemo)(()=>b.split("\n"),[b]),$=(0,f.useMemo)(()=>(0,t.J4)(c,d),[c,d]),[_,aa]=(0,f.useState)(null),ab=(0,f.useRef)(null),ac=(0,f.useRef)({onLocalMdLink:E,sourceFile:G});ac.current={onLocalMdLink:E,sourceFile:G};let ad=(0,f.useRef)(a=>{let{onLocalMdLink:b,sourceFile:c}=ac.current;if(!b||/^[a-z][a-z0-9+.-]*:/i.test(a))return!1;let d=a.indexOf("#"),e=d>=0?a.slice(0,d):a,f=d>=0?a.slice(d+1):null;if(!e)return!1;let g=e;try{g=decodeURIComponent(e)}catch{}return!!(0,v.e$)(g)&&(b((0,v.WU)(c,g),f),!0)}).current,{toolbarRef:ae,bumpRef:af,clearToolbar:ag}=(0,A.L)({enabled:!0,container:_,resolveLineRange:a=>{let b=function(a){let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a;if(!b||!("closest"in b))return null;let c=b.closest("[data-source-start]");if(!c)return null;let d=c.getAttribute("data-source-start"),e=c.getAttribute("data-source-end");return d&&e?{start:parseInt(d,10),end:parseInt(e,10)}:null}(a);return b?{start:b.start,end:b.end}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Math.max(0,a-1),d=Math.min(Z.length,b);return Z.slice(c,d).join("\n")}}),ah=(0,f.useCallback)(()=>{let a=ae.current;a&&(U({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ag())},[ag,ae]),ai=(0,f.useCallback)(()=>{let a=ae.current;a&&(W({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ag())},[ag,ae]),aj=(0,f.useCallback)(()=>{let a=ae.current;a&&J&&(ag(),(0,q.Ff)(J.sendMessage,{filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},r.A.t("explain.selectionMessage")))},[J,c,ag,ae]),ak=(0,f.useCallback)(async a=>{T&&(await N(T.range.start,T.range.end,a,T.selectedText),U(null))},[T,N]),al=(0,f.useCallback)(async(a,b)=>{if(J)try{let e=await (0,q.$3)(d),f=[];for(let a of e)f.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});f.push({filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot});let g=(0,q.Gw)(f,b);J.sendMessage(g),await (0,q.RP)(d),Q()}catch(a){console.error("Failed to send to AI:",a)}},[J,c,d,Q]),am=(0,f.useCallback)(a=>{V&&al(V,a)},[V,al]),an=(0,f.useCallback)(a=>{T&&al(T,a)},[T,al]);(0,f.useMemo)(()=>{if(0===M.length)return[];let a=new Map;for(let b of M){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[M]);let[ao,ap]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[!D&&(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-brand transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":c,onClick:()=>{navigator.clipboard.writeText(c),(0,k.oR)(H("common.copiedPath"))},children:["‎",c]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(z.ShareReviewToggle,{content:b,sourceFile:G}),((0,v.C_)(c)||(0,v.OG)(c))&&(0,e.jsx)("button",{onClick:()=>{let a=c.startsWith("/")||!d?c:`${d.replace(/\/$/,"")}/${c}`;(0,v.OG)(c)?L(a):K(a)},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:H((0,v.OG)(c)?"bots.addTooltip":"skills.addTooltip"),children:(0,e.jsx)(h.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:u,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:H("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)(y.l,{content:b,containerRef:ab}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:ab,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(s.T,{content:b,basePath:$,rehypePlugins:a,onLinkClick:ad})}),ao.map(({key:a,top:b,comments:c})=>(0,e.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),Y({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-lv1 hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),R&&I&&(0,i.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.fS,{floatingToolbarRef:ae,bumpRef:af,container:I,onAddComment:ah,onSendToAI:ai,onExplain:J?aj:void 0,isChatLoading:J?.isLoading}),T&&(0,e.jsx)(m.t,{x:T.x,y:T.y,range:T.range,filePath:c,lineSnapshot:T.lineSnapshot,container:I,onSubmit:ak,onSendToAI:J?an:void 0,onClose:()=>U(null),isChatLoading:J?.isLoading}),V&&(0,e.jsx)(m.G,{x:V.x,y:V.y,range:V.range,filePath:c,lineSnapshot:V.lineSnapshot,container:I,onSubmit:am,onClose:()=>W(null),isChatLoading:J?.isLoading}),X&&(0,e.jsx)(n.t,{x:X.x,y:X.y,comment:X.comment,container:I,onClose:()=>Y(null),onUpdateComment:O,onDeleteComment:P})]}),I)]})}d()}catch(a){d(a)}})},74228:(a,b,c)=>{"use strict";c.d(b,{S:()=>g,l:()=>h});var d=c(48249),e=c(40311),f=c(41233);function g(a){return"loading"===a||"unread"===a?a:"normal"}function h({projectNumber:a,sessionNumber:b,coordinate:c,status:g="normal",statusLabel:i,bot:j,className:k=""}){if(c){let[d,e]=c.split(".");a??=d,b??=e}if(null==a&&null==b&&"normal"!==g&&(b="\xb7"),null==a&&null==b)return null;let l=[a,b].filter(a=>null!=a).join(".");return(0,d.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[9px] font-medium leading-none tabular-nums flex-shrink-0 ${k}`,"aria-label":i?`${l} \xb7 ${i}`:l,children:[null!=a&&(0,d.jsx)("span",{className:`flex h-4 w-4 items-center justify-center border rounded-[4px] ${(0,e.ci)("normal",!1)}`,children:a}),null!=b&&(0,d.jsx)(f.w,{wash:(0,e.JQ)(g,!1),ring:(0,e.QV)(g),bot:j,title:i,children:b})]})}},74542:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},74691:(a,b,c)=>{"use strict";c.d(b,{y:()=>f});var d=c(48249),e=c(44384);function f({value:a,onChange:b,className:c}){let{t:g}=(0,e.Bd)();return(0,d.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${c??""}`,children:["compact","full"].map(c=>(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),b(c)},className:`px-2 py-0.5 text-xs transition-colors ${a===c?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:g("compact"===c?"diffViewer.compact":"diffViewer.full")},c))})}},74754:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});var d=c(67484);c(91579);var e=c(33281),f=c(89800);function g({cwd:a,filePath:b}){let[c,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(!1),[k,l]=(0,d.useState)(null),m=(0,d.useCallback)(async()=>{if(!a||!b)return;j(!0),l(null);let c=await e.t4.runPromiseExit((0,f.lb)(a,b));if("Success"===c._tag)h(c.value.comments??[]);else{let a="Fail"===c.cause._tag?c.cause.error:null,b=a?.cause;l(b instanceof Error?b.message:"Failed to load comments")}j(!1)},[a,b]),n=(0,d.useCallback)(async(c,d,g,i)=>{let j=await e.t4.runPromiseExit((0,f.BC)({cwd:a,filePath:b,startLine:c,endLine:d,content:g,...i?{selectedText:i}:{}}));if("Success"===j._tag&&j.value.comment){let a=j.value.comment;return h(b=>[...b,a]),a}return"Failure"===j._tag&&console.error("Failed to add comment:",j.cause),null},[a,b]),o=(0,d.useCallback)(async(b,c)=>{let d=await e.t4.runPromiseExit((0,f.vv)(a,b,c));if("Success"===d._tag&&d.value.comment){let a=d.value.comment;return h(c=>c.map(c=>c.id===b?a:c)),!0}return"Failure"===d._tag&&console.error("Failed to update comment:",d.cause),!1},[a]),p=(0,d.useCallback)(async b=>{let c=await e.t4.runPromiseExit((0,f.Tu)(a,b));return"Success"===c._tag?(h(a=>a.filter(a=>a.id!==b)),!0):(console.error("Failed to delete comment:",c.cause),!1)},[a]),q=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:i,error:k,addComment:n,updateComment:o,deleteComment:p,refresh:m,getCommentsForLine:q}}},74837:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteToolbar() from the server but NoteToolbar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteToolbar.tsx","NoteToolbar")},74991:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{I:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(29588),i=c(7833),j=c(15819);c(33281);var k=c(13054),l=c(30458),m=c(36688),n=c(32753),o=c(74228),p=c(15790);c(41224);var q=a([p,m]);function r(a){return a.engine||"claude"}function s(a){return a.lastFiredAt??a.createdAt}[p,m]=q.then?(await q)():q;let u=[{key:"pendingReview",labelKey:"scheduledTasks.groupPendingReview"},{key:"upcoming",labelKey:"scheduledTasks.groupUpcoming"},{key:"paused",labelKey:"scheduledTasks.paused"}];function t({collapsed:a,tasks:b,unreadCount:c,sessionNumbers:d,onSwitchProject:q,onPause:v,onResume:w,onTrigger:x,onDelete:y,onMarkRead:z,onUpdateTask:A}){let{t:B}=(0,g.Bd)(),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(null),G=(0,f.useRef)(null),H=(0,f.useRef)(null),[I,J]=(0,f.useState)(null),K=(0,f.useCallback)(()=>{F(null),G.current=null,J(null)},[]),[L,M]=(0,f.useState)(null),[N,O]=(0,f.useState)(null),[P,Q]=(0,f.useState)(null),[R,S]=(0,f.useState)(null),T=b.filter(a=>!a.completed),U=T.filter(a=>!a.paused).length,V=(0,f.useMemo)(()=>(function(a){let b=[],c=[],d=[];for(let e of a)e.unread||e.completed?b.push(e):e.paused?d.push(e):c.push(e);return b.sort((a,b)=>Number(!!b.unread)-Number(!!a.unread)||s(b)-s(a)),c.sort((a,b)=>(a.nextFireTime||Number.MAX_SAFE_INTEGER)-(b.nextFireTime||Number.MAX_SAFE_INTEGER)),d.sort((a,b)=>s(b)-s(a)),{pendingReview:b,upcoming:c,paused:d}})(b),[b]),W=P?b.find(a=>a.id===P)??null:null,[,X]=(0,f.useState)(0),Y=(0,f.useCallback)(()=>{M(null),O(null)},[]),Z=(0,f.useCallback)(async a=>{let b=!!a.taskFile;try{await navigator.clipboard.writeText(b?a.taskFile:a.message),(0,i.oR)(B(b?"common.copiedPath":"toast.copiedMessage"),"success")}catch{(0,i.oR)(B("common.copyFailed"),"error")}},[B]),$=(0,f.useCallback)(()=>{D(!1),Q(null)},[]),_=(0,f.useCallback)(a=>{q(a.cwd,a.sessionId),a.unread&&z(a.id),$()},[q,z,$]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{onClick:()=>D(!0),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${a?"w-full justify-center":"w-full"}`,title:a?B("scheduledTasks.title"):void 0,children:[(0,e.jsx)(h.A,{className:"w-5 h-5 flex-shrink-0"}),!a&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:B("scheduledTasks.title")}),c>0?(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 bg-orange-11/15 text-orange-11 text-xs font-medium rounded-full flex items-center justify-center ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,e.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-popover border border-border",children:b.length}):null]}),C&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:$}),(0,e.jsxs)("div",{className:j.aO,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-3 min-w-0",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:B("scheduledTasks.title")}),T.length>0&&(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[B("scheduledTasks.activeCount",{running:U}),T.length-U>0?` \xb7 ${B("scheduledTasks.pausedCount",{paused:T.length-U})}`:""]})]}),(0,e.jsx)("button",{onClick:$,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 flex min-h-0",children:0===b.length?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:B("scheduledTasks.noScheduledTasks")})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-full md:w-[360px] min-h-0 flex-shrink-0 md:border-r border-border overflow-y-auto",children:(0,e.jsx)("div",{className:"p-3 space-y-4",children:u.map(({key:a,labelKey:b})=>{let c=V[a];return 0===c.length?null:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"sticky top-0 z-10 -mx-3 px-3 py-1 bg-card text-[11px] font-medium text-muted-foreground",children:[B(b)," (",c.length,")"]}),(0,e.jsx)("div",{className:"mt-1 space-y-2",children:c.map(a=>{let b,c;return b=a.id===P,(0,e.jsxs)("div",{onClick:()=>Q(a.id),onMouseLeave:()=>S(b=>b===a.id?null:b),className:`group p-3 rounded border cursor-pointer transition-all hover:border-brand hover:shadow-lv2 ${b?"border-brand bg-brand/5 shadow-lv2":a.unread?"border-brand/40 bg-brand/5":"border-border"} ${a.completed?"opacity-70":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)(n.S,{engine:r(a),tooltip:(c=r(a),a.model?`${c} \xb7 ${a.model}`:c)}),(0,e.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":a.cwd,children:(0,k.P_)(a.cwd)}),(0,e.jsx)(o.l,{coordinate:d?.[`${a.cwd}
730
+ `;function f(a){return/^([/\\]|[A-Za-z]:)/.test(a)}function g(a){return f(a)||(0,d.P)(a)}function h(a,b){let c=a.replace(/[/\\]+$/,"");return b?`${c}/${b}`:c}function i(a,b){let c,d=(c=Math.max(a.lastIndexOf("/"),a.lastIndexOf("\\")))<0?"":0===c?"/":a.slice(0,c);return g(a)?d:b?h(b,d):d}function j(a,b){return g(a)||!!b}let k="/apps/local/",l="/apps/builtin/";function m(a,b){let c=a.trim();return k+n(g(c)?c:h(b??"",c)).replace(/\\/g,"/").split("/").map(encodeURIComponent).join("/").replace(/^\//,"")}function n(a){let b=/^[A-Za-z]:/.exec(a)?.[0]??"",c=b?a.slice(b.length):a,d=/^[/\\]/.test(c),e=[];for(let a of c.split(/[/\\]/))if(a&&"."!==a){if(".."===a){e.length&&".."!==e[e.length-1]?e.pop():d||b||e.push("..");continue}e.push(a)}return b+(d||b?"/":"")+e.join("/")}let o=/^([a-z][a-z0-9+.-]*:|\/\/|\/)/i;function p(a,b,c){let d=a.trim();if(!d||o.test(d)||!j(b,c))return a;let e=f(b)?b:h(c,b),g=d.search(/[?#]/),i=g<0?d:d.slice(0,g),k=g<0?"":d.slice(g);if(!i)return a;let l=i;try{l=decodeURIComponent(i)}catch{}return m(n(h(e,l)))+k}let q=[{chip:"*.md",exts:["md"]},{chip:"*.png/jpg/gif/webp/svg",exts:["png","jpg","jpeg","gif","webp","svg"]},{chip:"*.pdf",exts:["pdf"]},{chip:"*.json",exts:["json"]},{chip:"*.csv",exts:["csv"]},{chip:"*.tsv",exts:["tsv"]}],r=RegExp(`\\.(${q.flatMap(a=>a.exts).join("|")})$`,"i"),s=q.map(a=>a.chip);function t(a){return r.test(a.trim())}function u(a,b){let c=a.trim();return l+"file-viewer/index.html?file="+encodeURIComponent(n(g(c)?c:h(b??"",c)).replace(/\\/g,"/"))}function v(a,b){try{let c=new URL(a,b);if(!c.pathname.startsWith(l)&&!c.pathname.startsWith(k))return a;return"localhost"===c.hostname&&(c.hostname="127.0.0.1"),c.toString()}catch{return a}}function w(a,b){let c=a=>JSON.stringify(a).replace(/</g,"\\u003c"),d="<script>"+e.replaceAll("__CWD__",c(b.cwd)).replaceAll("__WS_URL__",c(b.wsUrl??""))+"<\/script>",f=a.match(/<head[^>]*>/i);if(f&&void 0!==f.index){let b=f.index+f[0].length;return a.slice(0,b)+d+a.slice(b)}let g=a.match(/<html[^>]*>/i);if(g&&void 0!==g.index){let b=g.index+g[0].length;return a.slice(0,b)+d+a.slice(b)}return d+a}},65139:(a,b,c)=>{"use strict";c.d(b,{BV:()=>i,NR:()=>u,Yd:()=>x,kn:()=>j,oJ:()=>p});var d=c(48249),e=c(67484),f=c(44256),g=c(63565),h=c(92545);let i="claude-opus-5-5",j="gpt-6.1-sol",k=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultracode",label:"Ultracode"},{id:"ultrathink",label:"Ultrathink"}],l=[{id:"claude-sonnet-5-5",label:"Claude Sonnet 5.5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"medium"},{id:"claude-sonnet-5",label:"Claude Sonnet 5",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"high"},{id:"claude-opus-5-5",label:"Claude Opus 5.5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"medium",fast:!0},{id:"claude-opus-5",label:"Claude Opus 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",fast:!0},{id:"claude-fable-5-1",label:"Claude Fable 5.1",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high"},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",thinking:!0}],m=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"Extra High"},{id:"max",label:"Max"},{id:"ultra",label:"Ultra"}],n=[{id:"gpt-6-astra",label:"GPT-6-Astra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"},{id:"gpt-6.1-sol",label:"GPT-6.1-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"},{id:"gpt-6-sol",label:"GPT-6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-6-luna",label:"GPT-6-Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"},{id:"gpt-5.6-sol",label:"GPT-5.6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"}];function o(a){return n.find(b=>b.id===a)?.defaultReasoning??"low"}function p(a,b){let c=n.find(b=>b.id===a)?.reasoning;return b&&(!c||c.includes(b))?b:o(a)}function q(a,b){return a.find(a=>a.id===b)?.label??b}function r(a){return l.find(b=>b.id===a)?.fast===!0}function s(a){return l.find(b=>b.id===a)?.thinking===!0}function t(a){let b=l.find(b=>b.id===a);return b?b.defaultEffort:"high"}function u(a,b){let c=l.find(b=>b.id===a),d=c?.effort;return b&&(!c||d?.includes(b))?b:t(a)}function v({value:a,selected:b,label:c,defaultValue:e,onSelect:f}){return(0,d.jsxs)("button",{type:"button",onClick:()=>f(a),className:`flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition-colors ${b?g.yI:"text-muted-foreground hover:bg-hover hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"mt-0.5",children:(0,d.jsx)(g.hG,{selected:b})}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c}),(0,d.jsx)("span",{className:"shrink-0",children:e&&(0,d.jsx)("span",{className:"rounded bg-muted px-1.5 text-[10px] font-medium text-muted-foreground",children:"Default"})})]})}function w({title:a,selected:b,value:c,items:h,onSelect:i,icon:j,testId:k}){let l=(0,e.useRef)(null),m=(0,e.useRef)(null),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)({top:0,left:0}),r=(0,f.F2)();return(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(g.XY,{buttonRef:l,label:c,labelMaxWidth:"max-w-[180px]",title:`${a}: ${c}`,onClick:()=>{n||(()=>{let a=l.current?.getBoundingClientRect();if(!a)return;let b=r?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;q({top:a.bottom+4-d,left:a.left-c})})(),o(a=>!a)},icon:j,testId:k}),n&&(0,d.jsx)(f.ZL,{children:(0,d.jsxs)("div",{ref:m,className:`${g.ys} min-w-[190px]`,style:{top:p.top,left:p.left},children:[(0,d.jsx)("div",{className:"px-3 pb-1 text-[11px] font-medium text-muted-foreground",children:a}),(0,d.jsx)("div",{className:"flex flex-col",children:h.map(a=>(0,d.jsx)(v,{value:a.id,selected:b===a.id,label:a.label,defaultValue:a.defaultValue,onSelect:a=>{i(a),o(!1)}},a.id))})]})})]})}function x(a){let b,c,e,f=a.engine??"claude",v=a.claudeModel??i,x=t(v),y=(b=l.find(a=>a.id===v)?.effort)?b.map(a=>k.find(b=>b.id===a)??{id:a,label:a}):[],z=u(v,a.claudeEffort),A=a.claudeFastMode??!1,B=a.claudeThinking??!1,C=a.codexModel??j,D=o(C),E=(c=n.find(a=>a.id===C)?.reasoning)?c.map(a=>m.find(b=>b.id===a)??{id:a,label:a}):m,F=p(C,a.codexReasoningEffort);return"claude"!==f?(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(w,{title:"Model",selected:C,value:n.find(a=>a.id===C)?.label??(0,h.U)(C),items:n.map(a=>({id:a.id,label:a.label,defaultValue:a.id===j})),onSelect:b=>{a.onCodexModelChange?.(b),a.onCodexReasoningEffortChange?.(o(b))},icon:(0,d.jsx)(g.eV,{engine:"codex"}),testId:"codex-model-picker"}),(0,d.jsx)(w,{title:"Reasoning",selected:F,value:q(m,F),items:E.map(a=>({...a,defaultValue:a.id===D})),onSelect:b=>a.onCodexReasoningEffortChange?.(b),testId:"codex-reasoning-picker"})]}):(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(w,{title:"Model",selected:v,value:(e=l.find(a=>a.id===v))?e.label:v.startsWith("claude-")?`Claude ${(0,h.J)(v)}`:v,items:l.map(a=>({id:a.id,label:a.label,defaultValue:a.id===i})),onSelect:b=>{a.onClaudeModelChange?.(b);let c=t(b);c&&a.onClaudeEffortChange?.(c),r(b)||a.onClaudeFastModeChange?.(!1),s(b)||a.onClaudeThinkingChange?.(!1)},icon:(0,d.jsx)(g.eV,{engine:"claude"}),testId:"claude-model-picker"}),z&&y.length>0&&(0,d.jsx)(w,{title:"Reasoning",selected:z,value:q(k,z),items:y.map(a=>({...a,defaultValue:a.id===x})),onSelect:b=>a.onClaudeEffortChange?.(b),testId:"claude-reasoning-picker"}),r(v)&&(0,d.jsx)(w,{title:"Fast Mode",selected:A?"on":"off",value:A?"Fast On":"Fast Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:b=>a.onClaudeFastModeChange?.("on"===b),testId:"claude-fast-mode-picker"}),s(v)&&(0,d.jsx)(w,{title:"Thinking",selected:B?"on":"off",value:B?"Thinking On":"Thinking Off",items:[{id:"on",label:"On"},{id:"off",label:"Off",defaultValue:!0}],onSelect:b=>a.onClaudeThinkingChange?.("on"===b),testId:"claude-thinking-picker"})]})}},65395:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>e});var d=c(77943);(0,d.registerClientReference)(function(){throw Error("Attempted to call reconcileStatusTabIds() from the server but reconcileStatusTabIds is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","reconcileStatusTabIds"),(0,d.registerClientReference)(function(){throw Error("Attempted to call repairPanes() from the server but repairPanes is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","repairPanes");let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,fz:()=>s,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b,c)=>d.$mh({try:async()=>{let d=l(a),e=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:b,baseMtime:c})});if(409===e.status){let a=await e.json();return{conflict:!0,content:a.content??"",mtime:a.mtime}}if(!e.ok)throw Error(`HTTP ${e.status}`);return{conflict:!1,mtime:(await e.json()).mtime}},catch:b=>new e.uV({message:`POST ${l(a)} failed`,cause:b})}),o=()=>f("/api/sessions/projects"),p=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),q=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),r=a=>g("/api/project-settings",a),s=a=>f(`/api/fs/dirs?path=${encodeURIComponent(a)}`),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},69424:(a,b,c)=>{"use strict";c.d(b,{$:()=>s});var d=c(48249),e=c(67484),f=c(44384),g=c(57063),h=c(7833),i=c(44256),j=c(74118),k=c(15273),l=c(46674),m=c(99941),n=c(44643),o=c(32026),p=c(11732),q=c(75513);function r(a){let b=a.input?.questions||[],c=a.input?.answers||{},d={};if(a.result)try{let b=JSON.parse(a.result);b?.answers&&(d=b.answers)}catch{}return{questions:b,answers:{...c,...d}}}function s({toolCalls:a,onClose:b}){let{t:c}=(0,f.Bd)(),t=(0,q.nH)(),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)({}),[A,B]=(0,e.useState)({});(0,g.E)(b);let C=a.reduce((a,b)=>{let{questions:c}=r(b);return a+c.length},0),D=Object.values(A).filter(Boolean).length,E=(0,e.useCallback)((a,b)=>{v(c=>({...c,[a]:b})),x(b=>({...b,[a]:!1}))},[]),F=(0,e.useCallback)(a=>{x(b=>{let c=!b[a];if(c){let b=y[a]||"";b&&v(c=>({...c,[a]:b}))}return{...b,[a]:c}})},[y]),G=(0,e.useCallback)((a,b)=>{z(c=>({...c,[a]:b})),b&&v(c=>({...c,[a]:b}))},[]),H=(0,e.useCallback)(a=>{B(b=>({...b,[a]:!b[a]}))},[]),I=(0,e.useCallback)(()=>{let b=D>0,d=[];return a.forEach((a,e)=>{let{questions:f}=r(a);f.forEach((a,f)=>{let g=`${e}-${f}`;if(b&&!A[g])return;let h=u[g];d.push(`Q: ${a.question}`),d.push(`A: ${h||c("askQuestion.notSelected")}`),d.push("")})}),d.join("\n").trim()},[a,u,A,D,c]),J=(0,e.useCallback)(()=>{navigator.clipboard.writeText(I()),(0,h.oR)(D>0?c("toast.copiedQA",{count:D}):c("toast.copiedAllQA"))},[I,D,c]),K=(0,e.useCallback)(()=>{t?(t.sendMessage(I()),(0,h.oR)(c("toast.sentQA")),b()):(0,h.oR)(c("askQuestion.sendNoChat"))},[t,I,b,c]),L=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:c("askQuestion.title")}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[c("askQuestion.nQuestions",{count:C}),D>0&&` \xb7 ${c("askQuestion.checkedN",{count:D})}`]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:K,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:D>0?c("askQuestion.sendChecked",{count:D}):c("askQuestion.sendAll"),children:(0,d.jsx)(j.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:J,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:D>0?c("askQuestion.copyChecked",{count:D}):c("askQuestion.copyAll"),children:(0,d.jsx)(k.A,{className:"w-4 h-4"})}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)(l.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-6",children:a.map((b,e)=>{let{questions:f}=r(b);return f.map((b,g)=>{let h=`${e}-${g}`,i=u[h],j=w[h]||!1,k=A[h]||!1;return(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("button",{onClick:()=>H(h),className:"mt-0.5 flex-shrink-0 p-0.5 rounded hover:bg-hover transition-colors",title:c("askQuestion.checkToCopy"),children:k?(0,d.jsx)(m.A,{className:"w-4 h-4 text-brand"}):(0,d.jsx)(n.A,{className:"w-4 h-4 text-muted-foreground"})}),b.header&&(0,d.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-brand/10 text-brand flex-shrink-0 mt-0.5",children:b.header}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground",children:b.question})]}),(0,d.jsxs)("div",{className:"space-y-1 ml-7",children:[b.options.map((a,b)=>{let c=i===a.label&&!j;return(0,d.jsxs)("button",{onClick:()=>E(h,a.label),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${c?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:c?(0,d.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("div",{className:`text-sm ${c?"text-foreground font-medium":"text-foreground"}`,children:a.label}),a.description&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]})]},b)}),(0,d.jsxs)("button",{onClick:()=>F(h),className:`flex items-start gap-2 px-2.5 py-1.5 rounded-md transition-colors w-full text-left cursor-pointer hover:bg-hover ${j?"bg-brand/10 hover:bg-brand/15":""}`,children:[(0,d.jsx)("div",{className:"mt-0.5 flex-shrink-0",children:j?(0,d.jsx)(o.A,{className:"w-3.5 h-3.5 text-brand"}):(0,d.jsx)("div",{className:"w-3.5 h-3.5 rounded-full border border-muted-foreground"})}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(p.A,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:c("askQuestion.custom")})]})]}),j&&(0,d.jsx)("div",{className:"ml-6 mt-1",children:(0,d.jsx)("input",{type:"text",autoFocus:!0,value:y[h]||"",onChange:a=>G(h,a.target.value),placeholder:c("askQuestion.customPlaceholder"),className:"w-full px-3 py-1.5 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-brand text-foreground"})})]}),(e!==a.length-1||g!==f.length-1)&&(0,d.jsx)("div",{className:"border-b border-border/50 mt-3"})]},h)})})})]})});return(0,d.jsx)(i.ZL,{children:L})}},69606:(a,b,c)=>{"use strict";c.d(b,{A:()=>g});var d=c(48249),e=c(18921),f=c(60591);function g({preview:a,onClose:b,search:c,preRef:h}){return(0,d.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:b,children:(0,d.jsxs)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-[90%] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:a.filePath}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",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:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)(e._,{search:c}),(0,d.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,d.jsx)("pre",{ref:h,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,f.xb)(a.content)})})]})})}},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>ak});var e=c(48249),f=c(67484),g=c.n(f),h=c(74429),i=c(8410),j=c(44256),k=c(33281),l=c(87808),m=c(25419),n=c(85655),o=c(21538),p=c(35208),q=c(74691),r=c(60333),s=c(7833),t=c(24724),u=c(20586),v=c(7122),w=c(55287),x=c(60591),y=c(19593),z=c(64825),A=c(66400),B=c(86588),C=c(64676),D=c(6478),E=c(59865),F=c(93321),G=c(9804),H=c(73887),I=c(40893),J=c(92608),K=c(94239),L=c(29939),M=c(23860),N=c(7031),O=c(72899),P=c(25667),Q=c(57014),R=c(69606),S=c(46242),T=c(21787),U=c(94308),V=c(53036),W=c(91975),X=c(6662),Y=c(20291),Z=c(58904),$=c(61632),_=c(41357),aa=c(76855),ab=c(4857),ac=c(44384),ad=c(18921),ae=c(28797),af=c(23881),ag=c(21672),ah=c(21482),ai=c(94192),aj=a([o,P,p,H,w,Q]);[o,P,p,H,w,Q]=aj.then?(await aj)():aj;let ak=g().memo(function({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:g,searchQueryTrigger:aj,fileOpenRequest:ak}){let al,am,an,ao,ap,aq,ar,{t:as}=(0,ac.Bd)(),at=(0,N.r)(),au=(0,f.useCallback)(a=>{at?.sendMessage(as("explain.fileMessage",{path:a}))},[at,as]),av=(0,f.useCallback)(a=>{at?.sendMessage(as("explain.stagedFileMessage",{path:a}))},[at,as]),aw=(0,f.useCallback)(a=>{at?.sendMessage(as("explain.unstagedFileMessage",{path:a}))},[at,as]),ax=(0,D.P)(),ay=(0,E.U)(),az=(0,F.Q)(),{activeView:aA,onViewChange:aB}=(0,ai.R8)(),[aC,aD]=(0,f.useState)(c),[aE,aF]=(0,f.useState)("code"),aG=(0,f.useRef)(null),aH=(0,f.useRef)(!1),[aI,aJ]=(0,f.useState)(null),[aK,aL]=(0,f.useState)(null),[aM,aN]=(0,f.useState)(!1),aO=(0,f.useRef)(1),aP=(0,f.useRef)(null),[aQ,aR]=(0,f.useState)(null),aS=(0,f.useRef)(null),[aT,aU]=(0,f.useState)({isDirty:!1,isSaving:!1}),[aV,aW]=(0,f.useState)(!1),[aX,aY]=(0,f.useState)(null),[aZ,a$]=(0,f.useState)(null),[a_,a0]=(0,f.useState)("compact"),[a1,a2]=(0,f.useState)("unified"),[a3,a4]=(0,f.useState)("full"),[a5,a6]=(0,f.useState)("unified"),[a7,a8]=(0,f.useState)(320),a9=(0,f.useRef)(null),ba=(0,f.useCallback)(a=>{"mouse"===a.pointerType&&0===a.button&&(a.preventDefault(),a9.current={startX:a.clientX,startWidth:a7},a.currentTarget.setPointerCapture(a.pointerId))},[a7]),bb=(0,f.useCallback)(a=>{let b=a9.current;if(!b)return;let c=b.startWidth+(a.clientX-b.startX);a8(Math.min(480,Math.max(320,c)))},[]),bc=(0,f.useCallback)(a=>{a9.current&&(a9.current=null,a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId))},[]),bd=(0,f.useRef)(null),be=(0,ad.o)(bd),bf=(0,f.useRef)(null),bg=(0,ad.o)(bf),bh=(0,aa.Sn)(b),bi=(0,aa.Xm)(b),bj=(0,aa.po)(b),bk=(0,ab.Q)(),bl=(0,M.F)(),bm=(0,X.W)({cwd:b});(0,aa.JL)(b,bm.selectedPath);let bn=(0,f.useMemo)(()=>{let a=bm.fileContent,b=bm.selectedPath;return a&&"text"===a.type&&"string"==typeof a.content&&b&&(0,x.Hz)(b)?(0,x.xb)(a.content,x.cG):null},[bm.fileContent,bm.selectedPath]),[bo,bp]=(0,f.useState)({version:0,collapsed:!1}),bq=(0,Y.p)({cwd:b,onSearchComplete:()=>aW(!0)}),br=(0,Z.e)({cwd:b,addToRecentFiles:bm.addToRecentFiles}),bs=(0,f.useMemo)(()=>{let a=new Set;if(br.status){for(let b of br.status.staged)a.add(b.path);for(let b of br.status.unstaged)a.add(b.path)}return a},[br.status]),bt=(0,f.useMemo)(()=>{let a=new Map;if(br.status){for(let b of br.status.staged)a.set(b.path,"staged");for(let b of br.status.unstaged)a.set(b.path,"unstaged")}return a},[br.status]),bu=(0,$.y)({cwd:b,addToRecentFiles:bm.addToRecentFiles}),bv=bu.compareFileDiff,bw=bv?.filePath??"",bx=(0,f.useMemo)(()=>{if(!bv||bv.isDeleted)return;let a={content:bv.newContent,filePath:bv.filePath};return(0,x.e$)(bv.filePath)?()=>a$(a):bv.filePath.endsWith(".json")?()=>aY(a):void 0},[bv]),by=(0,f.useCallback)(()=>a$(null),[]),bz=(0,f.useCallback)(()=>aY(null),[]),bA=(0,f.useMemo)(()=>{let a=0,b=0;for(let c of bu.compareFiles)a+=c.additions,b+=c.deletions;return{additions:a,deletions:b}},[bu.compareFiles]),bB=(0,f.useCallback)(a=>{at?.sendMessage(as("worktree"===bu.compareDiffMode?"explain.compareFileWorktreeMessage":"explain.compareFileMessage",{base:bu.compareBaseBranch,path:a}))},[at,as,bu.compareBaseBranch,bu.compareDiffMode]),bC=(0,f.useRef)(!1),bD=(0,f.useCallback)(a=>{bm.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),bm.showEditor||(bC.current=!0,bm.setShowEditor(!0))},[bm]),bE=(0,f.useCallback)(a=>{bm.setShowEditor(!0)},[bm]),bF=(0,f.useCallback)(async()=>{if(!bm.fileContent||"text"!==bm.fileContent.type||!bm.fileContent.content)return;let a=await k.t4.runPromiseExit((0,l.OJ)({cwd:b,path:bm.selectedPath,content:bm.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&bm.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,s.oR)(as("toast.savedSuccess"),"success")}catch{(0,s.oR)(as("toast.saveFailed"),"error")}},[b,bm]),bG=(0,f.useCallback)(()=>{if(!bm.selectedPath)return;let a=aO.current,b=aP.current;a>0&&bm.updateRecentFilePosition(bm.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[bm]),bH=(0,f.useCallback)(async(a,b)=>{let c=a!==bm.selectedPath;if(c&&bm.showEditor){if(aT.isDirty&&(!await (0,s.lJ)(as("fileBrowser.saveBeforeSwitch"),{confirmText:as("fileBrowser.saveAndSwitch"),cancelText:as("common.cancel")})||(await aS.current?.save(),aS.current?.isDirty)))return;bm.setShowEditor(!1)}c&&bG(),bm.handleSelectFile(a,b)},[bm,bG,aT.isDirty,as]),bI=(0,f.useMemo)(()=>{let a=bq.contentSearchResults;if(0===a.length)return{files:[],expandDirs:new Set,matchMap:new Map};let b=new Map,c=[];for(let d of a)b.set(d.path,d),c.push(d.path);let d=(0,G.v3)(c),e=new Set((0,G.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[bq.contentSearchResults]),[bJ,bK]=(0,f.useState)(new Set),bL=(0,f.useCallback)(a=>{bK(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),bM=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=bI.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[bI.matchMap]),bN=aV&&bq.contentSearchResults.length>0,[bO,bP]=(0,f.useState)("selected"),bQ=!!bm.selectedPath&&null!==(0,ae.c)(bm.selectedPath),[bR,bS]=(0,f.useState)(!1),bT=(0,f.useCallback)(async(a,c)=>{if(!bm.selectedPath||!bQ)return;let d=await bh.goToDefinition(bm.selectedPath,a,c);if(0===d.length)return;let e=d[0],f=b.endsWith("/")?b:b+"/",g=e.file.startsWith(f)?e.file.slice(f.length):e.file;bk.push({filePath:bm.selectedPath,lineNumber:aO.current}),g===bm.selectedPath?bm.setTargetLineNumber(e.line):bH(g,e.line)},[bm,b,bQ,bh,bk]),bU=(0,f.useCallback)((a,b,c,d,e)=>{a&&null!==(0,ae.c)(a)&&(bS(b),bi.onTokenMouseEnter(a,c,d,e))},[bi]),bV=(0,f.useCallback)((a,b,c)=>{bQ&&bU(bm.selectedPath,!1,a,b,c)},[bm.selectedPath,bQ,bU]),bW=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;bm.selectedPath&&bk.push({filePath:bm.selectedPath,lineNumber:aO.current}),d===bm.selectedPath?bm.setTargetLineNumber(a.line):bH(d,a.line)},[bm,b,bk]),bX=(0,f.useMemo)(()=>{if(!br.status)return null;let a=new Map,b=a=>{switch(a){case"modified":default:return"M";case"added":case"untracked":return"A";case"deleted":return"D";case"renamed":return"R"}};for(let c of br.status.staged)a.set(c.path,b(c.status));for(let c of br.status.unstaged)a.set(c.path,b(c.status));return a},[br.status]),bY=(0,f.useMemo)(()=>{if(!br.status)return null;let a=new Map;for(let b of br.status.staged)"renamed"===b.status&&b.oldPath&&a.set(b.path,b.oldPath);return a},[br.status]),bZ=(0,f.useCallback)(a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)},[bq.setContentSearchQuery,bq.performContentSearch]),b$=(0,_.H)({cwd:b,selectedPath:bm.selectedPath,gitStatusMap:bX,renameOldPaths:bY,isText:bm.fileContent?.type==="text",refreshKey:bm.fileContent?.mtime}),b_="tree"===aC&&b$.showDiff,b0=(0,f.useCallback)(a=>{aD(a),bm.setBlameSelectedCommit(null),"history"===a&&bu.selectedBranch&&bu.loadCommits(bu.selectedBranch)},[bm,bu.selectedBranch,bu.loadCommits]);(0,f.useCallback)(()=>{if(!bm.selectedPath)return;let a={filePath:bm.selectedPath,lineNumber:aO.current},b=bk.goBack(a);b&&(b.filePath===bm.selectedPath?bm.setTargetLineNumber(b.lineNumber):bH(b.filePath,b.lineNumber))},[bm,bk]),(0,f.useCallback)(()=>{if(!bm.selectedPath)return;let a={filePath:bm.selectedPath,lineNumber:aO.current},b=bk.goForward(a);b&&(b.filePath===bm.selectedPath?bm.setTargetLineNumber(b.lineNumber):bH(b.filePath,b.lineNumber))},[bm,bk]);let b1=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await k.t4.runPromiseExit((0,l.__)({cwd:b,path:a}));"Success"===d._tag?(0,s.oR)(as("toast.copiedName",{name:c}),"success"):(0,s.oR)(as("toast.copyFailed"),"error")},[b,as]),b2=(0,f.useCallback)(async a=>{let c=await k.t4.runPromiseExit((0,l.dt)());if("Success"!==c._tag||!c.value.path)return void(0,s.oR)(as("toast.noFileToPaste"),"info");let d=c.value.path,e=await k.t4.runPromiseExit((0,l.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,s.oR)(as("toast.pastedFile",{name:e.value.newName}),"success"),bm.loadDirectory(a),bm.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:as("toast.pasteFailed");(0,s.oR)(c,"error")}},[b,bm,as]);(0,f.useRef)(0),(0,f.useRef)(bl),(0,f.useRef)(aC),(0,f.useRef)(!1);let b3=(0,f.useRef)(bu.selectedBranch);b3.current=bu.selectedBranch;let b4=(0,f.useRef)(bm.selectedPath);b4.current=bm.selectedPath;let b5=(0,f.useRef)(bm.fileContent?.type);b5.current=bm.fileContent?.type;let b6=(0,f.useCallback)(async a=>{try{let{data:c}=a;if(!Array.isArray(c))return;let d=c.some(a=>"git"===a.type),e=c.some(a=>"file"===a.type),f=[];if((e||d)&&(f.push(k.t4.runPromise((0,l.mP)(b)).then(a=>{a.error||bm.setFiles(b=>(0,G.HR)(a.files??[],b))}).catch(()=>{})),f.push(k.t4.runPromise((0,l.DZ)(b)).then(a=>{a.paths&&bm.setFileIndex(a.paths)}).catch(()=>{})),f.push(k.t4.runPromise((0,l.r9)(b)).then(a=>{bm.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(k.t4.runPromise((0,n.lv)(b)).then(a=>{br.setStatus(a);let b=(0,u.Do)(a.staged),c=(0,u.Do)(a.unstaged);br.setStagedTree(b),br.setUnstagedTree(c)}).catch(()=>{})),br.refreshDiff(),bu.refreshCompare(),d&&bu.loadBranches();let a=b3.current;a&&f.push(k.t4.runPromise((0,n.Bj)(b,a,G.B_)).then(a=>{let b=a.commits??[];bu.setCommits(b),bu.setHasMoreCommits(b.length>=G.B_)}).catch(()=>{}))}let g=b4.current,h=b5.current;g&&"text"===h&&f.push(k.t4.runPromise((0,m.K)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&bm.setFileContent({type:"text",content:b.content,size:b.size,mtime:b.mtimeMs,...b.isSymlink?{isSymlink:!0,symlinkTarget:b.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(f)}catch(a){console.error("File watch handler error:",a)}},[b]);(0,L.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:b6,enabled:bl});let b7=(0,f.useCallback)(a=>{bH(a),bm.setShouldScrollToSelected(!0),aD("tree")},[bm,bH]);(0,f.useRef)(bH),(0,f.useRef)(null);let{setPreviewMarkdown:b8,setShouldScrollToSelected:b9}=bm,ca=(0,f.useCallback)(({focalFile:a})=>a&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${b}/${a}`),(0,s.oR)(as("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),b7(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),[b,b7,as]),cb=(0,f.useCallback)(({focalFile:a})=>"tree"===aC&&b$.canDiff&&a===bm.selectedPath?(0,e.jsxs)(e.Fragment,{children:[b$.showDiff&&(0,e.jsx)(q.y,{value:a3,onChange:a4}),(0,e.jsx)("button",{onClick:b$.toggleDiff,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${b$.showDiff?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,title:b$.showDiff?as("fileBrowser.exitDiff"):as("fileBrowser.viewDiff"),children:as("common.diff")})]}):null,[aC,b$.canDiff,b$.showDiff,b$.toggleDiff,bm.selectedPath,a3,as]),[cc,cd]=(0,f.useState)(null),ce=(0,f.useCallback)((a,b)=>{bm.setPreviewMarkdown(!0),b7(a),cd(b),b&&setTimeout(()=>cd(null),400)},[bm,b7]);return(0,e.jsxs)(v.SU,{container:aI,children:[(0,e.jsxs)("div",{ref:aG,className:"bg-card w-full h-full flex flex-col relative",children:[(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex-shrink-0 flex flex-col overflow-hidden",style:{width:a7},children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>b0("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>b0("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>b0("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>b0("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>b0("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===aC?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:as("fileBrowser.historyTab")})]}),"tree"===aC&&(0,e.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:bm.searchInputRef,type:"text",value:bm.searchQuery,onChange:a=>bm.setSearchQuery(a.target.value),placeholder:as("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),bm.searchQuery&&(0,e.jsx)("button",{onClick:()=>{bm.setSearchQuery(""),bm.searchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:as("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>bm.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${bm.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:bm.searchExactMatch?as("fileBrowser.exactMatchOn"):as("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>bm.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:as("fileBrowser.refreshTree"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>bm.searchTreeExpandedPaths?bm.setSearchTreeExpandedPaths(new Set):bm.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:as("fileBrowser.collapseAll"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===aC&&(0,e.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 relative",children:[(0,e.jsx)("input",{ref:bq.contentSearchInputRef,type:"text",value:bq.contentSearchQuery,onChange:a=>bq.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bq.performContentSearch(bq.contentSearchQuery)},placeholder:as("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),bq.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>{bq.setContentSearchQuery(""),bq.contentSearchInputRef.current?.focus()},className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:as("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("button",{onClick:()=>bq.performContentSearch(bq.contentSearchQuery),disabled:bq.isSearching||!bq.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:bq.isSearching?"...":as("common.search")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bq.searchOptions.caseSensitive,onChange:a=>bq.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:as("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bq.searchOptions.wholeWord,onChange:a=>bq.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:as("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bq.searchOptions.regex,onChange:a=>bq.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:as("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:bq.searchOptions.fileType,onChange:a=>bq.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:as("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground"})]})]}),"history"===aC&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:bu.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"flex-1 min-w-0 truncate",children:bu.branches?.current||"HEAD"}),(0,e.jsx)("div",{className:"flex flex-shrink-0 items-center rounded border border-border overflow-hidden text-xs",children:["head","worktree"].map(a=>(0,e.jsx)("button",{onClick:()=>bu.setCompareDiffMode(a),className:`px-1.5 py-0.5 transition-colors ${bu.compareDiffMode===a?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:as("head"===a?"fileBrowser.compareScopeHeadHint":"fileBrowser.compareScopeWorktreeHint"),children:as("head"===a?"fileBrowser.compareScopeHead":"fileBrowser.compareScopeWorktree")},a))})]}),(0,e.jsx)("button",{onClick:()=>bu.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:as("fileBrowser.compareModeOff"),children:as("fileBrowser.compareMode")})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(U.e,{branches:bu.branches,selectedBranch:bu.compareBaseBranch,onSelect:a=>{bu.setCompareBaseBranch(a),bu.loadCompareFiles(a)},isLoading:bu.isLoadingBranches,pinnedBranches:["origin/main",...bu.upstreamBranch&&"origin/main"!==bu.upstreamBranch?[bu.upstreamBranch]:[]]})})]})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex-1 min-w-0",children:(0,e.jsx)(U.e,{branches:bu.branches,selectedBranch:bu.selectedBranch,onSelect:a=>{bu.setSelectedBranch(a)},isLoading:bu.isLoadingBranches,pinnedBranches:["origin/main",...bu.upstreamBranch&&"origin/main"!==bu.upstreamBranch?[bu.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>bu.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-hover border border-border",title:as("fileBrowser.compareModeOn"),children:as("fileBrowser.compareMode")})]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,e.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===aC?"":"hidden"}`,children:[bm.creatingItem&&(0,e.jsxs)("div",{className:"px-2 py-1.5 border-b border-border flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:bm.creatingItem.parentPath?as("fileBrowser.createFileIn",{path:bm.creatingItem.parentPath}):as("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:as("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{aH.current=!0},onCompositionEnd:()=>{aH.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(aH.current)return;let c=a.target.value.trim();if(!c)return;let d=bm.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await k.t4.runPromiseExit((0,l.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,s.oR)(as("toast.createdFile",{name:c}),"success"),bm.setCreatingItem(null),bm.loadDirectory(d),bm.loadFileIndex(),d&&bm.setExpandedPaths(a=>new Set([...a,d])),bH(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,s.oR)(a||as("toast.createFailed"),"error")}else(0,s.oR)(as("toast.createFailed"),"error")}else"Escape"===a.key&&bm.setCreatingItem(null)},onBlur:()=>bm.setCreatingItem(null)})]}),bm.isLoadingFiles&&0===bm.files.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("common.loading")}):bm.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bm.fileError}):(0,e.jsx)(t.h,{files:bm.files,selectedPath:bm.selectedPath,expandedPaths:bm.effectiveExpandedPaths,matchedPaths:bm.matchedPaths,gitStatusMap:bX,loadingDirs:bm.loadingDirs,onSelect:a=>{bm.setShouldScrollToSelected(!1),bH(a)},onToggle:bm.handleToggle,cwd:b,shouldScrollToSelected:bm.shouldScrollToSelected,onScrolledToSelected:()=>bm.setShouldScrollToSelected(!1),onCreateFile:a=>bm.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>aL({path:a,isDirectory:b,name:c}),onRefresh:()=>bm.loadFiles(),onCopyFile:b1,onPaste:b2,onExplain:at?au:void 0,explainDisabled:at?.isLoading})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===aC?"":"hidden"}`,children:bq.isSearching?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bq.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bq.searchError}):0===bq.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:bq.contentSearchQuery?as("fileBrowser.noContentSearchResults"):as("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[bq.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b border-border flex-shrink-0",children:[as("fileBrowser.nFilesNMatches",{files:bq.searchStats.totalFiles,matches:bq.searchStats.totalMatches}),bq.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",as("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(t.h,{files:bI.files,selectedPath:bm.selectedPath,expandedPaths:bJ,onSelect:a=>{let b=bI.matchMap.get(a);bH(a,b?.matches[0]?.lineNumber),aV||aW(!0)},onToggle:bL,cwd:b,onExplain:at?au:void 0,explainDisabled:at?.isLoading,renderActions:bM,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===aC?"":"hidden"}`,children:0===bm.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.noRecentFiles")}):(0,e.jsx)(t.h,{files:bm.recentFilesTree,selectedPath:bm.selectedPath,expandedPaths:bm.recentTreeDirPaths,onSelect:bH,onToggle:G.tE,cwd:b,onExplain:at?au:void 0,explainDisabled:at?.isLoading})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===aC?"":"hidden"}`,children:br.statusLoading?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):br.statusError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,e.jsx)("span",{className:"text-red-11 text-sm",children:br.statusError})}):(0,e.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,e.jsxs)("div",{className:"border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:as("fileBrowser.stagingArea",{count:br.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>br.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:as("fileBrowser.refreshChanges"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(br.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:br.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:as("fileBrowser.unstageAll")})]}),(0,e.jsx)(u.VO,{files:br.stagedTree,selectedPath:br.statusSelectedFile?.type==="staged"?br.statusSelectedFile.file.path:null,expandedPaths:br.stagedExpandedPaths,onSelect:a=>a.file&&br.handleStatusFileSelect(a.file,"staged"),onToggle:br.handleStagedToggle,cwd:b,showChangeClass:!0,hideIndicatorsOnHover:!0,emptyMessage:as("fileBrowser.noStagedFiles"),className:"py-1",onExplain:at?av:void 0,explainDisabled:at?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,u.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),br.handleUnstageFiles(b.map(a=>a.path))},className:"hidden group-hover:block p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-colors",title:as("fileBrowser.unstageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),br.handleUnstage(a.path)},className:"hidden group-hover:block p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-colors",title:as("fileBrowser.unstageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:as("fileBrowser.workspace",{count:br.status?.unstaged.length||0})}),(br.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:br.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:as("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:br.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:as("fileBrowser.stageAll")})]})]}),(0,e.jsx)(u.VO,{files:br.unstagedTree,selectedPath:br.statusSelectedFile?.type==="unstaged"?br.statusSelectedFile.file.path:null,expandedPaths:br.unstagedExpandedPaths,onSelect:a=>a.file&&br.handleStatusFileSelect(a.file,"unstaged"),onToggle:br.handleUnstagedToggle,cwd:b,showChangeClass:!0,hideIndicatorsOnHover:!0,emptyMessage:as("fileBrowser.noUnstagedChanges"),className:"py-1",onExplain:at?aw:void 0,explainDisabled:at?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,u.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"hidden group-hover:flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),br.handleDiscardFiles(c)},className:"p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-colors",title:as("fileBrowser.discardNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),br.handleStageFiles(b.map(a=>a.path))},className:"p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-colors",title:as("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"hidden group-hover:flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),br.handleDiscardFile(a.file)},className:"p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-colors",title:as("fileBrowser.discardChanges"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),br.handleStage(a.path)},className:"p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-colors",title:as("fileBrowser.stageFile"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===aC?"":"hidden"}`,children:bu.historyError?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,e.jsx)("p",{className:"text-muted-foreground",children:bu.historyError})]})}):bu.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:bu.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.loadingDiff")}):0===bu.compareFiles.length?(0,e.jsxs)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:[(0,e.jsx)("div",{children:as("fileBrowser.noDiffFiles")}),"head"===bu.compareDiffMode&&(0,e.jsx)("button",{onClick:()=>bu.setCompareDiffMode("worktree"),className:"mt-2 text-xs text-brand hover:underline",children:as("fileBrowser.noDiffFilesHeadHint")})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:as("worktree"===bu.compareDiffMode?"fileBrowser.nFilesChangedWorktree":"fileBrowser.nFilesChanged",{count:bu.compareFiles.length,branch:bu.compareBaseBranch})}),(0,e.jsxs)("span",{className:"flex flex-shrink-0 items-center gap-1.5 text-xs tabular-nums",children:[(0,e.jsxs)("span",{className:"text-green-11",children:["+",bA.additions]}),(0,e.jsxs)("span",{className:"text-red-11",children:["-",bA.deletions]})]})]}),(0,e.jsx)(u.VO,{files:bu.compareFileTree,expandedPaths:bu.compareExpandedPaths,onToggle:bu.handleCompareToggle,selectedPath:bu.compareSelectedFile?.path||null,onSelect:a=>{a.file&&bu.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0,showChangeClass:!0,onExplain:at?bB:void 0,explainDisabled:at?.isLoading})]})}):(0,e.jsx)("div",{ref:bu.commitListRef,className:"flex-1 overflow-y-auto",onScroll:bu.handleCommitListScroll,children:bu.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.loadingCommits")}):0===bu.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:as("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[bu.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>bu.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${bu.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[a.changeClass&&(0,e.jsx)(i.N,{cls:a.changeClass}),(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-foreground-subtle","data-tooltip":a.date,children:[a.relativeDate," \xb7 ",(0,G.r6)(a.date)]})]}),(0,e.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":a.subject,children:a.subject}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:a.author})]},a.hash)),bu.isLoadingMore&&(0,e.jsx)("div",{className:"p-3 text-center",children:(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!bu.hasMoreCommits&&bu.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-foreground-subtle",children:as("fileBrowser.allLoaded",{count:bu.commits.length})})]})})})]})]}),(0,e.jsx)("div",{onPointerDown:ba,onPointerMove:bb,onPointerUp:bc,onPointerCancel:bc,className:"w-[5px] flex-shrink-0 relative cursor-col-resize group",children:(0,e.jsx)("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-px bg-border group-hover:bg-brand transition-colors"})}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[("tree"===aC||"search"===aC||"recent"===aC)&&(bm.blameSelectedCommit?(0,e.jsx)(o.n,{isOpen:!0,onClose:()=>bm.setBlameSelectedCommit(null),commit:bm.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:bm.selectedPath||void 0,onLocateInTree:b7,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):"map"===aE?b_&&b$.diff?(0,e.jsx)(P.r,{cwd:b,filePath:b$.diff.filePath,oldContent:b$.diff.oldContent,newContent:b$.diff.newContent,isNew:b$.diff.isNew,isDeleted:b$.diff.isDeleted,changedFiles:bs,fileGitStatusMap:bt,compact:"compact"===a3,enableComments:!0,onSwitchToCode:()=>aF("code"),onContentSearch:bZ,headerExtraLeft:ca,headerExtraRight:cb}):(0,e.jsx)(O.O,{cwd:b,highlightedFilePath:bm.selectedPath,changedFiles:bs,onSwitchToCode:()=>aF("code"),enableComments:!0,onContentSearch:bZ,headerExtraLeft:ca,headerExtraRight:cb}):bm.selectedPath?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"px-4 py-2 border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:bm.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${bm.selectedPath}`),(0,s.oR)(as("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),b7(bm.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:as("fileBrowser.locateInTree"),children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:bm.showEditor?(0,e.jsxs)(e.Fragment,{children:[aT.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:as("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>aS.current?.save(),disabled:!aT.isDirty||aT.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aT.isDirty&&!aT.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:aT.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):as("common.save")}),(0,e.jsx)("button",{onClick:()=>aS.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.closeEdit"),children:as("fileBrowser.closeBtn")})]}):b_?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(q.y,{value:a3,onChange:a4}),(0,e.jsx)(r.q,{value:a5,onChange:a6}),!(0,x.e$)(bm.selectedPath)&&!(0,x.aR)(bm.selectedPath)&&!(0,x.Hz)(bm.selectedPath)&&!(0,x.Zy)(bm.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aF("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("blockViewer.viewerToggle.toBlock"),children:as("common.codeMap")}),(0,e.jsx)("button",{onClick:b$.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors bg-brand text-white",children:as("fileBrowser.exitDiff")})]}):(0,e.jsxs)(e.Fragment,{children:["tree"===aC&&b$.canDiff&&(0,e.jsx)("button",{onClick:b$.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.viewDiff"),children:as("common.diff")}),bm.fileContent?.type==="text"&&(0,x.e$)(bm.selectedPath)&&(0,e.jsx)(J.ShareReviewToggle,{content:bm.fileContent.content||"",sourceFile:bm.selectedPath&&b&&bm.selectedPath.startsWith(b)?bm.selectedPath.slice(b.endsWith("/")?b.length:b.length+1):bm.selectedPath||""}),bm.fileContent?.type==="text"&&(0,x.Hz)(bm.selectedPath)&&bm.previewMarkdown&&!bm.showBlame&&(0,e.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:[!0,!1].map(a=>(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bp(b=>({version:b.version+1,collapsed:a}))},className:`px-2 py-0.5 text-xs transition-colors ${bo.collapsed===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:as(a?"fileBrowser.collapseAllJson":"fileBrowser.expandAllJson")},String(a)))}),bm.fileContent?.type==="text"&&((0,x.e$)(bm.selectedPath)||(0,x.aR)(bm.selectedPath)||(0,x.Hz)(bm.selectedPath)||(0,x.Zy)(bm.selectedPath))&&(am=(al=(0,x.aR)(bm.selectedPath))?bm.previewHtml:bm.previewMarkdown,(0,e.jsx)("button",{onClick:()=>al?bm.setPreviewHtml(a=>!a):bm.setPreviewMarkdown(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${am?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:am?as("fileBrowser.exitPreview"):as("common.preview")})),bm.fileContent?.type==="text"&&((0,x.C_)(bm.selectedPath||"")||(0,x.OG)(bm.selectedPath||""))&&(ao=(an=bm.selectedPath||"").startsWith("/")?an:b?`${b.replace(/\/$/,"")}/${an}`:an,ap=(0,x.OG)(an),(0,e.jsx)("button",{onClick:()=>void(ap?az(ao):ay(ao)),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as(ap?"bots.addTooltip":"skills.addTooltip"),children:(0,e.jsx)(z.A,{className:"w-3.5 h-3.5"})})),bm.fileContent?.type==="text"&&(0,x.aR)(bm.selectedPath)&&(ar=(aq=bm.selectedPath||"").startsWith("/")?aq:b?`${b.replace(/\/$/,"")}/${aq}`:aq,(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>ax(ar),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as("htmlApps.addTooltip"),children:(0,e.jsx)(z.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:ar}})),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as("common.openInConsole"),children:(0,e.jsx)(A.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>{let a=(0,C.Xe)(ar);window.open((0,C.PB)(a,window.location.origin),"_blank")},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:as("browser.openInNewWindow"),children:(0,e.jsx)(B.A,{className:"w-3.5 h-3.5"})})]})),bm.fileContent?.type==="text"&&!(bm.previewMarkdown&&((0,x.e$)(bm.selectedPath)||(0,x.Hz)(bm.selectedPath)||(0,x.Zy)(bm.selectedPath))||bm.previewHtml&&(0,x.aR)(bm.selectedPath))&&(0,e.jsx)("button",{onClick:bm.handleToggleBlame,disabled:bm.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bm.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-hover"} disabled:opacity-50`,title:as("fileBrowser.viewBlame"),children:bm.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),bm.fileContent?.type==="text"&&!(bm.previewMarkdown&&((0,x.e$)(bm.selectedPath)||(0,x.Hz)(bm.selectedPath)||(0,x.Zy)(bm.selectedPath))||bm.previewHtml&&(0,x.aR)(bm.selectedPath))&&(0,e.jsx)("button",{onClick:()=>bm.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.editFile"),children:as("common.edit")}),bm.fileContent?.type==="text"&&bm.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(bm.fileContent.content),(0,s.oR)(as("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("fileBrowser.copyFileContent"),children:as("common.copy")}),bm.fileContent?.type==="text"&&!(0,x.e$)(bm.selectedPath)&&!(0,x.aR)(bm.selectedPath)&&!(0,x.Hz)(bm.selectedPath)&&!(0,x.Zy)(bm.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aF("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:as("blockViewer.viewerToggle.toBlock"),children:as("common.codeMap")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:bm.isLoadingContent?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bm.fileContent?"text"===bm.fileContent.type&&"string"==typeof bm.fileContent.content?b_?b$.isLoadingDiff&&!b$.diff?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):b$.diff?"unified"===a5?(0,e.jsx)(p.xU,{oldContent:b$.diff.oldContent,newContent:b$.diff.newContent,filePath:b$.diff.filePath,cwd:b,enableComments:!0,compact:"compact"===a3,onContentSearch:bZ,onTokenHover:(a,b,c)=>bU(b$.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bi.onTokenMouseLeave,onTokenHoverCancel:bi.clearHover}):(0,e.jsx)(p.xZ,{oldContent:b$.diff.oldContent,newContent:b$.diff.newContent,filePath:b$.diff.filePath,isNew:b$.diff.isNew,isDeleted:b$.diff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===a3,onContentSearch:bZ,onTokenHover:(a,b,c)=>bU(b$.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bi.onTokenMouseLeave,onTokenHoverCancel:bi.clearHover}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{children:as("fileBrowser.diffLoadFailed")}),(0,e.jsx)("button",{onClick:b$.toggleDiff,className:"mt-2 text-brand hover:underline text-sm",children:as("fileBrowser.exitDiff")})]})}):bm.showBlame&&bm.blameError?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-red-11",children:bm.blameError}),(0,e.jsx)("button",{onClick:()=>bm.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:as("fileBrowser.backToPreview")})]})}):bm.showBlame&&0===bm.blameLines.length&&bm.isLoadingBlame?(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):bm.previewMarkdown&&(0,x.Hz)(bm.selectedPath)&&!bm.showBlame?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-background text-foreground",children:[(0,e.jsx)(ad._,{search:be}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:bd,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,e.jsx)(x.d9.Provider,{value:bo,children:bn})})})]}):bm.previewMarkdown&&(0,x.Zy)(bm.selectedPath)&&!bm.showBlame?(0,e.jsx)(y.C0,{content:bm.fileContent.content,filePath:bm.selectedPath,className:"h-full"}):bm.previewMarkdown&&(0,x.e$)(bm.selectedPath)&&!bm.showBlame?(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(H.M,{content:bm.fileContent.content,filePath:bm.selectedPath,cwd:b,embedded:!0,onLocalMdLink:ce,scrollToAnchor:cc})}):bm.previewHtml&&(0,x.aR)(bm.selectedPath)&&!bm.showBlame?(0,e.jsx)(I.O,{content:bm.fileContent.content,filePath:bm.selectedPath,cwd:b,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):(0,e.jsx)(w.Cv,{ref:aS,content:bm.fileContent.content,filePath:bm.selectedPath,cwd:b,enableComments:!0,scrollToLine:aQ??bm.targetLineNumber,scrollToLineAlign:null!=aQ?"start":bm.targetScrollAlign,onScrollToLineComplete:()=>{aR(null),bm.setTargetLineNumber(null)},highlightKeyword:"search"===aC?bq.contentSearchQuery:null,visibleLineRef:aO,viStateRef:aP,initialCursorLine:bm.initialCursorLine,initialCursorCol:bm.initialCursorCol,onInitialCursorSet:()=>{bm.setInitialCursorLine(null),bm.setInitialCursorCol(null)},onCmdClick:bQ?bT:void 0,onTokenHover:bQ?bV:void 0,onTokenHoverLeave:bQ?bi.onTokenMouseLeave:void 0,onTokenHoverCancel:bQ?bi.clearHover:void 0,blameLines:bm.showBlame&&bm.blameLines.length>0?bm.blameLines:void 0,inlineBlameLines:bm.blameLines.length>0?bm.blameLines:void 0,onSelectCommit:bm.setBlameSelectedCommit,editable:bm.showEditor,initialMtime:bm.fileContent.mtime,onEditorClose:a=>{bm.setShowEditor(!1),aR(a)},onSaved:()=>{let a=aO.current??1;bm.loadFileContent(bm.selectedPath),bm.setShowEditor(!1),aR(a)},onEditorStateChange:aU,viMode:!0,onContentMutate:bD,onEnterInsertMode:bE,onViSave:bF,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):"image"===bm.fileContent.type&&bm.selectedPath?(0,e.jsx)(V.I,{cwd:b,path:bm.selectedPath,refreshKey:bm.fileContent.mtime,alt:bm.selectedPath}):"pdf"===bm.fileContent.type&&bm.selectedPath?(0,e.jsx)(W.t,{cwd:b,path:bm.selectedPath,refreshKey:bm.fileContent.mtime}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,e.jsx)("p",{children:bm.fileContent.message||as("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:as("fileBrowser.selectFileToPreview")})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("svg",{className:"w-16 h-16 mx-auto text-foreground-faint mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,e.jsx)("p",{children:as("fileBrowser.selectFileToPreview")})]})})),"status"===aC&&(br.statusSelectedFile&&br.statusDiff?(0,e.jsx)(Q.m,{cwd:b,selected:br.statusSelectedFile,diff:br.statusDiff,showMarkdownPreview:br.showStatusDiffPreview,setShowMarkdownPreview:br.setShowStatusDiffPreview,changedFiles:bs,fileGitStatusMap:bt,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)},locateInTree:b7,setJsonPreview:aY,onTokenHover:(a,b,c)=>bU(br.statusDiff?.filePath,!0,a,b,c),onTokenHoverLeave:bi.onTokenMouseLeave,onTokenHoverCancel:bi.clearHover}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:as("fileBrowser.selectFileToViewDiff")})})),"history"===aC&&!bu.historyError&&(bu.compareMode?bu.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:as("fileBrowser.loadingDiffContent")}):bu.compareFileDiff?(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border flex-shrink-0",children:[(0,e.jsx)(T.d,{cwd:b,filePath:bu.compareFileDiff.filePath,onLocateInTree:b7}),!(0,G.u)(bu.compareFileDiff.filePath)&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(q.y,{value:a_,onChange:a0}),(0,e.jsx)(r.q,{value:a1,onChange:a2})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,G.u)(bu.compareFileDiff.filePath)?(0,e.jsx)(S.M,{cwd:b,filePath:bu.compareFileDiff.filePath,oldRev:bu.compareFileDiff.oldRev??(bu.compareFileDiff.isNew?null:bu.compareBaseBranch),newRev:"worktree"===bu.compareDiffMode?null:bu.compareFileDiff.newRev??(bu.compareFileDiff.isDeleted?null:"HEAD"),newNode:bu.compareFileDiff.newWorktree?(0,e.jsx)(V.I,{cwd:b,path:bu.compareFileDiff.filePath}):void 0}):"unified"===a1?(0,e.jsx)(p.xU,{oldContent:bu.compareFileDiff.oldContent,newContent:bu.compareFileDiff.newContent,filePath:bu.compareFileDiff.filePath,cwd:b,enableComments:!0,compact:"compact"===a_,onPreview:bx,previewLabel:bw.endsWith(".json")?as("common.readable"):as("common.preview"),onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):(0,e.jsx)(p.xZ,{oldContent:bu.compareFileDiff.oldContent,newContent:bu.compareFileDiff.newContent,filePath:bu.compareFileDiff.filePath,isNew:bu.compareFileDiff.isNew,isDeleted:bu.compareFileDiff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===a_,onPreview:bx,previewLabel:bw.endsWith(".json")?as("common.readable"):as("common.preview"),onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}})}),aZ&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>a$(null),children:(0,e.jsx)("div",{className:"bg-card rounded-lg shadow-lv3 w-full max-w-[90%] h-full flex flex-col",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(H.M,{content:aZ.content,filePath:aZ.filePath,cwd:b,onClose:by})})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:bu.compareFiles.length>0?as("fileBrowser.selectFileToViewDiff"):as("fileBrowser.clickCompareToLoad")})}):bu.selectedCommit?(0,e.jsx)(o.n,{isOpen:!0,onClose:()=>bu.setSelectedCommit(null),commit:bu.selectedCommit,cwd:b,embedded:!0,onLocateInTree:b7,onContentSearch:a=>{aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:as("fileBrowser.selectCommitToView")})})),aX&&(0,e.jsx)(R.A,{preview:aX,onClose:bz,search:bg,preRef:bf})]})]}),aM&&(0,e.jsx)(K.c,{files:bm.files,fileIndex:bm.fileIndex,recentFiles:bm.recentFilePaths,onSelectFile:a=>{bH(a),bm.setShouldScrollToSelected(!0),aD("tree")},onClose:()=>aN(!1)}),(bN||bj.visible)&&(0,e.jsxs)("div",{className:`flex ${bj.visible&&bN?"":"flex-col"}`,children:[bN&&(0,e.jsx)("div",{className:bj.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(ah.D,{results:bq.contentSearchResults,loading:bq.isSearching,totalMatches:bq.searchStats?.totalMatches??0,onSelect:(a,b)=>{bm.selectedPath&&bk.push({filePath:bm.selectedPath,lineNumber:aO.current}),aF("code"),bH(a,b)},onClose:()=>aW(!1),scope:bO,onScopeChange:bP,selectedPath:bm.selectedPath})}),bj.visible&&(0,e.jsx)("div",{className:bN?"flex-1 min-w-0":"",children:(0,e.jsx)(ag.D,{references:bj.references,loading:bj.loading,onSelect:bW,onClose:bj.closeReferences})})]})]}),aK&&(0,e.jsx)(j.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim",onClick:()=>aL(null),children:(0,e.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 p-4 max-w-sm w-full mx-4",onClick:a=>a.stopPropagation(),children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:as("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:as("fileBrowser.confirmDeleteMessage",{name:aK.name}).split(/<\/?file>/g).map((a,b)=>1===b?(0,e.jsx)("span",{className:"font-mono text-foreground",children:a},b):a)}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)("button",{onClick:()=>aL(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-hover transition-colors",children:as("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=aK;aL(null);let d=await k.t4.runPromiseExit((0,l.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,s.oR)(as("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";bm.loadDirectory(b),bm.loadFileIndex(),bm.selectedPath===a&&bH("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:as("toast.deleteFailed");(0,s.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:as("common.delete")})]})]})})}),bi.hoverInfo&&aI&&(0,h.createPortal)((0,e.jsx)(af.s,{ref:bi.setTooltipEl,displayString:bi.hoverInfo.displayString,documentation:bi.hoverInfo.documentation,x:bi.hoverInfo.x,y:bi.hoverInfo.y,container:aI,onMouseEnter:bi.onCardMouseEnter,onMouseLeave:bi.onCardMouseLeave,onFindReferences:bR?void 0:()=>{let{filePath:a,line:b,column:c}=bi.hoverInfo;bi.clearHover(),bj.findReferences(a,b,c)},onSearch:a=>{bi.clearHover(),aD("search"),bq.setContentSearchQuery(a),bq.performContentSearch(a)},onExplain:at?a=>{let{filePath:b,line:c}=bi.hoverInfo;bi.clearHover(),at.sendMessage(as("explain.symbolMessage",{name:a,path:b,lines:String(c)}))}:void 0,explainDisabled:at?.isLoading}),aI)]})});d()}catch(a){d(a)}})},70440:(a,b,c)=>{"use strict";function d(){return[{type:"image/x-icon",sizes:"16x16",url:"/favicon.ico?a49a3c8f7b751288"}]}c.r(b),c.d(b,{default:()=>d})},70596:(a,b,c)=>{"use strict";c.d(b,{t:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({x:a,y:b,comment:c,container:h,onClose:i,onUpdateComment:j,onDeleteComment:k}){let{t:l}=(0,f.Bd)(),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(c.content),q=(0,e.useRef)(null),[r,s]=(0,e.useState)({x:0,y:0}),t=async()=>{o.trim()&&(await j(c.id,o.trim()),n(!1))},u=async()=>{await k(c.id),i()};return(0,d.jsx)("div",{ref:q,className:"absolute z-[200] w-96 bg-card border border-border rounded-lg shadow-lv2 overflow-hidden",style:{left:r.x,top:r.y},children:(0,d.jsx)("div",{className:"p-3",children:m?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.target.value),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring",rows:3,autoFocus:!0,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),t()),"Escape"===a.key&&(n(!1),p(c.content))}}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>{n(!1),p(c.content)},className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground",children:l("common.cancel")}),(0,d.jsx)("button",{onClick:t,className:"px-2 py-1 text-xs bg-brand text-white rounded hover:bg-brand/90",children:l("common.save")})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:c.content}),(0,d.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:l("comments.lineRange",{start:c.startLine,end:c.endLine})}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>n(!0),className:"p-1 rounded hover:bg-hover text-muted-foreground",title:l("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{onClick:u,className:"p-1 rounded hover:bg-hover text-muted-foreground hover:text-red-9",title:l("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]})]})})})}},71192:(a,b,c)=>{"use strict";c.d(b,{m_:()=>f,uV:()=>e});var d=c(81218);class e extends d.rN("AppError"){}d.rN("DBError"),d.rN("WSError"),d.rN("FSError"),d.rN("AgentError"),d.rN("ValidationError");class f extends d.rN("NotFoundError"){}d.rN("PermissionError")},71697:(a,b,c)=>{"use strict";c.d(b,{V:()=>k,n:()=>j});var d=c(48249),e=c(67484),f=c(44384);c(59336);var g=c(15332);c(81608);var h=c(33281),i=c(41224);function j({value:a,onChange:b,textareaRef:c,extraCommands:d}){let[f,k]=(0,e.useState)(a.length),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)([]),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)(0),[t,u]=(0,e.useState)(()=>a.length>0),v=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a=await h.t4.runPromiseExit((0,i.l1)());if("Success"===a._tag){let b=a.value.skills??a.value;o((Array.isArray(b)?b:[]).filter(a=>a.valid&&!!a.name).map(a=>({name:`/${a.name}`,description:a.description||"",source:"skill",skillPath:a.path,argumentHint:a.argumentHint})))}else console.error("Failed to load skills:",a.cause)},[]),(0,e.useCallback)(async()=>{let a=await h.t4.runPromiseExit((0,g.jm)());"Success"===a._tag?q(a.value.flatMap(a=>a.valid?[{name:`@${a.name}`,description:a.description,source:"bot"}]:[])):console.error("Failed to load bots:",a.cause)},[]);let w=(0,e.useMemo)(()=>{let b=0===f?0:a.lastIndexOf("\n",f-1)+1,c=a.indexOf("\n",f),d=-1===c?a.length:c;return{text:a.slice(b,d),start:b,end:d}},[a,f]),x=(0,e.useMemo)(()=>{let a=w.text.match(/^\s*(\/@|\/|@)([a-zA-Z0-9-]*)$/);return a?{marker:a[1],verb:a[2].toLowerCase()}:null},[w.text]),y=(0,e.useMemo)(()=>{if(!x)return[];let{verb:a}=x,b=b=>b.name.slice(1).toLowerCase().startsWith(a);return"@"===x.marker?p.filter(b):[...(d??[]).filter(b),...l.filter(b),...n.filter(b)]},[x,d,l,n,p]),z=!t&&!!x&&y.length>0;(0,e.useRef)(a);let A=(0,e.useCallback)(a=>{k(a.selectionStart??0)},[]),B=(0,e.useCallback)(d=>{let e=x?.marker??"/",f=`${e}${d.name.slice(1)} `,g=a.slice(0,w.start),h=a.slice(w.end),i=g.length+f.length;b(g+f+h),k(i),requestAnimationFrame(()=>{let a=c.current;a&&(a.focus(),a.setSelectionRange(i,i))})},[a,w,x,b,c]),C=(0,e.useCallback)(a=>{if(a.nativeEvent.isComposing||!z||0===y.length)return!1;let b=()=>{a.preventDefault(),a.stopPropagation()};return"ArrowDown"===a.key?(b(),s(a=>(a+1)%y.length),!0):"ArrowUp"===a.key?(b(),s(a=>(a-1+y.length)%y.length),!0):"Enter"===a.key||"Tab"===a.key?(b(),B(y[r]),!0):"Escape"===a.key&&(b(),u(!0),!0)},[z,y,r,B]);return{isOpen:z,items:y,selectedIndex:r,marker:x?.marker??"/",listRef:v,selectCommand:B,handleKeyDown:C,trackCaret:A}}function k({ac:a,className:b=""}){let{t:c}=(0,f.Bd)(),{isOpen:e,items:g,selectedIndex:h,marker:i,listRef:j,selectCommand:l}=a;return e&&0!==g.length?(0,d.jsx)("div",{ref:j,className:`overflow-y-auto bg-card border border-border rounded-lg shadow-lv2 ${b}`,children:g.map((a,b)=>{let e=b>0?g[b-1]:null,f="skill"===a.source&&(!e||"skill"!==e.source),j="bot"===a.source&&(!e||"bot"!==e.source),k="builtin"===a.source&&0===b;return(0,d.jsxs)("div",{children:[k&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Commands"}),f&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Skills"}),j&&(0,d.jsx)("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-muted/40",children:"Bots"}),(0,d.jsxs)("div",{onClick:()=>l(a),className:`px-4 py-2 cursor-pointer ${b===h?"bg-brand/10":"hover:bg-hover"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"font-mono text-sm font-medium text-foreground",children:i+a.name.slice(1)}),(0,d.jsx)("span",{className:"flex-1 text-sm text-muted-foreground truncate",children:"builtin"===a.source?c(`commands.${a.name.slice(1)}`,{defaultValue:a.description}):a.description}),(0,d.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${(a=>{switch(a){case"builtin":return"bg-brand/15 text-brand dark:bg-brand/25 dark:text-teal-11";case"skill":return"bg-purple-9/15 text-purple-11 dark:bg-purple-9/25 dark:text-purple-11";case"bot":return"bg-teal-9/15 text-teal-11 dark:bg-teal-9/25 dark:text-teal-11"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return c("common.builtin");case"skill":return"Skill";case"bot":return"Bot"}})(a.source)})]}),"skill"===a.source&&a.argumentHint&&(0,d.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 pl-0 truncate",children:a.argumentHint})]})]},a.name)})}):null}},72399:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectSidebar.tsx","ProjectSidebar")},72529:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(48249),e=c(67484);function f({content:a,children:b,className:c}){if(c)return(0,d.jsx)("div",{"data-tooltip":a,className:c,children:b});let g=e.Children.toArray(b);if(1===g.length&&(0,e.isValidElement)(g[0])){let b=g[0];return(0,e.cloneElement)(b,{"data-tooltip":a})}return(0,d.jsx)("div",{"data-tooltip":a,style:{display:"contents"},children:b})}},72899:(a,b,c)=>{"use strict";c.d(b,{O:()=>ab});var d=c(48249),e=c(67484),f=c(44384),g=c(10316),h=c(46674),i=c(80600),j=c(69924);c(33281),c(85655),c(87808);var k=c(33982),l=c(34622),m=c(34948),n=c(26875),o=c(87148),p=c(82633);function q({kind:a,qname:b,className:c}){let e=`${(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)(i.A,{className:e});if("__preamble__"===b)return(0,d.jsx)(k.A,{className:e});if(b&&b.startsWith("__heading_"))return(0,d.jsx)(l.A,{className:e});switch(a){case"function":case"method":return(0,d.jsx)(m.A,{className:e});case"class":return(0,d.jsx)(n.A,{className:e});case"interface":return(0,d.jsx)(o.A,{className:e});default:return(0,d.jsx)(p.A,{className:e})}}var r=c(85984),s=c(29939);function t({cwd:a}){let{t:b}=(0,f.Bd)(),[c,g]=(0,e.useState)(null),h=(0,e.useCallback)(b=>{b?.type==="graphProgress"&&b.data&&b.data.cwd===a&&g(b.data)},[a]);(0,s.h)({url:`/ws/watch?cwd=${encodeURIComponent(a)}`,onMessage:h});let i=(0,e.useRef)("");if(c?.currentFile&&(i.current=c.currentFile),!c)return(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:b("blockViewer.fileMode.loading","Loading…")});let j=b(`blockViewer.buildProgress.${c.phase}`,u[c.phase]),k=Math.max(0,Math.min(100,Math.round(c.percent)));return(0,d.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-8",children:(0,d.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-baseline justify-between text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:j}),(0,d.jsx)("span",{className:"tabular-nums",children:"parsing"===c.phase&&c.filesTotal>0?`${c.filesDone} / ${c.filesTotal}`:`${k}%`})]}),(0,d.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:(0,d.jsx)("div",{className:"h-full rounded-full bg-primary transition-[width] duration-150 ease-linear",style:{width:`${k}%`}})}),(0,d.jsx)("div",{className:"h-4 truncate text-left font-mono text-[11px] leading-4 text-muted-foreground/70",dir:"rtl",title:"done"===c.phase?"":i.current,children:"done"===c.phase?"":i.current})]})})}let u={listing:"Listing files…",contexts:"Reading project config…",parsing:"Parsing files",resolving:"Resolving imports…",edges:"Building call graph…",done:"Finishing up…"};var v=c(7031),w=c(74754),x=c(91579),y=c(83768),z=c(36984),A=c(72529);function B({entries:a,onSelect:b,onClear:c}){let{t:e}=(0,f.Bd)();return(0,d.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"function-history-drawer",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,d.jsx)("div",{className:"flex items-center text-xs text-muted-foreground font-mono min-w-0",children:(0,d.jsx)("span",{className:"truncate",children:0===a.length?e("blockViewer.history.title"):`${e("blockViewer.history.title")} \xb7 ${a.length}/15`})}),a.length>0&&(0,d.jsx)(A.m,{content:e("blockViewer.history.clear"),children:(0,d.jsx)("button",{onClick:c,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,d.jsx)(h.A,{className:"w-3 h-3"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===a.length?(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:e("blockViewer.history.empty")}):a.map((a,c)=>{var e;let f;return(0,d.jsx)(A.m,{content:`${a.qname} \xb7 ${a.filePath}`,children:(0,d.jsxs)("button",{onClick:()=>b(a),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:transition-colors group flex items-start gap-1.5",children:[(0,d.jsx)(q,{kind:a.kind??"unknown",qname:a.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:a.name}),(0,d.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(f=(e=a.filePath).lastIndexOf("/"))>=0?e.slice(f+1):e,a.kind&&(0,d.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",a.kind]})]})]})]})},`${a.filePath}::${a.qname}::${c}`)})})]})}function C(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}var D=c(65543);function E({functions:a,counts:b,totalLines:c,currentQname:g,onSelect:h,notIndexed:i,onRebuild:j}){let{t:k}=(0,f.Bd)(),l=(0,e.useMemo)(()=>a.filter(D._),[a]);return(0,d.jsxs)("div",{className:"flex-1 min-h-0 bg-card flex flex-col","data-testid":"file-toc-section",children:[(0,d.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:[k("blockViewer.toc.title"),l.length>0&&` \xb7 ${l.length}`,null!=c&&` \xb7 ${c} ${k("common.lines")}`]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===l.length?i?(0,d.jsxs)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/80 leading-relaxed flex flex-col gap-2",children:[(0,d.jsx)("span",{className:"italic",children:k("blockViewer.toc.notIndexed")}),j&&(0,d.jsx)("button",{type:"button",onClick:j,className:"self-start px-2 py-1 rounded border border-border bg-secondary/60 hover:bg-secondary text-[10px] text-foreground transition-colors",children:k("blockViewer.refresh")})]}):(0,d.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:k("blockViewer.toc.empty")}):l.map(a=>{let c=g===a.qualifiedName,e=b?.get(a.qualifiedName),f=e?[e.in>0&&["in",e.in,"text-amber-11/80"],e.out>0&&["out",e.out,"text-green-11/80"],e.self>0&&["self",e.self,"text-muted-foreground/60"]].filter(Boolean):[];return(0,d.jsx)(A.m,{content:`${a.qualifiedName} \xb7 L${a.startLine}`,children:(0,d.jsxs)("button",{onClick:()=>h(a.qualifiedName,a.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-start gap-1.5 min-w-0 ${c?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,d.jsx)(q,{kind:a.kind,qname:a.qualifiedName,className:"w-3 h-3 flex-shrink-0 mt-0.5"}),(0,d.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:`flex-1 min-w-0 text-xs font-mono truncate ${c?"font-semibold text-brand":""}`,children:a.name}),(0,d.jsx)("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground/50 tabular-nums",children:a.endLine-a.startLine+1})]}),f.length>0&&(0,d.jsx)("span",{className:"block text-[10px] font-mono truncate",children:f.map(([a,b,c],e)=>(0,d.jsxs)("span",{className:c,children:[e>0&&(0,d.jsx)("span",{className:"text-muted-foreground/30",children:" \xb7 "}),a," ",b]},a))})]})]})},a.qualifiedName)})})]})}var F=c(37690),G=c(22341);function H({comments:a,startLine:b,endLine:c,lineHeight:e,bodyTopOffset:f,rowOf:g,onCommentClick:h}){let i=new Map;for(let d of a){if(d.endLine<b||d.endLine>c)continue;let a=i.get(d.endLine);a?a.push(d):i.set(d.endLine,[d])}return 0===i.size?null:(0,d.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(i.entries()).map(([a,c])=>{let i=g?g(a):a-b,j=c[0],k=c.length-1;return(0,d.jsx)(A.m,{content:1===c.length?j.content:`${c.length} comments — click to view`,children:(0,d.jsxs)("button",{onClick:a=>h(j,a),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-lv1 transition-colors",style:{top:`${f+i*e+e/2-8}px`},children:[(0,d.jsx)(G.A,{className:"w-2.5 h-2.5"}),k>0&&(0,d.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:k+1})]})},a)})})}function I(a,b){for(let c=0;c<a.blocks.length;c++){let d=a.blocks[c];if(b>=d.startLine&&b<=d.endLine)return a.prefix[c]+(b-d.startLine)}return null}function J({addedLines:a,blockRanges:b,viewportRange:c,onJumpToLine:f}){let g,h=(0,e.useRef)(null),i=(0,e.useMemo)(()=>(function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[0];for(let a of b){let b=Math.max(0,a.endLine-a.startLine+1);c.push(c[c.length-1]+b)}return{blocks:b,prefix:c,total:c[c.length-1]}})(b),[b]),j=(0,e.useMemo)(()=>{if(i.total<=0||0===a.size)return[];let b=[];for(let c of a){let a=i.blocks.find(a=>c>=a.startLine&&c<=a.endLine);a&&b.push({line:c,qname:a.qname})}b.sort((a,b)=>a.line-b.line);let c=[],d=null;for(let a of b)d&&a.line===d.end+1&&a.qname===d.qname?d.end=a.line:(d&&c.push(d),d={start:a.line,end:a.line,qname:a.qname});return d&&c.push(d),c},[a,i]);if(i.total<=0)return null;let k=(a,b)=>{let c=I(i,a),d=I(i,b);return null===c||null===d?null:{top:c/i.total*100,heightPct:(d-c+1)/i.total*100}};return(0,d.jsxs)("div",{ref:h,onClick:a=>{let b=h.current;if(!b)return;let c=b.getBoundingClientRect();if(c.height<=0)return;let d=function(a,b){if(a.total<=0)return null;let c=Math.max(0,Math.min(a.total-1,b));for(let b=0;b<a.blocks.length;b++){let d=a.prefix[b],e=a.prefix[b+1];if(c>=d&&c<e){let e=a.blocks[b];return{qname:e.qname,line:e.startLine+Math.round(c-d)}}}return null}(i,(a.clientY-c.top)/c.height*i.total);if(!d)return;let e=d.line,g=j.find(a=>a.qname===d.qname&&e>=a.start&&e<=a.end);if(g)return void f(g.qname,e);if(j.length>0){let a=Math.max(2,Math.round(.05*i.total)),b=I(i,e);if(null!==b){let c=null,d=1/0;for(let a of j){let e=I(i,a.start),f=I(i,a.end);if(null===e||null===f)continue;let g=b<e?e-b:b>f?b-f:0;g<d&&(c=a,d=g)}if(c&&d<=a){let a=e<c.start?c.start:e>c.end?c.end:e;f(c.qname,a);return}}}let k=i.blocks.find(a=>a.qname===d.qname);k&&f(k.qname,k.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[j.map(a=>{let b=k(a.start,a.end);return b?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${b.top}%`,height:`${b.heightPct}%`,minHeight:"2px"}},`run:${a.qname}:${a.start}-${a.end}`):null}),c&&c.end>=c.start&&((g=k(c.start,c.end))?(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${g.top}%`,height:`${Math.max(1.2,g.heightPct)}%`}}):null)]})}var K=c(73414),L=c(41051),M=c(42140),N=c(70596);function O(a){let b=a.lastIndexOf("/");return b>=0?a.slice(b+1):a}function P(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}let Q="flex-shrink-0 h-4 leading-4 px-1.5 rounded text-[10px] text-brand hover:bg-brand/10 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent";function R({symbol:a,fileSource:b,hasChange:c,onHighlighted:g,comments:h,onCommentClick:i,addedLines:j,upstream:k,downstream:l,fold:m,onExpandGap:n}){let{resolvedTheme:o}=(0,y.DP)(),{t:p}=(0,f.Bd)(),r=(0,v.r)(),s=(k?.length??0)+(l?.length??0)>0;(0,e.useMemo)(()=>(0,z.sQ)(a.filePath),[a.filePath]);let[t,u]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),A=(0,e.useMemo)(()=>{if(!t)return null;let b=b=>{let c=t[b-a.startLine]??"",d=j?.has(b)?" bg-green-9/15":"";return`<div class="flex${d}" style="min-width:max-content" data-line="${b}"><span class="select-none pr-3 text-muted-foreground/60 tabular-nums" style="min-width:3.2rem;text-align:right">${b}</span><span class="whitespace-pre">${c}</span></div>`};return m?m.segments.map(a=>{if("gap"===a.kind){var c;let b,d,e;return c=a.startLine,d=P(p("diffViewer.gap.hidden",{count:b=a.endLine-c+1})),e=P(p("diffViewer.gap.expandAll",{count:b})),`<div class="flex items-center cursor-pointer select-none hover:bg-hover" style="min-width:max-content;height:${U}px" data-fold-gap="${c}" title="${e}"><span class="select-none pr-3 text-muted-foreground/40" style="min-width:3.2rem;text-align:right">⋯</span><span class="text-[10px] text-muted-foreground/60 whitespace-pre">${d}</span></div>`}let d="";for(let c=a.startLine;c<=a.endLine;c++)d+=b(c);return d}).join(""):t.map((c,d)=>b(a.startLine+d)).join("")},[t,m,j,a.startLine,p]),B=(0,e.useCallback)(b=>{if(!n)return;let c=b.target,d=c?.closest?.("[data-fold-gap]");if(!d)return;let e=Number(d.getAttribute("data-fold-gap"));Number.isFinite(e)&&n(a.qualifiedName,e)},[n,a.qualifiedName]);return(0,d.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,d.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border text-xs",children:[(0,d.jsx)(q,{kind:a.kind,qname:a.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),!a.qualifiedName.startsWith("__code_")&&(0,d.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,d.jsx)("span",{className:"font-medium",children:a.name}),void 0!==a.params&&(0,d.jsxs)("span",{className:"text-muted-foreground/80",children:["(",a.params.join(", "),")"]})]}),(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:["unknown"!==a.kind&&`${a.kind} \xb7 `,a.endLine-a.startLine+1," ",p("common.lines")]}),r&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>r.sendMessage(p("explain.symbolMessage",{name:a.name,path:a.filePath,lines:`${a.startLine}-${a.endLine}`})),disabled:r.isLoading,title:r.isLoading?p("comments.aiResponding"):void 0,className:Q,children:p("explain.action")}),s&&(0,d.jsx)("button",{onClick:()=>r.sendMessage(p("deps.symbolMessage",{name:a.name,path:a.filePath,lines:`${a.startLine}-${a.endLine}`,...function(a,b,c){let d=a=>{switch(a.kind){case"cross":case"self":return`${a.external.name} (${a.external.filePath})`;case"method":return`${a.receiverName}.${a.methodName}()`;case"ext":return null}},e=a=>{let b=a.map(d).filter(a=>null!==a);return b.length?b.join(", "):c},f=new Map;for(let a of b){if("ext"!==a.kind)continue;let b=f.get(a.packageSpec);b?b.push(a.name):f.set(a.packageSpec,[a.name])}let g=[...f].map(([a,b])=>`${a} (${b.join(", ")})`);return{callers:e(a),callees:e(b),externals:g.length?g.join("; "):c}}(k??[],l??[],p("deps.none"))})),disabled:r.isLoading,title:r.isLoading?p("comments.aiResponding"):void 0,className:Q,children:p("deps.action")})]}),(0,d.jsx)("span",{className:"flex-1"}),c&&(0,d.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,d.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${U}px`},onClick:B,children:[!b&&(0,d.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),w&&(0,d.jsx)("span",{className:"text-red-11",children:w}),A&&(0,d.jsx)("div",{dangerouslySetInnerHTML:{__html:A}})]}),h&&h.length>0&&i&&(0,d.jsx)(H,{comments:h,startLine:a.startLine,endLine:a.endLine,lineHeight:U,bodyTopOffset:V+W,rowOf:m?.rowOf,onCommentClick:i})]})}function S({side:a,pin:b,accent:c,onClick:e}){let f,g,h,i,j,k,l,m=b.lines.length;"ext"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="ext",h="text-muted-foreground/60",i=b.name,j=b.packageSpec,k="external",l=b.packageSpec):"method"===b.kind?(f="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",g="method",h="text-muted-foreground/60",i=`${b.receiverName}.${b.methodName}`,j=null,k="method (unresolved)",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):"self"===b.kind?(f="bg-secondary/40 border-border hover:border-muted-foreground",g="self",h="text-muted-foreground/70",i=b.external.name,j=null,k="same-file",l=m>0?`at line${m>1?"s":""} ${b.lines.join(", ")}`:""):(f="in"===a?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",g=a,h="in"===a?"text-amber-11":"text-green-11",i=b.external.name,j=O(b.external.filePath),k="in"===a?"caller":"callee",l=b.external.filePath);let n=c&&"ext"!==b.kind&&"method"!==b.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),e()},className:`${f}${n} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors block`,"data-tooltip":`${k} \xb7 ${i}${l?" \xb7 "+l:""}`,children:(0,d.jsxs)("span",{className:"block h-[26px] leading-[13px] overflow-hidden",children:[(0,d.jsx)("span",{className:`${h} float-left mr-1.5 text-[9px] uppercase tracking-wider font-semibold`,children:g}),(j||m>1)&&(0,d.jsxs)("span",{className:"float-right clear-both ml-1.5 max-w-[60%] truncate text-muted-foreground/70",children:[j,m>1&&(0,d.jsxs)("span",{className:"text-muted-foreground/60",children:[j?" ":"","\xb7",m,"\xd7"]})]}),(0,d.jsx)("span",{className:"font-medium break-all",children:i})]})})}let T="w-44 @min-[900px]:w-52 @min-[1100px]:w-60 @min-[1400px]:w-72 @min-[1800px]:w-80 @min-[2400px]:w-96",U=18,V=29,W=8;function X(a,b){switch(b.kind){case"cross":return`${a}:x:${b.external.filePath}::${b.external.qualifiedName}`;case"self":return`${a}:s:${b.external.filePath}::${b.external.qualifiedName}`;case"ext":return`${a}:e:${b.packageSpec}::${b.name}`;case"method":return`${a}:m:${b.receiverName}::${b.methodName}`}}function Y(a,b){return"ext"!==a.kind&&"method"!==a.kind&&(b?.has(a.external.qualifiedName)??!1)}function Z(a){return{filePath:a.filePath,qname:a.qualifiedName,name:a.name,kind:a.kind}}function $({symbol:a,fileSource:b,hasChange:c,upstream:e,downstream:f,onPinClick:g,onHighlighted:h,comments:i,onCommentClick:j,accentQnames:k,addedLines:l,fold:m,onExpandGap:n}){let o=function(a,b,c){if(0===a.length)return[];let d=a.map((a,c)=>{var d,e;return{i:c,line:(d=a.lines[0]??b.startLine,e=b.startLine,Math.max(e,Math.min(b.endLine,d)))}});d.sort((a,b)=>a.line-b.line||a.i-b.i);let e=Array(a.length).fill(0),f=-1/0;for(let{i:a,line:g}of d){let d=Math.max(V+W+(c?c.rowOf(g):g-b.startLine)*U,f);e[a]=d,f=d+34}return e}(f,a,m);return(0,d.jsxs)("div",{"data-block-qname":a.qualifiedName,"data-start-line":a.startLine,"data-end-line":a.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,d.jsx)("div",{className:`${T} flex-shrink-0 flex flex-col gap-1 pt-1`,children:0===e.length?(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):e.map(b=>(0,d.jsx)(S,{side:"in",pin:b,accent:Y(b,k),onClick:()=>g(b,a)},X("in",b)))}),(0,d.jsx)(R,{symbol:a,fileSource:b,hasChange:c,onHighlighted:h,comments:i,onCommentClick:j,addedLines:l,upstream:e,downstream:f,fold:m,onExpandGap:n}),(0,d.jsx)("div",{className:`${T} flex-shrink-0 relative`,children:0===f.length?(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):f.map((b,c)=>(0,d.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${o[c]}px`},children:(0,d.jsx)(S,{side:"out",pin:b,accent:Y(b,k),onClick:()=>g(b,a)})},X("out",b)))})]})}function _({cwd:a,onSelect:b,onClose:c}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)({files:[],symbols:[]}),[n,o]=(0,e.useState)(0),[p,q]=(0,e.useState)(!1),r=(0,e.useMemo)(()=>[...l.files,...l.symbols],[l]),s=(0,e.useCallback)(a=>{if("Escape"===a.key)return void c();if(0!==r.length){if("ArrowDown"===a.key)a.preventDefault(),o(a=>Math.min(a+1,r.length-1));else if("ArrowUp"===a.key)a.preventDefault(),o(a=>Math.max(a-1,0));else if("Enter"===a.key){a.preventDefault();let c=r[n];c&&b(c)}}},[r,n,c,b]);return(0,d.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:c,children:(0,d.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-lv3 overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,d.jsx)(g.A,{className:"w-4 h-4 text-muted-foreground"}),(0,d.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),onKeyDown:s,placeholder:i("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),p&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,d.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground",children:(0,d.jsx)(h.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===r.length&&j&&!p&&(0,d.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:i("blockViewer.search.noResults","No matches")}),(0,d.jsx)(aa,{label:i("blockViewer.search.files","Files"),hits:l.files,startIdx:0,activeIdx:n,onSelect:b,setActive:o}),(0,d.jsx)(aa,{label:i("blockViewer.search.symbols","Symbols"),hits:l.symbols,startIdx:l.files.length,activeIdx:n,onSelect:b,setActive:o})]})]})})}function aa({label:a,hits:b,startIdx:c,activeIdx:e,onSelect:f,setActive:g}){return 0===b.length?null:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:a}),b.map((a,b)=>{let h=c+b,j=h===e;return(0,d.jsxs)("button",{onMouseEnter:()=>g(h),onClick:()=>f(a),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${j?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===a.type?(0,d.jsx)(i.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,d.jsx)(q,{kind:a.target.kind,qname:a.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,d.jsx)("span",{className:"font-mono truncate",children:a.label}),a.hint&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:a.hint})]})]},`${a.type}:${a.label}:${b}`)})]})}function ab({cwd:a,highlightedFilePath:b,changedFiles:c,onSwitchToCode:g,enableComments:h=!1,onContentSearch:i,onFocalChange:j,qnameFilter:k,qnameFilterFile:l,accentQnames:m,accentFile:n,addedLines:o,addedLinesFile:p,compact:q=!1,headerExtraLeft:s,headerExtraRight:u}){let{t:y}=(0,f.Bd)(),[z,A]=(0,e.useState)("toc"),[D,G]=(0,e.useState)(null),H=D??b??null,{state:I,refresh:P}=(0,r.V)(a,H),[Q,R]=(0,e.useState)(null),S=(0,e.useMemo)(()=>Q?Q.content.split("\n").length:null,[Q]);(0,e.useRef)(null);let[U,V]=(0,e.useState)([]),[W,X]=(0,e.useState)(!1),[Y,aa]=(0,e.useState)(null),ae=(0,e.useRef)(0);(0,e.useRef)(0);let[af,ag]=(0,e.useState)(()=>new Set);"ready"===I.state&&I.data.filePath;let ah=(0,e.useCallback)(a=>{ag(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c})},[]),ai=(0,e.useCallback)((a,b)=>{if("ext"===a.kind||"method"===a.kind){let a=b.filePath;if(!a)return;ae.current+=1,aa({filePath:a,qname:"__imports__",nonce:ae.current});return}let c=Z(b),d=Z(a.external);V(a=>C(C(a,c),d)),G(d.filePath),ae.current+=1,aa({filePath:d.filePath,qname:d.qname,nonce:ae.current})},[]),aj=(0,e.useCallback)(a=>{G(a.filePath),ae.current+=1,aa({filePath:a.filePath,qname:a.qname,nonce:ae.current})},[]),ak=(0,e.useCallback)(a=>{X(!1),G(a.target.filePath),"symbol"===a.type&&(ae.current+=1,aa({filePath:a.target.filePath,qname:a.target.qualifiedName,line:a.target.startLine,nonce:ae.current}))},[]),al=(0,e.useCallback)((a,b)=>{H&&(ae.current+=1,aa({filePath:H,qname:a,line:b,nonce:ae.current}))},[H]),[am,an]=(0,e.useState)(()=>new Set),ao=(0,e.useCallback)((a,b)=>{an(c=>{let d=new Set(c);return d.add(`${H}#${a}#${b}`),d})},[H]),[ap,aq]=(0,e.useState)(null),[ar,as]=(0,e.useState)(null),at=(0,e.useMemo)(()=>{if("ready"!==I.state||!ar)return null;let a=I.data.functions;if(0===a.length)return null;let b=(ar.start+ar.end)/2;for(let c of a)if(c.startLine<=b&&b<=c.endLine)return c.qualifiedName;let c=null;for(let b of a)b.startLine<=ar.start&&(!c||b.startLine>c.startLine)&&(c=b);return c?.qualifiedName??null},[I,ar]),au=h&&!!a&&!!H,av=(0,v.r)(),{comments:aw,addComment:ax,updateComment:ay,deleteComment:az,refresh:aA}=(0,w._)({cwd:a,filePath:H??""}),[aB,aC]=(0,e.useState)(null),{toolbarRef:aD,bumpRef:aE,clearToolbar:aF}=(0,F.L)({enabled:au,container:aB,resolveLineRange:a=>{if(!document.contains(a))return null;let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a,c=b?.closest("[data-line]");if(!c||!aB||!aB.contains(c))return null;let d=c.getAttribute("data-line");if(!d)return null;let e=parseInt(d,10);return Number.isFinite(e)?{start:e,end:e}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Q?.content;return c?c.split("\n").slice(a-1,b).join("\n"):""}}),[aG,aH]=(0,e.useState)(null),[aI,aJ]=(0,e.useState)(null),[aK,aL]=(0,e.useState)(null),aM=(0,e.useCallback)(()=>{let a=aD.current;a&&(aH({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aF())},[aF,aD]),aN=(0,e.useCallback)(()=>{let a=aD.current;a&&(aJ({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aF())},[aF,aD]),aO=(0,e.useCallback)(()=>{let a=aD.current;a&&av&&H&&(aF(),(0,x.Ff)(av.sendMessage,{filePath:H,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},y("explain.selectionMessage")))},[av,H,aF,aD,y]),aP=(0,e.useCallback)(()=>{let a=aD.current;if(!a||!i)return;let b=a.selectedText.trim();aF(),b&&i(b)},[i,aF,aD]),aQ=(0,e.useCallback)(async a=>{aG&&(await ax(aG.range.start,aG.range.end,a,aG.selectedText),aH(null))},[aG,ax]),aR=(0,e.useCallback)(async(b,c)=>{if(av&&a&&H)try{let d=(await (0,x.$3)(a)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));d.push({filePath:H,startLine:b.range.start,endLine:b.range.end,codeContent:b.lineSnapshot});let e=(0,x.Gw)(d,c);av.sendMessage(e),await (0,x.RP)(a),aA()}catch(a){console.error("[BlockViewer] send to AI failed:",a)}},[av,a,H,aA]),aS=(0,e.useCallback)(a=>{aI&&aR(aI,a)},[aI,aR]),aT=(0,e.useCallback)(a=>{aG&&aR(aG,a)},[aG,aR]),aU=(0,e.useCallback)((a,b)=>{b.stopPropagation(),aL({comment:a,x:b.clientX,y:b.clientY}),aF(),aH(null),aJ(null)},[aF]);if(!H)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:null,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,refreshDisabled:!0,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,d.jsx)("span",{children:y("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,d.jsx)("span",{className:"text-xs",children:y("blockViewer.empty.hint","or press ⌘K to search.")})]}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]});if("idle"===I.state||"loading"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,refreshDisabled:!0,extraLeft:s,extraRight:u}),(0,d.jsx)(t,{cwd:a})]});if("notFound"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:y("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]});if("error"===I.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:null,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,d.jsx)("span",{className:"text-red-11",children:I.message}),(0,d.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:y("blockViewer.retry","Retry")})]})]});let aV=I.data,aW=aV.functions;if(0===aW.length&&Q){let a=Math.max(1,S??1);aW=[{filePath:aV.filePath,qualifiedName:"__file__",name:O(aV.filePath),kind:"unknown",startLine:1,endLine:a}]}let aX=l&&l===aV.filePath,aY=n&&n===aV.filePath,aZ=p&&p===aV.filePath;aX&&k&&(aW=aW.filter(a=>k.has(a.qualifiedName)));let a$=aY?m:void 0,a_=aZ?o:void 0,a0=new Map;if(q&&a_)for(let a of aW)a0.set(a.qualifiedName,function(a,b,c,d,e=K.aj){if(b<a)return null;let f=[];for(let d of c)d>=a&&d<=b&&f.push(d);f.sort((a,b)=>a-b);let g=[];for(let c of f){let d=Math.max(a,c-e),f=Math.min(b,c+e),h=g[g.length-1];h&&d<=h.endLine+1?f>h.endLine&&(h.endLine=f):g.push({startLine:d,endLine:f})}let h=[],i=a;for(let a of g)a.startLine>i&&h.push({startLine:i,endLine:a.startLine-1}),i=a.endLine+1;i<=b&&h.push({startLine:i,endLine:b});let j=[],k=[];for(let a of h)a.endLine-a.startLine+1<2||d(a.startLine)?k.push(a):j.push(a);if(0===j.length)return null;g=function(a){let b=[...a].sort((a,b)=>a.startLine-b.startLine),c=[];for(let a of b){let b=c[c.length-1];b&&a.startLine<=b.endLine+1?a.endLine>b.endLine&&(b.endLine=a.endLine):c.push({...a})}return c}([...g,...k]);let l=[];for(let a of[...g.map(a=>({kind:"lines",...a})),...j.map(a=>({kind:"gap",...a}))].sort((a,b)=>a.startLine-b.startLine))l.push(a);let m=[],n=0;for(let a of l)m.push(n),n+="gap"===a.kind?1:a.endLine-a.startLine+1;let o=n;return{segments:l,visibleRuns:g,hiddenCount:j.reduce((a,b)=>a+(b.endLine-b.startLine+1),0),rowOf:b=>{for(let a=0;a<l.length;a++){let c=l[a];if(b<c.startLine)break;if(b<=c.endLine)return"gap"===c.kind?m[a]:m[a]+(b-c.startLine)}return b<a?0:Math.max(0,o-1)}}}(a.startLine,a.endLine,a_,b=>am.has(`${aV.filePath}#${a.qualifiedName}#${b}`)));let a1=ac(aV.upstreamCalls),a2=ac(aV.downstreamCalls),a3=new Map(aW.map(a=>[a.qualifiedName,a])),a4=new Map,a5=new Map;for(let a of aV.intraCalls){let b=a3.get(a.to),c=a3.get(a.from);if(b){let c=a4.get(a.from),d={kind:"self",external:b,lines:a.lines};c?c.push(d):a4.set(a.from,[d])}if(c){let b=a5.get(a.to),d={kind:"self",external:c,lines:a.lines};b?b.push(d):a5.set(a.to,[d])}}let a6=new Map;for(let a of aV.externalCalls??[]){let b=a6.get(a.focalQname),c={kind:"ext",name:a.external.name,packageSpec:a.external.packageSpec,lines:a.lines};b?b.push(c):a6.set(a.focalQname,[c])}let a7=new Map;for(let a of aV.methodCalls??[]){let b=a7.get(a.focalQname),c={kind:"method",receiverName:a.receiverName,methodName:a.methodName,lines:a.lines};b?b.push(c):a7.set(a.focalQname,[c])}let a8=new Map;for(let a of aW){let b=a.qualifiedName,c={in:a1.get(b)?.length??0,out:a2.get(b)?.length??0,self:(a5.get(b)?.length??0)+(a4.get(b)?.length??0)};(c.in||c.out||c.self)&&a8.set(b,c)}let a9=c.has(aV.filePath);return(0,d.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,d.jsx)(ad,{focalFile:H,fileCount:aV.fileCount,functionCount:aV.functions.length,upstreamCount:aV.upstreamCalls.length,downstreamCount:aV.downstreamCalls.length,onSwitchToCode:g,onSearch:()=>X(!0),onRefresh:P,extraLeft:s,extraRight:u}),(0,d.jsxs)("div",{ref:aC,className:"@container flex-1 relative min-h-0 flex",children:[(0,d.jsxs)("div",{className:`${T} flex-shrink-0 border-r border-border flex flex-col`,children:[(0,d.jsx)("div",{className:"flex-shrink-0 flex border-b border-border",children:[["toc",y("blockViewer.tabs.toc")],["history",y("blockViewer.tabs.history")]].map(([a,b])=>(0,d.jsx)("button",{onClick:()=>A(a),className:`flex-1 px-2 py-1.5 text-xs font-medium transition-colors ${z===a?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground"}`,children:b},a))}),(0,d.jsx)("div",{className:"toc"===z?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(E,{functions:aW,counts:a8,totalLines:S,currentQname:at,onSelect:al,notIndexed:aV.notIndexed,onRebuild:P})}),(0,d.jsx)("div",{className:"history"===z?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(B,{entries:U,onSelect:aj,onClear:()=>V([])})})]}),(0,d.jsx)("div",{ref:aq,className:"@container flex-1 min-w-0 overflow-auto",children:(0,d.jsx)("div",{className:"flex flex-col gap-3 p-3",children:aW.map(a=>{let b,c,e,f,g,h;return(0,d.jsx)($,{symbol:a,fileSource:Q?.content??null,hasChange:a9,upstream:(b=a1.get(a.qualifiedName),c=a5.get(a.qualifiedName),[...(b??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...c??[]]),downstream:(e=a2.get(a.qualifiedName),f=a4.get(a.qualifiedName),g=a7.get(a.qualifiedName),h=a6.get(a.qualifiedName),[...(e??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...f??[],...g??[],...h??[]]),onPinClick:ai,onHighlighted:ah,comments:au?aw:void 0,onCommentClick:au?aU:void 0,accentQnames:a$,addedLines:a_,fold:a0.get(a.qualifiedName),onExpandGap:ao},`${a.qualifiedName}#${a.startLine}`)})})}),au&&aB&&(0,d.jsx)(L.fS,{floatingToolbarRef:aD,bumpRef:aE,container:aB,onAddComment:aM,onSendToAI:aN,onSearch:i?aP:void 0,onExplain:av&&H?aO:void 0,isChatLoading:av?.isLoading}),au&&aG&&(0,d.jsx)(M.t,{x:aG.x,y:aG.y,range:aG.range,filePath:H??void 0,lineSnapshot:aG.lineSnapshot,container:aB,onSubmit:aQ,onSendToAI:av&&H?aT:void 0,onClose:()=>aH(null),isChatLoading:av?.isLoading}),au&&aI&&H&&(0,d.jsx)(M.G,{x:aI.x,y:aI.y,range:aI.range,filePath:H,lineSnapshot:aI.lineSnapshot,container:aB,onSubmit:aS,onClose:()=>aJ(null),isChatLoading:av?.isLoading}),au&&aK&&(0,d.jsx)(N.t,{x:aK.x,y:aK.y,comment:aK.comment,container:aB,onClose:()=>aL(null),onUpdateComment:ay,onDeleteComment:az}),a_&&a_.size>0&&aW.length>0&&(0,d.jsx)(J,{addedLines:a_,blockRanges:aW.flatMap(a=>{let b=a0.get(a.qualifiedName);return b?b.visibleRuns.map(b=>({qname:a.qualifiedName,startLine:b.startLine,endLine:b.endLine})):[{qname:a.qualifiedName,startLine:a.startLine,endLine:a.endLine}]}),viewportRange:ar,onJumpToLine:al}),W&&(0,d.jsx)(_,{cwd:a,onSelect:ak,onClose:()=>X(!1)})]})]})}function ac(a){let b=new Map;for(let c of a){let a=b.get(c.focalQname);if(!a){b.set(c.focalQname,[c]);continue}a.some(a=>a.external.filePath===c.external.filePath&&a.external.qualifiedName===c.external.qualifiedName)||a.push(c)}return b}function ad({focalFile:a,fileCount:b,functionCount:c,upstreamCount:e,downstreamCount:h,onSwitchToCode:i,onSearch:k,onRefresh:l,refreshDisabled:m,extraLeft:n,extraRight:o}){let{t:p}=(0,f.Bd)(),q={focalFile:a,blockCount:c??0,upstreamCount:e??0,downstreamCount:h??0};return(0,d.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,d.jsx)("span",{className:"truncate min-w-0",children:a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-foreground",children:a}),"number"==typeof c&&(0,d.jsxs)("span",{className:"ml-2",children:["\xb7 ",c," blocks"]}),"number"==typeof e&&"number"==typeof h&&(0,d.jsxs)("span",{className:"ml-2",children:["\xb7 ",e," in \xb7 ",h," out"]})]}):(0,d.jsx)("span",{children:null!==b?`${b} files`:"…"})}),n&&(0,d.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:n(q)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o&&(0,d.jsx)("span",{className:"flex items-center gap-1",children:o(q)}),(0,d.jsxs)("button",{onClick:k,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":p("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,d.jsx)(g.A,{className:"w-3 h-3"})," ⌘K"]}),(0,d.jsx)("button",{onClick:l,disabled:m,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":p("blockViewer.refresh","Rebuild project graph"),children:(0,d.jsx)(j.A,{className:"w-3 h-3"})}),i&&(0,d.jsx)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:p("common.code","Code")})]})]})}},73414:(a,b,c)=>{"use strict";c.d(b,{YO:()=>e,aj:()=>d,pU:()=>f});let d=3,e=20;function f(a,b,c,g=[]){let h=a.length,i=c=>"unchanged"!==a[c].type||"unchanged"!==b[c].type,j=new Set;for(let a=0;a<h;a++){if(!i(a))continue;let b=Math.max(0,a-d),c=Math.min(h-1,a+d);for(let a=b;a<=c;a++)j.add(a)}let k=[];for(let a=0;a<h;a++){if(j.has(a))continue;let b=a;for(;a<h&&!j.has(a);)a++;k.push({id:k.length,startIdx:b,endIdx:a-1}),a--}for(let a of k){let b=c.get(a.id)??{topRevealed:0,bottomRevealed:0},d=a.endIdx-a.startIdx+1,e=Math.max(0,Math.min(b.topRevealed,d)),f=Math.max(0,Math.min(b.bottomRevealed,d-e));for(let b=a.startIdx;b<a.startIdx+e;b++)j.add(b);for(let b=a.endIdx-f+1;b<=a.endIdx;b++)j.add(b)}let l=[];for(let a=0;a<h;a++){let c;if(j.has(a)){l.push({kind:"diff",idx:a});continue}let d=a;for(;a<h&&!j.has(a);)a++;let f=a-1;a--;let i=k.find(a=>a.startIdx<=d&&f<=a.endIdx);if(!i)continue;let m=f-d+1,n=Math.min(e,m);if(g.length>0&&f+1<h)for(let a=f+1;a<h;a++){let d=b[a].lineNum;if(!(d<=0)){c=function(a,b){let c=null;for(let d of a)d.startLine<=b&&b<=d.endLine&&(!c||d.endLine-d.startLine<c.endLine-c.startLine)&&(c=d);return c}(g,d)??void 0;break}}l.push({kind:"gap-expand",gapId:i.id,direction:"up",revealCount:n}),l.push({kind:"gap-label",gapId:i.id,hiddenCount:m,enclosingFn:c}),l.push({kind:"gap-expand",gapId:i.id,direction:"down",revealCount:n})}return{rows:l,gaps:k}}},73887:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{M:()=>B});var e=c(48249),f=c(67484),g=c(44384),h=c(64825),i=c(74429),j=c(7122),k=c(7833),l=c(41051),m=c(42140),n=c(70596),o=c(74754),p=c(7031),q=c(91579),r=c(208),s=c(5900),t=c(64676),u=c(84835);c(15466);var v=c(60591),w=c(59865),x=c(93321),y=c(24680),z=c(92608),A=c(37690);let a=[u.W];function B({content:b,filePath:c,cwd:d,onClose:u,sourceFile:C,embedded:D=!1,onLocalMdLink:E,scrollToAnchor:F}){let G=C||(d&&c.startsWith(d)?c.slice(d.endsWith("/")?d.length:d.length+1):c),{t:H}=(0,g.Bd)(),I=(0,j.iN)(),J=(0,p.r)(),K=(0,w.U)(),L=(0,x.Q)(),{comments:M,addComment:N,updateComment:O,deleteComment:P,refresh:Q}=(0,o._)({cwd:d,filePath:c}),[R,S]=(0,f.useState)(!1),[T,U]=(0,f.useState)(null),[V,W]=(0,f.useState)(null),[X,Y]=(0,f.useState)(null),Z=(0,f.useMemo)(()=>b.split("\n"),[b]),$=(0,f.useMemo)(()=>(0,t.J4)(c,d),[c,d]),[_,aa]=(0,f.useState)(null),ab=(0,f.useRef)(null),ac=(0,f.useRef)({onLocalMdLink:E,sourceFile:G});ac.current={onLocalMdLink:E,sourceFile:G};let ad=(0,f.useRef)(a=>{let{onLocalMdLink:b,sourceFile:c}=ac.current;if(!b||/^[a-z][a-z0-9+.-]*:/i.test(a))return!1;let d=a.indexOf("#"),e=d>=0?a.slice(0,d):a,f=d>=0?a.slice(d+1):null;if(!e)return!1;let g=e;try{g=decodeURIComponent(e)}catch{}return!!(0,v.e$)(g)&&(b((0,v.WU)(c,g),f),!0)}).current,{toolbarRef:ae,bumpRef:af,clearToolbar:ag}=(0,A.L)({enabled:!0,container:_,resolveLineRange:a=>{let b=function(a){let b=a.nodeType===Node.TEXT_NODE?a.parentElement:a;if(!b||!("closest"in b))return null;let c=b.closest("[data-source-start]");if(!c)return null;let d=c.getAttribute("data-source-start"),e=c.getAttribute("data-source-end");return d&&e?{start:parseInt(d,10),end:parseInt(e,10)}:null}(a);return b?{start:b.start,end:b.end}:null},buildLineSnapshot:({start:a,end:b})=>{let c=Math.max(0,a-1),d=Math.min(Z.length,b);return Z.slice(c,d).join("\n")}}),ah=(0,f.useCallback)(()=>{let a=ae.current;a&&(U({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ag())},[ag,ae]),ai=(0,f.useCallback)(()=>{let a=ae.current;a&&(W({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ag())},[ag,ae]),aj=(0,f.useCallback)(()=>{let a=ae.current;a&&J&&(ag(),(0,q.Ff)(J.sendMessage,{filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},r.A.t("explain.selectionMessage")))},[J,c,ag,ae]),ak=(0,f.useCallback)(async a=>{T&&(await N(T.range.start,T.range.end,a,T.selectedText),U(null))},[T,N]),al=(0,f.useCallback)(async(a,b)=>{if(J)try{let e=await (0,q.$3)(d),f=[];for(let a of e)f.push({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0});f.push({filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot});let g=(0,q.Gw)(f,b);J.sendMessage(g),await (0,q.RP)(d),Q()}catch(a){console.error("Failed to send to AI:",a)}},[J,c,d,Q]),am=(0,f.useCallback)(a=>{V&&al(V,a)},[V,al]),an=(0,f.useCallback)(a=>{T&&al(T,a)},[T,al]);(0,f.useMemo)(()=>{if(0===M.length)return[];let a=new Map;for(let b of M){let c=`${b.startLine}-${b.endLine}`;a.has(c)||a.set(c,[]),a.get(c).push(b)}return Array.from(a.entries()).map(([a,b])=>({key:a,startLine:b[0].startLine,endLine:b[0].endLine,comments:b}))},[M]);let[ao,ap]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[!D&&(0,e.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-brand transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":c,onClick:()=>{navigator.clipboard.writeText(c),(0,k.oR)(H("common.copiedPath"))},children:["‎",c]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(z.ShareReviewToggle,{content:b,sourceFile:G}),((0,v.C_)(c)||(0,v.OG)(c))&&(0,e.jsx)("button",{onClick:()=>{let a=c.startsWith("/")||!d?c:`${d.replace(/\/$/,"")}/${c}`;(0,v.OG)(c)?L(a):K(a)},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:H((0,v.OG)(c)?"bots.addTooltip":"skills.addTooltip"),children:(0,e.jsx)(h.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:u,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:H("common.close"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,e.jsx)(y.l,{content:b,containerRef:ab}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:ab,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(s.T,{content:b,basePath:$,rehypePlugins:a,onLinkClick:ad})}),ao.map(({key:a,top:b,comments:c})=>(0,e.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:b},onClick:a=>{a.stopPropagation(),Y({comment:c[0],x:a.clientX,y:a.clientY})},children:(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-lv1 hover:bg-amber-500 transition-colors",children:c.length})},a))]})]}),R&&I&&(0,i.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.fS,{floatingToolbarRef:ae,bumpRef:af,container:I,onAddComment:ah,onSendToAI:ai,onExplain:J?aj:void 0,isChatLoading:J?.isLoading}),T&&(0,e.jsx)(m.t,{x:T.x,y:T.y,range:T.range,filePath:c,lineSnapshot:T.lineSnapshot,container:I,onSubmit:ak,onSendToAI:J?an:void 0,onClose:()=>U(null),isChatLoading:J?.isLoading}),V&&(0,e.jsx)(m.G,{x:V.x,y:V.y,range:V.range,filePath:c,lineSnapshot:V.lineSnapshot,container:I,onSubmit:am,onClose:()=>W(null),isChatLoading:J?.isLoading}),X&&(0,e.jsx)(n.t,{x:X.x,y:X.y,comment:X.comment,container:I,onClose:()=>Y(null),onUpdateComment:O,onDeleteComment:P})]}),I)]})}d()}catch(a){d(a)}})},74228:(a,b,c)=>{"use strict";c.d(b,{S:()=>g,l:()=>h});var d=c(48249),e=c(40311),f=c(41233);function g(a){return"loading"===a||"unread"===a?a:"normal"}function h({projectNumber:a,sessionNumber:b,coordinate:c,status:g="normal",statusLabel:i,bot:j,className:k=""}){if(c){let[d,e]=c.split(".");a??=d,b??=e}if(null==a&&null==b&&"normal"!==g&&(b="\xb7"),null==a&&null==b)return null;let l=[a,b].filter(a=>null!=a).join(".");return(0,d.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[9px] font-medium leading-none tabular-nums flex-shrink-0 ${k}`,"aria-label":i?`${l} \xb7 ${i}`:l,children:[null!=a&&(0,d.jsx)("span",{className:`flex h-4 w-4 items-center justify-center border rounded-[4px] ${(0,e.ci)("normal",!1)}`,children:a}),null!=b&&(0,d.jsx)(f.w,{wash:(0,e.JQ)(g,!1),ring:(0,e.QV)(g),bot:j,title:i,children:b})]})}},74542:(a,b,c)=>{"use strict";c.d(b,{b:()=>f});var d=c(48249),e=c(67484);function f({lines:a,containerRef:b}){let c=(0,e.useRef)(null),[g,h]=(0,e.useState)({top:0,height:0});if(0===a.length)return null;let i=100/a.length;return(0,d.jsxs)("div",{ref:c,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:a=>{let d=b.current,e=c.current;if(!d||!e)return;let f=e.getBoundingClientRect(),g=(a.clientY-f.top)/f.height*d.scrollHeight-d.clientHeight/2;d.scrollTo({top:Math.max(0,g),behavior:"smooth"})},children:[a.map((a,b)=>"unchanged"!==a.type&&(0,d.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===a.type?"bg-red-9":"bg-green-9"}`,style:{top:`${b*i}%`,height:`${Math.max(i,.5)}%`,minHeight:"2px"}},b)),(0,d.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${g.top}px`,height:`${Math.max(g.height,10)}px`}})]})}},74691:(a,b,c)=>{"use strict";c.d(b,{y:()=>f});var d=c(48249),e=c(44384);function f({value:a,onChange:b,className:c}){let{t:g}=(0,e.Bd)();return(0,d.jsx)("div",{className:`flex items-center gap-0.5 rounded border border-border overflow-hidden ${c??""}`,children:["compact","full"].map(c=>(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),b(c)},className:`px-2 py-0.5 text-xs transition-colors ${a===c?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:g("compact"===c?"diffViewer.compact":"diffViewer.full")},c))})}},74754:(a,b,c)=>{"use strict";c.d(b,{_:()=>h});var d=c(67484),e=c(91579),f=c(33281),g=c(89800);function h({cwd:a,filePath:b}){let[c,i]=(0,d.useState)([]),[j,k]=(0,d.useState)(!1),[l,m]=(0,d.useState)(null),n=(0,d.useCallback)(async()=>{if(!a||!b)return;k(!0),m(null);let c=await f.t4.runPromiseExit((0,g.lb)(a,b));if("Success"===c._tag)i(c.value.comments??[]);else{let a="Fail"===c.cause._tag?c.cause.error:null,b=a?.cause;m(b instanceof Error?b.message:"Failed to load comments")}k(!1)},[a,b]),o=(0,d.useCallback)(async(c,d,h,j)=>{let k=await f.t4.runPromiseExit((0,g.BC)({cwd:a,filePath:b,startLine:c,endLine:d,content:h,...j?{selectedText:j}:{}}));if("Success"===k._tag&&k.value.comment){let a=k.value.comment;return i(b=>[...b,a]),(0,e.Cm)(),a}return"Failure"===k._tag&&console.error("Failed to add comment:",k.cause),null},[a,b]),p=(0,d.useCallback)(async(b,c)=>{let d=await f.t4.runPromiseExit((0,g.vv)(a,b,c));if("Success"===d._tag&&d.value.comment){let a=d.value.comment;return i(c=>c.map(c=>c.id===b?a:c)),!0}return"Failure"===d._tag&&console.error("Failed to update comment:",d.cause),!1},[a]),q=(0,d.useCallback)(async b=>{let c=await f.t4.runPromiseExit((0,g.Tu)(a,b));return"Success"===c._tag?(i(a=>a.filter(a=>a.id!==b)),(0,e.Cm)(),!0):(console.error("Failed to delete comment:",c.cause),!1)},[a]),r=(0,d.useCallback)(a=>c.filter(b=>a>=b.startLine&&a<=b.endLine),[c]);return{comments:c,isLoading:j,error:l,addComment:o,updateComment:p,deleteComment:q,refresh:n,getCommentsForLine:r}}},74837:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call NoteToolbar() from the server but NoteToolbar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/NoteToolbar.tsx","NoteToolbar")},74991:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{I:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(29588),i=c(7833),j=c(15819);c(33281);var k=c(13054),l=c(30458),m=c(36688),n=c(32753),o=c(74228),p=c(15790);c(41224);var q=a([p,m]);function r(a){return a.engine||"claude"}function s(a){return a.lastFiredAt??a.createdAt}[p,m]=q.then?(await q)():q;let u=[{key:"pendingReview",labelKey:"scheduledTasks.groupPendingReview"},{key:"upcoming",labelKey:"scheduledTasks.groupUpcoming"},{key:"paused",labelKey:"scheduledTasks.paused"}];function t({collapsed:a,tasks:b,unreadCount:c,sessionNumbers:d,onSwitchProject:q,onPause:v,onResume:w,onTrigger:x,onDelete:y,onMarkRead:z,onUpdateTask:A}){let{t:B}=(0,g.Bd)(),[C,D]=(0,f.useState)(!1),[E,F]=(0,f.useState)(null),G=(0,f.useRef)(null),H=(0,f.useRef)(null),[I,J]=(0,f.useState)(null),K=(0,f.useCallback)(()=>{F(null),G.current=null,J(null)},[]),[L,M]=(0,f.useState)(null),[N,O]=(0,f.useState)(null),[P,Q]=(0,f.useState)(null),[R,S]=(0,f.useState)(null),T=b.filter(a=>!a.completed),U=T.filter(a=>!a.paused).length,V=(0,f.useMemo)(()=>(function(a){let b=[],c=[],d=[];for(let e of a)e.unread||e.completed?b.push(e):e.paused?d.push(e):c.push(e);return b.sort((a,b)=>Number(!!b.unread)-Number(!!a.unread)||s(b)-s(a)),c.sort((a,b)=>(a.nextFireTime||Number.MAX_SAFE_INTEGER)-(b.nextFireTime||Number.MAX_SAFE_INTEGER)),d.sort((a,b)=>s(b)-s(a)),{pendingReview:b,upcoming:c,paused:d}})(b),[b]),W=P?b.find(a=>a.id===P)??null:null,[,X]=(0,f.useState)(0),Y=(0,f.useCallback)(()=>{M(null),O(null)},[]),Z=(0,f.useCallback)(async a=>{let b=!!a.taskFile;try{await navigator.clipboard.writeText(b?a.taskFile:a.message),(0,i.oR)(B(b?"common.copiedPath":"toast.copiedMessage"),"success")}catch{(0,i.oR)(B("common.copyFailed"),"error")}},[B]),$=(0,f.useCallback)(()=>{D(!1),Q(null)},[]),_=(0,f.useCallback)(a=>{q(a.cwd,a.sessionId),a.unread&&z(a.id),$()},[q,z,$]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{onClick:()=>D(!0),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-hover transition-colors ${a?"w-full justify-center":"w-full"}`,title:a?B("scheduledTasks.title"):void 0,children:[(0,e.jsx)(h.A,{className:"w-5 h-5 flex-shrink-0"}),!a&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:B("scheduledTasks.title")}),c>0?(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 bg-orange-11/15 text-orange-11 text-xs font-medium rounded-full flex items-center justify-center ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,e.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-popover border border-border",children:b.length}):null]}),C&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:$}),(0,e.jsxs)("div",{className:j.aO,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-3 min-w-0",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:B("scheduledTasks.title")}),T.length>0&&(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[B("scheduledTasks.activeCount",{running:U}),T.length-U>0?` \xb7 ${B("scheduledTasks.pausedCount",{paused:T.length-U})}`:""]})]}),(0,e.jsx)("button",{onClick:$,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 flex min-h-0",children:0===b.length?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:B("scheduledTasks.noScheduledTasks")})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-full md:w-[360px] min-h-0 flex-shrink-0 md:border-r border-border overflow-y-auto",children:(0,e.jsx)("div",{className:"p-3 space-y-4",children:u.map(({key:a,labelKey:b})=>{let c=V[a];return 0===c.length?null:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"sticky top-0 z-10 -mx-3 px-3 py-1 bg-card text-[11px] font-medium text-muted-foreground",children:[B(b)," (",c.length,")"]}),(0,e.jsx)("div",{className:"mt-1 space-y-2",children:c.map(a=>{let b,c;return b=a.id===P,(0,e.jsxs)("div",{onClick:()=>Q(a.id),onMouseLeave:()=>S(b=>b===a.id?null:b),className:`group p-3 rounded border cursor-pointer transition-all hover:border-brand hover:shadow-lv2 ${b?"border-brand bg-brand/5 shadow-lv2":a.unread?"border-brand/40 bg-brand/5":"border-border"} ${a.completed?"opacity-70":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)(n.S,{engine:r(a),tooltip:(c=r(a),a.model?`${c} \xb7 ${a.model}`:c)}),(0,e.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":a.cwd,children:(0,k.P_)(a.cwd)}),(0,e.jsx)(o.l,{coordinate:d?.[`${a.cwd}
731
731
  ${a.sessionId}`]}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0 group-hover:hidden",children:a.completed?B("scheduledTasks.completed"):a.paused?B("scheduledTasks.paused"):B("common.running")}),R===a.id?(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),S(null),y(a.id)},className:"px-2 py-0.5 text-[10px] rounded bg-red-9 text-white hover:bg-red-10",children:B("common.confirm")}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),S(null)},className:"px-2 py-0.5 text-[10px] rounded border border-border text-muted-foreground hover:text-foreground",children:B("common.cancel")})]}):(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.taskFile&&(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),M(a.taskFile)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:B("common.preview"),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)("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"})]})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),Z(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:B(a.taskFile?"common.copyPath":"common.copy"),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)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),x(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:B("scheduledTasks.runNow"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),G.current=b.currentTarget,F(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:B("common.edit"),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"})})}),a.completed?null:a.paused?(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-11",title:B("scheduledTasks.resume"),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:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),v(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-amber-11",title:B("scheduledTasks.pause"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),S(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:B("common.delete"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"text-xs text-foreground line-clamp-3 mb-1 whitespace-pre-wrap break-words","data-tooltip":(0,k.Q_)(a),children:(0,k.Q_)(a)}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"truncate",children:function(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}(a,B)}),(0,e.jsx)("span",{children:"\xb7"}),(0,e.jsx)("span",{className:"flex-shrink-0",children:a.completed?"success"===a.lastResult?B("scheduledTasks.success"):B("scheduledTasks.failure"):a.paused?B("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,B)}),!a.completed&&a.lastFiredAt&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{children:"\xb7"}),(0,e.jsxs)("span",{className:"flex-shrink-0",children:[B("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]},a.id)})})]},a)})})}),(0,e.jsx)("div",{className:"hidden md:flex flex-1 min-w-0",children:W?(0,e.jsx)(p.x,{task:W,onOpenSession:()=>_(W)},W.id):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-xs text-muted-foreground",children:B("scheduledTasks.selectTaskHint")})})]})})]})]}),L&&null!==N&&(0,e.jsx)(m.x,{filePath:L,content:N,cwd:L.slice(0,Math.max(0,L.lastIndexOf("/"))),onClose:Y,zClassName:"z-[80]"}),E&&(0,e.jsx)("div",{ref:H,className:"fixed z-[100]",style:{top:I?.top??0,left:I?.left??0,visibility:I?"visible":"hidden"},children:(0,e.jsx)(l.E,{onClose:K,onCreate:()=>{},editTask:{id:E.id,message:E.message,taskFile:E.taskFile,type:E.type,delayMinutes:E.delayMinutes,intervalMinutes:E.intervalMinutes,activeFrom:E.activeFrom,activeTo:E.activeTo,cron:E.cron},onUpdate:(a,b)=>{A(a,b),K()}})})]})}d()}catch(a){d(a)}})},75310:(a,b,c)=>{"use strict";function d(a,b){let c=`/project?cwd=${encodeURIComponent(a)}`;b?.sessionId?c+=`&sessionId=${encodeURIComponent(b.sessionId)}`:b?.blank&&(c+="&newChat=1"),b?.file?c+=`&file=${encodeURIComponent(b.file)}`:b?.bubble&&(c+=`&bubble=${encodeURIComponent(b.bubble)}`);let d=b?.file?"explorer":b?.bubble?"console":b?.sessionId&&b.switchToAgent?"agent":null;return d&&(c+=`&view=${d}`),c}c.d(b,{f:()=>d})},75389:(a,b,c)=>{"use strict";c.d(b,{T:()=>A});var d=c(48249),e=c(67484),f=c(36041),g=c(12625),h=c(44384),i=c(44256),j=c(63565),k=c(46674),l=c(57063);let m=/^#\s+(.*)$/;function n(a,b=[]){let c=new Map(b.map(a=>[a.name,a.id])),d=[];for(let[b,c]of a.split(/\r?\n/).entries()){let a=c.match(m);if(a){d.push({name:a[1].trim(),line:b+1,body:[]});continue}let e=d[d.length-1];if(!e){if(c.trim())return{ok:!1,line:b+1,reason:"content-before-heading"};continue}e.body.push(c)}let e=new Set,f=[];for(let a of d){let b=a.body.join("\n").trim();if(!a.name||!b)return{ok:!1,line:a.line,reason:"empty-style"};if(e.has(a.name))return{ok:!1,line:a.line,reason:"duplicate-name"};e.add(a.name),f.push({id:c.get(a.name)??"",name:a.name,content:b})}return{ok:!0,styles:f}}function o({styles:a,onSave:b,onClose:c}){let{t:f}=(0,h.Bd)(),[g,j]=(0,e.useState)(()=>a.map(a=>`# ${a.name}
732
732
  ${a.content}`).join("\n\n")),[m,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),s=n(g,a);(0,l.E)(c);let t=(0,e.useCallback)(async()=>{let d=n(g,a);if(d.ok&&!m){if(p(!0),r(!1),await b(d.styles))return void c();p(!1),r(!0)}},[c,b,m,a,g]),u=f("chat.editOutputStyles");return(0,d.jsx)(i.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onMouseDown:a=>{a.target===a.currentTarget&&c()},children:(0,d.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":u,className:"w-full max-w-4xl max-h-[90vh] bg-card border border-border rounded-xl shadow-lv3 flex flex-col",children:[(0,d.jsxs)("header",{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-sm font-medium text-foreground",children:u}),(0,d.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:f("chat.outputStylesMarkdownHint")})]}),(0,d.jsx)("button",{type:"button",onClick:c,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded","aria-label":f("common.cancel"),children:(0,d.jsx)(k.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 px-4 py-3",children:(0,d.jsx)("textarea",{autoFocus:!0,value:g,onChange:a=>j(a.target.value),placeholder:f("chat.outputStylesMarkdownPlaceholder"),rows:24,spellCheck:!1,"data-testid":"output-styles-editor",className:"w-full h-[60vh] min-h-80 max-h-[70vh] resize-y px-3 py-2 text-sm font-mono leading-6 bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-brand"})}),(0,d.jsxs)("footer",{className:"flex items-center justify-between gap-3 px-4 py-3 border-t border-border",children:[(0,d.jsx)("span",{className:"text-xs text-destructive",children:s.ok?q?f("chat.saveQuickInstructionsFailed"):"":f(`chat.outputStylesError.${s.reason}`,{line:s.line})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:c,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground rounded hover:bg-hover",children:f("common.cancel")}),(0,d.jsx)("button",{type:"button",disabled:!s.ok||m,onClick:t,"data-testid":"output-styles-save",className:"px-3 py-1.5 text-xs rounded border border-brand text-brand hover:bg-brand/10 disabled:opacity-40",children:f(m?"chat.savingQuickInstructions":"common.save")})]})]})]})})})}var p=c(33281),q=c(41224);let r=[],s=r,t=!1,u=null,v=new Set,w=a=>{s=a,v.forEach(a=>a())};async function x(a){let b=await p.t4.runPromiseExit((0,q.DF)(a));return"Failure"===b._tag?(console.error("Failed to save output styles:",b.cause),!1):(t=!0,w(b.value.styles??r),!0)}let y=a=>(v.add(a),()=>{v.delete(a)}),z=()=>s;function A({value:a,onChange:b}){let{t:c}=(0,h.Bd)(),k=(0,e.useSyncExternalStore)(y,z,()=>r),l=(0,e.useRef)(null),m=(0,e.useRef)(null),[n,s]=(0,e.useState)(!1),[v,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)({top:0,left:0}),E=(0,i.F2)(),F=k.find(b=>b.id===a),G=c("chat.outputStyleNone"),H=F?.name??G,I=(0,e.useCallback)(()=>{let a=l.current?.getBoundingClientRect();if(!a)return;let b=E?.getBoundingClientRect();D({top:a.bottom+4-(b?.top??0),left:a.left-(b?.left??0)})},[E]),J=a=>{b(a),s(!1)},K=a=>`flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition-colors ${a?j.yI:"text-muted-foreground hover:bg-hover hover:text-foreground"}`;return(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)(j.XY,{buttonRef:l,label:H,labelMaxWidth:"max-w-[140px]",title:`${c("chat.outputStyle")}: ${H}`,onClick:()=>{n||(I(),function(a=!1){t&&!a?Promise.resolve():u||(u=(async()=>{let a=await p.t4.runPromiseExit((0,q.K4)());(u=null,"Failure"===a._tag)?console.error("Failed to load output styles:",a.cause):(t=!0,w(a.value.styles??r))})())}(!0)),s(a=>!a)},icon:(0,d.jsx)(f.A,{className:`h-3.5 w-3.5 flex-shrink-0 ${F?"text-brand":""}`}),testId:"output-style-picker"}),n&&(0,d.jsx)(i.ZL,{children:(0,d.jsxs)("div",{ref:m,className:`${j.ys} min-w-[200px] max-w-[320px]`,style:{top:C.top,left:C.left},children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 pb-1",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:c("chat.outputStyle")}),(0,d.jsx)("button",{type:"button",onClick:()=>{s(!1),B(!0)},className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-hover",title:c("chat.editOutputStyles"),"data-testid":"output-style-edit",children:(0,d.jsx)(g.A,{className:"w-3 h-3"})})]}),(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>J(""),className:K(!F),children:[(0,d.jsx)("span",{className:"mt-0.5",children:(0,d.jsx)(j.hG,{selected:!F})}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:G})]}),k.map(a=>(0,d.jsxs)("button",{type:"button",onClick:()=>J(a.id),className:K(F?.id===a.id),title:a.content,children:[(0,d.jsx)("span",{className:"mt-0.5",children:(0,d.jsx)(j.hG,{selected:F?.id===a.id})}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:a.name})]},a.id)),0===k.length&&(0,d.jsx)("div",{className:"px-3 py-2 text-[11px] text-muted-foreground",children:c("chat.noOutputStyles")})]})]})}),v&&(0,d.jsx)(o,{styles:k,onSave:x,onClose:()=>B(!1)})]})}},75513:(a,b,c)=>{"use strict";c.d(b,{k_:()=>h,nH:()=>i});var d=c(48249),e=c(67484),f=c(7031);let g=(0,e.createContext)(null);function h({children:a}){let b=(0,e.useRef)(new Map),c=(0,e.useRef)(null),[i,j]=(0,e.useState)(()=>new Set),k=i.size>0,l=(0,e.useCallback)((a,b)=>{j(c=>{if(b===c.has(a))return c;let d=new Set(c);return b?d.add(a):d.delete(a),d})},[]),m=(0,e.useCallback)((a,c)=>{b.current.set(c,a)},[]),n=(0,e.useCallback)(a=>{b.current.delete(a),j(b=>{if(!b.has(a))return b;let c=new Set(b);return c.delete(a),c})},[]),o=(0,e.useCallback)(a=>{c.current=a},[]),p=(0,e.useCallback)(a=>{let d=c.current;if(!d)return void console.warn("No active tab to send message");let e=b.current.get(d);e?e(a):console.warn(`No chat sender registered for tab ${d}`)},[]),q=(0,e.useCallback)((a,c)=>{let d=b.current.get(a);return d?(d(c),!0):(console.warn(`No chat sender registered for tab ${a}`),!1)},[]),r=(0,e.useMemo)(()=>({sendMessage:p,sendToTab:q,isLoading:k,registerChat:m,unregisterChat:n,setActiveTab:o,setChatLoading:l}),[p,q,k,m,n,o,l]),s=(0,e.useMemo)(()=>({sendMessage:p,isLoading:k}),[p,k]);return(0,d.jsx)(g.Provider,{value:r,children:(0,d.jsx)(f.H,{value:s,children:a})})}function i(){return(0,e.useContext)(g)}},76306:(a,b,c)=>{"use strict";c.d(b,{V:()=>g});var d=c(57031),e=c(88214);let f={isFramed:()=>window.parent!==window,publishOpenProject:a=>(0,d.F)(e.n.OpenProject,a),navigate:a=>window.location.assign(a)};function g(a,b,c=f){c.isFramed()?c.publishOpenProject({cwd:a.cwd,sessionId:a.sessionId,switchToAgent:!0}):c.navigate(b)}},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>q,metadata:()=>o,viewport:()=>p});var d=c(5735),e=c(30768),f=c.n(e),g=c(93868),h=c.n(g),i=c(83503),j=c.n(i),k=c(29021),l=c(33873);c(61135);var m=c(25702);let n="";try{n=(0,k.readFileSync)((0,l.join)(process.cwd(),"public","boot.js"),"utf8")}catch{}let o={title:"OpenCockpit",description:"OpenCockpit is a local-first AI development hub with chat agents, a file explorer, terminals, and browser bubbles in one swipeable workspace. One seat. One AI.",appleWebApp:{capable:!0,statusBarStyle:"default",title:"Cockpit"},icons:{icon:"/icons/icon-192x192.png",apple:"/icons/icon-192x192.png"}},p={themeColor:[{media:"(prefers-color-scheme: light)",color:"#f9f9fb"},{media:"(prefers-color-scheme: dark)",color:"#111113"}]};function q({children:a}){return(0,d.jsxs)("html",{lang:"en",suppressHydrationWarning:!0,className:"overflow-hidden",children:[(0,d.jsxs)("head",{children:[(0,d.jsx)("script",{dangerouslySetInnerHTML:{__html:n}}),(0,d.jsx)("script",{dangerouslySetInnerHTML:{__html:`window.__COCKPIT_BUILD_ID__=${JSON.stringify(process.env.COCKPIT_BUILD_ID??null)};window.__COCKPIT_FORCE_UPDATE__=${JSON.stringify("1"===process.env.COCKPIT_FORCE_UPDATE_BADGE)}`}})]}),(0,d.jsx)("body",{className:`${f().variable} ${h().variable} ${j().variable} antialiased overflow-hidden`,children:(0,d.jsx)(m.Providers,{children:a})})]})}},76603:(a,b,c)=>{"use strict";c.d(b,{BotsModal:()=>t});var d=c(48249),e=c(67484),f=c(76193),g=c(46674),h=c(65255),i=c(7309),j=c(59347),k=c(44384),l=c(33281),m=c(57031),n=c(88214),o=c(15332),p=c(27668),q=c(81608),r=c(7833),s=c(15819);function t({isOpen:a,onClose:b}){let{t:c}=(0,k.Bd)(),[h,i]=(0,e.useState)([]),[j,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(""),B=(0,e.useCallback)(async()=>{w(!0);let a=await l.t4.runPromiseExit((0,o.jm)());"Success"===a._tag?i(a.value):(0,r.oR)((0,p.oh)(a.cause,c("bots.loadFailed")),"error"),w(!1)},[c]),C=(0,e.useMemo)(()=>{let a=z.trim().toLowerCase();return a?h.filter(b=>{let c=b.valid?b.description:b.error;return`${b.name}
733
733
  ${c}
734
734
  ${b.path}`.toLowerCase().includes(a)}):h},[h,z]),D=(0,e.useMemo)(()=>h.filter(a=>!a.builtin).length,[h]),E=z.trim().length>0,F=(0,e.useCallback)(async a=>{let b=await l.t4.runPromiseExit((0,o.Eo)(a));"Success"===b._tag?(i(b=>b.filter(b=>b.id!==a)),(0,q._)(),(0,r.oR)(c("bots.removed"),"success")):(0,r.oR)((0,p.oh)(b.cause,c("bots.removeFailed")),"error")},[c]),G=(0,e.useCallback)(a=>{(0,m.F)(n.n.OpenProject,{cwd:a,file:"BOT.md"}),b()},[b]),H=(0,e.useCallback)(()=>y(!0),[]),I=(0,e.useCallback)(()=>y(!1),[]),J=(0,e.useCallback)(async()=>{y(!1),await B()},[B]);return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:s.aO,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:c("bots.title")}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{value:z,onChange:a=>A(a.target.value),placeholder:c("bots.search"),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,d.jsxs)("button",{onClick:H,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border hover:bg-hover",children:[(0,d.jsx)(f.A,{className:"w-4 h-4"}),c("bots.addExisting")]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground",children:(0,d.jsx)(g.A,{className:"w-5 h-5"})})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:j?(0,d.jsx)("p",{className:"text-center text-sm text-muted-foreground py-8",children:c("common.loading")}):(0,d.jsxs)(d.Fragment,{children:[C.length>0&&(0,d.jsx)("div",{className:s.jL,children:C.map(a=>(0,d.jsx)(u,{bot:a,onOpen:G,onRemove:F},a.id))}),0===C.length&&E&&(0,d.jsx)("p",{className:"text-center text-sm text-muted-foreground py-8",children:c("bots.emptyNoMatch")}),!E&&0===D&&(0,d.jsxs)("div",{className:`text-center text-muted-foreground py-8 text-sm space-y-2${C.length>0?" mt-4 border-t border-border/60":""}`,children:[(0,d.jsx)("p",{children:c("bots.emptyNoBots")}),(0,d.jsxs)("p",{children:[c("bots.emptyCreatePrefix")," ",(0,d.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-foreground font-mono text-xs",children:"/bot"})," ",c("bots.emptyCreateSuffix")]}),(0,d.jsx)("p",{children:(0,d.jsx)("button",{type:"button",onClick:H,className:"text-brand hover:underline",children:c("bots.emptyAddExisting")})})]})]})})]}),x&&(0,d.jsx)(v,{onCancel:I,onAdded:J})]}):null}let u=(0,e.memo)(function({bot:a,onOpen:b,onRemove:c}){let{t:f}=(0,k.Bd)(),[g,l]=(0,e.useState)(!1);return(0,d.jsx)("div",{className:"group rounded-lg border border-border bg-card p-3 min-w-0",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(h.A,{className:"w-5 h-5 mt-0.5 text-brand flex-shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("span",{className:"font-medium text-sm text-foreground",children:["@",a.name]}),a.builtin&&(0,d.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-hover text-muted-foreground",children:f("bots.builtin")}),!a.valid&&(0,d.jsx)("span",{className:"text-[10px] text-destructive",children:f("bots.invalid")})]}),(0,d.jsx)("p",{className:`text-xs mt-1 line-clamp-2 ${a.valid?"text-muted-foreground":"text-destructive"}`,children:a.valid?a.description:a.error}),(0,d.jsx)("p",{className:"text-[11px] text-foreground-subtle font-mono mt-2 truncate",title:a.path,children:a.path})]}),(0,d.jsxs)("div",{className:`flex items-center gap-1 transition-opacity ${g?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"}`,children:[(0,d.jsx)("button",{onClick:()=>b(a.path),className:"p-1 text-foreground-subtle hover:text-foreground",title:f("bots.open"),children:(0,d.jsx)(i.A,{className:"w-4 h-4"})}),a.builtin?null:g?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>{l(!1),c(a.id)},className:"px-2 py-1 text-xs rounded bg-destructive text-destructive-foreground hover:bg-destructive/90",children:f("common.confirm")}),(0,d.jsx)("button",{onClick:()=>l(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:f("common.cancel")})]}):(0,d.jsx)("button",{onClick:()=>l(!0),className:"p-1 text-foreground-subtle hover:text-destructive",title:f("bots.remove"),children:(0,d.jsx)(j.A,{className:"w-4 h-4"})})]})]})})});function v({onCancel:a,onAdded:b}){let{t:c}=(0,k.Bd)(),[f,g]=(0,e.useState)(""),[h,i]=(0,e.useState)(!1),j=(0,e.useCallback)(async()=>{let a=f.trim();if(!a||h)return;i(!0);let d=await l.t4.runPromiseExit((0,o.zB)(a));if(i(!1),"Success"===d._tag){let{alreadyExists:a}=d.value;(0,r.oR)(c(a?"bots.alreadyAdded":"bots.added"),a?"info":"success"),a||(0,q._)(),b()}else(0,r.oR)((0,p.oh)(d.cause,c("bots.saveFailed")),"error")},[f,h,b,c]);return(0,d.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:()=>!h&&a()}),(0,d.jsxs)("div",{className:"relative w-full max-w-md rounded-xl border border-border bg-card p-5 shadow-xl",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground mb-4",children:c("bots.addExisting")}),(0,d.jsx)("input",{autoFocus:!0,value:f,onChange:a=>g(a.target.value),onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||j()},placeholder:c("bots.pathPlaceholder"),className:"w-full px-3 py-2 text-sm font-mono border border-border rounded bg-background"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground mt-3",children:c("bots.addHint")}),(0,d.jsxs)("div",{className:"flex justify-end gap-2 mt-5",children:[(0,d.jsx)("button",{disabled:h,onClick:a,className:"px-3 py-1.5 text-xs rounded border border-border",children:c("common.cancel")}),(0,d.jsx)("button",{disabled:h||!f.trim(),onClick:()=>void j(),className:"px-3 py-1.5 text-xs rounded bg-brand text-white disabled:opacity-50",children:h?c("common.loading"):c("common.confirm")})]})]})]})}},76855:(a,b,c)=>{"use strict";c.d(b,{Sn:()=>i,Xm:()=>j,po:()=>k,JL:()=>l});var d=c(67484);c(28797);var e=c(79606),f=c(33281),g=c(71192);let h=(a,b)=>e.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new g.uV({message:`${a} failed`,cause:b})});function i(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);let g=await f.t4.runPromiseExit(h("/api/lsp/definition",{cwd:a,filePath:b,line:d,column:e}));return(c(!1),"Success"===g._tag)?g.value.definitions??[]:(console.error("[useLSP] definition error:",g.cause),[])},[a]),loading:b}}function j(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),g=(0,d.useRef)(null),i=(0,d.useRef)(0),j=(0,d.useRef)(!1),k=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),m=(0,d.useCallback)(a=>{k.current=a},[]),n=(0,d.useRef)(!1),o=(0,d.useRef)(null),p=(0,d.useCallback)(()=>{let a=k.current;a&&n.current&&(a.style.pointerEvents="none"),n.current=!1,o.current&&(k.current?.removeEventListener("mouseleave",o.current),o.current=null)},[]),q=(0,d.useCallback)(()=>{let a=k.current;if(!a||n.current)return;n.current=!0,j.current=!0,a.style.pointerEvents="auto";let b=()=>{j.current=!1,p(),i.current++,c(null)};o.current=b,a.addEventListener("mouseleave",b)},[p]),r=(0,d.useCallback)((b,d,j,k)=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current);let l=++i.current;e.current=setTimeout(async()=>{let e=await f.t4.runPromiseExit(h("/api/lsp/hover",{cwd:a,filePath:b,line:d,column:j}));if(l!==i.current||"Success"!==e._tag)return;let g=e.value.hover;g&&g.displayString&&c({...g,x:k.x,y:k.y,filePath:b,line:d,column:j})},300)},[a]),s=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),i.current++,g.current=setTimeout(function(){if(j.current)return;let a=k.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=l.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void q()}c(null)},150)},[q]),t=(0,d.useCallback)(()=>{j.current=!0,g.current&&clearTimeout(g.current)},[]);return{hoverInfo:b,onTokenMouseEnter:r,onTokenMouseLeave:s,onCardMouseEnter:t,onCardMouseLeave:(0,d.useCallback)(()=>{j.current=!1,i.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current),j.current=!1,p(),i.current++,c(null)},[p]),setTooltipEl:m}}function k(a){let[b,c]=(0,d.useState)([]),[e,g]=(0,d.useState)(!1),[i,j]=(0,d.useState)(!1);return{references:b,loading:e,visible:i,findReferences:(0,d.useCallback)(async(b,d,e)=>{g(!0),j(!0);let i=await f.t4.runPromiseExit(h("/api/lsp/references",{cwd:a,filePath:b,line:d,column:e}));"Success"===i._tag?c(i.value.references??[]):(console.error("[useLSP] references error:",i.cause),c([])),g(!1)},[a]),closeReferences:(0,d.useCallback)(()=>{j(!1),c([])},[])}}function l(a,b){(0,d.useRef)(null)}},77120:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{SessionBrowser:()=>p});var e=c(48249),f=c(67484),g=c(44384),h=c(15819),i=c(57031),j=c(88214),k=c(33281),l=c(65484),m=c(53954),n=c(74228),o=c(32753);function p({isOpen:a,onClose:b,onSelectSession:c,onAddProject:d,sessionNumbers:q={},projectNumbers:r={}}){let{t:s}=(0,g.Bd)(),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)([]),[x,y]=(0,f.useState)({}),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(null),[D,E]=(0,f.useState)(""),F=(0,f.useRef)(null);(0,f.useCallback)(async()=>{A(!0),C(null),y({});let a=await k.t4.runPromiseExit((0,l.H7)());"Success"===a._tag?w(a.value):C("Failed to load projects"),A(!1)},[]);let G=(0,f.useCallback)(async a=>{y(b=>({...b,[a]:{...b[a],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));let b=await k.t4.runPromiseExit((0,l.QW)(a));"Success"===b._tag?y(c=>({...c,[a]:{...c[a],isLoading:!1,sessions:b.value}})):y(b=>({...b,[a]:{...b[a],isLoading:!1,error:"Failed to load sessions"}}))},[]),H=(0,f.useCallback)(a=>{let b=x[a];b?.isExpanded?y(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?y(b=>({...b,[a]:{...b[a],isExpanded:!0}})):G(a)},[x,G]),I=(0,f.useCallback)(a=>{d?.(a),b()},[d,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-scrim",onClick:b}),(0,e.jsxs)("div",{className:t?"relative w-full max-w-[min(42rem,calc((100vw_-_28rem)*0.9))] h-[min(70vh,36rem)] mx-4 bg-card rounded-lg shadow-lv3 flex flex-col overflow-hidden":h.aO,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t?(0,e.jsxs)("button",{onClick:()=>u(!1),className:"flex items-center gap-1 text-sm font-medium text-foreground hover:text-brand 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:"M15 19l-7-7 7-7"})}),s("folderPicker.title")]}):(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:s("sessions.projectList")}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[!t&&(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("input",{ref:F,type:"text",placeholder:s("workspace.searchProjectPath"),value:D,onChange:a=>E(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),D&&(0,e.jsx)("button",{onClick:()=>{E(""),F.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:s("fileBrowser.clear"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),d&&!t&&(0,e.jsxs)("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-hover 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:"M12 10v6m3-3H9m-4 7h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),s("sessions.openFolder")]}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover 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"})})})]})]}),t?(0,e.jsx)(m.d,{onPick:I}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[z&&(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,e.jsx)("span",{children:s("workspace.loadingProjects")})]})}),B&&(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:B})}),!z&&!B&&0===v.length&&(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:s("workspace.projectNotFound")})}),!z&&!B&&v.filter(a=>a.fullPath.toLowerCase().includes(D.toLowerCase())).map(a=>{let b=x[a.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null},d=r[a.fullPath];return(0,e.jsxs)("div",{className:"mb-3",children:[(0,e.jsxs)("button",{onClick:()=>H(a.encodedPath),className:"w-full flex items-center gap-2 p-2 rounded hover:bg-hover transition-colors text-left",children:[(0,e.jsx)("svg",{className:`w-3 h-3 text-muted-foreground transition-transform ${b.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),d&&(0,e.jsx)(n.l,{projectNumber:d}),(0,e.jsx)("span",{className:"flex-1 text-xs font-medium text-foreground truncate","data-tooltip":a.fullPath,children:a.fullPath}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a.sessionCount,")"]})]}),b.isExpanded&&(0,e.jsxs)("div",{className:"ml-6 mt-2",children:[b.isLoading&&(0,e.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-3 w-3",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,e.jsx)("span",{children:s("sessions.loadingSessions")})]}),b.error&&(0,e.jsx)("div",{className:"p-3 text-xs text-red-11",children:b.error}),!b.isLoading&&!b.error&&(0,e.jsx)("div",{className:h.jL,children:b.sessions.map(b=>{var d;let f=b.path.split("/").pop()||"",g=b.sessionId||f.replace(".jsonl",""),h=q[`${a.fullPath}
735
- ${g}`],[k,l]=h?.split(".")??[];return(0,e.jsxs)("div",{onClick:()=>{var d;let e,f;return d=a.fullPath,e=b.path.split("/").pop()||"",f=b.sessionId||e.replace(".jsonl",""),void(c?c(d,f):(0,i.F)(j.n.OpenProject,{cwd:d,sessionId:f}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)(o.S,{engine:b.engine}),(0,e.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":b.title,children:b.title}),h&&(0,e.jsx)(n.l,{projectNumber:k,sessionNumber:l,bot:b.bot,className:"ml-auto"})]}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:(d=b.modifiedAt,new Date(d).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}))}),(0,e.jsxs)("div",{className:"space-y-0.5 text-xs",children:[b.firstMessages.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),b.lastMessages.length>0&&(0,e.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),b.lastMessages.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]})]},b.path)})})]})]},a.encodedPath)})]})]})]}):null}d()}catch(a){d(a)}})},77156:(a,b,c)=>{"use strict";c.d(b,{Bz:()=>h,Hy:()=>e,L5:()=>f,hp:()=>g});var d=c(27668);let e=()=>(0,d.zi)("/api/skills"),f=a=>(0,d.zi)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),g=a=>(0,d.zi)(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),h=a=>(0,d.zi)(`/api/skills/content?id=${encodeURIComponent(a)}`)},77220:(a,b,c)=>{"use strict";c.d(b,{SettingsModal:()=>n});var d=c(48249),e=c(67484),f=c(44384),g=c(83768),h=c(7833),i=c(28602),j=c(15105),k=c(33281),l=c(79606),m=c(65484);function n({isOpen:a,onClose:b}){let{t:c,i18n:o}=(0,f.Bd)(),{theme:p,setTheme:q}=(0,g.DP)(),r=(0,j.G)(),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)("auto"),A=(0,e.useCallback)(a=>{z(a),k.t4.runFork((0,m.DZ)({language:a}).pipe(l.NWQ(()=>l.rIH)));let b="auto"===a?navigator.language.startsWith("zh")?"zh":"en":a;o.changeLanguage(b)},[o]),B=r?"installed":"not-installed",C=r?.version??null;if(!a)return null;let D=[{value:"system",label:c("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:c("settings.themeLight"),icon:"☀️"},{value:"dark",label:c("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-2xl mx-4 overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:c("settings.title")}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{className:"p-4 space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.theme")}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:D.map(a=>(0,d.jsxs)("button",{onClick:()=>q(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${p===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"text-xl",children:a.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.language")}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:c("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(a=>(0,d.jsxs)("button",{onClick:()=>A(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${y===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"text-xl",children:a.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.browserExtension")}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===B?"bg-green-500":"bg-slate-400"}`}),(0,d.jsxs)("span",{children:["installed"===B&&`${c("settings.extensionInstalled")}${C?` (v${C})`:""}`,"not-installed"===B&&c("settings.extensionNotInstalled")]})]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:c("settings.extensionDescription")}),"installed"!==B&&(0,d.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,d.jsx)("p",{className:"font-medium text-foreground",children:c("settings.installSteps")}),(0,d.jsxs)("p",{children:[c("settings.step1")," ",(0,d.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,d.jsx)("p",{children:c("settings.step2")}),(0,d.jsx)("p",{children:c("settings.step3")}),(0,i.L)()&&(0,d.jsx)("p",{dangerouslySetInnerHTML:{__html:c("settings.step4mac")}})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:()=>{let a=s||"chrome-extension";navigator.clipboard.writeText(a),(0,h.oR)(c("toast.copiedName",{name:a}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:c("settings.copyExtensionPath")}),"installed"===B&&(0,d.jsx)("button",{onClick:()=>{r?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(r.id,{type:"reload"}),(0,h.oR)(c("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:c("settings.reloadExtension")})]}),s&&(0,d.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:s})]})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.about")}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,d.jsxs)("p",{children:["Cockpit",u?` v${u}`:""]}),(w?.claude||w?.codex)&&(0,d.jsx)("p",{className:"text-muted-foreground/60",children:[w.claude&&`Claude Code ${w.claude}`,w.codex&&`Codex ${w.codex}`,c("settings.agentsBundled")].filter(Boolean).join(" \xb7 ")}),(0,d.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}},77462:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>K});var e=c(48249),f=c(67484),g=c(44384),h=c(14222),i=c(43209),j=c(70151),k=c(6900),l=c(85905),m=c(32465),n=c(75513),o=c(57632),p=c(79327),q=c(39796),r=c(94192),s=c(44256),t=c(37129),u=c(38878),v=c(3588),w=c(92340),x=c(52490),y=c(18946),z=c(29939),A=c(98982),B=c(13054),C=c(79606),D=c(23734),E=c(88214),F=c(33281),G=c(65484);c(37388);var H=a([t,u,v,y,o,j]);function I(a,b){if(!b.split)return{};let c=b.panes.indexOf(a);return -1===c?{}:{peerTabId:b.panes[1-c],peerSide:0===c?"right":"left"}}function J({tabId:a,panes:b,activePane:c,row:d,maximized:f,onFocusPane:h,onClosePane:i,onToggleMaximize:j,children:k}){let{t:l}=(0,g.Bd)(),m=b.indexOf(a),n=b.length>1;return(0,e.jsxs)("div",{onMouseDownCapture:n?()=>h(m):void 0,style:d&&-1!==m&&!f?{order:m}:void 0,className:`group/pane ${(0,q.vZ)(a,b,c,d,f)}`,children:[n&&-1!==m&&(0,e.jsxs)("div",{className:"absolute top-1 right-1 z-20 flex items-center gap-0.5 opacity-0 pointer-events-none transition-opacity focus-within:opacity-100 focus-within:pointer-events-auto group-hover/pane:opacity-100 group-hover/pane:pointer-events-auto",children:[(0,e.jsx)("button",{type:"button",onClick:()=>j(m),title:l(f?"chat.restorePane":"chat.maximizePane"),"aria-label":l(f?"chat.restorePane":"chat.maximizePane"),"aria-pressed":f,className:"flex items-center justify-center w-6 h-6 text-muted-foreground transition-colors hover:text-foreground",children:f?(0,e.jsx)(w.A,{className:"w-3.5 h-3.5"}):(0,e.jsx)(x.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:()=>i(m),title:l("chat.closePane"),"aria-label":l("chat.closePane"),className:"flex items-center justify-center w-6 h-6 text-muted-foreground transition-colors hover:text-foreground",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"})})})]}),k]})}function K({initialCwd:a,initialSessionId:b,initialBlank:c,initialView:d,initialFile:w,initialBubble:x}){let{t:H}=(0,g.Bd)(),[L,M]=(0,f.useState)(d??"agent"),[N,O]=(0,f.useState)(null),{tabs:P,activeTabId:Q,activeTab:R,paneTabIds:S,activePane:T,toggleSideBySide:U,focusPane:V,closePane:W,unreadTabs:X,globalLoadingTabs:Y,pageVisible:Z,dragTabIndex:$,dragOverTabIndex:_,closeTab:aa,closeAllTabs:ab,switchTab:ac,handleSelectSession:ad,handleNewTab:ae,handleNewCodexTab:af,handleNewKimiTab:ag,handleNewGlmTab:ah,handleNewOllamaTab:ai,handleNewDeepseekTab:aj,handleOpenSession:ak,updateTabState:al,updateTabEngine:am,updateTabOllamaModel:an,updateTabDeepseekModel:ao,updateTabKimiModel:ap,updateTabGlmModel:aq,updateTabClaudeModel:ar,updateTabClaudeEffort:as,updateTabClaudeFastMode:at,updateTabClaudeThinking:au,updateTabCodexModel:av,updateTabCodexReasoningEffort:aw,updateTabPlanMode:ax,updateTabNoHistory:ay,updateTabOutputStyle:az,handleTabDragStart:aA,handleTabDragOver:aB,handleTabDrop:aC,handleTabDragEnd:aD}=(0,t.useTabState)({initialCwd:a,initialSessionId:b,initialBlank:c,activeView:L}),{isPinned:aE,pinSession:aF,unpinSession:aG}=(0,A.P)(),{createTask:aH}=(0,B.nS)(),aI=(0,f.useCallback)(a=>{let b=P.find(b=>b.id===a);return!!b?.sessionId&&aE(b.sessionId)},[P,aE]),aJ=(0,f.useCallback)(b=>{let c=P.find(a=>a.id===b);c?.sessionId&&(aE(c.sessionId)?aG(c.sessionId):aF(c.sessionId,c.cwd||a||"",c.title))},[P,aE,aF,aG,a]),[aK,aL]=(0,f.useState)(!1),[aM,aN]=(0,f.useState)(!1),[aO,aP]=(0,f.useState)(!1),[aQ,aR]=(0,f.useState)(null),[aS,aT]=(0,f.useState)(!1),[aU,aV]=(0,f.useState)("tree"),[aW,aX]=(0,f.useState)(0),[aY,aZ]=(0,f.useState)(null),[a$,a_]=(0,f.useState)(0),[a0,a1]=(0,f.useState)(w?{path:w,nonce:0}:null),[a2,a3]=(0,f.useState)(x?{commandId:x,nonce:0}:null);(0,f.useRef)(()=>{});let[a4,a5]=(0,f.useState)(null),a6=null!==a4,a7=(0,f.useMemo)(()=>(0,q.p_)(S,T,Q,a6),[S,T,Q,a6]),[a8,a9]=(0,f.useState)(null),[ba,bb]=(0,f.useState)(),[bc,bd]=(0,f.useState)(!1);(0,f.useRef)(null);let be=(0,f.useCallback)(b=>{M(b),a&&(F.t4.runFork((0,G.Yn)({cwd:a,settings:{activeView:b}}).pipe(C.NWQ(()=>C.rIH))),F.t4.runFork(C.qIB(D.d,c=>c.publish(E.n.ViewChange,{cwd:a,view:b}))))},[a]),bf=(0,f.useCallback)(async()=>{if(!a)return;let b=await F.t4.runPromiseExit((0,G.b2)(a));if("Success"===b._tag){let c=b.value;if(aT(!!c.isGitRepo),c.isGitRepo&&c.worktrees&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&aR(b.branch)}}else console.error("Failed to load git info:",b.cause)},[a]),bg=(0,f.useCallback)(a=>{let{data:b}=a;Array.isArray(b)&&b.some(a=>"git"===a.type)&&bf()},[bf]);(0,z.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:bg,enabled:!!a});let bh=(0,f.useCallback)(()=>{aV("status"),aX(a=>a+1),be("explorer")},[be]),bi=(0,f.useCallback)(a=>{aZ(a),a_(a=>a+1),be("explorer")},[be]),bj=(0,f.useCallback)(()=>be("agent"),[be]),[bk,bl]=(0,f.useState)(!1),[bm,bn]=(0,f.useState)(!1),bo=(0,q.XL)(a7,bm),bp=(0,f.useCallback)(a=>{bn(a=>!a),V(a)},[V]),bq=(0,f.useCallback)(()=>bl(a=>!a),[]),br=(0,f.useCallback)(()=>a5(null),[]),bs=(0,f.useRef)(null),bt=(0,f.useCallback)(a=>{let b=bs.current;if(!b)return;let c=a.offset>0&&null!==a.target&&b.contains(a.target);if("move"===a.phase){if(!c)return;let d=Math.min(.5*a.offset,b.offsetWidth);b.style.transition="none",b.style.transform=`translateX(${d}px)`;return}c&&a.triggered?(b.style.transition="transform 140ms ease-out, opacity 140ms ease-out",b.style.transform="translateX(100%)",b.style.opacity="0",window.setTimeout(br,140)):(b.style.transition="transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)",b.style.transform="")},[br]),bu=(0,f.useRef)(a6),bv=(0,f.useRef)(bo),bw=(0,f.useCallback)(()=>{bu.current?br():null!==bv.current?bn(!1):U()},[U,br]),bx=(0,f.useCallback)((a,b,c,d,e)=>{a5(f=>(0,p.y)(f,{messageId:a,toolCalls:b,cwd:c,sessionId:d},!0===e)),e||be("agent")},[be]),by=(0,f.useCallback)(a=>{a1({...a,nonce:Date.now()}),be("explorer")},[be]),bz=(0,f.useCallback)(()=>{a&&F.t4.runFork(C.qIB(D.d,b=>b.publish(E.n.OpenNote,{cwd:a})))},[a]);return(0,e.jsx)(n.k_,{children:(0,e.jsx)(r.fY,{activeView:L,onViewChange:be,onOverscroll:bt,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(u.TabManagerTopBar,{initialCwd:a,activeTab:R,isGitRepo:aS,currentBranch:aQ,onOpenWorktree:()=>aN(!0),onOpenAliasManager:()=>aP(!0),onBranchSwitched:bf}),bc&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),H("console.screenshotting")]}),a?(0,e.jsxs)(r.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(s.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(v.TabBar,{tabs:P,selectedTabId:Q,sideBySide:a7.split,onToggleSideBySide:bw,unreadTabs:X,globalLoadingTabs:Y,dragTabIndex:$,dragOverTabIndex:_,isPinned:aI,onSwitchTab:ac,onCloseTab:aa,onCloseAllTabs:ab,onNewTab:ae,onNewCodexTab:af,onNewKimiTab:ag,onNewGlmTab:ah,onNewOllamaTab:ai,onNewDeepseekTab:aj,onOpenProjectSessions:()=>aL(!0),onDragStart:aA,onDragOver:aB,onDrop:aC,onDragEnd:aD}),(0,e.jsx)(h.c,{value:a7.split?N:null,children:(0,e.jsxs)("div",{className:`flex-1 overflow-hidden relative ${a7.row?"flex":""}`,children:[P.map(a=>(0,e.jsx)(J,{tabId:a.id,panes:a7.panes,activePane:a7.activePane,row:a7.row,maximized:bo===a.id,onFocusPane:V,onClosePane:W,onToggleMaximize:bp,children:(0,e.jsx)(y.X,{tabId:a.id,...I(a.id,a7),cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:am,ollamaModel:a.ollamaModel,onOllamaModelChange:an,deepseekModel:a.deepseekModel,onDeepseekModelChange:ao,kimiModel:a.kimiModel,onKimiModelChange:ap,glmModel:a.glmModel,onGlmModelChange:aq,claudeModel:a.claudeModel,onClaudeModelChange:ar,claudeEffort:a.claudeEffort,onClaudeEffortChange:as,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:at,claudeThinking:a.claudeThinking,onClaudeThinkingChange:au,codexModel:a.codexModel,onCodexModelChange:av,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:aw,planMode:a.planMode,onPlanModeChange:ax,noHistory:a.noHistory,onNoHistoryChange:ay,outputStyle:a.outputStyle,onOutputStyleChange:az,isActive:(0,q.gF)(a.id,S,"agent"===L,Z),isFocused:a.id===Q,refreshSignal:a8,onStateChange:al,onShowGitStatus:bh,onContentSearch:bi,onShowFileDiff:bx,onOpenFileLink:by,onOpenNote:bz,isFavorite:aI(a.id),onToggleFavorite:aJ,onCreateScheduledTask:aH,onOpenSession:ak})},a.id)),a4&&(0,e.jsx)("div",{ref:bs,"data-diff-column":"",className:bk?"absolute inset-0 z-30 bg-card":"h-full flex-1 min-w-0 border-l border-border",style:bk?void 0:{order:a7.diffOrder},children:(0,e.jsx)(o.e$,{toolCalls:a4.toolCalls,cwd:a4.cwd,sessionId:a4.sessionId,onClose:br,onContentSearch:bi,fullscreen:bk,onToggleFullscreen:bq},a4.messageId)})]})}),a7.split&&(0,e.jsx)("div",{ref:O,className:"flex-shrink-0"})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden relative",children:(0,e.jsx)(s.a9,{children:(0,e.jsx)(j.g,{onClose:bj,cwd:a,initialTab:aU,tabSwitchTrigger:aW,initialSearchQuery:aY,searchQueryTrigger:a$,fileOpenRequest:a0})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(s.a9,{children:(0,e.jsx)(l.J,{cwd:a,tabId:"default",onOpenNote:bz,focusBubble:a2})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(v.TabBar,{tabs:P,selectedTabId:Q,sideBySide:a7.split,onToggleSideBySide:bw,unreadTabs:X,globalLoadingTabs:Y,dragTabIndex:$,dragOverTabIndex:_,isPinned:aI,onSwitchTab:ac,onCloseTab:aa,onCloseAllTabs:ab,onNewTab:ae,onNewCodexTab:af,onNewKimiTab:ag,onNewGlmTab:ah,onNewDeepseekTab:aj,onDragStart:aA,onDragOver:aB,onDrop:aC,onDragEnd:aD}),(0,e.jsx)(h.c,{value:a7.split?N:null,children:(0,e.jsx)("div",{className:`flex-1 overflow-hidden relative ${a7.row?"flex":""}`,children:P.map(a=>(0,e.jsx)(J,{tabId:a.id,panes:a7.panes,activePane:a7.activePane,row:a7.row,maximized:bo===a.id,onFocusPane:V,onClosePane:W,onToggleMaximize:bp,children:(0,e.jsx)(y.X,{tabId:a.id,...I(a.id,a7),cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:am,ollamaModel:a.ollamaModel,onOllamaModelChange:an,deepseekModel:a.deepseekModel,onDeepseekModelChange:ao,kimiModel:a.kimiModel,onKimiModelChange:ap,glmModel:a.glmModel,onGlmModelChange:aq,claudeModel:a.claudeModel,onClaudeModelChange:ar,claudeEffort:a.claudeEffort,onClaudeEffortChange:as,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:at,claudeThinking:a.claudeThinking,onClaudeThinkingChange:au,codexModel:a.codexModel,onCodexModelChange:av,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:aw,planMode:a.planMode,onPlanModeChange:ax,noHistory:a.noHistory,onNoHistoryChange:ay,outputStyle:a.outputStyle,onOutputStyleChange:az,isActive:(0,q.gF)(a.id,S,!0,Z),isFocused:a.id===Q,refreshSignal:a8,onStateChange:al,isFavorite:aI(a.id),onToggleFavorite:aJ,onCreateScheduledTask:aH,onOpenSession:ak})},a.id))})}),a7.split&&(0,e.jsx)("div",{ref:O,className:"flex-shrink-0"})]})]}),a&&(0,e.jsx)(i.Q,{isOpen:aK,onClose:()=>aL(!1),cwd:a,onSelectSession:ad,projectNumber:ba,openSessionIds:P.map(a=>a.sessionId)}),a&&aS&&(0,e.jsx)(k.x,{isOpen:aM,onClose:()=>aN(!1),cwd:a}),aO&&(0,e.jsx)(m.Y,{onClose:()=>aP(!1),onSave:()=>aP(!1)})]})})})}[t,u,v,y,o,j]=H.then?(await H)():H,d()}catch(a){d(a)}})},77774:(a,b,c)=>{"use strict";c.d(b,{C:()=>h,x:()=>g});var d=c(79606),e=c(71192);let f=a=>`cockpit:active-tab:${a}`,g=a=>d.SvU({try:()=>{let b=window.sessionStorage.getItem(f(a));if(!b)return null;let c=JSON.parse(b);return"blank"===c.kind?{kind:"blank"}:"session"===c.kind&&"string"==typeof c.sessionId&&c.sessionId?{kind:"session",sessionId:c.sessionId}:null},catch:a=>new e.uV({message:"load active tab target failed",cause:a})}),h=(a,b)=>d.SvU({try:()=>window.sessionStorage.setItem(f(a),JSON.stringify(b)),catch:a=>new e.uV({message:"save active tab target failed",cause:a})})},79327:(a,b,c)=>{"use strict";function d(a,b,c){return c?a?.messageId!==b.messageId?a:{...a,toolCalls:b.toolCalls}:b}c.d(b,{y:()=>d})},80118:(a,b,c)=>{"use strict";c.d(b,{R:()=>j});var d=c(66142),e=c(10259),f=c(37361);let g=new e.hs("headingFold");function h(a){let b=a.attrs.foldState;return"folded"===b||"children"===b?b:"expanded"}function i(a){let b=[],c=[];return a.forEach((a,d)=>{let e=d+a.nodeSize;if("heading"===a.type.name){let g=a.attrs.level;for(;c.length&&c[c.length-1].level>=g;)c.pop();let i=h(a),j=c.some(a=>"folded"===a.state),k=["note-heading"];"expanded"!==i&&k.push("is-collapsed"),j&&k.push("note-folded-hidden"),b.push(f.NZ.node(d,e,{class:k.join(" ")})),b.push(f.NZ.widget(d+1,(a,b)=>{let c;return(c=document.createElement("span")).className="note-fold-toggle",c.contentEditable="false",c.setAttribute("data-fold-state",i),c.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation();let d=b();if(null==d)return;let e=d-1,f=a.state.doc.nodeAt(e);f&&"heading"===f.type.name&&a.dispatch(a.state.tr.setNodeMarkup(e,void 0,{...f.attrs,foldState:"expanded"===h(f)?"folded":"expanded"}))}),c},{side:-1,key:`fold-${d}-${i}`})),c.push({level:g,state:i})}else c.some(a=>"folded"===a.state||"children"===a.state)&&b.push(f.NZ.node(d,e,{class:"note-folded-hidden"}))}),f.zF.create(a,b)}let j=d.A.extend({addAttributes(){return{...this.parent?.(),foldState:{default:"expanded",keepOnSplit:!1,parseHTML:a=>"true"===a.getAttribute("data-collapsed")?"folded":"expanded",renderHTML:a=>a.foldState&&"expanded"!==a.foldState?{"data-collapsed":"true"}:{}}}},addKeyboardShortcuts(){let a=this.name;return{Tab:()=>{var b;let c,d,e,{state:f}=this.editor,{$from:g}=f.selection;if(g.parent.type.name!==a)return!1;let i=g.before(g.depth),j=f.doc.nodeAt(i);if(!j||j.type.name!==a)return!1;let k=j.attrs.level,l=(b=f.doc,d=[],e=!1,b.forEach((b,c)=>{if(c===i){e=!0;return}if(e&&b.type.name===a){if(b.attrs.level<=k){e=!1;return}d.push(c)}}),d),m=l.length>0,n=h(j),o=null;return m?"expanded"===n?c="folded":(c="folded"===n?"children":"expanded",o="expanded"):c="expanded"===n?"folded":"expanded",this.editor.chain().command(({tr:b})=>{if(b.setNodeMarkup(i,void 0,{...j.attrs,foldState:c}),o)for(let c of l){let d=b.doc.nodeAt(c);d&&d.type.name===a&&b.setNodeMarkup(c,void 0,{...d.attrs,foldState:o})}return!0}).run()}}},addStorage:()=>({markdown:{serialize(a,b){a.write(a.repeat("#",b.attrs.level)+" "),a.renderInline(b,!1),"expanded"!==h(b)&&a.write(" \x3c!-- fold --\x3e"),a.closeBlock(b)},parse:{updateDOM(a){a.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(a=>{let b=a.lastChild;for(;b&&3===b.nodeType&&!(b.textContent||"").trim();){let c=b.previousSibling;a.removeChild(b),b=c}if(b&&8===b.nodeType&&/^\s*fold\s*$/.test(b.textContent||"")){let c=b.previousSibling;a.removeChild(b),c&&3===c.nodeType&&(c.textContent=(c.textContent||"").replace(/\s+$/,"")),a.setAttribute("data-collapsed","true")}})}}}}),addProseMirrorPlugins:()=>[new e.k_({key:g,state:{init:(a,{doc:b})=>i(b),apply:(a,b)=>a.docChanged?i(a.doc):b},props:{decorations:a=>g.getState(a)}})]})},80514:(a,b,c)=>{"use strict";c.d(b,{V:()=>T});var d=c(48249),e=c(67484),f=c(44384),g=c(16944),h=c(29588),i=c(3623),j=c(44256),k=c(7833);function l({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=async b=>{b.stopPropagation();try{var d;if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");let b=await (d=a.preview,new Promise((a,b)=>{let c=new Image;c.onload=()=>{let d=document.createElement("canvas");d.width=c.naturalWidth,d.height=c.naturalHeight;let e=d.getContext("2d");e?(e.drawImage(c,0,0),d.toBlob(c=>{c?a(c):b(Error("Could not encode image"))},"image/png")):b(Error("Canvas is unavailable"))},c.onerror=()=>b(Error("Could not load image")),c.src=d}));await navigator.clipboard.write([new ClipboardItem({"image/png":b})]),(0,k.oR)(c("imagePreview.copiedImage"),"success")}catch{(0,k.oR)(c("common.copyFailed"),"error")}},g=(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,d.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:e,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:c("imagePreview.copyImage"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V5a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2M7 7h6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z"})})}),(0,d.jsx)("button",{type:"button",onClick:b,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]});return(0,d.jsx)(j.ZL,{children:g})}function m({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[h,i]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>i(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),h&&(0,d.jsx)(l,{image:h,onClose:()=>i(null)})]})}var n=c(30458),o=c(74429),p=c(65032),q=c(44218),r=c(42742),s=c(33999),t=c(74118),u=c(12625),v=c(46674),w=c(19794),x=c(24520),y=c(76193),z=c(72529),A=c(33281),B=c(41224),C=c(57063);let D=()=>Math.random().toString(36).slice(2,10),E=a=>a.replace(/\\n/g,"\n");function F(a){let b=[],c=null;for(let[d,e]of a.split(/\r?\n/).entries()){if(!e.trim())continue;let a=e.match(/^\s*-(?:\s+(.*))?$/);if(a){let b=(a[1]??"").trim();if(!c)return{ok:!1,line:d+1};c.isGroup=!0,b&&c.children.push(E(b));continue}if(/^\s/.test(e))return{ok:!1,line:d+1};let f=e.trim();f&&(c={text:E(f),children:[],isGroup:!1},b.push(c))}return{ok:!0,nodes:b.map(a=>a.isGroup?{id:D(),name:a.text,items:a.children.map(a=>({id:D(),text:a}))}:{id:D(),text:a.text})}}function G({title:a,nodes:b,onSave:c,onClose:g}){let{t:h}=(0,f.Bd)(),[i,k]=(0,e.useState)(()=>b.flatMap(a=>(0,B._9)(a)?[a.name.replace(/\n/g,"\\n"),...a.items.length>0?a.items.map(a=>`- ${a.text.replace(/\n/g,"\\n")}`):["- "]]:[a.text.replace(/\n/g,"\\n")]).join("\n")),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(!1),p=F(i);(0,C.E)(g);let q=(0,e.useCallback)(async()=>{let a=F(i);!a.ok||l||((m(!0),o(!1),await c(a.nodes))?g():(m(!1),o(!0)))},[g,c,l,i]);return(0,d.jsx)(j.ZL,{children:(0,d.jsx)("div",{"data-quick-instruction-layer":"",className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onMouseDown:a=>{a.target===a.currentTarget&&g()},children:(0,d.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":a,className:"w-full max-w-4xl max-h-[90vh] bg-card border border-border rounded-xl shadow-lv3 flex flex-col",children:[(0,d.jsxs)("header",{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-sm font-medium text-foreground",children:a}),(0,d.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h("chat.quickInstructionsMarkdownHint")})]}),(0,d.jsx)("button",{type:"button",onClick:g,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded","aria-label":h("common.cancel"),children:(0,d.jsx)(v.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 px-4 py-3",children:(0,d.jsx)("textarea",{autoFocus:!0,wrap:"off",value:i,onChange:a=>k(a.target.value),placeholder:h("chat.quickInstructionsMarkdownPlaceholder"),rows:24,spellCheck:!1,className:"w-full h-[60vh] min-h-80 max-h-[70vh] resize-y overflow-x-auto whitespace-pre px-3 py-2 text-sm font-mono leading-6 bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-brand"})}),(0,d.jsxs)("footer",{className:"flex items-center justify-between gap-3 px-4 py-3 border-t border-border",children:[(0,d.jsx)("span",{className:"text-xs text-destructive",children:p.ok?n?h("chat.saveQuickInstructionsFailed"):"":h("chat.quickInstructionsMarkdownError",{line:p.line})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:g,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground rounded hover:bg-hover",children:h("common.cancel")}),(0,d.jsx)("button",{type:"button",disabled:!p.ok||l,onClick:q,className:"px-3 py-1.5 text-xs rounded border border-brand text-brand hover:bg-brand/10 disabled:opacity-40",children:h(l?"chat.savingQuickInstructions":"common.save")})]})]})]})})})}let H="data-quick-instruction-layer",I=()=>Math.random().toString(36).slice(2,10);function J({groups:a,value:b,onChange:c,onSubmit:g,onCancel:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,s]=(0,e.useState)(0),t=(0,e.useRef)(null),u=(0,e.useRef)(null),v=[null,...a.map(a=>a.id)],w=null===b?i("chat.instructionGroupNone"):a.find(a=>a.id===b)?.name??i("chat.instructionGroupNone"),x=(0,e.useCallback)(()=>{let c=t.current?.getBoundingClientRect();c&&(m(((a,b,c)=>{let d=Math.min(a.width,c.width-16),e=Math.min(Math.max(8,a.left),Math.max(8,c.width-d-8)),f=c.height-a.bottom-2-8,g=a.top-2-8,h=28*b+8;if(f>=Math.min(h,96)||f>=g)return{left:e,top:a.bottom+2,width:d,maxHeight:Math.max(28,Math.min(h,f))};let i=Math.max(28,Math.min(h,g));return{left:e,top:a.top-2-i,width:d,maxHeight:i}})(c,a.length+1,{width:window.innerWidth,height:window.innerHeight})),s(Math.max(0,v.indexOf(b))),k(!0))},[a.length,v,b]),y=(0,e.useCallback)(()=>{k(!1),m(null),t.current?.focus()},[]),z=(0,e.useCallback)(a=>{c(a),y()},[c,y]),A=(0,e.useCallback)(a=>{j?"Escape"===a.key?(a.preventDefault(),a.stopPropagation(),y()):"ArrowDown"===a.key?(a.preventDefault(),a.stopPropagation(),s(a=>Math.min(v.length-1,a+1))):"ArrowUp"===a.key?(a.preventDefault(),a.stopPropagation(),s(a=>Math.max(0,a-1))):"Enter"===a.key&&(a.preventDefault(),a.stopPropagation(),z(v[n]??null)):"ArrowDown"===a.key||" "===a.key?(a.preventDefault(),a.stopPropagation(),x()):"Enter"===a.key?(a.preventDefault(),a.stopPropagation(),g()):"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),h())},[j,x,y,z,v,n,g,h]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{ref:t,type:"button",onClick:()=>j?y():x(),onKeyDown:A,className:"w-[140px] min-w-0 flex-shrink-0 px-2 py-1 flex items-center gap-1 text-xs rounded border border-input bg-background hover:bg-hover focus:outline-none focus:ring-1 focus:ring-ring transition-colors",title:i("chat.instructionGroupLabel"),children:[(0,d.jsx)(p.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:`flex-1 min-w-0 truncate text-left ${null===b?"text-muted-foreground":""}`,children:w}),(0,d.jsx)(q.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"})]}),j&&l&&(0,o.createPortal)((0,d.jsx)("div",{ref:u,[H]:"",role:"listbox",style:{left:l.left,top:l.top,width:l.width,maxHeight:l.maxHeight},className:"fixed z-[60] py-1 bg-popover border border-border rounded-lg shadow-lv2 overflow-y-auto",children:v.map((c,e)=>{let f=c===b;return(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":f,onClick:()=>z(c),onMouseEnter:()=>s(e),className:`w-full min-w-0 px-2 py-1 flex items-center gap-1.5 text-xs text-left transition-colors ${e===n?"bg-hover":""}`,children:[(0,d.jsx)(r.A,{className:`w-3 h-3 flex-shrink-0 ${f?"text-brand":"opacity-0"}`}),(0,d.jsx)("span",{className:`flex-1 min-w-0 truncate ${null===c?"text-muted-foreground":""}`,children:null===c?i("chat.instructionGroupNone"):a.find(a=>a.id===c)?.name})]},c??"__none__")})}),document.body)]})}function K({initialValue:a,placeholder:b,groupChoices:c,initialGroupId:f,onCommit:g,onCancel:h}){let[i,j]=(0,e.useState)(a),[k,l]=(0,e.useState)(f??null),m=(0,e.useCallback)(()=>{let a=i.trim();a&&g(a,k)},[i,k,g]),n=(0,e.useCallback)(a=>{"Enter"!==a.key||a.nativeEvent.isComposing?"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),h()):(a.preventDefault(),a.stopPropagation(),m())},[m,h]);return(0,d.jsxs)("div",{className:"mb-1 flex items-center gap-1",children:[(0,d.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),onKeyDown:n,placeholder:b,autoFocus:!0,className:"flex-1 min-w-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring"}),c&&c.length>0&&(0,d.jsx)(J,{groups:c,value:k,onChange:l,onSubmit:m,onCancel:h})]})}let L=(a,b)=>`flex items-center group min-w-0 rounded transition-opacity ${a?"opacity-50":""} ${b?"border-t-2 border-brand":""}`,M="p-1 text-muted-foreground hover:text-foreground rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",N=(0,e.memo)(function({item:a,isDragging:b,isDragOver:c,onSelect:e,onInsert:g,onEdit:h,onDelete:j,onDragStart:k,onDragOver:l,onDrop:m,onDragEnd:n,management:o=!0}){let{t:p}=(0,f.Bd)();return(0,d.jsxs)("div",{draggable:o,onDragStart:o?()=>k(a.id):void 0,onDragOver:o?b=>l(b,a.id):void 0,onDrop:o?()=>m(a.id):void 0,onDragEnd:o?n:void 0,className:L(b,c),children:[o&&(0,d.jsx)(s.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),(0,d.jsx)(z.m,{content:a.text,children:(0,d.jsxs)("button",{type:"button",onClick:()=>e(a.text),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",children:[(0,d.jsx)(t.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"truncate",children:a.text})]})}),(0,d.jsx)("button",{type:"button",onClick:()=>g(a.text),className:M,title:p("chat.insertQuickInstruction"),children:(0,d.jsx)(i.A,{className:"w-3 h-3"})}),o&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",onClick:()=>h(a.id),className:M,title:p("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>j(a.id),className:`${M} hover:text-destructive`,title:p("common.delete"),children:(0,d.jsx)(v.A,{className:"w-3 h-3"})})]})]})}),O=(0,e.memo)(function({group:a,isOpen:b,isDragging:c,isDragOver:g,isDragActive:h,onHoverOpen:i,onHoverClose:j,onToggle:k,onRename:l,onDelete:m,onDragStart:n,onDragOver:o,onDrop:q,onDragEnd:r,management:t=!0}){let{t:x}=(0,f.Bd)(),y=(0,e.useRef)(null),z=(0,e.useCallback)(()=>y.current?.getBoundingClientRect(),[]);return(0,d.jsxs)("div",{ref:y,draggable:t,onDragStart:t?()=>n(a.id):void 0,onDragOver:t?b=>o(b,a.id):void 0,onDrop:t?()=>q(a.id):void 0,onDragEnd:t?r:void 0,onMouseEnter:()=>{if(h)return;let b=z();b&&i(a.id,b)},onMouseLeave:()=>{h||j()},className:`${L(c,g)} ${b?"bg-hover":""}`,children:[t&&(0,d.jsx)(s.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),(0,d.jsxs)("button",{type:"button",onClick:()=>{let b=z();b&&k(a.id,b)},className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",title:a.name,children:[(0,d.jsx)(p.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"flex-1 min-w-0 truncate",children:a.name}),(0,d.jsxs)("span",{className:"ml-auto flex items-center gap-1 flex-shrink-0 text-[10px] text-muted-foreground",children:[a.items.length>0&&a.items.length,(0,d.jsx)(w.A,{className:"w-3 h-3"})]})]}),t&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",onClick:()=>l(a.id),className:M,title:x("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>m(a.id),className:`${M} hover:text-destructive`,title:x("common.delete"),children:(0,d.jsx)(v.A,{className:"w-3 h-3"})})]})]})});function P({group:a,position:b,groupChoices:c,editId:e,isAdding:g,isDragActive:h,dragId:i,dragOverId:j,onMouseEnter:k,onMouseLeave:l,onSelect:m,onInsert:n,onStartEdit:p,onCommitEdit:q,onCancelEdit:r,onDelete:s,onStartAdd:t,onCommitAdd:u,onCancelAdd:v,onDragStart:w,onDragOver:y,onDrop:z,onDragEnd:A,management:B=!0}){let{t:C}=(0,f.Bd)();return(0,o.createPortal)((0,d.jsxs)("div",{[H]:"",onMouseEnter:k,onMouseLeave:()=>{h||l()},style:{left:b.left,top:b.top,width:b.width,maxHeight:b.maxHeight},className:"fixed z-50 p-2 bg-popover border border-border rounded-lg shadow-lv2 overflow-y-auto",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1 truncate",children:a.name}),B&&(0,d.jsx)("button",{type:"button",onClick:t,className:"p-0.5 text-muted-foreground hover:text-foreground rounded flex-shrink-0",title:C("chat.addQuickInstruction"),children:(0,d.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}),B&&g&&(0,d.jsx)(K,{initialValue:"",placeholder:C("chat.quickInstructionPlaceholder"),onCommit:a=>u(a),onCancel:v}),0===a.items.length&&!g&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:C("chat.noQuickInstructions")}),a.items.map(b=>e===b.id?(0,d.jsx)(K,{initialValue:b.text,placeholder:C("chat.quickInstructionPlaceholder"),groupChoices:c,initialGroupId:a.id,onCommit:(a,c)=>q(b.id,a,c),onCancel:r},`edit-${b.id}`):(0,d.jsx)(N,{item:b,isDragging:i===b.id,isDragOver:j===b.id&&i!==b.id,onSelect:m,onInsert:n,onEdit:p,onDelete:s,onDragStart:w,onDragOver:y,onDrop:z,onDragEnd:A,management:B},b.id))]}),document.body)}function Q({label:a,nodes:b,scope:c,openGroupId:g,flyoutPosition:h,onOpenFlyout:i,onCloseFlyout:j,onKeepFlyout:l,onSave:m,onSelect:n,onInsert:o,management:p=!0,onManage:q}){let{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)(null),[v,w]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(null),G=b.filter(B._9),H=g?G.find(a=>a.id===g)??null:null,J=(0,e.useRef)(b);J.current=b;let L=(0,e.useRef)(g);L.current=g;let M=(0,e.useRef)(null),R=(0,e.useCallback)(a=>{A(null),m(c,a)},[m,c]),S=(0,e.useCallback)(a=>{t(null),R([...J.current,{id:I(),text:a}])},[R]),T=(0,e.useCallback)(a=>{t(null),R([...J.current,{id:I(),name:a,items:[]}])},[R]),U=(0,e.useCallback)((a,b,c,d)=>{let e=J.current,f={id:a,text:b};if(c===d)return void R(e.map(b=>(0,B._9)(b)?b.id===d?{...b,items:b.items.map(b=>b.id===a?f:b)}:b:null===d&&b.id===a?f:b));let g=null===c?e.filter(b=>(0,B._9)(b)||b.id!==a):e.map(b=>(0,B._9)(b)&&b.id===c?{...b,items:b.items.filter(b=>b.id!==a)}:b);R(null===d?[...g,f]:g.map(a=>(0,B._9)(a)&&a.id===d?{...a,items:[...a.items,f]}:a))},[R]),V=(0,e.useCallback)((a,b)=>{R(J.current.map(c=>(0,B._9)(c)&&c.id===a?{...c,name:b}:c))},[R]),W=(0,e.useCallback)(async a=>{let b=J.current.find(b=>b.id===a);if(b&&(0,B._9)(b)&&b.items.length>0){if(!await (0,k.lJ)(r("chat.deleteInstructionGroupConfirm",{name:b.name,count:b.items.length}),{danger:!0,confirmText:r("common.delete")}))return;j()}A(null),R(J.current.filter(b=>b.id!==a))},[R,r,j]),X=(0,e.useCallback)(a=>{let b=L.current;b&&R(J.current.map(c=>(0,B._9)(c)&&c.id===b?a(c):c))},[R]),Y=(0,e.useCallback)(a=>{w(!1),X(b=>({...b,items:[...b.items,{id:I(),text:a}]}))},[X]),Z=(0,e.useCallback)(a=>{A(null),X(b=>({...b,items:b.items.filter(b=>b.id!==a)}))},[X]),$=(0,e.useCallback)((a,b,c)=>{U(a,b,L.current,c)},[U]),_=(0,e.useCallback)(a=>{M.current=a,D(a)},[]),aa=(0,e.useCallback)(()=>{_(null),F(null)},[_]),ab=(0,e.useCallback)(a=>{_(a),j()},[_,j]),ac=(0,e.useCallback)((a,b)=>{a.preventDefault(),F(b)},[]),ad=(a,b,c)=>{let d=a.findIndex(a=>a.id===b),e=a.findIndex(a=>a.id===c);if(d<0||e<0)return a;let f=[...a],[g]=f.splice(d,1);return f.splice(e,0,g),f},ae=(0,e.useCallback)(a=>{let b=M.current;aa(),b&&b!==a&&R(ad(J.current,b,a))},[R,aa]),af=(0,e.useCallback)(a=>{let b=M.current;aa(),b&&b!==a&&X(c=>({...c,items:ad(c.items,b,a)}))},[X,aa]),ag=a=>{let b=J.current.find(b=>(0,B._9)(b)&&b.id===a);return b&&(0,B._9)(b)?b.items.length:0},ah=(0,e.useCallback)((a,b)=>{i(c,a,b,ag(a),!1)},[i,c]),ai=(0,e.useCallback)((a,b)=>{L.current===a?j():i(c,a,b,ag(a),!0)},[i,j,c]);return(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:a}),p?(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)("button",{type:"button",onClick:()=>{A(null),t("group")},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:r("chat.addInstructionGroup"),children:(0,d.jsx)(y.A,{className:"w-3.5 h-3.5"})}),(0,d.jsx)("button",{type:"button",onClick:()=>{A(null),t("instruction")},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:r("chat.addQuickInstruction"),children:(0,d.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}):q?(0,d.jsx)("button",{type:"button",onClick:q,className:"p-1 text-muted-foreground hover:text-brand rounded hover:bg-hover transition-colors",title:r("common.edit"),"aria-label":r("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3.5 h-3.5"})}):null]}),"instruction"===s&&(0,d.jsx)(K,{initialValue:"",placeholder:r("chat.quickInstructionPlaceholder"),onCommit:a=>S(a),onCancel:()=>t(null)}),"group"===s&&(0,d.jsx)(K,{initialValue:"",placeholder:r("chat.instructionGroupNamePlaceholder"),onCommit:a=>T(a),onCancel:()=>t(null)}),0===b.length&&!s&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:r("chat.noQuickInstructions")}),b.map(a=>z===a.id?(0,B._9)(a)?(0,d.jsx)(K,{initialValue:a.name,placeholder:r("chat.instructionGroupNamePlaceholder"),onCommit:b=>V(a.id,b),onCancel:()=>A(null)},`edit-${a.id}`):(0,d.jsx)(K,{initialValue:a.text,placeholder:r("chat.quickInstructionPlaceholder"),groupChoices:G,initialGroupId:null,onCommit:(b,c)=>U(a.id,b,null,c),onCancel:()=>A(null)},`edit-${a.id}`):(0,B._9)(a)?(0,d.jsx)(O,{group:a,isOpen:g===a.id,isDragging:C===a.id,isDragOver:E===a.id&&C!==a.id,isDragActive:null!==C,onHoverOpen:ah,onHoverClose:j,onToggle:ai,onRename:A,onDelete:W,onDragStart:ab,onDragOver:ac,onDrop:ae,onDragEnd:aa,management:p},a.id):(0,d.jsx)(N,{item:a,isDragging:C===a.id,isDragOver:E===a.id&&C!==a.id,onSelect:n,onInsert:o,onEdit:A,onDelete:W,onDragStart:ab,onDragOver:ac,onDrop:ae,onDragEnd:aa,management:p},a.id)),H&&h&&(0,d.jsx)(P,{group:H,position:h,groupChoices:G,editId:z,isAdding:v,isDragActive:null!==C,dragId:C,dragOverId:E,onMouseEnter:l,onMouseLeave:j,onSelect:n,onInsert:o,onStartEdit:A,onCommitEdit:$,onCancelEdit:()=>A(null),onDelete:Z,onStartAdd:()=>{A(null),w(!0)},onCommitAdd:Y,onCancelAdd:()=>w(!1),onDragStart:_,onDragOver:ac,onDrop:af,onDragEnd:aa,management:p})]})}function R({cwd:a,anchorRef:b,onClose:c,onSelect:g,onInsert:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(null),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),s.current&&(clearTimeout(s.current),s.current=null)},[]),u=(0,e.useCallback)((a,b,c,d,e)=>{t();let f=()=>{var e;let f,g,h,i,j,k,l;return o({scope:a,groupId:b,position:(g=(e={width:window.innerWidth,height:window.innerHeight}).width-c.right-4-8,h=c.left-4-8,i=288,g>=288?f=c.right+4:h>=288?f=c.left-4-288:g>=h?(i=Math.max(180,g),f=c.right+4):(i=Math.max(180,h),f=c.left-4-i),f=Math.min(Math.max(8,f),Math.max(8,e.width-i-8)),k=Math.min(j=Math.max(90,.6*e.height),30*d+40),(l=c.top-4)+k>e.height-8&&(l=e.height-8-k),{left:f,top:l=Math.max(8,l),width:i,maxHeight:j})})};e?f():r.current=setTimeout(f,150)},[t]),v=(0,e.useCallback)(()=>{t(),s.current=setTimeout(()=>o(null),300)},[t]),w=(0,e.useCallback)(()=>t(),[t]),x=(0,e.useCallback)(async(b,c)=>{let d="global"===b?k:m;d(c);let e=await A.t4.runPromiseExit((0,B.hZ)("global"===b?{scope:"global",instructions:c}:{cwd:a,instructions:c}));return"Failure"===e._tag?(console.error(`Failed to save ${b} instructions:`,e.cause),!1):(e.value?.instructions&&d(e.value.instructions),!0)},[a]),y=(0,e.useCallback)(a=>{c(),g(a)},[c,g]),z=(0,e.useCallback)(a=>{c(),h(a)},[c,h]),C=(0,e.useCallback)(async a=>!!p&&x(p,a),[p,x]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"absolute bottom-full left-0 mb-2 w-80 max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lv2 z-50 max-h-[70vh] overflow-y-auto",children:[(0,d.jsx)(Q,{label:i("chat.globalInstructions"),nodes:j,scope:"global",openGroupId:n?.scope==="global"?n.groupId:null,flyoutPosition:n?.scope==="global"?n.position:null,onOpenFlyout:u,onCloseFlyout:v,onKeepFlyout:w,onSave:x,onSelect:y,onInsert:z,management:!1,onManage:()=>{t(),o(null),q("global")}}),a&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsx)(Q,{label:i("chat.projectInstructions"),nodes:l,scope:"project",openGroupId:n?.scope==="project"?n.groupId:null,flyoutPosition:n?.scope==="project"?n.position:null,onOpenFlyout:u,onCloseFlyout:v,onKeepFlyout:w,onSave:x,onSelect:y,onInsert:z,management:!1,onManage:()=>{t(),o(null),q("project")}})]})]}),p&&(0,d.jsx)(G,{title:i("global"===p?"chat.editGlobalInstructions":"chat.editProjectInstructions"),nodes:"global"===p?j:l,onSave:C,onClose:()=>q(null)})]})}var S=c(71697);let T=(0,e.memo)(function({onSend:a,disabled:b,cwd:c,engine:j,onShowGitStatus:k,onShowComments:l,onOpenNote:o,isFavorite:p,onToggleFavorite:q,onCreateScheduledTask:r,draft:s,setDraft:t,draftImages:u,setDraftImages:v}){let{t:w}=(0,f.Bd)(),x=(0,e.useState)(""),y=(0,e.useState)([]),[z,A]=void 0!==s&&t?[s,t]:x,[B,C]=void 0!==u&&v?[u,v]:y,[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(!1),H=(0,e.useRef)(null),I=(0,e.useRef)(null),J=(0,e.useCallback)(()=>{let a=H.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,e.useLayoutEffect)(()=>{J()},[z,J]);let K=(0,e.useMemo)(()=>j&&"claude"!==j?[]:[{name:"/plan",description:"Enable plan mode (read-only). /plan <task> to plan a task; /plan off to disable.",source:"builtin",argumentHint:"[task|off]"}],[j]),L=(0,S.n)({value:z,onChange:A,textareaRef:H,extraCommands:K}),M=(0,e.useCallback)(()=>{let c=z.trim();(c||B.length>0)&&!b&&(a(c,B.length>0?B:void 0),A(""),C([]),H.current&&(H.current.style.height="auto"))},[z,B,b,a]),N=(0,e.useCallback)(c=>{b||a(c)},[b,a]),O=(0,e.useCallback)(a=>{A(b=>{let c=b.replace(/\s+$/,"");return c?`${c}
736
- ${a}`:a}),requestAnimationFrame(()=>{let a=H.current;a&&(a.focus(),a.setSelectionRange(a.value.length,a.value.length))})},[]),P=(0,e.useCallback)(a=>{a.nativeEvent.isComposing||!L.handleKeyDown(a)&&("Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),M()))},[L,M]),Q=(0,e.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(w("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};C(a=>[...a,e])},e.readAsDataURL(c)}}},[w]),T=(0,e.useCallback)(a=>{C(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(m,{images:B,onRemove:T,disabled:b}),(0,d.jsx)(S.V,{ac:L,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64"}),(0,d.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[k&&(0,d.jsx)("button",{onClick:k,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:w("chat.viewGitChanges"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),l&&(0,d.jsx)("button",{onClick:l,className:"p-2 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95 rounded-lg transition-all",title:w("chat.viewAllComments"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),o&&(0,d.jsx)("button",{onClick:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:w("chat.projectNotes"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"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"})})}),q&&(0,d.jsx)("button",{onClick:q,className:`p-2 rounded-lg transition-all ${p?"text-amber-9 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95":"text-muted-foreground hover:text-amber-9 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95"}`,title:w(p?"sessions.removeFavorite":"sessions.addFavorite"),"aria-label":w(p?"sessions.removeFavorite":"sessions.addFavorite"),"aria-pressed":p,children:(0,d.jsx)(g.A,{className:"w-5 h-5",fill:p?"currentColor":"none"})}),r&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>E(!D),className:`p-2 rounded-lg transition-all ${D?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:w("chat.scheduledTasks"),children:(0,d.jsx)(h.A,{className:"w-5 h-5"})}),D&&(0,d.jsx)(n.E,{onClose:()=>E(!1),onCreate:r})]}),(0,d.jsxs)("div",{className:"relative",ref:I,children:[(0,d.jsx)("button",{onClick:()=>G(!F),className:`p-2 rounded-lg transition-all ${F?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:w("chat.quickInstructions"),children:(0,d.jsx)(i.A,{className:"w-5 h-5"})}),F&&(0,d.jsx)(R,{cwd:c,anchorRef:I,onClose:()=>G(!1),onSelect:N,onInsert:O})]}),(0,d.jsx)("textarea",{ref:H,value:z,onChange:a=>{A(a.target.value),L.trackCaret(a.target)},onSelect:a=>L.trackCaret(a.currentTarget),onKeyDown:P,onPaste:Q,placeholder:b?w("chat.placeholderDisabled"):w("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground"})]})]})})},80983:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(23700),j=c(92701),k=c(93780),l=c(61349),m=a([l,i,j]);[l,i,j]=m.then?(await m)():m;let p={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",ApplyPatch:"\uD83E\uDDE9",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function n(a){return"object"==typeof a&&null!==a}function o({toolCall:a,cwd:b,sessionId:c,disableOverlays:d=!1}){var m;let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(null),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(!1),z=p[a.name]||"\uD83D\uDD27",A="Agent"===a.name||"Task"===a.name,B=A&&!!b&&!!c,C="Workflow"===a.name,D=C&&(m=a.result)?m.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,E=C&&!!D&&!!b&&!!c,F=(0,k.v2)(a.id)??a.task,G=F?.status==="running",H=!!a.isLoading||G,I=F?G||!!a.isLoading:!a.result,J=G?[F?.lastToolName,F?.toolUses?String(F.toolUses):null].filter(Boolean).join(" \xb7 "):"",K="Skill"===a.name,L="ApplyPatch"===a.name||A||C||K,M=a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a},N=(()=>{let b=a.input;if("Bash"===a.name&&b.command&&"string"==typeof b.command)return b.command;if("ApplyPatch"===a.name&&Array.isArray(b.changes)){let a=b.changes.filter(n).flatMap(a=>{let b="string"==typeof a.path?a.path:"";if(!b)return[];let c="string"==typeof a.kind&&a.kind?a.kind:"update";return`${c} ${M(b)}`});if(a.length>0)return a.join(" \xb7 ")}if(A&&b.description&&"string"==typeof b.description)return b.description;if(C){let a="string"==typeof b.name?b.name:"",c="string"==typeof b.args?b.args:"string"==typeof b.resumeFromRunId?b.resumeFromRunId:"",d=[a,c].filter(Boolean).join(" \xb7 ");if(d)return d}if(K&&"string"==typeof b.skill){let a="string"==typeof b.args?b.args:"";return[b.skill,a].filter(Boolean).join(" \xb7 ")}return"Glob"===a.name&&b.pattern&&"string"==typeof b.pattern||"Grep"===a.name&&b.pattern&&"string"==typeof b.pattern?b.pattern:"ToolSearch"===a.name&&b.query&&"string"==typeof b.query?b.query:"TaskCreate"===a.name&&b.subject&&"string"==typeof b.subject?b.subject:b.file_path&&"string"==typeof b.file_path?b.file_path:b.path&&"string"==typeof b.path?b.path:null})(),O="Glob"===a.name||"Grep"===a.name||"Bash"===a.name||"ApplyPatch"===a.name||A||C||K,P=N?O?N:M(N):null,Q=b=>{let c="input"===b?q("toolCall.inputParams"):q("toolCall.resultLabel"),d="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);u({title:`${a.name}${P?` ${P}`:""} - ${c}`,content:d,toolName:a.name})};return(0,e.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,e.jsxs)("button",{onClick:()=>s(!r),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors",children:[(0,e.jsx)("span",{className:"text-sm",children:z}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),P&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":N||"",children:P}),!L&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),N&&(navigator.clipboard.writeText(N),(0,h.oR)(q("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),N&&(navigator.clipboard.writeText(N),(0,h.oR)(q("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:q("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[B&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),w(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),w(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("chat.subagentViewTitle"),children:q("chat.subagent")}),E&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),y(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),y(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("chat.workflowViewTitle"),children:q("chat.workflowRun")}),J&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:J}),r&&!a.isLoading&&!d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),Q("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),Q("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("toolCall.inputParamsTitle"),children:q("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),Q("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),Q("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("toolCall.resultTitle"),children:q("toolCall.result")})]}),H?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-foreground-subtle text-xs",children:r?"▲":"▼"})]})]}),r&&(0,e.jsxs)("div",{className:"border-t border-line-1",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]}),a.skillContent&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:a.skillContent})]})]}),t&&(0,e.jsx)(l.M,{title:t.title,content:t.content,toolName:t.toolName,onClose:()=>u(null)}),v&&b&&c&&(0,e.jsx)(i.f,{cwd:b,sessionId:c,toolCall:a,running:I,onClose:()=>w(!1)}),x&&b&&c&&D&&(0,e.jsx)(j.K,{cwd:b,sessionId:c,runId:D,isRunning:H,onClose:()=>y(!1)})]})}d()}catch(a){d(a)}})},81064:(a,b,c)=>{Promise.resolve().then(c.bind(c,81227))},81206:(a,b,c)=>{"use strict";c.d(b,{z:()=>h,m:()=>j});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=a=>e.$mh({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})}),i=new Map;function j(a,b,c,{cwd:k,initialSessionId:l,onSessionId:m,onTitleChange:n,onTokenUsage:o,liveRunningRef:p}){let[q,r]=(0,d.useState)(!1),[s,t]=(0,d.useState)(!1),[u,v]=(0,d.useState)(!1),[w,x]=(0,d.useState)(void 0),[y,z]=(0,d.useState)(0),[A,B]=(0,d.useState)(null),[C,D]=(0,d.useState)(null),[E,F]=(0,d.useState)(null),G=(0,d.useRef)(null);G.current=A;let H=(0,d.useRef)(n);H.current=n;let I=(0,d.useRef)(o);I.current=o;let J=(0,d.useRef)(void 0),K=(0,d.useRef)(0),L=(0,d.useCallback)(async(a,c,d=!1,e,g,j=!1)=>{if(d){let a=Date.now();if(!j&&a-K.current<5e3)return;K.current=a}let k=(a,d)=>{a.fingerprint&&(J.current=a.fingerprint),void 0!==a.totalTurns&&z(a.totalTurns),void 0!==a.hasMore&&v(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>(function(a,b){if(0===b.length)return a;let c=0;if(a.length>0&&a[0].id!==b[0].id){c=-1;for(let d=a.length-1;d>=0;d--)if(a[d].id===b[0].id){c=d;break}}if(c<0)return b;let d=a.slice(c),e=0;for(let a=0;a<Math.min(d.length,b.length)&&d[a].id===b[a].id&&d[a].content===b[a].content;a++)e=a+1;return e===d.length&&e===b.length?a:e===d.length&&e<b.length?[...a,...b.slice(e)]:[...a.slice(0,c),...d.slice(0,e),...b.slice(e)]})(b,a.messages)):p?.current||b(a.messages),B(c)),a.sessionId&&m(a.sessionId),a.engine&&D(a.engine),F(a.bot??null),a.title&&H.current?.(a.title),a.usage&&I.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})},l=`${a}::${c}`;j&&i.delete(l);let n=!d&&void 0===g,o=n?i.get(l):void 0;d||(o?k(o.data,!1):r(!0));try{let b={cwd:a,sessionId:c,limit:e,beforeTurnIndex:g};d&&J.current?b.ifFingerprint=J.current:o&&(b.ifFingerprint=o.fingerprint);let j=await f.t4.runPromiseExit(h(b));if("Success"===j._tag&&j.value){let a=j.value;if(a.notModified)return;if(k(a,d),n&&a.fingerprint&&a.messages&&a.messages.length>0&&(i.delete(l),i.set(l,{data:a,fingerprint:a.fingerprint}),i.size>20)){let a=i.keys().next().value;void 0!==a&&i.delete(a)}}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||r(!1)}},[b,m]),M=(0,d.useCallback)(async()=>{if(k&&c&&!s&&u){t(!0);try{let d=void 0!==w?w:y-Math.ceil(a.filter(a=>"user"===a.role).length),e=await f.t4.runPromiseExit(h({cwd:k,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;x(a.startTurnIndex??d-e),B(c)}void 0!==a.hasMore&&v(a.hasMore),a.fingerprint&&(J.current=a.fingerprint)}else"Failure"===e._tag&&console.error("Failed to load more history:",e.cause)}finally{t(!1)}}},[k,c,s,u,w,y,a,b]);return{isLoadingHistory:q,isLoadingMore:s,hasMoreHistory:u,loadMoreHistory:M,ensureTurnLoaded:(0,d.useCallback)(async a=>{let d=G.current??c;if(k&&d&&!(a<0)){t(!0);try{let c=await f.t4.runPromiseExit(h({cwd:k,sessionId:d,fromTurnIndex:a}));if("Failure"===c._tag)return void console.error("Failed to load turns for jump:",c.cause);if(!c.value||G.current&&G.current!==d)return;let e=c.value;if(e.messages&&e.messages.length>0){let c=e.messages;b(a=>(function(a,b){if(0===b.length)return a;let c=new Set(b.map(a=>a.id)),d=a.map(a=>c.has(a.id)).lastIndexOf(!0);if(d<0)return b;let e=a.slice(d+1);return 0===e.length?b:[...b,...e]})(a,c)),x(e.startTurnIndex??a),B(d)}void 0!==e.totalTurns&&z(e.totalTurns),void 0!==e.hasMore&&v(e.hasMore),e.fingerprint&&(J.current=e.fingerprint)}finally{t(!1)}}},[k,c,b]),loadHistory:(0,d.useCallback)(async a=>{if(!k)return;r(!0);let c=e.$mh({try:async()=>{let b=await fetch(`/api/session/${encodeURIComponent(a)}/history?cwd=${encodeURIComponent(k)}`);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),B(a)):"Failure"===d._tag&&console.error("Failed to load history:",d.cause),r(!1)},[k,b]),loadHistoryByCwdAndSessionId:L,loadedSessionId:A,loadedEngine:C,loadedBot:E}}},81227:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx","default")},81608:(a,b,c)=>{"use strict";c.d(b,{_:()=>e,a:()=>f});let d=(0,c(41830).N)("cockpit-bots"),e=d.notify,f=d.subscribe},82338:(a,b,c)=>{"use strict";c.d(b,{B:()=>f});var d=c(48249),e=c(40311);function f({number:a,status:b="normal",isActive:c=!1}){return(0,d.jsx)("span",{className:`flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-[4px] border font-mono text-[10px] font-medium leading-none tabular-nums transition-colors ${(0,e.ci)(b,c)}`,"aria-hidden":"true",children:a})}},82795:(a,b,c)=>{"use strict";c.d(b,{e:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(15819),h=c(33281),i=c(41224),j=c(32753),k=c(74228),l=c(1512);function m({isOpen:a,onClose:b,onSwitchProject:c,sessionNumbers:n={}}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(""),x=(0,e.useRef)(null);(0,e.useCallback)(async()=>{s(!0),u(null);let a=await h.t4.runPromiseExit((0,i.z2)());"Success"===a._tag?q([...a.value]):u(o("sessions.loadSessionsFailed")),s(!1)},[o]);let y=(0,l.H)(p).filter(a=>{if(!v)return!0;let b=v.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.cwd.toLowerCase().includes(b)||(a.title?.toLowerCase().includes(b)??!1)||(a.lastUserMessage?.toLowerCase().includes(b)??!1)||(a.firstMessages?.some(a=>a.toLowerCase().includes(b))??!1)||(a.lastMessages?.some(a=>a.toLowerCase().includes(b))??!1)});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:g.aO,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:o("sessions.recentSessions")})}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{ref:x,type:"text",placeholder:o("sessions.searchSessions"),value:v,onChange:a=>w(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),v&&(0,d.jsx)("button",{onClick:()=>{w(""),x.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:o("fileBrowser.clear"),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"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[r&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:o("sessions.loadingSessions")})]})}),t&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:t})}),!r&&!t&&0===y.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:v?o("sessions.noMatchingSessions"):o("sessions.noSessions")})}),!r&&!t&&y.length>0&&(0,d.jsx)("div",{className:g.jL,children:y.map(a=>{let e;return(0,d.jsxs)("div",{onClick:()=>{c(a.cwd,a.sessionId),b()},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)(j.S,{engine:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":a.cwd,children:(e=a.cwd).split("/").pop()||e}),(0,d.jsx)(k.l,{coordinate:n[`${a.cwd}
735
+ ${g}`],[k,l]=h?.split(".")??[];return(0,e.jsxs)("div",{onClick:()=>{var d;let e,f;return d=a.fullPath,e=b.path.split("/").pop()||"",f=b.sessionId||e.replace(".jsonl",""),void(c?c(d,f):(0,i.F)(j.n.OpenProject,{cwd:d,sessionId:f}))},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,e.jsx)(o.S,{engine:b.engine}),(0,e.jsx)("h4",{className:"text-xs font-medium text-foreground truncate","data-tooltip":b.title,children:b.title}),h&&(0,e.jsx)(n.l,{projectNumber:k,sessionNumber:l,bot:b.bot,className:"ml-auto"})]}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:(d=b.modifiedAt,new Date(d).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}))}),(0,e.jsxs)("div",{className:"space-y-0.5 text-xs",children:[b.firstMessages.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),b.lastMessages.length>0&&(0,e.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),b.lastMessages.map((a,b)=>(0,e.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,e.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]})]},b.path)})})]})]},a.encodedPath)})]})]})]}):null}d()}catch(a){d(a)}})},77156:(a,b,c)=>{"use strict";c.d(b,{Bz:()=>h,Hy:()=>e,L5:()=>f,hp:()=>g});var d=c(27668);let e=()=>(0,d.zi)("/api/skills"),f=a=>(0,d.zi)("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),g=a=>(0,d.zi)(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),h=a=>(0,d.zi)(`/api/skills/content?id=${encodeURIComponent(a)}`)},77220:(a,b,c)=>{"use strict";c.d(b,{SettingsModal:()=>n});var d=c(48249),e=c(67484),f=c(44384),g=c(83768),h=c(7833),i=c(28602),j=c(15105),k=c(33281),l=c(79606),m=c(65484);function n({isOpen:a,onClose:b}){let{t:c,i18n:o}=(0,f.Bd)(),{theme:p,setTheme:q}=(0,g.DP)(),r=(0,j.G)(),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)("auto"),A=(0,e.useCallback)(a=>{z(a),k.t4.runFork((0,m.DZ)({language:a}).pipe(l.NWQ(()=>l.rIH)));let b="auto"===a?navigator.language.startsWith("zh")?"zh":"en":a;o.changeLanguage(b)},[o]),B=r?"installed":"not-installed",C=r?.version??null;if(!a)return null;let D=[{value:"system",label:c("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:c("settings.themeLight"),icon:"☀️"},{value:"dark",label:c("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:"relative bg-card rounded-lg shadow-lv3 w-full max-w-2xl mx-4 overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:c("settings.title")}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsxs)("div",{className:"p-4 space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.theme")}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:D.map(a=>(0,d.jsxs)("button",{onClick:()=>q(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${p===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"text-xl",children:a.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.language")}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:c("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(a=>(0,d.jsxs)("button",{onClick:()=>A(a.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${y===a.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,d.jsx)("span",{className:"text-xl",children:a.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:a.label})]},a.value))})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.browserExtension")}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===B?"bg-green-500":"bg-slate-400"}`}),(0,d.jsxs)("span",{children:["installed"===B&&`${c("settings.extensionInstalled")}${C?` (v${C})`:""}`,"not-installed"===B&&c("settings.extensionNotInstalled")]})]}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:c("settings.extensionDescription")}),"installed"!==B&&(0,d.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,d.jsx)("p",{className:"font-medium text-foreground",children:c("settings.installSteps")}),(0,d.jsxs)("p",{children:[c("settings.step1")," ",(0,d.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,d.jsx)("p",{children:c("settings.step2")}),(0,d.jsx)("p",{children:c("settings.step3")}),(0,i.L)()&&(0,d.jsx)("p",{dangerouslySetInnerHTML:{__html:c("settings.step4mac")}})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:()=>{let a=s||"chrome-extension";navigator.clipboard.writeText(a),(0,h.oR)(c("toast.copiedName",{name:a}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:c("settings.copyExtensionPath")}),"installed"===B&&(0,d.jsx)("button",{onClick:()=>{r?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(r.id,{type:"reload"}),(0,h.oR)(c("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:c("settings.reloadExtension")})]}),s&&(0,d.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:s})]})]}),(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:c("settings.about")}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,d.jsxs)("p",{children:["Cockpit",u?` v${u}`:""]}),(w?.claude||w?.codex)&&(0,d.jsx)("p",{className:"text-muted-foreground/60",children:[w.claude&&`Claude Code ${w.claude}`,w.codex&&`Codex ${w.codex}`,c("settings.agentsBundled")].filter(Boolean).join(" \xb7 ")}),(0,d.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}},77462:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManager:()=>K});var e=c(48249),f=c(67484),g=c(44384),h=c(14222),i=c(43209),j=c(70151),k=c(6900),l=c(85905),m=c(32465),n=c(75513),o=c(57632),p=c(79327),q=c(39796),r=c(94192),s=c(44256),t=c(37129),u=c(38878),v=c(3588),w=c(92340),x=c(52490),y=c(18946),z=c(29939),A=c(98982),B=c(13054),C=c(79606),D=c(23734),E=c(88214),F=c(33281),G=c(65484);c(37388);var H=a([t,u,v,y,o,j]);function I(a,b){if(!b.split)return{};let c=b.panes.indexOf(a);return -1===c?{}:{peerTabId:b.panes[1-c],peerSide:0===c?"right":"left"}}function J({tabId:a,panes:b,activePane:c,row:d,maximized:f,onFocusPane:h,onClosePane:i,onToggleMaximize:j,children:k}){let{t:l}=(0,g.Bd)(),m=b.indexOf(a),n=b.length>1;return(0,e.jsxs)("div",{onMouseDownCapture:n?()=>h(m):void 0,style:d&&-1!==m&&!f?{order:m}:void 0,className:`group/pane ${(0,q.vZ)(a,b,c,d,f)}`,children:[n&&-1!==m&&(0,e.jsxs)("div",{className:"absolute top-1 right-1 z-20 flex items-center gap-0.5 opacity-0 pointer-events-none transition-opacity focus-within:opacity-100 focus-within:pointer-events-auto group-hover/pane:opacity-100 group-hover/pane:pointer-events-auto",children:[(0,e.jsx)("button",{type:"button",onClick:()=>j(m),title:l(f?"chat.restorePane":"chat.maximizePane"),"aria-label":l(f?"chat.restorePane":"chat.maximizePane"),"aria-pressed":f,className:"flex items-center justify-center w-6 h-6 text-muted-foreground transition-colors hover:text-foreground",children:f?(0,e.jsx)(w.A,{className:"w-3.5 h-3.5"}):(0,e.jsx)(x.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:()=>i(m),title:l("chat.closePane"),"aria-label":l("chat.closePane"),className:"flex items-center justify-center w-6 h-6 text-muted-foreground transition-colors hover:text-foreground",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"})})})]}),k]})}function K({initialCwd:a,initialSessionId:b,initialBlank:c,initialView:d,initialFile:w,initialBubble:x}){let{t:H}=(0,g.Bd)(),[L,M]=(0,f.useState)(d??"agent"),[N,O]=(0,f.useState)(null),{tabs:P,activeTabId:Q,activeTab:R,paneTabIds:S,activePane:T,toggleSideBySide:U,focusPane:V,closePane:W,unreadTabs:X,globalLoadingTabs:Y,pageVisible:Z,dragTabIndex:$,dragOverTabIndex:_,closeTab:aa,closeAllTabs:ab,switchTab:ac,handleSelectSession:ad,handleNewTab:ae,handleNewCodexTab:af,handleNewKimiTab:ag,handleNewGlmTab:ah,handleNewOllamaTab:ai,handleNewDeepseekTab:aj,handleOpenSession:ak,updateTabState:al,updateTabEngine:am,updateTabOllamaModel:an,updateTabDeepseekModel:ao,updateTabKimiModel:ap,updateTabGlmModel:aq,updateTabClaudeModel:ar,updateTabClaudeEffort:as,updateTabClaudeFastMode:at,updateTabClaudeThinking:au,updateTabCodexModel:av,updateTabCodexReasoningEffort:aw,updateTabPlanMode:ax,updateTabNoHistory:ay,updateTabOutputStyle:az,handleTabDragStart:aA,handleTabDragOver:aB,handleTabDrop:aC,handleTabDragEnd:aD}=(0,t.useTabState)({initialCwd:a,initialSessionId:b,initialBlank:c,activeView:L}),{isPinned:aE,pinSession:aF,unpinSession:aG}=(0,A.P)(),{createTask:aH}=(0,B.nS)(),aI=(0,f.useCallback)(a=>{let b=P.find(b=>b.id===a);return!!b?.sessionId&&aE(b.sessionId)},[P,aE]),aJ=(0,f.useCallback)(b=>{let c=P.find(a=>a.id===b);c?.sessionId&&(aE(c.sessionId)?aG(c.sessionId):aF(c.sessionId,c.cwd||a||"",c.title))},[P,aE,aF,aG,a]),[aK,aL]=(0,f.useState)(!1),[aM,aN]=(0,f.useState)(!1),[aO,aP]=(0,f.useState)(!1),[aQ,aR]=(0,f.useState)(null),[aS,aT]=(0,f.useState)(!1),[aU,aV]=(0,f.useState)("tree"),[aW,aX]=(0,f.useState)(0),[aY,aZ]=(0,f.useState)(null),[a$,a_]=(0,f.useState)(0),[a0,a1]=(0,f.useState)(w?{path:w,nonce:0}:null),[a2,a3]=(0,f.useState)(x?{commandId:x,nonce:0}:null);(0,f.useRef)(()=>{});let[a4,a5]=(0,f.useState)(null),a6=null!==a4,a7=(0,f.useMemo)(()=>(0,q.p_)(S,T,Q,a6),[S,T,Q,a6]),[a8,a9]=(0,f.useState)(null),[ba,bb]=(0,f.useState)(),[bc,bd]=(0,f.useState)(!1);(0,f.useRef)(null);let be=(0,f.useCallback)(b=>{M(b),a&&(F.t4.runFork((0,G.Yn)({cwd:a,settings:{activeView:b}}).pipe(C.NWQ(()=>C.rIH))),F.t4.runFork(C.qIB(D.d,c=>c.publish(E.n.ViewChange,{cwd:a,view:b}))))},[a]),bf=(0,f.useCallback)(async()=>{if(!a)return;let b=await F.t4.runPromiseExit((0,G.b2)(a));if("Success"===b._tag){let c=b.value;if(aT(!!c.isGitRepo),c.isGitRepo&&c.worktrees&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&aR(b.branch)}}else console.error("Failed to load git info:",b.cause)},[a]),bg=(0,f.useCallback)(a=>{let{data:b}=a;Array.isArray(b)&&b.some(a=>"git"===a.type)&&bf()},[bf]);(0,z.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:bg,enabled:!!a});let bh=(0,f.useCallback)(()=>{aV("status"),aX(a=>a+1),be("explorer")},[be]),bi=(0,f.useCallback)(a=>{aZ(a),a_(a=>a+1),be("explorer")},[be]),bj=(0,f.useCallback)(()=>be("agent"),[be]),[bk,bl]=(0,f.useState)(!1),[bm,bn]=(0,f.useState)(!1),bo=(0,q.XL)(a7,bm),bp=(0,f.useCallback)(a=>{bn(a=>!a),V(a)},[V]),bq=(0,f.useCallback)(()=>bl(a=>!a),[]),br=(0,f.useCallback)(()=>a5(null),[]),bs=(0,f.useRef)(null),bt=(0,f.useCallback)(a=>{let b=bs.current;if(!b)return;let c=a.offset>0&&null!==a.target&&b.contains(a.target);if("move"===a.phase){if(!c)return;let d=Math.min(.5*a.offset,b.offsetWidth);b.style.transition="none",b.style.transform=`translateX(${d}px)`;return}c&&a.triggered?(b.style.transition="transform 140ms ease-out, opacity 140ms ease-out",b.style.transform="translateX(100%)",b.style.opacity="0",window.setTimeout(br,140)):(b.style.transition="transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)",b.style.transform="")},[br]),bu=(0,f.useRef)(a6),bv=(0,f.useRef)(bo),bw=(0,f.useCallback)(()=>{bu.current?br():null!==bv.current?bn(!1):U()},[U,br]),bx=(0,f.useCallback)((a,b,c,d,e)=>{a5(f=>(0,p.y)(f,{messageId:a,toolCalls:b,cwd:c,sessionId:d},!0===e)),e||be("agent")},[be]),by=(0,f.useCallback)(a=>{a1({...a,nonce:Date.now()}),be("explorer")},[be]),bz=(0,f.useCallback)(()=>{a&&F.t4.runFork(C.qIB(D.d,b=>b.publish(E.n.OpenNote,{cwd:a})))},[a]);return(0,e.jsx)(n.k_,{children:(0,e.jsx)(r.fY,{activeView:L,onViewChange:be,onOverscroll:bt,children:(0,e.jsxs)("div",{className:"flex h-screen bg-card",children:[(0,e.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,e.jsx)(u.TabManagerTopBar,{initialCwd:a,activeTab:R,isGitRepo:aS,currentBranch:aQ,onOpenWorktree:()=>aN(!0),onOpenAliasManager:()=>aP(!0),onBranchSwitched:bf}),bc&&(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-1 bg-brand/15 text-brand text-xs font-medium border-b border-brand/20",children:[(0,e.jsx)("span",{className:"animate-pulse",children:"●"}),H("console.screenshotting")]}),a?(0,e.jsxs)(r.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(s.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(v.TabBar,{tabs:P,selectedTabId:Q,sideBySide:a7.split,onToggleSideBySide:bw,unreadTabs:X,globalLoadingTabs:Y,dragTabIndex:$,dragOverTabIndex:_,isPinned:aI,onSwitchTab:ac,onCloseTab:aa,onCloseAllTabs:ab,onNewTab:ae,onNewCodexTab:af,onNewKimiTab:ag,onNewGlmTab:ah,onNewOllamaTab:ai,onNewDeepseekTab:aj,onOpenProjectSessions:()=>aL(!0),onDragStart:aA,onDragOver:aB,onDrop:aC,onDragEnd:aD}),(0,e.jsx)(h.c,{value:a7.split?N:null,children:(0,e.jsxs)("div",{className:`flex-1 overflow-hidden relative ${a7.row?"flex":""}`,children:[P.map(a=>(0,e.jsx)(J,{tabId:a.id,panes:a7.panes,activePane:a7.activePane,row:a7.row,maximized:bo===a.id,onFocusPane:V,onClosePane:W,onToggleMaximize:bp,children:(0,e.jsx)(y.X,{tabId:a.id,...I(a.id,a7),cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:am,ollamaModel:a.ollamaModel,onOllamaModelChange:an,deepseekModel:a.deepseekModel,onDeepseekModelChange:ao,kimiModel:a.kimiModel,onKimiModelChange:ap,glmModel:a.glmModel,onGlmModelChange:aq,claudeModel:a.claudeModel,onClaudeModelChange:ar,claudeEffort:a.claudeEffort,onClaudeEffortChange:as,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:at,claudeThinking:a.claudeThinking,onClaudeThinkingChange:au,codexModel:a.codexModel,onCodexModelChange:av,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:aw,planMode:a.planMode,onPlanModeChange:ax,noHistory:a.noHistory,onNoHistoryChange:ay,outputStyle:a.outputStyle,onOutputStyleChange:az,isActive:(0,q.gF)(a.id,S,"agent"===L,Z),isFocused:a.id===Q,refreshSignal:a8,onStateChange:al,onShowGitStatus:bh,onContentSearch:bi,onShowFileDiff:bx,onOpenFileLink:by,onOpenNote:bz,isFavorite:aI(a.id),onToggleFavorite:aJ,onCreateScheduledTask:aH,onOpenSession:ak})},a.id)),a4&&(0,e.jsx)("div",{ref:bs,"data-diff-column":"",className:bk?"absolute inset-0 z-30 bg-card":"h-full flex-1 min-w-0 border-l border-border",style:bk?void 0:{order:a7.diffOrder},children:(0,e.jsx)(o.e$,{toolCalls:a4.toolCalls,cwd:a4.cwd,sessionId:a4.sessionId,onClose:br,onContentSearch:bi,fullscreen:bk,onToggleFullscreen:bq},a4.messageId)})]})}),a7.split&&(0,e.jsx)("div",{ref:O,className:"flex-shrink-0"})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden relative",children:(0,e.jsx)(s.a9,{children:(0,e.jsx)(j.g,{onClose:bj,cwd:a,initialTab:aU,tabSwitchTrigger:aW,initialSearchQuery:aY,searchQueryTrigger:a$,fileOpenRequest:a0})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(s.a9,{children:(0,e.jsx)(l.J,{cwd:a,tabId:"default",onOpenNote:bz,focusBubble:a2})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(v.TabBar,{tabs:P,selectedTabId:Q,sideBySide:a7.split,onToggleSideBySide:bw,unreadTabs:X,globalLoadingTabs:Y,dragTabIndex:$,dragOverTabIndex:_,isPinned:aI,onSwitchTab:ac,onCloseTab:aa,onCloseAllTabs:ab,onNewTab:ae,onNewCodexTab:af,onNewKimiTab:ag,onNewGlmTab:ah,onNewDeepseekTab:aj,onDragStart:aA,onDragOver:aB,onDrop:aC,onDragEnd:aD}),(0,e.jsx)(h.c,{value:a7.split?N:null,children:(0,e.jsx)("div",{className:`flex-1 overflow-hidden relative ${a7.row?"flex":""}`,children:P.map(a=>(0,e.jsx)(J,{tabId:a.id,panes:a7.panes,activePane:a7.activePane,row:a7.row,maximized:bo===a.id,onFocusPane:V,onClosePane:W,onToggleMaximize:bp,children:(0,e.jsx)(y.X,{tabId:a.id,...I(a.id,a7),cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:am,ollamaModel:a.ollamaModel,onOllamaModelChange:an,deepseekModel:a.deepseekModel,onDeepseekModelChange:ao,kimiModel:a.kimiModel,onKimiModelChange:ap,glmModel:a.glmModel,onGlmModelChange:aq,claudeModel:a.claudeModel,onClaudeModelChange:ar,claudeEffort:a.claudeEffort,onClaudeEffortChange:as,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:at,claudeThinking:a.claudeThinking,onClaudeThinkingChange:au,codexModel:a.codexModel,onCodexModelChange:av,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:aw,planMode:a.planMode,onPlanModeChange:ax,noHistory:a.noHistory,onNoHistoryChange:ay,outputStyle:a.outputStyle,onOutputStyleChange:az,isActive:(0,q.gF)(a.id,S,!0,Z),isFocused:a.id===Q,refreshSignal:a8,onStateChange:al,isFavorite:aI(a.id),onToggleFavorite:aJ,onCreateScheduledTask:aH,onOpenSession:ak})},a.id))})}),a7.split&&(0,e.jsx)("div",{ref:O,className:"flex-shrink-0"})]})]}),a&&(0,e.jsx)(i.Q,{isOpen:aK,onClose:()=>aL(!1),cwd:a,onSelectSession:ad,projectNumber:ba,openSessionIds:P.map(a=>a.sessionId)}),a&&aS&&(0,e.jsx)(k.x,{isOpen:aM,onClose:()=>aN(!1),cwd:a}),aO&&(0,e.jsx)(m.Y,{onClose:()=>aP(!1),onSave:()=>aP(!1)})]})})})}[t,u,v,y,o,j]=H.then?(await H)():H,d()}catch(a){d(a)}})},77774:(a,b,c)=>{"use strict";c.d(b,{C:()=>h,x:()=>g});var d=c(79606),e=c(71192);let f=a=>`cockpit:active-tab:${a}`,g=a=>d.SvU({try:()=>{let b=window.sessionStorage.getItem(f(a));if(!b)return null;let c=JSON.parse(b);return"blank"===c.kind?{kind:"blank"}:"session"===c.kind&&"string"==typeof c.sessionId&&c.sessionId?{kind:"session",sessionId:c.sessionId}:null},catch:a=>new e.uV({message:"load active tab target failed",cause:a})}),h=(a,b)=>d.SvU({try:()=>window.sessionStorage.setItem(f(a),JSON.stringify(b)),catch:a=>new e.uV({message:"save active tab target failed",cause:a})})},79327:(a,b,c)=>{"use strict";function d(a,b,c){return c?a?.messageId!==b.messageId?a:{...a,toolCalls:b.toolCalls}:b}c.d(b,{y:()=>d})},80118:(a,b,c)=>{"use strict";c.d(b,{R:()=>j});var d=c(66142),e=c(10259),f=c(37361);let g=new e.hs("headingFold");function h(a){let b=a.attrs.foldState;return"folded"===b||"children"===b?b:"expanded"}function i(a){let b=[],c=[];return a.forEach((a,d)=>{let e=d+a.nodeSize;if("heading"===a.type.name){let g=a.attrs.level;for(;c.length&&c[c.length-1].level>=g;)c.pop();let i=h(a),j=c.some(a=>"folded"===a.state),k=["note-heading"];"expanded"!==i&&k.push("is-collapsed"),j&&k.push("note-folded-hidden"),b.push(f.NZ.node(d,e,{class:k.join(" ")})),b.push(f.NZ.widget(d+1,(a,b)=>{let c;return(c=document.createElement("span")).className="note-fold-toggle",c.contentEditable="false",c.setAttribute("data-fold-state",i),c.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation();let d=b();if(null==d)return;let e=d-1,f=a.state.doc.nodeAt(e);f&&"heading"===f.type.name&&a.dispatch(a.state.tr.setNodeMarkup(e,void 0,{...f.attrs,foldState:"expanded"===h(f)?"folded":"expanded"}))}),c},{side:-1,key:`fold-${d}-${i}`})),c.push({level:g,state:i})}else c.some(a=>"folded"===a.state||"children"===a.state)&&b.push(f.NZ.node(d,e,{class:"note-folded-hidden"}))}),f.zF.create(a,b)}let j=d.A.extend({addAttributes(){return{...this.parent?.(),foldState:{default:"expanded",keepOnSplit:!1,parseHTML:a=>"true"===a.getAttribute("data-collapsed")?"folded":"expanded",renderHTML:a=>a.foldState&&"expanded"!==a.foldState?{"data-collapsed":"true"}:{}}}},addKeyboardShortcuts(){let a=this.name;return{Tab:()=>{var b;let c,d,e,{state:f}=this.editor,{$from:g}=f.selection;if(g.parent.type.name!==a)return!1;let i=g.before(g.depth),j=f.doc.nodeAt(i);if(!j||j.type.name!==a)return!1;let k=j.attrs.level,l=(b=f.doc,d=[],e=!1,b.forEach((b,c)=>{if(c===i){e=!0;return}if(e&&b.type.name===a){if(b.attrs.level<=k){e=!1;return}d.push(c)}}),d),m=l.length>0,n=h(j),o=null;return m?"expanded"===n?c="folded":(c="folded"===n?"children":"expanded",o="expanded"):c="expanded"===n?"folded":"expanded",this.editor.chain().command(({tr:b})=>{if(b.setNodeMarkup(i,void 0,{...j.attrs,foldState:c}),o)for(let c of l){let d=b.doc.nodeAt(c);d&&d.type.name===a&&b.setNodeMarkup(c,void 0,{...d.attrs,foldState:o})}return!0}).run()}}},addStorage:()=>({markdown:{serialize(a,b){a.write(a.repeat("#",b.attrs.level)+" "),a.renderInline(b,!1),"expanded"!==h(b)&&a.write(" \x3c!-- fold --\x3e"),a.closeBlock(b)},parse:{updateDOM(a){a.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(a=>{let b=a.lastChild;for(;b&&3===b.nodeType&&!(b.textContent||"").trim();){let c=b.previousSibling;a.removeChild(b),b=c}if(b&&8===b.nodeType&&/^\s*fold\s*$/.test(b.textContent||"")){let c=b.previousSibling;a.removeChild(b),c&&3===c.nodeType&&(c.textContent=(c.textContent||"").replace(/\s+$/,"")),a.setAttribute("data-collapsed","true")}})}}}}),addProseMirrorPlugins:()=>[new e.k_({key:g,state:{init:(a,{doc:b})=>i(b),apply:(a,b)=>a.docChanged?i(a.doc):b},props:{decorations:a=>g.getState(a)}})]})},80514:(a,b,c)=>{"use strict";c.d(b,{V:()=>T});var d=c(48249),e=c(67484),f=c(44384),g=c(16944),h=c(29588),i=c(3623),j=c(44256),k=c(7833);function l({image:a,onClose:b}){let{t:c}=(0,f.Bd)(),e=async b=>{b.stopPropagation();try{var d;if(!navigator.clipboard?.write||"u"<typeof ClipboardItem)throw Error("Clipboard image write is unavailable");let b=await (d=a.preview,new Promise((a,b)=>{let c=new Image;c.onload=()=>{let d=document.createElement("canvas");d.width=c.naturalWidth,d.height=c.naturalHeight;let e=d.getContext("2d");e?(e.drawImage(c,0,0),d.toBlob(c=>{c?a(c):b(Error("Could not encode image"))},"image/png")):b(Error("Canvas is unavailable"))},c.onerror=()=>b(Error("Could not load image")),c.src=d}));await navigator.clipboard.write([new ClipboardItem({"image/png":b})]),(0,k.oR)(c("imagePreview.copiedImage"),"success")}catch{(0,k.oR)(c("common.copyFailed"),"error")}},g=(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:b,children:[(0,d.jsxs)("div",{className:"absolute top-4 right-4 flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:e,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:c("imagePreview.copyImage"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V5a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2M7 7h6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z"})})}),(0,d.jsx)("button",{type:"button",onClick:b,className:"w-10 h-10 flex items-center justify-center text-white/80 hover:text-white bg-black/40 hover:bg-black/60 rounded-full transition-colors",title:c("common.close"),children:(0,d.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("img",{src:a.preview,alt:c("imagePreview.previewImage"),className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:a=>a.stopPropagation()})]});return(0,d.jsx)(j.ZL,{children:g})}function m({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[h,i]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>i(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),h&&(0,d.jsx)(l,{image:h,onClose:()=>i(null)})]})}var n=c(30458),o=c(74429),p=c(65032),q=c(44218),r=c(42742),s=c(33999),t=c(74118),u=c(12625),v=c(46674),w=c(19794),x=c(24520),y=c(76193),z=c(72529),A=c(33281),B=c(41224),C=c(57063);let D=()=>Math.random().toString(36).slice(2,10),E=a=>a.replace(/\\n/g,"\n");function F(a){let b=[],c=null;for(let[d,e]of a.split(/\r?\n/).entries()){if(!e.trim())continue;let a=e.match(/^\s*-(?:\s+(.*))?$/);if(a){let b=(a[1]??"").trim();if(!c)return{ok:!1,line:d+1};c.isGroup=!0,b&&c.children.push(E(b));continue}if(/^\s/.test(e))return{ok:!1,line:d+1};let f=e.trim();f&&(c={text:E(f),children:[],isGroup:!1},b.push(c))}return{ok:!0,nodes:b.map(a=>a.isGroup?{id:D(),name:a.text,items:a.children.map(a=>({id:D(),text:a}))}:{id:D(),text:a.text})}}function G({title:a,nodes:b,onSave:c,onClose:g}){let{t:h}=(0,f.Bd)(),[i,k]=(0,e.useState)(()=>b.flatMap(a=>(0,B._9)(a)?[a.name.replace(/\n/g,"\\n"),...a.items.length>0?a.items.map(a=>`- ${a.text.replace(/\n/g,"\\n")}`):["- "]]:[a.text.replace(/\n/g,"\\n")]).join("\n")),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(!1),p=F(i);(0,C.E)(g);let q=(0,e.useCallback)(async()=>{let a=F(i);!a.ok||l||((m(!0),o(!1),await c(a.nodes))?g():(m(!1),o(!0)))},[g,c,l,i]);return(0,d.jsx)(j.ZL,{children:(0,d.jsx)("div",{"data-quick-instruction-layer":"",className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onMouseDown:a=>{a.target===a.currentTarget&&g()},children:(0,d.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":a,className:"w-full max-w-4xl max-h-[90vh] bg-card border border-border rounded-xl shadow-lv3 flex flex-col",children:[(0,d.jsxs)("header",{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-sm font-medium text-foreground",children:a}),(0,d.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h("chat.quickInstructionsMarkdownHint")})]}),(0,d.jsx)("button",{type:"button",onClick:g,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded","aria-label":h("common.cancel"),children:(0,d.jsx)(v.A,{className:"w-4 h-4"})})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 px-4 py-3",children:(0,d.jsx)("textarea",{autoFocus:!0,wrap:"off",value:i,onChange:a=>k(a.target.value),placeholder:h("chat.quickInstructionsMarkdownPlaceholder"),rows:24,spellCheck:!1,className:"w-full h-[60vh] min-h-80 max-h-[70vh] resize-y overflow-x-auto whitespace-pre px-3 py-2 text-sm font-mono leading-6 bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-brand"})}),(0,d.jsxs)("footer",{className:"flex items-center justify-between gap-3 px-4 py-3 border-t border-border",children:[(0,d.jsx)("span",{className:"text-xs text-destructive",children:p.ok?n?h("chat.saveQuickInstructionsFailed"):"":h("chat.quickInstructionsMarkdownError",{line:p.line})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:g,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground rounded hover:bg-hover",children:h("common.cancel")}),(0,d.jsx)("button",{type:"button",disabled:!p.ok||l,onClick:q,className:"px-3 py-1.5 text-xs rounded border border-brand text-brand hover:bg-brand/10 disabled:opacity-40",children:h(l?"chat.savingQuickInstructions":"common.save")})]})]})]})})})}let H="data-quick-instruction-layer",I=()=>Math.random().toString(36).slice(2,10);function J({groups:a,value:b,onChange:c,onSubmit:g,onCancel:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,s]=(0,e.useState)(0),t=(0,e.useRef)(null),u=(0,e.useRef)(null),v=[null,...a.map(a=>a.id)],w=null===b?i("chat.instructionGroupNone"):a.find(a=>a.id===b)?.name??i("chat.instructionGroupNone"),x=(0,e.useCallback)(()=>{let c=t.current?.getBoundingClientRect();c&&(m(((a,b,c)=>{let d=Math.min(a.width,c.width-16),e=Math.min(Math.max(8,a.left),Math.max(8,c.width-d-8)),f=c.height-a.bottom-2-8,g=a.top-2-8,h=28*b+8;if(f>=Math.min(h,96)||f>=g)return{left:e,top:a.bottom+2,width:d,maxHeight:Math.max(28,Math.min(h,f))};let i=Math.max(28,Math.min(h,g));return{left:e,top:a.top-2-i,width:d,maxHeight:i}})(c,a.length+1,{width:window.innerWidth,height:window.innerHeight})),s(Math.max(0,v.indexOf(b))),k(!0))},[a.length,v,b]),y=(0,e.useCallback)(()=>{k(!1),m(null),t.current?.focus()},[]),z=(0,e.useCallback)(a=>{c(a),y()},[c,y]),A=(0,e.useCallback)(a=>{j?"Escape"===a.key?(a.preventDefault(),a.stopPropagation(),y()):"ArrowDown"===a.key?(a.preventDefault(),a.stopPropagation(),s(a=>Math.min(v.length-1,a+1))):"ArrowUp"===a.key?(a.preventDefault(),a.stopPropagation(),s(a=>Math.max(0,a-1))):"Enter"===a.key&&(a.preventDefault(),a.stopPropagation(),z(v[n]??null)):"ArrowDown"===a.key||" "===a.key?(a.preventDefault(),a.stopPropagation(),x()):"Enter"===a.key?(a.preventDefault(),a.stopPropagation(),g()):"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),h())},[j,x,y,z,v,n,g,h]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{ref:t,type:"button",onClick:()=>j?y():x(),onKeyDown:A,className:"w-[140px] min-w-0 flex-shrink-0 px-2 py-1 flex items-center gap-1 text-xs rounded border border-input bg-background hover:bg-hover focus:outline-none focus:ring-1 focus:ring-ring transition-colors",title:i("chat.instructionGroupLabel"),children:[(0,d.jsx)(p.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:`flex-1 min-w-0 truncate text-left ${null===b?"text-muted-foreground":""}`,children:w}),(0,d.jsx)(q.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"})]}),j&&l&&(0,o.createPortal)((0,d.jsx)("div",{ref:u,[H]:"",role:"listbox",style:{left:l.left,top:l.top,width:l.width,maxHeight:l.maxHeight},className:"fixed z-[60] py-1 bg-popover border border-border rounded-lg shadow-lv2 overflow-y-auto",children:v.map((c,e)=>{let f=c===b;return(0,d.jsxs)("button",{type:"button",role:"option","aria-selected":f,onClick:()=>z(c),onMouseEnter:()=>s(e),className:`w-full min-w-0 px-2 py-1 flex items-center gap-1.5 text-xs text-left transition-colors ${e===n?"bg-hover":""}`,children:[(0,d.jsx)(r.A,{className:`w-3 h-3 flex-shrink-0 ${f?"text-brand":"opacity-0"}`}),(0,d.jsx)("span",{className:`flex-1 min-w-0 truncate ${null===c?"text-muted-foreground":""}`,children:null===c?i("chat.instructionGroupNone"):a.find(a=>a.id===c)?.name})]},c??"__none__")})}),document.body)]})}function K({initialValue:a,placeholder:b,groupChoices:c,initialGroupId:f,onCommit:g,onCancel:h}){let[i,j]=(0,e.useState)(a),[k,l]=(0,e.useState)(f??null),m=(0,e.useCallback)(()=>{let a=i.trim();a&&g(a,k)},[i,k,g]),n=(0,e.useCallback)(a=>{"Enter"!==a.key||a.nativeEvent.isComposing?"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),h()):(a.preventDefault(),a.stopPropagation(),m())},[m,h]);return(0,d.jsxs)("div",{className:"mb-1 flex items-center gap-1",children:[(0,d.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),onKeyDown:n,placeholder:b,autoFocus:!0,className:"flex-1 min-w-0 px-2 py-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring"}),c&&c.length>0&&(0,d.jsx)(J,{groups:c,value:k,onChange:l,onSubmit:m,onCancel:h})]})}let L=(a,b)=>`flex items-center group min-w-0 rounded transition-opacity ${a?"opacity-50":""} ${b?"border-t-2 border-brand":""}`,M="p-1 text-muted-foreground hover:text-foreground rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",N=(0,e.memo)(function({item:a,isDragging:b,isDragOver:c,onSelect:e,onInsert:g,onEdit:h,onDelete:j,onDragStart:k,onDragOver:l,onDrop:m,onDragEnd:n,management:o=!0}){let{t:p}=(0,f.Bd)();return(0,d.jsxs)("div",{draggable:o,onDragStart:o?()=>k(a.id):void 0,onDragOver:o?b=>l(b,a.id):void 0,onDrop:o?()=>m(a.id):void 0,onDragEnd:o?n:void 0,className:L(b,c),children:[o&&(0,d.jsx)(s.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),(0,d.jsx)(z.m,{content:a.text,children:(0,d.jsxs)("button",{type:"button",onClick:()=>e(a.text),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",children:[(0,d.jsx)(t.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"truncate",children:a.text})]})}),(0,d.jsx)("button",{type:"button",onClick:()=>g(a.text),className:M,title:p("chat.insertQuickInstruction"),children:(0,d.jsx)(i.A,{className:"w-3 h-3"})}),o&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",onClick:()=>h(a.id),className:M,title:p("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>j(a.id),className:`${M} hover:text-destructive`,title:p("common.delete"),children:(0,d.jsx)(v.A,{className:"w-3 h-3"})})]})]})}),O=(0,e.memo)(function({group:a,isOpen:b,isDragging:c,isDragOver:g,isDragActive:h,onHoverOpen:i,onHoverClose:j,onToggle:k,onRename:l,onDelete:m,onDragStart:n,onDragOver:o,onDrop:q,onDragEnd:r,management:t=!0}){let{t:x}=(0,f.Bd)(),y=(0,e.useRef)(null),z=(0,e.useCallback)(()=>y.current?.getBoundingClientRect(),[]);return(0,d.jsxs)("div",{ref:y,draggable:t,onDragStart:t?()=>n(a.id):void 0,onDragOver:t?b=>o(b,a.id):void 0,onDrop:t?()=>q(a.id):void 0,onDragEnd:t?r:void 0,onMouseEnter:()=>{if(h)return;let b=z();b&&i(a.id,b)},onMouseLeave:()=>{h||j()},className:`${L(c,g)} ${b?"bg-hover":""}`,children:[t&&(0,d.jsx)(s.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),(0,d.jsxs)("button",{type:"button",onClick:()=>{let b=z();b&&k(a.id,b)},className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1.5 text-left text-sm rounded hover:bg-hover transition-colors",title:a.name,children:[(0,d.jsx)(p.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"flex-1 min-w-0 truncate",children:a.name}),(0,d.jsxs)("span",{className:"ml-auto flex items-center gap-1 flex-shrink-0 text-[10px] text-muted-foreground",children:[a.items.length>0&&a.items.length,(0,d.jsx)(w.A,{className:"w-3 h-3"})]})]}),t&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{type:"button",onClick:()=>l(a.id),className:M,title:x("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>m(a.id),className:`${M} hover:text-destructive`,title:x("common.delete"),children:(0,d.jsx)(v.A,{className:"w-3 h-3"})})]})]})});function P({group:a,position:b,groupChoices:c,editId:e,isAdding:g,isDragActive:h,dragId:i,dragOverId:j,onMouseEnter:k,onMouseLeave:l,onSelect:m,onInsert:n,onStartEdit:p,onCommitEdit:q,onCancelEdit:r,onDelete:s,onStartAdd:t,onCommitAdd:u,onCancelAdd:v,onDragStart:w,onDragOver:y,onDrop:z,onDragEnd:A,management:B=!0}){let{t:C}=(0,f.Bd)();return(0,o.createPortal)((0,d.jsxs)("div",{[H]:"",onMouseEnter:k,onMouseLeave:()=>{h||l()},style:{left:b.left,top:b.top,width:b.width,maxHeight:b.maxHeight},className:"fixed z-50 p-2 bg-popover border border-border rounded-lg shadow-lv2 overflow-y-auto",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1 truncate",children:a.name}),B&&(0,d.jsx)("button",{type:"button",onClick:t,className:"p-0.5 text-muted-foreground hover:text-foreground rounded flex-shrink-0",title:C("chat.addQuickInstruction"),children:(0,d.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}),B&&g&&(0,d.jsx)(K,{initialValue:"",placeholder:C("chat.quickInstructionPlaceholder"),onCommit:a=>u(a),onCancel:v}),0===a.items.length&&!g&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:C("chat.noQuickInstructions")}),a.items.map(b=>e===b.id?(0,d.jsx)(K,{initialValue:b.text,placeholder:C("chat.quickInstructionPlaceholder"),groupChoices:c,initialGroupId:a.id,onCommit:(a,c)=>q(b.id,a,c),onCancel:r},`edit-${b.id}`):(0,d.jsx)(N,{item:b,isDragging:i===b.id,isDragOver:j===b.id&&i!==b.id,onSelect:m,onInsert:n,onEdit:p,onDelete:s,onDragStart:w,onDragOver:y,onDrop:z,onDragEnd:A,management:B},b.id))]}),document.body)}function Q({label:a,nodes:b,scope:c,openGroupId:g,flyoutPosition:h,onOpenFlyout:i,onCloseFlyout:j,onKeepFlyout:l,onSave:m,onSelect:n,onInsert:o,management:p=!0,onManage:q}){let{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)(null),[v,w]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(null),G=b.filter(B._9),H=g?G.find(a=>a.id===g)??null:null,J=(0,e.useRef)(b);J.current=b;let L=(0,e.useRef)(g);L.current=g;let M=(0,e.useRef)(null),R=(0,e.useCallback)(a=>{A(null),m(c,a)},[m,c]),S=(0,e.useCallback)(a=>{t(null),R([...J.current,{id:I(),text:a}])},[R]),T=(0,e.useCallback)(a=>{t(null),R([...J.current,{id:I(),name:a,items:[]}])},[R]),U=(0,e.useCallback)((a,b,c,d)=>{let e=J.current,f={id:a,text:b};if(c===d)return void R(e.map(b=>(0,B._9)(b)?b.id===d?{...b,items:b.items.map(b=>b.id===a?f:b)}:b:null===d&&b.id===a?f:b));let g=null===c?e.filter(b=>(0,B._9)(b)||b.id!==a):e.map(b=>(0,B._9)(b)&&b.id===c?{...b,items:b.items.filter(b=>b.id!==a)}:b);R(null===d?[...g,f]:g.map(a=>(0,B._9)(a)&&a.id===d?{...a,items:[...a.items,f]}:a))},[R]),V=(0,e.useCallback)((a,b)=>{R(J.current.map(c=>(0,B._9)(c)&&c.id===a?{...c,name:b}:c))},[R]),W=(0,e.useCallback)(async a=>{let b=J.current.find(b=>b.id===a);if(b&&(0,B._9)(b)&&b.items.length>0){if(!await (0,k.lJ)(r("chat.deleteInstructionGroupConfirm",{name:b.name,count:b.items.length}),{danger:!0,confirmText:r("common.delete")}))return;j()}A(null),R(J.current.filter(b=>b.id!==a))},[R,r,j]),X=(0,e.useCallback)(a=>{let b=L.current;b&&R(J.current.map(c=>(0,B._9)(c)&&c.id===b?a(c):c))},[R]),Y=(0,e.useCallback)(a=>{w(!1),X(b=>({...b,items:[...b.items,{id:I(),text:a}]}))},[X]),Z=(0,e.useCallback)(a=>{A(null),X(b=>({...b,items:b.items.filter(b=>b.id!==a)}))},[X]),$=(0,e.useCallback)((a,b,c)=>{U(a,b,L.current,c)},[U]),_=(0,e.useCallback)(a=>{M.current=a,D(a)},[]),aa=(0,e.useCallback)(()=>{_(null),F(null)},[_]),ab=(0,e.useCallback)(a=>{_(a),j()},[_,j]),ac=(0,e.useCallback)((a,b)=>{a.preventDefault(),F(b)},[]),ad=(a,b,c)=>{let d=a.findIndex(a=>a.id===b),e=a.findIndex(a=>a.id===c);if(d<0||e<0)return a;let f=[...a],[g]=f.splice(d,1);return f.splice(e,0,g),f},ae=(0,e.useCallback)(a=>{let b=M.current;aa(),b&&b!==a&&R(ad(J.current,b,a))},[R,aa]),af=(0,e.useCallback)(a=>{let b=M.current;aa(),b&&b!==a&&X(c=>({...c,items:ad(c.items,b,a)}))},[X,aa]),ag=a=>{let b=J.current.find(b=>(0,B._9)(b)&&b.id===a);return b&&(0,B._9)(b)?b.items.length:0},ah=(0,e.useCallback)((a,b)=>{i(c,a,b,ag(a),!1)},[i,c]),ai=(0,e.useCallback)((a,b)=>{L.current===a?j():i(c,a,b,ag(a),!0)},[i,j,c]);return(0,d.jsxs)("div",{className:"p-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs font-medium text-muted-foreground px-1",children:a}),p?(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)("button",{type:"button",onClick:()=>{A(null),t("group")},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:r("chat.addInstructionGroup"),children:(0,d.jsx)(y.A,{className:"w-3.5 h-3.5"})}),(0,d.jsx)("button",{type:"button",onClick:()=>{A(null),t("instruction")},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:r("chat.addQuickInstruction"),children:(0,d.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}):q?(0,d.jsx)("button",{type:"button",onClick:q,className:"p-1 text-muted-foreground hover:text-brand rounded hover:bg-hover transition-colors",title:r("common.edit"),"aria-label":r("common.edit"),children:(0,d.jsx)(u.A,{className:"w-3.5 h-3.5"})}):null]}),"instruction"===s&&(0,d.jsx)(K,{initialValue:"",placeholder:r("chat.quickInstructionPlaceholder"),onCommit:a=>S(a),onCancel:()=>t(null)}),"group"===s&&(0,d.jsx)(K,{initialValue:"",placeholder:r("chat.instructionGroupNamePlaceholder"),onCommit:a=>T(a),onCancel:()=>t(null)}),0===b.length&&!s&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:r("chat.noQuickInstructions")}),b.map(a=>z===a.id?(0,B._9)(a)?(0,d.jsx)(K,{initialValue:a.name,placeholder:r("chat.instructionGroupNamePlaceholder"),onCommit:b=>V(a.id,b),onCancel:()=>A(null)},`edit-${a.id}`):(0,d.jsx)(K,{initialValue:a.text,placeholder:r("chat.quickInstructionPlaceholder"),groupChoices:G,initialGroupId:null,onCommit:(b,c)=>U(a.id,b,null,c),onCancel:()=>A(null)},`edit-${a.id}`):(0,B._9)(a)?(0,d.jsx)(O,{group:a,isOpen:g===a.id,isDragging:C===a.id,isDragOver:E===a.id&&C!==a.id,isDragActive:null!==C,onHoverOpen:ah,onHoverClose:j,onToggle:ai,onRename:A,onDelete:W,onDragStart:ab,onDragOver:ac,onDrop:ae,onDragEnd:aa,management:p},a.id):(0,d.jsx)(N,{item:a,isDragging:C===a.id,isDragOver:E===a.id&&C!==a.id,onSelect:n,onInsert:o,onEdit:A,onDelete:W,onDragStart:ab,onDragOver:ac,onDrop:ae,onDragEnd:aa,management:p},a.id)),H&&h&&(0,d.jsx)(P,{group:H,position:h,groupChoices:G,editId:z,isAdding:v,isDragActive:null!==C,dragId:C,dragOverId:E,onMouseEnter:l,onMouseLeave:j,onSelect:n,onInsert:o,onStartEdit:A,onCommitEdit:$,onCancelEdit:()=>A(null),onDelete:Z,onStartAdd:()=>{A(null),w(!0)},onCommitAdd:Y,onCancelAdd:()=>w(!1),onDragStart:_,onDragOver:ac,onDrop:af,onDragEnd:aa,management:p})]})}function R({cwd:a,anchorRef:b,onClose:c,onSelect:g,onInsert:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)([]),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(null),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),s.current&&(clearTimeout(s.current),s.current=null)},[]),u=(0,e.useCallback)((a,b,c,d,e)=>{t();let f=()=>{var e;let f,g,h,i,j,k,l;return o({scope:a,groupId:b,position:(g=(e={width:window.innerWidth,height:window.innerHeight}).width-c.right-4-8,h=c.left-4-8,i=288,g>=288?f=c.right+4:h>=288?f=c.left-4-288:g>=h?(i=Math.max(180,g),f=c.right+4):(i=Math.max(180,h),f=c.left-4-i),f=Math.min(Math.max(8,f),Math.max(8,e.width-i-8)),k=Math.min(j=Math.max(90,.6*e.height),30*d+40),(l=c.top-4)+k>e.height-8&&(l=e.height-8-k),{left:f,top:l=Math.max(8,l),width:i,maxHeight:j})})};e?f():r.current=setTimeout(f,150)},[t]),v=(0,e.useCallback)(()=>{t(),s.current=setTimeout(()=>o(null),300)},[t]),w=(0,e.useCallback)(()=>t(),[t]),x=(0,e.useCallback)(async(b,c)=>{let d="global"===b?k:m;d(c);let e=await A.t4.runPromiseExit((0,B.hZ)("global"===b?{scope:"global",instructions:c}:{cwd:a,instructions:c}));return"Failure"===e._tag?(console.error(`Failed to save ${b} instructions:`,e.cause),!1):(e.value?.instructions&&d(e.value.instructions),!0)},[a]),y=(0,e.useCallback)(a=>{c(),g(a)},[c,g]),z=(0,e.useCallback)(a=>{c(),h(a)},[c,h]),C=(0,e.useCallback)(async a=>!!p&&x(p,a),[p,x]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"absolute bottom-full left-0 mb-2 w-80 max-w-[calc(100vw-1.5rem)] bg-popover border border-border rounded-lg shadow-lv2 z-50 max-h-[70vh] overflow-y-auto",children:[(0,d.jsx)(Q,{label:i("chat.globalInstructions"),nodes:j,scope:"global",openGroupId:n?.scope==="global"?n.groupId:null,flyoutPosition:n?.scope==="global"?n.position:null,onOpenFlyout:u,onCloseFlyout:v,onKeepFlyout:w,onSave:x,onSelect:y,onInsert:z,management:!1,onManage:()=>{t(),o(null),q("global")}}),a&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsx)(Q,{label:i("chat.projectInstructions"),nodes:l,scope:"project",openGroupId:n?.scope==="project"?n.groupId:null,flyoutPosition:n?.scope==="project"?n.position:null,onOpenFlyout:u,onCloseFlyout:v,onKeepFlyout:w,onSave:x,onSelect:y,onInsert:z,management:!1,onManage:()=>{t(),o(null),q("project")}})]})]}),p&&(0,d.jsx)(G,{title:i("global"===p?"chat.editGlobalInstructions":"chat.editProjectInstructions"),nodes:"global"===p?j:l,onSave:C,onClose:()=>q(null)})]})}var S=c(71697);let T=(0,e.memo)(function({onSend:a,disabled:b,cwd:c,engine:j,onShowGitStatus:k,onShowComments:l,hasComments:o,onOpenNote:p,isFavorite:q,onToggleFavorite:r,onCreateScheduledTask:s,draft:t,setDraft:u,draftImages:v,setDraftImages:w}){let{t:x}=(0,f.Bd)(),y=(0,e.useState)(""),z=(0,e.useState)([]),[A,B]=void 0!==t&&u?[t,u]:y,[C,D]=void 0!==v&&w?[v,w]:z,[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),I=(0,e.useRef)(null),J=(0,e.useRef)(null),K=(0,e.useCallback)(()=>{let a=I.current;if(!a)return;a.style.height="auto";let b=Math.max(38,Math.min(a.scrollHeight,200));a.style.height=`${b}px`},[]);(0,e.useLayoutEffect)(()=>{K()},[A,K]);let L=(0,e.useMemo)(()=>j&&"claude"!==j?[]:[{name:"/plan",description:"Enable plan mode (read-only). /plan <task> to plan a task; /plan off to disable.",source:"builtin",argumentHint:"[task|off]"}],[j]),M=(0,S.n)({value:A,onChange:B,textareaRef:I,extraCommands:L}),N=(0,e.useCallback)(()=>{let c=A.trim();(c||C.length>0)&&!b&&(a(c,C.length>0?C:void 0),B(""),D([]),I.current&&(I.current.style.height="auto"))},[A,C,b,a]),O=(0,e.useCallback)(c=>{b||a(c)},[b,a]),P=(0,e.useCallback)(a=>{B(b=>{let c=b.replace(/\s+$/,"");return c?`${c}
736
+ ${a}`:a}),requestAnimationFrame(()=>{let a=I.current;a&&(a.focus(),a.setSelectionRange(a.value.length,a.value.length))})},[]),Q=(0,e.useCallback)(a=>{a.nativeEvent.isComposing||!M.handleKeyDown(a)&&("Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),N()))},[M,N]),T=(0,e.useCallback)(a=>{let b=a.clipboardData?.items;if(!b)return;let c=["image/png","image/jpeg","image/webp","image/gif"];for(let d of Array.from(b)){let b=c.find(a=>d.type===a);if(b){a.preventDefault();let c=d.getAsFile();if(!c)continue;if(c.size>5242880){alert(x("chat.imageSizeLimit",{size:(c.size/1024/1024).toFixed(2)}));continue}let e=new FileReader;e.onload=a=>{let c=a.target?.result;if(!c)return;let d=c.replace(/^data:image\/\w+;base64,/,""),e={id:`img-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,data:d,preview:c,media_type:b};D(a=>[...a,e])},e.readAsDataURL(c)}}},[x]),U=(0,e.useCallback)(a=>{D(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(m,{images:C,onRemove:U,disabled:b}),(0,d.jsx)(S.V,{ac:M,className:"absolute bottom-full left-0 right-0 mx-4 mb-2 max-h-64"}),(0,d.jsxs)("div",{className:"flex gap-2 items-end p-4",children:[k&&(0,d.jsx)("button",{onClick:k,className:"p-2 text-brand hover:text-teal-10 hover:bg-brand/10 active:bg-brand/20 active:scale-95 rounded-lg transition-all",title:x("chat.viewGitChanges"),children:(0,d.jsxs)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"6",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"2",strokeWidth:2}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"2",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 8v10M18 8v4c0 2-2 4-6 4"})]})}),l&&(0,d.jsx)("button",{onClick:l,className:`p-2 rounded-lg transition-all active:scale-95 ${o?"text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted"}`,title:x("chat.viewAllComments"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),p&&(0,d.jsx)("button",{onClick:p,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:x("chat.projectNotes"),children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"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"})})}),r&&(0,d.jsx)("button",{onClick:r,className:`p-2 rounded-lg transition-all ${q?"text-amber-9 hover:text-amber-10 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95":"text-muted-foreground hover:text-amber-9 hover:bg-amber-9/10 active:bg-amber-9/20 active:scale-95"}`,title:x(q?"sessions.removeFavorite":"sessions.addFavorite"),"aria-label":x(q?"sessions.removeFavorite":"sessions.addFavorite"),"aria-pressed":q,children:(0,d.jsx)(g.A,{className:"w-5 h-5",fill:q?"currentColor":"none"})}),s&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>F(!E),className:`p-2 rounded-lg transition-all ${E?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:x("chat.scheduledTasks"),children:(0,d.jsx)(h.A,{className:"w-5 h-5"})}),E&&(0,d.jsx)(n.E,{onClose:()=>F(!1),onCreate:s})]}),(0,d.jsxs)("div",{className:"relative",ref:J,children:[(0,d.jsx)("button",{onClick:()=>H(!G),className:`p-2 rounded-lg transition-all ${G?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:x("chat.quickInstructions"),children:(0,d.jsx)(i.A,{className:"w-5 h-5"})}),G&&(0,d.jsx)(R,{cwd:c,anchorRef:J,onClose:()=>H(!1),onSelect:O,onInsert:P})]}),(0,d.jsx)("textarea",{ref:I,value:A,onChange:a=>{B(a.target.value),M.trackCaret(a.target)},onSelect:a=>M.trackCaret(a.currentTarget),onKeyDown:Q,onPaste:T,placeholder:b?x("chat.placeholderDisabled"):x("chat.placeholder"),rows:1,className:"flex-1 resize-none px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-ring bg-card text-foreground"})]})]})})},80983:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(23700),j=c(92701),k=c(93780),l=c(61349),m=a([l,i,j]);[l,i,j]=m.then?(await m)():m;let p={Read:"\uD83D\uDCC4",Write:"✏️",Edit:"\uD83D\uDCDD",ApplyPatch:"\uD83E\uDDE9",Bash:"\uD83D\uDCBB",Glob:"\uD83D\uDD0D",Grep:"\uD83D\uDD0E",WebFetch:"\uD83C\uDF10",WebSearch:"\uD83D\uDD0D",Workflow:"\uD83E\uDDE9",Skill:"\uD83D\uDEE0️"};function n(a){return"object"==typeof a&&null!==a}function o({toolCall:a,cwd:b,sessionId:c,disableOverlays:d=!1}){var m;let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(null),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(!1),z=p[a.name]||"\uD83D\uDD27",A="Agent"===a.name||"Task"===a.name,B=A&&!!b&&!!c,C="Workflow"===a.name,D=C&&(m=a.result)?m.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,E=C&&!!D&&!!b&&!!c,F=(0,k.v2)(a.id)??a.task,G=F?.status==="running",H=!!a.isLoading||G,I=F?G||!!a.isLoading:!a.result,J=G?[F?.lastToolName,F?.toolUses?String(F.toolUses):null].filter(Boolean).join(" \xb7 "):"",K="Skill"===a.name,L="ApplyPatch"===a.name||A||C||K,M=a=>{if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}let c=a.split("/");return c.length>2?".../"+c.slice(-2).join("/"):a},N=(()=>{let b=a.input;if("Bash"===a.name&&b.command&&"string"==typeof b.command)return b.command;if("ApplyPatch"===a.name&&Array.isArray(b.changes)){let a=b.changes.filter(n).flatMap(a=>{let b="string"==typeof a.path?a.path:"";if(!b)return[];let c="string"==typeof a.kind&&a.kind?a.kind:"update";return`${c} ${M(b)}`});if(a.length>0)return a.join(" \xb7 ")}if(A&&b.description&&"string"==typeof b.description)return b.description;if(C){let a="string"==typeof b.name?b.name:"",c="string"==typeof b.args?b.args:"string"==typeof b.resumeFromRunId?b.resumeFromRunId:"",d=[a,c].filter(Boolean).join(" \xb7 ");if(d)return d}if(K&&"string"==typeof b.skill){let a="string"==typeof b.args?b.args:"";return[b.skill,a].filter(Boolean).join(" \xb7 ")}return"Glob"===a.name&&b.pattern&&"string"==typeof b.pattern||"Grep"===a.name&&b.pattern&&"string"==typeof b.pattern?b.pattern:"ToolSearch"===a.name&&b.query&&"string"==typeof b.query?b.query:"TaskCreate"===a.name&&b.subject&&"string"==typeof b.subject?b.subject:b.file_path&&"string"==typeof b.file_path?b.file_path:b.path&&"string"==typeof b.path?b.path:null})(),O="Glob"===a.name||"Grep"===a.name||"Bash"===a.name||"ApplyPatch"===a.name||A||C||K,P=N?O?N:M(N):null,Q=b=>{let c="input"===b?q("toolCall.inputParams"):q("toolCall.resultLabel"),d="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);u({title:`${a.name}${P?` ${P}`:""} - ${c}`,content:d,toolName:a.name})};return(0,e.jsxs)("div",{className:"border-b border-line-1 last:border-b-0",children:[(0,e.jsxs)("button",{onClick:()=>s(!r),className:"w-full px-3 py-1.5 flex items-center gap-2 text-left hover:bg-hover transition-colors",children:[(0,e.jsx)("span",{className:"text-sm",children:z}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),P&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":N||"",children:P}),!L&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),N&&(navigator.clipboard.writeText(N),(0,h.oR)(q("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),N&&(navigator.clipboard.writeText(N),(0,h.oR)(q("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:q("common.copyAbsPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[B&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),w(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),w(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("chat.subagentViewTitle"),children:q("chat.subagent")}),E&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),y(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),y(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("chat.workflowViewTitle"),children:q("chat.workflowRun")}),J&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:J}),r&&!a.isLoading&&!d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),Q("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),Q("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("toolCall.inputParamsTitle"),children:q("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),Q("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),Q("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:q("toolCall.resultTitle"),children:q("toolCall.result")})]}),H?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-foreground-subtle text-xs",children:r?"▲":"▼"})]})]}),r&&(0,e.jsxs)("div",{className:"border-t border-line-1",children:[(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.inputParams"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:JSON.stringify(a.input,null,2)})]}),a.result&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.resultLabel"),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-24 overflow-y-auto text-foreground",children:"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2)})]}),a.skillContent&&(0,e.jsxs)("div",{className:"px-3 py-2 border-t border-line-1",children:[(0,e.jsx)("div",{className:"mb-1",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[q("toolCall.skillContent",{defaultValue:"Skill content"}),":"]})}),(0,e.jsx)("pre",{className:"text-xs bg-accent p-2 rounded overflow-x-auto max-h-60 overflow-y-auto text-foreground whitespace-pre-wrap",children:a.skillContent})]})]}),t&&(0,e.jsx)(l.M,{title:t.title,content:t.content,toolName:t.toolName,onClose:()=>u(null)}),v&&b&&c&&(0,e.jsx)(i.f,{cwd:b,sessionId:c,toolCall:a,running:I,onClose:()=>w(!1)}),x&&b&&c&&D&&(0,e.jsx)(j.K,{cwd:b,sessionId:c,runId:D,isRunning:H,onClose:()=>y(!1)})]})}d()}catch(a){d(a)}})},81064:(a,b,c)=>{Promise.resolve().then(c.bind(c,81227))},81206:(a,b,c)=>{"use strict";c.d(b,{z:()=>h,m:()=>j});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=a=>e.$mh({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})}),i=new Map;function j(a,b,c,{cwd:k,initialSessionId:l,onSessionId:m,onTitleChange:n,onTokenUsage:o,liveRunningRef:p}){let[q,r]=(0,d.useState)(!1),[s,t]=(0,d.useState)(!1),[u,v]=(0,d.useState)(!1),[w,x]=(0,d.useState)(void 0),[y,z]=(0,d.useState)(0),[A,B]=(0,d.useState)(null),[C,D]=(0,d.useState)(null),[E,F]=(0,d.useState)(null),G=(0,d.useRef)(null);G.current=A;let H=(0,d.useRef)(n);H.current=n;let I=(0,d.useRef)(o);I.current=o;let J=(0,d.useRef)(void 0),K=(0,d.useRef)(0),L=(0,d.useCallback)(async(a,c,d=!1,e,g,j=!1)=>{if(d){let a=Date.now();if(!j&&a-K.current<5e3)return;K.current=a}let k=(a,d)=>{a.fingerprint&&(J.current=a.fingerprint),void 0!==a.totalTurns&&z(a.totalTurns),void 0!==a.hasMore&&v(a.hasMore),a.messages&&a.messages.length>0&&(d?b(b=>(function(a,b){if(0===b.length)return a;let c=0;if(a.length>0&&a[0].id!==b[0].id){c=-1;for(let d=a.length-1;d>=0;d--)if(a[d].id===b[0].id){c=d;break}}if(c<0)return b;let d=a.slice(c),e=0;for(let a=0;a<Math.min(d.length,b.length)&&d[a].id===b[a].id&&d[a].content===b[a].content;a++)e=a+1;return e===d.length&&e===b.length?a:e===d.length&&e<b.length?[...a,...b.slice(e)]:[...a.slice(0,c),...d.slice(0,e),...b.slice(e)]})(b,a.messages)):p?.current||b(a.messages),B(c)),a.sessionId&&m(a.sessionId),a.engine&&D(a.engine),F(a.bot??null),a.title&&H.current?.(a.title),a.usage&&I.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})},l=`${a}::${c}`;j&&i.delete(l);let n=!d&&void 0===g,o=n?i.get(l):void 0;d||(o?k(o.data,!1):r(!0));try{let b={cwd:a,sessionId:c,limit:e,beforeTurnIndex:g};d&&J.current?b.ifFingerprint=J.current:o&&(b.ifFingerprint=o.fingerprint);let j=await f.t4.runPromiseExit(h(b));if("Success"===j._tag&&j.value){let a=j.value;if(a.notModified)return;if(k(a,d),n&&a.fingerprint&&a.messages&&a.messages.length>0&&(i.delete(l),i.set(l,{data:a,fingerprint:a.fingerprint}),i.size>20)){let a=i.keys().next().value;void 0!==a&&i.delete(a)}}}catch(a){console.error("Failed to load history by cwd and sessionId:",a)}finally{d||r(!1)}},[b,m]),M=(0,d.useCallback)(async()=>{if(k&&c&&!s&&u){t(!0);try{let d=void 0!==w?w:y-Math.ceil(a.filter(a=>"user"===a.role).length),e=await f.t4.runPromiseExit(h({cwd:k,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;x(a.startTurnIndex??d-e),B(c)}void 0!==a.hasMore&&v(a.hasMore),a.fingerprint&&(J.current=a.fingerprint)}else"Failure"===e._tag&&console.error("Failed to load more history:",e.cause)}finally{t(!1)}}},[k,c,s,u,w,y,a,b]);return{isLoadingHistory:q,isLoadingMore:s,hasMoreHistory:u,loadMoreHistory:M,ensureTurnLoaded:(0,d.useCallback)(async a=>{let d=G.current??c;if(k&&d&&!(a<0)){t(!0);try{let c=await f.t4.runPromiseExit(h({cwd:k,sessionId:d,fromTurnIndex:a}));if("Failure"===c._tag)return void console.error("Failed to load turns for jump:",c.cause);if(!c.value||G.current&&G.current!==d)return;let e=c.value;if(e.messages&&e.messages.length>0){let c=e.messages;b(a=>(function(a,b){if(0===b.length)return a;let c=new Set(b.map(a=>a.id)),d=a.map(a=>c.has(a.id)).lastIndexOf(!0);if(d<0)return b;let e=a.slice(d+1);return 0===e.length?b:[...b,...e]})(a,c)),x(e.startTurnIndex??a),B(d)}void 0!==e.totalTurns&&z(e.totalTurns),void 0!==e.hasMore&&v(e.hasMore),e.fingerprint&&(J.current=e.fingerprint)}finally{t(!1)}}},[k,c,b]),loadHistory:(0,d.useCallback)(async a=>{if(!k)return;r(!0);let c=e.$mh({try:async()=>{let b=await fetch(`/api/session/${encodeURIComponent(a)}/history?cwd=${encodeURIComponent(k)}`);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),B(a)):"Failure"===d._tag&&console.error("Failed to load history:",d.cause),r(!1)},[k,b]),loadHistoryByCwdAndSessionId:L,loadedSessionId:A,loadedEngine:C,loadedBot:E}}},81227:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx","default")},81608:(a,b,c)=>{"use strict";c.d(b,{_:()=>e,a:()=>f});let d=(0,c(41830).N)("cockpit-bots"),e=d.notify,f=d.subscribe},82338:(a,b,c)=>{"use strict";c.d(b,{B:()=>f});var d=c(48249),e=c(40311);function f({number:a,status:b="normal",isActive:c=!1}){return(0,d.jsx)("span",{className:`flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-[4px] border font-mono text-[10px] font-medium leading-none tabular-nums transition-colors ${(0,e.ci)(b,c)}`,"aria-hidden":"true",children:a})}},82795:(a,b,c)=>{"use strict";c.d(b,{e:()=>m});var d=c(48249),e=c(67484),f=c(44384),g=c(15819),h=c(33281),i=c(41224),j=c(32753),k=c(74228),l=c(1512);function m({isOpen:a,onClose:b,onSwitchProject:c,sessionNumbers:n={}}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)([]),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(""),x=(0,e.useRef)(null);(0,e.useCallback)(async()=>{s(!0),u(null);let a=await h.t4.runPromiseExit((0,i.z2)());"Success"===a._tag?q([...a.value]):u(o("sessions.loadSessionsFailed")),s(!1)},[o]);let y=(0,l.H)(p).filter(a=>{if(!v)return!0;let b=v.toLowerCase();return void 0!==a.searchText?a.searchText.includes(b):a.cwd.toLowerCase().includes(b)||(a.title?.toLowerCase().includes(b)??!1)||(a.lastUserMessage?.toLowerCase().includes(b)??!1)||(a.firstMessages?.some(a=>a.toLowerCase().includes(b))??!1)||(a.lastMessages?.some(a=>a.toLowerCase().includes(b))??!1)});return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-scrim",onClick:b}),(0,d.jsxs)("div",{className:g.aO,children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:o("sessions.recentSessions")})}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{ref:x,type:"text",placeholder:o("sessions.searchSessions"),value:v,onChange:a=>w(a.target.value),className:"px-2 py-1 pr-6 text-xs border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),v&&(0,d.jsx)("button",{onClick:()=>{w(""),x.current?.focus()},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-foreground-subtle hover:text-foreground rounded-sm transition-colors",title:o("fileBrowser.clear"),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"})})})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-foreground-subtle hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[r&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:o("sessions.loadingSessions")})]})}),t&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-red-11",children:t})}),!r&&!t&&0===y.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:v?o("sessions.noMatchingSessions"):o("sessions.noSessions")})}),!r&&!t&&y.length>0&&(0,d.jsx)("div",{className:g.jL,children:y.map(a=>{let e;return(0,d.jsxs)("div",{onClick:()=>{c(a.cwd,a.sessionId),b()},className:"p-3 rounded border border-border hover:border-brand hover:shadow-lv2 cursor-pointer transition-all",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)(j.S,{engine:a.engine}),(0,d.jsx)("h4",{className:"text-xs font-medium text-foreground truncate flex-1","data-tooltip":a.cwd,children:(e=a.cwd).split("/").pop()||e}),(0,d.jsx)(k.l,{coordinate:n[`${a.cwd}
737
737
  ${a.sessionId}`],status:(0,k.S)(a.status),statusLabel:"loading"===a.status?o("sessions.running"):"unread"===a.status?o("sessions.done"):void 0,bot:a.bot,className:"ml-auto"})]}),a.title&&(0,d.jsx)("div",{className:"text-xs font-medium text-foreground truncate mb-1","data-tooltip":a.title,children:a.title}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(a.lastActive).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(a.firstMessages?.length??0)>0||(a.lastMessages?.length??0)>0?(0,d.jsxs)("div",{className:"space-y-0.5 text-xs",children:[a.firstMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`first-${b}`)),(a.lastMessages?.length??0)>0&&(0,d.jsx)("div",{className:"text-foreground-subtle text-center py-0.5",children:"\xb7\xb7\xb7"}),a.lastMessages?.map((a,b)=>(0,d.jsxs)("div",{className:"text-foreground truncate","data-tooltip":a,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a]},`last-${b}`))]}):a.lastUserMessage?(0,d.jsxs)("div",{className:"text-xs text-foreground truncate","data-tooltip":a.lastUserMessage,children:[(0,d.jsx)("span",{className:"text-foreground-subtle mr-1",children:"•"}),a.lastUserMessage]}):null]},`${a.cwd}-${a.sessionId}`)})})]})]})]}):null}},83022:(a,b,c)=>{"use strict";c.d(b,{TabBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabBar() from the server but TabBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabBar.tsx","TabBar")},83120:(a,b,c)=>{"use strict";c.d(b,{BL:()=>q,Gm:()=>n,JK:()=>l,Wr:()=>o,Y8:()=>t,Y_:()=>k,_c:()=>r,bx:()=>m,dU:()=>s,i7:()=>x,jw:()=>u,mu:()=>v,vy:()=>w,z1:()=>p});var d=c(79606),e=c(71192);let f=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),j=a=>f(a,{method:"DELETE"}),k=()=>f("/api/review"),l=a=>{let b;return b=`/api/review/${encodeURIComponent(a)}`,d.$mh({try:async()=>{let a=await fetch(b);if(404===a.status)throw Object.assign(Error("not found"),{__404__:!0});if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>a?.__404__?new e.m_({resource:"review",id:b}):new e.uV({message:`GET ${b} failed`,cause:a})})},m=a=>g("/api/review",a),n=(a,b)=>i(`/api/review/${encodeURIComponent(a)}`,b),o=a=>j(`/api/review/${encodeURIComponent(a)}`),p=a=>i("/api/review/order",{order:a}),q=()=>f("/api/review/users"),r=()=>f("/api/review/share-info"),s=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/comments`,b),t=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/comments`,b),u=(a,b)=>j(`/api/review/${encodeURIComponent(a)}/comments?commentId=${encodeURIComponent(b)}`),v=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/replies`,b),w=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/replies`,b),x=(a,b,c)=>j(`/api/review/${encodeURIComponent(a)}/replies?commentId=${encodeURIComponent(b)}&replyId=${encodeURIComponent(c)}`)},83179:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({editor:a,onClose:b,position:c}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(()=>a.getAttributes("link").href||""),k=(0,e.useRef)(null),l=()=>{let c=i.trim();if(c){let b=c.match(/^https?:\/\//)?c:`https://${c}`;a.chain().focus().extendMarkRange("link").setLink({href:b}).run()}else a.chain().focus().extendMarkRange("link").unsetLink().run();b()},m=c?{top:c.top,left:c.left}:{};return(0,d.jsxs)("div",{className:`${c?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-lv2 p-2 flex items-center gap-2`,style:m,children:[(0,d.jsx)("input",{ref:k,type:"text",value:i,onChange:a=>j(a.target.value),onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),l()):"Escape"===a.key&&(a.preventDefault(),b())},placeholder:h("editor.linkPlaceholder"),className:"bg-background border border-border rounded px-2 py-1 text-sm w-64 outline-none focus:border-brand"}),(0,d.jsx)("button",{onClick:l,className:"p-1 rounded text-sm font-medium text-brand hover:bg-brand/10 transition-colors",title:h("editor.confirmLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}),a.isActive("link")&&(0,d.jsx)("button",{onClick:()=>{a.chain().focus().extendMarkRange("link").unsetLink().run(),b()},className:"p-1 rounded text-sm font-medium text-red-11 hover:bg-red-500/10 transition-colors",title:h("editor.removeLink"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})}function h({editor:a}){let{t:b}=(0,f.Bd)(),[c,i]=(0,e.useState)(!1),j=(0,e.useRef)(null),[,k]=(0,e.useState)(0);if(!a)return null;let l=a=>`p-1.5 rounded text-xs font-medium transition-colors ${a?"bg-brand/15 text-brand":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,m="w-px h-5 bg-border mx-0.5",n=a.isActive("table");return(0,d.jsxs)("div",{className:"flex items-center gap-0.5 px-4 py-1.5 border-b border-border flex-shrink-0 flex-wrap",children:[(0,d.jsx)("button",{className:l(a.isActive("heading",{level:1})),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),title:b("editor.heading1"),children:"H1"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:2})),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),title:b("editor.heading2"),children:"H2"}),(0,d.jsx)("button",{className:l(a.isActive("heading",{level:3})),onClick:()=>a.chain().focus().toggleHeading({level:3}).run(),title:b("editor.heading3"),children:"H3"}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bold")),onClick:()=>a.chain().focus().toggleBold().run(),title:b("editor.bold"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),(0,d.jsx)("button",{className:l(a.isActive("italic")),onClick:()=>a.chain().focus().toggleItalic().run(),title:b("editor.italic"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),(0,d.jsx)("button",{className:l(a.isActive("strike")),onClick:()=>a.chain().focus().toggleStrike().run(),title:b("editor.strikethrough"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("code")),onClick:()=>a.chain().focus().toggleCode().run(),title:b("editor.inlineCode"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{ref:j,className:l(a.isActive("link")),onClick:()=>i(!c),title:b("editor.link"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),c&&(0,d.jsx)(g,{editor:a,onClose:()=>i(!1),position:null})]}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("bulletList")),onClick:()=>a.chain().focus().toggleBulletList().run(),title:b("editor.bulletList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),(0,d.jsx)("button",{className:l(a.isActive("orderedList")),onClick:()=>a.chain().focus().toggleOrderedList().run(),title:b("editor.orderedList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),(0,d.jsx)("button",{className:l(a.isActive("taskList")),onClick:()=>a.chain().focus().toggleTaskList().run(),title:b("editor.taskList"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM17.99 9l-1.41-1.42-6.59 6.59-2.58-2.57-1.42 1.41 4 3.99z"})})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(a.isActive("blockquote")),onClick:()=>a.chain().focus().toggleBlockquote().run(),title:b("editor.blockquote"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),(0,d.jsx)("button",{className:l(a.isActive("codeBlock")),onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.codeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zm-7.5-4.5L15 12l-2.5-2.5L11 11l1.5 1.5L11 14l1.5 1.5zM9.5 14.5L7 12l2.5-2.5L11 11 9.5 12.5 11 14l-1.5.5z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:b("editor.table"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-9 15H4v-4h7v4zm0-6H4V7h7v4zm9 6h-7v-4h7v4zm0-6h-7V7h7v4z"})})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().setHorizontalRule().run(),title:b("editor.horizontalRule"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M4 11h16v2H4z"})})}),n&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowBefore().run(),title:b("editor.insertRowAbove"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zM11 17H4v-2h7v2zm0-4H4v-2h7v2zm9 4h-7v-2h7v2zm0-4h-7v-2h7v2z"}),(0,d.jsx)("path",{d:"M14 1h-4v2H8v2h2v2h4V5h2V3h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addRowAfter().run(),title:b("editor.insertRowBelow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v10h20V6c0-1.1-.9-2-2-2zM11 12H4v-2h7v2zm0-4H4V6h7v2zm9 4h-7v-2h7v2zm0-4h-7V6h7v2z"}),(0,d.jsx)("path",{d:"M14 19h-4v2H8v2h2v-2h4v2h2v-2h-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnBefore().run(),title:b("editor.insertColumnLeft"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 11H10v-2h7v2zm0-4H10V9h7v2z"}),(0,d.jsx)("path",{d:"M1 14v-4h2V8h2v2h-2v4h2v2H3v-2z",opacity:".6"})]})}),(0,d.jsx)("button",{className:l(!1),onClick:()=>a.chain().focus().addColumnAfter().run(),title:b("editor.insertColumnRight"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M4 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h10V4H4zm7 11H4v-2h7v2zm0-4H4V9h7v2z"}),(0,d.jsx)("path",{d:"M18 4v20h2c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-2z"}),(0,d.jsx)("path",{d:"M21 14v-4h2V8h2v2h-2v4h2v2h-2v-2z",opacity:".6"})]})}),(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-11 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteRow().run(),title:b("editor.deleteRow"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zm-8 8H4v-2h8v2z"}),(0,d.jsx)("path",{d:"M15 13l-1.41 1.41L15.17 16l-1.58 1.59L15 19l1.59-1.59L18.17 19l1.42-1.41L18 16l1.59-1.59L18.17 13 16.59 14.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-11 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteColumn().run(),title:b("editor.deleteColumn"),children:(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,d.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 7H10V9h7v2z"}),(0,d.jsx)("path",{d:"M13 16l-1.41 1.41L13.17 19l-1.58 1.59L13 22l1.59-1.59L16.17 22l1.42-1.41L16 19l1.59-1.59L16.17 16l-1.58 1.41z",fill:"currentColor"})]})}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-11 hover:bg-red-500/10",onClick:()=>a.chain().focus().deleteTable().run(),title:b("editor.deleteTable"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]}),a.isActive("codeBlock")&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:m}),(0,d.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-11 hover:bg-red-500/10",onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.deleteCodeBlock"),children:(0,d.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})]})}},83377:(a,b,c)=>{"use strict";c.d(b,{A:()=>e});var d=c(67484);function e({lines:a,enabled:b,onContentChange:c,onEnterInsert:f,onSave:g,getVisibleLineCount:h,scrollToLine:i,onSearchExecute:j,onSearchNext:k,onSearchPrev:l,onSearchClear:m}){let[n,o]=(0,d.useState)("normal"),[p,q]=(0,d.useState)(-1),[r,s]=(0,d.useState)(0),[t,u]=(0,d.useState)(!1),[v,w]=(0,d.useState)(""),[x,y]=(0,d.useState)(""),[z,A]=(0,d.useState)(""),[B,C]=(0,d.useState)(""),D=(0,d.useRef)([]),E=(0,d.useRef)([]),F=(0,d.useRef)([]),G=(0,d.useRef)(null),H=(0,d.useRef)(a),I=(0,d.useCallback)((a,b)=>Math.max(0,Math.min(b,Math.max(0,(H.current[a]??"").length-1))),[]);(0,d.useRef)(a.length);let J=(0,d.useCallback)(()=>{G.current&&(clearTimeout(G.current),G.current=null),w("")},[]),K=(0,d.useCallback)(()=>{G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{w(""),G.current=null},500)},[]),L=(0,d.useCallback)((a,b)=>{D.current.push(b),E.current=[],u(!0),c(a.join("\n"))},[c]),M=(0,d.useCallback)((a,b)=>{let c=Math.max(0,Math.min(a,H.current.length-1));q(c),s(I(c,b??0)),i(c,"auto")},[i,I]),N=(0,d.useCallback)(a=>{q(b=>{let c=Math.max(0,Math.min(b+a,H.current.length-1));return i(c,"auto"),s(a=>Math.max(0,Math.min(a,Math.max(0,(H.current[c]??"").length-1)))),c})},[i]),O=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);if(0===a.length)return;let c=a[b];F.current=[c];let d=[...a];d.splice(b,1),0===d.length&&d.push("");let e=Math.min(b,d.length-1);L(d,{lineIndex:b,oldLines:[c],newLines:[],cursorLine:b}),q(e),s(0)},[p,L]),P=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1);a.length>0&&(F.current=[a[b]])},[p]),Q=(0,d.useCallback)(()=>{let a=F.current;if(0===a.length)return;let b=H.current,c=Math.min(p,b.length-1)+1,d=[...b];d.splice(c,0,...a),L(d,{lineIndex:c,oldLines:[],newLines:[...a],cursorLine:p}),q(c),s(0),i(c,"auto")},[p,L,i]),R=(0,d.useCallback)(()=>{let a=H.current,b=Math.min(p,a.length-1),c=a[b];if(!c||0===c.length)return;let d=c.substring(1),e=[...a];e[b]=d,L(e,{lineIndex:b,oldLines:[c],newLines:[d],cursorLine:p})},[p,L]),S=(0,d.useCallback)(()=>{let a=D.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?d.splice(b.lineIndex,0,...b.oldLines):0===b.oldLines.length&&b.newLines.length>0?(d.splice(b.lineIndex,b.newLines.length),0===d.length&&d.push("")):d.splice(b.lineIndex,b.newLines.length,...b.oldLines),E.current.push(b),c(d.join("\n")),q(Math.min(b.cursorLine,d.length-1)),i(Math.min(b.cursorLine,d.length-1),"auto"),0===a.length&&u(!1)},[c,i]),T=(0,d.useCallback)(()=>{let a=E.current;if(0===a.length)return;let b=a.pop(),d=[...H.current];0===b.newLines.length&&b.oldLines.length>0?(d.splice(b.lineIndex,b.oldLines.length),0===d.length&&d.push("")):0===b.oldLines.length&&b.newLines.length>0?d.splice(b.lineIndex,0,...b.newLines):d.splice(b.lineIndex,b.oldLines.length,...b.newLines),D.current.push(b),u(!0),c(d.join("\n"));let e=b.lineIndex+Math.max(0,b.newLines.length-1);q(Math.min(e,d.length-1)),i(Math.min(e,d.length-1),"auto")},[c,i]),U=(0,d.useCallback)(a=>{let b=H.current,c=Math.min(p,b.length-1);if("o"===a||"O"===a){let d="o"===a?c+1:c,e=[...b];e.splice(d,0,""),L(e,{lineIndex:d,oldLines:[],newLines:[""],cursorLine:p}),c=d,q(d)}o("insert"),f(c,r,a)},[p,r,L,f]),V=(0,d.useCallback)(()=>{o("normal"),J()},[J]),W=(0,d.useCallback)(()=>{o("command"),y("")},[]),X=(0,d.useCallback)(()=>{o("normal"),y("")},[]),Y=(0,d.useCallback)(()=>{o("search"),A("")},[]),Z=(0,d.useCallback)(()=>{o("normal"),A("")},[]),$=(0,d.useCallback)(a=>{let b=a.trim();if("w"===b){g?.(),o("normal"),y("");return}if("q"===b){o("normal"),y("");return}if("wq"===b){g?.(),o("normal"),y("");return}if("noh"===b||"nohlsearch"===b){m?.(),o("normal"),y("");return}let c=parseInt(b,10);if(!isNaN(c)&&c>0){let a=Math.min(c-1,H.current.length-1);q(a),i(a,"center"),o("normal"),y("");return}o("normal"),y("")},[g,m,i]),_=(0,d.useCallback)(a=>{if(!a){o("normal"),A("");return}C(a),j?.(a),o("normal"),A("")},[j]),aa=(0,d.useCallback)(a=>{if(!b)return!1;let c=a.ctrlKey&&"c"===a.key&&!a.metaKey&&!a.shiftKey;if("insert"===n)return("Escape"===a.key||!!c)&&(V(),!0);if("command"===n)return!a.isComposing&&("Escape"===a.key||c?X():"Enter"===a.key?$(x):"Backspace"===a.key?0===x.length?X():y(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||y(b=>b+a.key),!0);if("search"===n)return!a.isComposing&&("Escape"===a.key||c?Z():"Enter"===a.key?_(z):"Backspace"===a.key?0===z.length?Z():A(a=>a.slice(0,-1)):1!==a.key.length||a.metaKey||a.ctrlKey||A(b=>b+a.key),!0);if(p<0&&(q(0),s(0)),a.metaKey)return!1;if(a.ctrlKey)return"d"===a.key?(N(Math.max(1,Math.floor(h()/2))),J(),!0):"u"===a.key?(N(-Math.max(1,Math.floor(h()/2))),J(),!0):"r"===a.key&&(T(),J(),!0);let d=a.key,e=v+d;if("g"===e)return w("g"),K(),!0;if("gg"===e)return M(0),J(),!0;if("d"===e)return w("d"),K(),!0;if("dd"===e)return O(),J(),!0;if("y"===e)return w("y"),K(),!0;if("yy"===e)return P(),J(),!0;if(v&&e!==d&&J(),"j"===d||"ArrowDown"===d)return N(1),!0;if("k"===d||"ArrowUp"===d)return N(-1),!0;if("h"===d||"ArrowLeft"===d)return s(a=>Math.max(0,a-1)),!0;if("l"===d||"ArrowRight"===d){let a=Math.max(0,(H.current[p]??"").length-1);return s(b=>Math.min(a,b+1)),!0}if("0"===d)return s(0),!0;if("$"===d)return s(Math.max(0,(H.current[p]??"").length-1)),!0;if("^"===d){let a=(H.current[p]??"").search(/\S/);return s(a>=0?a:0),!0}return"G"===d?(M(H.current.length-1),!0):"x"===d?(R(),!0):"p"===d?(Q(),!0):"u"===d?(S(),!0):"i"===d||"a"===d||"I"===d||"A"===d||"o"===d||"O"===d?(U(d),!0):"/"===d?(Y(),!0):"n"===d?(k?.(),!0):"N"===d?(l?.(),!0):":"===d?(W(),!0):"Escape"!==d&&1===d.length},[b,n,v,x,z,p,V,U,W,X,Y,Z,$,_,N,M,h,O,P,Q,R,S,T,J,K,k,l]);return{state:{mode:n,cursorLine:p,cursorCol:r,isDirty:t,keyBuffer:v,commandInput:x,searchInput:z,lastSearch:B},handleKeyDown:aa,enterNormal:V,enterInsert:U,setCursorLine:q,setCursorCol:s,setCommandInput:y,setSearchInput:A,setIsDirty:u,clearUndoHistory:(0,d.useCallback)(()=>{D.current=[],E.current=[]},[])}}},83768:(a,b,c)=>{"use strict";c.d(b,{DP:()=>g,NP:()=>i,Ql:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)(null);function g(){let a=(0,e.useContext)(f);if(!a)throw Error("useTheme must be used within a ThemeProvider");return a}function h(){return(0,e.useContext)(f)}function i({children:a}){let[b,c]=(0,e.useState)("system"),[g,h]=(0,e.useState)("light"),j=(0,e.useCallback)(()=>"light",[]),k=(0,e.useCallback)(a=>{let b=document.documentElement;b.classList.remove("light","dark"),b.classList.add(a),h(a);let c=document.querySelector('meta[name="theme-color"]'),d="dark"===a?"#111113":"#f9f9fb";c&&c.setAttribute("content",d)},[]),l=(0,e.useCallback)(a=>{c(a),localStorage.setItem("theme",a),k("system"===a?j():a),document.querySelectorAll("iframe").forEach(b=>{b.contentWindow?.postMessage({type:"THEME_CHANGE",theme:a},"*")})},[j,k]);return(0,d.jsx)(f.Provider,{value:{theme:b,resolvedTheme:g,setTheme:l},children:a})}},84398:(a,b,c)=>{"use strict";function d(a){let b=a.split("/").pop()?.toLowerCase()??"";switch(b.includes(".")?b.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";case"lean":return"lean";default:return null}}c.d(b,{k:()=>d})},84747:(a,b,c)=>{"use strict";c.d(b,{Workspace:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Workspace() from the server but Workspace is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/Workspace.tsx","Workspace")},84835:(a,b,c)=>{"use strict";c.d(b,{W:()=>f});var d=c(50300);let e=new Set(["p","h1","h2","h3","h4","h5","h6","li","blockquote","pre","table","tr","hr","div","ul","ol"]);function f(){return a=>{(0,d.YR)(a,"element",a=>{if(e.has(a.tagName)&&a.position&&(a.properties||(a.properties={}),a.properties["data-source-start"]=a.position.start.line,a.properties["data-source-end"]=a.position.end.line,"pre"===a.tagName)){let b=a.children?.find(a=>"element"===a.type&&"code"===a.tagName);b&&(b.properties||(b.properties={}),b.properties["data-source-start"]=a.position.start.line,b.properties["data-source-end"]=a.position.end.line)}})}}},84844:(a,b,c)=>{"use strict";c.d(b,{i:()=>p});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(91579),i=c(7031),j=c(44256),k=c(7833),l=c(33281),m=c(89800),n=c(25419);function o(a){if(0===a.length)return"";let b=[g.A.t("comments.codeRef"),""],c=a.filter(a=>a.filePath===h.Un),d=a.filter(a=>a.filePath!==h.Un);for(let a of(d.length>0&&d.forEach((a,c)=>{let d=a.startLine>0||a.endLine>0?`:${a.startLine}-${a.endLine}`:"";b.push(`[${c+1}] ${a.filePath}${d}`),b.push("```"),b.push(a.codeContent),b.push("```"),a.content&&b.push(g.A.t("comments.note",{content:a.content})),b.push("")}),c)){let c=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");b.push(c),a.content&&b.push(a.content),b.push("")}return b.join("\n").trim()}function p({isOpen:a,onClose:b,cwd:c,onNavigateToComment:g}){let{t:q}=(0,f.Bd)(),r=(0,i.r)(),[s,t]=(0,e.useState)([]),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(!1);(0,e.useCallback)(async()=>{if(!c)return;v(!0);let a=await l.t4.runPromiseExit((0,m.$)(c));"Success"===a._tag?t(a.value.comments??[]):console.error("Failed to load comments:",a.cause),v(!1)},[c]);let C=async a=>{let b=await l.t4.runPromiseExit((0,m.Tu)(c,a));"Success"===b._tag?(t(b=>b.filter(b=>b.id!==a)),(0,h.Cm)()):console.error("Failed to delete comment:",b.cause)},D=async a=>{x(a.id);try{let b="";if(a.selectedText)b=a.selectedText;else{let d=await l.t4.runPromiseExit((0,n.K)(c,a.filePath));if("Success"!==d._tag||!d.value.ok)throw Error("Failed to read file");b=(d.value.data?.content||"").split("\n").slice(a.startLine-1,a.endLine).join("\n")}let d={filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,content:a.content,codeContent:b},e=o([d]);await navigator.clipboard.writeText(e),(0,k.oR)(q("toast.copiedComment"))}catch(a){console.error("Failed to copy comment:",a)}finally{x(null)}},E=async()=>{if(0!==s.length){z(!0);try{let a=await (0,h.$3)(c),b=o(a);await navigator.clipboard.writeText(b),(0,k.oR)(q("toast.copiedAllComments"))}catch(a){console.error("Failed to copy all comments:",a)}finally{z(!1)}}},F=async()=>{if(0!==s.length&&r&&!r.isLoading&&!A){B(!0);try{let a=(await (0,h.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0})),d=(0,h.Gw)(a,"");r.sendMessage(d),await (0,h.RP)(c),t([]),b()}catch(a){console.error("Failed to send comments to AI:",a)}finally{B(!1)}}},G=s.reduce((a,b)=>(a[b.filePath]||(a[b.filePath]=[]),a[b.filePath].push(b),a),{});if(!a)return null;let H=(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:b,children:(0,d.jsxs)("div",{className:"w-full max-w-2xl max-h-[80vh] bg-card border border-border rounded-lg shadow-lv3 flex flex-col overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border ",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:q("comments.allComments")}),s.length>0&&(0,d.jsx)("button",{onClick:E,disabled:y,className:"p-1 rounded hover:bg-hover text-muted-foreground disabled:opacity-50",title:q("comments.copyAllComments"),children:y?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(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:"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,d.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-hover text-muted-foreground",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:u?(0,d.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:q("common.loading")}):0===s.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,d.jsx)("svg",{className:"w-12 h-12 mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),(0,d.jsx)("span",{children:q("comments.noComments")})]}):(0,d.jsx)("div",{className:"space-y-4",children:Object.entries(G).map(([a,b])=>(0,d.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground font-mono",children:a===h.Un?q("comments.aiReply"):a}),(0,d.jsxs)("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",q("comments.nComments",{count:b.length}),")"]})]}),(0,d.jsx)("div",{className:"divide-y divide-border",children:b.map(a=>{var b;return(0,d.jsx)("div",{className:"px-3 py-2 hover:bg-hover cursor-pointer group",onClick:()=>g?.(a),children:(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.startLine>0||a.endLine>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-xs text-brand font-mono",children:[q("common.line")," ",a.startLine===a.endLine?a.startLine:`${a.startLine}-${a.endLine}`]}),(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",q("comments.linesCount",{count:a.endLine-a.startLine+1}),")"]})]}):a.selectedText?(0,d.jsxs)("span",{className:"text-xs text-muted-foreground italic truncate max-w-[200px]",children:["“",a.selectedText.slice(0,50),a.selectedText.length>50?"...":"","”"]}):null,(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:(b=a.updatedAt||a.createdAt)?new Date(b).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):""})]}),(0,d.jsx)("p",{className:"text-sm text-foreground line-clamp-2",children:a.content||(0,d.jsx)("span",{className:"text-muted-foreground italic",children:q("comments.noContent")})})]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),D(a)},disabled:w===a.id,className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground transition-opacity disabled:opacity-50",title:q("common.copy"),children:w===a.id?(0,d.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):(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:"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,d.jsx)("button",{onClick:b=>{b.stopPropagation(),C(a.id)},className:"p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-hover text-muted-foreground hover:text-red-9 transition-opacity",title:q("common.delete"),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 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})},a.id)})})]},a))})}),(0,d.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm text-muted-foreground",children:q("comments.totalComments",{count:s.length})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[r&&(0,d.jsx)("button",{onClick:F,disabled:0===s.length||r.isLoading||A,className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",title:r.isLoading?q("comments.aiResponding"):void 0,children:A?q("comments.submitting"):q("comments.sendToAI")}),(0,d.jsx)("button",{onClick:async()=>{0===s.length||await (0,h.RP)(c)&&t([])},disabled:0===s.length,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 disabled:opacity-50 disabled:cursor-not-allowed",children:q("comments.clearAll")})]})]})]})});return(0,d.jsx)(j.ZL,{children:H})}},85655:(a,b,c)=>{"use strict";c.d(b,{Bj:()=>j,CM:()=>t,FK:()=>s,Iz:()=>n,MB:()=>u,Ub:()=>p,X0:()=>o,Zi:()=>k,lv:()=>m,oh:()=>r,r4:()=>h,ue:()=>i,w2:()=>q,yy:()=>l});var d=c(79606),e=c(71192);let f=a=>d.$mh({try:async()=>{let b=await fetch(a);if(!b.ok){let a;try{a=(await b.json()).error}catch{}throw Error(a||`HTTP ${b.status}`)}return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),h=a=>f(`/api/git/branches?cwd=${encodeURIComponent(a)}`).pipe(d.qIB(b=>"Failed to get branches"===b.error?d.fJG(new e.m_({resource:"git-repo",id:a})):d.PyW(b))),i=a=>f(`/api/git/current-branch?cwd=${encodeURIComponent(a)}`),j=(a,b,c,d)=>f(`/api/git/commits?cwd=${encodeURIComponent(a)}&branch=${encodeURIComponent(b)}&limit=${c}${"number"==typeof d?`&offset=${d}`:""}`),k=(a,b,c)=>f(`/api/git/commit-diff?cwd=${encodeURIComponent(a)}&hash=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),l=(a,b,c,d="worktree")=>f(`/api/git/branch-diff?cwd=${encodeURIComponent(a)}&base=${encodeURIComponent(b)}&mode=${d}${c?`&file=${encodeURIComponent(c)}`:""}`),m=a=>f(`/api/git/status?cwd=${encodeURIComponent(a)}`),n=(a,b)=>g("/api/git/stage",{cwd:a,files:b}),o=(a,b)=>g("/api/git/unstage",{cwd:a,files:b}),p=(a,b,c)=>g("/api/git/discard",{cwd:a,files:b,isUntracked:c}),q=(a,b,c,d)=>{let e=new URLSearchParams({cwd:a,file:b,type:c});return d&&e.set("oldPath",d),f(`/api/git/diff?${e}`)},r=a=>f(`/api/git/diff?${a.toString()}`),s=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),t=a=>d.$mh({try:async()=>{let b=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/git/worktree failed",cause:a})}),u=a=>f(`/api/projectGraph/search?${a.toString()}`)},85905:(a,b,c)=>{"use strict";c.d(b,{J:()=>bd});var d=c(48249),e=c(67484),f=c(44384),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(34678);function p(a){let b=function(a){let b=0xffffffff;for(let c=0;c<a.length;c++){b^=a.charCodeAt(c);for(let a=0;a<8;a++)b=b>>>1^(1&b?0xedb88320:0)}return(0xffffffff^b)>>>0}(a),c="",d=b;for(let a=0;a<4;a++)c+=String.fromCharCode(97+d%26),d=Math.floor(d/26);return c}var q=c(29939),r=c(33281),s=c(74429);function t({open:a,anchorRef:b,initialValue:c,onCancel:g,onSave:h}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(c),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(null),p=(0,e.useRef)(null),q=(0,e.useRef)(null);if((0,e.useCallback)(()=>{let a=b.current;if(!a)return;let c=a.getBoundingClientRect(),d=q.current?.offsetHeight??0,e=c.bottom+4;if(d&&e+d>window.innerHeight-8){let a=c.top-4-d;a>=8&&(e=a)}let f=c.left;o({top:e,left:f=Math.max(f=Math.min(f,window.innerWidth-260-8),8)})},[b]),!a||"u"<typeof document)return null;let r=async()=>{if(!l){m(!0);try{await h(j.trim())}finally{m(!1)}}};return(0,s.createPortal)((0,d.jsxs)("div",{ref:q,style:{top:n?.top??0,left:n?.left??0,width:260,visibility:n?"visible":"hidden"},className:"fixed z-[100] rounded-lg border border-border bg-card p-3 shadow-lv3",children:[(0,d.jsx)("div",{className:"mb-2 text-sm font-medium text-foreground",children:i("shortIdBadge.dialogTitle")}),(0,d.jsx)("input",{ref:p,type:"text",value:j,onChange:a=>k(a.target.value.slice(0,64)),onKeyDown:a=>{"Enter"!==a.key||a.nativeEvent.isComposing||229===a.keyCode||(a.preventDefault(),r())},placeholder:i("shortIdBadge.dialogPlaceholder"),maxLength:64,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm font-mono outline-none focus:border-brand"}),(0,d.jsxs)("div",{className:"mt-3 flex justify-end gap-2 text-sm",children:[(0,d.jsx)("button",{onClick:g,className:"rounded px-3 py-1 text-muted-foreground hover:bg-hover",disabled:l,children:i("common.cancel")}),(0,d.jsx)("button",{onClick:()=>void r(),className:"rounded bg-brand px-3 py-1 text-white hover:opacity-90 disabled:opacity-50",disabled:l,children:l?"…":i("common.save")})]})]}),document.body)}var u=c(23328);let v=(0,e.memo)(function({shortId:a,type:b,onRegister:c,onUnregister:g,fullId:h,projectCwd:i,tabId:j,registered:k}){let{t:l}=(0,f.Bd)(),[m,o]=(0,e.useState)(!1),p=k??m,[s,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(!1),y=(0,e.useRef)(null);(0,e.useEffect)(()=>{if(!h||!i||!j)return;let a=!1;return r.t4.runPromiseExit((0,u.MR)(i,j)).then(b=>{if(a||"Success"!==b._tag)return;let c=b.value[h];"string"==typeof c&&v(c)}),()=>{a=!0}},[h,i,j]),(0,q.h)({url:"/ws/global-state",enabled:!!h&&!!i&&!!j,onMessage:a=>{"console-delta"!==a.type||"rename"!==a.op||a.cwd!==i||a.tabId!==j||a.titles&&h&&Object.prototype.hasOwnProperty.call(a.titles,h)&&v(a.titles[h]??"")}});let z=(0,e.useCallback)(async d=>{if(d.stopPropagation(),p)await g(),o(!1),(0,n.oR)(l("toast.disconnected",{id:a}));else{await c(),o(!0);let d=`cockpit ${b} ${a}`;navigator.clipboard.writeText(d),(0,n.oR)(l("toast.copiedCommand",{command:d}))}},[p,a,b,c,g,l]),A=!!(h&&i&&j),B=(0,e.useCallback)(a=>{a.stopPropagation(),A&&x(!0)},[A]),C=(0,e.useCallback)(async a=>{h&&i&&j&&("Success"===(await r.t4.runPromiseExit((0,u.y8)(i,j,h,a)))._tag&&v(a),x(!1))},[h,i,j]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{onClick:z,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:p?l("shortIdBadge.clickToDisconnect"):l("shortIdBadge.clickToRegister"),children:[(0,d.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${p?"bg-green-500":"bg-muted-foreground/40"}`}),a]}),A&&(s?(0,d.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground",title:l("shortIdBadge.titleSet",{title:s})||s,children:[(0,d.jsx)("span",{className:"px-1 py-0.5 rounded bg-muted/40 max-w-[120px] truncate",children:s}),(0,d.jsx)("button",{ref:y,onClick:B,className:"opacity-50 hover:opacity-100 transition-opacity","aria-label":l("shortIdBadge.editTitle"),title:l("shortIdBadge.editTitle"),children:"✎"})]}):(0,d.jsxs)("button",{ref:y,onClick:B,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:l("shortIdBadge.setTitle"),children:["(",l("shortIdBadge.setTitlePlaceholder"),") ✎"]})),(0,d.jsx)(t,{open:w,anchorRef:y,initialValue:s,onCancel:()=>x(!1),onSave:C})]})});var w=c(28602),x=c(79606);let y=(0,e.lazy)(()=>c.e(8764).then(c.bind(c,98764)).then(a=>({default:a.XtermRenderer}))),z={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},A=/\x1b\[[0-9;]*m/g;function B({output:a,query:b,mode:c,currentIdx:f,matchListRef:g}){let h=(0,e.useRef)(null);h.current||(h.current=new o.v,h.current.use_classes=!0);let i=a.split("\n"),j=b.toLowerCase(),k=0;return g.current=[],(0,d.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:i.map((a,b)=>{let e=a.replace(A,""),i=e.toLowerCase().includes(j);if("filter"===c&&!i)return null;if(!i){let c=h.current.ansi_to_html(a);return(0,d.jsx)("div",{dangerouslySetInnerHTML:{__html:c}},b)}let l=[],m=0,n=e.toLowerCase(),o=0;for(;o<n.length;){let a=n.indexOf(j,o);if(-1===a)break;a>m&&l.push((0,d.jsx)("span",{children:e.slice(m,a)},`t${m}`));let b=k++,c=b===f;l.push((0,d.jsx)("mark",{ref:a=>{g.current[b]=a},className:c?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:e.slice(a,a+j.length)},`m${a}`)),o=m=a+j.length}return m<e.length&&l.push((0,d.jsx)("span",{children:e.slice(m)},`t${m}`)),(0,d.jsx)("div",{children:l},b)})})}let C=(0,e.memo)(function({commandId:a,tabId:b,projectCwd:c,command:q,output:s,exitCode:t,isRunning:A,selected:C,onSelect:D,onInterrupt:E,onStdin:F,onDelete:G,onRerun:H,timestamp:I,usePty:J,subscribePtyOutput:K,subscribePtyReset:L,subscribePtyRefresh:M,onPtyResize:N,onToggleMaximize:O,maximized:P,expandedHeight:Q,bubbleContentHeight:R,onTitleMouseDown:S}){let{t:T}=(0,f.Bd)(),U=(0,e.useRef)(null),V=(0,e.useRef)(null),W=(0,e.useRef)(!0),X=(0,e.useRef)(null),Y=(0,e.useRef)(null),Z=(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}`})(I),$=a&&b?p(b+a):void 0,[_,aa]=(0,e.useState)(!1),[ab,ac]=(0,e.useState)(""),ad=(0,e.useRef)(null),ae=(0,e.useRef)(null);(0,e.useEffect)(()=>{if(!K||!a)return;let b=()=>ad.current?K(a,ad.current.write):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[K,a]),(0,e.useEffect)(()=>{if(!L||!a)return;let b=()=>ad.current?L(a,ad.current.reset):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[L,a]),(0,e.useEffect)(()=>{if(!M||!a)return;let b=()=>ad.current?M(a,ad.current.refresh):null,c=b();if(c)return c;let d=setInterval(()=>{(c=b())&&clearInterval(d)},50);return()=>{clearInterval(d),c?.()}},[M,a]);let[af,ag]=(0,e.useState)(!1),[ah,ai]=(0,e.useState)(""),[aj,ak]=(0,e.useState)("search"),[al,am]=(0,e.useState)(0),an=(0,e.useRef)([]),ao=(0,e.useRef)(null),ap=(0,e.useRef)(0);(0,e.useEffect)(()=>{ao.current||(ao.current=new o.v,ao.current.use_classes=!0)},[]),(0,e.useLayoutEffect)(()=>{let a=V.current;if(a&&ao.current){if(s.length<ap.current&&(ao.current=new o.v,ao.current.use_classes=!0,ap.current=0,a.innerHTML=""),s.length>ap.current){let b=s.slice(ap.current),c=ao.current.ansi_to_html(b);ap.current=s.length,a.insertAdjacentHTML("beforeend",c)}if(U.current){let a=U.current.scrollHeight>U.current.clientHeight;aa(a),a&&(U.current.scrollTop=U.current.scrollHeight)}}},[s]),(0,e.useEffect)(()=>(A&&W.current&&U.current&&(null!==X.current&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight),X.current=null})),()=>{null!==X.current&&cancelAnimationFrame(X.current)}),[s,A]),(0,e.useEffect)(()=>{if(!P)return;let a=a=>{"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),O?.())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[P,O]);let aq=s?s.split("\n").length:0,ar=(0,e.useCallback)(()=>{ag(!0),requestAnimationFrame(()=>ae.current?.focus())},[]),as=(0,e.useCallback)(()=>{ag(!1),ai(""),am(0),ad.current?.clearSearch()},[]),at=(0,e.useCallback)(a=>{a.trim()&&(J?ad.current?.findNext(a):am(a=>{let b=a+1,c=an.current[b];return c?(c.scrollIntoView({block:"nearest"}),b):(an.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[J]),au=(0,e.useCallback)(a=>{a.trim()&&(J?ad.current?.findPrevious(a):am(a=>{let b=a-1;if(b>=0)return an.current[b]?.scrollIntoView({block:"nearest"}),b;let c=an.current.length-1;return c>=0&&an.current[c]?.scrollIntoView({block:"nearest"}),Math.max(c,0)}))},[J]);(0,e.useEffect)(()=>{if(!C)return;let a=a=>{if((a.metaKey||a.ctrlKey)&&"f"===a.key){a.preventDefault(),a.stopPropagation(),ar();return}if("Escape"===a.key&&af){a.preventDefault(),a.stopPropagation(),as();return}};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[C,af,ar,as]);let av=P&&Q?Q-41:R??360;return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-card text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${P?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${P?"":C?"border-brand":"border-brand/30"}`,onClick:D,children:[P?(0,d.jsxs)("div",{onDoubleClick:()=>O?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,d.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,d.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:q}),A&&(0,d.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),T("console.runningText")]}),A&&E&&(0,d.jsx)("button",{onClick:E,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-lv2 active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,d.jsx)("button",{onClick:()=>O?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:T("console.restoreTooltip",{modKey:(0,w.Mu)()}),children:(0,d.jsx)(g.A,{className:"w-4 h-4"})})]}):(0,d.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>S?.(),onDoubleClick:a=>{a.stopPropagation(),O?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${C?"border-brand":"border-brand/30"}`,children:[(0,d.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,d.jsx)(v,{shortId:$,type:"terminal",onRegister:()=>{r.t4.runFork((0,u.Ok)({tabId:b,commandId:a,command:q,projectCwd:c}).pipe(x.NWQ(()=>x.rIH)))},onUnregister:()=>{r.t4.runFork((0,u.jO)({commandId:a}).pipe(x.NWQ(()=>x.rIH)))},fullId:a,projectCwd:c,tabId:b}),(0,d.jsx)("span",{className:"font-mono text-foreground truncate",children:q}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(q),(0,n.oR)(T("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:T("console.copyCommand"),children:(0,d.jsx)(h.A,{className:"w-3.5 h-3.5"})}),(0,d.jsx)("span",{className:"flex-1"}),_&&!A&&(0,d.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:T("console.totalLines",{count:aq})}),s&&(0,d.jsx)("button",{onClick:a=>{let b;a.stopPropagation(),b=s.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(b),(0,n.oR)(T("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:T("console.copyOutput"),children:(0,d.jsx)(i.A,{className:"w-3.5 h-3.5"})}),H&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),H()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:T("console.rerun"),children:(0,d.jsx)(j.A,{className:"w-3.5 h-3.5"})}),G&&(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),G()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:T("console.deleteRecord"),children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),af&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,d.jsx)(k.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,d.jsx)("input",{ref:ae,value:ah,onChange:a=>{let b=a.target.value;ai(b),am(0),J&&(b.trim()?ad.current?.findNext(b):ad.current?.clearSearch())},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?au(ah):at(ah))},placeholder:T("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none",autoComplete:"off",spellCheck:"false"}),!J&&(0,d.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,d.jsx)("button",{onClick:()=>ak("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===aj?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:T("console.searchMode")}),(0,d.jsx)("button",{onClick:()=>ak("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===aj?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:T("console.filterMode")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)("button",{onClick:()=>au(ah),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:T("console.prevShiftEnter"),children:(0,d.jsx)(l.A,{className:"w-3.5 h-3.5"})}),(0,d.jsx)("button",{onClick:()=>at(ah),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:T("console.nextEnter"),children:(0,d.jsx)(m.A,{className:"w-3.5 h-3.5"})})]}),(0,d.jsx)("button",{onClick:as,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",children:(0,d.jsx)(g.A,{className:"w-3.5 h-3.5"})})]}),J?(0,d.jsxs)("div",{className:"relative group",style:{height:av,overflow:"hidden"},children:[(0,d.jsx)(e.Suspense,{fallback:(0,d.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:av},children:T("console.loadingTerminal")}),children:(0,d.jsx)(y,{ref:ad,output:s,isRunning:A,onInput:F,onResize:N,maximized:P,height:av,directWrite:!!K})}),!A&&(0,d.jsx)("div",{className:"absolute inset-0 bg-background/50 pointer-events-none"}),!A&&H&&(0,d.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(),H()},children:(0,d.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-tooltip text-tooltip-foreground text-xs",children:[(0,d.jsx)(j.A,{className:"w-3.5 h-3.5"}),T("console.rerun")]})})]}):(0,d.jsx)("div",{ref:U,className:"overflow-auto px-4 py-2",style:{height:av},onScroll:()=>{if(U.current){let{scrollTop:a,scrollHeight:b,clientHeight:c}=U.current;W.current=b-a-c<50}},children:af&&ah.trim()?(0,d.jsx)(B,{output:s,query:ah,mode:aj,currentIdx:al,matchListRef:an}):(0,d.jsx)("pre",{ref:V,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),A&&!P&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),J?(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:T("console.clickToInput")}):F?(0,d.jsx)("input",{ref:Y,value:ab,onChange:a=>ac(a.target.value),onKeyDown:a=>{if(a.ctrlKey&&!a.metaKey&&!a.altKey){let b=z[a.key.toLowerCase()];if(b){a.preventDefault(),a.stopPropagation(),F(b);return}}"Enter"!==a.key||a.nativeEvent.isComposing||(a.preventDefault(),F(ab+"\n"),ac("")),"Tab"===a.key&&(a.preventDefault(),F(" "))},placeholder:T("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none",autoComplete:"off",spellCheck:"false"}):(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:T("console.runningText")}),E&&(0,d.jsx)("button",{onClick:E,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),Z&&(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:Z})]}),!A&&void 0!==t&&!P&&(0,d.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===t?"bg-green-500":"bg-red-500"}`}),(0,d.jsx)("span",{children:T("console.exitCode",{code:t})}),(0,d.jsx)("span",{className:"flex-1"}),Z&&(0,d.jsx)("span",{className:"text-[11px] flex-shrink-0",children:Z})]})]})})});var D=c(64676);let E=new Map;function F(a){E.set(a.type,a)}function G(a){return E.get(a)}function H(a){for(let b of E.values())if(b.match(a))return b;return null}c(57031),c(88214);var I=c(71192);let J=(a,b)=>x.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new I.uV({message:`POST ${a} failed`,cause:b})}),K=(a,b)=>r.t4.runPromise(J(`/api/${a}/disconnect`,{id:b}).pipe(x.NWQ(()=>x.rIH))),L=a=>r.t4.runPromise(J("/api/browser/unregister",{id:a}).pipe(x.NWQ(()=>x.rIH))),M=a=>r.t4.runPromise(a.pipe(x.h9N(a=>x.OH5(()=>{if(a.cause instanceof Error)throw a.cause;throw Error(a.message)})))),N=(a,b)=>{if(a&&"object"==typeof a&&"error"in a){let b=a.error;if("string"==typeof b&&b.length>0)return b;if(b&&"object"==typeof b){let a=b.message;if("string"==typeof a&&a.length>0)return a;let c=b._tag;if("string"==typeof c&&c.length>0)return c}}return`HTTP ${b}`},O=(a,b)=>M(x.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(N(d,c.status));return d},catch:b=>new I.uV({message:`POST ${a} failed`,cause:b})})),P=(a,b)=>M(x.$mh({try:async()=>{let c=new URLSearchParams(b),d=await fetch(`${a}?${c}`),e=await d.json();if(!d.ok)throw Error(N(e,d.status));return e},catch:b=>new I.uV({message:`GET ${a} failed`,cause:b})})),Q=(a,b)=>M(x.$mh({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return c.blob()},catch:b=>new I.uV({message:`POST blob ${a} failed`,cause:b})}));var R=c(15105);function S(a){let b=a.trim().toLowerCase();return b.startsWith("http://")||b.startsWith("https://")}async function T(a){let b=(0,R.f)()?.id??null;return!!b&&new Promise(c=>{try{let d=globalThis.chrome?.runtime;if(!d?.sendMessage)return void c(!1);let e=setTimeout(()=>c(!1),2e3);d.sendMessage(b,{type:"prepare-iframe",url:a},a=>{clearTimeout(e),c(a?.ok??!1)})}catch{c(!1)}})}function U({url:a,id:b,selected:c,maximized:g,expandedHeight:h,bubbleContentHeight:i,onSelect:j,onClose:k,onToggleMaximize:l,onNewTab:m,timestamp:o,onTitleMouseDown:q,initialSleeping:r,onSleep:s,onWake:t,projectCwd:u,baseCwd:x,tabId:y,autoConnect:z}){let{t:A,i18n:B}=(0,f.Bd)(),[C,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(null),[H,I]=(0,e.useState)(a),[J,K]=(0,e.useState)(null),[M,N]=(0,e.useState)(r??!1),O=(0,e.useRef)(null),P=(0,e.useRef)(null),Q=(0,e.useRef)(null);(0,e.useRef)(!0),(0,e.useCallback)(()=>{M||(N(!0),K(null),s?.(b))},[M,b,s]),(0,e.useCallback)(()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]);let{shortId:R,connected:V,connect:W,disconnect:X}=function(a,b,c){let d=(0,e.useMemo)(()=>p(a),[a]),[f,g]=(0,e.useState)(!1),h=(0,e.useRef)(null);(0,e.useRef)([]),(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(c);let i=(0,e.useRef)([]);(0,e.useCallback)(a=>{let c=b.current;if(!c?.contentWindow){let b=h.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 j=(0,e.useCallback)(()=>f&&h.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(a=>{i.current.push(a),f||g(!0)}),[f]);return{shortId:d,connected:f,connect:j,disconnect:(0,e.useCallback)(()=>{g(!1)},[])}}(b,Q,!!J&&!M&&!C);(0,e.useRef)(V).current=V,(0,e.useRef)(!1);let Y=(0,e.useCallback)(()=>{if(N(!1),t?.(b),!S(a))return void K((0,D.Kx)(a)?(0,D.hE)(a,x):(0,D.Xe)(a,x));let c=function(a){if(!a)return a;try{let b=new URL(a);return b.searchParams.set("_cockpit","1"),b.toString()}catch{let b=a.includes("?")?"&":"?";return`${a}${b}_cockpit=1`}}(a);!function(a){try{let b=new URL(a).hostname;return"localhost"===b||"127.0.0.1"===b}catch{return!1}}(a)?T(a).then(()=>K(c)):K(c)},[a,b,t,x]),Z=(0,e.useCallback)(()=>{E(!1);let a=Q.current?.contentWindow;if(!a)return;let b=document.documentElement.classList.contains("dark");a.postMessage({type:"THEME_CHANGE",theme:b?"dark":"light"},"*"),a.postMessage({type:"cockpit:language-change",lang:B.language},"*")},[B]),$=(0,e.useCallback)(()=>{E(!1),G(A("browser.pageLoadFailed"))},[]),_=(0,e.useCallback)(()=>{if(M)return void Y();let a=P.current?.querySelector("iframe");if(a&&J){E(!0),G(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[M,Y,J]),aa=(0,e.useCallback)(()=>{if(!H)return;let a=S(H)?H:(0,D.Kx)(H)?(0,D.hE)(H,x):(0,D.Xe)(H,x);window.open((0,D.PB)(a,window.location.origin),"_blank")},[H,x]),ab=function(a){if(!a)return"";try{let b=new URL(a);return b.port?`${b.hostname}:${b.port}`:b.hostname}catch{return a.split("/").pop()||a}}(H);return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-accent text-foreground
738
738
  relative transition-colors cursor-pointer
739
739
  ${g?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}