@surething/cockpit 1.0.270 → 1.0.271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next-prod/BUILD_ID +1 -1
- package/.next-prod/app-path-routes-manifest.json +7 -7
- package/.next-prod/build-manifest.json +2 -2
- package/.next-prod/cockpit-build.json +1 -1
- package/.next-prod/prerender-manifest.json +3 -3
- package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_global-error.html +1 -1
- package/.next-prod/server/app/_global-error.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/_not-found.html +2 -2
- package/.next-prod/server/app/_not-found.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
- package/.next-prod/server/app/api/session-by-path/route.js +1 -1
- package/.next-prod/server/app/m/page.js +1 -1
- package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
- package/.next-prod/server/app-paths-manifest.json +7 -7
- package/.next-prod/server/chunks/516.js +1 -1
- package/.next-prod/server/chunks/5750.js +11 -9
- package/.next-prod/server/middleware-build-manifest.js +1 -1
- package/.next-prod/server/pages/404.html +2 -2
- package/.next-prod/server/pages/500.html +1 -1
- package/.next-prod/server/server-reference-manifest.json +1 -1
- package/.next-prod/static/chunks/{2302-ebf06ca1396efcce.js → 2302-5e8daad0800c3c02.js} +2 -2
- package/.next-prod/static/chunks/7184-b6fb5d3287fc073c.js +17 -0
- package/.next-prod/static/chunks/app/m/{page-0304eea2c0cf03f6.js → page-241cf89338a0f255.js} +1 -1
- package/.next-prod/static/css/ea27ccfe01ce807c.css +1 -0
- package/.next-prod/trace +14 -14
- package/.next-prod/trace-build +1 -1
- package/dist/scheduledTasks.mjs +8 -4
- package/package.json +3 -3
- package/.next-prod/static/chunks/7184-efdf8613e83ae823.js +0 -15
- package/.next-prod/static/css/4e29dd2bca2bb1ac.css +0 -1
- /package/.next-prod/static/{cqNAEj5KI8Y8li81B5f7n → BRgWyE48IVXSuUJ4BLHQb}/_buildManifest.js +0 -0
- /package/.next-prod/static/{cqNAEj5KI8Y8li81B5f7n → BRgWyE48IVXSuUJ4BLHQb}/_ssgManifest.js +0 -0
|
@@ -13,18 +13,19 @@ exports.id=5750,exports.ids=[5750],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:()=>x});var e=c(48249),f=c(67484),g=c(44384),h=c(25608),i=c(32459),j=c(18499),k=c(74991),l=c(98982),m=c(13054),n=c(7833),o=c(29939),p=c(64340),q=c(42390),r=c(50514),s=c(24703),t=a([h,i,j,k]);function u({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 v({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)(r.A,{className:"w-4 h-4"})})}function w({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)(u,{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)},t=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)(r.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)(u,{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:t(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)(u,{className:"w-4 h-4"})}),n.map(a=>(0,e.jsx)(v,{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)(s.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:t(o)})]})]})})}function x({projects:a,activeIndex:b,collapsed:c,currentCwd:d,onSelectProject:r,onRemoveProject:s,onReorderProjects:t,onToggleCollapse:u,onOpenSessionBrowser:v,onOpenSettings:y,onOpenNote:z,onOpenSkills:A,onOpenApps:B,htmlAppPreviews:C,activeHtmlAppPreviewPath:D,onShowHtmlAppPreview:E,onSwitchProject:F,onResolveSessionNumbers:G,sessionOrders:H,sessionNumbers:I}){let{t:J,i18n:K}=(0,g.Bd)(),{latest:L,hasUpdate:M}=(0,p.r)(),[N,O]=(0,f.useState)(!1),P=(0,f.useRef)(null),Q=(0,f.useCallback)(()=>{navigator.clipboard.writeText("cockpit update"),(0,n.oR)(J("workspace.upgradeCommandCopied")),O(!1)},[J]),{isUpdating:R,start:S}=(0,q.P)(),T=(0,f.useCallback)(()=>{O(!1),S()},[S]),{pinnedSessions:U,unpinSession:V,updateTitle:W,reorder:X}=(0,l.P)(),{tasks:Y,unreadCount:Z,reload:$,pauseTask:_,resumeTask:aa,triggerTask:ab,deleteTask:ac,updateTask:ad,markRead:ae}=(0,m.nS)(),[af,ag]=(0,f.useState)(null),[ah,ai]=(0,f.useState)(null),[aj,ak]=(0,f.useState)([]);(0,f.useRef)(aj);let al=(0,f.useRef)($),am=(0,f.useCallback)(a=>{try{if("task-fired"===a.type)return void al.current();let{data:b}=a;if(!b)return;ak(b.sessions||[])}catch{}},[]);(0,o.h)({url:"/ws/global-state",onMessage:am});let an=new Set(aj.filter(a=>"loading"===a.status).map(a=>a.cwd)),ao=new Set(aj.filter(a=>"unread"===a.status).map(a=>a.cwd)),ap=(0,f.useMemo)(()=>{let b=new Map;for(let c of a){let a=H[c.cwd]??[],d=aj.filter(a=>a.cwd===c.cwd&&("loading"===a.status||"unread"===a.status)).map(b=>({session:b,position:a.indexOf(b.sessionId)})).sort((a,b)=>a.position>=0&&b.position>=0?a.position-b.position:a.position>=0?-1:b.position>=0?1:b.session.lastActive-a.session.lastActive).slice(0,3).map(({session:a,position:b})=>({sessionId:a.sessionId,label:b>=0?String(b+1):"\xb7",status:"loading"===a.status?"loading":"unread"}));d.length>0&&b.set(c.cwd,d)}return b},[a,aj,H]),aq=(0,f.useCallback)(a=>{ag(a)},[]),ar=(0,f.useCallback)((a,b)=>{a.preventDefault(),null!==af&&af!==b&&ai(b)},[af]),as=(0,f.useCallback)(b=>{if(null!==af&&af!==b){let c=[...a],[d]=c.splice(af,1);c.splice(b,0,d),t(c)}ag(null),ai(null)},[af,a,t]),at=(0,f.useCallback)(()=>{ag(null),ai(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:v,title:c?J("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:J("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:u,title:J("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:u,title:J("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:()=>aq(d),onDragOver:a=>ar(a,d),onDrop:()=>as(d),onDragEnd:at,className:`${ah===d?"border-t-2 border-brand":""} ${af===d?"opacity-50":""}`,children:(0,e.jsx)(h.ProjectItem,{index:d,name:(g=(f=a.cwd).split("/").filter(Boolean))[g.length-1]||f,cwd:a.cwd,isActive:d===b,collapsed:c,hasUnread:ao.has(a.cwd),isLoading:an.has(a.cwd),sessionBadges:ap.get(a.cwd),onClick:()=>r(d),onSelectSession:b=>F(a.cwd,b),onRemove:()=>s(d),onOpenNote:()=>z(a.cwd)})},a.cwd)})}),(0,e.jsx)(w,{collapsed:c,previews:C,activePath:D,onOpenApps:B,onShowPreview:E}),(0,e.jsxs)("div",{className:"p-2 border-t border-border space-y-1",children:[(0,e.jsx)(i.e,{currentCwd:d,onSwitchProject:F,onResolveSessionNumbers:G,collapsed:c,sessions:aj}),(0,e.jsx)(j._,{collapsed:c,pinnedSessions:U,sessionNumbers:I,currentCwd:d,onSwitchProject:F,onUnpin:V,onUpdateTitle:W,onReorder:X}),(0,e.jsx)(k.I,{collapsed:c,tasks:Y,unreadCount:Z,sessionNumbers:I,onSwitchProject:F,onPause:_,onResume:aa,onTrigger:ab,onDelete:ac,onMarkRead:ae,onUpdateTask:ad}),(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:()=>z(),title:c?J("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:J("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:A,title:c?J("workspace.skills"):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:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})}),!c&&(0,e.jsx)("span",{className:"text-sm",children:J("workspace.skills")})]}),(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:y,title:J("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&&M&&(0,e.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500",title:L?J("workspace.updateAvailable",{version:L}):void 0})]}),!c&&(0,e.jsx)("span",{className:"flex-1 text-sm",children:J("workspace.settings")}),!c&&M&&L&&(0,e.jsxs)("div",{ref:P,className:"relative -mr-2",children:[(0,e.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),O(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:J("workspace.updateAvailable",{version:L}),"aria-label":J("workspace.updateAvailable",{version:L}),children:["v",L]}),N&&(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:J("workspace.updateAvailable",{version:L})}),(0,e.jsxs)("button",{type:"button",onClick:T,disabled:R,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:[R?(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:R?J("workspace.updating"):J("workspace.updateNow")})]}),(0,e.jsxs)("button",{type:"button",onClick:Q,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:J("workspace.copyUpgradeCommand")})]}),(0,e.jsxs)("a",{href:`https://opencockpit.dev/${K.language?.startsWith("zh")?"zh":"en"}/changelog/`,target:"_blank",rel:"noopener",onClick:()=>O(!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:J("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/${K.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:J("workspace.help"),"aria-label":J("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})]})})]})]})]})}[h,i,j,k]=t.then?(await t)():t,d()}catch(a){d(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.orElse(()=>i.void))),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.tryPromise({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.tryPromise({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.match({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.asVoid).pipe(g.orElse(()=>g.void))),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.asVoid).pipe(g.as(!0),g.orElseSucceed(()=>!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])}}},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)}})},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()}},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})},15578:(a,b,c)=>{"use strict";c.d(b,{S:()=>g,q:()=>f});let d=[/(^|\/)__tests__\//,/(^|\/)tests?\//,/\.(test|spec)\.[^/]+$/],e=[/\.(md|mdx)$/i,/(^|\/)docs\//,/(^|\/)README[^/]*$/i,/(^|\/)LICENSE[^/]*$/i,/(^|\/)CHANGELOG[^/]*$/i];function f(a){return d.some(b=>b.test(a))?"test":e.some(b=>b.test(a))?"docs":null}function g(a){if(0===a.length)return null;let b=f(a[0]);return null===b?null:a.every(a=>f(a)===b)?b:null}},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-4 py-3",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:"[&_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}function j(a){var b;let c,j,k=[],l=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)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);l&&k.push(l);for(let b=0;b<a.namedChildCount;b++){let c=a.namedChild(b);c&&k.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,k),k.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,k)),b=k,c=new Map,(j=a=>{for(let b of a){let a=(c.get(b.qualifiedName)??0)+1;c.set(b.qualifiedName,a),a>1&&(b.qualifiedName=`${b.qualifiedName}#${a}`),j(b.children)}})(b),k}c.d(b,{Hs:()=>j})},16665:(a,b,c)=>{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))},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)}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,{se:()=>h,xK:()=>g});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),g=(a,b,c,e)=>f(`/api/snapshots?cwd=${encodeURIComponent(a)}&toolIds=${encodeURIComponent(b.join(","))}${c?`&sessionKey=${encodeURIComponent(c)}`:""}${e?`&runId=${encodeURIComponent(e)}`:""}`).pipe(d.map(a=>a.commits??[])),h=(a,b,c,e)=>g(a,b,c,e).pipe(d.flatMap(b=>d.all(b.map(b=>{let c;return c=b.hash,f(`/api/snapshots/diff?cwd=${encodeURIComponent(a)}&commit=${encodeURIComponent(c)}`)}),{concurrency:4})))},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.jsx)(j.KO,{status:g?.status,className:"mt-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),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,claudeContextWindow:v,onClaudeContextWindowChange:w,claudeFastMode:x,onClaudeFastModeChange:y,claudeThinking:z,onClaudeThinkingChange:A,codexModel:B,onCodexModelChange:C,codexReasoningEffort:D,onCodexReasoningEffortChange:E,planMode:F,onPlanModeChange:G,noHistory:H,onNoHistoryChange:I,isActive:J,refreshSignal:K,onStateChange:L,onShowGitStatus:M,onOpenNote:N,onCreateScheduledTask:O,onOpenSession:P,onContentSearch:Q,onShowFileDiff:R,onOpenFileLink:S}){let T=(0,f.useCallback)(b=>{L(a,{isLoading:b})},[a,L]),U=(0,f.useCallback)(b=>{L(a,{sessionId:b})},[a,L]),V=(0,f.useCallback)(b=>{L(a,{title:b})},[a,L]),W=(0,f.useCallback)(b=>{h?.(a,b)},[a,h]),X=(0,f.useCallback)(b=>{k?.(a,b)},[a,k]),Y=(0,f.useCallback)(b=>{m?.(a,b)},[a,m]),Z=(0,f.useCallback)(b=>{o?.(a,b)},[a,o]),$=(0,f.useCallback)(b=>{q?.(a,b)},[a,q]),_=(0,f.useCallback)(b=>{s?.(a,b)},[a,s]),aa=(0,f.useCallback)(b=>{u?.(a,b)},[a,u]),ab=(0,f.useCallback)(b=>{w?.(a,b)},[a,w]),ac=(0,f.useCallback)(b=>{y?.(a,b)},[a,y]),ad=(0,f.useCallback)(b=>{A?.(a,b)},[a,A]),ae=(0,f.useCallback)(b=>{C?.(a,b)},[a,C]),af=(0,f.useCallback)(b=>{E?.(a,b)},[a,E]),ag=(0,f.useCallback)(b=>{G?.(a,b)},[a,G]),ah=(0,f.useCallback)(b=>{I?.(a,b)},[a,I]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:W,ollamaModel:j,onOllamaModelChange:X,deepseekModel:l,onDeepseekModelChange:Y,kimiModel:n,onKimiModelChange:Z,glmModel:p,onGlmModelChange:$,claudeModel:r,onClaudeModelChange:_,claudeEffort:t,onClaudeEffortChange:aa,claudeContextWindow:v,onClaudeContextWindowChange:ab,claudeFastMode:x,onClaudeFastModeChange:ac,claudeThinking:z,onClaudeThinkingChange:ad,codexModel:B,onCodexModelChange:ae,codexReasoningEffort:D,onCodexReasoningEffortChange:af,planMode:F,onPlanModeChange:ag,noHistory:H,onNoHistoryChange:ah,hideHeader:!0,hideSidebar:!0,isActive:J,refreshSignal:K,onLoadingChange:T,onSessionIdChange:U,onTitleChange:V,onShowGitStatus:M,onOpenNote:N,onCreateScheduledTask:O,onOpenSession:P,onContentSearch:Q,onShowFileDiff:R,onOpenFileLink:S})}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.tryPromise({try:async()=>{let a=await fetch(`/api/files/search?${i}`),b=await a.json();if(b.error)throw Error(b.error);return b},catch:a=>new h.uV({message:"content search failed",cause:a})});await g.t4.runPromise(j.pipe(f.match({onSuccess:a=>{l(a.results),v({totalFiles:a.totalFiles,totalMatches:a.totalMatches,truncated:a.truncated}),r(new Set(a.results.map(a=>a.path))),a.results.length>0&&b?.()},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Search failed"),l([])}}))),n(!1)},[a,s,b]);return{contentSearchQuery:c,setContentSearchQuery:j,contentSearchResults:k,isSearching:m,searchError:o,searchExpandedPaths:q,searchOptions:s,setSearchOptions:t,searchStats:u,contentSearchInputRef:w,performContentSearch:x,handleSearchToggle:(0,d.useCallback)(a=>{r(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},20586:(a,b,c)=>{"use strict";c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(7122),i=c(61591);function j({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 k=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=f===b.path,p=g.has(b.path),q=(0,e.useCallback)(()=>{b.isDirectory?k(b.path):h(b)},[b,h,k]),r=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);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:q,onContextMenu:r,children:[(0,d.jsx)("span",{className:"text-foreground-subtle text-xs",children:p?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m,renderActions:n},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 ${o?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)(i.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,d.jsx)(j,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)(d.Fragment,{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]})]}),n&&n(b)]})});function l({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:i,showChanges:j=!1,renderActions:m,emptyMessage:n,className:o,onExplain:p,explainDisabled:q}){let{t:r}=(0,g.Bd)(),s=n??r("gitFileTree.noFiles"),{contextMenu:t,showContextMenu:u,hideContextMenu:v}=(0,h.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:s}):(0,d.jsxs)("div",{className:o||"py-1",children:[a.map(a=>(0,d.jsx)(k,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:u,showChanges:j,renderActions:m},a.path)),t&&(0,d.jsx)(h.ft,{x:t.x,y:t.y,path:t.path,cwd:i,isDirectory:t.isDirectory,onClose:v,onExplain:p,explainDisabled:q})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},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:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(35208),i=c(39238),j=c(74691),k=c(60333),l=c(20586),m=c(46242),n=c(21787),o=c(9804),p=c(33281),q=c(85655),r=c(60591),s=c(18921),t=c(7031);c(57063);var u=a([h,i]);function v({isOpen:a,onClose:b,commit:c,cwd:d,embedded:u=!1,initialFilePath:w,onContentSearch:x,onLocateInTree:y}){let{t:z}=(0,g.Bd)(),[A,B]=(0,f.useState)([]),[C,D]=(0,f.useState)([]),[E,F]=(0,f.useState)(new Set),[G,H]=(0,f.useState)(null),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)(!1),[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)("compact"),[U,V]=(0,f.useState)("unified"),W=(0,f.useRef)(null),X=(0,s.o)(W),Y=(0,t.r)(),Z=c?.shortHash,$=(0,f.useCallback)(a=>{Z&&Y?.sendMessage(z("explain.commitFileMessage",{hash:Z,path:a}))},[Y,z,Z]),_=(0,f.useCallback)(a=>{c&&(H(a),N(!0),p.t4.runPromiseExit((0,q.Zi)(d,c.hash,a.path)).then(a=>{"Success"===a._tag?J(a.value):console.error(a.cause),N(!1)}))},[d,c]),aa=(0,f.useCallback)(a=>{F(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ab=(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]),ac=I?.filePath,ad=(0,f.useMemo)(()=>ac?(0,e.jsx)(n.d,{cwd:d,filePath:ac,onLocateInTree:y}):null,[d,ac,y]);if(!a||!c)return null;let ae=!!I&&(!0===I.isImage||(0,o.u)(I.filePath)),af=(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:z("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:z("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:z("commitDetail.date")}),(0,e.jsx)("span",{children:ab}),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:z("commitDetail.files")}),(0,e.jsx)("span",{children:z("commitDetail.nChanges",{count:A.length})})]}),!ae&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(j.y,{value:S,onChange:T}),(0,e.jsx)(k.q,{value:U,onChange:V})]})]})]}),(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:K?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:z("commitDetail.loadingFiles")}):(0,e.jsx)(l.VO,{files:C,selectedPath:G?.path||null,expandedPaths:E,onSelect:a=>a.file&&_(a.file),onToggle:aa,cwd:d,showChanges:!0,emptyMessage:z("commitDetail.noFileChanges"),className:"py-1",onExplain:Y&&Z?$:void 0,explainDisabled:Y?.isLoading})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:M?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("commitDetail.loadingDiff")}):I?ae?(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:ad}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(m.M,{cwd:d,filePath:I.filePath,oldRev:I.oldRev??(I.isNew?null:`${c.hash}^1`),newRev:I.newRev??(I.isDeleted?null:c.hash)})})]}):"unified"===U?(0,e.jsx)(h.xU,{oldContent:I.oldContent,newContent:I.newContent,filePath:I.filePath,cwd:d,enableComments:!0,compact:"compact"===S,headerLeading:ad,onPreview:I.isDeleted?void 0:(0,r.aR)(I.filePath)?()=>R({content:I.newContent,filePath:I.filePath}):I.filePath.endsWith(".json")?()=>P({content:I.newContent,filePath:I.filePath}):void 0,previewLabel:(0,r.aR)(I.filePath)?z("common.preview"):z("common.readable"),onContentSearch:x}):(0,e.jsx)(h.xZ,{oldContent:I.oldContent,newContent:I.newContent,filePath:I.filePath,isNew:I.isNew,isDeleted:I.isDeleted,cwd:d,enableComments:!0,compact:"compact"===S,headerLeading:ad,onPreview:I.isDeleted?void 0:(0,r.aR)(I.filePath)?()=>R({content:I.newContent,filePath:I.filePath}):I.filePath.endsWith(".json")?()=>P({content:I.newContent,filePath:I.filePath}):void 0,previewLabel:(0,r.aR)(I.filePath)?z("common.preview"):z("common.readable"),onContentSearch:x}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("commitDetail.selectFileToView")})})]})]}),ag=O&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>P(null),children:(0,e.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,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:O.filePath}),(0,e.jsx)("button",{onClick:()=>P(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(s._,{search:X}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{ref:W,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,r.xb)(O.content)})})]})}),ah=Q&&(0,e.jsx)(i.N,{filePath:Q.filePath,content:Q.content,cwd:d,onClose:()=>R(null)});return u?(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:z("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"})})}),af,ag,ah]}):(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:z("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"})})})]}),af,ag,ah]})})}[h,i]=u.then?(await u)():u,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:()=>q,Cb:()=>C,D0:()=>y,DN:()=>l,Jn:()=>j,MR:()=>m,Ok:()=>v,QF:()=>i,SN:()=>r,UV:()=>B,Vv:()=>t,Yj:()=>A,Yn:()=>z,bv:()=>s,cm:()=>n,cv:()=>u,jO:()=>w,tp:()=>x,uc:()=>p,y8:()=>o});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>g(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>d.gen(function*(){let c=new URLSearchParams({cwd:a});b&&c.set("tabId",b);let d=yield*f(`/api/terminal/env?${c}`);return{env:d.env||{},home:d.home||""}}),j=()=>f("/api/terminal/aliases").pipe(d.map(a=>a.aliases||{})),k=(a,b)=>`/api/terminal/bubble-order?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}`,l=(a,b)=>f(k(a,b)).pipe(d.map(a=>a.order||[])),m=(a,b)=>f(k(a,b)).pipe(d.map(a=>a.titles||{})),n=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,order:c,sourceId:d}),o=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,titles:{[c]:d}}),p=(a,b,c,d=100)=>f(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&page=${c}&pageSize=${d}`),q=(a,b,c,d)=>h("/api/terminal/history",{cwd:a,tabId:b,entry:c,sourceId:d}),r=(a,b,c,d)=>g(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&commandId=${encodeURIComponent(c)}${d?`&sourceId=${encodeURIComponent(d)}`:""}`,{method:"DELETE"}),s=(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})}),t=a=>h("/api/terminal/env",a),u=a=>h("/api/terminal/aliases",{aliases:a}),v=a=>h("/api/terminal/register",a),w=a=>h("/api/terminal/unregister",a),x=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"POST /api/terminal/autocomplete failed",cause:a})}),y=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),z=a=>h("/api/project-settings",a),A=()=>f("/api/services/config?scope=global"),B=a=>f(`/api/services/config?cwd=${encodeURIComponent(a)}`),C=a=>{let b;return b="/api/services/config",d.tryPromise({try:async()=>{let c=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:a=>new e.uV({message:`POST ${b} failed`,cause: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,onClose:l}){let{t:n}=(0,g.Bd)(),[o,p]=(0,f.useState)(null),[q,r]=(0,f.useState)(null),[s,t]=(0,f.useState)(!1),u=(0,f.useRef)(void 0),v=d?!!d.running:!c?.result;(0,f.useCallback)(async()=>{let e=await i.t4.runPromiseExit((0,k.z)({cwd:a,sessionId:b,...d?{workflowId:d.runId,workflowAgentId:d.agentId}:{toolUseId:c?.id},ifFingerprint:u.current}));if(t(!0),"Success"!==e._tag||!e.value)return;let f=e.value;f.fingerprint&&(u.current=f.fingerprint),!f.notModified&&(f.messages&&p(f.messages),f.subagent&&r(f.subagent))},[a,b,c?.id,d?.runId,d?.agentId]);let w=(0,f.useRef)(null),x=(0,f.useRef)(!0),y="string"==typeof c?.input?.description?c.input.description:"",z=d?d.label||"":[q?.agentType,y].filter(Boolean).join(" \xb7 ");return(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:l,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:n("chat.subagent")}),z&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":z,children:z}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[v&&(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:n("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{ref:w,onScroll:()=>{let a=w.current;a&&(x.current=a.scrollTop+a.clientHeight>=a.scrollHeight-40)},className:"flex-1 overflow-y-auto px-4 py-3",children:null===o?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:n(s?"chat.subagentEmpty":"common.loading")}):o.map(b=>(0,e.jsx)(j.s,{message:b,cwd:a},b.id))})]})})})}j=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},23734:(a,b,c)=>{"use strict";c.d(b,{R:()=>e,d:()=>f});var d=c(28031);let e=(a,b)=>({id:a,legacyType:b??a.replace(/-/g,"_").toUpperCase()}),f=d.Io("@cockpit/IframeBus")},23860:(a,b,c)=>{"use strict";c.d(b,{F:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return a}},23881:(a,b,c)=>{"use strict";c.d(b,{s:()=>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.jsx)(j.KO,{status:g?.status,className:"mt-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),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,claudeContextWindow:v,onClaudeContextWindowChange:w,claudeFastMode:x,onClaudeFastModeChange:y,claudeThinking:z,onClaudeThinkingChange:A,codexModel:B,onCodexModelChange:C,codexReasoningEffort:D,onCodexReasoningEffortChange:E,planMode:F,onPlanModeChange:G,noHistory:H,onNoHistoryChange:I,isActive:J,refreshSignal:K,onStateChange:L,onShowGitStatus:M,onOpenNote:N,onCreateScheduledTask:O,onOpenSession:P,onContentSearch:Q,onShowFileDiff:R,onOpenFileLink:S}){let T=(0,f.useCallback)(b=>{L(a,{isLoading:b})},[a,L]),U=(0,f.useCallback)(b=>{L(a,{sessionId:b})},[a,L]),V=(0,f.useCallback)(b=>{L(a,{title:b})},[a,L]),W=(0,f.useCallback)(b=>{h?.(a,b)},[a,h]),X=(0,f.useCallback)(b=>{k?.(a,b)},[a,k]),Y=(0,f.useCallback)(b=>{m?.(a,b)},[a,m]),Z=(0,f.useCallback)(b=>{o?.(a,b)},[a,o]),$=(0,f.useCallback)(b=>{q?.(a,b)},[a,q]),_=(0,f.useCallback)(b=>{s?.(a,b)},[a,s]),aa=(0,f.useCallback)(b=>{u?.(a,b)},[a,u]),ab=(0,f.useCallback)(b=>{w?.(a,b)},[a,w]),ac=(0,f.useCallback)(b=>{y?.(a,b)},[a,y]),ad=(0,f.useCallback)(b=>{A?.(a,b)},[a,A]),ae=(0,f.useCallback)(b=>{C?.(a,b)},[a,C]),af=(0,f.useCallback)(b=>{E?.(a,b)},[a,E]),ag=(0,f.useCallback)(b=>{G?.(a,b)},[a,G]),ah=(0,f.useCallback)(b=>{I?.(a,b)},[a,I]);return(0,e.jsx)(g.r,{tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:W,ollamaModel:j,onOllamaModelChange:X,deepseekModel:l,onDeepseekModelChange:Y,kimiModel:n,onKimiModelChange:Z,glmModel:p,onGlmModelChange:$,claudeModel:r,onClaudeModelChange:_,claudeEffort:t,onClaudeEffortChange:aa,claudeContextWindow:v,onClaudeContextWindowChange:ab,claudeFastMode:x,onClaudeFastModeChange:ac,claudeThinking:z,onClaudeThinkingChange:ad,codexModel:B,onCodexModelChange:ae,codexReasoningEffort:D,onCodexReasoningEffortChange:af,planMode:F,onPlanModeChange:ag,noHistory:H,onNoHistoryChange:ah,hideHeader:!0,hideSidebar:!0,isActive:J,refreshSignal:K,onLoadingChange:T,onSessionIdChange:U,onTitleChange:V,onShowGitStatus:M,onOpenNote:N,onCreateScheduledTask:O,onOpenSession:P,onContentSearch:Q,onShowFileDiff:R,onOpenFileLink:S})}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.tryPromise({try:async()=>{let a=await fetch(`/api/files/search?${i}`),b=await a.json();if(b.error)throw Error(b.error);return b},catch:a=>new h.uV({message:"content search failed",cause:a})});await g.t4.runPromise(j.pipe(f.match({onSuccess:a=>{l(a.results),v({totalFiles:a.totalFiles,totalMatches:a.totalMatches,truncated:a.truncated}),r(new Set(a.results.map(a=>a.path))),a.results.length>0&&b?.()},onFailure:a=>{p(a.cause instanceof Error?a.cause.message:"Search failed"),l([])}}))),n(!1)},[a,s,b]);return{contentSearchQuery:c,setContentSearchQuery:j,contentSearchResults:k,isSearching:m,searchError:o,searchExpandedPaths:q,searchOptions:s,setSearchOptions:t,searchStats:u,contentSearchInputRef:w,performContentSearch:x,handleSearchToggle:(0,d.useCallback)(a=>{r(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[])}}},20586:(a,b,c)=>{"use strict";c.d(b,{Do:()=>m,Sz:()=>n,VO:()=>l,wI:()=>o});var d=c(48249),e=c(67484),f=c.n(e),g=c(44384),h=c(7122),i=c(61591);function j({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 k=f().memo(function a({node:b,level:c,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m=!1,renderActions:n}){let o=f===b.path,p=g.has(b.path),q=(0,e.useCallback)(()=>{b.isDirectory?k(b.path):h(b)},[b,h,k]),r=(0,e.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),l(a,b.path,b.isDirectory)},[b.path,b.isDirectory,l]);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:q,onContextMenu:r,children:[(0,d.jsx)("span",{className:"text-foreground-subtle text-xs",children:p?"▼":"▶"}),(0,d.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":b.path,children:b.name}),n&&n(b)]}),p&&b.children.map(b=>(0,d.jsx)(a,{node:b,level:c+1,selectedPath:f,expandedPaths:g,onSelect:h,onToggle:k,onContextMenu:l,showChanges:m,renderActions:n},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 ${o?"bg-brand/10":"hover:bg-hover"}`,style:{paddingLeft:`${12*c+8}px`},onClick:q,onContextMenu:r,children:[(0,d.jsx)(i.o,{name:b.name,size:16,className:"flex-shrink-0"}),(0,d.jsx)("span",{className:`text-sm flex-1 truncate ${o?"text-brand":"text-foreground"}`,"data-tooltip":b.path,children:b.name}),b.status&&(0,d.jsx)(j,{status:b.status}),m&&void 0!==b.additions&&void 0!==b.deletions&&(0,d.jsxs)(d.Fragment,{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]})]}),n&&n(b)]})});function l({files:a,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,cwd:i,showChanges:j=!1,renderActions:m,emptyMessage:n,className:o,onExplain:p,explainDisabled:q}){let{t:r}=(0,g.Bd)(),s=n??r("gitFileTree.noFiles"),{contextMenu:t,showContextMenu:u,hideContextMenu:v}=(0,h.Ee)();return 0===a.length?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-foreground-subtle",children:s}):(0,d.jsxs)("div",{className:o||"py-1",children:[a.map(a=>(0,d.jsx)(k,{node:a,level:0,selectedPath:b,expandedPaths:c,onSelect:e,onToggle:f,onContextMenu:u,showChanges:j,renderActions:m},a.path)),t&&(0,d.jsx)(h.ft,{x:t.x,y:t.y,path:t.path,cwd:i,isDirectory:t.isDirectory,onClose:v,onExplain:p,explainDisabled:q})]})}function m(a){let b=[];for(let c of a){let a=c.path.split("/"),d=b;for(let b=0;b<a.length;b++){let e=a[b],f=b===a.length-1,g=a.slice(0,b+1).join("/"),h=d.find(a=>a.name===e);h||(h={name:e,path:g,isDirectory:!f,children:[],...f&&{status:c.status,additions:c.additions,deletions:c.deletions,oldPath:c.oldPath,file:c}},d.push(h)),f||(d=h.children)}}let c=a=>{a.sort((a,b)=>a.isDirectory&&!b.isDirectory?-1:!a.isDirectory&&b.isDirectory?1:a.name.localeCompare(b.name)),a.forEach(a=>c(a.children))};return c(b),b}function n(a){let b=[],c=a=>{for(let d of a)d.isDirectory&&(b.push(d.path),c(d.children))};return c(a),b}function o(a){let b=[],c=a=>{if(a.isDirectory)for(let b of a.children)c(b);else b.push(a)};return c(a),b}},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:()=>v});var e=c(48249),f=c(67484),g=c(44384),h=c(35208),i=c(39238),j=c(74691),k=c(60333),l=c(20586),m=c(46242),n=c(21787),o=c(9804),p=c(33281),q=c(85655),r=c(60591),s=c(18921),t=c(7031);c(57063);var u=a([h,i]);function v({isOpen:a,onClose:b,commit:c,cwd:d,embedded:u=!1,initialFilePath:w,onContentSearch:x,onLocateInTree:y}){let{t:z}=(0,g.Bd)(),[A,B]=(0,f.useState)([]),[C,D]=(0,f.useState)([]),[E,F]=(0,f.useState)(new Set),[G,H]=(0,f.useState)(null),[I,J]=(0,f.useState)(null),[K,L]=(0,f.useState)(!1),[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)(null),[S,T]=(0,f.useState)("compact"),[U,V]=(0,f.useState)("unified"),W=(0,f.useRef)(null),X=(0,s.o)(W),Y=(0,t.r)(),Z=c?.shortHash,$=(0,f.useCallback)(a=>{Z&&Y?.sendMessage(z("explain.commitFileMessage",{hash:Z,path:a}))},[Y,z,Z]),_=(0,f.useCallback)(a=>{c&&(H(a),N(!0),p.t4.runPromiseExit((0,q.Zi)(d,c.hash,a.path)).then(a=>{"Success"===a._tag?J(a.value):console.error(a.cause),N(!1)}))},[d,c]),aa=(0,f.useCallback)(a=>{F(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),ab=(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]),ac=I?.filePath,ad=(0,f.useMemo)(()=>ac?(0,e.jsx)(n.d,{cwd:d,filePath:ac,onLocateInTree:y}):null,[d,ac,y]);if(!a||!c)return null;let ae=!!I&&(!0===I.isImage||(0,o.u)(I.filePath)),af=(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:z("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:z("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:z("commitDetail.date")}),(0,e.jsx)("span",{children:ab}),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:z("commitDetail.files")}),(0,e.jsx)("span",{children:z("commitDetail.nChanges",{count:A.length})})]}),!ae&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(j.y,{value:S,onChange:T}),(0,e.jsx)(k.q,{value:U,onChange:V})]})]})]}),(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:K?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:z("commitDetail.loadingFiles")}):(0,e.jsx)(l.VO,{files:C,selectedPath:G?.path||null,expandedPaths:E,onSelect:a=>a.file&&_(a.file),onToggle:aa,cwd:d,showChanges:!0,emptyMessage:z("commitDetail.noFileChanges"),className:"py-1",onExplain:Y&&Z?$:void 0,explainDisabled:Y?.isLoading})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:M?(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("commitDetail.loadingDiff")}):I?ae?(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:ad}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(m.M,{cwd:d,filePath:I.filePath,oldRev:I.oldRev??(I.isNew?null:`${c.hash}^1`),newRev:I.newRev??(I.isDeleted?null:c.hash)})})]}):"unified"===U?(0,e.jsx)(h.xU,{oldContent:I.oldContent,newContent:I.newContent,filePath:I.filePath,cwd:d,enableComments:!0,compact:"compact"===S,headerLeading:ad,onPreview:I.isDeleted?void 0:(0,r.aR)(I.filePath)?()=>R({content:I.newContent,filePath:I.filePath}):I.filePath.endsWith(".json")?()=>P({content:I.newContent,filePath:I.filePath}):void 0,previewLabel:(0,r.aR)(I.filePath)?z("common.preview"):z("common.readable"),onContentSearch:x}):(0,e.jsx)(h.xZ,{oldContent:I.oldContent,newContent:I.newContent,filePath:I.filePath,isNew:I.isNew,isDeleted:I.isDeleted,cwd:d,enableComments:!0,compact:"compact"===S,headerLeading:ad,onPreview:I.isDeleted?void 0:(0,r.aR)(I.filePath)?()=>R({content:I.newContent,filePath:I.filePath}):I.filePath.endsWith(".json")?()=>P({content:I.newContent,filePath:I.filePath}):void 0,previewLabel:(0,r.aR)(I.filePath)?z("common.preview"):z("common.readable"),onContentSearch:x}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("commitDetail.selectFileToView")})})]})]}),ag=O&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>P(null),children:(0,e.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,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:O.filePath}),(0,e.jsx)("button",{onClick:()=>P(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(s._,{search:X}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{ref:W,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,r.xb)(O.content)})})]})}),ah=Q&&(0,e.jsx)(i.N,{filePath:Q.filePath,content:Q.content,cwd:d,onClose:()=>R(null)});return u?(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:z("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"})})}),af,ag,ah]}):(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:z("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"})})})]}),af,ag,ah]})})}[h,i]=u.then?(await u)():u,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:()=>q,Cb:()=>C,D0:()=>y,DN:()=>l,Jn:()=>j,MR:()=>m,Ok:()=>v,QF:()=>i,SN:()=>r,UV:()=>B,Vv:()=>t,Yj:()=>A,Yn:()=>z,bv:()=>s,cm:()=>n,cv:()=>u,jO:()=>w,tp:()=>x,uc:()=>p,y8:()=>o});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>g(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>d.gen(function*(){let c=new URLSearchParams({cwd:a});b&&c.set("tabId",b);let d=yield*f(`/api/terminal/env?${c}`);return{env:d.env||{},home:d.home||""}}),j=()=>f("/api/terminal/aliases").pipe(d.map(a=>a.aliases||{})),k=(a,b)=>`/api/terminal/bubble-order?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}`,l=(a,b)=>f(k(a,b)).pipe(d.map(a=>a.order||[])),m=(a,b)=>f(k(a,b)).pipe(d.map(a=>a.titles||{})),n=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,order:c,sourceId:d}),o=(a,b,c,d)=>h("/api/terminal/bubble-order",{cwd:a,tabId:b,titles:{[c]:d}}),p=(a,b,c,d=100)=>f(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&page=${c}&pageSize=${d}`),q=(a,b,c,d)=>h("/api/terminal/history",{cwd:a,tabId:b,entry:c,sourceId:d}),r=(a,b,c,d)=>g(`/api/terminal/history?cwd=${encodeURIComponent(a)}&tabId=${encodeURIComponent(b)}&commandId=${encodeURIComponent(c)}${d?`&sourceId=${encodeURIComponent(d)}`:""}`,{method:"DELETE"}),s=(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})}),t=a=>h("/api/terminal/env",a),u=a=>h("/api/terminal/aliases",{aliases:a}),v=a=>h("/api/terminal/register",a),w=a=>h("/api/terminal/unregister",a),x=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/terminal/autocomplete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"POST /api/terminal/autocomplete failed",cause:a})}),y=a=>f(`/api/project-settings?cwd=${encodeURIComponent(a)}`),z=a=>h("/api/project-settings",a),A=()=>f("/api/services/config?scope=global"),B=a=>f(`/api/services/config?cwd=${encodeURIComponent(a)}`),C=a=>{let b;return b="/api/services/config",d.tryPromise({try:async()=>{let c=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:a=>new e.uV({message:`POST ${b} failed`,cause: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: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(b=>(0,e.jsx)(j.s,{message:b,cwd:a},b.id))})]})})})}j=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},23734:(a,b,c)=>{"use strict";c.d(b,{R:()=>e,d:()=>f});var d=c(28031);let e=(a,b)=>({id:a,legacyType:b??a.replace(/-/g,"_").toUpperCase()}),f=d.Io("@cockpit/IframeBus")},23860:(a,b,c)=>{"use strict";c.d(b,{F:()=>e});var d=c(67484);function e(){let[a,b]=(0,d.useState)(()=>"u"<typeof document||"visible"===document.visibilityState);return a}},23881:(a,b,c)=>{"use strict";c.d(b,{s:()=>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
|
-
${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,b,c){let{engine:f,assistantId:g}=c;if("stream_event"===b.type){let c=b.event;if(c?.type==="content_block_delta"&&c.delta?.type==="text_delta"&&c.delta.text){let b=c.delta.text;return a.map(a=>a.id===g?{...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 h=a,i=b.message?.model==="<synthetic>";if("codex"===f||"ollama"===f||i){let a=c.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("");a&&(h=h.map(b=>b.id===g?{...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-${g}-${a.name}`,name:a.name,input:a.input||{},isLoading:!0};h=h.map(a=>a.id!==g||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 h}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===g?{...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===g?{...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===g?{...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}c.d(b,{F:()=>f})},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.tryPromise({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:()=>n});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(40311),j=c(29939),k=c(85655);function l({number:a,status:b,isActive:c}){return(0,e.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,i.c)(b,c)}`,"aria-hidden":"true",children:a})}function m({badge:a,onSelect:b}){return(0,e.jsx)("button",{type:"button",onClick:c=>{c.stopPropagation(),b(a.sessionId)},className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border font-mono text-[9px] font-medium leading-none tabular-nums transition-transform hover:scale-125 ${(0,i.c)(a.status,!1)}`,title:a.label,children:a.label})}let a=[],o=()=>{};function n({index:b,name:c,cwd:d,isActive:i,collapsed:p,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,k.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,j.h)({url:`/ws/watch?cwd=${encodeURIComponent(d)}`,onMessage:D});let E=s??a,F=A?p?`${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 ${p?"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,{number:b+1,status:p?r?"loading":q&&!i?"unread":"normal":"normal",isActive:i}),!p&&(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)(m,{badge:a,onSelect:u??o},a.sessionId))}):i?(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]})]})}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(83721);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,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)}})},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:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(15819),j=c(77156),k=c(59336),l=c(2633),m=c(33281),n=a([l]);function o({isOpen:a,onClose:b}){let{t:c,i18n:d}=(0,g.Bd)(),[n,q]=(0,f.useState)([]),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(""),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(""),[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 m.t4.runPromiseExit((0,j.Hy)());"Success"===a._tag?q(a.value):console.error("Failed to load skills",a.cause),s(!1)},[]),F=(0,f.useMemo)(()=>{let a=t.trim().toLowerCase();return a?n.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):n},[n,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 m.t4.runPromiseExit((0,j.L5)(a));if("Success"===b._tag)(0,h.oR)(b.value.alreadyExists?c("skills.alreadyAdded"):c("skills.added"),b.value.alreadyExists?"info":"success"),y(""),w(!1),await E(),b.value.alreadyExists||(0,k.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,h.oR)(e,"error")}A(!1)},[x,E,c]),I=(0,f.useCallback)(async a=>{let b=await m.t4.runPromiseExit((0,j.hp)(a));"Success"===b._tag?(q(b=>b.filter(b=>b.id!==a)),(0,k.k)()):(0,h.oR)(c("common.deleteFailed"),"error")},[c]),J=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,h.oR)(c("common.copiedPath"),"success")}catch{(0,h.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:i.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===n.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:i.jL,children:F.map(a=>(0,e.jsx)(p,{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)(l.d,{skillId:B,onClose:()=>C(null)})]}):null}function p({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let{t:h}=(0,g.Bd)(),[i,j]=(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)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})})}),(0,e.jsxs)("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:h("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:i?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),j(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:h("common.confirm")}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),j(!1)},className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:h("common.cancel")})]}):(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),j(!0)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:h("common.delete"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 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:h("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:h("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})]})}l=(n.then?(await n)():n)[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)()})})]})]})}},32459:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>n});var e=c(48249),f=c(67484),g=c(44384),h=c(82795),i=c(32753),j=c(74228),k=c(1512),l=c(50508),m=a([l]);function n({currentCwd:a,onSwitchProject:b,onResolveSessionNumbers:c,collapsed:d,sessions:m}){let{t:o}=(0,g.Bd)(),p=(0,f.useMemo)(()=>(0,k.H)(m),[m]),[q,r]=(0,f.useState)(!1),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)({}),w=(0,f.useRef)(0),x=(0,f.useRef)(null),y=(0,l.o$)(),{show:z,hide:A}=y,B=(0,f.useCallback)(a=>{b(a.cwd,a.sessionId),r(!1)},[b]),C=(0,f.useCallback)(()=>{let a=!q;if(r(a),a){let a=++w.current;v({}),c().then(b=>{w.current===a&&v(b)})}else w.current+=1},[q,c]),D=m.filter(a=>"loading"===a.status).length,E=m.filter(a=>"unread"===a.status).length;return(0,e.jsxs)("div",{className:"relative",ref:x,children:[(0,e.jsxs)("button",{onClick:C,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?o("sessions.recentSessions"):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:"M13 10V3L4 14h7v7l9-11h-7z"})}),!d&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:o("sessions.recentSessions")}),D>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-orange-11/20 animate-pulse ${d?"absolute -top-1 -right-1":""}`,children:D}),E>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-red-9/55 ${d&&!D?"absolute -top-1 -right-1":""}`,children:E})]}),q&&(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:o("sessions.recentSessions")}),D>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",o("sessions.runningCount",{count:D}),")"]}),E>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-red-11",children:["(",o("sessions.unreadCount",{count:E}),")"]}),(0,e.jsxs)("button",{onClick:()=>{r(!1),t(!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:o("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:o("sessions.search")})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===p.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:o("sessions.noSessions")}):p.map((b,c)=>(0,e.jsxs)("button",{onClick:()=>B(b),onMouseEnter:a=>z(b,a),onMouseLeave:A,className:`w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 ${c!==p.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:[(0,e.jsx)(l.KO,{status:b.status,className:"mt-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:b.engine}),(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:(0,l.Qr)(b.cwd)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(0,l.fw)(o,b.lastActive)}),(0,e.jsx)(j.l,{coordinate:u[`${b.cwd}
|
|
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:()=>j,Nn:()=>f,A7:()=>h,fD:()=>i});let g=["task_started","task_progress","task_notification"];function h(a){return"system"===a.type&&g.includes(a.subtype??"")}function i(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 j(a,b,c){let{engine:g,assistantId:i}=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=>{let d;return a.id===c?{...a,task:(d={status:"running",...a.task},"task_notification"===b.subtype&&(d.status=b.status??"completed"),b.task_id&&(d.id=b.task_id),b.last_tool_name&&(d.lastToolName=b.last_tool_name),b.summary&&(d.summary=b.summary),"number"==typeof b.usage?.tool_uses&&(d.toolUses=b.usage.tool_uses),"number"==typeof b.usage?.duration_ms&&(d.durationMs=b.usage.duration_ms),d)}: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===i?{...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===i?{...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-${i}-${a.name}`,name:a.name,input:a.input||{},isLoading:!0};f=f.map(a=>a.id!==i||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===i?{...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===i?{...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===i?{...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.tryPromise({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:()=>n});var e=c(48249),f=c(67484),g=c(44384),h=c(33281),i=c(40311),j=c(29939),k=c(85655);function l({number:a,status:b,isActive:c}){return(0,e.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,i.c)(b,c)}`,"aria-hidden":"true",children:a})}function m({badge:a,onSelect:b}){return(0,e.jsx)("button",{type:"button",onClick:c=>{c.stopPropagation(),b(a.sessionId)},className:`flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full border font-mono text-[9px] font-medium leading-none tabular-nums transition-transform hover:scale-125 ${(0,i.c)(a.status,!1)}`,title:a.label,children:a.label})}let a=[],o=()=>{};function n({index:b,name:c,cwd:d,isActive:i,collapsed:p,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,k.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,j.h)({url:`/ws/watch?cwd=${encodeURIComponent(d)}`,onMessage:D});let E=s??a,F=A?p?`${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 ${p?"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,{number:b+1,status:p?r?"loading":q&&!i?"unread":"normal":"normal",isActive:i}),!p&&(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)(m,{badge:a,onSelect:u??o},a.sessionId))}):i?(0,e.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]})]})}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(83721);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,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)}})},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:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(15819),j=c(77156),k=c(59336),l=c(2633),m=c(33281),n=a([l]);function o({isOpen:a,onClose:b}){let{t:c,i18n:d}=(0,g.Bd)(),[n,q]=(0,f.useState)([]),[r,s]=(0,f.useState)(!1),[t,u]=(0,f.useState)(""),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(""),[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 m.t4.runPromiseExit((0,j.Hy)());"Success"===a._tag?q(a.value):console.error("Failed to load skills",a.cause),s(!1)},[]),F=(0,f.useMemo)(()=>{let a=t.trim().toLowerCase();return a?n.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):n},[n,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 m.t4.runPromiseExit((0,j.L5)(a));if("Success"===b._tag)(0,h.oR)(b.value.alreadyExists?c("skills.alreadyAdded"):c("skills.added"),b.value.alreadyExists?"info":"success"),y(""),w(!1),await E(),b.value.alreadyExists||(0,k.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,h.oR)(e,"error")}A(!1)},[x,E,c]),I=(0,f.useCallback)(async a=>{let b=await m.t4.runPromiseExit((0,j.hp)(a));"Success"===b._tag?(q(b=>b.filter(b=>b.id!==a)),(0,k.k)()):(0,h.oR)(c("common.deleteFailed"),"error")},[c]),J=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,h.oR)(c("common.copiedPath"),"success")}catch{(0,h.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:i.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===n.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:i.jL,children:F.map(a=>(0,e.jsx)(p,{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)(l.d,{skillId:B,onClose:()=>C(null)})]}):null}function p({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let{t:h}=(0,g.Bd)(),[i,j]=(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)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})})}),(0,e.jsxs)("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:h("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:i?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),j(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:h("common.confirm")}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),j(!1)},className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:h("common.cancel")})]}):(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),j(!0)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:h("common.delete"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 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:h("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:h("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})]})}l=(n.then?(await n)():n)[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)()})})]})]})}},32459:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{e:()=>n});var e=c(48249),f=c(67484),g=c(44384),h=c(82795),i=c(32753),j=c(74228),k=c(1512),l=c(50508),m=a([l]);function n({currentCwd:a,onSwitchProject:b,onResolveSessionNumbers:c,collapsed:d,sessions:m}){let{t:o}=(0,g.Bd)(),p=(0,f.useMemo)(()=>(0,k.H)(m),[m]),[q,r]=(0,f.useState)(!1),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)({}),w=(0,f.useRef)(0),x=(0,f.useRef)(null),y=(0,l.o$)(),{show:z,hide:A}=y,B=(0,f.useCallback)(a=>{b(a.cwd,a.sessionId),r(!1)},[b]),C=(0,f.useCallback)(()=>{let a=!q;if(r(a),a){let a=++w.current;v({}),c().then(b=>{w.current===a&&v(b)})}else w.current+=1},[q,c]),D=m.filter(a=>"loading"===a.status).length,E=m.filter(a=>"unread"===a.status).length;return(0,e.jsxs)("div",{className:"relative",ref:x,children:[(0,e.jsxs)("button",{onClick:C,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?o("sessions.recentSessions"):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:"M13 10V3L4 14h7v7l9-11h-7z"})}),!d&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:o("sessions.recentSessions")}),D>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-orange-11/20 animate-pulse ${d?"absolute -top-1 -right-1":""}`,children:D}),E>0&&(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-red-9/55 ${d&&!D?"absolute -top-1 -right-1":""}`,children:E})]}),q&&(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:o("sessions.recentSessions")}),D>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",o("sessions.runningCount",{count:D}),")"]}),E>0&&(0,e.jsxs)("span",{className:"ml-2 text-xs text-red-11",children:["(",o("sessions.unreadCount",{count:E}),")"]}),(0,e.jsxs)("button",{onClick:()=>{r(!1),t(!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:o("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:o("sessions.search")})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===p.length?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:o("sessions.noSessions")}):p.map((b,c)=>(0,e.jsxs)("button",{onClick:()=>B(b),onMouseEnter:a=>z(b,a),onMouseLeave:A,className:`w-full px-3 py-2 text-left hover:bg-hover transition-colors flex items-start gap-2 ${c!==p.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:[(0,e.jsx)(l.KO,{status:b.status,className:"mt-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:b.engine}),(0,e.jsx)("span",{className:"font-medium text-sm truncate",children:(0,l.Qr)(b.cwd)}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(0,l.fw)(o,b.lastActive)}),(0,e.jsx)(j.l,{coordinate:u[`${b.cwd}
|
|
19
19
|
${b.sessionId}`],status:(0,j.S)(b.status),statusLabel:(0,l.Mm)(o,b.status),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)(l.LD,{...y}),(0,e.jsx)(h.e,{isOpen:s,onClose:()=>t(!1),onSwitchProject:b,sessionNumbers:u})]})}l=(m.then?(await m)():m)[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:()=>J});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));f.gen(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*f.sync(()=>{let a="u">typeof process?process.env:void 0,b=a?.HOME||a?.USERPROFILE||".",c=a?.COCKPIT_HOME;return c?c.replace(/^~(?=$|\/)/,b):b+"/.cockpit"});return{env:a,host:b,port:3457===c&&"dev"===a?3456:c,cockpitDir:l,openProject:d,openBrowser:!e,logLevel:g,logFile:l+"/logs/cockpit.log",snapshotKeepDays:h,snapshotRepoTtlDays:i,snapshotMaxFileKb:j,sessionKeepDays:k}}).pipe(f.orDie);let C=d.Ie;var D=c(7846),E=c(55805),F=c(23734);let G=d.P1(F.d,f.gen(function*(){let a=yield*D.dT();return yield*f.acquireRelease(f.sync(()=>b=>{f.runFork(D.mk(a,b))}),a=>f.sync(()=>{})),F.d.of({publish:(a,b)=>f.sync(()=>{}),subscribe:b=>E.qdp(a).pipe(E.pbD(a=>{var c;return c=a.data,!!c&&"object"==typeof c&&(c.topic===b.id||c.type===b.legacyType)}),E.TjK(a=>((a,b)=>{if(a.topic===b.id)return a.msg;let{type:c,...d}=a;return d})(a.data,b)))})})),H=d.Um(i,q,C),I=d.Um(H,G),J=e.L8(I);f.void},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.tapError(a=>A.sync(()=>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)}})},34728:(a,b,c)=>{"use strict";c.d(b,{U:()=>j});var d=c(67484),e=c(44384),f=c(7833),g=c(77156),h=c(59336),i=c(33281);function j(){let{t:a}=(0,e.Bd)();return(0,d.useCallback)(async b=>{let c=await i.t4.runPromiseExit((0,g.L5)(b));if("Success"===c._tag)c.value.alreadyExists?(0,f.oR)(a("skills.alreadyAdded"),"info"):((0,f.oR)(a("skills.added"),"success"),(0,h.k)());else{let b="Fail"===c.cause._tag?c.cause.error:null,d=b?.cause,e=d instanceof Error?d.message:a("skills.addFailed");(0,f.oR)(e,"error")}},[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})},36688:(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(44256),h=c(7122),i=c(73887),j=a([i]);function k({filePath:a,content:b,cwd:c,onClose:d,zClassName:j="z-50"}){let[l,m]=(0,f.useState)(null);return(0,e.jsx)(g.ZL,{children:(0,e.jsx)("div",{className:`fixed inset-0 ${j} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:d,children:(0,e.jsx)("div",{ref:m,className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative",onClick:a=>a.stopPropagation(),children:(0,e.jsx)(h.SU,{container:l,children:(0,e.jsx)(i.M,{content:b,filePath:a,cwd:c,onClose:d})})})})})}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},36702:(a,b,c)=>{"use strict";c.d(b,{V:()=>y});var d=c(48249),e=c(67484),f=c(44384),g=c(44256),h=c(7833);function i({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,h.oR)(c("imagePreview.copiedImage"),"success")}catch{(0,h.oR)(c("common.copyFailed"),"error")}},j=(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)(g.ZL,{children:j})}function j({images:a,onRemove:b,disabled:c}){let{t:g}=(0,f.Bd)(),[h,k]=(0,e.useState)(null);return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-2 p-2 border-b border-border",children:a.map(a=>(0,d.jsxs)("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-border cursor-pointer",onClick:()=>k(a),children:[(0,d.jsx)("img",{src:a.preview,alt:g("imagePreview.previewImage"),className:"w-full h-full object-cover hover:opacity-90 transition-opacity"}),(0,d.jsx)("button",{onClick:c=>{c.stopPropagation(),b(a.id)},className:"absolute top-0 right-0 w-5 h-5 bg-black/60 hover:bg-black/80 text-white text-xs flex items-center justify-center rounded-bl-lg opacity-0 group-hover:opacity-100 transition-opacity",title:g("imagePreview.deleteImage"),children:"✕"})]},a.id))}),h&&(0,d.jsx)(i,{image:h,onClose:()=>k(null)})]})}var k=c(30458),l=c(24520),m=c(33999),n=c(74118),o=c(3623),p=c(12625),q=c(46674),r=c(72529),s=c(33281),t=c(41224);function u({initialValue:a,placeholder:b,onCommit:c,onCancel:f}){let[g,h]=(0,e.useState)(a),i=(0,e.useCallback)(a=>{if("Enter"!==a.key||a.nativeEvent.isComposing)"Escape"===a.key&&(a.preventDefault(),a.stopPropagation(),f());else{a.preventDefault(),a.stopPropagation();let b=g.trim();b&&c(b)}},[g,c,f]);return(0,d.jsx)("input",{type:"text",value:g,onChange:a=>h(a.target.value),onKeyDown:i,placeholder:b,autoFocus:!0,className:"w-full min-w-0 px-2 py-1 mb-1 text-xs rounded border border-input bg-background focus:outline-none focus:ring-1 focus:ring-ring"})}function v({label:a,prompts:b,isAdding:c,onStartAdd:g,onCancelAdd:h,onAdd:i,onUpdate:j,onDelete:k,onReorder:s,onSelect:t,onInsert:w}){let{t:x}=(0,f.Bd)(),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),E=(0,e.useCallback)(()=>{B(null),D(null)},[]),F=(0,e.useCallback)((a,b)=>{a.preventDefault(),D(b)},[]),G=(0,e.useCallback)(a=>{if(null===A||A===a)return void E();let c=[...b],[d]=c.splice(A,1);c.splice(a,0,d),E(),z(null),s(c)},[A,b,s,E]);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}),(0,d.jsx)("button",{type:"button",onClick:()=>{z(null),g()},className:"p-0.5 text-muted-foreground hover:text-foreground rounded",title:x("chat.addQuickPrompt"),children:(0,d.jsx)(l.A,{className:"w-3.5 h-3.5"})})]}),c&&(0,d.jsx)(u,{initialValue:"",placeholder:x("chat.quickPromptPlaceholder"),onCommit:i,onCancel:h}),0===b.length&&!c&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground px-1 py-1",children:x("chat.noQuickPrompts")}),b.map((a,b)=>y===b?(0,d.jsx)(u,{initialValue:a,placeholder:x("chat.quickPromptPlaceholder"),onCommit:a=>{z(null),j(b,a)},onCancel:()=>z(null)},`edit-${b}`):(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>B(b),onDragOver:a=>F(a,b),onDrop:()=>G(b),onDragEnd:E,className:`flex items-center group min-w-0 rounded transition-opacity ${A===b?"opacity-50":""} ${C===b&&A!==b?"border-t-2 border-brand":""}`,children:[(0,d.jsx)(m.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)(r.m,{content:a,children:(0,d.jsxs)("button",{type:"button",onClick:()=>t(a),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)(n.A,{className:"w-3 h-3 flex-shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"truncate",children:a})]})}),(0,d.jsx)("button",{type:"button",onClick:()=>w(a),className:"p-1 text-muted-foreground hover:text-foreground rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:x("chat.insertQuickPrompt"),children:(0,d.jsx)(o.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>z(b),className:"p-1 text-muted-foreground hover:text-foreground rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:x("common.edit"),children:(0,d.jsx)(p.A,{className:"w-3 h-3"})}),(0,d.jsx)("button",{type:"button",onClick:()=>{z(null),k(b)},className:"p-1 text-muted-foreground hover:text-destructive rounded opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",title:x("common.delete"),children:(0,d.jsx)(q.A,{className:"w-3 h-3"})})]},b))]})}function w({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=(0,e.useCallback)(async(b,c)=>{let d="global"===b?k:m;d(c);let e=await s.t4.runPromiseExit((0,t.tY)("global"===b?{scope:"global",prompts:c}:{cwd:a,prompts:c}));"Failure"===e._tag?console.error(`Failed to save ${b} prompts:`,e.cause):e.value?.prompts&&d(e.value.prompts)},[a]),q=(0,e.useCallback)(a=>{c(),g(a)},[c,g]),r=(0,e.useCallback)(a=>{c(),h(a)},[c,h]);return(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)(v,{label:i("chat.globalPrompts"),prompts:j,isAdding:"global"===n,onStartAdd:()=>o("global"),onCancelAdd:()=>o(null),onAdd:a=>{p("global",[...j,a]),o(null)},onUpdate:(a,b)=>p("global",j.map((c,d)=>d===a?b:c)),onDelete:a=>p("global",j.filter((b,c)=>c!==a)),onReorder:a=>p("global",a),onSelect:q,onInsert:r}),a&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"border-t border-border"}),(0,d.jsx)(v,{label:i("chat.projectPrompts"),prompts:l,isAdding:"project"===n,onStartAdd:()=>o("project"),onCancelAdd:()=>o(null),onAdd:a=>{p("project",[...l,a]),o(null)},onUpdate:(a,b)=>p("project",l.map((c,d)=>d===a?b:c)),onDelete:a=>p("project",l.filter((b,c)=>c!==a)),onReorder:a=>p("project",a),onSelect:q,onInsert:r})]})]})}var x=c(71697);let y=(0,e.memo)(function({onSend:a,disabled:b,cwd:c,engine:g,onShowGitStatus:h,onShowComments:i,onShowUserMessages:l,onOpenNote:m,onCreateScheduledTask:n}){let{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)([]),[t,u]=(0,e.useState)(!1),[v,y]=(0,e.useState)(!1),z=(0,e.useRef)(null),A=(0,e.useRef)(null),B=(0,e.useCallback)(()=>{let a=z.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)(()=>{B()},[p,B]);let C=(0,e.useMemo)(()=>g&&"claude"!==g?[]:[{name:"/plan",description:"Enable plan mode (read-only). /plan <task> to plan a task; /plan off to disable.",source:"builtin",argumentHint:"[task|off]"}],[g]),D=(0,x.n)({value:p,onChange:q,textareaRef:z,extraCommands:C}),E=(0,e.useCallback)(()=>{let c=p.trim();(c||r.length>0)&&!b&&(a(c,r.length>0?r:void 0),q(""),s([]),z.current&&(z.current.style.height="auto"))},[p,r,b,a]),F=(0,e.useCallback)(c=>{b||a(c)},[b,a]),G=(0,e.useCallback)(a=>{q(b=>{let c=b.replace(/\s+$/,"");return c?`${c}
|
|
20
|
-
${a}`:a}),requestAnimationFrame(()=>{let a=z.current;a&&(a.focus(),a.setSelectionRange(a.value.length,a.value.length))})},[]),H=(0,e.useCallback)(a=>{a.nativeEvent.isComposing||!D.handleKeyDown(a)&&("Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),E()))},[D,E]),I=(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(o("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};s(a=>[...a,e])},e.readAsDataURL(c)}}},[o]),J=(0,e.useCallback)(a=>{s(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(j,{images:r,onRemove:J,disabled:b}),(0,d.jsx)(x.V,{ac:D,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:[h&&(0,d.jsx)("button",{onClick:h,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:o("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"})]})}),i&&(0,d.jsx)("button",{onClick:i,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:o("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"})})}),l&&(0,d.jsx)("button",{onClick:l,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:o("chat.userMessages"),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:"M4 6h16M4 12h16M4 18h16"})})}),m&&(0,d.jsx)("button",{onClick:m,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:o("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"})})}),n&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>u(!t),className:`p-2 rounded-lg transition-all ${t?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:o("chat.scheduledTasks"),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:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),t&&(0,d.jsx)(k.E,{onClose:()=>u(!1),onCreate:n})]}),(0,d.jsxs)("div",{className:"relative",ref:A,children:[(0,d.jsx)("button",{onClick:()=>y(!v),className:`p-2 rounded-lg transition-all ${v?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:o("chat.quickPrompts"),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:"M13 10V3L4 14h7v7l9-11h-7z"})})}),v&&(0,d.jsx)(w,{cwd:c,anchorRef:A,onClose:()=>y(!1),onSelect:F,onInsert:G})]}),(0,d.jsx)("textarea",{ref:z,value:p,onChange:a=>{q(a.target.value),D.trackCaret(a.target)},onSelect:a=>D.trackCaret(a.currentTarget),onKeyDown:H,onPaste:I,placeholder:b?o("chat.placeholderDisabled"):o("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"})]})]})})},36984:(a,b,c)=>{"use strict";c.d(b,{Np:()=>k,ZD:()=>h,ZR:()=>i,b8:()=>j,kS:()=>f,sQ:()=>g});let d=null,e=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function f(){return d||(d=Promise.resolve().then(c.bind(c,78908)).then(({createHighlighter:a})=>a({themes:["github-dark","github-light"],langs:[...e]}))),d}function g(a){let b=a.split("/").pop()?.toLowerCase()||"",c=b.split(".").pop()?.toLowerCase();if(".env"===b||b.startsWith(".env.")||"dockerfile"===b||b.startsWith("dockerfile.")||"makefile"===b)return"bash";let d={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[c||""]||"text";return e.includes(d)?d:"text"}function h(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let i=2e3;function j(a){return a.length>i?h(a.map(a=>a.content).join("")):a.map(a=>a.color?`<span style="color:${a.color}">${h(a.content)}</span>`:h(a.content)).join("")}function k(a,b,c,d){if(!b)return[];let e=[],f=c?b:b.toLowerCase();for(let b=0;b<a.length;b++){let g=c?a[b]:a[b].toLowerCase(),h=0;for(;;){let a=g.indexOf(f,h);if(-1===a)break;let c=a+f.length;if(d){let d=a>0?g[a-1]:" ",f=c<g.length?g[c]:" ",h=!/\w/.test(d),i=!/\w/.test(f);h&&i&&e.push({lineIndex:b,startCol:a,endCol:c})}else e.push({lineIndex:b,startCol:a,endCol:c});h=a+1}}return e}},37129:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>l});var d=c(67484),e=c(23860),f=c(29939);c(57031),c(88214);var g=c(79606),h=c(33281),i=c(37388);let j=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\.jsonl)?$/i;function k(a){let b=a.match(j);return b?.[1]??a}function l({initialCwd:a,initialSessionId:b,activeView:c}){(0,d.useRef)(!1);let j=(0,d.useRef)(!0),[m,n]=(0,d.useState)(!1);(0,d.useCallback)(()=>{j.current=!1,n(!0)},[]);let o=(0,d.useRef)(c),p=(0,e.F)(),q=(0,d.useRef)(p),[r,s]=(0,d.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:b?`Session ${b.slice(0,6)}...`:"New Chat"}]),[t,u]=(0,d.useState)(r[0]?.id??""),[v,w]=(0,d.useState)(new Set),x=(0,d.useRef)(r),y=(0,d.useRef)(t),z=(0,d.useRef)(new Set),A=(0,d.useCallback)((b,c)=>{a&&b&&h.t4.runFork((0,i.KJ)(a,b,c).pipe(g.catchAll(()=>g.void)))},[a]),[B,C]=(0,d.useState)(null),[D,E]=(0,d.useState)(null),F=(0,d.useCallback)(b=>{a&&h.t4.runPromise((0,i.n8)(a).pipe(g.catchAll(()=>g.succeed(null)))).then(c=>{if(!c)return;let d=c.engines||{},e={};for(let[a,b]of Object.entries(d))e["codex"===b?k(a):a]=b;let f=[];for(let a of c.sessions||[]){let b="codex"===d[a]?k(a):a;f.includes(b)||f.push(b)}let g=c.ollamaModels||{},h=c.deepseekModels||{},i=c.kimiModels||{},j=c.glmModels||{},l=c.claudeModels||{},m=c.claudeEfforts||{},n=c.claudeContextWindows||{},o=c.claudeFastModes||{},p=c.claudeThinkings||{},q=c.codexModels||{},r=c.codexReasoningEfforts||{},t=c.planModes||{},v=c.noHistories||{},w=x.current,z=new Set(b),A=w.filter(a=>!a.sessionId||!z.has(a.sessionId)),B=new Set(A.map(a=>a.sessionId).filter(Boolean)),C=f.filter(a=>!B.has(a));if(A.length===w.length&&0===C.length)return;let D=[...A,...C.map((b,c)=>({id:`tab-${Date.now()}-sync-${c}`,cwd:a,sessionId:b,title:`Session ${b.slice(0,6)}...`,engine:e[b]||void 0,ollamaModel:g[b]||void 0,deepseekModel:h[b]||void 0,kimiModel:i[b]||void 0,glmModel:j[b]||void 0,claudeModel:l[b]||void 0,claudeEffort:m[b]||void 0,claudeContextWindow:n[b]||void 0,claudeFastMode:o[b]??void 0,claudeThinking:p[b]??void 0,codexModel:q[b]||void 0,codexReasoningEffort:r[b]||void 0,planMode:t[b]||void 0,noHistory:v[b]||void 0}))];0===D.length&&(D=[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),s(D),D.some(a=>a.id===y.current)||u(D[D.length-1].id)})},[a]);(0,f.h)({url:"/ws/global-state",enabled:!!a,onMessage:b=>{j.current||!a||"project-state-changed"===b.type&&b.cwd===a&&F(b.closedSessionIds??[])}});let G=(0,d.useCallback)((a,b,c,d)=>{let{engine:e,ollamaModel:f,deepseekModel:g,kimiModel:h,glmModel:i,claudeModel:j,claudeEffort:k,claudeContextWindow:l,claudeFastMode:m,claudeThinking:n,codexModel:o,codexReasoningEffort:p,planMode:q,noHistory:r,appendToEnd:v=!1}=d??{},w={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat"),engine:e,ollamaModel:f,deepseekModel:g,kimiModel:h,glmModel:i,claudeModel:j,claudeEffort:k,claudeContextWindow:l,claudeFastMode:m,claudeThinking:n,codexModel:o,codexReasoningEffort:p,planMode:q,noHistory:r};s(a=>{if(v)return[...a,w];let b=a.findIndex(a=>a.id===t);if(-1===b)return[...a,w];let c=[...a];return c.splice(b+1,0,w),c}),u(w.id)},[t]),H=(0,d.useCallback)(b=>{let c=x.current.find(a=>a.id===b);c?.sessionId&&z.current.add(c.sessionId),s(c=>{let d=c.filter(a=>a.id!==b);if(b===t&&d.length>0&&u(d[d.length-1].id),0===d.length){let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};return u(b.id),[b]}return d})},[t,a]),I=(0,d.useCallback)(()=>{x.current.forEach(a=>{a.sessionId&&z.current.add(a.sessionId)});let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};u(b.id),s([b])},[a]),J=(0,d.useCallback)((b,c)=>{let d=r.find(a=>a.sessionId===b);d?u(d.id):a?h.t4.runPromise((0,i.n8)(a).pipe(g.catchAll(()=>g.succeed(null)))).then(d=>{let e=x.current.find(a=>a.sessionId===b);e?u(e.id):G(a,b,c,{engine:d?.engines?.[b],ollamaModel:d?.ollamaModels?.[b],deepseekModel:d?.deepseekModels?.[b],kimiModel:d?.kimiModels?.[b],glmModel:d?.glmModels?.[b],claudeModel:d?.claudeModels?.[b],claudeEffort:d?.claudeEfforts?.[b],claudeContextWindow:d?.claudeContextWindows?.[b],claudeFastMode:d?.claudeFastModes?.[b],claudeThinking:d?.claudeThinkings?.[b],codexModel:d?.codexModels?.[b],codexReasoningEffort:d?.codexReasoningEfforts?.[b],planMode:d?.planModes?.[b],noHistory:d?.noHistories?.[b],appendToEnd:!0})}):G(a,b,c,{appendToEnd:!0})},[r,a,G]),K=(0,d.useCallback)(()=>{G(a,void 0,void 0,{appendToEnd:!0})},[a,G]),L=(0,d.useCallback)(()=>{G(a,void 0,"New Codex Chat",{engine:"codex",appendToEnd:!0})},[a,G]),M=(0,d.useCallback)(()=>{G(a,void 0,"New Kimi Chat",{engine:"kimi",kimiModel:"k3",appendToEnd:!0})},[a,G]),N=(0,d.useCallback)(()=>{G(a,void 0,"New GLM Chat",{engine:"glm",glmModel:"glm-5.3",appendToEnd:!0})},[a,G]),O=(0,d.useCallback)(b=>{G(a,void 0,b?`New Ollama (${b})`:"New Ollama Chat",{engine:"ollama",ollamaModel:b,appendToEnd:!0})},[a,G]),P=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a&&c.engine!==b?{...c,engine:b}:c))},[]),Q=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,ollamaModel:b}:c))},[]),R=(0,d.useCallback)(()=>{G(a,void 0,"New DeepSeek Chat",{engine:"deepseek",deepseekModel:"deepseek-v4-flash",appendToEnd:!0})},[a,G]),S=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,deepseekModel:b}:c))},[]),T=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,kimiModel:b}:c))},[]),U=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,glmModel:b}:c))},[]),V=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeModel:b}:c))},[]),W=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeEffort:b}:c))},[]),X=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeContextWindow:b}:c))},[]),Y=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeFastMode:b}:c))},[]),Z=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeThinking:b}:c))},[]),$=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,codexModel:b}:c))},[]),_=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,codexReasoningEffort:b}:c))},[]),aa=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,planMode:b}:c))},[]),ab=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,noHistory:b}:c))},[]),ac=(0,d.useCallback)((b,c)=>{let d=x.current.find(a=>a.id===y.current);G(a,b,c,{engine:d?.engine,ollamaModel:d?.ollamaModel,deepseekModel:d?.deepseekModel,kimiModel:d?.kimiModel,glmModel:d?.glmModel,claudeModel:d?.claudeModel,claudeEffort:d?.claudeEffort,claudeContextWindow:d?.claudeContextWindow,claudeFastMode:d?.claudeFastMode,claudeThinking:d?.claudeThinking,codexModel:d?.codexModel,codexReasoningEffort:d?.codexReasoningEffort})},[a,G]),ad=(0,d.useCallback)((a,b)=>{s(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!o.current||"agent"===o.current;if(a===t&&c&&q.current){let a=d.sessionId||b.sessionId;a&&A(a,"normal")}else w(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[t,A]),ae=(0,d.useCallback)(a=>{u(a),w(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=x.current.find(b=>b.id===a);return d?.sessionId&&(A(d.sessionId,"normal"),h.t4.runFork((0,i.M2)(d.sessionId).pipe(g.catchAll(()=>g.void)))),c})},[A]),af=(0,d.useCallback)(a=>{C(a)},[]),ag=(0,d.useCallback)((a,b)=>{a.preventDefault(),null!==B&&B!==b&&E(b)},[B]),ah=(0,d.useCallback)(a=>{null!==B&&B!==a&&s(b=>{let c=[...b],[d]=c.splice(B,1);return c.splice(a,0,d),c}),C(null),E(null)},[B]),ai=(0,d.useCallback)(()=>{C(null),E(null)},[]),aj=r.find(a=>a.id===t);return{tabs:r,activeTabId:t,activeTab:aj,unreadTabs:v,dragTabIndex:B,dragOverTabIndex:D,addTab:G,closeTab:H,closeAllTabs:I,switchTab:ae,handleSelectSession:J,handleNewTab:K,handleNewCodexTab:L,handleNewKimiTab:M,handleNewGlmTab:N,handleNewOllamaTab:O,handleNewDeepseekTab:R,handleOpenSession:ac,updateTabState:ad,updateTabEngine:P,updateTabOllamaModel:Q,updateTabDeepseekModel:S,updateTabKimiModel:T,updateTabGlmModel:U,updateTabClaudeModel:V,updateTabClaudeEffort:W,updateTabClaudeContextWindow:X,updateTabClaudeFastMode:Y,updateTabClaudeThinking:Z,updateTabCodexModel:$,updateTabCodexReasoningEffort:_,updateTabPlanMode:aa,updateTabNoHistory:ab,handleTabDragStart:af,handleTabDragOver:ag,handleTabDrop:ah,handleTabDragEnd:ai}}},37202:(a,b,c)=>{"use strict";c.d(b,{M:()=>n,O:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(74429),h=c(74228);let i=[],j=[];function k(){j.forEach(a=>a())}function l(a){let b=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;i=[...i,{...a,id:b}],k()}function m(a){i=i.filter(b=>b.id!==a),k()}function n({onNavigate:a}){let b=function(){let[,a]=(0,e.useState)(0);return i}();return 0===b.length?null:(0,g.createPortal)((0,d.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:b.map(b=>(0,d.jsx)(o,{item:b,onNavigate:a,onRemove:m},b.id))}),document.body)}function o({item:a,onNavigate:b,onRemove:c}){let{t:g}=(0,f.Bd)(),[i,j]=(0,e.useState)(!1),k=(0,e.useRef)(void 0),l=(0,e.useCallback)(()=>{j(!0),setTimeout(()=>c(a.id),300)},[a.id,c]),m=(0,e.useCallback)(()=>{clearTimeout(k.current),b(a.cwd,a.sessionId),c(a.id)},[a,b,c]),n=(0,e.useCallback)(()=>{clearTimeout(k.current)},[]),p=(0,e.useCallback)(()=>{k.current=setTimeout(l,2e3)},[l]);return(0,d.jsxs)("div",{className:`group pointer-events-auto relative bg-popover border border-border rounded-lg shadow-lv3 px-3 py-3 min-h-[84px] min-w-[260px] max-w-[340px] cursor-pointer transition-all ${i?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:i?void 0:"slideInLeft 0.3s ease-out"},onClick:m,onMouseEnter:n,onMouseLeave:p,children:[(0,d.jsx)("div",{className:"pointer-events-none absolute inset-0 rounded-lg bg-hover opacity-0 group-hover:opacity-100 transition-opacity"}),(0,d.jsxs)("div",{className:"relative flex items-start gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-green-9 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.projectName}),(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:g("common.done")}),(0,d.jsx)(h.l,{projectNumber:a.projectNumber,sessionNumber:a.sessionNumber,className:"ml-auto"}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.message&&(0,d.jsx)("div",{className:"relative text-xs text-muted-foreground line-clamp-2 break-words mt-1 ml-6",children:a.message})]})}},37388:(a,b,c)=>{"use strict";c.d(b,{KJ:()=>h,M2:()=>i,ej:()=>g,n8:()=>f});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(`/api/project-state?cwd=${encodeURIComponent(a)}`);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"loadProjectState failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/project-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"saveProjectState failed",cause:a})}),h=(a,b,c)=>d.tryPromise({try:async()=>{let d=await fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c})});if(!d.ok)throw Error(`HTTP ${d.status}`)},catch:a=>new e.uV({message:"updateSessionStatus failed",cause:a})}),i=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markReadBySessionId",fields:{sessionId:a}})});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"markScheduledTasksReadBySession failed",cause:a})})},37690:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(67484);function e({enabled:a,container:b,resolveLineRange:c,buildLineSnapshot:f,dragThresholdPx:g=5}){let h=(0,d.useRef)(null),i=(0,d.useRef)(()=>{}),j=(0,d.useRef)(c),k=(0,d.useRef)(f),l=(0,d.useRef)(g);return j.current=c,k.current=f,l.current=g,{toolbarRef:h,bumpRef:i,clearToolbar:()=>{h.current&&(h.current=null,i.current())}}}},37701:(a,b,c)=>{"use strict";c.d(b,{Fe:()=>d,Ff:()=>h,Z8:()=>g,wL:()=>e});let d=a=>a?.toLowerCase().startsWith("zh")?"zh":"en",e=(a,b)=>{if(!a||"object"!=typeof a)return null;let c=a.quickReplies;return c&&"object"==typeof c?(a=>{if(!Array.isArray(a))return null;let b=[];for(let c of a.slice(0,12)){if(!Array.isArray(c))continue;let a=[];for(let b of c.slice(0,8)){if("string"!=typeof b)continue;let c=b.trim().slice(0,200);c&&a.push(c)}a.length&&b.push(a)}return b.length?b:null})(c[b]):null},f=/[,,]/,g=a=>a.split("\n").map(a=>a.split(f).map(a=>a.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(a=>a.length>0).slice(0,12),h=(a,b)=>a.map(a=>a.join("zh"===b?",":", ")).join("\n")},38878:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManagerTopBar:()=>u});var e=c(48249),f=c(67484),g=c(94192),h=c(12568),i=c(7833),j=c(44384),k=c(57031),l=c(88214),m=c(79606),n=c(33281),o=c(85655),p=c(35606),q=c(65484);function r({className:a}){return(0,e.jsxs)("svg",{className:a,fill:"none",viewBox:"0 0 100 100","aria-hidden":"true",children:[(0,e.jsx)("path",{fill:"#0065A9",d:"M96.461 10.796 75.857.876a6.23 6.23 0 0 0-7.107 1.207l-67.451 61.5a4.167 4.167 0 0 0 .004 6.162l5.51 5.009a4.167 4.167 0 0 0 5.32.236l81.228-61.62c2.725-2.067 6.639-.124 6.639 3.297v-.24a6.25 6.25 0 0 0-3.539-5.63Z"}),(0,e.jsx)("path",{fill:"#007ACC",d:"m96.461 89.204-20.604 9.92a6.229 6.229 0 0 1-7.107-1.207l-67.451-61.5a4.167 4.167 0 0 1 .004-6.162l5.51-5.009a4.167 4.167 0 0 1 5.32-.236l81.228 61.62c2.725 2.067 6.639.124 6.639-3.297v.24a6.25 6.25 0 0 0-3.539 5.63Z"}),(0,e.jsx)("path",{fill:"#1F9CF0",d:"M75.858 99.126a6.232 6.232 0 0 1-7.108-1.21c2.306 2.307 6.25.674 6.25-2.588V4.672c0-3.262-3.944-4.895-6.25-2.589a6.232 6.232 0 0 1 7.108-1.21l20.6 9.908A6.25 6.25 0 0 1 100 16.413v67.174a6.25 6.25 0 0 1-3.541 5.633l-20.601 9.906Z"})]})}function s({className:a}){return(0,e.jsx)("svg",{className:a,viewBox:"0 0 466.73 532.09",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"})})}function t({cwd:a,currentBranch:b,onSwitched:c}){let{t:d}=(0,j.Bd)(),[g,h]=(0,f.useState)(!1),[k,l]=(0,f.useState)([]),[m,p]=(0,f.useState)(!1),[r,s]=(0,f.useState)(!1),[u,v]=(0,f.useState)(""),w=(0,f.useRef)(null),x=(0,f.useRef)(null),y=(0,f.useCallback)(async()=>{p(!0);let b=await n.t4.runPromiseExit((0,o.r4)(a));if("Success"===b._tag){let a=b.value,c=a.local??[],d=a.remote??[],e=[...c,...d.filter(a=>!c.includes(a.replace(/^origin\//,"")))];l(e)}else(0,i.oR)(d("toast.loadBranchFailed"),"error");p(!1)},[a,d]),z=(0,f.useCallback)(()=>{h(!0),v(""),y()},[y]),A=(0,f.useCallback)(()=>{h(!1)},[]),B=async b=>{s(!0);let e=await n.t4.runPromiseExit((0,q.Kl)({action:"checkout",cwd:a,path:a,branch:b}));if("Success"===e._tag){let a=b.replace(/^origin\//,"");(0,i.oR)(d("toast.switchedToBranch",{branch:a}),"success"),A(),c()}else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:d("toast.switchBranchFailed");(0,i.oR)(c,"error")}s(!1)},C=k.filter(a=>a!==b&&a.toLowerCase().includes(u.toLowerCase()));return(0,e.jsxs)("div",{className:"relative",ref:w,children:[(0,e.jsx)("button",{onClick:g?A:z,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:d("git.switchBranch"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),g&&(0,e.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lv2 z-50 overflow-hidden",children:[(0,e.jsx)("div",{className:"p-2 border-b border-border",children:(0,e.jsx)("input",{ref:x,type:"text",value:u,onChange:a=>v(a.target.value),placeholder:d("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none",onKeyDown:a=>{"Escape"===a.key&&A()}})}),(0,e.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:m?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("common.loading")}):0===C.length?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:u?d("git.noMatchingBranches"):d("git.noBranches")}):C.map(a=>(0,e.jsx)("button",{onClick:()=>B(a),disabled:r,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-hover transition-colors truncate disabled:opacity-50",children:(0,e.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function u({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:d,onOpenWorktree:f,onOpenAliasManager:o,onBranchSwitched:v}){let{t:w}=(0,j.Bd)(),x=b?.sessionId?(0,p.X)(b.engine,b.sessionId):null;return(0,e.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:w("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,i.oR)(w("toast.copiedPageUrl"),"success")})}}),a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${a}`,children:a}),(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(w("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:w("tabManagerTopBar.copyDirPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}):(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsxs)("button",{onClick:f,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:"Git Worktrees",children:[(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,e.jsx)("span",{className:"text-sm",children:d||"main"})]}),(0,e.jsx)(t,{cwd:a,currentBranch:d,onSwitched:()=>v?.()})]})]}),(0,e.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,e.jsx)(g.gT,{})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(h.ReviewDropdown,{cwd:a}),(0,e.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.refreshProject"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,q.em)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openInVSCode"),children:(0,e.jsx)(r,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,q.Q1)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openInCursor"),children:(0,e.jsx)(s,{className:"w-4 h-4"})}),x&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(x).then(()=>{(0,i.oR)(w("toast.copiedCommand",{command:x}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("chat.copyCommandTooltip",{command:x}),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.aliasesGlobal"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,e.jsx)("button",{onClick:()=>(0,k.F)(l.n.OpenTokenStats,{}),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.tokenStats"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,e.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openSurething"),children:(0,e.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}d()}catch(a){d(a)}})},38896:(a,b,c)=>{"use strict";c.d(b,{C:()=>f});var d=c(67484),e=c(36984);function f(a,b){let[c,f]=(0,d.useState)(null),[g,h]=(0,d.useState)(!1),i=(0,d.useMemo)(()=>a.join("\n"),[a]),j=`${i}:${b}:${g}`;return(0,d.useMemo)(()=>c&&c.key===j?c.html:a.map(a=>(0,e.ZD)(a||" ")),[a,j,c])}},39031:(a,b,c)=>{"use strict";c.d(b,{IS:()=>h});var d=c(32891),e=c(10259),f=c(87748);let g=new Set(["taskItem","listItem"]),h=d.YY.create({name:"dropShellCleanup",addProseMirrorPlugins:()=>[new e.k_({key:new e.hs("dropShellCleanup"),appendTransaction(a,b,c){let d=[];if(a.forEach((b,c)=>{let e;if("drop"!==b.getMeta("uiEvent")||!b.docChanged)return;let g=(e=[],b.steps.forEach((a,c)=>{a instanceof f.Ln&&(0!==a.slice.size||a.from>=a.to||e.push(b.mapping.slice(c+1).map(a.from)))}),e);for(let b=c+1;b<a.length;b++)g=g.map(c=>a[b].mapping.map(c));d.push(...g)}),0===d.length)return null;let e=c.tr,h=!1;for(let a of d){let b=function(a,b){if(b<0||b>a.content.size)return null;let c=a.resolve(b);for(let a=c.depth;a>0;a--){var d;if(d=c.node(a),!g.has(d.type.name)||1!==d.childCount||null===d.firstChild||!d.firstChild.isTextblock||0!==d.firstChild.content.size)continue;let b=a;for(;b>1&&1===c.node(b-1).childCount;)b--;return{from:c.before(b),to:c.after(b)}}return null}(e.doc,e.mapping.map(a));if(b)try{e.delete(b.from,b.to),h=!0}catch{}}return h?e:null}})]})},39238:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{N:()=>r});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(64825),k=c(66400),l=c(86588),m=c(64676),n=c(40893),o=c(6478),p=c(48587),q=a([p]);function r({filePath:a,content:b,cwd:c,onClose:d,onContentSearch:q}){let{t:s}=(0,g.Bd)(),t=(0,o.P)(),[u,v]=(0,f.useState)("preview");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-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":a,onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(s("common.copiedPath"))},children:["",a]}),(0,e.jsx)("button",{onClick:()=>v(a=>"preview"===a?"source":"preview"),className:`px-1.5 py-0.5 text-xs rounded transition-colors flex-shrink-0 ${"preview"===u?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:"preview"===u?s("fileBrowser.exitPreview"):s("common.preview")}),(0,e.jsx)("button",{onClick:()=>t(a),title:s("htmlApps.addTooltip"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),d()},title:s("common.openInConsole"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{let b=(0,m.Xe)(a,c);window.open((0,m.PB)(b,window.location.origin),"_blank")},title:s("browser.openInNewWindow"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(l.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:"preview"===u?(0,e.jsx)(n.O,{content:b,filePath:a,cwd:c,onContentSearch:q?a=>{q(a),d()}:void 0}):(0,e.jsx)(p.y,{entryPath:a,entryContent:b,cwd:c})})]})})})}p=(q.then?(await q)():q)[0],d()}catch(a){d(a)}})},39247:(a,b,c)=>{"use strict";c.d(b,{h:()=>e});let d=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),e=a=>!d.has(a)},40159:(a,b,c)=>{"use strict";c.d(b,{S:()=>l,j:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(44256),i=c(89719);function j({blame:a,onClick:b}){let{t:c}=(0,f.Bd)(),i=(0,e.useRef)(null),k=(0,e.useRef)(null),l=(0,h.F2)(),m=(0,e.useRef)(!1),n=(0,e.useRef)(!1),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=(0,e.useRef)(null),r=(0,e.useRef)(a),s=(0,e.useRef)(b),t=(0,e.useCallback)(()=>{let a,b=k.current,c=i.current;if(!b||!c)return;let d=c.getBoundingClientRect(),e=b.getBoundingClientRect(),f=l?.getBoundingClientRect(),g=f?.left??0,h=f?.top??0,j=f?.width??window.innerWidth,m=f?.height??window.innerHeight,n=d.left-g;n+e.width>j-8&&(n=j-e.width-8),n<8&&(n=8);let o=d.top-h,p=d.bottom-h;(a=o-e.height-4<0?p+4:o-e.height-4)+e.height>m-8&&(a=m-e.height-8),b.style.left=`${n}px`,b.style.top=`${a}px`},[l]),u=(0,e.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),p.current&&(clearTimeout(p.current),p.current=null),m.current=!1,n.current=!1,k.current&&(k.current.style.display="none"),q.current&&(document.removeEventListener("mousedown",q.current.down),document.removeEventListener("mouseup",q.current.up),q.current=null)},[]),v=(0,e.useCallback)(()=>{let a=k.current;if(!a||m.current)return;m.current=!0,a.style.left="-9999px",a.style.top="-9999px",a.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(t));let b=0,c=0,d=a=>{b=a.clientX,c=a.clientY},e=a=>{if(!(Math.abs(a.clientX-b)>5||Math.abs(a.clientY-c)>5)){let b;b=a.target,k.current?.contains(b)||i.current?.contains(b)||u()}};document.addEventListener("mousedown",d),document.addEventListener("mouseup",e),q.current={down:d,up:e}},[t,u]),w=(0,e.useCallback)(()=>{if(o.current&&clearTimeout(o.current),p.current&&(clearTimeout(p.current),p.current=null),m.current)return;let a=window.getSelection();(!a||a.isCollapsed)&&(o.current=setTimeout(v,500))},[v]),x=(0,e.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),m.current&&(p.current=setTimeout(()=>{n.current||u()},200))},[u]),y=(0,e.useCallback)(()=>{n.current=!0,p.current&&(clearTimeout(p.current),p.current=null)},[]),z=(0,e.useCallback)(()=>{n.current=!1,u()},[u]),A=(0,e.useCallback)(a=>{a.stopPropagation();let b=window.getSelection();b&&b.toString().length>0&&k.current?.contains(b.anchorNode)||(s.current?.(r.current),u())},[u]),B=a.message.split("\n")[0]||"",C=a.message.split("\n").slice(1).join("\n").trim();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{ref:i,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:w,onMouseLeave:x,children:[a.author.split(" ")[0],", ",function(a){let b=g.A.t,c=Math.floor((Date.now()-1e3*a)/1e3);if(c<60)return b("common.justNow");let d=Math.floor(c/60);if(d<60)return b("common.minutesAgo",{count:d});let e=Math.floor(d/60);if(e<24)return b("common.hoursAgo",{count:e});let f=Math.floor(e/24);if(f<30)return b("common.daysAgo",{count:f});let h=Math.floor(f/30);return h<12?b("common.monthsAgo",{count:h}):b("common.yearsAgo",{count:Math.floor(h/12)})}(a.time)," \xb7 ",B]}),(0,d.jsx)(h.ZL,{children:(0,d.jsxs)("div",{ref:k,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-lv3 p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:y,onMouseLeave:z,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,d.jsx)("span",{className:"font-mono text-brand",children:a.hash}),(0,d.jsx)("span",{className:"text-muted-foreground",children:a.author}),(0,d.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*a.time).toLocaleString()})]}),(0,d.jsx)("div",{className:"font-medium",children:B}),C&&(0,d.jsx)("div",{className:"mt-1 text-muted-foreground",children:C}),(0,d.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:A,children:c("codeViewer.clickToViewDetails")})]})})]})}let k=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}],l=(0,e.memo)(function({virtualKey:a,lineNum:b,highlightedHtml:c,hasComments:g,firstComment:h,lineCommentsCount:k,isInRange:l,showLineNumbers:m,lineNumChars:n,commentsEnabled:o,virtualItemSize:p,virtualItemStart:q,onCommentBubbleClick:r,onCmdClick:s,onTokenHover:t,onTokenHoverLeave:u,flashLine:v,blameLine:w,showBlameInfo:x,blameAuthorColor:y,isBlameHovered:z,onBlameClick:A,onBlameMouseEnter:B,onBlameMouseLeave:C,inlineBlameData:D,onInlineBlameClick:E,isCursorLine:F,cursorCol:G}){let{t:H}=(0,f.Bd)(),I=(0,e.useMemo)(()=>F&&null!=G?function(a,b){let c=0,d=0;for(;d<a.length;){if("<"===a[d]){let b=a.indexOf(">",d);if(-1!==b){d=b+1;continue}}if(c===b){let b;if("&"===a[d]){let c=a.indexOf(";",d);b=-1!==c&&c-d<10?c+1:d+1}else b=d+1;let c=a.substring(d,b);return a.substring(0,d)+'<span class="vi-char-cursor">'+c+"</span>"+a.substring(b)}if("&"===a[d]){let b=a.indexOf(";",d);d=-1!==b&&b-d<10?b+1:d+1}else d++;c++}return a+'<span class="vi-char-cursor"> </span>'}(c,G):c,[c,F,G]),J=(0,e.useCallback)(a=>{if(!a.metaKey||!s)return;a.preventDefault(),a.stopPropagation();let c=a.currentTarget,d=(0,i.j)(a,c);window.getSelection()?.removeAllRanges(),s(b,d)},[b,s]),K=(0,e.useCallback)(a=>{if(!t)return;let c=(0,i.A)(a,a.currentTarget);c&&t(b,c.column,c.rect)},[b,t]),L=(0,e.useCallback)(()=>{w&&A&&A(w)},[w,A]),M=(0,e.useCallback)(a=>{w&&B&&B(w,a)},[w,B]);return(0,d.jsxs)("div",{"data-line":b,style:{position:"absolute",top:0,left:0,width:"100%",height:`${p}px`,transform:`translateY(${q}px)`,backgroundColor:z&&y?y.bg:void 0},className:`flex ${v===b?"flash-line":""} ${F?"vi-cursor-line":""} ${l?"bg-blue-9/20":g?"bg-amber-9/10":"hover:bg-hover"}`,children:[(0,d.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-card",style:{backgroundImage:z&&y?`linear-gradient(${y.bg}, ${y.bg})`:void 0},children:[w&&y&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,d.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-hover",onMouseEnter:M,onMouseLeave:C,onClick:L,title:H("codeViewer.clickToViewCommit"),children:x?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"font-medium",style:{color:y.border},children:w.hash}),(0,d.jsx)("span",{className:"truncate flex-1",children:w.author.split(" ")[0]})]}):null})]}),m&&(0,d.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${l?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[o&&g&&h&&(0,d.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:H("codeViewer.nComments",{count:k}),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.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&&!g&&(0,d.jsx)("span",{className:"w-4"}),(0,d.jsx)("span",{className:"text-right",style:{minWidth:`${n}ch`},children:b})]})]}),(0,d.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:J,onMouseOver:K,onMouseLeave:u,"data-code-content":!0,children:[(0,d.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),D&&(0,d.jsx)(j,{blame:D,onClick:E})]})]},a)})},40311:(a,b,c)=>{"use strict";function d(a,b){return"loading"===a?"border-transparent bg-orange-11/20 text-foreground animate-pulse":"unread"===a?"border-transparent bg-red-9/55 text-foreground":b?"border-transparent bg-brand/15 text-brand":"border-transparent bg-muted-foreground/15 text-muted-foreground"}c.d(b,{c:()=>d})},40699:(a,b,c)=>{"use strict";c.d(b,{u:()=>h});var d=c(67484),e=c(29939),f=c(85943),g=c(25414);function h(a,b,c,h,i){let j=(0,d.useRef)(null),k=(0,d.useRef)(0),l=(0,d.useRef)(0),m=(0,d.useRef)(!1),n=(0,d.useRef)(!1),o=(0,d.useRef)(!1),p=(0,d.useRef)(void 0),q=()=>{let a=`live-asst-${++k.current}`;return j.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",isStreaming:!0,runId:p.current}]),a},r=a=>{let c=a=>{i?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(a))})},d=a=>{!m.current&&"string"==typeof a&&a&&(l.current+=(0,f.r)(a),c(l.current))};if("system"===a.type&&"init"===a.subtype){let a=n.current;o.current=!0,a||(l.current=0,m.current=!1,i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(Date.now())),q();return}if("usage_update"===a.type){"number"==typeof a.output_tokens&&Number.isFinite(a.output_tokens)&&(m.current=!0,l.current=Math.max(l.current,Math.round(a.output_tokens)),c(l.current));return}if("stream_event"===a.type){let b=a.event;b?.type==="content_block_delta"&&b.delta?.type==="text_delta"&&d(b.delta.text)}if("system"===a.type&&"task_notification"===a.subtype){if(!o.current){let c=`live-tasknotif-${a.task_id||++k.current}`,d=`<task-notification>
|
|
20
|
+
${a}`:a}),requestAnimationFrame(()=>{let a=z.current;a&&(a.focus(),a.setSelectionRange(a.value.length,a.value.length))})},[]),H=(0,e.useCallback)(a=>{a.nativeEvent.isComposing||!D.handleKeyDown(a)&&("Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),E()))},[D,E]),I=(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(o("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};s(a=>[...a,e])},e.readAsDataURL(c)}}},[o]),J=(0,e.useCallback)(a=>{s(b=>b.filter(b=>b.id!==a))},[]);return(0,d.jsxs)("div",{className:"border-t border-border bg-card relative",children:[(0,d.jsx)(j,{images:r,onRemove:J,disabled:b}),(0,d.jsx)(x.V,{ac:D,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:[h&&(0,d.jsx)("button",{onClick:h,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:o("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"})]})}),i&&(0,d.jsx)("button",{onClick:i,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:o("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"})})}),l&&(0,d.jsx)("button",{onClick:l,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:o("chat.userMessages"),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:"M4 6h16M4 12h16M4 18h16"})})}),m&&(0,d.jsx)("button",{onClick:m,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 rounded-lg transition-all",title:o("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"})})}),n&&(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("button",{onClick:()=>u(!t),className:`p-2 rounded-lg transition-all ${t?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:o("chat.scheduledTasks"),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:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]})}),t&&(0,d.jsx)(k.E,{onClose:()=>u(!1),onCreate:n})]}),(0,d.jsxs)("div",{className:"relative",ref:A,children:[(0,d.jsx)("button",{onClick:()=>y(!v),className:`p-2 rounded-lg transition-all ${v?"text-brand bg-brand/10":"text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95"}`,title:o("chat.quickPrompts"),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:"M13 10V3L4 14h7v7l9-11h-7z"})})}),v&&(0,d.jsx)(w,{cwd:c,anchorRef:A,onClose:()=>y(!1),onSelect:F,onInsert:G})]}),(0,d.jsx)("textarea",{ref:z,value:p,onChange:a=>{q(a.target.value),D.trackCaret(a.target)},onSelect:a=>D.trackCaret(a.currentTarget),onKeyDown:H,onPaste:I,placeholder:b?o("chat.placeholderDisabled"):o("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"})]})]})})},36984:(a,b,c)=>{"use strict";c.d(b,{Np:()=>k,ZD:()=>h,ZR:()=>i,b8:()=>j,kS:()=>f,sQ:()=>g});let d=null,e=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function f(){return d||(d=Promise.resolve().then(c.bind(c,78908)).then(({createHighlighter:a})=>a({themes:["github-dark","github-light"],langs:[...e]}))),d}function g(a){let b=a.split("/").pop()?.toLowerCase()||"",c=b.split(".").pop()?.toLowerCase();if(".env"===b||b.startsWith(".env.")||"dockerfile"===b||b.startsWith("dockerfile.")||"makefile"===b)return"bash";let d={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[c||""]||"text";return e.includes(d)?d:"text"}function h(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let i=2e3;function j(a){return a.length>i?h(a.map(a=>a.content).join("")):a.map(a=>a.color?`<span style="color:${a.color}">${h(a.content)}</span>`:h(a.content)).join("")}function k(a,b,c,d){if(!b)return[];let e=[],f=c?b:b.toLowerCase();for(let b=0;b<a.length;b++){let g=c?a[b]:a[b].toLowerCase(),h=0;for(;;){let a=g.indexOf(f,h);if(-1===a)break;let c=a+f.length;if(d){let d=a>0?g[a-1]:" ",f=c<g.length?g[c]:" ",h=!/\w/.test(d),i=!/\w/.test(f);h&&i&&e.push({lineIndex:b,startCol:a,endCol:c})}else e.push({lineIndex:b,startCol:a,endCol:c});h=a+1}}return e}},37129:(a,b,c)=>{"use strict";c.d(b,{useTabState:()=>l});var d=c(67484),e=c(23860),f=c(29939);c(57031),c(88214);var g=c(79606),h=c(33281),i=c(37388);let j=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\.jsonl)?$/i;function k(a){let b=a.match(j);return b?.[1]??a}function l({initialCwd:a,initialSessionId:b,activeView:c}){(0,d.useRef)(!1);let j=(0,d.useRef)(!0),[m,n]=(0,d.useState)(!1);(0,d.useCallback)(()=>{j.current=!1,n(!0)},[]);let o=(0,d.useRef)(c),p=(0,e.F)(),q=(0,d.useRef)(p),[r,s]=(0,d.useState)(()=>[{id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:b?`Session ${b.slice(0,6)}...`:"New Chat"}]),[t,u]=(0,d.useState)(r[0]?.id??""),[v,w]=(0,d.useState)(new Set),x=(0,d.useRef)(r),y=(0,d.useRef)(t),z=(0,d.useRef)(new Set),A=(0,d.useCallback)((b,c)=>{a&&b&&h.t4.runFork((0,i.KJ)(a,b,c).pipe(g.catchAll(()=>g.void)))},[a]),[B,C]=(0,d.useState)(null),[D,E]=(0,d.useState)(null),F=(0,d.useCallback)(b=>{a&&h.t4.runPromise((0,i.n8)(a).pipe(g.catchAll(()=>g.succeed(null)))).then(c=>{if(!c)return;let d=c.engines||{},e={};for(let[a,b]of Object.entries(d))e["codex"===b?k(a):a]=b;let f=[];for(let a of c.sessions||[]){let b="codex"===d[a]?k(a):a;f.includes(b)||f.push(b)}let g=c.ollamaModels||{},h=c.deepseekModels||{},i=c.kimiModels||{},j=c.glmModels||{},l=c.claudeModels||{},m=c.claudeEfforts||{},n=c.claudeContextWindows||{},o=c.claudeFastModes||{},p=c.claudeThinkings||{},q=c.codexModels||{},r=c.codexReasoningEfforts||{},t=c.planModes||{},v=c.noHistories||{},w=x.current,z=new Set(b),A=w.filter(a=>!a.sessionId||!z.has(a.sessionId)),B=new Set(A.map(a=>a.sessionId).filter(Boolean)),C=f.filter(a=>!B.has(a));if(A.length===w.length&&0===C.length)return;let D=[...A,...C.map((b,c)=>({id:`tab-${Date.now()}-sync-${c}`,cwd:a,sessionId:b,title:`Session ${b.slice(0,6)}...`,engine:e[b]||void 0,ollamaModel:g[b]||void 0,deepseekModel:h[b]||void 0,kimiModel:i[b]||void 0,glmModel:j[b]||void 0,claudeModel:l[b]||void 0,claudeEffort:m[b]||void 0,claudeContextWindow:n[b]||void 0,claudeFastMode:o[b]??void 0,claudeThinking:p[b]??void 0,codexModel:q[b]||void 0,codexReasoningEffort:r[b]||void 0,planMode:t[b]||void 0,noHistory:v[b]||void 0}))];0===D.length&&(D=[{id:`tab-${Date.now()}`,cwd:a,title:"New Chat"}]),s(D),D.some(a=>a.id===y.current)||u(D[D.length-1].id)})},[a]);(0,f.h)({url:"/ws/global-state",enabled:!!a,onMessage:b=>{j.current||!a||"project-state-changed"===b.type&&b.cwd===a&&F(b.closedSessionIds??[])}});let G=(0,d.useCallback)((a,b,c,d)=>{let{engine:e,ollamaModel:f,deepseekModel:g,kimiModel:h,glmModel:i,claudeModel:j,claudeEffort:k,claudeContextWindow:l,claudeFastMode:m,claudeThinking:n,codexModel:o,codexReasoningEffort:p,planMode:q,noHistory:r,appendToEnd:v=!1}=d??{},w={id:`tab-${Date.now()}`,cwd:a,sessionId:b,title:c||(b?`Session ${b.slice(0,6)}...`:"New Chat"),engine:e,ollamaModel:f,deepseekModel:g,kimiModel:h,glmModel:i,claudeModel:j,claudeEffort:k,claudeContextWindow:l,claudeFastMode:m,claudeThinking:n,codexModel:o,codexReasoningEffort:p,planMode:q,noHistory:r};s(a=>{if(v)return[...a,w];let b=a.findIndex(a=>a.id===t);if(-1===b)return[...a,w];let c=[...a];return c.splice(b+1,0,w),c}),u(w.id)},[t]),H=(0,d.useCallback)(b=>{let c=x.current.find(a=>a.id===b);c?.sessionId&&z.current.add(c.sessionId),s(c=>{let d=c.filter(a=>a.id!==b);if(b===t&&d.length>0&&u(d[d.length-1].id),0===d.length){let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};return u(b.id),[b]}return d})},[t,a]),I=(0,d.useCallback)(()=>{x.current.forEach(a=>{a.sessionId&&z.current.add(a.sessionId)});let b={id:`tab-${Date.now()}`,cwd:a,title:"New Chat"};u(b.id),s([b])},[a]),J=(0,d.useCallback)((b,c)=>{let d=r.find(a=>a.sessionId===b);d?u(d.id):a?h.t4.runPromise((0,i.n8)(a).pipe(g.catchAll(()=>g.succeed(null)))).then(d=>{let e=x.current.find(a=>a.sessionId===b);e?u(e.id):G(a,b,c,{engine:d?.engines?.[b],ollamaModel:d?.ollamaModels?.[b],deepseekModel:d?.deepseekModels?.[b],kimiModel:d?.kimiModels?.[b],glmModel:d?.glmModels?.[b],claudeModel:d?.claudeModels?.[b],claudeEffort:d?.claudeEfforts?.[b],claudeContextWindow:d?.claudeContextWindows?.[b],claudeFastMode:d?.claudeFastModes?.[b],claudeThinking:d?.claudeThinkings?.[b],codexModel:d?.codexModels?.[b],codexReasoningEffort:d?.codexReasoningEfforts?.[b],planMode:d?.planModes?.[b],noHistory:d?.noHistories?.[b],appendToEnd:!0})}):G(a,b,c,{appendToEnd:!0})},[r,a,G]),K=(0,d.useCallback)(()=>{G(a,void 0,void 0,{appendToEnd:!0})},[a,G]),L=(0,d.useCallback)(()=>{G(a,void 0,"New Codex Chat",{engine:"codex",appendToEnd:!0})},[a,G]),M=(0,d.useCallback)(()=>{G(a,void 0,"New Kimi Chat",{engine:"kimi",kimiModel:"k3",appendToEnd:!0})},[a,G]),N=(0,d.useCallback)(()=>{G(a,void 0,"New GLM Chat",{engine:"glm",glmModel:"glm-5.3",appendToEnd:!0})},[a,G]),O=(0,d.useCallback)(b=>{G(a,void 0,b?`New Ollama (${b})`:"New Ollama Chat",{engine:"ollama",ollamaModel:b,appendToEnd:!0})},[a,G]),P=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a&&c.engine!==b?{...c,engine:b}:c))},[]),Q=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,ollamaModel:b}:c))},[]),R=(0,d.useCallback)(()=>{G(a,void 0,"New DeepSeek Chat",{engine:"deepseek",deepseekModel:"deepseek-v4-flash",appendToEnd:!0})},[a,G]),S=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,deepseekModel:b}:c))},[]),T=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,kimiModel:b}:c))},[]),U=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,glmModel:b}:c))},[]),V=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeModel:b}:c))},[]),W=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeEffort:b}:c))},[]),X=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeContextWindow:b}:c))},[]),Y=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeFastMode:b}:c))},[]),Z=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,claudeThinking:b}:c))},[]),$=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,codexModel:b}:c))},[]),_=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,codexReasoningEffort:b}:c))},[]),aa=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,planMode:b}:c))},[]),ab=(0,d.useCallback)((a,b)=>{s(c=>c.map(c=>c.id===a?{...c,noHistory:b}:c))},[]),ac=(0,d.useCallback)((b,c)=>{let d=x.current.find(a=>a.id===y.current);G(a,b,c,{engine:d?.engine,ollamaModel:d?.ollamaModel,deepseekModel:d?.deepseekModel,kimiModel:d?.kimiModel,glmModel:d?.glmModel,claudeModel:d?.claudeModel,claudeEffort:d?.claudeEffort,claudeContextWindow:d?.claudeContextWindow,claudeFastMode:d?.claudeFastMode,claudeThinking:d?.claudeThinking,codexModel:d?.codexModel,codexReasoningEffort:d?.codexReasoningEffort})},[a,G]),ad=(0,d.useCallback)((a,b)=>{s(c=>{let d=c.find(b=>b.id===a);if(d?.isLoading&&!1===b.isLoading){let c=!o.current||"agent"===o.current;if(a===t&&c&&q.current){let a=d.sessionId||b.sessionId;a&&A(a,"normal")}else w(b=>new Set(b).add(a))}return c.map(c=>c.id===a?{...c,...b}:c)})},[t,A]),ae=(0,d.useCallback)(a=>{u(a),w(b=>{if(!b.has(a))return b;let c=new Set(b);c.delete(a);let d=x.current.find(b=>b.id===a);return d?.sessionId&&(A(d.sessionId,"normal"),h.t4.runFork((0,i.M2)(d.sessionId).pipe(g.catchAll(()=>g.void)))),c})},[A]),af=(0,d.useCallback)(a=>{C(a)},[]),ag=(0,d.useCallback)((a,b)=>{a.preventDefault(),null!==B&&B!==b&&E(b)},[B]),ah=(0,d.useCallback)(a=>{null!==B&&B!==a&&s(b=>{let c=[...b],[d]=c.splice(B,1);return c.splice(a,0,d),c}),C(null),E(null)},[B]),ai=(0,d.useCallback)(()=>{C(null),E(null)},[]),aj=r.find(a=>a.id===t);return{tabs:r,activeTabId:t,activeTab:aj,unreadTabs:v,dragTabIndex:B,dragOverTabIndex:D,addTab:G,closeTab:H,closeAllTabs:I,switchTab:ae,handleSelectSession:J,handleNewTab:K,handleNewCodexTab:L,handleNewKimiTab:M,handleNewGlmTab:N,handleNewOllamaTab:O,handleNewDeepseekTab:R,handleOpenSession:ac,updateTabState:ad,updateTabEngine:P,updateTabOllamaModel:Q,updateTabDeepseekModel:S,updateTabKimiModel:T,updateTabGlmModel:U,updateTabClaudeModel:V,updateTabClaudeEffort:W,updateTabClaudeContextWindow:X,updateTabClaudeFastMode:Y,updateTabClaudeThinking:Z,updateTabCodexModel:$,updateTabCodexReasoningEffort:_,updateTabPlanMode:aa,updateTabNoHistory:ab,handleTabDragStart:af,handleTabDragOver:ag,handleTabDrop:ah,handleTabDragEnd:ai}}},37202:(a,b,c)=>{"use strict";c.d(b,{M:()=>n,O:()=>l});var d=c(48249),e=c(67484),f=c(44384),g=c(74429),h=c(74228);let i=[],j=[];function k(){j.forEach(a=>a())}function l(a){let b=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;i=[...i,{...a,id:b}],k()}function m(a){i=i.filter(b=>b.id!==a),k()}function n({onNavigate:a}){let b=function(){let[,a]=(0,e.useState)(0);return i}();return 0===b.length?null:(0,g.createPortal)((0,d.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:b.map(b=>(0,d.jsx)(o,{item:b,onNavigate:a,onRemove:m},b.id))}),document.body)}function o({item:a,onNavigate:b,onRemove:c}){let{t:g}=(0,f.Bd)(),[i,j]=(0,e.useState)(!1),k=(0,e.useRef)(void 0),l=(0,e.useCallback)(()=>{j(!0),setTimeout(()=>c(a.id),300)},[a.id,c]),m=(0,e.useCallback)(()=>{clearTimeout(k.current),b(a.cwd,a.sessionId),c(a.id)},[a,b,c]),n=(0,e.useCallback)(()=>{clearTimeout(k.current)},[]),p=(0,e.useCallback)(()=>{k.current=setTimeout(l,2e3)},[l]);return(0,d.jsxs)("div",{className:`group pointer-events-auto relative bg-popover border border-border rounded-lg shadow-lv3 px-3 py-3 min-h-[84px] min-w-[260px] max-w-[340px] cursor-pointer transition-all ${i?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:i?void 0:"slideInLeft 0.3s ease-out"},onClick:m,onMouseEnter:n,onMouseLeave:p,children:[(0,d.jsx)("div",{className:"pointer-events-none absolute inset-0 rounded-lg bg-hover opacity-0 group-hover:opacity-100 transition-opacity"}),(0,d.jsxs)("div",{className:"relative flex items-start gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-green-9 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.projectName}),(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:g("common.done")}),(0,d.jsx)(h.l,{projectNumber:a.projectNumber,sessionNumber:a.sessionNumber,className:"ml-auto"}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),l()},className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.message&&(0,d.jsx)("div",{className:"relative text-xs text-muted-foreground line-clamp-2 break-words mt-1 ml-6",children:a.message})]})}},37388:(a,b,c)=>{"use strict";c.d(b,{KJ:()=>h,M2:()=>i,ej:()=>g,n8:()=>f});var d=c(79606),e=c(71192);let f=a=>d.tryPromise({try:async()=>{let b=await fetch(`/api/project-state?cwd=${encodeURIComponent(a)}`);if(!b.ok)throw Error(`HTTP ${b.status}`);return await b.json()},catch:a=>new e.uV({message:"loadProjectState failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/project-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"saveProjectState failed",cause:a})}),h=(a,b,c)=>d.tryPromise({try:async()=>{let d=await fetch("/api/global-state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,sessionId:b,status:c})});if(!d.ok)throw Error(`HTTP ${d.status}`)},catch:a=>new e.uV({message:"updateSessionStatus failed",cause:a})}),i=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/scheduled-tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"markReadBySessionId",fields:{sessionId:a}})});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"markScheduledTasksReadBySession failed",cause:a})})},37690:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(67484);function e({enabled:a,container:b,resolveLineRange:c,buildLineSnapshot:f,dragThresholdPx:g=5}){let h=(0,d.useRef)(null),i=(0,d.useRef)(()=>{}),j=(0,d.useRef)(c),k=(0,d.useRef)(f),l=(0,d.useRef)(g);return j.current=c,k.current=f,l.current=g,{toolbarRef:h,bumpRef:i,clearToolbar:()=>{h.current&&(h.current=null,i.current())}}}},37701:(a,b,c)=>{"use strict";c.d(b,{Fe:()=>d,Ff:()=>h,Z8:()=>g,wL:()=>e});let d=a=>a?.toLowerCase().startsWith("zh")?"zh":"en",e=(a,b)=>{if(!a||"object"!=typeof a)return null;let c=a.quickReplies;return c&&"object"==typeof c?(a=>{if(!Array.isArray(a))return null;let b=[];for(let c of a.slice(0,12)){if(!Array.isArray(c))continue;let a=[];for(let b of c.slice(0,8)){if("string"!=typeof b)continue;let c=b.trim().slice(0,200);c&&a.push(c)}a.length&&b.push(a)}return b.length?b:null})(c[b]):null},f=/[,,]/,g=a=>a.split("\n").map(a=>a.split(f).map(a=>a.trim().slice(0,200)).filter(Boolean).slice(0,8)).filter(a=>a.length>0).slice(0,12),h=(a,b)=>a.map(a=>a.join("zh"===b?",":", ")).join("\n")},38878:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{TabManagerTopBar:()=>u});var e=c(48249),f=c(67484),g=c(94192),h=c(12568),i=c(7833),j=c(44384),k=c(57031),l=c(88214),m=c(79606),n=c(33281),o=c(85655),p=c(35606),q=c(65484);function r({className:a}){return(0,e.jsxs)("svg",{className:a,fill:"none",viewBox:"0 0 100 100","aria-hidden":"true",children:[(0,e.jsx)("path",{fill:"#0065A9",d:"M96.461 10.796 75.857.876a6.23 6.23 0 0 0-7.107 1.207l-67.451 61.5a4.167 4.167 0 0 0 .004 6.162l5.51 5.009a4.167 4.167 0 0 0 5.32.236l81.228-61.62c2.725-2.067 6.639-.124 6.639 3.297v-.24a6.25 6.25 0 0 0-3.539-5.63Z"}),(0,e.jsx)("path",{fill:"#007ACC",d:"m96.461 89.204-20.604 9.92a6.229 6.229 0 0 1-7.107-1.207l-67.451-61.5a4.167 4.167 0 0 1 .004-6.162l5.51-5.009a4.167 4.167 0 0 1 5.32-.236l81.228 61.62c2.725 2.067 6.639.124 6.639-3.297v.24a6.25 6.25 0 0 0-3.539 5.63Z"}),(0,e.jsx)("path",{fill:"#1F9CF0",d:"M75.858 99.126a6.232 6.232 0 0 1-7.108-1.21c2.306 2.307 6.25.674 6.25-2.588V4.672c0-3.262-3.944-4.895-6.25-2.589a6.232 6.232 0 0 1 7.108-1.21l20.6 9.908A6.25 6.25 0 0 1 100 16.413v67.174a6.25 6.25 0 0 1-3.541 5.633l-20.601 9.906Z"})]})}function s({className:a}){return(0,e.jsx)("svg",{className:a,viewBox:"0 0 466.73 532.09",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"})})}function t({cwd:a,currentBranch:b,onSwitched:c}){let{t:d}=(0,j.Bd)(),[g,h]=(0,f.useState)(!1),[k,l]=(0,f.useState)([]),[m,p]=(0,f.useState)(!1),[r,s]=(0,f.useState)(!1),[u,v]=(0,f.useState)(""),w=(0,f.useRef)(null),x=(0,f.useRef)(null),y=(0,f.useCallback)(async()=>{p(!0);let b=await n.t4.runPromiseExit((0,o.r4)(a));if("Success"===b._tag){let a=b.value,c=a.local??[],d=a.remote??[],e=[...c,...d.filter(a=>!c.includes(a.replace(/^origin\//,"")))];l(e)}else(0,i.oR)(d("toast.loadBranchFailed"),"error");p(!1)},[a,d]),z=(0,f.useCallback)(()=>{h(!0),v(""),y()},[y]),A=(0,f.useCallback)(()=>{h(!1)},[]),B=async b=>{s(!0);let e=await n.t4.runPromiseExit((0,q.Kl)({action:"checkout",cwd:a,path:a,branch:b}));if("Success"===e._tag){let a=b.replace(/^origin\//,"");(0,i.oR)(d("toast.switchedToBranch",{branch:a}),"success"),A(),c()}else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:d("toast.switchBranchFailed");(0,i.oR)(c,"error")}s(!1)},C=k.filter(a=>a!==b&&a.toLowerCase().includes(u.toLowerCase()));return(0,e.jsxs)("div",{className:"relative",ref:w,children:[(0,e.jsx)("button",{onClick:g?A:z,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:d("git.switchBranch"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})})}),g&&(0,e.jsxs)("div",{className:"absolute top-full left-0 mt-1 w-64 bg-popover border border-border rounded-lg shadow-lv2 z-50 overflow-hidden",children:[(0,e.jsx)("div",{className:"p-2 border-b border-border",children:(0,e.jsx)("input",{ref:x,type:"text",value:u,onChange:a=>v(a.target.value),placeholder:d("git.searchBranch"),className:"w-full px-2.5 py-1.5 text-sm bg-muted rounded border-none outline-none",onKeyDown:a=>{"Escape"===a.key&&A()}})}),(0,e.jsx)("div",{className:"max-h-60 overflow-y-auto p-1",children:m?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("common.loading")}):0===C.length?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:u?d("git.noMatchingBranches"):d("git.noBranches")}):C.map(a=>(0,e.jsx)("button",{onClick:()=>B(a),disabled:r,className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-hover transition-colors truncate disabled:opacity-50",children:(0,e.jsx)("span",{className:a.startsWith("origin/")?"text-muted-foreground":"text-foreground",children:a})},a))})]})]})}function u({initialCwd:a,activeTab:b,isGitRepo:c,currentBranch:d,onOpenWorktree:f,onOpenAliasManager:o,onBranchSwitched:v}){let{t:w}=(0,j.Bd)(),x=b?.sessionId?(0,p.X)(b.engine,b.sessionId):null;return(0,e.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("img",{src:"/icons/icon-72x72.png",alt:"Cockpit",className:"w-6 h-6 cursor-pointer",title:w("tabManagerTopBar.copyPageUrl"),onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>{(0,i.oR)(w("toast.copiedPageUrl"),"success")})}}),a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-sm text-foreground max-w-md truncate cursor-help","data-tooltip":`CWD: ${a}`,children:a}),(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(w("toast.copiedDirPath"))},className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:w("tabManagerTopBar.copyDirPath"),children:(0,e.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]}):(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Cockpit"})]}),c&&a&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsxs)("button",{onClick:f,className:"flex items-center gap-1.5 px-2 py-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:"Git Worktrees",children:[(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 17h8m0 0l-4-4m4 4l-4 4M3 7v6a4 4 0 004 4h5"})}),(0,e.jsx)("span",{className:"text-sm",children:d||"main"})]}),(0,e.jsx)(t,{cwd:a,currentBranch:d,onSwitched:()=>v?.()})]})]}),(0,e.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2",children:(0,e.jsx)(g.gT,{})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(h.ReviewDropdown,{cwd:a}),(0,e.jsx)("button",{onClick:()=>window.location.reload(),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.refreshProject"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,q.em)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openInVSCode"),children:(0,e.jsx)(r,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{b?.cwd&&n.t4.runFork((0,q.Q1)(b.cwd).pipe(m.orElse(()=>m.void)))},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openInCursor"),children:(0,e.jsx)(s,{className:"w-4 h-4"})}),x&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(x).then(()=>{(0,i.oR)(w("toast.copiedCommand",{command:x}),"success")})},className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("chat.copyCommandTooltip",{command:x}),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,e.jsx)("button",{onClick:o,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.aliasesGlobal"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 12h-6m-4 0a8 8 0 1116 0 8 8 0 01-16 0zm4 0h.01"})})}),(0,e.jsx)("button",{onClick:()=>(0,k.F)(l.n.OpenTokenStats,{}),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.tokenStats"),children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,e.jsx)("button",{onClick:()=>window.open("https://surething.io?from=cockpit","_blank"),className:"p-2 text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors",title:w("tabManagerTopBar.openSurething"),children:(0,e.jsx)("img",{src:"https://surething.io/logo.png?from=cockpit",alt:"Surething",className:"w-5 h-5 rounded-sm"})})]})]})})}d()}catch(a){d(a)}})},38896:(a,b,c)=>{"use strict";c.d(b,{C:()=>f});var d=c(67484),e=c(36984);function f(a,b){let[c,f]=(0,d.useState)(null),[g,h]=(0,d.useState)(!1),i=(0,d.useMemo)(()=>a.join("\n"),[a]),j=`${i}:${b}:${g}`;return(0,d.useMemo)(()=>c&&c.key===j?c.html:a.map(a=>(0,e.ZD)(a||" ")),[a,j,c])}},39031:(a,b,c)=>{"use strict";c.d(b,{IS:()=>h});var d=c(32891),e=c(10259),f=c(87748);let g=new Set(["taskItem","listItem"]),h=d.YY.create({name:"dropShellCleanup",addProseMirrorPlugins:()=>[new e.k_({key:new e.hs("dropShellCleanup"),appendTransaction(a,b,c){let d=[];if(a.forEach((b,c)=>{let e;if("drop"!==b.getMeta("uiEvent")||!b.docChanged)return;let g=(e=[],b.steps.forEach((a,c)=>{a instanceof f.Ln&&(0!==a.slice.size||a.from>=a.to||e.push(b.mapping.slice(c+1).map(a.from)))}),e);for(let b=c+1;b<a.length;b++)g=g.map(c=>a[b].mapping.map(c));d.push(...g)}),0===d.length)return null;let e=c.tr,h=!1;for(let a of d){let b=function(a,b){if(b<0||b>a.content.size)return null;let c=a.resolve(b);for(let a=c.depth;a>0;a--){var d;if(d=c.node(a),!g.has(d.type.name)||1!==d.childCount||null===d.firstChild||!d.firstChild.isTextblock||0!==d.firstChild.content.size)continue;let b=a;for(;b>1&&1===c.node(b-1).childCount;)b--;return{from:c.before(b),to:c.after(b)}}return null}(e.doc,e.mapping.map(a));if(b)try{e.delete(b.from,b.to),h=!0}catch{}}return h?e:null}})]})},39238:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{N:()=>r});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(64825),k=c(66400),l=c(86588),m=c(64676),n=c(40893),o=c(6478),p=c(48587),q=a([p]);function r({filePath:a,content:b,cwd:c,onClose:d,onContentSearch:q}){let{t:s}=(0,g.Bd)(),t=(0,o.P)(),[u,v]=(0,f.useState)("preview");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-0 md:p-4",onClick:d,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":a,onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(s("common.copiedPath"))},children:["",a]}),(0,e.jsx)("button",{onClick:()=>v(a=>"preview"===a?"source":"preview"),className:`px-1.5 py-0.5 text-xs rounded transition-colors flex-shrink-0 ${"preview"===u?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:"preview"===u?s("fileBrowser.exitPreview"):s("common.preview")}),(0,e.jsx)("button",{onClick:()=>t(a),title:s("htmlApps.addTooltip"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(j.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:a}})),d()},title:s("common.openInConsole"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(k.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>{let b=(0,m.Xe)(a,c);window.open((0,m.PB)(b,window.location.origin),"_blank")},title:s("browser.openInNewWindow"),className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:(0,e.jsx)(l.A,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:"preview"===u?(0,e.jsx)(n.O,{content:b,filePath:a,cwd:c,onContentSearch:q?a=>{q(a),d()}:void 0}):(0,e.jsx)(p.y,{entryPath:a,entryContent:b,cwd:c})})]})})})}p=(q.then?(await q)():q)[0],d()}catch(a){d(a)}})},39247:(a,b,c)=>{"use strict";c.d(b,{h:()=>e});let d=new Set(["Read","Grep","Glob","LS","WebSearch","WebFetch","NotebookRead","TodoRead","AskUserQuestion","ExitPlanMode","TodoWrite","Skill"]),e=a=>!d.has(a)},40159:(a,b,c)=>{"use strict";c.d(b,{S:()=>l,j:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(208),h=c(44256),i=c(89719);function j({blame:a,onClick:b}){let{t:c}=(0,f.Bd)(),i=(0,e.useRef)(null),k=(0,e.useRef)(null),l=(0,h.F2)(),m=(0,e.useRef)(!1),n=(0,e.useRef)(!1),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=(0,e.useRef)(null),r=(0,e.useRef)(a),s=(0,e.useRef)(b),t=(0,e.useCallback)(()=>{let a,b=k.current,c=i.current;if(!b||!c)return;let d=c.getBoundingClientRect(),e=b.getBoundingClientRect(),f=l?.getBoundingClientRect(),g=f?.left??0,h=f?.top??0,j=f?.width??window.innerWidth,m=f?.height??window.innerHeight,n=d.left-g;n+e.width>j-8&&(n=j-e.width-8),n<8&&(n=8);let o=d.top-h,p=d.bottom-h;(a=o-e.height-4<0?p+4:o-e.height-4)+e.height>m-8&&(a=m-e.height-8),b.style.left=`${n}px`,b.style.top=`${a}px`},[l]),u=(0,e.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),p.current&&(clearTimeout(p.current),p.current=null),m.current=!1,n.current=!1,k.current&&(k.current.style.display="none"),q.current&&(document.removeEventListener("mousedown",q.current.down),document.removeEventListener("mouseup",q.current.up),q.current=null)},[]),v=(0,e.useCallback)(()=>{let a=k.current;if(!a||m.current)return;m.current=!0,a.style.left="-9999px",a.style.top="-9999px",a.style.display="block",requestAnimationFrame(()=>requestAnimationFrame(t));let b=0,c=0,d=a=>{b=a.clientX,c=a.clientY},e=a=>{if(!(Math.abs(a.clientX-b)>5||Math.abs(a.clientY-c)>5)){let b;b=a.target,k.current?.contains(b)||i.current?.contains(b)||u()}};document.addEventListener("mousedown",d),document.addEventListener("mouseup",e),q.current={down:d,up:e}},[t,u]),w=(0,e.useCallback)(()=>{if(o.current&&clearTimeout(o.current),p.current&&(clearTimeout(p.current),p.current=null),m.current)return;let a=window.getSelection();(!a||a.isCollapsed)&&(o.current=setTimeout(v,500))},[v]),x=(0,e.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),m.current&&(p.current=setTimeout(()=>{n.current||u()},200))},[u]),y=(0,e.useCallback)(()=>{n.current=!0,p.current&&(clearTimeout(p.current),p.current=null)},[]),z=(0,e.useCallback)(()=>{n.current=!1,u()},[u]),A=(0,e.useCallback)(a=>{a.stopPropagation();let b=window.getSelection();b&&b.toString().length>0&&k.current?.contains(b.anchorNode)||(s.current?.(r.current),u())},[u]),B=a.message.split("\n")[0]||"",C=a.message.split("\n").slice(1).join("\n").trim();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{ref:i,className:"select-none text-xs text-muted-foreground/50 ml-6 cursor-default hover:text-muted-foreground/80",onMouseEnter:w,onMouseLeave:x,children:[a.author.split(" ")[0],", ",function(a){let b=g.A.t,c=Math.floor((Date.now()-1e3*a)/1e3);if(c<60)return b("common.justNow");let d=Math.floor(c/60);if(d<60)return b("common.minutesAgo",{count:d});let e=Math.floor(d/60);if(e<24)return b("common.hoursAgo",{count:e});let f=Math.floor(e/24);if(f<30)return b("common.daysAgo",{count:f});let h=Math.floor(f/30);return h<12?b("common.monthsAgo",{count:h}):b("common.yearsAgo",{count:Math.floor(h/12)})}(a.time)," \xb7 ",B]}),(0,d.jsx)(h.ZL,{children:(0,d.jsxs)("div",{ref:k,className:"fixed z-[9999] bg-card border border-border rounded-lg shadow-lv3 p-3 text-xs text-foreground whitespace-pre-wrap max-w-md select-text",style:{display:"none",minWidth:280,cursor:"text"},"data-inline-blame-tip":"",onMouseEnter:y,onMouseLeave:z,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,d.jsx)("span",{className:"font-mono text-brand",children:a.hash}),(0,d.jsx)("span",{className:"text-muted-foreground",children:a.author}),(0,d.jsx)("span",{className:"text-muted-foreground/60",children:new Date(1e3*a.time).toLocaleString()})]}),(0,d.jsx)("div",{className:"font-medium",children:B}),C&&(0,d.jsx)("div",{className:"mt-1 text-muted-foreground",children:C}),(0,d.jsx)("div",{className:"mt-2 text-[11px] text-brand border-t border-border pt-2 cursor-pointer hover:underline",onClick:A,children:c("codeViewer.clickToViewDetails")})]})})]})}let k=[{bg:"rgba(59, 130, 246, 0.15)",border:"rgb(59, 130, 246)"},{bg:"rgba(16, 185, 129, 0.15)",border:"rgb(16, 185, 129)"},{bg:"rgba(245, 158, 11, 0.15)",border:"rgb(245, 158, 11)"},{bg:"rgba(239, 68, 68, 0.15)",border:"rgb(239, 68, 68)"},{bg:"rgba(168, 85, 247, 0.15)",border:"rgb(168, 85, 247)"},{bg:"rgba(236, 72, 153, 0.15)",border:"rgb(236, 72, 153)"},{bg:"rgba(20, 184, 166, 0.15)",border:"rgb(20, 184, 166)"},{bg:"rgba(249, 115, 22, 0.15)",border:"rgb(249, 115, 22)"}],l=(0,e.memo)(function({virtualKey:a,lineNum:b,highlightedHtml:c,hasComments:g,firstComment:h,lineCommentsCount:k,isInRange:l,showLineNumbers:m,lineNumChars:n,commentsEnabled:o,virtualItemSize:p,virtualItemStart:q,onCommentBubbleClick:r,onCmdClick:s,onTokenHover:t,onTokenHoverLeave:u,flashLine:v,blameLine:w,showBlameInfo:x,blameAuthorColor:y,isBlameHovered:z,onBlameClick:A,onBlameMouseEnter:B,onBlameMouseLeave:C,inlineBlameData:D,onInlineBlameClick:E,isCursorLine:F,cursorCol:G}){let{t:H}=(0,f.Bd)(),I=(0,e.useMemo)(()=>F&&null!=G?function(a,b){let c=0,d=0;for(;d<a.length;){if("<"===a[d]){let b=a.indexOf(">",d);if(-1!==b){d=b+1;continue}}if(c===b){let b;if("&"===a[d]){let c=a.indexOf(";",d);b=-1!==c&&c-d<10?c+1:d+1}else b=d+1;let c=a.substring(d,b);return a.substring(0,d)+'<span class="vi-char-cursor">'+c+"</span>"+a.substring(b)}if("&"===a[d]){let b=a.indexOf(";",d);d=-1!==b&&b-d<10?b+1:d+1}else d++;c++}return a+'<span class="vi-char-cursor"> </span>'}(c,G):c,[c,F,G]),J=(0,e.useCallback)(a=>{if(!a.metaKey||!s)return;a.preventDefault(),a.stopPropagation();let c=a.currentTarget,d=(0,i.j)(a,c);window.getSelection()?.removeAllRanges(),s(b,d)},[b,s]),K=(0,e.useCallback)(a=>{if(!t)return;let c=(0,i.A)(a,a.currentTarget);c&&t(b,c.column,c.rect)},[b,t]),L=(0,e.useCallback)(()=>{w&&A&&A(w)},[w,A]),M=(0,e.useCallback)(a=>{w&&B&&B(w,a)},[w,B]);return(0,d.jsxs)("div",{"data-line":b,style:{position:"absolute",top:0,left:0,width:"100%",height:`${p}px`,transform:`translateY(${q}px)`,backgroundColor:z&&y?y.bg:void 0},className:`flex ${v===b?"flash-line":""} ${F?"vi-cursor-line":""} ${l?"bg-blue-9/20":g?"bg-amber-9/10":"hover:bg-hover"}`,children:[(0,d.jsxs)("div",{className:"flex shrink-0 sticky left-0 z-[2] bg-card",style:{backgroundImage:z&&y?`linear-gradient(${y.bg}, ${y.bg})`:void 0},children:[w&&y&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"w-1 flex-shrink-0",style:{backgroundColor:y.border}}),(0,d.jsx)("div",{className:"w-48 flex-shrink-0 px-2 flex items-center gap-2 border-r border-border text-muted-foreground cursor-pointer hover:bg-hover",onMouseEnter:M,onMouseLeave:C,onClick:L,title:H("codeViewer.clickToViewCommit"),children:x?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"font-medium",style:{color:y.border},children:w.hash}),(0,d.jsx)("span",{className:"truncate flex-1",children:w.author.split(" ")[0]})]}):null})]}),m&&(0,d.jsxs)("span",{className:`flex-shrink-0 flex items-center justify-end gap-0.5 pr-2 select-none border-r border-border font-variant-tabular ${l?"bg-blue-9/30 text-blue-11":"bg-card/50 text-foreground-subtle"}`,children:[o&&g&&h&&(0,d.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:H("codeViewer.nComments",{count:k}),children:(0,d.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,d.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&&!g&&(0,d.jsx)("span",{className:"w-4"}),(0,d.jsx)("span",{className:"text-right",style:{minWidth:`${n}ch`},children:b})]})]}),(0,d.jsxs)("span",{className:"flex-1 px-3 whitespace-pre select-text",onClick:J,onMouseOver:K,onMouseLeave:u,"data-code-content":!0,children:[(0,d.jsx)("span",{dangerouslySetInnerHTML:{__html:I}}),D&&(0,d.jsx)(j,{blame:D,onClick:E})]})]},a)})},40311:(a,b,c)=>{"use strict";function d(a,b){return"loading"===a?"border-transparent bg-orange-11/20 text-foreground animate-pulse":"unread"===a?"border-transparent bg-red-9/55 text-foreground":b?"border-transparent bg-brand/15 text-brand":"border-transparent bg-muted-foreground/15 text-muted-foreground"}c.d(b,{c:()=>d})},40699:(a,b,c)=>{"use strict";c.d(b,{u:()=>h});var d=c(67484),e=c(29939),f=c(85943),g=c(25414);function h(a,b,c,h,i){let j=(0,d.useRef)(null),k=(0,d.useRef)(0),l=(0,d.useRef)(0),m=(0,d.useRef)(!1),n=(0,d.useRef)(!1),o=(0,d.useRef)(!1),p=(0,d.useRef)(void 0),q=()=>{let a=`live-asst-${++k.current}`;return j.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",isStreaming:!0,runId:p.current}]),a},r=a=>{if((0,g.Nn)(a))return;let c=a=>{i?.onLiveOutputTokens?.({outputTokens:Math.max(0,Math.round(a))})},d=a=>{!m.current&&"string"==typeof a&&a&&(l.current+=(0,f.r)(a),c(l.current))};if("system"===a.type&&"init"===a.subtype){let a=n.current;o.current=!0,a||(l.current=0,m.current=!1,i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(Date.now())),q();return}if("usage_update"===a.type){"number"==typeof a.output_tokens&&Number.isFinite(a.output_tokens)&&(m.current=!0,l.current=Math.max(l.current,Math.round(a.output_tokens)),c(l.current));return}if("stream_event"===a.type){let b=a.event;b?.type==="content_block_delta"&&b.delta?.type==="text_delta"&&d(b.delta.text)}if("system"===a.type&&"background_tasks_changed"===a.subtype){let b=a.tasks??[];i?.onBackgroundTasks?.(b.filter(a=>!a.ambient).map(a=>({task_id:a.task_id,description:a.description})));return}if((0,g.A7)(a)&&(b(b=>(0,g.FM)(b,a,{engine:h,assistantId:j.current??""})),"task_notification"!==a.subtype))return;if("system"===a.type&&"task_notification"===a.subtype){if(!o.current){let c=`live-tasknotif-${a.task_id||++k.current}`,d=`<task-notification>
|
|
21
21
|
`+(a.task_id?`<task-id>${a.task_id}</task-id>
|
|
22
|
+
`:"")+(a.tool_use_id?`<tool-use-id>${a.tool_use_id}</tool-use-id>
|
|
22
23
|
`:"")+(a.status?`<status>${a.status}</status>
|
|
23
24
|
`:"")+(a.summary?`<summary>${a.summary}</summary>
|
|
24
25
|
`:"")+(a.output_file?`<output-file>${a.output_file}</output-file>
|
|
25
|
-
`:"")+"</task-notification>";b(b=>[...b,{id:c,role:"system",content:a.summary||"",systemEvent:{kind:"task-notification",...a.status?{status:a.status}:{},detail:d}}])}return}if("user"===a.type&&a._human){let c=a.message?.content,d="string"==typeof c?c:Array.isArray(c)?c.map(a=>a?.text||"").join(""):"",e="string"==typeof a._turnId?a._turnId:null;e&&(p.current=e);let f="number"==typeof a._ts?a._ts:null,g=e?`live-user-${e}`:`live-user-${++k.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&&(o.current=!1,n.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=j.current??q();b(b=>(0,g.F)(b,a,{engine:h,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&&(p.current=a.runId),"running"!==a.status){i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),l.current=0,m.current=!1,n.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,g=new Set;for(let b of a.events){let a=b?.uuid;if("string"==typeof a&&f.add(a),b?.type==="assistant"&&Array.isArray(b.message?.content))for(let a of b.message.content)a?.name&&"string"==typeof a.id&&g.add(a.id)}let h="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!==h&&!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>=h)a--;else break}return a<b.length?b.slice(0,a):b}if(!e)return b;let i=-1;for(let a=b.length-1;a>=0;a--)if("user"===b[a].role){b[a].content===e&&(i=a);break}return -1===i?b:b.slice(i+1).every(a=>"assistant"===a.role&&("string"==typeof a.id&&f.has(a.id)||!!a.toolCalls?.length&&a.toolCalls.every(a=>g.has(a.id))))?b.slice(0,i):b}),j.current=null,k.current=0,l.current=0,m.current=!1,n.current=!1,o.current=!1;let q="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let b of(null!==q&&(l.current=q,m.current=!0,i?.onLiveOutputTokens?.({outputTokens:q})),a.events))r(b);i?.onRunningChange?.(!0),i?.onRunStartedAt?.("number"==typeof a.startedAt?a.startedAt:Date.now())}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),l.current=0,m.current=!1,n.current=!1,i?.onComplete?.();return}r(a.message),i?.onRunningChange?.(!0)}else"run-idle"===a.type&&(i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),l.current=0,m.current=!1,n.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})})},41224:(a,b,c)=>{"use strict";c.d(b,{Cr:()=>C,F4:()=>q,Fi:()=>n,Hw:()=>k,JC:()=>u,M5:()=>s,Ny:()=>l,QW:()=>x,XO:()=>D,Zr:()=>w,an:()=>B,dM:()=>p,dQ:()=>m,em:()=>j,he:()=>o,l1:()=>t,n_:()=>v,qD:()=>A,tY:()=>F,td:()=>i,tf:()=>E,yS:()=>r,z2:()=>y});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=()=>f("/api/settings"),j=a=>h("/api/settings",a),k=a=>f(`/api/${a}/credentials`),l=a=>f(`/api/${a}/credentials?reveal=1`),m=(a,b)=>h(`/api/${a}/credentials`,{apiKey:b}),n=a=>f(`/api/${a}/models`),o=()=>f("/api/deepseek/balance"),p=a=>f(`/api/${a}/usage`),q=()=>f("/api/ollama/config"),r=a=>h("/api/ollama/config",a),s=()=>f("/api/commands"),t=()=>f("/api/skills"),u=a=>g("/api/bash",a),v=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return b.ok?await b.json():null},catch:a=>new e.uV({message:"POST /api/session-by-path failed",cause:a})}),w=(a,b)=>g(`/api/session/${encodeURIComponent(a)}/fork`,b),x=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),y=()=>f("/api/global-state").pipe(d.map(a=>a.sessions??[])),z=()=>d.tryPromise({try:async()=>{let a=await fetch("/api/ollama/models");return 503===a.status?{_tag:"not-running"}:a.ok?{_tag:"ok",models:(await a.json()).models??[]}:{_tag:"error",message:"Failed to fetch models"}},catch:a=>new e.uV({message:"fetch ollama models failed",cause:a})}),A=a=>d.gen(function*(){let b=yield*z();if("not-running"!==b._tag)return b;a&&(yield*d.sync(a));let c=yield*d.tryPromise({try:async()=>{let a=await fetch("/api/ollama/start",{method:"POST"}),b=await a.json().catch(()=>({}));return 404===a.status?{_tag:"not-installed",message:b.message||"Ollama is not installed"}:a.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:a=>new e.uV({message:"start ollama failed",cause:a})});if("not-installed"===c._tag)return{_tag:"not-installed",message:c.message};if("error"===c._tag)return{_tag:"error",message:c.message};let f=yield*z();return"not-running"===f._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:f}),B=a=>f(`/api/file?path=${encodeURIComponent(a)}`),C=()=>f("/api/claude-stats"),D=()=>f("/api/prompts/config?scope=global"),E=a=>f(`/api/prompts/config?cwd=${encodeURIComponent(a)}`),F=a=>g("/api/prompts/config",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)},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")})]})]})}},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,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}){return(0,d.jsx)(e.K,{filePath:b,oldSrc:c?f(a,c,b):null,newSrc:h?f(a,h,b):null})}},47276:(a,b,c)=>{"use strict";c.d(b,{m3:()=>i,mi:()=>g,ot:()=>h});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/html-apps"),h=a=>f("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/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,{KO:()=>i,LD:()=>m,Mm:()=>k,Qr:()=>a,fw:()=>j,o$:()=>l});var e=c(48249),f=c(67484),g=c(33281),h=c(85655);let a=a=>a.split("/").pop()||a;function i({status:a,className:b=""}){return(0,e.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===a?"bg-orange-11":"unread"===a?"bg-red-9":"bg-muted-foreground/30"} ${b}`})}function j(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 k(a,b){return"loading"===b?a("sessions.running"):"unread"===b?a("sessions.done"):void 0}function l(){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 m({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)},53113:(a,b,c)=>{Promise.resolve().then(c.bind(c,4462)),Promise.resolve().then(c.bind(c,29491)),Promise.resolve().then(c.bind(c,34001)),Promise.resolve().then(c.bind(c,83179)),Promise.resolve().then(c.bind(c,25608)),Promise.resolve().then(c.bind(c,8077)),Promise.resolve().then(c.bind(c,5585)),Promise.resolve().then(c.bind(c,77120)),Promise.resolve().then(c.bind(c,77220)),Promise.resolve().then(c.bind(c,3588)),Promise.resolve().then(c.bind(c,77462)),Promise.resolve().then(c.bind(c,38878)),Promise.resolve().then(c.bind(c,37129)),Promise.resolve().then(c.bind(c,99033))},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:()=>x});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(18921),p=c(72529),q=c(85984),r=c(65543),s=c(25667),t=c(53036),u=c(88018),v=c(9804),w=a([s,i,l,m]);[s,i,l,m]=w.then?(await w)():w;let y=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function x({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:w,changedFiles:z,fileGitStatusMap:A,onContentSearch:B,locateInTree:C,jsonPreview:D,setJsonPreview:E,jsonPreviewSearch:F,jsonPreviewPreRef:G,onTokenHover:H,onTokenHoverLeave:I,onTokenHoverCancel:J}){let{t:K}=(0,g.Bd)(),L="unstaged"===b.type?{onTokenHover:H,onTokenHoverLeave:I,onTokenHoverCancel:J}:{},[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)("file"),[Q,R]=(0,f.useState)("compact"),[S,T]=(0,f.useState)("unified"),U=b.file.path,V=b.file.oldPath||U,W=(0,v.u)(U),X=U.startsWith("/")?U:a?`${a.replace(/\/$/,"")}/${U}`:U,{state:Y}=(0,q.V)(a,U),Z=(0,f.useMemo)(()=>{if("ready"===Y.state)return Y.data.functions.filter(r._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[Y]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[W||"map"!==O?(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:U}),(0,e.jsx)(p.m,{content:K("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${U}`),(0,h.oR)(K("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)(p.m,{content:K("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),C(U)},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?K("fileBrowser.staged"):K("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!W&&(0,e.jsx)(j.y,{value:Q,onChange:R}),!W&&"file"===O&&(0,e.jsx)(k.q,{value:S,onChange:T}),!W&&(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(),P(a)},className:`px-2 py-0.5 text-xs transition-colors ${O===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:K("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:W?(0,e.jsx)(u.K,{filePath:U,oldSrc:c.isNew?null:y(a,"staged"===b.type?"HEAD":":0","staged"===b.type?V:U),newSrc:c.isDeleted||"staged"!==b.type?null:y(a,":0",U),newNode:c.isDeleted||"staged"===b.type?void 0:(0,e.jsx)(t.I,{cwd:a,path:U,className:"flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:U})}):"unified"===S?(0,e.jsx)(i.xU,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,cwd:a,enableComments:!0,compact:"compact"===Q,onPreview:!c.isDeleted&&(0,n.e$)(U)?()=>w(!0):!c.isDeleted&&(0,n.aR)(U)?()=>N(!0):!c.isDeleted&&U.endsWith(".json")?()=>E({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:U.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:B,...L}):(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"===Q,symbols:Z,onPreview:!c.isDeleted&&(0,n.e$)(U)?()=>w(!0):!c.isDeleted&&(0,n.aR)(U)?()=>N(!0):!c.isDeleted&&U.endsWith(".json")?()=>E({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:U.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:B,...L})})]}):(0,e.jsx)(s.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:z,fileGitStatusMap:A,enableComments:!0,compact:"compact"===Q,onContentSearch:B,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=A.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.m,{content:K("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(K("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)(p.m,{content:K("fileBrowser.locateInTree"),children:(0,e.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,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?K("fileBrowser.staged"):K("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.y,{value:Q,onChange:R}),(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(),P(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${O===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:K("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:()=>w(!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:()=>w(!1)})})}),M&&(0,e.jsx)(m.N,{filePath:X,content:c.newContent,cwd:a,onClose:()=>N(!1)}),D&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>E(null),children:(0,e.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,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:D.filePath}),(0,e.jsx)("button",{onClick:()=>E(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(o._,{search:F}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{ref:G,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,n.xb)(D.content)})})]})})]})}d()}catch(a){d(a)}})},57031:(a,b,c)=>{"use strict";c.d(b,{F:()=>g});var d=c(79606),e=c(23734),f=c(33281);let g=(a,b)=>{f.t4.runFork(d.flatMap(e.d,c=>c.publish(a,b)))}},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$:()=>I,vP:()=>E,zB:()=>J});var e=c(48249),f=c(67484),g=c(44384),h=c(79606),i=c(87819);c(57063);var j=c(7122),k=c(44256),l=c(67216),m=c(46674),n=c(145),o=c(20586),p=c(74691),q=c(60333),r=c(88018),s=c(35208),t=c(60591),u=c(73887),v=c(39238),w=c(18479),x=c(15578),y=c(39247),z=a([s,u,v]);[s,u,v]=z.then?(await z)():z;let K=(a,b,c)=>`/api/snapshots/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function A(a){return a.fullSubject||a.subject}function B(a,b,c){let d=A(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 C(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function D(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=C(a.file_path,b);c.push({key:d.id,toolName:"Edit",subject:`[Edit] ${e}`,legacy:!0,changeClass:(0,x.q)(e),files:[{path:e,status:"modified",old_string:a.old_string,new_string:a.new_string,fileClass:(0,x.q)(e)}]})}}else if("Write"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.content){let e=C(a.file_path,b);c.push({key:d.id,toolName:"Write",subject:`[Write] ${e}`,legacy:!0,changeClass:(0,x.q)(e),files:[{path:e,status:"added",old_string:"",new_string:a.content,fileClass:(0,x.q)(e)}]})}}return c}function E(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),toolName:a.commit.toolName??"tool",subject:a.commit.subject,timestamp:a.commit.timestamp,truncated:!0===a.truncated,changeClass:(0,x.S)(a.files.map(a=>a.path)),files:a.files.map(a=>({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:b.size>0&&!b.has(a.path),fileClass:(0,x.q)(a.path)}))}});return d=f.length>0?f:D(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 F({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 G({cls:a}){return(0,e.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})}function H(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 I({toolCalls:a,cwd:b,sessionId:c,runId:d,onClose:k,onContentSearch:x}){let{t:z}=(0,g.Bd)(),C=(0,f.useRef)(null),[J,L]=(0,f.useState)(null),M=(0,f.useMemo)(()=>a.map(a=>a.id).filter(Boolean),[a]),N=M.join(","),[O,P]=(0,f.useState)(0),Q=(0,i.Z)(b&&M.length>0?(0,w.se)(b,M,c,d):h.succeed([]),[b,c,d,N,O]);(0,f.useMemo)(()=>a.filter(a=>(0,y.h)(a.name)).map(a=>a.id),[a]);let R=(0,f.useRef)([]),S="loading"===Q.status&&0===R.current.length,T=(0,f.useMemo)(()=>{if("success"===Q.status){let c=E(Q.data,a,b);return c.length>0&&(R.current=c),c}return"loading"===Q.status&&R.current.length>0?R.current:"loading"===Q.status?[]:D(a,b)},[Q,a,b]),[U,V]=(0,f.useState)(null),[W,X]=(0,f.useState)(null),[Y,Z]=(0,f.useState)(new Set),[$,_]=(0,f.useState)(()=>!0),[aa,ab]=(0,f.useState)("compact"),[ac,ad]=(0,f.useState)("unified"),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(null),ak=(0,f.useMemo)(()=>T.find(a=>a.key===U)??null,[T,U]),al=(0,f.useRef)(null),am=ak??al.current,an=(0,f.useMemo)(()=>am?(0,o.Do)(am.files):[],[am]),ao=(0,f.useMemo)(()=>am?.files.find(a=>a.path===W)??null,[am,W]),ap=(0,f.useCallback)(a=>{V(a.key),X(a.files[0]?.path??null),Z(new Set((0,o.Sz)((0,o.Do)(a.files))))},[]),aq=(0,f.useMemo)(()=>T.reduce((a,b)=>a+b.files.length,0),[T]),ar=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:J,children:(0,e.jsxs)("div",{ref:C,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:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>_(a=>!a),"aria-label":z("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${$?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,e.jsx)(l.A,{className:"w-4 h-4"})}),(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:z("diffViewer.fileChanges",{count:aq})})]}),(0,e.jsx)("button",{onClick:k,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(m.A,{className:"w-5 h-5"})})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[$&&(0,e.jsx)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:T.map(a=>{let b;return(0,e.jsxs)("div",{onClick:()=>ap(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${U===a.key?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[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:H(a.timestamp)}),a.changeClass&&(0,e.jsx)("span",{className:"ml-auto",children:(0,e.jsx)(G,{cls:a.changeClass})})]}),(0,e.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":A(a),children:B(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:z("commitDetail.nChanges",{count:a.files.length})}),(b=function(a){let b=!1,c=0,d=0;for(let e of a.files)(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}(a))&&(b.additions>0||b.deletions>0)?(0,e.jsx)(F,{additions:b.additions,deletions:b.deletions}):null]})]},a.key)})}),(0,e.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:S?ar(z("diffViewer.loadingSnapshots")):0===T.length?ar(z("diffViewer.noChanges")):am?(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:[(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(n.A,{className:"w-3.5 h-3.5"}),am.toolName]}),am.shortHash&&(0,e.jsx)("span",{className:"font-mono text-brand",children:am.shortHash}),void 0!==am.timestamp&&(0,e.jsx)("span",{children:H(am.timestamp)}),(0,e.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":A(am),children:B(am,640,6)}),am.truncated&&(0,e.jsx)("span",{className:"text-amber-11",children:z("diffViewer.truncated")}),am.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":z("diffViewer.reconstructedHint"),children:z("diffViewer.reconstructed")}),(0,e.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!ao?.isImage&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.y,{value:aa,onChange:ab}),(0,e.jsx)(q.q,{value:ac,onChange:ad})]})})]}),(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:(0,e.jsx)(o.VO,{files:an,selectedPath:W,expandedPaths:Y,onToggle:a=>Z(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c}),onSelect:a=>{!a.isDirectory&&a.file&&X(a.file.path)},cwd:b||"",showChanges:!0,renderActions:a=>{if(a.isDirectory)return null;let b=a.file;return b?(0,e.jsxs)(e.Fragment,{children:[b.fileClass&&(0,e.jsx)(G,{cls:b.fileClass}),b.external&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":z("diffViewer.externalChange")})]}):null}})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:ao?ao.isImage?(0,e.jsx)(r.K,{filePath:ao.path,oldSrc:b&&ao.oldRev?K(b,ao.oldRev,ao.path):null,newSrc:b&&ao.newRev?K(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:z("diffViewer.notViewable")}):"unified"===ac?(0,e.jsx)(s.xU,{oldContent:ao.old_string,newContent:ao.new_string,filePath:ao.path,cwd:b,enableComments:!0,onContentSearch:x,compact:"compact"===aa,onPreview:"deleted"===ao.status?void 0:(0,t.e$)(ao.path)?()=>af(!0):(0,t.aR)(ao.path)?()=>ah(!0):ao.path.endsWith(".json")?()=>aj({content:ao.new_string,filePath:ao.path}):void 0,previewLabel:ao.path.endsWith(".json")?z("common.readable"):z("common.preview")}):(0,e.jsx)(s.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:x,compact:"compact"===aa,onPreview:"deleted"===ao.status?void 0:(0,t.e$)(ao.path)?()=>af(!0):(0,t.aR)(ao.path)?()=>ah(!0):ao.path.endsWith(".json")?()=>aj({content:ao.new_string,filePath:ao.path}):void 0,previewLabel:ao.path.endsWith(".json")?z("common.readable"):z("common.preview")}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("diffViewer.selectFileToView")})})]})]}):ar(z("diffViewer.selectFileToView"))})]}),ae&&ao&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>af(!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)(u.M,{content:ao.new_string,filePath:ao.path,cwd:b||"",onClose:()=>af(!1)})})}),ag&&ao&&(0,e.jsx)(v.N,{filePath:ao.path,content:ao.new_string,cwd:b,onClose:()=>ah(!1),onContentSearch:x}),ai&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>aj(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:ai.filePath}),(0,e.jsx)("button",{onClick:()=>aj(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(m.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,t.xb)(ai.content)})})]})})]})})}function J({toolCalls:a,cwd:b,sessionId:c,runId:d,onClose:f,onContentSearch:g}){return(0,e.jsx)(k.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:f,children:(0,e.jsx)(I,{toolCalls:a,cwd:b,sessionId:c,runId:d,onClose:f,onContentSearch:g?a=>{f(),g(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:()=>F});var e=c(48249),f=c(67484),g=c(41927),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(62473),q=c(86686),r=c(75513),s=c(81206),t=c(97951),u=c(99843),v=c(36702),w=c(43209),x=c(95401),y=c(42910),z=c(65139),A=c(47604),B=c(60812),C=c(84844),D=c(44384),E=a([u]);function F({tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:E,ollamaModel:G,onOllamaModelChange:H,deepseekModel:I,onDeepseekModelChange:J,kimiModel:K,onKimiModelChange:L,glmModel:M,onGlmModelChange:N,claudeModel:O,onClaudeModelChange:P,claudeEffort:Q,onClaudeEffortChange:R,claudeContextWindow:S,onClaudeContextWindowChange:T,claudeFastMode:U,onClaudeFastModeChange:V,claudeThinking:W,onClaudeThinkingChange:X,codexModel:Y,onCodexModelChange:Z,codexReasoningEffort:$,onCodexReasoningEffortChange:_,planMode:aa,onPlanModeChange:ab,noHistory:ac,onNoHistoryChange:ad,hideHeader:ae,hideSidebar:af,isActive:ag=!0,refreshSignal:ah,onLoadingChange:ai,onSessionIdChange:aj,onTitleChange:ak,onShowGitStatus:al,onOpenNote:am,onCreateScheduledTask:an,onOpenSession:ao,onContentSearch:ap,onShowFileDiff:aq,onOpenFileLink:ar,onOpenSessionBrowser:as,onOpenSettings:at}){let{t:au}=(0,D.Bd)();(0,r.nH)();let[av,aw]=(0,f.useState)([]),[ax,ay]=(0,f.useState)(null),[az,aA]=(0,f.useState)(!1),[aB,aC]=(0,f.useState)(!1),[aD,aE]=(0,f.useState)(!1),[aF,aG]=(0,f.useState)(!1),[aH,aI]=(0,f.useState)(null),[aJ,aK]=(0,f.useState)(!1),aL=aa??aJ,aM=(0,f.useCallback)(a=>{aK(a),ab?.(a)},[ab]),[aN,aO]=(0,f.useState)(!1),aP=ac??aN,aQ=(0,f.useCallback)(a=>{aO(a),ad?.(a)},[ad]),[aR,aS]=(0,f.useState)(!1),aT=(0,f.useRef)(null);(0,f.useRef)(null);let aU=(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?ak?.(c.value.title):"Failure"===c._tag&&console.error("Failed to fetch session title:",c.cause)},[b,ak]),aV=(0,f.useRef)(null),[aW,aX]=(0,f.useState)(!1),[aY,aZ]=(0,f.useState)(null),[a$,a_]=(0,f.useState)(null),a0=(0,f.useRef)(!1),{isLoadingHistory:a1,isLoadingMore:a2,hasMoreHistory:a3,loadMoreHistory:a4,loadHistoryByCwdAndSessionId:a5,loadedSessionId:a6,loadedEngine:a7}=(0,s.m)(av,aw,ax,{cwd:b,initialSessionId:c,onSessionId:ay,onTitleChange:ak,onTokenUsage:aI,liveRunningRef:a0}),a8=a7??d??void 0,a9=!a8||"claude"===a8,ba="codex"===a8,bb=O??z.BV,bc=(0,z.NR)(bb,Q),bd=(0,z.OO)(bb,S),be=Y??z.kn,bf=(0,z.oJ)(be,$),bg="deepseek"===a8||"kimi"===a8||"glm"===a8?a8:null,bh="kimi"===bg?K:"glm"===bg?M:I,bi="kimi"===bg?L:"glm"===bg?N:J,bj="ollama"===a8||null!==bg||a9||ba,{isLoading:bk,tokenUsage:bl,liveOutputTokens:bm,runningStartedAt:bn,rateLimitInfo:bo,apiRetryInfo:bp,backgroundTasks:bq,handleSend:br,handleStop:bs}=(0,t.e)(av,aw,{sessionId:ax,cwd:b,engine:a8,planMode:aL,noHistory:aP,ollamaModel:G,engineModel:bh,claudeModel:bb,claudeEffort:bc,claudeContextWindow:bd,claudeFastMode:U,claudeThinking:W,codexModel:be,codexReasoningEffort:bf,onSessionId:ay,onFetchTitle:aU,onRunComplete:()=>aV.current?.()}),bt=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(a9){let b=/^\/plan(?:\s+([\s\S]*))?$/.exec(a.trim());if(b){let a=(b[1]??"").trim();"off"===a.toLowerCase()?(aM(!1),(0,i.oR)(au("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===a?(aM(!0),(0,i.oR)(au("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(aM(!0),br(a,c,{permissionMode:"plan"}));return}}if(d.startsWith("!")&&d.length>1){let e=d.slice(1).trim();if(!e)return void br(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=au("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("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&&(p.current=e);let f="number"==typeof a._ts?a._ts:null,g=e?`live-user-${e}`:`live-user-${++k.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&&(o.current=!1,n.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=j.current??q();b(b=>(0,g.FM)(b,a,{engine:h,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&&(p.current=a.runId),"running"!==a.status){i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),i?.onBackgroundTasks?.([]),b(g.fD),l.current=0,m.current=!1,n.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 q="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!==q&&!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>=q)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}),j.current=null,k.current=0,l.current=0,m.current=!1,n.current=!1,o.current=!1;let s="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let b of(null!==s&&(l.current=s,m.current=!0,i?.onLiveOutputTokens?.({outputTokens:s})),a.events))r(b);i?.onRunningChange?.(!0),i?.onRunStartedAt?.("number"==typeof a.startedAt?a.startedAt:Date.now())}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type){i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),i?.onBackgroundTasks?.([]),b(g.fD),l.current=0,m.current=!1,n.current=!1,i?.onComplete?.();return}r(a.message),i?.onRunningChange?.(!0)}else"run-idle"===a.type&&(i?.onRunningChange?.(!1),i?.onLiveOutputTokens?.(null),i?.onRunStartedAt?.(null),i?.onBackgroundTasks?.([]),b(g.fD),l.current=0,m.current=!1,n.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})})},41224:(a,b,c)=>{"use strict";c.d(b,{Cr:()=>C,F4:()=>q,Fi:()=>n,Hw:()=>k,JC:()=>u,M5:()=>s,Ny:()=>l,QW:()=>x,XO:()=>D,Zr:()=>w,an:()=>B,dM:()=>p,dQ:()=>m,em:()=>j,he:()=>o,l1:()=>t,n_:()=>v,qD:()=>A,tY:()=>F,td:()=>i,tf:()=>E,yS:()=>r,z2:()=>y});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=()=>f("/api/settings"),j=a=>h("/api/settings",a),k=a=>f(`/api/${a}/credentials`),l=a=>f(`/api/${a}/credentials?reveal=1`),m=(a,b)=>h(`/api/${a}/credentials`,{apiKey:b}),n=a=>f(`/api/${a}/models`),o=()=>f("/api/deepseek/balance"),p=a=>f(`/api/${a}/usage`),q=()=>f("/api/ollama/config"),r=a=>h("/api/ollama/config",a),s=()=>f("/api/commands"),t=()=>f("/api/skills"),u=a=>g("/api/bash",a),v=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return b.ok?await b.json():null},catch:a=>new e.uV({message:"POST /api/session-by-path failed",cause:a})}),w=(a,b)=>g(`/api/session/${encodeURIComponent(a)}/fork`,b),x=a=>f(`/api/sessions/projects/${encodeURIComponent(a)}`),y=()=>f("/api/global-state").pipe(d.map(a=>a.sessions??[])),z=()=>d.tryPromise({try:async()=>{let a=await fetch("/api/ollama/models");return 503===a.status?{_tag:"not-running"}:a.ok?{_tag:"ok",models:(await a.json()).models??[]}:{_tag:"error",message:"Failed to fetch models"}},catch:a=>new e.uV({message:"fetch ollama models failed",cause:a})}),A=a=>d.gen(function*(){let b=yield*z();if("not-running"!==b._tag)return b;a&&(yield*d.sync(a));let c=yield*d.tryPromise({try:async()=>{let a=await fetch("/api/ollama/start",{method:"POST"}),b=await a.json().catch(()=>({}));return 404===a.status?{_tag:"not-installed",message:b.message||"Ollama is not installed"}:a.ok?{_tag:"started"}:{_tag:"error",message:"Failed to start Ollama"}},catch:a=>new e.uV({message:"start ollama failed",cause:a})});if("not-installed"===c._tag)return{_tag:"not-installed",message:c.message};if("error"===c._tag)return{_tag:"error",message:c.message};let f=yield*z();return"not-running"===f._tag?{_tag:"error",message:"Ollama started but cannot fetch models"}:f}),B=a=>f(`/api/file?path=${encodeURIComponent(a)}`),C=()=>f("/api/claude-stats"),D=()=>f("/api/prompts/config?scope=global"),E=a=>f(`/api/prompts/config?cwd=${encodeURIComponent(a)}`),F=a=>g("/api/prompts/config",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)},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")})]})]})}},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,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}){return(0,d.jsx)(e.K,{filePath:b,oldSrc:c?f(a,c,b):null,newSrc:h?f(a,h,b):null})}},47276:(a,b,c)=>{"use strict";c.d(b,{m3:()=>i,mi:()=>g,ot:()=>h});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/html-apps"),h=a=>f("/api/html-apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/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,{KO:()=>i,LD:()=>m,Mm:()=>k,Qr:()=>a,fw:()=>j,o$:()=>l});var e=c(48249),f=c(67484),g=c(33281),h=c(85655);let a=a=>a.split("/").pop()||a;function i({status:a,className:b=""}){return(0,e.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===a?"bg-orange-11":"unread"===a?"bg-red-9":"bg-muted-foreground/30"} ${b}`})}function j(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 k(a,b){return"loading"===b?a("sessions.running"):"unread"===b?a("sessions.done"):void 0}function l(){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 m({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)},53113:(a,b,c)=>{Promise.resolve().then(c.bind(c,4462)),Promise.resolve().then(c.bind(c,29491)),Promise.resolve().then(c.bind(c,34001)),Promise.resolve().then(c.bind(c,83179)),Promise.resolve().then(c.bind(c,25608)),Promise.resolve().then(c.bind(c,8077)),Promise.resolve().then(c.bind(c,5585)),Promise.resolve().then(c.bind(c,77120)),Promise.resolve().then(c.bind(c,77220)),Promise.resolve().then(c.bind(c,3588)),Promise.resolve().then(c.bind(c,77462)),Promise.resolve().then(c.bind(c,38878)),Promise.resolve().then(c.bind(c,37129)),Promise.resolve().then(c.bind(c,99033))},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:()=>x});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(18921),p=c(72529),q=c(85984),r=c(65543),s=c(25667),t=c(53036),u=c(88018),v=c(9804),w=a([s,i,l,m]);[s,i,l,m]=w.then?(await w)():w;let y=(a,b,c)=>`/api/git/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function x({cwd:a,selected:b,diff:c,showMarkdownPreview:d,setShowMarkdownPreview:w,changedFiles:z,fileGitStatusMap:A,onContentSearch:B,locateInTree:C,jsonPreview:D,setJsonPreview:E,jsonPreviewSearch:F,jsonPreviewPreRef:G,onTokenHover:H,onTokenHoverLeave:I,onTokenHoverCancel:J}){let{t:K}=(0,g.Bd)(),L="unstaged"===b.type?{onTokenHover:H,onTokenHoverLeave:I,onTokenHoverCancel:J}:{},[M,N]=(0,f.useState)(!1),[O,P]=(0,f.useState)("file"),[Q,R]=(0,f.useState)("compact"),[S,T]=(0,f.useState)("unified"),U=b.file.path,V=b.file.oldPath||U,W=(0,v.u)(U),X=U.startsWith("/")?U:a?`${a.replace(/\/$/,"")}/${U}`:U,{state:Y}=(0,q.V)(a,U),Z=(0,f.useMemo)(()=>{if("ready"===Y.state)return Y.data.functions.filter(r._).map(a=>({name:a.name,startLine:a.startLine,endLine:a.endLine,params:a.params}))},[Y]);return(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[W||"map"!==O?(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:U}),(0,e.jsx)(p.m,{content:K("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),navigator.clipboard.writeText(`${a}/${U}`),(0,h.oR)(K("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)(p.m,{content:K("fileBrowser.locateInTree"),children:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),C(U)},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?K("fileBrowser.staged"):K("fileBrowser.unstaged")}),(0,e.jsx)("div",{className:"flex-1"}),!W&&(0,e.jsx)(j.y,{value:Q,onChange:R}),!W&&"file"===O&&(0,e.jsx)(k.q,{value:S,onChange:T}),!W&&(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(),P(a)},className:`px-2 py-0.5 text-xs transition-colors ${O===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:K("file"===a?"common.file":"common.codeMap")},a))})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:W?(0,e.jsx)(u.K,{filePath:U,oldSrc:c.isNew?null:y(a,"staged"===b.type?"HEAD":":0","staged"===b.type?V:U),newSrc:c.isDeleted||"staged"!==b.type?null:y(a,":0",U),newNode:c.isDeleted||"staged"===b.type?void 0:(0,e.jsx)(t.I,{cwd:a,path:U,className:"flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:U})}):"unified"===S?(0,e.jsx)(i.xU,{oldContent:c.oldContent,newContent:c.newContent,filePath:c.filePath,cwd:a,enableComments:!0,compact:"compact"===Q,onPreview:!c.isDeleted&&(0,n.e$)(U)?()=>w(!0):!c.isDeleted&&(0,n.aR)(U)?()=>N(!0):!c.isDeleted&&U.endsWith(".json")?()=>E({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:U.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:B,...L}):(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"===Q,symbols:Z,onPreview:!c.isDeleted&&(0,n.e$)(U)?()=>w(!0):!c.isDeleted&&(0,n.aR)(U)?()=>N(!0):!c.isDeleted&&U.endsWith(".json")?()=>E({content:c.newContent,filePath:c.filePath}):void 0,previewLabel:U.endsWith(".json")?K("common.readable"):K("common.preview"),onContentSearch:B,...L})})]}):(0,e.jsx)(s.r,{cwd:a,filePath:c.filePath,oldContent:c.oldContent,newContent:c.newContent,isNew:c.isNew,isDeleted:c.isDeleted,changedFiles:z,fileGitStatusMap:A,enableComments:!0,compact:"compact"===Q,onContentSearch:B,headerExtraLeft:({focalFile:b})=>{if(!b)return null;let c=A.get(b);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.m,{content:K("common.copyAbsPath"),children:(0,e.jsx)("button",{onClick:c=>{c.stopPropagation(),navigator.clipboard.writeText(`${a}/${b}`),(0,h.oR)(K("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)(p.m,{content:K("fileBrowser.locateInTree"),children:(0,e.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,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?K("fileBrowser.staged"):K("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j.y,{value:Q,onChange:R}),(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(),P(a)},className:`px-2 py-0.5 text-[11px] transition-colors ${O===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:K("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:()=>w(!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:()=>w(!1)})})}),M&&(0,e.jsx)(m.N,{filePath:X,content:c.newContent,cwd:a,onClose:()=>N(!1)}),D&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim",onClick:()=>E(null),children:(0,e.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,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:D.filePath}),(0,e.jsx)("button",{onClick:()=>E(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)(o._,{search:F}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-secondary",children:(0,e.jsx)("pre",{ref:G,className:"whitespace-pre-wrap break-words font-mono text-foreground",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,n.xb)(D.content)})})]})})]})}d()}catch(a){d(a)}})},57031:(a,b,c)=>{"use strict";c.d(b,{F:()=>g});var d=c(79606),e=c(23734),f=c(33281);let g=(a,b)=>{f.t4.runFork(d.flatMap(e.d,c=>c.publish(a,b)))}},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$:()=>I,vP:()=>E,zB:()=>J});var e=c(48249),f=c(67484),g=c(44384),h=c(79606),i=c(87819);c(57063);var j=c(7122),k=c(44256),l=c(67216),m=c(46674),n=c(145),o=c(20586),p=c(74691),q=c(60333),r=c(88018),s=c(35208),t=c(60591),u=c(73887),v=c(39238),w=c(18479),x=c(15578),y=c(39247),z=a([s,u,v]);[s,u,v]=z.then?(await z)():z;let K=(a,b,c)=>`/api/snapshots/blob?cwd=${encodeURIComponent(a)}&rev=${encodeURIComponent(b)}&file=${encodeURIComponent(c)}`;function A(a){return a.fullSubject||a.subject}function B(a,b,c){let d=A(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 C(a,b){if(b&&a.startsWith(b)){let c=a.slice(b.length);return c.startsWith("/")?c.slice(1):c}return a}function D(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=C(a.file_path,b);c.push({key:d.id,toolName:"Edit",subject:`[Edit] ${e}`,legacy:!0,changeClass:(0,x.q)(e),files:[{path:e,status:"modified",old_string:a.old_string,new_string:a.new_string,fileClass:(0,x.q)(e)}]})}}else if("Write"===d.name){let a=d.input;if(a.file_path&&"string"==typeof a.content){let e=C(a.file_path,b);c.push({key:d.id,toolName:"Write",subject:`[Write] ${e}`,legacy:!0,changeClass:(0,x.q)(e),files:[{path:e,status:"added",old_string:"",new_string:a.content,fileClass:(0,x.q)(e)}]})}}return c}function E(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),toolName:a.commit.toolName??"tool",subject:a.commit.subject,timestamp:a.commit.timestamp,truncated:!0===a.truncated,changeClass:(0,x.S)(a.files.map(a=>a.path)),files:a.files.map(a=>({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:b.size>0&&!b.has(a.path),fileClass:(0,x.q)(a.path)}))}});return d=f.length>0?f:D(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 F({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 G({cls:a}){return(0,e.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})}function H(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 I({toolCalls:a,cwd:b,sessionId:c,runId:d,onClose:k,onContentSearch:x}){let{t:z}=(0,g.Bd)(),C=(0,f.useRef)(null),[J,L]=(0,f.useState)(null),M=(0,f.useMemo)(()=>a.map(a=>a.id).filter(Boolean),[a]),N=M.join(","),[O,P]=(0,f.useState)(0),Q=(0,i.Z)(b&&M.length>0?(0,w.se)(b,M,c,d):h.succeed([]),[b,c,d,N,O]);(0,f.useMemo)(()=>a.filter(a=>(0,y.h)(a.name)).map(a=>a.id),[a]);let R=(0,f.useRef)([]),S="loading"===Q.status&&0===R.current.length,T=(0,f.useMemo)(()=>{if("success"===Q.status){let c=E(Q.data,a,b);return c.length>0&&(R.current=c),c}return"loading"===Q.status&&R.current.length>0?R.current:"loading"===Q.status?[]:D(a,b)},[Q,a,b]),[U,V]=(0,f.useState)(null),[W,X]=(0,f.useState)(null),[Y,Z]=(0,f.useState)(new Set),[$,_]=(0,f.useState)(()=>!0),[aa,ab]=(0,f.useState)("compact"),[ac,ad]=(0,f.useState)("unified"),[ae,af]=(0,f.useState)(!1),[ag,ah]=(0,f.useState)(!1),[ai,aj]=(0,f.useState)(null),ak=(0,f.useMemo)(()=>T.find(a=>a.key===U)??null,[T,U]),al=(0,f.useRef)(null),am=ak??al.current,an=(0,f.useMemo)(()=>am?(0,o.Do)(am.files):[],[am]),ao=(0,f.useMemo)(()=>am?.files.find(a=>a.path===W)??null,[am,W]),ap=(0,f.useCallback)(a=>{V(a.key),X(a.files[0]?.path??null),Z(new Set((0,o.Sz)((0,o.Do)(a.files))))},[]),aq=(0,f.useMemo)(()=>T.reduce((a,b)=>a+b.files.length,0),[T]),ar=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:J,children:(0,e.jsxs)("div",{ref:C,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:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>_(a=>!a),"aria-label":z("diffViewer.toggleFileTree"),className:`p-1 rounded transition-colors ${$?"text-foreground bg-accent":"text-muted-foreground hover:text-foreground hover:bg-hover"}`,children:(0,e.jsx)(l.A,{className:"w-4 h-4"})}),(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground",children:z("diffViewer.fileChanges",{count:aq})})]}),(0,e.jsx)("button",{onClick:k,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(m.A,{className:"w-5 h-5"})})]}),(0,e.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[$&&(0,e.jsx)("div",{className:"w-60 flex-shrink-0 border-r border-border overflow-y-auto",children:T.map(a=>{let b;return(0,e.jsxs)("div",{onClick:()=>ap(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${U===a.key?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[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:H(a.timestamp)}),a.changeClass&&(0,e.jsx)("span",{className:"ml-auto",children:(0,e.jsx)(G,{cls:a.changeClass})})]}),(0,e.jsx)("div",{className:"text-sm text-foreground whitespace-pre-wrap break-words mt-0.5","data-tooltip":A(a),children:B(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:z("commitDetail.nChanges",{count:a.files.length})}),(b=function(a){let b=!1,c=0,d=0;for(let e of a.files)(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}(a))&&(b.additions>0||b.deletions>0)?(0,e.jsx)(F,{additions:b.additions,deletions:b.deletions}):null]})]},a.key)})}),(0,e.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:S?ar(z("diffViewer.loadingSnapshots")):0===T.length?ar(z("diffViewer.noChanges")):am?(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:[(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(n.A,{className:"w-3.5 h-3.5"}),am.toolName]}),am.shortHash&&(0,e.jsx)("span",{className:"font-mono text-brand",children:am.shortHash}),void 0!==am.timestamp&&(0,e.jsx)("span",{children:H(am.timestamp)}),(0,e.jsx)("span",{className:"flex-1 min-w-0 whitespace-pre-wrap break-words","data-tooltip":A(am),children:B(am,640,6)}),am.truncated&&(0,e.jsx)("span",{className:"text-amber-11",children:z("diffViewer.truncated")}),am.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":z("diffViewer.reconstructedHint"),children:z("diffViewer.reconstructed")}),(0,e.jsx)("div",{className:"ml-auto flex items-center gap-2",children:!ao?.isImage&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.y,{value:aa,onChange:ab}),(0,e.jsx)(q.q,{value:ac,onChange:ad})]})})]}),(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:(0,e.jsx)(o.VO,{files:an,selectedPath:W,expandedPaths:Y,onToggle:a=>Z(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c}),onSelect:a=>{!a.isDirectory&&a.file&&X(a.file.path)},cwd:b||"",showChanges:!0,renderActions:a=>{if(a.isDirectory)return null;let b=a.file;return b?(0,e.jsxs)(e.Fragment,{children:[b.fileClass&&(0,e.jsx)(G,{cls:b.fileClass}),b.external&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0","data-tooltip":z("diffViewer.externalChange")})]}):null}})}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:ao?ao.isImage?(0,e.jsx)(r.K,{filePath:ao.path,oldSrc:b&&ao.oldRev?K(b,ao.oldRev,ao.path):null,newSrc:b&&ao.newRev?K(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:z("diffViewer.notViewable")}):"unified"===ac?(0,e.jsx)(s.xU,{oldContent:ao.old_string,newContent:ao.new_string,filePath:ao.path,cwd:b,enableComments:!0,onContentSearch:x,compact:"compact"===aa,onPreview:"deleted"===ao.status?void 0:(0,t.e$)(ao.path)?()=>af(!0):(0,t.aR)(ao.path)?()=>ah(!0):ao.path.endsWith(".json")?()=>aj({content:ao.new_string,filePath:ao.path}):void 0,previewLabel:ao.path.endsWith(".json")?z("common.readable"):z("common.preview")}):(0,e.jsx)(s.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:x,compact:"compact"===aa,onPreview:"deleted"===ao.status?void 0:(0,t.e$)(ao.path)?()=>af(!0):(0,t.aR)(ao.path)?()=>ah(!0):ao.path.endsWith(".json")?()=>aj({content:ao.new_string,filePath:ao.path}):void 0,previewLabel:ao.path.endsWith(".json")?z("common.readable"):z("common.preview")}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:z("diffViewer.selectFileToView")})})]})]}):ar(z("diffViewer.selectFileToView"))})]}),ae&&ao&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>af(!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)(u.M,{content:ao.new_string,filePath:ao.path,cwd:b||"",onClose:()=>af(!1)})})}),ag&&ao&&(0,e.jsx)(v.N,{filePath:ao.path,content:ao.new_string,cwd:b,onClose:()=>ah(!1),onContentSearch:x}),ai&&(0,e.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-scrim p-2 md:p-4",onClick:()=>aj(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:ai.filePath}),(0,e.jsx)("button",{onClick:()=>aj(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",children:(0,e.jsx)(m.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,t.xb)(ai.content)})})]})})]})})}function J({toolCalls:a,cwd:b,sessionId:c,runId:d,onClose:f,onContentSearch:g}){return(0,e.jsx)(k.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim",onClick:f,children:(0,e.jsx)(I,{toolCalls:a,cwd:b,sessionId:c,runId:d,onClose:f,onContentSearch:g?a=>{f(),g(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:()=>F});var e=c(48249),f=c(67484),g=c(41927),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(62473),q=c(86686),r=c(75513),s=c(81206),t=c(97951),u=c(99843),v=c(36702),w=c(43209),x=c(95401),y=c(42910),z=c(65139),A=c(47604),B=c(60812),C=c(84844),D=c(44384),E=a([u]);function F({tabId:a,initialCwd:b,initialSessionId:c,engine:d,onEngineChange:E,ollamaModel:G,onOllamaModelChange:H,deepseekModel:I,onDeepseekModelChange:J,kimiModel:K,onKimiModelChange:L,glmModel:M,onGlmModelChange:N,claudeModel:O,onClaudeModelChange:P,claudeEffort:Q,onClaudeEffortChange:R,claudeContextWindow:S,onClaudeContextWindowChange:T,claudeFastMode:U,onClaudeFastModeChange:V,claudeThinking:W,onClaudeThinkingChange:X,codexModel:Y,onCodexModelChange:Z,codexReasoningEffort:$,onCodexReasoningEffortChange:_,planMode:aa,onPlanModeChange:ab,noHistory:ac,onNoHistoryChange:ad,hideHeader:ae,hideSidebar:af,isActive:ag=!0,refreshSignal:ah,onLoadingChange:ai,onSessionIdChange:aj,onTitleChange:ak,onShowGitStatus:al,onOpenNote:am,onCreateScheduledTask:an,onOpenSession:ao,onContentSearch:ap,onShowFileDiff:aq,onOpenFileLink:ar,onOpenSessionBrowser:as,onOpenSettings:at}){let{t:au}=(0,D.Bd)();(0,r.nH)();let[av,aw]=(0,f.useState)([]),[ax,ay]=(0,f.useState)(null),[az,aA]=(0,f.useState)(!1),[aB,aC]=(0,f.useState)(!1),[aD,aE]=(0,f.useState)(!1),[aF,aG]=(0,f.useState)(!1),[aH,aI]=(0,f.useState)(null),[aJ,aK]=(0,f.useState)(!1),aL=aa??aJ,aM=(0,f.useCallback)(a=>{aK(a),ab?.(a)},[ab]),[aN,aO]=(0,f.useState)(!1),aP=ac??aN,aQ=(0,f.useCallback)(a=>{aO(a),ad?.(a)},[ad]),[aR,aS]=(0,f.useState)(!1),aT=(0,f.useRef)(null);(0,f.useRef)(null);let aU=(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?ak?.(c.value.title):"Failure"===c._tag&&console.error("Failed to fetch session title:",c.cause)},[b,ak]),aV=(0,f.useRef)(null),[aW,aX]=(0,f.useState)(!1),[aY,aZ]=(0,f.useState)(null),[a$,a_]=(0,f.useState)(null),[a0,a1]=(0,f.useState)(t.R),a2=(0,f.useRef)(!1),{isLoadingHistory:a3,isLoadingMore:a4,hasMoreHistory:a5,loadMoreHistory:a6,loadHistoryByCwdAndSessionId:a7,loadedSessionId:a8,loadedEngine:a9}=(0,s.m)(av,aw,ax,{cwd:b,initialSessionId:c,onSessionId:ay,onTitleChange:ak,onTokenUsage:aI,liveRunningRef:a2}),ba=a9??d??void 0,bb=!ba||"claude"===ba,bc="codex"===ba,bd=O??z.BV,be=(0,z.NR)(bd,Q),bf=(0,z.OO)(bd,S),bg=Y??z.kn,bh=(0,z.oJ)(bg,$),bi="deepseek"===ba||"kimi"===ba||"glm"===ba?ba:null,bj="kimi"===bi?K:"glm"===bi?M:I,bk="kimi"===bi?L:"glm"===bi?N:J,bl="ollama"===ba||null!==bi||bb||bc,{isLoading:bm,tokenUsage:bn,liveOutputTokens:bo,runningStartedAt:bp,rateLimitInfo:bq,apiRetryInfo:br,backgroundTasks:bs,handleSend:bt,handleStop:bu}=(0,t.e)(av,aw,{sessionId:ax,cwd:b,engine:ba,planMode:aL,noHistory:aP,ollamaModel:G,engineModel:bj,claudeModel:bd,claudeEffort:be,claudeContextWindow:bf,claudeFastMode:U,claudeThinking:W,codexModel:bg,codexReasoningEffort:bh,onSessionId:ay,onFetchTitle:aU,onRunComplete:()=>aV.current?.()}),bv=(0,f.useCallback)(async(a,c)=>{let d=a.split("\n")[0];if(bb){let b=/^\/plan(?:\s+([\s\S]*))?$/.exec(a.trim());if(b){let a=(b[1]??"").trim();"off"===a.toLowerCase()?(aM(!1),(0,i.oR)(au("chat.planModeOff",{defaultValue:"Plan mode off"}),"info")):""===a?(aM(!0),(0,i.oR)(au("chat.planModeOn",{defaultValue:"Plan mode on"}),"success")):(aM(!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=au("chat.executedCommand",{command:e,exitInfo:d,output:b});f&&(h+=`
|
|
26
27
|
|
|
27
|
-
${f}`),br(h,c)}else br(au("chat.executedCommandFailed",{command:e,error:g.cause}),c);return}br(a,c)},[br,b,au,a9,aM]),bu=(0,f.useCallback)(()=>{aM(!1),br(au("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[br,aM,au]),bv=a6||ax,bw=ag&&!bk&&!!bv;(0,j.u)(bv,aw,bw,a8,{onRunningChange:a=>{a0.current=a,aX(a)},onLiveOutputTokens:aZ,onRunStartedAt:a_,onComplete:()=>{b&&bv&&a5(b,bv,!0,10)}}),(0,f.useRef)(ag),(0,f.useRef)(0);let bx=bl||aH,by=bk?bm:aW?aY:null,bz=bk?bn:aW?a$:null;(0,f.useRef)(!1);let bA=(0,f.useCallback)(async(a,c)=>{let d=a6??ax;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;ao?ao(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?au("toast.excerptFailed",{defaultValue:"Failed to excerpt this turn"}):au("toast.forkFailed",{defaultValue:"Failed to fork session"}),"error"))},[b,a6,ax,ao,au]),bB=(0,f.useRef)(bA);bB.current=bA;let bC=(0,f.useRef)((a,b)=>bB.current(a,b)).current,bD=(0,f.useCallback)(()=>{aE(!0)},[]),bE=(0,f.useCallback)(()=>{aG(!0)},[]),bF=(0,f.useMemo)(()=>{if(an&&b&&a)return c=>{an({...c,cwd:b,tabId:a,sessionId:ax??crypto.randomUUID(),engine:a8,..."ollama"===a8&&G&&{model:G},...bg&&bh&&{model:bh},...a9&&{model:bb},...ba&&{model:be}})}},[an,b,a,ax,a8,G,bg,bh,a9,bb,ba,be]),bG=bj?(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer select-none",title:au("chat.noHistoryHint",{defaultValue:"Independent task: each message is sent to the model on its own, with no prior conversation. The transcript above still records everything."}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"nohistory-toggle",checked:aP,onChange:a=>aQ(a.target.checked),className:"accent-brand"}),(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"}),au("chat.noHistory",{defaultValue:"Independent task"})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:au("chat.noHistoryDesc",{defaultValue:"no history sent"})})]}):null;return(0,e.jsxs)("div",{className:`flex ${ae&&af?"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:()=>aA(!0),onMouseLeave:()=>aA(!1),children:[!ae&&(0,e.jsx)(o.e,{cwd:b,sessionId:ax,engine:a8,onOpenProjectSessions:()=>aC(!0),onOpenSessionBrowser:as,onOpenSettings:at}),(a9||ba)&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[(0,e.jsx)(z.Yd,{engine:ba?"codex":"claude",claudeModel:bb,onClaudeModelChange:P,claudeEffort:bc,onClaudeEffortChange:R,claudeContextWindow:bd,onClaudeContextWindowChange:T,claudeFastMode:U,onClaudeFastModeChange:V,claudeThinking:W,onClaudeThinkingChange:X,codexModel:be,onCodexModelChange:Z,codexReasoningEffort:bf,onCodexReasoningEffortChange:_}),a9&&(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer select-none",title:au("chat.planModeHint",{defaultValue:"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement."}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:aL,onChange:a=>aM(a.target.checked),className:"accent-brand"}),(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"}),au("chat.planMode",{defaultValue:"Plan mode"})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:au("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"})})]}),bG]}),"ollama"===a8&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[H&&(0,e.jsx)(x.m,{currentModel:G,onModelChange:H}),bG]}),bg&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[bi&&(0,e.jsx)(y.Z,{engine:bg,currentModel:bh,onModelChange:bi,onHasKeyChange:aS}),bG,(0,e.jsx)("div",{className:"ml-auto pl-2",children:"deepseek"===bg?(0,e.jsx)(A.f,{hasKey:aR}):(0,e.jsx)(B.J,{engine:bg,hasKey:aR})})]}),a1?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:au("sessions.loadingHistory")})}):(0,e.jsx)(u.M,{ref:aT,messages:av,isLoading:bk||aW,liveOutputTokens:by,runningStartedAt:bz,cwd:b,sessionId:ax,engine:a8,apiRetryInfo:bp,backgroundTasks:bq,hasMoreHistory:a3,isLoadingMore:a2,onLoadMore:a4,onFork:bC,isActive:ag,onContentSearch:ap,onShowFileDiff:aq,onOpenFileLink:ar,onApprovePlan:bu}),bx&&(0,e.jsx)(p.g,{tokenUsage:bx,rateLimitInfo:bo}),(0,e.jsx)(v.V,{onSend:bt,disabled:bk||aW,cwd:b,engine:a8,onShowGitStatus:al,onShowComments:b?bD:void 0,onShowUserMessages:bE,onOpenNote:am,onCreateScheduledTask:bF})]}),!ae&&b&&(0,e.jsx)(w.Q,{isOpen:aB,onClose:()=>aC(!1),cwd:b}),b&&(0,e.jsx)(C.i,{isOpen:aD,onClose:()=>aE(!1),cwd:b}),(0,e.jsx)(q.f,{isOpen:aF,onClose:()=>aG(!1),messages:av,onSelectMessage:a=>{aT.current?.scrollToMessage(a)}})]})}u=(E.then?(await E)():E)[0],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.match({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.gen(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.gen(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";function d(){}function e(a){return()=>{}}c.d(b,{U:()=>e,k:()=>d})},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))})}},60591:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,C_:()=>v,Hz:()=>u,WU:()=>w,Zy:()=>t,aR:()=>s,cG:()=>i,d9:()=>j,e$:()=>r,jU:()=>g,oK:()=>x,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,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 x(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(98356),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",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},f={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,d.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"env"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},61632:(a,b,c)=>{"use strict";c.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=(0,d.useCallback)(()=>{D(!0),P(null),i.t4.runPromise((0,j.r4)(a).pipe(h.match({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]),am=(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.match({onSuccess:a=>{let b=a.commits||[];p(b),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>F(!1))},[a]),an=(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.match({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]),ao=(0,d.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&an()},[an]),ap=(0,d.useCallback)(b=>{r(b),z(null),B(null),L(!0),i.t4.runPromise((0,j.Zi)(a,b.hash).pipe(h.match({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]),aq=(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.match({onSuccess:a=>B(a),onFailure:a=>{console.error(a)}}))).finally(()=>N(!1)))},[a,q,b]),ar=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),as=(0,d.useCallback)(b=>{ai(!0),ae(null),ag(null),i.t4.runPromise((0,j.yy)(a,b).pipe(h.match({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]),at=(0,d.useCallback)(c=>{ae(c),b(c.path),ak(!0),i.t4.runPromise((0,j.yy)(a,X,c.path).pipe(h.match({onSuccess:a=>ag(a),onFailure:a=>{console.error(a)}}))).finally(()=>ak(!1))},[a,X,b]),au=(0,d.useCallback)(a=>{ac(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),av=(0,d.useCallback)(a=>{if(U(a),a){let a="origin/main";Y(a),as(a)}else $([]),aa([]),ae(null),ag(null),Y("")},[V,as]);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:al,loadCommits:am,loadMoreCommits:an,handleCommitListScroll:ao,handleSelectCommit:ap,handleSelectHistoryFile:aq,handleHistoryToggle:ar,handleCommitInfoMouseMove:(0,d.useCallback)(a=>{S({x:a.clientX,y:a.clientY})},[]),handleCommitInfoMouseLeave:(0,d.useCallback)(()=>{S(null)},[]),compareMode:T,toggleCompareMode:av,compareBaseBranch:X,setCompareBaseBranch:Y,upstreamBranch:V,compareFiles:Z,compareFileTree:_,compareExpandedPaths:ab,compareSelectedFile:ad,compareFileDiff:af,isLoadingCompareFiles:ah,isLoadingCompareDiff:aj,handleSelectCompareFile:at,handleCompareToggle:au,loadCompareFiles:as}}},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}`),bt(h,c)}else bt(au("chat.executedCommandFailed",{command:e,error:g.cause}),c);return}bt(a,c)},[bt,b,au,bb,aM]),bw=(0,f.useCallback)(()=>{aM(!1),bt(au("chat.approvePlanPrompt",{defaultValue:"已批准,按上述计划开始执行。"}),void 0,{permissionMode:null})},[bt,aM,au]),bx=a8||ax,by=ag&&!bm&&!!bx;(0,j.u)(bx,aw,by,ba,{onRunningChange:a=>{a2.current=a,aX(a)},onLiveOutputTokens:aZ,onRunStartedAt:a_,onBackgroundTasks:a=>a1(a.length?a:t.R),onComplete:()=>{b&&bx&&a7(b,bx,!0,10)}}),(0,f.useRef)(ag),(0,f.useRef)(0);let bz=bn||aH,bA=bm?bo:aW?aY:null,bB=bm?bp:aW?a$:null,bC=bm?bs:aW?a0:t.R;(0,f.useRef)(!1);let bD=(0,f.useCallback)(async(a,c)=>{let d=a8??ax;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;ao?ao(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?au("toast.excerptFailed",{defaultValue:"Failed to excerpt this turn"}):au("toast.forkFailed",{defaultValue:"Failed to fork session"}),"error"))},[b,a8,ax,ao,au]),bE=(0,f.useRef)(bD);bE.current=bD;let bF=(0,f.useRef)((a,b)=>bE.current(a,b)).current,bG=(0,f.useCallback)(()=>{aE(!0)},[]),bH=(0,f.useCallback)(()=>{aG(!0)},[]),bI=(0,f.useMemo)(()=>{if(an&&b&&a)return c=>{an({...c,cwd:b,tabId:a,sessionId:ax??crypto.randomUUID(),engine:ba,..."ollama"===ba&&G&&{model:G},...bi&&bj&&{model:bj},...bb&&{model:bd},...bc&&{model:bg}})}},[an,b,a,ax,ba,G,bi,bj,bb,bd,bc,bg]),bJ=bl?(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer select-none",title:au("chat.noHistoryHint",{defaultValue:"Independent task: each message is sent to the model on its own, with no prior conversation. The transcript above still records everything."}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"nohistory-toggle",checked:aP,onChange:a=>aQ(a.target.checked),className:"accent-brand"}),(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(g.A,{className:"w-3.5 h-3.5"}),au("chat.noHistory",{defaultValue:"Independent task"})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:au("chat.noHistoryDesc",{defaultValue:"no history sent"})})]}):null;return(0,e.jsxs)("div",{className:`flex ${ae&&af?"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:()=>aA(!0),onMouseLeave:()=>aA(!1),children:[!ae&&(0,e.jsx)(o.e,{cwd:b,sessionId:ax,engine:ba,onOpenProjectSessions:()=>aC(!0),onOpenSessionBrowser:as,onOpenSettings:at}),(bb||bc)&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[(0,e.jsx)(z.Yd,{engine:bc?"codex":"claude",claudeModel:bd,onClaudeModelChange:P,claudeEffort:be,onClaudeEffortChange:R,claudeContextWindow:bf,onClaudeContextWindowChange:T,claudeFastMode:U,onClaudeFastModeChange:V,claudeThinking:W,onClaudeThinkingChange:X,codexModel:bg,onCodexModelChange:Z,codexReasoningEffort:bh,onCodexReasoningEffortChange:_}),bb&&(0,e.jsxs)("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer select-none",title:au("chat.planModeHint",{defaultValue:"Plan mode: read-only exploration that produces a plan without editing. Uncheck and resend to implement."}),children:[(0,e.jsx)("input",{type:"checkbox","data-testid":"planmode-toggle",checked:aL,onChange:a=>aM(a.target.checked),className:"accent-brand"}),(0,e.jsxs)("span",{className:"flex items-center gap-1 text-foreground",children:[(0,e.jsx)(h.A,{className:"w-3.5 h-3.5"}),au("chat.planMode",{defaultValue:"Plan mode"})]}),(0,e.jsx)("span",{className:"text-muted-foreground",children:au("chat.planModeDesc",{defaultValue:"read-only \xb7 plan first, no edits"})})]}),bJ]}),"ollama"===ba&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[H&&(0,e.jsx)(x.m,{currentModel:G,onModelChange:H}),bJ]}),bi&&(0,e.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card/50",children:[bk&&(0,e.jsx)(y.Z,{engine:bi,currentModel:bj,onModelChange:bk,onHasKeyChange:aS}),bJ,(0,e.jsx)("div",{className:"ml-auto pl-2",children:"deepseek"===bi?(0,e.jsx)(A.f,{hasKey:aR}):(0,e.jsx)(B.J,{engine:bi,hasKey:aR})})]}),a3?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,e.jsx)("span",{className:"text-muted-foreground",children:au("sessions.loadingHistory")})}):(0,e.jsx)(u.M,{ref:aT,messages:av,isLoading:bm||aW,liveOutputTokens:bA,runningStartedAt:bB,cwd:b,sessionId:ax,engine:ba,apiRetryInfo:br,backgroundTasks:bC,hasMoreHistory:a5,isLoadingMore:a4,onLoadMore:a6,onFork:bF,isActive:ag,onContentSearch:ap,onShowFileDiff:aq,onOpenFileLink:ar,onApprovePlan:bw}),bz&&(0,e.jsx)(p.g,{tokenUsage:bz,rateLimitInfo:bq}),(0,e.jsx)(v.V,{onSend:bv,disabled:bm||aW,cwd:b,engine:ba,onShowGitStatus:al,onShowComments:b?bG:void 0,onShowUserMessages:bH,onOpenNote:am,onCreateScheduledTask:bI})]}),!ae&&b&&(0,e.jsx)(w.Q,{isOpen:aB,onClose:()=>aC(!1),cwd:b}),b&&(0,e.jsx)(C.i,{isOpen:aD,onClose:()=>aE(!1),cwd:b}),(0,e.jsx)(q.f,{isOpen:aF,onClose:()=>aG(!1),messages:av,onSelectMessage:a=>{aT.current?.scrollToMessage(a)}})]})}u=(E.then?(await E)():E)[0],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.match({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.gen(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.gen(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";function d(){}function e(a){return()=>{}}c.d(b,{U:()=>e,k:()=>d})},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))})}},60591:(a,b,c)=>{"use strict";c.d(b,{C6:()=>h,C_:()=>v,Hz:()=>u,WU:()=>w,Zy:()=>t,aR:()=>s,cG:()=>i,d9:()=>j,e$:()=>r,jU:()=>g,oK:()=>x,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,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 x(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(98356),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",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},f={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function g({name:a,className:b="",size:c=16}){let h,i=f[h=a.toLowerCase()]?f[h]:e[a.split(".").pop()?.toLowerCase()||""]||e.default,j=a.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:i}),(0,d.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===j||"tsx"===j&&a.includes("component")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:i})]}):["md","mdx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,d.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,d.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:i}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,d.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,d.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:i,strokeWidth:"2",fill:"none"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:i}),(0,d.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:i,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:i}),(0,d.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"html"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:i}),(0,d.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(j)?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,d.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===j||".gitignore"===a.toLowerCase()?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:i}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,d.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===j||"dockerfile"===a.toLowerCase()||a.toLowerCase().startsWith("dockerfile")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:i}),(0,d.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"env"===j||a.startsWith(".env")?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:i}),(0,d.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:i,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:i,strokeWidth:"1.5",fill:"none"})]}):"vue"===j?(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:i}),(0,d.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,d.jsxs)("svg",{width:c,height:c,viewBox:"0 0 24 24",fill:"none",className:b,children:[(0,d.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:i,strokeWidth:"1.5",fill:"none"}),(0,d.jsx)("path",{d:"M14 3v5h5",stroke:i,strokeWidth:"1.5",fill:"none"})]})}},61632:(a,b,c)=>{"use strict";c.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=(0,d.useCallback)(()=>{D(!0),P(null),i.t4.runPromise((0,j.r4)(a).pipe(h.match({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]),am=(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.match({onSuccess:a=>{let b=a.commits||[];p(b),J(b.length>=f.B_)},onFailure:a=>{console.error(a)}}))).finally(()=>F(!1))},[a]),an=(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.match({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]),ao=(0,d.useCallback)(a=>{let{scrollTop:b,scrollHeight:c,clientHeight:d}=a.target;c-b-d<100&&an()},[an]),ap=(0,d.useCallback)(b=>{r(b),z(null),B(null),L(!0),i.t4.runPromise((0,j.Zi)(a,b.hash).pipe(h.match({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]),aq=(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.match({onSuccess:a=>B(a),onFailure:a=>{console.error(a)}}))).finally(()=>N(!1)))},[a,q,b]),ar=(0,d.useCallback)(a=>{x(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),as=(0,d.useCallback)(b=>{ai(!0),ae(null),ag(null),i.t4.runPromise((0,j.yy)(a,b).pipe(h.match({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]),at=(0,d.useCallback)(c=>{ae(c),b(c.path),ak(!0),i.t4.runPromise((0,j.yy)(a,X,c.path).pipe(h.match({onSuccess:a=>ag(a),onFailure:a=>{console.error(a)}}))).finally(()=>ak(!1))},[a,X,b]),au=(0,d.useCallback)(a=>{ac(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),av=(0,d.useCallback)(a=>{if(U(a),a){let a="origin/main";Y(a),as(a)}else $([]),aa([]),ae(null),ag(null),Y("")},[V,as]);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:al,loadCommits:am,loadMoreCommits:an,handleCommitListScroll:ao,handleSelectCommit:ap,handleSelectHistoryFile:aq,handleHistoryToggle:ar,handleCommitInfoMouseMove:(0,d.useCallback)(a=>{S({x:a.clientX,y:a.clientY})},[]),handleCommitInfoMouseLeave:(0,d.useCallback)(()=>{S(null)},[]),compareMode:T,toggleCompareMode:av,compareBaseBranch:X,setCompareBaseBranch:Y,upstreamBranch:V,compareFiles:Z,compareFileTree:_,compareExpandedPaths:ab,compareSelectedFile:ad,compareFileDiff:af,isLoadingCompareFiles:ah,isLoadingCompareDiff:aj,handleSelectCompareFile:at,handleCompareToggle:au,loadCompareFiles:as}}},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
29
|
(function () {
|
|
29
30
|
if (window.cockpit) return;
|
|
30
31
|
|
|
@@ -726,9 +727,9 @@ ${f}`),br(h,c)}else br(au("chat.executedCommandFailed",{command:e,error:g.cause}
|
|
|
726
727
|
try { if (ws) ws.close(); } catch (e) {}
|
|
727
728
|
});
|
|
728
729
|
})();
|
|
729
|
-
`;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:()=>h,NR:()=>t,OO:()=>v,Yd:()=>y,kn:()=>i,oJ:()=>o});var d=c(48249),e=c(67484),f=c(44256),g=c(63565);let h="claude-opus-5",i="gpt-5.6-sol",j=[{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"}],k=[{id:"claude-sonnet-5",label:"Claude Sonnet 5",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-opus-5",label:"Claude Opus 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-fable-5-1",label:"Claude Fable 5.1",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-fable-5",label:"Claude Fable 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-opus-4-8",label:"Claude Opus 4.8",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",fast:!0},{id:"claude-opus-4-7",label:"Claude Opus 4.7",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"xhigh",fast:!0},{id:"claude-opus-4-6",label:"Claude Opus 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",thinking:!0}],l=[{id:"minimal",label:"Minimal"},{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"}],m=[{id:"gpt-5.6-sol",label:"GPT-5.6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-terra",label:"GPT-5.6-Terra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-luna",label:"GPT-5.6-Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"}];function n(a){return m.find(b=>b.id===a)?.defaultReasoning??"low"}function o(a,b){let c=m.find(b=>b.id===a)?.reasoning;return b&&(!c||c.includes(b))?b:n(a)}function p(a,b){return a.find(a=>a.id===b)?.label??b}function q(a){return k.find(b=>b.id===a)?.fast===!0}function r(a){return k.find(b=>b.id===a)?.thinking===!0}function s(a){let b=k.find(b=>b.id===a);return b?b.defaultEffort:"high"}function t(a,b){let c=k.find(b=>b.id===a),d=c?.effort;return b&&(!c||d?.includes(b))?b:s(a)}function u(a){let b=k.find(b=>b.id===a);return b?b.defaultContext:"200k"}function v(a,b){let c=k.find(b=>b.id===a),d=c?.context;return b&&(!c||d?.includes(b))?b:u(a)}function w({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 x({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)(w,{value:a.id,selected:b===a.id,label:a.label,defaultValue:a.defaultValue,onSelect:a=>{i(a),o(!1)}},a.id))})]})})]})}function y(a){let b,c,e=a.engine??"claude",f=a.claudeModel??h,w=s(f),y=(b=k.find(a=>a.id===f)?.effort)?b.map(a=>j.find(b=>b.id===a)??{id:a,label:a}):[],z=t(f,a.claudeEffort),A=u(f),B=k.find(a=>a.id===f)?.context??[],C=v(f,a.claudeContextWindow),D=a.claudeFastMode??!1,E=a.claudeThinking??!1,F=a.codexModel??i,G=n(F),H=(c=m.find(a=>a.id===F)?.reasoning)?c.map(a=>l.find(b=>b.id===a)??{id:a,label:a}):l,I=o(F,a.codexReasoningEffort);return"claude"!==e?(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(x,{title:"Model",selected:F,value:p(m,F),items:m.map(a=>({id:a.id,label:a.label,defaultValue:a.id===i})),onSelect:b=>{a.onCodexModelChange?.(b),a.onCodexReasoningEffortChange?.(n(b))},icon:(0,d.jsx)(g.eV,{engine:"codex"}),testId:"codex-model-picker"}),(0,d.jsx)(x,{title:"Reasoning",selected:I,value:p(l,I),items:H.map(a=>({...a,defaultValue:a.id===G})),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)(x,{title:"Model",selected:f,value:p(k,f),items:k.map(a=>({id:a.id,label:a.label,defaultValue:a.id===h})),onSelect:b=>{a.onClaudeModelChange?.(b);let c=s(b),d=u(b);c&&a.onClaudeEffortChange?.(c),d&&a.onClaudeContextWindowChange?.(d),q(b)||a.onClaudeFastModeChange?.(!1),r(b)||a.onClaudeThinkingChange?.(!1)},icon:(0,d.jsx)(g.eV,{engine:"claude"}),testId:"claude-model-picker"}),z&&y.length>0&&(0,d.jsx)(x,{title:"Reasoning",selected:z,value:p(j,z),items:y.map(a=>({...a,defaultValue:a.id===w})),onSelect:b=>a.onClaudeEffortChange?.(b),testId:"claude-reasoning-picker"}),C&&B.length>0&&(0,d.jsx)(x,{title:"Context Window",selected:C,value:"1m"===C?"1M":"200K",items:B.map(a=>({id:a,label:"1m"===a?"1M":"200K",defaultValue:a===A})),onSelect:b=>a.onClaudeContextWindowChange?.(b),testId:"claude-context-picker"}),q(f)&&(0,d.jsx)(x,{title:"Fast Mode",selected:D?"on":"off",value:D?"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"}),r(f)&&(0,d.jsx)(x,{title:"Thinking",selected:E?"on":"off",value:E?"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:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,It:()=>s,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b,c)=>d.tryPromise({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=()=>f("/api/pick-folder"),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},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})}},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>ah});var e=c(48249),f=c(67484),g=c.n(f),h=c(74429),i=c(44256),j=c(33281),k=c(87808),l=c(25419),m=c(85655),n=c(21538),o=c(35208),p=c(74691),q=c(60333),r=c(7833),s=c(24724),t=c(20586),u=c(7122),v=c(55287),w=c(60591),x=c(19593),y=c(64825),z=c(66400),A=c(86588),B=c(64676),C=c(6478),D=c(34728),E=c(9804),F=c(73887),G=c(40893),H=c(92608),I=c(94239),J=c(29939),K=c(23860),L=c(7031),M=c(83721),N=c(25667),O=c(57014),P=c(46242),Q=c(21787),R=c(94308),S=c(53036),T=c(91975),U=c(6662),V=c(20291),W=c(58904),X=c(61632),Y=c(41357),Z=c(76855),$=c(4857),_=c(44384),aa=c(18921),ab=c(28797),ac=c(23881),ad=c(21672),ae=c(21482),af=c(94192),ag=a([n,N,o,F,v,O]);[n,N,o,F,v,O]=ag.then?(await ag)():ag;let ah=g().memo(function({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:g,searchQueryTrigger:ag,fileOpenRequest:ah}){let ai,aj,ak,al,am,an,{t:ao}=(0,_.Bd)(),ap=(0,L.r)(),aq=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.fileMessage",{path:a}))},[ap,ao]),ar=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.stagedFileMessage",{path:a}))},[ap,ao]),as=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.unstagedFileMessage",{path:a}))},[ap,ao]),at=(0,C.P)(),au=(0,D.U)(),{activeView:av,onViewChange:aw}=(0,af.R8)(),[ax,ay]=(0,f.useState)(c),[az,aA]=(0,f.useState)("code"),aB=(0,f.useRef)(null),aC=(0,f.useRef)(!1),[aD,aE]=(0,f.useState)(null),[aF,aG]=(0,f.useState)(null),[aH,aI]=(0,f.useState)(!1),aJ=(0,f.useRef)(1),aK=(0,f.useRef)(null),[aL,aM]=(0,f.useState)(null),aN=(0,f.useRef)(null),[aO,aP]=(0,f.useState)({isDirty:!1,isSaving:!1}),[aQ,aR]=(0,f.useState)(!1),[aS,aT]=(0,f.useState)(null),[aU,aV]=(0,f.useState)("compact"),[aW,aX]=(0,f.useState)("unified"),[aY,aZ]=(0,f.useState)("full"),[a$,a_]=(0,f.useState)("unified"),[a0,a1]=(0,f.useState)(320),a2=(0,f.useRef)(null),a3=(0,f.useCallback)(a=>{"mouse"===a.pointerType&&0===a.button&&(a.preventDefault(),a2.current={startX:a.clientX,startWidth:a0},a.currentTarget.setPointerCapture(a.pointerId))},[a0]),a4=(0,f.useCallback)(a=>{let b=a2.current;if(!b)return;let c=b.startWidth+(a.clientX-b.startX);a1(Math.min(480,Math.max(320,c)))},[]),a5=(0,f.useCallback)(a=>{a2.current&&(a2.current=null,a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId))},[]),a6=(0,f.useRef)(null),a7=(0,aa.o)(a6),a8=(0,f.useRef)(null),a9=(0,aa.o)(a8),ba=(0,Z.Sn)(b),bb=(0,Z.Xm)(b),bc=(0,Z.po)(b),bd=(0,$.Q)(),be=(0,K.F)(),bf=(0,U.W)({cwd:b});(0,Z.JL)(b,bf.selectedPath);let bg=(0,f.useMemo)(()=>{let a=bf.fileContent,b=bf.selectedPath;return a&&"text"===a.type&&"string"==typeof a.content&&b&&(0,w.Hz)(b)?(0,w.xb)(a.content,w.cG):null},[bf.fileContent,bf.selectedPath]),[bh,bi]=(0,f.useState)({version:0,collapsed:!1}),bj=(0,V.p)({cwd:b,onSearchComplete:()=>aR(!0)}),bk=(0,W.e)({cwd:b,addToRecentFiles:bf.addToRecentFiles}),bl=(0,f.useMemo)(()=>{let a=new Set;if(bk.status){for(let b of bk.status.staged)a.add(b.path);for(let b of bk.status.unstaged)a.add(b.path)}return a},[bk.status]),bm=(0,f.useMemo)(()=>{let a=new Map;if(bk.status){for(let b of bk.status.staged)a.set(b.path,"staged");for(let b of bk.status.unstaged)a.set(b.path,"unstaged")}return a},[bk.status]),bn=(0,X.y)({cwd:b,addToRecentFiles:bf.addToRecentFiles}),bo=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.compareFileMessage",{base:bn.compareBaseBranch,path:a}))},[ap,ao,bn.compareBaseBranch]),bp=(0,f.useRef)(!1),bq=(0,f.useCallback)(a=>{bf.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),bf.showEditor||(bp.current=!0,bf.setShowEditor(!0))},[bf]),br=(0,f.useCallback)(a=>{bf.setShowEditor(!0)},[bf]),bs=(0,f.useCallback)(async()=>{if(!bf.fileContent||"text"!==bf.fileContent.type||!bf.fileContent.content)return;let a=await j.t4.runPromiseExit((0,k.OJ)({cwd:b,path:bf.selectedPath,content:bf.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&bf.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,r.oR)(ao("toast.savedSuccess"),"success")}catch{(0,r.oR)(ao("toast.saveFailed"),"error")}},[b,bf]),bt=(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a=aJ.current,b=aK.current;a>0&&bf.updateRecentFilePosition(bf.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[bf]),bu=(0,f.useCallback)(async(a,b)=>{let c=a!==bf.selectedPath;if(c&&bf.showEditor){if(aO.isDirty&&(!await (0,r.lJ)(ao("fileBrowser.saveBeforeSwitch"),{confirmText:ao("fileBrowser.saveAndSwitch"),cancelText:ao("common.cancel")})||(await aN.current?.save(),aN.current?.isDirty)))return;bf.setShowEditor(!1)}c&&bt(),bf.handleSelectFile(a,b)},[bf,bt,aO.isDirty,ao]),bv=(0,f.useMemo)(()=>{let a=bj.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,E.v3)(c),e=new Set((0,E.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[bj.contentSearchResults]),[bw,bx]=(0,f.useState)(new Set),by=(0,f.useCallback)(a=>{bx(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),bz=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=bv.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[bv.matchMap]),bA=aQ&&bj.contentSearchResults.length>0,[bB,bC]=(0,f.useState)("selected"),bD=!!bf.selectedPath&&null!==(0,ab.c)(bf.selectedPath),[bE,bF]=(0,f.useState)(!1),bG=(0,f.useCallback)(async(a,c)=>{if(!bf.selectedPath||!bD)return;let d=await ba.goToDefinition(bf.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;bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),g===bf.selectedPath?bf.setTargetLineNumber(e.line):bu(g,e.line)},[bf,b,bD,ba,bd]),bH=(0,f.useCallback)((a,b,c,d,e)=>{a&&null!==(0,ab.c)(a)&&(bF(b),bb.onTokenMouseEnter(a,c,d,e))},[bb]),bI=(0,f.useCallback)((a,b,c)=>{bD&&bH(bf.selectedPath,!1,a,b,c)},[bf.selectedPath,bD,bH]),bJ=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;bf.selectedPath&&bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),d===bf.selectedPath?bf.setTargetLineNumber(a.line):bu(d,a.line)},[bf,b,bd]),bK=(0,f.useMemo)(()=>{if(!bk.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 bk.status.staged)a.set(c.path,b(c.status));for(let c of bk.status.unstaged)a.set(c.path,b(c.status));return a},[bk.status]),bL=(0,f.useMemo)(()=>{if(!bk.status)return null;let a=new Map;for(let b of bk.status.staged)"renamed"===b.status&&b.oldPath&&a.set(b.path,b.oldPath);return a},[bk.status]),bM=(0,f.useCallback)(a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},[bj.setContentSearchQuery,bj.performContentSearch]),bN=(0,Y.H)({cwd:b,selectedPath:bf.selectedPath,gitStatusMap:bK,renameOldPaths:bL,isText:bf.fileContent?.type==="text",refreshKey:bf.fileContent?.mtime}),bO="tree"===ax&&bN.showDiff,bP=(0,f.useCallback)(a=>{ay(a),bf.setBlameSelectedCommit(null),"history"===a&&bn.selectedBranch&&bn.loadCommits(bn.selectedBranch)},[bf,bn.selectedBranch,bn.loadCommits]);(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a={filePath:bf.selectedPath,lineNumber:aJ.current},b=bd.goBack(a);b&&(b.filePath===bf.selectedPath?bf.setTargetLineNumber(b.lineNumber):bu(b.filePath,b.lineNumber))},[bf,bd]),(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a={filePath:bf.selectedPath,lineNumber:aJ.current},b=bd.goForward(a);b&&(b.filePath===bf.selectedPath?bf.setTargetLineNumber(b.lineNumber):bu(b.filePath,b.lineNumber))},[bf,bd]);let bQ=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await j.t4.runPromiseExit((0,k.__)({cwd:b,path:a}));"Success"===d._tag?(0,r.oR)(ao("toast.copiedName",{name:c}),"success"):(0,r.oR)(ao("toast.copyFailed"),"error")},[b,ao]),bR=(0,f.useCallback)(async a=>{let c=await j.t4.runPromiseExit((0,k.dt)());if("Success"!==c._tag||!c.value.path)return void(0,r.oR)(ao("toast.noFileToPaste"),"info");let d=c.value.path,e=await j.t4.runPromiseExit((0,k.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,r.oR)(ao("toast.pastedFile",{name:e.value.newName}),"success"),bf.loadDirectory(a),bf.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:ao("toast.pasteFailed");(0,r.oR)(c,"error")}},[b,bf,ao]);(0,f.useRef)(0),(0,f.useRef)(be),(0,f.useRef)(ax),(0,f.useRef)(!1);let bS=(0,f.useRef)(bn.selectedBranch);bS.current=bn.selectedBranch;let bT=(0,f.useRef)(bf.selectedPath);bT.current=bf.selectedPath;let bU=(0,f.useRef)(bf.fileContent?.type);bU.current=bf.fileContent?.type;let bV=(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(j.t4.runPromise((0,k.mP)(b)).then(a=>{a.error||bf.setFiles(b=>(0,E.HR)(a.files??[],b))}).catch(()=>{})),f.push(j.t4.runPromise((0,k.DZ)(b)).then(a=>{a.paths&&bf.setFileIndex(a.paths)}).catch(()=>{})),f.push(j.t4.runPromise((0,k.r9)(b)).then(a=>{bf.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(j.t4.runPromise((0,m.lv)(b)).then(a=>{bk.setStatus(a);let b=(0,t.Do)(a.staged),c=(0,t.Do)(a.unstaged);bk.setStagedTree(b),bk.setUnstagedTree(c)}).catch(()=>{})),bk.refreshDiff(),d&&bn.loadBranches();let a=bS.current;a&&f.push(j.t4.runPromise((0,m.Bj)(b,a,E.B_)).then(a=>{let b=a.commits??[];bn.setCommits(b),bn.setHasMoreCommits(b.length>=E.B_)}).catch(()=>{}))}let g=bT.current,h=bU.current;g&&"text"===h&&f.push(j.t4.runPromise((0,l.K)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&bf.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,J.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:bV,enabled:be});let bW=(0,f.useCallback)(a=>{bu(a),bf.setShouldScrollToSelected(!0),ay("tree")},[bf,bu]);(0,f.useRef)(bu),(0,f.useRef)(null);let{setPreviewMarkdown:bX,setShouldScrollToSelected:bY}=bf,bZ=(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,r.oR)(ao("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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(),bW(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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,bW,ao]),b$=(0,f.useCallback)(({focalFile:a})=>"tree"===ax&&bN.canDiff&&a===bf.selectedPath?(0,e.jsxs)(e.Fragment,{children:[bN.showDiff&&(0,e.jsx)(p.y,{value:aY,onChange:aZ}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bN.showDiff?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,title:bN.showDiff?ao("fileBrowser.exitDiff"):ao("fileBrowser.viewDiff"),children:ao("common.diff")})]}):null,[ax,bN.canDiff,bN.showDiff,bN.toggleDiff,bf.selectedPath,aY,ao]),[b_,b0]=(0,f.useState)(null),b1=(0,f.useCallback)((a,b)=>{bf.setPreviewMarkdown(!0),bW(a),b0(b),b&&setTimeout(()=>b0(null),400)},[bf,bW]);return(0,e.jsxs)(u.SU,{container:aD,children:[(0,e.jsxs)("div",{ref:aB,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:a0},children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>bP("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>bP("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>bP("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>bP("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>bP("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.historyTab")})]}),"tree"===ax&&(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:bf.searchInputRef,type:"text",value:bf.searchQuery,onChange:a=>bf.setSearchQuery(a.target.value),placeholder:ao("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"}),bf.searchQuery&&(0,e.jsx)("button",{onClick:()=>{bf.setSearchQuery(""),bf.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:ao("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:()=>bf.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${bf.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:bf.searchExactMatch?ao("fileBrowser.exactMatchOn"):ao("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>bf.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("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:()=>bf.searchTreeExpandedPaths?bf.setSearchTreeExpandedPaths(new Set):bf.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("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"===ax&&(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:bj.contentSearchInputRef,type:"text",value:bj.contentSearchQuery,onChange:a=>bj.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bj.performContentSearch(bj.contentSearchQuery)},placeholder:ao("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"}),bj.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>{bj.setContentSearchQuery(""),bj.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:ao("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:()=>bj.performContentSearch(bj.contentSearchQuery),disabled:bj.isSearching||!bj.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:bj.isSearching?"...":ao("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:bj.searchOptions.caseSensitive,onChange:a=>bj.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bj.searchOptions.wholeWord,onChange:a=>bj.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bj.searchOptions.regex,onChange:a=>bj.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:bj.searchOptions.fileType,onChange:a=>bj.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:ao("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground"})]})]}),"history"===ax&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:bn.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:bn.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>bn.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:ao("fileBrowser.compareModeOff"),children:ao("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)(R.e,{branches:bn.branches,selectedBranch:bn.compareBaseBranch,onSelect:a=>{bn.setCompareBaseBranch(a),bn.loadCompareFiles(a)},isLoading:bn.isLoadingBranches,pinnedBranches:["origin/main",...bn.upstreamBranch&&"origin/main"!==bn.upstreamBranch?[bn.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)(R.e,{branches:bn.branches,selectedBranch:bn.selectedBranch,onSelect:a=>{bn.setSelectedBranch(a)},isLoading:bn.isLoadingBranches,pinnedBranches:["origin/main",...bn.upstreamBranch&&"origin/main"!==bn.upstreamBranch?[bn.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>bn.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:ao("fileBrowser.compareModeOn"),children:ao("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"===ax?"":"hidden"}`,children:[bf.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:bf.creatingItem.parentPath?ao("fileBrowser.createFileIn",{path:bf.creatingItem.parentPath}):ao("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:ao("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:()=>{aC.current=!0},onCompositionEnd:()=>{aC.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(aC.current)return;let c=a.target.value.trim();if(!c)return;let d=bf.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await j.t4.runPromiseExit((0,k.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,r.oR)(ao("toast.createdFile",{name:c}),"success"),bf.setCreatingItem(null),bf.loadDirectory(d),bf.loadFileIndex(),d&&bf.setExpandedPaths(a=>new Set([...a,d])),bu(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,r.oR)(a||ao("toast.createFailed"),"error")}else(0,r.oR)(ao("toast.createFailed"),"error")}else"Escape"===a.key&&bf.setCreatingItem(null)},onBlur:()=>bf.setCreatingItem(null)})]}),bf.isLoadingFiles&&0===bf.files.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("common.loading")}):bf.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bf.fileError}):(0,e.jsx)(s.h,{files:bf.files,selectedPath:bf.selectedPath,expandedPaths:bf.effectiveExpandedPaths,matchedPaths:bf.matchedPaths,gitStatusMap:bK,loadingDirs:bf.loadingDirs,onSelect:a=>{bf.setShouldScrollToSelected(!1),bu(a)},onToggle:bf.handleToggle,cwd:b,shouldScrollToSelected:bf.shouldScrollToSelected,onScrolledToSelected:()=>bf.setShouldScrollToSelected(!1),onCreateFile:a=>bf.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>aG({path:a,isDirectory:b,name:c}),onRefresh:()=>bf.loadFiles(),onCopyFile:bQ,onPaste:bR,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===ax?"":"hidden"}`,children:bj.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"})}):bj.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bj.searchError}):0===bj.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:bj.contentSearchQuery?ao("fileBrowser.noContentSearchResults"):ao("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[bj.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b border-border flex-shrink-0",children:[ao("fileBrowser.nFilesNMatches",{files:bj.searchStats.totalFiles,matches:bj.searchStats.totalMatches}),bj.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",ao("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(s.h,{files:bv.files,selectedPath:bf.selectedPath,expandedPaths:bw,onSelect:a=>{let b=bv.matchMap.get(a);bu(a,b?.matches[0]?.lineNumber),aQ||aR(!0)},onToggle:by,cwd:b,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading,renderActions:bz,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"===ax?"":"hidden"}`,children:0===bf.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noRecentFiles")}):(0,e.jsx)(s.h,{files:bf.recentFilesTree,selectedPath:bf.selectedPath,expandedPaths:bf.recentTreeDirPaths,onSelect:bu,onToggle:E.tE,cwd:b,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===ax?"":"hidden"}`,children:bk.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"})}):bk.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:bk.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:ao("fileBrowser.stagingArea",{count:bk.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>bk.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("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"})})})]}),(bk.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:bk.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:ao("fileBrowser.unstageAll")})]}),(0,e.jsx)(t.VO,{files:bk.stagedTree,selectedPath:bk.statusSelectedFile?.type==="staged"?bk.statusSelectedFile.file.path:null,expandedPaths:bk.stagedExpandedPaths,onSelect:a=>a.file&&bk.handleStatusFileSelect(a.file,"staged"),onToggle:bk.handleStagedToggle,cwd:b,emptyMessage:ao("fileBrowser.noStagedFiles"),className:"py-1",onExplain:ap?ar:void 0,explainDisabled:ap?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,t.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bk.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:ao("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(),bk.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:ao("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:ao("fileBrowser.workspace",{count:bk.status?.unstaged.length||0})}),(bk.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bk.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:ao("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:bk.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:ao("fileBrowser.stageAll")})]})]}),(0,e.jsx)(t.VO,{files:bk.unstagedTree,selectedPath:bk.statusSelectedFile?.type==="unstaged"?bk.statusSelectedFile.file.path:null,expandedPaths:bk.unstagedExpandedPaths,onSelect:a=>a.file&&bk.handleStatusFileSelect(a.file,"unstaged"),onToggle:bk.handleUnstagedToggle,cwd:b,emptyMessage:ao("fileBrowser.noUnstagedChanges"),className:"py-1",onExplain:ap?as:void 0,explainDisabled:ap?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,t.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bk.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:ao("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(),bk.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:ao("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bk.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:ao("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(),bk.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:ao("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"===ax?"":"hidden"}`,children:bn.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:bn.historyError})]})}):bn.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:bn.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingDiff")}):0===bn.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:ao("fileBrowser.nFilesChanged",{count:bn.compareFiles.length,branch:bn.compareBaseBranch})})}),(0,e.jsx)(t.VO,{files:bn.compareFileTree,expandedPaths:bn.compareExpandedPaths,onToggle:bn.handleCompareToggle,selectedPath:bn.compareSelectedFile?.path||null,onSelect:a=>{a.file&&bn.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0,onExplain:ap?bo:void 0,explainDisabled:ap?.isLoading})]})}):(0,e.jsx)("div",{ref:bn.commitListRef,className:"flex-1 overflow-y-auto",onScroll:bn.handleCommitListScroll,children:bn.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingCommits")}):0===bn.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[bn.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>bn.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${bn.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-foreground-subtle","data-tooltip":a.date,children:[a.relativeDate," \xb7 ",(0,E.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)),bn.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"})}),!bn.hasMoreCommits&&bn.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-foreground-subtle",children:ao("fileBrowser.allLoaded",{count:bn.commits.length})})]})})})]})]}),(0,e.jsx)("div",{onPointerDown:a3,onPointerMove:a4,onPointerUp:a5,onPointerCancel:a5,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",children:[("tree"===ax||"search"===ax||"recent"===ax)&&(bf.blameSelectedCommit?(0,e.jsx)(n.n,{isOpen:!0,onClose:()=>bf.setBlameSelectedCommit(null),commit:bf.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:bf.selectedPath||void 0,onLocateInTree:bW,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):"map"===az?bO&&bN.diff?(0,e.jsx)(N.r,{cwd:b,filePath:bN.diff.filePath,oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,isNew:bN.diff.isNew,isDeleted:bN.diff.isDeleted,changedFiles:bl,fileGitStatusMap:bm,compact:"compact"===aY,enableComments:!0,onSwitchToCode:()=>aA("code"),onContentSearch:bM,headerExtraLeft:bZ,headerExtraRight:b$}):(0,e.jsx)(M.O,{cwd:b,highlightedFilePath:bf.selectedPath,changedFiles:bl,onSwitchToCode:()=>aA("code"),enableComments:!0,onContentSearch:bM,headerExtraLeft:bZ,headerExtraRight:b$}):bf.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:bf.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${bf.selectedPath}`),(0,r.oR)(ao("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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(),bW(bf.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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:bf.showEditor?(0,e.jsxs)(e.Fragment,{children:[aO.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:ao("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>aN.current?.save(),disabled:!aO.isDirty||aO.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aO.isDirty&&!aO.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:aO.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):ao("common.save")}),(0,e.jsx)("button",{onClick:()=>aN.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.closeEdit"),children:ao("fileBrowser.closeBtn")})]}):bO?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.y,{value:aY,onChange:aZ}),(0,e.jsx)(q.q,{value:a$,onChange:a_}),!(0,w.e$)(bf.selectedPath)&&!(0,w.aR)(bf.selectedPath)&&!(0,w.Hz)(bf.selectedPath)&&!(0,w.Zy)(bf.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("blockViewer.viewerToggle.toBlock"),children:ao("common.codeMap")}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors bg-brand text-white",children:ao("fileBrowser.exitDiff")})]}):(0,e.jsxs)(e.Fragment,{children:["tree"===ax&&bN.canDiff&&(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.viewDiff"),children:ao("common.diff")}),bf.fileContent?.type==="text"&&(0,w.e$)(bf.selectedPath)&&(0,e.jsx)(H.ShareReviewToggle,{content:bf.fileContent.content||"",sourceFile:bf.selectedPath&&b&&bf.selectedPath.startsWith(b)?bf.selectedPath.slice(b.endsWith("/")?b.length:b.length+1):bf.selectedPath||""}),bf.fileContent?.type==="text"&&(0,w.Hz)(bf.selectedPath)&&bf.previewMarkdown&&!bf.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(),bi(b=>({version:b.version+1,collapsed:a}))},className:`px-2 py-0.5 text-xs transition-colors ${bh.collapsed===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:ao(a?"fileBrowser.collapseAllJson":"fileBrowser.expandAllJson")},String(a)))}),bf.fileContent?.type==="text"&&((0,w.e$)(bf.selectedPath)||(0,w.aR)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))&&(aj=(ai=(0,w.aR)(bf.selectedPath))?bf.previewHtml:bf.previewMarkdown,(0,e.jsx)("button",{onClick:()=>ai?bf.setPreviewHtml(a=>!a):bf.setPreviewMarkdown(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aj?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:aj?ao("fileBrowser.exitPreview"):ao("common.preview")})),bf.fileContent?.type==="text"&&(0,w.C_)(bf.selectedPath||"")&&(al=(ak=bf.selectedPath||"").startsWith("/")?ak:b?`${b.replace(/\/$/,"")}/${ak}`:ak,(0,e.jsx)("button",{onClick:()=>au(al),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("skills.addTooltip"),children:(0,e.jsx)(y.A,{className:"w-3.5 h-3.5"})})),bf.fileContent?.type==="text"&&(0,w.aR)(bf.selectedPath)&&(an=(am=bf.selectedPath||"").startsWith("/")?am:b?`${b.replace(/\/$/,"")}/${am}`:am,(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>at(an),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("htmlApps.addTooltip"),children:(0,e.jsx)(y.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:an}})),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("common.openInConsole"),children:(0,e.jsx)(z.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>{let a=(0,B.Xe)(an);window.open((0,B.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:ao("browser.openInNewWindow"),children:(0,e.jsx)(A.A,{className:"w-3.5 h-3.5"})})]})),bf.fileContent?.type==="text"&&!(bf.previewMarkdown&&((0,w.e$)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))||bf.previewHtml&&(0,w.aR)(bf.selectedPath))&&(0,e.jsx)("button",{onClick:bf.handleToggleBlame,disabled:bf.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bf.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-hover"} disabled:opacity-50`,title:ao("fileBrowser.viewBlame"),children:bf.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),bf.fileContent?.type==="text"&&!(bf.previewMarkdown&&((0,w.e$)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))||bf.previewHtml&&(0,w.aR)(bf.selectedPath))&&(0,e.jsx)("button",{onClick:()=>bf.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.editFile"),children:ao("common.edit")}),bf.fileContent?.type==="text"&&bf.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(bf.fileContent.content),(0,r.oR)(ao("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.copyFileContent"),children:ao("common.copy")}),bf.fileContent?.type==="text"&&!(0,w.e$)(bf.selectedPath)&&!(0,w.aR)(bf.selectedPath)&&!(0,w.Hz)(bf.selectedPath)&&!(0,w.Zy)(bf.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("blockViewer.viewerToggle.toBlock"),children:ao("common.codeMap")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:bf.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"})}):bf.fileContent?"text"===bf.fileContent.type&&"string"==typeof bf.fileContent.content?bO?bN.isLoadingDiff&&!bN.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"})}):bN.diff?"unified"===a$?(0,e.jsx)(o.xU,{oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,filePath:bN.diff.filePath,cwd:b,enableComments:!0,compact:"compact"===aY,onContentSearch:bM,onTokenHover:(a,b,c)=>bH(bN.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.clearHover}):(0,e.jsx)(o.xZ,{oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,filePath:bN.diff.filePath,isNew:bN.diff.isNew,isDeleted:bN.diff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===aY,onContentSearch:bM,onTokenHover:(a,b,c)=>bH(bN.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.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:ao("fileBrowser.diffLoadFailed")}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"mt-2 text-brand hover:underline text-sm",children:ao("fileBrowser.exitDiff")})]})}):bf.showBlame&&bf.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:bf.blameError}),(0,e.jsx)("button",{onClick:()=>bf.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:ao("fileBrowser.backToPreview")})]})}):bf.showBlame&&0===bf.blameLines.length&&bf.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"})}):bf.previewMarkdown&&(0,w.Hz)(bf.selectedPath)&&!bf.showBlame?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-background text-foreground",children:[(0,e.jsx)(aa._,{search:a7}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:a6,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,e.jsx)(w.d9.Provider,{value:bh,children:bg})})})]}):bf.previewMarkdown&&(0,w.Zy)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)(x.C0,{content:bf.fileContent.content,filePath:bf.selectedPath,className:"h-full"}):bf.previewMarkdown&&(0,w.e$)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(F.M,{content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,embedded:!0,onLocalMdLink:b1,scrollToAnchor:b_})}):bf.previewHtml&&(0,w.aR)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)(G.O,{content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)(v.Cv,{ref:aN,content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,enableComments:!0,scrollToLine:aL??bf.targetLineNumber,scrollToLineAlign:null!=aL?"start":bf.targetScrollAlign,onScrollToLineComplete:()=>{aM(null),bf.setTargetLineNumber(null)},highlightKeyword:"search"===ax?bj.contentSearchQuery:null,visibleLineRef:aJ,viStateRef:aK,initialCursorLine:bf.initialCursorLine,initialCursorCol:bf.initialCursorCol,onInitialCursorSet:()=>{bf.setInitialCursorLine(null),bf.setInitialCursorCol(null)},onCmdClick:bD?bG:void 0,onTokenHover:bD?bI:void 0,onTokenHoverLeave:bD?bb.onTokenMouseLeave:void 0,onTokenHoverCancel:bD?bb.clearHover:void 0,blameLines:bf.showBlame&&bf.blameLines.length>0?bf.blameLines:void 0,inlineBlameLines:bf.blameLines.length>0?bf.blameLines:void 0,onSelectCommit:bf.setBlameSelectedCommit,editable:bf.showEditor,initialMtime:bf.fileContent.mtime,onEditorClose:a=>{bf.setShowEditor(!1),aM(a)},onSaved:()=>{let a=aJ.current??1;bf.loadFileContent(bf.selectedPath),bf.setShowEditor(!1),aM(a)},onEditorStateChange:aP,viMode:!0,onContentMutate:bq,onEnterInsertMode:br,onViSave:bs,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):"image"===bf.fileContent.type&&bf.selectedPath?(0,e.jsx)(S.I,{cwd:b,path:bf.selectedPath,refreshKey:bf.fileContent.mtime,alt:bf.selectedPath}):"pdf"===bf.fileContent.type&&bf.selectedPath?(0,e.jsx)(T.t,{cwd:b,path:bf.selectedPath,refreshKey:bf.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:bf.fileContent.message||ao("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:ao("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:ao("fileBrowser.selectFileToPreview")})]})})),"status"===ax&&(bk.statusSelectedFile&&bk.statusDiff?(0,e.jsx)(O.m,{cwd:b,selected:bk.statusSelectedFile,diff:bk.statusDiff,showMarkdownPreview:bk.showStatusDiffPreview,setShowMarkdownPreview:bk.setShowStatusDiffPreview,changedFiles:bl,fileGitStatusMap:bm,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},locateInTree:bW,jsonPreview:aS,setJsonPreview:aT,jsonPreviewSearch:a9,jsonPreviewPreRef:a8,onTokenHover:(a,b,c)=>bH(bk.statusDiff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.clearHover}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:ao("fileBrowser.selectFileToViewDiff")})})),"history"===ax&&!bn.historyError&&(bn.compareMode?bn.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingDiffContent")}):bn.compareFileDiff?(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",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)(Q.d,{cwd:b,filePath:bn.compareFileDiff.filePath,onLocateInTree:bW}),!(0,E.u)(bn.compareFileDiff.filePath)&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(p.y,{value:aU,onChange:aV}),(0,e.jsx)(q.q,{value:aW,onChange:aX})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,E.u)(bn.compareFileDiff.filePath)?(0,e.jsx)(P.M,{cwd:b,filePath:bn.compareFileDiff.filePath,oldRev:bn.compareFileDiff.oldRev??(bn.compareFileDiff.isNew?null:bn.compareBaseBranch),newRev:bn.compareFileDiff.newRev??(bn.compareFileDiff.isDeleted?null:"HEAD")}):"unified"===aW?(0,e.jsx)(o.xU,{oldContent:bn.compareFileDiff.oldContent,newContent:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath,cwd:b,enableComments:!0,compact:"compact"===aU,onPreview:!bn.compareFileDiff.isDeleted&&bn.compareFileDiff.filePath.endsWith(".json")?()=>aT({content:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath}):void 0,previewLabel:ao("common.readable"),onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)(o.xZ,{oldContent:bn.compareFileDiff.oldContent,newContent:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath,isNew:bn.compareFileDiff.isNew,isDeleted:bn.compareFileDiff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===aU,onPreview:!bn.compareFileDiff.isDeleted&&bn.compareFileDiff.filePath.endsWith(".json")?()=>aT({content:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath}):void 0,previewLabel:ao("common.readable"),onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:bn.compareFiles.length>0?ao("fileBrowser.selectFileToViewDiff"):ao("fileBrowser.clickCompareToLoad")})}):bn.selectedCommit?(0,e.jsx)(n.n,{isOpen:!0,onClose:()=>bn.setSelectedCommit(null),commit:bn.selectedCommit,cwd:b,embedded:!0,onLocateInTree:bW,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:ao("fileBrowser.selectCommitToView")})}))]})]}),aH&&(0,e.jsx)(I.c,{files:bf.files,fileIndex:bf.fileIndex,recentFiles:bf.recentFilePaths,onSelectFile:a=>{bu(a),bf.setShouldScrollToSelected(!0),ay("tree")},onClose:()=>aI(!1)}),(bA||bc.visible)&&(0,e.jsxs)("div",{className:`flex ${bc.visible&&bA?"":"flex-col"}`,children:[bA&&(0,e.jsx)("div",{className:bc.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(ae.D,{results:bj.contentSearchResults,loading:bj.isSearching,totalMatches:bj.searchStats?.totalMatches??0,onSelect:(a,b)=>{bf.selectedPath&&bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),aA("code"),bu(a,b)},onClose:()=>aR(!1),scope:bB,onScopeChange:bC,selectedPath:bf.selectedPath})}),bc.visible&&(0,e.jsx)("div",{className:bA?"flex-1 min-w-0":"",children:(0,e.jsx)(ad.D,{references:bc.references,loading:bc.loading,onSelect:bJ,onClose:bc.closeReferences})})]})]}),aF&&(0,e.jsx)(i.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim",onClick:()=>aG(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:ao("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:ao("fileBrowser.confirmDeleteMessage",{name:aF.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:()=>aG(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-hover transition-colors",children:ao("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=aF;aG(null);let d=await j.t4.runPromiseExit((0,k.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,r.oR)(ao("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";bf.loadDirectory(b),bf.loadFileIndex(),bf.selectedPath===a&&bu("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:ao("toast.deleteFailed");(0,r.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:ao("common.delete")})]})]})})}),bb.hoverInfo&&aD&&(0,h.createPortal)((0,e.jsx)(ac.s,{ref:bb.setTooltipEl,displayString:bb.hoverInfo.displayString,documentation:bb.hoverInfo.documentation,x:bb.hoverInfo.x,y:bb.hoverInfo.y,container:aD,onMouseEnter:bb.onCardMouseEnter,onMouseLeave:bb.onCardMouseLeave,onFindReferences:bE?void 0:()=>{let{filePath:a,line:b,column:c}=bb.hoverInfo;bb.clearHover(),bc.findReferences(a,b,c)},onSearch:a=>{bb.clearHover(),ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},onExplain:ap?a=>{let{filePath:b,line:c}=bb.hoverInfo;bb.clearHover(),ap.sendMessage(ao("explain.symbolMessage",{name:a,path:b,lines:String(c)}))}:void 0,explainDisabled:ap?.isLoading}),aD)]})});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:()=>j,n:()=>i});var d=c(48249),e=c(67484),f=c(44384);c(59336);var g=c(33281),h=c(41224);function i({value:a,onChange:b,textareaRef:c,extraCommands:d}){let[f,j]=(0,e.useState)(a.length),[k,l]=(0,e.useState)([]),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(0),[q,r]=(0,e.useState)(()=>a.length>0),s=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a=await g.t4.runPromiseExit((0,h.l1)());if("Success"===a._tag){let b=a.value.skills??a.value;n((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)},[]);let t=(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]),u=(0,e.useMemo)(()=>{let a=t.text.match(/^\s*([/@])([a-zA-Z0-9-]*)$/);return a?{marker:a[1],verb:a[2].toLowerCase()}:null},[t.text]),v=(0,e.useMemo)(()=>{if(!u)return[];let{verb:a}=u,b=b=>b.name.slice(1).toLowerCase().startsWith(a);return[...(d??[]).filter(b),...k.filter(b),...m.filter(b)]},[u,d,k,m]),w=!q&&!!u&&v.length>0;(0,e.useRef)(a);let x=(0,e.useCallback)(a=>{j(a.selectionStart??0)},[]),y=(0,e.useCallback)(d=>{let e=u?.marker??"/",f=`${e}${d.name.slice(1)} `,g=a.slice(0,t.start),h=a.slice(t.end),i=g.length+f.length;b(g+f+h),j(i),requestAnimationFrame(()=>{let a=c.current;a&&(a.focus(),a.setSelectionRange(i,i))})},[a,t,u,b,c]),z=(0,e.useCallback)(a=>{if(a.nativeEvent.isComposing||!w||0===v.length)return!1;let b=()=>{a.preventDefault(),a.stopPropagation()};return"ArrowDown"===a.key?(b(),p(a=>(a+1)%v.length),!0):"ArrowUp"===a.key?(b(),p(a=>(a-1+v.length)%v.length),!0):"Enter"===a.key||"Tab"===a.key?(b(),y(v[o]),!0):"Escape"===a.key&&(b(),r(!0),!0)},[w,v,o,y]);return{isOpen:w,items:v,selectedIndex:o,marker:u?.marker??"/",listRef:s,selectCommand:y,handleKeyDown:z,trackCaret:x}}function j({ac:a,className:b=""}){let{t:c}=(0,f.Bd)(),{isOpen:e,items:g,selectedIndex:h,marker:i,listRef:k,selectCommand:l}=a;return e&&0!==g.length?(0,d.jsx)("div",{ref:k,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="skill"!==a.source&&0===b;return(0,d.jsxs)("div",{children:[j&&(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"}),(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"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return c("common.builtin");case"skill":return"Skill"}})(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})}},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:()=>A});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(98356),t=c(64676),u=c(84835);c(15466);var v=c(60591),w=c(34728),x=c(24680),y=c(92608),z=c(37690);let a=[u.W];function A({content:b,filePath:c,cwd:d,onClose:u,sourceFile:B,embedded:C=!1,onLocalMdLink:D,scrollToAnchor:E}){let F=B||(d&&c.startsWith(d)?c.slice(d.endsWith("/")?d.length:d.length+1):c),{t:G}=(0,g.Bd)(),H=(0,j.iN)(),I=(0,p.r)(),J=(0,w.U)(),{comments:K,addComment:L,updateComment:M,deleteComment:N,refresh:O}=(0,o._)({cwd:d,filePath:c}),[P,Q]=(0,f.useState)(!1),[R,S]=(0,f.useState)(null),[T,U]=(0,f.useState)(null),[V,W]=(0,f.useState)(null),X=(0,f.useMemo)(()=>b.split("\n"),[b]),Y=(0,f.useMemo)(()=>(0,t.J4)(c,d),[c,d]),[Z,$]=(0,f.useState)(null),_=(0,f.useRef)(null),aa=(0,f.useRef)({onLocalMdLink:D,sourceFile:F});aa.current={onLocalMdLink:D,sourceFile:F};let ab=(0,f.useRef)(a=>{let{onLocalMdLink:b,sourceFile:c}=aa.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:ac,bumpRef:ad,clearToolbar:ae}=(0,z.L)({enabled:!0,container:Z,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(X.length,b);return X.slice(c,d).join("\n")}}),af=(0,f.useCallback)(()=>{let a=ac.current;a&&(S({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ae())},[ae,ac]),ag=(0,f.useCallback)(()=>{let a=ac.current;a&&(U({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ae())},[ae,ac]),ah=(0,f.useCallback)(()=>{let a=ac.current;a&&I&&(ae(),(0,q.Ff)(I.sendMessage,{filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},r.A.t("explain.selectionMessage")))},[I,c,ae,ac]),ai=(0,f.useCallback)(async a=>{R&&(await L(R.range.start,R.range.end,a,R.selectedText),S(null))},[R,L]),aj=(0,f.useCallback)(async(a,b)=>{if(I)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);I.sendMessage(g),await (0,q.RP)(d),O()}catch(a){console.error("Failed to send to AI:",a)}},[I,c,d,O]),ak=(0,f.useCallback)(a=>{T&&aj(T,a)},[T,aj]),al=(0,f.useCallback)(a=>{R&&aj(R,a)},[R,aj]);(0,f.useMemo)(()=>{if(0===K.length)return[];let a=new Map;for(let b of K){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}))},[K]);let[am,an]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[!C&&(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)(G("common.copiedPath"))},children:["",c]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(y.ShareReviewToggle,{content:b,sourceFile:F}),(0,v.C_)(c)&&(0,e.jsx)("button",{onClick:()=>J(c.startsWith("/")||!d?c:`${d.replace(/\/$/,"")}/${c}`),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:G("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:G("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)(x.l,{content:b,containerRef:_}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:_,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(s.T,{content:b,basePath:Y,rehypePlugins:a,onLinkClick:ab})}),am.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(),W({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))]})]}),P&&H&&(0,i.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.fS,{floatingToolbarRef:ac,bumpRef:ad,container:H,onAddComment:af,onSendToAI:ag,onExplain:I?ah:void 0,isChatLoading:I?.isLoading}),R&&(0,e.jsx)(m.t,{x:R.x,y:R.y,range:R.range,filePath:c,lineSnapshot:R.lineSnapshot,container:H,onSubmit:ai,onSendToAI:I?al:void 0,onClose:()=>S(null),isChatLoading:I?.isLoading}),T&&(0,e.jsx)(m.G,{x:T.x,y:T.y,range:T.range,filePath:c,lineSnapshot:T.lineSnapshot,container:H,onSubmit:ak,onClose:()=>U(null),isChatLoading:I?.isLoading}),V&&(0,e.jsx)(n.t,{x:V.x,y:V.y,comment:V.comment,container:H,onClose:()=>W(null),onUpdateComment:M,onDeleteComment:N})]}),H)]})}d()}catch(a){d(a)}})},74228:(a,b,c)=>{"use strict";c.d(b,{S:()=>f,l:()=>g});var d=c(48249),e=c(40311);function f(a){return"loading"===a||"unread"===a?a:"normal"}function g({projectNumber:a,sessionNumber:b,coordinate:c,status:f="normal",statusLabel:h,className:i=""}){if(c){let[d,e]=c.split(".");a??=d,b??=e}if(null==a&&null==b)return null;let j="flex h-4 w-4 items-center justify-center border",k=[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 ${i}`,"aria-label":h?`${k} \xb7 ${h}`:k,children:[null!=a&&(0,d.jsx)("span",{className:`${j} rounded-[4px] ${(0,e.c)("normal",!1)}`,children:a}),null!=b&&(0,d.jsx)("span",{className:`${j} rounded-full ${(0,e.c)(f,!1)}`,title:h,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:()=>s});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(15819);c(33281);var j=c(13054),k=c(30458),l=c(36688),m=c(32753),n=c(74228),o=c(15790);c(41224);var p=a([o,l]);function q(a){return a.engine||"claude"}function r(a){return a.lastFiredAt??a.createdAt}[o,l]=p.then?(await p)():p;let t=[{key:"pendingReview",labelKey:"scheduledTasks.groupPendingReview"},{key:"upcoming",labelKey:"scheduledTasks.groupUpcoming"},{key:"paused",labelKey:"scheduledTasks.paused"}];function s({collapsed:a,tasks:b,unreadCount:c,sessionNumbers:d,onSwitchProject:p,onPause:u,onResume:v,onTrigger:w,onDelete:x,onMarkRead:y,onUpdateTask:z}){let{t:A}=(0,g.Bd)(),[B,C]=(0,f.useState)(!1),[D,E]=(0,f.useState)(null),F=(0,f.useRef)(null),G=(0,f.useRef)(null),[H,I]=(0,f.useState)(null),J=(0,f.useCallback)(()=>{E(null),F.current=null,I(null)},[]),[K,L]=(0,f.useState)(null),[M,N]=(0,f.useState)(null),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)(null),S=b.filter(a=>!a.completed),T=S.filter(a=>!a.paused).length,U=(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)||r(b)-r(a)),c.sort((a,b)=>(a.nextFireTime||Number.MAX_SAFE_INTEGER)-(b.nextFireTime||Number.MAX_SAFE_INTEGER)),d.sort((a,b)=>r(b)-r(a)),{pendingReview:b,upcoming:c,paused:d}})(b),[b]),V=O?b.find(a=>a.id===O)??null:null,[,W]=(0,f.useState)(0),X=(0,f.useCallback)(()=>{L(null),N(null)},[]),Y=(0,f.useCallback)(async a=>{let b=!!a.taskFile;try{await navigator.clipboard.writeText(b?a.taskFile:a.message),(0,h.oR)(A(b?"common.copiedPath":"toast.copiedMessage"),"success")}catch{(0,h.oR)(A("common.copyFailed"),"error")}},[A]),Z=(0,f.useCallback)(()=>{C(!1),P(null)},[]),$=(0,f.useCallback)(a=>{p(a.cwd,a.sessionId),a.unread&&y(a.id),Z()},[p,y,Z]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{onClick:()=>C(!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?A("scheduledTasks.title"):void 0,children:[(0,e.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:A("scheduledTasks.title")}),c>0?(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-red-9/55 ${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]}),B&&(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:Z}),(0,e.jsxs)("div",{className:i.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:A("scheduledTasks.title")}),S.length>0&&(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[A("scheduledTasks.activeCount",{running:T}),S.length-T>0?` \xb7 ${A("scheduledTasks.pausedCount",{paused:S.length-T})}`:""]})]}),(0,e.jsx)("button",{onClick:Z,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:A("scheduledTasks.noScheduledTasks")})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-full md:w-[360px] flex-shrink-0 md:border-r border-border overflow-y-auto p-3 space-y-4",children:t.map(({key:a,labelKey:b})=>{let c=U[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:[A(b)," (",c.length,")"]}),(0,e.jsx)("div",{className:"mt-1 space-y-2",children:c.map(a=>{let b,c;return b=a.id===O,(0,e.jsxs)("div",{onClick:()=>P(a.id),onMouseLeave:()=>R(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)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.unread?"bg-red-9":a.completed?"bg-muted-foreground/30":a.paused?"bg-amber-9":"error"===a.lastResult?"bg-red-9":"bg-green-9"}`}),(0,e.jsx)(m.S,{engine:q(a),tooltip:(c=q(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,j.P_)(a.cwd)}),(0,e.jsx)(n.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:()=>h,NR:()=>t,OO:()=>v,Yd:()=>y,kn:()=>i,oJ:()=>o});var d=c(48249),e=c(67484),f=c(44256),g=c(63565);let h="claude-opus-5",i="gpt-5.6-sol",j=[{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"}],k=[{id:"claude-sonnet-5",label:"Claude Sonnet 5",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-opus-5",label:"Claude Opus 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-fable-5-1",label:"Claude Fable 5.1",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-fable-5",label:"Claude Fable 5",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m"},{id:"claude-opus-4-8",label:"Claude Opus 4.8",effort:["low","medium","high","xhigh","max","ultracode","ultrathink"],defaultEffort:"high",fast:!0},{id:"claude-opus-4-7",label:"Claude Opus 4.7",effort:["low","medium","high","xhigh","max","ultrathink"],defaultEffort:"xhigh",fast:!0},{id:"claude-opus-4-6",label:"Claude Opus 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"1m",fast:!0},{id:"claude-sonnet-4-6",label:"Claude Sonnet 4.6",effort:["low","medium","high","max","ultrathink"],defaultEffort:"high",context:["200k","1m"],defaultContext:"200k"},{id:"claude-haiku-4-5",label:"Claude Haiku 4.5",thinking:!0}],l=[{id:"minimal",label:"Minimal"},{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"}],m=[{id:"gpt-6-astra",label:"GPT-6-Astra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"low"},{id:"gpt-5.6-sol",label:"GPT-5.6-Sol",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-terra",label:"GPT-5.6-Terra",reasoning:["low","medium","high","xhigh","max","ultra"],defaultReasoning:"medium"},{id:"gpt-5.6-luna",label:"GPT-5.6-Luna",reasoning:["low","medium","high","xhigh","max"],defaultReasoning:"medium"}];function n(a){return m.find(b=>b.id===a)?.defaultReasoning??"low"}function o(a,b){let c=m.find(b=>b.id===a)?.reasoning;return b&&(!c||c.includes(b))?b:n(a)}function p(a,b){return a.find(a=>a.id===b)?.label??b}function q(a){return k.find(b=>b.id===a)?.fast===!0}function r(a){return k.find(b=>b.id===a)?.thinking===!0}function s(a){let b=k.find(b=>b.id===a);return b?b.defaultEffort:"high"}function t(a,b){let c=k.find(b=>b.id===a),d=c?.effort;return b&&(!c||d?.includes(b))?b:s(a)}function u(a){let b=k.find(b=>b.id===a);return b?b.defaultContext:"200k"}function v(a,b){let c=k.find(b=>b.id===a),d=c?.context;return b&&(!c||d?.includes(b))?b:u(a)}function w({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 x({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)(w,{value:a.id,selected:b===a.id,label:a.label,defaultValue:a.defaultValue,onSelect:a=>{i(a),o(!1)}},a.id))})]})})]})}function y(a){let b,c,e=a.engine??"claude",f=a.claudeModel??h,w=s(f),y=(b=k.find(a=>a.id===f)?.effort)?b.map(a=>j.find(b=>b.id===a)??{id:a,label:a}):[],z=t(f,a.claudeEffort),A=u(f),B=k.find(a=>a.id===f)?.context??[],C=v(f,a.claudeContextWindow),D=a.claudeFastMode??!1,E=a.claudeThinking??!1,F=a.codexModel??i,G=n(F),H=(c=m.find(a=>a.id===F)?.reasoning)?c.map(a=>l.find(b=>b.id===a)??{id:a,label:a}):l,I=o(F,a.codexReasoningEffort);return"claude"!==e?(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1","data-agent-model-traits":!0,children:[(0,d.jsx)(x,{title:"Model",selected:F,value:p(m,F),items:m.map(a=>({id:a.id,label:a.label,defaultValue:a.id===i})),onSelect:b=>{a.onCodexModelChange?.(b),a.onCodexReasoningEffortChange?.(n(b))},icon:(0,d.jsx)(g.eV,{engine:"codex"}),testId:"codex-model-picker"}),(0,d.jsx)(x,{title:"Reasoning",selected:I,value:p(l,I),items:H.map(a=>({...a,defaultValue:a.id===G})),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)(x,{title:"Model",selected:f,value:p(k,f),items:k.map(a=>({id:a.id,label:a.label,defaultValue:a.id===h})),onSelect:b=>{a.onClaudeModelChange?.(b);let c=s(b),d=u(b);c&&a.onClaudeEffortChange?.(c),d&&a.onClaudeContextWindowChange?.(d),q(b)||a.onClaudeFastModeChange?.(!1),r(b)||a.onClaudeThinkingChange?.(!1)},icon:(0,d.jsx)(g.eV,{engine:"claude"}),testId:"claude-model-picker"}),z&&y.length>0&&(0,d.jsx)(x,{title:"Reasoning",selected:z,value:p(j,z),items:y.map(a=>({...a,defaultValue:a.id===w})),onSelect:b=>a.onClaudeEffortChange?.(b),testId:"claude-reasoning-picker"}),C&&B.length>0&&(0,d.jsx)(x,{title:"Context Window",selected:C,value:"1m"===C?"1M":"200K",items:B.map(a=>({id:a,label:"1m"===a?"1M":"200K",defaultValue:a===A})),onSelect:b=>a.onClaudeContextWindowChange?.(b),testId:"claude-context-picker"}),q(f)&&(0,d.jsx)(x,{title:"Fast Mode",selected:D?"on":"off",value:D?"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"}),r(f)&&(0,d.jsx)(x,{title:"Thinking",selected:E?"on":"off",value:E?"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:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call useTabState() from the server but useTabState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/useTabState.ts","useTabState")},65484:(a,b,c)=>{"use strict";c.d(b,{Cq:()=>n,D0:()=>q,DZ:()=>i,H7:()=>o,It:()=>s,Kl:()=>w,M5:()=>h,Or:()=>k,Q1:()=>u,QW:()=>p,Wr:()=>j,Yn:()=>r,b2:()=>v,em:()=>t,zF:()=>m});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=()=>f("/api/settings"),i=a=>f("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),j=()=>f("/api/version"),k=()=>f("/api/extension/version"),l=a=>a?`/api/note?cwd=${encodeURIComponent(a)}`:"/api/note",m=a=>f(l(a)),n=(a,b,c)=>d.tryPromise({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=()=>f("/api/pick-folder"),t=a=>g("/api/open-vscode",{cwd:a}),u=a=>g("/api/open-cursor",{cwd:a}),v=a=>f(`/api/git/worktree?cwd=${encodeURIComponent(a)}`),w=a=>g("/api/git/worktree",a)},65543:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});let d=new Set(["function","class","method"]);function e(a){return d.has(a.kind)}},67045:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(48249);function e({error:a,reset:b}){return(0,d.jsx)("html",{children:(0,d.jsx)("body",{children:(0,d.jsxs)("div",{style:{padding:"2rem",fontFamily:"system-ui, sans-serif"},children:[(0,d.jsx)("h2",{children:"Something went wrong"}),(0,d.jsx)("p",{style:{color:"#666"},children:a.message}),(0,d.jsx)("button",{onClick:b,style:{marginTop:"1rem",padding:"0.5rem 1rem",cursor:"pointer",borderRadius:"0.375rem",border:"1px solid #ccc",background:"#fff"},children:"Try again"})]})})})}},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})}},70151:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>ah});var e=c(48249),f=c(67484),g=c.n(f),h=c(74429),i=c(44256),j=c(33281),k=c(87808),l=c(25419),m=c(85655),n=c(21538),o=c(35208),p=c(74691),q=c(60333),r=c(7833),s=c(24724),t=c(20586),u=c(7122),v=c(55287),w=c(60591),x=c(19593),y=c(64825),z=c(66400),A=c(86588),B=c(64676),C=c(6478),D=c(34728),E=c(9804),F=c(73887),G=c(40893),H=c(92608),I=c(94239),J=c(29939),K=c(23860),L=c(7031),M=c(83721),N=c(25667),O=c(57014),P=c(46242),Q=c(21787),R=c(94308),S=c(53036),T=c(91975),U=c(6662),V=c(20291),W=c(58904),X=c(61632),Y=c(41357),Z=c(76855),$=c(4857),_=c(44384),aa=c(18921),ab=c(28797),ac=c(23881),ad=c(21672),ae=c(21482),af=c(94192),ag=a([n,N,o,F,v,O]);[n,N,o,F,v,O]=ag.then?(await ag)():ag;let ah=g().memo(function({onClose:a,cwd:b,initialTab:c="tree",tabSwitchTrigger:d,initialSearchQuery:g,searchQueryTrigger:ag,fileOpenRequest:ah}){let ai,aj,ak,al,am,an,{t:ao}=(0,_.Bd)(),ap=(0,L.r)(),aq=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.fileMessage",{path:a}))},[ap,ao]),ar=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.stagedFileMessage",{path:a}))},[ap,ao]),as=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.unstagedFileMessage",{path:a}))},[ap,ao]),at=(0,C.P)(),au=(0,D.U)(),{activeView:av,onViewChange:aw}=(0,af.R8)(),[ax,ay]=(0,f.useState)(c),[az,aA]=(0,f.useState)("code"),aB=(0,f.useRef)(null),aC=(0,f.useRef)(!1),[aD,aE]=(0,f.useState)(null),[aF,aG]=(0,f.useState)(null),[aH,aI]=(0,f.useState)(!1),aJ=(0,f.useRef)(1),aK=(0,f.useRef)(null),[aL,aM]=(0,f.useState)(null),aN=(0,f.useRef)(null),[aO,aP]=(0,f.useState)({isDirty:!1,isSaving:!1}),[aQ,aR]=(0,f.useState)(!1),[aS,aT]=(0,f.useState)(null),[aU,aV]=(0,f.useState)("compact"),[aW,aX]=(0,f.useState)("unified"),[aY,aZ]=(0,f.useState)("full"),[a$,a_]=(0,f.useState)("unified"),[a0,a1]=(0,f.useState)(320),a2=(0,f.useRef)(null),a3=(0,f.useCallback)(a=>{"mouse"===a.pointerType&&0===a.button&&(a.preventDefault(),a2.current={startX:a.clientX,startWidth:a0},a.currentTarget.setPointerCapture(a.pointerId))},[a0]),a4=(0,f.useCallback)(a=>{let b=a2.current;if(!b)return;let c=b.startWidth+(a.clientX-b.startX);a1(Math.min(480,Math.max(320,c)))},[]),a5=(0,f.useCallback)(a=>{a2.current&&(a2.current=null,a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId))},[]),a6=(0,f.useRef)(null),a7=(0,aa.o)(a6),a8=(0,f.useRef)(null),a9=(0,aa.o)(a8),ba=(0,Z.Sn)(b),bb=(0,Z.Xm)(b),bc=(0,Z.po)(b),bd=(0,$.Q)(),be=(0,K.F)(),bf=(0,U.W)({cwd:b});(0,Z.JL)(b,bf.selectedPath);let bg=(0,f.useMemo)(()=>{let a=bf.fileContent,b=bf.selectedPath;return a&&"text"===a.type&&"string"==typeof a.content&&b&&(0,w.Hz)(b)?(0,w.xb)(a.content,w.cG):null},[bf.fileContent,bf.selectedPath]),[bh,bi]=(0,f.useState)({version:0,collapsed:!1}),bj=(0,V.p)({cwd:b,onSearchComplete:()=>aR(!0)}),bk=(0,W.e)({cwd:b,addToRecentFiles:bf.addToRecentFiles}),bl=(0,f.useMemo)(()=>{let a=new Set;if(bk.status){for(let b of bk.status.staged)a.add(b.path);for(let b of bk.status.unstaged)a.add(b.path)}return a},[bk.status]),bm=(0,f.useMemo)(()=>{let a=new Map;if(bk.status){for(let b of bk.status.staged)a.set(b.path,"staged");for(let b of bk.status.unstaged)a.set(b.path,"unstaged")}return a},[bk.status]),bn=(0,X.y)({cwd:b,addToRecentFiles:bf.addToRecentFiles}),bo=(0,f.useCallback)(a=>{ap?.sendMessage(ao("explain.compareFileMessage",{base:bn.compareBaseBranch,path:a}))},[ap,ao,bn.compareBaseBranch]),bp=(0,f.useRef)(!1),bq=(0,f.useCallback)(a=>{bf.setFileContent(b=>b?.type==="text"?{...b,content:a}:b),bf.showEditor||(bp.current=!0,bf.setShowEditor(!0))},[bf]),br=(0,f.useCallback)(a=>{bf.setShowEditor(!0)},[bf]),bs=(0,f.useCallback)(async()=>{if(!bf.fileContent||"text"!==bf.fileContent.type||!bf.fileContent.content)return;let a=await j.t4.runPromiseExit((0,k.OJ)({cwd:b,path:bf.selectedPath,content:bf.fileContent.content}));try{if("Failure"===a._tag||!a.value.ok)throw Error("Failed to save file");let b=a.value.data?.mtime;b&&bf.setFileContent(a=>a?.type==="text"?{...a,mtime:b}:a),(0,r.oR)(ao("toast.savedSuccess"),"success")}catch{(0,r.oR)(ao("toast.saveFailed"),"error")}},[b,bf]),bt=(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a=aJ.current,b=aK.current;a>0&&bf.updateRecentFilePosition(bf.selectedPath,a,b?b.cursorLine+1:a,b?b.cursorCol+1:1)},[bf]),bu=(0,f.useCallback)(async(a,b)=>{let c=a!==bf.selectedPath;if(c&&bf.showEditor){if(aO.isDirty&&(!await (0,r.lJ)(ao("fileBrowser.saveBeforeSwitch"),{confirmText:ao("fileBrowser.saveAndSwitch"),cancelText:ao("common.cancel")})||(await aN.current?.save(),aN.current?.isDirty)))return;bf.setShowEditor(!1)}c&&bt(),bf.handleSelectFile(a,b)},[bf,bt,aO.isDirty,ao]),bv=(0,f.useMemo)(()=>{let a=bj.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,E.v3)(c),e=new Set((0,E.tW)(d));return{files:d,expandDirs:e,matchMap:b}},[bj.contentSearchResults]),[bw,bx]=(0,f.useState)(new Set),by=(0,f.useCallback)(a=>{bx(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),bz=(0,f.useCallback)(a=>{if(a.isDirectory)return null;let b=bv.matchMap.get(a.path);return b?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:b.matches.length}):null},[bv.matchMap]),bA=aQ&&bj.contentSearchResults.length>0,[bB,bC]=(0,f.useState)("selected"),bD=!!bf.selectedPath&&null!==(0,ab.c)(bf.selectedPath),[bE,bF]=(0,f.useState)(!1),bG=(0,f.useCallback)(async(a,c)=>{if(!bf.selectedPath||!bD)return;let d=await ba.goToDefinition(bf.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;bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),g===bf.selectedPath?bf.setTargetLineNumber(e.line):bu(g,e.line)},[bf,b,bD,ba,bd]),bH=(0,f.useCallback)((a,b,c,d,e)=>{a&&null!==(0,ab.c)(a)&&(bF(b),bb.onTokenMouseEnter(a,c,d,e))},[bb]),bI=(0,f.useCallback)((a,b,c)=>{bD&&bH(bf.selectedPath,!1,a,b,c)},[bf.selectedPath,bD,bH]),bJ=(0,f.useCallback)(a=>{let c=b.endsWith("/")?b:b+"/",d=a.file.startsWith(c)?a.file.slice(c.length):a.file;bf.selectedPath&&bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),d===bf.selectedPath?bf.setTargetLineNumber(a.line):bu(d,a.line)},[bf,b,bd]),bK=(0,f.useMemo)(()=>{if(!bk.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 bk.status.staged)a.set(c.path,b(c.status));for(let c of bk.status.unstaged)a.set(c.path,b(c.status));return a},[bk.status]),bL=(0,f.useMemo)(()=>{if(!bk.status)return null;let a=new Map;for(let b of bk.status.staged)"renamed"===b.status&&b.oldPath&&a.set(b.path,b.oldPath);return a},[bk.status]),bM=(0,f.useCallback)(a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},[bj.setContentSearchQuery,bj.performContentSearch]),bN=(0,Y.H)({cwd:b,selectedPath:bf.selectedPath,gitStatusMap:bK,renameOldPaths:bL,isText:bf.fileContent?.type==="text",refreshKey:bf.fileContent?.mtime}),bO="tree"===ax&&bN.showDiff,bP=(0,f.useCallback)(a=>{ay(a),bf.setBlameSelectedCommit(null),"history"===a&&bn.selectedBranch&&bn.loadCommits(bn.selectedBranch)},[bf,bn.selectedBranch,bn.loadCommits]);(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a={filePath:bf.selectedPath,lineNumber:aJ.current},b=bd.goBack(a);b&&(b.filePath===bf.selectedPath?bf.setTargetLineNumber(b.lineNumber):bu(b.filePath,b.lineNumber))},[bf,bd]),(0,f.useCallback)(()=>{if(!bf.selectedPath)return;let a={filePath:bf.selectedPath,lineNumber:aJ.current},b=bd.goForward(a);b&&(b.filePath===bf.selectedPath?bf.setTargetLineNumber(b.lineNumber):bu(b.filePath,b.lineNumber))},[bf,bd]);let bQ=(0,f.useCallback)(async a=>{let c=a.split("/").pop()||a,d=await j.t4.runPromiseExit((0,k.__)({cwd:b,path:a}));"Success"===d._tag?(0,r.oR)(ao("toast.copiedName",{name:c}),"success"):(0,r.oR)(ao("toast.copyFailed"),"error")},[b,ao]),bR=(0,f.useCallback)(async a=>{let c=await j.t4.runPromiseExit((0,k.dt)());if("Success"!==c._tag||!c.value.path)return void(0,r.oR)(ao("toast.noFileToPaste"),"info");let d=c.value.path,e=await j.t4.runPromiseExit((0,k.Nn)({cwd:b,targetDir:a,sourceAbsPath:d}));if("Success"===e._tag)(0,r.oR)(ao("toast.pastedFile",{name:e.value.newName}),"success"),bf.loadDirectory(a),bf.loadFileIndex();else{let a="Fail"===e.cause._tag?e.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:ao("toast.pasteFailed");(0,r.oR)(c,"error")}},[b,bf,ao]);(0,f.useRef)(0),(0,f.useRef)(be),(0,f.useRef)(ax),(0,f.useRef)(!1);let bS=(0,f.useRef)(bn.selectedBranch);bS.current=bn.selectedBranch;let bT=(0,f.useRef)(bf.selectedPath);bT.current=bf.selectedPath;let bU=(0,f.useRef)(bf.fileContent?.type);bU.current=bf.fileContent?.type;let bV=(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(j.t4.runPromise((0,k.mP)(b)).then(a=>{a.error||bf.setFiles(b=>(0,E.HR)(a.files??[],b))}).catch(()=>{})),f.push(j.t4.runPromise((0,k.DZ)(b)).then(a=>{a.paths&&bf.setFileIndex(a.paths)}).catch(()=>{})),f.push(j.t4.runPromise((0,k.r9)(b)).then(a=>{bf.setRecentFiles(a.files??[])}).catch(()=>{}))),d||e){f.push(j.t4.runPromise((0,m.lv)(b)).then(a=>{bk.setStatus(a);let b=(0,t.Do)(a.staged),c=(0,t.Do)(a.unstaged);bk.setStagedTree(b),bk.setUnstagedTree(c)}).catch(()=>{})),bk.refreshDiff(),d&&bn.loadBranches();let a=bS.current;a&&f.push(j.t4.runPromise((0,m.Bj)(b,a,E.B_)).then(a=>{let b=a.commits??[];bn.setCommits(b),bn.setHasMoreCommits(b.length>=E.B_)}).catch(()=>{}))}let g=bT.current,h=bU.current;g&&"text"===h&&f.push(j.t4.runPromise((0,l.K)(b,g)).then(a=>{let b=a.ok?a.data:null;b&&"string"==typeof b.content&&bf.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,J.h)({url:`/ws/watch?cwd=${encodeURIComponent(b)}`,onMessage:bV,enabled:be});let bW=(0,f.useCallback)(a=>{bu(a),bf.setShouldScrollToSelected(!0),ay("tree")},[bf,bu]);(0,f.useRef)(bu),(0,f.useRef)(null);let{setPreviewMarkdown:bX,setShouldScrollToSelected:bY}=bf,bZ=(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,r.oR)(ao("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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(),bW(a)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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,bW,ao]),b$=(0,f.useCallback)(({focalFile:a})=>"tree"===ax&&bN.canDiff&&a===bf.selectedPath?(0,e.jsxs)(e.Fragment,{children:[bN.showDiff&&(0,e.jsx)(p.y,{value:aY,onChange:aZ}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bN.showDiff?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,title:bN.showDiff?ao("fileBrowser.exitDiff"):ao("fileBrowser.viewDiff"),children:ao("common.diff")})]}):null,[ax,bN.canDiff,bN.showDiff,bN.toggleDiff,bf.selectedPath,aY,ao]),[b_,b0]=(0,f.useState)(null),b1=(0,f.useCallback)((a,b)=>{bf.setPreviewMarkdown(!0),bW(a),b0(b),b&&setTimeout(()=>b0(null),400)},[bf,bW]);return(0,e.jsxs)(u.SU,{container:aD,children:[(0,e.jsxs)("div",{ref:aB,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:a0},children:[(0,e.jsxs)("div",{className:"flex border-b border-border",children:[(0,e.jsx)("button",{onClick:()=>bP("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.directoryTree")}),(0,e.jsx)("button",{onClick:()=>bP("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.searchTab")}),(0,e.jsx)("button",{onClick:()=>bP("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.recentTab")}),(0,e.jsx)("button",{onClick:()=>bP("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.changesTab")}),(0,e.jsx)("button",{onClick:()=>bP("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===ax?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:ao("fileBrowser.historyTab")})]}),"tree"===ax&&(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:bf.searchInputRef,type:"text",value:bf.searchQuery,onChange:a=>bf.setSearchQuery(a.target.value),placeholder:ao("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"}),bf.searchQuery&&(0,e.jsx)("button",{onClick:()=>{bf.setSearchQuery(""),bf.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:ao("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:()=>bf.setSearchDirExact(a=>!a),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${bf.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-hover"}`,title:bf.searchExactMatch?ao("fileBrowser.exactMatchOn"):ao("fileBrowser.exactMatchOff"),children:"ab"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:()=>bf.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("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:()=>bf.searchTreeExpandedPaths?bf.setSearchTreeExpandedPaths(new Set):bf.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("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"===ax&&(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:bj.contentSearchInputRef,type:"text",value:bj.contentSearchQuery,onChange:a=>bj.setContentSearchQuery(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bj.performContentSearch(bj.contentSearchQuery)},placeholder:ao("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"}),bj.contentSearchQuery&&(0,e.jsx)("button",{onClick:()=>{bj.setContentSearchQuery(""),bj.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:ao("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:()=>bj.performContentSearch(bj.contentSearchQuery),disabled:bj.isSearching||!bj.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:bj.isSearching?"...":ao("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:bj.searchOptions.caseSensitive,onChange:a=>bj.setSearchOptions(b=>({...b,caseSensitive:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.caseSensitive")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bj.searchOptions.wholeWord,onChange:a=>bj.setSearchOptions(b=>({...b,wholeWord:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.wholeWord")})]}),(0,e.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:bj.searchOptions.regex,onChange:a=>bj.setSearchOptions(b=>({...b,regex:a.target.checked})),className:"w-3 h-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:ao("fileBrowser.regex")})]}),(0,e.jsx)("input",{type:"text",value:bj.searchOptions.fileType,onChange:a=>bj.setSearchOptions(b=>({...b,fileType:a.target.value})),placeholder:ao("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground"})]})]}),"history"===ax&&(0,e.jsx)("div",{className:"p-3 border-b border-border",children:bn.compareMode?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,e.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,e.jsx)("span",{className:"truncate",children:bn.branches?.current||"HEAD"}),(0,e.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,e.jsx)("button",{onClick:()=>bn.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:ao("fileBrowser.compareModeOff"),children:ao("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)(R.e,{branches:bn.branches,selectedBranch:bn.compareBaseBranch,onSelect:a=>{bn.setCompareBaseBranch(a),bn.loadCompareFiles(a)},isLoading:bn.isLoadingBranches,pinnedBranches:["origin/main",...bn.upstreamBranch&&"origin/main"!==bn.upstreamBranch?[bn.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)(R.e,{branches:bn.branches,selectedBranch:bn.selectedBranch,onSelect:a=>{bn.setSelectedBranch(a)},isLoading:bn.isLoadingBranches,pinnedBranches:["origin/main",...bn.upstreamBranch&&"origin/main"!==bn.upstreamBranch?[bn.upstreamBranch]:[]]})}),(0,e.jsx)("button",{onClick:()=>bn.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:ao("fileBrowser.compareModeOn"),children:ao("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"===ax?"":"hidden"}`,children:[bf.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:bf.creatingItem.parentPath?ao("fileBrowser.createFileIn",{path:bf.creatingItem.parentPath}):ao("fileBrowser.createFile")}),(0,e.jsx)("input",{type:"text",autoFocus:!0,placeholder:ao("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:()=>{aC.current=!0},onCompositionEnd:()=>{aC.current=!1},onKeyDown:async a=>{if("Enter"===a.key){if(aC.current)return;let c=a.target.value.trim();if(!c)return;let d=bf.creatingItem.parentPath,e=d?`${d}/${c}`:c,f=await j.t4.runPromiseExit((0,k.OJ)({cwd:b,path:e,content:""}));if("Success"===f._tag&&f.value.ok)(0,r.oR)(ao("toast.createdFile",{name:c}),"success"),bf.setCreatingItem(null),bf.loadDirectory(d),bf.loadFileIndex(),d&&bf.setExpandedPaths(a=>new Set([...a,d])),bu(e);else if("Success"===f._tag){let a=f.value.data?.error;(0,r.oR)(a||ao("toast.createFailed"),"error")}else(0,r.oR)(ao("toast.createFailed"),"error")}else"Escape"===a.key&&bf.setCreatingItem(null)},onBlur:()=>bf.setCreatingItem(null)})]}),bf.isLoadingFiles&&0===bf.files.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("common.loading")}):bf.fileError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bf.fileError}):(0,e.jsx)(s.h,{files:bf.files,selectedPath:bf.selectedPath,expandedPaths:bf.effectiveExpandedPaths,matchedPaths:bf.matchedPaths,gitStatusMap:bK,loadingDirs:bf.loadingDirs,onSelect:a=>{bf.setShouldScrollToSelected(!1),bu(a)},onToggle:bf.handleToggle,cwd:b,shouldScrollToSelected:bf.shouldScrollToSelected,onScrolledToSelected:()=>bf.setShouldScrollToSelected(!1),onCreateFile:a=>bf.setCreatingItem({type:"file",parentPath:a}),onDelete:(a,b,c)=>aG({path:a,isDirectory:b,name:c}),onRefresh:()=>bf.loadFiles(),onCopyFile:bQ,onPaste:bR,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading})]}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===ax?"":"hidden"}`,children:bj.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"})}):bj.searchError?(0,e.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:bj.searchError}):0===bj.contentSearchResults.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:bj.contentSearchQuery?ao("fileBrowser.noContentSearchResults"):ao("fileBrowser.enterKeywordToSearch")}):(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[bj.searchStats&&(0,e.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b border-border flex-shrink-0",children:[ao("fileBrowser.nFilesNMatches",{files:bj.searchStats.totalFiles,matches:bj.searchStats.totalMatches}),bj.searchStats.truncated&&(0,e.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",ao("fileBrowser.resultsTruncated"),")"]})]}),(0,e.jsx)(s.h,{files:bv.files,selectedPath:bf.selectedPath,expandedPaths:bw,onSelect:a=>{let b=bv.matchMap.get(a);bu(a,b?.matches[0]?.lineNumber),aQ||aR(!0)},onToggle:by,cwd:b,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading,renderActions:bz,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"===ax?"":"hidden"}`,children:0===bf.recentFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noRecentFiles")}):(0,e.jsx)(s.h,{files:bf.recentFilesTree,selectedPath:bf.selectedPath,expandedPaths:bf.recentTreeDirPaths,onSelect:bu,onToggle:E.tE,cwd:b,onExplain:ap?aq:void 0,explainDisabled:ap?.isLoading})}),(0,e.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===ax?"":"hidden"}`,children:bk.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"})}):bk.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:bk.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:ao("fileBrowser.stagingArea",{count:bk.status?.staged.length||0})}),(0,e.jsx)("button",{onClick:()=>bk.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:ao("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"})})})]}),(bk.status?.staged.length||0)>0&&(0,e.jsx)("button",{onClick:bk.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:ao("fileBrowser.unstageAll")})]}),(0,e.jsx)(t.VO,{files:bk.stagedTree,selectedPath:bk.statusSelectedFile?.type==="staged"?bk.statusSelectedFile.file.path:null,expandedPaths:bk.stagedExpandedPaths,onSelect:a=>a.file&&bk.handleStatusFileSelect(a.file,"staged"),onToggle:bk.handleStagedToggle,cwd:b,emptyMessage:ao("fileBrowser.noStagedFiles"),className:"py-1",onExplain:ap?ar:void 0,explainDisabled:ap?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,t.wI)(a);return 0===b.length?null:(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bk.handleUnstageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:ao("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(),bk.handleUnstage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:ao("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:ao("fileBrowser.workspace",{count:bk.status?.unstaged.length||0})}),(bk.status?.unstaged.length||0)>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:bk.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:ao("fileBrowser.discardAll")}),(0,e.jsx)("button",{onClick:bk.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:ao("fileBrowser.stageAll")})]})]}),(0,e.jsx)(t.VO,{files:bk.unstagedTree,selectedPath:bk.statusSelectedFile?.type==="unstaged"?bk.statusSelectedFile.file.path:null,expandedPaths:bk.unstagedExpandedPaths,onSelect:a=>a.file&&bk.handleStatusFileSelect(a.file,"unstaged"),onToggle:bk.handleUnstagedToggle,cwd:b,emptyMessage:ao("fileBrowser.noUnstagedChanges"),className:"py-1",onExplain:ap?as:void 0,explainDisabled:ap?.isLoading,renderActions:a=>{if(a.isDirectory){let b=(0,t.wI)(a);if(0===b.length)return null;let c=b.map(a=>a.file).filter(Boolean);return(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),bk.handleDiscardFiles(c)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:ao("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(),bk.handleStageFiles(b.map(a=>a.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:ao("fileBrowser.stageNFiles",{count:b.length}),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return a.file?(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),bk.handleDiscardFile(a.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:ao("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(),bk.handleStage(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:ao("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"===ax?"":"hidden"}`,children:bn.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:bn.historyError})]})}):bn.compareMode?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:bn.isLoadingCompareFiles?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingDiff")}):0===bn.compareFiles.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noDiffFiles")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:ao("fileBrowser.nFilesChanged",{count:bn.compareFiles.length,branch:bn.compareBaseBranch})})}),(0,e.jsx)(t.VO,{files:bn.compareFileTree,expandedPaths:bn.compareExpandedPaths,onToggle:bn.handleCompareToggle,selectedPath:bn.compareSelectedFile?.path||null,onSelect:a=>{a.file&&bn.handleSelectCompareFile(a.file)},cwd:b,showChanges:!0,onExplain:ap?bo:void 0,explainDisabled:ap?.isLoading})]})}):(0,e.jsx)("div",{ref:bn.commitListRef,className:"flex-1 overflow-y-auto",onScroll:bn.handleCommitListScroll,children:bn.isLoadingCommits?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingCommits")}):0===bn.commits.length?(0,e.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:ao("fileBrowser.noCommits")}):(0,e.jsxs)(e.Fragment,{children:[bn.commits.map(a=>(0,e.jsxs)("div",{onClick:()=>bn.handleSelectCommit(a),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-hover ${bn.selectedCommit?.hash===a.hash?"bg-brand/10":""}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-brand",children:a.shortHash}),(0,e.jsxs)("span",{className:"text-xs text-foreground-subtle","data-tooltip":a.date,children:[a.relativeDate," \xb7 ",(0,E.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)),bn.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"})}),!bn.hasMoreCommits&&bn.commits.length>0&&(0,e.jsx)("div",{className:"p-3 text-center text-xs text-foreground-subtle",children:ao("fileBrowser.allLoaded",{count:bn.commits.length})})]})})})]})]}),(0,e.jsx)("div",{onPointerDown:a3,onPointerMove:a4,onPointerUp:a5,onPointerCancel:a5,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",children:[("tree"===ax||"search"===ax||"recent"===ax)&&(bf.blameSelectedCommit?(0,e.jsx)(n.n,{isOpen:!0,onClose:()=>bf.setBlameSelectedCommit(null),commit:bf.blameSelectedCommit,cwd:b,embedded:!0,initialFilePath:bf.selectedPath||void 0,onLocateInTree:bW,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):"map"===az?bO&&bN.diff?(0,e.jsx)(N.r,{cwd:b,filePath:bN.diff.filePath,oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,isNew:bN.diff.isNew,isDeleted:bN.diff.isDeleted,changedFiles:bl,fileGitStatusMap:bm,compact:"compact"===aY,enableComments:!0,onSwitchToCode:()=>aA("code"),onContentSearch:bM,headerExtraLeft:bZ,headerExtraRight:b$}):(0,e.jsx)(M.O,{cwd:b,highlightedFilePath:bf.selectedPath,changedFiles:bl,onSwitchToCode:()=>aA("code"),enableComments:!0,onContentSearch:bM,headerExtraLeft:bZ,headerExtraRight:b$}):bf.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:bf.selectedPath}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(`${b}/${bf.selectedPath}`),(0,r.oR)(ao("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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(),bW(bf.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0",title:ao("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:bf.showEditor?(0,e.jsxs)(e.Fragment,{children:[aO.isDirty&&(0,e.jsx)("span",{className:"text-xs text-amber-11",children:ao("fileBrowser.unsaved")}),(0,e.jsx)("button",{onClick:()=>aN.current?.save(),disabled:!aO.isDirty||aO.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aO.isDirty&&!aO.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:aO.isSaving?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):ao("common.save")}),(0,e.jsx)("button",{onClick:()=>aN.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.closeEdit"),children:ao("fileBrowser.closeBtn")})]}):bO?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(p.y,{value:aY,onChange:aZ}),(0,e.jsx)(q.q,{value:a$,onChange:a_}),!(0,w.e$)(bf.selectedPath)&&!(0,w.aR)(bf.selectedPath)&&!(0,w.Hz)(bf.selectedPath)&&!(0,w.Zy)(bf.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("blockViewer.viewerToggle.toBlock"),children:ao("common.codeMap")}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors bg-brand text-white",children:ao("fileBrowser.exitDiff")})]}):(0,e.jsxs)(e.Fragment,{children:["tree"===ax&&bN.canDiff&&(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.viewDiff"),children:ao("common.diff")}),bf.fileContent?.type==="text"&&(0,w.e$)(bf.selectedPath)&&(0,e.jsx)(H.ShareReviewToggle,{content:bf.fileContent.content||"",sourceFile:bf.selectedPath&&b&&bf.selectedPath.startsWith(b)?bf.selectedPath.slice(b.endsWith("/")?b.length:b.length+1):bf.selectedPath||""}),bf.fileContent?.type==="text"&&(0,w.Hz)(bf.selectedPath)&&bf.previewMarkdown&&!bf.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(),bi(b=>({version:b.version+1,collapsed:a}))},className:`px-2 py-0.5 text-xs transition-colors ${bh.collapsed===a?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:ao(a?"fileBrowser.collapseAllJson":"fileBrowser.expandAllJson")},String(a)))}),bf.fileContent?.type==="text"&&((0,w.e$)(bf.selectedPath)||(0,w.aR)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))&&(aj=(ai=(0,w.aR)(bf.selectedPath))?bf.previewHtml:bf.previewMarkdown,(0,e.jsx)("button",{onClick:()=>ai?bf.setPreviewHtml(a=>!a):bf.setPreviewMarkdown(a=>!a),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${aj?"bg-brand text-white":"text-muted-foreground hover:bg-hover"}`,children:aj?ao("fileBrowser.exitPreview"):ao("common.preview")})),bf.fileContent?.type==="text"&&(0,w.C_)(bf.selectedPath||"")&&(al=(ak=bf.selectedPath||"").startsWith("/")?ak:b?`${b.replace(/\/$/,"")}/${ak}`:ak,(0,e.jsx)("button",{onClick:()=>au(al),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("skills.addTooltip"),children:(0,e.jsx)(y.A,{className:"w-3.5 h-3.5"})})),bf.fileContent?.type==="text"&&(0,w.aR)(bf.selectedPath)&&(an=(am=bf.selectedPath||"").startsWith("/")?am:b?`${b.replace(/\/$/,"")}/${am}`:am,(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>at(an),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("htmlApps.addTooltip"),children:(0,e.jsx)(y.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("console-open-browser",{detail:{url:an}})),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover flex items-center",title:ao("common.openInConsole"),children:(0,e.jsx)(z.A,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("button",{onClick:()=>{let a=(0,B.Xe)(an);window.open((0,B.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:ao("browser.openInNewWindow"),children:(0,e.jsx)(A.A,{className:"w-3.5 h-3.5"})})]})),bf.fileContent?.type==="text"&&!(bf.previewMarkdown&&((0,w.e$)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))||bf.previewHtml&&(0,w.aR)(bf.selectedPath))&&(0,e.jsx)("button",{onClick:bf.handleToggleBlame,disabled:bf.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${bf.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-hover"} disabled:opacity-50`,title:ao("fileBrowser.viewBlame"),children:bf.isLoadingBlame?(0,e.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),bf.fileContent?.type==="text"&&!(bf.previewMarkdown&&((0,w.e$)(bf.selectedPath)||(0,w.Hz)(bf.selectedPath)||(0,w.Zy)(bf.selectedPath))||bf.previewHtml&&(0,w.aR)(bf.selectedPath))&&(0,e.jsx)("button",{onClick:()=>bf.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.editFile"),children:ao("common.edit")}),bf.fileContent?.type==="text"&&bf.fileContent.content&&(0,e.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(bf.fileContent.content),(0,r.oR)(ao("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("fileBrowser.copyFileContent"),children:ao("common.copy")}),bf.fileContent?.type==="text"&&!(0,w.e$)(bf.selectedPath)&&!(0,w.aR)(bf.selectedPath)&&!(0,w.Hz)(bf.selectedPath)&&!(0,w.Zy)(bf.selectedPath)&&(0,e.jsx)("button",{onClick:()=>aA("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-hover",title:ao("blockViewer.viewerToggle.toBlock"),children:ao("common.codeMap")})]})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:bf.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"})}):bf.fileContent?"text"===bf.fileContent.type&&"string"==typeof bf.fileContent.content?bO?bN.isLoadingDiff&&!bN.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"})}):bN.diff?"unified"===a$?(0,e.jsx)(o.xU,{oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,filePath:bN.diff.filePath,cwd:b,enableComments:!0,compact:"compact"===aY,onContentSearch:bM,onTokenHover:(a,b,c)=>bH(bN.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.clearHover}):(0,e.jsx)(o.xZ,{oldContent:bN.diff.oldContent,newContent:bN.diff.newContent,filePath:bN.diff.filePath,isNew:bN.diff.isNew,isDeleted:bN.diff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===aY,onContentSearch:bM,onTokenHover:(a,b,c)=>bH(bN.diff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.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:ao("fileBrowser.diffLoadFailed")}),(0,e.jsx)("button",{onClick:bN.toggleDiff,className:"mt-2 text-brand hover:underline text-sm",children:ao("fileBrowser.exitDiff")})]})}):bf.showBlame&&bf.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:bf.blameError}),(0,e.jsx)("button",{onClick:()=>bf.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:ao("fileBrowser.backToPreview")})]})}):bf.showBlame&&0===bf.blameLines.length&&bf.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"})}):bf.previewMarkdown&&(0,w.Hz)(bf.selectedPath)&&!bf.showBlame?(0,e.jsxs)("div",{className:"h-full flex flex-col bg-background text-foreground",children:[(0,e.jsx)(aa._,{search:a7}),(0,e.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,e.jsx)("pre",{ref:a6,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:(0,e.jsx)(w.d9.Provider,{value:bh,children:bg})})})]}):bf.previewMarkdown&&(0,w.Zy)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)(x.C0,{content:bf.fileContent.content,filePath:bf.selectedPath,className:"h-full"}):bf.previewMarkdown&&(0,w.e$)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)("div",{className:"h-full flex flex-col",children:(0,e.jsx)(F.M,{content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,embedded:!0,onLocalMdLink:b1,scrollToAnchor:b_})}):bf.previewHtml&&(0,w.aR)(bf.selectedPath)&&!bf.showBlame?(0,e.jsx)(G.O,{content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)(v.Cv,{ref:aN,content:bf.fileContent.content,filePath:bf.selectedPath,cwd:b,enableComments:!0,scrollToLine:aL??bf.targetLineNumber,scrollToLineAlign:null!=aL?"start":bf.targetScrollAlign,onScrollToLineComplete:()=>{aM(null),bf.setTargetLineNumber(null)},highlightKeyword:"search"===ax?bj.contentSearchQuery:null,visibleLineRef:aJ,viStateRef:aK,initialCursorLine:bf.initialCursorLine,initialCursorCol:bf.initialCursorCol,onInitialCursorSet:()=>{bf.setInitialCursorLine(null),bf.setInitialCursorCol(null)},onCmdClick:bD?bG:void 0,onTokenHover:bD?bI:void 0,onTokenHoverLeave:bD?bb.onTokenMouseLeave:void 0,onTokenHoverCancel:bD?bb.clearHover:void 0,blameLines:bf.showBlame&&bf.blameLines.length>0?bf.blameLines:void 0,inlineBlameLines:bf.blameLines.length>0?bf.blameLines:void 0,onSelectCommit:bf.setBlameSelectedCommit,editable:bf.showEditor,initialMtime:bf.fileContent.mtime,onEditorClose:a=>{bf.setShowEditor(!1),aM(a)},onSaved:()=>{let a=aJ.current??1;bf.loadFileContent(bf.selectedPath),bf.setShowEditor(!1),aM(a)},onEditorStateChange:aP,viMode:!0,onContentMutate:bq,onEnterInsertMode:br,onViSave:bs,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):"image"===bf.fileContent.type&&bf.selectedPath?(0,e.jsx)(S.I,{cwd:b,path:bf.selectedPath,refreshKey:bf.fileContent.mtime,alt:bf.selectedPath}):"pdf"===bf.fileContent.type&&bf.selectedPath?(0,e.jsx)(T.t,{cwd:b,path:bf.selectedPath,refreshKey:bf.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:bf.fileContent.message||ao("fileBrowser.cannotPreview")})]})}):(0,e.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:ao("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:ao("fileBrowser.selectFileToPreview")})]})})),"status"===ax&&(bk.statusSelectedFile&&bk.statusDiff?(0,e.jsx)(O.m,{cwd:b,selected:bk.statusSelectedFile,diff:bk.statusDiff,showMarkdownPreview:bk.showStatusDiffPreview,setShowMarkdownPreview:bk.setShowStatusDiffPreview,changedFiles:bl,fileGitStatusMap:bm,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},locateInTree:bW,jsonPreview:aS,setJsonPreview:aT,jsonPreviewSearch:a9,jsonPreviewPreRef:a8,onTokenHover:(a,b,c)=>bH(bk.statusDiff?.filePath,!0,a,b,c),onTokenHoverLeave:bb.onTokenMouseLeave,onTokenHoverCancel:bb.clearHover}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:ao("fileBrowser.selectFileToViewDiff")})})),"history"===ax&&!bn.historyError&&(bn.compareMode?bn.isLoadingCompareDiff?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:ao("fileBrowser.loadingDiffContent")}):bn.compareFileDiff?(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",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)(Q.d,{cwd:b,filePath:bn.compareFileDiff.filePath,onLocateInTree:bW}),!(0,E.u)(bn.compareFileDiff.filePath)&&(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsx)(p.y,{value:aU,onChange:aV}),(0,e.jsx)(q.q,{value:aW,onChange:aX})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,E.u)(bn.compareFileDiff.filePath)?(0,e.jsx)(P.M,{cwd:b,filePath:bn.compareFileDiff.filePath,oldRev:bn.compareFileDiff.oldRev??(bn.compareFileDiff.isNew?null:bn.compareBaseBranch),newRev:bn.compareFileDiff.newRev??(bn.compareFileDiff.isDeleted?null:"HEAD")}):"unified"===aW?(0,e.jsx)(o.xU,{oldContent:bn.compareFileDiff.oldContent,newContent:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath,cwd:b,enableComments:!0,compact:"compact"===aU,onPreview:!bn.compareFileDiff.isDeleted&&bn.compareFileDiff.filePath.endsWith(".json")?()=>aT({content:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath}):void 0,previewLabel:ao("common.readable"),onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)(o.xZ,{oldContent:bn.compareFileDiff.oldContent,newContent:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath,isNew:bn.compareFileDiff.isNew,isDeleted:bn.compareFileDiff.isDeleted,cwd:b,enableComments:!0,compact:"compact"===aU,onPreview:!bn.compareFileDiff.isDeleted&&bn.compareFileDiff.filePath.endsWith(".json")?()=>aT({content:bn.compareFileDiff.newContent,filePath:bn.compareFileDiff.filePath}):void 0,previewLabel:ao("common.readable"),onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}})})]}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:bn.compareFiles.length>0?ao("fileBrowser.selectFileToViewDiff"):ao("fileBrowser.clickCompareToLoad")})}):bn.selectedCommit?(0,e.jsx)(n.n,{isOpen:!0,onClose:()=>bn.setSelectedCommit(null),commit:bn.selectedCommit,cwd:b,embedded:!0,onLocateInTree:bW,onContentSearch:a=>{ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)}}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-foreground-subtle",children:(0,e.jsx)("span",{children:ao("fileBrowser.selectCommitToView")})}))]})]}),aH&&(0,e.jsx)(I.c,{files:bf.files,fileIndex:bf.fileIndex,recentFiles:bf.recentFilePaths,onSelectFile:a=>{bu(a),bf.setShouldScrollToSelected(!0),ay("tree")},onClose:()=>aI(!1)}),(bA||bc.visible)&&(0,e.jsxs)("div",{className:`flex ${bc.visible&&bA?"":"flex-col"}`,children:[bA&&(0,e.jsx)("div",{className:bc.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,e.jsx)(ae.D,{results:bj.contentSearchResults,loading:bj.isSearching,totalMatches:bj.searchStats?.totalMatches??0,onSelect:(a,b)=>{bf.selectedPath&&bd.push({filePath:bf.selectedPath,lineNumber:aJ.current}),aA("code"),bu(a,b)},onClose:()=>aR(!1),scope:bB,onScopeChange:bC,selectedPath:bf.selectedPath})}),bc.visible&&(0,e.jsx)("div",{className:bA?"flex-1 min-w-0":"",children:(0,e.jsx)(ad.D,{references:bc.references,loading:bc.loading,onSelect:bJ,onClose:bc.closeReferences})})]})]}),aF&&(0,e.jsx)(i.ZL,{children:(0,e.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim",onClick:()=>aG(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:ao("fileBrowser.confirmDelete")}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:ao("fileBrowser.confirmDeleteMessage",{name:aF.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:()=>aG(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-hover transition-colors",children:ao("common.cancel")}),(0,e.jsx)("button",{onClick:async()=>{let{path:a,name:c}=aF;aG(null);let d=await j.t4.runPromiseExit((0,k.VK)({cwd:b,path:a}));if("Success"===d._tag){(0,r.oR)(ao("toast.movedToTrash",{name:c}),"success");let b=a.includes("/")?a.substring(0,a.lastIndexOf("/")):"";bf.loadDirectory(b),bf.loadFileIndex(),bf.selectedPath===a&&bu("")}else{let a="Fail"===d.cause._tag?d.cause.error:null,b=a?.cause,c=b instanceof Error?b.message:ao("toast.deleteFailed");(0,r.oR)(c,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:ao("common.delete")})]})]})})}),bb.hoverInfo&&aD&&(0,h.createPortal)((0,e.jsx)(ac.s,{ref:bb.setTooltipEl,displayString:bb.hoverInfo.displayString,documentation:bb.hoverInfo.documentation,x:bb.hoverInfo.x,y:bb.hoverInfo.y,container:aD,onMouseEnter:bb.onCardMouseEnter,onMouseLeave:bb.onCardMouseLeave,onFindReferences:bE?void 0:()=>{let{filePath:a,line:b,column:c}=bb.hoverInfo;bb.clearHover(),bc.findReferences(a,b,c)},onSearch:a=>{bb.clearHover(),ay("search"),bj.setContentSearchQuery(a),bj.performContentSearch(a)},onExplain:ap?a=>{let{filePath:b,line:c}=bb.hoverInfo;bb.clearHover(),ap.sendMessage(ao("explain.symbolMessage",{name:a,path:b,lines:String(c)}))}:void 0,explainDisabled:ap?.isLoading}),aD)]})});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:()=>j,n:()=>i});var d=c(48249),e=c(67484),f=c(44384);c(59336);var g=c(33281),h=c(41224);function i({value:a,onChange:b,textareaRef:c,extraCommands:d}){let[f,j]=(0,e.useState)(a.length),[k,l]=(0,e.useState)([]),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(0),[q,r]=(0,e.useState)(()=>a.length>0),s=(0,e.useRef)(null);(0,e.useCallback)(async()=>{let a=await g.t4.runPromiseExit((0,h.l1)());if("Success"===a._tag){let b=a.value.skills??a.value;n((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)},[]);let t=(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]),u=(0,e.useMemo)(()=>{let a=t.text.match(/^\s*([/@])([a-zA-Z0-9-]*)$/);return a?{marker:a[1],verb:a[2].toLowerCase()}:null},[t.text]),v=(0,e.useMemo)(()=>{if(!u)return[];let{verb:a}=u,b=b=>b.name.slice(1).toLowerCase().startsWith(a);return[...(d??[]).filter(b),...k.filter(b),...m.filter(b)]},[u,d,k,m]),w=!q&&!!u&&v.length>0;(0,e.useRef)(a);let x=(0,e.useCallback)(a=>{j(a.selectionStart??0)},[]),y=(0,e.useCallback)(d=>{let e=u?.marker??"/",f=`${e}${d.name.slice(1)} `,g=a.slice(0,t.start),h=a.slice(t.end),i=g.length+f.length;b(g+f+h),j(i),requestAnimationFrame(()=>{let a=c.current;a&&(a.focus(),a.setSelectionRange(i,i))})},[a,t,u,b,c]),z=(0,e.useCallback)(a=>{if(a.nativeEvent.isComposing||!w||0===v.length)return!1;let b=()=>{a.preventDefault(),a.stopPropagation()};return"ArrowDown"===a.key?(b(),p(a=>(a+1)%v.length),!0):"ArrowUp"===a.key?(b(),p(a=>(a-1+v.length)%v.length),!0):"Enter"===a.key||"Tab"===a.key?(b(),y(v[o]),!0):"Escape"===a.key&&(b(),r(!0),!0)},[w,v,o,y]);return{isOpen:w,items:v,selectedIndex:o,marker:u?.marker??"/",listRef:s,selectCommand:y,handleKeyDown:z,trackCaret:x}}function j({ac:a,className:b=""}){let{t:c}=(0,f.Bd)(),{isOpen:e,items:g,selectedIndex:h,marker:i,listRef:k,selectCommand:l}=a;return e&&0!==g.length?(0,d.jsx)("div",{ref:k,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="skill"!==a.source&&0===b;return(0,d.jsxs)("div",{children:[j&&(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"}),(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"}})(a.source)}`,children:(a=>{switch(a){case"builtin":return c("common.builtin");case"skill":return"Skill"}})(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})}},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:()=>A});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(98356),t=c(64676),u=c(84835);c(15466);var v=c(60591),w=c(34728),x=c(24680),y=c(92608),z=c(37690);let a=[u.W];function A({content:b,filePath:c,cwd:d,onClose:u,sourceFile:B,embedded:C=!1,onLocalMdLink:D,scrollToAnchor:E}){let F=B||(d&&c.startsWith(d)?c.slice(d.endsWith("/")?d.length:d.length+1):c),{t:G}=(0,g.Bd)(),H=(0,j.iN)(),I=(0,p.r)(),J=(0,w.U)(),{comments:K,addComment:L,updateComment:M,deleteComment:N,refresh:O}=(0,o._)({cwd:d,filePath:c}),[P,Q]=(0,f.useState)(!1),[R,S]=(0,f.useState)(null),[T,U]=(0,f.useState)(null),[V,W]=(0,f.useState)(null),X=(0,f.useMemo)(()=>b.split("\n"),[b]),Y=(0,f.useMemo)(()=>(0,t.J4)(c,d),[c,d]),[Z,$]=(0,f.useState)(null),_=(0,f.useRef)(null),aa=(0,f.useRef)({onLocalMdLink:D,sourceFile:F});aa.current={onLocalMdLink:D,sourceFile:F};let ab=(0,f.useRef)(a=>{let{onLocalMdLink:b,sourceFile:c}=aa.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:ac,bumpRef:ad,clearToolbar:ae}=(0,z.L)({enabled:!0,container:Z,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(X.length,b);return X.slice(c,d).join("\n")}}),af=(0,f.useCallback)(()=>{let a=ac.current;a&&(S({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ae())},[ae,ac]),ag=(0,f.useCallback)(()=>{let a=ac.current;a&&(U({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),ae())},[ae,ac]),ah=(0,f.useCallback)(()=>{let a=ac.current;a&&I&&(ae(),(0,q.Ff)(I.sendMessage,{filePath:c,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},r.A.t("explain.selectionMessage")))},[I,c,ae,ac]),ai=(0,f.useCallback)(async a=>{R&&(await L(R.range.start,R.range.end,a,R.selectedText),S(null))},[R,L]),aj=(0,f.useCallback)(async(a,b)=>{if(I)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);I.sendMessage(g),await (0,q.RP)(d),O()}catch(a){console.error("Failed to send to AI:",a)}},[I,c,d,O]),ak=(0,f.useCallback)(a=>{T&&aj(T,a)},[T,aj]),al=(0,f.useCallback)(a=>{R&&aj(R,a)},[R,aj]);(0,f.useMemo)(()=>{if(0===K.length)return[];let a=new Map;for(let b of K){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}))},[K]);let[am,an]=(0,f.useState)([]);return(0,e.jsxs)(e.Fragment,{children:[!C&&(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)(G("common.copiedPath"))},children:["",c]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(y.ShareReviewToggle,{content:b,sourceFile:F}),(0,v.C_)(c)&&(0,e.jsx)("button",{onClick:()=>J(c.startsWith("/")||!d?c:`${d.replace(/\/$/,"")}/${c}`),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors",title:G("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:G("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)(x.l,{content:b,containerRef:_}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:_,children:[(0,e.jsx)("div",{className:"p-6",children:(0,e.jsx)(s.T,{content:b,basePath:Y,rehypePlugins:a,onLinkClick:ab})}),am.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(),W({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))]})]}),P&&H&&(0,i.createPortal)((0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.fS,{floatingToolbarRef:ac,bumpRef:ad,container:H,onAddComment:af,onSendToAI:ag,onExplain:I?ah:void 0,isChatLoading:I?.isLoading}),R&&(0,e.jsx)(m.t,{x:R.x,y:R.y,range:R.range,filePath:c,lineSnapshot:R.lineSnapshot,container:H,onSubmit:ai,onSendToAI:I?al:void 0,onClose:()=>S(null),isChatLoading:I?.isLoading}),T&&(0,e.jsx)(m.G,{x:T.x,y:T.y,range:T.range,filePath:c,lineSnapshot:T.lineSnapshot,container:H,onSubmit:ak,onClose:()=>U(null),isChatLoading:I?.isLoading}),V&&(0,e.jsx)(n.t,{x:V.x,y:V.y,comment:V.comment,container:H,onClose:()=>W(null),onUpdateComment:M,onDeleteComment:N})]}),H)]})}d()}catch(a){d(a)}})},74228:(a,b,c)=>{"use strict";c.d(b,{S:()=>f,l:()=>g});var d=c(48249),e=c(40311);function f(a){return"loading"===a||"unread"===a?a:"normal"}function g({projectNumber:a,sessionNumber:b,coordinate:c,status:f="normal",statusLabel:h,className:i=""}){if(c){let[d,e]=c.split(".");a??=d,b??=e}if(null==a&&null==b)return null;let j="flex h-4 w-4 items-center justify-center border",k=[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 ${i}`,"aria-label":h?`${k} \xb7 ${h}`:k,children:[null!=a&&(0,d.jsx)("span",{className:`${j} rounded-[4px] ${(0,e.c)("normal",!1)}`,children:a}),null!=b&&(0,d.jsx)("span",{className:`${j} rounded-full ${(0,e.c)(f,!1)}`,title:h,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:()=>s});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(15819);c(33281);var j=c(13054),k=c(30458),l=c(36688),m=c(32753),n=c(74228),o=c(15790);c(41224);var p=a([o,l]);function q(a){return a.engine||"claude"}function r(a){return a.lastFiredAt??a.createdAt}[o,l]=p.then?(await p)():p;let t=[{key:"pendingReview",labelKey:"scheduledTasks.groupPendingReview"},{key:"upcoming",labelKey:"scheduledTasks.groupUpcoming"},{key:"paused",labelKey:"scheduledTasks.paused"}];function s({collapsed:a,tasks:b,unreadCount:c,sessionNumbers:d,onSwitchProject:p,onPause:u,onResume:v,onTrigger:w,onDelete:x,onMarkRead:y,onUpdateTask:z}){let{t:A}=(0,g.Bd)(),[B,C]=(0,f.useState)(!1),[D,E]=(0,f.useState)(null),F=(0,f.useRef)(null),G=(0,f.useRef)(null),[H,I]=(0,f.useState)(null),J=(0,f.useCallback)(()=>{E(null),F.current=null,I(null)},[]),[K,L]=(0,f.useState)(null),[M,N]=(0,f.useState)(null),[O,P]=(0,f.useState)(null),[Q,R]=(0,f.useState)(null),S=b.filter(a=>!a.completed),T=S.filter(a=>!a.paused).length,U=(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)||r(b)-r(a)),c.sort((a,b)=>(a.nextFireTime||Number.MAX_SAFE_INTEGER)-(b.nextFireTime||Number.MAX_SAFE_INTEGER)),d.sort((a,b)=>r(b)-r(a)),{pendingReview:b,upcoming:c,paused:d}})(b),[b]),V=O?b.find(a=>a.id===O)??null:null,[,W]=(0,f.useState)(0),X=(0,f.useCallback)(()=>{L(null),N(null)},[]),Y=(0,f.useCallback)(async a=>{let b=!!a.taskFile;try{await navigator.clipboard.writeText(b?a.taskFile:a.message),(0,h.oR)(A(b?"common.copiedPath":"toast.copiedMessage"),"success")}catch{(0,h.oR)(A("common.copyFailed"),"error")}},[A]),Z=(0,f.useCallback)(()=>{C(!1),P(null)},[]),$=(0,f.useCallback)(a=>{p(a.cwd,a.sessionId),a.unread&&y(a.id),Z()},[p,y,Z]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{onClick:()=>C(!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?A("scheduledTasks.title"):void 0,children:[(0,e.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,e.jsx)("span",{className:"text-sm flex-1 text-left",children:A("scheduledTasks.title")}),c>0?(0,e.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-foreground text-xs font-medium rounded-full flex items-center justify-center bg-red-9/55 ${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]}),B&&(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:Z}),(0,e.jsxs)("div",{className:i.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:A("scheduledTasks.title")}),S.length>0&&(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[A("scheduledTasks.activeCount",{running:T}),S.length-T>0?` \xb7 ${A("scheduledTasks.pausedCount",{paused:S.length-T})}`:""]})]}),(0,e.jsx)("button",{onClick:Z,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:A("scheduledTasks.noScheduledTasks")})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-full md:w-[360px] flex-shrink-0 md:border-r border-border overflow-y-auto p-3 space-y-4",children:t.map(({key:a,labelKey:b})=>{let c=U[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:[A(b)," (",c.length,")"]}),(0,e.jsx)("div",{className:"mt-1 space-y-2",children:c.map(a=>{let b,c;return b=a.id===O,(0,e.jsxs)("div",{onClick:()=>P(a.id),onMouseLeave:()=>R(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)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.unread?"bg-red-9":a.completed?"bg-muted-foreground/30":a.paused?"bg-amber-9":"error"===a.lastResult?"bg-red-9":"bg-green-9"}`}),(0,e.jsx)(m.S,{engine:q(a),tooltip:(c=q(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,j.P_)(a.cwd)}),(0,e.jsx)(n.l,{coordinate:d?.[`${a.cwd}
|
|
730
731
|
${a.sessionId}`]}),(0,e.jsx)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0 group-hover:hidden",children:a.completed?A("scheduledTasks.completed"):a.paused?A("scheduledTasks.paused"):A("common.running")}),Q===a.id?(0,e.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-1",children:[(0,e.jsx)("button",{onClick:b=>{b.stopPropagation(),R(null),x(a.id)},className:"px-2 py-0.5 text-[10px] rounded bg-red-9 text-white hover:bg-red-10",children:A("common.confirm")}),(0,e.jsx)("button",{onClick:a=>{a.stopPropagation(),R(null)},className:"px-2 py-0.5 text-[10px] rounded border border-border text-muted-foreground hover:text-foreground",children:A("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(),L(a.taskFile)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:A("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(),Y(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:A(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(),w(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:A("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(),F.current=b.currentTarget,E(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:A("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(),v(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-11",title:A("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(),u(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-amber-11",title:A("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(),R(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:A("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,j.Q_)(a),children:(0,j.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,A)}),(0,e.jsx)("span",{children:"\xb7"}),(0,e.jsx)("span",{className:"flex-shrink-0",children:a.completed?"success"===a.lastResult?A("scheduledTasks.success"):A("scheduledTasks.failure"):a.paused?A("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,A)}),!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:[A("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]},a.id)})})]},a)})}),(0,e.jsx)("div",{className:"hidden md:flex flex-1 min-w-0",children:V?(0,e.jsx)(o.x,{task:V,onOpenSession:()=>$(V)},V.id):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-xs text-muted-foreground",children:A("scheduledTasks.selectTaskHint")})})]})})]})]}),K&&null!==M&&(0,e.jsx)(l.x,{filePath:K,content:M,cwd:K.slice(0,Math.max(0,K.lastIndexOf("/"))),onClose:X,zClassName:"z-[80]"}),D&&(0,e.jsx)("div",{ref:G,className:"fixed z-[100]",style:{top:H?.top??0,left:H?.left??0,visibility:H?"visible":"hidden"},children:(0,e.jsx)(k.E,{onClose:J,onCreate:()=>{},editTask:{id:D.id,message:D.message,taskFile:D.taskFile,type:D.type,delayMinutes:D.delayMinutes,intervalMinutes:D.intervalMinutes,activeFrom:D.activeFrom,activeTo:D.activeTo,cron:D.cron},onUpdate:(a,b)=>{z(a,b),J()}})})]})}d()}catch(a){d(a)}})},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)(!1),k=(0,e.useCallback)((a,c)=>{b.current.set(c,a)},[]),l=(0,e.useCallback)(a=>{b.current.delete(a)},[]),m=(0,e.useCallback)(a=>{c.current=a},[]),n=(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}`)},[]),o=(0,e.useMemo)(()=>({sendMessage:n,isLoading:i,registerChat:k,unregisterChat:l,setActiveTab:m,setIsLoading:j}),[n,i,k,l,m]),p=(0,e.useMemo)(()=>({sendMessage:n,isLoading:i}),[n,i]);return(0,d.jsx)(g.Provider,{value:o,children:(0,d.jsx)(f.H,{value:p,children:a})})}function i(){return(0,e.useContext)(g)}},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})})]})}},76855:(a,b,c)=>{"use strict";c.d(b,{Sn:()=>i,Xm:()=>j,po:()=>k,JL:()=>l});var d=c(67484);c(28797);var e=c(79606),f=c(33281),g=c(71192);let h=(a,b)=>e.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:b=>new g.uV({message:`${a} failed`,cause:b})});function i(a){let[b,c]=(0,d.useState)(!1);return{goToDefinition:(0,d.useCallback)(async(b,d,e)=>{c(!0);let g=await f.t4.runPromiseExit(h("/api/lsp/definition",{cwd:a,filePath:b,line:d,column:e}));return(c(!1),"Success"===g._tag)?g.value.definitions??[]:(console.error("[useLSP] definition error:",g.cause),[])},[a]),loading:b}}function j(a){let[b,c]=(0,d.useState)(null),e=(0,d.useRef)(null),g=(0,d.useRef)(null),i=(0,d.useRef)(0),j=(0,d.useRef)(!1),k=(0,d.useRef)(null),l=(0,d.useRef)({x:0,y:0}),m=(0,d.useCallback)(a=>{k.current=a},[]),n=(0,d.useRef)(!1),o=(0,d.useRef)(null),p=(0,d.useCallback)(()=>{let a=k.current;a&&n.current&&(a.style.pointerEvents="none"),n.current=!1,o.current&&(k.current?.removeEventListener("mouseleave",o.current),o.current=null)},[]),q=(0,d.useCallback)(()=>{let a=k.current;if(!a||n.current)return;n.current=!0,j.current=!0,a.style.pointerEvents="auto";let b=()=>{j.current=!1,p(),i.current++,c(null)};o.current=b,a.addEventListener("mouseleave",b)},[p]),r=(0,d.useCallback)((b,d,j,k)=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current);let l=++i.current;e.current=setTimeout(async()=>{let e=await f.t4.runPromiseExit(h("/api/lsp/hover",{cwd:a,filePath:b,line:d,column:j}));if(l!==i.current||"Success"!==e._tag)return;let g=e.value.hover;g&&g.displayString&&c({...g,x:k.x,y:k.y,filePath:b,line:d,column:j})},300)},[a]),s=(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),i.current++,g.current=setTimeout(function(){if(j.current)return;let a=k.current;if(a){let b=a.getBoundingClientRect(),{x:c,y:d}=l.current;if(c>=b.left&&c<=b.right&&d>=b.top&&d<=b.bottom)return void q()}c(null)},150)},[q]),t=(0,d.useCallback)(()=>{j.current=!0,g.current&&clearTimeout(g.current)},[]);return{hoverInfo:b,onTokenMouseEnter:r,onTokenMouseLeave:s,onCardMouseEnter:t,onCardMouseLeave:(0,d.useCallback)(()=>{j.current=!1,i.current++,c(null)},[]),clearHover:(0,d.useCallback)(()=>{e.current&&clearTimeout(e.current),g.current&&clearTimeout(g.current),j.current=!1,p(),i.current++,c(null)},[p]),setTooltipEl:m}}function k(a){let[b,c]=(0,d.useState)([]),[e,g]=(0,d.useState)(!1),[i,j]=(0,d.useState)(!1);return{references:b,loading:e,visible:i,findReferences:(0,d.useCallback)(async(b,d,e)=>{g(!0),j(!0);let i=await f.t4.runPromiseExit(h("/api/lsp/references",{cwd:a,filePath:b,line:d,column:e}));"Success"===i._tag?c(i.value.references??[]):(console.error("[useLSP] references error:",i.cause),c([])),g(!1)},[a]),closeReferences:(0,d.useCallback)(()=>{j(!1),c([])},[])}}function l(a,b){(0,d.useRef)(null)}},77120:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{SessionBrowser:()=>o});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(74228),n=c(32753);function o({isOpen:a,onClose:b,onSelectSession:c,onAddProject:d,sessionNumbers:p={},projectNumbers:q={}}){let{t:r}=(0,g.Bd)(),[s,t]=(0,f.useState)(!1),[u,v]=(0,f.useState)([]),[w,x]=(0,f.useState)({}),[y,z]=(0,f.useState)(!1),[A,B]=(0,f.useState)(null),[C,D]=(0,f.useState)(""),E=(0,f.useRef)(null);(0,f.useCallback)(async()=>{z(!0),B(null),x({});let a=await k.t4.runPromiseExit((0,l.H7)());"Success"===a._tag?v(a.value):B("Failed to load projects"),z(!1)},[]);let F=(0,f.useCallback)(async a=>{x(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?x(c=>({...c,[a]:{...c[a],isLoading:!1,sessions:b.value}})):x(b=>({...b,[a]:{...b[a],isLoading:!1,error:"Failed to load sessions"}}))},[]),G=(0,f.useCallback)(a=>{let b=w[a];b?.isExpanded?x(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?x(b=>({...b,[a]:{...b[a],isExpanded:!0}})):F(a)},[w,F]),H=(0,f.useCallback)(async()=>{if(s)return;t(!0);let a=await k.t4.runPromiseExit((0,l.It)());"Success"===a._tag&&a.value.folder&&d&&(d(a.value.folder),b()),t(!1)},[s,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:h.aO,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("sessions.projectList")}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("input",{ref:E,type:"text",placeholder:r("workspace.searchProjectPath"),value:C,onChange:a=>D(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"}),C&&(0,e.jsx)("button",{onClick:()=>{D(""),E.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,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&&(0,e.jsxs)("button",{onClick:H,disabled:s,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 disabled:opacity-50",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?r("sessions.selectingFolder"):r("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"})})})]})]}),(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[y&&(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:r("workspace.loadingProjects")})]})}),A&&(0,e.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,e.jsx)("div",{className:"text-xs text-red-11",children:A})}),!y&&!A&&0===u.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:r("workspace.projectNotFound")})}),!y&&!A&&u.filter(a=>a.fullPath.toLowerCase().includes(C.toLowerCase())).map(a=>{let b=w[a.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null},d=q[a.fullPath];return(0,e.jsxs)("div",{className:"mb-3",children:[(0,e.jsxs)("button",{onClick:()=>G(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)(m.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:r("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=p[`${a.fullPath}
|
|
731
|
-
${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)(n.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)(m.l,{projectNumber:k,sessionNumber:l,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:()=>j,Hy:()=>g,L5:()=>h,hp:()=>i});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/skills"),h=a=>f("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),j=a=>f(`/api/skills/content?id=${encodeURIComponent(a)}`)},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.orElse(()=>l.void)));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:()=>E});var e=c(48249),f=c(67484),g=c(44384),h=c(43209),i=c(70151),j=c(6900),k=c(85905),l=c(32465),m=c(75513),n=c(57632),o=c(79327),p=c(94192),q=c(44256),r=c(37129),s=c(38878),t=c(3588),u=c(18946),v=c(29939),w=c(98982),x=c(13054),y=c(79606),z=c(23734),A=c(88214),B=c(33281),C=c(65484);c(37388);var D=a([s,t,u,i,n]);function E({initialCwd:a,initialSessionId:b,initialView:c}){let{t:d}=(0,g.Bd)(),[D,F]=(0,f.useState)(c??"agent"),{tabs:G,activeTabId:H,activeTab:I,unreadTabs:J,dragTabIndex:K,dragOverTabIndex:L,closeTab:M,closeAllTabs:N,switchTab:O,handleSelectSession:P,handleNewTab:Q,handleNewCodexTab:R,handleNewKimiTab:S,handleNewGlmTab:T,handleNewOllamaTab:U,handleNewDeepseekTab:V,handleOpenSession:W,updateTabState:X,updateTabEngine:Y,updateTabOllamaModel:Z,updateTabDeepseekModel:$,updateTabKimiModel:_,updateTabGlmModel:aa,updateTabClaudeModel:ab,updateTabClaudeEffort:ac,updateTabClaudeContextWindow:ad,updateTabClaudeFastMode:ae,updateTabClaudeThinking:af,updateTabCodexModel:ag,updateTabCodexReasoningEffort:ah,updateTabPlanMode:ai,updateTabNoHistory:aj,handleTabDragStart:ak,handleTabDragOver:al,handleTabDrop:am,handleTabDragEnd:an}=(0,r.useTabState)({initialCwd:a,initialSessionId:b,activeView:D}),{isPinned:ao,pinSession:ap,unpinSession:aq}=(0,w.P)(),{createTask:ar}=(0,x.nS)(),as=(0,f.useCallback)(a=>{let b=G.find(b=>b.id===a);return!!b?.sessionId&&ao(b.sessionId)},[G,ao]),at=(0,f.useCallback)(b=>{let c=G.find(a=>a.id===b);c?.sessionId&&(ao(c.sessionId)?aq(c.sessionId):ap(c.sessionId,c.cwd||a||"",c.title))},[G,ao,ap,aq,a]),[au,av]=(0,f.useState)(!1),[aw,ax]=(0,f.useState)(!1),[ay,az]=(0,f.useState)(!1),[aA,aB]=(0,f.useState)(null),[aC,aD]=(0,f.useState)(!1),[aE,aF]=(0,f.useState)("tree"),[aG,aH]=(0,f.useState)(0),[aI,aJ]=(0,f.useState)(null),[aK,aL]=(0,f.useState)(0),[aM,aN]=(0,f.useState)(null),[aO,aP]=(0,f.useState)(null),[aQ,aR]=(0,f.useState)(null),[aS,aT]=(0,f.useState)(),[aU,aV]=(0,f.useState)(!1);(0,f.useRef)(null);let aW=(0,f.useCallback)(b=>{F(b),a&&(B.t4.runFork((0,C.Yn)({cwd:a,settings:{activeView:b}}).pipe(y.orElse(()=>y.void))),B.t4.runFork(y.flatMap(z.d,c=>c.publish(A.n.ViewChange,{cwd:a,view:b}))))},[a]),aX=(0,f.useCallback)(async()=>{if(!a)return;let b=await B.t4.runPromiseExit((0,C.b2)(a));if("Success"===b._tag){let c=b.value;if(aD(!!c.isGitRepo),c.isGitRepo&&c.worktrees&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&aB(b.branch)}}else console.error("Failed to load git info:",b.cause)},[a]),aY=(0,f.useCallback)(a=>{let{data:b}=a;Array.isArray(b)&&b.some(a=>"git"===a.type)&&aX()},[aX]);(0,v.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:aY,enabled:!!a});let aZ=(0,f.useCallback)(()=>{aF("status"),aH(a=>a+1),aW("explorer")},[aW]),a$=(0,f.useCallback)(a=>{aJ(a),aL(a=>a+1),aW("explorer")},[aW]),a_=(0,f.useCallback)(a=>{aP(null),a$(a)},[a$]),a0=(0,f.useCallback)(()=>aW("agent"),[aW]),a1=(0,f.useCallback)((a,b,c,d,e,f)=>{aP(g=>(0,o.y)(g,{messageId:a,toolCalls:b,cwd:c,sessionId:d,runId:e},!0===f)),f||aW("explorer")},[aW]),a2=(0,f.useCallback)(a=>{aP(null),aN({...a,nonce:Date.now()}),aW("explorer")},[aW]),a3=(0,f.useCallback)(()=>{a&&B.t4.runFork(y.flatMap(z.d,b=>b.publish(A.n.OpenNote,{cwd:a})))},[a]);return(0,e.jsx)(m.k_,{children:(0,e.jsx)(p.fY,{activeView:D,onViewChange:aW,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)(s.TabManagerTopBar,{initialCwd:a,activeTab:I,isGitRepo:aC,currentBranch:aA,onOpenWorktree:()=>ax(!0),onOpenAliasManager:()=>az(!0),onBranchSwitched:aX}),aU&&(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:"●"}),d("console.screenshotting")]}),a?(0,e.jsxs)(p.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(q.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(t.TabBar,{tabs:G,activeTabId:H,unreadTabs:J,dragTabIndex:K,dragOverTabIndex:L,isPinned:as,onTogglePin:at,onSwitchTab:O,onCloseTab:M,onCloseAllTabs:N,onNewTab:Q,onNewCodexTab:R,onNewKimiTab:S,onNewGlmTab:T,onNewOllamaTab:U,onNewDeepseekTab:V,onOpenProjectSessions:()=>av(!0),onDragStart:ak,onDragOver:al,onDrop:am,onDragEnd:an}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:G.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===H?"block":"hidden"}`,children:(0,e.jsx)(u.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:Y,ollamaModel:a.ollamaModel,onOllamaModelChange:Z,deepseekModel:a.deepseekModel,onDeepseekModelChange:$,kimiModel:a.kimiModel,onKimiModelChange:_,glmModel:a.glmModel,onGlmModelChange:aa,claudeModel:a.claudeModel,onClaudeModelChange:ab,claudeEffort:a.claudeEffort,onClaudeEffortChange:ac,claudeContextWindow:a.claudeContextWindow,onClaudeContextWindowChange:ad,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:ae,claudeThinking:a.claudeThinking,onClaudeThinkingChange:af,codexModel:a.codexModel,onCodexModelChange:ag,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:ah,planMode:a.planMode,onPlanModeChange:ai,noHistory:a.noHistory,onNoHistoryChange:aj,isActive:a.id===H&&"agent"===D,refreshSignal:aQ,onStateChange:X,onShowGitStatus:aZ,onContentSearch:a$,onShowFileDiff:a1,onOpenFileLink:a2,onOpenNote:a3,onCreateScheduledTask:ar,onOpenSession:W})},a.id))})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden relative",children:(0,e.jsxs)(q.a9,{children:[(0,e.jsx)(i.g,{onClose:a0,cwd:a,initialTab:aE,tabSwitchTrigger:aG,initialSearchQuery:aI,searchQueryTrigger:aK,fileOpenRequest:aM}),aO&&(0,e.jsx)("div",{className:"absolute inset-0 z-20 flex bg-scrim p-[4vmin]",onClick:()=>aP(null),children:(0,e.jsx)(n.e$,{toolCalls:aO.toolCalls,cwd:aO.cwd,sessionId:aO.sessionId,runId:aO.runId,onClose:()=>aP(null),onContentSearch:a_},aO.messageId)})]})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(q.a9,{children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:a3})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(t.TabBar,{tabs:G,activeTabId:H,unreadTabs:J,dragTabIndex:K,dragOverTabIndex:L,isPinned:as,onTogglePin:at,onSwitchTab:O,onCloseTab:M,onCloseAllTabs:N,onNewTab:Q,onNewCodexTab:R,onNewKimiTab:S,onNewGlmTab:T,onNewDeepseekTab:V,onDragStart:ak,onDragOver:al,onDrop:am,onDragEnd:an}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:G.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===H?"block":"hidden"}`,children:(0,e.jsx)(u.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:Y,ollamaModel:a.ollamaModel,onOllamaModelChange:Z,deepseekModel:a.deepseekModel,onDeepseekModelChange:$,kimiModel:a.kimiModel,onKimiModelChange:_,glmModel:a.glmModel,onGlmModelChange:aa,claudeModel:a.claudeModel,onClaudeModelChange:ab,claudeEffort:a.claudeEffort,onClaudeEffortChange:ac,claudeContextWindow:a.claudeContextWindow,onClaudeContextWindowChange:ad,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:ae,claudeThinking:a.claudeThinking,onClaudeThinkingChange:af,codexModel:a.codexModel,onCodexModelChange:ag,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:ah,planMode:a.planMode,onPlanModeChange:ai,noHistory:a.noHistory,onNoHistoryChange:aj,isActive:a.id===H,refreshSignal:aQ,onStateChange:X,onCreateScheduledTask:ar,onOpenSession:W})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:au,onClose:()=>av(!1),cwd:a,onSelectSession:P,projectNumber:aS,openSessionIds:G.map(a=>a.sessionId)}),a&&aC&&(0,e.jsx)(j.x,{isOpen:aw,onClose:()=>ax(!1),cwd:a}),ay&&(0,e.jsx)(l.Y,{onClose:()=>az(!1),onSave:()=>az(!1)})]})})})}[s,t,u,i,n]=D.then?(await D)():D,d()}catch(a){d(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)}})]})},80983:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>n});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(23700),j=c(92701),k=c(61349),l=a([k,i,j]);[k,i,j]=l.then?(await l)():l;let o={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 m(a){return"object"==typeof a&&null!==a}function n({toolCall:a,cwd:b,sessionId:c,disableOverlays:d=!1}){var l;let{t:p}=(0,g.Bd)(),[q,r]=(0,f.useState)(!1),[s,t]=(0,f.useState)(null),[u,v]=(0,f.useState)(!1),[w,x]=(0,f.useState)(!1),y=o[a.name]||"\uD83D\uDD27",z="Agent"===a.name||"Task"===a.name,A=z&&!!b&&!!c,B="Workflow"===a.name,C=B&&(l=a.result)?l.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,D=B&&!!C&&!!b&&!!c,E="Skill"===a.name,F="ApplyPatch"===a.name||z||B||E,G=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},H=(()=>{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(m).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} ${G(b)}`});if(a.length>0)return a.join(" \xb7 ")}if(z&&b.description&&"string"==typeof b.description)return b.description;if(B){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(E&&"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})(),I="Glob"===a.name||"Grep"===a.name||"Bash"===a.name||"ApplyPatch"===a.name||z||B||E,J=H?I?H:G(H):null,K=b=>{let c="input"===b?p("toolCall.inputParams"):p("toolCall.resultLabel"),d="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);t({title:`${a.name}${J?` ${J}`:""} - ${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:()=>r(!q),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:y}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),J&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":H||"",children:J}),!F&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),H&&(navigator.clipboard.writeText(H),(0,h.oR)(p("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),H&&(navigator.clipboard.writeText(H),(0,h.oR)(p("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:p("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:[A&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),v(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),v(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("chat.subagentViewTitle"),children:p("chat.subagent")}),D&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),x(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),x(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("chat.workflowViewTitle"),children:p("chat.workflowRun")}),q&&!a.isLoading&&!d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),K("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),K("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("toolCall.inputParamsTitle"),children:p("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),K("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),K("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("toolCall.resultTitle"),children:p("toolCall.result")})]}),a.isLoading?(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}):(0,e.jsx)("span",{className:"text-foreground-subtle text-xs",children:q?"▲":"▼"})]})]}),q&&(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:[p("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:[p("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:[p("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})]})]}),s&&(0,e.jsx)(k.M,{title:s.title,content:s.content,toolName:s.toolName,onClose:()=>t(null)}),u&&b&&c&&(0,e.jsx)(i.f,{cwd:b,sessionId:c,toolCall:a,onClose:()=>v(!1)}),w&&b&&c&&C&&(0,e.jsx)(j.K,{cwd:b,sessionId:c,runId:C,isRunning:!!a.isLoading,onClose:()=>x(!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.tryPromise({try:async()=>{let b=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return b.ok?await b.json():null},catch:a=>new g.uV({message:"session-by-path failed",cause:a})}),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=(0,d.useRef)(n);E.current=n;let F=(0,d.useRef)(o);F.current=o;let G=(0,d.useRef)(void 0),H=(0,d.useRef)(0),I=(0,d.useCallback)(async(a,c,d=!1,e,g,j=!1)=>{if(d){let a=Date.now();if(!j&&a-H.current<5e3)return;H.current=a}let k=(a,d)=>{a.fingerprint&&(G.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),a.title&&E.current?.(a.title),a.usage&&F.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}`,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&&G.current?b.ifFingerprint=G.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]),J=(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(d-e),B(c)}void 0!==a.hasMore&&v(a.hasMore),a.fingerprint&&(G.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:J,loadHistory:(0,d.useCallback)(async a=>{r(!0);let c=e.tryPromise({try:async()=>{let b=await fetch(`/api/session/${a}/history`);return b.ok?await b.json():null},catch:a=>new g.uV({message:"load session history failed",cause:a})}),d=await f.t4.runPromiseExit(c);"Success"===d._tag&&d.value?.messages&&d.value.messages.length>0?(b(d.value.messages),B(a)):"Failure"===d._tag&&console.error("Failed to load history:",d.cause),r(!1)},[b]),loadHistoryByCwdAndSessionId:I,loadedSessionId:A,loadedEngine:C}}},81227:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx","default")},82795:(a,b,c)=>{"use strict";c.d(b,{e:()=>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)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===a.status?"bg-orange-11":"unread"===a.status?"bg-red-9":"bg-muted-foreground/30"}`}),(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}
|
|
732
|
+
${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)(n.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)(m.l,{projectNumber:k,sessionNumber:l,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:()=>j,Hy:()=>g,L5:()=>h,hp:()=>i});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=()=>f("/api/skills"),h=a=>f("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),i=a=>f(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),j=a=>f(`/api/skills/content?id=${encodeURIComponent(a)}`)},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.orElse(()=>l.void)));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:()=>E});var e=c(48249),f=c(67484),g=c(44384),h=c(43209),i=c(70151),j=c(6900),k=c(85905),l=c(32465),m=c(75513),n=c(57632),o=c(79327),p=c(94192),q=c(44256),r=c(37129),s=c(38878),t=c(3588),u=c(18946),v=c(29939),w=c(98982),x=c(13054),y=c(79606),z=c(23734),A=c(88214),B=c(33281),C=c(65484);c(37388);var D=a([s,t,u,i,n]);function E({initialCwd:a,initialSessionId:b,initialView:c}){let{t:d}=(0,g.Bd)(),[D,F]=(0,f.useState)(c??"agent"),{tabs:G,activeTabId:H,activeTab:I,unreadTabs:J,dragTabIndex:K,dragOverTabIndex:L,closeTab:M,closeAllTabs:N,switchTab:O,handleSelectSession:P,handleNewTab:Q,handleNewCodexTab:R,handleNewKimiTab:S,handleNewGlmTab:T,handleNewOllamaTab:U,handleNewDeepseekTab:V,handleOpenSession:W,updateTabState:X,updateTabEngine:Y,updateTabOllamaModel:Z,updateTabDeepseekModel:$,updateTabKimiModel:_,updateTabGlmModel:aa,updateTabClaudeModel:ab,updateTabClaudeEffort:ac,updateTabClaudeContextWindow:ad,updateTabClaudeFastMode:ae,updateTabClaudeThinking:af,updateTabCodexModel:ag,updateTabCodexReasoningEffort:ah,updateTabPlanMode:ai,updateTabNoHistory:aj,handleTabDragStart:ak,handleTabDragOver:al,handleTabDrop:am,handleTabDragEnd:an}=(0,r.useTabState)({initialCwd:a,initialSessionId:b,activeView:D}),{isPinned:ao,pinSession:ap,unpinSession:aq}=(0,w.P)(),{createTask:ar}=(0,x.nS)(),as=(0,f.useCallback)(a=>{let b=G.find(b=>b.id===a);return!!b?.sessionId&&ao(b.sessionId)},[G,ao]),at=(0,f.useCallback)(b=>{let c=G.find(a=>a.id===b);c?.sessionId&&(ao(c.sessionId)?aq(c.sessionId):ap(c.sessionId,c.cwd||a||"",c.title))},[G,ao,ap,aq,a]),[au,av]=(0,f.useState)(!1),[aw,ax]=(0,f.useState)(!1),[ay,az]=(0,f.useState)(!1),[aA,aB]=(0,f.useState)(null),[aC,aD]=(0,f.useState)(!1),[aE,aF]=(0,f.useState)("tree"),[aG,aH]=(0,f.useState)(0),[aI,aJ]=(0,f.useState)(null),[aK,aL]=(0,f.useState)(0),[aM,aN]=(0,f.useState)(null),[aO,aP]=(0,f.useState)(null),[aQ,aR]=(0,f.useState)(null),[aS,aT]=(0,f.useState)(),[aU,aV]=(0,f.useState)(!1);(0,f.useRef)(null);let aW=(0,f.useCallback)(b=>{F(b),a&&(B.t4.runFork((0,C.Yn)({cwd:a,settings:{activeView:b}}).pipe(y.orElse(()=>y.void))),B.t4.runFork(y.flatMap(z.d,c=>c.publish(A.n.ViewChange,{cwd:a,view:b}))))},[a]),aX=(0,f.useCallback)(async()=>{if(!a)return;let b=await B.t4.runPromiseExit((0,C.b2)(a));if("Success"===b._tag){let c=b.value;if(aD(!!c.isGitRepo),c.isGitRepo&&c.worktrees&&c.worktrees.length>0){let b=c.worktrees.find(b=>b.path===a);b&&aB(b.branch)}}else console.error("Failed to load git info:",b.cause)},[a]),aY=(0,f.useCallback)(a=>{let{data:b}=a;Array.isArray(b)&&b.some(a=>"git"===a.type)&&aX()},[aX]);(0,v.h)({url:`/ws/watch?cwd=${encodeURIComponent(a||"")}`,onMessage:aY,enabled:!!a});let aZ=(0,f.useCallback)(()=>{aF("status"),aH(a=>a+1),aW("explorer")},[aW]),a$=(0,f.useCallback)(a=>{aJ(a),aL(a=>a+1),aW("explorer")},[aW]),a_=(0,f.useCallback)(a=>{aP(null),a$(a)},[a$]),a0=(0,f.useCallback)(()=>aW("agent"),[aW]),a1=(0,f.useCallback)((a,b,c,d,e,f)=>{aP(g=>(0,o.y)(g,{messageId:a,toolCalls:b,cwd:c,sessionId:d,runId:e},!0===f)),f||aW("explorer")},[aW]),a2=(0,f.useCallback)(a=>{aP(null),aN({...a,nonce:Date.now()}),aW("explorer")},[aW]),a3=(0,f.useCallback)(()=>{a&&B.t4.runFork(y.flatMap(z.d,b=>b.publish(A.n.OpenNote,{cwd:a})))},[a]);return(0,e.jsx)(m.k_,{children:(0,e.jsx)(p.fY,{activeView:D,onViewChange:aW,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)(s.TabManagerTopBar,{initialCwd:a,activeTab:I,isGitRepo:aC,currentBranch:aA,onOpenWorktree:()=>ax(!0),onOpenAliasManager:()=>az(!0),onBranchSwitched:aX}),aU&&(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:"●"}),d("console.screenshotting")]}),a?(0,e.jsxs)(p.c0,{children:[(0,e.jsx)("div",{className:"w-1/3 h-full flex flex-col overflow-hidden",children:(0,e.jsx)(q.a9,{children:(0,e.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,e.jsx)(t.TabBar,{tabs:G,activeTabId:H,unreadTabs:J,dragTabIndex:K,dragOverTabIndex:L,isPinned:as,onTogglePin:at,onSwitchTab:O,onCloseTab:M,onCloseAllTabs:N,onNewTab:Q,onNewCodexTab:R,onNewKimiTab:S,onNewGlmTab:T,onNewOllamaTab:U,onNewDeepseekTab:V,onOpenProjectSessions:()=>av(!0),onDragStart:ak,onDragOver:al,onDrop:am,onDragEnd:an}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:G.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===H?"block":"hidden"}`,children:(0,e.jsx)(u.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:Y,ollamaModel:a.ollamaModel,onOllamaModelChange:Z,deepseekModel:a.deepseekModel,onDeepseekModelChange:$,kimiModel:a.kimiModel,onKimiModelChange:_,glmModel:a.glmModel,onGlmModelChange:aa,claudeModel:a.claudeModel,onClaudeModelChange:ab,claudeEffort:a.claudeEffort,onClaudeEffortChange:ac,claudeContextWindow:a.claudeContextWindow,onClaudeContextWindowChange:ad,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:ae,claudeThinking:a.claudeThinking,onClaudeThinkingChange:af,codexModel:a.codexModel,onCodexModelChange:ag,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:ah,planMode:a.planMode,onPlanModeChange:ai,noHistory:a.noHistory,onNoHistoryChange:aj,isActive:a.id===H&&"agent"===D,refreshSignal:aQ,onStateChange:X,onShowGitStatus:aZ,onContentSearch:a$,onShowFileDiff:a1,onOpenFileLink:a2,onOpenNote:a3,onCreateScheduledTask:ar,onOpenSession:W})},a.id))})]})})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden relative",children:(0,e.jsxs)(q.a9,{children:[(0,e.jsx)(i.g,{onClose:a0,cwd:a,initialTab:aE,tabSwitchTrigger:aG,initialSearchQuery:aI,searchQueryTrigger:aK,fileOpenRequest:aM}),aO&&(0,e.jsx)("div",{className:"absolute inset-0 z-20 flex bg-scrim p-[4vmin]",onClick:()=>aP(null),children:(0,e.jsx)(n.e$,{toolCalls:aO.toolCalls,cwd:aO.cwd,sessionId:aO.sessionId,runId:aO.runId,onClose:()=>aP(null),onContentSearch:a_},aO.messageId)})]})}),(0,e.jsx)("div",{className:"w-1/3 h-full overflow-hidden",children:(0,e.jsx)(q.a9,{children:(0,e.jsx)(k.J,{cwd:a,tabId:"default",onOpenNote:a3})})})]}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,e.jsx)(t.TabBar,{tabs:G,activeTabId:H,unreadTabs:J,dragTabIndex:K,dragOverTabIndex:L,isPinned:as,onTogglePin:at,onSwitchTab:O,onCloseTab:M,onCloseAllTabs:N,onNewTab:Q,onNewCodexTab:R,onNewKimiTab:S,onNewGlmTab:T,onNewDeepseekTab:V,onDragStart:ak,onDragOver:al,onDrop:am,onDragEnd:an}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden relative",children:G.map(a=>(0,e.jsx)("div",{className:`h-full ${a.id===H?"block":"hidden"}`,children:(0,e.jsx)(u.X,{tabId:a.id,cwd:a.cwd,sessionId:a.sessionId,engine:a.engine,onEngineChange:Y,ollamaModel:a.ollamaModel,onOllamaModelChange:Z,deepseekModel:a.deepseekModel,onDeepseekModelChange:$,kimiModel:a.kimiModel,onKimiModelChange:_,glmModel:a.glmModel,onGlmModelChange:aa,claudeModel:a.claudeModel,onClaudeModelChange:ab,claudeEffort:a.claudeEffort,onClaudeEffortChange:ac,claudeContextWindow:a.claudeContextWindow,onClaudeContextWindowChange:ad,claudeFastMode:a.claudeFastMode,onClaudeFastModeChange:ae,claudeThinking:a.claudeThinking,onClaudeThinkingChange:af,codexModel:a.codexModel,onCodexModelChange:ag,codexReasoningEffort:a.codexReasoningEffort,onCodexReasoningEffortChange:ah,planMode:a.planMode,onPlanModeChange:ai,noHistory:a.noHistory,onNoHistoryChange:aj,isActive:a.id===H,refreshSignal:aQ,onStateChange:X,onCreateScheduledTask:ar,onOpenSession:W})},a.id))})]})]}),a&&(0,e.jsx)(h.Q,{isOpen:au,onClose:()=>av(!1),cwd:a,onSelectSession:P,projectNumber:aS,openSessionIds:G.map(a=>a.sessionId)}),a&&aC&&(0,e.jsx)(j.x,{isOpen:aw,onClose:()=>ax(!1),cwd:a}),ay&&(0,e.jsx)(l.Y,{onClose:()=>az(!1),onSave:()=>az(!1)})]})})})}[s,t,u,i,n]=D.then?(await D)():D,d()}catch(a){d(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)}})]})},80983:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>n});var e=c(48249),f=c(67484),g=c(44384),h=c(7833),i=c(23700),j=c(92701),k=c(61349),l=a([k,i,j]);[k,i,j]=l.then?(await l)():l;let o={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 m(a){return"object"==typeof a&&null!==a}function n({toolCall:a,cwd:b,sessionId:c,disableOverlays:d=!1}){var l;let{t:p}=(0,g.Bd)(),[q,r]=(0,f.useState)(!1),[s,t]=(0,f.useState)(null),[u,v]=(0,f.useState)(!1),[w,x]=(0,f.useState)(!1),y=o[a.name]||"\uD83D\uDD27",z="Agent"===a.name||"Task"===a.name,A=z&&!!b&&!!c,B="Workflow"===a.name,C=B&&(l=a.result)?l.match(/subagents\/workflows\/(wf_[A-Za-z0-9_-]+)/)?.[1]??null:null,D=B&&!!C&&!!b&&!!c,E=a.task?.status==="running",F=!!a.isLoading||E,G=a.task?E||!!a.isLoading:!a.result,H=E?[a.task?.lastToolName,a.task?.toolUses?String(a.task.toolUses):null].filter(Boolean).join(" \xb7 "):"",I="Skill"===a.name,J="ApplyPatch"===a.name||z||B||I,K=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},L=(()=>{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(m).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} ${K(b)}`});if(a.length>0)return a.join(" \xb7 ")}if(z&&b.description&&"string"==typeof b.description)return b.description;if(B){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(I&&"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})(),M="Glob"===a.name||"Grep"===a.name||"Bash"===a.name||"ApplyPatch"===a.name||z||B||I,N=L?M?L:K(L):null,O=b=>{let c="input"===b?p("toolCall.inputParams"):p("toolCall.resultLabel"),d="input"===b?JSON.stringify(a.input,null,2):"string"==typeof a.result?a.result:JSON.stringify(a.result,null,2);t({title:`${a.name}${N?` ${N}`:""} - ${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:()=>r(!q),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:y}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:a.name}),N&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":L||"",children:N}),!J&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),L&&(navigator.clipboard.writeText(L),(0,h.oR)(p("common.copiedPath")))},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),L&&(navigator.clipboard.writeText(L),(0,h.oR)(p("common.copiedPath"))))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors flex-shrink-0 cursor-pointer",title:p("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:[A&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),v(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),v(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("chat.subagentViewTitle"),children:p("chat.subagent")}),D&&!d&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),x(!0)},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),x(!0))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("chat.workflowViewTitle"),children:p("chat.workflowRun")}),H&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate max-w-[16rem]",children:H}),q&&!a.isLoading&&!d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),O("input")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),O("input"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("toolCall.inputParamsTitle"),children:p("toolCall.input")}),a.result&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),O("result")},onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&(a.stopPropagation(),O("result"))},className:"text-xs text-brand hover:text-teal-10 cursor-pointer",title:p("toolCall.resultTitle"),children:p("toolCall.result")})]}),F?(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:q?"▲":"▼"})]})]}),q&&(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:[p("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:[p("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:[p("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})]})]}),s&&(0,e.jsx)(k.M,{title:s.title,content:s.content,toolName:s.toolName,onClose:()=>t(null)}),u&&b&&c&&(0,e.jsx)(i.f,{cwd:b,sessionId:c,toolCall:a,running:G,onClose:()=>v(!1)}),w&&b&&c&&C&&(0,e.jsx)(j.K,{cwd:b,sessionId:c,runId:C,isRunning:F,onClose:()=>x(!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.tryPromise({try:async()=>{let b=await fetch("/api/session-by-path",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return b.ok?await b.json():null},catch:a=>new g.uV({message:"session-by-path failed",cause:a})}),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=(0,d.useRef)(n);E.current=n;let F=(0,d.useRef)(o);F.current=o;let G=(0,d.useRef)(void 0),H=(0,d.useRef)(0),I=(0,d.useCallback)(async(a,c,d=!1,e,g,j=!1)=>{if(d){let a=Date.now();if(!j&&a-H.current<5e3)return;H.current=a}let k=(a,d)=>{a.fingerprint&&(G.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),a.title&&E.current?.(a.title),a.usage&&F.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}`,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&&G.current?b.ifFingerprint=G.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]),J=(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(d-e),B(c)}void 0!==a.hasMore&&v(a.hasMore),a.fingerprint&&(G.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:J,loadHistory:(0,d.useCallback)(async a=>{r(!0);let c=e.tryPromise({try:async()=>{let b=await fetch(`/api/session/${a}/history`);return b.ok?await b.json():null},catch:a=>new g.uV({message:"load session history failed",cause:a})}),d=await f.t4.runPromiseExit(c);"Success"===d._tag&&d.value?.messages&&d.value.messages.length>0?(b(d.value.messages),B(a)):"Failure"===d._tag&&console.error("Failed to load history:",d.cause),r(!1)},[b]),loadHistoryByCwdAndSessionId:I,loadedSessionId:A,loadedEngine:C}}},81227:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx","default")},82795:(a,b,c)=>{"use strict";c.d(b,{e:()=>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)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"loading"===a.status?"bg-orange-11":"unread"===a.status?"bg-red-9":"bg-muted-foreground/30"}`}),(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}
|
|
732
733
|
${a.sessionId}`],status:(0,k.S)(a.status),statusLabel:"loading"===a.status?o("sessions.running"):"unread"===a.status?o("sessions.done"):void 0,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.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>f(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),h=(a,b)=>f(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),i=(a,b)=>f(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),j=a=>f(a,{method:"DELETE"}),k=()=>f("/api/review"),l=a=>{let b;return b=`/api/review/${encodeURIComponent(a)}`,d.tryPromise({try:async()=>{let a=await fetch(b);if(404===a.status)throw Object.assign(Error("not found"),{__404__:!0});if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>a?.__404__?new e.m_({resource:"review",id:b}):new e.uV({message:`GET ${b} failed`,cause:a})})},m=a=>g("/api/review",a),n=(a,b)=>i(`/api/review/${encodeURIComponent(a)}`,b),o=a=>j(`/api/review/${encodeURIComponent(a)}`),p=a=>i("/api/review/order",{order:a}),q=()=>f("/api/review/users"),r=()=>f("/api/review/share-info"),s=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/comments`,b),t=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/comments`,b),u=(a,b)=>j(`/api/review/${encodeURIComponent(a)}/comments?commentId=${encodeURIComponent(b)}`),v=(a,b)=>g(`/api/review/${encodeURIComponent(a)}/replies`,b),w=(a,b)=>h(`/api/review/${encodeURIComponent(a)}/replies`,b),x=(a,b,c)=>j(`/api/review/${encodeURIComponent(a)}/replies?commentId=${encodeURIComponent(b)}&replyId=${encodeURIComponent(c)}`)},83179:(a,b,c)=>{"use strict";c.d(b,{NoteToolbar:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({editor:a,onClose:b,position:c}){let{t:h}=(0,f.Bd)(),[i,j]=(0,e.useState)(()=>a.getAttributes("link").href||""),k=(0,e.useRef)(null),l=()=>{let c=i.trim();if(c){let b=c.match(/^https?:\/\//)?c:`https://${c}`;a.chain().focus().extendMarkRange("link").setLink({href:b}).run()}else a.chain().focus().extendMarkRange("link").unsetLink().run();b()},m=c?{top:c.top,left:c.left}:{};return(0,d.jsxs)("div",{className:`${c?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-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=[]},[])}}},83721:(a,b,c)=>{"use strict";c.d(b,{O:()=>_});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,onCommentClick:g}){let h=new Map;for(let d of a){if(d.endLine<b||d.endLine>c)continue;let a=h.get(d.endLine);a?a.push(d):h.set(d.endLine,[d])}return 0===h.size?null:(0,d.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(h.entries()).map(([a,c])=>{let h=f+(a-b)*e,i=c[0],j=c.length-1;return(0,d.jsx)(A.m,{content:1===c.length?i.content:`${c.length} comments — click to view`,children:(0,d.jsxs)("button",{onClick:a=>g(i,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:`${h+e/2-8}px`},children:[(0,d.jsx)(G.A,{className:"w-2.5 h-2.5"}),j>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:j+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(41051),L=c(42140),M=c(70596);function N(a){let b=a.lastIndexOf("/");return b>=0?a.slice(b+1):a}let O="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 P({symbol:a,fileSource:b,hasChange:c,onHighlighted:g,comments:h,onCommentClick:i,addedLines:j,upstream:k,downstream:l}){let{resolvedTheme:m}=(0,y.DP)(),{t:n}=(0,f.Bd)(),o=(0,v.r)(),p=(k?.length??0)+(l?.length??0)>0;(0,e.useMemo)(()=>(0,z.sQ)(a.filePath),[a.filePath]);let[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(null);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," ",n("common.lines")]}),o&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>o.sendMessage(n("explain.symbolMessage",{name:a.name,path:a.filePath,lines:`${a.startLine}-${a.endLine}`})),disabled:o.isLoading,title:o.isLoading?n("comments.aiResponding"):void 0,className:O,children:n("explain.action")}),p&&(0,d.jsx)("button",{onClick:()=>o.sendMessage(n("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??[],n("deps.none"))})),disabled:o.isLoading,title:o.isLoading?n("comments.aiResponding"):void 0,className:O,children:n("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:`${S}px`},children:[!b&&(0,d.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),t&&(0,d.jsx)("span",{className:"text-red-11",children:t}),r&&(0,d.jsx)("div",{dangerouslySetInnerHTML:{__html:r}})]}),h&&h.length>0&&i&&(0,d.jsx)(H,{comments:h,startLine:a.startLine,endLine:a.endLine,lineHeight:S,bodyTopOffset:T+U,onCommentClick:i})]})}function Q({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=N(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 R="w-44 @min-[900px]:w-52 @min-[1100px]:w-60 @min-[1400px]:w-72 @min-[1800px]:w-80 @min-[2400px]:w-96",S=18,T=29,U=8;function V(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 W(a,b){return"ext"!==a.kind&&"method"!==a.kind&&(b?.has(a.external.qualifiedName)??!1)}function X(a){return{filePath:a.filePath,qname:a.qualifiedName,name:a.name,kind:a.kind}}function Y({symbol:a,fileSource:b,hasChange:c,upstream:e,downstream:f,onPinClick:g,onHighlighted:h,comments:i,onCommentClick:j,accentQnames:k,addedLines:l}){let m=function(a,b){if(0===a.length)return[];let c=a.map((a,c)=>{var d,e;return{i:c,line:(d=a.lines[0]??b.startLine,e=b.startLine,Math.max(e,Math.min(b.endLine,d)))}});c.sort((a,b)=>a.line-b.line||a.i-b.i);let d=Array(a.length).fill(0),e=-1/0;for(let{i:a,line:f}of c){let c=Math.max(T+U+(f-b.startLine)*S,e);d[a]=c,e=c+34}return d}(f,a);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:`${R} 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)(Q,{side:"in",pin:b,accent:W(b,k),onClick:()=>g(b,a)},V("in",b)))}),(0,d.jsx)(P,{symbol:a,fileSource:b,hasChange:c,onHighlighted:h,comments:i,onCommentClick:j,addedLines:l,upstream:e,downstream:f}),(0,d.jsx)("div",{className:`${R} 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:`${m[c]}px`},children:(0,d.jsx)(Q,{side:"out",pin:b,accent:W(b,k),onClick:()=>g(b,a)})},V("out",b)))})]})}function Z({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)($,{label:i("blockViewer.search.files","Files"),hits:l.files,startIdx:0,activeIdx:n,onSelect:b,setActive:o}),(0,d.jsx)($,{label:i("blockViewer.search.symbols","Symbols"),hits:l.symbols,startIdx:l.files.length,activeIdx:n,onSelect:b,setActive:o})]})]})})}function $({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.target.kind?(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.symbolKind,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 _({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,headerExtraLeft:q,headerExtraRight:s}){let{t:u}=(0,f.Bd)(),[y,z]=(0,e.useState)("toc"),[A,D]=(0,e.useState)(null),G=A??b??null,{state:H,refresh:I}=(0,r.V)(a,G),[O,P]=(0,e.useState)(null),Q=(0,e.useMemo)(()=>O?O.content.split("\n").length:null,[O]);(0,e.useRef)(null);let[S,T]=(0,e.useState)([]),[U,V]=(0,e.useState)(!1),[W,$]=(0,e.useState)(null),ac=(0,e.useRef)(0);(0,e.useRef)(0);let[ad,ae]=(0,e.useState)(()=>new Set);"ready"===H.state&&H.data.filePath;let af=(0,e.useCallback)(a=>{ae(b=>{if(b.has(a))return b;let c=new Set(b);return c.add(a),c})},[]),ag=(0,e.useCallback)((a,b)=>{if("ext"===a.kind||"method"===a.kind){let a=b.filePath;if(!a)return;ac.current+=1,$({filePath:a,qname:"__imports__",nonce:ac.current});return}let c=X(b),d=X(a.external);T(a=>C(C(a,c),d)),D(d.filePath),ac.current+=1,$({filePath:d.filePath,qname:d.qname,nonce:ac.current})},[]),ah=(0,e.useCallback)(a=>{D(a.filePath),ac.current+=1,$({filePath:a.filePath,qname:a.qname,nonce:ac.current})},[]),ai=(0,e.useCallback)(a=>{V(!1),D(a.target.filePath),"symbol"===a.target.kind&&(ac.current+=1,$({filePath:a.target.filePath,qname:a.target.qualifiedName,line:a.target.line,nonce:ac.current}))},[]),aj=(0,e.useCallback)((a,b)=>{G&&(ac.current+=1,$({filePath:G,qname:a,line:b,nonce:ac.current}))},[G]),[ak,al]=(0,e.useState)(null),[am,an]=(0,e.useState)(null),ao=(0,e.useMemo)(()=>{if("ready"!==H.state||!am)return null;let a=H.data.functions;if(0===a.length)return null;let b=(am.start+am.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<=am.start&&(!c||b.startLine>c.startLine)&&(c=b);return c?.qualifiedName??null},[H,am]),ap=h&&!!a&&!!G,aq=(0,v.r)(),{comments:ar,addComment:as,updateComment:at,deleteComment:au,refresh:av}=(0,w._)({cwd:a,filePath:G??""}),[aw,ax]=(0,e.useState)(null),{toolbarRef:ay,bumpRef:az,clearToolbar:aA}=(0,F.L)({enabled:ap,container:aw,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||!aw||!aw.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=O?.content;return c?c.split("\n").slice(a-1,b).join("\n"):""}}),[aB,aC]=(0,e.useState)(null),[aD,aE]=(0,e.useState)(null),[aF,aG]=(0,e.useState)(null),aH=(0,e.useCallback)(()=>{let a=ay.current;a&&(aC({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aA())},[aA,ay]),aI=(0,e.useCallback)(()=>{let a=ay.current;a&&(aE({x:a.x,y:a.y,range:a.range,selectedText:a.selectedText,lineSnapshot:a.lineSnapshot}),aA())},[aA,ay]),aJ=(0,e.useCallback)(()=>{let a=ay.current;a&&aq&&G&&(aA(),(0,x.Ff)(aq.sendMessage,{filePath:G,startLine:a.range.start,endLine:a.range.end,codeContent:a.lineSnapshot},u("explain.selectionMessage")))},[aq,G,aA,ay,u]),aK=(0,e.useCallback)(()=>{let a=ay.current;if(!a||!i)return;let b=a.selectedText.trim();aA(),b&&i(b)},[i,aA,ay]),aL=(0,e.useCallback)(async a=>{aB&&(await as(aB.range.start,aB.range.end,a,aB.selectedText),aC(null))},[aB,as]),aM=(0,e.useCallback)(async(b,c)=>{if(aq&&a&&G)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:G,startLine:b.range.start,endLine:b.range.end,codeContent:b.lineSnapshot});let e=(0,x.Gw)(d,c);aq.sendMessage(e),await (0,x.RP)(a),av()}catch(a){console.error("[BlockViewer] send to AI failed:",a)}},[aq,a,G,av]),aN=(0,e.useCallback)(a=>{aD&&aM(aD,a)},[aD,aM]),aO=(0,e.useCallback)(a=>{aB&&aM(aB,a)},[aB,aM]),aP=(0,e.useCallback)((a,b)=>{b.stopPropagation(),aG({comment:a,x:b.clientX,y:b.clientY}),aA(),aC(null),aE(null)},[aA]);if(!G)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ab,{focalFile:null,fileCount:null,onSwitchToCode:g,onSearch:()=>V(!0),onRefresh:I,refreshDisabled:!0,extraLeft:q,extraRight:s}),(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:u("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,d.jsx)("span",{className:"text-xs",children:u("blockViewer.empty.hint","or press ⌘K to search.")})]}),U&&(0,d.jsx)(Z,{cwd:a,onSelect:ai,onClose:()=>V(!1)})]});if("idle"===H.state||"loading"===H.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ab,{focalFile:G,fileCount:null,onSwitchToCode:g,onSearch:()=>V(!0),onRefresh:I,refreshDisabled:!0,extraLeft:q,extraRight:s}),(0,d.jsx)(t,{cwd:a})]});if("notFound"===H.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ab,{focalFile:G,fileCount:null,onSwitchToCode:g,onSearch:()=>V(!0),onRefresh:I,extraLeft:q,extraRight:s}),(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:u("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),U&&(0,d.jsx)(Z,{cwd:a,onSelect:ai,onClose:()=>V(!1)})]});if("error"===H.state)return(0,d.jsxs)("div",{className:"h-full flex flex-col",children:[(0,d.jsx)(ab,{focalFile:G,fileCount:null,onSwitchToCode:g,onSearch:()=>V(!0),onRefresh:I,extraLeft:q,extraRight:s}),(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:H.message}),(0,d.jsx)("button",{onClick:I,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:u("blockViewer.retry","Retry")})]})]});let aQ=H.data,aR=aQ.functions;if(0===aR.length&&O){let a=Math.max(1,Q??1);aR=[{filePath:aQ.filePath,qualifiedName:"__file__",name:N(aQ.filePath),kind:"unknown",startLine:1,endLine:a}]}let aS=l&&l===aQ.filePath,aT=n&&n===aQ.filePath,aU=p&&p===aQ.filePath;aS&&k&&(aR=aR.filter(a=>k.has(a.qualifiedName)));let aV=aT?m:void 0,aW=aU?o:void 0,aX=aa(aQ.upstreamCalls),aY=aa(aQ.downstreamCalls),aZ=new Map(aR.map(a=>[a.qualifiedName,a])),a$=new Map,a_=new Map;for(let a of aQ.intraCalls){let b=aZ.get(a.to),c=aZ.get(a.from);if(b){let c=a$.get(a.from),d={kind:"self",external:b,lines:a.lines};c?c.push(d):a$.set(a.from,[d])}if(c){let b=a_.get(a.to),d={kind:"self",external:c,lines:a.lines};b?b.push(d):a_.set(a.to,[d])}}let a0=new Map;for(let a of aQ.externalCalls??[]){let b=a0.get(a.focalQname),c={kind:"ext",name:a.external.name,packageSpec:a.external.packageSpec,lines:a.lines};b?b.push(c):a0.set(a.focalQname,[c])}let a1=new Map;for(let a of aQ.methodCalls??[]){let b=a1.get(a.focalQname),c={kind:"method",receiverName:a.receiverName,methodName:a.methodName,lines:a.lines};b?b.push(c):a1.set(a.focalQname,[c])}let a2=new Map;for(let a of aR){let b=a.qualifiedName,c={in:aX.get(b)?.length??0,out:aY.get(b)?.length??0,self:(a_.get(b)?.length??0)+(a$.get(b)?.length??0)};(c.in||c.out||c.self)&&a2.set(b,c)}let a3=c.has(aQ.filePath);return(0,d.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,d.jsx)(ab,{focalFile:G,fileCount:aQ.fileCount,functionCount:aQ.functions.length,upstreamCount:aQ.upstreamCalls.length,downstreamCount:aQ.downstreamCalls.length,onSwitchToCode:g,onSearch:()=>V(!0),onRefresh:I,extraLeft:q,extraRight:s}),(0,d.jsxs)("div",{ref:ax,className:"@container flex-1 relative min-h-0 flex",children:[(0,d.jsxs)("div",{className:`${R} 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",u("blockViewer.tabs.toc")],["history",u("blockViewer.tabs.history")]].map(([a,b])=>(0,d.jsx)("button",{onClick:()=>z(a),className:`flex-1 px-2 py-1.5 text-xs font-medium transition-colors ${y===a?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground"}`,children:b},a))}),(0,d.jsx)("div",{className:"toc"===y?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(E,{functions:aR,counts:a2,totalLines:Q,currentQname:ao,onSelect:aj,notIndexed:aQ.notIndexed,onRebuild:I})}),(0,d.jsx)("div",{className:"history"===y?"flex-1 min-h-0 flex flex-col":"hidden",children:(0,d.jsx)(B,{entries:S,onSelect:ah,onClear:()=>T([])})})]}),(0,d.jsx)("div",{ref:al,className:"@container flex-1 min-w-0 overflow-auto",children:(0,d.jsx)("div",{className:"flex flex-col gap-3 p-3",children:aR.map(a=>{let b,c,e,f,g,h;return(0,d.jsx)(Y,{symbol:a,fileSource:O?.content??null,hasChange:a3,upstream:(b=aX.get(a.qualifiedName),c=a_.get(a.qualifiedName),[...(b??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...c??[]]),downstream:(e=aY.get(a.qualifiedName),f=a$.get(a.qualifiedName),g=a1.get(a.qualifiedName),h=a0.get(a.qualifiedName),[...(e??[]).map(a=>({kind:"cross",external:a.external,lines:a.lines})),...f??[],...g??[],...h??[]]),onPinClick:ag,onHighlighted:af,comments:ap?ar:void 0,onCommentClick:ap?aP:void 0,accentQnames:aV,addedLines:aW},`${a.qualifiedName}#${a.startLine}`)})})}),ap&&aw&&(0,d.jsx)(K.fS,{floatingToolbarRef:ay,bumpRef:az,container:aw,onAddComment:aH,onSendToAI:aI,onSearch:i?aK:void 0,onExplain:aq&&G?aJ:void 0,isChatLoading:aq?.isLoading}),ap&&aB&&(0,d.jsx)(L.t,{x:aB.x,y:aB.y,range:aB.range,filePath:G??void 0,lineSnapshot:aB.lineSnapshot,container:aw,onSubmit:aL,onSendToAI:aq&&G?aO:void 0,onClose:()=>aC(null),isChatLoading:aq?.isLoading}),ap&&aD&&G&&(0,d.jsx)(L.G,{x:aD.x,y:aD.y,range:aD.range,filePath:G,lineSnapshot:aD.lineSnapshot,container:aw,onSubmit:aN,onClose:()=>aE(null),isChatLoading:aq?.isLoading}),ap&&aF&&(0,d.jsx)(M.t,{x:aF.x,y:aF.y,comment:aF.comment,container:aw,onClose:()=>aG(null),onUpdateComment:at,onDeleteComment:au}),aW&&aW.size>0&&aR.length>0&&(0,d.jsx)(J,{addedLines:aW,blockRanges:aR.map(a=>({qname:a.qualifiedName,startLine:a.startLine,endLine:a.endLine})),viewportRange:am,onJumpToLine:aj}),U&&(0,d.jsx)(Z,{cwd:a,onSelect:ai,onClose:()=>V(!1)})]})]})}function aa(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 ab({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")})]})]})}},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";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.tryPromise({try:async()=>{let b=await fetch(a);if(!b.ok){let a;try{a=(await b.json()).error}catch{}throw Error(a||`HTTP ${b.status}`)}return await b.json()},catch:b=>new e.uV({message:`fetch ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new e.uV({message:`POST ${a} failed`,cause:b})}),h=a=>f(`/api/git/branches?cwd=${encodeURIComponent(a)}`).pipe(d.flatMap(b=>"Failed to get branches"===b.error?d.fail(new e.m_({resource:"git-repo",id:a})):d.succeed(b))),i=a=>f(`/api/git/current-branch?cwd=${encodeURIComponent(a)}`),j=(a,b,c,d)=>f(`/api/git/commits?cwd=${encodeURIComponent(a)}&branch=${encodeURIComponent(b)}&limit=${c}${"number"==typeof d?`&offset=${d}`:""}`),k=(a,b,c)=>f(`/api/git/commit-diff?cwd=${encodeURIComponent(a)}&hash=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),l=(a,b,c)=>f(`/api/git/branch-diff?cwd=${encodeURIComponent(a)}&base=${encodeURIComponent(b)}${c?`&file=${encodeURIComponent(c)}`:""}`),m=a=>f(`/api/git/status?cwd=${encodeURIComponent(a)}`),n=(a,b)=>g("/api/git/stage",{cwd:a,files:b}),o=(a,b)=>g("/api/git/unstage",{cwd:a,files:b}),p=(a,b,c)=>g("/api/git/discard",{cwd:a,files:b,isUntracked:c}),q=(a,b,c,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.tryPromise({try:async()=>{let b=await fetch("/api/git/worktree",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/git/worktree failed",cause:a})}),u=a=>f(`/api/projectGraph/search?${a.toString()}`)},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}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(!1),[o,p]=(0,e.useState)(""),[s,v]=(0,e.useState)(!1),w=(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&&p(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)&&p(a.titles[h]??"")}});let x=(0,e.useCallback)(async d=>{if(d.stopPropagation(),l)await g(),m(!1),(0,n.oR)(k("toast.disconnected",{id:a}));else{await c(),m(!0);let d=`cockpit ${b} ${a}`;navigator.clipboard.writeText(d),(0,n.oR)(k("toast.copiedCommand",{command:d}))}},[l,a,b,c,g,k]),y=!!(h&&i&&j),z=(0,e.useCallback)(a=>{a.stopPropagation(),y&&v(!0)},[y]),A=(0,e.useCallback)(async a=>{h&&i&&j&&("Success"===(await r.t4.runPromiseExit((0,u.y8)(i,j,h,a)))._tag&&p(a),v(!1))},[h,i,j]);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{onClick:x,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:l?k("shortIdBadge.clickToDisconnect"):k("shortIdBadge.clickToRegister"),children:[(0,d.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${l?"bg-green-500":"bg-muted-foreground/40"}`}),a]}),y&&(o?(0,d.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[10px] leading-none flex-shrink-0 text-muted-foreground",title:k("shortIdBadge.titleSet",{title:o})||o,children:[(0,d.jsx)("span",{className:"px-1 py-0.5 rounded bg-muted/40 max-w-[120px] truncate",children:o}),(0,d.jsx)("button",{ref:w,onClick:z,className:"opacity-50 hover:opacity-100 transition-opacity","aria-label":k("shortIdBadge.editTitle"),title:k("shortIdBadge.editTitle"),children:"✎"})]}):(0,d.jsxs)("button",{ref:w,onClick:z,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:k("shortIdBadge.setTitle"),children:["(",k("shortIdBadge.setTitlePlaceholder"),") ✎"]})),(0,d.jsx)(t,{open:s,anchorRef:w,initialValue:o,onCancel:()=>v(!1),onSave:A})]})});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.orElse(()=>x.void)))},onUnregister:()=>{r.t4.runFork((0,u.jO)({commandId:a}).pipe(x.orElse(()=>x.void)))},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.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:b=>new I.uV({message:`POST ${a} failed`,cause:b})}),K=(a,b)=>r.t4.runPromise(J(`/api/${a}/disconnect`,{id:b}).pipe(x.orElse(()=>x.void))),L=a=>r.t4.runPromise(J("/api/browser/unregister",{id:a}).pipe(x.orElse(()=>x.void))),M=a=>r.t4.runPromise(a.pipe(x.catchAll(a=>x.sync(()=>{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.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok)throw Error(N(d,c.status));return d},catch:b=>new I.uV({message:`POST ${a} failed`,cause:b})})),P=(a,b)=>M(x.tryPromise({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.tryPromise({try:async()=>{let c=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok)throw Error(`HTTP ${c.status}`);return c.blob()},catch:b=>new 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}){let{t:z,i18n:A}=(0,f.Bd)(),[B,C]=(0,e.useState)(!1),[E,F]=(0,e.useState)(null),[G,H]=(0,e.useState)(a),[I,J]=(0,e.useState)(null),[K,M]=(0,e.useState)(r??!1),N=(0,e.useRef)(null),O=(0,e.useRef)(null),P=(0,e.useRef)(null);(0,e.useRef)(!0),(0,e.useCallback)(()=>{K||(M(!0),J(null),s?.(b))},[K,b,s]),(0,e.useCallback)(()=>{N.current&&(clearTimeout(N.current),N.current=null)},[]);let{shortId:Q,connected:R,connect:V,disconnect:W}=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,P,!!I&&!K&&!B);(0,e.useRef)(R).current=R;let X=(0,e.useCallback)(()=>{if(M(!1),t?.(b),!S(a))return void J((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(()=>J(c)):J(c)},[a,b,t,x]),Y=(0,e.useCallback)(()=>{C(!1);let a=P.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:A.language},"*")},[A]),Z=(0,e.useCallback)(()=>{C(!1),F(z("browser.pageLoadFailed"))},[]),$=(0,e.useCallback)(()=>{if(K)return void X();let a=O.current?.querySelector("iframe");if(a&&I){C(!0),F(null);let b=a.src;a.src="",setTimeout(()=>{a.src=b},0)}},[K,X,I]),_=(0,e.useCallback)(()=>{if(!G)return;let a=S(G)?G:(0,D.Kx)(G)?(0,D.hE)(G,x):(0,D.Xe)(G,x);window.open((0,D.PB)(a,window.location.origin),"_blank")},[G,x]),aa=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}}(G);return(0,d.jsx)("div",{className:"flex flex-col items-start",children:(0,d.jsxs)("div",{className:`w-full bg-accent text-foreground
|
|
733
734
|
relative transition-colors cursor-pointer
|
|
734
735
|
${g?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
|
|
@@ -748,13 +749,14 @@ Error: ${a}`,exitCode:1,isRunning:!1,pid:void 0}:c))}})}catch(b){let a=ab(k);X(k
|
|
|
748
749
|
Error: ${b.message}`,exitCode:1,isRunning:!1,pid:void 0}:c))}},[C,l,z,c,a,W,ab,X,ac,d,ae]),aj=(0,e.useCallback)(a=>{let b=f.find(b=>b.id===a);b?.isRunning&&b.pid&&aR(b.pid)},[f]),ak=(0,e.useCallback)(async b=>{let d=f.find(a=>a.id===b);if(!d)return;d.isRunning&&d.pid&&(aR(d.pid),await new Promise(a=>setTimeout(a,200)));let e=d.command.trim().split(/\s+/),h=e[0],i=d.usePty&&d.command===ba,j=i?a9:d.command;!i&&C[h]&&(j=C[h]+(e.length>1?" "+e.slice(1).join(" "):""));let k=d.usePty||!1;if(k){let a=Z.current.get(b);if(a)for(let b of a)b()}X(b,k);let m=j!==d.command?`→ ${j}
|
|
749
750
|
`:"";k||K.current.set(b,m),k&&L.current.add(b),g(a=>a.map(a=>a.id===b?{...a,output:k?"":m,exitCode:void 0,isRunning:!0,pid:void 0}:a));let n=N.current.get(b);try{await aN({cwd:d.cwd||l,command:j,commandId:b,tabId:c||"",projectCwd:a,env:z,usePty:k,sourceId:T.current,...k&&n?{cols:n.cols,rows:n.rows}:{},onData:(a,c)=>{if("pid"===a)g(a=>a.map(a=>a.id===b?{...a,pid:c.pid,..."string"==typeof c.command?{command:c.command}:{}}:a));else if("stdout"===a||"stderr"===a)W(b,c.data);else if("exit"===a){let a=ab(b);X(b),g(d=>d.map(d=>d.id===b?{...d,output:a,exitCode:c.code,isRunning:!1,pid:void 0}:d))}},onError:a=>{let c=ab(b);X(b),g(d=>d.map(d=>d.id===b?{...d,output:c+`
|
|
750
751
|
Error: ${a}`,exitCode:1,isRunning:!1,pid:void 0}:d))}})}catch(c){let a=ab(b);X(b),g(d=>d.map(d=>d.id===b?{...d,output:a+`
|
|
751
|
-
Error: ${c.message}`,exitCode:1,isRunning:!1,pid:void 0}:d))}},[f,C,l,z,c,a,W,ab,X]),al=(0,e.useCallback)(async b=>{g(a=>a.filter(a=>a.id!==b)),X(b),c&&await r.t4.runPromise((0,u.SN)(a,c,b,T.current).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to delete command:",a))),x.orElse(()=>x.void)))},[a,c,X]),am=(0,e.useCallback)((b,d,e)=>{var f;let g=G(b);if(!g)return;let h=g.parse(d);"cwd"in h&&!h.cwd&&(h.cwd=l);let j={id:(f=g.idPrefix,`${f}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),_type:b,timestamp:new Date().toISOString(),...h};if(i(a=>[...a,j]),y(j.id),setTimeout(ac,100),e){let b=E&&E.length>0?[...E]:S.current.map(a=>a.data.id),d=b.indexOf(e);-1!==d?b.splice(d+1,0,j.id):b.push(j.id),F(b),c&&r.t4.runFork((0,u.cm)(a,c,b,T.current).pipe(x.orElse(()=>x.void)))}if(c){let d=g.toHistory(j);r.t4.runFork((0,u.AJ)(a,c,{type:b,id:j.id,timestamp:j.timestamp,...d},T.current).pipe(x.tapError(a=>x.sync(()=>console.error(`Failed to save ${b} item:`,a))),x.orElse(()=>x.void)))}},[ac,a,c,E]),an=(0,e.useCallback)(async b=>{let d=h.find(a=>a.id===b);if(i(a=>a.filter(a=>a.id!==b)),y(a=>a===b?null:a),k(a=>{let c=new Set(a);return c.delete(b),c}),d){let a=G(d._type);a?.onClose?.(d)}c&&r.t4.runFork((0,u.SN)(a,c,b,T.current).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to delete plugin item:",a))),x.orElse(()=>x.void)))},[h,a,c]);R.current=am,Q.current=ai;let ao=(0,e.useCallback)((b,d)=>{c&&r.t4.runFork((0,u.bv)(a,c,b,{sleeping:d},T.current).pipe(x.orElse(()=>x.void)))},[a,c]),ap=(0,e.useCallback)(a=>{k(b=>new Set(b).add(a)),ao(a,!0)},[ao]),aq=(0,e.useCallback)(a=>{k(b=>{let c=new Set(b);return c.delete(a),c}),ao(a,!1)},[ao]),ar=(0,e.useCallback)(async b=>{F(b),c&&await r.t4.runPromise((0,u.cm)(a,c,b,T.current).pipe(x.orElse(()=>x.void)))},[a,c]),as=(0,e.useMemo)(()=>{let a=[...f.map(a=>({type:"command",data:a})),...h.map(a=>({type:a._type,data:a}))];if(!E||0===E.length)return a.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime());let b=new Map(E.map((a,b)=>[a,b])),c=[],d=[];for(let e of a)b.has(e.data.id)?c.push(e):d.push(e);return c.sort((a,c)=>b.get(a.data.id)-b.get(c.data.id)),d.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime()),[...c,...d]},[f,h,E]);return S.current=as,{commands:f,pluginItems:h,sleepingBubbles:j,consoleItems:as,currentCwd:l,selectedCommandId:w,setSelectedCommandId:y,customEnv:z,setCustomEnv:A,aliases:C,setAliases:D,isLoadingHistory:n,hasMoreHistory:p,currentPage:t,scrollRef:U,commandHistoryRef:M,ptySizeRef:N,executeCommandRef:Q,executeCommand:ai,interruptCommand:aj,rerunCommand:ak,deleteCommand:al,addPluginItem:am,closePluginItem:an,handleBubbleSleep:ap,handleBubbleWake:aq,loadHistory:ad,scrollToBottom:ac,saveBubbleOrder:ar,sendStdin:aP,resizePty:aQ,subscribePtyOutput:Y,subscribePtyReset:$,subscribePtyRefresh:aa}}({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:g}),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)(0),[W,X]=(0,e.useState)(0),[Y,Z]=(0,e.useState)(!0),[$,_]=(0,e.useState)(!1),[aa,ab]=(0,e.useState)(!1),[ac,ad]=(0,e.useState)(!1),[ae,af]=(0,e.useState)(!1),ag=(0,e.useRef)(null),ah=(0,e.useRef)(null),ai=(0,e.useRef)(null),aj=(0,e.useRef)(!1),ak=(0,e.useRef)(null),al=(0,e.useRef)(null),am=(0,e.useRef)([]),an=(0,e.useCallback)(()=>{let a=k.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[k]),ao=(0,e.useCallback)(()=>{let a=k.current;return!a||a.scrollTop<50},[k]),ap=(0,e.useCallback)(()=>{ad(!ao()),af(!an())},[an,ao]),aq=(0,e.useCallback)(()=>{ah.current?.scrollIntoView({behavior:"smooth"})},[]),ar=(0,e.useCallback)(()=>{aj.current=!0},[]),as=(0,e.useCallback)((a,b)=>{if(!aj.current)return void a.preventDefault();aj.current=!1,ak.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b),a.currentTarget.style.opacity="0.4";let c=a.currentTarget.querySelector("[data-drag-handle]");if(c){let b=c.cloneNode(!0);b.style.cssText="position:fixed;top:-9999px;left:-9999px;width:"+c.offsetWidth+"px;background:hsl(var(--card));color:hsl(var(--foreground));box-shadow:var(--elevation-2);border-radius:8px;padding:4px 12px;opacity:0.9;",document.body.appendChild(b),a.dataTransfer.setDragImage(b,20,16),requestAnimationFrame(()=>document.body.removeChild(b))}},[]),at=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",al.current=b},[]),au=(0,e.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.add("ring-2","ring-brand")},[]),av=(0,e.useCallback)(a=>{a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aw=(0,e.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.remove("ring-2","ring-brand")},[]),ax=(0,e.useCallback)(a=>{a.currentTarget.style.opacity="1";let b=ak.current,c=al.current;if(ak.current=null,al.current=null,!b||!c||b===c)return;let d=am.current.map(a=>a.data.id),e=d.indexOf(b),f=d.indexOf(c);if(-1===e||-1===f)return;let g=[...d];g[e]=c,g[f]=b,K(g)},[K]),ay=(0,e.useCallback)(a=>{T(b=>b===a?null:a)},[]),az=(0,e.useCallback)((a,b)=>y("browser",a,b),[y]),aA=W>0?Math.floor((W-32-12)/2-41):void 0;return(0,d.jsxs)("div",{ref:ag,className:"h-full flex flex-col bg-background relative",children:[(0,d.jsx)("div",{ref:k,onScroll:ap,className:`console-scroll-root flex-1 overflow-y-auto ${S?"":"py-4 px-4"}`,children:0===j.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-4 text-sm",children:[(0,d.jsx)("p",{className:"text-muted-foreground",children:i("console.emptyIntro")}),(0,d.jsx)("ul",{className:"flex flex-col gap-2",children:bc.map(a=>(0,d.jsxs)("li",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:"w-16 flex-shrink-0 text-foreground font-medium",children:i(a.label)}),(0,d.jsxs)("span",{className:"flex-1 flex flex-col gap-1",children:[(0,d.jsx)("span",{className:"flex flex-wrap gap-1",children:a.triggers.map(a=>(0,d.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-xs font-mono text-muted-foreground",children:a},a))}),a.notes?.map(a=>(0,d.jsx)("span",{className:"text-xs leading-snug text-muted-foreground/70",children:i(a)},a))]})]},a.key))}),(0,d.jsxs)("button",{type:"button",onClick:()=>w(a9),title:i("console.launchShell"),className:"self-start flex items-center gap-2 px-4 py-2 rounded-lg border border-input bg-background text-sm text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 transition-all",children:[(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,d.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),"New PTY"]})]})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{ref:ah}),L&&(0,d.jsx)("div",{className:"flex justify-center mb-4",children:(0,d.jsx)("button",{onClick:()=>M(N+1),disabled:O,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors disabled:opacity-50",children:O?i("console.loadingMore"):i("console.loadMoreHistory")})}),(0,d.jsx)("div",{className:S?"flex flex-col gap-3":Y?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:j.map(b=>(0,d.jsx)(aT,{item:b,selected:l===b.data.id,maximized:S===b.data.id,initialSleeping:A.has(b.data.id),tabId:c,projectCwd:a,expandedHeight:U,bubbleContentHeight:aA,onDragStart:as,onDragOver:at,onDragEnter:au,onDragLeave:av,onDrop:aw,onDragEnd:ax,onSelectId:m,onInterruptId:n,onStdin:o,onDeleteCommand:p,onRerun:s,subscribePtyOutput:P,subscribePtyReset:Q,subscribePtyRefresh:R,ptySizeRef:t,resizePty:v,onToggleMaximizeId:ay,onTitleMouseDown:ar,onClosePlugin:z,addBrowserItem:az,onSleep:B,onWake:C},b.data.id))}),(0,d.jsx)("div",{ref:ai})]})}),!S&&j.length>0&&(0,d.jsx)(a6,{showTop:ac,showBottom:ae,onScrollTop:aq,onScrollBottom:D}),(0,d.jsx)(a5,{cwd:a,currentCwd:E,commandHistoryRef:F,gridLayout:Y,onGridLayoutChange:b=>{Z(b),r.t4.runFork((0,u.Yn)({cwd:a,settings:{gridLayout:b}}).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to save project settings:",a))),x.orElse(()=>x.void)))},onExecute:w,onAddPluginItem:y,onShowEnvManager:()=>_(!0),onOpenShell:()=>w(a9),onOpenNote:h}),$&&(0,d.jsx)(aW,{cwd:a,tabId:c,onClose:()=>_(!1),onSave:a=>I(a)}),aa&&(0,d.jsx)(aX.Y,{onClose:()=>ab(!1),onSave:a=>J(a)})]})})},85906:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectItem.tsx","ProjectItem")},85943:(a,b,c)=>{"use strict";function d(a){let b=0,c=0;for(let d of a)/[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\u{20000}-\u{2a6df}\uac00-\ud7af]/u.test(d)?b+=1:c+=1;return Math.max(1,Math.ceil(b+c/4))}c.d(b,{r:()=>d})},85984:(a,b,c)=>{"use strict";c.d(b,{V:()=>k});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=new Map,i=new Map;async function j(a,b,c=!1){let d=`${a}::${b}`;if(c)!function(a){if(!a){h.clear(),i.clear();return}let b=`${a}::`;for(let a of h.keys())a.startsWith(b)&&h.delete(a);for(let a of i.keys())a.startsWith(b)&&i.delete(a)}(a);else{let a=h.get(d);if(a)return a;let b=i.get(d);if(b)return b}let k=e.tryPromise({try:async()=>{let e=new URLSearchParams({cwd:a,path:b});c&&e.set("refresh","1");let f=await fetch(`/api/projectGraph/file-functions?${e}`);if(404===f.status)return"not-found";if(!f.ok)throw Error((await f.json().catch(()=>({error:`HTTP ${f.status}`}))).error||`HTTP ${f.status}`);let g=await f.json();return h.set(d,g),g},catch:a=>new g.uV({message:"fetchFileFunctions failed",cause:a})}),l=f.t4.runPromiseExit(k).then(a=>{if("Success"===a._tag)return a.value;let b="Fail"===a.cause._tag?a.cause.error:null,c=b?.cause;if(c instanceof Error)throw c;throw Error(b?.message??"fetchFileFunctions failed")}).finally(()=>i.delete(d));return i.set(d,l),l}function k(a,b){let[c,e]=(0,d.useState)({state:"idle"}),f=(0,d.useRef)(!0),g=(0,d.useCallback)((a,b,c)=>{e({state:"loading"}),j(a,b,c).then(a=>{f.current&&("not-found"===a?e({state:"notFound"}):e({state:"ready",data:a}))}).catch(a=>{f.current&&e({state:"error",message:a.message})})},[]);return{state:c,refresh:(0,d.useCallback)(()=>{a&&b&&g(a,b,!0)},[a,b,g])}}},86508:(a,b,c)=>{"use strict";c.d(b,{j:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(57063),h=c(44256),i=c(37701);function j({initialRows:a,lang:b,isCustomized:c,onSave:k,onRestoreDefault:l,onClose:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)(()=>(0,i.Ff)(a,b));(0,g.E)(m);let q=(0,e.useCallback)(()=>{k((0,i.Z8)(o)),m()},[o,k,m]),r=(0,e.useCallback)(()=>{l(),m()},[l,m]);return(0,d.jsx)(h.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onClick:m,children:(0,d.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 w-full max-w-md flex flex-col",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.jsx)("h2",{className:"text-sm font-medium text-foreground",children:n("quickReply.editTitle")}),(0,d.jsx)("button",{onClick:m,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors","aria-label":n("quickReply.cancel"),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.jsxs)("div",{className:"px-4 py-3 flex flex-col gap-2",children:[(0,d.jsx)("p",{className:"text-xs text-muted-foreground",children:n("quickReply.editHint")}),(0,d.jsx)("textarea",{autoFocus:!0,value:o,onChange:a=>p(a.target.value),placeholder:n("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs font-mono bg-background border border-border rounded text-foreground focus:outline-none focus:border-brand resize-y"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground",children:n("quickReply.customizedFor",{lang:n("zh"===b?"quickReply.langZh":"quickReply.langEn")})})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:r,disabled:!c,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:n("quickReply.restoreDefault")}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:m,className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-hover transition-colors",children:n("quickReply.cancel")}),(0,d.jsx)("button",{onClick:q,className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",children:n("quickReply.save")})]})]})]})})})}},86686:(a,b,c)=>{"use strict";c.d(b,{f:()=>h});var d=c(48249),e=c(44384),f=c(57063),g=c(44256);function h({isOpen:a,onClose:b,messages:c,onSelectMessage:i}){let{t:j}=(0,e.Bd)();if((0,f.E)(b,a),!a)return null;let k=c.filter(a=>"user"===a.role),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-2xl max-h-[85vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:j("userMessages.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.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===k.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:j("userMessages.noMessages")}):(0,d.jsx)("div",{className:"divide-y divide-border",children:k.map((a,c)=>{let e,f,g,h=(e=a.id.match(/^user-(\d+)/))?parseInt(e[1],10):null,j=h?(f=new Date(h),g=new Date,f.toDateString()===g.toDateString()?f.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):f.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,d.jsx)("button",{onClick:()=>{i(a.id),b()},className:"w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[c+1,"."]}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("p",{className:"text-sm text-foreground truncate",children:a.content.replace(/\s+/g," ").trim()})}),j&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:j})]})},a.id)})})})]})});return(0,d.jsx)(g.ZL,{children:l})}},87808:(a,b,c)=>{"use strict";c.d(b,{DZ:()=>i,Ft:()=>m,Nn:()=>t,OJ:()=>q,VK:()=>u,YW:()=>l,__:()=>s,dt:()=>r,eA:()=>p,eE:()=>n,gZ:()=>j,mP:()=>h,nM:()=>v,r6:()=>o,r9:()=>k});var d=c(79606),e=c(71192);let f=(a,b={})=>d.tryPromise({try:async()=>{let c=await fetch(a,b.init);if(b.passThroughStatuses&&b.passThroughStatuses.includes(c.status))return await c.json().catch(()=>({}));if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{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/files/init?cwd=${encodeURIComponent(a)}`),i=a=>f(`/api/files/index?cwd=${encodeURIComponent(a)}`),j=(a,b)=>f(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),k=a=>f(`/api/files/recent?cwd=${encodeURIComponent(a)}`),l=(a,b,c)=>g("/api/files/recent",{cwd:a,file:b,...c??{}}),m=(a,b)=>g("/api/files/expanded",{cwd:a,paths:b}),n=(a,b)=>f(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`).pipe(d.catchAll(a=>d.succeed({error:a.message}))),o=(a,b)=>{let c,f;return c=`/api/files/stat?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,f={cache:"no-store"},d.tryPromise({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})})},p=a=>f(`/api/files/text?${a.toString()}`),q=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=null;try{c=await b.json()}catch{}return{status:b.status,ok:b.ok,data:c}},catch:a=>new e.uV({message:"POST /api/files/save failed",cause:a})}),r=()=>f("/api/files/clipboard"),s=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"POST /api/files/clipboard failed",cause:a})}),t=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/paste failed",cause:a})}),u=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/delete failed",cause:a})}),v=a=>f(`/api/file?path=${encodeURIComponent(a)}`)},87819:(a,b,c)=>{"use strict";c.d(b,{Z:()=>e});var d=c(67484);function e(a,b){let[c,e]=(0,d.useState)({status:"loading"});return c}c(13426),c(79883),c(1239),c(79606),c(95046),c(33281)},88018:(a,b,c)=>{"use strict";c.d(b,{K:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({label:a,labelClassName:b,src:c,node:h,alt:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col items-center gap-2",children:[(0,d.jsx)("div",{className:`text-xs font-medium ${b}`,children:a}),(0,d.jsx)("div",{className:"w-full flex-1 flex items-center justify-center rounded border border-border bg-secondary p-3 min-h-[8rem]",children:h??(k?(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:j("diffViewer.imageLoadFailed")}):(0,d.jsx)("img",{src:c,alt:i,onError:()=>l(!0),className:"max-w-full max-h-[60vh] object-contain"}))})]})}function h({filePath:a,oldSrc:b,newSrc:c,oldNode:e,newNode:i}){let{t:j}=(0,f.Bd)(),k=!!e||!!b,l=!!i||!!c;return(0,d.jsxs)("div",{className:"h-full overflow-auto p-4",children:[(0,d.jsx)("div",{className:"text-xs font-mono text-muted-foreground mb-3 truncate",children:a}),k||l?(0,d.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[k&&(0,d.jsx)(g,{label:j(l?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:b,node:e,alt:`${a} (before)`}),l&&(0,d.jsx)(g,{label:j(k?"diffViewer.imageAfter":"diffViewer.imageAdded"),labelClassName:"text-green-11",src:c,node:i,alt:`${a} (after)`})]}):(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:j("diffViewer.imageUnavailable")})]})}},88214:(a,b,c)=>{"use strict";c.d(b,{n:()=>e});var d=c(23734);let e={SessionChange:(0,d.R)("session-change"),ViewChange:(0,d.R)("view-change"),OpenNote:(0,d.R)("open-note"),LangChange:(0,d.R)("lang-change"),TabAdd:(0,d.R)("tab-add"),TabClose:(0,d.R)("tab-close"),SwitchSession:(0,d.R)("switch-session"),ProjectChange:(0,d.R)("project-change"),OpenProject:(0,d.R)("open-project"),SessionComplete:(0,d.R)("session-complete"),OpenTokenStats:(0,d.R)("open-token-stats"),PinnedSessionsChanged:(0,d.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,d.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,d.R)("screenshot-prepare"),ScreenshotDone:(0,d.R)("screenshot-done")}},89719:(a,b,c)=>{"use strict";function d(a,b){let c,d=document.caretRangeFromPoint(a.clientX,a.clientY);if(!d||!b.contains(d.startContainer))return 1;let e=d.startContainer,f=d.startOffset,g=document.createTreeWalker(b,NodeFilter.SHOW_TEXT),h=1;for(;c=g.nextNode();){if(c===e){h+=f;break}h+=c.textContent?.length||0}return h}function e(a,b){if(0!==a.buttons)return null;let c=window.getSelection();if(c&&!c.isCollapsed)return null;let e=a.target;if("SPAN"!==e.tagName||!e.style.color)return null;let f=e.getBoundingClientRect();return{column:d(a,b),rect:{x:f.left,y:f.bottom+4}}}c.d(b,{A:()=>e,j:()=>d})},89800:(a,b,c)=>{"use strict";c.d(b,{$:()=>i,BC:()=>j,Tu:()=>l,lb:()=>h,tj:()=>m,vv:()=>k});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>f(`/api/comments?cwd=${encodeURIComponent(a)}${b?`&filePath=${encodeURIComponent(b)}`:""}`),i=a=>f(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`),j=a=>f("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),k=(a,b,c)=>f("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,id:b,content:c})}),l=(a,b)=>g(`/api/comments?cwd=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"}),m=a=>g(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`,{method:"DELETE"})},90031:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{s:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(19593),k=c(55287),l=a([k]);function m({filePath:a,content:b,onClose:c,zClassName:d="z-50"}){let{t:l}=(0,g.Bd)(),[n,o]=(0,f.useState)("table");return(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:`fixed inset-0 ${d} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:c,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":a,onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(l("common.copiedPath"))},children:["",a]}),(0,e.jsx)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5 flex-shrink-0",children:["table","raw"].map(a=>(0,e.jsx)("button",{onClick:()=>o(a),className:`px-2 py-0.5 text-xs rounded transition-colors ${n===a?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:l(`csv.${a}`)},a))}),(0,e.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:"table"===n?(0,e.jsx)(j.C0,{content:b,filePath:a,className:"h-full"}):(0,e.jsx)(k.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}k=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},91579:(a,b,c)=>{"use strict";c.d(b,{$3:()=>l,Cm:()=>k,Ff:()=>p,Gw:()=>o,RP:()=>m,Un:()=>n,zL:()=>j});var d=c(208),e=c(79606),f=c(33281),g=c(71192),h=c(89800);let i=new Set;function j(a){return i.add(a),()=>i.delete(a)}function k(){i.forEach(a=>a())}async function l(a){let b=await f.t4.runPromiseExit((0,h.lb)(a));if("Success"!==b._tag)throw Error("Failed to fetch comments");let c=b.value.comments??[];if(0===c.length)return[];let d=new Map;for(let a of c)a.selectedText||(d.has(a.filePath)||d.set(a.filePath,[]),d.get(a.filePath).push(a));let i=new Map;await Promise.all(Array.from(d.keys()).map(async b=>{let c=await f.t4.runPromiseExit(e.tryPromise({try:async()=>{let c=await fetch(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`);return c.ok?await c.json():null},catch:a=>new g.uV({message:`read file text ${b} failed`,cause:a})}));"Success"===c._tag&&c.value&&"string"==typeof c.value.content?i.set(b,c.value.content.split("\n")):"Failure"===c._tag&&console.error(`Failed to read file ${b}:`,c.cause)}));let j=[];for(let a of c){if(a.selectedText){j.push({...a,codeContent:a.selectedText});continue}let b=i.get(a.filePath),c="";if(b){let d=Math.max(0,a.startLine-1),e=Math.min(b.length,a.endLine);c=b.slice(d,e).join("\n")}j.push({...a,codeContent:c})}return j}async function m(a){let b=await f.t4.runPromiseExit((0,h.tj)(a));return"Success"===b._tag?(k(),!0):(console.error("Failed to clear comments:",b.cause),!1)}let n="__chat__";function o(a,b){let c=a.filter(a=>a.filePath===n),e=a.filter(a=>a.filePath!==n),f=[];for(let a of(e.length>0&&(f.push(`${d.A.t("comments.codeRef")}`,""),e.forEach((a,b)=>{let c=a.startLine>0||a.endLine>0?`:${a.startLine}-${a.endLine}`:"";f.push(`[${b+1}] ${a.filePath}${c}`),f.push("```"),f.push(a.codeContent),f.push("```"),a.note&&f.push(d.A.t("comments.note",{content:a.note})),f.push("")})),c)){let b=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");f.push(b),a.note&&f.push(a.note),f.push("")}if(b.trim()){for(;f.length>0&&""===f[f.length-1];)f.pop();f.push(b.trim())}return f.join("\n").trim()}function p(a,b,c){a(o([b],c))}},91975:(a,b,c)=>{"use strict";c.d(b,{t:()=>h});var d=c(48249),e=c(67484),f=c(36043);let g=96/72;function h({cwd:a,path:b,refreshKey:c}){let k=(0,e.useRef)(null),[l,m]=(0,e.useState)({kind:"loading"}),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(0),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(0),[v,w]=(0,e.useState)({kind:"auto"}),[x,y]=(0,e.useState)(1),[z,A]=(0,e.useState)(!0),B=(0,e.useMemo)(()=>r?.length?Math.max(...r.map(a=>a.w)):0,[r]),C=Math.min(B>0&&t>0?t/B:g,g),D="auto"===v.kind?C:v.factor*g,E=Math.round(D/g*100),F=(0,e.useMemo)(()=>r?r.map(a=>a.h*D+16):[],[r,D]),G=B*D,H=(0,e.useRef)(1);H.current=C/g;let I=(0,e.useRef)(F);I.current=F;let J=(0,f.Te)({count:p,getScrollElement:()=>k.current,estimateSize:a=>I.current[a]??0,overscan:2}),K=(0,e.useCallback)(()=>{let a=k.current;if(!a||0===p)return;let b=a.scrollTop,c=J.getVirtualItems().find(a=>a.end>b);y((c?c.index:p-1)+1)},[J,p]),L=(0,e.useCallback)(a=>{w(b=>({kind:"fixed",factor:Math.min(4,Math.max(.25,("auto"===b.kind?H.current:b.factor)*a))}))},[]),M=(0,e.useCallback)(()=>L(1.2),[L]),N=(0,e.useCallback)(()=>L(.8333333333333334),[L]),O=(0,e.useCallback)(()=>w({kind:"auto"}),[]),P=(0,e.useCallback)(()=>A(a=>!a),[]),Q=(0,e.useCallback)(a=>{J.scrollToIndex(a,{align:"start"}),y(a+1)},[J]),R=J.getVirtualItems(),S=J.getTotalSize(),T=(0,e.useMemo)(()=>(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border text-muted-foreground text-xs select-none",children:[(0,d.jsx)("button",{onClick:P,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors ${z?"text-foreground":""}`,title:z?"Hide thumbnails":"Show thumbnails","aria-label":"Toggle thumbnails",children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),(0,d.jsx)("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),(0,d.jsx)("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),(0,d.jsx)("span",{className:"tabular-nums",children:p>0?`${x} / ${p}`:"—"}),(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:N,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom out","aria-label":"Zoom out",children:"−"}),(0,d.jsxs)("button",{onClick:O,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors tabular-nums min-w-[3.5rem] ${"auto"===v.kind?"":"text-foreground"}`,title:"Reset to automatic zoom",children:[E,"%"]}),(0,d.jsx)("button",{onClick:M,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom in","aria-label":"Zoom in",children:"+"})]})]}),[p,x,E,v.kind,M,N,O,z,P]);return"error"===l.kind?(0,d.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[T,(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,d.jsx)("div",{className:"text-sm text-red-11",children:l.message})})]}):(0,d.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[T,(0,d.jsxs)("div",{className:"flex-1 flex min-h-0",children:[z&&n&&r&&(0,d.jsx)(i,{doc:n,numPages:p,sizes:r,maxPageW:B,currentPage:x,onSelect:Q}),(0,d.jsx)("div",{ref:k,onScroll:K,className:"flex-1 overflow-auto px-4 py-4",children:"loading"!==l.kind&&n&&r&&!(G<=0)?(0,d.jsx)("div",{style:{height:S,width:Math.max(G,t),position:"relative"},children:R.map(a=>(0,d.jsx)("div",{"data-index":a.index,className:"absolute left-0 top-0 w-full flex justify-center",style:{transform:`translateY(${a.start}px)`,paddingBottom:16},children:(0,d.jsx)(j,{doc:n,pageNumber:a.index+1,scale:D,width:r[a.index].w*D,height:r[a.index].h*D})},a.key))}):(0,d.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})})})]})]})}function i({doc:a,numPages:b,sizes:c,maxPageW:g,currentPage:h,onSelect:k}){let l=(0,e.useRef)(null),m=g>0?100/g:0,n=(0,e.useMemo)(()=>c.map(a=>a.h*m+18+12),[c,m]),o=(0,e.useRef)(n);o.current=n;let p=(0,f.Te)({count:b,getScrollElement:()=>l.current,estimateSize:a=>o.current[a]??0,overscan:3}),q=p.getVirtualItems();return(0,d.jsx)("div",{ref:l,className:"shrink-0 overflow-auto border-r border-border py-2",style:{width:132},children:(0,d.jsx)("div",{style:{height:p.getTotalSize(),width:"100%",position:"relative"},children:q.map(b=>{let e=h===b.index+1;return(0,d.jsxs)("div",{className:"absolute left-0 top-0 w-full flex flex-col items-center",style:{transform:`translateY(${b.start}px)`,paddingBottom:12},children:[(0,d.jsx)("button",{onClick:()=>k(b.index),className:`rounded-sm overflow-hidden transition-shadow ${e?"ring-2 ring-brand":"ring-1 ring-border hover:ring-muted-foreground"}`,title:`Page ${b.index+1}`,"aria-label":`Go to page ${b.index+1}`,children:(0,d.jsx)(j,{doc:a,pageNumber:b.index+1,scale:m,width:c[b.index].w*m,height:c[b.index].h*m})}),(0,d.jsx)("span",{className:`mt-0.5 text-[11px] tabular-nums leading-none ${e?"text-foreground font-medium":"text-muted-foreground"}`,style:{height:18},children:b.index+1})]},b.key)})})})}function j({doc:a,pageNumber:b,scale:c,width:f,height:g}){let h=(0,e.useRef)(null);return(0,d.jsx)("div",{className:"bg-white shadow-lv2",style:{width:f,height:g},children:(0,d.jsx)("canvas",{ref:h,className:"block"})})}},92451:(a,b,c)=>{"use strict";c.d(b,{U:()=>g});var d=c(48249),e=c(67484),f=c(19545);function g({editor:a,query:b,position:c,onClose:h}){let[i,j]=(0,e.useState)(0),k=(0,e.useRef)(null),l=(0,f.Qe)().filter(a=>a.label.toLowerCase().includes(b.toLowerCase())||a.description.toLowerCase().includes(b.toLowerCase()));return 0===l.length?null:(0,d.jsx)("div",{ref:k,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lv2 py-1 w-56 max-h-64 overflow-y-auto",style:{top:c.top,left:c.left},children:l.map((c,e)=>(0,d.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${e===i?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover hover:text-foreground"}`,onClick:()=>{a.chain().focus().deleteRange({from:a.state.selection.from-b.length-1,to:a.state.selection.from}).run(),c.action(a),h()},onMouseEnter:()=>j(e),children:[(0,d.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:c.icon}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-medium",children:c.label}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:c.description})]})]},c.label))})}},92608:(a,b,c)=>{"use strict";c.d(b,{ShareReviewToggle:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(7833),h=c(33281),i=c(83120);function j({content:a,sourceFile:b}){let c,k,l,m,n,{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(!0),[t,u]=(0,e.useState)(!1),v=p?.active===!0,w=(0,e.useCallback)(async()=>{u(!0);let c=b.split("/").pop()||b,d=await h.t4.runPromiseExit((0,i.bx)({title:c,content:a,sourceFile:b}));if("Success"!==d._tag||!d.value.review){(0,g.oR)(o("toast.reviewCreateFailed"),"error"),u(!1);return}let e=d.value.review;q({id:e.id,active:!0,updatedAt:e.updatedAt||e.createdAt});let f=await h.t4.runPromiseExit((0,i._c)()),j="Success"===f._tag&&f.value.shareBase?`${f.value.shareBase}/review/${e.id}`:`${window.location.origin}/review/${e.id}`;try{await navigator.clipboard.writeText(j)}catch{}(0,g.oR)(e.existing?o("toast.reviewUpdated"):o("toast.reviewCreated"),"success"),u(!1)},[a,b,o]),x=(0,e.useCallback)(async()=>{p&&(u(!0),"Success"===(await h.t4.runPromiseExit((0,i.Gm)(p.id,{active:!1})))._tag?(q(a=>a?{...a,active:!1}:null),(0,g.oR)(o("toast.sharingClosed"),"success")):(0,g.oR)(o("toast.sharingCloseFailed"),"error"),u(!1))},[p,o]),y=(0,e.useCallback)(()=>{t||(v?x():w())},[t,v,w,x]),z=(0,e.useCallback)(()=>{p&&window.open(`${window.location.origin}/review/${p.id}`,"_blank")},[p]);return r?null:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:y,disabled:t,className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${t?"opacity-50 cursor-wait":"cursor-pointer"} ${v?"bg-green-500":"bg-muted-foreground/30"}`,title:v?o("review.closeSharing"):o("review.enableSharing"),children:(0,d.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white transition-transform ${v?"translate-x-3.5":"translate-x-0.5"}`})}),(0,d.jsx)("span",{className:`text-[11px] ${v?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,children:v?o("review.sharing"):o("review.notShared")}),v&&p&&p.updatedAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(k=String((c=new Date(p.updatedAt)).getMonth()+1).padStart(2,"0"),l=String(c.getDate()).padStart(2,"0"),m=String(c.getHours()).padStart(2,"0"),n=String(c.getMinutes()).padStart(2,"0"),`${k}-${l} ${m}:${n}`)}),(0,d.jsx)("button",{onClick:z,className:"text-[11px] text-brand hover:underline",children:o("review.view")})]})]})}},92701:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(81206),k=c(23700),l=a([k]);function m(a){return a?a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a):"0"}function n(a){if(!a)return"–";let b=Math.round(a/1e3);if(b<60)return`${b}s`;let c=Math.floor(b/60);return`${c}m${b%60}s`}k=(l.then?(await l)():l)[0];let q={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function o({cwd:a,sessionId:b,runId:c,isRunning:d,onClose:l}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useRef)(void 0),y=d||null!=r&&"completed"!==r.status&&"failed"!==r.status;(0,f.useCallback)(async()=>{let d=await i.t4.runPromiseExit((0,j.z)({cwd:a,sessionId:b,workflowId:c,ifFingerprint:x.current}));if(u(!0),"Success"!==d._tag||!d.value)return;let e=d.value;e.fingerprint&&(x.current=e.fingerprint),!e.notModified&&e.workflow&&s(e.workflow)},[a,b,c]);let z=[];if(r?.agents){let a=new Map;for(let b of r.agents){let c=b.phaseTitle||q("chat.workflowUngrouped");a.has(c)||a.set(c,[]),a.get(c).push(b)}for(let[b,c]of a)z.push({title:b,agents:c})}let A=r?[r.workflowName,r.status,`${r.agentCount??r.agents?.length??0} ${q("chat.workflowAgents")}`,`${m(r.totalTokens)} tok`,n(r.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,e.jsxs)(h.ZL,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:l,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\uDDE9"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:q("chat.workflowRun")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:q("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===r?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:q(t?"chat.workflowEmpty":"common.loading")}):(0,e.jsxs)(e.Fragment,{children:[r.summary&&(0,e.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:r.summary}),z.map(a=>(0,e.jsxs)(f.Fragment,{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:a.title}),a.agents.map(a=>(0,e.jsx)(p,{agent:a,onOpen:()=>a.agentId&&w({runId:c,agentId:a.agentId,label:a.label,running:"done"!==a.state&&y})},`${a.index}-${a.agentId}`))]},a.title))]})})]})}),v&&(0,e.jsx)(k.f,{cwd:a,sessionId:b,workflowRef:v,onClose:()=>w(null)})]})}function p({agent:a,onOpen:b}){let{t:c}=(0,g.Bd)(),[d,h]=(0,f.useState)(!1),i=a.state&&q[a.state]||"text-muted-foreground",j=a.resultPreview||a.promptPreview||"";return(0,e.jsxs)("div",{className:"border border-border rounded-md mb-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,e.jsx)("button",{onClick:()=>h(a=>!a),className:"text-foreground-subtle text-xs flex-shrink-0",title:c(d?"chat.collapse":"chat.expand"),children:d?"▲":"▼"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0","data-tooltip":a.label||"",children:a.label||a.agentId}),(0,e.jsx)("span",{className:`text-[10px] flex-shrink-0 ${i}`,children:a.state}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[m(a.tokens)," tok \xb7 ",n(a.durationMs)]}),a.agentId&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:b,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&b()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:c("chat.subagentViewTitle"),children:c("chat.workflowViewAgent")})]}),d&&j&&(0,e.jsx)("pre",{className:"text-[11px] bg-secondary px-2 py-1.5 rounded-b overflow-x-auto max-h-32 overflow-y-auto text-muted-foreground whitespace-pre-wrap border-t border-border",children:j})]})}d()}catch(a){d(a)}})},93448:(a,b,c)=>{"use strict";c.d(b,{TabManagerTopBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManagerTopBar() from the server but TabManagerTopBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabManagerTopBar.tsx","TabManagerTopBar")},94192:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[k,l]=(0,e.useState)(!1);f.indexOf(a),f.length;let[m,n]=(0,e.useState)(!1),o={activeView:a,onViewChange:b,dragOffset:(()=>{if(!m)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:m&&k};return(0,d.jsx)(h.Provider,{value:o,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=f.indexOf(g),o=f.length;return(0,d.jsx)("div",{ref:l,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:m,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/o*100,c=-(100/o*n)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},94239:(a,b,c)=>{"use strict";c.d(b,{c:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(61591),h=c(44256);function i({path:a,matchedIndices:b}){let c=(0,e.useMemo)(()=>new Set(b),[b]),f=a.lastIndexOf("/"),g=f>=0?a.slice(0,f+1):"",h=f>=0?a.slice(f+1):a,j=(a,b,e)=>{let f=[],g="",h=!1;for(let e=0;e<a.length;e++){let i=b+e,j=c.has(i);j!==h&&g&&(f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${e}`):(0,d.jsx)("span",{children:g},`${b}-${e}`)),g=""),h=j,g+=a[e]}return g&&f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,d.jsx)("span",{children:g},`${b}-end`)),(0,d.jsx)("span",{className:e,children:f})};return(0,d.jsxs)("span",{className:"truncate",children:[g&&j(g,0,"text-muted-foreground"),j(h,g.length,"text-foreground")]})}function j({files:a,fileIndex:b,recentFiles:c,onSelectFile:k,onClose:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(0),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),u=(0,e.useMemo)(()=>{if(!n.trim()){let a=new Set(c);return[...c.map(a=>({path:a,score:0,matchedIndices:[]})),...t.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}))]}let a=[];for(let b of t){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)c[i]===d[f]&&(e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10),i>a.lastIndexOf("/")&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++);return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,n.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[n,t,c]),v=(0,e.useCallback)(a=>{o(a),q(0)},[]),w=(0,e.useCallback)(a=>{k(a),l()},[k,l]),x=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),q(a=>Math.min(a+1,u.length-1));break;case"ArrowUp":a.preventDefault(),q(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),u[p]&&w(u[p].path);break;case"Escape":a.preventDefault(),l()}},[u,p,w,l]);return(0,d.jsx)(h.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:l,children:(0,d.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-lv3 overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,d.jsx)("input",{ref:r,value:n,onChange:a=>v(a.target.value),onKeyDown:x,placeholder:m("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,d.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,d.jsx)("div",{ref:s,className:"flex-1 overflow-y-auto py-1",children:0===u.length?(0,d.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:m("quickFileOpen.noMatch")}):u.map((a,b)=>(0,d.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===p?"bg-brand/15 text-foreground":"hover:bg-hover text-foreground"}`,"data-tooltip":a.path,onClick:()=>w(a.path),children:[(0,d.jsx)(g.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)(i,{path:a.path,matchedIndices:a.matchedIndices}),!n.trim()&&c.includes(a.path)&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:m("quickFileOpen.recent")})]},a.path))}),(0,d.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",m("quickFileOpen.selectHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",m("quickFileOpen.openHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",m("quickFileOpen.closeHint")]})]})]})})})}},94308:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:h,pinnedBranches:i=[]}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=m.toLowerCase(),r=new Set([...a?.local||[],...a?.remote||[]]),s=i.filter(a=>r.has(a)&&a.toLowerCase().includes(q)),t=new Set(s),u=a?.local.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],v=a?.remote.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],w=a=>{c(a),l(!1),n("")};return(0,d.jsxs)("div",{className:"relative",ref:o,children:[(0,d.jsxs)("button",{onClick:()=>l(!k),disabled:h,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||j("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",j("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-foreground-subtle transition-transform ${k?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),k&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lv2 max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:p,type:"text",value:m,onChange:a=>n(a.target.value),placeholder:j("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length>0&&s.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${c}`)),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:j("git.localBranches")}),u.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),v.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:j("git.remoteBranches")}),v.map(a=>(0,d.jsxs)("div",{onClick:()=>w(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===s.length&&0===u.length&&0===v.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:j("git.noMatchingBranches")})]})]})]})}},95401:(a,b,c)=>{"use strict";c.d(b,{m:()=>k});var d=c(48249),e=c(67484),f=c(44256),g=c(33281),h=c(63565),i=c(41224);function j(a){return"env"===a?"from env var":"default"===a?"default":null}function k({currentModel:a,onModelChange:b}){let[c,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)("default"),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(""),[I,J]=(0,e.useState)("default"),[K,L]=(0,e.useState)(""),[M,N]=(0,e.useState)(!1),O=(0,e.useRef)(null),P=(0,e.useRef)(null),Q=(0,e.useRef)(null),[R,S]=(0,e.useState)({top:0,left:0}),T=(0,f.F2)(),U=(0,e.useCallback)(async()=>{p(!0),r(null);let a=await g.t4.runPromiseExit((0,i.qD)(()=>t(!0)));if(t(!1),"Failure"===a._tag)r("Connection error");else{let b=a.value;switch(b._tag){case"ok":n(b.models);break;case"not-installed":case"error":r(b.message);break;case"not-running":r("Ollama is not running")}}p(!1)},[]),V=(0,e.useCallback)(a=>{B(a.baseUrl),D(a.baseUrlSource),F(a.hasKey),H(a.maskedKey),J(a.keySource),L(""),N(!1)},[]),W=(0,e.useCallback)(async()=>{v(!0),z(null);let a=await g.t4.runPromiseExit((0,i.F4)());"Failure"===a._tag?z("Failed to load config"):V(a.value),v(!1)},[V]),X=async()=>{x(!0),z(null);let a=await g.t4.runPromiseExit((0,i.yS)({baseUrl:A}));"Failure"===a._tag?z("Save failed"):(V(a.value),await U()),x(!1)},Y=async()=>{let a=K.trim();if(!a)return;x(!0),z(null);let b=await g.t4.runPromiseExit((0,i.yS)({apiKey:a}));"Failure"===b._tag?z("Save failed"):V(b.value),x(!1)},Z=async()=>{x(!0),z(null);let a=await g.t4.runPromiseExit((0,i.yS)({apiKey:""}));"Failure"===a._tag?z("Clear failed"):V(a.value),x(!1)},$=a?a.replace(/:latest$/,""):"Select model",_=j(C),aa=j(I),ab=c?(0,d.jsx)(f.ZL,{children:(0,d.jsxs)("div",{ref:P,className:`${h.ys} min-w-[300px]`,style:{top:R.top,left:R.left},children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Server URL"}),_&&!u&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:_})]}),u?(0,d.jsxs)("div",{className:"flex items-center gap-2 py-1 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)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:A,onChange:a=>B(a.target.value),onKeyDown:a=>{"Enter"===a.key&&X()},placeholder:"http://127.0.0.1:11434",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${h.Fx}`}),(0,d.jsx)("button",{onClick:X,disabled:w,className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${h.$T}`,children:w?"...":"Save"})]})]}),(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),aa&&E&&!u&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:aa})]}),u?null:E&&!M?(0,d.jsxs)("div",{className:"flex items-center gap-2",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:G}),(0,d.jsx)("button",{onClick:()=>{N(!0),L(""),setTimeout(()=>Q.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:w,children:"Edit"}),(0,d.jsx)("button",{onClick:Z,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:w,children:"Clear"})]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:Q,type:"password",value:K,onChange:a=>L(a.target.value),onKeyDown:a=>{"Enter"===a.key&&Y()},placeholder:"optional — for authenticated servers",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${h.Fx}`}),(0,d.jsx)("button",{onClick:Y,disabled:w||!K.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${h.$T}`,children:w?"...":"Save"}),E&&(0,d.jsx)("button",{onClick:()=>{N(!1),L("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),y&&(0,d.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:y})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"}),(0,d.jsx)("div",{className:"px-3 pt-1 pb-0.5",children:(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Model"})}),(0,d.jsx)("div",{className:"max-h-[240px] overflow-y-auto",children:o||s?(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"}),s?"Starting Ollama...":"Loading models..."]}):q?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-red-11",children:q}):0===m.length?(0,d.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,d.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):m.map(c=>{var e;let f=c.name===a;return(0,d.jsxs)("button",{onClick:()=>{b(c.name),l(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors ${f?h.yI:"text-foreground hover:bg-hover"}`,children:[(0,d.jsx)(h.hG,{selected:f}),(0,d.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,d.jsx)("span",{className:"ml-auto pl-2 text-muted-foreground flex-shrink-0",children:c.parameter_size||((e=c.size)<1e9?`${(e/1e6).toFixed(0)}M`:`${(e/1e9).toFixed(1)}G`)})]},c.name)})})]})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h.XY,{buttonRef:O,label:$,title:"Configure Ollama",onClick:()=>{if(!c){if(O.current){let a=O.current.getBoundingClientRect(),b=T?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;S({top:a.bottom+4-d,left:a.left-c})}W(),U()}l(a=>!a)},icon:(0,d.jsx)(h.eV,{engine:"ollama"}),testId:"ollama-config-picker"}),ab]})}},97572:(a,b,c)=>{"use strict";c.d(b,{g:()=>g,v:()=>f});var d=c(79606),e=c(71192);let f=d.tryPromise({try:async()=>{let a=await fetch("/api/projects");if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>new e.uV({message:"fetch /api/projects failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"save /api/projects failed",cause:a})})},97951:(a,b,c)=>{"use strict";c.d(b,{e:()=>j});var d=c(67484),e=c(85943),f=c(25414),g=c(208),h=c(29939);let i=[];function j(a,b,{sessionId:c,cwd:k,engine:l,planMode:m,noHistory:n,ollamaModel:o,engineModel:p,claudeModel:q,claudeEffort:r,claudeContextWindow:s,claudeFastMode:t,claudeThinking:u,codexModel:v,codexReasoningEffort:w,onSessionId:x,onFetchTitle:y,onRunComplete:z}){let[A,B]=(0,d.useState)(!1),[C,D]=(0,d.useState)(null),[E,F]=(0,d.useState)(null),[G,H]=(0,d.useState)(null),[I,J]=(0,d.useState)(null),[K,L]=(0,d.useState)(null),[M,N]=(0,d.useState)(i),O=(0,d.useRef)(null),[P,Q]=(0,d.useState)(null),R=(0,d.useRef)(P);R.current=P;let S=(0,d.useRef)(!1),T=(0,d.useRef)(z);T.current=z;let U=(0,d.useRef)(!1),V=(0,d.useRef)(null),W=(0,d.useRef)(c);W.current=c;let X=(0,d.useRef)(null),Y=(0,d.useRef)(null),Z=(0,d.useRef)(null),$=(0,d.useRef)(!1),_=(0,d.useRef)(!1),aa=(0,d.useRef)(0),ab=(0,d.useCallback)(()=>{let a=X.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>(0,f.F)(a,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:d}}},{engine:l,assistantId:c})),X.current={messageId:c,text:""}}Y.current=null},[b,l]),ac=(0,d.useCallback)(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),V.current&&(clearTimeout(V.current),V.current=null),ab(),B(!1),F(null),H(null),N(i);let a=R.current,c=Z.current;a&&b(b=>b.map(b=>b.id===a.assistantId||b.id===c?{...b,isStreaming:!1}:b)),Q(null),T.current?.()},[ab,b]),ad=(0,d.useCallback)(()=>{let a=R.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:W.current,runId:a?.runKey})}).catch(()=>{}),ac()},[ac]),ae=(0,d.useCallback)((a,c)=>{let d=a.type,h=a=>{if(S.current||"string"!=typeof a||!a)return;let b=(0,e.r)(a);F(a=>({outputTokens:(a?.outputTokens||0)+b}))};if("system"===d&&"init"===a.subtype){let c=a.session_id,d=$.current;if(x(c),W.current=c,d||(H(a=>a??Date.now()),F(null),S.current=!1),L(null),d){let a=`auto-asst-${++aa.current}`;Z.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:R.current?.runKey,runId:R.current?.runId}])}_.current=!0;return}if("system"===d&&"background_tasks_changed"===a.subtype){let b=(a.tasks??[]).filter(a=>!a.ambient).map(a=>({task_id:a.task_id,description:a.description}));N(b.length?b:i);return}if("system"===d&&"task_notification"===a.subtype){if(!_.current){let c=a.status,d=a.summary||"",e=a.task_id,f=`<task-notification>
|
|
752
|
+
Error: ${c.message}`,exitCode:1,isRunning:!1,pid:void 0}:d))}},[f,C,l,z,c,a,W,ab,X]),al=(0,e.useCallback)(async b=>{g(a=>a.filter(a=>a.id!==b)),X(b),c&&await r.t4.runPromise((0,u.SN)(a,c,b,T.current).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to delete command:",a))),x.orElse(()=>x.void)))},[a,c,X]),am=(0,e.useCallback)((b,d,e)=>{var f;let g=G(b);if(!g)return;let h=g.parse(d);"cwd"in h&&!h.cwd&&(h.cwd=l);let j={id:(f=g.idPrefix,`${f}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),_type:b,timestamp:new Date().toISOString(),...h};if(i(a=>[...a,j]),y(j.id),setTimeout(ac,100),e){let b=E&&E.length>0?[...E]:S.current.map(a=>a.data.id),d=b.indexOf(e);-1!==d?b.splice(d+1,0,j.id):b.push(j.id),F(b),c&&r.t4.runFork((0,u.cm)(a,c,b,T.current).pipe(x.orElse(()=>x.void)))}if(c){let d=g.toHistory(j);r.t4.runFork((0,u.AJ)(a,c,{type:b,id:j.id,timestamp:j.timestamp,...d},T.current).pipe(x.tapError(a=>x.sync(()=>console.error(`Failed to save ${b} item:`,a))),x.orElse(()=>x.void)))}},[ac,a,c,E]),an=(0,e.useCallback)(async b=>{let d=h.find(a=>a.id===b);if(i(a=>a.filter(a=>a.id!==b)),y(a=>a===b?null:a),k(a=>{let c=new Set(a);return c.delete(b),c}),d){let a=G(d._type);a?.onClose?.(d)}c&&r.t4.runFork((0,u.SN)(a,c,b,T.current).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to delete plugin item:",a))),x.orElse(()=>x.void)))},[h,a,c]);R.current=am,Q.current=ai;let ao=(0,e.useCallback)((b,d)=>{c&&r.t4.runFork((0,u.bv)(a,c,b,{sleeping:d},T.current).pipe(x.orElse(()=>x.void)))},[a,c]),ap=(0,e.useCallback)(a=>{k(b=>new Set(b).add(a)),ao(a,!0)},[ao]),aq=(0,e.useCallback)(a=>{k(b=>{let c=new Set(b);return c.delete(a),c}),ao(a,!1)},[ao]),ar=(0,e.useCallback)(async b=>{F(b),c&&await r.t4.runPromise((0,u.cm)(a,c,b,T.current).pipe(x.orElse(()=>x.void)))},[a,c]),as=(0,e.useMemo)(()=>{let a=[...f.map(a=>({type:"command",data:a})),...h.map(a=>({type:a._type,data:a}))];if(!E||0===E.length)return a.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime());let b=new Map(E.map((a,b)=>[a,b])),c=[],d=[];for(let e of a)b.has(e.data.id)?c.push(e):d.push(e);return c.sort((a,c)=>b.get(a.data.id)-b.get(c.data.id)),d.sort((a,b)=>new Date(a.data.timestamp).getTime()-new Date(b.data.timestamp).getTime()),[...c,...d]},[f,h,E]);return S.current=as,{commands:f,pluginItems:h,sleepingBubbles:j,consoleItems:as,currentCwd:l,selectedCommandId:w,setSelectedCommandId:y,customEnv:z,setCustomEnv:A,aliases:C,setAliases:D,isLoadingHistory:n,hasMoreHistory:p,currentPage:t,scrollRef:U,commandHistoryRef:M,ptySizeRef:N,executeCommandRef:Q,executeCommand:ai,interruptCommand:aj,rerunCommand:ak,deleteCommand:al,addPluginItem:am,closePluginItem:an,handleBubbleSleep:ap,handleBubbleWake:aq,loadHistory:ad,scrollToBottom:ac,saveBubbleOrder:ar,sendStdin:aP,resizePty:aQ,subscribePtyOutput:Y,subscribePtyReset:$,subscribePtyRefresh:aa}}({cwd:a,initialShellCwd:b,tabId:c,onCwdChange:g}),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)(0),[W,X]=(0,e.useState)(0),[Y,Z]=(0,e.useState)(!0),[$,_]=(0,e.useState)(!1),[aa,ab]=(0,e.useState)(!1),[ac,ad]=(0,e.useState)(!1),[ae,af]=(0,e.useState)(!1),ag=(0,e.useRef)(null),ah=(0,e.useRef)(null),ai=(0,e.useRef)(null),aj=(0,e.useRef)(!1),ak=(0,e.useRef)(null),al=(0,e.useRef)(null),am=(0,e.useRef)([]),an=(0,e.useCallback)(()=>{let a=k.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[k]),ao=(0,e.useCallback)(()=>{let a=k.current;return!a||a.scrollTop<50},[k]),ap=(0,e.useCallback)(()=>{ad(!ao()),af(!an())},[an,ao]),aq=(0,e.useCallback)(()=>{ah.current?.scrollIntoView({behavior:"smooth"})},[]),ar=(0,e.useCallback)(()=>{aj.current=!0},[]),as=(0,e.useCallback)((a,b)=>{if(!aj.current)return void a.preventDefault();aj.current=!1,ak.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b),a.currentTarget.style.opacity="0.4";let c=a.currentTarget.querySelector("[data-drag-handle]");if(c){let b=c.cloneNode(!0);b.style.cssText="position:fixed;top:-9999px;left:-9999px;width:"+c.offsetWidth+"px;background:hsl(var(--card));color:hsl(var(--foreground));box-shadow:var(--elevation-2);border-radius:8px;padding:4px 12px;opacity:0.9;",document.body.appendChild(b),a.dataTransfer.setDragImage(b,20,16),requestAnimationFrame(()=>document.body.removeChild(b))}},[]),at=(0,e.useCallback)((a,b)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",al.current=b},[]),au=(0,e.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.add("ring-2","ring-brand")},[]),av=(0,e.useCallback)(a=>{a.currentTarget.classList.remove("ring-2","ring-brand")},[]),aw=(0,e.useCallback)(a=>{a.preventDefault(),a.currentTarget.classList.remove("ring-2","ring-brand")},[]),ax=(0,e.useCallback)(a=>{a.currentTarget.style.opacity="1";let b=ak.current,c=al.current;if(ak.current=null,al.current=null,!b||!c||b===c)return;let d=am.current.map(a=>a.data.id),e=d.indexOf(b),f=d.indexOf(c);if(-1===e||-1===f)return;let g=[...d];g[e]=c,g[f]=b,K(g)},[K]),ay=(0,e.useCallback)(a=>{T(b=>b===a?null:a)},[]),az=(0,e.useCallback)((a,b)=>y("browser",a,b),[y]),aA=W>0?Math.floor((W-32-12)/2-41):void 0;return(0,d.jsxs)("div",{ref:ag,className:"h-full flex flex-col bg-background relative",children:[(0,d.jsx)("div",{ref:k,onScroll:ap,className:`console-scroll-root flex-1 overflow-y-auto ${S?"":"py-4 px-4"}`,children:0===j.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-4 text-sm",children:[(0,d.jsx)("p",{className:"text-muted-foreground",children:i("console.emptyIntro")}),(0,d.jsx)("ul",{className:"flex flex-col gap-2",children:bc.map(a=>(0,d.jsxs)("li",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:"w-16 flex-shrink-0 text-foreground font-medium",children:i(a.label)}),(0,d.jsxs)("span",{className:"flex-1 flex flex-col gap-1",children:[(0,d.jsx)("span",{className:"flex flex-wrap gap-1",children:a.triggers.map(a=>(0,d.jsx)("code",{className:"px-1.5 py-0.5 rounded bg-muted text-xs font-mono text-muted-foreground",children:a},a))}),a.notes?.map(a=>(0,d.jsx)("span",{className:"text-xs leading-snug text-muted-foreground/70",children:i(a)},a))]})]},a.key))}),(0,d.jsxs)("button",{type:"button",onClick:()=>w(a9),title:i("console.launchShell"),className:"self-start flex items-center gap-2 px-4 py-2 rounded-lg border border-input bg-background text-sm text-muted-foreground hover:text-foreground hover:bg-hover active:bg-muted active:scale-95 transition-all",children:[(0,d.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,d.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),"New PTY"]})]})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{ref:ah}),L&&(0,d.jsx)("div",{className:"flex justify-center mb-4",children:(0,d.jsx)("button",{onClick:()=>M(N+1),disabled:O,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-hover rounded-lg transition-colors disabled:opacity-50",children:O?i("console.loadingMore"):i("console.loadMoreHistory")})}),(0,d.jsx)("div",{className:S?"flex flex-col gap-3":Y?"grid grid-cols-2 gap-3":"flex flex-col gap-3",children:j.map(b=>(0,d.jsx)(aT,{item:b,selected:l===b.data.id,maximized:S===b.data.id,initialSleeping:A.has(b.data.id),tabId:c,projectCwd:a,expandedHeight:U,bubbleContentHeight:aA,onDragStart:as,onDragOver:at,onDragEnter:au,onDragLeave:av,onDrop:aw,onDragEnd:ax,onSelectId:m,onInterruptId:n,onStdin:o,onDeleteCommand:p,onRerun:s,subscribePtyOutput:P,subscribePtyReset:Q,subscribePtyRefresh:R,ptySizeRef:t,resizePty:v,onToggleMaximizeId:ay,onTitleMouseDown:ar,onClosePlugin:z,addBrowserItem:az,onSleep:B,onWake:C},b.data.id))}),(0,d.jsx)("div",{ref:ai})]})}),!S&&j.length>0&&(0,d.jsx)(a6,{showTop:ac,showBottom:ae,onScrollTop:aq,onScrollBottom:D}),(0,d.jsx)(a5,{cwd:a,currentCwd:E,commandHistoryRef:F,gridLayout:Y,onGridLayoutChange:b=>{Z(b),r.t4.runFork((0,u.Yn)({cwd:a,settings:{gridLayout:b}}).pipe(x.tapError(a=>x.sync(()=>console.error("Failed to save project settings:",a))),x.orElse(()=>x.void)))},onExecute:w,onAddPluginItem:y,onShowEnvManager:()=>_(!0),onOpenShell:()=>w(a9),onOpenNote:h}),$&&(0,d.jsx)(aW,{cwd:a,tabId:c,onClose:()=>_(!1),onSave:a=>I(a)}),aa&&(0,d.jsx)(aX.Y,{onClose:()=>ab(!1),onSave:a=>J(a)})]})})},85906:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/ProjectItem.tsx","ProjectItem")},85943:(a,b,c)=>{"use strict";function d(a){let b=0,c=0;for(let d of a)/[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\u{20000}-\u{2a6df}\uac00-\ud7af]/u.test(d)?b+=1:c+=1;return Math.max(1,Math.ceil(b+c/4))}c.d(b,{r:()=>d})},85984:(a,b,c)=>{"use strict";c.d(b,{V:()=>k});var d=c(67484),e=c(79606),f=c(33281),g=c(71192);let h=new Map,i=new Map;async function j(a,b,c=!1){let d=`${a}::${b}`;if(c)!function(a){if(!a){h.clear(),i.clear();return}let b=`${a}::`;for(let a of h.keys())a.startsWith(b)&&h.delete(a);for(let a of i.keys())a.startsWith(b)&&i.delete(a)}(a);else{let a=h.get(d);if(a)return a;let b=i.get(d);if(b)return b}let k=e.tryPromise({try:async()=>{let e=new URLSearchParams({cwd:a,path:b});c&&e.set("refresh","1");let f=await fetch(`/api/projectGraph/file-functions?${e}`);if(404===f.status)return"not-found";if(!f.ok)throw Error((await f.json().catch(()=>({error:`HTTP ${f.status}`}))).error||`HTTP ${f.status}`);let g=await f.json();return h.set(d,g),g},catch:a=>new g.uV({message:"fetchFileFunctions failed",cause:a})}),l=f.t4.runPromiseExit(k).then(a=>{if("Success"===a._tag)return a.value;let b="Fail"===a.cause._tag?a.cause.error:null,c=b?.cause;if(c instanceof Error)throw c;throw Error(b?.message??"fetchFileFunctions failed")}).finally(()=>i.delete(d));return i.set(d,l),l}function k(a,b){let[c,e]=(0,d.useState)({state:"idle"}),f=(0,d.useRef)(!0),g=(0,d.useCallback)((a,b,c)=>{e({state:"loading"}),j(a,b,c).then(a=>{f.current&&("not-found"===a?e({state:"notFound"}):e({state:"ready",data:a}))}).catch(a=>{f.current&&e({state:"error",message:a.message})})},[]);return{state:c,refresh:(0,d.useCallback)(()=>{a&&b&&g(a,b,!0)},[a,b,g])}}},86508:(a,b,c)=>{"use strict";c.d(b,{j:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(57063),h=c(44256),i=c(37701);function j({initialRows:a,lang:b,isCustomized:c,onSave:k,onRestoreDefault:l,onClose:m}){let{t:n}=(0,f.Bd)(),[o,p]=(0,e.useState)(()=>(0,i.Ff)(a,b));(0,g.E)(m);let q=(0,e.useCallback)(()=>{k((0,i.Z8)(o)),m()},[o,k,m]),r=(0,e.useCallback)(()=>{l(),m()},[l,m]);return(0,d.jsx)(h.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-scrim p-4",onClick:m,children:(0,d.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-lv3 w-full max-w-md flex flex-col",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.jsx)("h2",{className:"text-sm font-medium text-foreground",children:n("quickReply.editTitle")}),(0,d.jsx)("button",{onClick:m,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-hover rounded transition-colors","aria-label":n("quickReply.cancel"),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.jsxs)("div",{className:"px-4 py-3 flex flex-col gap-2",children:[(0,d.jsx)("p",{className:"text-xs text-muted-foreground",children:n("quickReply.editHint")}),(0,d.jsx)("textarea",{autoFocus:!0,value:o,onChange:a=>p(a.target.value),placeholder:n("quickReply.editPlaceholder"),rows:6,spellCheck:!1,className:"w-full px-2 py-1.5 text-xs font-mono bg-background border border-border rounded text-foreground focus:outline-none focus:border-brand resize-y"}),(0,d.jsx)("p",{className:"text-xs text-muted-foreground",children:n("quickReply.customizedFor",{lang:n("zh"===b?"quickReply.langZh":"quickReply.langEn")})})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[(0,d.jsx)("button",{onClick:r,disabled:!c,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:n("quickReply.restoreDefault")}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:m,className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-hover transition-colors",children:n("quickReply.cancel")}),(0,d.jsx)("button",{onClick:q,className:"px-3 py-1.5 text-xs font-medium border border-brand text-brand rounded-md hover:bg-brand/10 transition-colors",children:n("quickReply.save")})]})]})]})})})}},86686:(a,b,c)=>{"use strict";c.d(b,{f:()=>h});var d=c(48249),e=c(44384),f=c(57063),g=c(44256);function h({isOpen:a,onClose:b,messages:c,onSelectMessage:i}){let{t:j}=(0,e.Bd)();if((0,f.E)(b,a),!a)return null;let k=c.filter(a=>"user"===a.role),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-2xl max-h-[85vh] flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border shrink-0",children:[(0,d.jsx)("h3",{className:"text-sm font-medium text-foreground",children:j("userMessages.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.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===k.length?(0,d.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:j("userMessages.noMessages")}):(0,d.jsx)("div",{className:"divide-y divide-border",children:k.map((a,c)=>{let e,f,g,h=(e=a.id.match(/^user-(\d+)/))?parseInt(e[1],10):null,j=h?(f=new Date(h),g=new Date,f.toDateString()===g.toDateString()?f.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):f.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})):"";return(0,d.jsx)("button",{onClick:()=>{i(a.id),b()},className:"w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsxs)("span",{className:"text-xs text-muted-foreground font-mono w-6 shrink-0 pt-0.5",children:[c+1,"."]}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:(0,d.jsx)("p",{className:"text-sm text-foreground truncate",children:a.content.replace(/\s+/g," ").trim()})}),j&&(0,d.jsx)("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:j})]})},a.id)})})})]})});return(0,d.jsx)(g.ZL,{children:l})}},87808:(a,b,c)=>{"use strict";c.d(b,{DZ:()=>i,Ft:()=>m,Nn:()=>t,OJ:()=>q,VK:()=>u,YW:()=>l,__:()=>s,dt:()=>r,eA:()=>p,eE:()=>n,gZ:()=>j,mP:()=>h,nM:()=>v,r6:()=>o,r9:()=>k});var d=c(79606),e=c(71192);let f=(a,b={})=>d.tryPromise({try:async()=>{let c=await fetch(a,b.init);if(b.passThroughStatuses&&b.passThroughStatuses.includes(c.status))return await c.json().catch(()=>({}));if(!c.ok){let a;try{a=(await c.json()).error}catch{}throw Error(a||`HTTP ${c.status}`)}return await c.json()},catch:b=>new e.uV({message:`GET ${a} failed`,cause:b})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,{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/files/init?cwd=${encodeURIComponent(a)}`),i=a=>f(`/api/files/index?cwd=${encodeURIComponent(a)}`),j=(a,b)=>f(`/api/files/readdir?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`),k=a=>f(`/api/files/recent?cwd=${encodeURIComponent(a)}`),l=(a,b,c)=>g("/api/files/recent",{cwd:a,file:b,...c??{}}),m=(a,b)=>g("/api/files/expanded",{cwd:a,paths:b}),n=(a,b)=>f(`/api/files/blame?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`).pipe(d.catchAll(a=>d.succeed({error:a.message}))),o=(a,b)=>{let c,f;return c=`/api/files/stat?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`,f={cache:"no-store"},d.tryPromise({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})})},p=a=>f(`/api/files/text?${a.toString()}`),q=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=null;try{c=await b.json()}catch{}return{status:b.status,ok:b.ok,data:c}},catch:a=>new e.uV({message:"POST /api/files/save failed",cause:a})}),r=()=>f("/api/files/clipboard"),s=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/clipboard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"POST /api/files/clipboard failed",cause:a})}),t=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/paste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/paste failed",cause:a})}),u=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||`HTTP ${b.status}`);return c},catch:a=>new e.uV({message:"POST /api/files/delete failed",cause:a})}),v=a=>f(`/api/file?path=${encodeURIComponent(a)}`)},87819:(a,b,c)=>{"use strict";c.d(b,{Z:()=>e});var d=c(67484);function e(a,b){let[c,e]=(0,d.useState)({status:"loading"});return c}c(13426),c(79883),c(1239),c(79606),c(95046),c(33281)},88018:(a,b,c)=>{"use strict";c.d(b,{K:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({label:a,labelClassName:b,src:c,node:h,alt:i}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col items-center gap-2",children:[(0,d.jsx)("div",{className:`text-xs font-medium ${b}`,children:a}),(0,d.jsx)("div",{className:"w-full flex-1 flex items-center justify-center rounded border border-border bg-secondary p-3 min-h-[8rem]",children:h??(k?(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:j("diffViewer.imageLoadFailed")}):(0,d.jsx)("img",{src:c,alt:i,onError:()=>l(!0),className:"max-w-full max-h-[60vh] object-contain"}))})]})}function h({filePath:a,oldSrc:b,newSrc:c,oldNode:e,newNode:i}){let{t:j}=(0,f.Bd)(),k=!!e||!!b,l=!!i||!!c;return(0,d.jsxs)("div",{className:"h-full overflow-auto p-4",children:[(0,d.jsx)("div",{className:"text-xs font-mono text-muted-foreground mb-3 truncate",children:a}),k||l?(0,d.jsxs)("div",{className:"flex flex-wrap items-stretch gap-4",children:[k&&(0,d.jsx)(g,{label:j(l?"diffViewer.imageBefore":"diffViewer.imageDeleted"),labelClassName:"text-red-11",src:b,node:e,alt:`${a} (before)`}),l&&(0,d.jsx)(g,{label:j(k?"diffViewer.imageAfter":"diffViewer.imageAdded"),labelClassName:"text-green-11",src:c,node:i,alt:`${a} (after)`})]}):(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:j("diffViewer.imageUnavailable")})]})}},88214:(a,b,c)=>{"use strict";c.d(b,{n:()=>e});var d=c(23734);let e={SessionChange:(0,d.R)("session-change"),ViewChange:(0,d.R)("view-change"),OpenNote:(0,d.R)("open-note"),LangChange:(0,d.R)("lang-change"),TabAdd:(0,d.R)("tab-add"),TabClose:(0,d.R)("tab-close"),SwitchSession:(0,d.R)("switch-session"),ProjectChange:(0,d.R)("project-change"),OpenProject:(0,d.R)("open-project"),SessionComplete:(0,d.R)("session-complete"),OpenTokenStats:(0,d.R)("open-token-stats"),PinnedSessionsChanged:(0,d.R)("pinned-sessions-changed"),ScheduledTasksChanged:(0,d.R)("scheduled-tasks-changed"),ScreenshotPrepare:(0,d.R)("screenshot-prepare"),ScreenshotDone:(0,d.R)("screenshot-done")}},89719:(a,b,c)=>{"use strict";function d(a,b){let c,d=document.caretRangeFromPoint(a.clientX,a.clientY);if(!d||!b.contains(d.startContainer))return 1;let e=d.startContainer,f=d.startOffset,g=document.createTreeWalker(b,NodeFilter.SHOW_TEXT),h=1;for(;c=g.nextNode();){if(c===e){h+=f;break}h+=c.textContent?.length||0}return h}function e(a,b){if(0!==a.buttons)return null;let c=window.getSelection();if(c&&!c.isCollapsed)return null;let e=a.target;if("SPAN"!==e.tagName||!e.style.color)return null;let f=e.getBoundingClientRect();return{column:d(a,b),rect:{x:f.left,y:f.bottom+4}}}c.d(b,{A:()=>e,j:()=>d})},89800:(a,b,c)=>{"use strict";c.d(b,{$:()=>i,BC:()=>j,Tu:()=>l,lb:()=>h,tj:()=>m,vv:()=>k});var d=c(79606),e=c(71192);let f=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`);return await c.json()},catch:c=>new e.uV({message:`${b?.method??"GET"} ${a} failed`,cause:c})}),g=(a,b)=>d.tryPromise({try:async()=>{let c=await fetch(a,b);if(!c.ok)throw Error(`HTTP ${c.status}`)},catch:c=>new e.uV({message:`${b.method} ${a} failed`,cause:c})}),h=(a,b)=>f(`/api/comments?cwd=${encodeURIComponent(a)}${b?`&filePath=${encodeURIComponent(b)}`:""}`),i=a=>f(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`),j=a=>f("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),k=(a,b,c)=>f("/api/comments",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,id:b,content:c})}),l=(a,b)=>g(`/api/comments?cwd=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"}),m=a=>g(`/api/comments?cwd=${encodeURIComponent(a)}&all=true`,{method:"DELETE"})},90031:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{s:()=>m});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(7833),j=c(19593),k=c(55287),l=a([k]);function m({filePath:a,content:b,onClose:c,zClassName:d="z-50"}){let{t:l}=(0,g.Bd)(),[n,o]=(0,f.useState)("table");return(0,e.jsx)(h.ZL,{children:(0,e.jsx)("div",{className:`fixed inset-0 ${d} flex items-center justify-center bg-scrim p-0 md:p-4`,onClick:c,children:(0,e.jsxs)("div",{className:"bg-card shadow-lv3 w-full h-full rounded-none md:max-w-[90%] md:h-[90vh] md:rounded-lg flex flex-col relative overflow-hidden",onClick:a=>a.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("span",{className:"text-sm text-muted-foreground truncate min-w-0 flex-1 cursor-pointer hover:text-foreground transition-colors",style:{direction:"rtl",textAlign:"left"},"data-tooltip":a,onClick:()=>{navigator.clipboard.writeText(a),(0,i.oR)(l("common.copiedPath"))},children:["",a]}),(0,e.jsx)("div",{className:"flex items-center gap-1 bg-accent rounded p-0.5 flex-shrink-0",children:["table","raw"].map(a=>(0,e.jsx)("button",{onClick:()=>o(a),className:`px-2 py-0.5 text-xs rounded transition-colors ${n===a?"bg-card text-foreground shadow-lv1":"text-muted-foreground hover:text-foreground"}`,children:l(`csv.${a}`)},a))}),(0,e.jsx)("button",{onClick:c,className:"text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-hover transition-colors flex-shrink-0",children:"✕"})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:"table"===n?(0,e.jsx)(j.C0,{content:b,filePath:a,className:"h-full"}):(0,e.jsx)(k.Cv,{content:b,filePath:a,showLineNumbers:!0,showSearch:!0,className:"h-full"})})]})})})}k=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},91579:(a,b,c)=>{"use strict";c.d(b,{$3:()=>l,Cm:()=>k,Ff:()=>p,Gw:()=>o,RP:()=>m,Un:()=>n,zL:()=>j});var d=c(208),e=c(79606),f=c(33281),g=c(71192),h=c(89800);let i=new Set;function j(a){return i.add(a),()=>i.delete(a)}function k(){i.forEach(a=>a())}async function l(a){let b=await f.t4.runPromiseExit((0,h.lb)(a));if("Success"!==b._tag)throw Error("Failed to fetch comments");let c=b.value.comments??[];if(0===c.length)return[];let d=new Map;for(let a of c)a.selectedText||(d.has(a.filePath)||d.set(a.filePath,[]),d.get(a.filePath).push(a));let i=new Map;await Promise.all(Array.from(d.keys()).map(async b=>{let c=await f.t4.runPromiseExit(e.tryPromise({try:async()=>{let c=await fetch(`/api/files/text?cwd=${encodeURIComponent(a)}&path=${encodeURIComponent(b)}`);return c.ok?await c.json():null},catch:a=>new g.uV({message:`read file text ${b} failed`,cause:a})}));"Success"===c._tag&&c.value&&"string"==typeof c.value.content?i.set(b,c.value.content.split("\n")):"Failure"===c._tag&&console.error(`Failed to read file ${b}:`,c.cause)}));let j=[];for(let a of c){if(a.selectedText){j.push({...a,codeContent:a.selectedText});continue}let b=i.get(a.filePath),c="";if(b){let d=Math.max(0,a.startLine-1),e=Math.min(b.length,a.endLine);c=b.slice(d,e).join("\n")}j.push({...a,codeContent:c})}return j}async function m(a){let b=await f.t4.runPromiseExit((0,h.tj)(a));return"Success"===b._tag?(k(),!0):(console.error("Failed to clear comments:",b.cause),!1)}let n="__chat__";function o(a,b){let c=a.filter(a=>a.filePath===n),e=a.filter(a=>a.filePath!==n),f=[];for(let a of(e.length>0&&(f.push(`${d.A.t("comments.codeRef")}`,""),e.forEach((a,b)=>{let c=a.startLine>0||a.endLine>0?`:${a.startLine}-${a.endLine}`:"";f.push(`[${b+1}] ${a.filePath}${c}`),f.push("```"),f.push(a.codeContent),f.push("```"),a.note&&f.push(d.A.t("comments.note",{content:a.note})),f.push("")})),c)){let b=a.codeContent.split("\n").map(a=>`> ${a}`).join("\n");f.push(b),a.note&&f.push(a.note),f.push("")}if(b.trim()){for(;f.length>0&&""===f[f.length-1];)f.pop();f.push(b.trim())}return f.join("\n").trim()}function p(a,b,c){a(o([b],c))}},91975:(a,b,c)=>{"use strict";c.d(b,{t:()=>h});var d=c(48249),e=c(67484),f=c(36043);let g=96/72;function h({cwd:a,path:b,refreshKey:c}){let k=(0,e.useRef)(null),[l,m]=(0,e.useState)({kind:"loading"}),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(0),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(0),[v,w]=(0,e.useState)({kind:"auto"}),[x,y]=(0,e.useState)(1),[z,A]=(0,e.useState)(!0),B=(0,e.useMemo)(()=>r?.length?Math.max(...r.map(a=>a.w)):0,[r]),C=Math.min(B>0&&t>0?t/B:g,g),D="auto"===v.kind?C:v.factor*g,E=Math.round(D/g*100),F=(0,e.useMemo)(()=>r?r.map(a=>a.h*D+16):[],[r,D]),G=B*D,H=(0,e.useRef)(1);H.current=C/g;let I=(0,e.useRef)(F);I.current=F;let J=(0,f.Te)({count:p,getScrollElement:()=>k.current,estimateSize:a=>I.current[a]??0,overscan:2}),K=(0,e.useCallback)(()=>{let a=k.current;if(!a||0===p)return;let b=a.scrollTop,c=J.getVirtualItems().find(a=>a.end>b);y((c?c.index:p-1)+1)},[J,p]),L=(0,e.useCallback)(a=>{w(b=>({kind:"fixed",factor:Math.min(4,Math.max(.25,("auto"===b.kind?H.current:b.factor)*a))}))},[]),M=(0,e.useCallback)(()=>L(1.2),[L]),N=(0,e.useCallback)(()=>L(.8333333333333334),[L]),O=(0,e.useCallback)(()=>w({kind:"auto"}),[]),P=(0,e.useCallback)(()=>A(a=>!a),[]),Q=(0,e.useCallback)(a=>{J.scrollToIndex(a,{align:"start"}),y(a+1)},[J]),R=J.getVirtualItems(),S=J.getTotalSize(),T=(0,e.useMemo)(()=>(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border text-muted-foreground text-xs select-none",children:[(0,d.jsx)("button",{onClick:P,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors ${z?"text-foreground":""}`,title:z?"Hide thumbnails":"Show thumbnails","aria-label":"Toggle thumbnails",children:(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,d.jsx)("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),(0,d.jsx)("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),(0,d.jsx)("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]})}),(0,d.jsx)("span",{className:"tabular-nums",children:p>0?`${x} / ${p}`:"—"}),(0,d.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:N,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom out","aria-label":"Zoom out",children:"−"}),(0,d.jsxs)("button",{onClick:O,className:`px-1.5 py-0.5 rounded hover:bg-hover transition-colors tabular-nums min-w-[3.5rem] ${"auto"===v.kind?"":"text-foreground"}`,title:"Reset to automatic zoom",children:[E,"%"]}),(0,d.jsx)("button",{onClick:M,className:"px-1.5 py-0.5 rounded hover:bg-hover transition-colors",title:"Zoom in","aria-label":"Zoom in",children:"+"})]})]}),[p,x,E,v.kind,M,N,O,z,P]);return"error"===l.kind?(0,d.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[T,(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,d.jsx)("div",{className:"text-sm text-red-11",children:l.message})})]}):(0,d.jsxs)("div",{className:"h-full flex flex-col bg-secondary",children:[T,(0,d.jsxs)("div",{className:"flex-1 flex min-h-0",children:[z&&n&&r&&(0,d.jsx)(i,{doc:n,numPages:p,sizes:r,maxPageW:B,currentPage:x,onSelect:Q}),(0,d.jsx)("div",{ref:k,onScroll:K,className:"flex-1 overflow-auto px-4 py-4",children:"loading"!==l.kind&&n&&r&&!(G<=0)?(0,d.jsx)("div",{style:{height:S,width:Math.max(G,t),position:"relative"},children:R.map(a=>(0,d.jsx)("div",{"data-index":a.index,className:"absolute left-0 top-0 w-full flex justify-center",style:{transform:`translateY(${a.start}px)`,paddingBottom:16},children:(0,d.jsx)(j,{doc:n,pageNumber:a.index+1,scale:D,width:r[a.index].w*D,height:r[a.index].h*D})},a.key))}):(0,d.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,d.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})})})]})]})}function i({doc:a,numPages:b,sizes:c,maxPageW:g,currentPage:h,onSelect:k}){let l=(0,e.useRef)(null),m=g>0?100/g:0,n=(0,e.useMemo)(()=>c.map(a=>a.h*m+18+12),[c,m]),o=(0,e.useRef)(n);o.current=n;let p=(0,f.Te)({count:b,getScrollElement:()=>l.current,estimateSize:a=>o.current[a]??0,overscan:3}),q=p.getVirtualItems();return(0,d.jsx)("div",{ref:l,className:"shrink-0 overflow-auto border-r border-border py-2",style:{width:132},children:(0,d.jsx)("div",{style:{height:p.getTotalSize(),width:"100%",position:"relative"},children:q.map(b=>{let e=h===b.index+1;return(0,d.jsxs)("div",{className:"absolute left-0 top-0 w-full flex flex-col items-center",style:{transform:`translateY(${b.start}px)`,paddingBottom:12},children:[(0,d.jsx)("button",{onClick:()=>k(b.index),className:`rounded-sm overflow-hidden transition-shadow ${e?"ring-2 ring-brand":"ring-1 ring-border hover:ring-muted-foreground"}`,title:`Page ${b.index+1}`,"aria-label":`Go to page ${b.index+1}`,children:(0,d.jsx)(j,{doc:a,pageNumber:b.index+1,scale:m,width:c[b.index].w*m,height:c[b.index].h*m})}),(0,d.jsx)("span",{className:`mt-0.5 text-[11px] tabular-nums leading-none ${e?"text-foreground font-medium":"text-muted-foreground"}`,style:{height:18},children:b.index+1})]},b.key)})})})}function j({doc:a,pageNumber:b,scale:c,width:f,height:g}){let h=(0,e.useRef)(null);return(0,d.jsx)("div",{className:"bg-white shadow-lv2",style:{width:f,height:g},children:(0,d.jsx)("canvas",{ref:h,className:"block"})})}},92451:(a,b,c)=>{"use strict";c.d(b,{U:()=>g});var d=c(48249),e=c(67484),f=c(19545);function g({editor:a,query:b,position:c,onClose:h}){let[i,j]=(0,e.useState)(0),k=(0,e.useRef)(null),l=(0,f.Qe)().filter(a=>a.label.toLowerCase().includes(b.toLowerCase())||a.description.toLowerCase().includes(b.toLowerCase()));return 0===l.length?null:(0,d.jsx)("div",{ref:k,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lv2 py-1 w-56 max-h-64 overflow-y-auto",style:{top:c.top,left:c.left},children:l.map((c,e)=>(0,d.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${e===i?"bg-accent text-foreground":"text-muted-foreground hover:bg-hover hover:text-foreground"}`,onClick:()=>{a.chain().focus().deleteRange({from:a.state.selection.from-b.length-1,to:a.state.selection.from}).run(),c.action(a),h()},onMouseEnter:()=>j(e),children:[(0,d.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:c.icon}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-medium",children:c.label}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:c.description})]})]},c.label))})}},92608:(a,b,c)=>{"use strict";c.d(b,{ShareReviewToggle:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(7833),h=c(33281),i=c(83120);function j({content:a,sourceFile:b}){let c,k,l,m,n,{t:o}=(0,f.Bd)(),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(!0),[t,u]=(0,e.useState)(!1),v=p?.active===!0,w=(0,e.useCallback)(async()=>{u(!0);let c=b.split("/").pop()||b,d=await h.t4.runPromiseExit((0,i.bx)({title:c,content:a,sourceFile:b}));if("Success"!==d._tag||!d.value.review){(0,g.oR)(o("toast.reviewCreateFailed"),"error"),u(!1);return}let e=d.value.review;q({id:e.id,active:!0,updatedAt:e.updatedAt||e.createdAt});let f=await h.t4.runPromiseExit((0,i._c)()),j="Success"===f._tag&&f.value.shareBase?`${f.value.shareBase}/review/${e.id}`:`${window.location.origin}/review/${e.id}`;try{await navigator.clipboard.writeText(j)}catch{}(0,g.oR)(e.existing?o("toast.reviewUpdated"):o("toast.reviewCreated"),"success"),u(!1)},[a,b,o]),x=(0,e.useCallback)(async()=>{p&&(u(!0),"Success"===(await h.t4.runPromiseExit((0,i.Gm)(p.id,{active:!1})))._tag?(q(a=>a?{...a,active:!1}:null),(0,g.oR)(o("toast.sharingClosed"),"success")):(0,g.oR)(o("toast.sharingCloseFailed"),"error"),u(!1))},[p,o]),y=(0,e.useCallback)(()=>{t||(v?x():w())},[t,v,w,x]),z=(0,e.useCallback)(()=>{p&&window.open(`${window.location.origin}/review/${p.id}`,"_blank")},[p]);return r?null:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:y,disabled:t,className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${t?"opacity-50 cursor-wait":"cursor-pointer"} ${v?"bg-green-500":"bg-muted-foreground/30"}`,title:v?o("review.closeSharing"):o("review.enableSharing"),children:(0,d.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white transition-transform ${v?"translate-x-3.5":"translate-x-0.5"}`})}),(0,d.jsx)("span",{className:`text-[11px] ${v?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,children:v?o("review.sharing"):o("review.notShared")}),v&&p&&p.updatedAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(k=String((c=new Date(p.updatedAt)).getMonth()+1).padStart(2,"0"),l=String(c.getDate()).padStart(2,"0"),m=String(c.getHours()).padStart(2,"0"),n=String(c.getMinutes()).padStart(2,"0"),`${k}-${l} ${m}:${n}`)}),(0,d.jsx)("button",{onClick:z,className:"text-[11px] text-brand hover:underline",children:o("review.view")})]})]})}},92701:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{K:()=>o});var e=c(48249),f=c(67484),g=c(44384),h=c(44256),i=c(33281),j=c(81206),k=c(23700),l=a([k]);function m(a){return a?a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a):"0"}function n(a){if(!a)return"–";let b=Math.round(a/1e3);if(b<60)return`${b}s`;let c=Math.floor(b/60);return`${c}m${b%60}s`}k=(l.then?(await l)():l)[0];let q={done:"text-green-9",running:"text-brand",queued:"text-muted-foreground",error:"text-red-9",failed:"text-red-9"};function o({cwd:a,sessionId:b,runId:c,isRunning:d,onClose:l}){let{t:q}=(0,g.Bd)(),[r,s]=(0,f.useState)(null),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useRef)(void 0),y=d||null!=r&&"completed"!==r.status&&"failed"!==r.status;(0,f.useCallback)(async()=>{let d=await i.t4.runPromiseExit((0,j.z)({cwd:a,sessionId:b,workflowId:c,ifFingerprint:x.current}));if(u(!0),"Success"!==d._tag||!d.value)return;let e=d.value;e.fingerprint&&(x.current=e.fingerprint),!e.notModified&&e.workflow&&s(e.workflow)},[a,b,c]);let z=[];if(r?.agents){let a=new Map;for(let b of r.agents){let c=b.phaseTitle||q("chat.workflowUngrouped");a.has(c)||a.set(c,[]),a.get(c).push(b)}for(let[b,c]of a)z.push({title:b,agents:c})}let A=r?[r.workflowName,r.status,`${r.agentCount??r.agents?.length??0} ${q("chat.workflowAgents")}`,`${m(r.totalTokens)} tok`,n(r.durationMs)].filter(Boolean).join(" \xb7 "):"";return(0,e.jsxs)(h.ZL,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4",onClick:l,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\uDDE9"}),(0,e.jsx)("span",{className:"font-medium text-sm text-foreground flex-shrink-0",children:q("chat.workflowRun")}),A&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate flex-1 min-w-0","data-tooltip":A,children:A}),(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[y&&(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("button",{onClick:l,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-hover transition-colors",title:q("common.close"),children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:null===r?(0,e.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:q(t?"chat.workflowEmpty":"common.loading")}):(0,e.jsxs)(e.Fragment,{children:[r.summary&&(0,e.jsx)("div",{className:"mb-3 text-xs text-muted-foreground whitespace-pre-wrap",children:r.summary}),z.map(a=>(0,e.jsxs)(f.Fragment,{children:[(0,e.jsx)("div",{className:"text-xs font-semibold text-foreground/80 mt-3 mb-1 sticky top-0 bg-card py-1",children:a.title}),a.agents.map(a=>(0,e.jsx)(p,{agent:a,onOpen:()=>a.agentId&&w({runId:c,agentId:a.agentId,label:a.label,running:"done"!==a.state&&y})},`${a.index}-${a.agentId}`))]},a.title))]})})]})}),v&&(0,e.jsx)(k.f,{cwd:a,sessionId:b,workflowRef:v,onClose:()=>w(null)})]})}function p({agent:a,onOpen:b}){let{t:c}=(0,g.Bd)(),[d,h]=(0,f.useState)(!1),i=a.state&&q[a.state]||"text-muted-foreground",j=a.resultPreview||a.promptPreview||"";return(0,e.jsxs)("div",{className:"border border-border rounded-md mb-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,e.jsx)("button",{onClick:()=>h(a=>!a),className:"text-foreground-subtle text-xs flex-shrink-0",title:c(d?"chat.collapse":"chat.expand"),children:d?"▲":"▼"}),(0,e.jsx)("span",{className:"text-xs text-foreground truncate flex-1 min-w-0","data-tooltip":a.label||"",children:a.label||a.agentId}),(0,e.jsx)("span",{className:`text-[10px] flex-shrink-0 ${i}`,children:a.state}),(0,e.jsxs)("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:[m(a.tokens)," tok \xb7 ",n(a.durationMs)]}),a.agentId&&(0,e.jsx)("span",{role:"button",tabIndex:0,onClick:b,onKeyDown:a=>{("Enter"===a.key||" "===a.key)&&b()},className:"text-xs text-brand hover:text-teal-10 cursor-pointer flex-shrink-0",title:c("chat.subagentViewTitle"),children:c("chat.workflowViewAgent")})]}),d&&j&&(0,e.jsx)("pre",{className:"text-[11px] bg-secondary px-2 py-1.5 rounded-b overflow-x-auto max-h-32 overflow-y-auto text-muted-foreground whitespace-pre-wrap border-t border-border",children:j})]})}d()}catch(a){d(a)}})},93448:(a,b,c)=>{"use strict";c.d(b,{TabManagerTopBar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call TabManagerTopBar() from the server but TabManagerTopBar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/packages/feature/workspace/src/client/TabManagerTopBar.tsx","TabManagerTopBar")},94192:(a,b,c)=>{"use strict";c.d(b,{R8:()=>i,c0:()=>k,fY:()=>j,gT:()=>l});var d=c(48249),e=c(67484);let f=["agent","explorer","console"],g={agent:"AGENT",explorer:"EXPLORER",console:"CONSOLE"},h=(0,e.createContext)(null);function i(){let a=(0,e.useContext)(h);if(!a)throw Error("useSwipeContext must be used within SwipeableViewContainer");return a}function j({activeView:a,onViewChange:b,children:c}){(0,e.useRef)(null),(0,e.useRef)(!1),(0,e.useRef)(0);let[g,i]=(0,e.useState)(0),[k,l]=(0,e.useState)(!1);f.indexOf(a),f.length;let[m,n]=(0,e.useState)(!1),o={activeView:a,onViewChange:b,dragOffset:(()=>{if(!m)return 0;let a=window.innerWidth;return a?g/a:0})(),isDragging:m&&k};return(0,d.jsx)(h.Provider,{value:o,children:c})}function k({children:a}){let b,c,{activeView:g,dragOffset:h,isDragging:j}=i(),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=f.indexOf(g),o=f.length;return(0,d.jsx)("div",{ref:l,className:"flex-1 overflow-hidden relative",style:{overscrollBehaviorX:"none"},children:(0,d.jsx)("div",{ref:m,className:j?"flex":"flex transition-transform duration-100 ease-out",style:{position:"absolute",top:"0px",bottom:"0px",left:"0px",width:`${100*f.length}%`,transform:(b=h/o*100,c=-(100/o*n)+(Number.isFinite(b)?b:0),`translateX(${c}%)`)},children:a})})}function l(){let{activeView:a,onViewChange:b,dragOffset:c,isDragging:h}=i(),j=(0,e.useRef)(null),k=(0,e.useRef)([]),[l,m]=(0,e.useState)({left:0,width:0}),n=f.indexOf(a),o=Number.isFinite(c)?c:0,p=Math.round(Math.max(0,Math.min(f.length-1,n-o)));return(0,d.jsxs)("div",{ref:j,className:"relative flex gap-4",children:[f.map((a,c)=>(0,d.jsx)("button",{ref:a=>{k.current[c]=a},onClick:()=>b(a),className:`px-4 py-1 text-sm font-medium transition-colors ${p===c?"text-brand":"text-muted-foreground hover:text-foreground"}`,children:g[a]},a)),(0,d.jsx)("div",{className:`absolute bottom-0 h-0.5 bg-brand ${h?"":"transition-all duration-100 ease-out"}`,style:{left:l.left,width:l.width}})]})}},94239:(a,b,c)=>{"use strict";c.d(b,{c:()=>j});var d=c(48249),e=c(67484),f=c(44384),g=c(61591),h=c(44256);function i({path:a,matchedIndices:b}){let c=(0,e.useMemo)(()=>new Set(b),[b]),f=a.lastIndexOf("/"),g=f>=0?a.slice(0,f+1):"",h=f>=0?a.slice(f+1):a,j=(a,b,e)=>{let f=[],g="",h=!1;for(let e=0;e<a.length;e++){let i=b+e,j=c.has(i);j!==h&&g&&(f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-${e}`):(0,d.jsx)("span",{children:g},`${b}-${e}`)),g=""),h=j,g+=a[e]}return g&&f.push(h?(0,d.jsx)("span",{className:"text-brand font-medium",children:g},`${b}-end`):(0,d.jsx)("span",{children:g},`${b}-end`)),(0,d.jsx)("span",{className:e,children:f})};return(0,d.jsxs)("span",{className:"truncate",children:[g&&j(g,0,"text-muted-foreground"),j(h,g.length,"text-foreground")]})}function j({files:a,fileIndex:b,recentFiles:c,onSelectFile:k,onClose:l}){let{t:m}=(0,f.Bd)(),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(0),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=(0,e.useMemo)(()=>{let c,d;return b??(c=[],(d=a=>{for(let b of a)b.isDirectory&&b.children?d(b.children):b.isDirectory||c.push(b.path)})(a),c)},[b,a]),u=(0,e.useMemo)(()=>{if(!n.trim()){let a=new Set(c);return[...c.map(a=>({path:a,score:0,matchedIndices:[]})),...t.filter(b=>!a.has(b)).slice(0,50).map(a=>({path:a,score:0,matchedIndices:[]}))]}let a=[];for(let b of t){let d=function(a,b){let c=a.toLowerCase(),d=b.toLowerCase(),e=[],f=0,g=0,h=-1;for(let i=0;i<c.length&&f<d.length;i++)c[i]===d[f]&&(e.push(i),h===i-1&&(g+=5),(0===i||"/"===a[i-1]||"."===a[i-1]||"-"===a[i-1]||"_"===a[i-1])&&(g+=10),i>a.lastIndexOf("/")&&(g+=3),a[i]===b[f]&&(g+=1),h=i,f++);return f<d.length?null:(g-=.1*a.length,{path:a,score:g,matchedIndices:e})}(b,n.trim());d&&(c.includes(b)&&(d.score+=20),a.push(d))}return a.sort((a,b)=>b.score-a.score),a.slice(0,50)},[n,t,c]),v=(0,e.useCallback)(a=>{o(a),q(0)},[]),w=(0,e.useCallback)(a=>{k(a),l()},[k,l]),x=(0,e.useCallback)(a=>{if(!a.nativeEvent.isComposing)switch(a.key){case"ArrowDown":a.preventDefault(),q(a=>Math.min(a+1,u.length-1));break;case"ArrowUp":a.preventDefault(),q(a=>Math.max(a-1,0));break;case"Enter":a.preventDefault(),u[p]&&w(u[p].path);break;case"Escape":a.preventDefault(),l()}},[u,p,w,l]);return(0,d.jsx)(h.ZL,{children:(0,d.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:l,children:(0,d.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-lv3 overflow-hidden flex flex-col",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,d.jsx)("input",{ref:r,value:n,onChange:a=>v(a.target.value),onKeyDown:x,placeholder:m("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,d.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,d.jsx)("div",{ref:s,className:"flex-1 overflow-y-auto py-1",children:0===u.length?(0,d.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:m("quickFileOpen.noMatch")}):u.map((a,b)=>(0,d.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${b===p?"bg-brand/15 text-foreground":"hover:bg-hover text-foreground"}`,"data-tooltip":a.path,onClick:()=>w(a.path),children:[(0,d.jsx)(g.o,{name:a.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,d.jsx)(i,{path:a.path,matchedIndices:a.matchedIndices}),!n.trim()&&c.includes(a.path)&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:m("quickFileOpen.recent")})]},a.path))}),(0,d.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",m("quickFileOpen.selectHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",m("quickFileOpen.openHint")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",m("quickFileOpen.closeHint")]})]})]})})})}},94308:(a,b,c)=>{"use strict";c.d(b,{e:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({branches:a,selectedBranch:b,onSelect:c,isLoading:h,pinnedBranches:i=[]}){let{t:j}=(0,f.Bd)(),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,e.useRef)(null),p=(0,e.useRef)(null),q=m.toLowerCase(),r=new Set([...a?.local||[],...a?.remote||[]]),s=i.filter(a=>r.has(a)&&a.toLowerCase().includes(q)),t=new Set(s),u=a?.local.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],v=a?.remote.filter(a=>!t.has(a)&&a.toLowerCase().includes(q))||[],w=a=>{c(a),l(!1),n("")};return(0,d.jsxs)("div",{className:"relative",ref:o,children:[(0,d.jsxs)("button",{onClick:()=>l(!k),disabled:h,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,d.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),b||j("git.selectBranch"),a?.current===b&&(0,d.jsxs)("span",{className:"text-xs text-green-11",children:["(",j("git.currentBranch"),")"]})]}),(0,d.jsx)("svg",{className:`w-4 h-4 text-foreground-subtle transition-transform ${k?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),k&&(0,d.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lv2 max-h-80 flex flex-col",children:[(0,d.jsx)("div",{className:"p-2 border-b border-border",children:(0,d.jsx)("input",{ref:p,type:"text",value:m,onChange:a=>n(a.target.value),placeholder:j("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground"})}),(0,d.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length>0&&s.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${c}`)),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:j("git.localBranches")}),u.map(c=>(0,d.jsxs)("div",{onClick:()=>w(c),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${c===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:c}),c===a?.current&&(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:j("git.currentBranch")}),c===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},c))]}),v.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-popover sticky top-0",children:j("git.remoteBranches")}),v.map(a=>(0,d.jsxs)("div",{onClick:()=>w(a),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${a===b?"bg-brand/10 text-brand":"hover:bg-hover text-foreground"}`,children:[(0,d.jsx)("span",{className:"truncate flex-1",children:a}),a===b&&(0,d.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},a))]}),0===s.length&&0===u.length&&0===v.length&&(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:j("git.noMatchingBranches")})]})]})]})}},95401:(a,b,c)=>{"use strict";c.d(b,{m:()=>k});var d=c(48249),e=c(67484),f=c(44256),g=c(33281),h=c(63565),i=c(41224);function j(a){return"env"===a?"from env var":"default"===a?"default":null}function k({currentModel:a,onModelChange:b}){let[c,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)("default"),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(""),[I,J]=(0,e.useState)("default"),[K,L]=(0,e.useState)(""),[M,N]=(0,e.useState)(!1),O=(0,e.useRef)(null),P=(0,e.useRef)(null),Q=(0,e.useRef)(null),[R,S]=(0,e.useState)({top:0,left:0}),T=(0,f.F2)(),U=(0,e.useCallback)(async()=>{p(!0),r(null);let a=await g.t4.runPromiseExit((0,i.qD)(()=>t(!0)));if(t(!1),"Failure"===a._tag)r("Connection error");else{let b=a.value;switch(b._tag){case"ok":n(b.models);break;case"not-installed":case"error":r(b.message);break;case"not-running":r("Ollama is not running")}}p(!1)},[]),V=(0,e.useCallback)(a=>{B(a.baseUrl),D(a.baseUrlSource),F(a.hasKey),H(a.maskedKey),J(a.keySource),L(""),N(!1)},[]),W=(0,e.useCallback)(async()=>{v(!0),z(null);let a=await g.t4.runPromiseExit((0,i.F4)());"Failure"===a._tag?z("Failed to load config"):V(a.value),v(!1)},[V]),X=async()=>{x(!0),z(null);let a=await g.t4.runPromiseExit((0,i.yS)({baseUrl:A}));"Failure"===a._tag?z("Save failed"):(V(a.value),await U()),x(!1)},Y=async()=>{let a=K.trim();if(!a)return;x(!0),z(null);let b=await g.t4.runPromiseExit((0,i.yS)({apiKey:a}));"Failure"===b._tag?z("Save failed"):V(b.value),x(!1)},Z=async()=>{x(!0),z(null);let a=await g.t4.runPromiseExit((0,i.yS)({apiKey:""}));"Failure"===a._tag?z("Clear failed"):V(a.value),x(!1)},$=a?a.replace(/:latest$/,""):"Select model",_=j(C),aa=j(I),ab=c?(0,d.jsx)(f.ZL,{children:(0,d.jsxs)("div",{ref:P,className:`${h.ys} min-w-[300px]`,style:{top:R.top,left:R.left},children:[(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Server URL"}),_&&!u&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:_})]}),u?(0,d.jsxs)("div",{className:"flex items-center gap-2 py-1 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)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:A,onChange:a=>B(a.target.value),onKeyDown:a=>{"Enter"===a.key&&X()},placeholder:"http://127.0.0.1:11434",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${h.Fx}`}),(0,d.jsx)("button",{onClick:X,disabled:w,className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${h.$T}`,children:w?"...":"Save"})]})]}),(0,d.jsxs)("div",{className:"px-3 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"API Key"}),aa&&E&&!u&&(0,d.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:aa})]}),u?null:E&&!M?(0,d.jsxs)("div",{className:"flex items-center gap-2",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:G}),(0,d.jsx)("button",{onClick:()=>{N(!0),L(""),setTimeout(()=>Q.current?.focus(),0)},className:"text-[11px] px-2 py-1 rounded bg-secondary hover:bg-hover text-foreground transition-colors",disabled:w,children:"Edit"}),(0,d.jsx)("button",{onClick:Z,className:"text-[11px] px-2 py-1 rounded text-red-11 hover:bg-red-500/10 transition-colors",disabled:w,children:"Clear"})]}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{ref:Q,type:"password",value:K,onChange:a=>L(a.target.value),onKeyDown:a=>{"Enter"===a.key&&Y()},placeholder:"optional — for authenticated servers",spellCheck:!1,className:`flex-1 min-w-0 text-xs px-2 py-1 rounded bg-secondary text-foreground border border-border focus:outline-none font-mono ${h.Fx}`}),(0,d.jsx)("button",{onClick:Y,disabled:w||!K.trim(),className:`text-[11px] px-2 py-1 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${h.$T}`,children:w?"...":"Save"}),E&&(0,d.jsx)("button",{onClick:()=>{N(!1),L("")},className:"text-[11px] px-2 py-1 rounded text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]}),y&&(0,d.jsx)("div",{className:"mt-1 text-[11px] text-red-11",children:y})]}),(0,d.jsx)("div",{className:"my-1 border-t border-border"}),(0,d.jsx)("div",{className:"px-3 pt-1 pb-0.5",children:(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Model"})}),(0,d.jsx)("div",{className:"max-h-[240px] overflow-y-auto",children:o||s?(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"}),s?"Starting Ollama...":"Loading models..."]}):q?(0,d.jsx)("div",{className:"px-3 py-2 text-xs text-red-11",children:q}):0===m.length?(0,d.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models found. Run ",(0,d.jsx)("code",{className:"bg-secondary px-1 rounded",children:"ollama pull <model>"})]}):m.map(c=>{var e;let f=c.name===a;return(0,d.jsxs)("button",{onClick:()=>{b(c.name),l(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs transition-colors ${f?h.yI:"text-foreground hover:bg-hover"}`,children:[(0,d.jsx)(h.hG,{selected:f}),(0,d.jsx)("span",{className:"truncate",children:c.name.replace(/:latest$/,"")}),(0,d.jsx)("span",{className:"ml-auto pl-2 text-muted-foreground flex-shrink-0",children:c.parameter_size||((e=c.size)<1e9?`${(e/1e6).toFixed(0)}M`:`${(e/1e9).toFixed(1)}G`)})]},c.name)})})]})}):null;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h.XY,{buttonRef:O,label:$,title:"Configure Ollama",onClick:()=>{if(!c){if(O.current){let a=O.current.getBoundingClientRect(),b=T?.getBoundingClientRect(),c=b?.left??0,d=b?.top??0;S({top:a.bottom+4-d,left:a.left-c})}W(),U()}l(a=>!a)},icon:(0,d.jsx)(h.eV,{engine:"ollama"}),testId:"ollama-config-picker"}),ab]})}},97572:(a,b,c)=>{"use strict";c.d(b,{g:()=>g,v:()=>f});var d=c(79606),e=c(71192);let f=d.tryPromise({try:async()=>{let a=await fetch("/api/projects");if(!a.ok)throw Error(`HTTP ${a.status}`);return await a.json()},catch:a=>new e.uV({message:"fetch /api/projects failed",cause:a})}),g=a=>d.tryPromise({try:async()=>{let b=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)});if(!b.ok)throw Error(`HTTP ${b.status}`)},catch:a=>new e.uV({message:"save /api/projects failed",cause:a})})},97951:(a,b,c)=>{"use strict";c.d(b,{R:()=>i,e:()=>j});var d=c(67484),e=c(85943),f=c(25414),g=c(208),h=c(29939);let i=[];function j(a,b,{sessionId:c,cwd:k,engine:l,planMode:m,noHistory:n,ollamaModel:o,engineModel:p,claudeModel:q,claudeEffort:r,claudeContextWindow:s,claudeFastMode:t,claudeThinking:u,codexModel:v,codexReasoningEffort:w,onSessionId:x,onFetchTitle:y,onRunComplete:z}){let[A,B]=(0,d.useState)(!1),[C,D]=(0,d.useState)(null),[E,F]=(0,d.useState)(null),[G,H]=(0,d.useState)(null),[I,J]=(0,d.useState)(null),[K,L]=(0,d.useState)(null),[M,N]=(0,d.useState)(i),O=(0,d.useRef)(null),[P,Q]=(0,d.useState)(null),R=(0,d.useRef)(P);R.current=P;let S=(0,d.useRef)(!1),T=(0,d.useRef)(z);T.current=z;let U=(0,d.useRef)(!1),V=(0,d.useRef)(null),W=(0,d.useRef)(c);W.current=c;let X=(0,d.useRef)(null),Y=(0,d.useRef)(null),Z=(0,d.useRef)(null),$=(0,d.useRef)(!1),_=(0,d.useRef)(!1),aa=(0,d.useRef)(0),ab=(0,d.useCallback)(()=>{let a=X.current;if(a&&a.text){let{messageId:c,text:d}=a;b(a=>(0,f.FM)(a,{type:"stream_event",event:{type:"content_block_delta",delta:{type:"text_delta",text:d}}},{engine:l,assistantId:c})),X.current={messageId:c,text:""}}Y.current=null},[b,l]),ac=(0,d.useCallback)(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),V.current&&(clearTimeout(V.current),V.current=null),ab(),b(f.fD),B(!1),F(null),H(null),N(i);let a=R.current,c=Z.current;a&&b(b=>b.map(b=>b.id===a.assistantId||b.id===c?{...b,isStreaming:!1}:b)),Q(null),T.current?.()},[ab,b]),ad=(0,d.useCallback)(()=>{let a=R.current;fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:W.current,runId:a?.runKey})}).catch(()=>{}),ac()},[ac]),ae=(0,d.useCallback)((a,c)=>{let d=a.type;if((0,f.Nn)(a))return;let h=a=>{if(S.current||"string"!=typeof a||!a)return;let b=(0,e.r)(a);F(a=>({outputTokens:(a?.outputTokens||0)+b}))};if("system"===d&&"init"===a.subtype){let c=a.session_id,d=$.current;if(x(c),W.current=c,d||(H(a=>a??Date.now()),F(null),S.current=!1),L(null),d){let a=`auto-asst-${++aa.current}`;Z.current=a,b(b=>[...b,{id:a,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runKey:R.current?.runKey,runId:R.current?.runId}])}_.current=!0;return}if("system"===d&&"background_tasks_changed"===a.subtype){let b=(a.tasks??[]).filter(a=>!a.ambient).map(a=>({task_id:a.task_id,description:a.description}));N(b.length?b:i);return}if(!(0,f.A7)(a)||(b(b=>(0,f.FM)(b,a,{engine:l,assistantId:c})),"task_notification"===a.subtype)){if("system"===d&&"task_notification"===a.subtype){if(!_.current){let c=a.status,d=a.summary||"",e=a.task_id,f=`<task-notification>
|
|
752
753
|
`+(e?`<task-id>${e}</task-id>
|
|
754
|
+
`:"")+(a.tool_use_id?`<tool-use-id>${a.tool_use_id}</tool-use-id>
|
|
753
755
|
`:"")+(c?`<status>${c}</status>
|
|
754
756
|
`:"")+(d?`<summary>${d}</summary>
|
|
755
757
|
`:"")+(a.output_file?`<output-file>${a.output_file}</output-file>
|
|
756
758
|
`:"")+"</task-notification>",g=`auto-tasknotif-${e||++aa.current}`;b(a=>[...a,{id:g,role:"system",content:d,systemEvent:{kind:"task-notification",...c?{status:c}:{},detail:f},runKey:R.current?.runKey}])}return}if("system"===d&&"api_retry"===a.subtype)return void L({attempt:a.attempt??0,maxRetries:a.max_retries??0,delayMs:a.retry_delay_ms??0,errorStatus:a.error_status,error:a.error});if("rate_limit_event"===d){let b=a.rate_limit_info;b&&J({status:b.status||"allowed",resetsAt:b.resetsAt,rateLimitType:b.rateLimitType,utilization:b.utilization,overageStatus:b.overageStatus,overageDisabledReason:b.overageDisabledReason,isUsingOverage:b.isUsingOverage,surpassedThreshold:b.surpassedThreshold});return}if("usage_update"===d){let b=a.output_tokens;if("number"==typeof b&&Number.isFinite(b)){S.current=!0;let a=Math.max(0,Math.round(b));F(b=>({outputTokens:Math.max(b?.outputTokens||0,a)}))}return}if("error"===d){let d=a.error||g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});L(null),Y.current&&(clearTimeout(Y.current),Y.current=null),ab(),b(a=>a.map(a=>a.id===c?{...a,content:a.content?`${a.content}
|
|
757
759
|
|
|
758
|
-
⚠️ ${d}`:`⚠️ ${d}`,isStreaming:!1}:a));return}if("stream_event"===d){L(a=>a?null:a);let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";h(a),X.current&&X.current.messageId===c?X.current.text+=a:X.current={messageId:c,text:a},Y.current||(Y.current=setTimeout(ab,50))}return}if("assistant"===d){let d=a.message?.content;if(Array.isArray(d))for(let a of d)a.text?h(a.text):a.name&&h(`${a.name} ${JSON.stringify(a.input??{})}`);b(b=>(0,f.F)(b,a,{engine:l,assistantId:c}))}if("user"===d){let d=a.message?.content;if(Array.isArray(d))for(let a of d)h("string"==typeof a.content?a.content:JSON.stringify(a.content??""));b(b=>(0,f.F)(b,a,{engine:l,assistantId:c}))}if("result"===d){_.current=!1,$.current=!0,L(null),Y.current&&(clearTimeout(Y.current),Y.current=null),ab();let d=W.current;d&&k&&b(a=>(2===a.length&&y(d),a));let e=a.usage,g=a.total_cost_usd;e&&D({inputTokens:e.input_tokens||0,outputTokens:e.output_tokens||0,cacheCreationInputTokens:e.cache_creation_input_tokens||0,cacheReadInputTokens:e.cache_read_input_tokens||0,totalCostUsd:g||0}),b(b=>(0,f.F)(b,a,{engine:l,assistantId:c}))}},[b,ab,x,y,k,l]);return(0,h.h)({url:P?`/ws/session-stream?sessionId=${encodeURIComponent(P.runKey)}`:"/ws/session-stream",enabled:!!P,onMessage:a=>{U.current=!0,V.current&&(clearTimeout(V.current),V.current=null);let c=R.current;if(c)if("run-snapshot"===a.type&&Array.isArray(a.events)){Y.current&&(clearTimeout(Y.current),Y.current=null),X.current=null,Z.current=c.assistantId,$.current=!1,_.current=!1,S.current=!1,F(null);let d="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let e of(null!==d&&(S.current=!0,F({outputTokens:d})),b(a=>a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("auto-")&&a.runKey===c.runKey)).map(a=>a.id===c.assistantId?{...a,content:"",toolCalls:[]}:a)),a.events))ae(e,Z.current??c.assistantId);a.status&&"running"!==a.status&&ac()}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type)return void ac();ae(a.message,Z.current??c.assistantId)}else"run-idle"===a.type&&ac()}}),{isLoading:A,tokenUsage:C,liveOutputTokens:E,runningStartedAt:G,rateLimitInfo:I,apiRetryInfo:K,backgroundTasks:M,handleSend:(0,d.useCallback)(async(a,c,d)=>{let e=d&&"permissionMode"in d?"plan"===d.permissionMode:m,f=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),h={id:`user-${Date.now()}`,role:"user",content:a,images:f};b(a=>[...a,h]),B(!0),F(null),S.current=!1,H(Date.now()),L(null),N(i);let j=function(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}(),x=`assistant-${Date.now()}`,y={id:x,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runId:j};b(a=>[...a,y]),Z.current=x,$.current=!1,_.current=!1;let z=!l||"claude"===l,A="deepseek"===l||"kimi"===l||"glm"===l,C="ollama"===l||A||z||"codex"===l;try{if("ollama"===l&&!o)throw Error("Please select an Ollama model first (click the model picker above)");let c="codex"===l?"/api/chat/codex":"kimi"===l?"/api/chat/kimi":"ollama"===l?"/api/chat/ollama":"deepseek"===l?"/api/chat/deepseek":"glm"===l?"/api/chat/glm":"/api/chat",d=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:W.current,runId:j,images:f,cwd:k,language:g.A.language,..."ollama"===l&&o&&{model:o},...A&&p&&{model:p},...z&&q&&{model:q},...z&&r&&{claudeEffort:r},...z&&s&&{claudeContextWindow:s},...z&&void 0!==t&&{claudeFastMode:t},...z&&void 0!==u&&{claudeThinking:u},..."codex"===l&&v&&{model:v},..."codex"===l&&w&&{codexReasoningEffort:w},...e&&z&&{permissionMode:"plan"},...C&&n&&{noHistory:!0}})});if(!d.ok){let a=await d.json().catch(()=>null);throw Error(a?.error||g.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let h=await d.json().catch(()=>({}));Q({runKey:h.runKey||j,assistantId:x,runId:j}),U.current=!1,V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{R.current&&!U.current&&(b(a=>a.map(a=>a.id!==x||a.content?a:{...a,content:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),ac())},15e3)}catch(c){console.error("Chat error:",c);let a=c instanceof Error?c.message:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});b(b=>b.map(b=>b.id===x?{...b,content:a,isStreaming:!1}:b)),B(!1),Q(null)}},[k,l,m,n,o,p,q,r,s,t,u,v,w,b,ac]),handleStop:ad,abortControllerRef:O}}},98356:(a,b,c)=>{"use strict";c.d(b,{T:()=>C});var d=c(48249),e=c(98051),f=c(38368),g=c(33972),h=c(10841),i=c(99773),j=c(36513);c(55583),c(87023);var k=c(50757),l=c(27454),m=c(37752),n=c(67484),o=c(64676),p=c(83768),q=c(15466),r=c(49216);function s(a){return{type:"tableCell",children:[{type:"text",value:a}]}}let t=[c(4014).A,function(){return a=>{let b=a.children;for(let a=0;a<b.length;a++){let c=b[a];if("yaml"!==c.type)continue;let d=null;try{let a=r.Ay.load(c.value??"");a&&"object"==typeof a&&!Array.isArray(a)&&(d=a)}catch{d=null}let e=d?Object.entries(d):[];if(0===e.length){b.splice(a,1),a--;continue}let f={type:"tableRow",children:[s("Field"),s("Value")]},g=e.map(([a,b])=>({type:"tableRow",children:[s(a),s(function(a){if(null==a)return"";if("string"==typeof a)return a.replace(/\s*\n\s*/g," ").trim();if("number"==typeof a||"boolean"==typeof a)return String(a);try{return JSON.stringify(a)}catch{return String(a)}}(b))]}));b[a]={type:"table",align:["left","left"],children:[f,...g]}}}}],u=[...t,f.A,g.A,h.jb],v=[...t,f.A,h.jb],w=[i.A,j.A],x=[i.A];function y(a){let b=[],c=a=>(b.push(a),` MASK${b.length-1} `);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/^(\|.+\|)$/gm,a=>/^\|[\s:|-]+\|$/.test(a)?a:a.replace(/`([^`]*)`/g,(a,b)=>b.includes("|")?"`"+b.replace(/\|/g,"\\|")+"`":a)).replace(/ MASK(\d+) /g,(a,c)=>b[+c])}function z(a){return a.replace(/\$(\d)/g,"\\$$1")}let A=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clippath","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan","use"]);function B(a){let b=[],c=a=>(b.push(a),`\u0000MASK${b.length-1}\u0000`);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/`[^`\n]+`/g,a=>c(a)).replace(/<\/?([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(a,b)=>{let c=b.toLowerCase();return A.has(c)||c.includes("-")?a:a.replace(/</g,"<").replace(/>/g,">")}).replace(/\u0000MASK(\d+)\u0000/g,(a,c)=>b[+c])}let C=(0,n.memo)(function({content:a,isUser:b=!1,isStreaming:c=!1,enableMath:f=!0,isDark:g,rehypePlugins:h,onLinkClick:i,basePath:j}){let r=(0,p.Ql)(),s=g??r?.resolvedTheme==="dark",t=(0,n.useRef)(null),A=(0,n.useMemo)(()=>({code({className:a,children:b,node:c,...e}){let f=/language-(\w+)/.exec(a||"");if(!("string"==typeof b||"number"==typeof b||Array.isArray(b)&&b.every(a=>"string"==typeof a||"number"==typeof a)))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let g=String(b);if(!f&&!a&&!g.includes("\n"))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let h=g.replace(/\n$/,""),i=f?.[1]||"text",j=Number(e["data-source-start"])||0,n=j?j+1:0,o=0;return(0,d.jsx)(k.A,{style:s?l.A:m.A,language:i,PreTag:"div",customStyle:{margin:"0.75rem 0",borderRadius:"0.375rem",fontSize:"0.875rem"},wrapLines:!0,lineProps:()=>{let a=n+o;return o++,{"data-source-start":a,"data-source-end":a,style:{display:"block"}}},children:h})},p:({children:a,node:b,...c})=>(0,d.jsx)("p",{className:"mb-3 last:mb-0",...c,children:a}),h1:({children:a,node:b,...c})=>(0,d.jsx)("h1",{className:"text-xl font-bold mb-3 mt-4 first:mt-0",...c,children:a}),h2:({children:a,node:b,...c})=>(0,d.jsx)("h2",{className:"text-lg font-bold mb-2 mt-3 first:mt-0",...c,children:a}),h3:({children:a,node:b,...c})=>(0,d.jsx)("h3",{className:"text-base font-bold mb-2 mt-3 first:mt-0",...c,children:a}),ul:({children:a,node:b,...c})=>(0,d.jsx)("ul",{className:"list-disc list-inside mb-3 space-y-1",...c,children:a}),ol:({children:a,node:b,...c})=>(0,d.jsx)("ol",{className:"list-decimal list-inside mb-3 space-y-1",...c,children:a}),li:({children:a,node:b,...c})=>(0,d.jsx)("li",{className:"leading-relaxed",...c,children:a}),blockquote:({children:a,node:b,...c})=>(0,d.jsx)("blockquote",{className:"border-l-4 border-border pl-4 my-3 italic text-muted-foreground",...c,children:a}),a:({href:a,children:b,node:c,...e})=>(0,d.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...e,onClick:b=>{if(a){if(a.startsWith("#")){(0,q.O)(t.current,a.slice(1))&&b.preventDefault();return}i?.(a)&&b.preventDefault()}},children:b}),table:({children:a,node:b,...c})=>(0,d.jsx)("div",{className:"overflow-x-auto my-3",...c,children:(0,d.jsx)("table",{className:"min-w-full border border-border",children:a})}),thead:({children:a,node:b,...c})=>(0,d.jsx)("thead",{className:"bg-accent",...c,children:a}),th:({children:a,node:b,...c})=>(0,d.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...c,children:a}),td:({children:a,node:b,...c})=>(0,d.jsx)("td",{className:"px-4 py-2 border-b border-border",...c,children:a}),hr:({node:a,...b})=>(0,d.jsx)("hr",{className:"my-4 border-border",...b}),img:({src:a,alt:b,node:c,height:e,width:f,style:g,...h})=>{let i=j&&"string"==typeof a?(0,o.xh)(a,j):a;if(!(e||f||g))return(0,d.jsx)("img",{src:i,alt:b||"",className:"max-w-full h-auto rounded-lg my-3",...h});let k=a=>a?/^\d+$/.test(String(a))?`${a}px`:String(a):void 0,l={...g,height:k(e)??g?.height,width:k(f)??g?.width};return(0,d.jsx)("img",{src:i,alt:b||"",style:l,className:"inline-block align-middle",...h})},strong:({children:a,node:b,...c})=>(0,d.jsx)("strong",{className:"font-bold",...c,children:a}),em:({children:a,node:b,...c})=>(0,d.jsx)("em",{className:"italic",...c,children:a}),del:({children:a,node:b,...c})=>(0,d.jsx)("del",{className:"line-through",...c,children:a})}),[s,i,j]),C=f?u:v,D=f?w:x,E=(0,n.useMemo)(()=>{if(b||c)return B(a);let d=B(y(!function(a){if(/^\|[\s:|-]+\|$/m.test(a))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(a)||/\+[-=]{2,}\+/.test(a))return!0;let b=a.split("\n").filter(a=>/^\s*\||\|\s*$/.test(a));if(b.length>=3){let a=b.map(a=>(a.match(/\|/g)||[]).length);return!a.every(b=>b===a[0])||!(a[0]>=3)}return!1}(a)||/^```[\s\S]*```$/m.test(a.trim())?a:"```text\n"+a.trim()+"\n```"));return f?z(d):d},[a,b,c,f]),F=(0,n.useMemo)(()=>h?.length?[...D,...h]:D,[h,D]);if(b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});if(c){let b=a.lastIndexOf("\n");if(-1===b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});let c=a.slice(0,b+1),g=a.slice(b+1);return(0,d.jsxs)("div",{className:"markdown-body",ref:t,children:[(0,d.jsx)(e.oz,{remarkPlugins:C,rehypePlugins:D,components:A,children:f?z(B(y(c))):B(y(c))}),g&&(0,d.jsx)("span",{className:"whitespace-pre-wrap",children:g})]})}return(0,d.jsx)("div",{className:"markdown-body",ref:t,children:(0,d.jsx)(e.oz,{remarkPlugins:C,rehypePlugins:F,components:A,children:E})})})},98982:(a,b,c)=>{"use strict";c.d(b,{P:()=>j});var d=c(67484),e=c(57031),f=c(88214),g=c(79606),h=c(33281),i=c(71192);function j(){let[a,b]=(0,d.useState)([]),c=(0,d.useCallback)(()=>{let a=g.tryPromise({try:async()=>{let a=await fetch("/api/pinned-sessions");return await a.json()},catch:a=>new i.uV({message:"loadPinnedSessions failed",cause:a})});h.t4.runPromise(a.pipe(g.match({onSuccess:a=>b(a.sessions||[]),onFailure:()=>{}})))},[]),j=(0,d.useCallback)(a=>{b(a);let c=g.tryPromise({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:a})})},catch:a=>new i.uV({message:"savePinnedSessions failed",cause:a})});h.t4.runFork(c.pipe(g.orElse(()=>g.void))),(0,e.F)(f.n.PinnedSessionsChanged,{})},[]),k=(0,d.useCallback)(b=>a.some(a=>a.sessionId===b),[a]),l=(0,d.useCallback)((b,c,d)=>{a.some(a=>a.sessionId===b)||j([...a,{sessionId:b,cwd:c,customTitle:d}])},[a,j]),m=(0,d.useCallback)(b=>{j(a.filter(a=>a.sessionId!==b))},[a,j]),n=(0,d.useCallback)((b,c)=>{j(a.map(a=>a.sessionId===b?{...a,customTitle:c}:a))},[a,j]);return{pinnedSessions:a,isPinned:k,pinSession:l,unpinSession:m,updateTitle:n,reorder:(0,d.useCallback)(a=>{j(a)},[j]),reload:c}}},99033:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Workspace:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(8077),i=c(4462),j=c(77120),k=c(77220),l=c(48830),m=c(3033),n=c(34001),o=c(29412),p=c(37202),q=c(87819),r=c(97572),s=a([h,j,n,o]);function t({initialCwd:a,initialSessionId:b}){let{t:d}=(0,g.Bd)(),[s,u]=(0,f.useState)([]),[v,w]=(0,f.useState)(0),[x,y]=(0,f.useState)(!1),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(!1),[D,E]=(0,f.useState)(!1),[F,G]=(0,f.useState)(!1),[H,I]=(0,f.useState)(null),[J,K]=(0,f.useState)(!1),[L,M]=(0,f.useState)(!1),[N,O]=(0,f.useState)([]),[P,Q]=(0,f.useState)(null),[R,S]=(0,f.useState)({}),[T,U]=(0,f.useState)({}),[V,W]=(0,f.useState)(!1),[X,Y]=(0,f.useState)(new Set),Z=(0,f.useRef)(new Map),$=(0,f.useRef)(new Map),_=(0,f.useRef)(new Map);(0,f.useRef)(null),(0,q.Z)(r.v,[]);let aa=(0,f.useCallback)(async(a,b,d)=>{let{Effect:e}=await c.e(2728).then(c.bind(c,92728)),{BrowserRuntime:f}=await c.e(3718).then(c.bind(c,3718)),g=await f.runPromise((0,r.g)({projects:a,activeIndex:b,collapsed:d}).pipe(e.either));"Left"===g._tag&&console.error("Failed to save projects:",g.left)},[]),ab=(0,f.useCallback)(a=>{let b=s[v]?.cwd,c=b?Z.current.get(b):null,d=c?.contentWindow;if(!d)return;let e=d.document.createEvent("CustomEvent");e.initCustomEvent("console-open-browser",!1,!1,{url:a}),d.dispatchEvent(e)},[v,s]),ac=(0,f.useCallback)(a=>{O(b=>b.some(b=>b.path===a.path)?b:[...b,a]),Q(a.path)},[]),ad=(0,f.useCallback)(()=>{Q(null)},[]),ae=(0,f.useCallback)(a=>{O(b=>b.filter(b=>b.path!==a)),Q(b=>b===a?null:b)},[]),af=(0,f.useMemo)(()=>{let a={};return s.forEach((b,c)=>{(T[b.cwd]??[]).forEach((d,e)=>{d&&(a[`${b.cwd}
|
|
760
|
+
⚠️ ${d}`:`⚠️ ${d}`,isStreaming:!1}:a));return}if("stream_event"===d){L(a=>a?null:a);let b=a.event;if(b?.type==="content_block_delta"&&b.delta?.type==="text_delta"){let a=b.delta.text||"";h(a),X.current&&X.current.messageId===c?X.current.text+=a:X.current={messageId:c,text:a},Y.current||(Y.current=setTimeout(ab,50))}return}if("assistant"===d){let d=a.message?.content;if(Array.isArray(d))for(let a of d)a.text?h(a.text):a.name&&h(`${a.name} ${JSON.stringify(a.input??{})}`);b(b=>(0,f.FM)(b,a,{engine:l,assistantId:c}))}if("user"===d){let d=a.message?.content;if(Array.isArray(d))for(let a of d)h("string"==typeof a.content?a.content:JSON.stringify(a.content??""));b(b=>(0,f.FM)(b,a,{engine:l,assistantId:c}))}if("result"===d){_.current=!1,$.current=!0,L(null),Y.current&&(clearTimeout(Y.current),Y.current=null),ab();let d=W.current;d&&k&&b(a=>(2===a.length&&y(d),a));let e=a.usage,g=a.total_cost_usd;e&&D({inputTokens:e.input_tokens||0,outputTokens:e.output_tokens||0,cacheCreationInputTokens:e.cache_creation_input_tokens||0,cacheReadInputTokens:e.cache_read_input_tokens||0,totalCostUsd:g||0}),b(b=>(0,f.FM)(b,a,{engine:l,assistantId:c}))}}},[b,ab,x,y,k,l]);return(0,h.h)({url:P?`/ws/session-stream?sessionId=${encodeURIComponent(P.runKey)}`:"/ws/session-stream",enabled:!!P,onMessage:a=>{U.current=!0,V.current&&(clearTimeout(V.current),V.current=null);let c=R.current;if(c)if("run-snapshot"===a.type&&Array.isArray(a.events)){Y.current&&(clearTimeout(Y.current),Y.current=null),X.current=null,Z.current=c.assistantId,$.current=!1,_.current=!1,S.current=!1,F(null);let d="number"==typeof a.outputTokens&&Number.isFinite(a.outputTokens)?Math.max(0,Math.round(a.outputTokens)):null;for(let e of(null!==d&&(S.current=!0,F({outputTokens:d})),b(a=>a.filter(a=>!("string"==typeof a.id&&a.id.startsWith("auto-")&&a.runKey===c.runKey)).map(a=>a.id===c.assistantId?{...a,content:"",toolCalls:[]}:a)),a.events))ae(e,Z.current??c.assistantId);a.status&&"running"!==a.status&&ac()}else if("run-event"===a.type&&a.message){if("run-ended"===a.message.type)return void ac();ae(a.message,Z.current??c.assistantId)}else"run-idle"===a.type&&ac()}}),{isLoading:A,tokenUsage:C,liveOutputTokens:E,runningStartedAt:G,rateLimitInfo:I,apiRetryInfo:K,backgroundTasks:M,handleSend:(0,d.useCallback)(async(a,c,d)=>{let e=d&&"permissionMode"in d?"plan"===d.permissionMode:m,f=c?.map(a=>({type:"base64",media_type:a.media_type,data:a.data})),h={id:`user-${Date.now()}`,role:"user",content:a,images:f};b(a=>[...a,h]),B(!0),F(null),S.current=!1,H(Date.now()),L(null),N(i);let j=function(){try{return crypto.randomUUID()}catch{return`run-${Date.now()}-${Math.floor(1e9*Math.random())}`}}(),x=`assistant-${Date.now()}`,y={id:x,role:"assistant",content:"",toolCalls:[],isStreaming:!0,runId:j};b(a=>[...a,y]),Z.current=x,$.current=!1,_.current=!1;let z=!l||"claude"===l,A="deepseek"===l||"kimi"===l||"glm"===l,C="ollama"===l||A||z||"codex"===l;try{if("ollama"===l&&!o)throw Error("Please select an Ollama model first (click the model picker above)");let c="codex"===l?"/api/chat/codex":"kimi"===l?"/api/chat/kimi":"ollama"===l?"/api/chat/ollama":"deepseek"===l?"/api/chat/deepseek":"glm"===l?"/api/chat/glm":"/api/chat",d=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,sessionId:W.current,runId:j,images:f,cwd:k,language:g.A.language,..."ollama"===l&&o&&{model:o},...A&&p&&{model:p},...z&&q&&{model:q},...z&&r&&{claudeEffort:r},...z&&s&&{claudeContextWindow:s},...z&&void 0!==t&&{claudeFastMode:t},...z&&void 0!==u&&{claudeThinking:u},..."codex"===l&&v&&{model:v},..."codex"===l&&w&&{codexReasoningEffort:w},...e&&z&&{permissionMode:"plan"},...C&&n&&{noHistory:!0}})});if(!d.ok){let a=await d.json().catch(()=>null);throw Error(a?.error||g.A.t("chat.requestFailed",{defaultValue:"Request failed"}))}let h=await d.json().catch(()=>({}));Q({runKey:h.runKey||j,assistantId:x,runId:j}),U.current=!1,V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{R.current&&!U.current&&(b(a=>a.map(a=>a.id!==x||a.content?a:{...a,content:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."})})),ac())},15e3)}catch(c){console.error("Chat error:",c);let a=c instanceof Error?c.message:g.A.t("chat.errorRetry",{defaultValue:"An error occurred. Please try again."});b(b=>b.map(b=>b.id===x?{...b,content:a,isStreaming:!1}:b)),B(!1),Q(null)}},[k,l,m,n,o,p,q,r,s,t,u,v,w,b,ac]),handleStop:ad,abortControllerRef:O}}},98356:(a,b,c)=>{"use strict";c.d(b,{T:()=>C});var d=c(48249),e=c(98051),f=c(38368),g=c(33972),h=c(10841),i=c(99773),j=c(36513);c(55583),c(87023);var k=c(50757),l=c(27454),m=c(37752),n=c(67484),o=c(64676),p=c(83768),q=c(15466),r=c(49216);function s(a){return{type:"tableCell",children:[{type:"text",value:a}]}}let t=[c(4014).A,function(){return a=>{let b=a.children;for(let a=0;a<b.length;a++){let c=b[a];if("yaml"!==c.type)continue;let d=null;try{let a=r.Ay.load(c.value??"");a&&"object"==typeof a&&!Array.isArray(a)&&(d=a)}catch{d=null}let e=d?Object.entries(d):[];if(0===e.length){b.splice(a,1),a--;continue}let f={type:"tableRow",children:[s("Field"),s("Value")]},g=e.map(([a,b])=>({type:"tableRow",children:[s(a),s(function(a){if(null==a)return"";if("string"==typeof a)return a.replace(/\s*\n\s*/g," ").trim();if("number"==typeof a||"boolean"==typeof a)return String(a);try{return JSON.stringify(a)}catch{return String(a)}}(b))]}));b[a]={type:"table",align:["left","left"],children:[f,...g]}}}}],u=[...t,f.A,g.A,h.jb],v=[...t,f.A,h.jb],w=[i.A,j.A],x=[i.A];function y(a){let b=[],c=a=>(b.push(a),` MASK${b.length-1} `);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/^(\|.+\|)$/gm,a=>/^\|[\s:|-]+\|$/.test(a)?a:a.replace(/`([^`]*)`/g,(a,b)=>b.includes("|")?"`"+b.replace(/\|/g,"\\|")+"`":a)).replace(/ MASK(\d+) /g,(a,c)=>b[+c])}function z(a){return a.replace(/\$(\d)/g,"\\$$1")}let A=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clippath","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan","use"]);function B(a){let b=[],c=a=>(b.push(a),`\u0000MASK${b.length-1}\u0000`);return a.replace(/```[\s\S]*?```/g,a=>c(a)).replace(/~~~[\s\S]*?~~~/g,a=>c(a)).replace(/`[^`\n]+`/g,a=>c(a)).replace(/<\/?([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(a,b)=>{let c=b.toLowerCase();return A.has(c)||c.includes("-")?a:a.replace(/</g,"<").replace(/>/g,">")}).replace(/\u0000MASK(\d+)\u0000/g,(a,c)=>b[+c])}let C=(0,n.memo)(function({content:a,isUser:b=!1,isStreaming:c=!1,enableMath:f=!0,isDark:g,rehypePlugins:h,onLinkClick:i,basePath:j}){let r=(0,p.Ql)(),s=g??r?.resolvedTheme==="dark",t=(0,n.useRef)(null),A=(0,n.useMemo)(()=>({code({className:a,children:b,node:c,...e}){let f=/language-(\w+)/.exec(a||"");if(!("string"==typeof b||"number"==typeof b||Array.isArray(b)&&b.every(a=>"string"==typeof a||"number"==typeof a)))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let g=String(b);if(!f&&!a&&!g.includes("\n"))return(0,d.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-accent text-sm font-mono",...e,children:b});let h=g.replace(/\n$/,""),i=f?.[1]||"text",j=Number(e["data-source-start"])||0,n=j?j+1:0,o=0;return(0,d.jsx)(k.A,{style:s?l.A:m.A,language:i,PreTag:"div",customStyle:{margin:"0.75rem 0",borderRadius:"0.375rem",fontSize:"0.875rem"},wrapLines:!0,lineProps:()=>{let a=n+o;return o++,{"data-source-start":a,"data-source-end":a,style:{display:"block"}}},children:h})},p:({children:a,node:b,...c})=>(0,d.jsx)("p",{className:"mb-3 last:mb-0",...c,children:a}),h1:({children:a,node:b,...c})=>(0,d.jsx)("h1",{className:"text-xl font-bold mb-3 mt-4 first:mt-0",...c,children:a}),h2:({children:a,node:b,...c})=>(0,d.jsx)("h2",{className:"text-lg font-bold mb-2 mt-3 first:mt-0",...c,children:a}),h3:({children:a,node:b,...c})=>(0,d.jsx)("h3",{className:"text-base font-bold mb-2 mt-3 first:mt-0",...c,children:a}),ul:({children:a,node:b,...c})=>(0,d.jsx)("ul",{className:"list-disc list-inside mb-3 space-y-1",...c,children:a}),ol:({children:a,node:b,...c})=>(0,d.jsx)("ol",{className:"list-decimal list-inside mb-3 space-y-1",...c,children:a}),li:({children:a,node:b,...c})=>(0,d.jsx)("li",{className:"leading-relaxed",...c,children:a}),blockquote:({children:a,node:b,...c})=>(0,d.jsx)("blockquote",{className:"border-l-4 border-border pl-4 my-3 italic text-muted-foreground",...c,children:a}),a:({href:a,children:b,node:c,...e})=>(0,d.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:underline",...e,onClick:b=>{if(a){if(a.startsWith("#")){(0,q.O)(t.current,a.slice(1))&&b.preventDefault();return}i?.(a)&&b.preventDefault()}},children:b}),table:({children:a,node:b,...c})=>(0,d.jsx)("div",{className:"overflow-x-auto my-3",...c,children:(0,d.jsx)("table",{className:"min-w-full border border-border",children:a})}),thead:({children:a,node:b,...c})=>(0,d.jsx)("thead",{className:"bg-accent",...c,children:a}),th:({children:a,node:b,...c})=>(0,d.jsx)("th",{className:"px-4 py-2 text-left font-semibold border-b border-border",...c,children:a}),td:({children:a,node:b,...c})=>(0,d.jsx)("td",{className:"px-4 py-2 border-b border-border",...c,children:a}),hr:({node:a,...b})=>(0,d.jsx)("hr",{className:"my-4 border-border",...b}),img:({src:a,alt:b,node:c,height:e,width:f,style:g,...h})=>{let i=j&&"string"==typeof a?(0,o.xh)(a,j):a;if(!(e||f||g))return(0,d.jsx)("img",{src:i,alt:b||"",className:"max-w-full h-auto rounded-lg my-3",...h});let k=a=>a?/^\d+$/.test(String(a))?`${a}px`:String(a):void 0,l={...g,height:k(e)??g?.height,width:k(f)??g?.width};return(0,d.jsx)("img",{src:i,alt:b||"",style:l,className:"inline-block align-middle",...h})},strong:({children:a,node:b,...c})=>(0,d.jsx)("strong",{className:"font-bold",...c,children:a}),em:({children:a,node:b,...c})=>(0,d.jsx)("em",{className:"italic",...c,children:a}),del:({children:a,node:b,...c})=>(0,d.jsx)("del",{className:"line-through",...c,children:a})}),[s,i,j]),C=f?u:v,D=f?w:x,E=(0,n.useMemo)(()=>{if(b||c)return B(a);let d=B(y(!function(a){if(/^\|[\s:|-]+\|$/m.test(a))return!1;if(/[┌┐└┘│─├┤┬┴┼╔╗╚╝║═╭╮╯╰▲▼◀▶△▽◁▷]/.test(a)||/\+[-=]{2,}\+/.test(a))return!0;let b=a.split("\n").filter(a=>/^\s*\||\|\s*$/.test(a));if(b.length>=3){let a=b.map(a=>(a.match(/\|/g)||[]).length);return!a.every(b=>b===a[0])||!(a[0]>=3)}return!1}(a)||/^```[\s\S]*```$/m.test(a.trim())?a:"```text\n"+a.trim()+"\n```"));return f?z(d):d},[a,b,c,f]),F=(0,n.useMemo)(()=>h?.length?[...D,...h]:D,[h,D]);if(b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});if(c){let b=a.lastIndexOf("\n");if(-1===b)return(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a});let c=a.slice(0,b+1),g=a.slice(b+1);return(0,d.jsxs)("div",{className:"markdown-body",ref:t,children:[(0,d.jsx)(e.oz,{remarkPlugins:C,rehypePlugins:D,components:A,children:f?z(B(y(c))):B(y(c))}),g&&(0,d.jsx)("span",{className:"whitespace-pre-wrap",children:g})]})}return(0,d.jsx)("div",{className:"markdown-body",ref:t,children:(0,d.jsx)(e.oz,{remarkPlugins:C,rehypePlugins:F,components:A,children:E})})})},98982:(a,b,c)=>{"use strict";c.d(b,{P:()=>j});var d=c(67484),e=c(57031),f=c(88214),g=c(79606),h=c(33281),i=c(71192);function j(){let[a,b]=(0,d.useState)([]),c=(0,d.useCallback)(()=>{let a=g.tryPromise({try:async()=>{let a=await fetch("/api/pinned-sessions");return await a.json()},catch:a=>new i.uV({message:"loadPinnedSessions failed",cause:a})});h.t4.runPromise(a.pipe(g.match({onSuccess:a=>b(a.sessions||[]),onFailure:()=>{}})))},[]),j=(0,d.useCallback)(a=>{b(a);let c=g.tryPromise({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:a})})},catch:a=>new i.uV({message:"savePinnedSessions failed",cause:a})});h.t4.runFork(c.pipe(g.orElse(()=>g.void))),(0,e.F)(f.n.PinnedSessionsChanged,{})},[]),k=(0,d.useCallback)(b=>a.some(a=>a.sessionId===b),[a]),l=(0,d.useCallback)((b,c,d)=>{a.some(a=>a.sessionId===b)||j([...a,{sessionId:b,cwd:c,customTitle:d}])},[a,j]),m=(0,d.useCallback)(b=>{j(a.filter(a=>a.sessionId!==b))},[a,j]),n=(0,d.useCallback)((b,c)=>{j(a.map(a=>a.sessionId===b?{...a,customTitle:c}:a))},[a,j]);return{pinnedSessions:a,isPinned:k,pinSession:l,unpinSession:m,updateTitle:n,reorder:(0,d.useCallback)(a=>{j(a)},[j]),reload:c}}},99033:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Workspace:()=>t});var e=c(48249),f=c(67484),g=c(44384),h=c(8077),i=c(4462),j=c(77120),k=c(77220),l=c(48830),m=c(3033),n=c(34001),o=c(29412),p=c(37202),q=c(87819),r=c(97572),s=a([h,j,n,o]);function t({initialCwd:a,initialSessionId:b}){let{t:d}=(0,g.Bd)(),[s,u]=(0,f.useState)([]),[v,w]=(0,f.useState)(0),[x,y]=(0,f.useState)(!1),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(!1),[D,E]=(0,f.useState)(!1),[F,G]=(0,f.useState)(!1),[H,I]=(0,f.useState)(null),[J,K]=(0,f.useState)(!1),[L,M]=(0,f.useState)(!1),[N,O]=(0,f.useState)([]),[P,Q]=(0,f.useState)(null),[R,S]=(0,f.useState)({}),[T,U]=(0,f.useState)({}),[V,W]=(0,f.useState)(!1),[X,Y]=(0,f.useState)(new Set),Z=(0,f.useRef)(new Map),$=(0,f.useRef)(new Map),_=(0,f.useRef)(new Map);(0,f.useRef)(null),(0,q.Z)(r.v,[]);let aa=(0,f.useCallback)(async(a,b,d)=>{let{Effect:e}=await c.e(2728).then(c.bind(c,92728)),{BrowserRuntime:f}=await c.e(3718).then(c.bind(c,3718)),g=await f.runPromise((0,r.g)({projects:a,activeIndex:b,collapsed:d}).pipe(e.either));"Left"===g._tag&&console.error("Failed to save projects:",g.left)},[]),ab=(0,f.useCallback)(a=>{let b=s[v]?.cwd,c=b?Z.current.get(b):null,d=c?.contentWindow;if(!d)return;let e=d.document.createEvent("CustomEvent");e.initCustomEvent("console-open-browser",!1,!1,{url:a}),d.dispatchEvent(e)},[v,s]),ac=(0,f.useCallback)(a=>{O(b=>b.some(b=>b.path===a.path)?b:[...b,a]),Q(a.path)},[]),ad=(0,f.useCallback)(()=>{Q(null)},[]),ae=(0,f.useCallback)(a=>{O(b=>b.filter(b=>b.path!==a)),Q(b=>b===a?null:b)},[]),af=(0,f.useMemo)(()=>{let a={};return s.forEach((b,c)=>{(T[b.cwd]??[]).forEach((d,e)=>{d&&(a[`${b.cwd}
|
|
759
761
|
${d}`]=`${c+1}.${e+1}`)})}),a},[s,T]),ag=(0,f.useCallback)(()=>{let a=crypto.randomUUID(),b=new Map(s.map((a,b)=>[a.cwd,b+1])),c=[...Z.current.values()];return 0===c.length?Promise.resolve({}):new Promise(d=>{let e={},f=new Set(c.map(a=>a.contentWindow).filter(Boolean)),g=()=>{window.removeEventListener("message",h),clearTimeout(i),S(e),d(e)},h=c=>{if(c.data?.type!=="SESSION_NUMBERS"||c.data?.requestId!==a||!f.delete(c.source))return;let d=b.get(c.data.cwd);d&&Array.isArray(c.data.sessionIds)&&c.data.sessionIds.forEach((a,b)=>{"string"==typeof a&&(e[`${c.data.cwd}
|
|
760
762
|
${a}`]=`${d}.${b+1}`)}),0===f.size&&g()};window.addEventListener("message",h);let i=window.setTimeout(g,300);c.forEach(b=>b.contentWindow?.postMessage({type:"GET_SESSION_NUMBERS",requestId:a},"*"))})},[s]),ah=Object.fromEntries(s.map((a,b)=>[a.cwd,b+1])),ai=(0,f.useCallback)((a,b)=>{let c=new URL(window.location.href);c.searchParams.set("cwd",a),b?c.searchParams.set("sessionId",b):c.searchParams.delete("sessionId"),window.history.replaceState({},"",c.toString());let d=a.split("/").filter(Boolean).pop();document.title=d||"Cockpit"},[]);(0,f.useRef)(!1);let aj=(0,f.useCallback)(a=>{w(a),aa(s,a,x);let b=s[a];if(b?.cwd){let a=_.current.get(b.cwd);ai(b.cwd,a)}},[s,x,aa,ai]),ak=(0,f.useCallback)(a=>{let b=s.filter((b,c)=>c!==a),c=v;a<v?c=v-1:a===v&&c>=b.length&&(c=Math.max(0,b.length-1)),u(b),w(c),aa(b,c,x)},[s,v,x,aa]),al=(0,f.useCallback)(a=>{let b=s[v],c=a.findIndex(a=>a.cwd===b?.cwd);u(a),w(c>=0?c:0),aa(a,c>=0?c:0,x)},[s,v,x,aa]),am=(0,f.useCallback)(()=>{let a=!x;y(a),aa(s,v,a)},[s,v,x,aa]),an=(0,f.useCallback)((a,b)=>{_.current.set(a,b);let c=s.findIndex(b=>b.cwd===a);if(c>=0){let d=Z.current.get(a);d?.contentWindow?d.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"):$.current.set(a,{sessionId:b,switchToAgent:!0}),w(c),aa(s,c,x)}else{let c=[...s,{cwd:a}],d=c.length-1;u(c),w(d),aa(c,d,x),$.current.set(a,{sessionId:b,switchToAgent:!0})}ai(a,b),A(!1)},[s,x,aa,ai]),ao=(0,f.useCallback)((a,b)=>{_.current.set(a,b);let c=s.findIndex(b=>b.cwd===a);if(c>=0){let d=Z.current.get(a);d?.contentWindow?d.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"):$.current.set(a,{sessionId:b,switchToAgent:!0}),c!==v&&(w(c),aa(s,c,x))}else{let c=[...s,{cwd:a}],d=c.length-1;u(c),w(d),aa(c,d,x),$.current.set(a,{sessionId:b,switchToAgent:!0})}ai(a,b)},[s,v,x,aa,ai]);return V?(0,e.jsxs)("div",{className:"h-screen flex bg-background overflow-hidden",children:[(0,e.jsx)(h.ProjectSidebar,{projects:s,activeIndex:v,collapsed:x,currentCwd:s[v]?.cwd,onSelectProject:aj,onRemoveProject:ak,onReorderProjects:al,onToggleCollapse:am,onOpenSessionBrowser:()=>A(!0),onOpenSettings:()=>C(!0),onOpenNote:a=>{I(a??null),G(!0)},onOpenSkills:()=>K(!0),onOpenApps:()=>M(!0),htmlAppPreviews:N,activeHtmlAppPreviewPath:P,onShowHtmlAppPreview:ac,onSwitchProject:ao,onResolveSessionNumbers:ag,sessionOrders:T,sessionNumbers:af}),(0,e.jsx)("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:0===s.length?(0,e.jsx)(i.EmptyState,{onBrowseProjects:()=>A(!0)}):(0,e.jsx)("div",{className:"flex-1 relative overflow-hidden",children:s.map((a,b)=>{let c,d;return X.has(a.cwd)&&(0,e.jsx)("iframe",{ref:b=>{b?Z.current.set(a.cwd,b):Z.current.delete(a.cwd)},src:(c=`/project?cwd=${encodeURIComponent(a.cwd)}`,d=$.current.get(a.cwd),d?.sessionId&&(c+=`&sessionId=${encodeURIComponent(d.sessionId)}`,d.switchToAgent&&(c+="&view=agent")),c),className:`absolute inset-0 w-full h-full border-0 ${b===v?"block":"hidden"}`,title:`Project: ${a.cwd}`},a.cwd)})})}),(0,e.jsx)(j.SessionBrowser,{isOpen:z,onClose:()=>A(!1),onSelectSession:an,sessionNumbers:R,projectNumbers:ah,onAddProject:a=>{let b=s.findIndex(b=>b.cwd===a);if(b>=0)w(b),aa(s,b,x);else{let b=[...s,{cwd:a}],c=b.length-1;u(b),w(c),aa(b,c,x)}A(!1)}}),(0,e.jsx)(k.SettingsModal,{isOpen:B,onClose:()=>C(!1)}),(0,e.jsx)(m.w,{isOpen:D,onClose:()=>E(!1)}),(0,e.jsx)(n.NoteModal,{isOpen:F,onClose:()=>{G(!1),I(null)},projectCwd:H,projectName:H?H.split("/").pop():null}),(0,e.jsx)(o.g,{isOpen:J,onClose:()=>K(!1)}),(0,e.jsx)(l.n,{isOpen:L,htmlAppPreviews:N,activeHtmlAppPreviewPath:P,onShowHtmlAppPreview:ac,onMinimizeHtmlAppPreview:ad,onCloseHtmlAppPreview:ae,onClose:()=>M(!1),onOpenApp:ab}),(0,e.jsx)(p.M,{onNavigate:ao})]}):(0,e.jsx)("div",{className:"h-screen flex items-center justify-center bg-card",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-5 w-5",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:d("workspace.loadingText")})]})})}[h,j,n,o]=s.then?(await s)():s,d()}catch(a){d(a)}})},99087:(a,b,c)=>{"use strict";c.d(b,{a:()=>e});var d=c(67484);function e(a){let[b,c]=(0,d.useState)(!1),[e,f]=(0,d.useState)(""),[g,h]=(0,d.useState)([]),[i,j]=(0,d.useState)(0),k=(0,d.useRef)(null),l=(0,d.useRef)([]),m=(0,d.useCallback)(()=>{let b=a.current;b&&(b.querySelectorAll("mark.chat-search-match, mark.chat-search-current").forEach(a=>{let b=a.parentNode;b&&(b.replaceChild(document.createTextNode(a.textContent||""),a),b.normalize())}),l.current=[])},[a]);(0,d.useCallback)(b=>{if(m(),!b||!a.current){h([]),j(0);return}let c=[],d=[],e=b.toLowerCase();a.current.querySelectorAll("[data-message-id]").forEach(a=>{let f,g=a.getAttribute("data-message-id")||"",h=0,i=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null),j=[];for(;f=i.nextNode();)j.push(f);for(let a of j){let f=(a.textContent||"").toLowerCase(),i=0,j=[];for(;;){let a=f.indexOf(e,i);if(-1===a)break;j.push({start:a,end:a+b.length}),i=a+1}if(0!==j.length)for(let b=j.length-1;b>=0;b--){let e=j[b];a.splitText(e.end);let f=a.splitText(e.start),i=document.createElement("mark");i.className="chat-search-match",i.textContent=f.textContent,f.parentNode.replaceChild(i,f),c.push({messageId:g,markIndex:h}),d.push(i),h++}}}),c.reverse(),d.reverse(),l.current=d,h(c),j(c.length>0?0:-1)},[a,m]);let n=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a+1)%g.length)},[g.length]),o=(0,d.useCallback)(()=>{0!==g.length&&j(a=>(a-1+g.length)%g.length)},[g.length]),p=(0,d.useCallback)(()=>{c(!0),setTimeout(()=>k.current?.focus(),0)},[]),q=(0,d.useCallback)(()=>{c(!1),f(""),m(),h([]),j(0)},[m]),r=(0,d.useCallback)(a=>{"Enter"===a.key&&(a.preventDefault(),a.shiftKey?o():n()),"Escape"===a.key&&q()},[n,o,q]);return{isSearchVisible:b,searchQuery:e,setSearchQuery:f,matches:g,currentMatchIndex:i,goToNextMatch:n,goToPrevMatch:o,openSearch:p,closeSearch:q,searchInputRef:k,handleSearchKeyDown:r}}},99829:(a,b,c)=>{"use strict";c.d(b,{I18nProvider:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call I18nProvider() from the server but I18nProvider 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/I18nProvider.tsx","I18nProvider")},99843:(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(75513),h=c(63565),i=c(2929),j=c(99087),k=c(74754),l=c(91579),m=c(41051),n=c(42140),o=c(44384),p=c(33281),q=c(41224),r=c(86508),s=c(37701),t=a([i]);i=(t.then?(await t)():t)[0];function u({value:a}){let[b,c]=(0,f.useState)(a);return(0,f.useRef)(a),(0,f.useRef)(null),(0,e.jsx)("span",{className:"tabular-nums",children:b})}let v=(0,f.forwardRef)(function({messages:a,isLoading:b,cwd:c,sessionId:d,engine:t,apiRetryInfo:v,backgroundTasks:w,liveOutputTokens:x,runningStartedAt:y,hasMoreHistory:z,isLoadingMore:A,onLoadMore:B,onFork:C,isActive:D=!0,onContentSearch:E,onShowFileDiff:F,onOpenFileLink:G,onApprovePlan:H},I){let{t:J,i18n:K}=(0,o.Bd)(),L=(0,f.useRef)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null),O=(0,f.useRef)(null),[P,Q]=(0,f.useState)(null),[R,S]=(0,f.useState)(!0),[T,U]=(0,f.useState)(!1),[V,W]=(0,f.useState)(!1),[X,Y]=(0,f.useState)(!1),[Z,$]=(0,f.useState)(!1),[_,aa]=(0,f.useState)(0);(0,f.useEffect)(()=>{Q(O.current)},[]),(0,f.useEffect)(()=>{if(!b||!y)return void aa(0);let a=()=>aa(Math.max(0,Math.floor((Date.now()-y)/1e3)));a();let c=setInterval(a,1e3);return()=>clearInterval(c)},[b,y]);let ab=(0,f.useMemo)(()=>(0,h.ch)(t)?h.H[t]:h.H.claude,[t]),ac=(0,h.ch)(t)?t:"claude",ad=(0,f.useMemo)(()=>{let a=Math.floor(_/60),b=_%60;return a>0?`${a}m${b}s`:`${b}s`},[_]),{isSearchVisible:ae,searchQuery:af,setSearchQuery:ag,matches:ah,currentMatchIndex:ai,goToNextMatch:aj,goToPrevMatch:ak,closeSearch:al,searchInputRef:am,handleSearchKeyDown:an}=(0,j.a)(O),ao=(0,g.nH)(),ap=(0,f.useRef)(null),aq=(0,f.useRef)(()=>{}),{addComment:ar,refresh:as}=(0,k._)({cwd:c||"",filePath:l.Un}),[at,au]=(0,f.useState)(null),[av,aw]=(0,f.useState)(null),ax=(0,f.useCallback)(a=>{if(at||av)return;let b=window.getSelection();if(!b||b.isCollapsed||!b.rangeCount){ap.current=null,aq.current();return}let c=b.toString().trim();if(!c){ap.current=null,aq.current();return}let d=b.anchorNode instanceof HTMLElement?b.anchorNode:b.anchorNode?.parentElement;if(d?.closest('[data-role="user"]')){ap.current=null,aq.current();return}ap.current={x:a.clientX,y:a.clientY,range:{start:0,end:0},selectedText:c,lineSnapshot:c},aq.current()},[at,av]),ay=(0,f.useCallback)(a=>{let b=a.target;!(b.closest(".floating-toolbar")||b.closest('[class*="z-[200]"]'))&&ap.current&&(ap.current=null,aq.current())},[]),az=(0,f.useCallback)(()=>{let a=ap.current;a&&(au({x:a.x,y:a.y,text:a.selectedText}),ap.current=null,aq.current(),window.getSelection()?.removeAllRanges())},[]),aA=(0,f.useCallback)(()=>{let a=ap.current;a&&(aw({x:a.x,y:a.y,text:a.selectedText}),ap.current=null,aq.current(),window.getSelection()?.removeAllRanges())},[]),aB=(0,f.useCallback)(()=>{let a=ap.current;a&&ao&&(ap.current=null,aq.current(),window.getSelection()?.removeAllRanges(),(0,l.Ff)(ao.sendMessage,{filePath:l.Un,startLine:0,endLine:0,codeContent:a.selectedText},J("explain.selectionMessage")))},[ao,J]),aC=(0,f.useCallback)(()=>{let a=ap.current;if(!a||!E)return;let b=a.selectedText.trim();ap.current=null,aq.current(),window.getSelection()?.removeAllRanges(),b&&E(b)},[E]),aD=(0,f.useCallback)(async a=>{at&&(await ar(0,0,a,at.text),au(null))},[at,ar]),aE=(0,f.useCallback)(async(a,b)=>{if(ao&&c)try{let d=(await (0,l.$3)(c)).map(a=>({filePath:a.filePath,startLine:a.startLine,endLine:a.endLine,codeContent:a.codeContent,note:a.content||void 0}));d.push({filePath:l.Un,startLine:0,endLine:0,codeContent:a});let e=(0,l.Gw)(d,b);ao.sendMessage(e),await (0,l.RP)(c),as()}catch(a){console.error("Failed to send to AI:",a)}},[ao,c,as]),aF=(0,f.useCallback)((a,b)=>{let c=ap.current;if(!c)return;let d=c.selectedText;ap.current=null,aq.current(),window.getSelection()?.removeAllRanges(),"comment"===a?ar(0,0,b,d):aE(d,b)},[ar,aE]),aG=(0,s.Fe)(K.language),[aH,aI]=(0,f.useState)(null),[aJ,aK]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let a=!1;return p.t4.runPromiseExit((0,q.td)()).then(b=>{a||aI("Success"===b._tag?(0,s.wL)(b.value,aG):null)}),()=>{a=!0}},[aG]);let aL=(0,f.useCallback)(a=>{p.t4.runPromiseExit((0,q.td)()).then(b=>{let c={..."Success"===b._tag?b.value.quickReplies??{}:{}};return a?c[aG]=a:delete c[aG],p.t4.runPromiseExit((0,q.em)({quickReplies:c})).then(b=>{"Success"===b._tag?aI(a):console.error("Failed to save quick replies:",b.cause)})})},[aG]),aM=(0,f.useCallback)(()=>{ap.current=null,aq.current(),window.getSelection()?.removeAllRanges(),aK(!0)},[]),aN=(0,f.useMemo)(()=>aH??m.SZ.map(a=>a.map(a=>J(a))),[aH,J]),aO=(0,f.useCallback)(a=>{av&&aE(av.text,a)},[av,aE]),aP=(0,f.useCallback)(a=>{at&&aE(at.text,a)},[at,aE]),aQ=(0,f.useMemo)(()=>{let b=new Set;return a.filter(a=>!b.has(a.id)&&(b.add(a.id),"assistant"!==a.role||!!a.isStreaming||!!a.content||!!a.images?.length||!!a.toolCalls?.length||!!a.parts?.length))},[a]),aR=(0,f.useRef)(0),aS=(0,f.useRef)(!1),aT=(0,f.useCallback)(()=>{let a=N.current;return!a||a.scrollHeight-a.scrollTop-a.clientHeight<50},[]),aU=(0,f.useCallback)(()=>{let a=N.current;return!a||a.scrollTop<50},[]),aV=(0,f.useCallback)(()=>{let a=N.current;if(!a)return;let b=a.querySelectorAll('[data-message-id][data-role="user"]'),c=b[0],d=b[b.length-1],e=a.getBoundingClientRect().top;Y(!!c&&c.getBoundingClientRect().top-e<-12),$(!!d&&d.getBoundingClientRect().top-e>12)},[]),aW=(0,f.useCallback)(()=>{let a=aT(),b=aU();if(S(a),U(!b),W(!a),aV(),b&&z&&!A&&B){let a=N.current;a&&(aR.current=a.scrollHeight,aS.current=!0),B()}},[aT,aU,aV,z,A,B]),aX=(0,f.useCallback)(()=>{M.current?.scrollIntoView({behavior:"smooth"})},[]),aY=(0,f.useCallback)(()=>{L.current?.scrollIntoView({behavior:"smooth"})},[]),aZ=(0,f.useCallback)(a=>{let b=N.current;if(!b)return;let c=b.querySelector(`[data-message-id="${a}"]`);c&&(c.scrollIntoView({behavior:"smooth",block:"center"}),c.classList.add("ring-2","ring-brand","ring-offset-2"),setTimeout(()=>{c.classList.remove("ring-2","ring-brand","ring-offset-2")},2e3))},[]),a$=(0,f.useCallback)(a=>{let b=N.current;if(!b)return;let c=b.getBoundingClientRect().top,d=Array.from(b.querySelectorAll('[data-message-id][data-role="user"]')),e=a=>a.getBoundingClientRect().top-c,f="prev"===a?[...d].reverse().find(a=>-12>e(a)):d.find(a=>e(a)>12);f&&b.scrollTo({top:b.scrollTop+e(f)-8,behavior:"smooth"})},[]);(0,f.useImperativeHandle)(I,()=>({scrollToMessage:aZ}),[aZ]);let a_=(0,f.useRef)(!0);(0,f.useLayoutEffect)(()=>{if(a_.current||!R||aS.current)return;let a=N.current;a&&(a.scrollTop=a.scrollHeight)},[a,R]),(0,f.useLayoutEffect)(()=>{if(R&&b){let a=N.current;a&&(a.scrollTop=a.scrollHeight)}},[b,R]),(0,f.useLayoutEffect)(()=>{if(aS.current&&!A){let a=N.current;if(a){let b=a.scrollHeight-aR.current;a.scrollTop=b,aS.current=!1}}},[a,A]);let a0=(0,f.useRef)(!1);return(0,f.useLayoutEffect)(()=>{if(D&&a0.current&&a.length>0){a0.current=!1;let a=N.current;a&&(a.scrollTop=a.scrollHeight)}},[D,a.length]),(0,f.useLayoutEffect)(()=>{if(a_.current&&a.length>0)if(a_.current=!1,D){let a=N.current;a&&(a.scrollTop=a.scrollHeight)}else a0.current=!0},[a.length,D]),(0,f.useEffect)(()=>{D&&aV()},[a,D,aV]),(0,e.jsxs)("div",{ref:O,className:"relative flex-1 min-h-0 overflow-hidden flex flex-col outline-none",tabIndex:-1,onMouseUp:ax,onMouseDown:ay,children:[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:am,type:"text",value:af,onChange:a=>ag(a.target.value),onKeyDown:an,placeholder:J("codeViewer.searchChat"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:ah.length>0?`${ai+1}/${ah.length}`:J("common.noMatch")}),(0,e.jsx)("button",{onClick:ak,disabled:0===ah.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:J("codeViewer.prevShiftEnter"),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:aj,disabled:0===ah.length,className:"p-1 rounded hover:bg-hover disabled:opacity-50",title:J("codeViewer.nextEnter"),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:al,className:"p-1 rounded hover:bg-hover",title:J("codeViewer.closeEsc"),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:N,onScroll:aW,className:"relative flex-1 min-h-0 overflow-y-auto p-4",children:0!==a.length||b?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{ref:M}),z&&(0,e.jsx)("div",{className:"flex justify-center py-3",children:A?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[(0,e.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"}),(0,e.jsx)("span",{children:J("chat.loadMoreHistory")})]}):(0,e.jsx)("button",{onClick:B,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:J("chat.scrollUpForMore")})}),aQ.map(a=>(0,e.jsx)("div",{"data-message-id":a.id,"data-role":a.role,className:"transition-[box-shadow] duration-300",children:(0,e.jsx)(i.s,{message:a,cwd:c,sessionId:d,onFork:C,forkSupported:!0,onApprovePlan:H,isLoading:b,onContentSearch:E,onShowFileDiff:F,onOpenFileLink:G})},a.id)),b&&(0,e.jsx)("div",{className:"flex justify-start mb-4",children:(0,e.jsxs)("div",{className:"px-1 py-1 max-w-[90%]",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[(0,e.jsx)("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center","aria-hidden":"true",children:(0,e.jsx)(h.eV,{engine:ac,className:"h-4 w-4 animate-pulse"})}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground/80",children:[ab," running ",ad," \xb7 processing"," ",(0,e.jsx)(u,{value:x?.outputTokens??0})]})]}),w&&w.length>0&&(0,e.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-muted-foreground border-t border-border/50 pt-2",children:[(0,e.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{children:["Waiting on ",w.length," background task",w.length>1?"s":""]}),w.map(a=>(0,e.jsx)("div",{className:"text-muted-foreground/80 break-words",children:a.description},a.task_id))]})]}),v&&(0,e.jsxs)("div",{className:"mt-2 flex items-start gap-2 text-xs text-amber-11 border-t border-border/50 pt-2",children:[(0,e.jsx)("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,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.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{children:["Retrying API call (attempt ",v.attempt,v.maxRetries>0?`/${v.maxRetries}`:"",v.delayMs>0?`, delay ${(v.delayMs/1e3).toFixed(1)}s`:"",")"]}),(v.errorStatus||v.error)&&(0,e.jsxs)("div",{className:"text-muted-foreground/80 break-words",children:[v.errorStatus?`${v.errorStatus}`:"",v.errorStatus&&v.error?" \xb7 ":"",v.error||""]})]})]})]})}),(0,e.jsx)("div",{ref:L})]}):(0,e.jsx)("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCAC"}),(0,e.jsx)("div",{children:J("chat.startConversation")})]})})}),T&&a.length>0&&(0,e.jsx)("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 flex items-center bg-card shadow-lv2 rounded-full",children:(0,e.jsx)("button",{onClick:aX,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95",title:J("chat.jumpToStart"),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"})})})}),V&&a.length>0&&(0,e.jsxs)("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex items-center bg-card shadow-lv2 rounded-full",children:[(0,e.jsx)("button",{onClick:aY,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95",title:J("chat.jumpToLatest"),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)("span",{className:"w-px h-4 bg-border"}),(0,e.jsx)("button",{onClick:()=>a$("prev"),disabled:!X,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95 disabled:opacity-40 disabled:hover:text-muted-foreground disabled:active:scale-100 disabled:cursor-default",title:J("chat.jumpToPrevUserMessage"),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 5h14M12 19V9m-5 5l5-5 5 5"})})}),(0,e.jsx)("button",{onClick:()=>a$("next"),disabled:!Z,className:"p-2 text-muted-foreground hover:text-foreground rounded-full transition-all active:scale-95 disabled:opacity-40 disabled:hover:text-muted-foreground disabled:active:scale-100 disabled:cursor-default",title:J("chat.jumpToNextUserMessage"),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 19H5m7-14v10m5-5l-5 5-5-5"})})})]}),P&&(0,e.jsx)(m.fS,{floatingToolbarRef:ap,bumpRef:aq,container:P,onAddComment:az,onSendToAI:aA,onSearch:E?aC:void 0,onExplain:ao?aB:void 0,onQuickReply:aF,quickReplyRows:aN,onEditQuickReplies:aM,isChatLoading:ao?.isLoading}),aJ&&(0,e.jsx)(r.j,{initialRows:aN,lang:aG,isCustomized:null!==aH,onSave:a=>aL(a.length?a:null),onRestoreDefault:()=>aL(null),onClose:()=>aK(!1)}),at&&P&&(0,e.jsx)(n.t,{x:at.x,y:at.y,range:{start:0,end:0},lineSnapshot:at.text,container:P,onSubmit:aD,onSendToAI:ao?aP:void 0,onClose:()=>au(null),isChatLoading:ao?.isLoading}),av&&P&&(0,e.jsx)(n.G,{x:av.x,y:av.y,range:{start:0,end:0},lineSnapshot:av.text,container:P,onSubmit:aO,onClose:()=>aw(null),isChatLoading:ao?.isLoading})]})});d()}catch(a){d(a)}})}};
|