cogpit 2.0.0
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/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/cli.js +26786 -0
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/CommandPaletteHost-ChH6w0Bx.js +1 -0
- package/dist/web/assets/ConfigBrowser-CPCH7_25.js +1 -0
- package/dist/web/assets/HighlightedEditor-BPmH8BvC.js +2 -0
- package/dist/web/assets/KeyboardShortcutsDialog-CTbXz40Z.js +1 -0
- package/dist/web/assets/MobileFileChanges-C5VoKbje.js +1 -0
- package/dist/web/assets/PreviewPanel-DoAf1W2k.js +1 -0
- package/dist/web/assets/ProjectFilesPanel-v_O7Awnm.js +4 -0
- package/dist/web/assets/ProjectSwitcherModal-CSZrCd3X.js +1 -0
- package/dist/web/assets/TerminalOutput-6GBZ9nXN.css +32 -0
- package/dist/web/assets/TerminalOutput-SImEU6_6.js +51 -0
- package/dist/web/assets/ThemeSelectorModal-rjVBMgWC.js +1 -0
- package/dist/web/assets/WorkflowsPanel-JVqgKAzY.js +1 -0
- package/dist/web/assets/WorktreePanel-D94-oAau.js +1 -0
- package/dist/web/assets/bash-Yzrsuije.js +1 -0
- package/dist/web/assets/c-BIGW1oBm.js +1 -0
- package/dist/web/assets/cpp-BRuaLJcg.js +1 -0
- package/dist/web/assets/css-DPfMkruS.js +1 -0
- package/dist/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/dist/web/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/dist/web/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/web/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/dist/web/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/dist/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/web/assets/github-dark-DHJKELXO.js +1 -0
- package/dist/web/assets/github-light-DAi9KRSo.js +1 -0
- package/dist/web/assets/go-CxLEBnE3.js +1 -0
- package/dist/web/assets/html-GMplVEZG.js +1 -0
- package/dist/web/assets/index-Bif4Kdtn.css +1 -0
- package/dist/web/assets/index-C00ZsBZl.js +1 -0
- package/dist/web/assets/index-C5VcQtkE.js +1 -0
- package/dist/web/assets/index-CNV6e3p0.js +138 -0
- package/dist/web/assets/index-S7UMnH_y.js +5 -0
- package/dist/web/assets/java-CylS5w8V.js +1 -0
- package/dist/web/assets/javascript-wDzz0qaB.js +1 -0
- package/dist/web/assets/json-Cp-IABpG.js +1 -0
- package/dist/web/assets/jsx-g9-lgVsj.js +1 -0
- package/dist/web/assets/kotlin-BdnUsdx6.js +1 -0
- package/dist/web/assets/markdown-Cvjx9yec.js +1 -0
- package/dist/web/assets/php-aq0itWAE.js +1 -0
- package/dist/web/assets/python-B6aJPvgy.js +1 -0
- package/dist/web/assets/ruby-B0Tyh1qT.js +1 -0
- package/dist/web/assets/rust-B1yitclQ.js +1 -0
- package/dist/web/assets/scss-OYdSNvt2.js +1 -0
- package/dist/web/assets/session-parser.worker-BhyaigCR.js +22 -0
- package/dist/web/assets/sql-BLtJtn59.js +1 -0
- package/dist/web/assets/svelte-DZMnMd3x.js +1 -0
- package/dist/web/assets/swift-D82vCrfD.js +1 -0
- package/dist/web/assets/toml-vGWfd6FD.js +1 -0
- package/dist/web/assets/tsx-COt5Ahok.js +1 -0
- package/dist/web/assets/typescript-BPQ3VLAy.js +1 -0
- package/dist/web/assets/vendor-markdown-BE1gYnO9.js +37 -0
- package/dist/web/assets/vendor-react-gGw_S5I_.js +57 -0
- package/dist/web/assets/vendor-shiki-DOn6sF-i.js +144 -0
- package/dist/web/assets/vendor-ui-BmLOQ5Or.js +797 -0
- package/dist/web/assets/vue-DVfSmUF7.js +1 -0
- package/dist/web/assets/xml-D2mA2LmW.js +1 -0
- package/dist/web/assets/yaml-Buea-lGh.js +1 -0
- package/dist/web/cogpit.svg +10 -0
- package/dist/web/index.html +28 -0
- package/dist/web/theme-bootstrap.js +25 -0
- package/package.json +51 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-SImEU6_6.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-BmLOQ5Or.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/TerminalOutput-6GBZ9nXN.css","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-B0Tyh1qT.js","assets/xml-D2mA2LmW.js","assets/java-CylS5w8V.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/php-aq0itWAE.js","assets/json-Cp-IABpG.js","assets/vue-DVfSmUF7.js","assets/svelte-DZMnMd3x.js","assets/scss-OYdSNvt2.js","assets/CommandPaletteHost-ChH6w0Bx.js","assets/index-C5VcQtkE.js","assets/KeyboardShortcutsDialog-CTbXz40Z.js","assets/ProjectSwitcherModal-CSZrCd3X.js","assets/ThemeSelectorModal-rjVBMgWC.js","assets/WorktreePanel-D94-oAau.js","assets/index-C00ZsBZl.js","assets/ConfigBrowser-CPCH7_25.js","assets/HighlightedEditor-BPmH8BvC.js","assets/PreviewPanel-DoAf1W2k.js","assets/ProjectFilesPanel-v_O7Awnm.js","assets/MobileFileChanges-C5VoKbje.js","assets/index-S7UMnH_y.js","assets/WorkflowsPanel-JVqgKAzY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var b0=Object.defineProperty;var y0=(n,e,t)=>e in n?b0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var vr=(n,e,t)=>y0(n,typeof e!="symbol"?e+"":e,t);import{c as F,j as r,d as ge,e as w0,r as b,a as j0,f as S0}from"./vendor-react-gGw_S5I_.js";import{at as N0,au as k0,av as C0,aw as Cn,a0 as lt,ax as _0,m as fn,ay as T0,aq as _n,az as Om,aA as E0,aB as El,aC as Dm,aD as P0,aE as A0,aF as Lm,aG as zm,aH as Fm,aI as Bm,aJ as M0,O as rt,aK as R0,aL as I0,aM as $0,ab as zo,J as Fo,a9 as nt,c as Ht,ah as O0,aN as Um,aO as Ur,G as Xs,aP as D0,aQ as L0,aR as z0,aS as F0,aT as B0,aU as U0,aV as W0,aW as H0,aX as K0,aY as V0,aZ as q0,a_ as G0,a$ as Y0,b0 as X0,b1 as Bo,b2 as Wm,b3 as Pl,b4 as Al,b5 as Ml,b6 as Rl,b7 as di,X as xt,b8 as Il,b9 as J0,N as $l,ba as Tn,bb as Z0,bc as Hm,bd as Km,be as Fs,bf as rs,bg as Q0,bh as e2,bi as t2,bj as n2,bk as ko,S as an,B as Hs,b as Vm,bl as ws,bm as qm,a1 as ui,bn as s2,a6 as fi,aj as Ya,W as Js,bo as qd,bp as o2,bq as r2,br as i2,bs as a2,bt as l2,bu as c2,bv as Ol,bw as d2,bx as u2,by as ln,D as bn,bz as Co,T as mi,bA as f2,bB as m2,bC as p2,bD as h2,bE as Uo,bF as g2,bG as x2,bH as v2,bI as b2,bJ as y2,bK as w2,bL as j2,bM as S2,bN as N2,bO as k2,bP as C2,bQ as _2,bR as T2,bS as E2,C as et,P as xn,A as Zs,g as Gm,bT as P2,bU as A2,F as _o,a2 as js,bV as M2,bW as Ym,a4 as Dl,j as pi,V as hi,bX as R2,bY as Xm,bZ as Xa,b_ as I2,b$ as $2,c0 as O2,a3 as Ll,R as zl,c1 as D2,c2 as L2,a7 as xs,E as Jm,c3 as z2,v as gi,c4 as xi,c5 as F2,c6 as B2,c7 as Zm,c8 as U2,c9 as W2,ca as br,cb as cs,a8 as la,af as Gd,e as Wo,cc as H2,ac as K2,cd as V2,ar as q2,w as vi,ce as G2,cf as Y2,cg as X2,ch as J2,ci as Z2,cj as Q2,ck as Qm,cl as ev,cm as tv,cn as nv,co as sv,ao as ov,r as Yd,cp as rv,cq as Xd,p as bi,cr as iv,cs as ep,d as tp,I as np,ct as av,ad as sp,u as lv,cu as cv,cv as op,L as dv,z as uv,cw as fv,cx as mv,s as rp,as as ip,y as pv,cy as hv,cz as gv,cA as xv,cB as vv,cC as bv,cD as Jd,cE as yv,am as wv,cF as jv,_ as Sv,cG as Nv}from"./vendor-ui-BmLOQ5Or.js";import{c as kv,a as Cv}from"./vendor-shiki-DOn6sF-i.js";import{r as yi,M as yn}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(o){if(o.ep)return;o.ep=!0;const i=t(o);fetch(o.href,i)}})();const _v="modulepreload",Tv=function(n){return"/"+n},Zd={},Ve=function(e,t,s){let o=Promise.resolve();if(t&&t.length>0){let a=function(d){return Promise.all(d.map(f=>Promise.resolve(f).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(t.map(d=>{if(d=Tv(d),d in Zd)return;Zd[d]=!0;const f=d.endsWith(".css"),u=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":_v,f||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),f)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return e().catch(i)})};function G(...n){return N0(k0(n))}const Ev=[{value:"",label:"Default"},{value:"fable",label:"Fable"},{value:"fable[1m]",label:"Fable 1M"},{value:"opus",label:"Opus"},{value:"opus[1m]",label:"Opus 1M"},{value:"sonnet",label:"Sonnet"},{value:"sonnet[1m]",label:"Sonnet 1M"},{value:"haiku",label:"Haiku"}],Fl=[{value:"low",label:"Light",description:"Fast responses with lighter reasoning"},{value:"medium",label:"Medium",description:"Balanced for everyday tasks"},{value:"high",label:"High",description:"Deeper reasoning for complex work"},{value:"xhigh",label:"Extra High",description:"Extra depth for difficult problems"},{value:"max",label:"Max",description:"Maximum reasoning depth"}],ap=[...Fl,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],yr=Fl.slice(0,4),mo=[{value:"priority",label:"Fast",description:"1.5× speed with increased usage"}],Qd={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:ap,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:mo},Pv=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",...Qd},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...Qd},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:ap,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:mo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:Fl,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:mo},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:yr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:mo},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:yr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:mo},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:yr,inputModalities:["text","image"],supportsPersonality:!0},{value:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",description:"Ultra-fast text-only coding model",defaultReasoningEffort:"high",supportedReasoningEfforts:yr,inputModalities:["text"],supportsPersonality:!0}],lp={claude:null,codex:null},Ja=new Set;function eu(n,e){!Array.isArray(e)||e.length===0||(lp[n]=e,Ja.forEach(t=>t()))}function Av(n){return Ja.add(n),()=>Ja.delete(n)}const ca="high",Mv=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function cp(n){return lp[n]??(n==="codex"?Pv:Ev)}function Ho(n,e){const t=cp(n);return e?t.find(s=>s.value===e):t.find(s=>s.value!==""&&s.isDefault)??t.find(s=>s.value==="")??t.find(s=>s.value!=="")}function dp(n,e){const t=Ho(n,e),s=t==null?void 0:t.supportedReasoningEfforts;return s&&s.length>0?s:(t==null?void 0:t.supportsEffort)===!1?[]:Mv}function Rv(n,e){var t;return((t=Ho(n,e))==null?void 0:t.serviceTiers)??[]}function up(n,e){return Rv(n,e).find(t=>t.value==="fast"||t.value==="priority"||t.label.toLowerCase()==="fast")}function Iv(n,e){var s;const t=(s=Ho(n,e))==null?void 0:s.inputModalities;return!t||t.includes("image")}function $v(n,e){var t;return n==="claude"&&((t=Ho(n,e))==null?void 0:t.supportsAutoMode)===!0}function Ov(n,e){return n!=="claude"?!1:!(e??"").toLowerCase().startsWith("haiku")}function wi(n,e,t){var l,c;const s=dp(n,t);if(s.length===0)return"";const o=(l=Ho(n,t))==null?void 0:l.defaultReasoningEffort,i=o&&s.some(d=>d.value===o)?o:s.some(d=>d.value===ca)?ca:((c=s[0])==null?void 0:c.value)??ca,a=e||i;return s.some(d=>d.value===a)?a:i}function Dv(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Ko(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}const Lv=Cn("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/20 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-7 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-7 rounded-md [&_svg:not([class*='size-'])]:size-3.5","icon-sm":"size-7","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function X(n){const e=F.c(12);let t,s,o,i;e[0]!==n?({className:t,variant:i,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e[5]!==t||e[6]!==o||e[7]!==i?(a=G(Lv({variant:i,size:o,className:t})),e[5]=t,e[6]=o,e[7]=i,e[8]=a):a=e[8];let l;return e[9]!==s||e[10]!==a?(l=r.jsx(C0,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function En(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Pn(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex max-w-sm flex-col items-center gap-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const zv=Cn("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function is(n){const e=F.c(11);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t||e[5]!==i?(a=G(zv({variant:i,className:t})),e[4]=t,e[5]=i,e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==a||e[9]!==i?(l=r.jsx("div",{"data-slot":"empty-icon","data-variant":i,className:a,...s}),e[7]=s,e[8]=a,e[9]=i,e[10]=l):l=e[10],l}function An(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm font-medium tracking-tight",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Mn(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function fp(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Fv(n){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e.appendChild(t),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}const Bv=n=>{switch(n){case"success":return Hv;case"info":return Vv;case"warning":return Kv;case"error":return qv;default:return null}},Uv=Array(12).fill(0),Wv=({visible:n,className:e})=>ge.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},ge.createElement("div",{className:"sonner-spinner"},Uv.map((t,s)=>ge.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),Hv=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ge.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Kv=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ge.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Vv=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ge.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),qv=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ge.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Gv=ge.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},ge.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ge.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Yv=()=>{const[n,e]=ge.useState(document.hidden);return ge.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let Xv=1;const Jv=100,tu=n=>{var e;return typeof(n==null?void 0:n.id)=="number"||(n==null||(e=n.id)==null?void 0:e.length)>0?n.id:Xv++};class Zv{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-Jv;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{const{message:t,...s}=e,o=tu(e),i=this.pendingDismissals.get(o);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(o),this.dismissedToasts.delete(o));const a=this.dismissedToasts.has(o),l=e.dismissible===void 0?!0:e.dismissible;return a&&(this.dismissedToasts.delete(o),this.toasts=this.toasts.filter(d=>d.id!==o)),(a?void 0:this.toasts.find(d=>d.id===o))?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...e,id:o,title:t}),{...d,...e,id:o,dismissible:l,title:t}):d):this.addToast({title:t,...s,dismissible:l,id:o}),o},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(s=>{this.dismissedToasts.add(s.id),this.subscribers.forEach(o=>o({id:s.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);const t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(s=>s({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;t.loading!==void 0&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));const o=Promise.resolve(e instanceof Function?e():e);let i=s!==void 0,a;const l=o.then(async d=>{if(a=["resolve",d],ge.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(eb(d)&&!d.ok){i=!1;const u=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description,h=typeof u=="object"&&!ge.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:m,...h})}else if(d instanceof Error){i=!1;const u=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof u=="object"&&!ge.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){i=!1;const u=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof u=="object"&&!ge.isValidElement(u)?u:{message:u};this.create({id:s,type:"success",description:m,...h})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){i=!1;const f=typeof t.error=="function"?await t.error(d):t.error,u=typeof t.description=="function"?await t.description(d):t.description,p=typeof f=="object"&&!ge.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:u,...p})}}).finally(()=>{i&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((d,f)=>l.then(()=>a[0]==="reject"?f(a[1]):d(a[1])).catch(f));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=tu(t);return this.create({...t,jsx:e(s),id:s,type:void 0}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}}const Ot=new Zv,Qv=(n,e)=>Ot.message(n,e),eb=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",tb=Qv,nb=()=>Ot.toasts,sb=()=>Ot.getActiveToasts(),ds=Object.assign(tb,{success:Ot.success,info:Ot.info,warning:Ot.warning,error:Ot.error,custom:Ot.custom,message:Ot.message,promise:Ot.promise,dismiss:Ot.dismiss,loading:Ot.loading},{getHistory:nb,getToasts:sb});Fv("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function wr(n){return n.label!==void 0}const ob=3,rb="24px",ib="16px",nu=4e3,ab=356,lb=14,cb=45,db=200;function hn(...n){return n.filter(Boolean).join(" ")}function ub(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const fb=n=>{var e,t,s,o,i,a,l,c,d;const{invert:f,toast:u,unstyled:m,interacting:p,setHeights:h,visibleToasts:g,heights:v,index:x,toasts:w,expanded:y,removeToast:j,defaultRichColors:N,closeButton:S,style:k,cancelButtonStyle:C,actionButtonStyle:T,className:_="",descriptionClassName:P="",duration:A,position:E,gap:M,expandByDefault:I,classNames:R,icons:D,closeButtonAriaLabel:L="Close toast"}=n,[$,z]=ge.useState(null),[U,O]=ge.useState(null),[H,B]=ge.useState(!1),[W,V]=ge.useState(!1),[q,Y]=ge.useState(!1),[K,J]=ge.useState(!1),[Z,Q]=ge.useState(!1),[se,ne]=ge.useState(0),[ee,ie]=ge.useState(0),oe=ge.useRef(u.duration||A||nu),re=ge.useRef(null),te=ge.useRef(null),ce=x===0,me=x+1<=g,pe=u.type,xe=pe??"default",we=u.dismissible!==!1,ae=u.className||"",ve=u.descriptionClassName||"",he=ge.useMemo(()=>v.findIndex(be=>be.toastId===u.id)||0,[v,u.id]),de=ge.useMemo(()=>{var be;return(be=u.closeButton)!=null?be:S},[u.closeButton,S]),Ne=ge.useMemo(()=>u.duration||A||nu,[u.duration,A]),ke=ge.useRef(0),Te=ge.useRef(0),Ae=ge.useRef(0),Pe=ge.useRef(null),[De,ze]=E.split("-"),Fe=ge.useMemo(()=>v.reduce((be,Ee,Ie)=>Ie>=he?be:be+Ee.height,0),[v,he]),ue=Yv(),le=ge.useMemo(()=>{var be;return(be=n.swipeDirections)!=null?be:ub(E)},[n.swipeDirections,E]),Me=u.invert||f,Le=pe==="loading";Te.current=ge.useMemo(()=>he*M+Fe,[he,Fe]),ge.useEffect(()=>{oe.current=Ne},[Ne]),ge.useEffect(()=>{B(!0)},[]),ge.useEffect(()=>{const be=te.current;if(be){const Ee=be.getBoundingClientRect().height;return ie(Ee),h(Ie=>[{toastId:u.id,height:Ee,position:u.position},...Ie]),()=>h(Ie=>Ie.filter(Ue=>Ue.toastId!==u.id))}},[h,u.id]),ge.useLayoutEffect(()=>{if(!H)return;const be=te.current,Ee=be.style.height;be.style.height="auto";const Ie=be.getBoundingClientRect().height;be.style.height=Ee,ie(Ie),h(Ue=>Ue.find(qe=>qe.toastId===u.id)?Ue.map(qe=>qe.toastId===u.id?{...qe,height:Ie}:qe):[{toastId:u.id,height:Ie,position:u.position},...Ue])},[H,u.title,u.description,h,u.id,u.jsx,u.action,u.cancel]);const je=ge.useCallback(()=>{V(!0),ne(Te.current),h(be=>be.filter(Ee=>Ee.toastId!==u.id)),setTimeout(()=>{j(u)},db)},[u,j,h,Te]);ge.useEffect(()=>{if(u.promise&&pe==="loading"||u.duration===1/0||u.type==="loading")return;let be;return y||p||ue?(()=>{if(Ae.current<ke.current){const Ue=new Date().getTime()-ke.current;oe.current=oe.current-Ue}Ae.current=new Date().getTime()})():(()=>{oe.current!==1/0&&(ke.current=new Date().getTime(),be=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),je()},oe.current))})(),()=>clearTimeout(be)},[y,p,u,pe,ue,je]),ge.useEffect(()=>{u.delete&&(je(),u.onDismiss==null||u.onDismiss.call(u,u))},[je,u.delete]);function fe(){var be;if(D!=null&&D.loading){var Ee;return ge.createElement("div",{className:hn(R==null?void 0:R.loader,u==null||(Ee=u.classNames)==null?void 0:Ee.loader,"sonner-loader"),"data-visible":pe==="loading"},D.loading)}return ge.createElement(Wv,{className:hn(R==null?void 0:R.loader,u==null||(be=u.classNames)==null?void 0:be.loader),visible:pe==="loading"})}const Ce=u.icon||(D==null?void 0:D[pe])||Bv(pe);var _e,Be;return ge.createElement("li",{tabIndex:0,ref:te,className:hn(_,ae,R==null?void 0:R.toast,u==null||(e=u.classNames)==null?void 0:e.toast,R==null?void 0:R[xe],u==null||(t=u.classNames)==null?void 0:t[xe]),"data-sonner-toast":"","data-rich-colors":(_e=u.richColors)!=null?_e:N,"data-styled":!(u.jsx||u.unstyled||m),"data-mounted":H,"data-promise":!!u.promise,"data-swiped":Z,"data-removed":W,"data-visible":me,"data-y-position":De,"data-x-position":ze,"data-index":x,"data-front":ce,"data-swiping":q,"data-dismissible":we,"data-type":pe,"data-invert":Me,"data-swipe-out":K,"data-swipe-direction":U,"data-expanded":!!(y||I&&H),"data-testid":u.testId,style:{"--index":x,"--toasts-before":x,"--z-index":w.length-x,"--offset":`${W?se:Te.current}px`,"--initial-height":I?"auto":`${ee}px`,...k,...u.style},onDragEnd:()=>{Y(!1),z(null),Pe.current=null},onPointerDown:be=>{be.button!==2&&(Le||!we||(re.current=new Date,ne(Te.current),be.target.setPointerCapture(be.pointerId),be.target.tagName!=="BUTTON"&&(Y(!0),Pe.current={x:be.clientX,y:be.clientY})))},onPointerUp:()=>{var be,Ee,Ie;if(K||!we)return;Pe.current=null;const Ue=Number(((be=te.current)==null?void 0:be.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Je=Number(((Ee=te.current)==null?void 0:Ee.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),qe=new Date().getTime()-((Ie=re.current)==null?void 0:Ie.getTime()),Ze=$==="x"?Ue:Je,Ke=Math.abs(Ze)/qe;if(($==="x"?le.includes(Ue>0?"right":"left"):le.includes(Je>0?"bottom":"top"))&&(Math.abs(Ze)>=cb||Ke>.11)){ne(Te.current),u.onDismiss==null||u.onDismiss.call(u,u),O($==="x"?Ue>0?"right":"left":Je>0?"down":"up"),je(),J(!0);return}else{var He,$e;(He=te.current)==null||He.style.setProperty("--swipe-amount-x","0px"),($e=te.current)==null||$e.style.setProperty("--swipe-amount-y","0px")}Q(!1),Y(!1),z(null)},onPointerMove:be=>{var Ee,Ie,Ue;if(!Pe.current||!we||((Ee=window.getSelection())==null?void 0:Ee.toString().length)>0)return;const qe=be.clientY-Pe.current.y,Ze=be.clientX-Pe.current.x;!$&&(Math.abs(Ze)>1||Math.abs(qe)>1)&&z(Math.abs(Ze)>Math.abs(qe)?"x":"y");let Ke={x:0,y:0};const Re=He=>1/(1.5+Math.abs(He)/20);if($==="y"){if(le.includes("top")||le.includes("bottom"))if(le.includes("top")&&qe<0||le.includes("bottom")&&qe>0)Ke.y=qe;else{const He=qe*Re(qe);Ke.y=Math.abs(He)<Math.abs(qe)?He:qe}}else if($==="x"&&(le.includes("left")||le.includes("right")))if(le.includes("left")&&Ze<0||le.includes("right")&&Ze>0)Ke.x=Ze;else{const He=Ze*Re(Ze);Ke.x=Math.abs(He)<Math.abs(Ze)?He:Ze}(Math.abs(Ke.x)>0||Math.abs(Ke.y)>0)&&Q(!0),(Ie=te.current)==null||Ie.style.setProperty("--swipe-amount-x",`${Ke.x}px`),(Ue=te.current)==null||Ue.style.setProperty("--swipe-amount-y",`${Ke.y}px`)}},de&&!u.jsx&&pe!=="loading"?ge.createElement("button",{"aria-label":L,"data-disabled":Le,"data-close-button":!0,onClick:Le||!we?()=>{}:()=>{je(),u.onDismiss==null||u.onDismiss.call(u,u)},className:hn(R==null?void 0:R.closeButton,u==null||(s=u.classNames)==null?void 0:s.closeButton)},(Be=D==null?void 0:D.close)!=null?Be:Gv):null,(pe||u.icon||u.promise)&&u.icon!==null&&((D==null?void 0:D[pe])!==null||u.icon)?ge.createElement("div",{"data-icon":"",className:hn(R==null?void 0:R.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},pe==="loading"?u.icon||fe():u.promise?fe():null,pe!=="loading"?Ce:null):null,ge.createElement("div",{"data-content":"",className:hn(R==null?void 0:R.content,u==null||(i=u.classNames)==null?void 0:i.content)},ge.createElement("div",{"data-title":"",className:hn(R==null?void 0:R.title,u==null||(a=u.classNames)==null?void 0:a.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?ge.createElement("div",{"data-description":"",className:hn(P,ve,R==null?void 0:R.description,u==null||(l=u.classNames)==null?void 0:l.description)},typeof u.description=="function"?u.description():u.description):null),ge.isValidElement(u.cancel)?u.cancel:u.cancel&&wr(u.cancel)?ge.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||C,onClick:be=>{wr(u.cancel)&&we&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,be),je())},className:hn(R==null?void 0:R.cancelButton,u==null||(c=u.classNames)==null?void 0:c.cancelButton)},u.cancel.label):null,ge.isValidElement(u.action)?u.action:u.action&&wr(u.action)?ge.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||T,onClick:be=>{wr(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,be),!be.defaultPrevented&&je())},className:hn(R==null?void 0:R.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function su(){if(typeof window>"u"||typeof document>"u")return"ltr";const n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function mb(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?ib:rb;function c(d){["top","right","bottom","left"].forEach(f=>{t[`${a}-${f}`]=typeof d=="number"?`${d}px`:d})}typeof s=="number"||typeof s=="string"?c(s):typeof s=="object"?["top","right","bottom","left"].forEach(d=>{s[d]===void 0?t[`${a}-${d}`]=l:t[`${a}-${d}`]=typeof s[d]=="number"?`${s[d]}px`:s[d]}):c(l)}),t}const pb=ge.forwardRef(function(e,t){const{id:s,invert:o,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:f,mobileOffset:u,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:v=ob,toastOptions:x,dir:w=su(),gap:y=lb,icons:j,customAriaLabel:N,containerAriaLabel:S="Notifications"}=e,[k,C]=ge.useState([]),T=ge.useMemo(()=>s?k.filter(B=>B.toasterId===s):k.filter(B=>!B.toasterId),[k,s]),_=ge.useMemo(()=>Array.from(new Set([i].concat(T.filter(B=>B.position).map(B=>B.position)))),[T,i]),[P,A]=ge.useState([]),[E,M]=ge.useState(!1),[I,R]=ge.useState(!1),[D,L]=ge.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=ge.useRef(null),z=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),U=ge.useRef(null),O=ge.useRef(!1),H=ge.useCallback(B=>{C(W=>{var V;return(V=W.find(q=>q.id===B.id))!=null&&V.delete||Ot.dismiss(B.id),W.filter(({id:q})=>q!==B.id)})},[]);return ge.useEffect(()=>Ot.subscribe(B=>{if(B.dismiss){requestAnimationFrame(()=>{C(W=>W.map(V=>V.id===B.id?{...V,delete:!0}:V))});return}setTimeout(()=>{w0.flushSync(()=>{C(W=>{const V=W.findIndex(q=>q.id===B.id);return V!==-1?[...W.slice(0,V),{...W[V],...B},...W.slice(V+1)]:[B,...W]})})})}),[]),ge.useEffect(()=>{if(m!=="system"){L(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),typeof window>"u")return;const B=window.matchMedia("(prefers-color-scheme: dark)");try{B.addEventListener("change",({matches:W})=>{L(W?"dark":"light")})}catch{B.addListener(({matches:V})=>{try{L(V?"dark":"light")}catch(q){console.error(q)}})}},[m]),ge.useEffect(()=>{k.length<=1&&M(!1)},[k]),ge.useEffect(()=>{const B=W=>{var V;if(a.length>0&&a.every(K=>W[K]||W.code===K)){var Y;M(!0),(Y=$.current)==null||Y.focus()}W.code==="Escape"&&(document.activeElement===$.current||(V=$.current)!=null&&V.contains(document.activeElement))&&M(!1)};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[a]),ge.useEffect(()=>{if($.current)return()=>{U.current&&(U.current.focus({preventScroll:!0}),U.current=null,O.current=!1)}},[$.current]),ge.createElement("section",{ref:t,"aria-label":N??`${S} ${z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},_.map((B,W)=>{var V;const[q,Y]=B.split("-");return T.length?ge.createElement("ol",{key:B,dir:w==="auto"?su():w,tabIndex:-1,ref:$,className:d,"data-sonner-toaster":!0,"data-sonner-theme":D,"data-y-position":q,"data-x-position":Y,style:{"--front-toast-height":`${((V=P[0])==null?void 0:V.height)||0}px`,"--width":`${ab}px`,"--gap":`${y}px`,...g,...mb(f,u)},onBlur:K=>{O.current&&!K.currentTarget.contains(K.relatedTarget)&&(O.current=!1,U.current&&(U.current.focus({preventScroll:!0}),U.current=null))},onFocus:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||O.current||(O.current=!0,U.current=K.relatedTarget)},onMouseEnter:()=>M(!0),onMouseMove:()=>M(!0),onMouseLeave:()=>{I||M(!1)},onDragEnd:()=>M(!1),onPointerDown:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},T.filter(K=>!K.position&&W===0||K.position===B).map((K,J)=>{var Z,Q;return ge.createElement(fb,{key:K.id,icons:j,index:J,toast:K,defaultRichColors:p,duration:(Z=x==null?void 0:x.duration)!=null?Z:h,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:o,visibleToasts:v,closeButton:(Q=x==null?void 0:x.closeButton)!=null?Q:c,interacting:I,position:B,style:x==null?void 0:x.style,unstyled:x==null?void 0:x.unstyled,classNames:x==null?void 0:x.classNames,cancelButtonStyle:x==null?void 0:x.cancelButtonStyle,actionButtonStyle:x==null?void 0:x.actionButtonStyle,closeButtonAriaLabel:x==null?void 0:x.closeButtonAriaLabel,removeToast:H,toasts:T.filter(se=>se.position==K.position),heights:P.filter(se=>se.position==K.position),setHeights:A,expandByDefault:l,gap:y,expanded:E,swipeDirections:e.swipeDirections})})):null}))}),hb=n=>{const e=F.c(6);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s,o;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={success:r.jsx(_n,{className:"size-4"}),info:r.jsx(T0,{className:"size-4"}),warning:r.jsx(fn,{className:"size-4"}),error:r.jsx(_0,{className:"size-4"}),loading:r.jsx(lt,{className:"size-4 animate-spin"})},o={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},e[2]=s,e[3]=o):(s=e[2],o=e[3]);let i;return e[4]!==t?(i=r.jsx(pb,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function gb(n){const e=F.c(13),{activeError:t,clearActiveError:s,modelFallbackNotice:o,dismissModelFallbackNotice:i,connectionLost:a,theme:l}=n;let c,d;e[0]!==t||e[1]!==s?(c=()=>{if(!t){ds.dismiss("app-error");return}ds.error(t,{id:"app-error",duration:8e3,onDismiss:s,onAutoClose:s})},d=[t,s],e[0]=t,e[1]=s,e[2]=c,e[3]=d):(c=e[2],d=e[3]),b.useEffect(c,d);let f,u;e[4]!==i||e[5]!==o?(f=()=>{if(!o){ds.dismiss("model-fallback");return}ds.warning(o,{id:"model-fallback",duration:1/0,onDismiss:i})},u=[i,o],e[4]=i,e[5]=o,e[6]=f,e[7]=u):(f=e[6],u=e[7]),b.useEffect(f,u);let m,p;e[8]!==a?(m=()=>{if(!a){ds.dismiss("session-connection");return}ds.warning("Connection lost",{id:"session-connection",description:"Reconnecting to the live session…",duration:1/0})},p=[a],e[8]=a,e[9]=m,e[10]=p):(m=e[9],p=e[10]),b.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(hb,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const gt="local",mp="cogpit-last-path::",Za=new Map;function ut(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return gt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:gt}function vs(){return ut()!==gt}function pp(){const n=ut();return n===gt?"":`/hub/${n}`}function hp(n){const e=pp();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")?`${e}${n}`:n}let To=null;function gp(n){n!==To&&(To=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function Zn(){return To}function Or(n){return n===gt?0:Za.get(n)??0}function xb(n,e){if(n===gt||!Number.isSafeInteger(e)||e<0)return!1;const t=Za.get(n);return t!==void 0&&e<=t?!1:(Za.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function nn(){const n=ut(),e=Or(n);return e===0?n:`${n}@${e}`}function Mt(n){const e=ut(),t=nn();return To!==null?`${n}::${t}::${To}`:e===gt?n:`${n}::${t}`}function so(n,e){sessionStorage.setItem(`${mp}${n}`,e)}function Qn(n){const t=sessionStorage.getItem(`${mp}${n}`)??(n===gt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const ou="cogpit-network-token",vb=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function ji(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!vb.has(e)}function Si(){try{localStorage.removeItem(ou),sessionStorage.removeItem(ou)}catch{}}typeof window<"u"&&Si();const bb={edition:"personal",needsBootstrap:!1};let Eo=null,Bs=null;function xp(){return fetch("/api/hello",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}}).then(async n=>{if(!n.ok)throw new Error(`Hello handshake failed (${n.status})`);const e=await n.json();return Bs=e.edition==="team"?"team":"personal",{edition:Bs,needsBootstrap:Bs==="team"&&e.needsBootstrap===!0}}).catch(()=>(Eo=null,bb))}function vp(){return Eo??(Eo=xp()),Eo}function ru(){return Eo=xp(),Eo}function bp(){return vp().then(n=>n.edition)}async function yb(){if(!ji()&&Bs!=="team")return!0;try{return(await fetch("/api/auth/session",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})).ok}catch{return!1}}async function wb(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Si()}}function iu(){return Si(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function yp(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=hp(n));const s=new Headers(e==null?void 0:e.headers);return s.delete("Authorization"),s.set("X-Cogpit-Client","1"),fetch(n,{...e,headers:s,credentials:"same-origin"}).then(o=>{if(o.status===401){if(ji()||Bs==="team")return iu();if(Bs===null)return bp().then(i=>i==="team"?iu():o)}if(o.status===502){const i=o.headers.get("X-Cogpit-Device");i&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:i}}))}return o})}function ye(n,e){return yp(n,e,!0)}function Kn(n,e){return yp(n,e,!1)}function Vo(n){return hp(n)}let au=!1;function lu(n){return Array.isArray(n)&&n.length>0&&n.every(e=>e&&typeof e=="object"&&typeof e.value=="string"&&typeof e.label=="string")}async function jb(){if(!au){au=!0;try{const n=await ye("/api/models");if(!n.ok)return;const e=await n.json();lu(e==null?void 0:e.claude)&&eu("claude",e.claude),lu(e==null?void 0:e.codex)&&eu("codex",e.codex)}catch{}}}function wp(n){const e=F.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],b.useEffect(Sb,t);let s;return e[1]!==n?(s=()=>cp(n),e[1]=n,e[2]=s):s=e[2],b.useSyncExternalStore(Av,s)}function Sb(){jb()}function Rn(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(P0,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function In(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(A0,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function $n(n){const e=F.c(18);let t,s,o,i,a,l;e[0]!==n?({align:o,alignOffset:i,side:a,sideOffset:l,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?0:i,f=a===void 0?"bottom":a,u=l===void 0?4:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(Lm,{"data-slot":"dropdown-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==u||e[16]!==p?(h=r.jsx(Fm,{children:r.jsx(Bm,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:f,sideOffset:u,children:p})}),e[12]=c,e[13]=d,e[14]=f,e[15]=u,e[16]=p,e[17]=h):h=e[17],h}function Lt(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Dm,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function es(n){const e=F.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(zm,{"data-slot":"dropdown-menu-label","data-inset":s,className:i,...o}),e[6]=s,e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function it(n){const e=F.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=G("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l||e[10]!==a?(c=r.jsx(Om,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":a,className:l,...o}),e[7]=s,e[8]=o,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function Nb(n){const e=F.c(15);let t,s,o,i,a;e[0]!==n?({className:o,children:s,checked:t,inset:i,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);let l;e[6]!==o?(l=G("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o),e[6]=o,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:r.jsx($0,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",children:r.jsx(rt,{})})}),e[8]=c):c=e[8];let d;return e[9]!==t||e[10]!==s||e[11]!==i||e[12]!==a||e[13]!==l?(d=r.jsxs(R0,{"data-slot":"dropdown-menu-checkbox-item","data-inset":i,className:l,checked:t,...a,children:[c,s]}),e[9]=t,e[10]=s,e[11]=i,e[12]=a,e[13]=l,e[14]=d):d=e[14],d}function Wr(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(I0,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Bl(n){const e=F.c(15);let t,s,o,i,a;e[0]!==n?({className:s,children:t,inset:o,closeOnClick:a,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=a===void 0?!0:a;let c;e[6]!==s?(c=G("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[6]=s,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:r.jsx(M0,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",children:r.jsx(rt,{})})}),e[8]=d):d=e[8];let f;return e[9]!==t||e[10]!==l||e[11]!==o||e[12]!==i||e[13]!==c?(f=r.jsxs(E0,{"data-slot":"dropdown-menu-radio-item","data-inset":o,closeOnClick:l,className:c,...i,children:[d,t]}),e[9]=t,e[10]=l,e[11]=o,e[12]=i,e[13]=c,e[14]=f):f=e[14],f}function Us(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(El,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const jp=[{value:"claude",label:"Claude",Icon:zo},{value:"codex",label:"Codex",Icon:Fo}];function Qa(n,e){const t=e==null?void 0:e.find(o=>o.value!==""&&o.value===n);if(t)return t.label;const s=n.toLowerCase();if(s.includes("opus"))return"Opus";if(s.includes("sonnet"))return"Sonnet";if(s.includes("haiku"))return"Haiku";if(s.includes("fable"))return"Fable";if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ");return`GPT-${o}${a?` ${a}`:""}`}return n}function Sp(n){const e=F.c(11),{option:t,descriptionWidth:s}=n,o=s===void 0?"max-w-64":s,i=t.menuLabel??t.label;let a;e[0]!==i?(a=r.jsx("span",{children:i}),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==o||e[3]!==t.description?(l=t.description&&r.jsx("span",{className:G(o,"truncate text-xs font-normal text-muted-foreground"),children:t.description}),e[2]=o,e[3]=t.description,e[4]=l):l=e[4];let c;e[5]!==a||e[6]!==l?(c=r.jsxs("span",{className:"flex min-w-0 flex-col items-start",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7];let d;return e[8]!==t.value||e[9]!==c?(d=r.jsx(Bl,{value:t.value,className:"items-start py-2",children:c}),e[8]=t.value,e[9]=c,e[10]=d):d=e[10],d}function kb(n){var _;const e=F.c(31),{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}=n,c=t==="codex"?"Codex":"Claude";let d;e[0]!==i||e[1]!==a||e[2]!==o?(d=((_=a.find(P=>P.value===o))==null?void 0:_.label)??i,e[0]=i,e[1]=a,e[2]=o,e[3]=d):d=e[3];const f=d;let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(X,{type:"button",variant:"ghost",size:"xs"}),e[4]=u):u=e[4];const m=`${c} / ${f}`;let p;e[5]!==m?(p=r.jsx("span",{className:"truncate",children:m}),e[5]=m,e[6]=p):p=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(nt,{"data-icon":"inline-end"}),e[7]=h):h=e[7];let g;e[8]!==p?(g=r.jsxs(In,{render:u,children:[p,h]}),e[8]=p,e[9]=g):g=e[9];let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(es,{children:"Agent"}),e[10]=v):v=e[10];let x;e[11]!==s?(x=P=>s(P),e[11]=s,e[12]=x):x=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=jp.map(_b),e[13]=w):w=e[13];let y;e[14]!==t||e[15]!==x?(y=r.jsxs(Lt,{children:[v,r.jsx(Wr,{value:t,onValueChange:x,children:w})]}),e[14]=t,e[15]=x,e[16]=y):y=e[16];let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Us,{}),e[17]=j):j=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(es,{children:"Model"}),e[18]=N):N=e[18];let S;e[19]!==a?(S=a.map(Cb),e[19]=a,e[20]=S):S=e[20];let k;e[21]!==l||e[22]!==S||e[23]!==o?(k=r.jsxs(Lt,{children:[N,r.jsx(Wr,{value:o,onValueChange:l,children:S})]}),e[21]=l,e[22]=S,e[23]=o,e[24]=k):k=e[24];let C;e[25]!==y||e[26]!==k?(C=r.jsxs($n,{"aria-label":"Agent and model",className:"w-72",children:[y,j,k]}),e[25]=y,e[26]=k,e[27]=C):C=e[27];let T;return e[28]!==C||e[29]!==g?(T=r.jsxs(Rn,{children:[g,C]}),e[28]=C,e[29]=g,e[30]=T):T=e[30],T}function Cb(n){return r.jsx(Sp,{option:n,descriptionWidth:"max-w-72"},n.value)}function _b(n){const e=n.Icon;return r.jsxs(Bl,{value:n.value,children:[r.jsx(e,{}),n.label]},n.value)}function Tb(n){const e=F.c(44),{servers:t,selected:s,onToggle:o,onRefresh:i,loading:a,onAuth:l}=n;let c;e[0]!==t?(c=t.filter(Eb),e[0]=t,e[1]=c):c=e[1];const d=c.length;let f;e[2]!==s?(f=new Set(s),e[2]=s,e[3]=f):f=e[3];const u=f,m=b.useId();let p,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(X,{type:"button",variant:"ghost",size:"xs"}),h=r.jsx(O0,{"data-icon":"inline-start"}),e[4]=p,e[5]=h):(p=e[4],h=e[5]);const g=a&&t.length===0?"MCPs":`MCPs ${s.length}/${d}`;let v;e[6]!==g?(v=r.jsx("span",{className:"truncate",children:g}),e[6]=g,e[7]=v):v=e[7];let x;e[8]!==a||e[9]!==t.length?(x=a&&t.length===0?r.jsx(Ht,{"data-icon":"inline-end",className:"animate-spin"}):r.jsx(nt,{"data-icon":"inline-end"}),e[8]=a,e[9]=t.length,e[10]=x):x=e[10];let w;e[11]!==v||e[12]!==x?(w=r.jsxs(In,{render:p,children:[h,v,x]}),e[11]=v,e[12]=x,e[13]=w):w=e[13];let y;e[14]!==m?(y=r.jsx(es,{id:m,children:"MCP servers"}),e[14]=m,e[15]=y):y=e[15];const j=a?"animate-spin":void 0;let N;e[16]!==j?(N=r.jsx(Ht,{"data-icon":"inline-start",className:j}),e[16]=j,e[17]=N):N=e[17];let S;e[18]!==i||e[19]!==N?(S=r.jsxs(it,{closeOnClick:!1,onClick:i,children:[N,"Refresh status"]}),e[18]=i,e[19]=N,e[20]=S):S=e[20];let k;e[21]!==a||e[22]!==t.length?(k=t.length===0&&r.jsx(it,{disabled:!0,children:a?"Loading...":"No MCP servers configured"}),e[21]=a,e[22]=t.length,e[23]=k):k=e[23];let C;if(e[24]!==l||e[25]!==o||e[26]!==u||e[27]!==t){let A;e[29]!==l||e[30]!==o||e[31]!==u?(A=E=>E.status!=="connected"?r.jsxs(it,{onClick:()=>l(E.name),className:"items-center",children:[r.jsx("span",{className:"size-2 rounded-full bg-warning"}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name}),r.jsx("span",{className:"text-xs text-warning",children:"Needs auth"})]},E.name):r.jsxs(Nb,{checked:u.has(E.name),onCheckedChange:()=>o(E.name),children:[r.jsx("span",{className:"size-2 rounded-full bg-success"}),r.jsx("span",{className:"truncate",children:E.name})]},E.name),e[29]=l,e[30]=o,e[31]=u,e[32]=A):A=e[32],C=t.map(A),e[24]=l,e[25]=o,e[26]=u,e[27]=t,e[28]=C}else C=e[28];let T;e[33]!==S||e[34]!==k||e[35]!==C||e[36]!==y?(T=r.jsxs(Lt,{children:[y,S,k,C]}),e[33]=S,e[34]=k,e[35]=C,e[36]=y,e[37]=T):T=e[37];let _;e[38]!==m||e[39]!==T?(_=r.jsx($n,{"aria-labelledby":m,className:"w-64",children:T}),e[38]=m,e[39]=T,e[40]=_):_=e[40];let P;return e[41]!==_||e[42]!==w?(P=r.jsxs(Rn,{children:[w,_]}),e[41]=_,e[42]=w,e[43]=P):P=e[43],P}function Eb(n){return n.status==="connected"}function cu(n){var S;const e=F.c(31),{value:t,fallbackLabel:s,options:o,onChange:i,disabled:a,title:l,ariaLabel:c}=n;let d;e[0]!==s||e[1]!==o||e[2]!==t?(d=((S=o.find(k=>k.value===t))==null?void 0:S.label)??s,e[0]=s,e[1]=o,e[2]=t,e[3]=d):d=e[3];const f=d,u=b.useId();let m;e[4]!==l?(m=r.jsx(X,{type:"button",variant:"ghost",size:"xs",title:l}),e[4]=l,e[5]=m):m=e[5];let p;e[6]!==f?(p=r.jsx("span",{className:"truncate",children:f}),e[6]=f,e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(nt,{"data-icon":"inline-end"}),e[8]=h):h=e[8];let g;e[9]!==a||e[10]!==m||e[11]!==p?(g=r.jsxs(In,{disabled:a,render:m,children:[p,h]}),e[9]=a,e[10]=m,e[11]=p,e[12]=g):g=e[12];let v;e[13]!==c||e[14]!==u?(v=r.jsx(es,{id:u,className:"sr-only",children:c}),e[13]=c,e[14]=u,e[15]=v):v=e[15];let x;e[16]!==o?(x=o.map(Pb),e[16]=o,e[17]=x):x=e[17];let w;e[18]!==i||e[19]!==x||e[20]!==t?(w=r.jsx(Wr,{value:t,onValueChange:i,children:x}),e[18]=i,e[19]=x,e[20]=t,e[21]=w):w=e[21];let y;e[22]!==v||e[23]!==w?(y=r.jsxs(Lt,{children:[v,w]}),e[22]=v,e[23]=w,e[24]=y):y=e[24];let j;e[25]!==u||e[26]!==y?(j=r.jsx($n,{"aria-labelledby":u,className:"w-48",children:y}),e[25]=u,e[26]=y,e[27]=j):j=e[27];let N;return e[28]!==j||e[29]!==g?(N=r.jsxs(Rn,{children:[g,j]}),e[28]=j,e[29]=g,e[30]=N):N=e[30],N}function Pb(n){return r.jsx(Sp,{option:n},n.value)}const Ab=[{value:"default",label:"Ask",description:"Ask before sensitive actions"},{value:"plan",label:"Plan",description:"Read and plan without changing files"},{value:"acceptEdits",label:"Accept Edits",description:"Allow file edits; ask for other actions"},{value:"auto",label:"Auto",description:"Run autonomously with classifier safeguards"},{value:"dontAsk",label:"Don't Ask",description:"Deny actions that need approval"},{value:"bypassPermissions",label:"Full access",description:"Skip permission checks"}],Mb=[{value:"default",label:"Workspace",description:"Write inside the project sandbox"},{value:"plan",label:"Read only",description:"Inspect and plan without writing"},{value:"bypassPermissions",label:"Full access",description:"No sandbox or approval checks"}];function Np(n,e){return n==="codex"?Mb:Ab.filter(t=>t.value!=="auto"||e)}function Rb(n){const e=F.c(39),{agentKind:t,mode:s,onChange:o,autoAvailable:i}=n,a=i===void 0?!1:i;let l,c,d,f,u,m,p,h,g,v,x;if(e[0]!==t||e[1]!==a||e[2]!==s||e[3]!==o){const S=Np(t,a),k=S.find(P=>P.value===s)??S[0];f=Rn;let C,T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(X,{type:"button",variant:"ghost",size:"xs"}),C=r.jsx(Um,{"data-icon":"inline-start"}),e[15]=C,e[16]=T):(C=e[15],T=e[16]);let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(nt,{"data-icon":"inline-end"}),e[17]=_):_=e[17],x=r.jsxs(In,{render:T,children:[C,r.jsx("span",{className:"truncate",children:k.label}),_]}),d=$n,g="Access policy",v="w-72",c=Lt,e[18]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(es,{children:"Permissions"}),e[18]=h):h=e[18],l=Wr,u=s,e[19]!==o?(m=P=>o(P),e[19]=o,e[20]=m):m=e[20],p=S.map(Ib),e[0]=t,e[1]=a,e[2]=s,e[3]=o,e[4]=l,e[5]=c,e[6]=d,e[7]=f,e[8]=u,e[9]=m,e[10]=p,e[11]=h,e[12]=g,e[13]=v,e[14]=x}else l=e[4],c=e[5],d=e[6],f=e[7],u=e[8],m=e[9],p=e[10],h=e[11],g=e[12],v=e[13],x=e[14];let w;e[21]!==l||e[22]!==u||e[23]!==m||e[24]!==p?(w=r.jsx(l,{value:u,onValueChange:m,children:p}),e[21]=l,e[22]=u,e[23]=m,e[24]=p,e[25]=w):w=e[25];let y;e[26]!==c||e[27]!==h||e[28]!==w?(y=r.jsxs(c,{children:[h,w]}),e[26]=c,e[27]=h,e[28]=w,e[29]=y):y=e[29];let j;e[30]!==d||e[31]!==y||e[32]!==g||e[33]!==v?(j=r.jsx(d,{"aria-label":g,className:v,children:y}),e[30]=d,e[31]=y,e[32]=g,e[33]=v,e[34]=j):j=e[34];let N;return e[35]!==f||e[36]!==j||e[37]!==x?(N=r.jsxs(f,{children:[x,j]}),e[35]=f,e[36]=j,e[37]=x,e[38]=N):N=e[38],N}function Ib(n){return r.jsx(Bl,{value:n.value,className:"items-start py-2",children:r.jsxs("span",{className:"flex min-w-0 flex-col items-start",children:[r.jsx("span",{children:n.label}),r.jsx("span",{className:"max-w-64 truncate text-xs font-normal text-muted-foreground",children:n.description})]})},n.value)}function $b(n){const e=F.c(60),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:f,fastTier:u,fastModeEnabled:m,onFastModeEnabledChange:p,isNewSession:h,worktreeEnabled:g,onWorktreeEnabledChange:v,ultracodeEnabled:x,onUltracodeEnabledChange:w,autoModeAvailable:y,permissionMode:j,onPermissionModeChange:N,mcpServers:S,selectedMcpServers:k,onToggleMcpServer:C,onRefreshMcpServers:T,mcpLoading:_,onMcpAuth:P,changeAndApply:A,trailingExtra:E}=n,M=t==="claude",I=b.useId(),R=h?void 0:t==="claude"?"Changes apply live":"Changes apply next turn",D=R?I:void 0;let L;e[0]!==R||e[1]!==I?(L=R&&r.jsx("span",{id:I,className:"sr-only",children:R}),e[0]=R,e[1]=I,e[2]=L):L=e[2];let $;e[3]!==t||e[4]!==a||e[5]!==s||e[6]!==l||e[7]!==i||e[8]!==o?($=s?r.jsx(kb,{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}):r.jsx(cu,{value:o,fallbackLabel:"Model",ariaLabel:"Model",options:a,onChange:l}),e[3]=t,e[4]=a,e[5]=s,e[6]=l,e[7]=i,e[8]=o,e[9]=$):$=e[9];let z;e[10]!==t||e[11]!==d||e[12]!==f||e[13]!==c||e[14]!==o||e[15]!==x?(z=d.length>0&&r.jsx(cu,{value:wi(t,c,o),fallbackLabel:"Effort",ariaLabel:"Reasoning effort",options:d,onChange:f,disabled:x,title:x?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[10]=t,e[11]=d,e[12]=f,e[13]=c,e[14]=o,e[15]=x,e[16]=z):z=e[16];let U;e[17]!==A||e[18]!==m||e[19]!==u||e[20]!==p?(U=u&&p&&r.jsxs(X,{type:"button",variant:m?"secondary":"ghost",size:"xs","aria-pressed":!!m,onClick:()=>A(()=>p(!m)),title:u.description,children:[r.jsx(Ur,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]}),e[17]=A,e[18]=m,e[19]=u,e[20]=p,e[21]=U):U=e[21];let O;e[22]!==t||e[23]!==y||e[24]!==A||e[25]!==N||e[26]!==j?(O=N&&j&&r.jsx(Rb,{agentKind:t,mode:j,onChange:Y=>A(()=>N(Y)),autoAvailable:y}),e[22]=t,e[23]=y,e[24]=A,e[25]=N,e[26]=j,e[27]=O):O=e[27];let H;e[28]!==h||e[29]!==v||e[30]!==M||e[31]!==g?(H=M&&h&&v&&r.jsxs(X,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>v(!g),children:[r.jsx(Xs,{"data-icon":"inline-start"}),"Worktree"]}),e[28]=h,e[29]=v,e[30]=M,e[31]=g,e[32]=H):H=e[32];let B;e[33]!==A||e[34]!==w||e[35]!==M||e[36]!==x?(B=M&&w&&r.jsxs(X,{type:"button",variant:x?"secondary":"ghost",size:"xs","aria-pressed":!!x,onClick:()=>A(()=>w(!x)),title:"Ultracode: XHigh effort + standing multi-agent workflow orchestration",children:[r.jsx(Ur,{"data-icon":"inline-start",className:G(x&&"fill-current")}),"Ultracode"]}),e[33]=A,e[34]=w,e[35]=M,e[36]=x,e[37]=B):B=e[37];let W;e[38]!==A||e[39]!==_||e[40]!==S||e[41]!==P||e[42]!==T||e[43]!==C||e[44]!==k?(W=C&&T&&P&&(_||S&&S.length>0)&&r.jsx(Tb,{servers:S??[],selected:k??[],onToggle:Y=>A(()=>C(Y)),onRefresh:T,loading:_??!1,onAuth:P}),e[38]=A,e[39]=_,e[40]=S,e[41]=P,e[42]=T,e[43]=C,e[44]=k,e[45]=W):W=e[45];let V;e[46]!==$||e[47]!==z||e[48]!==U||e[49]!==O||e[50]!==H||e[51]!==B||e[52]!==W||e[53]!==E?(V=r.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1.5",children:[$,z,U,O,H,B,W,E]}),e[46]=$,e[47]=z,e[48]=U,e[49]=O,e[50]=H,e[51]=B,e[52]=W,e[53]=E,e[54]=V):V=e[54];let q;return e[55]!==R||e[56]!==D||e[57]!==V||e[58]!==L?(q=r.jsxs("div",{className:"flex items-center pb-1.5 pl-6 pr-3",role:"group",title:R,"aria-describedby":D,children:[L,V]}),e[55]=R,e[56]=D,e[57]=V,e[58]=L,e[59]=q):q=e[59],q}function Et(n){const e=F.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=G("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(El,{"data-slot":"separator",orientation:i,className:a,...s}),e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9],l}function Ob(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("label",{"data-slot":"label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Db(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("fieldset",{"data-slot":"field-set",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Lb(n){const e=F.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"legend":o;let a;e[4]!==t?(a=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==a||e[8]!==i?(l=r.jsx("legend",{"data-slot":"field-legend","data-variant":i,className:a,...s}),e[6]=s,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}function Qs(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const zb=Cn("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function ft(n){const e=F.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t||e[5]!==i?(a=G(zb({orientation:i}),t),e[4]=t,e[5]=i,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==s||e[9]!==a?(l=r.jsx("div",{role:"group","data-slot":"field","data-orientation":i,className:a,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function kA(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function mt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ob,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ks(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-left text-sm leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("p",{"data-slot":"field-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jn(n){var f;const e=F.c(15);let t,s,o,i;e[0]!==n?({className:s,children:t,errors:o,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e:{if(t){a=t;break e}if(!(o!=null&&o.length)){a=null;break e}let u;e[5]!==o?(u=[...new Map(o.map(Bb)).values()],e[5]=o,e[6]=u):u=e[6];const m=u;if((m==null?void 0:m.length)==1){a=(f=m[0])==null?void 0:f.message;break e}let p;e[7]!==m?(p=r.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(Fb)}),e[7]=m,e[8]=p):p=e[8],a=p}const l=a;if(!l)return null;let c;e[9]!==s?(c=G("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let d;return e[11]!==l||e[12]!==i||e[13]!==c?(d=r.jsx("div",{role:"alert","data-slot":"field-error",className:c,...i,children:l}),e[11]=l,e[12]=i,e[13]=c,e[14]=d):d=e[14],d}function Fb(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function Bb(n){return[n==null?void 0:n.message,n]}const Ub=F0;function Wb(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("scroll-my-1 p-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(H0,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Hb(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-1 text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(B0,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Kb(n){const e=F.c(13);let t,s,o,i;e[0]!==n?({className:s,size:i,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==s?(l=G("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out select-none data-pressed:scale-[0.98] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none motion-reduce:data-pressed:scale-100 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(K0,{render:r.jsx(nt,{className:"pointer-events-none size-4 text-muted-foreground transition-transform duration-150 ease-out group-data-popup-open/select-trigger:rotate-180 motion-reduce:transition-none"})}),e[7]=c):c=e[7];let d;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==l?(d=r.jsxs(U0,{"data-slot":"select-trigger","data-size":a,className:l,...o,children:[t,c]}),e[8]=t,e[9]=o,e[10]=a,e[11]=l,e[12]=d):d=e[12],d}function Vb(n){const e=F.c(26);let t,s,o,i,a,l,c,d;e[0]!==n?({className:s,children:t,side:i,sideOffset:a,align:l,alignOffset:c,alignItemWithTrigger:d,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7],d=e[8]);const f=i===void 0?"bottom":i,u=a===void 0?4:a,m=l===void 0?"center":l,p=c===void 0?0:c,h=d===void 0?!0:d;let g;e[9]!==s?(g=G("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let v;e[11]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Gb,{}),e[11]=v):v=e[11];let x;e[12]!==t?(x=r.jsx(V0,{children:t}),e[12]=t,e[13]=x):x=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Yb,{}),e[14]=w):w=e[14];let y;e[15]!==o||e[16]!==g||e[17]!==x?(y=r.jsxs(W0,{"data-slot":"select-content",className:g,...o,children:[v,x,w]}),e[15]=o,e[16]=g,e[17]=x,e[18]=y):y=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==f||e[23]!==u||e[24]!==y?(j=r.jsx(q0,{children:r.jsx(G0,{side:f,sideOffset:u,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:y})}),e[19]=m,e[20]=h,e[21]=p,e[22]=f,e[23]=u,e[24]=y,e[25]=j):j=e[25],j}function qb(n){const e=F.c(13);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(L0,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=a):a=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(z0,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",render:r.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:r.jsx(rt,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==o||e[10]!==i||e[11]!==a?(c=r.jsxs(D0,{"data-slot":"select-item",className:i,...o,children:[a,l]}),e[9]=o,e[10]=i,e[11]=a,e[12]=c):c=e[12],c}function Gb(n){const e=F.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Bo,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Y0,{"data-slot":"select-scroll-up-button",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function Yb(n){const e=F.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(nt,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(X0,{"data-slot":"select-scroll-down-button",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function Xb(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Wm,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function Jb(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(J0,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Zb(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(di,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function Qb(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Rl,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function ey(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("fixed inset-0 z-50 bg-black/55 duration-200 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Il,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ty(n){const e=F.c(17);let t,s,o,i,a;e[0]!==n?({className:s,children:t,side:i,showCloseButton:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"right":i,c=a===void 0?!0:a;let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(ey,{}),e[6]=d):d=e[6];let f;e[7]!==s?(f=G("fixed z-50 flex flex-col border-border bg-popover text-popover-foreground shadow-lg duration-200 ease-out data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-[560px] data-[side=right]:border-l","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-[560px] data-[side=left]:border-r","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b","data-open:animate-in data-open:fade-in-0 data-[side=right]:data-open:slide-in-from-right data-[side=left]:data-open:slide-in-from-left data-[side=bottom]:data-open:slide-in-from-bottom data-[side=top]:data-open:slide-in-from-top","data-closed:animate-out data-closed:fade-out-0 data-[side=right]:data-closed:slide-out-to-right data-[side=left]:data-closed:slide-out-to-left data-[side=bottom]:data-closed:slide-out-to-bottom data-[side=top]:data-closed:slide-out-to-top",s),e[7]=s,e[8]=f):f=e[8];let u;e[9]!==c?(u=c&&r.jsxs(di,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[r.jsx(xt,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[9]=c,e[10]=u):u=e[10];let m;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==f||e[15]!==u?(m=r.jsxs(Qb,{children:[d,r.jsxs(Pl,{"data-slot":"sheet-content","data-side":l,className:f,...o,children:[t,u]})]}),e[11]=t,e[12]=o,e[13]=l,e[14]=f,e[15]=u,e[16]=m):m=e[16],m}function ny(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col gap-1.5 border-b p-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"sheet-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function sy(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm font-medium",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Al,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function oy(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ml,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function vo(n){const e=F.c(10),{label:t,children:s,wide:o}=n,a=(o===void 0?!1:o)&&"col-span-2";let l;e[0]!==a?(l=G("min-w-0 gap-1 py-1",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==t?(c=r.jsx(mt,{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("div",{className:"min-w-0 [&>button]:w-full [&>button]:justify-between",children:s}),e[4]=s,e[5]=d):d=e[5];let f;return e[6]!==l||e[7]!==c||e[8]!==d?(f=r.jsxs(ft,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=f):f=e[9],f}function jr(n){const e=F.c(19),{label:t,ariaLabel:s,value:o,options:i,onChange:a,disabled:l,title:c}=n;let d;e[0]!==a?(d=v=>{v!==null&&a(v)},e[0]=a,e[1]=d):d=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Hb,{}),e[2]=f):f=e[2];let u;e[3]!==s||e[4]!==c?(u=r.jsx(Kb,{"aria-label":s,title:c,className:"h-10 w-full",children:f}),e[3]=s,e[4]=c,e[5]=u):u=e[5];let m;e[6]!==i?(m=i.map(ry),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(Vb,{children:r.jsx(Wb,{children:m})}),e[8]=m,e[9]=p):p=e[9];let h;e[10]!==l||e[11]!==d||e[12]!==u||e[13]!==p||e[14]!==o?(h=r.jsxs(Ub,{value:o,onValueChange:d,disabled:l,children:[u,p]}),e[10]=l,e[11]=d,e[12]=u,e[13]=p,e[14]=o,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==h?(g=r.jsx(vo,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function ry(n){return r.jsx(qb,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function iy(n){const e=F.c(32),{agentKind:t,onAgentKindChange:s,selectedModel:o,onModelChange:i,modelOptions:a,selectedEffort:l,onEffortChange:c,effortOptions:d,ultracodeEnabled:f,fastTier:u,fastModeEnabled:m,onFastModeEnabledChange:p,permissionMode:h,permissionOptions:g,onPermissionModeChange:v,changeAndApply:x}=n;let w;e[0]!==t||e[1]!==l||e[2]!==o?(w=wi(t,l,o),e[0]=t,e[1]=l,e[2]=o,e[3]=w):w=e[3];const y=w;let j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[4]=j):j=e[4];let N;e[5]!==t||e[6]!==s?(N=s&&r.jsx(jr,{label:"Agent",ariaLabel:"Agent",value:t,options:jp,onChange:P=>s(P)}),e[5]=t,e[6]=s,e[7]=N):N=e[7];let S;e[8]!==a||e[9]!==i||e[10]!==o?(S=r.jsx(jr,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[8]=a,e[9]=i,e[10]=o,e[11]=S):S=e[11];let k;e[12]!==d||e[13]!==y||e[14]!==c||e[15]!==f?(k=d.length>0&&r.jsx(jr,{label:"Reasoning",ariaLabel:"Reasoning effort",value:y,options:d,onChange:c,disabled:f,title:f?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=d,e[13]=y,e[14]=c,e[15]=f,e[16]=k):k=e[16];let C;e[17]!==x||e[18]!==m||e[19]!==u||e[20]!==p?(C=u&&p&&r.jsx(vo,{label:"Speed",children:r.jsxs(X,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>x(()=>p(!m)),title:u.description,className:"h-10 justify-start",children:[r.jsx(Ur,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[17]=x,e[18]=m,e[19]=u,e[20]=p,e[21]=C):C=e[21];let T;e[22]!==v||e[23]!==h||e[24]!==g?(T=v&&h&&r.jsx(jr,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:P=>v(P)}),e[22]=v,e[23]=h,e[24]=g,e[25]=T):T=e[25];let _;return e[26]!==N||e[27]!==S||e[28]!==k||e[29]!==C||e[30]!==T?(_=r.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[j,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[N,S,k,C,T]})]}),e[26]=N,e[27]=S,e[28]=k,e[29]=C,e[30]=T,e[31]=_):_=e[31],_}function ay(n){const e=F.c(28),{agentKind:t,isNewSession:s,worktreeEnabled:o,onWorktreeEnabledChange:i,ultracodeEnabled:a,onUltracodeEnabledChange:l,mcpServers:c,selectedMcpServers:d,onToggleMcpServer:f,onRefreshMcpServers:u,mcpLoading:m,onMcpAuth:p,changeAndApply:h}=n,g=t==="claude",v=!!(f&&u&&p&&(m||c&&c.length>0)),x=!!(g&&s&&i||g&&l||v);let w;e[0]!==d?(w=d??[],e[0]=d,e[1]=w):w=e[1];let y;e[2]!==w?(y=new Set(w),e[2]=w,e[3]=y):y=e[3];const j=y;if(!x)return null;let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("h3",{id:"mobile-advanced-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Advanced"}),e[4]=N):N=e[4];let S;e[5]!==s||e[6]!==i||e[7]!==g||e[8]!==o?(S=g&&s&&i&&r.jsx(vo,{label:"Isolation",children:r.jsxs(X,{type:"button",variant:o?"secondary":"ghost","aria-pressed":!!o,onClick:()=>i(!o),className:"h-10 justify-start",children:[r.jsx(Xs,{"data-icon":"inline-start"}),"Worktree"]})}),e[5]=s,e[6]=i,e[7]=g,e[8]=o,e[9]=S):S=e[9];let k;e[10]!==h||e[11]!==l||e[12]!==g||e[13]!==a?(k=g&&l&&r.jsx(vo,{label:"Workflow",children:r.jsxs(X,{type:"button",variant:a?"secondary":"ghost","aria-pressed":!!a,onClick:()=>h(()=>l(!a)),className:"h-10 justify-start",children:[r.jsx(Ur,{"data-icon":"inline-start",className:G(a&&"fill-current")}),"Ultracode"]})}),e[10]=h,e[11]=l,e[12]=g,e[13]=a,e[14]=k):k=e[14];let C;e[15]!==h||e[16]!==m||e[17]!==c||e[18]!==p||e[19]!==u||e[20]!==f||e[21]!==j||e[22]!==v?(C=v&&f&&u&&p&&r.jsx(vo,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(X,{type:"button",variant:"ghost",onClick:u,className:"min-h-10 justify-start",children:[r.jsx(Ht,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(_=>{const P=j.has(_.name),A=_.status==="connected";return r.jsxs(X,{type:"button",variant:"ghost","aria-pressed":A?P:void 0,onClick:()=>A?h(()=>f(_.name)):p(_.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:G("size-2 shrink-0 rounded-full",A&&P?"bg-success":A?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:_.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:A?P?"On":"Off":"Connect"})]},_.name)})]})}),e[15]=h,e[16]=m,e[17]=c,e[18]=p,e[19]=u,e[20]=f,e[21]=j,e[22]=v,e[23]=C):C=e[23];let T;return e[24]!==S||e[25]!==k||e[26]!==C?(T=r.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[N,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[S,k,C]})]}),e[24]=S,e[25]=k,e[26]=C,e[27]=T):T=e[27],T}function ly(n){var ce,me;const e=F.c(78),{open:t,onOpenChange:s,agentKind:o,onAgentKindChange:i,selectedModel:a,resolvedDefaultName:l,catalogOptions:c,modelOptions:d,onModelChange:f,selectedEffort:u,effortOptions:m,onEffortChange:p,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:v,isNewSession:x,worktreeEnabled:w,onWorktreeEnabledChange:y,ultracodeEnabled:j,onUltracodeEnabledChange:N,autoModeAvailable:S,permissionMode:k,onPermissionModeChange:C,mcpServers:T,selectedMcpServers:_,onToggleMcpServer:P,onRefreshMcpServers:A,mcpLoading:E,onMcpAuth:M,mobileExtra:I,changeAndApply:R}=n;let D;e[0]!==o||e[1]!==u||e[2]!==a?(D=wi(o,u,a),e[0]=o,e[1]=u,e[2]=a,e[3]=D):D=e[3];const L=D;let $,z;e[4]!==o||e[5]!==S||e[6]!==k?($=Np(o,S),z=(ce=$.find(pe=>pe.value===k))==null?void 0:ce.label,e[4]=o,e[5]=S,e[6]=k,e[7]=$,e[8]=z):($=e[7],z=e[8]);const U=z;let O;e[9]!==c||e[10]!==l||e[11]!==a?(O=a?Qa(a,c):l,e[9]=c,e[10]=l,e[11]=a,e[12]=O):O=e[12];let H;e[13]!==m||e[14]!==L?(H=(me=m.find(pe=>pe.value===L))==null?void 0:me.label,e[13]=m,e[14]=L,e[15]=H):H=e[15];let B;e[16]!==U||e[17]!==O||e[18]!==H?(B=[O,H,U].filter(Boolean),e[16]=U,e[17]=O,e[18]=H,e[19]=B):B=e[19];const W=B.join(" · ");let V;e[20]!==R||e[21]!==C?(V=pe=>{C&&R(()=>C(pe))},e[20]=R,e[21]=C,e[22]=V):V=e[22];const q=V;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Jb,{render:r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"ml-0.5 shrink-0 rounded-full text-muted-foreground","aria-label":"Session controls",title:"Session controls"}),children:r.jsx($l,{})}),e[23]=Y):Y=e[23];let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(sy,{children:"Session controls"}),e[24]=K):K=e[24];let J;e[25]!==W?(J=r.jsx(oy,{className:"truncate text-xs",children:W}),e[25]=W,e[26]=J):J=e[26];let Z;e[27]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(Zb,{render:r.jsx(X,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:r.jsx(xt,{})}),e[27]=Z):Z=e[27];let Q;e[28]!==J?(Q=r.jsxs(ny,{className:"gap-1 px-4 pb-3 pt-4",children:[K,J,Z]}),e[28]=J,e[29]=Q):Q=e[29];let se;e[30]!==o||e[31]!==R||e[32]!==q||e[33]!==m||e[34]!==g||e[35]!==h||e[36]!==d||e[37]!==i||e[38]!==p||e[39]!==v||e[40]!==f||e[41]!==k||e[42]!==$||e[43]!==u||e[44]!==a||e[45]!==j?(se=r.jsx(iy,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:f,modelOptions:d,selectedEffort:u,onEffortChange:p,effortOptions:m,ultracodeEnabled:j,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:v,permissionMode:k,permissionOptions:$,onPermissionModeChange:q,changeAndApply:R}),e[30]=o,e[31]=R,e[32]=q,e[33]=m,e[34]=g,e[35]=h,e[36]=d,e[37]=i,e[38]=p,e[39]=v,e[40]=f,e[41]=k,e[42]=$,e[43]=u,e[44]=a,e[45]=j,e[46]=se):se=e[46];let ne;e[47]!==o||e[48]!==R||e[49]!==x||e[50]!==E||e[51]!==T||e[52]!==M||e[53]!==A||e[54]!==P||e[55]!==N||e[56]!==y||e[57]!==_||e[58]!==j||e[59]!==w?(ne=r.jsx(ay,{agentKind:o,isNewSession:x,worktreeEnabled:w,onWorktreeEnabledChange:y,ultracodeEnabled:j,onUltracodeEnabledChange:N,mcpServers:T,selectedMcpServers:_,onToggleMcpServer:P,onRefreshMcpServers:A,mcpLoading:E,onMcpAuth:M,changeAndApply:R}),e[47]=o,e[48]=R,e[49]=x,e[50]=E,e[51]=T,e[52]=M,e[53]=A,e[54]=P,e[55]=N,e[56]=y,e[57]=_,e[58]=j,e[59]=w,e[60]=ne):ne=e[60];let ee;e[61]!==I?(ee=I&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(Et,{className:"mb-3"}),r.jsx("h3",{id:"mobile-goal-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Long-running goal"}),r.jsx("div",{className:"[&>*]:mx-0 [&>*]:mb-0 [&_button]:min-h-10",children:I})]}),e[61]=I,e[62]=ee):ee=e[62];let ie;e[63]!==o||e[64]!==x?(ie=!x&&r.jsx("p",{className:"text-xs text-muted-foreground",children:o==="claude"?"Changes apply live.":"Changes apply on the next turn."}),e[63]=o,e[64]=x,e[65]=ie):ie=e[65];let oe;e[66]!==se||e[67]!==ne||e[68]!==ee||e[69]!==ie?(oe=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[se,ne,ee,ie]}),e[66]=se,e[67]=ne,e[68]=ee,e[69]=ie,e[70]=oe):oe=e[70];let re;e[71]!==Q||e[72]!==oe?(re=r.jsxs(ty,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[Q,oe]}),e[71]=Q,e[72]=oe,e[73]=re):re=e[73];let te;return e[74]!==s||e[75]!==t||e[76]!==re?(te=r.jsx(r.Fragment,{children:r.jsxs(Xb,{open:t,onOpenChange:s,children:[Y,re]})}),e[74]=s,e[75]=t,e[76]=re,e[77]=te):te=e[77],te}const cy=b.memo(function(e){var ie;const t=F.c(59),{agentKind:s,onAgentKindChange:o,selectedModel:i,onModelChange:a,selectedEffort:l,onEffortChange:c,fastModeEnabled:d,onFastModeEnabledChange:f,isNewSession:u,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,onApplySettings:v,activeModelId:x,mcpServers:w,selectedMcpServers:y,onToggleMcpServer:j,onRefreshMcpServers:N,mcpLoading:S,onMcpAuth:k,permissionMode:C,onPermissionModeChange:T,mobileExtra:_,trailingExtra:P,mobile:A}=e,E=s===void 0?"claude":s,M=A===void 0?!1:A,[I,R]=b.useState(!1);let D;t[0]!==u||t[1]!==v?(D=oe=>{oe(),!u&&v&&setTimeout(()=>v(),0)},t[0]=u,t[1]=v,t[2]=D):D=t[2];const L=D;let $;t[3]!==L||t[4]!==a?($=oe=>L(()=>a(oe)),t[3]=L,t[4]=a,t[5]=$):$=t[5];const z=$;let U;t[6]!==L||t[7]!==c?(U=oe=>L(()=>c(oe)),t[6]=L,t[7]=c,t[8]=U):U=t[8];const O=U,H=wp(E);let B,W;if(t[9]!==x||t[10]!==E||t[11]!==H){const oe=(ie=H.find(dy))==null?void 0:ie.label;B=E==="codex"?x!=null&&x.toLowerCase().startsWith("gpt-")?Qa(x,H):oe??"GPT":x?Qa(x,H):"Opus",W=H.map(re=>{const te=[re.description,re.availabilityMessage].filter(Boolean).join(" · ")||void 0;return re.value===""?{...re,description:te,value:"",label:B,menuLabel:`${B} (default)`}:{...re,description:te}}),t[9]=x,t[10]=E,t[11]=H,t[12]=B,t[13]=W}else B=t[12],W=t[13];const V=W;let q;t[14]!==E||t[15]!==i?(q=dp(E,i),t[14]=E,t[15]=i,t[16]=q):q=t[16];const Y=q;let K;t[17]!==E||t[18]!==i?(K=up(E,i),t[17]=E,t[18]=i,t[19]=K):K=t[19];const J=K;let Z;t[20]!==E||t[21]!==i?(Z=$v(E,i),t[20]=E,t[21]=i,t[22]=Z):Z=t[22];const Q=Z;let se;t[23]!==E||t[24]!==Q||t[25]!==L||t[26]!==Y||t[27]!==d||t[28]!==J||t[29]!==O||t[30]!==z||t[31]!==u||t[32]!==S||t[33]!==w||t[34]!==V||t[35]!==o||t[36]!==f||t[37]!==k||t[38]!==T||t[39]!==N||t[40]!==j||t[41]!==g||t[42]!==p||t[43]!==C||t[44]!==B||t[45]!==l||t[46]!==y||t[47]!==i||t[48]!==h||t[49]!==m?(se={agentKind:E,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:B,modelOptions:V,onModelChange:z,selectedEffort:l,effortOptions:Y,onEffortChange:O,fastTier:J,fastModeEnabled:d,onFastModeEnabledChange:f,isNewSession:u,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:Q,permissionMode:C,onPermissionModeChange:T,mcpServers:w,selectedMcpServers:y,onToggleMcpServer:j,onRefreshMcpServers:N,mcpLoading:S,onMcpAuth:k,changeAndApply:L},t[23]=E,t[24]=Q,t[25]=L,t[26]=Y,t[27]=d,t[28]=J,t[29]=O,t[30]=z,t[31]=u,t[32]=S,t[33]=w,t[34]=V,t[35]=o,t[36]=f,t[37]=k,t[38]=T,t[39]=N,t[40]=j,t[41]=g,t[42]=p,t[43]=C,t[44]=B,t[45]=l,t[46]=y,t[47]=i,t[48]=h,t[49]=m,t[50]=se):se=t[50];const ne=se;if(M){let oe;return t[51]!==H||t[52]!==ne||t[53]!==_||t[54]!==I?(oe=r.jsx(ly,{...ne,open:I,onOpenChange:R,catalogOptions:H,mobileExtra:_}),t[51]=H,t[52]=ne,t[53]=_,t[54]=I,t[55]=oe):oe=t[55],oe}let ee;return t[56]!==ne||t[57]!==P?(ee=r.jsx($b,{...ne,trailingExtra:P}),t[56]=ne,t[57]=P,t[58]=ee):ee=t[58],ee});function dy(n){return n.value!==""}function kp(n){return n.agentType==="team-lead"}function uy(n){return kp(n)?void 0:n.color}const fy={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function my(n){return n?fy[n]??"bg-zinc-400":"bg-zinc-400"}const py=b.memo(function(e){const t=F.c(18),{teamName:s,members:o,currentMemberName:i,loadingMember:a,onMemberClick:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Tn,{className:"size-3"}),t[0]=c):c=t[0];let d;t[1]!==s?(d=r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[c,r.jsx("span",{className:"max-w-[120px] truncate",children:s})]}),t[1]=s,t[2]=d):d=t[2];let f;t[3]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Et,{orientation:"vertical",className:"h-3.5"}),t[3]=f):f=t[3];let u;if(t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==l){let h;t[9]!==i||t[10]!==a||t[11]!==l?(h=g=>{const v=g.name===i,x=g.name===a,w=my(uy(g));return r.jsxs(X,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:x,className:G("whitespace-nowrap",v?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[x?r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx("span",{className:G("inline-flex size-1.5 shrink-0 rounded-full",w)}),r.jsx("span",{children:g.name}),kp(g)&&r.jsx(Z0,{"data-icon":"inline-end",className:"text-warning"})]},g.agentId)},t[9]=i,t[10]=a,t[11]=l,t[12]=h):h=t[12],u=o.map(h),t[4]=i,t[5]=a,t[6]=o,t[7]=l,t[8]=u}else u=t[8];let m;t[13]!==u?(m=r.jsx("div",{className:"flex items-center gap-1",children:u}),t[13]=u,t[14]=m):m=t[14];let p;return t[15]!==d||t[16]!==m?(p=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 overflow-x-auto border-b bg-background px-3 py-2",children:[d,f,m]}),t[15]=d,t[16]=m,t[17]=p):p=t[17],p});function Cp(n){const e=F.c(3),t=b.useRef(null),[s,o]=b.useState(0);let i,a;return e[0]!==n?(i=()=>{if(!n){t.current=null,o(0);return}t.current=Date.now(),o(0);const l=setInterval(()=>{t.current!==null&&o(Math.floor((Date.now()-t.current)/1e3))},1e3);return()=>clearInterval(l)},a=[n],e[0]=n,e[1]=i,e[2]=a):(i=e[1],a=e[2]),b.useEffect(i,a),s}const _p=b.createContext(null),Tp=b.createContext(null);function Dr(n){const e=F.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(Tp.Provider,{value:s,children:o}),e[0]=s,e[1]=o,e[2]=i):i=e[2];let a;return e[3]!==i||e[4]!==t?(a=r.jsx(_p.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function st(){const n=b.useContext(_p);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function qo(){const n=b.useContext(Tp);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const hy=Cn("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function Oe(n){const e=F.c(13);let t,s,o,i,a;if(e[0]!==n){const{className:d,variant:f,render:u,...m}=n;t=u,a=f===void 0?"default":f,i=Km,s="span",o=Hm({className:G(hy({variant:a}),d)},m),e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a}else t=e[1],s=e[2],o=e[3],i=e[4],a=e[5];let l;e[6]!==a?(l={slot:"badge",variant:a},e[6]=a,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==s||e[10]!==o||e[11]!==l?(c={defaultTagName:s,props:o,render:t,state:l},e[8]=t,e[9]=s,e[10]=o,e[11]=l,e[12]=c):c=e[12],i(c)}var du=1,gy=.9,xy=.8,vy=.17,da=.1,ua=.999,by=.9999,yy=.99,wy=/[\\\/_+.#"@\[\(\{&]/,jy=/[\\\/_+.#"@\[\(\{&]/g,Sy=/[\s-]/,Ep=/[\s-]/g;function el(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?du:yy;var l=`${o},${i}`;if(a[l]!==void 0)return a[l];for(var c=s.charAt(i),d=t.indexOf(c,o),f=0,u,m,p,h;d>=0;)u=el(n,e,t,s,d+1,i+1,a),u>f&&(d===o?u*=du:wy.test(n.charAt(d-1))?(u*=xy,p=n.slice(o,d-1).match(jy),p&&o>0&&(u*=Math.pow(ua,p.length))):Sy.test(n.charAt(d-1))?(u*=gy,h=n.slice(o,d-1).match(Ep),h&&o>0&&(u*=Math.pow(ua,h.length))):(u*=vy,o>0&&(u*=Math.pow(ua,d-o))),n.charAt(d)!==e.charAt(i)&&(u*=by)),(u<da&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=el(n,e,t,s,d+1,i+2,a),m*da>u&&(u=m*da)),u>f&&(f=u),d=t.indexOf(c,d+1);return a[l]=f,f}function uu(n){return n.toLowerCase().replace(Ep," ")}function Ny(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,el(n,e,uu(n),uu(e),0,0,{})}var oo='[cmdk-group=""]',fa='[cmdk-group-items=""]',ky='[cmdk-group-heading=""]',Pp='[cmdk-item=""]',fu=`${Pp}:not([aria-disabled="true"])`,tl="cmdk-item-select",Os="data-value",Cy=(n,e,t)=>Ny(n,e,t),Ap=b.createContext(void 0),Go=()=>b.useContext(Ap),Mp=b.createContext(void 0),Ul=()=>b.useContext(Mp),Rp=b.createContext(void 0),Ip=b.forwardRef((n,e)=>{let t=Ds(()=>{var O,H;return{search:"",value:(H=(O=n.value)!=null?O:n.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=Ds(()=>new Set),o=Ds(()=>new Map),i=Ds(()=>new Map),a=Ds(()=>new Set),l=$p(n),{label:c,children:d,value:f,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:v=!0,...x}=n,w=Fs(),y=Fs(),j=Fs(),N=b.useRef(null),S=Dy();bs(()=>{if(f!==void 0){let O=f.trim();t.current.value=O,k.emit()}},[f]),bs(()=>{S(6,E)},[]);let k=b.useMemo(()=>({subscribe:O=>(a.current.add(O),()=>a.current.delete(O)),snapshot:()=>t.current,setState:(O,H,B)=>{var W,V,q,Y;if(!Object.is(t.current[O],H)){if(t.current[O]=H,O==="search")A(),_(),S(1,P);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let K=document.getElementById(j);K?K.focus():(W=document.getElementById(w))==null||W.focus()}if(S(7,()=>{var K;t.current.selectedItemId=(K=M())==null?void 0:K.id,k.emit()}),B||S(5,E),((V=l.current)==null?void 0:V.value)!==void 0){let K=H??"";(Y=(q=l.current).onValueChange)==null||Y.call(q,K);return}}k.emit()}},emit:()=>{a.current.forEach(O=>O())}}),[]),C=b.useMemo(()=>({value:(O,H,B)=>{var W;H!==((W=i.current.get(O))==null?void 0:W.value)&&(i.current.set(O,{value:H,keywords:B}),t.current.filtered.items.set(O,T(H,B)),S(2,()=>{_(),k.emit()}))},item:(O,H)=>(s.current.add(O),H&&(o.current.has(H)?o.current.get(H).add(O):o.current.set(H,new Set([O]))),S(3,()=>{A(),_(),t.current.value||P(),k.emit()}),()=>{i.current.delete(O),s.current.delete(O),t.current.filtered.items.delete(O);let B=M();S(4,()=>{A(),(B==null?void 0:B.getAttribute("id"))===O&&P(),k.emit()})}),group:O=>(o.current.has(O)||o.current.set(O,new Set),()=>{i.current.delete(O),o.current.delete(O)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:w,inputId:j,labelId:y,listInnerRef:N}),[]);function T(O,H){var B,W;let V=(W=(B=l.current)==null?void 0:B.filter)!=null?W:Cy;return O?V(O,t.current.search,H):0}function _(){if(!t.current.search||l.current.shouldFilter===!1)return;let O=t.current.filtered.items,H=[];t.current.filtered.groups.forEach(W=>{let V=o.current.get(W),q=0;V.forEach(Y=>{let K=O.get(Y);q=Math.max(K,q)}),H.push([W,q])});let B=N.current;I().sort((W,V)=>{var q,Y;let K=W.getAttribute("id"),J=V.getAttribute("id");return((q=O.get(J))!=null?q:0)-((Y=O.get(K))!=null?Y:0)}).forEach(W=>{let V=W.closest(fa);V?V.appendChild(W.parentElement===V?W:W.closest(`${fa} > *`)):B.appendChild(W.parentElement===B?W:W.closest(`${fa} > *`))}),H.sort((W,V)=>V[1]-W[1]).forEach(W=>{var V;let q=(V=N.current)==null?void 0:V.querySelector(`${oo}[${Os}="${encodeURIComponent(W[0])}"]`);q==null||q.parentElement.appendChild(q)})}function P(){let O=I().find(B=>B.getAttribute("aria-disabled")!=="true"),H=O==null?void 0:O.getAttribute(Os);k.setState("value",H||void 0)}function A(){var O,H,B,W;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let V=0;for(let q of s.current){let Y=(H=(O=i.current.get(q))==null?void 0:O.value)!=null?H:"",K=(W=(B=i.current.get(q))==null?void 0:B.keywords)!=null?W:[],J=T(Y,K);t.current.filtered.items.set(q,J),J>0&&V++}for(let[q,Y]of o.current)for(let K of Y)if(t.current.filtered.items.get(K)>0){t.current.filtered.groups.add(q);break}t.current.filtered.count=V}function E(){var O,H,B;let W=M();W&&(((O=W.parentElement)==null?void 0:O.firstChild)===W&&((B=(H=W.closest(oo))==null?void 0:H.querySelector(ky))==null||B.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function M(){var O;return(O=N.current)==null?void 0:O.querySelector(`${Pp}[aria-selected="true"]`)}function I(){var O;return Array.from(((O=N.current)==null?void 0:O.querySelectorAll(fu))||[])}function R(O){let H=I()[O];H&&k.setState("value",H.getAttribute(Os))}function D(O){var H;let B=M(),W=I(),V=W.findIndex(Y=>Y===B),q=W[V+O];(H=l.current)!=null&&H.loop&&(q=V+O<0?W[W.length-1]:V+O===W.length?W[0]:W[V+O]),q&&k.setState("value",q.getAttribute(Os))}function L(O){let H=M(),B=H==null?void 0:H.closest(oo),W;for(;B&&!W;)B=O>0?$y(B,oo):Oy(B,oo),W=B==null?void 0:B.querySelector(fu);W?k.setState("value",W.getAttribute(Os)):D(O)}let $=()=>R(I().length-1),z=O=>{O.preventDefault(),O.metaKey?$():O.altKey?L(1):D(1)},U=O=>{O.preventDefault(),O.metaKey?R(0):O.altKey?L(-1):D(-1)};return b.createElement(rs.div,{ref:e,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:O=>{var H;(H=x.onKeyDown)==null||H.call(x,O);let B=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||B))switch(O.key){case"n":case"j":{v&&O.ctrlKey&&z(O);break}case"ArrowDown":{z(O);break}case"p":case"k":{v&&O.ctrlKey&&U(O);break}case"ArrowUp":{U(O);break}case"Home":{O.preventDefault(),R(0);break}case"End":{O.preventDefault(),$();break}case"Enter":{O.preventDefault();let W=M();if(W){let V=new Event(tl);W.dispatchEvent(V)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:C.inputId,id:C.labelId,style:zy},c),Ni(n,O=>b.createElement(Mp.Provider,{value:k},b.createElement(Ap.Provider,{value:C},O))))}),_y=b.forwardRef((n,e)=>{var t,s;let o=Fs(),i=b.useRef(null),a=b.useContext(Rp),l=Go(),c=$p(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;bs(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let f=Op(o,i,[n.value,n.children,i],n.keywords),u=Ul(),m=ts(S=>S.value&&S.value===f.current),p=ts(S=>d||l.filter()===!1?!0:S.search?S.filtered.items.get(o)>0:!0);b.useEffect(()=>{let S=i.current;if(!(!S||n.disabled))return S.addEventListener(tl,h),()=>S.removeEventListener(tl,h)},[p,n.onSelect,n.disabled]);function h(){var S,k;g(),(k=(S=c.current).onSelect)==null||k.call(S,f.current)}function g(){u.setState("value",f.current,!0)}if(!p)return null;let{disabled:v,value:x,onSelect:w,forceMount:y,keywords:j,...N}=n;return b.createElement(rs.div,{ref:ko(i,e),...N,id:o,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!m,"data-disabled":!!v,"data-selected":!!m,onPointerMove:v||l.getDisablePointerSelection()?void 0:g,onClick:v?void 0:h},n.children)}),Ty=b.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=Fs(),l=b.useRef(null),c=b.useRef(null),d=Fs(),f=Go(),u=ts(p=>o||f.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);bs(()=>f.group(a),[]),Op(a,l,[n.value,n.heading,c]);let m=b.useMemo(()=>({id:a,forceMount:o}),[o]);return b.createElement(rs.div,{ref:ko(l,e),...i,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},t&&b.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),Ni(n,p=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},b.createElement(Rp.Provider,{value:m},p))))}),Ey=b.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=b.useRef(null),i=ts(a=>!a.search);return!t&&!i?null:b.createElement(rs.div,{ref:ko(o,e),...s,"cmdk-separator":"",role:"separator"})}),Py=b.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Ul(),a=ts(d=>d.search),l=ts(d=>d.selectedItemId),c=Go();return b.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),b.createElement(rs.input,{ref:e,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:o?n.value:a,onChange:d=>{o||i.setState("search",d.target.value),t==null||t(d.target.value)}})}),Ay=b.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=b.useRef(null),a=b.useRef(null),l=ts(d=>d.selectedItemId),c=Go();return b.useEffect(()=>{if(a.current&&i.current){let d=a.current,f=i.current,u,m=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let p=d.offsetHeight;f.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(d),()=>{cancelAnimationFrame(u),m.unobserve(d)}}},[]),b.createElement(rs.div,{ref:ko(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Ni(n,d=>b.createElement("div",{ref:ko(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),My=b.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return b.createElement(Q0,{open:t,onOpenChange:s},b.createElement(e2,{container:a},b.createElement(t2,{"cmdk-overlay":"",className:o}),b.createElement(n2,{"aria-label":n.label,"cmdk-dialog":"",className:i},b.createElement(Ip,{ref:e,...l}))))}),Ry=b.forwardRef((n,e)=>ts(t=>t.filtered.count===0)?b.createElement(rs.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),Iy=b.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return b.createElement(rs.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ni(n,a=>b.createElement("div",{"aria-hidden":!0},a)))}),eo=Object.assign(Ip,{List:Ay,Item:_y,Input:Py,Group:Ty,Separator:Ey,Dialog:My,Empty:Ry,Loading:Iy});function $y(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function Oy(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function $p(n){let e=b.useRef(n);return bs(()=>{e.current=n}),e}var bs=typeof window>"u"?b.useEffect:b.useLayoutEffect;function Ds(n){let e=b.useRef();return e.current===void 0&&(e.current=n()),e}function ts(n){let e=Ul(),t=()=>n(e.snapshot());return b.useSyncExternalStore(e.subscribe,t,t)}function Op(n,e,t,s=[]){let o=b.useRef(),i=Go();return bs(()=>{var a;let l=(()=>{var d;for(let f of t){if(typeof f=="string")return f.trim();if(typeof f=="object"&&"current"in f)return f.current?(d=f.current.textContent)==null?void 0:d.trim():o.current}})(),c=s.map(d=>d.trim());i.value(n,l,c),(a=e.current)==null||a.setAttribute(Os,l),o.current=l}),o}var Dy=()=>{let[n,e]=b.useState(),t=Ds(()=>new Map);return bs(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function Ly(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Ni({asChild:n,children:e},t){return n&&b.isValidElement(e)?b.cloneElement(Ly(e),{ref:e.ref},t(e.props.children)):t(e)}var zy={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function On(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Wm,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function Fy(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Rl,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function By(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Il,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Dn(n){const e=F.c(15);let t,s,o,i;e[0]!==n?({className:s,children:t,showCloseButton:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?!0:i;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(By,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=G("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let d;e[8]!==a?(d=a&&r.jsxs(di,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[r.jsx(xt,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=a,e[9]=d):d=e[9];let f;return e[10]!==t||e[11]!==o||e[12]!==c||e[13]!==d?(f=r.jsxs(Fy,{children:[l,r.jsxs(Pl,{"data-slot":"dialog-content",className:c,...o,children:[t,d]})]}),e[10]=t,e[11]=o,e[12]=c,e[13]=d,e[14]=f):f=e[14],f}function as(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Dp(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ln(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Al,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zn(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ml,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Lp(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(eo,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function CA(n){const e=F.c(24);let t,s,o,i,a,l;e[0]!==n?({title:i,description:a,children:t,className:s,showCloseButton:l,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=i===void 0?"Command Palette":i,d=a===void 0?"Search for a command to run...":a,f=l===void 0?!1:l;let u;e[7]!==s?(u=G("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",s),e[7]=s,e[8]=u):u=e[8];let m;e[9]!==c?(m=r.jsx(Ln,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(zn,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(as,{className:"sr-only",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t||e[17]!==f||e[18]!==u||e[19]!==h?(g=r.jsxs(Dn,{className:u,showCloseButton:f,children:[h,t]}),e[16]=t,e[17]=f,e[18]=u,e[19]=h,e[20]=g):g=e[20];let v;return e[21]!==o||e[22]!==g?(v=r.jsx(On,{...o,children:g}),e[21]=o,e[22]=g,e[23]=v):v=e[23],v}function _A(n){const e=F.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(an,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=o):o=e[3];let i;e[4]!==t?(i=G("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==i?(a=r.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[o,r.jsx(eo.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function zp(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none transition-[height] duration-100 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(eo.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function TA(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("py-6 text-center text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-100 motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(eo.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Fp(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(eo.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Bp(n){const e=F.c(11);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none transition-colors duration-75 in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(rt,{className:"ml-auto scale-75 opacity-0 transition-[opacity,transform,scale] duration-100 ease-out group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:scale-100 group-data-[checked=true]/command-item:opacity-100 motion-reduce:transition-none"}),e[6]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(eo.Item,{"data-slot":"command-item",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function Uy(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("span",{"data-slot":"command-shortcut",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wy(n){return r.jsx(Oe,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const Hy=b.memo(function(e){const t=F.c(38),{suggestions:s,filter:o,loading:i,selectedIndex:a,onSelect:l,onHover:c,onEdit:d}=e;let f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=new Map,t[0]=f):f=t[0];const u=b.useRef(f);let m,p;if(t[1]!==a?(m=()=>{var P;const _=u.current.get(a);_&&((P=_.scrollIntoView)==null||P.call(_,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),b.useEffect(m,p),i){let _;return t[4]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[r.jsx(lt,{className:"size-3.5 animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=_):_=t[4],_}if(s.length===0){const _=o?`No commands or skills matching "${o}"`:"No commands or skills found";let P;return t[5]!==_?(P=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:_})})}),t[5]=_,t[6]=P):P=t[6],P}let h,g,v,x,w,y,j,N,S;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const _=s.filter(Vy),P=[{heading:"Commands",suggestions:_,offset:0},{heading:"Skills",suggestions:s.filter(qy),offset:_.length}];v="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Lp,w="slash-suggestions",y=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(j=A=>{const E=s.findIndex(M=>`${M.type}-${M.name}`===A);E>=0&&c(E)},t[21]=c,t[22]=s,t[23]=j):j=t[23],N=!1,S="border shadow-sm",h=zp,x=P.map(A=>A.suggestions.length>0&&r.jsx(Fp,{heading:A.heading,children:A.suggestions.map((E,M)=>{const I=A.offset+M;return r.jsx(Ky,{suggestion:E,index:I,isSelected:I===a,onSelect:l,onHover:c,onEdit:d,itemRefs:u},`${E.type}-${E.name}`)})},A.heading)),t[7]=d,t[8]=c,t[9]=l,t[10]=a,t[11]=s,t[12]=h,t[13]=g,t[14]=v,t[15]=x,t[16]=w,t[17]=y,t[18]=j,t[19]=N,t[20]=S}else h=t[12],g=t[13],v=t[14],x=t[15],w=t[16],y=t[17],j=t[18],N=t[19],S=t[20];let k;t[24]!==h||t[25]!==x?(k=r.jsx(h,{children:x}),t[24]=h,t[25]=x,t[26]=k):k=t[26];let C;t[27]!==g||t[28]!==k||t[29]!==w||t[30]!==y||t[31]!==j||t[32]!==N||t[33]!==S?(C=r.jsx(g,{id:w,value:y,onValueChange:j,shouldFilter:N,className:S,children:k}),t[27]=g,t[28]=k,t[29]=w,t[30]=y,t[31]=j,t[32]=N,t[33]=S,t[34]=C):C=t[34];let T;return t[35]!==v||t[36]!==C?(T=r.jsx("div",{className:v,children:C}),t[35]=v,t[36]=C,t[37]=T):T=t[37],T});function Ky({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=b.useCallback(c=>{c?(c.id=`slash-suggestion-${e}`,a.current.set(e,c)):a.current.delete(e)},[e,a]);return r.jsxs("div",{className:"group/suggestion relative",children:[r.jsxs(Bp,{ref:l,value:`${n.type}-${n.name}`,className:"items-start gap-2.5 px-2 py-2 pr-10",onMouseEnter:()=>o(e),onSelect:()=>s(n),onMouseDown:c=>{c.preventDefault()},children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:n.type==="command"?r.jsx(Hs,{className:"size-4 text-muted-foreground"}):r.jsx(Vm,{className:"size-4 text-muted-foreground"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",n.name]}),Wy(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(Uy,{className:i&&n.filePath?"mr-6":void 0,children:"Enter"})]}),i&&n.filePath&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1.5 top-1/2 -translate-y-1/2 opacity-0 transition-opacity group-hover/suggestion:opacity-100 focus-visible:opacity-100",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),i(n.filePath)},"aria-label":`Edit ${n.name}`,children:r.jsx(ws,{"data-icon":"inline-start"})})]})}function Vy(n){return n.type==="command"}function qy(n){return n.type==="skill"}function Gy(n){const e=F.c(25),{files:t,query:s,loading:o,selectedIndex:i,onSelect:a,onHover:l}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Map,e[0]=c):c=e[0];const d=b.useRef(c);let f,u;e[1]!==i?(f=()=>{var y,j;(j=(y=d.current.get(i))==null?void 0:y.scrollIntoView)==null||j.call(y,{block:"nearest"})},u=[i],e[1]=i,e[2]=f,e[3]=u):(f=e[2],u=e[3]),b.useEffect(f,u);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=y=>{const j=t.indexOf(y);j>=0&&l(j)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==o?(h=o&&r.jsx(lt,{"data-icon":"inline-end","aria-label":"Loading project files",className:"size-3.5 animate-spin"}),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==h?(g=r.jsxs("span",{className:"flex items-center justify-between",children:["Project files",h]}),e[9]=h,e[10]=g):g=e[10];let v;e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==a||e[15]!==s||e[16]!==i?(v=!o&&t.length===0?r.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:s?`No files matching “${s}”`:"No project files found"}):t.map((y,j)=>r.jsxs(Bp,{ref:N=>{N?(N.id=`file-suggestion-${j}`,d.current.set(j,N)):d.current.delete(j)},value:y,onMouseEnter:()=>l(j),onSelect:()=>a(y),onMouseDown:Yy,children:[r.jsx(qm,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:y}),j===i&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},y)),e[11]=t,e[12]=o,e[13]=l,e[14]=a,e[15]=s,e[16]=i,e[17]=v):v=e[17];let x;e[18]!==g||e[19]!==v?(x=r.jsx(zp,{className:"max-h-70",children:r.jsx(Fp,{heading:g,children:v})}),e[18]=g,e[19]=v,e[20]=x):x=e[20];let w;return e[21]!==m||e[22]!==p||e[23]!==x?(w=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-1.5 max-w-[var(--chat-width)]",children:r.jsx(Lp,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:x})}),e[21]=m,e[22]=p,e[23]=x,e[24]=w):w=e[24],w}function Yy(n){return n.preventDefault()}const Xy=Cn("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 motion-safe:duration-150 motion-safe:ease-out motion-reduce:animate-none *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function vt(n){const e=F.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t||e[5]!==o?(i=G(Xy({variant:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let a;return e[7]!==s||e[8]!==i?(a=r.jsx("div",{"data-slot":"alert",role:"alert",className:i,...s}),e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function At(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function bt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ns(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("absolute top-2 right-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jy(n){const e=F.c(15),{allowedPrompts:t,onApprove:s,onSend:o}=n;let i,a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(ui,{}),a=r.jsx(At,{children:"Plan ready for review"}),l=r.jsx(bt,{children:"Approve the plan or ask the agent to revise it."}),e[0]=i,e[1]=a,e[2]=l):(i=e[0],a=e[1],l=e[2]);let c;e[3]!==s?(c=r.jsx(X,{size:"sm",onClick:s,children:"Approve"}),e[3]=s,e[4]=c):c=e[4];let d;e[5]!==o?(d=r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>o("no"),children:"Reject"}),e[5]=o,e[6]=d):d=e[6];let f;e[7]!==c||e[8]!==d?(f=r.jsxs(ns,{className:"flex gap-2",children:[c,d]}),e[7]=c,e[8]=d,e[9]=f):f=e[9];let u;e[10]!==t?(u=t&&t.length>0&&r.jsxs("div",{className:"col-span-full mt-2 flex flex-wrap gap-1",children:[r.jsx("span",{className:"mr-1 self-center text-xs text-muted-foreground",children:"Permissions requested:"}),t.map(Zy)]}),e[10]=t,e[11]=u):u=e[11];let m;return e[12]!==f||e[13]!==u?(m=r.jsxs(vt,{className:"mb-3 pr-44",children:[i,a,l,f,u]}),e[12]=f,e[13]=u,e[14]=m):m=e[14],m}function Zy(n,e){return r.jsx(Oe,{variant:"outline",children:n.prompt},e)}const Qy=["allow","allow_always","deny"];function Sr(n,e){return(n.availableDecisions??Qy).includes(e)}function e3(n){switch(n){case"Bash":return{label:"Run command",icon:Hs,tone:"cmd"};case"Edit":return{label:"Edit file",icon:qd,tone:"write"};case"Write":return{label:"Write file",icon:qd,tone:"write"};case"Read":return{label:"Read file",icon:Js,tone:"read"};case"Glob":return{label:"File search",icon:an,tone:"search"};case"Grep":return{label:"Content search",icon:an,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:Ya,tone:"net"};case"WebSearch":return{label:"Web search",icon:Ya,tone:"net"};default:return{label:n,icon:fi,tone:"other"}}}function t3(n,e){if(n==="Bash"&&typeof e.command=="string")return e.command;if((n==="Edit"||n==="Write"||n==="Read")&&typeof e.file_path=="string")return e.file_path;if((n==="Glob"||n==="Grep")&&typeof e.pattern=="string")return e.pattern;if(n==="WebFetch"&&typeof e.url=="string")return e.url;if(n==="WebSearch"&&typeof e.query=="string")return e.query;const t=Object.keys(e).slice(0,2);return t.length===0?null:t.flatMap(s=>{const o=e[s],i=typeof o=="string"?o:JSON.stringify(o);return i?[i.length>160?i.slice(0,157)+"…":i]:[]}).join(" · ")}function n3({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?Sr(o,"allow"):!1,l=o?Sr(o,"allow_always"):!1,c=o?Sr(o,"deny"):!1,d=i>1&&n.every(y=>Sr(y,"allow")),f=b.useEffectEvent(y=>{if(!o)return;const j=y.target;if(j&&(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable)||y.metaKey||y.ctrlKey||y.altKey)return;const N=y.key.toLowerCase();N==="a"&&y.shiftKey&&d?(y.preventDefault(),s("allow")):N==="a"&&a?(y.preventDefault(),t(o.requestId,"allow")):N==="s"&&l?(y.preventDefault(),t(o.requestId,"allow_always")):N==="d"&&c&&(y.preventDefault(),t(o.requestId,"deny"))});b.useEffect(()=>{const y=j=>f(j);return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]);const u=o?e3(o.toolName):null,m=o?t3(o.toolName,o.input):null,p=(o==null?void 0:o.decisionReason)||(o==null?void 0:o.description)||(o==null?void 0:o.blockedPath),h=(((w=o==null?void 0:o.suggestions)==null?void 0:w.length)??0)>0;if(!o||!u)return null;const g=u.icon,v=e.has(o.requestId),x=i>1;return r.jsx("div",{className:"motion-slide-down-in border-b border-warning/20 bg-warning/5",children:r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("div",{className:"flex size-7 items-center justify-center rounded-md bg-warning/10 text-warning",children:r.jsx(Um,{className:"size-4"})}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(g,{className:"size-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm font-medium text-foreground",children:u.label})]})]}),m&&r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("code",{className:"block truncate rounded-md border bg-muted/40 px-2 py-1 font-mono text-xs text-muted-foreground",children:m})}),p&&p!==m&&r.jsx("p",{className:"hidden max-w-64 truncate text-xs text-muted-foreground xl:block",title:p,children:p}),x&&r.jsxs(Oe,{variant:"outline",className:"shrink-0 tabular-nums",children:["+",i-1," more"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c&&r.jsxs(X,{variant:"ghost",size:"sm",className:"text-destructive",disabled:v,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(xt,{"data-icon":"inline-start"}),"Deny",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]}),l&&r.jsxs(X,{variant:"outline",size:"sm",disabled:v,onClick:()=>t(o.requestId,"allow_always"),title:h?"Apply Claude's suggested scoped permission rule (S)":`Allow ${o.toolName} for this session (S)`,children:[r.jsx(s2,{"data-icon":"inline-start"}),h?"Remember rule":"Session",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"S"})]}),d&&r.jsxs(X,{variant:"secondary",size:"sm",disabled:v,onClick:()=>s("allow"),title:"Allow all pending (⇧A)",children:["Allow all",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"⇧A"})]}),a&&r.jsxs(X,{size:"sm",disabled:v,onClick:()=>t(o.requestId,"allow"),title:"Allow once (A)",children:[r.jsx(rt,{"data-icon":"inline-start"}),"Allow",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs opacity-70",children:"A"})]}),!a&&!l&&!c&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"Resolve this approval in Codex"})]})]})})}const s3=1568,o3=.85,mu=35e5;function r3(n,e){let{width:t,height:s}=n;const o=Math.min(1,s3/Math.max(t,s));t=Math.round(t*o),s=Math.round(s*o);const i=document.createElement("canvas");i.width=t,i.height=s,i.getContext("2d").drawImage(n,0,0,t,s);const l=e==="image/jpeg"||e==="image/webp",c=l?"image/jpeg":"image/png";let d=i.toDataURL(c,l?o3:void 0),f=d.split(",")[1];if(f.length>mu){let u=l?.7:.8;for(;f.length>mu&&u>.3;)d=i.toDataURL("image/jpeg",u),f=d.split(",")[1],u-=.1;return{dataUrl:d,base64:f,mediaType:"image/jpeg"}}return{dataUrl:d,base64:f,mediaType:c}}function i3(n){const e=F.c(24),t=n===void 0?!0:n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[o,i]=b.useState(s),[a,l]=b.useState(!1),[c,d]=b.useState(!1),f=b.useRef(t);let u,m;e[1]!==t?(u=()=>{f.current=t},m=[t],e[1]=t,e[2]=u,e[3]=m):(u=e[2],m=e[3]),b.useEffect(u,m);let p;e[4]!==t?(p=R=>{const D=Array.from(R).filter(c3);if(!t){D.length>0&&d(!0);return}d(!1);for(const L of D){const $=new FileReader;$.onload=()=>{if(!f.current){d(!0);return}const z=$.result,U=new Image;U.onload=()=>{if(!f.current){d(!0);return}const O=r3(U,L.type);i(H=>[...H,{id:crypto.randomUUID(),file:L,preview:O.dataUrl,data:O.base64,mediaType:O.mediaType}])},U.src=z},$.onerror=()=>{console.warn(`Failed to read image file: ${L.name}`)},$.readAsDataURL(L)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=R=>{i(D=>D.filter((L,$)=>$!==R)),d(!1)},e[6]=g):g=e[6];const v=g;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{i([]),d(!1)},e[7]=x):x=e[7];const w=x;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=()=>d(!1),e[8]=y):y=e[8];const j=y;let N;e[9]!==t?(N=R=>{R.preventDefault(),t&&l(!0)},e[9]=t,e[10]=N):N=e[10];const S=N;let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=R=>{R.preventDefault(),R.currentTarget.contains(R.relatedTarget)||l(!1)},e[11]=k):k=e[11];const C=k;let T;e[12]!==h?(T=R=>{R.preventDefault(),l(!1),R.dataTransfer.files.length>0&&h(R.dataTransfer.files)},e[12]=h,e[13]=T):T=e[13];const _=T;let P;e[14]!==h?(P=R=>{var z;const D=(z=R.clipboardData)==null?void 0:z.items;if(!D)return;const L=Array.from(D).filter(l3);if(L.length===0)return;R.preventDefault();const $=L.map(a3).filter(Boolean);h($)},e[14]=h,e[15]=P):P=e[15];const A=P,E=!t&&o.length>0?"The selected model does not accept images. Switch models or remove the attachments.":!t&&c?"The selected model does not accept the image you tried to add.":null,M=!t&&o.length>0;let I;return e[16]!==S||e[17]!==_||e[18]!==A||e[19]!==o||e[20]!==a||e[21]!==E||e[22]!==M?(I={images:o,isDragOver:a,imageError:E,hasUnsupportedAttachments:M,dismissImageError:j,removeImage:v,clearImages:w,handleDragOver:S,handleDragLeave:C,handleDrop:_,handlePaste:A},e[16]=S,e[17]=_,e[18]=A,e[19]=o,e[20]=a,e[21]=E,e[22]=M,e[23]=I):I=e[23],I}function a3(n){return n.getAsFile()}function l3(n){return n.type.startsWith("image/")}function c3(n){return n.type.startsWith("image/")}function d3(n){const e=F.c(6);let t,s;e[0]!==n?({delay:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);const o=s===void 0?0:s;let i;return e[3]!==o||e[4]!==t?(i=r.jsx(a2,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function St(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(d3,{children:r.jsx(i2,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Nt(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(o2,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function kt(n){const e=F.c(20);let t,s,o,i,a,l,c;e[0]!==n?({className:s,side:i,sideOffset:a,align:l,alignOffset:c,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=i===void 0?"top":i,f=a===void 0?4:a,u=l===void 0?"center":l,m=c===void 0?0:c;let p;e[8]!==s?(p=G("z-50 w-fit origin-(--transform-origin) overflow-hidden rounded-md bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 text-balance duration-100 ease-out data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[8]=s,e[9]=p):p=e[9];let h;e[10]!==t||e[11]!==o||e[12]!==p?(h=r.jsx(r2,{"data-slot":"tooltip-content",className:p,...o,children:t}),e[10]=t,e[11]=o,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==u||e[15]!==m||e[16]!==d||e[17]!==f||e[18]!==h?(g=r.jsx(l2,{children:r.jsx(c2,{align:u,alignOffset:m,side:d,sideOffset:f,className:"isolate z-50",children:h})}),e[14]=u,e[15]=m,e[16]=d,e[17]=f,e[18]=h,e[19]=g):g=e[19],g}const u3=33e3,pu=1e6,f3=2e5,m3=["claude-haiku-4-5","claude-haiku-4-1","claude-sonnet-4-5","claude-opus-4-5","claude-opus-4-1"];function p3(n){const e=n.trim().toLowerCase();return e.includes("[1m]")?pu:m3.some(s=>e.includes(s))?f3:pu}function h3(n,e){const t=typeof n.input_tokens=="number"?n.input_tokens:0,s=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,i=t+s+o,a=p3(e),l=a-u3;return{used:i,limit:a,compactAt:l,percent:Math.min(100,i/l*100),percentAbsolute:Math.min(100,i/a*100)}}const g3=4;function Up(n){return Math.ceil(n/g3)}function Wp(n){let e=0;for(const t of n)e+=t.length;return e}function x3(n){let e=0;for(const t of n)e+=JSON.stringify(t.input).length;return e}function v3(n){var t,s;const e=(s=(t=n.tokenUsage)==null?void 0:t.output_tokens_details)==null?void 0:s.thinking_tokens;return typeof e=="number"?e:Up(Wp(n.thinking.map(o=>o.thinking)))}function b3(n){return Up(Wp(n.assistantText)+x3(n.toolCalls))}function qn(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function ki(n){return n?n.includes("fable")?"fable":n.includes("mythos")?"mythos":n.includes("opus")?"opus":n.includes("sonnet")?"sonnet":n.includes("haiku")?"haiku":n.length>20?n.slice(0,20)+"...":n:"unknown"}function tt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function vn(n){if(n<1e3)return`${n}ms`;const e=Math.round(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return t>=60?`${Math.floor(t/60)}h ${t%60}m`:`${t}m ${s}s`}function y3(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function Hp(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Yo(n){const e=Date.now()-new Date(n).getTime(),t=Math.floor(e/6e4);if(t<1)return"now";if(t<60)return`${t}m`;const s=Math.floor(t/60);if(s<24)return`${s}h`;const o=Math.floor(s/24);return o<7?`${o}d`:new Date(n).toLocaleDateString()}function Wl(n){return n>=86400?`${Math.floor(n/86400)}d ${Math.floor(n%86400/3600)}h`:n>=3600?`${Math.floor(n/3600)}h ${Math.floor(n%3600/60)}m`:`${Math.max(1,Math.floor(n/60))}m`}function Hl(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e="";for(const s of n.toolCalls)s.timestamp&&s.timestamp>e&&(e=s.timestamp);for(const s of n.contentBlocks)s.timestamp&&s.timestamp>e&&(e=s.timestamp);if(!e)return null;const t=new Date(e).getTime()-new Date(n.timestamp).getTime();return t>0?t:null}function sn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function rn(n){return"/"+n.replace(/^-/,"").replace(/-/g,"/")}function Ci(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function _i(n){const e="/.worktrees/",t=n.indexOf(e);if(t===-1)return null;const s=n.slice(t+e.length).split("/")[0];return s?{parentPath:n.slice(0,t),worktreeName:s}:null}function Nn(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function ss(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function Kp(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return h3(t.message.usage,t.message.model??"")}return null}const gn="rounded-full border bg-background/80 shadow-sm backdrop-blur",Ti=b.memo(function(e){const t=F.c(8);let s,o;t[0]!==e?({className:s,...o}=e,t[0]=e,t[1]=s,t[2]=o):(s=t[1],o=t[2]);let i;t[3]!==s?(i=G("inline-block size-2 shrink-0 rounded-full bg-success",s),t[3]=s,t[4]=i):i=t[4];let a;return t[5]!==o||t[6]!==i?(a=r.jsx("span",{className:i,...o}),t[5]=o,t[6]=i,t[7]=a):a=t[7],a}),ma=b.memo(function(e){const t=F.c(17),{icon:s,label:o,onClick:i,disabled:a,className:l,iconClassName:c,size:d}=e,u=(d===void 0?"sm":d)==="sm"?"icon-xs":"icon-sm";let m;t[0]!==l||t[1]!==a||t[2]!==o||t[3]!==i||t[4]!==u?(m=r.jsx(X,{variant:"ghost",size:u,className:l,onClick:i,disabled:a,"aria-label":o}),t[0]=l,t[1]=a,t[2]=o,t[3]=i,t[4]=u,t[5]=m):m=t[5];let p;t[6]!==s||t[7]!==c?(p=r.jsx(s,{"data-icon":"inline-start",className:c}),t[6]=s,t[7]=c,t[8]=p):p=t[8];let h;t[9]!==m||t[10]!==p?(h=r.jsx(Nt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(kt,{children:o}),t[12]=o,t[13]=g):g=t[13];let v;return t[14]!==h||t[15]!==g?(v=r.jsxs(St,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=v):v=t[16],v});function w3(n){return n<10?"critical":n<30?"warning":"healthy"}const j3={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Vp=b.memo(function(e){const t=F.c(54),{rawMessages:s,showRemaining:o,showTooltip:i,warnOnly:a}=e,l=o===void 0?!1:o,c=i===void 0?!1:i,d=a===void 0?!1:a;let f,u,m,p,h,g,v,x,w,y,j,N,S;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){v=Symbol.for("react.early_return_sentinel");e:{const _=Kp(s);if(!_){v=null;break e}const P=Math.max(0,100-_.percent),A=w3(P);if(d&&A==="healthy"){v=null;break e}const E=Math.max(0,_.compactAt-_.used);let M;t[17]!==P||t[18]!==E||t[19]!==l?(M=l?`${P.toFixed(0)}% · ${tt(E)}`:`${P.toFixed(0)}%`,t[17]=P,t[18]=E,t[19]=l,t[20]=M):M=t[20];const I=M,R=j3[A],D=l&&"gap-1";let L;t[21]!==R||t[22]!==D?(L=G("shrink-0 tabular-nums",R,D),t[21]=R,t[22]=D,t[23]=L):L=t[23];let $;t[24]!==I||t[25]!==L?($=r.jsx(Oe,{variant:"outline",className:L,children:I}),t[24]=I,t[25]=L,t[26]=$):$=t[26];const z=$;if(!c){v=z;break e}u=St,t[27]!==z?(g=r.jsx(Nt,{render:z}),t[27]=z,t[28]=g):g=t[28],f=kt,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let U;t[30]!==E?(U=tt(E),t[30]=E,t[31]=U):U=t[31];let O;t[32]!==P?(O=P.toFixed(1),t[32]=P,t[33]=O):O=t[33],t[34]!==U||t[35]!==O?(h=r.jsxs("div",{children:[U," remaining (",O,"%)"]}),t[34]=U,t[35]=O,t[36]=h):h=t[36],x="text-muted-foreground",w=tt(_.used),y=" / ",j=tt(_.limit),N=" tokens used (",S=_.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=d,t[4]=f,t[5]=u,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=v,t[11]=x,t[12]=w,t[13]=y,t[14]=j,t[15]=N,t[16]=S}else f=t[4],u=t[5],m=t[6],p=t[7],h=t[8],g=t[9],v=t[10],x=t[11],w=t[12],y=t[13],j=t[14],N=t[15],S=t[16];if(v!==Symbol.for("react.early_return_sentinel"))return v;let k;t[37]!==x||t[38]!==w||t[39]!==y||t[40]!==j||t[41]!==N||t[42]!==S?(k=r.jsxs("div",{className:x,children:[w,y,j,N,S,"%)"]}),t[37]=x,t[38]=w,t[39]=y,t[40]=j,t[41]=N,t[42]=S,t[43]=k):k=t[43];let C;t[44]!==f||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==k?(C=r.jsxs(f,{className:m,children:[p,h,k]}),t[44]=f,t[45]=m,t[46]=p,t[47]=h,t[48]=k,t[49]=C):C=t[49];let T;return t[50]!==u||t[51]!==g||t[52]!==C?(T=r.jsxs(u,{children:[g,C]}),t[50]=u,t[51]=g,t[52]=C,t[53]=T):T=t[53],T});function hu(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function gu(n,e){n.totalInputTokens+=e.input_tokens,n.totalOutputTokens+=e.output_tokens,n.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,n.totalCacheReadTokens+=e.cache_read_input_tokens??0}function qp(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function Kl(n){const e=qp(n.length);for(const t of n){t.tokenUsage&&gu(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=hu(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=hu(s.toolCalls,e.toolCallCounts),s.tokenUsage&&gu(e,s.tokenUsage)}return e}const xu={0:"\0",b:"\b",f:"\f",n:`
|
|
3
|
+
`,r:"\r",t:" ",v:"\v"};function S3(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Hr(n){return!!(n&&/[\w$]/.test(n))}function kn(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",o=e+1;for(;o<n.length;){const i=n[o];if(i===t)return{endIndex:o+1,value:s};if(i!=="\\"){s+=i,o++;continue}if(o++,o>=n.length)return null;const a=n[o];if(a in xu){s+=xu[a],o++;continue}if(a===`
|
|
4
|
+
`){o++;continue}if(a==="\r"){o+=n[o+1]===`
|
|
5
|
+
`?2:1;continue}if(a==="x"&&/^[0-9a-fA-F]{2}$/.test(n.slice(o+1,o+3))){s+=String.fromCharCode(Number.parseInt(n.slice(o+1,o+3),16)),o+=3;continue}if(a==="u"){const l=n.slice(o+1).match(/^\{([0-9a-fA-F]+)\}/);if(l){const d=Number.parseInt(l[1],16);if(Number.isFinite(d)&&d<=1114111){s+=String.fromCodePoint(d),o+=l[0].length+1;continue}}const c=n.slice(o+1,o+5);if(/^[0-9a-fA-F]{4}$/.test(c)){s+=String.fromCharCode(Number.parseInt(c,16)),o+=5;continue}}s+=a,o++}return null}const Gn={"(":")","[":"]","{":"}"};function Vl(n,e){if(n[e]!=="/")return null;if(n[e+1]==="/"){const t=n.indexOf(`
|
|
6
|
+
`,e+2);return t===-1?n.length:t+1}if(n[e+1]==="*"){const t=n.indexOf("*/",e+2);return t===-1?n.length:t+2}return null}function Ei(n,e){const t=kn(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=Vl(n,e);return s===null?null:{endIndex:s,isString:!1}}function Dt(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=Vl(n,t);if(s===null)break;t=s}return t}function Pi(n,e){const t=n[e];if(!Gn[t])return null;const s=[Gn[t]];for(let o=e+1;o<n.length;o++){const i=Ei(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(Gn[a]){s.push(Gn[a]);continue}if(a===s.at(-1)&&(s.pop(),s.length===0))return o}return null}function Gp(n,e){if(!S3(n[e]))return null;let t=e+1;for(;Hr(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function N3(n,e,t){var f;const s=(f=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:f[1];if(!s)return t;const o=n.slice(0,e),i=new RegExp(`\\b(?:const|let|var)\\s+${s.replace(/[$]/g,"\\$")}\\s*=`,"g"),a=[...o.matchAll(i)].at(-1);if(!a||a.index===void 0)return t;const l=Dt(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const u=Pi(o,l);if(u!==null)return o.slice(l,u+1).trim()}const d=kn(o,l);return d?o.slice(l,d.endIndex).trim():t}function k3(n){const e=[];for(let t=0;t<n.length;t++){const s=Ei(n,t);if(s){t=s.endIndex-1;continue}if(!n.startsWith("tools",t)||Hr(n[t-1])||Hr(n[t+5]))continue;let o=Dt(n,t+5),i="";if(n[o]==="."){o=Dt(n,o+1);const c=Gp(n,o);if(!c)continue;i=c.value,o=c.endIndex}else if(n[o]==="["){o=Dt(n,o+1);const c=kn(n,o);if(!c||(o=Dt(n,c.endIndex),n[o]!=="]"))continue;i=c.value,o++}else continue;if(o=Dt(n,o),n[o]!=="(")continue;const a=Pi(n,o);if(a===null){e.push({name:i,argumentSource:n.slice(o+1).trim(),startIndex:t});break}const l=n.slice(o+1,a).trim();e.push({name:i,argumentSource:N3(n,t,l),startIndex:t})}return e}function Yp(n,e){return kn(n,e)??Gp(n,e)}function C3(n,e,t){const s=[];for(let o=e;o<t;o++){const i=Ei(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(Gn[a]){s.push(Gn[a]);continue}if(s.length>0&&a===s.at(-1)){s.pop();continue}if(s.length===0&&a===",")return o}return t}function ql(n,e){let t=Dt(n,0);for(;n[t]==="(";)t=Dt(n,t+1);if(n[t]!=="{")return null;const s=Pi(n,t);if(s===null)return null;let o=t+1;for(;o<s;){if(o=Dt(n,o),n[o]===","){o++;continue}const i=Yp(n,o);if(!i){o++;continue}if(o=Dt(n,i.endIndex),n[o]!==":"){o++;continue}const a=Dt(n,o+1),l=C3(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function Xp(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=Vl(n,o);if(i!==null){o=i-1;continue}const a=Yp(n,o);if(a){if(a.value===e&&!Hr(n[o-1])){const l=Dt(n,a.endIndex);if(n[l]===":"){const c=t(Dt(n,l+1));c!==null&&s.push(c)}}o=a.endIndex-1}}return s}function Gl(n,e){return Xp(n,e,t=>{var s;return((s=kn(n,t))==null?void 0:s.value)??null})}function Jp(n,e){return Xp(n,e,t=>{const s=n.slice(t).match(/^-?[\d_]+(?:\.\d+)?/);if(!s)return null;const o=Number(s[0].replaceAll("_",""));return Number.isFinite(o)?o:null})}function Zp(n){const e=Dt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=Pi(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=Ei(n,a);if(l){o||(o=l.isString),a=l.endIndex-1;continue}const c=n[a];Gn[c]?(o=!0,i.push(Gn[c])):i.length>0&&c===i.at(-1)?i.pop():i.length===0&&c===","?(o&&s++,o=!1):/\s/.test(c)||(o=!0)}return s+(o?1:0)}function vu(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function _3(n){if(!n.includes("apply_patch")||!n.includes("*** Begin Patch"))return[];const e=new Map;for(let a=0;a<n.length;a++){const l=kn(n,a);if(l){if(vu(l.value)){const c=n.slice(0,a).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);c&&e.set(c[1],l.value)}a=l.endIndex-1}}const t=[],s=new Set,o=/\btools\s*\.\s*apply_patch\s*\(/g;let i;for(;(i=o.exec(n))!==null;){let a=i.index+i[0].length;for(;/\s/.test(n[a]??"");)a++;const l=kn(n,a),c=l?null:n.slice(a).match(/^([A-Za-z_$][\w$]*)/),d=(l==null?void 0:l.value)??(c?e.get(c[1]):void 0);!d||!vu(d)||s.has(d)||(s.add(d),t.push(d))}return t}function bu(n,e){if(!e||n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n))return n;const t=e.replace(/[\\/]+$/,""),s=n.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${t}\\${s.replace(/\//g,"\\")}`:`${t}/${s}`}function yu(n,e,t,s=""){var c,d;const o=[],i=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,a=[];let l;for(;(l=i.exec(n))!==null;)a.push({action:l[1],filePath:l[2].trim(),headerIdx:l.index,startIdx:l.index+l[0].length});for(let f=0;f<a.length;f++){const u=a[f],m=f+1<a.length?a[f+1].headerIdx:n.length,p=n.slice(u.startIdx,m),h=(d=(c=p.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:c[1])==null?void 0:d.trim(),g=bu(u.filePath,s),v=bu(h||u.filePath,s),x=p.split(/^@@.*$/m).filter(N=>N.trim()),w=[],y=[];for(const N of x)for(const S of N.split(`
|
|
7
|
+
`))S.startsWith("-")?w.push(S.slice(1)):S.startsWith("+")?y.push(S.slice(1)):S.startsWith(" ")&&(w.push(S.slice(1)),y.push(S.slice(1)));const j=a.length>1?`${e}:file-${f}`:e;u.action==="Add File"?o.push({id:j,name:"Write",input:{file_path:v,content:y.join(`
|
|
8
|
+
`)},result:null,isError:!1,timestamp:t}):u.action==="Delete File"?o.push({id:j,name:"Edit",input:{file_path:v,old_string:w.join(`
|
|
9
|
+
`),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:j,name:"Edit",input:{file_path:v,...h?{old_path:g}:{},old_string:w.join(`
|
|
10
|
+
`),new_string:y.join(`
|
|
11
|
+
`)},result:null,isError:!1,timestamp:t})}return o}function T3(n,e,t,s,o=""){return n==="apply_patch"?yu(e,t,s,o):_3(e).flatMap((i,a)=>yu(i,`${t}:patch-${a}`,s,o))}function E3(n,e,t){var l;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(n))return new Set;const s=new Map;for(const c of t){const d=(l=c.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:l[1];if(d===void 0)continue;const f=Number(d),u=s.get(f)??[];u.push(c),s.set(f,u)}if(s.size===0)return new Set(t.map(c=>c.id));const o=n.toLowerCase().replaceAll("\\","/"),i=new Set;for(const[c,d]of s)d.some(f=>{const u=String(f.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!u)return!1;const p=u.split("/").filter(Boolean).slice(-2).join("/");return o.includes(u)||p.includes("/")&&o.includes(p)})&&i.add(c);for(const c of o.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const d=Number(c[1]);s.has(d)&&i.add(d)}i.size===0&&i.add(Math.max(...s.keys()));const a=Math.min(...i);for(const c of s.keys())c>=a&&i.add(c);return new Set([...i].flatMap(c=>{var d;return((d=s.get(c))==null?void 0:d.map(f=>f.id))??[]}))}function Yl(n){return typeof n=="object"&&n!==null}const P3=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]);function Xl(n){const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return P3.get(e)??n}function nl(n){if(!n)return!1;const e=n.match(/Process exited with code (\d+)/);if(e)return e[1]!=="0";const t=n.replace(/\b0\s+(?:fail(?:ed|ures?)?|errors?)\b/gi,"").replace(/\bno\s+(?:failures?|errors?)\b/gi,"");return/\b(error|failed|exception)\b/i.test(t)}function A3(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>Yl(s)).map(s=>({content:typeof s.step=="string"?s.step:"",status:typeof s.status=="string"?s.status:"pending",activeForm:typeof s.step=="string"?s.step:""}))}}function M3(n){return typeof n=="string"?n:Array.isArray(n)?n.filter(e=>Yl(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function Qp(n){const e=M3(n);if(!e)return{text:"",isError:!1};try{const t=JSON.parse(e),s=typeof t.output=="string"?t.output:e,o=Yl(t.metadata)?t.metadata:null,i=o?o.exit_code!==0&&o.exit_code!==void 0:nl(s);return{text:s,isError:i}}catch{return{text:e,isError:nl(e)}}}const R3=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function I3(n){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${n}-${Math.random().toString(36).slice(2,10)}`}function eh(n){try{return JSON.parse(n)}catch{return null}}function ot(n){return typeof n=="object"&&n!==null}function th(n){return!n||typeof n.type!="string"?!1:n.type==="session_meta"||n.type==="turn_context"||n.type==="event_msg"||n.type==="response_item"||n.type==="inter_agent_communication_metadata"||n.type==="compacted"||n.type==="world_state"}function Kr(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>ot(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
12
|
+
`).trim():""}const $3=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,O3=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function nh(n){if(typeof n!="string")return null;const e=$3.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function sh(n){if(typeof n!="string")return null;const e=O3.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function D3(n){return Array.isArray(n.images)?n.images.map(nh).filter(e=>e!==null):[]}function L3(n){return Array.isArray(n.audio)?n.audio.map(sh).filter(e=>e!==null):[]}function oh(n){return Array.isArray(n.content)?n.content.filter(e=>ot(e)&&e.type==="input_image").map(e=>nh(e.image_url)).filter(e=>e!==null):[]}function rh(n){return Array.isArray(n.content)?n.content.filter(e=>ot(e)&&e.type==="input_audio").map(e=>sh(e.audio_url)).filter(e=>e!==null):[]}function wu(n,e,t=[],s=[],o=[]){const i=[...s.map(l=>`
|
|
13
|
+
`),...o.map(l=>`
|
|
14
|
+
[audio attachment](<${l}>)`)].join(""),a=n+i;return e.length===0&&t.length===0?a:[...e,...t,...a?[{type:"text",text:a}]:[]]}function z3(n){var a,l;const e=Kr(n,"input_text");if(!e)return{messageType:null,text:""};const t=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!t||t.index===void 0)return{messageType:null,text:e.trim()};const o=((l=(a=e.slice(0,t.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:a[1])==null?void 0:l.trim().toUpperCase())??null,i=e.slice(t.index+t[0].length).trim();return{messageType:o,text:i}}function ro(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function F3(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function sl(n){const e=n.trim();return!e||R3.some(t=>e.startsWith(t))?"":e}function B3(n,e){return n?{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0)}:{...e}}function U3(n){if(!ot(n))return null;const e=typeof n.input_tokens=="number"?n.input_tokens:0,t=typeof n.output_tokens=="number"?n.output_tokens:0,s=typeof n.cache_write_input_tokens=="number"?n.cache_write_input_tokens:typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cached_input_tokens=="number"?Math.max(0,n.cached_input_tokens):null,i=o??(typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0),a=o===null?e:Math.max(0,e-o);return a===0&&t===0&&s===0&&i===0?null:{input_tokens:a,output_tokens:t,cache_creation_input_tokens:s,cache_read_input_tokens:i}}function W3(n,e,t){if(!e)return;n.assistantText.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if(s&&s.kind==="text"){s.text.push(e);return}n.contentBlocks.push({kind:"text",text:[e],timestamp:t})}function H3(n,e,t){if(!e)return;const s={type:"thinking",thinking:e,signature:""};n.thinking.push(s);const o=n.contentBlocks[n.contentBlocks.length-1];if(o&&o.kind==="thinking"){o.blocks.push(s);return}n.contentBlocks.push({kind:"thinking",blocks:[s],timestamp:t})}function Cs(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if(s&&s.kind==="tool_calls"&&s.timestamp===t){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function Nr(n,e,t){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&t){const o=new Date(e.timestamp).getTime(),i=new Date(t).getTime();Number.isFinite(o)&&Number.isFinite(i)&&i>=o&&(e.durationMs=i-o)}return n.push(e),null}function ju(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return ot(e)?e:{value:e}}catch{return{raw:n}}}function io(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function Su(...n){return n.find(e=>typeof e=="string")}function K3(n){return n.startsWith("exec-")}function V3(n){if(!ot(n))return{text:io(n),isError:!1};if("Err"in n)return{text:io(n.Err),isError:!0};const e=ot(n.Ok)?n.Ok:null;if(!e)return{text:io(n),isError:!1};const t=Qp(e.content);return{text:t.text||(e.structuredContent!==void 0?io(e.structuredContent):io(e)),isError:e.isError===!0||t.isError}}function q3(n,e,t){return{id:n?`${n}@${e}`:I3("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function ih(n){return n.type==="event_msg"&&ot(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?sl(n.payload.message):n.type==="response_item"&&ot(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?sl(Kr(n.payload,"input_text")):""}function G3(n,e){if(n.type==="session_meta"||n.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(n.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return ih(n)!==""||oh(e).length>0||rh(e).length>0}return!0}function Y3(n){let e="",t="",s="",o="",i="",a,l="",c="",d="",f="",u=0,m=!1,p=null,h="/root",g="";for(const v of n){if(!ot(v.payload))continue;if(v.type==="session_meta"){if(e||(e=typeof v.payload.id=="string"?v.payload.id:""),t||(t=typeof v.payload.cli_version=="string"?v.payload.cli_version:""),o||(o=typeof v.payload.cwd=="string"?v.payload.cwd:""),!a&&ot(v.payload.branchedFrom)){const j=typeof v.payload.branchedFrom.sessionId=="string"?v.payload.branchedFrom.sessionId:"";j&&(a={sessionId:j,turnIndex:typeof v.payload.branchedFrom.turnIndex=="number"?v.payload.branchedFrom.turnIndex:null})}const w=ot(v.payload.source)?v.payload.source:null;if(w&&ot(w.subagent)){m=!0;const j=ot(w.subagent.thread_spawn)?w.subagent.thread_spawn:null;j&&typeof j.agent_path=="string"&&(h=j.agent_path)}typeof v.payload.forked_from_id=="string"&&v.payload.forked_from_id&&(p=v.payload.forked_from_id);const y=ot(v.payload.git)?v.payload.git:null;s||(s=y&&typeof y.branch=="string"?y.branch:"")}v.type==="turn_context"&&(i||(i=typeof v.payload.model=="string"?v.payload.model:""),o||(o=typeof v.payload.cwd=="string"?v.payload.cwd:""));const x=ih(v);x&&x!==g&&(l||(l=x),c=x,g=x,u++,d||(d=v.timestamp??""),f=v.timestamp??f)}return f===""&&(f=d),{sessionId:e,version:t,gitBranch:s,cwd:o,model:i,slug:"",name:"",branchedFrom:a,firstUserMessage:l,lastUserMessage:c,timestamp:d,lastTimestamp:f,turnCount:u,isSubagent:m,parentSessionId:p,agentPath:h}}function Xo(n){for(const e of n.split(`
|
|
15
|
+
`)){const t=e.trim();if(t)return th(eh(t))}return!1}function Jl(n,e){const t=n.split(`
|
|
16
|
+
`).map(S=>S.trim()).filter(Boolean).map(eh).filter(th),s=Y3(t),o=[],i=new Map,a=new Map,l=new Map,c=new Map,d=new Map,f=new Map,u=new Map,m=new Map;function p(S,k,C,T={}){const _=d.get(S);let P=m.get(S);if(!P){const E={agentId:S,parentToolUseId:(_==null?void 0:_.parentToolCallId)||void 0,agentName:(_==null?void 0:_.nickname)??(_!=null&&_.agentPath?ro(_.agentPath):null),subagentType:(_==null?void 0:_.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(_==null?void 0:_.timestamp)??C,tokenUsage:null,model:(_==null?void 0:_.model)??null,isBackground:!1,prompt:(_==null?void 0:_.message)||void 0,status:T.status??"running"};k.subAgentActivity.push(E);const M=k.contentBlocks[k.contentBlocks.length-1];(M==null?void 0:M.kind)==="sub_agent"?M.messages.push(E):k.contentBlocks.push({kind:"sub_agent",messages:[E],timestamp:C}),P={message:E,turn:k},m.set(S,P)}const A=P.message;if(_&&(A.parentToolUseId=_.parentToolCallId||A.parentToolUseId,A.agentName=_.nickname??(_.agentPath?ro(_.agentPath):A.agentName),A.subagentType=_.agentType,A.model=_.model,A.prompt=_.message||A.prompt),T.text&&!A.text.includes(T.text)&&(A.text.push(T.text),A.content=A.text.join(`
|
|
17
|
+
|
|
18
|
+
`)),T.status){const E=new Set(["completed","failed","interrupted"]);if(T.status==="running"&&A.status&&E.has(A.status)||(A.status=T.status),E.has(T.status)&&A.timestamp&&C){const M=new Date(A.timestamp).getTime(),I=new Date(C).getTime();Number.isFinite(M)&&Number.isFinite(I)&&I>=M&&(A.durationMs=I-M)}}return A}let h=null,g=null,v=s.model||null,x="",w=null,y=!1;function j(S,k,C){const T=q3(S,k,C);return y||(T.isFragment=!0),w&&(T.compactionSummary=w,w=null),T}function N(S,k,C,T,_){const P=a.get(k);if(P){P.input={...P.input,...C},P.result=T,P.isError=T==="failed";return}const A={id:k,name:"WebSearch",input:C,result:T,isError:T==="failed",timestamp:_};a.set(k,A),Cs(S,A,_)}for(const S of t){const k=ot(S.payload)?S.payload:void 0,C=S.timestamp??"";if(S.type==="compacted"){h=Nr(o,h,x),w="Conversation compacted",x=C;continue}if(S.type!=="world_state"){if(S.type==="turn_context"){h=Nr(o,h,x),g=typeof(k==null?void 0:k.turn_id)=="string"?k.turn_id:null,v=typeof(k==null?void 0:k.model)=="string"?k.model:v,x=C,y=!0;continue}if(S.type==="event_msg"&&(k==null?void 0:k.type)==="user_message"&&typeof k.message=="string"){h&&(h.assistantText.length>0||h.toolCalls.length>0||h.thinking.length>0)&&(h=Nr(o,h,x)),y=!0,h??(h=j(g,C,v));const T=(Array.isArray(k.local_images)?k.local_images:[]).filter(P=>typeof P=="string"&&P.length>0),_=(Array.isArray(k.local_audio)?k.local_audio:[]).filter(P=>typeof P=="string"&&P.length>0);h.userMessage=wu(k.message,D3(k),L3(k),T,_),h.isFragment=!1,h.timestamp=h.timestamp||C,x=C;continue}if(!(!h&&!G3(S,k))){if(h??(h=j(g,C,v)),!h.model&&v&&(h.model=v),h.timestamp||(h.timestamp=C),C&&(x=C),S.type==="event_msg"&&(k==null?void 0:k.type)==="token_count"){const T=ot(k.info)?k.info:null,_=T?U3(T.last_token_usage):null;_&&(h.tokenUsage=B3(h.tokenUsage,_));continue}if(S.type==="event_msg"&&(k==null?void 0:k.type)==="web_search_end"&&typeof k.call_id=="string"){const T={};typeof k.query=="string"&&k.query&&(T.query=k.query),ot(k.action)&&(T.action=k.action),N(h,k.call_id,T,"completed",C);continue}if(S.type==="event_msg"&&(k==null?void 0:k.type)==="mcp_tool_call_end"&&typeof k.call_id=="string"&&ot(k.invocation)){const T=k.invocation,_=typeof T.server=="string"?T.server:"mcp",P=typeof T.tool=="string"?T.tool:"tool",A=ot(T.arguments)?T.arguments:{},E=V3(k.result),M=i.get(k.call_id);M?(M.result=E.text,M.isError=E.isError,i.delete(k.call_id)):K3(k.call_id)||Cs(h,{id:k.call_id,name:`mcp__${_}__${P}`,input:A,result:E.text,isError:E.isError,timestamp:C},C);continue}if(S.type==="event_msg"&&(k==null?void 0:k.type)==="sub_agent_activity"&&typeof k.agent_thread_id=="string"&&typeof k.agent_path=="string"){const T=k.agent_thread_id,_=typeof k.event_id=="string"?k.event_id:"",P=typeof k.kind=="string"?k.kind:"started",A=_?c.get(_):void 0,E=f.get(k.agent_path),M=d.get(T)??(E?d.get(E):void 0);if(P!=="started"&&!M&&!A)continue;if(E&&E!==T&&!m.has(T)){const D=m.get(E);D&&(D.message.agentId=T,m.delete(E),m.set(T,D)),d.delete(E)}const I={agentId:T,nickname:(M==null?void 0:M.nickname)??ro(k.agent_path)??(A==null?void 0:A.taskName)??null,agentPath:k.agent_path,message:(M==null?void 0:M.message)??(A==null?void 0:A.message)??"",model:(M==null?void 0:M.model)??(A==null?void 0:A.model)??null,agentType:(M==null?void 0:M.agentType)??(A==null?void 0:A.agentType)??null,timestamp:(M==null?void 0:M.timestamp)??(C||(A==null?void 0:A.timestamp)||""),parentToolCallId:(M==null?void 0:M.parentToolCallId)??_};d.set(T,I),f.set(k.agent_path,T),_&&(P==="started"||A)&&u.set(_,T),p(T,h,C,{status:P==="interrupted"?"interrupted":"running"});continue}if(!(S.type!=="response_item"||!k)){if(k.type==="reasoning"){const T=Array.isArray(k.summary)?k.summary.filter(_=>typeof _=="string").join(`
|
|
19
|
+
`):"";H3(h,T.trim(),C);continue}if(k.type==="message"&&k.role==="assistant"){W3(h,Kr(k,"output_text"),C);continue}if(k.type==="message"&&k.role==="user"&&h.userMessage===null){const T=sl(Kr(k,"input_text")),_=oh(k),P=rh(k);(T||_.length>0||P.length>0)&&(h.userMessage=wu(T,_,P),h.isFragment=!1,y=!0);continue}if(k.type==="web_search_call"&&typeof k.id=="string"){const T={};ot(k.action)&&(T.action=k.action);const _=typeof k.status=="string"?k.status:"completed";N(h,k.id,T,_,C);continue}if(k.type==="tool_search_call"){const T=Su(k.call_id,k.id)??"";if(T){const _={id:T,name:"ToolSearch",input:ot(k.arguments)?k.arguments:{},result:null,isError:!1,timestamp:C};i.set(T,_),Cs(h,_,C)}continue}if(k.type==="tool_search_output"&&typeof k.call_id=="string"){const T=i.get(k.call_id);if(T){const _=Array.isArray(k.tools)?k.tools:[],P=_.filter(ot).map(M=>Su(M.name)??"").filter(Boolean),A=P.length>0?P.length:_.length,E=`Found ${A} tool${A===1?"":"s"}`;T.result=P.length>0?`${E}: ${P.join(", ")}`:E,T.isError=k.status==="failed",i.delete(k.call_id)}continue}if(k.type==="agent_message"&&typeof k.author=="string"){const T=k.author,_=typeof k.recipient=="string"?k.recipient:null,P=z3(k);if(P.messageType==="NEW_TASK")continue;const A=f.get(T),E=T.startsWith(`${s.agentPath}/`)&&(_===null||_===s.agentPath);if(!A&&!E)continue;const M=A??T;A||(d.set(M,{agentId:M,nickname:ro(T),agentPath:T,message:"",model:null,agentType:null,timestamp:C,parentToolCallId:""}),f.set(T,M));let I;P.messageType==="FINAL_ANSWER"?I="completed":P.messageType==="ERROR"||P.messageType==="FAILED"?I="failed":P.messageType==="INTERRUPTED"?I="interrupted":P.messageType==="MESSAGE"&&(I="running"),p(M,h,C,{status:I,text:P.text||void 0});continue}if(k.type==="function_call"&&typeof k.call_id=="string"){const T=typeof k.name=="string"?k.name:"tool",_=Xl(T),P=ju(k.arguments);let A=_,E=P;_==="exec_command"?A="Bash":_==="update_plan"&&(A="TodoWrite",E=A3(P)),_==="spawn_agent"&&c.set(k.call_id,{callId:k.call_id,message:F3(P.message),taskName:typeof P.task_name=="string"?P.task_name:null,model:typeof P.model=="string"?P.model:null,agentType:typeof P.agent_type=="string"?P.agent_type:null,timestamp:C});const M={id:k.call_id,name:A,input:E,result:null,isError:!1,timestamp:C};i.set(M.id,M),Cs(h,M,C);continue}if(k.type==="function_call_output"&&typeof k.call_id=="string"){const T=i.get(k.call_id);if(!T)continue;const _=typeof k.output=="string"?k.output:null;if(T.result=_,T.isError=nl(_),i.delete(k.call_id),T.name==="spawn_agent"&&_)try{const P=JSON.parse(_),A=typeof P.agent_id=="string"?P.agent_id:u.get(T.id)??"",E=typeof P.task_name=="string"?P.task_name:null,M=typeof P.nickname=="string"?P.nickname:E?ro(E):null;if(A){const I=c.get(T.id),R=d.get(A),D={agentId:A,nickname:M??(R==null?void 0:R.nickname)??(I==null?void 0:I.taskName)??null,agentPath:E??(R==null?void 0:R.agentPath)??null,message:(R==null?void 0:R.message)??(I==null?void 0:I.message)??"",model:(R==null?void 0:R.model)??(I==null?void 0:I.model)??null,agentType:(R==null?void 0:R.agentType)??(I==null?void 0:I.agentType)??null,timestamp:(R==null?void 0:R.timestamp)??(I==null?void 0:I.timestamp)??C,parentToolCallId:(R==null?void 0:R.parentToolCallId)??T.id};d.set(A,D),u.set(T.id,A),D.agentPath&&f.set(D.agentPath,A),p(A,h,C,{status:"running"})}}catch{}if(T.name==="wait_agent"&&_&&h)try{const P=JSON.parse(_),A=ot(P.status)?P.status:{};for(const[E,M]of Object.entries(A)){const I=ot(M)?M:{},R=typeof I.completed=="string"?I.completed:"",D=typeof I.failed=="string"?I.failed:typeof I.error=="string"?I.error:"",L=typeof I.interrupted=="string"?I.interrupted:"",$=R?"completed":D?"failed":L?"interrupted":typeof I.status=="string"?I.status:"running";d.has(E)||d.set(E,{agentId:E,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:C,parentToolCallId:""}),p(E,h,C,{status:$,text:R||D||L||void 0})}}catch{}continue}if(k.type==="custom_tool_call"&&typeof k.call_id=="string"){const T=typeof k.name=="string"?k.name:"tool",_=typeof k.input=="string"?k.input:"",P=k.call_id,A=_?T3(T,_,P,C,s.cwd):[];if(T!=="apply_patch"){const E={id:P,name:T==="exec_command"?"Bash":T,input:ju(_),result:null,isError:!1,timestamp:C};i.set(E.id,E),Cs(h,E,C)}for(const E of A)i.set(E.id,E),Cs(h,E,C);A.length>0&&l.set(P,{calls:A,direct:T==="apply_patch"});continue}if(k.type==="custom_tool_call_output"&&typeof k.call_id=="string"){const T=k.call_id,{text:_,isError:P}=Qp(k.output),A=l.get(T);if(A){const M=A.direct&&P?new Set(A.calls.map(I=>I.id)):E3(_,P,A.calls);for(const I of A.calls){const R=i.get(I.id);R&&(R.result=_,R.isError=M.has(R.id),i.delete(R.id))}l.delete(T)}const E=i.get(T);E&&(E.result=_,E.isError=P,i.delete(T));continue}}}}}return Nr(o,h,x),{sessionId:s.sessionId,version:s.version,gitBranch:s.gitBranch,cwd:s.cwd,slug:s.slug,name:"",model:s.model,turns:o,stats:Kl(o),rawMessages:t,branchedFrom:s.branchedFrom,agentKind:"codex"}}const Zl="codex__";function Ai(n){return typeof n=="string"&&n.startsWith(Zl)}function ah(n){const e=new TextEncoder().encode(n);let t="";for(const s of e)t+=String.fromCharCode(s);return`${Zl}${btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function X3(n){const e=(n==null?void 0:n.mode)||"default";return e==="bypassPermissions"?["--dangerously-bypass-approvals-and-sandbox"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']}function J3(n){return n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[]}function Z3(n){return n?["-m",n]:[]}function Q3(n){return`'${n.replace(/'/g,"'\\''")}'`}function ew(n,e){return e?`codex -C ${Q3(e)} resume ${n}`:`codex resume ${n}`}const lh={kind:"codex",isDirName:Ai,isSessionText:Xo,resumeCommand:ew,buildPermArgs:X3,buildModelArgs:Z3,buildEffortArgs:J3};function tw(n){return(n.replace(/[\\/]+$/,"")||n).replace(/[^a-zA-Z0-9]/g,"-")}function nw(n){if(!n||!n.mode)return["--permission-mode","default"];if(n.mode==="bypassPermissions")return["--dangerously-skip-permissions"];const e=[],s={default:"default",plan:"plan",acceptEdits:"acceptEdits",dontAsk:"dontAsk",auto:"auto"}[n.mode];if(s&&e.push("--permission-mode",s),n.allowedTools)for(const o of n.allowedTools)e.push("--allowedTools",o);if(n.disallowedTools)for(const o of n.disallowedTools)e.push("--disallowedTools",o);return e}function sw(n){return n?["--model",n]:[]}function ow(n){return n?["--effort",n]:[]}function rw(n){return typeof n=="string"&&!n.startsWith(Zl)}function iw(n,e){return`claude --resume ${n}`}const aw={kind:"claude",isDirName:rw,isSessionText:n=>!Xo(n),resumeCommand:iw,buildPermArgs:nw,buildModelArgs:sw,buildEffortArgs:ow},lw=new Map([["codex",lh],["claude",aw]]);function cw(n){const e=lw.get(n);if(!e)throw new Error(`Unknown provider kind: ${n}`);return e}function Jt(n){return lh.isDirName(n)?"codex":"claude"}const dw=/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\.jsonl$/;function uw(n){const e=dw.exec(n);return e?e[1]:n.replace(".jsonl","")}function ch(n,e,t){return cw(n).resumeCommand(e,t)}function fw(n,e,t){return t==="codex"?ah(e):n}function Nu(n,e){return e==="codex"?ah(n):tw(n)}function ku(n){return n.replace(/\/+$/,"")||"/"}function mw(n,e){var s;const t=ku(e);return((s=n.find(o=>!Ai(o.dirName)&&ku(o.path)===t))==null?void 0:s.dirName)??null}function pw(n){const e=F.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=st(),{chat:a}=qo(),{isConnected:l}=a,c=l||i;let d;e[0]!==o||e[1]!==t||e[2]!==s||e[3]!==c?(d=c&&!t&&!s&&r.jsxs("div",{className:"motion-enter mr-1 flex items-center gap-1.5",children:[o>0&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:y3(o)}),r.jsx(Ti,{})]}),e[0]=o,e[1]=t,e[2]=s,e[3]=c,e[4]=d):d=e[4];let f;return e[5]!==d?(f=r.jsx(r.Fragment,{children:d}),e[5]=d,e[6]=f):f=e[6],f}function hw(n){const e=F.c(24),{hasContent:t,onSubmit:s,submitLabel:o}=n,i=o===void 0?"Send message":o,{isLive:a,sessionSource:l,actions:c}=st(),{handleStopSession:d}=c,{chat:f}=qo(),{isConnected:u,interrupt:m}=f,p=u||a;let h;e[0]!==(l==null?void 0:l.agentKind)||e[1]!==(l==null?void 0:l.dirName)?(h=(l==null?void 0:l.agentKind)??Jt((l==null?void 0:l.dirName)??null),e[0]=l==null?void 0:l.agentKind,e[1]=l==null?void 0:l.dirName,e[2]=h):h=e[2];const g=h,v=g==="codex"?"Stop active turn":"Interrupt agent";let x;e[3]!==v||e[4]!==m||e[5]!==p?(x=p&&r.jsxs(St,{children:[r.jsx(Nt,{render:r.jsx(X,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":v,title:v}),children:r.jsx(Ol,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(kt,{children:[v," (Esc)"]})]}),e[3]=v,e[4]=m,e[5]=p,e[6]=x):x=e[6];let w;e[7]!==g||e[8]!==d||e[9]!==p?(w=p&&g!=="codex"&&r.jsxs(St,{children:[r.jsx(Nt,{render:r.jsx(X,{variant:"ghost",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:d,"aria-label":"Stop session",title:"Stop session"}),children:r.jsx(d2,{"data-icon":"inline-start"})}),r.jsx(kt,{children:"Stop session"})]}),e[7]=g,e[8]=d,e[9]=p,e[10]=w):w=e[10];const y=t?"default":"secondary",j=!t&&"text-muted-foreground";let N;e[11]!==j?(N=G("shrink-0 rounded-full",j),e[11]=j,e[12]=N):N=e[12];const S=!t;let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(u2,{"data-icon":"inline-start"}),e[13]=k):k=e[13];let C;e[14]!==s||e[15]!==i||e[16]!==S||e[17]!==y||e[18]!==N?(C=r.jsx(X,{variant:y,size:"icon-sm",className:N,disabled:S,onClick:s,"aria-label":i,title:i,children:k}),e[14]=s,e[15]=i,e[16]=S,e[17]=y,e[18]=N,e[19]=C):C=e[19];let T;return e[20]!==C||e[21]!==x||e[22]!==w?(T=r.jsxs("div",{className:"flex items-center gap-1",children:[x,w,C]}),e[20]=C,e[21]=x,e[22]=w,e[23]=T):T=e[23],T}function Cu(n){const e=F.c(34),{error:t}=n,[s,o]=b.useState(!1),[i,a]=b.useState(!1);let l;e[0]!==t?(l=t.split(`
|
|
20
|
+
`),e[0]=t,e[1]=l):l=e[1];const c=l[0];let d;e[2]!==t||e[3]!==c?(d=t.includes(`
|
|
21
|
+
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=d):d=e[4];const f=d;let u;e[5]!==t?(u=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},e[5]=t,e[6]=u):u=e[6];const m=u;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>o(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ln,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=r.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let v;e[11]!==f?(v=f&&r.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=f,e[12]=v):v=e[12];let x;e[13]!==g||e[14]!==v?(x=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,v]}),e[13]=g,e[14]=v,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(as,{children:[r.jsxs(Ln,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(ln,{className:"size-4"}),"Error details"]}),r.jsx(zn,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let y;e[17]!==t?(y=r.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=y):y=e[18];let j;e[19]!==i?(j=i?r.jsx(rt,{"data-icon":"inline-start"}):r.jsx(bn,{"data-icon":"inline-start"}),e[19]=i,e[20]=j):j=e[20];const N=i?"Copied":"Copy";let S;e[21]!==m||e[22]!==j||e[23]!==N?(S=r.jsx("div",{className:"flex justify-end",children:r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,N]})}),e[21]=m,e[22]=j,e[23]=N,e[24]=S):S=e[24];let k;e[25]!==y||e[26]!==S?(k=r.jsxs(Dn,{className:"max-w-2xl",children:[w,y,S]}),e[25]=y,e[26]=S,e[27]=k):k=e[27];let C;e[28]!==s||e[29]!==k?(C=r.jsx(On,{open:s,onOpenChange:o,children:k}),e[28]=s,e[29]=k,e[30]=C):C=e[30];let T;return e[31]!==C||e[32]!==x?(T=r.jsxs(r.Fragment,{children:[x,C]}),e[31]=C,e[32]=x,e[33]=T):T=e[33],T}function gw(n){const e=F.c(17),{suggestion:t,onAccept:s}=n,[o,i]=b.useState(null);if(!t||t===o)return null;let a;e[0]!==s||e[1]!==t?(a=()=>{i(t),s(t)},e[0]=s,e[1]=t,e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Vm,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=r.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let d;e[6]!==a||e[7]!==c?(d=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:a,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=a,e[7]=c,e[8]=d):d=e[8];let f;e[9]!==t?(f=()=>i(t),e[9]=t,e[10]=f):f=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(xt,{}),e[11]=u):u=e[11];let m;e[12]!==f?(m=r.jsx(X,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:f,className:"shrink-0 text-muted-foreground",children:u}),e[12]=f,e[13]=m):m=e[13];let p;return e[14]!==d||e[15]!==m?(p=r.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[d,m]}),e[14]=d,e[15]=m,e[16]=p):p=e[16],p}function xw(n){const e=/(?:^|\s)@([^\s]*)$/.exec(n);if(!e||e.index===void 0)return null;const t=e[0].lastIndexOf("@");return{start:e.index+t,query:e[1]??""}}function vw(n,e,t){return`${n.slice(0,e.start)}@${t} `}const Mi={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Jo={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let dh=Mi;const ol=new Set;function zs(n){dh=(n==null?void 0:n.capabilities)??Mi;for(const e of ol)e()}function at(n){return dh[n]}function bw(n){return ol.add(n),()=>ol.delete(n)}function cn(n){const e=F.c(3);let t,s;return e[0]!==n?(t=()=>at(n),s=()=>at(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),b.useSyncExternalStore(bw,t,s)}function yw(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function ww(n,e,t){const s=cn("hostFiles"),[o,i]=b.useState([]),[a,l]=b.useState(!1);return b.useEffect(()=>{if(!s||!t||!n){i([]),l(!1);return}const c=new AbortController,d=window.setTimeout(async()=>{l(!0);try{const f=await ye(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!f.ok)throw new Error(`Request failed (${f.status})`);const u=await f.json();c.signal.aborted||i(yw(u))}catch{c.signal.aborted||i([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(d),c.abort()}},[s,n,t,e]),{files:o,loading:a}}const rl="cogpit-share-revoked";function jw(){window.dispatchEvent(new Event(rl))}async function uh(n,e){const t=new Headers(e==null?void 0:e.headers);t.set("X-Cogpit-Client","1");const s=await fetch(n,{...e,headers:t,credentials:"same-origin",cache:"no-store"});return s.status===401&&jw(),s}function Zo(n,e){return uh(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function Sw(){let n;try{n=await fetch("/api/share/session",{credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}catch{return{status:"error",message:"Could not reach the server."}}if(n.status===401)return{status:"unauthenticated"};if(!n.ok)return{status:"error",message:`The server refused the request (${n.status}).`};try{return{status:"ok",info:await n.json()}}catch{return{status:"error",message:"The server sent an unreadable response."}}}function Nw(n,e){return Zo("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function kw(){return Zo("/api/share/interrupt")}function Cw(){return Zo("/api/share/stop")}async function _w(n,e){return(await Zo("/api/share/permission",{requestId:n,behavior:e})).ok}async function Tw(n,e){try{const t=await Zo("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function Ew(){try{const n=await uh("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const Pw=/^\/shared\/([^/]+)\/?$/;function fh(n){const e=Pw.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function Ri(n){return fh(n)!==null}function Aw(n){return`/shared/${encodeURIComponent(n)}`}function EA(n){return[...n].join(", ")}async function Ql(n,e,t){if(Ri(window.location.pathname))return Tw(e,t);try{const s=await ye("/api/ask-user-answer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n,toolUseId:e,answers:t})});return{ok:s.ok,gone:s.status===404}}catch{return{ok:!1,gone:!1}}}function Ii(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("textarea",{"data-slot":"textarea",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ao(n,e){if(!n)return!1;const t=n.offsetHeight;n.style.transition="none",n.style.height="auto";const s=Math.min(n.scrollHeight,200);let o;if(e){const a=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,o=n.scrollHeight>48,n.style.width=a}else o=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",o}function Mw(n,e,t,s,o,i){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":i?o?"Steer…":"Message…":o?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function Rw(n,e,t){return t?"border-warning/40 focus-within:border-warning/60 focus-within:ring-warning/15":n||e?"border-info/40 focus-within:border-info/60 focus-within:ring-info/15":"border-input focus-within:border-ring focus-within:ring-ring/20"}const il=b.memo(b.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,compact:i=!1},a){var Fe;const l=cn("hostFiles"),{session:c,isLive:d,actions:{handleEditConfig:f},pendingInteraction:u,permissionRequests:m,permissionResponding:p,respondPermission:h,respondAllPermissions:g,slashSuggestions:v,slashSuggestionsLoading:x,turnError:w,promptSuggestion:y}=st(),{chat:{status:j,error:N,isConnected:S,sendMessage:k,interrupt:C}}=qo(),T=S||d,[_,P]=b.useState(""),[A,E]=b.useState(!1),M=b.useRef(!1),I=b.useRef(""),R=b.useRef(null);b.useEffect(()=>{I.current=_},[_]);const D=b.useCallback(ue=>{M.current=ue,E(ue)},[]),{images:L,isDragOver:$,imageError:z,hasUnsupportedAttachments:U,dismissImageError:O,removeImage:H,clearImages:B,handleDragOver:W,handleDragLeave:V,handleDrop:q,handlePaste:Y}=i3(e),[K,J]=b.useState(0),[Z,Q]=b.useState(0),[se,ne]=b.useState(!1),ee=_.startsWith("/")&&!_.includes(" "),ie=ee?_.slice(1):"",oe=b.useMemo(()=>{if(!ee)return[];const ue=ie.toLowerCase(),le=v.filter(je=>ue?je.name.toLowerCase().includes(ue)||je.description.toLowerCase().includes(ue):!0),Me=le.filter(je=>je.type==="command"),Le=le.filter(je=>je.type==="skill");return[...Me,...Le]},[ee,ie,v]),re=b.useMemo(()=>xw(_),[_]),te=!!(l&&re&&s&&!se),ce=ww(s,(re==null?void 0:re.query)??"",te);b.useEffect(()=>{J(0)},[ie]),b.useEffect(()=>{Q(0)},[re==null?void 0:re.query]);const me=Cp(S),pe=b.useCallback(async ue=>{const le=u;if(!(c!=null&&c.sessionId)||(le==null?void 0:le.type)!=="question")return;const Me=le.questions[0];if(!Me||!ue.trim())return;(await Ql(c.sessionId,le.toolUseId,{[Me.question]:ue})).ok||k(ue)},[u,c==null?void 0:c.sessionId,k]),xe=b.useCallback(ue=>{P(`/${ue.name} `),J(0),requestAnimationFrame(()=>{const le=R.current;le&&(le.focus(),le.selectionStart=le.selectionEnd=le.value.length,D(ao(le,M.current)))})},[D]),we=b.useCallback(ue=>{P(ue),requestAnimationFrame(()=>{const le=R.current;le&&(le.focus(),le.selectionStart=le.selectionEnd=le.value.length,D(ao(le,M.current)))})},[D]),ae=b.useCallback(ue=>{if(!re)return;const le=vw(_,re,ue);P(le),ne(!0),Q(0),requestAnimationFrame(()=>{const Me=R.current;Me&&(Me.focus(),Me.selectionStart=Me.selectionEnd=Me.value.length,D(ao(Me,M.current)))})},[re,_,D]),ve=b.useCallback(()=>{const ue=_.trim();if(!ue&&L.length===0||!e&&L.length>0)return;if((u==null?void 0:u.type)==="question"){pe(ue),P(""),D(!1),R.current&&(R.current.style.height="auto");return}const le=e&&L.length>0?L.map(Me=>({data:Me.data,mediaType:Me.mediaType})):void 0;k(ue,le),P(""),B(),D(!1),R.current&&(R.current.style.height="auto")},[_,L,e,k,B,D,u,pe]),he=b.useCallback(ue=>{if(te&&ue.key==="Escape"){ue.preventDefault(),ne(!0);return}if(te&&ce.files.length>0){if(ue.key==="ArrowDown"){ue.preventDefault(),Q(le=>le<ce.files.length-1?le+1:0);return}if(ue.key==="ArrowUp"){ue.preventDefault(),Q(le=>le>0?le-1:ce.files.length-1);return}if(ue.key==="Tab"||ue.key==="Enter"&&!ue.shiftKey){ue.preventDefault();const le=ce.files[Z];le&&ae(le);return}}if(ee&&oe.length>0){if(ue.key==="ArrowDown"){ue.preventDefault(),J(le=>le<oe.length-1?le+1:0);return}if(ue.key==="ArrowUp"){ue.preventDefault(),J(le=>le>0?le-1:oe.length-1);return}if(ue.key==="Tab"||ue.key==="Enter"&&!ue.shiftKey){ue.preventDefault();const le=oe[K];le&&xe(le);return}if(ue.key==="Escape"){ue.preventDefault(),P("");return}}if(ue.key==="Escape"&&T&&C){ue.preventDefault(),C();return}ue.key==="Enter"&&!ue.shiftKey&&(ue.preventDefault(),ve())},[ve,T,C,te,ce.files,Z,ae,ee,oe,K,xe]),de=b.useCallback(ue=>{P(ue.target.value),ne(!1),D(ao(ue.target,M.current))},[D]);b.useImperativeHandle(a,()=>({focus:()=>{var ue;return(ue=R.current)==null?void 0:ue.focus()},getText:()=>I.current,setText:ue=>{P(ue),ne(!1),requestAnimationFrame(()=>D(ao(R.current,M.current)))}}),[D]);const Ne=(u==null?void 0:u.type)==="plan",ke=(u==null?void 0:u.type)==="question",Te=m.length>0,Ae=(_.trim().length>0||L.length>0)&&!U,Pe=t==="codex"&&T,De=te?"file-suggestions":ee?"slash-suggestions":void 0,ze=te&&ce.files[Z]?`file-suggestion-${Z}`:ee&&oe[K]?`slash-suggestion-${K}`:void 0;return r.jsxs("div",{className:G("relative bg-background pb-0",i?"px-2 pt-2":"px-3 pt-2",$&&"ring-2 ring-info/40 ring-inset"),onDragOver:W,onDragLeave:V,onDrop:q,children:[$&&r.jsx("div",{className:"motion-enter pointer-events-none absolute inset-0 flex items-center justify-center rounded-lg border-2 border-dashed border-info/40 bg-info/10",children:r.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),ee&&r.jsx(Hy,{suggestions:oe,filter:ie,loading:x,selectedIndex:K,onSelect:xe,onHover:J,onEdit:f}),te&&r.jsx(Gy,{files:ce.files,query:(re==null?void 0:re.query)??"",loading:ce.loading,selectedIndex:Z,onSelect:ae,onHover:Q}),r.jsxs("div",{children:[Ne&&r.jsx(Jy,{allowedPrompts:u.allowedPrompts,onApprove:()=>k("yes"),onSend:k}),r.jsx(gw,{suggestion:y,onAccept:we}),L.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:L.map((ue,le)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:ue.preview,alt:`Upload ${le+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>H(le),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-background p-0 text-muted-foreground opacity-100 hover:bg-destructive hover:text-destructive-foreground sm:opacity-0 sm:group-hover/thumb:opacity-100 sm:focus-visible:opacity-100","aria-label":`Remove image ${le+1}`,children:r.jsx(xt,{className:"size-3","data-icon":"icon"})})]},ue.id))}),z&&r.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[r.jsx("span",{className:"flex-1",children:z}),!U&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:O,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(xt,{"data-icon":"icon"})})]}),r.jsxs("div",{className:G("relative overflow-hidden rounded-xl border bg-prompt-surface shadow-xs",Rw(Ne,ke,Te),"focus-within:ring-3"),children:[Te&&r.jsx(n3,{requests:m,responding:p,onRespond:h,onRespondAll:g},(Fe=m[0])==null?void 0:Fe.requestId),r.jsxs("div",{className:G("grid min-w-0 items-end",A?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]"),children:[o&&r.jsx("div",{className:G("flex shrink-0 items-center",A?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:o}),r.jsx(Ii,{ref:R,value:_,onChange:de,onKeyDown:he,onPaste:Y,onFocus:()=>{setTimeout(()=>{var ue;return(ue=R.current)==null?void 0:ue.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:Mw(Ne,ke,S,Te,Pe,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!De,"aria-controls":De,"aria-activedescendant":ze,rows:1,className:G("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",A?G("col-span-2 row-start-1",i?"py-2.5 pr-3":"py-3 pr-4"):G("col-start-2 row-start-1",i?"py-2 pr-1":"py-2.5 pr-2"),i?"pl-2 text-sm":"pl-4 text-sm")}),r.jsxs("div",{className:G("flex shrink-0 items-center justify-end",A?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"),children:[r.jsx(pw,{isPlanApproval:Ne,isUserQuestion:ke,elapsedSec:me}),r.jsx(hw,{hasContent:Ae,onSubmit:ve,submitLabel:Pe?"Steer active turn":"Send message"})]})]})]}),j==="error"&&N&&r.jsx(Cu,{error:N},N),w&&r.jsx(Cu,{error:w},w)]})]})}));function Iw(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function $w(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=Iw(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const o=typeof s.condition=="string"?s.condition:"",i=s.met===!0,a=s.failed===!0;return s.sentinel===!0&&i||!o?null:{condition:o,status:a?"failed":i?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}const Ow={section:null,canCreate:!1,beginEditing:()=>{}},ec=b.createContext(Ow);function mh(){return b.useContext(ec)}const ph="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",hh="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function Dw(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function Lw(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function zw(n){const e=F.c(80),{session:t,onSendCommand:s,children:o}=n;let i;e[0]!==t.rawMessages?(i=$w(t.rawMessages),e[0]=t.rawMessages,e[1]=i):i=e[1];const a=i,[l,c]=b.useState(),[d,f]=b.useState(!1),[u,m]=b.useState(""),[p,h]=b.useState(null),g=a?`${a.status}\0${a.condition}`:"",[v,x]=b.useState(g);v!==g&&(x(g),c(void 0));const w=l!==void 0?l:a;let y;e[2]!==(w==null?void 0:w.condition)?(y=()=>{m((w==null?void 0:w.condition)??""),h(null),f(!0)},e[2]=w==null?void 0:w.condition,e[3]=y):y=e[3];const j=y;let N;e[4]!==u||e[5]!==s?(N=()=>{const M=u.trim();if(M){if(M.length>4e3){h("Goal conditions can be at most 4,000 characters");return}c({condition:M,status:"active",iterations:0,durationMs:0,tokens:0}),f(!1),s(`/goal ${M}`)}},e[4]=u,e[5]=s,e[6]=N):N=e[6];const S=N;let k;e[7]!==s?(k=()=>{c(null),f(!1),s("/goal clear")},e[7]=s,e[8]=k):k=e[8];const C=k;let T;if(e[9]!==j||e[10]!==C||e[11]!==u||e[12]!==d||e[13]!==p||e[14]!==w||e[15]!==S){if(T=null,d){let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Co,{className:"size-3.5","data-icon":"inline-start"}),e[17]=M):M=e[17];const I=w?"Replace goal":"Set a long-running goal";let R;e[18]!==I?(R=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,I]}),e[18]=I,e[19]=R):R=e[19];const D=!!p;let L;e[20]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(mt,{className:"sr-only",htmlFor:"claude-goal-condition",children:"Goal condition"}),e[20]=L):L=e[20];let $;e[21]===Symbol.for("react.memo_cache_sentinel")?($=K=>m(K.target.value),e[21]=$):$=e[21];const z=!!p;let U;e[22]!==u||e[23]!==z?(U=r.jsx(Ii,{id:"claude-goal-condition",value:u,onChange:$,placeholder:"A measurable condition Claude should keep working toward…",rows:2,maxLength:4e3,"aria-invalid":z,autoFocus:!0}),e[22]=u,e[23]=z,e[24]=U):U=e[24];let O;e[25]!==p?(O=r.jsx(Jn,{children:p}),e[25]=p,e[26]=O):O=e[26];let H;e[27]!==U||e[28]!==O||e[29]!==D?(H=r.jsxs(ft,{"data-invalid":D,children:[L,U,O]}),e[27]=U,e[28]=O,e[29]=D,e[30]=H):H=e[30];let B;e[31]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>f(!1),children:[r.jsx(xt,{"data-icon":"inline-start"}),"Cancel"]}),e[31]=B):B=e[31];let W;e[32]!==u?(W=u.trim(),e[32]=u,e[33]=W):W=e[33];const V=!W;let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(rt,{"data-icon":"inline-start"}),e[34]=q):q=e[34];let Y;e[35]!==S||e[36]!==V?(Y=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[B,r.jsxs(X,{type:"button",size:"xs",onClick:S,disabled:V,children:[q,"Start goal"]})]}),e[35]=S,e[36]=V,e[37]=Y):Y=e[37],T=r.jsxs("section",{className:hh,"aria-label":"Claude goal editor",children:[R,H,Y]})}else if(w){let M;e[38]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Co,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[38]=M):M=e[38];let I;e[39]!==w.condition?(I=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:w.condition,children:w.condition}),e[39]=w.condition,e[40]=I):I=e[40];let R;e[41]!==w.status?(R=Lw(w.status),e[41]=w.status,e[42]=R):R=e[42];let D;e[43]!==w.status?(D=Dw(w.status),e[43]=w.status,e[44]=D):D=e[44];let L;e[45]!==R||e[46]!==D?(L=r.jsx(Oe,{variant:R,children:D}),e[45]=R,e[46]=D,e[47]=L):L=e[47];const $=w.iterations,z=w.iterations===1?"":"s";let U;e[48]!==w.tokens?(U=tt(w.tokens),e[48]=w.tokens,e[49]=U):U=e[49];let O;e[50]!==w.durationMs?(O=Math.round(w.durationMs/6e4),e[50]=w.durationMs,e[51]=O):O=e[51];const H=Math.max(0,O);let B;e[52]!==w.iterations||e[53]!==z||e[54]!==U||e[55]!==H?(B=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[$," turn",z," · ",U," · ",H,"m"]}),e[52]=w.iterations,e[53]=z,e[54]=U,e[55]=H,e[56]=B):B=e[56];let W;e[57]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(ws,{"data-icon":"icon"}),e[57]=W):W=e[57];let V;e[58]!==j?(V=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:j,"aria-label":"Replace goal",children:W}),e[58]=j,e[59]=V):V=e[59];let q;e[60]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(mi,{"data-icon":"icon"}),e[60]=q):q=e[60];let Y;e[61]!==C?(Y=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Clear goal",children:q}),e[61]=C,e[62]=Y):Y=e[62];let K;e[63]!==V||e[64]!==Y?(K=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[V,Y]}),e[63]=V,e[64]=Y,e[65]=K):K=e[65];let J;e[66]!==B||e[67]!==K||e[68]!==I||e[69]!==L?(J=r.jsxs("div",{className:"flex items-center gap-2",children:[M,I,L,B,K]}),e[66]=B,e[67]=K,e[68]=I,e[69]=L,e[70]=J):J=e[70];let Z;e[71]!==w.reason?(Z=w.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:w.reason}),e[71]=w.reason,e[72]=Z):Z=e[72],T=r.jsxs("section",{className:ph,"aria-label":"Claude goal",children:[J,Z]})}e[9]=j,e[10]=C,e[11]=u,e[12]=d,e[13]=p,e[14]=w,e[15]=S,e[16]=T}else T=e[16];const _=!w&&!d;let P;e[73]!==j||e[74]!==T||e[75]!==_?(P={section:T,canCreate:_,beginEditing:j},e[73]=j,e[74]=T,e[75]=_,e[76]=P):P=e[76];const A=P;let E;return e[77]!==o||e[78]!==A?(E=r.jsx(ec.Provider,{value:A,children:o}),e[77]=o,e[78]=A,e[79]=E):E=e[79],E}function Pt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(f2,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function tc(n){const e=F.c(13);let t,s,o,i;e[0]!==n?({className:s,children:t,value:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e[5]!==s?(a=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=a):a=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Fw,{children:r.jsx(Bw,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(m2,{value:i,"data-slot":"progress",className:a,...o,children:[t,l]}),e[8]=t,e[9]=o,e[10]=a,e[11]=i,e[12]=c):c=e[12],c}function Fw(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(p2,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Bw(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(h2,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Uw(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function Ww(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function Hw({threadId:n,children:e}){const[t,s]=b.useState(null),[o,i]=b.useState(!0),[a,l]=b.useState(!1),[c,d]=b.useState(""),[f,u]=b.useState(""),[m,p]=b.useState(!1),[h,g]=b.useState(null),v=b.useCallback(async C=>{try{const T=await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{signal:C});if(T.status===404||T.status===501){i(!1);return}if(!T.ok)return;const _=await T.json();s(_.goal),i(!0)}catch{}},[n]);b.useEffect(()=>{const C=new AbortController;v(C.signal);const T=o?setInterval(()=>void v(),1e4):void 0;return()=>{C.abort(),T!==void 0&&clearInterval(T)}},[v,o]);const x=b.useCallback(()=>{var C;d((t==null?void 0:t.objective)??""),u(((C=t==null?void 0:t.tokenBudget)==null?void 0:C.toString())??""),g(null),l(!0)},[t]),w=async()=>{const C=c.trim();if(!C)return;const T=f.trim()?Number(f):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){g("Token budget must be a positive whole number");return}p(!0),g(null);try{const _=await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:C,status:(t==null?void 0:t.status)==="complete"?"active":(t==null?void 0:t.status)??"active",tokenBudget:T})}),P=await _.json();if(!_.ok)throw new Error(P.error||"Could not save goal");s(P.goal),l(!1)}catch(_){g(_ instanceof Error?_.message:"Could not save goal")}finally{p(!1)}},y=async C=>{if(t){p(!0);try{const T=await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:C})});T.ok&&s((await T.json()).goal)}finally{p(!1)}}},j=async()=>{p(!0);try{(await ye(`/api/codex/goals/${encodeURIComponent(n)}`,{method:"DELETE"})).ok&&(s(null),l(!1))}finally{p(!1)}},N=t!=null&&t.tokenBudget?Math.min(100,t.tokensUsed/t.tokenBudget*100):null;let S=null;if(o&&a)S=r.jsxs("form",{className:hh,onSubmit:C=>{C.preventDefault(),w()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(Co,{className:"size-3.5","data-icon":"inline-start"}),t?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(Qs,{className:"gap-2",children:[r.jsxs(ft,{children:[r.jsx(mt,{className:"sr-only",htmlFor:"codex-goal-objective",children:"Goal objective"}),r.jsx(Ii,{id:"codex-goal-objective",value:c,onChange:C=>d(C.target.value),placeholder:"What should Codex keep working toward?",rows:2,autoFocus:!0})]}),r.jsxs(ft,{orientation:"horizontal","data-invalid":!!h,children:[r.jsx(mt,{className:"text-xs text-muted-foreground",htmlFor:"codex-goal-budget",children:"Token budget"}),r.jsx(Pt,{id:"codex-goal-budget",type:"number",min:1,step:1,value:f,onChange:C=>u(C.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!h})]})]}),r.jsx(Jn,{className:"mt-1.5",children:h}),r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(!1),children:[r.jsx(xt,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(X,{type:"submit",size:"xs",disabled:m||!c.trim(),children:[r.jsx(rt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(o&&t){const C=t.status==="paused",T=t.status==="complete";S=r.jsxs("section",{className:ph,"aria-label":"Codex goal",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Co,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:t.objective,children:t.objective}),r.jsx(Oe,{variant:Ww(t.status),children:Uw(t.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[tt(t.tokensUsed),t.tokenBudget?` / ${tt(t.tokenBudget)}`:""," · ",Math.max(0,Math.round(t.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[C&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void y("active"),disabled:m,"aria-label":"Resume goal",children:r.jsx(Uo,{"data-icon":"icon"})}),!C&&!T&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void y("paused"),disabled:m,"aria-label":"Pause goal",children:r.jsx(g2,{"data-icon":"icon"})}),!T&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void y("complete"),disabled:m,"aria-label":"Mark goal complete",children:r.jsx(rt,{"data-icon":"icon"})}),r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:x,"aria-label":"Edit goal",children:r.jsx(ws,{"data-icon":"icon"})}),r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j(),disabled:m,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(mi,{"data-icon":"icon"})})]})]}),N!==null&&r.jsx(tc,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const k=b.useMemo(()=>({section:S,canCreate:o&&!t&&!a,beginEditing:x}),[S,o,t,a,x]);return r.jsx(ec.Provider,{value:k,children:e})}function Kw(n){const e=F.c(7),{agentKind:t,session:s,onSendCommand:o,children:i}=n;if(t==="codex"){let l;return e[0]!==i||e[1]!==s.sessionId?(l=r.jsx(Hw,{threadId:s.sessionId,children:i}),e[0]=i,e[1]=s.sessionId,e[2]=l):l=e[2],l}let a;return e[3]!==i||e[4]!==o||e[5]!==s?(a=r.jsx(zw,{session:s,onSendCommand:o,children:i}),e[3]=i,e[4]=o,e[5]=s,e[6]=a):a=e[6],a}function gh(){return mh().section}function xh(){const n=F.c(3),{canCreate:e,beginEditing:t}=mh();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Co,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let o;return n[1]!==t?(o=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:t,title:"Set a long-running goal for this session",children:[s,"Set goal"]}),n[1]=t,n[2]=o):o=n[2],o}function Vw(){const n=F.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(gh,{}),r.jsx(xh,{})]}),n[0]=e):e=n[0],e}const qw=/\x1b\].*?(?:\x07|\x1b\\)/g,Gw=/\x1b\[[0-9;]*[A-Za-z]/g,Yw=/\x1b[()][AB012]/g,Xw=/\[2K\[1G/g;function vh(n){return n.replace(qw,"").replace(Gw,"").replace(Yw,"").replace(Xw,`
|
|
22
|
+
`).replace(/\r/g,"")}function Qo(n){const e=F.c(14);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("relative overflow-hidden",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(v2,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),e[6]=t,e[7]=a):a=e[7];let l,c;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Jw,{}),c=r.jsx(b2,{}),e[8]=l,e[9]=c):(l=e[8],c=e[9]);let d;return e[10]!==o||e[11]!==i||e[12]!==a?(d=r.jsxs(x2,{"data-slot":"scroll-area",className:i,...o,children:[a,l,c]}),e[10]=o,e[11]=i,e[12]=a,e[13]=d):d=e[13],d}function Jw(n){const e=F.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t?(a=G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",t),e[4]=t,e[5]=a):a=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(w2,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[6]=l):l=e[6];let c;return e[7]!==i||e[8]!==s||e[9]!==a?(c=r.jsx(y2,{"data-slot":"scroll-area-scrollbar","data-orientation":i,orientation:i,className:a,...s,children:l}),e[7]=i,e[8]=s,e[9]=a,e[10]=c):c=e[10],c}function bh(n){const e=F.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function Zw(n){const e=F.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function Qw(n){const e=F.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a=r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function ej(n){const e=F.c(11);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a,l;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),l=r.jsx("path",{className:"status-icon-spin",d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a,e[7]=l):(i=e[5],a=e[6],l=e[7]);let c;return e[8]!==s||e[9]!==o?(c=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a,l]}),e[8]=s,e[9]=o,e[10]=c):c=e[10],c}function It(n){const e=F.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o,i;if(e[3]!==t){const l=t==null?void 0:t.replace(/\banimate-spin\b/g,"").trim();o=bh,i=G(l),e[3]=t,e[4]=o,e[5]=i}else o=e[4],i=e[5];let a;return e[6]!==o||e[7]!==s||e[8]!==i?(a=r.jsx(o,{className:i,...s}),e[6]=o,e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function tj(n){const e=cn("hostFiles"),[t,s]=b.useState([]),[o,i]=b.useState(!1),a=b.useCallback(async()=>{if(!e||!n){s([]);return}i(!0);try{const l=await ye(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{i(!1)}},[e,n]);return b.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const _u=500,nj=5e3;function sj(n){const e=F.c(29),t=n===void 0?!0:n,[s,o]=b.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=b.useState(i),c=b.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const f=b.useRef(d),u=b.useRef(_u),m=b.useRef(null),p=b.useRef(!1),h=b.useRef(oj);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=z=>{var H;const U=z.type,O=z.id;if(U==="sessions"){l(z.sessions??[]);return}O&&((H=f.current.get(O))==null||H(U,z))},e[2]=g):g=e[2];const v=g;let x,w;e[3]!==t?(x=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const z=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${pp()}/__pty`},U=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const H=new WebSocket(z());c.current=H,H.onopen=()=>{if(p.current){H.close();return}u.current=_u,o("connected"),H.send(JSON.stringify({type:"list"}))},H.onmessage=B=>{try{const W=JSON.parse(B.data);v(W)}catch{}},H.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const B=u.current;u.current=Math.min(B*2,nj),m.current=setTimeout(()=>h.current(),B)}};return h.current=U,U(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},w=[t,v],e[3]=t,e[4]=x,e[5]=w):(x=e[4],w=e[5]),b.useEffect(x,w);let y;e[6]!==t?(y=z=>{if(!t)return;const U=c.current;U&&U.readyState===WebSocket.OPEN&&U.send(JSON.stringify(z))},e[6]=t,e[7]=y):y=e[7];const j=y;let N;e[8]===Symbol.for("react.memo_cache_sentinel")?(N=(z,U)=>{f.current.set(z,U)},e[8]=N):N=e[8];const S=N;let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=z=>{f.current.delete(z)},e[9]=k):k=e[9];const C=k;let T;e[10]!==j?(T=z=>{const U=z===void 0?{}:z,O=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:O,name:U.name??"Terminal",cwd:U.cwd,metadata:{type:"terminal"}}),O},e[10]=j,e[11]=T):T=e[11];const _=T;let P;e[12]!==j?(P=z=>{const U=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:U,name:z.name,cwd:z.cwd,args:["run",z.scriptName],command:"bun",metadata:{type:"script",source:z.source,scriptName:z.scriptName}}),U},e[12]=j,e[13]=P):P=e[13];const A=P;let E;e[14]!==j?(E=z=>{j({type:"kill",id:z})},e[14]=j,e[15]=E):E=e[15];const M=E;let I;e[16]!==j?(I=(z,U)=>{j({type:"input",id:z,data:U})},e[16]=j,e[17]=I):I=e[17];const R=I;let D;e[18]!==j?(D=(z,U,O)=>{j({type:"resize",id:z,cols:U,rows:O})},e[18]=j,e[19]=D):D=e[19];const L=D;let $;return e[20]!==M||e[21]!==L||e[22]!==j||e[23]!==a||e[24]!==A||e[25]!==_||e[26]!==s||e[27]!==R?($={status:s,send:j,subscribe:S,unsubscribe:C,sessions:a,spawnTerminal:_,spawnScript:A,killSession:M,writeInput:R,resize:L},e[20]=M,e[21]=L,e[22]=j,e[23]=a,e[24]=A,e[25]=_,e[26]=s,e[27]=R,e[28]=$):$=e[28],$}function oj(){}const yh=b.createContext(null);function pa(n){const e=F.c(3),{children:t,enabled:s}=n,i=sj(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(yh.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function nc(){const n=b.useContext(yh);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function rj(n){var f;const e=F.c(11),t=nc();let s;if(e[0]!==t.sessions){s=new Map;for(const u of t.sessions)((f=u.metadata)==null?void 0:f.type)==="script"&&s.set(u.id,{id:u.id,name:u.name,cwd:u.cwd,status:u.status==="running"?"running":"stopped",source:u.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const o=s;let i;e[2]!==n||e[3]!==t?(i=(u,m,p)=>{const h=t.spawnScript({name:u,cwd:m,source:p,scriptName:u}),g=p==="root/"?u:`${p.replace(/\/$/,"")}:${u}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=i):i=e[4];const a=i;let l;e[5]!==t?(l=u=>{t.killSession(u)},e[5]=t,e[6]=l):l=e[6];const c=l;let d;return e[7]!==a||e[8]!==o||e[9]!==c?(d={runningProcesses:o,runScript:a,stopScript:c},e[7]=a,e[8]=o,e[9]=c,e[10]=d):d=e[10],d}function ij(n){const e=F.c(14),{script:t,status:s,onRun:o,onStop:i}=n,a=s==="running";let l="bg-transparent";a?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=a?i:o,d=a?`Stop ${t.name}`:`Run: ${t.command}`;let f;e[0]!==l?(f=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=f):f=e[1];let u;e[2]!==f?(u=r.jsx("span",{className:f}),e[2]=f,e[3]=u):u=e[3];let m;e[4]!==t.name?(m=r.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.name}),e[4]=t.name,e[5]=m):m=e[5];let p;e[6]!==a?(p=a?r.jsx(Ol,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(Uo,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=a,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==d||e[10]!==u||e[11]!==m||e[12]!==p?(h=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:d,children:[u,m,p]}),e[8]=c,e[9]=d,e[10]=u,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const aj=b.memo(function(e){const t=F.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=b.useState(!1),[l,c]=b.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[f,u]=b.useState(d),{scripts:m,loading:p}=tj(s),{runningProcesses:h,runScript:g,stopScript:v}=rj(o);let x;if(t[1]!==m||t[2]!==l){const U=l.trim().toLowerCase(),O=U?m.filter(H=>H.name.toLowerCase().includes(U)||H.dirLabel.toLowerCase().includes(U)):m;x=new Map;for(const H of O){const B=x.get(H.dirLabel)??[];B.push(H),x.set(H.dirLabel,B)}t[1]=m,t[2]=l,t[3]=x}else x=t[3];const w=x;let y;if(t[4]!==h){y=new Map;for(const[U,O]of h)y.set(`${O.name}:${O.cwd}`,{id:U,status:O.status});t[4]=h,t[5]=y}else y=t[5];const j=y;if(!s||!p&&m.length===0)return null;let N;t[6]===Symbol.for("react.memo_cache_sentinel")?(N=function(O){u(H=>{const B=new Set(H);return B.has(O)?B.delete(O):B.add(O),B})},t[6]=N):N=t[6];const S=N;let k;t[7]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=k):k=t[7];let C;t[8]!==p?(C=p&&r.jsx(It,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=C):C=t[9];const T=i?"Close script search":"Search scripts";let _,P;t[10]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{a(lj),c("")},P=r.jsx(an,{}),t[10]=_,t[11]=P):(_=t[10],P=t[11]);let A;t[12]!==i||t[13]!==T?(A=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm","aria-label":T,"aria-expanded":i,onClick:_,children:P}),t[12]=i,t[13]=T,t[14]=A):A=t[14];let E;t[15]!==C||t[16]!==A?(E=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[k,C,A]}),t[15]=C,t[16]=A,t[17]=E):E=t[17];let M;t[18]!==i||t[19]!==l?(M=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(Pt,{type:"search",value:l,onChange:U=>c(U.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=i,t[19]=l,t[20]=M):M=t[20];let I;t[21]!==f||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==v?(I=[...w.entries()].map(U=>{const[O,H]=U,B=f.has(O)||!!l,W=H.filter(cj),V=H.filter(dj),q=B?H:W.length>0?W:H.slice(0,1);return r.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&r.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:O}),q.map(Y=>{const K=j.get(`${Y.name}:${Y.dir}`);return r.jsx(ij,{script:Y,status:(K==null?void 0:K.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{K&&v(K.id)}},`${O}:${Y.name}`)}),!l&&V.length>0&&r.jsx(X,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>S(O),children:B?"Show less":`Show ${V.length} more`})]},O)}),t[21]=f,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=v,t[27]=I):I=t[27];let R;t[28]!==w.size||t[29]!==p||t[30]!==l?(R=!p&&w.size===0&&l&&r.jsx(En,{className:"gap-1 p-3",children:r.jsxs(Pn,{className:"gap-1",children:[r.jsx(An,{children:"No matching scripts"}),r.jsx(Mn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=R):R=t[31];let D;t[32]!==I||t[33]!==R?(D=r.jsxs(Qo,{className:"min-h-0 flex-1 px-1 pb-1",children:[I,R]}),t[32]=I,t[33]=R,t[34]=D):D=t[34];let L;t[35]!==M||t[36]!==D||t[37]!==E?(L=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,M,D]}),t[35]=M,t[36]=D,t[37]=E,t[38]=L):L=t[38];let $;t[39]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Et,{orientation:"vertical"}),t[39]=$):$=t[39];let z;return t[40]!==L?(z=r.jsxs(r.Fragment,{children:[L,$]}),t[40]=L,t[41]=z):z=t[41],z});function lj(n){return!n}function cj(n){return n.isCommon}function dj(n){return!n.isCommon}function wt(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(S2,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function dn(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(N2,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function jt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("h-[var(--collapsible-panel-height)] overflow-hidden opacity-100 transition-[height,opacity] duration-150 ease-out [&[hidden]:not([hidden='until-found'])]:hidden motion-safe:data-starting-style:h-0 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:h-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(j2,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function wh(n){const e=F.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(_2,{"data-slot":"tabs","data-orientation":i,className:a,...s}),e[6]=i,e[7]=s,e[8]=a,e[9]=l):l=e[9],l}const uj=Cn("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function jh(n){const e=F.c(17);let t,s,o,i;e[0]!==n?({className:s,children:t,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==s||e[6]!==a?(l=G(uj({variant:a}),"relative isolate",s),e[5]=s,e[6]=a,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5"),e[8]=c):c=e[8];let d;e[9]!==a?(d=r.jsx(E2,{"data-slot":"tabs-indicator","data-variant":a,className:c}),e[9]=a,e[10]=d):d=e[10];let f;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==d||e[15]!==a?(f=r.jsxs(C2,{"data-slot":"tabs-list","data-variant":a,className:l,...o,children:[t,d]}),e[11]=t,e[12]=o,e[13]=l,e[14]=d,e[15]=a,e[16]=f):f=e[16],f}function po(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(T2,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ho(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(k2,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const fj=b.lazy(()=>Ve(()=>import("./TerminalOutput-SImEU6_6.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function mj({process:n}){const[e,t]=b.useState(""),[s,o]=b.useState(!1),i=b.useRef(null);return b.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=Vo(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`);else return;t(""),o(!1);const l=new EventSource(a);return l.onopen=()=>o(!0),l.onmessage=c=>{try{const d=JSON.parse(c.data);if(d.type==="output"&&d.text){const f=vh(d.text);f&&t(u=>{const m=u+f;return m.length>1e5?m.slice(-1e5):m})}}catch{}},l.onerror=()=>{},()=>l.close()},[n.id,n.type,n.outputPath]),b.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e]),r.jsx("pre",{ref:i,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||r.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function pj(n){const e=F.c(34),{process:t,isActive:s,onSelectActive:o,onClose:i,mobile:a}=n,l=t.source??t.name,c=t.id,d=t.name;let f;e[0]!==s||e[1]!==o?(f=()=>{s&&o()},e[0]=s,e[1]=o,e[2]=f):f=e[2];const u=a?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==u?(m=G("h-6 min-w-0 justify-start py-0 text-xs",u),e[3]=u,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&r.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&r.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=r.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const v=a&&"hidden";let x;e[11]!==v?(x=G("px-1 py-0 font-normal",v),e[11]=v,e[12]=x):x=e[12];let w;e[13]!==t.type||e[14]!==x?(w=r.jsx(Oe,{variant:"secondary",className:x,children:t.type}),e[13]=t.type,e[14]=x,e[15]=w):w=e[15];let y;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==f||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(y=r.jsxs(po,{value:c,"aria-label":d,onClick:f,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=f,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=y):y=e[24];const j=`Close ${t.name}`,N=`Close ${t.name}`;let S;e[25]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(xt,{"data-icon":"inline-start"}),e[25]=S):S=e[25];let k;e[26]!==i||e[27]!==j||e[28]!==N?(k=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:N,onClick:i,className:"mr-0.5 text-muted-foreground",children:S}),e[26]=i,e[27]=j,e[28]=N,e[29]=k):k=e[29];let C;return e[30]!==l||e[31]!==y||e[32]!==k?(C=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[y,k]}),e[30]=l,e[31]=y,e[32]=k,e[33]=C):C=e[33],C}const Sh=100,Nh=600,hj=200,kh="process-panel-height";function gj(){try{const n=localStorage.getItem(kh);if(n)return Math.min(Nh,Math.max(Sh,Number(n)))}catch{}return hj}const xj=b.memo(function(e){const t=F.c(89),{processes:s,activeProcessId:o,collapsed:i,onSetActive:a,onRemove:l,onToggleCollapse:c,onRequestTerminal:d,onAddTerminalContext:f,onUpdateStatus:u,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,v=nc(),[x,w]=b.useState(gj),y=b.useRef(null);let j,N;t[0]!==u||t[1]!==v.sessions?(j=()=>{for(const ae of v.sessions)ae.status==="exited"&&(u==null||u(ae.id,"stopped"))},N=[v.sessions,u],t[0]=u,t[1]=v.sessions,t[2]=j,t[3]=N):(j=t[2],N=t[3]),b.useEffect(j,N);let S;t[4]!==l||t[5]!==v?(S=ae=>{ae.type!=="task"&&v.killSession(ae.id),l(ae.id)},t[4]=l,t[5]=v,t[6]=S):S=t[6];const k=S;let C;t[7]!==x?(C=ae=>{ae.preventDefault(),y.current={startY:ae.clientY,startH:x},ae.target.setPointerCapture(ae.pointerId)},t[7]=x,t[8]=C):C=t[8];const T=C;let _;t[9]===Symbol.for("react.memo_cache_sentinel")?(_=ae=>{if(!y.current)return;const ve=y.current.startY-ae.clientY,he=Math.min(Nh,Math.max(Sh,y.current.startH+ve));w(he)},t[9]=_):_=t[9];const P=_;let A;t[10]!==x?(A=()=>{if(y.current){y.current=null;try{localStorage.setItem(kh,String(x))}catch{}}},t[10]=x,t[11]=A):A=t[11];const E=A;let M;t[12]!==o||t[13]!==s?(M=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=M):M=t[14];const I=M;let R;t[15]!==s?(R=[...s.values()],t[15]=s,t[16]=R):R=t[16];const D=R;let L;t[17]!==a?(L=ae=>{typeof ae=="string"&&a(ae)},t[17]=a,t[18]=L):L=t[18];let $;t[19]!==I||t[20]!==i||t[21]!==g||t[22]!==T||t[23]!==E?($=!g&&!i&&I&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:T,onPointerMove:P,onPointerUp:E,onPointerCancel:E}),t[19]=I,t[20]=i,t[21]=g,t[22]=T,t[23]=E,t[24]=$):$=t[24];const z=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let U;t[25]!==z?(U=G("flex shrink-0 items-center border-b bg-card",z),t[25]=z,t[26]=U):U=t[26];const O=i?"Expand terminal panel":"Collapse terminal panel",H=!i;let B;t[27]!==i?(B=i?r.jsx(et,{"data-icon":"inline-start"}):r.jsx(nt,{"data-icon":"inline-start"}),t[27]=i,t[28]=B):B=t[28];const W=g&&"sr-only";let V;t[29]!==W?(V=G(W),t[29]=W,t[30]=V):V=t[30];let q;t[31]!==V?(q=r.jsx("span",{className:V,children:"Terminal"}),t[31]=V,t[32]=q):q=t[32];let Y;t[33]!==c||t[34]!==O||t[35]!==H||t[36]!==B||t[37]!==q?(Y=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":O,"aria-expanded":H,children:[B,q]}),t[33]=c,t[34]=O,t[35]=H,t[36]=B,t[37]=q,t[38]=Y):Y=t[38];const K=!g&&"ml-2";let J;t[39]!==K?(J=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",K),t[39]=K,t[40]=J):J=t[40];let Z;t[41]!==o||t[42]!==k||t[43]!==g||t[44]!==a||t[45]!==D?(Z=D.map(ae=>r.jsx(pj,{process:ae,isActive:ae.id===o,onSelectActive:()=>a(ae.id),onClose:()=>k(ae),mobile:g},ae.id)),t[41]=o,t[42]=k,t[43]=g,t[44]=a,t[45]=D,t[46]=Z):Z=t[46];let Q;t[47]!==J||t[48]!==Z?(Q=r.jsx(jh,{variant:"default","aria-label":"Open processes",className:J,children:Z}),t[47]=J,t[48]=Z,t[49]=Q):Q=t[49];let se;t[50]!==d||t[51]!==m?(se=d&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:d,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:r.jsx(xn,{})}),t[50]=d,t[51]=m,t[52]=se):se=t[52];let ne;t[53]!==U||t[54]!==Y||t[55]!==Q||t[56]!==se?(ne=r.jsxs("div",{className:U,children:[Y,Q,se]}),t[53]=U,t[54]=Y,t[55]=Q,t[56]=se,t[57]=ne):ne=t[57];const ee=!i,ie=g?"min(36dvh, 260px)":x;let oe;t[58]!==ie?(oe={height:ie},t[58]=ie,t[59]=oe):oe=t[59];let re;t[60]!==g||t[61]!==p||t[62]!==m?(re=!g&&r.jsx(aj,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=re):re=t[63];let te;t[64]!==k||t[65]!==f||t[66]!==d||t[67]!==D?(te=D.map(ae=>r.jsx(ho,{value:ae.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ae.type==="task"?r.jsx(mj,{process:ae}):r.jsx(b.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(fj,{processId:ae.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>k(ae),onAddContext:f})})},ae.id)),t[64]=k,t[65]=f,t[66]=d,t[67]=D,t[68]=te):te=t[68];let ce;t[69]!==I||t[70]!==d||t[71]!==m?(ce=!I&&r.jsxs(En,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:r.jsx(Zs,{})}),r.jsx(An,{children:"No terminal open"}),r.jsx(Mn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(fp,{children:r.jsxs(X,{type:"button",size:"sm",onClick:d,children:[r.jsx(xn,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=I,t[70]=d,t[71]=m,t[72]=ce):ce=t[72];let me;t[73]!==te||t[74]!==ce?(me=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[te,ce]}),t[73]=te,t[74]=ce,t[75]=me):me=t[75];let pe;t[76]!==oe||t[77]!==re||t[78]!==me?(pe=r.jsx(jt,{children:r.jsxs("div",{className:"flex min-h-0",style:oe,children:[re,me]})}),t[76]=oe,t[77]=re,t[78]=me,t[79]=pe):pe=t[79];let xe;t[80]!==ee||t[81]!==pe?(xe=r.jsx(wt,{open:ee,className:"min-h-0",children:pe}),t[80]=ee,t[81]=pe,t[82]=xe):xe=t[82];let we;return t[83]!==o||t[84]!==L||t[85]!==$||t[86]!==ne||t[87]!==xe?(we=r.jsxs(wh,{value:o,onValueChange:L,className:"shrink-0 gap-0 border-t bg-background",children:[$,ne,xe]}),t[83]=o,t[84]=L,t[85]=$,t[86]=ne,t[87]=xe,t[88]=we):we=t[88],we});function Fn(n){const e=F.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const vj=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function bj(n){const e=new Set;for(const t of n.matchAll(vj)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function yj(n){var s;const e=F.c(2);let t;if(e[0]!==n){t=new Map;for(let o=0;o<n.length;o++)for(const i of n[o].toolCalls){if(i.name!=="Bash"||!i.input.run_in_background)continue;const a=i.input.command||"",l=i.input.description||"",c=((s=n[o].assistantText)==null?void 0:s.join(" "))||"",d=[a,l,i.result||"",c].join(" "),f=bj(d);if(f.length===0){const p=a.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&f.push(3e3)}const u=(i.result||"").match(/Output is being written to:\s*(\S+)/),m=u?u[1]:null;for(const p of f)t.set(p,{description:l||a.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function Tu(n){var e;return((e=n.preview.split(`
|
|
23
|
+
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function wj(n){const e=F.c(10),{port:t,isActive:s}=n,o=s?"bg-success":"bg-muted-foreground/40";let i;e[0]!==o?(i=G("inline-block size-1.5 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==i?(a=r.jsx("span",{className:i}),e[2]=i,e[3]=a):a=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=r.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(Oe,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Ch({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=b.useState([]),a=yj(e);b.useEffect(()=>{if(!n)return;let c=!1;async function d(){try{const u=await ye(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(c)return;if(u.ok){const h=await u.json();if(c)return;if(h.length>0){i(h);return}}if(a.size===0){i([]);return}const m=[...a.keys()],p=await ye(`/api/check-ports?ports=${m.join(",")}`);if(c)return;if(p.ok){const h=await p.json();if(c)return;const g=[],v=new Set;for(const[x,w]of a)!h[x]||v.has(x)||(v.add(x),g.push({id:`port-${x}`,outputPath:w.outputPath,ports:[x],portStatus:{[x]:!0},preview:w.description}));i(g)}}catch{}}d();const f=setInterval(d,1e4);return()=>{c=!0,clearInterval(f)}},[n,a]);const l=b.useCallback(async c=>{try{await ye("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:c})}),setTimeout(()=>{i(d=>d.filter(f=>!f.ports.includes(c)))},1500)}catch{}},[]);return b.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Tu(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(Fn,{children:["Active Servers (",o.length,")"]}),r.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(c=>{const d=c.ports.filter(u=>c.portStatus[u]),f=Tu(c);return r.jsxs("div",{className:"border-b border-border px-2 py-2 last:border-b-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Gm,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:f})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[c.ports.map(u=>r.jsx(wj,{port:u,isActive:c.portStatus[u]},u)),r.jsx("div",{className:"flex-1"}),c.outputPath&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>t==null?void 0:t(c.id,c.outputPath,f),title:"View server output","aria-label":"View server output",children:r.jsx(Zs,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(X,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(u=>l(u)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(Ol,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function sc(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(P2,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function jj(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(A2,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Sj(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Rl,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Nj(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("fixed inset-0 isolate z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Il,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function oc(n){const e=F.c(11);let t,s,o;e[0]!==n?({className:t,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Nj,{}),e[4]=a):a=e[4];let l;e[5]!==t?(l=G("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-4 text-popover-foreground shadow-lg duration-150 ease-out outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==i||e[9]!==l?(c=r.jsxs(Sj,{children:[a,r.jsx(Pl,{"data-slot":"alert-dialog-content","data-size":i,className:l,...s})]}),e[7]=s,e[8]=i,e[9]=l,e[10]=c):c=e[10],c}function rc(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ic(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function kj(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-media",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ac(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Al,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function lc(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ml,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function cc(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(X,{"data-slot":"alert-dialog-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function dc(n){const e=F.c(14);let t,s,o,i;e[0]!==n?({className:t,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=o===void 0?"outline":o,l=i===void 0?"default":i;let c;e[5]!==t?(c=G(t),e[5]=t,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==a?(d=r.jsx(X,{variant:a,size:l}),e[7]=l,e[8]=a,e[9]=d):d=e[9];let f;return e[10]!==s||e[11]!==c||e[12]!==d?(f=r.jsx(di,{"data-slot":"alert-dialog-cancel",className:c,render:d,...s}),e[10]=s,e[11]=c,e[12]=d,e[13]=f):f=e[13],f}const Cj={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},_j={undo:"This will revert file changes from the following turns.",redo:"This will re-apply file changes from the following turns.","branch-switch":"This will switch to a different branch, undoing current changes and applying the branch's changes."};function Tj(n){const e=F.c(54),{state:t,isApplying:s,applyError:o,onConfirm:i,onCancel:a}=n,[l,c]=b.useState(t);let d,f;e[0]!==t?(d=()=>{t&&c(t)},f=[t],e[0]=t,e[1]=d,e[2]=f):(d=e[1],f=e[2]),b.useEffect(d,f);const u=t??l;if(!u)return null;const m=t!==null;let p;e[3]!==a?(p=z=>{z||a()},e[3]=a,e[4]=p):p=e[4];let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=z=>{z||c(null)},e[5]=h):h=e[5];let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(kj,{children:r.jsx(fn,{className:"text-warning"})}),e[6]=g):g=e[6];const v=Cj[u.type];let x;e[7]!==v?(x=r.jsx(ac,{children:v}),e[7]=v,e[8]=x):x=e[8];const w=_j[u.type];let y;e[9]!==w?(y=r.jsx(lc,{children:w}),e[9]=w,e[10]=y):y=e[10];let j;e[11]!==y||e[12]!==x?(j=r.jsxs(rc,{children:[g,x,y]}),e[11]=y,e[12]=x,e[13]=j):j=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),e[14]=N):N=e[14];let S;e[15]!==u.summary.turnCount?(S=r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[N,r.jsx("span",{className:"text-foreground font-mono",children:u.summary.turnCount})]}),e[15]=u.summary.turnCount,e[16]=S):S=e[16];let k;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),e[17]=k):k=e[17];let C;e[18]!==u.summary.fileCount?(C=r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[k,r.jsx("span",{className:"text-foreground font-mono",children:u.summary.fileCount})]}),e[18]=u.summary.fileCount,e[19]=C):C=e[19];let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("span",{className:"text-muted-foreground",children:"Operations"}),e[20]=T):T=e[20];let _;e[21]!==u.summary.operationCount?(_=r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[T,r.jsx("span",{className:"text-foreground font-mono",children:u.summary.operationCount})]}),e[21]=u.summary.operationCount,e[22]=_):_=e[22];let P;e[23]!==u.summary.filePaths?(P=u.summary.filePaths.length>0&&r.jsx("div",{className:"mt-2 max-h-32 overflow-y-auto rounded-md border bg-muted/30 p-2",children:u.summary.filePaths.map(Ej)}),e[23]=u.summary.filePaths,e[24]=P):P=e[24];let A;e[25]!==S||e[26]!==C||e[27]!==_||e[28]!==P?(A=r.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[S,C,_,P]}),e[25]=S,e[26]=C,e[27]=_,e[28]=P,e[29]=A):A=e[29];let E;e[30]!==o?(E=o&&r.jsx(vt,{variant:"destructive",children:r.jsx(bt,{children:o})}),e[30]=o,e[31]=E):E=e[31];let M;e[32]!==s||e[33]!==a?(M=r.jsx(dc,{onClick:a,disabled:s,children:"Cancel"}),e[32]=s,e[33]=a,e[34]=M):M=e[34];let I;e[35]!==s||e[36]!==u.type?(I=s?r.jsxs(r.Fragment,{children:[r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):u.type==="undo"?"Undo":u.type==="redo"?"Redo":"Switch",e[35]=s,e[36]=u.type,e[37]=I):I=e[37];let R;e[38]!==s||e[39]!==i||e[40]!==I?(R=r.jsx(cc,{onClick:i,disabled:s,children:I}),e[38]=s,e[39]=i,e[40]=I,e[41]=R):R=e[41];let D;e[42]!==M||e[43]!==R?(D=r.jsxs(ic,{children:[M,R]}),e[42]=M,e[43]=R,e[44]=D):D=e[44];let L;e[45]!==j||e[46]!==A||e[47]!==E||e[48]!==D?(L=r.jsxs(oc,{children:[j,A,E,D]}),e[45]=j,e[46]=A,e[47]=E,e[48]=D,e[49]=L):L=e[49];let $;return e[50]!==L||e[51]!==m||e[52]!==p?($=r.jsx(sc,{open:m,onOpenChange:p,onOpenChangeComplete:h,children:L}),e[50]=L,e[51]=m,e[52]=p,e[53]=$):$=e[53],$}function Ej(n){return r.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:n},n)}function Ut(n){const e=F.c(10);let t,s,o;e[0]!==n?({className:t,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t?(a=G("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==a?(l=r.jsx("div",{"data-slot":"card","data-size":i,className:a,...s}),e[6]=s,e[7]=i,e[8]=a,e[9]=l):l=e[9],l}function Vt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function qt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Gt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function _h(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wt(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("px-4 group-data-[size=sm]/card:px-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function to(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Bn(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"input-group",role:"group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const Pj=Cn("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function un(n){const e=F.c(11);let t,s,o;e[0]!==n?({className:t,align:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"inline-start":o;let a;e[4]!==i||e[5]!==t?(a=G(Pj({align:i}),t),e[4]=i,e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==s||e[9]!==a?(l=r.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":i,className:a,onClick:Aj,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function Aj(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const Mj=Cn("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function er(n){const e=F.c(15);let t,s,o,i,a;e[0]!==n?({className:t,type:o,variant:i,size:a,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=o===void 0?"button":o,c=i===void 0?"ghost":i,d=a===void 0?"xs":a;let f;e[6]!==t||e[7]!==d?(f=G(Mj({size:d}),t),e[6]=t,e[7]=d,e[8]=f):f=e[8];let u;return e[9]!==s||e[10]!==d||e[11]!==f||e[12]!==l||e[13]!==c?(u=r.jsx(X,{type:l,"data-size":d,variant:c,className:f,...s}),e[9]=s,e[10]=d,e[11]=f,e[12]=l,e[13]=c,e[14]=u):u=e[14],u}function Un(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Pt,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Rj(){const[n,e]=b.useState("idle"),[t,s]=b.useState(null),o=b.useRef(void 0),i=b.useCallback(async d=>{if(!d.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const u=await(await ye(`/api/config/validate?path=${encodeURIComponent(d)}`)).json();u.valid?(e("valid"),s(null)):(e("invalid"),s(u.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),a=b.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=b.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=b.useCallback(async(d,f)=>{try{const u=await ye("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:d,...f})}),m=await u.json();return u.ok&&m.success?{success:!0,claudeDir:m.claudeDir}:(s(m.error||"Failed to save"),e("invalid"),{success:!1,error:m.error})}catch{return s("Failed to save configuration"),{success:!1,error:"Network error"}}},[]);return b.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}function Ij(n){const e=F.c(47),{onConfigured:t}=n,[s,o]=b.useState(""),[i,a]=b.useState(!1),{status:l,error:c,debouncedValidate:d,save:f}=Rj();let u;e[0]!==d?(u=z=>{const U=z.target.value;o(U),d(U)},e[0]=d,e[1]=u):u=e[1];const m=u;let p;e[2]!==t||e[3]!==s||e[4]!==f?(p=async()=>{a(!0);const z=await f(s);z.success&&z.claudeDir&&t(z.claudeDir),a(!1)},e[2]=t,e[3]=s,e[4]=f,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==i||e[8]!==l?(g=z=>{z.preventDefault(),l==="valid"&&!i&&h()},e[6]=h,e[7]=i,e[8]=l,e[9]=g):g=e[9];let v,x;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx($l,{className:"size-4"})}),x=r.jsx(qt,{children:"Connect your coding agent"}),e[10]=v,e[11]=x):(v=e[10],x=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:"~/.codex"}),e[12]=w):w=e[12];let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(Vt,{children:[v,x,r.jsxs(Gt,{children:["Cogpit connects to Codex automatically when"," ",w," ","is available. For Claude Code, enter its data directory, usually"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:"~/.claude"}),"."]})]}),e[13]=y):y=e[13];const j=l==="invalid";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(mt,{htmlFor:"claude-data-directory",children:"Claude Code data directory"}),e[14]=N):N=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(un,{children:r.jsx(_o,{"aria-hidden":"true"})}),e[15]=S):S=e[15];const k=l==="invalid";let C;e[16]!==m||e[17]!==s||e[18]!==k?(C=r.jsxs(Bn,{children:[S,r.jsx(Un,{id:"claude-data-directory",value:s,onChange:m,placeholder:"/Users/you/.claude",autoFocus:!0,"aria-invalid":k,"aria-describedby":"claude-directory-status"})]}),e[16]=m,e[17]=s,e[18]=k,e[19]=C):C=e[19];let T;e[20]!==l?(T=l==="validating"&&r.jsxs(Ks,{className:"flex items-center gap-2",children:[r.jsx(It,{className:"size-4"}),"Checking path..."]}),e[20]=l,e[21]=T):T=e[21];let _;e[22]!==l?(_=l==="valid"&&r.jsxs(Ks,{className:"flex items-center gap-2 text-success",children:[r.jsx(ui,{className:"size-4"}),"Claude Code history found"]}),e[22]=l,e[23]=_):_=e[23];let P;e[24]!==c||e[25]!==l?(P=l==="invalid"&&c&&r.jsxs(Jn,{className:"flex items-center gap-2",children:[r.jsx(js,{className:"size-4"}),c]}),e[24]=c,e[25]=l,e[26]=P):P=e[26];let A;e[27]!==T||e[28]!==_||e[29]!==P?(A=r.jsxs("div",{id:"claude-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[T,_,P]}),e[27]=T,e[28]=_,e[29]=P,e[30]=A):A=e[30];let E;e[31]!==C||e[32]!==A||e[33]!==j?(E=r.jsx(Wt,{children:r.jsx(Qs,{children:r.jsxs(ft,{"data-invalid":j,children:[N,C,A]})})}),e[31]=C,e[32]=A,e[33]=j,e[34]=E):E=e[34];const M=l!=="valid"||i;let I;e[35]!==i?(I=i&&r.jsx(It,{"data-icon":"inline-start"}),e[35]=i,e[36]=I):I=e[36];const R=i?"Saving...":"Connect Claude Code";let D;e[37]!==M||e[38]!==I||e[39]!==R?(D=r.jsx(to,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:M,children:[I,R]})}),e[37]=M,e[38]=I,e[39]=R,e[40]=D):D=e[40];let L;e[41]!==E||e[42]!==D?(L=r.jsxs(Ut,{children:[y,E,D]}),e[41]=E,e[42]=D,e[43]=L):L=e[43];let $;return e[44]!==L||e[45]!==g?($=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8 text-foreground",children:r.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:L})}),e[44]=L,e[45]=g,e[46]=$):$=e[46],$}const Th=/^[a-z]:[\\/]/i;function uc(n){return(Th.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function Eu(n){const e=uc(n);return Th.test(n)?e.toLowerCase():e}function $j(n){const e=uc(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Pu(n,e){const t=Eu(n),s=Eu(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?uc(e).slice(o.length):null}let fc=!1;function Oj(n){fc=n}function mc(){return fc}let bo=null;function Dj(n){return bo=n,()=>{bo===n&&(bo=null)}}function Lj(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=Pu(e,n.path);if(o)return{root:e,file:o,mode:Au(n),line:n.line}}const t=$j(n.path),s=Pu(t,n.path);return s?{root:t,file:s,mode:Au(n),line:n.line}:null}function Au(n){return n.mode==="diff"?"diff":"edit"}function Eh(n){return fc&&bo!==null&&bo(n)}function Ph(n,e){ye(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function Vr(n,e={}){if(at("hostFiles")&&!Eh({kind:"file",path:n,...e})){if(vs()){Ko(n);return}Ph("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function Ah(n){at("hostFiles")&&(n.path&&Eh({kind:"project",path:n.path})||Rh("/api/open-in-editor",n))}function Mh(n){at("hostFiles")&&Rh("/api/reveal-in-folder",n)}function Rh(n,e){!e.path&&!e.dirName||Ph(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let ha=null;const al=new Set,kr=new Map,Mu=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],Ih={typescript:()=>Ve(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>Ve(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>Ve(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>Ve(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>Ve(()=>import("./json-Cp-IABpG.js"),[]),css:()=>Ve(()=>import("./css-DPfMkruS.js"),[]),html:()=>Ve(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>Ve(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>Ve(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>Ve(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>Ve(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>Ve(()=>import("./rust-B1yitclQ.js"),[]),go:()=>Ve(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>Ve(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>Ve(()=>import("./sql-BLtJtn59.js"),[]),c:()=>Ve(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>Ve(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>Ve(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>Ve(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>Ve(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>Ve(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>Ve(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>Ve(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>Ve(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>Ve(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function $h(){return ha||(ha=(async()=>{const[n,e,...t]=await Promise.all([Ve(()=>import("./github-dark-DHJKELXO.js"),[]).then(o=>o.default),Ve(()=>import("./github-light-DAi9KRSo.js"),[]).then(o=>o.default),...Mu.map(o=>Ih[o]().then(i=>i.default))]),s=await kv({themes:[n,e],langs:t,engine:Cv()});for(const o of Mu)al.add(o);return s})()),ha}async function Oh(n,e){if(al.has(e))return;if(kr.has(e))return kr.get(e);const t=Ih[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),al.add(e)}).finally(()=>kr.delete(e));kr.set(e,s),await s}const zj={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",mts:"typescript",cts:"typescript",py:"python",rs:"rust",go:"go",json:"json",css:"css",scss:"scss",html:"html",htm:"html",md:"markdown",mdx:"markdown",yml:"yaml",yaml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",java:"java",rb:"ruby",swift:"swift",kt:"kotlin",kts:"kotlin",php:"php",vue:"vue",svelte:"svelte"};function Dh(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return zj[e]??null}async function pc(n,e,t){try{const s=await $h();await Oh(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}function tr(){const n=F.c(2),[e,t]=b.useState(Fj);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=document.documentElement,a=()=>t(i.classList.contains("dark")),l=new MutationObserver(a);return l.observe(i,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),b.useEffect(s,o),e}function Fj(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const Bj={js:"JavaScript",jsx:"JSX",ts:"TypeScript",tsx:"TSX",py:"Python",rb:"Ruby",rs:"Rust",go:"Go",java:"Java",kt:"Kotlin",swift:"Swift",cs:"C#",cpp:"C++",c:"C",sh:"Shell",bash:"Bash",zsh:"Zsh",fish:"Fish",ps1:"PowerShell",powershell:"PowerShell",sql:"SQL",graphql:"GraphQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",toml:"TOML",xml:"XML",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Docker",makefile:"Makefile",cmake:"CMake",lua:"Lua",vim:"Vim",diff:"Diff",plaintext:"Text",text:"Text",txt:"Text",php:"PHP",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",clojure:"Clojure",haskell:"Haskell",ocaml:"OCaml",zig:"Zig",nim:"Nim",dart:"Dart",vue:"Vue",svelte:"Svelte",astro:"Astro",prisma:"Prisma",terraform:"Terraform",tf:"Terraform",proto:"Protobuf",protobuf:"Protobuf"};function Uj(n){return Bj[n.toLowerCase()]??n}function Wj(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function Hj(n){const e=F.c(10),{text:t}=n,[s,o]=b.useState(!1),i=b.useRef(null),a=b.useRef(0);let l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>()=>{a.current=a.current+1,i.current&&clearTimeout(i.current)},c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),b.useEffect(l,c);let d;e[2]!==t?(d=function(){const g=a.current=a.current+1;Ko(t).then(v=>{v&&g===a.current&&(i.current&&clearTimeout(i.current),o(!0),i.current=setTimeout(()=>{i.current=null,o(!1)},2e3))})},e[2]=t,e[3]=d):d=e[3];const f=d,u=s?"Copied":"Copy code";let m;e[4]!==s?(m=s?r.jsxs(r.Fragment,{children:[r.jsx(rt,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(bn,{"data-icon":"icon"}),e[4]=s,e[5]=m):m=e[5];let p;return e[6]!==f||e[7]!==u||e[8]!==m?(p=r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"text-muted-foreground",title:"Copy code","aria-label":u,children:m}),e[6]=f,e[7]=u,e[8]=m,e[9]=p):p=e[9],p}function Kj(n){const e=F.c(2),{num:t}=n;let s;return e[0]!==t?(s=r.jsx("span",{className:"mr-3 inline-block w-8 select-none text-right text-xs text-muted-foreground/60",children:t}),e[0]=t,e[1]=s):s=e[1],s}function Vj(n){const e=F.c(16);let t,s,o;if(e[0]!==n){const{children:m,className:p,node:h,...g}=n;t=m,s=p,o=g,e[0]=n,e[1]=t,e[2]=s,e[3]=o}else t=e[1],s=e[2],o=e[3];const i=!s&&typeof t=="string"&&!t.includes(`
|
|
24
|
+
`);let a;e[4]!==s?(a=Wj(s),e[4]=s,e[5]=a):a=e[5];const l=a,c=String(t);let d;if(e[6]!==c){let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=/\n$/,e[8]=m):m=e[8],d=c.replace(m,""),e[6]=c,e[7]=d}else d=e[7];const f=d;if(i){let m;return e[9]!==t||e[10]!==o?(m=r.jsx("code",{className:"rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[0.9em] text-foreground",...o,children:t}),e[9]=t,e[10]=o,e[11]=m):m=e[11],m}let u;return e[12]!==f||e[13]!==l||e[14]!==o?(u=r.jsx(qj,{code:f,lang:l,...o}),e[12]=f,e[13]=l,e[14]=o,e[15]=u):u=e[15],u}function qj(n){const e=F.c(35);let t,s,o;e[0]!==n?({code:t,lang:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=tr(),[a,l]=b.useState(null),[c,d]=b.useState(!1),f=t.split(`
|
|
25
|
+
`),u=f.length,m=u>30,p=s?`${s}\0${i?"dark":"light"}\0${t}`:null,h=(a==null?void 0:a.key)===p?a.lines:null;let g,v;e[4]!==t||e[5]!==p||e[6]!==i||e[7]!==s?(g=()=>{if(!s||!p)return;let A=!1;return pc(t,s,i).then(E=>{A||l({key:p,lines:E})}),()=>{A=!0}},v=[t,s,i,p],e[4]=t,e[5]=p,e[6]=i,e[7]=s,e[8]=g,e[9]=v):(g=e[8],v=e[9]),b.useEffect(g,v);const x=c?et:nt,w="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let y;e[10]!==x||e[11]!==c||e[12]!==m?(y=m&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(!c),className:"text-muted-foreground","aria-label":c?"Expand code":"Collapse code",children:r.jsx(x,{"data-icon":"icon"})}),e[10]=x,e[11]=c,e[12]=m,e[13]=y):y=e[13];let j;e[14]!==s?(j=s&&r.jsx(Oe,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:Uj(s)}),e[14]=s,e[15]=j):j=e[15];let N;e[16]!==m||e[17]!==u?(N=m&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[16]=m,e[17]=u,e[18]=N):N=e[18];let S;e[19]!==y||e[20]!==j||e[21]!==N?(S=r.jsxs("div",{className:"flex items-center gap-2",children:[y,j,N]}),e[19]=y,e[20]=j,e[21]=N,e[22]=S):S=e[22];let k;e[23]!==t?(k=r.jsx(Hj,{text:t}),e[23]=t,e[24]=k):k=e[24];let C;e[25]!==S||e[26]!==k?(C=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[S,k]}),e[25]=S,e[26]=k,e[27]=C):C=e[27];const T=!c&&r.jsx("div",{className:"overflow-x-auto",children:r.jsx("pre",{className:"m-0 p-3 font-mono text-xs leading-relaxed",children:r.jsx("code",{className:G("block",!h&&"text-foreground/90"),...o,children:f.map((A,E)=>{const M=h==null?void 0:h[E];return r.jsxs("span",{className:"block",children:[r.jsx(Kj,{num:E+1}),M?M.map(Gj):A||" "]},E)})})})});let _;e[28]!==c||e[29]!==u?(_=c&&r.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(!1),className:"h-auto w-full justify-start rounded-none px-3 py-2 text-xs text-muted-foreground","aria-label":`Expand ${u} lines of code`,children:["Show ",u," lines..."]}),e[28]=c,e[29]=u,e[30]=_):_=e[30];let P;return e[31]!==T||e[32]!==_||e[33]!==C?(P=r.jsxs("div",{className:w,children:[C,T,_]}),e[31]=T,e[32]=_,e[33]=C,e[34]=P):P=e[34],P}function Gj(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var ps=function(n,e){return Number(n.toFixed(e))},Yj=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},Xj=function(n){return-Math.cos(n*Math.PI)/2+.5},Jj=function(n){return n},Zj=function(n){return n*n},Qj=function(n){return n*(2-n)},eS=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},tS=function(n){return n*n*n},nS=function(n){return--n*n*n+1},sS=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},oS=function(n){return n*n*n*n},rS=function(n){return 1- --n*n*n*n},iS=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},aS=function(n){return n*n*n*n*n},lS=function(n){return 1+--n*n*n*n*n},cS=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},Lh={easeOut:Xj,linear:Jj,easeInQuad:Zj,easeOutQuad:Qj,easeInOutQuad:eS,easeInCubic:tS,easeOutCubic:nS,easeInOutCubic:sS,easeInQuart:oS,easeOutQuart:rS,easeInOutQuart:iS,easeInQuint:aS,easeOutQuint:lS,easeInOutQuint:cS},zh=function(n){typeof n=="number"&&cancelAnimationFrame(n)},tn=function(n){n.mounted&&(zh(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function Fh(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;tn(n),n.animation=function(){if(!n.mounted)return zh(n.animation);var a=new Date().getTime()-o,l=a/t,c=Lh[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function dS(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function ls(n,e,t,s){var o=dS(e);if(!(!n.mounted||!o)){var i=n.setState,a=n.state,l=a.scale,c=a.positionX,d=a.positionY,f=e.scale-l,u=e.positionX-c,m=e.positionY-d;t===0?i(e.scale,e.positionX,e.positionY):Fh(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+f*p,g=c+u*p,v=d+m*p;i(h,g,v)})}}function uS(n,e,t){var s=n.offsetWidth,o=n.offsetHeight,i=e.offsetWidth,a=e.offsetHeight,l=i*t,c=a*t,d=s-l,f=o-c;return{wrapperWidth:s,wrapperHeight:o,newContentWidth:l,newDiffWidth:d,newContentHeight:c,newDiffHeight:f}}var fS=function(n,e,t,s,o,i,a){var l=n>e?t*(a?.5:1):0,c=s>o?i*(a?.5:1):0,d=n-e-l,f=l,u=s-o-c,m=c;return{minPositionX:d,maxPositionX:f,minPositionY:u,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},hc=function(n,e){var t=n.wrapperComponent,s=n.contentComponent,o=n.setup,i=o.centerZoomedOut,a=o.disablePadding;if(!t||!s)throw new Error("Components are not mounted");var l=uS(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,f=l.newContentWidth,u=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=fS(c,f,m,d,u,p,!!i),g=c>=f&&d>=u;a&&g&&!i&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var v=n.setup,x=v.minPositionX,w=v.maxPositionX,y=v.minPositionY,j=v.maxPositionY;return x!=null&&(h.minPositionX=c*(1-e)+x*e),w!=null&&(h.maxPositionX=w*e),y!=null&&(h.minPositionY=d*(1-e)+y*e),j!=null&&(h.maxPositionY=j*e),h},Po=function(n,e,t,s){return s?n<e?ps(e,2):n>t?ps(t,2):ps(n,2):ps(n,2)},Vs=function(n,e){var t=hc(n,e);return n.bounds=t,t};function nr(n,e,t,s,o,i,a){var l=t.minPositionX,c=t.minPositionY,d=t.maxPositionX,f=t.maxPositionY,u=0,m=0;a&&(u=o,m=i);var p=Po(n,l-u,d+u,s),h=Po(e,c-m,f+m,s);return{x:p,y:h}}function $i(n,e,t,s,o,i){var a=n.state,l=a.scale,c=a.positionX,d=a.positionY,f=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:d};var u=c-e*f,m=d-t*f,p=nr(u,m,o,i,0,0,null);return p}var Ru=1e-7;function sr(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,Ru),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,Ru)}var Iu=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,o=n.wrapperComponent,i=e.target,a="shadowRoot"in i&&"composedPath"in e,l=a?e.composedPath().some(function(f){return f instanceof Element?o==null?void 0:o.contains(f):!1}):o==null?void 0:o.contains(i),c=s&&i&&l;if(!c)return!1;var d=or(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},$u=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},mS=function(n,e){var t=n.state,s=t.positionX,o=t.positionY;n.isPanning=!0;var i=e.clientX,a=e.clientY;n.startCoords={x:i-s,y:a-o}},pS=function(n,e){var t=e.touches,s=n.state,o=s.positionX,i=s.positionY;n.isPanning=!0;var a=t.length===1;if(a){var l=t[0].clientX,c=t[0].clientY;n.startCoords={x:l-o,y:c-i}}};function hS(n){var e=n.state,t=e.positionX,s=e.positionY,o=e.scale,i=n.setup,a=i.disabled,l=i.limitToBounds,c=i.centerZoomedOut,d=n.wrapperComponent;if(!(a||!d||!n.bounds)){var f=n.bounds,u=f.maxPositionX,m=f.minPositionX,p=f.maxPositionY,h=f.minPositionY,g=t>u||t<m,v=s>p||s<h,x=t>u?d.offsetWidth:n.setup.minPositionX||0,w=s>p?d.offsetHeight:n.setup.minPositionY||0,y=$i(n,x,w,o,n.bounds,l||c),j=y.x,N=y.y;return{scale:o,positionX:g?j:t,positionY:v?N:s}}}function Bh(n,e,t,s,o){var i=n.setup.limitToBounds,a=n.wrapperComponent,l=n.bounds,c=n.state,d=c.scale,f=c.positionX,u=c.positionY;if(!(a===null||l===null||e===f&&t===u)){var m=nr(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var gS=function(n,e,t){var s=n.startCoords,o=n.state,i=n.setup.panning,a=i.lockAxisX,l=i.lockAxisY,c=o.positionX,d=o.positionY;if(!s)return{x:c,y:d};var f=e-s.x,u=t-s.y,m=a?c:f,p=l?d:u;return{x:m,y:p}},os=function(n,e,t){var s=n.setup,o=n.state,i=s.minScale,a=s.disablePadding,l=s.centerZoomedOut,c=t??o.scale;return e>0&&c>=i&&!a&&!l?e:0},Yn;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(Yn||(Yn={}));var xS=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,o=n.setup,i=o.disabled,a=o.velocityAnimation,l=o.limitToBounds,c=n.state.scale,d=a.disabled;if(d||i||!e||!t||!s)return!1;if(!l)return!0;var f=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return f},vS=function(n){var e=n.mounted,t=n.velocity,s=n.bounds,o=n.setup,i=o.disabled,a=o.velocityAnimation,l=a.disabled,c=!l&&!i&&e;return!(!c||!t||!s)};function bS(n,e){var t=n.setup.velocityAnimation,s=t.animationTime,o=t.maxAnimationTime,i=t.inertia;return Math.min(s*Math.max(1,Math.abs(e/i)),o)}function Ou(n,e,t,s,o,i,a,l,c,d){if(o){if(e>a&&t>a){var f=a+(n-a)*d;return f>c?c:f<a?a:f}if(e<i&&t<i){var f=i+(n-i)*d;return f<l?l:f>i?i:f}}return s?e:Po(n,i,a,o)}function yS(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var ga=function(n,e,t){var s=0,o=n*t;return Number.isNaN(o)?s:n<0?Math.max(o,-e):Math.min(o,e)};function wS(n,e,t){var s,o,i=xS(n);if(i){var a=n.lastMousePosition,l=n.velocityTime,c=n.setup,d=n.wrapperComponent,f=c.velocityAnimation,u=f.maxStrengthMouse,m=f.maxStrengthTouch,p=f.sensitivityTouch,h=f.sensitivityMouse,g=Date.now();if(a&&l&&d){var v=yS(d),x=(s={},s[Yn.TOUCH]=p,s[Yn.MOUSE]=h,s)[t],w=(o={},o[Yn.TOUCH]=m,o[Yn.MOUSE]=u,o)[t],y=e.x-a.x,j=e.y-a.y,N=ga(y/v,w,x),S=ga(j/v,w,x),k=g-l,C=y*y+j*j,T=ga(Math.sqrt(C)/k,w,x);n.velocity={velocityX:N,velocityY:S,total:T}}n.lastMousePosition=e,n.velocityTime=g}}function jS(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=vS(n);if(!(!i||!e||!t||!o)){var a=e.velocityX,l=e.velocityY,c=e.total,d=t.maxPositionX,f=t.minPositionX,u=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,v=s.panning,x=v.lockAxisY,w=v.lockAxisX,y=g.animationType,j=h.sizeX,N=h.sizeY,S=h.velocityAlignmentTime,k=S,C=bS(n,c),T=Math.max(C,k),_=os(n,j),P=os(n,N),A=_*o.offsetWidth/100,E=P*o.offsetHeight/100,M=d+A,I=f-A,R=u+E,D=m-E,L=n.state,$=new Date().getTime();Fh(n,y,T,function(z){var U=n.state,O=U.scale,H=U.positionX,B=U.positionY,W=new Date().getTime()-$,V=W/k,q=Lh[h.animationType],Y=1-q(Math.min(1,V)),K=1-z,J=H+a*K,Z=B+l*K,Q=Ou(J,L.positionX,H,w,p,f,d,I,M,Y),se=Ou(Z,L.positionY,B,x,p,m,u,D,R,Y);if(H!==J||B!==Z){n.setState(O,Q,se);var ne=n.props.onPanning;ne&&ne(Xe(n),{})}})}}function Du(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},tn(n),Vs(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?pS(n,e):mS(n,e)}function Uh(n,e){var t=n.state.scale,s=n.setup,o=s.minScale,i=s.autoAlignment,a=i.disabled,l=i.sizeX,c=i.sizeY,d=i.animationTime,f=i.animationType,u=a||t<o||!l&&!c;if(!u){var m=hS(n);m&&ls(n,m,d,f)}}function Lu(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=gS(n,e,t),f=d.x,u=d.y,m=os(n,l),p=os(n,c);wS(n,{x:f,y:u},s),Bh(n,f,u,m,p)}}function SS(n,e){if(n.isPanning){var t=n.velocity,s=n.wrapperComponent,o=n.contentComponent;n.isPanning=!1;var i=n.state,a=i.positionX,l=i.positionY,c=i.scale,d=n.panStartPosition;if(n.panStartPosition=null,d){var f=a-d.x,u=l-d.y;if(f*f+u*u<=25)return}n.isAnimating=!1,n.animation=null;var m=(s==null?void 0:s.offsetWidth)||0,p=(s==null?void 0:s.offsetHeight)||0,h=((o==null?void 0:o.offsetWidth)||0)*c,g=((o==null?void 0:o.offsetHeight)||0)*c,v=!n.setup.limitToBounds||m<h||p<g,x=!e&&t&&t.total>.1&&v;x?jS(n):Uh(n)}}function gc(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=sr(ps(e,2),i,a,0,!1),d=Vs(n,c),f=$i(n,t,s,c,d,l),u=f.x,m=f.y;return{scale:c,positionX:u,positionY:m}}function xc(n,e,t){var s=n.state.scale,o=n.wrapperComponent,i=n.setup,a=i.minScale,l=i.maxScale,c=i.limitToBounds,d=i.zoomAnimation,f=d.disabled,u=d.animationTime,m=d.animationType,p=s>=a&&s<=l,h=f||p;if((s>=1||c)&&Uh(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,v=t||o.offsetHeight/2,x=s<a?a:l,w=gc(n,x,g,v);w&&ls(n,w,u,m)}}var Yt=function(){return Yt=Object.assign||function(e){for(var t,s=1,o=arguments.length;s<o;s++){t=arguments[s];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Yt.apply(this,arguments)};function zu(n,e,t){for(var s=0,o=e.length,i;s<o;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return n.concat(i||Array.prototype.slice.call(e))}var xa={scale:1,positionX:0,positionY:0},ms={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,detached:!1,wheel:{step:.015,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},trackPadPanning:{disabled:!0,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,allowPanning:!0,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},autoAlignment:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivityMouse:1,sensitivityTouch:1.2,maxStrengthMouse:20,maxStrengthTouch:40,inertia:1,animationTime:300,maxAnimationTime:800,animationType:"easeOut"}},ll={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Wh=function(n){var e,t,s,o,i,a,l,c,d,f=Math.max((e=n.minScale)!==null&&e!==void 0?e:ms.minScale,1e-7),u=(t=n.maxScale)!==null&&t!==void 0?t:ms.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:xa.scale,p=Math.min(Math.max(m,f),u),h=Po((o=n.initialPositionX)!==null&&o!==void 0?o:xa.positionX,(i=n.minPositionX)!==null&&i!==void 0?i:-1/0,(a=n.maxPositionX)!==null&&a!==void 0?a:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=Po((l=n.initialPositionY)!==null&&l!==void 0?l:xa.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(d=n.maxPositionY)!==null&&d!==void 0?d:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},Fu=function(n){var e=Yt({},ms);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof ms[s]<"u";if(i&&o){var a=Object.prototype.toString.call(ms[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=Yt(Yt({},ms[s]),n[s]):c?e[s]=zu(zu([],ms[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},Hh=function(n,e,t){var s=n.state.scale,o=n.wrapperComponent,i=n.setup,a=i.maxScale,l=i.minScale,c=i.zoomAnimation,d=i.smooth,f=c.size;if(!o)throw new Error("Wrapper is not mounted");var u=d?s*Math.exp(e*t):s+e*t,m=sr(ps(u,3),l,a,f,!1);return m};function Kh(n,e,t,s,o){var i,a,l=n.wrapperComponent,c=n.state,d=c.scale,f=c.positionX,u=c.positionY,m=n.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var p=m.disabled?0:s,h=l.offsetWidth,g=l.offsetHeight,v=(h/2-f)/d,x=(g/2-u)/d,w=Hh(n,e,t),y=gc(n,w,v,x);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,N=j.onZoomStart,S=j.onZoom,k=j.onZoomStop,C=new MouseEvent("mousemove",{bubbles:!0}),T=Xe(n);Qe(T,C,N),Qe(T,C,S),ls(n,y,p,o);var _=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;_&&_.setTimeout(function(){n.mounted&&Qe(Xe(n),C,k)},p)}function Vh(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,f=a.centerOnInit,u=Wh(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var v=u.positionX,x=u.positionY;if(f&&c){var w=vc(u.scale,l,c);v=w.positionX,x=w.positionY}var y=hc(n,u.scale),j=nr(v,x,y,d,0,0,l),N={scale:u.scale,positionX:j.x,positionY:j.y};if(!(p===u.scale&&h===u.positionX&&g===u.positionY)){s==null||s();var S=n.props,k=S.onZoomStart,C=S.onZoom,T=S.onZoomStop,_=new MouseEvent("mousemove",{bubbles:!0}),P=Xe(n);Qe(P,_,k),Qe(P,_,C),ls(n,N,e,t);var A=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;A&&A.setTimeout(function(){n.mounted&&Qe(Xe(n),_,T)},e)}}}function NS(n,e,t,s){var o=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),l=i.x*s.scale,c=i.y*s.scale;return{x:(o.x-a.x+l)/s.scale,y:(o.y-a.y+c)/s.scale}}function kS(n,e,t,s,o){s===void 0&&(s=0),o===void 0&&(o=0);var i=n.wrapperComponent,a=n.contentComponent,l=n.state,c=n.setup,d=c.limitToBounds,f=c.minScale,u=c.maxScale;if(!i||!a)return l;var m=i.getBoundingClientRect(),p=e.getBoundingClientRect(),h=NS(e,i,a,l),g=h.x,v=h.y,x=p.width/l.scale,w=p.height/l.scale,y=i.offsetWidth/x,j=i.offsetHeight/w,N=sr(t||Math.min(y,j),f,u,0,!1),S=(m.width-x*N)/2,k=(m.height-w*N)/2,C=(m.left-g)*N+S+s,T=(m.top-v)*N+k+o,_=hc(n,N),P=nr(C,T,_,d,0,0,i),A=P.x,E=P.y;return{positionX:A,positionY:E,scale:N}}var CS=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Kh(n,1,e,t,s)}},_S=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Kh(n,-1,e,t,s)}},TS=function(n){return function(e,t,s,o,i){o===void 0&&(o=300),i===void 0&&(i="easeOut");var a=n.state,l=a.positionX,c=a.positionY,d=a.scale,f=n.wrapperComponent,u=n.contentComponent,m=n.setup.disabled;if(!(m||!f||!u)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?d:s};ls(n,p,o,i)}}},ES=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),Vh(n,e,t)}},PS=function(n){return function(e,t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut");var o=n.state,i=n.wrapperComponent,a=n.contentComponent;if(i&&a){var l=vc(e||o.scale,i,a);ls(n,l,t,s)}}},AS=function(n){return function(e,t,s,o,i,a){s===void 0&&(s=600),o===void 0&&(o="easeOut"),i===void 0&&(i=0),a===void 0&&(a=0),tn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=kS(n,c,t,i,a);ls(n,d,s,o)}}},cl=function(n){return{instance:n,state:n.state,zoomIn:CS(n),zoomOut:_S(n),setTransform:TS(n),resetTransform:ES(n),centerView:PS(n),zoomToElement:AS(n)}},MS=function(n){return{instance:n,state:n.state}},Xe=function(n){var e={};return Object.assign(e,MS(n)),Object.assign(e,cl(n)),e},va=!1;function ba(){try{var n={get passive(){return va=!0,!1}};return n}catch{return va=!1,va}}var Cr=".".concat(ll.wrapperClass),or=function(n,e){return e.some(function(t){return n.matches("".concat(Cr," ").concat(t,", ").concat(Cr," .").concat(t,", ").concat(Cr," ").concat(t," *, ").concat(Cr," .").concat(t," *"))})},Ao=function(n){n&&clearTimeout(n)},RS=function(n){return Number.parseFloat(n.toFixed(8))},qh=function(n,e,t){var s=RS(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},vc=function(n,e,t){var s=t.offsetWidth*n,o=t.offsetHeight*n,i=(e.offsetWidth-s)/2,a=(e.offsetHeight-o)/2;return{scale:n,positionX:i,positionY:a}};function IS(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function $S(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var Gh=function(n,e){var t=n.setup.wheel,s=t.disabled,o=t.wheelDisabled,i=t.touchPadDisabled,a=t.excluded,l=n.isInitialized,c=n.isPanning,d=e.target,f=l&&!c&&!s&&d;if(!f||o&&!e.ctrlKey||i&&e.ctrlKey)return!1;var u=or(d,a);if(u)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},OS=function(n,e){var t=n.setup,s=t.disabled,o=t.trackPadPanning,i=o.activationKeys,a=o.excluded;if(!n.wrapperComponent||!n.contentComponent||s||o.disabled||e.ctrlKey)return!1;var l=Gh(n,e);if(l)return!1;var c=e.target,d=or(c,a);if(d)return!1;var f=n.isPressingKeys(i);return!!f},DS=function(n){return n?n.deltaY<0?1:-1:0};function LS(n,e){var t=DS(n),s=Yj(e,t);return s}function Yh(n,e,t){var s=e.getBoundingClientRect(),o=0,i=0;if("clientX"in n)o=(n.clientX-s.left)/t,i=(n.clientY-s.top)/t;else{var a=n.touches[0];o=(a.clientX-s.left)/t,i=(a.clientY-s.top)/t}return Number.isNaN(o)||Number.isNaN(i)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:o,y:i}}var zS=function(n,e,t,s,o){var i=n.state.scale,a=n.wrapperComponent,l=n.setup,c=l.maxScale,d=l.minScale,f=l.zoomAnimation,u=l.disablePadding,m=f.size,p=f.disabled;if(!a)throw new Error("Wrapper is not mounted");var h=i+e*t,g=s?!1:!p,v=sr(h,d,c,m,g&&!u);return v},Xh=function(n,e){var t=n.previousWheelEvent,s=n.state.scale,o=n.setup,i=o.maxScale,a=o.minScale;return t?s<i||s>a||Math.sign(t.deltaY)!==Math.sign(e.deltaY)||t.deltaY>0&&t.deltaY<e.deltaY||t.deltaY<0&&t.deltaY>e.deltaY||Math.sign(t.deltaY)!==Math.sign(e.deltaY):!1},FS=function(n,e){var t=n.setup.pinch,s=t.disabled,o=t.excluded,i=n.isInitialized,a=e.target,l=i&&!s&&a;if(!l)return!1;var c=or(a,o);return!c},BS=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},US=function(n,e,t){var s=t.getBoundingClientRect(),o=n.touches,i=o[0].clientX-s.left,a=o[0].clientY-s.top,l=o[1].clientX-s.left,c=o[1].clientY-s.top;return{x:(i+l)/2/e,y:(a+c)/2/e}},Jh=function(n){return Math.sqrt(Math.pow(n.touches[0].pageX-n.touches[1].pageX,2)+Math.pow(n.touches[0].pageY-n.touches[1].pageY,2))},WS=5,HS=function(n,e){var t=n.pinchStartScale,s=n.pinchStartDistance,o=n.setup,i=o.maxScale,a=o.minScale,l=o.zoomAnimation,c=o.disablePadding,d=o.pinch,f=l.size,u=l.disabled,m=d.step;if(!t||s===null)throw new Error("Pinch touches distance was not provided");if(e<0)return n.state.scale;var p=e/s,h=p*t,g=(h-t)*(m/WS),v=t+g,x=v===1/0?0:ps(v,10);return sr(x,a,i,f,!u&&!c)},Zh=160,Qh=100,KS=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(tn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},VS=function(n,e){var t=n.props,s=t.onWheel,o=t.onZoom,i=n.contentComponent,a=n.setup,l=n.state,c=l.scale,d=a.limitToBounds,f=a.centerZoomedOut,u=a.zoomAnimation,m=a.wheel,p=a.disablePadding,h=a.smooth,g=u.size,v=u.disabled,x=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=LS(e,null),y=h?x*Math.abs(e.deltaY):x,j=zS(n,w,y,!e.ctrlKey);if(c!==j){var N=Vs(n,j),S=Yh(e,i,c),k=v||g===0||f||p,C=d&&k,T=$i(n,S.x,S.y,j,N,C),_=T.x,P=T.y;n.previousWheelEvent=e,n.setState(j,_,P),Qe(Xe(n),e,s),Qe(Xe(n),e,o)}},qS=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;Ao(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(xc(n,e.x,e.y),n.wheelAnimationTimer=null)},Qh);var i=Xh(n,e);i&&(Ao(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},Zh))},GS=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(tn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},YS=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;Ao(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(xc(n,e.x,e.y),n.wheelAnimationTimer=null)},Qh);var i=Xh(n,e);i&&(Ao(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},Zh))},eg=function(n){for(var e=0,t=0,s=0;s<2;s+=1)e+=n.touches[s].clientX,t+=n.touches[s].clientY;var o=e/2,i=t/2;return{x:o,y:i}},XS=function(n,e){var t=Jh(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=eg(e),tn(n)},JS=function(n,e){var t=n.contentComponent,s=n.pinchStartDistance,o=n.wrapperComponent,i=n.pinchPreviousCenter,a=n.state.scale,l=n.setup,c=l.limitToBounds,d=l.centerZoomedOut,f=l.zoomAnimation,u=l.autoAlignment,m=l.pinch,p=l.panning,h=f.disabled,g=f.size,v=m.allowPanning;if(!(s===null||!t)){var x=US(e,a,t);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var w=Jh(e),y=HS(n,w),j=eg(e),N=a/y,S=(j.x-((i==null?void 0:i.x)||0))*N,k=(j.y-((i==null?void 0:i.y)||0))*N;if(!(y===a&&S===0&&k===0)){n.pinchPreviousCenter=j;var C=Vs(n,y),T=h||g===0||d,_=c&&T,P=$i(n,x.x,x.y,y,C,_),A=P.x,E=P.y;if(n.pinchMidpoint=x,n.lastDistance=w,p.disabled||!v)n.setState(y,A,E);else{var M=u.sizeX,I=u.sizeY,R=os(n,M,y),D=os(n,I,y),L=A+S,$=E+k,z=nr(L,$,C,c,R,D,o),U=z.x,O=z.y;n.setState(y,U,O)}}}}},ZS=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,xc(n,e==null?void 0:e.x,e==null?void 0:e.y)},tg=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;Ao(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Xe(n),e,t)},s)},QS=function(n,e){var t=n.props,s=t.onZoomStart,o=t.onZoom,i=n.setup.doubleClick,a=i.animationTime,l=i.animationType;Qe(Xe(n),e,s),Vh(n,a,l,function(){return Qe(Xe(n),e,o)}),tg(n,e)};function e5(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function t5(n,e){var t=n.setup,s=n.doubleClickStopEventTimer,o=n.state,i=n.contentComponent,a=o.scale,l=n.props,c=l.onZoomStart,d=l.onZoom,f=t.doubleClick,u=f.disabled,m=f.mode,p=f.step,h=f.animationTime,g=f.animationType;if(!u&&!s){if(m==="reset")return QS(n,e);if(!i)return console.error("No ContentComponent found");var v=e5(m,n.state.scale),x=Hh(n,v,p);if(a!==x){Qe(Xe(n),e,c);var w=Yh(e,i,a),y=gc(n,x,w.x,w.y);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Xe(n),e,d),ls(n,y,h,g),tg(n,e)}}}var n5=function(n,e){var t=n.isInitialized,s=n.setup,o=n.wrapperComponent,i=s.doubleClick,a=i.disabled,l=i.excluded,c=e.target,d=o==null?void 0:o.contains(c),f=t&&c&&d&&!a;if(!f)return!1;var u=or(c,l);return!u},s5=(function(){function n(e){var t=this;this.mounted=!0,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.onTransformCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.panStartPosition=null,this.lastTouch=null,this.isPinching=!1,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.pinchPreviousCenter=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.isAnimating=!1,this.animation=null,this.pressedKeys={},this.mount=function(){t.initializeWindowEvents()},this.unmount=function(){t.cleanupWindowEvents()},this.update=function(s){t.props=s,t.wrapperComponent&&t.contentComponent&&Vs(t,t.state.scale),t.setup=Fu(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=ba(),c=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,d=c==null?void 0:c.defaultView;(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("wheel",t.onWheelPanning,l),(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("keyup",t.setKeyUnPressed,l),(a=t.wrapperComponent)===null||a===void 0||a.addEventListener("keydown",t.setKeyPressed,l),d==null||d.addEventListener("mousedown",t.onPanningStart,l),d==null||d.addEventListener("mousemove",t.onPanning,l),d==null||d.addEventListener("mouseup",t.onPanningStop,l),c==null||c.addEventListener("mouseleave",t.clearPanning,l),d==null||d.addEventListener("keyup",t.setKeyUnPressed,l),d==null||d.addEventListener("keydown",t.setKeyPressed,l),d==null||d.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var s,o,i,a,l,c=ba(),d=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,f=d==null?void 0:d.defaultView;f==null||f.removeEventListener("mousedown",t.onPanningStart,c),f==null||f.removeEventListener("mousemove",t.onPanning,c),f==null||f.removeEventListener("mouseup",t.onPanningStop,c),d==null||d.removeEventListener("mouseleave",t.clearPanning,c),f==null||f.removeEventListener("keyup",t.setKeyUnPressed,c),f==null||f.removeEventListener("keydown",t.setKeyPressed,c),f==null||f.removeEventListener("blur",t.handleWindowBlur),document.removeEventListener("mouseleave",t.clearPanning,c),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("wheel",t.onWheelPanning,c),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("keyup",t.setKeyUnPressed,c),(a=t.wrapperComponent)===null||a===void 0||a.removeEventListener("keydown",t.setKeyPressed,c),tn(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=ba();s.addEventListener("wheel",t.onWheelZoom,o),s.addEventListener("dblclick",t.onDoubleClick,o),s.addEventListener("touchstart",t.onTouchPanningStart,o),s.addEventListener("touchmove",t.onTouchPanning,o),s.addEventListener("touchend",t.onTouchPanningStop,o)},this.handleInitialize=function(s){var o=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(i){return i(Xe(t))}),o&&(t.setCenter(),t.observer=new ResizeObserver(function(){var i,a=s.offsetWidth,l=s.offsetHeight;(a>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(Xe(t))}),t.setCenter(),(i=t.observer)===null||i===void 0||i.disconnect())}),setTimeout(function(){var i;(i=t.observer)===null||i===void 0||i.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var o=t.setup.disabled;if(!o){t.syncModifierKeys(s);var i=Gh(t,s);i&&(KS(t,s),VS(t,s),qS(t,s))}},this.onWheelPanning=function(s){var o=t.props.onPanning,i=t.setup.trackPadPanning,a=i.lockAxisX,l=i.lockAxisY;t.syncModifierKeys(s);var c=OS(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var d=t.state,f=d.positionX,u=d.positionY,m=f-s.deltaX,p=u-s.deltaY,h=a?f:m,g=l?u:p,v=t.setup.autoAlignment,x=v.sizeX,w=v.sizeY,y=os(t,x),j=os(t,w);h===f&&g===u||(GS(t,s),Bh(t,h,g,y,j),Qe(Xe(t),s,o),YS(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=Iu(t,s);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.button===0&&!t.setup.panning.allowLeftClickPan||s.button===1&&!t.setup.panning.allowMiddleClickPan||s.button===2&&!t.setup.panning.allowRightClickPan||(s.cancelable&&s.preventDefault(),s.stopPropagation(),tn(t),Du(t,s),Qe(Xe(t),s,i)))}}},this.onPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(!o){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var a=$u(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Lu(t,s.clientX,s.clientY,Yn.MOUSE),Qe(Xe(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(SS(t,o),Qe(Xe(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=FS(t,s);a&&(XS(t,s),tn(t),Qe(Xe(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=BS(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),JS(t,s),Qe(Xe(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(ZS(t),Qe(Xe(t),s,o))},this.onTouchPanningStart=function(s){var o=t.setup,i=o.disabled,a=o.doubleClick,l=t.props.onPanningStart;if(!i){var c=!(a!=null&&a.disabled),d=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&d&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,tn(t);var f=s.touches,u=f.length===1,m=f.length===2,p=Iu(t,s);if(u){if(!p)return;tn(t),Du(t,s),Qe(Xe(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(o)return;var a=$u(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Lu(t,l.clientX,l.clientY,Yn.TOUCH),Qe(Xe(t),s,i)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var o=t.setup.disabled;if(!o){var i=n5(t,s);i&&t5(t,s)}},this.clearPanning=function(s){t.isPanning&&t.onPanningStop(s)},this.handleWindowBlur=function(){t.pressedKeys={},t.isPanning&&(t.isPanning=!1,t.startCoords=null)},this.syncModifierKeys=function(s){var o=s.ctrlKey,i=s.metaKey,a=s.shiftKey,l=s.altKey;typeof o=="boolean"&&(t.pressedKeys.Control=o),typeof i=="boolean"&&(t.pressedKeys.Meta=i),typeof a=="boolean"&&(t.pressedKeys.Shift=a),typeof l=="boolean"&&(t.pressedKeys.Alt=l)},this.setKeyPressed=function(s){t.pressedKeys[s.key]=!0},this.setKeyUnPressed=function(s){t.pressedKeys[s.key]=!1},this.isPressingKeys=function(s){return typeof s=="function"?s(Object.entries(t.pressedKeys).filter(function(o){var i=o[1];return i}).map(function(o){var i=o[0];return i})):s.length?!!s.every(function(o){return t.pressedKeys[o]}):!0},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var s=vc(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,o,i){return t.props.customTransform?t.props.customTransform(s,o,i):qh(s,o,i)},this.getContext=function(){return Xe(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,o=s.scale,i=s.positionX,a=s.positionY,l=t.handleTransformStyles(i,a,o);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:o,positionX:i,positionY:a,previousScale:t.state.previousScale,ref:Xe(t)})})}},this.setState=function(s,o,i){var a=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(o)&&!Number.isNaN(i)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=o,t.state.positionY=i,t.applyTransformation();var c=Xe(t);t.onChangeCallbacks.forEach(function(d){return d(c)}),Qe(c,{scale:t.state.scale,positionX:o,positionY:i},a)}else console.error("Detected NaN set state values")},this.onTransform=function(s){return t.onTransformCallbacks.has(s)||t.onTransformCallbacks.add(s),function(){t.onTransformCallbacks.delete(s)}},this.onChange=function(s){return t.onChangeCallbacks.has(s)||t.onChangeCallbacks.add(s),function(){t.onChangeCallbacks.delete(s)}},this.onInit=function(s){return t.onInitCallbacks.has(s)||t.onInitCallbacks.add(s),function(){t.onInitCallbacks.delete(s)}},this.init=function(s,o){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=o,Vs(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(o),t.initializeWindowEvents(),t.isInitialized=!0;var i=Xe(t);Qe(i,void 0,t.props.onInit),IS(t.props.ref,i)},this.props=e,this.setup=Fu(this.props),this.state=Wh(this.props)}return n})(),Oi=ge.createContext(null),o5=function(n,e){return typeof n=="function"?n(e):n},r5=ge.forwardRef(function(n,e){var t=b.useRef(new s5(n)).current,s=o5(n.children,cl(t));return b.useImperativeHandle(e,function(){return cl(t)},[t]),b.useEffect(function(){t.update(n)},[t,n]),r.jsx(Oi.Provider,Yt({value:t},{children:s}))});ge.forwardRef(function(n,e){var t=b.useRef(null),s=b.useContext(Oi);return b.useEffect(function(){return s.onChange(function(o){if(t.current){var i=0,a=0;t.current.style.transform=s.handleTransformStyles(i,a,1/o.instance.state.scale)}})},[s]),r.jsx("div",Yt({},n,{ref:$S([t,e])}))});function i5(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&s.firstChild?s.insertBefore(o,s.firstChild):s.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}var a5=`.transform-component-module_wrapper__SPB86 {
|
|
26
|
+
position: relative;
|
|
27
|
+
width: -moz-fit-content;
|
|
28
|
+
width: fit-content;
|
|
29
|
+
height: -moz-fit-content;
|
|
30
|
+
height: fit-content;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
33
|
+
-webkit-user-select: none; /* Safari */
|
|
34
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
35
|
+
-moz-user-select: none; /* Firefox */
|
|
36
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
37
|
+
user-select: none;
|
|
38
|
+
margin: 0;
|
|
39
|
+
padding: 0;
|
|
40
|
+
transform: translate3d(0, 0, 0);
|
|
41
|
+
}
|
|
42
|
+
.transform-component-module_content__FBWxo {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
width: -moz-fit-content;
|
|
46
|
+
width: fit-content;
|
|
47
|
+
height: -moz-fit-content;
|
|
48
|
+
height: fit-content;
|
|
49
|
+
margin: 0;
|
|
50
|
+
padding: 0;
|
|
51
|
+
transform-origin: 0% 0%;
|
|
52
|
+
}
|
|
53
|
+
.transform-component-module_content__FBWxo img {
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
.transform-component-module_infiniteGrid__Z-aP3 {
|
|
57
|
+
position: absolute;
|
|
58
|
+
inset: 0;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
background-image: radial-gradient(
|
|
61
|
+
circle,
|
|
62
|
+
rgba(0, 0, 0, 0.12) 1px,
|
|
63
|
+
transparent 1px
|
|
64
|
+
);
|
|
65
|
+
background-size: 20px 20px;
|
|
66
|
+
background-position: 0 0;
|
|
67
|
+
}
|
|
68
|
+
`,ya={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};i5(a5);var l5=function(n){var e=n.children,t=n.wrapperClass,s=t===void 0?"":t,o=n.contentClass,i=o===void 0?"":o,a=n.wrapperStyle,l=n.contentStyle,c=n.wrapperProps,d=c===void 0?{}:c,f=n.contentProps,u=f===void 0?{}:f,m=n.infinite,p=m===void 0?!1:m,h=b.useContext(Oi),g=h.init,v=h.cleanupWindowEvents,x=b.useRef(null),w=b.useRef(null),y=b.useRef(null);return b.useEffect(function(){var j=x.current,N=w.current;return j!==null&&N!==null&&g&&(g==null||g(j,N)),function(){v==null||v()}},[]),b.useEffect(function(){if(p){var j=y.current;if(j){var N=function(){var S=h.state,k=S.positionX,C=S.positionY;j.style.backgroundPosition="".concat(k,"px ").concat(C,"px")};return N(),h.onChange(N)}}},[p,h]),r.jsxs("div",Yt({},d,{ref:x,className:"".concat(ll.wrapperClass," ").concat(ya.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:y,className:ya.infiniteGrid,"aria-hidden":!0}),r.jsx("div",Yt({},u,{ref:w,className:"".concat(ll.contentClass," ").concat(ya.content," ").concat(i),style:Yt(Yt({},l),{transform:qh(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function c5(n,e){var t=Math.max(0,Math.min(n.x+n.width,e.x+e.width)-Math.max(n.x,e.x)),s=Math.max(0,Math.min(n.y+n.height,e.y+e.height)-Math.max(n.y,e.y));return t*s}function d5(n){var e=n.elementX,t=n.elementY,s=n.elementWidth,o=n.elementHeight,i=n.scale,a=n.positionX,l=n.positionY,c=n.viewportWidth,d=n.viewportHeight,f=n.margin,u=f===void 0?0:f,m=n.threshold,p=m===void 0?0:m,h={x:-u,y:-u,width:c+2*u,height:d+2*u},g={x:e*i+a,y:t*i+l,width:s*i,height:o*i};if(p<=0){var v=g.x<h.x+h.width&&g.x+g.width>h.x,x=g.y<h.y+h.height&&g.y+g.height>h.y;return v&&x}var w=g.width*g.height;if(w<=0)return!1;var y=c5(h,g);return y/w>=p}ge.forwardRef(function(n,e){var t=n.x,s=n.y,o=n.width,i=n.height,a=n.margin,l=a===void 0?0:a,c=n.threshold,d=c===void 0?0:c,f=n.placeholder,u=f===void 0?null:f,m=n.onShow,p=n.onHide,h=n.children,g=n.className,v=n.style,x=b.useContext(Oi),w=b.useState(!1),y=w[0],j=w[1],N=b.useRef(!1),S=b.useRef(m),k=b.useRef(p);return S.current=m,k.current=p,b.useEffect(function(){var C=function(){var P,A,E=x.wrapperComponent;if(E){var M=d5({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:x.state.scale,positionX:x.state.positionX,positionY:x.state.positionY,viewportWidth:E.offsetWidth,viewportHeight:E.offsetHeight,margin:l,threshold:d});M!==N.current&&(N.current=M,j(M),M?(P=S.current)===null||P===void 0||P.call(S):(A=k.current)===null||A===void 0||A.call(k))}};C();var T=x.onChange(C),_;return x.wrapperComponent||(_=x.onInit(function(){return C()})),function(){T(),_==null||_()}},[x,t,s,o,i,l,d]),y?r.jsx("div",Yt({ref:e,className:g,style:v},{children:h})):u?r.jsx(r.Fragment,{children:u}):null});const Bu=8,u5=56;function lo(n){const e=F.c(8),{label:t,disabled:s,onClick:o,children:i,className:a}=n;let l;e[0]!==a?(l=G("size-8 border border-white/10 bg-white/[0.06] text-white/75","hover:bg-white/10 hover:text-white focus-visible:ring-white/40","disabled:pointer-events-none disabled:opacity-30",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==s||e[4]!==t||e[5]!==o||e[6]!==l?(c=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,disabled:s,"aria-label":t,title:t,className:l,children:i}),e[2]=i,e[3]=s,e[4]=t,e[5]=o,e[6]=l,e[7]=c):c=e[7],c}function bc(n){const e=F.c(101),{open:t,images:s,initialIndex:o,onClose:i,onCloseComplete:a}=n,l=t===void 0?!0:t,c=Math.min(Math.max(o,0),Math.max(s.length-1,0)),[d,f]=b.useState(c),[u,m]=b.useState(100),p=b.useRef(null),h=b.useRef(null),g=s[d];let v;e[0]!==s.length?(v=fe=>{f(Math.min(Math.max(fe,0),s.length-1)),m(100)},e[0]=s.length,e[1]=v):v=e[1];const x=v;let w;e[2]!==x||e[3]!==d?(w=()=>x(d-1),e[2]=x,e[3]=d,e[4]=w):w=e[4];const y=w;let j;e[5]!==x||e[6]!==d?(j=()=>x(d+1),e[5]=x,e[6]=d,e[7]=j):j=e[7];const N=j;if(!g)return null;const S=s.length>1,k=d>0,C=d<s.length-1,T=u>100;let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{var fe;return(fe=p.current)==null?void 0:fe.zoomIn()},e[8]=_):_=e[8];const P=_;let A;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var fe;return(fe=p.current)==null?void 0:fe.zoomOut()},e[9]=A):A=e[9];const E=A;let M;e[10]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{var fe;return(fe=p.current)==null?void 0:fe.resetTransform()},e[10]=M):M=e[10];const I=M;let R;e[11]!==C||e[12]!==k||e[13]!==N||e[14]!==y?(R=fe=>{fe.key==="ArrowLeft"&&k?(fe.preventDefault(),y()):fe.key==="ArrowRight"&&C?(fe.preventDefault(),N()):fe.key==="+"||fe.key==="="?(fe.preventDefault(),P()):fe.key==="-"?(fe.preventDefault(),E()):fe.key==="0"&&(fe.preventDefault(),I())},e[11]=C,e[12]=k,e[13]=N,e[14]=y,e[15]=R):R=e[15];const D=R;let L;e[16]===Symbol.for("react.memo_cache_sentinel")?(L=fe=>{if(fe.pointerType==="mouse"||fe.isPrimary===!1){h.current=null;return}h.current={x:fe.clientX,y:fe.clientY}},e[16]=L):L=e[16];const $=L;let z;e[17]!==C||e[18]!==k||e[19]!==N||e[20]!==y?(z=fe=>{var Ee;const Ce=h.current;h.current=null;const _e=((Ee=p.current)==null?void 0:Ee.instance.state.scale)??1;if(!Ce||_e>1.01)return;const Be=fe.clientX-Ce.x,be=fe.clientY-Ce.y;Math.abs(Be)<u5||Math.abs(Be)<Math.abs(be)||(Be>0&&k&&y(),Be<0&&C&&N())},e[17]=C,e[18]=k,e[19]=N,e[20]=y,e[21]=z):z=e[21];const U=z;let O;e[22]!==i?(O=fe=>{fe||i()},e[22]=i,e[23]=O):O=e[23];let H;e[24]!==a?(H=fe=>{fe||a==null||a()},e[24]=a,e[25]=H):H=e[25];let B,W,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=G("flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl border-white/10 bg-black p-0 text-white","sm:h-[min(820px,calc(100dvh-2rem))] sm:w-[min(1120px,calc(100vw-2rem))] sm:max-w-none"),W=r.jsx(Ln,{className:"sr-only",children:"Image viewer"}),V=r.jsx(zn,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=B,e[27]=W,e[28]=V):(B=e[26],W=e[27],V=e[28]);let q;e[29]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-white/[0.06]",children:r.jsx(M2,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=q):q=e[29];const Y=g.label||g.alt||"Session image";let K;e[30]!==Y?(K=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:Y}),e[30]=Y,e[31]=K):K=e[31];let J;e[32]!==S||e[33]!==s.length||e[34]!==d?(J=S&&r.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[d+1," of ",s.length]}),e[32]=S,e[33]=s.length,e[34]=d,e[35]=J):J=e[35];let Z;e[36]!==K||e[37]!==J?(Z=r.jsxs("div",{className:"min-w-0 flex-1",children:[K,J]}),e[36]=K,e[37]=J,e[38]=Z):Z=e[38];const Q=u<=100;let se;e[39]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(Ym,{className:"size-3.5","data-icon":"icon"}),e[39]=se):se=e[39];let ne;e[40]!==Q?(ne=r.jsx(lo,{label:"Zoom out",disabled:Q,onClick:E,children:se}),e[40]=Q,e[41]=ne):ne=e[41];let ee;e[42]!==u?(ee=r.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:I,className:"min-w-12 px-1.5 font-mono text-xs tabular-nums text-white/60 hover:bg-white/[0.06] hover:text-white","aria-label":"Reset zoom",title:"Reset zoom",children:[u,"%"]}),e[42]=u,e[43]=ee):ee=e[43];const ie=u>=Bu*100;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsx(xn,{className:"size-3.5","data-icon":"icon"}),e[44]=oe):oe=e[44];let re;e[45]!==ie?(re=r.jsx(lo,{label:"Zoom in",disabled:ie,onClick:P,children:oe}),e[45]=ie,e[46]=re):re=e[46];let te;e[47]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("div",{className:"mx-1 h-5 w-px bg-white/10"}),e[47]=te):te=e[47];let ce;e[48]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(xt,{className:"size-4","data-icon":"icon"}),e[48]=ce):ce=e[48];let me;e[49]!==i?(me=r.jsx(lo,{label:"Close image viewer",onClick:i,children:ce}),e[49]=i,e[50]=me):me=e[50];let pe;e[51]!==ne||e[52]!==ee||e[53]!==re||e[54]!==me?(pe=r.jsxs("div",{className:"flex items-center gap-1",children:[ne,ee,re,te,me]}),e[51]=ne,e[52]=ee,e[53]=re,e[54]=me,e[55]=pe):pe=e[55];let xe;e[56]!==Z||e[57]!==pe?(xe=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-white/10 bg-black/20 px-2.5 sm:px-3",children:[q,Z,pe]}),e[56]=Z,e[57]=pe,e[58]=xe):xe=e[58];const we=g.id;let ae,ve,he;e[59]===Symbol.for("react.memo_cache_sentinel")?(ae={mode:"toggle"},ve={step:.005},he=(fe,Ce)=>m(Math.round(Ce.scale*100)),e[59]=ae,e[60]=ve,e[61]=he):(ae=e[59],ve=e[60],he=e[61]);let de,Ne;e[62]===Symbol.for("react.memo_cache_sentinel")?(de={width:"100%",height:"100%"},Ne={width:"100%",height:"100%"},e[62]=de,e[63]=Ne):(de=e[62],Ne=e[63]);const ke=g.src,Te=g.alt,Ae=T?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let Pe;e[64]!==Ae?(Pe=G("max-h-full max-w-full select-none object-contain",Ae),e[64]=Ae,e[65]=Pe):Pe=e[65];let De;e[66]!==g.alt||e[67]!==g.src||e[68]!==Pe?(De=r.jsx(l5,{wrapperStyle:de,contentStyle:Ne,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:ke,alt:Te,draggable:!1,className:Pe})}),e[66]=g.alt,e[67]=g.src,e[68]=Pe,e[69]=De):De=e[69];let ze;e[70]!==g.id||e[71]!==De?(ze=r.jsx(r5,{ref:p,minScale:1,maxScale:Bu,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ae,wheel:ve,onTransform:he,children:De},we),e[70]=g.id,e[71]=De,e[72]=ze):ze=e[72];let Fe;e[73]!==C||e[74]!==k||e[75]!==N||e[76]!==y||e[77]!==S?(Fe=S&&r.jsxs(r.Fragment,{children:[r.jsx(lo,{label:"Previous image",disabled:!k,onClick:y,className:"absolute left-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:left-3",children:r.jsx(Dl,{className:"size-5","data-icon":"icon"})}),r.jsx(lo,{label:"Next image",disabled:!C,onClick:N,className:"absolute right-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:right-3",children:r.jsx(et,{className:"size-5","data-icon":"icon"})})]}),e[73]=C,e[74]=k,e[75]=N,e[76]=y,e[77]=S,e[78]=Fe):Fe=e[78];let ue;e[79]!==u?(ue=u===100&&r.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 hidden -translate-x-1/2 items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 text-xs text-white/60 sm:flex",children:[r.jsx(pi,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=u,e[80]=ue):ue=e[80];let le;e[81]!==U||e[82]!==ze||e[83]!==Fe||e[84]!==ue?(le=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:$,onPointerUp:U,children:[ze,Fe,ue]}),e[81]=U,e[82]=ze,e[83]=Fe,e[84]=ue,e[85]=le):le=e[85];let Me;e[86]!==x||e[87]!==S||e[88]!==s||e[89]!==d?(Me=S&&r.jsx("footer",{className:"shrink-0 border-t border-white/10 bg-black/25 px-2 py-2",children:r.jsx("div",{className:"flex gap-1.5 overflow-x-auto overscroll-x-contain pb-0.5",children:s.map((fe,Ce)=>r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>x(Ce),"aria-label":`View image ${Ce+1}`,"aria-current":Ce===d?"true":void 0,className:G("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",Ce===d?"border-white ring-1 ring-white/40":"border-white/10 opacity-55 hover:border-white/25 hover:opacity-90"),children:[r.jsx("img",{src:fe.src,alt:"",draggable:!1,className:"size-full rounded-[3px] object-cover"}),r.jsx("span",{className:"absolute bottom-0.5 right-0.5 rounded bg-black/70 px-1 font-mono text-xs text-white/80",children:Ce+1})]},`${fe.id}-${Ce}`))})}),e[86]=x,e[87]=S,e[88]=s,e[89]=d,e[90]=Me):Me=e[90];let Le;e[91]!==D||e[92]!==xe||e[93]!==le||e[94]!==Me?(Le=r.jsxs(Dn,{showCloseButton:!1,onKeyDown:D,className:B,children:[W,V,xe,le,Me]}),e[91]=D,e[92]=xe,e[93]=le,e[94]=Me,e[95]=Le):Le=e[95];let je;return e[96]!==l||e[97]!==O||e[98]!==H||e[99]!==Le?(je=r.jsx(On,{open:l,onOpenChange:O,onOpenChangeComplete:H,children:Le}),e[96]=l,e[97]=O,e[98]=H,e[99]=Le,e[100]=je):je=e[100],je}function dl(n){return n.type==="user"}function yc(n){return n.type==="assistant"}function Uu(n){return n.type==="progress"}function Wu(n){return n.type==="system"}function ng(n){return n.type==="summary"}function f5(n){return n.type==="queue-operation"}function sg(n){return n.type==="attachment"}function m5(n){return n.type==="user"&&n.isCompactSummary===!0}function og(n){return n.type==="system"&&n.subtype==="compact_boundary"}const p5=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,h5=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function g5(n){for(const e of h5){const t=n.match(e),s=(t==null?void 0:t[1])??(t==null?void 0:t[2]);if(s)return s}return null}function x5(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function Mo(n){let e=null,t=!1;const s=n.replace(p5,(o,i,a,l)=>(t=!0,e===null&&(e=g5(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const v5=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],b5=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],y5=200,w5=/\bhttps?:\/\/\S+/g;function j5(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,y5).toLowerCase();if(v5.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
|
|
69
|
+
`)+1).slice(-200).replace(w5,"").toLowerCase();return o.includes("?")||b5.some(i=>i.test(o))}function rg(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
70
|
+
`)}function Hu(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
71
|
+
`):""}function ig(n){if(!(n!=null&&n.trim()))return!1;const e=n.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}function S5(n){if(!sg(n))return null;const e=n.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const t=e.prompt;if(t==null)return null;const s=typeof t=="string"?t:rg(t);if(!ig(s))return null;const o=e.origin;if((o==null?void 0:o.kind)==="peer"){const a=o.name??o.from??null;if(a)return{raw:s,sender:a,body:o.body??Mo(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=Mo(s);return{raw:s,sender:i.sender,body:i.body}}const N5=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function k5(n,e){let t=n;for(const[s,o]of N5){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}function C5(n,e){return n?{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??n.speed}:{...e}}const _5=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,T5=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function E5(n){return rg(n).trim().replace(_5,"").replace(T5,"").trim()}function P5(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function wa(n,e){return{id:n.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:n.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function A5(n){const e=[];let t=0;for(;t<n.length;){const s=n[t];if(s.kind==="tool_calls"){const o=s.toolCalls.findIndex(i=>i.name==="EnterPlanMode");if(o!==-1){const i=s.toolCalls[o],a=String(i.input.plan??""),l=s.timestamp,c=s.toolCalls.slice(0,o);c.length>0&&e.push({kind:"tool_calls",toolCalls:c,timestamp:s.timestamp});const d=[],f=s.toolCalls.slice(o+1),u=f.findIndex(m=>m.name==="ExitPlanMode");if(u!==-1){d.push(...f.slice(0,u));const m=f[u],p=m.input.path?String(m.input.path):void 0;let h="pending";m.result!==null&&(h=m.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l});const g=f.slice(u+1);g.length>0&&e.push({kind:"tool_calls",toolCalls:g,timestamp:s.timestamp}),t++;continue}else{d.push(...f);let m,p,h="pending",g=t+1;const v=[];for(;g<n.length;){const x=n[g];if(x.kind==="tool_calls"){const w=x.toolCalls.findIndex(y=>y.name==="ExitPlanMode");if(w!==-1){d.push(...x.toolCalls.slice(0,w)),m=x.toolCalls[w],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const y=x.toolCalls.slice(w+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...v),y.length>0&&e.push({kind:"tool_calls",toolCalls:y,timestamp:x.timestamp}),t=g+1;break}else d.push(...x.toolCalls),g++}else if(x.kind==="hook_event"||x.kind==="text"||x.kind==="queued_prompt"||x.kind==="agent_message")v.push(x),g++;else break}m||(e.push({kind:"plan_mode",plan:a,planFilePath:void 0,status:"pending",toolCalls:d,timestamp:l}),e.push(...v),t=g);continue}}}e.push(s),t++}return e}function M5(n){return n.contentBlocks.some(e=>e.kind==="agent_message")?{...n,contentBlocks:n.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:t,...s}=e;return s})}:n}function wc(n){var s;const e=n.map(M5),t=new Map;for(const o of e)for(const i of o.contentBlocks){if(i.kind==="agent_message"){const a=t.get(i.sender);a?a.push(i):t.set(i.sender,[i]);continue}if(i.kind==="tool_calls")for(const a of i.toolCalls){if(a.name!=="SendMessage")continue;const l=a.input.to;if(typeof l!="string"||!l)continue;const c=(s=t.get(l))==null?void 0:s.shift();if(!c)continue;const d=a.input.summary;c.reply={summary:typeof d=="string"?d:"",timestamp:a.timestamp||i.timestamp||""}}}return e}function R5(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(ng(o)||og(o)){t=!1;continue}if(dl(o)&&!o.isMeta){const i=o.message.content;if(t&&Array.isArray(i)&&i.some(l=>l.type==="tool_result"))continue;e.push(s),t=!0;continue}yc(o)&&!t&&(e.push(s),t=!0)}return e}function ag(n){var y,j;const e=[];let t=null,s=null;function o(N){s&&(N.compactionSummary=s.summary,N.compactionMeta=s.meta,s=null)}let i=null;const a=new Map,l=new Set,c=new Map,d=new Map,f=new Set,u=new Map,m=[],p=new Map;function h(N,S){let k=p.get(N);k||(k=new Map,p.set(N,k)),k.set(S,(k.get(S)??0)+1)}function g(N,S){const k=p.get(N),C=k==null?void 0:k.get(S);return!k||!C?!1:(C===1?k.delete(S):k.set(S,C-1),!0)}function v(){for(const N of m)N.turn.contentBlocks.push(N.sender?{kind:"agent_message",sender:N.sender,body:N.body,timestamp:N.timestamp}:{kind:"queued_prompt",content:N.content,timestamp:N.timestamp});m.length=0}function x(N){if(!t)return;const S=c.get(N);if(!S||S.length===0)return;t.subAgentActivity.push(...S),c.delete(N);const k=f.has(N)?"background_agent":"sub_agent",C=d.get(N);if(C)C.messages.push(...S);else{const T={kind:k,messages:[...S]};t.contentBlocks.push(T),d.set(N,T)}}function w(){if(t){for(const N of t.toolCalls)x(N.id);for(const[N]of c)x(N);for(const N of t.contentBlocks)if(N.kind==="hook_event")for(const S of N.events){if(!(S.eventName==="PostToolUse"||S.eventName.startsWith("PostToolUse:"))||!S.toolUseId)continue;const C=t.toolCalls.find(T=>T.id===S.toolUseId);C&&(S.updatedToolOutput&&(C.outputReplacedByHook=!0),S.durationMs!==void 0&&(C.hookDurationMs=(C.hookDurationMs??0)+S.durationMs))}t.contentBlocks=A5(t.contentBlocks),e.push(t),t=null,d.clear()}}for(const N of n){if(ng(N)){w(),s={summary:N.summary};continue}if(og(N)){w(),s={meta:P5(N.compactMetadata)};continue}if(m5(N)){w(),t=wa(N,null),t.compactionSummary=E5(N.message.content),t.compactionMeta=s==null?void 0:s.meta,s=null;continue}if(Wu(N)&&N.subtype==="away_summary"&&N.content){i={content:N.content,timestamp:N.timestamp};continue}if(f5(N)){if(t&&N.operation==="enqueue"&&ig(N.content)){const S=Mo(N.content);m.push({turn:t,content:N.content,timestamp:N.timestamp,sender:S.sender,body:S.body}),h(t,N.content)}continue}if(sg(N)){const S=S5(N);t&&S!==null&&!g(t,S.raw)&&m.push({turn:t,content:S.raw,timestamp:((y=N.attachment)==null?void 0:y.timestamp)??N.timestamp,sender:S.sender,body:S.body});continue}if(m.length>0){const S=dl(N)&&!N.isMeta?N.message.content:null;if(typeof S=="string"){const k=m.findIndex(C=>C.content===S);if(k>=0){const[C]=m.splice(k,1);g(C.turn,C.content)}}v()}if(dl(N)&&!N.isMeta){const S=N.message.content;if(typeof S!="string"&&Array.isArray(S)&&S.some(C=>C.type==="tool_result")&&t){for(const T of S)if(T.type==="tool_result"){const _=a.get(T.tool_use_id);_&&(_.turn.toolCalls[_.index].result=Hu(T.content),_.turn.toolCalls[_.index].isError=T.is_error===!0,a.delete(T.tool_use_id))}const C=N.toolUseResult;if(C!=null&&C.agentId){const T=((j=S.find(I=>I.type==="tool_result"))==null?void 0:j.tool_use_id)??"",_=u.get(T),P=f.has(T),A=[];if(Array.isArray(C.content))for(const I of C.content)I.type==="text"&&A.push(I.text);const E={agentId:C.agentId,parentToolUseId:T||void 0,agentName:(_==null?void 0:_.name)??null,subagentType:(_==null?void 0:_.subagentType)??null,type:"assistant",content:C.content,toolCalls:[],thinking:[],text:A,timestamp:N.timestamp??"",tokenUsage:C.usage?{input_tokens:C.usage.input_tokens??0,output_tokens:C.usage.output_tokens??0,cache_creation_input_tokens:C.usage.cache_creation_input_tokens??0,cache_read_input_tokens:C.usage.cache_read_input_tokens??0}:null,model:null,isBackground:P,prompt:C.prompt,status:C.status,durationMs:C.totalDurationMs,toolUseCount:C.totalToolUseCount};if(!d.get(T)){t.subAgentActivity.push(E);const R={kind:P?"background_agent":"sub_agent",messages:[E]};t.contentBlocks.push(R),d.set(T,R)}}continue}w(),t=wa(N,N.message.content),o(t),i&&(t.contentBlocks.push({kind:"recap",content:i.content,timestamp:i.timestamp}),i=null);continue}if(yc(N)){let S=function(){P.length>0&&(A.contentBlocks.push({kind:"tool_calls",toolCalls:[...P],timestamp:T}),P.length=0)},k=function(){if(_.length>0){const E=A.contentBlocks[A.contentBlocks.length-1];E&&E.kind==="thinking"?E.blocks.push(..._):A.contentBlocks.push({kind:"thinking",blocks:[..._],timestamp:T}),_.length=0}};t||(t=wa(N,null),o(t)),t.model=N.message.model,N.effort&&(t.effort=N.effort),t.attribution=k5(t.attribution,N);const C=N.message.id;l.has(C)||(l.add(C),t.tokenUsage=C5(t.tokenUsage,N.message.usage));const T=N.timestamp??"",_=[],P=[],A=t;for(const E of N.message.content)if(E.type==="thinking"){S();const M=E;if(!M.thinking)continue;t.thinking.push(M),_.push(M)}else if(E.type==="text"){S(),k();const M=/<thinking>([\s\S]*?)<\/thinking>/g;let I=E.text,R;for(;(R=M.exec(E.text))!==null;){const D=R[1].trim();if(D){const L={type:"thinking",thinking:D,signature:""};t.thinking.push(L),t.contentBlocks.push({kind:"thinking",blocks:[L],timestamp:T})}I=I.replace(R[0],"")}if(I=I.trim(),I){t.assistantText.push(I);const D=t.contentBlocks[t.contentBlocks.length-1];D&&D.kind==="text"?D.text.push(I):t.contentBlocks.push({kind:"text",text:[I],timestamp:T})}}else if(E.type==="tool_use"){k();const M={id:E.id,name:E.name,input:E.input,result:null,isError:!1,timestamp:N.timestamp??""},I=t.toolCalls.length;if(t.toolCalls.push(M),P.push(M),a.set(E.id,{turn:t,index:I}),E.name==="Task"||E.name==="Agent"){const R=E.input;R.run_in_background===!0&&f.add(E.id),u.set(E.id,{name:R.name??null,subagentType:R.subagent_type??null})}}k(),S();continue}if(Uu(N)&&N.data.type==="agent_progress"){const S=N.data,k=N.parentToolUseID??"";let C=null;if(S.message.type==="assistant"){const E=S.message.message,M=E.id,I=E.usage;I&&M&&!l.has(M)&&(l.add(M),C={input_tokens:I.input_tokens??0,output_tokens:I.output_tokens??0,cache_creation_input_tokens:I.cache_creation_input_tokens??0,cache_read_input_tokens:I.cache_read_input_tokens??0})}const T=S.message.type==="assistant"?S.message.message.model??null:null,_=u.get(k),P={agentId:S.agentId,parentToolUseId:k||void 0,agentName:(_==null?void 0:_.name)??null,subagentType:(_==null?void 0:_.subagentType)??null,type:S.message.type,content:S.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:S.message.timestamp??N.timestamp??"",tokenUsage:C,model:T,isBackground:f.has(k)};if(S.message.type==="assistant"){const E=S.message.message.content;if(Array.isArray(E))for(const M of E)M.type==="thinking"?P.thinking.push(M.thinking):M.type==="text"?P.text.push(M.text):M.type==="tool_use"&&P.toolCalls.push({id:M.id,name:M.name,input:M.input,result:null,isError:!1,timestamp:S.message.timestamp??N.timestamp??""})}else if(S.message.type==="user"){const E=S.message.message.content;if(Array.isArray(E)){for(const M of E)if(M.type==="tool_result"){const I=c.get(k);if(I)for(const R of I){const D=R.toolCalls.find(L=>L.id===M.tool_use_id);D&&(D.result=Hu(M.content),D.isError=M.is_error===!0)}}}}let A=c.get(k);A||(A=[],c.set(k,A)),A.push(P),t&&x(k);continue}if(Uu(N)&&N.data.type==="hook_progress"){const S=N.data,k=String(S.hook_event_name??S.hookEvent??"unknown"),C=S.hookSpecificOutput,T={eventName:k,source:S.source!==void 0?String(S.source):void 0,toolName:S.tool_name!==void 0?String(S.tool_name):void 0,toolUseId:S.tool_use_id!==void 0?String(S.tool_use_id):void 0,command:S.command!==void 0?String(S.command):void 0,output:S.output!==void 0?String(S.output):void 0,stderr:S.stderr!==void 0?String(S.stderr):void 0,exitCode:S.exit_code!==void 0?Number(S.exit_code):void 0,decision:S.decision!==void 0?String(S.decision):void 0,durationMs:S.duration_ms!==void 0?Number(S.duration_ms):void 0,updatedToolOutput:(C==null?void 0:C.updatedToolOutput)!==void 0?String(C.updatedToolOutput):void 0,sessionTitle:(C==null?void 0:C.sessionTitle)!==void 0?String(C.sessionTitle):void 0,worktreePath:(C==null?void 0:C.worktreePath)!==void 0?String(C.worktreePath):void 0,timestamp:N.timestamp??""};if(t){const _=t.contentBlocks[t.contentBlocks.length-1];_&&_.kind==="hook_event"?_.events.push(T):t.contentBlocks.push({kind:"hook_event",events:[T],timestamp:N.timestamp})}continue}if(Wu(N)&&N.subtype==="turn_duration"&&t){t.durationMs=N.durationMs??null;continue}}return v(),w(),wc(e)}function I5(n,e){if(n.length<2)return!1;const t=n[n.length-2],s=t.toolCalls[t.toolCalls.length-1];return(s==null?void 0:s.name)===e&&s.isError}function $5(n,e){const t=n.contentBlocks,s=t.findIndex(o=>o.kind==="tool_calls"&&o.toolCalls.some(i=>i.id===e));return s===-1?!1:t.slice(s+1).some(o=>o.kind==="text"||o.kind==="thinking"||o.kind==="tool_calls")}function lg(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];if(!t||t.toolCalls.length===0)return null;const s=t.toolCalls[t.toolCalls.length-1];if(!s)return null;const{name:o}=s;if(o!=="ExitPlanMode"&&o!=="AskUserQuestion"||s.result!==null&&!s.isError||I5(e,o)||s.isError&&$5(t,s.id))return null;const i=s.input;if(o==="ExitPlanMode")return{type:"plan",allowedPrompts:i.allowedPrompts};const a=i.questions;return a&&a.length>0?{type:"question",toolUseId:s.id,questions:a}:null}function O5(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
72
|
+
`)}function cg(n){const e=[];for(const t of n.split(`
|
|
73
|
+
`)){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function D5(n){var t;const e=(t=n[0])==null?void 0:t.type;return e==="session_meta"||e==="turn_context"||e==="event_msg"||e==="response_item"||e==="compacted"||e==="world_state"||e==="inter_agent_communication_metadata"}function L5(n){return n.map(e=>JSON.stringify(e)).join(`
|
|
74
|
+
`)}function z5(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const t of n)if(t.sessionId&&!e.sessionId&&(e.sessionId=t.sessionId),t.version&&!e.version&&(e.version=t.version),t.gitBranch&&!e.gitBranch&&(e.gitBranch=t.gitBranch),t.cwd&&!e.cwd&&(e.cwd=t.cwd),t.slug&&!e.slug&&(e.slug=t.slug),t.name&&!e.name&&(e.name=t.name),t.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=t.branchedFrom),yc(t)&&t.message.model&&!e.model&&(e.model=t.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function Di(n,e){if(Xo(n))return Jl(n);const t=cg(n),s=z5(t),o=ag(t),i=e!=null&&e.skipStats?qp(o.length):Kl(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function F5(n,e){if(D5(n.rawMessages)||Xo(e)){const h=L5(n.rawMessages);return Jl(h?`${h}
|
|
75
|
+
${e}`:e)}const t=cg(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=R5(s),a=Math.max(0,n.turns.length-i.length);let l=Math.max(0,i.length-1);const c=new Set;for(const h of t)if(h.type==="progress"){const g=h.parentToolUseID;g&&c.add(g)}if(c.size>0)for(let h=l-1;h>=0;h--){const g=n.turns[a+h];if(g!=null&&g.toolCalls.some(v=>c.has(v.id))){l=h;break}}const d=i[l]??s.length,f=n.turns.slice(0,a+l),u=ag(o.slice(d)),m=wc([...f,...u]),p=Kl(m);return{sessionId:n.sessionId,version:n.version,gitBranch:n.gitBranch,cwd:n.cwd,slug:n.slug,name:n.name,model:n.model||m.length>0&&m[m.length-1].model||"",turns:m,stats:p,rawMessages:o,branchedFrom:n.branchedFrom,agentKind:n.agentKind}}function Li(n){return n===null?"":typeof n=="string"?n:O5(n)}function dg(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const ug=b.createContext(null);function B5(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=dg(s.userMessage);for(let i=0;i<o.length;i+=1){const a=o[i];e.push({id:`${s.id}:attachment:${i}`,src:`data:${a.source.media_type};base64,${a.source.data}`,alt:`Attachment ${i+1} from turn ${t+1}`,label:`Turn ${t+1} · Image ${i+1}`})}}return e}function U5(n){const e=F.c(10),{images:t,children:s}=n,[o,i]=b.useState(null);let a;e[0]!==t?(a=m=>{const p=t.findIndex(g=>g.src===m.src),h=p>=0?t:[...t,{...m,id:m.id??`supplemental-image-${t.length}`}];i(g=>({key:((g==null?void 0:g.key)??0)+1,open:!0,images:h,index:p>=0?p:h.length-1}))},e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c={openImage:l},e[2]=l,e[3]=c):c=e[3];const d=c;let f;e[4]!==o?(f=o&&r.jsx(bc,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(W5),onCloseComplete:()=>i(null)},o.key),e[4]=o,e[5]=f):f=e[5];let u;return e[6]!==s||e[7]!==f||e[8]!==d?(u=r.jsxs(ug.Provider,{value:d,children:[s,f]}),e[6]=s,e[7]=f,e[8]=d,e[9]=u):u=e[9],u}function W5(n){return n?{...n,open:!1}:null}function H5(n){const e=F.c(7),{children:t}=n,{session:s}=st();s==null||s.turns;let o;e[0]!==(s==null?void 0:s.turns)?(o=(s==null?void 0:s.turns)??[],e[0]=s==null?void 0:s.turns,e[1]=o):o=e[1];let i;e[2]!==o?(i=B5(o),e[2]=o,e[3]=i):i=e[3];const a=i;let l;return e[4]!==t||e[5]!==a?(l=r.jsx(U5,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function fg(){return b.useContext(ug)}const mg=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function K5(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:mg.has(n.slice(e).toLowerCase())}function jc(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:K5(n)}function V5(n){return n&&(jc(n)?Vo(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function pg(n){const e=F.c(41),{src:t,alt:s,id:o,className:i,thumbnailClassName:a}=n,l=o===void 0?"markdown-image":o,c=cn("hostFiles"),[d,f]=b.useState(!1),[u,m]=b.useState(!1),[p,h]=b.useState(),g=fg();let v;e[0]!==c||e[1]!==t?(v=jc(t)&&!c,e[0]=c,e[1]=t,e[2]=v):v=e[2];const x=v;let w;e[3]!==x||e[4]!==t?(w=x?void 0:V5(t),e[3]=x,e[4]=t,e[5]=w):w=e[5];const y=w;let j;e[6]!==s||e[7]!==l||e[8]!==y?(j=y?{id:l,src:y,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=y,e[9]=j):j=e[9];const N=j;let S;e[10]!==g||e[11]!==N?(S=()=>{N&&(g?g.openImage(N):(m(!0),f(!0)))},e[10]=g,e[11]=N,e[12]=S):S=e[12];const k=S;if(x){let L;return e[13]!==s?(L=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=L):L=e[14],L}if(y&&p===y){const L=s?`: ${s}`:"";let $;return e[15]!==L?($=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",L]}),e[15]=L,e[16]=$):$=e[16],$}const C=`Open ${s||"rendered image"}`;let T;e[17]!==i?(T=G("group/image relative my-3 block h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 transition-colors hover:bg-muted focus-visible:ring-ring/40",i),e[17]=i,e[18]=T):T=e[18];const _=s??"";let P;e[19]!==y?(P=()=>h(y),e[19]=y,e[20]=P):P=e[20];let A;e[21]!==a?(A=G("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=A):A=e[22];let E;e[23]!==y||e[24]!==A||e[25]!==_||e[26]!==P?(E=r.jsx("img",{src:y,alt:_,loading:"lazy",decoding:"async",onError:P,className:A}),e[23]=y,e[24]=A,e[25]=_,e[26]=P,e[27]=E):E=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(pi,{className:"size-3.5","data-icon":"icon"})}),e[28]=M):M=e[28];let I;e[29]!==k||e[30]!==E||e[31]!==C||e[32]!==T?(I=r.jsxs(X,{type:"button",variant:"ghost",onClick:k,"aria-label":C,className:T,children:[E,M]}),e[29]=k,e[30]=E,e[31]=C,e[32]=T,e[33]=I):I=e[33];let R;e[34]!==d||e[35]!==u||e[36]!==N?(R=u&&N&&r.jsx(bc,{open:d,images:[N],initialIndex:0,onClose:()=>f(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=u,e[36]=N,e[37]=R):R=e[37];let D;return e[38]!==I||e[39]!==R?(D=r.jsxs(r.Fragment,{children:[I,R]}),e[38]=I,e[39]=R,e[40]=D):D=e[40],D}function q5(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("w-full caption-bottom text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:o,...s})}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function G5(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("[&_tr]:border-b",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("thead",{"data-slot":"table-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Y5(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tbody",{"data-slot":"table-body",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function X5(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tr",{"data-slot":"table-row",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function J5(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("th",{"data-slot":"table-head",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Z5(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("td",{"data-slot":"table-cell",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Q5(n){if(!n)return null;let e=n;if(e.toLowerCase().startsWith("file://"))try{const l=new URL(e);e=`${l.pathname}${l.hash}`}catch{return null}const t=e.startsWith("/")&&!e.startsWith("//"),s=/^\/?[a-z]:[\\/]/i.test(e);if(!t&&!s)return null;let o,i;const a=e.match(/#L(\d+)(?:C(\d+))?$/i);if(a)o=Number(a[1]),i=a[2]?Number(a[2]):void 0,e=e.slice(0,-a[0].length);else{const l=e.match(/:(\d+)(?::(\d+))?$/);l&&(o=Number(l[1]),i=l[2]?Number(l[2]):void 0,e=e.slice(0,-l[0].length))}try{e=decodeURIComponent(e)}catch{return null}return/^\/[a-z]:[\\/]/i.test(e)&&(e=e.slice(1)),{path:e,line:o,column:i}}function e4(n){const e=F.c(17);let t,s,o;e[0]!==n?({href:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=cn("hostFiles");let a;e[4]!==s?(a=Q5(s),e[4]=s,e[5]=a):a=e[5];const l=a;if(l&&!i){let u;return e[6]!==t||e[7]!==s?(u=r.jsx("span",{className:"text-muted-foreground",title:s,children:t}),e[6]=t,e[7]=s,e[8]=u):u=e[8],u}let c;e[9]!==l||e[10]!==s?(c=u=>{s&&(u.preventDefault(),l?Vr(l.path,{line:l.line,column:l.column}):window.open(s,"_blank","noopener,noreferrer"))},e[9]=l,e[10]=s,e[11]=c):c=e[11];const d=c;let f;return e[12]!==t||e[13]!==d||e[14]!==s||e[15]!==o?(f=r.jsx("a",{href:s,onClick:d,className:"text-primary underline decoration-primary/30 hover:decoration-primary/60 cursor-pointer transition-colors",title:s,...o,children:t}),e[12]=t,e[13]=d,e[14]=s,e[15]=o,e[16]=f):f=e[16],f}const t4=[...mg].map(n=>n.slice(1)).join("|"),n4=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${t4}))[ \\t]*$`,"gim");function hg(n){return n.replace(n4,(e,t,s)=>`${t}`)}const wn={code:Vj,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:e4,h1({children:n}){return r.jsx("h1",{className:"text-xl font-semibold mt-6 mb-3 pb-2 border-b border-border/40 text-foreground first:mt-0",children:n})},h2({children:n}){return r.jsx("h2",{className:"text-lg font-semibold mt-5 mb-2 pb-1.5 border-b border-border/30 text-foreground first:mt-0",children:n})},h3({children:n}){return r.jsx("h3",{className:"text-base font-semibold mt-4 mb-2 text-foreground first:mt-0",children:n})},h4({children:n}){return r.jsx("h4",{className:"text-sm font-semibold mt-3 mb-1.5 text-foreground first:mt-0",children:n})},h5({children:n}){return r.jsx("h5",{className:"text-sm font-medium mt-3 mb-1 text-foreground first:mt-0",children:n})},h6({children:n}){return r.jsx("h6",{className:"text-xs font-medium mt-3 mb-1 text-muted-foreground first:mt-0",children:n})},p({children:n}){return r.jsx("p",{className:"my-1.5 leading-[1.55] text-foreground/90 first:mt-0 last:mb-0 md:my-2 md:leading-relaxed",children:n})},blockquote({children:n}){return r.jsx("blockquote",{className:"my-2 rounded-r-md border-l-2 border-border bg-muted/30 py-1.5 pl-3 pr-2.5 text-foreground/80 [&>p]:my-1 md:my-3 md:py-2 md:pl-4 md:pr-3",children:n})},ul({children:n}){return r.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},ol({children:n}){return r.jsx("ol",{className:"my-1.5 flex list-decimal flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},li({children:n}){return r.jsx("li",{className:"pl-1 leading-[1.55] text-foreground/90 md:leading-relaxed",children:n})},hr(){return r.jsx(Et,{className:"my-4"})},table({children:n}){return r.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border/40",children:r.jsx(q5,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(G5,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(Y5,{children:n})},tr({children:n}){return r.jsx(X5,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(J5,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(Z5,{className:"px-3 py-2 text-foreground/90",children:n})},strong({children:n}){return r.jsx("strong",{className:"font-semibold text-foreground",children:n})},em({children:n}){return r.jsx("em",{className:"italic text-foreground/90",children:n})},del({children:n}){return r.jsx("del",{className:"line-through text-muted-foreground",children:n})},img:pg,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Ss=[yi],s4=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],o4=s4.join("|");function gg(){return new RegExp(`<(${o4})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function Sc(n){return n.replace(gg(),"").trim()}function r4(n){return gg().test(n)}const i4=/<command-message>([^<]+)<\/command-message>/,a4=/<command-name>([\s\S]*?)<\/command-name>/,l4=/<command-args>([\s\S]*?)<\/command-args>/;function xg(n){const e=n.match(i4);if(e)return e[1];const t=n.match(a4);return t?t[1].trim().replace(/^\//,""):null}function vg(n){const e=n.match(l4);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const bg={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},c4=new RegExp(`<(${Object.keys(bg).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function d4(n){const e=[],t=n.replace(c4,(s,o,i)=>(e.push({text:vh(i).trim(),stream:bg[o]}),"")).trim();return{outputs:e,remainingText:t}}const u4=/<task-notification>([\s\S]*?)<\/task-notification>/g;function _s(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function yg(n){const e=[],t=n.replace(u4,(s,o)=>(e.push({taskId:_s(o,"task-id"),toolUseId:_s(o,"tool-use-id"),outputFile:_s(o,"output-file"),status:_s(o,"status"),summary:_s(o,"summary"),result:_s(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const f4=/\[Request interrupted by user[^\]]*\]/g;function wg(n){const e=[],t=n.replace(f4,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const Ku="[SYSTEM NOTIFICATION - NOT USER INPUT]";function jg(n){const e=n.indexOf(Ku);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+Ku.length,s=n.indexOf(`
|
|
76
|
+
|
|
77
|
+
`,t),o=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(o)).trim(),isSystemNotification:!0}}function m4(n){const e=F.c(15),{output:t}=n,s=t.stream==="stderr",o=t.stream==="input",i=s&&"border-destructive/20 bg-destructive/5 text-destructive",a=o&&"border-border bg-muted/50 text-foreground",l=!s&&!o&&"border-border bg-muted/40 text-muted-foreground";let c;e[0]!==i||e[1]!==a||e[2]!==l?(c=G("rounded-md border px-3 py-2 my-1 font-mono text-xs",i,a,l),e[0]=i,e[1]=a,e[2]=l,e[3]=c):c=e[3];let d;e[4]!==s||e[5]!==o?(d=o?r.jsx(et,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Hs,{className:G("size-3 shrink-0",s?"text-destructive":"text-muted-foreground"),"data-icon":"inline-start"}),e[4]=s,e[5]=o,e[6]=d):d=e[6];let f;e[7]!==t.text?(f=r.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.text}),e[7]=t.text,e[8]=f):f=e[8];let u;e[9]!==d||e[10]!==f?(u=r.jsxs("div",{className:"flex items-center gap-1.5",children:[d,f]}),e[9]=d,e[10]=f,e[11]=u):u=e[11];let m;return e[12]!==c||e[13]!==u?(m=r.jsx("div",{className:c,children:u}),e[12]=c,e[13]=u,e[14]=m):m=e[14],m}const Vu={Icon:Qw,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},qu={completed:{Icon:Zw,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...Vu,label:"Failed"},error:{...Vu,label:"Error"},running:{Icon:ej,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function p4(n){const e=F.c(32),{notification:t}=n,[s,o]=b.useState(!1),i=qu[t.status]??qu.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?nt:et;let d;e[0]!==i.bg?(d=G("my-1 rounded-lg border p-3",i.bg),e[0]=i.bg,e[1]=d):d=e[1];let f;e[2]!==i.color?(f=G("mt-0.5 size-4 shrink-0",i.color),e[2]=i.color,e[3]=f):f=e[3];let u;e[4]!==a||e[5]!==f?(u=r.jsx(a,{className:f}),e[4]=a,e[5]=f,e[6]=u):u=e[6];let m;e[7]!==t.summary?(m=r.jsx("span",{className:"text-sm font-medium text-foreground",children:t.summary}),e[7]=t.summary,e[8]=m):m=e[8];let p;e[9]!==i.badgeVariant||e[10]!==i.color||e[11]!==i.label?(p=r.jsx(Oe,{variant:i.badgeVariant,className:i.color,children:i.label}),e[9]=i.badgeVariant,e[10]=i.color,e[11]=i.label,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==c||e[17]!==s||e[18]!==l||e[19]!==t.outputFile||e[20]!==t.result?(g=l&&r.jsxs(r.Fragment,{children:[r.jsxs(dn,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"mt-1.5 -ml-2 text-muted-foreground"}),children:[r.jsx(c,{"data-icon":"inline-start"}),s?"Hide detail":"Show detail"]}),r.jsx(jt,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(yn,{components:wn,remarkPlugins:Ss,children:t.result}),t.outputFile&&r.jsxs("div",{className:"mt-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Output file"}),r.jsx("div",{className:"mt-1 select-all break-all rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground",children:t.outputFile})]})]})})]}),e[16]=c,e[17]=s,e[18]=l,e[19]=t.outputFile,e[20]=t.result,e[21]=g):g=e[21];let v;e[22]!==h||e[23]!==g?(v=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,g]}),e[22]=h,e[23]=g,e[24]=v):v=e[24];let x;e[25]!==u||e[26]!==v?(x=r.jsxs("div",{className:"flex items-start gap-2",children:[u,v]}),e[25]=u,e[26]=v,e[27]=x):x=e[27];let w;return e[28]!==s||e[29]!==d||e[30]!==x?(w=r.jsx(wt,{open:s,onOpenChange:o,className:d,children:x}),e[28]=s,e[29]=d,e[30]=x,e[31]=w):w=e[31],w}function h4(n){const e=F.c(6),{loading:t,content:s}=n;let o;if(t){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground/60 font-mono",children:[r.jsx(bh,{className:"w-3 h-3 text-muted-foreground/60"})," Loading..."]}),e[0]=a):a=e[0],o=a}else if(s){let a;e[1]!==s?(a=r.jsx(yn,{components:wn,remarkPlugins:Ss,children:s}),e[1]=s,e[2]=a):a=e[2],o=a}else{let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-muted-foreground/60 font-mono",children:"Could not load command content"}),e[3]=a):a=e[3],o=a}let i;return e[4]!==o?(i=r.jsx("div",{className:"mt-2 max-h-80 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=i):i=e[5],i}const Nc=b.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=fg(),[l,c]=b.useState(!1),[d,f]=b.useState(!1),[u,m]=b.useState(!1),[p,h]=b.useState(null),[g,v]=b.useState(!1),[x,w]=b.useState(null),y=b.useMemo(()=>Li(e),[e]),j=b.useMemo(()=>xg(y),[y]),N=b.useMemo(()=>vg(y),[y]),{sender:S,body:k,matched:C}=b.useMemo(()=>Mo(y),[y]),T=b.useMemo(()=>Sc(k),[k]),{text:_,isSystemNotification:P}=b.useMemo(()=>jg(T),[T]),{notifications:A,remainingText:E}=b.useMemo(()=>yg(_),[_]),{outputs:M,remainingText:I}=b.useMemo(()=>d4(E),[E]),{interrupts:R,remainingText:D}=b.useMemo(()=>wg(I),[I]),L=b.useCallback(async q=>{if(!q){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!j)){v(!0),m(!0);try{const Y=await o(j,N??void 0);h(Y)}finally{v(!1)}}},[p,o,j,N]),$=b.useMemo(()=>dg(e),[e]),z=b.useMemo(()=>$.map(q=>`data:${q.source.media_type};base64,${q.source.data}`),[$]),U=b.useMemo(()=>z.map((q,Y)=>({id:`message-attachment-${Y}`,src:q,alt:`Attachment ${Y+1}`,label:z.length>1?`Attachment ${Y+1}`:"Attached image"})),[z]),O=b.useMemo(()=>r4(y)||P||C,[y,P,C]),H=d?y:D,W=H.length>500&&!l?H.slice(0,500)+"...":H,V=q=>{const Y=U[q];Y&&(a?a.openImage(Y):w({index:q,open:!0}))};return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:O&&r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>f(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(hi,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(Js,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&P&&r.jsx("div",{className:"mb-2",children:r.jsxs(Oe,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(Hs,{"data-icon":"inline-start"}),"System event"]})}),!d&&C&&r.jsx("div",{className:"mb-2",children:r.jsxs(Oe,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(Tn,{"data-icon":"inline-start"}),S?`From ${S}`:"Teammate message"]})}),j&&r.jsxs(wt,{open:u,onOpenChange:q=>void L(q),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Oe,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(Hs,{"data-icon":"inline-start"}),"/",j,N&&r.jsx("span",{className:"text-muted-foreground",children:N})]}),o&&r.jsxs(dn,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[u?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(et,{"data-icon":"inline-start"}),u?"Collapse":"Expand"]}),u&&s&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(j),className:"text-muted-foreground",children:[r.jsx(ws,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(jt,{children:r.jsx(h4,{loading:g,content:p})})]}),z.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:z.map((q,Y)=>r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>V(Y),"aria-label":`Open attached image ${Y+1}`,className:G("group/image relative h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 text-left","transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"),children:[r.jsx("img",{src:q,alt:`Attachment ${Y+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(pi,{className:"size-3.5","data-icon":"icon"})}),z.length>1&&r.jsxs("span",{className:"absolute bottom-2 right-2 rounded-md bg-black/55 px-1.5 py-0.5 font-mono text-xs text-white/80",children:[Y+1," / ",z.length]})]},`${$[Y].source.media_type}-${$[Y].source.data.slice(0,24)}-${Y}`))}),!d&&A.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:A.map(q=>r.jsx(p4,{notification:q},q.taskId))}),!d&&M.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:M.map((q,Y)=>r.jsx(m4,{output:q},Y))}),!d&&R.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((q,Y)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(R2,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:q})]},Y))}),W&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(yn,{components:wn,remarkPlugins:Ss,children:W})}),H.length>500&&r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>c(!l),className:"mt-1 -ml-2 text-muted-foreground",children:l?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(et,{"data-icon":"inline-start"})," Show more"]})}),!i&&t&&r.jsx("div",{className:"flex items-center mt-1.5 ml-auto",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t).toLocaleTimeString()})})]}),x!==null&&r.jsx(bc,{open:x.open,images:U,initialIndex:x.index,onClose:()=>w(q=>q?{...q,open:!1}:null),onCloseComplete:()=>w(null)},x.index)]})}),Sg=b.memo(function(e){const t=F.c(10),{message:s,turnNumber:o}=e;let i;t[0]!==o?(i=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Turn ",o]}),t[0]=o,t[1]=i):i=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Oe,{variant:"outline",children:"Queued"}),t[2]=a):a=t[2];let l;t[3]!==i?(l=r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[i,a]}),t[3]=i,t[4]=l):l=t[4];let c;t[5]!==s?(c=r.jsx("div",{className:"rounded-lg border border-dashed bg-prompt-surface p-3",children:r.jsx(Nc,{content:s,timestamp:""})}),t[5]=s,t[6]=c):c=t[6];let d;return t[7]!==l||t[8]!==c?(d=r.jsxs("div",{className:"motion-enter group relative px-4 py-5",children:[l,c]}),t[7]=l,t[8]=c,t[9]=d):d=t[9],d}),Ng=b.memo(function(e){const t=F.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=b.useState(!1),c=o??a,{todos:d,completed:f,total:u}=s,m=u>0?f/u*100:0;let p;t[0]!==i?(p=_=>{i==null||i(_),l(_)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(X,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-none px-3 py-2"}),t[2]=h):h=t[2];let g;t[3]!==c?(g=c?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Bo,{"data-icon":"inline-start"}),t[3]=c,t[4]=g):g=t[4];let v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"text-sm font-medium",children:"Tasks"}),t[5]=v):v=t[5];let x;t[6]!==f||t[7]!==u?(x=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[f,"/",u]}),t[6]=f,t[7]=u,t[8]=x):x=t[8];let w;t[9]!==m?(w=m.toFixed(0),t[9]=m,t[10]=w):w=t[10];const y=`${w}% of tasks complete`;let j;t[11]!==m||t[12]!==y?(j=r.jsx(tc,{value:m,className:"max-w-[200px] flex-1","aria-label":y}),t[11]=m,t[12]=y,t[13]=j):j=t[13];let N;t[14]!==s.inProgress?(N=s.inProgress&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[r.jsx(lt,{className:"size-3 shrink-0 animate-spin"}),r.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=N):N=t[15];let S;t[16]!==g||t[17]!==x||t[18]!==j||t[19]!==N?(S=r.jsxs(dn,{render:h,children:[g,v,x,j,N]}),t[16]=g,t[17]=x,t[18]=j,t[19]=N,t[20]=S):S=t[20];let k;t[21]!==d?(k=d.map(g4),t[21]=d,t[22]=k):k=t[22];let C;t[23]!==k?(C=r.jsx(jt,{children:r.jsx("div",{className:"px-3 pb-3 pt-1",children:r.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:k})})}),t[23]=k,t[24]=C):C=t[24];let T;return t[25]!==c||t[26]!==p||t[27]!==S||t[28]!==C?(T=r.jsxs(wt,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[S,C]}),t[25]=c,t[26]=p,t[27]=S,t[28]=C,t[29]=T):T=t[29],T});function g4(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(_n,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?r.jsx(lt,{className:"size-3 shrink-0 animate-spin text-info"}):r.jsx(Xm,{className:"size-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:G("truncate text-xs",n.status==="in_progress"?"text-foreground":"text-muted-foreground",n.status==="completed"&&"line-through"),children:n.content}),n.owner&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:n.owner})]},n.id??e)}function zi(n,e){const t=F.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const d=localStorage.getItem(n);return d===null?e:JSON.parse(d)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[o,i]=b.useState(s);let a;t[3]!==n?(a=d=>{i(f=>{const u=typeof d=="function"?d(f):d;try{localStorage.setItem(n,JSON.stringify(u))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return u})},t[3]=n,t[4]=a):a=t[4];const l=a;let c;return t[5]!==l||t[6]!==o?(c=[o,l],t[5]=l,t[6]=o,t[7]=c):c=t[7],c}function kg(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function x4(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const v4="cogpit:provider-update-dismissals:v1";function b4(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(kg(t)))}async function y4(n){const e=await ye("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function w4(n){const e=await ye("/api/provider-updates/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n})}),t=await e.json();if(!t.status)throw new Error(t.error??`Update failed (${e.status})`);return t}const j4=360*60*1e3;function S4(){const[n,e]=b.useState([]),[t,s]=zi(v4,[]),[o,i]=b.useState(null),[a,l]=b.useState(null);b.useEffect(()=>{const f=new AbortController,u=()=>{y4(f.signal).then(e).catch(()=>{})};u();const m=setInterval(u,j4);return()=>{f.abort(),clearInterval(m)}},[]);const c=b.useCallback(async f=>{i(f),l(null);try{const u=await w4(f);l(u),e(m=>m.map(p=>p.provider===f?u.info:p))}catch(u){l({provider:f,status:"failed",message:u instanceof Error?u.message:"Update failed.",output:null})}finally{i(null)}},[]),d=b.useCallback(f=>{s(u=>x4(u,kg(f)))},[s]);return{pending:b4(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:b.useCallback(()=>l(null),[])}}const N4=5e3,k4={warning:"border-warning/30 bg-warning/10 text-warning",destructive:"border-destructive/30 bg-destructive/10 text-destructive",success:"border-success/30 bg-success/10 text-success"};function ja(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${k4[n]}`}function Gu(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function Cg(){const n=F.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=S4(),l=at("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,f;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const E=setTimeout(a,N4);return()=>clearTimeout(E)},f=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=f):(d=n[2],f=n[3]),b.useEffect(d,f),s){let E;return n[4]!==a||n[5]!==s.message||n[6]!==c?(E=c?r.jsxs(vt,{className:ja("success"),children:[r.jsx(ui,{}),r.jsx(At,{children:s.message}),r.jsx(bt,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(vt,{className:ja("destructive"),children:[r.jsx(js,{}),r.jsx(At,{children:"Update did not complete"}),r.jsx(bt,{className:"text-destructive/80",children:s.message}),r.jsx(ns,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(X,{variant:"ghost",size:"xs",onClick:a,children:"Dismiss"})})]}),n[4]=a,n[5]=s.message,n[6]=c,n[7]=E):E=n[7],E}if(e.length===0)return null;const u=e[0],m=e.filter(E=>E.updateCommand!==null&&l),p=vt;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=ja("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(lt,{className:"animate-spin"}):r.jsx(fn,{}),n[9]=t,n[10]=g):g=n[10];let v;n[11]!==u||n[12]!==e?(v=e.length===1?Gu(u):`${e.map(C4).join(" and ")} are out of date`,n[11]=u,n[12]=e,n[13]=v):v=n[13];let x;n[14]!==v?(x=r.jsx(At,{children:v}),n[14]=v,n[15]=x):x=n[15];const w=e.length>1?e.map(Gu).join(" · "):m.length===1?`Cogpit can run \`${u.updateCommand}\` for you.`:u.updateCommand?`Run \`${u.updateCommand}\` to upgrade.`:"Update it with whatever installed it — Cogpit could not tell.";let y;n[16]!==w?(y=r.jsx(bt,{className:"text-warning/80",children:w}),n[16]=w,n[17]=y):y=n[17];const j=ns,N="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let S;n[18]!==e.length||n[19]!==o||n[20]!==t?(S=E=>r.jsxs(X,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(E.provider),children:[r.jsx(Xa,{"data-icon":"inline-start"}),t===E.provider?"Updating…":e.length===1?"Update":`Update ${E.displayName}`]},E.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=S):S=n[21];const k=m.map(S),C=t!==null;let T;n[22]!==i||n[23]!==e?(T=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=T):T=n[24];let _;n[25]!==C||n[26]!==T?(_=r.jsx(X,{variant:"ghost",size:"xs",disabled:C,onClick:T,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=C,n[26]=T,n[27]=_):_=n[27];let P;n[28]!==j||n[29]!==k||n[30]!==_?(P=r.jsxs(j,{className:N,children:[k,_]}),n[28]=j,n[29]=k,n[30]=_,n[31]=P):P=n[31];let A;return n[32]!==p||n[33]!==P||n[34]!==h||n[35]!==g||n[36]!==x||n[37]!==y?(A=r.jsxs(p,{className:h,children:[g,x,y,P]}),n[32]=p,n[33]=P,n[34]=h,n[35]=g,n[36]=x,n[37]=y,n[38]=A):A=n[38],A}function C4(n){return n.displayName}function _g(){const n=F.c(27),[e,t]=b.useState(null),[s,o]=b.useState(null),[i,a]=b.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const d=window.electronUpdater;d&&(d.onUpdateAvailable(f=>{t(f)}),d.onUpdateDownloaded(f=>{o(f)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),b.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Xa,{}),n[2]=d):d=n[2];let f;n[3]!==s.version?(f=r.jsxs(At,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=f):f=n[4];let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(bt,{className:"text-success/80",children:"Restart to apply the update."}),n[5]=u):u=n[5];let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>a(!0),n[6]=m):m=n[6];let p;n[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(ns,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:r.jsx(xt,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==f?(h=r.jsxs(vt,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-success/30 bg-success/10 px-4 py-2 pr-4 text-success has-data-[slot=alert-action]:pr-4",children:[d,f,u,p]}),n[8]=f,n[9]=h):h=n[9],h}if(e&&!i){let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Xa,{}),n[10]=d):d=n[10];let f;n[11]!==e.version?(f=r.jsxs(At,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=f):f=n[12];let u;n[13]!==e.platform?(u=e.platform!=="mac"&&r.jsx(bt,{children:"Update through your package manager."}),n[13]=e.platform,n[14]=u):u=n[14];let m;n[15]!==e.platform||n[16]!==e.url?(m=e.platform==="mac"&&r.jsxs(X,{variant:"outline",size:"xs",render:r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[r.jsx(I2,{"data-icon":"inline-start"}),"Download"]}),n[15]=e.platform,n[16]=e.url,n[17]=m):m=n[17];let p;n[18]!==e.version?(p=r.jsx(X,{variant:"ghost",size:"xs",onClick:()=>{var v;a(!0),(v=window.electronUpdater)==null||v.dismissVersion(e.version)},className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[18]=e.version,n[19]=p):p=n[19];let h;n[20]!==m||n[21]!==p?(h=r.jsxs(ns,{className:"static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center",children:[m,p]}),n[20]=m,n[21]=p,n[22]=h):h=n[22];let g;return n[23]!==f||n[24]!==u||n[25]!==h?(g=r.jsxs(vt,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-info/30 bg-info/10 px-4 py-2 pr-4 text-info has-data-[slot=alert-action]:pr-4",children:[d,f,u,h]}),n[23]=f,n[24]=u,n[25]=h,n[26]=g):g=n[26],g}return null}const Tg=b.createContext(null);function Lr(n){const e=F.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(Tg.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Ct(){const n=b.useContext(Tg);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const Ro=null,{min:hs,max:en,abs:Yu,floor:_4}=Math,Eg=(n,e,t)=>hs(t,en(e,n)),Pg=n=>[...n].sort((e,t)=>e-t),Ag=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},ul=()=>{let n;return[new Promise(e=>{n=e}),n]},Mg=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},yo=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},Rg=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},T4=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=hs(e,n.i),s},zr=(n,e)=>{if(!n.l)return 0;if(n.i>=e)return n.u[e];n.i<0&&(n.u[0]=0,n.i=0);let t=n.i,s=n.u[t];for(;t<e;)s+=Rg(n,t),n.u[++t]=s;return n.i=e,s},Ts=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=_4((t+s)/2);zr(n,i)<=e?(o=i,t=i+1):s=i-1}return Eg(o,0,n.l-1)},Xu=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:hs(e-1,n.i),n.l=e,s>0?(yo(n.u,s),yo(n.t,s,t),n.o*s):(n.u.splice(s),(t?n.t.splice(0,-s):n.t.splice(s)).reduce((o,i)=>o-(i===-1?n.o:i),0))},E4=typeof window<"u",P4=n=>n.documentElement,A4=n=>n.ownerDocument,M4=n=>n.defaultView,Ig=Mg(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),R4=Mg(()=>"scrollBehavior"in P4(document).style),I4=n=>en(n.h(),n.p()),$4=(n,e=40,t=0,s,o=!1)=>{let i=!!t,a=1,l=0,c=0,d=0,f=0,u=0,m=0,p=0,h=0,g=Ro,v=[0,i?en(t-1,0):-1],x=0,w=!1;const y=((E,M,I)=>({o:M,t:I?yo(I.slice(0,hs(E,I.length)),en(0,E-I.length)):yo([],E),l:E,i:-1,u:yo([],E+1)}))(n,s?s[1]:e,s&&s[0]),j=new Set,N=()=>d-c,S=()=>N()+u+f,k=(E,M)=>((I,R,D,L)=>{if(L=hs(L,I.l-1),zr(I,L)<=R){const $=Ts(I,D,L);return[Ts(I,R,L,$),$]}{const $=Ts(I,R,void 0,L);return[$,Ts(I,D,$)]}})(y,E,M,v[0]),C=()=>zr(y,y.l),T=(E,M)=>{const I=zr(y,E)-u;return M?C()-I-_(E):I},_=E=>Rg(y,E),P=(E,M=-1)=>y.t[E]===M,A=E=>{E&&(Ig()&&p!==0||g&&h===1?u+=E:f+=E)};return{v:()=>{j.clear()},m:()=>a,_:()=>(E=>[E.t.slice(),E.o])(y),S:(E=200)=>{if(!w||i)return v;let M,I;if(m)[M,I]=v;else{let R=en(0,S()),D=R+l;o||(E=en(0,E),p!==1&&(R-=E),p!==2&&(D+=E)),[M,I]=v=k(en(0,R),en(0,D)),g&&(M=hs(M,g[0]),I=en(I,g[1]))}return[en(M,0),hs(I,y.l-1)]},$:E=>Ts(y,E-c),I:P,k:T,R:_,T:()=>y.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:C,H:()=>(m=f,f=0,[m,h===2]),W:(E,M)=>{const I=[E,M];return j.add(I),()=>{j.delete(I)}},B:(E,M)=>{let I,R,D=0;switch(E){case 1:{if(M===d&&h===0)break;const L=m;m=0;const $=M-d,z=Yu($);L&&z<Yu(L)+1||h!==0||(p=$<0?2:1),i&&(i=!1),d=M,D=4;const U=N();U>=-l&&U<=C()&&(D+=1,R=z>l);break}case 2:D=8,p!==0&&(I=!0,D+=1),p=0,h=0,g=Ro;break;case 3:{const L=M.filter(([$,z])=>!P($,z));if(!L.length)break;A(L.reduce(($,[z,U])=>{let O;if(h===2)O=!0;else if(g&&h===1)O=z<g[0];else{const H=N(),B=T(z),W=_(z);O=p!==1&&h===0?B+W<=H:B<H&&B+W<H+l}return O&&($+=U-_(z)),$},0));for(const[$,z]of L){const U=_($),O=T4(y,$,z);o&&(x+=O?z:z-U)}o&&l&&x>l&&(A((($,z)=>{let U=0;const O=[];$.t.forEach((Y,K)=>{Y!==-1&&(O.push(Y),K<z&&U++)}),$.i=-1;const H=Pg(O),B=H.length,W=B/2|0,V=B%2==0?(H[W-1]+H[W])/2:H[W],q=$.o;return(($.o=V)-q)*en(z-U,0)})(y,Ts(y,S()))),o=!1),D=3,R=!0;break}case 4:l!==M&&(l||(w=R=!0),l=M,D=3);break;case 5:M[1]?(A(Xu(y,M[0],!0)),h=2,D=1):(Xu(y,M[0]),D=1);break;case 6:c=M;break;case 7:h=1;break;case 8:g=k(M,M+l),D=1}D&&(a=1+(2147483647&a),I&&u&&(f+=u,u=0),j.forEach(([L,$])=>{D&L&&$(R)}))}}},kc=setTimeout,Sa=(n,e)=>e?-n:n,O4=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,f=!1,u=!1;const m=(()=>{let x;const w=()=>{x!=Ro&&clearTimeout(x)},y=()=>{w(),x=kc(()=>{x=Ro,(()=>{if(c||d)return c=!1,void m();f=!1,n.B(2)})()},150)};return y.J=w,y})(),p=()=>{l=a(),f&&(u=!0),n.B(1,s()),m()},h=x=>{if(c||!n.M()||x.ctrlKey)return;const w=a()-l;150>w&&50<w&&(t?x.deltaX:x.deltaY)&&(c=!0)},g=()=>{d=!0,f=u=!1},v=()=>{d=!1,Ig()&&(f=!0)};return e.addEventListener("scroll",p),e.addEventListener("wheel",h,{passive:!0}),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("touchend",v,{passive:!0}),{A:()=>{e.removeEventListener("scroll",p),e.removeEventListener("wheel",h),e.removeEventListener("touchstart",g),e.removeEventListener("touchend",v),m.J()},L:()=>{const[x,w]=n.H();x&&(o(x,w,u),u=!1,w&&n.p()>n.h()&&n.B(1,s()))}}},D4=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=ul();return s=()=>{c(!1)},n.p()&&kc(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&R4())n.B(8,o()),Ag(async()=>{for(;;){let l=!0;for(let[f,u]=n.S();f<=u;f++)if(n.I(f)){l=!1;break}if(l)break;const[c,d]=a();try{if(!await c)return}finally{d()}}n.B(7),t(o(),i)});else for(;;){const[l,c]=a();try{if(n.B(7),t(o()),!await l)return}finally{c()}}},()=>{s&&s()}]},L4=(n,e)=>{let t,s,o=ul(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=D4(n,()=>o[0],(f,u)=>{f=Sa(f,i),u?t.scrollTo({[e?"left":"top"]:f,behavior:"smooth"}):t[a]=f});return{N(f,u){t=u,e&&(i=getComputedStyle(u).direction==="rtl"),s=O4(n,u,e,()=>Sa(u[a],i),(m,p,h)=>{if(h){const g=u.style,v=g[l];g[l]="hidden",kc(()=>{g[l]=v})}u[a]=Sa(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=ul()},P:()=>i,V(f){c(()=>f)},X(f){f+=n.C(),c(()=>f)},Y(f,{align:u,smooth:m,offset:p=0}={}){if(f=Eg(f,0,n.T()-1),u==="nearest"){const h=n.k(f),g=n.C();if(h<g)u="start";else{if(!(h+n.R(f)>g+n.p()))return;u="end"}}c(()=>p+n.O()+n.k(f)+(u==="end"?n.R(f)-n.p():u==="center"?(n.R(f)-n.p())/2:0),m)},q:()=>{s&&s.L()}}},z4=n=>{let e;return{j(t){(e||(e=new(M4(A4(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},F4=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=z4(a=>{const l=[];for(const{target:c,contentRect:d}of a)if(c.offsetParent)if(c===t)n.B(4,d[s]);else{const f=o.get(c);f!=Ro&&l.push([f,d[s]])}l.length&&n.B(3,l)});return{G(a){i.j(t=a)},U:(a,l)=>(o.set(a,l),i.j(a),()=>{o.delete(a),i.D(a)}),v:i.A}},qr=E4?b.useLayoutEffect:b.useEffect,Ft="current",$g=(n,e)=>{if(Array.isArray(n))for(const t of n)$g(t,e);else n==null||typeof n=="boolean"||e.push(n)},B4=(n,e)=>{const t=n.key;return t??"_"+e},U4=n=>{const e=b.useRef(null);return e[Ft]||(e[Ft]=n())},Ju=n=>{const e=b.useRef(n);return qr(()=>{e[Ft]=n},[n]),e},W4=b.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=b.useRef(null);qr(()=>e(c[Ft],t),[t]);const d=b.useMemo(()=>{const f={contain:"layout style",position:o&&l?void 0:"absolute",[a?"height":"width"]:"100%",[a?"top":"left"]:0,[a?"left":"top"]:s,visibility:!o||l?void 0:"hidden"};return a&&(f.display="inline-flex"),f},[s,o,l,a]);return r.jsx(i,typeof i=="string"?{ref:c,style:d,children:n}:{ref:c,style:d,index:t,children:n})}),H4=(n,e)=>b.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return $g(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),K4=b.forwardRef(({children:n,data:e,bufferSize:t,itemSize:s,shift:o,horizontal:i,keepMounted:a,cache:l,startMargin:c=0,ssrCount:d,as:f="div",item:u="div",scrollRef:m,onScroll:p,onScrollEnd:h},g)=>{const[v,x]=H4(n,e),w=b.useRef(null),y=b.useRef(!!d),j=Ju(p),N=Ju(h),[S,k,C,T]=U4(()=>{const D=!!i,L=$4(x,s,d,l,!s);return[L,F4(L,D),L4(L,D),D]});x!==S.T()&&S.B(5,[x,o]),c!==S.O()&&S.B(6,c);const[_,P]=b.useReducer(S.m,void 0,S.m),A=S.M(),E=S.h(),M=C.P(),I=[],R=D=>{const L=v(D);return r.jsx(W4,{ee:k.U,te:D,oe:S.k(D,M),ne:S.I(D),re:u,Z:L,se:T,ie:y[Ft]},B4(L,D))};if(qr(()=>{y[Ft]=!1,S.W(1,$=>{$?j0.flushSync(P):P()}),S.W(4,()=>{j[Ft]&&j[Ft](S.C())}),S.W(8,()=>{N[Ft]&&N[Ft]()});const D=w[Ft],L=$=>{k.G($),C.N(D,$)};return m?Ag(()=>{m[Ft]&&L(m[Ft])}):L(D.parentElement),()=>{S.v(),k.v(),C.v()}},[]),qr(()=>{C.q()},[_]),b.useImperativeHandle(g,()=>({get cache(){return S._()},get scrollOffset(){return S.C()},get scrollSize(){return I4(S)},get viewportSize(){return S.p()},findItemIndex:S.$,getItemOffset:S.k,getItemSize:S.R,scrollToIndex:C.Y,scrollTo:C.V,scrollBy:C.X}),[]),a){const D=new Set(a);for(let[L,$]=S.S(t);L<=$;L++)D.add(L);Pg([...D]).forEach(L=>{I.push(R(L))})}else for(let[D,L]=S.S(t);D<=L;D++)I.push(R(D));return r.jsx(f,{ref:w,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:T?E:"100%",height:T?"100%":E,pointerEvents:A?"none":void 0},children:I})});function Fi(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(O2,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Bi(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("select-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx($2,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ui(n){const e=F.c(18);let t,s,o,i,a,l;e[0]!==n?({className:t,align:o,alignOffset:i,side:a,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?4:i,f=a===void 0?"right":a,u=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(Lm,{"data-slot":"context-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==u||e[16]!==p?(h=r.jsx(Fm,{children:r.jsx(Bm,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:f,sideOffset:u,children:p})}),e[12]=c,e[13]=d,e[14]=f,e[15]=u,e[16]=p,e[17]=h):h=e[17],h}function Ws(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Dm,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function PA(n){const e=F.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(zm,{"data-slot":"context-menu-label","data-inset":s,className:i,...o}),e[6]=s,e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function Bt(n){const e=F.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=G("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l||e[10]!==a?(c=r.jsx(Om,{"data-slot":"context-menu-item","data-inset":s,"data-variant":a,className:l,...o}),e[7]=s,e[8]=o,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function Io(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(El,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function V4(n){const e=F.c(22),{children:t,turnIndex:s,branches:o,onRestoreToHere:i,onOpenBranches:a,onBranchFromHere:l}=n;let c;e[0]!==t?(c=r.jsx(Bi,{children:t}),e[0]=t,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==s?(d=()=>i(s),e[2]=i,e[3]=s,e[4]=d):d=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(zl,{"data-icon":"inline-start"}),e[5]=f):f=e[5];let u;e[6]!==d?(u=r.jsx(Ws,{children:r.jsxs(Bt,{onClick:d,children:[f,"Restore to this point"]})}),e[6]=d,e[7]=u):u=e[7];let m;e[8]!==o.length||e[9]!==a||e[10]!==s?(m=o.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Io,{}),r.jsx(Ws,{children:r.jsxs(Bt,{onClick:()=>a(s),children:[r.jsx(Ll,{"data-icon":"inline-start"}),"View branches (",o.length,")"]})})]}),e[8]=o.length,e[9]=a,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&r.jsxs(r.Fragment,{children:[r.jsx(Io,{}),r.jsx(Ws,{children:r.jsxs(Bt,{onClick:()=>l(s),children:[r.jsx(bn,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==u||e[16]!==m||e[17]!==p?(h=r.jsxs(Ui,{className:"min-w-44",children:[u,m,p]}),e[15]=u,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=r.jsxs(Fi,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function q4(n){const e=F.c(15),{redoTurnCount:t,onRedoAll:s}=n;if(t<=0)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(zl,{className:"size-4","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsx("span",{className:"font-mono",children:t}),e[1]=t,e[2]=i):i=e[2];const a=t!==1?"s":"";let l;e[3]!==a?(l=r.jsxs("span",{children:["turn",a," archived"]}),e[3]=a,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==l?(c=r.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[o,i,l]}),e[5]=i,e[6]=l,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Et,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(D2,{"data-icon":"inline-start"}),e[9]=f):f=e[9];let u;e[10]!==s?(u=r.jsxs(X,{variant:"default",size:"sm",onClick:s,children:[f,"Redo all"]}),e[10]=s,e[11]=u):u=e[11];let m;return e[12]!==c||e[13]!==u?(m=r.jsxs("div",{className:"sticky bottom-0 flex items-center justify-center gap-3 border-t border-border bg-background/95 px-4 py-2",role:"status",children:[c,d,u]}),e[12]=c,e[13]=u,e[14]=m):m=e[14],m}const Zu=new Map;function G4(n){let e=Zu.get(n);if(!e){const t=new Map;e={observer:new IntersectionObserver(o=>{var i;for(const a of o)(i=t.get(a.target))==null||i(a.isIntersecting)},{rootMargin:n}),callbacks:t},Zu.set(n,e)}return e}function Og(n){const e=F.c(5),t="100%",s=b.useRef(null),[o,i]=b.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:f,callbacks:u}=G4(t);return u.set(d,i),f.observe(d),()=>{f.unobserve(d),u.delete(d)}},l=[t],e[0]=t,e[1]=a,e[2]=l):(a=e[1],l=e[2]),b.useEffect(a,l);let c;return e[3]!==o?(c={ref:s,isNear:o},e[3]=o,e[4]=c):c=e[4],c}function Gr(n){if(typeof n!="string"||n.length===0)return Number.NEGATIVE_INFINITY;const e=Date.parse(n);return Number.isFinite(e)?e:Number.NEGATIVE_INFINITY}function Qu(n){const e=Gr(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Gr(n.lastModified)}function ef(n,e){return n===e?0:e-n}function tf(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function Y4(n,e){const t=ef(Qu(n),Qu(e));if(t!==0)return t;const s=ef(Gr(n.lastModified),Gr(e.lastModified));return s!==0?s:tf(n).localeCompare(tf(e))}function Cc(n){return[...n].sort(Y4)}function Dg(n,e){const t=!!(n.teamName&&n.agentName);return e||sn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const X4="Unknown project";function _c(n){const e=_i(n);return Ci(e?e.parentPath:n,2)||X4}function J4(n){return _c(n.cwd||rn(n.dirName))}function Z4(n){const e=Cc(n),t=new Map;for(const s of e){const o=J4(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function Lg(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function Q4(n,e,t){let s=-1;return n.forEach((o,i)=>{Lg(o,e)&&(s=i)}),Math.max(t,s+1)}const Tc=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),eN=12e4;function tN(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<eN}function zg(n,e,t=Date.now()){return Lg(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:tN(n,t)}function nN(n,e,t=Date.now()){return n.some(s=>zg(s,e,t))}const sN="cogpit:session-list-cache",oN=10080*60*1e3,rN=24,Sn={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},fl=new Map;function iN(){return{version:1,entries:{}}}function Fg(){return Mt(sN)}function Bg(){const n=Fg(),e=fl.get(n);if(e)return e;let t=iN();try{const s=localStorage.getItem(n);if(s){const o=JSON.parse(s);o.version===1&&o.entries&&typeof o.entries=="object"&&(t=o)}}catch{}return fl.set(n,t),t}function Ug(n){const e=Bg().entries[n];if(!(!e||Date.now()-e.savedAt>oN))return e.value}function Wg(n,e){const t=Fg(),o={...Bg().entries,[n]:{savedAt:Date.now(),value:e}},i=Object.entries(o).sort(([,l],[,c])=>c.savedAt-l.savedAt),a={version:1,entries:Object.fromEntries(i.slice(0,rN))};fl.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function Yr(n){const e=Ug(n);return Array.isArray(e)?e:void 0}function wo(n,e){Wg(n,e)}function Hg(n){return`sessions:${n}`}function aN(n){const e=Ug(Hg(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function lN(n,e){Wg(Hg(n),e)}const cN=2e4;function dN(n){const e=new Map;for(const t of n){if(!t.sessionId)continue;const s=e.get(t.sessionId);(!s||t.memMB>s.memMB)&&e.set(t.sessionId,t)}return e}const Kg=b.createContext(null);function uN({children:n}){const[e]=b.useState(nn),[t,s]=b.useState(()=>Yr(Sn.activeSessions)??[]),[o,i]=b.useState(()=>Yr(Sn.runningProcesses)??[]),[a,l]=b.useState(!1),[c,d]=b.useState(null),[f,u]=b.useState(new Set),m=b.useRef(null),p=b.useRef(null),h=b.useRef(!1);b.useEffect(()=>(h.current=!0,()=>{var S;h.current=!1,(S=p.current)==null||S.abort(),p.current=null}),[]);const g=b.useCallback(async()=>{var C;if(!h.current||nn()!==e)return;(C=p.current)==null||C.abort();const S=new AbortController;p.current=S;const k=()=>h.current&&!S.signal.aborted&&p.current===S&&nn()===e;l(!0);try{const[T,_]=await Promise.all([ye("/api/active-sessions",{signal:S.signal}),ye("/api/running-processes",{signal:S.signal})]);if(!k())return;if(!T.ok||!_.ok)throw new Error("Failed to fetch live data");const[P,A]=await Promise.all([T.json(),_.json()]);if(!k())return;const E=Array.isArray(P)?P:[],M=Array.isArray(A)?A:[];s(E),i(M),wo(Sn.activeSessions,E),wo(Sn.runningProcesses,M),d(null)}catch(T){if(!k())return;d(T instanceof Error?T.message:"Failed to load data")}finally{k()&&l(!1),p.current===S&&(p.current=null)}},[e]),v=b.useCallback(()=>{g()},[g]);b.useEffect(()=>{v()},[v]);const x=b.useMemo(()=>dN(o),[o]),w=b.useMemo(()=>nN(t,x),[t,x]);b.useEffect(()=>(window.addEventListener("focus",v),()=>window.removeEventListener("focus",v)),[v]),b.useEffect(()=>{if(!w)return;const S=setInterval(()=>{document.visibilityState==="visible"&&v()},cN);return()=>clearInterval(S)},[w,v]),b.useEffect(()=>{if(t.length===0)return;const S=m.current,k=new Map;for(const C of t)C.agentStatus&&x.has(C.sessionId)&&k.set(C.sessionId,C.agentStatus);S!==null&&u(C=>{let T=null;for(const[_,P]of k)P==="completed"&&S.get(_)!=="completed"&&(T??(T=new Set(C)),T.add(_));for(const _ of C)k.get(_)!=="completed"&&(T??(T=new Set(C)),T.delete(_));return T??C}),m.current=k},[t,x]);const y=b.useCallback(S=>{u(k=>{if(!k.has(S))return k;const C=new Set(k);return C.delete(S),C})},[]),j=b.useCallback(S=>{s(k=>{const C=k.filter(T=>T.sessionId!==S);return nn()===e&&wo(Sn.activeSessions,C),C})},[e]),N=b.useMemo(()=>({sessions:t,processes:o,procBySession:x,newlyCompleted:f,loading:a,error:c,refresh:v,removeSession:j,acknowledgeCompleted:y}),[t,o,x,f,a,c,v,j,y]);return r.jsx(Kg.Provider,{value:N,children:n})}function fN(){const n=Ec();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function Ec(){return b.useContext(Kg)}const nf=[20,50,80,110,140,170,200,230,260,290,320,350];function mN(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return nf[(e>>>0)%nf.length]}function Na(n){const e=[];let t=!1;for(const s of n.split(`
|
|
78
|
+
`)){if(/^\s*(```|~~~)/.test(s)){t=!t;continue}let o=s;if(!t){if(o=o.replace(/^\s{0,3}#{1,6}\s+/,"").replace(/^\s*>\s?/,"").replace(/^\s*(?:[-*+]|\d+[.)])\s+/,""),/^\s*(?:[-*_]\s*){3,}$/.test(o))continue;o=o.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\[[^\]]*\]/g,"$1").replace(/(\*\*|__|~~)(.*?)\1/g,"$2").replace(new RegExp("(?<![\\w*])[*_](?=\\S)([^*_]+?)(?<=\\S)[*_](?![\\w*])","g"),"$1").replace(/`+/g,"")}const i=o.trim();i&&e.push(i)}return e.join(" ")}function pN(n){const e=n.split(`
|
|
79
|
+
`);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=Na(e[t]??"");return s?{subject:s,preview:Na(e.slice(t+1).join(`
|
|
80
|
+
`))}:{subject:Na(n),preview:""}}function ml(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function hN(n,e){return n===null||e===null||e<n?null:e-n}function gN(n){const e=ml(n);return e===null?null:new Date(e).toLocaleTimeString()}function xN(n){var s;const e=(s=Ec())==null?void 0:s.sessions;let t;e:{if(!n||!e){t=null;break e}const o=e.filter(a=>a.agentName===n);if(o.length!==1){t=null;break e}const i=o[0].agentStatus;if(!i){t=null;break e}t=Tc.has(i)?"working":"idle"}return t}const vN=b.memo(function(e){const t=F.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=b.useState(!1);let f;t[0]!==o?(f=x5(o),t[0]=o,t[1]=f):f=t[1];const u=f;let m;t[2]!==u?(m=pN(u),t[2]=u,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=gN(i),t[4]=i,t[5]=g):g=t[5];const v=g,x=xN(s);let w;t[6]!==u?(w=j5(u),t[6]=u,t[7]=w):w=t[7];const y=w,j=y&&!a,N=ml(i),S=a?hN(N,ml(a.timestamp)):null,k=!a&&l===!0,C=!!a||y;Cp(k&&C);const T=!0;let _;t[8]!==s?(_=mN(s),t[8]=s,t[9]=_):_=t[9];const P=String(_);let A;t[10]!==P?(A={"--agent-hue":P},t[10]=P,t[11]=A):A=t[11];const E=A,M="my-2 rounded-lg border border-l-[3px] border-border bg-card px-3 py-2 [border-left-color:oklch(0.52_0.16_var(--agent-hue))] dark:[border-left-color:oklch(0.74_0.14_var(--agent-hue))]";let I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(L2,{className:"size-3.5 shrink-0 text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]","data-icon":"inline-start"}),t[12]=I):I=t[12];let R;t[13]!==s?(R=r.jsx("span",{className:"truncate font-mono text-xs font-medium text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]",children:s}),t[13]=s,t[14]=R):R=t[14];let D;t[15]!==x||t[16]!==s?(D=x&&r.jsx("span",{"data-testid":"agent-liveness","data-live":x,title:x==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${x==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=x,t[16]=s,t[17]=D):D=t[17];let L;t[18]!==R||t[19]!==D?(L=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[I,R,D]}),t[18]=R,t[19]=D,t[20]=L):L=t[20];let $;t[21]!==j?($=j&&r.jsx(Oe,{variant:"outline",className:"h-4 border-warning/30 bg-warning/10 px-1.5 text-[10px] tracking-wide text-warning uppercase",children:"Needs you"}),t[21]=j,t[22]=$):$=t[22];let z;t[23]!==v?(z=v&&r.jsx("span",{className:"text-xs text-muted-foreground",children:v}),t[23]=v,t[24]=z):z=t[24];let U;t[25]!==$||t[26]!==z?(U=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[$,z]}),t[25]=$,t[26]=z,t[27]=U):U=t[27];let O;t[28]!==L||t[29]!==U?(O=r.jsxs("div",{className:"flex items-center gap-2",children:[L,U]}),t[28]=L,t[29]=U,t[30]=O):O=t[30];let H;t[31]!==u||t[32]!==c||t[33]!==h||t[34]!==p?(H=c?r.jsx("div",{"data-testid":"agent-message-body",className:"mt-1.5 max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(yn,{components:wn,remarkPlugins:Ss,children:u})}):r.jsxs(r.Fragment,{children:[r.jsx("p",{"data-testid":"agent-message-subject",className:"mt-1 line-clamp-2 break-words text-sm font-medium text-foreground",children:p}),h&&r.jsx("p",{"data-testid":"agent-message-preview",className:"mt-0.5 line-clamp-2 break-words text-xs leading-relaxed text-muted-foreground",children:h})]}),t[31]=u,t[32]=c,t[33]=h,t[34]=p,t[35]=H):H=t[35];const B="mt-1.5 flex items-center justify-end gap-2",W=C&&r.jsx("p",{"data-testid":"agent-message-state",className:`min-w-0 flex-1 truncate text-xs ${k?"text-warning":"text-muted-foreground"}`,children:a?r.jsxs(r.Fragment,{children:[S===null?"You replied":`You replied ${vn(S)} later`,a.summary&&` · "${a.summary}"`]}):k?N===null?"Awaiting your reply":`Awaiting your reply · ${vn(Math.max(0,Date.now()-N))}`:"Never answered"});let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=()=>d(bN),t[36]=V):V=t[36];let q;t[37]!==u||t[38]!==c?(q=r.jsx(X,{type:"button",variant:"ghost",size:"xs",onClick:V,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(et,{"data-icon":"inline-start"})," Expand ·"," ",u.length.toLocaleString("en-US")," ",u.length===1?"char":"chars"]})}),t[37]=u,t[38]=c,t[39]=q):q=t[39];let Y;t[40]!==W||t[41]!==q?(Y=r.jsxs("div",{className:B,children:[W,q]}),t[40]=W,t[41]=q,t[42]=Y):Y=t[42];let K;return t[43]!==O||t[44]!==H||t[45]!==Y||t[46]!==E?(K=r.jsxs("div",{"data-agent-rail":T,style:E,className:M,children:[O,H,Y]}),t[43]=O,t[44]=H,t[45]=Y,t[46]=E,t[47]=K):K=t[47],K});function bN(n){return!n}const yN=1500;function qs(){const n=F.c(5),[e,t]=b.useState(!1),s=b.useRef(null);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{s.current&&clearTimeout(s.current)},i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),b.useEffect(o,i);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async d=>{await Ko(d)&&(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),yN))},n[2]=a):a=n[2];const l=a;let c;return n[3]!==e?(c=[e,l],n[3]=e,n[4]=c):c=n[4],c}const wN=b.memo(function(e){const t=F.c(20),{text:s,model:o,effort:i,timestamp:a,compact:l}=e,c=l===void 0?!1:l;let d;t[0]!==s?(d=hg(s),t[0]=s,t[1]=d):d=t[1];const f=d,[u,m]=qs();if(!s)return null;let p;t[2]!==c||t[3]!==u||t[4]!==m||t[5]!==i||t[6]!==o||t[7]!==s||t[8]!==a?(p=!c&&r.jsxs("div",{className:"mb-1 flex min-h-6 items-center justify-end gap-1.5",children:[o&&r.jsx("span",{className:"text-xs text-muted-foreground",children:ki(o)}),i&&r.jsx("span",{className:"text-xs text-muted-foreground",title:`Reasoning effort: ${i}`,children:i}),(o||i)&&a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(a).toLocaleTimeString()}),r.jsx(X,{variant:"ghost",size:"icon-sm",className:"opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100",onClick:()=>m(s),"aria-label":u?"Response copied":"Copy response",title:u?"Copied":"Copy response",children:u?r.jsx(rt,{"data-icon":"inline-start"}):r.jsx(bn,{"data-icon":"inline-start"})})]}),t[2]=c,t[3]=u,t[4]=m,t[5]=i,t[6]=o,t[7]=s,t[8]=a,t[9]=p):p=t[9];const h=c&&"leading-relaxed";let g;t[10]!==h?(g=G("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let v;t[12]!==f?(v=r.jsx(yn,{components:wn,remarkPlugins:Ss,children:f}),t[12]=f,t[13]=v):v=t[13];let x;t[14]!==g||t[15]!==v?(x=r.jsx("div",{className:g,children:v}),t[14]=g,t[15]=v,t[16]=x):x=t[16];let w;return t[17]!==p||t[18]!==x?(w=r.jsxs("div",{className:"group",children:[p,x]}),t[17]=p,t[18]=x,t[19]=w):w=t[19],w}),Ls=[];function jN(n){return n.map(e=>({messageId:e.messageId,parentToolUseId:e.parentToolUseId,stopped:e.stopped,...e.stopped?{stoppedAt:Date.now()}:{},blocks:e.blocks.map(t=>({...t}))}))}function SN(n,e){if(e.length===0)return n;const t=n.slice(),s=new Map,o=i=>{let a=s.get(i.messageId);if(a)return a;const l=t.findIndex(c=>c.messageId===i.messageId);return l>=0?(a={...t[l],blocks:t[l].blocks.map(c=>({...c}))},t[l]=a):(a={messageId:i.messageId,parentToolUseId:i.parentToolUseId,stopped:!1,blocks:[]},t.push(a)),s.set(i.messageId,a),a};for(const i of e){const a=o(i);if(i.event==="message_stop"){a.stopped=!0,a.stoppedAt=Date.now();continue}let l=a.blocks.find(c=>c.index===i.blockIndex);l||(l={index:i.blockIndex,blockType:i.blockType,...i.toolName?{toolName:i.toolName}:{},text:""},a.blocks.push(l)),i.delta&&(l.text+=i.delta)}return t}const sf=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function NN(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){sf.lastIndex=0;let i;for(;(i=sf.exec(o))!==null;)t.add(i[1])}if(t.size===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!t.has(o.messageId));return s.length===n.length?n:s}function kN(n,e=1e4,t=Date.now()){if(n.length===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!(o.stopped&&o.stoppedAt!==void 0&&t-o.stoppedAt>e));return s.length===n.length?n:s}function CN(n){return n.filter(e=>e.parentToolUseId===null)}function _N(n,e){return n.filter(t=>t.parentToolUseId===e)}const Vg={},qg=b.createContext(Ls),Gg=b.createContext(Vg);function ka(n){const e=F.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?Vg:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(Gg.Provider,{value:i,children:o}),e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==a||e[4]!==t?(l=r.jsx(qg.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function Pc(){return b.useContext(qg)}function TN(n){return b.useContext(Gg)[n]??null}function Es(n){return function({children:t}){return r.jsx(n,{className:"mt-2 mb-1 text-xs font-semibold text-foreground first:mt-0",children:t})}}const Yg={...wn,code({className:n,children:e}){return!n&&typeof e=="string"&&!e.includes(`
|
|
81
|
+
`)?r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground",children:e}):r.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed",children:r.jsx("code",{children:String(e).replace(/\n$/,"")})})},img:()=>null},EN={...Yg,h1:Es("h1"),h2:Es("h2"),h3:Es("h3"),h4:Es("h4"),h5:Es("h5"),h6:Es("h6")},Xg=b.memo(function(e){const t=F.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?EN:Yg;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(yn,{components:a,remarkPlugins:Ss,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),of=400,PN=24,Ac=b.memo(function(e){const t=F.c(24),{toolUseId:s}=e,o=Pc(),i=TN(s),a=b.useRef(null),[l,c]=b.useState(!0);let d,f,u;if(t[0]!==l||t[1]!==o||t[2]!==s){u=_N(o,s).flatMap(AN).filter(MN).map(RN).join(`
|
|
82
|
+
`);const S=u.split(`
|
|
83
|
+
`);d=l&&S.length>of,f=d?S.slice(-of).join(`
|
|
84
|
+
`):u,t[0]=l,t[1]=o,t[2]=s,t[3]=d,t[4]=f,t[5]=u}else d=t[3],f=t[4],u=t[5];const m=f;let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const S=a.current;if(!S)return;const k=S.scrollHeight-S.scrollTop-S.clientHeight<PN;c(C=>C===k?C:k)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const S=a.current;if(!S||!l)return;const k=S.scrollHeight-S.clientHeight;S.scrollTop!==k&&(S.scrollTop=k)},t[7]=l,t[8]=g):g=t[8];let v;if(t[9]!==l||t[10]!==m?(v=[m,l],t[9]=l,t[10]=m,t[11]=v):v=t[11],b.useLayoutEffect(g,v),!u&&!i)return null;const x=i?"live-subagent-summary":void 0;let w;t[12]!==i?(w=i??r.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=i,t[13]=w):w=t[13];let y;t[14]!==x||t[15]!==w?(y=r.jsx("div",{"data-testid":x,className:"mb-1 text-xs font-medium text-muted-foreground",children:w}),t[14]=x,t[15]=w,t[16]=y):y=t[16];let j;t[17]!==d||t[18]!==m||t[19]!==u?(j=u&&r.jsxs("div",{ref:a,onScroll:h,"data-testid":"live-subagent-scroll",role:"region","aria-label":"Live sub-agent output",tabIndex:0,className:"text-xs break-words max-h-64 overflow-y-auto overscroll-contain pr-1",children:[d&&r.jsx("div",{className:"text-muted-foreground/50",children:"…"}),r.jsx(Xg,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=u,t[20]=j):j=t[20];let N;return t[21]!==y||t[22]!==j?(N=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[y,j]}),t[21]=y,t[22]=j,t[23]=N):N=t[23],N});function AN(n){return n.blocks}function MN(n){return n.blockType!=="tool_use"&&n.text}function RN(n){return n.text}function rf(n){return n.length>8?n.slice(0,8):n}function Mc(n,e,t){const s=e??t;return s?`${s} - ${rf(n)}`:rf(n)}function IN(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,Mc(t.agentId,t.subagentType,t.agentName));return e}function $N(n){const e=new Map;for(const s of n)s.parentToolUseId&&!e.has(s.agentId)&&e.set(s.agentId,s.parentToolUseId);const t=new Map;for(const s of e.values())t.set(s,(t.get(s)??0)+1);for(const[s,o]of e)(t.get(o)??0)>1&&e.delete(s);return e}function ON(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
85
|
+
`):""}function Jg(n,e){if(Xo(n))return Jl(n).turns.filter(i=>i.assistantText.length>0||i.thinking.length>0||i.toolCalls.length>0).map(i=>({agentId:e,agentName:null,subagentType:null,type:"assistant",content:i.assistantText.join(`
|
|
86
|
+
|
|
87
|
+
`),toolCalls:i.toolCalls,thinking:i.thinking.map(a=>a.thinking),text:[...i.assistantText],timestamp:i.timestamp,tokenUsage:i.tokenUsage,model:i.model,isBackground:!0}));const t=[],s=new Map;for(const o of n.split(`
|
|
88
|
+
`)){const i=o.trim();if(!i)continue;let a;try{a=JSON.parse(i)}catch{continue}const l=a.type;if(l!=="user"&&l!=="assistant")continue;const c=a.message;if(!c)continue;const d=c.content,f=a.timestamp??"";if(l==="assistant"){const u={agentId:e,agentName:null,subagentType:null,type:"assistant",content:d,toolCalls:[],thinking:[],text:[],timestamp:f,tokenUsage:c.usage?{input_tokens:c.usage.input_tokens??0,output_tokens:c.usage.output_tokens??0,cache_creation_input_tokens:c.usage.cache_creation_input_tokens??0,cache_read_input_tokens:c.usage.cache_read_input_tokens??0}:null,model:c.model??null,isBackground:!0};if(Array.isArray(d)){for(const m of d)if(m.type==="thinking")u.thinking.push(m.thinking);else if(m.type==="text")u.text.push(m.text);else if(m.type==="tool_use"){const p={id:m.id,name:m.name,input:m.input,result:null,isError:!1,timestamp:f};u.toolCalls.push(p),s.set(m.id,p)}}t.push(u)}else if(l==="user"&&Array.isArray(d)){for(const u of d)if(u.type==="tool_result"){const m=s.get(u.tool_use_id);m&&(m.result=ON(u.content),m.isError=u.is_error??!1)}}}return t}const Ca=new Map;function DN(n,e){const t=F.c(21),{session:s,sessionSource:o,isLive:i}=st();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=b.useState(a),[d,f]=b.useState(!1);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[1]=u):u=t[1];const m=b.useRef(u);let p;if(t[2]!==i||t[3]!==n){let T;t[5]!==i?(T=_=>_.text.length>0||_.thinking.length>0||_.toolCalls.length>0?!1:i?_.durationMs!=null:_.status==="async_launched",t[5]=i,t[6]=T):T=t[6],p=n.filter(T),t[2]=i,t[3]=n,t[4]=p}else p=t[4];const h=p,g=o==null?void 0:o.dirName,v=s==null?void 0:s.sessionId;let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=Ri(window.location.pathname),t[7]=x):x=t[7];const w=x;let y,j;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==v?(y=()=>{if(w||!e||!g||!v||h.length===0)return;const T=[];for(const A of h){const E=Mt(`${g}/${v}/${A.agentId}`);if(!m.current.has(E)){if(Ca.has(E)){c(M=>{const I=new Map(M);return I.set(A.agentId,Ca.get(E)),I}),m.current.add(E);continue}T.push({agentId:A.agentId,cacheKey:E})}}if(T.length===0)return;let _=!1;return f(!0),async function(){const E=new Map;await Promise.all(T.map(async M=>{const{agentId:I,cacheKey:R}=M;try{const D=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(v)}/subagents/agent-${encodeURIComponent(I)}.jsonl`,L=await ye(D);if(!L.ok)return;const $=await L.text(),z=Jg($,I);Ca.set(R,z),m.current.add(R),E.set(I,z)}catch{}})),!_&&E.size>0&&c(M=>{const I=new Map(M);for(const[R,D]of E)I.set(R,D);return I}),_||f(!1)}(),()=>{_=!0}},j=[w,e,g,v,h],t[8]=h,t[9]=g,t[10]=e,t[11]=v,t[12]=y,t[13]=j):(y=t[12],j=t[13]),b.useEffect(y,j);let N;e:{if(l.size===0&&h.length===0){N=n;break e}let T;if(t[14]!==l||t[15]!==n){T=[];for(const _ of n){const P=l.get(_.agentId);if(P&&P.length>0&&(_.status==="async_launched"||_.durationMs!=null)){const A={...P[0],durationMs:_.durationMs,toolUseCount:_.toolUseCount,status:_.status,prompt:_.prompt,agentName:_.agentName,subagentType:_.subagentType};T.push(A,...P.slice(1))}else T.push(_)}t[14]=l,t[15]=n,t[16]=T}else T=t[16];N=T}const S=N,k=w&&e&&h.length>0;let C;return t[17]!==S||t[18]!==d||t[19]!==k?(C={enrichedMessages:S,isLoading:d,unavailable:k},t[17]=S,t[18]=d,t[19]=k,t[20]=C):C=t[20],C}const Zg=b.memo(function(e){const t=F.c(71),{messages:s,expandAll:o,label:i,countLabel:a,lazyLoad:l}=e,c=l===void 0?!1:l,[d,f]=b.useState(!1),u=o||d,{enrichedMessages:m,isLoading:p,unavailable:h}=DN(s,c&&u),{sessionSource:g,actions:v}=st();let x;e:{if(!(g!=null&&g.fileName)){x=null;break e}let K;t[0]!==g.fileName?(K=ss(g.fileName),t[0]=g.fileName,t[1]=K):K=t[1];const J=K;if(J){x=J.parentSessionId;break e}let Z;if(t[2]!==g.fileName){let se;t[4]===Symbol.for("react.memo_cache_sentinel")?(se=/^([^/]+)\.jsonl$/,t[4]=se):se=t[4],Z=g.fileName.match(se),t[2]=g.fileName,t[3]=Z}else Z=t[3];const Q=Z;x=(Q==null?void 0:Q[1])??null}const w=x;let y;t[5]!==m?(y=new Set(m.map(zN)),t[5]=m,t[6]=y):y=t[6];let j;t[7]!==y?(j=[...y],t[7]=y,t[8]=j):j=t[8];const N=j;let S;t[9]!==m?(S=IN(m),t[9]=m,t[10]=S):S=t[10];const k=S;let C;if(t[11]!==m||t[12]!==s){C=new Map;for(const K of[...s,...m]){const J=C.get(K.agentId)??{};K.durationMs!=null&&(J.durationMs=K.durationMs),K.toolUseCount!=null&&(J.toolUseCount=K.toolUseCount),K.status&&(J.status=K.status),C.set(K.agentId,J)}t[11]=m,t[12]=s,t[13]=C}else C=t[13];const T=C;let _;t[14]!==m||t[15]!==s?(_=$N([...s,...m]),t[14]=m,t[15]=s,t[16]=_):_=t[16];const P=_;let A,E;if(t[17]!==m){E=new Map,A=new Map;for(const K of m)A.set(K.agentId,K),K.text.length>0&&E.set(K.agentId,K);t[17]=m,t[18]=A,t[19]=E}else A=t[18],E=t[19];let M;if(t[20]!==N||t[21]!==A||t[22]!==E){M=new Map;for(const K of N){const J=E.get(K)??A.get(K);J&&M.set(K,J)}t[20]=N,t[21]=A,t[22]=E,t[23]=M}else M=t[23];const I=M;let R;e:{let K=0,J=0,Z=!1,Q=!0;for(const ne of s)ne.durationMs!=null&&(K=K+ne.durationMs,Z=!0),ne.toolUseCount!=null&&(J=J+ne.toolUseCount),ne.status&&ne.status!=="completed"&&(Q=!1);if(!Z){R=null;break e}let se;t[24]!==Q||t[25]!==K||t[26]!==J?(se={totalDuration:K,totalToolUses:J,allCompleted:Q},t[24]=Q,t[25]=K,t[26]=J,t[27]=se):se=t[27],R=se}const D=R;if(s.length===0)return null;let L;t[28]!==d?(L=()=>f(!d),t[28]=d,t[29]=L):L=t[29];let $;t[30]!==u?($=u?r.jsx(nt,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(et,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[30]=u,t[31]=$):$=t[31];let z;t[32]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(Tn,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=z):z=t[32];let U;t[33]!==i?(U=r.jsx("span",{className:"text-xs font-medium text-foreground",children:i}),t[33]=i,t[34]=U):U=t[34];let O;t[35]!==N.length||t[36]!==a?(O=N.length>1&&r.jsxs(Oe,{variant:"secondary",children:[N.length," ",a]}),t[35]=N.length,t[36]=a,t[37]=O):O=t[37];let H;t[38]!==N||t[39]!==k?(H=N.map(K=>r.jsx(Oe,{variant:"outline",children:k.get(K)},K)),t[38]=N,t[39]=k,t[40]=H):H=t[40];let B;t[41]!==N.length||t[42]!==D?(B=D?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[D.allCompleted?r.jsx(_n,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(js,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(xs,{className:"size-3","data-icon":"inline-start"}),vn(D.totalDuration)]}),D.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(fi,{className:"size-3","data-icon":"inline-start"}),D.totalToolUses]})]}):r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.length," agent",N.length!==1?"s":"",")"]}),t[41]=N.length,t[42]=D,t[43]=B):B=t[43];let W;t[44]!==U||t[45]!==O||t[46]!==H||t[47]!==B||t[48]!==L||t[49]!==$?(W=r.jsxs(X,{type:"button",variant:"ghost",onClick:L,className:"h-auto w-full min-w-0 flex-wrap justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[$,z,U,O,H,B]}),t[44]=U,t[45]=O,t[46]=H,t[47]=B,t[48]=L,t[49]=$,t[50]=W):W=t[50];let V;t[51]!==N||t[52]!==u||t[53]!==P?(V=!u&&N.map(K=>{const J=P.get(K);return J?r.jsx(Ac,{toolUseId:J},K):null}),t[51]=N,t[52]=u,t[53]=P,t[54]=V):V=t[54];let q;t[55]!==v||t[56]!==N||t[57]!==k||t[58]!==I||t[59]!==p||t[60]!==u||t[61]!==w||t[62]!==P||t[63]!==g||t[64]!==T||t[65]!==h?(q=u&&r.jsxs("div",{className:"motion-enter mt-2 flex flex-col gap-2",children:[h?r.jsx("div",{className:"py-1 text-xs italic text-muted-foreground",children:"Sub-agent transcripts aren't available in a shared session."}):p&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[r.jsx(lt,{className:"size-3 animate-spin"}),"Loading agent output..."]}),N.map(K=>{const J=I.get(K),Z=T.get(K),Q=!!g&&!!w&&!h;return r.jsx(LN,{agentLabel:k.get(K)??K,message:J,stats:Z,parentToolUseId:P.get(K),canNavigate:Q,onOpen:()=>{Q&&v.handleLoadSession(g.dirName,`${w}/subagents/agent-${K}.jsonl`)}},K)})]}),t[55]=v,t[56]=N,t[57]=k,t[58]=I,t[59]=p,t[60]=u,t[61]=w,t[62]=P,t[63]=g,t[64]=T,t[65]=h,t[66]=q):q=t[66];let Y;return t[67]!==W||t[68]!==V||t[69]!==q?(Y=r.jsxs("div",{children:[W,V,q]}),t[67]=W,t[68]=V,t[69]=q,t[70]=Y):Y=t[70],Y});function LN(n){const e=F.c(22),{agentLabel:t,message:s,stats:o,parentToolUseId:i,canNavigate:a,onOpen:l}=n,c=s==null?void 0:s.text;let d;e[0]!==c?(d=hg((c??[]).join(`
|
|
89
|
+
|
|
90
|
+
`)),e[0]=c,e[1]=d):d=e[1];const f=d,u=((c==null?void 0:c.length)??0)>0,m=(o==null?void 0:o.status)!=null&&o.status!=="completed"&&o.status!=="async_launched",p=(o==null?void 0:o.status)==="completed";let h;e[2]!==t?(h=r.jsx(Oe,{variant:"outline",children:t}),e[2]=t,e[3]=h):h=e[3];let g;e[4]!==p||e[5]!==o?(g=o&&r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[p&&r.jsx(_n,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(xs,{className:"size-3"}),vn(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(fi,{className:"size-3"}),o.toolUseCount]})]}),e[4]=p,e[5]=o,e[6]=g):g=e[6];let v;e[7]!==a||e[8]!==l?(v=a&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[r.jsx(Jm,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=a,e[8]=l,e[9]=v):v=e[9];let x;e[10]!==h||e[11]!==g||e[12]!==v?(x=r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h,g,v]}),e[10]=h,e[11]=g,e[12]=v,e[13]=x):x=e[13];let w;e[14]!==u||e[15]!==m||e[16]!==f||e[17]!==i?(w=u?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(yn,{components:wn,remarkPlugins:Ss,children:f})}):r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"inline-flex items-center gap-1.5 text-xs italic text-muted-foreground",children:m?r.jsxs(r.Fragment,{children:[r.jsx(lt,{className:"size-3 animate-spin"}),"Working — no return yet"]}):r.jsx(r.Fragment,{children:"No return message from this agent"})}),i&&r.jsx(Ac,{toolUseId:i})]}),e[14]=u,e[15]=m,e[16]=f,e[17]=i,e[18]=w):w=e[18];let y;return e[19]!==x||e[20]!==w?(y=r.jsx("div",{className:"border-l pl-3",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[x,w]})}),e[19]=x,e[20]=w,e[21]=y):y=e[21],y}function zN(n){return n.agentId}const FN=b.memo(function(e){const t=F.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(Zg,{messages:s,expandAll:o,label:"Sub-agent activity",countLabel:"subagents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),BN=b.memo(function(e){const t=F.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(Zg,{messages:s,expandAll:o,label:"Background agent activity",countLabel:"agents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),UN=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),WN=b.memo(function(e){const t=F.c(30),{events:s}=e,[o,i]=b.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(HN),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?nt:et,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let f;t[2]!==d?(f=G("my-1 rounded-md border px-2 py-1 text-xs",d),t[2]=d,t[3]=f):f=t[3];let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(X,{type:"button",variant:"ghost",size:"sm",className:"h-auto w-full justify-start px-0 py-0 text-left font-normal text-muted-foreground"}),t[4]=u):u=t[4];let m;t[5]!==c?(m=r.jsx(c,{className:"size-3 shrink-0","data-icon":"inline-start"}),t[5]=c,t[6]=m):m=t[6];let p;t[7]!==l?(p=l?r.jsx(ln,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(z2,{className:"size-3","data-icon":"inline-start"}),t[7]=l,t[8]=p):p=t[8];const h=s.length===1?"":"s";let g;t[9]!==s.length||t[10]!==h?(g=r.jsxs("span",{className:"font-mono",children:[s.length," hook event",h]}),t[9]=s.length,t[10]=h,t[11]=g):g=t[11];let v;t[12]!==s?(v=s.map(KN).join(", "),t[12]=s,t[13]=v):v=t[13];let x;t[14]!==v?(x=r.jsx("span",{className:"truncate text-muted-foreground/60",children:v}),t[14]=v,t[15]=x):x=t[15];let w;t[16]!==x||t[17]!==m||t[18]!==p||t[19]!==g?(w=r.jsxs(dn,{render:u,children:[m,p,g,x]}),t[16]=x,t[17]=m,t[18]=p,t[19]=g,t[20]=w):w=t[20];let y;t[21]!==s?(y=s.map(VN),t[21]=s,t[22]=y):y=t[22];let j;t[23]!==y?(j=r.jsx(jt,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:y})}),t[23]=y,t[24]=j):j=t[24];let N;return t[25]!==o||t[26]!==w||t[27]!==j||t[28]!==f?(N=r.jsxs(wt,{open:o,onOpenChange:i,className:f,children:[w,j]}),t[25]=o,t[26]=w,t[27]=j,t[28]=f,t[29]=N):N=t[29],N});function HN(n){return UN.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function KN(n){return n.eventName}function VN(n,e){return r.jsxs("li",{className:"text-muted-foreground/80",children:[r.jsx("span",{className:"text-foreground",children:n.eventName}),n.toolName&&r.jsxs("span",{children:[" · ",n.toolName]}),n.source&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" (",n.source,")"]}),n.decision&&r.jsxs("span",{className:"text-warning",children:[" → ",n.decision]}),n.durationMs!==void 0&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" ",n.durationMs,"ms"]}),n.exitCode!==void 0&&n.exitCode!==0&&r.jsxs("span",{className:"text-destructive",children:[" exit ",n.exitCode]}),n.stderr&&r.jsx("pre",{className:"ml-2 mt-0.5 whitespace-pre-wrap text-destructive",children:n.stderr.slice(0,500)}),n.updatedToolOutput&&r.jsx("span",{className:"text-info",children:" · output replaced by hook"}),n.sessionTitle&&r.jsxs("span",{className:"text-foreground",children:[" · title: ",n.sessionTitle]}),n.worktreePath&&r.jsxs("span",{className:"text-success",children:[" · path: ",n.worktreePath]})]},e)}const af=768;function Wi(){const n=F.c(2),[e,t]=b.useState(typeof window<"u"?window.innerWidth<af:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${af-1}px)`),a=l=>t(l.matches);return i.addEventListener("change",a),t(i.matches),()=>i.removeEventListener("change",a)},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),b.useEffect(s,o),e}const qN=24,co=[];function GN(n,e){for(let s=0;s<co.length;s++){const o=co[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=XN(n,e);return co.length>=qN&&co.shift(),co.push({oldStr:n,newStr:e,result:t}),t}const YN=25e4;function XN(n,e){const t=n.split(`
|
|
91
|
+
`),s=e.split(`
|
|
92
|
+
`),o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l,f=[];for(let u=0;u<a;u++)f.push({type:"unchanged",text:t[u],oldIdx:u,newIdx:u});if(!(c===0&&d===0))if(c===0)for(let u=0;u<d;u++)f.push({type:"added",text:s[a+u],newIdx:a+u});else if(d===0)for(let u=0;u<c;u++)f.push({type:"removed",text:t[a+u],oldIdx:a+u});else if(c*d>YN){for(let u=0;u<c;u++)f.push({type:"removed",text:t[a+u],oldIdx:a+u});for(let u=0;u<d;u++)f.push({type:"added",text:s[a+u],newIdx:a+u})}else{const u=d+1,m=new Int32Array((c+1)*u);for(let v=1;v<=c;v++){const x=t[a+v-1],w=v*u,y=w-u;for(let j=1;j<=d;j++)if(x===s[a+j-1])m[w+j]=m[y+j-1]+1;else{const N=m[y+j],S=m[w+j-1];m[w+j]=N>S?N:S}}const p=[];let h=c,g=d;for(;h>0||g>0;)h>0&&g>0&&t[a+h-1]===s[a+g-1]?(p.push({type:"unchanged",text:t[a+h-1],oldIdx:a+h-1,newIdx:a+g-1}),h--,g--):g>0&&(h===0||m[h*u+g-1]>=m[(h-1)*u+g])?(p.push({type:"added",text:s[a+g-1],newIdx:a+g-1}),g--):(p.push({type:"removed",text:t[a+h-1],oldIdx:a+h-1}),h--);p.reverse(),f.push(...p)}for(let u=0;u<l;u++){const m=o-l+u,p=i-l+u;f.push({type:"unchanged",text:t[m],oldIdx:m,newIdx:p})}return f}function JN(n,e,t,s){const o=F.c(9),[i,a]=b.useState(null),[l,c]=b.useState(null);let d,f;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=Dh(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||$h().then(async v=>{if(h||(await Oh(v,m),h))return;const x=v.codeToTokens(n,{lang:m,theme:p});if(h)return;a(x.tokens);const w=v.codeToTokens(e,{lang:m,theme:p});h||c(w.tokens)}).catch(v=>{console.warn("[EditDiffView] highlight failed:",v),h||(a(null),c(null))})});return()=>{h=!0,cancelAnimationFrame(g)}},f=[n,e,t,s],o[0]=t,o[1]=s,o[2]=e,o[3]=n,o[4]=d,o[5]=f):(d=o[4],f=o[5]),b.useEffect(d,f);let u;return o[6]!==l||o[7]!==i?(u={oldTokens:i,newTokens:l},o[6]=l,o[7]=i,o[8]=u):u=o[8],u}const ZN={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},lf={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},QN={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function ek(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:G(e&&"opacity-50"),children:t.content},s))}function tk(n,e,t){switch(n.type){case"removed":return e==null?void 0:e[n.oldIdx??-1];case"added":return t==null?void 0:t[n.newIdx??-1];case"unchanged":return(t==null?void 0:t[n.newIdx??-1])??(e==null?void 0:e[n.oldIdx??-1])}}function nk(n){const e=F.c(3),{type:t}=n;switch(t){case"removed":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ym,{className:"inline size-3","data-icon":"icon"}),e[0]=s):s=e[0],s}case"added":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(xn,{className:"inline size-3","data-icon":"icon"}),e[1]=s):s=e[1],s}default:{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("span",{className:"inline-block size-3","aria-hidden":"true"}),e[2]=s):s=e[2],s}}}const _a=3;function sk(n){if(n.length===0)return[];const e=new Set;for(let i=0;i<n.length;i++)n[i].type!=="unchanged"&&e.add(i);if(e.size===0||n.length<=_a*2+3)return n.map((i,a)=>({kind:"line",line:i,originalIdx:a}));const t=new Set;for(const i of e)for(let a=Math.max(0,i-_a);a<=Math.min(n.length-1,i+_a);a++)t.add(a);const s=[];let o=0;for(;o<n.length;)if(t.has(o))s.push({kind:"line",line:n[o],originalIdx:o}),o++;else{const i=o;let a=0;for(;o<n.length&&!t.has(o);)a++,o++;s.push({kind:"separator",count:a,fromIdx:i,toIdx:o-1})}return s}function ok(n){const e=F.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(gi,{className:"shrink-0","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsxs("span",{className:"font-mono",children:[t," unchanged lines"]}),e[1]=t,e[2]=i):i=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"flex-1 border-b border-border"}),e[3]=a):a=e[3];let l;return e[4]!==s||e[5]!==i?(l=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"h-auto w-full justify-start rounded-none px-2 py-1 text-xs text-muted-foreground",children:[o,i,a]}),e[4]=s,e[5]=i,e[6]=l):l=e[6],l}const cf=b.memo(function(e){const t=F.c(33),{line:s,lineNum:o,oldTokens:i,newTokens:a}=e;let l,c,d,f,u,m;if(t[0]!==s||t[1]!==o||t[2]!==a||t[3]!==i){m=tk(s,i,a);const v=ZN[s.type];t[10]!==v?(d=G("flex",v),t[10]=v,t[11]=d):d=t[11];const x=lf[s.type];let w;t[12]!==x?(w=G("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",x),t[12]=x,t[13]=w):w=t[13],t[14]!==o||t[15]!==w?(f=r.jsx("span",{className:w,children:o}),t[14]=o,t[15]=w,t[16]=f):f=t[16];const y=lf[s.type];let j;t[17]!==y?(j=G("select-none shrink-0 w-5 text-right pr-1 border-r",y),t[17]=y,t[18]=j):j=t[18];let N;t[19]!==s.type?(N=r.jsx(nk,{type:s.type}),t[19]=s.type,t[20]=N):N=t[20],t[21]!==j||t[22]!==N?(u=r.jsx("span",{className:j,children:N}),t[21]=j,t[22]=N,t[23]=u):u=t[23],l="pl-2 whitespace-pre",c=m?ek(m,s.type==="unchanged"):r.jsx("span",{className:QN[s.type],children:s.text||" "}),t[0]=s,t[1]=o,t[2]=a,t[3]=i,t[4]=l,t[5]=c,t[6]=d,t[7]=f,t[8]=u,t[9]=m}else l=t[4],c=t[5],d=t[6],f=t[7],u=t[8],m=t[9];const p=m&&m.length===0&&" ";let h;t[24]!==l||t[25]!==c||t[26]!==p?(h=r.jsxs("span",{className:l,children:[c,p]}),t[24]=l,t[25]=c,t[26]=p,t[27]=h):h=t[27];let g;return t[28]!==d||t[29]!==f||t[30]!==u||t[31]!==h?(g=r.jsxs("div",{className:d,children:[f,u,h]}),t[28]=d,t[29]=f,t[30]=u,t[31]=h,t[32]=g):g=t[32],g}),df=120,uf=60,rk=120;function ff(n){const e=F.c(34),{lines:t,oldTokens:s,newTokens:o,compact:i,startLine:a}=n,l=a===void 0?1:a;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const[d,f]=b.useState(c);let u;e[1]!==t?(u=sk(t),e[1]=t,e[2]=u):u=e[2];const m=u,p=m.length>df,[h,g]=b.useState(p?uf:m.length);let v;e[3]!==m.length?(v=()=>{g(m.length>df?uf:m.length)},e[3]=m.length,e[4]=v):v=e[4];let x;e[5]!==m?(x=[m],e[5]=m,e[6]=x):x=e[6],b.useEffect(v,x);let w,y;e[7]!==m.length||e[8]!==h?(w=()=>{if(h>=m.length)return;const A=requestAnimationFrame(()=>{g(E=>Math.min(E+rk,m.length))});return()=>cancelAnimationFrame(A)},y=[h,m.length],e[7]=m.length,e[8]=h,e[9]=w,e[10]=y):(w=e[9],y=e[10]),b.useEffect(w,y);let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=A=>{f(E=>new Set(E).add(A))},e[11]=j):j=e[11];const N=j;let S;e[12]!==m||e[13]!==p||e[14]!==h?(S=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=S):S=e[15];const k=S,C=i&&"max-h-64 overflow-y-auto";let T;e[16]!==C?(T=G("overflow-x-auto font-mono text-xs leading-relaxed",C),e[16]=C,e[17]=T):T=e[17];let _;if(e[18]!==d||e[19]!==k||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let A;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(A=(E,M)=>{if(E.kind==="separator")return d.has(E.fromIdx)?t.slice(E.fromIdx,E.toIdx+1).map((D,L)=>{const $=E.fromIdx+L;return r.jsx(cf,{line:D,lineNum:D.type==="removed"?(D.oldIdx??0)+l:(D.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${$}`)}):r.jsx(ok,{count:E.count,onExpand:()=>N(E.fromIdx)},`sep-${M}`);const{line:I}=E,R=I.type==="removed"?(I.oldIdx??0)+l:(I.newIdx??0)+l;return r.jsx(cf,{line:I,lineNum:R,oldTokens:s,newTokens:o},M)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=A):A=e[30],_=k.map(A),e[18]=d,e[19]=k,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=_}else _=e[24];let P;return e[31]!==T||e[32]!==_?(P=r.jsx("div",{className:T,children:_}),e[31]=T,e[32]=_,e[33]=P):P=e[33],P}function mf(n){const e=F.c(11),{lines:t}=n;let s=0,o=0;for(const m of t)m.type==="added"?s++:m.type==="removed"&&o++;let i;e[0]!==s||e[1]!==o?(i={added:s,removed:o},e[0]=s,e[1]=o,e[2]=i):i=e[2];const{added:a,removed:l}=i;let c;e[3]!==l?(c=l>0&&r.jsxs("span",{className:"text-destructive",children:["-",l]}),e[3]=l,e[4]=c):c=e[4];const d=l>0&&a>0&&" ";let f;e[5]!==a?(f=a>0&&r.jsxs("span",{className:"text-success",children:["+",a]}),e[5]=a,e[6]=f):f=e[6];let u;return e[7]!==c||e[8]!==d||e[9]!==f?(u=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[c,d,f]}),e[7]=c,e[8]=d,e[9]=f,e[10]=u):u=e[10],u}function Rc(n){const e=F.c(34),{oldString:t,newString:s,filePath:o,compact:i,startLine:a,hideHeader:l}=n,c=i===void 0?!0:i,d=a===void 0?1:a,f=l===void 0?!1:l,[u,m]=b.useState(!1),p=tr();let h;e[0]!==s||e[1]!==t?(h=GN(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:v,newTokens:x}=JN(t,s,o,p);let w;e[3]!==o?(w=o.split("/").slice(-3).join("/"),e[3]=o,e[4]=w):w=e[4];const y=w,j=c&&"mt-1.5",N=f&&"border-0 rounded-none";let S;e[5]!==j||e[6]!==N?(S=G("overflow-hidden rounded border border-border bg-muted/20",j,N),e[5]=j,e[6]=N,e[7]=S):S=e[7];let k;e[8]!==f||e[9]!==c||e[10]!==g||e[11]!==y?(k=!f&&r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-2 py-1",children:[r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:y}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(mf,{lines:g}),c&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:r.jsx(pi,{"data-icon":"icon"})})]})]}),e[8]=f,e[9]=c,e[10]=g,e[11]=y,e[12]=k):k=e[12];let C;e[13]!==c||e[14]!==g||e[15]!==x||e[16]!==v||e[17]!==d?(C=r.jsx(ff,{lines:g,oldTokens:v,newTokens:x,compact:c,startLine:d}),e[13]=c,e[14]=g,e[15]=x,e[16]=v,e[17]=d,e[18]=C):C=e[18];let T;e[19]!==C||e[20]!==S||e[21]!==k?(T=r.jsxs("div",{className:S,children:[k,C]}),e[19]=C,e[20]=S,e[21]=k,e[22]=T):T=e[22];let _;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==u||e[27]!==x||e[28]!==v||e[29]!==d?(_=c&&r.jsx(On,{open:u,onOpenChange:m,children:r.jsxs(Dn,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(as,{children:[r.jsxs(Ln,{className:"font-mono text-sm text-foreground flex items-center gap-3",children:[o,r.jsx(mf,{lines:g})]}),r.jsx(zn,{className:"sr-only",children:"Diff view for edit operation"})]}),r.jsx("div",{className:"flex-1 overflow-auto rounded border border-border bg-background",children:r.jsx(ff,{lines:g,oldTokens:v,newTokens:x,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=u,e[27]=x,e[28]=v,e[29]=d,e[30]=_):_=e[30];let P;return e[31]!==T||e[32]!==_?(P=r.jsxs(r.Fragment,{children:[T,_]}),e[31]=T,e[32]=_,e[33]=P):P=e[33],P}const ik=new Set(["command","cmd","description","timeout","run_in_background"]);function Qg(n){return typeof n!="number"||!Number.isFinite(n)?String(n):n<1e3?`${n} ms`:n%6e4===0?`${n/6e4} min`:n%1e3===0?`${n/1e3} sec`:`${(n/1e3).toFixed(1)} sec`}function e1(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function ak(n){if(typeof n=="string")return n;if(n===null)return"null";if(n===void 0)return"undefined";try{return JSON.stringify(n)}catch{return String(n)}}function lk(n,e){const t=F.c(5),s=tr(),[o,i]=b.useState(null);let a,l;return t[0]!==n||t[1]!==s||t[2]!==e?(a=()=>{let c=!1;return pc(n,e,s).then(d=>{!c&&d&&d.length>0&&i(d)}),()=>{c=!0}},l=[n,s,e],t[0]=n,t[1]=s,t[2]=e,t[3]=a,t[4]=l):(a=t[3],l=t[4]),b.useEffect(a,l),o}function t1(n){const e=F.c(74),{title:t,code:s,language:o,codeLabel:i,copyLabel:a,icon:l,prompt:c,description:d,metadata:f}=n;let u;e[0]!==f?(u=f===void 0?[]:f,e[0]=f,e[1]=u):u=e[1];const m=u,[p,h]=qs(),g=lk(s,o);let v,x,w,y,j,N,S,k,C,T,_;if(e[2]!==l||e[3]!==s||e[4]!==i||e[5]!==p||e[6]!==h||e[7]!==a||e[8]!==d||e[9]!==c||e[10]!==t||e[11]!==g){const D=s.split(`
|
|
93
|
+
`);x=Ut,_="sm",w="mt-1.5";let L;e[23]!==l?(L=r.jsx(l,{className:"size-4","aria-hidden":"true"}),e[23]=l,e[24]=L):L=e[24];let $;e[25]!==L||e[26]!==t?($=r.jsxs(qt,{className:"flex items-center gap-2",children:[L,t]}),e[25]=L,e[26]=t,e[27]=$):$=e[27];let z;e[28]!==d?(z=d&&r.jsx(Gt,{children:d}),e[28]=d,e[29]=z):z=e[29];let U;e[30]!==s||e[31]!==h?(U=()=>h(s),e[30]=s,e[31]=h,e[32]=U):U=e[32];const O=p?`${t} copied`:a,H=p?"Copied":a;let B;e[33]!==p?(B=p?r.jsx(rt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(bn,{"data-icon":"inline-start","aria-hidden":"true"}),e[33]=p,e[34]=B):B=e[34];let W;e[35]!==U||e[36]!==O||e[37]!==H||e[38]!==B?(W=r.jsx(_h,{children:r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:U,"aria-label":O,title:H,children:B})}),e[35]=U,e[36]=O,e[37]=H,e[38]=B,e[39]=W):W=e[39],e[40]!==$||e[41]!==z||e[42]!==W?(y=r.jsxs(Vt,{children:[$,z,W]}),e[40]=$,e[41]=z,e[42]=W,e[43]=y):y=e[43],v=Wt,C="flex items-start gap-2 overflow-x-auto rounded-md bg-muted/50 p-3",e[44]!==c?(T=c&&r.jsx("span",{className:"select-none font-mono text-xs text-muted-foreground","aria-hidden":"true",children:c}),e[44]=c,e[45]=T):T=e[45],k="m-0 min-w-0 flex-1 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed [overflow-wrap:anywhere]",j=i;const V=!g&&"text-foreground";e[46]!==V?(N=G("block",V),e[46]=V,e[47]=N):N=e[47];let q;e[48]!==g?(q=(Y,K)=>{const J=g==null?void 0:g[K];return r.jsx("span",{className:"block min-h-lh",children:J?J.map(dk):Y||" "},K)},e[48]=g,e[49]=q):q=e[49],S=D.map(q),e[2]=l,e[3]=s,e[4]=i,e[5]=p,e[6]=h,e[7]=a,e[8]=d,e[9]=c,e[10]=t,e[11]=g,e[12]=v,e[13]=x,e[14]=w,e[15]=y,e[16]=j,e[17]=N,e[18]=S,e[19]=k,e[20]=C,e[21]=T,e[22]=_}else v=e[12],x=e[13],w=e[14],y=e[15],j=e[16],N=e[17],S=e[18],k=e[19],C=e[20],T=e[21],_=e[22];let P;e[50]!==j||e[51]!==N||e[52]!==S?(P=r.jsx("code",{"aria-label":j,className:N,children:S}),e[50]=j,e[51]=N,e[52]=S,e[53]=P):P=e[53];let A;e[54]!==P||e[55]!==k?(A=r.jsx("pre",{className:k,children:P}),e[54]=P,e[55]=k,e[56]=A):A=e[56];let E;e[57]!==A||e[58]!==C||e[59]!==T?(E=r.jsxs("div",{className:C,children:[T,A]}),e[57]=A,e[58]=C,e[59]=T,e[60]=E):E=e[60];let M;e[61]!==v||e[62]!==E?(M=r.jsx(v,{children:E}),e[61]=v,e[62]=E,e[63]=M):M=e[63];let I;e[64]!==m||e[65]!==t?(I=m.length>0&&r.jsx(to,{className:"items-stretch",children:r.jsx("dl",{className:"grid w-full gap-1.5","aria-label":`${t} options`,children:m.map(ck)})}),e[64]=m,e[65]=t,e[66]=I):I=e[66];let R;return e[67]!==x||e[68]!==w||e[69]!==y||e[70]!==M||e[71]!==I||e[72]!==_?(R=r.jsxs(x,{size:_,className:w,children:[y,M,I]}),e[67]=x,e[68]=w,e[69]=y,e[70]=M,e[71]=I,e[72]=_,e[73]=R):R=e[73],R}function ck(n){const e=n.icon;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-start gap-2 text-xs",children:[r.jsxs("dt",{className:"flex items-center gap-1 text-muted-foreground",children:[e&&r.jsx(e,{className:"size-3","aria-hidden":"true"}),n.label]}),r.jsx("dd",{className:"min-w-0 break-all font-mono text-card-foreground",children:n.value})]},n.key)}function dk(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}function uk(n){const e=[];n.timeout!==void 0&&e.push({key:"timeout",label:"Timeout",value:Qg(n.timeout),icon:xi}),typeof n.run_in_background=="boolean"&&e.push({key:"run_in_background",label:"Execution",value:n.run_in_background?"Background":"Foreground",icon:Uo});for(const[t,s]of Object.entries(n))ik.has(t)||s===void 0||e.push({key:t,label:e1(t),value:ak(s)});return e}function pf(n){const e=F.c(6),{input:t}=n,s=String(t.command??t.cmd??""),o=typeof t.description=="string"?t.description:"";let i;e[0]!==t?(i=uk(t),e[0]=t,e[1]=i):i=e[1];const a=i;let l;return e[2]!==s||e[3]!==o||e[4]!==a?(l=r.jsx(t1,{title:"Command",code:s,language:"bash",codeLabel:"Bash command",copyLabel:"Copy command",icon:Hs,prompt:"$",description:o,metadata:a}),e[2]=s,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function hf(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*([\\d_]+)`));if(!t)return null;const s=Number(t[1].replace(/_/g,""));return Number.isFinite(s)?s:null}function fk(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*["']([^"']+)["']`));return(t==null?void 0:t[1])??null}function gf(n){const e=F.c(5),{input:t}=n,s=String(t.raw??"");let o;e[0]!==s?(o=mk(s),e[0]=s,e[1]=o):o=e[1];const i=o;let a;return e[2]!==i||e[3]!==s?(a=r.jsx(t1,{title:"Tool script",code:s,language:"typescript",codeLabel:"Codex exec script",copyLabel:"Copy script",icon:Fo,metadata:i}),e[2]=i,e[3]=s,e[4]=a):a=e[4],a}function mk(n){const e=[],t=new Set(Array.from(n.matchAll(/\btools\.([A-Za-z_$][\w$]*)\s*\(/g),a=>a[1]));for(const a of t)e.push({key:`tool-${a}`,label:"Tool",value:e1(a)});const s=fk(n,"workdir");s&&e.push({key:"workdir",label:"Working directory",value:s});const o=hf(n,"yield_time_ms");o!==null&&e.push({key:"yield-time",label:"Yield",value:Qg(o),icon:xi});const i=hf(n,"max_output_tokens");return i!==null&&e.push({key:"output-limit",label:"Output limit",value:`${i.toLocaleString()} tokens`}),e}const pk=Cn("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out hover:bg-muted hover:text-foreground active:scale-[0.96] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-muted motion-reduce:transition-none motion-reduce:active:scale-100 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}}),n1=b.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function s1(n){const e=F.c(29);let t,s,o,i,a,l,c;e[0]!==n?({className:s,variant:c,size:i,spacing:a,orientation:l,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=a===void 0?2:a,f=l===void 0?"horizontal":l;let u;e[8]!==d?(u={"--gap":d},e[8]=d,e[9]=u):u=e[9];const m=u;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==f||e[13]!==i||e[14]!==d||e[15]!==c?(h={variant:c,size:i,spacing:d,orientation:f},e[12]=f,e[13]=i,e[14]=d,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=r.jsx(n1.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let v;return e[20]!==f||e[21]!==o||e[22]!==i||e[23]!==d||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(v=r.jsx(B2,{"data-slot":"toggle-group","data-variant":c,"data-size":i,"data-spacing":d,"data-orientation":f,orientation:f,style:m,className:p,...o,children:g}),e[20]=f,e[21]=o,e[22]=i,e[23]=d,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=v):v=e[28],v}function o1(n){const e=F.c(19);let t,s,o,i,a;e[0]!==n?({className:s,children:t,variant:i,size:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"default":i,c=a===void 0?"default":a,d=b.useContext(n1),f=d.variant||l,u=d.size||c,m=d.spacing;let p;e[6]!==s||e[7]!==d.size||e[8]!==d.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",pk({variant:d.variant||l,size:d.size||c}),s),e[6]=s,e[7]=d.size,e[8]=d.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==d.spacing||e[14]!==o||e[15]!==f||e[16]!==u||e[17]!==p?(h=r.jsx(F2,{"data-slot":"toggle-group-item","data-variant":f,"data-size":u,"data-spacing":m,className:p,...o,children:t}),e[12]=t,e[13]=d.spacing,e[14]=o,e[15]=f,e[16]=u,e[17]=p,e[18]=h):h=e[18],h}function hk(n){const e=F.c(31),{toolCall:t,sessionId:s,embedded:o}=n,i=o===void 0?!1:o;let a;e[0]!==t.input.questions?(a=t.input.questions??[],e[0]=t.input.questions,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c=()=>Object.fromEntries(l.map(gk)),e[2]=l,e[3]=c):c=e[3];const[d,f]=b.useState(c),[u,m]=b.useState(!1),[p,h]=b.useState(!1),{chat:g}=qo(),{sendMessage:v}=g;if(l.length===0)return null;let x;e[4]!==d||e[5]!==l||e[6]!==v?(x=()=>{const A=l.map(E=>{var I;const M=(I=d[E.question])==null?void 0:I.trim();return M?l.length>1?`${E.question}
|
|
94
|
+
${M}`:M:null}).filter(Boolean).join(`
|
|
95
|
+
|
|
96
|
+
`);A&&v(A),h(!0)},e[4]=d,e[5]=l,e[6]=v,e[7]=x):x=e[7];const w=x;let y;if(e[8]!==d||e[9]!==w||e[10]!==s||e[11]!==t.id){const A=async E=>{E.preventDefault(),m(!0);try{(await Ql(s,t.id,d)).ok?h(!0):w()}catch{w()}m(!1)};y=E=>{A(E)},e[8]=d,e[9]=w,e[10]=s,e[11]=t.id,e[12]=y}else y=e[12];const j=!i&&"mt-2 rounded-md border bg-card p-3",N=p&&"pointer-events-none opacity-50";let S;e[13]!==j||e[14]!==N?(S=G("flex flex-col gap-3",j,N),e[13]=j,e[14]=N,e[15]=S):S=e[15];let k;if(e[16]!==d||e[17]!==l||e[18]!==t.id){let A;e[20]!==d||e[21]!==t.id?(A=(E,M)=>{const I=E.options&&E.options.length>0,R=new Set(E.multiSelect?(d[E.question]??"").split(", ").filter(Boolean):[]),D=`ask-user-answer-${t.id}-${M}`;return r.jsxs(Db,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(E.header||E.question)&&r.jsxs(Lb,{variant:"label",className:"flex flex-col items-start gap-1",children:[E.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:E.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:E.question})]}),I?r.jsx(s1,{multiple:E.multiSelect,orientation:"vertical",variant:"outline",value:E.multiSelect?Array.from(R):d[E.question]?[d[E.question]]:[],onValueChange:L=>{if(!E.multiSelect&&L.length===0)return;const $=E.multiSelect?L.join(", "):L[0];f({...d,[E.question]:$})},className:"grid w-full gap-1.5",children:E.options.map((L,$)=>{const z=E.multiSelect?R.has(L.label):d[E.question]===L.label;return r.jsxs(o1,{value:L.label,"aria-label":L.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",E.multiSelect?"rounded":"rounded-full",z?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:z&&r.jsx(rt,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-xs font-medium",children:L.label}),L.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:L.description})]})]},$)})}):r.jsxs(ft,{children:[r.jsx(mt,{htmlFor:D,children:"Answer"}),r.jsx(Ii,{id:D,value:d[E.question]??"",onChange:L=>{f({...d,[E.question]:L.target.value})},rows:2,placeholder:"Type your answer..."})]})]},M)},e[20]=d,e[21]=t.id,e[22]=A):A=e[22],k=l.map(A),e[16]=d,e[17]=l,e[18]=t.id,e[19]=k}else k=e[19];const C=u||p,T=p?"Sent":u?"Sending...":"Send answer";let _;e[23]!==C||e[24]!==T?(_=r.jsx(X,{type:"submit",size:"sm",disabled:C,children:T}),e[23]=C,e[24]=T,e[25]=_):_=e[25];let P;return e[26]!==k||e[27]!==_||e[28]!==y||e[29]!==S?(P=r.jsxs("form",{onSubmit:y,className:S,children:[k,_]}),e[26]=k,e[27]=_,e[28]=y,e[29]=S,e[30]=P):P=e[30],P}function gk(n){return[n.question,""]}function xk(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function xf(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function vk(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[xf(s[1])]=xf(s[2]);return e}function bk(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yk(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${bk(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function wk(n,e){const t=n.input.answers;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const o=Object.entries(t).filter(i=>typeof i[1]=="string");if(o.length>0)return Object.fromEntries(o)}if(!n.result)return{};const s=vk(n.result);for(const o of e)if(s[o.question]===void 0){const i=yk(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function vf(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function jk(n){const e=F.c(30),{question:t,answer:s,index:o,completed:i}=n;let a;e[0]!==t.options?(a=t.options??[],e[0]=t.options,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==s||e[3]!==l||e[4]!==t){let y;e[6]!==s||e[7]!==t?(y=j=>vf(t,s,j.label),e[6]=s,e[7]=t,e[8]=y):y=e[8],c=l.filter(y),e[2]=s,e[3]=l,e[4]=t,e[5]=c}else c=e[5];const d=c.length,f=i&&s!==void 0&&d===0,u=o+1;let m;e[9]!==u?(m=r.jsx(Oe,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:u}),e[9]=u,e[10]=m):m=e[10];let p;e[11]!==t.header?(p=t.header&&r.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t.header}),e[11]=t.header,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t.question?(g=r.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.question}),e[16]=t.question,e[17]=g):g=e[17];let v;e[18]!==s||e[19]!==l||e[20]!==t?(v=l.length>0&&r.jsx("div",{className:"mt-2 flex flex-col divide-y divide-border",children:l.map((y,j)=>{const N=vf(t,s,y.label);return r.jsxs("div",{className:G("flex items-start gap-2.5 py-2",N?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",t.multiSelect?"rounded":"rounded-full",N?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:N&&r.jsx(rt,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"block text-xs font-medium",children:[y.label,N&&r.jsx(Oe,{variant:"secondary",className:"ml-2",children:"Selected"})]}),y.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:y.description})]})]},`${y.label}-${j}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=v):v=e[21];let x;e[22]!==s||e[23]!==f?(x=f&&r.jsxs("div",{className:"mt-2 border-l-2 border-border pl-3",children:[r.jsx("div",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:"Answer"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:s.trim()||"No answer provided"})]}),e[22]=s,e[23]=f,e[24]=x):x=e[24];let w;return e[25]!==h||e[26]!==g||e[27]!==v||e[28]!==x?(w=r.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,v,x]}),e[25]=h,e[26]=g,e[27]=v,e[28]=x,e[29]=w):w=e[29],w}function Sk(n){const e=F.c(61),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=b.useState(!1);let c;e[0]!==t?(c=xk(t),e[0]=t,e[1]=c):c=e[1];const d=c;let f;e[2]!==d||e[3]!==t?(f=wk(t,d),e[2]=d,e[3]=t,e[4]=f):f=e[4];const u=f,m=s||a,p=t.result!==null&&!t.isError,h=t.result===null&&o&&!!i&&d.length>0;let g;e[5]!==u?(g=Object.keys(u),e[5]=u,e[6]=g):g=e[6];const v=g.length>0,x=t.isError?ln:p?_n:xi,w=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",y=t.isError&&"border-destructive/30";let j;e[7]!==y?(j=G("my-1 overflow-hidden rounded-lg border bg-card",y),e[7]=y,e[8]=j):j=e[8];let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Zm,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=N):N=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=S):S=e[10];const k=d.length===1?"question":"questions";let C;e[11]!==d.length||e[12]!==k?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[S,r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",k]})]}),e[11]=d.length,e[12]=k,e[13]=C):C=e[13];const T=t.isError?"destructive":p?"secondary":"outline";let _;e[14]!==x?(_=r.jsx(x,{"data-icon":"inline-start"}),e[14]=x,e[15]=_):_=e[15];let P;e[16]!==w||e[17]!==T||e[18]!==_?(P=r.jsxs(Oe,{variant:T,children:[_,w]}),e[16]=w,e[17]=T,e[18]=_,e[19]=P):P=e[19];let A;e[20]!==P||e[21]!==C?(A=r.jsxs("div",{className:"min-w-0 flex-1",children:[C,P]}),e[20]=P,e[21]=C,e[22]=A):A=e[22];let E;e[23]!==t.timestamp?(E=t.timestamp&&r.jsx("time",{className:"hidden shrink-0 pt-0.5 font-mono text-xs tabular-nums text-muted-foreground sm:block",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e[23]=t.timestamp,e[24]=E):E=e[24];let M;e[25]!==A||e[26]!==E?(M=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[N,A,E]}),e[25]=A,e[26]=E,e[27]=M):M=e[27];let I;e[28]!==u||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?(I=h&&i?r.jsx(hk,{toolCall:t,sessionId:i,embedded:!0}):d.length>0?d.map((B,W)=>r.jsx(jk,{question:B,answer:u[B.question],index:W,completed:t.result!==null},`${B.question}-${W}`)):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Question details are unavailable."}),e[28]=u,e[29]=h,e[30]=d,e[31]=i,e[32]=t,e[33]=I):I=e[33];let R;e[34]!==v||e[35]!==t.isError||e[36]!==t.result?(R=t.result!==null&&!v&&r.jsxs("div",{className:G("border-t border-border py-3",t.isError?"text-destructive":"text-muted-foreground"),children:[r.jsx("div",{className:"mb-0.5 text-xs font-semibold uppercase tracking-wide opacity-70",children:"Recorded response"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:t.result})]}),e[34]=v,e[35]=t.isError,e[36]=t.result,e[37]=R):R=e[37];let D;e[38]!==I||e[39]!==R?(D=r.jsxs("div",{className:"px-3",children:[I,R]}),e[38]=I,e[39]=R,e[40]=D):D=e[40];let L;e[41]!==s?(L=()=>{s||l(Nk)},e[41]=s,e[42]=L):L=e[42];let $;e[43]!==m?($=m?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(et,{"data-icon":"inline-start"}),e[43]=m,e[44]=$):$=e[44];let z;e[45]!==m||e[46]!==L||e[47]!==$?(z=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:L,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[$,"Raw details"]}),e[45]=m,e[46]=L,e[47]=$,e[48]=z):z=e[48];let U;e[49]!==m||e[50]!==t.input||e[51]!==t.result?(U=m&&r.jsxs("div",{className:"mt-1.5 grid gap-2 pb-1.5 lg:grid-cols-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Input"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:JSON.stringify(t.input,null,2)})]}),t.result!==null&&r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Result"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:t.result})]})]}),e[49]=m,e[50]=t.input,e[51]=t.result,e[52]=U):U=e[52];let O;e[53]!==z||e[54]!==U?(O=r.jsxs("div",{className:"border-t px-3 py-1.5",children:[z,U]}),e[53]=z,e[54]=U,e[55]=O):O=e[55];let H;return e[56]!==M||e[57]!==D||e[58]!==O||e[59]!==j?(H=r.jsxs("section",{className:j,"aria-label":"Question history",children:[M,D,O]}),e[56]=M,e[57]=D,e[58]=O,e[59]=j,e[60]=H):H=e[60],H}function Nk(n){return!n}const kk="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",Ck="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function r1(n,e,t){const s=F.c(5),[o,i]=b.useState(null);let a,l;return s[0]!==n||s[1]!==t||s[2]!==e?(a=()=>{if(!e){i(null);return}let c=!1;return pc(n,e,t).then(d=>{c||i(d)}),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=a,s[4]=l):(a=s[3],l=s[4]),b.useEffect(a,l),o}function i1(n){const e=F.c(12),{lines:t,tokens:s,lineNums:o,variant:i}=n,a=i==="boxed"?kk:Ck;let l;if(e[0]!==o||e[1]!==t||e[2]!==s){let f;e[4]!==o||e[5]!==s?(f=(u,m)=>{const p=s==null?void 0:s[m];return r.jsxs("span",{className:"block",children:[(o==null?void 0:o[m])&&r.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground/30 select-none",children:o[m]}),p?p.map(_k):u||" "]},m)},e[4]=o,e[5]=s,e[6]=f):f=e[6],l=t.map(f),e[0]=o,e[1]=t,e[2]=s,e[3]=l}else l=e[3];let c;e[7]!==l?(c=r.jsx("code",{className:"block",children:l}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==a||e[10]!==c?(d=r.jsx("pre",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=d):d=e[11],d}function _k(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const Tk=/^(\s*\d+)→(.*)$/;function a1(n){return n.split(/\r\n|\r|\n/)}function Ek(n){const e=[],t=[];for(const s of a1(n)){const o=s.match(Tk);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function Pk(n){const e=F.c(14),{result:t,filePath:s,expanded:o,variant:i}=n,a=i===void 0?"boxed":i,l=tr();let c;e[0]!==s?(c=Dh(s),e[0]=s,e[1]=c):c=e[1];const d=c;let f;e[2]!==o||e[3]!==t?(f=o?t:t.slice(0,500),e[2]=o,e[3]=t,e[4]=f):f=e[4];const u=f;let m;e[5]!==u?(m=Ek(u),e[5]=u,e[6]=m):m=e[6];const{lineNums:p,codeLines:h}=m;let g;e[7]!==h?(g=h.join(`
|
|
97
|
+
`),e[7]=h,e[8]=g):g=e[8];const x=r1(g,d,l);let w;return e[9]!==h||e[10]!==p||e[11]!==x||e[12]!==a?(w=r.jsx(i1,{lines:h,tokens:x,lineNums:p,variant:a}),e[9]=h,e[10]=p,e[11]=x,e[12]=a,e[13]=w):w=e[13],w}function l1(n){const e=n.trim();if(e[0]!=="{"&&e[0]!=="[")return null;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return null}}function pl(n){const e=F.c(12),{result:t,expanded:s,alreadyPretty:o,variant:i}=n,a=i===void 0?"boxed":i,l=tr();let c;e[0]!==o||e[1]!==t?(c=o?t:l1(t)??t,e[0]=o,e[1]=t,e[2]=c):c=e[2];const d=c;let f;e[3]!==s||e[4]!==d?(f=s?d:d.slice(0,2e3),e[3]=s,e[4]=d,e[5]=f):f=e[5];const u=f;let m;e[6]!==u?(m=a1(u),e[6]=u,e[7]=m):m=e[7];const p=m,h=r1(u,"json",l);let g;return e[8]!==p||e[9]!==h||e[10]!==a?(g=r.jsx(i1,{lines:p,tokens:h,variant:a}),e[8]=p,e[9]=h,e[10]=a,e[11]=g):g=e[11],g}const Ak={spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"Task"},send_message:{label:"Message agent",styleName:"Task"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"Task"},interrupt_agent:{label:"Interrupt agent",styleName:"Task"},tool_search:{label:"Find tools",styleName:"ToolSearch"},list_mcp_resources:{label:"List MCP resources",styleName:"Mcp"},list_mcp_resource_templates:{label:"List MCP templates",styleName:"Mcp"},read_mcp_resource:{label:"Read MCP resource",styleName:"Mcp"},request_plugin_install:{label:"Install plugin",styleName:"Mcp"},create_goal:{label:"Create goal",styleName:"TodoWrite"},get_goal:{label:"Check goal",styleName:"TodoWrite"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}};function Mk(n){return typeof n=="object"&&n!==null}function Xt(...n){return n.find(e=>typeof e=="string")??""}function Gs(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function Ic(n){const e=[],t=new Set;for(const s of n){const o=s.trim();!o||t.has(o)||(t.add(o),e.push(o))}return e}function rr(n,e=""){const t=Ic(n);if(t.length===0)return e;const s=Gs(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function $c(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const bf={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function Xr(n,e=!1){const t=n.replace(/^mcp__/,"").replace(/__/g," ").replace(/[_./:-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map(o=>{const i=o.toLowerCase();return bf[i]?bf[i]:e?i[0].toUpperCase()+i.slice(1):i});if(t.length===0)return"Tool";const s=t.join(" ");return s[0].toUpperCase()+s.slice(1)}function Rk(n){if(!n)return null;const e=n.trim(),t=kn(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function $t(n,...e){for(const t of e){const s=Rk(ql(n,t));if(s)return s;const o=Gl(n,t)[0];if(o)return o}return""}function Ik(n,...e){for(const t of e){const s=Jp(n,t)[0];if(s!==void 0)return s}return null}function Jr(n){return $t(n,"description","query","q","cmd","command","file_path","path","uri","url","pattern","prompt","objective","message","location","ticker","target","task_name","plugin_id","server","status","id")}const $k=[{key:"search_query",label:"Search web",noun:"search",summaryGroups:[["q","query"]]},{key:"image_query",label:"Search images",noun:"image search",summaryGroups:[["q","query"]]},{key:"open",label:"Open page",noun:"page",summaryGroups:[["ref_id","url"]],detail:{property:"lineno",format:n=>`line ${n}`}},{key:"click",label:"Open link",noun:"link",summaryGroups:[["ref_id"]],detail:{property:"id",format:n=>`link ${n}`}},{key:"find",label:"Find on page",noun:"find",summaryGroups:[["pattern"],["ref_id","url"]]},{key:"screenshot",label:"Capture page",noun:"capture",summaryGroups:[["ref_id"]],detail:{property:"pageno",format:n=>`page ${n+1}`}},{key:"finance",label:"Check markets",noun:"quote",summaryGroups:[["ticker"]]},{key:"weather",label:"Check weather",noun:"forecast",summaryGroups:[["location"]]},{key:"sports",label:"Check sports",noun:"sports lookup",summaryGroups:[["league","team"]],countProperties:["league"]},{key:"time",label:"Check time",noun:"time lookup",summaryGroups:[["utc_offset"]]}];function yf(n,e){return e.flatMap(t=>Gl(n,t))}function Ok(n,e){const t=e.summaryGroups.map(i=>yf(n,i)),s=e.detail?Jp(n,e.detail.property):[],o=e.countProperties?yf(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>rr(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(Zp(n),Ic(o).length,s.length,1)}}function Dk(n){const e=[];for(const t of $k){const s=ql(n,t.key);s&&e.push(Ok(s,t))}return e}function Lk(n){const e=Dk(n);return e.length===0?{label:"Browse web",summary:Jr(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>$c(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function c1(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:Xr(e,!0),action:Xr(t.join(" "))}}function zk(n,e){const t=c1(n);if(!t)return{label:Xr(n),summary:Jr(e),styleName:"Mcp"};const s=Jr(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function Fk(n){const e=kn(n.trim(),0),t=(e==null?void 0:e.value)??n,s=Ic(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return rr(s,s.length>0?$c(s.length,"file"):"")}function Bk(n){const e=n.argumentSource;switch(n.name){case"exec_command":return{label:"Run command",summary:$t(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=Ik(e,"session_id"),s=$t(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?Gs(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:Fk(e),styleName:"Edit"};case"web__run":case"web_search":return Lk(e);case"view_image":return{label:"View image",summary:$t(e,"path"),styleName:"Read"};case"update_plan":{const t=ql(e,"plan"),s=t?Zp(t):0;return{label:"Update plan",summary:s>0?$c(s,"step"):$t(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:$t(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TodoWrite"};case"update_goal":return{label:"Update goal",summary:$t(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:$t(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:$t(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[$t(e,"server"),$t(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:$t(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:$t(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:$t(e,"prompt"),styleName:"Image"};default:return n.name.startsWith("mcp__")?zk(n.name,e):{label:Xr(n.name),summary:Jr(e),styleName:n.name}}}function d1(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function Uk(n){const e=k3(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(Bk),s=t[0];if(t.every(i=>i.label===s.label)){const i=rr(t.map(a=>a.summary));return{label:s.label,summary:e.length===1?i:[`×${e.length}`,i].filter(Boolean).join(" · "),styleName:s.styleName}}const o=new Map;for(const i of t)o.set(i.label,(o.get(i.label)??0)+1);return{label:"Run tools",summary:[...o].map(([i,a])=>a>1?`${i} ×${a}`:i).join(" · "),styleName:"exec"}}function Wk(n){const e=Mk(n.action)?n.action:null,t=typeof(e==null?void 0:e.type)=="string"?e.type:"search";if(t==="open_page"||t==="openPage")return{label:"Open page",summary:Xt(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[Xt(e==null?void 0:e.pattern),Xt(e==null?void 0:e.url)].filter(Boolean).join(" · "),styleName:"WebSearch"};const s=Array.isArray(e==null?void 0:e.queries)?e.queries.filter(i=>typeof i=="string"):[],o=Xt(e==null?void 0:e.query,n.query);return{label:"Search web",summary:rr([o,...s]),styleName:"WebSearch"}}const Hk=["summary","headline","verdict","title"];function Kk(n){const e=Xt(...Hk.map(t=>n[t]));if(e)return Gs(e);for(const[t,s]of Object.entries(n)){if(!Array.isArray(s))continue;const o=s.length===1&&t.endsWith("s")?t.slice(0,-1):t;return`${s.length} ${o}`}return""}function Vk(n){const e=Xt(n.description);if(e)return Gs(e);const t=Xt(n.script);return(t?Gl(t,"name")[0]??"":"")||Xt(n.scriptPath)}function wf(n){const e=Object.keys(n);if(e.length===0)return"";const t=n[e[0]];return typeof t!="string"?"":t.length>80?t.slice(0,80)+"...":t}function jf(n){var t;const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":return String(e.command??e.cmd??"");case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return String(e.description??e.prompt??"");case"WebFetch":return String(e.url??"");case"NotebookEdit":return String(e.notebook_path??"");case"EnterPlanMode":return"Entered plan mode";case"ExitPlanMode":return"Waiting for plan approval";case"AskUserQuestion":{const s=e.questions;return((t=s==null?void 0:s[0])==null?void 0:t.question)??""}case"Monitor":{const s=String(e.bash_id??""),o=e.filter?` · filter=${e.filter}`:"";return`${s}${o}`}case"CronCreate":{const s=String(e.schedule??e.cron??""),o=String(e.prompt??""),i=o.length>60?o.slice(0,60)+"...":o;return s&&i?`${s} → ${i}`:s||i}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const s=Number(e.delaySeconds??0),o=Math.round(s/60),i=s>=3600?`${Math.round(s/3600)}h`:s>=60?`${o}m`:`${s}s`,a=e.reason?` · ${e.reason}`:"";return`in ${i}${a}`}case"RemoteTrigger":{const s=String(e.action??""),o=String(e.id??e.trigger_id??"");return[s,o].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const s=String(e.name??e.branch??""),o=e.path?` (${e.path})`:"";return`${s}${o}`}case"ExitWorktree":return String(e.name??e.branch??"");case"Skill":return String(e.skill??e.name??"");case"ToolSearch":return String(e.query??"");case"SendMessage":{const s=Xt(e.to,e.recipient),o=Gs(Xt(e.summary,e.message,e.content));return[s,o].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return Gs(Xt(e.subject,e.description));case"TaskUpdate":{const s=String(e.taskId??""),o=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(a=>typeof a=="string"):[],i=Xt(e.status)||(o.length>0?`blocked by ${o.join(", ")}`:"");return i?`${s} → ${i}`:s}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return Vk(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return Kk(e)||wf(e);case"spawn_agent":return String(e.task_name??e.message??"");case"wait_agent":{const s=Array.isArray(e.ids)?e.ids.filter(o=>typeof o=="string"):[];return rr(s)}case"send_message":case"followup_task":return[e.target,e.message].filter(s=>typeof s=="string").join(" · ");case"list_agents":return String(e.path_prefix??"");case"interrupt_agent":return String(e.target??"");case"list_mcp_resources":case"list_mcp_resource_templates":return String(e.server??"");case"read_mcp_resource":return[e.server,e.uri].filter(s=>typeof s=="string").join(" · ");case"request_plugin_install":return String(e.plugin_id??"");case"create_goal":return String(e.objective??"");case"update_goal":return String(e.status??"");case"view_image":return String(e.path??"");default:return wf(e)}}function Hi(n){if(d1(n))return Uk(n.input.raw);if(n.name==="WebSearch")return Wk(n.input);const e=c1(n.name);if(e)return{label:e.server,summary:[e.action,jf(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const t=Ak[n.name];return{label:(t==null?void 0:t.label)??n.name,summary:jf(n),styleName:(t==null?void 0:t.styleName)??n.name}}function qk(n){return Hi(n).summary}const Gk={mutating:"text-foreground",readOnly:"text-muted-foreground"},Yk="text-destructive",Sf=8,Xk="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground",Jk="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border p-2 font-mono text-xs leading-relaxed";function Zk(n){return n.split(/\r\n|\r|\n/)}const Qk={Write:"mutating",Edit:"mutating",Bash:"mutating",exec:"mutating",Task:"mutating",Skill:"mutating",TodoWrite:"mutating",Image:"mutating",AskUserQuestion:"mutating",CronCreate:"mutating",CronDelete:"mutating",ScheduleWakeup:"mutating",RemoteTrigger:"mutating",PushNotification:"mutating",EnterWorktree:"mutating",ExitWorktree:"mutating",Agent:"mutating",SendMessage:"mutating",EndConversation:"mutating",TaskCreate:"mutating",TaskUpdate:"mutating",TaskStop:"mutating",Workflow:"mutating",Read:"readOnly",Grep:"readOnly",Glob:"readOnly",WebFetch:"readOnly",WebSearch:"readOnly",ToolSearch:"readOnly",Monitor:"readOnly",CronList:"readOnly",Mcp:"readOnly",EnterPlanMode:"readOnly",ExitPlanMode:"readOnly",ListAgents:"readOnly",TaskList:"readOnly",TaskOutput:"readOnly",LSP:"readOnly",StructuredOutput:"readOnly",ReportFindings:"readOnly"},eC="readOnly";function tC(n){return Qk[n]??eC}function u1(n,e=!1){return e?Yk:Gk[tC(n)]}function Ta(n){const e=F.c(8),{isOpen:t,onClick:s,label:o,controlsId:i}=n,a=t?nt:et;let l;e[0]!==a?(l=r.jsx(a,{"data-icon":"inline-start"}),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s||e[6]!==l?(c=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground","aria-expanded":t,"aria-controls":i,children:[l,o]}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=l,e[7]=c):c=e[7],c}function f1(n){const e=F.c(2),{toolCall:t,isAgentActive:s}=n;if(t.isError){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(js,{role:"img","aria-label":"Tool call failed",className:"size-4 text-destructive","data-icon":"icon"}),e[0]=o):o=e[0],o}if(t.result===null&&s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(lt,{role:"img","aria-label":"Tool call running",className:"size-4 animate-spin text-info","data-icon":"icon"}),e[1]=o):o=e[1],o}return null}function nC(n){const e=F.c(30),{toolCall:t,resultExpanded:s,onToggleExpanded:o,isMobile:i}=n,a=t.result??"",l=a.length>1e3,c=l&&!s?a.slice(0,500)+"...":a;let d;e[0]!==a||e[1]!==t.isError||e[2]!==t.name?(d=!t.isError&&t.name!=="Read"?l1(a):null,e[0]=a,e[1]=t.isError,e[2]=t.name,e[3]=d):d=e[3];const f=d,u=f??a;let m;e[4]!==u?(m=Zk(u),e[4]=u,e[5]=m):m=e[5];const p=m,h=Math.max(0,p.length-Sf);let g;e[6]!==p||e[7]!==u||e[8]!==s?(g=s?u:p.slice(0,Sf).join(`
|
|
98
|
+
`),e[6]=p,e[7]=u,e[8]=s,e[9]=g):g=e[9];const v=g,x=i?l:h>0,w=!i||!l||s,y=i?"boxed":"unboxed";let j;e[10]!==v||e[11]!==w||e[12]!==y||e[13]!==i||e[14]!==c||e[15]!==f||e[16]!==a||e[17]!==t.input||e[18]!==t.isError||e[19]!==t.name?(j=t.name==="Read"&&!t.isError&&typeof t.input.file_path=="string"?r.jsx(Pk,{result:i?a:v,filePath:t.input.file_path,expanded:w,variant:y}):f!==null?r.jsx(pl,{result:i?f:v,expanded:w,alreadyPretty:!0,variant:y}):r.jsx("pre",{className:G(i?Jk:Xk,t.isError?G("border-destructive/20 text-destructive",i&&"bg-destructive/5"):i&&"border-border bg-muted/30 text-muted-foreground"),children:i?c:v}),e[10]=v,e[11]=w,e[12]=y,e[13]=i,e[14]=c,e[15]=f,e[16]=a,e[17]=t.input,e[18]=t.isError,e[19]=t.name,e[20]=j):j=e[20];let N;e[21]!==h||e[22]!==i||e[23]!==o||e[24]!==s||e[25]!==x?(N=x&&r.jsx("button",{type:"button",onClick:o,className:"mt-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:s?"Show less":i?"Show more":`+${h} lines`}),e[21]=h,e[22]=i,e[23]=o,e[24]=s,e[25]=x,e[26]=N):N=e[26];let S;return e[27]!==j||e[28]!==N?(S=r.jsxs("div",{className:"mt-1.5",children:[j,N]}),e[27]=j,e[28]=N,e[29]=S):S=e[29],S}function Nf(n){const e=F.c(35),{toolCall:t,isMobile:s,isAgentActive:o,displayName:i,summary:a,nameTitle:l,nameClass:c,timeLabel:d,timeIso:f}=n;let u;e[0]!==f||e[1]!==d?(u=d&&r.jsx("time",{className:"sr-only",dateTime:f,children:d}),e[0]=f,e[1]=d,e[2]=u):u=e[2];const m=s?"gap-1.5":"gap-2";let p;e[3]!==m?(p=G("flex min-w-0 flex-1 items-center",m),e[3]=m,e[4]=p):p=e[4];const h=s?"text-[10px]":"text-[11px]";let g;e[5]!==c||e[6]!==h?(g=G("shrink-0 font-mono",h,c),e[5]=c,e[6]=h,e[7]=g):g=e[7];let v;e[8]!==i||e[9]!==l||e[10]!==g?(v=r.jsx("span",{className:g,title:l,children:i}),e[8]=i,e[9]=l,e[10]=g,e[11]=v):v=e[11];let x;e[12]!==s||e[13]!==a?(x=a&&r.jsx("span",{className:G("truncate font-mono text-muted-foreground",s?"text-[11px]":"text-xs"),children:a}),e[12]=s,e[13]=a,e[14]=x):x=e[14];let w;e[15]!==p||e[16]!==v||e[17]!==x?(w=r.jsxs("div",{className:p,children:[v,x]}),e[15]=p,e[16]=v,e[17]=x,e[18]=w):w=e[18];let y;e[19]!==s||e[20]!==t.hookDurationMs?(y=t.hookDurationMs!==void 0&&t.hookDurationMs>0&&!s&&r.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",title:"PostToolUse hook duration",children:[t.hookDurationMs,"ms"]}),e[19]=s,e[20]=t.hookDurationMs,e[21]=y):y=e[21];let j;e[22]!==t.outputReplacedByHook?(j=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-blue-400",title:"Output replaced by hook",children:"hook"}),e[22]=t.outputReplacedByHook,e[23]=j):j=e[23];let N;e[24]!==o||e[25]!==t?(N=r.jsx(f1,{toolCall:t,isAgentActive:o}),e[24]=o,e[25]=t,e[26]=N):N=e[26];let S;e[27]!==j||e[28]!==N||e[29]!==y?(S=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[y,j,N]}),e[27]=j,e[28]=N,e[29]=y,e[30]=S):S=e[30];let k;return e[31]!==u||e[32]!==S||e[33]!==w?(k=r.jsxs(r.Fragment,{children:[u,w,S]}),e[31]=u,e[32]=S,e[33]=w,e[34]=k):k=e[34],k}function sC(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:n.name==="view_image"?n.input.path:null;return typeof e=="string"&&jc(e)?e:null}function kf(n){const e=F.c(4),{toolCall:t}=n,s=t.input.old_string,o=t.input.new_string,i=t.input.file_path;let a;return e[0]!==s||e[1]!==o||e[2]!==i?(a=r.jsx(Rc,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const oC={AskUserQuestion:"Question",Bash:"Command",exec:"Command",Task:"Agent",WebFetch:"Fetch",WebSearch:"Search",EnterPlanMode:"Plan mode",ExitPlanMode:"Plan review",ToolSearch:"Tool search"},m1=b.memo(function(e){var we;const t=F.c(124),{toolCall:s,expandAll:o,expandToolPayloads:i,isAgentActive:a,skillMetadata:l}=e,c=i===void 0?!1:i,{session:d,pendingInteraction:f}=st(),u=Wi(),[m,p]=b.useState(!1),[h,g]=b.useState(!1),[v,x]=b.useState(!1),[w,y]=b.useState(!1),[j,N]=b.useState(!1),[S,k]=b.useState(!1),C=b.useId(),T=b.useId(),_=b.useId(),P=b.useId(),A=b.useId(),[E,M]=b.useState(!1),I=s.result!==null||!a,R=u&&I&&!o&&!E;let D;t[0]!==s?(D=Hi(s),t[0]=s,t[1]=D):D=t[1];const L=D;let $;t[2]!==s?($=d1(s),t[2]=s,t[3]=$):$=t[3];const z=$,U=u&&L.label===s.name?oC[s.name]??s.name:L.label,O=L.label===s.name?s.name:`${L.label} (${s.name})`;let H,B,W,V,q,Y,K,J,Z,Q,se,ne,ee;if(t[4]!==P||t[5]!==j||t[6]!==w||t[7]!==U||t[8]!==o||t[9]!==c||t[10]!==m||t[11]!==a||t[12]!==z||t[13]!==R||t[14]!==u||t[15]!==O||t[16]!==f||t[17]!==L.styleName||t[18]!==L.summary||t[19]!==v||t[20]!==h||t[21]!==(d==null?void 0:d.sessionId)||t[22]!==l||t[23]!==s){ee=Symbol.for("react.early_return_sentinel");e:{const ae=u1(L.styleName,s.isError);let ve;t[37]!==s.timestamp?(ve=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[37]=s.timestamp,t[38]=ve):ve=t[38];const he=ve;let de;t[39]!==s.timestamp?(de=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[39]=s.timestamp,t[40]=de):de=t[40];const Ne=de,ke=c||u&&o;Y=ke||m,K=ke||h,q=ke||w;const Te=L.summary;let Ae;t[41]!==l||t[42]!==Te||t[43]!==s.name?(Ae=s.name==="Skill"&&l?l.get(Te)??null:null,t[41]=l,t[42]=Te,t[43]=s.name,t[44]=Ae):Ae=t[44],Z=Ae,J=Z==null?void 0:Z.filePath,B=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string",H=B?"diff":s.name==="Bash"||z?"command":"result",V=c||j;const Pe=sC(s),De=Pe!==null&&((we=s.result)==null?void 0:we.trim())==="";let ze;t[45]!==De||t[46]!==u||t[47]!==v||t[48]!==s?(ze=s.result!==null&&!De?r.jsx(nC,{toolCall:s,resultExpanded:v,onToggleExpanded:()=>x(!v),isMobile:u}):null,t[45]=De,t[46]=u,t[47]=v,t[48]=s,t[49]=ze):ze=t[49],W=ze;let Fe;t[50]!==R?(Fe=()=>{R&&M(!0)},t[50]=R,t[51]=Fe):Fe=t[51];const ue=Fe;if(s.name==="AskUserQuestion"){const Le=(f==null?void 0:f.type)==="question"&&f.toolUseId===s.id,je=d==null?void 0:d.sessionId;let fe;t[52]!==ke||t[53]!==Le||t[54]!==je||t[55]!==s?(fe=r.jsx(Sk,{toolCall:s,expandToolPayloads:ke,isAwaitingAnswer:Le,sessionId:je}),t[52]=ke,t[53]=Le,t[54]=je,t[55]=s,t[56]=fe):fe=t[56],ee=fe;break e}const le=R?"py-1":"py-1.5",Me=s.isError&&!R&&"rounded-md bg-destructive/5 px-2";t[57]!==le||t[58]!==Me?(Q=G(le,Me),t[57]=le,t[58]=Me,t[59]=Q):Q=t[59],se=R?r.jsxs(X,{type:"button",variant:"ghost",size:"xs",className:"h-auto w-full justify-start px-1 py-1 text-left",onClick:ue,"aria-label":`Expand ${U} tool call`,title:he,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[r.jsx("span",{className:G("shrink-0 font-mono text-xs",ae),title:O,children:U}),Te&&r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:Te})]}),r.jsx(et,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-end"}),r.jsx(f1,{toolCall:s,isAgentActive:a})]}):u?r.jsx("div",{className:"flex items-center gap-1.5",title:he,children:r.jsx(Nf,{toolCall:s,isMobile:!0,isAgentActive:a,displayName:U,summary:Te,nameTitle:O,nameClass:ae,timeLabel:he,timeIso:Ne})}):r.jsx("button",{type:"button",className:"flex w-full items-center gap-2 rounded-sm text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",title:he,"aria-label":`Toggle ${U} details${Te?`: ${Te}`:""}`,"aria-expanded":V,"aria-controls":P,onClick:()=>{c||N(rC)},children:r.jsx(Nf,{toolCall:s,isMobile:!1,isAgentActive:a,displayName:U,summary:Te,nameTitle:O,nameClass:ae,timeLabel:he,timeIso:Ne})}),ne=De&&!R&&r.jsx(pg,{src:Pe,alt:Pe.slice(Pe.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[4]=P,t[5]=j,t[6]=w,t[7]=U,t[8]=o,t[9]=c,t[10]=m,t[11]=a,t[12]=z,t[13]=R,t[14]=u,t[15]=O,t[16]=f,t[17]=L.styleName,t[18]=L.summary,t[19]=v,t[20]=h,t[21]=d==null?void 0:d.sessionId,t[22]=l,t[23]=s,t[24]=H,t[25]=B,t[26]=W,t[27]=V,t[28]=q,t[29]=Y,t[30]=K,t[31]=J,t[32]=Z,t[33]=Q,t[34]=se,t[35]=ne,t[36]=ee}else H=t[24],B=t[25],W=t[26],V=t[27],q=t[28],Y=t[29],K=t[30],J=t[31],Z=t[32],Q=t[33],se=t[34],ne=t[35],ee=t[36];if(ee!==Symbol.for("react.early_return_sentinel"))return ee;let ie;t[60]!==R||t[61]!==J||t[62]!==Z?(ie=Z&&!R&&r.jsxs("div",{className:"mt-1 flex items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",Z.source]}),J&&(!vs()||mc())&&r.jsxs(X,{type:"button",variant:"link",size:"xs",onClick:ae=>{ae.stopPropagation(),Vr(J)},className:"h-auto px-0 text-muted-foreground",title:J,children:[r.jsx(Jm,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[60]=R,t[61]=J,t[62]=Z,t[63]=ie):ie=t[63];let oe;t[64]!==w||t[65]!==B||t[66]!==m||t[67]!==R||t[68]!==u||t[69]!==C||t[70]!==T||t[71]!==_||t[72]!==W||t[73]!==h||t[74]!==q||t[75]!==Y||t[76]!==K?(oe=u&&!R&&r.jsxs("div",{className:"flex gap-3 mt-1",children:[B&&r.jsx(Ta,{isOpen:q,onClick:()=>y(!w),label:"Diff",controlsId:C}),r.jsx(Ta,{isOpen:Y,onClick:()=>p(!m),label:"Input",controlsId:T}),W&&r.jsx(Ta,{isOpen:K,onClick:()=>g(!h),label:"Result",controlsId:_})]}),t[64]=w,t[65]=B,t[66]=m,t[67]=R,t[68]=u,t[69]=C,t[70]=T,t[71]=_,t[72]=W,t[73]=h,t[74]=q,t[75]=Y,t[76]=K,t[77]=oe):oe=t[77];let re;t[78]!==B||t[79]!==R||t[80]!==u||t[81]!==C||t[82]!==q||t[83]!==s?(re=u&&!R&&B&&r.jsx(wt,{open:q,children:r.jsx(jt,{id:C,children:r.jsx(kf,{toolCall:s})})}),t[78]=B,t[79]=R,t[80]=u,t[81]=C,t[82]=q,t[83]=s,t[84]=re):re=t[84];let te;t[85]!==z||t[86]!==R||t[87]!==u||t[88]!==T||t[89]!==Y||t[90]!==s.input||t[91]!==s.name?(te=u&&!R&&r.jsx(wt,{open:Y,children:r.jsx(jt,{id:T,children:s.name==="Bash"&&(typeof s.input.command=="string"||typeof s.input.cmd=="string")?r.jsx(pf,{input:s.input}):z?r.jsx(gf,{input:s.input}):r.jsx(pl,{result:JSON.stringify(s.input),expanded:!0})})}),t[85]=z,t[86]=R,t[87]=u,t[88]=T,t[89]=Y,t[90]=s.input,t[91]=s.name,t[92]=te):te=t[92];let ce;t[93]!==s.id||t[94]!==s.name||t[95]!==s.result?(ce=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(Ac,{toolUseId:s.id}),t[93]=s.id,t[94]=s.name,t[95]=s.result,t[96]=ce):ce=t[96];let me;t[97]!==R||t[98]!==u||t[99]!==_||t[100]!==W||t[101]!==K?(me=u&&!R&&W&&r.jsx(wt,{open:K,children:r.jsx(jt,{id:_,children:W})}),t[97]=R,t[98]=u,t[99]=_,t[100]=W,t[101]=K,t[102]=me):me=t[102];let pe;t[103]!==A||t[104]!==S||t[105]!==P||t[106]!==H||t[107]!==B||t[108]!==u||t[109]!==W||t[110]!==V||t[111]!==s?(pe=!u&&r.jsx(wt,{open:V,children:r.jsxs(jt,{id:P,onClick:iC,children:[H==="diff"&&B&&r.jsx(kf,{toolCall:s}),H==="command"&&(s.name==="Bash"?r.jsx(pf,{input:s.input}):r.jsx(gf,{input:s.input})),(H==="result"||H==="command")&&W,r.jsx("button",{type:"button",className:"mt-1 text-[10px] text-muted-foreground/50 transition-colors hover:text-muted-foreground","aria-expanded":S,"aria-controls":A,onClick:ae=>{ae.stopPropagation(),k(aC)},children:"input"}),r.jsx(wt,{open:S,children:r.jsx(jt,{id:A,children:r.jsx(pl,{result:JSON.stringify(s.input),expanded:!0})})})]})}),t[103]=A,t[104]=S,t[105]=P,t[106]=H,t[107]=B,t[108]=u,t[109]=W,t[110]=V,t[111]=s,t[112]=pe):pe=t[112];let xe;return t[113]!==re||t[114]!==te||t[115]!==ce||t[116]!==me||t[117]!==pe||t[118]!==Q||t[119]!==se||t[120]!==ne||t[121]!==ie||t[122]!==oe?(xe=r.jsxs("div",{className:Q,children:[se,ne,ie,oe,re,te,ce,me,pe]}),t[113]=re,t[114]=te,t[115]=ce,t[116]=me,t[117]=pe,t[118]=Q,t[119]=se,t[120]=ne,t[121]=ie,t[122]=oe,t[123]=xe):xe=t[123],xe});function rC(n){return!n}function iC(n){return n.stopPropagation()}function aC(n){return!n}const lC=b.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,f]=b.useState(!0),u=o.some(j=>j.name==="AskUserQuestion"&&j.result===null),[m,p]=b.useState(null),h=b.useRef(u);b.useEffect(()=>{u&&(h.current=!0)},[u]);const g=i||d,v=i||(m??(u||h.current)),x=s==="approved"?ui:s==="rejected"?js:xs,w=g?nt:et,y=v?nt:et;return r.jsxs(wt,{open:g,onOpenChange:f,className:G("my-2 rounded-lg border",s==="approved"?"border-success/20 bg-success/5":s==="rejected"?"border-destructive/20 bg-destructive/5":"border-warning/20 bg-warning/5"),children:[r.jsxs(dn,{render:r.jsx(X,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[r.jsx(w,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(U2,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(x,{className:G("size-4",s==="approved"?"text-success":s==="rejected"?"text-destructive":"text-warning")}),r.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:s}),t&&r.jsx("span",{className:"ml-auto truncate font-mono text-xs text-muted-foreground",children:t})]}),r.jsx(jt,{children:r.jsxs("div",{className:"px-3 pb-2",children:[r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t pt-2",children:r.jsx(yn,{remarkPlugins:[yi],components:wn,children:e})}),o.length>0&&r.jsxs(wt,{open:v,onOpenChange:p,className:"mt-2",children:[r.jsxs(dn,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(y,{"data-icon":"inline-start"}),o.length," call",o.length===1?"":"s"," during planning"]}),r.jsx(jt,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(j=>r.jsx(m1,{toolCall:j,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},j.id))})})]})]})})]})}),cC=b.memo(function(e){const t=F.c(14),{content:s}=e,[o,i]=b.useState(!0),a=o?nt:et;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(X,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),t[0]=l):l=t[0];let c;t[1]!==a?(c=r.jsx(a,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[1]=a,t[2]=c):c=t[2];let d,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(W2,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),f=r.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=d,t[4]=f):(d=t[3],f=t[4]);let u;t[5]!==c?(u=r.jsxs(dn,{render:l,children:[c,d,f]}),t[5]=c,t[6]=u):u=t[6];let m;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=[yi],t[7]=m):m=t[7];let p;t[8]!==s?(p=r.jsx(jt,{children:r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t px-3 pb-2 pt-2",children:r.jsx(yn,{remarkPlugins:m,components:wn,children:s})})}),t[8]=s,t[9]=p):p=t[9];let h;return t[10]!==o||t[11]!==u||t[12]!==p?(h=r.jsxs(wt,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[u,p]}),t[10]=o,t[11]=u,t[12]=p,t[13]=h):h=t[13],h}),Ea=1;function Cf(n,e){return!e||n.length<=Ea?{visible:[...n],hidden:0}:{visible:n.slice(-Ea),hidden:n.length-Ea}}function dC(n){return`${n} earlier step${n===1?"":"s"}`}const uC=b.memo(function(e){const t=F.c(15),{blocks:s,expandAll:o}=e,[i,a]=b.useState(!1),l=o||i;if(s.length===0)return null;let c;t[0]!==o?(c=p=>{o||a(p)},t[0]=o,t[1]=c):c=t[1];let d;t[2]!==s.length||t[3]!==o||t[4]!==l?(d=!o&&r.jsxs(dn,{render:r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(et,{"data-icon":"inline-start"}),r.jsxs("span",{children:["Thinking... (",s.length," block",s.length>1?"s":"",")"]})]}),t[2]=s.length,t[3]=o,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==s?(f=s.map(fC),t[6]=s,t[7]=f):f=t[7];let u;t[8]!==f?(u=r.jsx(jt,{className:"mt-1 flex flex-col gap-2",children:f}),t[8]=f,t[9]=u):u=t[9];let m;return t[10]!==l||t[11]!==c||t[12]!==d||t[13]!==u?(m=r.jsxs(wt,{open:l,onOpenChange:c,children:[d,u]}),t[10]=l,t[11]=c,t[12]=d,t[13]=u,t[14]=m):m=t[14],m});function fC(n,e){return r.jsx("pre",{className:"text-xs text-muted-foreground/70 font-mono whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:n.thinking},e)}function $o(n,e){if(!n&&!e)return{add:0,del:0};const t=n?n.split(`
|
|
99
|
+
`):[],s=e?e.split(`
|
|
100
|
+
`):[];if(t.length===0)return{add:s.length,del:0};if(s.length===0)return{add:0,del:t.length};const o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l;if(c===0)return{add:d,del:0};if(d===0)return{add:0,del:c};let f=new Array(d+1).fill(0),u=new Array(d+1).fill(0);for(let p=1;p<=c;p++){u[0]=0;const h=t[a+p-1];for(let g=1;g<=d;g++)h===s[a+g-1]?u[g]=f[g-1]+1:u[g]=f[g]>u[g-1]?f[g]:u[g-1];[f,u]=[u,f]}const m=f[d];return{add:d-m,del:c-m}}function mC(n){let e=[];for(const a of n){if(a.isWrite){e=[{original:a.newString,current:a.newString}];continue}if(!a.oldString){e.push({original:a.oldString,current:a.newString});continue}let l=!1;for(const c of e){const d=c.current.indexOf(a.oldString);if(d!==-1){c.current=c.current.slice(0,d)+a.newString+c.current.slice(d+a.oldString.length),l=!0;break}}l||e.some(d=>d.original.includes(a.oldString)&&!d.current.includes(a.oldString))||e.push({original:a.oldString,current:a.newString})}const t=e.filter(a=>a.original!==a.current);if(t.length===0){if(n.some(l=>l.isWrite)&&e.length>0){const l=e.map(c=>c.current).join(`
|
|
101
|
+
`);if(l){const c=$o("",l);return{originalStr:"",currentStr:l,addCount:c.add,delCount:c.del}}}return{originalStr:"",currentStr:"",addCount:0,delCount:0}}const s=t.map(a=>a.original).join(`
|
|
102
|
+
`),o=t.map(a=>a.current).join(`
|
|
103
|
+
`),i=$o(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const pC=new Set(["echo","printf","true","false",":"]),hC=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),gC=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),xC=new Set(["ls","tree","du"]);function vC(n){return n.split(/\|\||&&|[|;\n]/).map(e=>e.trim()).filter(Boolean)}function bC(n){const e=vC(n);let t=!1,s=!1,o=!1,i=!1;for(const a of e){const l=a.split(/\s+/)[0];if(!(!l||pC.has(l)))if(i=!0,hC.has(l))t=!0;else if(gC.has(l))s=!0;else if(xC.has(l))o=!0;else return"shell"}return i?o?"list":t?"search":s?"read":"shell":"shell"}const yC=/[\\/]claude(?:-\d+)?[\\/](?:[^\\/]+[\\/])+scratchpad[\\/]/i;function wC(n){return yC.test(n)}const jC=new Set(["Grep","Glob"]),SC=new Set(["Bash","PowerShell"]),NC=new Set(["Edit","Write","NotebookEdit","MultiEdit"]),kC=new Set(["Task","Agent"]);function _f(n){const e=n.file_path??n.path;return typeof e=="string"?e:null}function CC(n){return typeof n.command=="string"?n.command:null}function _C(n){if(!n.startsWith("mcp__"))return null;const e=n.split("__")[1];return e?e.replace(/^claude[._]ai[._]/i,"").replace(/_/g," "):null}function TC(n,e){if(Array.isArray(e.edits)){let i=0,a=0;for(const l of e.edits){if(!l||typeof l!="object")continue;const{old_string:c,new_string:d}=l,f=$o(typeof c=="string"?c:"",typeof d=="string"?d:"");i+=f.add,a+=f.del}return{added:i,removed:a}}const t=n==="Edit"&&typeof e.old_string=="string"?e.old_string:"",s=typeof e.new_string=="string"?e.new_string:typeof e.content=="string"?e.content:typeof e.new_source=="string"?e.new_source:"",o=$o(t,s);return{added:o.add,removed:o.del}}function Ps(n,e,t=`${e}s`){return`${n} ${n===1?e:t}`}function EC(n){const e=Math.max(1,Math.floor(n/1e3));if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;if(t<60)return s>0?`${t}m ${s}s`:`${t}m`;const o=Math.floor(t/60),i=t%60;return i>0?`${o}h ${i}m`:`${o}h`}function PC(n,e={}){const t=new Set,s=new Set,o=new Set;let i=0,a=0,l=0,c=0,d=0,f=0,u=0,m=0,p=0,h=0,g=0,v=0;for(const N of n){const S=_C(N.name);if(S){p+=1,o.add(S);continue}if(NC.has(N.name)){const k=_f(N.input),C=TC(N.name,N.input);k&&wC(k)?(l+=1,c+=C.added,d+=C.removed):(t.add(k??N.id),i+=C.added,a+=C.removed);continue}if(N.name==="Read"){const k=_f(N.input);k?s.add(k):u+=1;continue}if(jC.has(N.name)){f+=1;continue}if(SC.has(N.name)){const k=CC(N.input);switch(k===null?"shell":bC(k)){case"search":f+=1;break;case"list":m+=1;break;case"read":u+=1;break;default:v+=1}continue}if(kC.has(N.name)){h+=1;continue}g+=1}const x=s.size>0?s.size:u,w=[],y=(N,S,k=0,C=0)=>{w.push(k>0||C>0?{key:N,text:S,added:k,removed:C}:{key:N,text:S})},j=e.thoughtForMs??0;if(j>0&&y("thought",`thought for ${EC(j)}`),t.size>0&&y("edit",`edited ${Ps(t.size,"file")}`,i,a),l>0&&y("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),f>0&&y("search",`searched for ${Ps(f,"pattern")}`),x>0&&y("read",`read ${Ps(x,"file")}`),m>0&&y("list",`listed ${Ps(m,"directory","directories")}`),p>0){const N=[...o].join(", ")||"MCP";y("mcp",p>1?`called ${N} ${p} times`:`called ${N}`)}return h>0&&y("agent",`ran ${Ps(h,"agent")}`),g>0&&y("other",`called ${Ps(g,"tool")}`),v>0&&y("bash",`ran ${v} shell ${v===1?"command":"commands"}`),{clauses:w}}const Tf="text-muted-foreground";function Ef(n){const e=F.c(4),{summary:t}=n;let s;e[0]!==t.clauses?(s=t.clauses.map(AC),e[0]=t.clauses,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3],o}function AC(n,e){return r.jsxs("span",{children:[e>0&&", ",e===0?n.text[0].toUpperCase()+n.text.slice(1):n.text,n.added?r.jsxs("span",{className:"text-success",children:[" +",n.added]}):null,n.removed?r.jsxs("span",{className:"text-destructive",children:[" -",n.removed]}):null]},n.key)}const Pf=b.memo(function(e){const t=F.c(35),{toolCalls:s,expandAll:o,expandToolPayloads:i,activeToolCallId:a,isAgentActive:l,activityItems:c,thinkingCount:d,thoughtForMs:f,skillMetadata:u}=e,m=l===void 0?!1:l,p=d===void 0?0:d,h=f===void 0?0:f,[g,v]=b.useState(null),x=b.useRef(null),w=m&&s.some(MC);let y;t[0]!==s?(y=s.some(RC),t[0]=s,t[1]=y):y=t[1];const j=y,N=o||j||(g??w),S=g===null&&w&&!o&&!j,k=b.useRef(null),C=b.useRef(null);let T,_;t[2]!==a||t[3]!==s?(T=()=>{if(!a){k.current=null;return}a!==k.current&&s.some(W=>W.id===a)&&(k.current=a,v(!0),C.current=requestAnimationFrame(()=>{C.current=requestAnimationFrame(()=>{var W;C.current=null,(W=x.current)==null||W.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},_=[a,s],t[2]=a,t[3]=s,t[4]=T,t[5]=_):(T=t[4],_=t[5]),b.useEffect(T,_);let P,A;t[6]===Symbol.for("react.memo_cache_sentinel")?(P=()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},A=[],t[6]=P,t[7]=A):(P=t[6],A=t[7]),b.useEffect(P,A);let E;if(t[8]!==s){const W=new Map;for(const V of s){const{label:q,styleName:Y}=Hi(V),K=W.get(q);K?(K.count=K.count+1,K.hasError=K.hasError||!!V.isError):W.set(q,{count:1,styleName:Y,hasError:!!V.isError})}E=[...W].sort(IC),t[8]=s,t[9]=E}else E=t[9];const M=E;let I;t[10]!==h||t[11]!==s?(I=PC(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=I):I=t[12];const R=I,D=function(V,q){const Y=m&&q&&V.result===null;return r.jsx("div",{ref:V.id===a?x:void 0,className:G(V.id===a&&"rounded-md ring-1 ring-ring"),children:r.jsx(m1,{toolCall:V,expandAll:o,expandToolPayloads:i,isAgentActive:Y,skillMetadata:u})},V.id)};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:D(s[0],!0)});if(N){let W;t[13]!==o||t[14]!==j||t[15]!==R||t[16]!==p?(W=!o&&!j&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>v(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(nt,{"data-icon":"inline-start"}),R.clauses.length>0?r.jsx(Ef,{summary:R}):r.jsxs("span",{className:G("font-mono text-xs",Tf),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=j,t[15]=R,t[16]=p,t[17]=W):W=t[17];const V=c?(()=>{const Y=Cf(c,S);return r.jsxs(r.Fragment,{children:[Y.hidden>0&&r.jsx(Af,{count:Y.hidden,onReveal:()=>v(!0)}),Y.visible.map((K,J)=>{if(K.kind==="thinking")return r.jsx(uC,{blocks:K.blocks,expandAll:!1},`thinking-${J}`);const Z=J===Y.visible.length-1;return K.toolCalls.map((Q,se)=>D(Q,Z&&se===K.toolCalls.length-1))})]})})():(()=>{const Y=Cf(s,S);return r.jsxs(r.Fragment,{children:[Y.hidden>0&&r.jsx(Af,{count:Y.hidden,onReveal:()=>v(!0)}),Y.visible.map((K,J)=>D(K,J===Y.visible.length-1))]})})();let q;return t[18]!==W||t[19]!==V?(q=r.jsxs("div",{className:"motion-enter flex flex-col gap-2",children:[W,V]}),t[18]=W,t[19]=V,t[20]=q):q=t[20],q}let L;t[21]===Symbol.for("react.memo_cache_sentinel")?(L=()=>v(!0),t[21]=L):L=t[21];let $;t[22]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(et,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[22]=$):$=t[22];let z;t[23]!==R?(z=R.clauses.length>0&&r.jsx(Ef,{summary:R}),t[23]=R,t[24]=z):z=t[24];let U;t[25]!==p?(U=p>0&&r.jsxs("span",{className:G("font-mono text-xs",Tf),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=U):U=t[26];let O;t[27]!==M?(O=M.map($C),t[27]=M,t[28]=O):O=t[28];let H;t[29]!==U||t[30]!==O?(H=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[U,O]}),t[29]=U,t[30]=O,t[31]=H):H=t[31];let B;return t[32]!==z||t[33]!==H?(B=r.jsxs(X,{type:"button",variant:"ghost",onClick:L,className:"motion-enter h-auto w-full items-start justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[$,r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[z,H]})]}),t[32]=z,t[33]=H,t[34]=B):B=t[34],B});function Af(n){const e=F.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(nt,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=dC(t),e[1]=t,e[2]=i):i=e[2];let a;return e[3]!==s||e[4]!==i?(a=r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground",children:[o,i]}),e[3]=s,e[4]=i,e[5]=a):a=e[5],a}function MC(n){return n.result===null}function RC(n){return n.name==="AskUserQuestion"}function IC(n,e){return e[1].count-n[1].count}function $C(n){const[e,t]=n,{count:s,styleName:o,hasError:i}=t;return r.jsxs("span",{className:G("font-mono text-xs",u1(o,i)),children:[e,s>1?` ×${s}`:""]},e)}function OC(n){const e=F.c(15),{label:t,expanded:s,onToggle:o,compact:i}=n,l=(i===void 0?!1:i)&&"min-h-9";let c;e[0]!==l?(c=G("group/fold h-auto min-h-8 w-full cursor-pointer justify-start gap-1.5 px-1 text-left text-xs font-normal text-muted-foreground",l),e[0]=l,e[1]=c):c=e[1];const d=s&&"rotate-90";let f;e[2]!==d?(f=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",d),e[2]=d,e[3]=f):f=e[3];let u;e[4]!==f?(u=r.jsx(et,{"data-icon":"inline-start",className:f}),e[4]=f,e[5]=u):u=e[5];let m;e[6]!==t?(m=r.jsx("span",{className:"tabular-nums",children:t}),e[6]=t,e[7]=m):m=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/fold:bg-border/70"}),e[8]=p):p=e[8];let h;return e[9]!==s||e[10]!==o||e[11]!==c||e[12]!==u||e[13]!==m?(h=r.jsxs(X,{type:"button",variant:"ghost",onClick:o,"aria-expanded":s,className:c,children:[u,m,p]}),e[9]=s,e[10]=o,e[11]=c,e[12]=u,e[13]=m,e[14]=h):h=e[14],h}const p1="synthesizedFrom",Mf=/[.*+?[\]{}()^$|]/,DC=/[$*?`~]|\\\s/,h1=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,LC=new RegExp(h1,"g");function g1(n,e,t,s){return{id:e,name:t,input:{...s,[p1]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function zC(n){return typeof n.input[p1]=="string"}function FC(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function Rf(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function Ki(n,e){const t=FC(n.trim());return!t||DC.test(t)?null:t.startsWith("/")?Rf(t):e?Rf(`${e}/${t}`):null}function BC(n){const e=[];let t="",s=null;function o(i){t.trim()&&e.push({text:t.trim(),piped:i}),t=""}for(let i=0;i<n.length;i++){const a=n[i];if(s){t+=a,a===s&&(s=null);continue}if(a==='"'||a==="'"){s=a,t+=a;continue}if(a==="|"){o(!0),n[i+1]==="|"&&i++;continue}if(a===";"||a==="&"&&n[i+1]==="&"){o(!1),a==="&"&&i++;continue}t+=a}return o(!1),e}function UC(n){const e=n.split(`
|
|
104
|
+
`),t=[];let s=0;for(;s<e.length;){const o=e[s];s++;const i=new Map;for(const a of o.matchAll(LC)){const[,l,c,d]=a,f=c??d,u=[];for(;s<e.length&&e[s].trim()!==f;)u.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,i.set(f,u.join(`
|
|
105
|
+
`)))}for(const a of BC(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function WC(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?Ki(t[1]??t[2]??t[3]??"",e):null}function HC(n){const e=n.match(/^tee\s+(?:(-a)\s+)?(?:"([^"]+)"|'([^']+)'|([^\s<>|;&]+))/);if(e)return e[1]?null:e[2]??e[3]??e[4]??null;if(!/^cat\b/.test(n))return null;const t=n.match(/(>>?)\s*(?:"([^"]+)"|'([^']+)'|([^\s<>|;&]+))/);return!t||t[1]===">>"?null:t[2]??t[3]??t[4]??null}function KC(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(h1);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=HC(n.text);if(!o)return null;const i=Ki(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function If(n,e){const t=e==="replacement";let s="";for(let o=0;o<n.length;o++){const i=n[o];if(i==="\\"){const a=n[o+1];if(a===void 0||a==="|"||!Mf.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&Mf.test(i))return null;s+=i}return s}const VC=/^sed\s+-i(?:\.\S+)?\s+(?:''\s+|""\s+)?(?<quote>['"])s(?<sep>.)(?<pattern>(?:(?!\k<sep>).)*)\k<sep>(?<replacement>(?:(?!\k<sep>).)*)\k<sep>(?<flags>[a-zA-Z]*)\k<quote>\s+(?:"(?<dquoted>[^"]+)"|'(?<squoted>[^']+)'|(?<bare>[^\s<>|;&]+))$/;function qC(n,e){var m;const t=(m=n.text.match(VC))==null?void 0:m.groups;if(!t)return null;const{pattern:s,replacement:o,flags:i,dquoted:a,squoted:l,bare:c}=t;if(/[^g]/.test(i))return null;const d=If(s,"pattern"),f=If(o,"replacement");if(!d||f===null)return null;const u=Ki(a??l??c??"",e);return u?{name:"Edit",input:{file_path:u,old_string:d,new_string:f,replace_all:i.includes("g")}}:null}function x1(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of UC(t)){const a=WC(i.text,o);if(a){o=a;continue}const l=KC(i,o)??qC(i,o);l&&s.push(g1(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function v1(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const o=Ki(s,e)??s,i=[];for(const[a,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:d,replace_all:f}=l;typeof c!="string"||typeof d!="string"||i.push(g1(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:f===!0}))}return i}function jo(n,e=null){const t=[];for(const s of n)s.isError||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(...v1(s,e)):s.name==="Bash"&&t.push(...x1(s,e)));return t}function Zr(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&v1(t,e).length>0||t.name==="Bash"&&x1(t,e).length>0))return!0;return!1}const GC=new Set(["tsx","jsx","ts","js","mjs","cjs","css","scss","sass","less","yaml","yml","toml","py","rs","go","html","htm","vue","svelte","sql","rb","java","kt","swift","php","c","h","cpp","cc","hpp","cs"]),YC={json:Gd,jsonc:Gd,md:la,mdx:la,txt:la,png:cs,jpg:cs,jpeg:cs,gif:cs,webp:cs,svg:cs,ico:cs,sh:br,bash:br,zsh:br,fish:br};function b1(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function XC(n){const e=b1(n);return YC[e]??(GC.has(e)?Wo:qm)}function hl(n){const e=F.c(11),{add:t,del:s,dimmed:o,className:i}=n,a=o&&"opacity-40";let l;e[0]!==i||e[1]!==a?(l=G("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",a,i),e[0]=i,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==t?(c=t>0&&r.jsxs("span",{className:"text-success",children:["+",t]}),e[3]=t,e[4]=c):c=e[4];let d;e[5]!==s?(d=s>0&&r.jsxs("span",{className:"text-destructive",children:["-",s]}),e[5]=s,e[6]=d):d=e[6];let f;return e[7]!==l||e[8]!==c||e[9]!==d?(f=r.jsxs("span",{className:l,children:[c,d]}),e[7]=l,e[8]=c,e[9]=d,e[10]=f):f=e[10],f}const $f=5;function Oc(n){const e=F.c(11),{add:t,del:s}=n,o=t+s;if(o===0)return null;let i,a,l;if(e[0]!==t||e[1]!==o){const f=Math.round(t/o*$f);i=$f-f,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:f},ZC),e[0]=t,e[1]=o,e[2]=i,e[3]=a,e[4]=l}else i=e[2],a=e[3],l=e[4];let c;e[5]!==i?(c=Array.from({length:i},JC),e[5]=i,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==l||e[9]!==c?(d=r.jsxs("span",{className:a,children:[l,c]}),e[7]=a,e[8]=l,e[9]=c,e[10]=d):d=e[10],d}function JC(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function ZC(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const Qr="cogpit:open-subagent";function y1(n){const e=F.c(3),{hasEdit:t,hasWrite:s}=n;if(t&&s){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E+W"}),e[0]=i):i=e[0],i}if(s){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("span",{className:"shrink-0 text-xs font-bold text-success",children:"W"}),e[1]=i):i=e[1],i}let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E"}),e[2]=o):o=e[2],o}function Dc(n){const e=F.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",className:"size-5 shrink-0 font-mono text-xs font-bold text-muted-foreground","aria-label":"Open sub-agent view",title:"Open sub-agent view",onClick:o=>{o.stopPropagation(),window.dispatchEvent(new CustomEvent(Qr,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const w1=b.memo(function(e){const t=F.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=Og(),[d,f]=b.useState(o),[u,m]=b.useState(o),p=b.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=ke=>{f(ke),ke?b.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let v,x;t[1]!==o?(v=()=>{p.current!==o&&(p.current=o,g(o))},x=[o,g],t[1]=o,t[2]=v,t[3]=x):(v=t[2],x=t[3]),b.useEffect(v,x);let w,y;t[4]!==i?(w=()=>{i&&g(!0)},y=[i,g],t[4]=i,t[5]=w,t[6]=y):(w=t[5],y=t[6]),b.useEffect(w,y);let j;t[7]!==s.filePath?(j=b1(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const N=j,S=s.netOriginal,k=s.netCurrent,C=!!(S||k);let T;t[9]!==s.edits?(T=s.edits.some(n_),t[9]=s.edits,t[10]=T):T=t[10];const P=a==="per-edit"?T:C,A=u&&c&&P,[E,M]=b.useState(0);let I;t[11]===Symbol.for("react.memo_cache_sentinel")?(I=ke=>{if(!ke)return;const Te=ke.offsetHeight;M(Ae=>Ae===Te?Ae:Te)},t[11]=I):I=t[11];const R=I,D=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,L=s.filePath,$=i?"border-ring ring-2 ring-ring/20":"border-border";let z;t[12]!==$?(z=G("rounded-lg border bg-card transition-colors",$),t[12]=$,t[13]=z):z=t[13];let U;t[14]!==d?(U=()=>g(!d),t[14]=d,t[15]=U):U=t[15];let O;t[16]!==d?(O=d?r.jsx(nt,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(et,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=d,t[17]=O):O=t[17];let H;t[18]!==N?(H=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:N}),t[18]=N,t[19]=H):H=t[19];let B;t[20]!==s.opTypes?(B=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=B):B=t[21];let W;t[22]!==s.opTypes?(W=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=W):W=t[23];let V;t[24]!==B||t[25]!==W?(V=r.jsx(y1,{hasEdit:B,hasWrite:W}),t[24]=B,t[25]=W,t[26]=V):V=t[26];let q;t[27]!==s.shortPath?(q=r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=q):q=t[28];let Y;t[29]!==D?(Y=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:D}),t[29]=D,t[30]=Y):Y=t[30];let K;t[31]!==s.editCount?(K=s.editCount>1&&r.jsxs(Oe,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=K):K=t[32];let J;t[33]!==d||t[34]!==U||t[35]!==O||t[36]!==H||t[37]!==V||t[38]!==q||t[39]!==Y||t[40]!==K?(J=r.jsxs(X,{type:"button",variant:"ghost",onClick:U,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":d,children:[O,H,V,q,Y,K]}),t[33]=d,t[34]=U,t[35]=O,t[36]=H,t[37]=V,t[38]=q,t[39]=Y,t[40]=K,t[41]=J):J=t[41];let Z;t[42]!==s.subAgentId?(Z=s.subAgentId&&r.jsx(Dc,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=Z):Z=t[43];let Q;t[44]!==s.filePath?(Q=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Vr(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=Q):Q=t[45];let se;t[46]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(Fo,{"data-icon":"inline-start"}),t[46]=se):se=t[46];let ne;t[47]!==Q?(ne=r.jsx(Nt,{render:Q,children:se}),t[47]=Q,t[48]=ne):ne=t[48];let ee;t[49]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx(kt,{children:"Open in editor"}),t[49]=ee):ee=t[49];let ie;t[50]!==ne?(ie=r.jsxs(St,{children:[ne,ee]}),t[50]=ne,t[51]=ie):ie=t[51];let oe;t[52]!==s.filePath?(oe=r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Vr(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=oe):oe=t[53];let re;t[54]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(H2,{"data-icon":"inline-start"}),t[54]=re):re=t[54];let te;t[55]!==oe?(te=r.jsx(Nt,{render:oe,children:re}),t[55]=oe,t[56]=te):te=t[56];let ce;t[57]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(kt,{children:"View git diff"}),t[57]=ce):ce=t[57];let me;t[58]!==te?(me=r.jsxs(St,{children:[te,ce]}),t[58]=te,t[59]=me):me=t[59];let pe;t[60]!==ie||t[61]!==me?(pe=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[ie,me]}),t[60]=ie,t[61]=me,t[62]=pe):pe=t[62];let xe;t[63]!==s.addCount?(xe=s.addCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",s.addCount]}),t[63]=s.addCount,t[64]=xe):xe=t[64];let we;t[65]!==s.delCount?(we=s.delCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",s.delCount]}),t[65]=s.delCount,t[66]=we):we=t[66];let ae;t[67]!==s.addCount||t[68]!==s.delCount?(ae=r.jsx(Oc,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=ae):ae=t[69];let ve;t[70]!==Z||t[71]!==pe||t[72]!==xe||t[73]!==we||t[74]!==ae?(ve=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Z,pe,xe,we,ae]}),t[70]=Z,t[71]=pe,t[72]=xe,t[73]=we,t[74]=ae,t[75]=ve):ve=t[75];let he;t[76]!==J||t[77]!==ve?(he=r.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-card transition-colors hover:bg-accent",children:[J,ve]}),t[76]=J,t[77]=ve,t[78]=he):he=t[78];let de;t[79]!==a||t[80]!==s.edits||t[81]!==s.filePath||t[82]!==s.netStartLine||t[83]!==P||t[84]!==E||t[85]!==k||t[86]!==S||t[87]!==d||t[88]!==A?(de=r.jsx(QC,{showDiff:A,open:d,hasDiff:P,diffRef:R,lastDiffHeight:E,oldString:S,newString:k,filePath:s.filePath,diffMode:a,edits:s.edits,netStartLine:s.netStartLine}),t[79]=a,t[80]=s.edits,t[81]=s.filePath,t[82]=s.netStartLine,t[83]=P,t[84]=E,t[85]=k,t[86]=S,t[87]=d,t[88]=A,t[89]=de):de=t[89];let Ne;return t[90]!==s.filePath||t[91]!==l||t[92]!==z||t[93]!==he||t[94]!==de?(Ne=r.jsxs("div",{ref:l,"data-file-path":L,className:z,children:[he,de]}),t[90]=s.filePath,t[91]=l,t[92]=z,t[93]=he,t[94]=de,t[95]=Ne):Ne=t[95],Ne}),QC=b.memo(function(e){const t=F.c(15),{showDiff:s,open:o,hasDiff:i,diffRef:a,lastDiffHeight:l,oldString:c,newString:d,filePath:f,diffMode:u,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==u||t[1]!==m||t[2]!==f||t[3]!==p||t[4]!==d||t[5]!==c?(h=u==="per-edit"?r.jsx(t_,{edits:m,filePath:f}):r.jsx(Rc,{oldString:c,newString:d,filePath:f,compact:!1,startLine:p,hideHeader:!0}),t[0]=u,t[1]=m,t[2]=f,t[3]=p,t[4]=d,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==u||t[8]!==a||t[9]!==h?(g=r.jsx("div",{ref:a,className:"motion-enter overflow-hidden rounded-b",children:h},u),t[7]=u,t[8]=a,t[9]=h,t[10]=g):g=t[10],g}if(o&&l>0){let h;return t[11]!==l?(h=r.jsx("div",{style:{height:l}}),t[11]=l,t[12]=h):h=t[12],h}if(o&&!i){const h=u==="per-edit"?"No edits":"No net changes (all edits cancelled out)";let g;return t[13]!==h?(g=r.jsx("div",{className:"motion-enter px-3 py-2 text-xs italic text-muted-foreground",children:h}),t[13]=h,t[14]=g):g=t[14],g}return null}),Of=3,e_=5,t_=b.memo(function(e){const t=F.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(s_),l=a.length>Of,[c,d]=b.useState(l?Of:a.length);b.useEffect(()=>{if(c>=a.length)return;const v=requestAnimationFrame(()=>{d(x=>Math.min(x+e_,a.length))});return()=>cancelAnimationFrame(v)},[c,a.length]);const f=l?a.slice(0,c):a,u="divide-y divide-border/30";let m;t[0]!==o||t[1]!==i?(m=(v,x)=>r.jsxs("div",{children:[i>1&&r.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[v.toolName," ",x+1,"/",i]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",v.turnIndex+1]}),v.agentId&&r.jsx(Dc,{agentId:v.agentId})]}),r.jsx(Rc,{oldString:v.oldString,newString:v.newString,filePath:o,compact:!1,startLine:v.startLine,hideHeader:!0})]},v.id),t[0]=o,t[1]=i,t[2]=m):m=t[2];const p=f.map(m);let h;t[3]!==a.length||t[4]!==c?(h=c<a.length&&r.jsxs("div",{className:"py-1.5 text-center text-xs text-muted-foreground",children:["Loading ",a.length-c," more edits…"]}),t[3]=a.length,t[4]=c,t[5]=h):h=t[5];let g;return t[6]!==p||t[7]!==h?(g=r.jsxs("div",{className:u,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function n_(n){return!!(n.oldString||n.newString)}function s_(n){return!!(n.oldString||n.newString)}const Pa=new Map;function o_(n){var j;const e=cn("hostFiles"),{sessionSource:t}=st(),s=t==null?void 0:t.dirName,o=Ai(s),i=n.turns.length,a=((j=n.turns.at(-1))==null?void 0:j.toolCalls.length)??0,l=b.useMemo(()=>{let N=0;for(const S of n.turns){N+=S.toolCalls.length;for(const k of S.subAgentActivity)N+=k.toolCalls.length}return N},[i,a]),c=b.useMemo(()=>{const N=[];for(let S=0;S<n.turns.length;S++)for(const k of n.turns[S].subAgentActivity){const C=o&&(k.status==="completed"||k.status==="failed"||k.status==="interrupted");(k.isBackground||C)&&k.toolCalls.length===0&&N.push({agentId:k.agentId,turnIndex:S})}return N},[n.turns,l,o]),[d,f]=b.useState(new Map),u=b.useRef(new Set);b.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const N=[];for(const{agentId:C}of c){const T=Mt(`${s}/${n.sessionId}/${C}`);if(!u.current.has(T)){if(Pa.has(T)){f(_=>{const P=new Map(_);return P.set(C,Pa.get(T)),P}),u.current.add(T);continue}N.push({agentId:C,cacheKey:T})}}if(N.length===0)return;let S=!1;async function k(){const C=new Map;await Promise.all(N.map(async({agentId:T,cacheKey:_})=>{try{const P=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(T)}.jsonl`,A=await ye(P);if(!A.ok)return;const E=await A.text(),I=Jg(E,T).flatMap(R=>jo(R.toolCalls,n.cwd));Pa.set(_,I),u.current.add(_),C.set(T,I)}catch{}})),!S&&C.size>0&&f(T=>{const _=new Map(T);for(const[P,A]of C)_.set(P,A);return _})}return k(),()=>{S=!0}},[s,n.sessionId,n.cwd,c]);const m=b.useMemo(()=>{const N=[],S=new Set;for(let k=0;k<n.turns.length;k++){const C=n.turns[k];for(const T of jo(C.toolCalls,n.cwd))N.push({turnIndex:k,toolCall:T});for(const T of C.subAgentActivity){for(const _ of jo(T.toolCalls,n.cwd))N.push({turnIndex:k,toolCall:_,agentId:T.agentId});if((T.isBackground||o)&&T.toolCalls.length===0&&!S.has(T.agentId)){S.add(T.agentId);const _=d.get(T.agentId);if(_)for(const P of _)N.push({turnIndex:k,toolCall:P,agentId:T.agentId})}}}return N},[l,n.turns,d,o]),p=b.useMemo(()=>{const N=new Set;for(const S of m){const k=j1(S.toolCall);k&&N.add(k)}return[...N]},[m]),[h,g]=b.useState(new Map);b.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let N=!1;return Promise.all(p.map(S=>ye(`/api/file-content?path=${encodeURIComponent(S)}`).then(k=>k.ok?k.text():null).then(k=>k?[S,k]:null).catch(()=>null))).then(S=>{if(N)return;const k=new Map;for(const C of S)C&&k.set(C[0],C[1]);g(k)}),()=>{N=!0}},[e,p]);const v=n.turns.length-1,x=b.useMemo(()=>ei(m,"all",h),[m,h]),w=b.useMemo(()=>ei(m,v,h),[m,v,h]),y=b.useMemo(()=>{const N=new Map;for(const S of n.turns)for(const k of S.subAgentActivity)N.has(k.agentId)||N.set(k.agentId,{name:k.agentName,type:k.subagentType});return N},[n.turns]);return{fileChanges:m,fileContents:h,groupedByFile:x,groupedLastTurn:w,lastTurnIndex:v,agentMap:y}}function Df(n,e){if(!n||!e)return 1;const t=n.indexOf(e);if(t===-1)return 1;let s=1;for(let o=0;o<t;o++)n[o]===`
|
|
106
|
+
`&&s++;return s}function j1(n){return String(n.input.file_path??n.input.path??"")}function r_(n){const e=n.name==="Edit";return{oldString:e?String(n.input.old_string??""):"",newString:String(e?n.input.new_string??"":n.input.content??""),isWrite:!e}}function ei(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=j1(i.toolCall);if(!a)continue;let l=s.get(a);l||(l=[],s.set(a,l)),l.push(i)}const o=[];for(const[i,a]of s){const l=[],c=[];let d=1/0,f=-1/0,u=!1,m=!1,p;const h=t==null?void 0:t.get(i);for(let x=0;x<a.length;x++){const w=a[x],y=r_(w.toolCall);l.push(y),w.turnIndex<d&&(d=w.turnIndex),w.turnIndex>f&&(f=w.turnIndex),w.toolCall.name==="Edit"?u=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:y.oldString,newString:y.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:Df(h,y.newString||y.oldString)})}const g=mC(l),v=[];u&&v.push("Edit"),m&&v.push("Write"),o.push({filePath:i,shortPath:i.split("/").slice(-3).join("/"),editCount:a.length,turnRange:[d,f],opTypes:v,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?Df(h,g.currentStr):c.length>0?c[0].startLine:1})}return o.sort((i,a)=>i.turnRange[1]-a.turnRange[1]||i.turnRange[0]-a.turnRange[0]||i.filePath.localeCompare(a.filePath)),o}function i_(n,e,t,s){const o=new Map;for(const a of n){if(!a.agentId||e!=="all"&&a.turnIndex!==e)continue;let l=o.get(a.agentId);l||(l=[],o.set(a.agentId,l)),l.push(a)}const i=[];for(const[a,l]of o){const c=ei(l,"all",s);if(c.length===0)continue;let d=0,f=0;for(const m of c)d+=m.addCount,f+=m.delCount;const u=t.get(a);i.push({agentId:a,agentName:(u==null?void 0:u.name)??null,subagentType:(u==null?void 0:u.type)??null,files:c,totalAdd:d,totalDel:f})}return i.sort((a,l)=>{var f,u;const c=((f=a.files[0])==null?void 0:f.turnRange[0])??0,d=((u=l.files[0])==null?void 0:u.turnRange[0])??0;return c-d}),i}const Oo="cogpit:focus-file",a_="cogpit:file-changes-prefs",l_={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function c_(n){const e=F.c(36),{group:t,allExpanded:s,highlightPath:o,diffMode:i}=n;let a;e[0]!==t.agentId||e[1]!==t.agentName?(a=t.agentName||t.agentId.slice(0,8),e[0]=t.agentId,e[1]=t.agentName,e[2]=a):a=e[2];const l=a,c=t.subagentType,d=`Open subagent ${t.agentId}`;let f;e[3]!==t.agentId?(f=()=>{window.dispatchEvent(new CustomEvent(Qr,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=f):f=e[4];let u;e[5]!==l||e[6]!==d||e[7]!==f?(u=r.jsx(X,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:d,onClick:f,children:l}),e[5]=l,e[6]=d,e[7]=f,e[8]=u):u=e[8];let m;e[9]!==c?(m=c&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==t.files.length?(p=r.jsx(Oe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:t.files.length}),e[11]=t.files.length,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"flex-1"}),e[13]=h):h=e[13];let g;e[14]!==t.totalAdd?(g=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",t.totalAdd]}),e[14]=t.totalAdd,e[15]=g):g=e[15];let v;e[16]!==t.totalDel?(v=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",t.totalDel]}),e[16]=t.totalDel,e[17]=v):v=e[17];let x;e[18]!==u||e[19]!==m||e[20]!==p||e[21]!==g||e[22]!==v?(x=r.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[u,m,p,h,g,v]}),e[18]=u,e[19]=m,e[20]=p,e[21]=g,e[22]=v,e[23]=x):x=e[23];let w;if(e[24]!==s||e[25]!==i||e[26]!==t.files||e[27]!==o){let j;e[29]!==s||e[30]!==i||e[31]!==o?(j=N=>r.jsx(w1,{file:N,defaultOpen:s,isHighlighted:o===N.filePath,diffMode:i},N.filePath),e[29]=s,e[30]=i,e[31]=o,e[32]=j):j=e[32],w=t.files.map(j),e[24]=s,e[25]=i,e[26]=t.files,e[27]=o,e[28]=w}else w=e[28];let y;return e[33]!==x||e[34]!==w?(y=r.jsxs("div",{className:"flex flex-col gap-1",children:[x,w]}),e[33]=x,e[34]=w,e[35]=y):y=e[35],y}const d_=b.memo(function({session:e,sessionChangeKey:t}){const s=b.useRef(null),o=b.useRef(null),i=b.useRef(!0),a=b.useRef(!1),l=b.useRef(0),c=b.useRef(e.turns.length),[d,f]=b.useState(!1),[u,m]=b.useState(!1),[p,h]=zi(a_,{}),g={...l_,...p},v=g.expanded,x=g.diffMode,w=g.groupByAgent,[y,j]=b.useState(g.scope),N=b.useCallback(K=>{h(J=>({...J,expanded:K}))},[h]),S=b.useCallback(K=>{h(J=>({...J,diffMode:K}))},[h]),k=b.useCallback(K=>{h(J=>({...J,groupByAgent:K}))},[h]);b.useEffect(()=>{typeof y!="number"&&h(K=>({...K,scope:y}))},[y,h]);const[C,T]=b.useState(null),_=b.useRef(null),{fileChanges:P,fileContents:A,groupedByFile:E,groupedLastTurn:M,lastTurnIndex:I,agentMap:R}=o_(e),D=b.useMemo(()=>typeof y!="number"?null:ei(P,y,A),[P,y,A]);function L(){return typeof y=="number"?D??[]:y==="all"?E:M}const $=L(),z=b.useMemo(()=>w?i_(P,typeof y=="number"?y:y==="all"?"all":I,R,A):[],[w,P,y,I,R,A]);b.useEffect(()=>{const K=J=>{const Z=J.detail;Z!=null&&Z.filePath&&(j(Z.turnIndex),T(Z.filePath),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>T(null),3e3),requestAnimationFrame(()=>{var se;const Q=(se=s.current)==null?void 0:se.querySelector(`[data-file-path="${CSS.escape(Z.filePath)}"]`);Q==null||Q.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(Oo,K),()=>{window.removeEventListener(Oo,K),_.current&&clearTimeout(_.current)}},[]);const U=b.useCallback(()=>{const K=s.current;K&&(f(K.scrollTop>10),m(K.scrollHeight-K.scrollTop-K.clientHeight>10))},[]),O=b.useCallback(()=>{const K=s.current;K&&(i.current=K.scrollHeight-K.scrollTop-K.clientHeight<50,U())},[U]);if(b.useEffect(()=>{U()},[P.length,$.length,U]),b.useEffect(()=>{const K=s.current;K&&(K.scrollTop=K.scrollHeight),i.current=!0,a.current=!1,l.current=P.length,c.current=e.turns.length,j(g.scope),T(null),U()},[t]),b.useEffect(()=>{const K=e.turns.length;K>c.current&&(a.current=!0),c.current=K},[e.turns.length]),b.useEffect(()=>{if(P.length<=l.current){l.current=P.length;return}l.current=P.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var K;(K=o.current)==null||K.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[P.length]),P.length===0)return null;let H=0,B=0,W=0;if(w)for(const K of z)H+=K.totalAdd,B+=K.totalDel,W+=K.files.length;else{for(const K of $)H+=K.addCount,B+=K.delCount;W=$.length}function V(){j(y==="last"?"all":"last")}function q(){return typeof y=="number"?`Turn ${y+1}`:y==="all"?"All turns":`Last turn (T${I+1})`}const Y=q();return r.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-card",children:[r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[r.jsx(Wo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),r.jsxs(Oe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[W," file",W!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",H]}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",B]}),r.jsxs(St,{children:[r.jsx(Nt,{render:r.jsx(X,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>k(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(Tn,{"data-icon":"inline-start"})}),r.jsx(kt,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(St,{children:[r.jsx(Nt,{render:r.jsx(X,{variant:y==="all"?"secondary":"ghost",size:"icon-xs",onClick:V,"aria-label":y==="last"?"Show all turns":"Show last turn only"}),children:y==="all"?r.jsx(K2,{"data-icon":"inline-start"}):r.jsx(xs,{"data-icon":"inline-start"})}),r.jsx(kt,{children:y==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(St,{children:[r.jsx(Nt,{render:r.jsx(X,{variant:x==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>S(x==="net"?"per-edit":"net"),"aria-label":x==="net"?"Show per-edit diffs":"Show net diff"}),children:x==="net"?r.jsx(V2,{"data-icon":"inline-start"}):r.jsx(q2,{"data-icon":"inline-start"})}),r.jsx(kt,{children:x==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(St,{children:[r.jsx(Nt,{render:r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>N(!v),"aria-label":v?"Collapse all":"Expand all"}),children:v?r.jsx(vi,{"data-icon":"inline-start"}):r.jsx(gi,{"data-icon":"inline-start"})}),r.jsx(kt,{children:v?"Collapse all":"Expand all"})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),y!=="all"&&I>0&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>{const K=typeof y=="number"?y:I;K>0&&j(K-1)},disabled:(typeof y=="number"?y:I)<=0,"aria-label":"Previous turn",children:r.jsx(Dl,{"data-icon":"inline-start"})}),r.jsx("span",{className:G("text-xs font-medium",typeof y=="number"?"text-foreground":"text-muted-foreground"),children:Y}),y!=="all"&&I>0&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>{j(K=>typeof K!="number"?K:K+1>=I?"last":K+1)},disabled:y==="last","aria-label":"Next turn",children:r.jsx(et,{"data-icon":"inline-start"})}),typeof y=="number"&&r.jsx(X,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:r.jsx(xt,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{className:G("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-background to-transparent transition-opacity duration-200",d?"opacity-100":"opacity-0")}),r.jsxs("div",{ref:s,onScroll:O,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?z.length>0?z.map(K=>r.jsx(c_,{group:K,allExpanded:v,highlightPath:C,diffMode:x},K.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):$.length>0?$.map(K=>r.jsx(w1,{file:K,defaultOpen:v,isHighlighted:C===K.filePath,diffMode:x},K.filePath)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",Y.toLowerCase()]})}),r.jsx("div",{ref:o})]}),r.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-background to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")})]})]})});function u_(n,e){const t=new Map;function s(o,i){const a=String(o.input.file_path??o.input.path??"");if(!a)return;const l=o.name==="Edit",c=l?String(o.input.old_string??""):"",d=String(l?o.input.new_string??"":o.input.content??""),f=$o(c,d),u=t.get(a)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};u.add+=f.add,u.del+=f.del,l?u.hasEdit=!0:u.hasWrite=!0,i&&(u.subAgentId=i),t.set(a,u)}return jo(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>jo(o.toolCalls,e).forEach(i=>s(i,o.agentId))),[...t.entries()].map(([o,{add:i,del:a,hasEdit:l,hasWrite:c,subAgentId:d}])=>({filePath:o,additions:i,deletions:a,hasEdit:l,hasWrite:c,subAgentId:d}))}function Lf(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function f_(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=Lf();for(const i of n){let a=i.filePath;t&&a.startsWith(t+"/")?a=a.slice(t.length+1):a.startsWith("/")&&(a=a.slice(1));const l=a.split("/");let c=s;for(let d=0;d<l.length;d++){let f=c.children.get(l[d]);f||(f=Lf(),c.children.set(l[d],f)),d===l.length-1&&(f.isFile=!0,f.absPath=i.filePath,f.additions+=i.additions,f.deletions+=i.deletions,i.hasEdit&&(f.hasEdit=!0),i.hasWrite&&(f.hasWrite=!0),i.subAgentId&&(f.subAgentId=i.subAgentId)),c=f}}function o(i,a){return[...i.children.entries()].sort(([c,d],[f,u])=>{const m=d.isFile&&d.children.size===0,p=u.isFile&&u.children.size===0;return m!==p?m?1:-1:c.localeCompare(f)}).map(([c,d])=>{const f=a?`${a}/${c}`:c;if(d.isFile&&d.children.size===0)return{name:c,fullPath:f,absPath:d.absPath,isFile:!0,additions:d.additions,deletions:d.deletions,hasEdit:d.hasEdit,hasWrite:d.hasWrite,subAgentId:d.subAgentId,children:[]};let u=d,m=c,p=f;for(;!u.isFile&&u.children.size===1;){const[j,N]=[...u.children.entries()][0];if(N.isFile&&N.children.size===0)break;m+="/"+j,p+="/"+j,u=N}const h=o(u,p);let g=0,v=0,x=u.isFile?u.hasEdit:!1,w=u.isFile?u.hasWrite:!1,y=u.isFile?u.subAgentId:null;for(const j of h)g+=j.additions,v+=j.deletions,j.hasEdit&&(x=!0),j.hasWrite&&(w=!0),j.subAgentId&&(y=j.subAgentId);return u.isFile&&(g+=u.additions,v+=u.deletions),{name:m,fullPath:p,absPath:u.absPath,isFile:!1,additions:g,deletions:v,hasEdit:x,hasWrite:w,subAgentId:y,children:h}})}return o(s,"")}const m_=b.memo(function(e){const t=F.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=cn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=u_(s,i),t[0]=i,t[1]=s,t[2]=l):l=t[2];const c=l;let d;t[3]!==i||t[4]!==c?(d=f_(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const f=d,[u,m]=b.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const M of c)p=p+M.additions,h=h+M.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const v=g;if(c.length===0)return null;const x=u&&"rotate-90";let w;t[14]!==x?(w=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",x),t[14]=x,t[15]=w):w=t[15];let y;t[16]!==w?(y=r.jsx(et,{"data-icon":"inline-start",className:w}),t[16]=w,t[17]=y):y=t[17];let j;t[18]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Wo,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=j):j=t[18];const N=c.length!==1?"s":"";let S;t[19]!==c.length||t[20]!==N?(S=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",N]}),t[19]=c.length,t[20]=N,t[21]=S):S=t[21];let k,C;t[22]!==v.add||t[23]!==v.del?(k=r.jsx(hl,{add:v.add,del:v.del,className:"opacity-80"}),C=r.jsx(Oc,{add:v.add,del:v.del}),t[22]=v.add,t[23]=v.del,t[24]=k,t[25]=C):(k=t[24],C=t[25]);let T;t[26]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/files:bg-border/70"}),t[26]=T):T=t[26];let _;t[27]!==k||t[28]!==C||t[29]!==y||t[30]!==S?(_=r.jsxs(dn,{className:"group/files flex min-h-7 w-full cursor-pointer items-center gap-1.5 rounded-md px-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[y,j,S,k,C,T]}),t[27]=k,t[28]=C,t[29]=y,t[30]=S,t[31]=_):_=t[31];let P;if(t[32]!==a||t[33]!==f||t[34]!==o){let M;t[36]!==a||t[37]!==o?(M=I=>r.jsx(p_,{node:I,depth:0,turnIndex:o,canFocusFiles:a},I.fullPath),t[36]=a,t[37]=o,t[38]=M):M=t[38],P=f.map(M),t[32]=a,t[33]=f,t[34]=o,t[35]=P}else P=t[35];let A;t[39]!==P?(A=r.jsx(jt,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:P})}),t[39]=P,t[40]=A):A=t[40];let E;return t[41]!==u||t[42]!==_||t[43]!==A?(E=r.jsxs(wt,{open:u,onOpenChange:m,children:[_,A]}),t[41]=u,t[42]=_,t[43]=A,t[44]=E):E=t[44],E}),p_=b.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=b.useState(!0),l=t*16+8;if(e.isFile){const c=XC(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(Oo,{detail:{filePath:e.absPath,turnIndex:s}}))};return r.jsxs("div",{className:"flex h-7 w-full items-center gap-1.5 font-mono text-xs",style:{paddingLeft:l},children:[r.jsxs(X,{type:"button",variant:"ghost",size:"xs",disabled:!o,className:G("h-7 min-w-0 flex-1 justify-start gap-1.5 rounded-sm px-0 font-mono text-xs font-normal disabled:opacity-100",o&&"cursor-pointer"),onClick:d,title:o?"Click to focus in sidebar":void 0,children:[r.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(y1,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Dc,{agentId:e.subAgentId}),r.jsx(hl,{add:e.additions,del:e.deletions}),r.jsx(Oc,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(X,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-full justify-start gap-1 rounded-sm font-mono text-xs font-normal",style:{paddingLeft:l},onClick:()=>a(!i),"aria-expanded":i,children:[i?r.jsx(nt,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(et,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(G2,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-foreground/70",children:e.name}),r.jsx("div",{className:"flex-1 min-w-2"}),!i&&r.jsx(hl,{add:e.additions,del:e.deletions,dimmed:!0})]}),i&&e.children.map(c=>r.jsx(n,{node:c,depth:t+1,turnIndex:s,canFocusFiles:o},c.fullPath))]})});function h_(n){const e=F.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let o;e[0]!==s?(o=r.jsx(X,{variant:"ghost",size:"xs",onClick:u=>{u.stopPropagation(),s()},className:"h-6 text-muted-foreground"}),e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ll,{"data-icon":"inline-start"}),e[2]=i):i=e[2];let a;e[3]!==t?(a=r.jsx("span",{className:"font-mono text-xs",children:t}),e[3]=t,e[4]=a):a=e[4];let l;e[5]!==o||e[6]!==a?(l=r.jsxs(Nt,{render:o,children:[i,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7];const c=t!==1?"es":"";let d;e[8]!==t||e[9]!==c?(d=r.jsxs(kt,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=r.jsxs(St,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}const S1="<task-notification>",g_=/<task-id>([^<]+)<\/task-id>/g,x_=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Rt(n){return typeof n=="object"&&n!==null}function v_(n){const e=Rt(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Rt(s)&&typeof s.text=="string").map(s=>s.text):[]}function b_(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes(S1)){for(const c of a.matchAll(g_))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(x_))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=Rt(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Rt(a.message)?a.message:null,f=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Rt(p)&&p.type==="tool_result").map(p=>p.tool_use_id),u=[l.agentId,l.taskId,...f].filter(p=>typeof p=="string"&&p.length>0),m=[l.description,l.workflowName,l.summary].find(p=>typeof p=="string"&&p.length>0)??"";u.length>0&&e.push({ids:u,description:m})}for(const c of v_(a))i(c,o);continue}if(a.type==="assistant"){const l=Rt(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!Rt(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const f=Rt(d.input)?d.input:null,u=(f==null?void 0:f.task_id)??(f==null?void 0:f.shell_id);typeof u=="string"&&t.add(u)}continue}if(a.type==="attachment"){const l=Rt(a.attachment)?a.attachment:null;typeof(l==null?void 0:l.prompt)=="string"&&i(l.prompt,o);continue}if(a.type==="queue-operation"&&typeof a.content=="string"){const l=a.operation;i(a.content,l==="enqueue"?s:o)}}return{pendingDescriptions:e.filter(a=>!a.ids.some(l=>t.has(l))).map(a=>a.description),undeliveredNotifications:[...s].filter(a=>!o.has(a)).length}}function N1(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function k1(n){var l,c,d;const e=(l=n[0])==null?void 0:l.type;if(e==="session_meta"||e==="turn_context"||e==="event_msg"||e==="response_item")return S_(n);let t=0,s=null,o=!1;function i(f,u){const m={status:f,pendingQueue:Math.max(0,t)};return u&&(m.toolName=u),m}function a(){return s??(s=b_(n))}for(let f=n.length-1;f>=0;f--){const u=n[f];if(u.type!=="queue-operation"){if(u.type==="progress"){const m=u.data;if((m==null?void 0:m.type)==="hook_progress"&&(m.decision??((c=m.hookSpecificOutput)==null?void 0:c.permissionDecision))==="defer")return i("deferred");break}break}}for(let f=n.length-1;f>=0;f--){const u=n[f];if(u.type==="queue-operation"){if(typeof u.content=="string"&&u.content.includes(S1))continue;const m=u.operation;m==="enqueue"?t++:(m==="dequeue"||m==="remove")&&t--;continue}if(u.type==="attachment"){const m=Rt(u.attachment)?u.attachment:null;(m==null?void 0:m.commandMode)==="task-notification"&&(o=!0);continue}if(u.type==="assistant"){const m=u.message,p=m==null?void 0:m.stop_reason;if(p==="end_turn"){const h=a();if(o||h.undeliveredNotifications>0)return i("processing");if(h.pendingDescriptions.length>0)return N1(h.pendingDescriptions,Math.max(0,t));let g=!1;for(let v=f-1;v>=0;v--){const x=n[v];if(x.type==="user"&&!x.isMeta){g=!0;break}}return i(g?"completed":"idle")}if(p==="tool_use"){const h=m==null?void 0:m.content,g=(d=h==null?void 0:h.findLast)==null?void 0:d.call(h,v=>v.type==="tool_use");return i("tool_use",g==null?void 0:g.name)}return i("thinking")}if(u.type==="user"){if(u.isMeta)continue;return i("processing")}if(u.type==="system"&&u.subtype==="terminal_reason"){const m=u.reason;if(m)return{status:"completed",terminalReason:m,pendingQueue:Math.max(0,t)};continue}u.type!=="summary"&&u.type==="system"&&u.subtype}return{status:"idle"}}const y_=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function w_(n){const e=n.content;return Array.isArray(e)?e.filter(t=>Rt(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
107
|
+
`):""}function _r(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return Rt(e)?e:null}catch{return null}}function j_(n){var c,d;const e=new Map,t=new Set,s=new Map,o=new Map,i=new Set,a=new Map;function l(f,u){t.has(f)||e.set(f,e.get(f)||u)}for(const f of n){const u=Rt(f.payload)?f.payload:null;if(u){if(f.type==="event_msg"&&u.type==="sub_agent_activity"&&typeof u.agent_thread_id=="string"&&typeof u.agent_path=="string"){const m=u.agent_thread_id,p=typeof u.kind=="string"?u.kind:"started",h=typeof u.event_id=="string"?u.event_id:"",g=s.get(u.agent_path),v=e.has(m)||t.has(m)||g!==void 0||o.has(h);if(p!=="started"&&!v)continue;g&&g!==m&&(e.has(g)&&(l(m,e.get(g)??""),e.delete(g)),t.has(g)&&t.add(m)),s.set(u.agent_path,m),p==="interrupted"?(t.add(m),e.delete(m)):l(m,o.get(h)??"");continue}if(f.type==="response_item"){if(u.type==="function_call"&&typeof u.call_id=="string"){const m=Xl(typeof u.name=="string"?u.name:"");if(m==="spawn_agent"){const p=_r(u.arguments);o.set(u.call_id,typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"")}else if(m==="wait_agent")i.add(u.call_id);else if(m==="interrupt_agent"){const p=_r(u.arguments),h=[p==null?void 0:p.agent_id,...Array.isArray(p==null?void 0:p.agent_ids)?p.agent_ids:[]].filter(g=>typeof g=="string");a.set(u.call_id,h)}continue}if(u.type==="function_call_output"&&typeof u.call_id=="string"){const m=u.call_id;if(o.has(m)){const p=_r(u.output),h=typeof(p==null?void 0:p.agent_id)=="string"?p.agent_id:"";if(h){l(h,o.get(m)??"");const g=typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"";g&&!s.has(g)&&s.set(g,h)}}else if(i.has(m)){const p=_r(u.output),h=Rt(p==null?void 0:p.status)?p.status:{};for(const[g,v]of Object.entries(h)){const x=Rt(v)?v:{},w=typeof x.status=="string"?x.status:"";(typeof x.completed=="string"||typeof x.failed=="string"||typeof x.error=="string"||typeof x.interrupted=="string"||w==="completed"||w==="failed"||w==="interrupted")&&(t.add(g),e.delete(g))}}else if(a.has(m))for(const p of a.get(m)??[])t.add(p),e.delete(p);continue}if(u.type==="agent_message"&&typeof u.author=="string"){const p=((d=(c=w_(u).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!y_.has(p))continue;const h=s.get(u.author)??u.author;t.add(h),e.delete(h)}}}}return[...e.entries()].filter(([f])=>!t.has(f)).map(([,f])=>f)}function S_(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="event_msg"){const s=t.payload;switch(s==null?void 0:s.type){case"task_complete":{const o=j_(n);return o.length>0?N1(o,0):{status:"completed"}}case"task_started":return{status:"processing"};case"agent_message":return{status:"thinking"};case"token_count":continue}}if(t.type==="response_item"){const s=t.payload;if(!s)continue;if(s.type==="function_call")return{status:"tool_use",toolName:s.name?Xl(s.name):s.name};if(s.type==="message"){if(s.role==="assistant")return{status:"thinking"};if(s.role==="user")return{status:"processing"}}}}return{status:"idle"}}const N_=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Lc(n){switch(n){case"max_turns":return"Stopped — turn limit reached";case"aborted_tools":return"Stopped — tools aborted";case"blocking_limit":return"Stopped — blocked";default:return`Stopped — ${n.replace(/_/g," ")}`}}function ir(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&N_.has(e)?"Running agents...":e?`Using ${e}`:"Using tool...";case"processing":return"Processing...";case"compacting":return"Compressing context...";case"deferred":return"Awaiting permission review";case"awaiting_agents":return s&&s>0?`Waiting on ${s} agent${s===1?"":"s"}...`:"Waiting on agents...";case"completed":return t?Lc(t):"Done";default:return null}}function k_(n){const e=F.c(6),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(X2,{className:"size-5 text-warning"}),e[0]=s):s=e[0],s}case"tool_use":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Zs,{className:"size-5 text-info"}),e[1]=s):s=e[1],s}case"processing":{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Y2,{className:"size-5 text-warning"}),e[2]=s):s=e[2],s}case"compacting":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(vi,{className:"size-5 text-warning"}),e[3]=s):s=e[3],s}case"awaiting_agents":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(zo,{className:"size-5 text-info"}),e[4]=s):s=e[4],s}case"completed":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(_n,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const zf=2e3,C1=600;function _1(n){const e=F.c(28),{status:t,label:s,fading:o,startTimestamp:i}=n,a=o===void 0?!1:o,l=t.status==="completed";let c;e[0]!==t.pendingAgentDescriptions?(c=t.pendingAgentDescriptions??[],e[0]=t.pendingAgentDescriptions,e[1]=c):c=e[1];const d=c,f=a?"opacity-0":"opacity-100";let u;e[2]!==f?(u=G("flex items-center gap-2.5 min-w-0 transition-opacity",f),e[2]=f,e[3]=u):u=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m={transitionDuration:`${C1}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(k_,{status:t.status}),e[5]=t.status,e[6]=p):p=e[6];const h=!l&&"text-muted-foreground",g=l&&t.terminalReason&&"text-warning",v=l&&!t.terminalReason&&"text-success";let x;e[7]!==h||e[8]!==g||e[9]!==v?(x=G("text-xs font-medium shrink-0",h,g,v),e[7]=h,e[8]=g,e[9]=v,e[10]=x):x=e[10];let w;e[11]!==s||e[12]!==x?(w=r.jsx("span",{className:x,children:s}),e[11]=s,e[12]=x,e[13]=w):w=e[13];let y;e[14]!==l||e[15]!==i?(y=!l&&i&&r.jsx(zc,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=y):y=e[16];let j;e[17]!==d?(j=d.length>0&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",title:d.join(`
|
|
108
|
+
`),children:d.join(" · ")}),e[17]=d,e[18]=j):j=e[18];let N;e[19]!==t.pendingQueue?(N=(t.pendingQueue??0)>0&&r.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[19]=t.pendingQueue,e[20]=N):N=e[20];let S;return e[21]!==w||e[22]!==y||e[23]!==j||e[24]!==N||e[25]!==u||e[26]!==p?(S=r.jsxs("div",{className:u,style:m,children:[p,w,y,j,N]}),e[21]=w,e[22]=y,e[23]=j,e[24]=N,e[25]=u,e[26]=p,e[27]=S):S=e[27],S}function C_(n){const e=F.c(28),{status:t,durationLabel:s}=n,[o,i]=b.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),zf),g=setTimeout(()=>i("ready"),zf+C1);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),b.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(_n,{className:"size-4 shrink-0 text-success"}),e[2]=h):h=e[2];const g=t.terminalReason?"text-warning":"text-muted-foreground";let v;e[3]!==g?(v=G("text-xs font-medium",g),e[3]=g,e[4]=v):v=e[4];let x;e[5]!==t.terminalReason?(x=t.terminalReason?Lc(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=x):x=e[6];let w;e[7]!==v||e[8]!==x?(w=r.jsx("span",{className:v,children:x}),e[7]=v,e[8]=x,e[9]=w):w=e[9];let y;e[10]!==s?(y=s&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=y):y=e[11];let j;return e[12]!==w||e[13]!==y?(j=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,y]}),e[12]=w,e[13]=y,e[14]=j):j=e[14],j}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=ir(t.status,t.toolName,t.terminalReason)??"Done",e[15]=t.status,e[16]=t.terminalReason,e[17]=t.toolName,e[18]=c):c=e[18];const d=c,f=o==="fading";let u;e[19]!==d||e[20]!==t||e[21]!==f?(u=r.jsx(_1,{status:t,label:d,fading:f}),e[19]=d,e[20]=t,e[21]=f,e[22]=u):u=e[22];let m;e[23]!==s?(m=s&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:["in ",s]}),e[23]=s,e[24]=m):m=e[24];let p;return e[25]!==u||e[26]!==m?(p=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[u,m]}),e[25]=u,e[26]=m,e[27]=p):p=e[27],p}const __=b.memo(function(){const e=F.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=st(),[l,c]=b.useState(!1),[d,f]=b.useState(!1),u=t==null?void 0:t.sessionId,[m,p]=b.useState(u);u!==m&&(p(u),c(!1),f(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={status:"compacting"},e[0]=M):M=e[0],h=M;break e}const A=t.rawMessages;let E;e[1]!==A?(E=k1(A),e[1]=A,e[2]=E):E=e[2],h=E}const g=h;let v,x;e[3]!==g||e[4]!==s||e[5]!==d?(v=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!d&&c(!0);return}if(g.status==="completed"){f(!0);return}c(!1),f(!1)}},x=[g,s,d],e[3]=g,e[4]=s,e[5]=d,e[6]=v,e[7]=x):(v=e[6],x=e[7]),b.useEffect(v,x);let w;e:{if(!g){w=null;break e}if(g.status==="compacting"){w=g;break e}if(g.status==="completed"){if(l){w=null;break e}if(!s&&!d){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const y=w,j=(y==null?void 0:y.status)==="completed",N=(t==null?void 0:t.turns[t.turns.length-1])??null;let S;e:{if(!j||!N){S=null;break e}let A;if(e[8]!==N){const E=Hl(N);A=E!==null?vn(E):null,e[8]=N,e[9]=A}else A=e[9];S=A}const k=S;if(a&&o==="connected"){let A;e[10]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(Zm,{className:"size-5 shrink-0 text-info"}),e[10]=A):A=e[10];const E=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let M;return e[11]!==E?(M=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[A,r.jsx("span",{className:"text-xs font-medium text-info",children:E})]}),e[11]=E,e[12]=M):M=e[12],M}if(!y)return null;if(j){let A;return e[13]!==y||e[14]!==k?(A=r.jsx(C_,{status:y,durationLabel:k}),e[13]=y,e[14]=k,e[15]=A):A=e[15],A}let C;e[16]!==y.pendingAgents||e[17]!==y.status||e[18]!==y.terminalReason||e[19]!==y.toolName?(C=ir(y.status,y.toolName,y.terminalReason,y.pendingAgents),e[16]=y.pendingAgents,e[17]=y.status,e[18]=y.terminalReason,e[19]=y.toolName,e[20]=C):C=e[20];const T=C;if(!T)return null;const _=N==null?void 0:N.timestamp;let P;return e[21]!==y||e[22]!==T||e[23]!==_?(P=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(_1,{status:y,label:T,startTimestamp:_})}),e[21]=y,e[22]=T,e[23]=_,e[24]=P):P=e[24],P});function zc(n){const e=F.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(T_,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function T_(n){const e=F.c(12),{startTimestamp:t,className:s}=n;let o;e[0]!==t?(o=new Date(t).getTime(),e[0]=t,e[1]=o):o=e[1];const i=o,a=b.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=vn(Math.max(0,Date.now()-i)))},1e3);return()=>clearInterval(h)},c=[i],e[2]=i,e[3]=l,e[4]=c):(l=e[3],c=e[4]),b.useEffect(l,c);let d;e[5]!==s?(d=G("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=d):d=e[6];const f=Math.max(0,Date.now()-i);let u;e[7]!==f?(u=vn(f),e[7]=f,e[8]=u):u=e[8];let m;return e[9]!==d||e[10]!==u?(m=r.jsx("span",{ref:a,className:d,children:u}),e[9]=d,e[10]=u,e[11]=m):m=e[11],m}function E_(n,e){var s;if(!e)return!0;const t=e.toLowerCase();if(n.userMessage&&(typeof n.userMessage=="string"?n.userMessage:JSON.stringify(n.userMessage)).toLowerCase().includes(t))return!0;for(const o of n.assistantText)if(o.toLowerCase().includes(t))return!0;for(const o of n.contentBlocks)if(o.kind==="queued_prompt"&&o.content.toLowerCase().includes(t)||o.kind==="agent_message"&&(o.sender.toLowerCase().includes(t)||o.body.toLowerCase().includes(t)))return!0;for(const o of n.thinking)if(o.thinking.toLowerCase().includes(t))return!0;for(const o of n.toolCalls)if(o.name.toLowerCase().includes(t)||JSON.stringify(o.input).toLowerCase().includes(t)||(s=o.result)!=null&&s.toLowerCase().includes(t))return!0;return!1}const P_=6e5;function A_(n,e){const t=n[e].timestamp,s=e>0?n[e-1].timestamp:void 0;if(!t||!s)return 0;const o=Date.parse(t)-Date.parse(s);return!Number.isFinite(o)||o<=0?0:Math.min(o,P_)}function Ff(n,e){const t=[],s=[];let o=0,i=0,a=e;for(;a<n.length;){const l=n[a];if(l.kind==="thinking")t.push({kind:"thinking",blocks:l.blocks}),o+=l.blocks.length,i+=A_(n,a),a++;else if(l.kind==="tool_calls")t.push({kind:"tool_calls",toolCalls:l.toolCalls}),s.push(...l.toolCalls),a++;else break}return{items:t,toolCalls:s,thinkingCount:o,thoughtForMs:i,nextIndex:a}}const gl=new Map,M_=300*1e3;function Bf(n){const e=gl.get(n);return e?Date.now()>e.expiresAt?(gl.delete(n),null):e.data:null}function R_(n,e){gl.set(n,{data:e,expiresAt:Date.now()+M_})}function I_(n){const e=F.c(5);let t;e[0]!==n?(t=()=>n?Bf(Mt(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=b.useState(t),i=b.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||Ri(window.location.pathname))return;const c=Mt(n),d=Bf(c);if(d){o(d);return}i.current=n;const f=new AbortController;return ye(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:f.signal}).then(async u=>{if(f.signal.aborted||i.current!==n||!u.ok)return;const m=await u.json();if(f.signal.aborted||i.current!==n)return;const p=new Map;for(const h of m.suggestions??[])h.type==="skill"&&p.set(h.name,{source:h.source,description:h.description,filePath:h.filePath});R_(c,p),o(p)}).catch($_),()=>f.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),b.useEffect(a,l),s}function $_(){}const O_=new Set(["queued_prompt","agent_message","plan_mode","recap"]),D_=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),L_=new Set(["AskUserQuestion","ExitPlanMode"]),z_=new Set(["text","thinking","tool_calls"]);function F_(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>L_.has(e.name)&&e.result==null)}function B_(n){for(let e=n.length-1;e>=0;e--){if(F_(n[e]))return e;if(z_.has(n[e].kind))return-1}return-1}const Tr={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function U_(n,e="settled"){if(n.length===0||!n.some(a=>D_.has(a.kind)))return Tr;let t=-1;if(e==="settled"){for(let a=n.length-1;a>=0;a--)if(n[a].kind==="text"){t=a;break}if(t===-1)return Tr}const s=B_(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];O_.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?Tr:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function W_(n,e){return n!==null&&n>0?`Worked for ${vn(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const T1="border border-border bg-prompt-surface",Uf="border-l border-border/40",Wf="border-l border-border";function E1(n){const e=F.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=Ct(),{activeTurnIndex:c,activeToolCallId:d,expandAll:f,expandToolPayloads:u}=a,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:v}=st(),x=p&&m!==null,w=x&&s===((m==null?void 0:m.turns.length)??0)-1;let y=!w;if(w&&m){let T;if(e[0]!==m.rawMessages){const{status:_}=k1(m.rawMessages);T=Tc.has(_),e[0]=m.rawMessages,e[1]=T}else T=e[1];y=!T}const j=(m==null?void 0:m.cwd)??"",N=I_(j),S=c===s,k=!g.enabled||h?void 0:g.requestUndo;let C;return e[2]!==v.handleEditCommand||e[3]!==v.handleExpandCommand||e[4]!==v.handleOpenBranches||e[5]!==d||e[6]!==i||e[7]!==j||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==w||e[12]!==l||e[13]!==x||e[14]!==y||e[15]!==N||e[16]!==S||e[17]!==k||e[18]!==t?(C=r.jsx(K_,{turn:t,index:s,branchCount:i,isActive:S,activeToolCallId:d,expandAll:f,expandToolPayloads:u,isAgentActive:w,isSessionLive:x,isTurnDone:y,isMobile:l,cwd:j,skillMetadata:N,onRestoreToHere:k,onOpenBranches:v.handleOpenBranches,onEditCommand:v.handleEditCommand,onExpandCommand:v.handleExpandCommand}),e[2]=v.handleEditCommand,e[3]=v.handleExpandCommand,e[4]=v.handleOpenBranches,e[5]=d,e[6]=i,e[7]=j,e[8]=f,e[9]=u,e[10]=s,e[11]=w,e[12]=l,e[13]=x,e[14]=y,e[15]=N,e[16]=S,e[17]=k,e[18]=t,e[19]=C):C=e[19],C}function H_(n){const e=F.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:o}=n;if(s){let a;return e[0]!==o||e[1]!==t?(a=W_(Hl(t),o),e[0]=o,e[1]=t,e[2]=a):a=e[2],a}if(!t.timestamp)return"Working";let i;return e[3]!==t.timestamp?(i=r.jsxs("span",{className:"inline-flex items-baseline gap-1",children:["Working for",r.jsx(zc,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const K_=b.memo(function({turn:e,index:t,branchCount:s,isActive:o,activeToolCallId:i,expandAll:a,expandToolPayloads:l,isAgentActive:c,isSessionLive:d,isTurnDone:f,isMobile:u,cwd:m,skillMetadata:p,onRestoreToHere:h,onOpenBranches:g,onEditCommand:v,onExpandCommand:x}){const{ref:w,isNear:y}=Og(),j=b.useRef(null),N=b.useRef(0);b.useLayoutEffect(()=>{y&&j.current&&(N.current=j.current.offsetHeight)},[y]);const S=Zr(e.toolCalls,m)||e.subAgentActivity.some(M=>Zr(M.toolCalls,m)),k=f?"settled":"working",C=b.useMemo(()=>U_(e.contentBlocks,k),[k,e.contentBlocks]),[T,_]=b.useState(void 0),P=T??(a||!f),{leadingBlocks:A,trailingBlocks:E}=b.useMemo(()=>{if(!C.foldable)return{leadingBlocks:[],trailingBlocks:[]};const M=C.foldAnchorIndex,I=new Set(C.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,M),trailingBlocks:e.contentBlocks.slice(M).filter((R,D)=>P||!I.has(M+D))}},[C,e.contentBlocks,P]);return r.jsxs("div",{ref:w,"data-turn-index":t,className:G("group relative",u?"px-1 py-3":"px-4 py-5",o&&"rounded-lg ring-1 ring-ring/40"),children:[r.jsx(q_,{index:t,turn:e,branchCount:s,isTurnDone:f,isMobile:u,onRestoreToHere:h,onOpenBranches:g}),y?r.jsxs("div",{ref:j,className:G("flex flex-col",u?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx("div",{"data-turn-prompt":!0,className:G(u?"rounded-lg p-2.5":"rounded-lg p-3",T1),children:r.jsx(Nc,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:v,onExpandCommand:x,compact:u})}),C.foldable?r.jsxs(r.Fragment,{children:[A.length>0&&r.jsx(Aa,{blocks:A,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),r.jsx(OC,{label:r.jsx(H_,{turn:e,isTurnDone:f,hiddenToolCalls:C.hiddenToolCalls}),expanded:P,onToggle:()=>_(!P),compact:u}),E.length>0&&r.jsx(Aa,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p})]}):r.jsx(Aa,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),f&&S&&r.jsx(m_,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:N.current||V_(e)}})]})});function V_(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function q_(n){const e=F.c(26),{index:t,turn:s,branchCount:o,isTurnDone:i,isMobile:a,onRestoreToHere:l,onOpenBranches:c}=n,d=!i&&!!s.timestamp;let f;e[0]!==i||e[1]!==s?(f=i?Hl(s):null,e[0]=i,e[1]=s,e[2]=f):f=e[2];const u=f,m=a?"mb-2 gap-1.5":"mb-4 gap-2";let p;e[3]!==m?(p=G("flex items-center",m),e[3]=m,e[4]=p):p=e[4];const h=a?`Turn ${t+1}`:t+1;let g;e[5]!==h?(g=r.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h}),e[5]=h,e[6]=g):g=e[6];let v;e[7]!==u||e[8]!==d||e[9]!==s.timestamp?(v=r.jsx(G_,{durationMs:u,showLiveTimer:d,timestamp:s.timestamp}),e[7]=u,e[8]=d,e[9]=s.timestamp,e[10]=v):v=e[10];let x;e[11]!==t||e[12]!==a||e[13]!==l?(x=l&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:G("ml-auto text-muted-foreground transition-opacity hover:text-foreground",a?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[r.jsx(zl,{"data-icon":"inline-start"}),r.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=a,e[13]=l,e[14]=x):x=e[14];let w;e[15]!==o||e[16]!==t||e[17]!==c||e[18]!==l?(w=o>0&&c&&r.jsx("div",{className:G(!l&&"ml-auto"),children:r.jsx(h_,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let y;return e[20]!==p||e[21]!==g||e[22]!==v||e[23]!==x||e[24]!==w?(y=r.jsxs("div",{className:p,children:[g,v,x,w]}),e[20]=p,e[21]=g,e[22]=v,e[23]=x,e[24]=w,e[25]=y):y=e[25],y}function G_(n){const e=F.c(8),{durationMs:t,showLiveTimer:s,timestamp:o}=n;if(t!==null){let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(xs,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=vn(t),e[1]=t,e[2]=a):a=e[2];let l;return e[3]!==a?(l=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[i,a]}),e[3]=a,e[4]=l):l=e[4],l}if(s){let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(xs,{className:"size-3","data-icon":"inline-start"}),e[5]=i):i=e[5];let a;return e[6]!==o?(a=r.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[i,r.jsx(zc,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function Y_(n){var e,t,s;switch(n.kind){case"tool_calls":return((e=n.toolCalls[0])==null?void 0:e.id)??null;case"sub_agent":case"background_agent":return((t=n.messages[0])==null?void 0:t.parentToolUseId)??((s=n.messages[0])==null?void 0:s.agentId)??null;default:return n.timestamp??null}}function Aa(n){const e=F.c(11),{blocks:t,model:s,effort:o,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:u}=n;let m;if(e[0]!==l||e[1]!==t||e[2]!==o||e[3]!==i||e[4]!==a||e[5]!==c||e[6]!==f||e[7]!==d||e[8]!==s||e[9]!==u){const p=[],h=f?"ml-0 pl-2":"ml-1 pl-3",g=f?"gap-2":"gap-3",v=new Map,x=(y,j)=>{const N=Y_(y)??`at-${j}`,S=v.get(N)??0;return v.set(N,S+1),S===0?N:`${N}#${S}`};let w=0;for(;w<t.length;){const y=t[w];if(y.kind==="thinking"||y.kind==="tool_calls"){const{items:j,toolCalls:N,thinkingCount:S,thoughtForMs:k,nextIndex:C}=Ff(t,w),T=j.length===1&&j[0].kind==="tool_calls";p.push(r.jsx("div",{className:G(Uf,h),children:r.jsx(Pf,{toolCalls:N,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:T?void 0:j,thinkingCount:S,thoughtForMs:k,skillMetadata:u})},x(y,w))),w=C;continue}if(y.kind==="text"){const{items:j,toolCalls:N,thinkingCount:S,thoughtForMs:k,nextIndex:C}=Ff(t,w+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:G("flex flex-col",g),children:y.text.map((T,_)=>r.jsx(wN,{text:T,model:s,effort:o,timestamp:y.timestamp,compact:f},_))}),(N.length>0||S>0)&&r.jsx("div",{className:G("mt-1.5",Uf,h),children:r.jsx(Pf,{toolCalls:N,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:S>0?j:void 0,thinkingCount:S,thoughtForMs:k,skillMetadata:u})})]},x(y,w))),w=C;continue}if(y.kind==="queued_prompt"){p.push(r.jsxs("div",{className:G(f?"rounded-lg p-2.5":"rounded-lg p-3",T1),children:[r.jsx(Oe,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(Nc,{content:y.content,timestamp:y.timestamp??"",compact:f})]},x(y,w))),w++;continue}if(y.kind==="agent_message"){p.push(r.jsx(vN,{sender:y.sender,body:y.body,reply:y.reply,timestamp:y.timestamp,isLive:d},x(y,w))),w++;continue}if(y.kind==="sub_agent"){p.push(r.jsx("div",{className:G(Wf,h),children:r.jsx(FN,{messages:y.messages,expandAll:i})},x(y,w))),w++;continue}if(y.kind==="background_agent"){p.push(r.jsx("div",{className:G(Wf,h),children:r.jsx(BN,{messages:y.messages,expandAll:i})},x(y,w))),w++;continue}if(y.kind==="hook_event"){p.push(r.jsx(WN,{events:y.events},x(y,w))),w++;continue}if(y.kind==="plan_mode"){p.push(r.jsx(lC,{plan:y.plan,planFilePath:y.planFilePath,status:y.status,toolCalls:y.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:u},x(y,w))),w++;continue}if(y.kind==="recap"){p.push(r.jsx(cC,{content:y.content,timestamp:y.timestamp},x(y,w))),w++;continue}w++}m=r.jsx(r.Fragment,{children:p}),e[0]=l,e[1]=t,e[2]=o,e[3]=i,e[4]=a,e[5]=c,e[6]=f,e[7]=d,e[8]=s,e[9]=u,e[10]=m}else m=e[10];return m}function X_(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${tt(n.preTokens)} → ${tt(n.postTokens)}`:`${e} · ${tt(n.preTokens)}`}const J_=b.memo(function(e){const t=F.c(30),{summary:s,meta:o}=e,[i,a]=b.useState(!1);let l;t[0]!==o?(l=X_(o),t[0]=o,t[1]=l):l=t[1];const c=l;let d;t[2]!==s?(d=s==null?void 0:s.trim(),t[2]=s,t[3]=d):d=t[3];const f=d;let u;t[4]!==f||t[5]!==i?(u=f&&(i?r.jsx(nt,{className:"size-3","data-icon":"inline-start"}):r.jsx(et,{className:"size-3","data-icon":"inline-start"})),t[4]=f,t[5]=i,t[6]=u):u=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(J2,{className:"size-3","data-icon":"inline-start"}),p=r.jsx("span",{className:"font-medium",children:"Compacted"}),t[7]=m,t[8]=p):(m=t[7],p=t[8]);let h;t[9]!==c?(h=c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"·"}),r.jsx("span",{children:c})]}),t[9]=c,t[10]=h):h=t[10];let g;t[11]!==u||t[12]!==h?(g=r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:[u,m,p,h]}),t[11]=u,t[12]=h,t[13]=g):g=t[13];const v=g;if(!f){let C;t[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=C):C=t[14];let T;t[15]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=T):T=t[15];let _;return t[16]!==v?(_=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[C,v,T]}),t[16]=v,t[17]=_):_=t[17],_}let x,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(X,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),w=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=x,t[19]=w):(x=t[18],w=t[19]);let y;t[20]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=y):y=t[20];let j;t[21]!==v?(j=r.jsxs(dn,{render:x,children:[w,v,y]}),t[21]=v,t[22]=j):j=t[22];let N;t[23]===Symbol.for("react.memo_cache_sentinel")?(N=[yi],t[23]=N):N=t[23];let S;t[24]!==f?(S=r.jsx(jt,{children:r.jsx("div",{className:"prose prose-sm dark:prose-invert mx-8 mt-2 max-w-none rounded-md border bg-muted/30 px-3 py-2",children:r.jsx(yn,{remarkPlugins:N,components:wn,children:f})})}),t[24]=f,t[25]=S):S=t[25];let k;return t[26]!==i||t[27]!==j||t[28]!==S?(k=r.jsxs(wt,{open:i,onOpenChange:a,className:"px-4 py-2",children:[j,S]}),t[26]=i,t[27]=j,t[28]=S,t[29]=k):k=t[29],k}),Z_=1.5;function Q_(n,e){return e<=0?!1:n<e*Z_}function e6(n,e){return n===0&&!e}function t6(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function n6(n,e){return e==="codex"?n.isFragment===!0:n.userMessage===null}const s6=1e3;function o6(n){const e=new Map;return n.map(t=>{if(!t.contentBlocks.some(o=>o.kind==="agent_message"))return t;const s=t.contentBlocks.filter(o=>{if(o.kind!=="agent_message")return!0;const i=Date.parse(o.timestamp??"");if(Number.isNaN(i))return!0;const a=`${o.sender}\0${o.body}`,l=e.get(a);return l!==void 0&&Math.abs(i-l)<=s6?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function P1(n,e,t){const s=new Set(n.map(c=>c.id)),o=e.filter(c=>!s.has(c.id));if(o.length===0)return n;const i=n[0],a=o[o.length-1],l=i&&a&&n6(i,t)?[...o.slice(0,-1),i6(a,i),...n.slice(1)]:[...o,...n];return wc(o6(l))}function r6(n,e){const t=Date.parse(n.timestamp),s=Date.parse(e.timestamp)+(e.durationMs??0);return!Number.isFinite(t)||!Number.isFinite(s)||s<t?e.durationMs??n.durationMs:s-t}function i6(n,e){return{...n,id:e.id,contentBlocks:[...n.contentBlocks,...e.contentBlocks],thinking:[...n.thinking,...e.thinking],assistantText:[...n.assistantText,...e.assistantText],toolCalls:[...n.toolCalls,...e.toolCalls],subAgentActivity:[...n.subAgentActivity,...e.subAgentActivity],durationMs:r6(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function a6(n){const e=F.c(12),{index:t,children:s}=n,{isSubAgentView:o,undoRedo:i,actions:a}=st(),{requestUndo:l,branchesAtTurn:c}=i,{handleOpenBranches:d,handleBranchFromHere:f}=a;if(!i.enabled||o||!l||!d){let p;return e[0]!==s?(p=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=p):p=e[1],p}let u;e[2]!==c||e[3]!==t?(u=c(t),e[2]=c,e[3]=t,e[4]=u):u=e[4];let m;return e[5]!==s||e[6]!==f||e[7]!==d||e[8]!==t||e[9]!==l||e[10]!==u?(m=r.jsx(V4,{turnIndex:t,branches:u,onRestoreToHere:l,onOpenBranches:d,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=d,e[8]=t,e[9]=l,e[10]=u,e[11]=m):m=e[11],m}function l6(){const n=F.c(10),{session:e,isSubAgentView:t,undoRedo:s}=st(),{canRedo:o,redoTurnCount:i,redoGhostTurns:a,requestRedoAll:l,requestRedoUpTo:c}=s,d=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!o||!l)return null;let f;n[0]!==i||n[1]!==l?(f=r.jsx(q4,{redoTurnCount:i,onRedoAll:l}),n[0]=i,n[1]=l,n[2]=f):f=n[2];let u;n[3]!==a||n[4]!==c||n[5]!==d?(u=a.length>0&&r.jsx("div",{className:"select-none",children:a.map((p,h)=>r.jsxs("div",{className:"group/ghost relative opacity-25 hover:opacity-40 transition-opacity",children:[r.jsx(E1,{turn:p,index:d+h}),c&&r.jsxs(X,{type:"button",variant:"outline",size:"xs",onClick:()=>c(h),className:"absolute right-4 top-4 text-success opacity-0 transition-opacity group-hover/ghost:opacity-100",children:[r.jsx(Z2,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=a,n[4]=c,n[5]=d,n[6]=u):u=n[6];let m;return n[7]!==f||n[8]!==u?(m=r.jsxs(r.Fragment,{children:[f,u]}),n[7]=f,n[8]=u,n[9]=m):m=n[9],m}function c6(n){const e=F.c(5),{hasMore:t,isLoadingOlder:s}=n;let o;e[0]!==t||e[1]!==s?(o=s?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(lt,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:r.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:o}),e[3]=o,e[4]=i):i=e[4],i}function d6(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function u6({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Ct(),{undoRedo:l}=st(),c=b.useRef(null),d=b.useRef(null),[f,u]=b.useState(0),m=b.useMemo(()=>{const y=new Map;return n.map(j=>{const N=y.get(j.turn.id)??0;return y.set(j.turn.id,N+1),{...j,key:N===0?j.turn.id:`${j.turn.id}#${N}`}})},[n]),p=b.useRef(null),h=b.useMemo(()=>t6(p.current,m.map(y=>y.key)),[m]);b.useLayoutEffect(()=>{var y;p.current={firstKey:(y=m[0])==null?void 0:y.key,length:m.length}},[m]);const g=b.useRef(t);b.useEffect(()=>{t&&(g.current=!0)},[t]);const v=t||g.current;b.useLayoutEffect(()=>{const y=e.current,j=d.current;if(!y||!j)return;const N=j.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop;u(S=>Math.abs(S-N)<1?S:N)},[e,v]),b.useEffect(()=>{if(!t||!i||!o||s)return;const y=e.current;if(!y)return;const j=()=>{Q_(y.scrollTop,y.clientHeight)&&i()};return j(),y.addEventListener("scroll",j,{passive:!0}),()=>y.removeEventListener("scroll",j)},[t,s,o,i,m.length,e]);const x=b.useMemo(()=>{const y=new Map;for(let j=0;j<m.length;j++)y.set(m[j].index,j);return y},[m]),w=b.useRef(null);return b.useEffect(()=>{var j;if(a===null){w.current=null;return}if(a===w.current)return;w.current=a;const y=x.get(a);y!==void 0&&((j=c.current)==null||j.scrollToIndex(y,{align:"start",smooth:!0}))},[a,x]),r.jsxs(r.Fragment,{children:[v&&r.jsx(c6,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(K4,{ref:c,scrollRef:e,startMargin:f,shift:h,children:m.map(({turn:y,index:j,key:N})=>r.jsx("div",{"data-turn-index":j,children:r.jsx(a6,{index:j,children:r.jsxs("div",{children:[(y.compactionSummary||y.compactionMeta)&&r.jsx(J_,{summary:y.compactionSummary,meta:y.compactionMeta}),!d6(y)&&r.jsx(E1,{turn:y,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]})})},N))})}),r.jsx(l6,{})]})}const f6=b.memo(function(e){const t=F.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=Ct(),{searchQuery:d,sessionChangeKey:f}=c,{session:u}=st(),m=u==null?void 0:u.turns;let p;t[0]!==m?(p=m?m.map(m6):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==d?(g=d?h.filter(j=>{const{turn:N}=j;return E_(N,d)}):h,t[2]=h,t[3]=d,t[4]=g):g=t[4];const v=g;let x;t[5]!==v.length||t[6]!==o||t[7]!==d?(x=d?v.length===0:e6(v.length,o??!1),t[5]=v.length,t[6]=o,t[7]=d,t[8]=x):x=t[8];const w=x;let y;return t[9]!==s||t[10]!==v||t[11]!==o||t[12]!==i||t[13]!==l||t[14]!==a||t[15]!==d||t[16]!==f||t[17]!==w?(y=r.jsx(H5,{children:w?r.jsx(En,{className:"min-h-64 border-0",children:r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:d?r.jsx(Q2,{}):r.jsx(Qm,{})}),r.jsx(An,{children:d?"No matching turns":"No conversation yet"}),r.jsx(Mn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(u6,{filteredTurns:v,scrollContainerRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l},f)}),t[9]=s,t[10]=v,t[11]=o,t[12]=i,t[13]=l,t[14]=a,t[15]=d,t[16]=f,t[17]=w,t[18]=y):y=t[18],y});function m6(n,e){return{turn:n,index:e}}const p6="[data-turn-index]",A1="[data-turn-prompt]",Hf=1,h6=120,Kf=180;function g6(n){if(!n.userMessage)return null;const e=Li(n.userMessage),{body:t}=Mo(e),s=Sc(t);if(!s){const i=xg(e);if(!i)return null;const a=vg(e);return a?`/${i} ${a}`:`/${i}`}const o=s.split(`
|
|
109
|
+
`)[0];return o.length>Kf?`${o.slice(0,Kf)}...`:o}function x6(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=g6(s);if(o)return{index:t,text:o}}return null}function v6(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(p6)){const c=l.getBoundingClientRect().top;if(c>e+Hf)break;t=l,s=c}if(!t)return null;const o=Number(t.dataset.turnIndex);if(!Number.isInteger(o))return null;const i=t.querySelector(A1);return(i?i.getBoundingClientRect().bottom>e+Hf:s+h6>e)?null:o}const b6=b.memo(function(e){const t=F.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=b.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const j=o.current;if(!j)return;let N=null;const S=()=>{N=null;const _=v6(j);a(P=>_===null?null:(P==null?void 0:P.sessionId)===s.sessionId&&P.index===_?P:{sessionId:s.sessionId,index:_})},k=()=>{N===null&&(N=requestAnimationFrame(S))};a(null),j.addEventListener("scroll",k,{passive:!0});const C=new MutationObserver(k);C.observe(j,{childList:!0,subtree:!0});const T=new ResizeObserver(k);return T.observe(j),j.firstElementChild&&T.observe(j.firstElementChild),k(),()=>{j.removeEventListener("scroll",k),C.disconnect(),T.disconnect(),N!==null&&cancelAnimationFrame(N)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),b.useEffect(l,c);let d;e:{if(!i||i.sessionId!==s.sessionId){d=null;break e}let j;t[4]!==s.turns||t[5]!==i.index?(j=x6(s.turns,i.index),t[4]=s.turns,t[5]=i.index,t[6]=j):j=t[6],d=j}const f=d;if(!f)return null;let u;t[7]!==f.index||t[8]!==o?(u=()=>{const j=o.current;if(!j)return;const N=j.querySelector(`[data-turn-index="${f.index}"]`),S=(N==null?void 0:N.querySelector(A1))??N;if(!S)return;const k=j.scrollTop+S.getBoundingClientRect().top-j.getBoundingClientRect().top;j.scrollTo({top:Math.max(0,k),behavior:"smooth"})},t[7]=f.index,t[8]=o,t[9]=u):u=t[9];const m=u,p=`Scroll to turn ${f.index+1} prompt`;let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Qm,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=f.index+1;let v;t[11]!==g?(v=r.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",g]}),t[11]=g,t[12]=v):v=t[12];let x;t[13]!==f.text?(x=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[13]=f.text,t[14]=x):x=t[14];let w;t[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Bo,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=w):w=t[15];let y;return t[16]!==f.text||t[17]!==m||t[18]!==p||t[19]!==v||t[20]!==x?(y=r.jsxs(X,{type:"button",variant:"outline",size:"sm","aria-label":p,title:f.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-background px-3 text-left shadow-sm",onClick:m,children:[h,v,x,w]}),t[16]=f.text,t[17]=m,t[18]=p,t[19]=v,t[20]=x,t[21]=y):y=t[21],y});function y6(n){const e=F.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=r.jsxs("div",{className:"text-xs text-muted-foreground italic py-1",children:["Preparing ",l,"…"]}),e[0]=l,e[1]=c):c=e[1],c}if(t.blockType==="thinking"){if(!t.text)return null;let l;e[2]!==s?(l=s&&r.jsx(Vf,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=r.jsxs("div",{className:"my-2 whitespace-pre-wrap break-words border-l pl-3 text-sm italic leading-relaxed text-muted-foreground",children:[t.text,l]}),e[4]=t.text,e[5]=l,e[6]=c):c=e[6],c}if(!t.text)return null;let o;e[7]!==t.text?(o=r.jsx(Xg,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(Vf,{}),e[9]=s,e[10]=i):i=e[10];let a;return e[11]!==o||e[12]!==i?(a=r.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[o,i]}),e[11]=o,e[12]=i,e[13]=a):a=e[13],a}function Vf(){const n=F.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("span",{className:"ml-0.5 inline-block h-[15px] w-[7px] rounded-[1px] bg-foreground/70 align-text-bottom"}),n[0]=e):e=n[0],e}const w6=b.memo(function(){const e=F.c(9),t=Pc();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=CN(t);if(c.length===0){a=null;break e}const d=new Map;s="px-4",o="streaming-turn-overlay",i=c.map(f=>{const u=d.get(f.messageId)??0;d.set(f.messageId,u+1);const m=f.blocks.reduce(j6,-1);return r.jsx("div",{children:f.blocks.map((p,h)=>r.jsx(y6,{block:p,showCursor:!f.stopped&&h===m},p.index))},`${f.messageId}:${u}`)})}e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a}else s=e[1],o=e[2],i=e[3],a=e[4];if(a!==Symbol.for("react.early_return_sentinel"))return a;let l;return e[5]!==s||e[6]!==o||e[7]!==i?(l=r.jsx("div",{className:s,"data-testid":o,children:i}),e[5]=s,e[6]=o,e[7]=i,e[8]=l):l=e[8],l});function j6(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const S6=3,ti=["w-6","w-4","w-2.5","w-2"],N6=ti[ti.length-1];function k6(n){return n===null||n<0?N6:ti[Math.min(n,ti.length-1)]}function C6(n){return n.type==="text"}function Ma(n){return n.replace(/\s+/g," ").trim()}function _6(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(C6).map(d=>d.text).join(" "):"",{text:t}=jg(e),{notifications:s,remainingText:o}=yg(t),{remainingText:i}=wg(o),a=Ma(Sc(i));if(a)return a;const l=s.map(d=>d.summary).find(Boolean);return l?Ma(l):n.assistantText.map(Ma).find(Boolean)||"Untitled turn"}const T6=b.memo(function(e){const t=F.c(21),{turns:s,scrollContainerRef:o,onJumpToTurn:i}=e,[a,l]=b.useState(null),c=b.useRef(null),d=s.length;let f;if(t[0]!==s){const j=new Map;f=s.map(N=>{const S=j.get(N.id)??0;return j.set(N.id,S+1),S===0?N.id:`${N.id}#${S}`}),t[0]=s,t[1]=f}else f=t[1];const u=f;let m;t[2]!==o?(m=()=>{const j=o.current,N=c.current;if(!j||!N)return;let S=null;const k=()=>{S=null;const T=j.getBoundingClientRect().top+j.clientHeight/2;let _=null;for(const P of j.querySelectorAll("[data-turn-index]")){const A=P.getBoundingClientRect();if(A.top<=T&&A.bottom>=T){_=Number(P.dataset.turnIndex);break}}for(const P of N.querySelectorAll("[data-tick-index]"))P.dataset.current=String(Number(P.dataset.tickIndex)===_)},C=()=>{S===null&&(S=requestAnimationFrame(k))};return k(),j.addEventListener("scroll",C,{passive:!0}),()=>{j.removeEventListener("scroll",C),S!==null&&cancelAnimationFrame(S)}},t[2]=o,t[3]=m):m=t[3];let p;t[4]!==o||t[5]!==d?(p=[o,d],t[4]=o,t[5]=d,t[6]=p):p=t[6],b.useEffect(m,p);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const N=j.key==="ArrowDown"?1:j.key==="ArrowUp"?-1:0,S=c.current;if(!S)return;const k=[...S.querySelectorAll("[data-tick-index]")];if(k.length===0)return;let C;if(N!==0){const T=k.indexOf(document.activeElement);C=k[Math.min(Math.max(T+N,0),k.length-1)]}else j.key==="Home"?C=k[0]:j.key==="End"&&(C=k[k.length-1]);C&&(j.preventDefault(),C.focus())},t[7]=h):h=t[7];const g=h;if(d<S6)return null;let v;t[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>l(null),t[8]=v):v=t[8];let x;t[9]===Symbol.for("react.memo_cache_sentinel")?(x=G("absolute left-0 top-0 hidden h-full max-h-full flex-col items-start gap-1","justify-evenly overflow-y-auto pb-6 pl-2 pt-14","opacity-60 transition-opacity hover:opacity-100 focus-within:opacity-100","[@media(pointer:fine)]:flex"),t[9]=x):x=t[9];let w;if(t[10]!==a||t[11]!==i||t[12]!==u||t[13]!==s){let j;t[15]!==a||t[16]!==i||t[17]!==u?(j=(N,S)=>{const k=_6(N);return r.jsx(X,{type:"button",variant:"ghost","data-tick-index":S,onMouseEnter:()=>l(S),onFocus:()=>l(S),onClick:()=>i(S),"aria-label":`Turn ${S+1}: ${k}`,className:G("group/tick relative h-1 shrink-0 rounded-full bg-muted-foreground/30 p-0","transition-[width,background-color] duration-150 motion-reduce:transition-none","hover:bg-muted-foreground/80 focus-visible:outline-none focus-visible:bg-muted-foreground/80","data-[current=true]:bg-primary/70",k6(a===null?null:Math.abs(S-a))),children:r.jsxs("span",{className:G("pointer-events-none absolute left-full top-1/2 ml-2 hidden w-64 -translate-y-1/2","rounded-md border bg-popover px-2 py-1.5 text-left","text-xs leading-relaxed text-popover-foreground shadow-sm","group-hover/tick:block group-focus-visible/tick:block"),children:[r.jsx("span",{className:"mr-1 font-mono text-muted-foreground/60",children:S+1}),r.jsx("span",{className:"line-clamp-2 align-middle",children:k})]})},u[S])},t[15]=a,t[16]=i,t[17]=u,t[18]=j):j=t[18],w=s.map(j),t[10]=a,t[11]=i,t[12]=u,t[13]=s,t[14]=w}else w=t[14];let y;return t[19]!==w?(y=r.jsx("nav",{ref:c,"aria-label":"Conversation timeline",onMouseLeave:v,onKeyDown:g,className:x,children:w}),t[19]=w,t[20]=y):y=t[20],y});class E6 extends b.Component{constructor(t){super(t);vr(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("ErrorBoundary caught:",t,s.componentStack)}render(){return this.state.hasError?r.jsx("div",{className:"flex justify-center p-8",children:r.jsxs(vt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(fn,{}),r.jsx(At,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(bt,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(ns,{className:"static col-start-2 mt-2",children:r.jsxs(X,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Ht,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const qf="find-in-session-highlight",Ra="find-in-session-active";function P6(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let s;for(;s=t.nextNode();)s.nodeValue&&s.nodeValue.trim().length>0&&e.push(s);return e}const A6=b.forwardRef(function(e,t){const s=F.c(63),{scrollContainerRef:o}=e,[i,a]=b.useState(!1),[l,c]=b.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[f,u]=b.useState(d),[m,p]=b.useState(-1),h=b.useRef(null);let g;s[1]!==o?(g=()=>{const ee=o.current;if(!ee)return;ee.querySelectorAll(`mark.${qf}`).forEach(M6)},s[1]=o,s[2]=g):g=s[2];const v=g;let x;s[3]!==v||s[4]!==o?(x=ee=>{if(v(),!ee||!o.current){u([]),p(-1);return}const ie=o.current,oe=P6(ie),re=ee.toLowerCase(),te=[];for(const ce of oe){const me=ce.nodeValue||"",pe=me.toLowerCase();let xe=0;const we=[];for(;;){const de=pe.indexOf(re,xe);if(de===-1)break;we.push(de),xe=de+1}if(we.length===0)continue;const ae=ce.parentNode;if(!ae)continue;const ve=document.createDocumentFragment();let he=0;for(const de of we){de>he&&ve.appendChild(document.createTextNode(me.slice(he,de)));const Ne=document.createElement("mark");Ne.className=qf,Ne.textContent=me.slice(de,de+ee.length),ve.appendChild(Ne),te.push(Ne),he=de+ee.length}he<me.length&&ve.appendChild(document.createTextNode(me.slice(he))),ae.replaceChild(ve,ce)}u(te),te.length>0?(p(0),te[0].classList.add(Ra),te[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=v,s[4]=o,s[5]=x):x=s[5];const w=x;let y;s[6]!==m||s[7]!==f?(y=ee=>{if(f.length===0)return;m>=0&&m<f.length&&f[m].classList.remove(Ra);const ie=(ee%f.length+f.length)%f.length;f[ie].classList.add(Ra),f[ie].scrollIntoView({block:"center",behavior:"smooth"}),p(ie)},s[6]=m,s[7]=f,s[8]=y):y=s[8];const j=y;let N;s[9]!==v?(N=()=>{a(!1),c(""),v(),u([]),p(-1)},s[9]=v,s[10]=N):N=s[10];const S=N;let k,C;s[11]!==S||s[12]!==i?(k=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var ee;return(ee=h.current)==null?void 0:ee.focus()})},close:S,isOpen:i}),C=[S,i],s[11]=S,s[12]=i,s[13]=k,s[14]=C):(k=s[13],C=s[14]),b.useImperativeHandle(t,k,C);let T,_;s[15]!==w||s[16]!==l?(T=()=>{const ee=setTimeout(()=>w(l),150);return()=>clearTimeout(ee)},_=[l,w],s[15]=w,s[16]=l,s[17]=T,s[18]=_):(T=s[17],_=s[18]),b.useEffect(T,_);let P,A;s[19]!==v?(P=()=>()=>v(),A=[v],s[19]=v,s[20]=P,s[21]=A):(P=s[20],A=s[21]),b.useEffect(P,A);let E;s[22]!==m||s[23]!==j||s[24]!==S?(E=ee=>{ee.key==="Escape"?(ee.preventDefault(),ee.stopPropagation(),S()):ee.key==="Enter"&&(ee.preventDefault(),ee.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=S,s[25]=E):E=s[25];const M=E;if(!i)return null;let I;s[26]===Symbol.for("react.memo_cache_sentinel")?(I=ee=>c(ee.target.value),s[26]=I):I=s[26];let R;s[27]!==M||s[28]!==l?(R=r.jsx(Un,{ref:h,value:l,onChange:I,onKeyDown:M,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=M,s[28]=l,s[29]=R):R=s[29];const D=l?f.length>0?`${m+1}/${f.length}`:"0/0":"";let L;s[30]!==D?(L=r.jsx(un,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:D})}),s[30]=D,s[31]=L):L=s[31];let $;s[32]!==R||s[33]!==L?($=r.jsxs(Bn,{className:"w-64",children:[R,L]}),s[32]=R,s[33]=L,s[34]=$):$=s[34];let z;s[35]!==m||s[36]!==j?(z=()=>j(m-1),s[35]=m,s[36]=j,s[37]=z):z=s[37];const U=f.length===0,O=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let H;s[38]!==O?(H=G("text-muted-foreground",O),s[38]=O,s[39]=H):H=s[39];let B;s[40]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(Bo,{"data-icon":"inline-start"}),s[40]=B):B=s[40];let W;s[41]!==z||s[42]!==U||s[43]!==H?(W=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:z,disabled:U,className:H,"aria-label":"Previous match",children:B}),s[41]=z,s[42]=U,s[43]=H,s[44]=W):W=s[44];let V;s[45]!==m||s[46]!==j?(V=()=>j(m+1),s[45]=m,s[46]=j,s[47]=V):V=s[47];const q=f.length===0,Y=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let K;s[48]!==Y?(K=G("text-muted-foreground",Y),s[48]=Y,s[49]=K):K=s[49];let J;s[50]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(nt,{"data-icon":"inline-start"}),s[50]=J):J=s[50];let Z;s[51]!==V||s[52]!==q||s[53]!==K?(Z=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:V,disabled:q,className:K,"aria-label":"Next match",children:J}),s[51]=V,s[52]=q,s[53]=K,s[54]=Z):Z=s[54];let Q;s[55]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(xt,{"data-icon":"inline-start"}),s[55]=Q):Q=s[55];let se;s[56]!==S?(se=r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:S,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:Q}),s[56]=S,s[57]=se):se=s[57];let ne;return s[58]!==$||s[59]!==W||s[60]!==Z||s[61]!==se?(ne=r.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[$,W,Z,se]}),s[58]=$,s[59]=W,s[60]=Z,s[61]=se,s[62]=ne):ne=s[62],ne});function M6(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const AA=["General","View","Tools"],Vi=[{command:"commandPalette",label:"Open command palette",description:"Search actions, projects, and recent sessions",group:"General",defaultShortcut:{key:"k",modKey:!0}},{command:"keyboardShortcuts",label:"Show keyboard shortcuts",description:"Open this reference — only while no text field is focused",group:"General",defaultShortcut:{key:"?",shiftKey:!0}},{command:"newSession",label:"Start a new session",description:"Open the project picker for a new agent session",group:"General",defaultShortcut:{key:"n",platformChord:!0}},{command:"focusComposer",label:"Focus message composer",description:"Jump to the chat composer — only while no text field is focused",group:"General",defaultShortcut:{key:" "}},{command:"prevLiveSession",label:"Focus previous live session",description:"Move focus up the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowup",modKey:!0,shiftKey:!0}},{command:"nextLiveSession",label:"Focus next live session",description:"Move focus down the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowdown",modKey:!0,shiftKey:!0}},{command:"recentSessionBack",label:"Previous recent session",description:"Step back through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0}},{command:"recentSessionForward",label:"Next recent session",description:"Step forward through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0,shiftKey:!0}},{command:"toggleSidebar",label:"Toggle session sidebar",description:"Show or hide projects and sessions",group:"View",defaultShortcut:{key:"b",modKey:!0}},{command:"missionControl",label:"Toggle Mission Control",description:"Show every live session at once and answer whatever is blocked",group:"View",defaultShortcut:{doubleTapModifier:"mod"}},{command:"toggleStats",label:"Toggle session analytics",description:"Show or hide the right analytics panel",group:"View",defaultShortcut:{key:"b",modKey:!0,shiftKey:!0}},{command:"expandAll",label:"Expand all groups",description:"Expand conversation and tool groups without opening raw payloads",group:"View",defaultShortcut:{key:"e",modKey:!0}},{command:"expandToolPayloads",label:"Expand all tool payloads",description:"Expand tool inputs, results, and diffs with their containing groups",group:"View",defaultShortcut:{key:"e",modKey:!0,shiftKey:!0}},{command:"findInConversation",label:"Find in conversation",description:"Search the open conversation and step through matches",group:"View",defaultShortcut:{key:"f",modKey:!0}},{command:"integratedTerminal",label:"Toggle integrated terminal",description:"Open or collapse the in-app project terminal",group:"Tools",defaultShortcut:{key:"j",modKey:!0}},{command:"newIntegratedTerminal",label:"New integrated terminal",description:"Create another terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"n",modKey:!0}},{command:"closeIntegratedTerminal",label:"Close integrated terminal",description:"Close the active terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"w",modKey:!0}},{command:"preview",label:"Toggle development preview",description:"Show or hide the in-app local server preview",group:"Tools",defaultShortcut:{key:"j",modKey:!0,shiftKey:!0}},{command:"previewRefresh",label:"Refresh development preview",description:"Reload the page while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"r",modKey:!0}},{command:"previewFocusUrl",label:"Focus preview URL",description:"Select the URL while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"l",modKey:!0}},{command:"previewZoomIn",label:"Zoom preview in",description:"Increase the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"=",modKey:!0}},{command:"previewZoomOut",label:"Zoom preview out",description:"Decrease the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"-",modKey:!0}},{command:"previewResetZoom",label:"Reset preview zoom",description:"Return the preview to 100% while its toolbar is focused",group:"Tools",defaultShortcut:{key:"0",modKey:!0}},{command:"projectFiles",label:"Toggle project files",description:"Browse and edit files in the active project",group:"Tools",defaultShortcut:{key:"f",modKey:!0,shiftKey:!0}},{command:"projectFileSave",label:"Save project file",description:"Save the open file while the project file workspace is focused",group:"Tools",defaultShortcut:{key:"s",modKey:!0}},{command:"systemTerminal",label:"Open system terminal",description:"Open the project in your preferred terminal app",group:"Tools",defaultShortcut:{key:"t",platformChord:!0}},{command:"themeSelector",label:"Change theme",description:"Open the theme selector",group:"Tools",defaultShortcut:{key:"s",platformChord:!0}},{command:"device.switch.1",label:"Switch to device 1",description:"Jump to this machine (the local device)",group:"General",defaultShortcut:{key:"1",platformChord:!0}},{command:"device.switch.2",label:"Switch to device 2",description:"Jump to the 2nd device in the switcher",group:"General",defaultShortcut:{key:"2",platformChord:!0}},{command:"device.switch.3",label:"Switch to device 3",description:"Jump to the 3rd device in the switcher",group:"General",defaultShortcut:{key:"3",platformChord:!0}},{command:"device.switch.4",label:"Switch to device 4",description:"Jump to the 4th device in the switcher",group:"General",defaultShortcut:{key:"4",platformChord:!0}},{command:"device.switch.5",label:"Switch to device 5",description:"Jump to the 5th device in the switcher",group:"General",defaultShortcut:{key:"5",platformChord:!0}},{command:"device.switch.6",label:"Switch to device 6",description:"Jump to the 6th device in the switcher",group:"General",defaultShortcut:{key:"6",platformChord:!0}},{command:"device.switch.7",label:"Switch to device 7",description:"Jump to the 7th device in the switcher",group:"General",defaultShortcut:{key:"7",platformChord:!0}},{command:"device.switch.8",label:"Switch to device 8",description:"Jump to the 8th device in the switcher",group:"General",defaultShortcut:{key:"8",platformChord:!0}},{command:"device.switch.9",label:"Switch to device 9",description:"Jump to the 9th device in the switcher",group:"General",defaultShortcut:{key:"9",platformChord:!0}},{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],M1="cogpit-keybindings";let us=null;function R1(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function Do(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function R6(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Fc(){if(us)return us;try{const n=localStorage.getItem(M1);if(!n)return us={};const e=JSON.parse(n);if(!e||typeof e!="object")return us={};const t={};for(const s of Vi){const o=e[s.command];R6(o)&&(t[s.command]=o)}return us=t}catch{return us={}}}function Bc(n){us=n;try{localStorage.setItem(M1,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function ar(n){const e=Vi.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Fc()[n]??e.defaultShortcut}function MA(){return Object.fromEntries(Vi.map(n=>[n.command,ar(n.command)]))}function RA(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:Do(e.key)};Bc({...Fc(),[n]:t})}function IA(n){const e={...Fc()};delete e[n],Bc(e)}function $A(){Bc({})}function OA(n){return{key:Do(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function I1(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function ht(n,e){const t=ar(n);return"doubleTapModifier"in t||Do(e.key)!==Do(t.key)?!1:t.modKey?e.metaKey===e.ctrlKey?!1:e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey:t.platformChord?e.ctrlKey&&e.metaKey!==e.altKey&&e.shiftKey===!!t.shiftKey:e.metaKey===!!t.metaKey&&e.ctrlKey===!!t.ctrlKey&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}function As(n){return n===" "?"Space":n==="escape"?"Esc":n==="tab"?"Tab":n==="arrowup"?"↑":n==="arrowdown"?"↓":n==="arrowleft"?"←":n==="arrowright"?"→":n.length===1?n.toUpperCase():n}function I6(n){const e=R1();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${As(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${As(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${As(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${As(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${As(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,As(n.key)].filter(Boolean).join("+")}function Ia(n){return I6(ar(n))}function Gf(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${Do(n.key)}|${t}|${s}|${o}|${i}`;return n.modKey?[e(!0,!1,!!n.shiftKey,!!n.altKey),e(!1,!0,!!n.shiftKey,!!n.altKey)]:n.platformChord?[e(!0,!0,!!n.shiftKey,!1),e(!1,!0,!!n.shiftKey,!0)]:[e(!!n.metaKey,!!n.ctrlKey,!!n.shiftKey,!!n.altKey)]}function DA(n,e){const t=new Set(Gf(n));return Vi.find(s=>s.command!==e&&Gf(ar(s.command)).some(o=>t.has(o)))??null}function Yf(n){return"doubleTapModifier"in ar(n)?R1()?"Meta":"Control":null}const $6=["device.switch.1","device.switch.2","device.switch.3","device.switch.4","device.switch.5","device.switch.6","device.switch.7","device.switch.8","device.switch.9"],O6="device.cycle";function D6(n){const e=$6.findIndex(t=>ht(t,n));return e===-1?null:e+1}function L6(n){return ht(O6,n)}const xl="cogpit:find-in-conversation",qi=b.memo(function(e){const t=F.c(85),{searchInputRef:s,hasTodos:o,hasMore:i,isLoadingOlder:a,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:d}=e,f=c===void 0?!1:c,{state:u,dispatch:m,isMobile:p}=Ct(),{session:h}=st(),{chat:g,scroll:v}=qo(),{searchQuery:x}=u,{pendingMessages:w}=g,{chatScrollRef:y,scrollEndRef:j,handleScroll:N,canScrollDown:S,scrollToBottomInstant:k,initialScrollDone:C}=v,T=b.useRef(null);let _;t[0]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{var de;return(de=T.current)==null?void 0:de.open()},t[0]=_):_=t[0];const P=_;let A,E;t[1]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const de=function(ke){ht("findInConversation",ke)&&(ke.preventDefault(),P())};return window.addEventListener("keydown",de),window.addEventListener(xl,P),()=>{window.removeEventListener("keydown",de),window.removeEventListener(xl,P)}},E=[P],t[1]=A,t[2]=E):(A=t[1],E=t[2]),b.useEffect(A,E);let M,I;t[3]!==p||t[4]!==f||t[5]!==s?(M=()=>{!p||!f||requestAnimationFrame(()=>{var de;return(de=s.current)==null?void 0:de.focus()})},I=[p,f,s],t[3]=p,t[4]=f,t[5]=s,t[6]=M,t[7]=I):(M=t[6],I=t[7]),b.useEffect(M,I);let R;t[8]!==m?(R=de=>m({type:"JUMP_TO_TURN",index:de}),t[8]=m,t[9]=R):R=t[9];const D=R;let L;t[10]!==m||t[11]!==d?(L=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=L):L=t[12];const $=L,z=h,U=z.turns.length>0||w.length===0,O=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let H;t[13]!==O?(H=G("relative bg-background",O),t[13]=O,t[14]=H):H=t[14];let B;t[15]!==$||t[16]!==m||t[17]!==p||t[18]!==f||t[19]!==s||t[20]!==x?(B=p&&f&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(Bn,{className:"h-9 flex-1",children:[r.jsx(Un,{ref:s,value:x,onChange:de=>m({type:"SET_SEARCH_QUERY",value:de.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(un,{align:"inline-start",children:r.jsx(an,{})})]}),r.jsx(X,{variant:"ghost",size:"icon-sm",onClick:$,"aria-label":"Close conversation search",children:r.jsx(xt,{"data-icon":"inline-start"})})]}),t[15]=$,t[16]=m,t[17]=p,t[18]=f,t[19]=s,t[20]=x,t[21]=B):B=t[21];const W=p?"flex-1 min-h-0":"h-full";let V;t[22]!==W?(V=G("relative",W),t[22]=W,t[23]=V):V=t[23];let q;t[24]!==y?(q=r.jsx(A6,{ref:T,scrollContainerRef:y}),t[24]=y,t[25]=q):q=t[25];let Y;t[26]!==y||t[27]!==z.turns||t[28]!==D||t[29]!==p?(Y=!p&&r.jsx(T6,{turns:z.turns,scrollContainerRef:y,onJumpToTurn:D}),t[26]=y,t[27]=z.turns,t[28]=D,t[29]=p,t[30]=Y):Y=t[30];let K;t[31]!==y||t[32]!==z?(K=r.jsx(b6,{session:z,scrollContainerRef:y}),t[31]=y,t[32]=z,t[33]=K):K=t[33];const J=p&&"mobile-scroll";let Z;t[34]!==J?(Z=G("h-full overflow-x-hidden overflow-y-auto bg-background",J),t[34]=J,t[35]=Z):Z=t[35];let Q;t[36]!==o||t[37]!==p?(Q=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6 pt-14",o?"pb-48":"pb-32"),t[36]=o,t[37]=p,t[38]=Q):Q=t[38];let se;t[39]!==y||t[40]!==i||t[41]!==C||t[42]!==a||t[43]!==l||t[44]!==U?(se=U&&r.jsx(f6,{chatScrollRef:y,hasMore:i,isLoadingOlder:a,pagingEnabled:C,onLoadMore:l}),t[39]=y,t[40]=i,t[41]=C,t[42]=a,t[43]=l,t[44]=U,t[45]=se):se=t[45];let ne;t[46]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(w6,{}),t[46]=ne):ne=t[46];let ee;if(t[47]!==z.turns.length||t[48]!==w){let de;t[50]!==z.turns.length?(de=(Ne,ke)=>r.jsx(Sg,{message:Ne,turnNumber:z.turns.length+1+ke},ke),t[50]=z.turns.length,t[51]=de):de=t[51],ee=w.map(de),t[47]=z.turns.length,t[48]=w,t[49]=ee}else ee=t[49];let ie;t[52]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx(__,{}),t[52]=ie):ie=t[52];let oe;t[53]!==j?(oe=r.jsx("div",{ref:j}),t[53]=j,t[54]=oe):oe=t[54];let re;t[55]!==se||t[56]!==ee||t[57]!==oe?(re=r.jsxs(E6,{fallbackMessage:"Failed to render conversation timeline",children:[se,ne,ee,ie,oe]}),t[55]=se,t[56]=ee,t[57]=oe,t[58]=re):re=t[58];let te;t[59]!==Q||t[60]!==re?(te=r.jsx("div",{className:Q,children:re}),t[59]=Q,t[60]=re,t[61]=te):te=t[61];let ce;t[62]!==y||t[63]!==N||t[64]!==Z||t[65]!==te?(ce=r.jsx("div",{ref:y,onScroll:N,className:Z,children:te}),t[62]=y,t[63]=N,t[64]=Z,t[65]=te,t[66]=ce):ce=t[66];const me=S?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",pe=p?"right-3 bottom-3":"right-5 bottom-5";let xe;t[67]!==me||t[68]!==pe?(xe=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",me,pe),t[67]=me,t[68]=pe,t[69]=xe):xe=t[69];let we;t[70]===Symbol.for("react.memo_cache_sentinel")?(we=r.jsx(ev,{"data-icon":"inline-start"}),t[70]=we):we=t[70];let ae;t[71]!==k||t[72]!==xe?(ae=r.jsx(X,{size:"icon",className:xe,onClick:k,"aria-label":"Scroll to bottom",children:we}),t[71]=k,t[72]=xe,t[73]=ae):ae=t[73];let ve;t[74]!==V||t[75]!==q||t[76]!==Y||t[77]!==K||t[78]!==ce||t[79]!==ae?(ve=r.jsxs("div",{className:V,children:[q,Y,K,ce,ae]}),t[74]=V,t[75]=q,t[76]=Y,t[77]=K,t[78]=ce,t[79]=ae,t[80]=ve):ve=t[80];let he;return t[81]!==H||t[82]!==B||t[83]!==ve?(he=r.jsxs("div",{className:H,children:[B,ve]}),t[81]=H,t[82]=B,t[83]=ve,t[84]=he):he=t[84],he}),vl="cogpit-devices-changed",$1="cogpit:devices-changed";function O1(n){typeof n.connectionRevision=="number"&&xb(n.id,n.connectionRevision)}function D1(n,e,t=!1){window.dispatchEvent(new CustomEvent(vl,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem($1,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function Xf(n){O1(n),D1(n.id,n.connectionRevision)}function $a(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function Ms(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function L1(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function z6(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function Gi(){const[n,e]=b.useState([]),[t,s]=b.useState(!0),[o,i]=b.useState(()=>ut()),a=b.useRef(0),l=b.useCallback(async()=>{const h=++a.current;try{const g=await Kn("/api/hub/devices");if(!g.ok)return;const v=await Ms(g);if(h!==a.current)return;const x=Array.isArray(v==null?void 0:v.devices)?v.devices:[];for(const w of x)O1(w);e(x)}catch{}finally{h===a.current&&s(!1)}},[]);b.useEffect(()=>{l()},[l]),b.useEffect(()=>{const h=()=>i(ut()),g=()=>void l(),v=y=>{if(y.key===$1){try{const j=JSON.parse(y.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&ut()===j.deviceId&&Qn(gt)}catch{}l()}},x=()=>{a.current+=1,e([]),s(!0),l()},w=()=>{a.current+=1,e([]),s(!1)};return window.addEventListener("cogpit-device-changed",h),window.addEventListener("popstate",h),window.addEventListener(vl,g),window.addEventListener("storage",v),window.addEventListener("cogpit-auth-changed",x),window.addEventListener("cogpit-identity-changed",x),window.addEventListener("cogpit-auth-required",w),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(vl,g),window.removeEventListener("storage",v),window.removeEventListener("cogpit-auth-changed",x),window.removeEventListener("cogpit-identity-changed",x),window.removeEventListener("cogpit-auth-required",w)}},[l]);const c=b.useMemo(()=>o===gt?void 0:n.find(h=>h.id===o),[n,o]),d=b.useCallback(async(h,g,v,x)=>{try{const w=await Kn("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:v,tls:x})}),y=await Ms(w);return(y==null?void 0:y.ok)===!0&&y.hello?{ok:!0,hello:y.hello}:{ok:!1,code:(y==null?void 0:y.code)??"UNREACHABLE",error:typeof(y==null?void 0:y.error)=="string"?y.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),f=b.useCallback(async h=>{try{const g=await Kn("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),v=await Ms(g);if(g.ok&&(v!=null&&v.device)){const x=v.device;return Xf(x),{ok:!0,device:x}}return{ok:!1,code:(v==null?void 0:v.code)??"ERROR",error:typeof(v==null?void 0:v.error)=="string"?v.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),u=b.useCallback(async(h,g)=>{try{const v=await Kn($a(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),x=await Ms(v);if(v.ok&&(x!=null&&x.device)){const w=x.device;return Xf(w),{ok:!0,device:w}}return{ok:!1,code:(x==null?void 0:x.code)??"ERROR",error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=b.useCallback(async h=>{try{const g=await Kn($a(h),{method:"DELETE"});if(g.ok)return ut()===h&&Qn(gt),D1(h,void 0,!0),{ok:!0};const v=await Ms(g);return{ok:!1,error:typeof(v==null?void 0:v.error)=="string"?v.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),p=b.useCallback(async h=>{try{const g=await Kn($a(h,"/test"),{method:"POST"});return await Ms(g)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:n,activeDeviceId:o,activeDevice:c,loading:t,refresh:l,probe:d,addDevice:f,updateDevice:u,removeDevice:m,testDevice:p}}const F6=b.lazy(()=>Ve(()=>import("./CommandPaletteHost-ChH6w0Bx.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),B6=b.lazy(()=>Ve(()=>import("./index-C5VcQtkE.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),U6=b.lazy(()=>Ve(()=>Promise.resolve().then(()=>lT),void 0).then(n=>({default:n.DevicesDialog}))),W6=b.lazy(()=>Ve(()=>import("./KeyboardShortcutsDialog-CTbXz40Z.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),H6=b.lazy(()=>Ve(()=>import("./ProjectSwitcherModal-CSZrCd3X.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),K6=b.lazy(()=>Ve(()=>import("./ThemeSelectorModal-rjVBMgWC.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal}))),V6=b.lazy(()=>Ve(()=>import("./WorktreePanel-D94-oAau.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function q6(n){const e=F.c(125),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Ct(),{session:c,sessionSource:d}=st(),{devices:f,activeDeviceId:u}=Gi(),[m,p]=b.useState(null),[h,g]=b.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=at("manageDevices"),e[0]=v):v=e[0];const x=v;let w;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(w=i.pendingCwd??(i.pendingDirName?rn(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=w):w=e[3];const y=w,j=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,N=m??h;let S,k;e[4]!==m?(S=()=>{m&&g(m)},k=[m],e[4]=m,e[5]=S,e[6]=k):(S=e[5],k=e[6]),b.useEffect(S,k);const C=o.onKeyboardShortcutsOpenChange;let T,_;e[7]!==C?(T=()=>{const Ie=function(Je){ht("keyboardShortcuts",Je)&&(I1(document.activeElement)||(Je.preventDefault(),C(!0)))};return window.addEventListener("keydown",Ie),()=>window.removeEventListener("keydown",Ie)},_=[C],e[7]=C,e[8]=T,e[9]=_):(T=e[8],_=e[9]),b.useEffect(T,_);const P=u===gt;let A;e[10]!==P?(A={id:gt,name:"This machine",isLocal:!0,isActive:P},e[10]=P,e[11]=A):A=e[11];let E;if(e[12]!==u||e[13]!==f||e[14]!==A){let Ie;e[16]!==u?(Ie=Ue=>({id:Ue.id,name:Ue.name,isLocal:!1,isActive:Ue.id===u}),e[16]=u,e[17]=Ie):Ie=e[17],E=[A,...f.map(Ie)],e[12]=u,e[13]=f,e[14]=A,e[15]=E}else E=e[15];const M=E;let I;e[18]!==c||e[19]!==(d==null?void 0:d.agentKind)||e[20]!==(d==null?void 0:d.dirName)?(I=()=>{if(!c)return;const Ie=(d==null?void 0:d.agentKind)??Jt((d==null?void 0:d.dirName)??null);Ko(ch(Ie,c.sessionId,c.cwd))},e[18]=c,e[19]=d==null?void 0:d.agentKind,e[20]=d==null?void 0:d.dirName,e[21]=I):I=e[21];const R=I,D=G6,L=s.supportsWorktrees&&t.panels.showWorktrees;let $;e[22]!==j||e[23]!==t.actions||e[24]!==t.panels?($=Ie=>{j&&t.actions.handleDashboardSelect(j,`${Ie}.jsonl`),t.panels.setShowWorktrees(!1)},e[22]=j,e[23]=t.actions,e[24]=t.panels,e[25]=$):$=e[25];let z;e[26]!==j||e[27]!==t.panels.setShowWorktrees||e[28]!==s.worktrees.loading||e[29]!==s.worktrees.refetch||e[30]!==s.worktrees.worktrees||e[31]!==L||e[32]!==$?(z=r.jsx(b.Suspense,{fallback:null,children:r.jsx(V6,{open:L,onOpenChange:t.panels.setShowWorktrees,worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:j,onRefetch:s.worktrees.refetch,onOpenSession:$})}),e[26]=j,e[27]=t.panels.setShowWorktrees,e[28]=s.worktrees.loading,e[29]=s.worktrees.refetch,e[30]=s.worktrees.worktrees,e[31]=L,e[32]=$,e[33]=z):z=e[33];const U=o.processPanel,O=o.workflowsPanel,H=o.undoDialog,B=o.branchModal,W=a.claudeDir??"";let V;e[34]!==a.handleCloseConfigDialog||e[35]!==a.handleConfigSaved||e[36]!==a.showConfigDialog||e[37]!==W?(V=r.jsx(b.Suspense,{fallback:null,children:r.jsx(B6,{open:a.showConfigDialog,currentPath:W,onClose:a.handleCloseConfigDialog,onSaved:a.handleConfigSaved})}),e[34]=a.handleCloseConfigDialog,e[35]=a.handleConfigSaved,e[36]=a.showConfigDialog,e[37]=W,e[38]=V):V=e[38];const q=(d==null?void 0:d.dirName)??i.pendingDirName??null,Y=(c==null?void 0:c.cwd)??i.pendingCwd??null;let K;e[39]!==a.defaultAgentKind||e[40]!==t.onStartNewFolder||e[41]!==t.onStartNewSession||e[42]!==t.panels.handleCloseProjectSwitcher||e[43]!==t.panels.showProjectSwitcher||e[44]!==q||e[45]!==Y?(K=r.jsx(b.Suspense,{fallback:null,children:r.jsx(H6,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:q,currentProjectCwd:Y})}),e[39]=a.defaultAgentKind,e[40]=t.onStartNewFolder,e[41]=t.onStartNewSession,e[42]=t.panels.handleCloseProjectSwitcher,e[43]=t.panels.showProjectSwitcher,e[44]=q,e[45]=Y,e[46]=K):K=e[46];let J;e[47]!==t.panels.handleCloseThemeSelector||e[48]!==t.panels.showThemeSelector||e[49]!==l.setPreview||e[50]!==l.setTheme||e[51]!==l.theme?(J=r.jsx(b.Suspense,{fallback:null,children:r.jsx(K6,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[47]=t.panels.handleCloseThemeSelector,e[48]=t.panels.showThemeSelector,e[49]=l.setPreview,e[50]=l.setTheme,e[51]=l.theme,e[52]=J):J=e[52];const Z=o.commandPaletteOpen,Q=o.onCommandPaletteOpenChange,se=t.actions.handleGoHome,ne=t.panels.handleOpenProjectSwitcher,ee=t.onOpenPaletteProject,ie=t.actions.handleDashboardSelect,oe=t.panels.handleToggleSidebar,re=t.panels.handleToggleStats,te=t.panels.handleToggleFileChanges,ce=t.panels.handleToggleWorktrees,me=t.panels.handleToggleMission,pe=c?t.handlers.handleDuplicateSession:void 0,xe=c?R:void 0,we=c?D:void 0,ae=at("killAny")?o.onKillAll:void 0,ve=at("configWrite")?t.panels.handleToggleConfig:void 0,he=a.openConfigDialog;let de;e[53]!==C?(de=()=>C(!0),e[53]=C,e[54]=de):de=e[54];const Ne=s.currentCwd?s.onTogglePreview:void 0,ke=at("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,Te=t.panels.handleToggleThemeSelector,Ae=s.onOpenTerminal,Pe=o.onFocusComposer,De=o.onExpandAll,ze=o.onExpandToolPayloads,Fe=o.onCollapseAll,ue=!!(c||i.pendingDirName);let le;e[55]!==y||e[56]!==(c==null?void 0:c.cwd)||e[57]!==(d==null?void 0:d.dirName)||e[58]!==i.dashboardProject||e[59]!==i.pendingDirName?(le=at("terminal")&&!!((c==null?void 0:c.cwd)??y??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[55]=y,e[56]=c==null?void 0:c.cwd,e[57]=d==null?void 0:d.dirName,e[58]=i.dashboardProject,e[59]=i.pendingDirName,e[60]=le):le=e[60];const Me=!!c;let Le;e[61]!==s.hasFileChanges?(Le=at("hostFiles")&&s.hasFileChanges,e[61]=s.hasFileChanges,e[62]=Le):Le=e[62];const je=i.mainView==="config",fe=i.mainView==="mission",Ce=(c==null?void 0:c.cwd)??y??null;let _e;e[63]!==o.commandPaletteOpen||e[64]!==o.onCollapseAll||e[65]!==o.onCommandPaletteOpenChange||e[66]!==o.onExpandAll||e[67]!==o.onExpandToolPayloads||e[68]!==o.onFocusComposer||e[69]!==a.openConfigDialog||e[70]!==j||e[71]!==t.actions.handleDashboardSelect||e[72]!==t.actions.handleGoHome||e[73]!==t.onOpenPaletteProject||e[74]!==t.panels.handleOpenProjectSwitcher||e[75]!==t.panels.handleToggleFileChanges||e[76]!==t.panels.handleToggleMission||e[77]!==t.panels.handleToggleSidebar||e[78]!==t.panels.handleToggleStats||e[79]!==t.panels.handleToggleThemeSelector||e[80]!==t.panels.handleToggleWorktrees||e[81]!==t.panels.showFileChanges||e[82]!==t.panels.showSidebar||e[83]!==t.panels.showStats||e[84]!==t.panels.showWorktrees||e[85]!==M||e[86]!==s.launchTerminalRequest||e[87]!==s.onOpenTerminal||e[88]!==s.processPanel.addProcess||e[89]!==s.showProjectFiles||e[90]!==s.supportsWorktrees||e[91]!==pe||e[92]!==xe||e[93]!==we||e[94]!==ae||e[95]!==ve||e[96]!==de||e[97]!==Ne||e[98]!==ke||e[99]!==ue||e[100]!==le||e[101]!==Me||e[102]!==Le||e[103]!==je||e[104]!==fe||e[105]!==Ce?(_e=r.jsx(b.Suspense,{fallback:null,children:r.jsx(F6,{open:Z,onOpenChange:Q,onGoHome:se,onNewSession:ne,onOpenProject:ee,onOpenSession:ie,onToggleSidebar:oe,onToggleStats:re,onToggleFileChanges:te,onToggleWorktrees:ce,onToggleMissionControl:me,onDuplicateSession:pe,onCopyResumeCommand:xe,onFindInConversation:we,onKillAll:ae,onOpenConfig:ve,onOpenSettings:he,onOpenKeyboardShortcuts:de,onTogglePreview:Ne,onToggleProjectFiles:ke,onOpenTheme:Te,onOpenTerminal:Ae,onOpenDevices:x?p:void 0,onSwitchDevice:Qn,devices:M,onFocusComposer:Pe,onExpandAll:De,onExpandToolPayloads:ze,onCollapseAll:Fe,canFocusComposer:ue,canOpenTerminal:le,hasSession:Me,hasFileChanges:Le,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:t.panels.showStats,showProjectFiles:s.showProjectFiles,showFileChanges:t.panels.showFileChanges,showWorktrees:t.panels.showWorktrees,showConfig:je,showMission:fe,currentProjectDirName:j,projectCwd:Ce,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[63]=o.commandPaletteOpen,e[64]=o.onCollapseAll,e[65]=o.onCommandPaletteOpenChange,e[66]=o.onExpandAll,e[67]=o.onExpandToolPayloads,e[68]=o.onFocusComposer,e[69]=a.openConfigDialog,e[70]=j,e[71]=t.actions.handleDashboardSelect,e[72]=t.actions.handleGoHome,e[73]=t.onOpenPaletteProject,e[74]=t.panels.handleOpenProjectSwitcher,e[75]=t.panels.handleToggleFileChanges,e[76]=t.panels.handleToggleMission,e[77]=t.panels.handleToggleSidebar,e[78]=t.panels.handleToggleStats,e[79]=t.panels.handleToggleThemeSelector,e[80]=t.panels.handleToggleWorktrees,e[81]=t.panels.showFileChanges,e[82]=t.panels.showSidebar,e[83]=t.panels.showStats,e[84]=t.panels.showWorktrees,e[85]=M,e[86]=s.launchTerminalRequest,e[87]=s.onOpenTerminal,e[88]=s.processPanel.addProcess,e[89]=s.showProjectFiles,e[90]=s.supportsWorktrees,e[91]=pe,e[92]=xe,e[93]=we,e[94]=ae,e[95]=ve,e[96]=de,e[97]=Ne,e[98]=ke,e[99]=ue,e[100]=le,e[101]=Me,e[102]=Le,e[103]=je,e[104]=fe,e[105]=Ce,e[106]=_e):_e=e[106];let Be;e[107]!==o.keyboardShortcutsOpen||e[108]!==C?(Be=r.jsx(b.Suspense,{fallback:null,children:r.jsx(W6,{open:o.keyboardShortcutsOpen,onOpenChange:C})}),e[107]=o.keyboardShortcutsOpen,e[108]=C,e[109]=Be):Be=e[109];let be;e[110]!==m||e[111]!==N?(be=x&&N!==null&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(U6,{open:m!==null,initialMode:N,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[110]=m,e[111]=N,e[112]=be):be=e[112];let Ee;return e[113]!==o.branchModal||e[114]!==o.processPanel||e[115]!==o.undoDialog||e[116]!==o.workflowsPanel||e[117]!==z||e[118]!==V||e[119]!==K||e[120]!==J||e[121]!==_e||e[122]!==Be||e[123]!==be?(Ee=r.jsxs(r.Fragment,{children:[z,U,O,H,B,V,K,J,_e,Be,be]}),e[113]=o.branchModal,e[114]=o.processPanel,e[115]=o.undoDialog,e[116]=o.workflowsPanel,e[117]=z,e[118]=V,e[119]=K,e[120]=J,e[121]=_e,e[122]=Be,e[123]=be,e[124]=Ee):Ee=e[124],Ee}function G6(){window.dispatchEvent(new Event(xl))}function Oa(n){const e=F.c(10),{reason:t,children:s}=n;if(!t)return s;let o;e[0]!==t?(o=r.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s||e[3]!==o?(i=r.jsx(Nt,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(kt,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(St,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}function Y6(n){const e=F.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-90 group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary motion-reduce:transition-none motion-reduce:active:scale-100 dark:data-checked:bg-primary",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(nv,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&>svg]:size-3.5",children:r.jsx(rt,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(tv,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const X6="2.0.0",z1={version:X6},J6=z1.version,Z6=19384,Q6=443,eT=450,tT=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),nT=`${tT?"⌘⇧":"Ctrl+Shift+"}1–9`,sT=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),oT=new Set(["ACCOUNT_DISABLED"]);function go(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),o=/^(.+):(\d+)$/.exec(s),i=o?o[1]:s,a=o?Number(o[2]):void 0;return t?{host:i,port:a,tls:!0}:{host:i,port:a}}function F1(n,e,t){if(n.ok){if(n.hello.edition==="team"&&n.hello.needsBootstrap===!0)return{tone:"info",text:"Reachable team server — create its first admin account before adding it here."};if(n.hello.edition!=="team"&&n.hello.networkAccess===!1)return{tone:"warn",text:"Cogpit is running but network access is disabled — enable it in that device's settings."};if(n.hello.configured===!1)return{tone:"info",text:"Reachable — this device hasn't finished setup yet and will show its setup screen."};const s=n.hello.name?` "${n.hello.name}"`:"",o=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${o}.`}}switch(n.code){case"UNREACHABLE":return{tone:"error",text:`Can't reach ${e}:${t}. Is Cogpit running with network access enabled?`};case"LEGACY_NO_HELLO":return{tone:"error",text:"That Cogpit is too old for multi-device — update it."};case"NOT_COGPIT":return{tone:"error",text:"Something responded, but it isn't Cogpit."};case"SELF_ADD":return{tone:"error",text:"That's this machine."};default:return{tone:"error",text:n.error??"Could not reach the device."}}}const B1={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function rT(n){const e=F.c(10),{tone:t}=n,s=B1[t];let o;e[0]!==s?(o=G("size-3.5 shrink-0",s),e[0]=s,e[1]=o):o=e[1];const i=o;if(t==="ok"){let l;return e[2]!==i?(l=r.jsx(_n,{"data-icon":"inline-start",className:i}),e[2]=i,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==i?(l=r.jsx(fn,{"data-icon":"inline-start",className:i}),e[4]=i,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==i?(l=r.jsx(Ht,{"data-icon":"inline-start",className:i}),e[6]=i,e[7]=l):l=e[7],l}let a;return e[8]!==i?(a=r.jsx(js,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const iT={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function aT({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=b.useState(!1),[c,d]=b.useState(n.name),[f,u]=b.useState(!1),[m,p]=b.useState(n.username??""),[h,g]=b.useState(""),[v,x]=b.useState(null),[w,y]=b.useState(!1),[j,N]=b.useState(null);b.useEffect(()=>{d(n.name)},[n.name]),b.useEffect(()=>{p(n.username??"")},[n.username]);const S=L1(n),k=S!==void 0&&S!==e,C=z6(n)==="team";async function T(){const P=c.trim();if(!P||P===n.name){l(!1),d(n.name);return}N("rename"),await t(n.id,P),N(null),l(!1)}async function _(){const P=m.trim(),A=n.username??"",E=P!==A,M=h.length>0;if(!E&&!M){u(!1),g(""),x(null);return}if(n.auth==="none"&&!M){x("Enter a password when adding an account to an unauthenticated device.");return}const I={};E&&(I.username=P||null),M&&(I.password=h),N("credentials"),x(null);const R=await s(n.id,I);if(N(null),!R.ok){x(R.error);return}u(!1),g("")}return r.jsxs("div",{className:"rounded-lg border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[r.jsx("span",{"aria-label":`Status: ${n.runtime.authState}`,className:G("size-2 shrink-0 rounded-full",iT[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Pt,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:P=>d(P.target.value),onKeyDown:P=>{P.key==="Enter"&&T(),P.key==="Escape"&&(l(!1),d(n.name))},onBlur:()=>void T(),className:"h-6 text-sm"}):r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm text-foreground",children:n.name}),S&&r.jsxs("span",{className:G("shrink-0 font-mono text-xs",k?"text-warning":"text-muted-foreground"),title:k?`Device runs v${S}; hub runs v${e}`:void 0,children:["v",S,k&&" ≠ hub"]}),n.auth==="none"&&r.jsx(Oe,{variant:"secondary",children:"Unauthenticated"})]}),r.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[n.tls?"https://":"",n.host,":",n.port]}),n.username?r.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:n.username,children:["Team account: ",n.username]}):C?r.jsx("span",{className:"text-xs text-warning",children:"Team account not configured"}):null]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:j==="test",onClick:async()=>{N("test"),await i(n.id),N(null)},children:r.jsx(Ht,{"data-icon":"inline-start",className:G(j==="test"&&"animate-spin")})}),r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{u(P=>!P),p(n.username??""),g(""),x(null)},children:r.jsx(sv,{"data-icon":"inline-start"})}),r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(ws,{"data-icon":"inline-start"})}),r.jsxs(sc,{open:w,onOpenChange:P=>{j!=="remove"&&y(P)},children:[r.jsx(jj,{render:r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(mi,{"data-icon":"inline-start"})}),r.jsxs(oc,{size:"sm",children:[r.jsxs(rc,{children:[r.jsxs(ac,{children:["Remove ",n.name,"?"]}),r.jsx(lc,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(ic,{children:[r.jsx(dc,{disabled:j==="remove",children:"Cancel"}),r.jsxs(cc,{variant:"destructive",disabled:j==="remove",onClick:async()=>{N("remove");try{await o(n.id)}finally{N(null)}},children:[j==="remove"&&r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),f&&r.jsxs("div",{className:"flex flex-col gap-3 border-t px-3 py-3",children:[r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.jsxs(ft,{children:[r.jsxs(mt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Pt,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:P=>p(P.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(ft,{children:[r.jsxs(mt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Pt,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:P=>g(P.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&m.trim()===""&&r.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),v&&r.jsx(Jn,{children:v}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(X,{variant:"outline",size:"sm",onClick:()=>{u(!1),p(n.username??""),g(""),x(null)},children:"Cancel"}),r.jsx(X,{size:"sm",disabled:j==="credentials",onClick:()=>void _(),children:j==="credentials"?r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function U1(n){var Ze,Ke;const e=F.c(118),{open:t,initialMode:s,onClose:o,onCloseComplete:i}=n,{devices:a,refresh:l,probe:c,addDevice:d,updateDevice:f,removeDevice:u,testDevice:m}=Gi(),[p,h]=b.useState(""),[g,v]=b.useState(""),[x,w]=b.useState(""),[y,j]=b.useState(""),[N,S]=b.useState(!1),[k,C]=b.useState(!1),[T,_]=b.useState(null),[P,A]=b.useState(!1),[E,M]=b.useState(null),I=b.useRef(null),R=b.useRef(0);let D,L;e[0]!==s||e[1]!==t?(D=()=>{t&&(h(""),v(""),w(""),j(""),S(!1),C(!1),_(null),M(null),s==="add"&&requestAnimationFrame(()=>{var Re;return(Re=I.current)==null?void 0:Re.focus()}))},L=[t,s],e[0]=s,e[1]=t,e[2]=D,e[3]=L):(D=e[2],L=e[3]),b.useEffect(D,L);let $;e[4]!==N||e[5]!==g||e[6]!==c?($=async()=>{const{host:Re,port:He,tls:$e}=go(g);if(!Re){_(null),C(!1);return}const We=R.current=R.current+1;C(!0);const Ye=await c(Re,He,N,$e);We===R.current&&(_({...F1(Ye,Re,He??($e?Q6:Z6)),hello:Ye.ok?Ye.hello:void 0}),C(!1))},e[4]=N,e[5]=g,e[6]=c,e[7]=$):$=e[7];const z=$;let U,O;e[8]!==g||e[9]!==t||e[10]!==z?(U=()=>{if(!t)return;if(!go(g).host){_(null),C(!1);return}const Re=window.setTimeout(()=>void z(),eT);return()=>window.clearTimeout(Re)},O=[t,g,z],e[8]=g,e[9]=t,e[10]=z,e[11]=U,e[12]=O):(U=e[11],O=e[12]),b.useEffect(U,O);const H=((Ze=T==null?void 0:T.hello)==null?void 0:Ze.edition)==="team",B=H&&((Ke=T==null?void 0:T.hello)==null?void 0:Ke.needsBootstrap)===!0,W=H||!N;let V;e:{if(P){V=!1;break e}if(!go(g).host){V=!1;break e}if(k||!T){V=!1;break e}if(B){V=!1;break e}if(W&&!y){V=!1;break e}if(H&&!x.trim()){V=!1;break e}if((T==null?void 0:T.tone)==="error"){V=!1;break e}V=!0}const q=V;let Y;e[13]!==d||e[14]!==N||e[15]!==W||e[16]!==g||e[17]!==p||e[18]!==o||e[19]!==y||e[20]!==H||e[21]!==x?(Y=async function(){const{host:He,port:$e,tls:We}=go(g);if(!He)return;A(!0),M(null);const Ye=await d({name:p.trim()||void 0,host:He,port:$e,tls:We,username:H?x.trim():void 0,password:W&&y||void 0,allowLocalTunnel:N});if(A(!1),Ye.ok){o(),Qn(Ye.device.id);return}M({field:oT.has(Ye.code)?"username":sT.has(Ye.code)?"password":"host",message:Ye.error})},e[13]=d,e[14]=N,e[15]=W,e[16]=g,e[17]=p,e[18]=o,e[19]=y,e[20]=H,e[21]=x,e[22]=Y):Y=e[22];const K=Y;let J;e[23]!==f?(J=async(Re,He)=>{await f(Re,{name:He})},e[23]=f,e[24]=J):J=e[24];const Z=J;let Q;e[25]!==u?(Q=async Re=>{await u(Re)},e[25]=u,e[26]=Q):Q=e[26];const se=Q;let ne;e[27]!==l||e[28]!==m?(ne=async Re=>{await m(Re),await l()},e[27]=l,e[28]=m,e[29]=ne):ne=e[29];const ee=ne;let ie;e[30]!==o?(ie=Re=>{Re||o()},e[30]=o,e[31]=ie):ie=e[31];let oe;e[32]!==i?(oe=Re=>{Re||i==null||i()},e[32]=i,e[33]=oe):oe=e[33];let re;e[34]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsxs(as,{children:[r.jsx(Ln,{children:"Devices"}),r.jsxs(zn,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",nT," jumps between devices."]})]}),e[34]=re):re=e[34];let te;e[35]!==a||e[36]!==se||e[37]!==Z||e[38]!==ee||e[39]!==f?(te=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(Re=>r.jsx(aT,{device:Re,hubVersion:J6,onRename:Z,onCredentials:f,onRemove:se,onTest:ee},Re.id))}),e[35]=a,e[36]=se,e[37]=Z,e[38]=ee,e[39]=f,e[40]=te):te=e[40];let ce;e[41]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(xn,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[41]=ce):ce=e[41];const me=(E==null?void 0:E.field)==="host";let pe,xe;e[42]===Symbol.for("react.memo_cache_sentinel")?(pe=r.jsx(mt,{htmlFor:"device-host",children:"Host"}),xe=r.jsx(Ks,{children:"Enter a local address or an HTTPS URL."}),e[42]=pe,e[43]=xe):(pe=e[42],xe=e[43]);let we;e[44]===Symbol.for("react.memo_cache_sentinel")?(we=Re=>{R.current=R.current+1,v(Re.target.value),w(""),_(null),M(null)},e[44]=we):we=e[44];let ae;e[45]!==z?(ae=()=>void z(),e[45]=z,e[46]=ae):ae=e[46];let ve;e[47]!==g||e[48]!==ae?(ve=r.jsx(Pt,{id:"device-host",ref:I,value:g,onChange:we,onBlur:ae,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[47]=g,e[48]=ae,e[49]=ve):ve=e[49];let he;e[50]!==k?(he=k&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(lt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[50]=k,e[51]=he):he=e[51];let de;e[52]!==T||e[53]!==k?(de=!k&&T&&r.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",B1[T.tone]),children:[r.jsx(rT,{tone:T.tone}),T.text]}),e[52]=T,e[53]=k,e[54]=de):de=e[54];let Ne;e[55]!==E?(Ne=(E==null?void 0:E.field)==="host"&&r.jsx(Jn,{children:E.message}),e[55]=E,e[56]=Ne):Ne=e[56];let ke;e[57]!==me||e[58]!==ve||e[59]!==he||e[60]!==de||e[61]!==Ne?(ke=r.jsxs(ft,{"data-invalid":me,children:[pe,xe,ve,he,de,Ne]}),e[57]=me,e[58]=ve,e[59]=he,e[60]=de,e[61]=Ne,e[62]=ke):ke=e[62];let Te;e[63]===Symbol.for("react.memo_cache_sentinel")?(Te=r.jsxs(mt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Te):Te=e[63];let Ae;e[64]===Symbol.for("react.memo_cache_sentinel")?(Ae=Re=>h(Re.target.value),e[64]=Ae):Ae=e[64];let Pe;e[65]!==p?(Pe=r.jsxs(ft,{children:[Te,r.jsx(Pt,{id:"device-name",value:p,onChange:Ae,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Pe):Pe=e[66];let De;e[67]!==E||e[68]!==H||e[69]!==x?(De=H&&r.jsxs(ft,{"data-invalid":(E==null?void 0:E.field)==="username",children:[r.jsx(mt,{htmlFor:"device-username",children:"Username"}),r.jsx(Pt,{id:"device-username",value:x,onChange:Re=>w(Re.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(Ks,{children:"Requests through this hub will act as this account on the team server."}),(E==null?void 0:E.field)==="username"&&r.jsx(Jn,{children:E.message})]}),e[67]=E,e[68]=H,e[69]=x,e[70]=De):De=e[70];let ze;e[71]!==W||e[72]!==y||e[73]!==E||e[74]!==H?(ze=W&&r.jsxs(ft,{"data-invalid":(E==null?void 0:E.field)==="password",children:[r.jsx(mt,{htmlFor:"device-password",children:"Password"}),r.jsx(Pt,{id:"device-password",type:"password",value:y,onChange:Re=>j(Re.target.value),placeholder:H?"Password for that team account":"Network access password for that device",autoComplete:H?"current-password":"off"}),(E==null?void 0:E.field)==="password"&&r.jsx(Jn,{children:E.message})]}),e[71]=W,e[72]=y,e[73]=E,e[74]=H,e[75]=ze):ze=e[75];let Fe;e[76]!==ke||e[77]!==Pe||e[78]!==De||e[79]!==ze?(Fe=r.jsxs(Qs,{children:[ke,Pe,De,ze]}),e[76]=ke,e[77]=Pe,e[78]=De,e[79]=ze,e[80]=Fe):Fe=e[80];let ue;e[81]===Symbol.for("react.memo_cache_sentinel")?(ue=Re=>{R.current=R.current+1,S(Re===!0),_(null),M(null)},e[81]=ue):ue=e[81];let le;e[82]!==N?(le=r.jsx(Y6,{id:"device-local-tunnel",name:"device-local-tunnel",checked:N,onCheckedChange:ue}),e[82]=N,e[83]=le):le=e[83];const Me=H?"":" — no password";let Le;e[84]!==Me?(Le=r.jsxs(mt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",Me]}),e[84]=Me,e[85]=Le):Le=e[85];let je;e[86]!==le||e[87]!==Le?(je=r.jsxs(ft,{orientation:"horizontal",children:[le,Le]}),e[86]=le,e[87]=Le,e[88]=je):je=e[88];let fe;e[89]!==N||e[90]!==H?(fe=N&&r.jsxs(vt,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(ov,{}),r.jsx(bt,{className:"text-warning",children:H?r.jsx(r.Fragment,{children:"The loopback address is allowed because the tunnel is local; team account authentication still applies."}):r.jsxs(r.Fragment,{children:["Traffic to this device is forwarded ",r.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[89]=N,e[90]=H,e[91]=fe):fe=e[91];let Ce;e[92]!==o?(Ce=r.jsx(X,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=Ce):Ce=e[93];const _e=!q;let Be;e[94]!==K?(Be=()=>void K(),e[94]=K,e[95]=Be):Be=e[95];let be;e[96]!==P?(be=P?r.jsxs(r.Fragment,{children:[r.jsx(lt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=P,e[97]=be):be=e[97];let Ee;e[98]!==_e||e[99]!==Be||e[100]!==be?(Ee=r.jsx(X,{disabled:_e,onClick:Be,children:be}),e[98]=_e,e[99]=Be,e[100]=be,e[101]=Ee):Ee=e[101];let Ie;e[102]!==Ce||e[103]!==Ee?(Ie=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Ce,Ee]}),e[102]=Ce,e[103]=Ee,e[104]=Ie):Ie=e[104];let Ue;e[105]!==Fe||e[106]!==je||e[107]!==fe||e[108]!==Ie?(Ue=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ce,Fe,je,fe,Ie]}),e[105]=Fe,e[106]=je,e[107]=fe,e[108]=Ie,e[109]=Ue):Ue=e[109];let Je;e[110]!==te||e[111]!==Ue?(Je=r.jsxs(Dn,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[re,te,Ue]}),e[110]=te,e[111]=Ue,e[112]=Je):Je=e[112];let qe;return e[113]!==t||e[114]!==ie||e[115]!==oe||e[116]!==Je?(qe=r.jsx(On,{open:t,onOpenChange:ie,onOpenChangeComplete:oe,children:Je}),e[113]=t,e[114]=ie,e[115]=oe,e[116]=Je,e[117]=qe):qe=e[117],qe}const lT=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:U1,parseHostPort:go,probeMessage:F1},Symbol.toStringTag,{value:"Module"})),Jf=z1.version,cT={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Zf={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function dT(n){const e=F.c(6),{state:t}=n,s=Zf[t],o=Zf[t],i=cT[t];let a;e[0]!==i?(a=G("size-2 shrink-0 rounded-full",i),e[0]=i,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==o||e[4]!==a?(l=r.jsx("span",{"aria-label":s,title:o,className:a}),e[2]=s,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function Uc(n){const e=F.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=Gi(),[d,f]=b.useState(null),u=(a==null?void 0:a.name)??"This machine",m=i!==gt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=at("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==o||e[2]!==l||e[3]!==c?(g=U=>{!U||o.length===0||Promise.all(o.map(O=>c(O.id).catch(fT))).then(()=>l())},e[1]=o,e[2]=l,e[3]=c,e[4]=g):g=e[4];const v=g;if(!s&&o.length===0&&!m)return null;const x=s?"sm":"xs",w=s&&"h-10";let y;e[5]!==w?(y=G("max-w-40 justify-start",w),e[5]=w,e[6]=y):y=e[6];let j;e[7]!==x||e[8]!==y?(j=r.jsx(X,{variant:"ghost",size:x,"aria-label":"Switch device",className:y}),e[7]=x,e[8]=y,e[9]=j):j=e[9];let N;e[10]!==m?(N=m?r.jsx(Gm,{"data-icon":"inline-start"}):r.jsx(Yd,{"data-icon":"inline-start"}),e[10]=m,e[11]=N):N=e[11];let S;e[12]!==u?(S=r.jsx("span",{className:"truncate",children:u}),e[12]=u,e[13]=S):S=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(nt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=k):k=e[14];let C;e[15]!==j||e[16]!==N||e[17]!==S?(C=r.jsxs(In,{render:j,children:[N,S,k]}),e[15]=j,e[16]=N,e[17]=S,e[18]=C):C=e[18];let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(es,{children:"Devices"}),e[19]=T):T=e[19];let _,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Yd,{}),P=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=_,e[21]=P):(_=e[20],P=e[21]);let A;e[22]!==m?(A=!m&&r.jsx(rt,{className:"ml-auto text-success"}),e[22]=m,e[23]=A):A=e[23];let E;e[24]!==A?(E=r.jsxs(it,{onClick:uT,children:[_,P,A]}),e[24]=A,e[25]=E):E=e[25];let M;if(e[26]!==i||e[27]!==s||e[28]!==o){let U;e[30]!==i||e[31]!==s?(U=O=>{const H=L1(O),B=H!==void 0&&H!==Jf,W=O.id===i;return r.jsxs(it,{onClick:()=>Qn(O.id),className:G(s&&"min-h-10"),children:[r.jsx(dT,{state:O.runtime.authState}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"truncate",children:O.name}),B&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${H}; hub runs v${Jf}`,children:["v",H]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[O.host,":",O.port,O.auth==="none"&&" · unauthenticated"]})]}),W&&r.jsx(rt,{className:"ml-auto text-success"})]},O.id)},e[30]=i,e[31]=s,e[32]=U):U=e[32],M=o.map(U),e[26]=i,e[27]=s,e[28]=o,e[29]=M}else M=e[29];let I;e[33]!==E||e[34]!==M?(I=r.jsxs(Lt,{children:[T,E,M]}),e[33]=E,e[34]=M,e[35]=I):I=e[35];let R;e[36]!==o.length?(R=h&&r.jsxs(r.Fragment,{children:[r.jsx(Us,{}),r.jsxs(Lt,{children:[r.jsxs(it,{onClick:()=>f("add"),children:[r.jsx(xn,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(it,{onClick:()=>f("manage"),children:[r.jsx($l,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=R):R=e[37];let D;e[38]!==I||e[39]!==R?(D=r.jsxs($n,{align:"end",sideOffset:6,className:"w-64",children:[I,R]}),e[38]=I,e[39]=R,e[40]=D):D=e[40];let L;e[41]!==v||e[42]!==C||e[43]!==D?(L=r.jsxs(Rn,{onOpenChange:v,children:[C,D]}),e[41]=v,e[42]=C,e[43]=D,e[44]=L):L=e[44];let $;e[45]!==d?($=h&&r.jsx(U1,{open:d!==null,initialMode:d??"manage",onClose:()=>f(null)}),e[45]=d,e[46]=$):$=e[46];let z;return e[47]!==L||e[48]!==$?(z=r.jsxs(r.Fragment,{children:[L,$]}),e[47]=L,e[48]=$,e[49]=z):z=e[49],z}function uT(){return Qn(gt)}function fT(){return null}const mT=6e4;function pT(){const[n,e]=b.useState([]),[t,s]=b.useState(!1),o=b.useRef(!1),i=b.useCallback(async()=>{if(!o.current){o.current=!0;try{const l=await ye("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(d=>d.suspectedLeak))}}catch{}finally{o.current=!1}}},[]),a=b.useCallback(async l=>{if(l.length!==0){s(!0);try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:l})}),await new Promise(c=>setTimeout(c,1e3)),await i()}catch{}finally{s(!1)}}},[i]);return b.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},mT);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const hT=6e4;function gT(){const n=F.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=pT(),[i,a]=b.useState(!1),l=e.length>0,c=e.reduce(bT,0);let d,f;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const A=window.setTimeout(()=>a(!1),hT);return()=>window.clearTimeout(A)},f=[l],n[0]=l,n[1]=d,n[2]=f):(d=n[1],f=n[2]),b.useEffect(d,f),!l&&!i)return null;const u=St,m=l?"destructive":"ghost",p=l?`Kill ${e.length} leaked agent ${e.length===1?"process":"processes"}`:"Leak monitor. No leaked agent processes";let h;n[3]!==l||n[4]!==s||n[5]!==e||n[6]!==o?(h=()=>void(l?s(e.map(vT)):o()),n[3]=l,n[4]=s,n[5]=e,n[6]=o,n[7]=h):h=n[7];const g=!l&&"text-muted-foreground";let v;n[8]!==g?(v=G("mr-1 font-mono",g),n[8]=g,n[9]=v):v=n[9];let x;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==v?(x=r.jsx(X,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:v}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=v,n[15]=x):x=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(rv,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const y=t?"…":e.length;let j;n[17]!==y?(j=r.jsx("span",{className:"tabular-nums",children:y}),n[17]=y,n[18]=j):j=n[18];let N;n[19]!==j||n[20]!==x?(N=r.jsxs(Nt,{render:x,children:[w,j]}),n[19]=j,n[20]=x,n[21]=N):N=n[21];const S=kt,k="bottom",C="p-3",T=l?r.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[r.jsxs("div",{className:"text-xs font-medium",children:["Leaked agent processes · ",c.toFixed(0),"% CPU"]}),e.slice(0,6).map(xT),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(Et,{}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):r.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[r.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let _;n[22]!==S||n[23]!==T?(_=r.jsx(S,{side:k,className:C,children:T}),n[22]=S,n[23]=T,n[24]=_):_=n[24];let P;return n[25]!==u||n[26]!==N||n[27]!==_?(P=r.jsxs(u,{children:[N,_]}),n[25]=u,n[26]=N,n[27]=_,n[28]=P):P=n[28],P}function xT(n){return r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[r.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",Wl(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function vT(n){return n.pid}function bT(n,e){return n+e.cpuPercent}const yT=15e3;function wT(){const n=F.c(12);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=b.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const x=await ye("/api/notifications?limit=100");if(!x.ok)return;const w=await x.json();Array.isArray(w.notifications)&&s(w.notifications)}catch{}},n[1]=o):o=n[1];const i=o;let a,l;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{i();const x=window.setInterval(()=>void i(),yT);return()=>window.clearInterval(x)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),b.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(x,w)=>{const y=new Date().toISOString();s(j=>j.map(N=>N.readAt===null&&w(N)?{...N,readAt:y}:N));try{await ye("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)})}catch{}},n[4]=c):c=n[4];const d=c;let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=async x=>d({ids:x},w=>x.includes(w.id)),n[5]=f):f=n[5];const u=f;let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=async()=>d({all:!0},ST),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(jT),n[7]=t,n[8]=h):h=n[8];const g=h.length;let v;return n[9]!==t||n[10]!==g?(v={notifications:t,unreadCount:g,refresh:i,markRead:u,markAllRead:p},n[9]=t,n[10]=g,n[11]=v):v=n[11],v}function jT(n){return n.readAt===null}function ST(){return!0}function W1(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function NT(){const n=F.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=wT(),[a,l]=b.useState(!1);let c;n[0]!==o?(c=function(C){if(o([C.id]),!C.dirName||!C.sessionId)return;const T=ut(),_=T===gt?"":`/d/${T}`;W1(`${_}/${encodeURIComponent(C.dirName)}/${encodeURIComponent(C.sessionId)}`),l(!1)},n[0]=o,n[1]=c):c=n[1];const d=c;let f;n[2]!==s?(f=k=>{l(k),k&&s()},n[2]=s,n[3]=f):f=n[3];const u=a?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==u||n[5]!==m?(p=r.jsx(X,{type:"button",variant:u,size:"icon-sm",className:"relative","aria-label":m}),n[4]=u,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Xd,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Oe,{className:"absolute -right-1 -top-1 h-4 min-w-4 px-1 tabular-nums",children:t>99?"99+":t}),n[8]=t,n[9]=g):g=n[9];let v;n[10]!==p||n[11]!==g?(v=r.jsxs(In,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=v):v=n[12];let x;n[13]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=x):x=n[13];let w;n[14]!==i||n[15]!==t?(w=t>0&&r.jsxs(X,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(iv,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=w):w=n[16];let y;n[17]!==w?(y=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[x,w]}),n[17]=w,n[18]=y):y=n[18];let j;n[19]!==e||n[20]!==d?(j=r.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?r.jsx(En,{className:"min-h-40 p-6",children:r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:r.jsx(Xd,{})}),r.jsx(An,{children:"No notifications"}),r.jsx(Mn,{children:"Session updates will appear here."})]})}):r.jsx(Lt,{children:e.map(k=>r.jsx(kT,{notification:k,onOpen:d},k.id))})}),n[19]=e,n[20]=d,n[21]=j):j=n[21];let N;n[22]!==y||n[23]!==j?(N=r.jsxs($n,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[y,j]}),n[22]=y,n[23]=j,n[24]=N):N=n[24];let S;return n[25]!==a||n[26]!==f||n[27]!==N||n[28]!==v?(S=r.jsxs(Rn,{open:a,onOpenChange:f,children:[v,N]}),n[25]=a,n[26]=f,n[27]=N,n[28]=v,n[29]=S):S=n[29],S}function kT(n){const e=F.c(38),{notification:t,onOpen:s}=n,o=t.readAt===null,i=!!(t.dirName&&t.sessionId),a=Date.now();let l;e[0]!==t.at?(l=new Date(t.at).getTime(),e[0]=t.at,e[1]=l):l=e[1];const c=Math.max(0,(a-l)/1e3),d=t.kind==="permission"?ln:bi;let f;e[2]!==t||e[3]!==s?(f=()=>s(t),e[2]=t,e[3]=s,e[4]=f):f=e[4];const u=!i&&"cursor-default",m=o&&"bg-accent/50";let p;e[5]!==u||e[6]!==m?(p=G("rounded-none border-b px-3 py-2.5 last:border-b-0",u,m),e[5]=u,e[6]=m,e[7]=p):p=e[7];const h=t.kind==="permission"?"text-warning":"text-info";let g;e[8]!==h?(g=G("mt-0.5",h),e[8]=h,e[9]=g):g=e[9];let v;e[10]!==d||e[11]!==g?(v=r.jsx(d,{className:g}),e[10]=d,e[11]=g,e[12]=v):v=e[12];const x=o?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==x?(w=G("truncate text-xs",x),e[13]=x,e[14]=w):w=e[14];let y;e[15]!==t.title||e[16]!==w?(y=r.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=y):y=e[17];let j;e[18]!==c?(j=Wl(c),e[18]=c,e[19]=j):j=e[19];let N;e[20]!==j?(N=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:j}),e[20]=j,e[21]=N):N=e[21];let S;e[22]!==y||e[23]!==N?(S=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[y,N]}),e[22]=y,e[23]=N,e[24]=S):S=e[24];let k;e[25]!==t.body?(k=r.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=k):k=e[26];let C;e[27]!==S||e[28]!==k?(C=r.jsxs("span",{className:"min-w-0 flex-1",children:[S,k]}),e[27]=S,e[28]=k,e[29]=C):C=e[29];let T;e[30]!==o?(T=o&&r.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=o,e[31]=T):T=e[31];let _;return e[32]!==C||e[33]!==T||e[34]!==f||e[35]!==p||e[36]!==v?(_=r.jsxs(it,{onClick:f,className:p,children:[v,C,T]}),e[32]=C,e[33]=T,e[34]=f,e[35]=p,e[36]=v,e[37]=_):_=e[37],_}const CT=2e3;function Ys(n){return`${n.toFixed(n<10?1:0)}%`}function ni(n){return`${n.toFixed(0)} MB`}function _T(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function TT(n){return n<=0?null:n>=1024*1024?`${(n/1024/1024).toFixed(1)} MB/s`:n>=1024?`${(n/1024).toFixed(1)} KB/s`:`${n.toFixed(0)} B/s`}function ET(n){const e=F.c(44),{metric:t,onKill:s}=n;let o;e[0]!==t.label?(o=r.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.pid?(i=r.jsxs(Oe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=i):i=e[3];let a;e[4]!==t.suspectedLeak?(a=t.suspectedLeak&&r.jsx(Oe,{variant:"destructive",children:"possible leak"}),e[4]=t.suspectedLeak,e[5]=a):a=e[5];let l;e[6]!==t.orphaned||e[7]!==t.suspectedLeak?(l=t.orphaned&&!t.suspectedLeak&&r.jsx(Oe,{variant:"secondary",children:"orphaned"}),e[6]=t.orphaned,e[7]=t.suspectedLeak,e[8]=l):l=e[8];let c;e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==l?(c=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o,i,a,l]}),e[9]=o,e[10]=i,e[11]=a,e[12]=l,e[13]=c):c=e[13];let d;e[14]!==t.command?(d=r.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[14]=t.command,e[15]=d):d=e[15];let f;e[16]!==c||e[17]!==d?(f=r.jsxs("div",{className:"min-w-0 flex-1",children:[c,d]}),e[16]=c,e[17]=d,e[18]=f):f=e[18];let u;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(u=t.suspectedLeak&&s&&r.jsx(X,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t.pid),children:"Kill"}),e[19]=t.pid,e[20]=t.suspectedLeak,e[21]=s,e[22]=u):u=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=G("font-mono text-sm font-semibold tabular-nums",m),e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t.cpuPercent?(h=Ys(t.cpuPercent),e[25]=t.cpuPercent,e[26]=h):h=e[26];let g;e[27]!==p||e[28]!==h?(g=r.jsx("div",{className:p,children:h}),e[27]=p,e[28]=h,e[29]=g):g=e[29];let v;e[30]!==t.memoryMb?(v=ni(t.memoryMb),e[30]=t.memoryMb,e[31]=v):v=e[31];let x;e[32]!==t.ageSeconds?(x=Wl(t.ageSeconds),e[32]=t.ageSeconds,e[33]=x):x=e[33];let w;e[34]!==v||e[35]!==x?(w=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[v," · ",x]}),e[34]=v,e[35]=x,e[36]=w):w=e[36];let y;e[37]!==g||e[38]!==w?(y=r.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=y):y=e[39];let j;return e[40]!==y||e[41]!==f||e[42]!==u?(j=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[f,u,y]}),e[40]=y,e[41]=f,e[42]=u,e[43]=j):j=e[43],j}function PT(n){return n.name==="Server"?"API, file watching, session streams, and agent I/O":n.name==="Renderer"?"React rendering, markdown, layout, and animations":n.name==="GPU"?"Compositing, animation, and visual effects":n.name==="App"?"Electron window and application lifecycle":n.type}function AT(n,e,t=0){return t>0?t===1?'1 agent process outside Cogpit looks leaked. See "Agent processes" below.':`${t} agent processes outside Cogpit look leaked. See "Agent processes" below.`:n<5?"Cogpit is currently idle. Leave this open while the power spike happens.":e?e.name==="Server"?"The server is doing the most work. Compare the activity and API lists below to find the hot loop.":e.name==="Renderer"?"The renderer is doing the most work, which points to repeated UI rendering, layout, or animation.":e.name==="GPU"?"The GPU process is doing the most work, which points to continuous compositing or visual effects.":`${e.name} is currently the busiest Cogpit process.`:"The server is active. The lists below show its busiest recent work."}function H1(n){const e=F.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=r.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let o;e[2]!==t.pid?(o=t.pid>0&&r.jsxs(Oe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=o):o=e[3];let i;e[4]!==s||e[5]!==o?(i=r.jsxs("div",{className:"flex items-center gap-2",children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6];let a;e[7]!==t?(a=PT(t),e[7]=t,e[8]=a):a=e[8];let l;e[9]!==a?(l=r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a}),e[9]=a,e[10]=l):l=e[10];let c;e[11]!==i||e[12]!==l?(c=r.jsxs("div",{className:"min-w-0 flex-1",children:[i,l]}),e[11]=i,e[12]=l,e[13]=c):c=e[13];const d=t.cpuPercent>=50&&"text-destructive";let f;e[14]!==d?(f=G("font-mono text-sm font-semibold tabular-nums",d),e[14]=d,e[15]=f):f=e[15];let u;e[16]!==t.cpuPercent?(u=Ys(t.cpuPercent),e[16]=t.cpuPercent,e[17]=u):u=e[17];let m;e[18]!==f||e[19]!==u?(m=r.jsx("div",{className:f,children:u}),e[18]=f,e[19]=u,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=ni(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=r.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let v;e[27]!==m||e[28]!==h||e[29]!==g?(v=r.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=v):v=e[30];let x;return e[31]!==v||e[32]!==c?(x=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,v]}),e[31]=v,e[32]=c,e[33]=x):x=e[33],x}function Qf(n){const e=F.c(6),{metrics:t,emptyLabel:s}=n;let o,i;if(e[0]!==s||e[1]!==t){i=Symbol.for("react.early_return_sentinel");e:{const a=t.slice(0,8);if(a.length===0){let l;e[4]!==s?(l=r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],i=l;break e}o=a.map(MT)}e[0]=s,e[1]=t,e[2]=o,e[3]=i}else o=e[2],i=e[3];return i!==Symbol.for("react.early_return_sentinel")?i:o}function MT(n,e){const t=TT(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(Et,{}),r.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm",children:n.name}),r.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:_T(n.ratePerSecond)}),t&&r.jsx("span",{children:t}),n.averageDurationMs!==void 0&&r.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&r.jsxs(Oe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function RT(n){const e=F.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(IT).join(", "),e[0]=t,e[1]=o):o=e[1];const i=`Recent Cogpit CPU: ${o}`;let a;e[2]!==s||e[3]!==t?(a=t.length===0?r.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,d)=>r.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:Ys(c)},d)),e[2]=s,e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==i||e[6]!==a?(l=r.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":i,children:a}),e[5]=i,e[6]=a,e[7]=l):l=e[7],l}function IT(n){return Ys(n)}function $T(n){var xe,we,ae,ve;const e=F.c(135),{open:t,onOpenChange:s}=n,[o,i]=b.useState(null),[a,l]=b.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,f]=b.useState(c),[u,m]=b.useState(null),[p,h]=b.useState(!1),g=b.useRef(!1),[v,x]=qs();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Pe;if(g.current)return;g.current=!0,h(!0);const he=ye("/api/performance").then(BT),de=((Pe=window.electronPerformance)==null?void 0:Pe.getSnapshot())??Promise.resolve(null),[Ne,ke]=await Promise.allSettled([he,de]),Te=Ne.status==="fulfilled"?Ne.value:null,Ae=ke.status==="fulfilled"?ke.value:null;if(Te&&l(Te),Ae&&i(Ae),!Te&&!Ae)m("Performance data is unavailable.");else{m(null);const De=Ae&&Ae.processes.length>0?Ae.processes.reduce(FT,0):(Te==null?void 0:Te.cpuPercent)??0;f(ze=>[...ze.slice(-29),De])}g.current=!1,h(!1)},e[1]=w):w=e[1];const y=w;let j,N;e[2]!==t?(j=()=>{if(!t)return;y();const he=window.setInterval(()=>void y(),CT);return()=>window.clearInterval(he)},N=[t,y],e[2]=t,e[3]=j,e[4]=N):(j=e[3],N=e[4]),b.useEffect(j,N);let S,k,C,T,_,P,A,E,M,I,R,D,L,$,z,U,O,H,B;if(e[5]!==v||e[6]!==x||e[7]!==o||e[8]!==u||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const he=[...(o==null?void 0:o.processes)??[]].sort(zT),de=he.length>0?he.reduce(LT,0):(a==null?void 0:a.cpuPercent)??0,Ne=he[0];let ke;e[33]!==((xe=a==null?void 0:a.system)==null?void 0:xe.processes)?(ke=((we=a==null?void 0:a.system)==null?void 0:we.processes)??[],e[33]=(ae=a==null?void 0:a.system)==null?void 0:ae.processes,e[34]=ke):ke=e[34],A=ke;const Te=((ve=a==null?void 0:a.system)==null?void 0:ve.suspectedLeakCount)??0,Ae=Te>0||de>=80?"High":de>=15?"Active":"Idle";let Pe;e[35]===Symbol.for("react.memo_cache_sentinel")?(Pe=async $e=>{try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[$e]})}),await new Promise(DT)}catch{}y()},e[35]=Pe):Pe=e[35],P=Pe;let De;e[36]!==x||e[37]!==o||e[38]!==d||e[39]!==a?(De=()=>{x(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=x,e[37]=o,e[38]=d,e[39]=a,e[40]=De):De=e[40];const ze=De;_=On,L=t,$=s,T=Dn,I="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let Fe;e[41]===Symbol.for("react.memo_cache_sentinel")?(Fe=r.jsx(Ln,{children:"Power & activity monitor"}),e[41]=Fe):Fe=e[41];const ue=Ae==="High"?"destructive":"secondary";let le;e[42]!==Ae||e[43]!==ue?(le=r.jsxs("div",{className:"flex items-center gap-2",children:[Fe,r.jsx(Oe,{variant:ue,children:Ae})]}),e[42]=Ae,e[43]=ue,e[44]=le):le=e[44];let Me;e[45]===Symbol.for("react.memo_cache_sentinel")?(Me=r.jsx(zn,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=Me):Me=e[45];let Le;e[46]!==le?(Le=r.jsxs("div",{className:"min-w-0 flex-1",children:[le,Me]}),e[46]=le,e[47]=Le):Le=e[47];let je;e[48]===Symbol.for("react.memo_cache_sentinel")?(je=()=>void y(),e[48]=je):je=e[48];const fe=p&&"animate-spin";let Ce;e[49]!==fe?(Ce=G(fe),e[49]=fe,e[50]=Ce):Ce=e[50];let _e;e[51]!==Ce?(_e=r.jsx(Ht,{"data-icon":"inline-start",className:Ce}),e[51]=Ce,e[52]=_e):_e=e[52];let Be;e[53]!==p||e[54]!==_e?(Be=r.jsxs(X,{variant:"outline",size:"sm",onClick:je,disabled:p,children:[_e,"Refresh"]}),e[53]=p,e[54]=_e,e[55]=Be):Be=e[55];const be=!a&&!o;let Ee;e[56]!==v?(Ee=v?r.jsx(rt,{"data-icon":"inline-start"}):r.jsx(bn,{"data-icon":"inline-start"}),e[56]=v,e[57]=Ee):Ee=e[57];const Ie=v?"Copied":"Copy data";let Ue;e[58]!==ze||e[59]!==be||e[60]!==Ee||e[61]!==Ie?(Ue=r.jsxs(X,{variant:"outline",size:"sm",onClick:ze,disabled:be,children:[Ee,Ie]}),e[58]=ze,e[59]=be,e[60]=Ee,e[61]=Ie,e[62]=Ue):Ue=e[62];let Je;e[63]!==Be||e[64]!==Ue?(Je=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Be,Ue]}),e[63]=Be,e[64]=Ue,e[65]=Je):Je=e[65],e[66]!==Le||e[67]!==Je?(R=r.jsx(as,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Le,Je]})}),e[66]=Le,e[67]=Je,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Et,{}),e[69]=D):D=e[69],C=Qo,M="min-h-0 min-w-0 flex-1",H="flex flex-col gap-4 p-5",e[70]!==u?(B=u&&r.jsx(vt,{variant:"destructive",children:r.jsx(bt,{children:u})}),e[70]=u,e[71]=B):B=e[71];let qe;e[72]===Symbol.for("react.memo_cache_sentinel")?(qe=r.jsx(qt,{children:"Current load"}),e[72]=qe):qe=e[72];const Ze=de>=80&&"text-destructive";let Ke;e[73]!==Ze?(Ke=G("font-mono text-lg font-semibold tabular-nums",Ze),e[73]=Ze,e[74]=Ke):Ke=e[74];const Re=r.jsxs(Vt,{children:[qe,r.jsx(Gt,{children:AT(de,Ne,Te)}),r.jsx(_h,{children:r.jsxs("span",{className:Ke,children:[Ys(de)," CPU"]})})]});let He;e[75]!==d?(He=r.jsx(Wt,{children:r.jsx(RT,{values:d})}),e[75]=d,e[76]=He):He=e[76],e[77]!==Re||e[78]!==He?(E=r.jsxs(Ut,{size:"sm",children:[Re,He]}),e[77]=Re,e[78]=He,e[79]=E):E=e[79],k=Ut,U="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsxs(Vt,{children:[r.jsx(qt,{children:"Processes"}),r.jsx(Gt,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=O):O=e[80],S=Wt,z=he.length>0?he.map(OT):a?r.jsx(H1,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:a.cpuPercent,memoryMb:a.memory.rssMb}}):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"}),e[5]=v,e[6]=x,e[7]=o,e[8]=u,e[9]=d,e[10]=s,e[11]=t,e[12]=p,e[13]=a,e[14]=S,e[15]=k,e[16]=C,e[17]=T,e[18]=_,e[19]=P,e[20]=A,e[21]=E,e[22]=M,e[23]=I,e[24]=R,e[25]=D,e[26]=L,e[27]=$,e[28]=z,e[29]=U,e[30]=O,e[31]=H,e[32]=B}else S=e[14],k=e[15],C=e[16],T=e[17],_=e[18],P=e[19],A=e[20],E=e[21],M=e[22],I=e[23],R=e[24],D=e[25],L=e[26],$=e[27],z=e[28],U=e[29],O=e[30],H=e[31],B=e[32];let W;e[81]!==S||e[82]!==z?(W=r.jsx(S,{children:z}),e[81]=S,e[82]=z,e[83]=W):W=e[83];let V;e[84]!==k||e[85]!==W||e[86]!==U||e[87]!==O?(V=r.jsxs(k,{size:U,children:[O,W]}),e[84]=k,e[85]=W,e[86]=U,e[87]=O,e[88]=V):V=e[88];let q;e[89]!==P||e[90]!==A?(q=A.length>0&&r.jsxs(Ut,{size:"sm",children:[r.jsxs(Vt,{children:[r.jsx(qt,{children:"Agent processes"}),r.jsx(Gt,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Wt,{children:A.map((he,de)=>r.jsxs("div",{children:[de>0&&r.jsx(Et,{}),r.jsx(ET,{metric:he,onKill:Ne=>void P(Ne)})]},he.pid))})]}),e[89]=P,e[90]=A,e[91]=q):q=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(qt,{children:"Server activity"}),e[92]=Y):Y=e[92];const K=(a==null?void 0:a.sampleWindowSeconds)??10;let J;e[93]!==K?(J=r.jsxs(Vt,{children:[Y,r.jsxs(Gt,{children:["File checks, streams, and agent work over the last ",K," seconds."]})]}),e[93]=K,e[94]=J):J=e[94];let Z;e[95]!==(a==null?void 0:a.activities)?(Z=(a==null?void 0:a.activities)??[],e[95]=a==null?void 0:a.activities,e[96]=Z):Z=e[96];let Q;e[97]!==Z?(Q=r.jsx(Wt,{children:r.jsx(Qf,{metrics:Z,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Z,e[98]=Q):Q=e[98];let se;e[99]!==J||e[100]!==Q?(se=r.jsxs(Ut,{size:"sm",children:[J,Q]}),e[99]=J,e[100]=Q,e[101]=se):se=e[101];let ne;e[102]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsxs(Vt,{children:[r.jsx(qt,{children:"API activity"}),r.jsx(Gt,{children:"Requests ranked by recent frequency and time."})]}),e[102]=ne):ne=e[102];let ee;e[103]!==(a==null?void 0:a.requests)?(ee=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=ee):ee=e[104];let ie;e[105]!==ee?(ie=r.jsxs(Ut,{size:"sm",children:[ne,r.jsx(Wt,{children:r.jsx(Qf,{metrics:ee,emptyLabel:"No API requests in this sample."})})]}),e[105]=ee,e[106]=ie):ie=e[106];let oe;e[107]!==se||e[108]!==ie?(oe=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[se,ie]}),e[107]=se,e[108]=ie,e[109]=oe):oe=e[109];let re;e[110]!==a?(re=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",Ys(a.eventLoopPercent)," · heap ",ni(a.memory.heapUsedMb)," · RSS ",ni(a.memory.rssMb)]}),e[110]=a,e[111]=re):re=e[111];let te;e[112]!==E||e[113]!==V||e[114]!==q||e[115]!==oe||e[116]!==re||e[117]!==H||e[118]!==B?(te=r.jsxs("div",{className:H,children:[B,E,V,q,oe,re]}),e[112]=E,e[113]=V,e[114]=q,e[115]=oe,e[116]=re,e[117]=H,e[118]=B,e[119]=te):te=e[119];let ce;e[120]!==C||e[121]!==M||e[122]!==te?(ce=r.jsx(C,{className:M,children:te}),e[120]=C,e[121]=M,e[122]=te,e[123]=ce):ce=e[123];let me;e[124]!==T||e[125]!==I||e[126]!==R||e[127]!==D||e[128]!==ce?(me=r.jsxs(T,{className:I,children:[R,D,ce]}),e[124]=T,e[125]=I,e[126]=R,e[127]=D,e[128]=ce,e[129]=me):me=e[129];let pe;return e[130]!==_||e[131]!==L||e[132]!==$||e[133]!==me?(pe=r.jsx(_,{open:L,onOpenChange:$,children:me}),e[130]=_,e[131]=L,e[132]=$,e[133]=me,e[134]=pe):pe=e[134],pe}function OT(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(Et,{}),r.jsx(H1,{metric:n})]},n.pid)}function DT(n){return setTimeout(n,1e3)}function LT(n,e){return n+e.cpuPercent}function zT(n,e){return e.cpuPercent-n.cpuPercent}function FT(n,e){return n+e.cpuPercent}async function BT(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function UT(n){return`${n.title??`Pull request #${n.number}`}
|
|
110
|
+
${n.repo}${n.isDraft?" · draft":""}`}function K1(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:UT(n)}}function Yi(n){const e=F.c(17),{pullRequests:t,max:s,compact:o,layout:i}=n,a=s===void 0?3:s,l=i===void 0?"chips":i;if(!(t!=null&&t.length))return null;if(l==="list"){let u;e[0]!==t?(u=t.map(HT),e[0]=t,e[1]=u):u=e[1];let m;return e[2]!==u?(m=r.jsx("div",{className:"flex flex-col gap-0.5",children:u}),e[2]=u,e[3]=m):m=e[3],m}let c,d;if(e[4]!==o||e[5]!==a||e[6]!==t){const u=t.slice(-a);if(e[9]!==a||e[10]!==t){const p=t.slice(0,-a);c=p.length>0&&r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",title:p.map(WT).join(`
|
|
111
|
+
`),children:["+",p.length]}),e[9]=a,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==o?(m=p=>{const h=p.isDraft?ep:tp;return r.jsxs(Oe,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...K1(p)}),className:G("shrink-0",o&&"px-1"),children:[r.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=o,e[13]=m):m=e[13],d=u.map(m),e[4]=o,e[5]=a,e[6]=t,e[7]=c,e[8]=d}else c=e[7],d=e[8];let f;return e[14]!==c||e[15]!==d?(f=r.jsxs(r.Fragment,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=f):f=e[16],f}function WT(n){return`#${n.number} ${n.title??n.repo}`}function HT(n){const e=n.isDraft?ep:tp;return r.jsxs("a",{...K1(n),className:"flex items-center gap-1 text-foreground hover:underline",children:[r.jsx(e,{className:"size-2.5 shrink-0"}),r.jsxs("span",{className:"shrink-0",children:["#",n.number]}),n.title&&r.jsx("span",{className:"truncate text-muted-foreground",children:n.title})]},n.url)}const KT=b.memo(function(e){const t=F.c(37),{session:s,sessionSource:o,isLive:i,pullRequests:a,copied:l,creatingSession:c,onCopyResume:d,onNewSession:f,onDuplicateSession:u,onOpenTerminal:m}=e;let p;if(t[0]!==o){const P=o?ss(o.fileName):null;p=P?Mc(P.agentId):null,t[0]=o,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(GT),t[2]=s.turns,t[3]=g):g=t[3];const v=g;let x;t[4]!==s.agentKind||t[5]!==s.rawMessages?(x=s.agentKind==="codex"?[]:s.rawMessages,t[4]=s.agentKind,t[5]=s.rawMessages,t[6]=x):x=t[6];const w=x;let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:G(gn,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=y):y=t[7];let j;t[8]!==l||t[9]!==c||t[10]!==d||t[11]!==u||t[12]!==f||t[13]!==m||t[14]!==s||t[15]!==o?(j=o?r.jsx(qT,{session:s,sessionSource:o,copied:l,creatingSession:c,onCopyResume:d,onNewSession:f,onDuplicateSession:u,onOpenTerminal:m}):r.jsx("button",{type:"button",onClick:d,className:"truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground",children:l?"Copied":s.slug||s.sessionId.slice(0,8)}),t[8]=l,t[9]=c,t[10]=d,t[11]=u,t[12]=f,t[13]=m,t[14]=s,t[15]=o,t[16]=j):j=t[16];let N;t[17]!==i?(N=i&&r.jsx(Ti,{"aria-label":"Session is live"}),t[17]=i,t[18]=N):N=t[18];let S;t[19]!==s.model?(S=s.model&&r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:ki(s.model)}),t[19]=s.model,t[20]=S):S=t[20];let k;t[21]!==w?(k=r.jsx(Vp,{rawMessages:w}),t[21]=w,t[22]=k):k=t[22];let C;t[23]!==j||t[24]!==N||t[25]!==S||t[26]!==k?(C=r.jsxs(Nt,{delay:200,render:y,children:[j,N,S,k]}),t[23]=j,t[24]=N,t[25]=S,t[26]=k,t[27]=C):C=t[27];let T;t[28]!==a||t[29]!==w||t[30]!==s||t[31]!==h||t[32]!==v?(T=r.jsx(kt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(VT,{session:s,thinkingEnabled:v,subAgentLabel:h,pullRequests:a,rawMessages:w})}),t[28]=a,t[29]=w,t[30]=s,t[31]=h,t[32]=v,t[33]=T):T=t[33];let _;return t[34]!==T||t[35]!==C?(_=r.jsxs(St,{children:[C,T]}),t[34]=T,t[35]=C,t[36]=_):_=t[36],_});function Rs(n){const e=F.c(7),{label:t,children:s}=n;let o;e[0]!==t?(o=r.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex gap-3",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function VT(n){const e=F.c(33),{session:t,thinkingEnabled:s,subAgentLabel:o,pullRequests:i,rawMessages:a}=n;let l,c,d,f,u,m,p;if(e[0]!==i||e[1]!==a||e[2]!==t.branchedFrom||e[3]!==t.gitBranch||e[4]!==t.model||e[5]!==o||e[6]!==s){const g=Kp(a),v=t.branchedFrom;l="flex min-w-64 max-w-96 flex-col gap-1.5 text-xs",e[14]!==t.model||e[15]!==s?(c=t.model&&r.jsxs(Rs,{label:"Model",children:[r.jsx("span",{children:ki(t.model)}),s&&r.jsx("span",{className:"text-muted-foreground",children:"· thinking"})]}),e[14]=t.model,e[15]=s,e[16]=c):c=e[16],e[17]!==t.gitBranch?(d=t.gitBranch&&r.jsx(Rs,{label:"Branch",children:r.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=d):d=e[18],e[19]!==i?(f=i.length>0&&r.jsx(Rs,{label:"Pull requests",children:r.jsx(Yi,{pullRequests:i})}),e[19]=i,e[20]=f):f=e[20],e[21]!==o?(u=o&&r.jsx(Rs,{label:"Agent",children:o}),e[21]=o,e[22]=u):u=e[22],e[23]!==v?(m=v&&r.jsxs(Rs,{label:"Duplicated from",children:[v.sessionId.slice(0,8),v.turnIndex!=null?` at turn ${v.turnIndex+1}`:""]}),e[23]=v,e[24]=m):m=e[24],p=g&&r.jsxs(Rs,{label:"Context",children:[tt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",tt(g.used)," / ",tt(g.limit)]}),e[0]=i,e[1]=a,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=o,e[6]=s,e[7]=l,e[8]=c,e[9]=d,e[10]=f,e[11]=u,e[12]=m,e[13]=p}else l=e[7],c=e[8],d=e[9],f=e[10],u=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==d||e[28]!==f||e[29]!==u||e[30]!==m||e[31]!==p?(h=r.jsxs("div",{className:l,children:[c,d,f,u,m,p]}),e[25]=l,e[26]=c,e[27]=d,e[28]=f,e[29]=u,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function qT(n){const e=F.c(54),{session:t,sessionSource:s,copied:o,creatingSession:i,onCopyResume:a,onNewSession:l,onDuplicateSession:c,onOpenTerminal:d}=n,{dispatch:f}=Ct(),u=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=vs(),e[0]=m):m=e[0];const p=m;let h;e[1]!==t.sessionId||e[2]!==t.slug?(h=t.slug||t.sessionId.slice(0,8),e[1]=t.sessionId,e[2]=t.slug,e[3]=h):h=e[3];const g=h;let v;e[4]!==t.cwd||e[5]!==g?(v=t.cwd?`${Nn(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=v):v=e[6];const x=v;let w;e[7]!==t.cwd||e[8]!==s.dirName?(w={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=w):w=e[9];const y=w;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=!p||mc(),e[10]=j):j=e[10];const N=j;let S;e[11]!==f||e[12]!==s.dirName?(S=function(){b.startTransition(()=>{f({type:"GO_HOME",isMobile:!1}),f({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=f,e[12]=s.dirName,e[13]=S):S=e[13];const k=S,C=`Copy resume command for ${x}; open session actions with the context menu`;let T;e[14]!==a||e[15]!==C?(T=r.jsx("button",{type:"button",onClick:a,className:"flex min-w-0 max-w-80 items-center gap-1.5 truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent","aria-label":C,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=a,e[15]=C,e[16]=T):T=e[16];let _;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(_=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(rt,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:Nn(t.cwd)}),t.cwd&&r.jsx("span",{className:"text-muted-foreground/50",children:"/"}),r.jsx("span",{className:"truncate",children:g})]}),e[17]=o,e[18]=t.cwd,e[19]=g,e[20]=_):_=e[20];let P;e[21]!==T||e[22]!==_?(P=r.jsx(Bi,{render:T,children:_}),e[21]=T,e[22]=_,e[23]=P):P=e[23];let A;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(A=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=A):A=e[27];let E;e[28]!==i?(E=i?r.jsx(It,{className:"size-3.5"}):r.jsx(xn,{className:"size-3.5"}),e[28]=i,e[29]=E):E=e[29];let M;e[30]!==i||e[31]!==A||e[32]!==E?(M=r.jsxs(Bt,{disabled:i,onClick:A,children:[E,"New session in this project"]}),e[30]=i,e[31]=A,e[32]=E,e[33]=M):M=e[33];let I;e[34]!==c?(I=c&&r.jsxs(Bt,{onClick:c,children:[r.jsx(bn,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=I):I=e[35];let R;e[36]!==u||e[37]!==y?(R=u&&(N||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(Io,{}),N&&r.jsxs(Bt,{onClick:()=>Ah(y),children:[r.jsx(Fo,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(Bt,{onClick:()=>Mh(y),children:[r.jsx(np,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=u,e[37]=y,e[38]=R):R=e[38];let D;e[39]!==d?(D=d&&!p&&at("terminal")&&r.jsxs(Bt,{onClick:d,children:[r.jsx(Zs,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=D):D=e[40];let L;e[41]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Io,{}),e[41]=L):L=e[41];let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(_o,{className:"size-3.5"}),e[42]=$):$=e[42];let z;e[43]!==k?(z=r.jsxs(Bt,{onClick:k,children:[$,"View all sessions in this project"]}),e[43]=k,e[44]=z):z=e[44];let U;e[45]!==M||e[46]!==I||e[47]!==R||e[48]!==D||e[49]!==z?(U=r.jsxs(Ui,{className:"min-w-56",children:[M,I,R,D,L,z]}),e[45]=M,e[46]=I,e[47]=R,e[48]=D,e[49]=z,e[50]=U):U=e[50];let O;return e[51]!==P||e[52]!==U?(O=r.jsxs(Fi,{children:[P,U]}),e[51]=P,e[52]=U,e[53]=O):O=e[53],O}function GT(n){return n.thinking.length>0}const bl="Could not reach the server";async function Er(n,e){try{return await ye(n,e)}catch{return null}}async function Da(n){const e=await(n==null?void 0:n.json().catch(()=>null)),t=e==null?void 0:e.error;return typeof t=="string"&&t.length>0?t:bl}function YT(){const n=F.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=b.useState(e),[o,i]=b.useState(null),a=b.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(a.current=!0,()=>{a.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),b.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const S=await Er("/api/shares");if(!(S!=null&&S.ok))return;const k=await S.json().catch(QT);a.current&&Array.isArray(k)&&s(k)},n[3]=d):d=n[3];const f=d;let u,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{f()},m=[f],n[4]=u,n[5]=m):(u=n[4],m=n[5]),b.useEffect(u,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async S=>{i(null);const k=await Er("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:S})});if(!(k!=null&&k.ok))return a.current&&i(await Da(k)),null;const C=await k.json().catch(ZT);if(!(C!=null&&C.passphrase)||!C.share)return a.current&&i(bl),null;const T=C.share;return a.current&&s(_=>[..._.filter(P=>P.sessionId!==T.sessionId),T]),C.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async S=>{i(null);const k=await Er(`/api/shares/${encodeURIComponent(S)}/regenerate`,{method:"POST"});if(!(k!=null&&k.ok))return a.current&&i(await Da(k)),null;const C=await k.json().catch(JT);return C!=null&&C.passphrase?(f(),C.passphrase):(a.current&&i(bl),null)},n[7]=g):g=n[7];const v=g;let x;n[8]===Symbol.for("react.memo_cache_sentinel")?(x=async S=>{i(null);const k=await Er(`/api/shares/${encodeURIComponent(S)}`,{method:"DELETE"});if(!(k!=null&&k.ok)){a.current&&i(await Da(k));return}a.current&&s(C=>C.filter(T=>T.sessionId!==S))},n[8]=x):x=n[8];const w=x;let y;n[9]!==t?(y=async()=>{const S=t.map(XT);for(const k of S)await w(k)},n[9]=t,n[10]=y):y=n[10];const j=y;let N;return n[11]!==o||n[12]!==j||n[13]!==t?(N={shares:t,error:o,refresh:f,create:h,regenerate:v,revoke:w,revokeAll:j},n[11]=o,n[12]=j,n[13]=t,n[14]=N):N=n[14],N}function XT(n){return n.sessionId}function JT(){return null}function ZT(){return null}function QT(){return null}const e7=5e3,t7="••••";function n7(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function s7({sessionId:n}){const{config:{networkAccessDisabled:e}}=Ct(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=YT(),[c,d]=b.useState(!1),[f,u]=b.useState(null),[m,p]=b.useState(!1),[h,g]=qs(),[v,x]=qs(),w=t.find(S=>S.sessionId===n)??null,y=`${window.location.origin}${Aw(n)}`;b.useEffect(()=>u(null),[n]),b.useEffect(()=>{if(!c)return;o();const S=setInterval(()=>void o(),e7);return()=>clearInterval(S)},[c,o]);async function j(S){p(!0);try{await S()}finally{p(!1)}}const N=e&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return r.jsxs(Rn,{open:c,onOpenChange:S=>{d(S),S||u(null)},children:[r.jsx(In,{render:r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm","aria-label":w?"Session is shared":"Share session",className:G(w&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:r.jsx(av,{"data-icon":"inline-start"})}),r.jsx($n,{align:"end",sideOffset:6,className:"w-80 p-3",children:w?r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:y}),r.jsx(X,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(y),children:h?r.jsx(rt,{"data-icon":"inline-start"}):r.jsx(bn,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:f??t7}),r.jsx(X,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{u(await a(n))}),children:r.jsx(Ht,{"data-icon":"inline-start"})})]}),f?r.jsx(X,{variant:"secondary",size:"xs",onClick:()=>x(`${y}
|
|
112
|
+
Passphrase: ${f}`),children:v?"Copied":"Copy link & passphrase"}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"The passphrase is only shown once. Regenerate to get a new one."}),N,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:n7(w.guests)}),r.jsx(X,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>j(async()=>{await l(n),u(null)}),children:"Stop sharing"})]})]}):r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with the link and passphrase can read and join this session."}),N,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(X,{size:"xs",disabled:m,onClick:()=>j(async()=>{u(await i(n))}),children:"Enable sharing"})]})})]})}function Xn(n){if(!(!n||typeof n.utilization!="number"))return{utilization:n.utilization,resetsAt:typeof n.resets_at=="string"?n.resets_at:void 0}}function o7(n){const e=n.extra_usage;return{providerName:"Claude",fiveHour:Xn(n.five_hour),sevenDay:Xn(n.seven_day),sevenDayOpus:Xn(n.seven_day_opus),sevenDaySonnet:Xn(n.seven_day_sonnet),extraUsage:e?{isEnabled:!!e.is_enabled,monthlyLimit:typeof e.monthly_limit=="number"?e.monthly_limit:void 0,usedCredits:typeof e.used_credits=="number"?e.used_credits:void 0,utilization:typeof e.utilization=="number"?e.utilization:void 0}:void 0,subscriptionType:typeof n.subscriptionType=="string"?n.subscriptionType:void 0}}function Tt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function r7(n){if(n.available!==!0)return null;const e=Tt(n.usage),t=Tt(e==null?void 0:e.rate_limits),s=Tt(n.account),o=Tt(t==null?void 0:t.extra_usage),i={providerName:"Claude",fiveHour:Xn(Tt(t==null?void 0:t.five_hour)),sevenDay:Xn(Tt(t==null?void 0:t.seven_day)),sevenDayOpus:Xn(Tt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:Xn(Tt(t==null?void 0:t.seven_day_sonnet)),extraUsage:o?{isEnabled:!!o.is_enabled,monthlyLimit:typeof o.monthly_limit=="number"?o.monthly_limit:void 0,usedCredits:typeof o.used_credits=="number"?o.used_credits:void 0,utilization:typeof o.utilization=="number"?o.utilization:void 0}:void 0,subscriptionType:typeof(e==null?void 0:e.subscription_type)=="string"?e.subscription_type:typeof(s==null?void 0:s.subscriptionType)=="string"?s.subscriptionType:void 0};return i.fiveHour||i.sevenDay||i.extraUsage||i.subscriptionType?i:null}function i7(n){if(!(typeof n!="number"||!Number.isFinite(n)))return new Date(n<1e10?n*1e3:n).toISOString()}function a7(n,e){return typeof n!="number"||!Number.isFinite(n)||n<=0?e:n%1440===0?`${n/1440}-day`:n%60===0?`${n/60}-hour`:`${n}-minute`}function em(n,e){if(!(!n||typeof n.usedPercent!="number"))return{utilization:n.usedPercent,resetsAt:i7(n.resetsAt),label:a7(n.windowDurationMins,e)}}function l7(n){if(n.available!==!0)return null;const e=Tt(n.rateLimits),t=Tt(e==null?void 0:e.rateLimits),s=Tt(n.account),o=Tt(s==null?void 0:s.account),i=Tt(n.usage),a=Tt(i==null?void 0:i.summary),l=Tt(t==null?void 0:t.credits),c=em(Tt(t==null?void 0:t.primary),"Primary"),d=em(Tt(t==null?void 0:t.secondary),"Secondary"),f=a==null?void 0:a.lifetimeTokens,u=typeof f=="number"?f:typeof f=="string"&&Number.isSafeInteger(Number(f))?Number(f):void 0;return!c&&!d&&u===void 0?null:{providerName:"Codex",fiveHour:c,sevenDay:d,subscriptionType:typeof(t==null?void 0:t.planType)=="string"?t.planType:typeof(o==null?void 0:o.planType)=="string"?o.planType:void 0,lifetimeTokens:u,creditBalance:typeof(l==null?void 0:l.balance)=="string"?l.balance:void 0,creditsUnlimited:(l==null?void 0:l.unlimited)===!0}}const c7=300*1e3;function d7(n="claude"){const e=cn("viewUsage"),[t,s]=b.useState(null),[o,i]=b.useState(!1),[a,l]=b.useState(!1),c=b.useRef(0),d=b.useRef(null),f=b.useCallback(async()=>{var h;if(!e)return;const u=++c.current;(h=d.current)==null||h.abort();const m=new AbortController;d.current=m;const p=()=>c.current===u&&!m.signal.aborted;i(!0);try{let g=await ye(n==="codex"?"/api/codex/runtime":"/api/claude/runtime",{signal:m.signal}),v=!1;if(n==="claude"&&!g.ok&&!m.signal.aborted&&(g=await ye("/api/usage",{signal:m.signal}),v=!0),!p())return;if(g.status===501||g.status===404){l(!1);return}if(!g.ok){l(!0);return}const x=await g.json();if(!p())return;const w=n==="codex"?l7(x):v?o7(x):r7(x);l(w!==null),s(w?{...w,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return b.useEffect(()=>{var m;if(s(null),l(!1),!e){i(!1),c.current+=1,(m=d.current)==null||m.abort(),d.current=null;return}f();const u=setInterval(f,c7);return()=>{var p;clearInterval(u),c.current+=1,(p=d.current)==null||p.abort(),d.current=null}},[e,f]),{usage:e?t:null,loading:e&&o,available:e&&a,refresh:f}}function V1(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const q1={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function u7(n){var d;const e=F.c(29),{usage:t}=n;let s,o,i;if(e[0]!==t.fetchedAt||e[1]!==t.fiveHour||e[2]!==t.providerName||e[3]!==t.sevenDay||e[4]!==t.sevenDayOpus||e[5]!==t.sevenDaySonnet||e[6]!==t.subscriptionType){const f=[];t.fiveHour&&f.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&f.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&f.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&f.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";const u=t.providerName??"Agent";let m;e[10]!==u?(m=r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[u," usage"]}),e[10]=u,e[11]=m):m=e[11];let p;e[12]!==t.subscriptionType?(p=t.subscriptionType&&r.jsx(Oe,{variant:"secondary",children:t.subscriptionType}),e[12]=t.subscriptionType,e[13]=p):p=e[13],e[14]!==m||e[15]!==p?(o=r.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[14]=m,e[15]=p,e[16]=o):o=e[16],i=f.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,v=g!=null?Math.max(0,Math.round(g/36e5)):null,x=V1(h.pct);return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted-foreground",children:h.label}),r.jsxs("span",{className:G("font-semibold",q1[x]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(tc,{value:Math.min(h.pct,100)}),v!=null&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Resets in ",v,"h"]})]},h.label)}),e[0]=t.fetchedAt,e[1]=t.fiveHour,e[2]=t.providerName,e[3]=t.sevenDay,e[4]=t.sevenDayOpus,e[5]=t.sevenDaySonnet,e[6]=t.subscriptionType,e[7]=s,e[8]=o,e[9]=i}else s=e[7],o=e[8],i=e[9];let a;e[17]!==t.extraUsage?(a=((d=t.extraUsage)==null?void 0:d.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(Et,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[17]=t.extraUsage,e[18]=a):a=e[18];let l;e[19]!==t.creditBalance||e[20]!==t.creditsUnlimited||e[21]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&r.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[r.jsx(Et,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",tt(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?r.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?r.jsxs("div",{children:["Credits: ",t.creditBalance]}):null]}),e[19]=t.creditBalance,e[20]=t.creditsUnlimited,e[21]=t.lifetimeTokens,e[22]=l):l=e[22];let c;return e[23]!==s||e[24]!==o||e[25]!==i||e[26]!==a||e[27]!==l?(c=r.jsxs("div",{className:s,children:[o,i,a,l]}),e[23]=s,e[24]=o,e[25]=i,e[26]=a,e[27]=l,e[28]=c):c=e[28],c}function f7(n){var y,j;const e=F.c(20),{agentKind:t}=n,s=t===void 0?"claude":t,{usage:o,loading:i,available:a,refresh:l}=d7(s);if(!a||!o)return null;const c=((y=o.fiveHour)==null?void 0:y.utilization)??((j=o.sevenDay)==null?void 0:j.utilization);if(c==null)return null;const d=`Refresh ${o.providerName??"agent"} usage`;let f;e[0]!==i||e[1]!==l||e[2]!==d?(f=r.jsx(X,{type:"button",variant:"ghost",size:"xs","aria-label":d,onClick:l,disabled:i,className:"mr-1 font-mono"}),e[0]=i,e[1]=l,e[2]=d,e[3]=f):f=e[3];const u=q1[V1(c)],m=i&&"opacity-50";let p;e[4]!==u||e[5]!==m?(p=G("tabular-nums",u,m),e[4]=u,e[5]=m,e[6]=p):p=e[6];let h;e[7]!==c?(h=c.toFixed(0),e[7]=c,e[8]=h):h=e[8];let g;e[9]!==p||e[10]!==h?(g=r.jsxs("span",{className:p,children:[h,"%"]}),e[9]=p,e[10]=h,e[11]=g):g=e[11];let v;e[12]!==f||e[13]!==g?(v=r.jsx(Nt,{render:f,children:g}),e[12]=f,e[13]=g,e[14]=v):v=e[14];let x;e[15]!==o?(x=r.jsx(kt,{side:"bottom",className:"p-3",children:r.jsx(u7,{usage:o})}),e[15]=o,e[16]=x):x=e[16];let w;return e[17]!==x||e[18]!==v?(w=r.jsxs(St,{children:[v,x]}),e[17]=x,e[18]=v,e[19]=w):w=e[19],w}function m7(n,e){const t=F.c(11);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={summary:null,loading:!1,error:null},t[0]=s):s=t[0];const[o,i]=b.useState(s),[a,l]=b.useState(0);let c;t[1]!==n||t[2]!==e?(c=()=>{const p=new AbortController;i(h7);const h=Intl.DateTimeFormat().resolvedOptions().timeZone;return ye(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(h)}`,{signal:p.signal}).then(async g=>{if(!g.ok)throw new Error(`Usage scan failed (${g.status})`);const v=await g.json();i({summary:v,loading:!1,error:null})}).catch(g=>{p.signal.aborted||i(v=>({...v,loading:!1,error:g instanceof Error?g.message:"Usage scan failed"}))}),()=>p.abort()},t[1]=n,t[2]=e,t[3]=c):c=t[3];let d;t[4]!==n||t[5]!==e||t[6]!==a?(d=[n,e,a],t[4]=n,t[5]=e,t[6]=a,t[7]=d):d=t[7],b.useEffect(c,d);let f;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>l(p7),t[8]=f):f=t[8];const u=f;let m;return t[9]!==o?(m={...o,refresh:u},t[9]=o,t[10]=m):m=t[10],m}function p7(n){return n+1}function h7(n){return{...n,loading:!0,error:null}}function g7(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const x7=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function v7(n,e){const t=g7(e);return t.length===0||x7.has(t)?null:n.get(t)??null}function b7(n,e,t,s){const o=v7(n,e);return o===null?{costUsd:0,costSource:"unpriced"}:{costUsd:t.uncachedInputTokens*o.inputCostPerToken+t.cachedInputTokens*o.cacheReadCostPerToken+t.cacheCreationTokens*o.cacheCreationCostPerToken+t.outputTokens*o.outputCostPerToken,costSource:"modelPriced"}}function y7(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function G1(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=b7(n,e,{uncachedInputTokens:t.input_tokens,cachedInputTokens:t.cache_read_input_tokens??0,cacheCreationTokens:t.cache_creation_input_tokens??0,outputTokens:t.output_tokens});return o==="unpriced"?0:s}const w7=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],So=[{key:"claude",label:"Claude Code",color:"var(--chart-1)"},{key:"codex",label:"Codex",color:"var(--chart-2)"}];function j7(n,e){const t=[],o=Date.parse(`${e}T00:00:00Z`);for(let i=Date.parse(`${n}T00:00:00Z`);i<=o;i+=864e5)t.push(new Date(i).toISOString().slice(0,10));return t}function tm(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0}}}function S7(n){const e=new Map;for(const o of j7(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:tm(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:tm(),days:[],models:[]};for(const o of n.buckets){const i=y7(o.totals);s.costUsd+=o.costUsd,s.tokens+=i,s.cacheSavingsUsd+=o.cacheSavingsUsd,s.byProvider[o.provider].costUsd+=o.costUsd,s.byProvider[o.provider].tokens+=i;const a=e.get(o.day);a&&(a.byProvider[o.provider].costUsd+=o.costUsd,a.byProvider[o.provider].tokens+=i,a.costUsd+=o.costUsd,a.tokens+=i);const l=`${o.provider}:${o.model}`;let c=t.get(l);c||(c={provider:o.provider,model:o.model,costUsd:0,tokens:0,unpriced:!0},t.set(l,c)),c.costUsd+=o.costUsd,c.tokens+=i,o.costSource!=="unpriced"&&(c.unpriced=!1)}return s.days=[...e.values()],s.models=[...t.values()].sort((o,i)=>i.costUsd-o.costUsd||i.tokens-o.tokens),s}function nm(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const La=720,za=180,N7=18;function k7(n){const e=F.c(41),{days:t,metric:s}=n,[o,i]=b.useState(null);let a;e[0]!==s?(a=k=>s==="cost"?k.costUsd:k.tokens,e[0]=s,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==t||e[3]!==l){let k;e[5]!==l?(k=C=>l(C),e[5]=l,e[6]=k):k=e[6],c=Math.max(...t.map(k)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const d=c;if(d<=0){let k;return e[7]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=k):k=e[7],k}const f=za-N7,u=La/t.length,m=Math.max(2,Math.min(28,u-2)),p=o!==null?t[o]:null;let h;e[8]!==p||e[9]!==s||e[10]!==l?(h=p&&r.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 z-10 flex justify-center",children:r.jsxs("div",{className:"rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-xs",children:[r.jsx("span",{className:"font-medium",children:nm(p.day)}),So.map(k=>{const{key:C,label:T,color:_}=k,P=p.byProvider[C];return l(P)<=0?null:r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:_}}),T,": ",s==="cost"?qn(P.costUsd):tt(P.tokens)]},C)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?qn(p.costUsd):tt(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let v,x;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=()=>i(null),x=r.jsx("line",{x1:0,y1:f,x2:La,y2:f,stroke:"var(--border)",strokeWidth:1}),e[12]=v,e[13]=x):(v=e[12],x=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==o||e[17]!==d||e[18]!==u||e[19]!==l){let k;e[21]!==m||e[22]!==o||e[23]!==d||e[24]!==u||e[25]!==l?(k=(C,T)=>{const _=T*u+(u-m)/2;let P=f;const A=o===T;return r.jsxs("g",{onMouseEnter:()=>i(T),children:[r.jsx("rect",{x:T*u,y:0,width:u,height:f,fill:"transparent"}),A&&r.jsx("rect",{x:T*u,y:0,width:u,height:f,fill:"var(--foreground)",opacity:.05,rx:2}),So.map(E=>{const{key:M,color:I}=E,R=l(C.byProvider[M]);if(R<=0)return null;const D=R/d*(f-6);return P=P-D,r.jsx("rect",{x:_,y:P,width:m,height:Math.max(1,D-1.5),rx:1.5,fill:I,opacity:A?1:.85},M)})]},C.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=u,e[25]=l,e[26]=k):k=e[26],w=t.map(k),e[14]=m,e[15]=t,e[16]=o,e[17]=d,e[18]=u,e[19]=l,e[20]=w}else w=e[20];let y;if(e[27]!==t||e[28]!==u){let k;e[30]!==t.length||e[31]!==u?(k=(C,T)=>T===0||T===t.length-1||t.length>10&&T%7===0&&T<t.length-3?r.jsx("text",{x:T*u+u/2,y:za-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:nm(C.day)},C.day):null,e[30]=t.length,e[31]=u,e[32]=k):k=e[32],y=t.map(k),e[27]=t,e[28]=u,e[29]=y}else y=e[29];let j;e[33]!==g||e[34]!==w||e[35]!==y?(j=r.jsxs("svg",{viewBox:`0 0 ${La} ${za}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:v,children:[x,w,y]}),e[33]=g,e[34]=w,e[35]=y,e[36]=j):j=e[36];let N;e[37]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:So.map(C7)}),e[37]=N):N=e[37];let S;return e[38]!==h||e[39]!==j?(S=r.jsxs("div",{className:"relative",children:[h,j,N]}),e[38]=h,e[39]=j,e[40]=S):S=e[40],S}function C7(n){const{key:e,label:t,color:s}=n;return r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:s}}),t]},e)}function Fa(n){const e=F.c(7),{label:t,value:s}=n;let o;e[0]!==t?(o=r.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("span",{className:"text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function _7(n){const e=F.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=m7(t,!0),[l,c]=b.useState("cost");let d;e[0]!==s?(d=s?S7(s):null,e[0]=s,e[1]=d):d=e[1];const f=d;if(i){let U;e[2]!==a?(U=r.jsx(X,{variant:"outline",size:"sm",onClick:a,children:"Retry"}),e[2]=a,e[3]=U):U=e[3];let O;return e[4]!==i||e[5]!==U?(O=r.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[i,U]}),e[4]=i,e[5]=U,e[6]=O):O=e[6],O}if(!f||!s){let U;return e[7]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[r.jsx(It,{className:"size-4"})," Scanning transcripts…"]}),e[7]=U):U=e[7],U}const u=o&&"opacity-60";let m;e[8]!==u?(m=G("flex flex-col gap-5",u),e[8]=u,e[9]=m):m=e[9];let p;e[10]!==f.costUsd||e[11]!==f.tokens||e[12]!==l?(p=l==="cost"?qn(f.costUsd):tt(f.tokens),e[10]=f.costUsd,e[11]=f.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=r.jsx("span",{className:"text-3xl font-semibold text-foreground tabular-nums",children:p}),e[14]=p,e[15]=h):h=e[15];const g=l==="cost"?"raw API price":"processed tokens";let v;e[16]!==s.distinctSessions||e[17]!==g?(v=r.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.distinctSessions," sessions · ",g]}),e[16]=s.distinctSessions,e[17]=g,e[18]=v):v=e[18];let x;e[19]!==h||e[20]!==v?(x=r.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,v]}),e[19]=h,e[20]=v,e[21]=x):x=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let y;e[23]!==l?(y=r.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(U=>r.jsx(X,{variant:l===U?"secondary":"ghost",size:"xs",onClick:()=>c(U),children:U==="cost"?"Cost":"Tokens"},U))}),e[23]=l,e[24]=y):y=e[24];let j;e[25]!==f.byProvider||e[26]!==l?(j=So.map(U=>{const{key:O,label:H}=U,B=f.byProvider[O];return B.costUsd===0&&B.tokens===0?null:r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[H,": ",l==="cost"?qn(B.costUsd):tt(B.tokens)]},O)}),e[25]=f.byProvider,e[26]=l,e[27]=j):j=e[27];let N;e[28]!==y||e[29]!==j?(N=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[y,j]}),e[28]=y,e[29]=j,e[30]=N):N=e[30];let S;e[31]!==N||e[32]!==x?(S=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[x,N]}),e[31]=N,e[32]=x,e[33]=S):S=e[33];let k;e[34]!==f.days||e[35]!==l?(k=r.jsx(k7,{days:f.days,metric:l}),e[34]=f.days,e[35]=l,e[36]=k):k=e[36];let C;e[37]!==f.tokens?(C=tt(f.tokens),e[37]=f.tokens,e[38]=C):C=e[38];let T;e[39]!==C?(T=r.jsx(Fa,{label:"Processed tokens",value:C}),e[39]=C,e[40]=T):T=e[40];let _;e[41]!==f.cacheSavingsUsd?(_=qn(f.cacheSavingsUsd),e[41]=f.cacheSavingsUsd,e[42]=_):_=e[42];let P;e[43]!==_?(P=r.jsx(Fa,{label:"Cache savings",value:_}),e[43]=_,e[44]=P):P=e[44];const A=String(s.scannedFiles);let E;e[45]!==A?(E=r.jsx(Fa,{label:"Files scanned",value:A}),e[45]=A,e[46]=E):E=e[46];let M;e[47]!==T||e[48]!==P||e[49]!==E?(M=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[T,P,E]}),e[47]=T,e[48]=P,e[49]=E,e[50]=M):M=e[50];let I;e[51]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("thead",{children:r.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[r.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=I):I=e[51];let R;if(e[52]!==f.costUsd||e[53]!==f.models){let U;e[55]!==f.costUsd?(U=O=>{var H;return r.jsxs("tr",{className:"border-b border-border/50",children:[r.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(H=So.find(B=>B.key===O.provider))==null?void 0:H.color}}),O.model]})}),r.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:O.unpriced?"—":qn(O.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:f.costUsd>0&&!O.unpriced?`${(O.costUsd/f.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:tt(O.tokens)})]},`${O.provider}:${O.model}`)},e[55]=f.costUsd,e[56]=U):U=e[56],R=f.models.map(U),e[52]=f.costUsd,e[53]=f.models,e[54]=R}else R=e[54];let D;e[57]!==R?(D=r.jsxs("table",{className:"w-full text-sm",children:[I,r.jsx("tbody",{children:R})]}),e[57]=R,e[58]=D):D=e[58];const L=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let $;e[59]!==L?($=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",L," ","— not what a subscription bills."]}),e[59]=L,e[60]=$):$=e[60];let z;return e[61]!==S||e[62]!==k||e[63]!==M||e[64]!==D||e[65]!==$||e[66]!==m?(z=r.jsxs("div",{className:m,children:[S,k,M,D,$]}),e[61]=S,e[62]=k,e[63]=M,e[64]=D,e[65]=$,e[66]=m,e[67]=z):z=e[67],z}function T7(n){const e=F.c(15),{open:t,onOpenChange:s}=n,[o,i]=b.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(Ln,{children:"API usage"}),r.jsx(zn,{children:"What this machine's agent usage would cost at raw API prices."})]}),e[0]=a):a=e[0];let l;e[1]!==o?(l=w7.map(m=>r.jsx(X,{variant:o===m.days?"secondary":"ghost",size:"xs",onClick:()=>i(m.days),children:m.label},m.days)),e[1]=o,e[2]=l):l=e[2];let c;e[3]!==l?(c=r.jsx(as,{children:r.jsxs("div",{className:"flex items-center justify-between gap-4 pr-6",children:[a,r.jsx("div",{className:"flex rounded-md border p-0.5",children:l})]})}),e[3]=l,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==t?(d=t&&r.jsx(_7,{days:o}),e[5]=o,e[6]=t,e[7]=d):d=e[7];let f;e[8]!==c||e[9]!==d?(f=r.jsxs(Dn,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,d]}),e[8]=c,e[9]=d,e[10]=f):f=e[10];let u;return e[11]!==s||e[12]!==t||e[13]!==f?(u=r.jsx(On,{open:t,onOpenChange:s,children:f}),e[11]=s,e[12]=t,e[13]=f,e[14]=u):u=e[14],u}const E7=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,P7=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,Ba=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,A7=[new RegExp(`${Ba}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${Ba}'([^']*)'`),new RegExp(`${Ba}(\\S+)`)];function M7(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(!Array.isArray(e))return[];const t=e.filter(s=>typeof s=="string");return[t.join(" "),...t]}function R7(n){return M7(n).find(e=>P7.test(e))??null}function I7(n){for(const e of A7){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function $7(){const n=[],e=new Set;function t(s){e.has(s.url)||(e.add(s.url),n.push(s))}return{pullRequests:n,add:t,record(s,o,i,a){const l=E7.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:I7(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function O7(n){const e=$7();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=R7(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function D7(...n){const e=new Map;for(const t of n)for(const s of t??[])e.has(s.url)||e.set(s.url,s);return[...e.values()].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}const Is="flex h-8 items-center px-0.5",L7=b.memo(function(e){var yt;const t=F.c(123),{showSidebar:s,sidebarRendered:o,sidebarShortcut:i,showStats:a,showWorktrees:l,showFileChanges:c,hasFileChanges:d,killing:f,creatingSession:u,onNewSession:m,onDuplicateSession:p,onOpenTerminal:h,onBackToMain:g,onShowWorkflows:v,workflowCount:x,onToggleSidebar:w,onToggleStats:y,onToggleWorktrees:j,onToggleFileChanges:N,onKillAll:S,onOpenSettings:k,showConfig:C,onToggleConfig:T,showMission:_,onToggleMission:P}=e,A=o===void 0?s:o,{config:E}=Ct(),{networkUrl:M,defaultAgentKind:I}=E,{session:R,sessionSource:D,isLive:L}=st(),$=Ec(),z=cn("viewUsage"),[U,O]=b.useState(!1),[H,B]=b.useState(!1),[W,V]=qs(),q=R==null?void 0:R.turns;let Y;t[0]!==($==null?void 0:$.sessions)||t[1]!==(R==null?void 0:R.sessionId)?(Y=(yt=$==null?void 0:$.sessions.find(zt=>zt.sessionId===(R==null?void 0:R.sessionId)))==null?void 0:yt.pullRequests,t[0]=$==null?void 0:$.sessions,t[1]=R==null?void 0:R.sessionId,t[2]=Y):Y=t[2];const K=Y;let J;t[3]!==K||t[4]!==q?(J=D7(O7(q??[]),K),t[3]=K,t[4]=q,t[5]=J):J=t[5];const Z=J;let Q;t[6]!==I||t[7]!==D?(Q=D?D.agentKind??Jt(D.dirName):I,t[6]=I,t[7]=D,t[8]=Q):Q=t[8];const se=Q;let ne;t[9]!==D?(ne=D?ss(D.fileName)!==null:!1,t[9]=D,t[10]=ne):ne=t[10];const ee=ne;let ie;t[11]!==V||t[12]!==R||t[13]!==(D==null?void 0:D.agentKind)||t[14]!==(D==null?void 0:D.dirName)?(ie=function(){if(!R)return;const Ns=(D==null?void 0:D.agentKind)??Jt((D==null?void 0:D.dirName)??null);V(ch(Ns,R.sessionId,R.cwd))},t[11]=V,t[12]=R,t[13]=D==null?void 0:D.agentKind,t[14]=D==null?void 0:D.dirName,t[15]=ie):ie=t[15];const oe=ie;let re;t[16]!==M?(re=function(){M&&Ko(M).then(F7)},t[16]=M,t[17]=re):re=t[17];const te=re;let ce,me;t[18]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),ce=r.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-gradient-to-b from-background from-50% to-transparent"}),t[18]=ce,t[19]=me):(ce=t[18],me=t[19]);const pe=!A&&"window-inset-start";let xe;t[20]!==pe?(xe=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",pe),t[20]=pe,t[21]=xe):xe=t[21];let we;t[22]!==w||t[23]!==s||t[24]!==i?(we=!s&&r.jsx(z7,{icon:cv,label:`Show sidebar (${i})`,onClick:w}),t[22]=w,t[23]=s,t[24]=i,t[25]=we):we=t[25];let ae;t[26]!==ee||t[27]!==g||t[28]!==R?(ae=R&&ee&&g&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:g,className:G(gn,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(et,{className:"size-3 rotate-180"}),"Main"]}),t[26]=ee,t[27]=g,t[28]=R,t[29]=ae):ae=t[29];let ve;t[30]!==W||t[31]!==u||t[32]!==oe||t[33]!==L||t[34]!==p||t[35]!==m||t[36]!==h||t[37]!==Z||t[38]!==R||t[39]!==D?(ve=R&&r.jsx(KT,{session:R,sessionSource:D,isLive:L,pullRequests:Z,copied:W,creatingSession:u,onCopyResume:oe,onNewSession:m,onDuplicateSession:p,onOpenTerminal:h}),t[30]=W,t[31]=u,t[32]=oe,t[33]=L,t[34]=p,t[35]=m,t[36]=h,t[37]=Z,t[38]=R,t[39]=D,t[40]=ve):ve=t[40];let he;t[41]!==v||t[42]!==R||t[43]!==x?(he=R&&v&&(x??0)>0&&r.jsxs(X,{variant:"ghost",size:"xs",className:G(gn,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:v,children:[r.jsx(sp,{className:"size-3"}),"Workflows",r.jsx(Oe,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:x})]}),t[41]=v,t[42]=R,t[43]=x,t[44]=he):he=t[44];let de;t[45]!==xe||t[46]!==we||t[47]!==ae||t[48]!==ve||t[49]!==he?(de=r.jsxs("div",{className:xe,children:[we,ae,ve,he]}),t[45]=xe,t[46]=we,t[47]=ae,t[48]=ve,t[49]=he,t[50]=de):de=t[50];let Ne,ke,Te;t[51]===Symbol.for("react.memo_cache_sentinel")?(Ne=r.jsx("div",{className:G(gn,Is,"empty:hidden"),children:r.jsx(gT,{})}),ke=r.jsx("div",{className:G(gn,Is,"empty:hidden"),children:r.jsx(NT,{})}),Te=G(gn,Is,"empty:hidden"),t[51]=Ne,t[52]=ke,t[53]=Te):(Ne=t[51],ke=t[52],Te=t[53]);let Ae;t[54]!==se?(Ae=r.jsx("div",{className:Te,children:r.jsx(f7,{agentKind:se})}),t[54]=se,t[55]=Ae):Ae=t[55];let Pe;t[56]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsx("div",{className:G(gn,Is,"empty:hidden"),children:r.jsx(Uc,{})}),t[56]=Pe):Pe=t[56];let De;t[57]!==R?(De=R&&at("share")&&r.jsx("div",{className:G(gn,Is),children:r.jsx(s7,{sessionId:R.sessionId})}),t[57]=R,t[58]=De):De=t[58];let ze;t[59]===Symbol.for("react.memo_cache_sentinel")?(ze=G(gn,Is),t[59]=ze):ze=t[59];let Fe;t[60]===Symbol.for("react.memo_cache_sentinel")?(Fe=r.jsx(In,{render:r.jsx(X,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(op,{"data-icon":"inline-start"})}),t[60]=Fe):Fe=t[60];let ue;t[61]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(es,{children:"Workspace"}),t[61]=ue):ue=t[61];let le;t[62]!==P||t[63]!==_?(le=P&&r.jsxs(it,{onClick:P,children:[r.jsx(dv,{}),"Mission Control",_&&r.jsx(rt,{className:"ml-auto"})]}),t[62]=P,t[63]=_,t[64]=le):le=t[64];let Me;t[65]!==T||t[66]!==C?(Me=T&&r.jsxs(it,{onClick:T,children:[r.jsx(uv,{}),"Config",C&&r.jsx(rt,{className:"ml-auto"})]}),t[65]=T,t[66]=C,t[67]=Me):Me=t[67];let Le;t[68]!==j||t[69]!==l?(Le=j&&r.jsxs(it,{onClick:j,children:[r.jsx(Xs,{}),"Worktrees",l&&r.jsx(rt,{className:"ml-auto"})]}),t[68]=j,t[69]=l,t[70]=Le):Le=t[70];let je;t[71]!==d||t[72]!==N||t[73]!==c?(je=d&&N&&r.jsxs(it,{onClick:N,children:[r.jsx(Wo,{}),"File changes",c&&r.jsx(rt,{className:"ml-auto"})]}),t[71]=d,t[72]=N,t[73]=c,t[74]=je):je=t[74];let fe;t[75]!==y||t[76]!==R||t[77]!==a?(fe=R&&r.jsxs(it,{onClick:y,children:[a?r.jsx(fv,{}):r.jsx(mv,{}),"Session details",a&&r.jsx(rt,{className:"ml-auto"})]}),t[75]=y,t[76]=R,t[77]=a,t[78]=fe):fe=t[78];let Ce;t[79]!==le||t[80]!==Me||t[81]!==Le||t[82]!==je||t[83]!==fe?(Ce=r.jsxs(Lt,{children:[ue,le,Me,Le,je,fe]}),t[79]=le,t[80]=Me,t[81]=Le,t[82]=je,t[83]=fe,t[84]=Ce):Ce=t[84];let _e;t[85]===Symbol.for("react.memo_cache_sentinel")?(_e=r.jsx(Us,{}),t[85]=_e):_e=t[85];let Be;t[86]!==z?(Be=z&&r.jsxs(it,{onClick:()=>O(!0),children:[r.jsx(rp,{}),"Usage & cost…"]}),t[86]=z,t[87]=Be):Be=t[87];let be;t[88]===Symbol.for("react.memo_cache_sentinel")?(be=r.jsxs(it,{onClick:()=>B(!0),children:[r.jsx(ip,{}),"Server monitor…"]}),t[88]=be):be=t[88];let Ee;t[89]!==te||t[90]!==M?(Ee=M&&r.jsxs(it,{onClick:te,children:[r.jsx(Ya,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:M})]}),t[89]=te,t[90]=M,t[91]=Ee):Ee=t[91];let Ie;t[92]!==Be||t[93]!==Ee?(Ie=r.jsxs(Lt,{children:[Be,be,Ee]}),t[92]=Be,t[93]=Ee,t[94]=Ie):Ie=t[94];let Ue;t[95]===Symbol.for("react.memo_cache_sentinel")?(Ue=r.jsx(Us,{}),t[95]=Ue):Ue=t[95];let Je;t[96]===Symbol.for("react.memo_cache_sentinel")?(Je=r.jsx(pv,{}),t[96]=Je):Je=t[96];let qe;t[97]!==k?(qe=r.jsx(Lt,{children:r.jsxs(it,{onClick:k,children:[Je,"Settings"]})}),t[97]=k,t[98]=qe):qe=t[98];let Ze;t[99]!==f||t[100]!==S?(Ze=at("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(Us,{}),r.jsx(Lt,{children:r.jsxs(it,{variant:"destructive",onClick:S,disabled:f,children:[r.jsx(lv,{}),f?"Stopping processes…":"Stop all agent processes"]})})]}),t[99]=f,t[100]=S,t[101]=Ze):Ze=t[101];let Ke;t[102]!==Ce||t[103]!==Ie||t[104]!==qe||t[105]!==Ze?(Ke=r.jsx("div",{className:ze,children:r.jsxs(Rn,{children:[Fe,r.jsxs($n,{align:"end",sideOffset:6,className:"w-64",children:[Ce,_e,Ie,Ue,qe,Ze]})]})}),t[102]=Ce,t[103]=Ie,t[104]=qe,t[105]=Ze,t[106]=Ke):Ke=t[106];let Re;t[107]!==Ae||t[108]!==De||t[109]!==Ke?(Re=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[Ne,ke,Ae,Pe,De,Ke]}),t[107]=Ae,t[108]=De,t[109]=Ke,t[110]=Re):Re=t[110];let He;t[111]!==de||t[112]!==Re?(He=r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-30 flex items-start justify-between gap-3 px-3 pt-2",children:[de,Re]}),t[111]=de,t[112]=Re,t[113]=He):He=t[113];let $e;t[114]!==z||t[115]!==U?($e=z&&r.jsx(T7,{open:U,onOpenChange:O}),t[114]=z,t[115]=U,t[116]=$e):$e=t[116];let We;t[117]!==H?(We=r.jsx($T,{open:H,onOpenChange:B}),t[117]=H,t[118]=We):We=t[118];let Ye;return t[119]!==He||t[120]!==$e||t[121]!==We?(Ye=r.jsxs(r.Fragment,{children:[me,ce,He,$e,We]}),t[119]=He,t[120]=$e,t[121]=We,t[122]=Ye):Ye=t[122],Ye});function z7(n){const e=F.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=G(gn,"size-8 shrink-0"),e[0]=i):i=e[0];let a;e[1]!==s||e[2]!==o?(a=r.jsx(X,{variant:"ghost",size:"icon-sm",onClick:o,"aria-label":s,className:i}),e[1]=s,e[2]=o,e[3]=a):a=e[3];let l;e[4]!==t?(l=r.jsx(t,{"data-icon":"inline-start"}),e[4]=t,e[5]=l):l=e[5];let c;e[6]!==a||e[7]!==l?(c=r.jsx(Nt,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(kt,{side:"bottom",children:s}),e[9]=s,e[10]=d):d=e[10];let f;return e[11]!==c||e[12]!==d?(f=r.jsxs(St,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=f):f=e[13],f}function F7(n){n&&ds.success("Copied network URL")}const B7=150,U7="(prefers-reduced-motion: reduce)";function W7(){if(typeof window.matchMedia!="function")return!1;try{return window.matchMedia(U7).matches}catch{return!1}}function H7(n){const e=F.c(5),{side:t,children:s,visible:o,enabled:i}=n,a=i===void 0?!0:i;if(o){let c;return e[0]!==s?(c=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=c):c=e[1],c}if(!a)return null;let l;return e[2]!==s||e[3]!==t?(l=r.jsx(K7,{side:t,children:s}),e[2]=s,e[3]=t,e[4]=l):l=e[4],l}function K7(n){const e=F.c(26),{side:t,children:s}=n,[o,i]=b.useState(!1),[a,l]=b.useState(!1),c=b.useRef(0),d=b.useRef(0),f=b.useRef(0),u=b.useRef(null),m=b.useRef(null),p=b.useRef(!1),h=b.useId();let g,v;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>{clearTimeout(c.current),clearTimeout(d.current),clearTimeout(f.current)},v=[],e[0]=g,e[1]=v):(g=e[0],v=e[1]),b.useEffect(g,v);let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{clearTimeout(f.current),l(!0),i(!0)},e[2]=x):x=e[2];const w=x;let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{if(clearTimeout(f.current),i(!1),W7()){l(!1);return}f.current=window.setTimeout(()=>{f.current=0,l(!1)},B7)},e[3]=y):y=e[3];const j=y;let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{clearTimeout(d.current),clearTimeout(c.current),c.current=window.setTimeout(w,200)},e[4]=N):N=e[4];const S=N;let k;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{clearTimeout(d.current),clearTimeout(c.current),w()},e[5]=k):k=e[5];const C=k;let T;e[6]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{if(p.current){p.current=!1;return}C()},e[6]=T):T=e[6];const _=T;let P;e[7]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{clearTimeout(c.current),d.current=window.setTimeout(j,300)},e[7]=P):P=e[7];const A=P;let E;e[8]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{var V,q;const W=document.activeElement;(V=u.current)!=null&&V.contains(W)||(q=m.current)!=null&&q.contains(W)||A()},e[8]=E):E=e[8];const M=E;let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=W=>{var q,Y;const V=W.relatedTarget;(q=u.current)!=null&&q.contains(V)||(Y=m.current)!=null&&Y.contains(V)||A()},e[9]=I):I=e[9];const R=I;let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D=W=>{W.key==="Escape"&&(W.preventDefault(),clearTimeout(c.current),clearTimeout(d.current),j(),p.current=!0,requestAnimationFrame(()=>{var V;return(V=u.current)==null?void 0:V.focus()}))},e[10]=D):D=e[10];const L=D,$=`Reveal ${t} sidebar`,z=`Reveal ${t} sidebar`;let U;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx("span",{"aria-hidden":"true",className:"mx-auto h-full w-px bg-border opacity-0 transition-opacity duration-150 group-hover:opacity-100"}),e[11]=U):U=e[11];let O;e[12]!==o||e[13]!==h||e[14]!==$||e[15]!==z?(O=r.jsx(X,{ref:u,type:"button",variant:"ghost","aria-label":$,"aria-controls":h,"aria-expanded":o,title:z,className:"group relative z-10 h-auto w-1.5 shrink-0 rounded-none p-0 focus-visible:ring-inset",onMouseEnter:S,onMouseLeave:M,onFocus:_,onBlur:R,onClick:C,children:U}),e[12]=o,e[13]=h,e[14]=$,e[15]=z,e[16]=O):O=e[16];let H;e[17]!==s||e[18]!==a||e[19]!==o||e[20]!==h||e[21]!==t?(H=a&&r.jsx("div",{ref:m,id:h,"aria-hidden":!o,inert:!o,className:G("electron-no-drag absolute inset-y-0 z-40 bg-background shadow-sm",!o&&"pointer-events-none animate-out fade-out-0 fill-mode-forwards duration-150 ease-in",t==="left"?o?"left-0 border-r panel-enter":"left-0 border-r slide-out-to-left-3":o?"right-0 border-l panel-enter-right":"right-0 border-l slide-out-to-right-3"),onMouseEnter:S,onMouseLeave:M,onFocusCapture:C,onBlurCapture:R,onKeyDown:L,children:s}),e[17]=s,e[18]=a,e[19]=o,e[20]=h,e[21]=t,e[22]=H):H=e[22];let B;return e[23]!==O||e[24]!==H?(B=r.jsxs(r.Fragment,{children:[O,H]}),e[23]=O,e[24]=H,e[25]=B):B=e[25],B}const V7=b.memo(function(e){const t=F.c(13),{onToggleSidebar:s,onGoHome:o,onOpenCommandPalette:i,sidebarShortcut:a,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let d;t[1]!==o?(d=r.jsx(ma,{icon:Js,label:"Home",onClick:o,size:"default"}),t[1]=o,t[2]=d):d=t[2];const f=`Search (${l})`;let u;t[3]!==i||t[4]!==f?(u=r.jsx(ma,{icon:an,label:f,onClick:i,size:"default"}),t[3]=i,t[4]=f,t[5]=u):u=t[5];const m=`Hide sidebar (${a})`;let p;t[6]!==s||t[7]!==m?(p=r.jsx(ma,{icon:hv,label:m,onClick:s,size:"default"}),t[6]=s,t[7]=m,t[8]=p):p=t[8];let h;return t[9]!==d||t[10]!==u||t[11]!==p?(h=r.jsxs("div",{className:"electron-drag window-inset-start flex h-12 shrink-0 items-center gap-1 px-2",children:[c,d,u,p]}),t[9]=d,t[10]=u,t[11]=p,t[12]=h):h=t[12],h}),yl=new Map;let Ua=null,Wa=null;async function q7(){try{const n=await ye("/api/usage-cost/rates");if(!n.ok)return yl;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return yl}}function Y1(){const[n,e]=b.useState(Ua??yl);return b.useEffect(()=>{if(Ua!==null)return;let t=!0;return Wa??(Wa=q7().then(s=>(s.size>0&&(Ua=s),Wa=null,s))),Wa.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function G7(n,e){return n.map((t,s)=>{var p,h,g,v;const o=((p=t.tokenUsage)==null?void 0:p.input_tokens)??0,i=((h=t.tokenUsage)==null?void 0:h.cache_read_input_tokens)??0,a=((g=t.tokenUsage)==null?void 0:g.cache_creation_input_tokens)??0,l=o+i+a,c=t.subAgentActivity.length>0,d=v3(t),f=b3(t),u=Math.max(d+f,((v=t.tokenUsage)==null?void 0:v.output_tokens)??0),m=t.tokenUsage?G1(e,t.model,t.tokenUsage):0;return{turn:s+1,totalInput:l,totalOutput:u,thinkingTokens:d,visibleTokens:f,newInput:o,cacheRead:i,cacheWrite:a,hasSubAgents:c,cost:m}})}function Y7(n){const e=F.c(41),{data:t}=n;let s;e[0]!==t.turn?(s=r.jsxs("div",{className:"mb-1 font-medium text-foreground",children:["Turn ",t.turn]}),e[0]=t.turn,e[1]=s):s=e[1];let o;e[2]!==t.totalInput?(o=tt(t.totalInput),e[2]=t.totalInput,e[3]=o):o=e[3];let i;e[4]!==o?(i=r.jsx("span",{className:"text-info",children:o}),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==t.cacheRead?(a=tt(t.cacheRead),e[6]=t.cacheRead,e[7]=a):a=e[7];let l;e[8]!==t.cacheWrite?(l=tt(t.cacheWrite),e[8]=t.cacheWrite,e[9]=l):l=e[9];let c;e[10]!==t.newInput?(c=tt(t.newInput),e[10]=t.newInput,e[11]=c):c=e[11];let d;e[12]!==a||e[13]!==l||e[14]!==c?(d=r.jsxs("span",{className:"ml-1 opacity-60",children:["(",a," cached, ",l," written, ",c," new)"]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d):d=e[15];let f;e[16]!==i||e[17]!==d?(f=r.jsxs("span",{children:["Input: ",i,d]}),e[16]=i,e[17]=d,e[18]=f):f=e[18];let u;e[19]!==t.totalOutput?(u=tt(t.totalOutput),e[19]=t.totalOutput,e[20]=u):u=e[20];let m;e[21]!==u?(m=r.jsx("span",{className:"text-success",children:u}),e[21]=u,e[22]=m):m=e[22];let p;e[23]!==t.thinkingTokens||e[24]!==t.visibleTokens?(p=t.thinkingTokens>0&&r.jsxs("span",{className:"ml-1 opacity-60",children:["(",tt(t.thinkingTokens)," thinking, ",tt(t.visibleTokens)," text)"]}),e[23]=t.thinkingTokens,e[24]=t.visibleTokens,e[25]=p):p=e[25];let h;e[26]!==m||e[27]!==p?(h=r.jsxs("span",{children:["Output: ",m,p]}),e[26]=m,e[27]=p,e[28]=h):h=e[28];let g;e[29]!==t.cost?(g=t.cost>0&&r.jsxs("span",{children:["API cost: ",r.jsx("span",{className:"text-warning",children:qn(t.cost)})]}),e[29]=t.cost,e[30]=g):g=e[30];let v;e[31]!==t.hasSubAgents?(v=t.hasSubAgents&&r.jsx("span",{className:"text-warning",children:"Has sub-agent activity"}),e[31]=t.hasSubAgents,e[32]=v):v=e[32];let x;e[33]!==h||e[34]!==g||e[35]!==v||e[36]!==f?(x=r.jsxs("div",{className:"flex flex-col gap-0.5 text-muted-foreground",children:[f,h,g,v]}),e[33]=h,e[34]=g,e[35]=v,e[36]=f,e[37]=x):x=e[37];let w;return e[38]!==s||e[39]!==x?(w=r.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-[28px] z-10 px-1",children:r.jsxs("div",{className:"w-fit rounded-md border bg-popover px-2.5 py-2 text-xs text-popover-foreground shadow-xs",children:[s,x]})}),e[38]=s,e[39]=x,e[40]=w):w=e[40],w}function X7(n){const e=F.c(33),{padLeft:t,svgHeight:s}=n,o=s-10;let i;e[0]!==t||e[1]!==o?(i=r.jsx("rect",{x:t,y:o,width:6,height:6,rx:1.5,fill:"var(--info)",opacity:.85}),e[0]=t,e[1]=o,e[2]=i):i=e[2];const a=t+9,l=s-4;let c;e[3]!==a||e[4]!==l?(c=r.jsx("text",{x:a,y:l,className:"fill-muted-foreground text-xs",children:"Input"}),e[3]=a,e[4]=l,e[5]=c):c=e[5];const d=t+48,f=s-10;let u;e[6]!==d||e[7]!==f?(u=r.jsx("rect",{x:d,y:f,width:6,height:6,rx:1.5,fill:"var(--success)",opacity:.7}),e[6]=d,e[7]=f,e[8]=u):u=e[8];const m=t+57,p=s-4;let h;e[9]!==p||e[10]!==m?(h=r.jsx("text",{x:m,y:p,className:"fill-muted-foreground text-xs",children:"Output"}),e[9]=p,e[10]=m,e[11]=h):h=e[11];const g=t+104,v=s-10;let x;e[12]!==g||e[13]!==v?(x=r.jsx("rect",{x:g,y:v,width:6,height:6,rx:1.5,fill:"var(--muted-foreground)",opacity:.45}),e[12]=g,e[13]=v,e[14]=x):x=e[14];const w=t+113,y=s-4;let j;e[15]!==w||e[16]!==y?(j=r.jsx("text",{x:w,y,className:"fill-muted-foreground text-xs",children:"Think"}),e[15]=w,e[16]=y,e[17]=j):j=e[17];const N=t+155,S=s-7;let k;e[18]!==N||e[19]!==S?(k=r.jsx("circle",{cx:N,cy:S,r:2,fill:"var(--warning)",opacity:.8}),e[18]=N,e[19]=S,e[20]=k):k=e[20];const C=t+162,T=s-4;let _;e[21]!==C||e[22]!==T?(_=r.jsx("text",{x:C,y:T,className:"fill-muted-foreground text-xs",children:"Agent"}),e[21]=C,e[22]=T,e[23]=_):_=e[23];let P;return e[24]!==h||e[25]!==x||e[26]!==j||e[27]!==i||e[28]!==k||e[29]!==_||e[30]!==c||e[31]!==u?(P=r.jsxs(r.Fragment,{children:[i,c,u,h,x,j,k,_]}),e[24]=h,e[25]=x,e[26]=j,e[27]=i,e[28]=k,e[29]=_,e[30]=c,e[31]=u,e[32]=P):P=e[32],P}function J7(n){const e=F.c(61),{data:t,groupX:s,barW:o,groupW:i,baseY:a,chartH:l,maxVal:c,isHovered:d,onHover:f,padTop:u}=n,m=t.cacheRead/c*l,p=t.cacheWrite/c*l,h=t.newInput/c*l,g=t.thinkingTokens/c*l,v=t.visibleTokens/c*l;let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={cursor:"crosshair"},e[0]=x):x=e[0];let w;e[1]!==l||e[2]!==i||e[3]!==s||e[4]!==u?(w=r.jsx("rect",{x:s,y:u,width:i,height:l,fill:"transparent"}),e[1]=l,e[2]=i,e[3]=s,e[4]=u,e[5]=w):w=e[5];let y;e[6]!==l||e[7]!==i||e[8]!==s||e[9]!==d||e[10]!==u?(y=d&&r.jsx("rect",{x:s-1,y:u,width:i+2,height:l,fill:"var(--foreground)",opacity:.04,rx:2}),e[6]=l,e[7]=i,e[8]=s,e[9]=d,e[10]=u,e[11]=y):y=e[11];let j;e[12]!==o||e[13]!==a||e[14]!==m||e[15]!==s||e[16]!==d?(j=m>0&&r.jsx("rect",{x:s,y:a-m,width:o,height:m,rx:1,fill:"var(--info)",opacity:d?.45:.25}),e[12]=o,e[13]=a,e[14]=m,e[15]=s,e[16]=d,e[17]=j):j=e[17];let N;e[18]!==o||e[19]!==a||e[20]!==m||e[21]!==p||e[22]!==s||e[23]!==d?(N=p>0&&r.jsx("rect",{x:s,y:a-m-p,width:o,height:p,rx:1,fill:"var(--info)",opacity:d?.7:.5}),e[18]=o,e[19]=a,e[20]=m,e[21]=p,e[22]=s,e[23]=d,e[24]=N):N=e[24];let S;e[25]!==o||e[26]!==a||e[27]!==m||e[28]!==p||e[29]!==s||e[30]!==d||e[31]!==h?(S=h>0&&r.jsx("rect",{x:s,y:a-m-p-h,width:o,height:h,rx:1,fill:"var(--info)",opacity:d?1:.85}),e[25]=o,e[26]=a,e[27]=m,e[28]=p,e[29]=s,e[30]=d,e[31]=h,e[32]=S):S=e[32];let k;e[33]!==o||e[34]!==a||e[35]!==s||e[36]!==d||e[37]!==g?(k=g>0&&r.jsx("rect",{x:s+o+1,y:a-g,width:o,height:g,rx:1,fill:"var(--muted-foreground)",opacity:d?.7:.45}),e[33]=o,e[34]=a,e[35]=s,e[36]=d,e[37]=g,e[38]=k):k=e[38];let C;e[39]!==o||e[40]!==a||e[41]!==s||e[42]!==d||e[43]!==g||e[44]!==v?(C=v>0&&r.jsx("rect",{x:s+o+1,y:a-g-v,width:o,height:v,rx:1,fill:"var(--success)",opacity:d?.95:.7}),e[39]=o,e[40]=a,e[41]=s,e[42]=d,e[43]=g,e[44]=v,e[45]=C):C=e[45];let T;e[46]!==a||e[47]!==t.hasSubAgents||e[48]!==i||e[49]!==s?(T=t.hasSubAgents&&r.jsx("circle",{cx:s+i/2,cy:a+5,r:1.5,fill:"var(--warning)",opacity:.8}),e[46]=a,e[47]=t.hasSubAgents,e[48]=i,e[49]=s,e[50]=T):T=e[50];let _;return e[51]!==f||e[52]!==w||e[53]!==y||e[54]!==j||e[55]!==N||e[56]!==S||e[57]!==k||e[58]!==C||e[59]!==T?(_=r.jsxs("g",{onMouseEnter:f,style:x,children:[w,y,j,N,S,k,C,T]}),e[51]=f,e[52]=w,e[53]=y,e[54]=j,e[55]=N,e[56]=S,e[57]=k,e[58]=C,e[59]=T,e[60]=_):_=e[60],_}const X1=280,wl=130,Fr=16,Z7=22,fs=36,Q7=8,Pr=X1-fs-Q7,sm=wl-Fr-Z7;function e8(n){const e=F.c(34),{turns:t}=n,[s,o]=b.useState(null),i=Y1();let a;e[0]!==i||e[1]!==t?(a=G7(t,i),e[0]=i,e[1]=t,e[2]=a):a=e[2];const l=a;if(l.length===0)return null;let c;e[3]!==l?(c=Math.max(...l.map(n8),...l.map(t8)),e[3]=l,e[4]=c):c=e[4];const d=c;if(d===0)return null;const f=Math.max(5,Math.min(20,Pr/l.length)),u=Math.max(2,(f-1)/2),m=Fr+sm,p=s!==null?l[s]:null;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Fn,{children:"Input / Output Per Turn"}),e[5]=h):h=e[5];let g;e[6]!==p?(g=p&&r.jsx(Y7,{data:p}),e[6]=p,e[7]=g):g=e[7];let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>o(null),e[8]=v):v=e[8];let x;e[9]!==d?(x=tt(d),e[9]=d,e[10]=x):x=e[10];let w;e[11]!==x?(w=r.jsx("text",{x:fs-4,y:Fr,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:x}),e[11]=x,e[12]=w):w=e[12];let y,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("text",{x:fs-4,y:m,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:"0"}),j=r.jsx("line",{x1:fs,y1:m,x2:fs+Pr,y2:m,stroke:"var(--border)",strokeWidth:.5}),e[13]=y,e[14]=j):(y=e[13],j=e[14]);let N;if(e[15]!==u||e[16]!==l||e[17]!==f||e[18]!==s||e[19]!==d){let T;e[21]!==u||e[22]!==l.length||e[23]!==f||e[24]!==s||e[25]!==d?(T=(_,P)=>{const A=fs+(l.length===1?(Pr-f)/2:P/(l.length-1)*(Pr-f));return r.jsx(J7,{data:_,groupX:A,barW:u,groupW:f,baseY:m,chartH:sm,maxVal:d,isHovered:s===P,onHover:()=>o(P),padTop:Fr},P)},e[21]=u,e[22]=l.length,e[23]=f,e[24]=s,e[25]=d,e[26]=T):T=e[26],N=l.map(T),e[15]=u,e[16]=l,e[17]=f,e[18]=s,e[19]=d,e[20]=N}else N=e[20];let S;e[27]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(X7,{padLeft:fs,svgHeight:wl}),e[27]=S):S=e[27];let k;e[28]!==N||e[29]!==w?(k=r.jsxs("svg",{width:"100%",viewBox:`0 0 ${X1} ${wl}`,onMouseLeave:v,children:[w,y,j,N,S]}),e[28]=N,e[29]=w,e[30]=k):k=e[30];let C;return e[31]!==k||e[32]!==g?(C=r.jsxs("section",{className:"relative",children:[h,g,k]}),e[31]=k,e[32]=g,e[33]=C):C=e[33],C}function t8(n){return n.totalOutput}function n8(n){return n.totalInput}const om=280,rm=32;function s8(n){const e=F.c(19),{turns:t}=n,[s,o]=b.useState(null);let i;e[0]!==t?(i=Math.max(1,...t.map(o8)),e[0]=t,e[1]=i):i=e[1];const a=i;if(t.length===0)return null;const l=Math.max(2,Math.min(20,om/t.length)),c=l*t.length;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Fn,{children:"Activity Heatmap"}),e[2]=d):d=e[2];const f=`0 0 ${Math.max(om,c)} ${rm}`;let u;if(e[3]!==a||e[4]!==l||e[5]!==t){let g;e[7]!==a||e[8]!==l?(g=(v,x)=>{const y=.1+v.toolCalls.length/a*.9;return r.jsx("rect",{x:x*l,y:0,width:l-1,height:rm,rx:2,fill:"var(--foreground)",opacity:y,onMouseEnter:()=>o(x),onMouseLeave:()=>o(null),className:"cursor-pointer"},x)},e[7]=a,e[8]=l,e[9]=g):g=e[9],u=t.map(g),e[3]=a,e[4]=l,e[5]=t,e[6]=u}else u=e[6];let m;e[10]!==f||e[11]!==u?(m=r.jsx("svg",{width:"100%",viewBox:f,children:u}),e[10]=f,e[11]=u,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==t?(p=s!==null&&r.jsxs("div",{className:"pointer-events-none absolute -top-9 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-xs",children:["Turn ",s+1,": ",t[s].toolCalls.length," tool calls"]}),e[13]=s,e[14]=t,e[15]=p):p=e[15];let h;return e[16]!==m||e[17]!==p?(h=r.jsxs("section",{children:[d,r.jsxs("div",{className:"relative",children:[m,p]})]}),e[16]=m,e[17]=p,e[18]=h):h=e[18],h}function o8(n){return n.toolCalls.length}function r8(n){const e=F.c(7),{turns:t}=n;let s;if(e[0]!==t){const c={};for(const d of t)d.model&&(c[d.model]=(c[d.model]??0)+1);s=Object.entries(c).sort(a8),e[0]=t,e[1]=s}else s=e[1];const o=s;if(o.length<=1)return null;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Fn,{children:"Models"}),e[2]=i):i=e[2];let a;e[3]!==o?(a=o.map(i8),e[3]=o,e[4]=a):a=e[4];let l;return e[5]!==a?(l=r.jsxs("section",{children:[i,r.jsx("div",{className:"flex flex-col gap-1",children:a})]}),e[5]=a,e[6]=l):l=e[6],l}function i8(n){const[e,t]=n;return r.jsxs("div",{className:"flex items-center justify-between rounded-md border bg-card px-2.5 py-1.5 text-xs",children:[r.jsx("span",{className:"truncate text-foreground",children:e}),r.jsx("span",{className:"ml-2 shrink-0 text-muted-foreground",children:t})]},e)}function a8(n,e){const[,t]=n,[,s]=e;return s-t}const l8=["agent","skill","plugin","mcpServer","mcpTool"],c8={agent:"Agents",skill:"Skills",plugin:"Plugins",mcpServer:"MCP servers",mcpTool:"MCP tools"},Ar="Unattributed";function im(n){return n.inputTokens+n.outputTokens}function d8(n,e){var i;const t=new Map;for(const a of n){const l=((i=a.attribution)==null?void 0:i[e])??Ar;let c=t.get(l);c||(c={name:l,turns:0,inputTokens:0,outputTokens:0,isUnattributed:l===Ar},t.set(l,c)),c.turns+=1;const d=a.tokenUsage;d&&(c.inputTokens+=d.input_tokens+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0),c.outputTokens+=d.output_tokens)}const s=t.get(Ar);s&&t.delete(Ar);const o=[...t.values()].sort((a,l)=>im(l)-im(a));return s&&o.push(s),o}function u8(n){return l8.filter(e=>n.some(t=>{var s;return(s=t.attribution)==null?void 0:s[e]}))}function f8(n){const e=F.c(38),{bucket:t,maxTotal:s}=n,o=t.inputTokens+t.outputTokens,i=s>0?o/s:0,a=o>0?t.inputTokens/o*i:0,l=o>0?t.outputTokens/o*i:0,c=t.name,d=t.turns;let f;e[0]!==t.inputTokens?(f=tt(t.inputTokens),e[0]=t.inputTokens,e[1]=f):f=e[1];let u;e[2]!==t.outputTokens?(u=tt(t.outputTokens),e[2]=t.outputTokens,e[3]=u):u=e[3];const m=`${c} — ${d} ${t.turns===1?"turn":"turns"}, ${f} input, ${u} output`,p=t.isUnattributed?"truncate text-muted-foreground":"truncate text-foreground";let h;e[4]!==t.name||e[5]!==p?(h=r.jsx("span",{className:p,children:t.name}),e[4]=t.name,e[5]=p,e[6]=h):h=e[6];const g=t.turns===1?"turn":"turns";let v;e[7]!==t.turns||e[8]!==g?(v=r.jsxs("span",{children:[t.turns," ",g]}),e[7]=t.turns,e[8]=g,e[9]=v):v=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("span",{className:"opacity-40",children:"·"}),e[10]=x):x=e[10];let w;e[11]!==o?(w=tt(o),e[11]=o,e[12]=w):w=e[12];let y;e[13]!==w?(y=r.jsx("span",{children:w}),e[13]=w,e[14]=y):y=e[14];let j;e[15]!==y||e[16]!==v?(j=r.jsxs("span",{className:"ml-2 flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground",children:[v,x,y]}),e[15]=y,e[16]=v,e[17]=j):j=e[17];let N;e[18]!==j||e[19]!==h?(N=r.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[h,j]}),e[18]=j,e[19]=h,e[20]=N):N=e[20];const S=t.isUnattributed?"rounded-xs bg-info/35":"rounded-xs bg-info/85",k=`${a*100}%`;let C;e[21]!==k?(C={width:k},e[21]=k,e[22]=C):C=e[22];let T;e[23]!==S||e[24]!==C?(T=r.jsx("div",{className:S,style:C}),e[23]=S,e[24]=C,e[25]=T):T=e[25];const _=t.isUnattributed?"rounded-xs bg-success/35":"rounded-xs bg-success/70",P=`${l*100}%`;let A;e[26]!==P?(A={width:P},e[26]=P,e[27]=A):A=e[27];let E;e[28]!==_||e[29]!==A?(E=r.jsx("div",{className:_,style:A}),e[28]=_,e[29]=A,e[30]=E):E=e[30];let M;e[31]!==T||e[32]!==E?(M=r.jsxs("div",{className:"mt-1.5 flex h-1 gap-[2px]","aria-hidden":"true",children:[T,E]}),e[31]=T,e[32]=E,e[33]=M):M=e[33];let I;return e[34]!==N||e[35]!==M||e[36]!==m?(I=r.jsxs("li",{className:"rounded-md border bg-card px-2.5 py-1.5",title:m,children:[N,M]}),e[34]=N,e[35]=M,e[36]=m,e[37]=I):I=e[37],I}function m8(){const n=F.c(2);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"size-1.5 rounded-xs bg-info/85"}),"Input"]}),n[0]=e):e=n[0];let t;return n[1]===Symbol.for("react.memo_cache_sentinel")?(t=r.jsxs("div",{className:"mt-2 flex items-center gap-3 text-xs text-muted-foreground",children:[e,r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"size-1.5 rounded-xs bg-success/70"}),"Output"]})]}),n[1]=t):t=n[1],t}function p8(n){const e=F.c(25),{turns:t}=n;let s;e[0]!==t?(s=u8(t),e[0]=t,e[1]=s):s=e[1];const o=s,[i,a]=b.useState(null);let l;e[2]!==o||e[3]!==i?(l=i&&o.includes(i)?i:o[0],e[2]=o,e[3]=i,e[4]=l):l=e[4];const c=l;let d;e[5]!==c||e[6]!==t?(d=c?d8(t,c):[],e[5]=c,e[6]=t,e[7]=d):d=e[7];const f=d;if(!c)return null;let u;e[8]!==f?(u=Math.max(...f.map(g8)),e[8]=f,e[9]=u):u=e[9];const m=u;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Fn,{children:"Attribution"}),e[10]=p):p=e[10];let h;e[11]!==c||e[12]!==o?(h=o.length>1&&r.jsx(s1,{"aria-label":"Attribution dimension",value:[c],onValueChange:y=>{const j=y[0];typeof j=="string"&&a(j)},variant:"outline",size:"sm",className:"mb-2 flex-wrap",children:o.map(h8)}),e[11]=c,e[12]=o,e[13]=h):h=e[13];let g;if(e[14]!==f||e[15]!==m){let y;e[17]!==m?(y=j=>r.jsx(f8,{bucket:j,maxTotal:m},j.name),e[17]=m,e[18]=y):y=e[18],g=f.map(y),e[14]=f,e[15]=m,e[16]=g}else g=e[16];let v;e[19]!==g?(v=r.jsx("ul",{className:"flex max-h-[280px] flex-col gap-1 overflow-y-auto pr-0.5",children:g}),e[19]=g,e[20]=v):v=e[20];let x;e[21]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(m8,{}),e[21]=x):x=e[21];let w;return e[22]!==h||e[23]!==v?(w=r.jsxs("section",{children:[p,h,v,x]}),e[22]=h,e[23]=v,e[24]=w):w=e[24],w}function h8(n){return r.jsx(o1,{value:n,children:c8[n]},n)}function g8(n){return n.inputTokens+n.outputTokens}function x8(n){const e=[];for(let t=0;t<n.length;t++)for(const s of n[t].toolCalls)s.isError&&s.result&&e.push({turnIndex:t,toolName:s.name,message:s.result.slice(0,200)});return e}function v8(n){const e=F.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=x8(t),e[0]=t,e[1]=o):o=e[1];const i=o;if(i.length===0)return null;let a;e[2]!==i.length?(a=r.jsxs(Fn,{children:["Errors (",i.length,")"]}),e[2]=i.length,e[3]=a):a=e[3];let l;if(e[4]!==i||e[5]!==s){let f;e[7]!==s?(f=(u,m)=>r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>s==null?void 0:s(u.turnIndex),className:"h-auto w-full flex-col items-stretch rounded-none border-b border-border px-2 py-2.5 text-left whitespace-normal last:border-b-0 hover:bg-destructive/5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"font-medium text-destructive",children:u.toolName}),r.jsxs("span",{className:"text-muted-foreground",children:["Turn ",u.turnIndex+1]})]}),r.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:u.message})]},m),e[7]=s,e[8]=f):f=e[8],l=i.map(f),e[4]=i,e[5]=s,e[6]=l}else l=e[6];let c;e[9]!==l?(c=r.jsx("div",{className:"flex max-h-[300px] flex-col overflow-y-auto pr-1",children:l}),e[9]=l,e[10]=c):c=e[10];let d;return e[11]!==a||e[12]!==c?(d=r.jsxs("section",{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d}function am(n){const e=F.c(42),{agentId:t,subagentType:s,agentName:o,preview:i,isViewing:a,isBackground:l,status:c,durationMs:d,toolUseCount:f,disabled:u,onClick:m,onStop:p}=n;let h;e[0]!==t||e[1]!==o||e[2]!==s?(h=o||Mc(t,s),e[0]=t,e[1]=o,e[2]=s,e[3]=h):h=e[3];const g=h;let v;e[4]!==d?(v=d==null?null:d<1e3?`${d}ms`:`${(d/1e3).toFixed(d>=1e4?0:1)}s`,e[4]=d,e[5]=v):v=e[5];const x=v;let w;e[6]!==c?(w=c==="running"?r.jsx(lt,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?r.jsx(_n,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(js,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(Xm,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=w):w=e[7];const y=w,j=a?"bg-accent":"hover:bg-muted/40";let N;e[8]!==j?(N=G("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",j),e[8]=j,e[9]=N):N=e[9];let S;e[10]!==g?(S=r.jsx(Oe,{variant:"outline",children:g}),e[10]=g,e[11]=S):S=e[11];let k;e[12]!==l?(k=l&&r.jsx(Oe,{variant:"outline",children:"Background"}),e[12]=l,e[13]=k):k=e[13];let C;e[14]!==a?(C=a&&r.jsx(Oe,{children:"Viewing"}),e[14]=a,e[15]=C):C=e[15];const T=c==="running"?"active":c;let _;e[16]!==T?(_=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:T}),e[16]=T,e[17]=_):_=e[17];let P;e[18]!==y||e[19]!==_||e[20]!==S||e[21]!==k||e[22]!==C?(P=r.jsxs("div",{className:"flex items-center gap-1.5",children:[y,S,k,C,_]}),e[18]=y,e[19]=_,e[20]=S,e[21]=k,e[22]=C,e[23]=P):P=e[23];let A;e[24]!==i?(A=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=A):A=e[25];let E;e[26]!==x||e[27]!==f?(E=(x||f!=null)&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[x&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(xi,{className:"size-2.5","data-icon":"inline-start"}),x]}),f!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(fi,{className:"size-2.5","data-icon":"inline-start"}),f," tools"]})]}),e[26]=x,e[27]=f,e[28]=E):E=e[28];let M;e[29]!==u||e[30]!==m||e[31]!==P||e[32]!==A||e[33]!==E?(M=r.jsxs(X,{type:"button",variant:"ghost",onClick:m,disabled:u,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[P,A,E]}),e[29]=u,e[30]=m,e[31]=P,e[32]=A,e[33]=E,e[34]=M):M=e[34];let I;e[35]!==g||e[36]!==p?(I=p&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(xt,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=I):I=e[37];let R;return e[38]!==M||e[39]!==I||e[40]!==N?(R=r.jsxs("div",{className:N,children:[M,I]}),e[38]=M,e[39]=I,e[40]=N,e[41]=R):R=e[41],R}function b8(n,e=!1){const t=n==null?void 0:n.toLowerCase();return t==="completed"||t==="success"||t==="done"?"done":t==="failed"||t==="error"||t==="cancelled"?"failed":e||t==="running"||t==="async_launched"?"running":"seen"}function jl(n){return n.split(`
|
|
113
|
+
`).map(e=>e.trim()).find(Boolean)??""}function y8(n){return n.name==="Task"||n.name==="Agent"}function w8(n,e){var i;const t=new Map;for(const a of n.turns)for(const l of a.contentBlocks)if(!(l.kind!=="sub_agent"&&l.kind!=="background_agent"))for(const c of l.messages){const d=t.get(c.agentId),f=b8(c.status);t.set(c.agentId,{agentId:c.agentId,agentName:c.agentName??(d==null?void 0:d.agentName)??null,subagentType:c.subagentType??(d==null?void 0:d.subagentType)??null,preview:jl(((i=c.prompt)==null?void 0:i.trim())||c.text.find(u=>u.trim())||"")||(d==null?void 0:d.preview)||"No task summary recorded",isBackground:c.isBackground||(d==null?void 0:d.isBackground)||!1,status:f==="seen"&&(d!=null&&d.status)?d.status:f,durationMs:c.durationMs??(d==null?void 0:d.durationMs),toolUseCount:c.toolUseCount??(d==null?void 0:d.toolUseCount),parentToolUseId:c.parentToolUseId??(d==null?void 0:d.parentToolUseId)})}const s=new Set;for(const a of t.values())a.parentToolUseId&&s.add(a.parentToolUseId);const o=new Set;for(const a of e)a.parentToolUseId&&o.add(a.parentToolUseId);for(const a of n.turns)for(const l of a.toolCalls){if(!y8(l)||!o.has(l.id)||s.has(l.id))continue;const c=l.input;t.set(`tool:${l.id}`,{agentId:`tool:${l.id}`,agentName:typeof c.name=="string"?c.name:null,subagentType:typeof c.subagent_type=="string"?c.subagent_type:null,preview:jl(typeof c.prompt=="string"?c.prompt:typeof c.description=="string"?c.description:"Agent task in progress"),isBackground:!1,status:"running",parentToolUseId:l.id})}return[...t.values()]}function j8({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=Pc(),i=b.useMemo(()=>{if(!e)return null;const w=ss(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=b.useMemo(()=>w8(n,o),[n,o]),l=b.useRef(a);b.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=b.useMemo(()=>{if(i)return i.parentSessionId;if(e!=null&&e.fileName){const w=e.fileName.match(/^([^/]+)\.jsonl$/);if(w)return w[1]}return null},[i,e]),f=b.useMemo(()=>d?t.filter(w=>w.parentSessionId===d):t,[t,d]),u=b.useMemo(()=>new Map(c.map(w=>[w.agentId,w])),[c]),m=b.useMemo(()=>{const w=new Set(f.map(y=>y.agentId));return c.filter(y=>!w.has(y.agentId))},[f,c]),p=b.useMemo(()=>[...f].sort((w,y)=>y.modifiedAt-w.modifiedAt),[f]),h=b.useMemo(()=>[...m].reverse(),[m]),g=f.length+m.length;if(g===0)return null;const v=w=>{ye(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(w)}`,{method:"DELETE"})},x=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(Fn,{children:["Agents (",g,")"]}),i&&s&&r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:()=>s(i.dirName,i.parentFileName),className:"mb-2 w-full justify-start",children:[r.jsx(et,{"data-icon":"inline-start",className:"rotate-180"}),"Back to Main Agent"]}),r.jsxs("div",{className:"flex max-h-[280px] flex-col gap-1.5 overflow-y-auto pr-0.5",children:[p.map((w,y)=>{const j=jl(w.preview??""),N=u.get(w.agentId);return r.jsx(am,{agentId:w.agentId,subagentType:(N==null?void 0:N.subagentType)??null,agentName:(N==null?void 0:N.agentName)??null,preview:(N==null?void 0:N.preview)||(j!==w.agentId?j:""),colorIndex:y,isViewing:x===w.agentId,isBackground:!0,status:w.isActive?"running":(N==null?void 0:N.status)==="failed"?"failed":"done",durationMs:N==null?void 0:N.durationMs,toolUseCount:N==null?void 0:N.toolUseCount,disabled:!s,onStop:w.isActive?()=>v(w.agentId):void 0,onClick:()=>s==null?void 0:s(w.dirName,w.fileName)},w.agentId)}),h.map((w,y)=>{const j=!!s&&!!d&&!!e&&!w.agentId.startsWith("tool:");return r.jsx(am,{agentId:w.agentId,subagentType:w.subagentType,agentName:w.agentName,preview:w.preview,colorIndex:p.length+y,isViewing:x===w.agentId,isBackground:w.isBackground,status:w.status,durationMs:w.durationMs,toolUseCount:w.toolUseCount,disabled:!j,onClick:()=>{j&&s(e.dirName,`${d}/subagents/agent-${w.agentId}.jsonl`)}},w.agentId)})]})]})}function S8(n,e){return`${n.id}-${e}`}function N8(n){const e=F.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=b.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(Fn,{children:["Turns (",t.length,")"]}),e[0]=t.length,e[1]=a):a=e[1];let l;if(e[2]!==o||e[3]!==s||e[4]!==t){let f;e[6]!==o||e[7]!==s?(f=(u,m)=>{const p=Li(u.userMessage),h=o===m;return r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>{i(m),s==null||s(m)},className:G("group h-auto w-full justify-start gap-2 px-2 py-1.5 text-left font-normal",h?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[r.jsx("span",{className:"mt-0.5 shrink-0 font-mono text-xs text-muted-foreground",children:String(m+1).padStart(2,"0")}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:p?sn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:u.toolCalls.length>0&&r.jsx(Oe,{variant:"secondary",className:"font-normal",children:u.toolCalls.length})})]},S8(u,m))},e[6]=o,e[7]=s,e[8]=f):f=e[8],l=t.map(f),e[2]=o,e[3]=s,e[4]=t,e[5]=l}else l=e[5];let c;e[9]!==l?(c=r.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:l})}),e[9]=l,e[10]=c):c=e[10];let d;return e[11]!==a||e[12]!==c?(d=r.jsxs("section",{children:[a,c]}),e[11]=a,e[12]=c,e[13]=d):d=e[13],d}function k8(n){const e=n.input;return e.file_path&&typeof e.file_path=="string"?e.file_path.split("/").slice(-2).join("/"):e.command&&typeof e.command=="string"?sn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?sn(e.query,40):e.url&&typeof e.url=="string"?sn(e.url,40):sn(qk(n),40)}function C8(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:G1(e,t.model,s)/t.toolCalls.length})}function _8(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=Hi(o);t.has(i.label)||t.set(i.label,{calls:[],count:0,estimatedCost:0,styleName:i.styleName});const a=t.get(i.label);a.calls.push({tc:o,turnIndex:s}),a.count++,a.estimatedCost+=e[s]}return Array.from(t.entries()).sort((s,o)=>o[1].count-s[1].count)}function T8(n){const e=F.c(14),{turns:t,onJumpToTurn:s}=n,o=Y1();let i;e[0]!==o||e[1]!==t?(i=C8(t,o),e[0]=o,e[1]=t,e[2]=i):i=e[2];const a=i;let l;e[3]!==a||e[4]!==t?(l=_8(t,a),e[3]=a,e[4]=t,e[5]=l):l=e[5];const c=l;if(c.length===0)return null;let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Fn,{children:"Tool Calls"}),e[6]=d):d=e[6];let f;if(e[7]!==s||e[8]!==c){let m;e[10]!==s?(m=p=>{const[h,g]=p;return r.jsxs(wt,{children:[r.jsxs(dn,{className:"group flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs transition-colors hover:bg-muted",children:[r.jsx(et,{className:"size-3 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),r.jsx("span",{className:"font-medium text-foreground",children:h}),r.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[g.estimatedCost>0&&r.jsx("span",{className:"font-mono text-xs text-warning",children:qn(g.estimatedCost)}),r.jsx(Oe,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(jt,{children:r.jsxs("div",{className:"ml-4 flex flex-col gap-0.5 border-l border-border pl-2 pt-0.5",children:[g.calls.slice(0,50).map((v,x)=>{const{tc:w,turnIndex:y}=v,j=k8(w);return r.jsx("div",{children:r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(y,w.id),className:G("h-auto w-full justify-start gap-1 px-1.5 py-0.5 text-left font-mono text-xs font-normal",w.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[w.isError&&r.jsx(fn,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),r.jsx("span",{className:"truncate",children:j||w.id.slice(0,8)})]})},`${w.id}-${x}`)}),g.calls.length>50&&r.jsxs("div",{className:"px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",g.calls.length-50," more"]})]})})]},h)},e[10]=s,e[11]=m):m=e[11],f=c.map(m),e[7]=s,e[8]=c,e[9]=f}else f=e[9];let u;return e[12]!==f?(u=r.jsxs("section",{children:[d,r.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-0.5 pr-2",children:f})})]}),e[12]=f,e[13]=u):u=e[13],u}function E8(n){const e=F.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Ct(),{searchQuery:i,expandAll:a}=s,{actions:l}=st(),{handleToggleExpandAll:c}=l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Session details"}),e[0]=d):d=e[0];const f=a?"Collapse all":"Expand all";let u;e[1]!==a?(u=a?r.jsx(vi,{"data-icon":"inline-start"}):r.jsx(gi,{"data-icon":"inline-start"}),e[1]=a,e[2]=u):u=e[2];let m;e[3]!==c||e[4]!==f||e[5]!==u?(m=r.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[d,r.jsx(X,{variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:c,"aria-label":f,children:u})]}),e[3]=c,e[4]=f,e[5]=u,e[6]=m):m=e[6];const p=i??"";let h;e[7]!==o?(h=y=>o({type:"SET_SEARCH_QUERY",value:y.target.value}),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==t||e[10]!==p||e[11]!==h?(g=r.jsx(Un,{ref:t,type:"text",value:p,onChange:h,placeholder:"Search conversation","aria-label":"Search conversation"}),e[9]=t,e[10]=p,e[11]=h,e[12]=g):g=e[12];let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(un,{align:"inline-start",children:r.jsx(an,{})}),e[13]=v):v=e[13];let x;e[14]!==g?(x=r.jsxs(Bn,{children:[g,v]}),e[14]=g,e[15]=x):x=e[15];let w;return e[16]!==x||e[17]!==m?(w=r.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,x]}),e[16]=x,e[17]=m,e[18]=w):w=e[18],w}const J1=b.memo(function(e){const t=F.c(40),{onJumpToTurn:s,onToggleServer:o,onServersChanged:i,searchInputRef:a,onLoadSession:l,backgroundAgents:c}=e,{isMobile:d}=Ct(),{session:f,sessionSource:u}=st(),m=f,{turns:p}=m,h=d?"mobile-scroll w-full flex-1":"view-transition-right-panel panel-enter-right w-[320px] border-l";let g;t[0]!==h?(g=G("h-full min-h-0 shrink-0 overflow-y-auto bg-background",h),t[0]=h,t[1]=g):g=t[1];let v;t[2]!==a?(v=a&&r.jsx(E8,{searchInputRef:a}),t[2]=a,t[3]=v):v=t[3];const x=d?"p-4":"p-3";let w;t[4]!==x?(w=G(x),t[4]=x,t[5]=w):w=t[5];let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(jh,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(po,{value:"activity",children:"Activity"}),r.jsx(po,{value:"agents",children:"Agents"}),r.jsx(po,{value:"metrics",children:"Metrics"}),r.jsx(po,{value:"issues",children:"Issues"})]}),t[6]=y):y=t[6];let j;t[7]!==s||t[8]!==p?(j=r.jsxs(ho,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(N8,{turns:p,onJumpToTurn:s}),r.jsx(T8,{turns:p,onJumpToTurn:s})]}),t[7]=s,t[8]=p,t[9]=j):j=t[9];let N;t[10]!==i||t[11]!==o||t[12]!==m.cwd||t[13]!==p?(N=r.jsx(Ch,{cwd:m.cwd,turns:p,onToggleServer:o,onServersChanged:i}),t[10]=i,t[11]=o,t[12]=m.cwd,t[13]=p,t[14]=N):N=t[14];let S;t[15]!==c?(S=c??[],t[15]=c,t[16]=S):S=t[16];let k;t[17]!==l||t[18]!==m||t[19]!==u||t[20]!==S?(k=r.jsx(j8,{session:m,sessionSource:u,bgAgents:S,onLoadSession:l}),t[17]=l,t[18]=m,t[19]=u,t[20]=S,t[21]=k):k=t[21];let C;t[22]!==k||t[23]!==N?(C=r.jsxs(ho,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[N,k]}),t[22]=k,t[23]=N,t[24]=C):C=t[24];let T;t[25]!==p?(T=r.jsxs(ho,{value:"metrics",className:"flex flex-col gap-6 pt-3",children:[r.jsx(e8,{turns:p}),r.jsx(s8,{turns:p}),r.jsx(r8,{turns:p}),r.jsx(p8,{turns:p})]}),t[25]=p,t[26]=T):T=t[26];let _;t[27]!==s||t[28]!==p?(_=r.jsx(ho,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(v8,{turns:p,onJumpToTurn:s})}),t[27]=s,t[28]=p,t[29]=_):_=t[29];let P;t[30]!==C||t[31]!==T||t[32]!==_||t[33]!==w||t[34]!==j?(P=r.jsxs(wh,{defaultValue:"activity",className:w,children:[y,j,C,T,_]}),t[30]=C,t[31]=T,t[32]=_,t[33]=w,t[34]=j,t[35]=P):P=t[35];let A;return t[36]!==P||t[37]!==g||t[38]!==v?(A=r.jsxs("aside",{className:g,children:[v,P]}),t[36]=P,t[37]=g,t[38]=v,t[39]=A):A=t[39],A});function P8(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(vv,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function lm(n){const e=F.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(xv,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function A8(n){const e=F.c(12);let t,s,o;e[0]!==n?({withHandle:o,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),e[4]=t,e[5]=i):i=e[5];let a;e[6]!==o?(a=o&&r.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=o,e[7]=a):a=e[7];let l;return e[8]!==s||e[9]!==i||e[10]!==a?(l=r.jsx(gv,{"data-slot":"resizable-handle",className:i,...s,children:a}),e[8]=s,e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function Xi(n){const e=F.c(4),{floating:t,children:s}=n;if(t){let i;return e[0]!==s?(i=r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] border-t bg-background px-3 pt-3",children:s})}),e[0]=s,e[1]=i):i=e[1],i}let o;return e[2]!==s?(o=r.jsx("div",{className:"flex w-full shrink-0 justify-center",children:r.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function Z1(n){const e=F.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?Nn(t):null,e[0]=t,e[1]=s):s=e[1];const o=s;let i;e[2]!==o?(i=o?r.jsxs(r.Fragment,{children:["What should we build in"," ",r.jsx("span",{children:o}),"?"]}):"What should we build?",e[2]=o,e[3]=i):i=e[3];let a;e[4]!==i?(a=r.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[4]=i,e[5]=a):a=e[5];let l;e[6]!==t?(l=t&&r.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:Ci(t)}),e[6]=t,e[7]=l):l=e[7];let c;return e[8]!==a||e[9]!==l?(c=r.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[a,l]}),e[8]=a,e[9]=l,e[10]=c):c=e[10],c}function M8(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function R8(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("ol",{"data-slot":"breadcrumb-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function cm(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("li",{"data-slot":"breadcrumb-item",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function I8(n){const e=F.c(10);let t,s,o,i;if(e[0]!==n){const{className:c,render:d,...f}=n;t=d,i=Km,s="a",o=Hm({className:G("transition-colors hover:text-foreground",c)},f),e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i}else t=e[1],s=e[2],o=e[3],i=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a={slot:"breadcrumb-link"},e[5]=a):a=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==o?(l={defaultTagName:s,props:o,render:t,state:a},e[6]=t,e[7]=s,e[8]=o,e[9]=l):l=e[9],i(l)}function $8(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("font-normal text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function O8(n){const e=F.c(12);let t,s,o;e[0]!==n?({children:t,className:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=t??r.jsx(et,{}),e[6]=t,e[7]=a):a=e[7];let l;return e[8]!==o||e[9]!==i||e[10]!==a?(l=r.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:i,...o,children:a}),e[8]=o,e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function Q1(n){const e=F.c(51),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l}=n,[c,d]=b.useState(!1),[f,u]=b.useState(!1),[m,p]=b.useState(""),h=b.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),u(!0),requestAnimationFrame(()=>{var H;return(H=h.current)==null?void 0:H.select()})},e[0]=o,e[1]=g):g=e[1];const v=g;let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("div",{className:"w-full"}),e[2]=x):x=e[2];let w;e[3]!==t?(w=r.jsx(Bi,{render:x,children:t}),e[3]=t,e[4]=w):w=e[4];let y;e[5]!==i||e[6]!==l||e[7]!==v?(y=(l||i)&&r.jsxs(Ws,{children:[l&&r.jsxs(Bt,{onClick:v,children:[r.jsx(ws,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(Bt,{onClick:i,children:[r.jsx(bn,{"data-icon":"inline-start"}),"Duplicate session"]})]}),e[5]=i,e[6]=l,e[7]=v,e[8]=y):y=e[8];let j;e[9]!==a||e[10]!==i||e[11]!==l?(j=a&&r.jsxs(r.Fragment,{children:[(i||l)&&r.jsx(Io,{}),r.jsx(Ws,{children:r.jsxs(Bt,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(mi,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[9]=a,e[10]=i,e[11]=l,e[12]=j):j=e[12];let N;e[13]!==y||e[14]!==j?(N=r.jsxs(Ui,{className:"min-w-44",children:[y,j]}),e[13]=y,e[14]=j,e[15]=N):N=e[15];let S;e[16]!==w||e[17]!==N?(S=r.jsxs(Fi,{children:[w,N]}),e[16]=w,e[17]=N,e[18]=S):S=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(ac,{children:"Delete session?"}),e[19]=k):k=e[19];let C;e[20]!==s?(C=r.jsxs(rc,{children:[k,r.jsxs(lc,{children:["This will permanently delete"," ",r.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[20]=s,e[21]=C):C=e[21];let T;e[22]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(dc,{size:"sm",children:"Cancel"}),e[22]=T):T=e[22];let _;e[23]!==a?(_=r.jsxs(ic,{children:[T,r.jsx(cc,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),d(!1)},children:"Delete"})]}),e[23]=a,e[24]=_):_=e[24];let P;e[25]!==_||e[26]!==C?(P=r.jsxs(oc,{children:[C,_]}),e[25]=_,e[26]=C,e[27]=P):P=e[27];let A;e[28]!==c||e[29]!==P?(A=r.jsx(sc,{open:c,onOpenChange:d,children:P}),e[28]=c,e[29]=P,e[30]=A):A=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsxs(as,{children:[r.jsx(Ln,{className:"text-foreground",children:"Rename session"}),r.jsx(zn,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[31]=E):E=e[31];let M;e[32]!==l||e[33]!==m?(M=O=>{O.preventDefault(),l==null||l(m),u(!1)},e[32]=l,e[33]=m,e[34]=M):M=e[34];let I;e[35]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(mt,{htmlFor:"session-rename",children:"Session name"}),e[35]=I):I=e[35];let R;e[36]===Symbol.for("react.memo_cache_sentinel")?(R=O=>p(O.target.value),e[36]=R):R=e[36];let D;e[37]!==m||e[38]!==s?(D=r.jsxs(ft,{children:[I,r.jsx(Pt,{id:"session-rename",ref:h,value:m,onChange:R,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=D):D=e[39];let L;e[40]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsxs(Dp,{children:[r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(!1),children:"Cancel"}),r.jsx(X,{type:"submit",size:"sm",children:"Save"})]}),e[40]=L):L=e[40];let $;e[41]!==M||e[42]!==D?($=r.jsxs(Dn,{className:"sm:max-w-md",children:[E,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:M,children:[D,L]})]}),e[41]=M,e[42]=D,e[43]=$):$=e[43];let z;e[44]!==f||e[45]!==$?(z=r.jsx(On,{open:f,onOpenChange:u,children:$}),e[44]=f,e[45]=$,e[46]=z):z=e[46];let U;return e[47]!==A||e[48]!==z||e[49]!==S?(U=r.jsxs(r.Fragment,{children:[S,A,z]}),e[47]=A,e[48]=z,e[49]=S,e[50]=U):U=e[50],U}const ex="session-custom-names";function tx(){try{const n=localStorage.getItem(Mt(ex));return n?JSON.parse(n):{}}catch{return{}}}function D8(n){localStorage.setItem(Mt(ex),JSON.stringify(n))}let si=tx();const oi=new Set;if(typeof window<"u"){const n=()=>{si=tx();for(const e of oi)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function L8(n){return oi.add(n),()=>{oi.delete(n)}}function z8(){return si}function Sl(n,e){const t={...si},s=e.trim();s?t[n]=s:delete t[n],D8(t),si=t;for(const o of oi)o()}function nx(){const n=F.c(2),e=b.useSyncExternalStore(L8,z8);let t;return n[0]!==e?(t={names:e,rename:Sl},n[0]=e,n[1]=t):t=n[1],t}function Vn(n){const e=F.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"skeleton",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function sx(n){const e=F.c(13),{value:t,onChange:s,placeholder:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(un,{children:r.jsx(an,{"aria-hidden":"true"})}),e[0]=i):i=e[0];let a;e[1]!==s?(a=f=>s(f.target.value),e[1]=s,e[2]=a):a=e[2];let l;e[3]!==o||e[4]!==a||e[5]!==t?(l=r.jsx(Un,{"aria-label":o,value:t,onChange:a,placeholder:o}),e[3]=o,e[4]=a,e[5]=t,e[6]=l):l=e[6];let c;e[7]!==s||e[8]!==t?(c=t&&r.jsx(un,{align:"inline-end",children:r.jsx(er,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(xt,{})})}),e[7]=s,e[8]=t,e[9]=c):c=e[9];let d;return e[10]!==l||e[11]!==c?(d=r.jsxs(Bn,{className:"w-full sm:max-w-sm",children:[i,l,c]}),e[10]=l,e[11]=c,e[12]=d):d=e[12],d}function ox(n){const e=F.c(10),{message:t,onRetry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(fn,{"aria-hidden":"true"}),i=r.jsx(At,{children:"Could not load this data"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(bt,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ht,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(ns,{children:r.jsxs(X,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(vt,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function rx(n){const e=F.c(5),{count:t,includeMessagePlaceholder:s}=n,o=t===void 0?4:t,i=s===void 0?!1:s;let a;if(e[0]!==o||e[1]!==i){let l;e[3]!==i?(l=(c,d)=>r.jsxs("div",{children:[d>0&&r.jsx(Et,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(Vn,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(Vn,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(Vn,{className:"h-3 w-72 max-w-full"}),r.jsx(Vn,{className:"h-3 w-52 max-w-full"})]}),r.jsx(Vn,{className:"hidden h-5 w-20 sm:block"})]})]},d),e[3]=i,e[4]=l):l=e[4],a=r.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:o},l)}),e[0]=o,e[1]=i,e[2]=a}else a=e[2];return a}function Lo(n){return n==="idle"||n==="completed"}function Wc(n){return Lo(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const gs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},F8=120*1e3;function ix(n){return n?Date.now()-new Date(n).getTime()<F8:!1}function ax(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?sn(s,70):sn(n.sessionId,16)}function dm(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function B8(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||dm(t)===dm(e)?null:sn(t,220)}function U8(n,e){const t=e.toLowerCase();return[n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.sessionId].some(s=>s==null?void 0:s.toLowerCase().includes(t))}function W8(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?vn(t):null}function H8(n){const e=[n.sessionId];return n.cwd&&e.push(n.cwd),n.version&&e.push(`CLI ${n.version}`),n.timestamp&&e.push(`Started ${new Date(n.timestamp).toLocaleString()}`),e.join(`
|
|
114
|
+
`)}function K8(n){var t;const e=n.cwd?(t=_i(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:bv,label:e,title:n.cwd}:n.gitBranch?{icon:Xs,label:n.gitBranch}:null}function V8(n,e){return n.agentStatus==="deferred"?"attention":e?Lo(n.agentStatus)?"idle":"working":null}function q8(n){const e=F.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Oe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=o):o=e[0],o}if(s){const o=Lo(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=ir(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=i):i=e[5];const a=i;let l;e[6]!==t.agentStatus?(l=Wc(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=o?"bg-success/60":"bg-current";let d;e[8]!==c?(d=G("size-1.5 rounded-full",c),e[8]=c,e[9]=d):d=e[9];let f;e[10]!==d?(f=r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:d}),e[10]=d,e[11]=f):f=e[11];let u;return e[12]!==a||e[13]!==l||e[14]!==f?(u=r.jsxs(Oe,{variant:"secondary",className:l,children:[f,a]}),e[12]=a,e[13]=l,e[14]=f,e[15]=u):u=e[15],u}if(t.agentTerminalReason){let o;e[16]!==t.agentTerminalReason?(o=Lc(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Oe,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function Ha(n){const e=F.c(9),{icon:t,title:s,className:o,children:i}=n;let a;e[0]!==o?(a=G("flex items-center gap-1",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==t?(l=r.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==i||e[5]!==a||e[6]!==l||e[7]!==s?(c=r.jsxs("span",{className:a,title:s,children:[l,i]}),e[4]=i,e[5]=a,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function G8(n){const e=F.c(98),{session:t,customName:s,onSelect:o}=n,i=t.lastActivityAt||t.lastModified;let a,l;e[0]!==i||e[1]!==t?(a=ix(i),l=V8(t,a),e[0]=i,e[1]=t,e[2]=a,e[3]=l):(a=e[2],l=e[3]);const c=l,d=t.teamName?t.agentName:void 0;let f,u,m,p,h,g,v,x,w,y,j,N,S,k;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const D=K8(t);let L;e[25]!==i||e[26]!==t.timestamp?(L=W8(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=L):L=e[27];const $=L,z=t.turnCount??0;let U,O;e[28]!==s||e[29]!==t?(O=ax(t,s),U=B8(t,O),e[28]=s,e[29]=t,e[30]=U,e[31]=O):(U=e[30],O=e[31]);const H=U;g="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",u=o,e[32]!==t?(m=H8(t),e[32]=t,e[33]=m):m=e[33],p="flex min-w-0 flex-1 items-start gap-3 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring";let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=r.jsx(Jd,{className:"size-4"}),e[34]=B):B=e[34];let W;e[35]!==c?(W=c&&r.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",gs[c])}),e[35]=c,e[36]=W):W=e[36],e[37]!==W?(h=r.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[B,W]}),e[37]=W,e[38]=h):h=e[38],N="flex min-w-0 flex-1 flex-col gap-1";let V;e[39]!==O?(V=r.jsx("span",{className:"truncate text-sm font-medium",children:O}),e[39]=O,e[40]=V):V=e[40];let q;e[41]!==d?(q=d&&r.jsxs(Oe,{variant:"outline",className:"shrink-0",children:[r.jsx(zo,{"data-icon":"inline-start"}),sn(d,18)]}),e[41]=d,e[42]=q):q=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Oe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(Ll,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let K;e[45]!==a||e[46]!==t?(K=r.jsx(q8,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=K):K=e[47];let J;e[48]!==i?(J=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Yo(i)}),e[48]=i,e[49]=J):J=e[49];let Z;e[50]!==K||e[51]!==J?(Z=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[K,J]}),e[50]=K,e[51]=J,e[52]=Z):Z=e[52],e[53]!==V||e[54]!==q||e[55]!==Y||e[56]!==Z?(S=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[V,q,Y,Z]}),e[53]=V,e[54]=q,e[55]=Y,e[56]=Z,e[57]=S):S=e[57],e[58]!==H?(k=H&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:H}),e[58]=H,e[59]=k):k=e[59],v="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(x=t.model&&r.jsx(Oe,{variant:"outline",children:ki(t.model)}),e[60]=t.model,e[61]=x):x=e[61],e[62]!==z?(w=z>0&&r.jsxs(Ha,{icon:Jd,children:[z," ",z===1?"turn":"turns"]}),e[62]=z,e[63]=w):w=e[63],e[64]!==$?(y=$&&r.jsx(Ha,{icon:xs,title:"First prompt to last activity",children:$}),e[64]=$,e[65]=y):y=e[65],j=D&&r.jsx(Ha,{icon:D.icon,className:"max-w-40 truncate",title:D.title,children:sn(D.label,22)}),e[4]=s,e[5]=c,e[6]=i,e[7]=a,e[8]=o,e[9]=t,e[10]=d,e[11]=f,e[12]=u,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=v,e[18]=x,e[19]=w,e[20]=y,e[21]=j,e[22]=N,e[23]=S,e[24]=k}else f=e[11],u=e[12],m=e[13],p=e[14],h=e[15],g=e[16],v=e[17],x=e[18],w=e[19],y=e[20],j=e[21],N=e[22],S=e[23],k=e[24];let C;e[66]!==t.size?(C=Hp(t.size),e[66]=t.size,e[67]=C):C=e[67];let T;e[68]!==C?(T=r.jsx("span",{children:C}),e[68]=C,e[69]=T):T=e[69];let _;e[70]!==T||e[71]!==v||e[72]!==x||e[73]!==w||e[74]!==y||e[75]!==j?(_=r.jsxs("span",{className:v,children:[x,w,y,j,T]}),e[70]=T,e[71]=v,e[72]=x,e[73]=w,e[74]=y,e[75]=j,e[76]=_):_=e[76];let P;e[77]!==_||e[78]!==N||e[79]!==S||e[80]!==k?(P=r.jsxs("span",{className:N,children:[S,k,_]}),e[77]=_,e[78]=N,e[79]=S,e[80]=k,e[81]=P):P=e[81];let A;e[82]!==f||e[83]!==u||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==P?(A=r.jsxs("button",{type:f,onClick:u,title:m,className:p,children:[h,P]}),e[82]=f,e[83]=u,e[84]=m,e[85]=p,e[86]=h,e[87]=P,e[88]=A):A=e[88];let E;e[89]!==t.pullRequests?(E=r.jsx(Yi,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.pullRequests,e[90]=E):E=e[90];let M;e[91]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(et,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[91]=M):M=e[91];let I;e[92]!==E?(I=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[E,M]}),e[92]=E,e[93]=I):I=e[93];let R;return e[94]!==g||e[95]!==A||e[96]!==I?(R=r.jsxs("div",{className:g,children:[A,I]}),e[94]=g,e[95]=A,e[96]=I,e[97]=R):R=e[97],R}function Y8(n){const e=F.c(59),{selectedProject:t,sessions:s,sessionsTotal:o,sessionsLoading:i,searchFilter:a,setSearchFilter:l,filteredSessions:c,fetchError:d,onSelectSession:f,onNewSession:u,creatingSession:m,onDuplicateSession:p,onDeleteSession:h,onBack:g,onRetryFetch:v,loadMoreSessions:x}=n,{names:w,rename:y}=nx();let j;e[0]!==t.path?(j=Nn(t.path),e[0]=t.path,e[1]=j):j=e[1];const N=j;let S;e[2]!==g?(S=r.jsx(cm,{children:r.jsx(I8,{render:r.jsx("button",{type:"button",onClick:g}),children:"Projects"})}),e[2]=g,e[3]=S):S=e[3];let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(O8,{}),e[4]=k):k=e[4];let C;e[5]!==N?(C=r.jsx(cm,{className:"min-w-0",children:r.jsx($8,{className:"truncate",children:N})}),e[5]=N,e[6]=C):C=e[6];let T;e[7]!==S||e[8]!==C?(T=r.jsx(M8,{children:r.jsxs(R8,{children:[S,k,C]})}),e[7]=S,e[8]=C,e[9]=T):T=e[9];let _;e[10]!==N?(_=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:N}),e[10]=N,e[11]=_):_=e[11];let P;e[12]!==o?(P=r.jsx(Oe,{variant:"secondary",children:o}),e[12]=o,e[13]=P):P=e[13];let A;e[14]!==_||e[15]!==P?(A=r.jsxs("div",{className:"flex items-center gap-2",children:[_,P]}),e[14]=_,e[15]=P,e[16]=A):A=e[16];let E;e[17]!==t.path?(E=Ci(t.path),e[17]=t.path,e[18]=E):E=e[18];let M;e[19]!==E?(M=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:E}),e[19]=E,e[20]=M):M=e[20];let I;e[21]!==M||e[22]!==A?(I=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[A,M]}),e[21]=M,e[22]=A,e[23]=I):I=e[23];let R;e[24]!==a||e[25]!==l?(R=r.jsx(sx,{value:a,onChange:l,placeholder:"Filter sessions..."}),e[24]=a,e[25]=l,e[26]=R):R=e[26];let D;e[27]!==m||e[28]!==u||e[29]!==t.dirName||e[30]!==t.path?(D=u&&r.jsxs(X,{size:"sm",disabled:m,onClick:()=>u(t.dirName,t.path),children:[m?r.jsx(It,{"data-icon":"inline-start"}):r.jsx(xn,{"data-icon":"inline-start"}),"New Session"]}),e[27]=m,e[28]=u,e[29]=t.dirName,e[30]=t.path,e[31]=D):D=e[31];let L;e[32]!==R||e[33]!==D?(L=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[R,D]}),e[32]=R,e[33]=D,e[34]=L):L=e[34];let $;e[35]!==d||e[36]!==v?($=d&&r.jsx(ox,{message:d,onRetry:v}),e[35]=d,e[36]=v,e[37]=$):$=e[37];let z;e[38]!==c||e[39]!==x||e[40]!==h||e[41]!==p||e[42]!==f||e[43]!==y||e[44]!==a||e[45]!==t.dirName||e[46]!==w||e[47]!==s||e[48]!==i||e[49]!==o?(z=i&&s.length===0?r.jsx(rx,{includeMessagePlaceholder:!0}):c.length===0?r.jsx(En,{className:"min-h-72 border",children:r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:r.jsx(bi,{})}),r.jsx(An,{children:a?"No sessions match your search":"No sessions yet"}),r.jsx(Mn,{children:a?"Try a session title, prompt, model, or branch.":"Start a session in this project and it will appear here."})]})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:c.map((H,B)=>r.jsxs(b.Fragment,{children:[B>0&&r.jsx(Et,{}),r.jsx(Q1,{sessionLabel:ax(H),customName:w[H.sessionId],onRename:W=>y(H.sessionId,W),onDuplicate:p?()=>p(t.dirName,H.fileName):void 0,onDelete:h?()=>h(t.dirName,H.fileName):void 0,children:r.jsx(G8,{session:H,customName:w[H.sessionId],onSelect:()=>f(t.dirName,H.fileName)})})]},H.fileName))}),s.length<o&&!a&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(X,{variant:"outline",size:"sm",disabled:i,onClick:x,children:[i&&r.jsx(It,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[38]=c,e[39]=x,e[40]=h,e[41]=p,e[42]=f,e[43]=y,e[44]=a,e[45]=t.dirName,e[46]=w,e[47]=s,e[48]=i,e[49]=o,e[50]=z):z=e[50];let U;e[51]!==L||e[52]!==$||e[53]!==z?(U=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[L,$,z]}),e[51]=L,e[52]=$,e[53]=z,e[54]=U):U=e[54];let O;return e[55]!==I||e[56]!==U||e[57]!==T?(O=r.jsx(Qo,{className:"h-full",children:r.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[T,I,U]})}),e[55]=I,e[56]=U,e[57]=T,e[58]=O):O=e[58],O}function X8(n){const e=F.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=b.useState(null);if(!t||i===t){let m;return e[0]!==s?(m=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=Vo(l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=()=>a(t),e[4]=t,e[5]=d):d=e[5];let f;e[6]!==o?(f=G("size-3.5 shrink-0 rounded-[3px] object-contain",o),e[6]=o,e[7]=f):f=e[7];let u;return e[8]!==t||e[9]!==c||e[10]!==d||e[11]!==f?(u=r.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:d,className:f},t),e[8]=t,e[9]=c,e[10]=d,e[11]=f,e[12]=u):u=e[12],u}function lx(n){const e=F.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=b.useState(!1),[d,f]=b.useState(""),u=b.useRef(null);let m;e[0]!==o?(m=function(){f(o||""),c(!0),requestAnimationFrame(()=>{var M;return(M=u.current)==null?void 0:M.select()})},e[0]=o,e[1]=m):m=e[1];const p=m;let h;e[2]!==i?(h=G("w-full",i),e[2]=i,e[3]=h):h=e[3];let g;e[4]!==h?(g=r.jsx("div",{className:h}),e[4]=h,e[5]=g):g=e[5];let v;e[6]!==t||e[7]!==g?(v=r.jsx(Bi,{render:g,children:t}),e[6]=t,e[7]=g,e[8]=v):v=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(ws,{"data-icon":"inline-start"}),e[9]=x):x=e[9];let w;e[10]!==p?(w=r.jsx(Ui,{className:"min-w-44",children:r.jsx(Ws,{children:r.jsxs(Bt,{onClick:p,children:[x,"Rename project"]})})}),e[10]=p,e[11]=w):w=e[11];let y;e[12]!==v||e[13]!==w?(y=r.jsxs(Fi,{children:[v,w]}),e[12]=v,e[13]=w,e[14]=y):y=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(as,{children:[r.jsx(Ln,{className:"text-foreground",children:"Rename project"}),r.jsx(zn,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[15]=j):j=e[15];let N;e[16]!==a||e[17]!==d?(N=E=>{E.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=N):N=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(mt,{htmlFor:"project-rename",children:"Project name"}),e[19]=S):S=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=E=>f(E.target.value),e[20]=k):k=e[20];let C;e[21]!==s||e[22]!==d?(C=r.jsxs(ft,{children:[S,r.jsx(Pt,{id:"project-rename",ref:u,value:d,onChange:k,placeholder:s})]}),e[21]=s,e[22]=d,e[23]=C):C=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsxs(Dp,{children:[r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(X,{type:"submit",size:"sm",children:"Save"})]}),e[24]=T):T=e[24];let _;e[25]!==C||e[26]!==N?(_=r.jsxs(Dn,{className:"sm:max-w-md",children:[j,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:N,children:[C,T]})]}),e[25]=C,e[26]=N,e[27]=_):_=e[27];let P;e[28]!==l||e[29]!==_?(P=r.jsx(On,{open:l,onOpenChange:c,children:_}),e[28]=l,e[29]=_,e[30]=P):P=e[30];let A;return e[31]!==P||e[32]!==y?(A=r.jsxs(r.Fragment,{children:[y,P]}),e[31]=P,e[32]=y,e[33]=A):A=e[33],A}const cx="project-custom-names";function dx(){try{const n=localStorage.getItem(Mt(cx));return n?JSON.parse(n):{}}catch{return{}}}function J8(n){localStorage.setItem(Mt(cx),JSON.stringify(n))}let ri=dx();const ii=new Set;if(typeof window<"u"){const n=()=>{ri=dx();for(const e of ii)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function Z8(n){return ii.add(n),()=>{ii.delete(n)}}function Q8(){return ri}function eE(n,e){const t={...ri},s=e.trim();s?t[n]=s:delete t[n],J8(t),ri=t;for(const o of ii)o()}function ux(){const n=F.c(2),e=b.useSyncExternalStore(Z8,Q8);let t;return n[0]!==e?(t={names:e,rename:eE},n[0]=e,n[1]=t):t=n[1],t}function tE(n){const e=F.c(45),{projects:t,activeSessions:s,loading:o,refreshing:i,searchFilter:a,setSearchFilter:l,fetchError:c,selectedProjectDirName:d,onSelectProject:f,onRefresh:u}=n;let m;if(e[0]!==s){m={};for(const R of s)ix(R.lastModified)&&(m[R.dirName]=(m[R.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=ux();let v;e:{if(!a){v=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==a){const D=a.toLowerCase();R=t.filter(L=>{var $;return L.path.toLowerCase().includes(D)||L.shortName.toLowerCase().includes(D)||(($=h[L.dirName])==null?void 0:$.toLowerCase().includes(D))}),e[2]=h,e[3]=t,e[4]=a,e[5]=R}else R=e[5];v=R}const x=v;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=w):w=e[6];let y;e[7]!==t.length?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[w,r.jsx(Oe,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=y):y=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=j):j=e[9];let N;e[10]!==y?(N=r.jsxs("header",{className:"flex flex-col gap-1",children:[y,j]}),e[10]=y,e[11]=N):N=e[11];let S;e[12]!==a||e[13]!==l?(S=r.jsx(sx,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=S):S=e[14];const k=i&&"animate-spin";let C;e[15]!==k?(C=G(k),e[15]=k,e[16]=C):C=e[16];let T;e[17]!==C?(T=r.jsx(Ht,{"data-icon":"inline-start",className:C}),e[17]=C,e[18]=T):T=e[18];let _;e[19]!==u||e[20]!==i||e[21]!==T?(_=r.jsxs(X,{variant:"outline",size:"sm",onClick:u,disabled:i,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[19]=u,e[20]=i,e[21]=T,e[22]=_):_=e[22];let P;e[23]!==_||e[24]!==S?(P=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,_]}),e[23]=_,e[24]=S,e[25]=P):P=e[25];let A;e[26]!==c||e[27]!==u||e[28]!==d?(A=c&&!d&&r.jsx(ox,{message:c,onRetry:u}),e[26]=c,e[27]=u,e[28]=d,e[29]=A):A=e[29];let E;e[30]!==p||e[31]!==x||e[32]!==o||e[33]!==f||e[34]!==h||e[35]!==g||e[36]!==a?(E=o?r.jsx(rx,{}):x.length===0?r.jsx(En,{className:"min-h-72 border",children:r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:r.jsx(_o,{})}),r.jsx(An,{children:a?"No projects match your search":"No projects yet"}),r.jsx(Mn,{children:a?"Try a project name or path.":"Start Claude Code or Codex and its project will appear here."})]})}):r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:x.map((R,D)=>{const L=p[R.dirName]||0,$=h[R.dirName];return r.jsxs(b.Fragment,{children:[D>0&&r.jsx(Et,{}),r.jsx(lx,{projectLabel:Nn(R.path),customName:$,onRename:z=>g(R.dirName,z),children:r.jsxs("button",{type:"button",onClick:()=>f==null?void 0:f(R.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:r.jsx(X8,{projectPath:R.path,className:"size-4",fallback:r.jsx(_o,{className:"size-4 text-muted-foreground"})})}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block truncate text-sm font-medium",children:$||Nn(R.path)}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:Ci(R.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[L>0&&r.jsxs(Oe,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),L," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[R.sessionCount," ",R.sessionCount===1?"session":"sessions"]}),R.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Yo(R.lastModified)}),r.jsx(et,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=x,e[32]=o,e[33]=f,e[34]=h,e[35]=g,e[36]=a,e[37]=E):E=e[37];let M;e[38]!==P||e[39]!==A||e[40]!==E?(M=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[P,A,E]}),e[38]=P,e[39]=A,e[40]=E,e[41]=M):M=e[41];let I;return e[42]!==M||e[43]!==N?(I=r.jsx(Qo,{className:"h-full",children:r.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[N,M]})}),e[42]=M,e[43]=N,e[44]=I):I=e[44],I}const nE=b.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=b.useState(()=>({projects:Yr(Sn.projects),activeSessions:Yr(Sn.activeSessions)})),[d,f]=b.useState(c.projects??[]),[u,m]=b.useState(c.activeSessions??[]),[p,h]=b.useState(c.projects===void 0),[g,v]=b.useState(!1),[x,w]=b.useState([]),[y,j]=b.useState(0),[N,S]=b.useState(1),[k,C]=b.useState(!1),[T,_]=b.useState(""),[P,A]=b.useState(null),E=b.useRef(0),M=b.useRef(null),I=b.useCallback(async(O=!1)=>{O&&v(!0);try{const[H,B]=await Promise.all([ye("/api/projects"),ye("/api/active-sessions")]);if(!H.ok||!B.ok)throw new Error("Failed to fetch dashboard data");const W=await H.json(),V=await B.json(),q=Array.isArray(W)?W:[],Y=Array.isArray(V)?V:[];f(q),m(Y),wo(Sn.projects,q),wo(Sn.activeSessions,Y),A(null)}catch(H){A(H instanceof Error?H.message:"Failed to load data")}finally{h(!1),v(!1)}},[]);b.useEffect(()=>{I()},[I]);const R=b.useCallback(async(O,H=1,B=!1)=>{var Y;const W=++E.current;(Y=M.current)==null||Y.abort();const V=new AbortController;M.current=V;const q=()=>W===E.current;if(C(!0),A(null),!B){const K=aN(O);K?(w(K.sessions),j(K.total),S(1)):w([])}try{const K=await ye(`/api/sessions/${encodeURIComponent(O)}?page=${H}&limit=20`,{signal:V.signal});if(!K.ok)throw new Error(`Failed to load sessions (${K.status})`);const J=await K.json();if(!q())return;const Z=Array.isArray(J.sessions)?J.sessions:[],Q=typeof J.total=="number"?J.total:Z.length;w(se=>B?[...se,...Z]:Z),j(Q),S(H),B||lN(O,{sessions:Z,total:Q})}catch(K){if(!q()||V.signal.aborted)return;A(K instanceof Error?K.message:"Failed to load sessions")}finally{q()&&(M.current=null,C(!1))}},[]);b.useEffect(()=>{var O;if(!o){E.current+=1,(O=M.current)==null||O.abort(),M.current=null,w([]),j(0),S(1),_(""),C(!1);return}_(""),R(o)},[o,R]),b.useEffect(()=>()=>{var O;E.current+=1,(O=M.current)==null||O.abort()},[]);const D=b.useMemo(()=>{if(!o)return null;const O=d.find(B=>B.dirName===o);if(O)return O;const H=rn(o);return{dirName:o,path:H,shortName:Nn(H),sessionCount:y,lastModified:null}},[o,d,y]),L=b.useCallback(()=>{i==null||i(null)},[i]),$=b.useCallback(()=>{o&&R(o,N+1,!0)},[o,N,R]),z=b.useMemo(()=>T?x.filter(O=>U8(O,T)):x,[x,T]);function U(O,H){l==null||l(O,H),w(B=>B.filter(W=>W.fileName!==H)),j(B=>B-1)}return D?r.jsx(Y8,{selectedProject:D,sessions:x,sessionsTotal:y,sessionsLoading:k,searchFilter:T,setSearchFilter:_,filteredSessions:z,fetchError:P,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:U,onBack:L,onRetryFetch:()=>{A(null),o&&R(o)},loadMoreSessions:$}):r.jsx(tE,{projects:d,activeSessions:u,loading:p,refreshing:g,searchFilter:T,setSearchFilter:_,fetchError:P,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>I(!0)})});async function fx(n,e,t){return(await ye(`/api/permissions/${encodeURIComponent(n)}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,behavior:t})})).ok}async function sE(n,e){return(await ye(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({behavior:e})})).ok}async function mx(n,e){try{const t=await ye(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function oE(n,e,t){return mx("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function rE(n,e,t){return mx("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const iE=3e3,px=b.createContext(null);async function Ka(n,e){try{const t=await ye(n);if(!t.ok)return;const s=await t.text();return s===e.current?void 0:(e.current=s,JSON.parse(s))}catch{return}}function Mr(n){const e=new Map;for(const[t,s]of Object.entries(n??{}))Array.isArray(s)&&s.length>0&&e.set(t,s);return e}function Rr(n,e,t){const s=new Map(n),o=(s.get(e)??[]).filter(i=>!t(i));return o.length>0?s.set(e,o):s.delete(e),s}function aE({children:n}){const[e,t]=b.useState(new Map),[s,o]=b.useState(new Map),[i,a]=b.useState(new Map),[l,c]=b.useState(new Map),[d,f]=b.useState(new Set),u=b.useRef(""),m=b.useRef(""),p=b.useRef(""),h=b.useCallback(async()=>{const[_,P,A]=await Promise.all([Ka("/api/permissions",u),Ka("/api/user-questions",m),Ka("/api/agent-prompts",p)]);_&&t(Mr(_.bySession)),P&&o(Mr(P.bySession)),A&&(a(Mr(A.elicitationsBySession)),c(Mr(A.dialogsBySession)))},[]);b.useEffect(()=>{const _=()=>{document.visibilityState==="visible"&&h()};_();const P=setInterval(_,iE);return document.addEventListener("visibilitychange",_),()=>{clearInterval(P),document.removeEventListener("visibilitychange",_)}},[h]);const g=b.useCallback(async(_,P)=>{f(A=>new Set(A).add(_));try{return await P()}finally{f(A=>{const E=new Set(A);return E.delete(_),E}),h()}},[h]),v=b.useCallback((_,P,A)=>g(P,async()=>{await fx(_,P,A).catch(()=>!1)&&(t(M=>Rr(M,_,I=>I.requestId===P)),u.current="")}),[g]),x=b.useCallback((_,P,A)=>g(P,async()=>{const E=await Ql(_,P,A);return E.ok&&(o(M=>Rr(M,_,I=>I.toolUseId===P)),m.current=""),E}),[g]),w=b.useCallback((_,P,A)=>g(P,async()=>{const E=await oE(_,P,A);return E.ok&&(a(M=>Rr(M,_,I=>I.requestId===P)),p.current=""),E}),[g]),y=b.useCallback((_,P,A)=>g(P,async()=>{const E=await rE(_,P,A);return E.ok&&(c(M=>Rr(M,_,I=>I.requestId===P)),p.current=""),E}),[g]),j=b.useMemo(()=>new Set(e.keys()),[e]),N=b.useMemo(()=>new Set(s.keys()),[s]),S=b.useMemo(()=>new Set(i.keys()),[i]),k=b.useMemo(()=>new Set(l.keys()),[l]),C=b.useCallback(()=>{h()},[h]),T=b.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:j,awaitingQuestion:N,awaitingElicitation:S,awaitingDialog:k,responding:d,respond:v,answerQuestion:x,answerElicitation:w,answerDialog:y,refresh:C}),[e,s,i,l,j,N,S,k,d,v,x,w,y,C]);return r.jsx(px.Provider,{value:T,children:n})}function lE(){const n=b.useContext(px);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const hx=typeof navigator<"u"&&"vibrate"in navigator;function Nl(){hx&&navigator.vibrate(10)}function cE(){hx&&navigator.vibrate(20)}function dE(n){return!!(n.teamName&&n.agentName)}function uE(n,e,t,s,o,i){const a=[],l=[];for(const c of Cc(n)){if(s!=null&&s.has(c.sessionId)){a.push({session:c,reason:"permission"});continue}if(o!=null&&o.has(c.sessionId)){a.push({session:c,reason:"question"});continue}if(i!=null&&i.has(c.sessionId)){a.push({session:c,reason:"prompt"});continue}if(c.agentStatus==="deferred"){a.push({session:c,reason:"deferred"});continue}if(dE(c))continue;const d=zg(c,e);if(c.agentStatus==="completed"||!d){t.has(c.sessionId)&&a.push({session:c,reason:"done"});continue}if(c.agentStatus==="idle"){a.push({session:c,reason:"waiting"});continue}(!c.agentStatus||Tc.has(c.agentStatus))&&l.push(c)}return{needsYou:a,working:l}}function fE(n){switch(n.agentStatus){case"tool_use":return n.agentToolName||"Tool";case"thinking":return"Thinking";case"processing":return"Processing";case"compacting":return"Compacting";case"awaiting_agents":return"Agents running";default:return"Running"}}const gx="aw:turnCounts",mE=200,Ji=new Map;try{const n=localStorage.getItem(gx);if(n){const e=JSON.parse(n);for(const[t,s]of e)Ji.set(t,s)}}catch{}function pE(){try{const n=[...Ji.entries()].slice(-mE);localStorage.setItem(gx,JSON.stringify(n))}catch{}}function hE(n,e){Ji.set(Mt(n),e),pE()}function gE(n,e){const t=Ji.get(Mt(n));return Math.max(t??0,e??0)}function xx(n){const e=F.c(40),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a}=n,l=i||t.aiTitle,c=t.lastUserMessage||t.firstUserMessage,d=gE(t.sessionId,t.turnCount);let f;e[0]!==l?(f=l&&r.jsx("span",{className:"font-medium leading-snug text-foreground",children:l}),e[0]=l,e[1]=f):f=e[1];let u;e[2]!==t.agentStatus||e[3]!==o?(u=o&&r.jsx("span",{className:G("font-medium",Wc(t.agentStatus)),children:o}),e[2]=t.agentStatus,e[3]=o,e[4]=u):u=e[4];let m;e[5]!==t.agentName||e[6]!==t.teamName?(m=t.teamName&&t.agentName&&r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Tn,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[5]=t.agentName,e[6]=t.teamName,e[7]=m):m=e[7];let p;e[8]!==c?(p=c&&r.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:r.jsx("span",{className:"line-clamp-3 leading-relaxed",children:c})}),e[8]=c,e[9]=p):p=e[9];let h;e[10]!==t.pullRequests?(h=r.jsx(Yi,{pullRequests:t.pullRequests,layout:"list"}),e[10]=t.pullRequests,e[11]=h):h=e[11];let g;e[12]!==t.gitBranch||e[13]!==a?(g=t.gitBranch&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Xs,{className:"size-2.5"}),a?`${t.gitBranch} · ${a}`:t.gitBranch]}),e[12]=t.gitBranch,e[13]=a,e[14]=g):g=e[14];let v;e[15]!==d?(v=d>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(bi,{className:"size-2.5"}),d," ",d===1?"turn":"turns"]}),e[15]=d,e[16]=v):v=e[16];let x;e[17]!==t.size?(x=Hp(t.size),e[17]=t.size,e[18]=x):x=e[18];let w;e[19]!==x?(w=r.jsx("span",{children:x}),e[19]=x,e[20]=w):w=e[20];let y;e[21]!==s?(y=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(yv,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=y):y=e[22];const j=t.lastActivityAt||t.lastModified;let N;e[23]!==j?(N=Yo(j),e[23]=j,e[24]=N):N=e[24];let S;e[25]!==N?(S=r.jsx("span",{children:N}),e[25]=N,e[26]=S):S=e[26];let k;e[27]!==y||e[28]!==S||e[29]!==g||e[30]!==v||e[31]!==w?(k=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[g,v,w,y,S]}),e[27]=y,e[28]=S,e[29]=g,e[30]=v,e[31]=w,e[32]=k):k=e[32];let C;return e[33]!==f||e[34]!==k||e[35]!==u||e[36]!==m||e[37]!==p||e[38]!==h?(C=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[f,u,m,p,h,k]}),e[33]=f,e[34]=k,e[35]=u,e[36]=m,e[37]=p,e[38]=h,e[39]=C):C=e[39],C}const xE=120;function vx(n){const e=F.c(7),t=b.useRef(null);let s,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},o=[],e[0]=s,e[1]=o):(s=e[0],o=e[1]),b.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,xE))},e[2]=n,e[3]=i):i=e[3];const a=i;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{t.current&&(clearTimeout(t.current),t.current=null)},e[4]=l):l=e[4];const c=l;let d;return e[5]!==a?(d={onHoverStart:a,onHoverEnd:c},e[5]=a,e[6]=d):d=e[6],d}const vE=6;function bE(n){const e=F.c(7),{iso:t}=n,[,s]=b.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(yE),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[2]=i):i=e[2],b.useEffect(o,i);let a;e[3]!==t?(a=Yo(t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==a?(l=r.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6],l}function yE(n){return n+1}const wE={permission:{label:"Permission",className:"border-warning/30 bg-warning/10 text-warning"},deferred:{label:"Deferred",className:"border-warning/30 bg-warning/10 text-warning"},question:{label:"Question",className:"border-warning/30 bg-warning/10 text-warning"},prompt:{label:"Input needed",className:"border-warning/30 bg-warning/10 text-warning"},waiting:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"},done:{label:"Done",className:"border-success/30 bg-success/10 text-success"}},jE={permission:gs.attention,deferred:gs.attention,waiting:gs.attention,question:"bg-warning",prompt:"bg-warning",done:"bg-success"};function um(n){const e=F.c(70),{session:t,chip:s,dotClassName:o,cardClassName:i,isActiveSession:a,proc:l,killingPids:c,customName:d,projectLabel:f,compact:u,onSelect:m,onKill:p,onResume:h,onPrefetch:g}=n,v=u===void 0?!1:u;let x;e[0]!==s.label||e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(x=ir(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[0]=s.label,e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=x):x=e[5];const w=x,{onHoverStart:y,onHoverEnd:j}=vx(g),N=v?"px-2.5 py-2":"border px-2 py-2",S=a&&!v&&"ring-1 ring-ring";let k;e[6]!==i||e[7]!==N||e[8]!==S?(k=G("group relative w-full rounded-md text-left transition-colors",N,i,S),e[6]=i,e[7]=N,e[8]=S,e[9]=k):k=e[9];let C;e[10]!==v||e[11]!==a?(C=v&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[10]=v,e[11]=a,e[12]=C):C=e[12];const T=h&&"pr-20";let _;e[13]!==T?(_=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[13]=T,e[14]=_):_=e[14];let P;e[15]!==j||e[16]!==y||e[17]!==m||e[18]!==_?(P=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:y,onMouseLeave:j,onFocus:y,onBlur:j,className:_}),e[15]=j,e[16]=y,e[17]=m,e[18]=_,e[19]=P):P=e[19];const A=v&&"ring-0";let E;e[20]!==o||e[21]!==A?(E=G("size-1.5 shrink-0 rounded-full",o,A),e[20]=o,e[21]=A,e[22]=E):E=e[22];let M;e[23]!==E?(M=r.jsx("span",{className:E,"aria-hidden":"true"}),e[23]=E,e[24]=M):M=e[24];let I;e[25]!==d||e[26]!==t?(I=Dg(t,d),e[25]=d,e[26]=t,e[27]=I):I=e[27];let R;e[28]!==I?(R=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:I}),e[28]=I,e[29]=R):R=e[29];const D=v?"text-muted-foreground":s.className;let L;e[30]!==D?(L=G("shrink-0",D),e[30]=D,e[31]=L):L=e[31];let $;e[32]!==s.label||e[33]!==L?($=r.jsx(Oe,{variant:"outline",className:L,children:s.label}),e[32]=s.label,e[33]=L,e[34]=$):$=e[34];let z;e[35]!==v||e[36]!==t.lastActivityAt||e[37]!==t.lastModified?(z=!v&&r.jsx(bE,{iso:t.lastActivityAt||t.lastModified}),e[35]=v,e[36]=t.lastActivityAt,e[37]=t.lastModified,e[38]=z):z=e[38];let U;e[39]!==M||e[40]!==R||e[41]!==$||e[42]!==z?(U=r.jsxs("span",{className:"flex items-center gap-1.5",children:[M,R,$,z]}),e[39]=M,e[40]=R,e[41]=$,e[42]=z,e[43]=U):U=e[43];let O;e[44]!==f?(O=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[44]=f,e[45]=O):O=e[45];let H;e[46]!==U||e[47]!==O||e[48]!==P?(H=r.jsxs(Nt,{render:P,children:[U,O]}),e[46]=U,e[47]=O,e[48]=P,e[49]=H):H=e[49];let B;e[50]!==d||e[51]!==l||e[52]!==t||e[53]!==w?(B=r.jsx(kt,{side:"right",className:"max-w-[280px]",children:r.jsx(xx,{session:t,proc:l,statusLabel:w,customName:d})}),e[50]=d,e[51]=l,e[52]=t,e[53]=w,e[54]=B):B=e[54];let W;e[55]!==H||e[56]!==B?(W=r.jsxs(St,{children:[H,B]}),e[55]=H,e[56]=B,e[57]=W):W=e[57];let V;e[58]!==h?(V=h&&r.jsxs(X,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(Uo,{"data-icon":"inline-start"}),"Resume"]}),e[58]=h,e[59]=V):V=e[59];let q;e[60]!==c||e[61]!==p||e[62]!==l?(q=l&&p&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:K=>p(l.pid,K),disabled:c.has(l.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:r.jsx(xt,{"data-icon":"inline-start"})}),e[60]=c,e[61]=p,e[62]=l,e[63]=q):q=e[63];let Y;return e[64]!==W||e[65]!==V||e[66]!==q||e[67]!==k||e[68]!==C?(Y=r.jsxs("div",{className:k,children:[C,W,V,q]}),e[64]=W,e[65]=V,e[66]=q,e[67]=k,e[68]=C,e[69]=Y):Y=e[69],Y}function SE(n){const e=F.c(15),{dotClassName:t,labelClassName:s,label:o,count:i}=n;let a;e[0]!==t?(a=G("size-1.5 rounded-full",t),e[0]=t,e[1]=a):a=e[1];let l;e[2]!==a?(l=r.jsx("span",{className:a,"aria-hidden":"true"}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let d;e[6]!==o||e[7]!==c?(d=r.jsx("span",{className:c,children:o}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let f;e[9]!==i?(f=r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:i}),e[9]=i,e[10]=f):f=e[10];let u;return e[11]!==l||e[12]!==d||e[13]!==f?(u=r.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,d,f]}),e[11]=l,e[12]=d,e[13]=f,e[14]=u):u=e[14],u}function NE(n){const e=F.c(27),{groups:t,activeSessionKey:s,procBySession:o,killingPids:i,sessionNames:a,projectNames:l,onSelectSession:c,onKill:d,onResumeSession:f,onPrefetchSession:u}=n,[m,p]=b.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,vE),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,v=t.working.length-g.length;let x;e[3]!==l?(x=C=>l[C.dirName]||_c(C.cwd||rn(C.dirName)),e[3]=l,e[4]=x):x=e[4];const w=x;let y;e[5]!==s||e[6]!==i||e[7]!==u||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(y=C=>{const T=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:T,proc:o.get(C.sessionId),killingPids:i,customName:a[C.sessionId],projectLabel:w(C),onSelect:()=>c(C.dirName,C.fileName),onPrefetch:u&&!T?()=>u(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=i,e[7]=u,e[8]=c,e[9]=o,e[10]=w,e[11]=a,e[12]=y):y=e[12];const j=y;let N;e[13]!==t.needsYou||e[14]!==d||e[15]!==f||e[16]!==j?(N=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(SE,{dotClassName:gs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{const{session:T,reason:_}=C;return r.jsx(um,{...j(T),chip:wE[_],dotClassName:jE[_],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:_==="deferred"&&f?()=>f(T.sessionId,T.cwd):void 0},`${T.dirName}/${T.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=f,e[16]=j,e[17]=N):N=e[17];let S;e[18]!==t.working.length||e[19]!==v||e[20]!==d||e[21]!==j||e[22]!==g?(S=t.working.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between px-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),r.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:g.map(C=>r.jsx(um,{...j(C),chip:{label:fE(C),className:""},dotClassName:gs.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${C.dirName}/${C.fileName}`))}),v>0&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Show ",v," more"]})]}),e[18]=t.working.length,e[19]=v,e[20]=d,e[21]=j,e[22]=g,e[23]=S):S=e[23];let k;return e[24]!==N||e[25]!==S?(k=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[N,S]}),e[24]=N,e[25]=S,e[26]=k):k=e[26],k}function kE(n){const e=F.c(23),{loading:t,isMobile:s,searchQuery:o,onSearchQueryChange:i,onRefresh:a}=n;let l;e[0]!==i?(l=w=>i(w.target.value),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==o||e[3]!==l?(c=r.jsx(Un,{type:"search",value:o,onChange:l,placeholder:"Filter sessions","aria-label":"Search sessions by project, branch, title, first prompt, or latest prompt"}),e[2]=o,e[3]=l,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(un,{align:"inline-start",children:r.jsx(an,{})}),e[5]=d):d=e[5];let f;e[6]!==i||e[7]!==o?(f=o&&r.jsx(un,{align:"inline-end",children:r.jsx(er,{size:"icon-xs",onClick:()=>i(""),"aria-label":"Clear session search",children:r.jsx(xt,{"data-icon":"inline-start"})})}),e[6]=i,e[7]=o,e[8]=f):f=e[8];let u;e[9]!==c||e[10]!==f?(u=r.jsxs(Bn,{children:[c,d,f]}),e[9]=c,e[10]=f,e[11]=u):u=e[11];const m=s?"icon-sm":"icon-xs",p=t&&"animate-spin";let h;e[12]!==p?(h=G(p),e[12]=p,e[13]=h):h=e[13];let g;e[14]!==h?(g=r.jsx(Ht,{"data-icon":"inline-start",className:h}),e[14]=h,e[15]=g):g=e[15];let v;e[16]!==a||e[17]!==m||e[18]!==g?(v=r.jsx(X,{variant:"ghost",size:m,onClick:a,"aria-label":"Refresh sessions",children:g}),e[16]=a,e[17]=m,e[18]=g,e[19]=v):v=e[19];let x;return e[20]!==v||e[21]!==u?(x=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[u,v]}),e[20]=v,e[21]=u,e[22]=x):x=e[22],x}const CE=["first","second","third","fourth","fifth"];function _E(n){const e=F.c(13),{fetchError:t,showEmpty:s,searching:o,loading:i,sessionCount:a,onRetry:l}=n;let c;e[0]!==t||e[1]!==l?(c=t&&r.jsxs(vt,{variant:"destructive",children:[r.jsx(fn,{}),r.jsx(At,{children:"Could not load sessions"}),r.jsx(bt,{className:"truncate",children:t}),r.jsx(ns,{children:r.jsx(X,{variant:"outline",size:"xs",onClick:l,children:"Retry"})})]}),e[0]=t,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==o||e[4]!==s?(d=s&&r.jsx(En,{className:"min-h-56 px-4 py-8",children:r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:o?r.jsx(an,{}):r.jsx(ip,{})}),r.jsx(An,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(Mn,{children:o?"Try a project, branch, title, or prompt.":"Start Claude Code or Codex to see recent work here."})]})}),e[3]=o,e[4]=s,e[5]=d):d=e[5];let f;e[6]!==i||e[7]!==a?(f=i&&a===0&&r.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:CE.map(TE)}),e[6]=i,e[7]=a,e[8]=f):f=e[8];let u;return e[9]!==c||e[10]!==d||e[11]!==f?(u=r.jsxs(r.Fragment,{children:[c,d,f]}),e[9]=c,e[10]=d,e[11]=f,e[12]=u):u=e[12],u}function TE(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(Vn,{className:"size-2 shrink-0 rounded-full"}),r.jsx(Vn,{className:"h-4 flex-1"}),r.jsx(Vn,{className:"h-4 w-10"})]},n)}function EE(n){var we;const e=F.c(109),{session:t,isActiveSession:s,proc:o,killingPids:i,isNewlyCompleted:a,customName:l,worktreeName:c,teammateCount:d,teammatesCollapsed:f,onToggleTeammates:u,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onRenameSession:v,onPrefetchSession:x,onResumeSession:w}=n,y=o!==void 0,j=t.isActive===!0,N=y||j,S=j&&Lo(t.agentStatus),k=t.agentStatus==="deferred",[C,T]=b.useState(!1),_=N?S?"Running":ir(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,P=k?"attention":N?Lo(t.agentStatus)?"idle":"working":null,A=!!(t.teamName&&t.agentName);let E;e[0]!==l||e[1]!==t?(E=Dg(t,l),e[0]=l,e[1]=t,e[2]=E):E=e[2];const M=E;let I;e[3]!==s||e[4]!==x||e[5]!==t.dirName||e[6]!==t.fileName?(I=x&&!s?()=>x(t.dirName,t.fileName):void 0,e[3]=s,e[4]=x,e[5]=t.dirName,e[6]=t.fileName,e[7]=I):I=e[7];const{onHoverStart:R,onHoverEnd:D}=vx(I);let L;e[8]!==w||e[9]!==C||e[10]!==t.cwd||e[11]!==t.sessionId?(L=ae=>{ae.stopPropagation(),!(!w||C)&&(T(!0),w(t.sessionId,t.cwd),setTimeout(()=>T(!1),3e3))},e[8]=w,e[9]=C,e[10]=t.cwd,e[11]=t.sessionId,e[12]=L):L=e[12];const $=L;let z;e[13]!==y||e[14]!==s||e[15]!==j||e[16]!==a||e[17]!==t.agentStatus?(z=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",PE(s,!j&&y&&t.agentStatus==="completed"&&!!a)),e[13]=y,e[14]=s,e[15]=j,e[16]=a,e[17]=t.agentStatus,e[18]=z):z=e[18];const U=St,O=Nt;let H;e[19]!==m||e[20]!==t.dirName||e[21]!==t.fileName?(H=()=>m(t.dirName,t.fileName),e[19]=m,e[20]=t.dirName,e[21]=t.fileName,e[22]=H):H=e[22];let B;e[23]!==D||e[24]!==R||e[25]!==H?(B=r.jsx("button",{type:"button","data-live-session":!0,onClick:H,onMouseEnter:R,onMouseLeave:D,onFocus:R,onBlur:D,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[23]=D,e[24]=R,e[25]=H,e[26]=B):B=e[26];let W;e[27]!==P?(W=P&&r.jsx("span",{"data-status-dot":P,className:G("size-1.5 rounded-full",gs[P])}),e[27]=P,e[28]=W):W=e[28];let V;e[29]!==W?(V=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:W}),e[29]=W,e[30]=V):V=e[30];let q;e[31]!==M?(q=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:M}),e[31]=M,e[32]=q):q=e[32];let Y;e[33]!==A||e[34]!==t.agentName||e[35]!==M?(Y=A&&r.jsxs(Oe,{variant:"outline",children:[r.jsx(zo,{"data-icon":"inline-start"}),M!==t.agentName?t.agentName:"Agent"]}),e[33]=A,e[34]=t.agentName,e[35]=M,e[36]=Y):Y=e[36];const K=N&&!k&&_&&r.jsx(Oe,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",S&&"text-success",!S&&Wc(t.agentStatus)),children:_});let J;e[37]!==k?(J=k&&r.jsx(Oe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[37]=k,e[38]=J):J=e[38];let Z;e[39]!==c?(Z=c&&r.jsxs(Oe,{variant:"outline",children:[r.jsx(Xs,{"data-icon":"inline-start"}),c]}),e[39]=c,e[40]=Z):Z=e[40];let Q;e[41]!==O||e[42]!==Y||e[43]!==K||e[44]!==J||e[45]!==Z||e[46]!==B||e[47]!==V||e[48]!==q?(Q=r.jsxs(O,{render:B,children:[V,q,Y,K,J,Z]}),e[41]=O,e[42]=Y,e[43]=K,e[44]=J,e[45]=Z,e[46]=B,e[47]=V,e[48]=q,e[49]=Q):Q=e[49];let se;e[50]!==l||e[51]!==o||e[52]!==t||e[53]!==_||e[54]!==c?(se=r.jsx(kt,{side:"right",className:"max-w-[280px]",children:r.jsx(xx,{session:t,proc:o,statusLabel:_,customName:l,worktreeName:c})}),e[50]=l,e[51]=o,e[52]=t,e[53]=_,e[54]=c,e[55]=se):se=e[55];let ne;e[56]!==U||e[57]!==Q||e[58]!==se?(ne=r.jsxs(U,{children:[Q,se]}),e[56]=U,e[57]=Q,e[58]=se,e[59]=ne):ne=e[59];let ee;e[60]!==u||e[61]!==d||e[62]!==f?(ee=!!d&&u&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:u,className:"shrink-0",title:f?"Show team agents":"Hide team agents","aria-label":f?`Show ${d} team agents`:`Hide ${d} team agents`,"aria-expanded":!f,children:[r.jsx(Tn,{"data-icon":"inline-start"}),d,r.jsx(et,{"data-icon":"inline-end",className:G("transition-transform duration-150",!f&&"rotate-90")})]}),e[60]=u,e[61]=d,e[62]=f,e[63]=ee):ee=e[63];let ie;e[64]!==$||e[65]!==k||e[66]!==w||e[67]!==C?(ie=k&&w&&r.jsxs(X,{type:"button",variant:"outline",size:"xs",onClick:$,disabled:C,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx(Uo,{"data-icon":"inline-start"}),"Resume"]}),e[64]=$,e[65]=k,e[66]=w,e[67]=C,e[68]=ie):ie=e[68];let oe;e[69]!==t.pullRequests?(oe=r.jsx(Yi,{pullRequests:t.pullRequests,max:1,compact:!0}),e[69]=t.pullRequests,e[70]=oe):oe=e[70];const re=t.lastActivityAt||t.lastModified;let te;e[71]!==re?(te=Yo(re),e[71]=re,e[72]=te):te=e[72];let ce;e[73]!==te?(ce=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:te}),e[73]=te,e[74]=ce):ce=e[74];let me;e[75]!==y||e[76]!==i||e[77]!==p||e[78]!==o?(me=y&&p&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",onClick:ae=>p(o.pid,ae),disabled:i.has(o.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${o.pid}`,"aria-label":`Kill process ${o.pid}`,children:r.jsx(xt,{"data-icon":"inline-start"})}),e[75]=y,e[76]=i,e[77]=p,e[78]=o,e[79]=me):me=e[79];let pe;e[80]!==ne||e[81]!==ee||e[82]!==ie||e[83]!==oe||e[84]!==ce||e[85]!==me||e[86]!==z?(pe=r.jsxs("div",{className:z,children:[ne,ee,ie,oe,ce,me]}),e[80]=ne,e[81]=ee,e[82]=ie,e[83]=oe,e[84]=ce,e[85]=me,e[86]=z,e[87]=pe):pe=e[87];const xe=pe;if(h||g||v){let ae;e[88]!==t.firstUserMessage||e[89]!==t.sessionId||e[90]!==t.slug?(ae=t.slug||((we=t.firstUserMessage)==null?void 0:we.slice(0,30))||t.sessionId.slice(0,12),e[88]=t.firstUserMessage,e[89]=t.sessionId,e[90]=t.slug,e[91]=ae):ae=e[91];let ve;e[92]!==h||e[93]!==t.dirName||e[94]!==t.fileName?(ve=h?()=>h(t.dirName,t.fileName):void 0,e[92]=h,e[93]=t.dirName,e[94]=t.fileName,e[95]=ve):ve=e[95];let he;e[96]!==g||e[97]!==t?(he=g?()=>g(t):void 0,e[96]=g,e[97]=t,e[98]=he):he=e[98];let de;e[99]!==v||e[100]!==t.sessionId?(de=v?ke=>v(t.sessionId,ke):void 0,e[99]=v,e[100]=t.sessionId,e[101]=de):de=e[101];let Ne;return e[102]!==l||e[103]!==xe||e[104]!==ae||e[105]!==ve||e[106]!==he||e[107]!==de?(Ne=r.jsx(Q1,{sessionLabel:ae,customName:l,onDuplicate:ve,onDelete:he,onRename:de,children:xe}),e[102]=l,e[103]=xe,e[104]=ae,e[105]=ve,e[106]=he,e[107]=de,e[108]=Ne):Ne=e[108],Ne}return xe}function PE(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function AE(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function ME(n){const e=F.c(36),{grouped:t,pendingProjectPath:s,pendingSession:o,collapsedGroups:i,searchQuery:a,activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:f,sessionNames:u,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:v,onDeleteSession:x,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:N,onPrefetchSession:S,onResumeSession:k}=n;let C;e[0]!==l||e[1]!==N||e[2]!==d||e[3]!==f||e[4]!==x||e[5]!==v||e[6]!==g||e[7]!==j||e[8]!==S||e[9]!==y||e[10]!==w||e[11]!==k||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==u?(C={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:f,sessionNames:u,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:v,onDeleteSession:x,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:N,onPrefetchSession:S,onResumeSession:k},e[0]=l,e[1]=N,e[2]=d,e[3]=f,e[4]=x,e[5]=v,e[6]=g,e[7]=j,e[8]=S,e[9]=y,e[10]=w,e[11]=k,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=u,e[17]=C):C=e[17];const T=C;let _;e[18]!==a?(_=a.trim(),e[18]=a,e[19]=_):_=e[19];const P=!!_;let A;e[20]!==i||e[21]!==P||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==T?(A=[...t.entries()].map((I,R)=>{const[D,L]=I,$=AE(L,c);return b.createElement(fm,{...T,key:D,projectPath:D,sessions:L,liveCount:$,collapsed:i[D]??(R>=3&&$===0),forceExpand:P,pendingSession:s===D?o:void 0})}),e[20]=i,e[21]=P,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=T,e[27]=A):A=e[27];let E;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==T?(E=s&&!t.has(s)&&o&&b.createElement(fm,{...T,key:`pending-${s}`,projectPath:s,sessions:[],liveCount:0,collapsed:!1,pendingSession:o}),e[28]=t,e[29]=s,e[30]=o,e[31]=T,e[32]=E):E=e[32];let M;return e[33]!==A||e[34]!==E?(M=r.jsxs(r.Fragment,{children:[A,E]}),e[33]=A,e[34]=E,e[35]=M):M=e[35],M}function fm(n){var Me,Le;const e=F.c(99),{projectPath:t,sessions:s,activeSessionKey:o,procBySession:i,killingPids:a,newlyCompleted:l,sessionNames:c,projectNames:d,liveCount:f,collapsed:u,onToggleCollapsed:m,forceExpand:p,onSelectSession:h,onKill:g,onDuplicateSession:v,onDeleteSession:x,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:N,pendingSession:S,onPrefetchSession:k,onResumeSession:C}=n,T=p===void 0?!1:p,_=b.useId(),P=!!S,A=T||P?!1:u;let E;e[0]!==s?(E=new Set(s.map(IE)),e[0]=s,e[1]=E):E=e[1];const M=E;let I;if(e[2]!==M||e[3]!==s){const je=new Map,fe=[];for(const Ce of s){const _e=Ce.teamLeadSessionId;if(_e&&_e!==Ce.sessionId&&M.has(_e)){const Be=je.get(_e);Be?Be.push(Ce):je.set(_e,[Ce])}else fe.push(Ce)}I={topLevelSessions:fe,teammatesByLead:je},e[2]=M,e[3]=s,e[4]=I}else I=e[4];const{topLevelSessions:R,teammatesByLead:D}=I;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=new Set,e[5]=L):L=e[5];const[$,z]=b.useState(L);let U;e[6]===Symbol.for("react.memo_cache_sentinel")?(U=je=>{z(fe=>{const Ce=new Set(fe);return Ce.has(je)?Ce.delete(je):Ce.add(je),Ce})},e[6]=U):U=e[6];const O=U,[H,B]=b.useState(!1),W=s.length+(P?1:0);let V,q;e[7]!==T||e[8]!==P||e[9]!==i||e[10]!==H||e[11]!==R?(V=Q4(R,i,Math.max(1,5-(P?1:0))),q=T||H?R:R.slice(0,V),e[7]=T,e[8]=P,e[9]=i,e[10]=H,e[11]=R,e[12]=V,e[13]=q):(V=e[12],q=e[13]);const Y=q,K=R.length-Y.length,J=H&&!T&&R.length>V,Z=((Me=s.find(RE))==null?void 0:Me.dirName)??((Le=s[0])==null?void 0:Le.dirName)??(S==null?void 0:S.dirName),Q=Z?d[Z]:void 0;let se;e[14]!==o||e[15]!==a||e[16]!==l||e[17]!==x||e[18]!==v||e[19]!==g||e[20]!==k||e[21]!==w||e[22]!==C||e[23]!==h||e[24]!==i||e[25]!==c?(se=function(fe,Ce,_e){return r.jsx(EE,{session:fe,isActiveSession:o===`${fe.dirName}/${fe.fileName}`,proc:i.get(fe.sessionId),killingPids:a,isNewlyCompleted:l.has(fe.sessionId),customName:c[fe.sessionId],worktreeName:Ce,teammateCount:_e==null?void 0:_e.count,teammatesCollapsed:_e==null?void 0:_e.collapsed,onToggleTeammates:_e==null?void 0:_e.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:v,onDeleteSession:x,onRenameSession:w,onPrefetchSession:k,onResumeSession:C},`${fe.dirName}/${fe.fileName}`)},e[14]=o,e[15]=a,e[16]=l,e[17]=x,e[18]=v,e[19]=g,e[20]=k,e[21]=w,e[22]=C,e[23]=h,e[24]=i,e[25]=c,e[26]=se):se=e[26];const ne=se,ee=!A;let ie;e[27]!==Z||e[28]!==y?(ie=je=>{Z&&y&&y(Z,je)},e[27]=Z,e[28]=y,e[29]=ie):ie=e[29];let oe;e[30]!==u||e[31]!==m||e[32]!==t?(oe=()=>m(t,!u),e[30]=u,e[31]=m,e[32]=t,e[33]=oe):oe=e[33];const re=!A,te=T?"Groups stay expanded while searching":void 0,ce=!A&&"rotate-90";let me;e[34]!==ce?(me=G("size-3 shrink-0 text-muted-foreground transition-transform duration-150",ce),e[34]=ce,e[35]=me):me=e[35];let pe;e[36]!==me?(pe=r.jsx(et,{className:me}),e[36]=me,e[37]=pe):pe=e[37];const xe=Q||t;let we;e[38]!==xe?(we=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:xe}),e[38]=xe,e[39]=we):we=e[39];let ae;e[40]!==Q||e[41]!==t?(ae=Q&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=Q,e[41]=t,e[42]=ae):ae=e[42];let ve;e[43]!==f?(ve=f>0&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":`${f} live sessions`,children:[r.jsx(Ti,{className:"size-1.5","aria-hidden":"true"}),f]}),e[43]=f,e[44]=ve):ve=e[44];let he;e[45]!==W?(he=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:W}),e[45]=W,e[46]=he):he=e[46];let de;e[47]!==T||e[48]!==_||e[49]!==oe||e[50]!==re||e[51]!==te||e[52]!==pe||e[53]!==we||e[54]!==ae||e[55]!==ve||e[56]!==he?(de=r.jsxs("button",{type:"button",onClick:oe,disabled:T,"aria-expanded":re,"aria-controls":_,title:te,className:"flex min-w-0 flex-1 items-center gap-1 rounded-md px-1 py-1 text-left transition-colors hover:bg-accent",children:[pe,we,ae,ve,he]}),e[47]=T,e[48]=_,e[49]=oe,e[50]=re,e[51]=te,e[52]=pe,e[53]=we,e[54]=ae,e[55]=ve,e[56]=he,e[57]=de):de=e[57];let Ne;e[58]!==N||e[59]!==j||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(Ne=j&&s.length>0&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:N,onClick:je=>{je.stopPropagation();const fe=s[0];j(fe.dirName,fe.cwd??void 0)},"aria-label":`New session in ${t}`,children:N?r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(xn,{"data-icon":"inline-start"})}),e[58]=N,e[59]=j,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=Ne):Ne=e[63];let ke;e[64]!==de||e[65]!==Ne?(ke=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[de,Ne]}),e[64]=de,e[65]=Ne,e[66]=ke):ke=e[66];let Te;e[67]!==Q||e[68]!==t||e[69]!==ke||e[70]!==ie?(Te=r.jsx(lx,{projectLabel:t,customName:Q,className:"sticky top-0 z-20 bg-background",onRename:ie,children:ke}),e[67]=Q,e[68]=t,e[69]=ke,e[70]=ie,e[71]=Te):Te=e[71];let Ae;e[72]!==S?(Ae=S&&r.jsx($E,{firstMessage:S.firstMessage}),e[72]=S,e[73]=Ae):Ae=e[73];let Pe;if(e[74]!==$||e[75]!==ne||e[76]!==D||e[77]!==Y){let je;e[79]!==$||e[80]!==ne||e[81]!==D?(je=fe=>{const Ce=fe.cwd??rn(fe.dirName),_e=_i(Ce),Be=D.get(fe.sessionId);if(!Be)return ne(fe,_e==null?void 0:_e.worktreeName);const be=$.has(fe.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[ne(fe,_e==null?void 0:_e.worktreeName,{count:Be.length,collapsed:be,onToggle:()=>O(fe.sessionId)}),!be&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Be.map(Ee=>ne(Ee))})]},`${fe.dirName}/${fe.fileName}`)},e[79]=$,e[80]=ne,e[81]=D,e[82]=je):je=e[82],Pe=Y.map(je),e[74]=$,e[75]=ne,e[76]=D,e[77]=Y,e[78]=Pe}else Pe=e[78];let De;e[83]!==K?(De=K>0&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>B(!0),className:"justify-start",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Show ",K," more"]}),e[83]=K,e[84]=De):De=e[84];let ze;e[85]!==J?(ze=J&&r.jsxs(X,{type:"button",variant:"ghost",size:"xs",onClick:()=>B(!1),className:"justify-start",children:[r.jsx(Bo,{"data-icon":"inline-start"}),"Show less"]}),e[85]=J,e[86]=ze):ze=e[86];let Fe;e[87]!==Ae||e[88]!==Pe||e[89]!==De||e[90]!==ze?(Fe=r.jsxs("div",{className:"flex flex-col gap-px",children:[Ae,Pe,De,ze]}),e[87]=Ae,e[88]=Pe,e[89]=De,e[90]=ze,e[91]=Fe):Fe=e[91];let ue;e[92]!==_||e[93]!==Fe?(ue=r.jsx(jt,{id:_,className:"ml-3 border-l pl-1",children:Fe}),e[92]=_,e[93]=Fe,e[94]=ue):ue=e[94];let le;return e[95]!==Te||e[96]!==ue||e[97]!==ee?(le=r.jsxs(wt,{open:ee,className:"flex flex-col",children:[Te,ue]}),e[95]=Te,e[96]=ue,e[97]=ee,e[98]=le):le=e[98],le}function RE(n){return!_i(n.cwd??rn(n.dirName))}function IE(n){return n.sessionId}function $E(n){const e=F.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(lt,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const o=t||"New session";let i;return e[1]!==o?(i=r.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-md bg-accent px-2 py-2 text-left",children:[s,r.jsx("span",{className:"flex-1 truncate text-xs leading-tight text-foreground",children:o})]}),e[1]=o,e[2]=i):i=e[2],i}const OE=b.memo(function(e){const t=F.c(116),{activeSessionKey:s,onSelectSession:o,onDuplicateSession:i,onDeleteSession:a,onNewSession:l,creatingSession:c,pendingSession:d,refreshRef:f,onPrefetchSession:u}=e,{names:m,rename:p}=nx(),{names:h,rename:g}=ux(),v=nc(),x=cn("terminal"),w=cn("killAny"),{sessions:y,procBySession:j,newlyCompleted:N,loading:S,error:k,refresh:C,removeSession:T,acknowledgeCompleted:_}=fN(),{awaitingPermission:P,awaitingQuestion:A,awaitingElicitation:E,awaitingDialog:M}=lE();let I;t[0]!==M||t[1]!==E?(I=new Set([...E,...M]),t[0]=M,t[1]=E,t[2]=I):I=t[2];const R=I;let D;t[3]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,t[3]=D):D=t[3];const[L,$]=b.useState(D),[z,U]=b.useState("");let O,H;t[4]===Symbol.for("react.memo_cache_sentinel")?(O=Mt("live-sessions-collapsed-projects"),H={},t[4]=O,t[5]=H):(O=t[4],H=t[5]);const[B,W]=zi(O,H);let V;t[6]!==W?(V=($e,We)=>{W(Ye=>({...Ye,[$e]:We}))},t[6]=W,t[7]=V):V=t[7];const q=V,Y=b.useRef(y);let K;t[8]===Symbol.for("react.memo_cache_sentinel")?(K=new Set,t[8]=K):K=t[8];const J=b.useRef(K),Z=b.useRef(!1);let Q;t[9]===Symbol.for("react.memo_cache_sentinel")?(Q=($e,We)=>{if(!Z.current)return;const Ye=setTimeout(()=>{J.current.delete(Ye),Z.current&&$e()},We);J.current.add(Ye)},t[9]=Q):Q=t[9];const se=Q;let ne,ee;t[10]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{const $e=J.current;return Z.current=!0,()=>{Z.current=!1;for(const We of $e)clearTimeout(We);$e.clear()}},ee=[],t[10]=ne,t[11]=ee):(ne=t[10],ee=t[11]),b.useEffect(ne,ee);let ie,oe;t[12]!==y?(ie=()=>{Y.current=y},oe=[y],t[12]=y,t[13]=ie,t[14]=oe):(ie=t[13],oe=t[14]),b.useEffect(ie,oe);let re,te;t[15]!==C||t[16]!==f?(re=()=>{if(f)return f.current=C,()=>{f.current===C&&(f.current=null)}},te=[C,f],t[15]=C,t[16]=f,t[17]=re,t[18]=te):(re=t[17],te=t[18]),b.useEffect(re,te);const ce=Wi();let me;if(t[19]!==h||t[20]!==z||t[21]!==m||t[22]!==y){e:{const $e=z.trim().toLowerCase();if(!$e){me=y;break e}me=y.filter(We=>{const Ye=m[We.sessionId],yt=h[We.dirName];return[Ye,yt,We.aiTitle,We.firstUserMessage,We.lastUserMessage,We.slug,We.cwd,We.projectShortName,We.gitBranch,We.agentName,We.teamName].some(zt=>zt==null?void 0:zt.toLowerCase().includes($e))})}t[19]=h,t[20]=z,t[21]=m,t[22]=y,t[23]=me}else me=t[23];const pe=me;let xe;t[24]!==pe?(xe=Z4(pe),t[24]=pe,t[25]=xe):xe=t[25];const we=xe;let ae;t[26]!==P||t[27]!==R||t[28]!==A||t[29]!==N||t[30]!==j||t[31]!==y?(ae=uE(y,j,N,P,A,R),t[26]=P,t[27]=R,t[28]=A,t[29]=N,t[30]=j,t[31]=y,t[32]=ae):ae=t[32];const ve=ae,he=ve.needsYou.length>0||ve.working.length>0;let de;t[33]!==he||t[34]!==z?(de=!z.trim()&&he,t[33]=he,t[34]=z,t[35]=de):de=t[35];const Ne=de;let ke;e:{if(!d){ke=null;break e}let $e;t[36]!==d.cwd||t[37]!==d.dirName?($e=d.cwd||rn(d.dirName),t[36]=d.cwd,t[37]=d.dirName,t[38]=$e):$e=t[38];let We;t[39]!==$e?(We=_c($e),t[39]=$e,t[40]=We):We=t[40],ke=We}const Te=ke,Ae=b.useRef(!1);let Pe,De;t[41]!==u||t[42]!==y?(Pe=()=>{if(Ae.current||!u||y.length===0)return;Ae.current=!0;const $e=Cc(y).slice(0,3),We=globalThis,Ye=()=>{for(const Ns of $e)u(Ns.dirName,Ns.fileName)};let yt=null,zt=null;return typeof We.requestIdleCallback=="function"?yt=We.requestIdleCallback(Ye,{timeout:1500}):zt=setTimeout(Ye,300),()=>{yt!=null&&typeof We.cancelIdleCallback=="function"&&We.cancelIdleCallback(yt),zt!=null&&clearTimeout(zt)}},De=[y,u],t[41]=u,t[42]=y,t[43]=Pe,t[44]=De):(Pe=t[43],De=t[44]),b.useEffect(Pe,De);let ze;t[45]!==C?(ze=async($e,We)=>{We.stopPropagation(),$(Ye=>new Set(Ye).add($e));try{await ye("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:$e})}),se(C,1500)}catch{}se(()=>{$(Ye=>{const yt=new Set(Ye);return yt.delete($e),yt})},2e3)},t[45]=C,t[46]=ze):ze=t[46];const Fe=ze;let ue;t[47]!==_||t[48]!==o?(ue=($e,We)=>{const Ye=Y.current.find(yt=>yt.dirName===$e&&yt.fileName===We);Ye&&_(Ye.sessionId),o($e,We)},t[47]=_,t[48]=o,t[49]=ue):ue=t[49];const le=ue;let Me;t[50]!==a||t[51]!==T?(Me=$e=>{a==null||a($e.dirName,$e.fileName),T($e.sessionId)},t[50]=a,t[51]=T,t[52]=Me):Me=t[52];const Le=Me;let je;t[53]!==C||t[54]!==v?(je=($e,We)=>{const Ye=`resume_${crypto.randomUUID().slice(0,8)}`;v.send({type:"spawn",id:Ye,name:`Resume ${$e.slice(0,8)}`,command:"claude",args:["-p","--resume",$e],cwd:We??void 0,metadata:{type:"terminal"}}),se(C,3e3)},t[53]=C,t[54]=v,t[55]=je):je=t[55];const fe=je;let Ce;t[56]!==C?(Ce=()=>{cE(),C()},t[56]=C,t[57]=Ce):Ce=t[57];let _e;t[58]!==ce||t[59]!==S||t[60]!==z||t[61]!==Ce?(_e=r.jsx(kE,{loading:S,isMobile:ce,searchQuery:z,onSearchQueryChange:U,onRefresh:Ce}),t[58]=ce,t[59]=S,t[60]=z,t[61]=Ce,t[62]=_e):_e=t[62];const Be=pe.length===0&&!d&&!S&&!k;let be;t[63]!==z?(be=z.trim(),t[63]=z,t[64]=be):be=t[64];const Ee=!!be;let Ie;t[65]!==C||t[66]!==k||t[67]!==S||t[68]!==y.length||t[69]!==Be||t[70]!==Ee?(Ie=r.jsx(_E,{fetchError:k,showEmpty:Be,searching:Ee,loading:S,sessionCount:y.length,onRetry:C}),t[65]=C,t[66]=k,t[67]=S,t[68]=y.length,t[69]=Be,t[70]=Ee,t[71]=Ie):Ie=t[71];let Ue;t[72]!==s||t[73]!==ve||t[74]!==w||t[75]!==x||t[76]!==Fe||t[77]!==fe||t[78]!==le||t[79]!==L||t[80]!==u||t[81]!==j||t[82]!==h||t[83]!==m||t[84]!==Ne?(Ue=Ne&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(NE,{groups:ve,activeSessionKey:s,procBySession:j,killingPids:L,sessionNames:m,projectNames:h,onSelectSession:le,onKill:w?Fe:void 0,onResumeSession:x?fe:void 0,onPrefetchSession:u}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Projects"}),r.jsx(Et,{className:"flex-1"})]})]}),t[72]=s,t[73]=ve,t[74]=w,t[75]=x,t[76]=Fe,t[77]=fe,t[78]=le,t[79]=L,t[80]=u,t[81]=j,t[82]=h,t[83]=m,t[84]=Ne,t[85]=Ue):Ue=t[85];const Je=w?Fe:void 0,qe=a?Le:void 0,Ze=x?fe:void 0;let Ke;t[86]!==s||t[87]!==B||t[88]!==c||t[89]!==we||t[90]!==le||t[91]!==L||t[92]!==N||t[93]!==i||t[94]!==l||t[95]!==u||t[96]!==Te||t[97]!==d||t[98]!==j||t[99]!==h||t[100]!==g||t[101]!==p||t[102]!==z||t[103]!==m||t[104]!==Je||t[105]!==qe||t[106]!==Ze||t[107]!==q?(Ke=r.jsx(ME,{grouped:we,pendingProjectPath:Te,pendingSession:d,collapsedGroups:B,searchQuery:z,activeSessionKey:s,procBySession:j,killingPids:L,newlyCompleted:N,sessionNames:m,projectNames:h,onToggleCollapsed:q,onSelectSession:le,onKill:Je,onDuplicateSession:i,onDeleteSession:qe,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:u,onResumeSession:Ze}),t[86]=s,t[87]=B,t[88]=c,t[89]=we,t[90]=le,t[91]=L,t[92]=N,t[93]=i,t[94]=l,t[95]=u,t[96]=Te,t[97]=d,t[98]=j,t[99]=h,t[100]=g,t[101]=p,t[102]=z,t[103]=m,t[104]=Je,t[105]=qe,t[106]=Ze,t[107]=q,t[108]=Ke):Ke=t[108];let Re;t[109]!==Ie||t[110]!==Ue||t[111]!==Ke?(Re=r.jsx(Qo,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[Ie,Ue,Ke]})}),t[109]=Ie,t[110]=Ue,t[111]=Ke,t[112]=Re):Re=t[112];let He;return t[113]!==_e||t[114]!==Re?(He=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[_e,Re]}),t[113]=_e,t[114]=Re,t[115]=He):He=t[115],He}),DE=b.memo(function(e){const t=F.c(16),{activeSessionKey:s,onSelectSession:o,onNewSession:i,creatingSession:a,isMobile:l,onDuplicateSession:c,onDeleteSession:d,pendingSession:f,liveSessionsRefreshRef:u,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let v;t[2]!==s||t[3]!==a||t[4]!==u||t[5]!==d||t[6]!==c||t[7]!==i||t[8]!==m||t[9]!==o||t[10]!==f?(v=r.jsx(OE,{activeSessionKey:s,onSelectSession:o,onDuplicateSession:c,onDeleteSession:d,onNewSession:i,creatingSession:a,pendingSession:f,refreshRef:u,onPrefetchSession:m}),t[2]=s,t[3]=a,t[4]=u,t[5]=d,t[6]=c,t[7]=i,t[8]=m,t[9]=o,t[10]=f,t[11]=v):v=t[11];let x;return t[12]!==p||t[13]!==g||t[14]!==v?(x=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,v]}),t[12]=p,t[13]=g,t[14]=v,t[15]=x):x=t[15],x}),LE=b.lazy(()=>Ve(()=>import("./index-C00ZsBZl.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.MissionControl})));function bx(n){const e=F.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(It,{className:"size-4"}),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=o):o=e[2],o}function yx(n){const e=F.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=st(),l=a?`${a.dirName}/${a.fileName}`:null;let c;return e[0]!==l||e[1]!==o||e[2]!==i||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=r.jsx(DE,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:i,header:o}),e[0]=l,e[1]=o,e[2]=i,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function wx(n){const e=F.c(8),{navigation:t}=n,{state:s}=Ct();let o;return e[0]!==t.actions.handleDashboardSelect||e[1]!==t.creatingSession||e[2]!==t.handlers.handleDeleteSession||e[3]!==t.handlers.handleDuplicateSessionByPath||e[4]!==t.onSelectProject||e[5]!==t.onStartNewSession||e[6]!==s.dashboardProject?(o=r.jsx(nE,{onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,selectedProjectDirName:s.dashboardProject,onSelectProject:t.onSelectProject,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession}),e[0]=t.actions.handleDashboardSelect,e[1]=t.creatingSession,e[2]=t.handlers.handleDeleteSession,e[3]=t.handlers.handleDuplicateSessionByPath,e[4]=t.onSelectProject,e[5]=t.onStartNewSession,e[6]=s.dashboardProject,e[7]=o):o=e[7],o}function zE(n){const e=F.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(bx,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(b.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(LE,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function FE({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function BE({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function UE({path:n,text:e,startLine:t,endLine:s,comment:o}){if(!e)return`@${n}`;const i=e.includes("```")?"````":"```",a=t===s?`line ${t}`:`lines ${t}-${s}`;return`${o?`Review request: ${o}
|
|
115
|
+
`:""}${n} (${a})
|
|
116
|
+
${i}
|
|
117
|
+
${e}
|
|
118
|
+
${i}`}const WE=b.lazy(()=>Ve(()=>import("./ConfigBrowser-CPCH7_25.js"),__vite__mapDeps([32,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser}))),HE=b.lazy(()=>Ve(()=>import("./PreviewPanel-DoAf1W2k.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),KE=b.lazy(()=>Ve(()=>import("./ProjectFilesPanel-v_O7Awnm.js"),__vite__mapDeps([35,1,33,2,3,4])).then(n=>({default:n.ProjectFilesPanel})));function VE(n){const e=F.c(33),{navigation:t,sessionView:s,project:o,floatingChrome:i}=n,{state:a}=Ct(),{session:l}=st();if(!l)return null;const c=o.hasFileChanges&&t.panels.showFileChanges?70:100;let d;e[0]!==s.teamMembersBar?(d=s.teamMembersBar&&r.jsx("div",{className:"pt-10",children:s.teamMembersBar}),e[0]=s.teamMembersBar,e[1]=d):d=e[1];const f=!!s.todoProgress&&s.todosExpanded;let u;e[2]!==s.hasMoreTurns||e[3]!==s.isLoadingOlderTurns||e[4]!==s.onLoadMoreTurns||e[5]!==s.searchInputRef||e[6]!==f?(u=r.jsx(qi,{searchInputRef:s.searchInputRef,hasTodos:f,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns}),e[2]=s.hasMoreTurns,e[3]=s.isLoadingOlderTurns,e[4]=s.onLoadMoreTurns,e[5]=s.searchInputRef,e[6]=f,e[7]=u):u=e[7];let m;e[8]!==s.onTodosExpandedChange||e[9]!==s.todoProgress||e[10]!==s.todosExpanded?(m=s.todoProgress&&r.jsx(Ng,{progress:s.todoProgress,expanded:s.todosExpanded,onExpandedChange:s.onTodosExpandedChange}),e[8]=s.onTodosExpandedChange,e[9]=s.todoProgress,e[10]=s.todosExpanded,e[11]=m):m=e[11];let p;e[12]!==s.activeComposer||e[13]!==m?(p=r.jsxs(Xi,{floating:!0,children:[m,s.activeComposer]}),e[12]=s.activeComposer,e[13]=m,e[14]=p):p=e[14];let h;e[15]!==i||e[16]!==d||e[17]!==u||e[18]!==p?(h=r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[i,d,u,p]}),e[15]=i,e[16]=d,e[17]=u,e[18]=p,e[19]=h):h=e[19];let g;e[20]!==c||e[21]!==h?(g=r.jsx(lm,{defaultSize:c,minSize:"500px",children:h}),e[20]=c,e[21]=h,e[22]=g):g=e[22];let v;e[23]!==t||e[24]!==o.hasFileChanges||e[25]!==l||e[26]!==s.fileChangesCollapsed||e[27]!==s.onFileChangesPanelResize||e[28]!==a?(v=o.hasFileChanges&&t.panels.showFileChanges&&r.jsxs(r.Fragment,{children:[r.jsx(A8,{withHandle:!0}),r.jsx(lm,{defaultSize:30,minSize:0,collapsible:!0,onResize:s.onFileChangesPanelResize,children:!s.fileChangesCollapsed&&r.jsx(d_,{session:l,sessionChangeKey:a.sessionChangeKey})})]}),e[23]=t,e[24]=o.hasFileChanges,e[25]=l,e[26]=s.fileChangesCollapsed,e[27]=s.onFileChangesPanelResize,e[28]=a,e[29]=v):v=e[29];let x;return e[30]!==g||e[31]!==v?(x=r.jsx("div",{className:"flex min-h-0 flex-1 bg-background",children:r.jsxs(P8,{orientation:"horizontal",className:"min-h-0 flex-1",children:[g,v]})}),e[30]=g,e[31]=v,e[32]=x):x=e[32],x}function qE(n){const e=F.c(38),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Ct(),{session:c,sessionSource:d}=st();let f,u;if(e[0]!==(c==null?void 0:c.cwd)||e[1]!==d||e[2]!==l.configFilePath||e[3]!==l.dashboardProject||e[4]!==l.pendingCwd||e[5]!==l.pendingDirName||e[6]!==i){u=Symbol.for("react.early_return_sentinel");e:if(f=l.pendingCwd??(l.pendingDirName?rn(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(bx,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(WE,{projectPath:BE({sessionCwd:c==null?void 0:c.cwd,pendingPath:f,sessionDirPath:d!=null&&d.dirName?rn(d.dirName):null,dashboardProjectPath:l.dashboardProject?rn(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(b.Suspense,{fallback:p,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:h})}),e[10]=h,e[11]=g):g=e[11],u=g;break e}e[0]=c==null?void 0:c.cwd,e[1]=d,e[2]=l.configFilePath,e[3]=l.dashboardProject,e[4]=l.pendingCwd,e[5]=l.pendingDirName,e[6]=i,e[7]=f,e[8]=u}else f=e[7],u=e[8];if(u!==Symbol.for("react.early_return_sentinel"))return u;if(i==="mission"){let p;return e[12]!==t?(p=r.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:r.jsx(zE,{navigation:t})}),e[12]=t,e[13]=p):p=e[13],p}if(i==="session"){let p;return e[14]!==a||e[15]!==t||e[16]!==o||e[17]!==s?(p=r.jsx(VE,{navigation:t,sessionView:s,project:o,floatingChrome:a}),e[14]=a,e[15]=t,e[16]=o,e[17]=s,e[18]=p):p=e[18],p}if(i==="pending"){const p=s.pendingTurns.length>0,h=vs()?"Only on the machine running this session":void 0;let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=mc()?void 0:h,e[19]=g):g=e[19];const v=g,x=!p&&"justify-center gap-4";let w;e[20]!==x?(w=G("flex min-h-0 min-w-0 flex-1 flex-col bg-background",x),e[20]=x,e[21]=w):w=e[21];let y;e[22]!==p||e[23]!==f||e[24]!==s.pendingTurns?(y=p?r.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:r.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):r.jsx(Z1,{projectPath:f}),e[22]=p,e[23]=f,e[24]=s.pendingTurns,e[25]=y):y=e[25];let j;e[26]!==s.pendingComposer?(j=r.jsx(Xi,{children:s.pendingComposer}),e[26]=s.pendingComposer,e[27]=j):j=e[27];let N;e[28]!==p||e[29]!==o?(N=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[at("terminal")&&r.jsx(Oa,{reason:h,children:r.jsxs(X,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(Zs,{"data-icon":"inline-start"}),"Terminal"]})}),at("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(Oa,{reason:v,children:r.jsxs(X,{variant:"outline",size:"xs",disabled:!!v,onClick:()=>Ah(o.pendingProject),children:[r.jsx(Fo,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(Oa,{reason:h,children:r.jsxs(X,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>Mh(o.pendingProject),children:[r.jsx(np,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[28]=p,e[29]=o,e[30]=N):N=e[30];let S;return e[31]!==w||e[32]!==y||e[33]!==j||e[34]!==N?(S=r.jsxs("div",{className:w,children:[y,j,N]}),e[31]=w,e[32]=y,e[33]=j,e[34]=N,e[35]=S):S=e[35],S}let m;return e[36]!==t?(m=r.jsx(wx,{navigation:t}),e[36]=t,e[37]=m):m=e[37],m}function GE(n){const e=F.c(78),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Ct(),{session:c}=st();let d;e[0]!==s.chatInputRef.current?(d=function(Y){var ie,oe,re;const{path:K,text:J,startLine:Z,endLine:Q,comment:se}=Y,ne=UE({path:K,text:J,startLine:Z,endLine:Q,comment:se}),ee=((ie=s.chatInputRef.current)==null?void 0:ie.getText().trimEnd())??"";(oe=s.chatInputRef.current)==null||oe.setText(ee?`${ee}
|
|
119
|
+
|
|
120
|
+
${ne}
|
|
121
|
+
`:`${ne}
|
|
122
|
+
`),(re=s.chatInputRef.current)==null||re.focus()},e[0]=s.chatInputRef.current,e[1]=d):d=e[1];const f=d,u=a.mainView,m=!!c;let p;e[2]!==a.mainView||e[3]!==a.pendingDirName||e[4]!==m?(p=FE({mainView:u,hasSession:m,pendingDirName:a.pendingDirName}),e[2]=a.mainView,e[3]=a.pendingDirName,e[4]=m,e[5]=p):p=e[5];const h=p,g=t.panels.handleToggleSidebar,v=t.actions.handleGoHome,x=i.onOpenCommandPalette;let w,y;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=Ia("toggleSidebar"),y=Ia("commandPalette"),e[6]=w,e[7]=y):(w=e[6],y=e[7]);let j;e[8]!==i.onOpenCommandPalette||e[9]!==t.actions.handleGoHome||e[10]!==t.panels.handleToggleSidebar?(j=r.jsx(V7,{onToggleSidebar:g,onGoHome:v,onOpenCommandPalette:x,sidebarShortcut:w,commandPaletteShortcut:y}),e[8]=i.onOpenCommandPalette,e[9]=t.actions.handleGoHome,e[10]=t.panels.handleToggleSidebar,e[11]=j):j=e[11];const N=j,S=t.panels.showSidebar&&a.mainView!=="config",k=t.panels.showSidebar;let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=Ia("toggleSidebar"),e[12]=C):C=e[12];const T=o.supportsWorktrees&&t.panels.showWorktrees,_=o.supportsWorktrees?t.panels.handleToggleWorktrees:void 0,P=a.mainView==="config",A=at("configWrite")?t.panels.handleToggleConfig:void 0,E=a.mainView==="mission";let M;e[13]!==i.killing||e[14]!==i.onKillAll||e[15]!==l.openConfigDialog||e[16]!==t.creatingSession||e[17]!==t.handlers.handleDuplicateSession||e[18]!==t.onStartNewSession||e[19]!==t.panels.handleToggleFileChanges||e[20]!==t.panels.handleToggleMission||e[21]!==t.panels.handleToggleSidebar||e[22]!==t.panels.handleToggleStats||e[23]!==t.panels.showFileChanges||e[24]!==t.panels.showSidebar||e[25]!==t.panels.showStats||e[26]!==o.hasFileChanges||e[27]!==o.onOpenTerminal||e[28]!==s.onBackToMain||e[29]!==s.onShowWorkflows||e[30]!==s.workflowCount||e[31]!==S||e[32]!==T||e[33]!==_||e[34]!==P||e[35]!==A||e[36]!==E?(M=r.jsx(L7,{showSidebar:k,sidebarRendered:S,sidebarShortcut:C,showStats:t.panels.showStats,showWorktrees:T,showFileChanges:t.panels.showFileChanges,hasFileChanges:o.hasFileChanges,killing:i.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:o.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onToggleStats:t.panels.handleToggleStats,onToggleWorktrees:_,onToggleFileChanges:t.panels.handleToggleFileChanges,showConfig:P,onToggleConfig:A,showMission:E,onToggleMission:t.panels.handleToggleMission,onKillAll:i.onKillAll,onOpenSettings:l.openConfigDialog}),e[13]=i.killing,e[14]=i.onKillAll,e[15]=l.openConfigDialog,e[16]=t.creatingSession,e[17]=t.handlers.handleDuplicateSession,e[18]=t.onStartNewSession,e[19]=t.panels.handleToggleFileChanges,e[20]=t.panels.handleToggleMission,e[21]=t.panels.handleToggleSidebar,e[22]=t.panels.handleToggleStats,e[23]=t.panels.showFileChanges,e[24]=t.panels.showSidebar,e[25]=t.panels.showStats,e[26]=o.hasFileChanges,e[27]=o.onOpenTerminal,e[28]=s.onBackToMain,e[29]=s.onShowWorkflows,e[30]=s.workflowCount,e[31]=S,e[32]=T,e[33]=_,e[34]=P,e[35]=A,e[36]=E,e[37]=M):M=e[37];const I=M;let R;e[38]!==t||e[39]!==N||e[40]!==S?(R=S&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(yx,{navigation:t,header:N})}),e[38]=t,e[39]=N,e[40]=S,e[41]=R):R=e[41];const D=h!=="session"&&I;let L;e[42]!==I||e[43]!==t||e[44]!==o||e[45]!==s||e[46]!==h?(L=r.jsx(qE,{navigation:t,sessionView:s,project:o,view:h,floatingChrome:I}),e[42]=I,e[43]=t,e[44]=o,e[45]=s,e[46]=h,e[47]=L):L=e[47];let $;e[48]!==D||e[49]!==L?($=r.jsxs("main",{className:"app-view-transition relative flex min-w-0 flex-1 flex-col overflow-hidden",children:[D,L]}),e[48]=D,e[49]=L,e[50]=$):$=e[50];const z=!o.showPreview&&!o.showProjectFiles&&t.panels.showStats&&!!c&&a.mainView!=="config",U=!o.showPreview&&!o.showProjectFiles&&!!c&&a.mainView!=="config";let O;e[51]!==t.actions.handleJumpToTurn||e[52]!==t.handlers.handleLoadSessionScrollAware||e[53]!==o.backgroundAgents||e[54]!==o.processPanel.handleServersChanged||e[55]!==o.processPanel.handleToggleServer||e[56]!==s.searchInputRef?(O=r.jsx(J1,{onJumpToTurn:t.actions.handleJumpToTurn,onToggleServer:o.processPanel.handleToggleServer,onServersChanged:o.processPanel.handleServersChanged,searchInputRef:s.searchInputRef,onLoadSession:t.handlers.handleLoadSessionScrollAware,backgroundAgents:o.backgroundAgents}),e[51]=t.actions.handleJumpToTurn,e[52]=t.handlers.handleLoadSessionScrollAware,e[53]=o.backgroundAgents,e[54]=o.processPanel.handleServersChanged,e[55]=o.processPanel.handleToggleServer,e[56]=s.searchInputRef,e[57]=O):O=e[57];let H;e[58]!==z||e[59]!==U||e[60]!==O?(H=r.jsx(H7,{side:"right",visible:z,enabled:U,children:O}),e[58]=z,e[59]=U,e[60]=O,e[61]=H):H=e[61];let B;e[62]!==o.currentCwd||e[63]!==o.onCloseRightWorkspace||e[64]!==o.showPreview?(B=o.showPreview&&o.currentCwd&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(HE,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[62]=o.currentCwd,e[63]=o.onCloseRightWorkspace,e[64]=o.showPreview,e[65]=B):B=e[65];let W;e[66]!==f||e[67]!==o.onCloseRightWorkspace||e[68]!==o.projectFilesRequest||e[69]!==o.projectFilesRoot||e[70]!==o.showProjectFiles?(W=o.showProjectFiles&&o.projectFilesRoot&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(KE,{cwd:o.projectFilesRoot,onClose:o.onCloseRightWorkspace,onAddToPrompt:f,openRequest:o.projectFilesRequest})}),e[66]=f,e[67]=o.onCloseRightWorkspace,e[68]=o.projectFilesRequest,e[69]=o.projectFilesRoot,e[70]=o.showProjectFiles,e[71]=W):W=e[71];let V;return e[72]!==R||e[73]!==$||e[74]!==H||e[75]!==B||e[76]!==W?(V=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[R,$,H,B,W]}),e[72]=R,e[73]=$,e[74]=H,e[75]=B,e[76]=W,e[77]=V):V=e[77],V}function YE(n){const e=F.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Ct(),l=`${a.themeClasses} flex h-dvh flex-col bg-background text-foreground`;let c,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(_g,{}),d=r.jsx(Cg,{}),e[0]=c,e[1]=d):(c=e[0],d=e[1]);let f;e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s?(f=r.jsx(GE,{navigation:t,sessionView:s,project:o,chrome:i}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=f):f=e[6];let u;e[7]!==i||e[8]!==t||e[9]!==o?(u=r.jsx(q6,{navigation:t,project:o,chrome:i}),e[7]=i,e[8]=t,e[9]=o,e[10]=u):u=e[10];let m;return e[11]!==i.backgroundServers||e[12]!==l||e[13]!==f||e[14]!==u?(m=r.jsxs("div",{className:l,children:[i.backgroundServers,c,d,f,u]}),e[11]=i.backgroundServers,e[12]=l,e[13]=f,e[14]=u,e[15]=m):m=e[15],m}const XE=[{id:"sessions",label:"Sessions",icon:_o},{id:"chat",label:"Chat",icon:bi},{id:"stats",label:"Stats",icon:rp,requiresSession:!0}],JE=b.memo(function(e){const t=F.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=st(),l=i!==null;let c,d,f;if(t[0]!==s||t[1]!==l||t[2]!==a||t[3]!==o){let m;t[7]!==l?(m=g=>!(g.requiresSession&&!l),t[7]=l,t[8]=m):m=t[8];const p=XE.filter(m);c="flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]",d="Navigation";let h;t[9]!==s||t[10]!==a||t[11]!==o?(h=g=>{const v=g.icon,x=s===g.id;return r.jsx("button",{type:"button","aria-current":x?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{Nl(),o(g.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",x?"text-foreground":"text-muted-foreground hover:text-foreground"),children:r.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",x?"scale-100 bg-accent":"scale-95"),children:[r.jsx(v,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",x&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(Ti,{className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},g.id)},t[9]=s,t[10]=a,t[11]=o,t[12]=h):h=t[12],f=p.map(h),t[0]=s,t[1]=l,t[2]=a,t[3]=o,t[4]=c,t[5]=d,t[6]=f}else c=t[4],d=t[5],f=t[6];let u;return t[13]!==c||t[14]!==d||t[15]!==f?(u=r.jsx("nav",{className:c,"aria-label":d,children:f}),t[13]=c,t[14]=d,t[15]=f,t[16]=u):u=t[16],u});function ZE(n){const e=F.c(63),{session:t,sessionSource:s,isSubAgentView:o,claudeRawMessages:i,creatingSession:a,onNewSession:l,onDuplicateSession:c,onBackToMain:d,onShowFileChanges:f,hasFileChanges:u,onShowWorkflows:m,workflowCount:p,onSearch:h,expandAll:g,onToggleExpandAll:v}=n;let x;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(x=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=x):x=e[3];const w=x;let y;e[4]!==o||e[5]!==d?(y=o&&d&&r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(Dl,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=y):y=e[6];let j,N;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Uc,{compact:!0}),N=r.jsx(Et,{orientation:"vertical",className:"h-4"}),e[7]=j,e[8]=N):(j=e[7],N=e[8]);let S;e[9]!==i?(S=r.jsx(Vp,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=S):S=e[10];let k;e[11]!==t.cwd?(k=t.cwd?Nn(t.cwd):"Session",e[11]=t.cwd,e[12]=k):k=e[12];let C;e[13]!==k?(C=r.jsx("span",{className:"min-w-0 flex-1 truncate text-center text-xs font-medium text-muted-foreground",children:k}),e[13]=k,e[14]=C):C=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(In,{render:r.jsx(X,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(op,{"data-icon":"inline-start"})}),e[15]=T):T=e[15];let _;e[16]!==t.cwd?(_=t.cwd?Nn(t.cwd):"Current session",e[16]=t.cwd,e[17]=_):_=e[17];let P;e[18]!==_?(P=r.jsx("span",{className:"truncate text-foreground",children:_}),e[18]=_,e[19]=P):P=e[19];let A;e[20]!==t.gitBranch||e[21]!==t.model?(A=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=A):A=e[22];let E;e[23]!==A?(E=r.jsx("span",{className:"truncate font-normal",children:A}),e[23]=A,e[24]=E):E=e[24];let M;e[25]!==P||e[26]!==E?(M=r.jsxs(es,{className:"flex flex-col gap-0.5",children:[P,E]}),e[25]=P,e[26]=E,e[27]=M):M=e[27];let I;e[28]!==a||e[29]!==w||e[30]!==s?(I=s&&r.jsxs(it,{onClick:w,disabled:a,children:[a?r.jsx(It,{}):r.jsx(xn,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=w,e[30]=s,e[31]=I):I=e[31];let R;e[32]!==c?(R=c&&r.jsxs(it,{onClick:c,children:[r.jsx(bn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let D;e[34]!==M||e[35]!==I||e[36]!==R?(D=r.jsxs(Lt,{children:[M,I,R]}),e[34]=M,e[35]=I,e[36]=R,e[37]=D):D=e[37];let L;e[38]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Us,{}),e[38]=L):L=e[38];let $;e[39]!==h?($=h&&r.jsxs(it,{onClick:h,children:[r.jsx(an,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=$):$=e[40];let z;e[41]!==g||e[42]!==v?(z=v&&r.jsxs(it,{onClick:v,children:[g?r.jsx(vi,{}):r.jsx(gi,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=v,e[43]=z):z=e[43];let U;e[44]!==u||e[45]!==f?(U=u&&f&&r.jsxs(it,{onClick:f,children:[r.jsx(Wo,{}),r.jsx("span",{children:"File changes"})]}),e[44]=u,e[45]=f,e[46]=U):U=e[46];let O;e[47]!==m||e[48]!==p?(O=m&&(p??0)>0&&r.jsxs(it,{onClick:m,children:[r.jsx(sp,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Oe,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=O):O=e[49];let H;e[50]!==$||e[51]!==z||e[52]!==U||e[53]!==O?(H=r.jsxs(Lt,{children:[$,z,U,O]}),e[50]=$,e[51]=z,e[52]=U,e[53]=O,e[54]=H):H=e[54];let B;e[55]!==D||e[56]!==H?(B=r.jsxs(Rn,{children:[T,r.jsxs($n,{align:"end",sideOffset:6,className:"w-72",children:[D,L,H]})]}),e[55]=D,e[56]=H,e[57]=B):B=e[57];let W;return e[58]!==y||e[59]!==B||e[60]!==S||e[61]!==C?(W=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[y,j,N,S,C,B]}),e[58]=y,e[59]=B,e[60]=S,e[61]=C,e[62]=W):W=e[62],W}const QE=b.memo(function(e){const t=F.c(11),{isMobile:s}=Ct(),{session:o,sessionSource:i}=st();if(!s||!o)return null;let a;t[0]!==i?(a=i?ss(i.fileName):null,t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]!==o.agentKind||t[3]!==o.rawMessages?(c=o.agentKind==="codex"?[]:o.rawMessages,t[2]=o.agentKind,t[3]=o.rawMessages,t[4]=c):c=t[4];const d=c,f=l!==null;let u;return t[5]!==d||t[6]!==e||t[7]!==o||t[8]!==i||t[9]!==f?(u=r.jsx(ZE,{...e,session:o,sessionSource:i,isSubAgentView:f,claudeRawMessages:d}),t[5]=d,t[6]=e,t[7]=o,t[8]=i,t[9]=f,t[10]=u):u=t[10],u});function e9({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=b.useRef(null),i=b.useRef(null),a=b.useRef(n),l=b.useRef(e);return a.current=n,l.current=e,b.useEffect(()=>{const c=o.current;if(!c||!s)return;function d(u){const m=u.touches[0];i.current={x:m.clientX,y:m.clientY}}function f(u){var g,v;if(!i.current)return;const m=u.changedTouches[0],p=m.clientX-i.current.x,h=m.clientY-i.current.y;i.current=null,!(Math.abs(p)<t||Math.abs(p)<Math.abs(h))&&(p>0?(g=l.current)==null||g.call(l):(v=a.current)==null||v.call(a))}return c.addEventListener("touchstart",d,{passive:!0}),c.addEventListener("touchend",f,{passive:!0}),()=>{c.removeEventListener("touchstart",d),c.removeEventListener("touchend",f)}},[s,t]),o}const t9=["sessions","chat","stats"];function n9({hasSession:n,hasPendingSession:e}){return t9.filter(t=>!(t==="stats"&&!n&&!e))}function mm(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const s9=b.lazy(()=>Ve(()=>import("./MobileFileChanges-C5VoKbje.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function o9(n){const e=F.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Ct(),{session:c,isSubAgentView:d}=st(),f=!!c,u=!!a.pendingDirName;let m;e[0]!==f||e[1]!==u?(m=n9({hasSession:f,hasPendingSession:u}),e[0]=f,e[1]=u,e[2]=m):m=e[2];const p=m;let h;e[3]!==t.actions||e[4]!==a.mobileTab||e[5]!==p?(h={enabled:!0,onSwipeLeft:()=>{const U=mm(p,a.mobileTab,1);U&&(Nl(),t.actions.handleMobileTabChange(U))},onSwipeRight:()=>{const U=mm(p,a.mobileTab,-1);U&&(Nl(),t.actions.handleMobileTabChange(U))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=e9(h);let v;e[7]!==i||e[8]!==t.actions?(v=U=>{i.onSearchOpenChange(!1),t.actions.handleMobileTabChange(U)},e[7]=i,e[8]=t.actions,e[9]=v):v=e[9];const x=v,w=`${l.themeClasses} flex h-dvh flex-col bg-background text-foreground`,y=i.backgroundServers;let j,N;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(_g,{}),N=r.jsx(Cg,{}),e[10]=j,e[11]=N):(j=e[10],N=e[11]);let S;e[12]!==c||e[13]!==a.mobileTab?(S=!(a.mobileTab==="chat"&&c)&&r.jsx("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:r.jsx(Uc,{compact:!0})}),e[12]=c,e[13]=a.mobileTab,e[14]=S):S=e[14];const k=a.mobileTab,C=!(a.mobileTab==="chat"&&c)&&"motion-session-enter";let T;e[15]!==C?(T=G("flex min-h-0 min-w-0 flex-1",C),e[15]=C,e[16]=T):T=e[16];let _;e[17]!==t||e[18]!==a.mobileTab?(_=a.mobileTab==="sessions"&&r.jsx(yx,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=_):_=e[19];let P;e[20]!==i||e[21]!==d||e[22]!==t||e[23]!==o||e[24]!==c||e[25]!==s||e[26]!==a.expandAll||e[27]!==a.mobileTab||e[28]!==a.pendingDirName?(P=a.mobileTab==="chat"&&r.jsx("div",{className:"flex flex-1 min-h-0 flex-col min-w-0",children:c?r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,r.jsx(QE,{creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:o.onOpenTerminal,onBackToMain:d?s.onBackToMain:void 0,onShowFileChanges:()=>i.onFileChangesOpenChange(!0),hasFileChanges:o.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>i.onSearchOpenChange(!0),expandAll:a.expandAll,onToggleExpandAll:s.onToggleExpandAll}),r.jsx(qi,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:i.searchOpen,onMobileSearchClose:()=>i.onSearchOpenChange(!1)})]}):a.pendingDirName?r.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?r.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[r.jsx(Z1,{projectPath:s.pendingPath??null}),at("terminal")&&r.jsxs(X,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(Zs,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(wx,{navigation:t})}),e[20]=i,e[21]=d,e[22]=t,e[23]=o,e[24]=c,e[25]=s,e[26]=a.expandAll,e[27]=a.mobileTab,e[28]=a.pendingDirName,e[29]=P):P=e[29];let A;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(A=a.mobileTab==="stats"&&c&&r.jsx(J1,{onJumpToTurn:t.handlers.handleMobileJumpToTurn,onToggleServer:o.processPanel.handleToggleServer,onServersChanged:o.processPanel.handleServersChanged,onLoadSession:t.handlers.handleLoadSessionScrollAware,backgroundAgents:o.backgroundAgents}),e[30]=t.handlers,e[31]=o,e[32]=c,e[33]=a.mobileTab,e[34]=A):A=e[34];let E;e[35]!==a.mobileTab||e[36]!==T||e[37]!==_||e[38]!==P||e[39]!==A?(E=r.jsxs("div",{className:T,children:[_,P,A]},k),e[35]=a.mobileTab,e[36]=T,e[37]=_,e[38]=P,e[39]=A,e[40]=E):E=e[40];let M;e[41]!==g||e[42]!==E?(M=r.jsx("main",{ref:g,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:E}),e[41]=g,e[42]=E,e[43]=M):M=e[43];const I=a.mobileTab==="chat"&&i.processPanel;let R;e[44]!==c||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?(R=a.mobileTab==="chat"&&(c||a.pendingDirName)&&r.jsxs(r.Fragment,{children:[s.todoProgress,c?s.activeComposer:s.pendingComposer]}),e[44]=c,e[45]=s,e[46]=a.mobileTab,e[47]=a.pendingDirName,e[48]=R):R=e[48];let D;e[49]!==I||e[50]!==R?(D=r.jsxs("div",{className:"shrink-0",children:[I,R]}),e[49]=I,e[50]=R,e[51]=D):D=e[51];let L;e[52]!==x||e[53]!==a.mobileTab?(L=r.jsx(JE,{activeTab:a.mobileTab,onTabChange:x}),e[52]=x,e[53]=a.mobileTab,e[54]=L):L=e[54];let $;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?($=c&&o.hasFileChanges&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(s9,{open:i.fileChangesOpen,onClose:()=>i.onFileChangesOpenChange(!1),session:c,sessionChangeKey:a.sessionChangeKey})}),e[55]=i,e[56]=o,e[57]=c,e[58]=a.sessionChangeKey,e[59]=$):$=e[59];let z;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==S||e[65]!==M||e[66]!==D||e[67]!==L||e[68]!==$||e[69]!==w?(z=r.jsxs("div",{className:w,children:[y,j,N,S,M,D,i.workflowsPanel,L,i.undoDialog,i.branchModal,$]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=S,e[65]=M,e[66]=D,e[67]=L,e[68]=$,e[69]=w,e[70]=z):z=e[70],z}function r9(n){const e=F.c(13),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{theme:d,isMobile:f}=Ct(),{session:u}=st(),m=`${d.themeClasses} flex h-dvh flex-col overflow-hidden bg-background text-foreground`;let p;e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==f||e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==u||e[8]!==t?(p=u?r.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[r.jsx(qi,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),f?i:r.jsx(Xi,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(En,{className:"max-w-md",children:r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:s?r.jsx(ln,{}):r.jsx(lt,{className:"animate-spin"})}),r.jsx(An,{children:s?"Unable to open session":"Opening session"}),r.jsx(Mn,{children:s??`Looking for ${t} in your local Claude and Codex history.`})]})})}),e[0]=i,e[1]=a,e[2]=l,e[3]=f,e[4]=s,e[5]=c,e[6]=o,e[7]=u,e[8]=t,e[9]=p):p=e[9];let h;return e[10]!==m||e[11]!==p?(h=r.jsx("div",{className:m,children:p}),e[10]=m,e[11]=p,e[12]=h):h=e[12],h}const i9=5;function Ir(n,e){const t=nn(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class a9{constructor(){vr(this,"cache",new Map)}get(e,t){const s=Ir(e,t),o=this.cache.get(s);return o&&(o.lastAccessed=Date.now()),o}set(e,t,s,o,i,a,l,c){const d=Ir(e,t);!this.cache.has(d)&&this.cache.size>=i9&&this.evictLRU(),this.cache.set(d,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:o,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:i,hasMore:a,lastAccessed:Date.now()})}update(e,t,s){const o=Ir(e,t),i=this.cache.get(o);i&&(s.parsed!==void 0&&(i.parsed=s.parsed),s.olderTurns!==void 0&&(i.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(i.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(i.hasMore=s.hasMore),s.lastAccessed!==void 0&&(i.lastAccessed=s.lastAccessed),s.source&&(i.source={...i.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(Ir(e,t)):this.evictLRU()}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,o]of this.cache)o.lastAccessed<t&&(t=o.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const on=new a9,pm={};function jx(n,e,t,s,o,i){const[a,l]=b.useState(!1),[c,d]=b.useState("disconnected"),[f,u]=b.useState(!1),[m,p]=b.useState(null),[h,g]=b.useState(pm),[v,x]=b.useState(null),[w,y]=b.useState(Ls),j=b.useRef(""),N=b.useRef(null),S=b.useRef(Ls),k=b.useRef("disconnected"),C=b.useRef(e);C.current=e;const T=b.useRef(o);T.current=o;const _=b.useRef(t);_.current=t;const P=b.useRef(s);P.current=s;const A=b.useRef(i??null);A.current=i??null;const E=b.useRef(!1),M=(n==null?void 0:n.dirName)??null,I=(n==null?void 0:n.fileName)??null,R=(n==null?void 0:n.rawText)??"",D=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return b.useEffect(()=>{if(j.current=R,!R){N.current=null,l(!1);return}const L=A.current;if(L){N.current=L;return}_.current(R).then($=>{N.current=$})},[R]),b.useEffect(()=>{if(x(null),!M||!I){l(!1),d("disconnected");return}d("connecting");const L=`/api/watch/${encodeURIComponent(M)}/${encodeURIComponent(I)}?offset=${D}`,$=new EventSource(Vo(L));let z=null;const U=(re=3e4)=>{z&&clearTimeout(z),z=setTimeout(()=>{l(!1),u(!1)},re)};let O="",H=D,B=!1,W=!1,V=!1,q=null;const Y=()=>{V=!1,q=null,N.current&&C.current(N.current)},K=()=>{V||(V=!0,q=requestAnimationFrame(Y))};let J=!1,Z=null,Q=null;const se=()=>{J=!1,Z=null,y(S.current)},ne=()=>{J||(J=!0,Z=requestAnimationFrame(se))},ee=re=>{re!==S.current&&(S.current=re,ne(),re.length>0&&!Q&&(Q=setInterval(()=>{const te=kN(S.current);te!==S.current&&(S.current=te,ne()),S.current.length===0&&Q&&(clearInterval(Q),Q=null)},5e3)))},ie=()=>{ee(Ls),g(pm)},oe=()=>{if(W||B||!O)return;const re=O;O="",B=!0;const te=N.current;(te?P.current(te,re):_.current(j.current)).then(me=>{W||(N.current=me,M&&I&&on.update(M,I,{parsed:me,source:{rawText:j.current,watchOffset:H}}),K())}).catch(me=>{console.error("[useLiveSession] worker parse failed:",me)}).finally(()=>{B=!1,!W&&O&&oe()})};return $.onopen=()=>{var re;if(k.current!=="connected"){const te=E.current;E.current=!1,k.current="connected",d("connected"),te&&((re=T.current)==null||re.call(T))}},$.onmessage=re=>{try{k.current!=="connected"&&(k.current="connected",d("connected"));const te=JSON.parse(re.data);if(te.type==="init")te.recentlyActive?(l(!0),U(5e3)):U();else if(te.type==="compacting_in_progress")l(!0),u(!0),ie(),U();else if(te.type==="subagent_activity")l(!0),U();else if(te.type==="stream_snapshot")l(!0),U(),ee(jN(te.messages??[]));else if(te.type==="stream_delta")l(!0),U(),p(null),x(null),ee(SN(S.current,te.events??[]));else if(te.type==="agent_progress")l(!0),U(),g(ce=>({...ce,[te.toolUseId]:te.summary}));else if(te.type==="prompt_suggestion")x(typeof te.suggestion=="string"?te.suggestion:null);else if(te.type==="turn_error")p(typeof te.message=="string"?te.message:"The turn failed");else if(te.type==="stream_clear")ie();else if(te.type==="lines"&&te.lines.length>0){l(!0),u(!1),U(),ee(NN(S.current,te.lines));const ce=te.lines.join(`
|
|
123
|
+
`)+`
|
|
124
|
+
`;H+=new TextEncoder().encode(ce).byteLength,j.current+=ce,O+=ce,oe()}}catch(te){console.error("[useLiveSession] Error processing SSE message:",te)}},$.onerror=()=>{l(!1),u(!1),E.current=k.current==="connected",k.current="disconnected",d("disconnected"),ie()},()=>{W=!0,$.close(),l(!1),k.current="disconnected",d("disconnected"),z&&clearTimeout(z),q!==null&&cancelAnimationFrame(q),Z!==null&&cancelAnimationFrame(Z),Q&&clearInterval(Q),S.current=Ls,y(Ls)}},[M,I,R,D]),{isLive:a,sseState:c,isCompacting:f,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:v}}const l9=3e4;function Sx(n,e,t){const s=F.c(9),o=l9,[i,a]=b.useState(!1),l=b.useRef(e);let c,d;s[0]!==e?(c=()=>{l.current=e},d=[e],s[0]=e,s[1]=c,s[2]=d):(c=s[1],d=s[2]),b.useEffect(c,d);let f,u;s[3]!==o||s[4]!==n?(f=()=>{if(!n){a(!1);return}let p=!0,h=null;const g=new EventSource(Vo(n));a(!1);const v=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&a(!1)},o)};return g.onmessage=x=>{if(p)try{const w=JSON.parse(x.data);w.type==="init"?v():w.type==="update"&&(a(!0),v(),l.current())}catch{}},g.onerror=()=>{p&&a(!1)},()=>{p=!1,g.close(),h&&clearTimeout(h)}},u=[n,o],s[3]=o,s[4]=n,s[5]=f,s[6]=u):(f=s[5],u=s[6]),b.useEffect(f,u);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function c9(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return Sx(t,e)}function d9(n,e){const[t,s]=b.useState(null),o=b.useRef(null),i=(()=>{if(!n)return null;let l,c=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(l=d[1],c=d[2]):l=n.replace(".jsonl","");const f=new URLSearchParams({leadSessionId:l});return c&&f.set("subagentFile",c),e&&f.set("dirName",e),f.toString()})();o.current=i;const a=b.useCallback(async()=>{const l=o.current;if(l)try{const c=await ye(`/api/session-team?${l}`);if(!c.ok){s(null);return}const d=await c.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);return b.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),c9((t==null?void 0:t.teamName)??null,a),t}function u9(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),Sx(o,s)}function f9(n,e,t=!0){const[s,o]=b.useState([]),[i,a]=b.useState(!1),l=b.useRef(0),c=!!n&&!!e,d=b.useCallback(async()=>{const m=++l.current;if(!c){o([]);return}try{const p=await ye(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&o([]);return}const h=await p.json();m===l.current&&o(Array.isArray(h)?h:[])}catch{m===l.current&&o([])}finally{m===l.current&&a(!1)}},[c,n,e]);b.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const f=c&&(t||s.length>0),{isLive:u}=u9(f?n:null,f?e:null,null,d);return{workflows:s,loading:i,isLive:u,refetch:d}}const ai={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},m9="cogpit:permissions";function p9(n){if(!n)return!1;const e=n.toLowerCase();return e.includes("issue with the selected model")||e.includes("selected model")&&e.includes("may not exist or you may not have access")||e.includes("run --model to pick a different model")}async function hm(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function Nx(n,{model:e,agentKind:t,errorFallback:s,onModelRejected:o}){const i=c=>typeof s=="function"?s(c):s;let a=await n(e||void 0),l=a.ok?null:await hm(a,i(a));return!a.ok&&t==="codex"&&e&&p9(l)&&(o==null||o(e),a=await n(void 0),l=a.ok?null:await hm(a,i(a))),{res:a,errorMessage:l}}function h9({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:o,model:i,effort:a,fastMode:l,ultracode:c,mcpConfig:d,onCodexModelRejected:f,onCreateSession:u}){const[m,p]=b.useState("idle"),[h,g]=b.useState(),[v,x]=b.useState([]),w=b.useRef(null),y=b.useRef(null),j=b.useRef(!1),N=n!=null&&n.fileName?uw(n.fileName):null,S=e||N,k=n?Jt(n.dirName):null,C=b.useCallback(()=>{var I;(I=w.current)==null||I.abort(),w.current=null,j.current=!1,p("idle"),g(void 0),x([])},[]);b.useEffect(()=>{var I;y.current!==S&&(j.current?(j.current=!1,(I=w.current)==null||I.abort(),w.current=null,p("idle"),g(void 0)):C(),y.current=S)},[S,C]),b.useEffect(()=>()=>{var I;(I=w.current)==null||I.abort()},[]);const T=b.useCallback(async(I,R)=>{if(!S&&u){x($=>[...$,I]),p("connected"),g(void 0),j.current=!0,o==null||o();try{if(!await u(I,R)){j.current=!1,p("idle"),x([]);return}p("idle")}catch($){j.current=!1,g($ instanceof Error?$.message:"Failed to create session"),p("error"),x([])}return}if(!S)return;x($=>[...$,I]),p("connected"),g(void 0);const D=s??ai;o==null||o();const L=new AbortController;w.current=L;try{const $={sessionId:S,message:I,images:R||void 0,cwd:t||void 0,permissions:D,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:z,errorMessage:U}=await Nx(O=>ye("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,model:O}),signal:L.signal}),{model:i,agentKind:k,errorFallback:O=>`Request failed (${O.status})`,onModelRejected:f});w.current===L&&(z.ok?p("idle"):(g(U||`Request failed (${z.status})`),p("error"),x(O=>O.slice(0,-1))))}catch($){if($ instanceof Error&&$.name==="AbortError")return;w.current===L&&(g($ instanceof Error?$.message:"Unknown error"),p("error"),x(z=>z.slice(0,-1)))}},[S,k,t,s,o,i,a,l,c,d,f,u]),_=b.useCallback(()=>{C()},[C]),P=b.useCallback(()=>{S&&ye("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:S})}).catch(()=>{})},[S]),A=b.useCallback(()=>{var I;(I=w.current)==null||I.abort(),w.current=null,P(),p("idle"),x([])},[P]),E=A,M=b.useCallback((I=1)=>{x(R=>R.slice(I))},[]);return{status:m,error:h,pendingMessages:v,sendMessage:T,disconnect:_,interrupt:A,stopAgent:E,consumePending:M,isConnected:m==="connected"}}const Hn={expandAll:!1,expandToolPayloads:!1},g9={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Hn,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function gm(n,e,t,s){const o=P1(e,t,s);return o===n.turns?n:{...n,turns:o}}function $s(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function x9(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...$s(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Hn,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...$s(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Hn,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...$s(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...Hn,currentMemberName:e.memberName,sessionChangeKey:n.sessionChangeKey+1};case"JUMP_TO_TURN":return{...n,activeTurnIndex:e.index,activeToolCallId:e.toolCallId??null};case"SET_SEARCH_QUERY":return n.searchQuery===e.value?n:{...n,searchQuery:e.value};case"SET_EXPAND_ALL":return e.value?n.expandAll&&!n.expandToolPayloads?n:{...n,expandAll:!0,expandToolPayloads:!1}:!n.expandAll&&!n.expandToolPayloads?n:{...n,...Hn};case"SET_EXPAND_TOOL_PAYLOADS":return e.value?n.expandAll&&n.expandToolPayloads?n:{...n,expandAll:!0,expandToolPayloads:!0}:n.expandToolPayloads?{...n,expandToolPayloads:!1}:n;case"TOGGLE_EXPAND_ALL":return n.expandAll?{...n,...Hn}:{...n,expandAll:!0};case"SET_MOBILE_TAB":return n.mobileTab===e.tab?n:{...n,mobileTab:e.tab};case"UPDATE_SESSION":return{...n,windowTurns:e.session.turns,session:gm(e.session,e.session.turns,n.olderTurns,(t=n.sessionSource)==null?void 0:t.agentKind)};case"SET_OLDER_TURNS":return!n.session||e.turns===n.olderTurns?n:{...n,olderTurns:e.turns,session:gm(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...$s(e.session),sessionSource:e.source,sessionChangeKey:n.sessionChangeKey+1};case"SET_CURRENT_MEMBER_NAME":return n.currentMemberName===e.name?n:{...n,currentMemberName:e.name};case"GUARD_MOBILE_TAB":{let o=n.mobileTab;return!e.hasSession&&(o==="stats"||o==="chat")&&(o="sessions"),o!==n.mobileTab?{...n,mobileTab:o}:n}case"SET_LOADING_MEMBER":return n.loadingMember===e.name?n:{...n,loadingMember:e.name};case"SET_DASHBOARD_PROJECT":return n.dashboardProject===e.dirName?n:{...n,dashboardProject:e.dirName};case"INIT_PENDING_SESSION":return{...n,...$s(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Hn,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...$s(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Hn,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"OPEN_CONFIG":return{...n,mainView:"config",configFilePath:e.filePath??null};case"CLOSE_CONFIG":return{...n,mainView:"sessions",configFilePath:null};case"OPEN_MISSION":return{...n,mainView:"mission"};case"CLOSE_MISSION":return{...n,mainView:"sessions"};default:return n}}function kx(){return b.useReducer(x9,g9)}function xm(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function Cx({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialContentLen:i=0}){const a=b.useRef(null),l=b.useRef(null),c=b.useRef(!0),d=b.useRef(!1),f=b.useRef(0),u=b.useMemo(()=>(n==null?void 0:n.turns.flatMap($=>$.contentBlocks.flatMap(z=>z.kind==="queued_prompt"?[{id:JSON.stringify([z.timestamp??"",z.content]),content:z.content}]:[])))??[],[n==null?void 0:n.turns]),m=b.useRef(null),p=b.useRef(!1),[h,g]=b.useState(!1),[v,x]=b.useState(!1),[w,y]=b.useState(null),j=b.useCallback(()=>{requestAnimationFrame(()=>{var $;($=l.current)==null||$.scrollIntoView({behavior:"smooth"})})},[]),N=b.useCallback(()=>{xm(()=>{const $=a.current;$&&($.scrollTop=$.scrollHeight),c.current=!0,d.current=!1})},[]),S=b.useCallback(()=>{p.current=!0},[]),k=b.useRef(!1),C=b.useRef(!1),T=b.useCallback(()=>{const $=a.current;if(!$)return;const z=$.scrollTop>10,U=$.scrollHeight-$.scrollTop-$.clientHeight>10;z!==k.current&&(k.current=z,g(z)),U!==C.current&&(C.current=U,x(U))},[]),_=b.useCallback(()=>{const $=a.current;$&&(c.current=$.scrollHeight-$.scrollTop-$.clientHeight<150,T())},[T]),P=b.useCallback($=>{f.current=$},[]),A=b.useRef(o);b.useEffect(()=>{if(o===A.current)return;A.current=o;const $=p.current;p.current=!1;const z=()=>{const O=a.current;O&&($?(O.scrollTop=0,c.current=!1):(O.scrollTop=O.scrollHeight,c.current=!0),d.current=!1)};xm(z);const U=setTimeout(()=>{z(),y(o)},150);return()=>clearTimeout(U)},[o]);const E=t.length;b.useEffect(()=>{E>0&&(d.current=!0,j())},[E,j]),b.useEffect(()=>{const $=(n==null?void 0:n.sessionId)??null,z=m.current,U=new Set(u.map(B=>B.id));if(!z||z.sessionId!==$){m.current={sessionId:$,ids:U};return}const O=u.filter(B=>!z.ids.has(B.id));if(m.current={sessionId:$,ids:U},O.length===0||E===0)return;let H=0;for(const B of O){const W=t[H];(W===B.content||(W==null?void 0:W.trim())===""&&B.content.length>0)&&H++}H>0&&s(H)},[n==null?void 0:n.sessionId,u,t,E,s]);const M=(n==null?void 0:n.turns.length)??0;b.useEffect(()=>{if(M===0)return;const $=M-f.current;$>0&&(E>0&&s(Math.min($,E)),(d.current||c.current)&&(j(),d.current=!1)),f.current=M},[M,E,s,j]);const I=n==null?void 0:n.turns.at(-1),R=(I==null?void 0:I.toolCalls.length)??0,D=(I==null?void 0:I.assistantText.length)??0;b.useEffect(()=>{if(!(!n||!e)){if(c.current){const $=a.current;$&&($.scrollTop=$.scrollHeight)}requestAnimationFrame(T)}},[M,R,D,i,e,T]);const L=w===o;return b.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:v,initialScrollDone:L,handleScroll:_,scrollToBottomInstant:N,requestScrollToTop:S,resetTurnCount:P}),[h,v,L,_,N,S,P])}async function _x(n,e,t,s){const o=await ye(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`);if(!o.ok)throw new Error(`Failed to load ${s} (${o.status})`);const i=await o.json(),a=new Set(i.headerLines),l=i.tailLines.filter(f=>!a.has(f)),c=[...i.headerLines,...l].join(`
|
|
125
|
+
`);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:Jt(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function ys(n,e,t,s){const o=on.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=nn(),a=Zn(),{parsed:l,source:c,byteOffset:d,hasMore:f}=await _x(n,e,t,s);if(nn()!==i||Zn()!==a)return{parsed:l,source:c};const u=on.get(n,e);return u?{parsed:u.parsed,source:u.source}:(on.set(n,e,l,c.rawText,d,f,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function Tx(n,e,t,s){on.evict(n,e);const o=nn(),i=Zn(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await _x(n,e,t,s);return nn()===o&&Zn()===i&&on.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function v9({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=b.useState(null),f=b.useCallback((x,w)=>{d(null),b.startTransition(()=>{n({type:"LOAD_SESSION",session:x,source:w,isMobile:e})}),i(x.turns.length),hE(x.sessionId,x.turns.length),o()},[n,e,i,o]),u=b.useCallback(async(x,w)=>{l==null||l(),d(null);try{const{parsed:y,source:j}=await ys(x,w,a,"session");f(y,j)}catch(y){d(y instanceof Error?y.message:"Failed to load session")}},[f,a,l]),m=b.useCallback(async x=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:x.name});try{const w=await ye(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(x.name)}`);if(!w.ok)throw new Error(`Failed to find session for ${x.name}`);const{dirName:y,fileName:j}=await w.json(),{parsed:N,source:S}=await ys(y,j,a,`session for ${x.name}`);b.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:N,source:S,memberName:x.name})}),i(N.turns.length),o()}catch(w){d(w instanceof Error?w.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,i,o,a,l]),p=b.useCallback(()=>d(null),[]),h=b.useCallback(()=>{b.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=b.useCallback((x,w)=>{n({type:"JUMP_TO_TURN",index:x,toolCallId:w})},[n]),v=b.useCallback(x=>{x!==t&&b.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:x})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:f,handleDashboardSelect:u,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:v}}const b9=/^\/preview\/([^/]+)\/?$/;function Hc(n){const e=b9.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function Ex(){const n=ut();return n===gt?"":`/d/${n}`}function kl(){const n=Ex();return n?`${n}/`:"/"}function Px(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function y9(n){return n.replace(/\.jsonl$/,"")}function w9(n){return n.endsWith(".jsonl")?n:`${n}.jsonl`}function j9(n){const e=Ex();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=y9(s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:kl()}function vm(n){const e=Px(n),t=Hc(e);if(t)return{type:"preview",sessionId:t};if(e.startsWith("/team/"))return{type:"home",normalizeHome:!0};const s=e.split("/").filter(Boolean);return s.length>=2?{type:"session",dirName:decodeURIComponent(s[0]),sessionId:decodeURIComponent(s[1])}:s.length===1?{type:"project",dirName:decodeURIComponent(s[0])}:{type:"home"}}function S9({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=b.useState(null),c=b.useRef(0),d=b.useRef(window.location.pathname),f=b.useRef(!1),u=b.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await ye(`/api/find-session/${encodeURIComponent(m.sessionId)}`);if(!p.ok)throw new Error(p.status===404?`Session ${m.sessionId} was not found.`:`Failed to resolve session (${p.status}).`);const h=await p.json();if(!h.dirName||!h.fileName)throw new Error("Cogpit returned an invalid session location.");const g=await ys(h.dirName,h.fileName,i,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),o()}catch(p){e({type:"GO_HOME",isMobile:t}),l(p instanceof Error?p.message:"Failed to load session preview.")}}else if(m.type==="session"&&m.dirName&&m.sessionId){l(null);const p=w9(m.sessionId);let h;try{h=await ys(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=kl();window.history.replaceState(null,"",g),d.current=g,so(ut(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),o()}else if(m.type==="project"&&m.dirName)l(null),e({type:"SET_DASHBOARD_PROJECT",dirName:m.dirName});else if(l(null),e({type:"GO_HOME",isMobile:t}),m.normalizeHome){const p=kl();window.history.replaceState(null,"",p),d.current=p,so(ut(),p)}}finally{c.current--}},[e,t,s,o,i]);return b.useEffect(()=>{if(f.current)return;f.current=!0,so(ut(),window.location.pathname);const m=vm(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&u(m)},[u]),b.useEffect(()=>{if(c.current>0||Hc(Px(window.location.pathname)))return;const m=j9(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,so(ut(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),b.useEffect(()=>{const m=()=>{const p=vm(window.location.pathname);d.current=window.location.pathname,so(ut(),window.location.pathname),u(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[u]),{previewLoadError:a}}const N9=400;function bm(){return Array.from(document.querySelectorAll("[data-live-session]"))}function k9(n){let e=n.parentElement;for(;e;){const{overflowY:t}=getComputedStyle(e);if(t==="auto"||t==="scroll")return e;e=e.parentElement}return null}function ym(n){n.focus({preventScroll:!0});const e=k9(n);if(e){const t=e.getBoundingClientRect(),s=n.getBoundingClientRect();s.top<t.top?e.scrollTop-=t.top-s.top+8:s.bottom>t.bottom&&(e.scrollTop+=s.bottom-t.bottom+8)}}function C9(n){const e=F.c(20),{isMobile:t,searchInputRef:s,chatInputRef:o,dispatch:i,onToggleSidebar:a,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:d,onOpenProjectSwitcher:f,onOpenThemeSelector:u,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:v,onHistoryForward:x,onNavigateToSession:w,onCommitNavigation:y}=n;let j,N;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==y||e[4]!==v||e[5]!==x||e[6]!==w||e[7]!==d||e[8]!==f||e[9]!==m||e[10]!==u||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==a||e[17]!==s?(j=()=>{if(t)return;let S=!1,k=!1,C=null;const T=function(E){var D,L;const M=Yf("missionControl");if(M){if(E.key===M){E.repeat||(S=!0,k=E.shiftKey||E.altKey||(M==="Meta"?E.ctrlKey:E.metaKey));return}S&&(k=!0),C=null}if(ht("commandPalette",E)){E.preventDefault(),d==null||d();return}if(ht("integratedTerminal",E)){if(!at("terminal"))return;E.preventDefault(),p();return}if(ht("preview",E)){E.preventDefault(),h();return}if(ht("projectFiles",E)){if(!at("hostFiles"))return;E.preventDefault(),g();return}if(ht("expandAll",E)){E.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(ht("expandToolPayloads",E)){E.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(ht("toggleSidebar",E)){E.preventDefault(),a();return}if(ht("toggleStats",E)){E.preventDefault(),l();return}if(ht("missionControl",E)){E.preventDefault(),c();return}if(ht("newSession",E)&&(E.preventDefault(),f()),ht("themeSelector",E)&&(E.preventDefault(),u()),ht("systemTerminal",E)){if(!at("terminal"))return;E.preventDefault(),m()}if(E.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(D=s.current)==null||D.blur()),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.code.startsWith("Digit")){const $=parseInt(E.code.charAt(5),10);if($>=1&&$<=9){E.preventDefault();const U=bm()[$-1];U&&(ym(U),U.click())}}const I=ht("recentSessionForward",E);if(I||ht("recentSessionBack",E)){E.preventDefault();const $=I?x():v();$&&w($.dirName,$.fileName)}ht("focusComposer",E)&&!I1(document.activeElement)&&(E.preventDefault(),(L=o.current)==null||L.focus());const R=ht("nextLiveSession",E);if(R||ht("prevLiveSession",E)){E.preventDefault();const $=bm();if($.length===0)return;const z=$.findIndex(_9);let U;z===-1?U=R?0:$.length-1:U=Math.max(0,Math.min($.length-1,z+(R?1:-1))),ym($[U])}},_=function(E){const M=Yf("missionControl");if(M&&E.key===M&&S){const I=!k;if(S=!1,k=!1,I){const R=Date.now();C!==null&&R-C<=N9?(C=null,E.preventDefault(),c()):C=R}else C=null}E.key==="Control"&&(y==null||y())},P=function(){S=!1,k=!1,C=null};return window.addEventListener("keydown",T),window.addEventListener("keyup",_),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",T),window.removeEventListener("keyup",_),window.removeEventListener("blur",P)}},N=[t,s,o,i,a,l,c,d,f,u,m,p,h,g,v,x,w,y],e[0]=o,e[1]=i,e[2]=t,e[3]=y,e[4]=v,e[5]=x,e[6]=w,e[7]=d,e[8]=f,e[9]=m,e[10]=u,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=a,e[17]=s,e[18]=j,e[19]=N):(j=e[18],N=e[19]),b.useEffect(j,N)}function _9(n){return n===document.activeElement}const wm="cogpit-theme",LA=[{id:"dark",name:"Default Dark",swatches:["oklch(0.105 0 0)","oklch(0.13 0 0)","oklch(0.16 0 0)","oklch(0.2 0 0)","oklch(0.24 0 0)"]},{id:"oled",name:"Deep OLED",swatches:["oklch(0 0 0)","oklch(0.08 0 0)","oklch(0.10 0 0)","oklch(0.10 0 0)","oklch(0.18 0 0)"]},{id:"light",name:"Light",swatches:["oklch(1 0 0)","oklch(1 0 0)","oklch(1 0 0)","oklch(0.96 0 0)","oklch(0.922 0 0)"]}];function T9(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function Ax(){const[n,e]=b.useState(()=>{try{const l=localStorage.getItem(wm);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=b.useState(null),o=b.useCallback(l=>{localStorage.setItem(wm,l),e(l),s(null)},[]),i=t??n,a=T9(i);return b.useEffect(()=>{const l=document.documentElement.classList;l.remove("dark","theme-oled"),i==="dark"?l.add("dark"):i==="oled"&&l.add("dark","theme-oled")},[i]),{theme:n,activeTheme:i,themeClasses:a,setTheme:o,setPreview:s}}const E9="cogpit-session-history",Cl=50;function Mx(){return Mt(E9)}function P9(){try{const n=localStorage.getItem(Mx());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,Cl)}catch{}return[]}function jm(n){try{localStorage.setItem(Mx(),JSON.stringify(n))}catch{}}function A9(){const n=F.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=P9(),n[0]=e):e=n[0];const t=b.useRef(e),s=b.useRef(0),o=b.useRef(!1);let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=(h,g)=>{if(o.current){o.current=!1;return}const v=`${h}/${g}`;t.current=t.current.filter(x=>`${x.dirName}/${x.fileName}`!==v),t.current.unshift({dirName:h,fileName:g}),t.current.length>Cl&&(t.current.length=Cl),s.current=0,jm(t.current)},n[1]=i):i=n[1];const a=i;let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{if(t.current.length<=1)return null;const h=(s.current+1)%t.current.length;return s.current=h,o.current=!0,t.current[h]},n[2]=l):l=n[2];const c=l;let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{if(t.current.length<=1)return null;const h=(s.current-1+t.current.length)%t.current.length;return s.current=h,o.current=!0,t.current[h]},n[3]=d):d=n[3];const f=d;let u;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(s.current===0){o.current=!1;return}const h=t.current[s.current];h&&(t.current.splice(s.current,1),t.current.unshift(h),jm(t.current)),s.current=0,o.current=!1},n[4]=u):u=n[4];const m=u;let p;return n[5]===Symbol.for("react.memo_cache_sentinel")?(p={push:a,goBack:c,goForward:f,commitNavigation:m},n[5]=p):p=n[5],p}function Rx(){return Mt(m9)}function Sm(){try{const n=localStorage.getItem(Rx());if(n){const e=JSON.parse(n);return{mode:e.mode||ai.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return ai}function M9(n){localStorage.setItem(Rx(),JSON.stringify(n))}function R9(){const n=F.c(21),[e,t]=b.useState(Sm),[s,o]=b.useState(Sm),i=b.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}M9(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),b.useEffect(a,l);let c;n[3]!==s.allowedTools||n[4]!==s.disallowedTools||n[5]!==s.mode||n[6]!==e.allowedTools||n[7]!==e.disallowedTools||n[8]!==e.mode?(c=e.mode!==s.mode||JSON.stringify(e.allowedTools)!==JSON.stringify(s.allowedTools)||JSON.stringify(e.disallowedTools)!==JSON.stringify(s.disallowedTools),n[3]=s.allowedTools,n[4]=s.disallowedTools,n[5]=s.mode,n[6]=e.allowedTools,n[7]=e.disallowedTools,n[8]=e.mode,n[9]=c):c=n[9];const d=c;let f;n[10]===Symbol.for("react.memo_cache_sentinel")?(f=N=>{t(S=>({...S,mode:N}))},n[10]=f):f=n[10];const u=f;let m;n[11]===Symbol.for("react.memo_cache_sentinel")?(m=N=>{t(S=>{const k=S.allowedTools.includes(N);return{...S,allowedTools:k?S.allowedTools.filter(C=>C!==N):[...S.allowedTools,N]}})},n[11]=m):m=n[11];const p=m;let h;n[12]===Symbol.for("react.memo_cache_sentinel")?(h=N=>{t(S=>{const k=S.disallowedTools.includes(N);return{...S,disallowedTools:k?S.disallowedTools.filter(C=>C!==N):[...S.disallowedTools,N]}})},n[12]=h):h=n[12];const g=h;let v;n[13]!==e?(v=()=>{o(e)},n[13]=e,n[14]=v):v=n[14];const x=v;let w;n[15]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{t(ai)},n[15]=w):w=n[15];const y=w;let j;return n[16]!==s||n[17]!==e||n[18]!==d||n[19]!==x?(j={config:e,appliedConfig:s,hasPendingChanges:d,setMode:u,toggleAllowedTool:p,toggleDisallowedTool:g,markApplied:x,resetToDefault:y},n[16]=s,n[17]=e,n[18]=d,n[19]=x,n[20]=j):j=n[20],j}const I9=2e3;function $9(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function O9(n,e){const[t,s]=b.useState([]),[o,i]=b.useState(new Set);b.useEffect(()=>{if(!n){s([]);return}let c=!1;const d=async()=>{if(!c)try{const p=await ye(`/api/permissions/${encodeURIComponent(n)}`);if(c)return;if(p.ok){const h=await p.json();s(g=>$9(g,h.permissions)?g:h.permissions)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&d()},u=()=>{document.visibilityState==="visible"&&d()};f();const m=setInterval(f,I9);return document.addEventListener("visibilitychange",u),()=>{c=!0,clearInterval(m),document.removeEventListener("visibilitychange",u)}},[n]);const a=b.useCallback(async(c,d)=>{if(n){i(f=>new Set(f).add(c));try{await fx(n,c,d)&&s(f=>f.filter(u=>u.requestId!==c))}finally{i(f=>{const u=new Set(f);return u.delete(c),u})}}},[n]),l=b.useCallback(async c=>{if(n)try{await sE(n,c)&&s([])}catch{}},[n]);return{requests:t,responding:o,respond:a,respondAll:l}}function D9(n){return n.file_path??n.path??""}function Ix(n){const e=[];for(const t of n.toolCalls){if(t.isError||zC(t))continue;const s=D9(t.input);if(s){if(t.name==="Edit"){const o=t.input.old_string,i=t.input.new_string;o!==void 0&&i!==void 0&&e.push({type:"Edit",filePath:s,oldString:o,newString:i,replaceAll:t.input.replace_all??!1})}else if(t.name==="Write"){const o=t.input.content;o!==void 0&&e.push({type:"Write",filePath:s,content:o})}}}return e}function L9(n,e){return{index:e,userMessage:Li(n.userMessage),toolCalls:Ix(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function li(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=Ix(i);for(let l=a.length-1;l>=0;l--){const c=a[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:o}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:o}))}}return s}function z9(n,e){const t=[];for(const s of n)s.type==="Edit"?t.push({type:"apply-edit",filePath:s.filePath,oldString:s.oldString,newString:s.newString,replaceAll:s.replaceAll,turnIndex:e}):s.type==="Write"&&t.push({type:"create-write",filePath:s.filePath,content:s.content,turnIndex:e});return t}function No(n,e){const t=[],s=e!==void 0?e+1:n.length;for(let o=0;o<s;o++){const i=n[o];i&&t.push(...z9(i.toolCalls,i.index))}return t}function $x(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(L9(d,c))}const i=((l=o[0])==null?void 0:l.userMessage)||"Untitled branch",a=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,label:a,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}function Ox(n,e){const t=[],s=[];for(const o of n)o.branchPointTurnIndex>e?s.push(o):t.push(o);return{retained:t,scooped:s}}function Dx(n,e,t){const s=e+t,o=[],i=[];for(const a of n)a.branchPointTurnIndex<=s?o.push(a):i.push(a);return{restored:o,remaining:i}}function F9(n){const e=new Set,t=new Set;for(const s of n)e.add(s.filePath),t.add(s.turnIndex);return{turnCount:t.size,fileCount:e.size,filePaths:[...e],operationCount:n.length}}function B9(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function $r(n,e){return n.length>0?F9(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function U9(n){var t;if(n.type!=="user"||n.isMeta)return!1;const e=(t=n.message)==null?void 0:t.content;return!(Array.isArray(e)&&e.some(s=>s.type==="tool_result"))}function W9(n){return n.type==="event_msg"&&typeof n.payload=="object"&&n.payload!==null&&n.payload.type==="user_message"&&typeof n.payload.message=="string"}function ci(n,e){let t=0,s=null;for(let o=0;o<n.length;o++)try{const i=JSON.parse(n[o]);if(i.type==="turn_context"){s=o;continue}if(U9(i)){if(t++,t>e)return o;continue}if(W9(i)){if(t++,t>e)return s??o;s=null}}catch{}return n.length}class xo extends Error{constructor(){super("abort")}}async function H9(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=li(e.turns,e.turns.length-1,l),d=l+1,f=o.split(`
|
|
126
|
+
`).filter(Boolean),u=ci(f,d),m=f.slice(u);if(m.length===0)throw a("Unable to locate the selected turn in the current session file"),new xo;const{retained:p,scooped:h}=Ox(s.branches,l),g=$x(e.turns,l,m,h),v={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},x=e.agentKind==="claude"?(w=e.turns[l+1])==null?void 0:w.id:void 0;await i({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:u,expectedLineCount:f.length},state:v,...x?{checkpoint:{sessionId:e.sessionId,userMessageId:x,cwd:e.cwd}}:{}})}async function K9(n,e,t,s,o,i){var x;const a=n.redoUpToArchiveIndex!==void 0&&n.redoUpToArchiveIndex<s.turns.length-1,l=n.redoUpToArchiveIndex??s.turns.length-1,c=l+1,d=No(s.turns,l),f=a?ci(s.jsonlLines,c):s.jsonlLines.length,u=s.jsonlLines.slice(0,f),m=s.jsonlLines.slice(f),p=s.childBranches??[];let h;if(a&&m.length>0){const{restored:w,remaining:y}=Dx(p,s.branchPointTurnIndex,c),j={...s,branchPointTurnIndex:s.branchPointTurnIndex+c,turns:s.turns.slice(c),jsonlLines:m,label:((x=s.turns[c])==null?void 0:x.userMessage)||s.label,childBranches:y.length>0?y:void 0};h=[...t.branches.map(N=>N.id===s.id?j:N),...w]}else h=[...t.branches.filter(w=>w.id!==s.id),...p];const g={...t,currentTurnIndex:t.currentTurnIndex+c,totalTurns:t.totalTurns+c,branches:h,activeBranchId:null},v=o.split(`
|
|
127
|
+
`).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:u,expectedLineCount:v.length},state:g})}async function V9(n,e,t,s,o,i,a){var j;let l=[...t.branches],c=o.split(`
|
|
128
|
+
`).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const N=li(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...N);const{retained:S,scooped:k}=Ox(l,s.branchPointTurnIndex);l=S;const C=s.branchPointTurnIndex+1,T=ci(c,C),_=c.slice(T);if(_.length>0){const P=$x(n.turns,s.branchPointTurnIndex,_,k);l=[...l,P],c=c.slice(0,T)}}const f=i.branchTurnIndex??s.turns.length-1,u=f+1,m=f<s.turns.length-1,p=No(s.turns,f);d.push(...p);const h=m?ci(s.jsonlLines,u):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),v=s.jsonlLines.slice(h),x=s.childBranches??[];let w;if(m&&v.length>0){const{restored:N,remaining:S}=Dx(x,s.branchPointTurnIndex,u);w=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+u,turns:s.turns.slice(u),jsonlLines:v,label:((j=s.turns[u])==null?void 0:j.userMessage)||s.label,childBranches:S.length>0?S:void 0},...N]}else w=x;const y={...t,currentTurnIndex:s.branchPointTurnIndex+u,totalTurns:s.branchPointTurnIndex+1+u,branches:[...l.filter(N=>N.id!==s.id),...w],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
|
|
129
|
+
`).filter(Boolean).length},state:y})}const q9=[];function Lx(n,e,t,s=!0){const[o,i]=b.useState(null),[a,l]=b.useState(null),[c,d]=b.useState(!1),[f,u]=b.useState(null),m=b.useRef(null);b.useEffect(()=>{if(!s||!n){i(null),l(null),u(null),m.current=null;return}if(n.sessionId===m.current)return;m.current=n.sessionId;const _=n.sessionId,P=new AbortController;return ye(`/api/undo-state/${encodeURIComponent(_)}`,{signal:P.signal}).then(A=>A.ok?A.json():null).then(A=>{m.current===_&&i(A??null)}).catch(A=>{A instanceof Error&&A.name==="AbortError"||m.current===_&&i(null)}),()=>P.abort()},[s,n==null?void 0:n.sessionId]);const p=b.useCallback(async _=>{try{const P=await ye("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:_.operations,session:{dirName:_.sessionSource.dirName,fileName:_.sessionSource.fileName,mutation:_.sessionMutation},state:_.state,checkpoint:_.checkpoint})}),A=await P.json().catch(()=>null);if(!P.ok)throw u((A==null?void 0:A.error)||"Undo transaction failed"),new xo;i(_.state)}catch(P){throw P instanceof xo?P:(u(String(P)),new xo)}},[]),h=(o==null?void 0:o.branches)??q9,{canRedo:g,redoTurnCount:v,redoBranch:x}=b.useMemo(()=>{if(!n||h.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let _=h.length-1;_>=0;_--){const P=h[_];if(P.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:P.turns.length,redoBranch:P}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,h]),w=b.useMemo(()=>{if(!x||x.jsonlLines.length===0)return[];try{return Di(x.jsonlLines.join(`
|
|
130
|
+
`)).turns}catch{return[]}},[x]),y=b.useCallback(_=>h.filter(P=>P.branchPointTurnIndex===_),[h]),j=b.useCallback(_=>{if(!s||!n)return;const P=_-1;if(P>=n.turns.length-1||P<-1)return;const A=li(n.turns,n.turns.length-1,P);l({type:"undo",summary:$r(A,n.turns.length-1-P),targetTurnIndex:P})},[s,n]),N=b.useCallback(()=>{if(!s||!g||!x||!n)return;const _=No(x.turns);l({type:"redo",summary:$r(_,x.turns.length),targetTurnIndex:x.branchPointTurnIndex+x.turns.length,branchId:x.id})},[s,g,x,n]),S=b.useCallback(_=>{if(!s||!g||!x||!n)return;const P=_+1,A=No(x.turns,_);l({type:"redo",summary:$r(A,P),targetTurnIndex:x.branchPointTurnIndex+P,branchId:x.id,redoUpToArchiveIndex:_})},[s,g,x,n]),k=b.useCallback((_,P)=>{if(!s||!n)return;const A=h.find(R=>R.id===_);if(!A)return;const E=P??A.turns.length-1,M=n.turns.length>A.branchPointTurnIndex+1?li(n.turns,n.turns.length-1,A.branchPointTurnIndex):[],I=No(A.turns,E);l({type:"branch-switch",summary:$r([...M,...I],E+1),targetTurnIndex:A.branchPointTurnIndex,branchId:_,branchTurnIndex:E})},[s,n,h]),C=b.useCallback(async()=>{if(!s||!a||!n||!e){l(null);return}d(!0),u(null);try{const _=o??B9(n.sessionId,n.turns.length),P=await ye(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!P.ok){u("Failed to read session file");return}const A=await P.text();if(a.type==="undo")await H9(a,n,e,_,A,p,u);else if(a.type==="redo"){const E=h.find(M=>M.id===a.branchId);if(!E){l(null);return}await K9(a,e,_,E,A,p)}else if(a.type==="branch-switch"){const E=h.find(M=>M.id===a.branchId);if(!E){l(null);return}await V9(n,e,_,E,A,a,p)}try{await ye("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(_){if(!(_ instanceof xo))throw _}finally{d(!1)}},[s,a,n,e,o,h,p,t]),T=b.useCallback(()=>{l(null),u(null)},[]);return{enabled:s,undoState:o,canRedo:g,redoTurnCount:v,redoGhostTurns:w,branches:h,branchesAtTurn:y,requestUndo:j,requestRedoAll:N,requestRedoUpTo:S,requestBranchSwitch:k,confirmState:a,confirmApply:C,confirmCancel:T,isApplying:c,applyError:f}}async function G9(n){try{const t=await(await Kn("/api/network-info",{signal:n})).json();return{url:t.enabled&&t.url?t.url:null,disabled:!t.enabled}}catch{return{url:null,disabled:!1}}}async function Nm(n){const e=await ye("/api/config",{signal:n});if(!e.ok)throw new Error(`Config request failed (${e.status})`);const t=await e.json();return{claudeDir:(t==null?void 0:t.claudeDir)??null,defaultAgentKind:(t==null?void 0:t.mode)==="codex"?"codex":"claude",useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function Y9(){const n=F.c(26),[e,t]=b.useState(!0),[s,o]=b.useState(null),[i,a]=b.useState(null),[l,c]=b.useState("claude"),[d,f]=b.useState(!1),[u,m]=b.useState(null),[p,h]=b.useState(!1),[g,v]=b.useState(0),x=b.useRef(null),w=b.useRef(null);let y;n[0]===Symbol.for("react.memo_cache_sentinel")?(y=B=>{a(B.claudeDir),c(B.defaultAgentKind),Oj(B.useBuiltInEditor)},n[0]=y):y=n[0];const j=y;let N;n[1]===Symbol.for("react.memo_cache_sentinel")?(N=async()=>{var V;(V=x.current)==null||V.abort();const B=new AbortController;x.current=B;const W=await G9(B.signal);B.signal.aborted||x.current!==B||(m(W.url),h(W.disabled))},n[1]=N):N=n[1];const S=N;let k,C;n[2]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>{var B,W;(B=x.current)==null||B.abort(),(W=w.current)==null||W.abort()},C=[],n[2]=k,n[3]=C):(k=n[2],C=n[3]),b.useEffect(k,C);let T;n[4]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const B=new AbortController;return t(!0),o(null),Nm(B.signal).then(j).catch(W=>{W instanceof Error&&W.name==="AbortError"||(a(null),o(W instanceof Error?W.message:"Failed to load configuration"))}).finally(()=>{B.signal.aborted||t(!1)}),()=>B.abort()},n[4]=T):T=n[4];let _;n[5]!==g?(_=[j,g],n[5]=g,n[6]=_):_=n[6],b.useEffect(T,_);let P,A;n[7]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const B=()=>v(J9);return window.addEventListener("cogpit-auth-changed",B),()=>window.removeEventListener("cogpit-auth-changed",B)},A=[],n[7]=P,n[8]=A):(P=n[7],A=n[8]),b.useEffect(P,A);let E;n[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{S()},n[9]=E):E=n[9];let M;n[10]!==i?(M=[i,S],n[10]=i,n[11]=M):M=n[11],b.useEffect(E,M);let I;n[12]===Symbol.for("react.memo_cache_sentinel")?(I=()=>f(!1),n[12]=I):I=n[12];const R=I;let D;n[13]!==i?(D=B=>{if(f(!1),B!==i){a(B),window.location.reload();return}v(X9),S()},n[13]=i,n[14]=D):D=n[14];const L=D;let $;n[15]===Symbol.for("react.memo_cache_sentinel")?($=()=>f(!0),n[15]=$):$=n[15];const z=$;let U;n[16]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{var W;(W=w.current)==null||W.abort();const B=new AbortController;w.current=B,t(!0),o(null),Nm(B.signal).then(V=>{B.signal.aborted||w.current!==B||j(V)}).catch(V=>{B.signal.aborted||w.current!==B||(a(null),o(V instanceof Error?V.message:"Failed to load configuration"))}).finally(()=>{B.signal.aborted||w.current!==B||t(!1)})},n[16]=U):U=n[16];const O=U;let H;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==L||n[22]!==p||n[23]!==u||n[24]!==d?(H={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:z,handleCloseConfigDialog:R,handleConfigSaved:L,retryConfig:O,networkUrl:u,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=L,n[22]=p,n[23]=u,n[24]=d,n[25]=H):H=n[25],H}function X9(n){return n+1}function J9(n){return n+1}const km={authenticated:!0,edition:"personal",user:null,capabilities:Mi},Qt={authenticated:!1,edition:"personal",user:null,capabilities:Jo},zx=Object.keys(Mi);function Cm(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&zx.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function Z9(n,e){const t={...Jo};for(const s of zx)t[s]=n[s]&&e[s];return t}async function _m(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function Q9(n){try{const e=await ye("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function uo(n){var e;return zs(n),gp(((e=n.user)==null?void 0:e.id)??null),n}function eP(n){const e=F.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...Qt,checked:!1},e[0]=t):t=e[0];const[s,o]=b.useState(t),[i,a]=b.useState(0),l=b.useRef(null),c=b.useRef(!1);let d;e[1]!==n?(d=()=>{var y;if((y=l.current)==null||y.abort(),n===null){c.current=!1,zs(Qt),o({...Qt,checked:!1});return}const p=c.current;c.current=!1,zs(Qt),o(j=>p?{...j,capabilities:Jo,checked:!1}:{...Qt,checked:!1});const h=new AbortController;l.current=h;const g=vs(),v=_m(Kn,h.signal),x=g?Q9(h.signal):Promise.resolve(n),w=g?_m(ye,h.signal):Promise.resolve(null);return Promise.all([v,x,w]).then(j=>{const[N,S,k]=j;if(h.signal.aborted)return;const C=Cm(N,n)?N:n==="personal"?km:null;if(!C||S===null){o({...uo(Qt),checked:!1});return}if(!g){o({...uo(C),checked:!0});return}const T=Cm(k,S)?k:S==="personal"?km:null;if(!T){o({...uo(Qt),checked:!1});return}o({...uo({authenticated:C.authenticated,edition:C.edition,user:C.user,capabilities:Z9(C.capabilities,T.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...uo(Qt),checked:!1})}),()=>{h.abort(),l.current===h&&(l.current=null)}},e[1]=n,e[2]=d):d=e[2];let f;e[3]!==n||e[4]!==i?(f=[n,i],e[3]=n,e[4]=i,e[5]=f):f=e[5],b.useEffect(d,f);let u,m;return e[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=()=>{var g;(g=l.current)==null||g.abort(),c.current=!1,zs(Qt),gp(null),o({...Qt,checked:!1}),a(sP)},h=g=>{var w,y;const v=ut();if(v===gt)return;const x=(w=g.detail)==null?void 0:w.deviceId;x&&x!==v||((y=l.current)==null||y.abort(),c.current=!0,zs(Qt),o(nP),a(tP))};return window.addEventListener("cogpit-auth-changed",p),window.addEventListener("cogpit-devices-changed",h),()=>{window.removeEventListener("cogpit-auth-changed",p),window.removeEventListener("cogpit-devices-changed",h)}},m=[],e[6]=u,e[7]=m):(u=e[6],m=e[7]),b.useEffect(u,m),s}function tP(n){return n+1}function nP(n){return{...n,capabilities:Jo,checked:!1}}function sP(n){return n+1}const oP=3e4;function rP(n){const[e,t]=b.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=b.useRef(0),o=b.useCallback(async()=>{if(!n)return;const a=++s.current;t(l=>l.dirName===n&&l.loading?l:{dirName:n,worktrees:l.dirName===n?l.worktrees:[],loading:!0,error:l.dirName===n?l.error:null});try{const l=await ye(`/api/worktrees/${encodeURIComponent(n)}`);if(a!==s.current)return;if(l.ok){const c=await l.json();if(a!==s.current)return;t({dirName:n,worktrees:c,loading:!1,error:null});return}t(c=>c.dirName===n?{...c,loading:!1,error:"Failed to fetch worktrees"}:c)}catch(l){if(a!==s.current)return;t(c=>c.dirName===n?{...c,loading:!1,error:l instanceof Error?l.message:"Unknown error"}:c)}},[n]);b.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),oP);return()=>{clearInterval(a),s.current+=1}},[n,o]);const i=e.dirName===n?e:{worktrees:[],loading:n!==null,error:null};return{worktrees:i.worktrees,loading:i.loading,error:i.error,refetch:o}}function iP(){const n=F.c(3),[e,t]=b.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await ye("/api/kill-all",{method:"POST"})}catch{}setTimeout(()=>t(!1),1500)},n[0]=s):s=n[0];const o=s;let i;return n[1]!==e?(i={killing:e,handleKillAll:o},n[1]=e,n[2]=i):i=n[2],i}function aP(n,e){return n?`${n}.jsonl`:e??null}async function Fx(n){try{const e=await ye(`/api/session-config/${encodeURIComponent(n)}`);if(!e.ok)return null;const t=await e.json();return t&&typeof t=="object"?t:null}catch{return null}}const lP=300,Va=new Map;function _l(n,e){const t=Mt(n),s=Va.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{Va.delete(t),Mt(n)===t&&(async()=>{try{await ye(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},lP);Va.set(t,{patch:o,timer:i})}function Tl(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function Tm(n){const e=await Fx(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function Em(n,e){_l(n,{mcpServers:e})}async function cP(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function Pm(n,e){try{const t=await ye(n,{signal:e});if(e.aborted)return null;const s=await cP(t);return e.aborted?null:s}catch{return null}}async function Am(n,e,t){const s=Tl(t);if(s.size===0)return[];if(n){const o=await Tm(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await Tm(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function dP(n,e,t,s=!0){const[o,i]=b.useState([]),[a,l]=b.useState({}),[c,d]=b.useState([]),[f,u]=b.useState(!1),[m,p]=b.useState(!1),h=b.useRef(null),g=b.useRef(e);g.current=e;const v=t??e??null,x=b.useRef(v);x.current=v;const w=b.useRef(void 0);b.useEffect(()=>{var k,C;if(!s||!n){(k=h.current)==null||k.abort(),w.current=void 0,i([]),l({}),d([]),u(!1),p(!1);return}const S=new AbortController;return(C=h.current)==null||C.abort(),i([]),l({}),d([]),u(!0),p(!1),w.current=n,Pm(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,S.signal).then(async T=>{if(S.signal.aborted||w.current!==n||!T)return;i(T.servers),l(T.configs);const _=await Am(x.current,g.current,T.servers);S.signal.aborted||w.current!==n||d(_)}).finally(()=>{S.signal.aborted||w.current!==n||(u(!1),p(!0))}),()=>S.abort()},[n,s]),b.useEffect(()=>()=>{var S;return(S=h.current)==null?void 0:S.abort()},[]),b.useEffect(()=>{if(o.length===0||!v)return;let S=!1;return Am(v,e,o).then(k=>{S||x.current!==v||d(k)}),()=>{S=!0}},[v]);const y=b.useCallback(S=>{d(k=>{const C=k.includes(S)?k.filter(T=>T!==S):[...k,S];return x.current&&Em(x.current,C),C})},[]),j=b.useCallback(()=>{var k;if(!s||!n)return;(k=h.current)==null||k.abort();const S=new AbortController;h.current=S,u(!0),Pm(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,S.signal).then(C=>{if(S.signal.aborted||w.current!==n||!C)return;i(C.servers),l(C.configs);const T=Tl(C.servers);d(_=>{const P=_.filter(A=>T.has(A));return x.current&&Em(x.current,P),P})}).finally(()=>{S.signal.aborted||h.current!==S||u(!1)})},[n,s]),N=b.useMemo(()=>{if(o.length===0)return null;const S=Tl(o);if(c.length===S.size&&S.size>0&&c.every(T=>S.has(T))||!c.every(T=>a[T]))return null;const C=Object.fromEntries(c.map(T=>[T,a[T]]));return JSON.stringify({mcpServers:C})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:N,loading:f,loaded:m,toggleServer:y,refresh:j}}function uP(n){var s,o;const e=F.c(12);let t;e:{if(!n){t=null;break e}let i=null,a;if(e[0]!==i||e[1]!==n.turns){const p=new Map;let h=0;for(const g of n.turns)for(const v of g.toolCalls){if(v.name==="TodoWrite"){const x=v.input;Array.isArray(x.todos)&&(i=x.todos);continue}if(v.name==="TaskCreate"){const x=v.input;h=h+1;const y=((o=(s=v.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:o[1])??String(h);p.set(y,{id:y,content:x.subject||x.description||`Task ${y}`,activeForm:x.activeForm||x.subject||`Working on task ${y}`,status:"pending",owner:x.owner});continue}if(v.name==="TaskUpdate"){const x=v.input,w=String(x.taskId??"");if(!w)continue;if(x.status==="deleted"){p.delete(w);continue}const y=p.get(w)??{id:w,content:x.subject||x.description||`Task ${w}`,activeForm:x.activeForm||x.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...y,content:x.subject||x.description||y.content,activeForm:x.activeForm||y.activeForm,status:x.status||y.status,owner:x.owner??y.owner,blockedBy:x.addBlockedBy?[...new Set([...y.blockedBy??[],...x.addBlockedBy])]:y.blockedBy})}}a=p.size>0?[...p.values()]:i,e[0]=i,e[1]=n.turns,e[2]=a,e[3]=i}else a=e[2],i=e[3];const l=a;if(!l||l.length===0){t=null;break e}let c;e[4]!==l?(c=l.filter(mP),e[4]=l,e[5]=c):c=e[5];const d=c.length;let f;e[6]!==l?(f=l.find(fP)??null,e[6]=l,e[7]=f):f=e[7];const u=f;let m;e[8]!==d||e[9]!==u||e[10]!==l?(m={todos:l,completed:d,total:l.length,inProgress:u},e[8]=d,e[9]=u,e[10]=l,e[11]=m):m=e[11],t=m}return t}function fP(n){return n.status==="in_progress"}function mP(n){return n.status==="completed"}function pP(n){const e=F.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,o]=b.useState(t);let i,a;return e[1]!==n?(i=()=>{if(!n){o([]);return}let l=!1;const c=async function(){try{const u=await ye(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(l)return;if(u.ok){const m=await u.json();o(m)}}catch{}};c();const d=setInterval(c,5e3);return()=>{l=!0,clearInterval(d)}},a=[n],e[1]=n,e[2]=i,e[3]=a):(i=e[2],a=e[3]),b.useEffect(i,a),s}function hP(n,e){const t=F.c(8),s=e===void 0?!0:e;let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];const[i,a]=b.useState(o),[l,c]=b.useState(!1),d=b.useRef(void 0);let f,u;t[1]!==n||t[2]!==s?(f=()=>{if(!s){d.current=void 0,a([]),c(!1);return}if(d.current===n)return;d.current=n,c(!0);const p=n?`?cwd=${encodeURIComponent(n)}`:"";ye(`/api/slash-suggestions${p}`).then(gP).then(h=>a(h.suggestions||[])).catch(()=>a([])).finally(()=>c(!1))},u=[n,s],t[1]=n,t[2]=s,t[3]=f,t[4]=u):(f=t[3],u=t[4]),b.useEffect(f,u);let m;return t[5]!==l||t[6]!==i?(m={suggestions:i,loading:l},t[5]=l,t[6]=i,t[7]=m):m=t[7],m}function gP(n){return n.json()}function fo(n,e){const t=F.c(6),[s,o]=zi(n,e),i=typeof s=="boolean"?s:e;let a;t[0]!==e||t[1]!==o?(a=d=>{o(f=>typeof d=="function"?d(typeof f=="boolean"?f:e):d)},t[0]=e,t[1]=o,t[2]=a):a=t[2];const l=a;let c;return t[3]!==l||t[4]!==i?(c=[i,l],t[3]=l,t[4]=i,t[5]=c):c=t[5],c}function xP(n,e){const t=F.c(45),[s,o]=fo("panel-sidebar-visible",!0),[i,a]=fo("panel-stats-visible",!1),[l,c]=fo("panel-worktrees-visible",!1),[d,f]=fo("panel-workflows-visible",!1),[u,m]=fo("panel-file-changes-visible",!0),[p,h]=b.useState(!1),[g,v]=b.useState(!1);let x;t[0]!==o||t[1]!==s?(x=()=>{b.startTransition(()=>o(!s))},t[0]=o,t[1]=s,t[2]=x):x=t[2];const w=x;let y;t[3]!==a||t[4]!==i?(y=()=>{b.startTransition(()=>a(!i))},t[3]=a,t[4]=i,t[5]=y):y=t[5];const j=y;let N;t[6]!==c?(N=()=>c(yP),t[6]=c,t[7]=N):N=t[7];const S=N;let k;t[8]!==f?(k=()=>f(bP),t[8]=f,t[9]=k):k=t[9];const C=k;let T;t[10]!==m||t[11]!==u?(T=()=>{b.startTransition(()=>m(!u))},t[10]=m,t[11]=u,t[12]=T):T=t[12];const _=T;let P;t[13]!==e||t[14]!==n.mainView?(P=()=>{const V=n.mainView==="config";b.startTransition(()=>{e({type:V?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[13]=e,t[14]=n.mainView,t[15]=P):P=t[15];const A=P;let E;t[16]!==e||t[17]!==n.mainView?(E=()=>{const V=n.mainView==="mission";b.startTransition(()=>{e({type:V?"CLOSE_MISSION":"OPEN_MISSION"})})},t[16]=e,t[17]=n.mainView,t[18]=E):E=t[18];const M=E;let I;t[19]!==e?(I=V=>{b.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:V})})},t[19]=e,t[20]=I):I=t[20];const R=I;let D;t[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>h(!0),t[21]=D):D=t[21];const L=D;let $;t[22]===Symbol.for("react.memo_cache_sentinel")?($=()=>h(!1),t[22]=$):$=t[22];const z=$;let U;t[23]===Symbol.for("react.memo_cache_sentinel")?(U=()=>v(vP),t[23]=U):U=t[23];const O=U;let H;t[24]===Symbol.for("react.memo_cache_sentinel")?(H=()=>v(!1),t[24]=H):H=t[24];const B=H;let W;return t[25]!==R||t[26]!==A||t[27]!==_||t[28]!==M||t[29]!==w||t[30]!==j||t[31]!==C||t[32]!==S||t[33]!==m||t[34]!==o||t[35]!==f||t[36]!==c||t[37]!==u||t[38]!==p||t[39]!==s||t[40]!==i||t[41]!==g||t[42]!==d||t[43]!==l?(W={showSidebar:s,showStats:i,showWorktrees:l,showWorkflows:d,showFileChanges:u,showProjectSwitcher:p,showThemeSelector:g,handleToggleSidebar:w,handleToggleStats:j,handleToggleWorktrees:S,handleToggleWorkflows:C,handleToggleFileChanges:_,handleToggleConfig:A,handleToggleMission:M,handleEditConfig:R,handleOpenProjectSwitcher:L,handleCloseProjectSwitcher:z,handleToggleThemeSelector:O,handleCloseThemeSelector:B,setShowSidebar:o,setShowWorktrees:c,setShowWorkflows:f,setShowFileChanges:m},t[25]=R,t[26]=A,t[27]=_,t[28]=M,t[29]=w,t[30]=j,t[31]=C,t[32]=S,t[33]=m,t[34]=o,t[35]=f,t[36]=c,t[37]=u,t[38]=p,t[39]=s,t[40]=i,t[41]=g,t[42]=d,t[43]=l,t[44]=W):W=t[44],W}function vP(n){return!n}function bP(n){return!n}function yP(n){return!n}function wP(n){var V;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:o,markPermissionsApplied:i,hasPermsPendingChanges:a,permissionsConfig:l,selectedModel:c,selectedEffort:d,fastMode:f,ultracode:u,mcpConfig:m,scrollRequestScrollToTop:p,handleDashboardSelect:h,workerParse:g}=n,v=b.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:q,fileName:Y}=e.sessionSource;try{const{parsed:K,source:J}=await Tx(q,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:K,source:J})}catch{}},[e.sessionSource,t,g]),[x,w]=b.useState(null),y=b.useCallback(q=>w(q),[]),j=b.useCallback(()=>w(null),[]),N=b.useCallback(async(q,Y)=>{try{const K=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:Y})});if(!K.ok)return;const J=await K.json(),{parsed:Z,source:Q}=await ys(J.dirName,J.fileName,g,"session");t({type:"LOAD_SESSION",session:Z,source:Q,isMobile:s})}catch{}},[t,s,g]),S=b.useCallback(()=>{e.sessionSource&&N(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,N]),k=b.useCallback(async(q,Y)=>{try{await ye("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:Y})})}catch{}},[]),C=b.useCallback(async q=>{var Z,Q;if(!e.sessionSource)return;const{dirName:Y,fileName:K}=e.sessionSource,J=(Q=(Z=e.session)==null?void 0:Z.turns[q])==null?void 0:Q.id;try{const se=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:K,turnIndex:q,turnUuid:J})});if(!se.ok)return;const ne=await se.json(),{parsed:ee,source:ie}=await ys(ne.dirName,ne.fileName,g,"session");t({type:"LOAD_SESSION",session:ee,source:ie,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),T=b.useCallback((q,Y)=>{o(q,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[_,P]=b.useState({}),A=b.useRef(c);A.current=c;const E=b.useRef(d);E.current=d;const M=b.useRef(m);M.current=m;const I=b.useRef(f);I.current=f;const R=b.useRef(u);R.current=u;const D=b.useRef(l);D.current=l;const L=((V=e.session)==null?void 0:V.sessionId)??null,$=b.useRef(null);b.useEffect(()=>{L!==$.current&&($.current=L,L&&P(q=>L in q?q:{...q,[L]:{model:A.current,effort:E.current,fastMode:I.current,ultracode:R.current,mcpConfig:M.current}}))},[L]);const z=L?_[L]:void 0,U=m!==((z==null?void 0:z.mcpConfig)??null),O=z!=null&&(c!==z.model||d!==z.effort||f!==z.fastMode||u!==z.ultracode||a||U),H=b.useCallback(async()=>{var ne,ee;if(!L)return;const q=A.current,Y=E.current,K=I.current,J=R.current,Z=M.current,Q=D.current;(((ne=e.sessionSource)==null?void 0:ne.agentKind)??Jt(((ee=e.sessionSource)==null?void 0:ee.dirName)??null))==="claude"&&await ye(`/api/claude/settings/${encodeURIComponent(L)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:q,effort:Y,fastMode:K,ultracode:J,mcpConfig:Z,permissionMode:Q.mode,allowedTools:Q.allowedTools,disallowedTools:Q.disallowedTools})}),P(ie=>({...ie,[L]:{model:q,effort:Y,fastMode:K,ultracode:J,mcpConfig:Z}})),i()},[L,e.sessionSource,i]),B=b.useCallback(async()=>{if(L)try{await ye("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:L})})}catch{}},[L]),W=b.useCallback((q,Y)=>{ss(Y)&&p(),h(q,Y)},[p,h]);return{reloadSession:v,branchModalTurn:x,setBranchModalTurn:w,handleOpenBranches:y,handleCloseBranchModal:j,handleDuplicateSessionByPath:N,handleDuplicateSession:S,handleDeleteSession:k,handleBranchFromHere:C,handleMobileJumpToTurn:T,hasSettingsChanges:O,handleApplySettings:H,handleStopSession:B,handleLoadSessionScrollAware:W}}function Bx(){const n=F.c(6),e=b.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=b.useRef(t),o=b.useRef(0);let i,a;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const m=s.current,p=new Worker(new URL("/assets/session-parser.worker-BhyaigCR.js",import.meta.url),{type:"module"});return p.onmessage=h=>{const g=h.data,v=m.get(g.id);v&&(m.delete(g.id),g.type==="result"?v.resolve(g.session):v.reject(new Error(g.error)))},p.onerror=h=>{for(const[,g]of m)g.reject(new Error(`Worker error: ${h.message}`));m.clear()},e.current=p,()=>{p.terminate(),e.current=null;for(const[,h]of m)h.reject(new Error("Worker terminated"));m.clear()}},a=[],n[1]=i,n[2]=a):(i=n[1],a=n[2]),b.useEffect(i,a);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{o.current=o.current+1;const v=o.current;s.current.set(v,{resolve:h,reject:g}),p.postMessage({type:"parse",id:v,text:m})}):Promise.resolve().then(()=>Di(m))},n[3]=l):l=n[3];const c=l;let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(m,p)=>{const h=e.current;return h?new Promise((g,v)=>{o.current=o.current+1;const x=o.current;s.current.set(x,{resolve:g,reject:v}),h.postMessage({type:"append",id:x,existing:m,newText:p})}):Promise.resolve().then(()=>F5(m,p))},n[4]=d):d=n[4];const f=d;let u;return n[5]===Symbol.for("react.memo_cache_sentinel")?(u={parse:c,append:f},n[5]=u):u=n[5],u}const jP=30;function Ux({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=b.useState(!1),[l,c]=b.useState(!1),d=b.useRef(""),f=b.useRef(null),u=`${n??""}::${e??""}::${t}`;return b.useEffect(()=>{d.current=u,f.current=null,c(!1);const p=n&&e?on.get(n,e):void 0;a((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&o(p.olderTurns)},[u,n,e,t,o]),{loadMore:b.useCallback(async()=>{if(!n||!e||f.current)return 0;const p=`${n}::${e}::${t}`,h=on.get(n,e);if(!(h!=null&&h.hasMore))return d.current===p&&a(!1),0;const g=Symbol("paging-flight");f.current=g,c(!0);try{const v=await ye(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${jP}`);if(!v.ok)return 0;const x=await v.json(),w=x.lines.length>0&&x.hasMore;if(d.current===p&&a(w),x.lines.length===0)return on.update(n,e,{hasMore:w,nextByteOffset:x.byteOffset}),0;const y=new Set(x.headerLines),j=x.lines.filter(k=>!y.has(k)),N=await s([...x.headerLines,...j].join(`
|
|
131
|
+
`)),S=P1(h.olderTurns,N.turns,h.source.agentKind);return on.update(n,e,{hasMore:w,nextByteOffset:x.byteOffset,olderTurns:S}),d.current!==p?0:(o(S),N.turns.length)}finally{f.current===g&&(f.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function SP(n){const e=F.c(50),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??"claude",c=wp(l),[d,f]=b.useState(""),[u,m]=b.useState(""),[p,h]=b.useState(!1),[g,v]=b.useState(!1),x=d||(s==null?void 0:s.model);let w;e[0]!==l||e[1]!==x?(w=Ov(l,x),e[0]=l,e[1]=x,e[2]=w):w=e[2];const y=w,j=g&&y;let N;e[3]!==l||e[4]!==u||e[5]!==d||e[6]!==j?(N=j?"xhigh":wi(l,u,d),e[3]=l,e[4]=u,e[5]=d,e[6]=j,e[7]=N):N=e[7];const S=N;let k;e[8]!==l||e[9]!==d?(k=up(l,d),e[8]=l,e[9]=d,e[10]=k):k=e[10];const C=!!k,T=C&&p;let _;e[11]!==l||e[12]!==d?(_=Iv(l,d),e[11]=l,e[12]=d,e[13]=_):_=e[13];const P=_,[A,E]=b.useState(null),M=b.useRef(null),I=(o==null?void 0:o.fileName)??null,R=b.useRef(I);let D,L;e[14]!==I?(D=()=>{const ne=R.current;R.current=I,!(ne===null||ne===I)&&v(!1)},L=[I],e[14]=I,e[15]=D,e[16]=L):(D=e[15],L=e[16]),b.useEffect(D,L);let $,z;e[17]!==i?($=()=>{i&&v(!1)},z=[i],e[17]=i,e[18]=$,e[19]=z):($=e[18],z=e[19]),b.useEffect($,z);let U;e[20]===Symbol.for("react.memo_cache_sentinel")?(U=ne=>{f(ee=>ee===ne?"":ee),E(`${ne} is unavailable for this account. Cogpit retried the turn with Codex's default model.`)},e[20]=U):U=e[20];const O=U;let H;e[21]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{E(null)},e[21]=H):H=e[21];const B=H;let W,V;e[22]!==c||e[23]!==i||e[24]!==d||e[25]!==o?(W=()=>{d&&(!o&&!i||c.some(ne=>ne.value===d)||f(""))},V=[c,d,o,i],e[22]=c,e[23]=i,e[24]=d,e[25]=o,e[26]=W,e[27]=V):(W=e[26],V=e[27]),b.useEffect(W,V);let q,Y;e[28]!==A?(q=()=>{if(!A)return;const ne=setTimeout(()=>E(null),12e3);return()=>clearTimeout(ne)},Y=[A],e[28]=A,e[29]=q,e[30]=Y):(q=e[29],Y=e[30]),b.useEffect(q,Y);let K;e[31]!==a||e[32]!==s?(K=()=>{if(!a||(s==null?void 0:s.agentKind)!=="claude")return;const ne=s.rawMessages;let ee;for(let ce=ne.length-1;ce>=0;ce=ce-1,ce){const me=ne[ce];if(me.type==="system"&&me.subtype==="model_refusal_fallback"){ee=me;break}}if(!ee)return;const ie=typeof ee.uuid=="string"?ee.uuid:`${String(ee.original_model)}:${String(ee.fallback_model)}:${String(ee.request_id)}`;if(M.current===ie)return;M.current=ie;const oe=typeof ee.original_model=="string"?ee.original_model:"Fable",re=typeof ee.fallback_model=="string"?ee.fallback_model:"Opus",te=typeof ee.api_refusal_explanation=="string"?` ${ee.api_refusal_explanation}`:"";E(`${oe} could not handle this request, so Claude continued with ${re}.${te}`)},e[31]=a,e[32]=s,e[33]=K):K=e[33];const J=s==null?void 0:s.agentKind,Z=s==null?void 0:s.rawMessages;let Q;e[34]!==a||e[35]!==J||e[36]!==Z?(Q=[a,J,Z],e[34]=a,e[35]=J,e[36]=Z,e[37]=Q):Q=e[37],b.useEffect(K,Q);let se;return e[38]!==S||e[39]!==T||e[40]!==C||e[41]!==p||e[42]!==P||e[43]!==A||e[44]!==u||e[45]!==d||e[46]!==j||e[47]!==y||e[48]!==g?(se={selectedModel:d,setSelectedModel:f,selectedEffort:u,setSelectedEffort:m,fastModeEnabled:p,ultracodeEnabled:g,effectiveEffort:S,fastModeAvailable:C,fastModeActive:T,setFastModeEnabled:h,ultracodeAvailable:y,ultracodeActive:j,setUltracodeEnabled:v,imageInputAvailable:P,modelFallbackNotice:A,dismissModelFallbackNotice:B,handleCodexModelRejected:O},e[38]=S,e[39]=T,e[40]=C,e[41]=p,e[42]=P,e[43]=A,e[44]=u,e[45]=d,e[46]=j,e[47]=y,e[48]=g,e[49]=se):se=e[49],se}const NP=["model","effort","fastMode","ultracode","permissionMode"];function kP({sessionKey:n,values:e,onHydrate:t}){const s=b.useRef(null),o=b.useRef(null),i=b.useRef(t);i.current=t;const a=b.useRef(e);a.current=e,b.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return Fx(n).then(d=>{if(c||d===null)return;if(NP.some(u=>d[u]!==void 0)){i.current(d);const u=a.current,m={model:d.model??u.model,effort:d.effort??u.effort,fastMode:d.fastMode??u.fastMode,ultracode:d.ultracode??u.ultracode,permissionMode:d.permissionMode??u.permissionMode};o.current=JSON.stringify(m)}else _l(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);b.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,_l(n,a.current))},[l,n])}function CP(n){const[e,t]=b.useState(new Map),[s,o]=b.useState(null),[i,a]=b.useState(!0),l=b.useRef(new Map),c=b.useRef(null);b.useEffect(()=>{const v=n??null,x=c.current;if(x&&x!==v&&l.current.set(x,{activeId:s,collapsed:i}),v!==x){const w=v?l.current.get(v):null;w?(o(w.activeId),a(w.collapsed)):(o(null),a(!0))}c.current=v},[n]);const d=b.useCallback(()=>a(v=>!v),[]),f=b.useCallback(v=>{t(x=>{const w=new Map(x);return w.set(v.id,v),w}),o(v.id),a(!1)},[]),u=b.useCallback(v=>{t(x=>{const w=new Map(x);return w.delete(v),o(y=>{if(y!==v)return y;const j=[...w.keys()];return j.length>0?j[j.length-1]:null}),w})},[]),m=b.useCallback(v=>{o(v),a(!1)},[]),p=b.useCallback((v,x)=>{t(w=>{const y=w.get(v);if(!y||y.status===x)return w;const j=new Map(w);return j.set(v,{...y,status:x}),j})},[]),h=b.useCallback(v=>{t(x=>{let w=!1;const y=new Map(x),j=new Set(v.map(N=>N.id));for(const[N,S]of y)S.type==="task"&&!j.has(N)&&(y.delete(N),w=!0);for(const N of v){const S=y.get(N.id);S?(S.name!==N.title||S.outputPath!==N.outputPath)&&(y.set(N.id,{...S,name:N.title,outputPath:N.outputPath}),w=!0):(y.set(N.id,{id:N.id,name:N.title,type:"task",status:"running",outputPath:N.outputPath}),w=!0)}return w?y:x})},[]),g=b.useCallback((v,x,w)=>{x&&w&&t(y=>{if(y.has(v))return y;const j=new Map(y);return j.set(v,{id:v,name:w,type:"task",status:"running",outputPath:x}),j}),o(y=>y===v?(a(!0),y):(a(!1),v))},[]);return{processes:e,activeProcessId:s,collapsed:i,toggleCollapse:d,addProcess:f,removeProcess:u,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function _P(n){const e=F.c(50),{sessionId:t,sessionCwd:s,pendingPath:o,sessionDirName:i,pendingDirName:a,dashboardProject:l,supportsFileWorkspace:c}=n,d=CP(t),[f,u]=b.useState(null),[m,p]=b.useState(0),h=b.useRef(0),g=s??o??void 0,v=!!(g&&(f==null?void 0:f.kind)==="preview"&&f.cwd===g),x=(f==null?void 0:f.kind)==="project-files"&&f.anchorCwd===(g??null)?f:null;let w;e[0]!==a||e[1]!==o?(w={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=w):w=e[2];const y=w;let j;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(j=()=>{if(vs()){console.warn("[open-terminal] unavailable for remote devices");return}const V=s??o??void 0,q=i??a??l??void 0;if(!V&&!q){console.warn("[open-terminal] no project path available");return}ye("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:V,dirName:q})}).then(RP).catch(MP)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=j):j=e[8];const N=j;let S;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(S=V=>{if(vs()){console.warn("[mcp-auth] unavailable for remote devices");return}const q=s??o??void 0,Y=i??a??l??void 0;!q&&!Y||ye("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:q,dirName:Y,command:"claude /mcp"})}).catch(AP)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=S):S=e[14];const k=S;let C;e[15]!==o||e[16]!==d||e[17]!==s?(C=()=>{const q=[...d.processes.values()].filter(PP).at(-1);if(!q){(s??o)&&p(EP);return}d.activeProcessId===q.id&&!d.collapsed?d.toggleCollapse():d.setActive(q.id)},e[15]=o,e[16]=d,e[17]=s,e[18]=C):C=e[18];const T=C;let _;e[19]!==o||e[20]!==s?(_=()=>{(s??o)&&p(TP)},e[19]=o,e[20]=s,e[21]=_):_=e[21];const P=_;let A;e[22]!==g||e[23]!==v?(A=()=>{g&&b.startTransition(()=>{u(v?null:{kind:"preview",cwd:g})})},e[22]=g,e[23]=v,e[24]=A):A=e[24];const E=A;let M;e[25]!==g||e[26]!==x?(M=()=>{g&&b.startTransition(()=>{u(x?null:{kind:"project-files",root:g,anchorCwd:g,request:null})})},e[25]=g,e[26]=x,e[27]=M):M=e[27];const I=M;let R;e[28]!==g||e[29]!==c?(R=V=>{if(!c)return!1;const q=Lj(V,g);if(!q)return!1;h.current=h.current+1;const Y=h.current;return b.startTransition(()=>u({kind:"project-files",root:q.root,anchorCwd:g??null,request:q.file?{file:q.file,mode:q.mode,line:q.line,token:Y}:null})),!0},e[28]=g,e[29]=c,e[30]=R):R=e[30];const D=R;let L,$;e[31]!==D?($=()=>Dj(D),L=[D],e[31]=D,e[32]=L,e[33]=$):(L=e[32],$=e[33]),b.useEffect($,L);let z;e[34]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{b.startTransition(()=>u(null))},e[34]=z):z=e[34];const U=z,O=x!==null,H=x==null?void 0:x.root,B=(x==null?void 0:x.request)??null;let W;return e[35]!==g||e[36]!==k||e[37]!==P||e[38]!==N||e[39]!==T||e[40]!==E||e[41]!==I||e[42]!==m||e[43]!==y||e[44]!==d||e[45]!==v||e[46]!==O||e[47]!==H||e[48]!==B?(W={processPanel:d,currentCwd:g,showPreview:v,showProjectFiles:O,projectFilesRoot:H,projectFilesRequest:B,launchTerminalRequest:m,pendingProject:y,handleOpenTerminal:N,handleMcpAuth:k,handleToggleIntegratedTerminal:T,handleNewIntegratedTerminal:P,handleTogglePreview:E,handleToggleProjectFiles:I,closeRightWorkspace:U},e[35]=g,e[36]=k,e[37]=P,e[38]=N,e[39]=T,e[40]=E,e[41]=I,e[42]=m,e[43]=y,e[44]=d,e[45]=v,e[46]=O,e[47]=H,e[48]=B,e[49]=W):W=e[49],W}function TP(n){return n+1}function EP(n){return n+1}function PP(n){return n.type==="terminal"}function AP(n){return console.error("[mcp-auth] open-terminal failed:",n)}function MP(n){return console.error("[open-terminal] fetch failed:",n)}function RP(n){n.ok||n.json().then($P).catch(IP)}function IP(){}function $P(n){return console.error("[open-terminal]",n.error)}function OP(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
132
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const DP={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function Wx(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:Jt(n.dirName)}}function LP(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...DP},rawMessages:[],agentKind:Jt(n.dirName)}}function Hx(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:Di(n)}}catch{return null}}async function zP(n,e,t=3,s=100,o=!0){if(o){const i=Hx(n.initialContent);if(i)return i}for(let i=0;i<t;i++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const a=await ye(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(a.ok){const l=await a.text();if(l.trim())try{return{rawText:l,parsed:Di(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function FP(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await zP(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:Wx(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function Mm(n,e,t,s,o){const i=Hx(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??LP(n),c=Wx(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),FP(n,e,t,a),n.sessionId}async function BP(n,e,t,s){const o=await ye(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json(),a=t-3e4,l=e.trim(),c=(i.sessions??[]).filter(f=>{const u=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(u)&&u>=a}),d=c.find(f=>{var u,m;return((u=f.firstUserMessage)==null?void 0:u.trim())===l||((m=f.lastUserMessage)==null?void 0:m.trim())===l})??c[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function UP({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:o,onCodexModelRejected:i,model:a,effort:l,fastMode:c,ultracode:d,mcpConfig:f}){const[u,m]=b.useState(!1),[p,h]=b.useState(null),[g,v]=b.useState(!1),[x,w]=b.useState(""),y=b.useRef(null),j=b.useRef(null),N=b.useRef(null),S=b.useCallback((_,P)=>{j.current=_,N.current=P??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:_,cwd:P,isMobile:t})},[e,t]),k=b.useCallback(async(_,P)=>{var D;const A=j.current;if(!A)return null;const E=Jt(A),M=N.current;(D=y.current)==null||D.abort();const I=new AbortController;y.current=I,m(!0),h(null),o==null||o(_);const R=Date.now();try{const L=OP(_),$={dirName:A,cwd:E==="claude"?M??void 0:void 0,message:_,images:P,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:E==="claude"&&d?!0:void 0,name:E==="claude"&&L||void 0,worktreeName:E==="claude"&&g?x||Dv(_):void 0,mcpConfig:E==="claude"&&f||void 0},{res:z,errorMessage:U}=await Nx(B=>ye("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,model:B}),signal:I.signal}),{model:a,agentKind:E,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(E==="codex"){const B=await BP(A,_,R,I);if(B){j.current=null,N.current=null;const W=await Mm(B,I,e,t,s);return L&&W&&Sl(W,L),W}}return h(U||`Failed to create session (${z.status})`),null}const O=await z.json();j.current=null,N.current=null;const H=await Mm(O,I,e,t,s);return L&&H&&Sl(H,L),H}catch(L){return I.signal.aborted||h(L instanceof Error?L.message:"Failed to create session"),null}finally{I.signal.aborted||m(!1)}},[n,a,l,c,d,f,g,x,e,t,s,o,i]),C=b.useCallback(()=>h(null),[]),T=b.useCallback(()=>{var _;(_=y.current)==null||_.abort(),y.current=null,j.current=null,N.current=null,m(!1),h(null)},[]);return{creatingSession:u,createError:p,clearCreateError:C,handleNewSession:S,createAndSend:k,cancelCreation:T,pendingDirNameRef:j,worktreeEnabled:g,setWorktreeEnabled:v,worktreeName:x,setWorktreeName:w}}function WP(n){const e=F.c(40),{permissionsConfig:t,dispatch:s,isMobile:o,defaultAgentKind:i,pendingDirName:a,pendingCwd:l,model:c,effort:d,fastMode:f,ultracode:u,mcpConfig:m,onCodexModelRejected:p}=n,h=b.useRef(null),g=b.useRef(null),[v,x]=b.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=B=>{var W;(W=h.current)==null||W.call(h,B),setTimeout(()=>{var V;return(V=g.current)==null?void 0:V.call(g)},300),setTimeout(()=>{var V;return(V=g.current)==null?void 0:V.call(g)},2e3)},e[0]=w):w=e[0];let y;e[1]!==s||e[2]!==d||e[3]!==f||e[4]!==o||e[5]!==m||e[6]!==c||e[7]!==p||e[8]!==t||e[9]!==u?(y={permissionsConfig:t,dispatch:s,isMobile:o,onSessionFinalized:w,onCreateStarted:x,onCodexModelRejected:p,model:c,effort:d,fastMode:f,ultracode:u,mcpConfig:m},e[1]=s,e[2]=d,e[3]=f,e[4]=o,e[5]=m,e[6]=c,e[7]=p,e[8]=t,e[9]=u,e[10]=y):y=e[10];const j=UP(y),N=j.handleNewSession,[S,k]=b.useState(null);let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[11]=C):C=e[11];const T=b.useRef(C);let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=async B=>{const W=T.current;if(W.has(B))return W.get(B)??null;try{const V=await ye("/api/projects");if(!V.ok)return W.set(B,null),null;const q=await V.json(),Y=mw(q,B);return W.set(B,Y),Y}catch{return W.set(B,null),null}},e[12]=_):_=e[12];const P=_;let A;e[13]!==N?(A=async(B,W)=>{const V=W??null;if(!V){k(null),N(B);return}const q=Ai(B),Y=q?await P(V):Nu(V,"claude");k(Y?{claudeDirName:Y,cwd:V}:null),N(q||!Y?B:Y,V)},e[13]=N,e[14]=A):A=e[14];const E=A;let M;e[15]!==i||e[16]!==E?(M=B=>{const W=Nu(B,i);E(W,B)},e[15]=i,e[16]=E,e[17]=M):M=e[17];const I=M;let R;e[18]!==N||e[19]!==S?(R=B=>{if(!S)return;const W=fw(S.claudeDirName,S.cwd,B);N(W,S.cwd)},e[18]=N,e[19]=S,e[20]=R):R=e[20];const D=R;let L;e:{if(!j.creatingSession||!a){L=null;break e}const B=v??void 0;let W;e[21]!==l||e[22]!==a||e[23]!==B?(W={dirName:a,cwd:l,firstMessage:B},e[21]=l,e[22]=a,e[23]=B,e[24]=W):W=e[24],L=W}const $=L;let z,U;e[25]!==a?(U=()=>{a||(x(null),k(null))},z=[a],e[25]=a,e[26]=z,e[27]=U):(z=e[26],U=e[27]),b.useEffect(U,z);const O=S?D:void 0;let H;return e[28]!==I||e[29]!==E||e[30]!==j.cancelCreation||e[31]!==j.clearCreateError||e[32]!==j.createAndSend||e[33]!==j.createError||e[34]!==j.creatingSession||e[35]!==j.setWorktreeEnabled||e[36]!==j.worktreeEnabled||e[37]!==$||e[38]!==O?(H={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:$,pendingAgentKindChange:O,handleStartNewSession:E,handleStartNewFolder:I},e[28]=I,e[29]=E,e[30]=j.cancelCreation,e[31]=j.clearCreateError,e[32]=j.createAndSend,e[33]=j.createError,e[34]=j.creatingSession,e[35]=j.setWorktreeEnabled,e[36]=j.worktreeEnabled,e[37]=$,e[38]=O,e[39]=H):H=e[39],H}const qa=new Set;function HP(n,e){const t=nn(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function KP(n,e,t){const s=HP(n,e);if(!qa.has(s)&&!on.get(n,e)){qa.add(s);try{await ys(n,e,t,"session prefetch")}catch{}finally{qa.delete(s)}}}function VP({onAuthenticated:n}){const[e,t]=b.useState(null),[s,o]=b.useState(""),[i,a]=b.useState(""),[l,c]=b.useState(!1),[d,f]=b.useState(null),[u,m]=b.useState(!1),p=e==="team";b.useEffect(()=>{let v=!1;return bp().then(x=>{v||t(x)}),()=>{v=!0}},[]);const h=b.useCallback(async v=>{if(v.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),f(null);try{const x=await fetch("/api/auth/verify",p?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:s.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),w=await x.json();x.ok&&w.valid?(Si(),a(""),o(""),n()):f(w.error||(p?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{m(!1)}}},[p,n,i,s]),g=u||!i.trim()||p&&!s.trim();return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:h,className:"w-full max-w-sm",children:r.jsxs(Ut,{children:[r.jsxs(Vt,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(wv,{className:"size-4"})}),r.jsx(qt,{children:"Sign in to Cogpit"}),r.jsx(Gt,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Wt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(It,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Wt,{className:"flex flex-col gap-4",children:[r.jsxs(Qs,{children:[p&&r.jsxs(ft,{children:[r.jsx(mt,{htmlFor:"login-username",children:"Username"}),r.jsx(Pt,{id:"login-username",type:"text",value:s,onChange:v=>o(v.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(ft,{children:[r.jsx(mt,{htmlFor:"login-password",children:"Password"}),r.jsxs(Bn,{children:[r.jsx(Un,{id:"login-password",type:l?"text":"password",value:i,onChange:v=>a(v.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(un,{align:"inline-end",children:r.jsx(er,{size:"icon-xs",onClick:()=>c(v=>!v),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(hi,{}):r.jsx(Js,{})})})]})]})]}),d&&r.jsxs(vt,{variant:"destructive",children:[r.jsx(ln,{"aria-hidden":"true"}),r.jsx(At,{children:"Sign in failed"}),r.jsx(bt,{children:d})]})]}),r.jsx(to,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:g,children:[u&&r.jsx(It,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const Rm=16,Br="__cogpitBootstrapToken";function qP(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[Br]=="string"?t[Br]:"");return e&&window.history.replaceState({...t,[Br]:e},"",`${window.location.pathname}${window.location.search}`),s}function Im(){const n={...window.history.state||{}};delete n[Br],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function GP({onAuthenticated:n,onBootstrapClosed:e}){const[t]=b.useState(qP),[s,o]=b.useState(""),[i,a]=b.useState(""),[l,c]=b.useState(""),[d,f]=b.useState(""),[u,m]=b.useState(!1),[p,h]=b.useState(null),[g,v]=b.useState(!1),x=d.length>0&&d!==l,w=!t||!s.trim()||l.length<Rm||d!==l,y=b.useCallback(async j=>{if(j.preventDefault(),!w){v(!0),h(null);try{const N=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify({username:s.trim(),password:l,...i.trim()?{displayName:i.trim()}:{}})}),S=await N.json();if(N.ok){Im(),c(""),f(""),o(""),a(""),await e(),n();return}if(N.status===410){Im(),await e();return}h(S.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{v(!1)}}},[t,i,w,n,e,l,s]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:y,className:"w-full max-w-md",children:r.jsxs(Ut,{children:[r.jsxs(Vt,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(jv,{className:"size-4"})}),r.jsx(qt,{children:"Create the first admin"}),r.jsx(Gt,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Wt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(vt,{children:[r.jsx(fn,{"aria-hidden":"true"}),r.jsx(At,{children:"Setup link required"}),r.jsx(bt,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(Qs,{children:[r.jsxs(ft,{children:[r.jsx(mt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Pt,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(Ks,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(ft,{children:[r.jsxs(mt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Pt,{id:"bootstrap-display-name",type:"text",value:i,onChange:j=>a(j.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(ft,{children:[r.jsx(mt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(Bn,{children:[r.jsx(Un,{id:"bootstrap-password",type:u?"text":"password",value:l,onChange:j=>c(j.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(un,{align:"inline-end",children:r.jsx(er,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":u?"Hide password":"Show password",children:u?r.jsx(hi,{}):r.jsx(Js,{})})})]}),r.jsxs(Ks,{children:["Use at least ",Rm," characters."]})]}),r.jsxs(ft,{"data-invalid":x,children:[r.jsx(mt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Pt,{id:"bootstrap-confirm-password",type:u?"text":"password",value:d,onChange:j=>f(j.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":x}),x&&r.jsx(Jn,{children:"Passwords do not match"})]})]}),p&&r.jsxs(vt,{variant:"destructive",children:[r.jsx(ln,{"aria-hidden":"true"}),r.jsx(At,{children:"Could not create the account"}),r.jsx(bt,{children:p})]})]}),r.jsx(to,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(It,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function YP(){const n=F.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=ji(),n[0]=e):e=n[0];const t=e,[s,o]=b.useState(null),[i,a]=b.useState(!1),[l,c]=b.useState(!1),d=b.useRef(0);let f,u;n[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let A=!1;return vp().then(E=>{A||o(E)}),()=>{A=!0}},u=[],n[1]=f,n[2]=u):(f=n[1],u=n[2]),b.useEffect(f,u);const m=t?!0:s===null?null:s.edition==="team";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){a(!0),c(!0);return}let A=!1;const E=d.current;return yb().then(M=>{!A&&d.current===E&&(a(M),c(!0))}),()=>{A=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),b.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let A=!1;const E=()=>{const M=d.current=d.current+1,I=()=>{A||d.current!==M||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){I();return}ru().then(R=>{A||d.current!==M||(o(R),R.edition==="team"&&I())})};return window.addEventListener("cogpit-auth-required",E),()=>{A=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const v=s==null?void 0:s.edition;let x;n[8]!==v?(x=[v,t],n[8]=v,n[9]=x):x=n[9],b.useEffect(g,x);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{d.current=d.current+1,a(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const y=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{o(await ru())},n[11]=j):j=n[11];const N=j;let S;n[12]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{d.current=d.current+1,a(!1),c(!0),wb().finally(XP)},n[12]=S):S=n[12];const k=S,C=(s==null?void 0:s.edition)??null,T=l&&s!==null,_=(s==null?void 0:s.needsBootstrap)===!0;let P;return n[13]!==i||n[14]!==C||n[15]!==T||n[16]!==_?(P={isRemote:t,edition:C,authChecked:T,authenticated:i,needsBootstrap:_,handleAuthenticated:y,refreshServerState:N,logout:k},n[13]=i,n[14]=C,n[15]=T,n[16]=_,n[17]=P):P=n[17],P}function XP(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const JP=b.lazy(()=>Ve(()=>import("./index-S7UMnH_y.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),ZP=b.lazy(()=>Ve(()=>import("./WorkflowsPanel-JVqgKAzY.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function QP(){var kd,Cd,_d,Td,Ed,Pd,Ad,Md,Rd,Id,$d,Od,Dd,Ld,zd,Fd,Bd,Ud,Wd;const n=Hc(window.location.pathname),e=Y9(),t=YP(),s=eP(t.edition),o=s.checked&&(t.edition!=="team"||s.authenticated&&s.edition==="team"&&s.user!==null),i=o&&s.capabilities.configWrite,a=o&&s.capabilities.hostFiles,l=o&&s.capabilities.terminal,c=Wi(),d=Ax(),[f,u]=kx(),{parse:m,append:p}=Bx(),h=b.useCallback(Se=>{u({type:"SET_OLDER_TURNS",turns:Se})},[u]),g=b.useCallback((Se,Ge)=>{KP(Se,Ge,m)},[m]),v=Ux({dirName:((kd=f.sessionSource)==null?void 0:kd.dirName)??null,fileName:((Cd=f.sessionSource)==null?void 0:Cd.fileName)??null,sessionChangeKey:f.sessionChangeKey,workerParse:m,onOlderTurns:h}),{loadMore:x}=v,w=!!f.searchQuery&&v.hasMore,y=((_d=f.session)==null?void 0:_d.turns.length)??0;b.useEffect(()=>{w&&x()},[w,x,y]);const j=xP(f,u),N=b.useRef(null),S=b.useRef(null),[k,C]=b.useState(!1),[T,_]=b.useState(!1),P=b.useCallback(()=>u({type:"TOGGLE_EXPAND_ALL"}),[u]),A=b.useCallback(()=>C(!0),[]),E=b.useCallback(()=>{var Se;return(Se=S.current)==null?void 0:Se.focus()},[]),M=b.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!0}),[u]),I=b.useCallback(()=>u({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[u]),R=b.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!1}),[u]),D=b.useCallback(Se=>{b.startTransition(()=>{u({type:"SET_DASHBOARD_PROJECT",dirName:Se})})},[u]),L=f.pendingCwd??(f.pendingDirName?rn(f.pendingDirName):null),$=((Td=f.sessionSource)==null?void 0:Td.agentKind)??Jt(((Ed=f.sessionSource)==null?void 0:Ed.dirName)??f.pendingDirName??null),z=$==="claude",U=$==="claude",O=hP(i?((Pd=f.session)==null?void 0:Pd.cwd)??L??void 0:void 0,i),H=b.useCallback(Se=>{if(!i)return;const Ge=O.suggestions.find(pt=>pt.name===Se);b.startTransition(()=>{u({type:"OPEN_CONFIG",filePath:Ge==null?void 0:Ge.filePath})})},[i,u,O.suggestions]),B=b.useCallback(async(Se,Ge)=>{if(!i)return null;const pt=O.suggestions.find(Zt=>Zt.name===Se);if(!(pt!=null&&pt.filePath))return null;try{const Zt=await ye("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:pt.filePath,args:Ge||""})});return Zt.ok?(await Zt.json()).content??null:null}catch{return null}},[i,O.suggestions]),{processPanel:W,currentCwd:V,showPreview:q,showProjectFiles:Y,projectFilesRoot:K,projectFilesRequest:J,launchTerminalRequest:Z,pendingProject:Q,handleOpenTerminal:se,handleMcpAuth:ne,handleToggleIntegratedTerminal:ee,handleNewIntegratedTerminal:ie,handleTogglePreview:oe,handleToggleProjectFiles:re,closeRightWorkspace:te}=_P({sessionId:(Ad=f.session)==null?void 0:Ad.sessionId,sessionCwd:(Md=f.session)==null?void 0:Md.cwd,pendingPath:L,sessionDirName:(Rd=f.sessionSource)==null?void 0:Rd.dirName,pendingDirName:f.pendingDirName,dashboardProject:f.dashboardProject,supportsFileWorkspace:!c&&a}),ce=uP(f.session??null),[me,pe]=b.useState(!1),xe=((Id=f.sessionSource)==null?void 0:Id.dirName)??f.pendingDirName??f.dashboardProject??null,we=rP(o&&z&&j.showWorktrees?xe:null),ae=b.useMemo(()=>{const Se=f.session;return Se?Se.turns.some(Ge=>Zr(Ge.toolCalls,Se.cwd)||Ge.subAgentActivity.some(pt=>Zr(pt.toolCalls,Se.cwd))):!1},[f.session]),ve=b.useMemo(()=>{if(!f.session)return 0;let Se=0;for(const Ge of f.session.turns)for(const pt of Ge.toolCalls)pt.name==="Workflow"&&Se++;return Se},[f.session]),he=ve>0,de=b.useMemo(()=>{const Se=f.sessionSource;return!Se||ss(Se.fileName)?{dirName:null,sessionId:null}:{dirName:Se.dirName,sessionId:Se.fileName.replace(/\.jsonl$/,"")}},[f.sessionSource]),Ne=f9(de.dirName,de.sessionId,he),ke=he||Ne.workflows.length>0,Te=Ne.workflows.length||ve,Ae=j.setShowWorkflows,Pe=b.useCallback(()=>Ae(!0),[Ae]),[De,ze]=b.useState(!1),Fe=b.useCallback(Se=>{ze(Se.asPercentage===0)},[]),[ue,le]=b.useState(!1),[Me,Le]=b.useState(!1),je=j.setShowFileChanges;b.useEffect(()=>{if(!a)return;const Se=()=>{c?le(!0):b.startTransition(()=>{je(!0),ze(!1)})};return window.addEventListener(Oo,Se),()=>window.removeEventListener(Oo,Se)},[a,je,c]);const fe=b.useMemo(()=>f.session?lg(f.session):null,[f.session]),Ce=b.useRef(null),{isLive:_e,sseState:Be,isCompacting:be,streamingOverlay:Ee,turnError:Ie,agentProgress:Ue,promptSuggestion:Je}=jx(f.sessionSource,Se=>{b.startTransition(()=>{u({type:"UPDATE_SESSION",session:Se})})},m,p,()=>{var Se;return(Se=Ce.current)==null?void 0:Se.call(Ce)},f.session),qe=b.useMemo(()=>Ee.reduce((Se,Ge)=>Se+Ge.blocks.reduce((pt,Zt)=>pt+Zt.text.length,0),0),[Ee]),Ze=pP((($d=f.session)==null?void 0:$d.cwd)??null),Ke=R9(),Re=Ke.setMode,He=O9(((Od=f.session)==null?void 0:Od.sessionId)??null,Ke.config.mode),{selectedModel:$e,setSelectedModel:We,selectedEffort:Ye,setSelectedEffort:yt,fastModeEnabled:zt,ultracodeEnabled:Ns,effectiveEffort:lr,fastModeAvailable:qx,fastModeActive:cr,setFastModeEnabled:Zi,ultracodeAvailable:Gx,ultracodeActive:dr,setUltracodeEnabled:Qi,imageInputAvailable:Kc,modelFallbackNotice:Yx,dismissModelFallbackNotice:Xx,handleCodexModelRejected:Vc}=SP({agentKind:$,session:f.session,sessionSource:f.sessionSource,pendingDirName:f.pendingDirName,isLive:_e}),qc=aP((Dd=f.session)==null?void 0:Dd.sessionId,(Ld=f.sessionSource)==null?void 0:Ld.fileName);kP({sessionKey:qc,values:{model:$e,effort:Ye,fastMode:zt,ultracode:Ns,permissionMode:Ke.config.mode},onHydrate:b.useCallback(Se=>{Se.model!==void 0&&We(Se.model),Se.effort!==void 0&&yt(Se.effort),Se.fastMode!==void 0&&Zi(Se.fastMode),Se.ultracode!==void 0&&Qi(Se.ultracode),Se.permissionMode&&Re(Se.permissionMode)},[We,yt,Zi,Qi,Re])});const Kt=dP(U&&i?V:void 0,U&&i?xe??void 0:void 0,U&&i?qc??void 0:void 0,i),{showWorktrees:Gc,setShowWorktrees:Yc,showWorkflows:Xc}=j;b.useEffect(()=>{!z&&Gc&&Yc(!1)},[z,Gc,Yc]),b.useEffect(()=>{Xc&&!ke&&Ae(!1)},[Xc,ke,Ae]);const{creatingSession:Jc,createError:Zc,clearCreateError:Jx,createAndSend:Zx,cancelCreation:Qc,worktreeEnabled:Qx,setWorktreeEnabled:e0,sessionFinalizedRef:ur,liveSessionsRefreshRef:ed,pendingSessionInfo:td,pendingAgentKindChange:t0,handleStartNewSession:nd,handleStartNewFolder:n0}=WP({permissionsConfig:Ke.config,dispatch:u,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:f.pendingDirName,pendingCwd:f.pendingCwd,onCodexModelRejected:Vc,model:$e,effort:lr,fastMode:cr,ultracode:dr,mcpConfig:U&&i?Kt.mcpConfigJson:null}),dt=h9({sessionSource:f.sessionSource,parsedSessionId:((zd=f.session)==null?void 0:zd.sessionId)??null,cwd:(Fd=f.session)==null?void 0:Fd.cwd,permissions:Ke.config,onPermissionsApplied:Ke.markApplied,model:$e,effort:lr,fastMode:cr,ultracode:dr,mcpConfig:U&&i?Kt.mcpConfigJson:null,onCodexModelRejected:Vc,onCreateSession:f.pendingDirName?Zx:void 0}),_t=d9($==="claude"?((Bd=f.sessionSource)==null?void 0:Bd.fileName)??null:null,((Ud=f.sessionSource)==null?void 0:Ud.dirName)??null);b.useEffect(()=>{_t!=null&&_t.currentMemberName?u({type:"SET_CURRENT_MEMBER_NAME",name:_t.currentMemberName}):_t||u({type:"SET_CURRENT_MEMBER_NAME",name:null})},[_t==null?void 0:_t.currentMemberName,_t,u]),b.useEffect(()=>{c&&u({type:"GUARD_MOBILE_TAB",hasSession:!!f.session||!!f.pendingDirName})},[f.session,f.pendingDirName,f.mobileTab,c,u]);const mn=Cx({session:f.session,isLive:_e,pendingMessages:dt.pendingMessages,consumePending:dt.consumePending,sessionChangeKey:f.sessionChangeKey,partialContentLen:qe}),sd=mn.chatScrollRef,od=mn.resetTurnCount,rd=mn.scrollToBottomInstant,s0=b.useCallback(Se=>{pe(Se),requestAnimationFrame(()=>{const Ge=sd.current;Ge&&Ge.scrollTo({top:Ge.scrollTop+(Se?64:-64),behavior:"smooth"})})},[sd]);b.useLayoutEffect(()=>{const Se=Ge=>{od(0),rd()};return ur.current=Se,()=>{ur.current===Se&&(ur.current=null)}},[od,rd,ur]);const o0=b.useCallback(()=>{dt.disconnect(),Qc()},[dt.disconnect,Qc]),pn=v9({dispatch:u,isMobile:c,mobileTab:f.mobileTab,teamContext:_t,scrollToBottomInstant:mn.scrollToBottomInstant,resetTurnCount:mn.resetTurnCount,workerParse:m,onBeforeSwitch:o0}),r0=b.useCallback(Se=>{b.startTransition(()=>{u({type:"GO_HOME",isMobile:c}),u({type:"SET_DASHBOARD_PROJECT",dirName:Se})})},[u,c]),{previewLoadError:i0}=S9({state:f,dispatch:u,isMobile:c,resetTurnCount:mn.resetTurnCount,scrollToBottomInstant:mn.scrollToBottomInstant,workerParse:m}),fr=A9(),id=fr.push;b.useEffect(()=>{f.sessionSource&&id(f.sessionSource.dirName,f.sessionSource.fileName)},[f.sessionSource,id]);const ct=wP({state:{session:f.session,sessionSource:f.sessionSource},dispatch:u,isMobile:c,handleJumpToTurn:pn.handleJumpToTurn,markPermissionsApplied:Ke.markApplied,hasPermsPendingChanges:Ke.hasPendingChanges,permissionsConfig:Ke.config,selectedModel:$e,selectedEffort:lr,fastMode:cr,ultracode:dr,mcpConfig:U&&i?Kt.mcpConfigJson:null,scrollRequestScrollToTop:mn.requestScrollToTop,handleDashboardSelect:pn.handleDashboardSelect,workerParse:m}),{hasSettingsChanges:ad,handleApplySettings:ld}=ct,cd=U&&i&&Kt.mcpConfigJson!==null,dd=b.useRef(!1);b.useEffect(()=>{var pt;const Se=Kt.loaded&&!dd.current;dd.current=Kt.loaded;const Ge=(pt=f.session)==null?void 0:pt.sessionId;Se&&Ge&&cd&&ad&&ld()},[Kt.loaded,cd,ad,ld,(Wd=f.session)==null?void 0:Wd.sessionId]),b.useLayoutEffect(()=>(Ce.current=ct.reloadSession,()=>{Ce.current===ct.reloadSession&&(Ce.current=null)}),[ct.reloadSession]);const jn=Lx(f.session,f.sessionSource,ct.reloadSession,a),mr=jn.requestBranchSwitch,pr=ct.setBranchModalTurn,a0=b.useCallback((Se,Ge)=>{mr(Se,Ge),pr(null)},[mr,pr]),l0=b.useCallback(Se=>{mr(Se),pr(null)},[mr,pr]);C9({isMobile:c,searchInputRef:N,chatInputRef:S,dispatch:u,onToggleSidebar:j.handleToggleSidebar,onToggleRightSidebar:j.handleToggleStats,onToggleMissionControl:j.handleToggleMission,onOpenCommandPalette:A,onOpenProjectSwitcher:j.handleOpenProjectSwitcher,onOpenThemeSelector:j.handleToggleThemeSelector,onOpenTerminal:se,onToggleIntegratedTerminal:ee,onTogglePreview:oe,onToggleProjectFiles:re,onHistoryBack:fr.goBack,onHistoryForward:fr.goForward,onNavigateToSession:pn.handleDashboardSelect,onCommitNavigation:fr.commitNavigation});const{killing:c0,handleKillAll:d0}=iP(),Wn=f.sessionSource?ss(f.sessionSource.fileName):null,u0=Wn!==null&&!!(_t!=null&&_t.currentMemberName),ea=Wn!==null&&!u0,hr=pn.handleDashboardSelect,ud=b.useCallback(()=>{!f.sessionSource||!Wn||hr(f.sessionSource.dirName,Wn.parentFileName)},[f.sessionSource,Wn,hr]);b.useEffect(()=>{const Se=Ge=>{const{agentId:pt}=Ge.detail??{};if(!pt||!f.sessionSource)return;const Zt=Wn?Wn.parentSessionId:f.sessionSource.fileName.replace(/\.jsonl$/,"");hr(f.sessionSource.dirName,`${Zt}/subagents/agent-${pt}.jsonl`)};return window.addEventListener(Qr,Se),()=>window.removeEventListener(Qr,Se)},[f.sessionSource,Wn,hr]);const[f0,fd]=b.useState(null),m0=ct.branchModalTurn!==null,ks=ct.branchModalTurn??f0;b.useEffect(()=>{ct.branchModalTurn!==null&&fd(ct.branchModalTurn)},[ct.branchModalTurn]);const md=ks!==null?jn.branchesAtTurn(ks):[],ta=ea?r.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(zo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Viewing sub-agent session (read-only)"})]}):null,p0=pn.loadError||Zc||null;let na;pn.loadError?na=pn.clearLoadError:Zc&&(na=Jx);const h0=!!(f.session&&f.sessionSource&&Be==="disconnected"),sa=b.useMemo(()=>({state:f,dispatch:u,config:e,theme:d,networkAuth:t,me:s,isMobile:c}),[f.activeTurnIndex,f.activeToolCallId,f.searchQuery,f.expandAll,f.expandToolPayloads,f.mainView,f.mobileTab,f.dashboardProject,f.pendingDirName,f.pendingCwd,f.currentMemberName,f.loadingMember,f.configFilePath,f.sessionChangeKey,u,e,d,t,s,c]),oa=b.useMemo(()=>({session:f.session,sessionSource:f.sessionSource,isLive:_e,sseState:Be,isCompacting:be,turnError:Ie,promptSuggestion:Je,undoRedo:jn,pendingInteraction:fe,permissionRequests:He.requests,permissionResponding:He.responding,respondPermission:He.respond,respondAllPermissions:He.respondAll,isSubAgentView:ea,slashSuggestions:O.suggestions,slashSuggestionsLoading:O.loading,actions:{handleStopSession:ct.handleStopSession,handleEditConfig:i?j.handleEditConfig:void 0,handleEditCommand:i?H:void 0,handleExpandCommand:i?B:void 0,handleOpenBranches:ct.handleOpenBranches,handleBranchFromHere:ct.handleBranchFromHere,handleToggleExpandAll:P,handleLoadSession:ct.handleLoadSessionScrollAware}}),[f.session,f.sessionSource,_e,Be,be,Ie,Je,jn,fe,ea,He.requests,He.responding,He.respond,He.respondAll,O.suggestions,O.loading,ct.handleStopSession,i,j.handleEditConfig,H,B,ct.handleOpenBranches,ct.handleBranchFromHere,P,ct.handleLoadSessionScrollAware]),ra=b.useMemo(()=>({chat:{status:dt.status,error:dt.error,pendingMessages:dt.pendingMessages,isConnected:dt.isConnected,sendMessage:dt.sendMessage,interrupt:dt.interrupt,stopAgent:dt.stopAgent,consumePending:dt.consumePending},scroll:mn}),[dt.status,dt.error,dt.pendingMessages,dt.isConnected,dt.sendMessage,dt.interrupt,dt.stopAgent,dt.consumePending,mn]),no=!!f.pendingDirName&&!f.session;if(b.useEffect(()=>{if(!no||c)return;const Se=requestAnimationFrame(()=>{var Ge;return(Ge=S.current)==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(Se)},[no,c,f.pendingDirName]),!t.authChecked)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Checking authentication",children:r.jsx(lt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx(GP,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(VP,{onAuthenticated:t.handleAuthenticated});if(!o)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading identity",children:r.jsx(lt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configLoading)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading",children:r.jsx(lt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-foreground",children:r.jsxs(En,{children:[r.jsxs(Pn,{children:[r.jsx(is,{variant:"icon",children:r.jsx(fn,{className:"text-destructive"})}),r.jsx(An,{children:"Failed to connect"}),r.jsx(Mn,{children:e.configError})]}),r.jsx(fp,{children:r.jsxs(X,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Ht,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(Ij,{onConfigured:e.setClaudeDir}):r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const ia=r.jsx(gb,{activeError:p0,clearActiveError:na,modelFallbackNotice:Yx,dismissModelFallbackNotice:Xx,connectionLost:h0,theme:d.activeTheme}),pd=a?r.jsx(Tj,{state:jn.confirmState,isApplying:jn.isApplying,applyError:jn.applyError,onConfirm:jn.confirmApply,onCancel:jn.confirmCancel}):null,g0=ks!==null&&f.session?f.session.turns.slice(ks):[],hd=a&&ks!==null&&md.length>0&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(JP,{open:m0,branches:md,branchPointTurnIndex:ks,currentTurns:g0,onClose:ct.handleCloseBranchModal,onCloseComplete:()=>fd(null),onRedoToTurn:a0,onRedoEntireBranch:l0})}),gd=l&&r.jsx(xj,{processes:W.processes,activeProcessId:W.activeProcessId,collapsed:W.collapsed,onSetActive:W.setActive,onRemove:W.removeProcess,onToggleCollapse:W.toggleCollapse,onRequestTerminal:at("terminal")?ie:void 0,onAddTerminalContext:Se=>{var Hd,Kd,Vd;const Ge=Se.trim();if(!Ge)return;const pt=Ge.includes("```")?"````":"```",Zt=`${pt}terminal
|
|
133
|
+
${Ge}
|
|
134
|
+
${pt}`,aa=((Hd=S.current)==null?void 0:Hd.getText().trimEnd())??"";(Kd=S.current)==null||Kd.setText(aa?`${aa}
|
|
135
|
+
|
|
136
|
+
${Zt}
|
|
137
|
+
`:`${Zt}
|
|
138
|
+
`),(Vd=S.current)==null||Vd.focus()},onUpdateStatus:W.updateProcessStatus,projectDir:V,onProcessStarted:W.addProcess,mobile:c}),xd=_t&&r.jsx(py,{teamName:_t.config.name||_t.teamName,members:_t.config.members,currentMemberName:f.currentMemberName,loadingMember:f.loadingMember,onMemberClick:pn.handleTeamMemberSwitch}),vd=ke&&r.jsx(b.Suspense,{fallback:null,children:r.jsx(ZP,{open:j.showWorkflows,onOpenChange:j.setShowWorkflows,dirName:de.dirName,sessionId:de.sessionId,workflows:Ne.workflows,isLive:Ne.isLive,onRefetchList:Ne.refetch},`${de.dirName??""}:${de.sessionId??""}`)}),gr=$&&f.session?f.session:null,bd=Se=>{var Ge;return r.jsx(cy,{agentKind:$??"claude",onAgentKindChange:no?t0:void 0,selectedModel:$e,onModelChange:We,selectedEffort:lr,onEffortChange:yt,fastModeEnabled:cr,onFastModeEnabledChange:qx?Zi:void 0,isNewSession:no,worktreeEnabled:Qx,onWorktreeEnabledChange:no&&z?e0:void 0,ultracodeEnabled:dr,onUltracodeEnabledChange:Gx?Qi:void 0,onApplySettings:ct.handleApplySettings,activeModelId:(Ge=f.session)==null?void 0:Ge.model,mcpServers:U&&i?Kt.servers:void 0,selectedMcpServers:U&&i?Kt.selectedServers:void 0,onToggleMcpServer:U&&i?Kt.toggleServer:void 0,onRefreshMcpServers:U&&i?Kt.refresh:void 0,mcpLoading:U&&i?Kt.loading:void 0,onMcpAuth:U&&i?ne:void 0,permissionMode:Ke.config.mode,onPermissionModeChange:Ke.setMode,mobileExtra:c&&Se&&gr?r.jsx(Vw,{}):void 0,trailingExtra:!c&&Se&&gr?r.jsx(xh,{}):void 0,mobile:c})},yd=bd(!0),wd=bd(!1),jd=r.jsxs("div",{className:"shrink-0 bg-background",children:[!c&&r.jsx(gh,{}),r.jsx(il,{ref:S,allowImages:Kc,agentKind:$,projectCwd:V,compact:c,leadingAccessory:c?yd:void 0}),!c&&yd]}),xr=gr&&$?r.jsx(Kw,{agentKind:$,session:gr,onSendCommand:dt.sendMessage,children:jd}):jd,x0=r.jsxs("div",{className:"shrink-0 bg-background",children:[r.jsx(il,{ref:S,allowImages:Kc,agentKind:$,projectCwd:V,compact:c,leadingAccessory:c?wd:void 0}),!c&&wd]}),Sd=dt.pendingMessages.map((Se,Ge)=>r.jsx(Sg,{message:Se,turnNumber:Ge+1},Ge)),v0=c?f.mobileTab==="stats":j.showStats,Nd=f.session&&!v0&&r.jsx("div",{className:"hidden",children:r.jsx(Ch,{cwd:f.session.cwd,turns:f.session.turns,onServersChanged:W.handleServersChanged})});return n?r.jsxs(Lr,{value:sa,children:[r.jsx(pa,{children:r.jsx(Dr,{value:oa,chatValue:ra,children:r.jsx(ka,{value:Ee,agentProgress:Ue,children:r.jsx(r9,{sessionId:n,loadError:i0,searchInputRef:N,activeComposer:ta||x0,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore})})})}),ia]}):c?r.jsxs(Lr,{value:sa,children:[r.jsx(pa,{enabled:l,children:r.jsx(Dr,{value:oa,chatValue:ra,children:r.jsx(ka,{value:Ee,agentProgress:Ue,children:r.jsx(o9,{navigation:{actions:pn,handlers:ct,creatingSession:Jc,pendingSession:td,onStartNewSession:nd,onSelectProject:D,liveSessionsRefreshRef:ed,onPrefetchSession:g},sessionView:{searchInputRef:N,teamMembersBar:xd,activeComposer:ta||xr,pendingComposer:xr,pendingTurns:Sd,todoProgress:ce&&r.jsx(Ng,{progress:ce}),hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:ud,onShowWorkflows:Pe,onToggleExpandAll:P,workflowCount:Te,pendingPath:L},project:{processPanel:W,backgroundAgents:Ze,hasFileChanges:a&&ae,onOpenTerminal:se},chrome:{backgroundServers:Nd,processPanel:gd,workflowsPanel:vd,undoDialog:pd,branchModal:hd,fileChangesOpen:ue,onFileChangesOpenChange:le,searchOpen:Me,onSearchOpenChange:Le}})})})}),ia]}):r.jsxs(Lr,{value:sa,children:[r.jsx(pa,{enabled:l,children:r.jsx(Dr,{value:oa,chatValue:ra,children:r.jsx(ka,{value:Ee,agentProgress:Ue,children:r.jsx(YE,{navigation:{panels:j,actions:pn,handlers:ct,creatingSession:Jc,pendingSession:td,onStartNewSession:nd,onStartNewFolder:n0,onSelectProject:D,onOpenPaletteProject:r0,liveSessionsRefreshRef:ed,onPrefetchSession:g},sessionView:{searchInputRef:N,chatInputRef:S,teamMembersBar:xd,activeComposer:ta||xr,pendingComposer:xr,pendingTurns:Sd,todoProgress:ce,todosExpanded:me,onTodosExpandedChange:s0,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:ud,onShowWorkflows:Pe,workflowCount:Te,fileChangesCollapsed:De,onFileChangesPanelResize:Fe},project:{processPanel:W,worktrees:we,backgroundAgents:Ze,supportsWorktrees:z,hasFileChanges:a&&ae,currentCwd:V,showPreview:q,showProjectFiles:a&&Y,projectFilesRoot:K,projectFilesRequest:J,launchTerminalRequest:Z,pendingProject:Q,onOpenTerminal:se,onTogglePreview:oe,onToggleProjectFiles:re,onCloseRightWorkspace:te},chrome:{backgroundServers:Nd,processPanel:gd,workflowsPanel:vd,undoDialog:pd,branchModal:hd,killing:c0,onKillAll:d0,commandPaletteOpen:k,onCommandPaletteOpenChange:C,onOpenCommandPalette:A,onFocusComposer:E,onExpandAll:M,onExpandToolPayloads:I,onCollapseAll:R,keyboardShortcutsOpen:T,onKeyboardShortcutsOpenChange:_}})})})}),ia]})}function eA(){var w;const[n,e]=b.useState(ut),[t,s]=b.useState(()=>Or(ut())),[o,i]=b.useState(Zn),[a,l]=b.useState(0),[c,d]=b.useState(!1),[f,u]=b.useState(!1),[m,p]=b.useState(!1),{devices:h,testDevice:g}=Gi();b.useEffect(()=>{const y=()=>{const j=ut();e(N=>N===j?N:j),s(Or(j))};return window.addEventListener("cogpit-device-changed",y),window.addEventListener("popstate",y),()=>{window.removeEventListener("cogpit-device-changed",y),window.removeEventListener("popstate",y)}},[]),b.useEffect(()=>{const y=j=>{const N=j.detail;(N==null?void 0:N.deviceId)===ut()&&s(Or(N.deviceId))};return window.addEventListener("cogpit-device-scope-changed",y),()=>window.removeEventListener("cogpit-device-scope-changed",y)},[]),b.useEffect(()=>{const y=()=>i(Zn());return window.addEventListener("cogpit-identity-changed",y),()=>window.removeEventListener("cogpit-identity-changed",y)},[]),b.useEffect(()=>(window.__cogpitRevealSession=W1,()=>{delete window.__cogpitRevealSession}),[]),b.useEffect(()=>{const y=j=>{const N=[gt,...h.map(T=>T.id)],S=ut();let k;const C=D6(j);if(C!==null)k=N[C-1];else if(L6(j)){const T=N.indexOf(S);k=N[(T+1)%N.length]}!k||k===S||(j.preventDefault(),Qn(k))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]),b.useEffect(()=>{const y=j=>{var S;const N=(S=j.detail)==null?void 0:S.deviceId;N&&N===ut()&&d(!0)};return window.addEventListener("cogpit-device-unreachable",y),()=>window.removeEventListener("cogpit-device-unreachable",y)},[]),b.useEffect(()=>{d(!1),u(!1),p(!1)},[n,t]);const v=b.useCallback(async()=>{p(!0);try{const y=await g(n);y.reachable&&y.authState==="bad-password"?u(!0):y.ok&&(d(!1),u(!1),l(j=>j+1))}finally{p(!1)}},[n,g]);b.useEffect(()=>{if(!c||f)return;const y=setInterval(()=>void v(),1e4);return()=>clearInterval(y)},[c,f,v]);const x=((w=h.find(y=>y.id===n))==null?void 0:w.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==gt&&r.jsxs(vt,{role:"status",className:"fixed inset-x-3 top-3 z-40 mx-auto max-w-2xl border-warning/40 bg-popover shadow-md",children:[r.jsx(Sv,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(At,{children:f?"Device credentials need attention":"Remote device unavailable"}),r.jsx(bt,{children:f?`${x} rejected the stored password. Update it in Devices.`:`Can’t reach ${x}. Cogpit will keep retrying.`}),r.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[!f&&r.jsxs(X,{variant:"outline",size:"xs",onClick:()=>void v(),disabled:m,children:[m&&r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),r.jsx(X,{variant:"outline",size:"xs",onClick:()=>Qn(gt),children:"Switch to this machine"})]})]}),r.jsx(uN,{children:r.jsx(aE,{children:r.jsx(QP,{})})},`${n}:${t}:${a}:${o??""}`)]})}const $m="Invalid link or passphrase.";function tA(n,e){return n===401?$m:n===429?e||"Too many attempts. Try again in a minute.":n===426?"This link needs a secure HTTPS connection. Open the tunnel URL instead of the plain http address.":n===403?"Network access is off on the host, so this session cannot be joined right now.":e||$m}function nA({sessionId:n,onAuthenticated:e}){const[t,s]=b.useState(""),[o,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(!1),f=b.useCallback(async u=>{if(u.preventDefault(),!!t.trim()){d(!0),l(null);try{const m=await fetch("/api/share/verify",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({sessionId:n,passphrase:t})}),p=await m.json();m.ok&&p.valid?(s(""),e()):l(tA(m.status,p.error))}catch{l("Failed to connect to server")}finally{d(!1)}}},[e,t,n]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:f,className:"w-full max-w-sm",children:r.jsxs(Ut,{children:[r.jsxs(Vt,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Tn,{className:"size-4"})}),r.jsx(qt,{children:"Join this session"}),r.jsx(Gt,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(Wt,{className:"flex flex-col gap-4",children:[r.jsx(Qs,{children:r.jsxs(ft,{children:[r.jsx(mt,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(Bn,{children:[r.jsx(Un,{id:"share-passphrase",type:o?"text":"password",value:t,onChange:u=>s(u.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),r.jsx(un,{align:"inline-end",children:r.jsx(er,{size:"icon-xs",onClick:()=>i(u=>!u),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(hi,{}):r.jsx(Js,{})})})]})]})}),a&&r.jsxs(vt,{variant:"destructive",children:[r.jsx(ln,{"aria-hidden":"true"}),r.jsx(At,{children:"Could not join"}),r.jsx(bt,{children:a})]})]}),r.jsx(to,{children:r.jsxs(X,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(It,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function sA(){const n=F.c(9),[e,t]=b.useState("idle"),[s,o]=b.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=b.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(v,x)=>{l(w=>[...w,v]),t("connected"),o(void 0),Nw(v,x).then(w=>{if(w.ok){t("idle");return}o(`Request failed (${w.status})`),t("error"),l(iA)}).catch(w=>{o(w instanceof Error?w.message:"Unknown error"),t("error"),l(rA)})},n[1]=c):c=n[1];const d=c;let f;n[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{kw().catch(oA),t("idle"),l([])},n[2]=f):f=n[2];const u=f;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=v=>{const x=v===void 0?1:v;l(w=>w.slice(x))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==a||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:a,isConnected:h,sendMessage:d,interrupt:u,stopAgent:u,consumePending:p},n[4]=s,n[5]=a,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function oA(){}function rA(n){return n.slice(0,-1)}function iA(n){return n.slice(0,-1)}const aA=2e3;function lA(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function cA(){const n=F.c(11);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=b.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=b.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const w=await Ew();h||w===null||s(y=>lA(y,w)?y:w)},v=()=>{document.visibilityState==="visible"&&g()};v();const x=setInterval(v,aA);return document.addEventListener("visibilitychange",v),()=>{h=!0,clearInterval(x),document.removeEventListener("visibilitychange",v)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),b.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(v=>new Set(v).add(h)),_w(h,g).then(v=>{v&&s(x=>x.filter(w=>w.requestId!==h))}).finally(()=>{a(v=>{const x=new Set(v);return x.delete(h),x})})},n[4]=d):d=n[4];const f=d;let u;n[5]!==t?(u=h=>{for(const g of t)f(g.requestId,h)},n[5]=t,n[6]=u):u=n[6];const m=u;let p;return n[7]!==t||n[8]!==m||n[9]!==i?(p={requests:t,responding:i,respond:f,respondAll:m},n[7]=t,n[8]=m,n[9]=i,n[10]=p):p=n[10],p}const Kx={authenticated:!0,edition:"personal",user:null,capabilities:Jo};function dA(n){var pe,xe;const e=F.c(78),{info:t,children:s}=n,o=Wi(),i=Ax(),[a,l]=kx(),{parse:c,append:d}=Bx(),[f,u]=b.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],b.useEffect(hA,m);const p=sA(),h=cA();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:we,source:ae}=await Tx(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:we,source:ae,isMobile:o}),u("ready")}catch{u("failed")}},e[1]=l,e[2]=t.dirName,e[3]=t.fileName,e[4]=o,e[5]=c,e[6]=g):g=e[6];const v=g,x=b.useRef(!1);let w,y;e[7]!==v?(w=()=>{x.current||(x.current=!0,v())},y=[v],e[7]=v,e[8]=w,e[9]=y):(w=e[8],y=e[9]),b.useEffect(w,y);let j;e[10]!==l?(j=we=>{l({type:"UPDATE_SESSION",session:we})},e[10]=l,e[11]=j):j=e[11];const N=j,{isLive:S,sseState:k,isCompacting:C,turnError:T}=jx(a.sessionSource,N,c,d,void 0,a.session);let _;e[12]!==l?(_=we=>{l({type:"SET_OLDER_TURNS",turns:we})},e[12]=l,e[13]=_):_=e[13];const P=_,A=((pe=a.sessionSource)==null?void 0:pe.dirName)??null,E=((xe=a.sessionSource)==null?void 0:xe.fileName)??null;let M;e[14]!==P||e[15]!==a.sessionChangeKey||e[16]!==A||e[17]!==E||e[18]!==c?(M={dirName:A,fileName:E,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:P},e[14]=P,e[15]=a.sessionChangeKey,e[16]=A,e[17]=E,e[18]=c,e[19]=M):M=e[19];const I=Ux(M);let R;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==S||e[23]!==a.session||e[24]!==a.sessionChangeKey?(R={session:a.session,isLive:S,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=S,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=R):R=e[25];const D=Cx(R),L=Lx(a.session,a.sessionSource,v,!1);let $;e[26]!==a.session?($=a.session?lg(a.session):null,e[26]=a.session,e[27]=$):$=e[27];const z=$;let U;e[28]!==l?(U=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=U):U=e[29];const O=U,H=mA,B=fA;let W;e[30]!==t.dirName?(W=Jt(t.dirName)??"claude",e[30]=t.dirName,e[31]=W):W=e[31];let V;e[32]!==W?(V={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:W,setClaudeDir:B,showConfigDialog:!1,openConfigDialog:B,handleCloseConfigDialog:B,handleConfigSaved:B,retryConfig:B,networkUrl:null,networkAccessDisabled:!1},e[32]=W,e[33]=V):V=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q={isRemote:ji(),edition:"personal",authChecked:!0,authenticated:!0,needsBootstrap:!1,handleAuthenticated:B,refreshServerState:uA,logout:B},e[34]=q):q=e[34];let Y;e[35]!==l||e[36]!==o||e[37]!==a||e[38]!==V||e[39]!==i?(Y={state:a,dispatch:l,config:V,theme:i,networkAuth:q,me:Kx,isMobile:o},e[35]=l,e[36]=o,e[37]=a,e[38]=V,e[39]=i,e[40]=Y):Y=e[40];const K=Y;let J;e[41]===Symbol.for("react.memo_cache_sentinel")?(J=[],e[41]=J):J=e[41];let Z;e[42]!==O?(Z={handleStopSession:H,handleOpenBranches:B,handleBranchFromHere:B,handleToggleExpandAll:O,handleLoadSession:B},e[42]=O,e[43]=Z):Z=e[43];let Q;e[44]!==C||e[45]!==S||e[46]!==z||e[47]!==h.requests||e[48]!==h.respond||e[49]!==h.respondAll||e[50]!==h.responding||e[51]!==k||e[52]!==a.session||e[53]!==a.sessionSource||e[54]!==Z||e[55]!==T||e[56]!==L?(Q={session:a.session,sessionSource:a.sessionSource,isLive:S,sseState:k,isCompacting:C,turnError:T,undoRedo:L,pendingInteraction:z,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:J,slashSuggestionsLoading:!1,promptSuggestion:null,actions:Z},e[44]=C,e[45]=S,e[46]=z,e[47]=h.requests,e[48]=h.respond,e[49]=h.respondAll,e[50]=h.responding,e[51]=k,e[52]=a.session,e[53]=a.sessionSource,e[54]=Z,e[55]=T,e[56]=L,e[57]=Q):Q=e[57];const se=Q;let ne;e[58]!==p||e[59]!==D?(ne={chat:p,scroll:D},e[58]=p,e[59]=D,e[60]=ne):ne=e[60];const ee=ne;let ie;e[61]!==I?(ie=()=>{I.loadMore()},e[61]=I,e[62]=ie):ie=e[62];let oe;e[63]!==f||e[64]!==I.hasMore||e[65]!==I.isLoadingOlder||e[66]!==ie?(oe={loadState:f,hasMore:I.hasMore,isLoadingOlder:I.isLoadingOlder,loadMore:ie},e[63]=f,e[64]=I.hasMore,e[65]=I.isLoadingOlder,e[66]=ie,e[67]=oe):oe=e[67];const re=oe;let te;e[68]!==s||e[69]!==re?(te=s(re),e[68]=s,e[69]=re,e[70]=te):te=e[70];let ce;e[71]!==ee||e[72]!==se||e[73]!==te?(ce=r.jsx(Dr,{value:se,chatValue:ee,children:te}),e[71]=ee,e[72]=se,e[73]=te,e[74]=ce):ce=e[74];let me;return e[75]!==K||e[76]!==ce?(me=r.jsx(Lr,{value:K,children:ce}),e[75]=K,e[76]=ce,e[77]=me):me=e[77],me}function uA(){return Promise.resolve()}function fA(){}async function mA(){await Cw().catch(pA)}function pA(){}function hA(){zs(Kx)}function gA(n){const e=F.c(6),{info:t}=n,s=b.useRef(null);let o;e[0]!==t.provider||e[1]!==t.title?(o=a=>r.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-background",children:[r.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[r.jsx(Tn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:t.title}),r.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:"Guest view"})]}),a.loadState==="failed"?r.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:r.jsxs(vt,{variant:"destructive",className:"max-w-sm",children:[r.jsx(ln,{"aria-hidden":"true"}),r.jsx(At,{children:"Session unavailable"}),r.jsx(bt,{children:"This conversation could not be loaded. It may have been deleted on the host."})]})}):a.loadState==="loading"?r.jsx("div",{className:"flex flex-1 items-center justify-center",role:"status","aria-label":"Loading shared session",children:r.jsx(It,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(qi,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(Xi,{children:r.jsx(il,{agentKind:t.provider,projectCwd:null})})]})]}),e[0]=t.provider,e[1]=t.title,e[2]=o):o=e[2];let i;return e[3]!==t||e[4]!==o?(i=r.jsx(dA,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function Ga(n){const e=F.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function xA(){const n=F.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=fh(window.location.pathname),n[0]=e):e=n[0];const t=e;let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=t?{kind:"probing"}:{kind:"error",message:"This share link is not valid."},n[1]=s):s=n[1];const[o,i]=b.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await Sw();i(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=a):a=n[2];const l=a;let c,d;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},d=[l,t],n[3]=c,n[4]=d):(c=n[3],d=n[4]),b.useEffect(c,d);let f,u;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{i(vA)};return window.addEventListener(rl,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(rl,p),window.removeEventListener("cogpit-auth-required",p)}},u=[],n[5]=f,n[6]=u):(f=n[5],u=n[6]),b.useEffect(f,u),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(gA,{info:o.info}),n[7]=o.info,n[8]=p):p=n[8],p}if(o.kind==="login"&&t){let p;return n[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(nA,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(o.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Ga,{children:r.jsx(Ut,{children:r.jsxs(Vt,{children:[r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Nv,{className:"size-4"})}),r.jsx(qt,{children:"Sharing has ended"}),r.jsx(Gt,{children:"The host stopped sharing this session or changed its passphrase. Ask for a new link to rejoin."})]})})}),n[10]=p):p=n[10],p}if(o.kind==="error"){let p,h;n[11]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(ln,{"aria-hidden":"true"}),h=r.jsx(At,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==o.message?(g=r.jsxs(vt,{variant:"destructive",children:[p,h,r.jsx(bt,{children:o.message})]}),n[13]=o.message,n[14]=g):g=n[14];let v;n[15]===Symbol.for("react.memo_cache_sentinel")?(v=t&&r.jsx(X,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=v):v=n[15];let x;return n[16]!==g?(x=r.jsxs(Ga,{children:[g,v]}),n[16]=g,n[17]=x):x=n[17],x}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ga,{children:r.jsx(Ut,{children:r.jsxs(Wt,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(Tn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(It,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function vA(n){return n.kind==="ready"?{kind:"ended"}:n}class bA extends b.Component{constructor(){super(...arguments);vr(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,s){console.error("[Cogpit] Unhandled render error",t,s.componentStack)}render(){if(!this.state.error)return this.props.children;const t=this.state.error.message||"An unexpected render error occurred.";return r.jsx("main",{className:"flex h-dvh items-center justify-center bg-background p-6 text-foreground",children:r.jsxs(Ut,{className:"w-full max-w-lg text-center",children:[r.jsxs(Vt,{className:"justify-items-center",children:[r.jsx(fn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(qt,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(Gt,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(Wt,{children:r.jsx("pre",{className:"max-h-40 w-full overflow-auto rounded-md bg-muted p-3 text-left font-mono text-xs whitespace-pre-wrap",children:t})}),r.jsx(to,{className:"justify-center",children:r.jsxs(X,{onClick:()=>window.location.reload(),children:[r.jsx(Ht,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Vx=document.getElementById("root");if(!Vx)throw new Error("Root element not found");S0.createRoot(Vx).render(r.jsx(b.StrictMode,{children:r.jsx(bA,{children:Ri(window.location.pathname)?r.jsx(xA,{}):r.jsx(eA,{})})}));export{rc as $,vt as A,X as B,_A as C,On as D,En as E,d_ as F,An as G,Mn as H,un as I,Bp as J,Vi as K,Ci as L,zp as M,Fp as N,Lp as O,ht as P,mw as Q,cn as R,ny as S,G as T,Oe as U,Yo as V,wt as W,dn as X,jt as Y,sc as Z,oc as _,sy as a,St as a$,kj as a0,ac as a1,lc as a2,ic as a3,dc as a4,cc as a5,ds as a6,Gi as a7,Qs as a8,ft as a9,Ko as aA,LA as aB,mt as aC,Ks as aD,YT as aE,Rj as aF,Pt as aG,Y6 as aH,kA as aI,Hi as aJ,Vt as aK,qt as aL,Wt as aM,to as aN,Ut as aO,Di as aP,hg as aQ,Ss as aR,wn as aS,qs as aT,vn as aU,At as aV,Gt as aW,_h as aX,tc as aY,u9 as aZ,Ti as a_,er as aa,Jn as ab,s1 as ac,o1 as ad,Mt as ae,yw as af,$o as ag,It as ah,XC as ai,hl as aj,Rc as ak,Ii as al,Dp as am,tr as an,Dh as ao,pc as ap,Ia as aq,$6 as ar,Uy as as,CA as at,nc as au,vs as av,at as aw,mc as ax,Ah as ay,Mh as az,oy as b,Nt as b0,kt as b1,Fi as b2,Bi as b3,Ui as b4,Ws as b5,PA as b6,Bt as b7,Io as b8,jj as b9,Vn as ba,Ob as bb,EA as bc,Cc as bd,zg as be,Tc as bf,Dg as bg,ki as bh,fN as bi,lE as bj,nx as bk,zi as bl,ns as bm,J4 as bn,ty as c,Xb as d,AA as e,I6 as f,MA as g,Dn as h,as as i,Ln as j,zn as k,Et as l,Bn as m,Un as n,$A as o,bt as p,Qo as q,IA as r,OA as s,DA as t,RA as u,ux as v,ye as w,TA as x,Pn as y,is as z};
|