cogpit 2.1.2 → 2.2.1
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 +947 -425
- package/dist/web/assets/CommandPaletteHost--_g3tlgk.js +1 -0
- package/dist/web/assets/ConfigBrowser-DrAZQBx8.js +1 -0
- package/dist/web/assets/{HighlightedEditor-BYfv1SYX.js → HighlightedEditor-Byq8pOUC.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-YDYAOpa5.js → KeyboardShortcutsDialog-CFhdeGBw.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-Bb3zEFSH.js → MobileFileChanges-uxpxh1W6.js} +1 -1
- package/dist/web/assets/{PreviewPanel-B9CQNmuh.js → PreviewPanel-DC6OTZfZ.js} +1 -1
- package/dist/web/assets/ProjectFilesPanel-ByyaiSGy.js +4 -0
- package/dist/web/assets/{ProjectSwitcherModal-CxbGrX7A.js → ProjectSwitcherModal-BRbFj3Dd.js} +1 -1
- package/dist/web/assets/{TerminalOutput-LwRcBZWA.js → TerminalOutput-Aavw8QCx.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-BG_Jah0i.js → ThemeSelectorModal-CxGMhlkF.js} +1 -1
- package/dist/web/assets/WorkflowsPanel-Beg1AAtq.js +1 -0
- package/dist/web/assets/{WorktreePanel-gR-fCesa.js → WorktreePanel-B17_SlFC.js} +1 -1
- package/dist/web/assets/{index-EmT8Vg0x.js → index-C-5Kgwol.js} +4 -4
- package/dist/web/assets/{index-BaKcHvT2.js → index-CJcccHRp.js} +1 -1
- package/dist/web/assets/index-CTpAqQye.js +1 -0
- package/dist/web/assets/index-DB1wEO_I.js +148 -0
- package/dist/web/assets/index-DU9XxwBy.css +1 -0
- package/dist/web/assets/{session-parser.worker-DycJL0jJ.js → session-parser.worker-RMitC4X_.js} +17 -17
- package/dist/web/assets/{vendor-ui-Bg9q4lA4.js → vendor-ui-CyII6N5s.js} +152 -147
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/CommandPaletteHost-Bq0_FFr0.js +0 -1
- package/dist/web/assets/ConfigBrowser-DmOlS3cU.js +0 -1
- package/dist/web/assets/ProjectFilesPanel-C3jKD37-.js +0 -4
- package/dist/web/assets/WorkflowsPanel-CiZjrfSd.js +0 -1
- package/dist/web/assets/index-Bif4Kdtn.css +0 -1
- package/dist/web/assets/index-C_pb6rZe.js +0 -1
- package/dist/web/assets/index-D-Mg0tNr.js +0 -144
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-Aavw8QCx.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-CyII6N5s.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--_g3tlgk.js","assets/index-CTpAqQye.js","assets/KeyboardShortcutsDialog-CFhdeGBw.js","assets/ProjectSwitcherModal-BRbFj3Dd.js","assets/ThemeSelectorModal-CxGMhlkF.js","assets/WorktreePanel-B17_SlFC.js","assets/ProjectFilesPanel-ByyaiSGy.js","assets/HighlightedEditor-Byq8pOUC.js","assets/index-CJcccHRp.js","assets/ConfigBrowser-DrAZQBx8.js","assets/PreviewPanel-DC6OTZfZ.js","assets/MobileFileChanges-uxpxh1W6.js","assets/index-C-5Kgwol.js","assets/WorkflowsPanel-Beg1AAtq.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Bb=Object.defineProperty;var Ub=(n,e,t)=>e in n?Bb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Yr=(n,e,t)=>Ub(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as be,e as Wb,r as v,a as Hb,f as Kb}from"./vendor-react-gGw_S5I_.js";import{au as qb,av as Vb,aw as Gb,ax as Gn,ad as rt,ay as Yb,m as yn,az as Xb,ar as Pn,aA as fh,aB as Jb,aC as Qb,aD as Zb,aE as mh,aF as ph,aG as Ac,aH as hh,aI as gh,aJ as xh,aK as ev,O as ft,aL as tv,aM as nv,aN as sv,aO as bh,J as br,a1 as mo,$ as Ze,c as Wt,ai as ov,aP as vh,aQ as Ti,G as zs,aR as rv,aS as iv,aT as av,aU as lv,aV as cv,aW as dv,aX as uv,aY as fv,aZ as mv,a_ as pv,a$ as hv,b0 as gv,b1 as xv,b2 as bv,b3 as vr,b4 as yh,b5 as Rc,b6 as Ic,b7 as Mc,b8 as $c,b9 as Zi,X as Nt,ba as Oc,bb as vv,N as Dc,bc as Yn,bd as yv,be as wh,bf as jh,bg as lo,bh as js,bi as wv,bj as jv,bk as Sv,bl as kv,bm as er,S as ln,B as po,b as Sh,bn as Fs,bo as kh,bp as Nv,bq as Cv,br as _v,ae as ea,bs as Tv,W as ta,ak as ql,a8 as So,bt as Vl,bu as Ev,bv as Pv,bw as Av,bx as Rv,by as Iv,bz as Mv,bA as $v,bB as Lc,bC as Ov,bD as en,D as An,bE as Dv,bF as Lv,bG as zv,bH as Fv,bI as tr,bJ as ko,bK as Bv,T as na,bL as Uv,bM as Wv,bN as Hv,bO as Kv,bP as qv,bQ as Vv,bR as Gv,bS as Yv,bT as Xv,bU as Jv,C as Je,P as Tn,A as No,g as Nh,bV as Qv,bW as Zv,bX as ey,bY as ty,F as ho,af as Ss,bZ as ny,b_ as Ch,U as zc,j as sa,a7 as oa,b$ as sy,c0 as Fc,c1 as Gl,c2 as oy,c3 as ry,c4 as iy,Q as Bc,R as Uc,c5 as ay,c6 as ly,Y as $s,E as _h,c7 as cy,v as ra,c8 as yr,_ as bi,a2 as Th,c9 as dy,ca as uy,cb as Eh,cc as fy,cd as my,ce as Xr,cf as _s,ag as of,e as wr,cg as py,ch as hy,as as gy,w as ia,ci as xy,cj as by,ck as vy,cl as yy,cm as wy,cn as jy,co as Ph,cp as Sy,cq as ky,ap as Ny,r as rf,cr as Cy,cs as af,p as aa,ct as _y,cu as Ah,d as Rh,I as Ih,cv as Ty,a3 as la,u as Ey,cw as Py,cx as Mh,L as Ay,z as Ry,s as $h,at as Oh,y as Iy,cy as My,cz as $y,cA as Oy,cB as Dy,cC as Ly,cD as zy,l as Fy,cE as By,cF as Uy,cG as lf,ab as Wy,an as Hy,cH as Ky,aa as qy,cI as Vy}from"./vendor-ui-CyII6N5s.js";import{c as Gy,a as Yy}from"./vendor-shiki-DOn6sF-i.js";import{r as ca,M as Rn}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 Xy="modulepreload",Jy=function(n){return"/"+n},cf={},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=Jy(d),d in cf)return;cf[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":Xy,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)})},ps=["codex","copilot","claude"],Yl="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function Qy(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 Zy(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 Dh(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>Qy(n,e),decode:e=>Zy(n,e)}}function Lh(n){const e=new RegExp(`(${Yl})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const zh={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function Fh(n){return`'${n.replace(/'/g,"'\\''")}'`}function nr(n,e){return e?[n,e]:[]}function Ei(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const Pi="[0-9a-f-]{36}",Bh="codex__",Uh="copilot__",e3=new Set(["default","plan","acceptEdits","dontAsk","auto"]),Wh={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(Bh)&&!n.startsWith(Uh),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:Lh,...zh},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"]:[...e3.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>nr("--model",n),effort:n=>nr("--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/")},bundledBySdk:!0,homeDirName:".claude",homeEnvVar:null,installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>Ei(n,new RegExp(`--resume(?:=|\\s+)(${Pi})`))??Ei(n,new RegExp(`--session-id(?:=|\\s+)(${Pi})`))}},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}},df={appServerValue:"priority",cliConfigValue:"fast"},t3={kind:"codex",displayName:"Codex",binName:"codex",dirName:Dh(Bh),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:Lh,...zh},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${Fh(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=>nr("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(df.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:df,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>Ei(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${Pi})`))}},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}},n3={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:Dh(Uh),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${Yl})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${Yl})/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 ${Fh(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=>nr("--model",n),effort:n=>nr("--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"},bundledBySdk:!1,homeDirName:".copilot",homeEnvVar:"COPILOT_HOME",installMarker:"session-state",homeIsDiscoverable:!0,process:{by:"executable",sessionIdFromCommand:n=>Ei(n,new RegExp(`--resume(?:=|\\s+)(${Pi})`))}},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}},sr=Object.freeze({claude:Wh,codex:t3,copilot:n3});function tn(n){return sr[n]}function da(){return ps.map(n=>sr[n])}function s3(n,e){const t=da().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function ks(n){for(const e of ps)if(e!=="claude"&&sr[e].dirName.owns(n))return sr[e];return Wh}function Ct(n){return ks(n).kind}function el(n,e,t){const s=sr[n].dirName;return t&&s.lossy?t:s.encode(e)}const Bs=ks(null).kind;var dh;const Jr=((dh=da().find(n=>n.dirName.lossy))==null?void 0:dh.kind)??null;function go(n){return ks(n).capabilities}function Ht(n){return tn(n).capabilities}function o3(n,e){return ps.find(t=>t===n)??e}function Xl(n){for(const e of da()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function r3(n,e){return ks(n).sessionFile.urlId(e)}function i3(n,e){return ks(n).sessionFile.fileNameFromUrlId(e)}function Hh(n,e,t){return tn(n).resume.command(e,t)}function a3(n,e){const t=tn(n);return{command:t.binName,args:[...t.resume.args(e)]}}function uf(n){return n.replace(/\/+$/,"")||"/"}function l3(n,e,t){var o;const s=uf(e);return((o=n.find(i=>ks(i.dirName).kind===t&&uf(i.path)===s))==null?void 0:o.dirName)??null}const c3=[{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"}],Wc=[{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"}],Kh=[...Wc,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],Qr=Wc.slice(0,4);var uh;const zo=[{value:((uh=tn("codex").serviceTier)==null?void 0:uh.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],ff={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:Kh,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:zo},d3=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...ff},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...ff},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:Kh,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:zo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:Wc,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:zo},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:Qr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:zo},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:Qr,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:zo},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:Qr,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:Qr,inputModalities:["text"],supportsPersonality:!0}],u3=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],f3={claude:c3,codex:d3,copilot:u3};function m3(n){return f3[n]}function G(...n){return qb(Vb(n))}const qh=new Map,Jl=new Set;function p3(n,e){!Array.isArray(e)||e.length===0||(qh.set(n,e),Jl.forEach(t=>t()))}function h3(n){return Jl.add(n),()=>Jl.delete(n)}const tl="high",g3=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function Vh(n){return qh.get(n)??m3(n)}function jr(n,e){const t=Vh(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 Gh(n,e){const t=jr(n,e),s=t==null?void 0:t.supportedReasoningEfforts;return s&&s.length>0?s:(t==null?void 0:t.supportsEffort)===!1||!Ht(n).reasoningEffort?[]:g3}function x3(n,e){var t;return((t=jr(n,e))==null?void 0:t.serviceTiers)??[]}function Yh(n,e){return x3(n,e).find(t=>t.value==="fast"||t.value==="priority"||t.label.toLowerCase()==="fast")}function b3(n,e){var s;const t=(s=jr(n,e))==null?void 0:s.inputModalities;return t?t.includes("image"):Ht(n).imageInput}function v3(n,e){var s;const t=Ht(n).autoPermissionMode;return t==="always"?!0:t==="never"?!1:((s=jr(n,e))==null?void 0:s.supportsAutoMode)===!0}function y3(n,e){return Ht(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function ua(n,e,t){var l,c;const s=Gh(n,t);if(s.length===0)return"";const o=(l=jr(n,t))==null?void 0:l.defaultReasoningEffort,i=o&&s.some(d=>d.value===o)?o:s.some(d=>d.value===tl)?tl:((c=s[0])==null?void 0:c.value)??tl,a=e||i;return s.some(d=>d.value===a)?a:i}function w3(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Sr(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 j3=Gn("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 Z(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(j3({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(Gb,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function In(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 Mn(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 S3=Gn("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 Xn(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(S3({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 $n(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 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/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 Xh(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 k3(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 N3=n=>{switch(n){case"success":return T3;case"info":return P3;case"warning":return E3;case"error":return A3;default:return null}},C3=Array(12).fill(0),_3=({visible:n,className:e})=>be.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},be.createElement("div",{className:"sonner-spinner"},C3.map((t,s)=>be.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),T3=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"})),E3=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"})),P3=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"})),A3=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"})),R3=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"})),I3=()=>{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 M3=1;const $3=100,mf=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:M3++};class O3{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-$3;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=mf(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(L3(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=mf(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 qt=new O3,D3=(n,e)=>qt.message(n,e),L3=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",z3=D3,F3=()=>qt.toasts,B3=()=>qt.getActiveToasts(),Ts=Object.assign(z3,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:F3,getToasts:B3});k3("[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 Zr(n){return n.label!==void 0}const U3=3,W3="24px",H3="16px",pf=4e3,K3=356,q3=14,V3=45,G3=200;function Nn(...n){return n.filter(Boolean).join(" ")}function Y3(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const X3=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:R,expandByDefault:M,classNames:I,icons:D,closeButtonAriaLabel:O="Close toast"}=n,[$,L]=be.useState(null),[F,z]=be.useState(null),[H,U]=be.useState(!1),[W,q]=be.useState(!1),[V,Y]=be.useState(!1),[K,X]=be.useState(!1),[Q,J]=be.useState(!1),[ee,oe]=be.useState(0),[se,re]=be.useState(0),ie=be.useRef(u.duration||T||pf),ae=be.useRef(null),te=be.useRef(null),me=b===0,de=b+1<=g,le=u.type,he=le??"default",ge=u.dismissible!==!1,ce=u.className||"",ve=u.descriptionClassName||"",xe=be.useMemo(()=>x.findIndex(ne=>ne.toastId===u.id)||0,[x,u.id]),pe=be.useMemo(()=>{var ne;return(ne=u.closeButton)!=null?ne:N},[u.closeButton,N]),je=be.useMemo(()=>u.duration||T||pf,[u.duration,T]),_e=be.useRef(0),Re=be.useRef(0),De=be.useRef(0),Te=be.useRef(null),[Ie,Le]=E.split("-"),ze=be.useMemo(()=>x.reduce((ne,ue,ke)=>ke>=xe?ne:ne+ue.height,0),[x,xe]),Ue=I3(),Se=be.useMemo(()=>{var ne;return(ne=n.swipeDirections)!=null?ne:Y3(E)},[n.swipeDirections,E]),He=u.invert||f,Oe=le==="loading";Re.current=be.useMemo(()=>xe*R+ze,[xe,ze]),be.useEffect(()=>{ie.current=je},[je]),be.useEffect(()=>{U(!0)},[]),be.useEffect(()=>{const ne=te.current;if(ne){const ue=ne.getBoundingClientRect().height;return re(ue),h(ke=>[{toastId:u.id,height:ue,position:u.position},...ke]),()=>h(ke=>ke.filter(Ae=>Ae.toastId!==u.id))}},[h,u.id]),be.useLayoutEffect(()=>{if(!H)return;const ne=te.current,ue=ne.style.height;ne.style.height="auto";const ke=ne.getBoundingClientRect().height;ne.style.height=ue,re(ke),h(Ae=>Ae.find(We=>We.toastId===u.id)?Ae.map(We=>We.toastId===u.id?{...We,height:ke}:We):[{toastId:u.id,height:ke,position:u.position},...Ae])},[H,u.title,u.description,h,u.id,u.jsx,u.action,u.cancel]);const Ne=be.useCallback(()=>{q(!0),oe(Re.current),h(ne=>ne.filter(ue=>ue.toastId!==u.id)),setTimeout(()=>{j(u)},G3)},[u,j,h,Re]);be.useEffect(()=>{if(u.promise&&le==="loading"||u.duration===1/0||u.type==="loading")return;let ne;return y||p||Ue?(()=>{if(De.current<_e.current){const Ae=new Date().getTime()-_e.current;ie.current=ie.current-Ae}De.current=new Date().getTime()})():(()=>{ie.current!==1/0&&(_e.current=new Date().getTime(),ne=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Ne()},ie.current))})(),()=>clearTimeout(ne)},[y,p,u,le,Ue,Ne]),be.useEffect(()=>{u.delete&&(Ne(),u.onDismiss==null||u.onDismiss.call(u,u))},[Ne,u.delete]);function fe(){var ne;if(D!=null&&D.loading){var ue;return be.createElement("div",{className:Nn(I==null?void 0:I.loader,u==null||(ue=u.classNames)==null?void 0:ue.loader,"sonner-loader"),"data-visible":le==="loading"},D.loading)}return be.createElement(_3,{className:Nn(I==null?void 0:I.loader,u==null||(ne=u.classNames)==null?void 0:ne.loader),visible:le==="loading"})}const Pe=u.icon||(D==null?void 0:D[le])||N3(le);var Me,Fe;return be.createElement("li",{tabIndex:0,ref:te,className:Nn(P,ce,I==null?void 0:I.toast,u==null||(e=u.classNames)==null?void 0:e.toast,I==null?void 0:I[he],u==null||(t=u.classNames)==null?void 0:t[he]),"data-sonner-toast":"","data-rich-colors":(Me=u.richColors)!=null?Me:k,"data-styled":!(u.jsx||u.unstyled||m),"data-mounted":H,"data-promise":!!u.promise,"data-swiped":Q,"data-removed":W,"data-visible":de,"data-y-position":Ie,"data-x-position":Le,"data-index":b,"data-front":me,"data-swiping":V,"data-dismissible":ge,"data-type":le,"data-invert":He,"data-swipe-out":K,"data-swipe-direction":F,"data-expanded":!!(y||M&&H),"data-testid":u.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${W?ee:Re.current}px`,"--initial-height":M?"auto":`${se}px`,...C,...u.style},onDragEnd:()=>{Y(!1),L(null),Te.current=null},onPointerDown:ne=>{ne.button!==2&&(Oe||!ge||(ae.current=new Date,oe(Re.current),ne.target.setPointerCapture(ne.pointerId),ne.target.tagName!=="BUTTON"&&(Y(!0),Te.current={x:ne.clientX,y:ne.clientY})))},onPointerUp:()=>{var ne,ue,ke;if(K||!ge)return;Te.current=null;const Ae=Number(((ne=te.current)==null?void 0:ne.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),$e=Number(((ue=te.current)==null?void 0:ue.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),We=new Date().getTime()-((ke=ae.current)==null?void 0:ke.getTime()),Xe=$==="x"?Ae:$e,nt=Math.abs(Xe)/We;if(($==="x"?Se.includes(Ae>0?"right":"left"):Se.includes($e>0?"bottom":"top"))&&(Math.abs(Xe)>=V3||nt>.11)){oe(Re.current),u.onDismiss==null||u.onDismiss.call(u,u),z($==="x"?Ae>0?"right":"left":$e>0?"down":"up"),Ne(),X(!0);return}else{var Ge,ot;(Ge=te.current)==null||Ge.style.setProperty("--swipe-amount-x","0px"),(ot=te.current)==null||ot.style.setProperty("--swipe-amount-y","0px")}J(!1),Y(!1),L(null)},onPointerMove:ne=>{var ue,ke,Ae;if(!Te.current||!ge||((ue=window.getSelection())==null?void 0:ue.toString().length)>0)return;const We=ne.clientY-Te.current.y,Xe=ne.clientX-Te.current.x;!$&&(Math.abs(Xe)>1||Math.abs(We)>1)&&L(Math.abs(Xe)>Math.abs(We)?"x":"y");let nt={x:0,y:0};const Be=Ge=>1/(1.5+Math.abs(Ge)/20);if($==="y"){if(Se.includes("top")||Se.includes("bottom"))if(Se.includes("top")&&We<0||Se.includes("bottom")&&We>0)nt.y=We;else{const Ge=We*Be(We);nt.y=Math.abs(Ge)<Math.abs(We)?Ge:We}}else if($==="x"&&(Se.includes("left")||Se.includes("right")))if(Se.includes("left")&&Xe<0||Se.includes("right")&&Xe>0)nt.x=Xe;else{const Ge=Xe*Be(Xe);nt.x=Math.abs(Ge)<Math.abs(Xe)?Ge:Xe}(Math.abs(nt.x)>0||Math.abs(nt.y)>0)&&J(!0),(ke=te.current)==null||ke.style.setProperty("--swipe-amount-x",`${nt.x}px`),(Ae=te.current)==null||Ae.style.setProperty("--swipe-amount-y",`${nt.y}px`)}},pe&&!u.jsx&&le!=="loading"?be.createElement("button",{"aria-label":O,"data-disabled":Oe,"data-close-button":!0,onClick:Oe||!ge?()=>{}:()=>{Ne(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Nn(I==null?void 0:I.closeButton,u==null||(s=u.classNames)==null?void 0:s.closeButton)},(Fe=D==null?void 0:D.close)!=null?Fe:R3):null,(le||u.icon||u.promise)&&u.icon!==null&&((D==null?void 0:D[le])!==null||u.icon)?be.createElement("div",{"data-icon":"",className:Nn(I==null?void 0:I.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},le==="loading"?u.icon||fe():u.promise?fe():null,le!=="loading"?Pe:null):null,be.createElement("div",{"data-content":"",className:Nn(I==null?void 0:I.content,u==null||(i=u.classNames)==null?void 0:i.content)},be.createElement("div",{"data-title":"",className:Nn(I==null?void 0:I.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,ve,I==null?void 0:I.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&&Zr(u.cancel)?be.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||S,onClick:ne=>{Zr(u.cancel)&&ge&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,ne),Ne())},className:Nn(I==null?void 0:I.cancelButton,u==null||(c=u.classNames)==null?void 0:c.cancelButton)},u.cancel.label):null,be.isValidElement(u.action)?u.action:u.action&&Zr(u.action)?be.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||_,onClick:ne=>{Zr(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,ne),!ne.defaultPrevented&&Ne())},className:Nn(I==null?void 0:I.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function hf(){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 J3(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?H3:W3;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 Q3=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=U3,toastOptions:b,dir:w=hf(),gap:y=q3,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,R]=be.useState(!1),[M,I]=be.useState(!1),[D,O]=be.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=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 q;return(q=W.find(V=>V.id===U.id))!=null&&q.delete||qt.dismiss(U.id),W.filter(({id:V})=>V!==U.id)})},[]);return be.useEffect(()=>qt.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{S(W=>W.map(q=>q.id===U.id?{...q,delete:!0}:q))});return}setTimeout(()=>{Wb.flushSync(()=>{S(W=>{const q=W.findIndex(V=>V.id===U.id);return q!==-1?[...W.slice(0,q),{...W[q],...U},...W.slice(q+1)]:[U,...W]})})})}),[]),be.useEffect(()=>{if(m!=="system"){O(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?O("dark"):O("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:W})=>{O(W?"dark":"light")})}catch{U.addListener(({matches:q})=>{try{O(q?"dark":"light")}catch(V){console.error(V)}})}},[m]),be.useEffect(()=>{C.length<=1&&R(!1)},[C]),be.useEffect(()=>{const U=W=>{var q;if(a.length>0&&a.every(K=>W[K]||W.code===K)){var Y;R(!0),(Y=$.current)==null||Y.focus()}W.code==="Escape"&&(document.activeElement===$.current||(q=$.current)!=null&&q.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[a]),be.useEffect(()=>{if($.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,z.current=!1)}},[$.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 q;const[V,Y]=U.split("-");return _.length?be.createElement("ol",{key:U,dir:w==="auto"?hf():w,tabIndex:-1,ref:$,className:d,"data-sonner-toaster":!0,"data-sonner-theme":D,"data-y-position":V,"data-x-position":Y,style:{"--front-toast-height":`${((q=A[0])==null?void 0:q.height)||0}px`,"--width":`${K3}px`,"--gap":`${y}px`,...g,...J3(f,u)},onBlur:K=>{z.current&&!K.currentTarget.contains(K.relatedTarget)&&(z.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||z.current||(z.current=!0,F.current=K.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{M||R(!1)},onDragEnd:()=>R(!1),onPointerDown:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},_.filter(K=>!K.position&&W===0||K.position===U).map((K,X)=>{var Q,J;return be.createElement(X3,{key:K.id,icons:j,index:X,toast:K,defaultRichColors:p,duration:(Q=b==null?void 0:b.duration)!=null?Q:h,className:b==null?void 0:b.className,descriptionClassName:b==null?void 0:b.descriptionClassName,invert:o,visibleToasts:x,closeButton:(J=b==null?void 0:b.closeButton)!=null?J:c,interacting:M,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==K.position),heights:A.filter(ee=>ee.position==K.position),setHeights:T,expandByDefault:l,gap:y,expanded:E,swipeDirections:e.swipeDirections})})):null}))}),Z3=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(Pn,{className:"size-4"}),info:r.jsx(Xb,{className:"size-4"}),warning:r.jsx(yn,{className:"size-4"}),error:r.jsx(Yb,{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(Q3,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function ew(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){Ts.dismiss("app-error");return}Ts.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){Ts.dismiss("model-fallback");return}Ts.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){Ts.dismiss("session-connection");return}Ts.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(Z3,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const jt="local",Jh="cogpit-last-path::",Ql=new Map;function ht(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return jt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:jt}function Os(){return ht()!==jt}function Qh(){const n=ht();return n===jt?"":`/hub/${n}`}function Zh(n){const e=Qh();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")?`${e}${n}`:n}let or=null;function eg(n){n!==or&&(or=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function hs(){return or}function vi(n){return n===jt?0:Ql.get(n)??0}function tw(n,e){if(n===jt||!Number.isSafeInteger(e)||e<0)return!1;const t=Ql.get(n);return t!==void 0&&e<=t?!1:(Ql.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function mn(){const n=ht(),e=vi(n);return e===0?n:`${n}@${e}`}function Ft(n){const e=ht(),t=mn();return or!==null?`${n}::${t}::${or}`:e===jt?n:`${n}::${t}`}function Ao(n,e){sessionStorage.setItem(`${Jh}${n}`,e)}function gs(n){const t=sessionStorage.getItem(`${Jh}${n}`)??(n===jt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const gf="cogpit-network-token",nw=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function fa(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!nw.has(e)}function ma(){try{localStorage.removeItem(gf),sessionStorage.removeItem(gf)}catch{}}typeof window<"u"&&ma();const sw={edition:"personal",needsBootstrap:!1};let rr=null,co=null;function tg(){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 co=e.edition==="team"?"team":"personal",{edition:co,needsBootstrap:co==="team"&&e.needsBootstrap===!0}}).catch(()=>(rr=null,sw))}function ng(){return rr??(rr=tg()),rr}function xf(){return rr=tg(),rr}function sg(){return ng().then(n=>n.edition)}async function ow(){if(!fa()&&co!=="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 rw(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{ma()}}function bf(){return ma(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function og(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=Zh(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(fa()||co==="team")return bf();if(co===null)return sg().then(i=>i==="team"?bf():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 og(n,e,!0)}function as(n,e){return og(n,e,!1)}function kr(n){return Zh(n)}let vf=!1;function iw(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 aw(){if(!vf){vf=!0;try{const n=await ye("/api/models");if(!n.ok)return;const e=await n.json();for(const t of ps){const s=e==null?void 0:e[t];iw(s)&&p3(t,s)}}catch{}}}function rg(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(lw,t);let s;return e[1]!==n?(s=()=>Vh(n),e[1]=n,e[2]=s):s=e[2],v.useSyncExternalStore(h3,s)}function lw(){aw()}function Dn(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(Qb,{"data-slot":"dropdown-menu",...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(Zb,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function zn(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(mh,{"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(gh,{children:r.jsx(xh,{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 Ut(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(ph,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function xs(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(hh,{"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 ut(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(fh,{"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 cw(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(sv,{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(ft,{})})}),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(tv,{"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 Ai(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(nv,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Hc(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(ev,{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(ft,{})})}),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(Jb,{"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 uo(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(Ac,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}tn("claude").contextWindow.compactBuffer;function dw(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=tn(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 uw(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=dw(e,t),c=l-tn(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 fw=4;function ig(n){return Math.ceil(n/fw)}function ag(n){let e=0;for(const t of n)e+=t.length;return e}function mw(n){let e=0;for(const t of n)e+=JSON.stringify(t.input).length;return e}function pw(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:ig(ag(n.thinking.map(o=>o.thinking)))}function hw(n){return ig(ag(n.assistantText)+mw(n.toolCalls))}function ls(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}const gw=["fable","mythos","opus","sonnet","haiku"];function yf(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Nr(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const o of gw){const i=s.match(new RegExp(`${o}(?:-(\\d+)(?:-(\\d{1,2}))?(?!\\d))?`));if(!i)continue;const a=i[1]?` ${i[1]}${i[2]?`.${i[2]}`:""}`:"";return`${yf(o)}${a}${t}`}if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(yf).join(" ");return`GPT-${o}${a?` ${a}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function tt(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 xw(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function lg(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Cr(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 Kc(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 qc(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 ks(n).dirName.decode(n)??n}function pa(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function ha(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 qn(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function bs(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function cg(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return uw(t.message.usage,t.message.model??"","claude")}return null}const bw={claude:mo,codex:br,copilot:bh},Vc={claude:"Claude",codex:"Codex",copilot:"Copilot"},vw={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},yw={claude:null,codex:"Codex",copilot:"Copilot"},ww={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"}},jw={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},Sw={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},kw={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 Nw(n){return kw[n]}function ga(n){return Vc[n]}function kO(n){return vw[n]}function Cw(n){return yw[n]}function NO(n){return ww[n]}function _w(n){return Sw[n]}function Tw(n){return jw[n]}const wf=ks(null).kind,dg=[wf,...ps.filter(n=>n!==wf)];function Ew(n){return`This ${Vc[n]} session is controlled by another process. Cogpit can only view it.`}const Zl=dg.map(n=>({value:n,label:Vc[n],Icon:bw[n]}));function Pw(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 Aw(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?Gc(e,n):"Default"}function Gc(n,e){var t;return((t=Pw(n,e))==null?void 0:t.label)??Nr(n)}function ug(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(Hc,{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 Rw(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=Zl.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(Z,{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(Ze,{"data-icon":"inline-end"}),e[9]=g):g=e[9];let x;e[10]!==h?(x=r.jsxs(Ln,{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(xs,{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=Zl.map(Mw),e[15]=y):y=e[15];let j;e[16]!==t||e[17]!==w?(j=r.jsxs(Ut,{children:[b,r.jsx(Ai,{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(uo,{}),e[19]=k):k=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(xs,{children:"Model"}),e[20]=N):N=e[20];let C;e[21]!==a?(C=a.map(Iw),e[21]=a,e[22]=C):C=e[22];let S;e[23]!==l||e[24]!==C||e[25]!==o?(S=r.jsxs(Ut,{children:[N,r.jsx(Ai,{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(zn,{"aria-label":"Agent and model",className:"w-80",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(Dn,{children:[x,_]}),e[30]=_,e[31]=x,e[32]=P):P=e[32],P}function Iw(n){return r.jsx(ug,{option:n,descriptionWidth:"max-w-80"},n.value)}function Mw(n){const e=n.Icon;return r.jsxs(Hc,{value:n.value,children:[r.jsx(e,{}),n.label]},n.value)}function $w(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(Ow),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(Z,{type:"button",variant:"ghost",size:"xs"}),h=r.jsx(ov,{"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(Wt,{"data-icon":"inline-end",className:"animate-spin"}):r.jsx(Ze,{"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(Ln,{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(xs,{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(Wt,{"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(ut,{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(ut,{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(ut,{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(cw,{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(Ut,{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(zn,{"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(Dn,{children:[w,P]}),e[41]=P,e[42]=w,e[43]=A):A=e[43],A}function Ow(n){return n.status==="connected"}function jf(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(Z,{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(Ze,{"data-icon":"inline-end"}),e[8]=h):h=e[8];let g;e[9]!==a||e[10]!==m||e[11]!==p?(g=r.jsxs(Ln,{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(xs,{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(Dw),e[16]=o,e[17]=b):b=e[17];let w;e[18]!==i||e[19]!==b||e[20]!==t?(w=r.jsx(Ai,{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(Ut,{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(zn,{"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(Dn,{children:[g,j]}),e[28]=j,e[29]=g,e[30]=k):k=e[30],k}function Dw(n){return r.jsx(ug,{option:n},n.value)}function fg(n,e){return Nw(n).filter(t=>t.value!=="auto"||e)}function Lw(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=fg(t,a),C=N.find(A=>A.value===s)??N[0];f=Dn;let S,_;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Z,{type:"button",variant:"ghost",size:"xs"}),S=r.jsx(vh,{"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(Ze,{"data-icon":"inline-end"}),e[17]=P):P=e[17],b=r.jsxs(Ln,{render:_,children:[S,r.jsx("span",{className:"truncate",children:C.label}),P]}),d=zn,g="Access policy",x="w-72",c=Ut,e[18]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(xs,{children:"Permissions"}),e[18]=h):h=e[18],l=Ai,u=s,e[19]!==o?(m=A=>o(A),e[19]=o,e[20]=m):m=e[20],p=N.map(zw),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 zw(n){return r.jsx(Hc,{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 Fw(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 R;e[0]!==t?(R=Ht(t),e[0]=t,e[1]=R):R=e[1];const{worktrees:M,ultracode:I,settingsApply:D}=R,O=v.useId(),$=h?void 0:D==="live"?"Changes apply live":"Changes apply next turn",L=$?O:void 0;let F;e[2]!==$||e[3]!==O?(F=$&&r.jsx("span",{id:O,className:"sr-only",children:$}),e[2]=$,e[3]=O,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(Rw,{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}):r.jsx(jf,{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(jf,{value:ua(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(Z,{type:"button",variant:m?"secondary":"ghost",size:"xs","aria-pressed":!!m,onClick:()=>T(()=>p(!m)),title:u.description,children:[r.jsx(Ti,{"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(Lw,{agentKind:t,mode:j,onChange:Q=>T(()=>k(Q)),autoAvailable:y}),e[24]=t,e[25]=y,e[26]=T,e[27]=k,e[28]=j,e[29]=W):W=e[29];let q;e[30]!==h||e[31]!==x||e[32]!==M||e[33]!==g?(q=M&&h&&x&&r.jsxs(Z,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(zs,{"data-icon":"inline-start"}),"Worktree"]}),e[30]=h,e[31]=x,e[32]=M,e[33]=g,e[34]=q):q=e[34];let V;e[35]!==T||e[36]!==w||e[37]!==I||e[38]!==b?(V=I&&w&&r.jsxs(Z,{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(Ti,{"data-icon":"inline-start",className:G(b&&"fill-current")}),"Ultracode"]}),e[35]=T,e[36]=w,e[37]=I,e[38]=b,e[39]=V):V=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($w,{servers:N??[],selected:C??[],onToggle:Q=>T(()=>S(Q)),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 K;e[48]!==Y||e[49]!==z||e[50]!==H||e[51]!==U||e[52]!==W||e[53]!==q||e[54]!==V||e[55]!==E?(K=r.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1.5",children:[z,H,U,W,q,V,Y,E]}),e[48]=Y,e[49]=z,e[50]=H,e[51]=U,e[52]=W,e[53]=q,e[54]=V,e[55]=E,e[56]=K):K=e[56];let X;return e[57]!==$||e[58]!==K||e[59]!==L||e[60]!==F?(X=r.jsxs("div",{className:"flex items-center pb-1.5 pl-6 pr-3",role:"group",title:$,"aria-describedby":L,children:[F,K]}),e[57]=$,e[58]=K,e[59]=L,e[60]=F,e[61]=X):X=e[61],X}function Mt(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(Ac,{"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 Bw(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 Uw(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 Ww(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 Co(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 Hw=Gn("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(Hw({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 CO(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(Bw,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function xo(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 fs(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(qw)).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(Kw)}),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 Kw(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function qw(n){return[n==null?void 0:n.message,n]}const Vw=lv;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("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(fv,{"data-slot":"select-group",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-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(cv,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Xw(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(mv,{render:r.jsx(Ze,{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(dv,{"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 Jw(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(Zw,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=r.jsx(pv,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(ej,{}),e[14]=w):w=e[14];let y;e[15]!==o||e[16]!==g||e[17]!==b?(y=r.jsxs(uv,{"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(hv,{children:r.jsx(gv,{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 Qw(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(iv,{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(av,{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(ft,{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(rv,{"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 Zw(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(vr,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(xv,{"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 ej(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(Ze,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(bv,{"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 tj(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(yh,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function nj(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(vv,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function sj(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(Zi,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function oj(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($c,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function rj(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(Oc,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ij(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(rj,{}),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(Zi,{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(Nt,{"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(oj,{children:[d,r.jsxs(Rc,{"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 aj(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 lj(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(Ic,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function cj(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(Mc,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vo(n){const e=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 ei(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(Yw,{}),e[2]=f):f=e[2];let u;e[3]!==s||e[4]!==c?(u=r.jsx(Xw,{"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(dj),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(Jw,{children:r.jsx(Gw,{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(Vw,{value:o,onValueChange:d,disabled:l,children:[u,p]}),e[10]=l,e[11]=d,e[12]=u,e[13]=p,e[14]=o,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==h?(g=r.jsx(Vo,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function dj(n){return r.jsx(Qw,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function uj(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=ua(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(ei,{label:"Agent",ariaLabel:"Agent",value:t,options:Zl,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(ei,{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(ei,{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(Vo,{label:"Speed",children:r.jsxs(Z,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>b(()=>p(!m)),title:u.description,className:"h-10 justify-start",children:[r.jsx(Ti,{"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(ei,{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 fj(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=Ht(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(Vo,{label:"Isolation",children:r.jsxs(Z,{type:"button",variant:o?"secondary":"ghost","aria-pressed":!!o,onClick:()=>i(!o),className:"h-10 justify-start",children:[r.jsx(zs,{"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(Vo,{label:"Workflow",children:r.jsxs(Z,{type:"button",variant:a?"secondary":"ghost","aria-pressed":!!a,onClick:()=>h(()=>l(!a)),className:"h-10 justify-start",children:[r.jsx(Ti,{"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(Vo,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(Z,{type:"button",variant:"ghost",onClick:u,className:"min-h-10 justify-start",children:[r.jsx(Wt,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(T=>{const E=N.has(T.name),R=T.status==="connected";return r.jsxs(Z,{type:"button",variant:"ghost","aria-pressed":R?E:void 0,onClick:()=>R?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",R&&E?"bg-success":R?"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:R?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 mj(n){var me,de;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:R,mobileExtra:M,changeAndApply:I}=n;let D;e[0]!==o||e[1]!==u||e[2]!==a?(D=ua(o,u,a),e[0]=o,e[1]=u,e[2]=a,e[3]=D):D=e[3];const O=D;let $,L;e[4]!==o||e[5]!==N||e[6]!==C?($=fg(o,N),L=(me=$.find(le=>le.value===C))==null?void 0:me.label,e[4]=o,e[5]=N,e[6]=C,e[7]=$,e[8]=L):($=e[7],L=e[8]);const F=L;let z;e[9]!==c||e[10]!==l||e[11]!==a?(z=a?Gc(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]!==O?(H=(de=m.find(le=>le.value===O))==null?void 0:de.label,e[13]=m,e[14]=O,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 q;e[20]!==I||e[21]!==S?(q=le=>{S&&I(()=>S(le))},e[20]=I,e[21]=S,e[22]=q):q=e[22];const V=q;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(nj,{render:r.jsx(Z,{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(Dc,{})}),e[23]=Y):Y=e[23];let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(lj,{children:"Session controls"}),e[24]=K):K=e[24];let X;e[25]!==W?(X=r.jsx(cj,{className:"truncate text-xs",children:W}),e[25]=W,e[26]=X):X=e[26];let Q;e[27]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(sj,{render:r.jsx(Z,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:r.jsx(Nt,{})}),e[27]=Q):Q=e[27];let J;e[28]!==X?(J=r.jsxs(aj,{className:"gap-1 px-4 pb-3 pt-4",children:[K,X,Q]}),e[28]=X,e[29]=J):J=e[29];let ee;e[30]!==o||e[31]!==I||e[32]!==V||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]!==$||e[43]!==u||e[44]!==a||e[45]!==j?(ee=r.jsx(uj,{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:$,onPermissionModeChange:V,changeAndApply:I}),e[30]=o,e[31]=I,e[32]=V,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]=$,e[43]=u,e[44]=a,e[45]=j,e[46]=ee):ee=e[46];let oe;e[47]!==o||e[48]!==I||e[49]!==b||e[50]!==E||e[51]!==_||e[52]!==R||e[53]!==T||e[54]!==A||e[55]!==k||e[56]!==y||e[57]!==P||e[58]!==j||e[59]!==w?(oe=r.jsx(fj,{agentKind:o,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:y,ultracodeEnabled:j,onUltracodeEnabledChange:k,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:R,changeAndApply:I}),e[47]=o,e[48]=I,e[49]=b,e[50]=E,e[51]=_,e[52]=R,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]!==M?(se=M&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(Mt,{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:M})]}),e[61]=M,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:Ht(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]!==J||e[72]!==ie?(ae=r.jsxs(ij,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[J,ie]}),e[71]=J,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(tj,{open:t,onOpenChange:s,children:[Y,ae]})}),e[74]=s,e[75]=t,e[76]=ae,e[77]=te):te=e[77],te}const pj=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?Bs:s,R=T===void 0?!1:T,[M,I]=v.useState(!1);let D;t[0]!==u||t[1]!==x?(D=te=>{te(),!u&&x&&setTimeout(()=>x(),0)},t[0]=u,t[1]=x,t[2]=D):D=t[2];const O=D;let $;t[3]!==O||t[4]!==a?($=te=>O(()=>a(te)),t[3]=O,t[4]=a,t[5]=$):$=t[5];const L=$;let F;t[6]!==O||t[7]!==c?(F=te=>O(()=>c(te)),t[6]=O,t[7]=c,t[8]=F):F=t[8];const z=F,H=rg(E),U=(b==null?void 0:b.toLowerCase().startsWith("gpt-"))??!1,q=b&&(E==="copilot"||U===(E==="codex"))?b:void 0;let V,Y;t[9]!==H||t[10]!==q?(V=q?Gc(q,H):Aw(H),Y=H.map(te=>{const me=[te.description,te.availabilityMessage].filter(Boolean).join(" · ")||void 0;return te.value===""?{...te,description:me,label:V,menuLabel:te.label}:{...te,description:me}}),t[9]=H,t[10]=q,t[11]=V,t[12]=Y):(V=t[11],Y=t[12]);const K=Y;let X;t[13]!==E||t[14]!==i?(X=Gh(E,i),t[13]=E,t[14]=i,t[15]=X):X=t[15];const Q=X;let J;t[16]!==E||t[17]!==i?(J=Yh(E,i),t[16]=E,t[17]=i,t[18]=J):J=t[18];const ee=J;let oe;t[19]!==E||t[20]!==i?(oe=v3(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]!==O||t[25]!==Q||t[26]!==d||t[27]!==ee||t[28]!==z||t[29]!==L||t[30]!==u||t[31]!==N||t[32]!==w||t[33]!==K||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]!==V||t[44]!==l||t[45]!==y||t[46]!==i||t[47]!==h||t[48]!==m?(re={agentKind:E,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:V,modelOptions:K,onModelChange:L,selectedEffort:l,effortOptions:Q,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:O},t[22]=E,t[23]=se,t[24]=O,t[25]=Q,t[26]=d,t[27]=ee,t[28]=z,t[29]=L,t[30]=u,t[31]=N,t[32]=w,t[33]=K,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]=V,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(R){let te;return t[50]!==H||t[51]!==ie||t[52]!==P||t[53]!==M?(te=r.jsx(mj,{...ie,open:M,onOpenChange:I,catalogOptions:H,mobileExtra:P}),t[50]=H,t[51]=ie,t[52]=P,t[53]=M,t[54]=te):te=t[54],te}let ae;return t[55]!==ie||t[56]!==A?(ae=r.jsx(Fw,{...ie,trailingExtra:A}),t[55]=ie,t[56]=A,t[57]=ae):ae=t[57],ae});function mg(n){return n.agentType==="team-lead"}function hj(n){return mg(n)?void 0:n.color}const gj={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function xj(n){return n?gj[n]??"bg-zinc-400":"bg-zinc-400"}const bj=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(Yn,{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(Mt,{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=xj(hj(g));return r.jsxs(Z,{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}),mg(g)&&r.jsx(yv,{"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 pg(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 hg=v.createContext(null),gg=v.createContext(null);function yi(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(gg.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(hg.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function it(){const n=v.useContext(hg);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function _r(){const n=v.useContext(gg);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const vj=Gn("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 Ee(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=jh,s="span",o=wh({className:G(vj({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 Sf=1,yj=.9,wj=.8,jj=.17,nl=.1,sl=.999,Sj=.9999,kj=.99,Nj=/[\\\/_+.#"@\[\(\{&]/,Cj=/[\\\/_+.#"@\[\(\{&]/g,_j=/[\s-]/,xg=/[\s-]/g;function ec(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?Sf:kj;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=ec(n,e,t,s,d+1,i+1,a),u>f&&(d===o?u*=Sf:Nj.test(n.charAt(d-1))?(u*=wj,p=n.slice(o,d-1).match(Cj),p&&o>0&&(u*=Math.pow(sl,p.length))):_j.test(n.charAt(d-1))?(u*=yj,h=n.slice(o,d-1).match(xg),h&&o>0&&(u*=Math.pow(sl,h.length))):(u*=jj,o>0&&(u*=Math.pow(sl,d-o))),n.charAt(d)!==e.charAt(i)&&(u*=Sj)),(u<nl&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=ec(n,e,t,s,d+1,i+2,a),m*nl>u&&(u=m*nl)),u>f&&(f=u),d=t.indexOf(c,d+1);return a[l]=f,f}function kf(n){return n.toLowerCase().replace(xg," ")}function Tj(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,ec(n,e,kf(n),kf(e),0,0,{})}var Ro='[cmdk-group=""]',ol='[cmdk-group-items=""]',Ej='[cmdk-group-heading=""]',bg='[cmdk-item=""]',Nf=`${bg}:not([aria-disabled="true"])`,tc="cmdk-item-select",so="data-value",Pj=(n,e,t)=>Tj(n,e,t),vg=v.createContext(void 0),Tr=()=>v.useContext(vg),yg=v.createContext(void 0),Yc=()=>v.useContext(yg),wg=v.createContext(void 0),jg=v.forwardRef((n,e)=>{let t=oo(()=>{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=oo(()=>new Set),o=oo(()=>new Map),i=oo(()=>new Map),a=oo(()=>new Set),l=Sg(n),{label:c,children:d,value:f,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,w=lo(),y=lo(),j=lo(),k=v.useRef(null),N=Bj();Ds(()=>{if(f!==void 0){let z=f.trim();t.current.value=z,C.emit()}},[f]),Ds(()=>{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,q,V,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 K=document.getElementById(j);K?K.focus():(W=document.getElementById(w))==null||W.focus()}if(N(7,()=>{var K;t.current.selectedItemId=(K=R())==null?void 0:K.id,C.emit()}),U||N(5,E),((q=l.current)==null?void 0:q.value)!==void 0){let K=H??"";(Y=(V=l.current).onValueChange)==null||Y.call(V,K);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=R();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 q=(W=(U=l.current)==null?void 0:U.filter)!=null?W:Pj;return z?q(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 q=o.current.get(W),V=0;q.forEach(Y=>{let K=z.get(Y);V=Math.max(K,V)}),H.push([W,V])});let U=k.current;M().sort((W,q)=>{var V,Y;let K=W.getAttribute("id"),X=q.getAttribute("id");return((V=z.get(X))!=null?V:0)-((Y=z.get(K))!=null?Y:0)}).forEach(W=>{let q=W.closest(ol);q?q.appendChild(W.parentElement===q?W:W.closest(`${ol} > *`)):U.appendChild(W.parentElement===U?W:W.closest(`${ol} > *`))}),H.sort((W,q)=>q[1]-W[1]).forEach(W=>{var q;let V=(q=k.current)==null?void 0:q.querySelector(`${Ro}[${so}="${encodeURIComponent(W[0])}"]`);V==null||V.parentElement.appendChild(V)})}function A(){let z=M().find(U=>U.getAttribute("aria-disabled")!=="true"),H=z==null?void 0:z.getAttribute(so);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 q=0;for(let V of s.current){let Y=(H=(z=i.current.get(V))==null?void 0:z.value)!=null?H:"",K=(W=(U=i.current.get(V))==null?void 0:U.keywords)!=null?W:[],X=_(Y,K);t.current.filtered.items.set(V,X),X>0&&q++}for(let[V,Y]of o.current)for(let K of Y)if(t.current.filtered.items.get(K)>0){t.current.filtered.groups.add(V);break}t.current.filtered.count=q}function E(){var z,H,U;let W=R();W&&(((z=W.parentElement)==null?void 0:z.firstChild)===W&&((U=(H=W.closest(Ro))==null?void 0:H.querySelector(Ej))==null||U.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function R(){var z;return(z=k.current)==null?void 0:z.querySelector(`${bg}[aria-selected="true"]`)}function M(){var z;return Array.from(((z=k.current)==null?void 0:z.querySelectorAll(Nf))||[])}function I(z){let H=M()[z];H&&C.setState("value",H.getAttribute(so))}function D(z){var H;let U=R(),W=M(),q=W.findIndex(Y=>Y===U),V=W[q+z];(H=l.current)!=null&&H.loop&&(V=q+z<0?W[W.length-1]:q+z===W.length?W[0]:W[q+z]),V&&C.setState("value",V.getAttribute(so))}function O(z){let H=R(),U=H==null?void 0:H.closest(Ro),W;for(;U&&!W;)U=z>0?zj(U,Ro):Fj(U,Ro),W=U==null?void 0:U.querySelector(Nf);W?C.setState("value",W.getAttribute(so)):D(z)}let $=()=>I(M().length-1),L=z=>{z.preventDefault(),z.metaKey?$():z.altKey?O(1):D(1)},F=z=>{z.preventDefault(),z.metaKey?I(0):z.altKey?O(-1):D(-1)};return v.createElement(js.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(),I(0);break}case"End":{z.preventDefault(),$();break}case"Enter":{z.preventDefault();let W=R();if(W){let q=new Event(tc);W.dispatchEvent(q)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:Wj},c),xa(n,z=>v.createElement(yg.Provider,{value:C},v.createElement(vg.Provider,{value:S},z))))}),Aj=v.forwardRef((n,e)=>{var t,s;let o=lo(),i=v.useRef(null),a=v.useContext(wg),l=Tr(),c=Sg(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;Ds(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let f=kg(o,i,[n.value,n.children,i],n.keywords),u=Yc(),m=vs(N=>N.value&&N.value===f.current),p=vs(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(tc,h),()=>N.removeEventListener(tc,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(js.div,{ref:er(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)}),Rj=v.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=lo(),l=v.useRef(null),c=v.useRef(null),d=lo(),f=Tr(),u=vs(p=>o||f.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);Ds(()=>f.group(a),[]),kg(a,l,[n.value,n.heading,c]);let m=v.useMemo(()=>({id:a,forceMount:o}),[o]);return v.createElement(js.div,{ref:er(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),xa(n,p=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},v.createElement(wg.Provider,{value:m},p))))}),Ij=v.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=v.useRef(null),i=vs(a=>!a.search);return!t&&!i?null:v.createElement(js.div,{ref:er(o,e),...s,"cmdk-separator":"",role:"separator"})}),Mj=v.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Yc(),a=vs(d=>d.search),l=vs(d=>d.selectedItemId),c=Tr();return v.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),v.createElement(js.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)}})}),$j=v.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=v.useRef(null),a=v.useRef(null),l=vs(d=>d.selectedItemId),c=Tr();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(js.div,{ref:er(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},xa(n,d=>v.createElement("div",{ref:er(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),Oj=v.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return v.createElement(wv,{open:t,onOpenChange:s},v.createElement(jv,{container:a},v.createElement(Sv,{"cmdk-overlay":"",className:o}),v.createElement(kv,{"aria-label":n.label,"cmdk-dialog":"",className:i},v.createElement(jg,{ref:e,...l}))))}),Dj=v.forwardRef((n,e)=>vs(t=>t.filtered.count===0)?v.createElement(js.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),Lj=v.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return v.createElement(js.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},xa(n,a=>v.createElement("div",{"aria-hidden":!0},a)))}),_o=Object.assign(jg,{List:$j,Item:Aj,Input:Mj,Group:Rj,Separator:Ij,Dialog:Oj,Empty:Dj,Loading:Lj});function zj(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function Fj(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Sg(n){let e=v.useRef(n);return Ds(()=>{e.current=n}),e}var Ds=typeof window>"u"?v.useEffect:v.useLayoutEffect;function oo(n){let e=v.useRef();return e.current===void 0&&(e.current=n()),e}function vs(n){let e=Yc(),t=()=>n(e.snapshot());return v.useSyncExternalStore(e.subscribe,t,t)}function kg(n,e,t,s=[]){let o=v.useRef(),i=Tr();return Ds(()=>{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(so,l),o.current=l}),o}var Bj=()=>{let[n,e]=v.useState(),t=oo(()=>new Map);return Ds(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function Uj(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function xa({asChild:n,children:e},t){return n&&v.isValidElement(e)?v.cloneElement(Uj(e),{ref:e.ref},t(e.props.children)):t(e)}var Wj={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Jn(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(yh,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function Hj(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($c,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Kj(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(Oc,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Qn(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(Kj,{}),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(Zi,{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(Nt,{"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(Hj,{children:[l,r.jsxs(Rc,{"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 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("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 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("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 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("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(Ic,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}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("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(Mc,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Cg(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(_o,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function _O(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(Zn,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(es,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(Ns,{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(Qn,{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(Jn,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function TO(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(ln,{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(_o.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function _g(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(_o.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function EO(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(_o.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Tg(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(_o.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Eg(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(ft,{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(_o.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 qj(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 Vj(n){return r.jsx(Ee,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const Gj=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(Xj),A=[{heading:"Commands",suggestions:P,offset:0},{heading:"Skills",suggestions:s.filter(Jj),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=Cg,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(R=>`${R.type}-${R.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=_g,b=A.map(T=>T.suggestions.length>0&&r.jsx(Tg,{heading:T.heading,children:T.suggestions.map((E,R)=>{const M=T.offset+R;return r.jsx(Yj,{suggestion:E,index:M,isSelected:M===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 Yj({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(Eg,{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(po,{className:"size-4 text-muted-foreground"}):r.jsx(Sh,{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]}),Vj(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(qj,{className:i&&n.filePath?"mr-6":void 0,children:"Enter"})]}),i&&n.filePath&&r.jsx(Z,{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(Fs,{"data-icon":"inline-start"})})]})}function Xj(n){return n.type==="command"}function Jj(n){return n.type==="skill"}function Qj(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(Eg,{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:Zj,children:[r.jsx(kh,{"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(_g,{className:"max-h-70",children:r.jsx(Tg,{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(Cg,{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 Zj(n){return n.preventDefault()}const eS=Gn("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 St(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(eS({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 It(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 kt(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 ys(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 yt(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(Cv,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function Jt(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(_v,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function wt(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(Nv,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const tS={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function Cf(n){return tS[n]??n.replaceAll("_"," ")}function nS(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(I=>I!==T);m=St,b="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(ea,{}),y=r.jsx(It,{children:"Plan ready for review"}),e[15]=w,e[16]=y):(w=e[15],y=e[16]);const R=s||"Approve the plan or ask the agent to revise it.";e[17]!==R?(j=r.jsx(kt,{children:R}),e[17]=R,e[18]=j):j=e[18],u=ys,h="flex gap-2";let M;e[19]!==p?(M=p&&r.jsx(rt,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=M):M=e[20],g=r.jsxs(Z,{size:"sm",disabled:p,onClick:()=>d(T),children:[M,p?"Sending...":T?Cf(T):"Approve"]}),x=E.length>0&&r.jsxs(Dn,{children:[r.jsx(Ln,{render:r.jsx(Z,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(Ze,{"data-icon":"icon"})}),r.jsx(zn,{align:"end",children:r.jsx(Ut,{children:E.map(I=>r.jsx(ut,{onClick:()=>d(I),children:Cf(I)},I))})})]}),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(Z,{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(yt,{className:"col-span-full mt-2",children:[r.jsx(Jt,{render:r.jsx(Z,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(wt,{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(sS)]}),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 sS(n,e){return r.jsx(Ee,{variant:"outline",children:n.prompt},e)}const oS=["allow","allow_always","deny"];function ti(n,e){return(n.availableDecisions??oS).includes(e)}function rS(n){switch(n){case"Bash":return{label:"Run command",icon:po,tone:"cmd"};case"Edit":return{label:"Edit file",icon:Vl,tone:"write"};case"Write":return{label:"Write file",icon:Vl,tone:"write"};case"Read":return{label:"Read file",icon:So,tone:"read"};case"Glob":return{label:"File search",icon:ln,tone:"search"};case"Grep":return{label:"Content search",icon:ln,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:ql,tone:"net"};case"WebSearch":return{label:"Web search",icon:ql,tone:"net"};default:return{label:n,icon:ta,tone:"other"}}}function iS(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 aS({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?ti(o,"allow"):!1,l=o?ti(o,"allow_always"):!1,c=o?ti(o,"deny"):!1,d=i>1&&n.every(y=>ti(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?rS(o.toolName):null,m=o?iS(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(vh,{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(Ee,{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(Z,{variant:"ghost",size:"sm",className:"text-destructive",disabled:x,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(Nt,{"data-icon":"inline-start"}),"Deny",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]}),l&&r.jsxs(Z,{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(Tv,{"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(Z,{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(Z,{size:"sm",disabled:x,onClick:()=>t(o.requestId,"allow"),title:"Allow once (A)",children:[r.jsx(ft,{"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 lS=1568,cS=.85,_f=35e5;function dS(n,e){let{width:t,height:s}=n;const o=Math.min(1,lS/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?cS:void 0),f=d.split(",")[1];if(f.length>_f){let u=l?.7:.8;for(;f.length>_f&&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 uS(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=I=>{const D=Array.from(I).filter(pS);if(!t){D.length>0&&d(!0);return}d(!1);for(const O of D){const $=new FileReader;$.onload=()=>{if(!f.current){d(!0);return}const L=$.result,F=new Image;F.onload=()=>{if(!f.current){d(!0);return}const z=dS(F,O.type);i(H=>[...H,{id:crypto.randomUUID(),file:O,preview:z.dataUrl,data:z.base64,mediaType:z.mediaType}])},F.src=L},$.onerror=()=>{console.warn(`Failed to read image file: ${O.name}`)},$.readAsDataURL(O)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=I=>{i(D=>D.filter((O,$)=>$!==I)),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=I=>{I.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=I=>{I.preventDefault(),I.currentTarget.contains(I.relatedTarget)||l(!1)},e[11]=C):C=e[11];const S=C;let _;e[12]!==h?(_=I=>{I.preventDefault(),l(!1),I.dataTransfer.files.length>0&&h(I.dataTransfer.files)},e[12]=h,e[13]=_):_=e[13];const P=_;let A;e[14]!==h?(A=I=>{var L;const D=(L=I.clipboardData)==null?void 0:L.items;if(!D)return;const O=Array.from(D).filter(mS);if(O.length===0)return;I.preventDefault();const $=O.map(fS).filter(Boolean);h($)},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,R=!t&&o.length>0;let M;return e[16]!==N||e[17]!==P||e[18]!==T||e[19]!==o||e[20]!==a||e[21]!==E||e[22]!==R?(M={images:o,isDragOver:a,imageError:E,hasUnsupportedAttachments:R,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]=R,e[23]=M):M=e[23],M}function fS(n){return n.getAsFile()}function mS(n){return n.type.startsWith("image/")}function pS(n){return n.type.startsWith("image/")}function hS(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(Rv,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function _t(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(hS,{children:r.jsx(Av,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Tt(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(Ev,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Et(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(Pv,{"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(Iv,{children:r.jsx(Mv,{align:u,alignOffset:m,side:d,sideOffset:f,className:"isolate z-50",children:h})}),e[14]=u,e[15]=m,e[16]=d,e[17]=f,e[18]=h,e[19]=g):g=e[19],g}const Cn="rounded-full border bg-background/80 shadow-sm backdrop-blur",ba=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}),rl=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(Z,{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(Tt,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(Et,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(_t,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function gS(n){return n<10?"critical":n<30?"warning":"healthy"}const xS={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Pg=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=cg(s);if(!P){x=null;break e}const A=Math.max(0,100-P.percent),T=gS(A);if(d&&T==="healthy"){x=null;break e}const E=Math.max(0,P.compactAt-P.used);let R;t[17]!==A||t[18]!==E||t[19]!==l?(R=l?`${A.toFixed(0)}% · ${tt(E)}`:`${A.toFixed(0)}%`,t[17]=A,t[18]=E,t[19]=l,t[20]=R):R=t[20];const M=R,I=xS[T],D=l&&"gap-1";let O;t[21]!==I||t[22]!==D?(O=G("shrink-0 tabular-nums",I,D),t[21]=I,t[22]=D,t[23]=O):O=t[23];let $;t[24]!==M||t[25]!==O?($=r.jsx(Ee,{variant:"outline",className:O,children:M}),t[24]=M,t[25]=O,t[26]=$):$=t[26];const L=$;if(!c){x=L;break e}u=_t,t[27]!==L?(g=r.jsx(Tt,{render:L}),t[27]=L,t[28]=g):g=t[28],f=Et,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=tt(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=tt(P.used),y=" / ",j=tt(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 bS(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=it(),{chat:a}=_r(),{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:xw(o)}),r.jsx(ba,{})]}),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 vS(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}=_r(),{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)??Ct((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=_w(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(_t,{children:[r.jsx(Tt,{render:r.jsx(Z,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:r.jsx(Lc,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(Et,{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&&Ht(g).stopSession&&r.jsxs(_t,{children:[r.jsx(Tt,{render:r.jsx(Z,{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($v,{"data-icon":"inline-start"})}),r.jsx(Et,{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(Ov,{"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(Z,{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 Tf(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
|
+
`),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
|
+
`)||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(en,{"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(Z,{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(Ns,{children:[r.jsxs(Zn,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(en,{className:"size-4"}),"Error details"]}),r.jsx(es,{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(ft,{"data-icon":"inline-start"}):r.jsx(An,{"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(Z,{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(Qn,{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(Jn,{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 yS(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(Sh,{"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(Z,{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(Nt,{}),e[11]=u):u=e[11];let m;e[12]!==f?(m=r.jsx(Z,{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 wS(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 jS(n,e,t){return`${n.slice(0,e.start)}@${t} `}const va={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Er={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let Ag=va;const nc=new Set;function ao(n){Ag=(n==null?void 0:n.capabilities)??va;for(const e of nc)e()}function lt(n){return Ag[n]}function SS(n){return nc.add(n),()=>nc.delete(n)}function bn(n){const e=B.c(3);let t,s;return e[0]!==n?(t=()=>lt(n),s=()=>lt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),v.useSyncExternalStore(SS,t,s)}function kS(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function NS(n,e,t){const s=bn("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(kS(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 sc="cogpit-share-revoked";function CS(){window.dispatchEvent(new Event(sc))}async function Rg(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&&CS(),s}function Pr(n,e){return Rg(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function _S(){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 TS(n,e){return Pr("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function ES(){return Pr("/api/share/interrupt")}function PS(){return Pr("/api/share/stop")}async function AS(n,e){return(await Pr("/api/share/permission",{requestId:n,behavior:e})).ok}async function RS(n,e){try{const t=await Pr("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function IS(){try{const n=await Rg("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const MS=/^\/shared\/([^/]+)\/?$/;function Ig(n){const e=MS.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function ya(n){return Ig(n)!==null}function $S(n){return`/shared/${encodeURIComponent(n)}`}function PO(n){return[...n].join(", ")}async function Xc(n,e,t){if(ya(window.location.pathname))return RS(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 OS(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 wa(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 ni(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 DS(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 LS(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 oc=v.memo(v.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,compact:i=!1},a){var Fe;const l=bn("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}}=_r(),_=N||d,[P,A]=v.useState(""),[T,E]=v.useState(!1),[R,M]=v.useState(!1),[I,D]=v.useState(null),O=v.useRef(null),$=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:q,hasUnsupportedAttachments:V,dismissImageError:Y,removeImage:K,clearImages:X,handleDragOver:Q,handleDragLeave:J,handleDrop:ee,handlePaste:oe}=uS(e),[se,re]=v.useState(0),[ie,ae]=v.useState(0),[te,me]=v.useState(!1),de=P.startsWith("/")&&!P.includes(" "),le=de?P.slice(1):"",he=v.useMemo(()=>{if(!de)return[];const ne=le.toLowerCase(),ue=x.filter($e=>ne?$e.name.toLowerCase().includes(ne)||$e.description.toLowerCase().includes(ne):!0),ke=ue.filter($e=>$e.type==="command"),Ae=ue.filter($e=>$e.type==="skill");return[...ke,...Ae]},[de,le,x]),ge=v.useMemo(()=>wS(P),[P]),ce=!!(l&&ge&&s&&!te),ve=NS(s,(ge==null?void 0:ge.query)??"",ce);v.useEffect(()=>{re(0)},[le]),v.useEffect(()=>{ae(0)},[ge==null?void 0:ge.query]);const xe=pg(N),pe=(u==null?void 0:u.type)==="plan"?u.requestId??null:null;v.useEffect(()=>{$.current=pe,O.current=null,M(!1),D(null)},[pe]);const je=v.useCallback(async ne=>{const ue=u;if(!(c!=null&&c.sessionId)||(ue==null?void 0:ue.type)!=="question")return;const ke=ue.questions[0];if(!ke||!ne.trim())return;(await Xc(c.sessionId,ue.toolUseId,{[ke.question]:ne})).ok||C(ne)},[u,c==null?void 0:c.sessionId,C]),_e=v.useCallback(async(ne,ue,ke)=>{const Ae=u;if((Ae==null?void 0:Ae.type)==="plan"&&Ae.provider==="copilot"&&Ae.requestId&&(c!=null&&c.sessionId)){const $e=Ae.requestId;if(O.current)return!1;O.current=$e,M(!0),D(null);try{const We=await OS(c.sessionId,$e,{approved:ne,...ue?{selectedAction:ue}:{},...ke?{feedback:ke}:{}});return!We&&$.current===$e&&D("Couldn't send the plan response. Try again."),We}finally{O.current===$e&&(O.current=null,M(!1))}}return C(ne?"yes":ke||"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(ni(ne,L.current)))})},[H]),De=v.useCallback(ne=>{A(`/${ne.name} `),re(0),Re()},[Re]),Te=v.useCallback(ne=>{A(ne),Re()},[Re]),Ie=v.useCallback(ne=>{if(!ge)return;const ue=jS(P,ge,ne);A(ue),me(!0),ae(0),requestAnimationFrame(()=>{const ke=z.current;ke&&(ke.focus(),ke.selectionStart=ke.selectionEnd=ke.value.length,H(ni(ke,L.current)))})},[ge,P,H]),Le=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 _e(!1,void 0,ne))return;A(""),H(!1),z.current&&(z.current.style.height="auto");return}const ue=e&&U.length>0?U.map(ke=>({data:ke.data,mediaType:ke.mediaType})):void 0;C(ne,ue),A(""),X(),H(!1),z.current&&(z.current.style.height="auto")},[P,U,e,C,X,H,u,je,_e]),ze=v.useCallback(ne=>{if(ce&&ne.key==="Escape"){ne.preventDefault(),me(!0);return}if(ce&&ve.files.length>0){if(ne.key==="ArrowDown"){ne.preventDefault(),ae(ue=>ue<ve.files.length-1?ue+1:0);return}if(ne.key==="ArrowUp"){ne.preventDefault(),ae(ue=>ue>0?ue-1:ve.files.length-1);return}if(ne.key==="Tab"||ne.key==="Enter"&&!ne.shiftKey){ne.preventDefault();const ue=ve.files[ie];ue&&Ie(ue);return}}if(de&&he.length>0){if(ne.key==="ArrowDown"){ne.preventDefault(),re(ue=>ue<he.length-1?ue+1:0);return}if(ne.key==="ArrowUp"){ne.preventDefault(),re(ue=>ue>0?ue-1:he.length-1);return}if(ne.key==="Tab"||ne.key==="Enter"&&!ne.shiftKey){ne.preventDefault();const ue=he[se];ue&&De(ue);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(),Le())},[Le,_,S,ce,ve.files,ie,Ie,de,he,se,De]),Ue=v.useCallback(ne=>{A(ne.target.value),me(!1),H(ni(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),me(!1),requestAnimationFrame(()=>H(ni(z.current,L.current)))}}),[H]);const Se=(u==null?void 0:u.type)==="plan",He=(u==null?void 0:u.type)==="question",Oe=m.length>0,Ne=(P.trim().length>0||U.length>0)&&!V,fe=Ht(t??Bs).midTurnSteering&&_,Pe=ce?"file-suggestions":de?"slash-suggestions":void 0,Me=ce&&ve.files[ie]?`file-suggestion-${ie}`:de&&he[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:Q,onDragLeave:J,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"})}),de&&r.jsx(Gj,{suggestions:he,filter:le,loading:b,selectedIndex:se,onSelect:De,onHover:re,onEdit:f}),ce&&r.jsx(Qj,{files:ve.files,query:(ge==null?void 0:ge.query)??"",loading:ve.loading,selectedIndex:ie,onSelect:Ie,onHover:ae}),r.jsxs("div",{children:[Se&&r.jsx(nS,{allowedPrompts:u.allowedPrompts,summary:u.summary,planContent:u.planContent,actions:u.actions,recommendedAction:u.recommendedAction,responding:R,responseError:I,onApprove:ne=>{_e(!0,ne)},onReject:()=>{_e(!1)}}),r.jsx(yS,{suggestion:y,onAccept:Te}),U.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:U.map((ne,ue)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:ne.preview,alt:`Upload ${ue+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>K(ue),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 ${ue+1}`,children:r.jsx(Nt,{className:"size-3","data-icon":"icon"})})]},ne.id))}),q&&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:q}),!V&&r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:Y,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(Nt,{"data-icon":"icon"})})]}),r.jsxs("div",{className:G("relative overflow-hidden rounded-xl border bg-prompt-surface shadow-xs",LS(Se,He,Oe),"focus-within:ring-3"),children:[Oe&&r.jsx(aS,{requests:m,responding:p,onRespond:h,onRespondAll:g},(Fe=m[0])==null?void 0:Fe.requestId),r.jsxs("div",{className:G("grid min-w-0 items-end",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(wa,{ref:z,value:P,onChange:Ue,onKeyDown:ze,onPaste:oe,onFocus:()=>{setTimeout(()=>{var ne;return(ne=z.current)==null?void 0:ne.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:DS(Se,He,N,Oe,fe,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Pe,"aria-controls":Pe,"aria-activedescendant":Me,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(bS,{isPlanApproval:Se,isUserQuestion:He,elapsedSec:xe}),r.jsx(vS,{hasContent:Ne,onSubmit:Le,submitLabel:fe?"Steer active turn":"Send message"})]})]})]}),j==="error"&&k&&r.jsx(Tf,{error:k},k),w&&r.jsx(Tf,{error:w},w)]})]})}));function zS(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function FS(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=zS(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 si(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function zt(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(Dv,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ar(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(BS,{children:r.jsx(US,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(Lv,{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 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("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(zv,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function US(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(Fv,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const WS={section:null,canCreate:!1,beginEditing:()=>{}},Jc=v.createContext(WS);function Mg(){return v.useContext(Jc)}const $g="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",Og="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function HS(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function KS(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function qS({agentKind:n,threadId:e,children:t}){const s=ga(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(si(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(si(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(si(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(si(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:Og,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(tr,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(Co,{className:"gap-2",children:[r.jsxs(gt,{children:[r.jsx(xt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(wa,{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(zt,{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(fs,{className:"mt-1.5",children:x}),r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(!1),children:[r.jsx(Nt,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(Z,{type:"submit",size:"xs",disabled:h||!f.trim(),children:[r.jsx(ft,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const P=o.status==="paused",A=o.status==="complete";S=r.jsxs("section",{className:$g,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(tr,{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(Ee,{variant:KS(o.status),children:HS(o.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[tt(o.tokensUsed),o.tokenBudget?` / ${tt(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(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx(ko,{"data-icon":"icon"})}),!P&&!A&&r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(Bv,{"data-icon":"icon"})}),!A&&r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(ft,{"data-icon":"icon"})}),r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:y,"aria-label":"Edit goal",children:r.jsx(Fs,{"data-icon":"icon"})}),r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void N(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(na,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(Ar,{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(Jc.Provider,{value:_,children:t})}function VS(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function GS(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function YS(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=ga(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=FS(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 D=h.trim();if(D){if(D.length>4e3){b("Goal conditions can be at most 4,000 characters");return}u({condition:D,status:"active",iterations:0,durationMs:0,tokens:0}),p(!1),o(`/goal ${D}`)}},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 D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(tr,{className:"size-3.5","data-icon":"inline-start"}),e[20]=D):D=e[20];const O=k?"Replace goal":"Set a long-running goal";let $;e[21]!==O?($=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[D,O]}),e[21]=O,e[22]=$):$=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(wa,{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 q;e[29]!==x?(q=r.jsx(fs,{children:x}),e[29]=x,e[30]=q):q=e[30];let V;e[31]!==W||e[32]!==q||e[33]!==L?(V=r.jsxs(gt,{"data-invalid":L,children:[F,W,q]}),e[31]=W,e[32]=q,e[33]=L,e[34]=V):V=e[34];let Y;e[35]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[r.jsx(Nt,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=Y):Y=e[35];let K;e[36]!==h?(K=h.trim(),e[36]=h,e[37]=K):K=e[37];const X=!K;let Q;e[38]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(ft,{"data-icon":"inline-start"}),e[38]=Q):Q=e[38];let J;e[39]!==_||e[40]!==X?(J=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,r.jsxs(Z,{type:"button",size:"xs",onClick:_,disabled:X,children:[Q,"Start goal"]})]}),e[39]=_,e[40]=X,e[41]=J):J=e[41],T=r.jsxs("section",{className:Og,"aria-label":`${l} goal editor`,children:[$,V,J]})}else if(k){let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(tr,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=D):D=e[42];let O;e[43]!==k.condition?(O=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]=O):O=e[44];let $;e[45]!==k.status?($=GS(k.status),e[45]=k.status,e[46]=$):$=e[46];let L;e[47]!==k.status?(L=VS(k.status),e[47]=k.status,e[48]=L):L=e[48];let F;e[49]!==$||e[50]!==L?(F=r.jsx(Ee,{variant:$,children:L}),e[49]=$,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=tt(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 q=Math.max(0,W);let V;e[56]!==k.iterations||e[57]!==H||e[58]!==U||e[59]!==q?(V=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[z," turn",H," · ",U," · ",q,"m"]}),e[56]=k.iterations,e[57]=H,e[58]=U,e[59]=q,e[60]=V):V=e[60];let Y;e[61]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Fs,{"data-icon":"icon"}),e[61]=Y):Y=e[61];let K;e[62]!==C?(K=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:Y}),e[62]=C,e[63]=K):K=e[63];let X;e[64]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(na,{"data-icon":"icon"}),e[64]=X):X=e[64];let Q;e[65]!==A?(Q=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:X}),e[65]=A,e[66]=Q):Q=e[66];let J;e[67]!==K||e[68]!==Q?(J=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[K,Q]}),e[67]=K,e[68]=Q,e[69]=J):J=e[69];let ee;e[70]!==F||e[71]!==V||e[72]!==J||e[73]!==O?(ee=r.jsxs("div",{className:"flex items-center gap-2",children:[D,O,F,V,J]}),e[70]=F,e[71]=V,e[72]=J,e[73]=O,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:$g,"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 R;e[77]!==C||e[78]!==T||e[79]!==E?(R={section:T,canCreate:E,beginEditing:C},e[77]=C,e[78]=T,e[79]=E,e[80]=R):R=e[80];const M=R;let I;return e[81]!==i||e[82]!==M?(I=r.jsx(Jc.Provider,{value:M,children:i}),e[81]=i,e[82]=M,e[83]=I):I=e[83],I}function XS(n){const e=B.c(9),{agentKind:t,session:s,onSendCommand:o,children:i}=n,a=Ht(t).goals;if(a==="thread-api"){let l;return e[0]!==t||e[1]!==i||e[2]!==s.sessionId?(l=r.jsx(qS,{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(YS,{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 Dg(){return Mg().section}function Lg(){const n=B.c(3),{canCreate:e,beginEditing:t}=Mg();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(tr,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let o;return n[1]!==t?(o=r.jsxs(Z,{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 JS(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(Dg,{}),r.jsx(Lg,{})]}),n[0]=e):e=n[0],e}const QS=/\x1b\].*?(?:\x07|\x1b\\)/g,ZS=/\x1b\[[0-9;]*[A-Za-z]/g,e4=/\x1b[()][AB012]/g,t4=/\[2K\[1G/g;function zg(n){return n.replace(QS,"").replace(ZS,"").replace(e4,"").replace(t4,`
|
|
5
|
+
`).replace(/\r/g,"")}function To(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(Wv,{"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(n4,{}),c=r.jsx(Hv,{}),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(Uv,{"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 n4(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(qv,{"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(Kv,{"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 Fg(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 s4(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 o4(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 r4(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 At(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=Fg,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 i4(n){const e=bn("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 Ef=500,a4=5e3;function l4(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(Ef),m=v.useRef(null),p=v.useRef(!1),h=v.useRef(c4);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}${Qh()}/__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=Ef,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,a4),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 R=E;let M;e[16]!==j?(M=(L,F)=>{j({type:"input",id:L,data:F})},e[16]=j,e[17]=M):M=e[17];const I=M;let D;e[18]!==j?(D=(L,F,z)=>{j({type:"resize",id:L,cols:F,rows:z})},e[18]=j,e[19]=D):D=e[19];const O=D;let $;return e[20]!==R||e[21]!==O||e[22]!==j||e[23]!==a||e[24]!==T||e[25]!==P||e[26]!==s||e[27]!==I?($={status:s,send:j,subscribe:N,unsubscribe:S,sessions:a,spawnTerminal:P,spawnScript:T,killSession:R,writeInput:I,resize:O},e[20]=R,e[21]=O,e[22]=j,e[23]=a,e[24]=T,e[25]=P,e[26]=s,e[27]=I,e[28]=$):$=e[28],$}function c4(){}const Bg=v.createContext(null);function il(n){const e=B.c(3),{children:t,enabled:s}=n,i=l4(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(Bg.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function Qc(){const n=v.useContext(Bg);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function d4(n){var f;const e=B.c(11),t=Qc();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 u4(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(Lc,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(ko,{"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(Z,{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 f4=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}=i4(s),{runningProcesses:h,runScript:g,stopScript:x}=d4(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(At,{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(m4),c("")},A=r.jsx(ln,{}),t[10]=P,t[11]=A):(P=t[10],A=t[11]);let T;t[12]!==i||t[13]!==_?(T=r.jsx(Z,{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 R;t[18]!==i||t[19]!==l?(R=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(zt,{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]=R):R=t[20];let M;t[21]!==f||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?(M=[...w.entries()].map(F=>{const[z,H]=F,U=f.has(z)||!!l,W=H.filter(p4),q=H.filter(h4),V=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}),V.map(Y=>{const K=j.get(`${Y.name}:${Y.dir}`);return r.jsx(u4,{script:Y,status:(K==null?void 0:K.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{K&&x(K.id)}},`${z}:${Y.name}`)}),!l&&q.length>0&&r.jsx(Z,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>N(z),children:U?"Show less":`Show ${q.length} more`})]},z)}),t[21]=f,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=M):M=t[27];let I;t[28]!==w.size||t[29]!==p||t[30]!==l?(I=!p&&w.size===0&&l&&r.jsx(In,{className:"gap-1 p-3",children:r.jsxs(Mn,{className:"gap-1",children:[r.jsx($n,{children:"No matching scripts"}),r.jsx(On,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=I):I=t[31];let D;t[32]!==M||t[33]!==I?(D=r.jsxs(To,{className:"min-h-0 flex-1 px-1 pb-1",children:[M,I]}),t[32]=M,t[33]=I,t[34]=D):D=t[34];let O;t[35]!==R||t[36]!==D||t[37]!==E?(O=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,R,D]}),t[35]=R,t[36]=D,t[37]=E,t[38]=O):O=t[38];let $;t[39]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Mt,{orientation:"vertical"}),t[39]=$):$=t[39];let L;return t[40]!==O?(L=r.jsxs(r.Fragment,{children:[O,$]}),t[40]=O,t[41]=L):L=t[41],L});function m4(n){return!n}function p4(n){return n.isCommon}function h4(n){return!n.isCommon}function Ug(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(Yv,{"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 g4=Gn("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 Wg(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(g4({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(Jv,{"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(Gv,{"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 Fo(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(Xv,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Bo(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(Vv,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const x4=v.lazy(()=>Ke(()=>import("./TerminalOutput-Aavw8QCx.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function b4({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=kr(`/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=zg(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 v4(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(Ee,{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(Fo,{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(Nt,{"data-icon":"inline-start"}),e[25]=N):N=e[25];let C;e[26]!==i||e[27]!==j||e[28]!==k?(C=r.jsx(Z,{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 Hg=100,Kg=600,y4=200,qg="process-panel-height";function w4(){try{const n=localStorage.getItem(qg);if(n)return Math.min(Kg,Math.max(Hg,Number(n)))}catch{}return y4}const j4=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=Qc(),[b,w]=v.useState(w4),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 ve=y.current.startY-ce.clientY,xe=Math.min(Kg,Math.max(Hg,y.current.startH+ve));w(xe)},t[9]=P):P=t[9];const A=P;let T;t[10]!==b?(T=()=>{if(y.current){y.current=null;try{localStorage.setItem(qg,String(b))}catch{}}},t[10]=b,t[11]=T):T=t[11];const E=T;let R;t[12]!==o||t[13]!==s?(R=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=R):R=t[14];const M=R;let I;t[15]!==s?(I=[...s.values()],t[15]=s,t[16]=I):I=t[16];const D=I;let O;t[17]!==a?(O=ce=>{typeof ce=="string"&&a(ce)},t[17]=a,t[18]=O):O=t[18];let $;t[19]!==M||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==E?($=!g&&!i&&M&&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]=M,t[20]=i,t[21]=g,t[22]=_,t[23]=E,t[24]=$):$=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(Je,{"data-icon":"inline-start"}):r.jsx(Ze,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const W=g&&"sr-only";let q;t[29]!==W?(q=G(W),t[29]=W,t[30]=q):q=t[30];let V;t[31]!==q?(V=r.jsx("span",{className:q,children:"Terminal"}),t[31]=q,t[32]=V):V=t[32];let Y;t[33]!==c||t[34]!==z||t[35]!==H||t[36]!==U||t[37]!==V?(Y=r.jsxs(Z,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":z,"aria-expanded":H,children:[U,V]}),t[33]=c,t[34]=z,t[35]=H,t[36]=U,t[37]=V,t[38]=Y):Y=t[38];const K=!g&&"ml-2";let X;t[39]!==K?(X=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",K),t[39]=K,t[40]=X):X=t[40];let Q;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==D?(Q=D.map(ce=>r.jsx(v4,{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]=D,t[46]=Q):Q=t[46];let J;t[47]!==X||t[48]!==Q?(J=r.jsx(Wg,{variant:"default","aria-label":"Open processes",className:X,children:Q}),t[47]=X,t[48]=Q,t[49]=J):J=t[49];let ee;t[50]!==d||t[51]!==m?(ee=d&&r.jsx(Z,{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]!==J||t[56]!==ee?(oe=r.jsxs("div",{className:F,children:[Y,J,ee]}),t[53]=F,t[54]=Y,t[55]=J,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(f4,{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]!==D?(te=D.map(ce=>r.jsx(Bo,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?r.jsx(b4,{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(x4,{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]=D,t[68]=te):te=t[68];let me;t[69]!==M||t[70]!==d||t[71]!==m?(me=!M&&r.jsxs(In,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:r.jsx(No,{})}),r.jsx($n,{children:"No terminal open"}),r.jsx(On,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(Xh,{children:r.jsxs(Z,{type:"button",size:"sm",onClick:d,children:[r.jsx(Tn,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=M,t[70]=d,t[71]=m,t[72]=me):me=t[72];let de;t[73]!==te||t[74]!==me?(de=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[te,me]}),t[73]=te,t[74]=me,t[75]=de):de=t[75];let le;t[76]!==ie||t[77]!==ae||t[78]!==de?(le=r.jsx(wt,{children:r.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,de]})}),t[76]=ie,t[77]=ae,t[78]=de,t[79]=le):le=t[79];let he;t[80]!==se||t[81]!==le?(he=r.jsx(yt,{open:se,className:"min-h-0",children:le}),t[80]=se,t[81]=le,t[82]=he):he=t[82];let ge;return t[83]!==o||t[84]!==O||t[85]!==$||t[86]!==oe||t[87]!==he?(ge=r.jsxs(Ug,{value:o,onValueChange:O,className:"shrink-0 gap-0 border-t bg-background",children:[$,oe,he]}),t[83]=o,t[84]=O,t[85]=$,t[86]=oe,t[87]=he,t[88]=ge):ge=t[88],ge});function ts(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 S4=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function k4(n){const e=new Set;for(const t of n.matchAll(S4)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function N4(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=k4(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 Pf(n){var e;return((e=n.preview.split(`
|
|
6
|
+
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function C4(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(Ee,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Vg({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=v.useState([]),a=N4(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:Pf(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(ts,{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=Pf(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(Nh,{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(C4,{port:u,isActive:c.portStatus[u]},u)),r.jsx("div",{className:"flex-1"}),c.outputPath&&r.jsx(Z,{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(No,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(Z,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(u=>l(u)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(Lc,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function Zc(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(Qv,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function _4(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(Zv,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function T4(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($c,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function E4(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(Oc,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ed(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(E4,{}),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(T4,{children:[a,r.jsx(Rc,{"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 td(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 nd(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 P4(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 sd(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(Ic,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function od(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(Mc,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function rd(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(Z,{"data-slot":"alert-dialog-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function id(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(Z,{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(Zi,{"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 Gg(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(ty,{"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(ft,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(ey,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const A4={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},R4={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 I4({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(Zc,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(ed,{children:[r.jsxs(td,{children:[r.jsx(P4,{children:r.jsx(yn,{className:"text-warning"})}),r.jsx(sd,{children:A4[c.type]}),r.jsx(od,{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.":R4[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(Gg,{checked:f,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(St,{variant:"destructive",children:r.jsx(kt,{children:t})}),r.jsxs(nd,{children:[r.jsx(id,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(rd,{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 Dt(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 Bt(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 Vt(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 Gt(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 ad(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 Lt(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 Eo(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 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("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 M4=Gn("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 vn(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(M4({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:$4,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function $4(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const O4=Gn("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 Rr(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(O4({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(Z,{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 ss(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(zt,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function D4(){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 ro=s3(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),Yg=da().filter(n=>n.cli.homeIsDiscoverable);function Xg(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function Jg(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 L4=Xg(Yg.map(n=>n.displayName)),z4=Xg(Yg.map(n=>r.jsx(Jg,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),F4=`~/${ro.cli.homeDirName}`;function B4(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}=D4();let u;e[0]!==d?(u=$=>{const L=$.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 $=await f(s);$.success&&$.claudeDir&&t($.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=$=>{$.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(Dc,{className:"size-4"})}),b=r.jsx(Vt,{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(Bt,{children:[x,b,r.jsxs(Gt,{children:["Cogpit detects ",L4," automatically. Existing histories live in"," ",z4,"."," ","For ",ro.displayName,", enter its data directory, usually"," ",r.jsx(Jg,{children:F4}),"."]})]}),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:[ro.displayName," data directory"]}),e[13]=j):j=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(vn,{children:r.jsx(ho,{"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(ns,{children:[k,r.jsx(ss,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${ro.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(xo,{className:"flex items-center gap-2",children:[r.jsx(At,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=S):S=e[20];let _;e[21]!==l?(_=l==="valid"&&r.jsxs(xo,{className:"flex items-center gap-2 text-success",children:[r.jsx(ea,{className:"size-4"}),ro.displayName," history found"]}),e[21]=l,e[22]=_):_=e[22];let P;e[23]!==c||e[24]!==l?(P=l==="invalid"&&c&&r.jsxs(fs,{className:"flex items-center gap-2",children:[r.jsx(Ss,{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(Lt,{children:r.jsx(Co,{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 R;e[34]!==i?(R=i&&r.jsx(At,{"data-icon":"inline-start"}),e[34]=i,e[35]=R):R=e[35];const M=i?"Saving...":`Connect ${ro.displayName}`;let I;e[36]!==E||e[37]!==R||e[38]!==M?(I=r.jsx(Eo,{children:r.jsxs(Z,{type:"submit",className:"w-full",disabled:E,children:[R,M]})}),e[36]=E,e[37]=R,e[38]=M,e[39]=I):I=e[39];let D;e[40]!==T||e[41]!==I?(D=r.jsxs(Dt,{children:[w,T,I]}),e[40]=T,e[41]=I,e[42]=D):D=e[42];let O;return e[43]!==D||e[44]!==g?(O=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:D})}),e[43]=D,e[44]=g,e[45]=O):O=e[45],O}const Qg=/^[a-z]:[\\/]/i;function ld(n){return(Qg.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function Af(n){const e=ld(n);return Qg.test(n)?e.toLowerCase():e}function U4(n){const e=ld(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Rf(n,e){const t=Af(n),s=Af(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?ld(e).slice(o.length):null}let cd=!1;function W4(n){cd=n}function dd(){return cd}let Go=null;function H4(n){return Go=n,()=>{Go===n&&(Go=null)}}function K4(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=Rf(e,n.path);if(o)return{root:e,file:o,mode:If(n),line:n.line}}const t=U4(n.path),s=Rf(t,n.path);return s?{root:t,file:s,mode:If(n),line:n.line}:null}function If(n){return n.mode==="diff"?"diff":"edit"}function Zg(n){return cd&&Go!==null&&Go(n)}function e1(n,e){ye(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function ir(n,e={}){if(lt("hostFiles")&&!Zg({kind:"file",path:n,...e})){if(Os()){Sr(n);return}e1("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function t1(n){lt("hostFiles")&&(n.path&&Zg({kind:"project",path:n.path})||s1("/api/open-in-editor",n))}function n1(n){lt("hostFiles")&&s1("/api/reveal-in-folder",n)}function s1(n,e){!e.path&&!e.dirName||e1(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let al=null;const rc=new Set,oi=new Map,Mf=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],o1={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 r1(){return al||(al=(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),...Mf.map(o=>o1[o]().then(i=>i.default))]),s=await Gy({themes:[n,e],langs:t,engine:Yy()});for(const o of Mf)rc.add(o);return s})()),al}async function i1(n,e){if(rc.has(e))return;if(oi.has(e))return oi.get(e);const t=o1[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),rc.add(e)}).finally(()=>oi.delete(e));oi.set(e,s),await s}const q4={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 a1(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return q4[e]??null}async function ud(n,e,t){try{const s=await r1();await i1(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}function Ir(){const n=B.c(2),[e,t]=v.useState(V4);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 V4(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const G4={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 Y4(n){return G4[n.toLowerCase()]??n}function X4(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function J4(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;Sr(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(ft,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(An,{"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(Z,{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 Q4(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 Z4(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
|
+
`);let a;e[4]!==s?(a=X4(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(e5,{code:f,lang:l,...o}),e[12]=f,e[13]=l,e[14]=o,e[15]=u):u=e[15],u}function e5(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=Ir(),[a,l]=v.useState(null),[c,d]=v.useState(!1),f=t.split(`
|
|
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 ud(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?Je:Ze,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(Z,{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(Ee,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:Y4(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(J4,{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 R=h==null?void 0:h[E];return r.jsxs("span",{className:"block",children:[r.jsx(Q4,{num:E+1}),R?R.map(t5):T||" "]},E)})})})});let P;e[28]!==c||e[29]!==u?(P=c&&r.jsxs(Z,{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 t5(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var Rs=function(n,e){return Number(n.toFixed(e))},n5=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},s5=function(n){return-Math.cos(n*Math.PI)/2+.5},o5=function(n){return n},r5=function(n){return n*n},i5=function(n){return n*(2-n)},a5=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},l5=function(n){return n*n*n},c5=function(n){return--n*n*n+1},d5=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},u5=function(n){return n*n*n*n},f5=function(n){return 1- --n*n*n*n},m5=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},p5=function(n){return n*n*n*n*n},h5=function(n){return 1+--n*n*n*n*n},g5=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},l1={easeOut:s5,linear:o5,easeInQuad:r5,easeOutQuad:i5,easeInOutQuad:a5,easeInCubic:l5,easeOutCubic:c5,easeInOutCubic:d5,easeInQuart:u5,easeOutQuart:f5,easeInOutQuart:m5,easeInQuint:p5,easeOutQuint:h5,easeInOutQuint:g5},c1=function(n){typeof n=="number"&&cancelAnimationFrame(n)},fn=function(n){n.mounted&&(c1(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function d1(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;fn(n),n.animation=function(){if(!n.mounted)return c1(n.animation);var a=new Date().getTime()-o,l=a/t,c=l1[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function x5(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function Cs(n,e,t,s){var o=x5(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):d1(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 b5(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 v5=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}},fd=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=b5(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,f=l.newContentWidth,u=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=v5(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},ar=function(n,e,t,s){return s?n<e?Rs(e,2):n>t?Rs(t,2):Rs(n,2):Rs(n,2)},bo=function(n,e){var t=fd(n,e);return n.bounds=t,t};function Mr(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=ar(n,l-u,d+u,s),h=ar(e,c-m,f+m,s);return{x:p,y:h}}function ja(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=Mr(u,m,o,i,0,0,null);return p}var $f=1e-7;function $r(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,$f),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,$f)}var Of=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,o=n.wrapperComponent,i=e.target,a="shadowRoot"in i&&"composedPath"in e,l=a?e.composedPath().some(function(f){return f instanceof Element?o==null?void 0:o.contains(f):!1}):o==null?void 0:o.contains(i),c=s&&i&&l;if(!c)return!1;var d=Or(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},Df=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},y5=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}},w5=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 j5(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=ja(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 u1(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=Mr(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var S5=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}},ws=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},cs;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(cs||(cs={}));var k5=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},N5=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 C5(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 Lf(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:ar(n,i,a,o)}function _5(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var ll=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 T5(n,e,t){var s,o,i=k5(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=_5(d),b=(s={},s[cs.TOUCH]=p,s[cs.MOUSE]=h,s)[t],w=(o={},o[cs.TOUCH]=m,o[cs.MOUSE]=u,o)[t],y=e.x-a.x,j=e.y-a.y,k=ll(y/x,w,b),N=ll(j/x,w,b),C=g-l,S=y*y+j*j,_=ll(Math.sqrt(S)/C,w,b);n.velocity={velocityX:k,velocityY:N,total:_}}n.lastMousePosition=e,n.velocityTime=g}}function E5(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=N5(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=C5(n,c),_=Math.max(S,C),P=ws(n,j),A=ws(n,k),T=P*o.offsetWidth/100,E=A*o.offsetHeight/100,R=d+T,M=f-T,I=u+E,D=m-E,O=n.state,$=new Date().getTime();d1(n,y,_,function(L){var F=n.state,z=F.scale,H=F.positionX,U=F.positionY,W=new Date().getTime()-$,q=W/C,V=l1[h.animationType],Y=1-V(Math.min(1,q)),K=1-L,X=H+a*K,Q=U+l*K,J=Lf(X,O.positionX,H,w,p,f,d,M,R,Y),ee=Lf(Q,O.positionY,U,b,p,m,u,D,I,Y);if(H!==X||U!==Q){n.setState(z,J,ee);var oe=n.props.onPanning;oe&&oe(Ye(n),{})}})}}function zf(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},fn(n),bo(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?w5(n,e):y5(n,e)}function f1(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=j5(n);m&&Cs(n,m,d,f)}}function Ff(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=S5(n,e,t),f=d.x,u=d.y,m=ws(n,l),p=ws(n,c);T5(n,{x:f,y:u},s),u1(n,f,u,m,p)}}function P5(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?E5(n):f1(n)}}function md(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=$r(Rs(e,2),i,a,0,!1),d=bo(n,c),f=ja(n,t,s,c,d,l),u=f.x,m=f.y;return{scale:c,positionX:u,positionY:m}}function pd(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)&&f1(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,b=s<a?a:l,w=md(n,b,g,x);w&&Cs(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 Bf(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 cl={scale:1,positionX:0,positionY:0},As={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"}},ic={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},m1=function(n){var e,t,s,o,i,a,l,c,d,f=Math.max((e=n.minScale)!==null&&e!==void 0?e:As.minScale,1e-7),u=(t=n.maxScale)!==null&&t!==void 0?t:As.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:cl.scale,p=Math.min(Math.max(m,f),u),h=ar((o=n.initialPositionX)!==null&&o!==void 0?o:cl.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=ar((l=n.initialPositionY)!==null&&l!==void 0?l:cl.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}},Uf=function(n){var e=rn({},As);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof As[s]<"u";if(i&&o){var a=Object.prototype.toString.call(As[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=rn(rn({},As[s]),n[s]):c?e[s]=Bf(Bf([],As[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},p1=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=$r(Rs(u,3),l,a,f,!1);return m};function h1(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=p1(n,e,t),y=md(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),Cs(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 g1(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,f=a.centerOnInit,u=m1(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=hd(u.scale,l,c);x=w.positionX,b=w.positionY}var y=fd(n,u.scale),j=Mr(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),Cs(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 A5(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 R5(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=A5(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=$r(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=fd(n,k),A=Mr(S,_,P,d,0,0,i),T=A.x,E=A.y;return{positionX:T,positionY:E,scale:k}}var I5=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),h1(n,1,e,t,s)}},M5=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),h1(n,-1,e,t,s)}},$5=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};Cs(n,p,o,i)}}},O5=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),g1(n,e,t)}},D5=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=hd(e||o.scale,i,a);Cs(n,l,t,s)}}},L5=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=R5(n,c,t,i,a);Cs(n,d,s,o)}}},ac=function(n){return{instance:n,state:n.state,zoomIn:I5(n),zoomOut:M5(n),setTransform:$5(n),resetTransform:O5(n),centerView:D5(n),zoomToElement:L5(n)}},z5=function(n){return{instance:n,state:n.state}},Ye=function(n){var e={};return Object.assign(e,z5(n)),Object.assign(e,ac(n)),e},dl=!1;function ul(){try{var n={get passive(){return dl=!0,!1}};return n}catch{return dl=!1,dl}}var ri=".".concat(ic.wrapperClass),Or=function(n,e){return e.some(function(t){return n.matches("".concat(ri," ").concat(t,", ").concat(ri," .").concat(t,", ").concat(ri," ").concat(t," *, ").concat(ri," .").concat(t," *"))})},lr=function(n){n&&clearTimeout(n)},F5=function(n){return Number.parseFloat(n.toFixed(8))},x1=function(n,e,t){var s=F5(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},hd=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 B5(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function U5(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var b1=function(n,e){var t=n.setup.wheel,s=t.disabled,o=t.wheelDisabled,i=t.touchPadDisabled,a=t.excluded,l=n.isInitialized,c=n.isPanning,d=e.target,f=l&&!c&&!s&&d;if(!f||o&&!e.ctrlKey||i&&e.ctrlKey)return!1;var u=Or(d,a);if(u)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},W5=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=b1(n,e);if(l)return!1;var c=e.target,d=Or(c,a);if(d)return!1;var f=n.isPressingKeys(i);return!!f},H5=function(n){return n?n.deltaY<0?1:-1:0};function K5(n,e){var t=H5(n),s=n5(e,t);return s}function v1(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 q5=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=$r(h,d,c,m,g&&!u);return x},y1=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},V5=function(n,e){var t=n.setup.pinch,s=t.disabled,o=t.excluded,i=n.isInitialized,a=e.target,l=i&&!s&&a;if(!l)return!1;var c=Or(a,o);return!c},G5=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},Y5=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}},w1=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))},X5=5,J5=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/X5),x=t+g,b=x===1/0?0:Rs(x,10);return $r(b,a,i,f,!u&&!c)},j1=160,S1=100,Q5=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))},Z5=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=K5(e,null),y=h?b*Math.abs(e.deltaY):b,j=q5(n,w,y,!e.ctrlKey);if(c!==j){var k=bo(n,j),N=v1(e,i,c),C=x||g===0||f||p,S=d&&C,_=ja(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)}},ek=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;lr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(pd(n,e.x,e.y),n.wheelAnimationTimer=null)},S1);var i=y1(n,e);i&&(lr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Ye(n),e,s),Qe(Ye(n),e,o))},j1))},tk=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))},nk=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;lr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(pd(n,e.x,e.y),n.wheelAnimationTimer=null)},S1);var i=y1(n,e);i&&(lr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Ye(n),e,s),Qe(Ye(n),e,o))},j1))},k1=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}},sk=function(n,e){var t=w1(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=k1(e),fn(n)},ok=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=Y5(e,a,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=w1(e),y=J5(n,w),j=k1(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=bo(n,y),_=h||g===0||d,P=c&&_,A=ja(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 R=u.sizeX,M=u.sizeY,I=ws(n,R,y),D=ws(n,M,y),O=T+N,$=E+C,L=Mr(O,$,S,c,I,D,o),F=L.x,z=L.y;n.setState(y,F,z)}}}}},rk=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,pd(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;lr(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Ye(n),e,t)},s)},ik=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),g1(n,a,l,function(){return Qe(Ye(n),e,o)}),N1(n,e)};function ak(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function lk(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 ik(n,e);if(!i)return console.error("No ContentComponent found");var x=ak(m,n.state.scale),b=p1(n,x,p);if(a!==b){Qe(Ye(n),e,c);var w=v1(e,i,a),y=md(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),Cs(n,y,h,g),N1(n,e)}}}var ck=function(n,e){var t=n.isInitialized,s=n.setup,o=n.wrapperComponent,i=s.doubleClick,a=i.disabled,l=i.excluded,c=e.target,d=o==null?void 0:o.contains(c),f=t&&c&&d&&!a;if(!f)return!1;var u=Or(c,l);return!u},dk=(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&&bo(t,t.state.scale),t.setup=Uf(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=ul(),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=ul(),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=ul();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=b1(t,s);i&&(Q5(t,s),Z5(t,s),ek(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=W5(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=ws(t,b),j=ws(t,w);h===f&&g===u||(tk(t,s),u1(t,h,g,y,j),Qe(Ye(t),s,o),nk(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=Of(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),zf(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=Df(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Ff(t,s.clientX,s.clientY,cs.MOUSE),Qe(Ye(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(P5(t,o),Qe(Ye(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=V5(t,s);a&&(sk(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=G5(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),ok(t,s),Qe(Ye(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(rk(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=Of(t,s);if(u){if(!p)return;fn(t),zf(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=Df(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Ff(t,l.clientX,l.clientY,cs.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=ck(t,s);i&&lk(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=hd(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):x1(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,bo(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),B5(t.props.ref,i)},this.props=e,this.setup=Uf(this.props),this.state=m1(this.props)}return n})(),Sa=be.createContext(null),uk=function(n,e){return typeof n=="function"?n(e):n},fk=be.forwardRef(function(n,e){var t=v.useRef(new dk(n)).current,s=uk(n.children,ac(t));return v.useImperativeHandle(e,function(){return ac(t)},[t]),v.useEffect(function(){t.update(n)},[t,n]),r.jsx(Sa.Provider,rn({value:t},{children:s}))});be.forwardRef(function(n,e){var t=v.useRef(null),s=v.useContext(Sa);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:U5([t,e])}))});function mk(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 pk=`.transform-component-module_wrapper__SPB86 {
|
|
9
|
+
position: relative;
|
|
10
|
+
width: -moz-fit-content;
|
|
11
|
+
width: fit-content;
|
|
12
|
+
height: -moz-fit-content;
|
|
13
|
+
height: fit-content;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
16
|
+
-webkit-user-select: none; /* Safari */
|
|
17
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
18
|
+
-moz-user-select: none; /* Firefox */
|
|
19
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
20
|
+
user-select: none;
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 0;
|
|
23
|
+
transform: translate3d(0, 0, 0);
|
|
24
|
+
}
|
|
25
|
+
.transform-component-module_content__FBWxo {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
width: -moz-fit-content;
|
|
29
|
+
width: fit-content;
|
|
30
|
+
height: -moz-fit-content;
|
|
31
|
+
height: fit-content;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
transform-origin: 0% 0%;
|
|
35
|
+
}
|
|
36
|
+
.transform-component-module_content__FBWxo img {
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
}
|
|
39
|
+
.transform-component-module_infiniteGrid__Z-aP3 {
|
|
40
|
+
position: absolute;
|
|
41
|
+
inset: 0;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
background-image: radial-gradient(
|
|
44
|
+
circle,
|
|
45
|
+
rgba(0, 0, 0, 0.12) 1px,
|
|
46
|
+
transparent 1px
|
|
47
|
+
);
|
|
48
|
+
background-size: 20px 20px;
|
|
49
|
+
background-position: 0 0;
|
|
50
|
+
}
|
|
51
|
+
`,fl={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};mk(pk);var hk=function(n){var e=n.children,t=n.wrapperClass,s=t===void 0?"":t,o=n.contentClass,i=o===void 0?"":o,a=n.wrapperStyle,l=n.contentStyle,c=n.wrapperProps,d=c===void 0?{}:c,f=n.contentProps,u=f===void 0?{}:f,m=n.infinite,p=m===void 0?!1:m,h=v.useContext(Sa),g=h.init,x=h.cleanupWindowEvents,b=v.useRef(null),w=v.useRef(null),y=v.useRef(null);return v.useEffect(function(){var j=b.current,k=w.current;return j!==null&&k!==null&&g&&(g==null||g(j,k)),function(){x==null||x()}},[]),v.useEffect(function(){if(p){var j=y.current;if(j){var k=function(){var N=h.state,C=N.positionX,S=N.positionY;j.style.backgroundPosition="".concat(C,"px ").concat(S,"px")};return k(),h.onChange(k)}}},[p,h]),r.jsxs("div",rn({},d,{ref:b,className:"".concat(ic.wrapperClass," ").concat(fl.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:y,className:fl.infiniteGrid,"aria-hidden":!0}),r.jsx("div",rn({},u,{ref:w,className:"".concat(ic.contentClass," ").concat(fl.content," ").concat(i),style:rn(rn({},l),{transform:x1(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function gk(n,e){var t=Math.max(0,Math.min(n.x+n.width,e.x+e.width)-Math.max(n.x,e.x)),s=Math.max(0,Math.min(n.y+n.height,e.y+e.height)-Math.max(n.y,e.y));return t*s}function xk(n){var e=n.elementX,t=n.elementY,s=n.elementWidth,o=n.elementHeight,i=n.scale,a=n.positionX,l=n.positionY,c=n.viewportWidth,d=n.viewportHeight,f=n.margin,u=f===void 0?0:f,m=n.threshold,p=m===void 0?0:m,h={x:-u,y:-u,width:c+2*u,height:d+2*u},g={x:e*i+a,y:t*i+l,width:s*i,height:o*i};if(p<=0){var x=g.x<h.x+h.width&&g.x+g.width>h.x,b=g.y<h.y+h.height&&g.y+g.height>h.y;return x&&b}var w=g.width*g.height;if(w<=0)return!1;var y=gk(h,g);return y/w>=p}be.forwardRef(function(n,e){var t=n.x,s=n.y,o=n.width,i=n.height,a=n.margin,l=a===void 0?0:a,c=n.threshold,d=c===void 0?0:c,f=n.placeholder,u=f===void 0?null:f,m=n.onShow,p=n.onHide,h=n.children,g=n.className,x=n.style,b=v.useContext(Sa),w=v.useState(!1),y=w[0],j=w[1],k=v.useRef(!1),N=v.useRef(m),C=v.useRef(p);return N.current=m,C.current=p,v.useEffect(function(){var S=function(){var A,T,E=b.wrapperComponent;if(E){var R=xk({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:E.offsetWidth,viewportHeight:E.offsetHeight,margin:l,threshold:d});R!==k.current&&(k.current=R,j(R),R?(A=N.current)===null||A===void 0||A.call(N):(T=C.current)===null||T===void 0||T.call(C))}};S();var _=b.onChange(S),P;return b.wrapperComponent||(P=b.onInit(function(){return S()})),function(){_(),P==null||P()}},[b,t,s,o,i,l,d]),y?r.jsx("div",rn({ref:e,className:g,style:x},{children:h})):u?r.jsx(r.Fragment,{children:u}):null});const Wf=8,bk=56;function Io(n){const e=B.c(8),{label:t,disabled:s,onClick:o,children:i,className:a}=n;let l;e[0]!==a?(l=G("size-8 border border-white/10 bg-white/[0.06] text-white/75","hover:bg-white/10 hover:text-white focus-visible:ring-white/40","disabled:pointer-events-none disabled:opacity-30",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==s||e[4]!==t||e[5]!==o||e[6]!==l?(c=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,disabled:s,"aria-label":t,title:t,className:l,children:i}),e[2]=i,e[3]=s,e[4]=t,e[5]=o,e[6]=l,e[7]=c):c=e[7],c}function gd(n){const e=B.c(101),{open:t,images:s,initialIndex:o,onClose:i,onCloseComplete:a}=n,l=t===void 0?!0:t,c=Math.min(Math.max(o,0),Math.max(s.length-1,0)),[d,f]=v.useState(c),[u,m]=v.useState(100),p=v.useRef(null),h=v.useRef(null),g=s[d];let x;e[0]!==s.length?(x=fe=>{f(Math.min(Math.max(fe,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const b=x;let w;e[2]!==b||e[3]!==d?(w=()=>b(d-1),e[2]=b,e[3]=d,e[4]=w):w=e[4];const y=w;let j;e[5]!==b||e[6]!==d?(j=()=>b(d+1),e[5]=b,e[6]=d,e[7]=j):j=e[7];const k=j;if(!g)return null;const N=s.length>1,C=d>0,S=d<s.length-1,_=u>100;let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var fe;return(fe=p.current)==null?void 0:fe.zoomIn()},e[8]=P):P=e[8];const A=P;let T;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var fe;return(fe=p.current)==null?void 0:fe.zoomOut()},e[9]=T):T=e[9];const E=T;let R;e[10]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{var fe;return(fe=p.current)==null?void 0:fe.resetTransform()},e[10]=R):R=e[10];const M=R;let I;e[11]!==S||e[12]!==C||e[13]!==k||e[14]!==y?(I=fe=>{fe.key==="ArrowLeft"&&C?(fe.preventDefault(),y()):fe.key==="ArrowRight"&&S?(fe.preventDefault(),k()):fe.key==="+"||fe.key==="="?(fe.preventDefault(),A()):fe.key==="-"?(fe.preventDefault(),E()):fe.key==="0"&&(fe.preventDefault(),M())},e[11]=S,e[12]=C,e[13]=k,e[14]=y,e[15]=I):I=e[15];const D=I;let O;e[16]===Symbol.for("react.memo_cache_sentinel")?(O=fe=>{if(fe.pointerType==="mouse"||fe.isPrimary===!1){h.current=null;return}h.current={x:fe.clientX,y:fe.clientY}},e[16]=O):O=e[16];const $=O;let L;e[17]!==S||e[18]!==C||e[19]!==k||e[20]!==y?(L=fe=>{var ue;const Pe=h.current;h.current=null;const Me=((ue=p.current)==null?void 0:ue.instance.state.scale)??1;if(!Pe||Me>1.01)return;const Fe=fe.clientX-Pe.x,ne=fe.clientY-Pe.y;Math.abs(Fe)<bk||Math.abs(Fe)<Math.abs(ne)||(Fe>0&&C&&y(),Fe<0&&S&&k())},e[17]=S,e[18]=C,e[19]=k,e[20]=y,e[21]=L):L=e[21];const F=L;let z;e[22]!==i?(z=fe=>{fe||i()},e[22]=i,e[23]=z):z=e[23];let H;e[24]!==a?(H=fe=>{fe||a==null||a()},e[24]=a,e[25]=H):H=e[25];let U,W,q;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=G("flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl border-white/10 bg-black p-0 text-white","sm:h-[min(820px,calc(100dvh-2rem))] sm:w-[min(1120px,calc(100vw-2rem))] sm:max-w-none"),W=r.jsx(Zn,{className:"sr-only",children:"Image viewer"}),q=r.jsx(es,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=U,e[27]=W,e[28]=q):(U=e[26],W=e[27],q=e[28]);let V;e[29]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-white/[0.06]",children:r.jsx(ny,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=V):V=e[29];const Y=g.label||g.alt||"Session image";let K;e[30]!==Y?(K=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:Y}),e[30]=Y,e[31]=K):K=e[31];let X;e[32]!==N||e[33]!==s.length||e[34]!==d?(X=N&&r.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[d+1," of ",s.length]}),e[32]=N,e[33]=s.length,e[34]=d,e[35]=X):X=e[35];let Q;e[36]!==K||e[37]!==X?(Q=r.jsxs("div",{className:"min-w-0 flex-1",children:[K,X]}),e[36]=K,e[37]=X,e[38]=Q):Q=e[38];const J=u<=100;let ee;e[39]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx(Ch,{className:"size-3.5","data-icon":"icon"}),e[39]=ee):ee=e[39];let oe;e[40]!==J?(oe=r.jsx(Io,{label:"Zoom out",disabled:J,onClick:E,children:ee}),e[40]=J,e[41]=oe):oe=e[41];let se;e[42]!==u?(se=r.jsxs(Z,{type:"button",variant:"ghost",size:"sm",onClick:M,className:"min-w-12 px-1.5 font-mono text-xs tabular-nums text-white/60 hover:bg-white/[0.06] hover:text-white","aria-label":"Reset zoom",title:"Reset zoom",children:[u,"%"]}),e[42]=u,e[43]=se):se=e[43];const re=u>=Wf*100;let ie;e[44]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx(Tn,{className:"size-3.5","data-icon":"icon"}),e[44]=ie):ie=e[44];let ae;e[45]!==re?(ae=r.jsx(Io,{label:"Zoom in",disabled:re,onClick:A,children:ie}),e[45]=re,e[46]=ae):ae=e[46];let te;e[47]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("div",{className:"mx-1 h-5 w-px bg-white/10"}),e[47]=te):te=e[47];let me;e[48]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx(Nt,{className:"size-4","data-icon":"icon"}),e[48]=me):me=e[48];let de;e[49]!==i?(de=r.jsx(Io,{label:"Close image viewer",onClick:i,children:me}),e[49]=i,e[50]=de):de=e[50];let le;e[51]!==oe||e[52]!==se||e[53]!==ae||e[54]!==de?(le=r.jsxs("div",{className:"flex items-center gap-1",children:[oe,se,ae,te,de]}),e[51]=oe,e[52]=se,e[53]=ae,e[54]=de,e[55]=le):le=e[55];let he;e[56]!==Q||e[57]!==le?(he=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-white/10 bg-black/20 px-2.5 sm:px-3",children:[V,Q,le]}),e[56]=Q,e[57]=le,e[58]=he):he=e[58];const ge=g.id;let ce,ve,xe;e[59]===Symbol.for("react.memo_cache_sentinel")?(ce={mode:"toggle"},ve={step:.005},xe=(fe,Pe)=>m(Math.round(Pe.scale*100)),e[59]=ce,e[60]=ve,e[61]=xe):(ce=e[59],ve=e[60],xe=e[61]);let pe,je;e[62]===Symbol.for("react.memo_cache_sentinel")?(pe={width:"100%",height:"100%"},je={width:"100%",height:"100%"},e[62]=pe,e[63]=je):(pe=e[62],je=e[63]);const _e=g.src,Re=g.alt,De=_?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let Te;e[64]!==De?(Te=G("max-h-full max-w-full select-none object-contain",De),e[64]=De,e[65]=Te):Te=e[65];let Ie;e[66]!==g.alt||e[67]!==g.src||e[68]!==Te?(Ie=r.jsx(hk,{wrapperStyle:pe,contentStyle:je,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:_e,alt:Re,draggable:!1,className:Te})}),e[66]=g.alt,e[67]=g.src,e[68]=Te,e[69]=Ie):Ie=e[69];let Le;e[70]!==g.id||e[71]!==Ie?(Le=r.jsx(fk,{ref:p,minScale:1,maxScale:Wf,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ce,wheel:ve,onTransform:xe,children:Ie},ge),e[70]=g.id,e[71]=Ie,e[72]=Le):Le=e[72];let ze;e[73]!==S||e[74]!==C||e[75]!==k||e[76]!==y||e[77]!==N?(ze=N&&r.jsxs(r.Fragment,{children:[r.jsx(Io,{label:"Previous image",disabled:!C,onClick:y,className:"absolute left-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:left-3",children:r.jsx(zc,{className:"size-5","data-icon":"icon"})}),r.jsx(Io,{label:"Next image",disabled:!S,onClick:k,className:"absolute right-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:right-3",children:r.jsx(Je,{className:"size-5","data-icon":"icon"})})]}),e[73]=S,e[74]=C,e[75]=k,e[76]=y,e[77]=N,e[78]=ze):ze=e[78];let Ue;e[79]!==u?(Ue=u===100&&r.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 hidden -translate-x-1/2 items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 text-xs text-white/60 sm:flex",children:[r.jsx(sa,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=u,e[80]=Ue):Ue=e[80];let Se;e[81]!==F||e[82]!==Le||e[83]!==ze||e[84]!==Ue?(Se=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:$,onPointerUp:F,children:[Le,ze,Ue]}),e[81]=F,e[82]=Le,e[83]=ze,e[84]=Ue,e[85]=Se):Se=e[85];let He;e[86]!==b||e[87]!==N||e[88]!==s||e[89]!==d?(He=N&&r.jsx("footer",{className:"shrink-0 border-t border-white/10 bg-black/25 px-2 py-2",children:r.jsx("div",{className:"flex gap-1.5 overflow-x-auto overscroll-x-contain pb-0.5",children:s.map((fe,Pe)=>r.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>b(Pe),"aria-label":`View image ${Pe+1}`,"aria-current":Pe===d?"true":void 0,className:G("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",Pe===d?"border-white ring-1 ring-white/40":"border-white/10 opacity-55 hover:border-white/25 hover:opacity-90"),children:[r.jsx("img",{src:fe.src,alt:"",draggable:!1,className:"size-full rounded-[3px] object-cover"}),r.jsx("span",{className:"absolute bottom-0.5 right-0.5 rounded bg-black/70 px-1 font-mono text-xs text-white/80",children:Pe+1})]},`${fe.id}-${Pe}`))})}),e[86]=b,e[87]=N,e[88]=s,e[89]=d,e[90]=He):He=e[90];let Oe;e[91]!==D||e[92]!==he||e[93]!==Se||e[94]!==He?(Oe=r.jsxs(Qn,{showCloseButton:!1,onKeyDown:D,className:U,children:[W,q,he,Se,He]}),e[91]=D,e[92]=he,e[93]=Se,e[94]=He,e[95]=Oe):Oe=e[95];let Ne;return e[96]!==l||e[97]!==z||e[98]!==H||e[99]!==Oe?(Ne=r.jsx(Jn,{open:l,onOpenChange:z,onOpenChangeComplete:H,children:Oe}),e[96]=l,e[97]=z,e[98]=H,e[99]=Oe,e[100]=Ne):Ne=e[100],Ne}function lc(n){return n.type==="user"}function xd(n){return n.type==="assistant"}function Hf(n){return n.type==="progress"}function Kf(n){return n.type==="system"}function C1(n){return n.type==="summary"}function vk(n){return n.type==="queue-operation"}function _1(n){return n.type==="attachment"}function yk(n){return n.type==="user"&&n.isCompactSummary===!0}function T1(n){return n.type==="system"&&n.subtype==="compact_boundary"}function qf(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function Vf(n,e){n.totalInputTokens+=e.input_tokens,n.totalOutputTokens+=e.output_tokens,n.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,n.totalCacheReadTokens+=e.cache_read_input_tokens??0}function ka(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function Na(n){const e=ka(n.length);for(const t of n){t.tokenUsage&&Vf(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=qf(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=qf(s.toolCalls,e.toolCallCounts),s.tokenUsage&&Vf(e,s.tokenUsage)}return e}const wk=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,jk=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function Sk(n){for(const e of jk){const t=n.match(e),s=(t==null?void 0:t[1])??(t==null?void 0:t[2]);if(s)return s}return null}function kk(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function cr(n){let e=null,t=!1;const s=n.replace(wk,(o,i,a,l)=>(t=!0,e===null&&(e=Sk(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const Nk=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],Ck=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],_k=200,Tk=/\bhttps?:\/\/\S+/g;function Ek(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,_k).toLowerCase();if(Nk.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
|
|
52
|
+
`)+1).slice(-200).replace(Tk,"").toLowerCase();return o.includes("?")||Ck.some(i=>i.test(o))}function Ca(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
53
|
+
`)}function Gf(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
54
|
+
`):""}function E1(n){if(!(n!=null&&n.trim()))return!1;const e=n.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}const Pk=/<task-notification>[\s\S]*?<\/task-notification>/g,Ak=/<[^>]*>/g;function Rk(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=Ca(n.message.content);return e.includes("<task-notification>")?e.replace(Pk,"").replace(Ak,"").trim()==="":!1}function Ik(n){if(!_1(n))return null;const e=n.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const t=e.prompt;if(t==null)return null;const s=typeof t=="string"?t:Ca(t);if(!E1(s))return null;const o=e.origin;if((o==null?void 0:o.kind)==="peer"){const a=o.name??o.from??null;if(a)return{raw:s,sender:a,body:o.body??cr(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=cr(s);return{raw:s,sender:i.sender,body:i.body}}const Mk=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function $k(n,e){let t=n;for(const[s,o]of Mk){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}function Ok(n,e){var s,o;if(!n)return{...e};const t=(((s=n.output_tokens_details)==null?void 0:s.thinking_tokens)??0)+(((o=e.output_tokens_details)==null?void 0:o.thinking_tokens)??0);return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??n.speed,...n.output_tokens_details||e.output_tokens_details?{output_tokens_details:{thinking_tokens:t}}:{}}}const Dk=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,Lk=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function zk(n){return Ca(n).trim().replace(Dk,"").replace(Lk,"").trim()}function Fk(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function ii(n,e){return{id:n.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:n.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function Bk(n){const e=[];let t=0;for(;t<n.length;){const s=n[t];if(s.kind==="tool_calls"){const o=s.toolCalls.findIndex(i=>i.name==="EnterPlanMode");if(o!==-1){const i=s.toolCalls[o],a=String(i.input.plan??""),l=s.timestamp,c=s.toolCalls.slice(0,o);c.length>0&&e.push({kind:"tool_calls",toolCalls:c,timestamp:s.timestamp});const d=[],f=s.toolCalls.slice(o+1),u=f.findIndex(m=>m.name==="ExitPlanMode");if(u!==-1){d.push(...f.slice(0,u));const m=f[u],p=m.input.path?String(m.input.path):void 0;let h="pending";m.result!==null&&(h=m.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l});const g=f.slice(u+1);g.length>0&&e.push({kind:"tool_calls",toolCalls:g,timestamp:s.timestamp}),t++;continue}else{d.push(...f);let m,p,h="pending",g=t+1;const x=[];for(;g<n.length;){const b=n[g];if(b.kind==="tool_calls"){const w=b.toolCalls.findIndex(y=>y.name==="ExitPlanMode");if(w!==-1){d.push(...b.toolCalls.slice(0,w)),m=b.toolCalls[w],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const y=b.toolCalls.slice(w+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...x),y.length>0&&e.push({kind:"tool_calls",toolCalls:y,timestamp:b.timestamp}),t=g+1;break}else d.push(...b.toolCalls),g++}else if(b.kind==="hook_event"||b.kind==="text"||b.kind==="queued_prompt"||b.kind==="agent_message")x.push(b),g++;else break}m||(e.push({kind:"plan_mode",plan:a,planFilePath:void 0,status:"pending",toolCalls:d,timestamp:l}),e.push(...x),t=g);continue}}}e.push(s),t++}return e}function Uk(n){return n.contentBlocks.some(e=>e.kind==="agent_message")?{...n,contentBlocks:n.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:t,...s}=e;return s})}:n}function bd(n){var s;const e=n.map(Uk),t=new Map;for(const o of e)for(const i of o.contentBlocks){if(i.kind==="agent_message"){const a=t.get(i.sender);a?a.push(i):t.set(i.sender,[i]);continue}if(i.kind==="tool_calls")for(const a of i.toolCalls){if(a.name!=="SendMessage")continue;const l=a.input.to;if(typeof l!="string"||!l)continue;const c=(s=t.get(l))==null?void 0:s.shift();if(!c)continue;const d=a.input.summary;c.reply={summary:typeof d=="string"?d:"",timestamp:a.timestamp||i.timestamp||""}}}return e}function Wk(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(C1(o)||T1(o)){t=!1;continue}if(lc(o)&&!o.isMeta){const i=o.message.content;if(t&&Array.isArray(i)&&i.some(l=>l.type==="tool_result"))continue;e.push(s),t=!0;continue}xd(o)&&!t&&(e.push(s),t=!0)}return e}function P1(n){var N,C;const e=[],t=[];let s=null,o=0,i=null,a=null;function l(S){a&&(S.compactionSummary=a.summary,S.compactionMeta=a.meta,a=null)}let c=null;const d=new Map,f=new Set,u=new Map,m=new Map,p=new Set,h=new Map,g=[],x=new Map;function b(S,_){let P=x.get(S);P||(P=new Map,x.set(S,P)),P.set(_,(P.get(_)??0)+1)}function w(S,_){const P=x.get(S),A=P==null?void 0:P.get(_);return!P||!A?!1:(A===1?P.delete(_):P.set(_,A-1),!0)}function y(){for(const S of g)S.turn.contentBlocks.push(S.sender?{kind:"agent_message",sender:S.sender,body:S.body,timestamp:S.timestamp}:{kind:"queued_prompt",content:S.content,timestamp:S.timestamp});g.length=0}function j(S){if(!i)return;const _=u.get(S);if(!_||_.length===0)return;i.subAgentActivity.push(..._),u.delete(S);const P=p.has(S)?"background_agent":"sub_agent",A=m.get(S);if(A)A.messages.push(..._);else{const T={kind:P,messages:[..._]};i.contentBlocks.push(T),m.set(S,T)}}function k(){if(i){for(const S of i.toolCalls)j(S.id);for(const[S]of u)j(S);for(const S of i.contentBlocks)if(S.kind==="hook_event")for(const _ of S.events){if(!(_.eventName==="PostToolUse"||_.eventName.startsWith("PostToolUse:"))||!_.toolUseId)continue;const A=i.toolCalls.find(T=>T.id===_.toolUseId);A&&(_.updatedToolOutput&&(A.outputReplacedByHook=!0),_.durationMs!==void 0&&(A.hookDurationMs=(A.hookDurationMs??0)+_.durationMs))}i.contentBlocks=Bk(i.contentBlocks),e.push(i),s!==null&&t.push(s),s=null,i=null,m.clear()}}for(o=0;o<n.length;o++){const S=n[o];if(C1(S)){k(),a={summary:S.summary};continue}if(T1(S)){k(),a={meta:Fk(S.compactMetadata)};continue}if(yk(S)){k(),s=o,i=ii(S,null),i.compactionSummary=zk(S.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(Kf(S)&&S.subtype==="away_summary"&&S.content){c={content:S.content,timestamp:S.timestamp};continue}if(vk(S)){if(i&&S.operation==="enqueue"&&E1(S.content)){const _=cr(S.content);g.push({turn:i,content:S.content,timestamp:S.timestamp,sender:_.sender,body:_.body}),b(i,S.content)}continue}if(_1(S)){const _=Ik(S);i&&_!==null&&!w(i,_.raw)&&g.push({turn:i,content:_.raw,timestamp:((N=S.attachment)==null?void 0:N.timestamp)??S.timestamp,sender:_.sender,body:_.body});continue}if(g.length>0){const _=lc(S)&&!S.isMeta?S.message.content:null;if(typeof _=="string"){const P=g.findIndex(A=>A.content===_);if(P>=0){const[A]=g.splice(P,1);w(A.turn,A.content)}}y()}if(lc(S)&&!S.isMeta){const _=S.message.content;if(typeof _!="string"&&Array.isArray(_)&&_.some(A=>A.type==="tool_result")&&i){for(const T of _)if(T.type==="tool_result"){const E=d.get(T.tool_use_id);E&&(E.turn.toolCalls[E.index].result=Gf(T.content),E.turn.toolCalls[E.index].isError=T.is_error===!0,d.delete(T.tool_use_id))}const A=S.toolUseResult;if(A!=null&&A.agentId){const T=((C=_.find(O=>O.type==="tool_result"))==null?void 0:C.tool_use_id)??"",E=h.get(T),R=p.has(T),M=[];if(Array.isArray(A.content))for(const O of A.content)O.type==="text"&&M.push(O.text);const I={agentId:A.agentId,parentToolUseId:T||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:"assistant",content:A.content,toolCalls:[],thinking:[],text:M,timestamp:S.timestamp??"",tokenUsage:A.usage?{input_tokens:A.usage.input_tokens??0,output_tokens:A.usage.output_tokens??0,cache_creation_input_tokens:A.usage.cache_creation_input_tokens??0,cache_read_input_tokens:A.usage.cache_read_input_tokens??0}:null,model:null,isBackground:R,prompt:A.prompt,status:A.status,durationMs:A.totalDurationMs,toolUseCount:A.totalToolUseCount};if(!m.get(T)){i.subAgentActivity.push(I);const $={kind:R?"background_agent":"sub_agent",messages:[I]};i.contentBlocks.push($),m.set(T,$)}}continue}if(Rk(S)){const P={kind:"task_notification",content:Ca(_),timestamp:S.timestamp};if(i){i.contentBlocks.push(P);continue}s=o,i=ii(S,null),i.contentBlocks.push(P),l(i);continue}k(),s=o,i=ii(S,S.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(xd(S)){let _=function(){R.length>0&&(M.contentBlocks.push({kind:"tool_calls",toolCalls:[...R],timestamp:T}),R.length=0)},P=function(){if(E.length>0){const I=M.contentBlocks[M.contentBlocks.length-1];I&&I.kind==="thinking"?I.blocks.push(...E):M.contentBlocks.push({kind:"thinking",blocks:[...E],timestamp:T}),E.length=0}};i||(s=o,i=ii(S,null),l(i)),i.model=S.message.model,S.effort&&(i.effort=S.effort),i.attribution=$k(i.attribution,S);const A=S.message.id;f.has(A)||(f.add(A),i.tokenUsage=Ok(i.tokenUsage,S.message.usage));const T=S.timestamp??"",E=[],R=[],M=i;for(const I of S.message.content)if(I.type==="thinking"){_();const D=I;if(!D.thinking)continue;i.thinking.push(D),E.push(D)}else if(I.type==="text"){_(),P();const D=/<thinking>([\s\S]*?)<\/thinking>/g;let O=I.text,$;for(;($=D.exec(I.text))!==null;){const L=$[1].trim();if(L){const F={type:"thinking",thinking:L,signature:""};i.thinking.push(F),i.contentBlocks.push({kind:"thinking",blocks:[F],timestamp:T})}O=O.replace($[0],"")}if(O=O.trim(),O){i.assistantText.push(O);const L=i.contentBlocks[i.contentBlocks.length-1];L&&L.kind==="text"?L.text.push(O):i.contentBlocks.push({kind:"text",text:[O],timestamp:T})}}else if(I.type==="tool_use"){P();const D={id:I.id,name:I.name,input:I.input,result:null,isError:!1,timestamp:S.timestamp??""},O=i.toolCalls.length;if(i.toolCalls.push(D),R.push(D),d.set(I.id,{turn:i,index:O}),I.name==="Task"||I.name==="Agent"){const $=I.input;$.run_in_background===!0&&p.add(I.id),h.set(I.id,{name:$.name??null,subagentType:$.subagent_type??null})}}P(),_();continue}if(Hf(S)&&S.data.type==="agent_progress"){const _=S.data,P=S.parentToolUseID??"";let A=null;if(_.message.type==="assistant"){const I=_.message.message,D=I.id,O=I.usage;O&&D&&!f.has(D)&&(f.add(D),A={input_tokens:O.input_tokens??0,output_tokens:O.output_tokens??0,cache_creation_input_tokens:O.cache_creation_input_tokens??0,cache_read_input_tokens:O.cache_read_input_tokens??0})}const T=_.message.type==="assistant"?_.message.message.model??null:null,E=h.get(P),R={agentId:_.agentId,parentToolUseId:P||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:_.message.type,content:_.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:_.message.timestamp??S.timestamp??"",tokenUsage:A,model:T,isBackground:p.has(P)};if(_.message.type==="assistant"){const I=_.message.message.content;if(Array.isArray(I))for(const D of I)D.type==="thinking"?R.thinking.push(D.thinking):D.type==="text"?R.text.push(D.text):D.type==="tool_use"&&R.toolCalls.push({id:D.id,name:D.name,input:D.input,result:null,isError:!1,timestamp:_.message.timestamp??S.timestamp??""})}else if(_.message.type==="user"){const I=_.message.message.content;if(Array.isArray(I)){for(const D of I)if(D.type==="tool_result"){const O=u.get(P);if(O)for(const $ of O){const L=$.toolCalls.find(F=>F.id===D.tool_use_id);L&&(L.result=Gf(D.content),L.isError=D.is_error===!0)}}}}let M=u.get(P);M||(M=[],u.set(P,M)),M.push(R),i&&j(P);continue}if(Hf(S)&&S.data.type==="hook_progress"){const _=S.data,P=String(_.hook_event_name??_.hookEvent??"unknown"),A=_.hookSpecificOutput,T={eventName:P,source:_.source!==void 0?String(_.source):void 0,toolName:_.tool_name!==void 0?String(_.tool_name):void 0,toolUseId:_.tool_use_id!==void 0?String(_.tool_use_id):void 0,command:_.command!==void 0?String(_.command):void 0,output:_.output!==void 0?String(_.output):void 0,stderr:_.stderr!==void 0?String(_.stderr):void 0,exitCode:_.exit_code!==void 0?Number(_.exit_code):void 0,decision:_.decision!==void 0?String(_.decision):void 0,durationMs:_.duration_ms!==void 0?Number(_.duration_ms):void 0,updatedToolOutput:(A==null?void 0:A.updatedToolOutput)!==void 0?String(A.updatedToolOutput):void 0,sessionTitle:(A==null?void 0:A.sessionTitle)!==void 0?String(A.sessionTitle):void 0,worktreePath:(A==null?void 0:A.worktreePath)!==void 0?String(A.worktreePath):void 0,timestamp:S.timestamp??""};if(i){const E=i.contentBlocks[i.contentBlocks.length-1];E&&E.kind==="hook_event"?E.events.push(T):i.contentBlocks.push({kind:"hook_event",events:[T],timestamp:S.timestamp})}continue}if(Kf(S)&&S.subtype==="turn_duration"&&i){S.durationMs!==void 0&&S.durationMs!==null&&(i.durationMs=(i.durationMs??0)+S.durationMs);continue}}return y(),k(),{turns:bd(e),turnStartIndices:t}}function A1(n){return P1(n).turns}function Yf(){return!0}function R1(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function I1(n){return R1(n.split(`
|
|
55
|
+
`))}function M1(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const t of n)if(t.sessionId&&!e.sessionId&&(e.sessionId=t.sessionId),t.version&&!e.version&&(e.version=t.version),t.gitBranch&&!e.gitBranch&&(e.gitBranch=t.gitBranch),t.cwd&&!e.cwd&&(e.cwd=t.cwd),t.slug&&!e.slug&&(e.slug=t.slug),t.name&&!e.name&&(e.name=t.name),t.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=t.branchedFrom),xd(t)&&t.message.model&&!e.model&&(e.model=t.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function Hk(n){return M1(R1(n))}function Kk(n,e){const t=I1(n),s=M1(t),o=A1(t),i=e!=null&&e.skipStats?ka(o.length):Na(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function qk(n,e){const t=I1(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=Wk(s),a=Math.max(0,n.turns.length-i.length);let l=Math.max(0,i.length-1);const c=new Set;for(const h of t)if(h.type==="progress"){const g=h.parentToolUseID;g&&c.add(g)}if(c.size>0)for(let h=l-1;h>=0;h--){const g=n.turns[a+h];if(g!=null&&g.toolCalls.some(x=>c.has(x.id))){l=h;break}}const d=i[l]??s.length,f=n.turns.slice(0,a+l),u=A1(o.slice(d)),m=bd([...f,...u]),p=Na(m);return{sessionId:n.sessionId,version:n.version,gitBranch:n.gitBranch,cwd:n.cwd,slug:n.slug,name:n.name,model:n.model||m.length>0&&m[m.length-1].model||"",turns:m,stats:p,rawMessages:o,branchedFrom:n.branchedFrom,agentKind:n.agentKind}}const $1="<task-notification>",Vk=/<task-id>([^<]+)<\/task-id>/g,Gk=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function _n(n){return typeof n=="object"&&n!==null}function Yk(n){const e=_n(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>_n(s)&&typeof s.text=="string").map(s=>s.text):[]}function Xk(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes($1)){for(const c of a.matchAll(Vk))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(Gk))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=_n(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=_n(a.message)?a.message:null,f=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>_n(p)&&p.type==="tool_result").map(p=>p.tool_use_id),u=[l.agentId,l.taskId,...f].filter(p=>typeof p=="string"&&p.length>0),m=[l.description,l.workflowName,l.summary].find(p=>typeof p=="string"&&p.length>0)??"";u.length>0&&e.push({ids:u,description:m})}for(const c of Yk(a))i(c,o);continue}if(a.type==="assistant"){const l=_n(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!_n(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const f=_n(d.input)?d.input:null,u=(f==null?void 0:f.task_id)??(f==null?void 0:f.shell_id);typeof u=="string"&&t.add(u)}continue}if(a.type==="attachment"){const l=_n(a.attachment)?a.attachment:null;typeof(l==null?void 0:l.prompt)=="string"&&i(l.prompt,o);continue}if(a.type==="queue-operation"&&typeof a.content=="string"){const l=a.operation;i(a.content,l==="enqueue"?s:o)}}return{pendingDescriptions:e.filter(a=>!a.ids.some(l=>t.has(l))).map(a=>a.description),undeliveredNotifications:[...s].filter(a=>!o.has(a)).length}}function Jk(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function Qk(n){var a,l;let e=0,t=null,s=!1;function o(c,d){const f={status:c,pendingQueue:Math.max(0,e)};return d&&(f.toolName=d),f}function i(){return t??(t=Xk(n))}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type!=="queue-operation"){if(d.type==="progress"){const f=d.data;if((f==null?void 0:f.type)==="hook_progress"&&(f.decision??((a=f.hookSpecificOutput)==null?void 0:a.permissionDecision))==="defer")return o("deferred");break}break}}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type==="queue-operation"){if(typeof d.content=="string"&&d.content.includes($1))continue;const f=d.operation;f==="enqueue"?e++:(f==="dequeue"||f==="remove")&&e--;continue}if(d.type==="attachment"){const f=_n(d.attachment)?d.attachment:null;(f==null?void 0:f.commandMode)==="task-notification"&&(s=!0);continue}if(d.type==="assistant"){const f=d.message,u=f==null?void 0:f.stop_reason;if(u==="end_turn"){const m=i();if(s||m.undeliveredNotifications>0)return o("processing");if(m.pendingDescriptions.length>0)return Jk(m.pendingDescriptions,Math.max(0,e));let p=!1;for(let h=c-1;h>=0;h--){const g=n[h];if(g.type==="user"&&!g.isMeta){p=!0;break}}return o(p?"completed":"idle")}if(u==="tool_use"){const m=f==null?void 0:f.content,p=(l=m==null?void 0:m.findLast)==null?void 0:l.call(m,h=>h.type==="tool_use");return o("tool_use",p==null?void 0:p.name)}return o("thinking")}if(d.type==="user"){if(d.isMeta)continue;return o("processing")}if(d.type==="system"&&d.subtype==="terminal_reason"){const f=d.reason;if(f)return{status:"completed",terminalReason:f,pendingQueue:Math.max(0,e)};continue}d.type!=="summary"&&d.type==="system"&&d.subtype}return{status:"idle"}}function Zk(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function eN(n){return P1(n).turnStartIndices}function O1(n,e,t){if(!e)return;n.assistantText.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="text"){s.text.push(e);return}n.contentBlocks.push({kind:"text",text:[e],timestamp:t})}const Xf={0:"\0",b:"\b",f:"\f",n:`
|
|
56
|
+
`,r:"\r",t:" ",v:"\v"};function tN(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Ri(n){return!!(n&&/[\w$]/.test(n))}function Vn(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",o=e+1;for(;o<n.length;){const i=n[o];if(i===t)return{endIndex:o+1,value:s};if(i!=="\\"){s+=i,o++;continue}if(o++,o>=n.length)return null;const a=n[o];if(a in Xf){s+=Xf[a],o++;continue}if(a===`
|
|
57
|
+
`){o++;continue}if(a==="\r"){o+=n[o+1]===`
|
|
58
|
+
`?2:1;continue}if(a==="x"&&/^[0-9a-fA-F]{2}$/.test(n.slice(o+1,o+3))){s+=String.fromCharCode(Number.parseInt(n.slice(o+1,o+3),16)),o+=3;continue}if(a==="u"){const l=n.slice(o+1).match(/^\{([0-9a-fA-F]+)\}/);if(l){const d=Number.parseInt(l[1],16);if(Number.isFinite(d)&&d<=1114111){s+=String.fromCodePoint(d),o+=l[0].length+1;continue}}const c=n.slice(o+1,o+5);if(/^[0-9a-fA-F]{4}$/.test(c)){s+=String.fromCharCode(Number.parseInt(c,16)),o+=5;continue}}s+=a,o++}return null}const ds={"(":")","[":"]","{":"}"};function vd(n,e){if(n[e]!=="/")return null;if(n[e+1]==="/"){const t=n.indexOf(`
|
|
59
|
+
`,e+2);return t===-1?n.length:t+1}if(n[e+1]==="*"){const t=n.indexOf("*/",e+2);return t===-1?n.length:t+2}return null}function _a(n,e){const t=Vn(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=vd(n,e);return s===null?null:{endIndex:s,isString:!1}}function Yt(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=vd(n,t);if(s===null)break;t=s}return t}function Ta(n,e){const t=n[e];if(!ds[t])return null;const s=[ds[t]];for(let o=e+1;o<n.length;o++){const i=_a(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(ds[a]){s.push(ds[a]);continue}if(a===s.at(-1)&&(s.pop(),s.length===0))return o}return null}function D1(n,e){if(!tN(n[e]))return null;let t=e+1;for(;Ri(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function nN(n,e,t){var f;const s=(f=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:f[1];if(!s)return t;const o=n.slice(0,e),i=new RegExp(`\\b(?:const|let|var)\\s+${s.replace(/[$]/g,"\\$")}\\s*=`,"g"),a=[...o.matchAll(i)].at(-1);if(!a||a.index===void 0)return t;const l=Yt(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const u=Ta(o,l);if(u!==null)return o.slice(l,u+1).trim()}const d=Vn(o,l);return d?o.slice(l,d.endIndex).trim():t}function sN(n){const e=[];for(let t=0;t<n.length;t++){const s=_a(n,t);if(s){t=s.endIndex-1;continue}if(!n.startsWith("tools",t)||Ri(n[t-1])||Ri(n[t+5]))continue;let o=Yt(n,t+5),i="";if(n[o]==="."){o=Yt(n,o+1);const c=D1(n,o);if(!c)continue;i=c.value,o=c.endIndex}else if(n[o]==="["){o=Yt(n,o+1);const c=Vn(n,o);if(!c||(o=Yt(n,c.endIndex),n[o]!=="]"))continue;i=c.value,o++}else continue;if(o=Yt(n,o),n[o]!=="(")continue;const a=Ta(n,o);if(a===null){e.push({name:i,argumentSource:n.slice(o+1).trim(),startIndex:t});break}const l=n.slice(o+1,a).trim();e.push({name:i,argumentSource:nN(n,t,l),startIndex:t})}return e}function L1(n,e){return Vn(n,e)??D1(n,e)}function oN(n,e,t){const s=[];for(let o=e;o<t;o++){const i=_a(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(ds[a]){s.push(ds[a]);continue}if(s.length>0&&a===s.at(-1)){s.pop();continue}if(s.length===0&&a===",")return o}return t}function yd(n,e){let t=Yt(n,0);for(;n[t]==="(";)t=Yt(n,t+1);if(n[t]!=="{")return null;const s=Ta(n,t);if(s===null)return null;let o=t+1;for(;o<s;){if(o=Yt(n,o),n[o]===","){o++;continue}const i=L1(n,o);if(!i){o++;continue}if(o=Yt(n,i.endIndex),n[o]!==":"){o++;continue}const a=Yt(n,o+1),l=oN(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function z1(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=vd(n,o);if(i!==null){o=i-1;continue}const a=L1(n,o);if(a){if(a.value===e&&!Ri(n[o-1])){const l=Yt(n,a.endIndex);if(n[l]===":"){const c=t(Yt(n,l+1));c!==null&&s.push(c)}}o=a.endIndex-1}}return s}function wd(n,e){return z1(n,e,t=>{var s;return((s=Vn(n,t))==null?void 0:s.value)??null})}function F1(n,e){return z1(n,e,t=>{const s=n.slice(t).match(/^-?[\d_]+(?:\.\d+)?/);if(!s)return null;const o=Number(s[0].replaceAll("_",""));return Number.isFinite(o)?o:null})}function B1(n){const e=Yt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=Ta(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=_a(n,a);if(l){o||(o=l.isString),a=l.endIndex-1;continue}const c=n[a];ds[c]?(o=!0,i.push(ds[c])):i.length>0&&c===i.at(-1)?i.pop():i.length===0&&c===","?(o&&s++,o=!1):/\s/.test(c)||(o=!0)}return s+(o?1:0)}function Jf(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function rN(n){if(!n.includes("apply_patch")||!n.includes("*** Begin Patch"))return[];const e=new Map;for(let a=0;a<n.length;a++){const l=Vn(n,a);if(l){if(Jf(l.value)){const c=n.slice(0,a).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);c&&e.set(c[1],l.value)}a=l.endIndex-1}}const t=[],s=new Set,o=/\btools\s*\.\s*apply_patch\s*\(/g;let i;for(;(i=o.exec(n))!==null;){let a=i.index+i[0].length;for(;/\s/.test(n[a]??"");)a++;const l=Vn(n,a),c=l?null:n.slice(a).match(/^([A-Za-z_$][\w$]*)/),d=(l==null?void 0:l.value)??(c?e.get(c[1]):void 0);!d||!Jf(d)||s.has(d)||(s.add(d),t.push(d))}return t}function Qf(n,e){if(!e||n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n))return n;const t=e.replace(/[\\/]+$/,""),s=n.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${t}\\${s.replace(/\//g,"\\")}`:`${t}/${s}`}function Zf(n,e,t,s=""){var c,d;const o=[],i=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,a=[];let l;for(;(l=i.exec(n))!==null;)a.push({action:l[1],filePath:l[2].trim(),headerIdx:l.index,startIdx:l.index+l[0].length});for(let f=0;f<a.length;f++){const u=a[f],m=f+1<a.length?a[f+1].headerIdx:n.length,p=n.slice(u.startIdx,m),h=(d=(c=p.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:c[1])==null?void 0:d.trim(),g=Qf(u.filePath,s),x=Qf(h||u.filePath,s),b=p.split(/^@@.*$/m).filter(k=>k.trim()),w=[],y=[];for(const k of b)for(const N of k.split(`
|
|
60
|
+
`))N.startsWith("-")?w.push(N.slice(1)):N.startsWith("+")?y.push(N.slice(1)):N.startsWith(" ")&&(w.push(N.slice(1)),y.push(N.slice(1)));const j=a.length>1?`${e}:file-${f}`:e;u.action==="Add File"?o.push({id:j,name:"Write",input:{file_path:x,content:y.join(`
|
|
61
|
+
`)},result:null,isError:!1,timestamp:t}):u.action==="Delete File"?o.push({id:j,name:"Edit",input:{file_path:x,old_string:w.join(`
|
|
62
|
+
`),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:j,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:w.join(`
|
|
63
|
+
`),new_string:y.join(`
|
|
64
|
+
`)},result:null,isError:!1,timestamp:t})}return o}function U1(n,e,t,s,o=""){return n==="apply_patch"?Zf(e,t,s,o):rN(e).flatMap((i,a)=>Zf(i,`${t}:patch-${a}`,s,o))}function iN(n,e,t){var l;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(n))return new Set;const s=new Map;for(const c of t){const d=(l=c.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:l[1];if(d===void 0)continue;const f=Number(d),u=s.get(f)??[];u.push(c),s.set(f,u)}if(s.size===0)return new Set(t.map(c=>c.id));const o=n.toLowerCase().replaceAll("\\","/"),i=new Set;for(const[c,d]of s)d.some(f=>{const u=String(f.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!u)return!1;const p=u.split("/").filter(Boolean).slice(-2).join("/");return o.includes(u)||p.includes("/")&&o.includes(p)})&&i.add(c);for(const c of o.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const d=Number(c[1]);s.has(d)&&i.add(d)}i.size===0&&i.add(Math.max(...s.keys()));const a=Math.min(...i);for(const c of s.keys())c>=a&&i.add(c);return new Set([...i].flatMap(c=>{var d;return((d=s.get(c))==null?void 0:d.map(f=>f.id))??[]}))}function jd(n){return typeof n=="object"&&n!==null}const aN=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]);function dr(n){const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return aN.get(e)??n}function cc(n){if(!n)return!1;const e=n.match(/Process exited with code (\d+)/);if(e)return e[1]!=="0";const t=n.replace(/\b0\s+(?:fail(?:ed|ures?)?|errors?)\b/gi,"").replace(/\bno\s+(?:failures?|errors?)\b/gi,"");return/\b(error|failed|exception)\b/i.test(t)}function lN(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>jd(s)).map(s=>({content:typeof s.step=="string"?s.step:"",status:typeof s.status=="string"?s.status:"pending",activeForm:typeof s.step=="string"?s.step:""}))}}function cN(n){return typeof n=="string"?n:Array.isArray(n)?n.filter(e=>jd(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function W1(n){const e=cN(n);if(!e)return{text:"",isError:!1};try{const t=JSON.parse(e),s=typeof t.output=="string"?t.output:e,o=jd(t.metadata)?t.metadata:null,i=o?o.exit_code!==0&&o.exit_code!==void 0:cc(s);return{text:s,isError:i}}catch{return{text:e,isError:cc(e)}}}const dN=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function uN(n){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${n}-${Math.random().toString(36).slice(2,10)}`}function Sd(n){try{return JSON.parse(n)}catch{return null}}function et(n){return typeof n=="object"&&n!==null}function vo(n){return!n||typeof n.type!="string"?!1:n.type==="session_meta"||n.type==="turn_context"||n.type==="event_msg"||n.type==="response_item"||n.type==="inter_agent_communication_metadata"||n.type==="compacted"||n.type==="world_state"}function Ii(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>et(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
65
|
+
`).trim():""}const fN=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,mN=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function H1(n){if(typeof n!="string")return null;const e=fN.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function K1(n){if(typeof n!="string")return null;const e=mN.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function pN(n){return Array.isArray(n.images)?n.images.map(H1).filter(e=>e!==null):[]}function hN(n){return Array.isArray(n.audio)?n.audio.map(K1).filter(e=>e!==null):[]}function q1(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_image").map(e=>H1(e.image_url)).filter(e=>e!==null):[]}function V1(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_audio").map(e=>K1(e.audio_url)).filter(e=>e!==null):[]}function em(n,e,t=[],s=[],o=[]){const i=[...s.map(l=>`
|
|
66
|
+
`),...o.map(l=>`
|
|
67
|
+
[audio attachment](<${l}>)`)].join(""),a=n+i;return e.length===0&&t.length===0?a:[...e,...t,...a?[{type:"text",text:a}]:[]]}function gN(n){var a,l;const e=Ii(n,"input_text");if(!e)return{messageType:null,text:""};const t=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!t||t.index===void 0)return{messageType:null,text:e.trim()};const o=((l=(a=e.slice(0,t.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:a[1])==null?void 0:l.trim().toUpperCase())??null,i=e.slice(t.index+t[0].length).trim();return{messageType:o,text:i}}function Mo(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function xN(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function dc(n){const e=n.trim();return!e||dN.some(t=>e.startsWith(t))?"":e}function bN(n,e){return n?{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0)}:{...e}}function vN(n){if(!et(n))return null;const e=typeof n.input_tokens=="number"?n.input_tokens:0,t=typeof n.output_tokens=="number"?n.output_tokens:0,s=typeof n.cache_write_input_tokens=="number"?n.cache_write_input_tokens:typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cached_input_tokens=="number"?Math.max(0,n.cached_input_tokens):null,i=o??(typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0),a=o===null?e:Math.max(0,e-o);return a===0&&t===0&&s===0&&i===0?null:{input_tokens:a,output_tokens:t,cache_creation_input_tokens:s,cache_read_input_tokens:i}}function yN(n,e,t){if(!e)return;const s={type:"thinking",thinking:e,signature:""};n.thinking.push(s);const o=n.contentBlocks[n.contentBlocks.length-1];if(o&&o.kind==="thinking"){o.blocks.push(s);return}n.contentBlocks.push({kind:"thinking",blocks:[s],timestamp:t})}function Vs(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if(s&&s.kind==="tool_calls"&&s.timestamp===t){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function wN(n,e,t){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&t){const o=new Date(e.timestamp).getTime(),i=new Date(t).getTime();Number.isFinite(o)&&Number.isFinite(i)&&i>=o&&(e.durationMs=i-o)}return n.push(e),null}function tm(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return et(e)?e:{value:e}}catch{return{raw:n}}}function $o(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function nm(...n){return n.find(e=>typeof e=="string")}function jN(n){return n.startsWith("exec-")}function SN(n){if(!et(n))return{text:$o(n),isError:!1};if("Err"in n)return{text:$o(n.Err),isError:!0};const e=et(n.Ok)?n.Ok:null;if(!e)return{text:$o(n),isError:!1};const t=W1(e.content);return{text:t.text||(e.structuredContent!==void 0?$o(e.structuredContent):$o(e)),isError:e.isError===!0||t.isError}}function kN(n,e,t){return{id:n?`${n}@${e}`:uN("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function G1(n){return n.type==="event_msg"&&et(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?dc(n.payload.message):n.type==="response_item"&&et(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?dc(Ii(n.payload,"input_text")):""}function NN(n,e){if(n.type==="session_meta"||n.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(n.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return G1(n)!==""||q1(e).length>0||V1(e).length>0}return!0}function Y1(n){let e="",t="",s="",o="",i="",a,l="",c="",d="",f="",u=0,m=!1,p=null,h="/root",g="";for(const x of n){if(!et(x.payload))continue;if(x.type==="session_meta"){if(e||(e=typeof x.payload.id=="string"?x.payload.id:""),t||(t=typeof x.payload.cli_version=="string"?x.payload.cli_version:""),o||(o=typeof x.payload.cwd=="string"?x.payload.cwd:""),!a&&et(x.payload.branchedFrom)){const j=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";j&&(a={sessionId:j,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const w=et(x.payload.source)?x.payload.source:null;if(w&&et(w.subagent)){m=!0;const j=et(w.subagent.thread_spawn)?w.subagent.thread_spawn:null;j&&typeof j.agent_path=="string"&&(h=j.agent_path)}typeof x.payload.forked_from_id=="string"&&x.payload.forked_from_id&&(p=x.payload.forked_from_id);const y=et(x.payload.git)?x.payload.git:null;s||(s=y&&typeof y.branch=="string"?y.branch:"")}x.type==="turn_context"&&(i||(i=typeof x.payload.model=="string"?x.payload.model:""),o||(o=typeof x.payload.cwd=="string"?x.payload.cwd:""));const b=G1(x);b&&b!==g&&(l||(l=b),c=b,g=b,u++,d||(d=x.timestamp??""),f=x.timestamp??f)}return f===""&&(f=d),{sessionId:e,version:t,gitBranch:s,cwd:o,model:i,slug:"",name:"",branchedFrom:a,firstUserMessage:l,lastUserMessage:c,timestamp:d,lastTimestamp:f,turnCount:u,isSubagent:m,parentSessionId:p,agentPath:h}}function X1(n){for(const e of n.split(`
|
|
68
|
+
`)){const t=e.trim();if(t)return vo(Sd(t))}return!1}function CN(n){return vo(n[0]??null)}function _N(n){const e=n.map(Sd).filter(vo);return Y1(e)}function J1(n,e){const t=Y1(n.filter(vo)),s=[],o=new Map,i=new Map,a=new Map,l=new Map,c=new Map,d=new Map,f=new Map,u=new Map;function m(P,A,T,E={}){const R=c.get(P);let M=u.get(P);if(!M){const D={agentId:P,parentToolUseId:(R==null?void 0:R.parentToolCallId)||void 0,agentName:(R==null?void 0:R.nickname)??(R!=null&&R.agentPath?Mo(R.agentPath):null),subagentType:(R==null?void 0:R.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(R==null?void 0:R.timestamp)??T,tokenUsage:null,model:(R==null?void 0:R.model)??null,isBackground:!1,prompt:(R==null?void 0:R.message)||void 0,status:E.status??"running"};A.subAgentActivity.push(D);const O=A.contentBlocks[A.contentBlocks.length-1];(O==null?void 0:O.kind)==="sub_agent"?O.messages.push(D):A.contentBlocks.push({kind:"sub_agent",messages:[D],timestamp:T}),M={message:D,turn:A},u.set(P,M)}const I=M.message;if(R&&(I.parentToolUseId=R.parentToolCallId||I.parentToolUseId,I.agentName=R.nickname??(R.agentPath?Mo(R.agentPath):I.agentName),I.subagentType=R.agentType,I.model=R.model,I.prompt=R.message||I.prompt),E.text&&!I.text.includes(E.text)&&(I.text.push(E.text),I.content=I.text.join(`
|
|
69
|
+
|
|
70
|
+
`)),E.status){const D=new Set(["completed","failed","interrupted"]);if(E.status==="running"&&I.status&&D.has(I.status)||(I.status=E.status),D.has(E.status)&&I.timestamp&&T){const O=new Date(I.timestamp).getTime(),$=new Date(T).getTime();Number.isFinite(O)&&Number.isFinite($)&&$>=O&&(I.durationMs=$-O)}}return I}let p=null,h=null,g=t.model||null,x="",b=null,w=!1;const y=[];let j=0,k=null,N=null;function C(P){const A=s.length,T=wN(s,P,x);return s.length>A&&N!==null&&y.push(N),N=null,T}function S(P,A,T){const E=kN(P,A,T);return N=k??j,k=null,w||(E.isFragment=!0),b&&(E.compactionSummary=b,b=null),E}function _(P,A,T,E,R){const M=i.get(A);if(M){M.input={...M.input,...T},M.result=E,M.isError=E==="failed";return}const I={id:A,name:"WebSearch",input:T,result:E,isError:E==="failed",timestamp:R};i.set(A,I),Vs(P,I,R)}for(let P=0;P<n.length;P++){const A=n[P];if(!vo(A))continue;j=P;const T=et(A.payload)?A.payload:void 0,E=A.timestamp??"";if(A.type==="compacted"){p=C(p),b="Conversation compacted",x=E;continue}if(A.type!=="world_state"){if(A.type==="turn_context"){p=C(p),k=P,h=typeof(T==null?void 0:T.turn_id)=="string"?T.turn_id:null,g=typeof(T==null?void 0:T.model)=="string"?T.model:g,x=E,w=!0;continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="user_message"&&typeof T.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),w=!0,p??(p=S(h,E,g));const R=(Array.isArray(T.local_images)?T.local_images:[]).filter(I=>typeof I=="string"&&I.length>0),M=(Array.isArray(T.local_audio)?T.local_audio:[]).filter(I=>typeof I=="string"&&I.length>0);p.userMessage=em(T.message,pN(T),hN(T),R,M),p.isFragment=!1,p.timestamp=p.timestamp||E,x=E;continue}if(!(!p&&!NN(A,T))){if(p??(p=S(h,E,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=E),E&&(x=E),A.type==="event_msg"&&(T==null?void 0:T.type)==="token_count"){const R=et(T.info)?T.info:null,M=R?vN(R.last_token_usage):null;M&&(p.tokenUsage=bN(p.tokenUsage,M));continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="web_search_end"&&typeof T.call_id=="string"){const R={};typeof T.query=="string"&&T.query&&(R.query=T.query),et(T.action)&&(R.action=T.action),_(p,T.call_id,R,"completed",E);continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="mcp_tool_call_end"&&typeof T.call_id=="string"&&et(T.invocation)){const R=T.invocation,M=typeof R.server=="string"?R.server:"mcp",I=typeof R.tool=="string"?R.tool:"tool",D=et(R.arguments)?R.arguments:{},O=SN(T.result),$=o.get(T.call_id);$?($.result=O.text,$.isError=O.isError,o.delete(T.call_id)):jN(T.call_id)||Vs(p,{id:T.call_id,name:`mcp__${M}__${I}`,input:D,result:O.text,isError:O.isError,timestamp:E},E);continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="sub_agent_activity"&&typeof T.agent_thread_id=="string"&&typeof T.agent_path=="string"){const R=T.agent_thread_id,M=typeof T.event_id=="string"?T.event_id:"",I=typeof T.kind=="string"?T.kind:"started",D=M?l.get(M):void 0,O=d.get(T.agent_path),$=c.get(R)??(O?c.get(O):void 0);if(I!=="started"&&!$&&!D)continue;if(O&&O!==R&&!u.has(R)){const z=u.get(O);z&&(z.message.agentId=R,u.delete(O),u.set(R,z)),c.delete(O)}const L={agentId:R,nickname:($==null?void 0:$.nickname)??Mo(T.agent_path)??(D==null?void 0:D.taskName)??null,agentPath:T.agent_path,message:($==null?void 0:$.message)??(D==null?void 0:D.message)??"",model:($==null?void 0:$.model)??(D==null?void 0:D.model)??null,agentType:($==null?void 0:$.agentType)??(D==null?void 0:D.agentType)??null,timestamp:($==null?void 0:$.timestamp)??(E||(D==null?void 0:D.timestamp)||""),parentToolCallId:($==null?void 0:$.parentToolCallId)??M};c.set(R,L),d.set(T.agent_path,R),M&&(I==="started"||D)&&f.set(M,R),m(R,p,E,{status:I==="interrupted"?"interrupted":"running"});continue}if(!(A.type!=="response_item"||!T)){if(T.type==="reasoning"){const R=Array.isArray(T.summary)?T.summary.filter(M=>typeof M=="string").join(`
|
|
71
|
+
`):"";yN(p,R.trim(),E);continue}if(T.type==="message"&&T.role==="assistant"){O1(p,Ii(T,"output_text"),E);continue}if(T.type==="message"&&T.role==="user"&&p.userMessage===null){const R=dc(Ii(T,"input_text")),M=q1(T),I=V1(T);(R||M.length>0||I.length>0)&&(p.userMessage=em(R,M,I),p.isFragment=!1,w=!0);continue}if(T.type==="web_search_call"&&typeof T.id=="string"){const R={};et(T.action)&&(R.action=T.action);const M=typeof T.status=="string"?T.status:"completed";_(p,T.id,R,M,E);continue}if(T.type==="tool_search_call"){const R=nm(T.call_id,T.id)??"";if(R){const M={id:R,name:"ToolSearch",input:et(T.arguments)?T.arguments:{},result:null,isError:!1,timestamp:E};o.set(R,M),Vs(p,M,E)}continue}if(T.type==="tool_search_output"&&typeof T.call_id=="string"){const R=o.get(T.call_id);if(R){const M=Array.isArray(T.tools)?T.tools:[],I=M.filter(et).map($=>nm($.name)??"").filter(Boolean),D=I.length>0?I.length:M.length,O=`Found ${D} tool${D===1?"":"s"}`;R.result=I.length>0?`${O}: ${I.join(", ")}`:O,R.isError=T.status==="failed",o.delete(T.call_id)}continue}if(T.type==="agent_message"&&typeof T.author=="string"){const R=T.author,M=typeof T.recipient=="string"?T.recipient:null,I=gN(T);if(I.messageType==="NEW_TASK")continue;const D=d.get(R),O=R.startsWith(`${t.agentPath}/`)&&(M===null||M===t.agentPath);if(!D&&!O)continue;const $=D??R;D||(c.set($,{agentId:$,nickname:Mo(R),agentPath:R,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),d.set(R,$));let L;I.messageType==="FINAL_ANSWER"?L="completed":I.messageType==="ERROR"||I.messageType==="FAILED"?L="failed":I.messageType==="INTERRUPTED"?L="interrupted":I.messageType==="MESSAGE"&&(L="running"),m($,p,E,{status:L,text:I.text||void 0});continue}if(T.type==="function_call"&&typeof T.call_id=="string"){const R=typeof T.name=="string"?T.name:"tool",M=dr(R),I=tm(T.arguments);let D=M,O=I;M==="exec_command"?D="Bash":M==="update_plan"&&(D="TodoWrite",O=lN(I)),M==="spawn_agent"&&l.set(T.call_id,{callId:T.call_id,message:xN(I.message),taskName:typeof I.task_name=="string"?I.task_name:null,model:typeof I.model=="string"?I.model:null,agentType:typeof I.agent_type=="string"?I.agent_type:null,timestamp:E});const $={id:T.call_id,name:D,input:O,result:null,isError:!1,timestamp:E};o.set($.id,$),Vs(p,$,E);continue}if(T.type==="function_call_output"&&typeof T.call_id=="string"){const R=o.get(T.call_id);if(!R)continue;const M=typeof T.output=="string"?T.output:null;if(R.result=M,R.isError=cc(M),o.delete(T.call_id),R.name==="spawn_agent"&&M)try{const I=JSON.parse(M),D=typeof I.agent_id=="string"?I.agent_id:f.get(R.id)??"",O=typeof I.task_name=="string"?I.task_name:null,$=typeof I.nickname=="string"?I.nickname:O?Mo(O):null;if(D){const L=l.get(R.id),F=c.get(D),z={agentId:D,nickname:$??(F==null?void 0:F.nickname)??(L==null?void 0:L.taskName)??null,agentPath:O??(F==null?void 0:F.agentPath)??null,message:(F==null?void 0:F.message)??(L==null?void 0:L.message)??"",model:(F==null?void 0:F.model)??(L==null?void 0:L.model)??null,agentType:(F==null?void 0:F.agentType)??(L==null?void 0:L.agentType)??null,timestamp:(F==null?void 0:F.timestamp)??(L==null?void 0:L.timestamp)??E,parentToolCallId:(F==null?void 0:F.parentToolCallId)??R.id};c.set(D,z),f.set(R.id,D),z.agentPath&&d.set(z.agentPath,D),m(D,p,E,{status:"running"})}}catch{}if(R.name==="wait_agent"&&M&&p)try{const I=JSON.parse(M),D=et(I.status)?I.status:{};for(const[O,$]of Object.entries(D)){const L=et($)?$:{},F=typeof L.completed=="string"?L.completed:"",z=typeof L.failed=="string"?L.failed:typeof L.error=="string"?L.error:"",H=typeof L.interrupted=="string"?L.interrupted:"",U=F?"completed":z?"failed":H?"interrupted":typeof L.status=="string"?L.status:"running";c.has(O)||c.set(O,{agentId:O,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),m(O,p,E,{status:U,text:F||z||H||void 0})}}catch{}continue}if(T.type==="custom_tool_call"&&typeof T.call_id=="string"){const R=typeof T.name=="string"?T.name:"tool",M=typeof T.input=="string"?T.input:"",I=T.call_id,D=M?U1(R,M,I,E,t.cwd):[];if(R!=="apply_patch"){const O={id:I,name:R==="exec_command"?"Bash":R,input:tm(M),result:null,isError:!1,timestamp:E};o.set(O.id,O),Vs(p,O,E)}for(const O of D)o.set(O.id,O),Vs(p,O,E);D.length>0&&a.set(I,{calls:D,direct:R==="apply_patch"});continue}if(T.type==="custom_tool_call_output"&&typeof T.call_id=="string"){const R=T.call_id,{text:M,isError:I}=W1(T.output),D=a.get(R);if(D){const $=D.direct&&I?new Set(D.calls.map(L=>L.id)):iN(M,I,D.calls);for(const L of D.calls){const F=o.get(L.id);F&&(F.result=M,F.isError=$.has(F.id),o.delete(F.id))}a.delete(R)}const O=o.get(R);O&&(O.result=M,O.isError=I,o.delete(R));continue}}}}}return C(p),{turnStartIndices:y,sessionId:t.sessionId,version:t.version,gitBranch:t.gitBranch,cwd:t.cwd,slug:t.slug,name:"",model:t.model,turns:s,stats:e!=null&&e.skipStats?ka(s.length):Na(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function kd(n,e){const t=n.split(`
|
|
72
|
+
`).map(i=>i.trim()).filter(Boolean).map(Sd).filter(vo),{turnStartIndices:s,...o}=J1(t,e);return o}function TN(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
73
|
+
`);return kd(t?`${t}
|
|
74
|
+
${e}`:e)}const EN=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function PN(n){const e=n.content;return Array.isArray(e)?e.filter(t=>et(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
75
|
+
`):""}function ai(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return et(e)?e:null}catch{return null}}function AN(n){var c,d;const e=new Map,t=new Set,s=new Map,o=new Map,i=new Set,a=new Map;function l(f,u){t.has(f)||e.set(f,e.get(f)||u)}for(const f of n){const u=et(f.payload)?f.payload:null;if(u){if(f.type==="event_msg"&&u.type==="sub_agent_activity"&&typeof u.agent_thread_id=="string"&&typeof u.agent_path=="string"){const m=u.agent_thread_id,p=typeof u.kind=="string"?u.kind:"started",h=typeof u.event_id=="string"?u.event_id:"",g=s.get(u.agent_path),x=e.has(m)||t.has(m)||g!==void 0||o.has(h);if(p!=="started"&&!x)continue;g&&g!==m&&(e.has(g)&&(l(m,e.get(g)??""),e.delete(g)),t.has(g)&&t.add(m)),s.set(u.agent_path,m),p==="interrupted"?(t.add(m),e.delete(m)):l(m,o.get(h)??"");continue}if(f.type==="response_item"){if(u.type==="function_call"&&typeof u.call_id=="string"){const m=dr(typeof u.name=="string"?u.name:"");if(m==="spawn_agent"){const p=ai(u.arguments);o.set(u.call_id,typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"")}else if(m==="wait_agent")i.add(u.call_id);else if(m==="interrupt_agent"){const p=ai(u.arguments),h=[p==null?void 0:p.agent_id,...Array.isArray(p==null?void 0:p.agent_ids)?p.agent_ids:[]].filter(g=>typeof g=="string");a.set(u.call_id,h)}continue}if(u.type==="function_call_output"&&typeof u.call_id=="string"){const m=u.call_id;if(o.has(m)){const p=ai(u.output),h=typeof(p==null?void 0:p.agent_id)=="string"?p.agent_id:"";if(h){l(h,o.get(m)??"");const g=typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"";g&&!s.has(g)&&s.set(g,h)}}else if(i.has(m)){const p=ai(u.output),h=et(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const b=et(x)?x:{},w=typeof b.status=="string"?b.status:"";(typeof b.completed=="string"||typeof b.failed=="string"||typeof b.error=="string"||typeof b.interrupted=="string"||w==="completed"||w==="failed"||w==="interrupted")&&(t.add(g),e.delete(g))}}else if(a.has(m))for(const p of a.get(m)??[])t.add(p),e.delete(p);continue}if(u.type==="agent_message"&&typeof u.author=="string"){const p=((d=(c=PN(u).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!EN.has(p))continue;const h=s.get(u.author)??u.author;t.add(h),e.delete(h)}}}}return[...e.entries()].filter(([f])=>!t.has(f)).map(([,f])=>f)}function RN(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="event_msg"){const s=t.payload;switch(s==null?void 0:s.type){case"task_complete":{const o=AN(n);return o.length>0?{status:"awaiting_agents",pendingQueue:0,pendingAgents:o.length,pendingAgentDescriptions:o.filter(i=>i.length>0)}:{status:"completed"}}case"task_started":return{status:"processing"};case"agent_message":return{status:"thinking"};case"token_count":continue}}if(t.type==="response_item"){const s=t.payload;if(!s)continue;if(s.type==="function_call")return{status:"tool_use",toolName:s.name?dr(s.name):s.name};if(s.type==="message"){if(s.role==="assistant")return{status:"thinking"};if(s.role==="user")return{status:"processing"}}}}return{status:"idle"}}function IN(n,e,t){const s=et(n.payload)?{...n.payload}:{},o=typeof s.id=="string"?s.id:"";return s.id=e,s.branchedFrom={sessionId:o,turnIndex:t},{record:{...n,payload:s},originalId:o}}function MN(n){return J1(n,{skipStats:!0}).turnStartIndices}const $N=/^(?:assistant|auto_mode|auto_mode_switch|background_tasks|canvas|command|custom|elicitation|exit_plan_mode|extensions|external_tool|factory|hook|managed_settings|mcp|model|pending_messages|permission|sampling|session|skill|subagent|system|tool|ui|user_input)\./;function Pt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Q1(n){return typeof n.agentId!="string"||n.agentId.length===0}function Z1(n){return!Pt(n)||typeof n.type!="string"||!Pt(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||$N.test(n.type)}function ex(n){try{const e=JSON.parse(n);return Z1(e)?e:null}catch{return null}}function ON(n){return n.split(`
|
|
76
|
+
`).map(e=>e.trim()).filter(Boolean).map(ex).filter(e=>e!==null)}function we(...n){return n.find(e=>typeof e=="string")??""}function Hn(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function Uo(n){return typeof n.timestamp=="string"?n.timestamp:""}function rs(n,e){var t,s;return typeof n.id=="string"&&n.id?n.id:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`${e}-${Math.random().toString(36).slice(2,10)}`}function sm(n){const e=rs(n,"copilot-turn"),t=we(n.data.turnId);return t?`${t}@${e}`:e}function ml(n,e){if(!Pt(n))return;const t=we(n.cwd),s=we(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function tx(n){const e={sessionId:"",version:"",gitBranch:"",cwd:"",model:"",slug:"",name:"",firstUserMessage:"",lastUserMessage:"",timestamp:"",lastTimestamp:"",turnCount:0,isSubagent:!1,parentSessionId:null};for(const t of n){if(!Q1(t))continue;const{data:s}=t,o=Uo(t);if(o&&(e.lastTimestamp=o),t.type==="session.start"){e.sessionId||(e.sessionId=we(s.sessionId)),e.version||(e.version=we(s.copilotVersion)||(typeof s.version=="number"?String(s.version):we(s.version))),ml(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){ml(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){ml(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=we(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=we(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=we(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=we(s.currentModel)||e.model;continue}if((t.type==="assistant.turn_start"||t.type==="assistant.turn_end"||t.type==="assistant.message"||t.type==="assistant.usage"||t.type==="tool.execution_start"||t.type==="tool.execution_complete")&&(e.model=we(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=o);const i=we(s.content).trim();i&&(e.firstUserMessage||(e.firstUserMessage=i),e.lastUserMessage=i)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function DN(n){for(const e of n.split(`
|
|
77
|
+
`)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(Z1(s))return!0}catch{}}return!1}function LN(n){var e;return QN((e=n[0])==null?void 0:e.type)}function zN(n){const e=n.map(t=>ex(t.trim())).filter(t=>t!==null);return tx(e)}function pl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function om(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:Pt(e)?we(e.text,e.content):"";return t?[t]:[]}).join(`
|
|
78
|
+
`):""}function FN(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=we(t.data.assetId),o=we(t.data.data),i=we(t.data.mimeType);s&&o&&i&&e.set(s,{data:o,mimeType:i})}return e}function BN(n,e){if(!Pt(n))return null;const t=e.get(we(n.assetId)),s=we(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),o=we(n.data,t==null?void 0:t.data);return!s.startsWith("image/")||!o?null:{type:"image",source:{type:"base64",media_type:s,data:o}}}function nx(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=BN(o,e);if(!i)continue;const a=`${i.source.media_type}:${i.source.data}`;s.has(a)||(s.add(a),t.push(i))}return t}function UN(n,e){const t=we(n.content),s=nx(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function WN(n,e){return Pt(n.result)?nx([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function wi(n,e){var o,i;if(!n)return{...e};const t=((o=n.output_tokens_details)==null?void 0:o.thinking_tokens)??0,s=((i=e.output_tokens_details)==null?void 0:i.thinking_tokens)??0;return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),...t||s?{output_tokens_details:{thinking_tokens:t+s}}:{}}}function uc(n,e=!1){const t=Hn(n.cacheWriteTokens),s=Hn(n.cacheReadTokens),o=Hn(n.inputTokens),i={input_tokens:e?Math.max(0,o-t-s):o,output_tokens:Hn(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},a=Hn(n.reasoningTokens);return a&&(i.output_tokens_details={thinking_tokens:a}),i.input_tokens===0&&i.output_tokens===0&&i.cache_creation_input_tokens===0&&i.cache_read_input_tokens===0&&a===0?null:i}function HN(n){if(!Pt(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!Pt(t)||!Pt(t.usage))continue;const s=uc(t.usage,!0);s&&(e=wi(e,s))}return e}function KN(n){if(typeof n=="string")return{label:n};if(!Pt(n))return null;const e=we(n.label,n.title,n.value,n.name);if(!e)return null;const t=we(n.description);return t?{label:e,description:t}:{label:e}}function qN(n){return Array.isArray(n)?n.map(KN).filter(e=>e!==null):[]}function VN(n){if(!Pt(n))return null;const e=we(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=we(n.header,n.title),s=typeof n.multiSelect=="boolean"?n.multiSelect:typeof n.multi_select=="boolean"?n.multi_select:void 0;return{question:e,...t?{header:t}:{},options:qN(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function GN(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(VN).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function Wo(n){switch(n.toLowerCase().replace(/-/g,"_")){case"ask_user":return"AskUserQuestion";case"bash":case"powershell":case"shell":return"Bash";case"create":return"Write";case"edit":return"Edit";default:return n}}function Mi(n,e){const t=Pt(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?GN(t):n==="Edit"?{...t,file_path:we(t.file_path,t.path),old_string:we(t.old_string,t.old_str),new_string:we(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:we(t.file_path,t.path),content:we(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function YN(n){const e=n.error;if(typeof e=="string")return e;if(Pt(e)){const s=we(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!Pt(t))return t===void 0?"":pl(t);if(typeof t.detailedContent=="string")return t.detailedContent;if(typeof t.content=="string")return t.content;if(Array.isArray(t.contents)){const s=t.contents.flatMap(o=>{const i=typeof o=="string"?o:Pt(o)?we(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
|
|
79
|
+
`);if(s)return s}return t.structuredContent!==void 0?pl(t.structuredContent):pl(t)}function rm(n,e,t,s){if(!e||n.thinking.some(a=>a.thinking===e))return;const o={type:"thinking",thinking:e,signature:s};n.thinking.push(o);const i=n.contentBlocks[n.contentBlocks.length-1];if((i==null?void 0:i.kind)==="thinking"){i.blocks.push(o);return}n.contentBlocks.push({kind:"thinking",blocks:[o],timestamp:t})}function li(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="tool_calls"){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function Ho(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function im(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const o of n){if(!Pt(o))continue;const i=we(o.toolCallId),a=we(o.name);if(!i||!a||t(i))continue;const l=Wo(a);s.push(Ho(i,l,Mi(l,o.arguments),e))}return s}function am(n,e,t,s){n.name=e,n.input=Mi(e,t),n.timestamp=s||n.timestamp}function lm(n,e,t){n.result=YN(e);const s=WN(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function cm(n,e,t,s,o,i){return{id:n,userMessage:t,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:s,...o?{effort:o}:{},...i?{isFragment:!0}:{}}}function XN(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function sx(n,e){const t=ON(n),s=tx(t),o=FN(t),i=[],a=new Map,l=new Map,c=new Map,d=new WeakMap,f=new WeakMap;let u=null,m=null,p,h=!1,g=!1,x=null;function b(C,S){S&&d.set(C,S)}function w(C){return u||(u=cm(sm(C),Uo(C),null,m,p,!0)),u}function y(){u&&(XN(u)&&i.push(u),u=null)}function j(C){var M;const S=typeof C.agentId=="string"?C.agentId:"";if(!S)return null;const _=l.get(S);if(_)return _.message;const P=C.data,A=we(P.toolCallId),T=A?((M=a.get(A))==null?void 0:M.turn)??u:u;if(!T)return null;const E=we(P.executionMode),R={agentId:S,...A?{parentToolUseId:A}:{},agentName:we(P.agentDisplayName,P.agentName)||null,subagentType:we(P.agentType,P.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:Uo(C),tokenUsage:null,model:we(P.model)||null,isBackground:E==="background",...we(P.description)?{prompt:we(P.description)}:{},status:"running"};return T.subAgentActivity.push(R),T.contentBlocks.push({kind:R.isBackground?"background_agent":"sub_agent",messages:[R],timestamp:R.timestamp}),l.set(S,{message:R,turn:T}),R}function k(C){if(Q1(C))return!1;const S=j(C);if(!S)return!0;const{data:_}=C,P=Uo(C);if(C.type==="subagent.started"||C.type==="subagent.configured")return S.parentToolUseId||(S.parentToolUseId=we(_.toolCallId)||void 0),S.agentName=we(_.agentDisplayName,_.agentName)||S.agentName,S.subagentType=we(_.agentType,_.agentName)||S.subagentType,S.model=we(_.model)||S.model,S.prompt||(S.prompt=we(_.description)||void 0),S.isBackground||(S.isBackground=we(_.executionMode)==="background"),S.status="running",!0;if(C.type==="subagent.completed"||C.type==="subagent.failed"){S.agentName=we(_.agentDisplayName,_.agentName)||S.agentName,S.subagentType=we(_.agentType,_.agentName)||S.subagentType,S.model=we(_.model)||S.model,S.durationMs=Hn(_.durationMs)||S.durationMs,S.toolUseCount=Hn(_.totalToolCalls)||S.toolUseCount,S.status=C.type==="subagent.completed"?"completed":"failed";const A=we(_.error,_.message);return A&&!S.text.includes(A)&&S.text.push(A),!0}if(C.type==="user.message")return S.prompt||(S.prompt=we(_.content)||void 0),!0;if(C.type==="assistant.reasoning"){const A=we(_.content);return A&&!S.thinking.includes(A)&&S.thinking.push(A),!0}if(C.type==="assistant.message"){S.model=we(_.model)||S.model;const A=we(_.reasoningText);A&&!S.thinking.includes(A)&&S.thinking.push(A);const T=om(_.content);T&&!S.text.includes(T)&&S.text.push(T);for(const E of im(_.toolRequests,P,R=>c.has(R)))S.toolCalls.push(E),c.set(E.id,{call:E,message:S});return!0}if(C.type==="assistant.usage"){S.model=we(_.model)||S.model;const A=uc(_);return A&&(S.tokenUsage=wi(S.tokenUsage,A)),!0}if(C.type==="tool.execution_start"){const A=we(_.toolCallId)||rs(C,"copilot-agent-tool"),T=we(_.toolName)||"Tool",E=Wo(T),R=c.get(A);if(R)am(R.call,E,_.arguments,P);else{const M=Ho(A,E,Mi(E,_.arguments),P);S.toolCalls.push(M),c.set(A,{call:M,message:S})}return!0}if(C.type==="tool.execution_complete"){const A=we(_.toolCallId)||rs(C,"copilot-agent-tool");let T=c.get(A);if(!T){const E=we(_.toolName)||"Tool",R=Wo(E),M=Ho(A,R,{},P);S.toolCalls.push(M),T={call:M,message:S}}return lm(T.call,_,o),c.delete(A),!0}return!0}for(const C of t){if(k(C))continue;const{data:S}=C,_=Uo(C);if(C.type==="session.start"||C.type==="session.resume"){m=we(S.selectedModel)||m,p=we(S.reasoningEffort)||p;continue}if(C.type==="session.auto_mode_resolved"){m=we(S.chosenModel)||m,u&&(u.model=m);continue}if(C.type==="session.model_change"){m=we(S.newModel)||m;const P=S.reasoningEffort;typeof P=="string"&&(p=P),u&&(u.model=m,p&&(u.effort=p));continue}if(C.type==="session.shutdown"){m=we(S.currentModel)||m,u&&!u.model&&(u.model=m),x=HN(S)??x;const P=Hn(S.totalApiDurationMs);u&&!g&&P&&f.set(u,P);continue}if(C.type==="user.message"){y(),u=cm(sm(C),_,UN(S,o),m,p,!1),b(u,_);continue}if(C.type==="assistant.turn_start"){m=we(S.model)||m;const P=w(C);P.model=m,p&&(P.effort=p),b(P,_);continue}if(C.type==="assistant.reasoning"){const P=w(C);rm(P,we(S.content),_,we(S.reasoningId)||rs(C,"copilot-thinking")),b(P,_);continue}if(C.type==="assistant.message"){m=we(S.model)||m;const P=w(C);P.model=m,p&&(P.effort=p),rm(P,we(S.reasoningText),_,rs(C,"copilot-thinking")),O1(P,om(S.content),_);for(const A of im(S.toolRequests,_,T=>a.has(T)))li(P,A,_),a.set(A.id,{call:A,turn:P});b(P,_);continue}if(C.type==="assistant.usage"){m=we(S.model)||m,p=we(S.reasoningEffort)||p;const P=uc(S),A=Hn(S.duration);P&&(h=!0),A&&(g=!0);const T=w(C);T.model=m,p&&(T.effort=p),P&&(T.tokenUsage=wi(T.tokenUsage,P)),A&&f.set(T,(f.get(T)??0)+A),b(T,_);continue}if(C.type==="tool.execution_start"){m=we(S.model)||m;const P=w(C);P.model=m;const A=we(S.toolCallId)||rs(C,"copilot-tool"),T=we(S.toolName)||"Tool",E=Wo(T),R=a.get(A);if(R)am(R.call,E,S.arguments,_);else{const M=Ho(A,E,Mi(E,S.arguments),_);li(P,M,_),a.set(A,{call:M,turn:P})}b(P,_);continue}if(C.type==="tool.execution_complete"){m=we(S.model)||m;const P=we(S.toolCallId)||rs(C,"copilot-tool");let A=a.get(P);if(!A){const T=w(C),E=we(S.toolName)||"Tool",R=Wo(E),M=Ho(P,R,{},_);li(T,M,_),A={call:M,turn:T}}lm(A.call,S,o),a.delete(P),b(A.turn,_);continue}if(C.type==="session.error"){const P=w(C),T={errorType:we(S.errorType)||"unknown"};typeof S.statusCode=="number"&&(T.statusCode=S.statusCode),typeof S.errorCode=="string"&&(T.errorCode=S.errorCode),li(P,{id:rs(C,"copilot-error"),name:"Error",input:T,result:we(S.message)||"Copilot session error",isError:!0,timestamp:_},_),b(P,_);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&u&&b(u,_)}if(y(),!h&&x&&i.length===1&&(i[0].tokenUsage=wi(i[0].tokenUsage,x)),s.model)for(const C of i)C.model||(C.model=s.model);for(const C of i){const S=d.get(C),_=Date.parse(C.timestamp),P=S?Date.parse(S):Number.NaN;if(Number.isFinite(_)&&Number.isFinite(P)&&P>=_)C.durationMs=P-_;else{const A=f.get(C)??0;A&&(C.durationMs=A)}}const N=e!=null&&e.skipStats?ka(i.length):Na(i);return!(e!=null&&e.skipStats)&&!h&&x&&i.length>1&&(N.totalInputTokens=x.input_tokens,N.totalOutputTokens=x.output_tokens,N.totalCacheCreationTokens=x.cache_creation_input_tokens??0,N.totalCacheReadTokens=x.cache_read_input_tokens??0),{sessionId:s.sessionId,version:s.version,gitBranch:s.gitBranch,cwd:s.cwd,slug:s.slug,name:s.name,model:s.model,turns:i,stats:N,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function JN(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
80
|
+
`);return sx(t?`${t}
|
|
81
|
+
${e}`:e)}function QN(n){return typeof n=="string"&&(n==="abort"||n==="binary_asset"||n==="user.message"||n.startsWith("assistant.")||n.startsWith("permission.")||n.startsWith("session.")||n.startsWith("subagent.")||n.startsWith("tool.")||n.startsWith("user_input."))}function ZN(n){const e=new Map;for(const o of n){const i=typeof o.agentId=="string"?o.agentId:"";if(!i&&(o.type==="abort"||o.type==="session.shutdown"||o.type==="session.error")){e.clear();continue}if(!i||!o.type.startsWith("subagent."))continue;const a=Pt(o.data)?o.data:{};if(o.type==="subagent.completed"||o.type==="subagent.failed"){e.delete(i);continue}if(o.type==="subagent.started"||o.type==="subagent.configured"){const l=[a.agentDisplayName,a.description,a.agentName].find(c=>typeof c=="string")??"";e.set(i,l||e.get(i)||"")}}if(e.size>0){const o=[...e.values()];return{status:"awaiting_agents",pendingQueue:0,pendingAgents:o.length,pendingAgentDescriptions:o.filter(i=>i.length>0)}}let t=!1;const s=new Set;for(let o=n.length-1;o>=0;o--){const i=n[o];if(typeof i.agentId=="string"&&i.agentId)continue;const a=Pt(i.data)?i.data:{};switch(i.type){case"abort":case"session.shutdown":return{status:"completed"};case"assistant.turn_end":{for(let l=o-1;l>=0;l--){const c=n[l];if(typeof c.agentId=="string"&&c.agentId)continue;if(c.type==="user.message")break;if(c.type==="abort")return{status:"completed"};if(c.type!=="assistant.message")continue;const d=Pt(c.data)?c.data:{};return Array.isArray(d.toolRequests)&&d.toolRequests.length>0?{status:"processing"}:{status:"completed"}}return{status:"processing"}}case"session.error":return{status:"completed",terminalReason:typeof a.message=="string"?a.message:"Copilot session error"};case"assistant.idle":case"session.idle":return{status:t?"completed":"idle"};case"permission.completed":{const l=typeof a.requestId=="string"?a.requestId:"";l&&s.add(l);continue}case"permission.requested":{const l=typeof a.requestId=="string"?a.requestId:"";if(l&&s.has(l))continue;return{status:"deferred"}}case"user_input.requested":return{status:"tool_use",toolName:"AskUserQuestion"};case"tool.execution_start":return s.size>0?{status:"thinking"}:{status:"tool_use",toolName:typeof a.toolName=="string"?dr(a.toolName):typeof a.name=="string"?dr(a.name):void 0};case"tool.execution_complete":return{status:"thinking"};case"assistant.turn_start":return{status:"processing"};case"assistant.message":case"assistant.message_delta":case"assistant.reasoning":case"assistant.reasoning_delta":return{status:"thinking"};case"user.message":return t=!0,{status:"processing"};case"session.start":case"session.resume":return{status:t?"processing":"idle"}}}return{status:"idle"}}function eC(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function tC(n){const e=[];for(let t=0;t<n.length;t++){const s=n[t];if(s.type!=="user.message"||typeof s.agentId=="string")continue;const o=s.data;!o||typeof o!="object"||Array.isArray(o)||typeof s.id!="string"||!s.id||e.push(t)}return e}const ox=ps[ps.length-1],nC={kind:"codex",descriptor:tn("codex"),detectsText:X1,detectsRecords:CN,parse:kd,append:TN,metadataFromLines:_N,status:RN,brandBranch:IN,turnBoundaries:MN},sC={kind:"copilot",descriptor:tn("copilot"),detectsText:DN,detectsRecords:LN,parse:sx,append:JN,metadataFromLines:zN,status:ZN,brandBranch:eC,turnBoundaries:tC},oC={kind:"claude",descriptor:tn("claude"),detectsText:Yf,detectsRecords:Yf,parse:Kk,append:qk,metadataFromLines:Hk,status:Qk,brandBranch:Zk,turnBoundaries:eN},rC=Object.freeze({claude:oC,codex:nC,copilot:sC});function iC(n){function e(t){for(const s of ps){const o=n[s];if(t(o))return o}return n[ox]}return{formatFor:t=>n[t],formatForText:t=>e(s=>s.detectsText(t)),formatForRecords:t=>e(s=>s.detectsRecords(t))}}const Nd=iC(rC);function rx(n){return Nd.formatFor(n)}function ix(n){return Nd.formatForText(n)}function ax(n){return Nd.formatForRecords(n)}function lx(n,e){const t=e.map(s=>{try{const o=JSON.parse(s);return o&&typeof o=="object"&&!Array.isArray(o)?o:{}}catch{return{}}});return n.turnBoundaries(t)}function cx(n,e,t){return lx(n,e)[t]??e.length}function aC(n,e,t){let s=-1;for(let o=0;o<e.length;o++)if(e[o].includes(t))try{const i=JSON.parse(e[o]);if((i==null?void 0:i.uuid)===t){s=o;break}}catch{}return s<0?null:lx(n,e).find(o=>o>s)??"keep-all"}function lC(n,e){if(n.length<2)return!1;const t=n[n.length-2],s=t.toolCalls[t.toolCalls.length-1];return(s==null?void 0:s.name)===e&&s.isError}function cC(n,e){const t=n.contentBlocks,s=t.findIndex(o=>o.kind==="tool_calls"&&o.toolCalls.some(i=>i.id===e));return s===-1?!1:t.slice(s+1).some(o=>o.kind==="text"||o.kind==="thinking"||o.kind==="tool_calls")}function dx(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];if(!t||t.toolCalls.length===0)return null;const s=t.toolCalls[t.toolCalls.length-1];if(!s)return null;const{name:o}=s;if(o!=="ExitPlanMode"&&o!=="AskUserQuestion"||s.result!==null&&!s.isError||lC(e,o)||s.isError&&cC(t,s.id))return null;const i=s.input;if(o==="ExitPlanMode")return{type:"plan",allowedPrompts:i.allowedPrompts};const a=i.questions;return a&&a.length>0?{type:"question",toolUseId:s.id,questions:a}:null}function dC(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
82
|
+
`)}function Ea(n,e){return ix(n).parse(n,e)}function uC(n,e){const t=ax(n.rawMessages);return(t.kind===ox?ix(e):t).append(n,e)}function Pa(n){return n===null?"":typeof n=="string"?n:dC(n)}function ux(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const fx=v.createContext(null);function fC(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=ux(s.userMessage);for(let i=0;i<o.length;i+=1){const a=o[i];e.push({id:`${s.id}:attachment:${i}`,src:`data:${a.source.media_type};base64,${a.source.data}`,alt:`Attachment ${i+1} from turn ${t+1}`,label:`Turn ${t+1} · Image ${i+1}`})}}return e}function mC(n){const e=B.c(10),{images:t,children:s}=n,[o,i]=v.useState(null);let a;e[0]!==t?(a=m=>{const p=t.findIndex(g=>g.src===m.src),h=p>=0?t:[...t,{...m,id:m.id??`supplemental-image-${t.length}`}];i(g=>({key:((g==null?void 0:g.key)??0)+1,open:!0,images:h,index:p>=0?p:h.length-1}))},e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c={openImage:l},e[2]=l,e[3]=c):c=e[3];const d=c;let f;e[4]!==o?(f=o&&r.jsx(gd,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(pC),onCloseComplete:()=>i(null)},o.key),e[4]=o,e[5]=f):f=e[5];let u;return e[6]!==s||e[7]!==f||e[8]!==d?(u=r.jsxs(fx.Provider,{value:d,children:[s,f]}),e[6]=s,e[7]=f,e[8]=d,e[9]=u):u=e[9],u}function pC(n){return n?{...n,open:!1}:null}function hC(n){const e=B.c(7),{children:t}=n,{session:s}=it();s==null||s.turns;let o;e[0]!==(s==null?void 0:s.turns)?(o=(s==null?void 0:s.turns)??[],e[0]=s==null?void 0:s.turns,e[1]=o):o=e[1];let i;e[2]!==o?(i=fC(o),e[2]=o,e[3]=i):i=e[3];const a=i;let l;return e[4]!==t||e[5]!==a?(l=r.jsx(mC,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function mx(){return v.useContext(fx)}const px=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function gC(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:px.has(n.slice(e).toLowerCase())}function Cd(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:gC(n)}function xC(n){return n&&(Cd(n)?kr(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function fc(n){const e=B.c(41),{src:t,alt:s,id:o,className:i,thumbnailClassName:a}=n,l=o===void 0?"markdown-image":o,c=bn("hostFiles"),[d,f]=v.useState(!1),[u,m]=v.useState(!1),[p,h]=v.useState(),g=mx();let x;e[0]!==c||e[1]!==t?(x=Cd(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const b=x;let w;e[3]!==b||e[4]!==t?(w=b?void 0:xC(t),e[3]=b,e[4]=t,e[5]=w):w=e[5];const y=w;let j;e[6]!==s||e[7]!==l||e[8]!==y?(j=y?{id:l,src:y,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=y,e[9]=j):j=e[9];const k=j;let N;e[10]!==g||e[11]!==k?(N=()=>{k&&(g?g.openImage(k):(m(!0),f(!0)))},e[10]=g,e[11]=k,e[12]=N):N=e[12];const C=N;if(b){let O;return e[13]!==s?(O=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=O):O=e[14],O}if(y&&p===y){const O=s?`: ${s}`:"";let $;return e[15]!==O?($=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",O]}),e[15]=O,e[16]=$):$=e[16],$}const S=`Open ${s||"rendered image"}`;let _;e[17]!==i?(_=G("group/image relative my-3 block h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 transition-colors hover:bg-muted focus-visible:ring-ring/40",i),e[17]=i,e[18]=_):_=e[18];const P=s??"";let A;e[19]!==y?(A=()=>h(y),e[19]=y,e[20]=A):A=e[20];let T;e[21]!==a?(T=G("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=T):T=e[22];let E;e[23]!==y||e[24]!==T||e[25]!==P||e[26]!==A?(E=r.jsx("img",{src:y,alt:P,loading:"lazy",decoding:"async",onError:A,className:T}),e[23]=y,e[24]=T,e[25]=P,e[26]=A,e[27]=E):E=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(sa,{className:"size-3.5","data-icon":"icon"})}),e[28]=R):R=e[28];let M;e[29]!==C||e[30]!==E||e[31]!==S||e[32]!==_?(M=r.jsxs(Z,{type:"button",variant:"ghost",onClick:C,"aria-label":S,className:_,children:[E,R]}),e[29]=C,e[30]=E,e[31]=S,e[32]=_,e[33]=M):M=e[33];let I;e[34]!==d||e[35]!==u||e[36]!==k?(I=u&&k&&r.jsx(gd,{open:d,images:[k],initialIndex:0,onClose:()=>f(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=u,e[36]=k,e[37]=I):I=e[37];let D;return e[38]!==M||e[39]!==I?(D=r.jsxs(r.Fragment,{children:[M,I]}),e[38]=M,e[39]=I,e[40]=D):D=e[40],D}function bC(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("w-full caption-bottom text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:o,...s})}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function vC(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("[&_tr]:border-b",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("thead",{"data-slot":"table-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function yC(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("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tbody",{"data-slot":"table-body",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function 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("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tr",{"data-slot":"table-row",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function jC(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-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("th",{"data-slot":"table-head",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function SC(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("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("td",{"data-slot":"table-cell",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function kC(n){if(!n)return null;let e=n;if(e.toLowerCase().startsWith("file://"))try{const l=new URL(e);e=`${l.pathname}${l.hash}`}catch{return null}const t=e.startsWith("/")&&!e.startsWith("//"),s=/^\/?[a-z]:[\\/]/i.test(e);if(!t&&!s)return null;let o,i;const a=e.match(/#L(\d+)(?:C(\d+))?$/i);if(a)o=Number(a[1]),i=a[2]?Number(a[2]):void 0,e=e.slice(0,-a[0].length);else{const l=e.match(/:(\d+)(?::(\d+))?$/);l&&(o=Number(l[1]),i=l[2]?Number(l[2]):void 0,e=e.slice(0,-l[0].length))}try{e=decodeURIComponent(e)}catch{return null}return/^\/[a-z]:[\\/]/i.test(e)&&(e=e.slice(1)),{path:e,line:o,column:i}}function NC(n){const e=B.c(17);let t,s,o;e[0]!==n?({href:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=bn("hostFiles");let a;e[4]!==s?(a=kC(s),e[4]=s,e[5]=a):a=e[5];const l=a;if(l&&!i){let u;return e[6]!==t||e[7]!==s?(u=r.jsx("span",{className:"text-muted-foreground",title:s,children:t}),e[6]=t,e[7]=s,e[8]=u):u=e[8],u}let c;e[9]!==l||e[10]!==s?(c=u=>{s&&(u.preventDefault(),l?ir(l.path,{line:l.line,column:l.column}):window.open(s,"_blank","noopener,noreferrer"))},e[9]=l,e[10]=s,e[11]=c):c=e[11];const d=c;let f;return e[12]!==t||e[13]!==d||e[14]!==s||e[15]!==o?(f=r.jsx("a",{href:s,onClick:d,className:"text-primary underline decoration-primary/30 hover:decoration-primary/60 cursor-pointer transition-colors",title:s,...o,children:t}),e[12]=t,e[13]=d,e[14]=s,e[15]=o,e[16]=f):f=e[16],f}const CC=[...px].map(n=>n.slice(1)).join("|"),_C=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${CC}))[ \\t]*$`,"gim");function hx(n){return n.replace(_C,(e,t,s)=>`${t}`)}const Fn={code:Z4,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:NC,h1({children:n}){return r.jsx("h1",{className:"text-xl font-semibold mt-6 mb-3 pb-2 border-b border-border/40 text-foreground first:mt-0",children:n})},h2({children:n}){return r.jsx("h2",{className:"text-lg font-semibold mt-5 mb-2 pb-1.5 border-b border-border/30 text-foreground first:mt-0",children:n})},h3({children:n}){return r.jsx("h3",{className:"text-base font-semibold mt-4 mb-2 text-foreground first:mt-0",children:n})},h4({children:n}){return r.jsx("h4",{className:"text-sm font-semibold mt-3 mb-1.5 text-foreground first:mt-0",children:n})},h5({children:n}){return r.jsx("h5",{className:"text-sm font-medium mt-3 mb-1 text-foreground first:mt-0",children:n})},h6({children:n}){return r.jsx("h6",{className:"text-xs font-medium mt-3 mb-1 text-muted-foreground first:mt-0",children:n})},p({children:n}){return r.jsx("p",{className:"my-1.5 leading-[1.55] text-foreground/90 first:mt-0 last:mb-0 md:my-2 md:leading-relaxed",children:n})},blockquote({children:n}){return r.jsx("blockquote",{className:"my-2 rounded-r-md border-l-2 border-border bg-muted/30 py-1.5 pl-3 pr-2.5 text-foreground/80 [&>p]:my-1 md:my-3 md:py-2 md:pl-4 md:pr-3",children:n})},ul({children:n}){return r.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},ol({children:n}){return r.jsx("ol",{className:"my-1.5 flex list-decimal flex-col gap-0.5 pl-5 marker:text-muted-foreground/50 [&_ol]:my-1 [&_ul]:my-1 md:my-2 md:gap-1 md:pl-6",children:n})},li({children:n}){return r.jsx("li",{className:"pl-1 leading-[1.55] text-foreground/90 md:leading-relaxed",children:n})},hr(){return r.jsx(Mt,{className:"my-4"})},table({children:n}){return r.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border/40",children:r.jsx(bC,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(vC,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(yC,{children:n})},tr({children:n}){return r.jsx(wC,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(jC,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(SC,{className:"px-3 py-2 text-foreground/90",children:n})},strong({children:n}){return r.jsx("strong",{className:"font-semibold text-foreground",children:n})},em({children:n}){return r.jsx("em",{className:"italic text-foreground/90",children:n})},del({children:n}){return r.jsx("del",{className:"line-through text-muted-foreground",children:n})},img:fc,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Us=[ca],TC=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],EC=TC.join("|");function gx(){return new RegExp(`<(${EC})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function _d(n){return n.replace(gx(),"").trim()}function PC(n){return gx().test(n)}const AC=/<command-message>([^<]+)<\/command-message>/,RC=/<command-name>([\s\S]*?)<\/command-name>/,IC=/<command-args>([\s\S]*?)<\/command-args>/;function xx(n){const e=n.match(AC);if(e)return e[1];const t=n.match(RC);return t?t[1].trim().replace(/^\//,""):null}function bx(n){const e=n.match(IC);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const vx={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},MC=new RegExp(`<(${Object.keys(vx).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function $C(n){const e=[],t=n.replace(MC,(s,o,i)=>(e.push({text:zg(i).trim(),stream:vx[o]}),"")).trim();return{outputs:e,remainingText:t}}const OC=/<task-notification>([\s\S]*?)<\/task-notification>/g;function Gs(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function ur(n){const e=[],t=n.replace(OC,(s,o)=>(e.push({taskId:Gs(o,"task-id"),toolUseId:Gs(o,"tool-use-id"),outputFile:Gs(o,"output-file"),status:Gs(o,"status"),summary:Gs(o,"summary"),result:Gs(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const DC=/\[Request interrupted by user[^\]]*\]/g;function yx(n){const e=[],t=n.replace(DC,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const dm="[SYSTEM NOTIFICATION - NOT USER INPUT]";function wx(n){const e=n.indexOf(dm);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+dm.length,s=n.indexOf(`
|
|
83
|
+
|
|
84
|
+
`,t),o=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(o)).trim(),isSystemNotification:!0}}const um={Icon:o4,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},fm={completed:{Icon:s4,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...um,label:"Failed"},error:{...um,label:"Error"},running:{Icon:r4,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function jx(n){const e=B.c(32),{notification:t}=n,[s,o]=v.useState(!1),i=fm[t.status]??fm.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?Ze:Je;let d;e[0]!==i.bg?(d=G("my-1 rounded-lg border p-3",i.bg),e[0]=i.bg,e[1]=d):d=e[1];let f;e[2]!==i.color?(f=G("mt-0.5 size-4 shrink-0",i.color),e[2]=i.color,e[3]=f):f=e[3];let u;e[4]!==a||e[5]!==f?(u=r.jsx(a,{className:f}),e[4]=a,e[5]=f,e[6]=u):u=e[6];let m;e[7]!==t.summary?(m=r.jsx("span",{className:"text-sm font-medium text-foreground",children:t.summary}),e[7]=t.summary,e[8]=m):m=e[8];let p;e[9]!==i.badgeVariant||e[10]!==i.color||e[11]!==i.label?(p=r.jsx(Ee,{variant:i.badgeVariant,className:i.color,children:i.label}),e[9]=i.badgeVariant,e[10]=i.color,e[11]=i.label,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==c||e[17]!==s||e[18]!==l||e[19]!==t.outputFile||e[20]!==t.result?(g=l&&r.jsxs(r.Fragment,{children:[r.jsxs(Jt,{render:r.jsx(Z,{type:"button",variant:"ghost",size:"xs",className:"mt-1.5 -ml-2 text-muted-foreground"}),children:[r.jsx(c,{"data-icon":"inline-start"}),s?"Hide detail":"Show detail"]}),r.jsx(wt,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(Rn,{components:Fn,remarkPlugins:Us,children:t.result}),t.outputFile&&r.jsxs("div",{className:"mt-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Output file"}),r.jsx("div",{className:"mt-1 select-all break-all rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground",children:t.outputFile})]})]})})]}),e[16]=c,e[17]=s,e[18]=l,e[19]=t.outputFile,e[20]=t.result,e[21]=g):g=e[21];let x;e[22]!==h||e[23]!==g?(x=r.jsxs("div",{className:"min-w-0 flex-1",children:[h,g]}),e[22]=h,e[23]=g,e[24]=x):x=e[24];let b;e[25]!==u||e[26]!==x?(b=r.jsxs("div",{className:"flex items-start gap-2",children:[u,x]}),e[25]=u,e[26]=x,e[27]=b):b=e[27];let w;return e[28]!==s||e[29]!==d||e[30]!==b?(w=r.jsx(yt,{open:s,onOpenChange:o,className:d,children:b}),e[28]=s,e[29]=d,e[30]=b,e[31]=w):w=e[31],w}function LC(n){const e=B.c(7),{content:t}=n;let s,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const{notifications:l}=ur(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(zC)}e[0]=t,e[1]=s,e[2]=o,e[3]=i}else s=e[1],o=e[2],i=e[3];if(i!==Symbol.for("react.early_return_sentinel"))return i;let a;return e[4]!==s||e[5]!==o?(a=r.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=a):a=e[6],a}function zC(n,e){return r.jsx(jx,{notification:n},n.taskId||`notification-${e}`)}function FC(n){const e=B.c(15),{output:t}=n,s=t.stream==="stderr",o=t.stream==="input",i=s&&"border-destructive/20 bg-destructive/5 text-destructive",a=o&&"border-border bg-muted/50 text-foreground",l=!s&&!o&&"border-border bg-muted/40 text-muted-foreground";let c;e[0]!==i||e[1]!==a||e[2]!==l?(c=G("rounded-md border px-3 py-2 my-1 font-mono text-xs",i,a,l),e[0]=i,e[1]=a,e[2]=l,e[3]=c):c=e[3];let d;e[4]!==s||e[5]!==o?(d=o?r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(po,{className:G("size-3 shrink-0",s?"text-destructive":"text-muted-foreground"),"data-icon":"inline-start"}),e[4]=s,e[5]=o,e[6]=d):d=e[6];let f;e[7]!==t.text?(f=r.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.text}),e[7]=t.text,e[8]=f):f=e[8];let u;e[9]!==d||e[10]!==f?(u=r.jsxs("div",{className:"flex items-center gap-1.5",children:[d,f]}),e[9]=d,e[10]=f,e[11]=u):u=e[11];let m;return e[12]!==c||e[13]!==u?(m=r.jsx("div",{className:c,children:u}),e[12]=c,e[13]=u,e[14]=m):m=e[14],m}function BC(n){const e=B.c(6),{loading:t,content:s}=n;let o;if(t){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground/60 font-mono",children:[r.jsx(Fg,{className:"w-3 h-3 text-muted-foreground/60"})," Loading..."]}),e[0]=a):a=e[0],o=a}else if(s){let a;e[1]!==s?(a=r.jsx(Rn,{components:Fn,remarkPlugins:Us,children:s}),e[1]=s,e[2]=a):a=e[2],o=a}else{let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-muted-foreground/60 font-mono",children:"Could not load command content"}),e[3]=a):a=e[3],o=a}let i;return e[4]!==o?(i=r.jsx("div",{className:"mt-2 max-h-80 overflow-auto rounded-md border border-border bg-muted/40 p-3 text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=i):i=e[5],i}const Td=v.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=mx(),[l,c]=v.useState(!1),[d,f]=v.useState(!1),[u,m]=v.useState(!1),[p,h]=v.useState(null),[g,x]=v.useState(!1),[b,w]=v.useState(null),y=v.useMemo(()=>Pa(e),[e]),j=v.useMemo(()=>xx(y),[y]),k=v.useMemo(()=>bx(y),[y]),{sender:N,body:C,matched:S}=v.useMemo(()=>cr(y),[y]),_=v.useMemo(()=>_d(C),[C]),{text:P,isSystemNotification:A}=v.useMemo(()=>wx(_),[_]),{notifications:T,remainingText:E}=v.useMemo(()=>ur(P),[P]),{outputs:R,remainingText:M}=v.useMemo(()=>$C(E),[E]),{interrupts:I,remainingText:D}=v.useMemo(()=>yx(M),[M]),O=v.useCallback(async V=>{if(!V){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!j)){x(!0),m(!0);try{const Y=await o(j,k??void 0);h(Y)}finally{x(!1)}}},[p,o,j,k]),$=v.useMemo(()=>ux(e),[e]),L=v.useMemo(()=>$.map(V=>`data:${V.source.media_type};base64,${V.source.data}`),[$]),F=v.useMemo(()=>L.map((V,Y)=>({id:`message-attachment-${Y}`,src:V,alt:`Attachment ${Y+1}`,label:L.length>1?`Attachment ${Y+1}`:"Attached image"})),[L]),z=v.useMemo(()=>PC(y)||A||S,[y,A,S]),H=d?y:D,W=H.length>500&&!l?H.slice(0,500)+"...":H,q=V=>{const Y=F[V];Y&&(a?a.openImage(Y):w({index:V,open:!0}))};return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:z&&r.jsx(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>f(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(oa,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(So,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&A&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ee,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(po,{"data-icon":"inline-start"}),"System event"]})}),!d&&S&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ee,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(Yn,{"data-icon":"inline-start"}),N?`From ${N}`:"Teammate message"]})}),j&&r.jsxs(yt,{open:u,onOpenChange:V=>void O(V),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ee,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(po,{"data-icon":"inline-start"}),"/",j,k&&r.jsx("span",{className:"text-muted-foreground",children:k})]}),o&&r.jsxs(Jt,{render:r.jsx(Z,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[u?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),u?"Collapse":"Expand"]}),u&&s&&r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(j),className:"text-muted-foreground",children:[r.jsx(Fs,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(wt,{children:r.jsx(BC,{loading:g,content:p})})]}),L.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:L.map((V,Y)=>r.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>q(Y),"aria-label":`Open attached image ${Y+1}`,className:G("group/image relative h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 text-left","transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"),children:[r.jsx("img",{src:V,alt:`Attachment ${Y+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(sa,{className:"size-3.5","data-icon":"icon"})}),L.length>1&&r.jsxs("span",{className:"absolute bottom-2 right-2 rounded-md bg-black/55 px-1.5 py-0.5 font-mono text-xs text-white/80",children:[Y+1," / ",L.length]})]},`${$[Y].source.media_type}-${$[Y].source.data.slice(0,24)}-${Y}`))}),!d&&T.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:T.map(V=>r.jsx(jx,{notification:V},V.taskId))}),!d&&R.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((V,Y)=>r.jsx(FC,{output:V},Y))}),!d&&I.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:I.map((V,Y)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(sy,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:V})]},Y))}),W&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Rn,{components:Fn,remarkPlugins:Us,children:W})}),H.length>500&&r.jsx(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>c(!l),className:"mt-1 -ml-2 text-muted-foreground",children:l?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(Je,{"data-icon":"inline-start"})," Show more"]})}),!i&&t&&r.jsx("div",{className:"flex items-center mt-1.5 ml-auto",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t).toLocaleTimeString()})})]}),b!==null&&r.jsx(gd,{open:b.open,images:F,initialIndex:b.index,onClose:()=>w(V=>V?{...V,open:!1}:null),onCloseComplete:()=>w(null)},b.index)]})}),Sx=v.memo(function(e){const t=B.c(10),{message:s,turnNumber:o}=e;let i;t[0]!==o?(i=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Turn ",o]}),t[0]=o,t[1]=i):i=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Ee,{variant:"outline",children:"Queued"}),t[2]=a):a=t[2];let l;t[3]!==i?(l=r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[i,a]}),t[3]=i,t[4]=l):l=t[4];let c;t[5]!==s?(c=r.jsx("div",{className:"rounded-lg border border-dashed bg-prompt-surface p-3",children:r.jsx(Td,{content:s,timestamp:""})}),t[5]=s,t[6]=c):c=t[6];let d;return t[7]!==l||t[8]!==c?(d=r.jsxs("div",{className:"motion-enter group relative px-4 py-5",children:[l,c]}),t[7]=l,t[8]=c,t[9]=d):d=t[9],d}),kx=v.memo(function(e){const t=B.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=v.useState(!1),c=o??a,{todos:d,completed:f,total:u}=s,m=u>0?f/u*100:0;let p;t[0]!==i?(p=P=>{i==null||i(P),l(P)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Z,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-none px-3 py-2"}),t[2]=h):h=t[2];let g;t[3]!==c?(g=c?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(vr,{"data-icon":"inline-start"}),t[3]=c,t[4]=g):g=t[4];let x;t[5]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("span",{className:"text-sm font-medium",children:"Tasks"}),t[5]=x):x=t[5];let b;t[6]!==f||t[7]!==u?(b=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[f,"/",u]}),t[6]=f,t[7]=u,t[8]=b):b=t[8];let w;t[9]!==m?(w=m.toFixed(0),t[9]=m,t[10]=w):w=t[10];const y=`${w}% of tasks complete`;let j;t[11]!==m||t[12]!==y?(j=r.jsx(Ar,{value:m,className:"max-w-[200px] flex-1","aria-label":y}),t[11]=m,t[12]=y,t[13]=j):j=t[13];let k;t[14]!==s.inProgress?(k=s.inProgress&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[r.jsx(rt,{className:"size-3 shrink-0 animate-spin"}),r.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=k):k=t[15];let N;t[16]!==g||t[17]!==b||t[18]!==j||t[19]!==k?(N=r.jsxs(Jt,{render:h,children:[g,x,b,j,k]}),t[16]=g,t[17]=b,t[18]=j,t[19]=k,t[20]=N):N=t[20];let C;t[21]!==d?(C=d.map(UC),t[21]=d,t[22]=C):C=t[22];let S;t[23]!==C?(S=r.jsx(wt,{children:r.jsx("div",{className:"px-3 pb-3 pt-1",children:r.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:C})})}),t[23]=C,t[24]=S):S=t[24];let _;return t[25]!==c||t[26]!==p||t[27]!==N||t[28]!==S?(_=r.jsxs(yt,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[N,S]}),t[25]=c,t[26]=p,t[27]=N,t[28]=S,t[29]=_):_=t[29],_});function UC(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(Pn,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?r.jsx(rt,{className:"size-3 shrink-0 animate-spin text-info"}):r.jsx(Fc,{className:"size-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:G("truncate text-xs",n.status==="in_progress"?"text-foreground":"text-muted-foreground",n.status==="completed"&&"line-through"),children:n.content}),n.owner&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:n.owner})]},n.id??e)}function Dr(n,e){const t=B.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const d=localStorage.getItem(n);return d===null?e:JSON.parse(d)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[o,i]=v.useState(s);let a;t[3]!==n?(a=d=>{i(f=>{const u=typeof d=="function"?d(f):d;try{localStorage.setItem(n,JSON.stringify(u))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return u})},t[3]=n,t[4]=a):a=t[4];const l=a;let c;return t[5]!==l||t[6]!==o?(c=[o,l],t[5]=l,t[6]=o,t[7]=c):c=t[7],c}function Nx(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function WC(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const HC="cogpit:provider-update-dismissals:v1";function KC(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(Nx(t)))}async function qC(n){const e=await ye("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function VC(n){const e=await ye("/api/provider-updates/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n})}),t=await e.json();if(!t.status)throw new Error(t.error??`Update failed (${e.status})`);return t}const GC=360*60*1e3;function YC(){const[n,e]=v.useState([]),[t,s]=Dr(HC,[]),[o,i]=v.useState(null),[a,l]=v.useState(null);v.useEffect(()=>{const f=new AbortController,u=()=>{qC(f.signal).then(e).catch(()=>{})};u();const m=setInterval(u,GC);return()=>{f.abort(),clearInterval(m)}},[]);const c=v.useCallback(async f=>{i(f),l(null);try{const u=await VC(f);l(u),e(m=>m.map(p=>p.provider===f?u.info:p))}catch(u){l({provider:f,status:"failed",message:u instanceof Error?u.message:"Update failed.",output:null})}finally{i(null)}},[]),d=v.useCallback(f=>{s(u=>WC(u,Nx(f)))},[s]);return{pending:KC(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:v.useCallback(()=>l(null),[])}}const XC=5e3,JC={warning:"border-warning/30 bg-warning/10 text-warning",destructive:"border-destructive/30 bg-destructive/10 text-destructive",success:"border-success/30 bg-success/10 text-success"};function hl(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${JC[n]}`}function mm(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function Cx(){const n=B.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=YC(),l=lt("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,f;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const E=setTimeout(a,XC);return()=>clearTimeout(E)},f=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=f):(d=n[2],f=n[3]),v.useEffect(d,f),s){let E;return n[4]!==a||n[5]!==s.message||n[6]!==c?(E=c?r.jsxs(St,{className:hl("success"),children:[r.jsx(ea,{}),r.jsx(It,{children:s.message}),r.jsx(kt,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(St,{className:hl("destructive"),children:[r.jsx(Ss,{}),r.jsx(It,{children:"Update did not complete"}),r.jsx(kt,{className:"text-destructive/80",children:s.message}),r.jsx(ys,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(Z,{variant:"ghost",size:"xs",onClick:a,children:"Dismiss"})})]}),n[4]=a,n[5]=s.message,n[6]=c,n[7]=E):E=n[7],E}if(e.length===0)return null;const u=e[0],m=e.filter(E=>E.updateCommand!==null&&l),p=St;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=hl("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(rt,{className:"animate-spin"}):r.jsx(yn,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==u||n[12]!==e?(x=e.length===1?mm(u):`${e.map(QC).join(" and ")} are out of date`,n[11]=u,n[12]=e,n[13]=x):x=n[13];let b;n[14]!==x?(b=r.jsx(It,{children:x}),n[14]=x,n[15]=b):b=n[15];const w=e.length>1?e.map(mm).join(" · "):m.length===1?`Cogpit can run \`${u.updateCommand}\` for you.`:u.updateCommand?`Run \`${u.updateCommand}\` to upgrade.`:"Update it with whatever installed it — Cogpit could not tell.";let y;n[16]!==w?(y=r.jsx(kt,{className:"text-warning/80",children:w}),n[16]=w,n[17]=y):y=n[17];const j=ys,k="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let N;n[18]!==e.length||n[19]!==o||n[20]!==t?(N=E=>r.jsxs(Z,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(E.provider),children:[r.jsx(Gl,{"data-icon":"inline-start"}),t===E.provider?"Updating…":e.length===1?"Update":`Update ${E.displayName}`]},E.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=N):N=n[21];const C=m.map(N),S=t!==null;let _;n[22]!==i||n[23]!==e?(_=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=_):_=n[24];let P;n[25]!==S||n[26]!==_?(P=r.jsx(Z,{variant:"ghost",size:"xs",disabled:S,onClick:_,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=S,n[26]=_,n[27]=P):P=n[27];let A;n[28]!==j||n[29]!==C||n[30]!==P?(A=r.jsxs(j,{className:k,children:[C,P]}),n[28]=j,n[29]=C,n[30]=P,n[31]=A):A=n[31];let T;return n[32]!==p||n[33]!==A||n[34]!==h||n[35]!==g||n[36]!==b||n[37]!==y?(T=r.jsxs(p,{className:h,children:[g,b,y,A]}),n[32]=p,n[33]=A,n[34]=h,n[35]=g,n[36]=b,n[37]=y,n[38]=T):T=n[38],T}function QC(n){return n.displayName}function _x(){const n=B.c(27),[e,t]=v.useState(null),[s,o]=v.useState(null),[i,a]=v.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const d=window.electronUpdater;d&&(d.onUpdateAvailable(f=>{t(f)}),d.onUpdateDownloaded(f=>{o(f)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),v.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Gl,{}),n[2]=d):d=n[2];let f;n[3]!==s.version?(f=r.jsxs(It,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=f):f=n[4];let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(kt,{className:"text-success/80",children:"Restart to apply the update."}),n[5]=u):u=n[5];let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>a(!0),n[6]=m):m=n[6];let p;n[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(ys,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(Z,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:r.jsx(Nt,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==f?(h=r.jsxs(St,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-success/30 bg-success/10 px-4 py-2 pr-4 text-success has-data-[slot=alert-action]:pr-4",children:[d,f,u,p]}),n[8]=f,n[9]=h):h=n[9],h}if(e&&!i){let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Gl,{}),n[10]=d):d=n[10];let f;n[11]!==e.version?(f=r.jsxs(It,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=f):f=n[12];let u;n[13]!==e.platform?(u=e.platform!=="mac"&&r.jsx(kt,{children:"Update through your package manager."}),n[13]=e.platform,n[14]=u):u=n[14];let m;n[15]!==e.platform||n[16]!==e.url?(m=e.platform==="mac"&&r.jsxs(Z,{variant:"outline",size:"xs",render:r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[r.jsx(oy,{"data-icon":"inline-start"}),"Download"]}),n[15]=e.platform,n[16]=e.url,n[17]=m):m=n[17];let p;n[18]!==e.version?(p=r.jsx(Z,{variant:"ghost",size:"xs",onClick:()=>{var x;a(!0),(x=window.electronUpdater)==null||x.dismissVersion(e.version)},className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[18]=e.version,n[19]=p):p=n[19];let h;n[20]!==m||n[21]!==p?(h=r.jsxs(ys,{className:"static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center",children:[m,p]}),n[20]=m,n[21]=p,n[22]=h):h=n[22];let g;return n[23]!==f||n[24]!==u||n[25]!==h?(g=r.jsxs(St,{className:"grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 border-info/30 bg-info/10 px-4 py-2 pr-4 text-info has-data-[slot=alert-action]:pr-4",children:[d,f,u,h]}),n[23]=f,n[24]=u,n[25]=h,n[26]=g):g=n[26],g}return null}const Tx=v.createContext(null);function ji(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(Tx.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Ot(){const n=v.useContext(Tx);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const fr=null,{min:Is,max:un,abs:pm,floor:ZC}=Math,Ex=(n,e,t)=>Is(t,un(e,n)),Px=n=>[...n].sort((e,t)=>e-t),Ax=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},mc=()=>{let n;return[new Promise(e=>{n=e}),n]},Rx=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},Yo=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},Ix=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},e_=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=Is(e,n.i),s},Si=(n,e)=>{if(!n.l)return 0;if(n.i>=e)return n.u[e];n.i<0&&(n.u[0]=0,n.i=0);let t=n.i,s=n.u[t];for(;t<e;)s+=Ix(n,t),n.u[++t]=s;return n.i=e,s},Ys=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=ZC((t+s)/2);Si(n,i)<=e?(o=i,t=i+1):s=i-1}return Ex(o,0,n.l-1)},hm=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:Is(e-1,n.i),n.l=e,s>0?(Yo(n.u,s),Yo(n.t,s,t),n.o*s):(n.u.splice(s),(t?n.t.splice(0,-s):n.t.splice(s)).reduce((o,i)=>o-(i===-1?n.o:i),0))},t_=typeof window<"u",n_=n=>n.documentElement,s_=n=>n.ownerDocument,o_=n=>n.defaultView,Mx=Rx(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),r_=Rx(()=>"scrollBehavior"in n_(document).style),i_=n=>un(n.h(),n.p()),a_=(n,e=40,t=0,s,o=!1)=>{let i=!!t,a=1,l=0,c=0,d=0,f=0,u=0,m=0,p=0,h=0,g=fr,x=[0,i?un(t-1,0):-1],b=0,w=!1;const y=((E,R,M)=>({o:R,t:M?Yo(M.slice(0,Is(E,M.length)),un(0,E-M.length)):Yo([],E),l:E,i:-1,u:Yo([],E+1)}))(n,s?s[1]:e,s&&s[0]),j=new Set,k=()=>d-c,N=()=>k()+u+f,C=(E,R)=>((M,I,D,O)=>{if(O=Is(O,M.l-1),Si(M,O)<=I){const $=Ys(M,D,O);return[Ys(M,I,O,$),$]}{const $=Ys(M,I,void 0,O);return[$,Ys(M,D,$)]}})(y,E,R,x[0]),S=()=>Si(y,y.l),_=(E,R)=>{const M=Si(y,E)-u;return R?S()-M-P(E):M},P=E=>Ix(y,E),A=(E,R=-1)=>y.t[E]===R,T=E=>{E&&(Mx()&&p!==0||g&&h===1?u+=E:f+=E)};return{v:()=>{j.clear()},m:()=>a,_:()=>(E=>[E.t.slice(),E.o])(y),S:(E=200)=>{if(!w||i)return x;let R,M;if(m)[R,M]=x;else{let I=un(0,N()),D=I+l;o||(E=un(0,E),p!==1&&(I-=E),p!==2&&(D+=E)),[R,M]=x=C(un(0,I),un(0,D)),g&&(R=Is(R,g[0]),M=un(M,g[1]))}return[un(R,0),Is(M,y.l-1)]},$:E=>Ys(y,E-c),I:A,k:_,R:P,T:()=>y.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:S,H:()=>(m=f,f=0,[m,h===2]),W:(E,R)=>{const M=[E,R];return j.add(M),()=>{j.delete(M)}},B:(E,R)=>{let M,I,D=0;switch(E){case 1:{if(R===d&&h===0)break;const O=m;m=0;const $=R-d,L=pm($);O&&L<pm(O)+1||h!==0||(p=$<0?2:1),i&&(i=!1),d=R,D=4;const F=k();F>=-l&&F<=S()&&(D+=1,I=L>l);break}case 2:D=8,p!==0&&(M=!0,D+=1),p=0,h=0,g=fr;break;case 3:{const O=R.filter(([$,L])=>!A($,L));if(!O.length)break;T(O.reduce(($,[L,F])=>{let z;if(h===2)z=!0;else if(g&&h===1)z=L<g[0];else{const H=k(),U=_(L),W=P(L);z=p!==1&&h===0?U+W<=H:U<H&&U+W<H+l}return z&&($+=F-P(L)),$},0));for(const[$,L]of O){const F=P($),z=e_(y,$,L);o&&(b+=z?L:L-F)}o&&l&&b>l&&(T((($,L)=>{let F=0;const z=[];$.t.forEach((Y,K)=>{Y!==-1&&(z.push(Y),K<L&&F++)}),$.i=-1;const H=Px(z),U=H.length,W=U/2|0,q=U%2==0?(H[W-1]+H[W])/2:H[W],V=$.o;return(($.o=q)-V)*un(L-F,0)})(y,Ys(y,N()))),o=!1),D=3,I=!0;break}case 4:l!==R&&(l||(w=I=!0),l=R,D=3);break;case 5:R[1]?(T(hm(y,R[0],!0)),h=2,D=1):(hm(y,R[0]),D=1);break;case 6:c=R;break;case 7:h=1;break;case 8:g=C(R,R+l),D=1}D&&(a=1+(2147483647&a),M&&u&&(f+=u,u=0),j.forEach(([O,$])=>{D&O&&$(I)}))}}},Ed=setTimeout,gl=(n,e)=>e?-n:n,l_=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,f=!1,u=!1;const m=(()=>{let b;const w=()=>{b!=fr&&clearTimeout(b)},y=()=>{w(),b=Ed(()=>{b=fr,(()=>{if(c||d)return c=!1,void m();f=!1,n.B(2)})()},150)};return y.J=w,y})(),p=()=>{l=a(),f&&(u=!0),n.B(1,s()),m()},h=b=>{if(c||!n.M()||b.ctrlKey)return;const w=a()-l;150>w&&50<w&&(t?b.deltaX:b.deltaY)&&(c=!0)},g=()=>{d=!0,f=u=!1},x=()=>{d=!1,Mx()&&(f=!0)};return e.addEventListener("scroll",p),e.addEventListener("wheel",h,{passive:!0}),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("touchend",x,{passive:!0}),{A:()=>{e.removeEventListener("scroll",p),e.removeEventListener("wheel",h),e.removeEventListener("touchstart",g),e.removeEventListener("touchend",x),m.J()},L:()=>{const[b,w]=n.H();b&&(o(b,w,u),u=!1,w&&n.p()>n.h()&&n.B(1,s()))}}},c_=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=mc();return s=()=>{c(!1)},n.p()&&Ed(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&r_())n.B(8,o()),Ax(async()=>{for(;;){let l=!0;for(let[f,u]=n.S();f<=u;f++)if(n.I(f)){l=!1;break}if(l)break;const[c,d]=a();try{if(!await c)return}finally{d()}}n.B(7),t(o(),i)});else for(;;){const[l,c]=a();try{if(n.B(7),t(o()),!await l)return}finally{c()}}},()=>{s&&s()}]},d_=(n,e)=>{let t,s,o=mc(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=c_(n,()=>o[0],(f,u)=>{f=gl(f,i),u?t.scrollTo({[e?"left":"top"]:f,behavior:"smooth"}):t[a]=f});return{N(f,u){t=u,e&&(i=getComputedStyle(u).direction==="rtl"),s=l_(n,u,e,()=>gl(u[a],i),(m,p,h)=>{if(h){const g=u.style,x=g[l];g[l]="hidden",Ed(()=>{g[l]=x})}u[a]=gl(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=mc()},P:()=>i,V(f){c(()=>f)},X(f){f+=n.C(),c(()=>f)},Y(f,{align:u,smooth:m,offset:p=0}={}){if(f=Ex(f,0,n.T()-1),u==="nearest"){const h=n.k(f),g=n.C();if(h<g)u="start";else{if(!(h+n.R(f)>g+n.p()))return;u="end"}}c(()=>p+n.O()+n.k(f)+(u==="end"?n.R(f)-n.p():u==="center"?(n.R(f)-n.p())/2:0),m)},q:()=>{s&&s.L()}}},u_=n=>{let e;return{j(t){(e||(e=new(o_(s_(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},f_=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=u_(a=>{const l=[];for(const{target:c,contentRect:d}of a)if(c.offsetParent)if(c===t)n.B(4,d[s]);else{const f=o.get(c);f!=fr&&l.push([f,d[s]])}l.length&&n.B(3,l)});return{G(a){i.j(t=a)},U:(a,l)=>(o.set(a,l),i.j(a),()=>{o.delete(a),i.D(a)}),v:i.A}},$i=t_?v.useLayoutEffect:v.useEffect,Qt="current",$x=(n,e)=>{if(Array.isArray(n))for(const t of n)$x(t,e);else n==null||typeof n=="boolean"||e.push(n)},m_=(n,e)=>{const t=n.key;return t??"_"+e},p_=n=>{const e=v.useRef(null);return e[Qt]||(e[Qt]=n())},gm=n=>{const e=v.useRef(n);return $i(()=>{e[Qt]=n},[n]),e},h_=v.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=v.useRef(null);$i(()=>e(c[Qt],t),[t]);const d=v.useMemo(()=>{const f={contain:"layout style",position:o&&l?void 0:"absolute",[a?"height":"width"]:"100%",[a?"top":"left"]:0,[a?"left":"top"]:s,visibility:!o||l?void 0:"hidden"};return a&&(f.display="inline-flex"),f},[s,o,l,a]);return r.jsx(i,typeof i=="string"?{ref:c,style:d,children:n}:{ref:c,style:d,index:t,children:n})}),g_=(n,e)=>v.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return $x(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),x_=v.forwardRef(({children:n,data:e,bufferSize:t,itemSize:s,shift:o,horizontal:i,keepMounted:a,cache:l,startMargin:c=0,ssrCount:d,as:f="div",item:u="div",scrollRef:m,onScroll:p,onScrollEnd:h},g)=>{const[x,b]=g_(n,e),w=v.useRef(null),y=v.useRef(!!d),j=gm(p),k=gm(h),[N,C,S,_]=p_(()=>{const D=!!i,O=a_(b,s,d,l,!s);return[O,f_(O,D),d_(O,D),D]});b!==N.T()&&N.B(5,[b,o]),c!==N.O()&&N.B(6,c);const[P,A]=v.useReducer(N.m,void 0,N.m),T=N.M(),E=N.h(),R=S.P(),M=[],I=D=>{const O=x(D);return r.jsx(h_,{ee:C.U,te:D,oe:N.k(D,R),ne:N.I(D),re:u,Z:O,se:_,ie:y[Qt]},m_(O,D))};if($i(()=>{y[Qt]=!1,N.W(1,$=>{$?Hb.flushSync(A):A()}),N.W(4,()=>{j[Qt]&&j[Qt](N.C())}),N.W(8,()=>{k[Qt]&&k[Qt]()});const D=w[Qt],O=$=>{C.G($),S.N(D,$)};return m?Ax(()=>{m[Qt]&&O(m[Qt])}):O(D.parentElement),()=>{N.v(),C.v(),S.v()}},[]),$i(()=>{S.q()},[P]),v.useImperativeHandle(g,()=>({get cache(){return N._()},get scrollOffset(){return N.C()},get scrollSize(){return i_(N)},get viewportSize(){return N.p()},findItemIndex:N.$,getItemOffset:N.k,getItemSize:N.R,scrollToIndex:S.Y,scrollTo:S.V,scrollBy:S.X}),[]),a){const D=new Set(a);for(let[O,$]=N.S(t);O<=$;O++)D.add(O);Px([...D]).forEach(O=>{M.push(I(O))})}else for(let[D,O]=N.S(t);D<=O;D++)M.push(I(D));return r.jsx(f,{ref:w,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:_?E:"100%",height:_?"100%":E,pointerEvents:T?"none":void 0},children:M})});function Aa(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(iy,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Ra(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("select-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ry,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ia(n){const e=B.c(18);let t,s,o,i,a,l;e[0]!==n?({className:t,align:o,alignOffset:i,side:a,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6]);const c=o===void 0?"start":o,d=i===void 0?4:i,f=a===void 0?"right":a,u=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(mh,{"data-slot":"context-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==u||e[16]!==p?(h=r.jsx(gh,{children:r.jsx(xh,{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 fo(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(ph,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function AO(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(hh,{"data-slot":"context-menu-label","data-inset":s,className:i,...o}),e[6]=s,e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function Zt(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/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l||e[10]!==a?(c=r.jsx(fh,{"data-slot":"context-menu-item","data-inset":s,"data-variant":a,className:l,...o}),e[7]=s,e[8]=o,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}function mr(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(Ac,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function b_(n){const e=B.c(22),{children:t,turnIndex:s,branches:o,onRestoreToHere:i,onOpenBranches:a,onBranchFromHere:l}=n;let c;e[0]!==t?(c=r.jsx(Ra,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let d;e[2]!==i||e[3]!==s?(d=()=>i(s),e[2]=i,e[3]=s,e[4]=d):d=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Uc,{"data-icon":"inline-start"}),e[5]=f):f=e[5];let u;e[6]!==d?(u=r.jsx(fo,{children:r.jsxs(Zt,{onClick:d,children:[f,"Restore to this point"]})}),e[6]=d,e[7]=u):u=e[7];let m;e[8]!==o.length||e[9]!==a||e[10]!==s?(m=o.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(mr,{}),r.jsx(fo,{children:r.jsxs(Zt,{onClick:()=>a(s),children:[r.jsx(Bc,{"data-icon":"inline-start"}),"View branches (",o.length,")"]})})]}),e[8]=o.length,e[9]=a,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&r.jsxs(r.Fragment,{children:[r.jsx(mr,{}),r.jsx(fo,{children:r.jsxs(Zt,{onClick:()=>l(s),children:[r.jsx(An,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==u||e[16]!==m||e[17]!==p?(h=r.jsxs(Ia,{className:"min-w-44",children:[u,m,p]}),e[15]=u,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=r.jsxs(Aa,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function v_(n){const e=B.c(15),{redoTurnCount:t,onRedoAll:s}=n;if(t<=0)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Uc,{className:"size-4","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsx("span",{className:"font-mono",children:t}),e[1]=t,e[2]=i):i=e[2];const a=t!==1?"s":"";let l;e[3]!==a?(l=r.jsxs("span",{children:["turn",a," archived"]}),e[3]=a,e[4]=l):l=e[4];let c;e[5]!==i||e[6]!==l?(c=r.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[o,i,l]}),e[5]=i,e[6]=l,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(Mt,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ay,{"data-icon":"inline-start"}),e[9]=f):f=e[9];let u;e[10]!==s?(u=r.jsxs(Z,{variant:"default",size:"sm",onClick:s,children:[f,"Redo all"]}),e[10]=s,e[11]=u):u=e[11];let m;return e[12]!==c||e[13]!==u?(m=r.jsxs("div",{className:"sticky bottom-0 flex items-center justify-center gap-3 border-t border-border bg-background/95 px-4 py-2",role:"status",children:[c,d,u]}),e[12]=c,e[13]=u,e[14]=m):m=e[14],m}const xm=new Map;function y_(n){let e=xm.get(n);if(!e){const t=new Map;e={observer:new IntersectionObserver(o=>{var i;for(const a of o)(i=t.get(a.target))==null||i(a.isIntersecting)},{rootMargin:n}),callbacks:t},xm.set(n,e)}return e}function Ox(n){const e=B.c(5),t="100%",s=v.useRef(null),[o,i]=v.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:f,callbacks:u}=y_(t);return u.set(d,i),f.observe(d),()=>{f.unobserve(d),u.delete(d)}},l=[t],e[0]=t,e[1]=a,e[2]=l):(a=e[1],l=e[2]),v.useEffect(a,l);let c;return e[3]!==o?(c={ref:s,isNear:o},e[3]=o,e[4]=c):c=e[4],c}function Oi(n){if(typeof n!="string"||n.length===0)return Number.NEGATIVE_INFINITY;const e=Date.parse(n);return Number.isFinite(e)?e:Number.NEGATIVE_INFINITY}function bm(n){const e=Oi(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Oi(n.lastModified)}function vm(n,e){return n===e?0:e-n}function ym(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function w_(n,e){const t=vm(bm(n),bm(e));if(t!==0)return t;const s=vm(Oi(n.lastModified),Oi(e.lastModified));return s!==0?s:ym(n).localeCompare(ym(e))}function Pd(n){return[...n].sort(w_)}function Dx(n,e){const t=!!(n.teamName&&n.agentName);return e||pn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const j_="Unknown project";function Ad(n){const e=ha(n);return pa(e?e.parentPath:n,2)||j_}function S_(n){return Ad(n.cwd||gn(n.dirName))}function k_(n){const e=Pd(n),t=new Map;for(const s of e){const o=S_(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function Lx(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function N_(n,e,t){let s=-1;return n.forEach((o,i)=>{Lx(o,e)&&(s=i)}),Math.max(t,s+1)}const Rd=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),C_=12e4;function __(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<C_}function zx(n,e,t=Date.now()){return Lx(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:__(n,t)}function T_(n,e,t=Date.now()){return n.some(s=>zx(s,e,t))}const E_="cogpit:session-list-cache",P_=10080*60*1e3,A_=24,Kn={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},pc=new Map;function R_(){return{version:1,entries:{}}}function Fx(){return Ft(E_)}function Bx(){const n=Fx(),e=pc.get(n);if(e)return e;let t=R_();try{const s=localStorage.getItem(n);if(s){const o=JSON.parse(s);o.version===1&&o.entries&&typeof o.entries=="object"&&(t=o)}}catch{}return pc.set(n,t),t}function Ux(n){const e=Bx().entries[n];if(!(!e||Date.now()-e.savedAt>P_))return e.value}function Wx(n,e){const t=Fx(),o={...Bx().entries,[n]:{savedAt:Date.now(),value:e}},i=Object.entries(o).sort(([,l],[,c])=>c.savedAt-l.savedAt),a={version:1,entries:Object.fromEntries(i.slice(0,A_))};pc.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function Di(n){const e=Ux(n);return Array.isArray(e)?e:void 0}function Xo(n,e){Wx(n,e)}function Hx(n){return`sessions:${n}`}function I_(n){const e=Ux(Hx(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function M_(n,e){Wx(Hx(n),e)}const $_=2e4;function O_(n){const e=new Map;for(const t of n){if(!t.sessionId)continue;const s=e.get(t.sessionId);(!s||t.memMB>s.memMB)&&e.set(t.sessionId,t)}return e}const Kx=v.createContext(null);function D_({children:n}){const[e]=v.useState(mn),[t,s]=v.useState(()=>Di(Kn.activeSessions)??[]),[o,i]=v.useState(()=>Di(Kn.runningProcesses)??[]),[a,l]=v.useState(!1),[c,d]=v.useState(null),[f,u]=v.useState(new Set),m=v.useRef(null),p=v.useRef(null),h=v.useRef(!1);v.useEffect(()=>(h.current=!0,()=>{var N;h.current=!1,(N=p.current)==null||N.abort(),p.current=null}),[]);const g=v.useCallback(async()=>{var S;if(!h.current||mn()!==e)return;(S=p.current)==null||S.abort();const N=new AbortController;p.current=N;const C=()=>h.current&&!N.signal.aborted&&p.current===N&&mn()===e;l(!0);try{const[_,P]=await Promise.all([ye("/api/active-sessions",{signal:N.signal}),ye("/api/running-processes",{signal:N.signal})]);if(!C())return;if(!_.ok||!P.ok)throw new Error("Failed to fetch live data");const[A,T]=await Promise.all([_.json(),P.json()]);if(!C())return;const E=Array.isArray(A)?A:[],R=Array.isArray(T)?T:[];s(E),i(R),Xo(Kn.activeSessions,E),Xo(Kn.runningProcesses,R),d(null)}catch(_){if(!C())return;d(_ instanceof Error?_.message:"Failed to load data")}finally{C()&&l(!1),p.current===N&&(p.current=null)}},[e]),x=v.useCallback(()=>{g()},[g]);v.useEffect(()=>{x()},[x]);const b=v.useMemo(()=>O_(o),[o]),w=v.useMemo(()=>T_(t,b),[t,b]);v.useEffect(()=>(window.addEventListener("focus",x),()=>window.removeEventListener("focus",x)),[x]),v.useEffect(()=>{if(!w)return;const N=setInterval(()=>{document.visibilityState==="visible"&&x()},$_);return()=>clearInterval(N)},[w,x]),v.useEffect(()=>{if(t.length===0)return;const N=m.current,C=new Map;for(const S of t)S.agentStatus&&b.has(S.sessionId)&&C.set(S.sessionId,S.agentStatus);N!==null&&u(S=>{let _=null;for(const[P,A]of C)A==="completed"&&N.get(P)!=="completed"&&(_??(_=new Set(S)),_.add(P));for(const P of S)C.get(P)!=="completed"&&(_??(_=new Set(S)),_.delete(P));return _??S}),m.current=C},[t,b]);const y=v.useCallback(N=>{u(C=>{if(!C.has(N))return C;const S=new Set(C);return S.delete(N),S})},[]),j=v.useCallback(N=>{s(C=>{const S=C.filter(_=>_.sessionId!==N);return mn()===e&&Xo(Kn.activeSessions,S),S})},[e]),k=v.useMemo(()=>({sessions:t,processes:o,procBySession:b,newlyCompleted:f,loading:a,error:c,refresh:x,removeSession:j,acknowledgeCompleted:y}),[t,o,b,f,a,c,x,j,y]);return r.jsx(Kx.Provider,{value:k,children:n})}function qx(){const n=Id();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function Id(){return v.useContext(Kx)}const wm=[20,50,80,110,140,170,200,230,260,290,320,350];function L_(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return wm[(e>>>0)%wm.length]}function xl(n){const e=[];let t=!1;for(const s of n.split(`
|
|
85
|
+
`)){if(/^\s*(```|~~~)/.test(s)){t=!t;continue}let o=s;if(!t){if(o=o.replace(/^\s{0,3}#{1,6}\s+/,"").replace(/^\s*>\s?/,"").replace(/^\s*(?:[-*+]|\d+[.)])\s+/,""),/^\s*(?:[-*_]\s*){3,}$/.test(o))continue;o=o.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\[[^\]]*\]/g,"$1").replace(/(\*\*|__|~~)(.*?)\1/g,"$2").replace(new RegExp("(?<![\\w*])[*_](?=\\S)([^*_]+?)(?<=\\S)[*_](?![\\w*])","g"),"$1").replace(/`+/g,"")}const i=o.trim();i&&e.push(i)}return e.join(" ")}function z_(n){const e=n.split(`
|
|
86
|
+
`);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=xl(e[t]??"");return s?{subject:s,preview:xl(e.slice(t+1).join(`
|
|
87
|
+
`))}:{subject:xl(n),preview:""}}function hc(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function F_(n,e){return n===null||e===null||e<n?null:e-n}function B_(n){const e=hc(n);return e===null?null:new Date(e).toLocaleTimeString()}function U_(n){var s;const e=(s=Id())==null?void 0:s.sessions;let t;e:{if(!n||!e){t=null;break e}const o=e.filter(a=>a.agentName===n);if(o.length!==1){t=null;break e}const i=o[0].agentStatus;if(!i){t=null;break e}t=Rd.has(i)?"working":"idle"}return t}const W_=v.memo(function(e){const t=B.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=v.useState(!1);let f;t[0]!==o?(f=kk(o),t[0]=o,t[1]=f):f=t[1];const u=f;let m;t[2]!==u?(m=z_(u),t[2]=u,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=B_(i),t[4]=i,t[5]=g):g=t[5];const x=g,b=U_(s);let w;t[6]!==u?(w=Ek(u),t[6]=u,t[7]=w):w=t[7];const y=w,j=y&&!a,k=hc(i),N=a?F_(k,hc(a.timestamp)):null,C=!a&&l===!0,S=!!a||y;pg(C&&S);const _=!0;let P;t[8]!==s?(P=L_(s),t[8]=s,t[9]=P):P=t[9];const A=String(P);let T;t[10]!==A?(T={"--agent-hue":A},t[10]=A,t[11]=T):T=t[11];const E=T,R="my-2 rounded-lg border border-l-[3px] border-border bg-card px-3 py-2 [border-left-color:oklch(0.52_0.16_var(--agent-hue))] dark:[border-left-color:oklch(0.74_0.14_var(--agent-hue))]";let M;t[12]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(ly,{className:"size-3.5 shrink-0 text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]","data-icon":"inline-start"}),t[12]=M):M=t[12];let I;t[13]!==s?(I=r.jsx("span",{className:"truncate font-mono text-xs font-medium text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]",children:s}),t[13]=s,t[14]=I):I=t[14];let D;t[15]!==b||t[16]!==s?(D=b&&r.jsx("span",{"data-testid":"agent-liveness","data-live":b,title:b==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${b==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=b,t[16]=s,t[17]=D):D=t[17];let O;t[18]!==I||t[19]!==D?(O=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[M,I,D]}),t[18]=I,t[19]=D,t[20]=O):O=t[20];let $;t[21]!==j?($=j&&r.jsx(Ee,{variant:"outline",className:"h-4 border-warning/30 bg-warning/10 px-1.5 text-[10px] tracking-wide text-warning uppercase",children:"Needs you"}),t[21]=j,t[22]=$):$=t[22];let L;t[23]!==x?(L=x&&r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=L):L=t[24];let F;t[25]!==$||t[26]!==L?(F=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[$,L]}),t[25]=$,t[26]=L,t[27]=F):F=t[27];let z;t[28]!==O||t[29]!==F?(z=r.jsxs("div",{className:"flex items-center gap-2",children:[O,F]}),t[28]=O,t[29]=F,t[30]=z):z=t[30];let H;t[31]!==u||t[32]!==c||t[33]!==h||t[34]!==p?(H=c?r.jsx("div",{"data-testid":"agent-message-body",className:"mt-1.5 max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Rn,{components:Fn,remarkPlugins:Us,children:u})}):r.jsxs(r.Fragment,{children:[r.jsx("p",{"data-testid":"agent-message-subject",className:"mt-1 line-clamp-2 break-words text-sm font-medium text-foreground",children:p}),h&&r.jsx("p",{"data-testid":"agent-message-preview",className:"mt-0.5 line-clamp-2 break-words text-xs leading-relaxed text-muted-foreground",children:h})]}),t[31]=u,t[32]=c,t[33]=h,t[34]=p,t[35]=H):H=t[35];const U="mt-1.5 flex items-center justify-end gap-2",W=S&&r.jsx("p",{"data-testid":"agent-message-state",className:`min-w-0 flex-1 truncate text-xs ${C?"text-warning":"text-muted-foreground"}`,children:a?r.jsxs(r.Fragment,{children:[N===null?"You replied":`You replied ${En(N)} later`,a.summary&&` · "${a.summary}"`]}):C?k===null?"Awaiting your reply":`Awaiting your reply · ${En(Math.max(0,Date.now()-k))}`:"Never answered"});let q;t[36]===Symbol.for("react.memo_cache_sentinel")?(q=()=>d(H_),t[36]=q):q=t[36];let V;t[37]!==u||t[38]!==c?(V=r.jsx(Z,{type:"button",variant:"ghost",size:"xs",onClick:q,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Je,{"data-icon":"inline-start"})," Expand ·"," ",u.length.toLocaleString("en-US")," ",u.length===1?"char":"chars"]})}),t[37]=u,t[38]=c,t[39]=V):V=t[39];let Y;t[40]!==W||t[41]!==V?(Y=r.jsxs("div",{className:U,children:[W,V]}),t[40]=W,t[41]=V,t[42]=Y):Y=t[42];let K;return t[43]!==z||t[44]!==H||t[45]!==Y||t[46]!==E?(K=r.jsxs("div",{"data-agent-rail":_,style:E,className:R,children:[z,H,Y]}),t[43]=z,t[44]=H,t[45]=Y,t[46]=E,t[47]=K):K=t[47],K});function H_(n){return!n}const K_=1500;function yo(){const n=B.c(5),[e,t]=v.useState(!1),s=v.useRef(null);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{s.current&&clearTimeout(s.current)},i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),v.useEffect(o,i);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async d=>{await Sr(d)&&(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),K_))},n[2]=a):a=n[2];const l=a;let c;return n[3]!==e?(c=[e,l],n[3]=e,n[4]=c):c=n[4],c}const q_=v.memo(function(e){const t=B.c(20),{text:s,model:o,effort:i,timestamp:a,compact:l}=e,c=l===void 0?!1:l;let d;t[0]!==s?(d=hx(s),t[0]=s,t[1]=d):d=t[1];const f=d,[u,m]=yo();if(!s)return null;let p;t[2]!==c||t[3]!==u||t[4]!==m||t[5]!==i||t[6]!==o||t[7]!==s||t[8]!==a?(p=!c&&r.jsxs("div",{className:"mb-1 flex min-h-6 items-center justify-end gap-1.5",children:[o&&r.jsx("span",{className:"text-xs text-muted-foreground",children:Nr(o)}),i&&r.jsx("span",{className:"text-xs text-muted-foreground",title:`Reasoning effort: ${i}`,children:i}),(o||i)&&a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),a&&r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(a).toLocaleTimeString()}),r.jsx(Z,{variant:"ghost",size:"icon-sm",className:"opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100",onClick:()=>m(s),"aria-label":u?"Response copied":"Copy response",title:u?"Copied":"Copy response",children:u?r.jsx(ft,{"data-icon":"inline-start"}):r.jsx(An,{"data-icon":"inline-start"})})]}),t[2]=c,t[3]=u,t[4]=m,t[5]=i,t[6]=o,t[7]=s,t[8]=a,t[9]=p):p=t[9];const h=c&&"leading-relaxed";let g;t[10]!==h?(g=G("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==f?(x=r.jsx(Rn,{components:Fn,remarkPlugins:Us,children:f}),t[12]=f,t[13]=x):x=t[13];let b;t[14]!==g||t[15]!==x?(b=r.jsx("div",{className:g,children:x}),t[14]=g,t[15]=x,t[16]=b):b=t[16];let w;return t[17]!==p||t[18]!==b?(w=r.jsxs("div",{className:"group",children:[p,b]}),t[17]=p,t[18]=b,t[19]=w):w=t[19],w}),io=[];function V_(n){return n.map(e=>({messageId:e.messageId,parentToolUseId:e.parentToolUseId,stopped:e.stopped,...e.stopped?{stoppedAt:Date.now()}:{},blocks:e.blocks.map(t=>({...t}))}))}function G_(n,e){if(e.length===0)return n;const t=n.slice(),s=new Map,o=i=>{let a=s.get(i.messageId);if(a)return a;const l=t.findIndex(c=>c.messageId===i.messageId);return l>=0?(a={...t[l],blocks:t[l].blocks.map(c=>({...c}))},t[l]=a):(a={messageId:i.messageId,parentToolUseId:i.parentToolUseId,stopped:!1,blocks:[]},t.push(a)),s.set(i.messageId,a),a};for(const i of e){const a=o(i);if(i.event==="message_stop"){a.stopped=!0,a.stoppedAt=Date.now();continue}let l=a.blocks.find(c=>c.index===i.blockIndex);l||(l={index:i.blockIndex,blockType:i.blockType,...i.toolName?{toolName:i.toolName}:{},text:""},a.blocks.push(l)),i.delta&&(l.text+=i.delta)}return t}const jm=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function Y_(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){jm.lastIndex=0;let i;for(;(i=jm.exec(o))!==null;)t.add(i[1])}if(t.size===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!t.has(o.messageId));return s.length===n.length?n:s}function X_(n,e=1e4,t=Date.now()){if(n.length===0)return n;const s=n.filter(o=>o.parentToolUseId!==null||!(o.stopped&&o.stoppedAt!==void 0&&t-o.stoppedAt>e));return s.length===n.length?n:s}function J_(n){return n.filter(e=>e.parentToolUseId===null)}function Q_(n,e){return n.filter(t=>t.parentToolUseId===e)}const Vx={},Gx=v.createContext(io),Yx=v.createContext(Vx);function bl(n){const e=B.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?Vx:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(Yx.Provider,{value:i,children:o}),e[0]=i,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==a||e[4]!==t?(l=r.jsx(Gx.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function Md(){return v.useContext(Gx)}function Z_(n){return v.useContext(Yx)[n]??null}function Xs(n){return function({children:t}){return r.jsx(n,{className:"mt-2 mb-1 text-xs font-semibold text-foreground first:mt-0",children:t})}}const Xx={...Fn,code({className:n,children:e}){return!n&&typeof e=="string"&&!e.includes(`
|
|
88
|
+
`)?r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground",children:e}):r.jsx("pre",{className:"my-1.5 overflow-x-auto rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed",children:r.jsx("code",{children:String(e).replace(/\n$/,"")})})},img:()=>null},e6={...Xx,h1:Xs("h1"),h2:Xs("h2"),h3:Xs("h3"),h4:Xs("h4"),h5:Xs("h5"),h6:Xs("h6")},Jx=v.memo(function(e){const t=B.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?e6:Xx;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(Rn,{components:a,remarkPlugins:Us,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),Sm=400,t6=24,$d=v.memo(function(e){const t=B.c(24),{toolUseId:s}=e,o=Md(),i=Z_(s),a=v.useRef(null),[l,c]=v.useState(!0);let d,f,u;if(t[0]!==l||t[1]!==o||t[2]!==s){u=Q_(o,s).flatMap(n6).filter(s6).map(o6).join(`
|
|
89
|
+
`);const N=u.split(`
|
|
90
|
+
`);d=l&&N.length>Sm,f=d?N.slice(-Sm).join(`
|
|
91
|
+
`):u,t[0]=l,t[1]=o,t[2]=s,t[3]=d,t[4]=f,t[5]=u}else d=t[3],f=t[4],u=t[5];const m=f;let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const N=a.current;if(!N)return;const C=N.scrollHeight-N.scrollTop-N.clientHeight<t6;c(S=>S===C?S:C)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const N=a.current;if(!N||!l)return;const C=N.scrollHeight-N.clientHeight;N.scrollTop!==C&&(N.scrollTop=C)},t[7]=l,t[8]=g):g=t[8];let x;if(t[9]!==l||t[10]!==m?(x=[m,l],t[9]=l,t[10]=m,t[11]=x):x=t[11],v.useLayoutEffect(g,x),!u&&!i)return null;const b=i?"live-subagent-summary":void 0;let w;t[12]!==i?(w=i??r.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=i,t[13]=w):w=t[13];let y;t[14]!==b||t[15]!==w?(y=r.jsx("div",{"data-testid":b,className:"mb-1 text-xs font-medium text-muted-foreground",children:w}),t[14]=b,t[15]=w,t[16]=y):y=t[16];let j;t[17]!==d||t[18]!==m||t[19]!==u?(j=u&&r.jsxs("div",{ref:a,onScroll:h,"data-testid":"live-subagent-scroll",role:"region","aria-label":"Live sub-agent output",tabIndex:0,className:"text-xs break-words max-h-64 overflow-y-auto overscroll-contain pr-1",children:[d&&r.jsx("div",{className:"text-muted-foreground/50",children:"…"}),r.jsx(Jx,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=u,t[20]=j):j=t[20];let k;return t[21]!==y||t[22]!==j?(k=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[y,j]}),t[21]=y,t[22]=j,t[23]=k):k=t[23],k});function n6(n){return n.blocks}function s6(n){return n.blockType!=="tool_use"&&n.text}function o6(n){return n.text}function km(n){return n.length>8?n.slice(0,8):n}function Od(n,e,t){const s=e??t;return s?`${s} - ${km(n)}`:km(n)}function r6(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,Od(t.agentId,t.subagentType,t.agentName));return e}function i6(n){const e=new Map;for(const s of n)s.parentToolUseId&&!e.has(s.agentId)&&e.set(s.agentId,s.parentToolUseId);const t=new Map;for(const s of e.values())t.set(s,(t.get(s)??0)+1);for(const[s,o]of e)(t.get(o)??0)>1&&e.delete(s);return e}function a6(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
92
|
+
`):""}function Qx(n,e){if(X1(n))return kd(n).turns.filter(i=>i.assistantText.length>0||i.thinking.length>0||i.toolCalls.length>0).map(i=>({agentId:e,agentName:null,subagentType:null,type:"assistant",content:i.assistantText.join(`
|
|
93
|
+
|
|
94
|
+
`),toolCalls:i.toolCalls,thinking:i.thinking.map(a=>a.thinking),text:[...i.assistantText],timestamp:i.timestamp,tokenUsage:i.tokenUsage,model:i.model,isBackground:!0}));const t=[],s=new Map;for(const o of n.split(`
|
|
95
|
+
`)){const i=o.trim();if(!i)continue;let a;try{a=JSON.parse(i)}catch{continue}const l=a.type;if(l!=="user"&&l!=="assistant")continue;const c=a.message;if(!c)continue;const d=c.content,f=a.timestamp??"";if(l==="assistant"){const u={agentId:e,agentName:null,subagentType:null,type:"assistant",content:d,toolCalls:[],thinking:[],text:[],timestamp:f,tokenUsage:c.usage?{input_tokens:c.usage.input_tokens??0,output_tokens:c.usage.output_tokens??0,cache_creation_input_tokens:c.usage.cache_creation_input_tokens??0,cache_read_input_tokens:c.usage.cache_read_input_tokens??0}:null,model:c.model??null,isBackground:!0};if(Array.isArray(d)){for(const m of d)if(m.type==="thinking")u.thinking.push(m.thinking);else if(m.type==="text")u.text.push(m.text);else if(m.type==="tool_use"){const p={id:m.id,name:m.name,input:m.input,result:null,isError:!1,timestamp:f};u.toolCalls.push(p),s.set(m.id,p)}}t.push(u)}else if(l==="user"&&Array.isArray(d)){for(const u of d)if(u.type==="tool_result"){const m=s.get(u.tool_use_id);m&&(m.result=a6(u.content),m.isError=u.is_error??!1)}}}return t}const vl=new Map;function l6(n,e){const t=B.c(21),{session:s,sessionSource:o,isLive:i}=it();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=v.useState(a),[d,f]=v.useState(!1);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[1]=u):u=t[1];const m=v.useRef(u);let p;if(t[2]!==i||t[3]!==n){let _;t[5]!==i?(_=P=>P.text.length>0||P.thinking.length>0||P.toolCalls.length>0?!1:i?P.durationMs!=null:P.status==="async_launched",t[5]=i,t[6]=_):_=t[6],p=n.filter(_),t[2]=i,t[3]=n,t[4]=p}else p=t[4];const h=p,g=o==null?void 0:o.dirName,x=s==null?void 0:s.sessionId;let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=ya(window.location.pathname),t[7]=b):b=t[7];const w=b;let y,j;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(y=()=>{if(w||!e||!g||!x||h.length===0)return;const _=[];for(const T of h){const E=Ft(`${g}/${x}/${T.agentId}`);if(!m.current.has(E)){if(vl.has(E)){c(R=>{const M=new Map(R);return M.set(T.agentId,vl.get(E)),M}),m.current.add(E);continue}_.push({agentId:T.agentId,cacheKey:E})}}if(_.length===0)return;let P=!1;return f(!0),async function(){const E=new Map;await Promise.all(_.map(async R=>{const{agentId:M,cacheKey:I}=R;try{const D=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent(M)}.jsonl`,O=await ye(D);if(!O.ok)return;const $=await O.text(),L=Qx($,M);vl.set(I,L),m.current.add(I),E.set(M,L)}catch{}})),!P&&E.size>0&&c(R=>{const M=new Map(R);for(const[I,D]of E)M.set(I,D);return M}),P||f(!1)}(),()=>{P=!0}},j=[w,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=y,t[13]=j):(y=t[12],j=t[13]),v.useEffect(y,j);let k;e:{if(l.size===0&&h.length===0){k=n;break e}let _;if(t[14]!==l||t[15]!==n){_=[];for(const P of n){const A=l.get(P.agentId);if(A&&A.length>0&&(P.status==="async_launched"||P.durationMs!=null)){const T={...A[0],durationMs:P.durationMs,toolUseCount:P.toolUseCount,status:P.status,prompt:P.prompt,agentName:P.agentName,subagentType:P.subagentType};_.push(T,...A.slice(1))}else _.push(P)}t[14]=l,t[15]=n,t[16]=_}else _=t[16];k=_}const N=k,C=w&&e&&h.length>0;let S;return t[17]!==N||t[18]!==d||t[19]!==C?(S={enrichedMessages:N,isLoading:d,unavailable:C},t[17]=N,t[18]=d,t[19]=C,t[20]=S):S=t[20],S}const Zx=v.memo(function(e){const t=B.c(74),{messages:s,expandAll:o,label:i,countLabel:a,lazyLoad:l}=e,c=l===void 0?!1:l,[d,f]=v.useState(!1),u=o||d,{sessionSource:m,actions:p}=it(),h=m==null?void 0:m.dirName;let g;t[0]!==h?(g=go(h),t[0]=h,t[1]=g):g=t[1];const x=g.subagentTranscripts,{enrichedMessages:b,isLoading:w,unavailable:y}=l6(s,c&&u&&x);let j;e:{if(!(m!=null&&m.fileName)){j=null;break e}let J;t[2]!==m.fileName?(J=bs(m.fileName),t[2]=m.fileName,t[3]=J):J=t[3];const ee=J;if(ee){j=ee.parentSessionId;break e}let oe;if(t[4]!==m.fileName){let re;t[6]===Symbol.for("react.memo_cache_sentinel")?(re=/^([^/]+)\.jsonl$/,t[6]=re):re=t[6],oe=m.fileName.match(re),t[4]=m.fileName,t[5]=oe}else oe=t[5];const se=oe;j=(se==null?void 0:se[1])??null}const k=j;let N;t[7]!==b?(N=new Set(b.map(d6)),t[7]=b,t[8]=N):N=t[8];let C;t[9]!==N?(C=[...N],t[9]=N,t[10]=C):C=t[10];const S=C;let _;t[11]!==b?(_=r6(b),t[11]=b,t[12]=_):_=t[12];const P=_;let A;if(t[13]!==b||t[14]!==s){A=new Map;for(const J of[...s,...b]){const ee=A.get(J.agentId)??{};J.durationMs!=null&&(ee.durationMs=J.durationMs),J.toolUseCount!=null&&(ee.toolUseCount=J.toolUseCount),J.status&&(ee.status=J.status),A.set(J.agentId,ee)}t[13]=b,t[14]=s,t[15]=A}else A=t[15];const T=A;let E;t[16]!==b||t[17]!==s?(E=i6([...s,...b]),t[16]=b,t[17]=s,t[18]=E):E=t[18];const R=E;let M,I;if(t[19]!==b){I=new Map,M=new Map;for(const J of b)M.set(J.agentId,J),J.text.length>0&&I.set(J.agentId,J);t[19]=b,t[20]=M,t[21]=I}else M=t[20],I=t[21];let D;if(t[22]!==S||t[23]!==M||t[24]!==I){D=new Map;for(const J of S){const ee=I.get(J)??M.get(J);ee&&D.set(J,ee)}t[22]=S,t[23]=M,t[24]=I,t[25]=D}else D=t[25];const O=D;let $;e:{let J=0,ee=0,oe=!1,se=!0;for(const ie of s)ie.durationMs!=null&&(J=J+ie.durationMs,oe=!0),ie.toolUseCount!=null&&(ee=ee+ie.toolUseCount),ie.status&&ie.status!=="completed"&&(se=!1);if(!oe){$=null;break e}let re;t[26]!==se||t[27]!==J||t[28]!==ee?(re={totalDuration:J,totalToolUses:ee,allCompleted:se},t[26]=se,t[27]=J,t[28]=ee,t[29]=re):re=t[29],$=re}const L=$;if(s.length===0)return null;let F;t[30]!==d?(F=()=>f(!d),t[30]=d,t[31]=F):F=t[31];let z;t[32]!==u?(z=u?r.jsx(Ze,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Je,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=u,t[33]=z):z=t[33];let H;t[34]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx(Yn,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=H):H=t[34];let U;t[35]!==i?(U=r.jsx("span",{className:"text-xs font-medium text-foreground",children:i}),t[35]=i,t[36]=U):U=t[36];let W;t[37]!==S.length||t[38]!==a?(W=S.length>1&&r.jsxs(Ee,{variant:"secondary",children:[S.length," ",a]}),t[37]=S.length,t[38]=a,t[39]=W):W=t[39];let q;t[40]!==S||t[41]!==P?(q=S.map(J=>r.jsx(Ee,{variant:"outline",children:P.get(J)},J)),t[40]=S,t[41]=P,t[42]=q):q=t[42];let V;t[43]!==S.length||t[44]!==L?(V=L?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[L.allCompleted?r.jsx(Pn,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(Ss,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx($s,{className:"size-3","data-icon":"inline-start"}),En(L.totalDuration)]}),L.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ta,{className:"size-3","data-icon":"inline-start"}),L.totalToolUses]})]}):r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",S.length," agent",S.length!==1?"s":"",")"]}),t[43]=S.length,t[44]=L,t[45]=V):V=t[45];let Y;t[46]!==F||t[47]!==z||t[48]!==U||t[49]!==W||t[50]!==q||t[51]!==V?(Y=r.jsxs(Z,{type:"button",variant:"ghost",onClick:F,className:"h-auto w-full min-w-0 flex-wrap justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[z,H,U,W,q,V]}),t[46]=F,t[47]=z,t[48]=U,t[49]=W,t[50]=q,t[51]=V,t[52]=Y):Y=t[52];let K;t[53]!==S||t[54]!==u||t[55]!==R?(K=!u&&S.map(J=>{const ee=R.get(J);return ee?r.jsx($d,{toolUseId:ee},J):null}),t[53]=S,t[54]=u,t[55]=R,t[56]=K):K=t[56];let X;t[57]!==p||t[58]!==S||t[59]!==P||t[60]!==O||t[61]!==x||t[62]!==w||t[63]!==u||t[64]!==k||t[65]!==R||t[66]!==m||t[67]!==T||t[68]!==y?(X=u&&r.jsxs("div",{className:"motion-enter mt-2 flex flex-col gap-2",children:[y?r.jsx("div",{className:"py-1 text-xs italic text-muted-foreground",children:"Sub-agent transcripts aren't available in a shared session."}):w&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[r.jsx(rt,{className:"size-3 animate-spin"}),"Loading agent output..."]}),S.map(J=>{const ee=O.get(J),oe=T.get(J),se=x&&!!m&&!!k&&!y;return r.jsx(c6,{agentLabel:P.get(J)??J,message:ee,stats:oe,parentToolUseId:R.get(J),canNavigate:se,onOpen:()=>{se&&p.handleLoadSession(m.dirName,`${k}/subagents/agent-${J}.jsonl`)}},J)})]}),t[57]=p,t[58]=S,t[59]=P,t[60]=O,t[61]=x,t[62]=w,t[63]=u,t[64]=k,t[65]=R,t[66]=m,t[67]=T,t[68]=y,t[69]=X):X=t[69];let Q;return t[70]!==Y||t[71]!==K||t[72]!==X?(Q=r.jsxs("div",{children:[Y,K,X]}),t[70]=Y,t[71]=K,t[72]=X,t[73]=Q):Q=t[73],Q});function c6(n){const e=B.c(22),{agentLabel:t,message:s,stats:o,parentToolUseId:i,canNavigate:a,onOpen:l}=n,c=s==null?void 0:s.text;let d;e[0]!==c?(d=hx((c??[]).join(`
|
|
96
|
+
|
|
97
|
+
`)),e[0]=c,e[1]=d):d=e[1];const f=d,u=((c==null?void 0:c.length)??0)>0,m=(o==null?void 0:o.status)!=null&&o.status!=="completed"&&o.status!=="async_launched",p=(o==null?void 0:o.status)==="completed";let h;e[2]!==t?(h=r.jsx(Ee,{variant:"outline",children:t}),e[2]=t,e[3]=h):h=e[3];let g;e[4]!==p||e[5]!==o?(g=o&&r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[p&&r.jsx(Pn,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx($s,{className:"size-3"}),En(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ta,{className:"size-3"}),o.toolUseCount]})]}),e[4]=p,e[5]=o,e[6]=g):g=e[6];let x;e[7]!==a||e[8]!==l?(x=a&&r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[r.jsx(_h,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=a,e[8]=l,e[9]=x):x=e[9];let b;e[10]!==h||e[11]!==g||e[12]!==x?(b=r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h,g,x]}),e[10]=h,e[11]=g,e[12]=x,e[13]=b):b=e[13];let w;e[14]!==u||e[15]!==m||e[16]!==f||e[17]!==i?(w=u?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(Rn,{components:Fn,remarkPlugins:Us,children:f})}):r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"inline-flex items-center gap-1.5 text-xs italic text-muted-foreground",children:m?r.jsxs(r.Fragment,{children:[r.jsx(rt,{className:"size-3 animate-spin"}),"Working — no return yet"]}):r.jsx(r.Fragment,{children:"No return message from this agent"})}),i&&r.jsx($d,{toolUseId:i})]}),e[14]=u,e[15]=m,e[16]=f,e[17]=i,e[18]=w):w=e[18];let y;return e[19]!==b||e[20]!==w?(y=r.jsx("div",{className:"border-l pl-3",children:r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[b,w]})}),e[19]=b,e[20]=w,e[21]=y):y=e[21],y}function d6(n){return n.agentId}const u6=v.memo(function(e){const t=B.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(Zx,{messages:s,expandAll:o,label:"Sub-agent activity",countLabel:"subagents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),f6=v.memo(function(e){const t=B.c(3),{messages:s,expandAll:o}=e;let i;return t[0]!==o||t[1]!==s?(i=r.jsx(Zx,{messages:s,expandAll:o,label:"Background agent activity",countLabel:"agents active",lazyLoad:!0}),t[0]=o,t[1]=s,t[2]=i):i=t[2],i}),m6=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),p6=v.memo(function(e){const t=B.c(30),{events:s}=e,[o,i]=v.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(h6),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?Ze:Je,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let f;t[2]!==d?(f=G("my-1 rounded-md border px-2 py-1 text-xs",d),t[2]=d,t[3]=f):f=t[3];let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-auto w-full justify-start px-0 py-0 text-left font-normal text-muted-foreground"}),t[4]=u):u=t[4];let m;t[5]!==c?(m=r.jsx(c,{className:"size-3 shrink-0","data-icon":"inline-start"}),t[5]=c,t[6]=m):m=t[6];let p;t[7]!==l?(p=l?r.jsx(en,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(cy,{className:"size-3","data-icon":"inline-start"}),t[7]=l,t[8]=p):p=t[8];const h=s.length===1?"":"s";let g;t[9]!==s.length||t[10]!==h?(g=r.jsxs("span",{className:"font-mono",children:[s.length," hook event",h]}),t[9]=s.length,t[10]=h,t[11]=g):g=t[11];let x;t[12]!==s?(x=s.map(g6).join(", "),t[12]=s,t[13]=x):x=t[13];let b;t[14]!==x?(b=r.jsx("span",{className:"truncate text-muted-foreground/60",children:x}),t[14]=x,t[15]=b):b=t[15];let w;t[16]!==b||t[17]!==m||t[18]!==p||t[19]!==g?(w=r.jsxs(Jt,{render:u,children:[m,p,g,b]}),t[16]=b,t[17]=m,t[18]=p,t[19]=g,t[20]=w):w=t[20];let y;t[21]!==s?(y=s.map(x6),t[21]=s,t[22]=y):y=t[22];let j;t[23]!==y?(j=r.jsx(wt,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:y})}),t[23]=y,t[24]=j):j=t[24];let k;return t[25]!==o||t[26]!==w||t[27]!==j||t[28]!==f?(k=r.jsxs(yt,{open:o,onOpenChange:i,className:f,children:[w,j]}),t[25]=o,t[26]=w,t[27]=j,t[28]=f,t[29]=k):k=t[29],k});function h6(n){return m6.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function g6(n){return n.eventName}function x6(n,e){return r.jsxs("li",{className:"text-muted-foreground/80",children:[r.jsx("span",{className:"text-foreground",children:n.eventName}),n.toolName&&r.jsxs("span",{children:[" · ",n.toolName]}),n.source&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" (",n.source,")"]}),n.decision&&r.jsxs("span",{className:"text-warning",children:[" → ",n.decision]}),n.durationMs!==void 0&&r.jsxs("span",{className:"text-muted-foreground/50",children:[" ",n.durationMs,"ms"]}),n.exitCode!==void 0&&n.exitCode!==0&&r.jsxs("span",{className:"text-destructive",children:[" exit ",n.exitCode]}),n.stderr&&r.jsx("pre",{className:"ml-2 mt-0.5 whitespace-pre-wrap text-destructive",children:n.stderr.slice(0,500)}),n.updatedToolOutput&&r.jsx("span",{className:"text-info",children:" · output replaced by hook"}),n.sessionTitle&&r.jsxs("span",{className:"text-foreground",children:[" · title: ",n.sessionTitle]}),n.worktreePath&&r.jsxs("span",{className:"text-success",children:[" · path: ",n.worktreePath]})]},e)}const Nm=768;function Ma(){const n=B.c(2),[e,t]=v.useState(typeof window<"u"?window.innerWidth<Nm:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${Nm-1}px)`),a=l=>t(l.matches);return i.addEventListener("change",a),t(i.matches),()=>i.removeEventListener("change",a)},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),v.useEffect(s,o),e}const b6=24,Oo=[];function v6(n,e){for(let s=0;s<Oo.length;s++){const o=Oo[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=w6(n,e);return Oo.length>=b6&&Oo.shift(),Oo.push({oldStr:n,newStr:e,result:t}),t}const y6=25e4;function w6(n,e){const t=n.split(`
|
|
98
|
+
`),s=e.split(`
|
|
99
|
+
`),o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l,f=[];for(let u=0;u<a;u++)f.push({type:"unchanged",text:t[u],oldIdx:u,newIdx:u});if(!(c===0&&d===0))if(c===0)for(let u=0;u<d;u++)f.push({type:"added",text:s[a+u],newIdx:a+u});else if(d===0)for(let u=0;u<c;u++)f.push({type:"removed",text:t[a+u],oldIdx:a+u});else if(c*d>y6){for(let u=0;u<c;u++)f.push({type:"removed",text:t[a+u],oldIdx:a+u});for(let u=0;u<d;u++)f.push({type:"added",text:s[a+u],newIdx:a+u})}else{const u=d+1,m=new Int32Array((c+1)*u);for(let x=1;x<=c;x++){const b=t[a+x-1],w=x*u,y=w-u;for(let j=1;j<=d;j++)if(b===s[a+j-1])m[w+j]=m[y+j-1]+1;else{const k=m[y+j],N=m[w+j-1];m[w+j]=k>N?k:N}}const p=[];let h=c,g=d;for(;h>0||g>0;)h>0&&g>0&&t[a+h-1]===s[a+g-1]?(p.push({type:"unchanged",text:t[a+h-1],oldIdx:a+h-1,newIdx:a+g-1}),h--,g--):g>0&&(h===0||m[h*u+g-1]>=m[(h-1)*u+g])?(p.push({type:"added",text:s[a+g-1],newIdx:a+g-1}),g--):(p.push({type:"removed",text:t[a+h-1],oldIdx:a+h-1}),h--);p.reverse(),f.push(...p)}for(let u=0;u<l;u++){const m=o-l+u,p=i-l+u;f.push({type:"unchanged",text:t[m],oldIdx:m,newIdx:p})}return f}function j6(n,e,t,s){const o=B.c(9),[i,a]=v.useState(null),[l,c]=v.useState(null);let d,f;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=a1(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||r1().then(async x=>{if(h||(await i1(x,m),h))return;const b=x.codeToTokens(n,{lang:m,theme:p});if(h)return;a(b.tokens);const w=x.codeToTokens(e,{lang:m,theme:p});h||c(w.tokens)}).catch(x=>{console.warn("[EditDiffView] highlight failed:",x),h||(a(null),c(null))})});return()=>{h=!0,cancelAnimationFrame(g)}},f=[n,e,t,s],o[0]=t,o[1]=s,o[2]=e,o[3]=n,o[4]=d,o[5]=f):(d=o[4],f=o[5]),v.useEffect(d,f);let u;return o[6]!==l||o[7]!==i?(u={oldTokens:i,newTokens:l},o[6]=l,o[7]=i,o[8]=u):u=o[8],u}const S6={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},Cm={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},k6={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function N6(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:G(e&&"opacity-50"),children:t.content},s))}function C6(n,e,t){switch(n.type){case"removed":return e==null?void 0:e[n.oldIdx??-1];case"added":return t==null?void 0:t[n.newIdx??-1];case"unchanged":return(t==null?void 0:t[n.newIdx??-1])??(e==null?void 0:e[n.oldIdx??-1])}}function _6(n){const e=B.c(3),{type:t}=n;switch(t){case"removed":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ch,{className:"inline size-3","data-icon":"icon"}),e[0]=s):s=e[0],s}case"added":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Tn,{className:"inline size-3","data-icon":"icon"}),e[1]=s):s=e[1],s}default:{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("span",{className:"inline-block size-3","aria-hidden":"true"}),e[2]=s):s=e[2],s}}}const yl=3;function T6(n){if(n.length===0)return[];const e=new Set;for(let i=0;i<n.length;i++)n[i].type!=="unchanged"&&e.add(i);if(e.size===0||n.length<=yl*2+3)return n.map((i,a)=>({kind:"line",line:i,originalIdx:a}));const t=new Set;for(const i of e)for(let a=Math.max(0,i-yl);a<=Math.min(n.length-1,i+yl);a++)t.add(a);const s=[];let o=0;for(;o<n.length;)if(t.has(o))s.push({kind:"line",line:n[o],originalIdx:o}),o++;else{const i=o;let a=0;for(;o<n.length&&!t.has(o);)a++,o++;s.push({kind:"separator",count:a,fromIdx:i,toIdx:o-1})}return s}function E6(n){const e=B.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(ra,{className:"shrink-0","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=r.jsxs("span",{className:"font-mono",children:[t," unchanged lines"]}),e[1]=t,e[2]=i):i=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"flex-1 border-b border-border"}),e[3]=a):a=e[3];let l;return e[4]!==s||e[5]!==i?(l=r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"h-auto w-full justify-start rounded-none px-2 py-1 text-xs text-muted-foreground",children:[o,i,a]}),e[4]=s,e[5]=i,e[6]=l):l=e[6],l}const _m=v.memo(function(e){const t=B.c(33),{line:s,lineNum:o,oldTokens:i,newTokens:a}=e;let l,c,d,f,u,m;if(t[0]!==s||t[1]!==o||t[2]!==a||t[3]!==i){m=C6(s,i,a);const x=S6[s.type];t[10]!==x?(d=G("flex",x),t[10]=x,t[11]=d):d=t[11];const b=Cm[s.type];let w;t[12]!==b?(w=G("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",b),t[12]=b,t[13]=w):w=t[13],t[14]!==o||t[15]!==w?(f=r.jsx("span",{className:w,children:o}),t[14]=o,t[15]=w,t[16]=f):f=t[16];const y=Cm[s.type];let j;t[17]!==y?(j=G("select-none shrink-0 w-5 text-right pr-1 border-r",y),t[17]=y,t[18]=j):j=t[18];let k;t[19]!==s.type?(k=r.jsx(_6,{type:s.type}),t[19]=s.type,t[20]=k):k=t[20],t[21]!==j||t[22]!==k?(u=r.jsx("span",{className:j,children:k}),t[21]=j,t[22]=k,t[23]=u):u=t[23],l="pl-2 whitespace-pre",c=m?N6(m,s.type==="unchanged"):r.jsx("span",{className:k6[s.type],children:s.text||" "}),t[0]=s,t[1]=o,t[2]=a,t[3]=i,t[4]=l,t[5]=c,t[6]=d,t[7]=f,t[8]=u,t[9]=m}else l=t[4],c=t[5],d=t[6],f=t[7],u=t[8],m=t[9];const p=m&&m.length===0&&" ";let h;t[24]!==l||t[25]!==c||t[26]!==p?(h=r.jsxs("span",{className:l,children:[c,p]}),t[24]=l,t[25]=c,t[26]=p,t[27]=h):h=t[27];let g;return t[28]!==d||t[29]!==f||t[30]!==u||t[31]!==h?(g=r.jsxs("div",{className:d,children:[f,u,h]}),t[28]=d,t[29]=f,t[30]=u,t[31]=h,t[32]=g):g=t[32],g}),Tm=120,Em=60,P6=120;function Pm(n){const e=B.c(34),{lines:t,oldTokens:s,newTokens:o,compact:i,startLine:a}=n,l=a===void 0?1:a;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const[d,f]=v.useState(c);let u;e[1]!==t?(u=T6(t),e[1]=t,e[2]=u):u=e[2];const m=u,p=m.length>Tm,[h,g]=v.useState(p?Em:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>Tm?Em:m.length)},e[3]=m.length,e[4]=x):x=e[4];let b;e[5]!==m?(b=[m],e[5]=m,e[6]=b):b=e[6],v.useEffect(x,b);let w,y;e[7]!==m.length||e[8]!==h?(w=()=>{if(h>=m.length)return;const T=requestAnimationFrame(()=>{g(E=>Math.min(E+P6,m.length))});return()=>cancelAnimationFrame(T)},y=[h,m.length],e[7]=m.length,e[8]=h,e[9]=w,e[10]=y):(w=e[9],y=e[10]),v.useEffect(w,y);let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=T=>{f(E=>new Set(E).add(T))},e[11]=j):j=e[11];const k=j;let N;e[12]!==m||e[13]!==p||e[14]!==h?(N=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=N):N=e[15];const C=N,S=i&&"max-h-64 overflow-y-auto";let _;e[16]!==S?(_=G("overflow-x-auto font-mono text-xs leading-relaxed",S),e[16]=S,e[17]=_):_=e[17];let P;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let T;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(T=(E,R)=>{if(E.kind==="separator")return d.has(E.fromIdx)?t.slice(E.fromIdx,E.toIdx+1).map((D,O)=>{const $=E.fromIdx+O;return r.jsx(_m,{line:D,lineNum:D.type==="removed"?(D.oldIdx??0)+l:(D.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${$}`)}):r.jsx(E6,{count:E.count,onExpand:()=>k(E.fromIdx)},`sep-${R}`);const{line:M}=E,I=M.type==="removed"?(M.oldIdx??0)+l:(M.newIdx??0)+l;return r.jsx(_m,{line:M,lineNum:I,oldTokens:s,newTokens:o},R)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=T):T=e[30],P=C.map(T),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=P}else P=e[24];let A;return e[31]!==_||e[32]!==P?(A=r.jsx("div",{className:_,children:P}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}function Am(n){const e=B.c(11),{lines:t}=n;let s=0,o=0;for(const m of t)m.type==="added"?s++:m.type==="removed"&&o++;let i;e[0]!==s||e[1]!==o?(i={added:s,removed:o},e[0]=s,e[1]=o,e[2]=i):i=e[2];const{added:a,removed:l}=i;let c;e[3]!==l?(c=l>0&&r.jsxs("span",{className:"text-destructive",children:["-",l]}),e[3]=l,e[4]=c):c=e[4];const d=l>0&&a>0&&" ";let f;e[5]!==a?(f=a>0&&r.jsxs("span",{className:"text-success",children:["+",a]}),e[5]=a,e[6]=f):f=e[6];let u;return e[7]!==c||e[8]!==d||e[9]!==f?(u=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[c,d,f]}),e[7]=c,e[8]=d,e[9]=f,e[10]=u):u=e[10],u}function Dd(n){const e=B.c(34),{oldString:t,newString:s,filePath:o,compact:i,startLine:a,hideHeader:l}=n,c=i===void 0?!0:i,d=a===void 0?1:a,f=l===void 0?!1:l,[u,m]=v.useState(!1),p=Ir();let h;e[0]!==s||e[1]!==t?(h=v6(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:b}=j6(t,s,o,p);let w;e[3]!==o?(w=o.split("/").slice(-3).join("/"),e[3]=o,e[4]=w):w=e[4];const y=w,j=c&&"mt-1.5",k=f&&"border-0 rounded-none";let N;e[5]!==j||e[6]!==k?(N=G("overflow-hidden rounded border border-border bg-muted/20",j,k),e[5]=j,e[6]=k,e[7]=N):N=e[7];let C;e[8]!==f||e[9]!==c||e[10]!==g||e[11]!==y?(C=!f&&r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-2 py-1",children:[r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:y}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Am,{lines:g}),c&&r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:r.jsx(sa,{"data-icon":"icon"})})]})]}),e[8]=f,e[9]=c,e[10]=g,e[11]=y,e[12]=C):C=e[12];let S;e[13]!==c||e[14]!==g||e[15]!==b||e[16]!==x||e[17]!==d?(S=r.jsx(Pm,{lines:g,oldTokens:x,newTokens:b,compact:c,startLine:d}),e[13]=c,e[14]=g,e[15]=b,e[16]=x,e[17]=d,e[18]=S):S=e[18];let _;e[19]!==S||e[20]!==N||e[21]!==C?(_=r.jsxs("div",{className:N,children:[C,S]}),e[19]=S,e[20]=N,e[21]=C,e[22]=_):_=e[22];let P;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==u||e[27]!==b||e[28]!==x||e[29]!==d?(P=c&&r.jsx(Jn,{open:u,onOpenChange:m,children:r.jsxs(Qn,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(Ns,{children:[r.jsxs(Zn,{className:"font-mono text-sm text-foreground flex items-center gap-3",children:[o,r.jsx(Am,{lines:g})]}),r.jsx(es,{className:"sr-only",children:"Diff view for edit operation"})]}),r.jsx("div",{className:"flex-1 overflow-auto rounded border border-border bg-background",children:r.jsx(Pm,{lines:g,oldTokens:x,newTokens:b,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=u,e[27]=b,e[28]=x,e[29]=d,e[30]=P):P=e[30];let A;return e[31]!==_||e[32]!==P?(A=r.jsxs(r.Fragment,{children:[_,P]}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}const A6=new Set(["command","cmd","description","timeout","run_in_background"]);function e0(n){return typeof n!="number"||!Number.isFinite(n)?String(n):n<1e3?`${n} ms`:n%6e4===0?`${n/6e4} min`:n%1e3===0?`${n/1e3} sec`:`${(n/1e3).toFixed(1)} sec`}function t0(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function R6(n){if(typeof n=="string")return n;if(n===null)return"null";if(n===void 0)return"undefined";try{return JSON.stringify(n)}catch{return String(n)}}function I6(n,e){const t=B.c(5),s=Ir(),[o,i]=v.useState(null);let a,l;return t[0]!==n||t[1]!==s||t[2]!==e?(a=()=>{let c=!1;return ud(n,e,s).then(d=>{!c&&d&&d.length>0&&i(d)}),()=>{c=!0}},l=[n,s,e],t[0]=n,t[1]=s,t[2]=e,t[3]=a,t[4]=l):(a=t[3],l=t[4]),v.useEffect(a,l),o}function n0(n){const e=B.c(74),{title:t,code:s,language:o,codeLabel:i,copyLabel:a,icon:l,prompt:c,description:d,metadata:f}=n;let u;e[0]!==f?(u=f===void 0?[]:f,e[0]=f,e[1]=u):u=e[1];const m=u,[p,h]=yo(),g=I6(s,o);let x,b,w,y,j,k,N,C,S,_,P;if(e[2]!==l||e[3]!==s||e[4]!==i||e[5]!==p||e[6]!==h||e[7]!==a||e[8]!==d||e[9]!==c||e[10]!==t||e[11]!==g){const D=s.split(`
|
|
100
|
+
`);b=Dt,P="sm",w="mt-1.5";let O;e[23]!==l?(O=r.jsx(l,{className:"size-4","aria-hidden":"true"}),e[23]=l,e[24]=O):O=e[24];let $;e[25]!==O||e[26]!==t?($=r.jsxs(Vt,{className:"flex items-center gap-2",children:[O,t]}),e[25]=O,e[26]=t,e[27]=$):$=e[27];let L;e[28]!==d?(L=d&&r.jsx(Gt,{children:d}),e[28]=d,e[29]=L):L=e[29];let F;e[30]!==s||e[31]!==h?(F=()=>h(s),e[30]=s,e[31]=h,e[32]=F):F=e[32];const z=p?`${t} copied`:a,H=p?"Copied":a;let U;e[33]!==p?(U=p?r.jsx(ft,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(An,{"data-icon":"inline-start","aria-hidden":"true"}),e[33]=p,e[34]=U):U=e[34];let W;e[35]!==F||e[36]!==z||e[37]!==H||e[38]!==U?(W=r.jsx(ad,{children:r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,"aria-label":z,title:H,children:U})}),e[35]=F,e[36]=z,e[37]=H,e[38]=U,e[39]=W):W=e[39],e[40]!==$||e[41]!==L||e[42]!==W?(y=r.jsxs(Bt,{children:[$,L,W]}),e[40]=$,e[41]=L,e[42]=W,e[43]=y):y=e[43],x=Lt,S="flex items-start gap-2 overflow-x-auto rounded-md bg-muted/50 p-3",e[44]!==c?(_=c&&r.jsx("span",{className:"select-none font-mono text-xs text-muted-foreground","aria-hidden":"true",children:c}),e[44]=c,e[45]=_):_=e[45],C="m-0 min-w-0 flex-1 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed [overflow-wrap:anywhere]",j=i;const q=!g&&"text-foreground";e[46]!==q?(k=G("block",q),e[46]=q,e[47]=k):k=e[47];let V;e[48]!==g?(V=(Y,K)=>{const X=g==null?void 0:g[K];return r.jsx("span",{className:"block min-h-lh",children:X?X.map($6):Y||" "},K)},e[48]=g,e[49]=V):V=e[49],N=D.map(V),e[2]=l,e[3]=s,e[4]=i,e[5]=p,e[6]=h,e[7]=a,e[8]=d,e[9]=c,e[10]=t,e[11]=g,e[12]=x,e[13]=b,e[14]=w,e[15]=y,e[16]=j,e[17]=k,e[18]=N,e[19]=C,e[20]=S,e[21]=_,e[22]=P}else x=e[12],b=e[13],w=e[14],y=e[15],j=e[16],k=e[17],N=e[18],C=e[19],S=e[20],_=e[21],P=e[22];let A;e[50]!==j||e[51]!==k||e[52]!==N?(A=r.jsx("code",{"aria-label":j,className:k,children:N}),e[50]=j,e[51]=k,e[52]=N,e[53]=A):A=e[53];let T;e[54]!==A||e[55]!==C?(T=r.jsx("pre",{className:C,children:A}),e[54]=A,e[55]=C,e[56]=T):T=e[56];let E;e[57]!==T||e[58]!==S||e[59]!==_?(E=r.jsxs("div",{className:S,children:[_,T]}),e[57]=T,e[58]=S,e[59]=_,e[60]=E):E=e[60];let R;e[61]!==x||e[62]!==E?(R=r.jsx(x,{children:E}),e[61]=x,e[62]=E,e[63]=R):R=e[63];let M;e[64]!==m||e[65]!==t?(M=m.length>0&&r.jsx(Eo,{className:"items-stretch",children:r.jsx("dl",{className:"grid w-full gap-1.5","aria-label":`${t} options`,children:m.map(M6)})}),e[64]=m,e[65]=t,e[66]=M):M=e[66];let I;return e[67]!==b||e[68]!==w||e[69]!==y||e[70]!==R||e[71]!==M||e[72]!==P?(I=r.jsxs(b,{size:P,className:w,children:[y,R,M]}),e[67]=b,e[68]=w,e[69]=y,e[70]=R,e[71]=M,e[72]=P,e[73]=I):I=e[73],I}function M6(n){const e=n.icon;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-start gap-2 text-xs",children:[r.jsxs("dt",{className:"flex items-center gap-1 text-muted-foreground",children:[e&&r.jsx(e,{className:"size-3","aria-hidden":"true"}),n.label]}),r.jsx("dd",{className:"min-w-0 break-all font-mono text-card-foreground",children:n.value})]},n.key)}function $6(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}function O6(n){const e=[];n.timeout!==void 0&&e.push({key:"timeout",label:"Timeout",value:e0(n.timeout),icon:yr}),typeof n.run_in_background=="boolean"&&e.push({key:"run_in_background",label:"Execution",value:n.run_in_background?"Background":"Foreground",icon:ko});for(const[t,s]of Object.entries(n))A6.has(t)||s===void 0||e.push({key:t,label:t0(t),value:R6(s)});return e}function Rm(n){const e=B.c(6),{input:t}=n,s=String(t.command??t.cmd??""),o=typeof t.description=="string"?t.description:"";let i;e[0]!==t?(i=O6(t),e[0]=t,e[1]=i):i=e[1];const a=i;let l;return e[2]!==s||e[3]!==o||e[4]!==a?(l=r.jsx(n0,{title:"Command",code:s,language:"bash",codeLabel:"Bash command",copyLabel:"Copy command",icon:po,prompt:"$",description:o,metadata:a}),e[2]=s,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function Im(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*([\\d_]+)`));if(!t)return null;const s=Number(t[1].replace(/_/g,""));return Number.isFinite(s)?s:null}function D6(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*["']([^"']+)["']`));return(t==null?void 0:t[1])??null}function Mm(n){const e=B.c(5),{input:t}=n,s=String(t.raw??"");let o;e[0]!==s?(o=L6(s),e[0]=s,e[1]=o):o=e[1];const i=o;let a;return e[2]!==i||e[3]!==s?(a=r.jsx(n0,{title:"Tool script",code:s,language:"typescript",codeLabel:"Codex exec script",copyLabel:"Copy script",icon:br,metadata:i}),e[2]=i,e[3]=s,e[4]=a):a=e[4],a}function L6(n){const e=[],t=new Set(Array.from(n.matchAll(/\btools\.([A-Za-z_$][\w$]*)\s*\(/g),a=>a[1]));for(const a of t)e.push({key:`tool-${a}`,label:"Tool",value:t0(a)});const s=D6(n,"workdir");s&&e.push({key:"workdir",label:"Working directory",value:s});const o=Im(n,"yield_time_ms");o!==null&&e.push({key:"yield-time",label:"Yield",value:e0(o),icon:yr});const i=Im(n,"max_output_tokens");return i!==null&&e.push({key:"output-limit",label:"Output limit",value:`${i.toLocaleString()} tokens`}),e}const z6="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",F6="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function s0(n,e,t){const s=B.c(5),[o,i]=v.useState(null);let a,l;return s[0]!==n||s[1]!==t||s[2]!==e?(a=()=>{if(!e){i(null);return}let c=!1;return ud(n,e,t).then(d=>{c||i(d)}),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=a,s[4]=l):(a=s[3],l=s[4]),v.useEffect(a,l),o}function o0(n){const e=B.c(12),{lines:t,tokens:s,lineNums:o,variant:i}=n,a=i==="boxed"?z6:F6;let l;if(e[0]!==o||e[1]!==t||e[2]!==s){let f;e[4]!==o||e[5]!==s?(f=(u,m)=>{const p=s==null?void 0:s[m];return r.jsxs("span",{className:"block",children:[(o==null?void 0:o[m])&&r.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground/30 select-none",children:o[m]}),p?p.map(B6):u||" "]},m)},e[4]=o,e[5]=s,e[6]=f):f=e[6],l=t.map(f),e[0]=o,e[1]=t,e[2]=s,e[3]=l}else l=e[3];let c;e[7]!==l?(c=r.jsx("code",{className:"block",children:l}),e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==a||e[10]!==c?(d=r.jsx("pre",{className:a,children:c}),e[9]=a,e[10]=c,e[11]=d):d=e[11],d}function B6(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const U6=/^(\s*\d+)→(.*)$/;function r0(n){return n.split(/\r\n|\r|\n/)}function W6(n){const e=[],t=[];for(const s of r0(n)){const o=s.match(U6);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function i0(n){const e=B.c(14),{result:t,filePath:s,expanded:o,variant:i}=n,a=i===void 0?"boxed":i,l=Ir();let c;e[0]!==s?(c=a1(s),e[0]=s,e[1]=c):c=e[1];const d=c;let f;e[2]!==o||e[3]!==t?(f=o?t:t.slice(0,500),e[2]=o,e[3]=t,e[4]=f):f=e[4];const u=f;let m;e[5]!==u?(m=W6(u),e[5]=u,e[6]=m):m=e[6];const{lineNums:p,codeLines:h}=m;let g;e[7]!==h?(g=h.join(`
|
|
101
|
+
`),e[7]=h,e[8]=g):g=e[8];const b=s0(g,d,l);let w;return e[9]!==h||e[10]!==p||e[11]!==b||e[12]!==a?(w=r.jsx(o0,{lines:h,tokens:b,lineNums:p,variant:a}),e[9]=h,e[10]=p,e[11]=b,e[12]=a,e[13]=w):w=e[13],w}function a0(n){const e=n.trim();if(e[0]!=="{"&&e[0]!=="[")return null;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return null}}function gc(n){const e=B.c(12),{result:t,expanded:s,alreadyPretty:o,variant:i}=n,a=i===void 0?"boxed":i,l=Ir();let c;e[0]!==o||e[1]!==t?(c=o?t:a0(t)??t,e[0]=o,e[1]=t,e[2]=c):c=e[2];const d=c;let f;e[3]!==s||e[4]!==d?(f=s?d:d.slice(0,2e3),e[3]=s,e[4]=d,e[5]=f):f=e[5];const u=f;let m;e[6]!==u?(m=r0(u),e[6]=u,e[7]=m):m=e[7];const p=m,h=s0(u,"json",l);let g;return e[8]!==p||e[9]!==h||e[10]!==a?(g=r.jsx(o0,{lines:p,tokens:h,variant:a}),e[8]=p,e[9]=h,e[10]=a,e[11]=g):g=e[11],g}const H6=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function $m(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function K6(n,e){const t=[],s=[];let o=0;for(const l of n.matchAll(H6)){const c=$m(n.slice(o,l.index));c&&t.push({label:s.at(-1)??"",command:c,chunk:s.length}),s.push(l[2]),o=l.index+l[0].length}if(s.length===0)return null;const i=$m(n.slice(o));if(i&&t.push({label:s.at(-1)??"",command:i,chunk:s.length}),t.length<2)return null;const a=e===null?null:q6(e,s);return a!==null&&a.length<2?null:t.map(({chunk:l,...c})=>({...c,output:a!==null&&l<a.length?a[l]:null}))}function q6(n,e){const t=[[]];let s=0;for(const o of n.split(/\r\n|\r|\n/))s<e.length&&o===`---${e[s]}`?(t.push([]),s++):t[t.length-1].push(o);return t.map(o=>o.join(`
|
|
102
|
+
`).trim())}const V6=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),G6=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,Y6=/\|\||&&|[|;\n]/,X6=new Set(["echo","printf","true","false",":"]),J6=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),Q6=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),Z6=new Set(["ls","tree","du"]),eT=new Set(["xargs","sudo","env","time","nohup","command"]);function tT(n){const e=n.split(/\s+/);for(;e.length>1&&(eT.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return V6.has(t)||t==="sed"&&s.some(o=>/^-[a-zA-Z]*i/.test(o))||/^python3?$/.test(t)&&s[0]==="-"||t==="git"&&/^(add|commit|checkout|reset|push|stash|rebase|merge|rm|mv)$/.test(s[0]??"")?!0:G6.test(n)}const l0=/<<-?\s*['"]?\w+['"]?/,nT=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function sT(n){return n.split(l0)[0].replace(nT,'""').split(Y6).map(e=>e.trim()).filter(Boolean)}function oT(n){const e=sT(n);if(e.some(tT))return"write";let t=!1,s=!1,o=!1;for(const i of e){const a=i.split(/\s+/)[0];if(!(!a||X6.has(a)))if(J6.has(a))t=!0;else if(Q6.has(a))s=!0;else if(Z6.has(a))o=!0;else return"run"}return o?"list":t?"search":s?"read":"run"}const rT=/^["']?((?:~|\.{1,2})?\/?[\w.@+-]+(?:\/[\w.@+*{}-]+)+\/?|[\w@+-]+\.(?:[cm]?[jt]sx?|json|md|mdx|py|rb|go|rs|sh|zsh|ya?ml|toml|css|scss|html|txt|sql|swift|kt|java|plist|lock))["']?[,:;]?$/;function c0(n){const e=new Set;for(const t of n.split(l0)[0].split(/\s+/)){const s=t.match(rT);if(!s)continue;const o=s[1];o.includes("*")||o.includes("{")||o.startsWith("-")||e.add(o)}return[...e]}const iT=/^(?:cat|head(?:\s+-n?\s*\d+)?|tail(?:\s+-n?\s*\d+)?|sed\s+-n\s+(\d+),(\d+)p)\s+(["']?)(\S+)\3(?:\s*\|\s*(?:head|tail)(?:\s+-n?\s*\d+)?)?$/;function aT(n){const e=n.trim().match(iT);if(!e)return null;const[,t,s,,o]=e;return c0(o).length?t?{path:o,from:Number(t),to:Number(s)}:{path:o}:null}const lT=/(?:No such file or directory|command not found|no matches found|Permission denied|is not recognized as an internal|Traceback \(most recent call last\)|^fatal: |^npm ERR!|^error: |^ERROR: |exited with code [1-9]\d*|^FAIL\b)/m;function cT(n,e){return!e||n==="read"&&e.split(`
|
|
103
|
+
`).length>3?!1:lT.test(e)}function d0(n){const e=oT(n.command);return{kind:e,paths:c0(n.command),readFile:e==="read"?aT(n.command):null,failed:cT(e,n.output)}}function Li(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}function dT({kind:n,failed:e}){return e?"failed":n==="write"?"write":"muted"}function uT(n){return n.map(e=>({name:Li(e),tone:dT(d0(e))}))}const u0={muted:"text-muted-foreground",write:"border-foreground/40 text-foreground",failed:"border-destructive/40 text-destructive"},zi={read:{icon:bi,label:"read",plural:"reads"},search:{icon:ln,label:"search",plural:"searches"},list:{icon:ho,label:"list",plural:"lists"},run:{icon:ko,label:"run",plural:"runs"},write:{icon:Vl,label:"write",plural:"writes"}},fT=["read","search","list","run","write"];function Ld(n){return n?n.split(`
|
|
104
|
+
`).length:0}function f0(n){if(n===null)return"not reached";if(n==="")return"no output";const e=Ld(n);return e===1?"1 line":`${e} lines`}const Om=["bg-sky-500/70","bg-violet-500/70","bg-emerald-500/70","bg-amber-500/70","bg-rose-500/70","bg-teal-500/70"];function m0(n){return Om[n%Om.length]}function mT(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function p0(n){const e=B.c(12),{path:t,line:s,cwd:o,children:i}=n;let a;e[0]!==o||e[1]!==t?(a=mT(t,o),e[0]=o,e[1]=t,e[2]=a):a=e[2];const l=a;if(!l||!lt("hostFiles")){let u;return e[3]!==i?(u=r.jsx(r.Fragment,{children:i}),e[3]=i,e[4]=u):u=e[4],u}const c=`Open ${l}${s?`:${s}`:""}`;let d;e[5]!==s||e[6]!==l?(d=u=>{u.stopPropagation(),ir(l,s?{line:s}:{})},e[5]=s,e[6]=l,e[7]=d):d=e[7];let f;return e[8]!==i||e[9]!==c||e[10]!==d?(f=r.jsx("button",{type:"button",className:"rounded-sm underline decoration-dotted decoration-muted-foreground/60 underline-offset-2 hover:bg-muted hover:text-primary hover:decoration-solid",title:c,onClick:d,children:i}),e[8]=i,e[9]=c,e[10]=d,e[11]=f):f=e[11],f}function pT(n){const e=B.c(13),{command:t,paths:s,cwd:o}=n;if(s.length===0){let d;return e[0]!==t?(d=r.jsx(r.Fragment,{children:t}),e[0]=t,e[1]=d):d=e[1],d}let i;e[2]!==s?(i=new Set(s),e[2]=s,e[3]=i):i=e[3];const a=i;let l;if(e[4]!==t||e[5]!==o||e[6]!==a){let d;e[8]!==o||e[9]!==a?(d=(f,u)=>{const m=f.replace(/^["']|["']?[,:;]?$/g,"");return a.has(m)?r.jsx(p0,{path:m,cwd:o,children:f},u):f},e[8]=o,e[9]=a,e[10]=d):d=e[10],l=t.split(/(\s+)/).map(d),e[4]=t,e[5]=o,e[6]=a,e[7]=l}else l=e[7];let c;return e[11]!==l?(c=r.jsx(r.Fragment,{children:l}),e[11]=l,e[12]=c):c=e[12],c}const hT=/^([^\s:]+):(\d+)([:-])/,wl="mb-2 ml-[7px] max-h-96 overflow-y-auto whitespace-pre-wrap break-all border-l-2 pl-4 font-mono text-[11px] leading-relaxed text-muted-foreground";function gT(n){const e=B.c(16),{section:t,analysis:s,cwd:o}=n,i=t.output??"";if(s.readFile&&!s.failed){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=G(wl,"pl-0 [&_pre]:border-0 [&_pre]:pl-4"),e[0]=d):d=e[0];let f;return e[1]!==s.readFile.path||e[2]!==i?(f=r.jsx("div",{className:d,children:r.jsx(i0,{result:i,filePath:s.readFile.path,expanded:!0,variant:"unboxed"})}),e[1]=s.readFile.path,e[2]=i,e[3]=f):f=e[3],f}if(s.kind==="search"&&!s.failed){let d;if(e[4]!==o||e[5]!==i){let u;e[7]!==o?(u=(m,p)=>{const h=m.match(hT);return r.jsx("span",{className:"block",children:h?r.jsxs(r.Fragment,{children:[r.jsxs(p0,{path:h[1],line:Number(h[2]),cwd:o,children:[h[1],":",h[2]]}),m.slice(h[1].length+h[2].length+1)]}):m||" "},p)},e[7]=o,e[8]=u):u=e[8],d=i.split(`
|
|
105
|
+
`).map(u),e[4]=o,e[5]=i,e[6]=d}else d=e[6];let f;return e[9]!==d?(f=r.jsx("pre",{className:wl,children:d}),e[9]=d,e[10]=f):f=e[10],f}const a=s.failed&&"border-destructive/40 text-destructive";let l;e[11]!==a?(l=G(wl,a),e[11]=a,e[12]=l):l=e[12];let c;return e[13]!==i||e[14]!==l?(c=r.jsx("pre",{className:l,children:i}),e[13]=i,e[14]=l,e[15]=c):c=e[15],c}function xT(n){const e=B.c(11),{sections:t}=n;let s,o,i,a,l;if(e[0]!==t){l=Symbol.for("react.early_return_sentinel");e:{const d=t.map(vT);if(d.reduce(bT,0)===0){l=null;break e}s="flex h-1.5 w-full gap-px overflow-hidden rounded-full bg-muted",o="img",i=`Output share: ${t.map((u,m)=>`${Li(u)} ${d[m]}`).join(", ")}`,a=d.map((u,m)=>u>0?r.jsx("span",{className:G("h-full",m0(m)),style:{flexGrow:u,flexBasis:0},title:`${Li(t[m])}: ${f0(t[m].output)}`},m):null)}e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=l}else s=e[1],o=e[2],i=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;let c;return e[6]!==s||e[7]!==o||e[8]!==i||e[9]!==a?(c=r.jsx("div",{className:s,role:o,"aria-label":i,children:a}),e[6]=s,e[7]=o,e[8]=i,e[9]=a,e[10]=c):c=e[10],c}function bT(n,e){return n+e}function vT(n){return Ld(n.output)}function yT(n,e,t){return n.output===null?"bg-muted-foreground/40":e.failed?"bg-destructive":m0(t)}function wT(n,e){return e.failed?"font-medium text-destructive":n.output===null?"text-amber-500":"text-muted-foreground"}function jT(n){var U;const e=B.c(64),{section:t,analysis:s,index:o,defaultOpen:i,cwd:a}=n,[l,c]=v.useState(i);let d;e[0]!==t?(d=Li(t),e[0]=t,e[1]=d):d=e[1];const f=d,u=t.output!==null&&t.output!=="",m=`${f} section: ${t.command}`,p=zi[s.kind].icon;let h;e[2]!==s||e[3]!==o||e[4]!==t?(h=G("flex size-4 shrink-0 items-center justify-center rounded-full font-mono text-[9px] tabular-nums text-background",yT(t,s,o)),e[2]=s,e[3]=o,e[4]=t,e[5]=h):h=e[5];const g=o+1;let x;e[6]!==h||e[7]!==g?(x=r.jsx("span",{className:h,"aria-hidden":"true",children:g}),e[6]=h,e[7]=g,e[8]=x):x=e[8];const b=s.kind==="write"?"text-foreground":"text-muted-foreground";let w;e[9]!==b?(w=G("size-3 shrink-0",b),e[9]=b,e[10]=w):w=e[10];const y=zi[s.kind];let j;e[11]!==p||e[12]!==w||e[13]!==y.label?(j=r.jsx(p,{className:w,"aria-label":y.label}),e[11]=p,e[12]=w,e[13]=y.label,e[14]=j):j=e[14];const k=s.failed&&u0.failed;let N;e[15]!==k?(N=G("shrink-0 font-mono text-[10px]",k),e[15]=k,e[16]=N):N=e[16];let C;e[17]!==f||e[18]!==N?(C=r.jsx(Ee,{variant:"outline",className:N,children:f}),e[17]=f,e[18]=N,e[19]=C):C=e[19];let S;e[20]!==s.paths||e[21]!==a||e[22]!==t.command?(S=r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/90",children:r.jsx(pT,{command:t.command,paths:s.paths,cwd:a})}),e[20]=s.paths,e[21]=a,e[22]=t.command,e[23]=S):S=e[23];let _;e[24]!==s.readFile?(_=((U=s.readFile)==null?void 0:U.from)&&r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/70",children:["L",s.readFile.from,"–",s.readFile.to]}),e[24]=s.readFile,e[25]=_):_=e[25];let P;e[26]!==s||e[27]!==t?(P=G("shrink-0 text-[10px] tabular-nums",wT(t,s)),e[26]=s,e[27]=t,e[28]=P):P=e[28];let A;e[29]!==s.failed||e[30]!==t.output?(A=s.failed?"failed":f0(t.output),e[29]=s.failed,e[30]=t.output,e[31]=A):A=e[31];let T;e[32]!==P||e[33]!==A?(T=r.jsx("span",{className:P,children:A}),e[32]=P,e[33]=A,e[34]=T):T=e[34];const E=l&&"rotate-90",R=!u&&"invisible";let M;e[35]!==E||e[36]!==R?(M=G("size-3 shrink-0 text-muted-foreground transition-transform",E,R),e[35]=E,e[36]=R,e[37]=M):M=e[37];let I;e[38]!==M?(I=r.jsx(Je,{className:M,"aria-hidden":"true"}),e[38]=M,e[39]=I):I=e[39];let D;e[40]!==C||e[41]!==S||e[42]!==_||e[43]!==T||e[44]!==I||e[45]!==x||e[46]!==j?(D=r.jsxs(r.Fragment,{children:[x,j,C,S,_,T,I]}),e[40]=C,e[41]=S,e[42]=_,e[43]=T,e[44]=I,e[45]=x,e[46]=j,e[47]=D):D=e[47];const O=D;if(!u){let W;return e[48]!==O||e[49]!==m?(W=r.jsx("div",{className:"group/row flex w-full items-center gap-2 py-1.5 pr-2 text-left","aria-label":m,children:O}),e[48]=O,e[49]=m,e[50]=W):W=e[50],W}let $,L;e[51]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx("div",{role:"button",tabIndex:0}),L=G("group/row flex w-full items-center gap-2 py-1.5 pr-2 text-left","cursor-pointer rounded-sm hover:bg-muted/40"),e[51]=$,e[52]=L):($=e[51],L=e[52]);let F;e[53]!==O||e[54]!==m?(F=r.jsx(Jt,{nativeButton:!1,render:$,className:L,"aria-label":m,children:O}),e[53]=O,e[54]=m,e[55]=F):F=e[55];let z;e[56]!==s||e[57]!==a||e[58]!==t?(z=r.jsx(wt,{children:r.jsx(gT,{section:t,analysis:s,cwd:a})}),e[56]=s,e[57]=a,e[58]=t,e[59]=z):z=e[59];let H;return e[60]!==l||e[61]!==F||e[62]!==z?(H=r.jsxs(yt,{open:l,onOpenChange:c,children:[F,z]}),e[60]=l,e[61]=F,e[62]=z,e[63]=H):H=e[63],H}function ST(n){const e=new Map;for(const{kind:t}of n)e.set(t,(e.get(t)??0)+1);return fT.filter(t=>e.has(t)).map(t=>{const s=e.get(t)??0;return`${s} ${s===1?zi[t].label:zi[t].plural}`}).join(" · ")}function Dm(n){const e=B.c(49),{sections:t,description:s,cwd:o,expandAll:i}=n,a=i===void 0?!1:i;let l;e[0]!==t?(l=t.map(d0),e[0]=t,e[1]=l):l=e[1];const c=l;let d;e[2]!==t?(d=t.reduce(CT,0),e[2]=t,e[3]=d):d=e[3];const f=d;let u;e[4]!==t?(u=t.filter(NT),e[4]=t,e[5]=u):u=e[5];const m=u.length;let p;e[6]!==c?(p=c.filter(kT),e[6]=c,e[7]=p):p=e[7];const h=p.length;let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Th,{className:"size-4","aria-hidden":"true"}),e[8]=g):g=e[8];let x;e[9]!==h?(x=h>0&&r.jsxs("span",{className:"font-medium text-destructive",children:[" · ",h," failed"]}),e[9]=h,e[10]=x):x=e[10];let b;e[11]!==m?(b=m>0&&r.jsxs("span",{className:"text-amber-500",children:[" · ",m," not reached"]}),e[11]=m,e[12]=b):b=e[12];let w;e[13]!==x||e[14]!==b||e[15]!==f?(w=r.jsxs("span",{className:"ml-auto font-normal tabular-nums text-muted-foreground",children:[f," lines",x,b]}),e[13]=x,e[14]=b,e[15]=f,e[16]=w):w=e[16];let y;e[17]!==t.length||e[18]!==w?(y=r.jsxs(Vt,{className:"flex items-center gap-2",children:[g,t.length," commands in one call",w]}),e[17]=t.length,e[18]=w,e[19]=y):y=e[19];let j;e[20]!==c?(j=ST(c),e[20]=c,e[21]=j):j=e[21];let k;e[22]!==j?(k=r.jsx("span",{className:"tabular-nums",children:j}),e[22]=j,e[23]=k):k=e[23];let N;e[24]!==s?(N=s&&r.jsx("span",{className:"text-foreground/80",children:s}),e[24]=s,e[25]=N):N=e[25];let C;e[26]!==k||e[27]!==N?(C=r.jsxs(Gt,{className:"flex flex-wrap gap-x-2",children:[k,N]}),e[26]=k,e[27]=N,e[28]=C):C=e[28];let S;e[29]!==t?(S=r.jsx(xT,{sections:t}),e[29]=t,e[30]=S):S=e[30];let _;e[31]!==y||e[32]!==C||e[33]!==S?(_=r.jsxs(Bt,{children:[y,C,S]}),e[31]=y,e[32]=C,e[33]=S,e[34]=_):_=e[34];let P;if(e[35]!==c||e[36]!==o||e[37]!==a||e[38]!==t){let E;e[40]!==c||e[41]!==o||e[42]!==a?(E=(R,M)=>r.jsx(jT,{section:R,analysis:c[M],index:M,defaultOpen:a,cwd:o},M),e[40]=c,e[41]=o,e[42]=a,e[43]=E):E=e[43],P=t.map(E),e[35]=c,e[36]=o,e[37]=a,e[38]=t,e[39]=P}else P=e[39];let A;e[44]!==P?(A=r.jsx(Lt,{children:r.jsx("div",{"aria-label":"Command sections",children:P})}),e[44]=P,e[45]=A):A=e[45];let T;return e[46]!==_||e[47]!==A?(T=r.jsxs(Dt,{size:"sm",className:"mt-1.5",children:[_,A]}),e[46]=_,e[47]=A,e[48]=T):T=e[48],T}function kT(n){return n.failed}function NT(n){return n.output===null}function CT(n,e){return n+Ld(e.output)}const _T=Gn("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out hover:bg-muted hover:text-foreground active:scale-[0.96] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-muted motion-reduce:transition-none motion-reduce:active:scale-100 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}}),h0=v.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function g0(n){const e=B.c(29);let t,s,o,i,a,l,c;e[0]!==n?({className:s,variant:c,size:i,spacing:a,orientation:l,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=a===void 0?2:a,f=l===void 0?"horizontal":l;let u;e[8]!==d?(u={"--gap":d},e[8]=d,e[9]=u):u=e[9];const m=u;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==f||e[13]!==i||e[14]!==d||e[15]!==c?(h={variant:c,size:i,spacing:d,orientation:f},e[12]=f,e[13]=i,e[14]=d,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=r.jsx(h0.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==f||e[21]!==o||e[22]!==i||e[23]!==d||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=r.jsx(uy,{"data-slot":"toggle-group","data-variant":c,"data-size":i,"data-spacing":d,"data-orientation":f,orientation:f,style:m,className:p,...o,children:g}),e[20]=f,e[21]=o,e[22]=i,e[23]=d,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function x0(n){const e=B.c(19);let t,s,o,i,a;e[0]!==n?({className:s,children:t,variant:i,size:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"default":i,c=a===void 0?"default":a,d=v.useContext(h0),f=d.variant||l,u=d.size||c,m=d.spacing;let p;e[6]!==s||e[7]!==d.size||e[8]!==d.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",_T({variant:d.variant||l,size:d.size||c}),s),e[6]=s,e[7]=d.size,e[8]=d.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==d.spacing||e[14]!==o||e[15]!==f||e[16]!==u||e[17]!==p?(h=r.jsx(dy,{"data-slot":"toggle-group-item","data-variant":f,"data-size":u,"data-spacing":m,className:p,...o,children:t}),e[12]=t,e[13]=d.spacing,e[14]=o,e[15]=f,e[16]=u,e[17]=p,e[18]=h):h=e[18],h}function TT(n){const e=B.c(31),{toolCall:t,sessionId:s,embedded:o}=n,i=o===void 0?!1:o;let a;e[0]!==t.input.questions?(a=t.input.questions??[],e[0]=t.input.questions,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c=()=>Object.fromEntries(l.map(ET)),e[2]=l,e[3]=c):c=e[3];const[d,f]=v.useState(c),[u,m]=v.useState(!1),[p,h]=v.useState(!1),{chat:g}=_r(),{sendMessage:x}=g;if(l.length===0)return null;let b;e[4]!==d||e[5]!==l||e[6]!==x?(b=()=>{const T=l.map(E=>{var M;const R=(M=d[E.question])==null?void 0:M.trim();return R?l.length>1?`${E.question}
|
|
106
|
+
${R}`:R:null}).filter(Boolean).join(`
|
|
107
|
+
|
|
108
|
+
`);T&&x(T),h(!0)},e[4]=d,e[5]=l,e[6]=x,e[7]=b):b=e[7];const w=b;let y;if(e[8]!==d||e[9]!==w||e[10]!==s||e[11]!==t.id){const T=async E=>{E.preventDefault(),m(!0);try{(await Xc(s,t.id,d)).ok?h(!0):w()}catch{w()}m(!1)};y=E=>{T(E)},e[8]=d,e[9]=w,e[10]=s,e[11]=t.id,e[12]=y}else y=e[12];const j=!i&&"mt-2 rounded-md border bg-card p-3",k=p&&"pointer-events-none opacity-50";let N;e[13]!==j||e[14]!==k?(N=G("flex flex-col gap-3",j,k),e[13]=j,e[14]=k,e[15]=N):N=e[15];let C;if(e[16]!==d||e[17]!==l||e[18]!==t.id){let T;e[20]!==d||e[21]!==t.id?(T=(E,R)=>{const M=E.options&&E.options.length>0,I=new Set(E.multiSelect?(d[E.question]??"").split(", ").filter(Boolean):[]),D=`ask-user-answer-${t.id}-${R}`;return r.jsxs(Uw,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(E.header||E.question)&&r.jsxs(Ww,{variant:"label",className:"flex flex-col items-start gap-1",children:[E.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:E.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:E.question})]}),M?r.jsx(g0,{multiple:E.multiSelect,orientation:"vertical",variant:"outline",value:E.multiSelect?Array.from(I):d[E.question]?[d[E.question]]:[],onValueChange:O=>{if(!E.multiSelect&&O.length===0)return;const $=E.multiSelect?O.join(", "):O[0];f({...d,[E.question]:$})},className:"grid w-full gap-1.5",children:E.options.map((O,$)=>{const L=E.multiSelect?I.has(O.label):d[E.question]===O.label;return r.jsxs(x0,{value:O.label,"aria-label":O.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",E.multiSelect?"rounded":"rounded-full",L?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:L&&r.jsx(ft,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-xs font-medium",children:O.label}),O.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:O.description})]})]},$)})}):r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:D,children:"Answer"}),r.jsx(wa,{id:D,value:d[E.question]??"",onChange:O=>{f({...d,[E.question]:O.target.value})},rows:2,placeholder:"Type your answer..."})]})]},R)},e[20]=d,e[21]=t.id,e[22]=T):T=e[22],C=l.map(T),e[16]=d,e[17]=l,e[18]=t.id,e[19]=C}else C=e[19];const S=u||p,_=p?"Sent":u?"Sending...":"Send answer";let P;e[23]!==S||e[24]!==_?(P=r.jsx(Z,{type:"submit",size:"sm",disabled:S,children:_}),e[23]=S,e[24]=_,e[25]=P):P=e[25];let A;return e[26]!==C||e[27]!==P||e[28]!==y||e[29]!==N?(A=r.jsxs("form",{onSubmit:y,className:N,children:[C,P]}),e[26]=C,e[27]=P,e[28]=y,e[29]=N,e[30]=A):A=e[30],A}function ET(n){return[n.question,""]}function PT(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function Lm(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function AT(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[Lm(s[1])]=Lm(s[2]);return e}function RT(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function IT(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${RT(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function MT(n,e){const t=n.input.answers;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const o=Object.entries(t).filter(i=>typeof i[1]=="string");if(o.length>0)return Object.fromEntries(o)}if(!n.result)return{};const s=AT(n.result);for(const o of e)if(s[o.question]===void 0){const i=IT(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function zm(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function $T(n){const e=B.c(30),{question:t,answer:s,index:o,completed:i}=n;let a;e[0]!==t.options?(a=t.options??[],e[0]=t.options,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==s||e[3]!==l||e[4]!==t){let y;e[6]!==s||e[7]!==t?(y=j=>zm(t,s,j.label),e[6]=s,e[7]=t,e[8]=y):y=e[8],c=l.filter(y),e[2]=s,e[3]=l,e[4]=t,e[5]=c}else c=e[5];const d=c.length,f=i&&s!==void 0&&d===0,u=o+1;let m;e[9]!==u?(m=r.jsx(Ee,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:u}),e[9]=u,e[10]=m):m=e[10];let p;e[11]!==t.header?(p=t.header&&r.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t.header}),e[11]=t.header,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t.question?(g=r.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.question}),e[16]=t.question,e[17]=g):g=e[17];let x;e[18]!==s||e[19]!==l||e[20]!==t?(x=l.length>0&&r.jsx("div",{className:"mt-2 flex flex-col divide-y divide-border",children:l.map((y,j)=>{const k=zm(t,s,y.label);return r.jsxs("div",{className:G("flex items-start gap-2.5 py-2",k?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",t.multiSelect?"rounded":"rounded-full",k?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:k&&r.jsx(ft,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"block text-xs font-medium",children:[y.label,k&&r.jsx(Ee,{variant:"secondary",className:"ml-2",children:"Selected"})]}),y.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:y.description})]})]},`${y.label}-${j}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let b;e[22]!==s||e[23]!==f?(b=f&&r.jsxs("div",{className:"mt-2 border-l-2 border-border pl-3",children:[r.jsx("div",{className:"mb-0.5 text-xs font-medium text-muted-foreground",children:"Answer"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90",children:s.trim()||"No answer provided"})]}),e[22]=s,e[23]=f,e[24]=b):b=e[24];let w;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==b?(w=r.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,x,b]}),e[25]=h,e[26]=g,e[27]=x,e[28]=b,e[29]=w):w=e[29],w}function OT(n){const e=B.c(61),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=v.useState(!1);let c;e[0]!==t?(c=PT(t),e[0]=t,e[1]=c):c=e[1];const d=c;let f;e[2]!==d||e[3]!==t?(f=MT(t,d),e[2]=d,e[3]=t,e[4]=f):f=e[4];const u=f,m=s||a,p=t.result!==null&&!t.isError,h=t.result===null&&o&&!!i&&d.length>0;let g;e[5]!==u?(g=Object.keys(u),e[5]=u,e[6]=g):g=e[6];const x=g.length>0,b=t.isError?en:p?Pn:yr,w=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",y=t.isError&&"border-destructive/30";let j;e[7]!==y?(j=G("my-1 overflow-hidden rounded-lg border bg-card",y),e[7]=y,e[8]=j):j=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Eh,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=k):k=e[9];let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=N):N=e[10];const C=d.length===1?"question":"questions";let S;e[11]!==d.length||e[12]!==C?(S=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[N,r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",C]})]}),e[11]=d.length,e[12]=C,e[13]=S):S=e[13];const _=t.isError?"destructive":p?"secondary":"outline";let P;e[14]!==b?(P=r.jsx(b,{"data-icon":"inline-start"}),e[14]=b,e[15]=P):P=e[15];let A;e[16]!==w||e[17]!==_||e[18]!==P?(A=r.jsxs(Ee,{variant:_,children:[P,w]}),e[16]=w,e[17]=_,e[18]=P,e[19]=A):A=e[19];let T;e[20]!==A||e[21]!==S?(T=r.jsxs("div",{className:"min-w-0 flex-1",children:[S,A]}),e[20]=A,e[21]=S,e[22]=T):T=e[22];let E;e[23]!==t.timestamp?(E=t.timestamp&&r.jsx("time",{className:"hidden shrink-0 pt-0.5 font-mono text-xs tabular-nums text-muted-foreground sm:block",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e[23]=t.timestamp,e[24]=E):E=e[24];let R;e[25]!==T||e[26]!==E?(R=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[k,T,E]}),e[25]=T,e[26]=E,e[27]=R):R=e[27];let M;e[28]!==u||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?(M=h&&i?r.jsx(TT,{toolCall:t,sessionId:i,embedded:!0}):d.length>0?d.map((U,W)=>r.jsx($T,{question:U,answer:u[U.question],index:W,completed:t.result!==null},`${U.question}-${W}`)):r.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Question details are unavailable."}),e[28]=u,e[29]=h,e[30]=d,e[31]=i,e[32]=t,e[33]=M):M=e[33];let I;e[34]!==x||e[35]!==t.isError||e[36]!==t.result?(I=t.result!==null&&!x&&r.jsxs("div",{className:G("border-t border-border py-3",t.isError?"text-destructive":"text-muted-foreground"),children:[r.jsx("div",{className:"mb-0.5 text-xs font-semibold uppercase tracking-wide opacity-70",children:"Recorded response"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:t.result})]}),e[34]=x,e[35]=t.isError,e[36]=t.result,e[37]=I):I=e[37];let D;e[38]!==M||e[39]!==I?(D=r.jsxs("div",{className:"px-3",children:[M,I]}),e[38]=M,e[39]=I,e[40]=D):D=e[40];let O;e[41]!==s?(O=()=>{s||l(DT)},e[41]=s,e[42]=O):O=e[42];let $;e[43]!==m?($=m?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),e[43]=m,e[44]=$):$=e[44];let L;e[45]!==m||e[46]!==O||e[47]!==$?(L=r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:O,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[$,"Raw details"]}),e[45]=m,e[46]=O,e[47]=$,e[48]=L):L=e[48];let F;e[49]!==m||e[50]!==t.input||e[51]!==t.result?(F=m&&r.jsxs("div",{className:"mt-1.5 grid gap-2 pb-1.5 lg:grid-cols-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Input"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:JSON.stringify(t.input,null,2)})]}),t.result!==null&&r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Result"}),r.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",children:t.result})]})]}),e[49]=m,e[50]=t.input,e[51]=t.result,e[52]=F):F=e[52];let z;e[53]!==L||e[54]!==F?(z=r.jsxs("div",{className:"border-t px-3 py-1.5",children:[L,F]}),e[53]=L,e[54]=F,e[55]=z):z=e[55];let H;return e[56]!==R||e[57]!==D||e[58]!==z||e[59]!==j?(H=r.jsxs("section",{className:j,"aria-label":"Question history",children:[R,D,z]}),e[56]=R,e[57]=D,e[58]=z,e[59]=j,e[60]=H):H=e[60],H}function DT(n){return!n}const LT={spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"Task"},send_message:{label:"Message agent",styleName:"Task"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"Task"},interrupt_agent:{label:"Interrupt agent",styleName:"Task"},tool_search:{label:"Find tools",styleName:"ToolSearch"},list_mcp_resources:{label:"List MCP resources",styleName:"Mcp"},list_mcp_resource_templates:{label:"List MCP templates",styleName:"Mcp"},read_mcp_resource:{label:"Read MCP resource",styleName:"Mcp"},request_plugin_install:{label:"Install plugin",styleName:"Mcp"},create_goal:{label:"Create goal",styleName:"TodoWrite"},get_goal:{label:"Check goal",styleName:"TodoWrite"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}};function zT(n){return typeof n=="object"&&n!==null}function an(...n){return n.find(e=>typeof e=="string")??""}function wo(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function zd(n){const e=[],t=new Set;for(const s of n){const o=s.trim();!o||t.has(o)||(t.add(o),e.push(o))}return e}function Lr(n,e=""){const t=zd(n);if(t.length===0)return e;const s=wo(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function Fd(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const Fm={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function Fi(n,e=!1){const t=n.replace(/^mcp__/,"").replace(/__/g," ").replace(/[_./:-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map(o=>{const i=o.toLowerCase();return Fm[i]?Fm[i]:e?i[0].toUpperCase()+i.slice(1):i});if(t.length===0)return"Tool";const s=t.join(" ");return s[0].toUpperCase()+s.slice(1)}function FT(n){if(!n)return null;const e=n.trim(),t=Vn(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function Kt(n,...e){for(const t of e){const s=FT(yd(n,t));if(s)return s;const o=wd(n,t)[0];if(o)return o}return""}function BT(n,...e){for(const t of e){const s=F1(n,t)[0];if(s!==void 0)return s}return null}function Bi(n){return Kt(n,"description","query","q","cmd","command","file_path","path","uri","url","pattern","prompt","objective","message","location","ticker","target","task_name","plugin_id","server","status","id")}const UT=[{key:"search_query",label:"Search web",noun:"search",summaryGroups:[["q","query"]]},{key:"image_query",label:"Search images",noun:"image search",summaryGroups:[["q","query"]]},{key:"open",label:"Open page",noun:"page",summaryGroups:[["ref_id","url"]],detail:{property:"lineno",format:n=>`line ${n}`}},{key:"click",label:"Open link",noun:"link",summaryGroups:[["ref_id"]],detail:{property:"id",format:n=>`link ${n}`}},{key:"find",label:"Find on page",noun:"find",summaryGroups:[["pattern"],["ref_id","url"]]},{key:"screenshot",label:"Capture page",noun:"capture",summaryGroups:[["ref_id"]],detail:{property:"pageno",format:n=>`page ${n+1}`}},{key:"finance",label:"Check markets",noun:"quote",summaryGroups:[["ticker"]]},{key:"weather",label:"Check weather",noun:"forecast",summaryGroups:[["location"]]},{key:"sports",label:"Check sports",noun:"sports lookup",summaryGroups:[["league","team"]],countProperties:["league"]},{key:"time",label:"Check time",noun:"time lookup",summaryGroups:[["utc_offset"]]}];function Bm(n,e){return e.flatMap(t=>wd(n,t))}function WT(n,e){const t=e.summaryGroups.map(i=>Bm(n,i)),s=e.detail?F1(n,e.detail.property):[],o=e.countProperties?Bm(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>Lr(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(B1(n),zd(o).length,s.length,1)}}function HT(n){const e=[];for(const t of UT){const s=yd(n,t.key);s&&e.push(WT(s,t))}return e}function KT(n){const e=HT(n);return e.length===0?{label:"Browse web",summary:Bi(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>Fd(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function b0(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:Fi(e,!0),action:Fi(t.join(" "))}}function qT(n,e){const t=b0(n);if(!t)return{label:Fi(n),summary:Bi(e),styleName:"Mcp"};const s=Bi(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function VT(n){const e=Vn(n.trim(),0),t=(e==null?void 0:e.value)??n,s=zd(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return Lr(s,s.length>0?Fd(s.length,"file"):"")}function GT(n){const e=n.argumentSource;switch(n.name){case"exec_command":return{label:"Run command",summary:Kt(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=BT(e,"session_id"),s=Kt(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?wo(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:VT(e),styleName:"Edit"};case"web__run":case"web_search":return KT(e);case"view_image":return{label:"View image",summary:Kt(e,"path"),styleName:"Read"};case"update_plan":{const t=yd(e,"plan"),s=t?B1(t):0;return{label:"Update plan",summary:s>0?Fd(s,"step"):Kt(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:Kt(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TodoWrite"};case"update_goal":return{label:"Update goal",summary:Kt(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:Kt(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:Kt(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[Kt(e,"server"),Kt(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:Kt(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:Kt(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:Kt(e,"prompt"),styleName:"Image"};default:return n.name.startsWith("mcp__")?qT(n.name,e):{label:Fi(n.name),summary:Bi(e),styleName:n.name}}}function v0(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function YT(n){const e=sN(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(GT),s=t[0];if(t.every(i=>i.label===s.label)){const i=Lr(t.map(a=>a.summary));return{label:s.label,summary:e.length===1?i:[`×${e.length}`,i].filter(Boolean).join(" · "),styleName:s.styleName}}const o=new Map;for(const i of t)o.set(i.label,(o.get(i.label)??0)+1);return{label:"Run tools",summary:[...o].map(([i,a])=>a>1?`${i} ×${a}`:i).join(" · "),styleName:"exec"}}function XT(n){const e=zT(n.action)?n.action:null,t=typeof(e==null?void 0:e.type)=="string"?e.type:"search";if(t==="open_page"||t==="openPage")return{label:"Open page",summary:an(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[an(e==null?void 0:e.pattern),an(e==null?void 0:e.url)].filter(Boolean).join(" · "),styleName:"WebSearch"};const s=Array.isArray(e==null?void 0:e.queries)?e.queries.filter(i=>typeof i=="string"):[],o=an(e==null?void 0:e.query,n.query);return{label:"Search web",summary:Lr([o,...s]),styleName:"WebSearch"}}const JT=["summary","headline","verdict","title"];function QT(n){const e=an(...JT.map(t=>n[t]));if(e)return wo(e);for(const[t,s]of Object.entries(n)){if(!Array.isArray(s))continue;const o=s.length===1&&t.endsWith("s")?t.slice(0,-1):t;return`${s.length} ${o}`}return""}function ZT(n){const e=an(n.description);if(e)return wo(e);const t=an(n.script);return(t?wd(t,"name")[0]??"":"")||an(n.scriptPath)}function Um(n){const e=Object.keys(n);if(e.length===0)return"";const t=n[e[0]];return typeof t!="string"?"":t.length>80?t.slice(0,80)+"...":t}function Wm(n){var t;const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":return String(e.command??e.cmd??"");case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return String(e.description??e.prompt??"");case"WebFetch":return String(e.url??"");case"NotebookEdit":return String(e.notebook_path??"");case"EnterPlanMode":return"Entered plan mode";case"ExitPlanMode":return"Waiting for plan approval";case"AskUserQuestion":{const s=e.questions;return((t=s==null?void 0:s[0])==null?void 0:t.question)??""}case"Monitor":{const s=String(e.bash_id??""),o=e.filter?` · filter=${e.filter}`:"";return`${s}${o}`}case"CronCreate":{const s=String(e.schedule??e.cron??""),o=String(e.prompt??""),i=o.length>60?o.slice(0,60)+"...":o;return s&&i?`${s} → ${i}`:s||i}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const s=Number(e.delaySeconds??0),o=Math.round(s/60),i=s>=3600?`${Math.round(s/3600)}h`:s>=60?`${o}m`:`${s}s`,a=e.reason?` · ${e.reason}`:"";return`in ${i}${a}`}case"RemoteTrigger":{const s=String(e.action??""),o=String(e.id??e.trigger_id??"");return[s,o].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const s=String(e.name??e.branch??""),o=e.path?` (${e.path})`:"";return`${s}${o}`}case"ExitWorktree":return String(e.name??e.branch??"");case"Skill":return String(e.skill??e.name??"");case"ToolSearch":return String(e.query??"");case"SendMessage":{const s=an(e.to,e.recipient),o=wo(an(e.summary,e.message,e.content));return[s,o].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return wo(an(e.subject,e.description));case"TaskUpdate":{const s=String(e.taskId??""),o=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(a=>typeof a=="string"):[],i=an(e.status)||(o.length>0?`blocked by ${o.join(", ")}`:"");return i?`${s} → ${i}`:s}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return ZT(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return QT(e)||Um(e);case"spawn_agent":return String(e.task_name??e.message??"");case"wait_agent":{const s=Array.isArray(e.ids)?e.ids.filter(o=>typeof o=="string"):[];return Lr(s)}case"send_message":case"followup_task":return[e.target,e.message].filter(s=>typeof s=="string").join(" · ");case"list_agents":return String(e.path_prefix??"");case"interrupt_agent":return String(e.target??"");case"list_mcp_resources":case"list_mcp_resource_templates":return String(e.server??"");case"read_mcp_resource":return[e.server,e.uri].filter(s=>typeof s=="string").join(" · ");case"request_plugin_install":return String(e.plugin_id??"");case"create_goal":return String(e.objective??"");case"update_goal":return String(e.status??"");case"view_image":return String(e.path??"");default:return Um(e)}}function $a(n){if(v0(n))return YT(n.input.raw);if(n.name==="WebSearch")return XT(n.input);const e=b0(n.name);if(e)return{label:e.server,summary:[e.action,Wm(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const t=LT[n.name];return{label:(t==null?void 0:t.label)??n.name,summary:Wm(n),styleName:(t==null?void 0:t.styleName)??n.name}}function e7(n){return $a(n).summary}const t7={mutating:"text-foreground",readOnly:"text-muted-foreground"},n7="text-destructive",Hm=8,s7=4,o7="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground",r7="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border p-2 font-mono text-xs leading-relaxed";function i7(n){return n.split(/\r\n|\r|\n/)}const a7={Write:"mutating",Edit:"mutating",Bash:"mutating",exec:"mutating",Task:"mutating",Skill:"mutating",TodoWrite:"mutating",Image:"mutating",AskUserQuestion:"mutating",CronCreate:"mutating",CronDelete:"mutating",ScheduleWakeup:"mutating",RemoteTrigger:"mutating",PushNotification:"mutating",EnterWorktree:"mutating",ExitWorktree:"mutating",Agent:"mutating",SendMessage:"mutating",EndConversation:"mutating",TaskCreate:"mutating",TaskUpdate:"mutating",TaskStop:"mutating",Workflow:"mutating",Read:"readOnly",Grep:"readOnly",Glob:"readOnly",WebFetch:"readOnly",WebSearch:"readOnly",ToolSearch:"readOnly",Monitor:"readOnly",CronList:"readOnly",Mcp:"readOnly",EnterPlanMode:"readOnly",ExitPlanMode:"readOnly",ListAgents:"readOnly",TaskList:"readOnly",TaskOutput:"readOnly",LSP:"readOnly",StructuredOutput:"readOnly",ReportFindings:"readOnly"},l7="readOnly";function c7(n){return a7[n]??l7}function y0(n,e=!1){return e?n7:t7[c7(n)]}function jl(n){const e=B.c(8),{isOpen:t,onClick:s,label:o,controlsId:i}=n,a=t?Ze:Je;let l;e[0]!==a?(l=r.jsx(a,{"data-icon":"inline-start"}),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s||e[6]!==l?(c=r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground","aria-expanded":t,"aria-controls":i,children:[l,o]}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=l,e[7]=c):c=e[7],c}function w0(n){const e=B.c(2),{toolCall:t,isAgentActive:s}=n;if(t.isError){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ss,{role:"img","aria-label":"Tool call failed",className:"size-4 text-destructive","data-icon":"icon"}),e[0]=o):o=e[0],o}if(t.result===null&&s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(rt,{role:"img","aria-label":"Tool call running",className:"size-4 animate-spin text-info","data-icon":"icon"}),e[1]=o):o=e[1],o}return null}function d7(n){const e=B.c(30),{toolCall:t,resultExpanded:s,onToggleExpanded:o,isMobile:i}=n,a=t.result??"",l=a.length>1e3,c=l&&!s?a.slice(0,500)+"...":a;let d;e[0]!==a||e[1]!==t.isError||e[2]!==t.name?(d=!t.isError&&t.name!=="Read"?a0(a):null,e[0]=a,e[1]=t.isError,e[2]=t.name,e[3]=d):d=e[3];const f=d,u=f??a;let m;e[4]!==u?(m=i7(u),e[4]=u,e[5]=m):m=e[5];const p=m,h=Math.max(0,p.length-Hm);let g;e[6]!==p||e[7]!==u||e[8]!==s?(g=s?u:p.slice(0,Hm).join(`
|
|
109
|
+
`),e[6]=p,e[7]=u,e[8]=s,e[9]=g):g=e[9];const x=g,b=i?l:h>0,w=!i||!l||s,y=i?"boxed":"unboxed";let j;e[10]!==x||e[11]!==w||e[12]!==y||e[13]!==i||e[14]!==c||e[15]!==f||e[16]!==a||e[17]!==t.input||e[18]!==t.isError||e[19]!==t.name?(j=t.name==="Read"&&!t.isError&&typeof t.input.file_path=="string"?r.jsx(i0,{result:i?a:x,filePath:t.input.file_path,expanded:w,variant:y}):f!==null?r.jsx(gc,{result:i?f:x,expanded:w,alreadyPretty:!0,variant:y}):r.jsx("pre",{className:G(i?r7:o7,t.isError?G("border-destructive/20 text-destructive",i&&"bg-destructive/5"):i&&"border-border bg-muted/30 text-muted-foreground"),children:i?c:x}),e[10]=x,e[11]=w,e[12]=y,e[13]=i,e[14]=c,e[15]=f,e[16]=a,e[17]=t.input,e[18]=t.isError,e[19]=t.name,e[20]=j):j=e[20];let k;e[21]!==h||e[22]!==i||e[23]!==o||e[24]!==s||e[25]!==b?(k=b&&r.jsx("button",{type:"button",onClick:o,className:"mt-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:s?"Show less":i?"Show more":`+${h} lines`}),e[21]=h,e[22]=i,e[23]=o,e[24]=s,e[25]=b,e[26]=k):k=e[26];let N;return e[27]!==j||e[28]!==k?(N=r.jsxs("div",{className:"mt-1.5",children:[j,k]}),e[27]=j,e[28]=k,e[29]=N):N=e[29],N}function u7(n){const e=B.c(12),{chips:t}=n;let s,o,i,a;if(e[0]!==t){const d=t.slice(0,s7);s=t.length-d.length,o="flex min-w-0 items-center gap-1 overflow-hidden",i=`Sections: ${t.map(m7).join(", ")}`,a=d.map(f7),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];let l;e[5]!==s?(l=s>0&&r.jsxs("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:["+",s]}),e[5]=s,e[6]=l):l=e[6];let c;return e[7]!==o||e[8]!==i||e[9]!==a||e[10]!==l?(c=r.jsxs("span",{className:o,"aria-label":i,children:[a,l]}),e[7]=o,e[8]=i,e[9]=a,e[10]=l,e[11]=c):c=e[11],c}function f7(n,e){return r.jsx(Ee,{variant:"outline",className:G("h-4 shrink-0 px-1.5 font-mono text-[10px]",u0[n.tone]),children:n.name},e)}function m7(n){return n.name}function j0(n){const e=B.c(7),{chips:t,summary:s,isMobile:o}=n;if(t){let c;return e[0]!==t?(c=r.jsx(u7,{chips:t}),e[0]=t,e[1]=c):c=e[1],c}if(!s)return null;const i=o?"text-[11px]":"text-xs";let a;e[2]!==i?(a=G("truncate font-mono text-muted-foreground",i),e[2]=i,e[3]=a):a=e[3];let l;return e[4]!==s||e[5]!==a?(l=r.jsx("span",{className:a,children:s}),e[4]=s,e[5]=a,e[6]=l):l=e[6],l}function Km(n){const e=B.c(36),{toolCall:t,isMobile:s,isAgentActive:o,displayName:i,summary:a,sectionChips:l,nameTitle:c,nameClass:d,timeLabel:f,timeIso:u}=n;let m;e[0]!==u||e[1]!==f?(m=f&&r.jsx("time",{className:"sr-only",dateTime:u,children:f}),e[0]=u,e[1]=f,e[2]=m):m=e[2];const p=s?"gap-1.5":"gap-2";let h;e[3]!==p?(h=G("flex min-w-0 flex-1 items-center",p),e[3]=p,e[4]=h):h=e[4];const g=s?"text-[10px]":"text-[11px]";let x;e[5]!==d||e[6]!==g?(x=G("shrink-0 font-mono",g,d),e[5]=d,e[6]=g,e[7]=x):x=e[7];let b;e[8]!==i||e[9]!==c||e[10]!==x?(b=r.jsx("span",{className:x,title:c,children:i}),e[8]=i,e[9]=c,e[10]=x,e[11]=b):b=e[11];let w;e[12]!==l||e[13]!==s||e[14]!==a?(w=r.jsx(j0,{chips:l,summary:a,isMobile:s}),e[12]=l,e[13]=s,e[14]=a,e[15]=w):w=e[15];let y;e[16]!==h||e[17]!==b||e[18]!==w?(y=r.jsxs("div",{className:h,children:[b,w]}),e[16]=h,e[17]=b,e[18]=w,e[19]=y):y=e[19];let j;e[20]!==s||e[21]!==t.hookDurationMs?(j=t.hookDurationMs!==void 0&&t.hookDurationMs>0&&!s&&r.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",title:"PostToolUse hook duration",children:[t.hookDurationMs,"ms"]}),e[20]=s,e[21]=t.hookDurationMs,e[22]=j):j=e[22];let k;e[23]!==t.outputReplacedByHook?(k=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-blue-400",title:"Output replaced by hook",children:"hook"}),e[23]=t.outputReplacedByHook,e[24]=k):k=e[24];let N;e[25]!==o||e[26]!==t?(N=r.jsx(w0,{toolCall:t,isAgentActive:o}),e[25]=o,e[26]=t,e[27]=N):N=e[27];let C;e[28]!==k||e[29]!==N||e[30]!==j?(C=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[j,k,N]}),e[28]=k,e[29]=N,e[30]=j,e[31]=C):C=e[31];let S;return e[32]!==m||e[33]!==C||e[34]!==y?(S=r.jsxs(r.Fragment,{children:[m,y,C]}),e[32]=m,e[33]=C,e[34]=y,e[35]=S):S=e[35],S}function p7(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:n.name==="view_image"?n.input.path:null;return typeof e=="string"&&Cd(e)?e:null}function qm(n){const e=B.c(4),{toolCall:t}=n,s=t.input.old_string,o=t.input.new_string,i=t.input.file_path;let a;return e[0]!==s||e[1]!==o||e[2]!==i?(a=r.jsx(Dd,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const h7={AskUserQuestion:"Question",Bash:"Command",exec:"Command",Task:"Agent",WebFetch:"Fetch",WebSearch:"Search",EnterPlanMode:"Plan mode",ExitPlanMode:"Plan review",ToolSearch:"Tool search"},S0=v.memo(function(e){var Re,De;const t=B.c(147),{toolCall:s,expandAll:o,expandToolPayloads:i,isAgentActive:a,skillMetadata:l}=e,c=i===void 0?!1:i,{session:d,pendingInteraction:f}=it(),u=Ma(),[m,p]=v.useState(!1),[h,g]=v.useState(!1),[x,b]=v.useState(!1),[w,y]=v.useState(!1),[j,k]=v.useState(!1),[N,C]=v.useState(!1),S=v.useId(),_=v.useId(),P=v.useId(),A=v.useId(),T=v.useId(),[E,R]=v.useState(!1),M=s.result!==null||!a,I=u&&M&&!o&&!E;let D;t[0]!==s?(D=$a(s),t[0]=s,t[1]=D):D=t[1];const O=D;let $;t[2]!==s?($=v0(s),t[2]=s,t[3]=$):$=t[3];const L=$;let F;t[4]!==s.input.command||t[5]!==s.name||t[6]!==s.result?(F=s.name==="Bash"&&typeof s.input.command=="string"?K6(s.input.command,s.result):null,t[4]=s.input.command,t[5]=s.name,t[6]=s.result,t[7]=F):F=t[7];const z=F;let H;t[8]!==z?(H=z?uT(z):void 0,t[8]=z,t[9]=H):H=t[9];const U=H,W=typeof s.input.description=="string"?s.input.description:void 0,q=u&&O.label===s.name?h7[s.name]??s.name:O.label,V=O.label===s.name?s.name:`${O.label} (${s.name})`;let Y,K,X,Q,J,ee,oe,se,re,ie,ae,te,me,de;if(t[10]!==U||t[11]!==A||t[12]!==j||t[13]!==w||t[14]!==q||t[15]!==o||t[16]!==c||t[17]!==m||t[18]!==a||t[19]!==L||t[20]!==I||t[21]!==u||t[22]!==V||t[23]!==f||t[24]!==O.styleName||t[25]!==O.summary||t[26]!==x||t[27]!==h||t[28]!==z||t[29]!==(d==null?void 0:d.sessionId)||t[30]!==l||t[31]!==s){de=Symbol.for("react.early_return_sentinel");e:{const Te=y0(O.styleName,s.isError);let Ie;t[46]!==s.timestamp?(Ie=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[46]=s.timestamp,t[47]=Ie):Ie=t[47];const Le=Ie;let ze;t[48]!==s.timestamp?(ze=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[48]=s.timestamp,t[49]=ze):ze=t[49];const Ue=ze;X=c||u&&o,oe=X||m,se=X||h,ee=X||w;const Se=O.summary;let He;t[50]!==l||t[51]!==Se||t[52]!==s.name?(He=s.name==="Skill"&&l?l.get(Se)??null:null,t[50]=l,t[51]=Se,t[52]=s.name,t[53]=He):He=t[53],ie=He,re=ie==null?void 0:ie.filePath,K=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string",Y=K?"diff":s.name==="Bash"||L?"command":"result",J=c||j;const Oe=p7(s),Ne=Oe!==null&&((Re=s.result)==null?void 0:Re.trim())==="";let fe;t[54]!==Ne||t[55]!==u||t[56]!==x||t[57]!==z||t[58]!==s?(fe=s.result!==null&&!Ne&&!z?r.jsx(d7,{toolCall:s,resultExpanded:x,onToggleExpanded:()=>b(!x),isMobile:u}):null,t[54]=Ne,t[55]=u,t[56]=x,t[57]=z,t[58]=s,t[59]=fe):fe=t[59],Q=fe;let Pe;t[60]!==I?(Pe=()=>{I&&R(!0)},t[60]=I,t[61]=Pe):Pe=t[61];const Me=Pe;if(s.name==="AskUserQuestion"){const ue=(f==null?void 0:f.type)==="question"&&f.toolUseId===s.id,ke=d==null?void 0:d.sessionId;let Ae;t[62]!==X||t[63]!==ue||t[64]!==ke||t[65]!==s?(Ae=r.jsx(OT,{toolCall:s,expandToolPayloads:X,isAwaitingAnswer:ue,sessionId:ke}),t[62]=X,t[63]=ue,t[64]=ke,t[65]=s,t[66]=Ae):Ae=t[66],de=Ae;break e}const Fe=I?"py-1":"py-1.5",ne=s.isError&&!I&&"rounded-md bg-destructive/5 px-2";t[67]!==Fe||t[68]!==ne?(ae=G(Fe,ne),t[67]=Fe,t[68]=ne,t[69]=ae):ae=t[69],te=I?r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",className:"h-auto w-full justify-start px-1 py-1 text-left",onClick:Me,"aria-label":`Expand ${q} tool call`,title:Le,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[r.jsx("span",{className:G("shrink-0 font-mono text-xs",Te),title:V,children:q}),r.jsx(j0,{chips:U,summary:Se})]}),r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-end"}),r.jsx(w0,{toolCall:s,isAgentActive:a})]}):u?r.jsx("div",{className:"flex items-center gap-1.5",title:Le,children:r.jsx(Km,{toolCall:s,isMobile:!0,isAgentActive:a,displayName:q,summary:Se,sectionChips:U,nameTitle:V,nameClass:Te,timeLabel:Le,timeIso:Ue})}):r.jsx("button",{type:"button",className:"flex w-full items-center gap-2 rounded-sm text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",title:Le,"aria-label":`Toggle ${q} details${Se?`: ${Se}`:""}`,"aria-expanded":J,"aria-controls":A,onClick:()=>{c||k(g7)},children:r.jsx(Km,{toolCall:s,isMobile:!1,isAgentActive:a,displayName:q,summary:Se,sectionChips:U,nameTitle:V,nameClass:Te,timeLabel:Le,timeIso:Ue})}),me=Ne&&!I&&r.jsx(fc,{src:Oe,alt:Oe.slice(Oe.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[10]=U,t[11]=A,t[12]=j,t[13]=w,t[14]=q,t[15]=o,t[16]=c,t[17]=m,t[18]=a,t[19]=L,t[20]=I,t[21]=u,t[22]=V,t[23]=f,t[24]=O.styleName,t[25]=O.summary,t[26]=x,t[27]=h,t[28]=z,t[29]=d==null?void 0:d.sessionId,t[30]=l,t[31]=s,t[32]=Y,t[33]=K,t[34]=X,t[35]=Q,t[36]=J,t[37]=ee,t[38]=oe,t[39]=se,t[40]=re,t[41]=ie,t[42]=ae,t[43]=te,t[44]=me,t[45]=de}else Y=t[32],K=t[33],X=t[34],Q=t[35],J=t[36],ee=t[37],oe=t[38],se=t[39],re=t[40],ie=t[41],ae=t[42],te=t[43],me=t[44],de=t[45];if(de!==Symbol.for("react.early_return_sentinel"))return de;let le;t[70]!==I||t[71]!==s.id||t[72]!==s.resultImages?(le=!I&&((De=s.resultImages)==null?void 0:De.map((Te,Ie)=>r.jsx(fc,{src:`data:${Te.source.media_type};base64,${Te.source.data}`,alt:`Tool result image ${Ie+1}`,id:`tool-result-image:${s.id}:${Ie}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${Te.source.media_type}-${Te.source.data.length}-${Te.source.data.slice(0,32)}-${Te.source.data.slice(-32)}`))),t[70]=I,t[71]=s.id,t[72]=s.resultImages,t[73]=le):le=t[73];let he;t[74]!==I||t[75]!==re||t[76]!==ie?(he=ie&&!I&&r.jsxs("div",{className:"mt-1 flex items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",ie.source]}),re&&(!Os()||dd())&&r.jsxs(Z,{type:"button",variant:"link",size:"xs",onClick:Te=>{Te.stopPropagation(),ir(re)},className:"h-auto px-0 text-muted-foreground",title:re,children:[r.jsx(_h,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[74]=I,t[75]=re,t[76]=ie,t[77]=he):he=t[77];let ge;t[78]!==w||t[79]!==K||t[80]!==m||t[81]!==I||t[82]!==u||t[83]!==S||t[84]!==_||t[85]!==P||t[86]!==Q||t[87]!==h||t[88]!==ee||t[89]!==oe||t[90]!==se?(ge=u&&!I&&r.jsxs("div",{className:"flex gap-3 mt-1",children:[K&&r.jsx(jl,{isOpen:ee,onClick:()=>y(!w),label:"Diff",controlsId:S}),r.jsx(jl,{isOpen:oe,onClick:()=>p(!m),label:"Input",controlsId:_}),Q&&r.jsx(jl,{isOpen:se,onClick:()=>g(!h),label:"Result",controlsId:P})]}),t[78]=w,t[79]=K,t[80]=m,t[81]=I,t[82]=u,t[83]=S,t[84]=_,t[85]=P,t[86]=Q,t[87]=h,t[88]=ee,t[89]=oe,t[90]=se,t[91]=ge):ge=t[91];let ce;t[92]!==K||t[93]!==I||t[94]!==u||t[95]!==S||t[96]!==ee||t[97]!==s?(ce=u&&!I&&K&&r.jsx(yt,{open:ee,children:r.jsx(wt,{id:S,children:r.jsx(qm,{toolCall:s})})}),t[92]=K,t[93]=I,t[94]=u,t[95]=S,t[96]=ee,t[97]=s,t[98]=ce):ce=t[98];let ve;t[99]!==W||t[100]!==L||t[101]!==I||t[102]!==u||t[103]!==_||t[104]!==X||t[105]!==z||t[106]!==(d==null?void 0:d.cwd)||t[107]!==oe||t[108]!==s.input||t[109]!==s.name?(ve=u&&!I&&r.jsx(yt,{open:oe,children:r.jsx(wt,{id:_,children:z?r.jsx(Dm,{sections:z,description:W,cwd:d==null?void 0:d.cwd,expandAll:X}):s.name==="Bash"&&(typeof s.input.command=="string"||typeof s.input.cmd=="string")?r.jsx(Rm,{input:s.input}):L?r.jsx(Mm,{input:s.input}):r.jsx(gc,{result:JSON.stringify(s.input),expanded:!0})})}),t[99]=W,t[100]=L,t[101]=I,t[102]=u,t[103]=_,t[104]=X,t[105]=z,t[106]=d==null?void 0:d.cwd,t[107]=oe,t[108]=s.input,t[109]=s.name,t[110]=ve):ve=t[110];let xe;t[111]!==s.id||t[112]!==s.name||t[113]!==s.result?(xe=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx($d,{toolUseId:s.id}),t[111]=s.id,t[112]=s.name,t[113]=s.result,t[114]=xe):xe=t[114];let pe;t[115]!==I||t[116]!==u||t[117]!==P||t[118]!==Q||t[119]!==se?(pe=u&&!I&&Q&&r.jsx(yt,{open:se,children:r.jsx(wt,{id:P,children:Q})}),t[115]=I,t[116]=u,t[117]=P,t[118]=Q,t[119]=se,t[120]=pe):pe=t[120];let je;t[121]!==W||t[122]!==T||t[123]!==N||t[124]!==A||t[125]!==Y||t[126]!==c||t[127]!==K||t[128]!==u||t[129]!==Q||t[130]!==z||t[131]!==(d==null?void 0:d.cwd)||t[132]!==J||t[133]!==s?(je=!u&&r.jsx(yt,{open:J,children:r.jsxs(wt,{id:A,onClick:x7,children:[Y==="diff"&&K&&r.jsx(qm,{toolCall:s}),Y==="command"&&(z?r.jsx(Dm,{sections:z,description:W,cwd:d==null?void 0:d.cwd,expandAll:c}):s.name==="Bash"?r.jsx(Rm,{input:s.input}):r.jsx(Mm,{input:s.input})),(Y==="result"||Y==="command")&&Q,r.jsx("button",{type:"button",className:"mt-1 text-[10px] text-muted-foreground/50 transition-colors hover:text-muted-foreground","aria-expanded":N,"aria-controls":T,onClick:Te=>{Te.stopPropagation(),C(b7)},children:"input"}),r.jsx(yt,{open:N,children:r.jsx(wt,{id:T,children:r.jsx(gc,{result:JSON.stringify(s.input),expanded:!0})})})]})}),t[121]=W,t[122]=T,t[123]=N,t[124]=A,t[125]=Y,t[126]=c,t[127]=K,t[128]=u,t[129]=Q,t[130]=z,t[131]=d==null?void 0:d.cwd,t[132]=J,t[133]=s,t[134]=je):je=t[134];let _e;return t[135]!==le||t[136]!==he||t[137]!==ge||t[138]!==ce||t[139]!==ve||t[140]!==xe||t[141]!==pe||t[142]!==je||t[143]!==ae||t[144]!==te||t[145]!==me?(_e=r.jsxs("div",{className:ae,children:[te,me,le,he,ge,ce,ve,xe,pe,je]}),t[135]=le,t[136]=he,t[137]=ge,t[138]=ce,t[139]=ve,t[140]=xe,t[141]=pe,t[142]=je,t[143]=ae,t[144]=te,t[145]=me,t[146]=_e):_e=t[146],_e});function g7(n){return!n}function x7(n){return n.stopPropagation()}function b7(n){return!n}const v7=v.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,f]=v.useState(!0),u=o.some(j=>j.name==="AskUserQuestion"&&j.result===null),[m,p]=v.useState(null),h=v.useRef(u);v.useEffect(()=>{u&&(h.current=!0)},[u]);const g=i||d,x=i||(m??(u||h.current)),b=s==="approved"?ea:s==="rejected"?Ss:$s,w=g?Ze:Je,y=x?Ze:Je;return r.jsxs(yt,{open:g,onOpenChange:f,className:G("my-2 rounded-lg border",s==="approved"?"border-success/20 bg-success/5":s==="rejected"?"border-destructive/20 bg-destructive/5":"border-warning/20 bg-warning/5"),children:[r.jsxs(Jt,{render:r.jsx(Z,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[r.jsx(w,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(fy,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(b,{className:G("size-4",s==="approved"?"text-success":s==="rejected"?"text-destructive":"text-warning")}),r.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:s}),t&&r.jsx("span",{className:"ml-auto truncate font-mono text-xs text-muted-foreground",children:t})]}),r.jsx(wt,{children:r.jsxs("div",{className:"px-3 pb-2",children:[r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t pt-2",children:r.jsx(Rn,{remarkPlugins:[ca],components:Fn,children:e})}),o.length>0&&r.jsxs(yt,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs(Jt,{render:r.jsx(Z,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(y,{"data-icon":"inline-start"}),o.length," call",o.length===1?"":"s"," during planning"]}),r.jsx(wt,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(j=>r.jsx(S0,{toolCall:j,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},j.id))})})]})]})})]})}),y7=v.memo(function(e){const t=B.c(14),{content:s}=e,[o,i]=v.useState(!0),a=o?Ze:Je;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Z,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),t[0]=l):l=t[0];let c;t[1]!==a?(c=r.jsx(a,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[1]=a,t[2]=c):c=t[2];let d,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(my,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),f=r.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=d,t[4]=f):(d=t[3],f=t[4]);let u;t[5]!==c?(u=r.jsxs(Jt,{render:l,children:[c,d,f]}),t[5]=c,t[6]=u):u=t[6];let m;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=[ca],t[7]=m):m=t[7];let p;t[8]!==s?(p=r.jsx(wt,{children:r.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none border-t px-3 pb-2 pt-2",children:r.jsx(Rn,{remarkPlugins:m,components:Fn,children:s})})}),t[8]=s,t[9]=p):p=t[9];let h;return t[10]!==o||t[11]!==u||t[12]!==p?(h=r.jsxs(yt,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[u,p]}),t[10]=o,t[11]=u,t[12]=p,t[13]=h):h=t[13],h}),Sl=1;function Vm(n,e){return!e||n.length<=Sl?{visible:[...n],hidden:0}:{visible:n.slice(-Sl),hidden:n.length-Sl}}function w7(n){return`${n} earlier step${n===1?"":"s"}`}const j7=v.memo(function(e){const t=B.c(15),{blocks:s,expandAll:o}=e,[i,a]=v.useState(!1),l=o||i;if(s.length===0)return null;let c;t[0]!==o?(c=p=>{o||a(p)},t[0]=o,t[1]=c):c=t[1];let d;t[2]!==s.length||t[3]!==o||t[4]!==l?(d=!o&&r.jsxs(Jt,{render:r.jsx(Z,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),r.jsxs("span",{children:["Thinking... (",s.length," block",s.length>1?"s":"",")"]})]}),t[2]=s.length,t[3]=o,t[4]=l,t[5]=d):d=t[5];let f;t[6]!==s?(f=s.map(S7),t[6]=s,t[7]=f):f=t[7];let u;t[8]!==f?(u=r.jsx(wt,{className:"mt-1 flex flex-col gap-2",children:f}),t[8]=f,t[9]=u):u=t[9];let m;return t[10]!==l||t[11]!==c||t[12]!==d||t[13]!==u?(m=r.jsxs(yt,{open:l,onOpenChange:c,children:[d,u]}),t[10]=l,t[11]=c,t[12]=d,t[13]=u,t[14]=m):m=t[14],m});function S7(n,e){return r.jsx("pre",{className:"text-xs text-muted-foreground/70 font-mono whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:n.thinking},e)}function pr(n,e){if(!n&&!e)return{add:0,del:0};const t=n?n.split(`
|
|
110
|
+
`):[],s=e?e.split(`
|
|
111
|
+
`):[];if(t.length===0)return{add:s.length,del:0};if(s.length===0)return{add:0,del:t.length};const o=t.length,i=s.length;let a=0;for(;a<o&&a<i&&t[a]===s[a];)a++;let l=0;for(;l<o-a&&l<i-a&&t[o-1-l]===s[i-1-l];)l++;const c=o-a-l,d=i-a-l;if(c===0)return{add:d,del:0};if(d===0)return{add:0,del:c};let f=new Array(d+1).fill(0),u=new Array(d+1).fill(0);for(let p=1;p<=c;p++){u[0]=0;const h=t[a+p-1];for(let g=1;g<=d;g++)h===s[a+g-1]?u[g]=f[g-1]+1:u[g]=f[g]>u[g-1]?f[g]:u[g-1];[f,u]=[u,f]}const m=f[d];return{add:d-m,del:c-m}}function k7(n){let e=[];for(const a of n){if(a.isWrite){e=[{original:a.newString,current:a.newString}];continue}if(!a.oldString){e.push({original:a.oldString,current:a.newString});continue}let l=!1;for(const c of e){const d=c.current.indexOf(a.oldString);if(d!==-1){c.current=c.current.slice(0,d)+a.newString+c.current.slice(d+a.oldString.length),l=!0;break}}l||e.some(d=>d.original.includes(a.oldString)&&!d.current.includes(a.oldString))||e.push({original:a.oldString,current:a.newString})}const t=e.filter(a=>a.original!==a.current);if(t.length===0){if(n.some(l=>l.isWrite)&&e.length>0){const l=e.map(c=>c.current).join(`
|
|
112
|
+
`);if(l){const c=pr("",l);return{originalStr:"",currentStr:l,addCount:c.add,delCount:c.del}}}return{originalStr:"",currentStr:"",addCount:0,delCount:0}}const s=t.map(a=>a.original).join(`
|
|
113
|
+
`),o=t.map(a=>a.current).join(`
|
|
114
|
+
`),i=pr(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const N7=new Set(["echo","printf","true","false",":"]),C7=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),_7=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),T7=new Set(["ls","tree","du"]);function E7(n){return n.split(/\|\||&&|[|;\n]/).map(e=>e.trim()).filter(Boolean)}function P7(n){const e=E7(n);let t=!1,s=!1,o=!1,i=!1;for(const a of e){const l=a.split(/\s+/)[0];if(!(!l||N7.has(l)))if(i=!0,C7.has(l))t=!0;else if(_7.has(l))s=!0;else if(T7.has(l))o=!0;else return"shell"}return i?o?"list":t?"search":s?"read":"shell":"shell"}const A7=/[\\/]claude(?:-\d+)?[\\/](?:[^\\/]+[\\/])+scratchpad[\\/]/i;function R7(n){return A7.test(n)}const I7=new Set(["Grep","Glob"]),M7=new Set(["Bash","PowerShell"]),$7=new Set(["Edit","Write","NotebookEdit","MultiEdit"]),O7=new Set(["Task","Agent"]);function Gm(n){const e=n.file_path??n.path;return typeof e=="string"?e:null}function D7(n){return typeof n.command=="string"?n.command:null}function L7(n){if(!n.startsWith("mcp__"))return null;const e=n.split("__")[1];return e?e.replace(/^claude[._]ai[._]/i,"").replace(/_/g," "):null}function z7(n,e){if(Array.isArray(e.edits)){let i=0,a=0;for(const l of e.edits){if(!l||typeof l!="object")continue;const{old_string:c,new_string:d}=l,f=pr(typeof c=="string"?c:"",typeof d=="string"?d:"");i+=f.add,a+=f.del}return{added:i,removed:a}}const t=n==="Edit"&&typeof e.old_string=="string"?e.old_string:"",s=typeof e.new_string=="string"?e.new_string:typeof e.content=="string"?e.content:typeof e.new_source=="string"?e.new_source:"",o=pr(t,s);return{added:o.add,removed:o.del}}function Js(n,e,t=`${e}s`){return`${n} ${n===1?e:t}`}function F7(n){const e=Math.max(1,Math.floor(n/1e3));if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;if(t<60)return s>0?`${t}m ${s}s`:`${t}m`;const o=Math.floor(t/60),i=t%60;return i>0?`${o}h ${i}m`:`${o}h`}function B7(n,e={}){const t=new Set,s=new Set,o=new Set;let i=0,a=0,l=0,c=0,d=0,f=0,u=0,m=0,p=0,h=0,g=0,x=0;for(const k of n){const N=L7(k.name);if(N){p+=1,o.add(N);continue}if($7.has(k.name)){const C=Gm(k.input),S=z7(k.name,k.input);C&&R7(C)?(l+=1,c+=S.added,d+=S.removed):(t.add(C??k.id),i+=S.added,a+=S.removed);continue}if(k.name==="Read"){const C=Gm(k.input);C?s.add(C):u+=1;continue}if(I7.has(k.name)){f+=1;continue}if(M7.has(k.name)){const C=D7(k.input);switch(C===null?"shell":P7(C)){case"search":f+=1;break;case"list":m+=1;break;case"read":u+=1;break;default:x+=1}continue}if(O7.has(k.name)){h+=1;continue}g+=1}const b=s.size>0?s.size:u,w=[],y=(k,N,C=0,S=0)=>{w.push(C>0||S>0?{key:k,text:N,added:C,removed:S}:{key:k,text:N})},j=e.thoughtForMs??0;if(j>0&&y("thought",`thought for ${F7(j)}`),t.size>0&&y("edit",`edited ${Js(t.size,"file")}`,i,a),l>0&&y("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),f>0&&y("search",`searched for ${Js(f,"pattern")}`),b>0&&y("read",`read ${Js(b,"file")}`),m>0&&y("list",`listed ${Js(m,"directory","directories")}`),p>0){const k=[...o].join(", ")||"MCP";y("mcp",p>1?`called ${k} ${p} times`:`called ${k}`)}return h>0&&y("agent",`ran ${Js(h,"agent")}`),g>0&&y("other",`called ${Js(g,"tool")}`),x>0&&y("bash",`ran ${x} shell ${x===1?"command":"commands"}`),{clauses:w}}const Ym="text-muted-foreground";function Xm(n){const e=B.c(4),{summary:t}=n;let s;e[0]!==t.clauses?(s=t.clauses.map(U7),e[0]=t.clauses,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3],o}function U7(n,e){return r.jsxs("span",{children:[e>0&&", ",e===0?n.text[0].toUpperCase()+n.text.slice(1):n.text,n.added?r.jsxs("span",{className:"text-success",children:[" +",n.added]}):null,n.removed?r.jsxs("span",{className:"text-destructive",children:[" -",n.removed]}):null]},n.key)}const Jm=v.memo(function(e){const t=B.c(35),{toolCalls:s,expandAll:o,expandToolPayloads:i,activeToolCallId:a,isAgentActive:l,activityItems:c,thinkingCount:d,thoughtForMs:f,skillMetadata:u}=e,m=l===void 0?!1:l,p=d===void 0?0:d,h=f===void 0?0:f,[g,x]=v.useState(null),b=v.useRef(null),w=m&&s.some(W7);let y;t[0]!==s?(y=s.some(H7),t[0]=s,t[1]=y):y=t[1];const j=y,k=o||j||(g??w),N=g===null&&w&&!o&&!j,C=v.useRef(null),S=v.useRef(null);let _,P;t[2]!==a||t[3]!==s?(_=()=>{if(!a){C.current=null;return}a!==C.current&&s.some(W=>W.id===a)&&(C.current=a,x(!0),S.current=requestAnimationFrame(()=>{S.current=requestAnimationFrame(()=>{var W;S.current=null,(W=b.current)==null||W.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},P=[a,s],t[2]=a,t[3]=s,t[4]=_,t[5]=P):(_=t[4],P=t[5]),v.useEffect(_,P);let A,T;t[6]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{S.current!==null&&cancelAnimationFrame(S.current)},T=[],t[6]=A,t[7]=T):(A=t[6],T=t[7]),v.useEffect(A,T);let E;if(t[8]!==s){const W=new Map;for(const q of s){const{label:V,styleName:Y}=$a(q),K=W.get(V);K?(K.count=K.count+1,K.hasError=K.hasError||!!q.isError):W.set(V,{count:1,styleName:Y,hasError:!!q.isError})}E=[...W].sort(K7),t[8]=s,t[9]=E}else E=t[9];const R=E;let M;t[10]!==h||t[11]!==s?(M=B7(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=M):M=t[12];const I=M,D=function(q,V){const Y=m&&V&&q.result===null;return r.jsx("div",{ref:q.id===a?b:void 0,className:G(q.id===a&&"rounded-md ring-1 ring-ring"),children:r.jsx(S0,{toolCall:q,expandAll:o,expandToolPayloads:i,isAgentActive:Y,skillMetadata:u})},q.id)};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:D(s[0],!0)});if(k){let W;t[13]!==o||t[14]!==j||t[15]!==I||t[16]!==p?(W=!o&&!j&&r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(Ze,{"data-icon":"inline-start"}),I.clauses.length>0?r.jsx(Xm,{summary:I}):r.jsxs("span",{className:G("font-mono text-xs",Ym),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=j,t[15]=I,t[16]=p,t[17]=W):W=t[17];const q=c?(()=>{const Y=Vm(c,N);return r.jsxs(r.Fragment,{children:[Y.hidden>0&&r.jsx(Qm,{count:Y.hidden,onReveal:()=>x(!0)}),Y.visible.map((K,X)=>{if(K.kind==="thinking")return r.jsx(j7,{blocks:K.blocks,expandAll:!1},`thinking-${X}`);const Q=X===Y.visible.length-1;return K.toolCalls.map((J,ee)=>D(J,Q&&ee===K.toolCalls.length-1))})]})})():(()=>{const Y=Vm(s,N);return r.jsxs(r.Fragment,{children:[Y.hidden>0&&r.jsx(Qm,{count:Y.hidden,onReveal:()=>x(!0)}),Y.visible.map((K,X)=>D(K,X===Y.visible.length-1))]})})();let V;return t[18]!==W||t[19]!==q?(V=r.jsxs("div",{className:"motion-enter flex flex-col gap-2",children:[W,q]}),t[18]=W,t[19]=q,t[20]=V):V=t[20],V}let O;t[21]===Symbol.for("react.memo_cache_sentinel")?(O=()=>x(!0),t[21]=O):O=t[21];let $;t[22]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Je,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[22]=$):$=t[22];let L;t[23]!==I?(L=I.clauses.length>0&&r.jsx(Xm,{summary:I}),t[23]=I,t[24]=L):L=t[24];let F;t[25]!==p?(F=p>0&&r.jsxs("span",{className:G("font-mono text-xs",Ym),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=F):F=t[26];let z;t[27]!==R?(z=R.map(q7),t[27]=R,t[28]=z):z=t[28];let H;t[29]!==F||t[30]!==z?(H=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[F,z]}),t[29]=F,t[30]=z,t[31]=H):H=t[31];let U;return t[32]!==L||t[33]!==H?(U=r.jsxs(Z,{type:"button",variant:"ghost",onClick:O,className:"motion-enter h-auto w-full items-start justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[$,r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[L,H]})]}),t[32]=L,t[33]=H,t[34]=U):U=t[34],U});function Qm(n){const e=B.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Ze,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=w7(t),e[1]=t,e[2]=i):i=e[2];let a;return e[3]!==s||e[4]!==i?(a=r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:s,className:"-ml-2 text-muted-foreground",children:[o,i]}),e[3]=s,e[4]=i,e[5]=a):a=e[5],a}function W7(n){return n.result===null}function H7(n){return n.name==="AskUserQuestion"}function K7(n,e){return e[1].count-n[1].count}function q7(n){const[e,t]=n,{count:s,styleName:o,hasError:i}=t;return r.jsxs("span",{className:G("font-mono text-xs",y0(o,i)),children:[e,s>1?` ×${s}`:""]},e)}function V7(n){const e=B.c(15),{label:t,expanded:s,onToggle:o,compact:i}=n,l=(i===void 0?!1:i)&&"min-h-9";let c;e[0]!==l?(c=G("group/fold h-auto min-h-8 w-full cursor-pointer justify-start gap-1.5 px-1 text-left text-xs font-normal text-muted-foreground",l),e[0]=l,e[1]=c):c=e[1];const d=s&&"rotate-90";let f;e[2]!==d?(f=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",d),e[2]=d,e[3]=f):f=e[3];let u;e[4]!==f?(u=r.jsx(Je,{"data-icon":"inline-start",className:f}),e[4]=f,e[5]=u):u=e[5];let m;e[6]!==t?(m=r.jsx("span",{className:"tabular-nums",children:t}),e[6]=t,e[7]=m):m=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/fold:bg-border/70"}),e[8]=p):p=e[8];let h;return e[9]!==s||e[10]!==o||e[11]!==c||e[12]!==u||e[13]!==m?(h=r.jsxs(Z,{type:"button",variant:"ghost",onClick:o,"aria-expanded":s,className:c,children:[u,m,p]}),e[9]=s,e[10]=o,e[11]=c,e[12]=u,e[13]=m,e[14]=h):h=e[14],h}const k0="synthesizedFrom",Zm=/[.*+?[\]{}()^$|]/,G7=/[$*?`~]|\\\s/,N0=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,Y7=new RegExp(N0,"g");function Bd(n,e,t,s){return{id:e,name:t,input:{...s,[k0]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function X7(n){return typeof n.input[k0]=="string"}function J7(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function ep(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function Oa(n,e){const t=J7(n.trim());return!t||G7.test(t)?null:t.startsWith("/")?ep(t):e?ep(`${e}/${t}`):null}function Q7(n){const e=[];let t="",s=null;function o(i){t.trim()&&e.push({text:t.trim(),piped:i}),t=""}for(let i=0;i<n.length;i++){const a=n[i];if(s){t+=a,a===s&&(s=null);continue}if(a==='"'||a==="'"){s=a,t+=a;continue}if(a==="|"){o(!0),n[i+1]==="|"&&i++;continue}if(a===";"||a==="&"&&n[i+1]==="&"){o(!1),a==="&"&&i++;continue}t+=a}return o(!1),e}function Z7(n){const e=n.split(`
|
|
115
|
+
`),t=[];let s=0;for(;s<e.length;){const o=e[s];s++;const i=new Map;for(const a of o.matchAll(Y7)){const[,l,c,d]=a,f=c??d,u=[];for(;s<e.length&&e[s].trim()!==f;)u.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,i.set(f,u.join(`
|
|
116
|
+
`)))}for(const a of Q7(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function e8(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?Oa(t[1]??t[2]??t[3]??"",e):null}function t8(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 n8(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(N0);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=t8(n.text);if(!o)return null;const i=Oa(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function tp(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==="|"||!Zm.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&Zm.test(i))return null;s+=i}return s}const s8=/^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 o8(n,e){var m;const t=(m=n.text.match(s8))==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=tp(s,"pattern"),f=tp(o,"replacement");if(!d||f===null)return null;const u=Oa(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 C0(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of Z7(t)){const a=e8(i.text,o);if(a){o=a;continue}const l=n8(i,o)??o8(i,o);l&&s.push(Bd(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function _0(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=Oa(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(Bd(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:f===!0}))}return i}function T0(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?U1("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Bd(n,s.id,s.name,s.input)):[]}function Jo(n,e=null){const t=[];for(const s of n)s.isError||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(..._0(s,e)):s.name==="Bash"?t.push(...C0(s,e)):s.name==="apply_patch"&&t.push(...T0(s,e)));return t}function Ui(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&_0(t,e).length>0||t.name==="Bash"&&C0(t,e).length>0||t.name==="apply_patch"&&T0(t,e).length>0))return!0;return!1}const r8=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"]),i8={json:of,jsonc:of,md:bi,mdx:bi,txt:bi,png:_s,jpg:_s,jpeg:_s,gif:_s,webp:_s,svg:_s,ico:_s,sh:Xr,bash:Xr,zsh:Xr,fish:Xr};function E0(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function a8(n){const e=E0(n);return i8[e]??(r8.has(e)?wr:kh)}function xc(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 np=5;function Ud(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*np);i=np-f,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:f},c8),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},l8),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 l8(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function c8(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const Wi="cogpit:open-subagent";function P0(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 Wd(n){const e=B.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=r.jsx(Z,{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(Wi,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const A0=v.memo(function(e){const t=B.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=Ox(),[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=_e=>{f(_e),_e?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=E0(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(m8),t[9]=s.edits,t[10]=_):_=t[10];const A=a==="per-edit"?_:S,T=u&&c&&A,[E,R]=v.useState(0);let M;t[11]===Symbol.for("react.memo_cache_sentinel")?(M=_e=>{if(!_e)return;const Re=_e.offsetHeight;R(De=>De===Re?De:Re)},t[11]=M):M=t[11];const I=M,D=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,O=s.filePath,$=i?"border-ring ring-2 ring-ring/20":"border-border";let L;t[12]!==$?(L=G("rounded-lg border bg-card transition-colors",$),t[12]=$,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(Ze,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(Je,{"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 q;t[24]!==U||t[25]!==W?(q=r.jsx(P0,{hasEdit:U,hasWrite:W}),t[24]=U,t[25]=W,t[26]=q):q=t[26];let V;t[27]!==s.shortPath?(V=r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=V):V=t[28];let Y;t[29]!==D?(Y=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:D}),t[29]=D,t[30]=Y):Y=t[30];let K;t[31]!==s.editCount?(K=s.editCount>1&&r.jsxs(Ee,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=K):K=t[32];let X;t[33]!==d||t[34]!==F||t[35]!==z||t[36]!==H||t[37]!==q||t[38]!==V||t[39]!==Y||t[40]!==K?(X=r.jsxs(Z,{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,q,V,Y,K]}),t[33]=d,t[34]=F,t[35]=z,t[36]=H,t[37]=q,t[38]=V,t[39]=Y,t[40]=K,t[41]=X):X=t[41];let Q;t[42]!==s.subAgentId?(Q=s.subAgentId&&r.jsx(Wd,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=Q):Q=t[43];let J;t[44]!==s.filePath?(J=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>ir(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=J):J=t[45];let ee;t[46]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx(br,{"data-icon":"inline-start"}),t[46]=ee):ee=t[46];let oe;t[47]!==J?(oe=r.jsx(Tt,{render:J,children:ee}),t[47]=J,t[48]=oe):oe=t[48];let se;t[49]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(Et,{children:"Open in editor"}),t[49]=se):se=t[49];let re;t[50]!==oe?(re=r.jsxs(_t,{children:[oe,se]}),t[50]=oe,t[51]=re):re=t[51];let ie;t[52]!==s.filePath?(ie=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>ir(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(py,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let te;t[55]!==ie?(te=r.jsx(Tt,{render:ie,children:ae}),t[55]=ie,t[56]=te):te=t[56];let me;t[57]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx(Et,{children:"View git diff"}),t[57]=me):me=t[57];let de;t[58]!==te?(de=r.jsxs(_t,{children:[te,me]}),t[58]=te,t[59]=de):de=t[59];let le;t[60]!==re||t[61]!==de?(le=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[re,de]}),t[60]=re,t[61]=de,t[62]=le):le=t[62];let he;t[63]!==s.addCount?(he=s.addCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",s.addCount]}),t[63]=s.addCount,t[64]=he):he=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(Ud,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=ce):ce=t[69];let ve;t[70]!==Q||t[71]!==le||t[72]!==he||t[73]!==ge||t[74]!==ce?(ve=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Q,le,he,ge,ce]}),t[70]=Q,t[71]=le,t[72]=he,t[73]=ge,t[74]=ce,t[75]=ve):ve=t[75];let xe;t[76]!==X||t[77]!==ve?(xe=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:[X,ve]}),t[76]=X,t[77]=ve,t[78]=xe):xe=t[78];let pe;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?(pe=r.jsx(d8,{showDiff:T,open:d,hasDiff:A,diffRef:I,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]=pe):pe=t[89];let je;return t[90]!==s.filePath||t[91]!==l||t[92]!==L||t[93]!==xe||t[94]!==pe?(je=r.jsxs("div",{ref:l,"data-file-path":O,className:L,children:[xe,pe]}),t[90]=s.filePath,t[91]=l,t[92]=L,t[93]=xe,t[94]=pe,t[95]=je):je=t[95],je}),d8=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(f8,{edits:m,filePath:f}):r.jsx(Dd,{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}),sp=3,u8=5,f8=v.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(p8),l=a.length>sp,[c,d]=v.useState(l?sp:a.length);v.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(b=>Math.min(b+u8,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(Wd,{agentId:x.agentId})]}),r.jsx(Dd,{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 m8(n){return!!(n.oldString||n.newString)}function p8(n){return!!(n.oldString||n.newString)}const kl=new Map;function h8(n){var j;const e=bn("hostFiles"),{sessionSource:t}=it(),s=t==null?void 0:t.dirName,o=Ct(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 _=Ft(`${s}/${n.sessionId}/${S}`);if(!u.current.has(_)){if(kl.has(_)){f(P=>{const A=new Map(P);return A.set(S,kl.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(),M=Qx(E,_).flatMap(I=>Jo(I.toolCalls,n.cwd));kl.set(P,M),u.current.add(P),S.set(_,M)}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 Jo(S.toolCalls,n.cwd))k.push({turnIndex:C,toolCall:_});for(const _ of S.subAgentActivity){for(const P of Jo(_.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=R0(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(()=>Hi(m,"all",h),[m,h]),w=v.useMemo(()=>Hi(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 op(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]===`
|
|
117
|
+
`&&s++;return s}function R0(n){return String(n.input.file_path??n.input.path??"")}function g8(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 Hi(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=R0(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=g8(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:op(h,y.newString||y.oldString)})}const g=k7(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?op(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 x8(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=Hi(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 hr="cogpit:focus-file",b8="cogpit:file-changes-prefs",v8={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function y8(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(Wi,{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(Z,{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(Ee,{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(A0,{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 w8=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]=Dr(b8,{}),g={...v8,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[y,j]=v.useState(g.scope),k=v.useCallback(K=>{h(X=>({...X,expanded:K}))},[h]),N=v.useCallback(K=>{h(X=>({...X,diffMode:K}))},[h]),C=v.useCallback(K=>{h(X=>({...X,groupByAgent:K}))},[h]);v.useEffect(()=>{typeof y!="number"&&h(K=>({...K,scope:y}))},[y,h]);const[S,_]=v.useState(null),P=v.useRef(null),{fileChanges:A,fileContents:T,groupedByFile:E,groupedLastTurn:R,lastTurnIndex:M,agentMap:I}=h8(e),D=v.useMemo(()=>typeof y!="number"?null:Hi(A,y,T),[A,y,T]);function O(){return typeof y=="number"?D??[]:y==="all"?E:R}const $=O(),L=v.useMemo(()=>w?x8(A,typeof y=="number"?y:y==="all"?"all":M,I,T):[],[w,A,y,M,I,T]);v.useEffect(()=>{const K=X=>{const Q=X.detail;Q!=null&&Q.filePath&&(j(Q.turnIndex),_(Q.filePath),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>_(null),3e3),requestAnimationFrame(()=>{var ee;const J=(ee=s.current)==null?void 0:ee.querySelector(`[data-file-path="${CSS.escape(Q.filePath)}"]`);J==null||J.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(hr,K),()=>{window.removeEventListener(hr,K),P.current&&clearTimeout(P.current)}},[]);const F=v.useCallback(()=>{const K=s.current;K&&(f(K.scrollTop>10),m(K.scrollHeight-K.scrollTop-K.clientHeight>10))},[]),z=v.useCallback(()=>{const K=s.current;K&&(i.current=K.scrollHeight-K.scrollTop-K.clientHeight<50,F())},[F]);if(v.useEffect(()=>{F()},[A.length,$.length,F]),v.useEffect(()=>{const K=s.current;K&&(K.scrollTop=K.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 K=e.turns.length;K>c.current&&(a.current=!0),c.current=K},[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 K;(K=o.current)==null||K.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[A.length]),A.length===0)return null;let H=0,U=0,W=0;if(w)for(const K of L)H+=K.totalAdd,U+=K.totalDel,W+=K.files.length;else{for(const K of $)H+=K.addCount,U+=K.delCount;W=$.length}function q(){j(y==="last"?"all":"last")}function V(){return typeof y=="number"?`Turn ${y+1}`:y==="all"?"All turns":`Last turn (T${M+1})`}const Y=V();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(wr,{"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(Ee,{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(_t,{children:[r.jsx(Tt,{render:r.jsx(Z,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(Yn,{"data-icon":"inline-start"})}),r.jsx(Et,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(_t,{children:[r.jsx(Tt,{render:r.jsx(Z,{variant:y==="all"?"secondary":"ghost",size:"icon-xs",onClick:q,"aria-label":y==="last"?"Show all turns":"Show last turn only"}),children:y==="all"?r.jsx(Th,{"data-icon":"inline-start"}):r.jsx($s,{"data-icon":"inline-start"})}),r.jsx(Et,{children:y==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(_t,{children:[r.jsx(Tt,{render:r.jsx(Z,{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(hy,{"data-icon":"inline-start"}):r.jsx(gy,{"data-icon":"inline-start"})}),r.jsx(Et,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(_t,{children:[r.jsx(Tt,{render:r.jsx(Z,{variant:"ghost",size:"icon-xs",onClick:()=>k(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(ia,{"data-icon":"inline-start"}):r.jsx(ra,{"data-icon":"inline-start"})}),r.jsx(Et,{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"&&M>0&&r.jsx(Z,{variant:"ghost",size:"icon-xs",onClick:()=>{const K=typeof y=="number"?y:M;K>0&&j(K-1)},disabled:(typeof y=="number"?y:M)<=0,"aria-label":"Previous turn",children:r.jsx(zc,{"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"&&M>0&&r.jsx(Z,{variant:"ghost",size:"icon-xs",onClick:()=>{j(K=>typeof K!="number"?K:K+1>=M?"last":K+1)},disabled:y==="last","aria-label":"Next turn",children:r.jsx(Je,{"data-icon":"inline-start"})}),typeof y=="number"&&r.jsx(Z,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:r.jsx(Nt,{"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(K=>r.jsx(y8,{group:K,allExpanded:x,highlightPath:S,diffMode:b},K.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):$.length>0?$.map(K=>r.jsx(A0,{file:K,defaultOpen:x,isHighlighted:S===K.filePath,diffMode:b},K.filePath)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",Y.toLowerCase()]})}),r.jsx("div",{ref:o})]}),r.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-background to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")})]})]})});function j8(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=pr(c,d),u=t.get(a)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};u.add+=f.add,u.del+=f.del,l?u.hasEdit=!0:u.hasWrite=!0,i&&(u.subAgentId=i),t.set(a,u)}return Jo(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>Jo(o.toolCalls,e).forEach(i=>s(i,o.agentId))),[...t.entries()].map(([o,{add:i,del:a,hasEdit:l,hasWrite:c,subAgentId:d}])=>({filePath:o,additions:i,deletions:a,hasEdit:l,hasWrite:c,subAgentId:d}))}function rp(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function S8(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=rp();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=rp(),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 k8=v.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=bn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=j8(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=S8(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 R of c)p=p+R.additions,h=h+R.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(Je,{"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(wr,{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(xc,{add:x.add,del:x.del,className:"opacity-80"}),S=r.jsx(Ud,{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(Jt,{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 R;t[36]!==a||t[37]!==o?(R=M=>r.jsx(N8,{node:M,depth:0,turnIndex:o,canFocusFiles:a},M.fullPath),t[36]=a,t[37]=o,t[38]=R):R=t[38],A=f.map(R),t[32]=a,t[33]=f,t[34]=o,t[35]=A}else A=t[35];let T;t[39]!==A?(T=r.jsx(wt,{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(yt,{open:u,onOpenChange:m,children:[P,T]}),t[41]=u,t[42]=P,t[43]=T,t[44]=E):E=t[44],E}),N8=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=a8(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(hr,{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(Z,{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(P0,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Wd,{agentId:e.subAgentId}),r.jsx(xc,{add:e.additions,del:e.deletions}),r.jsx(Ud,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(Z,{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(Ze,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(xy,{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(xc,{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 C8(n){const e=B.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let o;e[0]!==s?(o=r.jsx(Z,{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(Bc,{"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(Tt,{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(Et,{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(_t,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function I0(n){return ax(n).status(n)}const _8=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Hd(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 zr(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&_8.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?Hd(t):"Done";default:return null}}function T8(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(vy,{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(No,{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(by,{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(ia,{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(mo,{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(Pn,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const ip=2e3,M0=600;function $0(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:`${M0}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(T8,{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(Kd,{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(`
|
|
118
|
+
`),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 E8(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"),ip),g=setTimeout(()=>i("ready"),ip+M0);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(Pn,{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?Hd(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=zr(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($0,{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 P8=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 R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={status:"compacting"},e[0]=R):R=e[0],h=R;break e}const T=t.rawMessages;let E;e[1]!==T?(E=I0(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=qc(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(Eh,{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 R;return e[11]!==E?(R=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]=R):R=e[12],R}if(!y)return null;if(j){let T;return e[13]!==y||e[14]!==C?(T=r.jsx(E8,{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=zr(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($0,{status:y,label:_,startTimestamp:P})}),e[21]=y,e[22]=_,e[23]=P,e[24]=A):A=e[24],A});function Kd(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(A8,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function A8(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 R8(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 I8=6e5;function M8(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,I8)}function ap(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+=M8(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 bc=new Map,$8=300*1e3;function lp(n){const e=bc.get(n);return e?Date.now()>e.expiresAt?(bc.delete(n),null):e.data:null}function O8(n,e){bc.set(n,{data:e,expiresAt:Date.now()+$8})}function D8(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?lp(Ft(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||ya(window.location.pathname))return;const c=Ft(n),d=lp(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});O8(c,p),o(p)}).catch(L8),()=>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 L8(){}const z8=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),F8=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),B8=new Set(["AskUserQuestion","ExitPlanMode"]),U8=new Set(["text","thinking","tool_calls"]);function W8(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>B8.has(e.name)&&e.result==null)}function H8(n){for(let e=n.length-1;e>=0;e--){if(W8(n[e]))return e;if(U8.has(n[e].kind))return-1}return-1}const ci={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function K8(n,e="settled"){if(n.length===0||!n.some(a=>F8.has(a.kind)))return ci;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 ci}const s=H8(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];z8.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?ci:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function q8(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",cp="border-l border-border/40",dp="border-l border-border";function D0(n){const e=B.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=Ot(),{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}=I0(m.rawMessages);_=Rd.has(P),e[0]=m.rawMessages,e[1]=_}else _=e[1];y=!_}const j=(m==null?void 0:m.cwd)??"",k=D8(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(G8,{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 V8(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=q8(qc(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(Kd,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const G8=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}=Ox(),j=v.useRef(null),k=v.useRef(0);v.useLayoutEffect(()=>{y&&j.current&&(k.current=j.current.offsetHeight)},[y]);const N=Ui(e.toolCalls,m)||e.subAgentActivity.some(R=>Ui(R.toolCalls,m)),C=f?"settled":"working",S=v.useMemo(()=>K8(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 R=S.foldAnchorIndex,M=new Set(S.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,R),trailingBlocks:e.contentBlocks.slice(R).filter((I,D)=>A||!M.has(R+D))}},[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(X8,{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(Td,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b,compact:u})}),S.foldable?r.jsxs(r.Fragment,{children:[T.length>0&&r.jsx(Nl,{blocks:T,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),r.jsx(V7,{label:r.jsx(V8,{turn:e,isTurnDone:f,hiddenToolCalls:S.hiddenToolCalls}),expanded:A,onToggle:()=>P(!A),compact:u}),E.length>0&&r.jsx(Nl,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p})]}):r.jsx(Nl,{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(k8,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:k.current||Y8(e)}})]})});function Y8(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function X8(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?qc(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(J8,{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(Z,{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(Uc,{"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(C8,{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 J8(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($s,{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($s,{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(Kd,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function Q8(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 Nl(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=Q8(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}=ap(t,w),_=j.length===1&&j[0].kind==="tool_calls";p.push(r.jsx("div",{className:G(cp,h),children:r.jsx(Jm,{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}=ap(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(q_,{text:_,model:s,effort:o,timestamp:y.timestamp,compact:f},P))}),(k.length>0||N>0)&&r.jsx("div",{className:G("mt-1.5",cp,h),children:r.jsx(Jm,{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(Ee,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(Td,{content:y.content,timestamp:y.timestamp??"",compact:f})]},b(y,w))),w++;continue}if(y.kind==="agent_message"){p.push(r.jsx(W_,{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(dp,h),children:r.jsx(u6,{messages:y.messages,expandAll:i})},b(y,w))),w++;continue}if(y.kind==="background_agent"){p.push(r.jsx("div",{className:G(dp,h),children:r.jsx(f6,{messages:y.messages,expandAll:i})},b(y,w))),w++;continue}if(y.kind==="hook_event"){p.push(r.jsx(p6,{events:y.events},b(y,w))),w++;continue}if(y.kind==="plan_mode"){p.push(r.jsx(v7,{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(y7,{content:y.content,timestamp:y.timestamp},b(y,w))),w++;continue}if(y.kind==="task_notification"){p.push(r.jsx(LC,{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 Z8(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${tt(n.preTokens)} → ${tt(n.postTokens)}`:`${e} · ${tt(n.preTokens)}`}const eE=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=Z8(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(Ze,{className:"size-3","data-icon":"inline-start"}):r.jsx(Je,{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(yy,{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(Z,{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(Jt,{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=[ca],t[23]=k):k=t[23];let N;t[24]!==f?(N=r.jsx(wt,{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(Rn,{remarkPlugins:k,components:Fn,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(yt,{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}),tE=1.5;function nE(n,e){return e<=0?!1:n<e*tE}function sE(n,e){return n===0&&!e}function oE(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function rE(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const iE=1e3;function aE(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)<=iE?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function L0(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&&rE(i,t)?[...o.slice(0,-1),cE(a,i),...n.slice(1)]:[...o,...n];return bd(aE(l))}function lE(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 cE(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:lE(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function dE(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(b_,{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 uE(){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(v_,{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(D0,{turn:p,index:d+h}),c&&r.jsxs(Z,{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(wy,{"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 fE(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 mE(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function pE({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Ot(),{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(()=>oE(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=()=>{nE(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(fE,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(x_,{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(dE,{index:j,children:r.jsxs("div",{children:[(y.compactionSummary||y.compactionMeta)&&r.jsx(eE,{summary:y.compactionSummary,meta:y.compactionMeta}),!mE(y)&&r.jsx(D0,{turn:y,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]})})},k))})}),r.jsx(uE,{})]})}const hE=v.memo(function(e){const t=B.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=Ot(),{searchQuery:d,sessionChangeKey:f}=c,{session:u}=it(),m=u==null?void 0:u.turns;let p;t[0]!==m?(p=m?m.map(gE):[],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 R8(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:sE(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(hC,{children:w?r.jsx(In,{className:"min-h-64 border-0",children:r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:d?r.jsx(jy,{}):r.jsx(Ph,{})}),r.jsx($n,{children:d?"No matching turns":"No conversation yet"}),r.jsx(On,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(pE,{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 gE(n,e){return{turn:n,index:e}}const xE="[data-turn-index]",z0="[data-turn-prompt]",up=1,bE=120,fp=180;function vE(n){if(!n.userMessage)return null;const e=Pa(n.userMessage),{body:t}=cr(e),{remainingText:s}=ur(t),o=_d(s);if(!o){const a=xx(e);if(!a)return null;const l=bx(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
|
|
119
|
+
`)[0];return i.length>fp?`${i.slice(0,fp)}...`:i}function yE(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=vE(s);if(o)return{index:t,text:o}}return null}function wE(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(xE)){const c=l.getBoundingClientRect().top;if(c>e+up)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(z0);return(i?i.getBoundingClientRect().bottom>e+up:s+bE>e)?null:o}const jE=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=wE(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=yE(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(z0))??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(Ph,{"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(vr,{"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(Z,{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 SE(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(mp,{}),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(Jx,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(mp,{}),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 mp(){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 kE=v.memo(function(){const e=B.c(9),t=Md();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=J_(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(NE,-1);return r.jsx("div",{children:f.blocks.map((p,h)=>r.jsx(SE,{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 NE(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const CE=3,Ki=["w-6","w-4","w-2.5","w-2"],_E=Ki[Ki.length-1];function TE(n){return n===null||n<0?_E:Ki[Math.min(n,Ki.length-1)]}function EE(n){return n.type==="text"}function Cl(n){return n.replace(/\s+/g," ").trim()}function PE(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(EE).map(l=>l.text).join(" "):"",{text:t}=wx(e),{remainingText:s}=ur(t),{remainingText:o}=yx(s),i=Cl(_d(o));if(i)return i;for(const l of n.contentBlocks){if(l.kind!=="task_notification")continue;const c=ur(l.content).notifications.map(d=>d.summary).find(Boolean);if(c)return Cl(c)}return n.assistantText.map(Cl).find(Boolean)||"Untitled turn"}const AE=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<CE)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=PE(k);return r.jsx(Z,{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",TE(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 RE extends v.Component{constructor(t){super(t);Yr(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(St,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(yn,{}),r.jsx(It,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(kt,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(ys,{className:"static col-start-2 mt-2",children:r.jsxs(Z,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Wt,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const pp="find-in-session-highlight",_l="find-in-session-active";function IE(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 ME=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.${pp}`).forEach($E)},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=IE(re),ae=se.toLowerCase(),te=[];for(const me of ie){const de=me.nodeValue||"",le=de.toLowerCase();let he=0;const ge=[];for(;;){const pe=le.indexOf(ae,he);if(pe===-1)break;ge.push(pe),he=pe+1}if(ge.length===0)continue;const ce=me.parentNode;if(!ce)continue;const ve=document.createDocumentFragment();let xe=0;for(const pe of ge){pe>xe&&ve.appendChild(document.createTextNode(de.slice(xe,pe)));const je=document.createElement("mark");je.className=pp,je.textContent=de.slice(pe,pe+se.length),ve.appendChild(je),te.push(je),xe=pe+se.length}xe<de.length&&ve.appendChild(document.createTextNode(de.slice(xe))),ce.replaceChild(ve,me)}u(te),te.length>0?(p(0),te[0].classList.add(_l),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(_l);const re=(se%f.length+f.length)%f.length;f[re].classList.add(_l),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 R=E;if(!i)return null;let M;s[26]===Symbol.for("react.memo_cache_sentinel")?(M=se=>c(se.target.value),s[26]=M):M=s[26];let I;s[27]!==R||s[28]!==l?(I=r.jsx(ss,{ref:h,value:l,onChange:M,onKeyDown:R,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=R,s[28]=l,s[29]=I):I=s[29];const D=l?f.length>0?`${m+1}/${f.length}`:"0/0":"";let O;s[30]!==D?(O=r.jsx(vn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:D})}),s[30]=D,s[31]=O):O=s[31];let $;s[32]!==I||s[33]!==O?($=r.jsxs(ns,{className:"w-64",children:[I,O]}),s[32]=I,s[33]=O,s[34]=$):$=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(vr,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let W;s[41]!==L||s[42]!==F||s[43]!==H?(W=r.jsx(Z,{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 q;s[45]!==m||s[46]!==j?(q=()=>j(m+1),s[45]=m,s[46]=j,s[47]=q):q=s[47];const V=f.length===0,Y=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let K;s[48]!==Y?(K=G("text-muted-foreground",Y),s[48]=Y,s[49]=K):K=s[49];let X;s[50]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(Ze,{"data-icon":"inline-start"}),s[50]=X):X=s[50];let Q;s[51]!==q||s[52]!==V||s[53]!==K?(Q=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:q,disabled:V,className:K,"aria-label":"Next match",children:X}),s[51]=q,s[52]=V,s[53]=K,s[54]=Q):Q=s[54];let J;s[55]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(Nt,{"data-icon":"inline-start"}),s[55]=J):J=s[55];let ee;s[56]!==N?(ee=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:N,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:J}),s[56]=N,s[57]=ee):ee=s[57];let oe;return s[58]!==$||s[59]!==W||s[60]!==Q||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:[$,W,Q,ee]}),s[58]=$,s[59]=W,s[60]=Q,s[61]=ee,s[62]=oe):oe=s[62],oe});function $E(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const RO=["General","View","Tools"],Da=[{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}}],F0="cogpit-keybindings";let Es=null;function B0(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function gr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function OE(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function qd(){if(Es)return Es;try{const n=localStorage.getItem(F0);if(!n)return Es={};const e=JSON.parse(n);if(!e||typeof e!="object")return Es={};const t={};for(const s of Da){const o=e[s.command];OE(o)&&(t[s.command]=o)}return Es=t}catch{return Es={}}}function Vd(n){Es=n;try{localStorage.setItem(F0,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Fr(n){const e=Da.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return qd()[n]??e.defaultShortcut}function IO(){return Object.fromEntries(Da.map(n=>[n.command,Fr(n.command)]))}function MO(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:gr(e.key)};Vd({...qd(),[n]:t})}function $O(n){const e={...qd()};delete e[n],Vd(e)}function OO(){Vd({})}function DO(n){return{key:gr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function U0(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function vt(n,e){const t=Fr(n);return"doubleTapModifier"in t||gr(e.key)!==gr(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 Qs(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 DE(n){const e=B0();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Qs(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Qs(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Qs(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Qs(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Qs(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Qs(n.key)].filter(Boolean).join("+")}function Tl(n){return DE(Fr(n))}function hp(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${gr(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 LO(n,e){const t=new Set(hp(n));return Da.find(s=>s.command!==e&&hp(Fr(s.command)).some(o=>t.has(o)))??null}function gp(n){return"doubleTapModifier"in Fr(n)?B0()?"Meta":"Control":null}const LE=["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"],zE="device.cycle";function FE(n){const e=LE.findIndex(t=>vt(t,n));return e===-1?null:e+1}function BE(n){return vt(zE,n)}const vc="cogpit:find-in-conversation",La=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}=Ot(),{session:h}=it(),{chat:g,scroll:x}=_r(),{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 pe;return(pe=_.current)==null?void 0:pe.open()},t[0]=P):P=t[0];const A=P;let T,E;t[1]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const pe=function(_e){vt("findInConversation",_e)&&(_e.preventDefault(),A())};return window.addEventListener("keydown",pe),window.addEventListener(vc,A),()=>{window.removeEventListener("keydown",pe),window.removeEventListener(vc,A)}},E=[A],t[1]=T,t[2]=E):(T=t[1],E=t[2]),v.useEffect(T,E);let R,M;t[3]!==p||t[4]!==f||t[5]!==s?(R=()=>{!p||!f||requestAnimationFrame(()=>{var pe;return(pe=s.current)==null?void 0:pe.focus()})},M=[p,f,s],t[3]=p,t[4]=f,t[5]=s,t[6]=R,t[7]=M):(R=t[6],M=t[7]),v.useEffect(R,M);let I;t[8]!==m?(I=pe=>m({type:"JUMP_TO_TURN",index:pe}),t[8]=m,t[9]=I):I=t[9];const D=I;let O;t[10]!==m||t[11]!==d?(O=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=O):O=t[12];const $=O,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]!==$||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(ns,{className:"h-9 flex-1",children:[r.jsx(ss,{ref:s,value:b,onChange:pe=>m({type:"SET_SEARCH_QUERY",value:pe.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(vn,{align:"inline-start",children:r.jsx(ln,{})})]}),r.jsx(Z,{variant:"ghost",size:"icon-sm",onClick:$,"aria-label":"Close conversation search",children:r.jsx(Nt,{"data-icon":"inline-start"})})]}),t[15]=$,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 q;t[22]!==W?(q=G("relative",W),t[22]=W,t[23]=q):q=t[23];let V;t[24]!==y?(V=r.jsx(ME,{ref:_,scrollContainerRef:y}),t[24]=y,t[25]=V):V=t[25];let Y;t[26]!==y||t[27]!==L.turns||t[28]!==D||t[29]!==p?(Y=!p&&r.jsx(AE,{turns:L.turns,scrollContainerRef:y,onJumpToTurn:D}),t[26]=y,t[27]=L.turns,t[28]=D,t[29]=p,t[30]=Y):Y=t[30];let K;t[31]!==y||t[32]!==L?(K=r.jsx(jE,{session:L,scrollContainerRef:y}),t[31]=y,t[32]=L,t[33]=K):K=t[33];const X=p&&"mobile-scroll";let Q;t[34]!==X?(Q=G("h-full overflow-x-hidden overflow-y-auto bg-background",X),t[34]=X,t[35]=Q):Q=t[35];let J;t[36]!==o||t[37]!==p?(J=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]=J):J=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(hE,{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(kE,{}),t[46]=oe):oe=t[46];let se;if(t[47]!==L.turns.length||t[48]!==w){let pe;t[50]!==L.turns.length?(pe=(je,_e)=>r.jsx(Sx,{message:je,turnNumber:L.turns.length+1+_e},_e),t[50]=L.turns.length,t[51]=pe):pe=t[51],se=w.map(pe),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(P8,{}),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(RE,{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]!==J||t[60]!==ae?(te=r.jsx("div",{className:J,children:ae}),t[59]=J,t[60]=ae,t[61]=te):te=t[61];let me;t[62]!==y||t[63]!==k||t[64]!==Q||t[65]!==te?(me=r.jsx("div",{ref:y,onScroll:k,className:Q,children:te}),t[62]=y,t[63]=k,t[64]=Q,t[65]=te,t[66]=me):me=t[66];const de=N?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",le=p?"right-3 bottom-3":"right-5 bottom-5";let he;t[67]!==de||t[68]!==le?(he=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",de,le),t[67]=de,t[68]=le,t[69]=he):he=t[69];let ge;t[70]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsx(Sy,{"data-icon":"inline-start"}),t[70]=ge):ge=t[70];let ce;t[71]!==C||t[72]!==he?(ce=r.jsx(Z,{size:"icon",className:he,onClick:C,"aria-label":"Scroll to bottom",children:ge}),t[71]=C,t[72]=he,t[73]=ce):ce=t[73];let ve;t[74]!==q||t[75]!==V||t[76]!==Y||t[77]!==K||t[78]!==me||t[79]!==ce?(ve=r.jsxs("div",{className:q,children:[V,Y,K,me,ce]}),t[74]=q,t[75]=V,t[76]=Y,t[77]=K,t[78]=me,t[79]=ce,t[80]=ve):ve=t[80];let xe;return t[81]!==H||t[82]!==U||t[83]!==ve?(xe=r.jsxs("div",{className:H,children:[U,ve]}),t[81]=H,t[82]=U,t[83]=ve,t[84]=xe):xe=t[84],xe}),yc="cogpit-devices-changed",W0="cogpit:devices-changed";function H0(n){typeof n.connectionRevision=="number"&&tw(n.id,n.connectionRevision)}function K0(n,e,t=!1){window.dispatchEvent(new CustomEvent(yc,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(W0,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function xp(n){H0(n),K0(n.id,n.connectionRevision)}function El(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function Zs(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function q0(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function UE(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function za(){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 as("/api/hub/devices");if(!g.ok)return;const x=await Zs(g);if(h!==a.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of b)H0(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===W0){try{const j=JSON.parse(y.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&ht()===j.deviceId&&gs(jt)}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(yc,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(yc,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===jt?void 0:n.find(h=>h.id===o),[n,o]),d=v.useCallback(async(h,g,x,b)=>{try{const w=await as("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:b})}),y=await Zs(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 as("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await Zs(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return xp(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 as(El(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await Zs(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return xp(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 as(El(h),{method:"DELETE"});if(g.ok)return ht()===h&&gs(jt),K0(h,void 0,!0),{ok:!0};const x=await Zs(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 as(El(h,"/test"),{method:"POST"});return await Zs(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 WE=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function bp(n,e){if(!WE.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function ki(n,e){return`${n}.${e}`}function HE(n){const e=new Set,t=new Set,s=[];for(const o of n){if(bp("plugin",o.id),e.has(o.id))throw new Error(`Duplicate Cogpit plugin id "${o.id}"`);e.add(o.id);for(const i of o.workspacePanels??[]){bp("panel",i.id);const a=ki(o.id,i.id);if(t.has(a))throw new Error(`Duplicate Cogpit workspace panel id "${a}"`);t.add(a),s.push({...i,id:a,pluginId:o.id,localId:i.id})}}return s.sort((o,i)=>(o.order??100)-(i.order??100)||o.title.localeCompare(i.title))}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("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}const Ni="cogpit",Xt={projectFiles:ki(Ni,"project-files"),fileChanges:ki(Ni,"file-changes"),sessionInfo:ki(Ni,"session-info")},KE=v.lazy(()=>Ke(()=>import("./CommandPaletteHost--_g3tlgk.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),qE=v.lazy(()=>Ke(()=>import("./index-CTpAqQye.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),VE=v.lazy(()=>Ke(()=>Promise.resolve().then(()=>f9),void 0).then(n=>({default:n.DevicesDialog}))),GE=v.lazy(()=>Ke(()=>import("./KeyboardShortcutsDialog-CFhdeGBw.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),YE=v.lazy(()=>Ke(()=>import("./ProjectSwitcherModal-BRbFj3Dd.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),XE=v.lazy(()=>Ke(()=>import("./ThemeSelectorModal-CxGMhlkF.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal}))),JE=v.lazy(()=>Ke(()=>import("./WorktreePanel-B17_SlFC.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function QE(n){const e=B.c(128),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Ot(),{session:c,sessionSource:d}=it(),{devices:f,activeDeviceId:u}=za(),[m,p]=v.useState(null),[h,g]=v.useState(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=lt("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 $e=function(Xe){vt("keyboardShortcuts",Xe)&&(U0(document.activeElement)||(Xe.preventDefault(),S(!0)))};return window.addEventListener("keydown",$e),()=>window.removeEventListener("keydown",$e)},P=[S],e[7]=S,e[8]=_,e[9]=P):(_=e[8],P=e[9]),v.useEffect(_,P);const A=u===jt;let T;e[10]!==A?(T={id:jt,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 $e;e[16]!==u?($e=We=>({id:We.id,name:We.name,isLocal:!1,isActive:We.id===u}),e[16]=u,e[17]=$e):$e=e[17],E=[T,...f.map($e)],e[12]=u,e[13]=f,e[14]=T,e[15]=E}else E=e[15];const R=E;let M;e[18]!==c||e[19]!==(d==null?void 0:d.agentKind)||e[20]!==(d==null?void 0:d.dirName)?(M=()=>{if(!c)return;const $e=(d==null?void 0:d.agentKind)??Ct((d==null?void 0:d.dirName)??null);Sr(Hh($e,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]=M):M=e[21];const I=M,D=ZE,O=s.supportsWorktrees&&t.panels.showWorktrees;let $;e[22]!==j||e[23]!==t.actions||e[24]!==t.panels?($=$e=>{j&&t.actions.handleDashboardSelect(j,`${$e}.jsonl`),t.panels.setShowWorktrees(!1)},e[22]=j,e[23]=t.actions,e[24]=t.panels,e[25]=$):$=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]!==O||e[32]!==$?(L=r.jsx(v.Suspense,{fallback:null,children:r.jsx(JE,{open:O,onOpenChange:t.panels.setShowWorktrees,worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:j,onRefetch:s.worktrees.refetch,onOpenSession:$})}),e[26]=j,e[27]=t.panels.setShowWorktrees,e[28]=s.worktrees.loading,e[29]=s.worktrees.refetch,e[30]=s.worktrees.worktrees,e[31]=O,e[32]=$,e[33]=L):L=e[33];const F=o.processPanel,z=o.workflowsPanel,H=o.undoDialog,U=o.branchModal,W=a.claudeDir??"";let q;e[34]!==a.handleCloseConfigDialog||e[35]!==a.handleConfigSaved||e[36]!==a.showConfigDialog||e[37]!==W?(q=r.jsx(v.Suspense,{fallback:null,children:r.jsx(qE,{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]=q):q=e[38];const V=(d==null?void 0:d.dirName)??i.pendingDirName??null,Y=(c==null?void 0:c.cwd)??i.pendingCwd??null;let K;e[39]!==a.defaultAgentKind||e[40]!==t.onStartNewFolder||e[41]!==t.onStartNewSession||e[42]!==t.panels.handleCloseProjectSwitcher||e[43]!==t.panels.showProjectSwitcher||e[44]!==V||e[45]!==Y?(K=r.jsx(v.Suspense,{fallback:null,children:r.jsx(YE,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:V,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]=V,e[45]=Y,e[46]=K):K=e[46];let X;e[47]!==t.panels.handleCloseThemeSelector||e[48]!==t.panels.showThemeSelector||e[49]!==l.setPreview||e[50]!==l.setTheme||e[51]!==l.theme?(X=r.jsx(v.Suspense,{fallback:null,children:r.jsx(XE,{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]=X):X=e[52];const Q=o.commandPaletteOpen,J=o.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,oe=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,re=t.actions.handleDashboardSelect,ie=t.panels.handleToggleSidebar;let ae,te;e[53]!==t.panels?(ae=()=>t.panels.toggleWorkspacePanel(Xt.sessionInfo),te=()=>t.panels.toggleWorkspacePanel(Xt.fileChanges),e[53]=t.panels,e[54]=ae,e[55]=te):(ae=e[54],te=e[55]);const me=t.panels.handleToggleWorktrees,de=t.panels.handleToggleMission,le=c?t.handlers.handleDuplicateSession:void 0,he=c?I:void 0,ge=c?D:void 0,ce=lt("killAny")?o.onKillAll:void 0,ve=lt("configWrite")?t.panels.handleToggleConfig:void 0,xe=a.openConfigDialog;let pe;e[56]!==S?(pe=()=>S(!0),e[56]=S,e[57]=pe):pe=e[57];const je=s.currentCwd?s.onTogglePreview:void 0,_e=lt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,Re=t.panels.handleToggleThemeSelector,De=s.onOpenTerminal,Te=o.onFocusComposer,Ie=o.onExpandAll,Le=o.onExpandToolPayloads,ze=o.onCollapseAll,Ue=!!(c||i.pendingDirName);let Se;e[58]!==y||e[59]!==(c==null?void 0:c.cwd)||e[60]!==(d==null?void 0:d.dirName)||e[61]!==i.dashboardProject||e[62]!==i.pendingDirName?(Se=lt("terminal")&&!!((c==null?void 0:c.cwd)??y??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[58]=y,e[59]=c==null?void 0:c.cwd,e[60]=d==null?void 0:d.dirName,e[61]=i.dashboardProject,e[62]=i.pendingDirName,e[63]=Se):Se=e[63];const He=!!c;let Oe;e[64]!==s.hasFileChanges?(Oe=lt("hostFiles")&&s.hasFileChanges,e[64]=s.hasFileChanges,e[65]=Oe):Oe=e[65];const Ne=t.panels.activeWorkspacePanel===Xt.sessionInfo,fe=t.panels.activeWorkspacePanel===Xt.fileChanges,Pe=i.mainView==="config",Me=i.mainView==="mission",Fe=(c==null?void 0:c.cwd)??y??null;let ne;e[66]!==o.commandPaletteOpen||e[67]!==o.onCollapseAll||e[68]!==o.onCommandPaletteOpenChange||e[69]!==o.onExpandAll||e[70]!==o.onExpandToolPayloads||e[71]!==o.onFocusComposer||e[72]!==a.openConfigDialog||e[73]!==j||e[74]!==t.actions.handleDashboardSelect||e[75]!==t.actions.handleGoHome||e[76]!==t.onOpenPaletteProject||e[77]!==t.panels.handleOpenProjectSwitcher||e[78]!==t.panels.handleToggleMission||e[79]!==t.panels.handleToggleSidebar||e[80]!==t.panels.handleToggleThemeSelector||e[81]!==t.panels.handleToggleWorktrees||e[82]!==t.panels.showSidebar||e[83]!==t.panels.showWorktrees||e[84]!==R||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==ae||e[91]!==te||e[92]!==le||e[93]!==he||e[94]!==ge||e[95]!==ce||e[96]!==ve||e[97]!==pe||e[98]!==je||e[99]!==_e||e[100]!==Ue||e[101]!==Se||e[102]!==He||e[103]!==Oe||e[104]!==Ne||e[105]!==fe||e[106]!==Pe||e[107]!==Me||e[108]!==Fe?(ne=r.jsx(v.Suspense,{fallback:null,children:r.jsx(KE,{open:Q,onOpenChange:J,onGoHome:ee,onNewSession:oe,onOpenProject:se,onOpenSession:re,onToggleSidebar:ie,onToggleStats:ae,onToggleFileChanges:te,onToggleWorktrees:me,onToggleMissionControl:de,onDuplicateSession:le,onCopyResumeCommand:he,onFindInConversation:ge,onKillAll:ce,onOpenConfig:ve,onOpenSettings:xe,onOpenKeyboardShortcuts:pe,onTogglePreview:je,onToggleProjectFiles:_e,onOpenTheme:Re,onOpenTerminal:De,onOpenDevices:b?p:void 0,onSwitchDevice:gs,devices:R,onFocusComposer:Te,onExpandAll:Ie,onExpandToolPayloads:Le,onCollapseAll:ze,canFocusComposer:Ue,canOpenTerminal:Se,hasSession:He,hasFileChanges:Oe,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ne,showProjectFiles:s.showProjectFiles,showFileChanges:fe,showWorktrees:t.panels.showWorktrees,showConfig:Pe,showMission:Me,currentProjectDirName:j,projectCwd:Fe,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[66]=o.commandPaletteOpen,e[67]=o.onCollapseAll,e[68]=o.onCommandPaletteOpenChange,e[69]=o.onExpandAll,e[70]=o.onExpandToolPayloads,e[71]=o.onFocusComposer,e[72]=a.openConfigDialog,e[73]=j,e[74]=t.actions.handleDashboardSelect,e[75]=t.actions.handleGoHome,e[76]=t.onOpenPaletteProject,e[77]=t.panels.handleOpenProjectSwitcher,e[78]=t.panels.handleToggleMission,e[79]=t.panels.handleToggleSidebar,e[80]=t.panels.handleToggleThemeSelector,e[81]=t.panels.handleToggleWorktrees,e[82]=t.panels.showSidebar,e[83]=t.panels.showWorktrees,e[84]=R,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=ae,e[91]=te,e[92]=le,e[93]=he,e[94]=ge,e[95]=ce,e[96]=ve,e[97]=pe,e[98]=je,e[99]=_e,e[100]=Ue,e[101]=Se,e[102]=He,e[103]=Oe,e[104]=Ne,e[105]=fe,e[106]=Pe,e[107]=Me,e[108]=Fe,e[109]=ne):ne=e[109];let ue;e[110]!==o.keyboardShortcutsOpen||e[111]!==S?(ue=r.jsx(v.Suspense,{fallback:null,children:r.jsx(GE,{open:o.keyboardShortcutsOpen,onOpenChange:S})}),e[110]=o.keyboardShortcutsOpen,e[111]=S,e[112]=ue):ue=e[112];let ke;e[113]!==m||e[114]!==k?(ke=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[113]=m,e[114]=k,e[115]=ke):ke=e[115];let Ae;return e[116]!==o.branchModal||e[117]!==o.processPanel||e[118]!==o.undoDialog||e[119]!==o.workflowsPanel||e[120]!==L||e[121]!==q||e[122]!==K||e[123]!==X||e[124]!==ne||e[125]!==ue||e[126]!==ke?(Ae=r.jsxs(r.Fragment,{children:[L,F,z,H,U,q,K,X,ne,ue,ke]}),e[116]=o.branchModal,e[117]=o.processPanel,e[118]=o.undoDialog,e[119]=o.workflowsPanel,e[120]=L,e[121]=q,e[122]=K,e[123]=X,e[124]=ne,e[125]=ue,e[126]=ke,e[127]=Ae):Ae=e[127],Ae}function ZE(){window.dispatchEvent(new Event(vc))}function Pl(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(Tt,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(Et,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(_t,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const e9="2.2.1",V0={version:e9},t9=V0.version,n9=19384,s9=443,o9=450,r9=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),i9=`${r9?"⌘⇧":"Ctrl+Shift+"}1–9`,a9=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),l9=new Set(["ACCOUNT_DISABLED"]);function Ko(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 Y0={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function c9(n){const e=B.c(10),{tone:t}=n,s=Y0[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(Pn,{"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(yn,{"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(Wt,{"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(Ss,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const d9={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function u9({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=q0(n),C=N!==void 0&&N!==e,S=UE(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,R=h.length>0;if(!E&&!R){u(!1),g(""),b(null);return}if(n.auth==="none"&&!R){b("Enter a password when adding an account to an unauthenticated device.");return}const M={};E&&(M.username=A||null),R&&(M.password=h),k("credentials"),b(null);const I=await s(n.id,M);if(k(null),!I.ok){b(I.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",d9[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(zt,{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(Ee,{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(Z,{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(Wt,{"data-icon":"inline-start",className:G(j==="test"&&"animate-spin")})}),r.jsx(Z,{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(ky,{"data-icon":"inline-start"})}),r.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Fs,{"data-icon":"inline-start"})}),r.jsxs(Zc,{open:w,onOpenChange:A=>{j!=="remove"&&y(A)},children:[r.jsx(_4,{render:r.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(na,{"data-icon":"inline-start"})}),r.jsxs(ed,{size:"sm",children:[r.jsxs(td,{children:[r.jsxs(sd,{children:["Remove ",n.name,"?"]}),r.jsx(od,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(nd,{children:[r.jsx(id,{disabled:j==="remove",children:"Cancel"}),r.jsxs(rd,{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(zt,{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(zt,{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(fs,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(Z,{variant:"outline",size:"sm",onClick:()=>{u(!1),p(n.username??""),g(""),b(null)},children:"Cancel"}),r.jsx(Z,{size:"sm",disabled:j==="credentials",onClick:()=>void P(),children:j==="credentials"?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function X0(n){var Xe,nt;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}=za(),[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,R]=v.useState(null),M=v.useRef(null),I=v.useRef(0);let D,O;e[0]!==s||e[1]!==t?(D=()=>{t&&(h(""),x(""),w(""),j(""),N(!1),S(!1),P(null),R(null),s==="add"&&requestAnimationFrame(()=>{var Be;return(Be=M.current)==null?void 0:Be.focus()}))},O=[t,s],e[0]=s,e[1]=t,e[2]=D,e[3]=O):(D=e[2],O=e[3]),v.useEffect(D,O);let $;e[4]!==k||e[5]!==g||e[6]!==c?($=async()=>{const{host:Be,port:Ge,tls:ot}=Ko(g);if(!Be){P(null),S(!1);return}const wn=I.current=I.current+1;S(!0);const ct=await c(Be,Ge,k,ot);wn===I.current&&(P({...G0(ct,Be,Ge??(ot?s9:n9)),hello:ct.ok?ct.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=c,e[7]=$):$=e[7];const L=$;let F,z;e[8]!==g||e[9]!==t||e[10]!==L?(F=()=>{if(!t)return;if(!Ko(g).host){P(null),S(!1);return}const Be=window.setTimeout(()=>void L(),o9);return()=>window.clearTimeout(Be)},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&&((nt=_==null?void 0:_.hello)==null?void 0:nt.needsBootstrap)===!0,W=H||!k;let q;e:{if(A){q=!1;break e}if(!Ko(g).host){q=!1;break e}if(C||!_){q=!1;break e}if(U){q=!1;break e}if(W&&!y){q=!1;break e}if(H&&!b.trim()){q=!1;break e}if((_==null?void 0:_.tone)==="error"){q=!1;break e}q=!0}const V=q;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:Ge,port:ot,tls:wn}=Ko(g);if(!Ge)return;T(!0),R(null);const ct=await d({name:p.trim()||void 0,host:Ge,port:ot,tls:wn,username:H?b.trim():void 0,password:W&&y||void 0,allowLocalTunnel:k});if(T(!1),ct.ok){o(),gs(ct.device.id);return}R({field:l9.has(ct.code)?"username":a9.has(ct.code)?"password":"host",message:ct.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 K=Y;let X;e[23]!==f?(X=async(Be,Ge)=>{await f(Be,{name:Ge})},e[23]=f,e[24]=X):X=e[24];const Q=X;let J;e[25]!==u?(J=async Be=>{await u(Be)},e[25]=u,e[26]=J):J=e[26];const ee=J;let oe;e[27]!==l||e[28]!==m?(oe=async Be=>{await m(Be),await l()},e[27]=l,e[28]=m,e[29]=oe):oe=e[29];const se=oe;let re;e[30]!==o?(re=Be=>{Be||o()},e[30]=o,e[31]=re):re=e[31];let ie;e[32]!==i?(ie=Be=>{Be||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(Ns,{children:[r.jsx(Zn,{children:"Devices"}),r.jsxs(es,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",i9," jumps between devices."]})]}),e[34]=ae):ae=e[34];let te;e[35]!==a||e[36]!==ee||e[37]!==Q||e[38]!==se||e[39]!==f?(te=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(Be=>r.jsx(u9,{device:Be,hubVersion:t9,onRename:Q,onCredentials:f,onRemove:ee,onTest:se},Be.id))}),e[35]=a,e[36]=ee,e[37]=Q,e[38]=se,e[39]=f,e[40]=te):te=e[40];let me;e[41]===Symbol.for("react.memo_cache_sentinel")?(me=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]=me):me=e[41];const de=(E==null?void 0:E.field)==="host";let le,he;e[42]===Symbol.for("react.memo_cache_sentinel")?(le=r.jsx(xt,{htmlFor:"device-host",children:"Host"}),he=r.jsx(xo,{children:"Enter a local address or an HTTPS URL."}),e[42]=le,e[43]=he):(le=e[42],he=e[43]);let ge;e[44]===Symbol.for("react.memo_cache_sentinel")?(ge=Be=>{I.current=I.current+1,x(Be.target.value),w(""),P(null),R(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 ve;e[47]!==g||e[48]!==ce?(ve=r.jsx(zt,{id:"device-host",ref:M,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]=ve):ve=e[49];let xe;e[50]!==C?(xe=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]=xe):xe=e[51];let pe;e[52]!==_||e[53]!==C?(pe=!C&&_&&r.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",Y0[_.tone]),children:[r.jsx(c9,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=pe):pe=e[54];let je;e[55]!==E?(je=(E==null?void 0:E.field)==="host"&&r.jsx(fs,{children:E.message}),e[55]=E,e[56]=je):je=e[56];let _e;e[57]!==de||e[58]!==ve||e[59]!==xe||e[60]!==pe||e[61]!==je?(_e=r.jsxs(gt,{"data-invalid":de,children:[le,he,ve,xe,pe,je]}),e[57]=de,e[58]=ve,e[59]=xe,e[60]=pe,e[61]=je,e[62]=_e):_e=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 De;e[64]===Symbol.for("react.memo_cache_sentinel")?(De=Be=>h(Be.target.value),e[64]=De):De=e[64];let Te;e[65]!==p?(Te=r.jsxs(gt,{children:[Re,r.jsx(zt,{id:"device-name",value:p,onChange:De,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Te):Te=e[66];let Ie;e[67]!==E||e[68]!==H||e[69]!==b?(Ie=H&&r.jsxs(gt,{"data-invalid":(E==null?void 0:E.field)==="username",children:[r.jsx(xt,{htmlFor:"device-username",children:"Username"}),r.jsx(zt,{id:"device-username",value:b,onChange:Be=>w(Be.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(xo,{children:"Requests through this hub will act as this account on the team server."}),(E==null?void 0:E.field)==="username"&&r.jsx(fs,{children:E.message})]}),e[67]=E,e[68]=H,e[69]=b,e[70]=Ie):Ie=e[70];let Le;e[71]!==W||e[72]!==y||e[73]!==E||e[74]!==H?(Le=W&&r.jsxs(gt,{"data-invalid":(E==null?void 0:E.field)==="password",children:[r.jsx(xt,{htmlFor:"device-password",children:"Password"}),r.jsx(zt,{id:"device-password",type:"password",value:y,onChange:Be=>j(Be.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(fs,{children:E.message})]}),e[71]=W,e[72]=y,e[73]=E,e[74]=H,e[75]=Le):Le=e[75];let ze;e[76]!==_e||e[77]!==Te||e[78]!==Ie||e[79]!==Le?(ze=r.jsxs(Co,{children:[_e,Te,Ie,Le]}),e[76]=_e,e[77]=Te,e[78]=Ie,e[79]=Le,e[80]=ze):ze=e[80];let Ue;e[81]===Symbol.for("react.memo_cache_sentinel")?(Ue=Be=>{I.current=I.current+1,N(Be===!0),P(null),R(null)},e[81]=Ue):Ue=e[81];let Se;e[82]!==k?(Se=r.jsx(Gg,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Ue}),e[82]=k,e[83]=Se):Se=e[83];const He=H?"":" — no password";let Oe;e[84]!==He?(Oe=r.jsxs(xt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",He]}),e[84]=He,e[85]=Oe):Oe=e[85];let Ne;e[86]!==Se||e[87]!==Oe?(Ne=r.jsxs(gt,{orientation:"horizontal",children:[Se,Oe]}),e[86]=Se,e[87]=Oe,e[88]=Ne):Ne=e[88];let fe;e[89]!==k||e[90]!==H?(fe=k&&r.jsxs(St,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(Ny,{}),r.jsx(kt,{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]=fe):fe=e[91];let Pe;e[92]!==o?(Pe=r.jsx(Z,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=Pe):Pe=e[93];const Me=!V;let Fe;e[94]!==K?(Fe=()=>void K(),e[94]=K,e[95]=Fe):Fe=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 ue;e[98]!==Me||e[99]!==Fe||e[100]!==ne?(ue=r.jsx(Z,{disabled:Me,onClick:Fe,children:ne}),e[98]=Me,e[99]=Fe,e[100]=ne,e[101]=ue):ue=e[101];let ke;e[102]!==Pe||e[103]!==ue?(ke=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Pe,ue]}),e[102]=Pe,e[103]=ue,e[104]=ke):ke=e[104];let Ae;e[105]!==ze||e[106]!==Ne||e[107]!==fe||e[108]!==ke?(Ae=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[me,ze,Ne,fe,ke]}),e[105]=ze,e[106]=Ne,e[107]=fe,e[108]=ke,e[109]=Ae):Ae=e[109];let $e;e[110]!==te||e[111]!==Ae?($e=r.jsxs(Qn,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,te,Ae]}),e[110]=te,e[111]=Ae,e[112]=$e):$e=e[112];let We;return e[113]!==t||e[114]!==re||e[115]!==ie||e[116]!==$e?(We=r.jsx(Jn,{open:t,onOpenChange:re,onOpenChangeComplete:ie,children:$e}),e[113]=t,e[114]=re,e[115]=ie,e[116]=$e,e[117]=We):We=e[117],We}const f9=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:X0,parseHostPort:Ko,probeMessage:G0},Symbol.toStringTag,{value:"Module"})),vp=V0.version,m9={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},yp={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function p9(n){const e=B.c(6),{state:t}=n,s=yp[t],o=yp[t],i=m9[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 Gd(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}=za(),[d,f]=v.useState(null),u=(a==null?void 0:a.name)??"This machine",m=i!==jt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=lt("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(g9))).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(Z,{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(Nh,{"data-icon":"inline-start"}):r.jsx(rf,{"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(Ze,{"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(Ln,{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(xs,{children:"Devices"}),e[19]=_):_=e[19];let P,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(rf,{}),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(ft,{className:"ml-auto text-success"}),e[22]=m,e[23]=T):T=e[23];let E;e[24]!==T?(E=r.jsxs(ut,{onClick:h9,children:[P,A,T]}),e[24]=T,e[25]=E):E=e[25];let R;if(e[26]!==i||e[27]!==s||e[28]!==o){let F;e[30]!==i||e[31]!==s?(F=z=>{const H=q0(z),U=H!==void 0&&H!==vp,W=z.id===i;return r.jsxs(ut,{onClick:()=>gs(z.id),className:G(s&&"min-h-10"),children:[r.jsx(p9,{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${vp}`,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(ft,{className:"ml-auto text-success"})]},z.id)},e[30]=i,e[31]=s,e[32]=F):F=e[32],R=o.map(F),e[26]=i,e[27]=s,e[28]=o,e[29]=R}else R=e[29];let M;e[33]!==E||e[34]!==R?(M=r.jsxs(Ut,{children:[_,E,R]}),e[33]=E,e[34]=R,e[35]=M):M=e[35];let I;e[36]!==o.length?(I=h&&r.jsxs(r.Fragment,{children:[r.jsx(uo,{}),r.jsxs(Ut,{children:[r.jsxs(ut,{onClick:()=>f("add"),children:[r.jsx(Tn,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(ut,{onClick:()=>f("manage"),children:[r.jsx(Dc,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=I):I=e[37];let D;e[38]!==M||e[39]!==I?(D=r.jsxs(zn,{align:"end",sideOffset:6,className:"w-64",children:[M,I]}),e[38]=M,e[39]=I,e[40]=D):D=e[40];let O;e[41]!==x||e[42]!==S||e[43]!==D?(O=r.jsxs(Dn,{onOpenChange:x,children:[S,D]}),e[41]=x,e[42]=S,e[43]=D,e[44]=O):O=e[44];let $;e[45]!==d?($=h&&r.jsx(X0,{open:d!==null,initialMode:d??"manage",onClose:()=>f(null)}),e[45]=d,e[46]=$):$=e[46];let L;return e[47]!==O||e[48]!==$?(L=r.jsxs(r.Fragment,{children:[O,$]}),e[47]=O,e[48]=$,e[49]=L):L=e[49],L}function h9(){return gs(jt)}function g9(){return null}const x9=6e4;function b9(){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()},x9);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const v9=6e4;function y9(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=b9(),[i,a]=v.useState(!1),l=e.length>0,c=e.reduce(S9,0);let d,f;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const T=window.setTimeout(()=>a(!1),v9);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=_t,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(j9)):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(Z,{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(Cy,{"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(Tt,{render:b,children:[w,j]}),n[19]=j,n[20]=b,n[21]=k):k=n[21];const N=Et,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(w9),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(Mt,{}),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 w9(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," · ",Kc(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function j9(n){return n.pid}function S9(n,e){return n+e.cpuPercent}const k9=15e3;function N9(){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(),k9);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},_9),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(C9),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 C9(n){return n.readAt===null}function _9(){return!0}function J0(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function T9(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=N9(),[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=_===jt?"":`/d/${_}`;J0(`${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(Z,{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(af,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Ee,{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(Ln,{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(Z,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(_y,{"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(In,{className:"min-h-40 p-6",children:r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:r.jsx(af,{})}),r.jsx($n,{children:"No notifications"}),r.jsx(On,{children:"Session updates will appear here."})]})}):r.jsx(Ut,{children:e.map(C=>r.jsx(E9,{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(zn,{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(Dn,{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 E9(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"?en:aa;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=Kc(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(ut,{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 P9=2e3;function jo(n){return`${n.toFixed(n<10?1:0)}%`}function qi(n){return`${n.toFixed(0)} MB`}function A9(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function R9(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 I9(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(Ee,{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(Ee,{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(Ee,{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(Z,{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=jo(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=qi(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=Kc(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 M9(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 $9(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 Q0(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(Ee,{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=M9(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=jo(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=qi(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 wp(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(O9)}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 O9(n,e){const t=R9(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(Mt,{}),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:A9(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(Ee,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function D9(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(L9).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:jo(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 L9(n){return jo(n)}function z9(n){var he,ge,ce,ve;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]=yo();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Te;if(g.current)return;g.current=!0,h(!0);const xe=ye("/api/performance").then(K9),pe=((Te=window.electronPerformance)==null?void 0:Te.getSnapshot())??Promise.resolve(null),[je,_e]=await Promise.allSettled([xe,pe]),Re=je.status==="fulfilled"?je.value:null,De=_e.status==="fulfilled"?_e.value:null;if(Re&&l(Re),De&&i(De),!Re&&!De)m("Performance data is unavailable.");else{m(null);const Ie=De&&De.processes.length>0?De.processes.reduce(H9,0):(Re==null?void 0:Re.cpuPercent)??0;f(Le=>[...Le.slice(-29),Ie])}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 xe=window.setInterval(()=>void y(),P9);return()=>window.clearInterval(xe)},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,R,M,I,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 xe=[...(o==null?void 0:o.processes)??[]].sort(W9),pe=xe.length>0?xe.reduce(U9,0):(a==null?void 0:a.cpuPercent)??0,je=xe[0];let _e;e[33]!==((he=a==null?void 0:a.system)==null?void 0:he.processes)?(_e=((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]=_e):_e=e[34],T=_e;const Re=((ve=a==null?void 0:a.system)==null?void 0:ve.suspectedLeakCount)??0,De=Re>0||pe>=80?"High":pe>=15?"Active":"Idle";let Te;e[35]===Symbol.for("react.memo_cache_sentinel")?(Te=async ot=>{try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[ot]})}),await new Promise(B9)}catch{}y()},e[35]=Te):Te=e[35],A=Te;let Ie;e[36]!==b||e[37]!==o||e[38]!==d||e[39]!==a?(Ie=()=>{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]=Ie):Ie=e[40];const Le=Ie;P=Jn,O=t,$=s,_=Qn,M="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(Zn,{children:"Power & activity monitor"}),e[41]=ze):ze=e[41];const Ue=De==="High"?"destructive":"secondary";let Se;e[42]!==De||e[43]!==Ue?(Se=r.jsxs("div",{className:"flex items-center gap-2",children:[ze,r.jsx(Ee,{variant:Ue,children:De})]}),e[42]=De,e[43]=Ue,e[44]=Se):Se=e[44];let He;e[45]===Symbol.for("react.memo_cache_sentinel")?(He=r.jsx(es,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=He):He=e[45];let Oe;e[46]!==Se?(Oe=r.jsxs("div",{className:"min-w-0 flex-1",children:[Se,He]}),e[46]=Se,e[47]=Oe):Oe=e[47];let Ne;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>void y(),e[48]=Ne):Ne=e[48];const fe=p&&"animate-spin";let Pe;e[49]!==fe?(Pe=G(fe),e[49]=fe,e[50]=Pe):Pe=e[50];let Me;e[51]!==Pe?(Me=r.jsx(Wt,{"data-icon":"inline-start",className:Pe}),e[51]=Pe,e[52]=Me):Me=e[52];let Fe;e[53]!==p||e[54]!==Me?(Fe=r.jsxs(Z,{variant:"outline",size:"sm",onClick:Ne,disabled:p,children:[Me,"Refresh"]}),e[53]=p,e[54]=Me,e[55]=Fe):Fe=e[55];const ne=!a&&!o;let ue;e[56]!==x?(ue=x?r.jsx(ft,{"data-icon":"inline-start"}):r.jsx(An,{"data-icon":"inline-start"}),e[56]=x,e[57]=ue):ue=e[57];const ke=x?"Copied":"Copy data";let Ae;e[58]!==Le||e[59]!==ne||e[60]!==ue||e[61]!==ke?(Ae=r.jsxs(Z,{variant:"outline",size:"sm",onClick:Le,disabled:ne,children:[ue,ke]}),e[58]=Le,e[59]=ne,e[60]=ue,e[61]=ke,e[62]=Ae):Ae=e[62];let $e;e[63]!==Fe||e[64]!==Ae?($e=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Fe,Ae]}),e[63]=Fe,e[64]=Ae,e[65]=$e):$e=e[65],e[66]!==Oe||e[67]!==$e?(I=r.jsx(Ns,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Oe,$e]})}),e[66]=Oe,e[67]=$e,e[68]=I):I=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Mt,{}),e[69]=D):D=e[69],S=To,R="min-h-0 min-w-0 flex-1",H="flex flex-col gap-4 p-5",e[70]!==u?(U=u&&r.jsx(St,{variant:"destructive",children:r.jsx(kt,{children:u})}),e[70]=u,e[71]=U):U=e[71];let We;e[72]===Symbol.for("react.memo_cache_sentinel")?(We=r.jsx(Vt,{children:"Current load"}),e[72]=We):We=e[72];const Xe=pe>=80&&"text-destructive";let nt;e[73]!==Xe?(nt=G("font-mono text-lg font-semibold tabular-nums",Xe),e[73]=Xe,e[74]=nt):nt=e[74];const Be=r.jsxs(Bt,{children:[We,r.jsx(Gt,{children:$9(pe,je,Re)}),r.jsx(ad,{children:r.jsxs("span",{className:nt,children:[jo(pe)," CPU"]})})]});let Ge;e[75]!==d?(Ge=r.jsx(Lt,{children:r.jsx(D9,{values:d})}),e[75]=d,e[76]=Ge):Ge=e[76],e[77]!==Be||e[78]!==Ge?(E=r.jsxs(Dt,{size:"sm",children:[Be,Ge]}),e[77]=Be,e[78]=Ge,e[79]=E):E=e[79],C=Dt,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs(Bt,{children:[r.jsx(Vt,{children:"Processes"}),r.jsx(Gt,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],N=Lt,L=xe.length>0?xe.map(F9):a?r.jsx(Q0,{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]=R,e[23]=M,e[24]=I,e[25]=D,e[26]=O,e[27]=$,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],R=e[22],M=e[23],I=e[24],D=e[25],O=e[26],$=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 q;e[84]!==C||e[85]!==W||e[86]!==F||e[87]!==z?(q=r.jsxs(C,{size:F,children:[z,W]}),e[84]=C,e[85]=W,e[86]=F,e[87]=z,e[88]=q):q=e[88];let V;e[89]!==A||e[90]!==T?(V=T.length>0&&r.jsxs(Dt,{size:"sm",children:[r.jsxs(Bt,{children:[r.jsx(Vt,{children:"Agent processes"}),r.jsx(Gt,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Lt,{children:T.map((xe,pe)=>r.jsxs("div",{children:[pe>0&&r.jsx(Mt,{}),r.jsx(I9,{metric:xe,onKill:je=>void A(je)})]},xe.pid))})]}),e[89]=A,e[90]=T,e[91]=V):V=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Vt,{children:"Server activity"}),e[92]=Y):Y=e[92];const K=(a==null?void 0:a.sampleWindowSeconds)??10;let X;e[93]!==K?(X=r.jsxs(Bt,{children:[Y,r.jsxs(Gt,{children:["File checks, streams, and agent work over the last ",K," seconds."]})]}),e[93]=K,e[94]=X):X=e[94];let Q;e[95]!==(a==null?void 0:a.activities)?(Q=(a==null?void 0:a.activities)??[],e[95]=a==null?void 0:a.activities,e[96]=Q):Q=e[96];let J;e[97]!==Q?(J=r.jsx(Lt,{children:r.jsx(wp,{metrics:Q,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Q,e[98]=J):J=e[98];let ee;e[99]!==X||e[100]!==J?(ee=r.jsxs(Dt,{size:"sm",children:[X,J]}),e[99]=X,e[100]=J,e[101]=ee):ee=e[101];let oe;e[102]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsxs(Bt,{children:[r.jsx(Vt,{children:"API activity"}),r.jsx(Gt,{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(Dt,{size:"sm",children:[oe,r.jsx(Lt,{children:r.jsx(wp,{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 ",jo(a.eventLoopPercent)," · heap ",qi(a.memory.heapUsedMb)," · RSS ",qi(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let te;e[112]!==E||e[113]!==q||e[114]!==V||e[115]!==ie||e[116]!==ae||e[117]!==H||e[118]!==U?(te=r.jsxs("div",{className:H,children:[U,E,q,V,ie,ae]}),e[112]=E,e[113]=q,e[114]=V,e[115]=ie,e[116]=ae,e[117]=H,e[118]=U,e[119]=te):te=e[119];let me;e[120]!==S||e[121]!==R||e[122]!==te?(me=r.jsx(S,{className:R,children:te}),e[120]=S,e[121]=R,e[122]=te,e[123]=me):me=e[123];let de;e[124]!==_||e[125]!==M||e[126]!==I||e[127]!==D||e[128]!==me?(de=r.jsxs(_,{className:M,children:[I,D,me]}),e[124]=_,e[125]=M,e[126]=I,e[127]=D,e[128]=me,e[129]=de):de=e[129];let le;return e[130]!==P||e[131]!==O||e[132]!==$||e[133]!==de?(le=r.jsx(P,{open:O,onOpenChange:$,children:de}),e[130]=P,e[131]=O,e[132]=$,e[133]=de,e[134]=le):le=e[134],le}function F9(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(Mt,{}),r.jsx(Q0,{metric:n})]},n.pid)}function B9(n){return setTimeout(n,1e3)}function U9(n,e){return n+e.cpuPercent}function W9(n,e){return e.cpuPercent-n.cpuPercent}function H9(n,e){return n+e.cpuPercent}async function K9(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function q9(n){return`${n.title??`Pull request #${n.number}`}
|
|
120
|
+
${n.repo}${n.isDraft?" · draft":""}`}function Z0(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:q9(n)}}function Fa(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(G9),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(V9).join(`
|
|
121
|
+
`),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?Ah:Rh;return r.jsxs(Ee,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...Z0(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 V9(n){return`#${n.number} ${n.title??n.repo}`}function G9(n){const e=n.isDraft?Ah:Rh;return r.jsxs("a",{...Z0(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 Y9=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?bs(o.fileName):null;p=A?Od(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(Q9),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=go(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(J9,{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(ba,{"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:Nr(s.model)}),t[19]=s.model,t[20]=N):N=t[20];let C;t[21]!==w?(C=r.jsx(Pg,{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(Tt,{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(Et,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(X9,{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(_t,{children:[S,_]}),t[34]=_,t[35]=S,t[36]=P):P=t[36],P});function eo(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 X9(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=cg(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(eo,{label:"Model",children:[r.jsx("span",{children:Nr(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(eo,{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(eo,{label:"Pull requests",children:r.jsx(Fa,{pullRequests:i})}),e[19]=i,e[20]=f):f=e[20],e[21]!==o?(u=o&&r.jsx(eo,{label:"Agent",children:o}),e[21]=o,e[22]=u):u=e[22],e[23]!==x?(m=x&&r.jsxs(eo,{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(eo,{label:"Context",children:[tt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",tt(g.used)," / ",tt(g.limit)]}),e[0]=i,e[1]=a,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=o,e[6]=s,e[7]=l,e[8]=c,e[9]=d,e[10]=f,e[11]=u,e[12]=m,e[13]=p}else l=e[7],c=e[8],d=e[9],f=e[10],u=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==d||e[28]!==f||e[29]!==u||e[30]!==m||e[31]!==p?(h=r.jsxs("div",{className:l,children:[c,d,f,u,m,p]}),e[25]=l,e[26]=c,e[27]=d,e[28]=f,e[29]=u,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function J9(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}=Ot(),u=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Os(),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?`${qn(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||dd(),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(ft,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:qn(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(Ra,{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(At,{className:"size-3.5"}):r.jsx(Tn,{className:"size-3.5"}),e[28]=i,e[29]=E):E=e[29];let R;e[30]!==i||e[31]!==T||e[32]!==E?(R=r.jsxs(Zt,{disabled:i,onClick:T,children:[E,"New session in this project"]}),e[30]=i,e[31]=T,e[32]=E,e[33]=R):R=e[33];let M;e[34]!==c?(M=c&&r.jsxs(Zt,{onClick:c,children:[r.jsx(An,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=M):M=e[35];let I;e[36]!==u||e[37]!==y?(I=u&&(k||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(mr,{}),k&&r.jsxs(Zt,{onClick:()=>t1(y),children:[r.jsx(br,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(Zt,{onClick:()=>n1(y),children:[r.jsx(Ih,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=u,e[37]=y,e[38]=I):I=e[38];let D;e[39]!==d?(D=d&&!p&<("terminal")&&r.jsxs(Zt,{onClick:d,children:[r.jsx(No,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=D):D=e[40];let O;e[41]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(mr,{}),e[41]=O):O=e[41];let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(ho,{className:"size-3.5"}),e[42]=$):$=e[42];let L;e[43]!==C?(L=r.jsxs(Zt,{onClick:C,children:[$,"View all sessions in this project"]}),e[43]=C,e[44]=L):L=e[44];let F;e[45]!==R||e[46]!==M||e[47]!==I||e[48]!==D||e[49]!==L?(F=r.jsxs(Ia,{className:"min-w-56",children:[R,M,I,D,O,L]}),e[45]=R,e[46]=M,e[47]=I,e[48]=D,e[49]=L,e[50]=F):F=e[50];let z;return e[51]!==A||e[52]!==F?(z=r.jsxs(Aa,{children:[A,F]}),e[51]=A,e[52]=F,e[53]=z):z=e[53],z}function Q9(n){return n.thinking.length>0}const wc="Could not reach the server";async function di(n,e){try{return await ye(n,e)}catch{return null}}async function Al(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:wc}function Z9(){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 di("/api/shares");if(!(N!=null&&N.ok))return;const C=await N.json().catch(sP);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 di("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:N})});if(!(C!=null&&C.ok))return a.current&&i(await Al(C)),null;const S=await C.json().catch(nP);if(!(S!=null&&S.passphrase)||!S.share)return a.current&&i(wc),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 di(`/api/shares/${encodeURIComponent(N)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await Al(C)),null;const S=await C.json().catch(tP);return S!=null&&S.passphrase?(f(),S.passphrase):(a.current&&i(wc),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 di(`/api/shares/${encodeURIComponent(N)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await Al(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(eP);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 eP(n){return n.sessionId}function tP(){return null}function nP(){return null}function sP(){return null}const oP=5e3,rP="••••";function iP(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function aP({sessionId:n}){const{config:{networkAccessDisabled:e}}=Ot(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=Z9(),[c,d]=v.useState(!1),[f,u]=v.useState(null),[m,p]=v.useState(!1),[h,g]=yo(),[x,b]=yo(),w=t.find(N=>N.sessionId===n)??null,y=`${window.location.origin}${$S(n)}`;v.useEffect(()=>u(null),[n]),v.useEffect(()=>{if(!c)return;o();const N=setInterval(()=>void o(),oP);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(Dn,{open:c,onOpenChange:N=>{d(N),N||u(null)},children:[r.jsx(Ln,{render:r.jsx(Z,{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(Ty,{"data-icon":"inline-start"})}),r.jsx(zn,{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(Z,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(y),children:h?r.jsx(ft,{"data-icon":"inline-start"}):r.jsx(An,{"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??rP}),r.jsx(Z,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{u(await a(n))}),children:r.jsx(Wt,{"data-icon":"inline-start"})})]}),f?r.jsx(Z,{variant:"secondary",size:"xs",onClick:()=>b(`${y}
|
|
122
|
+
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:iP(w.guests)}),r.jsx(Z,{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(Z,{size:"xs",disabled:m,onClick:()=>j(async()=>{u(await i(n))}),children:"Enable sharing"})]})})]})}function Yd(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 ms(n){return typeof n=="string"?n:void 0}function us(n){return n?Yd(xn(n.utilization),ms(n.resets_at)):void 0}function e2(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:xn(n.monthly_limit),usedCredits:xn(n.used_credits),utilization:xn(n.utilization)}}function lP(n){return{fiveHour:us(at(n.five_hour)),sevenDay:us(at(n.seven_day)),sevenDayOpus:us(at(n.seven_day_opus)),sevenDaySonnet:us(at(n.seven_day_sonnet)),extraUsage:e2(at(n.extra_usage)),subscriptionType:ms(n.subscriptionType)}}function cP(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:us(at(t==null?void 0:t.five_hour)),sevenDay:us(at(t==null?void 0:t.seven_day)),sevenDayOpus:us(at(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:us(at(t==null?void 0:t.seven_day_sonnet)),extraUsage:e2(at(t==null?void 0:t.extra_usage)),subscriptionType:ms(e==null?void 0:e.subscription_type)??ms(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function dP(n){const e=xn(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function uP(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 jp(n,e){if(n)return Yd(xn(n.usedPercent),dP(n.resetsAt),uP(n.windowDurationMins,e))}function fP(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=jp(at(e==null?void 0:e.primary),"Primary"),a=jp(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:ms(e==null?void 0:e.planType)??ms(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:ms(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function Sp(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),Yd(i,ms(n.resetDate),e)}function mP(n){var s;if(n.available!==!0)return null;const e=at((s=at(n.quota))==null?void 0:s.quotaSnapshots),t=Sp(at(e==null?void 0:e.chat),"Chat")??Sp(at(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const pP={claude:{endpoint:"/api/claude/runtime",read:cP,legacy:{endpoint:"/api/usage",read:lP}},codex:{endpoint:"/api/codex/runtime",read:fP},copilot:{endpoint:"/api/copilot/runtime",read:mP}};function hP(n){return pP[n]}const gP=300*1e3;function xP(n=Bs){const e=bn("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=hP(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,gP);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 t2(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const n2={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function bP(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?ga(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(Ee,{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=t2(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",n2[b]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Ar,{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(Mt,{}),"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(Mt,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",tt(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?r.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?r.jsxs("div",{children:["Credits: ",t.creditBalance]}):null]}),e[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 vP(n){var j,k;const e=B.c(22),{agentKind:t}=n,s=t===void 0?Bs:t,{usage:o,loading:i,available:a,refresh:l}=xP(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?ga(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(Z,{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=n2[t2(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(Tt,{render:u,children:x}),e[14]=u,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==o?(w=r.jsx(Et,{side:"bottom",className:"p-3",children:r.jsx(bP,{usage:o})}),e[17]=o,e[18]=w):w=e[18];let y;return e[19]!==b||e[20]!==w?(y=r.jsxs(_t,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=y):y=e[21],y}function yP(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(jP);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(wP),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 wP(n){return n+1}function jP(n){return{...n,loading:!0,error:null}}function SP(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const kP=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function NP(n,e){const t=SP(e);return t.length===0||kP.has(t)?null:n.get(t)??null}function CP(n,e,t,s){const o=NP(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 _P(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function s2(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=CP(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 TP=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],Qo=dg.map(n=>({key:n,label:tn(n).displayName,color:Tw(n)}));function EP(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 kp(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function PP(n){const e=new Map;for(const o of EP(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:kp(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:kp(),days:[],models:[]};for(const o of n.buckets){const i=_P(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 Np(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const Rl=720,Il=180,AP=18;function RP(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=Il-AP,u=Rl/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:Np(p.day)}),Qo.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"?ls(A.costUsd):tt(A.tokens)]},S)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?ls(p.costUsd):tt(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>i(null),b=r.jsx("line",{x1:0,y1:f,x2:Rl,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}),Qo.map(E=>{const{key:R,color:M}=E,I=l(S.byProvider[R]);if(I<=0)return null;const D=I/d*(f-6);return A=A-D,r.jsx("rect",{x:P,y:A,width:m,height:Math.max(1,D-1.5),rx:1.5,fill:M,opacity:T?1:.85},R)})]},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:Il-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:Np(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 ${Rl} ${Il}`,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:Qo.map(IP)}),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 IP(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 Ml(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 MP(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=yP(t,!0),[l,c]=v.useState("cost");let d;e[0]!==s?(d=s?PP(s):null,e[0]=s,e[1]=d):d=e[1];const f=d;if(i){let F;e[2]!==a?(F=r.jsx(Z,{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(At,{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"?ls(f.costUsd):tt(f.tokens),e[10]=f.costUsd,e[11]=f.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=r.jsx("span",{className:"text-3xl font-semibold text-foreground tabular-nums",children:p}),e[14]=p,e[15]=h):h=e[15];const g=l==="cost"?"raw API price":"processed tokens";let 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(Z,{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=Qo.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"?ls(U.costUsd):tt(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(RP,{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=tt(f.tokens),e[37]=f.tokens,e[38]=S):S=e[38];let _;e[39]!==S?(_=r.jsx(Ml,{label:"Processed tokens",value:S}),e[39]=S,e[40]=_):_=e[40];let P;e[41]!==f.cacheSavingsUsd?(P=ls(f.cacheSavingsUsd),e[41]=f.cacheSavingsUsd,e[42]=P):P=e[42];let A;e[43]!==P?(A=r.jsx(Ml,{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(Ml,{label:"Files scanned",value:T}),e[45]=T,e[46]=E):E=e[46];let R;e[47]!==_||e[48]!==A||e[49]!==E?(R=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]=R):R=e[50];let M;e[51]===Symbol.for("react.memo_cache_sentinel")?(M=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]=M):M=e[51];let I;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=Qo.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?"—":ls(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:tt(z.tokens)})]},`${z.provider}:${z.model}`)},e[55]=f.costUsd,e[56]=F):F=e[56],I=f.models.map(F),e[52]=f.costUsd,e[53]=f.models,e[54]=I}else I=e[54];let D;e[57]!==I?(D=r.jsxs("table",{className:"w-full text-sm",children:[M,r.jsx("tbody",{children:I})]}),e[57]=I,e[58]=D):D=e[58];const O=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let $;e[59]!==O?($=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",O," ","— not what a subscription bills."]}),e[59]=O,e[60]=$):$=e[60];let L;return e[61]!==N||e[62]!==C||e[63]!==R||e[64]!==D||e[65]!==$||e[66]!==m?(L=r.jsxs("div",{className:m,children:[N,C,R,D,$]}),e[61]=N,e[62]=C,e[63]=R,e[64]=D,e[65]=$,e[66]=m,e[67]=L):L=e[67],L}function $P(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(Zn,{children:"API usage"}),r.jsx(es,{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=TP.map(m=>r.jsx(Z,{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(Ns,{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(MP,{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(Qn,{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(Jn,{open:t,onOpenChange:s,children:f}),e[11]=s,e[12]=t,e[13]=f,e[14]=u):u=e[14],u}const OP=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,DP=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,$l=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,LP=[new RegExp(`${$l}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${$l}'([^']*)'`),new RegExp(`${$l}(\\S+)`)];function zP(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 FP(n){return zP(n).find(e=>DP.test(e))??null}function BP(n){for(const e of LP){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function UP(){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=OP.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:BP(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function WP(n){const e=UP();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=FP(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function HP(...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 to="flex h-8 items-center px-0.5",KP=v.memo(function(e){var Xe;const t=B.c(114),{showSidebar:s,sidebarRendered:o,sidebarShortcut:i,showWorktrees:a,killing:l,creatingSession:c,onNewSession:d,onDuplicateSession:f,onOpenTerminal:u,onBackToMain:m,onShowWorkflows:p,workflowCount:h,onToggleSidebar:g,onToggleWorktrees:x,onKillAll:b,onOpenSettings:w,showConfig:y,onToggleConfig:j,showMission:k,onToggleMission:N}=e,C=o===void 0?s:o,{config:S}=Ot(),{networkUrl:_,defaultAgentKind:P}=S,{session:A,sessionSource:T,isLive:E}=it(),R=Id(),M=bn("viewUsage"),[I,D]=v.useState(!1),[O,$]=v.useState(!1),[L,F]=yo(),z=A==null?void 0:A.turns;let H;t[0]!==(R==null?void 0:R.sessions)||t[1]!==(A==null?void 0:A.sessionId)?(H=(Xe=R==null?void 0:R.sessions.find(nt=>nt.sessionId===(A==null?void 0:A.sessionId)))==null?void 0:Xe.pullRequests,t[0]=R==null?void 0:R.sessions,t[1]=A==null?void 0:A.sessionId,t[2]=H):H=t[2];const U=H;let W;t[3]!==U||t[4]!==z?(W=HP(WP(z??[]),U),t[3]=U,t[4]=z,t[5]=W):W=t[5];const q=W;let V;t[6]!==P||t[7]!==T?(V=T?T.agentKind??Ct(T.dirName):P,t[6]=P,t[7]=T,t[8]=V):V=t[8];const Y=V;let K;t[9]!==T?(K=T?bs(T.fileName)!==null:!1,t[9]=T,t[10]=K):K=t[10];const X=K;let Q;t[11]!==F||t[12]!==A||t[13]!==(T==null?void 0:T.agentKind)||t[14]!==(T==null?void 0:T.dirName)?(Q=function(){if(!A)return;const Be=(T==null?void 0:T.agentKind)??Ct((T==null?void 0:T.dirName)??null);F(Hh(Be,A.sessionId,A.cwd))},t[11]=F,t[12]=A,t[13]=T==null?void 0:T.agentKind,t[14]=T==null?void 0:T.dirName,t[15]=Q):Q=t[15];const J=Q;let ee;t[16]!==_?(ee=function(){_&&Sr(_).then(VP)},t[16]=_,t[17]=ee):ee=t[17];const oe=ee;let se,re;t[18]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),se=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]=se,t[19]=re):(se=t[18],re=t[19]);const ie=!C&&"window-inset-start";let ae;t[20]!==ie?(ae=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",ie),t[20]=ie,t[21]=ae):ae=t[21];let te;t[22]!==g||t[23]!==s||t[24]!==i?(te=!s&&r.jsx(qP,{icon:Py,label:`Show sidebar (${i})`,onClick:g}),t[22]=g,t[23]=s,t[24]=i,t[25]=te):te=t[25];let me;t[26]!==X||t[27]!==m||t[28]!==A?(me=A&&X&&m&&r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:m,className:G(Cn,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(Je,{className:"size-3 rotate-180"}),"Main"]}),t[26]=X,t[27]=m,t[28]=A,t[29]=me):me=t[29];let de;t[30]!==L||t[31]!==c||t[32]!==J||t[33]!==E||t[34]!==f||t[35]!==d||t[36]!==u||t[37]!==q||t[38]!==A||t[39]!==T?(de=A&&r.jsx(Y9,{session:A,sessionSource:T,isLive:E,pullRequests:q,copied:L,creatingSession:c,onCopyResume:J,onNewSession:d,onDuplicateSession:f,onOpenTerminal:u}),t[30]=L,t[31]=c,t[32]=J,t[33]=E,t[34]=f,t[35]=d,t[36]=u,t[37]=q,t[38]=A,t[39]=T,t[40]=de):de=t[40];let le;t[41]!==p||t[42]!==A||t[43]!==h?(le=A&&p&&(h??0)>0&&r.jsxs(Z,{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:p,children:[r.jsx(la,{className:"size-3"}),"Workflows",r.jsx(Ee,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:h})]}),t[41]=p,t[42]=A,t[43]=h,t[44]=le):le=t[44];let he;t[45]!==ae||t[46]!==te||t[47]!==me||t[48]!==de||t[49]!==le?(he=r.jsxs("div",{className:ae,children:[te,me,de,le]}),t[45]=ae,t[46]=te,t[47]=me,t[48]=de,t[49]=le,t[50]=he):he=t[50];let ge,ce,ve;t[51]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsx("div",{className:G(Cn,to,"empty:hidden"),children:r.jsx(y9,{})}),ce=r.jsx("div",{className:G(Cn,to,"empty:hidden"),children:r.jsx(T9,{})}),ve=G(Cn,to,"empty:hidden"),t[51]=ge,t[52]=ce,t[53]=ve):(ge=t[51],ce=t[52],ve=t[53]);let xe;t[54]!==Y?(xe=r.jsx("div",{className:ve,children:r.jsx(vP,{agentKind:Y})}),t[54]=Y,t[55]=xe):xe=t[55];let pe;t[56]===Symbol.for("react.memo_cache_sentinel")?(pe=r.jsx("div",{className:G(Cn,to,"empty:hidden"),children:r.jsx(Gd,{})}),t[56]=pe):pe=t[56];let je;t[57]!==Y||t[58]!==A?(je=A&&Ht(Y).sharing&<("share")&&r.jsx("div",{className:G(Cn,to),children:r.jsx(aP,{sessionId:A.sessionId})}),t[57]=Y,t[58]=A,t[59]=je):je=t[59];let _e;t[60]===Symbol.for("react.memo_cache_sentinel")?(_e=G(Cn,to),t[60]=_e):_e=t[60];let Re;t[61]===Symbol.for("react.memo_cache_sentinel")?(Re=r.jsx(Ln,{render:r.jsx(Z,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(Mh,{"data-icon":"inline-start"})}),t[61]=Re):Re=t[61];let De;t[62]===Symbol.for("react.memo_cache_sentinel")?(De=r.jsx(xs,{children:"Workspace"}),t[62]=De):De=t[62];let Te;t[63]!==N||t[64]!==k?(Te=N&&r.jsxs(ut,{onClick:N,children:[r.jsx(Ay,{}),"Mission Control",k&&r.jsx(ft,{className:"ml-auto"})]}),t[63]=N,t[64]=k,t[65]=Te):Te=t[65];let Ie;t[66]!==j||t[67]!==y?(Ie=j&&r.jsxs(ut,{onClick:j,children:[r.jsx(Ry,{}),"Config",y&&r.jsx(ft,{className:"ml-auto"})]}),t[66]=j,t[67]=y,t[68]=Ie):Ie=t[68];let Le;t[69]!==x||t[70]!==a?(Le=x&&r.jsxs(ut,{onClick:x,children:[r.jsx(zs,{}),"Worktrees",a&&r.jsx(ft,{className:"ml-auto"})]}),t[69]=x,t[70]=a,t[71]=Le):Le=t[71];let ze;t[72]!==Te||t[73]!==Ie||t[74]!==Le?(ze=r.jsxs(Ut,{children:[De,Te,Ie,Le]}),t[72]=Te,t[73]=Ie,t[74]=Le,t[75]=ze):ze=t[75];let Ue;t[76]===Symbol.for("react.memo_cache_sentinel")?(Ue=r.jsx(uo,{}),t[76]=Ue):Ue=t[76];let Se;t[77]!==M?(Se=M&&r.jsxs(ut,{onClick:()=>D(!0),children:[r.jsx($h,{}),"Usage & cost…"]}),t[77]=M,t[78]=Se):Se=t[78];let He;t[79]===Symbol.for("react.memo_cache_sentinel")?(He=r.jsxs(ut,{onClick:()=>$(!0),children:[r.jsx(Oh,{}),"Server monitor…"]}),t[79]=He):He=t[79];let Oe;t[80]!==oe||t[81]!==_?(Oe=_&&r.jsxs(ut,{onClick:oe,children:[r.jsx(ql,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:_})]}),t[80]=oe,t[81]=_,t[82]=Oe):Oe=t[82];let Ne;t[83]!==Se||t[84]!==Oe?(Ne=r.jsxs(Ut,{children:[Se,He,Oe]}),t[83]=Se,t[84]=Oe,t[85]=Ne):Ne=t[85];let fe;t[86]===Symbol.for("react.memo_cache_sentinel")?(fe=r.jsx(uo,{}),t[86]=fe):fe=t[86];let Pe;t[87]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsx(Iy,{}),t[87]=Pe):Pe=t[87];let Me;t[88]!==w?(Me=r.jsx(Ut,{children:r.jsxs(ut,{onClick:w,children:[Pe,"Settings"]})}),t[88]=w,t[89]=Me):Me=t[89];let Fe;t[90]!==l||t[91]!==b?(Fe=lt("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(uo,{}),r.jsx(Ut,{children:r.jsxs(ut,{variant:"destructive",onClick:b,disabled:l,children:[r.jsx(Ey,{}),l?"Stopping processes…":"Stop all agent processes"]})})]}),t[90]=l,t[91]=b,t[92]=Fe):Fe=t[92];let ne;t[93]!==ze||t[94]!==Ne||t[95]!==Me||t[96]!==Fe?(ne=r.jsx("div",{className:_e,children:r.jsxs(Dn,{children:[Re,r.jsxs(zn,{align:"end",sideOffset:6,className:"w-64",children:[ze,Ue,Ne,fe,Me,Fe]})]})}),t[93]=ze,t[94]=Ne,t[95]=Me,t[96]=Fe,t[97]=ne):ne=t[97];let ue;t[98]!==xe||t[99]!==je||t[100]!==ne?(ue=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ge,ce,xe,pe,je,ne]}),t[98]=xe,t[99]=je,t[100]=ne,t[101]=ue):ue=t[101];let ke;t[102]!==he||t[103]!==ue?(ke=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:[he,ue]}),t[102]=he,t[103]=ue,t[104]=ke):ke=t[104];let Ae;t[105]!==M||t[106]!==I?(Ae=M&&r.jsx($P,{open:I,onOpenChange:D}),t[105]=M,t[106]=I,t[107]=Ae):Ae=t[107];let $e;t[108]!==O?($e=r.jsx(z9,{open:O,onOpenChange:$}),t[108]=O,t[109]=$e):$e=t[109];let We;return t[110]!==ke||t[111]!==Ae||t[112]!==$e?(We=r.jsxs(r.Fragment,{children:[re,se,ke,Ae,$e]}),t[110]=ke,t[111]=Ae,t[112]=$e,t[113]=We):We=t[113],We});function qP(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(Z,{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(Tt,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(Et,{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(_t,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=f):f=e[13],f}function VP(n){n&&Ts.success("Copied network URL")}const GP=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(rl,{icon:So,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(rl,{icon:ln,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(rl,{icon:My,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});function YP(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(Dy,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Cp(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(Oy,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function XP(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($y,{"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}const o2=v.createContext(null);function JP(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(o2.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function r2(){const n=v.useContext(o2);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function i2(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function QP(n){const e=B.c(16),{panels:t,context:s,activePanelId:o,onTogglePanel:i}=n;let a,l,c,d;if(e[0]!==o||e[1]!==s||e[2]!==i||e[3]!==t){d=Symbol.for("react.early_return_sentinel");e:{const u=i2(t,s);if(u.length===0){d=null;break e}a="Workspace panels",l="electron-no-drag flex w-11 shrink-0 flex-col items-center gap-1 border-l bg-sidebar py-2 text-sidebar-foreground";let m;e[8]!==o||e[9]!==s||e[10]!==i?(m=p=>{var w;const h=p.id===o,g=(w=p.badge)==null?void 0:w.call(p,s),x=p.indicator,b=p.icon;return r.jsxs(_t,{children:[r.jsxs(Tt,{render:r.jsx(Z,{type:"button",variant:h?"secondary":"ghost",size:"icon-sm","aria-label":p.title,"aria-pressed":h,onClick:()=>i(p.id),className:"relative rounded-md"}),children:[r.jsx(b,{"data-icon":"inline-start"}),x?r.jsx(x,{context:s,active:h}):g!=null&&r.jsx(Ee,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:g})]}),r.jsx(Et,{side:"left",children:p.title})]},p.id)},e[8]=o,e[9]=s,e[10]=i,e[11]=m):m=e[11],c=u.map(m)}e[0]=o,e[1]=s,e[2]=i,e[3]=t,e[4]=a,e[5]=l,e[6]=c,e[7]=d}else a=e[4],l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;return e[12]!==a||e[13]!==l||e[14]!==c?(f=r.jsx("aside",{"aria-label":a,className:l,children:c}),e[12]=a,e[13]=l,e[14]=c,e[15]=f):f=e[15],f}function ZP(n){const e=B.c(20),{panels:t,context:s,activePanelId:o,onClosePanel:i,onOpenPanel:a}=n;let l;e[0]!==o?(l=()=>new Set([o]),e[0]=o,e[1]=l):l=e[1];const[c,d]=v.useState(l);let f,u;e[2]!==o?(f=()=>{d(h=>{if(h.has(o))return h;const g=new Set(h);return g.add(o),g})},u=[o],e[2]=o,e[3]=f,e[4]=u):(f=e[3],u=e[4]),v.useEffect(f,u);let m;if(e[5]!==o||e[6]!==s||e[7]!==i||e[8]!==a||e[9]!==t||e[10]!==c){let h;e[12]!==o||e[13]!==s||e[14]!==i||e[15]!==a||e[16]!==c?(h=g=>{const x=g.id===o;if(!x&&(!g.keepAlive||!c.has(g.id)))return null;const b=g.component;return r.jsx("div",{className:G("absolute inset-0 min-h-0",!x&&"hidden"),"aria-hidden":!x,children:r.jsx(b,{context:s,active:x,closePanel:i,openPanel:a})},g.id)},e[12]=o,e[13]=s,e[14]=i,e[15]=a,e[16]=c,e[17]=h):h=e[17],m=t.map(h),e[5]=o,e[6]=s,e[7]=i,e[8]=a,e[9]=t,e[10]=c,e[11]=m}else m=e[11];let p;return e[18]!==m?(p=r.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-background",children:m}),e[18]=m,e[19]=p):p=e[19],p}function eA(n){const e=n==null?void 0:n.match(/^(\d+(?:\.\d+)?)%$/);if(!e)return"64%";const t=Number(e[1]);return t>0&&t<100?`${100-t}%`:"64%"}function tA(n){const e=B.c(23),{children:t,panels:s,context:o,activePanel:i,services:a,onClosePanel:l,onOpenPanel:c,onTogglePanel:d}=n;let f;e[0]!==i?(f=i?eA(i.defaultSize):"100%",e[0]=i,e[1]=f):f=e[1];let u;e[2]!==t||e[3]!==f?(u=r.jsx(Cp,{defaultSize:f,minSize:"320px",children:t}),e[2]=t,e[3]=f,e[4]=u):u=e[4];let m;e[5]!==i||e[6]!==o||e[7]!==l||e[8]!==c||e[9]!==s||e[10]!==a?(m=i&&r.jsxs(r.Fragment,{children:[r.jsx(XP,{withHandle:!0}),r.jsx(Cp,{defaultSize:i.defaultSize??"36%",minSize:i.minSize??"300px",maxSize:i.maxSize??"70%",children:r.jsx(JP,{value:a,children:r.jsx(ZP,{panels:s,context:o,activePanelId:i.id,onClosePanel:l,onOpenPanel:c})})})]}),e[5]=i,e[6]=o,e[7]=l,e[8]=c,e[9]=s,e[10]=a,e[11]=m):m=e[11];let p;e[12]!==u||e[13]!==m?(p=r.jsxs(YP,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[u,m]}),e[12]=u,e[13]=m,e[14]=p):p=e[14];const h=(i==null?void 0:i.id)??null;let g;e[15]!==o||e[16]!==d||e[17]!==s||e[18]!==h?(g=r.jsx(QP,{panels:s,context:o,activePanelId:h,onTogglePanel:d}),e[15]=o,e[16]=d,e[17]=s,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=r.jsxs(r.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}const Xd={data:null,error:null,loading:!1,refreshing:!1},_p=new Map,nA=8e3,sA=1e4,oA=new Set(["gh_missing","gh_auth_required","no_git_repository","no_github_remote"]);function Jd(n){let e=_p.get(n);return e||(e={snapshot:Xd,listeners:new Set,request:null,fetchedAt:0},_p.set(n,e)),e}function Ol(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function a2(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`GitHub Actions request failed (${n.status})`,code:"github_api_failed"}}async function Dl(n,e=!1){const t=Jd(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&oA.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<nA))return Ol(t,{...t.snapshot,error:null,loading:t.snapshot.data===null,refreshing:t.snapshot.data!==null}),t.request=ye(`/api/github-actions?cwd=${encodeURIComponent(n)}&limit=20`).then(async s=>{if(!s.ok)throw await a2(s);const o=await s.json();t.fetchedAt=Date.now(),Ol(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;Ol(t,{...t.snapshot,error:{error:typeof o.error=="string"?o.error:"Unable to load GitHub Actions",code:typeof o.code=="string"?o.code:"github_api_failed"},loading:!1,refreshing:!1})}).finally(()=>{t.request=null}),t.request}function rA(n,e){if(!n)return()=>{};const t=Jd(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function iA(n){return n?Jd(n).snapshot:Xd}function l2(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>rA(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>iA(s),t[2]=s,t[3]=i):i=t[3];const a=v.useSyncExternalStore(o,i,aA);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;Dl(s);const m=window.setInterval(()=>{Dl(s)},sA);return()=>window.clearInterval(m)},c=[e,s],t[4]=e,t[5]=s,t[6]=l,t[7]=c):(l=t[6],c=t[7]),v.useEffect(l,c);let d;t[8]!==s?(d=()=>s?Dl(s,!0):Promise.resolve(),t[8]=s,t[9]=d):d=t[9];const f=d;let u;return t[10]!==f||t[11]!==a?(u={...a,refresh:f},t[10]=f,t[11]=a,t[12]=u):u=t[12],u}function aA(){return Xd}async function lA(n,e){const t=await ye(`/api/github-actions/jobs?cwd=${encodeURIComponent(n)}&runId=${e}`);if(!t.ok)throw await a2(t);return t.json()}const ui=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function Ws(n){return n!=="completed"}function Ba(n){return n==="action_required"||n==="failure"||n==="startup_failure"||n==="timed_out"}function c2(n,e){return n==="in_progress"?"Running":n==="queued"||n==="requested"||n==="waiting"||n==="pending"?"Queued":e==="success"?"Passed":e==="cancelled"?"Cancelled":e==="skipped"?"Skipped":e==="timed_out"?"Timed out":e==="action_required"?"Needs action":e==="neutral"||e==="stale"?"Neutral":"Failed"}function cA(n,e){return Ws(n)?"default":Ba(e)?"destructive":e==="success"?"secondary":"outline"}function dA(n){const e=Date.parse(n);if(!Number.isFinite(e))return"Unknown time";const t=Math.round((e-Date.now())/1e3);if(Math.abs(t)<60)return ui.format(t,"second");const s=Math.round(t/60);if(Math.abs(s)<60)return ui.format(s,"minute");const o=Math.round(s/60);return Math.abs(o)<24?ui.format(o,"hour"):ui.format(Math.round(o/24),"day")}function d2(n){const e=B.c(6),{status:t,conclusion:s}=n;if(t==="in_progress"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(At,{className:"size-4","aria-label":"Running"}),e[0]=i):i=e[0],i}if(Ws(t)){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(yr,{className:"size-4","aria-label":"Queued"}),e[1]=i):i=e[1],i}if(s==="success"){let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Pn,{className:"size-4","aria-label":"Passed"}),e[2]=i):i=e[2],i}if(Ba(s)){let i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ss,{className:"size-4 text-destructive","aria-label":"Failed"}),e[3]=i):i=e[3],i}if(s==="skipped"||s==="cancelled"){let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ly,{className:"size-4 text-muted-foreground","aria-label":"Skipped"}),e[4]=i):i=e[4],i}let o;return e[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Fc,{className:"size-4 text-muted-foreground","aria-label":"Completed"}),e[5]=o):o=e[5],o}function uA(n){return n.code==="gh_missing"?"Install GitHub CLI, then refresh this panel.":n.code==="gh_auth_required"?"Run `gh auth login` on the Cogpit host, then refresh.":n.code==="no_github_remote"?"Add a GitHub origin remote to this repository.":"Check the repository and your GitHub access, then try again."}function fA(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col gap-3 p-3","aria-label":"Loading workflow runs",children:[0,1,2].map(mA)}),n[0]=e):e=n[0],e}function mA(n){return r.jsxs(Dt,{size:"sm",children:[r.jsxs(Bt,{children:[r.jsx(on,{className:"h-4 w-2/3"}),r.jsx(on,{className:"h-3 w-1/2"})]}),r.jsxs(Lt,{className:"flex flex-col gap-2",children:[r.jsx(on,{className:"h-3 w-full"}),r.jsx(on,{className:"h-7 w-full"})]})]},n)}function pA(n){const e=B.c(17),{step:t}=n;let s;e[0]!==t.conclusion||e[1]!==t.status?(s=r.jsx(d2,{status:t.status,conclusion:t.conclusion}),e[0]=t.conclusion,e[1]=t.status,e[2]=s):s=e[2];const o=t.conclusion==="skipped"&&"text-muted-foreground";let i;e[3]!==o?(i=G("min-w-0 flex-1 truncate",o),e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t.name||e[6]!==i?(a=r.jsx("span",{className:i,children:t.name}),e[5]=t.name,e[6]=i,e[7]=a):a=e[7];let l;e[8]!==t.conclusion||e[9]!==t.status?(l=c2(t.status,t.conclusion),e[8]=t.conclusion,e[9]=t.status,e[10]=l):l=e[10];let c;e[11]!==l?(c=r.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:l}),e[11]=l,e[12]=c):c=e[12];let d;return e[13]!==s||e[14]!==a||e[15]!==c?(d=r.jsxs("li",{className:"flex min-w-0 items-center gap-2 py-1 text-xs",children:[s,a,c]}),e[13]=s,e[14]=a,e[15]=c,e[16]=d):d=e[16],d}function hA(n){const e=B.c(25),{job:t}=n;let s;e[0]!==t.steps?(s=t.steps.filter(xA),e[0]=t.steps,e[1]=s):s=e[1];const o=s.length;let i;e[2]!==t.conclusion||e[3]!==t.status?(i=r.jsx(d2,{status:t.status,conclusion:t.conclusion}),e[2]=t.conclusion,e[3]=t.status,e[4]=i):i=e[4];let a;e[5]!==t.name?(a=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:t.name}),e[5]=t.name,e[6]=a):a=e[6];let l;e[7]!==o||e[8]!==t.steps.length?(l=r.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[o,"/",t.steps.length]}),e[7]=o,e[8]=t.steps.length,e[9]=l):l=e[9];let c;e[10]!==i||e[11]!==a||e[12]!==l?(c=r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i,a,l]}),e[10]=i,e[11]=a,e[12]=l,e[13]=c):c=e[13];let d;e[14]!==o||e[15]!==t.name||e[16]!==t.status||e[17]!==t.steps.length?(d=Ws(t.status)&&r.jsx(Ar,{value:t.steps.length>0?Math.round(o/t.steps.length*100):null,"aria-label":`${t.name} progress`,className:"mt-2 gap-0"}),e[14]=o,e[15]=t.name,e[16]=t.status,e[17]=t.steps.length,e[18]=d):d=e[18];let f;e[19]!==t.steps?(f=t.steps.length>0&&r.jsx("ul",{className:"mt-1.5 divide-y",children:t.steps.map(gA)}),e[19]=t.steps,e[20]=f):f=e[20];let u;return e[21]!==c||e[22]!==d||e[23]!==f?(u=r.jsxs("div",{className:"rounded-lg border bg-muted/20 px-2.5 py-2",children:[c,d,f]}),e[21]=c,e[22]=d,e[23]=f,e[24]=u):u=e[24],u}function gA(n){return r.jsx(pA,{step:n},n.number)}function xA(n){return n.status==="completed"}const bA={data:null,error:null,loading:!1};function vA(n){var te,me,de;const e=B.c(102),{run:t,projectPath:s}=n,[o,i]=v.useState(!1),[a,l]=v.useState(bA);let c;e[0]!==t.status?(c=Ws(t.status),e[0]=t.status,e[1]=c):c=e[1];const d=c;let f;e[2]!==a.loading||e[3]!==s||e[4]!==t.id?(f=async function(){if(!a.loading){l(jA);try{const he=await lA(s,t.id);l({data:he,error:null,loading:!1})}catch(he){const ce=he;l({data:null,error:{error:typeof ce.error=="string"?ce.error:"Unable to load workflow jobs",code:ce.code??"github_api_failed"},loading:!1})}}},e[2]=a.loading,e[3]=s,e[4]=t.id,e[5]=f):f=e[5];const u=f;let m;e[6]!==d||e[7]!==a.data||e[8]!==u?(m=function(he){i(he),he&&(!a.data||d)&&u()},e[6]=d,e[7]=a.data,e[8]=u,e[9]=m):m=e[9];const p=m;let h;e[10]!==((te=a.data)==null?void 0:te.jobs)?(h=((me=a.data)==null?void 0:me.jobs)??[],e[10]=(de=a.data)==null?void 0:de.jobs,e[11]=h):h=e[11];const g=h;let x;e[12]!==g?(x=g.filter(wA),e[12]=g,e[13]=x):x=e[13];const b=x.length;let w;e[14]!==b||e[15]!==g.length?(w=g.length>0?Math.round(b/g.length*100):null,e[14]=b,e[15]=g.length,e[16]=w):w=e[16];const y=w;let j;e[17]!==t.displayTitle?(j=r.jsx(Vt,{className:"pr-2",children:t.displayTitle}),e[17]=t.displayTitle,e[18]=j):j=e[18];let k;e[19]!==t.name||e[20]!==t.runNumber?(k=r.jsxs(Gt,{className:"truncate",children:[t.name," #",t.runNumber]}),e[19]=t.name,e[20]=t.runNumber,e[21]=k):k=e[21];let N;e[22]!==t.conclusion||e[23]!==t.status?(N=cA(t.status,t.conclusion),e[22]=t.conclusion,e[23]=t.status,e[24]=N):N=e[24];let C;e[25]!==t.conclusion||e[26]!==t.status?(C=c2(t.status,t.conclusion),e[25]=t.conclusion,e[26]=t.status,e[27]=C):C=e[27];let S;e[28]!==C||e[29]!==N?(S=r.jsx(ad,{children:r.jsx(Ee,{variant:N,children:C})}),e[28]=C,e[29]=N,e[30]=S):S=e[30];let _;e[31]!==S||e[32]!==j||e[33]!==k?(_=r.jsxs(Bt,{children:[j,k,S]}),e[31]=S,e[32]=j,e[33]=k,e[34]=_):_=e[34];let P;e[35]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(zs,{className:"size-3"}),e[35]=P):P=e[35];const A=t.branch||"unknown branch";let T;e[36]!==A?(T=r.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[P,r.jsx("span",{className:"max-w-36 truncate",children:A})]}),e[36]=A,e[37]=T):T=e[37];let E;e[38]!==t.event?(E=r.jsx("span",{children:t.event}),e[38]=t.event,e[39]=E):E=e[39];const R=t.updatedAt;let M;e[40]!==t.updatedAt?(M=new Date(t.updatedAt).toLocaleString(),e[40]=t.updatedAt,e[41]=M):M=e[41];let I;e[42]!==t.updatedAt?(I=dA(t.updatedAt),e[42]=t.updatedAt,e[43]=I):I=e[43];let D;e[44]!==t.updatedAt||e[45]!==M||e[46]!==I?(D=r.jsx("time",{dateTime:R,title:M,children:I}),e[44]=t.updatedAt,e[45]=M,e[46]=I,e[47]=D):D=e[47];let O;e[48]!==T||e[49]!==E||e[50]!==D?(O=r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[T,E,D]}),e[48]=T,e[49]=E,e[50]=D,e[51]=O):O=e[51];let $;e[52]!==d||e[53]!==y||e[54]!==t.name?($=d&&r.jsx(Ar,{value:y,"aria-label":y===null?`${t.name} is running`:`${t.name} is ${y}% complete`,className:"gap-0"}),e[52]=d,e[53]=y,e[54]=t.name,e[55]=$):$=e[55];let L;e[56]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Z,{type:"button",variant:"ghost",size:"xs",className:"flex-1 justify-start"}),e[56]=L):L=e[56];const F=o&&"rotate-180";let z;e[57]!==F?(z=G(F),e[57]=F,e[58]=z):z=e[58];let H;e[59]!==z?(H=r.jsx(Ze,{"data-icon":"inline-start",className:z}),e[59]=z,e[60]=H):H=e[60];const U=o?"Hide jobs":"View jobs";let W;e[61]!==H||e[62]!==U?(W=r.jsxs(Jt,{render:L,children:[H,U]}),e[61]=H,e[62]=U,e[63]=W):W=e[63];const q=`Open ${t.name} run on GitHub`;let V;e[64]!==t.url?(V=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[64]=t.url,e[65]=V):V=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(zy,{}),e[66]=Y):Y=e[66];let K;e[67]!==q||e[68]!==V?(K=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs","aria-label":q,onClick:V,children:Y}),e[67]=q,e[68]=V,e[69]=K):K=e[69];let X;e[70]!==W||e[71]!==K?(X=r.jsxs("div",{className:"flex items-center gap-1",children:[W,K]}),e[70]=W,e[71]=K,e[72]=X):X=e[72];let Q;e[73]!==a.data||e[74]!==a.loading?(Q=a.loading&&!a.data&&r.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",role:"status",children:[r.jsx(At,{}),"Loading jobs…"]}),e[73]=a.data,e[74]=a.loading,e[75]=Q):Q=e[75];let J;e[76]!==a.error?(J=a.error&&r.jsxs(St,{variant:"destructive",children:[r.jsx(en,{}),r.jsx(It,{children:"Jobs unavailable"}),r.jsx(kt,{children:a.error.error})]}),e[76]=a.error,e[77]=J):J=e[77];let ee;e[78]!==g.length||e[79]!==a.data||e[80]!==a.error||e[81]!==a.loading?(ee=!a.loading&&!a.error&&a.data&&g.length===0&&r.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No jobs were reported for this run."}),e[78]=g.length,e[79]=a.data,e[80]=a.error,e[81]=a.loading,e[82]=ee):ee=e[82];let oe;e[83]!==g?(oe=g.map(yA),e[83]=g,e[84]=oe):oe=e[84];let se;e[85]!==Q||e[86]!==J||e[87]!==ee||e[88]!==oe?(se=r.jsx(wt,{children:r.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[Q,J,ee,oe]})}),e[85]=Q,e[86]=J,e[87]=ee,e[88]=oe,e[89]=se):se=e[89];let re;e[90]!==p||e[91]!==o||e[92]!==X||e[93]!==se?(re=r.jsxs(yt,{open:o,onOpenChange:p,children:[X,se]}),e[90]=p,e[91]=o,e[92]=X,e[93]=se,e[94]=re):re=e[94];let ie;e[95]!==O||e[96]!==$||e[97]!==re?(ie=r.jsxs(Lt,{className:"flex flex-col gap-2.5",children:[O,$,re]}),e[95]=O,e[96]=$,e[97]=re,e[98]=ie):ie=e[98];let ae;return e[99]!==_||e[100]!==ie?(ae=r.jsxs(Dt,{size:"sm",children:[_,ie]}),e[99]=_,e[100]=ie,e[101]=ae):ae=e[101],ae}function yA(n){return r.jsx(hA,{job:n},n.id)}function wA(n){return n.status==="completed"}function jA(n){return{...n,error:null,loading:!0}}function SA(n){var l;const e=B.c(6),{context:t}=n,{data:s}=l2(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.runs)?(o=(s==null?void 0:s.runs.filter(kA).length)??0,e[0]=s==null?void 0:s.runs,e[1]=o):o=e[1];const i=o,a=(l=s==null?void 0:s.runs[0])!=null&&l.conclusion?Ba(s.runs[0].conclusion):!1;if(i>0){const c=`${i} active GitHub Actions run${i===1?"":"s"}`;let d;return e[2]!==i||e[3]!==c?(d=r.jsx(Ee,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":c,children:i}),e[2]=i,e[3]=c,e[4]=d):d=e[4],d}if(a){let c;return e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Ee,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest GitHub Actions run failed",children:"!"}),e[5]=c):c=e[5],c}return null}function kA(n){return Ws(n.status)}function NA(n){const e=B.c(22),{activeCount:t,passedCount:s,failedCount:o}=n;let i;e[0]!==t?(i=r.jsx("div",{className:"text-sm font-semibold tabular-nums",children:t}),e[0]=t,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Active"}),e[2]=a):a=e[2];let l;e[3]!==i?(l=r.jsxs("div",{className:"text-center",children:[i,a]}),e[3]=i,e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx("div",{className:"text-sm font-semibold tabular-nums",children:s}),e[5]=s,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Passed"}),e[7]=d):d=e[7];let f;e[8]!==c?(f=r.jsxs("div",{className:"text-center",children:[c,d]}),e[8]=c,e[9]=f):f=e[9];const u=o>0&&"text-destructive";let m;e[10]!==u?(m=G("text-sm font-semibold tabular-nums",u),e[10]=u,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==m?(p=r.jsx("div",{className:m,children:o}),e[12]=o,e[13]=m,e[14]=p):p=e[14];let h;e[15]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Failed"}),e[15]=h):h=e[15];let g;e[16]!==p?(g=r.jsxs("div",{className:"text-center",children:[p,h]}),e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==l||e[20]!==f?(x=r.jsxs("div",{className:"grid shrink-0 grid-cols-3 divide-x border-b bg-muted/20 py-2",children:[l,f,g]}),e[18]=g,e[19]=l,e[20]=f,e[21]=x):x=e[21],x}function Tp(n){const e=B.c(17),{id:t,title:s,runs:o,projectPath:i}=n;if(o.length===0)return null;let a;e[0]!==t||e[1]!==s?(a=r.jsx("h3",{id:t,className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:s}),e[0]=t,e[1]=s,e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Mt,{className:"flex-1"}),e[3]=l):l=e[3];let c;e[4]!==a?(c=r.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[a,l]}),e[4]=a,e[5]=c):c=e[5];let d;if(e[6]!==i||e[7]!==o){let m;e[9]!==i?(m=p=>r.jsx(vA,{run:p,projectPath:i},p.id),e[9]=i,e[10]=m):m=e[10],d=o.map(m),e[6]=i,e[7]=o,e[8]=d}else d=e[8];let f;e[11]!==d?(f=r.jsx("div",{className:"flex flex-col gap-2",children:d}),e[11]=d,e[12]=f):f=e[12];let u;return e[13]!==t||e[14]!==c||e[15]!==f?(u=r.jsxs("section",{"aria-labelledby":t,children:[c,f]}),e[13]=t,e[14]=c,e[15]=f,e[16]=u):u=e[16],u}function CA(n){const e=B.c(29),{data:t,error:s,loading:o,projectPath:i,activeRuns:a,completedRuns:l,refresh:c}=n;if(o&&!t){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(fA,{}),e[0]=m):m=e[0],m}if(s&&!t){let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(en,{}),e[1]=m):m=e[1];let p;e[2]!==s.error?(p=r.jsx(It,{children:s.error}),e[2]=s.error,e[3]=p):p=e[3];let h;e[4]!==s?(h=uA(s),e[4]=s,e[5]=h):h=e[5];let g;e[6]!==h?(g=r.jsx("span",{children:h}),e[6]=h,e[7]=g):g=e[7];let x;e[8]!==c?(x=()=>{c()},e[8]=c,e[9]=x):x=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Wt,{"data-icon":"inline-start"}),e[10]=b):b=e[10];let w;e[11]!==x?(w=r.jsxs(Z,{type:"button",variant:"outline",size:"xs",onClick:x,children:[b,"Try again"]}),e[11]=x,e[12]=w):w=e[12];let y;e[13]!==g||e[14]!==w?(y=r.jsxs(kt,{className:"flex flex-col items-start gap-2",children:[g,w]}),e[13]=g,e[14]=w,e[15]=y):y=e[15];let j;return e[16]!==p||e[17]!==y?(j=r.jsx("div",{className:"p-3",children:r.jsxs(St,{variant:"destructive",children:[m,p,y]})}),e[16]=p,e[17]=y,e[18]=j):j=e[18],j}if(t&&t.runs.length===0){let m;return e[19]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(In,{className:"border-0",children:r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:r.jsx(la,{})}),r.jsx($n,{children:"No workflow runs"}),r.jsx(On,{children:"GitHub has not reported any Actions runs for this repository."})]})}),e[19]=m):m=e[19],m}if(!t||!i)return null;let d;e[20]!==a||e[21]!==i?(d=r.jsx(Tp,{id:"active-workflow-runs",title:"Active",runs:a,projectPath:i}),e[20]=a,e[21]=i,e[22]=d):d=e[22];let f;e[23]!==l||e[24]!==i?(f=r.jsx(Tp,{id:"recent-workflow-runs",title:"Recent",runs:l,projectPath:i}),e[23]=l,e[24]=i,e[25]=f):f=e[25];let u;return e[26]!==d||e[27]!==f?(u=r.jsx(To,{className:"min-h-0 flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-3",children:[d,f]})}),e[26]=d,e[27]=f,e[28]=u):u=e[28],u}function _A(n){const e=B.c(41),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=l2(t.projectPath,s);let f,u,m,p;if(e[0]!==(i==null?void 0:i.runs)){const R=(i==null?void 0:i.runs)??[];f=R.filter(AA),u=R.filter(PA),m=u.filter(EA).length,p=u.filter(TA),e[0]=i==null?void 0:i.runs,e[1]=f,e[2]=u,e[3]=m,e[4]=p}else f=e[1],u=e[2],m=e[3],p=e[4];const h=p.length,g=t.projectPath;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("div",{className:"flex size-7 items-center justify-center rounded-md bg-muted",children:r.jsx(bh,{className:"size-4"})}),e[5]=x):x=e[5];let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"GitHub Actions"}),e[6]=b):b=e[6];const w=(i==null?void 0:i.repository)??"Current repository";let y;e[7]!==w?(y=r.jsxs("div",{className:"min-w-0 flex-1",children:[b,r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:w})]}),e[7]=w,e[8]=y):y=e[8];let j;e[9]!==d?(j=()=>{d()},e[9]=d,e[10]=j):j=e[10];const k=l||c||!g;let N;e[11]!==c?(N=c?r.jsx(At,{}):r.jsx(Wt,{}),e[11]=c,e[12]=N):N=e[12];let C;e[13]!==j||e[14]!==k||e[15]!==N?(C=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:j,disabled:k,"aria-label":"Refresh GitHub Actions",children:N}),e[13]=j,e[14]=k,e[15]=N,e[16]=C):C=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Nt,{}),e[17]=S):S=e[17];let _;e[18]!==o?(_=r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close GitHub Actions",children:S}),e[18]=o,e[19]=_):_=e[19];let P;e[20]!==_||e[21]!==y||e[22]!==C?(P=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-3",children:[x,y,C,_]}),e[20]=_,e[21]=y,e[22]=C,e[23]=P):P=e[23];let A;e[24]!==f||e[25]!==i||e[26]!==h||e[27]!==m?(A=i&&r.jsx(NA,{activeCount:f.length,passedCount:m,failedCount:h}),e[24]=f,e[25]=i,e[26]=h,e[27]=m,e[28]=A):A=e[28];let T;e[29]!==f||e[30]!==u||e[31]!==i||e[32]!==a||e[33]!==l||e[34]!==g||e[35]!==d?(T=r.jsx(CA,{data:i,error:a,loading:l,projectPath:g,activeRuns:f,completedRuns:u,refresh:d}),e[29]=f,e[30]=u,e[31]=i,e[32]=a,e[33]=l,e[34]=g,e[35]=d,e[36]=T):T=e[36];let E;return e[37]!==P||e[38]!==A||e[39]!==T?(E=r.jsxs("section",{className:"flex size-full min-h-0 flex-col","aria-label":"GitHub Actions panel",children:[P,A,T]}),e[37]=P,e[38]=A,e[39]=T,e[40]=E):E=e[40],E}function TA(n){return Ba(n.conclusion)}function EA(n){return n.conclusion==="success"}function PA(n){return!Ws(n.status)}function AA(n){return Ws(n.status)}const RA={id:"github-actions",workspacePanels:[{id:"runs",title:"GitHub Actions",icon:la,component:_A,indicator:SA,order:40,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},IA=[RA],jc=new Map;let Ll=null,zl=null;async function MA(){try{const n=await ye("/api/usage-cost/rates");if(!n.ok)return jc;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return jc}}function u2(){const[n,e]=v.useState(Ll??jc);return v.useEffect(()=>{if(Ll!==null)return;let t=!0;return zl??(zl=MA().then(s=>(s.size>0&&(Ll=s),zl=null,s))),zl.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function $A(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=pw(t),f=hw(t),u=Math.max(d+f,((x=t.tokenUsage)==null?void 0:x.output_tokens)??0),m=t.tokenUsage?s2(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 OA(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=tt(t.totalInput),e[2]=t.totalInput,e[3]=o):o=e[3];let i;e[4]!==o?(i=r.jsx("span",{className:"text-info",children:o}),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==t.cacheRead?(a=tt(t.cacheRead),e[6]=t.cacheRead,e[7]=a):a=e[7];let l;e[8]!==t.cacheWrite?(l=tt(t.cacheWrite),e[8]=t.cacheWrite,e[9]=l):l=e[9];let c;e[10]!==t.newInput?(c=tt(t.newInput),e[10]=t.newInput,e[11]=c):c=e[11];let d;e[12]!==a||e[13]!==l||e[14]!==c?(d=r.jsxs("span",{className:"ml-1 opacity-60",children:["(",a," cached, ",l," written, ",c," new)"]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d):d=e[15];let f;e[16]!==i||e[17]!==d?(f=r.jsxs("span",{children:["Input: ",i,d]}),e[16]=i,e[17]=d,e[18]=f):f=e[18];let u;e[19]!==t.totalOutput?(u=tt(t.totalOutput),e[19]=t.totalOutput,e[20]=u):u=e[20];let m;e[21]!==u?(m=r.jsx("span",{className:"text-success",children:u}),e[21]=u,e[22]=m):m=e[22];let p;e[23]!==t.thinkingTokens||e[24]!==t.visibleTokens?(p=t.thinkingTokens>0&&r.jsxs("span",{className:"ml-1 opacity-60",children:["(",tt(t.thinkingTokens)," thinking, ",tt(t.visibleTokens)," text)"]}),e[23]=t.thinkingTokens,e[24]=t.visibleTokens,e[25]=p):p=e[25];let h;e[26]!==m||e[27]!==p?(h=r.jsxs("span",{children:["Output: ",m,p]}),e[26]=m,e[27]=p,e[28]=h):h=e[28];let g;e[29]!==t.cost?(g=t.cost>0&&r.jsxs("span",{children:["API cost: ",r.jsx("span",{className:"text-warning",children:ls(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 DA(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 LA(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 f2=280,Sc=130,Ci=16,zA=22,Ps=36,FA=8,fi=f2-Ps-FA,Ep=Sc-Ci-zA;function BA(n){const e=B.c(34),{turns:t}=n,[s,o]=v.useState(null),i=u2();let a;e[0]!==i||e[1]!==t?(a=$A(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(WA),...l.map(UA)),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,fi/l.length)),u=Math.max(2,(f-1)/2),m=Ci+Ep,p=s!==null?l[s]:null;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ts,{children:"Input / Output Per Turn"}),e[5]=h):h=e[5];let g;e[6]!==p?(g=p&&r.jsx(OA,{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=tt(d),e[9]=d,e[10]=b):b=e[10];let w;e[11]!==b?(w=r.jsx("text",{x:Ps-4,y:Ci,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:Ps-4,y:m,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:"0"}),j=r.jsx("line",{x1:Ps,y1:m,x2:Ps+fi,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=Ps+(l.length===1?(fi-f)/2:A/(l.length-1)*(fi-f));return r.jsx(LA,{data:P,groupX:T,barW:u,groupW:f,baseY:m,chartH:Ep,maxVal:d,isHovered:s===A,onHover:()=>o(A),padTop:Ci},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(DA,{padLeft:Ps,svgHeight:Sc}),e[27]=N):N=e[27];let C;e[28]!==k||e[29]!==w?(C=r.jsxs("svg",{width:"100%",viewBox:`0 0 ${f2} ${Sc}`,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 UA(n){return n.totalOutput}function WA(n){return n.totalInput}const Pp=280,Ap=32;function HA(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(KA)),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,Pp/t.length)),c=l*t.length;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(ts,{children:"Activity Heatmap"}),e[2]=d):d=e[2];const f=`0 0 ${Math.max(Pp,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 KA(n){return n.toolCalls.length}function qA(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(GA),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(ts,{children:"Models"}),e[2]=i):i=e[2];let a;e[3]!==o?(a=o.map(VA),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 VA(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 GA(n,e){const[,t]=n,[,s]=e;return s-t}const YA=["agent","skill","plugin","mcpServer","mcpTool"],XA={agent:"Agents",skill:"Skills",plugin:"Plugins",mcpServer:"MCP servers",mcpTool:"MCP tools"},mi="Unattributed";function Rp(n){return n.inputTokens+n.outputTokens}function JA(n,e){var i;const t=new Map;for(const a of n){const l=((i=a.attribution)==null?void 0:i[e])??mi;let c=t.get(l);c||(c={name:l,turns:0,inputTokens:0,outputTokens:0,isUnattributed:l===mi},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(mi);s&&t.delete(mi);const o=[...t.values()].sort((a,l)=>Rp(l)-Rp(a));return s&&o.push(s),o}function QA(n){return YA.filter(e=>n.some(t=>{var s;return(s=t.attribution)==null?void 0:s[e]}))}function ZA(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=tt(t.inputTokens),e[0]=t.inputTokens,e[1]=f):f=e[1];let u;e[2]!==t.outputTokens?(u=tt(t.outputTokens),e[2]=t.outputTokens,e[3]=u):u=e[3];const m=`${c} — ${d} ${t.turns===1?"turn":"turns"}, ${f} input, ${u} output`,p=t.isUnattributed?"truncate text-muted-foreground":"truncate text-foreground";let h;e[4]!==t.name||e[5]!==p?(h=r.jsx("span",{className:p,children:t.name}),e[4]=t.name,e[5]=p,e[6]=h):h=e[6];const g=t.turns===1?"turn":"turns";let 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=tt(o),e[11]=o,e[12]=w):w=e[12];let y;e[13]!==w?(y=r.jsx("span",{children:w}),e[13]=w,e[14]=y):y=e[14];let j;e[15]!==y||e[16]!==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 R;e[31]!==_||e[32]!==E?(R=r.jsxs("div",{className:"mt-1.5 flex h-1 gap-[2px]","aria-hidden":"true",children:[_,E]}),e[31]=_,e[32]=E,e[33]=R):R=e[33];let M;return e[34]!==k||e[35]!==R||e[36]!==m?(M=r.jsxs("li",{className:"rounded-md border bg-card px-2.5 py-1.5",title:m,children:[k,R]}),e[34]=k,e[35]=R,e[36]=m,e[37]=M):M=e[37],M}function eR(){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 tR(n){const e=B.c(25),{turns:t}=n;let s;e[0]!==t?(s=QA(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?JA(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(sR)),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(ts,{children:"Attribution"}),e[10]=p):p=e[10];let h;e[11]!==c||e[12]!==o?(h=o.length>1&&r.jsx(g0,{"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(nR)}),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(ZA,{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(eR,{}),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 nR(n){return r.jsx(x0,{value:n,children:XA[n]},n)}function sR(n){return n.inputTokens+n.outputTokens}function oR(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 rR(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=oR(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(ts,{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(Z,{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 Ip(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||Od(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(Pn,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(Ss,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(Fc,{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(Ee,{variant:"outline",children:g}),e[10]=g,e[11]=N):N=e[11];let C;e[12]!==l?(C=l&&r.jsx(Ee,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let S;e[14]!==a?(S=a&&r.jsx(Ee,{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(yr,{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(ta,{className:"size-2.5","data-icon":"inline-start"}),f," tools"]})]}),e[26]=b,e[27]=f,e[28]=E):E=e[28];let R;e[29]!==u||e[30]!==m||e[31]!==A||e[32]!==T||e[33]!==E?(R=r.jsxs(Z,{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]=R):R=e[34];let M;e[35]!==g||e[36]!==p?(M=p&&r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(Nt,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=M):M=e[37];let I;return e[38]!==R||e[39]!==M||e[40]!==k?(I=r.jsxs("div",{className:k,children:[R,M]}),e[38]=R,e[39]=M,e[40]=k,e[41]=I):I=e[41],I}function iR(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 kc(n){return n.split(`
|
|
123
|
+
`).map(e=>e.trim()).find(Boolean)??""}function aR(n){return n.name==="Task"||n.name==="Agent"}function lR(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=iR(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:kc(((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(!aR(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:kc(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 cR({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=Md(),i=v.useMemo(()=>{if(!e)return null;const w=bs(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=v.useMemo(()=>lR(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(ts,{children:["Agents (",g,")"]}),i&&s&&r.jsxs(Z,{type:"button",variant:"outline",size:"sm",onClick:()=>s(i.dirName,i.parentFileName),className:"mb-2 w-full justify-start",children:[r.jsx(Je,{"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=kc(w.preview??""),k=u.get(w.agentId);return r.jsx(Ip,{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(Ip,{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 dR(n,e){return`${n.id}-${e}`}function uR(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(ts,{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=Pa(u.userMessage),h=o===m;return r.jsxs(Z,{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(Ee,{variant:"secondary",className:"font-normal",children:u.toolCalls.length})})]},dR(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 fR(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(e7(n),40)}function mR(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:s2(e,t.model,s)/t.toolCalls.length})}function pR(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 hR(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=u2();let i;e[0]!==o||e[1]!==t?(i=mR(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=pR(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(ts,{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(yt,{children:[r.jsxs(Jt,{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(Je,{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:ls(g.estimatedCost)}),r.jsx(Ee,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(wt,{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=fR(w);return r.jsx("div",{children:r.jsxs(Z,{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(yn,{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 gR(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Ot(),{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(ia,{"data-icon":"inline-start"}):r.jsx(ra,{"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(Z,{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(ss,{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(vn,{align:"inline-start",children:r.jsx(ln,{})}),e[13]=x):x=e[13];let b;e[14]!==g?(b=r.jsxs(ns,{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 m2=v.memo(function(e){const t=B.c(40),{embedded:s,onJumpToTurn:o,onToggleServer:i,onServersChanged:a,searchInputRef:l,onLoadSession:c,backgroundAgents:d}=e,f=s===void 0?!1:s,{isMobile:u}=Ot(),{session:m,sessionSource:p}=it(),h=m,{turns:g}=h,x=u?"mobile-scroll w-full flex-1":f?"w-full":"view-transition-right-panel panel-enter-right w-[320px] border-l";let b;t[0]!==x?(b=G("h-full min-h-0 shrink-0 overflow-y-auto bg-background",x),t[0]=x,t[1]=b):b=t[1];let w;t[2]!==l?(w=l&&r.jsx(gR,{searchInputRef:l}),t[2]=l,t[3]=w):w=t[3];const y=u?"p-4":"p-3";let j;t[4]!==y?(j=G(y),t[4]=y,t[5]=j):j=t[5];let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsxs(Wg,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(Fo,{value:"activity",children:"Activity"}),r.jsx(Fo,{value:"agents",children:"Agents"}),r.jsx(Fo,{value:"metrics",children:"Metrics"}),r.jsx(Fo,{value:"issues",children:"Issues"})]}),t[6]=k):k=t[6];let N;t[7]!==o||t[8]!==g?(N=r.jsxs(Bo,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(uR,{turns:g,onJumpToTurn:o}),r.jsx(hR,{turns:g,onJumpToTurn:o})]}),t[7]=o,t[8]=g,t[9]=N):N=t[9];let C;t[10]!==a||t[11]!==i||t[12]!==h.cwd||t[13]!==g?(C=r.jsx(Vg,{cwd:h.cwd,turns:g,onToggleServer:i,onServersChanged:a}),t[10]=a,t[11]=i,t[12]=h.cwd,t[13]=g,t[14]=C):C=t[14];let S;t[15]!==d?(S=d??[],t[15]=d,t[16]=S):S=t[16];let _;t[17]!==c||t[18]!==h||t[19]!==p||t[20]!==S?(_=r.jsx(cR,{session:h,sessionSource:p,bgAgents:S,onLoadSession:c}),t[17]=c,t[18]=h,t[19]=p,t[20]=S,t[21]=_):_=t[21];let P;t[22]!==_||t[23]!==C?(P=r.jsxs(Bo,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[C,_]}),t[22]=_,t[23]=C,t[24]=P):P=t[24];let A;t[25]!==g?(A=r.jsxs(Bo,{value:"metrics",className:"flex flex-col gap-6 pt-3",children:[r.jsx(BA,{turns:g}),r.jsx(HA,{turns:g}),r.jsx(qA,{turns:g}),r.jsx(tR,{turns:g})]}),t[25]=g,t[26]=A):A=t[26];let T;t[27]!==o||t[28]!==g?(T=r.jsx(Bo,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(rR,{turns:g,onJumpToTurn:o})}),t[27]=o,t[28]=g,t[29]=T):T=t[29];let E;t[30]!==P||t[31]!==A||t[32]!==T||t[33]!==j||t[34]!==N?(E=r.jsxs(Ug,{defaultValue:"activity",className:j,children:[k,N,P,A,T]}),t[30]=P,t[31]=A,t[32]=T,t[33]=j,t[34]=N,t[35]=E):E=t[35];let R;return t[36]!==E||t[37]!==b||t[38]!==w?(R=r.jsxs("aside",{className:b,children:[w,E]}),t[36]=E,t[37]=b,t[38]=w,t[39]=R):R=t[39],R}),xR=v.lazy(()=>Ke(()=>import("./ProjectFilesPanel-ByyaiSGy.js"),__vite__mapDeps([31,1,32,2,3,4])).then(n=>({default:n.ProjectFilesPanel})));function bR(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[r.jsx(At,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function vR(n){const e=B.c(6),{context:t,closePanel:s}=n,o=r2(),i=o.projectFilesRoot??t.projectPath;if(!i)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(bR,{}),e[0]=a):a=e[0];let l;return e[1]!==s||e[2]!==i||e[3]!==o.addProjectContext||e[4]!==o.projectFilesRequest?(l=r.jsx(v.Suspense,{fallback:a,children:r.jsx(xR,{cwd:i,onClose:s,onAddToPrompt:o.addProjectContext,openRequest:o.projectFilesRequest,embedded:!0},i)}),e[1]=s,e[2]=i,e[3]=o.addProjectContext,e[4]=o.projectFilesRequest,e[5]=l):l=e[5],l}function yR(n){const e=B.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=r.jsx(w8,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function wR(){const n=B.c(7),e=r2();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=r.jsx(m2,{embedded:!0,onJumpToTurn:e.jumpToTurn,onToggleServer:e.toggleServer,onServersChanged:e.serversChanged,searchInputRef:e.searchInputRef,onLoadSession:e.loadSession,backgroundAgents:e.backgroundAgents}),n[0]=e.backgroundAgents,n[1]=e.jumpToTurn,n[2]=e.loadSession,n[3]=e.searchInputRef,n[4]=e.serversChanged,n[5]=e.toggleServer,n[6]=t):t=n[6],t}const jR={id:Ni,workspacePanels:[{id:"project-files",title:"Project files",icon:Fy,component:vR,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"file-changes",title:"File changes",icon:wr,component:yR,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:By,component:wR,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},SR=HE([jR,...IA]);function Ua(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 p2(n){const e=B.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?qn(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:pa(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 kR(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 NR(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 Mp(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 CR(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=jh,s="a",o=wh({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 _R(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 TR(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(Je,{}),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 h2(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(Ra,{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(fo,{children:[l&&r.jsxs(Zt,{onClick:x,children:[r.jsx(Fs,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(Zt,{onClick:i,children:[r.jsx(An,{"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(mr,{}),r.jsx(fo,{children:r.jsxs(Zt,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(na,{"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(Ia,{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(Aa,{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(sd,{children:"Delete session?"}),e[19]=C):C=e[19];let S;e[20]!==s?(S=r.jsxs(td,{children:[C,r.jsxs(od,{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(id,{size:"sm",children:"Cancel"}),e[22]=_):_=e[22];let P;e[23]!==a?(P=r.jsxs(nd,{children:[_,r.jsx(rd,{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(ed,{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(Zc,{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(Ns,{children:[r.jsx(Zn,{className:"text-foreground",children:"Rename session"}),r.jsx(es,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[31]=E):E=e[31];let R;e[32]!==l||e[33]!==m?(R=z=>{z.preventDefault(),l==null||l(m),u(!1)},e[32]=l,e[33]=m,e[34]=R):R=e[34];let M;e[35]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(xt,{htmlFor:"session-rename",children:"Session name"}),e[35]=M):M=e[35];let I;e[36]===Symbol.for("react.memo_cache_sentinel")?(I=z=>p(z.target.value),e[36]=I):I=e[36];let D;e[37]!==m||e[38]!==s?(D=r.jsxs(gt,{children:[M,r.jsx(zt,{id:"session-rename",ref:h,value:m,onChange:I,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=D):D=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsxs(Ng,{children:[r.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(!1),children:"Cancel"}),r.jsx(Z,{type:"submit",size:"sm",children:"Save"})]}),e[40]=O):O=e[40];let $;e[41]!==R||e[42]!==D?($=r.jsxs(Qn,{className:"sm:max-w-md",children:[E,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:R,children:[D,O]})]}),e[41]=R,e[42]=D,e[43]=$):$=e[43];let L;e[44]!==f||e[45]!==$?(L=r.jsx(Jn,{open:f,onOpenChange:u,children:$}),e[44]=f,e[45]=$,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 g2="session-custom-names";function x2(){try{const n=localStorage.getItem(Ft(g2));return n?JSON.parse(n):{}}catch{return{}}}function ER(n){localStorage.setItem(Ft(g2),JSON.stringify(n))}let Vi=x2();const Gi=new Set;if(typeof window<"u"){const n=()=>{Vi=x2();for(const e of Gi)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function PR(n){return Gi.add(n),()=>{Gi.delete(n)}}function AR(){return Vi}function Nc(n,e){const t={...Vi},s=e.trim();s?t[n]=s:delete t[n],ER(t),Vi=t;for(const o of Gi)o()}function b2(){const n=B.c(2),e=v.useSyncExternalStore(PR,AR);let t;return n[0]!==e?(t={names:e,rename:Nc},n[0]=e,n[1]=t):t=n[1],t}function v2(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(vn,{children:a?r.jsx(rt,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(ln,{"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(ss,{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(vn,{align:"inline-end",children:r.jsx(Rr,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(Nt,{})})}),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(ns,{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 y2(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(yn,{"aria-hidden":"true"}),i=r.jsx(It,{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(kt,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Wt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(ys,{children:r.jsxs(Z,{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(St,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function w2(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(Mt,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(on,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(on,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(on,{className:"h-3 w-72 max-w-full"}),r.jsx(on,{className:"h-3 w-52 max-w-full"})]}),r.jsx(on,{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 xr(n){return n==="idle"||n==="completed"}function Qd(n){return xr(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"},RR=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,IR=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,MR=/(?:^|\s)#(\d+)(?=\s|$)/,$R=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function pi(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function OR(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 j2(n){const e=n.trim();if(!e)return null;const t=RR.exec(e);if(t){const l=pi(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=IR.exec(e);if(s){const l=pi(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=MR.exec(e);if(o){const l=pi(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:OR(c)}}const i=$R.exec(e);if(!i)return null;const a=pi(i[1]);return a===null?null:{number:a,repoHint:null}}function $p(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function DR(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 LR(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?$p(n.repo,s):$p(n.repo,s)?!0:t.some(o=>DR(o,s)):!0}function S2(n,e,t=[]){var i;const s=j2(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>LR(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 zR=120*1e3;function k2(n){return n?Date.now()-new Date(n).getTime()<zR:!1}function N2(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 Op(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function FR(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Op(t)===Op(e)?null:pn(t,220)}function BR(n,e){return S2(n,e)}function UR(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?En(t):null}function WR(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(`
|
|
124
|
+
`)}function HR(n){var t;const e=n.cwd?(t=ha(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:Uy,label:e,title:n.cwd}:n.gitBranch?{icon:zs,label:n.gitBranch}:null}function KR(n,e){return n.agentStatus==="deferred"?"attention":e?xr(n.agentStatus)?"idle":"working":null}function qR(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(Ee,{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=xr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=zr(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=Qd(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(Ee,{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=Hd(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Ee,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function Fl(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 VR(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=k2(i),l=KR(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 D=HR(t);let O;e[25]!==i||e[26]!==t.timestamp?(O=UR(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=O):O=e[27];const $=O,L=t.turnCount??0;let F,z;e[28]!==s||e[29]!==t?(z=N2(t,s),F=FR(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=WR(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(lf,{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 q;e[39]!==z?(q=r.jsx("span",{className:"truncate text-sm font-medium",children:z}),e[39]=z,e[40]=q):q=e[40];let V;e[41]!==d?(V=d&&r.jsxs(Ee,{variant:"outline",className:"shrink-0",children:[r.jsx(mo,{"data-icon":"inline-start"}),pn(d,18)]}),e[41]=d,e[42]=V):V=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Ee,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(Bc,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let K;e[45]!==a||e[46]!==t?(K=r.jsx(qR,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=K):K=e[47];let X;e[48]!==i?(X=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Cr(i)}),e[48]=i,e[49]=X):X=e[49];let Q;e[50]!==K||e[51]!==X?(Q=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[K,X]}),e[50]=K,e[51]=X,e[52]=Q):Q=e[52],e[53]!==q||e[54]!==V||e[55]!==Y||e[56]!==Q?(N=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[q,V,Y,Q]}),e[53]=q,e[54]=V,e[55]=Y,e[56]=Q,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(Ee,{variant:"outline",children:Nr(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==L?(w=L>0&&r.jsxs(Fl,{icon:lf,children:[L," ",L===1?"turn":"turns"]}),e[62]=L,e[63]=w):w=e[63],e[64]!==$?(y=$&&r.jsx(Fl,{icon:$s,title:"First prompt to last activity",children:$}),e[64]=$,e[65]=y):y=e[65],j=D&&r.jsx(Fl,{icon:D.icon,className:"max-w-40 truncate",title:D.title,children:pn(D.label,22)}),e[4]=s,e[5]=c,e[6]=i,e[7]=a,e[8]=o,e[9]=t,e[10]=d,e[11]=f,e[12]=u,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=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=lg(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(Ee,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Fa,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=E):E=e[91];let R;e[92]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Je,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=R):R=e[92];let M;e[93]!==E?(M=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[E,R]}),e[93]=E,e[94]=M):M=e[94];let I;return e[95]!==g||e[96]!==T||e[97]!==M?(I=r.jsxs("div",{className:g,children:[T,M]}),e[95]=g,e[96]=T,e[97]=M,e[98]=I):I=e[98],I}function GR(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}=b2();let k;e[0]!==t.path?(k=qn(t.path),e[0]=t.path,e[1]=k):k=e[1];const N=k;let C;e[2]!==x?(C=r.jsx(Mp,{children:r.jsx(CR,{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(TR,{}),e[4]=S):S=e[4];let _;e[5]!==N?(_=r.jsx(Mp,{className:"min-w-0",children:r.jsx(_R,{className:"truncate",children:N})}),e[5]=N,e[6]=_):_=e[6];let P;e[7]!==C||e[8]!==_?(P=r.jsx(kR,{children:r.jsxs(NR,{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(Ee,{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 R;e[17]!==t.path?(R=pa(t.path),e[17]=t.path,e[18]=R):R=e[18];let M;e[19]!==R?(M=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:R}),e[19]=R,e[20]=M):M=e[20];let I;e[21]!==M||e[22]!==E?(I=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[E,M]}),e[21]=M,e[22]=E,e[23]=I):I=e[23];let D;e[24]!==l||e[25]!==a||e[26]!==c?(D=r.jsx(v2,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:a}),e[24]=l,e[25]=a,e[26]=c,e[27]=D):D=e[27];let O;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(O=m&&r.jsxs(Z,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(At,{"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]=O):O=e[32];let $;e[33]!==D||e[34]!==O?($=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[D,O]}),e[33]=D,e[34]=O,e[35]=$):$=e[35];let L;e[36]!==f||e[37]!==b?(L=f&&r.jsx(y2,{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(w2,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(In,{className:"min-h-72 border",children:r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:r.jsx(aa,{})}),r.jsx($n,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(On,{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(Mt,{}),r.jsx(h2,{sessionLabel:N2(U),customName:y[U.sessionId],onRename:q=>j(U.sessionId,q),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(VR,{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(Z,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(At,{"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]!==$||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[$,L,F]}),e[53]=$,e[54]=L,e[55]=F,e[56]=z):z=e[56];let H;return e[57]!==I||e[58]!==z||e[59]!==P?(H=r.jsx(To,{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,I,z]})}),e[57]=I,e[58]=z,e[59]=P,e[60]=H):H=e[60],H}function YR(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=kr(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 C2(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 R;return(R=u.current)==null?void 0:R.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(Ra,{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(Fs,{"data-icon":"inline-start"}),e[9]=b):b=e[9];let w;e[10]!==p?(w=r.jsx(Ia,{className:"min-w-44",children:r.jsx(fo,{children:r.jsxs(Zt,{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(Aa,{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(Ns,{children:[r.jsx(Zn,{className:"text-foreground",children:"Rename project"}),r.jsx(es,{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(zt,{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(Ng,{children:[r.jsx(Z,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(Z,{type:"submit",size:"sm",children:"Save"})]}),e[24]=_):_=e[24];let P;e[25]!==S||e[26]!==k?(P=r.jsxs(Qn,{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(Jn,{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 _2="project-custom-names";function T2(){try{const n=localStorage.getItem(Ft(_2));return n?JSON.parse(n):{}}catch{return{}}}function XR(n){localStorage.setItem(Ft(_2),JSON.stringify(n))}let Yi=T2();const Xi=new Set;if(typeof window<"u"){const n=()=>{Yi=T2();for(const e of Xi)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function JR(n){return Xi.add(n),()=>{Xi.delete(n)}}function QR(){return Yi}function ZR(n,e){const t={...Yi},s=e.trim();s?t[n]=s:delete t[n],XR(t),Yi=t;for(const o of Xi)o()}function E2(){const n=B.c(2),e=v.useSyncExternalStore(JR,QR);let t;return n[0]!==e?(t={names:e,rename:ZR},n[0]=e,n[1]=t):t=n[1],t}function eI(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 I of s)k2(I.lastModified)&&(m[I.dirName]=(m[I.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=E2();let x;e:{if(!a){x=t;break e}let I;if(e[2]!==h||e[3]!==t||e[4]!==a){const D=a.toLowerCase();I=t.filter(O=>{var $;return O.path.toLowerCase().includes(D)||O.shortName.toLowerCase().includes(D)||(($=h[O.dirName])==null?void 0:$.toLowerCase().includes(D))}),e[2]=h,e[3]=t,e[4]=a,e[5]=I}else I=e[5];x=I}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(Ee,{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(v2,{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(Wt,{"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(Z,{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(y2,{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(w2,{}):b.length===0?r.jsx(In,{className:"min-h-72 border",children:r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:r.jsx(ho,{})}),r.jsx($n,{children:a?"No projects match your search":"No projects yet"}),r.jsx(On,{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((I,D)=>{const O=p[I.dirName]||0,$=h[I.dirName],L=Cw(Ct(I.dirName));return r.jsxs(v.Fragment,{children:[D>0&&r.jsx(Mt,{}),r.jsx(C2,{projectLabel:qn(I.path),customName:$,onRename:F=>g(I.dirName,F),children:r.jsxs("button",{type:"button",onClick:()=>f==null?void 0:f(I.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(YR,{projectPath:I.path,className:"size-4",fallback:r.jsx(ho,{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:$||qn(I.path)}),L&&r.jsx(Ee,{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:pa(I.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[O>0&&r.jsxs(Ee,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),O," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[I.sessionCount," ",I.sessionCount===1?"session":"sessions"]}),I.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Cr(I.lastModified)}),r.jsx(Je,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},I.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 R;e[38]!==A||e[39]!==T||e[40]!==E?(R=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]=R):R=e[41];let M;return e[42]!==R||e[43]!==k?(M=r.jsx(To,{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,R]})}),e[42]=R,e[43]=k,e[44]=M):M=e[44],M}const tI=250,nI=400,Dp={results:null,loading:!1,error:null};function P2(n,e){const t=v.useMemo(()=>j2(n),[n]),[s,o]=v.useState(0),[i,a]=v.useState(Dp);v.useEffect(()=>{if(!t){a(Dp);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()},nI);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()},tI);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 sI=v.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=v.useState(()=>({projects:Di(Kn.projects),activeSessions:Di(Kn.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),R=v.useRef(null),M=v.useCallback(async(U=!1)=>{U&&x(!0);try{const[W,q]=await Promise.all([ye("/api/projects"),ye("/api/active-sessions")]);if(!W.ok||!q.ok)throw new Error("Failed to fetch dashboard data");const V=await W.json(),Y=await q.json(),K=Array.isArray(V)?V:[],X=Array.isArray(Y)?Y:[];f(K),m(X),Xo(Kn.projects,K),Xo(Kn.activeSessions,X),T(null)}catch(W){T(W instanceof Error?W.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);v.useEffect(()=>{M()},[M]);const I=v.useCallback(async(U,W=1,q=!1)=>{var X;const V=++E.current;(X=R.current)==null||X.abort();const Y=new AbortController;R.current=Y;const K=()=>V===E.current;if(S(!0),T(null),!q){const Q=I_(U);Q?(w(Q.sessions),j(Q.total),N(1)):w([])}try{const Q=await ye(`/api/sessions/${encodeURIComponent(U)}?page=${W}&limit=20`,{signal:Y.signal});if(!Q.ok)throw new Error(`Failed to load sessions (${Q.status})`);const J=await Q.json();if(!K())return;const ee=Array.isArray(J.sessions)?J.sessions:[],oe=typeof J.total=="number"?J.total:ee.length;w(se=>q?[...se,...ee]:ee),j(oe),N(W),q||M_(U,{sessions:ee,total:oe})}catch(Q){if(!K()||Y.signal.aborted)return;T(Q instanceof Error?Q.message:"Failed to load sessions")}finally{K()&&(R.current=null,S(!1))}},[]);v.useEffect(()=>{var U;if(!o){E.current+=1,(U=R.current)==null||U.abort(),R.current=null,w([]),j(0),N(1),P(""),S(!1);return}P(""),I(o)},[o,I]),v.useEffect(()=>()=>{var U;E.current+=1,(U=R.current)==null||U.abort()},[]);const D=v.useMemo(()=>{if(!o)return null;const U=d.find(q=>q.dirName===o);if(U)return U;const W=gn(o);return{dirName:o,path:W,shortName:qn(W),sessionCount:y,lastModified:null}},[o,d,y]),O=v.useCallback(()=>{i==null||i(null)},[i]),$=v.useCallback(()=>{o&&I(o,k+1,!0)},[o,k,I]),L=P2(o?_:"",o??void 0),F=v.useMemo(()=>_?b.filter(U=>BR(U,_)):b,[b,_]),z=L.results??F;function H(U,W){l==null||l(U,W),w(q=>q.filter(V=>V.fileName!==W)),j(q=>q-1)}return D?r.jsx(GR,{selectedProject:D,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:O,onRetryFetch:()=>{if(L.error){L.refresh();return}T(null),o&&I(o)},loadMoreSessions:$}):r.jsx(eI,{projects:d,activeSessions:u,loading:p,refreshing:g,searchFilter:_,setSearchFilter:P,fetchError:A,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>M(!0)})});async function A2(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 oI(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 R2(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 rI(n,e,t){return R2("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function iI(n,e,t){return R2("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const aI=3e3,I2=v.createContext(null);async function Bl(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 Do(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 hi(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 lI({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,R]=await Promise.all([Bl("/api/permissions",p),Bl("/api/user-questions",h),Bl("/api/agent-prompts",g)]);T&&(t(Do(T.bySession)),f(new Set(Do(T.plansBySession).keys()))),E&&o(Do(E.bySession)),R&&(a(Do(R.elicitationsBySession)),c(Do(R.dialogsBySession)))},[]);v.useEffect(()=>{const T=()=>{document.visibilityState==="visible"&&x()};T();const E=setInterval(T,aI);return document.addEventListener("visibilitychange",T),()=>{clearInterval(E),document.removeEventListener("visibilitychange",T)}},[x]);const b=v.useCallback(async(T,E)=>{m(R=>new Set(R).add(T));try{return await E()}finally{m(R=>{const M=new Set(R);return M.delete(T),M}),x()}},[x]),w=v.useCallback((T,E,R)=>b(E,async()=>{await A2(T,E,R).catch(()=>!1)&&(t(I=>hi(I,T,D=>D.requestId===E)),p.current="")}),[b]),y=v.useCallback((T,E,R)=>b(E,async()=>{const M=await Xc(T,E,R);return M.ok&&(o(I=>hi(I,T,D=>D.toolUseId===E)),h.current=""),M}),[b]),j=v.useCallback((T,E,R)=>b(E,async()=>{const M=await rI(T,E,R);return M.ok&&(a(I=>hi(I,T,D=>D.requestId===E)),g.current=""),M}),[b]),k=v.useCallback((T,E,R)=>b(E,async()=>{const M=await iI(T,E,R);return M.ok&&(c(I=>hi(I,T,D=>D.requestId===E)),g.current=""),M}),[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(I2.Provider,{value:A,children:n})}function cI(){const n=v.useContext(I2);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const M2=typeof navigator<"u"&&"vibrate"in navigator;function Cc(){M2&&navigator.vibrate(10)}function dI(){M2&&navigator.vibrate(20)}function uI(n){return!!(n.teamName&&n.agentName)}function fI(n,e,t,s,o,i,a){const l=[],c=[];for(const d of Pd(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(uI(d))continue;const f=zx(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||Rd.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function mI(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 Zd(n,e){return n?Ht(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const $2="aw:turnCounts",pI=200,Wa=new Map;try{const n=localStorage.getItem($2);if(n){const e=JSON.parse(n);for(const[t,s]of e)Wa.set(t,s)}}catch{}function hI(){try{const n=[...Wa.entries()].slice(-pI);localStorage.setItem($2,JSON.stringify(n))}catch{}}function gI(n,e){Wa.set(Ft(n),e),hI()}function xI(n,e){const t=Wa.get(Ft(n));return Math.max(t??0,e??0)}function O2(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=xI(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",Qd(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(Yn,{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(Fa,{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(zs,{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(aa,{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=lg(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(Wy,{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=Cr(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 bI=120;function D2(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,bI))},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 vI=6;function yI(n){const e=B.c(7),{iso:t}=n,[,s]=v.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(wI),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=Cr(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 wI(n){return n+1}const jI={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"}},SI={permission:Ms.attention,deferred:Ms.attention,waiting:Ms.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function Lp(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=Zd(Ct(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":zr(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}=D2(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 R;e[19]!==C||e[20]!==N||e[21]!==m||e[22]!==E?(R=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]=R):R=e[23];const M=x&&"ring-0";let I;e[24]!==o||e[25]!==M?(I=G("size-1.5 shrink-0 rounded-full",o,M),e[24]=o,e[25]=M,e[26]=I):I=e[26];let D;e[27]!==I?(D=r.jsx("span",{className:I,"aria-hidden":"true"}),e[27]=I,e[28]=D):D=e[28];let O;e[29]!==d||e[30]!==t?(O=Dx(t,d),e[29]=d,e[30]=t,e[31]=O):O=e[31];let $;e[32]!==O?($=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:O}),e[32]=O,e[33]=$):$=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(Ee,{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(yI,{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]!==D||e[44]!==$||e[45]!==H||e[46]!==U?(W=r.jsxs("span",{className:"flex items-center gap-1.5",children:[D,$,H,U]}),e[43]=D,e[44]=$,e[45]=H,e[46]=U,e[47]=W):W=e[47];let q;e[48]!==f?(q=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[48]=f,e[49]=q):q=e[49];let V;e[50]!==R||e[51]!==W||e[52]!==q?(V=r.jsxs(Tt,{render:R,children:[W,q]}),e[50]=R,e[51]=W,e[52]=q,e[53]=V):V=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==j?(Y=r.jsx(Et,{side:"right",className:"max-w-[280px]",children:r.jsx(O2,{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 K;e[59]!==V||e[60]!==Y?(K=r.jsxs(_t,{children:[V,Y]}),e[59]=V,e[60]=Y,e[61]=K):K=e[61];let X;e[62]!==k||e[63]!==h?(X=k&&r.jsxs(Z,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(ko,{"data-icon":"inline-start"}),"Resume"]}),e[62]=k,e[63]=h,e[64]=X):X=e[64];let Q;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(Q=l&&p&&!w&&r.jsx(Z,{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(Nt,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=Q):Q=e[69];let J;return e[70]!==K||e[71]!==X||e[72]!==Q||e[73]!==P||e[74]!==A?(J=r.jsxs("div",{className:P,children:[A,K,X,Q]}),e[70]=K,e[71]=X,e[72]=Q,e[73]=P,e[74]=A,e[75]=J):J=e[75],J}function kI(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 NI(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,vI),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]||Ad(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(kI,{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(Lp,{...j(_),chip:jI[P],dotClassName:SI[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(Lp,{...j(S),chip:{label:mI(S),className:""},dotClassName:Ms.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${S.dirName}/${S.fileName}`))}),x>0&&r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(Ze,{"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 CI(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(ss,{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(vn,{align:"inline-start",children:i?r.jsx(rt,{className:"animate-spin"}):r.jsx(ln,{})}),e[6]=i,e[7]=f):f=e[7];let u;e[8]!==a||e[9]!==o?(u=o&&r.jsx(vn,{align:"inline-end",children:r.jsx(Rr,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(Nt,{"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(ns,{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(Wt,{"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(Z,{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 _I=["first","second","third","fourth","fifth"];function TI(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(St,{variant:"destructive",children:[r.jsx(yn,{}),r.jsx(It,{children:"Could not load sessions"}),r.jsx(kt,{className:"truncate",children:t}),r.jsx(ys,{children:r.jsx(Z,{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(In,{className:"min-h-56 px-4 py-8",children:r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:o?r.jsx(ln,{}):r.jsx(Oh,{})}),r.jsx($n,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(On,{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:_I.map(EI)}),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 EI(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(on,{className:"size-2 shrink-0 rounded-full"}),r.jsx(on,{className:"h-4 flex-1"}),r.jsx(on,{className:"h-4 w-10"})]},n)}function PI(n){var ve;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&&xr(t.agentStatus),C=t.agentStatus==="deferred";let S;e[0]!==o||e[1]!==t.dirName?(S=Zd(Ct(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":zr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,E=C?"attention":k?xr(t.agentStatus)?"idle":"working":null,R=!!(t.teamName&&t.agentName);let M;e[3]!==l||e[4]!==t?(M=Dx(t,l),e[3]=l,e[4]=t,e[5]=M):M=e[5];const I=M;let D;e[6]!==s||e[7]!==b||e[8]!==t.dirName||e[9]!==t.fileName?(D=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]=D):D=e[10];const{onHoverStart:O,onHoverEnd:$}=D2(D);let L;e[11]!==w||e[12]!==P||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(L=xe=>{xe.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",AI(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=_t,U=Tt;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 q;e[27]!==$||e[28]!==O||e[29]!==W?(q=r.jsx("button",{type:"button","data-live-session":!0,onClick:W,onMouseEnter:O,onMouseLeave:$,onFocus:O,onBlur:$,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]=$,e[28]=O,e[29]=W,e[30]=q):q=e[30];let V;e[31]!==E?(V=E&&r.jsx("span",{"data-status-dot":E,className:G("size-1.5 rounded-full",Ms[E])}),e[31]=E,e[32]=V):V=e[32];let Y;e[33]!==V?(Y=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:V}),e[33]=V,e[34]=Y):Y=e[34];let K;e[35]!==I?(K=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:I}),e[35]=I,e[36]=K):K=e[36];let X;e[37]!==R||e[38]!==t.agentName||e[39]!==I?(X=R&&r.jsxs(Ee,{variant:"outline",children:[r.jsx(mo,{"data-icon":"inline-start"}),I!==t.agentName?t.agentName:"Agent"]}),e[37]=R,e[38]=t.agentName,e[39]=I,e[40]=X):X=e[40];const Q=k&&!C&&T&&r.jsx(Ee,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&Qd(t.agentStatus)),children:T});let J;e[41]!==C?(J=C&&r.jsx(Ee,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[41]=C,e[42]=J):J=e[42];let ee;e[43]!==c?(ee=c&&r.jsxs(Ee,{variant:"outline",children:[r.jsx(zs,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=ee):ee=e[44];let oe;e[45]!==U||e[46]!==K||e[47]!==X||e[48]!==Q||e[49]!==J||e[50]!==ee||e[51]!==q||e[52]!==Y?(oe=r.jsxs(U,{render:q,children:[Y,K,X,Q,J,ee]}),e[45]=U,e[46]=K,e[47]=X,e[48]=Q,e[49]=J,e[50]=ee,e[51]=q,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(Et,{side:"right",className:"max-w-[280px]",children:r.jsx(O2,{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(Z,{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(Yn,{"data-icon":"inline-start"}),d,r.jsx(Je,{"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(Z,{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(ko,{"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(Ee,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Fa,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=te):te=e[76];const me=t.lastActivityAt||t.lastModified;let de;e[77]!==me?(de=Cr(me),e[77]=me,e[78]=de):de=e[78];let le;e[79]!==de?(le=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:de}),e[79]=de,e[80]=le):le=e[80];let he;e[81]!==y||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(he=y&&p&&!_&&r.jsx(Z,{type:"button",variant:"ghost",size:"icon-xs",onClick:xe=>p(o.pid,xe),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(Nt,{"data-icon":"inline-start"})}),e[81]=y,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=he):he=e[86];let ge;e[87]!==re||e[88]!==ie||e[89]!==ae||e[90]!==te||e[91]!==le||e[92]!==he||e[93]!==z?(ge=r.jsxs("div",{className:z,children:[re,ie,ae,te,le,he]}),e[87]=re,e[88]=ie,e[89]=ae,e[90]=te,e[91]=le,e[92]=he,e[93]=z,e[94]=ge):ge=e[94];const ce=ge;if(h||g||x){let xe;e[95]!==t.firstUserMessage||e[96]!==t.sessionId||e[97]!==t.slug?(xe=t.slug||((ve=t.firstUserMessage)==null?void 0:ve.slice(0,30))||t.sessionId.slice(0,12),e[95]=t.firstUserMessage,e[96]=t.sessionId,e[97]=t.slug,e[98]=xe):xe=e[98];let pe;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(pe=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=pe):pe=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 _e;e[106]!==x||e[107]!==t.sessionId?(_e=x?De=>x(t.sessionId,De):void 0,e[106]=x,e[107]=t.sessionId,e[108]=_e):_e=e[108];let Re;return e[109]!==l||e[110]!==ce||e[111]!==xe||e[112]!==pe||e[113]!==je||e[114]!==_e?(Re=r.jsx(h2,{sessionLabel:xe,customName:l,onDuplicate:pe,onDelete:je,onRename:_e,children:ce}),e[109]=l,e[110]=ce,e[111]=xe,e[112]=pe,e[113]=je,e[114]=_e,e[115]=Re):Re=e[115],Re}return ce}function AI(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function RI(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function II(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((M,I)=>{const[D,O]=M,$=RI(O,c);return v.createElement(zp,{..._,key:D,projectPath:D,sessions:O,liveCount:$,collapsed:i[D]??(I>=3&&$===0),forceExpand:A,pendingSession:s===D?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(zp,{..._,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 R;return e[33]!==T||e[34]!==E?(R=r.jsxs(r.Fragment,{children:[T,E]}),e[33]=T,e[34]=E,e[35]=R):R=e[35],R}function zp(n){var He,Oe;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($I)),e[0]=s,e[1]=E):E=e[1];const R=E;let M;if(e[2]!==R||e[3]!==s){const Ne=new Map,fe=[];for(const Pe of s){const Me=Pe.teamLeadSessionId;if(Me&&Me!==Pe.sessionId&&R.has(Me)){const Fe=Ne.get(Me);Fe?Fe.push(Pe):Ne.set(Me,[Pe])}else fe.push(Pe)}M={topLevelSessions:fe,teammatesByLead:Ne},e[2]=R,e[3]=s,e[4]=M}else M=e[4];const{topLevelSessions:I,teammatesByLead:D}=M;let O;e[5]===Symbol.for("react.memo_cache_sentinel")?(O=new Set,e[5]=O):O=e[5];const[$,L]=v.useState(O);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=Ne=>{L(fe=>{const Pe=new Set(fe);return Pe.has(Ne)?Pe.delete(Ne):Pe.add(Ne),Pe})},e[6]=F):F=e[6];const z=F,[H,U]=v.useState(!1),W=s.length+(A?1:0);let q,V;e[7]!==_||e[8]!==A||e[9]!==i||e[10]!==H||e[11]!==I?(q=N_(I,i,Math.max(1,5-(A?1:0))),V=_||H?I:I.slice(0,q),e[7]=_,e[8]=A,e[9]=i,e[10]=H,e[11]=I,e[12]=q,e[13]=V):(q=e[12],V=e[13]);const Y=V,K=I.length-Y.length,X=H&&!_&&I.length>q,Q=((He=s.find(MI))==null?void 0:He.dirName)??((Oe=s[0])==null?void 0:Oe.dirName)??(N==null?void 0:N.dirName),J=Q?d[Q]: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(fe,Pe,Me){return r.jsx(PI,{session:fe,isActiveSession:o===`${fe.dirName}/${fe.fileName}`,proc:i.get(fe.sessionId),killingPids:a,isNewlyCompleted:l.has(fe.sessionId),customName:c[fe.sessionId],worktreeName:Pe,teammateCount:Me==null?void 0:Me.count,teammatesCollapsed:Me==null?void 0:Me.collapsed,onToggleTeammates:Me==null?void 0:Me.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onPrefetchSession:C,onResumeSession:S},`${fe.dirName}/${fe.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]!==Q||e[28]!==y?(re=Ne=>{Q&&y&&y(Q,Ne)},e[27]=Q,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,me=!T&&"rotate-90";let de;e[34]!==me?(de=G("size-3 shrink-0 text-muted-foreground transition-transform duration-150",me),e[34]=me,e[35]=de):de=e[35];let le;e[36]!==de?(le=r.jsx(Je,{className:de}),e[36]=de,e[37]=le):le=e[37];const he=J||t;let ge;e[38]!==he?(ge=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:he}),e[38]=he,e[39]=ge):ge=e[39];let ce;e[40]!==J||e[41]!==t?(ce=J&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=J,e[41]=t,e[42]=ce):ce=e[42];let ve;e[43]!==f?(ve=f>0&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":`${f} live sessions`,children:[r.jsx(ba,{className:"size-1.5","aria-hidden":"true"}),f]}),e[43]=f,e[44]=ve):ve=e[44];let xe;e[45]!==W?(xe=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:W}),e[45]=W,e[46]=xe):xe=e[46];let 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]!==ve||e[56]!==xe?(pe=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,ve,xe]}),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]=ve,e[56]=xe,e[57]=pe):pe=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(Z,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:k,onClick:Ne=>{Ne.stopPropagation();const fe=s[0];j(fe.dirName,fe.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 _e;e[64]!==pe||e[65]!==je?(_e=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[pe,je]}),e[64]=pe,e[65]=je,e[66]=_e):_e=e[66];let Re;e[67]!==J||e[68]!==t||e[69]!==_e||e[70]!==re?(Re=r.jsx(C2,{projectLabel:t,customName:J,className:"sticky top-0 z-20 bg-background",onRename:re,children:_e}),e[67]=J,e[68]=t,e[69]=_e,e[70]=re,e[71]=Re):Re=e[71];let De;e[72]!==N?(De=N&&r.jsx(OI,{firstMessage:N.firstMessage}),e[72]=N,e[73]=De):De=e[73];let Te;if(e[74]!==$||e[75]!==oe||e[76]!==D||e[77]!==Y){let Ne;e[79]!==$||e[80]!==oe||e[81]!==D?(Ne=fe=>{const Pe=fe.cwd??gn(fe.dirName),Me=ha(Pe),Fe=D.get(fe.sessionId);if(!Fe)return oe(fe,Me==null?void 0:Me.worktreeName);const ne=$.has(fe.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[oe(fe,Me==null?void 0:Me.worktreeName,{count:Fe.length,collapsed:ne,onToggle:()=>z(fe.sessionId)}),!ne&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Fe.map(ue=>oe(ue))})]},`${fe.dirName}/${fe.fileName}`)},e[79]=$,e[80]=oe,e[81]=D,e[82]=Ne):Ne=e[82],Te=Y.map(Ne),e[74]=$,e[75]=oe,e[76]=D,e[77]=Y,e[78]=Te}else Te=e[78];let Ie;e[83]!==K?(Ie=K>0&&r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!0),className:"justify-start",children:[r.jsx(Ze,{"data-icon":"inline-start"}),"Show ",K," more"]}),e[83]=K,e[84]=Ie):Ie=e[84];let Le;e[85]!==X?(Le=X&&r.jsxs(Z,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!1),className:"justify-start",children:[r.jsx(vr,{"data-icon":"inline-start"}),"Show less"]}),e[85]=X,e[86]=Le):Le=e[86];let ze;e[87]!==De||e[88]!==Te||e[89]!==Ie||e[90]!==Le?(ze=r.jsxs("div",{className:"flex flex-col gap-px",children:[De,Te,Ie,Le]}),e[87]=De,e[88]=Te,e[89]=Ie,e[90]=Le,e[91]=ze):ze=e[91];let Ue;e[92]!==P||e[93]!==ze?(Ue=r.jsx(wt,{id:P,className:"ml-3 border-l pl-1",children:ze}),e[92]=P,e[93]=ze,e[94]=Ue):Ue=e[94];let Se;return e[95]!==Re||e[96]!==Ue||e[97]!==se?(Se=r.jsxs(yt,{open:se,className:"flex flex-col",children:[Re,Ue]}),e[95]=Re,e[96]=Ue,e[97]=se,e[98]=Se):Se=e[98],Se}function MI(n){return!ha(n.cwd??gn(n.dirName))}function $I(n){return n.sessionId}function OI(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 DI=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}=b2(),{names:h,rename:g}=E2(),x=Qc(),b=bn("terminal"),w=bn("killAny"),{sessions:y,procBySession:j,newlyCompleted:k,loading:N,error:C,refresh:S,removeSession:_,acknowledgeCompleted:P}=qx(),{awaitingPermission:A,awaitingQuestion:T,awaitingElicitation:E,awaitingDialog:R,awaitingPlan:M}=cI();let I;t[0]!==R||t[1]!==E?(I=new Set([...E,...R]),t[0]=R,t[1]=E,t[2]=I):I=t[2];const D=I;let O;t[3]===Symbol.for("react.memo_cache_sentinel")?(O=new Set,t[3]=O):O=t[3];const[$,L]=v.useState(O),[F,z]=v.useState("");let H,U;t[4]===Symbol.for("react.memo_cache_sentinel")?(H=Ft("live-sessions-collapsed-projects"),U={},t[4]=H,t[5]=U):(H=t[4],U=t[5]);const[W,q]=Dr(H,U);let V;t[6]!==q?(V=(qe,st)=>{q(mt=>({...mt,[qe]:st}))},t[6]=q,t[7]=V):V=t[7];const Y=V,K=v.useRef(y);let X;t[8]===Symbol.for("react.memo_cache_sentinel")?(X=new Set,t[8]=X):X=t[8];const Q=v.useRef(X),J=v.useRef(!1);let ee;t[9]===Symbol.for("react.memo_cache_sentinel")?(ee=(qe,st)=>{if(!J.current)return;const mt=setTimeout(()=>{Q.current.delete(mt),J.current&&qe()},st);Q.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 qe=Q.current;return J.current=!0,()=>{J.current=!1;for(const st of qe)clearTimeout(st);qe.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=()=>{K.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,me;t[15]!==S||t[16]!==f?(te=()=>{if(f)return f.current=S,()=>{f.current===S&&(f.current=null)}},me=[S,f],t[15]=S,t[16]=f,t[17]=te,t[18]=me):(te=t[17],me=t[18]),v.useEffect(te,me);const de=Ma(),le=P2(F);let he;e:{if(!F.trim()){he=y;break e}let qe;if(t[19]!==h||t[20]!==F||t[21]!==m||t[22]!==y){let st;t[24]!==h||t[25]!==F||t[26]!==m?(st=mt=>{const Rt=m[mt.sessionId],Bn=h[mt.dirName];return S2(mt,F,[Rt,Bn])},t[24]=h,t[25]=F,t[26]=m,t[27]=st):st=t[27],qe=y.filter(st),t[19]=h,t[20]=F,t[21]=m,t[22]=y,t[23]=qe}else qe=t[23];he=qe}const ge=he,ce=le.results??ge;let ve;t[28]!==ce?(ve=k_(ce),t[28]=ce,t[29]=ve):ve=t[29];const xe=ve;let pe;t[30]!==A||t[31]!==M||t[32]!==D||t[33]!==T||t[34]!==k||t[35]!==j||t[36]!==y?(pe=fI(y,j,k,A,T,D,M),t[30]=A,t[31]=M,t[32]=D,t[33]=T,t[34]=k,t[35]=j,t[36]=y,t[37]=pe):pe=t[37];const je=pe,_e=je.needsYou.length>0||je.working.length>0;let Re;t[38]!==_e||t[39]!==F?(Re=!F.trim()&&_e,t[38]=_e,t[39]=F,t[40]=Re):Re=t[40];const De=Re;let Te;e:{if(!d){Te=null;break e}let qe;t[41]!==d.cwd||t[42]!==d.dirName?(qe=d.cwd||gn(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=qe):qe=t[43];let st;t[44]!==qe?(st=Ad(qe),t[44]=qe,t[45]=st):st=t[45],Te=st}const Ie=Te,Le=v.useRef(!1);let ze,Ue;t[46]!==u||t[47]!==y?(ze=()=>{if(Le.current||!u||y.length===0)return;Le.current=!0;const qe=Pd(y).slice(0,3),st=globalThis,mt=()=>{for(const Un of qe)u(Un.dirName,Un.fileName)};let Rt=null,Bn=null;return typeof st.requestIdleCallback=="function"?Rt=st.requestIdleCallback(mt,{timeout:1500}):Bn=setTimeout(mt,300),()=>{Rt!=null&&typeof st.cancelIdleCallback=="function"&&st.cancelIdleCallback(Rt),Bn!=null&&clearTimeout(Bn)}},Ue=[y,u],t[46]=u,t[47]=y,t[48]=ze,t[49]=Ue):(ze=t[48],Ue=t[49]),v.useEffect(ze,Ue);let Se;t[50]!==S?(Se=async(qe,st)=>{st.stopPropagation(),L(mt=>new Set(mt).add(qe));try{await ye("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:qe})}),oe(S,1500)}catch{}oe(()=>{L(mt=>{const Rt=new Set(mt);return Rt.delete(qe),Rt})},2e3)},t[50]=S,t[51]=Se):Se=t[51];const He=Se;let Oe;t[52]!==P||t[53]!==o?(Oe=(qe,st)=>{const mt=K.current.find(Rt=>Rt.dirName===qe&&Rt.fileName===st);mt&&P(mt.sessionId),o(qe,st)},t[52]=P,t[53]=o,t[54]=Oe):Oe=t[54];const Ne=Oe;let fe;t[55]!==a||t[56]!==_?(fe=qe=>{a==null||a(qe.dirName,qe.fileName),_(qe.sessionId)},t[55]=a,t[56]=_,t[57]=fe):fe=t[57];const Pe=fe;let Me;t[58]!==S||t[59]!==x?(Me=(qe,st,mt)=>{const{command:Rt,args:Bn}=a3(Ct(mt),qe),Un=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Un,name:`Resume ${qe.slice(0,8)}`,command:Rt,args:Bn,cwd:st??void 0,metadata:{type:"terminal"}}),oe(S,3e3)},t[58]=S,t[59]=x,t[60]=Me):Me=t[60];const Fe=Me;let ne;t[61]!==S?(ne=()=>{dI(),S()},t[61]=S,t[62]=ne):ne=t[62];let ue;t[63]!==de||t[64]!==N||t[65]!==le.loading||t[66]!==F||t[67]!==ne?(ue=r.jsx(CI,{loading:N,isMobile:de,searchQuery:F,searchLoading:le.loading,onSearchQueryChange:z,onRefresh:ne}),t[63]=de,t[64]=N,t[65]=le.loading,t[66]=F,t[67]=ne,t[68]=ue):ue=t[68];const ke=le.error??C,Ae=ce.length===0&&!d&&!N&&!le.loading&&!C&&!le.error;let $e;t[69]!==F?($e=F.trim(),t[69]=F,t[70]=$e):$e=t[70];const We=!!$e,Xe=N||le.loading,nt=le.active?ce.length:y.length,Be=le.error?le.refresh:S;let Ge;t[71]!==ke||t[72]!==Ae||t[73]!==We||t[74]!==Xe||t[75]!==nt||t[76]!==Be?(Ge=r.jsx(TI,{fetchError:ke,showEmpty:Ae,searching:We,loading:Xe,sessionCount:nt,onRetry:Be}),t[71]=ke,t[72]=Ae,t[73]=We,t[74]=Xe,t[75]=nt,t[76]=Be,t[77]=Ge):Ge=t[77];let ot;t[78]!==s||t[79]!==je||t[80]!==w||t[81]!==b||t[82]!==He||t[83]!==Fe||t[84]!==Ne||t[85]!==$||t[86]!==u||t[87]!==j||t[88]!==h||t[89]!==m||t[90]!==De?(ot=De&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(NI,{groups:je,activeSessionKey:s,procBySession:j,killingPids:$,sessionNames:m,projectNames:h,onSelectSession:Ne,onKill:w?He:void 0,onResumeSession:b?Fe:void 0,onPrefetchSession:u}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Projects"}),r.jsx(Mt,{className:"flex-1"})]})]}),t[78]=s,t[79]=je,t[80]=w,t[81]=b,t[82]=He,t[83]=Fe,t[84]=Ne,t[85]=$,t[86]=u,t[87]=j,t[88]=h,t[89]=m,t[90]=De,t[91]=ot):ot=t[91];const wn=w?He:void 0,ct=a?Pe:void 0,Hs=b?Fe:void 0;let nn;t[92]!==s||t[93]!==W||t[94]!==c||t[95]!==xe||t[96]!==Ne||t[97]!==$||t[98]!==k||t[99]!==i||t[100]!==l||t[101]!==u||t[102]!==Ie||t[103]!==d||t[104]!==j||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==F||t[109]!==m||t[110]!==wn||t[111]!==ct||t[112]!==Hs||t[113]!==Y?(nn=r.jsx(II,{grouped:xe,pendingProjectPath:Ie,pendingSession:d,collapsedGroups:W,searchQuery:F,activeSessionKey:s,procBySession:j,killingPids:$,newlyCompleted:k,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Ne,onKill:wn,onDuplicateSession:i,onDeleteSession:ct,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:u,onResumeSession:Hs}),t[92]=s,t[93]=W,t[94]=c,t[95]=xe,t[96]=Ne,t[97]=$,t[98]=k,t[99]=i,t[100]=l,t[101]=u,t[102]=Ie,t[103]=d,t[104]=j,t[105]=h,t[106]=g,t[107]=p,t[108]=F,t[109]=m,t[110]=wn,t[111]=ct,t[112]=Hs,t[113]=Y,t[114]=nn):nn=t[114];let jn;t[115]!==Ge||t[116]!==ot||t[117]!==nn?(jn=r.jsx(To,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[Ge,ot,nn]})}),t[115]=Ge,t[116]=ot,t[117]=nn,t[118]=jn):jn=t[118];let Ks;return t[119]!==ue||t[120]!==jn?(Ks=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ue,jn]}),t[119]=ue,t[120]=jn,t[121]=Ks):Ks=t[121],Ks}),LI=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(DI,{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}),zI=v.lazy(()=>Ke(()=>import("./index-CJcccHRp.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.MissionControl})));function L2(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(At,{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 z2(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(LI,{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 F2(n){const e=B.c(8),{navigation:t}=n,{state:s}=Ot();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(sI,{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 FI(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(L2,{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(zI,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function BI({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function UI({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function WI({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}
|
|
125
|
+
`:""}${n} (${a})
|
|
126
|
+
${i}
|
|
127
|
+
${e}
|
|
128
|
+
${i}`}const HI=v.lazy(()=>Ke(()=>import("./ConfigBrowser-DrAZQBx8.js"),__vite__mapDeps([34,1,2,32,3,4])).then(n=>({default:n.ConfigBrowser}))),KI=v.lazy(()=>Ke(()=>import("./PreviewPanel-DC6OTZfZ.js"),__vite__mapDeps([35,1,2,3,4])).then(n=>({default:n.PreviewPanel})));function qI(n){const e=B.c(20),{sessionView:t,floatingChrome:s}=n,{session:o}=it();if(!o)return null;let i;e[0]!==t.teamMembersBar?(i=t.teamMembersBar&&r.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=i):i=e[1];const a=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==a?(l=r.jsx(La,{searchInputRef:t.searchInputRef,hasTodos:a,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=a,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&r.jsx(kx,{progress:t.todoProgress,expanded:t.todosExpanded,onExpandedChange:t.onTodosExpandedChange}),e[8]=t.onTodosExpandedChange,e[9]=t.todoProgress,e[10]=t.todosExpanded,e[11]=c):c=e[11];let d;e[12]!==t.activeComposer||e[13]!==c?(d=r.jsxs(Ua,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=d):d=e[14];let f;return e[15]!==s||e[16]!==i||e[17]!==l||e[18]!==d?(f=r.jsx("div",{className:"flex min-h-0 flex-1 bg-background",children:r.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,i,l,d]})}),e[15]=s,e[16]=i,e[17]=l,e[18]=d,e[19]=f):f=e[19],f}function VI(n){const e=B.c(36),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Ot(),{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(L2,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(HI,{projectPath:UI({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(FI,{navigation:t})}),e[12]=t,e[13]=p):p=e[13],p}if(i==="session"){let p;return e[14]!==a||e[15]!==s?(p=r.jsx(qI,{sessionView:s,floatingChrome:a}),e[14]=a,e[15]=s,e[16]=p):p=e[16],p}if(i==="pending"){const p=s.pendingTurns.length>0,h=Os()?"Only on the machine running this session":void 0;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=dd()?void 0:h,e[17]=g):g=e[17];const x=g,b=!p&&"justify-center gap-4";let w;e[18]!==b?(w=G("flex min-h-0 min-w-0 flex-1 flex-col bg-background",b),e[18]=b,e[19]=w):w=e[19];let y;e[20]!==p||e[21]!==f||e[22]!==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(p2,{projectPath:f}),e[20]=p,e[21]=f,e[22]=s.pendingTurns,e[23]=y):y=e[23];let j;e[24]!==s.pendingComposer?(j=r.jsx(Ua,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=j):j=e[25];let k;e[26]!==p||e[27]!==o?(k=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[lt("terminal")&&r.jsx(Pl,{reason:h,children:r.jsxs(Z,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(No,{"data-icon":"inline-start"}),"Terminal"]})}),lt("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(Pl,{reason:x,children:r.jsxs(Z,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>t1(o.pendingProject),children:[r.jsx(br,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(Pl,{reason:h,children:r.jsxs(Z,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>n1(o.pendingProject),children:[r.jsx(Ih,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=o,e[28]=k):k=e[28];let N;return e[29]!==w||e[30]!==y||e[31]!==j||e[32]!==k?(N=r.jsxs("div",{className:w,children:[y,j,k]}),e[29]=w,e[30]=y,e[31]=j,e[32]=k,e[33]=N):N=e[33],N}let m;return e[34]!==t?(m=r.jsx(F2,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function GI(n){const e=B.c(90),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Ot(),{session:c}=it();let d;e[0]!==s.chatInputRef?(d=function(re){var ge,ce,ve;const{path:ie,text:ae,startLine:te,endLine:me,comment:de}=re,le=WI({path:ie,text:ae,startLine:te,endLine:me,comment:de}),he=((ge=s.chatInputRef.current)==null?void 0:ge.getText().trimEnd())??"";(ce=s.chatInputRef.current)==null||ce.setText(he?`${he}
|
|
129
|
+
|
|
130
|
+
${le}
|
|
131
|
+
`:`${le}
|
|
132
|
+
`),(ve=s.chatInputRef.current)==null||ve.focus()},e[0]=s.chatInputRef,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=BI({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=Tl("toggleSidebar"),y=Tl("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(GP,{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=o.currentCwd??null;let S,_,P;if(e[12]!==t.panels.activeWorkspacePanel||e[13]!==o.hasFileChanges||e[14]!==c||e[15]!==a.mainView||e[16]!==a.sessionChangeKey||e[17]!==C){S={session:c,sessionChangeKey:a.sessionChangeKey,projectPath:C,hasFileChanges:o.hasFileChanges,canAccessHostFiles:lt("hostFiles")},P=a.mainView==="config"?[]:i2(SR,S);let se;e[21]!==t.panels.activeWorkspacePanel?(se=re=>re.id===t.panels.activeWorkspacePanel,e[21]=t.panels.activeWorkspacePanel,e[22]=se):se=e[22],_=P.find(se),e[12]=t.panels.activeWorkspacePanel,e[13]=o.hasFileChanges,e[14]=c,e[15]=a.mainView,e[16]=a.sessionChangeKey,e[17]=C,e[18]=S,e[19]=_,e[20]=P}else S=e[18],_=e[19],P=e[20];const A=_;let T;e[23]!==t.panels||e[24]!==o?(T=function(re){o.showPreview&&o.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(re)},e[23]=t.panels,e[24]=o,e[25]=T):T=e[25];const E=T;let R;e[26]!==t.panels||e[27]!==o?(R=function(re){o.showPreview&&o.onCloseRightWorkspace(),t.panels.openWorkspacePanel(re)},e[26]=t.panels,e[27]=o,e[28]=R):R=e[28];const M=R,I=t.panels.showSidebar;let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=Tl("toggleSidebar"),e[29]=D):D=e[29];const O=o.supportsWorktrees&&t.panels.showWorktrees,$=o.supportsWorktrees?t.panels.handleToggleWorktrees:void 0,L=a.mainView==="config",F=lt("configWrite")?t.panels.handleToggleConfig:void 0,z=a.mainView==="mission";let H;e[30]!==i.killing||e[31]!==i.onKillAll||e[32]!==l.openConfigDialog||e[33]!==t.creatingSession||e[34]!==t.handlers.handleDuplicateSession||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleToggleMission||e[37]!==t.panels.handleToggleSidebar||e[38]!==t.panels.showSidebar||e[39]!==o.onOpenTerminal||e[40]!==s.onBackToMain||e[41]!==s.onShowWorkflows||e[42]!==s.workflowCount||e[43]!==N||e[44]!==O||e[45]!==$||e[46]!==L||e[47]!==F||e[48]!==z?(H=r.jsx(KP,{showSidebar:I,sidebarRendered:N,sidebarShortcut:D,showWorktrees:O,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,onToggleWorktrees:$,showConfig:L,onToggleConfig:F,showMission:z,onToggleMission:t.panels.handleToggleMission,onKillAll:i.onKillAll,onOpenSettings:l.openConfigDialog}),e[30]=i.killing,e[31]=i.onKillAll,e[32]=l.openConfigDialog,e[33]=t.creatingSession,e[34]=t.handlers.handleDuplicateSession,e[35]=t.onStartNewSession,e[36]=t.panels.handleToggleMission,e[37]=t.panels.handleToggleSidebar,e[38]=t.panels.showSidebar,e[39]=o.onOpenTerminal,e[40]=s.onBackToMain,e[41]=s.onShowWorkflows,e[42]=s.workflowCount,e[43]=N,e[44]=O,e[45]=$,e[46]=L,e[47]=F,e[48]=z,e[49]=H):H=e[49];const U=H;let W;e[50]!==t||e[51]!==k||e[52]!==N?(W=N&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(z2,{navigation:t,header:k})}),e[50]=t,e[51]=k,e[52]=N,e[53]=W):W=e[53];const q=A??null,V=o.projectFilesRoot??o.currentCwd??null;let Y;e[54]!==f||e[55]!==t.actions.handleJumpToTurn||e[56]!==t.handlers.handleLoadSessionScrollAware||e[57]!==o.backgroundAgents||e[58]!==o.processPanel.handleServersChanged||e[59]!==o.processPanel.handleToggleServer||e[60]!==o.projectFilesRequest||e[61]!==s.searchInputRef||e[62]!==V?(Y={projectFilesRoot:V,projectFilesRequest:o.projectFilesRequest,backgroundAgents:o.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:f,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:o.processPanel.handleToggleServer,serversChanged:o.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware},e[54]=f,e[55]=t.actions.handleJumpToTurn,e[56]=t.handlers.handleLoadSessionScrollAware,e[57]=o.backgroundAgents,e[58]=o.processPanel.handleServersChanged,e[59]=o.processPanel.handleToggleServer,e[60]=o.projectFilesRequest,e[61]=s.searchInputRef,e[62]=V,e[63]=Y):Y=e[63];const K=h!=="session"&&U;let X;e[64]!==U||e[65]!==t||e[66]!==o||e[67]!==s||e[68]!==h?(X=r.jsx(VI,{navigation:t,sessionView:s,project:o,view:h,floatingChrome:U}),e[64]=U,e[65]=t,e[66]=o,e[67]=s,e[68]=h,e[69]=X):X=e[69];let Q;e[70]!==K||e[71]!==X?(Q=r.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[K,X]}),e[70]=K,e[71]=X,e[72]=Q):Q=e[72];let J;e[73]!==t.panels.closeWorkspacePanel||e[74]!==M||e[75]!==S||e[76]!==q||e[77]!==Y||e[78]!==Q||e[79]!==E||e[80]!==P?(J=r.jsx(tA,{panels:P,context:S,activePanel:q,services:Y,onClosePanel:t.panels.closeWorkspacePanel,onOpenPanel:M,onTogglePanel:E,children:Q}),e[73]=t.panels.closeWorkspacePanel,e[74]=M,e[75]=S,e[76]=q,e[77]=Y,e[78]=Q,e[79]=E,e[80]=P,e[81]=J):J=e[81];let ee;e[82]!==o.currentCwd||e[83]!==o.onCloseRightWorkspace||e[84]!==o.showPreview?(ee=o.showPreview&&o.currentCwd&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(KI,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[82]=o.currentCwd,e[83]=o.onCloseRightWorkspace,e[84]=o.showPreview,e[85]=ee):ee=e[85];let oe;return e[86]!==W||e[87]!==J||e[88]!==ee?(oe=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[W,J,ee]}),e[86]=W,e[87]=J,e[88]=ee,e[89]=oe):oe=e[89],oe}function YI(n){const e=B.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Ot(),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(_x,{}),d=r.jsx(Cx,{}),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(GI,{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(QE,{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 XI=[{id:"sessions",label:"Sessions",icon:ho},{id:"chat",label:"Chat",icon:aa},{id:"stats",label:"Stats",icon:$h,requiresSession:!0}],JI=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=XI.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:()=>{Cc(),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(ba,{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 QI(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(Z,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(zc,{"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(Gd,{compact:!0}),k=r.jsx(Mt,{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(Pg,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=N):N=e[10];let C;e[11]!==t.cwd?(C=t.cwd?qn(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(Ln,{render:r.jsx(Z,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(Mh,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let P;e[16]!==t.cwd?(P=t.cwd?qn(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 R;e[25]!==A||e[26]!==E?(R=r.jsxs(xs,{className:"flex flex-col gap-0.5",children:[A,E]}),e[25]=A,e[26]=E,e[27]=R):R=e[27];let M;e[28]!==a||e[29]!==w||e[30]!==s?(M=s&&r.jsxs(ut,{onClick:w,disabled:a,children:[a?r.jsx(At,{}):r.jsx(Tn,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=w,e[30]=s,e[31]=M):M=e[31];let I;e[32]!==c?(I=c&&r.jsxs(ut,{onClick:c,children:[r.jsx(An,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=I):I=e[33];let D;e[34]!==R||e[35]!==M||e[36]!==I?(D=r.jsxs(Ut,{children:[R,M,I]}),e[34]=R,e[35]=M,e[36]=I,e[37]=D):D=e[37];let O;e[38]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(uo,{}),e[38]=O):O=e[38];let $;e[39]!==h?($=h&&r.jsxs(ut,{onClick:h,children:[r.jsx(ln,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=$):$=e[40];let L;e[41]!==g||e[42]!==x?(L=x&&r.jsxs(ut,{onClick:x,children:[g?r.jsx(ia,{}):r.jsx(ra,{}),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(ut,{onClick:f,children:[r.jsx(wr,{}),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(ut,{onClick:m,children:[r.jsx(la,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Ee,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=z):z=e[49];let H;e[50]!==$||e[51]!==L||e[52]!==F||e[53]!==z?(H=r.jsxs(Ut,{children:[$,L,F,z]}),e[50]=$,e[51]=L,e[52]=F,e[53]=z,e[54]=H):H=e[54];let U;e[55]!==D||e[56]!==H?(U=r.jsxs(Dn,{children:[_,r.jsxs(zn,{align:"end",sideOffset:6,className:"w-72",children:[D,O,H]})]}),e[55]=D,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 ZI=v.memo(function(e){const t=B.c(11),{isMobile:s}=Ot(),{session:o,sessionSource:i}=it();if(!s||!o)return null;let a;t[0]!==i?(a=i?bs(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=go(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(QI,{...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 eM({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 tM=["sessions","chat","stats"];function nM({hasSession:n,hasPendingSession:e}){return tM.filter(t=>!(t==="stats"&&!n&&!e))}function Fp(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const sM=v.lazy(()=>Ke(()=>import("./MobileFileChanges-uxpxh1W6.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function oM(n){const e=B.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Ot(),{session:c,isSubAgentView:d}=it(),f=!!c,u=!!a.pendingDirName;let m;e[0]!==f||e[1]!==u?(m=nM({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=Fp(p,a.mobileTab,1);F&&(Cc(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{const F=Fp(p,a.mobileTab,-1);F&&(Cc(),t.actions.handleMobileTabChange(F))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=eM(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(_x,{}),k=r.jsx(Cx,{}),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(Gd,{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(z2,{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(ZI,{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(La,{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(p2,{projectPath:s.pendingPath??null}),lt("terminal")&&r.jsxs(Z,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(No,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(F2,{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(m2,{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 R;e[41]!==g||e[42]!==E?(R=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]=R):R=e[43];const M=a.mobileTab==="chat"&&i.processPanel;let I;e[44]!==c||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?(I=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]=I):I=e[48];let D;e[49]!==M||e[50]!==I?(D=r.jsxs("div",{className:"shrink-0",children:[M,I]}),e[49]=M,e[50]=I,e[51]=D):D=e[51];let O;e[52]!==b||e[53]!==a.mobileTab?(O=r.jsx(JI,{activeTab:a.mobileTab,onTabChange:b}),e[52]=b,e[53]=a.mobileTab,e[54]=O):O=e[54];let $;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?($=c&&o.hasFileChanges&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(sM,{open:i.fileChangesOpen,onClose:()=>i.onFileChangesOpenChange(!1),session:c,sessionChangeKey:a.sessionChangeKey})}),e[55]=i,e[56]=o,e[57]=c,e[58]=a.sessionChangeKey,e[59]=$):$=e[59];let L;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==N||e[65]!==R||e[66]!==D||e[67]!==O||e[68]!==$||e[69]!==w?(L=r.jsxs("div",{className:w,children:[y,j,k,N,R,D,i.workflowsPanel,O,i.undoDialog,i.branchModal,$]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=N,e[65]=R,e[66]=D,e[67]=O,e[68]=$,e[69]=w,e[70]=L):L=e[70],L}function rM(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}=Ot(),{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(La,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),f?i:r.jsx(Ua,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(In,{className:"max-w-md",children:r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:s?r.jsx(en,{}):r.jsx(rt,{className:"animate-spin"})}),r.jsx($n,{children:s?"Unable to open session":"Opening session"}),r.jsx(On,{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 iM=5;function gi(n,e){const t=mn(),s=hs();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class aM{constructor(){Yr(this,"cache",new Map)}get(e,t){const s=gi(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=gi(e,t);!this.cache.has(d)&&this.cache.size>=iM&&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=gi(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(gi(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 aM,Bp={};function B2(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(io),j=v.useRef(""),k=v.useRef(null),N=v.useRef(io),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),R=(n==null?void 0:n.dirName)??null,M=(n==null?void 0:n.fileName)??null,I=(n==null?void 0:n.rawText)??"",D=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(I).byteLength;return v.useEffect(()=>{if(j.current=I,!I){k.current=null,l(!1);return}const O=T.current;if(O){k.current=O;return}P.current(I).then($=>{k.current=$})},[I]),v.useEffect(()=>{if(b(null),!R||!M){l(!1),d("disconnected");return}d("connecting");const O=`/api/watch/${encodeURIComponent(R)}/${encodeURIComponent(M)}?offset=${D}`,$=new EventSource(kr(O));let L=null;const F=(ae=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),u(!1)},ae)};let z="",H=D,U=!1,W=!1,q=!1,V=null;const Y=()=>{q=!1,V=null,k.current&&S.current(k.current)},K=()=>{q||(q=!0,V=requestAnimationFrame(Y))};let X=!1,Q=null,J=null;const ee=()=>{X=!1,Q=null,y(N.current)},oe=()=>{X||(X=!0,Q=requestAnimationFrame(ee))},se=ae=>{ae!==N.current&&(N.current=ae,oe(),ae.length>0&&!J&&(J=setInterval(()=>{const te=X_(N.current);te!==N.current&&(N.current=te,oe()),N.current.length===0&&J&&(clearInterval(J),J=null)},5e3)))},re=()=>{se(io),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(de=>{W||(k.current=de,R&&M&&hn.update(R,M,{parsed:de,source:{rawText:j.current,watchOffset:H}}),K())}).catch(de=>{console.error("[useLiveSession] worker parse failed:",de)}).finally(()=>{U=!1,!W&&z&&ie()})};return $.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(_))}},$.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(V_(te.messages??[]));else if(te.type==="stream_delta")l(!0),F(),p(null),b(null),se(G_(N.current,te.events??[]));else if(te.type==="agent_progress")l(!0),F(),g(me=>({...me,[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(Y_(N.current,te.lines));const me=te.lines.join(`
|
|
133
|
+
`)+`
|
|
134
|
+
`;H+=new TextEncoder().encode(me).byteLength,j.current+=me,z+=me,ie()}}catch(te){console.error("[useLiveSession] Error processing SSE message:",te)}},$.onerror=()=>{l(!1),u(!1),E.current=C.current==="connected",C.current="disconnected",d("disconnected"),re()},()=>{W=!0,$.close(),l(!1),C.current="disconnected",d("disconnected"),L&&clearTimeout(L),V!==null&&cancelAnimationFrame(V),Q!==null&&cancelAnimationFrame(Q),J&&clearInterval(J),N.current=io,y(io)}},[R,M,I,D]),{isLive:a,sseState:c,isCompacting:f,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:x}}const lM=3e4;function U2(n,e,t){const s=B.c(9),o=lM,[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(kr(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 cM(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return U2(t,e)}function dM(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]),cM((t==null?void 0:t.teamName)??null,a),t}function uM(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),U2(o,s)}function fM(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}=uM(f?n:null,f?e:null,null,d);return{workflows:s,loading:i,isLive:u,refetch:d}}const Ji={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},mM="cogpit:permissions";function pM(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 Up(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function W2(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 Up(l,i(l));return!l.ok&&t==="codex"&&e&&pM(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await Up(l,i(l))),{res:l,errorMessage:c}}function hM({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?Xl(n.fileName):null,C=e||N,S=n?Ct(n.dirName):null,_=v.useCallback(()=>{var I;(I=y.current)==null||I.abort(),y.current=null,k.current=!1,h("idle"),x(void 0),w([])},[]);v.useEffect(()=>{var I;j.current!==C&&(k.current?(k.current=!1,(I=y.current)==null||I.abort(),y.current=null,h("idle"),x(void 0)):_(),j.current=C)},[C,_]),v.useEffect(()=>()=>{var I;(I=y.current)==null||I.abort()},[]),v.useEffect(()=>{u&&_()},[u,_]);const P=v.useCallback(async(I,D)=>{if(u)return;if(!C&&m){w(L=>[...L,I]),h("connected"),x(void 0),k.current=!0,o==null||o();try{if(!await m(I,D)){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,I]),h("connected"),x(void 0);const O=s??Ji;o==null||o();const $=new AbortController;y.current=$;try{const L={sessionId:C,message:I,images:D||void 0,cwd:t||void 0,permissions:O,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:F,errorMessage:z}=await W2(H=>ye("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:H}),signal:$.signal}),{model:i,agentKind:S,errorFallback:H=>`Request failed (${H.status})`,onModelRejected:f});y.current===$&&(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===$&&(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 I;(I=y.current)==null||I.abort(),y.current=null,T(),h("idle"),w([])},[T]),R=E,M=v.useCallback((I=1)=>{w(D=>D.slice(I))},[]);return{status:p,error:g,pendingMessages:b,sendMessage:P,disconnect:A,interrupt:E,stopAgent:R,consumePending:M,isConnected:p==="connected"}}const is={expandAll:!1,expandToolPayloads:!1},gM={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...is,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function Wp(n,e,t,s){const o=L0(e,t,s);return o===n.turns?n:{...n,turns:o}}function no(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function xM(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...no(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...is,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...no(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...is,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...no(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...is,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,...is};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,...is}:{...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:Wp(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:Wp(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...no(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,...no(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...is,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...no(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...is,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 H2(){return v.useReducer(xM,gM)}function Hp(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function K2({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($=>$.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 $;($=l.current)==null||$.scrollIntoView({behavior:"smooth"})})},[]),k=v.useCallback(()=>{Hp(()=>{const $=a.current;$&&($.scrollTop=$.scrollHeight),c.current=!0,d.current=!1})},[]),N=v.useCallback(()=>{p.current=!0},[]),C=v.useRef(!1),S=v.useRef(!1),_=v.useCallback(()=>{const $=a.current;if(!$)return;const L=$.scrollTop>10,F=$.scrollHeight-$.scrollTop-$.clientHeight>10;L!==C.current&&(C.current=L,g(L)),F!==S.current&&(S.current=F,b(F))},[]),P=v.useCallback(()=>{const $=a.current;$&&(c.current=$.scrollHeight-$.scrollTop-$.clientHeight<150,_())},[_]),A=v.useCallback($=>{f.current=$},[]),T=v.useRef(o);v.useEffect(()=>{if(o===T.current)return;T.current=o;const $=p.current;p.current=!1;const L=()=>{const z=a.current;z&&($?(z.scrollTop=0,c.current=!1):(z.scrollTop=z.scrollHeight,c.current=!0),d.current=!1)};Hp(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 $=(n==null?void 0:n.sessionId)??null,L=m.current,F=new Set(u.map(U=>U.id));if(!L||L.sessionId!==$){m.current={sessionId:$,ids:F};return}const z=u.filter(U=>!L.ids.has(U.id));if(m.current={sessionId:$,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 R=(n==null?void 0:n.turns.length)??0;v.useEffect(()=>{if(R===0)return;const $=R-f.current;$>0&&(E>0&&s(Math.min($,E)),(d.current||c.current)&&(j(),d.current=!1)),f.current=R},[R,E,s,j]);const M=n==null?void 0:n.turns.at(-1),I=(M==null?void 0:M.toolCalls.length)??0,D=(M==null?void 0:M.assistantText.length)??0;v.useEffect(()=>{if(!(!n||!e)){if(c.current){const $=a.current;$&&($.scrollTop=$.scrollHeight)}requestAnimationFrame(_)}},[R,I,D,i,e,_]);const O=w===o;return v.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:x,initialScrollDone:O,handleScroll:P,scrollToBottomInstant:k,requestScrollToTop:N,resetTurnCount:A}),[h,x,O,P,k,N,A])}async function q2(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(`
|
|
135
|
+
`);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:Ct(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Ls(n,e,t,s){const o=hn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=mn(),a=hs(),{parsed:l,source:c,byteOffset:d,hasMore:f}=await q2(n,e,t,s);if(mn()!==i||hs()!==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 V2(n,e,t,s){hn.evict(n,e);const o=mn(),i=hs(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await q2(n,e,t,s);return mn()===o&&hs()===i&&hn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function bM({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),gI(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 Ls(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 Ls(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 vM=/^\/preview\/([^/]+)\/?$/;function eu(n){const e=vM.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function G2(){const n=ht();return n===jt?"":`/d/${n}`}function _c(){const n=G2();return n?`${n}/`:"/"}function Y2(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function yM(n,e){return i3(n,e)}function wM(n){const e=G2();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=r3(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:_c()}function Kp(n){const e=Y2(n),t=eu(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 jM({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 Ls(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=yM(m.dirName,m.sessionId);let h;try{h=await Ls(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=_c();window.history.replaceState(null,"",g),d.current=g,Ao(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=_c();window.history.replaceState(null,"",p),d.current=p,Ao(ht(),p)}}finally{c.current--}},[e,t,s,o,i]);return v.useEffect(()=>{if(f.current)return;f.current=!0,Ao(ht(),window.location.pathname);const m=Kp(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&u(m)},[u]),v.useEffect(()=>{if(c.current>0||eu(Y2(window.location.pathname)))return;const m=wM(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,Ao(ht(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),v.useEffect(()=>{const m=()=>{const p=Kp(window.location.pathname);d.current=window.location.pathname,Ao(ht(),window.location.pathname),u(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[u]),{previewLoadError:a}}const SM=400;function qp(){return Array.from(document.querySelectorAll("[data-live-session]"))}function kM(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 Vp(n){n.focus({preventScroll:!0});const e=kM(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 NM(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,O;const R=gp("missionControl");if(R){if(E.key===R){E.repeat||(N=!0,C=E.shiftKey||E.altKey||(R==="Meta"?E.ctrlKey:E.metaKey));return}N&&(C=!0),S=null}if(vt("commandPalette",E)){E.preventDefault(),d==null||d();return}if(vt("integratedTerminal",E)){if(!lt("terminal"))return;E.preventDefault(),p();return}if(vt("preview",E)){E.preventDefault(),h();return}if(vt("projectFiles",E)){if(!lt("hostFiles"))return;E.preventDefault(),g();return}if(vt("expandAll",E)){E.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(vt("expandToolPayloads",E)){E.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(vt("toggleSidebar",E)){E.preventDefault(),a();return}if(vt("toggleStats",E)){E.preventDefault(),l();return}if(vt("missionControl",E)){E.preventDefault(),c();return}if(vt("newSession",E)&&(E.preventDefault(),f()),vt("themeSelector",E)&&(E.preventDefault(),u()),vt("systemTerminal",E)){if(!lt("terminal"))return;E.preventDefault(),m()}if(E.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(D=s.current)==null||D.blur()),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.code.startsWith("Digit")){const $=parseInt(E.code.charAt(5),10);if($>=1&&$<=9){E.preventDefault();const F=qp()[$-1];F&&(Vp(F),F.click())}}const M=vt("recentSessionForward",E);if(M||vt("recentSessionBack",E)){E.preventDefault();const $=M?b():x();$&&w($.dirName,$.fileName)}vt("focusComposer",E)&&!U0(document.activeElement)&&(E.preventDefault(),(O=o.current)==null||O.focus());const I=vt("nextLiveSession",E);if(I||vt("prevLiveSession",E)){E.preventDefault();const $=qp();if($.length===0)return;const L=$.findIndex(CM);let F;L===-1?F=I?0:$.length-1:F=Math.max(0,Math.min($.length-1,L+(I?1:-1))),Vp($[F])}},P=function(E){const R=gp("missionControl");if(R&&E.key===R&&N){const M=!C;if(N=!1,C=!1,M){const I=Date.now();S!==null&&I-S<=SM?(S=null,E.preventDefault(),c()):S=I}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 CM(n){return n===document.activeElement}const Gp="cogpit-theme",zO=[{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 _M(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function X2(){const[n,e]=v.useState(()=>{try{const l=localStorage.getItem(Gp);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=v.useState(null),o=v.useCallback(l=>{localStorage.setItem(Gp,l),e(l),s(null)},[]),i=t??n,a=_M(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 TM="cogpit-session-history",Tc=50;function J2(){return Ft(TM)}function EM(){try{const n=localStorage.getItem(J2());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,Tc)}catch{}return[]}function Yp(n){try{localStorage.setItem(J2(),JSON.stringify(n))}catch{}}function PM(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=EM(),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>Tc&&(t.current.length=Tc),s.current=0,Yp(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),Yp(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 Q2(){return Ft(mM)}function Xp(){try{const n=localStorage.getItem(Q2());if(n){const e=JSON.parse(n);return{mode:e.mode||Ji.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return Ji}function AM(n){localStorage.setItem(Q2(),JSON.stringify(n))}function RM(){const n=B.c(21),[e,t]=v.useState(Xp),[s,o]=v.useState(Xp),i=v.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}AM(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(Ji)},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 IM=2e3;function MM(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function $M(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=>MM(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,IM);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 A2(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 oI(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function OM(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 DM(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 LM(n){return n.file_path??n.path??""}function Z2(n){const e=[];for(const t of n.toolCalls){if(t.isError||X7(t))continue;const s=LM(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 zM(n,e){return{index:e,userMessage:Pa(n.userMessage),toolCalls:Z2(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function Qi(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=Z2(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 FM(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 Zo(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(...FM(i.toolCalls,i.index))}return t}function eb(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(zM(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 tb(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 nb(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 BM(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 UM(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function xi(n,e){return n.length>0?BM(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function sb(n,e,t){return cx(rx(Ct(t)),n,e)}function ob(n,e,t,s){const o=rx(Ct(s)),i=e==null?void 0:e.id;if(i){const a=aC(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return cx(o,n,t)}class qo extends Error{constructor(){super("abort")}}async function WM(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=Qi(e.turns,e.turns.length-1,l),d=l+1,f=o.split(`
|
|
136
|
+
`).filter(Boolean),u=ob(f,e.turns[l],d,t.dirName),m=f.slice(u);if(m.length===0)throw a("Unable to locate the selected turn in the current session file"),new qo;const{retained:p,scooped:h}=tb(s.branches,l),g=eb(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},b=go(t.dirName).fileCheckpoints?(w=e.turns[l+1])==null?void 0:w.id:void 0;await i({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:u,expectedLineCount:f.length},state:x,...b?{checkpoint:{sessionId:e.sessionId,userMessageId:b,cwd:e.cwd}}:{}})}async function HM(n,e,t,s,o,i){var b;const a=n.redoUpToArchiveIndex!==void 0&&n.redoUpToArchiveIndex<s.turns.length-1,l=n.redoUpToArchiveIndex??s.turns.length-1,c=l+1,d=Zo(s.turns,l),f=a?sb(s.jsonlLines,c,e.dirName):s.jsonlLines.length,u=s.jsonlLines.slice(0,f),m=s.jsonlLines.slice(f),p=s.childBranches??[];let h;if(a&&m.length>0){const{restored:w,remaining:y}=nb(p,s.branchPointTurnIndex,c),j={...s,branchPointTurnIndex:s.branchPointTurnIndex+c,turns:s.turns.slice(c),jsonlLines:m,label:((b=s.turns[c])==null?void 0:b.userMessage)||s.label,childBranches:y.length>0?y:void 0};h=[...t.branches.map(k=>k.id===s.id?j:k),...w]}else h=[...t.branches.filter(w=>w.id!==s.id),...p];const g={...t,currentTurnIndex:t.currentTurnIndex+c,totalTurns:t.totalTurns+c,branches:h,activeBranchId:null},x=o.split(`
|
|
137
|
+
`).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:u,expectedLineCount:x.length},state:g})}async function KM(n,e,t,s,o,i,a){var j;let l=[...t.branches],c=o.split(`
|
|
138
|
+
`).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const k=Qi(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...k);const{retained:N,scooped:C}=tb(l,s.branchPointTurnIndex);l=N;const S=s.branchPointTurnIndex+1,_=ob(c,n.turns[s.branchPointTurnIndex],S,e.dirName),P=c.slice(_);if(P.length>0){const A=eb(n.turns,s.branchPointTurnIndex,P,C);l=[...l,A],c=c.slice(0,_)}}const f=i.branchTurnIndex??s.turns.length-1,u=f+1,m=f<s.turns.length-1,p=Zo(s.turns,f);d.push(...p);const h=m?sb(s.jsonlLines,u,e.dirName):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),x=s.jsonlLines.slice(h),b=s.childBranches??[];let w;if(m&&x.length>0){const{restored:k,remaining:N}=nb(b,s.branchPointTurnIndex,u);w=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+u,turns:s.turns.slice(u),jsonlLines:x,label:((j=s.turns[u])==null?void 0:j.userMessage)||s.label,childBranches:N.length>0?N:void 0},...k]}else w=b;const y={...t,currentTurnIndex:s.branchPointTurnIndex+u,totalTurns:s.branchPointTurnIndex+1+u,branches:[...l.filter(k=>k.id!==s.id),...w],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
|
|
139
|
+
`).filter(Boolean).length},state:y})}const qM=[];function rb(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,!go(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 qo;i(A.state)}catch(T){throw T instanceof qo?T:(u(String(T)),new qo)}},[]),g=(o==null?void 0:o.branches)??qM,{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 Ea(w.jsonlLines.join(`
|
|
140
|
+
`)).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(go(e==null?void 0:e.dirName).nativeRewind){const R=n.turns[A];if(!R)return;const M=n.sessionId,I=++p.current,D=()=>p.current===I&&m.current===M,O=R.id.includes("@")?R.id.slice(R.id.lastIndexOf("@")+1):R.id,$=n.turns.length-A;OM(n.sessionId,O).then(L=>{var H;if(!D())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:$,fileCount:z,filePaths:F,operationCount:z},targetTurnIndex:T,nativeRewind:{eventId:O,mode:"conversation",filesAvailable:!!(L!=null&&L.available&&z>0)}})}).catch(()=>{D()&&l({type:"undo",summary:{turnCount:$,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:T,nativeRewind:{eventId:O,mode:"conversation"}})});return}const E=Qi(n.turns,n.turns.length-1,T);l({type:"undo",summary:xi(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=Zo(w.turns);l({type:"redo",summary:xi(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=Zo(w.turns,A);l({type:"redo",summary:xi(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(D=>D.id===A);if(!E)return;const R=T??E.turns.length-1,M=n.turns.length>E.branchPointTurnIndex+1?Qi(n.turns,n.turns.length-1,E.branchPointTurnIndex):[],I=Zo(E.turns,R);l({type:"branch-switch",summary:xi([...M,...I],R+1),targetTurnIndex:E.branchPointTurnIndex,branchId:A,branchTurnIndex:R})},[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 M=A&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",I=await DM(n.sessionId,a.nativeRewind.eventId,M);if(!I.ok){u(I.error);return}await t(),l(null);return}const T=o??UM(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 R=await E.text();if(a.type==="undo")await WM(a,n,e,T,R,h,u);else if(a.type==="redo"){const M=g.find(I=>I.id===a.branchId);if(!M){l(null);return}await HM(a,e,T,M,R,h)}else if(a.type==="branch-switch"){const M=g.find(I=>I.id===a.branchId);if(!M){l(null);return}await KM(n,e,T,M,R,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 qo))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 VM(n){try{const t=await(await as("/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 Jp(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:o3(t==null?void 0:t.mode,Bs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function GM(){const n=B.c(26),[e,t]=v.useState(!0),[s,o]=v.useState(null),[i,a]=v.useState(null),[l,c]=v.useState(Bs),[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),W4(U.useBuiltInEditor)},n[0]=y):y=n[0];const j=y;let k;n[1]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{var q;(q=b.current)==null||q.abort();const U=new AbortController;b.current=U;const W=await VM(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),Jp(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(XM);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 R;n[10]!==i?(R=[i,N],n[10]=i,n[11]=R):R=n[11],v.useEffect(E,R);let M;n[12]===Symbol.for("react.memo_cache_sentinel")?(M=()=>f(!1),n[12]=M):M=n[12];const I=M;let D;n[13]!==i?(D=U=>{if(f(!1),U!==i){a(U),window.location.reload();return}x(YM),N()},n[13]=i,n[14]=D):D=n[14];const O=D;let $;n[15]===Symbol.for("react.memo_cache_sentinel")?($=()=>f(!0),n[15]=$):$=n[15];const L=$;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),Jp(U.signal).then(q=>{U.signal.aborted||w.current!==U||j(q)}).catch(q=>{U.signal.aborted||w.current!==U||(a(null),o(q instanceof Error?q.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]!==O||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:I,handleConfigSaved:O,retryConfig:z,networkUrl:u,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=O,n[22]=p,n[23]=u,n[24]=d,n[25]=H):H=n[25],H}function YM(n){return n+1}function XM(n){return n+1}const Qp={authenticated:!0,edition:"personal",user:null,capabilities:va},dn={authenticated:!1,edition:"personal",user:null,capabilities:Er},ib=Object.keys(va);function Zp(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&ib.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function JM(n,e){const t={...Er};for(const s of ib)t[s]=n[s]&&e[s];return t}async function eh(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function QM(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 Lo(n){var e;return ao(n),eg(((e=n.user)==null?void 0:e.id)??null),n}function ZM(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,ao(dn),o({...dn,checked:!1});return}const p=c.current;c.current=!1,ao(dn),o(j=>p?{...j,capabilities:Er,checked:!1}:{...dn,checked:!1});const h=new AbortController;l.current=h;const g=Os(),x=eh(as,h.signal),b=g?QM(h.signal):Promise.resolve(n),w=g?eh(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=Zp(k,n)?k:n==="personal"?Qp:null;if(!S||N===null){o({...Lo(dn),checked:!1});return}if(!g){o({...Lo(S),checked:!0});return}const _=Zp(C,N)?C:N==="personal"?Qp:null;if(!_){o({...Lo(dn),checked:!1});return}o({...Lo({authenticated:S.authenticated,edition:S.edition,user:S.user,capabilities:JM(S.capabilities,_.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Lo(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,ao(dn),eg(null),o({...dn,checked:!1}),a(n$)},h=g=>{var w,y;const x=ht();if(x===jt)return;const b=(w=g.detail)==null?void 0:w.deviceId;b&&b!==x||((y=l.current)==null||y.abort(),c.current=!0,ao(dn),o(t$),a(e$))};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 e$(n){return n+1}function t$(n){return{...n,capabilities:Er,checked:!1}}function n$(n){return n+1}const s$=3e4;function o$(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(),s$);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 r$(){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 i$(n,e){return n?`${n}.jsonl`:e??null}async function ab(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 a$=300,Ul=new Map;function Ec(n,e){const t=Ft(n),s=Ul.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{Ul.delete(t),Ft(n)===t&&(async()=>{try{await ye(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},a$);Ul.set(t,{patch:o,timer:i})}function Pc(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function th(n){const e=await ab(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function nh(n,e){Ec(n,{mcpServers:e})}async function l$(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function sh(n,e){try{const t=await ye(n,{signal:e});if(e.aborted)return null;const s=await l$(t);return e.aborted?null:s}catch{return null}}async function oh(n,e,t){const s=Pc(t);if(s.size===0)return[];if(n){const o=await th(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await th(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function c$(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,sh(`/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 oh(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 oh(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&&nh(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),sh(`/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 _=Pc(S.servers);d(P=>{const A=P.filter(T=>_.has(T));return b.current&&nh(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=Pc(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 d$(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(f$),e[4]=l,e[5]=c):c=e[5];const d=c.length;let f;e[6]!==l?(f=l.find(u$)??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 u$(n){return n.status==="in_progress"}function f$(n){return n.status==="completed"}function m$(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 p$(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(h$).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 h$(n){return n.json()}function Wl(n,e){const t=B.c(6),[s,o]=Dr(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 rh(){if(typeof window>"u")return Xt.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return Xt.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return Xt.fileChanges}function g$(n,e){const t=B.c(47),[s,o]=Wl("panel-sidebar-visible",!0),[i,a]=Wl("panel-worktrees-visible",!1),[l,c]=Wl("panel-workflows-visible",!1);let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=rh(),t[0]=d):d=t[0];const[f,u]=Dr("workspace-panel-active",d);let m;t[1]!==f?(m=typeof f=="string"||f===null?f:rh(),t[1]=f,t[2]=m):m=t[2];const p=m,[h,g]=v.useState(!1),[x,b]=v.useState(!1);let w;t[3]!==o||t[4]!==s?(w=()=>{v.startTransition(()=>o(!s))},t[3]=o,t[4]=s,t[5]=w):w=t[5];const y=w;let j;t[6]!==a?(j=()=>a(v$),t[6]=a,t[7]=j):j=t[7];const k=j;let N;t[8]!==c?(N=()=>c(b$),t[8]=c,t[9]=N):N=t[9];const C=N;let S;t[10]!==u?(S=K=>{v.startTransition(()=>{u(X=>X===K?null:K)})},t[10]=u,t[11]=S):S=t[11];const _=S;let P;t[12]!==u?(P=K=>{v.startTransition(()=>u(K))},t[12]=u,t[13]=P):P=t[13];const A=P;let T;t[14]!==u?(T=()=>{v.startTransition(()=>u(null))},t[14]=u,t[15]=T):T=t[15];const E=T;let R;t[16]!==e||t[17]!==n.mainView?(R=()=>{const K=n.mainView==="config";v.startTransition(()=>{e({type:K?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=n.mainView,t[18]=R):R=t[18];const M=R;let I;t[19]!==e||t[20]!==n.mainView?(I=()=>{const K=n.mainView==="mission";v.startTransition(()=>{e({type:K?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=n.mainView,t[21]=I):I=t[21];const D=I;let O;t[22]!==e?(O=K=>{v.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:K})})},t[22]=e,t[23]=O):O=t[23];const $=O;let L;t[24]===Symbol.for("react.memo_cache_sentinel")?(L=()=>g(!0),t[24]=L):L=t[24];const F=L;let z;t[25]===Symbol.for("react.memo_cache_sentinel")?(z=()=>g(!1),t[25]=z):z=t[25];const H=z;let U;t[26]===Symbol.for("react.memo_cache_sentinel")?(U=()=>b(x$),t[26]=U):U=t[26];const W=U;let q;t[27]===Symbol.for("react.memo_cache_sentinel")?(q=()=>b(!1),t[27]=q):q=t[27];const V=q;let Y;return t[28]!==p||t[29]!==E||t[30]!==$||t[31]!==M||t[32]!==D||t[33]!==y||t[34]!==C||t[35]!==k||t[36]!==A||t[37]!==o||t[38]!==c||t[39]!==a||t[40]!==h||t[41]!==s||t[42]!==x||t[43]!==l||t[44]!==i||t[45]!==_?(Y={showSidebar:s,showWorktrees:i,showWorkflows:l,activeWorkspacePanel:p,showProjectSwitcher:h,showThemeSelector:x,handleToggleSidebar:y,handleToggleWorktrees:k,handleToggleWorkflows:C,toggleWorkspacePanel:_,openWorkspacePanel:A,closeWorkspacePanel:E,handleToggleConfig:M,handleToggleMission:D,handleEditConfig:$,handleOpenProjectSwitcher:F,handleCloseProjectSwitcher:H,handleToggleThemeSelector:W,handleCloseThemeSelector:V,setShowSidebar:o,setShowWorktrees:a,setShowWorkflows:c},t[28]=p,t[29]=E,t[30]=$,t[31]=M,t[32]=D,t[33]=y,t[34]=C,t[35]=k,t[36]=A,t[37]=o,t[38]=c,t[39]=a,t[40]=h,t[41]=s,t[42]=x,t[43]=l,t[44]=i,t[45]=_,t[46]=Y):Y=t[46],Y}function x$(n){return!n}function b$(n){return!n}function v$(n){return!n}function y$(n){var q;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:V,fileName:Y}=e.sessionSource;try{const{parsed:K,source:X}=await V2(V,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:K,source:X})}catch{}},[e.sessionSource,t,g]),[b,w]=v.useState(null),y=v.useCallback(V=>w(V),[]),j=v.useCallback(()=>w(null),[]),k=v.useCallback(async(V,Y)=>{try{const K=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:V,fileName:Y})});if(!K.ok)return;const X=await K.json(),{parsed:Q,source:J}=await Ls(X.dirName,X.fileName,g,"session");t({type:"LOAD_SESSION",session:Q,source:J,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(V,Y)=>{try{await ye("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:V,fileName:Y})})}catch{}},[]),S=v.useCallback(async V=>{var Q,J;if(!e.sessionSource)return;const{dirName:Y,fileName:K}=e.sessionSource,X=(J=(Q=e.session)==null?void 0:Q.turns[V])==null?void 0:J.id;try{const ee=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:K,turnIndex:V,turnUuid:X})});if(!ee.ok)return;const oe=await ee.json(),{parsed:se,source:re}=await Ls(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((V,Y)=>{o(V,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 R=v.useRef(m);R.current=m;const M=v.useRef(f);M.current=f;const I=v.useRef(u);I.current=u;const D=v.useRef(l);D.current=l;const O=((q=e.session)==null?void 0:q.sessionId)??null,$=v.useRef(null);v.useEffect(()=>{O!==$.current&&($.current=O,O&&A(V=>O in V?V:{...V,[O]:{model:T.current,effort:E.current,fastMode:M.current,ultracode:I.current,mcpConfig:R.current}}))},[O]);const L=O?P[O]: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(!O)return;const V=T.current,Y=E.current,K=M.current,X=I.current,Q=R.current,J=D.current,ee=((oe=e.sessionSource)==null?void 0:oe.agentKind)??Ct(((se=e.sessionSource)==null?void 0:se.dirName)??null);Ht(ee).settingsApply==="live"&&await ye(`/api/claude/settings/${encodeURIComponent(O)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:V,effort:Y,fastMode:K,ultracode:X,mcpConfig:Q,permissionMode:J.mode,allowedTools:J.allowedTools,disallowedTools:J.disallowedTools})}),A(re=>({...re,[O]:{model:V,effort:Y,fastMode:K,ultracode:X,mcpConfig:Q}})),i()},[O,e.sessionSource,i]),U=v.useCallback(async()=>{if(O)try{await ye("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:O})})}catch{}},[O]),W=v.useCallback((V,Y)=>{bs(Y)&&p(),h(V,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 lb(){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-RMitC4X_.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(()=>Ea(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(()=>uC(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 w$=30;function cb({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=${w$}`);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(`
|
|
141
|
+
`)),N=L0(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 j$(n){const e=B.c(50),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??Bs,c=rg(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=y3(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":ua(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=Yh(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=b3(l,d),e[11]=l,e[12]=d,e[13]=P):P=e[13];const A=P,[T,E]=v.useState(null),R=v.useRef(null),M=(o==null?void 0:o.fileName)??null,I=v.useRef(M);let D,O;e[14]!==M?(D=()=>{const ee=I.current;I.current=M,!(ee===null||ee===M)&&x(!1)},O=[M],e[14]=M,e[15]=D,e[16]=O):(D=e[15],O=e[16]),v.useEffect(D,O);let $,L;e[17]!==i?($=()=>{i&&x(!1)},L=[i],e[17]=i,e[18]=$,e[19]=L):($=e[18],L=e[19]),v.useEffect($,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 ${tn(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,q;e[23]!==c||e[24]!==i||e[25]!==d||e[26]!==o?(W=()=>{d&&(!o&&!i||c.some(ee=>ee.value===d)||f(""))},q=[c,d,o,i],e[23]=c,e[24]=i,e[25]=d,e[26]=o,e[27]=W,e[28]=q):(W=e[27],q=e[28]),v.useEffect(W,q);let V,Y;e[29]!==T?(V=()=>{if(!T)return;const ee=setTimeout(()=>E(null),12e3);return()=>clearTimeout(ee)},Y=[T],e[29]=T,e[30]=V,e[31]=Y):(V=e[30],Y=e[31]),v.useEffect(V,Y);const K=s==null?void 0:s.rawMessages;let X,Q;e[32]!==l||e[33]!==a||e[34]!==K?(X=()=>{if(!a||!K||!Ht(l).modelFallbackNotices)return;let ee;for(let ae=K.length-1;ae>=0;ae=ae-1,ae){const te=K[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(R.current===oe)return;R.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}`)},Q=[a,K,l],e[32]=l,e[33]=a,e[34]=K,e[35]=X,e[36]=Q):(X=e[35],Q=e[36]),v.useEffect(X,Q);let J;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?(J={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]=J):J=e[49],J}const S$=["model","effort","fastMode","ultracode","permissionMode"];function k$({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 ab(n).then(d=>{if(c||d===null)return;if(S$.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 Ec(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,Ec(n,a.current))},[l,n])}function N$(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 C$(n){const e=B.c(54),{sessionId:t,sessionCwd:s,pendingPath:o,sessionDirName:i,pendingDirName:a,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:d,openWorkspacePanel:f,closeWorkspacePanel:u}=n,m=N$(t),[p,h]=v.useState(null),[g,x]=v.useState(0),b=v.useRef(0),w=s??o??void 0,y=!!(w&&(p==null?void 0:p.kind)==="preview"&&p.cwd===w),j=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(w??null)?p:null;let k;e[0]!==a||e[1]!==o?(k={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=k):k=e[2];const N=k;let C;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(C=()=>{if(Os()){console.warn("[open-terminal] unavailable for remote devices");return}const K=s??o??void 0,X=i??a??l??void 0;if(!K&&!X){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:X})}).then(R$).catch(A$)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=C):C=e[8];const S=C;let _;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(_=K=>{if(Os()){console.warn("[mcp-auth] unavailable for remote devices");return}const X=s??o??void 0,Q=i??a??l??void 0;!X&&!Q||ye("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:X,dirName:Q,command:"claude /mcp"})}).catch(P$)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=_):_=e[14];const P=_;let A;e[15]!==o||e[16]!==m||e[17]!==s?(A=()=>{const X=[...m.processes.values()].filter(E$).at(-1);if(!X){(s??o)&&x(T$);return}m.activeProcessId===X.id&&!m.collapsed?m.toggleCollapse():m.setActive(X.id)},e[15]=o,e[16]=m,e[17]=s,e[18]=A):A=e[18];const T=A;let E;e[19]!==o||e[20]!==s?(E=()=>{(s??o)&&x(_$)},e[19]=o,e[20]=s,e[21]=E):E=e[21];const R=E;let M;e[22]!==u||e[23]!==w||e[24]!==y?(M=()=>{w&&v.startTransition(()=>{u(),h(y?null:{kind:"preview",cwd:w})})},e[22]=u,e[23]=w,e[24]=y,e[25]=M):M=e[25];const I=M;let D;e[26]!==d||e[27]!==u||e[28]!==w||e[29]!==f?(D=()=>{if(w){if(d===Xt.projectFiles){u();return}v.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),f(Xt.projectFiles)})}},e[26]=d,e[27]=u,e[28]=w,e[29]=f,e[30]=D):D=e[30];const O=D;let $;e[31]!==w||e[32]!==f||e[33]!==c?($=K=>{if(!c)return!1;const X=K4(K,w);if(!X)return!1;b.current=b.current+1;const Q=b.current;return v.startTransition(()=>h({kind:"project-files",root:X.root,anchorCwd:w??null,request:X.file?{file:X.file,mode:X.mode,line:X.line,token:Q}:null})),f(Xt.projectFiles),!0},e[31]=w,e[32]=f,e[33]=c,e[34]=$):$=e[34];const L=$;let F,z;e[35]!==L?(z=()=>H4(L),F=[L],e[35]=L,e[36]=F,e[37]=z):(F=e[36],z=e[37]),v.useEffect(z,F);let H;e[38]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{v.startTransition(()=>h(null))},e[38]=H):H=e[38];const U=H,W=!!(w&&d===Xt.projectFiles),q=j==null?void 0:j.root,V=(j==null?void 0:j.request)??null;let Y;return e[39]!==w||e[40]!==P||e[41]!==R||e[42]!==S||e[43]!==T||e[44]!==I||e[45]!==O||e[46]!==g||e[47]!==N||e[48]!==m||e[49]!==y||e[50]!==W||e[51]!==q||e[52]!==V?(Y={processPanel:m,currentCwd:w,showPreview:y,showProjectFiles:W,projectFilesRoot:q,projectFilesRequest:V,launchTerminalRequest:g,pendingProject:N,handleOpenTerminal:S,handleMcpAuth:P,handleToggleIntegratedTerminal:T,handleNewIntegratedTerminal:R,handleTogglePreview:I,handleToggleProjectFiles:O,closeRightWorkspace:U},e[39]=w,e[40]=P,e[41]=R,e[42]=S,e[43]=T,e[44]=I,e[45]=O,e[46]=g,e[47]=N,e[48]=m,e[49]=y,e[50]=W,e[51]=q,e[52]=V,e[53]=Y):Y=e[53],Y}function _$(n){return n+1}function T$(n){return n+1}function E$(n){return n.type==="terminal"}function P$(n){return console.error("[mcp-auth] open-terminal failed:",n)}function A$(n){return console.error("[open-terminal] fetch failed:",n)}function R$(n){n.ok||n.json().then(M$).catch(I$)}function I$(){}function M$(n){return console.error("[open-terminal]",n.error)}function $$(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
142
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const O$={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function db(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:Ct(n.dirName)}}function D$(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...O$},rawMessages:[],agentKind:Ct(n.dirName)}}function ub(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:Ea(n)}}catch{return null}}async function L$(n,e,t=3,s=100,o=!0){if(o){const i=ub(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:Ea(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function z$(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await L$(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:db(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function ih(n,e,t,s,o){const i=ub(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??D$(n),c=db(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),z$(n,e,t,a),n.sessionId}async function F$(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 B$({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 D;const T=j.current;if(!T)return null;const E=Ct(T),R=k.current;(D=y.current)==null||D.abort();const M=new AbortController;y.current=M,m(!0),h(null),o==null||o(P);const I=Date.now();try{const O=$$(P),$=tn(E),{capabilities:L}=$,F={dirName:T,cwd:$.dirName.lossy?R??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&&O||void 0,worktreeName:L.worktrees&&g?b||w3(P):void 0,mcpConfig:L.mcp&&f||void 0},{res:z,errorMessage:H}=await W2(q=>ye("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:q}),signal:M.signal}),{model:a,agentKind:E,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(E==="codex"){const q=await F$(T,P,I,M);if(q){j.current=null,k.current=null;const V=await ih(q,M,e,t,s);return O&&V&&Nc(V,O),V}}return h(H||`Failed to create session (${z.status})`),null}const U=await z.json();j.current=null,k.current=null;const W=await ih(U,M,e,t,s);return O&&W&&Nc(W,O),W}catch(O){return M.signal.aborted||h(O instanceof Error?O.message:"Failed to create session"),null}finally{M.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 U$(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 q;return(q=g.current)==null?void 0:q.call(g)},300),setTimeout(()=>{var q;return(q=g.current)==null?void 0:q.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=B$(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(Jr===null)return null;const W=_.current;if(W.has(U))return W.get(U)??null;try{const q=await ye("/api/projects");if(!q.ok)return W.set(U,null),null;const V=await q.json(),Y=l3(V,U,Jr);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 q=W??null;if(!q){C(null),k(U);return}const V=Ct(U)===Jr?Jr:null,Y=V?el(V,q):await A(q);C(Y?{discoveredDirName:Y,cwd:q}:null),k(V&&Y?Y:U,q)},e[13]=k,e[14]=T):T=e[14];const E=T;let R;e[15]!==i||e[16]!==E?(R=U=>{const W=el(i,U);E(W,U)},e[15]=i,e[16]=E,e[17]=R):R=e[17];const M=R;let I;e[18]!==k||e[19]!==N?(I=U=>{if(!N)return;const W=el(U,N.cwd,N.discoveredDirName);k(W,N.cwd)},e[18]=k,e[19]=N,e[20]=I):I=e[20];const D=I;let O;e:{if(!j.creatingSession||!a){O=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],O=W}const $=O;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?D:void 0;let H;return e[28]!==M||e[29]!==E||e[30]!==j.cancelCreation||e[31]!==j.clearCreateError||e[32]!==j.createAndSend||e[33]!==j.createError||e[34]!==j.creatingSession||e[35]!==j.setWorktreeEnabled||e[36]!==j.worktreeEnabled||e[37]!==$||e[38]!==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:$,pendingAgentKindChange:z,handleStartNewSession:E,handleStartNewFolder:M},e[28]=M,e[29]=E,e[30]=j.cancelCreation,e[31]=j.clearCreateError,e[32]=j.createAndSend,e[33]=j.createError,e[34]=j.creatingSession,e[35]=j.setWorktreeEnabled,e[36]=j.worktreeEnabled,e[37]=$,e[38]=z,e[39]=H):H=e[39],H}const Hl=new Set;function W$(n,e){const t=mn(),s=hs();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function H$(n,e,t){const s=W$(n,e);if(!Hl.has(s)&&!hn.get(n,e)){Hl.add(s);try{await Ls(n,e,t,"session prefetch")}catch{}finally{Hl.delete(s)}}}function K$({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 sg().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?(ma(),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(Dt,{children:[r.jsxs(Bt,{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(Hy,{className:"size-4"})}),r.jsx(Vt,{children:"Sign in to Cogpit"}),r.jsx(Gt,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Lt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(At,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Lt,{className:"flex flex-col gap-4",children:[r.jsxs(Co,{children:[p&&r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"login-username",children:"Username"}),r.jsx(zt,{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(ns,{children:[r.jsx(ss,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(vn,{align:"inline-end",children:r.jsx(Rr,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(oa,{}):r.jsx(So,{})})})]})]})]}),d&&r.jsxs(St,{variant:"destructive",children:[r.jsx(en,{"aria-hidden":"true"}),r.jsx(It,{children:"Sign in failed"}),r.jsx(kt,{children:d})]})]}),r.jsx(Eo,{children:r.jsxs(Z,{type:"submit",className:"w-full",disabled:g,children:[u&&r.jsx(At,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const ah=16,_i="__cogpitBootstrapToken";function q$(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[_i]=="string"?t[_i]:"");return e&&window.history.replaceState({...t,[_i]:e},"",`${window.location.pathname}${window.location.search}`),s}function lh(){const n={...window.history.state||{}};delete n[_i],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function V$({onAuthenticated:n,onBootstrapClosed:e}){const[t]=v.useState(q$),[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<ah||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){lh(),c(""),f(""),o(""),a(""),await e(),n();return}if(k.status===410){lh(),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(Dt,{children:[r.jsxs(Bt,{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(Ky,{className:"size-4"})}),r.jsx(Vt,{children:"Create the first admin"}),r.jsx(Gt,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Lt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(St,{children:[r.jsx(yn,{"aria-hidden":"true"}),r.jsx(It,{children:"Setup link required"}),r.jsx(kt,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(Co,{children:[r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(zt,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(xo,{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(zt,{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(ns,{children:[r.jsx(ss,{id:"bootstrap-password",type:u?"text":"password",value:l,onChange:j=>c(j.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(vn,{align:"inline-end",children:r.jsx(Rr,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":u?"Hide password":"Show password",children:u?r.jsx(oa,{}):r.jsx(So,{})})})]}),r.jsxs(xo,{children:["Use at least ",ah," characters."]})]}),r.jsxs(gt,{"data-invalid":b,children:[r.jsx(xt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(zt,{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(fs,{children:"Passwords do not match"})]})]}),p&&r.jsxs(St,{variant:"destructive",children:[r.jsx(en,{"aria-hidden":"true"}),r.jsx(It,{children:"Could not create the account"}),r.jsx(kt,{children:p})]})]}),r.jsx(Eo,{children:r.jsxs(Z,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(At,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function G$(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=fa(),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 ng().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 ow().then(R=>{!T&&d.current===E&&(a(R),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 R=d.current=d.current+1,M=()=>{T||d.current!==R||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){M();return}xf().then(I=>{T||d.current!==R||(o(I),I.edition==="team"&&M())})};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 xf())},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),rw().finally(Y$)},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 Y$(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const X$=v.lazy(()=>Ke(()=>import("./index-C-5Kgwol.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),J$=v.lazy(()=>Ke(()=>import("./WorkflowsPanel-Beg1AAtq.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function Q$(){var $u,Ou,Du,Lu,zu,Fu,Bu,Uu,Wu,Hu,Ku,qu,Vu,Gu,Yu,Xu,Ju,Qu,Zu,ef;const n=eu(window.location.pathname),e=GM(),t=G$(),s=ZM(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=Ma(),d=X2(),[f,u]=H2(),{procBySession:m}=qx(),{parse:p,append:h}=lb(),g=v.useCallback(Ce=>{u({type:"SET_OLDER_TURNS",turns:Ce})},[u]),x=v.useCallback((Ce,Ve)=>{H$(Ce,Ve,p)},[p]),b=cb({dirName:(($u=f.sessionSource)==null?void 0:$u.dirName)??null,fileName:((Ou=f.sessionSource)==null?void 0:Ou.fileName)??null,sessionChangeKey:f.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=b,y=!!f.searchQuery&&b.hasMore,j=((Du=f.session)==null?void 0:Du.turns.length)??0;v.useEffect(()=>{y&&w()},[y,w,j]);const k=g$(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),[]),R=v.useCallback(()=>{var Ce;return(Ce=C.current)==null?void 0:Ce.focus()},[]),M=v.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!0}),[u]),I=v.useCallback(()=>u({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[u]),D=v.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!1}),[u]),O=k.toggleWorkspacePanel,$=v.useCallback(()=>O(Xt.sessionInfo),[O]),L=v.useCallback(Ce=>{v.startTransition(()=>{u({type:"SET_DASHBOARD_PROJECT",dirName:Ce})})},[u]),F=f.pendingCwd??(f.pendingDirName?gn(f.pendingDirName):null),z=((Lu=f.sessionSource)==null?void 0:Lu.agentKind)??Ct(((zu=f.sessionSource)==null?void 0:zu.dirName)??f.pendingDirName??null),H=(Fu=f.session)!=null&&Fu.sessionId?m.get(f.session.sessionId):void 0,U=Ht(z),W=Zd(z,H),q=U.worktrees,V=U.mcp,Y=p$(i?((Bu=f.session)==null?void 0:Bu.cwd)??F??void 0:void 0,i&&U.slashCommands),K=v.useCallback(Ce=>{if(!i)return;const Ve=Y.suggestions.find(bt=>bt.name===Ce);v.startTransition(()=>{u({type:"OPEN_CONFIG",filePath:Ve==null?void 0:Ve.filePath})})},[i,u,Y.suggestions]),X=v.useCallback(async(Ce,Ve)=>{if(!i)return null;const bt=Y.suggestions.find(cn=>cn.name===Ce);if(!(bt!=null&&bt.filePath))return null;try{const cn=await ye("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:bt.filePath,args:Ve||""})});return cn.ok?(await cn.json()).content??null:null}catch{return null}},[i,Y.suggestions]),{processPanel:Q,currentCwd:J,showPreview:ee,showProjectFiles:oe,projectFilesRoot:se,projectFilesRequest:re,launchTerminalRequest:ie,pendingProject:ae,handleOpenTerminal:te,handleMcpAuth:me,handleToggleIntegratedTerminal:de,handleNewIntegratedTerminal:le,handleTogglePreview:he,handleToggleProjectFiles:ge,closeRightWorkspace:ce}=C$({sessionId:(Uu=f.session)==null?void 0:Uu.sessionId,sessionCwd:(Wu=f.session)==null?void 0:Wu.cwd,pendingPath:F,sessionDirName:(Hu=f.sessionSource)==null?void 0:Hu.dirName,pendingDirName:f.pendingDirName,dashboardProject:f.dashboardProject,supportsFileWorkspace:!c&&a,activeWorkspacePanel:k.activeWorkspacePanel,openWorkspacePanel:k.openWorkspacePanel,closeWorkspacePanel:k.closeWorkspacePanel}),ve=d$(f.session??null),[xe,pe]=v.useState(!1),je=((Ku=f.sessionSource)==null?void 0:Ku.dirName)??f.pendingDirName??f.dashboardProject??null,_e=o$(o&&q&&k.showWorktrees?je:null),Re=v.useMemo(()=>{const Ce=f.session;return Ce?Ce.turns.some(Ve=>Ui(Ve.toolCalls,Ce.cwd)||Ve.subAgentActivity.some(bt=>Ui(bt.toolCalls,Ce.cwd))):!1},[f.session]),De=v.useMemo(()=>{if(!f.session||!U.workflows)return 0;let Ce=0;for(const Ve of f.session.turns)for(const bt of Ve.toolCalls)bt.name==="Workflow"&&Ce++;return Ce},[f.session,U.workflows]),Te=De>0,Ie=v.useMemo(()=>{const Ce=f.sessionSource;return!Ce||!U.workflows||bs(Ce.fileName)?{dirName:null,sessionId:null}:{dirName:Ce.dirName,sessionId:Xl(Ce.fileName)}},[f.sessionSource,U.workflows]),Le=fM(Ie.dirName,Ie.sessionId,Te),ze=Te||Le.workflows.length>0,Ue=Le.workflows.length||De,Se=k.setShowWorkflows,He=v.useCallback(()=>Se(!0),[Se]),[Oe,Ne]=v.useState(!1),[fe,Pe]=v.useState(!1),Me=k.openWorkspacePanel;v.useEffect(()=>{if(!a)return;const Ce=()=>{c?Ne(!0):Me(Xt.fileChanges)};return window.addEventListener(hr,Ce),()=>window.removeEventListener(hr,Ce)},[a,Me,c]);const Fe=v.useMemo(()=>f.session?dx(f.session):null,[f.session]),ne=v.useRef(null),{isLive:ue,sseState:ke,isCompacting:Ae,streamingOverlay:$e,turnError:We,agentProgress:Xe,promptSuggestion:nt}=B2(f.sessionSource,Ce=>{v.startTransition(()=>{u({type:"UPDATE_SESSION",session:Ce})})},p,h,()=>{var Ce;return(Ce=ne.current)==null?void 0:Ce.call(ne)},f.session),Be=v.useMemo(()=>$e.reduce((Ce,Ve)=>Ce+Ve.blocks.reduce((bt,cn)=>bt+cn.text.length,0),0),[$e]),Ge=m$(((qu=f.session)==null?void 0:qu.cwd)??null),ot=RM(),wn=ot.setMode,ct=$M(W?null:((Vu=f.session)==null?void 0:Vu.sessionId)??null),Hs=W?null:ct.plan??Fe,{selectedModel:nn,setSelectedModel:jn,selectedEffort:Ks,setSelectedEffort:qe,fastModeEnabled:st,ultracodeEnabled:mt,effectiveEffort:Rt,fastModeAvailable:Bn,fastModeActive:Un,setFastModeEnabled:Ha,ultracodeAvailable:pb,ultracodeActive:Br,setUltracodeEnabled:Ka,imageInputAvailable:tu,modelFallbackNotice:hb,dismissModelFallbackNotice:gb,handleModelRejected:nu}=j$({agentKind:z,session:f.session,sessionSource:f.sessionSource,pendingDirName:f.pendingDirName,isLive:ue}),su=i$((Gu=f.session)==null?void 0:Gu.sessionId,(Yu=f.sessionSource)==null?void 0:Yu.fileName);k$({sessionKey:su,values:{model:nn,effort:Ks,fastMode:st,ultracode:mt,permissionMode:ot.config.mode},onHydrate:v.useCallback(Ce=>{Ce.model!==void 0&&jn(Ce.model),Ce.effort!==void 0&&qe(Ce.effort),Ce.fastMode!==void 0&&Ha(Ce.fastMode),Ce.ultracode!==void 0&&Ka(Ce.ultracode),Ce.permissionMode&&wn(Ce.permissionMode)},[jn,qe,Ha,Ka,wn])});const sn=c$(V&&i?J:void 0,V&&i?je??void 0:void 0,V&&i?su??void 0:void 0,i),{showWorktrees:ou,setShowWorktrees:ru,showWorkflows:iu}=k;v.useEffect(()=>{!q&&ou&&ru(!1)},[q,ou,ru]),v.useEffect(()=>{iu&&!ze&&Se(!1)},[iu,ze,Se]);const{creatingSession:au,createError:lu,clearCreateError:xb,createAndSend:bb,cancelCreation:cu,worktreeEnabled:vb,setWorktreeEnabled:yb,sessionFinalizedRef:Ur,liveSessionsRefreshRef:du,pendingSessionInfo:uu,pendingAgentKindChange:wb,handleStartNewSession:fu,handleStartNewFolder:jb}=U$({permissionsConfig:ot.config,dispatch:u,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:f.pendingDirName,pendingCwd:f.pendingCwd,onModelRejected:nu,model:nn,effort:Rt,fastMode:Un,ultracode:Br,mcpConfig:V&&i?sn.mcpConfigJson:null}),pt=hM({sessionSource:f.sessionSource,parsedSessionId:((Xu=f.session)==null?void 0:Xu.sessionId)??null,cwd:(Ju=f.session)==null?void 0:Ju.cwd,permissions:ot.config,onPermissionsApplied:ot.markApplied,model:nn,effort:Rt,fastMode:Un,ultracode:Br,mcpConfig:V&&i?sn.mcpConfigJson:null,onModelRejected:nu,readOnly:W,onCreateSession:f.pendingDirName?bb:void 0}),$t=dM(U.agentTeams?((Qu=f.sessionSource)==null?void 0:Qu.fileName)??null:null,((Zu=f.sessionSource)==null?void 0:Zu.dirName)??null);v.useEffect(()=>{$t!=null&&$t.currentMemberName?u({type:"SET_CURRENT_MEMBER_NAME",name:$t.currentMemberName}):$t||u({type:"SET_CURRENT_MEMBER_NAME",name:null})},[$t==null?void 0:$t.currentMemberName,$t,u]),v.useEffect(()=>{c&&u({type:"GUARD_MOBILE_TAB",hasSession:!!f.session||!!f.pendingDirName})},[f.session,f.pendingDirName,f.mobileTab,c,u]);const Sn=K2({session:f.session,isLive:ue,pendingMessages:pt.pendingMessages,consumePending:pt.consumePending,sessionChangeKey:f.sessionChangeKey,partialContentLen:Be}),mu=Sn.chatScrollRef,pu=Sn.resetTurnCount,hu=Sn.scrollToBottomInstant,Sb=v.useCallback(Ce=>{pe(Ce),requestAnimationFrame(()=>{const Ve=mu.current;Ve&&Ve.scrollTo({top:Ve.scrollTop+(Ce?64:-64),behavior:"smooth"})})},[mu]);v.useLayoutEffect(()=>{const Ce=Ve=>{pu(0),hu()};return Ur.current=Ce,()=>{Ur.current===Ce&&(Ur.current=null)}},[pu,hu,Ur]);const kb=v.useCallback(()=>{pt.disconnect(),cu()},[pt.disconnect,cu]),kn=bM({dispatch:u,isMobile:c,mobileTab:f.mobileTab,teamContext:$t,scrollToBottomInstant:Sn.scrollToBottomInstant,resetTurnCount:Sn.resetTurnCount,workerParse:p,onBeforeSwitch:kb}),Nb=v.useCallback(Ce=>{v.startTransition(()=>{u({type:"GO_HOME",isMobile:c}),u({type:"SET_DASHBOARD_PROJECT",dirName:Ce})})},[u,c]),{previewLoadError:Cb}=jM({state:f,dispatch:u,isMobile:c,resetTurnCount:Sn.resetTurnCount,scrollToBottomInstant:Sn.scrollToBottomInstant,workerParse:p}),Wr=PM(),gu=Wr.push;v.useEffect(()=>{f.sessionSource&&gu(f.sessionSource.dirName,f.sessionSource.fileName)},[f.sessionSource,gu]);const dt=y$({state:{session:f.session,sessionSource:f.sessionSource},dispatch:u,isMobile:c,handleJumpToTurn:kn.handleJumpToTurn,markPermissionsApplied:ot.markApplied,hasPermsPendingChanges:ot.hasPendingChanges,permissionsConfig:ot.config,selectedModel:nn,selectedEffort:Rt,fastMode:Un,ultracode:Br,mcpConfig:V&&i?sn.mcpConfigJson:null,scrollRequestScrollToTop:Sn.requestScrollToTop,handleDashboardSelect:kn.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:xu,handleApplySettings:bu}=dt,vu=V&&i&&sn.mcpConfigJson!==null,yu=v.useRef(!1);v.useEffect(()=>{var bt;const Ce=sn.loaded&&!yu.current;yu.current=sn.loaded;const Ve=(bt=f.session)==null?void 0:bt.sessionId;Ce&&Ve&&vu&&xu&&bu()},[sn.loaded,vu,xu,bu,(ef=f.session)==null?void 0:ef.sessionId]),v.useLayoutEffect(()=>(ne.current=dt.reloadSession,()=>{ne.current===dt.reloadSession&&(ne.current=null)}),[dt.reloadSession]);const Wn=rb(f.session,f.sessionSource,dt.reloadSession,a),Hr=Wn.requestBranchSwitch,Kr=dt.setBranchModalTurn,_b=v.useCallback((Ce,Ve)=>{Hr(Ce,Ve),Kr(null)},[Hr,Kr]),Tb=v.useCallback(Ce=>{Hr(Ce),Kr(null)},[Hr,Kr]);NM({isMobile:c,searchInputRef:N,chatInputRef:C,dispatch:u,onToggleSidebar:k.handleToggleSidebar,onToggleRightSidebar:$,onToggleMissionControl:k.handleToggleMission,onOpenCommandPalette:E,onOpenProjectSwitcher:k.handleOpenProjectSwitcher,onOpenThemeSelector:k.handleToggleThemeSelector,onOpenTerminal:te,onToggleIntegratedTerminal:de,onTogglePreview:he,onToggleProjectFiles:ge,onHistoryBack:Wr.goBack,onHistoryForward:Wr.goForward,onNavigateToSession:kn.handleDashboardSelect,onCommitNavigation:Wr.commitNavigation});const{killing:Eb,handleKillAll:Pb}=r$(),os=f.sessionSource?bs(f.sessionSource.fileName):null,Ab=os!==null&&!!($t!=null&&$t.currentMemberName),qa=os!==null&&!Ab,qr=kn.handleDashboardSelect,wu=v.useCallback(()=>{!f.sessionSource||!os||qr(f.sessionSource.dirName,os.parentFileName)},[f.sessionSource,os,qr]);v.useEffect(()=>{const Ce=Ve=>{const{agentId:bt}=Ve.detail??{};if(!bt||!f.sessionSource||!U.subagentTranscripts)return;const cn=os?os.parentSessionId:Xl(f.sessionSource.fileName);qr(f.sessionSource.dirName,`${cn}/subagents/agent-${bt}.jsonl`)};return window.addEventListener(Wi,Ce),()=>window.removeEventListener(Wi,Ce)},[f.sessionSource,os,qr,U.subagentTranscripts]);const[Rb,ju]=v.useState(null),Ib=dt.branchModalTurn!==null,qs=dt.branchModalTurn??Rb;v.useEffect(()=>{dt.branchModalTurn!==null&&ju(dt.branchModalTurn)},[dt.branchModalTurn]);const Su=qs!==null?Wn.branchesAtTurn(qs):[],Mb=qa?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(mo,{"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,$b=W?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(mo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Ew(z)})]}):null,Va=Mb||$b,Ob=kn.loadError||lu||null;let Ga;kn.loadError?Ga=kn.clearLoadError:lu&&(Ga=xb);const Db=!!(f.session&&f.sessionSource&&ke==="disconnected"),Ya=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]),Xa=v.useMemo(()=>({session:f.session,sessionSource:f.sessionSource,isLive:ue,sseState:ke,isCompacting:Ae,turnError:We,promptSuggestion:nt,undoRedo:Wn,pendingInteraction:Hs,permissionRequests:ct.requests,permissionResponding:ct.responding,respondPermission:ct.respond,respondAllPermissions:ct.respondAll,isSubAgentView:qa,slashSuggestions:Y.suggestions,slashSuggestionsLoading:Y.loading,actions:{handleStopSession:dt.handleStopSession,handleEditConfig:i?k.handleEditConfig:void 0,handleEditCommand:i?K:void 0,handleExpandCommand:i?X:void 0,handleOpenBranches:dt.handleOpenBranches,handleBranchFromHere:dt.handleBranchFromHere,handleToggleExpandAll:T,handleLoadSession:dt.handleLoadSessionScrollAware}}),[f.session,f.sessionSource,ue,ke,Ae,We,nt,Wn,Hs,qa,ct.requests,ct.responding,ct.respond,ct.respondAll,Y.suggestions,Y.loading,dt.handleStopSession,i,k.handleEditConfig,K,X,dt.handleOpenBranches,dt.handleBranchFromHere,T,dt.handleLoadSessionScrollAware]),Ja=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]),Po=!!f.pendingDirName&&!f.session;if(v.useEffect(()=>{if(!Po||c)return;const Ce=requestAnimationFrame(()=>{var Ve;return(Ve=C.current)==null?void 0:Ve.focus()});return()=>cancelAnimationFrame(Ce)},[Po,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(V$,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(K$,{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(In,{children:[r.jsxs(Mn,{children:[r.jsx(Xn,{variant:"icon",children:r.jsx(yn,{className:"text-destructive"})}),r.jsx($n,{children:"Failed to connect"}),r.jsx(On,{children:e.configError})]}),r.jsx(Xh,{children:r.jsxs(Z,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Wt,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(B4,{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 Qa=r.jsx(ew,{activeError:Ob,clearActiveError:Ga,modelFallbackNotice:hb,dismissModelFallbackNotice:gb,connectionLost:Db,theme:d.activeTheme}),ku=a?r.jsx(I4,{state:Wn.confirmState,isApplying:Wn.isApplying,applyError:Wn.applyError,onConfirm:Wn.confirmApply,onCancel:Wn.confirmCancel}):null,Lb=qs!==null&&f.session?f.session.turns.slice(qs):[],Nu=a&&qs!==null&&Su.length>0&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(X$,{open:Ib,branches:Su,branchPointTurnIndex:qs,currentTurns:Lb,onClose:dt.handleCloseBranchModal,onCloseComplete:()=>ju(null),onRedoToTurn:_b,onRedoEntireBranch:Tb})}),Cu=l&&r.jsx(j4,{processes:Q.processes,activeProcessId:Q.activeProcessId,collapsed:Q.collapsed,onSetActive:Q.setActive,onRemove:Q.removeProcess,onToggleCollapse:Q.toggleCollapse,onRequestTerminal:lt("terminal")?le:void 0,onAddTerminalContext:Ce=>{var tf,nf,sf;const Ve=Ce.trim();if(!Ve)return;const bt=Ve.includes("```")?"````":"```",cn=`${bt}terminal
|
|
143
|
+
${Ve}
|
|
144
|
+
${bt}`,Za=((tf=C.current)==null?void 0:tf.getText().trimEnd())??"";(nf=C.current)==null||nf.setText(Za?`${Za}
|
|
145
|
+
|
|
146
|
+
${cn}
|
|
147
|
+
`:`${cn}
|
|
148
|
+
`),(sf=C.current)==null||sf.focus()},onUpdateStatus:Q.updateProcessStatus,projectDir:J,onProcessStarted:Q.addProcess,mobile:c}),_u=$t&&r.jsx(bj,{teamName:$t.config.name||$t.teamName,members:$t.config.members,currentMemberName:f.currentMemberName,loadingMember:f.loadingMember,onMemberClick:kn.handleTeamMemberSwitch}),Tu=ze&&r.jsx(v.Suspense,{fallback:null,children:r.jsx(J$,{open:k.showWorkflows,onOpenChange:k.setShowWorkflows,dirName:Ie.dirName,sessionId:Ie.sessionId,workflows:Le.workflows,isLive:Le.isLive,onRefetchList:Le.refetch},`${Ie.dirName??""}:${Ie.sessionId??""}`)}),Vr=U.goals?f.session:null,Eu=Ce=>{var Ve;return r.jsx(pj,{agentKind:z,onAgentKindChange:Po?wb:void 0,selectedModel:nn,onModelChange:jn,selectedEffort:Rt,onEffortChange:qe,fastModeEnabled:Un,onFastModeEnabledChange:Bn?Ha:void 0,isNewSession:Po,worktreeEnabled:vb,onWorktreeEnabledChange:Po&&q?yb:void 0,ultracodeEnabled:Br,onUltracodeEnabledChange:pb?Ka:void 0,onApplySettings:dt.handleApplySettings,activeModelId:(Ve=f.session)==null?void 0:Ve.model,mcpServers:V&&i?sn.servers:void 0,selectedMcpServers:V&&i?sn.selectedServers:void 0,onToggleMcpServer:V&&i?sn.toggleServer:void 0,onRefreshMcpServers:V&&i?sn.refresh:void 0,mcpLoading:V&&i?sn.loading:void 0,onMcpAuth:V&&i?me:void 0,permissionMode:ot.config.mode,onPermissionModeChange:ot.setMode,mobileExtra:c&&Ce&&Vr?r.jsx(JS,{}):void 0,trailingExtra:!c&&Ce&&Vr?r.jsx(Lg,{}):void 0,mobile:c})},Pu=Eu(!0),Au=Eu(!1),Ru=r.jsxs("div",{className:"shrink-0 bg-background",children:[!c&&r.jsx(Dg,{}),r.jsx(oc,{ref:C,allowImages:tu,agentKind:z,projectCwd:J,compact:c,leadingAccessory:c?Pu:void 0}),!c&&Pu]}),Gr=Vr?r.jsx(XS,{agentKind:z,session:Vr,onSendCommand:pt.sendMessage,children:Ru}):Ru,zb=r.jsxs("div",{className:"shrink-0 bg-background",children:[r.jsx(oc,{ref:C,allowImages:tu,agentKind:z,projectCwd:J,compact:c,leadingAccessory:c?Au:void 0}),!c&&Au]}),Iu=pt.pendingMessages.map((Ce,Ve)=>r.jsx(Sx,{message:Ce,turnNumber:Ve+1},Ve)),Fb=c?f.mobileTab==="stats":k.activeWorkspacePanel===Xt.sessionInfo,Mu=f.session&&!Fb&&r.jsx("div",{className:"hidden",children:r.jsx(Vg,{cwd:f.session.cwd,turns:f.session.turns,onServersChanged:Q.handleServersChanged})});return n?r.jsxs(ji,{value:Ya,children:[r.jsx(il,{children:r.jsx(yi,{value:Xa,chatValue:Ja,children:r.jsx(bl,{value:$e,agentProgress:Xe,children:r.jsx(rM,{sessionId:n,loadError:Cb,searchInputRef:N,activeComposer:Va||zb,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore})})})}),Qa]}):c?r.jsxs(ji,{value:Ya,children:[r.jsx(il,{enabled:l,children:r.jsx(yi,{value:Xa,chatValue:Ja,children:r.jsx(bl,{value:$e,agentProgress:Xe,children:r.jsx(oM,{navigation:{actions:kn,handlers:dt,creatingSession:au,pendingSession:uu,onStartNewSession:fu,onSelectProject:L,liveSessionsRefreshRef:du,onPrefetchSession:x},sessionView:{searchInputRef:N,teamMembersBar:_u,activeComposer:Va||Gr,pendingComposer:Gr,pendingTurns:Iu,todoProgress:ve&&r.jsx(kx,{progress:ve}),hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:wu,onShowWorkflows:He,onToggleExpandAll:T,workflowCount:Ue,pendingPath:F},project:{processPanel:Q,backgroundAgents:Ge,hasFileChanges:a&&Re,onOpenTerminal:te},chrome:{backgroundServers:Mu,processPanel:Cu,workflowsPanel:Tu,undoDialog:ku,branchModal:Nu,fileChangesOpen:Oe,onFileChangesOpenChange:Ne,searchOpen:fe,onSearchOpenChange:Pe}})})})}),Qa]}):r.jsxs(ji,{value:Ya,children:[r.jsx(il,{enabled:l,children:r.jsx(yi,{value:Xa,chatValue:Ja,children:r.jsx(bl,{value:$e,agentProgress:Xe,children:r.jsx(YI,{navigation:{panels:k,actions:kn,handlers:dt,creatingSession:au,pendingSession:uu,onStartNewSession:fu,onStartNewFolder:jb,onSelectProject:L,onOpenPaletteProject:Nb,liveSessionsRefreshRef:du,onPrefetchSession:x},sessionView:{searchInputRef:N,chatInputRef:C,teamMembersBar:_u,activeComposer:Va||Gr,pendingComposer:Gr,pendingTurns:Iu,todoProgress:ve,todosExpanded:xe,onTodosExpandedChange:Sb,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:wu,onShowWorkflows:He,workflowCount:Ue},project:{processPanel:Q,worktrees:_e,backgroundAgents:Ge,supportsWorktrees:q,hasFileChanges:a&&Re,currentCwd:J,showPreview:ee,showProjectFiles:a&&oe,projectFilesRoot:se,projectFilesRequest:re,launchTerminalRequest:ie,pendingProject:ae,onOpenTerminal:te,onTogglePreview:he,onToggleProjectFiles:ge,onCloseRightWorkspace:ce},chrome:{backgroundServers:Mu,processPanel:Cu,workflowsPanel:Tu,undoDialog:ku,branchModal:Nu,killing:Eb,onKillAll:Pb,commandPaletteOpen:S,onCommandPaletteOpenChange:_,onOpenCommandPalette:E,onFocusComposer:R,onExpandAll:M,onExpandToolPayloads:I,onCollapseAll:D,keyboardShortcutsOpen:P,onKeyboardShortcutsOpenChange:A}})})})}),Qa]})}function Z$(){var w;const[n,e]=v.useState(ht),[t,s]=v.useState(()=>vi(ht())),[o,i]=v.useState(hs),[a,l]=v.useState(0),[c,d]=v.useState(!1),[f,u]=v.useState(!1),[m,p]=v.useState(!1),{devices:h,testDevice:g}=za();v.useEffect(()=>{const y=()=>{const j=ht();e(k=>k===j?k:j),s(vi(j))};return window.addEventListener("cogpit-device-changed",y),window.addEventListener("popstate",y),()=>{window.removeEventListener("cogpit-device-changed",y),window.removeEventListener("popstate",y)}},[]),v.useEffect(()=>{const y=j=>{const k=j.detail;(k==null?void 0:k.deviceId)===ht()&&s(vi(k.deviceId))};return window.addEventListener("cogpit-device-scope-changed",y),()=>window.removeEventListener("cogpit-device-scope-changed",y)},[]),v.useEffect(()=>{const y=()=>i(hs());return window.addEventListener("cogpit-identity-changed",y),()=>window.removeEventListener("cogpit-identity-changed",y)},[]),v.useEffect(()=>(window.__cogpitRevealSession=J0,()=>{delete window.__cogpitRevealSession}),[]),v.useEffect(()=>{const y=j=>{const k=[jt,...h.map(_=>_.id)],N=ht();let C;const S=FE(j);if(S!==null)C=k[S-1];else if(BE(j)){const _=k.indexOf(N);C=k[(_+1)%k.length]}!C||C===N||(j.preventDefault(),gs(C))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]),v.useEffect(()=>{const y=j=>{const k=j.detail;!(k!=null&&k.deviceId)||k.deviceId!==ht()||(d(!0),k.reason==="DEVICE_AUTH_FAILED"&&u(!0))};return window.addEventListener("cogpit-device-unreachable",y),()=>window.removeEventListener("cogpit-device-unreachable",y)},[]),v.useEffect(()=>{d(!1),u(!1),p(!1)},[n,t]);const x=v.useCallback(async()=>{p(!0);try{const y=await g(n);y.reachable&&y.authState==="bad-password"?u(!0):y.ok&&(d(!1),u(!1),l(j=>j+1))}finally{p(!1)}},[n,g]);v.useEffect(()=>{if(!c||f)return;const y=setInterval(()=>void x(),1e4);return()=>clearInterval(y)},[c,f,x]);const b=((w=h.find(y=>y.id===n))==null?void 0:w.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==jt&&r.jsxs(St,{role:"status",className:"fixed inset-x-3 top-3 z-40 mx-auto max-w-2xl border-warning/40 bg-popover shadow-md",children:[r.jsx(qy,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(It,{children:f?"Device credentials need attention":"Remote device unavailable"}),r.jsx(kt,{children:f?`${b} rejected the stored password. Update it in Devices.`:`Can’t reach ${b}. Cogpit will keep retrying.`}),r.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[!f&&r.jsxs(Z,{variant:"outline",size:"xs",onClick:()=>void x(),disabled:m,children:[m&&r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),r.jsx(Z,{variant:"outline",size:"xs",onClick:()=>gs(jt),children:"Switch to this machine"})]})]}),r.jsx(D_,{children:r.jsx(lI,{children:r.jsx(Q$,{})})},`${n}:${t}:${a}:${o??""}`)]})}const ch="Invalid link or passphrase.";function eO(n,e){return n===401?ch:n===429?e||"Too many attempts. Try again in a minute.":n===426?"This link needs a secure HTTPS connection. Open the tunnel URL instead of the plain http address.":n===403?"Network access is off on the host, so this session cannot be joined right now.":e||ch}function tO({sessionId:n,onAuthenticated:e}){const[t,s]=v.useState(""),[o,i]=v.useState(!1),[a,l]=v.useState(null),[c,d]=v.useState(!1),f=v.useCallback(async u=>{if(u.preventDefault(),!!t.trim()){d(!0),l(null);try{const m=await fetch("/api/share/verify",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({sessionId:n,passphrase:t})}),p=await m.json();m.ok&&p.valid?(s(""),e()):l(eO(m.status,p.error))}catch{l("Failed to connect to server")}finally{d(!1)}}},[e,t,n]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:f,className:"w-full max-w-sm",children:r.jsxs(Dt,{children:[r.jsxs(Bt,{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(Yn,{className:"size-4"})}),r.jsx(Vt,{children:"Join this session"}),r.jsx(Gt,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(Lt,{className:"flex flex-col gap-4",children:[r.jsx(Co,{children:r.jsxs(gt,{children:[r.jsx(xt,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(ns,{children:[r.jsx(ss,{id:"share-passphrase",type:o?"text":"password",value:t,onChange:u=>s(u.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),r.jsx(vn,{align:"inline-end",children:r.jsx(Rr,{size:"icon-xs",onClick:()=>i(u=>!u),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(oa,{}):r.jsx(So,{})})})]})]})}),a&&r.jsxs(St,{variant:"destructive",children:[r.jsx(en,{"aria-hidden":"true"}),r.jsx(It,{children:"Could not join"}),r.jsx(kt,{children:a})]})]}),r.jsx(Eo,{children:r.jsxs(Z,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(At,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function nO(){const n=B.c(9),[e,t]=v.useState("idle"),[s,o]=v.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=v.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>{l(w=>[...w,x]),t("connected"),o(void 0),TS(x,b).then(w=>{if(w.ok){t("idle");return}o(`Request failed (${w.status})`),t("error"),l(rO)}).catch(w=>{o(w instanceof Error?w.message:"Unknown error"),t("error"),l(oO)})},n[1]=c):c=n[1];const d=c;let f;n[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{ES().catch(sO),t("idle"),l([])},n[2]=f):f=n[2];const u=f;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const b=x===void 0?1:x;l(w=>w.slice(b))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==a||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:a,isConnected:h,sendMessage:d,interrupt:u,stopAgent:u,consumePending:p},n[4]=s,n[5]=a,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function sO(){}function oO(n){return n.slice(0,-1)}function rO(n){return n.slice(0,-1)}const iO=2e3;function aO(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function lO(){const n=B.c(11);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=new Set,n[1]=o):o=n[1];const[i,a]=v.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const w=await IS();h||w===null||s(y=>aO(y,w)?y:w)},x=()=>{document.visibilityState==="visible"&&g()};x();const b=setInterval(x,iO);return document.addEventListener("visibilitychange",x),()=>{h=!0,clearInterval(b),document.removeEventListener("visibilitychange",x)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),v.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),AS(h,g).then(x=>{x&&s(b=>b.filter(w=>w.requestId!==h))}).finally(()=>{a(x=>{const b=new Set(x);return b.delete(h),b})})},n[4]=d):d=n[4];const f=d;let u;n[5]!==t?(u=h=>{for(const g of t)f(g.requestId,h)},n[5]=t,n[6]=u):u=n[6];const m=u;let p;return n[7]!==t||n[8]!==m||n[9]!==i?(p={requests:t,responding:i,respond:f,respondAll:m},n[7]=t,n[8]=m,n[9]=i,n[10]=p):p=n[10],p}const fb={authenticated:!0,edition:"personal",user:null,capabilities:Er};function cO(n){var le,he;const e=B.c(78),{info:t,children:s}=n,o=Ma(),i=X2(),[a,l]=H2(),{parse:c,append:d}=lb(),[f,u]=v.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],v.useEffect(pO,m);const p=nO(),h=lO();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:ge,source:ce}=await V2(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:ge,source:ce,isMobile:o}),u("ready")}catch{u("failed")}},e[1]=l,e[2]=t.dirName,e[3]=t.fileName,e[4]=o,e[5]=c,e[6]=g):g=e[6];const x=g,b=v.useRef(!1);let w,y;e[7]!==x?(w=()=>{b.current||(b.current=!0,x())},y=[x],e[7]=x,e[8]=w,e[9]=y):(w=e[8],y=e[9]),v.useEffect(w,y);let j;e[10]!==l?(j=ge=>{l({type:"UPDATE_SESSION",session:ge})},e[10]=l,e[11]=j):j=e[11];const k=j,{isLive:N,sseState:C,isCompacting:S,turnError:_}=B2(a.sessionSource,k,c,d,void 0,a.session);let P;e[12]!==l?(P=ge=>{l({type:"SET_OLDER_TURNS",turns:ge})},e[12]=l,e[13]=P):P=e[13];const A=P,T=((le=a.sessionSource)==null?void 0:le.dirName)??null,E=((he=a.sessionSource)==null?void 0:he.fileName)??null;let R;e[14]!==A||e[15]!==a.sessionChangeKey||e[16]!==T||e[17]!==E||e[18]!==c?(R={dirName:T,fileName:E,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:A},e[14]=A,e[15]=a.sessionChangeKey,e[16]=T,e[17]=E,e[18]=c,e[19]=R):R=e[19];const M=cb(R);let I;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==N||e[23]!==a.session||e[24]!==a.sessionChangeKey?(I={session:a.session,isLive:N,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=N,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=I):I=e[25];const D=K2(I),O=rb(a.session,a.sessionSource,x,!1);let $;e[26]!==a.session?($=a.session?dx(a.session):null,e[26]=a.session,e[27]=$):$=e[27];const L=$;let F;e[28]!==l?(F=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=F):F=e[29];const z=F,H=fO,U=uO;let W;e[30]!==t.dirName?(W=Ct(t.dirName),e[30]=t.dirName,e[31]=W):W=e[31];let q;e[32]!==W?(q={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:W,setClaudeDir:U,showConfigDialog:!1,openConfigDialog:U,handleCloseConfigDialog:U,handleConfigSaved:U,retryConfig:U,networkUrl:null,networkAccessDisabled:!1},e[32]=W,e[33]=q):q=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V={isRemote:fa(),edition:"personal",authChecked:!0,authenticated:!0,needsBootstrap:!1,handleAuthenticated:U,refreshServerState:dO,logout:U},e[34]=V):V=e[34];let Y;e[35]!==l||e[36]!==o||e[37]!==a||e[38]!==q||e[39]!==i?(Y={state:a,dispatch:l,config:q,theme:i,networkAuth:V,me:fb,isMobile:o},e[35]=l,e[36]=o,e[37]=a,e[38]=q,e[39]=i,e[40]=Y):Y=e[40];const K=Y;let X;e[41]===Symbol.for("react.memo_cache_sentinel")?(X=[],e[41]=X):X=e[41];let Q;e[42]!==z?(Q={handleStopSession:H,handleOpenBranches:U,handleBranchFromHere:U,handleToggleExpandAll:z,handleLoadSession:U},e[42]=z,e[43]=Q):Q=e[43];let J;e[44]!==S||e[45]!==N||e[46]!==L||e[47]!==h.requests||e[48]!==h.respond||e[49]!==h.respondAll||e[50]!==h.responding||e[51]!==C||e[52]!==a.session||e[53]!==a.sessionSource||e[54]!==Q||e[55]!==_||e[56]!==O?(J={session:a.session,sessionSource:a.sessionSource,isLive:N,sseState:C,isCompacting:S,turnError:_,undoRedo:O,pendingInteraction:L,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:X,slashSuggestionsLoading:!1,promptSuggestion:null,actions:Q},e[44]=S,e[45]=N,e[46]=L,e[47]=h.requests,e[48]=h.respond,e[49]=h.respondAll,e[50]=h.responding,e[51]=C,e[52]=a.session,e[53]=a.sessionSource,e[54]=Q,e[55]=_,e[56]=O,e[57]=J):J=e[57];const ee=J;let oe;e[58]!==p||e[59]!==D?(oe={chat:p,scroll:D},e[58]=p,e[59]=D,e[60]=oe):oe=e[60];const se=oe;let re;e[61]!==M?(re=()=>{M.loadMore()},e[61]=M,e[62]=re):re=e[62];let ie;e[63]!==f||e[64]!==M.hasMore||e[65]!==M.isLoadingOlder||e[66]!==re?(ie={loadState:f,hasMore:M.hasMore,isLoadingOlder:M.isLoadingOlder,loadMore:re},e[63]=f,e[64]=M.hasMore,e[65]=M.isLoadingOlder,e[66]=re,e[67]=ie):ie=e[67];const ae=ie;let te;e[68]!==s||e[69]!==ae?(te=s(ae),e[68]=s,e[69]=ae,e[70]=te):te=e[70];let me;e[71]!==se||e[72]!==ee||e[73]!==te?(me=r.jsx(yi,{value:ee,chatValue:se,children:te}),e[71]=se,e[72]=ee,e[73]=te,e[74]=me):me=e[74];let de;return e[75]!==K||e[76]!==me?(de=r.jsx(ji,{value:K,children:me}),e[75]=K,e[76]=me,e[77]=de):de=e[77],de}function dO(){return Promise.resolve()}function uO(){}async function fO(){await PS().catch(mO)}function mO(){}function pO(){ao(fb)}function hO(n){const e=B.c(6),{info:t}=n,s=v.useRef(null);let o;e[0]!==t.provider||e[1]!==t.title?(o=a=>r.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-background",children:[r.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[r.jsx(Yn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:t.title}),r.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:"Guest view"})]}),a.loadState==="failed"?r.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:r.jsxs(St,{variant:"destructive",className:"max-w-sm",children:[r.jsx(en,{"aria-hidden":"true"}),r.jsx(It,{children:"Session unavailable"}),r.jsx(kt,{children:"This conversation could not be loaded. It may have been deleted on the host."})]})}):a.loadState==="loading"?r.jsx("div",{className:"flex flex-1 items-center justify-center",role:"status","aria-label":"Loading shared session",children:r.jsx(At,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(La,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(Ua,{children:r.jsx(oc,{agentKind:t.provider,projectCwd:null})})]})]}),e[0]=t.provider,e[1]=t.title,e[2]=o):o=e[2];let i;return e[3]!==t||e[4]!==o?(i=r.jsx(cO,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function Kl(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function gO(){const n=B.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ig(window.location.pathname),n[0]=e):e=n[0];const t=e;let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=t?{kind:"probing"}:{kind:"error",message:"This share link is not valid."},n[1]=s):s=n[1];const[o,i]=v.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await _S();i(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=a):a=n[2];const l=a;let c,d;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},d=[l,t],n[3]=c,n[4]=d):(c=n[3],d=n[4]),v.useEffect(c,d);let f,u;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{i(xO)};return window.addEventListener(sc,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(sc,p),window.removeEventListener("cogpit-auth-required",p)}},u=[],n[5]=f,n[6]=u):(f=n[5],u=n[6]),v.useEffect(f,u),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(hO,{info:o.info}),n[7]=o.info,n[8]=p):p=n[8],p}if(o.kind==="login"&&t){let p;return n[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(tO,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(o.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Kl,{children:r.jsx(Dt,{children:r.jsxs(Bt,{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(Vy,{className:"size-4"})}),r.jsx(Vt,{children:"Sharing has ended"}),r.jsx(Gt,{children:"The host stopped sharing this session or changed its passphrase. Ask for a new link to rejoin."})]})})}),n[10]=p):p=n[10],p}if(o.kind==="error"){let p,h;n[11]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(en,{"aria-hidden":"true"}),h=r.jsx(It,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==o.message?(g=r.jsxs(St,{variant:"destructive",children:[p,h,r.jsx(kt,{children:o.message})]}),n[13]=o.message,n[14]=g):g=n[14];let x;n[15]===Symbol.for("react.memo_cache_sentinel")?(x=t&&r.jsx(Z,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=x):x=n[15];let b;return n[16]!==g?(b=r.jsxs(Kl,{children:[g,x]}),n[16]=g,n[17]=b):b=n[17],b}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Kl,{children:r.jsx(Dt,{children:r.jsxs(Lt,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(Yn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(At,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function xO(n){return n.kind==="ready"?{kind:"ended"}:n}class bO extends v.Component{constructor(){super(...arguments);Yr(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,s){console.error("[Cogpit] Unhandled render error",t,s.componentStack)}render(){if(!this.state.error)return this.props.children;const t=this.state.error.message||"An unexpected render error occurred.";return r.jsx("main",{className:"flex h-dvh items-center justify-center bg-background p-6 text-foreground",children:r.jsxs(Dt,{className:"w-full max-w-lg text-center",children:[r.jsxs(Bt,{className:"justify-items-center",children:[r.jsx(yn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(Vt,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(Gt,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(Lt,{children:r.jsx("pre",{className:"max-h-40 w-full overflow-auto rounded-md bg-muted p-3 text-left font-mono text-xs whitespace-pre-wrap",children:t})}),r.jsx(Eo,{className:"justify-center",children:r.jsxs(Z,{onClick:()=>window.location.reload(),children:[r.jsx(Wt,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const mb=document.getElementById("root");if(!mb)throw new Error("Root element not found");Kb.createRoot(mb).render(r.jsx(v.StrictMode,{children:r.jsx(bO,{children:ya(window.location.pathname)?r.jsx(gO,{}):r.jsx(Z$,{})})}));export{ed as $,St as A,Z as B,TO as C,Jn as D,In as E,w8 as F,$n as G,On as H,vn as I,Eg as J,Da as K,kO as L,pa as M,_g as N,Tg as O,Cg as P,vt as Q,l3 as R,aj as S,bn as T,G as U,Ee as V,Cr as W,yt as X,Jt as Y,wt as Z,Zc as _,lj as a,D4 as a$,td as a0,P4 as a1,sd as a2,od as a3,nd as a4,id as a5,rd as a6,Ts as a7,za as a8,Co as a9,n1 as aA,Sr as aB,zO as aC,$a as aD,Bt as aE,Vt as aF,Lt as aG,Eo as aH,Dt as aI,Ea as aJ,hx as aK,Us as aL,Fn as aM,yo as aN,En as aO,It as aP,Gt as aQ,ad as aR,Ar as aS,uM as aT,ba as aU,xt as aV,xo as aW,Z9 as aX,tn as aY,CO as aZ,zt as a_,gt as aa,Rr as ab,fs as ac,g0 as ad,x0 as ae,Ft as af,kS as ag,pr as ah,At as ai,a8 as aj,xc as ak,Dd as al,wa as am,Ng as an,Ir as ao,a1 as ap,ud as aq,Tl as ar,LE as as,qj as at,_O as au,Qc as av,Os as aw,lt as ax,dd as ay,t1 as az,cj as b,da as b0,Gg as b1,NO as b2,_t as b3,Tt as b4,Et as b5,Aa as b6,Ra as b7,Ia as b8,fo as b9,AO as ba,Zt as bb,mr as bc,_4 as bd,on as be,Bw as bf,PO as bg,Pd as bh,zx as bi,Rd as bj,Dx as bk,Nr as bl,qx as bm,cI as bn,b2 as bo,Dr as bp,ys as bq,S_ as br,ij as c,tj as d,RO as e,DE as f,IO as g,Qn as h,Ns as i,Zn as j,es as k,Mt as l,ns as m,ss as n,OO as o,kt as p,To as q,$O as r,DO as s,LO as t,MO as u,E2 as v,ye as w,EO as x,Mn as y,Xn as z};
|