cogpit 2.1.1 → 2.1.2
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/dist/cli.js +1 -1
- package/dist/web/assets/{CommandPaletteHost-Bfg_Eihd.js → CommandPaletteHost-Bq0_FFr0.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-Dc7sWHDS.js → ConfigBrowser-DmOlS3cU.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-f230XyPa.js → HighlightedEditor-BYfv1SYX.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-Bu1kIaBx.js → KeyboardShortcutsDialog-YDYAOpa5.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-CiZ45577.js → MobileFileChanges-Bb3zEFSH.js} +1 -1
- package/dist/web/assets/{PreviewPanel-CaYEItEH.js → PreviewPanel-B9CQNmuh.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-kXGeC2Kp.js → ProjectFilesPanel-C3jKD37-.js} +1 -1
- package/dist/web/assets/{ProjectSwitcherModal-DulA-4x-.js → ProjectSwitcherModal-CxbGrX7A.js} +1 -1
- package/dist/web/assets/{TerminalOutput-jlukYn0_.js → TerminalOutput-LwRcBZWA.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-CklkGcoT.js → ThemeSelectorModal-BG_Jah0i.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-B1JVdvuy.js → WorkflowsPanel-CiZjrfSd.js} +1 -1
- package/dist/web/assets/{WorktreePanel-CC8kT63h.js → WorktreePanel-gR-fCesa.js} +1 -1
- package/dist/web/assets/{index-cAtUK6__.js → index-BaKcHvT2.js} +1 -1
- package/dist/web/assets/{index-BXfuxlSt.js → index-C_pb6rZe.js} +1 -1
- package/dist/web/assets/{index-I4CawQjt.js → index-D-Mg0tNr.js} +7 -7
- package/dist/web/assets/{index-DHjlP4ip.js → index-EmT8Vg0x.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +2 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-LwRcBZWA.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-Bg9q4lA4.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-Bq0_FFr0.js","assets/index-C_pb6rZe.js","assets/KeyboardShortcutsDialog-YDYAOpa5.js","assets/ProjectSwitcherModal-CxbGrX7A.js","assets/ThemeSelectorModal-BG_Jah0i.js","assets/WorktreePanel-gR-fCesa.js","assets/index-BaKcHvT2.js","assets/ConfigBrowser-DmOlS3cU.js","assets/HighlightedEditor-BYfv1SYX.js","assets/PreviewPanel-B9CQNmuh.js","assets/ProjectFilesPanel-C3jKD37-.js","assets/MobileFileChanges-Bb3zEFSH.js","assets/index-EmT8Vg0x.js","assets/WorkflowsPanel-CiZjrfSd.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var nb=Object.defineProperty;var sb=(n,e,t)=>e in n?nb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Hr=(n,e,t)=>sb(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as be,e as ob,r as v,a as rb,f as ib}from"./vendor-react-gGw_S5I_.js";import{at as ab,au as lb,av as cb,aw as Bn,a0 as rt,ax as db,m as jn,ay as ub,aq as Un,az as Up,aA as fb,aB as mb,aC as pb,aD as Wp,aE as Hp,aF as bc,aG as Kp,aH as qp,aI as Vp,aJ as hb,O as dt,aK as gb,aL as xb,aM as bb,aN as vb,J as pr,ab as co,a9 as st,c as Qt,ah as yb,aO as Gp,aP as vi,G as vo,aQ as wb,aR as jb,aS as Sb,aT as kb,aU as Nb,aV as Cb,aW as _b,aX as Tb,aY as Eb,aZ as Pb,a_ as Ab,a$ as Rb,b0 as Mb,b1 as Ib,b2 as hr,b3 as Yp,b4 as vc,b5 as yc,b6 as wc,b7 as jc,b8 as Wi,X as jt,b9 as Sc,ba as $b,N as kc,bb as Wn,bc as Ob,bd as Xp,be as Jp,bf as ro,bg as ws,bh as Db,bi as Lb,bj as zb,bk as Fb,bl as Xo,S as bn,B as uo,b as Qp,bm as Ls,bn as Zp,bo as Bb,bp as Ub,bq as Wb,a1 as Hi,br as Hb,a6 as Ki,aj as Il,W as yo,bs as Bu,bt as Kb,bu as qb,bv as Vb,bw as Gb,bx as Yb,by as Xb,bz as Jb,bA as Nc,bB as Qb,bC as vn,D as Pn,bD as Zb,bE as ev,bF as tv,bG as nv,bH as Jo,bI as gr,bJ as sv,T as qi,bK as ov,bL as rv,bM as iv,bN as av,bO as lv,bP as cv,bQ as dv,bR as uv,bS as fv,bT as mv,C as Ze,P as Tn,A as wo,g as eh,bU as pv,bV as hv,bW as gv,bX as xv,F as Qo,a2 as zs,bY as bv,bZ as th,a4 as Cc,j as Vi,V as Gi,b_ as vv,b$ as nh,c0 as $l,c1 as yv,c2 as wv,c3 as jv,a3 as _c,R as Tc,c4 as Sv,c5 as kv,a7 as Is,E as sh,c6 as Nv,v as Yi,c7 as Xi,c8 as Cv,c9 as _v,ca as oh,cb as Tv,cc as Ev,cd as Kr,ce as Cs,a8 as Ka,af as Uu,e as xr,cf as Pv,ac as Av,cg as Rv,ar as Mv,w as Ji,ch as Iv,ci as $v,cj as Ov,ck as Dv,cl as Lv,cm as zv,cn as rh,co as Fv,cp as Bv,ao as Uv,r as Wu,cq as Wv,cr as Hu,p as Qi,cs as Hv,ct as ih,d as ah,I as lh,cu as Kv,ad as ch,u as qv,cv as Vv,cw as dh,L as Gv,z as Yv,cx as Xv,cy as Jv,s as uh,as as fh,y as Qv,cz as Zv,cA as ey,cB as ty,cC as ny,cD as sy,cE as Ku,cF as oy,am as ry,cG as iy,_ as ay,cH as ly}from"./vendor-ui-Bg9q4lA4.js";import{c as cy,a as dy}from"./vendor-shiki-DOn6sF-i.js";import{r as Zi,M as An}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 uy="modulepreload",fy=function(n){return"/"+n},qu={},Ke=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=fy(d),d in qu)return;qu[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":uy,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)})},ms=["codex","copilot","claude"],Ol="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function my(n,e){const t=new TextEncoder().encode(e);let s="";for(const i of t)s+=String.fromCharCode(i);const o=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${o}`}function py(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),o=Uint8Array.from(s,i=>i.charCodeAt(0));return new TextDecoder().decode(o)}catch{return null}}function mh(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>my(n,e),decode:e=>py(n,e)}}function ph(n){const e=new RegExp(`(${Ol})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const hh={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function gh(n){return`'${n.replace(/'/g,"'\\''")}'`}function Zo(n,e){return e?[n,e]:[]}function yi(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const wi="[0-9a-f-]{36}",xh="codex__",bh="copilot__",hy=new Set(["default","plan","acceptEdits","dontAsk","auto"]),vh={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(xh)&&!n.startsWith(bh),encode:n=>(n.replace(/[\\/]+$/,"")||n).replace(/[^a-zA-Z0-9]/g,"-"),decode:n=>{const e=/^([A-Za-z])--(.*)$/.exec(n);return e?`${e[1]}:\\${e[2].replace(/-/g,"\\")}`:"/"+n.replace(/^-/,"").replace(/-/g,"/")}},sessionFile:{name:n=>`${n}.jsonl`,sessionId:ph,...hh},metadataFromHead:!0,resume:{command:n=>`claude --resume ${n}`,args:n=>["--resume",n]},launchArgs:{permissions:n=>n!=null&&n.mode?n.mode==="bypassPermissions"?["--dangerously-skip-permissions"]:[...hy.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>Zo("--model",n),effort:n=>Zo("--effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@anthropic-ai/claude-code",homebrew:{name:"claude-code",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/claude")||n.endsWith("/.local/bin/claude.exe")||n.includes("/.local/share/claude/")},homeDirName:".claude",homeEnvVar:null,installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>yi(n,new RegExp(`--resume(?:=|\\s+)(${wi})`))??yi(n,new RegExp(`--session-id(?:=|\\s+)(${wi})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]}],settings:[{in:"root",path:"settings.json",scopes:["global"]},{in:"root",path:"settings.local.json",scopes:["project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"commands",themesDir:"themes",pluginsDir:"plugins"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!1,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,modelFallbackNotices:!0,autoPermissionMode:"per-model",settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},Vu={appServerValue:"priority",cliConfigValue:"fast"},gy={kind:"codex",displayName:"Codex",binName:"codex",dirName:mh(xh),sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${o}/rollout-${t}-${s}-${o}T${i}-${a}-${l}-${n}.jsonl`},sessionId:ph,...hh},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${gh(e)} resume ${n}`:`codex resume ${n}`,args:n=>["resume",n]},launchArgs:{permissions: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"']},model:n=>Zo("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(Vu.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:Vu,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,homeDirName:".codex",homeEnvVar:"CODEX_HOME",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>yi(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${wi})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,fastTier:!0,imageInput:!0,planMode:!0,midTurnSteering:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,modelFallbackNotices:!1,autoPermissionMode:"never",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}},xy={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:mh(bh),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${Ol})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${Ol})/events\\.jsonl$`,"i").exec(n);return e?e[1]:n.replace(/\.jsonl$/,"")},fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${gh(e)} --resume ${n}`:`copilot --resume ${n}`,args:n=>[`--resume=${n}`]},launchArgs:{permissions:n=>(n==null?void 0:n.mode)==="bypassPermissions"||(n==null?void 0:n.mode)==="auto"?["--allow-all"]:[],model:n=>Zo("--model",n),effort:n=>Zo("--reasoning-effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@github/copilot",homebrew:{name:"copilot-cli",cask:!0},wingetId:"GitHub.Copilot",versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/copilot")||n==="/usr/local/bin/copilot"},homeDirName:".copilot",homeEnvVar:"COPILOT_HOME",installMarker:"session-state",homeIsDiscoverable:!0,process:{by:"executable",sessionIdFromCommand:n=>yi(n,new RegExp(`--resume(?:=|\\s+)(${wi})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,fastTier:!1,imageInput:!1,planMode:!0,midTurnSteering:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},er=Object.freeze({claude:vh,codex:gy,copilot:xy});function Zt(n){return er[n]}function ea(){return ms.map(n=>er[n])}function by(n,e){const t=ea().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function js(n){for(const e of ms)if(e!=="claude"&&er[e].dirName.owns(n))return er[e];return vh}function St(n){return js(n).kind}function qa(n,e,t){const s=er[n].dirName;return t&&s.lossy?t:s.encode(e)}const Fs=js(null).kind;var Fp;const qr=((Fp=ea().find(n=>n.dirName.lossy))==null?void 0:Fp.kind)??null;function fo(n){return js(n).capabilities}function Ut(n){return Zt(n).capabilities}function vy(n,e){return ms.find(t=>t===n)??e}function Dl(n){for(const e of ea()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function yy(n,e){return js(n).sessionFile.urlId(e)}function wy(n,e){return js(n).sessionFile.fileNameFromUrlId(e)}function yh(n,e,t){return Zt(n).resume.command(e,t)}function jy(n,e){const t=Zt(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Gu(n){return n.replace(/\/+$/,"")||"/"}function Sy(n,e,t){var o;const s=Gu(e);return((o=n.find(i=>js(i.dirName).kind===t&&Gu(i.path)===s))==null?void 0:o.dirName)??null}const ky=[{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"}],Ec=[{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"}],wh=[...Ec,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],Vr=Ec.slice(0,4);var Bp;const $o=[{value:((Bp=Zt("codex").serviceTier)==null?void 0:Bp.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],Yu={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:wh,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:$o},Ny=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...Yu},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...Yu},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:wh,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:$o},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:Ec,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:$o},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:Vr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:$o},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:Vr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:$o},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:Vr,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:Vr,inputModalities:["text"],supportsPersonality:!0}],Cy=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],_y={claude:ky,codex:Ny,copilot:Cy};function Ty(n){return _y[n]}function G(...n){return ab(lb(n))}const jh=new Map,Ll=new Set;function Ey(n,e){!Array.isArray(e)||e.length===0||(jh.set(n,e),Ll.forEach(t=>t()))}function Py(n){return Ll.add(n),()=>Ll.delete(n)}const Va="high",Ay=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function Sh(n){return jh.get(n)??Ty(n)}function br(n,e){const t=Sh(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 kh(n,e){const t=br(n,e),s=t==null?void 0:t.supportedReasoningEfforts;return s&&s.length>0?s:(t==null?void 0:t.supportsEffort)===!1||!Ut(n).reasoningEffort?[]:Ay}function Ry(n,e){var t;return((t=br(n,e))==null?void 0:t.serviceTiers)??[]}function Nh(n,e){return Ry(n,e).find(t=>t.value==="fast"||t.value==="priority"||t.label.toLowerCase()==="fast")}function My(n,e){var s;const t=(s=br(n,e))==null?void 0:s.inputModalities;return t?t.includes("image"):Ut(n).imageInput}function Iy(n,e){var s;const t=Ut(n).autoPermissionMode;return t==="always"?!0:t==="never"?!1:((s=br(n,e))==null?void 0:s.supportsAutoMode)===!0}function $y(n,e){return Ut(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function ta(n,e,t){var l,c;const s=kh(n,t);if(s.length===0)return"";const o=(l=br(n,t))==null?void 0:l.defaultReasoningEffort,i=o&&s.some(d=>d.value===o)?o:s.some(d=>d.value===Va)?Va:((c=s[0])==null?void 0:c.value)??Va,a=e||i;return s.some(d=>d.value===a)?a:i}function Oy(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function vr(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 Dy=Bn("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 J(n){const e=B.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(Dy({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(cb,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Hn(n){const e=B.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 Kn(n){const e=B.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 Ly=Bn("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 Ss(n){const e=B.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(Ly({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 qn(n){const e=B.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 Vn(n){const e=B.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 Ch(n){const e=B.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 zy(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 Fy=n=>{switch(n){case"success":return Wy;case"info":return Ky;case"warning":return Hy;case"error":return qy;default:return null}},By=Array(12).fill(0),Uy=({visible:n,className:e})=>be.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},be.createElement("div",{className:"sonner-spinner"},By.map((t,s)=>be.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),Wy=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),Hy=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),Ky=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),qy=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},be.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"})),Vy=be.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"},be.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),be.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Gy=()=>{const[n,e]=be.useState(document.hidden);return be.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let Yy=1;const Xy=100,Xu=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:Yy++};class Jy{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-Xy;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=Xu(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],be.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(Zy(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"&&!be.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"&&!be.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"&&!be.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"&&!be.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=Xu(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 Kt=new Jy,Qy=(n,e)=>Kt.message(n,e),Zy=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",ew=Qy,tw=()=>Kt.toasts,nw=()=>Kt.getActiveToasts(),_s=Object.assign(ew,{success:Kt.success,info:Kt.info,warning:Kt.warning,error:Kt.error,custom:Kt.custom,message:Kt.message,promise:Kt.promise,dismiss:Kt.dismiss,loading:Kt.loading},{getHistory:tw,getToasts:nw});zy("[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 Gr(n){return n.label!==void 0}const sw=3,ow="24px",rw="16px",Ju=4e3,iw=356,aw=14,lw=45,cw=200;function Nn(...n){return n.filter(Boolean).join(" ")}function dw(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const uw=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:x,index:b,toasts:w,expanded:y,removeToast:j,defaultRichColors:k,closeButton:N,style:C,cancelButtonStyle:S,actionButtonStyle:_,className:P="",descriptionClassName:A="",duration:T,position:E,gap:M,expandByDefault:I,classNames:R,icons:$,closeButtonAriaLabel:D="Close toast"}=n,[O,L]=be.useState(null),[F,z]=be.useState(null),[H,U]=be.useState(!1),[W,K]=be.useState(!1),[q,Y]=be.useState(!1),[V,Q]=be.useState(!1),[Z,X]=be.useState(!1),[ee,oe]=be.useState(0),[se,re]=be.useState(0),ie=be.useRef(u.duration||T||Ju),ae=be.useRef(null),te=be.useRef(null),he=b===0,me=b+1<=g,le=u.type,xe=le??"default",ge=u.dismissible!==!1,ce=u.className||"",we=u.descriptionClassName||"",pe=be.useMemo(()=>x.findIndex(ne=>ne.toastId===u.id)||0,[x,u.id]),ue=be.useMemo(()=>{var ne;return(ne=u.closeButton)!=null?ne:N},[u.closeButton,N]),je=be.useMemo(()=>u.duration||T||Ju,[u.duration,T]),Ne=be.useRef(0),Re=be.useRef(0),Te=be.useRef(0),Pe=be.useRef(null),[Oe,Fe]=E.split("-"),ze=be.useMemo(()=>x.reduce((ne,fe,Se)=>Se>=pe?ne:ne+fe.height,0),[x,pe]),Be=Gy(),_e=be.useMemo(()=>{var ne;return(ne=n.swipeDirections)!=null?ne:dw(E)},[n.swipeDirections,E]),He=u.invert||f,Ie=le==="loading";Re.current=be.useMemo(()=>pe*M+ze,[pe,ze]),be.useEffect(()=>{ie.current=je},[je]),be.useEffect(()=>{U(!0)},[]),be.useEffect(()=>{const ne=te.current;if(ne){const fe=ne.getBoundingClientRect().height;return re(fe),h(Se=>[{toastId:u.id,height:fe,position:u.position},...Se]),()=>h(Se=>Se.filter($e=>$e.toastId!==u.id))}},[h,u.id]),be.useLayoutEffect(()=>{if(!H)return;const ne=te.current,fe=ne.style.height;ne.style.height="auto";const Se=ne.getBoundingClientRect().height;ne.style.height=fe,re(Se),h($e=>$e.find(We=>We.toastId===u.id)?$e.map(We=>We.toastId===u.id?{...We,height:Se}:We):[{toastId:u.id,height:Se,position:u.position},...$e])},[H,u.title,u.description,h,u.id,u.jsx,u.action,u.cancel]);const Ce=be.useCallback(()=>{K(!0),oe(Re.current),h(ne=>ne.filter(fe=>fe.toastId!==u.id)),setTimeout(()=>{j(u)},cw)},[u,j,h,Re]);be.useEffect(()=>{if(u.promise&&le==="loading"||u.duration===1/0||u.type==="loading")return;let ne;return y||p||Be?(()=>{if(Te.current<Ne.current){const $e=new Date().getTime()-Ne.current;ie.current=ie.current-$e}Te.current=new Date().getTime()})():(()=>{ie.current!==1/0&&(Ne.current=new Date().getTime(),ne=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Ce()},ie.current))})(),()=>clearTimeout(ne)},[y,p,u,le,Be,Ce]),be.useEffect(()=>{u.delete&&(Ce(),u.onDismiss==null||u.onDismiss.call(u,u))},[Ce,u.delete]);function de(){var ne;if($!=null&&$.loading){var fe;return be.createElement("div",{className:Nn(R==null?void 0:R.loader,u==null||(fe=u.classNames)==null?void 0:fe.loader,"sonner-loader"),"data-visible":le==="loading"},$.loading)}return be.createElement(Uy,{className:Nn(R==null?void 0:R.loader,u==null||(ne=u.classNames)==null?void 0:ne.loader),visible:le==="loading"})}const Ee=u.icon||($==null?void 0:$[le])||Fy(le);var Ae,Le;return be.createElement("li",{tabIndex:0,ref:te,className:Nn(P,ce,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":(Ae=u.richColors)!=null?Ae:k,"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":Oe,"data-x-position":Fe,"data-index":b,"data-front":he,"data-swiping":q,"data-dismissible":ge,"data-type":le,"data-invert":He,"data-swipe-out":V,"data-swipe-direction":F,"data-expanded":!!(y||I&&H),"data-testid":u.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${W?ee:Re.current}px`,"--initial-height":I?"auto":`${se}px`,...C,...u.style},onDragEnd:()=>{Y(!1),L(null),Pe.current=null},onPointerDown:ne=>{ne.button!==2&&(Ie||!ge||(ae.current=new Date,oe(Re.current),ne.target.setPointerCapture(ne.pointerId),ne.target.tagName!=="BUTTON"&&(Y(!0),Pe.current={x:ne.clientX,y:ne.clientY})))},onPointerUp:()=>{var ne,fe,Se;if(V||!ge)return;Pe.current=null;const $e=Number(((ne=te.current)==null?void 0:ne.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ue=Number(((fe=te.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),We=new Date().getTime()-((Se=ae.current)==null?void 0:Se.getTime()),Xe=O==="x"?$e:Ue,Je=Math.abs(Xe)/We;if((O==="x"?_e.includes($e>0?"right":"left"):_e.includes(Ue>0?"bottom":"top"))&&(Math.abs(Xe)>=lw||Je>.11)){oe(Re.current),u.onDismiss==null||u.onDismiss.call(u,u),z(O==="x"?$e>0?"right":"left":Ue>0?"down":"up"),Ce(),Q(!0);return}else{var qe,ot;(qe=te.current)==null||qe.style.setProperty("--swipe-amount-x","0px"),(ot=te.current)==null||ot.style.setProperty("--swipe-amount-y","0px")}X(!1),Y(!1),L(null)},onPointerMove:ne=>{var fe,Se,$e;if(!Pe.current||!ge||((fe=window.getSelection())==null?void 0:fe.toString().length)>0)return;const We=ne.clientY-Pe.current.y,Xe=ne.clientX-Pe.current.x;!O&&(Math.abs(Xe)>1||Math.abs(We)>1)&&L(Math.abs(Xe)>Math.abs(We)?"x":"y");let Je={x:0,y:0};const De=qe=>1/(1.5+Math.abs(qe)/20);if(O==="y"){if(_e.includes("top")||_e.includes("bottom"))if(_e.includes("top")&&We<0||_e.includes("bottom")&&We>0)Je.y=We;else{const qe=We*De(We);Je.y=Math.abs(qe)<Math.abs(We)?qe:We}}else if(O==="x"&&(_e.includes("left")||_e.includes("right")))if(_e.includes("left")&&Xe<0||_e.includes("right")&&Xe>0)Je.x=Xe;else{const qe=Xe*De(Xe);Je.x=Math.abs(qe)<Math.abs(Xe)?qe:Xe}(Math.abs(Je.x)>0||Math.abs(Je.y)>0)&&X(!0),(Se=te.current)==null||Se.style.setProperty("--swipe-amount-x",`${Je.x}px`),($e=te.current)==null||$e.style.setProperty("--swipe-amount-y",`${Je.y}px`)}},ue&&!u.jsx&&le!=="loading"?be.createElement("button",{"aria-label":D,"data-disabled":Ie,"data-close-button":!0,onClick:Ie||!ge?()=>{}:()=>{Ce(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Nn(R==null?void 0:R.closeButton,u==null||(s=u.classNames)==null?void 0:s.closeButton)},(Le=$==null?void 0:$.close)!=null?Le:Vy):null,(le||u.icon||u.promise)&&u.icon!==null&&(($==null?void 0:$[le])!==null||u.icon)?be.createElement("div",{"data-icon":"",className:Nn(R==null?void 0:R.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},le==="loading"?u.icon||de():u.promise?de():null,le!=="loading"?Ee:null):null,be.createElement("div",{"data-content":"",className:Nn(R==null?void 0:R.content,u==null||(i=u.classNames)==null?void 0:i.content)},be.createElement("div",{"data-title":"",className:Nn(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?be.createElement("div",{"data-description":"",className:Nn(A,we,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),be.isValidElement(u.cancel)?u.cancel:u.cancel&&Gr(u.cancel)?be.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||S,onClick:ne=>{Gr(u.cancel)&&ge&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,ne),Ce())},className:Nn(R==null?void 0:R.cancelButton,u==null||(c=u.classNames)==null?void 0:c.cancelButton)},u.cancel.label):null,be.isValidElement(u.action)?u.action:u.action&&Gr(u.action)?be.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||_,onClick:ne=>{Gr(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,ne),!ne.defaultPrevented&&Ce())},className:Nn(R==null?void 0:R.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function Qu(){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 fw(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?rw:ow;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 mw=be.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:x=sw,toastOptions:b,dir:w=Qu(),gap:y=aw,icons:j,customAriaLabel:k,containerAriaLabel:N="Notifications"}=e,[C,S]=be.useState([]),_=be.useMemo(()=>s?C.filter(U=>U.toasterId===s):C.filter(U=>!U.toasterId),[C,s]),P=be.useMemo(()=>Array.from(new Set([i].concat(_.filter(U=>U.position).map(U=>U.position)))),[_,i]),[A,T]=be.useState([]),[E,M]=be.useState(!1),[I,R]=be.useState(!1),[$,D]=be.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=be.useRef(null),L=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=be.useRef(null),z=be.useRef(!1),H=be.useCallback(U=>{S(W=>{var K;return(K=W.find(q=>q.id===U.id))!=null&&K.delete||Kt.dismiss(U.id),W.filter(({id:q})=>q!==U.id)})},[]);return be.useEffect(()=>Kt.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{S(W=>W.map(K=>K.id===U.id?{...K,delete:!0}:K))});return}setTimeout(()=>{ob.flushSync(()=>{S(W=>{const K=W.findIndex(q=>q.id===U.id);return K!==-1?[...W.slice(0,K),{...W[K],...U},...W.slice(K+1)]:[U,...W]})})})}),[]),be.useEffect(()=>{if(m!=="system"){D(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?D("dark"):D("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:W})=>{D(W?"dark":"light")})}catch{U.addListener(({matches:K})=>{try{D(K?"dark":"light")}catch(q){console.error(q)}})}},[m]),be.useEffect(()=>{C.length<=1&&M(!1)},[C]),be.useEffect(()=>{const U=W=>{var K;if(a.length>0&&a.every(V=>W[V]||W.code===V)){var Y;M(!0),(Y=O.current)==null||Y.focus()}W.code==="Escape"&&(document.activeElement===O.current||(K=O.current)!=null&&K.contains(document.activeElement))&&M(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[a]),be.useEffect(()=>{if(O.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,z.current=!1)}},[O.current]),be.createElement("section",{ref:t,"aria-label":k??`${N} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},P.map((U,W)=>{var K;const[q,Y]=U.split("-");return _.length?be.createElement("ol",{key:U,dir:w==="auto"?Qu():w,tabIndex:-1,ref:O,className:d,"data-sonner-toaster":!0,"data-sonner-theme":$,"data-y-position":q,"data-x-position":Y,style:{"--front-toast-height":`${((K=A[0])==null?void 0:K.height)||0}px`,"--width":`${iw}px`,"--gap":`${y}px`,...g,...fw(f,u)},onBlur:V=>{z.current&&!V.currentTarget.contains(V.relatedTarget)&&(z.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||z.current||(z.current=!0,F.current=V.relatedTarget)},onMouseEnter:()=>M(!0),onMouseMove:()=>M(!0),onMouseLeave:()=>{I||M(!1)},onDragEnd:()=>M(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},_.filter(V=>!V.position&&W===0||V.position===U).map((V,Q)=>{var Z,X;return be.createElement(uw,{key:V.id,icons:j,index:Q,toast:V,defaultRichColors:p,duration:(Z=b==null?void 0:b.duration)!=null?Z:h,className:b==null?void 0:b.className,descriptionClassName:b==null?void 0:b.descriptionClassName,invert:o,visibleToasts:x,closeButton:(X=b==null?void 0:b.closeButton)!=null?X:c,interacting:I,position:U,style:b==null?void 0:b.style,unstyled:b==null?void 0:b.unstyled,classNames:b==null?void 0:b.classNames,cancelButtonStyle:b==null?void 0:b.cancelButtonStyle,actionButtonStyle:b==null?void 0:b.actionButtonStyle,closeButtonAriaLabel:b==null?void 0:b.closeButtonAriaLabel,removeToast:H,toasts:_.filter(ee=>ee.position==V.position),heights:A.filter(ee=>ee.position==V.position),setHeights:T,expandByDefault:l,gap:y,expanded:E,swipeDirections:e.swipeDirections})})):null}))}),pw=n=>{const e=B.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(Un,{className:"size-4"}),info:r.jsx(ub,{className:"size-4"}),warning:r.jsx(jn,{className:"size-4"}),error:r.jsx(db,{className:"size-4"}),loading:r.jsx(rt,{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(mw,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function hw(n){const e=B.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){_s.dismiss("app-error");return}_s.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]),v.useEffect(c,d);let f,u;e[4]!==i||e[5]!==o?(f=()=>{if(!o){_s.dismiss("model-fallback");return}_s.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]),v.useEffect(f,u);let m,p;e[8]!==a?(m=()=>{if(!a){_s.dismiss("session-connection");return}_s.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]),v.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(pw,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const wt="local",_h="cogpit-last-path::",zl=new Map;function ht(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return wt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:wt}function $s(){return ht()!==wt}function Th(){const n=ht();return n===wt?"":`/hub/${n}`}function Eh(n){const e=Th();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")?`${e}${n}`:n}let tr=null;function Ph(n){n!==tr&&(tr=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function ps(){return tr}function fi(n){return n===wt?0:zl.get(n)??0}function gw(n,e){if(n===wt||!Number.isSafeInteger(e)||e<0)return!1;const t=zl.get(n);return t!==void 0&&e<=t?!1:(zl.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function mn(){const n=ht(),e=fi(n);return e===0?n:`${n}@${e}`}function Lt(n){const e=ht(),t=mn();return tr!==null?`${n}::${t}::${tr}`:e===wt?n:`${n}::${t}`}function Co(n,e){sessionStorage.setItem(`${_h}${n}`,e)}function hs(n){const t=sessionStorage.getItem(`${_h}${n}`)??(n===wt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const Zu="cogpit-network-token",xw=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function na(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!xw.has(e)}function sa(){try{localStorage.removeItem(Zu),sessionStorage.removeItem(Zu)}catch{}}typeof window<"u"&&sa();const bw={edition:"personal",needsBootstrap:!1};let nr=null,io=null;function Ah(){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 io=e.edition==="team"?"team":"personal",{edition:io,needsBootstrap:io==="team"&&e.needsBootstrap===!0}}).catch(()=>(nr=null,bw))}function Rh(){return nr??(nr=Ah()),nr}function ef(){return nr=Ah(),nr}function Mh(){return Rh().then(n=>n.edition)}async function vw(){if(!na()&&io!=="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 yw(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{sa()}}function tf(){return sa(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function Ih(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=Eh(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(na()||io==="team")return tf();if(io===null)return Mh().then(i=>i==="team"?tf():o)}if(o.status===502){const i=o.headers.get("X-Cogpit-Hub-Error"),a=o.headers.get("X-Cogpit-Device");a&&(i==="DEVICE_UNREACHABLE"||i==="DEVICE_AUTH_FAILED")&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:a,reason:i}}))}return o})}function ye(n,e){return Ih(n,e,!0)}function rs(n,e){return Ih(n,e,!1)}function yr(n){return Eh(n)}let nf=!1;function ww(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 jw(){if(!nf){nf=!0;try{const n=await ye("/api/models");if(!n.ok)return;const e=await n.json();for(const t of ms){const s=e==null?void 0:e[t];ww(s)&&Ey(t,s)}}catch{}}}function $h(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],v.useEffect(Sw,t);let s;return e[1]!==n?(s=()=>Sh(n),e[1]=n,e[2]=s):s=e[2],v.useSyncExternalStore(Py,s)}function Sw(){jw()}function Rn(n){const e=B.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(mb,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Mn(n){const e=B.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(pb,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function In(n){const e=B.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(Wp,{"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(qp,{children:r.jsx(Vp,{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 Ft(n){const e=B.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(Hp,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function gs(n){const e=B.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(Kp,{"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 ct(n){const e=B.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(Up,{"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 kw(n){const e=B.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(bb,{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(dt,{})})}),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(gb,{"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 ji(n){const e=B.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(xb,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Pc(n){const e=B.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(hb,{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(dt,{})})}),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(fb,{"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 ao(n){const e=B.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(bc,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const Nw={claude:co,codex:pr,copilot:vb},Ac={claude:"Claude",codex:"Codex",copilot:"Copilot"},Cw={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},_w={claude:null,codex:"Codex",copilot:"Copilot"},Tw={claude:{letter:"C",label:"Loaded by Claude Code"},codex:{letter:"X",label:"Loaded by Codex CLI"},copilot:{letter:"G",label:"Loaded by GitHub Copilot CLI"}},Ew={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},Pw={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},Aw={claude:[{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"}],codex:[{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"}],copilot:[{value:"default",label:"Ask",description:"Ask before running tools or changing files"},{value:"plan",label:"Plan",description:"Explore and plan without changing project files"},{value:"auto",label:"Autopilot",description:"Implement autonomously until the task is complete"},{value:"bypassPermissions",label:"Full access",description:"Allow tools, paths, and URLs without asking"}]};function Rw(n){return Aw[n]}function oa(n){return Ac[n]}function fI(n){return Cw[n]}function Mw(n){return _w[n]}function mI(n){return Tw[n]}function Iw(n){return Pw[n]}function $w(n){return Ew[n]}const sf=js(null).kind,Oh=[sf,...ms.filter(n=>n!==sf)];function Ow(n){return`This ${Ac[n]} session is controlled by another process. Cogpit can only view it.`}const Fl=Oh.map(n=>({value:n,label:Ac[n],Icon:Nw[n]}));function Dw(n,e){const t=e==null?void 0:e.filter(s=>s.value!=="");return(t==null?void 0:t.find(s=>s.value===n))??(t==null?void 0:t.find(s=>s.resolvedModel===n))}function Lw(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?Rc(e,n):"Default"}function Rc(n,e){const t=Dw(n,e);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 Dh(n){const e=B.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(Pc,{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 zw(n){var A,T;const e=B.c(33),{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}=n;let c;e[0]!==t?(c=((A=Fl.find(E=>E.value===t))==null?void 0:A.label)??t,e[0]=t,e[1]=c):c=e[1];const d=c;let f;e[2]!==i||e[3]!==a||e[4]!==o?(f=((T=a.find(E=>E.value===o))==null?void 0:T.label)??i,e[2]=i,e[3]=a,e[4]=o,e[5]=f):f=e[5];const u=f;let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(J,{type:"button",variant:"ghost",size:"xs"}),e[6]=m):m=e[6];const p=`${d} / ${u}`;let h;e[7]!==p?(h=r.jsx("span",{className:"truncate",children:p}),e[7]=p,e[8]=h):h=e[8];let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(st,{"data-icon":"inline-end"}),e[9]=g):g=e[9];let x;e[10]!==h?(x=r.jsxs(Mn,{render:m,children:[h,g]}),e[10]=h,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(gs,{children:"Agent"}),e[12]=b):b=e[12];let w;e[13]!==s?(w=E=>s(E),e[13]=s,e[14]=w):w=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=Fl.map(Bw),e[15]=y):y=e[15];let j;e[16]!==t||e[17]!==w?(j=r.jsxs(Ft,{children:[b,r.jsx(ji,{value:t,onValueChange:w,children:y})]}),e[16]=t,e[17]=w,e[18]=j):j=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(ao,{}),e[19]=k):k=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(gs,{children:"Model"}),e[20]=N):N=e[20];let C;e[21]!==a?(C=a.map(Fw),e[21]=a,e[22]=C):C=e[22];let S;e[23]!==l||e[24]!==C||e[25]!==o?(S=r.jsxs(Ft,{children:[N,r.jsx(ji,{value:o,onValueChange:l,children:C})]}),e[23]=l,e[24]=C,e[25]=o,e[26]=S):S=e[26];let _;e[27]!==j||e[28]!==S?(_=r.jsxs(In,{"aria-label":"Agent and model",className:"w-72",children:[j,k,S]}),e[27]=j,e[28]=S,e[29]=_):_=e[29];let P;return e[30]!==_||e[31]!==x?(P=r.jsxs(Rn,{children:[x,_]}),e[30]=_,e[31]=x,e[32]=P):P=e[32],P}function Fw(n){return r.jsx(Dh,{option:n,descriptionWidth:"max-w-72"},n.value)}function Bw(n){const e=n.Icon;return r.jsxs(Pc,{value:n.value,children:[r.jsx(e,{}),n.label]},n.value)}function Uw(n){const e=B.c(44),{servers:t,selected:s,onToggle:o,onRefresh:i,loading:a,onAuth:l}=n;let c;e[0]!==t?(c=t.filter(Ww),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=v.useId();let p,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(J,{type:"button",variant:"ghost",size:"xs"}),h=r.jsx(yb,{"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 x;e[6]!==g?(x=r.jsx("span",{className:"truncate",children:g}),e[6]=g,e[7]=x):x=e[7];let b;e[8]!==a||e[9]!==t.length?(b=a&&t.length===0?r.jsx(Qt,{"data-icon":"inline-end",className:"animate-spin"}):r.jsx(st,{"data-icon":"inline-end"}),e[8]=a,e[9]=t.length,e[10]=b):b=e[10];let w;e[11]!==x||e[12]!==b?(w=r.jsxs(Mn,{render:p,children:[h,x,b]}),e[11]=x,e[12]=b,e[13]=w):w=e[13];let y;e[14]!==m?(y=r.jsx(gs,{id:m,children:"MCP servers"}),e[14]=m,e[15]=y):y=e[15];const j=a?"animate-spin":void 0;let k;e[16]!==j?(k=r.jsx(Qt,{"data-icon":"inline-start",className:j}),e[16]=j,e[17]=k):k=e[17];let N;e[18]!==i||e[19]!==k?(N=r.jsxs(ct,{closeOnClick:!1,onClick:i,children:[k,"Refresh status"]}),e[18]=i,e[19]=k,e[20]=N):N=e[20];let C;e[21]!==a||e[22]!==t.length?(C=t.length===0&&r.jsx(ct,{disabled:!0,children:a?"Loading...":"No MCP servers configured"}),e[21]=a,e[22]=t.length,e[23]=C):C=e[23];let S;if(e[24]!==l||e[25]!==o||e[26]!==u||e[27]!==t){let T;e[29]!==l||e[30]!==o||e[31]!==u?(T=E=>E.status!=="connected"?r.jsxs(ct,{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(kw,{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]=T):T=e[32],S=t.map(T),e[24]=l,e[25]=o,e[26]=u,e[27]=t,e[28]=S}else S=e[28];let _;e[33]!==N||e[34]!==C||e[35]!==S||e[36]!==y?(_=r.jsxs(Ft,{children:[y,N,C,S]}),e[33]=N,e[34]=C,e[35]=S,e[36]=y,e[37]=_):_=e[37];let P;e[38]!==m||e[39]!==_?(P=r.jsx(In,{"aria-labelledby":m,className:"w-64",children:_}),e[38]=m,e[39]=_,e[40]=P):P=e[40];let A;return e[41]!==P||e[42]!==w?(A=r.jsxs(Rn,{children:[w,P]}),e[41]=P,e[42]=w,e[43]=A):A=e[43],A}function Ww(n){return n.status==="connected"}function of(n){var N;const e=B.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=((N=o.find(C=>C.value===t))==null?void 0:N.label)??s,e[0]=s,e[1]=o,e[2]=t,e[3]=d):d=e[3];const f=d,u=v.useId();let m;e[4]!==l?(m=r.jsx(J,{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(st,{"data-icon":"inline-end"}),e[8]=h):h=e[8];let g;e[9]!==a||e[10]!==m||e[11]!==p?(g=r.jsxs(Mn,{disabled:a,render:m,children:[p,h]}),e[9]=a,e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==c||e[14]!==u?(x=r.jsx(gs,{id:u,className:"sr-only",children:c}),e[13]=c,e[14]=u,e[15]=x):x=e[15];let b;e[16]!==o?(b=o.map(Hw),e[16]=o,e[17]=b):b=e[17];let w;e[18]!==i||e[19]!==b||e[20]!==t?(w=r.jsx(ji,{value:t,onValueChange:i,children:b}),e[18]=i,e[19]=b,e[20]=t,e[21]=w):w=e[21];let y;e[22]!==x||e[23]!==w?(y=r.jsxs(Ft,{children:[x,w]}),e[22]=x,e[23]=w,e[24]=y):y=e[24];let j;e[25]!==u||e[26]!==y?(j=r.jsx(In,{"aria-labelledby":u,className:"w-48",children:y}),e[25]=u,e[26]=y,e[27]=j):j=e[27];let k;return e[28]!==j||e[29]!==g?(k=r.jsxs(Rn,{children:[g,j]}),e[28]=j,e[29]=g,e[30]=k):k=e[30],k}function Hw(n){return r.jsx(Dh,{option:n},n.value)}function Lh(n,e){return Rw(n).filter(t=>t.value!=="auto"||e)}function Kw(n){const e=B.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,x,b;if(e[0]!==t||e[1]!==a||e[2]!==s||e[3]!==o){const N=Lh(t,a),C=N.find(A=>A.value===s)??N[0];f=Rn;let S,_;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(J,{type:"button",variant:"ghost",size:"xs"}),S=r.jsx(Gp,{"data-icon":"inline-start"}),e[15]=S,e[16]=_):(S=e[15],_=e[16]);let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(st,{"data-icon":"inline-end"}),e[17]=P):P=e[17],b=r.jsxs(Mn,{render:_,children:[S,r.jsx("span",{className:"truncate",children:C.label}),P]}),d=In,g="Access policy",x="w-72",c=Ft,e[18]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(gs,{children:"Permissions"}),e[18]=h):h=e[18],l=ji,u=s,e[19]!==o?(m=A=>o(A),e[19]=o,e[20]=m):m=e[20],p=N.map(qw),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]=x,e[14]=b}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],x=e[13],b=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]!==x?(j=r.jsx(d,{"aria-label":g,className:x,children:y}),e[30]=d,e[31]=y,e[32]=g,e[33]=x,e[34]=j):j=e[34];let k;return e[35]!==f||e[36]!==j||e[37]!==b?(k=r.jsxs(f,{children:[b,j]}),e[35]=f,e[36]=j,e[37]=b,e[38]=k):k=e[38],k}function qw(n){return r.jsx(Pc,{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 Vw(n){const e=B.c(62),{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:x,ultracodeEnabled:b,onUltracodeEnabledChange:w,autoModeAvailable:y,permissionMode:j,onPermissionModeChange:k,mcpServers:N,selectedMcpServers:C,onToggleMcpServer:S,onRefreshMcpServers:_,mcpLoading:P,onMcpAuth:A,changeAndApply:T,trailingExtra:E}=n;let M;e[0]!==t?(M=Ut(t),e[0]=t,e[1]=M):M=e[1];const{worktrees:I,ultracode:R,settingsApply:$}=M,D=v.useId(),O=h?void 0:$==="live"?"Changes apply live":"Changes apply next turn",L=O?D:void 0;let F;e[2]!==O||e[3]!==D?(F=O&&r.jsx("span",{id:D,className:"sr-only",children:O}),e[2]=O,e[3]=D,e[4]=F):F=e[4];let z;e[5]!==t||e[6]!==a||e[7]!==s||e[8]!==l||e[9]!==i||e[10]!==o?(z=s?r.jsx(zw,{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}):r.jsx(of,{value:o,fallbackLabel:"Model",ariaLabel:"Model",options:a,onChange:l}),e[5]=t,e[6]=a,e[7]=s,e[8]=l,e[9]=i,e[10]=o,e[11]=z):z=e[11];let H;e[12]!==t||e[13]!==d||e[14]!==f||e[15]!==c||e[16]!==o||e[17]!==b?(H=d.length>0&&r.jsx(of,{value:ta(t,c,o),fallbackLabel:"Effort",ariaLabel:"Reasoning effort",options:d,onChange:f,disabled:b,title:b?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=t,e[13]=d,e[14]=f,e[15]=c,e[16]=o,e[17]=b,e[18]=H):H=e[18];let U;e[19]!==T||e[20]!==m||e[21]!==u||e[22]!==p?(U=u&&p&&r.jsxs(J,{type:"button",variant:m?"secondary":"ghost",size:"xs","aria-pressed":!!m,onClick:()=>T(()=>p(!m)),title:u.description,children:[r.jsx(vi,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]}),e[19]=T,e[20]=m,e[21]=u,e[22]=p,e[23]=U):U=e[23];let W;e[24]!==t||e[25]!==y||e[26]!==T||e[27]!==k||e[28]!==j?(W=k&&j&&r.jsx(Kw,{agentKind:t,mode:j,onChange:Z=>T(()=>k(Z)),autoAvailable:y}),e[24]=t,e[25]=y,e[26]=T,e[27]=k,e[28]=j,e[29]=W):W=e[29];let K;e[30]!==h||e[31]!==x||e[32]!==I||e[33]!==g?(K=I&&h&&x&&r.jsxs(J,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(vo,{"data-icon":"inline-start"}),"Worktree"]}),e[30]=h,e[31]=x,e[32]=I,e[33]=g,e[34]=K):K=e[34];let q;e[35]!==T||e[36]!==w||e[37]!==R||e[38]!==b?(q=R&&w&&r.jsxs(J,{type:"button",variant:b?"secondary":"ghost",size:"xs","aria-pressed":!!b,onClick:()=>T(()=>w(!b)),title:"Ultracode: XHigh effort + standing multi-agent workflow orchestration",children:[r.jsx(vi,{"data-icon":"inline-start",className:G(b&&"fill-current")}),"Ultracode"]}),e[35]=T,e[36]=w,e[37]=R,e[38]=b,e[39]=q):q=e[39];let Y;e[40]!==T||e[41]!==P||e[42]!==N||e[43]!==A||e[44]!==_||e[45]!==S||e[46]!==C?(Y=S&&_&&A&&(P||N&&N.length>0)&&r.jsx(Uw,{servers:N??[],selected:C??[],onToggle:Z=>T(()=>S(Z)),onRefresh:_,loading:P??!1,onAuth:A}),e[40]=T,e[41]=P,e[42]=N,e[43]=A,e[44]=_,e[45]=S,e[46]=C,e[47]=Y):Y=e[47];let V;e[48]!==Y||e[49]!==z||e[50]!==H||e[51]!==U||e[52]!==W||e[53]!==K||e[54]!==q||e[55]!==E?(V=r.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1.5",children:[z,H,U,W,K,q,Y,E]}),e[48]=Y,e[49]=z,e[50]=H,e[51]=U,e[52]=W,e[53]=K,e[54]=q,e[55]=E,e[56]=V):V=e[56];let Q;return e[57]!==O||e[58]!==V||e[59]!==L||e[60]!==F?(Q=r.jsxs("div",{className:"flex items-center pb-1.5 pl-6 pr-3",role:"group",title:O,"aria-describedby":L,children:[F,V]}),e[57]=O,e[58]=V,e[59]=L,e[60]=F,e[61]=Q):Q=e[61],Q}function It(n){const e=B.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(bc,{"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 Gw(n){const e=B.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 Yw(n){const e=B.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 Xw(n){const e=B.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 jo(n){const e=B.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 Jw=Bn("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 gt(n){const e=B.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(Jw({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 pI(n){const e=B.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 xt(n){const e=B.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(Gw,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function mo(n){const e=B.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 us(n){var f;const e=B.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(Zw)).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(Qw)}),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 Qw(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function Zw(n){return[n==null?void 0:n.message,n]}const e3=kb;function t3(n){const e=B.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(Tb,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function n3(n){const e=B.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(Nb,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function s3(n){const e=B.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(Eb,{render:r.jsx(st,{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(Cb,{"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 o3(n){const e=B.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 x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(i3,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=r.jsx(Pb,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(a3,{}),e[14]=w):w=e[14];let y;e[15]!==o||e[16]!==g||e[17]!==b?(y=r.jsxs(_b,{"data-slot":"select-content",className:g,...o,children:[x,b,w]}),e[15]=o,e[16]=g,e[17]=b,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(Ab,{children:r.jsx(Rb,{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 r3(n){const e=B.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(jb,{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(Sb,{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(dt,{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(wb,{"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 i3(n){const e=B.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(hr,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Mb,{"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 a3(n){const e=B.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(st,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Ib,{"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 l3(n){const e=B.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(Yp,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function c3(n){const e=B.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($b,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function d3(n){const e=B.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(Wi,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function u3(n){const e=B.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(jc,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function f3(n){const e=B.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(Sc,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function m3(n){const e=B.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(f3,{}),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(Wi,{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(jt,{"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(u3,{children:[d,r.jsxs(vc,{"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 p3(n){const e=B.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 h3(n){const e=B.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(yc,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function g3(n){const e=B.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(wc,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wo(n){const e=B.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(xt,{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(gt,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=f):f=e[9],f}function Yr(n){const e=B.c(19),{label:t,ariaLabel:s,value:o,options:i,onChange:a,disabled:l,title:c}=n;let d;e[0]!==a?(d=x=>{x!==null&&a(x)},e[0]=a,e[1]=d):d=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(n3,{}),e[2]=f):f=e[2];let u;e[3]!==s||e[4]!==c?(u=r.jsx(s3,{"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(x3),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(o3,{children:r.jsx(t3,{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(e3,{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(Wo,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function x3(n){return r.jsx(r3,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function b3(n){const e=B.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:x,changeAndApply:b}=n;let w;e[0]!==t||e[1]!==l||e[2]!==o?(w=ta(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 k;e[5]!==t||e[6]!==s?(k=s&&r.jsx(Yr,{label:"Agent",ariaLabel:"Agent",value:t,options:Fl,onChange:A=>s(A)}),e[5]=t,e[6]=s,e[7]=k):k=e[7];let N;e[8]!==a||e[9]!==i||e[10]!==o?(N=r.jsx(Yr,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[8]=a,e[9]=i,e[10]=o,e[11]=N):N=e[11];let C;e[12]!==d||e[13]!==y||e[14]!==c||e[15]!==f?(C=d.length>0&&r.jsx(Yr,{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]=C):C=e[16];let S;e[17]!==b||e[18]!==m||e[19]!==u||e[20]!==p?(S=u&&p&&r.jsx(Wo,{label:"Speed",children:r.jsxs(J,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>b(()=>p(!m)),title:u.description,className:"h-10 justify-start",children:[r.jsx(vi,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[17]=b,e[18]=m,e[19]=u,e[20]=p,e[21]=S):S=e[21];let _;e[22]!==x||e[23]!==h||e[24]!==g?(_=x&&h&&r.jsx(Yr,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:A=>x(A)}),e[22]=x,e[23]=h,e[24]=g,e[25]=_):_=e[25];let P;return e[26]!==k||e[27]!==N||e[28]!==C||e[29]!==S||e[30]!==_?(P=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:[k,N,C,S,_]})]}),e[26]=k,e[27]=N,e[28]=C,e[29]=S,e[30]=_,e[31]=P):P=e[31],P}function v3(n){const e=B.c(30),{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;let g;e[0]!==t?(g=Ut(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:b}=g,w=!!(f&&u&&p&&(m||c&&c.length>0)),y=!!(x&&s&&i||b&&l||w);let j;e[2]!==d?(j=d??[],e[2]=d,e[3]=j):j=e[3];let k;e[4]!==j?(k=new Set(j),e[4]=j,e[5]=k):k=e[5];const N=k;if(!y)return null;let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("h3",{id:"mobile-advanced-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Advanced"}),e[6]=C):C=e[6];let S;e[7]!==s||e[8]!==i||e[9]!==x||e[10]!==o?(S=x&&s&&i&&r.jsx(Wo,{label:"Isolation",children:r.jsxs(J,{type:"button",variant:o?"secondary":"ghost","aria-pressed":!!o,onClick:()=>i(!o),className:"h-10 justify-start",children:[r.jsx(vo,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=i,e[9]=x,e[10]=o,e[11]=S):S=e[11];let _;e[12]!==h||e[13]!==l||e[14]!==b||e[15]!==a?(_=b&&l&&r.jsx(Wo,{label:"Workflow",children:r.jsxs(J,{type:"button",variant:a?"secondary":"ghost","aria-pressed":!!a,onClick:()=>h(()=>l(!a)),className:"h-10 justify-start",children:[r.jsx(vi,{"data-icon":"inline-start",className:G(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=a,e[16]=_):_=e[16];let P;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==u||e[22]!==f||e[23]!==N||e[24]!==w?(P=w&&f&&u&&p&&r.jsx(Wo,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(J,{type:"button",variant:"ghost",onClick:u,className:"min-h-10 justify-start",children:[r.jsx(Qt,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(T=>{const E=N.has(T.name),M=T.status==="connected";return r.jsxs(J,{type:"button",variant:"ghost","aria-pressed":M?E:void 0,onClick:()=>M?h(()=>f(T.name)):p(T.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:G("size-2 shrink-0 rounded-full",M&&E?"bg-success":M?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:M?E?"On":"Off":"Connect"})]},T.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=u,e[22]=f,e[23]=N,e[24]=w,e[25]=P):P=e[25];let A;return e[26]!==S||e[27]!==_||e[28]!==P?(A=r.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[C,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[S,_,P]})]}),e[26]=S,e[27]=_,e[28]=P,e[29]=A):A=e[29],A}function y3(n){var he,me;const e=B.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:x,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:y,ultracodeEnabled:j,onUltracodeEnabledChange:k,autoModeAvailable:N,permissionMode:C,onPermissionModeChange:S,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:M,mobileExtra:I,changeAndApply:R}=n;let $;e[0]!==o||e[1]!==u||e[2]!==a?($=ta(o,u,a),e[0]=o,e[1]=u,e[2]=a,e[3]=$):$=e[3];const D=$;let O,L;e[4]!==o||e[5]!==N||e[6]!==C?(O=Lh(o,N),L=(he=O.find(le=>le.value===C))==null?void 0:he.label,e[4]=o,e[5]=N,e[6]=C,e[7]=O,e[8]=L):(O=e[7],L=e[8]);const F=L;let z;e[9]!==c||e[10]!==l||e[11]!==a?(z=a?Rc(a,c):l,e[9]=c,e[10]=l,e[11]=a,e[12]=z):z=e[12];let H;e[13]!==m||e[14]!==D?(H=(me=m.find(le=>le.value===D))==null?void 0:me.label,e[13]=m,e[14]=D,e[15]=H):H=e[15];let U;e[16]!==F||e[17]!==z||e[18]!==H?(U=[z,H,F].filter(Boolean),e[16]=F,e[17]=z,e[18]=H,e[19]=U):U=e[19];const W=U.join(" · ");let K;e[20]!==R||e[21]!==S?(K=le=>{S&&R(()=>S(le))},e[20]=R,e[21]=S,e[22]=K):K=e[22];const q=K;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(c3,{render:r.jsx(J,{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(kc,{})}),e[23]=Y):Y=e[23];let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(h3,{children:"Session controls"}),e[24]=V):V=e[24];let Q;e[25]!==W?(Q=r.jsx(g3,{className:"truncate text-xs",children:W}),e[25]=W,e[26]=Q):Q=e[26];let Z;e[27]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(d3,{render:r.jsx(J,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:r.jsx(jt,{})}),e[27]=Z):Z=e[27];let X;e[28]!==Q?(X=r.jsxs(p3,{className:"gap-1 px-4 pb-3 pt-4",children:[V,Q,Z]}),e[28]=Q,e[29]=X):X=e[29];let ee;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]!==x||e[40]!==f||e[41]!==C||e[42]!==O||e[43]!==u||e[44]!==a||e[45]!==j?(ee=r.jsx(b3,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:f,modelOptions:d,selectedEffort:u,onEffortChange:p,effortOptions:m,ultracodeEnabled:j,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:O,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]=x,e[40]=f,e[41]=C,e[42]=O,e[43]=u,e[44]=a,e[45]=j,e[46]=ee):ee=e[46];let oe;e[47]!==o||e[48]!==R||e[49]!==b||e[50]!==E||e[51]!==_||e[52]!==M||e[53]!==T||e[54]!==A||e[55]!==k||e[56]!==y||e[57]!==P||e[58]!==j||e[59]!==w?(oe=r.jsx(v3,{agentKind:o,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:y,ultracodeEnabled:j,onUltracodeEnabledChange:k,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:M,changeAndApply:R}),e[47]=o,e[48]=R,e[49]=b,e[50]=E,e[51]=_,e[52]=M,e[53]=T,e[54]=A,e[55]=k,e[56]=y,e[57]=P,e[58]=j,e[59]=w,e[60]=oe):oe=e[60];let se;e[61]!==I?(se=I&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(It,{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]=se):se=e[62];let re;e[63]!==o||e[64]!==b?(re=!b&&r.jsx("p",{className:"text-xs text-muted-foreground",children:Ut(o).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[63]=o,e[64]=b,e[65]=re):re=e[65];let ie;e[66]!==ee||e[67]!==oe||e[68]!==se||e[69]!==re?(ie=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[ee,oe,se,re]}),e[66]=ee,e[67]=oe,e[68]=se,e[69]=re,e[70]=ie):ie=e[70];let ae;e[71]!==X||e[72]!==ie?(ae=r.jsxs(m3,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[X,ie]}),e[71]=X,e[72]=ie,e[73]=ae):ae=e[73];let te;return e[74]!==s||e[75]!==t||e[76]!==ae?(te=r.jsx(r.Fragment,{children:r.jsxs(l3,{open:t,onOpenChange:s,children:[Y,ae]})}),e[74]=s,e[75]=t,e[76]=ae,e[77]=te):te=e[77],te}const w3=v.memo(function(e){const t=B.c(58),{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:x,activeModelId:b,mcpServers:w,selectedMcpServers:y,onToggleMcpServer:j,onRefreshMcpServers:k,mcpLoading:N,onMcpAuth:C,permissionMode:S,onPermissionModeChange:_,mobileExtra:P,trailingExtra:A,mobile:T}=e,E=s===void 0?Fs:s,M=T===void 0?!1:T,[I,R]=v.useState(!1);let $;t[0]!==u||t[1]!==x?($=te=>{te(),!u&&x&&setTimeout(()=>x(),0)},t[0]=u,t[1]=x,t[2]=$):$=t[2];const D=$;let O;t[3]!==D||t[4]!==a?(O=te=>D(()=>a(te)),t[3]=D,t[4]=a,t[5]=O):O=t[5];const L=O;let F;t[6]!==D||t[7]!==c?(F=te=>D(()=>c(te)),t[6]=D,t[7]=c,t[8]=F):F=t[8];const z=F,H=$h(E),U=(b==null?void 0:b.toLowerCase().startsWith("gpt-"))??!1,K=b&&(E==="copilot"||U===(E==="codex"))?b:void 0;let q,Y;t[9]!==H||t[10]!==K?(q=K?Rc(K,H):Lw(H),Y=H.map(te=>{const he=[te.description,te.availabilityMessage].filter(Boolean).join(" · ")||void 0;return te.value===""?{...te,description:he,label:q,menuLabel:te.label}:{...te,description:he}}),t[9]=H,t[10]=K,t[11]=q,t[12]=Y):(q=t[11],Y=t[12]);const V=Y;let Q;t[13]!==E||t[14]!==i?(Q=kh(E,i),t[13]=E,t[14]=i,t[15]=Q):Q=t[15];const Z=Q;let X;t[16]!==E||t[17]!==i?(X=Nh(E,i),t[16]=E,t[17]=i,t[18]=X):X=t[18];const ee=X;let oe;t[19]!==E||t[20]!==i?(oe=Iy(E,i),t[19]=E,t[20]=i,t[21]=oe):oe=t[21];const se=oe;let re;t[22]!==E||t[23]!==se||t[24]!==D||t[25]!==Z||t[26]!==d||t[27]!==ee||t[28]!==z||t[29]!==L||t[30]!==u||t[31]!==N||t[32]!==w||t[33]!==V||t[34]!==o||t[35]!==f||t[36]!==C||t[37]!==_||t[38]!==k||t[39]!==j||t[40]!==g||t[41]!==p||t[42]!==S||t[43]!==q||t[44]!==l||t[45]!==y||t[46]!==i||t[47]!==h||t[48]!==m?(re={agentKind:E,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:q,modelOptions:V,onModelChange:L,selectedEffort:l,effortOptions:Z,onEffortChange:z,fastTier:ee,fastModeEnabled:d,onFastModeEnabledChange:f,isNewSession:u,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:se,permissionMode:S,onPermissionModeChange:_,mcpServers:w,selectedMcpServers:y,onToggleMcpServer:j,onRefreshMcpServers:k,mcpLoading:N,onMcpAuth:C,changeAndApply:D},t[22]=E,t[23]=se,t[24]=D,t[25]=Z,t[26]=d,t[27]=ee,t[28]=z,t[29]=L,t[30]=u,t[31]=N,t[32]=w,t[33]=V,t[34]=o,t[35]=f,t[36]=C,t[37]=_,t[38]=k,t[39]=j,t[40]=g,t[41]=p,t[42]=S,t[43]=q,t[44]=l,t[45]=y,t[46]=i,t[47]=h,t[48]=m,t[49]=re):re=t[49];const ie=re;if(M){let te;return t[50]!==H||t[51]!==ie||t[52]!==P||t[53]!==I?(te=r.jsx(y3,{...ie,open:I,onOpenChange:R,catalogOptions:H,mobileExtra:P}),t[50]=H,t[51]=ie,t[52]=P,t[53]=I,t[54]=te):te=t[54],te}let ae;return t[55]!==ie||t[56]!==A?(ae=r.jsx(Vw,{...ie,trailingExtra:A}),t[55]=ie,t[56]=A,t[57]=ae):ae=t[57],ae});function zh(n){return n.agentType==="team-lead"}function j3(n){return zh(n)?void 0:n.color}const S3={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function k3(n){return n?S3[n]??"bg-zinc-400":"bg-zinc-400"}const N3=v.memo(function(e){const t=B.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(Wn,{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(It,{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 x=g.name===i,b=g.name===a,w=k3(j3(g));return r.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:G("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[b?r.jsx(rt,{"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}),zh(g)&&r.jsx(Ob,{"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 Fh(n){const e=B.c(3),t=v.useRef(null),[s,o]=v.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]),v.useEffect(i,a),s}const Bh=v.createContext(null),Uh=v.createContext(null);function mi(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(Uh.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(Bh.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function it(){const n=v.useContext(Bh);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function wr(){const n=v.useContext(Uh);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const C3=Bn("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 Me(n){const e=B.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=Jp,s="span",o=Xp({className:G(C3({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 rf=1,_3=.9,T3=.8,E3=.17,Ga=.1,Ya=.999,P3=.9999,A3=.99,R3=/[\\\/_+.#"@\[\(\{&]/,M3=/[\\\/_+.#"@\[\(\{&]/g,I3=/[\s-]/,Wh=/[\s-]/g;function Bl(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?rf:A3;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=Bl(n,e,t,s,d+1,i+1,a),u>f&&(d===o?u*=rf:R3.test(n.charAt(d-1))?(u*=T3,p=n.slice(o,d-1).match(M3),p&&o>0&&(u*=Math.pow(Ya,p.length))):I3.test(n.charAt(d-1))?(u*=_3,h=n.slice(o,d-1).match(Wh),h&&o>0&&(u*=Math.pow(Ya,h.length))):(u*=E3,o>0&&(u*=Math.pow(Ya,d-o))),n.charAt(d)!==e.charAt(i)&&(u*=P3)),(u<Ga&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=Bl(n,e,t,s,d+1,i+2,a),m*Ga>u&&(u=m*Ga)),u>f&&(f=u),d=t.indexOf(c,d+1);return a[l]=f,f}function af(n){return n.toLowerCase().replace(Wh," ")}function $3(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,Bl(n,e,af(n),af(e),0,0,{})}var _o='[cmdk-group=""]',Xa='[cmdk-group-items=""]',O3='[cmdk-group-heading=""]',Hh='[cmdk-item=""]',lf=`${Hh}:not([aria-disabled="true"])`,Ul="cmdk-item-select",eo="data-value",D3=(n,e,t)=>$3(n,e,t),Kh=v.createContext(void 0),jr=()=>v.useContext(Kh),qh=v.createContext(void 0),Mc=()=>v.useContext(qh),Vh=v.createContext(void 0),Gh=v.forwardRef((n,e)=>{let t=to(()=>{var z,H;return{search:"",value:(H=(z=n.value)!=null?z:n.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=to(()=>new Set),o=to(()=>new Map),i=to(()=>new Map),a=to(()=>new Set),l=Yh(n),{label:c,children:d,value:f,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,w=ro(),y=ro(),j=ro(),k=v.useRef(null),N=G3();Os(()=>{if(f!==void 0){let z=f.trim();t.current.value=z,C.emit()}},[f]),Os(()=>{N(6,E)},[]);let C=v.useMemo(()=>({subscribe:z=>(a.current.add(z),()=>a.current.delete(z)),snapshot:()=>t.current,setState:(z,H,U)=>{var W,K,q,Y;if(!Object.is(t.current[z],H)){if(t.current[z]=H,z==="search")T(),P(),N(1,A);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let V=document.getElementById(j);V?V.focus():(W=document.getElementById(w))==null||W.focus()}if(N(7,()=>{var V;t.current.selectedItemId=(V=M())==null?void 0:V.id,C.emit()}),U||N(5,E),((K=l.current)==null?void 0:K.value)!==void 0){let V=H??"";(Y=(q=l.current).onValueChange)==null||Y.call(q,V);return}}C.emit()}},emit:()=>{a.current.forEach(z=>z())}}),[]),S=v.useMemo(()=>({value:(z,H,U)=>{var W;H!==((W=i.current.get(z))==null?void 0:W.value)&&(i.current.set(z,{value:H,keywords:U}),t.current.filtered.items.set(z,_(H,U)),N(2,()=>{P(),C.emit()}))},item:(z,H)=>(s.current.add(z),H&&(o.current.has(H)?o.current.get(H).add(z):o.current.set(H,new Set([z]))),N(3,()=>{T(),P(),t.current.value||A(),C.emit()}),()=>{i.current.delete(z),s.current.delete(z),t.current.filtered.items.delete(z);let U=M();N(4,()=>{T(),(U==null?void 0:U.getAttribute("id"))===z&&A(),C.emit()})}),group:z=>(o.current.has(z)||o.current.set(z,new Set),()=>{i.current.delete(z),o.current.delete(z)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:w,inputId:j,labelId:y,listInnerRef:k}),[]);function _(z,H){var U,W;let K=(W=(U=l.current)==null?void 0:U.filter)!=null?W:D3;return z?K(z,t.current.search,H):0}function P(){if(!t.current.search||l.current.shouldFilter===!1)return;let z=t.current.filtered.items,H=[];t.current.filtered.groups.forEach(W=>{let K=o.current.get(W),q=0;K.forEach(Y=>{let V=z.get(Y);q=Math.max(V,q)}),H.push([W,q])});let U=k.current;I().sort((W,K)=>{var q,Y;let V=W.getAttribute("id"),Q=K.getAttribute("id");return((q=z.get(Q))!=null?q:0)-((Y=z.get(V))!=null?Y:0)}).forEach(W=>{let K=W.closest(Xa);K?K.appendChild(W.parentElement===K?W:W.closest(`${Xa} > *`)):U.appendChild(W.parentElement===U?W:W.closest(`${Xa} > *`))}),H.sort((W,K)=>K[1]-W[1]).forEach(W=>{var K;let q=(K=k.current)==null?void 0:K.querySelector(`${_o}[${eo}="${encodeURIComponent(W[0])}"]`);q==null||q.parentElement.appendChild(q)})}function A(){let z=I().find(U=>U.getAttribute("aria-disabled")!=="true"),H=z==null?void 0:z.getAttribute(eo);C.setState("value",H||void 0)}function T(){var z,H,U,W;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let K=0;for(let q of s.current){let Y=(H=(z=i.current.get(q))==null?void 0:z.value)!=null?H:"",V=(W=(U=i.current.get(q))==null?void 0:U.keywords)!=null?W:[],Q=_(Y,V);t.current.filtered.items.set(q,Q),Q>0&&K++}for(let[q,Y]of o.current)for(let V of Y)if(t.current.filtered.items.get(V)>0){t.current.filtered.groups.add(q);break}t.current.filtered.count=K}function E(){var z,H,U;let W=M();W&&(((z=W.parentElement)==null?void 0:z.firstChild)===W&&((U=(H=W.closest(_o))==null?void 0:H.querySelector(O3))==null||U.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function M(){var z;return(z=k.current)==null?void 0:z.querySelector(`${Hh}[aria-selected="true"]`)}function I(){var z;return Array.from(((z=k.current)==null?void 0:z.querySelectorAll(lf))||[])}function R(z){let H=I()[z];H&&C.setState("value",H.getAttribute(eo))}function $(z){var H;let U=M(),W=I(),K=W.findIndex(Y=>Y===U),q=W[K+z];(H=l.current)!=null&&H.loop&&(q=K+z<0?W[W.length-1]:K+z===W.length?W[0]:W[K+z]),q&&C.setState("value",q.getAttribute(eo))}function D(z){let H=M(),U=H==null?void 0:H.closest(_o),W;for(;U&&!W;)U=z>0?q3(U,_o):V3(U,_o),W=U==null?void 0:U.querySelector(lf);W?C.setState("value",W.getAttribute(eo)):$(z)}let O=()=>R(I().length-1),L=z=>{z.preventDefault(),z.metaKey?O():z.altKey?D(1):$(1)},F=z=>{z.preventDefault(),z.metaKey?R(0):z.altKey?D(-1):$(-1)};return v.createElement(ws.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:z=>{var H;(H=b.onKeyDown)==null||H.call(b,z);let U=z.nativeEvent.isComposing||z.keyCode===229;if(!(z.defaultPrevented||U))switch(z.key){case"n":case"j":{x&&z.ctrlKey&&L(z);break}case"ArrowDown":{L(z);break}case"p":case"k":{x&&z.ctrlKey&&F(z);break}case"ArrowUp":{F(z);break}case"Home":{z.preventDefault(),R(0);break}case"End":{z.preventDefault(),O();break}case"Enter":{z.preventDefault();let W=M();if(W){let K=new Event(Ul);W.dispatchEvent(K)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:X3},c),ra(n,z=>v.createElement(qh.Provider,{value:C},v.createElement(Kh.Provider,{value:S},z))))}),L3=v.forwardRef((n,e)=>{var t,s;let o=ro(),i=v.useRef(null),a=v.useContext(Vh),l=jr(),c=Yh(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;Os(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let f=Xh(o,i,[n.value,n.children,i],n.keywords),u=Mc(),m=xs(N=>N.value&&N.value===f.current),p=xs(N=>d||l.filter()===!1?!0:N.search?N.filtered.items.get(o)>0:!0);v.useEffect(()=>{let N=i.current;if(!(!N||n.disabled))return N.addEventListener(Ul,h),()=>N.removeEventListener(Ul,h)},[p,n.onSelect,n.disabled]);function h(){var N,C;g(),(C=(N=c.current).onSelect)==null||C.call(N,f.current)}function g(){u.setState("value",f.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:w,forceMount:y,keywords:j,...k}=n;return v.createElement(ws.div,{ref:Xo(i,e),...k,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||l.getDisablePointerSelection()?void 0:g,onClick:x?void 0:h},n.children)}),z3=v.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=ro(),l=v.useRef(null),c=v.useRef(null),d=ro(),f=jr(),u=xs(p=>o||f.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);Os(()=>f.group(a),[]),Xh(a,l,[n.value,n.heading,c]);let m=v.useMemo(()=>({id:a,forceMount:o}),[o]);return v.createElement(ws.div,{ref:Xo(l,e),...i,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},t&&v.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),ra(n,p=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},v.createElement(Vh.Provider,{value:m},p))))}),F3=v.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=v.useRef(null),i=xs(a=>!a.search);return!t&&!i?null:v.createElement(ws.div,{ref:Xo(o,e),...s,"cmdk-separator":"",role:"separator"})}),B3=v.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Mc(),a=xs(d=>d.search),l=xs(d=>d.selectedItemId),c=jr();return v.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),v.createElement(ws.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)}})}),U3=v.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=v.useRef(null),a=v.useRef(null),l=xs(d=>d.selectedItemId),c=jr();return v.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)}}},[]),v.createElement(ws.div,{ref:Xo(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},ra(n,d=>v.createElement("div",{ref:Xo(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),W3=v.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return v.createElement(Db,{open:t,onOpenChange:s},v.createElement(Lb,{container:a},v.createElement(zb,{"cmdk-overlay":"",className:o}),v.createElement(Fb,{"aria-label":n.label,"cmdk-dialog":"",className:i},v.createElement(Gh,{ref:e,...l}))))}),H3=v.forwardRef((n,e)=>xs(t=>t.filtered.count===0)?v.createElement(ws.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),K3=v.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return v.createElement(ws.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ra(n,a=>v.createElement("div",{"aria-hidden":!0},a)))}),So=Object.assign(Gh,{List:U3,Item:L3,Input:B3,Group:z3,Separator:F3,Dialog:W3,Empty:H3,Loading:K3});function q3(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function V3(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Yh(n){let e=v.useRef(n);return Os(()=>{e.current=n}),e}var Os=typeof window>"u"?v.useEffect:v.useLayoutEffect;function to(n){let e=v.useRef();return e.current===void 0&&(e.current=n()),e}function xs(n){let e=Mc(),t=()=>n(e.snapshot());return v.useSyncExternalStore(e.subscribe,t,t)}function Xh(n,e,t,s=[]){let o=v.useRef(),i=jr();return Os(()=>{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(eo,l),o.current=l}),o}var G3=()=>{let[n,e]=v.useState(),t=to(()=>new Map);return Os(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function Y3(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function ra({asChild:n,children:e},t){return n&&v.isValidElement(e)?v.cloneElement(Y3(e),{ref:e.ref},t(e.props.children)):t(e)}var X3={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Gn(n){const e=B.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(Yp,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function J3(n){const e=B.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(jc,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Q3(n){const e=B.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(Sc,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Yn(n){const e=B.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(Q3,{}),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(Wi,{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(jt,{"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(J3,{children:[l,r.jsxs(vc,{"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 ks(n){const e=B.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 Jh(n){const e=B.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 Xn(n){const e=B.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(yc,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jn(n){const e=B.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(wc,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Qh(n){const e=B.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(So,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function hI(n){const e=B.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(Xn,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(Jn,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(ks,{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(Yn,{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 x;return e[21]!==o||e[22]!==g?(x=r.jsx(Gn,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function gI(n){const e=B.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(bn,{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(So.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function Zh(n){const e=B.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(So.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function xI(n){const e=B.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(So.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function eg(n){const e=B.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(So.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function tg(n){const e=B.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(dt,{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(So.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 Z3(n){const e=B.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 ej(n){return r.jsx(Me,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const tj=v.memo(function(e){const t=B.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=v.useRef(f);let m,p;if(t[1]!==a?(m=()=>{var A;const P=u.current.get(a);P&&((A=P.scrollIntoView)==null||A.call(P,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),v.useEffect(m,p),i){let P;return t[4]===Symbol.for("react.memo_cache_sentinel")?(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.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[r.jsx(rt,{className:"size-3.5 animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=P):P=t[4],P}if(s.length===0){const P=o?`No commands or skills matching "${o}"`:"No commands or skills found";let A;return t[5]!==P?(A=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:P})})}),t[5]=P,t[6]=A):A=t[6],A}let h,g,x,b,w,y,j,k,N;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const P=s.filter(sj),A=[{heading:"Commands",suggestions:P,offset:0},{heading:"Skills",suggestions:s.filter(oj),offset:P.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Qh,w="slash-suggestions",y=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(j=T=>{const E=s.findIndex(M=>`${M.type}-${M.name}`===T);E>=0&&c(E)},t[21]=c,t[22]=s,t[23]=j):j=t[23],k=!1,N="border shadow-sm",h=Zh,b=A.map(T=>T.suggestions.length>0&&r.jsx(eg,{heading:T.heading,children:T.suggestions.map((E,M)=>{const I=T.offset+M;return r.jsx(nj,{suggestion:E,index:I,isSelected:I===a,onSelect:l,onHover:c,onEdit:d,itemRefs:u},`${E.type}-${E.name}`)})},T.heading)),t[7]=d,t[8]=c,t[9]=l,t[10]=a,t[11]=s,t[12]=h,t[13]=g,t[14]=x,t[15]=b,t[16]=w,t[17]=y,t[18]=j,t[19]=k,t[20]=N}else h=t[12],g=t[13],x=t[14],b=t[15],w=t[16],y=t[17],j=t[18],k=t[19],N=t[20];let C;t[24]!==h||t[25]!==b?(C=r.jsx(h,{children:b}),t[24]=h,t[25]=b,t[26]=C):C=t[26];let S;t[27]!==g||t[28]!==C||t[29]!==w||t[30]!==y||t[31]!==j||t[32]!==k||t[33]!==N?(S=r.jsx(g,{id:w,value:y,onValueChange:j,shouldFilter:k,className:N,children:C}),t[27]=g,t[28]=C,t[29]=w,t[30]=y,t[31]=j,t[32]=k,t[33]=N,t[34]=S):S=t[34];let _;return t[35]!==x||t[36]!==S?(_=r.jsx("div",{className:x,children:S}),t[35]=x,t[36]=S,t[37]=_):_=t[37],_});function nj({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=v.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(tg,{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(uo,{className:"size-4 text-muted-foreground"}):r.jsx(Qp,{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]}),ej(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(Z3,{className:i&&n.filePath?"mr-6":void 0,children:"Enter"})]}),i&&n.filePath&&r.jsx(J,{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(Ls,{"data-icon":"inline-start"})})]})}function sj(n){return n.type==="command"}function oj(n){return n.type==="skill"}function rj(n){const e=B.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=v.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]),v.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(rt,{"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 x;e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==a||e[15]!==s||e[16]!==i?(x=!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(tg,{ref:k=>{k?(k.id=`file-suggestion-${j}`,d.current.set(j,k)):d.current.delete(j)},value:y,onMouseEnter:()=>l(j),onSelect:()=>a(y),onMouseDown:ij,children:[r.jsx(Zp,{"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]=x):x=e[17];let b;e[18]!==g||e[19]!==x?(b=r.jsx(Zh,{className:"max-h-70",children:r.jsx(eg,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=b):b=e[20];let w;return e[21]!==m||e[22]!==p||e[23]!==b?(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(Qh,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:b})}),e[21]=m,e[22]=p,e[23]=b,e[24]=w):w=e[24],w}function ij(n){return n.preventDefault()}const aj=Bn("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 Ct(n){const e=B.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(aj({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 Dt(n){const e=B.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 _t(n){const e=B.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 bs(n){const e=B.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 kt(n){const e=B.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(Ub,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function ln(n){const e=B.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(Wb,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Nt(n){const e=B.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(Bb,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const lj={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function cf(n){return lj[n]??n.replaceAll("_"," ")}function cj(n){const e=B.c(46),{allowedPrompts:t,summary:s,planContent:o,actions:i,recommendedAction:a,responding:l,responseError:c,onApprove:d,onReject:f}=n;let u,m,p,h,g,x,b,w,y,j;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const A=i===void 0?[]:i;p=l===void 0?!1:l;const T=a??A[0],E=A.filter(R=>R!==T);m=Ct,b="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Hi,{}),y=r.jsx(Dt,{children:"Plan ready for review"}),e[15]=w,e[16]=y):(w=e[15],y=e[16]);const M=s||"Approve the plan or ask the agent to revise it.";e[17]!==M?(j=r.jsx(_t,{children:M}),e[17]=M,e[18]=j):j=e[18],u=bs,h="flex gap-2";let I;e[19]!==p?(I=p&&r.jsx(rt,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=I):I=e[20],g=r.jsxs(J,{size:"sm",disabled:p,onClick:()=>d(T),children:[I,p?"Sending...":T?cf(T):"Approve"]}),x=E.length>0&&r.jsxs(Rn,{children:[r.jsx(Mn,{render:r.jsx(J,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(st,{"data-icon":"icon"})}),r.jsx(In,{align:"end",children:r.jsx(Ft,{children:E.map(R=>r.jsx(ct,{onClick:()=>d(R),children:cf(R)},R))})})]}),e[0]=d,e[1]=a,e[2]=s,e[3]=i,e[4]=l,e[5]=u,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=b,e[12]=w,e[13]=y,e[14]=j}else u=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],b=e[11],w=e[12],y=e[13],j=e[14];let k;e[21]!==f||e[22]!==p?(k=r.jsx(J,{variant:"ghost",size:"sm",disabled:p,onClick:f,children:"Reject"}),e[21]=f,e[22]=p,e[23]=k):k=e[23];let N;e[24]!==u||e[25]!==k||e[26]!==h||e[27]!==g||e[28]!==x?(N=r.jsxs(u,{className:h,children:[g,x,k]}),e[24]=u,e[25]=k,e[26]=h,e[27]=g,e[28]=x,e[29]=N):N=e[29];let C;e[30]!==c?(C=c&&r.jsx("div",{role:"alert",className:"col-span-full mt-2 text-xs text-destructive",children:c}),e[30]=c,e[31]=C):C=e[31];let S;e[32]!==o?(S=o&&r.jsxs(kt,{className:"col-span-full mt-2",children:[r.jsx(ln,{render:r.jsx(J,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(Nt,{children:r.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 text-xs text-foreground",children:o})})]}),e[32]=o,e[33]=S):S=e[33];let _;e[34]!==t?(_=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(dj)]}),e[34]=t,e[35]=_):_=e[35];let P;return e[36]!==m||e[37]!==N||e[38]!==C||e[39]!==S||e[40]!==_||e[41]!==b||e[42]!==w||e[43]!==y||e[44]!==j?(P=r.jsxs(m,{className:b,children:[w,y,j,N,C,S,_]}),e[36]=m,e[37]=N,e[38]=C,e[39]=S,e[40]=_,e[41]=b,e[42]=w,e[43]=y,e[44]=j,e[45]=P):P=e[45],P}function dj(n,e){return r.jsx(Me,{variant:"outline",children:n.prompt},e)}const uj=["allow","allow_always","deny"];function Xr(n,e){return(n.availableDecisions??uj).includes(e)}function fj(n){switch(n){case"Bash":return{label:"Run command",icon:uo,tone:"cmd"};case"Edit":return{label:"Edit file",icon:Bu,tone:"write"};case"Write":return{label:"Write file",icon:Bu,tone:"write"};case"Read":return{label:"Read file",icon:yo,tone:"read"};case"Glob":return{label:"File search",icon:bn,tone:"search"};case"Grep":return{label:"Content search",icon:bn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:Il,tone:"net"};case"WebSearch":return{label:"Web search",icon:Il,tone:"net"};default:return{label:n,icon:Ki,tone:"other"}}}function mj(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 pj({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?Xr(o,"allow"):!1,l=o?Xr(o,"allow_always"):!1,c=o?Xr(o,"deny"):!1,d=i>1&&n.every(y=>Xr(y,"allow")),f=v.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 k=y.key.toLowerCase();k==="a"&&y.shiftKey&&d?(y.preventDefault(),s("allow")):k==="a"&&a?(y.preventDefault(),t(o.requestId,"allow")):k==="s"&&l?(y.preventDefault(),t(o.requestId,"allow_always")):k==="d"&&c&&(y.preventDefault(),t(o.requestId,"deny"))});v.useEffect(()=>{const y=j=>f(j);return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]);const u=o?fj(o.toolName):null,m=o?mj(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,x=e.has(o.requestId),b=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(Gp,{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}),b&&r.jsxs(Me,{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(J,{variant:"ghost",size:"sm",className:"text-destructive",disabled:x,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(jt,{"data-icon":"inline-start"}),"Deny",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]}),l&&r.jsxs(J,{variant:"outline",size:"sm",disabled:x,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(Hb,{"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(J,{variant:"secondary",size:"sm",disabled:x,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(J,{size:"sm",disabled:x,onClick:()=>t(o.requestId,"allow"),title:"Allow once (A)",children:[r.jsx(dt,{"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 hj=1568,gj=.85,df=35e5;function xj(n,e){let{width:t,height:s}=n;const o=Math.min(1,hj/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?gj:void 0),f=d.split(",")[1];if(f.length>df){let u=l?.7:.8;for(;f.length>df&&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 bj(n){const e=B.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]=v.useState(s),[a,l]=v.useState(!1),[c,d]=v.useState(!1),f=v.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]),v.useEffect(u,m);let p;e[4]!==t?(p=R=>{const $=Array.from(R).filter(wj);if(!t){$.length>0&&d(!0);return}d(!1);for(const D of $){const O=new FileReader;O.onload=()=>{if(!f.current){d(!0);return}const L=O.result,F=new Image;F.onload=()=>{if(!f.current){d(!0);return}const z=xj(F,D.type);i(H=>[...H,{id:crypto.randomUUID(),file:D,preview:z.dataUrl,data:z.base64,mediaType:z.mediaType}])},F.src=L},O.onerror=()=>{console.warn(`Failed to read image file: ${D.name}`)},O.readAsDataURL(D)}},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($=>$.filter((D,O)=>O!==R)),d(!1)},e[6]=g):g=e[6];const x=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{i([]),d(!1)},e[7]=b):b=e[7];const w=b;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=()=>d(!1),e[8]=y):y=e[8];const j=y;let k;e[9]!==t?(k=R=>{R.preventDefault(),t&&l(!0)},e[9]=t,e[10]=k):k=e[10];const N=k;let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{R.preventDefault(),R.currentTarget.contains(R.relatedTarget)||l(!1)},e[11]=C):C=e[11];const S=C;let _;e[12]!==h?(_=R=>{R.preventDefault(),l(!1),R.dataTransfer.files.length>0&&h(R.dataTransfer.files)},e[12]=h,e[13]=_):_=e[13];const P=_;let A;e[14]!==h?(A=R=>{var L;const $=(L=R.clipboardData)==null?void 0:L.items;if(!$)return;const D=Array.from($).filter(yj);if(D.length===0)return;R.preventDefault();const O=D.map(vj).filter(Boolean);h(O)},e[14]=h,e[15]=A):A=e[15];const T=A,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]!==N||e[17]!==P||e[18]!==T||e[19]!==o||e[20]!==a||e[21]!==E||e[22]!==M?(I={images:o,isDragOver:a,imageError:E,hasUnsupportedAttachments:M,dismissImageError:j,removeImage:x,clearImages:w,handleDragOver:N,handleDragLeave:S,handleDrop:P,handlePaste:T},e[16]=N,e[17]=P,e[18]=T,e[19]=o,e[20]=a,e[21]=E,e[22]=M,e[23]=I):I=e[23],I}function vj(n){return n.getAsFile()}function yj(n){return n.type.startsWith("image/")}function wj(n){return n.type.startsWith("image/")}function jj(n){const e=B.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(Gb,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function Et(n){const e=B.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(jj,{children:r.jsx(Vb,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Pt(n){const e=B.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(Kb,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function At(n){const e=B.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(qb,{"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(Yb,{children:r.jsx(Xb,{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}Zt("claude").contextWindow.compactBuffer;function Sj(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=Zt(e).contextWindow,i=n.trim().toLowerCase();return o&&i.includes(o.marker)?o.limit:((a=s.find(l=>i.includes(l.match)))==null?void 0:a.limit)??t}function kj(n,e,t){const s=typeof n.input_tokens=="number"?n.input_tokens:0,o=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,i=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,a=s+o+i,l=Sj(e,t),c=l-Zt(t).contextWindow.compactBuffer;return{used:a,limit:l,compactAt:c,percent:Math.min(100,a/c*100),percentAbsolute:Math.min(100,a/l*100)}}const Nj=4;function ng(n){return Math.ceil(n/Nj)}function sg(n){let e=0;for(const t of n)e+=t.length;return e}function Cj(n){let e=0;for(const t of n)e+=JSON.stringify(t.input).length;return e}function _j(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:ng(sg(n.thinking.map(o=>o.thinking)))}function Tj(n){return ng(sg(n.assistantText)+Cj(n.toolCalls))}function as(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function ia(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 nt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function En(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 Ej(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function og(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Sr(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 Ic(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 $c(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e=0,t=n.timestamp,s="";const o=a=>{a&&a>s&&(s=a)},i=()=>{if(!s)return;const a=new Date(s).getTime()-new Date(t).getTime();a>0&&(e+=a),s=""};for(const a of n.contentBlocks){if(a.kind==="task_notification"){i(),a.timestamp&&(t=a.timestamp);continue}if(o(a.timestamp),a.kind==="tool_calls"||a.kind==="plan_mode")for(const l of a.toolCalls)o(l.timestamp)}return i(),e>0?e:null}function pn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function gn(n){return js(n).dirName.decode(n)??n}function aa(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function la(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 zn(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function vs(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function rg(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return kj(t.message.usage,t.message.model??"","claude")}return null}const Cn="rounded-full border bg-background/80 shadow-sm backdrop-blur",ca=v.memo(function(e){const t=B.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}),Ja=v.memo(function(e){const t=B.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(J,{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(Pt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(At,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(Et,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function Pj(n){return n<10?"critical":n<30?"warning":"healthy"}const Aj={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},ig=v.memo(function(e){const t=B.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,x,b,w,y,j,k,N;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const P=rg(s);if(!P){x=null;break e}const A=Math.max(0,100-P.percent),T=Pj(A);if(d&&T==="healthy"){x=null;break e}const E=Math.max(0,P.compactAt-P.used);let M;t[17]!==A||t[18]!==E||t[19]!==l?(M=l?`${A.toFixed(0)}% · ${nt(E)}`:`${A.toFixed(0)}%`,t[17]=A,t[18]=E,t[19]=l,t[20]=M):M=t[20];const I=M,R=Aj[T],$=l&&"gap-1";let D;t[21]!==R||t[22]!==$?(D=G("shrink-0 tabular-nums",R,$),t[21]=R,t[22]=$,t[23]=D):D=t[23];let O;t[24]!==I||t[25]!==D?(O=r.jsx(Me,{variant:"outline",className:D,children:I}),t[24]=I,t[25]=D,t[26]=O):O=t[26];const L=O;if(!c){x=L;break e}u=Et,t[27]!==L?(g=r.jsx(Pt,{render:L}),t[27]=L,t[28]=g):g=t[28],f=At,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 F;t[30]!==E?(F=nt(E),t[30]=E,t[31]=F):F=t[31];let z;t[32]!==A?(z=A.toFixed(1),t[32]=A,t[33]=z):z=t[33],t[34]!==F||t[35]!==z?(h=r.jsxs("div",{children:[F," remaining (",z,"%)"]}),t[34]=F,t[35]=z,t[36]=h):h=t[36],b="text-muted-foreground",w=nt(P.used),y=" / ",j=nt(P.limit),k=" tokens used (",N=P.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]=x,t[11]=b,t[12]=w,t[13]=y,t[14]=j,t[15]=k,t[16]=N}else f=t[4],u=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],b=t[11],w=t[12],y=t[13],j=t[14],k=t[15],N=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==b||t[38]!==w||t[39]!==y||t[40]!==j||t[41]!==k||t[42]!==N?(C=r.jsxs("div",{className:b,children:[w,y,j,k,N,"%)"]}),t[37]=b,t[38]=w,t[39]=y,t[40]=j,t[41]=k,t[42]=N,t[43]=C):C=t[43];let S;t[44]!==f||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==C?(S=r.jsxs(f,{className:m,children:[p,h,C]}),t[44]=f,t[45]=m,t[46]=p,t[47]=h,t[48]=C,t[49]=S):S=t[49];let _;return t[50]!==u||t[51]!==g||t[52]!==S?(_=r.jsxs(u,{children:[g,S]}),t[50]=u,t[51]=g,t[52]=S,t[53]=_):_=t[53],_});function Rj(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=it(),{chat:a}=wr(),{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:Ej(o)}),r.jsx(ca,{})]}),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 Mj(n){const e=B.c(26),{hasContent:t,onSubmit:s,submitLabel:o}=n,i=o===void 0?"Send message":o,{isLive:a,sessionSource:l,actions:c}=it(),{handleStopSession:d}=c,{chat:f}=wr(),{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)??St((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;let x;e[3]!==g?(x=Iw(g),e[3]=g,e[4]=x):x=e[4];const b=x;let w;e[5]!==b||e[6]!==m||e[7]!==p?(w=p&&r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(J,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:r.jsx(Nc,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(At,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=w):w=e[8];let y;e[9]!==g||e[10]!==d||e[11]!==p?(y=p&&Ut(g).stopSession&&r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(J,{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(Jb,{"data-icon":"inline-start"})}),r.jsx(At,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=y):y=e[12];const j=t?"default":"secondary",k=!t&&"text-muted-foreground";let N;e[13]!==k?(N=G("shrink-0 rounded-full",k),e[13]=k,e[14]=N):N=e[14];const C=!t;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Qb,{"data-icon":"inline-start"}),e[15]=S):S=e[15];let _;e[16]!==s||e[17]!==i||e[18]!==N||e[19]!==C||e[20]!==j?(_=r.jsx(J,{variant:j,size:"icon-sm",className:N,disabled:C,onClick:s,"aria-label":i,title:i,children:S}),e[16]=s,e[17]=i,e[18]=N,e[19]=C,e[20]=j,e[21]=_):_=e[21];let P;return e[22]!==_||e[23]!==w||e[24]!==y?(P=r.jsxs("div",{className:"flex items-center gap-1",children:[w,y,_]}),e[22]=_,e[23]=w,e[24]=y,e[25]=P):P=e[25],P}function uf(n){const e=B.c(34),{error:t}=n,[s,o]=v.useState(!1),[i,a]=v.useState(!1);let l;e[0]!==t?(l=t.split(`
|
|
3
3
|
`),e[0]=t,e[1]=l):l=e[1];const c=l[0];let d;e[2]!==t||e[3]!==c?(d=t.includes(`
|
|
4
4
|
`)||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(vn,{"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 x;e[11]!==f?(x=f&&r.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=f,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=r.jsxs(J,{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,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(ks,{children:[r.jsxs(Xn,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(vn,{className:"size-4"}),"Error details"]}),r.jsx(Jn,{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(dt,{"data-icon":"inline-start"}):r.jsx(Pn,{"data-icon":"inline-start"}),e[19]=i,e[20]=j):j=e[20];const k=i?"Copied":"Copy";let N;e[21]!==m||e[22]!==j||e[23]!==k?(N=r.jsx("div",{className:"flex justify-end",children:r.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,k]})}),e[21]=m,e[22]=j,e[23]=k,e[24]=N):N=e[24];let C;e[25]!==y||e[26]!==N?(C=r.jsxs(Yn,{className:"max-w-2xl",children:[w,y,N]}),e[25]=y,e[26]=N,e[27]=C):C=e[27];let S;e[28]!==s||e[29]!==C?(S=r.jsx(Gn,{open:s,onOpenChange:o,children:C}),e[28]=s,e[29]=C,e[30]=S):S=e[30];let _;return e[31]!==S||e[32]!==b?(_=r.jsxs(r.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=_):_=e[33],_}function Ij(n){const e=B.c(17),{suggestion:t,onAccept:s}=n,[o,i]=v.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(Qp,{"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(J,{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(jt,{}),e[11]=u):u=e[11];let m;e[12]!==f?(m=r.jsx(J,{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 $j(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 Oj(n,e,t){return`${n.slice(0,e.start)}@${t} `}const da={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},kr={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let ag=da;const Wl=new Set;function oo(n){ag=(n==null?void 0:n.capabilities)??da;for(const e of Wl)e()}function ut(n){return ag[n]}function Dj(n){return Wl.add(n),()=>Wl.delete(n)}function yn(n){const e=B.c(3);let t,s;return e[0]!==n?(t=()=>ut(n),s=()=>ut(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),v.useSyncExternalStore(Dj,t,s)}function Lj(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function zj(n,e,t){const s=yn("hostFiles"),[o,i]=v.useState([]),[a,l]=v.useState(!1);return v.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(Lj(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 Hl="cogpit-share-revoked";function Fj(){window.dispatchEvent(new Event(Hl))}async function lg(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&&Fj(),s}function Nr(n,e){return lg(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function Bj(){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 Uj(n,e){return Nr("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function Wj(){return Nr("/api/share/interrupt")}function Hj(){return Nr("/api/share/stop")}async function Kj(n,e){return(await Nr("/api/share/permission",{requestId:n,behavior:e})).ok}async function qj(n,e){try{const t=await Nr("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function Vj(){try{const n=await lg("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const Gj=/^\/shared\/([^/]+)\/?$/;function cg(n){const e=Gj.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function ua(n){return cg(n)!==null}function Yj(n){return`/shared/${encodeURIComponent(n)}`}function bI(n){return[...n].join(", ")}async function Oc(n,e,t){if(ua(window.location.pathname))return qj(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}}}async function Xj(n,e,t){try{return(await ye(`/api/permissions/${encodeURIComponent(n)}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,...t})})).ok}catch{return!1}}function fa(n){const e=B.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 Jr(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 Jj(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 Qj(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 Kl=v.memo(v.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,compact:i=!1},a){var Le;const l=yn("hostFiles"),{session:c,isLive:d,actions:{handleEditConfig:f},pendingInteraction:u,permissionRequests:m,permissionResponding:p,respondPermission:h,respondAllPermissions:g,slashSuggestions:x,slashSuggestionsLoading:b,turnError:w,promptSuggestion:y}=it(),{chat:{status:j,error:k,isConnected:N,sendMessage:C,interrupt:S}}=wr(),_=N||d,[P,A]=v.useState(""),[T,E]=v.useState(!1),[M,I]=v.useState(!1),[R,$]=v.useState(null),D=v.useRef(null),O=v.useRef(null),L=v.useRef(!1),F=v.useRef(""),z=v.useRef(null);v.useEffect(()=>{F.current=P},[P]);const H=v.useCallback(ne=>{L.current=ne,E(ne)},[]),{images:U,isDragOver:W,imageError:K,hasUnsupportedAttachments:q,dismissImageError:Y,removeImage:V,clearImages:Q,handleDragOver:Z,handleDragLeave:X,handleDrop:ee,handlePaste:oe}=bj(e),[se,re]=v.useState(0),[ie,ae]=v.useState(0),[te,he]=v.useState(!1),me=P.startsWith("/")&&!P.includes(" "),le=me?P.slice(1):"",xe=v.useMemo(()=>{if(!me)return[];const ne=le.toLowerCase(),fe=x.filter(Ue=>ne?Ue.name.toLowerCase().includes(ne)||Ue.description.toLowerCase().includes(ne):!0),Se=fe.filter(Ue=>Ue.type==="command"),$e=fe.filter(Ue=>Ue.type==="skill");return[...Se,...$e]},[me,le,x]),ge=v.useMemo(()=>$j(P),[P]),ce=!!(l&&ge&&s&&!te),we=zj(s,(ge==null?void 0:ge.query)??"",ce);v.useEffect(()=>{re(0)},[le]),v.useEffect(()=>{ae(0)},[ge==null?void 0:ge.query]);const pe=Fh(N),ue=(u==null?void 0:u.type)==="plan"?u.requestId??null:null;v.useEffect(()=>{O.current=ue,D.current=null,I(!1),$(null)},[ue]);const je=v.useCallback(async ne=>{const fe=u;if(!(c!=null&&c.sessionId)||(fe==null?void 0:fe.type)!=="question")return;const Se=fe.questions[0];if(!Se||!ne.trim())return;(await Oc(c.sessionId,fe.toolUseId,{[Se.question]:ne})).ok||C(ne)},[u,c==null?void 0:c.sessionId,C]),Ne=v.useCallback(async(ne,fe,Se)=>{const $e=u;if(($e==null?void 0:$e.type)==="plan"&&$e.provider==="copilot"&&$e.requestId&&(c!=null&&c.sessionId)){const Ue=$e.requestId;if(D.current)return!1;D.current=Ue,I(!0),$(null);try{const We=await Xj(c.sessionId,Ue,{approved:ne,...fe?{selectedAction:fe}:{},...Se?{feedback:Se}:{}});return!We&&O.current===Ue&&$("Couldn't send the plan response. Try again."),We}finally{D.current===Ue&&(D.current=null,I(!1))}}return C(ne?"yes":Se||"no"),!0},[u,c==null?void 0:c.sessionId,C]),Re=v.useCallback(()=>{requestAnimationFrame(()=>{const ne=z.current;ne&&(ne.focus(),ne.selectionStart=ne.selectionEnd=ne.value.length,H(Jr(ne,L.current)))})},[H]),Te=v.useCallback(ne=>{A(`/${ne.name} `),re(0),Re()},[Re]),Pe=v.useCallback(ne=>{A(ne),Re()},[Re]),Oe=v.useCallback(ne=>{if(!ge)return;const fe=Oj(P,ge,ne);A(fe),he(!0),ae(0),requestAnimationFrame(()=>{const Se=z.current;Se&&(Se.focus(),Se.selectionStart=Se.selectionEnd=Se.value.length,H(Jr(Se,L.current)))})},[ge,P,H]),Fe=v.useCallback(async()=>{const ne=P.trim();if(!ne&&U.length===0||!e&&U.length>0)return;if((u==null?void 0:u.type)==="question"){je(ne),A(""),H(!1),z.current&&(z.current.style.height="auto");return}if((u==null?void 0:u.type)==="plan"&&u.provider==="copilot"){if(!ne||!await Ne(!1,void 0,ne))return;A(""),H(!1),z.current&&(z.current.style.height="auto");return}const fe=e&&U.length>0?U.map(Se=>({data:Se.data,mediaType:Se.mediaType})):void 0;C(ne,fe),A(""),Q(),H(!1),z.current&&(z.current.style.height="auto")},[P,U,e,C,Q,H,u,je,Ne]),ze=v.useCallback(ne=>{if(ce&&ne.key==="Escape"){ne.preventDefault(),he(!0);return}if(ce&&we.files.length>0){if(ne.key==="ArrowDown"){ne.preventDefault(),ae(fe=>fe<we.files.length-1?fe+1:0);return}if(ne.key==="ArrowUp"){ne.preventDefault(),ae(fe=>fe>0?fe-1:we.files.length-1);return}if(ne.key==="Tab"||ne.key==="Enter"&&!ne.shiftKey){ne.preventDefault();const fe=we.files[ie];fe&&Oe(fe);return}}if(me&&xe.length>0){if(ne.key==="ArrowDown"){ne.preventDefault(),re(fe=>fe<xe.length-1?fe+1:0);return}if(ne.key==="ArrowUp"){ne.preventDefault(),re(fe=>fe>0?fe-1:xe.length-1);return}if(ne.key==="Tab"||ne.key==="Enter"&&!ne.shiftKey){ne.preventDefault();const fe=xe[se];fe&&Te(fe);return}if(ne.key==="Escape"){ne.preventDefault(),A("");return}}if(ne.key==="Escape"&&_&&S){ne.preventDefault(),S();return}ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),Fe())},[Fe,_,S,ce,we.files,ie,Oe,me,xe,se,Te]),Be=v.useCallback(ne=>{A(ne.target.value),he(!1),H(Jr(ne.target,L.current))},[H]);v.useImperativeHandle(a,()=>({focus:()=>{var ne;return(ne=z.current)==null?void 0:ne.focus()},getText:()=>F.current,setText:ne=>{A(ne),he(!1),requestAnimationFrame(()=>H(Jr(z.current,L.current)))}}),[H]);const _e=(u==null?void 0:u.type)==="plan",He=(u==null?void 0:u.type)==="question",Ie=m.length>0,Ce=(P.trim().length>0||U.length>0)&&!q,de=Ut(t??Fs).midTurnSteering&&_,Ee=ce?"file-suggestions":me?"slash-suggestions":void 0,Ae=ce&&we.files[ie]?`file-suggestion-${ie}`:me&&xe[se]?`slash-suggestion-${se}`:void 0;return r.jsxs("div",{className:G("relative bg-background pb-0",i?"px-2 pt-2":"px-3 pt-2",W&&"ring-2 ring-info/40 ring-inset"),onDragOver:Z,onDragLeave:X,onDrop:ee,children:[W&&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"})}),me&&r.jsx(tj,{suggestions:xe,filter:le,loading:b,selectedIndex:se,onSelect:Te,onHover:re,onEdit:f}),ce&&r.jsx(rj,{files:we.files,query:(ge==null?void 0:ge.query)??"",loading:we.loading,selectedIndex:ie,onSelect:Oe,onHover:ae}),r.jsxs("div",{children:[_e&&r.jsx(cj,{allowedPrompts:u.allowedPrompts,summary:u.summary,planContent:u.planContent,actions:u.actions,recommendedAction:u.recommendedAction,responding:M,responseError:R,onApprove:ne=>{Ne(!0,ne)},onReject:()=>{Ne(!1)}}),r.jsx(Ij,{suggestion:y,onAccept:Pe}),U.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:U.map((ne,fe)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:ne.preview,alt:`Upload ${fe+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>V(fe),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 ${fe+1}`,children:r.jsx(jt,{className:"size-3","data-icon":"icon"})})]},ne.id))}),K&&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:K}),!q&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:Y,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(jt,{"data-icon":"icon"})})]}),r.jsxs("div",{className:G("relative overflow-hidden rounded-xl border bg-prompt-surface shadow-xs",Qj(_e,He,Ie),"focus-within:ring-3"),children:[Ie&&r.jsx(pj,{requests:m,responding:p,onRespond:h,onRespondAll:g},(Le=m[0])==null?void 0:Le.requestId),r.jsxs("div",{className:G("grid min-w-0 items-end",T?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]"),children:[o&&r.jsx("div",{className:G("flex shrink-0 items-center",T?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:o}),r.jsx(fa,{ref:z,value:P,onChange:Be,onKeyDown:ze,onPaste:oe,onFocus:()=>{setTimeout(()=>{var ne;return(ne=z.current)==null?void 0:ne.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:Jj(_e,He,N,Ie,de,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Ee,"aria-controls":Ee,"aria-activedescendant":Ae,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",T?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",T?"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(Rj,{isPlanApproval:_e,isUserQuestion:He,elapsedSec:pe}),r.jsx(Mj,{hasContent:Ce,onSubmit:Fe,submitLabel:de?"Steer active turn":"Send message"})]})]})]}),j==="error"&&k&&r.jsx(uf,{error:k},k),w&&r.jsx(uf,{error:w},w)]})]})}));function Zj(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function eS(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=Zj(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}function Qr(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Ot(n){const e=B.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(Zb,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Dc(n){const e=B.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(tS,{children:r.jsx(nS,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(ev,{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 tS(n){const e=B.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(tv,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function nS(n){const e=B.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(nv,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const sS={section:null,canCreate:!1,beginEditing:()=>{}},Lc=v.createContext(sS);function dg(){return v.useContext(Lc)}const ug="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",fg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function oS(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function rS(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function iS({agentKind:n,threadId:e,children:t}){const s=oa(n),[o,i]=v.useState(null),[a,l]=v.useState(!0),[c,d]=v.useState(!1),[f,u]=v.useState(""),[m,p]=v.useState(""),[h,g]=v.useState(!1),[x,b]=v.useState(null),w=v.useCallback(async P=>{try{const A=await ye(Qr(e),{signal:P});if(A.status===404||A.status===501){l(!1);return}if(!A.ok)return;const T=await A.json();i(T.goal),l(!0)}catch{}},[e]);v.useEffect(()=>{const P=new AbortController;w(P.signal);const A=a?setInterval(()=>void w(),1e4):void 0;return()=>{P.abort(),A!==void 0&&clearInterval(A)}},[w,a]);const y=v.useCallback(()=>{var P;u((o==null?void 0:o.objective)??""),p(((P=o==null?void 0:o.tokenBudget)==null?void 0:P.toString())??""),b(null),d(!0)},[o]),j=async()=>{const P=f.trim();if(!P)return;const A=m.trim()?Number(m):null;if(A!==null&&(!Number.isSafeInteger(A)||A<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const T=await ye(Qr(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:P,status:(o==null?void 0:o.status)==="complete"?"active":(o==null?void 0:o.status)??"active",tokenBudget:A})}),E=await T.json();if(!T.ok)throw new Error(E.error||"Could not save goal");i(E.goal),d(!1)}catch(T){b(T instanceof Error?T.message:"Could not save goal")}finally{g(!1)}},k=async P=>{if(o){g(!0);try{const A=await ye(Qr(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:P})});A.ok&&i((await A.json()).goal)}finally{g(!1)}}},N=async()=>{g(!0);try{(await ye(Qr(e),{method:"DELETE"})).ok&&(i(null),d(!1))}finally{g(!1)}},C=o!=null&&o.tokenBudget?Math.min(100,o.tokensUsed/o.tokenBudget*100):null;let S=null;if(a&&c)S=r.jsxs("form",{className:fg,onSubmit:P=>{P.preventDefault(),j()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(Jo,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(jo,{className:"gap-2",children:[r.jsxs(gt,{children:[r.jsx(xt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(fa,{id:"goal-objective",value:f,onChange:P=>u(P.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),r.jsxs(gt,{orientation:"horizontal","data-invalid":!!x,children:[r.jsx(xt,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),r.jsx(Ot,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:P=>p(P.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),r.jsx(us,{className:"mt-1.5",children:x}),r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(!1),children:[r.jsx(jt,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(J,{type:"submit",size:"xs",disabled:h||!f.trim(),children:[r.jsx(dt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const P=o.status==="paused",A=o.status==="complete";S=r.jsxs("section",{className:ug,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Jo,{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:o.objective,children:o.objective}),r.jsx(Me,{variant:rS(o.status),children:oS(o.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[nt(o.tokensUsed),o.tokenBudget?` / ${nt(o.tokenBudget)}`:""," · ",Math.max(0,Math.round(o.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[P&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx(gr,{"data-icon":"icon"})}),!P&&!A&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(sv,{"data-icon":"icon"})}),!A&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(dt,{"data-icon":"icon"})}),r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:y,"aria-label":"Edit goal",children:r.jsx(Ls,{"data-icon":"icon"})}),r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void N(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(qi,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(Dc,{className:"mt-1 mb-0.5",value:C,"aria-label":`${C.toFixed(0)}% of goal token budget used`})]})}const _=v.useMemo(()=>({section:S,canCreate:a&&!o&&!c,beginEditing:y}),[S,a,o,c,y]);return r.jsx(Lc.Provider,{value:_,children:t})}function aS(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function lS(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function cS(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=oa(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=eS(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const d=c,[f,u]=v.useState(),[m,p]=v.useState(!1),[h,g]=v.useState(""),[x,b]=v.useState(null),w=d?`${d.status}\0${d.condition}`:"",[y,j]=v.useState(w);y!==w&&(j(w),u(void 0));const k=f!==void 0?f:d;let N;e[4]!==(k==null?void 0:k.condition)?(N=()=>{g((k==null?void 0:k.condition)??""),b(null),p(!0)},e[4]=k==null?void 0:k.condition,e[5]=N):N=e[5];const C=N;let S;e[6]!==h||e[7]!==o?(S=()=>{const $=h.trim();if($){if($.length>4e3){b("Goal conditions can be at most 4,000 characters");return}u({condition:$,status:"active",iterations:0,durationMs:0,tokens:0}),p(!1),o(`/goal ${$}`)}},e[6]=h,e[7]=o,e[8]=S):S=e[8];const _=S;let P;e[9]!==o?(P=()=>{u(null),p(!1),o("/goal clear")},e[9]=o,e[10]=P):P=e[10];const A=P;let T;if(e[11]!==l||e[12]!==C||e[13]!==A||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==k||e[18]!==_){if(T=null,m){let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Jo,{className:"size-3.5","data-icon":"inline-start"}),e[20]=$):$=e[20];const D=k?"Replace goal":"Set a long-running goal";let O;e[21]!==D?(O=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[$,D]}),e[21]=D,e[22]=O):O=e[22];const L=!!x;let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(xt,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[23]=F):F=e[23];let z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=ee=>g(ee.target.value),e[24]=z):z=e[24];const H=`A measurable condition ${l} should keep working toward…`,U=!!x;let W;e[25]!==h||e[26]!==H||e[27]!==U?(W=r.jsx(fa,{id:"goal-condition",value:h,onChange:z,placeholder:H,rows:2,maxLength:4e3,"aria-invalid":U,autoFocus:!0}),e[25]=h,e[26]=H,e[27]=U,e[28]=W):W=e[28];let K;e[29]!==x?(K=r.jsx(us,{children:x}),e[29]=x,e[30]=K):K=e[30];let q;e[31]!==W||e[32]!==K||e[33]!==L?(q=r.jsxs(gt,{"data-invalid":L,children:[F,W,K]}),e[31]=W,e[32]=K,e[33]=L,e[34]=q):q=e[34];let Y;e[35]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[r.jsx(jt,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=Y):Y=e[35];let V;e[36]!==h?(V=h.trim(),e[36]=h,e[37]=V):V=e[37];const Q=!V;let Z;e[38]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(dt,{"data-icon":"inline-start"}),e[38]=Z):Z=e[38];let X;e[39]!==_||e[40]!==Q?(X=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,r.jsxs(J,{type:"button",size:"xs",onClick:_,disabled:Q,children:[Z,"Start goal"]})]}),e[39]=_,e[40]=Q,e[41]=X):X=e[41],T=r.jsxs("section",{className:fg,"aria-label":`${l} goal editor`,children:[O,q,X]})}else if(k){let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Jo,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=$):$=e[42];let D;e[43]!==k.condition?(D=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:k.condition,children:k.condition}),e[43]=k.condition,e[44]=D):D=e[44];let O;e[45]!==k.status?(O=lS(k.status),e[45]=k.status,e[46]=O):O=e[46];let L;e[47]!==k.status?(L=aS(k.status),e[47]=k.status,e[48]=L):L=e[48];let F;e[49]!==O||e[50]!==L?(F=r.jsx(Me,{variant:O,children:L}),e[49]=O,e[50]=L,e[51]=F):F=e[51];const z=k.iterations,H=k.iterations===1?"":"s";let U;e[52]!==k.tokens?(U=nt(k.tokens),e[52]=k.tokens,e[53]=U):U=e[53];let W;e[54]!==k.durationMs?(W=Math.round(k.durationMs/6e4),e[54]=k.durationMs,e[55]=W):W=e[55];const K=Math.max(0,W);let q;e[56]!==k.iterations||e[57]!==H||e[58]!==U||e[59]!==K?(q=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[z," turn",H," · ",U," · ",K,"m"]}),e[56]=k.iterations,e[57]=H,e[58]=U,e[59]=K,e[60]=q):q=e[60];let Y;e[61]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Ls,{"data-icon":"icon"}),e[61]=Y):Y=e[61];let V;e[62]!==C?(V=r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:Y}),e[62]=C,e[63]=V):V=e[63];let Q;e[64]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(qi,{"data-icon":"icon"}),e[64]=Q):Q=e[64];let Z;e[65]!==A?(Z=r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:Q}),e[65]=A,e[66]=Z):Z=e[66];let X;e[67]!==V||e[68]!==Z?(X=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[V,Z]}),e[67]=V,e[68]=Z,e[69]=X):X=e[69];let ee;e[70]!==F||e[71]!==q||e[72]!==X||e[73]!==D?(ee=r.jsxs("div",{className:"flex items-center gap-2",children:[$,D,F,q,X]}),e[70]=F,e[71]=q,e[72]=X,e[73]=D,e[74]=ee):ee=e[74];let oe;e[75]!==k.reason?(oe=k.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:k.reason}),e[75]=k.reason,e[76]=oe):oe=e[76],T=r.jsxs("section",{className:ug,"aria-label":`${l} goal`,children:[ee,oe]})}e[11]=l,e[12]=C,e[13]=A,e[14]=h,e[15]=m,e[16]=x,e[17]=k,e[18]=_,e[19]=T}else T=e[19];const E=!k&&!m;let M;e[77]!==C||e[78]!==T||e[79]!==E?(M={section:T,canCreate:E,beginEditing:C},e[77]=C,e[78]=T,e[79]=E,e[80]=M):M=e[80];const I=M;let R;return e[81]!==i||e[82]!==I?(R=r.jsx(Lc.Provider,{value:I,children:i}),e[81]=i,e[82]=I,e[83]=R):R=e[83],R}function dS(n){const e=B.c(9),{agentKind:t,session:s,onSendCommand:o,children:i}=n,a=Ut(t).goals;if(a==="thread-api"){let l;return e[0]!==t||e[1]!==i||e[2]!==s.sessionId?(l=r.jsx(iS,{agentKind:t,threadId:s.sessionId,children:i}),e[0]=t,e[1]=i,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(a==="transcript"){let l;return e[4]!==t||e[5]!==i||e[6]!==o||e[7]!==s?(l=r.jsx(cS,{agentKind:t,session:s,onSendCommand:o,children:i}),e[4]=t,e[5]=i,e[6]=o,e[7]=s,e[8]=l):l=e[8],l}return i}function mg(){return dg().section}function pg(){const n=B.c(3),{canCreate:e,beginEditing:t}=dg();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Jo,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let o;return n[1]!==t?(o=r.jsxs(J,{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 uS(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(mg,{}),r.jsx(pg,{})]}),n[0]=e):e=n[0],e}const fS=/\x1b\].*?(?:\x07|\x1b\\)/g,mS=/\x1b\[[0-9;]*[A-Za-z]/g,pS=/\x1b[()][AB012]/g,hS=/\[2K\[1G/g;function hg(n){return n.replace(fS,"").replace(mS,"").replace(pS,"").replace(hS,`
|
|
5
|
-
`).replace(/\r/g,"")}function Cr(n){const e=B.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(rv,{"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(gS,{}),c=r.jsx(iv,{}),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(ov,{"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 gS(n){const e=B.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(lv,{"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(av,{"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 gg(n){const e=B.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 xS(n){const e=B.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 bS(n){const e=B.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 vS(n){const e=B.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 Bt(n){const e=B.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=gg,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 yS(n){const e=yn("hostFiles"),[t,s]=v.useState([]),[o,i]=v.useState(!1),a=v.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 v.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const ff=500,wS=5e3;function jS(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=v.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=v.useState(i),c=v.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const f=v.useRef(d),u=v.useRef(ff),m=v.useRef(null),p=v.useRef(!1),h=v.useRef(SS);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=L=>{var H;const F=L.type,z=L.id;if(F==="sessions"){l(L.sessions??[]);return}z&&((H=f.current.get(z))==null||H(F,L))},e[2]=g):g=e[2];const x=g;let b,w;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const L=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${Th()}/__pty`},F=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const H=new WebSocket(L());c.current=H,H.onopen=()=>{if(p.current){H.close();return}u.current=ff,o("connected"),H.send(JSON.stringify({type:"list"}))},H.onmessage=U=>{try{const W=JSON.parse(U.data);x(W)}catch{}},H.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const U=u.current;u.current=Math.min(U*2,wS),m.current=setTimeout(()=>h.current(),U)}};return h.current=F,F(),()=>{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,x],e[3]=t,e[4]=b,e[5]=w):(b=e[4],w=e[5]),v.useEffect(b,w);let y;e[6]!==t?(y=L=>{if(!t)return;const F=c.current;F&&F.readyState===WebSocket.OPEN&&F.send(JSON.stringify(L))},e[6]=t,e[7]=y):y=e[7];const j=y;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=(L,F)=>{f.current.set(L,F)},e[8]=k):k=e[8];const N=k;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=L=>{f.current.delete(L)},e[9]=C):C=e[9];const S=C;let _;e[10]!==j?(_=L=>{const F=L===void 0?{}:L,z=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:z,name:F.name??"Terminal",cwd:F.cwd,metadata:{type:"terminal"}}),z},e[10]=j,e[11]=_):_=e[11];const P=_;let A;e[12]!==j?(A=L=>{const F=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:F,name:L.name,cwd:L.cwd,args:["run",L.scriptName],command:"bun",metadata:{type:"script",source:L.source,scriptName:L.scriptName}}),F},e[12]=j,e[13]=A):A=e[13];const T=A;let E;e[14]!==j?(E=L=>{j({type:"kill",id:L})},e[14]=j,e[15]=E):E=e[15];const M=E;let I;e[16]!==j?(I=(L,F)=>{j({type:"input",id:L,data:F})},e[16]=j,e[17]=I):I=e[17];const R=I;let $;e[18]!==j?($=(L,F,z)=>{j({type:"resize",id:L,cols:F,rows:z})},e[18]=j,e[19]=$):$=e[19];const D=$;let O;return e[20]!==M||e[21]!==D||e[22]!==j||e[23]!==a||e[24]!==T||e[25]!==P||e[26]!==s||e[27]!==R?(O={status:s,send:j,subscribe:N,unsubscribe:S,sessions:a,spawnTerminal:P,spawnScript:T,killSession:M,writeInput:R,resize:D},e[20]=M,e[21]=D,e[22]=j,e[23]=a,e[24]=T,e[25]=P,e[26]=s,e[27]=R,e[28]=O):O=e[28],O}function SS(){}const xg=v.createContext(null);function Qa(n){const e=B.c(3),{children:t,enabled:s}=n,i=jS(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(xg.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function zc(){const n=v.useContext(xg);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function kS(n){var f;const e=B.c(11),t=zc();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 NS(n){const e=B.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(Nc,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(gr,{"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(J,{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 CS=v.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=v.useState(!1),[l,c]=v.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[f,u]=v.useState(d),{scripts:m,loading:p}=yS(s),{runningProcesses:h,runScript:g,stopScript:x}=kS(o);let b;if(t[1]!==m||t[2]!==l){const F=l.trim().toLowerCase(),z=F?m.filter(H=>H.name.toLowerCase().includes(F)||H.dirLabel.toLowerCase().includes(F)):m;b=new Map;for(const H of z){const U=b.get(H.dirLabel)??[];U.push(H),b.set(H.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let y;if(t[4]!==h){y=new Map;for(const[F,z]of h)y.set(`${z.name}:${z.cwd}`,{id:F,status:z.status});t[4]=h,t[5]=y}else y=t[5];const j=y;if(!s||!p&&m.length===0)return null;let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=function(z){u(H=>{const U=new Set(H);return U.has(z)?U.delete(z):U.add(z),U})},t[6]=k):k=t[6];const N=k;let C;t[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=C):C=t[7];let S;t[8]!==p?(S=p&&r.jsx(Bt,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const _=i?"Close script search":"Search scripts";let P,A;t[10]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{a(_S),c("")},A=r.jsx(bn,{}),t[10]=P,t[11]=A):(P=t[10],A=t[11]);let T;t[12]!==i||t[13]!==_?(T=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":_,"aria-expanded":i,onClick:P,children:A}),t[12]=i,t[13]=_,t[14]=T):T=t[14];let E;t[15]!==S||t[16]!==T?(E=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,S,T]}),t[15]=S,t[16]=T,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(Ot,{type:"search",value:l,onChange:F=>c(F.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]!==x?(I=[...w.entries()].map(F=>{const[z,H]=F,U=f.has(z)||!!l,W=H.filter(TS),K=H.filter(ES),q=U?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:z}),q.map(Y=>{const V=j.get(`${Y.name}:${Y.dir}`);return r.jsx(NS,{script:Y,status:(V==null?void 0:V.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{V&&x(V.id)}},`${z}:${Y.name}`)}),!l&&K.length>0&&r.jsx(J,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>N(z),children:U?"Show less":`Show ${K.length} more`})]},z)}),t[21]=f,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,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(Hn,{className:"gap-1 p-3",children:r.jsxs(Kn,{className:"gap-1",children:[r.jsx(qn,{children:"No matching scripts"}),r.jsx(Vn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=R):R=t[31];let $;t[32]!==I||t[33]!==R?($=r.jsxs(Cr,{className:"min-h-0 flex-1 px-1 pb-1",children:[I,R]}),t[32]=I,t[33]=R,t[34]=$):$=t[34];let D;t[35]!==M||t[36]!==$||t[37]!==E?(D=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,M,$]}),t[35]=M,t[36]=$,t[37]=E,t[38]=D):D=t[38];let O;t[39]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(It,{orientation:"vertical"}),t[39]=O):O=t[39];let L;return t[40]!==D?(L=r.jsxs(r.Fragment,{children:[D,O]}),t[40]=D,t[41]=L):L=t[41],L});function _S(n){return!n}function TS(n){return n.isCommon}function ES(n){return!n.isCommon}function bg(n){const e=B.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(uv,{"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 PS=Bn("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 vg(n){const e=B.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(PS({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(mv,{"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(dv,{"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 Oo(n){const e=B.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(fv,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Do(n){const e=B.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(cv,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const AS=v.lazy(()=>Ke(()=>import("./TerminalOutput-jlukYn0_.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function RS({process:n}){const[e,t]=v.useState(""),[s,o]=v.useState(!1),i=v.useRef(null);return v.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=yr(`/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=hg(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]),v.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 MS(n){const e=B.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 x=a&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=r.jsx(Me,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,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(Oo,{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}`,k=`Close ${t.name}`;let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(jt,{"data-icon":"inline-start"}),e[25]=N):N=e[25];let C;e[26]!==i||e[27]!==j||e[28]!==k?(C=r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:k,onClick:i,className:"mr-0.5 text-muted-foreground",children:N}),e[26]=i,e[27]=j,e[28]=k,e[29]=C):C=e[29];let S;return e[30]!==l||e[31]!==y||e[32]!==C?(S=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[y,C]}),e[30]=l,e[31]=y,e[32]=C,e[33]=S):S=e[33],S}const yg=100,wg=600,IS=200,jg="process-panel-height";function $S(){try{const n=localStorage.getItem(jg);if(n)return Math.min(wg,Math.max(yg,Number(n)))}catch{}return IS}const OS=v.memo(function(e){const t=B.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,x=zc(),[b,w]=v.useState($S),y=v.useRef(null);let j,k;t[0]!==u||t[1]!==x.sessions?(j=()=>{for(const ce of x.sessions)ce.status==="exited"&&(u==null||u(ce.id,"stopped"))},k=[x.sessions,u],t[0]=u,t[1]=x.sessions,t[2]=j,t[3]=k):(j=t[2],k=t[3]),v.useEffect(j,k);let N;t[4]!==l||t[5]!==x?(N=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=N):N=t[6];const C=N;let S;t[7]!==b?(S=ce=>{ce.preventDefault(),y.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=S):S=t[8];const _=S;let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P=ce=>{if(!y.current)return;const we=y.current.startY-ce.clientY,pe=Math.min(wg,Math.max(yg,y.current.startH+we));w(pe)},t[9]=P):P=t[9];const A=P;let T;t[10]!==b?(T=()=>{if(y.current){y.current=null;try{localStorage.setItem(jg,String(b))}catch{}}},t[10]=b,t[11]=T):T=t[11];const E=T;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 $=R;let D;t[17]!==a?(D=ce=>{typeof ce=="string"&&a(ce)},t[17]=a,t[18]=D):D=t[18];let O;t[19]!==I||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==E?(O=!g&&!i&&I&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:_,onPointerMove:A,onPointerUp:E,onPointerCancel:E}),t[19]=I,t[20]=i,t[21]=g,t[22]=_,t[23]=E,t[24]=O):O=t[24];const L=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==L?(F=G("flex shrink-0 items-center border-b bg-card",L),t[25]=L,t[26]=F):F=t[26];const z=i?"Expand terminal panel":"Collapse terminal panel",H=!i;let U;t[27]!==i?(U=i?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(st,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const W=g&&"sr-only";let K;t[29]!==W?(K=G(W),t[29]=W,t[30]=K):K=t[30];let q;t[31]!==K?(q=r.jsx("span",{className:K,children:"Terminal"}),t[31]=K,t[32]=q):q=t[32];let Y;t[33]!==c||t[34]!==z||t[35]!==H||t[36]!==U||t[37]!==q?(Y=r.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":z,"aria-expanded":H,children:[U,q]}),t[33]=c,t[34]=z,t[35]=H,t[36]=U,t[37]=q,t[38]=Y):Y=t[38];const V=!g&&"ml-2";let Q;t[39]!==V?(Q=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",V),t[39]=V,t[40]=Q):Q=t[40];let Z;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==$?(Z=$.map(ce=>r.jsx(MS,{process:ce,isActive:ce.id===o,onSelectActive:()=>a(ce.id),onClose:()=>C(ce),mobile:g},ce.id)),t[41]=o,t[42]=C,t[43]=g,t[44]=a,t[45]=$,t[46]=Z):Z=t[46];let X;t[47]!==Q||t[48]!==Z?(X=r.jsx(vg,{variant:"default","aria-label":"Open processes",className:Q,children:Z}),t[47]=Q,t[48]=Z,t[49]=X):X=t[49];let ee;t[50]!==d||t[51]!==m?(ee=d&&r.jsx(J,{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(Tn,{})}),t[50]=d,t[51]=m,t[52]=ee):ee=t[52];let oe;t[53]!==F||t[54]!==Y||t[55]!==X||t[56]!==ee?(oe=r.jsxs("div",{className:F,children:[Y,X,ee]}),t[53]=F,t[54]=Y,t[55]=X,t[56]=ee,t[57]=oe):oe=t[57];const se=!i,re=g?"min(36dvh, 260px)":b;let ie;t[58]!==re?(ie={height:re},t[58]=re,t[59]=ie):ie=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&r.jsx(CS,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let te;t[64]!==C||t[65]!==f||t[66]!==d||t[67]!==$?(te=$.map(ce=>r.jsx(Do,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?r.jsx(RS,{process:ce}):r.jsx(v.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(AS,{processId:ce.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(ce),onAddContext:f})})},ce.id)),t[64]=C,t[65]=f,t[66]=d,t[67]=$,t[68]=te):te=t[68];let he;t[69]!==I||t[70]!==d||t[71]!==m?(he=!I&&r.jsxs(Hn,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(wo,{})}),r.jsx(qn,{children:"No terminal open"}),r.jsx(Vn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(Ch,{children:r.jsxs(J,{type:"button",size:"sm",onClick:d,children:[r.jsx(Tn,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=I,t[70]=d,t[71]=m,t[72]=he):he=t[72];let me;t[73]!==te||t[74]!==he?(me=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[te,he]}),t[73]=te,t[74]=he,t[75]=me):me=t[75];let le;t[76]!==ie||t[77]!==ae||t[78]!==me?(le=r.jsx(Nt,{children:r.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,me]})}),t[76]=ie,t[77]=ae,t[78]=me,t[79]=le):le=t[79];let xe;t[80]!==se||t[81]!==le?(xe=r.jsx(kt,{open:se,className:"min-h-0",children:le}),t[80]=se,t[81]=le,t[82]=xe):xe=t[82];let ge;return t[83]!==o||t[84]!==D||t[85]!==O||t[86]!==oe||t[87]!==xe?(ge=r.jsxs(bg,{value:o,onValueChange:D,className:"shrink-0 gap-0 border-t bg-background",children:[O,oe,xe]}),t[83]=o,t[84]=D,t[85]=O,t[86]=oe,t[87]=xe,t[88]=ge):ge=t[88],ge});function Qn(n){const e=B.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 DS=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function LS(n){const e=new Set;for(const t of n.matchAll(DS)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function zS(n){var s;const e=B.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=LS(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 mf(n){var e;return((e=n.preview.split(`
|
|
5
|
+
`).replace(/\r/g,"")}function Cr(n){const e=B.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(rv,{"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(gS,{}),c=r.jsx(iv,{}),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(ov,{"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 gS(n){const e=B.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(lv,{"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(av,{"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 gg(n){const e=B.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 xS(n){const e=B.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 bS(n){const e=B.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 vS(n){const e=B.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 Bt(n){const e=B.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=gg,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 yS(n){const e=yn("hostFiles"),[t,s]=v.useState([]),[o,i]=v.useState(!1),a=v.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 v.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const ff=500,wS=5e3;function jS(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=v.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=v.useState(i),c=v.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const f=v.useRef(d),u=v.useRef(ff),m=v.useRef(null),p=v.useRef(!1),h=v.useRef(SS);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=L=>{var H;const F=L.type,z=L.id;if(F==="sessions"){l(L.sessions??[]);return}z&&((H=f.current.get(z))==null||H(F,L))},e[2]=g):g=e[2];const x=g;let b,w;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const L=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${Th()}/__pty`},F=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const H=new WebSocket(L());c.current=H,H.onopen=()=>{if(p.current){H.close();return}u.current=ff,o("connected"),H.send(JSON.stringify({type:"list"}))},H.onmessage=U=>{try{const W=JSON.parse(U.data);x(W)}catch{}},H.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const U=u.current;u.current=Math.min(U*2,wS),m.current=setTimeout(()=>h.current(),U)}};return h.current=F,F(),()=>{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,x],e[3]=t,e[4]=b,e[5]=w):(b=e[4],w=e[5]),v.useEffect(b,w);let y;e[6]!==t?(y=L=>{if(!t)return;const F=c.current;F&&F.readyState===WebSocket.OPEN&&F.send(JSON.stringify(L))},e[6]=t,e[7]=y):y=e[7];const j=y;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=(L,F)=>{f.current.set(L,F)},e[8]=k):k=e[8];const N=k;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=L=>{f.current.delete(L)},e[9]=C):C=e[9];const S=C;let _;e[10]!==j?(_=L=>{const F=L===void 0?{}:L,z=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:z,name:F.name??"Terminal",cwd:F.cwd,metadata:{type:"terminal"}}),z},e[10]=j,e[11]=_):_=e[11];const P=_;let A;e[12]!==j?(A=L=>{const F=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:F,name:L.name,cwd:L.cwd,args:["run",L.scriptName],command:"bun",metadata:{type:"script",source:L.source,scriptName:L.scriptName}}),F},e[12]=j,e[13]=A):A=e[13];const T=A;let E;e[14]!==j?(E=L=>{j({type:"kill",id:L})},e[14]=j,e[15]=E):E=e[15];const M=E;let I;e[16]!==j?(I=(L,F)=>{j({type:"input",id:L,data:F})},e[16]=j,e[17]=I):I=e[17];const R=I;let $;e[18]!==j?($=(L,F,z)=>{j({type:"resize",id:L,cols:F,rows:z})},e[18]=j,e[19]=$):$=e[19];const D=$;let O;return e[20]!==M||e[21]!==D||e[22]!==j||e[23]!==a||e[24]!==T||e[25]!==P||e[26]!==s||e[27]!==R?(O={status:s,send:j,subscribe:N,unsubscribe:S,sessions:a,spawnTerminal:P,spawnScript:T,killSession:M,writeInput:R,resize:D},e[20]=M,e[21]=D,e[22]=j,e[23]=a,e[24]=T,e[25]=P,e[26]=s,e[27]=R,e[28]=O):O=e[28],O}function SS(){}const xg=v.createContext(null);function Qa(n){const e=B.c(3),{children:t,enabled:s}=n,i=jS(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(xg.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function zc(){const n=v.useContext(xg);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function kS(n){var f;const e=B.c(11),t=zc();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 NS(n){const e=B.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(Nc,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(gr,{"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(J,{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 CS=v.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=v.useState(!1),[l,c]=v.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[f,u]=v.useState(d),{scripts:m,loading:p}=yS(s),{runningProcesses:h,runScript:g,stopScript:x}=kS(o);let b;if(t[1]!==m||t[2]!==l){const F=l.trim().toLowerCase(),z=F?m.filter(H=>H.name.toLowerCase().includes(F)||H.dirLabel.toLowerCase().includes(F)):m;b=new Map;for(const H of z){const U=b.get(H.dirLabel)??[];U.push(H),b.set(H.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let y;if(t[4]!==h){y=new Map;for(const[F,z]of h)y.set(`${z.name}:${z.cwd}`,{id:F,status:z.status});t[4]=h,t[5]=y}else y=t[5];const j=y;if(!s||!p&&m.length===0)return null;let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=function(z){u(H=>{const U=new Set(H);return U.has(z)?U.delete(z):U.add(z),U})},t[6]=k):k=t[6];const N=k;let C;t[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=C):C=t[7];let S;t[8]!==p?(S=p&&r.jsx(Bt,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const _=i?"Close script search":"Search scripts";let P,A;t[10]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{a(_S),c("")},A=r.jsx(bn,{}),t[10]=P,t[11]=A):(P=t[10],A=t[11]);let T;t[12]!==i||t[13]!==_?(T=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":_,"aria-expanded":i,onClick:P,children:A}),t[12]=i,t[13]=_,t[14]=T):T=t[14];let E;t[15]!==S||t[16]!==T?(E=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,S,T]}),t[15]=S,t[16]=T,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(Ot,{type:"search",value:l,onChange:F=>c(F.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]!==x?(I=[...w.entries()].map(F=>{const[z,H]=F,U=f.has(z)||!!l,W=H.filter(TS),K=H.filter(ES),q=U?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:z}),q.map(Y=>{const V=j.get(`${Y.name}:${Y.dir}`);return r.jsx(NS,{script:Y,status:(V==null?void 0:V.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{V&&x(V.id)}},`${z}:${Y.name}`)}),!l&&K.length>0&&r.jsx(J,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>N(z),children:U?"Show less":`Show ${K.length} more`})]},z)}),t[21]=f,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,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(Hn,{className:"gap-1 p-3",children:r.jsxs(Kn,{className:"gap-1",children:[r.jsx(qn,{children:"No matching scripts"}),r.jsx(Vn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=R):R=t[31];let $;t[32]!==I||t[33]!==R?($=r.jsxs(Cr,{className:"min-h-0 flex-1 px-1 pb-1",children:[I,R]}),t[32]=I,t[33]=R,t[34]=$):$=t[34];let D;t[35]!==M||t[36]!==$||t[37]!==E?(D=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,M,$]}),t[35]=M,t[36]=$,t[37]=E,t[38]=D):D=t[38];let O;t[39]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(It,{orientation:"vertical"}),t[39]=O):O=t[39];let L;return t[40]!==D?(L=r.jsxs(r.Fragment,{children:[D,O]}),t[40]=D,t[41]=L):L=t[41],L});function _S(n){return!n}function TS(n){return n.isCommon}function ES(n){return!n.isCommon}function bg(n){const e=B.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(uv,{"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 PS=Bn("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 vg(n){const e=B.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(PS({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(mv,{"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(dv,{"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 Oo(n){const e=B.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(fv,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Do(n){const e=B.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(cv,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const AS=v.lazy(()=>Ke(()=>import("./TerminalOutput-LwRcBZWA.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function RS({process:n}){const[e,t]=v.useState(""),[s,o]=v.useState(!1),i=v.useRef(null);return v.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=yr(`/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=hg(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]),v.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 MS(n){const e=B.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 x=a&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=r.jsx(Me,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,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(Oo,{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}`,k=`Close ${t.name}`;let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(jt,{"data-icon":"inline-start"}),e[25]=N):N=e[25];let C;e[26]!==i||e[27]!==j||e[28]!==k?(C=r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:k,onClick:i,className:"mr-0.5 text-muted-foreground",children:N}),e[26]=i,e[27]=j,e[28]=k,e[29]=C):C=e[29];let S;return e[30]!==l||e[31]!==y||e[32]!==C?(S=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[y,C]}),e[30]=l,e[31]=y,e[32]=C,e[33]=S):S=e[33],S}const yg=100,wg=600,IS=200,jg="process-panel-height";function $S(){try{const n=localStorage.getItem(jg);if(n)return Math.min(wg,Math.max(yg,Number(n)))}catch{}return IS}const OS=v.memo(function(e){const t=B.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,x=zc(),[b,w]=v.useState($S),y=v.useRef(null);let j,k;t[0]!==u||t[1]!==x.sessions?(j=()=>{for(const ce of x.sessions)ce.status==="exited"&&(u==null||u(ce.id,"stopped"))},k=[x.sessions,u],t[0]=u,t[1]=x.sessions,t[2]=j,t[3]=k):(j=t[2],k=t[3]),v.useEffect(j,k);let N;t[4]!==l||t[5]!==x?(N=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=N):N=t[6];const C=N;let S;t[7]!==b?(S=ce=>{ce.preventDefault(),y.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=S):S=t[8];const _=S;let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P=ce=>{if(!y.current)return;const we=y.current.startY-ce.clientY,pe=Math.min(wg,Math.max(yg,y.current.startH+we));w(pe)},t[9]=P):P=t[9];const A=P;let T;t[10]!==b?(T=()=>{if(y.current){y.current=null;try{localStorage.setItem(jg,String(b))}catch{}}},t[10]=b,t[11]=T):T=t[11];const E=T;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 $=R;let D;t[17]!==a?(D=ce=>{typeof ce=="string"&&a(ce)},t[17]=a,t[18]=D):D=t[18];let O;t[19]!==I||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==E?(O=!g&&!i&&I&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:_,onPointerMove:A,onPointerUp:E,onPointerCancel:E}),t[19]=I,t[20]=i,t[21]=g,t[22]=_,t[23]=E,t[24]=O):O=t[24];const L=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==L?(F=G("flex shrink-0 items-center border-b bg-card",L),t[25]=L,t[26]=F):F=t[26];const z=i?"Expand terminal panel":"Collapse terminal panel",H=!i;let U;t[27]!==i?(U=i?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(st,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const W=g&&"sr-only";let K;t[29]!==W?(K=G(W),t[29]=W,t[30]=K):K=t[30];let q;t[31]!==K?(q=r.jsx("span",{className:K,children:"Terminal"}),t[31]=K,t[32]=q):q=t[32];let Y;t[33]!==c||t[34]!==z||t[35]!==H||t[36]!==U||t[37]!==q?(Y=r.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":z,"aria-expanded":H,children:[U,q]}),t[33]=c,t[34]=z,t[35]=H,t[36]=U,t[37]=q,t[38]=Y):Y=t[38];const V=!g&&"ml-2";let Q;t[39]!==V?(Q=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",V),t[39]=V,t[40]=Q):Q=t[40];let Z;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==$?(Z=$.map(ce=>r.jsx(MS,{process:ce,isActive:ce.id===o,onSelectActive:()=>a(ce.id),onClose:()=>C(ce),mobile:g},ce.id)),t[41]=o,t[42]=C,t[43]=g,t[44]=a,t[45]=$,t[46]=Z):Z=t[46];let X;t[47]!==Q||t[48]!==Z?(X=r.jsx(vg,{variant:"default","aria-label":"Open processes",className:Q,children:Z}),t[47]=Q,t[48]=Z,t[49]=X):X=t[49];let ee;t[50]!==d||t[51]!==m?(ee=d&&r.jsx(J,{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(Tn,{})}),t[50]=d,t[51]=m,t[52]=ee):ee=t[52];let oe;t[53]!==F||t[54]!==Y||t[55]!==X||t[56]!==ee?(oe=r.jsxs("div",{className:F,children:[Y,X,ee]}),t[53]=F,t[54]=Y,t[55]=X,t[56]=ee,t[57]=oe):oe=t[57];const se=!i,re=g?"min(36dvh, 260px)":b;let ie;t[58]!==re?(ie={height:re},t[58]=re,t[59]=ie):ie=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&r.jsx(CS,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let te;t[64]!==C||t[65]!==f||t[66]!==d||t[67]!==$?(te=$.map(ce=>r.jsx(Do,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?r.jsx(RS,{process:ce}):r.jsx(v.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(AS,{processId:ce.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(ce),onAddContext:f})})},ce.id)),t[64]=C,t[65]=f,t[66]=d,t[67]=$,t[68]=te):te=t[68];let he;t[69]!==I||t[70]!==d||t[71]!==m?(he=!I&&r.jsxs(Hn,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(wo,{})}),r.jsx(qn,{children:"No terminal open"}),r.jsx(Vn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(Ch,{children:r.jsxs(J,{type:"button",size:"sm",onClick:d,children:[r.jsx(Tn,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=I,t[70]=d,t[71]=m,t[72]=he):he=t[72];let me;t[73]!==te||t[74]!==he?(me=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[te,he]}),t[73]=te,t[74]=he,t[75]=me):me=t[75];let le;t[76]!==ie||t[77]!==ae||t[78]!==me?(le=r.jsx(Nt,{children:r.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,me]})}),t[76]=ie,t[77]=ae,t[78]=me,t[79]=le):le=t[79];let xe;t[80]!==se||t[81]!==le?(xe=r.jsx(kt,{open:se,className:"min-h-0",children:le}),t[80]=se,t[81]=le,t[82]=xe):xe=t[82];let ge;return t[83]!==o||t[84]!==D||t[85]!==O||t[86]!==oe||t[87]!==xe?(ge=r.jsxs(bg,{value:o,onValueChange:D,className:"shrink-0 gap-0 border-t bg-background",children:[O,oe,xe]}),t[83]=o,t[84]=D,t[85]=O,t[86]=oe,t[87]=xe,t[88]=ge):ge=t[88],ge});function Qn(n){const e=B.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 DS=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function LS(n){const e=new Set;for(const t of n.matchAll(DS)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function zS(n){var s;const e=B.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=LS(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 mf(n){var e;return((e=n.preview.split(`
|
|
6
6
|
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function FS(n){const e=B.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(Me,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Sg({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=v.useState([]),a=zS(e);v.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=[],x=new Set;for(const[b,w]of a)!h[b]||x.has(b)||(x.add(b),g.push({id:`port-${b}`,outputPath:w.outputPath,ports:[b],portStatus:{[b]:!0},preview:w.description}));i(g)}}catch{}}d();const f=setInterval(d,1e4);return()=>{c=!0,clearInterval(f)}},[n,a]);const l=v.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 v.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:mf(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(Qn,{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=mf(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(eh,{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(FS,{port:u,isActive:c.portStatus[u]},u)),r.jsx("div",{className:"flex-1"}),c.outputPath&&r.jsx(J,{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(wo,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(J,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(u=>l(u)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(Nc,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function Fc(n){const e=B.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(pv,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function BS(n){const e=B.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(hv,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function US(n){const e=B.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(jc,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function WS(n){const e=B.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(Sc,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Bc(n){const e=B.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(WS,{}),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(US,{children:[a,r.jsx(vc,{"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 Uc(n){const e=B.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 Wc(n){const e=B.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 HS(n){const e=B.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 Hc(n){const e=B.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(yc,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Kc(n){const e=B.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(wc,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function qc(n){const e=B.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(J,{"data-slot":"alert-dialog-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vc(n){const e=B.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(J,{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(Wi,{"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}function kg(n){const e=B.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(xv,{"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(dt,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(gv,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const KS={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},qS={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 VS({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var u,m;const i=v.useRef(n),[a,l]=v.useState({key:"",selected:!1});v.useEffect(()=>{n&&(i.current=n)},[n]);const c=n??i.current;if(!c)return null;const d=((u=c.nativeRewind)==null?void 0:u.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,f=a.key===d&&a.selected;return r.jsx(Fc,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(Bc,{children:[r.jsxs(Uc,{children:[r.jsx(HS,{children:r.jsx(jn,{className:"text-warning"})}),r.jsx(Hc,{children:KS[c.type]}),r.jsx(Kc,{children:c.nativeRewind?f?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":qS[c.type]})]}),r.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.turnCount})]}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.fileCount})]}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Operations"}),r.jsx("span",{className:"text-foreground font-mono",children:c.summary.operationCount})]}),c.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:c.summary.filePaths.map(p=>r.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:p},p))}),((m=c.nativeRewind)==null?void 0:m.filesAvailable)&&r.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[r.jsx(kg,{checked:f,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(Ct,{variant:"destructive",children:r.jsx(_t,{children:t})}),r.jsxs(Wc,{children:[r.jsx(Vc,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(qc,{onClick:()=>s(f),disabled:e,children:e?r.jsxs(r.Fragment,{children:[r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Xt(n){const e=B.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 nn(n){const e=B.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 sn(n){const e=B.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 on(n){const e=B.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 Ng(n){const e=B.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 Jt(n){const e=B.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 ko(n){const e=B.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 Zn(n){const e=B.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 GS=Bn("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 wn(n){const e=B.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(GS({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:YS,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function YS(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const XS=Bn("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 _r(n){const e=B.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(XS({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(J,{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 es(n){const e=B.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(Ot,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function JS(){const[n,e]=v.useState("idle"),[t,s]=v.useState(null),o=v.useRef(void 0),i=v.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=v.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=v.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=v.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 v.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}const no=by(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),Cg=ea().filter(n=>n.cli.homeIsDiscoverable);function _g(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function Tg(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const QS=_g(Cg.map(n=>n.displayName)),ZS=_g(Cg.map(n=>r.jsx(Tg,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),e5=`~/${no.cli.homeDirName}`;function t5(n){const e=B.c(46),{onConfigured:t}=n,[s,o]=v.useState(""),[i,a]=v.useState(!1),{status:l,error:c,debouncedValidate:d,save:f}=JS();let u;e[0]!==d?(u=O=>{const L=O.target.value;o(L),d(L)},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 O=await f(s);O.success&&O.claudeDir&&t(O.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=O=>{O.preventDefault(),l==="valid"&&!i&&h()},e[6]=h,e[7]=i,e[8]=l,e[9]=g):g=e[9];let x,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(kc,{className:"size-4"})}),b=r.jsx(sn,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(nn,{children:[x,b,r.jsxs(on,{children:["Cogpit detects ",QS," automatically. Existing histories live in"," ",ZS,"."," ","For ",no.displayName,", enter its data directory, usually"," ",r.jsx(Tg,{children:e5}),"."]})]}),e[12]=w):w=e[12];const y=l==="invalid";let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(xt,{htmlFor:"agent-data-directory",children:[no.displayName," data directory"]}),e[13]=j):j=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(wn,{children:r.jsx(Qo,{"aria-hidden":"true"})}),e[14]=k):k=e[14];const N=l==="invalid";let C;e[15]!==m||e[16]!==s||e[17]!==N?(C=r.jsxs(Zn,{children:[k,r.jsx(es,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${no.cli.homeDirName}`,autoFocus:!0,"aria-invalid":N,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=N,e[18]=C):C=e[18];let S;e[19]!==l?(S=l==="validating"&&r.jsxs(mo,{className:"flex items-center gap-2",children:[r.jsx(Bt,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=S):S=e[20];let _;e[21]!==l?(_=l==="valid"&&r.jsxs(mo,{className:"flex items-center gap-2 text-success",children:[r.jsx(Hi,{className:"size-4"}),no.displayName," history found"]}),e[21]=l,e[22]=_):_=e[22];let P;e[23]!==c||e[24]!==l?(P=l==="invalid"&&c&&r.jsxs(us,{className:"flex items-center gap-2",children:[r.jsx(zs,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=P):P=e[25];let A;e[26]!==S||e[27]!==_||e[28]!==P?(A=r.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[S,_,P]}),e[26]=S,e[27]=_,e[28]=P,e[29]=A):A=e[29];let T;e[30]!==C||e[31]!==A||e[32]!==y?(T=r.jsx(Jt,{children:r.jsx(jo,{children:r.jsxs(gt,{"data-invalid":y,children:[j,C,A]})})}),e[30]=C,e[31]=A,e[32]=y,e[33]=T):T=e[33];const E=l!=="valid"||i;let M;e[34]!==i?(M=i&&r.jsx(Bt,{"data-icon":"inline-start"}),e[34]=i,e[35]=M):M=e[35];const I=i?"Saving...":`Connect ${no.displayName}`;let R;e[36]!==E||e[37]!==M||e[38]!==I?(R=r.jsx(ko,{children:r.jsxs(J,{type:"submit",className:"w-full",disabled:E,children:[M,I]})}),e[36]=E,e[37]=M,e[38]=I,e[39]=R):R=e[39];let $;e[40]!==T||e[41]!==R?($=r.jsxs(Xt,{children:[w,T,R]}),e[40]=T,e[41]=R,e[42]=$):$=e[42];let D;return e[43]!==$||e[44]!==g?(D=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:$})}),e[43]=$,e[44]=g,e[45]=D):D=e[45],D}const Eg=/^[a-z]:[\\/]/i;function Gc(n){return(Eg.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function pf(n){const e=Gc(n);return Eg.test(n)?e.toLowerCase():e}function n5(n){const e=Gc(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function hf(n,e){const t=pf(n),s=pf(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?Gc(e).slice(o.length):null}let Yc=!1;function s5(n){Yc=n}function Xc(){return Yc}let Ho=null;function o5(n){return Ho=n,()=>{Ho===n&&(Ho=null)}}function r5(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=hf(e,n.path);if(o)return{root:e,file:o,mode:gf(n),line:n.line}}const t=n5(n.path),s=hf(t,n.path);return s?{root:t,file:s,mode:gf(n),line:n.line}:null}function gf(n){return n.mode==="diff"?"diff":"edit"}function Pg(n){return Yc&&Ho!==null&&Ho(n)}function Ag(n,e){ye(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function Si(n,e={}){if(ut("hostFiles")&&!Pg({kind:"file",path:n,...e})){if($s()){vr(n);return}Ag("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function Rg(n){ut("hostFiles")&&(n.path&&Pg({kind:"project",path:n.path})||Ig("/api/open-in-editor",n))}function Mg(n){ut("hostFiles")&&Ig("/api/reveal-in-folder",n)}function Ig(n,e){!e.path&&!e.dirName||Ag(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let Za=null;const ql=new Set,Zr=new Map,xf=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],$g={typescript:()=>Ke(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>Ke(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>Ke(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>Ke(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>Ke(()=>import("./json-Cp-IABpG.js"),[]),css:()=>Ke(()=>import("./css-DPfMkruS.js"),[]),html:()=>Ke(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>Ke(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>Ke(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>Ke(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>Ke(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>Ke(()=>import("./rust-B1yitclQ.js"),[]),go:()=>Ke(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>Ke(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>Ke(()=>import("./sql-BLtJtn59.js"),[]),c:()=>Ke(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>Ke(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>Ke(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>Ke(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>Ke(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>Ke(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>Ke(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>Ke(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>Ke(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>Ke(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function Og(){return Za||(Za=(async()=>{const[n,e,...t]=await Promise.all([Ke(()=>import("./github-dark-DHJKELXO.js"),[]).then(o=>o.default),Ke(()=>import("./github-light-DAi9KRSo.js"),[]).then(o=>o.default),...xf.map(o=>$g[o]().then(i=>i.default))]),s=await cy({themes:[n,e],langs:t,engine:dy()});for(const o of xf)ql.add(o);return s})()),Za}async function Dg(n,e){if(ql.has(e))return;if(Zr.has(e))return Zr.get(e);const t=$g[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),ql.add(e)}).finally(()=>Zr.delete(e));Zr.set(e,s),await s}const i5={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 Lg(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return i5[e]??null}async function Jc(n,e,t){try{const s=await Og();await Dg(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=B.c(2),[e,t]=v.useState(a5);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]),v.useEffect(s,o),e}function a5(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const l5={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 c5(n){return l5[n.toLowerCase()]??n}function d5(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function u5(n){const e=B.c(10),{text:t}=n,[s,o]=v.useState(!1),i=v.useRef(null),a=v.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]),v.useEffect(l,c);let d;e[2]!==t?(d=function(){const g=a.current=a.current+1;vr(t).then(x=>{x&&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(dt,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(Pn,{"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(J,{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 f5(n){const e=B.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 m5(n){const e=B.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(`
|
|
7
7
|
`);let a;e[4]!==s?(a=d5(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(p5,{code:f,lang:l,...o}),e[12]=f,e[13]=l,e[14]=o,e[15]=u):u=e[15],u}function p5(n){const e=B.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]=v.useState(null),[c,d]=v.useState(!1),f=t.split(`
|
|
8
8
|
`),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,x;e[4]!==t||e[5]!==p||e[6]!==i||e[7]!==s?(g=()=>{if(!s||!p)return;let T=!1;return Jc(t,s,i).then(E=>{T||l({key:p,lines:E})}),()=>{T=!0}},x=[t,s,i,p],e[4]=t,e[5]=p,e[6]=i,e[7]=s,e[8]=g,e[9]=x):(g=e[8],x=e[9]),v.useEffect(g,x);const b=c?Ze:st,w="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let y;e[10]!==b||e[11]!==c||e[12]!==m?(y=m&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(!c),className:"text-muted-foreground","aria-label":c?"Expand code":"Collapse code",children:r.jsx(b,{"data-icon":"icon"})}),e[10]=b,e[11]=c,e[12]=m,e[13]=y):y=e[13];let j;e[14]!==s?(j=s&&r.jsx(Me,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:c5(s)}),e[14]=s,e[15]=j):j=e[15];let k;e[16]!==m||e[17]!==u?(k=m&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[16]=m,e[17]=u,e[18]=k):k=e[18];let N;e[19]!==y||e[20]!==j||e[21]!==k?(N=r.jsxs("div",{className:"flex items-center gap-2",children:[y,j,k]}),e[19]=y,e[20]=j,e[21]=k,e[22]=N):N=e[22];let C;e[23]!==t?(C=r.jsx(u5,{text:t}),e[23]=t,e[24]=C):C=e[24];let S;e[25]!==N||e[26]!==C?(S=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[N,C]}),e[25]=N,e[26]=C,e[27]=S):S=e[27];const _=!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((T,E)=>{const M=h==null?void 0:h[E];return r.jsxs("span",{className:"block",children:[r.jsx(f5,{num:E+1}),M?M.map(h5):T||" "]},E)})})})});let P;e[28]!==c||e[29]!==u?(P=c&&r.jsxs(J,{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]=P):P=e[30];let A;return e[31]!==_||e[32]!==P||e[33]!==S?(A=r.jsxs("div",{className:w,children:[S,_,P]}),e[31]=_,e[32]=P,e[33]=S,e[34]=A):A=e[34],A}function h5(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var As=function(n,e){return Number(n.toFixed(e))},g5=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},x5=function(n){return-Math.cos(n*Math.PI)/2+.5},b5=function(n){return n},v5=function(n){return n*n},y5=function(n){return n*(2-n)},w5=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},j5=function(n){return n*n*n},S5=function(n){return--n*n*n+1},k5=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},N5=function(n){return n*n*n*n},C5=function(n){return 1- --n*n*n*n},_5=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},T5=function(n){return n*n*n*n*n},E5=function(n){return 1+--n*n*n*n*n},P5=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},zg={easeOut:x5,linear:b5,easeInQuad:v5,easeOutQuad:y5,easeInOutQuad:w5,easeInCubic:j5,easeOutCubic:S5,easeInOutCubic:k5,easeInQuart:N5,easeOutQuart:C5,easeInOutQuart:_5,easeInQuint:T5,easeOutQuint:E5,easeInOutQuint:P5},Fg=function(n){typeof n=="number"&&cancelAnimationFrame(n)},fn=function(n){n.mounted&&(Fg(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function Bg(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;fn(n),n.animation=function(){if(!n.mounted)return Fg(n.animation);var a=new Date().getTime()-o,l=a/t,c=zg[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function A5(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function Ns(n,e,t,s){var o=A5(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):Bg(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+f*p,g=c+u*p,x=d+m*p;i(h,g,x)})}}function R5(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 M5=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}},Qc=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=R5(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,f=l.newContentWidth,u=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=M5(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 x=n.setup,b=x.minPositionX,w=x.maxPositionX,y=x.minPositionY,j=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),w!=null&&(h.maxPositionX=w*e),y!=null&&(h.minPositionY=d*(1-e)+y*e),j!=null&&(h.maxPositionY=j*e),h},sr=function(n,e,t,s){return s?n<e?As(e,2):n>t?As(t,2):As(n,2):As(n,2)},po=function(n,e){var t=Qc(n,e);return n.bounds=t,t};function Er(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=sr(n,l-u,d+u,s),h=sr(e,c-m,f+m,s);return{x:p,y:h}}function ma(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=Er(u,m,o,i,0,0,null);return p}var bf=1e-7;function Pr(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,bf),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,bf)}var vf=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=Ar(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},yf=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},I5=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}},$5=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 O5(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,x=s>p||s<h,b=t>u?d.offsetWidth:n.setup.minPositionX||0,w=s>p?d.offsetHeight:n.setup.minPositionY||0,y=ma(n,b,w,o,n.bounds,l||c),j=y.x,k=y.y;return{scale:o,positionX:g?j:t,positionY:x?k:s}}}function Ug(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=Er(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var D5=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}},ys=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},ls;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(ls||(ls={}));var L5=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},z5=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 F5(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 wf(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:sr(n,i,a,o)}function B5(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var el=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 U5(n,e,t){var s,o,i=L5(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 x=B5(d),b=(s={},s[ls.TOUCH]=p,s[ls.MOUSE]=h,s)[t],w=(o={},o[ls.TOUCH]=m,o[ls.MOUSE]=u,o)[t],y=e.x-a.x,j=e.y-a.y,k=el(y/x,w,b),N=el(j/x,w,b),C=g-l,S=y*y+j*j,_=el(Math.sqrt(S)/C,w,b);n.velocity={velocityX:k,velocityY:N,total:_}}n.lastMousePosition=e,n.velocityTime=g}}function W5(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=z5(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,x=s.panning,b=x.lockAxisY,w=x.lockAxisX,y=g.animationType,j=h.sizeX,k=h.sizeY,N=h.velocityAlignmentTime,C=N,S=F5(n,c),_=Math.max(S,C),P=ys(n,j),A=ys(n,k),T=P*o.offsetWidth/100,E=A*o.offsetHeight/100,M=d+T,I=f-T,R=u+E,$=m-E,D=n.state,O=new Date().getTime();Bg(n,y,_,function(L){var F=n.state,z=F.scale,H=F.positionX,U=F.positionY,W=new Date().getTime()-O,K=W/C,q=zg[h.animationType],Y=1-q(Math.min(1,K)),V=1-L,Q=H+a*V,Z=U+l*V,X=wf(Q,D.positionX,H,w,p,f,d,I,M,Y),ee=wf(Z,D.positionY,U,b,p,m,u,$,R,Y);if(H!==Q||U!==Z){n.setState(z,X,ee);var oe=n.props.onPanning;oe&&oe(Ye(n),{})}})}}function jf(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},fn(n),po(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?$5(n,e):I5(n,e)}function Wg(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=O5(n);m&&Ns(n,m,d,f)}}function Sf(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=D5(n,e,t),f=d.x,u=d.y,m=ys(n,l),p=ys(n,c);U5(n,{x:f,y:u},s),Ug(n,f,u,m,p)}}function H5(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,x=!n.setup.limitToBounds||m<h||p<g,b=!e&&t&&t.total>.1&&x;b?W5(n):Wg(n)}}function Zc(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=Pr(As(e,2),i,a,0,!1),d=po(n,c),f=ma(n,t,s,c,d,l),u=f.x,m=f.y;return{scale:c,positionX:u,positionY:m}}function ed(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)&&Wg(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,b=s<a?a:l,w=Zc(n,b,g,x);w&&Ns(n,w,u,m)}}var rn=function(){return rn=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},rn.apply(this,arguments)};function kf(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 tl={scale:1,positionX:0,positionY:0},Ps={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"}},Vl={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Hg=function(n){var e,t,s,o,i,a,l,c,d,f=Math.max((e=n.minScale)!==null&&e!==void 0?e:Ps.minScale,1e-7),u=(t=n.maxScale)!==null&&t!==void 0?t:Ps.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:tl.scale,p=Math.min(Math.max(m,f),u),h=sr((o=n.initialPositionX)!==null&&o!==void 0?o:tl.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=sr((l=n.initialPositionY)!==null&&l!==void 0?l:tl.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}},Nf=function(n){var e=rn({},Ps);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof Ps[s]<"u";if(i&&o){var a=Object.prototype.toString.call(Ps[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=rn(rn({},Ps[s]),n[s]):c?e[s]=kf(kf([],Ps[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},Kg=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=Pr(As(u,3),l,a,f,!1);return m};function qg(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,x=(h/2-f)/d,b=(g/2-u)/d,w=Kg(n,e,t),y=Zc(n,w,x,b);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,k=j.onZoomStart,N=j.onZoom,C=j.onZoomStop,S=new MouseEvent("mousemove",{bubbles:!0}),_=Ye(n);Qe(_,S,k),Qe(_,S,N),Ns(n,y,p,o);var P=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;P&&P.setTimeout(function(){n.mounted&&Qe(Ye(n),S,C)},p)}function Vg(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,f=a.centerOnInit,u=Hg(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=u.positionX,b=u.positionY;if(f&&c){var w=td(u.scale,l,c);x=w.positionX,b=w.positionY}var y=Qc(n,u.scale),j=Er(x,b,y,d,0,0,l),k={scale:u.scale,positionX:j.x,positionY:j.y};if(!(p===u.scale&&h===u.positionX&&g===u.positionY)){s==null||s();var N=n.props,C=N.onZoomStart,S=N.onZoom,_=N.onZoomStop,P=new MouseEvent("mousemove",{bubbles:!0}),A=Ye(n);Qe(A,P,C),Qe(A,P,S),Ns(n,k,e,t);var T=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;T&&T.setTimeout(function(){n.mounted&&Qe(Ye(n),P,_)},e)}}}function K5(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 q5(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=K5(e,i,a,l),g=h.x,x=h.y,b=p.width/l.scale,w=p.height/l.scale,y=i.offsetWidth/b,j=i.offsetHeight/w,k=Pr(t||Math.min(y,j),f,u,0,!1),N=(m.width-b*k)/2,C=(m.height-w*k)/2,S=(m.left-g)*k+N+s,_=(m.top-x)*k+C+o,P=Qc(n,k),A=Er(S,_,P,d,0,0,i),T=A.x,E=A.y;return{positionX:T,positionY:E,scale:k}}var V5=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),qg(n,1,e,t,s)}},G5=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),qg(n,-1,e,t,s)}},Y5=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};Ns(n,p,o,i)}}},X5=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),Vg(n,e,t)}},J5=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=td(e||o.scale,i,a);Ns(n,l,t,s)}}},Q5=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),fn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=q5(n,c,t,i,a);Ns(n,d,s,o)}}},Gl=function(n){return{instance:n,state:n.state,zoomIn:V5(n),zoomOut:G5(n),setTransform:Y5(n),resetTransform:X5(n),centerView:J5(n),zoomToElement:Q5(n)}},Z5=function(n){return{instance:n,state:n.state}},Ye=function(n){var e={};return Object.assign(e,Z5(n)),Object.assign(e,Gl(n)),e},nl=!1;function sl(){try{var n={get passive(){return nl=!0,!1}};return n}catch{return nl=!1,nl}}var ei=".".concat(Vl.wrapperClass),Ar=function(n,e){return e.some(function(t){return n.matches("".concat(ei," ").concat(t,", ").concat(ei," .").concat(t,", ").concat(ei," ").concat(t," *, ").concat(ei," .").concat(t," *"))})},or=function(n){n&&clearTimeout(n)},e4=function(n){return Number.parseFloat(n.toFixed(8))},Gg=function(n,e,t){var s=e4(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},td=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 t4(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function n4(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var Yg=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=Ar(d,a);if(u)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},s4=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=Yg(n,e);if(l)return!1;var c=e.target,d=Ar(c,a);if(d)return!1;var f=n.isPressingKeys(i);return!!f},o4=function(n){return n?n.deltaY<0?1:-1:0};function r4(n,e){var t=o4(n),s=g5(e,t);return s}function Xg(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 i4=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,x=Pr(h,d,c,m,g&&!u);return x},Jg=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},a4=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=Ar(a,o);return!c},l4=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},c4=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}},Qg=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))},d4=5,u4=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/d4),x=t+g,b=x===1/0?0:As(x,10);return Pr(b,a,i,f,!u&&!c)},Zg=160,e1=100,f4=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(fn(n),Qe(Ye(n),e,s),Qe(Ye(n),e,o))},m4=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,x=u.disabled,b=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=r4(e,null),y=h?b*Math.abs(e.deltaY):b,j=i4(n,w,y,!e.ctrlKey);if(c!==j){var k=po(n,j),N=Xg(e,i,c),C=x||g===0||f||p,S=d&&C,_=ma(n,N.x,N.y,j,k,S),P=_.x,A=_.y;n.previousWheelEvent=e,n.setState(j,P,A),Qe(Ye(n),e,s),Qe(Ye(n),e,o)}},p4=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;or(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(ed(n,e.x,e.y),n.wheelAnimationTimer=null)},e1);var i=Jg(n,e);i&&(or(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Ye(n),e,s),Qe(Ye(n),e,o))},Zg))},h4=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(fn(n),Qe(Ye(n),e,s),Qe(Ye(n),e,o))},g4=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;or(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(ed(n,e.x,e.y),n.wheelAnimationTimer=null)},e1);var i=Jg(n,e);i&&(or(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Ye(n),e,s),Qe(Ye(n),e,o))},Zg))},t1=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}},x4=function(n,e){var t=Qg(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=t1(e),fn(n)},b4=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,x=m.allowPanning;if(!(s===null||!t)){var b=c4(e,a,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=Qg(e),y=u4(n,w),j=t1(e),k=a/y,N=(j.x-((i==null?void 0:i.x)||0))*k,C=(j.y-((i==null?void 0:i.y)||0))*k;if(!(y===a&&N===0&&C===0)){n.pinchPreviousCenter=j;var S=po(n,y),_=h||g===0||d,P=c&&_,A=ma(n,b.x,b.y,y,S,P),T=A.x,E=A.y;if(n.pinchMidpoint=b,n.lastDistance=w,p.disabled||!x)n.setState(y,T,E);else{var M=u.sizeX,I=u.sizeY,R=ys(n,M,y),$=ys(n,I,y),D=T+N,O=E+C,L=Er(D,O,S,c,R,$,o),F=L.x,z=L.y;n.setState(y,F,z)}}}}},v4=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,ed(n,e==null?void 0:e.x,e==null?void 0:e.y)},n1=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;or(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Ye(n),e,t)},s)},y4=function(n,e){var t=n.props,s=t.onZoomStart,o=t.onZoom,i=n.setup.doubleClick,a=i.animationTime,l=i.animationType;Qe(Ye(n),e,s),Vg(n,a,l,function(){return Qe(Ye(n),e,o)}),n1(n,e)};function w4(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function j4(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 y4(n,e);if(!i)return console.error("No ContentComponent found");var x=w4(m,n.state.scale),b=Kg(n,x,p);if(a!==b){Qe(Ye(n),e,c);var w=Xg(e,i,a),y=Zc(n,b,w.x,w.y);if(!y)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Ye(n),e,d),Ns(n,y,h,g),n1(n,e)}}}var S4=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=Ar(c,l);return!u},k4=(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&&po(t,t.state.scale),t.setup=Nf(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=sl(),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=sl(),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),fn(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=sl();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(Ye(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(Ye(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=Yg(t,s);i&&(f4(t,s),m4(t,s),p4(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=s4(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,x=t.setup.autoAlignment,b=x.sizeX,w=x.sizeY,y=ys(t,b),j=ys(t,w);h===f&&g===u||(h4(t,s),Ug(t,h,g,y,j),Qe(Ye(t),s,o),g4(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=vf(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(),fn(t),jf(t,s),Qe(Ye(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=yf(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Sf(t,s.clientX,s.clientY,ls.MOUSE),Qe(Ye(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(H5(t,o),Qe(Ye(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=a4(t,s);a&&(x4(t,s),fn(t),Qe(Ye(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=l4(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),b4(t,s),Qe(Ye(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(v4(t),Qe(Ye(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,fn(t);var f=s.touches,u=f.length===1,m=f.length===2,p=vf(t,s);if(u){if(!p)return;fn(t),jf(t,s),Qe(Ye(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=yf(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Sf(t,l.clientX,l.clientY,ls.TOUCH),Qe(Ye(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=S4(t,s);i&&j4(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=td(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):Gg(s,o,i)},this.getContext=function(){return Ye(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:Ye(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=Ye(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,po(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(o),t.initializeWindowEvents(),t.isInitialized=!0;var i=Ye(t);Qe(i,void 0,t.props.onInit),t4(t.props.ref,i)},this.props=e,this.setup=Nf(this.props),this.state=Hg(this.props)}return n})(),pa=be.createContext(null),N4=function(n,e){return typeof n=="function"?n(e):n},C4=be.forwardRef(function(n,e){var t=v.useRef(new k4(n)).current,s=N4(n.children,Gl(t));return v.useImperativeHandle(e,function(){return Gl(t)},[t]),v.useEffect(function(){t.update(n)},[t,n]),r.jsx(pa.Provider,rn({value:t},{children:s}))});be.forwardRef(function(n,e){var t=v.useRef(null),s=v.useContext(pa);return v.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",rn({},n,{ref:n4([t,e])}))});function _4(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 T4=`.transform-component-module_wrapper__SPB86 {
|
|
@@ -112,20 +112,20 @@ ${M}`:M:null}).filter(Boolean).join(`
|
|
|
112
112
|
`)))}for(const a of C6(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function T6(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?Ta(t[1]??t[2]??t[3]??"",e):null}function E6(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 P6(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(Vx);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=E6(n.text);if(!o)return null;const i=Ta(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function $m(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==="|"||!Mm.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&Mm.test(i))return null;s+=i}return s}const A6=/^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 R6(n,e){var m;const t=(m=n.text.match(A6))==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=$m(s,"pattern"),f=$m(o,"replacement");if(!d||f===null)return null;const u=Ta(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 Gx(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of _6(t)){const a=T6(i.text,o);if(a){o=a;continue}const l=P6(i,o)??R6(i,o);l&&s.push(Cd(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function Yx(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=Ta(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(Cd(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:f===!0}))}return i}function Xx(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?v1("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Cd(n,s.id,s.name,s.input)):[]}function Vo(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(...Yx(s,e)):s.name==="Bash"?t.push(...Gx(s,e)):s.name==="apply_patch"&&t.push(...Xx(s,e)));return t}function Ri(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&Yx(t,e).length>0||t.name==="Bash"&&Gx(t,e).length>0||t.name==="apply_patch"&&Xx(t,e).length>0))return!0;return!1}const M6=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"]),I6={json:Uu,jsonc:Uu,md:Ka,mdx:Ka,txt:Ka,png:Cs,jpg:Cs,jpeg:Cs,gif:Cs,webp:Cs,svg:Cs,ico:Cs,sh:Kr,bash:Kr,zsh:Kr,fish:Kr};function Jx(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function $6(n){const e=Jx(n);return I6[e]??(M6.has(e)?xr:Zp)}function oc(n){const e=B.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 Om=5;function _d(n){const e=B.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*Om);i=Om-f,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:f},D6),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},O6),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 O6(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function D6(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const Mi="cogpit:open-subagent";function Qx(n){const e=B.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 Td(n){const e=B.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=r.jsx(J,{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(Mi,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const Zx=v.memo(function(e){const t=B.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=mx(),[d,f]=v.useState(o),[u,m]=v.useState(o),p=v.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Ne=>{f(Ne),Ne?v.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,b;t[1]!==o?(x=()=>{p.current!==o&&(p.current=o,g(o))},b=[o,g],t[1]=o,t[2]=x,t[3]=b):(x=t[2],b=t[3]),v.useEffect(x,b);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]),v.useEffect(w,y);let j;t[7]!==s.filePath?(j=Jx(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const k=j,N=s.netOriginal,C=s.netCurrent,S=!!(N||C);let _;t[9]!==s.edits?(_=s.edits.some(B6),t[9]=s.edits,t[10]=_):_=t[10];const A=a==="per-edit"?_:S,T=u&&c&&A,[E,M]=v.useState(0);let I;t[11]===Symbol.for("react.memo_cache_sentinel")?(I=Ne=>{if(!Ne)return;const Re=Ne.offsetHeight;M(Te=>Te===Re?Te:Re)},t[11]=I):I=t[11];const R=I,$=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,D=s.filePath,O=i?"border-ring ring-2 ring-ring/20":"border-border";let L;t[12]!==O?(L=G("rounded-lg border bg-card transition-colors",O),t[12]=O,t[13]=L):L=t[13];let F;t[14]!==d?(F=()=>g(!d),t[14]=d,t[15]=F):F=t[15];let z;t[16]!==d?(z=d?r.jsx(st,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(Ze,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=d,t[17]=z):z=t[17];let H;t[18]!==k?(H=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:k}),t[18]=k,t[19]=H):H=t[19];let U;t[20]!==s.opTypes?(U=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=U):U=t[21];let W;t[22]!==s.opTypes?(W=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=W):W=t[23];let K;t[24]!==U||t[25]!==W?(K=r.jsx(Qx,{hasEdit:U,hasWrite:W}),t[24]=U,t[25]=W,t[26]=K):K=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]!==$?(Y=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:$}),t[29]=$,t[30]=Y):Y=t[30];let V;t[31]!==s.editCount?(V=s.editCount>1&&r.jsxs(Me,{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]=V):V=t[32];let Q;t[33]!==d||t[34]!==F||t[35]!==z||t[36]!==H||t[37]!==K||t[38]!==q||t[39]!==Y||t[40]!==V?(Q=r.jsxs(J,{type:"button",variant:"ghost",onClick:F,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:[z,H,K,q,Y,V]}),t[33]=d,t[34]=F,t[35]=z,t[36]=H,t[37]=K,t[38]=q,t[39]=Y,t[40]=V,t[41]=Q):Q=t[41];let Z;t[42]!==s.subAgentId?(Z=s.subAgentId&&r.jsx(Td,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=Z):Z=t[43];let X;t[44]!==s.filePath?(X=r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Si(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=X):X=t[45];let ee;t[46]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx(pr,{"data-icon":"inline-start"}),t[46]=ee):ee=t[46];let oe;t[47]!==X?(oe=r.jsx(Pt,{render:X,children:ee}),t[47]=X,t[48]=oe):oe=t[48];let se;t[49]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(At,{children:"Open in editor"}),t[49]=se):se=t[49];let re;t[50]!==oe?(re=r.jsxs(Et,{children:[oe,se]}),t[50]=oe,t[51]=re):re=t[51];let ie;t[52]!==s.filePath?(ie=r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Si(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=ie):ie=t[53];let ae;t[54]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(Pv,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let te;t[55]!==ie?(te=r.jsx(Pt,{render:ie,children:ae}),t[55]=ie,t[56]=te):te=t[56];let he;t[57]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(At,{children:"View git diff"}),t[57]=he):he=t[57];let me;t[58]!==te?(me=r.jsxs(Et,{children:[te,he]}),t[58]=te,t[59]=me):me=t[59];let le;t[60]!==re||t[61]!==me?(le=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[re,me]}),t[60]=re,t[61]=me,t[62]=le):le=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 ge;t[65]!==s.delCount?(ge=s.delCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",s.delCount]}),t[65]=s.delCount,t[66]=ge):ge=t[66];let ce;t[67]!==s.addCount||t[68]!==s.delCount?(ce=r.jsx(_d,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=ce):ce=t[69];let we;t[70]!==Z||t[71]!==le||t[72]!==xe||t[73]!==ge||t[74]!==ce?(we=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Z,le,xe,ge,ce]}),t[70]=Z,t[71]=le,t[72]=xe,t[73]=ge,t[74]=ce,t[75]=we):we=t[75];let pe;t[76]!==Q||t[77]!==we?(pe=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:[Q,we]}),t[76]=Q,t[77]=we,t[78]=pe):pe=t[78];let ue;t[79]!==a||t[80]!==s.edits||t[81]!==s.filePath||t[82]!==s.netStartLine||t[83]!==A||t[84]!==E||t[85]!==C||t[86]!==N||t[87]!==d||t[88]!==T?(ue=r.jsx(L6,{showDiff:T,open:d,hasDiff:A,diffRef:R,lastDiffHeight:E,oldString:N,newString:C,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]=A,t[84]=E,t[85]=C,t[86]=N,t[87]=d,t[88]=T,t[89]=ue):ue=t[89];let je;return t[90]!==s.filePath||t[91]!==l||t[92]!==L||t[93]!==pe||t[94]!==ue?(je=r.jsxs("div",{ref:l,"data-file-path":D,className:L,children:[pe,ue]}),t[90]=s.filePath,t[91]=l,t[92]=L,t[93]=pe,t[94]=ue,t[95]=je):je=t[95],je}),L6=v.memo(function(e){const t=B.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(F6,{edits:m,filePath:f}):r.jsx(Sd,{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}),Dm=3,z6=5,F6=v.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(U6),l=a.length>Dm,[c,d]=v.useState(l?Dm:a.length);v.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(b=>Math.min(b+z6,a.length))});return()=>cancelAnimationFrame(x)},[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=(x,b)=>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:[x.toolName," ",b+1,"/",i]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&r.jsx(Td,{agentId:x.agentId})]}),r.jsx(Sd,{oldString:x.oldString,newString:x.newString,filePath:o,compact:!1,startLine:x.startLine,hideHeader:!0})]},x.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 B6(n){return!!(n.oldString||n.newString)}function U6(n){return!!(n.oldString||n.newString)}const hl=new Map;function W6(n){var j;const e=yn("hostFiles"),{sessionSource:t}=it(),s=t==null?void 0:t.dirName,o=St(s)==="codex",i=n.turns.length,a=((j=n.turns.at(-1))==null?void 0:j.toolCalls.length)??0,l=v.useMemo(()=>{let k=0;for(const N of n.turns){k+=N.toolCalls.length;for(const C of N.subAgentActivity)k+=C.toolCalls.length}return k},[i,a]),c=v.useMemo(()=>{const k=[];for(let N=0;N<n.turns.length;N++)for(const C of n.turns[N].subAgentActivity){const S=o&&(C.status==="completed"||C.status==="failed"||C.status==="interrupted");(C.isBackground||S)&&C.toolCalls.length===0&&k.push({agentId:C.agentId,turnIndex:N})}return k},[n.turns,l,o]),[d,f]=v.useState(new Map),u=v.useRef(new Set);v.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const k=[];for(const{agentId:S}of c){const _=Lt(`${s}/${n.sessionId}/${S}`);if(!u.current.has(_)){if(hl.has(_)){f(P=>{const A=new Map(P);return A.set(S,hl.get(_)),A}),u.current.add(_);continue}k.push({agentId:S,cacheKey:_})}}if(k.length===0)return;let N=!1;async function C(){const S=new Map;await Promise.all(k.map(async({agentId:_,cacheKey:P})=>{try{const A=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(_)}.jsonl`,T=await ye(A);if(!T.ok)return;const E=await T.text(),I=Ex(E,_).flatMap(R=>Vo(R.toolCalls,n.cwd));hl.set(P,I),u.current.add(P),S.set(_,I)}catch{}})),!N&&S.size>0&&f(_=>{const P=new Map(_);for(const[A,T]of S)P.set(A,T);return P})}return C(),()=>{N=!0}},[s,n.sessionId,n.cwd,c]);const m=v.useMemo(()=>{const k=[],N=new Set;for(let C=0;C<n.turns.length;C++){const S=n.turns[C];for(const _ of Vo(S.toolCalls,n.cwd))k.push({turnIndex:C,toolCall:_});for(const _ of S.subAgentActivity){for(const P of Vo(_.toolCalls,n.cwd))k.push({turnIndex:C,toolCall:P,agentId:_.agentId});if((_.isBackground||o)&&_.toolCalls.length===0&&!N.has(_.agentId)){N.add(_.agentId);const P=d.get(_.agentId);if(P)for(const A of P)k.push({turnIndex:C,toolCall:A,agentId:_.agentId})}}}return k},[l,n.turns,d,o]),p=v.useMemo(()=>{const k=new Set;for(const N of m){const C=e0(N.toolCall);C&&k.add(C)}return[...k]},[m]),[h,g]=v.useState(new Map);v.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let k=!1;return Promise.all(p.map(N=>ye(`/api/file-content?path=${encodeURIComponent(N)}`).then(C=>C.ok?C.text():null).then(C=>C?[N,C]:null).catch(()=>null))).then(N=>{if(k)return;const C=new Map;for(const S of N)S&&C.set(S[0],S[1]);g(C)}),()=>{k=!0}},[e,p]);const x=n.turns.length-1,b=v.useMemo(()=>Ii(m,"all",h),[m,h]),w=v.useMemo(()=>Ii(m,x,h),[m,x,h]),y=v.useMemo(()=>{const k=new Map;for(const N of n.turns)for(const C of N.subAgentActivity)k.has(C.agentId)||k.set(C.agentId,{name:C.agentName,type:C.subagentType});return k},[n.turns]);return{fileChanges:m,fileContents:h,groupedByFile:b,groupedLastTurn:w,lastTurnIndex:x,agentMap:y}}function Lm(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]===`
|
|
113
113
|
`&&s++;return s}function e0(n){return String(n.input.file_path??n.input.path??"")}function H6(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 Ii(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=e0(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 b=0;b<a.length;b++){const w=a[b],y=H6(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:Lm(h,y.newString||y.oldString)})}const g=QT(l),x=[];u&&x.push("Edit"),m&&x.push("Write"),o.push({filePath:i,shortPath:i.split("/").slice(-3).join("/"),editCount:a.length,turnRange:[d,f],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?Lm(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 K6(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=Ii(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 ur="cogpit:focus-file",q6="cogpit:file-changes-prefs",V6={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function G6(n){const e=B.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(Mi,{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(J,{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(Me,{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 x;e[16]!==t.totalDel?(x=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",t.totalDel]}),e[16]=t.totalDel,e[17]=x):x=e[17];let b;e[18]!==u||e[19]!==m||e[20]!==p||e[21]!==g||e[22]!==x?(b=r.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[u,m,p,h,g,x]}),e[18]=u,e[19]=m,e[20]=p,e[21]=g,e[22]=x,e[23]=b):b=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=k=>r.jsx(Zx,{file:k,defaultOpen:s,isHighlighted:o===k.filePath,diffMode:i},k.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]!==b||e[34]!==w?(y=r.jsxs("div",{className:"flex flex-col gap-1",children:[b,w]}),e[33]=b,e[34]=w,e[35]=y):y=e[35],y}const Y6=v.memo(function({session:e,sessionChangeKey:t}){const s=v.useRef(null),o=v.useRef(null),i=v.useRef(!0),a=v.useRef(!1),l=v.useRef(0),c=v.useRef(e.turns.length),[d,f]=v.useState(!1),[u,m]=v.useState(!1),[p,h]=ja(q6,{}),g={...V6,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[y,j]=v.useState(g.scope),k=v.useCallback(V=>{h(Q=>({...Q,expanded:V}))},[h]),N=v.useCallback(V=>{h(Q=>({...Q,diffMode:V}))},[h]),C=v.useCallback(V=>{h(Q=>({...Q,groupByAgent:V}))},[h]);v.useEffect(()=>{typeof y!="number"&&h(V=>({...V,scope:y}))},[y,h]);const[S,_]=v.useState(null),P=v.useRef(null),{fileChanges:A,fileContents:T,groupedByFile:E,groupedLastTurn:M,lastTurnIndex:I,agentMap:R}=W6(e),$=v.useMemo(()=>typeof y!="number"?null:Ii(A,y,T),[A,y,T]);function D(){return typeof y=="number"?$??[]:y==="all"?E:M}const O=D(),L=v.useMemo(()=>w?K6(A,typeof y=="number"?y:y==="all"?"all":I,R,T):[],[w,A,y,I,R,T]);v.useEffect(()=>{const V=Q=>{const Z=Q.detail;Z!=null&&Z.filePath&&(j(Z.turnIndex),_(Z.filePath),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>_(null),3e3),requestAnimationFrame(()=>{var ee;const X=(ee=s.current)==null?void 0:ee.querySelector(`[data-file-path="${CSS.escape(Z.filePath)}"]`);X==null||X.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(ur,V),()=>{window.removeEventListener(ur,V),P.current&&clearTimeout(P.current)}},[]);const F=v.useCallback(()=>{const V=s.current;V&&(f(V.scrollTop>10),m(V.scrollHeight-V.scrollTop-V.clientHeight>10))},[]),z=v.useCallback(()=>{const V=s.current;V&&(i.current=V.scrollHeight-V.scrollTop-V.clientHeight<50,F())},[F]);if(v.useEffect(()=>{F()},[A.length,O.length,F]),v.useEffect(()=>{const V=s.current;V&&(V.scrollTop=V.scrollHeight),i.current=!0,a.current=!1,l.current=A.length,c.current=e.turns.length,j(g.scope),_(null),F()},[t]),v.useEffect(()=>{const V=e.turns.length;V>c.current&&(a.current=!0),c.current=V},[e.turns.length]),v.useEffect(()=>{if(A.length<=l.current){l.current=A.length;return}l.current=A.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var V;(V=o.current)==null||V.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[A.length]),A.length===0)return null;let H=0,U=0,W=0;if(w)for(const V of L)H+=V.totalAdd,U+=V.totalDel,W+=V.files.length;else{for(const V of O)H+=V.addCount,U+=V.delCount;W=O.length}function K(){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(xr,{"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(Me,{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:["-",U]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(J,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(Wn,{"data-icon":"inline-start"})}),r.jsx(At,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(J,{variant:y==="all"?"secondary":"ghost",size:"icon-xs",onClick:K,"aria-label":y==="last"?"Show all turns":"Show last turn only"}),children:y==="all"?r.jsx(Av,{"data-icon":"inline-start"}):r.jsx(Is,{"data-icon":"inline-start"})}),r.jsx(At,{children:y==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(J,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>N(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?r.jsx(Rv,{"data-icon":"inline-start"}):r.jsx(Mv,{"data-icon":"inline-start"})}),r.jsx(At,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(Et,{children:[r.jsx(Pt,{render:r.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>k(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(Ji,{"data-icon":"inline-start"}):r.jsx(Yi,{"data-icon":"inline-start"})}),r.jsx(At,{children:x?"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(J,{variant:"ghost",size:"icon-xs",onClick:()=>{const V=typeof y=="number"?y:I;V>0&&j(V-1)},disabled:(typeof y=="number"?y:I)<=0,"aria-label":"Previous turn",children:r.jsx(Cc,{"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(J,{variant:"ghost",size:"icon-xs",onClick:()=>{j(V=>typeof V!="number"?V:V+1>=I?"last":V+1)},disabled:y==="last","aria-label":"Next turn",children:r.jsx(Ze,{"data-icon":"inline-start"})}),typeof y=="number"&&r.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:r.jsx(jt,{"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:z,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?L.length>0?L.map(V=>r.jsx(G6,{group:V,allExpanded:x,highlightPath:S,diffMode:b},V.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):O.length>0?O.map(V=>r.jsx(Zx,{file:V,defaultOpen:x,isHighlighted:S===V.filePath,diffMode:b},V.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 X6(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=dr(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 Vo(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>Vo(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 zm(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function J6(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=zm();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=zm(),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,k]=[...u.children.entries()][0];if(k.isFile&&k.children.size===0)break;m+="/"+j,p+="/"+j,u=k}const h=o(u,p);let g=0,x=0,b=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,x+=j.deletions,j.hasEdit&&(b=!0),j.hasWrite&&(w=!0),j.subAgentId&&(y=j.subAgentId);return u.isFile&&(g+=u.additions,x+=u.deletions),{name:m,fullPath:p,absPath:u.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:w,subAgentId:y,children:h}})}return o(s,"")}const Q6=v.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=yn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=X6(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=J6(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const f=d,[u,m]=v.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 x=g;if(c.length===0)return null;const b=u&&"rotate-90";let w;t[14]!==b?(w=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=w):w=t[15];let y;t[16]!==w?(y=r.jsx(Ze,{"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(xr,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=j):j=t[18];const k=c.length!==1?"s":"";let N;t[19]!==c.length||t[20]!==k?(N=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",k]}),t[19]=c.length,t[20]=k,t[21]=N):N=t[21];let C,S;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(oc,{add:x.add,del:x.del,className:"opacity-80"}),S=r.jsx(_d,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=C,t[25]=S):(C=t[24],S=t[25]);let _;t[26]===Symbol.for("react.memo_cache_sentinel")?(_=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[26];let P;t[27]!==C||t[28]!==S||t[29]!==y||t[30]!==N?(P=r.jsxs(ln,{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,N,C,S,_]}),t[27]=C,t[28]=S,t[29]=y,t[30]=N,t[31]=P):P=t[31];let A;if(t[32]!==a||t[33]!==f||t[34]!==o){let M;t[36]!==a||t[37]!==o?(M=I=>r.jsx(Z6,{node:I,depth:0,turnIndex:o,canFocusFiles:a},I.fullPath),t[36]=a,t[37]=o,t[38]=M):M=t[38],A=f.map(M),t[32]=a,t[33]=f,t[34]=o,t[35]=A}else A=t[35];let T;t[39]!==A?(T=r.jsx(Nt,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:A})}),t[39]=A,t[40]=T):T=t[40];let E;return t[41]!==u||t[42]!==P||t[43]!==T?(E=r.jsxs(kt,{open:u,onOpenChange:m,children:[P,T]}),t[41]=u,t[42]=P,t[43]=T,t[44]=E):E=t[44],E}),Z6=v.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=v.useState(!0),l=t*16+8;if(e.isFile){const c=$6(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(ur,{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(J,{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(Qx,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Td,{agentId:e.subAgentId}),r.jsx(oc,{add:e.additions,del:e.deletions}),r.jsx(_d,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(J,{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(st,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Ze,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(Iv,{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(oc,{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 e7(n){const e=B.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let o;e[0]!==s?(o=r.jsx(J,{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(_c,{"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(Pt,{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(At,{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(Et,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function t0(n){return L1(n).status(n)}const t7=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Ed(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 Mr(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&t7.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?Ed(t):"Done";default:return null}}function n7(n){const e=B.c(6),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ov,{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(wo,{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($v,{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(Ji,{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(co,{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(Un,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const Fm=2e3,n0=600;function s0(n){const e=B.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:`${n0}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(n7,{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",x=l&&!t.terminalReason&&"text-success";let b;e[7]!==h||e[8]!==g||e[9]!==x?(b=G("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=b):b=e[10];let w;e[11]!==s||e[12]!==b?(w=r.jsx("span",{className:b,children:s}),e[11]=s,e[12]=b,e[13]=w):w=e[13];let y;e[14]!==l||e[15]!==i?(y=!l&&i&&r.jsx(Pd,{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(`
|
|
114
114
|
`),children:d.join(" · ")}),e[17]=d,e[18]=j):j=e[18];let k;e[19]!==t.pendingQueue?(k=(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]=k):k=e[20];let N;return e[21]!==w||e[22]!==y||e[23]!==j||e[24]!==k||e[25]!==u||e[26]!==p?(N=r.jsxs("div",{className:u,style:m,children:[p,w,y,j,k]}),e[21]=w,e[22]=y,e[23]=j,e[24]=k,e[25]=u,e[26]=p,e[27]=N):N=e[27],N}function s7(n){const e=B.c(28),{status:t,durationLabel:s}=n,[o,i]=v.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),Fm),g=setTimeout(()=>i("ready"),Fm+n0);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),v.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Un,{className:"size-4 shrink-0 text-success"}),e[2]=h):h=e[2];const g=t.terminalReason?"text-warning":"text-muted-foreground";let x;e[3]!==g?(x=G("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?Ed(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let w;e[7]!==x||e[8]!==b?(w=r.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,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=Mr(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(s0,{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 o7=v.memo(function(){const e=B.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=it(),[l,c]=v.useState(!1),[d,f]=v.useState(!1),u=t==null?void 0:t.sessionId,[m,p]=v.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 T=t.rawMessages;let E;e[1]!==T?(E=t0(T),e[1]=T,e[2]=E):E=e[2],h=E}const g=h;let x,b;e[3]!==g||e[4]!==s||e[5]!==d?(x=()=>{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)}},b=[g,s,d],e[3]=g,e[4]=s,e[5]=d,e[6]=x,e[7]=b):(x=e[6],b=e[7]),v.useEffect(x,b);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",k=(t==null?void 0:t.turns[t.turns.length-1])??null;let N;e:{if(!j||!k){N=null;break e}let T;if(e[8]!==k){const E=$c(k);T=E!==null?En(E):null,e[8]=k,e[9]=T}else T=e[9];N=T}const C=N;if(a&&o==="connected"){let T;e[10]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(oh,{className:"size-5 shrink-0 text-info"}),e[10]=T):T=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:[T,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 T;return e[13]!==y||e[14]!==C?(T=r.jsx(s7,{status:y,durationLabel:C}),e[13]=y,e[14]=C,e[15]=T):T=e[15],T}let S;e[16]!==y.pendingAgents||e[17]!==y.status||e[18]!==y.terminalReason||e[19]!==y.toolName?(S=Mr(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]=S):S=e[20];const _=S;if(!_)return null;const P=k==null?void 0:k.timestamp;let A;return e[21]!==y||e[22]!==_||e[23]!==P?(A=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(s0,{status:y,label:_,startTimestamp:P})}),e[21]=y,e[22]=_,e[23]=P,e[24]=A):A=e[24],A});function Pd(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(r7,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function r7(n){const e=B.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=v.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=En(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]),v.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=En(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 i7(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 a7=6e5;function l7(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,a7)}function Bm(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+=l7(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 rc=new Map,c7=300*1e3;function Um(n){const e=rc.get(n);return e?Date.now()>e.expiresAt?(rc.delete(n),null):e.data:null}function d7(n,e){rc.set(n,{data:e,expiresAt:Date.now()+c7})}function u7(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?Um(Lt(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=v.useState(t),i=v.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||ua(window.location.pathname))return;const c=Lt(n),d=Um(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});d7(c,p),o(p)}).catch(f7),()=>f.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),v.useEffect(a,l),s}function f7(){}const m7=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),p7=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),h7=new Set(["AskUserQuestion","ExitPlanMode"]),g7=new Set(["text","thinking","tool_calls"]);function x7(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>h7.has(e.name)&&e.result==null)}function b7(n){for(let e=n.length-1;e>=0;e--){if(x7(n[e]))return e;if(g7.has(n[e].kind))return-1}return-1}const oi={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function v7(n,e="settled"){if(n.length===0||!n.some(a=>p7.has(a.kind)))return oi;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 oi}const s=b7(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];m7.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?oi:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function y7(n,e){return n!==null&&n>0?`Worked for ${En(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const o0="border border-border bg-prompt-surface",Wm="border-l border-border/40",Hm="border-l border-border";function r0(n){const e=B.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=Rt(),{activeTurnIndex:c,activeToolCallId:d,expandAll:f,expandToolPayloads:u}=a,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x}=it(),b=p&&m!==null,w=b&&s===((m==null?void 0:m.turns.length)??0)-1;let y=!w;if(w&&m){let _;if(e[0]!==m.rawMessages){const{status:P}=t0(m.rawMessages);_=bd.has(P),e[0]=m.rawMessages,e[1]=_}else _=e[1];y=!_}const j=(m==null?void 0:m.cwd)??"",k=u7(j),N=c===s,C=!g.enabled||h?void 0:g.requestUndo;let S;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.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]!==b||e[14]!==y||e[15]!==k||e[16]!==N||e[17]!==C||e[18]!==t?(S=r.jsx(j7,{turn:t,index:s,branchCount:i,isActive:N,activeToolCallId:d,expandAll:f,expandToolPayloads:u,isAgentActive:w,isSessionLive:b,isTurnDone:y,isMobile:l,cwd:j,skillMetadata:k,onRestoreToHere:C,onOpenBranches:x.handleOpenBranches,onEditCommand:x.handleEditCommand,onExpandCommand:x.handleExpandCommand}),e[2]=x.handleEditCommand,e[3]=x.handleExpandCommand,e[4]=x.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]=b,e[14]=y,e[15]=k,e[16]=N,e[17]=C,e[18]=t,e[19]=S):S=e[19],S}function w7(n){const e=B.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:o}=n;if(s){let a;return e[0]!==o||e[1]!==t?(a=y7($c(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(Pd,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const j7=v.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:x,onExpandCommand:b}){const{ref:w,isNear:y}=mx(),j=v.useRef(null),k=v.useRef(0);v.useLayoutEffect(()=>{y&&j.current&&(k.current=j.current.offsetHeight)},[y]);const N=Ri(e.toolCalls,m)||e.subAgentActivity.some(M=>Ri(M.toolCalls,m)),C=f?"settled":"working",S=v.useMemo(()=>v7(e.contentBlocks,C),[C,e.contentBlocks]),[_,P]=v.useState(void 0),A=_??(a||!f),{leadingBlocks:T,trailingBlocks:E}=v.useMemo(()=>{if(!S.foldable)return{leadingBlocks:[],trailingBlocks:[]};const M=S.foldAnchorIndex,I=new Set(S.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,M),trailingBlocks:e.contentBlocks.slice(M).filter((R,$)=>A||!I.has(M+$))}},[S,e.contentBlocks,A]);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(k7,{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",o0),children:r.jsx(pd,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b,compact:u})}),S.foldable?r.jsxs(r.Fragment,{children:[T.length>0&&r.jsx(gl,{blocks:T,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),r.jsx(w6,{label:r.jsx(w7,{turn:e,isTurnDone:f,hiddenToolCalls:S.hiddenToolCalls}),expanded:A,onToggle:()=>P(!A),compact:u}),E.length>0&&r.jsx(gl,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p})]}):r.jsx(gl,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),f&&N&&r.jsx(Q6,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:k.current||S7(e)}})]})});function S7(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function k7(n){const e=B.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?$c(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 x;e[7]!==u||e[8]!==d||e[9]!==s.timestamp?(x=r.jsx(N7,{durationMs:u,showLiveTimer:d,timestamp:s.timestamp}),e[7]=u,e[8]=d,e[9]=s.timestamp,e[10]=x):x=e[10];let b;e[11]!==t||e[12]!==a||e[13]!==l?(b=l&&r.jsxs(J,{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(Tc,{"data-icon":"inline-start"}),r.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=a,e[13]=l,e[14]=b):b=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(e7,{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]!==x||e[23]!==b||e[24]!==w?(y=r.jsxs("div",{className:p,children:[g,x,b,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=w,e[25]=y):y=e[25],y}function N7(n){const e=B.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(Is,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=En(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(Is,{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(Pd,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function C7(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 gl(n){const e=B.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",x=new Map,b=(y,j)=>{const k=C7(y)??`at-${j}`,N=x.get(k)??0;return x.set(k,N+1),N===0?k:`${k}#${N}`};let w=0;for(;w<t.length;){const y=t[w];if(y.kind==="thinking"||y.kind==="tool_calls"){const{items:j,toolCalls:k,thinkingCount:N,thoughtForMs:C,nextIndex:S}=Bm(t,w),_=j.length===1&&j[0].kind==="tool_calls";p.push(r.jsx("div",{className:G(Wm,h),children:r.jsx(Am,{toolCalls:k,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:_?void 0:j,thinkingCount:N,thoughtForMs:C,skillMetadata:u})},b(y,w))),w=S;continue}if(y.kind==="text"){const{items:j,toolCalls:k,thinkingCount:N,thoughtForMs:C,nextIndex:S}=Bm(t,w+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:G("flex flex-col",g),children:y.text.map((_,P)=>r.jsx(i_,{text:_,model:s,effort:o,timestamp:y.timestamp,compact:f},P))}),(k.length>0||N>0)&&r.jsx("div",{className:G("mt-1.5",Wm,h),children:r.jsx(Am,{toolCalls:k,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:N>0?j:void 0,thinkingCount:N,thoughtForMs:C,skillMetadata:u})})]},b(y,w))),w=S;continue}if(y.kind==="queued_prompt"){p.push(r.jsxs("div",{className:G(f?"rounded-lg p-2.5":"rounded-lg p-3",o0),children:[r.jsx(Me,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(pd,{content:y.content,timestamp:y.timestamp??"",compact:f})]},b(y,w))),w++;continue}if(y.kind==="agent_message"){p.push(r.jsx(s_,{sender:y.sender,body:y.body,reply:y.reply,timestamp:y.timestamp,isLive:d},b(y,w))),w++;continue}if(y.kind==="sub_agent"){p.push(r.jsx("div",{className:G(Hm,h),children:r.jsx(N_,{messages:y.messages,expandAll:i})},b(y,w))),w++;continue}if(y.kind==="background_agent"){p.push(r.jsx("div",{className:G(Hm,h),children:r.jsx(C_,{messages:y.messages,expandAll:i})},b(y,w))),w++;continue}if(y.kind==="hook_event"){p.push(r.jsx(T_,{events:y.events},b(y,w))),w++;continue}if(y.kind==="plan_mode"){p.push(r.jsx(VT,{plan:y.plan,planFilePath:y.planFilePath,status:y.status,toolCalls:y.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:u},b(y,w))),w++;continue}if(y.kind==="recap"){p.push(r.jsx(GT,{content:y.content,timestamp:y.timestamp},b(y,w))),w++;continue}if(y.kind==="task_notification"){p.push(r.jsx(QN,{content:y.content},b(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 _7(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${nt(n.preTokens)} → ${nt(n.postTokens)}`:`${e} · ${nt(n.preTokens)}`}const T7=v.memo(function(e){const t=B.c(30),{summary:s,meta:o}=e,[i,a]=v.useState(!1);let l;t[0]!==o?(l=_7(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(st,{className:"size-3","data-icon":"inline-start"}):r.jsx(Ze,{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(Dv,{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 x=g;if(!f){let S;t[14]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=S):S=t[14];let _;t[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=_):_=t[15];let P;return t[16]!==x?(P=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[S,x,_]}),t[16]=x,t[17]=P):P=t[17],P}let b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(J,{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]=b,t[19]=w):(b=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]!==x?(j=r.jsxs(ln,{render:b,children:[w,x,y]}),t[21]=x,t[22]=j):j=t[22];let k;t[23]===Symbol.for("react.memo_cache_sentinel")?(k=[Zi],t[23]=k):k=t[23];let N;t[24]!==f?(N=r.jsx(Nt,{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(An,{remarkPlugins:k,components:$n,children:f})})}),t[24]=f,t[25]=N):N=t[25];let C;return t[26]!==i||t[27]!==j||t[28]!==N?(C=r.jsxs(kt,{open:i,onOpenChange:a,className:"px-4 py-2",children:[j,N]}),t[26]=i,t[27]=j,t[28]=N,t[29]=C):C=t[29],C}),E7=1.5;function P7(n,e){return e<=0?!1:n<e*E7}function A7(n,e){return n===0&&!e}function R7(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function M7(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const I7=1e3;function $7(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)<=I7?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function i0(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&&M7(i,t)?[...o.slice(0,-1),D7(a,i),...n.slice(1)]:[...o,...n];return od($7(l))}function O7(n,e){if(n.durationMs!==null&&e.durationMs!==null)return n.durationMs+e.durationMs;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 D7(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:O7(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function L7(n){const e=B.c(12),{index:t,children:s}=n,{isSubAgentView:o,undoRedo:i,actions:a}=it(),{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(RC,{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 z7(){const n=B.c(10),{session:e,isSubAgentView:t,undoRedo:s}=it(),{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(MC,{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(r0,{turn:p,index:d+h}),c&&r.jsxs(J,{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(Lv,{"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 F7(n){const e=B.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(rt,{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 B7(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function U7({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Rt(),{undoRedo:l}=it(),c=v.useRef(null),d=v.useRef(null),[f,u]=v.useState(0),m=v.useMemo(()=>{const y=new Map;return n.map(j=>{const k=y.get(j.turn.id)??0;return y.set(j.turn.id,k+1),{...j,key:k===0?j.turn.id:`${j.turn.id}#${k}`}})},[n]),p=v.useRef(null),h=v.useMemo(()=>R7(p.current,m.map(y=>y.key)),[m]);v.useLayoutEffect(()=>{var y;p.current={firstKey:(y=m[0])==null?void 0:y.key,length:m.length}},[m]);const g=v.useRef(t);v.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;v.useLayoutEffect(()=>{const y=e.current,j=d.current;if(!y||!j)return;const k=j.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop;u(N=>Math.abs(N-k)<1?N:k)},[e,x]),v.useEffect(()=>{if(!t||!i||!o||s)return;const y=e.current;if(!y)return;const j=()=>{P7(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 b=v.useMemo(()=>{const y=new Map;for(let j=0;j<m.length;j++)y.set(m[j].index,j);return y},[m]),w=v.useRef(null);return v.useEffect(()=>{var j;if(a===null){w.current=null;return}if(a===w.current)return;w.current=a;const y=b.get(a);y!==void 0&&((j=c.current)==null||j.scrollToIndex(y,{align:"start",smooth:!0}))},[a,b]),r.jsxs(r.Fragment,{children:[x&&r.jsx(F7,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(AC,{ref:c,scrollRef:e,startMargin:f,shift:h,children:m.map(({turn:y,index:j,key:k})=>r.jsx("div",{"data-turn-index":j,children:r.jsx(L7,{index:j,children:r.jsxs("div",{children:[(y.compactionSummary||y.compactionMeta)&&r.jsx(T7,{summary:y.compactionSummary,meta:y.compactionMeta}),!B7(y)&&r.jsx(r0,{turn:y,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]})})},k))})}),r.jsx(z7,{})]})}const W7=v.memo(function(e){const t=B.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=Rt(),{searchQuery:d,sessionChangeKey:f}=c,{session:u}=it(),m=u==null?void 0:u.turns;let p;t[0]!==m?(p=m?m.map(H7):[],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:k}=j;return i7(k,d)}):h,t[2]=h,t[3]=d,t[4]=g):g=t[4];const x=g;let b;t[5]!==x.length||t[6]!==o||t[7]!==d?(b=d?x.length===0:A7(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=b):b=t[8];const w=b;let y;return t[9]!==s||t[10]!==x||t[11]!==o||t[12]!==i||t[13]!==l||t[14]!==a||t[15]!==d||t[16]!==f||t[17]!==w?(y=r.jsx(EN,{children:w?r.jsx(Hn,{className:"min-h-64 border-0",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:d?r.jsx(zv,{}):r.jsx(rh,{})}),r.jsx(qn,{children:d?"No matching turns":"No conversation yet"}),r.jsx(Vn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(U7,{filteredTurns:x,scrollContainerRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l},f)}),t[9]=s,t[10]=x,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 H7(n,e){return{turn:n,index:e}}const K7="[data-turn-index]",a0="[data-turn-prompt]",Km=1,q7=120,qm=180;function V7(n){if(!n.userMessage)return null;const e=wa(n.userMessage),{body:t}=rr(e),{remainingText:s}=ar(t),o=md(s);if(!o){const a=G1(e);if(!a)return null;const l=Y1(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
|
|
115
|
-
`)[0];return i.length>qm?`${i.slice(0,qm)}...`:i}function G7(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=V7(s);if(o)return{index:t,text:o}}return null}function Y7(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(K7)){const c=l.getBoundingClientRect().top;if(c>e+Km)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(a0);return(i?i.getBoundingClientRect().bottom>e+Km:s+q7>e)?null:o}const X7=v.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=v.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const j=o.current;if(!j)return;let k=null;const N=()=>{k=null;const P=Y7(j);a(A=>P===null?null:(A==null?void 0:A.sessionId)===s.sessionId&&A.index===P?A:{sessionId:s.sessionId,index:P})},C=()=>{k===null&&(k=requestAnimationFrame(N))};a(null),j.addEventListener("scroll",C,{passive:!0});const S=new MutationObserver(C);S.observe(j,{childList:!0,subtree:!0});const _=new ResizeObserver(C);return _.observe(j),j.firstElementChild&&_.observe(j.firstElementChild),C(),()=>{j.removeEventListener("scroll",C),S.disconnect(),_.disconnect(),k!==null&&cancelAnimationFrame(k)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),v.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=G7(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 k=j.querySelector(`[data-turn-index="${f.index}"]`),N=(k==null?void 0:k.querySelector(a0))??k;if(!N)return;const C=j.scrollTop+N.getBoundingClientRect().top-j.getBoundingClientRect().top;j.scrollTo({top:Math.max(0,C),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(rh,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=f.index+1;let x;t[11]!==g?(x=r.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",g]}),t[11]=g,t[12]=x):x=t[12];let b;t[13]!==f.text?(b=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]=b):b=t[14];let w;t[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(hr,{"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]!==x||t[20]!==b?(y=r.jsxs(J,{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,x,b,w]}),t[16]=f.text,t[17]=m,t[18]=p,t[19]=x,t[20]=b,t[21]=y):y=t[21],y});function J7(n){const e=B.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(Vm,{}),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(Tx,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(Vm,{}),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 Vm(){const n=B.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 Q7=v.memo(function(){const e=B.c(9),t=yd();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=u_(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(Z7,-1);return r.jsx("div",{children:f.blocks.map((p,h)=>r.jsx(J7,{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 Z7(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const eE=3,$i=["w-6","w-4","w-2.5","w-2"],tE=$i[$i.length-1];function nE(n){return n===null||n<0?tE:$i[Math.min(n,$i.length-1)]}function sE(n){return n.type==="text"}function xl(n){return n.replace(/\s+/g," ").trim()}function oE(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(sE).map(l=>l.text).join(" "):"",{text:t}=Q1(e),{remainingText:s}=ar(t),{remainingText:o}=J1(s),i=xl(md(o));if(i)return i;for(const l of n.contentBlocks){if(l.kind!=="task_notification")continue;const c=ar(l.content).notifications.map(d=>d.summary).find(Boolean);if(c)return xl(c)}return n.assistantText.map(xl).find(Boolean)||"Untitled turn"}const rE=v.memo(function(e){const t=B.c(21),{turns:s,scrollContainerRef:o,onJumpToTurn:i}=e,[a,l]=v.useState(null),c=v.useRef(null),d=s.length;let f;if(t[0]!==s){const j=new Map;f=s.map(k=>{const N=j.get(k.id)??0;return j.set(k.id,N+1),N===0?k.id:`${k.id}#${N}`}),t[0]=s,t[1]=f}else f=t[1];const u=f;let m;t[2]!==o?(m=()=>{const j=o.current,k=c.current;if(!j||!k)return;let N=null;const C=()=>{N=null;const _=j.getBoundingClientRect().top+j.clientHeight/2;let P=null;for(const A of j.querySelectorAll("[data-turn-index]")){const T=A.getBoundingClientRect();if(T.top<=_&&T.bottom>=_){P=Number(A.dataset.turnIndex);break}}for(const A of k.querySelectorAll("[data-tick-index]"))A.dataset.current=String(Number(A.dataset.tickIndex)===P)},S=()=>{N===null&&(N=requestAnimationFrame(C))};return C(),j.addEventListener("scroll",S,{passive:!0}),()=>{j.removeEventListener("scroll",S),N!==null&&cancelAnimationFrame(N)}},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],v.useEffect(m,p);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const k=j.key==="ArrowDown"?1:j.key==="ArrowUp"?-1:0,N=c.current;if(!N)return;const C=[...N.querySelectorAll("[data-tick-index]")];if(C.length===0)return;let S;if(k!==0){const _=C.indexOf(document.activeElement);S=C[Math.min(Math.max(_+k,0),C.length-1)]}else j.key==="Home"?S=C[0]:j.key==="End"&&(S=C[C.length-1]);S&&(j.preventDefault(),S.focus())},t[7]=h):h=t[7];const g=h;if(d<eE)return null;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(null),t[8]=x):x=t[8];let b;t[9]===Symbol.for("react.memo_cache_sentinel")?(b=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]=b):b=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=(k,N)=>{const C=oE(k);return r.jsx(J,{type:"button",variant:"ghost","data-tick-index":N,onMouseEnter:()=>l(N),onFocus:()=>l(N),onClick:()=>i(N),"aria-label":`Turn ${N+1}: ${C}`,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",nE(a===null?null:Math.abs(N-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:N+1}),r.jsx("span",{className:"line-clamp-2 align-middle",children:C})]})},u[N])},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:x,onKeyDown:g,className:b,children:w}),t[19]=w,t[20]=y):y=t[20],y});class iE extends v.Component{constructor(t){super(t);Hr(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(Ct,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(jn,{}),r.jsx(Dt,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(_t,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(bs,{className:"static col-start-2 mt-2",children:r.jsxs(J,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Qt,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const Gm="find-in-session-highlight",bl="find-in-session-active";function aE(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 lE=v.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=v.useState(!1),[l,c]=v.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[f,u]=v.useState(d),[m,p]=v.useState(-1),h=v.useRef(null);let g;s[1]!==o?(g=()=>{const se=o.current;if(!se)return;se.querySelectorAll(`mark.${Gm}`).forEach(cE)},s[1]=o,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==o?(b=se=>{if(x(),!se||!o.current){u([]),p(-1);return}const re=o.current,ie=aE(re),ae=se.toLowerCase(),te=[];for(const he of ie){const me=he.nodeValue||"",le=me.toLowerCase();let xe=0;const ge=[];for(;;){const ue=le.indexOf(ae,xe);if(ue===-1)break;ge.push(ue),xe=ue+1}if(ge.length===0)continue;const ce=he.parentNode;if(!ce)continue;const we=document.createDocumentFragment();let pe=0;for(const ue of ge){ue>pe&&we.appendChild(document.createTextNode(me.slice(pe,ue)));const je=document.createElement("mark");je.className=Gm,je.textContent=me.slice(ue,ue+se.length),we.appendChild(je),te.push(je),pe=ue+se.length}pe<me.length&&we.appendChild(document.createTextNode(me.slice(pe))),ce.replaceChild(we,he)}u(te),te.length>0?(p(0),te[0].classList.add(bl),te[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=b):b=s[5];const w=b;let y;s[6]!==m||s[7]!==f?(y=se=>{if(f.length===0)return;m>=0&&m<f.length&&f[m].classList.remove(bl);const re=(se%f.length+f.length)%f.length;f[re].classList.add(bl),f[re].scrollIntoView({block:"center",behavior:"smooth"}),p(re)},s[6]=m,s[7]=f,s[8]=y):y=s[8];const j=y;let k;s[9]!==x?(k=()=>{a(!1),c(""),x(),u([]),p(-1)},s[9]=x,s[10]=k):k=s[10];const N=k;let C,S;s[11]!==N||s[12]!==i?(C=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var se;return(se=h.current)==null?void 0:se.focus()})},close:N,isOpen:i}),S=[N,i],s[11]=N,s[12]=i,s[13]=C,s[14]=S):(C=s[13],S=s[14]),v.useImperativeHandle(t,C,S);let _,P;s[15]!==w||s[16]!==l?(_=()=>{const se=setTimeout(()=>w(l),150);return()=>clearTimeout(se)},P=[l,w],s[15]=w,s[16]=l,s[17]=_,s[18]=P):(_=s[17],P=s[18]),v.useEffect(_,P);let A,T;s[19]!==x?(A=()=>()=>x(),T=[x],s[19]=x,s[20]=A,s[21]=T):(A=s[20],T=s[21]),v.useEffect(A,T);let E;s[22]!==m||s[23]!==j||s[24]!==N?(E=se=>{se.key==="Escape"?(se.preventDefault(),se.stopPropagation(),N()):se.key==="Enter"&&(se.preventDefault(),se.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=N,s[25]=E):E=s[25];const M=E;if(!i)return null;let I;s[26]===Symbol.for("react.memo_cache_sentinel")?(I=se=>c(se.target.value),s[26]=I):I=s[26];let R;s[27]!==M||s[28]!==l?(R=r.jsx(es,{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 $=l?f.length>0?`${m+1}/${f.length}`:"0/0":"";let D;s[30]!==$?(D=r.jsx(wn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:$})}),s[30]=$,s[31]=D):D=s[31];let O;s[32]!==R||s[33]!==D?(O=r.jsxs(Zn,{className:"w-64",children:[R,D]}),s[32]=R,s[33]=D,s[34]=O):O=s[34];let L;s[35]!==m||s[36]!==j?(L=()=>j(m-1),s[35]=m,s[36]=j,s[37]=L):L=s[37];const F=f.length===0,z=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let H;s[38]!==z?(H=G("text-muted-foreground",z),s[38]=z,s[39]=H):H=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(hr,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let W;s[41]!==L||s[42]!==F||s[43]!==H?(W=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:L,disabled:F,className:H,"aria-label":"Previous match",children:U}),s[41]=L,s[42]=F,s[43]=H,s[44]=W):W=s[44];let K;s[45]!==m||s[46]!==j?(K=()=>j(m+1),s[45]=m,s[46]=j,s[47]=K):K=s[47];const q=f.length===0,Y=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let V;s[48]!==Y?(V=G("text-muted-foreground",Y),s[48]=Y,s[49]=V):V=s[49];let Q;s[50]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(st,{"data-icon":"inline-start"}),s[50]=Q):Q=s[50];let Z;s[51]!==K||s[52]!==q||s[53]!==V?(Z=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:K,disabled:q,className:V,"aria-label":"Next match",children:Q}),s[51]=K,s[52]=q,s[53]=V,s[54]=Z):Z=s[54];let X;s[55]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(jt,{"data-icon":"inline-start"}),s[55]=X):X=s[55];let ee;s[56]!==N?(ee=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:N,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:X}),s[56]=N,s[57]=ee):ee=s[57];let oe;return s[58]!==O||s[59]!==W||s[60]!==Z||s[61]!==ee?(oe=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:[O,W,Z,ee]}),s[58]=O,s[59]=W,s[60]=Z,s[61]=ee,s[62]=oe):oe=s[62],oe});function cE(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const yI=["General","View","Tools"],Ea=[{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}}],l0="cogpit-keybindings";let Ts=null;function c0(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function fr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function dE(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Ad(){if(Ts)return Ts;try{const n=localStorage.getItem(l0);if(!n)return Ts={};const e=JSON.parse(n);if(!e||typeof e!="object")return Ts={};const t={};for(const s of Ea){const o=e[s.command];dE(o)&&(t[s.command]=o)}return Ts=t}catch{return Ts={}}}function Rd(n){Ts=n;try{localStorage.setItem(l0,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Ir(n){const e=Ea.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Ad()[n]??e.defaultShortcut}function wI(){return Object.fromEntries(Ea.map(n=>[n.command,Ir(n.command)]))}function jI(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:fr(e.key)};Rd({...Ad(),[n]:t})}function SI(n){const e={...Ad()};delete e[n],Rd(e)}function kI(){Rd({})}function NI(n){return{key:fr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function d0(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function yt(n,e){const t=Ir(n);return"doubleTapModifier"in t||fr(e.key)!==fr(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 Ys(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 uE(n){const e=c0();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Ys(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Ys(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Ys(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Ys(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Ys(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Ys(n.key)].filter(Boolean).join("+")}function vl(n){return uE(Ir(n))}function Ym(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${fr(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 CI(n,e){const t=new Set(Ym(n));return Ea.find(s=>s.command!==e&&Ym(Ir(s.command)).some(o=>t.has(o)))??null}function Xm(n){return"doubleTapModifier"in Ir(n)?c0()?"Meta":"Control":null}const fE=["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"],mE="device.cycle";function pE(n){const e=fE.findIndex(t=>yt(t,n));return e===-1?null:e+1}function hE(n){return yt(mE,n)}const ic="cogpit:find-in-conversation",Pa=v.memo(function(e){const t=B.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}=Rt(),{session:h}=it(),{chat:g,scroll:x}=wr(),{searchQuery:b}=u,{pendingMessages:w}=g,{chatScrollRef:y,scrollEndRef:j,handleScroll:k,canScrollDown:N,scrollToBottomInstant:C,initialScrollDone:S}=x,_=v.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var ue;return(ue=_.current)==null?void 0:ue.open()},t[0]=P):P=t[0];const A=P;let T,E;t[1]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const ue=function(Ne){yt("findInConversation",Ne)&&(Ne.preventDefault(),A())};return window.addEventListener("keydown",ue),window.addEventListener(ic,A),()=>{window.removeEventListener("keydown",ue),window.removeEventListener(ic,A)}},E=[A],t[1]=T,t[2]=E):(T=t[1],E=t[2]),v.useEffect(T,E);let M,I;t[3]!==p||t[4]!==f||t[5]!==s?(M=()=>{!p||!f||requestAnimationFrame(()=>{var ue;return(ue=s.current)==null?void 0:ue.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]),v.useEffect(M,I);let R;t[8]!==m?(R=ue=>m({type:"JUMP_TO_TURN",index:ue}),t[8]=m,t[9]=R):R=t[9];const $=R;let D;t[10]!==m||t[11]!==d?(D=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=D):D=t[12];const O=D,L=h,F=L.turns.length>0||w.length===0,z=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let H;t[13]!==z?(H=G("relative bg-background",z),t[13]=z,t[14]=H):H=t[14];let U;t[15]!==O||t[16]!==m||t[17]!==p||t[18]!==f||t[19]!==s||t[20]!==b?(U=p&&f&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(Zn,{className:"h-9 flex-1",children:[r.jsx(es,{ref:s,value:b,onChange:ue=>m({type:"SET_SEARCH_QUERY",value:ue.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(wn,{align:"inline-start",children:r.jsx(bn,{})})]}),r.jsx(J,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:r.jsx(jt,{"data-icon":"inline-start"})})]}),t[15]=O,t[16]=m,t[17]=p,t[18]=f,t[19]=s,t[20]=b,t[21]=U):U=t[21];const W=p?"flex-1 min-h-0":"h-full";let K;t[22]!==W?(K=G("relative",W),t[22]=W,t[23]=K):K=t[23];let q;t[24]!==y?(q=r.jsx(lE,{ref:_,scrollContainerRef:y}),t[24]=y,t[25]=q):q=t[25];let Y;t[26]!==y||t[27]!==L.turns||t[28]!==$||t[29]!==p?(Y=!p&&r.jsx(rE,{turns:L.turns,scrollContainerRef:y,onJumpToTurn:$}),t[26]=y,t[27]=L.turns,t[28]=$,t[29]=p,t[30]=Y):Y=t[30];let V;t[31]!==y||t[32]!==L?(V=r.jsx(X7,{session:L,scrollContainerRef:y}),t[31]=y,t[32]=L,t[33]=V):V=t[33];const Q=p&&"mobile-scroll";let Z;t[34]!==Q?(Z=G("h-full overflow-x-hidden overflow-y-auto bg-background",Q),t[34]=Q,t[35]=Z):Z=t[35];let X;t[36]!==o||t[37]!==p?(X=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]=X):X=t[38];let ee;t[39]!==y||t[40]!==i||t[41]!==S||t[42]!==a||t[43]!==l||t[44]!==F?(ee=F&&r.jsx(W7,{chatScrollRef:y,hasMore:i,isLoadingOlder:a,pagingEnabled:S,onLoadMore:l}),t[39]=y,t[40]=i,t[41]=S,t[42]=a,t[43]=l,t[44]=F,t[45]=ee):ee=t[45];let oe;t[46]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsx(Q7,{}),t[46]=oe):oe=t[46];let se;if(t[47]!==L.turns.length||t[48]!==w){let ue;t[50]!==L.turns.length?(ue=(je,Ne)=>r.jsx(ex,{message:je,turnNumber:L.turns.length+1+Ne},Ne),t[50]=L.turns.length,t[51]=ue):ue=t[51],se=w.map(ue),t[47]=L.turns.length,t[48]=w,t[49]=se}else se=t[49];let re;t[52]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(o7,{}),t[52]=re):re=t[52];let ie;t[53]!==j?(ie=r.jsx("div",{ref:j}),t[53]=j,t[54]=ie):ie=t[54];let ae;t[55]!==ee||t[56]!==se||t[57]!==ie?(ae=r.jsxs(iE,{fallbackMessage:"Failed to render conversation timeline",children:[ee,oe,se,re,ie]}),t[55]=ee,t[56]=se,t[57]=ie,t[58]=ae):ae=t[58];let te;t[59]!==X||t[60]!==ae?(te=r.jsx("div",{className:X,children:ae}),t[59]=X,t[60]=ae,t[61]=te):te=t[61];let he;t[62]!==y||t[63]!==k||t[64]!==Z||t[65]!==te?(he=r.jsx("div",{ref:y,onScroll:k,className:Z,children:te}),t[62]=y,t[63]=k,t[64]=Z,t[65]=te,t[66]=he):he=t[66];const me=N?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",le=p?"right-3 bottom-3":"right-5 bottom-5";let xe;t[67]!==me||t[68]!==le?(xe=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",me,le),t[67]=me,t[68]=le,t[69]=xe):xe=t[69];let ge;t[70]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsx(Fv,{"data-icon":"inline-start"}),t[70]=ge):ge=t[70];let ce;t[71]!==C||t[72]!==xe?(ce=r.jsx(J,{size:"icon",className:xe,onClick:C,"aria-label":"Scroll to bottom",children:ge}),t[71]=C,t[72]=xe,t[73]=ce):ce=t[73];let we;t[74]!==K||t[75]!==q||t[76]!==Y||t[77]!==V||t[78]!==he||t[79]!==ce?(we=r.jsxs("div",{className:K,children:[q,Y,V,he,ce]}),t[74]=K,t[75]=q,t[76]=Y,t[77]=V,t[78]=he,t[79]=ce,t[80]=we):we=t[80];let pe;return t[81]!==H||t[82]!==U||t[83]!==we?(pe=r.jsxs("div",{className:H,children:[U,we]}),t[81]=H,t[82]=U,t[83]=we,t[84]=pe):pe=t[84],pe}),ac="cogpit-devices-changed",u0="cogpit:devices-changed";function f0(n){typeof n.connectionRevision=="number"&&gw(n.id,n.connectionRevision)}function m0(n,e,t=!1){window.dispatchEvent(new CustomEvent(ac,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(u0,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function Jm(n){f0(n),m0(n.id,n.connectionRevision)}function yl(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function Xs(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function p0(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function gE(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function Aa(){const[n,e]=v.useState([]),[t,s]=v.useState(!0),[o,i]=v.useState(()=>ht()),a=v.useRef(0),l=v.useCallback(async()=>{const h=++a.current;try{const g=await rs("/api/hub/devices");if(!g.ok)return;const x=await Xs(g);if(h!==a.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of b)f0(w);e(b)}catch{}finally{h===a.current&&s(!1)}},[]);v.useEffect(()=>{l()},[l]),v.useEffect(()=>{const h=()=>i(ht()),g=()=>void l(),x=y=>{if(y.key===u0){try{const j=JSON.parse(y.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&ht()===j.deviceId&&hs(wt)}catch{}l()}},b=()=>{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(ac,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-identity-changed",b),window.addEventListener("cogpit-auth-required",w),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(ac,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-identity-changed",b),window.removeEventListener("cogpit-auth-required",w)}},[l]);const c=v.useMemo(()=>o===wt?void 0:n.find(h=>h.id===o),[n,o]),d=v.useCallback(async(h,g,x,b)=>{try{const w=await rs("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:b})}),y=await Xs(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=v.useCallback(async h=>{try{const g=await rs("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await Xs(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return Jm(b),{ok:!0,device:b}}return{ok:!1,code:(x==null?void 0:x.code)??"ERROR",error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),u=v.useCallback(async(h,g)=>{try{const x=await rs(yl(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await Xs(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return Jm(w),{ok:!0,device:w}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=v.useCallback(async h=>{try{const g=await rs(yl(h),{method:"DELETE"});if(g.ok)return ht()===h&&hs(wt),m0(h,void 0,!0),{ok:!0};const x=await Xs(g);return{ok:!1,error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),p=v.useCallback(async h=>{try{const g=await rs(yl(h,"/test"),{method:"POST"});return await Xs(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 xE=v.lazy(()=>Ke(()=>import("./CommandPaletteHost-Bfg_Eihd.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),bE=v.lazy(()=>Ke(()=>import("./index-BXfuxlSt.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),vE=v.lazy(()=>Ke(()=>Promise.resolve().then(()=>LE),void 0).then(n=>({default:n.DevicesDialog}))),yE=v.lazy(()=>Ke(()=>import("./KeyboardShortcutsDialog-Bu1kIaBx.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),wE=v.lazy(()=>Ke(()=>import("./ProjectSwitcherModal-DulA-4x-.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),jE=v.lazy(()=>Ke(()=>import("./ThemeSelectorModal-CklkGcoT.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal}))),SE=v.lazy(()=>Ke(()=>import("./WorktreePanel-CC8kT63h.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function kE(n){const e=B.c(125),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Rt(),{session:c,sessionSource:d}=it(),{devices:f,activeDeviceId:u}=Aa(),[m,p]=v.useState(null),[h,g]=v.useState(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=ut("manageDevices"),e[0]=x):x=e[0];const b=x;let w;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(w=i.pendingCwd??(i.pendingDirName?gn(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,k=m??h;let N,C;e[4]!==m?(N=()=>{m&&g(m)},C=[m],e[4]=m,e[5]=N,e[6]=C):(N=e[5],C=e[6]),v.useEffect(N,C);const S=o.onKeyboardShortcutsOpenChange;let _,P;e[7]!==S?(_=()=>{const Se=function(Ue){yt("keyboardShortcuts",Ue)&&(d0(document.activeElement)||(Ue.preventDefault(),S(!0)))};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},P=[S],e[7]=S,e[8]=_,e[9]=P):(_=e[8],P=e[9]),v.useEffect(_,P);const A=u===wt;let T;e[10]!==A?(T={id:wt,name:"This machine",isLocal:!0,isActive:A},e[10]=A,e[11]=T):T=e[11];let E;if(e[12]!==u||e[13]!==f||e[14]!==T){let Se;e[16]!==u?(Se=$e=>({id:$e.id,name:$e.name,isLocal:!1,isActive:$e.id===u}),e[16]=u,e[17]=Se):Se=e[17],E=[T,...f.map(Se)],e[12]=u,e[13]=f,e[14]=T,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 Se=(d==null?void 0:d.agentKind)??St((d==null?void 0:d.dirName)??null);vr(yh(Se,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,$=NE,D=s.supportsWorktrees&&t.panels.showWorktrees;let O;e[22]!==j||e[23]!==t.actions||e[24]!==t.panels?(O=Se=>{j&&t.actions.handleDashboardSelect(j,`${Se}.jsonl`),t.panels.setShowWorktrees(!1)},e[22]=j,e[23]=t.actions,e[24]=t.panels,e[25]=O):O=e[25];let L;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]!==D||e[32]!==O?(L=r.jsx(v.Suspense,{fallback:null,children:r.jsx(SE,{open:D,onOpenChange:t.panels.setShowWorktrees,worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:j,onRefetch:s.worktrees.refetch,onOpenSession:O})}),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]=D,e[32]=O,e[33]=L):L=e[33];const F=o.processPanel,z=o.workflowsPanel,H=o.undoDialog,U=o.branchModal,W=a.claudeDir??"";let K;e[34]!==a.handleCloseConfigDialog||e[35]!==a.handleConfigSaved||e[36]!==a.showConfigDialog||e[37]!==W?(K=r.jsx(v.Suspense,{fallback:null,children:r.jsx(bE,{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]=K):K=e[38];const q=(d==null?void 0:d.dirName)??i.pendingDirName??null,Y=(c==null?void 0:c.cwd)??i.pendingCwd??null;let V;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?(V=r.jsx(v.Suspense,{fallback:null,children:r.jsx(wE,{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]=V):V=e[46];let Q;e[47]!==t.panels.handleCloseThemeSelector||e[48]!==t.panels.showThemeSelector||e[49]!==l.setPreview||e[50]!==l.setTheme||e[51]!==l.theme?(Q=r.jsx(v.Suspense,{fallback:null,children:r.jsx(jE,{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]=Q):Q=e[52];const Z=o.commandPaletteOpen,X=o.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,oe=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,re=t.actions.handleDashboardSelect,ie=t.panels.handleToggleSidebar,ae=t.panels.handleToggleStats,te=t.panels.handleToggleFileChanges,he=t.panels.handleToggleWorktrees,me=t.panels.handleToggleMission,le=c?t.handlers.handleDuplicateSession:void 0,xe=c?R:void 0,ge=c?$:void 0,ce=ut("killAny")?o.onKillAll:void 0,we=ut("configWrite")?t.panels.handleToggleConfig:void 0,pe=a.openConfigDialog;let ue;e[53]!==S?(ue=()=>S(!0),e[53]=S,e[54]=ue):ue=e[54];const je=s.currentCwd?s.onTogglePreview:void 0,Ne=ut("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,Re=t.panels.handleToggleThemeSelector,Te=s.onOpenTerminal,Pe=o.onFocusComposer,Oe=o.onExpandAll,Fe=o.onExpandToolPayloads,ze=o.onCollapseAll,Be=!!(c||i.pendingDirName);let _e;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=ut("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]=_e):_e=e[60];const He=!!c;let Ie;e[61]!==s.hasFileChanges?(Ie=ut("hostFiles")&&s.hasFileChanges,e[61]=s.hasFileChanges,e[62]=Ie):Ie=e[62];const Ce=i.mainView==="config",de=i.mainView==="mission",Ee=(c==null?void 0:c.cwd)??y??null;let Ae;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]!==le||e[92]!==xe||e[93]!==ge||e[94]!==ce||e[95]!==we||e[96]!==ue||e[97]!==je||e[98]!==Ne||e[99]!==Be||e[100]!==_e||e[101]!==He||e[102]!==Ie||e[103]!==Ce||e[104]!==de||e[105]!==Ee?(Ae=r.jsx(v.Suspense,{fallback:null,children:r.jsx(xE,{open:Z,onOpenChange:X,onGoHome:ee,onNewSession:oe,onOpenProject:se,onOpenSession:re,onToggleSidebar:ie,onToggleStats:ae,onToggleFileChanges:te,onToggleWorktrees:he,onToggleMissionControl:me,onDuplicateSession:le,onCopyResumeCommand:xe,onFindInConversation:ge,onKillAll:ce,onOpenConfig:we,onOpenSettings:pe,onOpenKeyboardShortcuts:ue,onTogglePreview:je,onToggleProjectFiles:Ne,onOpenTheme:Re,onOpenTerminal:Te,onOpenDevices:b?p:void 0,onSwitchDevice:hs,devices:M,onFocusComposer:Pe,onExpandAll:Oe,onExpandToolPayloads:Fe,onCollapseAll:ze,canFocusComposer:Be,canOpenTerminal:_e,hasSession:He,hasFileChanges:Ie,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:t.panels.showStats,showProjectFiles:s.showProjectFiles,showFileChanges:t.panels.showFileChanges,showWorktrees:t.panels.showWorktrees,showConfig:Ce,showMission:de,currentProjectDirName:j,projectCwd:Ee,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]=le,e[92]=xe,e[93]=ge,e[94]=ce,e[95]=we,e[96]=ue,e[97]=je,e[98]=Ne,e[99]=Be,e[100]=_e,e[101]=He,e[102]=Ie,e[103]=Ce,e[104]=de,e[105]=Ee,e[106]=Ae):Ae=e[106];let Le;e[107]!==o.keyboardShortcutsOpen||e[108]!==S?(Le=r.jsx(v.Suspense,{fallback:null,children:r.jsx(yE,{open:o.keyboardShortcutsOpen,onOpenChange:S})}),e[107]=o.keyboardShortcutsOpen,e[108]=S,e[109]=Le):Le=e[109];let ne;e[110]!==m||e[111]!==k?(ne=b&&k!==null&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(vE,{open:m!==null,initialMode:k,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[110]=m,e[111]=k,e[112]=ne):ne=e[112];let fe;return e[113]!==o.branchModal||e[114]!==o.processPanel||e[115]!==o.undoDialog||e[116]!==o.workflowsPanel||e[117]!==L||e[118]!==K||e[119]!==V||e[120]!==Q||e[121]!==Ae||e[122]!==Le||e[123]!==ne?(fe=r.jsxs(r.Fragment,{children:[L,F,z,H,U,K,V,Q,Ae,Le,ne]}),e[113]=o.branchModal,e[114]=o.processPanel,e[115]=o.undoDialog,e[116]=o.workflowsPanel,e[117]=L,e[118]=K,e[119]=V,e[120]=Q,e[121]=Ae,e[122]=Le,e[123]=ne,e[124]=fe):fe=e[124],fe}function NE(){window.dispatchEvent(new Event(ic))}function wl(n){const e=B.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(Pt,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(At,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(Et,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const CE="2.1.1",h0={version:CE},_E=h0.version,TE=19384,EE=443,PE=450,AE=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),RE=`${AE?"⌘⇧":"Ctrl+Shift+"}1–9`,ME=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),IE=new Set(["ACCOUNT_DISABLED"]);function Bo(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 g0(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 x0={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function $E(n){const e=B.c(10),{tone:t}=n,s=x0[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(Un,{"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(jn,{"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(Qt,{"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(zs,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const OE={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function DE({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=v.useState(!1),[c,d]=v.useState(n.name),[f,u]=v.useState(!1),[m,p]=v.useState(n.username??""),[h,g]=v.useState(""),[x,b]=v.useState(null),[w,y]=v.useState(!1),[j,k]=v.useState(null);v.useEffect(()=>{d(n.name)},[n.name]),v.useEffect(()=>{p(n.username??"")},[n.username]);const N=p0(n),C=N!==void 0&&N!==e,S=gE(n)==="team";async function _(){const A=c.trim();if(!A||A===n.name){l(!1),d(n.name);return}k("rename"),await t(n.id,A),k(null),l(!1)}async function P(){const A=m.trim(),T=n.username??"",E=A!==T,M=h.length>0;if(!E&&!M){u(!1),g(""),b(null);return}if(n.auth==="none"&&!M){b("Enter a password when adding an account to an unauthenticated device.");return}const I={};E&&(I.username=A||null),M&&(I.password=h),k("credentials"),b(null);const R=await s(n.id,I);if(k(null),!R.ok){b(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",OE[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Ot,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:A=>d(A.target.value),onKeyDown:A=>{A.key==="Enter"&&_(),A.key==="Escape"&&(l(!1),d(n.name))},onBlur:()=>void _(),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}),N&&r.jsxs("span",{className:G("shrink-0 font-mono text-xs",C?"text-warning":"text-muted-foreground"),title:C?`Device runs v${N}; hub runs v${e}`:void 0,children:["v",N,C&&" ≠ hub"]}),n.auth==="none"&&r.jsx(Me,{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]}):S?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(J,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:j==="test",onClick:async()=>{k("test"),await i(n.id),k(null)},children:r.jsx(Qt,{"data-icon":"inline-start",className:G(j==="test"&&"animate-spin")})}),r.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{u(A=>!A),p(n.username??""),g(""),b(null)},children:r.jsx(Bv,{"data-icon":"inline-start"})}),r.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Ls,{"data-icon":"inline-start"})}),r.jsxs(Fc,{open:w,onOpenChange:A=>{j!=="remove"&&y(A)},children:[r.jsx(BS,{render:r.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(qi,{"data-icon":"inline-start"})}),r.jsxs(Bc,{size:"sm",children:[r.jsxs(Uc,{children:[r.jsxs(Hc,{children:["Remove ",n.name,"?"]}),r.jsx(Kc,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(Wc,{children:[r.jsx(Vc,{disabled:j==="remove",children:"Cancel"}),r.jsxs(qc,{variant:"destructive",disabled:j==="remove",onClick:async()=>{k("remove");try{await o(n.id)}finally{k(null)}},children:[j==="remove"&&r.jsx(rt,{"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(gt,{children:[r.jsxs(xt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Ot,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:A=>p(A.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(gt,{children:[r.jsxs(xt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Ot,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:A=>g(A.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."}),x&&r.jsx(us,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(J,{variant:"outline",size:"sm",onClick:()=>{u(!1),p(n.username??""),g(""),b(null)},children:"Cancel"}),r.jsx(J,{size:"sm",disabled:j==="credentials",onClick:()=>void P(),children:j==="credentials"?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function b0(n){var Xe,Je;const e=B.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}=Aa(),[p,h]=v.useState(""),[g,x]=v.useState(""),[b,w]=v.useState(""),[y,j]=v.useState(""),[k,N]=v.useState(!1),[C,S]=v.useState(!1),[_,P]=v.useState(null),[A,T]=v.useState(!1),[E,M]=v.useState(null),I=v.useRef(null),R=v.useRef(0);let $,D;e[0]!==s||e[1]!==t?($=()=>{t&&(h(""),x(""),w(""),j(""),N(!1),S(!1),P(null),M(null),s==="add"&&requestAnimationFrame(()=>{var De;return(De=I.current)==null?void 0:De.focus()}))},D=[t,s],e[0]=s,e[1]=t,e[2]=$,e[3]=D):($=e[2],D=e[3]),v.useEffect($,D);let O;e[4]!==k||e[5]!==g||e[6]!==c?(O=async()=>{const{host:De,port:qe,tls:ot}=Bo(g);if(!De){P(null),S(!1);return}const lt=R.current=R.current+1;S(!0);const bt=await c(De,qe,k,ot);lt===R.current&&(P({...g0(bt,De,qe??(ot?EE:TE)),hello:bt.ok?bt.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=c,e[7]=O):O=e[7];const L=O;let F,z;e[8]!==g||e[9]!==t||e[10]!==L?(F=()=>{if(!t)return;if(!Bo(g).host){P(null),S(!1);return}const De=window.setTimeout(()=>void L(),PE);return()=>window.clearTimeout(De)},z=[t,g,L],e[8]=g,e[9]=t,e[10]=L,e[11]=F,e[12]=z):(F=e[11],z=e[12]),v.useEffect(F,z);const H=((Xe=_==null?void 0:_.hello)==null?void 0:Xe.edition)==="team",U=H&&((Je=_==null?void 0:_.hello)==null?void 0:Je.needsBootstrap)===!0,W=H||!k;let K;e:{if(A){K=!1;break e}if(!Bo(g).host){K=!1;break e}if(C||!_){K=!1;break e}if(U){K=!1;break e}if(W&&!y){K=!1;break e}if(H&&!b.trim()){K=!1;break e}if((_==null?void 0:_.tone)==="error"){K=!1;break e}K=!0}const q=K;let Y;e[13]!==d||e[14]!==k||e[15]!==W||e[16]!==g||e[17]!==p||e[18]!==o||e[19]!==y||e[20]!==H||e[21]!==b?(Y=async function(){const{host:qe,port:ot,tls:lt}=Bo(g);if(!qe)return;T(!0),M(null);const bt=await d({name:p.trim()||void 0,host:qe,port:ot,tls:lt,username:H?b.trim():void 0,password:W&&y||void 0,allowLocalTunnel:k});if(T(!1),bt.ok){o(),hs(bt.device.id);return}M({field:IE.has(bt.code)?"username":ME.has(bt.code)?"password":"host",message:bt.error})},e[13]=d,e[14]=k,e[15]=W,e[16]=g,e[17]=p,e[18]=o,e[19]=y,e[20]=H,e[21]=b,e[22]=Y):Y=e[22];const V=Y;let Q;e[23]!==f?(Q=async(De,qe)=>{await f(De,{name:qe})},e[23]=f,e[24]=Q):Q=e[24];const Z=Q;let X;e[25]!==u?(X=async De=>{await u(De)},e[25]=u,e[26]=X):X=e[26];const ee=X;let oe;e[27]!==l||e[28]!==m?(oe=async De=>{await m(De),await l()},e[27]=l,e[28]=m,e[29]=oe):oe=e[29];const se=oe;let re;e[30]!==o?(re=De=>{De||o()},e[30]=o,e[31]=re):re=e[31];let ie;e[32]!==i?(ie=De=>{De||i==null||i()},e[32]=i,e[33]=ie):ie=e[33];let ae;e[34]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsxs(ks,{children:[r.jsx(Xn,{children:"Devices"}),r.jsxs(Jn,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",RE," jumps between devices."]})]}),e[34]=ae):ae=e[34];let te;e[35]!==a||e[36]!==ee||e[37]!==Z||e[38]!==se||e[39]!==f?(te=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(De=>r.jsx(DE,{device:De,hubVersion:_E,onRename:Z,onCredentials:f,onRemove:ee,onTest:se},De.id))}),e[35]=a,e[36]=ee,e[37]=Z,e[38]=se,e[39]=f,e[40]=te):te=e[40];let he;e[41]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Tn,{"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]=he):he=e[41];const me=(E==null?void 0:E.field)==="host";let le,xe;e[42]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(xt,{htmlFor:"device-host",children:"Host"}),xe=r.jsx(mo,{children:"Enter a local address or an HTTPS URL."}),e[42]=le,e[43]=xe):(le=e[42],xe=e[43]);let ge;e[44]===Symbol.for("react.memo_cache_sentinel")?(ge=De=>{R.current=R.current+1,x(De.target.value),w(""),P(null),M(null)},e[44]=ge):ge=e[44];let ce;e[45]!==L?(ce=()=>void L(),e[45]=L,e[46]=ce):ce=e[46];let we;e[47]!==g||e[48]!==ce?(we=r.jsx(Ot,{id:"device-host",ref:I,value:g,onChange:ge,onBlur:ce,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[47]=g,e[48]=ce,e[49]=we):we=e[49];let pe;e[50]!==C?(pe=C&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[50]=C,e[51]=pe):pe=e[51];let ue;e[52]!==_||e[53]!==C?(ue=!C&&_&&r.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",x0[_.tone]),children:[r.jsx($E,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=ue):ue=e[54];let je;e[55]!==E?(je=(E==null?void 0:E.field)==="host"&&r.jsx(us,{children:E.message}),e[55]=E,e[56]=je):je=e[56];let Ne;e[57]!==me||e[58]!==we||e[59]!==pe||e[60]!==ue||e[61]!==je?(Ne=r.jsxs(gt,{"data-invalid":me,children:[le,xe,we,pe,ue,je]}),e[57]=me,e[58]=we,e[59]=pe,e[60]=ue,e[61]=je,e[62]=Ne):Ne=e[62];let Re;e[63]===Symbol.for("react.memo_cache_sentinel")?(Re=r.jsxs(xt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Re):Re=e[63];let Te;e[64]===Symbol.for("react.memo_cache_sentinel")?(Te=De=>h(De.target.value),e[64]=Te):Te=e[64];let Pe;e[65]!==p?(Pe=r.jsxs(gt,{children:[Re,r.jsx(Ot,{id:"device-name",value:p,onChange:Te,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Pe):Pe=e[66];let Oe;e[67]!==E||e[68]!==H||e[69]!==b?(Oe=H&&r.jsxs(gt,{"data-invalid":(E==null?void 0:E.field)==="username",children:[r.jsx(xt,{htmlFor:"device-username",children:"Username"}),r.jsx(Ot,{id:"device-username",value:b,onChange:De=>w(De.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(mo,{children:"Requests through this hub will act as this account on the team server."}),(E==null?void 0:E.field)==="username"&&r.jsx(us,{children:E.message})]}),e[67]=E,e[68]=H,e[69]=b,e[70]=Oe):Oe=e[70];let Fe;e[71]!==W||e[72]!==y||e[73]!==E||e[74]!==H?(Fe=W&&r.jsxs(gt,{"data-invalid":(E==null?void 0:E.field)==="password",children:[r.jsx(xt,{htmlFor:"device-password",children:"Password"}),r.jsx(Ot,{id:"device-password",type:"password",value:y,onChange:De=>j(De.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(us,{children:E.message})]}),e[71]=W,e[72]=y,e[73]=E,e[74]=H,e[75]=Fe):Fe=e[75];let ze;e[76]!==Ne||e[77]!==Pe||e[78]!==Oe||e[79]!==Fe?(ze=r.jsxs(jo,{children:[Ne,Pe,Oe,Fe]}),e[76]=Ne,e[77]=Pe,e[78]=Oe,e[79]=Fe,e[80]=ze):ze=e[80];let Be;e[81]===Symbol.for("react.memo_cache_sentinel")?(Be=De=>{R.current=R.current+1,N(De===!0),P(null),M(null)},e[81]=Be):Be=e[81];let _e;e[82]!==k?(_e=r.jsx(kg,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Be}),e[82]=k,e[83]=_e):_e=e[83];const He=H?"":" — no password";let Ie;e[84]!==He?(Ie=r.jsxs(xt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",He]}),e[84]=He,e[85]=Ie):Ie=e[85];let Ce;e[86]!==_e||e[87]!==Ie?(Ce=r.jsxs(gt,{orientation:"horizontal",children:[_e,Ie]}),e[86]=_e,e[87]=Ie,e[88]=Ce):Ce=e[88];let de;e[89]!==k||e[90]!==H?(de=k&&r.jsxs(Ct,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(Uv,{}),r.jsx(_t,{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]=k,e[90]=H,e[91]=de):de=e[91];let Ee;e[92]!==o?(Ee=r.jsx(J,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=Ee):Ee=e[93];const Ae=!q;let Le;e[94]!==V?(Le=()=>void V(),e[94]=V,e[95]=Le):Le=e[95];let ne;e[96]!==A?(ne=A?r.jsxs(r.Fragment,{children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=A,e[97]=ne):ne=e[97];let fe;e[98]!==Ae||e[99]!==Le||e[100]!==ne?(fe=r.jsx(J,{disabled:Ae,onClick:Le,children:ne}),e[98]=Ae,e[99]=Le,e[100]=ne,e[101]=fe):fe=e[101];let Se;e[102]!==Ee||e[103]!==fe?(Se=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Ee,fe]}),e[102]=Ee,e[103]=fe,e[104]=Se):Se=e[104];let $e;e[105]!==ze||e[106]!==Ce||e[107]!==de||e[108]!==Se?($e=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[he,ze,Ce,de,Se]}),e[105]=ze,e[106]=Ce,e[107]=de,e[108]=Se,e[109]=$e):$e=e[109];let Ue;e[110]!==te||e[111]!==$e?(Ue=r.jsxs(Yn,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,te,$e]}),e[110]=te,e[111]=$e,e[112]=Ue):Ue=e[112];let We;return e[113]!==t||e[114]!==re||e[115]!==ie||e[116]!==Ue?(We=r.jsx(Gn,{open:t,onOpenChange:re,onOpenChangeComplete:ie,children:Ue}),e[113]=t,e[114]=re,e[115]=ie,e[116]=Ue,e[117]=We):We=e[117],We}const LE=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:b0,parseHostPort:Bo,probeMessage:g0},Symbol.toStringTag,{value:"Module"})),Qm=h0.version,zE={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Zm={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function FE(n){const e=B.c(6),{state:t}=n,s=Zm[t],o=Zm[t],i=zE[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 Md(n){const e=B.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=Aa(),[d,f]=v.useState(null),u=(a==null?void 0:a.name)??"This machine",m=i!==wt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ut("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==o||e[2]!==l||e[3]!==c?(g=F=>{!F||o.length===0||Promise.all(o.map(z=>c(z.id).catch(UE))).then(()=>l())},e[1]=o,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&o.length===0&&!m)return null;const b=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]!==b||e[8]!==y?(j=r.jsx(J,{variant:"ghost",size:b,"aria-label":"Switch device",className:y}),e[7]=b,e[8]=y,e[9]=j):j=e[9];let k;e[10]!==m?(k=m?r.jsx(eh,{"data-icon":"inline-start"}):r.jsx(Wu,{"data-icon":"inline-start"}),e[10]=m,e[11]=k):k=e[11];let N;e[12]!==u?(N=r.jsx("span",{className:"truncate",children:u}),e[12]=u,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(st,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let S;e[15]!==j||e[16]!==k||e[17]!==N?(S=r.jsxs(Mn,{render:j,children:[k,N,C]}),e[15]=j,e[16]=k,e[17]=N,e[18]=S):S=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(gs,{children:"Devices"}),e[19]=_):_=e[19];let P,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Wu,{}),A=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=P,e[21]=A):(P=e[20],A=e[21]);let T;e[22]!==m?(T=!m&&r.jsx(dt,{className:"ml-auto text-success"}),e[22]=m,e[23]=T):T=e[23];let E;e[24]!==T?(E=r.jsxs(ct,{onClick:BE,children:[P,A,T]}),e[24]=T,e[25]=E):E=e[25];let M;if(e[26]!==i||e[27]!==s||e[28]!==o){let F;e[30]!==i||e[31]!==s?(F=z=>{const H=p0(z),U=H!==void 0&&H!==Qm,W=z.id===i;return r.jsxs(ct,{onClick:()=>hs(z.id),className:G(s&&"min-h-10"),children:[r.jsx(FE,{state:z.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:z.name}),U&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${H}; hub runs v${Qm}`,children:["v",H]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[z.host,":",z.port,z.auth==="none"&&" · unauthenticated"]})]}),W&&r.jsx(dt,{className:"ml-auto text-success"})]},z.id)},e[30]=i,e[31]=s,e[32]=F):F=e[32],M=o.map(F),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(Ft,{children:[_,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(ao,{}),r.jsxs(Ft,{children:[r.jsxs(ct,{onClick:()=>f("add"),children:[r.jsx(Tn,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(ct,{onClick:()=>f("manage"),children:[r.jsx(kc,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=R):R=e[37];let $;e[38]!==I||e[39]!==R?($=r.jsxs(In,{align:"end",sideOffset:6,className:"w-64",children:[I,R]}),e[38]=I,e[39]=R,e[40]=$):$=e[40];let D;e[41]!==x||e[42]!==S||e[43]!==$?(D=r.jsxs(Rn,{onOpenChange:x,children:[S,$]}),e[41]=x,e[42]=S,e[43]=$,e[44]=D):D=e[44];let O;e[45]!==d?(O=h&&r.jsx(b0,{open:d!==null,initialMode:d??"manage",onClose:()=>f(null)}),e[45]=d,e[46]=O):O=e[46];let L;return e[47]!==D||e[48]!==O?(L=r.jsxs(r.Fragment,{children:[D,O]}),e[47]=D,e[48]=O,e[49]=L):L=e[49],L}function BE(){return hs(wt)}function UE(){return null}const WE=6e4;function HE(){const[n,e]=v.useState([]),[t,s]=v.useState(!1),o=v.useRef(!1),i=v.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=v.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 v.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},WE);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const KE=6e4;function qE(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=HE(),[i,a]=v.useState(!1),l=e.length>0,c=e.reduce(YE,0);let d,f;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const T=window.setTimeout(()=>a(!1),KE);return()=>window.clearTimeout(T)},f=[l],n[0]=l,n[1]=d,n[2]=f):(d=n[1],f=n[2]),v.useEffect(d,f),!l&&!i)return null;const u=Et,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(GE)):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 x;n[8]!==g?(x=G("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=r.jsx(J,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:x}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=x,n[15]=b):b=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Wv,{"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 k;n[19]!==j||n[20]!==b?(k=r.jsxs(Pt,{render:b,children:[w,j]}),n[19]=j,n[20]=b,n[21]=k):k=n[21];const N=At,C="bottom",S="p-3",_=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(VE),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(It,{}),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 P;n[22]!==N||n[23]!==_?(P=r.jsx(N,{side:C,className:S,children:_}),n[22]=N,n[23]=_,n[24]=P):P=n[24];let A;return n[25]!==u||n[26]!==k||n[27]!==P?(A=r.jsxs(u,{children:[k,P]}),n[25]=u,n[26]=k,n[27]=P,n[28]=A):A=n[28],A}function VE(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," · ",Ic(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function GE(n){return n.pid}function YE(n,e){return n+e.cpuPercent}const XE=15e3;function JE(){const n=B.c(12);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=v.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const b=await ye("/api/notifications?limit=100");if(!b.ok)return;const w=await b.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 b=window.setInterval(()=>void i(),XE);return()=>window.clearInterval(b)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),v.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(b,w)=>{const y=new Date().toISOString();s(j=>j.map(k=>k.readAt===null&&w(k)?{...k,readAt:y}:k));try{await ye("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})}catch{}},n[4]=c):c=n[4];const d=c;let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=async b=>d({ids:b},w=>b.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},ZE),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(QE),n[7]=t,n[8]=h):h=n[8];const g=h.length;let x;return n[9]!==t||n[10]!==g?(x={notifications:t,unreadCount:g,refresh:i,markRead:u,markAllRead:p},n[9]=t,n[10]=g,n[11]=x):x=n[11],x}function QE(n){return n.readAt===null}function ZE(){return!0}function v0(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function e8(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=JE(),[a,l]=v.useState(!1);let c;n[0]!==o?(c=function(S){if(o([S.id]),!S.dirName||!S.sessionId)return;const _=ht(),P=_===wt?"":`/d/${_}`;v0(`${P}/${encodeURIComponent(S.dirName)}/${encodeURIComponent(S.sessionId)}`),l(!1)},n[0]=o,n[1]=c):c=n[1];const d=c;let f;n[2]!==s?(f=C=>{l(C),C&&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(J,{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(Hu,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Me,{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 x;n[10]!==p||n[11]!==g?(x=r.jsxs(Mn,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let b;n[13]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=b):b=n[13];let w;n[14]!==i||n[15]!==t?(w=t>0&&r.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(Hv,{"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:[b,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(Hn,{className:"min-h-40 p-6",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(Hu,{})}),r.jsx(qn,{children:"No notifications"}),r.jsx(Vn,{children:"Session updates will appear here."})]})}):r.jsx(Ft,{children:e.map(C=>r.jsx(t8,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=j):j=n[21];let k;n[22]!==y||n[23]!==j?(k=r.jsxs(In,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[y,j]}),n[22]=y,n[23]=j,n[24]=k):k=n[24];let N;return n[25]!==a||n[26]!==f||n[27]!==k||n[28]!==x?(N=r.jsxs(Rn,{open:a,onOpenChange:f,children:[x,k]}),n[25]=a,n[26]=f,n[27]=k,n[28]=x,n[29]=N):N=n[29],N}function t8(n){const e=B.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"?vn:Qi;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 x;e[10]!==d||e[11]!==g?(x=r.jsx(d,{className:g}),e[10]=d,e[11]=g,e[12]=x):x=e[12];const b=o?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==b?(w=G("truncate text-xs",b),e[13]=b,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=Ic(c),e[18]=c,e[19]=j):j=e[19];let k;e[20]!==j?(k=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:j}),e[20]=j,e[21]=k):k=e[21];let N;e[22]!==y||e[23]!==k?(N=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[y,k]}),e[22]=y,e[23]=k,e[24]=N):N=e[24];let C;e[25]!==t.body?(C=r.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=C):C=e[26];let S;e[27]!==N||e[28]!==C?(S=r.jsxs("span",{className:"min-w-0 flex-1",children:[N,C]}),e[27]=N,e[28]=C,e[29]=S):S=e[29];let _;e[30]!==o?(_=o&&r.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=o,e[31]=_):_=e[31];let P;return e[32]!==S||e[33]!==_||e[34]!==f||e[35]!==p||e[36]!==x?(P=r.jsxs(ct,{onClick:f,className:p,children:[x,S,_]}),e[32]=S,e[33]=_,e[34]=f,e[35]=p,e[36]=x,e[37]=P):P=e[37],P}const n8=2e3;function bo(n){return`${n.toFixed(n<10?1:0)}%`}function Oi(n){return`${n.toFixed(0)} MB`}function s8(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function o8(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 r8(n){const e=B.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(Me,{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(Me,{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(Me,{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(J,{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=bo(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 x;e[30]!==t.memoryMb?(x=Oi(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=Ic(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let w;e[34]!==x||e[35]!==b?(w=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,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 i8(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 a8(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 y0(n){const e=B.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(Me,{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=i8(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=bo(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=Oi(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 x;e[27]!==m||e[28]!==h||e[29]!==g?(x=r.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function ep(n){const e=B.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(l8)}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 l8(n,e){const t=o8(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(It,{}),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:s8(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(Me,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function c8(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(d8).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:bo(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 d8(n){return bo(n)}function u8(n){var xe,ge,ce,we;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=v.useState(null),[a,l]=v.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,f]=v.useState(c),[u,m]=v.useState(null),[p,h]=v.useState(!1),g=v.useRef(!1),[x,b]=go();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Pe;if(g.current)return;g.current=!0,h(!0);const pe=ye("/api/performance").then(x8),ue=((Pe=window.electronPerformance)==null?void 0:Pe.getSnapshot())??Promise.resolve(null),[je,Ne]=await Promise.allSettled([pe,ue]),Re=je.status==="fulfilled"?je.value:null,Te=Ne.status==="fulfilled"?Ne.value:null;if(Re&&l(Re),Te&&i(Te),!Re&&!Te)m("Performance data is unavailable.");else{m(null);const Oe=Te&&Te.processes.length>0?Te.processes.reduce(g8,0):(Re==null?void 0:Re.cpuPercent)??0;f(Fe=>[...Fe.slice(-29),Oe])}g.current=!1,h(!1)},e[1]=w):w=e[1];const y=w;let j,k;e[2]!==t?(j=()=>{if(!t)return;y();const pe=window.setInterval(()=>void y(),n8);return()=>window.clearInterval(pe)},k=[t,y],e[2]=t,e[3]=j,e[4]=k):(j=e[3],k=e[4]),v.useEffect(j,k);let N,C,S,_,P,A,T,E,M,I,R,$,D,O,L,F,z,H,U;if(e[5]!==x||e[6]!==b||e[7]!==o||e[8]!==u||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const pe=[...(o==null?void 0:o.processes)??[]].sort(h8),ue=pe.length>0?pe.reduce(p8,0):(a==null?void 0:a.cpuPercent)??0,je=pe[0];let Ne;e[33]!==((xe=a==null?void 0:a.system)==null?void 0:xe.processes)?(Ne=((ge=a==null?void 0:a.system)==null?void 0:ge.processes)??[],e[33]=(ce=a==null?void 0:a.system)==null?void 0:ce.processes,e[34]=Ne):Ne=e[34],T=Ne;const Re=((we=a==null?void 0:a.system)==null?void 0:we.suspectedLeakCount)??0,Te=Re>0||ue>=80?"High":ue>=15?"Active":"Idle";let Pe;e[35]===Symbol.for("react.memo_cache_sentinel")?(Pe=async ot=>{try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[ot]})}),await new Promise(m8)}catch{}y()},e[35]=Pe):Pe=e[35],A=Pe;let Oe;e[36]!==b||e[37]!==o||e[38]!==d||e[39]!==a?(Oe=()=>{b(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=b,e[37]=o,e[38]=d,e[39]=a,e[40]=Oe):Oe=e[40];const Fe=Oe;P=Gn,D=t,O=s,_=Yn,I="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let ze;e[41]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(Xn,{children:"Power & activity monitor"}),e[41]=ze):ze=e[41];const Be=Te==="High"?"destructive":"secondary";let _e;e[42]!==Te||e[43]!==Be?(_e=r.jsxs("div",{className:"flex items-center gap-2",children:[ze,r.jsx(Me,{variant:Be,children:Te})]}),e[42]=Te,e[43]=Be,e[44]=_e):_e=e[44];let He;e[45]===Symbol.for("react.memo_cache_sentinel")?(He=r.jsx(Jn,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=He):He=e[45];let Ie;e[46]!==_e?(Ie=r.jsxs("div",{className:"min-w-0 flex-1",children:[_e,He]}),e[46]=_e,e[47]=Ie):Ie=e[47];let Ce;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>void y(),e[48]=Ce):Ce=e[48];const de=p&&"animate-spin";let Ee;e[49]!==de?(Ee=G(de),e[49]=de,e[50]=Ee):Ee=e[50];let Ae;e[51]!==Ee?(Ae=r.jsx(Qt,{"data-icon":"inline-start",className:Ee}),e[51]=Ee,e[52]=Ae):Ae=e[52];let Le;e[53]!==p||e[54]!==Ae?(Le=r.jsxs(J,{variant:"outline",size:"sm",onClick:Ce,disabled:p,children:[Ae,"Refresh"]}),e[53]=p,e[54]=Ae,e[55]=Le):Le=e[55];const ne=!a&&!o;let fe;e[56]!==x?(fe=x?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(Pn,{"data-icon":"inline-start"}),e[56]=x,e[57]=fe):fe=e[57];const Se=x?"Copied":"Copy data";let $e;e[58]!==Fe||e[59]!==ne||e[60]!==fe||e[61]!==Se?($e=r.jsxs(J,{variant:"outline",size:"sm",onClick:Fe,disabled:ne,children:[fe,Se]}),e[58]=Fe,e[59]=ne,e[60]=fe,e[61]=Se,e[62]=$e):$e=e[62];let Ue;e[63]!==Le||e[64]!==$e?(Ue=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Le,$e]}),e[63]=Le,e[64]=$e,e[65]=Ue):Ue=e[65],e[66]!==Ie||e[67]!==Ue?(R=r.jsx(ks,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Ie,Ue]})}),e[66]=Ie,e[67]=Ue,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(It,{}),e[69]=$):$=e[69],S=Cr,M="min-h-0 min-w-0 flex-1",H="flex flex-col gap-4 p-5",e[70]!==u?(U=u&&r.jsx(Ct,{variant:"destructive",children:r.jsx(_t,{children:u})}),e[70]=u,e[71]=U):U=e[71];let We;e[72]===Symbol.for("react.memo_cache_sentinel")?(We=r.jsx(sn,{children:"Current load"}),e[72]=We):We=e[72];const Xe=ue>=80&&"text-destructive";let Je;e[73]!==Xe?(Je=G("font-mono text-lg font-semibold tabular-nums",Xe),e[73]=Xe,e[74]=Je):Je=e[74];const De=r.jsxs(nn,{children:[We,r.jsx(on,{children:a8(ue,je,Re)}),r.jsx(Ng,{children:r.jsxs("span",{className:Je,children:[bo(ue)," CPU"]})})]});let qe;e[75]!==d?(qe=r.jsx(Jt,{children:r.jsx(c8,{values:d})}),e[75]=d,e[76]=qe):qe=e[76],e[77]!==De||e[78]!==qe?(E=r.jsxs(Xt,{size:"sm",children:[De,qe]}),e[77]=De,e[78]=qe,e[79]=E):E=e[79],C=Xt,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs(nn,{children:[r.jsx(sn,{children:"Processes"}),r.jsx(on,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],N=Jt,L=pe.length>0?pe.map(f8):a?r.jsx(y0,{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]=x,e[6]=b,e[7]=o,e[8]=u,e[9]=d,e[10]=s,e[11]=t,e[12]=p,e[13]=a,e[14]=N,e[15]=C,e[16]=S,e[17]=_,e[18]=P,e[19]=A,e[20]=T,e[21]=E,e[22]=M,e[23]=I,e[24]=R,e[25]=$,e[26]=D,e[27]=O,e[28]=L,e[29]=F,e[30]=z,e[31]=H,e[32]=U}else N=e[14],C=e[15],S=e[16],_=e[17],P=e[18],A=e[19],T=e[20],E=e[21],M=e[22],I=e[23],R=e[24],$=e[25],D=e[26],O=e[27],L=e[28],F=e[29],z=e[30],H=e[31],U=e[32];let W;e[81]!==N||e[82]!==L?(W=r.jsx(N,{children:L}),e[81]=N,e[82]=L,e[83]=W):W=e[83];let K;e[84]!==C||e[85]!==W||e[86]!==F||e[87]!==z?(K=r.jsxs(C,{size:F,children:[z,W]}),e[84]=C,e[85]=W,e[86]=F,e[87]=z,e[88]=K):K=e[88];let q;e[89]!==A||e[90]!==T?(q=T.length>0&&r.jsxs(Xt,{size:"sm",children:[r.jsxs(nn,{children:[r.jsx(sn,{children:"Agent processes"}),r.jsx(on,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Jt,{children:T.map((pe,ue)=>r.jsxs("div",{children:[ue>0&&r.jsx(It,{}),r.jsx(r8,{metric:pe,onKill:je=>void A(je)})]},pe.pid))})]}),e[89]=A,e[90]=T,e[91]=q):q=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(sn,{children:"Server activity"}),e[92]=Y):Y=e[92];const V=(a==null?void 0:a.sampleWindowSeconds)??10;let Q;e[93]!==V?(Q=r.jsxs(nn,{children:[Y,r.jsxs(on,{children:["File checks, streams, and agent work over the last ",V," seconds."]})]}),e[93]=V,e[94]=Q):Q=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 X;e[97]!==Z?(X=r.jsx(Jt,{children:r.jsx(ep,{metrics:Z,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Z,e[98]=X):X=e[98];let ee;e[99]!==Q||e[100]!==X?(ee=r.jsxs(Xt,{size:"sm",children:[Q,X]}),e[99]=Q,e[100]=X,e[101]=ee):ee=e[101];let oe;e[102]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsxs(nn,{children:[r.jsx(sn,{children:"API activity"}),r.jsx(on,{children:"Requests ranked by recent frequency and time."})]}),e[102]=oe):oe=e[102];let se;e[103]!==(a==null?void 0:a.requests)?(se=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=se):se=e[104];let re;e[105]!==se?(re=r.jsxs(Xt,{size:"sm",children:[oe,r.jsx(Jt,{children:r.jsx(ep,{metrics:se,emptyLabel:"No API requests in this sample."})})]}),e[105]=se,e[106]=re):re=e[106];let ie;e[107]!==ee||e[108]!==re?(ie=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[ee,re]}),e[107]=ee,e[108]=re,e[109]=ie):ie=e[109];let ae;e[110]!==a?(ae=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",bo(a.eventLoopPercent)," · heap ",Oi(a.memory.heapUsedMb)," · RSS ",Oi(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let te;e[112]!==E||e[113]!==K||e[114]!==q||e[115]!==ie||e[116]!==ae||e[117]!==H||e[118]!==U?(te=r.jsxs("div",{className:H,children:[U,E,K,q,ie,ae]}),e[112]=E,e[113]=K,e[114]=q,e[115]=ie,e[116]=ae,e[117]=H,e[118]=U,e[119]=te):te=e[119];let he;e[120]!==S||e[121]!==M||e[122]!==te?(he=r.jsx(S,{className:M,children:te}),e[120]=S,e[121]=M,e[122]=te,e[123]=he):he=e[123];let me;e[124]!==_||e[125]!==I||e[126]!==R||e[127]!==$||e[128]!==he?(me=r.jsxs(_,{className:I,children:[R,$,he]}),e[124]=_,e[125]=I,e[126]=R,e[127]=$,e[128]=he,e[129]=me):me=e[129];let le;return e[130]!==P||e[131]!==D||e[132]!==O||e[133]!==me?(le=r.jsx(P,{open:D,onOpenChange:O,children:me}),e[130]=P,e[131]=D,e[132]=O,e[133]=me,e[134]=le):le=e[134],le}function f8(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(It,{}),r.jsx(y0,{metric:n})]},n.pid)}function m8(n){return setTimeout(n,1e3)}function p8(n,e){return n+e.cpuPercent}function h8(n,e){return e.cpuPercent-n.cpuPercent}function g8(n,e){return n+e.cpuPercent}async function x8(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function b8(n){return`${n.title??`Pull request #${n.number}`}
|
|
115
|
+
`)[0];return i.length>qm?`${i.slice(0,qm)}...`:i}function G7(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=V7(s);if(o)return{index:t,text:o}}return null}function Y7(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(K7)){const c=l.getBoundingClientRect().top;if(c>e+Km)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(a0);return(i?i.getBoundingClientRect().bottom>e+Km:s+q7>e)?null:o}const X7=v.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=v.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const j=o.current;if(!j)return;let k=null;const N=()=>{k=null;const P=Y7(j);a(A=>P===null?null:(A==null?void 0:A.sessionId)===s.sessionId&&A.index===P?A:{sessionId:s.sessionId,index:P})},C=()=>{k===null&&(k=requestAnimationFrame(N))};a(null),j.addEventListener("scroll",C,{passive:!0});const S=new MutationObserver(C);S.observe(j,{childList:!0,subtree:!0});const _=new ResizeObserver(C);return _.observe(j),j.firstElementChild&&_.observe(j.firstElementChild),C(),()=>{j.removeEventListener("scroll",C),S.disconnect(),_.disconnect(),k!==null&&cancelAnimationFrame(k)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),v.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=G7(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 k=j.querySelector(`[data-turn-index="${f.index}"]`),N=(k==null?void 0:k.querySelector(a0))??k;if(!N)return;const C=j.scrollTop+N.getBoundingClientRect().top-j.getBoundingClientRect().top;j.scrollTo({top:Math.max(0,C),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(rh,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=f.index+1;let x;t[11]!==g?(x=r.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",g]}),t[11]=g,t[12]=x):x=t[12];let b;t[13]!==f.text?(b=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]=b):b=t[14];let w;t[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(hr,{"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]!==x||t[20]!==b?(y=r.jsxs(J,{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,x,b,w]}),t[16]=f.text,t[17]=m,t[18]=p,t[19]=x,t[20]=b,t[21]=y):y=t[21],y});function J7(n){const e=B.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(Vm,{}),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(Tx,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(Vm,{}),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 Vm(){const n=B.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 Q7=v.memo(function(){const e=B.c(9),t=yd();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=u_(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(Z7,-1);return r.jsx("div",{children:f.blocks.map((p,h)=>r.jsx(J7,{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 Z7(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const eE=3,$i=["w-6","w-4","w-2.5","w-2"],tE=$i[$i.length-1];function nE(n){return n===null||n<0?tE:$i[Math.min(n,$i.length-1)]}function sE(n){return n.type==="text"}function xl(n){return n.replace(/\s+/g," ").trim()}function oE(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(sE).map(l=>l.text).join(" "):"",{text:t}=Q1(e),{remainingText:s}=ar(t),{remainingText:o}=J1(s),i=xl(md(o));if(i)return i;for(const l of n.contentBlocks){if(l.kind!=="task_notification")continue;const c=ar(l.content).notifications.map(d=>d.summary).find(Boolean);if(c)return xl(c)}return n.assistantText.map(xl).find(Boolean)||"Untitled turn"}const rE=v.memo(function(e){const t=B.c(21),{turns:s,scrollContainerRef:o,onJumpToTurn:i}=e,[a,l]=v.useState(null),c=v.useRef(null),d=s.length;let f;if(t[0]!==s){const j=new Map;f=s.map(k=>{const N=j.get(k.id)??0;return j.set(k.id,N+1),N===0?k.id:`${k.id}#${N}`}),t[0]=s,t[1]=f}else f=t[1];const u=f;let m;t[2]!==o?(m=()=>{const j=o.current,k=c.current;if(!j||!k)return;let N=null;const C=()=>{N=null;const _=j.getBoundingClientRect().top+j.clientHeight/2;let P=null;for(const A of j.querySelectorAll("[data-turn-index]")){const T=A.getBoundingClientRect();if(T.top<=_&&T.bottom>=_){P=Number(A.dataset.turnIndex);break}}for(const A of k.querySelectorAll("[data-tick-index]"))A.dataset.current=String(Number(A.dataset.tickIndex)===P)},S=()=>{N===null&&(N=requestAnimationFrame(C))};return C(),j.addEventListener("scroll",S,{passive:!0}),()=>{j.removeEventListener("scroll",S),N!==null&&cancelAnimationFrame(N)}},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],v.useEffect(m,p);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const k=j.key==="ArrowDown"?1:j.key==="ArrowUp"?-1:0,N=c.current;if(!N)return;const C=[...N.querySelectorAll("[data-tick-index]")];if(C.length===0)return;let S;if(k!==0){const _=C.indexOf(document.activeElement);S=C[Math.min(Math.max(_+k,0),C.length-1)]}else j.key==="Home"?S=C[0]:j.key==="End"&&(S=C[C.length-1]);S&&(j.preventDefault(),S.focus())},t[7]=h):h=t[7];const g=h;if(d<eE)return null;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(null),t[8]=x):x=t[8];let b;t[9]===Symbol.for("react.memo_cache_sentinel")?(b=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]=b):b=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=(k,N)=>{const C=oE(k);return r.jsx(J,{type:"button",variant:"ghost","data-tick-index":N,onMouseEnter:()=>l(N),onFocus:()=>l(N),onClick:()=>i(N),"aria-label":`Turn ${N+1}: ${C}`,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",nE(a===null?null:Math.abs(N-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:N+1}),r.jsx("span",{className:"line-clamp-2 align-middle",children:C})]})},u[N])},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:x,onKeyDown:g,className:b,children:w}),t[19]=w,t[20]=y):y=t[20],y});class iE extends v.Component{constructor(t){super(t);Hr(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(Ct,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(jn,{}),r.jsx(Dt,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(_t,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(bs,{className:"static col-start-2 mt-2",children:r.jsxs(J,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Qt,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const Gm="find-in-session-highlight",bl="find-in-session-active";function aE(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 lE=v.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=v.useState(!1),[l,c]=v.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[f,u]=v.useState(d),[m,p]=v.useState(-1),h=v.useRef(null);let g;s[1]!==o?(g=()=>{const se=o.current;if(!se)return;se.querySelectorAll(`mark.${Gm}`).forEach(cE)},s[1]=o,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==o?(b=se=>{if(x(),!se||!o.current){u([]),p(-1);return}const re=o.current,ie=aE(re),ae=se.toLowerCase(),te=[];for(const he of ie){const me=he.nodeValue||"",le=me.toLowerCase();let xe=0;const ge=[];for(;;){const ue=le.indexOf(ae,xe);if(ue===-1)break;ge.push(ue),xe=ue+1}if(ge.length===0)continue;const ce=he.parentNode;if(!ce)continue;const we=document.createDocumentFragment();let pe=0;for(const ue of ge){ue>pe&&we.appendChild(document.createTextNode(me.slice(pe,ue)));const je=document.createElement("mark");je.className=Gm,je.textContent=me.slice(ue,ue+se.length),we.appendChild(je),te.push(je),pe=ue+se.length}pe<me.length&&we.appendChild(document.createTextNode(me.slice(pe))),ce.replaceChild(we,he)}u(te),te.length>0?(p(0),te[0].classList.add(bl),te[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=b):b=s[5];const w=b;let y;s[6]!==m||s[7]!==f?(y=se=>{if(f.length===0)return;m>=0&&m<f.length&&f[m].classList.remove(bl);const re=(se%f.length+f.length)%f.length;f[re].classList.add(bl),f[re].scrollIntoView({block:"center",behavior:"smooth"}),p(re)},s[6]=m,s[7]=f,s[8]=y):y=s[8];const j=y;let k;s[9]!==x?(k=()=>{a(!1),c(""),x(),u([]),p(-1)},s[9]=x,s[10]=k):k=s[10];const N=k;let C,S;s[11]!==N||s[12]!==i?(C=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var se;return(se=h.current)==null?void 0:se.focus()})},close:N,isOpen:i}),S=[N,i],s[11]=N,s[12]=i,s[13]=C,s[14]=S):(C=s[13],S=s[14]),v.useImperativeHandle(t,C,S);let _,P;s[15]!==w||s[16]!==l?(_=()=>{const se=setTimeout(()=>w(l),150);return()=>clearTimeout(se)},P=[l,w],s[15]=w,s[16]=l,s[17]=_,s[18]=P):(_=s[17],P=s[18]),v.useEffect(_,P);let A,T;s[19]!==x?(A=()=>()=>x(),T=[x],s[19]=x,s[20]=A,s[21]=T):(A=s[20],T=s[21]),v.useEffect(A,T);let E;s[22]!==m||s[23]!==j||s[24]!==N?(E=se=>{se.key==="Escape"?(se.preventDefault(),se.stopPropagation(),N()):se.key==="Enter"&&(se.preventDefault(),se.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=N,s[25]=E):E=s[25];const M=E;if(!i)return null;let I;s[26]===Symbol.for("react.memo_cache_sentinel")?(I=se=>c(se.target.value),s[26]=I):I=s[26];let R;s[27]!==M||s[28]!==l?(R=r.jsx(es,{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 $=l?f.length>0?`${m+1}/${f.length}`:"0/0":"";let D;s[30]!==$?(D=r.jsx(wn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:$})}),s[30]=$,s[31]=D):D=s[31];let O;s[32]!==R||s[33]!==D?(O=r.jsxs(Zn,{className:"w-64",children:[R,D]}),s[32]=R,s[33]=D,s[34]=O):O=s[34];let L;s[35]!==m||s[36]!==j?(L=()=>j(m-1),s[35]=m,s[36]=j,s[37]=L):L=s[37];const F=f.length===0,z=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let H;s[38]!==z?(H=G("text-muted-foreground",z),s[38]=z,s[39]=H):H=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(hr,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let W;s[41]!==L||s[42]!==F||s[43]!==H?(W=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:L,disabled:F,className:H,"aria-label":"Previous match",children:U}),s[41]=L,s[42]=F,s[43]=H,s[44]=W):W=s[44];let K;s[45]!==m||s[46]!==j?(K=()=>j(m+1),s[45]=m,s[46]=j,s[47]=K):K=s[47];const q=f.length===0,Y=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let V;s[48]!==Y?(V=G("text-muted-foreground",Y),s[48]=Y,s[49]=V):V=s[49];let Q;s[50]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(st,{"data-icon":"inline-start"}),s[50]=Q):Q=s[50];let Z;s[51]!==K||s[52]!==q||s[53]!==V?(Z=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:K,disabled:q,className:V,"aria-label":"Next match",children:Q}),s[51]=K,s[52]=q,s[53]=V,s[54]=Z):Z=s[54];let X;s[55]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(jt,{"data-icon":"inline-start"}),s[55]=X):X=s[55];let ee;s[56]!==N?(ee=r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:N,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:X}),s[56]=N,s[57]=ee):ee=s[57];let oe;return s[58]!==O||s[59]!==W||s[60]!==Z||s[61]!==ee?(oe=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:[O,W,Z,ee]}),s[58]=O,s[59]=W,s[60]=Z,s[61]=ee,s[62]=oe):oe=s[62],oe});function cE(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const yI=["General","View","Tools"],Ea=[{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}}],l0="cogpit-keybindings";let Ts=null;function c0(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function fr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function dE(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Ad(){if(Ts)return Ts;try{const n=localStorage.getItem(l0);if(!n)return Ts={};const e=JSON.parse(n);if(!e||typeof e!="object")return Ts={};const t={};for(const s of Ea){const o=e[s.command];dE(o)&&(t[s.command]=o)}return Ts=t}catch{return Ts={}}}function Rd(n){Ts=n;try{localStorage.setItem(l0,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Ir(n){const e=Ea.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Ad()[n]??e.defaultShortcut}function wI(){return Object.fromEntries(Ea.map(n=>[n.command,Ir(n.command)]))}function jI(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:fr(e.key)};Rd({...Ad(),[n]:t})}function SI(n){const e={...Ad()};delete e[n],Rd(e)}function kI(){Rd({})}function NI(n){return{key:fr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function d0(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function yt(n,e){const t=Ir(n);return"doubleTapModifier"in t||fr(e.key)!==fr(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 Ys(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 uE(n){const e=c0();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Ys(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Ys(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Ys(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Ys(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Ys(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Ys(n.key)].filter(Boolean).join("+")}function vl(n){return uE(Ir(n))}function Ym(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${fr(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 CI(n,e){const t=new Set(Ym(n));return Ea.find(s=>s.command!==e&&Ym(Ir(s.command)).some(o=>t.has(o)))??null}function Xm(n){return"doubleTapModifier"in Ir(n)?c0()?"Meta":"Control":null}const fE=["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"],mE="device.cycle";function pE(n){const e=fE.findIndex(t=>yt(t,n));return e===-1?null:e+1}function hE(n){return yt(mE,n)}const ic="cogpit:find-in-conversation",Pa=v.memo(function(e){const t=B.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}=Rt(),{session:h}=it(),{chat:g,scroll:x}=wr(),{searchQuery:b}=u,{pendingMessages:w}=g,{chatScrollRef:y,scrollEndRef:j,handleScroll:k,canScrollDown:N,scrollToBottomInstant:C,initialScrollDone:S}=x,_=v.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var ue;return(ue=_.current)==null?void 0:ue.open()},t[0]=P):P=t[0];const A=P;let T,E;t[1]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const ue=function(Ne){yt("findInConversation",Ne)&&(Ne.preventDefault(),A())};return window.addEventListener("keydown",ue),window.addEventListener(ic,A),()=>{window.removeEventListener("keydown",ue),window.removeEventListener(ic,A)}},E=[A],t[1]=T,t[2]=E):(T=t[1],E=t[2]),v.useEffect(T,E);let M,I;t[3]!==p||t[4]!==f||t[5]!==s?(M=()=>{!p||!f||requestAnimationFrame(()=>{var ue;return(ue=s.current)==null?void 0:ue.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]),v.useEffect(M,I);let R;t[8]!==m?(R=ue=>m({type:"JUMP_TO_TURN",index:ue}),t[8]=m,t[9]=R):R=t[9];const $=R;let D;t[10]!==m||t[11]!==d?(D=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=D):D=t[12];const O=D,L=h,F=L.turns.length>0||w.length===0,z=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let H;t[13]!==z?(H=G("relative bg-background",z),t[13]=z,t[14]=H):H=t[14];let U;t[15]!==O||t[16]!==m||t[17]!==p||t[18]!==f||t[19]!==s||t[20]!==b?(U=p&&f&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(Zn,{className:"h-9 flex-1",children:[r.jsx(es,{ref:s,value:b,onChange:ue=>m({type:"SET_SEARCH_QUERY",value:ue.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(wn,{align:"inline-start",children:r.jsx(bn,{})})]}),r.jsx(J,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:r.jsx(jt,{"data-icon":"inline-start"})})]}),t[15]=O,t[16]=m,t[17]=p,t[18]=f,t[19]=s,t[20]=b,t[21]=U):U=t[21];const W=p?"flex-1 min-h-0":"h-full";let K;t[22]!==W?(K=G("relative",W),t[22]=W,t[23]=K):K=t[23];let q;t[24]!==y?(q=r.jsx(lE,{ref:_,scrollContainerRef:y}),t[24]=y,t[25]=q):q=t[25];let Y;t[26]!==y||t[27]!==L.turns||t[28]!==$||t[29]!==p?(Y=!p&&r.jsx(rE,{turns:L.turns,scrollContainerRef:y,onJumpToTurn:$}),t[26]=y,t[27]=L.turns,t[28]=$,t[29]=p,t[30]=Y):Y=t[30];let V;t[31]!==y||t[32]!==L?(V=r.jsx(X7,{session:L,scrollContainerRef:y}),t[31]=y,t[32]=L,t[33]=V):V=t[33];const Q=p&&"mobile-scroll";let Z;t[34]!==Q?(Z=G("h-full overflow-x-hidden overflow-y-auto bg-background",Q),t[34]=Q,t[35]=Z):Z=t[35];let X;t[36]!==o||t[37]!==p?(X=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]=X):X=t[38];let ee;t[39]!==y||t[40]!==i||t[41]!==S||t[42]!==a||t[43]!==l||t[44]!==F?(ee=F&&r.jsx(W7,{chatScrollRef:y,hasMore:i,isLoadingOlder:a,pagingEnabled:S,onLoadMore:l}),t[39]=y,t[40]=i,t[41]=S,t[42]=a,t[43]=l,t[44]=F,t[45]=ee):ee=t[45];let oe;t[46]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsx(Q7,{}),t[46]=oe):oe=t[46];let se;if(t[47]!==L.turns.length||t[48]!==w){let ue;t[50]!==L.turns.length?(ue=(je,Ne)=>r.jsx(ex,{message:je,turnNumber:L.turns.length+1+Ne},Ne),t[50]=L.turns.length,t[51]=ue):ue=t[51],se=w.map(ue),t[47]=L.turns.length,t[48]=w,t[49]=se}else se=t[49];let re;t[52]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(o7,{}),t[52]=re):re=t[52];let ie;t[53]!==j?(ie=r.jsx("div",{ref:j}),t[53]=j,t[54]=ie):ie=t[54];let ae;t[55]!==ee||t[56]!==se||t[57]!==ie?(ae=r.jsxs(iE,{fallbackMessage:"Failed to render conversation timeline",children:[ee,oe,se,re,ie]}),t[55]=ee,t[56]=se,t[57]=ie,t[58]=ae):ae=t[58];let te;t[59]!==X||t[60]!==ae?(te=r.jsx("div",{className:X,children:ae}),t[59]=X,t[60]=ae,t[61]=te):te=t[61];let he;t[62]!==y||t[63]!==k||t[64]!==Z||t[65]!==te?(he=r.jsx("div",{ref:y,onScroll:k,className:Z,children:te}),t[62]=y,t[63]=k,t[64]=Z,t[65]=te,t[66]=he):he=t[66];const me=N?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",le=p?"right-3 bottom-3":"right-5 bottom-5";let xe;t[67]!==me||t[68]!==le?(xe=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",me,le),t[67]=me,t[68]=le,t[69]=xe):xe=t[69];let ge;t[70]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsx(Fv,{"data-icon":"inline-start"}),t[70]=ge):ge=t[70];let ce;t[71]!==C||t[72]!==xe?(ce=r.jsx(J,{size:"icon",className:xe,onClick:C,"aria-label":"Scroll to bottom",children:ge}),t[71]=C,t[72]=xe,t[73]=ce):ce=t[73];let we;t[74]!==K||t[75]!==q||t[76]!==Y||t[77]!==V||t[78]!==he||t[79]!==ce?(we=r.jsxs("div",{className:K,children:[q,Y,V,he,ce]}),t[74]=K,t[75]=q,t[76]=Y,t[77]=V,t[78]=he,t[79]=ce,t[80]=we):we=t[80];let pe;return t[81]!==H||t[82]!==U||t[83]!==we?(pe=r.jsxs("div",{className:H,children:[U,we]}),t[81]=H,t[82]=U,t[83]=we,t[84]=pe):pe=t[84],pe}),ac="cogpit-devices-changed",u0="cogpit:devices-changed";function f0(n){typeof n.connectionRevision=="number"&&gw(n.id,n.connectionRevision)}function m0(n,e,t=!1){window.dispatchEvent(new CustomEvent(ac,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(u0,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function Jm(n){f0(n),m0(n.id,n.connectionRevision)}function yl(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function Xs(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function p0(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function gE(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function Aa(){const[n,e]=v.useState([]),[t,s]=v.useState(!0),[o,i]=v.useState(()=>ht()),a=v.useRef(0),l=v.useCallback(async()=>{const h=++a.current;try{const g=await rs("/api/hub/devices");if(!g.ok)return;const x=await Xs(g);if(h!==a.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of b)f0(w);e(b)}catch{}finally{h===a.current&&s(!1)}},[]);v.useEffect(()=>{l()},[l]),v.useEffect(()=>{const h=()=>i(ht()),g=()=>void l(),x=y=>{if(y.key===u0){try{const j=JSON.parse(y.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&ht()===j.deviceId&&hs(wt)}catch{}l()}},b=()=>{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(ac,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-identity-changed",b),window.addEventListener("cogpit-auth-required",w),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(ac,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-identity-changed",b),window.removeEventListener("cogpit-auth-required",w)}},[l]);const c=v.useMemo(()=>o===wt?void 0:n.find(h=>h.id===o),[n,o]),d=v.useCallback(async(h,g,x,b)=>{try{const w=await rs("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:b})}),y=await Xs(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=v.useCallback(async h=>{try{const g=await rs("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await Xs(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return Jm(b),{ok:!0,device:b}}return{ok:!1,code:(x==null?void 0:x.code)??"ERROR",error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),u=v.useCallback(async(h,g)=>{try{const x=await rs(yl(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await Xs(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return Jm(w),{ok:!0,device:w}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=v.useCallback(async h=>{try{const g=await rs(yl(h),{method:"DELETE"});if(g.ok)return ht()===h&&hs(wt),m0(h,void 0,!0),{ok:!0};const x=await Xs(g);return{ok:!1,error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),p=v.useCallback(async h=>{try{const g=await rs(yl(h,"/test"),{method:"POST"});return await Xs(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 xE=v.lazy(()=>Ke(()=>import("./CommandPaletteHost-Bq0_FFr0.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),bE=v.lazy(()=>Ke(()=>import("./index-C_pb6rZe.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),vE=v.lazy(()=>Ke(()=>Promise.resolve().then(()=>LE),void 0).then(n=>({default:n.DevicesDialog}))),yE=v.lazy(()=>Ke(()=>import("./KeyboardShortcutsDialog-YDYAOpa5.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),wE=v.lazy(()=>Ke(()=>import("./ProjectSwitcherModal-CxbGrX7A.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),jE=v.lazy(()=>Ke(()=>import("./ThemeSelectorModal-BG_Jah0i.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal}))),SE=v.lazy(()=>Ke(()=>import("./WorktreePanel-gR-fCesa.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function kE(n){const e=B.c(125),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Rt(),{session:c,sessionSource:d}=it(),{devices:f,activeDeviceId:u}=Aa(),[m,p]=v.useState(null),[h,g]=v.useState(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=ut("manageDevices"),e[0]=x):x=e[0];const b=x;let w;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(w=i.pendingCwd??(i.pendingDirName?gn(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,k=m??h;let N,C;e[4]!==m?(N=()=>{m&&g(m)},C=[m],e[4]=m,e[5]=N,e[6]=C):(N=e[5],C=e[6]),v.useEffect(N,C);const S=o.onKeyboardShortcutsOpenChange;let _,P;e[7]!==S?(_=()=>{const Se=function(Ue){yt("keyboardShortcuts",Ue)&&(d0(document.activeElement)||(Ue.preventDefault(),S(!0)))};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},P=[S],e[7]=S,e[8]=_,e[9]=P):(_=e[8],P=e[9]),v.useEffect(_,P);const A=u===wt;let T;e[10]!==A?(T={id:wt,name:"This machine",isLocal:!0,isActive:A},e[10]=A,e[11]=T):T=e[11];let E;if(e[12]!==u||e[13]!==f||e[14]!==T){let Se;e[16]!==u?(Se=$e=>({id:$e.id,name:$e.name,isLocal:!1,isActive:$e.id===u}),e[16]=u,e[17]=Se):Se=e[17],E=[T,...f.map(Se)],e[12]=u,e[13]=f,e[14]=T,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 Se=(d==null?void 0:d.agentKind)??St((d==null?void 0:d.dirName)??null);vr(yh(Se,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,$=NE,D=s.supportsWorktrees&&t.panels.showWorktrees;let O;e[22]!==j||e[23]!==t.actions||e[24]!==t.panels?(O=Se=>{j&&t.actions.handleDashboardSelect(j,`${Se}.jsonl`),t.panels.setShowWorktrees(!1)},e[22]=j,e[23]=t.actions,e[24]=t.panels,e[25]=O):O=e[25];let L;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]!==D||e[32]!==O?(L=r.jsx(v.Suspense,{fallback:null,children:r.jsx(SE,{open:D,onOpenChange:t.panels.setShowWorktrees,worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:j,onRefetch:s.worktrees.refetch,onOpenSession:O})}),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]=D,e[32]=O,e[33]=L):L=e[33];const F=o.processPanel,z=o.workflowsPanel,H=o.undoDialog,U=o.branchModal,W=a.claudeDir??"";let K;e[34]!==a.handleCloseConfigDialog||e[35]!==a.handleConfigSaved||e[36]!==a.showConfigDialog||e[37]!==W?(K=r.jsx(v.Suspense,{fallback:null,children:r.jsx(bE,{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]=K):K=e[38];const q=(d==null?void 0:d.dirName)??i.pendingDirName??null,Y=(c==null?void 0:c.cwd)??i.pendingCwd??null;let V;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?(V=r.jsx(v.Suspense,{fallback:null,children:r.jsx(wE,{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]=V):V=e[46];let Q;e[47]!==t.panels.handleCloseThemeSelector||e[48]!==t.panels.showThemeSelector||e[49]!==l.setPreview||e[50]!==l.setTheme||e[51]!==l.theme?(Q=r.jsx(v.Suspense,{fallback:null,children:r.jsx(jE,{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]=Q):Q=e[52];const Z=o.commandPaletteOpen,X=o.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,oe=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,re=t.actions.handleDashboardSelect,ie=t.panels.handleToggleSidebar,ae=t.panels.handleToggleStats,te=t.panels.handleToggleFileChanges,he=t.panels.handleToggleWorktrees,me=t.panels.handleToggleMission,le=c?t.handlers.handleDuplicateSession:void 0,xe=c?R:void 0,ge=c?$:void 0,ce=ut("killAny")?o.onKillAll:void 0,we=ut("configWrite")?t.panels.handleToggleConfig:void 0,pe=a.openConfigDialog;let ue;e[53]!==S?(ue=()=>S(!0),e[53]=S,e[54]=ue):ue=e[54];const je=s.currentCwd?s.onTogglePreview:void 0,Ne=ut("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,Re=t.panels.handleToggleThemeSelector,Te=s.onOpenTerminal,Pe=o.onFocusComposer,Oe=o.onExpandAll,Fe=o.onExpandToolPayloads,ze=o.onCollapseAll,Be=!!(c||i.pendingDirName);let _e;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=ut("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]=_e):_e=e[60];const He=!!c;let Ie;e[61]!==s.hasFileChanges?(Ie=ut("hostFiles")&&s.hasFileChanges,e[61]=s.hasFileChanges,e[62]=Ie):Ie=e[62];const Ce=i.mainView==="config",de=i.mainView==="mission",Ee=(c==null?void 0:c.cwd)??y??null;let Ae;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]!==le||e[92]!==xe||e[93]!==ge||e[94]!==ce||e[95]!==we||e[96]!==ue||e[97]!==je||e[98]!==Ne||e[99]!==Be||e[100]!==_e||e[101]!==He||e[102]!==Ie||e[103]!==Ce||e[104]!==de||e[105]!==Ee?(Ae=r.jsx(v.Suspense,{fallback:null,children:r.jsx(xE,{open:Z,onOpenChange:X,onGoHome:ee,onNewSession:oe,onOpenProject:se,onOpenSession:re,onToggleSidebar:ie,onToggleStats:ae,onToggleFileChanges:te,onToggleWorktrees:he,onToggleMissionControl:me,onDuplicateSession:le,onCopyResumeCommand:xe,onFindInConversation:ge,onKillAll:ce,onOpenConfig:we,onOpenSettings:pe,onOpenKeyboardShortcuts:ue,onTogglePreview:je,onToggleProjectFiles:Ne,onOpenTheme:Re,onOpenTerminal:Te,onOpenDevices:b?p:void 0,onSwitchDevice:hs,devices:M,onFocusComposer:Pe,onExpandAll:Oe,onExpandToolPayloads:Fe,onCollapseAll:ze,canFocusComposer:Be,canOpenTerminal:_e,hasSession:He,hasFileChanges:Ie,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:t.panels.showStats,showProjectFiles:s.showProjectFiles,showFileChanges:t.panels.showFileChanges,showWorktrees:t.panels.showWorktrees,showConfig:Ce,showMission:de,currentProjectDirName:j,projectCwd:Ee,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]=le,e[92]=xe,e[93]=ge,e[94]=ce,e[95]=we,e[96]=ue,e[97]=je,e[98]=Ne,e[99]=Be,e[100]=_e,e[101]=He,e[102]=Ie,e[103]=Ce,e[104]=de,e[105]=Ee,e[106]=Ae):Ae=e[106];let Le;e[107]!==o.keyboardShortcutsOpen||e[108]!==S?(Le=r.jsx(v.Suspense,{fallback:null,children:r.jsx(yE,{open:o.keyboardShortcutsOpen,onOpenChange:S})}),e[107]=o.keyboardShortcutsOpen,e[108]=S,e[109]=Le):Le=e[109];let ne;e[110]!==m||e[111]!==k?(ne=b&&k!==null&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(vE,{open:m!==null,initialMode:k,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[110]=m,e[111]=k,e[112]=ne):ne=e[112];let fe;return e[113]!==o.branchModal||e[114]!==o.processPanel||e[115]!==o.undoDialog||e[116]!==o.workflowsPanel||e[117]!==L||e[118]!==K||e[119]!==V||e[120]!==Q||e[121]!==Ae||e[122]!==Le||e[123]!==ne?(fe=r.jsxs(r.Fragment,{children:[L,F,z,H,U,K,V,Q,Ae,Le,ne]}),e[113]=o.branchModal,e[114]=o.processPanel,e[115]=o.undoDialog,e[116]=o.workflowsPanel,e[117]=L,e[118]=K,e[119]=V,e[120]=Q,e[121]=Ae,e[122]=Le,e[123]=ne,e[124]=fe):fe=e[124],fe}function NE(){window.dispatchEvent(new Event(ic))}function wl(n){const e=B.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(Pt,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(At,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(Et,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const CE="2.1.2",h0={version:CE},_E=h0.version,TE=19384,EE=443,PE=450,AE=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),RE=`${AE?"⌘⇧":"Ctrl+Shift+"}1–9`,ME=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),IE=new Set(["ACCOUNT_DISABLED"]);function Bo(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 g0(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 x0={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function $E(n){const e=B.c(10),{tone:t}=n,s=x0[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(Un,{"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(jn,{"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(Qt,{"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(zs,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const OE={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function DE({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=v.useState(!1),[c,d]=v.useState(n.name),[f,u]=v.useState(!1),[m,p]=v.useState(n.username??""),[h,g]=v.useState(""),[x,b]=v.useState(null),[w,y]=v.useState(!1),[j,k]=v.useState(null);v.useEffect(()=>{d(n.name)},[n.name]),v.useEffect(()=>{p(n.username??"")},[n.username]);const N=p0(n),C=N!==void 0&&N!==e,S=gE(n)==="team";async function _(){const A=c.trim();if(!A||A===n.name){l(!1),d(n.name);return}k("rename"),await t(n.id,A),k(null),l(!1)}async function P(){const A=m.trim(),T=n.username??"",E=A!==T,M=h.length>0;if(!E&&!M){u(!1),g(""),b(null);return}if(n.auth==="none"&&!M){b("Enter a password when adding an account to an unauthenticated device.");return}const I={};E&&(I.username=A||null),M&&(I.password=h),k("credentials"),b(null);const R=await s(n.id,I);if(k(null),!R.ok){b(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",OE[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Ot,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:A=>d(A.target.value),onKeyDown:A=>{A.key==="Enter"&&_(),A.key==="Escape"&&(l(!1),d(n.name))},onBlur:()=>void _(),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}),N&&r.jsxs("span",{className:G("shrink-0 font-mono text-xs",C?"text-warning":"text-muted-foreground"),title:C?`Device runs v${N}; hub runs v${e}`:void 0,children:["v",N,C&&" ≠ hub"]}),n.auth==="none"&&r.jsx(Me,{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]}):S?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(J,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:j==="test",onClick:async()=>{k("test"),await i(n.id),k(null)},children:r.jsx(Qt,{"data-icon":"inline-start",className:G(j==="test"&&"animate-spin")})}),r.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{u(A=>!A),p(n.username??""),g(""),b(null)},children:r.jsx(Bv,{"data-icon":"inline-start"})}),r.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Ls,{"data-icon":"inline-start"})}),r.jsxs(Fc,{open:w,onOpenChange:A=>{j!=="remove"&&y(A)},children:[r.jsx(BS,{render:r.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(qi,{"data-icon":"inline-start"})}),r.jsxs(Bc,{size:"sm",children:[r.jsxs(Uc,{children:[r.jsxs(Hc,{children:["Remove ",n.name,"?"]}),r.jsx(Kc,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(Wc,{children:[r.jsx(Vc,{disabled:j==="remove",children:"Cancel"}),r.jsxs(qc,{variant:"destructive",disabled:j==="remove",onClick:async()=>{k("remove");try{await o(n.id)}finally{k(null)}},children:[j==="remove"&&r.jsx(rt,{"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(gt,{children:[r.jsxs(xt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Ot,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:A=>p(A.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(gt,{children:[r.jsxs(xt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Ot,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:A=>g(A.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."}),x&&r.jsx(us,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(J,{variant:"outline",size:"sm",onClick:()=>{u(!1),p(n.username??""),g(""),b(null)},children:"Cancel"}),r.jsx(J,{size:"sm",disabled:j==="credentials",onClick:()=>void P(),children:j==="credentials"?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function b0(n){var Xe,Je;const e=B.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}=Aa(),[p,h]=v.useState(""),[g,x]=v.useState(""),[b,w]=v.useState(""),[y,j]=v.useState(""),[k,N]=v.useState(!1),[C,S]=v.useState(!1),[_,P]=v.useState(null),[A,T]=v.useState(!1),[E,M]=v.useState(null),I=v.useRef(null),R=v.useRef(0);let $,D;e[0]!==s||e[1]!==t?($=()=>{t&&(h(""),x(""),w(""),j(""),N(!1),S(!1),P(null),M(null),s==="add"&&requestAnimationFrame(()=>{var De;return(De=I.current)==null?void 0:De.focus()}))},D=[t,s],e[0]=s,e[1]=t,e[2]=$,e[3]=D):($=e[2],D=e[3]),v.useEffect($,D);let O;e[4]!==k||e[5]!==g||e[6]!==c?(O=async()=>{const{host:De,port:qe,tls:ot}=Bo(g);if(!De){P(null),S(!1);return}const lt=R.current=R.current+1;S(!0);const bt=await c(De,qe,k,ot);lt===R.current&&(P({...g0(bt,De,qe??(ot?EE:TE)),hello:bt.ok?bt.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=c,e[7]=O):O=e[7];const L=O;let F,z;e[8]!==g||e[9]!==t||e[10]!==L?(F=()=>{if(!t)return;if(!Bo(g).host){P(null),S(!1);return}const De=window.setTimeout(()=>void L(),PE);return()=>window.clearTimeout(De)},z=[t,g,L],e[8]=g,e[9]=t,e[10]=L,e[11]=F,e[12]=z):(F=e[11],z=e[12]),v.useEffect(F,z);const H=((Xe=_==null?void 0:_.hello)==null?void 0:Xe.edition)==="team",U=H&&((Je=_==null?void 0:_.hello)==null?void 0:Je.needsBootstrap)===!0,W=H||!k;let K;e:{if(A){K=!1;break e}if(!Bo(g).host){K=!1;break e}if(C||!_){K=!1;break e}if(U){K=!1;break e}if(W&&!y){K=!1;break e}if(H&&!b.trim()){K=!1;break e}if((_==null?void 0:_.tone)==="error"){K=!1;break e}K=!0}const q=K;let Y;e[13]!==d||e[14]!==k||e[15]!==W||e[16]!==g||e[17]!==p||e[18]!==o||e[19]!==y||e[20]!==H||e[21]!==b?(Y=async function(){const{host:qe,port:ot,tls:lt}=Bo(g);if(!qe)return;T(!0),M(null);const bt=await d({name:p.trim()||void 0,host:qe,port:ot,tls:lt,username:H?b.trim():void 0,password:W&&y||void 0,allowLocalTunnel:k});if(T(!1),bt.ok){o(),hs(bt.device.id);return}M({field:IE.has(bt.code)?"username":ME.has(bt.code)?"password":"host",message:bt.error})},e[13]=d,e[14]=k,e[15]=W,e[16]=g,e[17]=p,e[18]=o,e[19]=y,e[20]=H,e[21]=b,e[22]=Y):Y=e[22];const V=Y;let Q;e[23]!==f?(Q=async(De,qe)=>{await f(De,{name:qe})},e[23]=f,e[24]=Q):Q=e[24];const Z=Q;let X;e[25]!==u?(X=async De=>{await u(De)},e[25]=u,e[26]=X):X=e[26];const ee=X;let oe;e[27]!==l||e[28]!==m?(oe=async De=>{await m(De),await l()},e[27]=l,e[28]=m,e[29]=oe):oe=e[29];const se=oe;let re;e[30]!==o?(re=De=>{De||o()},e[30]=o,e[31]=re):re=e[31];let ie;e[32]!==i?(ie=De=>{De||i==null||i()},e[32]=i,e[33]=ie):ie=e[33];let ae;e[34]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsxs(ks,{children:[r.jsx(Xn,{children:"Devices"}),r.jsxs(Jn,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",RE," jumps between devices."]})]}),e[34]=ae):ae=e[34];let te;e[35]!==a||e[36]!==ee||e[37]!==Z||e[38]!==se||e[39]!==f?(te=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(De=>r.jsx(DE,{device:De,hubVersion:_E,onRename:Z,onCredentials:f,onRemove:ee,onTest:se},De.id))}),e[35]=a,e[36]=ee,e[37]=Z,e[38]=se,e[39]=f,e[40]=te):te=e[40];let he;e[41]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Tn,{"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]=he):he=e[41];const me=(E==null?void 0:E.field)==="host";let le,xe;e[42]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(xt,{htmlFor:"device-host",children:"Host"}),xe=r.jsx(mo,{children:"Enter a local address or an HTTPS URL."}),e[42]=le,e[43]=xe):(le=e[42],xe=e[43]);let ge;e[44]===Symbol.for("react.memo_cache_sentinel")?(ge=De=>{R.current=R.current+1,x(De.target.value),w(""),P(null),M(null)},e[44]=ge):ge=e[44];let ce;e[45]!==L?(ce=()=>void L(),e[45]=L,e[46]=ce):ce=e[46];let we;e[47]!==g||e[48]!==ce?(we=r.jsx(Ot,{id:"device-host",ref:I,value:g,onChange:ge,onBlur:ce,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[47]=g,e[48]=ce,e[49]=we):we=e[49];let pe;e[50]!==C?(pe=C&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[50]=C,e[51]=pe):pe=e[51];let ue;e[52]!==_||e[53]!==C?(ue=!C&&_&&r.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",x0[_.tone]),children:[r.jsx($E,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=ue):ue=e[54];let je;e[55]!==E?(je=(E==null?void 0:E.field)==="host"&&r.jsx(us,{children:E.message}),e[55]=E,e[56]=je):je=e[56];let Ne;e[57]!==me||e[58]!==we||e[59]!==pe||e[60]!==ue||e[61]!==je?(Ne=r.jsxs(gt,{"data-invalid":me,children:[le,xe,we,pe,ue,je]}),e[57]=me,e[58]=we,e[59]=pe,e[60]=ue,e[61]=je,e[62]=Ne):Ne=e[62];let Re;e[63]===Symbol.for("react.memo_cache_sentinel")?(Re=r.jsxs(xt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Re):Re=e[63];let Te;e[64]===Symbol.for("react.memo_cache_sentinel")?(Te=De=>h(De.target.value),e[64]=Te):Te=e[64];let Pe;e[65]!==p?(Pe=r.jsxs(gt,{children:[Re,r.jsx(Ot,{id:"device-name",value:p,onChange:Te,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Pe):Pe=e[66];let Oe;e[67]!==E||e[68]!==H||e[69]!==b?(Oe=H&&r.jsxs(gt,{"data-invalid":(E==null?void 0:E.field)==="username",children:[r.jsx(xt,{htmlFor:"device-username",children:"Username"}),r.jsx(Ot,{id:"device-username",value:b,onChange:De=>w(De.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(mo,{children:"Requests through this hub will act as this account on the team server."}),(E==null?void 0:E.field)==="username"&&r.jsx(us,{children:E.message})]}),e[67]=E,e[68]=H,e[69]=b,e[70]=Oe):Oe=e[70];let Fe;e[71]!==W||e[72]!==y||e[73]!==E||e[74]!==H?(Fe=W&&r.jsxs(gt,{"data-invalid":(E==null?void 0:E.field)==="password",children:[r.jsx(xt,{htmlFor:"device-password",children:"Password"}),r.jsx(Ot,{id:"device-password",type:"password",value:y,onChange:De=>j(De.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(us,{children:E.message})]}),e[71]=W,e[72]=y,e[73]=E,e[74]=H,e[75]=Fe):Fe=e[75];let ze;e[76]!==Ne||e[77]!==Pe||e[78]!==Oe||e[79]!==Fe?(ze=r.jsxs(jo,{children:[Ne,Pe,Oe,Fe]}),e[76]=Ne,e[77]=Pe,e[78]=Oe,e[79]=Fe,e[80]=ze):ze=e[80];let Be;e[81]===Symbol.for("react.memo_cache_sentinel")?(Be=De=>{R.current=R.current+1,N(De===!0),P(null),M(null)},e[81]=Be):Be=e[81];let _e;e[82]!==k?(_e=r.jsx(kg,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Be}),e[82]=k,e[83]=_e):_e=e[83];const He=H?"":" — no password";let Ie;e[84]!==He?(Ie=r.jsxs(xt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",He]}),e[84]=He,e[85]=Ie):Ie=e[85];let Ce;e[86]!==_e||e[87]!==Ie?(Ce=r.jsxs(gt,{orientation:"horizontal",children:[_e,Ie]}),e[86]=_e,e[87]=Ie,e[88]=Ce):Ce=e[88];let de;e[89]!==k||e[90]!==H?(de=k&&r.jsxs(Ct,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(Uv,{}),r.jsx(_t,{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]=k,e[90]=H,e[91]=de):de=e[91];let Ee;e[92]!==o?(Ee=r.jsx(J,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=Ee):Ee=e[93];const Ae=!q;let Le;e[94]!==V?(Le=()=>void V(),e[94]=V,e[95]=Le):Le=e[95];let ne;e[96]!==A?(ne=A?r.jsxs(r.Fragment,{children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=A,e[97]=ne):ne=e[97];let fe;e[98]!==Ae||e[99]!==Le||e[100]!==ne?(fe=r.jsx(J,{disabled:Ae,onClick:Le,children:ne}),e[98]=Ae,e[99]=Le,e[100]=ne,e[101]=fe):fe=e[101];let Se;e[102]!==Ee||e[103]!==fe?(Se=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Ee,fe]}),e[102]=Ee,e[103]=fe,e[104]=Se):Se=e[104];let $e;e[105]!==ze||e[106]!==Ce||e[107]!==de||e[108]!==Se?($e=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[he,ze,Ce,de,Se]}),e[105]=ze,e[106]=Ce,e[107]=de,e[108]=Se,e[109]=$e):$e=e[109];let Ue;e[110]!==te||e[111]!==$e?(Ue=r.jsxs(Yn,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,te,$e]}),e[110]=te,e[111]=$e,e[112]=Ue):Ue=e[112];let We;return e[113]!==t||e[114]!==re||e[115]!==ie||e[116]!==Ue?(We=r.jsx(Gn,{open:t,onOpenChange:re,onOpenChangeComplete:ie,children:Ue}),e[113]=t,e[114]=re,e[115]=ie,e[116]=Ue,e[117]=We):We=e[117],We}const LE=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:b0,parseHostPort:Bo,probeMessage:g0},Symbol.toStringTag,{value:"Module"})),Qm=h0.version,zE={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Zm={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function FE(n){const e=B.c(6),{state:t}=n,s=Zm[t],o=Zm[t],i=zE[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 Md(n){const e=B.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=Aa(),[d,f]=v.useState(null),u=(a==null?void 0:a.name)??"This machine",m=i!==wt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ut("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==o||e[2]!==l||e[3]!==c?(g=F=>{!F||o.length===0||Promise.all(o.map(z=>c(z.id).catch(UE))).then(()=>l())},e[1]=o,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&o.length===0&&!m)return null;const b=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]!==b||e[8]!==y?(j=r.jsx(J,{variant:"ghost",size:b,"aria-label":"Switch device",className:y}),e[7]=b,e[8]=y,e[9]=j):j=e[9];let k;e[10]!==m?(k=m?r.jsx(eh,{"data-icon":"inline-start"}):r.jsx(Wu,{"data-icon":"inline-start"}),e[10]=m,e[11]=k):k=e[11];let N;e[12]!==u?(N=r.jsx("span",{className:"truncate",children:u}),e[12]=u,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(st,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let S;e[15]!==j||e[16]!==k||e[17]!==N?(S=r.jsxs(Mn,{render:j,children:[k,N,C]}),e[15]=j,e[16]=k,e[17]=N,e[18]=S):S=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(gs,{children:"Devices"}),e[19]=_):_=e[19];let P,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Wu,{}),A=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=P,e[21]=A):(P=e[20],A=e[21]);let T;e[22]!==m?(T=!m&&r.jsx(dt,{className:"ml-auto text-success"}),e[22]=m,e[23]=T):T=e[23];let E;e[24]!==T?(E=r.jsxs(ct,{onClick:BE,children:[P,A,T]}),e[24]=T,e[25]=E):E=e[25];let M;if(e[26]!==i||e[27]!==s||e[28]!==o){let F;e[30]!==i||e[31]!==s?(F=z=>{const H=p0(z),U=H!==void 0&&H!==Qm,W=z.id===i;return r.jsxs(ct,{onClick:()=>hs(z.id),className:G(s&&"min-h-10"),children:[r.jsx(FE,{state:z.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:z.name}),U&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${H}; hub runs v${Qm}`,children:["v",H]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[z.host,":",z.port,z.auth==="none"&&" · unauthenticated"]})]}),W&&r.jsx(dt,{className:"ml-auto text-success"})]},z.id)},e[30]=i,e[31]=s,e[32]=F):F=e[32],M=o.map(F),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(Ft,{children:[_,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(ao,{}),r.jsxs(Ft,{children:[r.jsxs(ct,{onClick:()=>f("add"),children:[r.jsx(Tn,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(ct,{onClick:()=>f("manage"),children:[r.jsx(kc,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=R):R=e[37];let $;e[38]!==I||e[39]!==R?($=r.jsxs(In,{align:"end",sideOffset:6,className:"w-64",children:[I,R]}),e[38]=I,e[39]=R,e[40]=$):$=e[40];let D;e[41]!==x||e[42]!==S||e[43]!==$?(D=r.jsxs(Rn,{onOpenChange:x,children:[S,$]}),e[41]=x,e[42]=S,e[43]=$,e[44]=D):D=e[44];let O;e[45]!==d?(O=h&&r.jsx(b0,{open:d!==null,initialMode:d??"manage",onClose:()=>f(null)}),e[45]=d,e[46]=O):O=e[46];let L;return e[47]!==D||e[48]!==O?(L=r.jsxs(r.Fragment,{children:[D,O]}),e[47]=D,e[48]=O,e[49]=L):L=e[49],L}function BE(){return hs(wt)}function UE(){return null}const WE=6e4;function HE(){const[n,e]=v.useState([]),[t,s]=v.useState(!1),o=v.useRef(!1),i=v.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=v.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 v.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},WE);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const KE=6e4;function qE(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=HE(),[i,a]=v.useState(!1),l=e.length>0,c=e.reduce(YE,0);let d,f;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const T=window.setTimeout(()=>a(!1),KE);return()=>window.clearTimeout(T)},f=[l],n[0]=l,n[1]=d,n[2]=f):(d=n[1],f=n[2]),v.useEffect(d,f),!l&&!i)return null;const u=Et,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(GE)):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 x;n[8]!==g?(x=G("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=r.jsx(J,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:x}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=x,n[15]=b):b=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Wv,{"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 k;n[19]!==j||n[20]!==b?(k=r.jsxs(Pt,{render:b,children:[w,j]}),n[19]=j,n[20]=b,n[21]=k):k=n[21];const N=At,C="bottom",S="p-3",_=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(VE),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(It,{}),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 P;n[22]!==N||n[23]!==_?(P=r.jsx(N,{side:C,className:S,children:_}),n[22]=N,n[23]=_,n[24]=P):P=n[24];let A;return n[25]!==u||n[26]!==k||n[27]!==P?(A=r.jsxs(u,{children:[k,P]}),n[25]=u,n[26]=k,n[27]=P,n[28]=A):A=n[28],A}function VE(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," · ",Ic(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function GE(n){return n.pid}function YE(n,e){return n+e.cpuPercent}const XE=15e3;function JE(){const n=B.c(12);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=v.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const b=await ye("/api/notifications?limit=100");if(!b.ok)return;const w=await b.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 b=window.setInterval(()=>void i(),XE);return()=>window.clearInterval(b)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),v.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(b,w)=>{const y=new Date().toISOString();s(j=>j.map(k=>k.readAt===null&&w(k)?{...k,readAt:y}:k));try{await ye("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})}catch{}},n[4]=c):c=n[4];const d=c;let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=async b=>d({ids:b},w=>b.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},ZE),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(QE),n[7]=t,n[8]=h):h=n[8];const g=h.length;let x;return n[9]!==t||n[10]!==g?(x={notifications:t,unreadCount:g,refresh:i,markRead:u,markAllRead:p},n[9]=t,n[10]=g,n[11]=x):x=n[11],x}function QE(n){return n.readAt===null}function ZE(){return!0}function v0(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function e8(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=JE(),[a,l]=v.useState(!1);let c;n[0]!==o?(c=function(S){if(o([S.id]),!S.dirName||!S.sessionId)return;const _=ht(),P=_===wt?"":`/d/${_}`;v0(`${P}/${encodeURIComponent(S.dirName)}/${encodeURIComponent(S.sessionId)}`),l(!1)},n[0]=o,n[1]=c):c=n[1];const d=c;let f;n[2]!==s?(f=C=>{l(C),C&&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(J,{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(Hu,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Me,{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 x;n[10]!==p||n[11]!==g?(x=r.jsxs(Mn,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let b;n[13]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=b):b=n[13];let w;n[14]!==i||n[15]!==t?(w=t>0&&r.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(Hv,{"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:[b,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(Hn,{className:"min-h-40 p-6",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(Hu,{})}),r.jsx(qn,{children:"No notifications"}),r.jsx(Vn,{children:"Session updates will appear here."})]})}):r.jsx(Ft,{children:e.map(C=>r.jsx(t8,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=j):j=n[21];let k;n[22]!==y||n[23]!==j?(k=r.jsxs(In,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[y,j]}),n[22]=y,n[23]=j,n[24]=k):k=n[24];let N;return n[25]!==a||n[26]!==f||n[27]!==k||n[28]!==x?(N=r.jsxs(Rn,{open:a,onOpenChange:f,children:[x,k]}),n[25]=a,n[26]=f,n[27]=k,n[28]=x,n[29]=N):N=n[29],N}function t8(n){const e=B.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"?vn:Qi;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 x;e[10]!==d||e[11]!==g?(x=r.jsx(d,{className:g}),e[10]=d,e[11]=g,e[12]=x):x=e[12];const b=o?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==b?(w=G("truncate text-xs",b),e[13]=b,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=Ic(c),e[18]=c,e[19]=j):j=e[19];let k;e[20]!==j?(k=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:j}),e[20]=j,e[21]=k):k=e[21];let N;e[22]!==y||e[23]!==k?(N=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[y,k]}),e[22]=y,e[23]=k,e[24]=N):N=e[24];let C;e[25]!==t.body?(C=r.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=C):C=e[26];let S;e[27]!==N||e[28]!==C?(S=r.jsxs("span",{className:"min-w-0 flex-1",children:[N,C]}),e[27]=N,e[28]=C,e[29]=S):S=e[29];let _;e[30]!==o?(_=o&&r.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=o,e[31]=_):_=e[31];let P;return e[32]!==S||e[33]!==_||e[34]!==f||e[35]!==p||e[36]!==x?(P=r.jsxs(ct,{onClick:f,className:p,children:[x,S,_]}),e[32]=S,e[33]=_,e[34]=f,e[35]=p,e[36]=x,e[37]=P):P=e[37],P}const n8=2e3;function bo(n){return`${n.toFixed(n<10?1:0)}%`}function Oi(n){return`${n.toFixed(0)} MB`}function s8(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function o8(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 r8(n){const e=B.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(Me,{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(Me,{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(Me,{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(J,{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=bo(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 x;e[30]!==t.memoryMb?(x=Oi(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=Ic(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let w;e[34]!==x||e[35]!==b?(w=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,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 i8(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 a8(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 y0(n){const e=B.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(Me,{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=i8(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=bo(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=Oi(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 x;e[27]!==m||e[28]!==h||e[29]!==g?(x=r.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function ep(n){const e=B.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(l8)}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 l8(n,e){const t=o8(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(It,{}),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:s8(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(Me,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function c8(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(d8).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:bo(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 d8(n){return bo(n)}function u8(n){var xe,ge,ce,we;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=v.useState(null),[a,l]=v.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,f]=v.useState(c),[u,m]=v.useState(null),[p,h]=v.useState(!1),g=v.useRef(!1),[x,b]=go();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Pe;if(g.current)return;g.current=!0,h(!0);const pe=ye("/api/performance").then(x8),ue=((Pe=window.electronPerformance)==null?void 0:Pe.getSnapshot())??Promise.resolve(null),[je,Ne]=await Promise.allSettled([pe,ue]),Re=je.status==="fulfilled"?je.value:null,Te=Ne.status==="fulfilled"?Ne.value:null;if(Re&&l(Re),Te&&i(Te),!Re&&!Te)m("Performance data is unavailable.");else{m(null);const Oe=Te&&Te.processes.length>0?Te.processes.reduce(g8,0):(Re==null?void 0:Re.cpuPercent)??0;f(Fe=>[...Fe.slice(-29),Oe])}g.current=!1,h(!1)},e[1]=w):w=e[1];const y=w;let j,k;e[2]!==t?(j=()=>{if(!t)return;y();const pe=window.setInterval(()=>void y(),n8);return()=>window.clearInterval(pe)},k=[t,y],e[2]=t,e[3]=j,e[4]=k):(j=e[3],k=e[4]),v.useEffect(j,k);let N,C,S,_,P,A,T,E,M,I,R,$,D,O,L,F,z,H,U;if(e[5]!==x||e[6]!==b||e[7]!==o||e[8]!==u||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const pe=[...(o==null?void 0:o.processes)??[]].sort(h8),ue=pe.length>0?pe.reduce(p8,0):(a==null?void 0:a.cpuPercent)??0,je=pe[0];let Ne;e[33]!==((xe=a==null?void 0:a.system)==null?void 0:xe.processes)?(Ne=((ge=a==null?void 0:a.system)==null?void 0:ge.processes)??[],e[33]=(ce=a==null?void 0:a.system)==null?void 0:ce.processes,e[34]=Ne):Ne=e[34],T=Ne;const Re=((we=a==null?void 0:a.system)==null?void 0:we.suspectedLeakCount)??0,Te=Re>0||ue>=80?"High":ue>=15?"Active":"Idle";let Pe;e[35]===Symbol.for("react.memo_cache_sentinel")?(Pe=async ot=>{try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[ot]})}),await new Promise(m8)}catch{}y()},e[35]=Pe):Pe=e[35],A=Pe;let Oe;e[36]!==b||e[37]!==o||e[38]!==d||e[39]!==a?(Oe=()=>{b(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=b,e[37]=o,e[38]=d,e[39]=a,e[40]=Oe):Oe=e[40];const Fe=Oe;P=Gn,D=t,O=s,_=Yn,I="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let ze;e[41]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(Xn,{children:"Power & activity monitor"}),e[41]=ze):ze=e[41];const Be=Te==="High"?"destructive":"secondary";let _e;e[42]!==Te||e[43]!==Be?(_e=r.jsxs("div",{className:"flex items-center gap-2",children:[ze,r.jsx(Me,{variant:Be,children:Te})]}),e[42]=Te,e[43]=Be,e[44]=_e):_e=e[44];let He;e[45]===Symbol.for("react.memo_cache_sentinel")?(He=r.jsx(Jn,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=He):He=e[45];let Ie;e[46]!==_e?(Ie=r.jsxs("div",{className:"min-w-0 flex-1",children:[_e,He]}),e[46]=_e,e[47]=Ie):Ie=e[47];let Ce;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ce=()=>void y(),e[48]=Ce):Ce=e[48];const de=p&&"animate-spin";let Ee;e[49]!==de?(Ee=G(de),e[49]=de,e[50]=Ee):Ee=e[50];let Ae;e[51]!==Ee?(Ae=r.jsx(Qt,{"data-icon":"inline-start",className:Ee}),e[51]=Ee,e[52]=Ae):Ae=e[52];let Le;e[53]!==p||e[54]!==Ae?(Le=r.jsxs(J,{variant:"outline",size:"sm",onClick:Ce,disabled:p,children:[Ae,"Refresh"]}),e[53]=p,e[54]=Ae,e[55]=Le):Le=e[55];const ne=!a&&!o;let fe;e[56]!==x?(fe=x?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(Pn,{"data-icon":"inline-start"}),e[56]=x,e[57]=fe):fe=e[57];const Se=x?"Copied":"Copy data";let $e;e[58]!==Fe||e[59]!==ne||e[60]!==fe||e[61]!==Se?($e=r.jsxs(J,{variant:"outline",size:"sm",onClick:Fe,disabled:ne,children:[fe,Se]}),e[58]=Fe,e[59]=ne,e[60]=fe,e[61]=Se,e[62]=$e):$e=e[62];let Ue;e[63]!==Le||e[64]!==$e?(Ue=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Le,$e]}),e[63]=Le,e[64]=$e,e[65]=Ue):Ue=e[65],e[66]!==Ie||e[67]!==Ue?(R=r.jsx(ks,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Ie,Ue]})}),e[66]=Ie,e[67]=Ue,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(It,{}),e[69]=$):$=e[69],S=Cr,M="min-h-0 min-w-0 flex-1",H="flex flex-col gap-4 p-5",e[70]!==u?(U=u&&r.jsx(Ct,{variant:"destructive",children:r.jsx(_t,{children:u})}),e[70]=u,e[71]=U):U=e[71];let We;e[72]===Symbol.for("react.memo_cache_sentinel")?(We=r.jsx(sn,{children:"Current load"}),e[72]=We):We=e[72];const Xe=ue>=80&&"text-destructive";let Je;e[73]!==Xe?(Je=G("font-mono text-lg font-semibold tabular-nums",Xe),e[73]=Xe,e[74]=Je):Je=e[74];const De=r.jsxs(nn,{children:[We,r.jsx(on,{children:a8(ue,je,Re)}),r.jsx(Ng,{children:r.jsxs("span",{className:Je,children:[bo(ue)," CPU"]})})]});let qe;e[75]!==d?(qe=r.jsx(Jt,{children:r.jsx(c8,{values:d})}),e[75]=d,e[76]=qe):qe=e[76],e[77]!==De||e[78]!==qe?(E=r.jsxs(Xt,{size:"sm",children:[De,qe]}),e[77]=De,e[78]=qe,e[79]=E):E=e[79],C=Xt,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs(nn,{children:[r.jsx(sn,{children:"Processes"}),r.jsx(on,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],N=Jt,L=pe.length>0?pe.map(f8):a?r.jsx(y0,{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]=x,e[6]=b,e[7]=o,e[8]=u,e[9]=d,e[10]=s,e[11]=t,e[12]=p,e[13]=a,e[14]=N,e[15]=C,e[16]=S,e[17]=_,e[18]=P,e[19]=A,e[20]=T,e[21]=E,e[22]=M,e[23]=I,e[24]=R,e[25]=$,e[26]=D,e[27]=O,e[28]=L,e[29]=F,e[30]=z,e[31]=H,e[32]=U}else N=e[14],C=e[15],S=e[16],_=e[17],P=e[18],A=e[19],T=e[20],E=e[21],M=e[22],I=e[23],R=e[24],$=e[25],D=e[26],O=e[27],L=e[28],F=e[29],z=e[30],H=e[31],U=e[32];let W;e[81]!==N||e[82]!==L?(W=r.jsx(N,{children:L}),e[81]=N,e[82]=L,e[83]=W):W=e[83];let K;e[84]!==C||e[85]!==W||e[86]!==F||e[87]!==z?(K=r.jsxs(C,{size:F,children:[z,W]}),e[84]=C,e[85]=W,e[86]=F,e[87]=z,e[88]=K):K=e[88];let q;e[89]!==A||e[90]!==T?(q=T.length>0&&r.jsxs(Xt,{size:"sm",children:[r.jsxs(nn,{children:[r.jsx(sn,{children:"Agent processes"}),r.jsx(on,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Jt,{children:T.map((pe,ue)=>r.jsxs("div",{children:[ue>0&&r.jsx(It,{}),r.jsx(r8,{metric:pe,onKill:je=>void A(je)})]},pe.pid))})]}),e[89]=A,e[90]=T,e[91]=q):q=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(sn,{children:"Server activity"}),e[92]=Y):Y=e[92];const V=(a==null?void 0:a.sampleWindowSeconds)??10;let Q;e[93]!==V?(Q=r.jsxs(nn,{children:[Y,r.jsxs(on,{children:["File checks, streams, and agent work over the last ",V," seconds."]})]}),e[93]=V,e[94]=Q):Q=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 X;e[97]!==Z?(X=r.jsx(Jt,{children:r.jsx(ep,{metrics:Z,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Z,e[98]=X):X=e[98];let ee;e[99]!==Q||e[100]!==X?(ee=r.jsxs(Xt,{size:"sm",children:[Q,X]}),e[99]=Q,e[100]=X,e[101]=ee):ee=e[101];let oe;e[102]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsxs(nn,{children:[r.jsx(sn,{children:"API activity"}),r.jsx(on,{children:"Requests ranked by recent frequency and time."})]}),e[102]=oe):oe=e[102];let se;e[103]!==(a==null?void 0:a.requests)?(se=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=se):se=e[104];let re;e[105]!==se?(re=r.jsxs(Xt,{size:"sm",children:[oe,r.jsx(Jt,{children:r.jsx(ep,{metrics:se,emptyLabel:"No API requests in this sample."})})]}),e[105]=se,e[106]=re):re=e[106];let ie;e[107]!==ee||e[108]!==re?(ie=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[ee,re]}),e[107]=ee,e[108]=re,e[109]=ie):ie=e[109];let ae;e[110]!==a?(ae=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",bo(a.eventLoopPercent)," · heap ",Oi(a.memory.heapUsedMb)," · RSS ",Oi(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let te;e[112]!==E||e[113]!==K||e[114]!==q||e[115]!==ie||e[116]!==ae||e[117]!==H||e[118]!==U?(te=r.jsxs("div",{className:H,children:[U,E,K,q,ie,ae]}),e[112]=E,e[113]=K,e[114]=q,e[115]=ie,e[116]=ae,e[117]=H,e[118]=U,e[119]=te):te=e[119];let he;e[120]!==S||e[121]!==M||e[122]!==te?(he=r.jsx(S,{className:M,children:te}),e[120]=S,e[121]=M,e[122]=te,e[123]=he):he=e[123];let me;e[124]!==_||e[125]!==I||e[126]!==R||e[127]!==$||e[128]!==he?(me=r.jsxs(_,{className:I,children:[R,$,he]}),e[124]=_,e[125]=I,e[126]=R,e[127]=$,e[128]=he,e[129]=me):me=e[129];let le;return e[130]!==P||e[131]!==D||e[132]!==O||e[133]!==me?(le=r.jsx(P,{open:D,onOpenChange:O,children:me}),e[130]=P,e[131]=D,e[132]=O,e[133]=me,e[134]=le):le=e[134],le}function f8(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(It,{}),r.jsx(y0,{metric:n})]},n.pid)}function m8(n){return setTimeout(n,1e3)}function p8(n,e){return n+e.cpuPercent}function h8(n,e){return e.cpuPercent-n.cpuPercent}function g8(n,e){return n+e.cpuPercent}async function x8(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function b8(n){return`${n.title??`Pull request #${n.number}`}
|
|
116
116
|
${n.repo}${n.isDraft?" · draft":""}`}function w0(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:b8(n)}}function Ra(n){const e=B.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(y8),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(v8).join(`
|
|
117
117
|
`),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?ih:ah;return r.jsxs(Me,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...w0(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 v8(n){return`#${n.number} ${n.title??n.repo}`}function y8(n){const e=n.isDraft?ih:ah;return r.jsxs("a",{...w0(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 w8=v.memo(function(e){const t=B.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 A=o?vs(o.fileName):null;p=A?jd(A.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(k8),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let b;t[4]!==s.rawMessages||t[5]!==(o==null?void 0:o.dirName)?(b=fo(o==null?void 0:o.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=o==null?void 0:o.dirName,t[6]=b):b=t[6];const w=b;let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:G(Cn,"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(S8,{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 k;t[17]!==i?(k=i&&r.jsx(ca,{"aria-label":"Session is live"}),t[17]=i,t[18]=k):k=t[18];let N;t[19]!==s.model?(N=s.model&&r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:ia(s.model)}),t[19]=s.model,t[20]=N):N=t[20];let C;t[21]!==w?(C=r.jsx(ig,{rawMessages:w}),t[21]=w,t[22]=C):C=t[22];let S;t[23]!==j||t[24]!==k||t[25]!==N||t[26]!==C?(S=r.jsxs(Pt,{delay:200,render:y,children:[j,k,N,C]}),t[23]=j,t[24]=k,t[25]=N,t[26]=C,t[27]=S):S=t[27];let _;t[28]!==a||t[29]!==w||t[30]!==s||t[31]!==h||t[32]!==x?(_=r.jsx(At,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(j8,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:a,rawMessages:w})}),t[28]=a,t[29]=w,t[30]=s,t[31]=h,t[32]=x,t[33]=_):_=t[33];let P;return t[34]!==_||t[35]!==S?(P=r.jsxs(Et,{children:[S,_]}),t[34]=_,t[35]=S,t[36]=P):P=t[36],P});function Js(n){const e=B.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 j8(n){const e=B.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=rg(a),x=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(Js,{label:"Model",children:[r.jsx("span",{children:ia(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(Js,{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(Js,{label:"Pull requests",children:r.jsx(Ra,{pullRequests:i})}),e[19]=i,e[20]=f):f=e[20],e[21]!==o?(u=o&&r.jsx(Js,{label:"Agent",children:o}),e[21]=o,e[22]=u):u=e[22],e[23]!==x?(m=x&&r.jsxs(Js,{label:"Duplicated from",children:[x.sessionId.slice(0,8),x.turnIndex!=null?` at turn ${x.turnIndex+1}`:""]}),e[23]=x,e[24]=m):m=e[24],p=g&&r.jsxs(Js,{label:"Context",children:[nt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",nt(g.used)," / ",nt(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 S8(n){const e=B.c(54),{session:t,sessionSource:s,copied:o,creatingSession:i,onCopyResume:a,onNewSession:l,onDuplicateSession:c,onOpenTerminal:d}=n,{dispatch:f}=Rt(),u=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=$s(),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 x;e[4]!==t.cwd||e[5]!==g?(x=t.cwd?`${zn(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;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||Xc(),e[10]=j):j=e[10];const k=j;let N;e[11]!==f||e[12]!==s.dirName?(N=function(){v.startTransition(()=>{f({type:"GO_HOME",isMobile:!1}),f({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=f,e[12]=s.dirName,e[13]=N):N=e[13];const C=N,S=`Copy resume command for ${b}; open session actions with the context menu`;let _;e[14]!==a||e[15]!==S?(_=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":S,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=a,e[15]=S,e[16]=_):_=e[16];let P;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(P=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(dt,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:zn(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]=P):P=e[20];let A;e[21]!==_||e[22]!==P?(A=r.jsx(ka,{render:_,children:P}),e[21]=_,e[22]=P,e[23]=A):A=e[23];let T;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(T=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=T):T=e[27];let E;e[28]!==i?(E=i?r.jsx(Bt,{className:"size-3.5"}):r.jsx(Tn,{className:"size-3.5"}),e[28]=i,e[29]=E):E=e[29];let M;e[30]!==i||e[31]!==T||e[32]!==E?(M=r.jsxs(Yt,{disabled:i,onClick:T,children:[E,"New session in this project"]}),e[30]=i,e[31]=T,e[32]=E,e[33]=M):M=e[33];let I;e[34]!==c?(I=c&&r.jsxs(Yt,{onClick:c,children:[r.jsx(Pn,{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&&(k||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(cr,{}),k&&r.jsxs(Yt,{onClick:()=>Rg(y),children:[r.jsx(pr,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(Yt,{onClick:()=>Mg(y),children:[r.jsx(lh,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=u,e[37]=y,e[38]=R):R=e[38];let $;e[39]!==d?($=d&&!p&&ut("terminal")&&r.jsxs(Yt,{onClick:d,children:[r.jsx(wo,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=$):$=e[40];let D;e[41]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(cr,{}),e[41]=D):D=e[41];let O;e[42]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Qo,{className:"size-3.5"}),e[42]=O):O=e[42];let L;e[43]!==C?(L=r.jsxs(Yt,{onClick:C,children:[O,"View all sessions in this project"]}),e[43]=C,e[44]=L):L=e[44];let F;e[45]!==M||e[46]!==I||e[47]!==R||e[48]!==$||e[49]!==L?(F=r.jsxs(Na,{className:"min-w-56",children:[M,I,R,$,D,L]}),e[45]=M,e[46]=I,e[47]=R,e[48]=$,e[49]=L,e[50]=F):F=e[50];let z;return e[51]!==A||e[52]!==F?(z=r.jsxs(Sa,{children:[A,F]}),e[51]=A,e[52]=F,e[53]=z):z=e[53],z}function k8(n){return n.thinking.length>0}const lc="Could not reach the server";async function ri(n,e){try{return await ye(n,e)}catch{return null}}async function jl(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:lc}function N8(){const n=B.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=v.useState(e),[o,i]=v.useState(null),a=v.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]),v.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const N=await ri("/api/shares");if(!(N!=null&&N.ok))return;const C=await N.json().catch(E8);a.current&&Array.isArray(C)&&s(C)},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]),v.useEffect(u,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async N=>{i(null);const C=await ri("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:N})});if(!(C!=null&&C.ok))return a.current&&i(await jl(C)),null;const S=await C.json().catch(T8);if(!(S!=null&&S.passphrase)||!S.share)return a.current&&i(lc),null;const _=S.share;return a.current&&s(P=>[...P.filter(A=>A.sessionId!==_.sessionId),_]),S.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async N=>{i(null);const C=await ri(`/api/shares/${encodeURIComponent(N)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await jl(C)),null;const S=await C.json().catch(_8);return S!=null&&S.passphrase?(f(),S.passphrase):(a.current&&i(lc),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async N=>{i(null);const C=await ri(`/api/shares/${encodeURIComponent(N)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await jl(C));return}a.current&&s(S=>S.filter(_=>_.sessionId!==N))},n[8]=b):b=n[8];const w=b;let y;n[9]!==t?(y=async()=>{const N=t.map(C8);for(const C of N)await w(C)},n[9]=t,n[10]=y):y=n[10];const j=y;let k;return n[11]!==o||n[12]!==j||n[13]!==t?(k={shares:t,error:o,refresh:f,create:h,regenerate:x,revoke:w,revokeAll:j},n[11]=o,n[12]=j,n[13]=t,n[14]=k):k=n[14],k}function C8(n){return n.sessionId}function _8(){return null}function T8(){return null}function E8(){return null}const P8=5e3,A8="••••";function R8(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function M8({sessionId:n}){const{config:{networkAccessDisabled:e}}=Rt(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=N8(),[c,d]=v.useState(!1),[f,u]=v.useState(null),[m,p]=v.useState(!1),[h,g]=go(),[x,b]=go(),w=t.find(N=>N.sessionId===n)??null,y=`${window.location.origin}${Yj(n)}`;v.useEffect(()=>u(null),[n]),v.useEffect(()=>{if(!c)return;o();const N=setInterval(()=>void o(),P8);return()=>clearInterval(N)},[c,o]);async function j(N){p(!0);try{await N()}finally{p(!1)}}const k=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:N=>{d(N),N||u(null)},children:[r.jsx(Mn,{render:r.jsx(J,{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(Kv,{"data-icon":"inline-start"})}),r.jsx(In,{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(J,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(y),children:h?r.jsx(dt,{"data-icon":"inline-start"}):r.jsx(Pn,{"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??A8}),r.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{u(await a(n))}),children:r.jsx(Qt,{"data-icon":"inline-start"})})]}),f?r.jsx(J,{variant:"secondary",size:"xs",onClick:()=>b(`${y}
|
|
118
118
|
Passphrase: ${f}`),children:x?"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."}),k,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:R8(w.guests)}),r.jsx(J,{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."}),k,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(J,{size:"xs",disabled:m,onClick:()=>j(async()=>{u(await i(n))}),children:"Enable sharing"})]})})]})}function Id(n,e,t){if(!(n===void 0||!Number.isFinite(n)))return{utilization:Math.min(100,Math.max(0,n)),...e===void 0?{}:{resetsAt:e},...t===void 0?{}:{label:t}}}function at(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function xn(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function fs(n){return typeof n=="string"?n:void 0}function ds(n){return n?Id(xn(n.utilization),fs(n.resets_at)):void 0}function j0(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:xn(n.monthly_limit),usedCredits:xn(n.used_credits),utilization:xn(n.utilization)}}function I8(n){return{fiveHour:ds(at(n.five_hour)),sevenDay:ds(at(n.seven_day)),sevenDayOpus:ds(at(n.seven_day_opus)),sevenDaySonnet:ds(at(n.seven_day_sonnet)),extraUsage:j0(at(n.extra_usage)),subscriptionType:fs(n.subscriptionType)}}function $8(n){if(n.available!==!0)return null;const e=at(n.usage),t=at(e==null?void 0:e.rate_limits),s=at(n.account),o={fiveHour:ds(at(t==null?void 0:t.five_hour)),sevenDay:ds(at(t==null?void 0:t.seven_day)),sevenDayOpus:ds(at(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:ds(at(t==null?void 0:t.seven_day_sonnet)),extraUsage:j0(at(t==null?void 0:t.extra_usage)),subscriptionType:fs(e==null?void 0:e.subscription_type)??fs(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function O8(n){const e=xn(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function D8(n,e){const t=xn(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function tp(n,e){if(n)return Id(xn(n.usedPercent),O8(n.resetsAt),D8(n.windowDurationMins,e))}function L8(n){var d,f,u;if(n.available!==!0)return null;const e=at((d=at(n.rateLimits))==null?void 0:d.rateLimits),t=at((f=at(n.account))==null?void 0:f.account),s=at((u=at(n.usage))==null?void 0:u.summary),o=at(e==null?void 0:e.credits),i=tp(at(e==null?void 0:e.primary),"Primary"),a=tp(at(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=xn(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!i&&!a&&c===void 0?null:{fiveHour:i,sevenDay:a,subscriptionType:fs(e==null?void 0:e.planType)??fs(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:fs(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function np(n,e){if(!n)return;const t=xn(n.remainingPercentage),s=xn(n.usedRequests),o=xn(n.entitlementRequests);let i;return t!==void 0?i=100-t:n.isUnlimitedEntitlement===!0||o===-1?i=0:s!==void 0&&o!==void 0&&o>0&&(i=s/o*100),Id(i,fs(n.resetDate),e)}function z8(n){var s;if(n.available!==!0)return null;const e=at((s=at(n.quota))==null?void 0:s.quotaSnapshots),t=np(at(e==null?void 0:e.chat),"Chat")??np(at(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const F8={claude:{endpoint:"/api/claude/runtime",read:$8,legacy:{endpoint:"/api/usage",read:I8}},codex:{endpoint:"/api/codex/runtime",read:L8},copilot:{endpoint:"/api/copilot/runtime",read:z8}};function B8(n){return F8[n]}const U8=300*1e3;function W8(n=Fs){const e=yn("viewUsage"),[t,s]=v.useState(null),[o,i]=v.useState(!1),[a,l]=v.useState(!1),c=v.useRef(0),d=v.useRef(null),f=v.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{const g=B8(n);let x=await ye(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await ye(g.legacy.endpoint,{signal:m.signal}),b=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const w=await x.json();if(!p())return;const y=b(w);l(y!==null),s(y?{...y,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return v.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,U8);return()=>{var p;clearInterval(u),c.current+=1,(p=d.current)==null||p.abort(),d.current=null}},[n,e,f]),{usage:e?t:null,loading:e&&o,available:e&&a,refresh:f}}function S0(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const k0={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function H8(n){var d;const e=B.c(31),{usage:t}=n;let s,o,i;if(e[0]!==t.agentKind||e[1]!==t.fetchedAt||e[2]!==t.fiveHour||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";let u;e[10]!==t.agentKind?(u=t.agentKind?oa(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=u):u=e[11];let m;e[12]!==u?(m=r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[u," usage"]}),e[12]=u,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&r.jsx(Me,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(o=r.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=o):o=e[18],i=f.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,b=S0(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",k0[b]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Dc,{value:Math.min(h.pct,100)}),x!=null&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Resets in ",x,"h"]})]},h.label)}),e[0]=t.agentKind,e[1]=t.fetchedAt,e[2]=t.fiveHour,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[19]!==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(It,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=a):a=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==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(It,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",nt(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?r.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?r.jsxs("div",{children:["Credits: ",t.creditBalance]}):null]}),e[21]=t.creditBalance,e[22]=t.creditsUnlimited,e[23]=t.lifetimeTokens,e[24]=l):l=e[24];let c;return e[25]!==s||e[26]!==o||e[27]!==i||e[28]!==a||e[29]!==l?(c=r.jsxs("div",{className:s,children:[o,i,a,l]}),e[25]=s,e[26]=o,e[27]=i,e[28]=a,e[29]=l,e[30]=c):c=e[30],c}function K8(n){var j,k;const e=B.c(22),{agentKind:t}=n,s=t===void 0?Fs:t,{usage:o,loading:i,available:a,refresh:l}=W8(s);if(!a||!o)return null;const c=((j=o.fiveHour)==null?void 0:j.utilization)??((k=o.sevenDay)==null?void 0:k.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?oa(o.agentKind):"agent",e[0]=o.agentKind,e[1]=d):d=e[1];const f=`Refresh ${d} usage`;let u;e[2]!==i||e[3]!==l||e[4]!==f?(u=r.jsx(J,{type:"button",variant:"ghost",size:"xs","aria-label":f,onClick:l,disabled:i,className:"mr-1 font-mono"}),e[2]=i,e[3]=l,e[4]=f,e[5]=u):u=e[5];const m=k0[S0(c)],p=i&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=G("tabular-nums",m,p),e[6]=m,e[7]=p,e[8]=h):h=e[8];let g;e[9]!==c?(g=c.toFixed(0),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==h||e[12]!==g?(x=r.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let b;e[14]!==u||e[15]!==x?(b=r.jsx(Pt,{render:u,children:x}),e[14]=u,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==o?(w=r.jsx(At,{side:"bottom",className:"p-3",children:r.jsx(H8,{usage:o})}),e[17]=o,e[18]=w):w=e[18];let y;return e[19]!==b||e[20]!==w?(y=r.jsxs(Et,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=y):y=e[21],y}function q8(n,e){const t=B.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]=v.useState(s),[a,l]=v.useState(0);let c;t[1]!==n||t[2]!==e?(c=()=>{const p=new AbortController;i(G8);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 x=await g.json();i({summary:x,loading:!1,error:null})}).catch(g=>{p.signal.aborted||i(x=>({...x,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],v.useEffect(c,d);let f;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>l(V8),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 V8(n){return n+1}function G8(n){return{...n,loading:!0,error:null}}function Y8(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const X8=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function J8(n,e){const t=Y8(e);return t.length===0||X8.has(t)?null:n.get(t)??null}function Q8(n,e,t,s){const o=J8(n,e);if(o===null)return{costUsd:0,costSource:"unpriced"};const i=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens);return{costUsd:t.uncachedInputTokens*o.inputCostPerToken+t.cachedInputTokens*o.cacheReadCostPerToken+(t.cacheCreationTokens-i)*o.cacheCreationCostPerToken+i*o.cacheCreation1hCostPerToken+t.outputTokens*o.outputCostPerToken,costSource:"modelPriced"}}function Z8(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function N0(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=Q8(n,e,{uncachedInputTokens:t.input_tokens,cachedInputTokens:t.cache_read_input_tokens??0,cacheCreationTokens:t.cache_creation_input_tokens??0,cacheCreation1hTokens:0,outputTokens:t.output_tokens});return o==="unpriced"?0:s}const e9=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],Go=Oh.map(n=>({key:n,label:Zt(n).displayName,color:$w(n)}));function t9(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 sp(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function n9(n){const e=new Map;for(const o of t9(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:sp(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:sp(),days:[],models:[]};for(const o of n.buckets){const i=Z8(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 op(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const Sl=720,kl=180,s9=18;function o9(n){const e=B.c(41),{days:t,metric:s}=n,[o,i]=v.useState(null);let a;e[0]!==s?(a=C=>s==="cost"?C.costUsd:C.tokens,e[0]=s,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==t||e[3]!==l){let C;e[5]!==l?(C=S=>l(S),e[5]=l,e[6]=C):C=e[6],c=Math.max(...t.map(C)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const d=c;if(d<=0){let C;return e[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=C):C=e[7],C}const f=kl-s9,u=Sl/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:op(p.day)}),Go.map(C=>{const{key:S,label:_,color:P}=C,A=p.byProvider[S];return l(A)<=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:P}}),_,": ",s==="cost"?as(A.costUsd):nt(A.tokens)]},S)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?as(p.costUsd):nt(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 x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>i(null),b=r.jsx("line",{x1:0,y1:f,x2:Sl,y2:f,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==o||e[17]!==d||e[18]!==u||e[19]!==l){let C;e[21]!==m||e[22]!==o||e[23]!==d||e[24]!==u||e[25]!==l?(C=(S,_)=>{const P=_*u+(u-m)/2;let A=f;const T=o===_;return r.jsxs("g",{onMouseEnter:()=>i(_),children:[r.jsx("rect",{x:_*u,y:0,width:u,height:f,fill:"transparent"}),T&&r.jsx("rect",{x:_*u,y:0,width:u,height:f,fill:"var(--foreground)",opacity:.05,rx:2}),Go.map(E=>{const{key:M,color:I}=E,R=l(S.byProvider[M]);if(R<=0)return null;const $=R/d*(f-6);return A=A-$,r.jsx("rect",{x:P,y:A,width:m,height:Math.max(1,$-1.5),rx:1.5,fill:I,opacity:T?1:.85},M)})]},S.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=u,e[25]=l,e[26]=C):C=e[26],w=t.map(C),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 C;e[30]!==t.length||e[31]!==u?(C=(S,_)=>_===0||_===t.length-1||t.length>10&&_%7===0&&_<t.length-3?r.jsx("text",{x:_*u+u/2,y:kl-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:op(S.day)},S.day):null,e[30]=t.length,e[31]=u,e[32]=C):C=e[32],y=t.map(C),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 ${Sl} ${kl}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,w,y]}),e[33]=g,e[34]=w,e[35]=y,e[36]=j):j=e[36];let k;e[37]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:Go.map(r9)}),e[37]=k):k=e[37];let N;return e[38]!==h||e[39]!==j?(N=r.jsxs("div",{className:"relative",children:[h,j,k]}),e[38]=h,e[39]=j,e[40]=N):N=e[40],N}function r9(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 Nl(n){const e=B.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 i9(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=q8(t,!0),[l,c]=v.useState("cost");let d;e[0]!==s?(d=s?n9(s):null,e[0]=s,e[1]=d):d=e[1];const f=d;if(i){let F;e[2]!==a?(F=r.jsx(J,{variant:"outline",size:"sm",onClick:a,children:"Retry"}),e[2]=a,e[3]=F):F=e[3];let z;return e[4]!==i||e[5]!==F?(z=r.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[i,F]}),e[4]=i,e[5]=F,e[6]=z):z=e[6],z}if(!f||!s){let F;return e[7]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[r.jsx(Bt,{className:"size-4"})," Scanning transcripts…"]}),e[7]=F):F=e[7],F}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"?as(f.costUsd):nt(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 x;e[16]!==s.distinctSessions||e[17]!==g?(x=r.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.distinctSessions," sessions · ",g]}),e[16]=s.distinctSessions,e[17]=g,e[18]=x):x=e[18];let b;e[19]!==h||e[20]!==x?(b=r.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=b):b=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(F=>r.jsx(J,{variant:l===F?"secondary":"ghost",size:"xs",onClick:()=>c(F),children:F==="cost"?"Cost":"Tokens"},F))}),e[23]=l,e[24]=y):y=e[24];let j;e[25]!==f.byProvider||e[26]!==l?(j=Go.map(F=>{const{key:z,label:H}=F,U=f.byProvider[z];return U.costUsd===0&&U.tokens===0?null:r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[H,": ",l==="cost"?as(U.costUsd):nt(U.tokens)]},z)}),e[25]=f.byProvider,e[26]=l,e[27]=j):j=e[27];let k;e[28]!==y||e[29]!==j?(k=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[y,j]}),e[28]=y,e[29]=j,e[30]=k):k=e[30];let N;e[31]!==k||e[32]!==b?(N=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,k]}),e[31]=k,e[32]=b,e[33]=N):N=e[33];let C;e[34]!==f.days||e[35]!==l?(C=r.jsx(o9,{days:f.days,metric:l}),e[34]=f.days,e[35]=l,e[36]=C):C=e[36];let S;e[37]!==f.tokens?(S=nt(f.tokens),e[37]=f.tokens,e[38]=S):S=e[38];let _;e[39]!==S?(_=r.jsx(Nl,{label:"Processed tokens",value:S}),e[39]=S,e[40]=_):_=e[40];let P;e[41]!==f.cacheSavingsUsd?(P=as(f.cacheSavingsUsd),e[41]=f.cacheSavingsUsd,e[42]=P):P=e[42];let A;e[43]!==P?(A=r.jsx(Nl,{label:"Cache savings",value:P}),e[43]=P,e[44]=A):A=e[44];const T=String(s.scannedFiles);let E;e[45]!==T?(E=r.jsx(Nl,{label:"Files scanned",value:T}),e[45]=T,e[46]=E):E=e[46];let M;e[47]!==_||e[48]!==A||e[49]!==E?(M=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[_,A,E]}),e[47]=_,e[48]=A,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 F;e[55]!==f.costUsd?(F=z=>{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=Go.find(U=>U.key===z.provider))==null?void 0:H.color}}),z.model]})}),r.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:z.unpriced?"—":as(z.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:f.costUsd>0&&!z.unpriced?`${(z.costUsd/f.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:nt(z.tokens)})]},`${z.provider}:${z.model}`)},e[55]=f.costUsd,e[56]=F):F=e[56],R=f.models.map(F),e[52]=f.costUsd,e[53]=f.models,e[54]=R}else R=e[54];let $;e[57]!==R?($=r.jsxs("table",{className:"w-full text-sm",children:[I,r.jsx("tbody",{children:R})]}),e[57]=R,e[58]=$):$=e[58];const D=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let O;e[59]!==D?(O=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",D," ","— not what a subscription bills."]}),e[59]=D,e[60]=O):O=e[60];let L;return e[61]!==N||e[62]!==C||e[63]!==M||e[64]!==$||e[65]!==O||e[66]!==m?(L=r.jsxs("div",{className:m,children:[N,C,M,$,O]}),e[61]=N,e[62]=C,e[63]=M,e[64]=$,e[65]=O,e[66]=m,e[67]=L):L=e[67],L}function a9(n){const e=B.c(15),{open:t,onOpenChange:s}=n,[o,i]=v.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(Xn,{children:"API usage"}),r.jsx(Jn,{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=e9.map(m=>r.jsx(J,{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(ks,{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(i9,{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(Yn,{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(Gn,{open:t,onOpenChange:s,children:f}),e[11]=s,e[12]=t,e[13]=f,e[14]=u):u=e[14],u}const l9=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,c9=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,Cl=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,d9=[new RegExp(`${Cl}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${Cl}'([^']*)'`),new RegExp(`${Cl}(\\S+)`)];function u9(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(Array.isArray(e)){const a=e.filter(l=>typeof l=="string");return[a.join(" "),...a]}const t=n.source;if(typeof t!="string")return[];const s=[],o=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*"((?:\\.|[^"\\])*)"/g;for(const a of t.matchAll(o))try{s.push(JSON.parse(`"${a[1]}"`))}catch{}const i=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*`([^`]*)`/g;for(const a of t.matchAll(i))s.push(a[1]);return s}function f9(n){return u9(n).find(e=>c9.test(e))??null}function m9(n){for(const e of d9){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function p9(){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=l9.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:m9(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function h9(n){const e=p9();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=f9(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function g9(...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 Qs="flex h-8 items-center px-0.5",x9=v.memo(function(e){var $t;const t=B.c(124),{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:x,workflowCount:b,onToggleSidebar:w,onToggleStats:y,onToggleWorktrees:j,onToggleFileChanges:k,onKillAll:N,onOpenSettings:C,showConfig:S,onToggleConfig:_,showMission:P,onToggleMission:A}=e,T=o===void 0?s:o,{config:E}=Rt(),{networkUrl:M,defaultAgentKind:I}=E,{session:R,sessionSource:$,isLive:D}=it(),O=vd(),L=yn("viewUsage"),[F,z]=v.useState(!1),[H,U]=v.useState(!1),[W,K]=go(),q=R==null?void 0:R.turns;let Y;t[0]!==(O==null?void 0:O.sessions)||t[1]!==(R==null?void 0:R.sessionId)?(Y=($t=O==null?void 0:O.sessions.find(Vt=>Vt.sessionId===(R==null?void 0:R.sessionId)))==null?void 0:$t.pullRequests,t[0]=O==null?void 0:O.sessions,t[1]=R==null?void 0:R.sessionId,t[2]=Y):Y=t[2];const V=Y;let Q;t[3]!==V||t[4]!==q?(Q=g9(h9(q??[]),V),t[3]=V,t[4]=q,t[5]=Q):Q=t[5];const Z=Q;let X;t[6]!==I||t[7]!==$?(X=$?$.agentKind??St($.dirName):I,t[6]=I,t[7]=$,t[8]=X):X=t[8];const ee=X;let oe;t[9]!==$?(oe=$?vs($.fileName)!==null:!1,t[9]=$,t[10]=oe):oe=t[10];const se=oe;let re;t[11]!==K||t[12]!==R||t[13]!==($==null?void 0:$.agentKind)||t[14]!==($==null?void 0:$.dirName)?(re=function(){if(!R)return;const Wt=($==null?void 0:$.agentKind)??St(($==null?void 0:$.dirName)??null);K(yh(Wt,R.sessionId,R.cwd))},t[11]=K,t[12]=R,t[13]=$==null?void 0:$.agentKind,t[14]=$==null?void 0:$.dirName,t[15]=re):re=t[15];const ie=re;let ae;t[16]!==M?(ae=function(){M&&vr(M).then(v9)},t[16]=M,t[17]=ae):ae=t[17];const te=ae;let he,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"}),he=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]=he,t[19]=me):(he=t[18],me=t[19]);const le=!T&&"window-inset-start";let xe;t[20]!==le?(xe=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",le),t[20]=le,t[21]=xe):xe=t[21];let ge;t[22]!==w||t[23]!==s||t[24]!==i?(ge=!s&&r.jsx(b9,{icon:Vv,label:`Show sidebar (${i})`,onClick:w}),t[22]=w,t[23]=s,t[24]=i,t[25]=ge):ge=t[25];let ce;t[26]!==se||t[27]!==g||t[28]!==R?(ce=R&&se&&g&&r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:g,className:G(Cn,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(Ze,{className:"size-3 rotate-180"}),"Main"]}),t[26]=se,t[27]=g,t[28]=R,t[29]=ce):ce=t[29];let we;t[30]!==W||t[31]!==u||t[32]!==ie||t[33]!==D||t[34]!==p||t[35]!==m||t[36]!==h||t[37]!==Z||t[38]!==R||t[39]!==$?(we=R&&r.jsx(w8,{session:R,sessionSource:$,isLive:D,pullRequests:Z,copied:W,creatingSession:u,onCopyResume:ie,onNewSession:m,onDuplicateSession:p,onOpenTerminal:h}),t[30]=W,t[31]=u,t[32]=ie,t[33]=D,t[34]=p,t[35]=m,t[36]=h,t[37]=Z,t[38]=R,t[39]=$,t[40]=we):we=t[40];let pe;t[41]!==x||t[42]!==R||t[43]!==b?(pe=R&&x&&(b??0)>0&&r.jsxs(J,{variant:"ghost",size:"xs",className:G(Cn,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:x,children:[r.jsx(ch,{className:"size-3"}),"Workflows",r.jsx(Me,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:b})]}),t[41]=x,t[42]=R,t[43]=b,t[44]=pe):pe=t[44];let ue;t[45]!==xe||t[46]!==ge||t[47]!==ce||t[48]!==we||t[49]!==pe?(ue=r.jsxs("div",{className:xe,children:[ge,ce,we,pe]}),t[45]=xe,t[46]=ge,t[47]=ce,t[48]=we,t[49]=pe,t[50]=ue):ue=t[50];let je,Ne,Re;t[51]===Symbol.for("react.memo_cache_sentinel")?(je=r.jsx("div",{className:G(Cn,Qs,"empty:hidden"),children:r.jsx(qE,{})}),Ne=r.jsx("div",{className:G(Cn,Qs,"empty:hidden"),children:r.jsx(e8,{})}),Re=G(Cn,Qs,"empty:hidden"),t[51]=je,t[52]=Ne,t[53]=Re):(je=t[51],Ne=t[52],Re=t[53]);let Te;t[54]!==ee?(Te=r.jsx("div",{className:Re,children:r.jsx(K8,{agentKind:ee})}),t[54]=ee,t[55]=Te):Te=t[55];let Pe;t[56]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsx("div",{className:G(Cn,Qs,"empty:hidden"),children:r.jsx(Md,{})}),t[56]=Pe):Pe=t[56];let Oe;t[57]!==ee||t[58]!==R?(Oe=R&&Ut(ee).sharing&&ut("share")&&r.jsx("div",{className:G(Cn,Qs),children:r.jsx(M8,{sessionId:R.sessionId})}),t[57]=ee,t[58]=R,t[59]=Oe):Oe=t[59];let Fe;t[60]===Symbol.for("react.memo_cache_sentinel")?(Fe=G(Cn,Qs),t[60]=Fe):Fe=t[60];let ze;t[61]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(Mn,{render:r.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(dh,{"data-icon":"inline-start"})}),t[61]=ze):ze=t[61];let Be;t[62]===Symbol.for("react.memo_cache_sentinel")?(Be=r.jsx(gs,{children:"Workspace"}),t[62]=Be):Be=t[62];let _e;t[63]!==A||t[64]!==P?(_e=A&&r.jsxs(ct,{onClick:A,children:[r.jsx(Gv,{}),"Mission Control",P&&r.jsx(dt,{className:"ml-auto"})]}),t[63]=A,t[64]=P,t[65]=_e):_e=t[65];let He;t[66]!==_||t[67]!==S?(He=_&&r.jsxs(ct,{onClick:_,children:[r.jsx(Yv,{}),"Config",S&&r.jsx(dt,{className:"ml-auto"})]}),t[66]=_,t[67]=S,t[68]=He):He=t[68];let Ie;t[69]!==j||t[70]!==l?(Ie=j&&r.jsxs(ct,{onClick:j,children:[r.jsx(vo,{}),"Worktrees",l&&r.jsx(dt,{className:"ml-auto"})]}),t[69]=j,t[70]=l,t[71]=Ie):Ie=t[71];let Ce;t[72]!==d||t[73]!==k||t[74]!==c?(Ce=d&&k&&r.jsxs(ct,{onClick:k,children:[r.jsx(xr,{}),"File changes",c&&r.jsx(dt,{className:"ml-auto"})]}),t[72]=d,t[73]=k,t[74]=c,t[75]=Ce):Ce=t[75];let de;t[76]!==y||t[77]!==R||t[78]!==a?(de=R&&r.jsxs(ct,{onClick:y,children:[a?r.jsx(Xv,{}):r.jsx(Jv,{}),"Session details",a&&r.jsx(dt,{className:"ml-auto"})]}),t[76]=y,t[77]=R,t[78]=a,t[79]=de):de=t[79];let Ee;t[80]!==_e||t[81]!==He||t[82]!==Ie||t[83]!==Ce||t[84]!==de?(Ee=r.jsxs(Ft,{children:[Be,_e,He,Ie,Ce,de]}),t[80]=_e,t[81]=He,t[82]=Ie,t[83]=Ce,t[84]=de,t[85]=Ee):Ee=t[85];let Ae;t[86]===Symbol.for("react.memo_cache_sentinel")?(Ae=r.jsx(ao,{}),t[86]=Ae):Ae=t[86];let Le;t[87]!==L?(Le=L&&r.jsxs(ct,{onClick:()=>z(!0),children:[r.jsx(uh,{}),"Usage & cost…"]}),t[87]=L,t[88]=Le):Le=t[88];let ne;t[89]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsxs(ct,{onClick:()=>U(!0),children:[r.jsx(fh,{}),"Server monitor…"]}),t[89]=ne):ne=t[89];let fe;t[90]!==te||t[91]!==M?(fe=M&&r.jsxs(ct,{onClick:te,children:[r.jsx(Il,{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[90]=te,t[91]=M,t[92]=fe):fe=t[92];let Se;t[93]!==Le||t[94]!==fe?(Se=r.jsxs(Ft,{children:[Le,ne,fe]}),t[93]=Le,t[94]=fe,t[95]=Se):Se=t[95];let $e;t[96]===Symbol.for("react.memo_cache_sentinel")?($e=r.jsx(ao,{}),t[96]=$e):$e=t[96];let Ue;t[97]===Symbol.for("react.memo_cache_sentinel")?(Ue=r.jsx(Qv,{}),t[97]=Ue):Ue=t[97];let We;t[98]!==C?(We=r.jsx(Ft,{children:r.jsxs(ct,{onClick:C,children:[Ue,"Settings"]})}),t[98]=C,t[99]=We):We=t[99];let Xe;t[100]!==f||t[101]!==N?(Xe=ut("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(ao,{}),r.jsx(Ft,{children:r.jsxs(ct,{variant:"destructive",onClick:N,disabled:f,children:[r.jsx(qv,{}),f?"Stopping processes…":"Stop all agent processes"]})})]}),t[100]=f,t[101]=N,t[102]=Xe):Xe=t[102];let Je;t[103]!==Ee||t[104]!==Se||t[105]!==We||t[106]!==Xe?(Je=r.jsx("div",{className:Fe,children:r.jsxs(Rn,{children:[ze,r.jsxs(In,{align:"end",sideOffset:6,className:"w-64",children:[Ee,Ae,Se,$e,We,Xe]})]})}),t[103]=Ee,t[104]=Se,t[105]=We,t[106]=Xe,t[107]=Je):Je=t[107];let De;t[108]!==Te||t[109]!==Oe||t[110]!==Je?(De=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[je,Ne,Te,Pe,Oe,Je]}),t[108]=Te,t[109]=Oe,t[110]=Je,t[111]=De):De=t[111];let qe;t[112]!==ue||t[113]!==De?(qe=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:[ue,De]}),t[112]=ue,t[113]=De,t[114]=qe):qe=t[114];let ot;t[115]!==L||t[116]!==F?(ot=L&&r.jsx(a9,{open:F,onOpenChange:z}),t[115]=L,t[116]=F,t[117]=ot):ot=t[117];let lt;t[118]!==H?(lt=r.jsx(u8,{open:H,onOpenChange:U}),t[118]=H,t[119]=lt):lt=t[119];let bt;return t[120]!==qe||t[121]!==ot||t[122]!==lt?(bt=r.jsxs(r.Fragment,{children:[me,he,qe,ot,lt]}),t[120]=qe,t[121]=ot,t[122]=lt,t[123]=bt):bt=t[123],bt});function b9(n){const e=B.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=G(Cn,"size-8 shrink-0"),e[0]=i):i=e[0];let a;e[1]!==s||e[2]!==o?(a=r.jsx(J,{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(Pt,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(At,{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(Et,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=f):f=e[13],f}function v9(n){n&&_s.success("Copied network URL")}const y9=150,w9="(prefers-reduced-motion: reduce)";function j9(){if(typeof window.matchMedia!="function")return!1;try{return window.matchMedia(w9).matches}catch{return!1}}function S9(n){const e=B.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(k9,{side:t,children:s}),e[2]=s,e[3]=t,e[4]=l):l=e[4],l}function k9(n){const e=B.c(26),{side:t,children:s}=n,[o,i]=v.useState(!1),[a,l]=v.useState(!1),c=v.useRef(0),d=v.useRef(0),f=v.useRef(0),u=v.useRef(null),m=v.useRef(null),p=v.useRef(!1),h=v.useId();let g,x;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>()=>{clearTimeout(c.current),clearTimeout(d.current),clearTimeout(f.current)},x=[],e[0]=g,e[1]=x):(g=e[0],x=e[1]),v.useEffect(g,x);let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{clearTimeout(f.current),l(!0),i(!0)},e[2]=b):b=e[2];const w=b;let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{if(clearTimeout(f.current),i(!1),j9()){l(!1);return}f.current=window.setTimeout(()=>{f.current=0,l(!1)},y9)},e[3]=y):y=e[3];const j=y;let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{clearTimeout(d.current),clearTimeout(c.current),c.current=window.setTimeout(w,200)},e[4]=k):k=e[4];const N=k;let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{clearTimeout(d.current),clearTimeout(c.current),w()},e[5]=C):C=e[5];const S=C;let _;e[6]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{if(p.current){p.current=!1;return}S()},e[6]=_):_=e[6];const P=_;let A;e[7]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{clearTimeout(c.current),d.current=window.setTimeout(j,300)},e[7]=A):A=e[7];const T=A;let E;e[8]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{var K,q;const W=document.activeElement;(K=u.current)!=null&&K.contains(W)||(q=m.current)!=null&&q.contains(W)||T()},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 K=W.relatedTarget;(q=u.current)!=null&&q.contains(K)||(Y=m.current)!=null&&Y.contains(K)||T()},e[9]=I):I=e[9];const R=I;let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=W=>{W.key==="Escape"&&(W.preventDefault(),clearTimeout(c.current),clearTimeout(d.current),j(),p.current=!0,requestAnimationFrame(()=>{var K;return(K=u.current)==null?void 0:K.focus()}))},e[10]=$):$=e[10];const D=$,O=`Reveal ${t} sidebar`,L=`Reveal ${t} sidebar`;let F;e[11]===Symbol.for("react.memo_cache_sentinel")?(F=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]=F):F=e[11];let z;e[12]!==o||e[13]!==h||e[14]!==O||e[15]!==L?(z=r.jsx(J,{ref:u,type:"button",variant:"ghost","aria-label":O,"aria-controls":h,"aria-expanded":o,title:L,className:"group relative z-10 h-auto w-1.5 shrink-0 rounded-none p-0 focus-visible:ring-inset",onMouseEnter:N,onMouseLeave:M,onFocus:P,onBlur:R,onClick:S,children:F}),e[12]=o,e[13]=h,e[14]=O,e[15]=L,e[16]=z):z=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:N,onMouseLeave:M,onFocusCapture:S,onBlurCapture:R,onKeyDown:D,children:s}),e[17]=s,e[18]=a,e[19]=o,e[20]=h,e[21]=t,e[22]=H):H=e[22];let U;return e[23]!==z||e[24]!==H?(U=r.jsxs(r.Fragment,{children:[z,H]}),e[23]=z,e[24]=H,e[25]=U):U=e[25],U}const N9=v.memo(function(e){const t=B.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(Ja,{icon:yo,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(Ja,{icon:bn,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(Ja,{icon:Zv,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}),cc=new Map;let _l=null,Tl=null;async function C9(){try{const n=await ye("/api/usage-cost/rates");if(!n.ok)return cc;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return cc}}function C0(){const[n,e]=v.useState(_l??cc);return v.useEffect(()=>{if(_l!==null)return;let t=!0;return Tl??(Tl=C9().then(s=>(s.size>0&&(_l=s),Tl=null,s))),Tl.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function _9(n,e){return n.map((t,s)=>{var p,h,g,x;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=_j(t),f=Tj(t),u=Math.max(d+f,((x=t.tokenUsage)==null?void 0:x.output_tokens)??0),m=t.tokenUsage?N0(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 T9(n){const e=B.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=nt(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=nt(t.cacheRead),e[6]=t.cacheRead,e[7]=a):a=e[7];let l;e[8]!==t.cacheWrite?(l=nt(t.cacheWrite),e[8]=t.cacheWrite,e[9]=l):l=e[9];let c;e[10]!==t.newInput?(c=nt(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=nt(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:["(",nt(t.thinkingTokens)," thinking, ",nt(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:as(t.cost)})]}),e[29]=t.cost,e[30]=g):g=e[30];let x;e[31]!==t.hasSubAgents?(x=t.hasSubAgents&&r.jsx("span",{className:"text-warning",children:"Has sub-agent activity"}),e[31]=t.hasSubAgents,e[32]=x):x=e[32];let b;e[33]!==h||e[34]!==g||e[35]!==x||e[36]!==f?(b=r.jsxs("div",{className:"flex flex-col gap-0.5 text-muted-foreground",children:[f,h,g,x]}),e[33]=h,e[34]=g,e[35]=x,e[36]=f,e[37]=b):b=e[37];let w;return e[38]!==s||e[39]!==b?(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,b]})}),e[38]=s,e[39]=b,e[40]=w):w=e[40],w}function E9(n){const e=B.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,x=s-10;let b;e[12]!==g||e[13]!==x?(b=r.jsx("rect",{x:g,y:x,width:6,height:6,rx:1.5,fill:"var(--muted-foreground)",opacity:.45}),e[12]=g,e[13]=x,e[14]=b):b=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 k=t+155,N=s-7;let C;e[18]!==k||e[19]!==N?(C=r.jsx("circle",{cx:k,cy:N,r:2,fill:"var(--warning)",opacity:.8}),e[18]=k,e[19]=N,e[20]=C):C=e[20];const S=t+162,_=s-4;let P;e[21]!==S||e[22]!==_?(P=r.jsx("text",{x:S,y:_,className:"fill-muted-foreground text-xs",children:"Agent"}),e[21]=S,e[22]=_,e[23]=P):P=e[23];let A;return e[24]!==h||e[25]!==b||e[26]!==j||e[27]!==i||e[28]!==C||e[29]!==P||e[30]!==c||e[31]!==u?(A=r.jsxs(r.Fragment,{children:[i,c,u,h,b,j,C,P]}),e[24]=h,e[25]=b,e[26]=j,e[27]=i,e[28]=C,e[29]=P,e[30]=c,e[31]=u,e[32]=A):A=e[32],A}function P9(n){const e=B.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,x=t.visibleTokens/c*l;let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={cursor:"crosshair"},e[0]=b):b=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 k;e[18]!==o||e[19]!==a||e[20]!==m||e[21]!==p||e[22]!==s||e[23]!==d?(k=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]=k):k=e[24];let N;e[25]!==o||e[26]!==a||e[27]!==m||e[28]!==p||e[29]!==s||e[30]!==d||e[31]!==h?(N=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]=N):N=e[32];let C;e[33]!==o||e[34]!==a||e[35]!==s||e[36]!==d||e[37]!==g?(C=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]=C):C=e[38];let S;e[39]!==o||e[40]!==a||e[41]!==s||e[42]!==d||e[43]!==g||e[44]!==x?(S=x>0&&r.jsx("rect",{x:s+o+1,y:a-g-x,width:o,height:x,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]=x,e[45]=S):S=e[45];let _;e[46]!==a||e[47]!==t.hasSubAgents||e[48]!==i||e[49]!==s?(_=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]=_):_=e[50];let P;return e[51]!==f||e[52]!==w||e[53]!==y||e[54]!==j||e[55]!==k||e[56]!==N||e[57]!==C||e[58]!==S||e[59]!==_?(P=r.jsxs("g",{onMouseEnter:f,style:b,children:[w,y,j,k,N,C,S,_]}),e[51]=f,e[52]=w,e[53]=y,e[54]=j,e[55]=k,e[56]=N,e[57]=C,e[58]=S,e[59]=_,e[60]=P):P=e[60],P}const _0=280,dc=130,xi=16,A9=22,Es=36,R9=8,ii=_0-Es-R9,rp=dc-xi-A9;function M9(n){const e=B.c(34),{turns:t}=n,[s,o]=v.useState(null),i=C0();let a;e[0]!==i||e[1]!==t?(a=_9(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($9),...l.map(I9)),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,ii/l.length)),u=Math.max(2,(f-1)/2),m=xi+rp,p=s!==null?l[s]:null;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Qn,{children:"Input / Output Per Turn"}),e[5]=h):h=e[5];let g;e[6]!==p?(g=p&&r.jsx(T9,{data:p}),e[6]=p,e[7]=g):g=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),e[8]=x):x=e[8];let b;e[9]!==d?(b=nt(d),e[9]=d,e[10]=b):b=e[10];let w;e[11]!==b?(w=r.jsx("text",{x:Es-4,y:xi,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:b}),e[11]=b,e[12]=w):w=e[12];let y,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("text",{x:Es-4,y:m,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:"0"}),j=r.jsx("line",{x1:Es,y1:m,x2:Es+ii,y2:m,stroke:"var(--border)",strokeWidth:.5}),e[13]=y,e[14]=j):(y=e[13],j=e[14]);let k;if(e[15]!==u||e[16]!==l||e[17]!==f||e[18]!==s||e[19]!==d){let _;e[21]!==u||e[22]!==l.length||e[23]!==f||e[24]!==s||e[25]!==d?(_=(P,A)=>{const T=Es+(l.length===1?(ii-f)/2:A/(l.length-1)*(ii-f));return r.jsx(P9,{data:P,groupX:T,barW:u,groupW:f,baseY:m,chartH:rp,maxVal:d,isHovered:s===A,onHover:()=>o(A),padTop:xi},A)},e[21]=u,e[22]=l.length,e[23]=f,e[24]=s,e[25]=d,e[26]=_):_=e[26],k=l.map(_),e[15]=u,e[16]=l,e[17]=f,e[18]=s,e[19]=d,e[20]=k}else k=e[20];let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(E9,{padLeft:Es,svgHeight:dc}),e[27]=N):N=e[27];let C;e[28]!==k||e[29]!==w?(C=r.jsxs("svg",{width:"100%",viewBox:`0 0 ${_0} ${dc}`,onMouseLeave:x,children:[w,y,j,k,N]}),e[28]=k,e[29]=w,e[30]=C):C=e[30];let S;return e[31]!==C||e[32]!==g?(S=r.jsxs("section",{className:"relative",children:[h,g,C]}),e[31]=C,e[32]=g,e[33]=S):S=e[33],S}function I9(n){return n.totalOutput}function $9(n){return n.totalInput}const ip=280,ap=32;function O9(n){const e=B.c(19),{turns:t}=n,[s,o]=v.useState(null);let i;e[0]!==t?(i=Math.max(1,...t.map(D9)),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,ip/t.length)),c=l*t.length;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Qn,{children:"Activity Heatmap"}),e[2]=d):d=e[2];const f=`0 0 ${Math.max(ip,c)} ${ap}`;let u;if(e[3]!==a||e[4]!==l||e[5]!==t){let g;e[7]!==a||e[8]!==l?(g=(x,b)=>{const y=.1+x.toolCalls.length/a*.9;return r.jsx("rect",{x:b*l,y:0,width:l-1,height:ap,rx:2,fill:"var(--foreground)",opacity:y,onMouseEnter:()=>o(b),onMouseLeave:()=>o(null),className:"cursor-pointer"},b)},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 D9(n){return n.toolCalls.length}function L9(n){const e=B.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(F9),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(Qn,{children:"Models"}),e[2]=i):i=e[2];let a;e[3]!==o?(a=o.map(z9),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 z9(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 F9(n,e){const[,t]=n,[,s]=e;return s-t}const B9=["agent","skill","plugin","mcpServer","mcpTool"],U9={agent:"Agents",skill:"Skills",plugin:"Plugins",mcpServer:"MCP servers",mcpTool:"MCP tools"},ai="Unattributed";function lp(n){return n.inputTokens+n.outputTokens}function W9(n,e){var i;const t=new Map;for(const a of n){const l=((i=a.attribution)==null?void 0:i[e])??ai;let c=t.get(l);c||(c={name:l,turns:0,inputTokens:0,outputTokens:0,isUnattributed:l===ai},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(ai);s&&t.delete(ai);const o=[...t.values()].sort((a,l)=>lp(l)-lp(a));return s&&o.push(s),o}function H9(n){return B9.filter(e=>n.some(t=>{var s;return(s=t.attribution)==null?void 0:s[e]}))}function K9(n){const e=B.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=nt(t.inputTokens),e[0]=t.inputTokens,e[1]=f):f=e[1];let u;e[2]!==t.outputTokens?(u=nt(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 x;e[7]!==t.turns||e[8]!==g?(x=r.jsxs("span",{children:[t.turns," ",g]}),e[7]=t.turns,e[8]=g,e[9]=x):x=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"opacity-40",children:"·"}),e[10]=b):b=e[10];let w;e[11]!==o?(w=nt(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]!==x?(j=r.jsxs("span",{className:"ml-2 flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground",children:[x,b,y]}),e[15]=y,e[16]=x,e[17]=j):j=e[17];let k;e[18]!==j||e[19]!==h?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[h,j]}),e[18]=j,e[19]=h,e[20]=k):k=e[20];const N=t.isUnattributed?"rounded-xs bg-info/35":"rounded-xs bg-info/85",C=`${a*100}%`;let S;e[21]!==C?(S={width:C},e[21]=C,e[22]=S):S=e[22];let _;e[23]!==N||e[24]!==S?(_=r.jsx("div",{className:N,style:S}),e[23]=N,e[24]=S,e[25]=_):_=e[25];const P=t.isUnattributed?"rounded-xs bg-success/35":"rounded-xs bg-success/70",A=`${l*100}%`;let T;e[26]!==A?(T={width:A},e[26]=A,e[27]=T):T=e[27];let E;e[28]!==P||e[29]!==T?(E=r.jsx("div",{className:P,style:T}),e[28]=P,e[29]=T,e[30]=E):E=e[30];let M;e[31]!==_||e[32]!==E?(M=r.jsxs("div",{className:"mt-1.5 flex h-1 gap-[2px]","aria-hidden":"true",children:[_,E]}),e[31]=_,e[32]=E,e[33]=M):M=e[33];let I;return e[34]!==k||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:[k,M]}),e[34]=k,e[35]=M,e[36]=m,e[37]=I):I=e[37],I}function q9(){const n=B.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 V9(n){const e=B.c(25),{turns:t}=n;let s;e[0]!==t?(s=H9(t),e[0]=t,e[1]=s):s=e[1];const o=s,[i,a]=v.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?W9(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(Y9)),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(Qn,{children:"Attribution"}),e[10]=p):p=e[10];let h;e[11]!==c||e[12]!==o?(h=o.length>1&&r.jsx($x,{"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(G9)}),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(K9,{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 x;e[19]!==g?(x=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]=x):x=e[20];let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(q9,{}),e[21]=b):b=e[21];let w;return e[22]!==h||e[23]!==x?(w=r.jsxs("section",{children:[p,h,x,b]}),e[22]=h,e[23]=x,e[24]=w):w=e[24],w}function G9(n){return r.jsx(Ox,{value:n,children:U9[n]},n)}function Y9(n){return n.inputTokens+n.outputTokens}function X9(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 J9(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=X9(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(Qn,{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(J,{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 cp(n){const e=B.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||jd(t,s),e[0]=t,e[1]=o,e[2]=s,e[3]=h):h=e[3];const g=h;let x;e[4]!==d?(x=d==null?null:d<1e3?`${d}ms`:`${(d/1e3).toFixed(d>=1e4?0:1)}s`,e[4]=d,e[5]=x):x=e[5];const b=x;let w;e[6]!==c?(w=c==="running"?r.jsx(rt,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?r.jsx(Un,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(zs,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(nh,{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 k;e[8]!==j?(k=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]=k):k=e[9];let N;e[10]!==g?(N=r.jsx(Me,{variant:"outline",children:g}),e[10]=g,e[11]=N):N=e[11];let C;e[12]!==l?(C=l&&r.jsx(Me,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let S;e[14]!==a?(S=a&&r.jsx(Me,{children:"Viewing"}),e[14]=a,e[15]=S):S=e[15];const _=c==="running"?"active":c;let P;e[16]!==_?(P=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:_}),e[16]=_,e[17]=P):P=e[17];let A;e[18]!==y||e[19]!==P||e[20]!==N||e[21]!==C||e[22]!==S?(A=r.jsxs("div",{className:"flex items-center gap-1.5",children:[y,N,C,S,P]}),e[18]=y,e[19]=P,e[20]=N,e[21]=C,e[22]=S,e[23]=A):A=e[23];let T;e[24]!==i?(T=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=T):T=e[25];let E;e[26]!==b||e[27]!==f?(E=(b||f!=null)&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Xi,{className:"size-2.5","data-icon":"inline-start"}),b]}),f!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Ki,{className:"size-2.5","data-icon":"inline-start"}),f," tools"]})]}),e[26]=b,e[27]=f,e[28]=E):E=e[28];let M;e[29]!==u||e[30]!==m||e[31]!==A||e[32]!==T||e[33]!==E?(M=r.jsxs(J,{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:[A,T,E]}),e[29]=u,e[30]=m,e[31]=A,e[32]=T,e[33]=E,e[34]=M):M=e[34];let I;e[35]!==g||e[36]!==p?(I=p&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(jt,{"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]!==k?(R=r.jsxs("div",{className:k,children:[M,I]}),e[38]=M,e[39]=I,e[40]=k,e[41]=R):R=e[41],R}function Q9(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 uc(n){return n.split(`
|
|
119
119
|
`).map(e=>e.trim()).find(Boolean)??""}function Z9(n){return n.name==="Task"||n.name==="Agent"}function eP(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=Q9(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:uc(((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(!Z9(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:uc(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 tP({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=yd(),i=v.useMemo(()=>{if(!e)return null;const w=vs(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=v.useMemo(()=>eP(n,o),[n,o]),l=v.useRef(a);v.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=v.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=v.useMemo(()=>d?t.filter(w=>w.parentSessionId===d):t,[t,d]),u=v.useMemo(()=>new Map(c.map(w=>[w.agentId,w])),[c]),m=v.useMemo(()=>{const w=new Set(f.map(y=>y.agentId));return c.filter(y=>!w.has(y.agentId))},[f,c]),p=v.useMemo(()=>[...f].sort((w,y)=>y.modifiedAt-w.modifiedAt),[f]),h=v.useMemo(()=>[...m].reverse(),[m]),g=f.length+m.length;if(g===0)return null;const x=w=>{ye(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(w)}`,{method:"DELETE"})},b=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(Qn,{children:["Agents (",g,")"]}),i&&s&&r.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>s(i.dirName,i.parentFileName),className:"mb-2 w-full justify-start",children:[r.jsx(Ze,{"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=uc(w.preview??""),k=u.get(w.agentId);return r.jsx(cp,{agentId:w.agentId,subagentType:(k==null?void 0:k.subagentType)??null,agentName:(k==null?void 0:k.agentName)??null,preview:(k==null?void 0:k.preview)||(j!==w.agentId?j:""),colorIndex:y,isViewing:b===w.agentId,isBackground:!0,status:w.isActive?"running":(k==null?void 0:k.status)==="failed"?"failed":"done",durationMs:k==null?void 0:k.durationMs,toolUseCount:k==null?void 0:k.toolUseCount,disabled:!s,onStop:w.isActive?()=>x(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(cp,{agentId:w.agentId,subagentType:w.subagentType,agentName:w.agentName,preview:w.preview,colorIndex:p.length+y,isViewing:b===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 nP(n,e){return`${n.id}-${e}`}function sP(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=v.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(Qn,{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=wa(u.userMessage),h=o===m;return r.jsxs(J,{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?pn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:u.toolCalls.length>0&&r.jsx(Me,{variant:"secondary",className:"font-normal",children:u.toolCalls.length})})]},nP(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 oP(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"?pn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?pn(e.query,40):e.url&&typeof e.url=="string"?pn(e.url,40):pn(RT(n),40)}function rP(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:N0(e,t.model,s)/t.toolCalls.length})}function iP(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=_a(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 aP(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=C0();let i;e[0]!==o||e[1]!==t?(i=rP(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=iP(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(Qn,{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(kt,{children:[r.jsxs(ln,{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(Ze,{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:as(g.estimatedCost)}),r.jsx(Me,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(Nt,{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((x,b)=>{const{tc:w,turnIndex:y}=x,j=oP(w);return r.jsx("div",{children:r.jsxs(J,{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(jn,{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}-${b}`)}),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 lP(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Rt(),{searchQuery:i,expandAll:a}=s,{actions:l}=it(),{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(Ji,{"data-icon":"inline-start"}):r.jsx(Yi,{"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(J,{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(es,{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 x;e[13]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(wn,{align:"inline-start",children:r.jsx(bn,{})}),e[13]=x):x=e[13];let b;e[14]!==g?(b=r.jsxs(Zn,{children:[g,x]}),e[14]=g,e[15]=b):b=e[15];let w;return e[16]!==b||e[17]!==m?(w=r.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,b]}),e[16]=b,e[17]=m,e[18]=w):w=e[18],w}const T0=v.memo(function(e){const t=B.c(40),{onJumpToTurn:s,onToggleServer:o,onServersChanged:i,searchInputRef:a,onLoadSession:l,backgroundAgents:c}=e,{isMobile:d}=Rt(),{session:f,sessionSource:u}=it(),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 x;t[2]!==a?(x=a&&r.jsx(lP,{searchInputRef:a}),t[2]=a,t[3]=x):x=t[3];const b=d?"p-4":"p-3";let w;t[4]!==b?(w=G(b),t[4]=b,t[5]=w):w=t[5];let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(vg,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(Oo,{value:"activity",children:"Activity"}),r.jsx(Oo,{value:"agents",children:"Agents"}),r.jsx(Oo,{value:"metrics",children:"Metrics"}),r.jsx(Oo,{value:"issues",children:"Issues"})]}),t[6]=y):y=t[6];let j;t[7]!==s||t[8]!==p?(j=r.jsxs(Do,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(sP,{turns:p,onJumpToTurn:s}),r.jsx(aP,{turns:p,onJumpToTurn:s})]}),t[7]=s,t[8]=p,t[9]=j):j=t[9];let k;t[10]!==i||t[11]!==o||t[12]!==m.cwd||t[13]!==p?(k=r.jsx(Sg,{cwd:m.cwd,turns:p,onToggleServer:o,onServersChanged:i}),t[10]=i,t[11]=o,t[12]=m.cwd,t[13]=p,t[14]=k):k=t[14];let N;t[15]!==c?(N=c??[],t[15]=c,t[16]=N):N=t[16];let C;t[17]!==l||t[18]!==m||t[19]!==u||t[20]!==N?(C=r.jsx(tP,{session:m,sessionSource:u,bgAgents:N,onLoadSession:l}),t[17]=l,t[18]=m,t[19]=u,t[20]=N,t[21]=C):C=t[21];let S;t[22]!==C||t[23]!==k?(S=r.jsxs(Do,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[k,C]}),t[22]=C,t[23]=k,t[24]=S):S=t[24];let _;t[25]!==p?(_=r.jsxs(Do,{value:"metrics",className:"flex flex-col gap-6 pt-3",children:[r.jsx(M9,{turns:p}),r.jsx(O9,{turns:p}),r.jsx(L9,{turns:p}),r.jsx(V9,{turns:p})]}),t[25]=p,t[26]=_):_=t[26];let P;t[27]!==s||t[28]!==p?(P=r.jsx(Do,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(J9,{turns:p,onJumpToTurn:s})}),t[27]=s,t[28]=p,t[29]=P):P=t[29];let A;t[30]!==S||t[31]!==_||t[32]!==P||t[33]!==w||t[34]!==j?(A=r.jsxs(bg,{defaultValue:"activity",className:w,children:[y,j,S,_,P]}),t[30]=S,t[31]=_,t[32]=P,t[33]=w,t[34]=j,t[35]=A):A=t[35];let T;return t[36]!==A||t[37]!==g||t[38]!==x?(T=r.jsxs("aside",{className:g,children:[x,A]}),t[36]=A,t[37]=g,t[38]=x,t[39]=T):T=t[39],T});function cP(n){const e=B.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(ny,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function dp(n){const e=B.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(ty,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function dP(n){const e=B.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(ey,{"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 Ma(n){const e=B.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 E0(n){const e=B.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?zn(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:aa(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 uP(n){const e=B.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 fP(n){const e=B.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 up(n){const e=B.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 mP(n){const e=B.c(10);let t,s,o,i;if(e[0]!==n){const{className:c,render:d,...f}=n;t=d,i=Jp,s="a",o=Xp({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 pP(n){const e=B.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 hP(n){const e=B.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(Ze,{}),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 P0(n){const e=B.c(51),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l}=n,[c,d]=v.useState(!1),[f,u]=v.useState(!1),[m,p]=v.useState(""),h=v.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 x=g;let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"w-full"}),e[2]=b):b=e[2];let w;e[3]!==t?(w=r.jsx(ka,{render:b,children:t}),e[3]=t,e[4]=w):w=e[4];let y;e[5]!==i||e[6]!==l||e[7]!==x?(y=(l||i)&&r.jsxs(lo,{children:[l&&r.jsxs(Yt,{onClick:x,children:[r.jsx(Ls,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(Yt,{onClick:i,children:[r.jsx(Pn,{"data-icon":"inline-start"}),"Duplicate session"]})]}),e[5]=i,e[6]=l,e[7]=x,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(cr,{}),r.jsx(lo,{children:r.jsxs(Yt,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(qi,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[9]=a,e[10]=i,e[11]=l,e[12]=j):j=e[12];let k;e[13]!==y||e[14]!==j?(k=r.jsxs(Na,{className:"min-w-44",children:[y,j]}),e[13]=y,e[14]=j,e[15]=k):k=e[15];let N;e[16]!==w||e[17]!==k?(N=r.jsxs(Sa,{children:[w,k]}),e[16]=w,e[17]=k,e[18]=N):N=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(Hc,{children:"Delete session?"}),e[19]=C):C=e[19];let S;e[20]!==s?(S=r.jsxs(Uc,{children:[C,r.jsxs(Kc,{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]=S):S=e[21];let _;e[22]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Vc,{size:"sm",children:"Cancel"}),e[22]=_):_=e[22];let P;e[23]!==a?(P=r.jsxs(Wc,{children:[_,r.jsx(qc,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),d(!1)},children:"Delete"})]}),e[23]=a,e[24]=P):P=e[24];let A;e[25]!==P||e[26]!==S?(A=r.jsxs(Bc,{children:[S,P]}),e[25]=P,e[26]=S,e[27]=A):A=e[27];let T;e[28]!==c||e[29]!==A?(T=r.jsx(Fc,{open:c,onOpenChange:d,children:A}),e[28]=c,e[29]=A,e[30]=T):T=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsxs(ks,{children:[r.jsx(Xn,{className:"text-foreground",children:"Rename session"}),r.jsx(Jn,{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=z=>{z.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(xt,{htmlFor:"session-rename",children:"Session name"}),e[35]=I):I=e[35];let R;e[36]===Symbol.for("react.memo_cache_sentinel")?(R=z=>p(z.target.value),e[36]=R):R=e[36];let $;e[37]!==m||e[38]!==s?($=r.jsxs(gt,{children:[I,r.jsx(Ot,{id:"session-rename",ref:h,value:m,onChange:R,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=$):$=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsxs(Jh,{children:[r.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(!1),children:"Cancel"}),r.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[40]=D):D=e[40];let O;e[41]!==M||e[42]!==$?(O=r.jsxs(Yn,{className:"sm:max-w-md",children:[E,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:M,children:[$,D]})]}),e[41]=M,e[42]=$,e[43]=O):O=e[43];let L;e[44]!==f||e[45]!==O?(L=r.jsx(Gn,{open:f,onOpenChange:u,children:O}),e[44]=f,e[45]=O,e[46]=L):L=e[46];let F;return e[47]!==T||e[48]!==L||e[49]!==N?(F=r.jsxs(r.Fragment,{children:[N,T,L]}),e[47]=T,e[48]=L,e[49]=N,e[50]=F):F=e[50],F}const A0="session-custom-names";function R0(){try{const n=localStorage.getItem(Lt(A0));return n?JSON.parse(n):{}}catch{return{}}}function gP(n){localStorage.setItem(Lt(A0),JSON.stringify(n))}let Di=R0();const Li=new Set;if(typeof window<"u"){const n=()=>{Di=R0();for(const e of Li)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function xP(n){return Li.add(n),()=>{Li.delete(n)}}function bP(){return Di}function fc(n,e){const t={...Di},s=e.trim();s?t[n]=s:delete t[n],gP(t),Di=t;for(const o of Li)o()}function M0(){const n=B.c(2),e=v.useSyncExternalStore(xP,bP);let t;return n[0]!==e?(t={names:e,rename:fc},n[0]=e,n[1]=t):t=n[1],t}function is(n){const e=B.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 I0(n){const e=B.c(16),{value:t,onChange:s,placeholder:o,loading:i}=n,a=i===void 0?!1:i;let l;e[0]!==a?(l=r.jsx(wn,{children:a?r.jsx(rt,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(bn,{"aria-hidden":"true"})}),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s?(c=m=>s(m.target.value),e[2]=s,e[3]=c):c=e[3];let d;e[4]!==a||e[5]!==o||e[6]!==c||e[7]!==t?(d=r.jsx(es,{type:"search","aria-busy":a,"aria-label":o,value:t,onChange:c,placeholder:o}),e[4]=a,e[5]=o,e[6]=c,e[7]=t,e[8]=d):d=e[8];let f;e[9]!==s||e[10]!==t?(f=t&&r.jsx(wn,{align:"inline-end",children:r.jsx(_r,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(jt,{})})}),e[9]=s,e[10]=t,e[11]=f):f=e[11];let u;return e[12]!==l||e[13]!==d||e[14]!==f?(u=r.jsxs(Zn,{className:"w-full sm:max-w-sm",children:[l,d,f]}),e[12]=l,e[13]=d,e[14]=f,e[15]=u):u=e[15],u}function $0(n){const e=B.c(10),{message:t,onRetry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(jn,{"aria-hidden":"true"}),i=r.jsx(Dt,{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(_t,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Qt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(bs,{children:r.jsxs(J,{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(Ct,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function O0(n){const e=B.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(It,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(is,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(is,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(is,{className:"h-3 w-72 max-w-full"}),r.jsx(is,{className:"h-3 w-52 max-w-full"})]}),r.jsx(is,{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 mr(n){return n==="idle"||n==="completed"}function $d(n){return mr(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const Ms={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},vP=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,yP=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,wP=/(?:^|\s)#(\d+)(?=\s|$)/,jP=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function li(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function SP(n){const e=n.trim().replace(/^(?:pr|pull\s+request)\b/i,"").trim().replace(/^(?:in|on)\s+/i,"");return!e||/^(?:pr|pull\s+request)$/i.test(e)?null:e.toLowerCase()}function D0(n){const e=n.trim();if(!e)return null;const t=vP.exec(e);if(t){const l=li(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=yP.exec(e);if(s){const l=li(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=wP.exec(e);if(o){const l=li(o[1]);if(l===null)return null;const c=`${e.slice(0,o.index)} ${e.slice(o.index+o[0].length)}`;return{number:l,repoHint:SP(c)}}const i=jP.exec(e);if(!i)return null;const a=li(i[1]);return a===null?null:{number:a,repoHint:null}}function fp(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function kP(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"").split(/[\\/]/).filter(Boolean).at(-1);if(!t)return!1;const s=t.replace(/[^a-z0-9]/g,"");return e.split("/").some(o=>o.replace(/[^a-z0-9]/g,"")===s)}function NP(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?fp(n.repo,s):fp(n.repo,s)?!0:t.some(o=>kP(o,s)):!0}function L0(n,e,t=[]){var i;const s=D0(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>NP(l,s,a)))??!1}const o=e.trim().toLowerCase();return o?[...t,n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.teamName,n.sessionId,n.cwd,n.projectShortName].some(a=>a==null?void 0:a.toLowerCase().includes(o)):!0}const CP=120*1e3;function z0(n){return n?Date.now()-new Date(n).getTime()<CP:!1}function F0(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?pn(s,70):pn(n.sessionId,16)}function mp(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function _P(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||mp(t)===mp(e)?null:pn(t,220)}function TP(n,e){return L0(n,e)}function EP(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?En(t):null}function PP(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(`
|
|
120
|
-
`)}function AP(n){var t;const e=n.cwd?(t=la(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:sy,label:e,title:n.cwd}:n.gitBranch?{icon:vo,label:n.gitBranch}:null}function RP(n,e){return n.agentStatus==="deferred"?"attention":e?mr(n.agentStatus)?"idle":"working":null}function MP(n){const e=B.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(Me,{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=mr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=Mr(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=$d(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(Me,{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=Ed(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Me,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function El(n){const e=B.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 IP(n){const e=B.c(99),{session:t,customName:s,onSelect:o}=n,i=t.lastActivityAt||t.lastModified;let a,l;e[0]!==i||e[1]!==t?(a=z0(i),l=RP(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,x,b,w,y,j,k,N,C;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const $=AP(t);let D;e[25]!==i||e[26]!==t.timestamp?(D=EP(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=D):D=e[27];const O=D,L=t.turnCount??0;let F,z;e[28]!==s||e[29]!==t?(z=F0(t,s),F=_P(t,z),e[28]=s,e[29]=t,e[30]=F,e[31]=z):(F=e[30],z=e[31]);const H=F;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=PP(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 U;e[34]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(Ku,{className:"size-4"}),e[34]=U):U=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",Ms[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:[U,W]}),e[37]=W,e[38]=h):h=e[38],k="flex min-w-0 flex-1 flex-col gap-1";let K;e[39]!==z?(K=r.jsx("span",{className:"truncate text-sm font-medium",children:z}),e[39]=z,e[40]=K):K=e[40];let q;e[41]!==d?(q=d&&r.jsxs(Me,{variant:"outline",className:"shrink-0",children:[r.jsx(co,{"data-icon":"inline-start"}),pn(d,18)]}),e[41]=d,e[42]=q):q=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Me,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(_c,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let V;e[45]!==a||e[46]!==t?(V=r.jsx(MP,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=V):V=e[47];let Q;e[48]!==i?(Q=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Sr(i)}),e[48]=i,e[49]=Q):Q=e[49];let Z;e[50]!==V||e[51]!==Q?(Z=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[V,Q]}),e[50]=V,e[51]=Q,e[52]=Z):Z=e[52],e[53]!==K||e[54]!==q||e[55]!==Y||e[56]!==Z?(N=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[K,q,Y,Z]}),e[53]=K,e[54]=q,e[55]=Y,e[56]=Z,e[57]=N):N=e[57],e[58]!==H?(C=H&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:H}),e[58]=H,e[59]=C):C=e[59],x="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(b=t.model&&r.jsx(Me,{variant:"outline",children:ia(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==L?(w=L>0&&r.jsxs(El,{icon:Ku,children:[L," ",L===1?"turn":"turns"]}),e[62]=L,e[63]=w):w=e[63],e[64]!==O?(y=O&&r.jsx(El,{icon:Is,title:"First prompt to last activity",children:O}),e[64]=O,e[65]=y):y=e[65],j=$&&r.jsx(El,{icon:$.icon,className:"max-w-40 truncate",title:$.title,children:pn($.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]=x,e[18]=b,e[19]=w,e[20]=y,e[21]=j,e[22]=k,e[23]=N,e[24]=C}else f=e[11],u=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],y=e[20],j=e[21],k=e[22],N=e[23],C=e[24];let S;e[66]!==t.size?(S=og(t.size),e[66]=t.size,e[67]=S):S=e[67];let _;e[68]!==S?(_=r.jsx("span",{children:S}),e[68]=S,e[69]=_):_=e[69];let P;e[70]!==_||e[71]!==x||e[72]!==b||e[73]!==w||e[74]!==y||e[75]!==j?(P=r.jsxs("span",{className:x,children:[b,w,y,j,_]}),e[70]=_,e[71]=x,e[72]=b,e[73]=w,e[74]=y,e[75]=j,e[76]=P):P=e[76];let A;e[77]!==P||e[78]!==k||e[79]!==N||e[80]!==C?(A=r.jsxs("span",{className:k,children:[N,C,P]}),e[77]=P,e[78]=k,e[79]=N,e[80]=C,e[81]=A):A=e[81];let T;e[82]!==f||e[83]!==u||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==A?(T=r.jsxs("button",{type:f,onClick:u,title:m,className:p,children:[h,A]}),e[82]=f,e[83]=u,e[84]=m,e[85]=p,e[86]=h,e[87]=A,e[88]=T):T=e[88];let E;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(E=t.matchedPullRequestNumber?r.jsxs(Me,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Ra,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=E):E=e[91];let M;e[92]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Ze,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=M):M=e[92];let I;e[93]!==E?(I=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[E,M]}),e[93]=E,e[94]=I):I=e[94];let R;return e[95]!==g||e[96]!==T||e[97]!==I?(R=r.jsxs("div",{className:g,children:[T,I]}),e[95]=g,e[96]=T,e[97]=I,e[98]=R):R=e[98],R}function $P(n){const e=B.c(61),{selectedProject:t,sessions:s,sessionsTotal:o,sessionsLoading:i,searchLoading:a,searchFilter:l,setSearchFilter:c,filteredSessions:d,fetchError:f,onSelectSession:u,onNewSession:m,creatingSession:p,onDuplicateSession:h,onDeleteSession:g,onBack:x,onRetryFetch:b,loadMoreSessions:w}=n,{names:y,rename:j}=M0();let k;e[0]!==t.path?(k=zn(t.path),e[0]=t.path,e[1]=k):k=e[1];const N=k;let C;e[2]!==x?(C=r.jsx(up,{children:r.jsx(mP,{render:r.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=C):C=e[3];let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(hP,{}),e[4]=S):S=e[4];let _;e[5]!==N?(_=r.jsx(up,{className:"min-w-0",children:r.jsx(pP,{className:"truncate",children:N})}),e[5]=N,e[6]=_):_=e[6];let P;e[7]!==C||e[8]!==_?(P=r.jsx(uP,{children:r.jsxs(fP,{children:[C,S,_]})}),e[7]=C,e[8]=_,e[9]=P):P=e[9];let A;e[10]!==N?(A=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:N}),e[10]=N,e[11]=A):A=e[11];let T;e[12]!==o?(T=r.jsx(Me,{variant:"secondary",children:o}),e[12]=o,e[13]=T):T=e[13];let E;e[14]!==A||e[15]!==T?(E=r.jsxs("div",{className:"flex items-center gap-2",children:[A,T]}),e[14]=A,e[15]=T,e[16]=E):E=e[16];let M;e[17]!==t.path?(M=aa(t.path),e[17]=t.path,e[18]=M):M=e[18];let I;e[19]!==M?(I=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:M}),e[19]=M,e[20]=I):I=e[20];let R;e[21]!==I||e[22]!==E?(R=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[E,I]}),e[21]=I,e[22]=E,e[23]=R):R=e[23];let $;e[24]!==l||e[25]!==a||e[26]!==c?($=r.jsx(I0,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:a}),e[24]=l,e[25]=a,e[26]=c,e[27]=$):$=e[27];let D;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(D=m&&r.jsxs(J,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(Bt,{"data-icon":"inline-start"}):r.jsx(Tn,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=D):D=e[32];let O;e[33]!==$||e[34]!==D?(O=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[$,D]}),e[33]=$,e[34]=D,e[35]=O):O=e[35];let L;e[36]!==f||e[37]!==b?(L=f&&r.jsx($0,{message:f,onRetry:b}),e[36]=f,e[37]=b,e[38]=L):L=e[38];let F;e[39]!==d||e[40]!==w||e[41]!==g||e[42]!==h||e[43]!==u||e[44]!==j||e[45]!==l||e[46]!==a||e[47]!==t.dirName||e[48]!==y||e[49]!==s||e[50]!==i||e[51]!==o?(F=(i||a)&&d.length===0?r.jsx(O0,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(Hn,{className:"min-h-72 border",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(Qi,{})}),r.jsx(qn,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(Vn,{children:l?"Try #157, honest-cms #157, or paste a PR URL.":"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:d.map((U,W)=>r.jsxs(v.Fragment,{children:[W>0&&r.jsx(It,{}),r.jsx(P0,{sessionLabel:F0(U),customName:y[U.sessionId],onRename:K=>j(U.sessionId,K),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(IP,{session:U,customName:y[U.sessionId],onSelect:()=>u(t.dirName,U.fileName)})})]},U.fileName))}),s.length<o&&!l&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(J,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(Bt,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=w,e[41]=g,e[42]=h,e[43]=u,e[44]=j,e[45]=l,e[46]=a,e[47]=t.dirName,e[48]=y,e[49]=s,e[50]=i,e[51]=o,e[52]=F):F=e[52];let z;e[53]!==O||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[O,L,F]}),e[53]=O,e[54]=L,e[55]=F,e[56]=z):z=e[56];let H;return e[57]!==R||e[58]!==z||e[59]!==P?(H=r.jsx(Cr,{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:[P,R,z]})}),e[57]=R,e[58]=z,e[59]=P,e[60]=H):H=e[60],H}function OP(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=v.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=yr(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 B0(n){const e=B.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=v.useState(!1),[d,f]=v.useState(""),u=v.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 x;e[6]!==t||e[7]!==g?(x=r.jsx(ka,{render:g,children:t}),e[6]=t,e[7]=g,e[8]=x):x=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Ls,{"data-icon":"inline-start"}),e[9]=b):b=e[9];let w;e[10]!==p?(w=r.jsx(Na,{className:"min-w-44",children:r.jsx(lo,{children:r.jsxs(Yt,{onClick:p,children:[b,"Rename project"]})})}),e[10]=p,e[11]=w):w=e[11];let y;e[12]!==x||e[13]!==w?(y=r.jsxs(Sa,{children:[x,w]}),e[12]=x,e[13]=w,e[14]=y):y=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(ks,{children:[r.jsx(Xn,{className:"text-foreground",children:"Rename project"}),r.jsx(Jn,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[15]=j):j=e[15];let k;e[16]!==a||e[17]!==d?(k=E=>{E.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=k):k=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(xt,{htmlFor:"project-rename",children:"Project name"}),e[19]=N):N=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=E=>f(E.target.value),e[20]=C):C=e[20];let S;e[21]!==s||e[22]!==d?(S=r.jsxs(gt,{children:[N,r.jsx(Ot,{id:"project-rename",ref:u,value:d,onChange:C,placeholder:s})]}),e[21]=s,e[22]=d,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(Jh,{children:[r.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[24]=_):_=e[24];let P;e[25]!==S||e[26]!==k?(P=r.jsxs(Yn,{className:"sm:max-w-md",children:[j,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:k,children:[S,_]})]}),e[25]=S,e[26]=k,e[27]=P):P=e[27];let A;e[28]!==l||e[29]!==P?(A=r.jsx(Gn,{open:l,onOpenChange:c,children:P}),e[28]=l,e[29]=P,e[30]=A):A=e[30];let T;return e[31]!==A||e[32]!==y?(T=r.jsxs(r.Fragment,{children:[y,A]}),e[31]=A,e[32]=y,e[33]=T):T=e[33],T}const U0="project-custom-names";function W0(){try{const n=localStorage.getItem(Lt(U0));return n?JSON.parse(n):{}}catch{return{}}}function DP(n){localStorage.setItem(Lt(U0),JSON.stringify(n))}let zi=W0();const Fi=new Set;if(typeof window<"u"){const n=()=>{zi=W0();for(const e of Fi)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function LP(n){return Fi.add(n),()=>{Fi.delete(n)}}function zP(){return zi}function FP(n,e){const t={...zi},s=e.trim();s?t[n]=s:delete t[n],DP(t),zi=t;for(const o of Fi)o()}function H0(){const n=B.c(2),e=v.useSyncExternalStore(LP,zP);let t;return n[0]!==e?(t={names:e,rename:FP},n[0]=e,n[1]=t):t=n[1],t}function BP(n){const e=B.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)z0(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}=H0();let x;e:{if(!a){x=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==a){const $=a.toLowerCase();R=t.filter(D=>{var O;return D.path.toLowerCase().includes($)||D.shortName.toLowerCase().includes($)||((O=h[D.dirName])==null?void 0:O.toLowerCase().includes($))}),e[2]=h,e[3]=t,e[4]=a,e[5]=R}else R=e[5];x=R}const b=x;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(Me,{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 k;e[10]!==y?(k=r.jsxs("header",{className:"flex flex-col gap-1",children:[y,j]}),e[10]=y,e[11]=k):k=e[11];let N;e[12]!==a||e[13]!==l?(N=r.jsx(I0,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=N):N=e[14];const C=i&&"animate-spin";let S;e[15]!==C?(S=G(C),e[15]=C,e[16]=S):S=e[16];let _;e[17]!==S?(_=r.jsx(Qt,{"data-icon":"inline-start",className:S}),e[17]=S,e[18]=_):_=e[18];let P;e[19]!==u||e[20]!==i||e[21]!==_?(P=r.jsxs(J,{variant:"outline",size:"sm",onClick:u,disabled:i,"aria-label":"Refresh projects",children:[_,"Refresh"]}),e[19]=u,e[20]=i,e[21]=_,e[22]=P):P=e[22];let A;e[23]!==P||e[24]!==N?(A=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[N,P]}),e[23]=P,e[24]=N,e[25]=A):A=e[25];let T;e[26]!==c||e[27]!==u||e[28]!==d?(T=c&&!d&&r.jsx($0,{message:c,onRetry:u}),e[26]=c,e[27]=u,e[28]=d,e[29]=T):T=e[29];let E;e[30]!==p||e[31]!==b||e[32]!==o||e[33]!==f||e[34]!==h||e[35]!==g||e[36]!==a?(E=o?r.jsx(O0,{}):b.length===0?r.jsx(Hn,{className:"min-h-72 border",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(Qo,{})}),r.jsx(qn,{children:a?"No projects match your search":"No projects yet"}),r.jsx(Vn,{children:a?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]})}):r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:b.map((R,$)=>{const D=p[R.dirName]||0,O=h[R.dirName],L=Mw(St(R.dirName));return r.jsxs(v.Fragment,{children:[$>0&&r.jsx(It,{}),r.jsx(B0,{projectLabel:zn(R.path),customName:O,onRename:F=>g(R.dirName,F),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(OP,{projectPath:R.path,className:"size-4",fallback:r.jsx(Qo,{className:"size-4 text-muted-foreground"})})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-medium",children:O||zn(R.path)}),L&&r.jsx(Me,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:L})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:aa(R.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[D>0&&r.jsxs(Me,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),D," 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:Sr(R.lastModified)}),r.jsx(Ze,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=b,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]!==A||e[39]!==T||e[40]!==E?(M=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,T,E]}),e[38]=A,e[39]=T,e[40]=E,e[41]=M):M=e[41];let I;return e[42]!==M||e[43]!==k?(I=r.jsx(Cr,{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:[k,M]})}),e[42]=M,e[43]=k,e[44]=I):I=e[44],I}const UP=250,WP=400,pp={results:null,loading:!1,error:null};function K0(n,e){const t=v.useMemo(()=>D0(n),[n]),[s,o]=v.useState(0),[i,a]=v.useState(pp);v.useEffect(()=>{if(!t){a(pp);return}const c=new AbortController;a({results:null,loading:!0,error:null});let d=null;const f=async()=>{const m=new URLSearchParams({search:n.trim(),limit:"200"});e&&m.set("project",e);try{const p=await ye(`/api/active-sessions?${m}`,{signal:c.signal});if(!p.ok)throw new Error(`Search failed (${p.status})`);const h=await p.json();if(c.signal.aborted)return;const g=Number(p.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(g)&&g>0){d=setTimeout(()=>{f()},WP);return}a({results:Array.isArray(h)?h:[],loading:!1,error:null})}catch(p){if(c.signal.aborted)return;a({results:[],loading:!1,error:p instanceof Error?p.message:"Search failed"})}},u=setTimeout(()=>{f()},UP);return()=>{clearTimeout(u),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=v.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const HP=v.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=v.useState(()=>({projects:Ei(Ln.projects),activeSessions:Ei(Ln.activeSessions)})),[d,f]=v.useState(c.projects??[]),[u,m]=v.useState(c.activeSessions??[]),[p,h]=v.useState(c.projects===void 0),[g,x]=v.useState(!1),[b,w]=v.useState([]),[y,j]=v.useState(0),[k,N]=v.useState(1),[C,S]=v.useState(!1),[_,P]=v.useState(""),[A,T]=v.useState(null),E=v.useRef(0),M=v.useRef(null),I=v.useCallback(async(U=!1)=>{U&&x(!0);try{const[W,K]=await Promise.all([ye("/api/projects"),ye("/api/active-sessions")]);if(!W.ok||!K.ok)throw new Error("Failed to fetch dashboard data");const q=await W.json(),Y=await K.json(),V=Array.isArray(q)?q:[],Q=Array.isArray(Y)?Y:[];f(V),m(Q),qo(Ln.projects,V),qo(Ln.activeSessions,Q),T(null)}catch(W){T(W instanceof Error?W.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);v.useEffect(()=>{I()},[I]);const R=v.useCallback(async(U,W=1,K=!1)=>{var Q;const q=++E.current;(Q=M.current)==null||Q.abort();const Y=new AbortController;M.current=Y;const V=()=>q===E.current;if(S(!0),T(null),!K){const Z=VC(U);Z?(w(Z.sessions),j(Z.total),N(1)):w([])}try{const Z=await ye(`/api/sessions/${encodeURIComponent(U)}?page=${W}&limit=20`,{signal:Y.signal});if(!Z.ok)throw new Error(`Failed to load sessions (${Z.status})`);const X=await Z.json();if(!V())return;const ee=Array.isArray(X.sessions)?X.sessions:[],oe=typeof X.total=="number"?X.total:ee.length;w(se=>K?[...se,...ee]:ee),j(oe),N(W),K||GC(U,{sessions:ee,total:oe})}catch(Z){if(!V()||Y.signal.aborted)return;T(Z instanceof Error?Z.message:"Failed to load sessions")}finally{V()&&(M.current=null,S(!1))}},[]);v.useEffect(()=>{var U;if(!o){E.current+=1,(U=M.current)==null||U.abort(),M.current=null,w([]),j(0),N(1),P(""),S(!1);return}P(""),R(o)},[o,R]),v.useEffect(()=>()=>{var U;E.current+=1,(U=M.current)==null||U.abort()},[]);const $=v.useMemo(()=>{if(!o)return null;const U=d.find(K=>K.dirName===o);if(U)return U;const W=gn(o);return{dirName:o,path:W,shortName:zn(W),sessionCount:y,lastModified:null}},[o,d,y]),D=v.useCallback(()=>{i==null||i(null)},[i]),O=v.useCallback(()=>{o&&R(o,k+1,!0)},[o,k,R]),L=K0(o?_:"",o??void 0),F=v.useMemo(()=>_?b.filter(U=>TP(U,_)):b,[b,_]),z=L.results??F;function H(U,W){l==null||l(U,W),w(K=>K.filter(q=>q.fileName!==W)),j(K=>K-1)}return $?r.jsx($P,{selectedProject:$,sessions:b,sessionsTotal:y,sessionsLoading:C,searchLoading:L.loading,searchFilter:_,setSearchFilter:P,filteredSessions:z,fetchError:L.error??A,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:H,onBack:D,onRetryFetch:()=>{if(L.error){L.refresh();return}T(null),o&&R(o)},loadMoreSessions:O}):r.jsx(BP,{projects:d,activeSessions:u,loading:p,refreshing:g,searchFilter:_,setSearchFilter:P,fetchError:A,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>I(!0)})});async function q0(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 KP(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 V0(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 qP(n,e,t){return V0("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function VP(n,e,t){return V0("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const GP=3e3,G0=v.createContext(null);async function Pl(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 Ro(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 ci(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 YP({children:n}){const[e,t]=v.useState(new Map),[s,o]=v.useState(new Map),[i,a]=v.useState(new Map),[l,c]=v.useState(new Map),[d,f]=v.useState(new Set),[u,m]=v.useState(new Set),p=v.useRef(""),h=v.useRef(""),g=v.useRef(""),x=v.useCallback(async()=>{const[T,E,M]=await Promise.all([Pl("/api/permissions",p),Pl("/api/user-questions",h),Pl("/api/agent-prompts",g)]);T&&(t(Ro(T.bySession)),f(new Set(Ro(T.plansBySession).keys()))),E&&o(Ro(E.bySession)),M&&(a(Ro(M.elicitationsBySession)),c(Ro(M.dialogsBySession)))},[]);v.useEffect(()=>{const T=()=>{document.visibilityState==="visible"&&x()};T();const E=setInterval(T,GP);return document.addEventListener("visibilitychange",T),()=>{clearInterval(E),document.removeEventListener("visibilitychange",T)}},[x]);const b=v.useCallback(async(T,E)=>{m(M=>new Set(M).add(T));try{return await E()}finally{m(M=>{const I=new Set(M);return I.delete(T),I}),x()}},[x]),w=v.useCallback((T,E,M)=>b(E,async()=>{await q0(T,E,M).catch(()=>!1)&&(t(R=>ci(R,T,$=>$.requestId===E)),p.current="")}),[b]),y=v.useCallback((T,E,M)=>b(E,async()=>{const I=await Oc(T,E,M);return I.ok&&(o(R=>ci(R,T,$=>$.toolUseId===E)),h.current=""),I}),[b]),j=v.useCallback((T,E,M)=>b(E,async()=>{const I=await qP(T,E,M);return I.ok&&(a(R=>ci(R,T,$=>$.requestId===E)),g.current=""),I}),[b]),k=v.useCallback((T,E,M)=>b(E,async()=>{const I=await VP(T,E,M);return I.ok&&(c(R=>ci(R,T,$=>$.requestId===E)),g.current=""),I}),[b]),N=v.useMemo(()=>new Set(e.keys()),[e]),C=v.useMemo(()=>new Set(s.keys()),[s]),S=v.useMemo(()=>new Set(i.keys()),[i]),_=v.useMemo(()=>new Set(l.keys()),[l]),P=v.useCallback(()=>{x()},[x]),A=v.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:N,awaitingQuestion:C,awaitingElicitation:S,awaitingDialog:_,awaitingPlan:d,responding:u,respond:w,answerQuestion:y,answerElicitation:j,answerDialog:k,refresh:P}),[e,s,i,l,N,C,S,_,d,u,w,y,j,k,P]);return r.jsx(G0.Provider,{value:A,children:n})}function XP(){const n=v.useContext(G0);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const Y0=typeof navigator<"u"&&"vibrate"in navigator;function mc(){Y0&&navigator.vibrate(10)}function JP(){Y0&&navigator.vibrate(20)}function QP(n){return!!(n.teamName&&n.agentName)}function ZP(n,e,t,s,o,i,a){const l=[],c=[];for(const d of gd(n)){if(s!=null&&s.has(d.sessionId)){l.push({session:d,reason:"permission"});continue}if(o!=null&&o.has(d.sessionId)){l.push({session:d,reason:"question"});continue}if(i!=null&&i.has(d.sessionId)){l.push({session:d,reason:"prompt"});continue}if(a!=null&&a.has(d.sessionId)){l.push({session:d,reason:"plan"});continue}if(d.agentStatus==="deferred"){l.push({session:d,reason:"deferred"});continue}if(QP(d))continue;const f=gx(d,e);if(d.agentStatus==="completed"||!f){t.has(d.sessionId)&&l.push({session:d,reason:"done"});continue}if(d.agentStatus==="idle"){l.push({session:d,reason:"waiting"});continue}(!d.agentStatus||bd.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function eA(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"}}function Od(n,e){return n?Ut(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const X0="aw:turnCounts",tA=200,Ia=new Map;try{const n=localStorage.getItem(X0);if(n){const e=JSON.parse(n);for(const[t,s]of e)Ia.set(t,s)}}catch{}function nA(){try{const n=[...Ia.entries()].slice(-tA);localStorage.setItem(X0,JSON.stringify(n))}catch{}}function sA(n,e){Ia.set(Lt(n),e),nA()}function oA(n,e){const t=Ia.get(Lt(n));return Math.max(t??0,e??0)}function J0(n){const e=B.c(40),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a}=n,l=i||t.aiTitle,c=t.lastUserMessage||t.firstUserMessage,d=oA(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",$d(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(Wn,{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(Ra,{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(vo,{className:"size-2.5"}),a?`${t.gitBranch} · ${a}`:t.gitBranch]}),e[12]=t.gitBranch,e[13]=a,e[14]=g):g=e[14];let x;e[15]!==d?(x=d>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Qi,{className:"size-2.5"}),d," ",d===1?"turn":"turns"]}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==t.size?(b=og(t.size),e[17]=t.size,e[18]=b):b=e[18];let w;e[19]!==b?(w=r.jsx("span",{children:b}),e[19]=b,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(oy,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=y):y=e[22];const j=t.lastActivityAt||t.lastModified;let k;e[23]!==j?(k=Sr(j),e[23]=j,e[24]=k):k=e[24];let N;e[25]!==k?(N=r.jsx("span",{children:k}),e[25]=k,e[26]=N):N=e[26];let C;e[27]!==y||e[28]!==N||e[29]!==g||e[30]!==x||e[31]!==w?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[g,x,w,y,N]}),e[27]=y,e[28]=N,e[29]=g,e[30]=x,e[31]=w,e[32]=C):C=e[32];let S;return e[33]!==f||e[34]!==C||e[35]!==u||e[36]!==m||e[37]!==p||e[38]!==h?(S=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[f,u,m,p,h,C]}),e[33]=f,e[34]=C,e[35]=u,e[36]=m,e[37]=p,e[38]=h,e[39]=S):S=e[39],S}const rA=120;function Q0(n){const e=B.c(7),t=v.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]),v.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,rA))},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 iA=6;function aA(n){const e=B.c(7),{iso:t}=n,[,s]=v.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(lA),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],v.useEffect(o,i);let a;e[3]!==t?(a=Sr(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 lA(n){return n+1}const cA={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"},plan:{label:"Review plan",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"}},dA={permission:Ms.attention,deferred:Ms.attention,waiting:Ms.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function hp(n){const e=B.c(76),{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,x=u===void 0?!1:u;let b;e[0]!==l||e[1]!==t.dirName?(b=Od(St(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const w=b;let y;e[3]!==s||e[4]!==w||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(y=w?"Read-only":Mr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=w,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=y):y=e[9];const j=y,k=!!h&&!w,{onHoverStart:N,onHoverEnd:C}=Q0(g),S=x?"px-2.5 py-2":"border px-2 py-2",_=a&&!x&&"ring-1 ring-ring";let P;e[10]!==i||e[11]!==S||e[12]!==_?(P=G("group relative w-full rounded-md text-left transition-colors",S,i,_),e[10]=i,e[11]=S,e[12]=_,e[13]=P):P=e[13];let A;e[14]!==x||e[15]!==a?(A=x&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=a,e[16]=A):A=e[16];const T=k&&"pr-20";let E;e[17]!==T?(E=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[17]=T,e[18]=E):E=e[18];let M;e[19]!==C||e[20]!==N||e[21]!==m||e[22]!==E?(M=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:N,onMouseLeave:C,onFocus:N,onBlur:C,className:E}),e[19]=C,e[20]=N,e[21]=m,e[22]=E,e[23]=M):M=e[23];const I=x&&"ring-0";let R;e[24]!==o||e[25]!==I?(R=G("size-1.5 shrink-0 rounded-full",o,I),e[24]=o,e[25]=I,e[26]=R):R=e[26];let $;e[27]!==R?($=r.jsx("span",{className:R,"aria-hidden":"true"}),e[27]=R,e[28]=$):$=e[28];let D;e[29]!==d||e[30]!==t?(D=px(t,d),e[29]=d,e[30]=t,e[31]=D):D=e[31];let O;e[32]!==D?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:D}),e[32]=D,e[33]=O):O=e[33];const L=x?"text-muted-foreground":s.className;let F;e[34]!==L?(F=G("shrink-0",L),e[34]=L,e[35]=F):F=e[35];const z=w?"Read-only":s.label;let H;e[36]!==F||e[37]!==z?(H=r.jsx(Me,{variant:"outline",className:F,children:z}),e[36]=F,e[37]=z,e[38]=H):H=e[38];let U;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(U=!x&&r.jsx(aA,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=U):U=e[42];let W;e[43]!==$||e[44]!==O||e[45]!==H||e[46]!==U?(W=r.jsxs("span",{className:"flex items-center gap-1.5",children:[$,O,H,U]}),e[43]=$,e[44]=O,e[45]=H,e[46]=U,e[47]=W):W=e[47];let K;e[48]!==f?(K=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[48]=f,e[49]=K):K=e[49];let q;e[50]!==M||e[51]!==W||e[52]!==K?(q=r.jsxs(Pt,{render:M,children:[W,K]}),e[50]=M,e[51]=W,e[52]=K,e[53]=q):q=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==j?(Y=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(J0,{session:t,proc:l,statusLabel:j,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=j,e[58]=Y):Y=e[58];let V;e[59]!==q||e[60]!==Y?(V=r.jsxs(Et,{children:[q,Y]}),e[59]=q,e[60]=Y,e[61]=V):V=e[61];let Q;e[62]!==k||e[63]!==h?(Q=k&&r.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(gr,{"data-icon":"inline-start"}),"Resume"]}),e[62]=k,e[63]=h,e[64]=Q):Q=e[64];let Z;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(Z=l&&p&&!w&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ee=>p(l.pid,ee),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(jt,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=Z):Z=e[69];let X;return e[70]!==V||e[71]!==Q||e[72]!==Z||e[73]!==P||e[74]!==A?(X=r.jsxs("div",{className:P,children:[A,V,Q,Z]}),e[70]=V,e[71]=Q,e[72]=Z,e[73]=P,e[74]=A,e[75]=X):X=e[75],X}function uA(n){const e=B.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 fA(n){const e=B.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]=v.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,iA),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let b;e[3]!==l?(b=S=>l[S.dirName]||xd(S.cwd||gn(S.dirName)),e[3]=l,e[4]=b):b=e[4];const w=b;let y;e[5]!==s||e[6]!==i||e[7]!==u||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(y=S=>{const _=s===`${S.dirName}/${S.fileName}`;return{session:S,isActiveSession:_,proc:o.get(S.sessionId),killingPids:i,customName:a[S.sessionId],projectLabel:w(S),onSelect:()=>c(S.dirName,S.fileName),onPrefetch:u&&!_?()=>u(S.dirName,S.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 k;e[13]!==t.needsYou||e[14]!==d||e[15]!==f||e[16]!==j?(k=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(uA,{dotClassName:Ms.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(S=>{const{session:_,reason:P}=S;return r.jsx(hp,{...j(_),chip:cA[P],dotClassName:dA[P],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:P==="deferred"&&f?()=>f(_.sessionId,_.cwd,_.dirName):void 0},`${_.dirName}/${_.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=f,e[16]=j,e[17]=k):k=e[17];let N;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==j||e[22]!==g?(N=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(S=>r.jsx(hp,{...j(S),chip:{label:eA(S),className:""},dotClassName:Ms.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${S.dirName}/${S.fileName}`))}),x>0&&r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(st,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=j,e[22]=g,e[23]=N):N=e[23];let C;return e[24]!==k||e[25]!==N?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[k,N]}),e[24]=k,e[25]=N,e[26]=C):C=e[26],C}function mA(n){const e=B.c(26),{loading:t,isMobile:s,searchQuery:o,searchLoading:i,onSearchQueryChange:a,onRefresh:l}=n;let c;e[0]!==a?(c=y=>a(y.target.value),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==o||e[4]!==c?(d=r.jsx(es,{type:"search",value:o,onChange:c,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":i}),e[2]=i,e[3]=o,e[4]=c,e[5]=d):d=e[5];let f;e[6]!==i?(f=r.jsx(wn,{align:"inline-start",children:i?r.jsx(rt,{className:"animate-spin"}):r.jsx(bn,{})}),e[6]=i,e[7]=f):f=e[7];let u;e[8]!==a||e[9]!==o?(u=o&&r.jsx(wn,{align:"inline-end",children:r.jsx(_r,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(jt,{"data-icon":"inline-start"})})}),e[8]=a,e[9]=o,e[10]=u):u=e[10];let m;e[11]!==d||e[12]!==f||e[13]!==u?(m=r.jsxs(Zn,{children:[d,f,u]}),e[11]=d,e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=s?"icon-sm":"icon-xs",h=t&&"animate-spin";let g;e[15]!==h?(g=G(h),e[15]=h,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(Qt,{"data-icon":"inline-start",className:g}),e[17]=g,e[18]=x):x=e[18];let b;e[19]!==l||e[20]!==p||e[21]!==x?(b=r.jsx(J,{variant:"ghost",size:p,onClick:l,"aria-label":"Refresh sessions",children:x}),e[19]=l,e[20]=p,e[21]=x,e[22]=b):b=e[22];let w;return e[23]!==b||e[24]!==m?(w=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[m,b]}),e[23]=b,e[24]=m,e[25]=w):w=e[25],w}const pA=["first","second","third","fourth","fifth"];function hA(n){const e=B.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(Ct,{variant:"destructive",children:[r.jsx(jn,{}),r.jsx(Dt,{children:"Could not load sessions"}),r.jsx(_t,{className:"truncate",children:t}),r.jsx(bs,{children:r.jsx(J,{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(Hn,{className:"min-h-56 px-4 py-8",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:o?r.jsx(bn,{}):r.jsx(fh,{})}),r.jsx(qn,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(Vn,{children:o?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot 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:pA.map(gA)}),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 gA(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(is,{className:"size-2 shrink-0 rounded-full"}),r.jsx(is,{className:"h-4 flex-1"}),r.jsx(is,{className:"h-4 w-10"})]},n)}function xA(n){var we;const e=B.c(116),{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:x,onPrefetchSession:b,onResumeSession:w}=n,y=o!==void 0,j=t.isActive===!0,k=y||j,N=j&&mr(t.agentStatus),C=t.agentStatus==="deferred";let S;e[0]!==o||e[1]!==t.dirName?(S=Od(St(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=S):S=e[2];const _=S,[P,A]=v.useState(!1),T=_?"Read-only":k?N?"Running":Mr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,E=C?"attention":k?mr(t.agentStatus)?"idle":"working":null,M=!!(t.teamName&&t.agentName);let I;e[3]!==l||e[4]!==t?(I=px(t,l),e[3]=l,e[4]=t,e[5]=I):I=e[5];const R=I;let $;e[6]!==s||e[7]!==b||e[8]!==t.dirName||e[9]!==t.fileName?($=b&&!s?()=>b(t.dirName,t.fileName):void 0,e[6]=s,e[7]=b,e[8]=t.dirName,e[9]=t.fileName,e[10]=$):$=e[10];const{onHoverStart:D,onHoverEnd:O}=Q0($);let L;e[11]!==w||e[12]!==P||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(L=pe=>{pe.stopPropagation(),!(!w||P)&&(A(!0),w(t.sessionId,t.cwd,t.dirName),setTimeout(()=>A(!1),3e3))},e[11]=w,e[12]=P,e[13]=t.cwd,e[14]=t.dirName,e[15]=t.sessionId,e[16]=L):L=e[16];const F=L;let z;e[17]!==y||e[18]!==s||e[19]!==j||e[20]!==a||e[21]!==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",bA(s,!j&&y&&t.agentStatus==="completed"&&!!a)),e[17]=y,e[18]=s,e[19]=j,e[20]=a,e[21]=t.agentStatus,e[22]=z):z=e[22];const H=Et,U=Pt;let W;e[23]!==m||e[24]!==t.dirName||e[25]!==t.fileName?(W=()=>m(t.dirName,t.fileName),e[23]=m,e[24]=t.dirName,e[25]=t.fileName,e[26]=W):W=e[26];let K;e[27]!==O||e[28]!==D||e[29]!==W?(K=r.jsx("button",{type:"button","data-live-session":!0,onClick:W,onMouseEnter:D,onMouseLeave:O,onFocus:D,onBlur:O,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[27]=O,e[28]=D,e[29]=W,e[30]=K):K=e[30];let q;e[31]!==E?(q=E&&r.jsx("span",{"data-status-dot":E,className:G("size-1.5 rounded-full",Ms[E])}),e[31]=E,e[32]=q):q=e[32];let Y;e[33]!==q?(Y=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:q}),e[33]=q,e[34]=Y):Y=e[34];let V;e[35]!==R?(V=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:R}),e[35]=R,e[36]=V):V=e[36];let Q;e[37]!==M||e[38]!==t.agentName||e[39]!==R?(Q=M&&r.jsxs(Me,{variant:"outline",children:[r.jsx(co,{"data-icon":"inline-start"}),R!==t.agentName?t.agentName:"Agent"]}),e[37]=M,e[38]=t.agentName,e[39]=R,e[40]=Q):Q=e[40];const Z=k&&!C&&T&&r.jsx(Me,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&$d(t.agentStatus)),children:T});let X;e[41]!==C?(X=C&&r.jsx(Me,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[41]=C,e[42]=X):X=e[42];let ee;e[43]!==c?(ee=c&&r.jsxs(Me,{variant:"outline",children:[r.jsx(vo,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=ee):ee=e[44];let oe;e[45]!==U||e[46]!==V||e[47]!==Q||e[48]!==Z||e[49]!==X||e[50]!==ee||e[51]!==K||e[52]!==Y?(oe=r.jsxs(U,{render:K,children:[Y,V,Q,Z,X,ee]}),e[45]=U,e[46]=V,e[47]=Q,e[48]=Z,e[49]=X,e[50]=ee,e[51]=K,e[52]=Y,e[53]=oe):oe=e[53];let se;e[54]!==l||e[55]!==o||e[56]!==t||e[57]!==T||e[58]!==c?(se=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(J0,{session:t,proc:o,statusLabel:T,customName:l,worktreeName:c})}),e[54]=l,e[55]=o,e[56]=t,e[57]=T,e[58]=c,e[59]=se):se=e[59];let re;e[60]!==H||e[61]!==oe||e[62]!==se?(re=r.jsxs(H,{children:[oe,se]}),e[60]=H,e[61]=oe,e[62]=se,e[63]=re):re=e[63];let ie;e[64]!==u||e[65]!==d||e[66]!==f?(ie=!!d&&u&&r.jsxs(J,{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(Wn,{"data-icon":"inline-start"}),d,r.jsx(Ze,{"data-icon":"inline-end",className:G("transition-transform duration-150",!f&&"rotate-90")})]}),e[64]=u,e[65]=d,e[66]=f,e[67]=ie):ie=e[67];let ae;e[68]!==F||e[69]!==C||e[70]!==_||e[71]!==w||e[72]!==P?(ae=C&&w&&!_&&r.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:F,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx(gr,{"data-icon":"inline-start"}),"Resume"]}),e[68]=F,e[69]=C,e[70]=_,e[71]=w,e[72]=P,e[73]=ae):ae=e[73];let te;e[74]!==t.matchedPullRequestNumber||e[75]!==t.pullRequests?(te=t.matchedPullRequestNumber?r.jsxs(Me,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Ra,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=te):te=e[76];const he=t.lastActivityAt||t.lastModified;let me;e[77]!==he?(me=Sr(he),e[77]=he,e[78]=me):me=e[78];let le;e[79]!==me?(le=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:me}),e[79]=me,e[80]=le):le=e[80];let xe;e[81]!==y||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(xe=y&&p&&!_&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:pe=>p(o.pid,pe),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(jt,{"data-icon":"inline-start"})}),e[81]=y,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=xe):xe=e[86];let ge;e[87]!==re||e[88]!==ie||e[89]!==ae||e[90]!==te||e[91]!==le||e[92]!==xe||e[93]!==z?(ge=r.jsxs("div",{className:z,children:[re,ie,ae,te,le,xe]}),e[87]=re,e[88]=ie,e[89]=ae,e[90]=te,e[91]=le,e[92]=xe,e[93]=z,e[94]=ge):ge=e[94];const ce=ge;if(h||g||x){let pe;e[95]!==t.firstUserMessage||e[96]!==t.sessionId||e[97]!==t.slug?(pe=t.slug||((we=t.firstUserMessage)==null?void 0:we.slice(0,30))||t.sessionId.slice(0,12),e[95]=t.firstUserMessage,e[96]=t.sessionId,e[97]=t.slug,e[98]=pe):pe=e[98];let ue;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(ue=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=ue):ue=e[102];let je;e[103]!==g||e[104]!==t?(je=g?()=>g(t):void 0,e[103]=g,e[104]=t,e[105]=je):je=e[105];let Ne;e[106]!==x||e[107]!==t.sessionId?(Ne=x?Te=>x(t.sessionId,Te):void 0,e[106]=x,e[107]=t.sessionId,e[108]=Ne):Ne=e[108];let Re;return e[109]!==l||e[110]!==ce||e[111]!==pe||e[112]!==ue||e[113]!==je||e[114]!==Ne?(Re=r.jsx(P0,{sessionLabel:pe,customName:l,onDuplicate:ue,onDelete:je,onRename:Ne,children:ce}),e[109]=l,e[110]=ce,e[111]=pe,e[112]=ue,e[113]=je,e[114]=Ne,e[115]=Re):Re=e[115],Re}return ce}function bA(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function vA(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function yA(n){const e=B.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:x,onDeleteSession:b,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,onPrefetchSession:N,onResumeSession:C}=n;let S;e[0]!==l||e[1]!==k||e[2]!==d||e[3]!==f||e[4]!==b||e[5]!==x||e[6]!==g||e[7]!==j||e[8]!==N||e[9]!==y||e[10]!==w||e[11]!==C||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==u?(S={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:f,sessionNames:u,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,onPrefetchSession:N,onResumeSession:C},e[0]=l,e[1]=k,e[2]=d,e[3]=f,e[4]=b,e[5]=x,e[6]=g,e[7]=j,e[8]=N,e[9]=y,e[10]=w,e[11]=C,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=u,e[17]=S):S=e[17];const _=S;let P;e[18]!==a?(P=a.trim(),e[18]=a,e[19]=P):P=e[19];const A=!!P;let T;e[20]!==i||e[21]!==A||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==_?(T=[...t.entries()].map((I,R)=>{const[$,D]=I,O=vA(D,c);return v.createElement(gp,{..._,key:$,projectPath:$,sessions:D,liveCount:O,collapsed:i[$]??(R>=3&&O===0),forceExpand:A,pendingSession:s===$?o:void 0})}),e[20]=i,e[21]=A,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=_,e[27]=T):T=e[27];let E;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==_?(E=s&&!t.has(s)&&o&&v.createElement(gp,{..._,key:`pending-${s}`,projectPath:s,sessions:[],liveCount:0,collapsed:!1,pendingSession:o}),e[28]=t,e[29]=s,e[30]=o,e[31]=_,e[32]=E):E=e[32];let M;return e[33]!==T||e[34]!==E?(M=r.jsxs(r.Fragment,{children:[T,E]}),e[33]=T,e[34]=E,e[35]=M):M=e[35],M}function gp(n){var He,Ie;const e=B.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:x,onDeleteSession:b,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,pendingSession:N,onPrefetchSession:C,onResumeSession:S}=n,_=p===void 0?!1:p,P=v.useId(),A=!!N,T=_||A?!1:u;let E;e[0]!==s?(E=new Set(s.map(jA)),e[0]=s,e[1]=E):E=e[1];const M=E;let I;if(e[2]!==M||e[3]!==s){const Ce=new Map,de=[];for(const Ee of s){const Ae=Ee.teamLeadSessionId;if(Ae&&Ae!==Ee.sessionId&&M.has(Ae)){const Le=Ce.get(Ae);Le?Le.push(Ee):Ce.set(Ae,[Ee])}else de.push(Ee)}I={topLevelSessions:de,teammatesByLead:Ce},e[2]=M,e[3]=s,e[4]=I}else I=e[4];const{topLevelSessions:R,teammatesByLead:$}=I;let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[5]=D):D=e[5];const[O,L]=v.useState(D);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=Ce=>{L(de=>{const Ee=new Set(de);return Ee.has(Ce)?Ee.delete(Ce):Ee.add(Ce),Ee})},e[6]=F):F=e[6];const z=F,[H,U]=v.useState(!1),W=s.length+(A?1:0);let K,q;e[7]!==_||e[8]!==A||e[9]!==i||e[10]!==H||e[11]!==R?(K=zC(R,i,Math.max(1,5-(A?1:0))),q=_||H?R:R.slice(0,K),e[7]=_,e[8]=A,e[9]=i,e[10]=H,e[11]=R,e[12]=K,e[13]=q):(K=e[12],q=e[13]);const Y=q,V=R.length-Y.length,Q=H&&!_&&R.length>K,Z=((He=s.find(wA))==null?void 0:He.dirName)??((Ie=s[0])==null?void 0:Ie.dirName)??(N==null?void 0:N.dirName),X=Z?d[Z]:void 0;let ee;e[14]!==o||e[15]!==a||e[16]!==l||e[17]!==b||e[18]!==x||e[19]!==g||e[20]!==C||e[21]!==w||e[22]!==S||e[23]!==h||e[24]!==i||e[25]!==c?(ee=function(de,Ee,Ae){return r.jsx(xA,{session:de,isActiveSession:o===`${de.dirName}/${de.fileName}`,proc:i.get(de.sessionId),killingPids:a,isNewlyCompleted:l.has(de.sessionId),customName:c[de.sessionId],worktreeName:Ee,teammateCount:Ae==null?void 0:Ae.count,teammatesCollapsed:Ae==null?void 0:Ae.collapsed,onToggleTeammates:Ae==null?void 0:Ae.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onPrefetchSession:C,onResumeSession:S},`${de.dirName}/${de.fileName}`)},e[14]=o,e[15]=a,e[16]=l,e[17]=b,e[18]=x,e[19]=g,e[20]=C,e[21]=w,e[22]=S,e[23]=h,e[24]=i,e[25]=c,e[26]=ee):ee=e[26];const oe=ee,se=!T;let re;e[27]!==Z||e[28]!==y?(re=Ce=>{Z&&y&&y(Z,Ce)},e[27]=Z,e[28]=y,e[29]=re):re=e[29];let ie;e[30]!==u||e[31]!==m||e[32]!==t?(ie=()=>m(t,!u),e[30]=u,e[31]=m,e[32]=t,e[33]=ie):ie=e[33];const ae=!T,te=_?"Groups stay expanded while searching":void 0,he=!T&&"rotate-90";let me;e[34]!==he?(me=G("size-3 shrink-0 text-muted-foreground transition-transform duration-150",he),e[34]=he,e[35]=me):me=e[35];let le;e[36]!==me?(le=r.jsx(Ze,{className:me}),e[36]=me,e[37]=le):le=e[37];const xe=X||t;let ge;e[38]!==xe?(ge=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:xe}),e[38]=xe,e[39]=ge):ge=e[39];let ce;e[40]!==X||e[41]!==t?(ce=X&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=X,e[41]=t,e[42]=ce):ce=e[42];let we;e[43]!==f?(we=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(ca,{className:"size-1.5","aria-hidden":"true"}),f]}),e[43]=f,e[44]=we):we=e[44];let pe;e[45]!==W?(pe=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:W}),e[45]=W,e[46]=pe):pe=e[46];let ue;e[47]!==_||e[48]!==P||e[49]!==ie||e[50]!==ae||e[51]!==te||e[52]!==le||e[53]!==ge||e[54]!==ce||e[55]!==we||e[56]!==pe?(ue=r.jsxs("button",{type:"button",onClick:ie,disabled:_,"aria-expanded":ae,"aria-controls":P,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:[le,ge,ce,we,pe]}),e[47]=_,e[48]=P,e[49]=ie,e[50]=ae,e[51]=te,e[52]=le,e[53]=ge,e[54]=ce,e[55]=we,e[56]=pe,e[57]=ue):ue=e[57];let je;e[58]!==k||e[59]!==j||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(je=j&&s.length>0&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:k,onClick:Ce=>{Ce.stopPropagation();const de=s[0];j(de.dirName,de.cwd??void 0)},"aria-label":`New session in ${t}`,children:k?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(Tn,{"data-icon":"inline-start"})}),e[58]=k,e[59]=j,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=je):je=e[63];let Ne;e[64]!==ue||e[65]!==je?(Ne=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[ue,je]}),e[64]=ue,e[65]=je,e[66]=Ne):Ne=e[66];let Re;e[67]!==X||e[68]!==t||e[69]!==Ne||e[70]!==re?(Re=r.jsx(B0,{projectLabel:t,customName:X,className:"sticky top-0 z-20 bg-background",onRename:re,children:Ne}),e[67]=X,e[68]=t,e[69]=Ne,e[70]=re,e[71]=Re):Re=e[71];let Te;e[72]!==N?(Te=N&&r.jsx(SA,{firstMessage:N.firstMessage}),e[72]=N,e[73]=Te):Te=e[73];let Pe;if(e[74]!==O||e[75]!==oe||e[76]!==$||e[77]!==Y){let Ce;e[79]!==O||e[80]!==oe||e[81]!==$?(Ce=de=>{const Ee=de.cwd??gn(de.dirName),Ae=la(Ee),Le=$.get(de.sessionId);if(!Le)return oe(de,Ae==null?void 0:Ae.worktreeName);const ne=O.has(de.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[oe(de,Ae==null?void 0:Ae.worktreeName,{count:Le.length,collapsed:ne,onToggle:()=>z(de.sessionId)}),!ne&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Le.map(fe=>oe(fe))})]},`${de.dirName}/${de.fileName}`)},e[79]=O,e[80]=oe,e[81]=$,e[82]=Ce):Ce=e[82],Pe=Y.map(Ce),e[74]=O,e[75]=oe,e[76]=$,e[77]=Y,e[78]=Pe}else Pe=e[78];let Oe;e[83]!==V?(Oe=V>0&&r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!0),className:"justify-start",children:[r.jsx(st,{"data-icon":"inline-start"}),"Show ",V," more"]}),e[83]=V,e[84]=Oe):Oe=e[84];let Fe;e[85]!==Q?(Fe=Q&&r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!1),className:"justify-start",children:[r.jsx(hr,{"data-icon":"inline-start"}),"Show less"]}),e[85]=Q,e[86]=Fe):Fe=e[86];let ze;e[87]!==Te||e[88]!==Pe||e[89]!==Oe||e[90]!==Fe?(ze=r.jsxs("div",{className:"flex flex-col gap-px",children:[Te,Pe,Oe,Fe]}),e[87]=Te,e[88]=Pe,e[89]=Oe,e[90]=Fe,e[91]=ze):ze=e[91];let Be;e[92]!==P||e[93]!==ze?(Be=r.jsx(Nt,{id:P,className:"ml-3 border-l pl-1",children:ze}),e[92]=P,e[93]=ze,e[94]=Be):Be=e[94];let _e;return e[95]!==Re||e[96]!==Be||e[97]!==se?(_e=r.jsxs(kt,{open:se,className:"flex flex-col",children:[Re,Be]}),e[95]=Re,e[96]=Be,e[97]=se,e[98]=_e):_e=e[98],_e}function wA(n){return!la(n.cwd??gn(n.dirName))}function jA(n){return n.sessionId}function SA(n){const e=B.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(rt,{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 kA=v.memo(function(e){const t=B.c(122),{activeSessionKey:s,onSelectSession:o,onDuplicateSession:i,onDeleteSession:a,onNewSession:l,creatingSession:c,pendingSession:d,refreshRef:f,onPrefetchSession:u}=e,{names:m,rename:p}=M0(),{names:h,rename:g}=H0(),x=zc(),b=yn("terminal"),w=yn("killAny"),{sessions:y,procBySession:j,newlyCompleted:k,loading:N,error:C,refresh:S,removeSession:_,acknowledgeCompleted:P}=Sx(),{awaitingPermission:A,awaitingQuestion:T,awaitingElicitation:E,awaitingDialog:M,awaitingPlan:I}=XP();let R;t[0]!==M||t[1]!==E?(R=new Set([...E,...M]),t[0]=M,t[1]=E,t[2]=R):R=t[2];const $=R;let D;t[3]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,t[3]=D):D=t[3];const[O,L]=v.useState(D),[F,z]=v.useState("");let H,U;t[4]===Symbol.for("react.memo_cache_sentinel")?(H=Lt("live-sessions-collapsed-projects"),U={},t[4]=H,t[5]=U):(H=t[4],U=t[5]);const[W,K]=ja(H,U);let q;t[6]!==K?(q=(Ge,et)=>{K(mt=>({...mt,[Ge]:et}))},t[6]=K,t[7]=q):q=t[7];const Y=q,V=v.useRef(y);let Q;t[8]===Symbol.for("react.memo_cache_sentinel")?(Q=new Set,t[8]=Q):Q=t[8];const Z=v.useRef(Q),X=v.useRef(!1);let ee;t[9]===Symbol.for("react.memo_cache_sentinel")?(ee=(Ge,et)=>{if(!X.current)return;const mt=setTimeout(()=>{Z.current.delete(mt),X.current&&Ge()},et);Z.current.add(mt)},t[9]=ee):ee=t[9];const oe=ee;let se,re;t[10]===Symbol.for("react.memo_cache_sentinel")?(se=()=>{const Ge=Z.current;return X.current=!0,()=>{X.current=!1;for(const et of Ge)clearTimeout(et);Ge.clear()}},re=[],t[10]=se,t[11]=re):(se=t[10],re=t[11]),v.useEffect(se,re);let ie,ae;t[12]!==y?(ie=()=>{V.current=y},ae=[y],t[12]=y,t[13]=ie,t[14]=ae):(ie=t[13],ae=t[14]),v.useEffect(ie,ae);let te,he;t[15]!==S||t[16]!==f?(te=()=>{if(f)return f.current=S,()=>{f.current===S&&(f.current=null)}},he=[S,f],t[15]=S,t[16]=f,t[17]=te,t[18]=he):(te=t[17],he=t[18]),v.useEffect(te,he);const me=Ca(),le=K0(F);let xe;e:{if(!F.trim()){xe=y;break e}let Ge;if(t[19]!==h||t[20]!==F||t[21]!==m||t[22]!==y){let et;t[24]!==h||t[25]!==F||t[26]!==m?(et=mt=>{const zt=m[mt.sessionId],en=h[mt.dirName];return L0(mt,F,[zt,en])},t[24]=h,t[25]=F,t[26]=m,t[27]=et):et=t[27],Ge=y.filter(et),t[19]=h,t[20]=F,t[21]=m,t[22]=y,t[23]=Ge}else Ge=t[23];xe=Ge}const ge=xe,ce=le.results??ge;let we;t[28]!==ce?(we=LC(ce),t[28]=ce,t[29]=we):we=t[29];const pe=we;let ue;t[30]!==A||t[31]!==I||t[32]!==$||t[33]!==T||t[34]!==k||t[35]!==j||t[36]!==y?(ue=ZP(y,j,k,A,T,$,I),t[30]=A,t[31]=I,t[32]=$,t[33]=T,t[34]=k,t[35]=j,t[36]=y,t[37]=ue):ue=t[37];const je=ue,Ne=je.needsYou.length>0||je.working.length>0;let Re;t[38]!==Ne||t[39]!==F?(Re=!F.trim()&&Ne,t[38]=Ne,t[39]=F,t[40]=Re):Re=t[40];const Te=Re;let Pe;e:{if(!d){Pe=null;break e}let Ge;t[41]!==d.cwd||t[42]!==d.dirName?(Ge=d.cwd||gn(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=Ge):Ge=t[43];let et;t[44]!==Ge?(et=xd(Ge),t[44]=Ge,t[45]=et):et=t[45],Pe=et}const Oe=Pe,Fe=v.useRef(!1);let ze,Be;t[46]!==u||t[47]!==y?(ze=()=>{if(Fe.current||!u||y.length===0)return;Fe.current=!0;const Ge=gd(y).slice(0,3),et=globalThis,mt=()=>{for(const Us of Ge)u(Us.dirName,Us.fileName)};let zt=null,en=null;return typeof et.requestIdleCallback=="function"?zt=et.requestIdleCallback(mt,{timeout:1500}):en=setTimeout(mt,300),()=>{zt!=null&&typeof et.cancelIdleCallback=="function"&&et.cancelIdleCallback(zt),en!=null&&clearTimeout(en)}},Be=[y,u],t[46]=u,t[47]=y,t[48]=ze,t[49]=Be):(ze=t[48],Be=t[49]),v.useEffect(ze,Be);let _e;t[50]!==S?(_e=async(Ge,et)=>{et.stopPropagation(),L(mt=>new Set(mt).add(Ge));try{await ye("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:Ge})}),oe(S,1500)}catch{}oe(()=>{L(mt=>{const zt=new Set(mt);return zt.delete(Ge),zt})},2e3)},t[50]=S,t[51]=_e):_e=t[51];const He=_e;let Ie;t[52]!==P||t[53]!==o?(Ie=(Ge,et)=>{const mt=V.current.find(zt=>zt.dirName===Ge&&zt.fileName===et);mt&&P(mt.sessionId),o(Ge,et)},t[52]=P,t[53]=o,t[54]=Ie):Ie=t[54];const Ce=Ie;let de;t[55]!==a||t[56]!==_?(de=Ge=>{a==null||a(Ge.dirName,Ge.fileName),_(Ge.sessionId)},t[55]=a,t[56]=_,t[57]=de):de=t[57];const Ee=de;let Ae;t[58]!==S||t[59]!==x?(Ae=(Ge,et,mt)=>{const{command:zt,args:en}=jy(St(mt),Ge),Us=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Us,name:`Resume ${Ge.slice(0,8)}`,command:zt,args:en,cwd:et??void 0,metadata:{type:"terminal"}}),oe(S,3e3)},t[58]=S,t[59]=x,t[60]=Ae):Ae=t[60];const Le=Ae;let ne;t[61]!==S?(ne=()=>{JP(),S()},t[61]=S,t[62]=ne):ne=t[62];let fe;t[63]!==me||t[64]!==N||t[65]!==le.loading||t[66]!==F||t[67]!==ne?(fe=r.jsx(mA,{loading:N,isMobile:me,searchQuery:F,searchLoading:le.loading,onSearchQueryChange:z,onRefresh:ne}),t[63]=me,t[64]=N,t[65]=le.loading,t[66]=F,t[67]=ne,t[68]=fe):fe=t[68];const Se=le.error??C,$e=ce.length===0&&!d&&!N&&!le.loading&&!C&&!le.error;let Ue;t[69]!==F?(Ue=F.trim(),t[69]=F,t[70]=Ue):Ue=t[70];const We=!!Ue,Xe=N||le.loading,Je=le.active?ce.length:y.length,De=le.error?le.refresh:S;let qe;t[71]!==Se||t[72]!==$e||t[73]!==We||t[74]!==Xe||t[75]!==Je||t[76]!==De?(qe=r.jsx(hA,{fetchError:Se,showEmpty:$e,searching:We,loading:Xe,sessionCount:Je,onRetry:De}),t[71]=Se,t[72]=$e,t[73]=We,t[74]=Xe,t[75]=Je,t[76]=De,t[77]=qe):qe=t[77];let ot;t[78]!==s||t[79]!==je||t[80]!==w||t[81]!==b||t[82]!==He||t[83]!==Le||t[84]!==Ce||t[85]!==O||t[86]!==u||t[87]!==j||t[88]!==h||t[89]!==m||t[90]!==Te?(ot=Te&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(fA,{groups:je,activeSessionKey:s,procBySession:j,killingPids:O,sessionNames:m,projectNames:h,onSelectSession:Ce,onKill:w?He:void 0,onResumeSession:b?Le: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(It,{className:"flex-1"})]})]}),t[78]=s,t[79]=je,t[80]=w,t[81]=b,t[82]=He,t[83]=Le,t[84]=Ce,t[85]=O,t[86]=u,t[87]=j,t[88]=h,t[89]=m,t[90]=Te,t[91]=ot):ot=t[91];const lt=w?He:void 0,bt=a?Ee:void 0,$t=b?Le:void 0;let Vt;t[92]!==s||t[93]!==W||t[94]!==c||t[95]!==pe||t[96]!==Ce||t[97]!==O||t[98]!==k||t[99]!==i||t[100]!==l||t[101]!==u||t[102]!==Oe||t[103]!==d||t[104]!==j||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==F||t[109]!==m||t[110]!==lt||t[111]!==bt||t[112]!==$t||t[113]!==Y?(Vt=r.jsx(yA,{grouped:pe,pendingProjectPath:Oe,pendingSession:d,collapsedGroups:W,searchQuery:F,activeSessionKey:s,procBySession:j,killingPids:O,newlyCompleted:k,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Ce,onKill:lt,onDuplicateSession:i,onDeleteSession:bt,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:u,onResumeSession:$t}),t[92]=s,t[93]=W,t[94]=c,t[95]=pe,t[96]=Ce,t[97]=O,t[98]=k,t[99]=i,t[100]=l,t[101]=u,t[102]=Oe,t[103]=d,t[104]=j,t[105]=h,t[106]=g,t[107]=p,t[108]=F,t[109]=m,t[110]=lt,t[111]=bt,t[112]=$t,t[113]=Y,t[114]=Vt):Vt=t[114];let Wt;t[115]!==qe||t[116]!==ot||t[117]!==Vt?(Wt=r.jsx(Cr,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[qe,ot,Vt]})}),t[115]=qe,t[116]=ot,t[117]=Vt,t[118]=Wt):Wt=t[118];let ts;return t[119]!==fe||t[120]!==Wt?(ts=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[fe,Wt]}),t[119]=fe,t[120]=Wt,t[121]=ts):ts=t[121],ts}),NA=v.memo(function(e){const t=B.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 x;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?(x=r.jsx(kA,{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]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),CA=v.lazy(()=>Ke(()=>import("./index-cAtUK6__.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.MissionControl})));function Z0(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Bt,{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 e2(n){const e=B.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=it(),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(NA,{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 t2(n){const e=B.c(8),{navigation:t}=n,{state:s}=Rt();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(HP,{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 _A(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Z0,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(v.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(CA,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function TA({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function EA({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function PA({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}
|
|
120
|
+
`)}function AP(n){var t;const e=n.cwd?(t=la(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:sy,label:e,title:n.cwd}:n.gitBranch?{icon:vo,label:n.gitBranch}:null}function RP(n,e){return n.agentStatus==="deferred"?"attention":e?mr(n.agentStatus)?"idle":"working":null}function MP(n){const e=B.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(Me,{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=mr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=Mr(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=$d(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(Me,{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=Ed(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Me,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function El(n){const e=B.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 IP(n){const e=B.c(99),{session:t,customName:s,onSelect:o}=n,i=t.lastActivityAt||t.lastModified;let a,l;e[0]!==i||e[1]!==t?(a=z0(i),l=RP(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,x,b,w,y,j,k,N,C;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const $=AP(t);let D;e[25]!==i||e[26]!==t.timestamp?(D=EP(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=D):D=e[27];const O=D,L=t.turnCount??0;let F,z;e[28]!==s||e[29]!==t?(z=F0(t,s),F=_P(t,z),e[28]=s,e[29]=t,e[30]=F,e[31]=z):(F=e[30],z=e[31]);const H=F;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=PP(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 U;e[34]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(Ku,{className:"size-4"}),e[34]=U):U=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",Ms[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:[U,W]}),e[37]=W,e[38]=h):h=e[38],k="flex min-w-0 flex-1 flex-col gap-1";let K;e[39]!==z?(K=r.jsx("span",{className:"truncate text-sm font-medium",children:z}),e[39]=z,e[40]=K):K=e[40];let q;e[41]!==d?(q=d&&r.jsxs(Me,{variant:"outline",className:"shrink-0",children:[r.jsx(co,{"data-icon":"inline-start"}),pn(d,18)]}),e[41]=d,e[42]=q):q=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Me,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(_c,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let V;e[45]!==a||e[46]!==t?(V=r.jsx(MP,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=V):V=e[47];let Q;e[48]!==i?(Q=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Sr(i)}),e[48]=i,e[49]=Q):Q=e[49];let Z;e[50]!==V||e[51]!==Q?(Z=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[V,Q]}),e[50]=V,e[51]=Q,e[52]=Z):Z=e[52],e[53]!==K||e[54]!==q||e[55]!==Y||e[56]!==Z?(N=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[K,q,Y,Z]}),e[53]=K,e[54]=q,e[55]=Y,e[56]=Z,e[57]=N):N=e[57],e[58]!==H?(C=H&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:H}),e[58]=H,e[59]=C):C=e[59],x="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(b=t.model&&r.jsx(Me,{variant:"outline",children:ia(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==L?(w=L>0&&r.jsxs(El,{icon:Ku,children:[L," ",L===1?"turn":"turns"]}),e[62]=L,e[63]=w):w=e[63],e[64]!==O?(y=O&&r.jsx(El,{icon:Is,title:"First prompt to last activity",children:O}),e[64]=O,e[65]=y):y=e[65],j=$&&r.jsx(El,{icon:$.icon,className:"max-w-40 truncate",title:$.title,children:pn($.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]=x,e[18]=b,e[19]=w,e[20]=y,e[21]=j,e[22]=k,e[23]=N,e[24]=C}else f=e[11],u=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],y=e[20],j=e[21],k=e[22],N=e[23],C=e[24];let S;e[66]!==t.size?(S=og(t.size),e[66]=t.size,e[67]=S):S=e[67];let _;e[68]!==S?(_=r.jsx("span",{children:S}),e[68]=S,e[69]=_):_=e[69];let P;e[70]!==_||e[71]!==x||e[72]!==b||e[73]!==w||e[74]!==y||e[75]!==j?(P=r.jsxs("span",{className:x,children:[b,w,y,j,_]}),e[70]=_,e[71]=x,e[72]=b,e[73]=w,e[74]=y,e[75]=j,e[76]=P):P=e[76];let A;e[77]!==P||e[78]!==k||e[79]!==N||e[80]!==C?(A=r.jsxs("span",{className:k,children:[N,C,P]}),e[77]=P,e[78]=k,e[79]=N,e[80]=C,e[81]=A):A=e[81];let T;e[82]!==f||e[83]!==u||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==A?(T=r.jsxs("button",{type:f,onClick:u,title:m,className:p,children:[h,A]}),e[82]=f,e[83]=u,e[84]=m,e[85]=p,e[86]=h,e[87]=A,e[88]=T):T=e[88];let E;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(E=t.matchedPullRequestNumber?r.jsxs(Me,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Ra,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=E):E=e[91];let M;e[92]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Ze,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=M):M=e[92];let I;e[93]!==E?(I=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[E,M]}),e[93]=E,e[94]=I):I=e[94];let R;return e[95]!==g||e[96]!==T||e[97]!==I?(R=r.jsxs("div",{className:g,children:[T,I]}),e[95]=g,e[96]=T,e[97]=I,e[98]=R):R=e[98],R}function $P(n){const e=B.c(61),{selectedProject:t,sessions:s,sessionsTotal:o,sessionsLoading:i,searchLoading:a,searchFilter:l,setSearchFilter:c,filteredSessions:d,fetchError:f,onSelectSession:u,onNewSession:m,creatingSession:p,onDuplicateSession:h,onDeleteSession:g,onBack:x,onRetryFetch:b,loadMoreSessions:w}=n,{names:y,rename:j}=M0();let k;e[0]!==t.path?(k=zn(t.path),e[0]=t.path,e[1]=k):k=e[1];const N=k;let C;e[2]!==x?(C=r.jsx(up,{children:r.jsx(mP,{render:r.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=C):C=e[3];let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(hP,{}),e[4]=S):S=e[4];let _;e[5]!==N?(_=r.jsx(up,{className:"min-w-0",children:r.jsx(pP,{className:"truncate",children:N})}),e[5]=N,e[6]=_):_=e[6];let P;e[7]!==C||e[8]!==_?(P=r.jsx(uP,{children:r.jsxs(fP,{children:[C,S,_]})}),e[7]=C,e[8]=_,e[9]=P):P=e[9];let A;e[10]!==N?(A=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:N}),e[10]=N,e[11]=A):A=e[11];let T;e[12]!==o?(T=r.jsx(Me,{variant:"secondary",children:o}),e[12]=o,e[13]=T):T=e[13];let E;e[14]!==A||e[15]!==T?(E=r.jsxs("div",{className:"flex items-center gap-2",children:[A,T]}),e[14]=A,e[15]=T,e[16]=E):E=e[16];let M;e[17]!==t.path?(M=aa(t.path),e[17]=t.path,e[18]=M):M=e[18];let I;e[19]!==M?(I=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:M}),e[19]=M,e[20]=I):I=e[20];let R;e[21]!==I||e[22]!==E?(R=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[E,I]}),e[21]=I,e[22]=E,e[23]=R):R=e[23];let $;e[24]!==l||e[25]!==a||e[26]!==c?($=r.jsx(I0,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:a}),e[24]=l,e[25]=a,e[26]=c,e[27]=$):$=e[27];let D;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(D=m&&r.jsxs(J,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(Bt,{"data-icon":"inline-start"}):r.jsx(Tn,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=D):D=e[32];let O;e[33]!==$||e[34]!==D?(O=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[$,D]}),e[33]=$,e[34]=D,e[35]=O):O=e[35];let L;e[36]!==f||e[37]!==b?(L=f&&r.jsx($0,{message:f,onRetry:b}),e[36]=f,e[37]=b,e[38]=L):L=e[38];let F;e[39]!==d||e[40]!==w||e[41]!==g||e[42]!==h||e[43]!==u||e[44]!==j||e[45]!==l||e[46]!==a||e[47]!==t.dirName||e[48]!==y||e[49]!==s||e[50]!==i||e[51]!==o?(F=(i||a)&&d.length===0?r.jsx(O0,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(Hn,{className:"min-h-72 border",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(Qi,{})}),r.jsx(qn,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(Vn,{children:l?"Try #157, honest-cms #157, or paste a PR URL.":"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:d.map((U,W)=>r.jsxs(v.Fragment,{children:[W>0&&r.jsx(It,{}),r.jsx(P0,{sessionLabel:F0(U),customName:y[U.sessionId],onRename:K=>j(U.sessionId,K),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(IP,{session:U,customName:y[U.sessionId],onSelect:()=>u(t.dirName,U.fileName)})})]},U.fileName))}),s.length<o&&!l&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(J,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(Bt,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=w,e[41]=g,e[42]=h,e[43]=u,e[44]=j,e[45]=l,e[46]=a,e[47]=t.dirName,e[48]=y,e[49]=s,e[50]=i,e[51]=o,e[52]=F):F=e[52];let z;e[53]!==O||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[O,L,F]}),e[53]=O,e[54]=L,e[55]=F,e[56]=z):z=e[56];let H;return e[57]!==R||e[58]!==z||e[59]!==P?(H=r.jsx(Cr,{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:[P,R,z]})}),e[57]=R,e[58]=z,e[59]=P,e[60]=H):H=e[60],H}function OP(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=v.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=yr(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 B0(n){const e=B.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=v.useState(!1),[d,f]=v.useState(""),u=v.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 x;e[6]!==t||e[7]!==g?(x=r.jsx(ka,{render:g,children:t}),e[6]=t,e[7]=g,e[8]=x):x=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Ls,{"data-icon":"inline-start"}),e[9]=b):b=e[9];let w;e[10]!==p?(w=r.jsx(Na,{className:"min-w-44",children:r.jsx(lo,{children:r.jsxs(Yt,{onClick:p,children:[b,"Rename project"]})})}),e[10]=p,e[11]=w):w=e[11];let y;e[12]!==x||e[13]!==w?(y=r.jsxs(Sa,{children:[x,w]}),e[12]=x,e[13]=w,e[14]=y):y=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(ks,{children:[r.jsx(Xn,{className:"text-foreground",children:"Rename project"}),r.jsx(Jn,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[15]=j):j=e[15];let k;e[16]!==a||e[17]!==d?(k=E=>{E.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=k):k=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(xt,{htmlFor:"project-rename",children:"Project name"}),e[19]=N):N=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=E=>f(E.target.value),e[20]=C):C=e[20];let S;e[21]!==s||e[22]!==d?(S=r.jsxs(gt,{children:[N,r.jsx(Ot,{id:"project-rename",ref:u,value:d,onChange:C,placeholder:s})]}),e[21]=s,e[22]=d,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(Jh,{children:[r.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[24]=_):_=e[24];let P;e[25]!==S||e[26]!==k?(P=r.jsxs(Yn,{className:"sm:max-w-md",children:[j,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:k,children:[S,_]})]}),e[25]=S,e[26]=k,e[27]=P):P=e[27];let A;e[28]!==l||e[29]!==P?(A=r.jsx(Gn,{open:l,onOpenChange:c,children:P}),e[28]=l,e[29]=P,e[30]=A):A=e[30];let T;return e[31]!==A||e[32]!==y?(T=r.jsxs(r.Fragment,{children:[y,A]}),e[31]=A,e[32]=y,e[33]=T):T=e[33],T}const U0="project-custom-names";function W0(){try{const n=localStorage.getItem(Lt(U0));return n?JSON.parse(n):{}}catch{return{}}}function DP(n){localStorage.setItem(Lt(U0),JSON.stringify(n))}let zi=W0();const Fi=new Set;if(typeof window<"u"){const n=()=>{zi=W0();for(const e of Fi)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function LP(n){return Fi.add(n),()=>{Fi.delete(n)}}function zP(){return zi}function FP(n,e){const t={...zi},s=e.trim();s?t[n]=s:delete t[n],DP(t),zi=t;for(const o of Fi)o()}function H0(){const n=B.c(2),e=v.useSyncExternalStore(LP,zP);let t;return n[0]!==e?(t={names:e,rename:FP},n[0]=e,n[1]=t):t=n[1],t}function BP(n){const e=B.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)z0(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}=H0();let x;e:{if(!a){x=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==a){const $=a.toLowerCase();R=t.filter(D=>{var O;return D.path.toLowerCase().includes($)||D.shortName.toLowerCase().includes($)||((O=h[D.dirName])==null?void 0:O.toLowerCase().includes($))}),e[2]=h,e[3]=t,e[4]=a,e[5]=R}else R=e[5];x=R}const b=x;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(Me,{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 k;e[10]!==y?(k=r.jsxs("header",{className:"flex flex-col gap-1",children:[y,j]}),e[10]=y,e[11]=k):k=e[11];let N;e[12]!==a||e[13]!==l?(N=r.jsx(I0,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=N):N=e[14];const C=i&&"animate-spin";let S;e[15]!==C?(S=G(C),e[15]=C,e[16]=S):S=e[16];let _;e[17]!==S?(_=r.jsx(Qt,{"data-icon":"inline-start",className:S}),e[17]=S,e[18]=_):_=e[18];let P;e[19]!==u||e[20]!==i||e[21]!==_?(P=r.jsxs(J,{variant:"outline",size:"sm",onClick:u,disabled:i,"aria-label":"Refresh projects",children:[_,"Refresh"]}),e[19]=u,e[20]=i,e[21]=_,e[22]=P):P=e[22];let A;e[23]!==P||e[24]!==N?(A=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[N,P]}),e[23]=P,e[24]=N,e[25]=A):A=e[25];let T;e[26]!==c||e[27]!==u||e[28]!==d?(T=c&&!d&&r.jsx($0,{message:c,onRetry:u}),e[26]=c,e[27]=u,e[28]=d,e[29]=T):T=e[29];let E;e[30]!==p||e[31]!==b||e[32]!==o||e[33]!==f||e[34]!==h||e[35]!==g||e[36]!==a?(E=o?r.jsx(O0,{}):b.length===0?r.jsx(Hn,{className:"min-h-72 border",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(Qo,{})}),r.jsx(qn,{children:a?"No projects match your search":"No projects yet"}),r.jsx(Vn,{children:a?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]})}):r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:b.map((R,$)=>{const D=p[R.dirName]||0,O=h[R.dirName],L=Mw(St(R.dirName));return r.jsxs(v.Fragment,{children:[$>0&&r.jsx(It,{}),r.jsx(B0,{projectLabel:zn(R.path),customName:O,onRename:F=>g(R.dirName,F),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(OP,{projectPath:R.path,className:"size-4",fallback:r.jsx(Qo,{className:"size-4 text-muted-foreground"})})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-medium",children:O||zn(R.path)}),L&&r.jsx(Me,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:L})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:aa(R.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[D>0&&r.jsxs(Me,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),D," 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:Sr(R.lastModified)}),r.jsx(Ze,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=b,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]!==A||e[39]!==T||e[40]!==E?(M=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,T,E]}),e[38]=A,e[39]=T,e[40]=E,e[41]=M):M=e[41];let I;return e[42]!==M||e[43]!==k?(I=r.jsx(Cr,{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:[k,M]})}),e[42]=M,e[43]=k,e[44]=I):I=e[44],I}const UP=250,WP=400,pp={results:null,loading:!1,error:null};function K0(n,e){const t=v.useMemo(()=>D0(n),[n]),[s,o]=v.useState(0),[i,a]=v.useState(pp);v.useEffect(()=>{if(!t){a(pp);return}const c=new AbortController;a({results:null,loading:!0,error:null});let d=null;const f=async()=>{const m=new URLSearchParams({search:n.trim(),limit:"200"});e&&m.set("project",e);try{const p=await ye(`/api/active-sessions?${m}`,{signal:c.signal});if(!p.ok)throw new Error(`Search failed (${p.status})`);const h=await p.json();if(c.signal.aborted)return;const g=Number(p.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(g)&&g>0){d=setTimeout(()=>{f()},WP);return}a({results:Array.isArray(h)?h:[],loading:!1,error:null})}catch(p){if(c.signal.aborted)return;a({results:[],loading:!1,error:p instanceof Error?p.message:"Search failed"})}},u=setTimeout(()=>{f()},UP);return()=>{clearTimeout(u),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=v.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const HP=v.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=v.useState(()=>({projects:Ei(Ln.projects),activeSessions:Ei(Ln.activeSessions)})),[d,f]=v.useState(c.projects??[]),[u,m]=v.useState(c.activeSessions??[]),[p,h]=v.useState(c.projects===void 0),[g,x]=v.useState(!1),[b,w]=v.useState([]),[y,j]=v.useState(0),[k,N]=v.useState(1),[C,S]=v.useState(!1),[_,P]=v.useState(""),[A,T]=v.useState(null),E=v.useRef(0),M=v.useRef(null),I=v.useCallback(async(U=!1)=>{U&&x(!0);try{const[W,K]=await Promise.all([ye("/api/projects"),ye("/api/active-sessions")]);if(!W.ok||!K.ok)throw new Error("Failed to fetch dashboard data");const q=await W.json(),Y=await K.json(),V=Array.isArray(q)?q:[],Q=Array.isArray(Y)?Y:[];f(V),m(Q),qo(Ln.projects,V),qo(Ln.activeSessions,Q),T(null)}catch(W){T(W instanceof Error?W.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);v.useEffect(()=>{I()},[I]);const R=v.useCallback(async(U,W=1,K=!1)=>{var Q;const q=++E.current;(Q=M.current)==null||Q.abort();const Y=new AbortController;M.current=Y;const V=()=>q===E.current;if(S(!0),T(null),!K){const Z=VC(U);Z?(w(Z.sessions),j(Z.total),N(1)):w([])}try{const Z=await ye(`/api/sessions/${encodeURIComponent(U)}?page=${W}&limit=20`,{signal:Y.signal});if(!Z.ok)throw new Error(`Failed to load sessions (${Z.status})`);const X=await Z.json();if(!V())return;const ee=Array.isArray(X.sessions)?X.sessions:[],oe=typeof X.total=="number"?X.total:ee.length;w(se=>K?[...se,...ee]:ee),j(oe),N(W),K||GC(U,{sessions:ee,total:oe})}catch(Z){if(!V()||Y.signal.aborted)return;T(Z instanceof Error?Z.message:"Failed to load sessions")}finally{V()&&(M.current=null,S(!1))}},[]);v.useEffect(()=>{var U;if(!o){E.current+=1,(U=M.current)==null||U.abort(),M.current=null,w([]),j(0),N(1),P(""),S(!1);return}P(""),R(o)},[o,R]),v.useEffect(()=>()=>{var U;E.current+=1,(U=M.current)==null||U.abort()},[]);const $=v.useMemo(()=>{if(!o)return null;const U=d.find(K=>K.dirName===o);if(U)return U;const W=gn(o);return{dirName:o,path:W,shortName:zn(W),sessionCount:y,lastModified:null}},[o,d,y]),D=v.useCallback(()=>{i==null||i(null)},[i]),O=v.useCallback(()=>{o&&R(o,k+1,!0)},[o,k,R]),L=K0(o?_:"",o??void 0),F=v.useMemo(()=>_?b.filter(U=>TP(U,_)):b,[b,_]),z=L.results??F;function H(U,W){l==null||l(U,W),w(K=>K.filter(q=>q.fileName!==W)),j(K=>K-1)}return $?r.jsx($P,{selectedProject:$,sessions:b,sessionsTotal:y,sessionsLoading:C,searchLoading:L.loading,searchFilter:_,setSearchFilter:P,filteredSessions:z,fetchError:L.error??A,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:H,onBack:D,onRetryFetch:()=>{if(L.error){L.refresh();return}T(null),o&&R(o)},loadMoreSessions:O}):r.jsx(BP,{projects:d,activeSessions:u,loading:p,refreshing:g,searchFilter:_,setSearchFilter:P,fetchError:A,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>I(!0)})});async function q0(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 KP(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 V0(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 qP(n,e,t){return V0("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function VP(n,e,t){return V0("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const GP=3e3,G0=v.createContext(null);async function Pl(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 Ro(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 ci(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 YP({children:n}){const[e,t]=v.useState(new Map),[s,o]=v.useState(new Map),[i,a]=v.useState(new Map),[l,c]=v.useState(new Map),[d,f]=v.useState(new Set),[u,m]=v.useState(new Set),p=v.useRef(""),h=v.useRef(""),g=v.useRef(""),x=v.useCallback(async()=>{const[T,E,M]=await Promise.all([Pl("/api/permissions",p),Pl("/api/user-questions",h),Pl("/api/agent-prompts",g)]);T&&(t(Ro(T.bySession)),f(new Set(Ro(T.plansBySession).keys()))),E&&o(Ro(E.bySession)),M&&(a(Ro(M.elicitationsBySession)),c(Ro(M.dialogsBySession)))},[]);v.useEffect(()=>{const T=()=>{document.visibilityState==="visible"&&x()};T();const E=setInterval(T,GP);return document.addEventListener("visibilitychange",T),()=>{clearInterval(E),document.removeEventListener("visibilitychange",T)}},[x]);const b=v.useCallback(async(T,E)=>{m(M=>new Set(M).add(T));try{return await E()}finally{m(M=>{const I=new Set(M);return I.delete(T),I}),x()}},[x]),w=v.useCallback((T,E,M)=>b(E,async()=>{await q0(T,E,M).catch(()=>!1)&&(t(R=>ci(R,T,$=>$.requestId===E)),p.current="")}),[b]),y=v.useCallback((T,E,M)=>b(E,async()=>{const I=await Oc(T,E,M);return I.ok&&(o(R=>ci(R,T,$=>$.toolUseId===E)),h.current=""),I}),[b]),j=v.useCallback((T,E,M)=>b(E,async()=>{const I=await qP(T,E,M);return I.ok&&(a(R=>ci(R,T,$=>$.requestId===E)),g.current=""),I}),[b]),k=v.useCallback((T,E,M)=>b(E,async()=>{const I=await VP(T,E,M);return I.ok&&(c(R=>ci(R,T,$=>$.requestId===E)),g.current=""),I}),[b]),N=v.useMemo(()=>new Set(e.keys()),[e]),C=v.useMemo(()=>new Set(s.keys()),[s]),S=v.useMemo(()=>new Set(i.keys()),[i]),_=v.useMemo(()=>new Set(l.keys()),[l]),P=v.useCallback(()=>{x()},[x]),A=v.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:N,awaitingQuestion:C,awaitingElicitation:S,awaitingDialog:_,awaitingPlan:d,responding:u,respond:w,answerQuestion:y,answerElicitation:j,answerDialog:k,refresh:P}),[e,s,i,l,N,C,S,_,d,u,w,y,j,k,P]);return r.jsx(G0.Provider,{value:A,children:n})}function XP(){const n=v.useContext(G0);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const Y0=typeof navigator<"u"&&"vibrate"in navigator;function mc(){Y0&&navigator.vibrate(10)}function JP(){Y0&&navigator.vibrate(20)}function QP(n){return!!(n.teamName&&n.agentName)}function ZP(n,e,t,s,o,i,a){const l=[],c=[];for(const d of gd(n)){if(s!=null&&s.has(d.sessionId)){l.push({session:d,reason:"permission"});continue}if(o!=null&&o.has(d.sessionId)){l.push({session:d,reason:"question"});continue}if(i!=null&&i.has(d.sessionId)){l.push({session:d,reason:"prompt"});continue}if(a!=null&&a.has(d.sessionId)){l.push({session:d,reason:"plan"});continue}if(d.agentStatus==="deferred"){l.push({session:d,reason:"deferred"});continue}if(QP(d))continue;const f=gx(d,e);if(d.agentStatus==="completed"||!f){t.has(d.sessionId)&&l.push({session:d,reason:"done"});continue}if(d.agentStatus==="idle"){l.push({session:d,reason:"waiting"});continue}(!d.agentStatus||bd.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function eA(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"}}function Od(n,e){return n?Ut(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const X0="aw:turnCounts",tA=200,Ia=new Map;try{const n=localStorage.getItem(X0);if(n){const e=JSON.parse(n);for(const[t,s]of e)Ia.set(t,s)}}catch{}function nA(){try{const n=[...Ia.entries()].slice(-tA);localStorage.setItem(X0,JSON.stringify(n))}catch{}}function sA(n,e){Ia.set(Lt(n),e),nA()}function oA(n,e){const t=Ia.get(Lt(n));return Math.max(t??0,e??0)}function J0(n){const e=B.c(40),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a}=n,l=i||t.aiTitle,c=t.lastUserMessage||t.firstUserMessage,d=oA(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",$d(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(Wn,{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(Ra,{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(vo,{className:"size-2.5"}),a?`${t.gitBranch} · ${a}`:t.gitBranch]}),e[12]=t.gitBranch,e[13]=a,e[14]=g):g=e[14];let x;e[15]!==d?(x=d>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Qi,{className:"size-2.5"}),d," ",d===1?"turn":"turns"]}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==t.size?(b=og(t.size),e[17]=t.size,e[18]=b):b=e[18];let w;e[19]!==b?(w=r.jsx("span",{children:b}),e[19]=b,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(oy,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=y):y=e[22];const j=t.lastActivityAt||t.lastModified;let k;e[23]!==j?(k=Sr(j),e[23]=j,e[24]=k):k=e[24];let N;e[25]!==k?(N=r.jsx("span",{children:k}),e[25]=k,e[26]=N):N=e[26];let C;e[27]!==y||e[28]!==N||e[29]!==g||e[30]!==x||e[31]!==w?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[g,x,w,y,N]}),e[27]=y,e[28]=N,e[29]=g,e[30]=x,e[31]=w,e[32]=C):C=e[32];let S;return e[33]!==f||e[34]!==C||e[35]!==u||e[36]!==m||e[37]!==p||e[38]!==h?(S=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[f,u,m,p,h,C]}),e[33]=f,e[34]=C,e[35]=u,e[36]=m,e[37]=p,e[38]=h,e[39]=S):S=e[39],S}const rA=120;function Q0(n){const e=B.c(7),t=v.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]),v.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,rA))},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 iA=6;function aA(n){const e=B.c(7),{iso:t}=n,[,s]=v.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(lA),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],v.useEffect(o,i);let a;e[3]!==t?(a=Sr(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 lA(n){return n+1}const cA={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"},plan:{label:"Review plan",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"}},dA={permission:Ms.attention,deferred:Ms.attention,waiting:Ms.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function hp(n){const e=B.c(76),{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,x=u===void 0?!1:u;let b;e[0]!==l||e[1]!==t.dirName?(b=Od(St(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const w=b;let y;e[3]!==s||e[4]!==w||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(y=w?"Read-only":Mr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=w,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=y):y=e[9];const j=y,k=!!h&&!w,{onHoverStart:N,onHoverEnd:C}=Q0(g),S=x?"px-2.5 py-2":"border px-2 py-2",_=a&&!x&&"ring-1 ring-ring";let P;e[10]!==i||e[11]!==S||e[12]!==_?(P=G("group relative w-full rounded-md text-left transition-colors",S,i,_),e[10]=i,e[11]=S,e[12]=_,e[13]=P):P=e[13];let A;e[14]!==x||e[15]!==a?(A=x&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=a,e[16]=A):A=e[16];const T=k&&"pr-20";let E;e[17]!==T?(E=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[17]=T,e[18]=E):E=e[18];let M;e[19]!==C||e[20]!==N||e[21]!==m||e[22]!==E?(M=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:N,onMouseLeave:C,onFocus:N,onBlur:C,className:E}),e[19]=C,e[20]=N,e[21]=m,e[22]=E,e[23]=M):M=e[23];const I=x&&"ring-0";let R;e[24]!==o||e[25]!==I?(R=G("size-1.5 shrink-0 rounded-full",o,I),e[24]=o,e[25]=I,e[26]=R):R=e[26];let $;e[27]!==R?($=r.jsx("span",{className:R,"aria-hidden":"true"}),e[27]=R,e[28]=$):$=e[28];let D;e[29]!==d||e[30]!==t?(D=px(t,d),e[29]=d,e[30]=t,e[31]=D):D=e[31];let O;e[32]!==D?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:D}),e[32]=D,e[33]=O):O=e[33];const L=x?"text-muted-foreground":s.className;let F;e[34]!==L?(F=G("shrink-0",L),e[34]=L,e[35]=F):F=e[35];const z=w?"Read-only":s.label;let H;e[36]!==F||e[37]!==z?(H=r.jsx(Me,{variant:"outline",className:F,children:z}),e[36]=F,e[37]=z,e[38]=H):H=e[38];let U;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(U=!x&&r.jsx(aA,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=U):U=e[42];let W;e[43]!==$||e[44]!==O||e[45]!==H||e[46]!==U?(W=r.jsxs("span",{className:"flex items-center gap-1.5",children:[$,O,H,U]}),e[43]=$,e[44]=O,e[45]=H,e[46]=U,e[47]=W):W=e[47];let K;e[48]!==f?(K=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[48]=f,e[49]=K):K=e[49];let q;e[50]!==M||e[51]!==W||e[52]!==K?(q=r.jsxs(Pt,{render:M,children:[W,K]}),e[50]=M,e[51]=W,e[52]=K,e[53]=q):q=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==j?(Y=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(J0,{session:t,proc:l,statusLabel:j,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=j,e[58]=Y):Y=e[58];let V;e[59]!==q||e[60]!==Y?(V=r.jsxs(Et,{children:[q,Y]}),e[59]=q,e[60]=Y,e[61]=V):V=e[61];let Q;e[62]!==k||e[63]!==h?(Q=k&&r.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(gr,{"data-icon":"inline-start"}),"Resume"]}),e[62]=k,e[63]=h,e[64]=Q):Q=e[64];let Z;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(Z=l&&p&&!w&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ee=>p(l.pid,ee),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(jt,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=Z):Z=e[69];let X;return e[70]!==V||e[71]!==Q||e[72]!==Z||e[73]!==P||e[74]!==A?(X=r.jsxs("div",{className:P,children:[A,V,Q,Z]}),e[70]=V,e[71]=Q,e[72]=Z,e[73]=P,e[74]=A,e[75]=X):X=e[75],X}function uA(n){const e=B.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 fA(n){const e=B.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]=v.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,iA),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let b;e[3]!==l?(b=S=>l[S.dirName]||xd(S.cwd||gn(S.dirName)),e[3]=l,e[4]=b):b=e[4];const w=b;let y;e[5]!==s||e[6]!==i||e[7]!==u||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(y=S=>{const _=s===`${S.dirName}/${S.fileName}`;return{session:S,isActiveSession:_,proc:o.get(S.sessionId),killingPids:i,customName:a[S.sessionId],projectLabel:w(S),onSelect:()=>c(S.dirName,S.fileName),onPrefetch:u&&!_?()=>u(S.dirName,S.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 k;e[13]!==t.needsYou||e[14]!==d||e[15]!==f||e[16]!==j?(k=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(uA,{dotClassName:Ms.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(S=>{const{session:_,reason:P}=S;return r.jsx(hp,{...j(_),chip:cA[P],dotClassName:dA[P],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:P==="deferred"&&f?()=>f(_.sessionId,_.cwd,_.dirName):void 0},`${_.dirName}/${_.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=f,e[16]=j,e[17]=k):k=e[17];let N;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==j||e[22]!==g?(N=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(S=>r.jsx(hp,{...j(S),chip:{label:eA(S),className:""},dotClassName:Ms.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${S.dirName}/${S.fileName}`))}),x>0&&r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(st,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=j,e[22]=g,e[23]=N):N=e[23];let C;return e[24]!==k||e[25]!==N?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[k,N]}),e[24]=k,e[25]=N,e[26]=C):C=e[26],C}function mA(n){const e=B.c(26),{loading:t,isMobile:s,searchQuery:o,searchLoading:i,onSearchQueryChange:a,onRefresh:l}=n;let c;e[0]!==a?(c=y=>a(y.target.value),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==o||e[4]!==c?(d=r.jsx(es,{type:"search",value:o,onChange:c,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":i}),e[2]=i,e[3]=o,e[4]=c,e[5]=d):d=e[5];let f;e[6]!==i?(f=r.jsx(wn,{align:"inline-start",children:i?r.jsx(rt,{className:"animate-spin"}):r.jsx(bn,{})}),e[6]=i,e[7]=f):f=e[7];let u;e[8]!==a||e[9]!==o?(u=o&&r.jsx(wn,{align:"inline-end",children:r.jsx(_r,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(jt,{"data-icon":"inline-start"})})}),e[8]=a,e[9]=o,e[10]=u):u=e[10];let m;e[11]!==d||e[12]!==f||e[13]!==u?(m=r.jsxs(Zn,{children:[d,f,u]}),e[11]=d,e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=s?"icon-sm":"icon-xs",h=t&&"animate-spin";let g;e[15]!==h?(g=G(h),e[15]=h,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(Qt,{"data-icon":"inline-start",className:g}),e[17]=g,e[18]=x):x=e[18];let b;e[19]!==l||e[20]!==p||e[21]!==x?(b=r.jsx(J,{variant:"ghost",size:p,onClick:l,"aria-label":"Refresh sessions",children:x}),e[19]=l,e[20]=p,e[21]=x,e[22]=b):b=e[22];let w;return e[23]!==b||e[24]!==m?(w=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[m,b]}),e[23]=b,e[24]=m,e[25]=w):w=e[25],w}const pA=["first","second","third","fourth","fifth"];function hA(n){const e=B.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(Ct,{variant:"destructive",children:[r.jsx(jn,{}),r.jsx(Dt,{children:"Could not load sessions"}),r.jsx(_t,{className:"truncate",children:t}),r.jsx(bs,{children:r.jsx(J,{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(Hn,{className:"min-h-56 px-4 py-8",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:o?r.jsx(bn,{}):r.jsx(fh,{})}),r.jsx(qn,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(Vn,{children:o?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot 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:pA.map(gA)}),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 gA(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(is,{className:"size-2 shrink-0 rounded-full"}),r.jsx(is,{className:"h-4 flex-1"}),r.jsx(is,{className:"h-4 w-10"})]},n)}function xA(n){var we;const e=B.c(116),{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:x,onPrefetchSession:b,onResumeSession:w}=n,y=o!==void 0,j=t.isActive===!0,k=y||j,N=j&&mr(t.agentStatus),C=t.agentStatus==="deferred";let S;e[0]!==o||e[1]!==t.dirName?(S=Od(St(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=S):S=e[2];const _=S,[P,A]=v.useState(!1),T=_?"Read-only":k?N?"Running":Mr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,E=C?"attention":k?mr(t.agentStatus)?"idle":"working":null,M=!!(t.teamName&&t.agentName);let I;e[3]!==l||e[4]!==t?(I=px(t,l),e[3]=l,e[4]=t,e[5]=I):I=e[5];const R=I;let $;e[6]!==s||e[7]!==b||e[8]!==t.dirName||e[9]!==t.fileName?($=b&&!s?()=>b(t.dirName,t.fileName):void 0,e[6]=s,e[7]=b,e[8]=t.dirName,e[9]=t.fileName,e[10]=$):$=e[10];const{onHoverStart:D,onHoverEnd:O}=Q0($);let L;e[11]!==w||e[12]!==P||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(L=pe=>{pe.stopPropagation(),!(!w||P)&&(A(!0),w(t.sessionId,t.cwd,t.dirName),setTimeout(()=>A(!1),3e3))},e[11]=w,e[12]=P,e[13]=t.cwd,e[14]=t.dirName,e[15]=t.sessionId,e[16]=L):L=e[16];const F=L;let z;e[17]!==y||e[18]!==s||e[19]!==j||e[20]!==a||e[21]!==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",bA(s,!j&&y&&t.agentStatus==="completed"&&!!a)),e[17]=y,e[18]=s,e[19]=j,e[20]=a,e[21]=t.agentStatus,e[22]=z):z=e[22];const H=Et,U=Pt;let W;e[23]!==m||e[24]!==t.dirName||e[25]!==t.fileName?(W=()=>m(t.dirName,t.fileName),e[23]=m,e[24]=t.dirName,e[25]=t.fileName,e[26]=W):W=e[26];let K;e[27]!==O||e[28]!==D||e[29]!==W?(K=r.jsx("button",{type:"button","data-live-session":!0,onClick:W,onMouseEnter:D,onMouseLeave:O,onFocus:D,onBlur:O,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[27]=O,e[28]=D,e[29]=W,e[30]=K):K=e[30];let q;e[31]!==E?(q=E&&r.jsx("span",{"data-status-dot":E,className:G("size-1.5 rounded-full",Ms[E])}),e[31]=E,e[32]=q):q=e[32];let Y;e[33]!==q?(Y=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:q}),e[33]=q,e[34]=Y):Y=e[34];let V;e[35]!==R?(V=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:R}),e[35]=R,e[36]=V):V=e[36];let Q;e[37]!==M||e[38]!==t.agentName||e[39]!==R?(Q=M&&r.jsxs(Me,{variant:"outline",children:[r.jsx(co,{"data-icon":"inline-start"}),R!==t.agentName?t.agentName:"Agent"]}),e[37]=M,e[38]=t.agentName,e[39]=R,e[40]=Q):Q=e[40];const Z=k&&!C&&T&&r.jsx(Me,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&$d(t.agentStatus)),children:T});let X;e[41]!==C?(X=C&&r.jsx(Me,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[41]=C,e[42]=X):X=e[42];let ee;e[43]!==c?(ee=c&&r.jsxs(Me,{variant:"outline",children:[r.jsx(vo,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=ee):ee=e[44];let oe;e[45]!==U||e[46]!==V||e[47]!==Q||e[48]!==Z||e[49]!==X||e[50]!==ee||e[51]!==K||e[52]!==Y?(oe=r.jsxs(U,{render:K,children:[Y,V,Q,Z,X,ee]}),e[45]=U,e[46]=V,e[47]=Q,e[48]=Z,e[49]=X,e[50]=ee,e[51]=K,e[52]=Y,e[53]=oe):oe=e[53];let se;e[54]!==l||e[55]!==o||e[56]!==t||e[57]!==T||e[58]!==c?(se=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(J0,{session:t,proc:o,statusLabel:T,customName:l,worktreeName:c})}),e[54]=l,e[55]=o,e[56]=t,e[57]=T,e[58]=c,e[59]=se):se=e[59];let re;e[60]!==H||e[61]!==oe||e[62]!==se?(re=r.jsxs(H,{children:[oe,se]}),e[60]=H,e[61]=oe,e[62]=se,e[63]=re):re=e[63];let ie;e[64]!==u||e[65]!==d||e[66]!==f?(ie=!!d&&u&&r.jsxs(J,{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(Wn,{"data-icon":"inline-start"}),d,r.jsx(Ze,{"data-icon":"inline-end",className:G("transition-transform duration-150",!f&&"rotate-90")})]}),e[64]=u,e[65]=d,e[66]=f,e[67]=ie):ie=e[67];let ae;e[68]!==F||e[69]!==C||e[70]!==_||e[71]!==w||e[72]!==P?(ae=C&&w&&!_&&r.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:F,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx(gr,{"data-icon":"inline-start"}),"Resume"]}),e[68]=F,e[69]=C,e[70]=_,e[71]=w,e[72]=P,e[73]=ae):ae=e[73];let te;e[74]!==t.matchedPullRequestNumber||e[75]!==t.pullRequests?(te=t.matchedPullRequestNumber?r.jsxs(Me,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Ra,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=te):te=e[76];const he=t.lastActivityAt||t.lastModified;let me;e[77]!==he?(me=Sr(he),e[77]=he,e[78]=me):me=e[78];let le;e[79]!==me?(le=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:me}),e[79]=me,e[80]=le):le=e[80];let xe;e[81]!==y||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(xe=y&&p&&!_&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:pe=>p(o.pid,pe),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(jt,{"data-icon":"inline-start"})}),e[81]=y,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=xe):xe=e[86];let ge;e[87]!==re||e[88]!==ie||e[89]!==ae||e[90]!==te||e[91]!==le||e[92]!==xe||e[93]!==z?(ge=r.jsxs("div",{className:z,children:[re,ie,ae,te,le,xe]}),e[87]=re,e[88]=ie,e[89]=ae,e[90]=te,e[91]=le,e[92]=xe,e[93]=z,e[94]=ge):ge=e[94];const ce=ge;if(h||g||x){let pe;e[95]!==t.firstUserMessage||e[96]!==t.sessionId||e[97]!==t.slug?(pe=t.slug||((we=t.firstUserMessage)==null?void 0:we.slice(0,30))||t.sessionId.slice(0,12),e[95]=t.firstUserMessage,e[96]=t.sessionId,e[97]=t.slug,e[98]=pe):pe=e[98];let ue;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(ue=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=ue):ue=e[102];let je;e[103]!==g||e[104]!==t?(je=g?()=>g(t):void 0,e[103]=g,e[104]=t,e[105]=je):je=e[105];let Ne;e[106]!==x||e[107]!==t.sessionId?(Ne=x?Te=>x(t.sessionId,Te):void 0,e[106]=x,e[107]=t.sessionId,e[108]=Ne):Ne=e[108];let Re;return e[109]!==l||e[110]!==ce||e[111]!==pe||e[112]!==ue||e[113]!==je||e[114]!==Ne?(Re=r.jsx(P0,{sessionLabel:pe,customName:l,onDuplicate:ue,onDelete:je,onRename:Ne,children:ce}),e[109]=l,e[110]=ce,e[111]=pe,e[112]=ue,e[113]=je,e[114]=Ne,e[115]=Re):Re=e[115],Re}return ce}function bA(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function vA(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function yA(n){const e=B.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:x,onDeleteSession:b,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,onPrefetchSession:N,onResumeSession:C}=n;let S;e[0]!==l||e[1]!==k||e[2]!==d||e[3]!==f||e[4]!==b||e[5]!==x||e[6]!==g||e[7]!==j||e[8]!==N||e[9]!==y||e[10]!==w||e[11]!==C||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==u?(S={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:f,sessionNames:u,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,onPrefetchSession:N,onResumeSession:C},e[0]=l,e[1]=k,e[2]=d,e[3]=f,e[4]=b,e[5]=x,e[6]=g,e[7]=j,e[8]=N,e[9]=y,e[10]=w,e[11]=C,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=u,e[17]=S):S=e[17];const _=S;let P;e[18]!==a?(P=a.trim(),e[18]=a,e[19]=P):P=e[19];const A=!!P;let T;e[20]!==i||e[21]!==A||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==_?(T=[...t.entries()].map((I,R)=>{const[$,D]=I,O=vA(D,c);return v.createElement(gp,{..._,key:$,projectPath:$,sessions:D,liveCount:O,collapsed:i[$]??(R>=3&&O===0),forceExpand:A,pendingSession:s===$?o:void 0})}),e[20]=i,e[21]=A,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=_,e[27]=T):T=e[27];let E;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==_?(E=s&&!t.has(s)&&o&&v.createElement(gp,{..._,key:`pending-${s}`,projectPath:s,sessions:[],liveCount:0,collapsed:!1,pendingSession:o}),e[28]=t,e[29]=s,e[30]=o,e[31]=_,e[32]=E):E=e[32];let M;return e[33]!==T||e[34]!==E?(M=r.jsxs(r.Fragment,{children:[T,E]}),e[33]=T,e[34]=E,e[35]=M):M=e[35],M}function gp(n){var He,Ie;const e=B.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:x,onDeleteSession:b,onRenameSession:w,onRenameProject:y,onNewSession:j,creatingSession:k,pendingSession:N,onPrefetchSession:C,onResumeSession:S}=n,_=p===void 0?!1:p,P=v.useId(),A=!!N,T=_||A?!1:u;let E;e[0]!==s?(E=new Set(s.map(jA)),e[0]=s,e[1]=E):E=e[1];const M=E;let I;if(e[2]!==M||e[3]!==s){const Ce=new Map,de=[];for(const Ee of s){const Ae=Ee.teamLeadSessionId;if(Ae&&Ae!==Ee.sessionId&&M.has(Ae)){const Le=Ce.get(Ae);Le?Le.push(Ee):Ce.set(Ae,[Ee])}else de.push(Ee)}I={topLevelSessions:de,teammatesByLead:Ce},e[2]=M,e[3]=s,e[4]=I}else I=e[4];const{topLevelSessions:R,teammatesByLead:$}=I;let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[5]=D):D=e[5];const[O,L]=v.useState(D);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=Ce=>{L(de=>{const Ee=new Set(de);return Ee.has(Ce)?Ee.delete(Ce):Ee.add(Ce),Ee})},e[6]=F):F=e[6];const z=F,[H,U]=v.useState(!1),W=s.length+(A?1:0);let K,q;e[7]!==_||e[8]!==A||e[9]!==i||e[10]!==H||e[11]!==R?(K=zC(R,i,Math.max(1,5-(A?1:0))),q=_||H?R:R.slice(0,K),e[7]=_,e[8]=A,e[9]=i,e[10]=H,e[11]=R,e[12]=K,e[13]=q):(K=e[12],q=e[13]);const Y=q,V=R.length-Y.length,Q=H&&!_&&R.length>K,Z=((He=s.find(wA))==null?void 0:He.dirName)??((Ie=s[0])==null?void 0:Ie.dirName)??(N==null?void 0:N.dirName),X=Z?d[Z]:void 0;let ee;e[14]!==o||e[15]!==a||e[16]!==l||e[17]!==b||e[18]!==x||e[19]!==g||e[20]!==C||e[21]!==w||e[22]!==S||e[23]!==h||e[24]!==i||e[25]!==c?(ee=function(de,Ee,Ae){return r.jsx(xA,{session:de,isActiveSession:o===`${de.dirName}/${de.fileName}`,proc:i.get(de.sessionId),killingPids:a,isNewlyCompleted:l.has(de.sessionId),customName:c[de.sessionId],worktreeName:Ee,teammateCount:Ae==null?void 0:Ae.count,teammatesCollapsed:Ae==null?void 0:Ae.collapsed,onToggleTeammates:Ae==null?void 0:Ae.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onPrefetchSession:C,onResumeSession:S},`${de.dirName}/${de.fileName}`)},e[14]=o,e[15]=a,e[16]=l,e[17]=b,e[18]=x,e[19]=g,e[20]=C,e[21]=w,e[22]=S,e[23]=h,e[24]=i,e[25]=c,e[26]=ee):ee=e[26];const oe=ee,se=!T;let re;e[27]!==Z||e[28]!==y?(re=Ce=>{Z&&y&&y(Z,Ce)},e[27]=Z,e[28]=y,e[29]=re):re=e[29];let ie;e[30]!==u||e[31]!==m||e[32]!==t?(ie=()=>m(t,!u),e[30]=u,e[31]=m,e[32]=t,e[33]=ie):ie=e[33];const ae=!T,te=_?"Groups stay expanded while searching":void 0,he=!T&&"rotate-90";let me;e[34]!==he?(me=G("size-3 shrink-0 text-muted-foreground transition-transform duration-150",he),e[34]=he,e[35]=me):me=e[35];let le;e[36]!==me?(le=r.jsx(Ze,{className:me}),e[36]=me,e[37]=le):le=e[37];const xe=X||t;let ge;e[38]!==xe?(ge=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:xe}),e[38]=xe,e[39]=ge):ge=e[39];let ce;e[40]!==X||e[41]!==t?(ce=X&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=X,e[41]=t,e[42]=ce):ce=e[42];let we;e[43]!==f?(we=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(ca,{className:"size-1.5","aria-hidden":"true"}),f]}),e[43]=f,e[44]=we):we=e[44];let pe;e[45]!==W?(pe=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:W}),e[45]=W,e[46]=pe):pe=e[46];let ue;e[47]!==_||e[48]!==P||e[49]!==ie||e[50]!==ae||e[51]!==te||e[52]!==le||e[53]!==ge||e[54]!==ce||e[55]!==we||e[56]!==pe?(ue=r.jsxs("button",{type:"button",onClick:ie,disabled:_,"aria-expanded":ae,"aria-controls":P,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:[le,ge,ce,we,pe]}),e[47]=_,e[48]=P,e[49]=ie,e[50]=ae,e[51]=te,e[52]=le,e[53]=ge,e[54]=ce,e[55]=we,e[56]=pe,e[57]=ue):ue=e[57];let je;e[58]!==k||e[59]!==j||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(je=j&&s.length>0&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:k,onClick:Ce=>{Ce.stopPropagation();const de=s[0];j(de.dirName,de.cwd??void 0)},"aria-label":`New session in ${t}`,children:k?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(Tn,{"data-icon":"inline-start"})}),e[58]=k,e[59]=j,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=je):je=e[63];let Ne;e[64]!==ue||e[65]!==je?(Ne=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[ue,je]}),e[64]=ue,e[65]=je,e[66]=Ne):Ne=e[66];let Re;e[67]!==X||e[68]!==t||e[69]!==Ne||e[70]!==re?(Re=r.jsx(B0,{projectLabel:t,customName:X,className:"sticky top-0 z-20 bg-background",onRename:re,children:Ne}),e[67]=X,e[68]=t,e[69]=Ne,e[70]=re,e[71]=Re):Re=e[71];let Te;e[72]!==N?(Te=N&&r.jsx(SA,{firstMessage:N.firstMessage}),e[72]=N,e[73]=Te):Te=e[73];let Pe;if(e[74]!==O||e[75]!==oe||e[76]!==$||e[77]!==Y){let Ce;e[79]!==O||e[80]!==oe||e[81]!==$?(Ce=de=>{const Ee=de.cwd??gn(de.dirName),Ae=la(Ee),Le=$.get(de.sessionId);if(!Le)return oe(de,Ae==null?void 0:Ae.worktreeName);const ne=O.has(de.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[oe(de,Ae==null?void 0:Ae.worktreeName,{count:Le.length,collapsed:ne,onToggle:()=>z(de.sessionId)}),!ne&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Le.map(fe=>oe(fe))})]},`${de.dirName}/${de.fileName}`)},e[79]=O,e[80]=oe,e[81]=$,e[82]=Ce):Ce=e[82],Pe=Y.map(Ce),e[74]=O,e[75]=oe,e[76]=$,e[77]=Y,e[78]=Pe}else Pe=e[78];let Oe;e[83]!==V?(Oe=V>0&&r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!0),className:"justify-start",children:[r.jsx(st,{"data-icon":"inline-start"}),"Show ",V," more"]}),e[83]=V,e[84]=Oe):Oe=e[84];let Fe;e[85]!==Q?(Fe=Q&&r.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!1),className:"justify-start",children:[r.jsx(hr,{"data-icon":"inline-start"}),"Show less"]}),e[85]=Q,e[86]=Fe):Fe=e[86];let ze;e[87]!==Te||e[88]!==Pe||e[89]!==Oe||e[90]!==Fe?(ze=r.jsxs("div",{className:"flex flex-col gap-px",children:[Te,Pe,Oe,Fe]}),e[87]=Te,e[88]=Pe,e[89]=Oe,e[90]=Fe,e[91]=ze):ze=e[91];let Be;e[92]!==P||e[93]!==ze?(Be=r.jsx(Nt,{id:P,className:"ml-3 border-l pl-1",children:ze}),e[92]=P,e[93]=ze,e[94]=Be):Be=e[94];let _e;return e[95]!==Re||e[96]!==Be||e[97]!==se?(_e=r.jsxs(kt,{open:se,className:"flex flex-col",children:[Re,Be]}),e[95]=Re,e[96]=Be,e[97]=se,e[98]=_e):_e=e[98],_e}function wA(n){return!la(n.cwd??gn(n.dirName))}function jA(n){return n.sessionId}function SA(n){const e=B.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(rt,{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 kA=v.memo(function(e){const t=B.c(122),{activeSessionKey:s,onSelectSession:o,onDuplicateSession:i,onDeleteSession:a,onNewSession:l,creatingSession:c,pendingSession:d,refreshRef:f,onPrefetchSession:u}=e,{names:m,rename:p}=M0(),{names:h,rename:g}=H0(),x=zc(),b=yn("terminal"),w=yn("killAny"),{sessions:y,procBySession:j,newlyCompleted:k,loading:N,error:C,refresh:S,removeSession:_,acknowledgeCompleted:P}=Sx(),{awaitingPermission:A,awaitingQuestion:T,awaitingElicitation:E,awaitingDialog:M,awaitingPlan:I}=XP();let R;t[0]!==M||t[1]!==E?(R=new Set([...E,...M]),t[0]=M,t[1]=E,t[2]=R):R=t[2];const $=R;let D;t[3]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,t[3]=D):D=t[3];const[O,L]=v.useState(D),[F,z]=v.useState("");let H,U;t[4]===Symbol.for("react.memo_cache_sentinel")?(H=Lt("live-sessions-collapsed-projects"),U={},t[4]=H,t[5]=U):(H=t[4],U=t[5]);const[W,K]=ja(H,U);let q;t[6]!==K?(q=(Ge,et)=>{K(mt=>({...mt,[Ge]:et}))},t[6]=K,t[7]=q):q=t[7];const Y=q,V=v.useRef(y);let Q;t[8]===Symbol.for("react.memo_cache_sentinel")?(Q=new Set,t[8]=Q):Q=t[8];const Z=v.useRef(Q),X=v.useRef(!1);let ee;t[9]===Symbol.for("react.memo_cache_sentinel")?(ee=(Ge,et)=>{if(!X.current)return;const mt=setTimeout(()=>{Z.current.delete(mt),X.current&&Ge()},et);Z.current.add(mt)},t[9]=ee):ee=t[9];const oe=ee;let se,re;t[10]===Symbol.for("react.memo_cache_sentinel")?(se=()=>{const Ge=Z.current;return X.current=!0,()=>{X.current=!1;for(const et of Ge)clearTimeout(et);Ge.clear()}},re=[],t[10]=se,t[11]=re):(se=t[10],re=t[11]),v.useEffect(se,re);let ie,ae;t[12]!==y?(ie=()=>{V.current=y},ae=[y],t[12]=y,t[13]=ie,t[14]=ae):(ie=t[13],ae=t[14]),v.useEffect(ie,ae);let te,he;t[15]!==S||t[16]!==f?(te=()=>{if(f)return f.current=S,()=>{f.current===S&&(f.current=null)}},he=[S,f],t[15]=S,t[16]=f,t[17]=te,t[18]=he):(te=t[17],he=t[18]),v.useEffect(te,he);const me=Ca(),le=K0(F);let xe;e:{if(!F.trim()){xe=y;break e}let Ge;if(t[19]!==h||t[20]!==F||t[21]!==m||t[22]!==y){let et;t[24]!==h||t[25]!==F||t[26]!==m?(et=mt=>{const zt=m[mt.sessionId],en=h[mt.dirName];return L0(mt,F,[zt,en])},t[24]=h,t[25]=F,t[26]=m,t[27]=et):et=t[27],Ge=y.filter(et),t[19]=h,t[20]=F,t[21]=m,t[22]=y,t[23]=Ge}else Ge=t[23];xe=Ge}const ge=xe,ce=le.results??ge;let we;t[28]!==ce?(we=LC(ce),t[28]=ce,t[29]=we):we=t[29];const pe=we;let ue;t[30]!==A||t[31]!==I||t[32]!==$||t[33]!==T||t[34]!==k||t[35]!==j||t[36]!==y?(ue=ZP(y,j,k,A,T,$,I),t[30]=A,t[31]=I,t[32]=$,t[33]=T,t[34]=k,t[35]=j,t[36]=y,t[37]=ue):ue=t[37];const je=ue,Ne=je.needsYou.length>0||je.working.length>0;let Re;t[38]!==Ne||t[39]!==F?(Re=!F.trim()&&Ne,t[38]=Ne,t[39]=F,t[40]=Re):Re=t[40];const Te=Re;let Pe;e:{if(!d){Pe=null;break e}let Ge;t[41]!==d.cwd||t[42]!==d.dirName?(Ge=d.cwd||gn(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=Ge):Ge=t[43];let et;t[44]!==Ge?(et=xd(Ge),t[44]=Ge,t[45]=et):et=t[45],Pe=et}const Oe=Pe,Fe=v.useRef(!1);let ze,Be;t[46]!==u||t[47]!==y?(ze=()=>{if(Fe.current||!u||y.length===0)return;Fe.current=!0;const Ge=gd(y).slice(0,3),et=globalThis,mt=()=>{for(const Us of Ge)u(Us.dirName,Us.fileName)};let zt=null,en=null;return typeof et.requestIdleCallback=="function"?zt=et.requestIdleCallback(mt,{timeout:1500}):en=setTimeout(mt,300),()=>{zt!=null&&typeof et.cancelIdleCallback=="function"&&et.cancelIdleCallback(zt),en!=null&&clearTimeout(en)}},Be=[y,u],t[46]=u,t[47]=y,t[48]=ze,t[49]=Be):(ze=t[48],Be=t[49]),v.useEffect(ze,Be);let _e;t[50]!==S?(_e=async(Ge,et)=>{et.stopPropagation(),L(mt=>new Set(mt).add(Ge));try{await ye("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:Ge})}),oe(S,1500)}catch{}oe(()=>{L(mt=>{const zt=new Set(mt);return zt.delete(Ge),zt})},2e3)},t[50]=S,t[51]=_e):_e=t[51];const He=_e;let Ie;t[52]!==P||t[53]!==o?(Ie=(Ge,et)=>{const mt=V.current.find(zt=>zt.dirName===Ge&&zt.fileName===et);mt&&P(mt.sessionId),o(Ge,et)},t[52]=P,t[53]=o,t[54]=Ie):Ie=t[54];const Ce=Ie;let de;t[55]!==a||t[56]!==_?(de=Ge=>{a==null||a(Ge.dirName,Ge.fileName),_(Ge.sessionId)},t[55]=a,t[56]=_,t[57]=de):de=t[57];const Ee=de;let Ae;t[58]!==S||t[59]!==x?(Ae=(Ge,et,mt)=>{const{command:zt,args:en}=jy(St(mt),Ge),Us=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Us,name:`Resume ${Ge.slice(0,8)}`,command:zt,args:en,cwd:et??void 0,metadata:{type:"terminal"}}),oe(S,3e3)},t[58]=S,t[59]=x,t[60]=Ae):Ae=t[60];const Le=Ae;let ne;t[61]!==S?(ne=()=>{JP(),S()},t[61]=S,t[62]=ne):ne=t[62];let fe;t[63]!==me||t[64]!==N||t[65]!==le.loading||t[66]!==F||t[67]!==ne?(fe=r.jsx(mA,{loading:N,isMobile:me,searchQuery:F,searchLoading:le.loading,onSearchQueryChange:z,onRefresh:ne}),t[63]=me,t[64]=N,t[65]=le.loading,t[66]=F,t[67]=ne,t[68]=fe):fe=t[68];const Se=le.error??C,$e=ce.length===0&&!d&&!N&&!le.loading&&!C&&!le.error;let Ue;t[69]!==F?(Ue=F.trim(),t[69]=F,t[70]=Ue):Ue=t[70];const We=!!Ue,Xe=N||le.loading,Je=le.active?ce.length:y.length,De=le.error?le.refresh:S;let qe;t[71]!==Se||t[72]!==$e||t[73]!==We||t[74]!==Xe||t[75]!==Je||t[76]!==De?(qe=r.jsx(hA,{fetchError:Se,showEmpty:$e,searching:We,loading:Xe,sessionCount:Je,onRetry:De}),t[71]=Se,t[72]=$e,t[73]=We,t[74]=Xe,t[75]=Je,t[76]=De,t[77]=qe):qe=t[77];let ot;t[78]!==s||t[79]!==je||t[80]!==w||t[81]!==b||t[82]!==He||t[83]!==Le||t[84]!==Ce||t[85]!==O||t[86]!==u||t[87]!==j||t[88]!==h||t[89]!==m||t[90]!==Te?(ot=Te&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(fA,{groups:je,activeSessionKey:s,procBySession:j,killingPids:O,sessionNames:m,projectNames:h,onSelectSession:Ce,onKill:w?He:void 0,onResumeSession:b?Le: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(It,{className:"flex-1"})]})]}),t[78]=s,t[79]=je,t[80]=w,t[81]=b,t[82]=He,t[83]=Le,t[84]=Ce,t[85]=O,t[86]=u,t[87]=j,t[88]=h,t[89]=m,t[90]=Te,t[91]=ot):ot=t[91];const lt=w?He:void 0,bt=a?Ee:void 0,$t=b?Le:void 0;let Vt;t[92]!==s||t[93]!==W||t[94]!==c||t[95]!==pe||t[96]!==Ce||t[97]!==O||t[98]!==k||t[99]!==i||t[100]!==l||t[101]!==u||t[102]!==Oe||t[103]!==d||t[104]!==j||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==F||t[109]!==m||t[110]!==lt||t[111]!==bt||t[112]!==$t||t[113]!==Y?(Vt=r.jsx(yA,{grouped:pe,pendingProjectPath:Oe,pendingSession:d,collapsedGroups:W,searchQuery:F,activeSessionKey:s,procBySession:j,killingPids:O,newlyCompleted:k,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Ce,onKill:lt,onDuplicateSession:i,onDeleteSession:bt,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:u,onResumeSession:$t}),t[92]=s,t[93]=W,t[94]=c,t[95]=pe,t[96]=Ce,t[97]=O,t[98]=k,t[99]=i,t[100]=l,t[101]=u,t[102]=Oe,t[103]=d,t[104]=j,t[105]=h,t[106]=g,t[107]=p,t[108]=F,t[109]=m,t[110]=lt,t[111]=bt,t[112]=$t,t[113]=Y,t[114]=Vt):Vt=t[114];let Wt;t[115]!==qe||t[116]!==ot||t[117]!==Vt?(Wt=r.jsx(Cr,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[qe,ot,Vt]})}),t[115]=qe,t[116]=ot,t[117]=Vt,t[118]=Wt):Wt=t[118];let ts;return t[119]!==fe||t[120]!==Wt?(ts=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[fe,Wt]}),t[119]=fe,t[120]=Wt,t[121]=ts):ts=t[121],ts}),NA=v.memo(function(e){const t=B.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 x;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?(x=r.jsx(kA,{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]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),CA=v.lazy(()=>Ke(()=>import("./index-BaKcHvT2.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.MissionControl})));function Z0(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Bt,{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 e2(n){const e=B.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=it(),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(NA,{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 t2(n){const e=B.c(8),{navigation:t}=n,{state:s}=Rt();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(HP,{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 _A(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Z0,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(v.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(CA,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function TA({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function EA({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function PA({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}
|
|
121
121
|
`:""}${n} (${a})
|
|
122
122
|
${i}
|
|
123
123
|
${e}
|
|
124
|
-
${i}`}const AA=v.lazy(()=>Ke(()=>import("./ConfigBrowser-
|
|
124
|
+
${i}`}const AA=v.lazy(()=>Ke(()=>import("./ConfigBrowser-DmOlS3cU.js"),__vite__mapDeps([32,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser}))),RA=v.lazy(()=>Ke(()=>import("./PreviewPanel-B9CQNmuh.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),MA=v.lazy(()=>Ke(()=>import("./ProjectFilesPanel-C3jKD37-.js"),__vite__mapDeps([35,1,33,2,3,4])).then(n=>({default:n.ProjectFilesPanel})));function IA(n){const e=B.c(33),{navigation:t,sessionView:s,project:o,floatingChrome:i}=n,{state:a}=Rt(),{session:l}=it();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(Pa,{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(tx,{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(Ma,{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(dp,{defaultSize:c,minSize:"500px",children:h}),e[20]=c,e[21]=h,e[22]=g):g=e[22];let x;e[23]!==t||e[24]!==o.hasFileChanges||e[25]!==l||e[26]!==s.fileChangesCollapsed||e[27]!==s.onFileChangesPanelResize||e[28]!==a?(x=o.hasFileChanges&&t.panels.showFileChanges&&r.jsxs(r.Fragment,{children:[r.jsx(dP,{withHandle:!0}),r.jsx(dp,{defaultSize:30,minSize:0,collapsible:!0,onResize:s.onFileChangesPanelResize,children:!s.fileChangesCollapsed&&r.jsx(Y6,{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]=x):x=e[29];let b;return e[30]!==g||e[31]!==x?(b=r.jsx("div",{className:"flex min-h-0 flex-1 bg-background",children:r.jsxs(cP,{orientation:"horizontal",className:"min-h-0 flex-1",children:[g,x]})}),e[30]=g,e[31]=x,e[32]=b):b=e[32],b}function $A(n){const e=B.c(38),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Rt(),{session:c,sessionSource:d}=it();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?gn(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Z0,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(AA,{projectPath:EA({sessionCwd:c==null?void 0:c.cwd,pendingPath:f,sessionDirPath:d!=null&&d.dirName?gn(d.dirName):null,dashboardProjectPath:l.dashboardProject?gn(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(v.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(_A,{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(IA,{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=$s()?"Only on the machine running this session":void 0;let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=Xc()?void 0:h,e[19]=g):g=e[19];const x=g,b=!p&&"justify-center gap-4";let w;e[20]!==b?(w=G("flex min-h-0 min-w-0 flex-1 flex-col bg-background",b),e[20]=b,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(E0,{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(Ma,{children:s.pendingComposer}),e[26]=s.pendingComposer,e[27]=j):j=e[27];let k;e[28]!==p||e[29]!==o?(k=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[ut("terminal")&&r.jsx(wl,{reason:h,children:r.jsxs(J,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(wo,{"data-icon":"inline-start"}),"Terminal"]})}),ut("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(wl,{reason:x,children:r.jsxs(J,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>Rg(o.pendingProject),children:[r.jsx(pr,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(wl,{reason:h,children:r.jsxs(J,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>Mg(o.pendingProject),children:[r.jsx(lh,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[28]=p,e[29]=o,e[30]=k):k=e[30];let N;return e[31]!==w||e[32]!==y||e[33]!==j||e[34]!==k?(N=r.jsxs("div",{className:w,children:[y,j,k]}),e[31]=w,e[32]=y,e[33]=j,e[34]=k,e[35]=N):N=e[35],N}let m;return e[36]!==t?(m=r.jsx(t2,{navigation:t}),e[36]=t,e[37]=m):m=e[37],m}function OA(n){const e=B.c(78),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Rt(),{session:c}=it();let d;e[0]!==s.chatInputRef.current?(d=function(Y){var re,ie,ae;const{path:V,text:Q,startLine:Z,endLine:X,comment:ee}=Y,oe=PA({path:V,text:Q,startLine:Z,endLine:X,comment:ee}),se=((re=s.chatInputRef.current)==null?void 0:re.getText().trimEnd())??"";(ie=s.chatInputRef.current)==null||ie.setText(se?`${se}
|
|
125
125
|
|
|
126
126
|
${oe}
|
|
127
127
|
`:`${oe}
|
|
128
|
-
`),(ae=s.chatInputRef.current)==null||ae.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=TA({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,x=t.actions.handleGoHome,b=i.onOpenCommandPalette;let w,y;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=vl("toggleSidebar"),y=vl("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(N9,{onToggleSidebar:g,onGoHome:x,onOpenCommandPalette:b,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 k=j,N=t.panels.showSidebar&&a.mainView!=="config",C=t.panels.showSidebar;let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=vl("toggleSidebar"),e[12]=S):S=e[12];const _=o.supportsWorktrees&&t.panels.showWorktrees,P=o.supportsWorktrees?t.panels.handleToggleWorktrees:void 0,A=a.mainView==="config",T=ut("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]!==N||e[32]!==_||e[33]!==P||e[34]!==A||e[35]!==T||e[36]!==E?(M=r.jsx(x9,{showSidebar:C,sidebarRendered:N,sidebarShortcut:S,showStats:t.panels.showStats,showWorktrees:_,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:P,onToggleFileChanges:t.panels.handleToggleFileChanges,showConfig:A,onToggleConfig:T,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]=N,e[32]=_,e[33]=P,e[34]=A,e[35]=T,e[36]=E,e[37]=M):M=e[37];const I=M;let R;e[38]!==t||e[39]!==k||e[40]!==N?(R=N&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(e2,{navigation:t,header:k})}),e[38]=t,e[39]=k,e[40]=N,e[41]=R):R=e[41];const $=h!=="session"&&I;let D;e[42]!==I||e[43]!==t||e[44]!==o||e[45]!==s||e[46]!==h?(D=r.jsx($A,{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]=D):D=e[47];let O;e[48]!==$||e[49]!==D?(O=r.jsxs("main",{className:"app-view-transition relative flex min-w-0 flex-1 flex-col overflow-hidden",children:[$,D]}),e[48]=$,e[49]=D,e[50]=O):O=e[50];const L=!o.showPreview&&!o.showProjectFiles&&t.panels.showStats&&!!c&&a.mainView!=="config",F=!o.showPreview&&!o.showProjectFiles&&!!c&&a.mainView!=="config";let z;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?(z=r.jsx(T0,{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]=z):z=e[57];let H;e[58]!==L||e[59]!==F||e[60]!==z?(H=r.jsx(S9,{side:"right",visible:L,enabled:F,children:z}),e[58]=L,e[59]=F,e[60]=z,e[61]=H):H=e[61];let U;e[62]!==o.currentCwd||e[63]!==o.onCloseRightWorkspace||e[64]!==o.showPreview?(U=o.showPreview&&o.currentCwd&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(RA,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[62]=o.currentCwd,e[63]=o.onCloseRightWorkspace,e[64]=o.showPreview,e[65]=U):U=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(v.Suspense,{fallback:null,children:r.jsx(MA,{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 K;return e[72]!==R||e[73]!==O||e[74]!==H||e[75]!==U||e[76]!==W?(K=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[R,O,H,U,W]}),e[72]=R,e[73]=O,e[74]=H,e[75]=U,e[76]=W,e[77]=K):K=e[77],K}function DA(n){const e=B.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Rt(),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(ox,{}),d=r.jsx(sx,{}),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(OA,{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(kE,{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 LA=[{id:"sessions",label:"Sessions",icon:Qo},{id:"chat",label:"Chat",icon:Qi},{id:"stats",label:"Stats",icon:uh,requiresSession:!0}],zA=v.memo(function(e){const t=B.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=it(),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=LA.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 x=g.icon,b=s===g.id;return r.jsx("button",{type:"button","aria-current":b?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{mc(),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",b?"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",b?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",b&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(ca,{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 FA(n){const e=B.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:x}=n;let b;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(b=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=b):b=e[3];const w=b;let y;e[4]!==o||e[5]!==d?(y=o&&d&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(Cc,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=y):y=e[6];let j,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Md,{compact:!0}),k=r.jsx(It,{orientation:"vertical",className:"h-4"}),e[7]=j,e[8]=k):(j=e[7],k=e[8]);let N;e[9]!==i?(N=r.jsx(ig,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=N):N=e[10];let C;e[11]!==t.cwd?(C=t.cwd?zn(t.cwd):"Session",e[11]=t.cwd,e[12]=C):C=e[12];let S;e[13]!==C?(S=r.jsx("span",{className:"min-w-0 flex-1 truncate text-center text-xs font-medium text-muted-foreground",children:C}),e[13]=C,e[14]=S):S=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Mn,{render:r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(dh,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let P;e[16]!==t.cwd?(P=t.cwd?zn(t.cwd):"Current session",e[16]=t.cwd,e[17]=P):P=e[17];let A;e[18]!==P?(A=r.jsx("span",{className:"truncate text-foreground",children:P}),e[18]=P,e[19]=A):A=e[19];let T;e[20]!==t.gitBranch||e[21]!==t.model?(T=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=T):T=e[22];let E;e[23]!==T?(E=r.jsx("span",{className:"truncate font-normal",children:T}),e[23]=T,e[24]=E):E=e[24];let M;e[25]!==A||e[26]!==E?(M=r.jsxs(gs,{className:"flex flex-col gap-0.5",children:[A,E]}),e[25]=A,e[26]=E,e[27]=M):M=e[27];let I;e[28]!==a||e[29]!==w||e[30]!==s?(I=s&&r.jsxs(ct,{onClick:w,disabled:a,children:[a?r.jsx(Bt,{}):r.jsx(Tn,{}),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(ct,{onClick:c,children:[r.jsx(Pn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let $;e[34]!==M||e[35]!==I||e[36]!==R?($=r.jsxs(Ft,{children:[M,I,R]}),e[34]=M,e[35]=I,e[36]=R,e[37]=$):$=e[37];let D;e[38]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(ao,{}),e[38]=D):D=e[38];let O;e[39]!==h?(O=h&&r.jsxs(ct,{onClick:h,children:[r.jsx(bn,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=O):O=e[40];let L;e[41]!==g||e[42]!==x?(L=x&&r.jsxs(ct,{onClick:x,children:[g?r.jsx(Ji,{}):r.jsx(Yi,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=L):L=e[43];let F;e[44]!==u||e[45]!==f?(F=u&&f&&r.jsxs(ct,{onClick:f,children:[r.jsx(xr,{}),r.jsx("span",{children:"File changes"})]}),e[44]=u,e[45]=f,e[46]=F):F=e[46];let z;e[47]!==m||e[48]!==p?(z=m&&(p??0)>0&&r.jsxs(ct,{onClick:m,children:[r.jsx(ch,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Me,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=z):z=e[49];let H;e[50]!==O||e[51]!==L||e[52]!==F||e[53]!==z?(H=r.jsxs(Ft,{children:[O,L,F,z]}),e[50]=O,e[51]=L,e[52]=F,e[53]=z,e[54]=H):H=e[54];let U;e[55]!==$||e[56]!==H?(U=r.jsxs(Rn,{children:[_,r.jsxs(In,{align:"end",sideOffset:6,className:"w-72",children:[$,D,H]})]}),e[55]=$,e[56]=H,e[57]=U):U=e[57];let W;return e[58]!==y||e[59]!==U||e[60]!==N||e[61]!==S?(W=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[y,j,k,N,S,U]}),e[58]=y,e[59]=U,e[60]=N,e[61]=S,e[62]=W):W=e[62],W}const BA=v.memo(function(e){const t=B.c(11),{isMobile:s}=Rt(),{session:o,sessionSource:i}=it();if(!s||!o)return null;let a;t[0]!==i?(a=i?vs(i.fileName):null,t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]!==o||t[3]!==(i==null?void 0:i.dirName)?(c=fo(i==null?void 0:i.dirName).contextWindow?o.rawMessages:[],t[2]=o,t[3]=i==null?void 0:i.dirName,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(FA,{...e,onDuplicateSession:e.onDuplicateSession,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 UA({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=v.useRef(null),i=v.useRef(null),a=v.useRef(n),l=v.useRef(e);return a.current=n,l.current=e,v.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,x;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):(x=a.current)==null||x.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 WA=["sessions","chat","stats"];function HA({hasSession:n,hasPendingSession:e}){return WA.filter(t=>!(t==="stats"&&!n&&!e))}function xp(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const KA=v.lazy(()=>Ke(()=>import("./MobileFileChanges-CiZ45577.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function qA(n){const e=B.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Rt(),{session:c,isSubAgentView:d}=it(),f=!!c,u=!!a.pendingDirName;let m;e[0]!==f||e[1]!==u?(m=HA({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 F=xp(p,a.mobileTab,1);F&&(mc(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{const F=xp(p,a.mobileTab,-1);F&&(mc(),t.actions.handleMobileTabChange(F))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=UA(h);let x;e[7]!==i||e[8]!==t.actions?(x=F=>{i.onSearchOpenChange(!1),t.actions.handleMobileTabChange(F)},e[7]=i,e[8]=t.actions,e[9]=x):x=e[9];const b=x,w=`${l.themeClasses} flex h-dvh flex-col bg-background text-foreground`,y=i.backgroundServers;let j,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ox,{}),k=r.jsx(sx,{}),e[10]=j,e[11]=k):(j=e[10],k=e[11]);let N;e[12]!==c||e[13]!==a.mobileTab?(N=!(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(Md,{compact:!0})}),e[12]=c,e[13]=a.mobileTab,e[14]=N):N=e[14];const C=a.mobileTab,S=!(a.mobileTab==="chat"&&c)&&"motion-session-enter";let _;e[15]!==S?(_=G("flex min-h-0 min-w-0 flex-1",S),e[15]=S,e[16]=_):_=e[16];let P;e[17]!==t||e[18]!==a.mobileTab?(P=a.mobileTab==="sessions"&&r.jsx(e2,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=P):P=e[19];let A;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?(A=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(BA,{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(Pa,{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(E0,{projectPath:s.pendingPath??null}),ut("terminal")&&r.jsxs(J,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(wo,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(t2,{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]=A):A=e[29];let T;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(T=a.mobileTab==="stats"&&c&&r.jsx(T0,{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]=T):T=e[34];let E;e[35]!==a.mobileTab||e[36]!==_||e[37]!==P||e[38]!==A||e[39]!==T?(E=r.jsxs("div",{className:_,children:[P,A,T]},C),e[35]=a.mobileTab,e[36]=_,e[37]=P,e[38]=A,e[39]=T,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 $;e[49]!==I||e[50]!==R?($=r.jsxs("div",{className:"shrink-0",children:[I,R]}),e[49]=I,e[50]=R,e[51]=$):$=e[51];let D;e[52]!==b||e[53]!==a.mobileTab?(D=r.jsx(zA,{activeTab:a.mobileTab,onTabChange:b}),e[52]=b,e[53]=a.mobileTab,e[54]=D):D=e[54];let O;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?(O=c&&o.hasFileChanges&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(KA,{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]=O):O=e[59];let L;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==N||e[65]!==M||e[66]!==$||e[67]!==D||e[68]!==O||e[69]!==w?(L=r.jsxs("div",{className:w,children:[y,j,k,N,M,$,i.workflowsPanel,D,i.undoDialog,i.branchModal,O]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=N,e[65]=M,e[66]=$,e[67]=D,e[68]=O,e[69]=w,e[70]=L):L=e[70],L}function VA(n){const e=B.c(13),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{theme:d,isMobile:f}=Rt(),{session:u}=it(),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(Pa,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),f?i:r.jsx(Ma,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(Hn,{className:"max-w-md",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:s?r.jsx(vn,{}):r.jsx(rt,{className:"animate-spin"})}),r.jsx(qn,{children:s?"Unable to open session":"Opening session"}),r.jsx(Vn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot 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 GA=5;function di(n,e){const t=mn(),s=ps();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class YA{constructor(){Hr(this,"cache",new Map)}get(e,t){const s=di(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=di(e,t);!this.cache.has(d)&&this.cache.size>=GA&&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=di(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(di(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 hn=new YA,bp={};function n2(n,e,t,s,o,i){const[a,l]=v.useState(!1),[c,d]=v.useState("disconnected"),[f,u]=v.useState(!1),[m,p]=v.useState(null),[h,g]=v.useState(bp),[x,b]=v.useState(null),[w,y]=v.useState(so),j=v.useRef(""),k=v.useRef(null),N=v.useRef(so),C=v.useRef("disconnected"),S=v.useRef(e);S.current=e;const _=v.useRef(o);_.current=o;const P=v.useRef(t);P.current=t;const A=v.useRef(s);A.current=s;const T=v.useRef(i??null);T.current=i??null;const E=v.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)??"",$=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return v.useEffect(()=>{if(j.current=R,!R){k.current=null,l(!1);return}const D=T.current;if(D){k.current=D;return}P.current(R).then(O=>{k.current=O})},[R]),v.useEffect(()=>{if(b(null),!M||!I){l(!1),d("disconnected");return}d("connecting");const D=`/api/watch/${encodeURIComponent(M)}/${encodeURIComponent(I)}?offset=${$}`,O=new EventSource(yr(D));let L=null;const F=(ae=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),u(!1)},ae)};let z="",H=$,U=!1,W=!1,K=!1,q=null;const Y=()=>{K=!1,q=null,k.current&&S.current(k.current)},V=()=>{K||(K=!0,q=requestAnimationFrame(Y))};let Q=!1,Z=null,X=null;const ee=()=>{Q=!1,Z=null,y(N.current)},oe=()=>{Q||(Q=!0,Z=requestAnimationFrame(ee))},se=ae=>{ae!==N.current&&(N.current=ae,oe(),ae.length>0&&!X&&(X=setInterval(()=>{const te=d_(N.current);te!==N.current&&(N.current=te,oe()),N.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},re=()=>{se(so),g(bp)},ie=()=>{if(W||U||!z)return;const ae=z;z="",U=!0;const te=k.current;(te?A.current(te,ae):P.current(j.current)).then(me=>{W||(k.current=me,M&&I&&hn.update(M,I,{parsed:me,source:{rawText:j.current,watchOffset:H}}),V())}).catch(me=>{console.error("[useLiveSession] worker parse failed:",me)}).finally(()=>{U=!1,!W&&z&&ie()})};return O.onopen=()=>{var ae;if(C.current!=="connected"){const te=E.current;E.current=!1,C.current="connected",d("connected"),te&&((ae=_.current)==null||ae.call(_))}},O.onmessage=ae=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const te=JSON.parse(ae.data);if(te.type==="init")te.recentlyActive?(l(!0),F(5e3)):F();else if(te.type==="compacting_in_progress")l(!0),u(!0),re(),F();else if(te.type==="subagent_activity")l(!0),F();else if(te.type==="runtime_activity")l(!0),F();else if(te.type==="stream_snapshot")l(!0),F(),se(a_(te.messages??[]));else if(te.type==="stream_delta")l(!0),F(),p(null),b(null),se(l_(N.current,te.events??[]));else if(te.type==="agent_progress")l(!0),F(),g(he=>({...he,[te.toolUseId]:te.summary}));else if(te.type==="prompt_suggestion")b(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")re();else if(te.type==="lines"&&te.lines.length>0){l(!0),u(!1),F(),se(c_(N.current,te.lines));const he=te.lines.join(`
|
|
128
|
+
`),(ae=s.chatInputRef.current)==null||ae.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=TA({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,x=t.actions.handleGoHome,b=i.onOpenCommandPalette;let w,y;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=vl("toggleSidebar"),y=vl("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(N9,{onToggleSidebar:g,onGoHome:x,onOpenCommandPalette:b,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 k=j,N=t.panels.showSidebar&&a.mainView!=="config",C=t.panels.showSidebar;let S;e[12]===Symbol.for("react.memo_cache_sentinel")?(S=vl("toggleSidebar"),e[12]=S):S=e[12];const _=o.supportsWorktrees&&t.panels.showWorktrees,P=o.supportsWorktrees?t.panels.handleToggleWorktrees:void 0,A=a.mainView==="config",T=ut("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]!==N||e[32]!==_||e[33]!==P||e[34]!==A||e[35]!==T||e[36]!==E?(M=r.jsx(x9,{showSidebar:C,sidebarRendered:N,sidebarShortcut:S,showStats:t.panels.showStats,showWorktrees:_,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:P,onToggleFileChanges:t.panels.handleToggleFileChanges,showConfig:A,onToggleConfig:T,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]=N,e[32]=_,e[33]=P,e[34]=A,e[35]=T,e[36]=E,e[37]=M):M=e[37];const I=M;let R;e[38]!==t||e[39]!==k||e[40]!==N?(R=N&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(e2,{navigation:t,header:k})}),e[38]=t,e[39]=k,e[40]=N,e[41]=R):R=e[41];const $=h!=="session"&&I;let D;e[42]!==I||e[43]!==t||e[44]!==o||e[45]!==s||e[46]!==h?(D=r.jsx($A,{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]=D):D=e[47];let O;e[48]!==$||e[49]!==D?(O=r.jsxs("main",{className:"app-view-transition relative flex min-w-0 flex-1 flex-col overflow-hidden",children:[$,D]}),e[48]=$,e[49]=D,e[50]=O):O=e[50];const L=!o.showPreview&&!o.showProjectFiles&&t.panels.showStats&&!!c&&a.mainView!=="config",F=!o.showPreview&&!o.showProjectFiles&&!!c&&a.mainView!=="config";let z;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?(z=r.jsx(T0,{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]=z):z=e[57];let H;e[58]!==L||e[59]!==F||e[60]!==z?(H=r.jsx(S9,{side:"right",visible:L,enabled:F,children:z}),e[58]=L,e[59]=F,e[60]=z,e[61]=H):H=e[61];let U;e[62]!==o.currentCwd||e[63]!==o.onCloseRightWorkspace||e[64]!==o.showPreview?(U=o.showPreview&&o.currentCwd&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(RA,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[62]=o.currentCwd,e[63]=o.onCloseRightWorkspace,e[64]=o.showPreview,e[65]=U):U=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(v.Suspense,{fallback:null,children:r.jsx(MA,{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 K;return e[72]!==R||e[73]!==O||e[74]!==H||e[75]!==U||e[76]!==W?(K=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[R,O,H,U,W]}),e[72]=R,e[73]=O,e[74]=H,e[75]=U,e[76]=W,e[77]=K):K=e[77],K}function DA(n){const e=B.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Rt(),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(ox,{}),d=r.jsx(sx,{}),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(OA,{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(kE,{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 LA=[{id:"sessions",label:"Sessions",icon:Qo},{id:"chat",label:"Chat",icon:Qi},{id:"stats",label:"Stats",icon:uh,requiresSession:!0}],zA=v.memo(function(e){const t=B.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=it(),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=LA.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 x=g.icon,b=s===g.id;return r.jsx("button",{type:"button","aria-current":b?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{mc(),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",b?"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",b?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",b&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(ca,{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 FA(n){const e=B.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:x}=n;let b;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(b=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=b):b=e[3];const w=b;let y;e[4]!==o||e[5]!==d?(y=o&&d&&r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(Cc,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=y):y=e[6];let j,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Md,{compact:!0}),k=r.jsx(It,{orientation:"vertical",className:"h-4"}),e[7]=j,e[8]=k):(j=e[7],k=e[8]);let N;e[9]!==i?(N=r.jsx(ig,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=N):N=e[10];let C;e[11]!==t.cwd?(C=t.cwd?zn(t.cwd):"Session",e[11]=t.cwd,e[12]=C):C=e[12];let S;e[13]!==C?(S=r.jsx("span",{className:"min-w-0 flex-1 truncate text-center text-xs font-medium text-muted-foreground",children:C}),e[13]=C,e[14]=S):S=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Mn,{render:r.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(dh,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let P;e[16]!==t.cwd?(P=t.cwd?zn(t.cwd):"Current session",e[16]=t.cwd,e[17]=P):P=e[17];let A;e[18]!==P?(A=r.jsx("span",{className:"truncate text-foreground",children:P}),e[18]=P,e[19]=A):A=e[19];let T;e[20]!==t.gitBranch||e[21]!==t.model?(T=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=T):T=e[22];let E;e[23]!==T?(E=r.jsx("span",{className:"truncate font-normal",children:T}),e[23]=T,e[24]=E):E=e[24];let M;e[25]!==A||e[26]!==E?(M=r.jsxs(gs,{className:"flex flex-col gap-0.5",children:[A,E]}),e[25]=A,e[26]=E,e[27]=M):M=e[27];let I;e[28]!==a||e[29]!==w||e[30]!==s?(I=s&&r.jsxs(ct,{onClick:w,disabled:a,children:[a?r.jsx(Bt,{}):r.jsx(Tn,{}),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(ct,{onClick:c,children:[r.jsx(Pn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let $;e[34]!==M||e[35]!==I||e[36]!==R?($=r.jsxs(Ft,{children:[M,I,R]}),e[34]=M,e[35]=I,e[36]=R,e[37]=$):$=e[37];let D;e[38]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(ao,{}),e[38]=D):D=e[38];let O;e[39]!==h?(O=h&&r.jsxs(ct,{onClick:h,children:[r.jsx(bn,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=O):O=e[40];let L;e[41]!==g||e[42]!==x?(L=x&&r.jsxs(ct,{onClick:x,children:[g?r.jsx(Ji,{}):r.jsx(Yi,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=L):L=e[43];let F;e[44]!==u||e[45]!==f?(F=u&&f&&r.jsxs(ct,{onClick:f,children:[r.jsx(xr,{}),r.jsx("span",{children:"File changes"})]}),e[44]=u,e[45]=f,e[46]=F):F=e[46];let z;e[47]!==m||e[48]!==p?(z=m&&(p??0)>0&&r.jsxs(ct,{onClick:m,children:[r.jsx(ch,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Me,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=z):z=e[49];let H;e[50]!==O||e[51]!==L||e[52]!==F||e[53]!==z?(H=r.jsxs(Ft,{children:[O,L,F,z]}),e[50]=O,e[51]=L,e[52]=F,e[53]=z,e[54]=H):H=e[54];let U;e[55]!==$||e[56]!==H?(U=r.jsxs(Rn,{children:[_,r.jsxs(In,{align:"end",sideOffset:6,className:"w-72",children:[$,D,H]})]}),e[55]=$,e[56]=H,e[57]=U):U=e[57];let W;return e[58]!==y||e[59]!==U||e[60]!==N||e[61]!==S?(W=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[y,j,k,N,S,U]}),e[58]=y,e[59]=U,e[60]=N,e[61]=S,e[62]=W):W=e[62],W}const BA=v.memo(function(e){const t=B.c(11),{isMobile:s}=Rt(),{session:o,sessionSource:i}=it();if(!s||!o)return null;let a;t[0]!==i?(a=i?vs(i.fileName):null,t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]!==o||t[3]!==(i==null?void 0:i.dirName)?(c=fo(i==null?void 0:i.dirName).contextWindow?o.rawMessages:[],t[2]=o,t[3]=i==null?void 0:i.dirName,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(FA,{...e,onDuplicateSession:e.onDuplicateSession,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 UA({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=v.useRef(null),i=v.useRef(null),a=v.useRef(n),l=v.useRef(e);return a.current=n,l.current=e,v.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,x;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):(x=a.current)==null||x.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 WA=["sessions","chat","stats"];function HA({hasSession:n,hasPendingSession:e}){return WA.filter(t=>!(t==="stats"&&!n&&!e))}function xp(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const KA=v.lazy(()=>Ke(()=>import("./MobileFileChanges-Bb3zEFSH.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function qA(n){const e=B.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Rt(),{session:c,isSubAgentView:d}=it(),f=!!c,u=!!a.pendingDirName;let m;e[0]!==f||e[1]!==u?(m=HA({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 F=xp(p,a.mobileTab,1);F&&(mc(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{const F=xp(p,a.mobileTab,-1);F&&(mc(),t.actions.handleMobileTabChange(F))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=UA(h);let x;e[7]!==i||e[8]!==t.actions?(x=F=>{i.onSearchOpenChange(!1),t.actions.handleMobileTabChange(F)},e[7]=i,e[8]=t.actions,e[9]=x):x=e[9];const b=x,w=`${l.themeClasses} flex h-dvh flex-col bg-background text-foreground`,y=i.backgroundServers;let j,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(ox,{}),k=r.jsx(sx,{}),e[10]=j,e[11]=k):(j=e[10],k=e[11]);let N;e[12]!==c||e[13]!==a.mobileTab?(N=!(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(Md,{compact:!0})}),e[12]=c,e[13]=a.mobileTab,e[14]=N):N=e[14];const C=a.mobileTab,S=!(a.mobileTab==="chat"&&c)&&"motion-session-enter";let _;e[15]!==S?(_=G("flex min-h-0 min-w-0 flex-1",S),e[15]=S,e[16]=_):_=e[16];let P;e[17]!==t||e[18]!==a.mobileTab?(P=a.mobileTab==="sessions"&&r.jsx(e2,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=P):P=e[19];let A;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?(A=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(BA,{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(Pa,{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(E0,{projectPath:s.pendingPath??null}),ut("terminal")&&r.jsxs(J,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(wo,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(t2,{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]=A):A=e[29];let T;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(T=a.mobileTab==="stats"&&c&&r.jsx(T0,{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]=T):T=e[34];let E;e[35]!==a.mobileTab||e[36]!==_||e[37]!==P||e[38]!==A||e[39]!==T?(E=r.jsxs("div",{className:_,children:[P,A,T]},C),e[35]=a.mobileTab,e[36]=_,e[37]=P,e[38]=A,e[39]=T,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 $;e[49]!==I||e[50]!==R?($=r.jsxs("div",{className:"shrink-0",children:[I,R]}),e[49]=I,e[50]=R,e[51]=$):$=e[51];let D;e[52]!==b||e[53]!==a.mobileTab?(D=r.jsx(zA,{activeTab:a.mobileTab,onTabChange:b}),e[52]=b,e[53]=a.mobileTab,e[54]=D):D=e[54];let O;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?(O=c&&o.hasFileChanges&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(KA,{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]=O):O=e[59];let L;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==N||e[65]!==M||e[66]!==$||e[67]!==D||e[68]!==O||e[69]!==w?(L=r.jsxs("div",{className:w,children:[y,j,k,N,M,$,i.workflowsPanel,D,i.undoDialog,i.branchModal,O]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=N,e[65]=M,e[66]=$,e[67]=D,e[68]=O,e[69]=w,e[70]=L):L=e[70],L}function VA(n){const e=B.c(13),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{theme:d,isMobile:f}=Rt(),{session:u}=it(),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(Pa,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),f?i:r.jsx(Ma,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(Hn,{className:"max-w-md",children:r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:s?r.jsx(vn,{}):r.jsx(rt,{className:"animate-spin"})}),r.jsx(qn,{children:s?"Unable to open session":"Opening session"}),r.jsx(Vn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot 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 GA=5;function di(n,e){const t=mn(),s=ps();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class YA{constructor(){Hr(this,"cache",new Map)}get(e,t){const s=di(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=di(e,t);!this.cache.has(d)&&this.cache.size>=GA&&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=di(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(di(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 hn=new YA,bp={};function n2(n,e,t,s,o,i){const[a,l]=v.useState(!1),[c,d]=v.useState("disconnected"),[f,u]=v.useState(!1),[m,p]=v.useState(null),[h,g]=v.useState(bp),[x,b]=v.useState(null),[w,y]=v.useState(so),j=v.useRef(""),k=v.useRef(null),N=v.useRef(so),C=v.useRef("disconnected"),S=v.useRef(e);S.current=e;const _=v.useRef(o);_.current=o;const P=v.useRef(t);P.current=t;const A=v.useRef(s);A.current=s;const T=v.useRef(i??null);T.current=i??null;const E=v.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)??"",$=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return v.useEffect(()=>{if(j.current=R,!R){k.current=null,l(!1);return}const D=T.current;if(D){k.current=D;return}P.current(R).then(O=>{k.current=O})},[R]),v.useEffect(()=>{if(b(null),!M||!I){l(!1),d("disconnected");return}d("connecting");const D=`/api/watch/${encodeURIComponent(M)}/${encodeURIComponent(I)}?offset=${$}`,O=new EventSource(yr(D));let L=null;const F=(ae=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),u(!1)},ae)};let z="",H=$,U=!1,W=!1,K=!1,q=null;const Y=()=>{K=!1,q=null,k.current&&S.current(k.current)},V=()=>{K||(K=!0,q=requestAnimationFrame(Y))};let Q=!1,Z=null,X=null;const ee=()=>{Q=!1,Z=null,y(N.current)},oe=()=>{Q||(Q=!0,Z=requestAnimationFrame(ee))},se=ae=>{ae!==N.current&&(N.current=ae,oe(),ae.length>0&&!X&&(X=setInterval(()=>{const te=d_(N.current);te!==N.current&&(N.current=te,oe()),N.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},re=()=>{se(so),g(bp)},ie=()=>{if(W||U||!z)return;const ae=z;z="",U=!0;const te=k.current;(te?A.current(te,ae):P.current(j.current)).then(me=>{W||(k.current=me,M&&I&&hn.update(M,I,{parsed:me,source:{rawText:j.current,watchOffset:H}}),V())}).catch(me=>{console.error("[useLiveSession] worker parse failed:",me)}).finally(()=>{U=!1,!W&&z&&ie()})};return O.onopen=()=>{var ae;if(C.current!=="connected"){const te=E.current;E.current=!1,C.current="connected",d("connected"),te&&((ae=_.current)==null||ae.call(_))}},O.onmessage=ae=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const te=JSON.parse(ae.data);if(te.type==="init")te.recentlyActive?(l(!0),F(5e3)):F();else if(te.type==="compacting_in_progress")l(!0),u(!0),re(),F();else if(te.type==="subagent_activity")l(!0),F();else if(te.type==="runtime_activity")l(!0),F();else if(te.type==="stream_snapshot")l(!0),F(),se(a_(te.messages??[]));else if(te.type==="stream_delta")l(!0),F(),p(null),b(null),se(l_(N.current,te.events??[]));else if(te.type==="agent_progress")l(!0),F(),g(he=>({...he,[te.toolUseId]:te.summary}));else if(te.type==="prompt_suggestion")b(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")re();else if(te.type==="lines"&&te.lines.length>0){l(!0),u(!1),F(),se(c_(N.current,te.lines));const he=te.lines.join(`
|
|
129
129
|
`)+`
|
|
130
130
|
`;H+=new TextEncoder().encode(he).byteLength,j.current+=he,z+=he,ie()}}catch(te){console.error("[useLiveSession] Error processing SSE message:",te)}},O.onerror=()=>{l(!1),u(!1),E.current=C.current==="connected",C.current="disconnected",d("disconnected"),re()},()=>{W=!0,O.close(),l(!1),C.current="disconnected",d("disconnected"),L&&clearTimeout(L),q!==null&&cancelAnimationFrame(q),Z!==null&&cancelAnimationFrame(Z),X&&clearInterval(X),N.current=so,y(so)}},[M,I,R,$]),{isLive:a,sseState:c,isCompacting:f,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:x}}const XA=3e4;function s2(n,e,t){const s=B.c(9),o=XA,[i,a]=v.useState(!1),l=v.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]),v.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(yr(n));a(!1);const x=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&a(!1)},o)};return g.onmessage=b=>{if(p)try{const w=JSON.parse(b.data);w.type==="init"?x():w.type==="update"&&(a(!0),x(),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]),v.useEffect(f,u);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function JA(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return s2(t,e)}function QA(n,e){const[t,s]=v.useState(null),o=v.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=v.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 v.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),JA((t==null?void 0:t.teamName)??null,a),t}function ZA(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),s2(o,s)}function eR(n,e,t=!0){const[s,o]=v.useState([]),[i,a]=v.useState(!1),l=v.useRef(0),c=!!n&&!!e,d=v.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]);v.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const f=c&&(t||s.length>0),{isLive:u}=ZA(f?n:null,f?e:null,null,d);return{workflows:s,loading:i,isLive:u,refetch:d}}const Bi={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},tR="cogpit:permissions";function nR(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 vp(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function o2(n,{model:e,agentKind:t,errorFallback:s,onModelRejected:o}){const i=d=>typeof s=="function"?s(d):s;let l=await n(t==="copilot"?e||"auto":e||void 0),c=l.ok?null:await vp(l,i(l));return!l.ok&&t==="codex"&&e&&nR(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await vp(l,i(l))),{res:l,errorMessage:c}}function sR({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:o,model:i,effort:a,fastMode:l,ultracode:c,mcpConfig:d,onModelRejected:f,readOnly:u=!1,onCreateSession:m}){const[p,h]=v.useState("idle"),[g,x]=v.useState(),[b,w]=v.useState([]),y=v.useRef(null),j=v.useRef(null),k=v.useRef(!1),N=n!=null&&n.fileName?Dl(n.fileName):null,C=e||N,S=n?St(n.dirName):null,_=v.useCallback(()=>{var R;(R=y.current)==null||R.abort(),y.current=null,k.current=!1,h("idle"),x(void 0),w([])},[]);v.useEffect(()=>{var R;j.current!==C&&(k.current?(k.current=!1,(R=y.current)==null||R.abort(),y.current=null,h("idle"),x(void 0)):_(),j.current=C)},[C,_]),v.useEffect(()=>()=>{var R;(R=y.current)==null||R.abort()},[]),v.useEffect(()=>{u&&_()},[u,_]);const P=v.useCallback(async(R,$)=>{if(u)return;if(!C&&m){w(L=>[...L,R]),h("connected"),x(void 0),k.current=!0,o==null||o();try{if(!await m(R,$)){k.current=!1,h("idle"),w([]);return}h("idle")}catch(L){k.current=!1,x(L instanceof Error?L.message:"Failed to create session"),h("error"),w([])}return}if(!C)return;w(L=>[...L,R]),h("connected"),x(void 0);const D=s??Bi;o==null||o();const O=new AbortController;y.current=O;try{const L={sessionId:C,message:R,images:$||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:F,errorMessage:z}=await o2(H=>ye("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:H}),signal:O.signal}),{model:i,agentKind:S,errorFallback:H=>`Request failed (${H.status})`,onModelRejected:f});y.current===O&&(F.ok?h("idle"):(x(z||`Request failed (${F.status})`),h("error"),w(H=>H.slice(0,-1))))}catch(L){if(L instanceof Error&&L.name==="AbortError")return;y.current===O&&(x(L instanceof Error?L.message:"Unknown error"),h("error"),w(F=>F.slice(0,-1)))}},[C,S,t,s,o,i,a,l,c,d,f,u,m]),A=v.useCallback(()=>{_()},[_]),T=v.useCallback(()=>{!C||u||ye("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,u]),E=v.useCallback(()=>{var R;(R=y.current)==null||R.abort(),y.current=null,T(),h("idle"),w([])},[T]),M=E,I=v.useCallback((R=1)=>{w($=>$.slice(R))},[]);return{status:p,error:g,pendingMessages:b,sendMessage:P,disconnect:A,interrupt:E,stopAgent:M,consumePending:I,isConnected:p==="connected"}}const os={expandAll:!1,expandToolPayloads:!1},oR={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function yp(n,e,t,s){const o=i0(e,t,s);return o===n.turns?n:{...n,turns:o}}function Zs(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function rR(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...Zs(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...Zs(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...Zs(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...os,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,...os};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,...os}:{...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:yp(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:yp(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...Zs(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,...Zs(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...Zs(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...os,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 r2(){return v.useReducer(rR,oR)}function wp(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function i2({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialContentLen:i=0}){const a=v.useRef(null),l=v.useRef(null),c=v.useRef(!0),d=v.useRef(!1),f=v.useRef(0),u=v.useMemo(()=>(n==null?void 0:n.turns.flatMap(O=>O.contentBlocks.flatMap(L=>L.kind==="queued_prompt"?[{id:JSON.stringify([L.timestamp??"",L.content]),content:L.content}]:[])))??[],[n==null?void 0:n.turns]),m=v.useRef(null),p=v.useRef(!1),[h,g]=v.useState(!1),[x,b]=v.useState(!1),[w,y]=v.useState(null),j=v.useCallback(()=>{requestAnimationFrame(()=>{var O;(O=l.current)==null||O.scrollIntoView({behavior:"smooth"})})},[]),k=v.useCallback(()=>{wp(()=>{const O=a.current;O&&(O.scrollTop=O.scrollHeight),c.current=!0,d.current=!1})},[]),N=v.useCallback(()=>{p.current=!0},[]),C=v.useRef(!1),S=v.useRef(!1),_=v.useCallback(()=>{const O=a.current;if(!O)return;const L=O.scrollTop>10,F=O.scrollHeight-O.scrollTop-O.clientHeight>10;L!==C.current&&(C.current=L,g(L)),F!==S.current&&(S.current=F,b(F))},[]),P=v.useCallback(()=>{const O=a.current;O&&(c.current=O.scrollHeight-O.scrollTop-O.clientHeight<150,_())},[_]),A=v.useCallback(O=>{f.current=O},[]),T=v.useRef(o);v.useEffect(()=>{if(o===T.current)return;T.current=o;const O=p.current;p.current=!1;const L=()=>{const z=a.current;z&&(O?(z.scrollTop=0,c.current=!1):(z.scrollTop=z.scrollHeight,c.current=!0),d.current=!1)};wp(L);const F=setTimeout(()=>{L(),y(o)},150);return()=>clearTimeout(F)},[o]);const E=t.length;v.useEffect(()=>{E>0&&(d.current=!0,j())},[E,j]),v.useEffect(()=>{const O=(n==null?void 0:n.sessionId)??null,L=m.current,F=new Set(u.map(U=>U.id));if(!L||L.sessionId!==O){m.current={sessionId:O,ids:F};return}const z=u.filter(U=>!L.ids.has(U.id));if(m.current={sessionId:O,ids:F},z.length===0||E===0)return;let H=0;for(const U of z){const W=t[H];(W===U.content||(W==null?void 0:W.trim())===""&&U.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;v.useEffect(()=>{if(M===0)return;const O=M-f.current;O>0&&(E>0&&s(Math.min(O,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,$=(I==null?void 0:I.assistantText.length)??0;v.useEffect(()=>{if(!(!n||!e)){if(c.current){const O=a.current;O&&(O.scrollTop=O.scrollHeight)}requestAnimationFrame(_)}},[M,R,$,i,e,_]);const D=w===o;return v.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:x,initialScrollDone:D,handleScroll:P,scrollToBottomInstant:k,requestScrollToTop:N,resetTurnCount:A}),[h,x,D,P,k,N,A])}async function a2(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(`
|
|
131
131
|
`);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:St(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Ds(n,e,t,s){const o=hn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=mn(),a=ps(),{parsed:l,source:c,byteOffset:d,hasMore:f}=await a2(n,e,t,s);if(mn()!==i||ps()!==a)return{parsed:l,source:c};const u=hn.get(n,e);return u?{parsed:u.parsed,source:u.source}:(hn.set(n,e,l,c.rawText,d,f,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function l2(n,e,t,s){hn.evict(n,e);const o=mn(),i=ps(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await a2(n,e,t,s);return mn()===o&&ps()===i&&hn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function iR({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=v.useState(null),f=v.useCallback((b,w)=>{d(null),v.startTransition(()=>{n({type:"LOAD_SESSION",session:b,source:w,isMobile:e})}),i(b.turns.length),sA(b.sessionId,b.turns.length),o()},[n,e,i,o]),u=v.useCallback(async(b,w)=>{l==null||l(),d(null);try{const{parsed:y,source:j}=await Ds(b,w,a,"session");f(y,j)}catch(y){d(y instanceof Error?y.message:"Failed to load session")}},[f,a,l]),m=v.useCallback(async b=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:b.name});try{const w=await ye(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(b.name)}`);if(!w.ok)throw new Error(`Failed to find session for ${b.name}`);const{dirName:y,fileName:j}=await w.json(),{parsed:k,source:N}=await Ds(y,j,a,`session for ${b.name}`);v.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:k,source:N,memberName:b.name})}),i(k.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=v.useCallback(()=>d(null),[]),h=v.useCallback(()=>{v.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=v.useCallback((b,w)=>{n({type:"JUMP_TO_TURN",index:b,toolCallId:w})},[n]),x=v.useCallback(b=>{b!==t&&v.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:b})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:f,handleDashboardSelect:u,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const aR=/^\/preview\/([^/]+)\/?$/;function Dd(n){const e=aR.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function c2(){const n=ht();return n===wt?"":`/d/${n}`}function pc(){const n=c2();return n?`${n}/`:"/"}function d2(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function lR(n,e){return wy(n,e)}function cR(n){const e=c2();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=yy(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:pc()}function jp(n){const e=d2(n),t=Dd(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 dR({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=v.useState(null),c=v.useRef(0),d=v.useRef(window.location.pathname),f=v.useRef(!1),u=v.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 Ds(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=lR(m.dirName,m.sessionId);let h;try{h=await Ds(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=pc();window.history.replaceState(null,"",g),d.current=g,Co(ht(),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=pc();window.history.replaceState(null,"",p),d.current=p,Co(ht(),p)}}finally{c.current--}},[e,t,s,o,i]);return v.useEffect(()=>{if(f.current)return;f.current=!0,Co(ht(),window.location.pathname);const m=jp(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&u(m)},[u]),v.useEffect(()=>{if(c.current>0||Dd(d2(window.location.pathname)))return;const m=cR(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,Co(ht(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),v.useEffect(()=>{const m=()=>{const p=jp(window.location.pathname);d.current=window.location.pathname,Co(ht(),window.location.pathname),u(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[u]),{previewLoadError:a}}const uR=400;function Sp(){return Array.from(document.querySelectorAll("[data-live-session]"))}function fR(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 kp(n){n.focus({preventScroll:!0});const e=fR(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 mR(n){const e=B.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:x,onHistoryForward:b,onNavigateToSession:w,onCommitNavigation:y}=n;let j,k;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==y||e[4]!==x||e[5]!==b||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 N=!1,C=!1,S=null;const _=function(E){var $,D;const M=Xm("missionControl");if(M){if(E.key===M){E.repeat||(N=!0,C=E.shiftKey||E.altKey||(M==="Meta"?E.ctrlKey:E.metaKey));return}N&&(C=!0),S=null}if(yt("commandPalette",E)){E.preventDefault(),d==null||d();return}if(yt("integratedTerminal",E)){if(!ut("terminal"))return;E.preventDefault(),p();return}if(yt("preview",E)){E.preventDefault(),h();return}if(yt("projectFiles",E)){if(!ut("hostFiles"))return;E.preventDefault(),g();return}if(yt("expandAll",E)){E.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(yt("expandToolPayloads",E)){E.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(yt("toggleSidebar",E)){E.preventDefault(),a();return}if(yt("toggleStats",E)){E.preventDefault(),l();return}if(yt("missionControl",E)){E.preventDefault(),c();return}if(yt("newSession",E)&&(E.preventDefault(),f()),yt("themeSelector",E)&&(E.preventDefault(),u()),yt("systemTerminal",E)){if(!ut("terminal"))return;E.preventDefault(),m()}if(E.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),($=s.current)==null||$.blur()),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.code.startsWith("Digit")){const O=parseInt(E.code.charAt(5),10);if(O>=1&&O<=9){E.preventDefault();const F=Sp()[O-1];F&&(kp(F),F.click())}}const I=yt("recentSessionForward",E);if(I||yt("recentSessionBack",E)){E.preventDefault();const O=I?b():x();O&&w(O.dirName,O.fileName)}yt("focusComposer",E)&&!d0(document.activeElement)&&(E.preventDefault(),(D=o.current)==null||D.focus());const R=yt("nextLiveSession",E);if(R||yt("prevLiveSession",E)){E.preventDefault();const O=Sp();if(O.length===0)return;const L=O.findIndex(pR);let F;L===-1?F=R?0:O.length-1:F=Math.max(0,Math.min(O.length-1,L+(R?1:-1))),kp(O[F])}},P=function(E){const M=Xm("missionControl");if(M&&E.key===M&&N){const I=!C;if(N=!1,C=!1,I){const R=Date.now();S!==null&&R-S<=uR?(S=null,E.preventDefault(),c()):S=R}else S=null}E.key==="Control"&&(y==null||y())},A=function(){N=!1,C=!1,S=null};return window.addEventListener("keydown",_),window.addEventListener("keyup",P),window.addEventListener("blur",A),()=>{window.removeEventListener("keydown",_),window.removeEventListener("keyup",P),window.removeEventListener("blur",A)}},k=[t,s,o,i,a,l,c,d,f,u,m,p,h,g,x,b,w,y],e[0]=o,e[1]=i,e[2]=t,e[3]=y,e[4]=x,e[5]=b,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]=k):(j=e[18],k=e[19]),v.useEffect(j,k)}function pR(n){return n===document.activeElement}const Np="cogpit-theme",_I=[{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 hR(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function u2(){const[n,e]=v.useState(()=>{try{const l=localStorage.getItem(Np);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=v.useState(null),o=v.useCallback(l=>{localStorage.setItem(Np,l),e(l),s(null)},[]),i=t??n,a=hR(i);return v.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 gR="cogpit-session-history",hc=50;function f2(){return Lt(gR)}function xR(){try{const n=localStorage.getItem(f2());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,hc)}catch{}return[]}function Cp(n){try{localStorage.setItem(f2(),JSON.stringify(n))}catch{}}function bR(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=xR(),n[0]=e):e=n[0];const t=v.useRef(e),s=v.useRef(0),o=v.useRef(!1);let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=(h,g)=>{if(o.current){o.current=!1;return}const x=`${h}/${g}`;t.current=t.current.filter(b=>`${b.dirName}/${b.fileName}`!==x),t.current.unshift({dirName:h,fileName:g}),t.current.length>hc&&(t.current.length=hc),s.current=0,Cp(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),Cp(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 m2(){return Lt(tR)}function _p(){try{const n=localStorage.getItem(m2());if(n){const e=JSON.parse(n);return{mode:e.mode||Bi.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return Bi}function vR(n){localStorage.setItem(m2(),JSON.stringify(n))}function yR(){const n=B.c(21),[e,t]=v.useState(_p),[s,o]=v.useState(_p),i=v.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}vR(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),v.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=k=>{t(N=>({...N,mode:k}))},n[10]=f):f=n[10];const u=f;let m;n[11]===Symbol.for("react.memo_cache_sentinel")?(m=k=>{t(N=>{const C=N.allowedTools.includes(k);return{...N,allowedTools:C?N.allowedTools.filter(S=>S!==k):[...N.allowedTools,k]}})},n[11]=m):m=n[11];const p=m;let h;n[12]===Symbol.for("react.memo_cache_sentinel")?(h=k=>{t(N=>{const C=N.disallowedTools.includes(k);return{...N,disallowedTools:C?N.disallowedTools.filter(S=>S!==k):[...N.disallowedTools,k]}})},n[12]=h):h=n[12];const g=h;let x;n[13]!==e?(x=()=>{o(e)},n[13]=e,n[14]=x):x=n[14];const b=x;let w;n[15]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{t(Bi)},n[15]=w):w=n[15];const y=w;let j;return n[16]!==s||n[17]!==e||n[18]!==d||n[19]!==b?(j={config:e,appliedConfig:s,hasPendingChanges:d,setMode:u,toggleAllowedTool:p,toggleDisallowedTool:g,markApplied:b,resetToDefault:y},n[16]=s,n[17]=e,n[18]=d,n[19]=b,n[20]=j):j=n[20],j}const wR=2e3;function jR(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function SR(n){const[e,t]=v.useState([]),[s,o]=v.useState(null),[i,a]=v.useState(new Set);v.useEffect(()=>{if(!n){t([]),o(null);return}let d=!1;const f=async()=>{if(!d)try{const h=await ye(`/api/permissions/${encodeURIComponent(n)}`);if(d)return;if(h.ok){const g=await h.json();if(d)return;t(b=>jR(b,g.permissions)?b:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;o(b=>JSON.stringify(b)===JSON.stringify(x)?b:x)}}catch{}},u=()=>{(typeof document>"u"||document.visibilityState==="visible")&&f()},m=()=>{document.visibilityState==="visible"&&f()};u();const p=setInterval(u,wR);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=v.useCallback(async(d,f)=>{if(n){a(u=>new Set(u).add(d));try{await q0(n,d,f)&&t(u=>u.filter(m=>m.requestId!==d))}finally{a(u=>{const m=new Set(u);return m.delete(d),m})}}},[n]),c=v.useCallback(async d=>{if(n)try{await KP(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function kR(n,e){const t=await ye(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:e})});return t.ok?await t.json():null}async function NR(n,e,t){const s=await ye(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:e,mode:t})}),o=await s.json().catch(()=>null);return!s.ok||(o==null?void 0:o.outcome)!=="success"?{ok:!1,error:(o==null?void 0:o.error)||`Copilot rewind failed${o!=null&&o.outcome?`: ${o.outcome}`:""}`}:{ok:!0}}function CR(n){return n.file_path??n.path??""}function p2(n){const e=[];for(const t of n.toolCalls){if(t.isError||k6(t))continue;const s=CR(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 _R(n,e){return{index:e,userMessage:wa(n.userMessage),toolCalls:p2(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function Ui(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=p2(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 TR(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 Yo(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(...TR(i.toolCalls,i.index))}return t}function h2(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(_R(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 g2(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 x2(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 ER(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 PR(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function ui(n,e){return n.length>0?ER(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function b2(n,e,t){return F1(O1(St(t)),n,e)}function v2(n,e,t,s){const o=O1(St(s)),i=e==null?void 0:e.id;if(i){const a=wN(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return F1(o,n,t)}class Uo extends Error{constructor(){super("abort")}}async function AR(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=Ui(e.turns,e.turns.length-1,l),d=l+1,f=o.split(`
|
|
@@ -135,7 +135,7 @@ ${oe}
|
|
|
135
135
|
`).filter(Boolean).length},state:y})}const IR=[];function y2(n,e,t,s=!0){const[o,i]=v.useState(null),[a,l]=v.useState(null),[c,d]=v.useState(!1),[f,u]=v.useState(null),m=v.useRef(null),p=v.useRef(0);v.useEffect(()=>{if(p.current+=1,!s||!n){i(null),l(null),u(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!fo(e==null?void 0:e.dirName).redo){i(null);return}const A=n.sessionId,T=new AbortController;return ye(`/api/undo-state/${encodeURIComponent(A)}`,{signal:T.signal}).then(E=>E.ok?E.json():null).then(E=>{m.current===A&&i(E??null)}).catch(E=>{E instanceof Error&&E.name==="AbortError"||m.current===A&&i(null)}),()=>T.abort()},[s,n==null?void 0:n.sessionId]);const h=v.useCallback(async A=>{try{const T=await ye("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:A.operations,session:{dirName:A.sessionSource.dirName,fileName:A.sessionSource.fileName,mutation:A.sessionMutation},state:A.state,checkpoint:A.checkpoint})}),E=await T.json().catch(()=>null);if(!T.ok)throw u((E==null?void 0:E.error)||"Undo transaction failed"),new Uo;i(A.state)}catch(T){throw T instanceof Uo?T:(u(String(T)),new Uo)}},[]),g=(o==null?void 0:o.branches)??IR,{canRedo:x,redoTurnCount:b,redoBranch:w}=v.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let A=g.length-1;A>=0;A--){const T=g[A];if(T.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:T.turns.length,redoBranch:T}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),y=v.useMemo(()=>{if(!w||w.jsonlLines.length===0)return[];try{return ya(w.jsonlLines.join(`
|
|
136
136
|
`)).turns}catch{return[]}},[w]),j=v.useCallback(A=>g.filter(T=>T.branchPointTurnIndex===A),[g]),k=v.useCallback(A=>{if(!s||!n)return;const T=A-1;if(T>=n.turns.length-1||T<-1)return;if(fo(e==null?void 0:e.dirName).nativeRewind){const M=n.turns[A];if(!M)return;const I=n.sessionId,R=++p.current,$=()=>p.current===R&&m.current===I,D=M.id.includes("@")?M.id.slice(M.id.lastIndexOf("@")+1):M.id,O=n.turns.length-A;kR(n.sessionId,D).then(L=>{var H;if(!$())return;const F=((H=L==null?void 0:L.files)==null?void 0:H.map(({path:U})=>U).filter(U=>typeof U=="string"))??[],z=L!=null&&L.available?L.fileCount??F.length:0;l({type:"undo",summary:{turnCount:O,fileCount:z,filePaths:F,operationCount:z},targetTurnIndex:T,nativeRewind:{eventId:D,mode:"conversation",filesAvailable:!!(L!=null&&L.available&&z>0)}})}).catch(()=>{$()&&l({type:"undo",summary:{turnCount:O,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:T,nativeRewind:{eventId:D,mode:"conversation"}})});return}const E=Ui(n.turns,n.turns.length-1,T);l({type:"undo",summary:ui(E,n.turns.length-1-T),targetTurnIndex:T})},[s,n,e==null?void 0:e.dirName]),N=v.useCallback(()=>{if(!s||!x||!w||!n)return;const A=Yo(w.turns);l({type:"redo",summary:ui(A,w.turns.length),targetTurnIndex:w.branchPointTurnIndex+w.turns.length,branchId:w.id})},[s,x,w,n]),C=v.useCallback(A=>{if(!s||!x||!w||!n)return;const T=A+1,E=Yo(w.turns,A);l({type:"redo",summary:ui(E,T),targetTurnIndex:w.branchPointTurnIndex+T,branchId:w.id,redoUpToArchiveIndex:A})},[s,x,w,n]),S=v.useCallback((A,T)=>{if(!s||!n)return;const E=g.find($=>$.id===A);if(!E)return;const M=T??E.turns.length-1,I=n.turns.length>E.branchPointTurnIndex+1?Ui(n.turns,n.turns.length-1,E.branchPointTurnIndex):[],R=Yo(E.turns,M);l({type:"branch-switch",summary:ui([...I,...R],M+1),targetTurnIndex:E.branchPointTurnIndex,branchId:A,branchTurnIndex:M})},[s,n,g]),_=v.useCallback(async(A=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),u(null);try{if(a.nativeRewind){const I=A&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",R=await NR(n.sessionId,a.nativeRewind.eventId,I);if(!R.ok){u(R.error);return}await t(),l(null);return}const T=o??PR(n.sessionId,n.turns.length),E=await ye(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!E.ok){u("Failed to read session file");return}const M=await E.text();if(a.type==="undo")await AR(a,n,e,T,M,h,u);else if(a.type==="redo"){const I=g.find(R=>R.id===a.branchId);if(!I){l(null);return}await RR(a,e,T,I,M,h)}else if(a.type==="branch-switch"){const I=g.find(R=>R.id===a.branchId);if(!I){l(null);return}await MR(n,e,T,I,M,a,h)}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(T){if(!(T instanceof Uo))throw T}finally{d(!1)}},[s,a,n,e,o,g,h,t]),P=v.useCallback(()=>{p.current+=1,l(null),u(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:b,redoGhostTurns:y,branches:g,branchesAtTurn:j,requestUndo:k,requestRedoAll:N,requestRedoUpTo:C,requestBranchSwitch:S,confirmState:a,confirmApply:_,confirmCancel:P,isApplying:c,applyError:f}}async function $R(n){try{const t=await(await rs("/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 Tp(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:vy(t==null?void 0:t.mode,Fs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function OR(){const n=B.c(26),[e,t]=v.useState(!0),[s,o]=v.useState(null),[i,a]=v.useState(null),[l,c]=v.useState(Fs),[d,f]=v.useState(!1),[u,m]=v.useState(null),[p,h]=v.useState(!1),[g,x]=v.useState(0),b=v.useRef(null),w=v.useRef(null);let y;n[0]===Symbol.for("react.memo_cache_sentinel")?(y=U=>{a(U.claudeDir),c(U.defaultAgentKind),s5(U.useBuiltInEditor)},n[0]=y):y=n[0];const j=y;let k;n[1]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{var K;(K=b.current)==null||K.abort();const U=new AbortController;b.current=U;const W=await $R(U.signal);U.signal.aborted||b.current!==U||(m(W.url),h(W.disabled))},n[1]=k):k=n[1];const N=k;let C,S;n[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{var U,W;(U=b.current)==null||U.abort(),(W=w.current)==null||W.abort()},S=[],n[2]=C,n[3]=S):(C=n[2],S=n[3]),v.useEffect(C,S);let _;n[4]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const U=new AbortController;return t(!0),o(null),Tp(U.signal).then(j).catch(W=>{W instanceof Error&&W.name==="AbortError"||(a(null),o(W instanceof Error?W.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||t(!1)}),()=>U.abort()},n[4]=_):_=n[4];let P;n[5]!==g?(P=[j,g],n[5]=g,n[6]=P):P=n[6],v.useEffect(_,P);let A,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const U=()=>x(LR);return window.addEventListener("cogpit-auth-changed",U),()=>window.removeEventListener("cogpit-auth-changed",U)},T=[],n[7]=A,n[8]=T):(A=n[7],T=n[8]),v.useEffect(A,T);let E;n[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{N()},n[9]=E):E=n[9];let M;n[10]!==i?(M=[i,N],n[10]=i,n[11]=M):M=n[11],v.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 $;n[13]!==i?($=U=>{if(f(!1),U!==i){a(U),window.location.reload();return}x(DR),N()},n[13]=i,n[14]=$):$=n[14];const D=$;let O;n[15]===Symbol.for("react.memo_cache_sentinel")?(O=()=>f(!0),n[15]=O):O=n[15];const L=O;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{var W;(W=w.current)==null||W.abort();const U=new AbortController;w.current=U,t(!0),o(null),Tp(U.signal).then(K=>{U.signal.aborted||w.current!==U||j(K)}).catch(K=>{U.signal.aborted||w.current!==U||(a(null),o(K instanceof Error?K.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||w.current!==U||t(!1)})},n[16]=F):F=n[16];const z=F;let H;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==D||n[22]!==p||n[23]!==u||n[24]!==d?(H={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:L,handleCloseConfigDialog:R,handleConfigSaved:D,retryConfig:z,networkUrl:u,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=D,n[22]=p,n[23]=u,n[24]=d,n[25]=H):H=n[25],H}function DR(n){return n+1}function LR(n){return n+1}const Ep={authenticated:!0,edition:"personal",user:null,capabilities:da},dn={authenticated:!1,edition:"personal",user:null,capabilities:kr},w2=Object.keys(da);function Pp(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&w2.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function zR(n,e){const t={...kr};for(const s of w2)t[s]=n[s]&&e[s];return t}async function Ap(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function FR(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 Mo(n){var e;return oo(n),Ph(((e=n.user)==null?void 0:e.id)??null),n}function BR(n){const e=B.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...dn,checked:!1},e[0]=t):t=e[0];const[s,o]=v.useState(t),[i,a]=v.useState(0),l=v.useRef(null),c=v.useRef(!1);let d;e[1]!==n?(d=()=>{var y;if((y=l.current)==null||y.abort(),n===null){c.current=!1,oo(dn),o({...dn,checked:!1});return}const p=c.current;c.current=!1,oo(dn),o(j=>p?{...j,capabilities:kr,checked:!1}:{...dn,checked:!1});const h=new AbortController;l.current=h;const g=$s(),x=Ap(rs,h.signal),b=g?FR(h.signal):Promise.resolve(n),w=g?Ap(ye,h.signal):Promise.resolve(null);return Promise.all([x,b,w]).then(j=>{const[k,N,C]=j;if(h.signal.aborted)return;const S=Pp(k,n)?k:n==="personal"?Ep:null;if(!S||N===null){o({...Mo(dn),checked:!1});return}if(!g){o({...Mo(S),checked:!0});return}const _=Pp(C,N)?C:N==="personal"?Ep:null;if(!_){o({...Mo(dn),checked:!1});return}o({...Mo({authenticated:S.authenticated,edition:S.edition,user:S.user,capabilities:zR(S.capabilities,_.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Mo(dn),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],v.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,oo(dn),Ph(null),o({...dn,checked:!1}),a(HR)},h=g=>{var w,y;const x=ht();if(x===wt)return;const b=(w=g.detail)==null?void 0:w.deviceId;b&&b!==x||((y=l.current)==null||y.abort(),c.current=!0,oo(dn),o(WR),a(UR))};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]),v.useEffect(u,m),s}function UR(n){return n+1}function WR(n){return{...n,capabilities:kr,checked:!1}}function HR(n){return n+1}const KR=3e4;function qR(n){const[e,t]=v.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=v.useRef(0),o=v.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]);v.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),KR);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 VR(){const n=B.c(3),[e,t]=v.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 GR(n,e){return n?`${n}.jsonl`:e??null}async function j2(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 YR=300,Al=new Map;function gc(n,e){const t=Lt(n),s=Al.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{Al.delete(t),Lt(n)===t&&(async()=>{try{await ye(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},YR);Al.set(t,{patch:o,timer:i})}function xc(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function Rp(n){const e=await j2(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function Mp(n,e){gc(n,{mcpServers:e})}async function XR(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function Ip(n,e){try{const t=await ye(n,{signal:e});if(e.aborted)return null;const s=await XR(t);return e.aborted?null:s}catch{return null}}async function $p(n,e,t){const s=xc(t);if(s.size===0)return[];if(n){const o=await Rp(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await Rp(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function JR(n,e,t,s=!0){const[o,i]=v.useState([]),[a,l]=v.useState({}),[c,d]=v.useState([]),[f,u]=v.useState(!1),[m,p]=v.useState(!1),h=v.useRef(null),g=v.useRef(e);g.current=e;const x=t??e??null,b=v.useRef(x);b.current=x;const w=v.useRef(void 0);v.useEffect(()=>{var C,S;if(!s||!n){(C=h.current)==null||C.abort(),w.current=void 0,i([]),l({}),d([]),u(!1),p(!1);return}const N=new AbortController;return(S=h.current)==null||S.abort(),i([]),l({}),d([]),u(!0),p(!1),w.current=n,Ip(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,N.signal).then(async _=>{if(N.signal.aborted||w.current!==n||!_)return;i(_.servers),l(_.configs);const P=await $p(b.current,g.current,_.servers);N.signal.aborted||w.current!==n||d(P)}).finally(()=>{N.signal.aborted||w.current!==n||(u(!1),p(!0))}),()=>N.abort()},[n,s]),v.useEffect(()=>()=>{var N;return(N=h.current)==null?void 0:N.abort()},[]),v.useEffect(()=>{if(o.length===0||!x)return;let N=!1;return $p(x,e,o).then(C=>{N||b.current!==x||d(C)}),()=>{N=!0}},[x]);const y=v.useCallback(N=>{d(C=>{const S=C.includes(N)?C.filter(_=>_!==N):[...C,N];return b.current&&Mp(b.current,S),S})},[]),j=v.useCallback(()=>{var C;if(!s||!n)return;(C=h.current)==null||C.abort();const N=new AbortController;h.current=N,u(!0),Ip(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,N.signal).then(S=>{if(N.signal.aborted||w.current!==n||!S)return;i(S.servers),l(S.configs);const _=xc(S.servers);d(P=>{const A=P.filter(T=>_.has(T));return b.current&&Mp(b.current,A),A})}).finally(()=>{N.signal.aborted||h.current!==N||u(!1)})},[n,s]),k=v.useMemo(()=>{if(o.length===0)return null;const N=xc(o);if(c.length===N.size&&N.size>0&&c.every(_=>N.has(_))||!c.every(_=>a[_]))return null;const S=Object.fromEntries(c.map(_=>[_,a[_]]));return JSON.stringify({mcpServers:S})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:k,loading:f,loaded:m,toggleServer:y,refresh:j}}function QR(n){var s,o;const e=B.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 x of g.toolCalls){if(x.name==="TodoWrite"){const b=x.input;Array.isArray(b.todos)&&(i=b.todos);continue}if(x.name==="TaskCreate"){const b=x.input;h=h+1;const y=((o=(s=x.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:b.subject||b.description||`Task ${y}`,activeForm:b.activeForm||b.subject||`Working on task ${y}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,w=String(b.taskId??"");if(!w)continue;if(b.status==="deleted"){p.delete(w);continue}const y=p.get(w)??{id:w,content:b.subject||b.description||`Task ${w}`,activeForm:b.activeForm||b.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...y,content:b.subject||b.description||y.content,activeForm:b.activeForm||y.activeForm,status:b.status||y.status,owner:b.owner??y.owner,blockedBy:b.addBlockedBy?[...new Set([...y.blockedBy??[],...b.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(eM),e[4]=l,e[5]=c):c=e[5];const d=c.length;let f;e[6]!==l?(f=l.find(ZR)??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 ZR(n){return n.status==="in_progress"}function eM(n){return n.status==="completed"}function tM(n){const e=B.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,o]=v.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]),v.useEffect(i,a),s}function nM(n,e){const t=B.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]=v.useState(o),[l,c]=v.useState(!1),d=v.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(sM).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]),v.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 sM(n){return n.json()}function Io(n,e){const t=B.c(6),[s,o]=ja(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 oM(n,e){const t=B.c(45),[s,o]=Io("panel-sidebar-visible",!0),[i,a]=Io("panel-stats-visible",!1),[l,c]=Io("panel-worktrees-visible",!1),[d,f]=Io("panel-workflows-visible",!1),[u,m]=Io("panel-file-changes-visible",!0),[p,h]=v.useState(!1),[g,x]=v.useState(!1);let b;t[0]!==o||t[1]!==s?(b=()=>{v.startTransition(()=>o(!s))},t[0]=o,t[1]=s,t[2]=b):b=t[2];const w=b;let y;t[3]!==a||t[4]!==i?(y=()=>{v.startTransition(()=>a(!i))},t[3]=a,t[4]=i,t[5]=y):y=t[5];const j=y;let k;t[6]!==c?(k=()=>c(aM),t[6]=c,t[7]=k):k=t[7];const N=k;let C;t[8]!==f?(C=()=>f(iM),t[8]=f,t[9]=C):C=t[9];const S=C;let _;t[10]!==m||t[11]!==u?(_=()=>{v.startTransition(()=>m(!u))},t[10]=m,t[11]=u,t[12]=_):_=t[12];const P=_;let A;t[13]!==e||t[14]!==n.mainView?(A=()=>{const K=n.mainView==="config";v.startTransition(()=>{e({type:K?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[13]=e,t[14]=n.mainView,t[15]=A):A=t[15];const T=A;let E;t[16]!==e||t[17]!==n.mainView?(E=()=>{const K=n.mainView==="mission";v.startTransition(()=>{e({type:K?"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=K=>{v.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:K})})},t[19]=e,t[20]=I):I=t[20];const R=I;let $;t[21]===Symbol.for("react.memo_cache_sentinel")?($=()=>h(!0),t[21]=$):$=t[21];const D=$;let O;t[22]===Symbol.for("react.memo_cache_sentinel")?(O=()=>h(!1),t[22]=O):O=t[22];const L=O;let F;t[23]===Symbol.for("react.memo_cache_sentinel")?(F=()=>x(rM),t[23]=F):F=t[23];const z=F;let H;t[24]===Symbol.for("react.memo_cache_sentinel")?(H=()=>x(!1),t[24]=H):H=t[24];const U=H;let W;return t[25]!==R||t[26]!==T||t[27]!==P||t[28]!==M||t[29]!==w||t[30]!==j||t[31]!==S||t[32]!==N||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:N,handleToggleWorkflows:S,handleToggleFileChanges:P,handleToggleConfig:T,handleToggleMission:M,handleEditConfig:R,handleOpenProjectSwitcher:D,handleCloseProjectSwitcher:L,handleToggleThemeSelector:z,handleCloseThemeSelector:U,setShowSidebar:o,setShowWorktrees:c,setShowWorkflows:f,setShowFileChanges:m},t[25]=R,t[26]=T,t[27]=P,t[28]=M,t[29]=w,t[30]=j,t[31]=S,t[32]=N,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 rM(n){return!n}function iM(n){return!n}function aM(n){return!n}function lM(n){var K;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,x=v.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:q,fileName:Y}=e.sessionSource;try{const{parsed:V,source:Q}=await l2(q,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:V,source:Q})}catch{}},[e.sessionSource,t,g]),[b,w]=v.useState(null),y=v.useCallback(q=>w(q),[]),j=v.useCallback(()=>w(null),[]),k=v.useCallback(async(q,Y)=>{try{const V=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:Y})});if(!V.ok)return;const Q=await V.json(),{parsed:Z,source:X}=await Ds(Q.dirName,Q.fileName,g,"session");t({type:"LOAD_SESSION",session:Z,source:X,isMobile:s})}catch{}},[t,s,g]),N=v.useCallback(()=>{e.sessionSource&&k(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,k]),C=v.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{}},[]),S=v.useCallback(async q=>{var Z,X;if(!e.sessionSource)return;const{dirName:Y,fileName:V}=e.sessionSource,Q=(X=(Z=e.session)==null?void 0:Z.turns[q])==null?void 0:X.id;try{const ee=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:V,turnIndex:q,turnUuid:Q})});if(!ee.ok)return;const oe=await ee.json(),{parsed:se,source:re}=await Ds(oe.dirName,oe.fileName,g,"session");t({type:"LOAD_SESSION",session:se,source:re,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),_=v.useCallback((q,Y)=>{o(q,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[P,A]=v.useState({}),T=v.useRef(c);T.current=c;const E=v.useRef(d);E.current=d;const M=v.useRef(m);M.current=m;const I=v.useRef(f);I.current=f;const R=v.useRef(u);R.current=u;const $=v.useRef(l);$.current=l;const D=((K=e.session)==null?void 0:K.sessionId)??null,O=v.useRef(null);v.useEffect(()=>{D!==O.current&&(O.current=D,D&&A(q=>D in q?q:{...q,[D]:{model:T.current,effort:E.current,fastMode:I.current,ultracode:R.current,mcpConfig:M.current}}))},[D]);const L=D?P[D]:void 0,F=m!==((L==null?void 0:L.mcpConfig)??null),z=L!=null&&(c!==L.model||d!==L.effort||f!==L.fastMode||u!==L.ultracode||a||F),H=v.useCallback(async()=>{var oe,se;if(!D)return;const q=T.current,Y=E.current,V=I.current,Q=R.current,Z=M.current,X=$.current,ee=((oe=e.sessionSource)==null?void 0:oe.agentKind)??St(((se=e.sessionSource)==null?void 0:se.dirName)??null);Ut(ee).settingsApply==="live"&&await ye(`/api/claude/settings/${encodeURIComponent(D)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:q,effort:Y,fastMode:V,ultracode:Q,mcpConfig:Z,permissionMode:X.mode,allowedTools:X.allowedTools,disallowedTools:X.disallowedTools})}),A(re=>({...re,[D]:{model:q,effort:Y,fastMode:V,ultracode:Q,mcpConfig:Z}})),i()},[D,e.sessionSource,i]),U=v.useCallback(async()=>{if(D)try{await ye("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:D})})}catch{}},[D]),W=v.useCallback((q,Y)=>{vs(Y)&&p(),h(q,Y)},[p,h]);return{reloadSession:x,branchModalTurn:b,setBranchModalTurn:w,handleOpenBranches:y,handleCloseBranchModal:j,handleDuplicateSessionByPath:k,handleDuplicateSession:N,handleDeleteSession:C,handleBranchFromHere:S,handleMobileJumpToTurn:_,hasSettingsChanges:z,handleApplySettings:H,handleStopSession:U,handleLoadSessionScrollAware:W}}function S2(){const n=B.c(6),e=v.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=v.useRef(t),o=v.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-DycJL0jJ.js",import.meta.url),{type:"module"});return p.onmessage=h=>{const g=h.data,x=m.get(g.id);x&&(m.delete(g.id),g.type==="result"?x.resolve(g.session):x.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]),v.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 x=o.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>ya(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,x)=>{o.current=o.current+1;const b=o.current;s.current.set(b,{resolve:g,reject:x}),h.postMessage({type:"append",id:b,existing:m,newText:p})}):Promise.resolve().then(()=>NN(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 cM=30;function k2({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=v.useState(!1),[l,c]=v.useState(!1),d=v.useRef(""),f=v.useRef(null),u=`${n??""}::${e??""}::${t}`;return v.useEffect(()=>{d.current=u,f.current=null,c(!1);const p=n&&e?hn.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:v.useCallback(async()=>{if(!n||!e||f.current)return 0;const p=`${n}::${e}::${t}`,h=hn.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 x=await ye(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${cM}`);if(!x.ok)return 0;const b=await x.json(),w=b.lines.length>0&&b.hasMore;if(d.current===p&&a(w),b.lines.length===0)return hn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset}),0;const y=new Set(b.headerLines),j=b.lines.filter(C=>!y.has(C)),k=await s([...b.headerLines,...j].join(`
|
|
137
137
|
`)),N=i0(h.olderTurns,k.turns,h.source.agentKind);return hn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset,olderTurns:N}),d.current!==p?0:(o(N),k.turns.length)}finally{f.current===g&&(f.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function dM(n){const e=B.c(50),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??Fs,c=$h(l),[d,f]=v.useState(""),[u,m]=v.useState(""),[p,h]=v.useState(!1),[g,x]=v.useState(!1),b=d||(s==null?void 0:s.model);let w;e[0]!==l||e[1]!==b?(w=$y(l,b),e[0]=l,e[1]=b,e[2]=w):w=e[2];const y=w,j=g&&y;let k;e[3]!==l||e[4]!==u||e[5]!==d||e[6]!==j?(k=j?"xhigh":ta(l,u,d),e[3]=l,e[4]=u,e[5]=d,e[6]=j,e[7]=k):k=e[7];const N=k;let C;e[8]!==l||e[9]!==d?(C=Nh(l,d),e[8]=l,e[9]=d,e[10]=C):C=e[10];const S=!!C,_=S&&p;let P;e[11]!==l||e[12]!==d?(P=My(l,d),e[11]=l,e[12]=d,e[13]=P):P=e[13];const A=P,[T,E]=v.useState(null),M=v.useRef(null),I=(o==null?void 0:o.fileName)??null,R=v.useRef(I);let $,D;e[14]!==I?($=()=>{const ee=R.current;R.current=I,!(ee===null||ee===I)&&x(!1)},D=[I],e[14]=I,e[15]=$,e[16]=D):($=e[15],D=e[16]),v.useEffect($,D);let O,L;e[17]!==i?(O=()=>{i&&x(!1)},L=[i],e[17]=i,e[18]=O,e[19]=L):(O=e[18],L=e[19]),v.useEffect(O,L);let F;e[20]!==l?(F=ee=>{f(oe=>oe===ee?"":oe),E(`${ee} is unavailable for this account. Cogpit retried the turn with ${Zt(l).displayName}'s default model.`)},e[20]=l,e[21]=F):F=e[21];const z=F;let H;e[22]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{E(null)},e[22]=H):H=e[22];const U=H;let W,K;e[23]!==c||e[24]!==i||e[25]!==d||e[26]!==o?(W=()=>{d&&(!o&&!i||c.some(ee=>ee.value===d)||f(""))},K=[c,d,o,i],e[23]=c,e[24]=i,e[25]=d,e[26]=o,e[27]=W,e[28]=K):(W=e[27],K=e[28]),v.useEffect(W,K);let q,Y;e[29]!==T?(q=()=>{if(!T)return;const ee=setTimeout(()=>E(null),12e3);return()=>clearTimeout(ee)},Y=[T],e[29]=T,e[30]=q,e[31]=Y):(q=e[30],Y=e[31]),v.useEffect(q,Y);const V=s==null?void 0:s.rawMessages;let Q,Z;e[32]!==l||e[33]!==a||e[34]!==V?(Q=()=>{if(!a||!V||!Ut(l).modelFallbackNotices)return;let ee;for(let ae=V.length-1;ae>=0;ae=ae-1,ae){const te=V[ae];if(te.type==="system"&&te.subtype==="model_refusal_fallback"){ee=te;break}}if(!ee)return;const oe=typeof ee.uuid=="string"?ee.uuid:`${String(ee.original_model)}:${String(ee.fallback_model)}:${String(ee.request_id)}`;if(M.current===oe)return;M.current=oe;const se=typeof ee.original_model=="string"?ee.original_model:"Fable",re=typeof ee.fallback_model=="string"?ee.fallback_model:"Opus",ie=typeof ee.api_refusal_explanation=="string"?` ${ee.api_refusal_explanation}`:"";E(`${se} could not handle this request, so Claude continued with ${re}.${ie}`)},Z=[a,V,l],e[32]=l,e[33]=a,e[34]=V,e[35]=Q,e[36]=Z):(Q=e[35],Z=e[36]),v.useEffect(Q,Z);let X;return e[37]!==N||e[38]!==_||e[39]!==S||e[40]!==p||e[41]!==z||e[42]!==A||e[43]!==T||e[44]!==u||e[45]!==d||e[46]!==j||e[47]!==y||e[48]!==g?(X={selectedModel:d,setSelectedModel:f,selectedEffort:u,setSelectedEffort:m,fastModeEnabled:p,ultracodeEnabled:g,effectiveEffort:N,fastModeAvailable:S,fastModeActive:_,setFastModeEnabled:h,ultracodeAvailable:y,ultracodeActive:j,setUltracodeEnabled:x,imageInputAvailable:A,modelFallbackNotice:T,dismissModelFallbackNotice:U,handleModelRejected:z},e[37]=N,e[38]=_,e[39]=S,e[40]=p,e[41]=z,e[42]=A,e[43]=T,e[44]=u,e[45]=d,e[46]=j,e[47]=y,e[48]=g,e[49]=X):X=e[49],X}const uM=["model","effort","fastMode","ultracode","permissionMode"];function fM({sessionKey:n,values:e,onHydrate:t}){const s=v.useRef(null),o=v.useRef(null),i=v.useRef(t);i.current=t;const a=v.useRef(e);a.current=e,v.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return j2(n).then(d=>{if(c||d===null)return;if(uM.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 gc(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);v.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,gc(n,a.current))},[l,n])}function mM(n){const[e,t]=v.useState(new Map),[s,o]=v.useState(null),[i,a]=v.useState(!0),l=v.useRef(new Map),c=v.useRef(null);v.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:i}),x!==b){const w=x?l.current.get(x):null;w?(o(w.activeId),a(w.collapsed)):(o(null),a(!0))}c.current=x},[n]);const d=v.useCallback(()=>a(x=>!x),[]),f=v.useCallback(x=>{t(b=>{const w=new Map(b);return w.set(x.id,x),w}),o(x.id),a(!1)},[]),u=v.useCallback(x=>{t(b=>{const w=new Map(b);return w.delete(x),o(y=>{if(y!==x)return y;const j=[...w.keys()];return j.length>0?j[j.length-1]:null}),w})},[]),m=v.useCallback(x=>{o(x),a(!1)},[]),p=v.useCallback((x,b)=>{t(w=>{const y=w.get(x);if(!y||y.status===b)return w;const j=new Map(w);return j.set(x,{...y,status:b}),j})},[]),h=v.useCallback(x=>{t(b=>{let w=!1;const y=new Map(b),j=new Set(x.map(k=>k.id));for(const[k,N]of y)N.type==="task"&&!j.has(k)&&(y.delete(k),w=!0);for(const k of x){const N=y.get(k.id);N?(N.name!==k.title||N.outputPath!==k.outputPath)&&(y.set(k.id,{...N,name:k.title,outputPath:k.outputPath}),w=!0):(y.set(k.id,{id:k.id,name:k.title,type:"task",status:"running",outputPath:k.outputPath}),w=!0)}return w?y:b})},[]),g=v.useCallback((x,b,w)=>{b&&w&&t(y=>{if(y.has(x))return y;const j=new Map(y);return j.set(x,{id:x,name:w,type:"task",status:"running",outputPath:b}),j}),o(y=>y===x?(a(!0),y):(a(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:i,toggleCollapse:d,addProcess:f,removeProcess:u,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function pM(n){const e=B.c(50),{sessionId:t,sessionCwd:s,pendingPath:o,sessionDirName:i,pendingDirName:a,dashboardProject:l,supportsFileWorkspace:c}=n,d=mM(t),[f,u]=v.useState(null),[m,p]=v.useState(0),h=v.useRef(0),g=s??o??void 0,x=!!(g&&(f==null?void 0:f.kind)==="preview"&&f.cwd===g),b=(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($s()){console.warn("[open-terminal] unavailable for remote devices");return}const K=s??o??void 0,q=i??a??l??void 0;if(!K&&!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:K,dirName:q})}).then(yM).catch(vM)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=j):j=e[8];const k=j;let N;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(N=K=>{if($s()){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(bM)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=N):N=e[14];const C=N;let S;e[15]!==o||e[16]!==d||e[17]!==s?(S=()=>{const q=[...d.processes.values()].filter(xM).at(-1);if(!q){(s??o)&&p(gM);return}d.activeProcessId===q.id&&!d.collapsed?d.toggleCollapse():d.setActive(q.id)},e[15]=o,e[16]=d,e[17]=s,e[18]=S):S=e[18];const _=S;let P;e[19]!==o||e[20]!==s?(P=()=>{(s??o)&&p(hM)},e[19]=o,e[20]=s,e[21]=P):P=e[21];const A=P;let T;e[22]!==g||e[23]!==x?(T=()=>{g&&v.startTransition(()=>{u(x?null:{kind:"preview",cwd:g})})},e[22]=g,e[23]=x,e[24]=T):T=e[24];const E=T;let M;e[25]!==g||e[26]!==b?(M=()=>{g&&v.startTransition(()=>{u(b?null:{kind:"project-files",root:g,anchorCwd:g,request:null})})},e[25]=g,e[26]=b,e[27]=M):M=e[27];const I=M;let R;e[28]!==g||e[29]!==c?(R=K=>{if(!c)return!1;const q=r5(K,g);if(!q)return!1;h.current=h.current+1;const Y=h.current;return v.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 $=R;let D,O;e[31]!==$?(O=()=>o5($),D=[$],e[31]=$,e[32]=D,e[33]=O):(D=e[32],O=e[33]),v.useEffect(O,D);let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{v.startTransition(()=>u(null))},e[34]=L):L=e[34];const F=L,z=b!==null,H=b==null?void 0:b.root,U=(b==null?void 0:b.request)??null;let W;return e[35]!==g||e[36]!==C||e[37]!==A||e[38]!==k||e[39]!==_||e[40]!==E||e[41]!==I||e[42]!==m||e[43]!==y||e[44]!==d||e[45]!==x||e[46]!==z||e[47]!==H||e[48]!==U?(W={processPanel:d,currentCwd:g,showPreview:x,showProjectFiles:z,projectFilesRoot:H,projectFilesRequest:U,launchTerminalRequest:m,pendingProject:y,handleOpenTerminal:k,handleMcpAuth:C,handleToggleIntegratedTerminal:_,handleNewIntegratedTerminal:A,handleTogglePreview:E,handleToggleProjectFiles:I,closeRightWorkspace:F},e[35]=g,e[36]=C,e[37]=A,e[38]=k,e[39]=_,e[40]=E,e[41]=I,e[42]=m,e[43]=y,e[44]=d,e[45]=x,e[46]=z,e[47]=H,e[48]=U,e[49]=W):W=e[49],W}function hM(n){return n+1}function gM(n){return n+1}function xM(n){return n.type==="terminal"}function bM(n){return console.error("[mcp-auth] open-terminal failed:",n)}function vM(n){return console.error("[open-terminal] fetch failed:",n)}function yM(n){n.ok||n.json().then(jM).catch(wM)}function wM(){}function jM(n){return console.error("[open-terminal]",n.error)}function SM(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
138
|
-
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const kM={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function N2(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:St(n.dirName)}}function NM(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...kM},rawMessages:[],agentKind:St(n.dirName)}}function C2(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:ya(n)}}catch{return null}}async function CM(n,e,t=3,s=100,o=!0){if(o){const i=C2(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:ya(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function _M(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await CM(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:N2(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function Op(n,e,t,s,o){const i=C2(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??NM(n),c=N2(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),_M(n,e,t,a),n.sessionId}async function TM(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 EM({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:o,onModelRejected:i,model:a,effort:l,fastMode:c,ultracode:d,mcpConfig:f}){const[u,m]=v.useState(!1),[p,h]=v.useState(null),[g,x]=v.useState(!1),[b,w]=v.useState(""),y=v.useRef(null),j=v.useRef(null),k=v.useRef(null),N=v.useCallback((P,A)=>{j.current=P,k.current=A??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:P,cwd:A,isMobile:t})},[e,t]),C=v.useCallback(async(P,A)=>{var $;const T=j.current;if(!T)return null;const E=St(T),M=k.current;($=y.current)==null||$.abort();const I=new AbortController;y.current=I,m(!0),h(null),o==null||o(P);const R=Date.now();try{const D=SM(P),O=Zt(E),{capabilities:L}=O,F={dirName:T,cwd:O.dirName.lossy?M??void 0:void 0,message:P,images:A,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:L.ultracode&&d?!0:void 0,name:L.namedSessions&&D||void 0,worktreeName:L.worktrees&&g?b||Oy(P):void 0,mcpConfig:L.mcp&&f||void 0},{res:z,errorMessage:H}=await o2(K=>ye("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:K}),signal:I.signal}),{model:a,agentKind:E,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(E==="codex"){const K=await TM(T,P,R,I);if(K){j.current=null,k.current=null;const q=await Op(K,I,e,t,s);return D&&q&&fc(q,D),q}}return h(H||`Failed to create session (${z.status})`),null}const U=await z.json();j.current=null,k.current=null;const W=await Op(U,I,e,t,s);return D&&W&&fc(W,D),W}catch(D){return I.signal.aborted||h(D instanceof Error?D.message:"Failed to create session"),null}finally{I.signal.aborted||m(!1)}},[n,a,l,c,d,f,g,b,e,t,s,o,i]),S=v.useCallback(()=>h(null),[]),_=v.useCallback(()=>{var P;(P=y.current)==null||P.abort(),y.current=null,j.current=null,k.current=null,m(!1),h(null)},[]);return{creatingSession:u,createError:p,clearCreateError:S,handleNewSession:N,createAndSend:C,cancelCreation:_,pendingDirNameRef:j,worktreeEnabled:g,setWorktreeEnabled:x,worktreeName:b,setWorktreeName:w}}function PM(n){const e=B.c(40),{permissionsConfig:t,dispatch:s,isMobile:o,defaultAgentKind:i,pendingDirName:a,pendingCwd:l,model:c,effort:d,fastMode:f,ultracode:u,mcpConfig:m,onModelRejected:p}=n,h=v.useRef(null),g=v.useRef(null),[x,b]=v.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=U=>{var W;(W=h.current)==null||W.call(h,U),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},300),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.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:b,onModelRejected: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=EM(y),k=j.handleNewSession,[N,C]=v.useState(null);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=new Map,e[11]=S):S=e[11];const _=v.useRef(S);let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=async U=>{if(qr===null)return null;const W=_.current;if(W.has(U))return W.get(U)??null;try{const K=await ye("/api/projects");if(!K.ok)return W.set(U,null),null;const q=await K.json(),Y=Sy(q,U,qr);return W.set(U,Y),Y}catch{return W.set(U,null),null}},e[12]=P):P=e[12];const A=P;let T;e[13]!==k?(T=async(U,W)=>{const K=W??null;if(!K){C(null),k(U);return}const q=St(U)===qr?qr:null,Y=q?qa(q,K):await A(K);C(Y?{discoveredDirName:Y,cwd:K}:null),k(q&&Y?Y:U,K)},e[13]=k,e[14]=T):T=e[14];const E=T;let M;e[15]!==i||e[16]!==E?(M=U=>{const W=qa(i,U);E(W,U)},e[15]=i,e[16]=E,e[17]=M):M=e[17];const I=M;let R;e[18]!==k||e[19]!==N?(R=U=>{if(!N)return;const W=qa(U,N.cwd,N.discoveredDirName);k(W,N.cwd)},e[18]=k,e[19]=N,e[20]=R):R=e[20];const $=R;let D;e:{if(!j.creatingSession||!a){D=null;break e}const U=x??void 0;let W;e[21]!==l||e[22]!==a||e[23]!==U?(W={dirName:a,cwd:l,firstMessage:U},e[21]=l,e[22]=a,e[23]=U,e[24]=W):W=e[24],D=W}const O=D;let L,F;e[25]!==a?(F=()=>{a||(b(null),C(null))},L=[a],e[25]=a,e[26]=L,e[27]=F):(L=e[26],F=e[27]),v.useEffect(F,L);const z=N?$: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]!==O||e[38]!==z?(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:O,pendingAgentKindChange:z,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]=O,e[38]=z,e[39]=H):H=e[39],H}const Rl=new Set;function AM(n,e){const t=mn(),s=ps();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function RM(n,e,t){const s=AM(n,e);if(!Rl.has(s)&&!hn.get(n,e)){Rl.add(s);try{await Ds(n,e,t,"session prefetch")}catch{}finally{Rl.delete(s)}}}function MM({onAuthenticated:n}){const[e,t]=v.useState(null),[s,o]=v.useState(""),[i,a]=v.useState(""),[l,c]=v.useState(!1),[d,f]=v.useState(null),[u,m]=v.useState(!1),p=e==="team";v.useEffect(()=>{let x=!1;return Mh().then(b=>{x||t(b)}),()=>{x=!0}},[]);const h=v.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),f(null);try{const b=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 b.json();b.ok&&w.valid?(sa(),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(Xt,{children:[r.jsxs(nn,{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(ry,{className:"size-4"})}),r.jsx(sn,{children:"Sign in to Cogpit"}),r.jsx(on,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Jt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(Bt,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Jt,{className:"flex flex-col gap-4",children:[r.jsxs(jo,{children:[p&&r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"login-username",children:"Username"}),r.jsx(Ot,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"login-password",children:"Password"}),r.jsxs(Zn,{children:[r.jsx(es,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(wn,{align:"inline-end",children:r.jsx(_r,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(Gi,{}):r.jsx(yo,{})})})]})]})]}),d&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(vn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Sign in failed"}),r.jsx(_t,{children:d})]})]}),r.jsx(ko,{children:r.jsxs(J,{type:"submit",className:"w-full",disabled:g,children:[u&&r.jsx(Bt,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const Dp=16,bi="__cogpitBootstrapToken";function IM(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[bi]=="string"?t[bi]:"");return e&&window.history.replaceState({...t,[bi]:e},"",`${window.location.pathname}${window.location.search}`),s}function Lp(){const n={...window.history.state||{}};delete n[bi],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function $M({onAuthenticated:n,onBootstrapClosed:e}){const[t]=v.useState(IM),[s,o]=v.useState(""),[i,a]=v.useState(""),[l,c]=v.useState(""),[d,f]=v.useState(""),[u,m]=v.useState(!1),[p,h]=v.useState(null),[g,x]=v.useState(!1),b=d.length>0&&d!==l,w=!t||!s.trim()||l.length<Dp||d!==l,y=v.useCallback(async j=>{if(j.preventDefault(),!w){x(!0),h(null);try{const k=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()}:{}})}),N=await k.json();if(k.ok){Lp(),c(""),f(""),o(""),a(""),await e(),n();return}if(k.status===410){Lp(),await e();return}h(N.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!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(Xt,{children:[r.jsxs(nn,{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(iy,{className:"size-4"})}),r.jsx(sn,{children:"Create the first admin"}),r.jsx(on,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Jt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(Ct,{children:[r.jsx(jn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Setup link required"}),r.jsx(_t,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(jo,{children:[r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Ot,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(mo,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(gt,{children:[r.jsxs(xt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Ot,{id:"bootstrap-display-name",type:"text",value:i,onChange:j=>a(j.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(Zn,{children:[r.jsx(es,{id:"bootstrap-password",type:u?"text":"password",value:l,onChange:j=>c(j.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(wn,{align:"inline-end",children:r.jsx(_r,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":u?"Hide password":"Show password",children:u?r.jsx(Gi,{}):r.jsx(yo,{})})})]}),r.jsxs(mo,{children:["Use at least ",Dp," characters."]})]}),r.jsxs(gt,{"data-invalid":b,children:[r.jsx(xt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Ot,{id:"bootstrap-confirm-password",type:u?"text":"password",value:d,onChange:j=>f(j.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":b}),b&&r.jsx(us,{children:"Passwords do not match"})]})]}),p&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(vn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Could not create the account"}),r.jsx(_t,{children:p})]})]}),r.jsx(ko,{children:r.jsxs(J,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(Bt,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function OM(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=na(),n[0]=e):e=n[0];const t=e,[s,o]=v.useState(null),[i,a]=v.useState(!1),[l,c]=v.useState(!1),d=v.useRef(0);let f,u;n[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let T=!1;return Rh().then(E=>{T||o(E)}),()=>{T=!0}},u=[],n[1]=f,n[2]=u):(f=n[1],u=n[2]),v.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 T=!1;const E=d.current;return vw().then(M=>{!T&&d.current===E&&(a(M),c(!0))}),()=>{T=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),v.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let T=!1;const E=()=>{const M=d.current=d.current+1,I=()=>{T||d.current!==M||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){I();return}ef().then(R=>{T||d.current!==M||(o(R),R.edition==="team"&&I())})};return window.addEventListener("cogpit-auth-required",E),()=>{T=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],v.useEffect(g,b);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 ef())},n[11]=j):j=n[11];const k=j;let N;n[12]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{d.current=d.current+1,a(!1),c(!0),yw().finally(DM)},n[12]=N):N=n[12];const C=N,S=(s==null?void 0:s.edition)??null,_=l&&s!==null,P=(s==null?void 0:s.needsBootstrap)===!0;let A;return n[13]!==i||n[14]!==S||n[15]!==_||n[16]!==P?(A={isRemote:t,edition:S,authChecked:_,authenticated:i,needsBootstrap:P,handleAuthenticated:y,refreshServerState:k,logout:C},n[13]=i,n[14]=S,n[15]=_,n[16]=P,n[17]=A):A=n[17],A}function DM(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const LM=v.lazy(()=>Ke(()=>import("./index-DHjlP4ip.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),zM=v.lazy(()=>Ke(()=>import("./WorkflowsPanel-B1JVdvuy.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function FM(){var bu,vu,yu,wu,ju,Su,ku,Nu,Cu,_u,Tu,Eu,Pu,Au,Ru,Mu,Iu,$u,Ou,Du;const n=Dd(window.location.pathname),e=OR(),t=OM(),s=BR(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=Ca(),d=u2(),[f,u]=r2(),{procBySession:m}=Sx(),{parse:p,append:h}=S2(),g=v.useCallback(ke=>{u({type:"SET_OLDER_TURNS",turns:ke})},[u]),x=v.useCallback((ke,Ve)=>{RM(ke,Ve,p)},[p]),b=k2({dirName:((bu=f.sessionSource)==null?void 0:bu.dirName)??null,fileName:((vu=f.sessionSource)==null?void 0:vu.fileName)??null,sessionChangeKey:f.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=b,y=!!f.searchQuery&&b.hasMore,j=((yu=f.session)==null?void 0:yu.turns.length)??0;v.useEffect(()=>{y&&w()},[y,w,j]);const k=oM(f,u),N=v.useRef(null),C=v.useRef(null),[S,_]=v.useState(!1),[P,A]=v.useState(!1),T=v.useCallback(()=>u({type:"TOGGLE_EXPAND_ALL"}),[u]),E=v.useCallback(()=>_(!0),[]),M=v.useCallback(()=>{var ke;return(ke=C.current)==null?void 0:ke.focus()},[]),I=v.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!0}),[u]),R=v.useCallback(()=>u({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[u]),$=v.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!1}),[u]),D=v.useCallback(ke=>{v.startTransition(()=>{u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u]),O=f.pendingCwd??(f.pendingDirName?gn(f.pendingDirName):null),L=((wu=f.sessionSource)==null?void 0:wu.agentKind)??St(((ju=f.sessionSource)==null?void 0:ju.dirName)??f.pendingDirName??null),F=(Su=f.session)!=null&&Su.sessionId?m.get(f.session.sessionId):void 0,z=Ut(L),H=Od(L,F),U=z.worktrees,W=z.mcp,K=nM(i?((ku=f.session)==null?void 0:ku.cwd)??O??void 0:void 0,i&&z.slashCommands),q=v.useCallback(ke=>{if(!i)return;const Ve=K.suggestions.find(vt=>vt.name===ke);v.startTransition(()=>{u({type:"OPEN_CONFIG",filePath:Ve==null?void 0:Ve.filePath})})},[i,u,K.suggestions]),Y=v.useCallback(async(ke,Ve)=>{if(!i)return null;const vt=K.suggestions.find(cn=>cn.name===ke);if(!(vt!=null&&vt.filePath))return null;try{const cn=await ye("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:vt.filePath,args:Ve||""})});return cn.ok?(await cn.json()).content??null:null}catch{return null}},[i,K.suggestions]),{processPanel:V,currentCwd:Q,showPreview:Z,showProjectFiles:X,projectFilesRoot:ee,projectFilesRequest:oe,launchTerminalRequest:se,pendingProject:re,handleOpenTerminal:ie,handleMcpAuth:ae,handleToggleIntegratedTerminal:te,handleNewIntegratedTerminal:he,handleTogglePreview:me,handleToggleProjectFiles:le,closeRightWorkspace:xe}=pM({sessionId:(Nu=f.session)==null?void 0:Nu.sessionId,sessionCwd:(Cu=f.session)==null?void 0:Cu.cwd,pendingPath:O,sessionDirName:(_u=f.sessionSource)==null?void 0:_u.dirName,pendingDirName:f.pendingDirName,dashboardProject:f.dashboardProject,supportsFileWorkspace:!c&&a}),ge=QR(f.session??null),[ce,we]=v.useState(!1),pe=((Tu=f.sessionSource)==null?void 0:Tu.dirName)??f.pendingDirName??f.dashboardProject??null,ue=qR(o&&U&&k.showWorktrees?pe:null),je=v.useMemo(()=>{const ke=f.session;return ke?ke.turns.some(Ve=>Ri(Ve.toolCalls,ke.cwd)||Ve.subAgentActivity.some(vt=>Ri(vt.toolCalls,ke.cwd))):!1},[f.session]),Ne=v.useMemo(()=>{if(!f.session||!z.workflows)return 0;let ke=0;for(const Ve of f.session.turns)for(const vt of Ve.toolCalls)vt.name==="Workflow"&&ke++;return ke},[f.session,z.workflows]),Re=Ne>0,Te=v.useMemo(()=>{const ke=f.sessionSource;return!ke||!z.workflows||vs(ke.fileName)?{dirName:null,sessionId:null}:{dirName:ke.dirName,sessionId:Dl(ke.fileName)}},[f.sessionSource,z.workflows]),Pe=eR(Te.dirName,Te.sessionId,Re),Oe=Re||Pe.workflows.length>0,Fe=Pe.workflows.length||Ne,ze=k.setShowWorkflows,Be=v.useCallback(()=>ze(!0),[ze]),[_e,He]=v.useState(!1),Ie=v.useCallback(ke=>{He(ke.asPercentage===0)},[]),[Ce,de]=v.useState(!1),[Ee,Ae]=v.useState(!1),Le=k.setShowFileChanges;v.useEffect(()=>{if(!a)return;const ke=()=>{c?de(!0):v.startTransition(()=>{Le(!0),He(!1)})};return window.addEventListener(ur,ke),()=>window.removeEventListener(ur,ke)},[a,Le,c]);const ne=v.useMemo(()=>f.session?B1(f.session):null,[f.session]),fe=v.useRef(null),{isLive:Se,sseState:$e,isCompacting:Ue,streamingOverlay:We,turnError:Xe,agentProgress:Je,promptSuggestion:De}=n2(f.sessionSource,ke=>{v.startTransition(()=>{u({type:"UPDATE_SESSION",session:ke})})},p,h,()=>{var ke;return(ke=fe.current)==null?void 0:ke.call(fe)},f.session),qe=v.useMemo(()=>We.reduce((ke,Ve)=>ke+Ve.blocks.reduce((vt,cn)=>vt+cn.text.length,0),0),[We]),ot=tM(((Eu=f.session)==null?void 0:Eu.cwd)??null),lt=yR(),bt=lt.setMode,$t=SR(H?null:((Pu=f.session)==null?void 0:Pu.sessionId)??null),Vt=H?null:$t.plan??ne,{selectedModel:Wt,setSelectedModel:ts,selectedEffort:Ge,setSelectedEffort:et,fastModeEnabled:mt,ultracodeEnabled:zt,effectiveEffort:en,fastModeAvailable:Us,fastModeActive:$r,setFastModeEnabled:$a,ultracodeAvailable:E2,ultracodeActive:Or,setUltracodeEnabled:Oa,imageInputAvailable:Ld,modelFallbackNotice:P2,dismissModelFallbackNotice:A2,handleModelRejected:zd}=dM({agentKind:L,session:f.session,sessionSource:f.sessionSource,pendingDirName:f.pendingDirName,isLive:Se}),Fd=GR((Au=f.session)==null?void 0:Au.sessionId,(Ru=f.sessionSource)==null?void 0:Ru.fileName);fM({sessionKey:Fd,values:{model:Wt,effort:Ge,fastMode:mt,ultracode:zt,permissionMode:lt.config.mode},onHydrate:v.useCallback(ke=>{ke.model!==void 0&&ts(ke.model),ke.effort!==void 0&&et(ke.effort),ke.fastMode!==void 0&&$a(ke.fastMode),ke.ultracode!==void 0&&Oa(ke.ultracode),ke.permissionMode&&bt(ke.permissionMode)},[ts,et,$a,Oa,bt])});const tn=JR(W&&i?Q:void 0,W&&i?pe??void 0:void 0,W&&i?Fd??void 0:void 0,i),{showWorktrees:Bd,setShowWorktrees:Ud,showWorkflows:Wd}=k;v.useEffect(()=>{!U&&Bd&&Ud(!1)},[U,Bd,Ud]),v.useEffect(()=>{Wd&&!Oe&&ze(!1)},[Wd,Oe,ze]);const{creatingSession:Hd,createError:Kd,clearCreateError:R2,createAndSend:M2,cancelCreation:qd,worktreeEnabled:I2,setWorktreeEnabled:$2,sessionFinalizedRef:Dr,liveSessionsRefreshRef:Vd,pendingSessionInfo:Gd,pendingAgentKindChange:O2,handleStartNewSession:Yd,handleStartNewFolder:D2}=PM({permissionsConfig:lt.config,dispatch:u,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:f.pendingDirName,pendingCwd:f.pendingCwd,onModelRejected:zd,model:Wt,effort:en,fastMode:$r,ultracode:Or,mcpConfig:W&&i?tn.mcpConfigJson:null}),pt=sR({sessionSource:f.sessionSource,parsedSessionId:((Mu=f.session)==null?void 0:Mu.sessionId)??null,cwd:(Iu=f.session)==null?void 0:Iu.cwd,permissions:lt.config,onPermissionsApplied:lt.markApplied,model:Wt,effort:en,fastMode:$r,ultracode:Or,mcpConfig:W&&i?tn.mcpConfigJson:null,onModelRejected:zd,readOnly:H,onCreateSession:f.pendingDirName?M2:void 0}),Mt=QA(z.agentTeams?(($u=f.sessionSource)==null?void 0:$u.fileName)??null:null,((Ou=f.sessionSource)==null?void 0:Ou.dirName)??null);v.useEffect(()=>{Mt!=null&&Mt.currentMemberName?u({type:"SET_CURRENT_MEMBER_NAME",name:Mt.currentMemberName}):Mt||u({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Mt==null?void 0:Mt.currentMemberName,Mt,u]),v.useEffect(()=>{c&&u({type:"GUARD_MOBILE_TAB",hasSession:!!f.session||!!f.pendingDirName})},[f.session,f.pendingDirName,f.mobileTab,c,u]);const Sn=i2({session:f.session,isLive:Se,pendingMessages:pt.pendingMessages,consumePending:pt.consumePending,sessionChangeKey:f.sessionChangeKey,partialContentLen:qe}),Xd=Sn.chatScrollRef,Jd=Sn.resetTurnCount,Qd=Sn.scrollToBottomInstant,L2=v.useCallback(ke=>{we(ke),requestAnimationFrame(()=>{const Ve=Xd.current;Ve&&Ve.scrollTo({top:Ve.scrollTop+(ke?64:-64),behavior:"smooth"})})},[Xd]);v.useLayoutEffect(()=>{const ke=Ve=>{Jd(0),Qd()};return Dr.current=ke,()=>{Dr.current===ke&&(Dr.current=null)}},[Jd,Qd,Dr]);const z2=v.useCallback(()=>{pt.disconnect(),qd()},[pt.disconnect,qd]),kn=iR({dispatch:u,isMobile:c,mobileTab:f.mobileTab,teamContext:Mt,scrollToBottomInstant:Sn.scrollToBottomInstant,resetTurnCount:Sn.resetTurnCount,workerParse:p,onBeforeSwitch:z2}),F2=v.useCallback(ke=>{v.startTransition(()=>{u({type:"GO_HOME",isMobile:c}),u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u,c]),{previewLoadError:B2}=dR({state:f,dispatch:u,isMobile:c,resetTurnCount:Sn.resetTurnCount,scrollToBottomInstant:Sn.scrollToBottomInstant,workerParse:p}),Lr=bR(),Zd=Lr.push;v.useEffect(()=>{f.sessionSource&&Zd(f.sessionSource.dirName,f.sessionSource.fileName)},[f.sessionSource,Zd]);const ft=lM({state:{session:f.session,sessionSource:f.sessionSource},dispatch:u,isMobile:c,handleJumpToTurn:kn.handleJumpToTurn,markPermissionsApplied:lt.markApplied,hasPermsPendingChanges:lt.hasPendingChanges,permissionsConfig:lt.config,selectedModel:Wt,selectedEffort:en,fastMode:$r,ultracode:Or,mcpConfig:W&&i?tn.mcpConfigJson:null,scrollRequestScrollToTop:Sn.requestScrollToTop,handleDashboardSelect:kn.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:eu,handleApplySettings:tu}=ft,nu=W&&i&&tn.mcpConfigJson!==null,su=v.useRef(!1);v.useEffect(()=>{var vt;const ke=tn.loaded&&!su.current;su.current=tn.loaded;const Ve=(vt=f.session)==null?void 0:vt.sessionId;ke&&Ve&&nu&&eu&&tu()},[tn.loaded,nu,eu,tu,(Du=f.session)==null?void 0:Du.sessionId]),v.useLayoutEffect(()=>(fe.current=ft.reloadSession,()=>{fe.current===ft.reloadSession&&(fe.current=null)}),[ft.reloadSession]);const On=y2(f.session,f.sessionSource,ft.reloadSession,a),zr=On.requestBranchSwitch,Fr=ft.setBranchModalTurn,U2=v.useCallback((ke,Ve)=>{zr(ke,Ve),Fr(null)},[zr,Fr]),W2=v.useCallback(ke=>{zr(ke),Fr(null)},[zr,Fr]);mR({isMobile:c,searchInputRef:N,chatInputRef:C,dispatch:u,onToggleSidebar:k.handleToggleSidebar,onToggleRightSidebar:k.handleToggleStats,onToggleMissionControl:k.handleToggleMission,onOpenCommandPalette:E,onOpenProjectSwitcher:k.handleOpenProjectSwitcher,onOpenThemeSelector:k.handleToggleThemeSelector,onOpenTerminal:ie,onToggleIntegratedTerminal:te,onTogglePreview:me,onToggleProjectFiles:le,onHistoryBack:Lr.goBack,onHistoryForward:Lr.goForward,onNavigateToSession:kn.handleDashboardSelect,onCommitNavigation:Lr.commitNavigation});const{killing:H2,handleKillAll:K2}=VR(),ns=f.sessionSource?vs(f.sessionSource.fileName):null,q2=ns!==null&&!!(Mt!=null&&Mt.currentMemberName),Da=ns!==null&&!q2,Br=kn.handleDashboardSelect,ou=v.useCallback(()=>{!f.sessionSource||!ns||Br(f.sessionSource.dirName,ns.parentFileName)},[f.sessionSource,ns,Br]);v.useEffect(()=>{const ke=Ve=>{const{agentId:vt}=Ve.detail??{};if(!vt||!f.sessionSource||!z.subagentTranscripts)return;const cn=ns?ns.parentSessionId:Dl(f.sessionSource.fileName);Br(f.sessionSource.dirName,`${cn}/subagents/agent-${vt}.jsonl`)};return window.addEventListener(Mi,ke),()=>window.removeEventListener(Mi,ke)},[f.sessionSource,ns,Br,z.subagentTranscripts]);const[V2,ru]=v.useState(null),G2=ft.branchModalTurn!==null,Ws=ft.branchModalTurn??V2;v.useEffect(()=>{ft.branchModalTurn!==null&&ru(ft.branchModalTurn)},[ft.branchModalTurn]);const iu=Ws!==null?On.branchesAtTurn(Ws):[],Y2=Da?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(co,{"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,X2=H?r.jsxs("div",{role:"status",className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(co,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Ow(L)})]}):null,La=Y2||X2,J2=kn.loadError||Kd||null;let za;kn.loadError?za=kn.clearLoadError:Kd&&(za=R2);const Q2=!!(f.session&&f.sessionSource&&$e==="disconnected"),Fa=v.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]),Ba=v.useMemo(()=>({session:f.session,sessionSource:f.sessionSource,isLive:Se,sseState:$e,isCompacting:Ue,turnError:Xe,promptSuggestion:De,undoRedo:On,pendingInteraction:Vt,permissionRequests:$t.requests,permissionResponding:$t.responding,respondPermission:$t.respond,respondAllPermissions:$t.respondAll,isSubAgentView:Da,slashSuggestions:K.suggestions,slashSuggestionsLoading:K.loading,actions:{handleStopSession:ft.handleStopSession,handleEditConfig:i?k.handleEditConfig:void 0,handleEditCommand:i?q:void 0,handleExpandCommand:i?Y:void 0,handleOpenBranches:ft.handleOpenBranches,handleBranchFromHere:ft.handleBranchFromHere,handleToggleExpandAll:T,handleLoadSession:ft.handleLoadSessionScrollAware}}),[f.session,f.sessionSource,Se,$e,Ue,Xe,De,On,Vt,Da,$t.requests,$t.responding,$t.respond,$t.respondAll,K.suggestions,K.loading,ft.handleStopSession,i,k.handleEditConfig,q,Y,ft.handleOpenBranches,ft.handleBranchFromHere,T,ft.handleLoadSessionScrollAware]),Ua=v.useMemo(()=>({chat:{status:pt.status,error:pt.error,pendingMessages:pt.pendingMessages,isConnected:pt.isConnected,sendMessage:pt.sendMessage,interrupt:pt.interrupt,stopAgent:pt.stopAgent,consumePending:pt.consumePending},scroll:Sn}),[pt.status,pt.error,pt.pendingMessages,pt.isConnected,pt.sendMessage,pt.interrupt,pt.stopAgent,pt.consumePending,Sn]),No=!!f.pendingDirName&&!f.session;if(v.useEffect(()=>{if(!No||c)return;const ke=requestAnimationFrame(()=>{var Ve;return(Ve=C.current)==null?void 0:Ve.focus()});return()=>cancelAnimationFrame(ke)},[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(rt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx($M,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(MM,{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(rt,{"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(rt,{"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(Hn,{children:[r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(jn,{className:"text-destructive"})}),r.jsx(qn,{children:"Failed to connect"}),r.jsx(Vn,{children:e.configError})]}),r.jsx(Ch,{children:r.jsxs(J,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Qt,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(t5,{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 Wa=r.jsx(hw,{activeError:J2,clearActiveError:za,modelFallbackNotice:P2,dismissModelFallbackNotice:A2,connectionLost:Q2,theme:d.activeTheme}),au=a?r.jsx(VS,{state:On.confirmState,isApplying:On.isApplying,applyError:On.applyError,onConfirm:On.confirmApply,onCancel:On.confirmCancel}):null,Z2=Ws!==null&&f.session?f.session.turns.slice(Ws):[],lu=a&&Ws!==null&&iu.length>0&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(LM,{open:G2,branches:iu,branchPointTurnIndex:Ws,currentTurns:Z2,onClose:ft.handleCloseBranchModal,onCloseComplete:()=>ru(null),onRedoToTurn:U2,onRedoEntireBranch:W2})}),cu=l&&r.jsx(OS,{processes:V.processes,activeProcessId:V.activeProcessId,collapsed:V.collapsed,onSetActive:V.setActive,onRemove:V.removeProcess,onToggleCollapse:V.toggleCollapse,onRequestTerminal:ut("terminal")?he:void 0,onAddTerminalContext:ke=>{var Lu,zu,Fu;const Ve=ke.trim();if(!Ve)return;const vt=Ve.includes("```")?"````":"```",cn=`${vt}terminal
|
|
138
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const kM={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function N2(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:St(n.dirName)}}function NM(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...kM},rawMessages:[],agentKind:St(n.dirName)}}function C2(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:ya(n)}}catch{return null}}async function CM(n,e,t=3,s=100,o=!0){if(o){const i=C2(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:ya(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function _M(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await CM(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:N2(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function Op(n,e,t,s,o){const i=C2(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??NM(n),c=N2(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),_M(n,e,t,a),n.sessionId}async function TM(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 EM({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:o,onModelRejected:i,model:a,effort:l,fastMode:c,ultracode:d,mcpConfig:f}){const[u,m]=v.useState(!1),[p,h]=v.useState(null),[g,x]=v.useState(!1),[b,w]=v.useState(""),y=v.useRef(null),j=v.useRef(null),k=v.useRef(null),N=v.useCallback((P,A)=>{j.current=P,k.current=A??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:P,cwd:A,isMobile:t})},[e,t]),C=v.useCallback(async(P,A)=>{var $;const T=j.current;if(!T)return null;const E=St(T),M=k.current;($=y.current)==null||$.abort();const I=new AbortController;y.current=I,m(!0),h(null),o==null||o(P);const R=Date.now();try{const D=SM(P),O=Zt(E),{capabilities:L}=O,F={dirName:T,cwd:O.dirName.lossy?M??void 0:void 0,message:P,images:A,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:L.ultracode&&d?!0:void 0,name:L.namedSessions&&D||void 0,worktreeName:L.worktrees&&g?b||Oy(P):void 0,mcpConfig:L.mcp&&f||void 0},{res:z,errorMessage:H}=await o2(K=>ye("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:K}),signal:I.signal}),{model:a,agentKind:E,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(E==="codex"){const K=await TM(T,P,R,I);if(K){j.current=null,k.current=null;const q=await Op(K,I,e,t,s);return D&&q&&fc(q,D),q}}return h(H||`Failed to create session (${z.status})`),null}const U=await z.json();j.current=null,k.current=null;const W=await Op(U,I,e,t,s);return D&&W&&fc(W,D),W}catch(D){return I.signal.aborted||h(D instanceof Error?D.message:"Failed to create session"),null}finally{I.signal.aborted||m(!1)}},[n,a,l,c,d,f,g,b,e,t,s,o,i]),S=v.useCallback(()=>h(null),[]),_=v.useCallback(()=>{var P;(P=y.current)==null||P.abort(),y.current=null,j.current=null,k.current=null,m(!1),h(null)},[]);return{creatingSession:u,createError:p,clearCreateError:S,handleNewSession:N,createAndSend:C,cancelCreation:_,pendingDirNameRef:j,worktreeEnabled:g,setWorktreeEnabled:x,worktreeName:b,setWorktreeName:w}}function PM(n){const e=B.c(40),{permissionsConfig:t,dispatch:s,isMobile:o,defaultAgentKind:i,pendingDirName:a,pendingCwd:l,model:c,effort:d,fastMode:f,ultracode:u,mcpConfig:m,onModelRejected:p}=n,h=v.useRef(null),g=v.useRef(null),[x,b]=v.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=U=>{var W;(W=h.current)==null||W.call(h,U),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},300),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.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:b,onModelRejected: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=EM(y),k=j.handleNewSession,[N,C]=v.useState(null);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=new Map,e[11]=S):S=e[11];const _=v.useRef(S);let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=async U=>{if(qr===null)return null;const W=_.current;if(W.has(U))return W.get(U)??null;try{const K=await ye("/api/projects");if(!K.ok)return W.set(U,null),null;const q=await K.json(),Y=Sy(q,U,qr);return W.set(U,Y),Y}catch{return W.set(U,null),null}},e[12]=P):P=e[12];const A=P;let T;e[13]!==k?(T=async(U,W)=>{const K=W??null;if(!K){C(null),k(U);return}const q=St(U)===qr?qr:null,Y=q?qa(q,K):await A(K);C(Y?{discoveredDirName:Y,cwd:K}:null),k(q&&Y?Y:U,K)},e[13]=k,e[14]=T):T=e[14];const E=T;let M;e[15]!==i||e[16]!==E?(M=U=>{const W=qa(i,U);E(W,U)},e[15]=i,e[16]=E,e[17]=M):M=e[17];const I=M;let R;e[18]!==k||e[19]!==N?(R=U=>{if(!N)return;const W=qa(U,N.cwd,N.discoveredDirName);k(W,N.cwd)},e[18]=k,e[19]=N,e[20]=R):R=e[20];const $=R;let D;e:{if(!j.creatingSession||!a){D=null;break e}const U=x??void 0;let W;e[21]!==l||e[22]!==a||e[23]!==U?(W={dirName:a,cwd:l,firstMessage:U},e[21]=l,e[22]=a,e[23]=U,e[24]=W):W=e[24],D=W}const O=D;let L,F;e[25]!==a?(F=()=>{a||(b(null),C(null))},L=[a],e[25]=a,e[26]=L,e[27]=F):(L=e[26],F=e[27]),v.useEffect(F,L);const z=N?$: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]!==O||e[38]!==z?(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:O,pendingAgentKindChange:z,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]=O,e[38]=z,e[39]=H):H=e[39],H}const Rl=new Set;function AM(n,e){const t=mn(),s=ps();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function RM(n,e,t){const s=AM(n,e);if(!Rl.has(s)&&!hn.get(n,e)){Rl.add(s);try{await Ds(n,e,t,"session prefetch")}catch{}finally{Rl.delete(s)}}}function MM({onAuthenticated:n}){const[e,t]=v.useState(null),[s,o]=v.useState(""),[i,a]=v.useState(""),[l,c]=v.useState(!1),[d,f]=v.useState(null),[u,m]=v.useState(!1),p=e==="team";v.useEffect(()=>{let x=!1;return Mh().then(b=>{x||t(b)}),()=>{x=!0}},[]);const h=v.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),f(null);try{const b=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 b.json();b.ok&&w.valid?(sa(),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(Xt,{children:[r.jsxs(nn,{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(ry,{className:"size-4"})}),r.jsx(sn,{children:"Sign in to Cogpit"}),r.jsx(on,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Jt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(Bt,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Jt,{className:"flex flex-col gap-4",children:[r.jsxs(jo,{children:[p&&r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"login-username",children:"Username"}),r.jsx(Ot,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"login-password",children:"Password"}),r.jsxs(Zn,{children:[r.jsx(es,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(wn,{align:"inline-end",children:r.jsx(_r,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(Gi,{}):r.jsx(yo,{})})})]})]})]}),d&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(vn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Sign in failed"}),r.jsx(_t,{children:d})]})]}),r.jsx(ko,{children:r.jsxs(J,{type:"submit",className:"w-full",disabled:g,children:[u&&r.jsx(Bt,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const Dp=16,bi="__cogpitBootstrapToken";function IM(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[bi]=="string"?t[bi]:"");return e&&window.history.replaceState({...t,[bi]:e},"",`${window.location.pathname}${window.location.search}`),s}function Lp(){const n={...window.history.state||{}};delete n[bi],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function $M({onAuthenticated:n,onBootstrapClosed:e}){const[t]=v.useState(IM),[s,o]=v.useState(""),[i,a]=v.useState(""),[l,c]=v.useState(""),[d,f]=v.useState(""),[u,m]=v.useState(!1),[p,h]=v.useState(null),[g,x]=v.useState(!1),b=d.length>0&&d!==l,w=!t||!s.trim()||l.length<Dp||d!==l,y=v.useCallback(async j=>{if(j.preventDefault(),!w){x(!0),h(null);try{const k=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()}:{}})}),N=await k.json();if(k.ok){Lp(),c(""),f(""),o(""),a(""),await e(),n();return}if(k.status===410){Lp(),await e();return}h(N.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!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(Xt,{children:[r.jsxs(nn,{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(iy,{className:"size-4"})}),r.jsx(sn,{children:"Create the first admin"}),r.jsx(on,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Jt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(Ct,{children:[r.jsx(jn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Setup link required"}),r.jsx(_t,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(jo,{children:[r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Ot,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(mo,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(gt,{children:[r.jsxs(xt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Ot,{id:"bootstrap-display-name",type:"text",value:i,onChange:j=>a(j.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(Zn,{children:[r.jsx(es,{id:"bootstrap-password",type:u?"text":"password",value:l,onChange:j=>c(j.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(wn,{align:"inline-end",children:r.jsx(_r,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":u?"Hide password":"Show password",children:u?r.jsx(Gi,{}):r.jsx(yo,{})})})]}),r.jsxs(mo,{children:["Use at least ",Dp," characters."]})]}),r.jsxs(gt,{"data-invalid":b,children:[r.jsx(xt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Ot,{id:"bootstrap-confirm-password",type:u?"text":"password",value:d,onChange:j=>f(j.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":b}),b&&r.jsx(us,{children:"Passwords do not match"})]})]}),p&&r.jsxs(Ct,{variant:"destructive",children:[r.jsx(vn,{"aria-hidden":"true"}),r.jsx(Dt,{children:"Could not create the account"}),r.jsx(_t,{children:p})]})]}),r.jsx(ko,{children:r.jsxs(J,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(Bt,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function OM(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=na(),n[0]=e):e=n[0];const t=e,[s,o]=v.useState(null),[i,a]=v.useState(!1),[l,c]=v.useState(!1),d=v.useRef(0);let f,u;n[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let T=!1;return Rh().then(E=>{T||o(E)}),()=>{T=!0}},u=[],n[1]=f,n[2]=u):(f=n[1],u=n[2]),v.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 T=!1;const E=d.current;return vw().then(M=>{!T&&d.current===E&&(a(M),c(!0))}),()=>{T=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),v.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let T=!1;const E=()=>{const M=d.current=d.current+1,I=()=>{T||d.current!==M||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){I();return}ef().then(R=>{T||d.current!==M||(o(R),R.edition==="team"&&I())})};return window.addEventListener("cogpit-auth-required",E),()=>{T=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],v.useEffect(g,b);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 ef())},n[11]=j):j=n[11];const k=j;let N;n[12]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{d.current=d.current+1,a(!1),c(!0),yw().finally(DM)},n[12]=N):N=n[12];const C=N,S=(s==null?void 0:s.edition)??null,_=l&&s!==null,P=(s==null?void 0:s.needsBootstrap)===!0;let A;return n[13]!==i||n[14]!==S||n[15]!==_||n[16]!==P?(A={isRemote:t,edition:S,authChecked:_,authenticated:i,needsBootstrap:P,handleAuthenticated:y,refreshServerState:k,logout:C},n[13]=i,n[14]=S,n[15]=_,n[16]=P,n[17]=A):A=n[17],A}function DM(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const LM=v.lazy(()=>Ke(()=>import("./index-EmT8Vg0x.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),zM=v.lazy(()=>Ke(()=>import("./WorkflowsPanel-CiZjrfSd.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function FM(){var bu,vu,yu,wu,ju,Su,ku,Nu,Cu,_u,Tu,Eu,Pu,Au,Ru,Mu,Iu,$u,Ou,Du;const n=Dd(window.location.pathname),e=OR(),t=OM(),s=BR(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=Ca(),d=u2(),[f,u]=r2(),{procBySession:m}=Sx(),{parse:p,append:h}=S2(),g=v.useCallback(ke=>{u({type:"SET_OLDER_TURNS",turns:ke})},[u]),x=v.useCallback((ke,Ve)=>{RM(ke,Ve,p)},[p]),b=k2({dirName:((bu=f.sessionSource)==null?void 0:bu.dirName)??null,fileName:((vu=f.sessionSource)==null?void 0:vu.fileName)??null,sessionChangeKey:f.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=b,y=!!f.searchQuery&&b.hasMore,j=((yu=f.session)==null?void 0:yu.turns.length)??0;v.useEffect(()=>{y&&w()},[y,w,j]);const k=oM(f,u),N=v.useRef(null),C=v.useRef(null),[S,_]=v.useState(!1),[P,A]=v.useState(!1),T=v.useCallback(()=>u({type:"TOGGLE_EXPAND_ALL"}),[u]),E=v.useCallback(()=>_(!0),[]),M=v.useCallback(()=>{var ke;return(ke=C.current)==null?void 0:ke.focus()},[]),I=v.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!0}),[u]),R=v.useCallback(()=>u({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[u]),$=v.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!1}),[u]),D=v.useCallback(ke=>{v.startTransition(()=>{u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u]),O=f.pendingCwd??(f.pendingDirName?gn(f.pendingDirName):null),L=((wu=f.sessionSource)==null?void 0:wu.agentKind)??St(((ju=f.sessionSource)==null?void 0:ju.dirName)??f.pendingDirName??null),F=(Su=f.session)!=null&&Su.sessionId?m.get(f.session.sessionId):void 0,z=Ut(L),H=Od(L,F),U=z.worktrees,W=z.mcp,K=nM(i?((ku=f.session)==null?void 0:ku.cwd)??O??void 0:void 0,i&&z.slashCommands),q=v.useCallback(ke=>{if(!i)return;const Ve=K.suggestions.find(vt=>vt.name===ke);v.startTransition(()=>{u({type:"OPEN_CONFIG",filePath:Ve==null?void 0:Ve.filePath})})},[i,u,K.suggestions]),Y=v.useCallback(async(ke,Ve)=>{if(!i)return null;const vt=K.suggestions.find(cn=>cn.name===ke);if(!(vt!=null&&vt.filePath))return null;try{const cn=await ye("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:vt.filePath,args:Ve||""})});return cn.ok?(await cn.json()).content??null:null}catch{return null}},[i,K.suggestions]),{processPanel:V,currentCwd:Q,showPreview:Z,showProjectFiles:X,projectFilesRoot:ee,projectFilesRequest:oe,launchTerminalRequest:se,pendingProject:re,handleOpenTerminal:ie,handleMcpAuth:ae,handleToggleIntegratedTerminal:te,handleNewIntegratedTerminal:he,handleTogglePreview:me,handleToggleProjectFiles:le,closeRightWorkspace:xe}=pM({sessionId:(Nu=f.session)==null?void 0:Nu.sessionId,sessionCwd:(Cu=f.session)==null?void 0:Cu.cwd,pendingPath:O,sessionDirName:(_u=f.sessionSource)==null?void 0:_u.dirName,pendingDirName:f.pendingDirName,dashboardProject:f.dashboardProject,supportsFileWorkspace:!c&&a}),ge=QR(f.session??null),[ce,we]=v.useState(!1),pe=((Tu=f.sessionSource)==null?void 0:Tu.dirName)??f.pendingDirName??f.dashboardProject??null,ue=qR(o&&U&&k.showWorktrees?pe:null),je=v.useMemo(()=>{const ke=f.session;return ke?ke.turns.some(Ve=>Ri(Ve.toolCalls,ke.cwd)||Ve.subAgentActivity.some(vt=>Ri(vt.toolCalls,ke.cwd))):!1},[f.session]),Ne=v.useMemo(()=>{if(!f.session||!z.workflows)return 0;let ke=0;for(const Ve of f.session.turns)for(const vt of Ve.toolCalls)vt.name==="Workflow"&&ke++;return ke},[f.session,z.workflows]),Re=Ne>0,Te=v.useMemo(()=>{const ke=f.sessionSource;return!ke||!z.workflows||vs(ke.fileName)?{dirName:null,sessionId:null}:{dirName:ke.dirName,sessionId:Dl(ke.fileName)}},[f.sessionSource,z.workflows]),Pe=eR(Te.dirName,Te.sessionId,Re),Oe=Re||Pe.workflows.length>0,Fe=Pe.workflows.length||Ne,ze=k.setShowWorkflows,Be=v.useCallback(()=>ze(!0),[ze]),[_e,He]=v.useState(!1),Ie=v.useCallback(ke=>{He(ke.asPercentage===0)},[]),[Ce,de]=v.useState(!1),[Ee,Ae]=v.useState(!1),Le=k.setShowFileChanges;v.useEffect(()=>{if(!a)return;const ke=()=>{c?de(!0):v.startTransition(()=>{Le(!0),He(!1)})};return window.addEventListener(ur,ke),()=>window.removeEventListener(ur,ke)},[a,Le,c]);const ne=v.useMemo(()=>f.session?B1(f.session):null,[f.session]),fe=v.useRef(null),{isLive:Se,sseState:$e,isCompacting:Ue,streamingOverlay:We,turnError:Xe,agentProgress:Je,promptSuggestion:De}=n2(f.sessionSource,ke=>{v.startTransition(()=>{u({type:"UPDATE_SESSION",session:ke})})},p,h,()=>{var ke;return(ke=fe.current)==null?void 0:ke.call(fe)},f.session),qe=v.useMemo(()=>We.reduce((ke,Ve)=>ke+Ve.blocks.reduce((vt,cn)=>vt+cn.text.length,0),0),[We]),ot=tM(((Eu=f.session)==null?void 0:Eu.cwd)??null),lt=yR(),bt=lt.setMode,$t=SR(H?null:((Pu=f.session)==null?void 0:Pu.sessionId)??null),Vt=H?null:$t.plan??ne,{selectedModel:Wt,setSelectedModel:ts,selectedEffort:Ge,setSelectedEffort:et,fastModeEnabled:mt,ultracodeEnabled:zt,effectiveEffort:en,fastModeAvailable:Us,fastModeActive:$r,setFastModeEnabled:$a,ultracodeAvailable:E2,ultracodeActive:Or,setUltracodeEnabled:Oa,imageInputAvailable:Ld,modelFallbackNotice:P2,dismissModelFallbackNotice:A2,handleModelRejected:zd}=dM({agentKind:L,session:f.session,sessionSource:f.sessionSource,pendingDirName:f.pendingDirName,isLive:Se}),Fd=GR((Au=f.session)==null?void 0:Au.sessionId,(Ru=f.sessionSource)==null?void 0:Ru.fileName);fM({sessionKey:Fd,values:{model:Wt,effort:Ge,fastMode:mt,ultracode:zt,permissionMode:lt.config.mode},onHydrate:v.useCallback(ke=>{ke.model!==void 0&&ts(ke.model),ke.effort!==void 0&&et(ke.effort),ke.fastMode!==void 0&&$a(ke.fastMode),ke.ultracode!==void 0&&Oa(ke.ultracode),ke.permissionMode&&bt(ke.permissionMode)},[ts,et,$a,Oa,bt])});const tn=JR(W&&i?Q:void 0,W&&i?pe??void 0:void 0,W&&i?Fd??void 0:void 0,i),{showWorktrees:Bd,setShowWorktrees:Ud,showWorkflows:Wd}=k;v.useEffect(()=>{!U&&Bd&&Ud(!1)},[U,Bd,Ud]),v.useEffect(()=>{Wd&&!Oe&&ze(!1)},[Wd,Oe,ze]);const{creatingSession:Hd,createError:Kd,clearCreateError:R2,createAndSend:M2,cancelCreation:qd,worktreeEnabled:I2,setWorktreeEnabled:$2,sessionFinalizedRef:Dr,liveSessionsRefreshRef:Vd,pendingSessionInfo:Gd,pendingAgentKindChange:O2,handleStartNewSession:Yd,handleStartNewFolder:D2}=PM({permissionsConfig:lt.config,dispatch:u,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:f.pendingDirName,pendingCwd:f.pendingCwd,onModelRejected:zd,model:Wt,effort:en,fastMode:$r,ultracode:Or,mcpConfig:W&&i?tn.mcpConfigJson:null}),pt=sR({sessionSource:f.sessionSource,parsedSessionId:((Mu=f.session)==null?void 0:Mu.sessionId)??null,cwd:(Iu=f.session)==null?void 0:Iu.cwd,permissions:lt.config,onPermissionsApplied:lt.markApplied,model:Wt,effort:en,fastMode:$r,ultracode:Or,mcpConfig:W&&i?tn.mcpConfigJson:null,onModelRejected:zd,readOnly:H,onCreateSession:f.pendingDirName?M2:void 0}),Mt=QA(z.agentTeams?(($u=f.sessionSource)==null?void 0:$u.fileName)??null:null,((Ou=f.sessionSource)==null?void 0:Ou.dirName)??null);v.useEffect(()=>{Mt!=null&&Mt.currentMemberName?u({type:"SET_CURRENT_MEMBER_NAME",name:Mt.currentMemberName}):Mt||u({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Mt==null?void 0:Mt.currentMemberName,Mt,u]),v.useEffect(()=>{c&&u({type:"GUARD_MOBILE_TAB",hasSession:!!f.session||!!f.pendingDirName})},[f.session,f.pendingDirName,f.mobileTab,c,u]);const Sn=i2({session:f.session,isLive:Se,pendingMessages:pt.pendingMessages,consumePending:pt.consumePending,sessionChangeKey:f.sessionChangeKey,partialContentLen:qe}),Xd=Sn.chatScrollRef,Jd=Sn.resetTurnCount,Qd=Sn.scrollToBottomInstant,L2=v.useCallback(ke=>{we(ke),requestAnimationFrame(()=>{const Ve=Xd.current;Ve&&Ve.scrollTo({top:Ve.scrollTop+(ke?64:-64),behavior:"smooth"})})},[Xd]);v.useLayoutEffect(()=>{const ke=Ve=>{Jd(0),Qd()};return Dr.current=ke,()=>{Dr.current===ke&&(Dr.current=null)}},[Jd,Qd,Dr]);const z2=v.useCallback(()=>{pt.disconnect(),qd()},[pt.disconnect,qd]),kn=iR({dispatch:u,isMobile:c,mobileTab:f.mobileTab,teamContext:Mt,scrollToBottomInstant:Sn.scrollToBottomInstant,resetTurnCount:Sn.resetTurnCount,workerParse:p,onBeforeSwitch:z2}),F2=v.useCallback(ke=>{v.startTransition(()=>{u({type:"GO_HOME",isMobile:c}),u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u,c]),{previewLoadError:B2}=dR({state:f,dispatch:u,isMobile:c,resetTurnCount:Sn.resetTurnCount,scrollToBottomInstant:Sn.scrollToBottomInstant,workerParse:p}),Lr=bR(),Zd=Lr.push;v.useEffect(()=>{f.sessionSource&&Zd(f.sessionSource.dirName,f.sessionSource.fileName)},[f.sessionSource,Zd]);const ft=lM({state:{session:f.session,sessionSource:f.sessionSource},dispatch:u,isMobile:c,handleJumpToTurn:kn.handleJumpToTurn,markPermissionsApplied:lt.markApplied,hasPermsPendingChanges:lt.hasPendingChanges,permissionsConfig:lt.config,selectedModel:Wt,selectedEffort:en,fastMode:$r,ultracode:Or,mcpConfig:W&&i?tn.mcpConfigJson:null,scrollRequestScrollToTop:Sn.requestScrollToTop,handleDashboardSelect:kn.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:eu,handleApplySettings:tu}=ft,nu=W&&i&&tn.mcpConfigJson!==null,su=v.useRef(!1);v.useEffect(()=>{var vt;const ke=tn.loaded&&!su.current;su.current=tn.loaded;const Ve=(vt=f.session)==null?void 0:vt.sessionId;ke&&Ve&&nu&&eu&&tu()},[tn.loaded,nu,eu,tu,(Du=f.session)==null?void 0:Du.sessionId]),v.useLayoutEffect(()=>(fe.current=ft.reloadSession,()=>{fe.current===ft.reloadSession&&(fe.current=null)}),[ft.reloadSession]);const On=y2(f.session,f.sessionSource,ft.reloadSession,a),zr=On.requestBranchSwitch,Fr=ft.setBranchModalTurn,U2=v.useCallback((ke,Ve)=>{zr(ke,Ve),Fr(null)},[zr,Fr]),W2=v.useCallback(ke=>{zr(ke),Fr(null)},[zr,Fr]);mR({isMobile:c,searchInputRef:N,chatInputRef:C,dispatch:u,onToggleSidebar:k.handleToggleSidebar,onToggleRightSidebar:k.handleToggleStats,onToggleMissionControl:k.handleToggleMission,onOpenCommandPalette:E,onOpenProjectSwitcher:k.handleOpenProjectSwitcher,onOpenThemeSelector:k.handleToggleThemeSelector,onOpenTerminal:ie,onToggleIntegratedTerminal:te,onTogglePreview:me,onToggleProjectFiles:le,onHistoryBack:Lr.goBack,onHistoryForward:Lr.goForward,onNavigateToSession:kn.handleDashboardSelect,onCommitNavigation:Lr.commitNavigation});const{killing:H2,handleKillAll:K2}=VR(),ns=f.sessionSource?vs(f.sessionSource.fileName):null,q2=ns!==null&&!!(Mt!=null&&Mt.currentMemberName),Da=ns!==null&&!q2,Br=kn.handleDashboardSelect,ou=v.useCallback(()=>{!f.sessionSource||!ns||Br(f.sessionSource.dirName,ns.parentFileName)},[f.sessionSource,ns,Br]);v.useEffect(()=>{const ke=Ve=>{const{agentId:vt}=Ve.detail??{};if(!vt||!f.sessionSource||!z.subagentTranscripts)return;const cn=ns?ns.parentSessionId:Dl(f.sessionSource.fileName);Br(f.sessionSource.dirName,`${cn}/subagents/agent-${vt}.jsonl`)};return window.addEventListener(Mi,ke),()=>window.removeEventListener(Mi,ke)},[f.sessionSource,ns,Br,z.subagentTranscripts]);const[V2,ru]=v.useState(null),G2=ft.branchModalTurn!==null,Ws=ft.branchModalTurn??V2;v.useEffect(()=>{ft.branchModalTurn!==null&&ru(ft.branchModalTurn)},[ft.branchModalTurn]);const iu=Ws!==null?On.branchesAtTurn(Ws):[],Y2=Da?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(co,{"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,X2=H?r.jsxs("div",{role:"status",className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(co,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Ow(L)})]}):null,La=Y2||X2,J2=kn.loadError||Kd||null;let za;kn.loadError?za=kn.clearLoadError:Kd&&(za=R2);const Q2=!!(f.session&&f.sessionSource&&$e==="disconnected"),Fa=v.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]),Ba=v.useMemo(()=>({session:f.session,sessionSource:f.sessionSource,isLive:Se,sseState:$e,isCompacting:Ue,turnError:Xe,promptSuggestion:De,undoRedo:On,pendingInteraction:Vt,permissionRequests:$t.requests,permissionResponding:$t.responding,respondPermission:$t.respond,respondAllPermissions:$t.respondAll,isSubAgentView:Da,slashSuggestions:K.suggestions,slashSuggestionsLoading:K.loading,actions:{handleStopSession:ft.handleStopSession,handleEditConfig:i?k.handleEditConfig:void 0,handleEditCommand:i?q:void 0,handleExpandCommand:i?Y:void 0,handleOpenBranches:ft.handleOpenBranches,handleBranchFromHere:ft.handleBranchFromHere,handleToggleExpandAll:T,handleLoadSession:ft.handleLoadSessionScrollAware}}),[f.session,f.sessionSource,Se,$e,Ue,Xe,De,On,Vt,Da,$t.requests,$t.responding,$t.respond,$t.respondAll,K.suggestions,K.loading,ft.handleStopSession,i,k.handleEditConfig,q,Y,ft.handleOpenBranches,ft.handleBranchFromHere,T,ft.handleLoadSessionScrollAware]),Ua=v.useMemo(()=>({chat:{status:pt.status,error:pt.error,pendingMessages:pt.pendingMessages,isConnected:pt.isConnected,sendMessage:pt.sendMessage,interrupt:pt.interrupt,stopAgent:pt.stopAgent,consumePending:pt.consumePending},scroll:Sn}),[pt.status,pt.error,pt.pendingMessages,pt.isConnected,pt.sendMessage,pt.interrupt,pt.stopAgent,pt.consumePending,Sn]),No=!!f.pendingDirName&&!f.session;if(v.useEffect(()=>{if(!No||c)return;const ke=requestAnimationFrame(()=>{var Ve;return(Ve=C.current)==null?void 0:Ve.focus()});return()=>cancelAnimationFrame(ke)},[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(rt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx($M,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(MM,{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(rt,{"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(rt,{"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(Hn,{children:[r.jsxs(Kn,{children:[r.jsx(Ss,{variant:"icon",children:r.jsx(jn,{className:"text-destructive"})}),r.jsx(qn,{children:"Failed to connect"}),r.jsx(Vn,{children:e.configError})]}),r.jsx(Ch,{children:r.jsxs(J,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Qt,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(t5,{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 Wa=r.jsx(hw,{activeError:J2,clearActiveError:za,modelFallbackNotice:P2,dismissModelFallbackNotice:A2,connectionLost:Q2,theme:d.activeTheme}),au=a?r.jsx(VS,{state:On.confirmState,isApplying:On.isApplying,applyError:On.applyError,onConfirm:On.confirmApply,onCancel:On.confirmCancel}):null,Z2=Ws!==null&&f.session?f.session.turns.slice(Ws):[],lu=a&&Ws!==null&&iu.length>0&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(LM,{open:G2,branches:iu,branchPointTurnIndex:Ws,currentTurns:Z2,onClose:ft.handleCloseBranchModal,onCloseComplete:()=>ru(null),onRedoToTurn:U2,onRedoEntireBranch:W2})}),cu=l&&r.jsx(OS,{processes:V.processes,activeProcessId:V.activeProcessId,collapsed:V.collapsed,onSetActive:V.setActive,onRemove:V.removeProcess,onToggleCollapse:V.toggleCollapse,onRequestTerminal:ut("terminal")?he:void 0,onAddTerminalContext:ke=>{var Lu,zu,Fu;const Ve=ke.trim();if(!Ve)return;const vt=Ve.includes("```")?"````":"```",cn=`${vt}terminal
|
|
139
139
|
${Ve}
|
|
140
140
|
${vt}`,Ha=((Lu=C.current)==null?void 0:Lu.getText().trimEnd())??"";(zu=C.current)==null||zu.setText(Ha?`${Ha}
|
|
141
141
|
|