cogpit 2.1.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cli.js +1603 -773
  2. package/dist/web/assets/CommandPaletteHost-D-VvT_HL.js +1 -0
  3. package/dist/web/assets/ConfigBrowser-Cc2lrh85.js +1 -0
  4. package/dist/web/assets/{HighlightedEditor-qhEWgnBF.js → HighlightedEditor-DWNz1Jcz.js} +2 -2
  5. package/dist/web/assets/{KeyboardShortcutsDialog-B9nMtf5U.js → KeyboardShortcutsDialog-yOs1u5D6.js} +1 -1
  6. package/dist/web/assets/{MobileFileChanges-j9DCxvz6.js → MobileFileChanges-B1dtcdSZ.js} +1 -1
  7. package/dist/web/assets/PreviewPanel-BJwfunf9.js +1 -0
  8. package/dist/web/assets/ProjectFilesPanel-DppuIFEt.js +4 -0
  9. package/dist/web/assets/{ProjectSwitcherModal-o8NhzySH.js → ProjectSwitcherModal-DgsuH5CY.js} +1 -1
  10. package/dist/web/assets/{TerminalOutput-CcWkSv29.js → TerminalOutput-DlGDS0Wx.js} +1 -1
  11. package/dist/web/assets/ThemeSelectorModal-oI9Vm3EH.js +1 -0
  12. package/dist/web/assets/WorkflowsPanel-SKbsv_IK.js +1 -0
  13. package/dist/web/assets/WorktreePanel-CcSLupr7.js +1 -0
  14. package/dist/web/assets/{index-_0HhakEy.js → index-7FuVzOBC.js} +4 -4
  15. package/dist/web/assets/index-BVkjlOVU.js +1 -0
  16. package/dist/web/assets/index-Bw-DFQut.js +1 -0
  17. package/dist/web/assets/index-Du17HzQD.js +151 -0
  18. package/dist/web/assets/index-xdv0cIL2.css +1 -0
  19. package/dist/web/assets/{session-parser.worker-DycJL0jJ.js → session-parser.worker-RMitC4X_.js} +17 -17
  20. package/dist/web/assets/{vendor-ui-Bg9q4lA4.js → vendor-ui-CdA11Wfh.js} +162 -147
  21. package/dist/web/index.html +3 -3
  22. package/package.json +1 -1
  23. package/dist/web/assets/CommandPaletteHost-1UPdv9Nv.js +0 -1
  24. package/dist/web/assets/ConfigBrowser-B5lZsJDw.js +0 -1
  25. package/dist/web/assets/PreviewPanel-DZSVN3mt.js +0 -1
  26. package/dist/web/assets/ProjectFilesPanel-DSvO4CrB.js +0 -4
  27. package/dist/web/assets/ThemeSelectorModal-CnbSCgJj.js +0 -1
  28. package/dist/web/assets/WorkflowsPanel-CvBweQMf.js +0 -1
  29. package/dist/web/assets/WorktreePanel-DahbK2L0.js +0 -1
  30. package/dist/web/assets/index-7UiltNKa.js +0 -1
  31. package/dist/web/assets/index-BESnPMZk.js +0 -144
  32. package/dist/web/assets/index-Bif4Kdtn.css +0 -1
  33. package/dist/web/assets/index-DXTQExVH.js +0 -1
@@ -0,0 +1,151 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-DlGDS0Wx.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-CdA11Wfh.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-D-VvT_HL.js","assets/index-Bw-DFQut.js","assets/KeyboardShortcutsDialog-yOs1u5D6.js","assets/ProjectSwitcherModal-DgsuH5CY.js","assets/ThemeSelectorModal-oI9Vm3EH.js","assets/ProjectFilesPanel-DppuIFEt.js","assets/HighlightedEditor-DWNz1Jcz.js","assets/WorktreePanel-CcSLupr7.js","assets/index-BVkjlOVU.js","assets/ConfigBrowser-Cc2lrh85.js","assets/PreviewPanel-BJwfunf9.js","assets/MobileFileChanges-B1dtcdSZ.js","assets/index-7FuVzOBC.js","assets/WorkflowsPanel-SKbsv_IK.js"])))=>i.map(i=>d[i]);
2
+ var rv=Object.defineProperty;var iv=(n,e,t)=>e in n?rv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var si=(n,e,t)=>iv(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as ve,e as av,r as y,a as lv,f as cv}from"./vendor-react-gGw_S5I_.js";import{au as dv,av as uv,aw as fv,ax as Gn,ad as rt,ay as mv,i as kn,az as pv,ar as Yn,aA as _h,aB as hv,aC as gv,aD as xv,aE as Th,aF as Eh,aG as zc,aH as Ah,aI as Ph,aJ as bv,O as mt,aK as Ih,aL as vv,aM as yv,aN as wv,aO as jv,J as Sr,a1 as go,$ as nt,b as Dt,ai as Sv,aP as Rh,aQ as $i,G as Us,aR as Nv,aS as kv,aT as Cv,aU as _v,aV as Tv,aW as Ev,aX as Av,aY as Pv,aZ as Iv,a_ as Rv,a$ as $v,b0 as Mv,b1 as Ov,b2 as Dv,b3 as Nr,b4 as Fc,b5 as Bc,b6 as Uc,b7 as $h,b8 as Wc,b9 as oa,X as ct,ba as Hc,bb as Lv,N as Kc,bc as Xn,bd as zv,be as Mh,bf as Oh,bg as mo,bh as ws,bi as Fv,bj as Bv,bk as Uv,bl as Wv,bm as or,S as dn,B as xo,m as Dh,bn as Ws,bo as Lh,bp as Hv,bq as Kv,br as qv,ae as ra,bs as Vv,W as ia,ak as Zl,a8 as Co,bt as ec,bu as Gv,bv as Yv,bw as Xv,bx as Jv,by as Qv,bz as Zv,bA as ey,bB as qc,bC as ty,bD as sn,D as Cn,bE as ny,bF as sy,bG as oy,bH as ry,bI as rr,bJ as kr,bK as iy,o as aa,bL as ay,bM as ly,bN as cy,bO as dy,bP as uy,bQ as fy,bR as my,bS as py,bT as hy,bU as gy,C as Je,P as $n,A as Hs,d as zh,bV as xy,bW as by,bX as vy,bY as yy,F as bo,af as Ks,bZ as wy,b_ as Fh,U as Vc,f as la,a7 as ca,b$ as jy,c0 as Gc,c1 as tc,c2 as Sy,c3 as Ny,c4 as ky,Q as Yc,R as Xc,c5 as Cy,c6 as _y,Y as Os,c as Bh,c7 as Ty,v as da,c8 as Cr,_ as Ci,c9 as Ey,ca as Ay,cb as Uh,cc as Py,cd as Iy,ce as oi,cf as Cs,ag as vf,l as _r,cg as Ry,a2 as $y,ch as My,as as Oy,w as ua,ci as Dy,cj as Ly,ck as zy,cl as Fy,cm as By,cn as Uy,co as Wh,cp as Wy,cq as Hy,ap as Ky,r as yf,cr as qy,cs as wf,p as fa,ct as Vy,cu as Hh,n as Kh,I as qh,cv as Gy,a3 as ma,u as Yy,cw as Xy,cx as Vh,s as Gh,at as Yh,y as Jy,cy as Qy,cz as Zy,cA as e3,cB as t3,cC as _o,cD as n3,cE as s3,cF as Xh,h as o3,cG as r3,cH as i3,cI as jf,ab as a3,L as l3,z as c3,an as d3,cJ as u3,aa as f3,cK as m3}from"./vendor-ui-CdA11Wfh.js";import{c as p3,a as h3}from"./vendor-shiki-DOn6sF-i.js";import{r as pa,M as On}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 g3="modulepreload",x3=function(n){return"/"+n},Sf={},qe=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=x3(d),d in Sf)return;Sf[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":g3,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"],nc="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function b3(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 v3(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 Jh(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>b3(n,e),decode:e=>v3(n,e)}}function Qh(n){const e=new RegExp(`(${nc})\\.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 eg(n){return`'${n.replace(/'/g,"'\\''")}'`}function ir(n,e){return e?[n,e]:[]}function Mi(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const Oi="[0-9a-f-]{36}",tg="codex__",ng="copilot__",y3=new Set(["default","plan","acceptEdits","dontAsk","auto"]),sg={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(tg)&&!n.startsWith(ng),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:Qh,...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"]:[...y3.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>ir("--model",n),effort:n=>ir("--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=>Mi(n,new RegExp(`--resume(?:=|\\s+)(${Oi})`))??Mi(n,new RegExp(`--session-id(?:=|\\s+)(${Oi})`))}},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}},Nf={appServerValue:"priority",cliConfigValue:"fast"},w3={kind:"codex",displayName:"Codex",binName:"codex",dirName:Jh(tg),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:Qh,...Zh},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${eg(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=>ir("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(Nf.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:Nf,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=>Mi(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${Oi})`))}},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}},j3={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:Jh(ng),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${nc})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${nc})/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 ${eg(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=>ir("--model",n),effort:n=>ir("--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=>Mi(n,new RegExp(`--resume(?:=|\\s+)(${Oi})`))}},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}},ar=Object.freeze({claude:sg,codex:w3,copilot:j3});function on(n){return ar[n]}function ha(){return ps.map(n=>ar[n])}function S3(n,e){const t=ha().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function js(n){for(const e of ps)if(e!=="claude"&&ar[e].dirName.owns(n))return ar[e];return sg}function Ct(n){return js(n).kind}function il(n,e,t){const s=ar[n].dirName;return t&&s.lossy?t:s.encode(e)}const qs=js(null).kind;var kh;const ri=((kh=ha().find(n=>n.dirName.lossy))==null?void 0:kh.kind)??null;function vo(n){return js(n).capabilities}function Ht(n){return on(n).capabilities}function N3(n,e){return ps.find(t=>t===n)??e}function sc(n){for(const e of ha()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function k3(n,e){return js(n).sessionFile.urlId(e)}function C3(n,e){return js(n).sessionFile.fileNameFromUrlId(e)}function og(n,e,t){return on(n).resume.command(e,t)}function _3(n,e){const t=on(n);return{command:t.binName,args:[...t.resume.args(e)]}}function kf(n){return n.replace(/\/+$/,"")||"/"}function T3(n,e,t){var o;const s=kf(e);return((o=n.find(i=>js(i.dirName).kind===t&&kf(i.path)===s))==null?void 0:o.dirName)??null}const E3=[{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"}],Jc=[{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"}],rg=[...Jc,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],ii=Jc.slice(0,4);var Ch;const Bo=[{value:((Ch=on("codex").serviceTier)==null?void 0:Ch.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],Cf={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:rg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Bo},A3=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...Cf},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...Cf},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:rg,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Bo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:Jc,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Bo},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:ii,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Bo},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:ii,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Bo},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:ii,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:ii,inputModalities:["text"],supportsPersonality:!0}],P3=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],I3={claude:E3,codex:A3,copilot:P3};function R3(n){return I3[n]}function V(...n){return dv(uv(n))}const ig=new Map,oc=new Set;function $3(n,e){!Array.isArray(e)||e.length===0||(ig.set(n,e),oc.forEach(t=>t()))}function M3(n){return oc.add(n),()=>oc.delete(n)}const al="high",O3=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function ag(n){return ig.get(n)??R3(n)}function Tr(n,e){const t=ag(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 lg(n,e){const t=Tr(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?[]:O3}function D3(n,e){var t;return((t=Tr(n,e))==null?void 0:t.serviceTiers)??[]}function cg(n,e){return D3(n,e).find(t=>t.value==="fast"||t.value==="priority"||t.label.toLowerCase()==="fast")}function L3(n,e){var s;const t=(s=Tr(n,e))==null?void 0:s.inputModalities;return t?t.includes("image"):Ht(n).imageInput}function z3(n,e){var s;const t=Ht(n).autoPermissionMode;return t==="always"?!0:t==="never"?!1:((s=Tr(n,e))==null?void 0:s.supportsAutoMode)===!0}function F3(n,e){return Ht(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function ga(n,e,t){var l,c;const s=lg(n,t);if(s.length===0)return"";const o=(l=Tr(n,t))==null?void 0:l.defaultReasoningEffort,i=o&&s.some(d=>d.value===o)?o:s.some(d=>d.value===al)?al:((c=s[0])==null?void 0:c.value)??al,a=e||i;return s.some(d=>d.value===a)?a:i}function B3(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Er(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 U3=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 ee(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=V(U3({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(fv,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function un(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=V("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 fn(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=V("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 W3=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 _n(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=V(W3({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 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=V("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 Tn(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=V("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 dg(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=V("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 H3(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 K3=n=>{switch(n){case"success":return G3;case"info":return X3;case"warning":return Y3;case"error":return J3;default:return null}},q3=Array(12).fill(0),V3=({visible:n,className:e})=>ve.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},ve.createElement("div",{className:"sonner-spinner"},q3.map((t,s)=>ve.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),G3=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ve.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"})),Y3=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ve.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"})),X3=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ve.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"})),J3=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ve.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"})),Q3=ve.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"},ve.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Z3=()=>{const[n,e]=ve.useState(document.hidden);return ve.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let ew=1;const tw=100,_f=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:ew++};class nw{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-tw;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=_f(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],ve.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(ow(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"&&!ve.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"&&!ve.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"&&!ve.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"&&!ve.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=_f(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 Gt=new nw,sw=(n,e)=>Gt.message(n,e),ow=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",rw=sw,iw=()=>Gt.toasts,aw=()=>Gt.getActiveToasts(),_s=Object.assign(rw,{success:Gt.success,info:Gt.info,warning:Gt.warning,error:Gt.error,custom:Gt.custom,message:Gt.message,promise:Gt.promise,dismiss:Gt.dismiss,loading:Gt.loading},{getHistory:iw,getToasts:aw});H3("[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 ai(n){return n.label!==void 0}const lw=3,cw="24px",dw="16px",Tf=4e3,uw=356,fw=14,mw=45,pw=200;function Pn(...n){return n.filter(Boolean).join(" ")}function hw(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const gw=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:v,removeToast:j,defaultRichColors:S,closeButton:k,style:C,cancelButtonStyle:N,actionButtonStyle:_,className:A="",descriptionClassName:P="",duration:E,position:T,gap:I,expandByDefault:$,classNames:R,icons:M,closeButtonAriaLabel:D="Close toast"}=n,[O,L]=ve.useState(null),[F,z]=ve.useState(null),[W,U]=ve.useState(!1),[H,K]=ve.useState(!1),[q,Y]=ve.useState(!1),[G,J]=ve.useState(!1),[Q,X]=ve.useState(!1),[Z,se]=ve.useState(0),[ne,re]=ve.useState(0),ie=ve.useRef(u.duration||E||Tf),ae=ve.useRef(null),te=ve.useRef(null),ue=b===0,le=b+1<=g,de=u.type,he=de??"default",xe=u.dismissible!==!1,ce=u.className||"",be=u.descriptionClassName||"",ge=ve.useMemo(()=>x.findIndex(oe=>oe.toastId===u.id)||0,[x,u.id]),fe=ve.useMemo(()=>{var oe;return(oe=u.closeButton)!=null?oe:k},[u.closeButton,k]),je=ve.useMemo(()=>u.duration||E||Tf,[u.duration,E]),Se=ve.useRef(0),Ae=ve.useRef(0),Ie=ve.useRef(0),Re=ve.useRef(null),[De,Le]=T.split("-"),ze=ve.useMemo(()=>x.reduce((oe,pe,Te)=>Te>=ge?oe:oe+pe.height,0),[x,ge]),_e=Z3(),Ce=ve.useMemo(()=>{var oe;return(oe=n.swipeDirections)!=null?oe:hw(T)},[n.swipeDirections,T]),We=u.invert||f,Fe=de==="loading";Ae.current=ve.useMemo(()=>ge*I+ze,[ge,ze]),ve.useEffect(()=>{ie.current=je},[je]),ve.useEffect(()=>{U(!0)},[]),ve.useEffect(()=>{const oe=te.current;if(oe){const pe=oe.getBoundingClientRect().height;return re(pe),h(Te=>[{toastId:u.id,height:pe,position:u.position},...Te]),()=>h(Te=>Te.filter($e=>$e.toastId!==u.id))}},[h,u.id]),ve.useLayoutEffect(()=>{if(!W)return;const oe=te.current,pe=oe.style.height;oe.style.height="auto";const Te=oe.getBoundingClientRect().height;oe.style.height=pe,re(Te),h($e=>$e.find(Ke=>Ke.toastId===u.id)?$e.map(Ke=>Ke.toastId===u.id?{...Ke,height:Te}:Ke):[{toastId:u.id,height:Te,position:u.position},...$e])},[W,u.title,u.description,h,u.id,u.jsx,u.action,u.cancel]);const Ne=ve.useCallback(()=>{K(!0),se(Ae.current),h(oe=>oe.filter(pe=>pe.toastId!==u.id)),setTimeout(()=>{j(u)},pw)},[u,j,h,Ae]);ve.useEffect(()=>{if(u.promise&&de==="loading"||u.duration===1/0||u.type==="loading")return;let oe;return v||p||_e?(()=>{if(Ie.current<Se.current){const $e=new Date().getTime()-Se.current;ie.current=ie.current-$e}Ie.current=new Date().getTime()})():(()=>{ie.current!==1/0&&(Se.current=new Date().getTime(),oe=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Ne()},ie.current))})(),()=>clearTimeout(oe)},[v,p,u,de,_e,Ne]),ve.useEffect(()=>{u.delete&&(Ne(),u.onDismiss==null||u.onDismiss.call(u,u))},[Ne,u.delete]);function me(){var oe;if(M!=null&&M.loading){var pe;return ve.createElement("div",{className:Pn(R==null?void 0:R.loader,u==null||(pe=u.classNames)==null?void 0:pe.loader,"sonner-loader"),"data-visible":de==="loading"},M.loading)}return ve.createElement(V3,{className:Pn(R==null?void 0:R.loader,u==null||(oe=u.classNames)==null?void 0:oe.loader),visible:de==="loading"})}const Oe=u.icon||(M==null?void 0:M[de])||K3(de);var Pe,Be;return ve.createElement("li",{tabIndex:0,ref:te,className:Pn(A,ce,R==null?void 0:R.toast,u==null||(e=u.classNames)==null?void 0:e.toast,R==null?void 0:R[he],u==null||(t=u.classNames)==null?void 0:t[he]),"data-sonner-toast":"","data-rich-colors":(Pe=u.richColors)!=null?Pe:S,"data-styled":!(u.jsx||u.unstyled||m),"data-mounted":W,"data-promise":!!u.promise,"data-swiped":Q,"data-removed":H,"data-visible":le,"data-y-position":De,"data-x-position":Le,"data-index":b,"data-front":ue,"data-swiping":q,"data-dismissible":xe,"data-type":de,"data-invert":We,"data-swipe-out":G,"data-swipe-direction":F,"data-expanded":!!(v||$&&W),"data-testid":u.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${H?Z:Ae.current}px`,"--initial-height":$?"auto":`${ne}px`,...C,...u.style},onDragEnd:()=>{Y(!1),L(null),Re.current=null},onPointerDown:oe=>{oe.button!==2&&(Fe||!xe||(ae.current=new Date,se(Ae.current),oe.target.setPointerCapture(oe.pointerId),oe.target.tagName!=="BUTTON"&&(Y(!0),Re.current={x:oe.clientX,y:oe.clientY})))},onPointerUp:()=>{var oe,pe,Te;if(G||!xe)return;Re.current=null;const $e=Number(((oe=te.current)==null?void 0:oe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),He=Number(((pe=te.current)==null?void 0:pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ke=new Date().getTime()-((Te=ae.current)==null?void 0:Te.getTime()),st=O==="x"?$e:He,Ye=Math.abs(st)/Ke;if((O==="x"?Ce.includes($e>0?"right":"left"):Ce.includes(He>0?"bottom":"top"))&&(Math.abs(st)>=mw||Ye>.11)){se(Ae.current),u.onDismiss==null||u.onDismiss.call(u,u),z(O==="x"?$e>0?"right":"left":He>0?"down":"up"),Ne(),J(!0);return}else{var Ue,ot;(Ue=te.current)==null||Ue.style.setProperty("--swipe-amount-x","0px"),(ot=te.current)==null||ot.style.setProperty("--swipe-amount-y","0px")}X(!1),Y(!1),L(null)},onPointerMove:oe=>{var pe,Te,$e;if(!Re.current||!xe||((pe=window.getSelection())==null?void 0:pe.toString().length)>0)return;const Ke=oe.clientY-Re.current.y,st=oe.clientX-Re.current.x;!O&&(Math.abs(st)>1||Math.abs(Ke)>1)&&L(Math.abs(st)>Math.abs(Ke)?"x":"y");let Ye={x:0,y:0};const Me=Ue=>1/(1.5+Math.abs(Ue)/20);if(O==="y"){if(Ce.includes("top")||Ce.includes("bottom"))if(Ce.includes("top")&&Ke<0||Ce.includes("bottom")&&Ke>0)Ye.y=Ke;else{const Ue=Ke*Me(Ke);Ye.y=Math.abs(Ue)<Math.abs(Ke)?Ue:Ke}}else if(O==="x"&&(Ce.includes("left")||Ce.includes("right")))if(Ce.includes("left")&&st<0||Ce.includes("right")&&st>0)Ye.x=st;else{const Ue=st*Me(st);Ye.x=Math.abs(Ue)<Math.abs(st)?Ue:st}(Math.abs(Ye.x)>0||Math.abs(Ye.y)>0)&&X(!0),(Te=te.current)==null||Te.style.setProperty("--swipe-amount-x",`${Ye.x}px`),($e=te.current)==null||$e.style.setProperty("--swipe-amount-y",`${Ye.y}px`)}},fe&&!u.jsx&&de!=="loading"?ve.createElement("button",{"aria-label":D,"data-disabled":Fe,"data-close-button":!0,onClick:Fe||!xe?()=>{}:()=>{Ne(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Pn(R==null?void 0:R.closeButton,u==null||(s=u.classNames)==null?void 0:s.closeButton)},(Be=M==null?void 0:M.close)!=null?Be:Q3):null,(de||u.icon||u.promise)&&u.icon!==null&&((M==null?void 0:M[de])!==null||u.icon)?ve.createElement("div",{"data-icon":"",className:Pn(R==null?void 0:R.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},de==="loading"?u.icon||me():u.promise?me():null,de!=="loading"?Oe:null):null,ve.createElement("div",{"data-content":"",className:Pn(R==null?void 0:R.content,u==null||(i=u.classNames)==null?void 0:i.content)},ve.createElement("div",{"data-title":"",className:Pn(R==null?void 0:R.title,u==null||(a=u.classNames)==null?void 0:a.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?ve.createElement("div",{"data-description":"",className:Pn(P,be,R==null?void 0:R.description,u==null||(l=u.classNames)==null?void 0:l.description)},typeof u.description=="function"?u.description():u.description):null),ve.isValidElement(u.cancel)?u.cancel:u.cancel&&ai(u.cancel)?ve.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||N,onClick:oe=>{ai(u.cancel)&&xe&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,oe),Ne())},className:Pn(R==null?void 0:R.cancelButton,u==null||(c=u.classNames)==null?void 0:c.cancelButton)},u.cancel.label):null,ve.isValidElement(u.action)?u.action:u.action&&ai(u.action)?ve.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||_,onClick:oe=>{ai(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,oe),!oe.defaultPrevented&&Ne())},className:Pn(R==null?void 0:R.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function Ef(){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 xw(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?dw:cw;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 bw=ve.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=lw,toastOptions:b,dir:w=Ef(),gap:v=fw,icons:j,customAriaLabel:S,containerAriaLabel:k="Notifications"}=e,[C,N]=ve.useState([]),_=ve.useMemo(()=>s?C.filter(U=>U.toasterId===s):C.filter(U=>!U.toasterId),[C,s]),A=ve.useMemo(()=>Array.from(new Set([i].concat(_.filter(U=>U.position).map(U=>U.position)))),[_,i]),[P,E]=ve.useState([]),[T,I]=ve.useState(!1),[$,R]=ve.useState(!1),[M,D]=ve.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=ve.useRef(null),L=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=ve.useRef(null),z=ve.useRef(!1),W=ve.useCallback(U=>{N(H=>{var K;return(K=H.find(q=>q.id===U.id))!=null&&K.delete||Gt.dismiss(U.id),H.filter(({id:q})=>q!==U.id)})},[]);return ve.useEffect(()=>Gt.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{N(H=>H.map(K=>K.id===U.id?{...K,delete:!0}:K))});return}setTimeout(()=>{av.flushSync(()=>{N(H=>{const K=H.findIndex(q=>q.id===U.id);return K!==-1?[...H.slice(0,K),{...H[K],...U},...H.slice(K+1)]:[U,...H]})})})}),[]),ve.useEffect(()=>{if(m!=="system"){D(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?D("dark"):D("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:H})=>{D(H?"dark":"light")})}catch{U.addListener(({matches:K})=>{try{D(K?"dark":"light")}catch(q){console.error(q)}})}},[m]),ve.useEffect(()=>{C.length<=1&&I(!1)},[C]),ve.useEffect(()=>{const U=H=>{var K;if(a.length>0&&a.every(G=>H[G]||H.code===G)){var Y;I(!0),(Y=O.current)==null||Y.focus()}H.code==="Escape"&&(document.activeElement===O.current||(K=O.current)!=null&&K.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[a]),ve.useEffect(()=>{if(O.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,z.current=!1)}},[O.current]),ve.createElement("section",{ref:t,"aria-label":S??`${k} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},A.map((U,H)=>{var K;const[q,Y]=U.split("-");return _.length?ve.createElement("ol",{key:U,dir:w==="auto"?Ef():w,tabIndex:-1,ref:O,className:d,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":q,"data-x-position":Y,style:{"--front-toast-height":`${((K=P[0])==null?void 0:K.height)||0}px`,"--width":`${uw}px`,"--gap":`${v}px`,...g,...xw(f,u)},onBlur:G=>{z.current&&!G.currentTarget.contains(G.relatedTarget)&&(z.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||z.current||(z.current=!0,F.current=G.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{$||I(!1)},onDragEnd:()=>I(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},_.filter(G=>!G.position&&H===0||G.position===U).map((G,J)=>{var Q,X;return ve.createElement(gw,{key:G.id,icons:j,index:J,toast:G,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:(X=b==null?void 0:b.closeButton)!=null?X:c,interacting:$,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:W,toasts:_.filter(Z=>Z.position==G.position),heights:P.filter(Z=>Z.position==G.position),setHeights:E,expandByDefault:l,gap:v,expanded:T,swipeDirections:e.swipeDirections})})):null}))}),vw=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(Yn,{className:"size-4"}),info:r.jsx(pv,{className:"size-4"}),warning:r.jsx(kn,{className:"size-4"}),error:r.jsx(mv,{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(bw,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function yw(n){const e=B.c(13),{activeError:t,clearActiveError:s,modelFallbackNotice:o,dismissModelFallbackNotice:i,connectionLost:a,theme:l}=n;let c,d;e[0]!==t||e[1]!==s?(c=()=>{if(!t){_s.dismiss("app-error");return}_s.error(t,{id:"app-error",duration:8e3,onDismiss:s,onAutoClose:s})},d=[t,s],e[0]=t,e[1]=s,e[2]=c,e[3]=d):(c=e[2],d=e[3]),y.useEffect(c,d);let f,u;e[4]!==i||e[5]!==o?(f=()=>{if(!o){_s.dismiss("model-fallback");return}_s.warning(o,{id:"model-fallback",duration:1/0,onDismiss:i})},u=[i,o],e[4]=i,e[5]=o,e[6]=f,e[7]=u):(f=e[6],u=e[7]),y.useEffect(f,u);let m,p;e[8]!==a?(m=()=>{if(!a){_s.dismiss("session-connection");return}_s.warning("Connection lost",{id:"session-connection",description:"Reconnecting to the live session…",duration:1/0})},p=[a],e[8]=a,e[9]=m,e[10]=p):(m=e[9],p=e[10]),y.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(vw,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const jt="local",ug="cogpit-last-path::",rc=new Map;function gt(){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 Ds(){return gt()!==jt}function fg(){const n=gt();return n===jt?"":`/hub/${n}`}function mg(n){const e=fg();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")?`${e}${n}`:n}let lr=null;function pg(n){n!==lr&&(lr=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function hs(){return lr}function _i(n){return n===jt?0:rc.get(n)??0}function ww(n,e){if(n===jt||!Number.isSafeInteger(e)||e<0)return!1;const t=rc.get(n);return t!==void 0&&e<=t?!1:(rc.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function bn(){const n=gt(),e=_i(n);return e===0?n:`${n}@${e}`}function Ut(n){const e=gt(),t=bn();return lr!==null?`${n}::${t}::${lr}`:e===jt?n:`${n}::${t}`}function Ro(n,e){sessionStorage.setItem(`${ug}${n}`,e)}function gs(n){const t=sessionStorage.getItem(`${ug}${n}`)??(n===jt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const Af="cogpit-network-token",jw=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function xa(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!jw.has(e)}function ba(){try{localStorage.removeItem(Af),sessionStorage.removeItem(Af)}catch{}}typeof window<"u"&&ba();const Sw={edition:"personal",needsBootstrap:!1};let cr=null,po=null;function hg(){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 po=e.edition==="team"?"team":"personal",{edition:po,needsBootstrap:po==="team"&&e.needsBootstrap===!0}}).catch(()=>(cr=null,Sw))}function gg(){return cr??(cr=hg()),cr}function Pf(){return cr=hg(),cr}function xg(){return gg().then(n=>n.edition)}async function Nw(){if(!xa()&&po!=="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 kw(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{ba()}}function If(){return ba(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function bg(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=mg(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(xa()||po==="team")return If();if(po===null)return xg().then(i=>i==="team"?If():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 bg(n,e,!0)}function as(n,e){return bg(n,e,!1)}function Ar(n){return mg(n)}let Rf=!1;function Cw(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 _w(){if(!Rf){Rf=!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];Cw(s)&&$3(t,s)}}catch{}}}function vg(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],y.useEffect(Tw,t);let s;return e[1]!==n?(s=()=>ag(n),e[1]=n,e[2]=s):s=e[2],y.useSyncExternalStore(M3,s)}function Tw(){_w()}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(gv,{"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(xv,{"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=V("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(Th,{"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(Ah,{children:r.jsx(Ph,{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 Qt(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(Eh,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Ls(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=V("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(Ih,{"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 kt(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=V("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(_h,{"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 Ew(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=V("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(wv,{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(mt,{})})}),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(vv,{"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 Di(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(yv,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Qc(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=V("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(bv,{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(mt,{})})}),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(hv,{"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 dr(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=V("-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(zc,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}on("claude").contextWindow.compactBuffer;function Aw(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=on(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 Pw(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=Aw(e,t),c=l-on(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 Iw=4;function yg(n){return Math.ceil(n/Iw)}function wg(n){let e=0;for(const t of n)e+=t.length;return e}function Rw(n){let e=0;for(const t of n)e+=JSON.stringify(t.input).length;return e}function $w(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:yg(wg(n.thinking.map(o=>o.thinking)))}function Mw(n){return yg(wg(n.assistantText)+Rw(n.toolCalls))}function ls(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}const Ow=["fable","mythos","opus","sonnet","haiku"];function $f(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Pr(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const o of Ow){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`${$f(o)}${a}${t}`}if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map($f).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 Mn(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 Dw(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function jg(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Ir(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 Zc(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 ed(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 vn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function wn(n){return js(n).dirName.decode(n)??n}function va(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function ya(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 xs(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function Sg(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return Pw(t.message.usage,t.message.model??"","claude")}return null}const Lw={claude:go,codex:Sr,copilot:jv},td={claude:"Claude",codex:"Codex",copilot:"Copilot"},zw={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},Fw={claude:null,codex:"Codex",copilot:"Copilot"},Bw={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"}},Uw={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},Ww={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},Hw={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 Kw(n){return Hw[n]}function wa(n){return td[n]}function OD(n){return zw[n]}function qw(n){return Fw[n]}function DD(n){return Bw[n]}function Vw(n){return Ww[n]}function Gw(n){return Uw[n]}const Mf=js(null).kind,Ng=[Mf,...ps.filter(n=>n!==Mf)];function Yw(n){return`This ${td[n]} session is controlled by another process. Cogpit can only view it.`}const ic=Ng.map(n=>({value:n,label:td[n],Icon:Lw[n]}));function Xw(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 Jw(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?nd(e,n):"Default"}function nd(n,e){var t;return((t=Xw(n,e))==null?void 0:t.label)??Pr(n)}function kg(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:V(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(Qc,{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 Qw(n){var P,E;const e=B.c(33),{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}=n;let c;e[0]!==t?(c=((P=ic.find(T=>T.value===t))==null?void 0:P.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=((E=a.find(T=>T.value===o))==null?void 0:E.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(ee,{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(nt,{"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(Ls,{children:"Agent"}),e[12]=b):b=e[12];let w;e[13]!==s?(w=T=>s(T),e[13]=s,e[14]=w):w=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=ic.map(ej),e[15]=v):v=e[15];let j;e[16]!==t||e[17]!==w?(j=r.jsxs(Qt,{children:[b,r.jsx(Di,{value:t,onValueChange:w,children:v})]}),e[16]=t,e[17]=w,e[18]=j):j=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(dr,{}),e[19]=S):S=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Ls,{children:"Model"}),e[20]=k):k=e[20];let C;e[21]!==a?(C=a.map(Zw),e[21]=a,e[22]=C):C=e[22];let N;e[23]!==l||e[24]!==C||e[25]!==o?(N=r.jsxs(Qt,{children:[k,r.jsx(Di,{value:o,onValueChange:l,children:C})]}),e[23]=l,e[24]=C,e[25]=o,e[26]=N):N=e[26];let _;e[27]!==j||e[28]!==N?(_=r.jsxs(zn,{"aria-label":"Agent and model",className:"w-80",children:[j,S,N]}),e[27]=j,e[28]=N,e[29]=_):_=e[29];let A;return e[30]!==_||e[31]!==x?(A=r.jsxs(Dn,{children:[x,_]}),e[30]=_,e[31]=x,e[32]=A):A=e[32],A}function Zw(n){return r.jsx(kg,{option:n,descriptionWidth:"max-w-80"},n.value)}function ej(n){const e=n.Icon;return r.jsxs(Qc,{value:n.value,children:[r.jsx(e,{}),n.label]},n.value)}function tj(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(nj),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=y.useId();let p,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),h=r.jsx(Sv,{"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(Dt,{"data-icon":"inline-end",className:"animate-spin"}):r.jsx(nt,{"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 v;e[14]!==m?(v=r.jsx(Ls,{id:m,children:"MCP servers"}),e[14]=m,e[15]=v):v=e[15];const j=a?"animate-spin":void 0;let S;e[16]!==j?(S=r.jsx(Dt,{"data-icon":"inline-start",className:j}),e[16]=j,e[17]=S):S=e[17];let k;e[18]!==i||e[19]!==S?(k=r.jsxs(kt,{closeOnClick:!1,onClick:i,children:[S,"Refresh status"]}),e[18]=i,e[19]=S,e[20]=k):k=e[20];let C;e[21]!==a||e[22]!==t.length?(C=t.length===0&&r.jsx(kt,{disabled:!0,children:a?"Loading...":"No MCP servers configured"}),e[21]=a,e[22]=t.length,e[23]=C):C=e[23];let N;if(e[24]!==l||e[25]!==o||e[26]!==u||e[27]!==t){let E;e[29]!==l||e[30]!==o||e[31]!==u?(E=T=>T.status!=="connected"?r.jsxs(kt,{onClick:()=>l(T.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:T.name}),r.jsx("span",{className:"text-xs text-warning",children:"Needs auth"})]},T.name):r.jsxs(Ew,{checked:u.has(T.name),onCheckedChange:()=>o(T.name),children:[r.jsx("span",{className:"size-2 rounded-full bg-success"}),r.jsx("span",{className:"truncate",children:T.name})]},T.name),e[29]=l,e[30]=o,e[31]=u,e[32]=E):E=e[32],N=t.map(E),e[24]=l,e[25]=o,e[26]=u,e[27]=t,e[28]=N}else N=e[28];let _;e[33]!==k||e[34]!==C||e[35]!==N||e[36]!==v?(_=r.jsxs(Qt,{children:[v,k,C,N]}),e[33]=k,e[34]=C,e[35]=N,e[36]=v,e[37]=_):_=e[37];let A;e[38]!==m||e[39]!==_?(A=r.jsx(zn,{"aria-labelledby":m,className:"w-64",children:_}),e[38]=m,e[39]=_,e[40]=A):A=e[40];let P;return e[41]!==A||e[42]!==w?(P=r.jsxs(Dn,{children:[w,A]}),e[41]=A,e[42]=w,e[43]=P):P=e[43],P}function nj(n){return n.status==="connected"}function Of(n){var k;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=((k=o.find(C=>C.value===t))==null?void 0:k.label)??s,e[0]=s,e[1]=o,e[2]=t,e[3]=d):d=e[3];const f=d,u=y.useId();let m;e[4]!==l?(m=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",title:l}),e[4]=l,e[5]=m):m=e[5];let p;e[6]!==f?(p=r.jsx("span",{className:"truncate",children:f}),e[6]=f,e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(nt,{"data-icon":"inline-end"}),e[8]=h):h=e[8];let g;e[9]!==a||e[10]!==m||e[11]!==p?(g=r.jsxs(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(Ls,{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(sj),e[16]=o,e[17]=b):b=e[17];let w;e[18]!==i||e[19]!==b||e[20]!==t?(w=r.jsx(Di,{value:t,onValueChange:i,children:b}),e[18]=i,e[19]=b,e[20]=t,e[21]=w):w=e[21];let v;e[22]!==x||e[23]!==w?(v=r.jsxs(Qt,{children:[x,w]}),e[22]=x,e[23]=w,e[24]=v):v=e[24];let j;e[25]!==u||e[26]!==v?(j=r.jsx(zn,{"aria-labelledby":u,className:"w-48",children:v}),e[25]=u,e[26]=v,e[27]=j):j=e[27];let S;return e[28]!==j||e[29]!==g?(S=r.jsxs(Dn,{children:[g,j]}),e[28]=j,e[29]=g,e[30]=S):S=e[30],S}function sj(n){return r.jsx(kg,{option:n},n.value)}function Cg(n,e){return Kw(n).filter(t=>t.value!=="auto"||e)}function oj(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 k=Cg(t,a),C=k.find(P=>P.value===s)??k[0];f=Dn;let N,_;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),N=r.jsx(Rh,{"data-icon":"inline-start"}),e[15]=N,e[16]=_):(N=e[15],_=e[16]);let A;e[17]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(nt,{"data-icon":"inline-end"}),e[17]=A):A=e[17],b=r.jsxs(Ln,{render:_,children:[N,r.jsx("span",{className:"truncate",children:C.label}),A]}),d=zn,g="Access policy",x="w-72",c=Qt,e[18]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Ls,{children:"Permissions"}),e[18]=h):h=e[18],l=Di,u=s,e[19]!==o?(m=P=>o(P),e[19]=o,e[20]=m):m=e[20],p=k.map(rj),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 v;e[26]!==c||e[27]!==h||e[28]!==w?(v=r.jsxs(c,{children:[h,w]}),e[26]=c,e[27]=h,e[28]=w,e[29]=v):v=e[29];let j;e[30]!==d||e[31]!==v||e[32]!==g||e[33]!==x?(j=r.jsx(d,{"aria-label":g,className:x,children:v}),e[30]=d,e[31]=v,e[32]=g,e[33]=x,e[34]=j):j=e[34];let S;return e[35]!==f||e[36]!==j||e[37]!==b?(S=r.jsxs(f,{children:[b,j]}),e[35]=f,e[36]=j,e[37]=b,e[38]=S):S=e[38],S}function rj(n){return r.jsx(Qc,{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 ij(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:v,permissionMode:j,onPermissionModeChange:S,mcpServers:k,selectedMcpServers:C,onToggleMcpServer:N,onRefreshMcpServers:_,mcpLoading:A,onMcpAuth:P,changeAndApply:E,trailingExtra:T}=n;let I;e[0]!==t?(I=Ht(t),e[0]=t,e[1]=I):I=e[1];const{worktrees:$,ultracode:R,settingsApply:M}=I,D=y.useId(),O=h?void 0:M==="live"?"Changes apply live":"Changes apply next turn",L=O?D:void 0;let F;e[2]!==O||e[3]!==D?(F=O&&r.jsx("span",{id:D,className:"sr-only",children:O}),e[2]=O,e[3]=D,e[4]=F):F=e[4];let z;e[5]!==t||e[6]!==a||e[7]!==s||e[8]!==l||e[9]!==i||e[10]!==o?(z=s?r.jsx(Qw,{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}):r.jsx(Of,{value:o,fallbackLabel:"Model",ariaLabel:"Model",options:a,onChange:l}),e[5]=t,e[6]=a,e[7]=s,e[8]=l,e[9]=i,e[10]=o,e[11]=z):z=e[11];let W;e[12]!==t||e[13]!==d||e[14]!==f||e[15]!==c||e[16]!==o||e[17]!==b?(W=d.length>0&&r.jsx(Of,{value:ga(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]=W):W=e[18];let U;e[19]!==E||e[20]!==m||e[21]!==u||e[22]!==p?(U=u&&p&&r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost",size:"xs","aria-pressed":!!m,onClick:()=>E(()=>p(!m)),title:u.description,children:[r.jsx($i,{"data-icon":"inline-start",className:V(m&&"fill-current")}),m?"Fast":"Standard"]}),e[19]=E,e[20]=m,e[21]=u,e[22]=p,e[23]=U):U=e[23];let H;e[24]!==t||e[25]!==v||e[26]!==E||e[27]!==S||e[28]!==j?(H=S&&j&&r.jsx(oj,{agentKind:t,mode:j,onChange:Q=>E(()=>S(Q)),autoAvailable:v}),e[24]=t,e[25]=v,e[26]=E,e[27]=S,e[28]=j,e[29]=H):H=e[29];let K;e[30]!==h||e[31]!==x||e[32]!==$||e[33]!==g?(K=$&&h&&x&&r.jsxs(ee,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(Us,{"data-icon":"inline-start"}),"Worktree"]}),e[30]=h,e[31]=x,e[32]=$,e[33]=g,e[34]=K):K=e[34];let q;e[35]!==E||e[36]!==w||e[37]!==R||e[38]!==b?(q=R&&w&&r.jsxs(ee,{type:"button",variant:b?"secondary":"ghost",size:"xs","aria-pressed":!!b,onClick:()=>E(()=>w(!b)),title:"Ultracode: XHigh effort + standing multi-agent workflow orchestration",children:[r.jsx($i,{"data-icon":"inline-start",className:V(b&&"fill-current")}),"Ultracode"]}),e[35]=E,e[36]=w,e[37]=R,e[38]=b,e[39]=q):q=e[39];let Y;e[40]!==E||e[41]!==A||e[42]!==k||e[43]!==P||e[44]!==_||e[45]!==N||e[46]!==C?(Y=N&&_&&P&&(A||k&&k.length>0)&&r.jsx(tj,{servers:k??[],selected:C??[],onToggle:Q=>E(()=>N(Q)),onRefresh:_,loading:A??!1,onAuth:P}),e[40]=E,e[41]=A,e[42]=k,e[43]=P,e[44]=_,e[45]=N,e[46]=C,e[47]=Y):Y=e[47];let G;e[48]!==Y||e[49]!==z||e[50]!==W||e[51]!==U||e[52]!==H||e[53]!==K||e[54]!==q||e[55]!==T?(G=r.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1.5",children:[z,W,U,H,K,q,Y,T]}),e[48]=Y,e[49]=z,e[50]=W,e[51]=U,e[52]=H,e[53]=K,e[54]=q,e[55]=T,e[56]=G):G=e[56];let J;return e[57]!==O||e[58]!==G||e[59]!==L||e[60]!==F?(J=r.jsxs("div",{className:"flex items-center pb-1.5 pl-6 pr-3",role:"group",title:O,"aria-describedby":L,children:[F,G]}),e[57]=O,e[58]=G,e[59]=L,e[60]=F,e[61]=J):J=e[61],J}function Rt(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=V("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(zc,{"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 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=V("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 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=V("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 cj(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=V("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 To(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=V("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 dj=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 xt(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=V(dj({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 LD(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=V("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 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=V("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(aj,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function yo(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=V("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(fj)).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(uj)}),e[7]=m,e[8]=p):p=e[8],a=p}const l=a;if(!l)return null;let c;e[9]!==s?(c=V("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 uj(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function fj(n){return[n==null?void 0:n.message,n]}const mj=_v;function pj(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=V("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(Pv,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function hj(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=V("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(Tv,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function gj(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=V("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(Iv,{render:r.jsx(nt,{className:"pointer-events-none size-4 text-muted-foreground transition-transform duration-150 ease-out group-data-popup-open/select-trigger:rotate-180 motion-reduce:transition-none"})}),e[7]=c):c=e[7];let d;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==l?(d=r.jsxs(Ev,{"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 xj(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=V("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(vj,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=r.jsx(Rv,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(yj,{}),e[14]=w):w=e[14];let v;e[15]!==o||e[16]!==g||e[17]!==b?(v=r.jsxs(Av,{"data-slot":"select-content",className:g,...o,children:[x,b,w]}),e[15]=o,e[16]=g,e[17]=b,e[18]=v):v=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==f||e[23]!==u||e[24]!==v?(j=r.jsx($v,{children:r.jsx(Mv,{side:f,sideOffset:u,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=f,e[23]=u,e[24]=v,e[25]=j):j=e[25],j}function bj(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=V("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(kv,{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(Cv,{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(mt,{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(Nv,{"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 vj(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=V("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(Nr,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Ov,{"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 yj(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=V("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(nt,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Dv,{"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 wj(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($h,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function jj(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(Lv,{"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(oa,{"data-slot":"sheet-close",...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(Wc,{"data-slot":"sheet-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=V("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(Hc,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Cj(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(kj,{}),e[6]=d):d=e[6];let f;e[7]!==s?(f=V("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(oa,{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(ct,{"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(Nj,{children:[d,r.jsxs(Uc,{"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 _j(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=V("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 Tj(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=V("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(Fc,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ej(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=V("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(Bc,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jo(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=V("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(bt,{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(xt,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=f):f=e[9],f}function li(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(hj,{}),e[2]=f):f=e[2];let u;e[3]!==s||e[4]!==c?(u=r.jsx(gj,{"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(Aj),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(xj,{children:r.jsx(pj,{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(mj,{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(Jo,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function Aj(n){return r.jsx(bj,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function Pj(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=ga(t,l,o),e[0]=t,e[1]=l,e[2]=o,e[3]=w):w=e[3];const v=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 S;e[5]!==t||e[6]!==s?(S=s&&r.jsx(li,{label:"Agent",ariaLabel:"Agent",value:t,options:ic,onChange:P=>s(P)}),e[5]=t,e[6]=s,e[7]=S):S=e[7];let k;e[8]!==a||e[9]!==i||e[10]!==o?(k=r.jsx(li,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[8]=a,e[9]=i,e[10]=o,e[11]=k):k=e[11];let C;e[12]!==d||e[13]!==v||e[14]!==c||e[15]!==f?(C=d.length>0&&r.jsx(li,{label:"Reasoning",ariaLabel:"Reasoning effort",value:v,options:d,onChange:c,disabled:f,title:f?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=d,e[13]=v,e[14]=c,e[15]=f,e[16]=C):C=e[16];let N;e[17]!==b||e[18]!==m||e[19]!==u||e[20]!==p?(N=u&&p&&r.jsx(Jo,{label:"Speed",children:r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>b(()=>p(!m)),title:u.description,className:"h-10 justify-start",children:[r.jsx($i,{"data-icon":"inline-start",className:V(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[17]=b,e[18]=m,e[19]=u,e[20]=p,e[21]=N):N=e[21];let _;e[22]!==x||e[23]!==h||e[24]!==g?(_=x&&h&&r.jsx(li,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:P=>x(P)}),e[22]=x,e[23]=h,e[24]=g,e[25]=_):_=e[25];let A;return e[26]!==S||e[27]!==k||e[28]!==C||e[29]!==N||e[30]!==_?(A=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:[S,k,C,N,_]})]}),e[26]=S,e[27]=k,e[28]=C,e[29]=N,e[30]=_,e[31]=A):A=e[31],A}function Ij(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)),v=!!(x&&s&&i||b&&l||w);let j;e[2]!==d?(j=d??[],e[2]=d,e[3]=j):j=e[3];let S;e[4]!==j?(S=new Set(j),e[4]=j,e[5]=S):S=e[5];const k=S;if(!v)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 N;e[7]!==s||e[8]!==i||e[9]!==x||e[10]!==o?(N=x&&s&&i&&r.jsx(Jo,{label:"Isolation",children:r.jsxs(ee,{type:"button",variant:o?"secondary":"ghost","aria-pressed":!!o,onClick:()=>i(!o),className:"h-10 justify-start",children:[r.jsx(Us,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=i,e[9]=x,e[10]=o,e[11]=N):N=e[11];let _;e[12]!==h||e[13]!==l||e[14]!==b||e[15]!==a?(_=b&&l&&r.jsx(Jo,{label:"Workflow",children:r.jsxs(ee,{type:"button",variant:a?"secondary":"ghost","aria-pressed":!!a,onClick:()=>h(()=>l(!a)),className:"h-10 justify-start",children:[r.jsx($i,{"data-icon":"inline-start",className:V(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=a,e[16]=_):_=e[16];let A;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==u||e[22]!==f||e[23]!==k||e[24]!==w?(A=w&&f&&u&&p&&r.jsx(Jo,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(ee,{type:"button",variant:"ghost",onClick:u,className:"min-h-10 justify-start",children:[r.jsx(Dt,{"data-icon":"inline-start",className:V(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(E=>{const T=k.has(E.name),I=E.status==="connected";return r.jsxs(ee,{type:"button",variant:"ghost","aria-pressed":I?T:void 0,onClick:()=>I?h(()=>f(E.name)):p(E.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:V("size-2 shrink-0 rounded-full",I&&T?"bg-success":I?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:I?T?"On":"Off":"Connect"})]},E.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=u,e[22]=f,e[23]=k,e[24]=w,e[25]=A):A=e[25];let P;return e[26]!==N||e[27]!==_||e[28]!==A?(P=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:[N,_,A]})]}),e[26]=N,e[27]=_,e[28]=A,e[29]=P):P=e[29],P}function Rj(n){var ue,le;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:v,ultracodeEnabled:j,onUltracodeEnabledChange:S,autoModeAvailable:k,permissionMode:C,onPermissionModeChange:N,mcpServers:_,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:E,mcpLoading:T,onMcpAuth:I,mobileExtra:$,changeAndApply:R}=n;let M;e[0]!==o||e[1]!==u||e[2]!==a?(M=ga(o,u,a),e[0]=o,e[1]=u,e[2]=a,e[3]=M):M=e[3];const D=M;let O,L;e[4]!==o||e[5]!==k||e[6]!==C?(O=Cg(o,k),L=(ue=O.find(de=>de.value===C))==null?void 0:ue.label,e[4]=o,e[5]=k,e[6]=C,e[7]=O,e[8]=L):(O=e[7],L=e[8]);const F=L;let z;e[9]!==c||e[10]!==l||e[11]!==a?(z=a?nd(a,c):l,e[9]=c,e[10]=l,e[11]=a,e[12]=z):z=e[12];let W;e[13]!==m||e[14]!==D?(W=(le=m.find(de=>de.value===D))==null?void 0:le.label,e[13]=m,e[14]=D,e[15]=W):W=e[15];let U;e[16]!==F||e[17]!==z||e[18]!==W?(U=[z,W,F].filter(Boolean),e[16]=F,e[17]=z,e[18]=W,e[19]=U):U=e[19];const H=U.join(" · ");let K;e[20]!==R||e[21]!==N?(K=de=>{N&&R(()=>N(de))},e[20]=R,e[21]=N,e[22]=K):K=e[22];const q=K;let Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(jj,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"ml-0.5 shrink-0 rounded-full text-muted-foreground","aria-label":"Session controls",title:"Session controls"}),children:r.jsx(Kc,{})}),e[23]=Y):Y=e[23];let G;e[24]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(Tj,{children:"Session controls"}),e[24]=G):G=e[24];let J;e[25]!==H?(J=r.jsx(Ej,{className:"truncate text-xs",children:H}),e[25]=H,e[26]=J):J=e[26];let Q;e[27]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(Sj,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:r.jsx(ct,{})}),e[27]=Q):Q=e[27];let X;e[28]!==J?(X=r.jsxs(_j,{className:"gap-1 px-4 pb-3 pt-4",children:[G,J,Q]}),e[28]=J,e[29]=X):X=e[29];let Z;e[30]!==o||e[31]!==R||e[32]!==q||e[33]!==m||e[34]!==g||e[35]!==h||e[36]!==d||e[37]!==i||e[38]!==p||e[39]!==x||e[40]!==f||e[41]!==C||e[42]!==O||e[43]!==u||e[44]!==a||e[45]!==j?(Z=r.jsx(Pj,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:f,modelOptions:d,selectedEffort:u,onEffortChange:p,effortOptions:m,ultracodeEnabled:j,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:O,onPermissionModeChange:q,changeAndApply:R}),e[30]=o,e[31]=R,e[32]=q,e[33]=m,e[34]=g,e[35]=h,e[36]=d,e[37]=i,e[38]=p,e[39]=x,e[40]=f,e[41]=C,e[42]=O,e[43]=u,e[44]=a,e[45]=j,e[46]=Z):Z=e[46];let se;e[47]!==o||e[48]!==R||e[49]!==b||e[50]!==T||e[51]!==_||e[52]!==I||e[53]!==E||e[54]!==P||e[55]!==S||e[56]!==v||e[57]!==A||e[58]!==j||e[59]!==w?(se=r.jsx(Ij,{agentKind:o,isNewSession:b,worktreeEnabled:w,onWorktreeEnabledChange:v,ultracodeEnabled:j,onUltracodeEnabledChange:S,mcpServers:_,selectedMcpServers:A,onToggleMcpServer:P,onRefreshMcpServers:E,mcpLoading:T,onMcpAuth:I,changeAndApply:R}),e[47]=o,e[48]=R,e[49]=b,e[50]=T,e[51]=_,e[52]=I,e[53]=E,e[54]=P,e[55]=S,e[56]=v,e[57]=A,e[58]=j,e[59]=w,e[60]=se):se=e[60];let ne;e[61]!==$?(ne=$&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(Rt,{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:$})]}),e[61]=$,e[62]=ne):ne=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]!==Z||e[67]!==se||e[68]!==ne||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:[Z,se,ne,re]}),e[66]=Z,e[67]=se,e[68]=ne,e[69]=re,e[70]=ie):ie=e[70];let ae;e[71]!==X||e[72]!==ie?(ae=r.jsxs(Cj,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[X,ie]}),e[71]=X,e[72]=ie,e[73]=ae):ae=e[73];let te;return e[74]!==s||e[75]!==t||e[76]!==ae?(te=r.jsx(r.Fragment,{children:r.jsxs(wj,{open:t,onOpenChange:s,children:[Y,ae]})}),e[74]=s,e[75]=t,e[76]=ae,e[77]=te):te=e[77],te}const $j=y.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:v,onToggleMcpServer:j,onRefreshMcpServers:S,mcpLoading:k,onMcpAuth:C,permissionMode:N,onPermissionModeChange:_,mobileExtra:A,trailingExtra:P,mobile:E}=e,T=s===void 0?qs:s,I=E===void 0?!1:E,[$,R]=y.useState(!1);let M;t[0]!==u||t[1]!==x?(M=te=>{te(),!u&&x&&setTimeout(()=>x(),0)},t[0]=u,t[1]=x,t[2]=M):M=t[2];const D=M;let O;t[3]!==D||t[4]!==a?(O=te=>D(()=>a(te)),t[3]=D,t[4]=a,t[5]=O):O=t[5];const L=O;let F;t[6]!==D||t[7]!==c?(F=te=>D(()=>c(te)),t[6]=D,t[7]=c,t[8]=F):F=t[8];const z=F,W=vg(T),U=(b==null?void 0:b.toLowerCase().startsWith("gpt-"))??!1,K=b&&(T==="copilot"||U===(T==="codex"))?b:void 0;let q,Y;t[9]!==W||t[10]!==K?(q=K?nd(K,W):Jw(W),Y=W.map(te=>{const ue=[te.description,te.availabilityMessage].filter(Boolean).join(" · ")||void 0;return te.value===""?{...te,description:ue,label:q,menuLabel:te.label}:{...te,description:ue}}),t[9]=W,t[10]=K,t[11]=q,t[12]=Y):(q=t[11],Y=t[12]);const G=Y;let J;t[13]!==T||t[14]!==i?(J=lg(T,i),t[13]=T,t[14]=i,t[15]=J):J=t[15];const Q=J;let X;t[16]!==T||t[17]!==i?(X=cg(T,i),t[16]=T,t[17]=i,t[18]=X):X=t[18];const Z=X;let se;t[19]!==T||t[20]!==i?(se=z3(T,i),t[19]=T,t[20]=i,t[21]=se):se=t[21];const ne=se;let re;t[22]!==T||t[23]!==ne||t[24]!==D||t[25]!==Q||t[26]!==d||t[27]!==Z||t[28]!==z||t[29]!==L||t[30]!==u||t[31]!==k||t[32]!==w||t[33]!==G||t[34]!==o||t[35]!==f||t[36]!==C||t[37]!==_||t[38]!==S||t[39]!==j||t[40]!==g||t[41]!==p||t[42]!==N||t[43]!==q||t[44]!==l||t[45]!==v||t[46]!==i||t[47]!==h||t[48]!==m?(re={agentKind:T,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:q,modelOptions:G,onModelChange:L,selectedEffort:l,effortOptions:Q,onEffortChange:z,fastTier:Z,fastModeEnabled:d,onFastModeEnabledChange:f,isNewSession:u,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:ne,permissionMode:N,onPermissionModeChange:_,mcpServers:w,selectedMcpServers:v,onToggleMcpServer:j,onRefreshMcpServers:S,mcpLoading:k,onMcpAuth:C,changeAndApply:D},t[22]=T,t[23]=ne,t[24]=D,t[25]=Q,t[26]=d,t[27]=Z,t[28]=z,t[29]=L,t[30]=u,t[31]=k,t[32]=w,t[33]=G,t[34]=o,t[35]=f,t[36]=C,t[37]=_,t[38]=S,t[39]=j,t[40]=g,t[41]=p,t[42]=N,t[43]=q,t[44]=l,t[45]=v,t[46]=i,t[47]=h,t[48]=m,t[49]=re):re=t[49];const ie=re;if(I){let te;return t[50]!==W||t[51]!==ie||t[52]!==A||t[53]!==$?(te=r.jsx(Rj,{...ie,open:$,onOpenChange:R,catalogOptions:W,mobileExtra:A}),t[50]=W,t[51]=ie,t[52]=A,t[53]=$,t[54]=te):te=t[54],te}let ae;return t[55]!==ie||t[56]!==P?(ae=r.jsx(ij,{...ie,trailingExtra:P}),t[55]=ie,t[56]=P,t[57]=ae):ae=t[57],ae});function _g(n){return n.agentType==="team-lead"}function Mj(n){return _g(n)?void 0:n.color}const Oj={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function Dj(n){return n?Oj[n]??"bg-zinc-400":"bg-zinc-400"}const Lj=y.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(Xn,{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(Rt,{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=Dj(Mj(g));return r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:V("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:V("inline-flex size-1.5 shrink-0 rounded-full",w)}),r.jsx("span",{children:g.name}),_g(g)&&r.jsx(zv,{"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 Tg(n){const e=B.c(3),t=y.useRef(null),[s,o]=y.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]),y.useEffect(i,a),s}const Eg=y.createContext(null),Ag=y.createContext(null);function Ti(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(Ag.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(Eg.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function it(){const n=y.useContext(Eg);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function Rr(){const n=y.useContext(Ag);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const zj=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=Oh,s="span",o=Mh({className:V(zj({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 Df=1,Fj=.9,Bj=.8,Uj=.17,ll=.1,cl=.999,Wj=.9999,Hj=.99,Kj=/[\\\/_+.#"@\[\(\{&]/,qj=/[\\\/_+.#"@\[\(\{&]/g,Vj=/[\s-]/,Pg=/[\s-]/g;function ac(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?Df:Hj;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=ac(n,e,t,s,d+1,i+1,a),u>f&&(d===o?u*=Df:Kj.test(n.charAt(d-1))?(u*=Bj,p=n.slice(o,d-1).match(qj),p&&o>0&&(u*=Math.pow(cl,p.length))):Vj.test(n.charAt(d-1))?(u*=Fj,h=n.slice(o,d-1).match(Pg),h&&o>0&&(u*=Math.pow(cl,h.length))):(u*=Uj,o>0&&(u*=Math.pow(cl,d-o))),n.charAt(d)!==e.charAt(i)&&(u*=Wj)),(u<ll&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=ac(n,e,t,s,d+1,i+2,a),m*ll>u&&(u=m*ll)),u>f&&(f=u),d=t.indexOf(c,d+1);return a[l]=f,f}function Lf(n){return n.toLowerCase().replace(Pg," ")}function Gj(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,ac(n,e,Lf(n),Lf(e),0,0,{})}var $o='[cmdk-group=""]',dl='[cmdk-group-items=""]',Yj='[cmdk-group-heading=""]',Ig='[cmdk-item=""]',zf=`${Ig}:not([aria-disabled="true"])`,lc="cmdk-item-select",ao="data-value",Xj=(n,e,t)=>Gj(n,e,t),Rg=y.createContext(void 0),$r=()=>y.useContext(Rg),$g=y.createContext(void 0),sd=()=>y.useContext($g),Mg=y.createContext(void 0),Og=y.forwardRef((n,e)=>{let t=lo(()=>{var z,W;return{search:"",value:(W=(z=n.value)!=null?z:n.defaultValue)!=null?W:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=lo(()=>new Set),o=lo(()=>new Map),i=lo(()=>new Map),a=lo(()=>new Set),l=Dg(n),{label:c,children:d,value:f,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,w=mo(),v=mo(),j=mo(),S=y.useRef(null),k=aS();zs(()=>{if(f!==void 0){let z=f.trim();t.current.value=z,C.emit()}},[f]),zs(()=>{k(6,T)},[]);let C=y.useMemo(()=>({subscribe:z=>(a.current.add(z),()=>a.current.delete(z)),snapshot:()=>t.current,setState:(z,W,U)=>{var H,K,q,Y;if(!Object.is(t.current[z],W)){if(t.current[z]=W,z==="search")E(),A(),k(1,P);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(j);G?G.focus():(H=document.getElementById(w))==null||H.focus()}if(k(7,()=>{var G;t.current.selectedItemId=(G=I())==null?void 0:G.id,C.emit()}),U||k(5,T),((K=l.current)==null?void 0:K.value)!==void 0){let G=W??"";(Y=(q=l.current).onValueChange)==null||Y.call(q,G);return}}C.emit()}},emit:()=>{a.current.forEach(z=>z())}}),[]),N=y.useMemo(()=>({value:(z,W,U)=>{var H;W!==((H=i.current.get(z))==null?void 0:H.value)&&(i.current.set(z,{value:W,keywords:U}),t.current.filtered.items.set(z,_(W,U)),k(2,()=>{A(),C.emit()}))},item:(z,W)=>(s.current.add(z),W&&(o.current.has(W)?o.current.get(W).add(z):o.current.set(W,new Set([z]))),k(3,()=>{E(),A(),t.current.value||P(),C.emit()}),()=>{i.current.delete(z),s.current.delete(z),t.current.filtered.items.delete(z);let U=I();k(4,()=>{E(),(U==null?void 0:U.getAttribute("id"))===z&&P(),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:v,listInnerRef:S}),[]);function _(z,W){var U,H;let K=(H=(U=l.current)==null?void 0:U.filter)!=null?H:Xj;return z?K(z,t.current.search,W):0}function A(){if(!t.current.search||l.current.shouldFilter===!1)return;let z=t.current.filtered.items,W=[];t.current.filtered.groups.forEach(H=>{let K=o.current.get(H),q=0;K.forEach(Y=>{let G=z.get(Y);q=Math.max(G,q)}),W.push([H,q])});let U=S.current;$().sort((H,K)=>{var q,Y;let G=H.getAttribute("id"),J=K.getAttribute("id");return((q=z.get(J))!=null?q:0)-((Y=z.get(G))!=null?Y:0)}).forEach(H=>{let K=H.closest(dl);K?K.appendChild(H.parentElement===K?H:H.closest(`${dl} > *`)):U.appendChild(H.parentElement===U?H:H.closest(`${dl} > *`))}),W.sort((H,K)=>K[1]-H[1]).forEach(H=>{var K;let q=(K=S.current)==null?void 0:K.querySelector(`${$o}[${ao}="${encodeURIComponent(H[0])}"]`);q==null||q.parentElement.appendChild(q)})}function P(){let z=$().find(U=>U.getAttribute("aria-disabled")!=="true"),W=z==null?void 0:z.getAttribute(ao);C.setState("value",W||void 0)}function E(){var z,W,U,H;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let K=0;for(let q of s.current){let Y=(W=(z=i.current.get(q))==null?void 0:z.value)!=null?W:"",G=(H=(U=i.current.get(q))==null?void 0:U.keywords)!=null?H:[],J=_(Y,G);t.current.filtered.items.set(q,J),J>0&&K++}for(let[q,Y]of o.current)for(let G of Y)if(t.current.filtered.items.get(G)>0){t.current.filtered.groups.add(q);break}t.current.filtered.count=K}function T(){var z,W,U;let H=I();H&&(((z=H.parentElement)==null?void 0:z.firstChild)===H&&((U=(W=H.closest($o))==null?void 0:W.querySelector(Yj))==null||U.scrollIntoView({block:"nearest"})),H.scrollIntoView({block:"nearest"}))}function I(){var z;return(z=S.current)==null?void 0:z.querySelector(`${Ig}[aria-selected="true"]`)}function $(){var z;return Array.from(((z=S.current)==null?void 0:z.querySelectorAll(zf))||[])}function R(z){let W=$()[z];W&&C.setState("value",W.getAttribute(ao))}function M(z){var W;let U=I(),H=$(),K=H.findIndex(Y=>Y===U),q=H[K+z];(W=l.current)!=null&&W.loop&&(q=K+z<0?H[H.length-1]:K+z===H.length?H[0]:H[K+z]),q&&C.setState("value",q.getAttribute(ao))}function D(z){let W=I(),U=W==null?void 0:W.closest($o),H;for(;U&&!H;)U=z>0?rS(U,$o):iS(U,$o),H=U==null?void 0:U.querySelector(zf);H?C.setState("value",H.getAttribute(ao)):M(z)}let O=()=>R($().length-1),L=z=>{z.preventDefault(),z.metaKey?O():z.altKey?D(1):M(1)},F=z=>{z.preventDefault(),z.metaKey?R(0):z.altKey?D(-1):M(-1)};return y.createElement(ws.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:z=>{var W;(W=b.onKeyDown)==null||W.call(b,z);let U=z.nativeEvent.isComposing||z.keyCode===229;if(!(z.defaultPrevented||U))switch(z.key){case"n":case"j":{x&&z.ctrlKey&&L(z);break}case"ArrowDown":{L(z);break}case"p":case"k":{x&&z.ctrlKey&&F(z);break}case"ArrowUp":{F(z);break}case"Home":{z.preventDefault(),R(0);break}case"End":{z.preventDefault(),O();break}case"Enter":{z.preventDefault();let H=I();if(H){let K=new Event(lc);H.dispatchEvent(K)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:cS},c),ja(n,z=>y.createElement($g.Provider,{value:C},y.createElement(Rg.Provider,{value:N},z))))}),Jj=y.forwardRef((n,e)=>{var t,s;let o=mo(),i=y.useRef(null),a=y.useContext(Mg),l=$r(),c=Dg(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;zs(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let f=Lg(o,i,[n.value,n.children,i],n.keywords),u=sd(),m=bs(k=>k.value&&k.value===f.current),p=bs(k=>d||l.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);y.useEffect(()=>{let k=i.current;if(!(!k||n.disabled))return k.addEventListener(lc,h),()=>k.removeEventListener(lc,h)},[p,n.onSelect,n.disabled]);function h(){var k,C;g(),(C=(k=c.current).onSelect)==null||C.call(k,f.current)}function g(){u.setState("value",f.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:w,forceMount:v,keywords:j,...S}=n;return y.createElement(ws.div,{ref:or(i,e),...S,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)}),Qj=y.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=mo(),l=y.useRef(null),c=y.useRef(null),d=mo(),f=$r(),u=bs(p=>o||f.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);zs(()=>f.group(a),[]),Lg(a,l,[n.value,n.heading,c]);let m=y.useMemo(()=>({id:a,forceMount:o}),[o]);return y.createElement(ws.div,{ref:or(l,e),...i,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},t&&y.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),ja(n,p=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},y.createElement(Mg.Provider,{value:m},p))))}),Zj=y.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=y.useRef(null),i=bs(a=>!a.search);return!t&&!i?null:y.createElement(ws.div,{ref:or(o,e),...s,"cmdk-separator":"",role:"separator"})}),eS=y.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=sd(),a=bs(d=>d.search),l=bs(d=>d.selectedItemId),c=$r();return y.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),y.createElement(ws.input,{ref:e,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:o?n.value:a,onChange:d=>{o||i.setState("search",d.target.value),t==null||t(d.target.value)}})}),tS=y.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=y.useRef(null),a=y.useRef(null),l=bs(d=>d.selectedItemId),c=$r();return y.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)}}},[]),y.createElement(ws.div,{ref:or(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},ja(n,d=>y.createElement("div",{ref:or(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),nS=y.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return y.createElement(Fv,{open:t,onOpenChange:s},y.createElement(Bv,{container:a},y.createElement(Uv,{"cmdk-overlay":"",className:o}),y.createElement(Wv,{"aria-label":n.label,"cmdk-dialog":"",className:i},y.createElement(Og,{ref:e,...l}))))}),sS=y.forwardRef((n,e)=>bs(t=>t.filtered.count===0)?y.createElement(ws.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),oS=y.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return y.createElement(ws.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ja(n,a=>y.createElement("div",{"aria-hidden":!0},a)))}),Eo=Object.assign(Og,{List:tS,Item:Jj,Input:eS,Group:Qj,Separator:Zj,Dialog:nS,Empty:sS,Loading:oS});function rS(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function iS(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Dg(n){let e=y.useRef(n);return zs(()=>{e.current=n}),e}var zs=typeof window>"u"?y.useEffect:y.useLayoutEffect;function lo(n){let e=y.useRef();return e.current===void 0&&(e.current=n()),e}function bs(n){let e=sd(),t=()=>n(e.snapshot());return y.useSyncExternalStore(e.subscribe,t,t)}function Lg(n,e,t,s=[]){let o=y.useRef(),i=$r();return zs(()=>{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(ao,l),o.current=l}),o}var aS=()=>{let[n,e]=y.useState(),t=lo(()=>new Map);return zs(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function lS(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function ja({asChild:n,children:e},t){return n&&y.isValidElement(e)?y.cloneElement(lS(e),{ref:e.ref},t(e.props.children)):t(e)}var cS={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($h,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function dS(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(Wc,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}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=V("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(Hc,{"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(uS,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=V("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(oa,{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(ct,{"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(dS,{children:[l,r.jsxs(Uc,{"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 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=V("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 zg(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=V("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=V("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(Fc,{"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=V("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(Bc,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Fg(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=V("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zD(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=V("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(Ss,{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 FD(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(dn,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=o):o=e[3];let i;e[4]!==t?(i=V("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==i?(a=r.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[o,r.jsx(Eo.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function Bg(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=V("no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none transition-[height] duration-100 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function BD(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=V("py-6 text-center text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-100 motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ug(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=V("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wg(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=V("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(mt,{className:"ml-auto scale-75 opacity-0 transition-[opacity,transform,scale] duration-100 ease-out group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:scale-100 group-data-[checked=true]/command-item:opacity-100 motion-reduce:transition-none"}),e[6]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(Eo.Item,{"data-slot":"command-item",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function fS(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=V("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 mS(n){return r.jsx(Ee,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const pS=y.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=y.useRef(f);let m,p;if(t[1]!==a?(m=()=>{var P;const A=u.current.get(a);A&&((P=A.scrollIntoView)==null||P.call(A,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),y.useEffect(m,p),i){let A;return t[4]===Symbol.for("react.memo_cache_sentinel")?(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.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]=A):A=t[4],A}if(s.length===0){const A=o?`No commands or skills matching "${o}"`:"No commands or skills found";let P;return t[5]!==A?(P=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:A})})}),t[5]=A,t[6]=P):P=t[6],P}let h,g,x,b,w,v,j,S,k;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const A=s.filter(gS),P=[{heading:"Commands",suggestions:A,offset:0},{heading:"Skills",suggestions:s.filter(xS),offset:A.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Fg,w="slash-suggestions",v=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(j=E=>{const T=s.findIndex(I=>`${I.type}-${I.name}`===E);T>=0&&c(T)},t[21]=c,t[22]=s,t[23]=j):j=t[23],S=!1,k="border shadow-sm",h=Bg,b=P.map(E=>E.suggestions.length>0&&r.jsx(Ug,{heading:E.heading,children:E.suggestions.map((T,I)=>{const $=E.offset+I;return r.jsx(hS,{suggestion:T,index:$,isSelected:$===a,onSelect:l,onHover:c,onEdit:d,itemRefs:u},`${T.type}-${T.name}`)})},E.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]=v,t[18]=j,t[19]=S,t[20]=k}else h=t[12],g=t[13],x=t[14],b=t[15],w=t[16],v=t[17],j=t[18],S=t[19],k=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 N;t[27]!==g||t[28]!==C||t[29]!==w||t[30]!==v||t[31]!==j||t[32]!==S||t[33]!==k?(N=r.jsx(g,{id:w,value:v,onValueChange:j,shouldFilter:S,className:k,children:C}),t[27]=g,t[28]=C,t[29]=w,t[30]=v,t[31]=j,t[32]=S,t[33]=k,t[34]=N):N=t[34];let _;return t[35]!==x||t[36]!==N?(_=r.jsx("div",{className:x,children:N}),t[35]=x,t[36]=N,t[37]=_):_=t[37],_});function hS({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=y.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(Wg,{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(xo,{className:"size-4 text-muted-foreground"}):r.jsx(Dh,{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]}),mS(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(fS,{className:i&&n.filePath?"mr-6":void 0,children:"Enter"})]}),i&&n.filePath&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1.5 top-1/2 -translate-y-1/2 opacity-0 transition-opacity group-hover/suggestion:opacity-100 focus-visible:opacity-100",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),i(n.filePath)},"aria-label":`Edit ${n.name}`,children:r.jsx(Ws,{"data-icon":"inline-start"})})]})}function gS(n){return n.type==="command"}function xS(n){return n.type==="skill"}function bS(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=y.useRef(c);let f,u;e[1]!==i?(f=()=>{var v,j;(j=(v=d.current.get(i))==null?void 0:v.scrollIntoView)==null||j.call(v,{block:"nearest"})},u=[i],e[1]=i,e[2]=f,e[3]=u):(f=e[2],u=e[3]),y.useEffect(f,u);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=v=>{const j=t.indexOf(v);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((v,j)=>r.jsxs(Wg,{ref:S=>{S?(S.id=`file-suggestion-${j}`,d.current.set(j,S)):d.current.delete(j)},value:v,onMouseEnter:()=>l(j),onSelect:()=>a(v),onMouseDown:vS,children:[r.jsx(Lh,{"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:v}),j===i&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},v)),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(Bg,{className:"max-h-70",children:r.jsx(Ug,{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(Fg,{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 vS(n){return n.preventDefault()}const yS=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=V(yS({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=V("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 Nt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=V("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 vs(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=V("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 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(Kv,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function Wt(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":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function ft(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=V("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(Hv,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const wS={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function Ff(n){return wS[n]??n.replaceAll("_"," ")}function jS(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,v,j;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const P=i===void 0?[]:i;p=l===void 0?!1:l;const E=a??P[0],T=P.filter(R=>R!==E);m=St,b="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(ra,{}),v=r.jsx(It,{children:"Plan ready for review"}),e[15]=w,e[16]=v):(w=e[15],v=e[16]);const I=s||"Approve the plan or ask the agent to revise it.";e[17]!==I?(j=r.jsx(Nt,{children:I}),e[17]=I,e[18]=j):j=e[18],u=vs,h="flex gap-2";let $;e[19]!==p?($=p&&r.jsx(rt,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=$):$=e[20],g=r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>d(E),children:[$,p?"Sending...":E?Ff(E):"Approve"]}),x=T.length>0&&r.jsxs(Dn,{children:[r.jsx(Ln,{render:r.jsx(ee,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(nt,{"data-icon":"icon"})}),r.jsx(zn,{align:"end",children:r.jsx(Qt,{children:T.map(R=>r.jsx(kt,{onClick:()=>d(R),children:Ff(R)},R))})})]}),e[0]=d,e[1]=a,e[2]=s,e[3]=i,e[4]=l,e[5]=u,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=b,e[12]=w,e[13]=v,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],v=e[13],j=e[14];let S;e[21]!==f||e[22]!==p?(S=r.jsx(ee,{variant:"ghost",size:"sm",disabled:p,onClick:f,children:"Reject"}),e[21]=f,e[22]=p,e[23]=S):S=e[23];let k;e[24]!==u||e[25]!==S||e[26]!==h||e[27]!==g||e[28]!==x?(k=r.jsxs(u,{className:h,children:[g,x,S]}),e[24]=u,e[25]=S,e[26]=h,e[27]=g,e[28]=x,e[29]=k):k=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 N;e[32]!==o?(N=o&&r.jsxs(ut,{className:"col-span-full mt-2",children:[r.jsx(Wt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(ft,{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]=N):N=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 A;return e[36]!==m||e[37]!==k||e[38]!==C||e[39]!==N||e[40]!==_||e[41]!==b||e[42]!==w||e[43]!==v||e[44]!==j?(A=r.jsxs(m,{className:b,children:[w,v,j,k,C,N,_]}),e[36]=m,e[37]=k,e[38]=C,e[39]=N,e[40]=_,e[41]=b,e[42]=w,e[43]=v,e[44]=j,e[45]=A):A=e[45],A}function SS(n,e){return r.jsx(Ee,{variant:"outline",children:n.prompt},e)}const NS=["allow","allow_always","deny"];function ci(n,e){return(n.availableDecisions??NS).includes(e)}function kS(n){switch(n){case"Bash":return{label:"Run command",icon:xo,tone:"cmd"};case"Edit":return{label:"Edit file",icon:ec,tone:"write"};case"Write":return{label:"Write file",icon:ec,tone:"write"};case"Read":return{label:"Read file",icon:Co,tone:"read"};case"Glob":return{label:"File search",icon:dn,tone:"search"};case"Grep":return{label:"Content search",icon:dn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:Zl,tone:"net"};case"WebSearch":return{label:"Web search",icon:Zl,tone:"net"};default:return{label:n,icon:ia,tone:"other"}}}function CS(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 _S({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?ci(o,"allow"):!1,l=o?ci(o,"allow_always"):!1,c=o?ci(o,"deny"):!1,d=i>1&&n.every(v=>ci(v,"allow")),f=y.useEffectEvent(v=>{if(!o)return;const j=v.target;if(j&&(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable)||v.metaKey||v.ctrlKey||v.altKey)return;const S=v.key.toLowerCase();S==="a"&&v.shiftKey&&d?(v.preventDefault(),s("allow")):S==="a"&&a?(v.preventDefault(),t(o.requestId,"allow")):S==="s"&&l?(v.preventDefault(),t(o.requestId,"allow_always")):S==="d"&&c&&(v.preventDefault(),t(o.requestId,"deny"))});y.useEffect(()=>{const v=j=>f(j);return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]);const u=o?kS(o.toolName):null,m=o?CS(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(Rh,{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(ee,{variant:"ghost",size:"sm",className:"text-destructive",disabled:x,onClick:()=>t(o.requestId,"deny"),title:"Deny (D)",children:[r.jsx(ct,{"data-icon":"inline-start"}),"Deny",r.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]}),l&&r.jsxs(ee,{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(Vv,{"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(ee,{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(ee,{size:"sm",disabled:x,onClick:()=>t(o.requestId,"allow"),title:"Allow once (A)",children:[r.jsx(mt,{"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 TS=1568,ES=.85,Bf=35e5;function AS(n,e){let{width:t,height:s}=n;const o=Math.min(1,TS/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?ES:void 0),f=d.split(",")[1];if(f.length>Bf){let u=l?.7:.8;for(;f.length>Bf&&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 PS(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]=y.useState(s),[a,l]=y.useState(!1),[c,d]=y.useState(!1),f=y.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]),y.useEffect(u,m);let p;e[4]!==t?(p=R=>{const M=Array.from(R).filter($S);if(!t){M.length>0&&d(!0);return}d(!1);for(const D of M){const O=new FileReader;O.onload=()=>{if(!f.current){d(!0);return}const L=O.result,F=new Image;F.onload=()=>{if(!f.current){d(!0);return}const z=AS(F,D.type);i(W=>[...W,{id:crypto.randomUUID(),file:D,preview:z.dataUrl,data:z.base64,mediaType:z.mediaType}])},F.src=L},O.onerror=()=>{console.warn(`Failed to read image file: ${D.name}`)},O.readAsDataURL(D)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=R=>{i(M=>M.filter((D,O)=>O!==R)),d(!1)},e[6]=g):g=e[6];const x=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{i([]),d(!1)},e[7]=b):b=e[7];const w=b;let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>d(!1),e[8]=v):v=e[8];const j=v;let S;e[9]!==t?(S=R=>{R.preventDefault(),t&&l(!0)},e[9]=t,e[10]=S):S=e[10];const k=S;let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{R.preventDefault(),R.currentTarget.contains(R.relatedTarget)||l(!1)},e[11]=C):C=e[11];const N=C;let _;e[12]!==h?(_=R=>{R.preventDefault(),l(!1),R.dataTransfer.files.length>0&&h(R.dataTransfer.files)},e[12]=h,e[13]=_):_=e[13];const A=_;let P;e[14]!==h?(P=R=>{var L;const M=(L=R.clipboardData)==null?void 0:L.items;if(!M)return;const D=Array.from(M).filter(RS);if(D.length===0)return;R.preventDefault();const O=D.map(IS).filter(Boolean);h(O)},e[14]=h,e[15]=P):P=e[15];const E=P,T=!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,I=!t&&o.length>0;let $;return e[16]!==k||e[17]!==A||e[18]!==E||e[19]!==o||e[20]!==a||e[21]!==T||e[22]!==I?($={images:o,isDragOver:a,imageError:T,hasUnsupportedAttachments:I,dismissImageError:j,removeImage:x,clearImages:w,handleDragOver:k,handleDragLeave:N,handleDrop:A,handlePaste:E},e[16]=k,e[17]=A,e[18]=E,e[19]=o,e[20]=a,e[21]=T,e[22]=I,e[23]=$):$=e[23],$}function IS(n){return n.getAsFile()}function RS(n){return n.type.startsWith("image/")}function $S(n){return n.type.startsWith("image/")}function MS(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(Jv,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}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(MS,{children:r.jsx(Xv,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Et(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Gv,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function At(n){const e=B.c(20);let t,s,o,i,a,l,c;e[0]!==n?({className:s,side:i,sideOffset:a,align:l,alignOffset:c,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7]);const d=i===void 0?"top":i,f=a===void 0?4:a,u=l===void 0?"center":l,m=c===void 0?0:c;let p;e[8]!==s?(p=V("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(Yv,{"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(Qv,{children:r.jsx(Zv,{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 In="rounded-full border bg-background/80 shadow-sm backdrop-blur",Sa=y.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=V("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}),ul=y.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(ee,{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(Et,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(At,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(Tt,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function OS(n){return n<10?"critical":n<30?"warning":"healthy"}const DS={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Hg=y.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,v,j,S,k;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const A=Sg(s);if(!A){x=null;break e}const P=Math.max(0,100-A.percent),E=OS(P);if(d&&E==="healthy"){x=null;break e}const T=Math.max(0,A.compactAt-A.used);let I;t[17]!==P||t[18]!==T||t[19]!==l?(I=l?`${P.toFixed(0)}% · ${tt(T)}`:`${P.toFixed(0)}%`,t[17]=P,t[18]=T,t[19]=l,t[20]=I):I=t[20];const $=I,R=DS[E],M=l&&"gap-1";let D;t[21]!==R||t[22]!==M?(D=V("shrink-0 tabular-nums",R,M),t[21]=R,t[22]=M,t[23]=D):D=t[23];let O;t[24]!==$||t[25]!==D?(O=r.jsx(Ee,{variant:"outline",className:D,children:$}),t[24]=$,t[25]=D,t[26]=O):O=t[26];const L=O;if(!c){x=L;break e}u=Tt,t[27]!==L?(g=r.jsx(Et,{render:L}),t[27]=L,t[28]=g):g=t[28],f=At,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let F;t[30]!==T?(F=tt(T),t[30]=T,t[31]=F):F=t[31];let z;t[32]!==P?(z=P.toFixed(1),t[32]=P,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(A.used),v=" / ",j=tt(A.limit),S=" tokens used (",k=A.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]=v,t[14]=j,t[15]=S,t[16]=k}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],v=t[13],j=t[14],S=t[15],k=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==b||t[38]!==w||t[39]!==v||t[40]!==j||t[41]!==S||t[42]!==k?(C=r.jsxs("div",{className:b,children:[w,v,j,S,k,"%)"]}),t[37]=b,t[38]=w,t[39]=v,t[40]=j,t[41]=S,t[42]=k,t[43]=C):C=t[43];let N;t[44]!==f||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==C?(N=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]=N):N=t[49];let _;return t[50]!==u||t[51]!==g||t[52]!==N?(_=r.jsxs(u,{children:[g,N]}),t[50]=u,t[51]=g,t[52]=N,t[53]=_):_=t[53],_});function LS(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=it(),{chat:a}=Rr(),{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:Dw(o)}),r.jsx(Sa,{})]}),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 zS(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}=Rr(),{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=Vw(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(Tt,{children:[r.jsx(Et,{render:r.jsx(ee,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:r.jsx(qc,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(At,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=w):w=e[8];let v;e[9]!==g||e[10]!==d||e[11]!==p?(v=p&&Ht(g).stopSession&&r.jsxs(Tt,{children:[r.jsx(Et,{render:r.jsx(ee,{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(ey,{"data-icon":"inline-start"})}),r.jsx(At,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=v):v=e[12];const j=t?"default":"secondary",S=!t&&"text-muted-foreground";let k;e[13]!==S?(k=V("shrink-0 rounded-full",S),e[13]=S,e[14]=k):k=e[14];const C=!t;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(ty,{"data-icon":"inline-start"}),e[15]=N):N=e[15];let _;e[16]!==s||e[17]!==i||e[18]!==k||e[19]!==C||e[20]!==j?(_=r.jsx(ee,{variant:j,size:"icon-sm",className:k,disabled:C,onClick:s,"aria-label":i,title:i,children:N}),e[16]=s,e[17]=i,e[18]=k,e[19]=C,e[20]=j,e[21]=_):_=e[21];let A;return e[22]!==_||e[23]!==w||e[24]!==v?(A=r.jsxs("div",{className:"flex items-center gap-1",children:[w,v,_]}),e[22]=_,e[23]=w,e[24]=v,e[25]=A):A=e[25],A}function Uf(n){const e=B.c(34),{error:t}=n,[s,o]=y.useState(!1),[i,a]=y.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(sn,{"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(ee,{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(Ss,{children:[r.jsxs(Zn,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(sn,{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 v;e[17]!==t?(v=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]=v):v=e[18];let j;e[19]!==i?(j=i?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(Cn,{"data-icon":"inline-start"}),e[19]=i,e[20]=j):j=e[20];const S=i?"Copied":"Copy";let k;e[21]!==m||e[22]!==j||e[23]!==S?(k=r.jsx("div",{className:"flex justify-end",children:r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,S]})}),e[21]=m,e[22]=j,e[23]=S,e[24]=k):k=e[24];let C;e[25]!==v||e[26]!==k?(C=r.jsxs(Qn,{className:"max-w-2xl",children:[w,v,k]}),e[25]=v,e[26]=k,e[27]=C):C=e[27];let N;e[28]!==s||e[29]!==C?(N=r.jsx(Jn,{open:s,onOpenChange:o,children:C}),e[28]=s,e[29]=C,e[30]=N):N=e[30];let _;return e[31]!==N||e[32]!==b?(_=r.jsxs(r.Fragment,{children:[b,N]}),e[31]=N,e[32]=b,e[33]=_):_=e[33],_}function FS(n){const e=B.c(17),{suggestion:t,onAccept:s}=n,[o,i]=y.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(Dh,{"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(ee,{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(ct,{}),e[11]=u):u=e[11];let m;e[12]!==f?(m=r.jsx(ee,{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 BS(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 US(n,e,t){return`${n.slice(0,e.start)}@${t} `}const Na={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Mr={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let Kg=Na;const cc=new Set;function fo(n){Kg=(n==null?void 0:n.capabilities)??Na;for(const e of cc)e()}function lt(n){return Kg[n]}function WS(n){return cc.add(n),()=>cc.delete(n)}function Sn(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]),y.useSyncExternalStore(WS,t,s)}function HS(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function KS(n,e,t){const s=Sn("hostFiles"),[o,i]=y.useState([]),[a,l]=y.useState(!1);return y.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(HS(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 dc="cogpit-share-revoked";function qS(){window.dispatchEvent(new Event(dc))}async function qg(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&&qS(),s}function Or(n,e){return qg(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function VS(){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 GS(n,e){return Or("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function YS(){return Or("/api/share/interrupt")}function XS(){return Or("/api/share/stop")}async function JS(n,e){return(await Or("/api/share/permission",{requestId:n,behavior:e})).ok}async function QS(n,e){try{const t=await Or("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function ZS(){try{const n=await qg("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const e4=/^\/shared\/([^/]+)\/?$/;function Vg(n){const e=e4.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function ka(n){return Vg(n)!==null}function t4(n){return`/shared/${encodeURIComponent(n)}`}function UD(n){return[...n].join(", ")}async function od(n,e,t){if(ka(window.location.pathname))return QS(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 n4(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 Ca(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=V("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 di(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 s4(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 o4(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 uc=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,compact:i=!1},a){var Be;const l=Sn("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:v}=it(),{chat:{status:j,error:S,isConnected:k,sendMessage:C,interrupt:N}}=Rr(),_=k||d,[A,P]=y.useState(""),[E,T]=y.useState(!1),[I,$]=y.useState(!1),[R,M]=y.useState(null),D=y.useRef(null),O=y.useRef(null),L=y.useRef(!1),F=y.useRef(""),z=y.useRef(null);y.useEffect(()=>{F.current=A},[A]);const W=y.useCallback(oe=>{L.current=oe,T(oe)},[]),{images:U,isDragOver:H,imageError:K,hasUnsupportedAttachments:q,dismissImageError:Y,removeImage:G,clearImages:J,handleDragOver:Q,handleDragLeave:X,handleDrop:Z,handlePaste:se}=PS(e),[ne,re]=y.useState(0),[ie,ae]=y.useState(0),[te,ue]=y.useState(!1),le=A.startsWith("/")&&!A.includes(" "),de=le?A.slice(1):"",he=y.useMemo(()=>{if(!le)return[];const oe=de.toLowerCase(),pe=x.filter(He=>oe?He.name.toLowerCase().includes(oe)||He.description.toLowerCase().includes(oe):!0),Te=pe.filter(He=>He.type==="command"),$e=pe.filter(He=>He.type==="skill");return[...Te,...$e]},[le,de,x]),xe=y.useMemo(()=>BS(A),[A]),ce=!!(l&&xe&&s&&!te),be=KS(s,(xe==null?void 0:xe.query)??"",ce);y.useEffect(()=>{re(0)},[de]),y.useEffect(()=>{ae(0)},[xe==null?void 0:xe.query]);const ge=Tg(k),fe=(u==null?void 0:u.type)==="plan"?u.requestId??null:null;y.useEffect(()=>{O.current=fe,D.current=null,$(!1),M(null)},[fe]);const je=y.useCallback(async oe=>{const pe=u;if(!(c!=null&&c.sessionId)||(pe==null?void 0:pe.type)!=="question")return;const Te=pe.questions[0];if(!Te||!oe.trim())return;(await od(c.sessionId,pe.toolUseId,{[Te.question]:oe})).ok||C(oe)},[u,c==null?void 0:c.sessionId,C]),Se=y.useCallback(async(oe,pe,Te)=>{const $e=u;if(($e==null?void 0:$e.type)==="plan"&&$e.provider==="copilot"&&$e.requestId&&(c!=null&&c.sessionId)){const He=$e.requestId;if(D.current)return!1;D.current=He,$(!0),M(null);try{const Ke=await n4(c.sessionId,He,{approved:oe,...pe?{selectedAction:pe}:{},...Te?{feedback:Te}:{}});return!Ke&&O.current===He&&M("Couldn't send the plan response. Try again."),Ke}finally{D.current===He&&(D.current=null,$(!1))}}return C(oe?"yes":Te||"no"),!0},[u,c==null?void 0:c.sessionId,C]),Ae=y.useCallback(()=>{requestAnimationFrame(()=>{const oe=z.current;oe&&(oe.focus(),oe.selectionStart=oe.selectionEnd=oe.value.length,W(di(oe,L.current)))})},[W]),Ie=y.useCallback(oe=>{P(`/${oe.name} `),re(0),Ae()},[Ae]),Re=y.useCallback(oe=>{P(oe),Ae()},[Ae]),De=y.useCallback(oe=>{if(!xe)return;const pe=US(A,xe,oe);P(pe),ue(!0),ae(0),requestAnimationFrame(()=>{const Te=z.current;Te&&(Te.focus(),Te.selectionStart=Te.selectionEnd=Te.value.length,W(di(Te,L.current)))})},[xe,A,W]),Le=y.useCallback(async()=>{const oe=A.trim();if(!oe&&U.length===0||!e&&U.length>0)return;if((u==null?void 0:u.type)==="question"){je(oe),P(""),W(!1),z.current&&(z.current.style.height="auto");return}if((u==null?void 0:u.type)==="plan"&&u.provider==="copilot"){if(!oe||!await Se(!1,void 0,oe))return;P(""),W(!1),z.current&&(z.current.style.height="auto");return}const pe=e&&U.length>0?U.map(Te=>({data:Te.data,mediaType:Te.mediaType})):void 0;C(oe,pe),P(""),J(),W(!1),z.current&&(z.current.style.height="auto")},[A,U,e,C,J,W,u,je,Se]),ze=y.useCallback(oe=>{if(ce&&oe.key==="Escape"){oe.preventDefault(),ue(!0);return}if(ce&&be.files.length>0){if(oe.key==="ArrowDown"){oe.preventDefault(),ae(pe=>pe<be.files.length-1?pe+1:0);return}if(oe.key==="ArrowUp"){oe.preventDefault(),ae(pe=>pe>0?pe-1:be.files.length-1);return}if(oe.key==="Tab"||oe.key==="Enter"&&!oe.shiftKey){oe.preventDefault();const pe=be.files[ie];pe&&De(pe);return}}if(le&&he.length>0){if(oe.key==="ArrowDown"){oe.preventDefault(),re(pe=>pe<he.length-1?pe+1:0);return}if(oe.key==="ArrowUp"){oe.preventDefault(),re(pe=>pe>0?pe-1:he.length-1);return}if(oe.key==="Tab"||oe.key==="Enter"&&!oe.shiftKey){oe.preventDefault();const pe=he[ne];pe&&Ie(pe);return}if(oe.key==="Escape"){oe.preventDefault(),P("");return}}if(oe.key==="Escape"&&_&&N){oe.preventDefault(),N();return}oe.key==="Enter"&&!oe.shiftKey&&(oe.preventDefault(),Le())},[Le,_,N,ce,be.files,ie,De,le,he,ne,Ie]),_e=y.useCallback(oe=>{P(oe.target.value),ue(!1),W(di(oe.target,L.current))},[W]);y.useImperativeHandle(a,()=>({focus:()=>{var oe;return(oe=z.current)==null?void 0:oe.focus()},getText:()=>F.current,setText:oe=>{P(oe),ue(!1),requestAnimationFrame(()=>W(di(z.current,L.current)))}}),[W]);const Ce=(u==null?void 0:u.type)==="plan",We=(u==null?void 0:u.type)==="question",Fe=m.length>0,Ne=(A.trim().length>0||U.length>0)&&!q,me=Ht(t??qs).midTurnSteering&&_,Oe=ce?"file-suggestions":le?"slash-suggestions":void 0,Pe=ce&&be.files[ie]?`file-suggestion-${ie}`:le&&he[ne]?`slash-suggestion-${ne}`:void 0;return r.jsxs("div",{className:V("relative bg-background pb-0",i?"px-2 pt-2":"px-3 pt-2",H&&"ring-2 ring-info/40 ring-inset"),onDragOver:Q,onDragLeave:X,onDrop:Z,children:[H&&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"})}),le&&r.jsx(pS,{suggestions:he,filter:de,loading:b,selectedIndex:ne,onSelect:Ie,onHover:re,onEdit:f}),ce&&r.jsx(bS,{files:be.files,query:(xe==null?void 0:xe.query)??"",loading:be.loading,selectedIndex:ie,onSelect:De,onHover:ae}),r.jsxs("div",{children:[Ce&&r.jsx(jS,{allowedPrompts:u.allowedPrompts,summary:u.summary,planContent:u.planContent,actions:u.actions,recommendedAction:u.recommendedAction,responding:I,responseError:R,onApprove:oe=>{Se(!0,oe)},onReject:()=>{Se(!1)}}),r.jsx(FS,{suggestion:v,onAccept:Re}),U.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:U.map((oe,pe)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:oe.preview,alt:`Upload ${pe+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>G(pe),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 ${pe+1}`,children:r.jsx(ct,{className:"size-3","data-icon":"icon"})})]},oe.id))}),K&&r.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[r.jsx("span",{className:"flex-1",children:K}),!q&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Y,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(ct,{"data-icon":"icon"})})]}),r.jsxs("div",{className:V("relative overflow-hidden rounded-xl border bg-prompt-surface shadow-xs",o4(Ce,We,Fe),"focus-within:ring-3"),children:[Fe&&r.jsx(_S,{requests:m,responding:p,onRespond:h,onRespondAll:g},(Be=m[0])==null?void 0:Be.requestId),r.jsxs("div",{className:V("grid min-w-0 items-end",E?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]"),children:[o&&r.jsx("div",{className:V("flex shrink-0 items-center",E?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:o}),r.jsx(Ca,{ref:z,value:A,onChange:_e,onKeyDown:ze,onPaste:se,onFocus:()=>{setTimeout(()=>{var oe;return(oe=z.current)==null?void 0:oe.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:s4(Ce,We,k,Fe,me,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Oe,"aria-controls":Oe,"aria-activedescendant":Pe,rows:1,className:V("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",E?V("col-span-2 row-start-1",i?"py-2.5 pr-3":"py-3 pr-4"):V("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:V("flex shrink-0 items-center justify-end",E?"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(LS,{isPlanApproval:Ce,isUserQuestion:We,elapsedSec:ge}),r.jsx(zS,{hasContent:Ne,onSubmit:Le,submitLabel:me?"Steer active turn":"Send message"})]})]})]}),j==="error"&&S&&r.jsx(Uf,{error:S},S),w&&r.jsx(Uf,{error:w},w)]})]})}));function r4(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function i4(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=r4(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 ui(n){return`/api/codex/goals/${encodeURIComponent(n)}`}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=V("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(ny,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function rd(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=V("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(a4,{children:r.jsx(l4,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(sy,{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 a4(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=V("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(oy,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function l4(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=V("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(ry,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const c4={section:null,canCreate:!1,beginEditing:()=>{}},id=y.createContext(c4);function Gg(){return y.useContext(id)}const Yg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",Xg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function d4(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function u4(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function f4({agentKind:n,threadId:e,children:t}){const s=wa(n),[o,i]=y.useState(null),[a,l]=y.useState(!0),[c,d]=y.useState(!1),[f,u]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async A=>{try{const P=await ye(ui(e),{signal:A});if(P.status===404||P.status===501){l(!1);return}if(!P.ok)return;const E=await P.json();i(E.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const A=new AbortController;w(A.signal);const P=a?setInterval(()=>void w(),1e4):void 0;return()=>{A.abort(),P!==void 0&&clearInterval(P)}},[w,a]);const v=y.useCallback(()=>{var A;u((o==null?void 0:o.objective)??""),p(((A=o==null?void 0:o.tokenBudget)==null?void 0:A.toString())??""),b(null),d(!0)},[o]),j=async()=>{const A=f.trim();if(!A)return;const P=m.trim()?Number(m):null;if(P!==null&&(!Number.isSafeInteger(P)||P<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const E=await ye(ui(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:A,status:(o==null?void 0:o.status)==="complete"?"active":(o==null?void 0:o.status)??"active",tokenBudget:P})}),T=await E.json();if(!E.ok)throw new Error(T.error||"Could not save goal");i(T.goal),d(!1)}catch(E){b(E instanceof Error?E.message:"Could not save goal")}finally{g(!1)}},S=async A=>{if(o){g(!0);try{const P=await ye(ui(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})});P.ok&&i((await P.json()).goal)}finally{g(!1)}}},k=async()=>{g(!0);try{(await ye(ui(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 N=null;if(a&&c)N=r.jsxs("form",{className:Xg,onSubmit:A=>{A.preventDefault(),j()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(rr,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(To,{className:"gap-2",children:[r.jsxs(xt,{children:[r.jsx(bt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(Ca,{id:"goal-objective",value:f,onChange:A=>u(A.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),r.jsxs(xt,{orientation:"horizontal","data-invalid":!!x,children:[r.jsx(bt,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),r.jsx(Bt,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:A=>p(A.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(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(!1),children:[r.jsx(ct,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(ee,{type:"submit",size:"xs",disabled:h||!f.trim(),children:[r.jsx(mt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const A=o.status==="paused",P=o.status==="complete";N=r.jsxs("section",{className:Yg,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(rr,{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:u4(o.status),children:d4(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:[A&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx(kr,{"data-icon":"icon"})}),!A&&!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(iy,{"data-icon":"icon"})}),!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(mt,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:r.jsx(Ws,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(aa,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(rd,{className:"mt-1 mb-0.5",value:C,"aria-label":`${C.toFixed(0)}% of goal token budget used`})]})}const _=y.useMemo(()=>({section:N,canCreate:a&&!o&&!c,beginEditing:v}),[N,a,o,c,v]);return r.jsx(id.Provider,{value:_,children:t})}function m4(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function p4(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function h4(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=wa(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=i4(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const d=c,[f,u]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=d?`${d.status}\0${d.condition}`:"",[v,j]=y.useState(w);v!==w&&(j(w),u(void 0));const S=f!==void 0?f:d;let k;e[4]!==(S==null?void 0:S.condition)?(k=()=>{g((S==null?void 0:S.condition)??""),b(null),p(!0)},e[4]=S==null?void 0:S.condition,e[5]=k):k=e[5];const C=k;let N;e[6]!==h||e[7]!==o?(N=()=>{const M=h.trim();if(M){if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}u({condition:M,status:"active",iterations:0,durationMs:0,tokens:0}),p(!1),o(`/goal ${M}`)}},e[6]=h,e[7]=o,e[8]=N):N=e[8];const _=N;let A;e[9]!==o?(A=()=>{u(null),p(!1),o("/goal clear")},e[9]=o,e[10]=A):A=e[10];const P=A;let E;if(e[11]!==l||e[12]!==C||e[13]!==P||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==S||e[18]!==_){if(E=null,m){let M;e[20]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(rr,{className:"size-3.5","data-icon":"inline-start"}),e[20]=M):M=e[20];const D=S?"Replace goal":"Set a long-running goal";let O;e[21]!==D?(O=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,D]}),e[21]=D,e[22]=O):O=e[22];const L=!!x;let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(bt,{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=Z=>g(Z.target.value),e[24]=z):z=e[24];const W=`A measurable condition ${l} should keep working toward…`,U=!!x;let H;e[25]!==h||e[26]!==W||e[27]!==U?(H=r.jsx(Ca,{id:"goal-condition",value:h,onChange:z,placeholder:W,rows:2,maxLength:4e3,"aria-invalid":U,autoFocus:!0}),e[25]=h,e[26]=W,e[27]=U,e[28]=H):H=e[28];let K;e[29]!==x?(K=r.jsx(fs,{children:x}),e[29]=x,e[30]=K):K=e[30];let q;e[31]!==H||e[32]!==K||e[33]!==L?(q=r.jsxs(xt,{"data-invalid":L,children:[F,H,K]}),e[31]=H,e[32]=K,e[33]=L,e[34]=q):q=e[34];let Y;e[35]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[r.jsx(ct,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=Y):Y=e[35];let G;e[36]!==h?(G=h.trim(),e[36]=h,e[37]=G):G=e[37];const J=!G;let Q;e[38]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(mt,{"data-icon":"inline-start"}),e[38]=Q):Q=e[38];let X;e[39]!==_||e[40]!==J?(X=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,r.jsxs(ee,{type:"button",size:"xs",onClick:_,disabled:J,children:[Q,"Start goal"]})]}),e[39]=_,e[40]=J,e[41]=X):X=e[41],E=r.jsxs("section",{className:Xg,"aria-label":`${l} goal editor`,children:[O,q,X]})}else if(S){let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(rr,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=M):M=e[42];let D;e[43]!==S.condition?(D=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:S.condition,children:S.condition}),e[43]=S.condition,e[44]=D):D=e[44];let O;e[45]!==S.status?(O=p4(S.status),e[45]=S.status,e[46]=O):O=e[46];let L;e[47]!==S.status?(L=m4(S.status),e[47]=S.status,e[48]=L):L=e[48];let F;e[49]!==O||e[50]!==L?(F=r.jsx(Ee,{variant:O,children:L}),e[49]=O,e[50]=L,e[51]=F):F=e[51];const z=S.iterations,W=S.iterations===1?"":"s";let U;e[52]!==S.tokens?(U=tt(S.tokens),e[52]=S.tokens,e[53]=U):U=e[53];let H;e[54]!==S.durationMs?(H=Math.round(S.durationMs/6e4),e[54]=S.durationMs,e[55]=H):H=e[55];const K=Math.max(0,H);let q;e[56]!==S.iterations||e[57]!==W||e[58]!==U||e[59]!==K?(q=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[z," turn",W," · ",U," · ",K,"m"]}),e[56]=S.iterations,e[57]=W,e[58]=U,e[59]=K,e[60]=q):q=e[60];let Y;e[61]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Ws,{"data-icon":"icon"}),e[61]=Y):Y=e[61];let G;e[62]!==C?(G=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:Y}),e[62]=C,e[63]=G):G=e[63];let J;e[64]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(aa,{"data-icon":"icon"}),e[64]=J):J=e[64];let Q;e[65]!==P?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:P,"aria-label":"Clear goal",children:J}),e[65]=P,e[66]=Q):Q=e[66];let X;e[67]!==G||e[68]!==Q?(X=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[G,Q]}),e[67]=G,e[68]=Q,e[69]=X):X=e[69];let Z;e[70]!==F||e[71]!==q||e[72]!==X||e[73]!==D?(Z=r.jsxs("div",{className:"flex items-center gap-2",children:[M,D,F,q,X]}),e[70]=F,e[71]=q,e[72]=X,e[73]=D,e[74]=Z):Z=e[74];let se;e[75]!==S.reason?(se=S.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:S.reason}),e[75]=S.reason,e[76]=se):se=e[76],E=r.jsxs("section",{className:Yg,"aria-label":`${l} goal`,children:[Z,se]})}e[11]=l,e[12]=C,e[13]=P,e[14]=h,e[15]=m,e[16]=x,e[17]=S,e[18]=_,e[19]=E}else E=e[19];const T=!S&&!m;let I;e[77]!==C||e[78]!==E||e[79]!==T?(I={section:E,canCreate:T,beginEditing:C},e[77]=C,e[78]=E,e[79]=T,e[80]=I):I=e[80];const $=I;let R;return e[81]!==i||e[82]!==$?(R=r.jsx(id.Provider,{value:$,children:i}),e[81]=i,e[82]=$,e[83]=R):R=e[83],R}function g4(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(f4,{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(h4,{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 Jg(){return Gg().section}function Qg(){const n=B.c(3),{canCreate:e,beginEditing:t}=Gg();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(rr,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let o;return n[1]!==t?(o=r.jsxs(ee,{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 x4(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(Jg,{}),r.jsx(Qg,{})]}),n[0]=e):e=n[0],e}const b4=/\x1b\].*?(?:\x07|\x1b\\)/g,v4=/\x1b\[[0-9;]*[A-Za-z]/g,y4=/\x1b[()][AB012]/g,w4=/\[2K\[1G/g;function Zg(n){return n.replace(b4,"").replace(v4,"").replace(y4,"").replace(w4,`
5
+ `).replace(/\r/g,"")}function Vs(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=V("relative overflow-hidden",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(ly,{"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(j4,{}),c=r.jsx(cy,{}),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(ay,{"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 j4(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=V("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(uy,{"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(dy,{"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 e1(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=V("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=V("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 N4(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=V("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 k4(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=V("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 vt(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=e1,i=V(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 C4(n){const e=Sn("hostFiles"),[t,s]=y.useState([]),[o,i]=y.useState(!1),a=y.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 y.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const Wf=500,_4=5e3;function T4(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=y.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=y.useState(i),c=y.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const f=y.useRef(d),u=y.useRef(Wf),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(E4);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=L=>{var W;const F=L.type,z=L.id;if(F==="sessions"){l(L.sessions??[]);return}z&&((W=f.current.get(z))==null||W(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}${fg()}/__pty`},F=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const W=new WebSocket(L());c.current=W,W.onopen=()=>{if(p.current){W.close();return}u.current=Wf,o("connected"),W.send(JSON.stringify({type:"list"}))},W.onmessage=U=>{try{const H=JSON.parse(U.data);x(H)}catch{}},W.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const U=u.current;u.current=Math.min(U*2,_4),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]),y.useEffect(b,w);let v;e[6]!==t?(v=L=>{if(!t)return;const F=c.current;F&&F.readyState===WebSocket.OPEN&&F.send(JSON.stringify(L))},e[6]=t,e[7]=v):v=e[7];const j=v;let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=(L,F)=>{f.current.set(L,F)},e[8]=S):S=e[8];const k=S;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=L=>{f.current.delete(L)},e[9]=C):C=e[9];const N=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 A=_;let P;e[12]!==j?(P=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]=P):P=e[13];const E=P;let T;e[14]!==j?(T=L=>{j({type:"kill",id:L})},e[14]=j,e[15]=T):T=e[15];const I=T;let $;e[16]!==j?($=(L,F)=>{j({type:"input",id:L,data:F})},e[16]=j,e[17]=$):$=e[17];const R=$;let M;e[18]!==j?(M=(L,F,z)=>{j({type:"resize",id:L,cols:F,rows:z})},e[18]=j,e[19]=M):M=e[19];const D=M;let O;return e[20]!==I||e[21]!==D||e[22]!==j||e[23]!==a||e[24]!==E||e[25]!==A||e[26]!==s||e[27]!==R?(O={status:s,send:j,subscribe:k,unsubscribe:N,sessions:a,spawnTerminal:A,spawnScript:E,killSession:I,writeInput:R,resize:D},e[20]=I,e[21]=D,e[22]=j,e[23]=a,e[24]=E,e[25]=A,e[26]=s,e[27]=R,e[28]=O):O=e[28],O}function E4(){}const t1=y.createContext(null);function fl(n){const e=B.c(3),{children:t,enabled:s}=n,i=T4(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(t1.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function ad(){const n=y.useContext(t1);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function A4(n){var f;const e=B.c(11),t=ad();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 P4(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=V("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(qc,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx(kr,{"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(ee,{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 I4=y.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[f,u]=y.useState(d),{scripts:m,loading:p}=C4(s),{runningProcesses:h,runScript:g,stopScript:x}=A4(o);let b;if(t[1]!==m||t[2]!==l){const F=l.trim().toLowerCase(),z=F?m.filter(W=>W.name.toLowerCase().includes(F)||W.dirLabel.toLowerCase().includes(F)):m;b=new Map;for(const W of z){const U=b.get(W.dirLabel)??[];U.push(W),b.set(W.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let v;if(t[4]!==h){v=new Map;for(const[F,z]of h)v.set(`${z.name}:${z.cwd}`,{id:F,status:z.status});t[4]=h,t[5]=v}else v=t[5];const j=v;if(!s||!p&&m.length===0)return null;let S;t[6]===Symbol.for("react.memo_cache_sentinel")?(S=function(z){u(W=>{const U=new Set(W);return U.has(z)?U.delete(z):U.add(z),U})},t[6]=S):S=t[6];const k=S;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 N;t[8]!==p?(N=p&&r.jsx(vt,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=N):N=t[9];const _=i?"Close script search":"Search scripts";let A,P;t[10]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{a(R4),c("")},P=r.jsx(dn,{}),t[10]=A,t[11]=P):(A=t[10],P=t[11]);let E;t[12]!==i||t[13]!==_?(E=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":_,"aria-expanded":i,onClick:A,children:P}),t[12]=i,t[13]=_,t[14]=E):E=t[14];let T;t[15]!==N||t[16]!==E?(T=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,N,E]}),t[15]=N,t[16]=E,t[17]=T):T=t[17];let I;t[18]!==i||t[19]!==l?(I=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(Bt,{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]=I):I=t[20];let $;t[21]!==f||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?($=[...w.entries()].map(F=>{const[z,W]=F,U=f.has(z)||!!l,H=W.filter($4),K=W.filter(M4),q=U?W:H.length>0?H:W.slice(0,1);return r.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&r.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:z}),q.map(Y=>{const G=j.get(`${Y.name}:${Y.dir}`);return r.jsx(P4,{script:Y,status:(G==null?void 0:G.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{G&&x(G.id)}},`${z}:${Y.name}`)}),!l&&K.length>0&&r.jsx(ee,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>k(z),children:U?"Show less":`Show ${K.length} more`})]},z)}),t[21]=f,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=$):$=t[27];let R;t[28]!==w.size||t[29]!==p||t[30]!==l?(R=!p&&w.size===0&&l&&r.jsx(un,{className:"gap-1 p-3",children:r.jsxs(fn,{className:"gap-1",children:[r.jsx(mn,{children:"No matching scripts"}),r.jsx(Tn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=R):R=t[31];let M;t[32]!==$||t[33]!==R?(M=r.jsxs(Vs,{className:"min-h-0 flex-1 px-1 pb-1",children:[$,R]}),t[32]=$,t[33]=R,t[34]=M):M=t[34];let D;t[35]!==I||t[36]!==M||t[37]!==T?(D=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[T,I,M]}),t[35]=I,t[36]=M,t[37]=T,t[38]=D):D=t[38];let O;t[39]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Rt,{orientation:"vertical"}),t[39]=O):O=t[39];let L;return t[40]!==D?(L=r.jsxs(r.Fragment,{children:[D,O]}),t[40]=D,t[41]=L):L=t[41],L});function R4(n){return!n}function $4(n){return n.isCommon}function M4(n){return!n.isCommon}function n1(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=V("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(py,{"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 O4=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 s1(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=V(O4({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=V("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(gy,{"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(my,{"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 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=V("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(hy,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wo(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=V("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(fy,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const D4=y.lazy(()=>qe(()=>import("./TerminalOutput-DlGDS0Wx.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function L4({process:n}){const[e,t]=y.useState(""),[s,o]=y.useState(!1),i=y.useRef(null);return y.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=Ar(`/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]),y.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 z4(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=V("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=V("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 v;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?(v=r.jsxs(Uo,{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]=v):v=e[24];const j=`Close ${t.name}`,S=`Close ${t.name}`;let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(ct,{"data-icon":"inline-start"}),e[25]=k):k=e[25];let C;e[26]!==i||e[27]!==j||e[28]!==S?(C=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:S,onClick:i,className:"mr-0.5 text-muted-foreground",children:k}),e[26]=i,e[27]=j,e[28]=S,e[29]=C):C=e[29];let N;return e[30]!==l||e[31]!==v||e[32]!==C?(N=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,C]}),e[30]=l,e[31]=v,e[32]=C,e[33]=N):N=e[33],N}const o1=100,r1=600,F4=200,i1="process-panel-height";function B4(){try{const n=localStorage.getItem(i1);if(n)return Math.min(r1,Math.max(o1,Number(n)))}catch{}return F4}const U4=y.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=ad(),[b,w]=y.useState(B4),v=y.useRef(null);let j,S;t[0]!==u||t[1]!==x.sessions?(j=()=>{for(const ce of x.sessions)ce.status==="exited"&&(u==null||u(ce.id,"stopped"))},S=[x.sessions,u],t[0]=u,t[1]=x.sessions,t[2]=j,t[3]=S):(j=t[2],S=t[3]),y.useEffect(j,S);let k;t[4]!==l||t[5]!==x?(k=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=k):k=t[6];const C=k;let N;t[7]!==b?(N=ce=>{ce.preventDefault(),v.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=N):N=t[8];const _=N;let A;t[9]===Symbol.for("react.memo_cache_sentinel")?(A=ce=>{if(!v.current)return;const be=v.current.startY-ce.clientY,ge=Math.min(r1,Math.max(o1,v.current.startH+be));w(ge)},t[9]=A):A=t[9];const P=A;let E;t[10]!==b?(E=()=>{if(v.current){v.current=null;try{localStorage.setItem(i1,String(b))}catch{}}},t[10]=b,t[11]=E):E=t[11];const T=E;let I;t[12]!==o||t[13]!==s?(I=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=I):I=t[14];const $=I;let R;t[15]!==s?(R=[...s.values()],t[15]=s,t[16]=R):R=t[16];const M=R;let D;t[17]!==a?(D=ce=>{typeof ce=="string"&&a(ce)},t[17]=a,t[18]=D):D=t[18];let O;t[19]!==$||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==T?(O=!g&&!i&&$&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:_,onPointerMove:P,onPointerUp:T,onPointerCancel:T}),t[19]=$,t[20]=i,t[21]=g,t[22]=_,t[23]=T,t[24]=O):O=t[24];const L=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==L?(F=V("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",W=!i;let U;t[27]!==i?(U=i?r.jsx(Je,{"data-icon":"inline-start"}):r.jsx(nt,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const H=g&&"sr-only";let K;t[29]!==H?(K=V(H),t[29]=H,t[30]=K):K=t[30];let q;t[31]!==K?(q=r.jsx("span",{className:K,children:"Terminal"}),t[31]=K,t[32]=q):q=t[32];let Y;t[33]!==c||t[34]!==z||t[35]!==W||t[36]!==U||t[37]!==q?(Y=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":z,"aria-expanded":W,children:[U,q]}),t[33]=c,t[34]=z,t[35]=W,t[36]=U,t[37]=q,t[38]=Y):Y=t[38];const G=!g&&"ml-2";let J;t[39]!==G?(J=V("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",G),t[39]=G,t[40]=J):J=t[40];let Q;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==M?(Q=M.map(ce=>r.jsx(z4,{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]=M,t[46]=Q):Q=t[46];let X;t[47]!==J||t[48]!==Q?(X=r.jsx(s1,{variant:"default","aria-label":"Open processes",className:J,children:Q}),t[47]=J,t[48]=Q,t[49]=X):X=t[49];let Z;t[50]!==d||t[51]!==m?(Z=d&&r.jsx(ee,{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($n,{})}),t[50]=d,t[51]=m,t[52]=Z):Z=t[52];let se;t[53]!==F||t[54]!==Y||t[55]!==X||t[56]!==Z?(se=r.jsxs("div",{className:F,children:[Y,X,Z]}),t[53]=F,t[54]=Y,t[55]=X,t[56]=Z,t[57]=se):se=t[57];const ne=!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(I4,{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]!==M?(te=M.map(ce=>r.jsx(Wo,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?r.jsx(L4,{process:ce}):r.jsx(y.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(D4,{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]=M,t[68]=te):te=t[68];let ue;t[69]!==$||t[70]!==d||t[71]!==m?(ue=!$&&r.jsxs(un,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(Hs,{})}),r.jsx(mn,{children:"No terminal open"}),r.jsx(Tn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(dg,{children:r.jsxs(ee,{type:"button",size:"sm",onClick:d,children:[r.jsx($n,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=$,t[70]=d,t[71]=m,t[72]=ue):ue=t[72];let le;t[73]!==te||t[74]!==ue?(le=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[te,ue]}),t[73]=te,t[74]=ue,t[75]=le):le=t[75];let de;t[76]!==ie||t[77]!==ae||t[78]!==le?(de=r.jsx(ft,{children:r.jsxs("div",{className:"flex min-h-0",style:ie,children:[ae,le]})}),t[76]=ie,t[77]=ae,t[78]=le,t[79]=de):de=t[79];let he;t[80]!==ne||t[81]!==de?(he=r.jsx(ut,{open:ne,className:"min-h-0",children:de}),t[80]=ne,t[81]=de,t[82]=he):he=t[82];let xe;return t[83]!==o||t[84]!==D||t[85]!==O||t[86]!==se||t[87]!==he?(xe=r.jsxs(n1,{value:o,onValueChange:D,className:"shrink-0 gap-0 border-t bg-background",children:[O,se,he]}),t[83]=o,t[84]=D,t[85]=O,t[86]=se,t[87]=he,t[88]=xe):xe=t[88],xe});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 W4=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function H4(n){const e=new Set;for(const t of n.matchAll(W4)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function K4(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=H4(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 Hf(n){var e;return((e=n.preview.split(`
6
+ `).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function q4(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=V("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 a1({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=y.useState([]),a=K4(e);y.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=y.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 y.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Hf(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=Hf(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(zh,{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(q4,{port:u,isActive:c.portStatus[u]},u)),r.jsx("div",{className:"flex-1"}),c.outputPath&&r.jsx(ee,{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(Hs,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(u=>l(u)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(qc,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function ld(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(xy,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function V4(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(by,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function G4(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(Wc,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Y4(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=V("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(Hc,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function cd(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(Y4,{}),e[4]=a):a=e[4];let l;e[5]!==t?(l=V("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(G4,{children:[a,r.jsx(Uc,{"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 dd(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=V("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 ud(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=V("-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 X4(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=V("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 fd(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=V("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(Fc,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function md(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=V("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(Bc,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function pd(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=V(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ee,{"data-slot":"alert-dialog-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function hd(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=V(t),e[5]=t,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==a?(d=r.jsx(ee,{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(oa,{"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 l1(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=V("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(yy,{"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(mt,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(vy,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const J4={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},Q4={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 Z4({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var u,m;const i=y.useRef(n),[a,l]=y.useState({key:"",selected:!1});y.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(ld,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(cd,{children:[r.jsxs(dd,{children:[r.jsx(X4,{children:r.jsx(kn,{className:"text-warning"})}),r.jsx(fd,{children:J4[c.type]}),r.jsx(md,{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.":Q4[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(l1,{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(Nt,{children:t})}),r.jsxs(ud,{children:[r.jsx(hd,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(pd,{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 Yt(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=V("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 tn(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=V("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 nn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=V("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 an(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=V("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 gd(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=V("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 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=V("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 Ao(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=V("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=V("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 e5=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 Nn(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=V(e5({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:t5,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function t5(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const n5=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 Dr(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=V(n5({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(ee,{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=V("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(Bt,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function s5(){const[n,e]=y.useState("idle"),[t,s]=y.useState(null),o=y.useRef(void 0),i=y.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=y.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=y.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=y.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 y.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}const co=S3(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),c1=ha().filter(n=>n.cli.homeIsDiscoverable);function d1(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function u1(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 o5=d1(c1.map(n=>n.displayName)),r5=d1(c1.map(n=>r.jsx(u1,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),i5=`~/${co.cli.homeDirName}`;function a5(n){const e=B.c(46),{onConfigured:t}=n,[s,o]=y.useState(""),[i,a]=y.useState(!1),{status:l,error:c,debouncedValidate:d,save:f}=s5();let u;e[0]!==d?(u=O=>{const L=O.target.value;o(L),d(L)},e[0]=d,e[1]=u):u=e[1];const m=u;let p;e[2]!==t||e[3]!==s||e[4]!==f?(p=async()=>{a(!0);const O=await f(s);O.success&&O.claudeDir&&t(O.claudeDir),a(!1)},e[2]=t,e[3]=s,e[4]=f,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==i||e[8]!==l?(g=O=>{O.preventDefault(),l==="valid"&&!i&&h()},e[6]=h,e[7]=i,e[8]=l,e[9]=g):g=e[9];let x,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:r.jsx(Kc,{className:"size-4"})}),b=r.jsx(nn,{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(tn,{children:[x,b,r.jsxs(an,{children:["Cogpit detects ",o5," automatically. Existing histories live in"," ",r5,"."," ","For ",co.displayName,", enter its data directory, usually"," ",r.jsx(u1,{children:i5}),"."]})]}),e[12]=w):w=e[12];const v=l==="invalid";let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(bt,{htmlFor:"agent-data-directory",children:[co.displayName," data directory"]}),e[13]=j):j=e[13];let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Nn,{children:r.jsx(bo,{"aria-hidden":"true"})}),e[14]=S):S=e[14];const k=l==="invalid";let C;e[15]!==m||e[16]!==s||e[17]!==k?(C=r.jsxs(ns,{children:[S,r.jsx(ss,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${co.cli.homeDirName}`,autoFocus:!0,"aria-invalid":k,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=k,e[18]=C):C=e[18];let N;e[19]!==l?(N=l==="validating"&&r.jsxs(yo,{className:"flex items-center gap-2",children:[r.jsx(vt,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=N):N=e[20];let _;e[21]!==l?(_=l==="valid"&&r.jsxs(yo,{className:"flex items-center gap-2 text-success",children:[r.jsx(ra,{className:"size-4"}),co.displayName," history found"]}),e[21]=l,e[22]=_):_=e[22];let A;e[23]!==c||e[24]!==l?(A=l==="invalid"&&c&&r.jsxs(fs,{className:"flex items-center gap-2",children:[r.jsx(Ks,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=A):A=e[25];let P;e[26]!==N||e[27]!==_||e[28]!==A?(P=r.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[N,_,A]}),e[26]=N,e[27]=_,e[28]=A,e[29]=P):P=e[29];let E;e[30]!==C||e[31]!==P||e[32]!==v?(E=r.jsx(Xt,{children:r.jsx(To,{children:r.jsxs(xt,{"data-invalid":v,children:[j,C,P]})})}),e[30]=C,e[31]=P,e[32]=v,e[33]=E):E=e[33];const T=l!=="valid"||i;let I;e[34]!==i?(I=i&&r.jsx(vt,{"data-icon":"inline-start"}),e[34]=i,e[35]=I):I=e[35];const $=i?"Saving...":`Connect ${co.displayName}`;let R;e[36]!==T||e[37]!==I||e[38]!==$?(R=r.jsx(Ao,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:T,children:[I,$]})}),e[36]=T,e[37]=I,e[38]=$,e[39]=R):R=e[39];let M;e[40]!==E||e[41]!==R?(M=r.jsxs(Yt,{children:[w,E,R]}),e[40]=E,e[41]=R,e[42]=M):M=e[42];let D;return e[43]!==M||e[44]!==g?(D=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8 text-foreground",children:r.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:M})}),e[43]=M,e[44]=g,e[45]=D):D=e[45],D}const f1=/^[a-z]:[\\/]/i;function xd(n){return(f1.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function Kf(n){const e=xd(n);return f1.test(n)?e.toLowerCase():e}function l5(n){const e=xd(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function qf(n,e){const t=Kf(n),s=Kf(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?xd(e).slice(o.length):null}let bd=!1;function c5(n){bd=n}function vd(){return bd}let Qo=null;function d5(n){return Qo=n,()=>{Qo===n&&(Qo=null)}}function u5(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=qf(e,n.path);if(o)return{root:e,file:o,mode:Vf(n),line:n.line}}const t=l5(n.path),s=qf(t,n.path);return s?{root:t,file:s,mode:Vf(n),line:n.line}:null}function Vf(n){return n.mode==="diff"?"diff":"edit"}function m1(n){return bd&&Qo!==null&&Qo(n)}function p1(n,e){ye(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function ur(n,e={}){if(lt("hostFiles")&&!m1({kind:"file",path:n,...e})){if(Ds()){Er(n);return}p1("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function h1(n){lt("hostFiles")&&(n.path&&m1({kind:"project",path:n.path})||x1("/api/open-in-editor",n))}function g1(n){lt("hostFiles")&&x1("/api/reveal-in-folder",n)}function x1(n,e){!e.path&&!e.dirName||p1(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let ml=null;const fc=new Set,fi=new Map,Gf=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],b1={typescript:()=>qe(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>qe(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>qe(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>qe(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>qe(()=>import("./json-Cp-IABpG.js"),[]),css:()=>qe(()=>import("./css-DPfMkruS.js"),[]),html:()=>qe(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([6,7,8])),python:()=>qe(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>qe(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>qe(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>qe(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>qe(()=>import("./rust-B1yitclQ.js"),[]),go:()=>qe(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>qe(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>qe(()=>import("./sql-BLtJtn59.js"),[]),c:()=>qe(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>qe(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([9,10,11])),java:()=>qe(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>qe(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([12,6,7,8,13,14,11,15,16,17,9,10,18,19])),swift:()=>qe(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>qe(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>qe(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([20,6,7,8,13,14,11,21])),vue:()=>qe(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([22,8,7,15,21,6])),svelte:()=>qe(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([23,7,15,8])),scss:()=>qe(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([24,8]))};function v1(){return ml||(ml=(async()=>{const[n,e,...t]=await Promise.all([qe(()=>import("./github-dark-DHJKELXO.js"),[]).then(o=>o.default),qe(()=>import("./github-light-DAi9KRSo.js"),[]).then(o=>o.default),...Gf.map(o=>b1[o]().then(i=>i.default))]),s=await p3({themes:[n,e],langs:t,engine:h3()});for(const o of Gf)fc.add(o);return s})()),ml}async function y1(n,e){if(fc.has(e))return;if(fi.has(e))return fi.get(e);const t=b1[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),fc.add(e)}).finally(()=>fi.delete(e));fi.set(e,s),await s}const f5={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 w1(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return f5[e]??null}async function yd(n,e,t){try{const s=await v1();await y1(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}function Lr(){const n=B.c(2),[e,t]=y.useState(m5);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]),y.useEffect(s,o),e}function m5(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const p5={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 h5(n){return p5[n.toLowerCase()]??n}function g5(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function x5(n){const e=B.c(10),{text:t}=n,[s,o]=y.useState(!1),i=y.useRef(null),a=y.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]),y.useEffect(l,c);let d;e[2]!==t?(d=function(){const g=a.current=a.current+1;Er(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(mt,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(Cn,{"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(ee,{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 b5(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 v5(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=g5(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(y5,{code:f,lang:l,...o}),e[12]=f,e[13]=l,e[14]=o,e[15]=u):u=e[15],u}function y5(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=Lr(),[a,l]=y.useState(null),[c,d]=y.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 E=!1;return yd(t,s,i).then(T=>{E||l({key:p,lines:T})}),()=>{E=!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]),y.useEffect(g,x);const b=c?Je:nt,w="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let v;e[10]!==b||e[11]!==c||e[12]!==m?(v=m&&r.jsx(ee,{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]=v):v=e[13];let j;e[14]!==s?(j=s&&r.jsx(Ee,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:h5(s)}),e[14]=s,e[15]=j):j=e[15];let S;e[16]!==m||e[17]!==u?(S=m&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[16]=m,e[17]=u,e[18]=S):S=e[18];let k;e[19]!==v||e[20]!==j||e[21]!==S?(k=r.jsxs("div",{className:"flex items-center gap-2",children:[v,j,S]}),e[19]=v,e[20]=j,e[21]=S,e[22]=k):k=e[22];let C;e[23]!==t?(C=r.jsx(x5,{text:t}),e[23]=t,e[24]=C):C=e[24];let N;e[25]!==k||e[26]!==C?(N=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[k,C]}),e[25]=k,e[26]=C,e[27]=N):N=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:V("block",!h&&"text-foreground/90"),...o,children:f.map((E,T)=>{const I=h==null?void 0:h[T];return r.jsxs("span",{className:"block",children:[r.jsx(b5,{num:T+1}),I?I.map(w5):E||" "]},T)})})})});let A;e[28]!==c||e[29]!==u?(A=c&&r.jsxs(ee,{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]=A):A=e[30];let P;return e[31]!==_||e[32]!==A||e[33]!==N?(P=r.jsxs("div",{className:w,children:[N,_,A]}),e[31]=_,e[32]=A,e[33]=N,e[34]=P):P=e[34],P}function w5(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var Ps=function(n,e){return Number(n.toFixed(e))},j5=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},N5=function(n){return n},k5=function(n){return n*n},C5=function(n){return n*(2-n)},_5=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},T5=function(n){return n*n*n},E5=function(n){return--n*n*n+1},A5=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},P5=function(n){return n*n*n*n},I5=function(n){return 1- --n*n*n*n},R5=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},$5=function(n){return n*n*n*n*n},M5=function(n){return 1+--n*n*n*n*n},O5=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},j1={easeOut:S5,linear:N5,easeInQuad:k5,easeOutQuad:C5,easeInOutQuad:_5,easeInCubic:T5,easeOutCubic:E5,easeInOutCubic:A5,easeInQuart:P5,easeOutQuart:I5,easeInOutQuart:R5,easeInQuint:$5,easeOutQuint:M5,easeInOutQuint:O5},S1=function(n){typeof n=="number"&&cancelAnimationFrame(n)},xn=function(n){n.mounted&&(S1(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function N1(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;xn(n),n.animation=function(){if(!n.mounted)return S1(n.animation);var a=new Date().getTime()-o,l=a/t,c=j1[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function D5(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function Ns(n,e,t,s){var o=D5(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):N1(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 L5(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 z5=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}},wd=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=L5(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,f=l.newContentWidth,u=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=z5(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,v=x.minPositionY,j=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),w!=null&&(h.maxPositionX=w*e),v!=null&&(h.minPositionY=d*(1-e)+v*e),j!=null&&(h.maxPositionY=j*e),h},fr=function(n,e,t,s){return s?n<e?Ps(e,2):n>t?Ps(t,2):Ps(n,2):Ps(n,2)},wo=function(n,e){var t=wd(n,e);return n.bounds=t,t};function zr(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=fr(n,l-u,d+u,s),h=fr(e,c-m,f+m,s);return{x:p,y:h}}function _a(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=zr(u,m,o,i,0,0,null);return p}var Yf=1e-7;function Fr(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,Yf),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,Yf)}var Xf=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=Br(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},Jf=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},F5=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}},B5=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 U5(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,v=_a(n,b,w,o,n.bounds,l||c),j=v.x,S=v.y;return{scale:o,positionX:g?j:t,positionY:x?S:s}}}function k1(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=zr(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var W5=function(n,e,t){var s=n.startCoords,o=n.state,i=n.setup.panning,a=i.lockAxisX,l=i.lockAxisY,c=o.positionX,d=o.positionY;if(!s)return{x:c,y:d};var f=e-s.x,u=t-s.y,m=a?c:f,p=l?d:u;return{x:m,y:p}},ys=function(n,e,t){var s=n.setup,o=n.state,i=s.minScale,a=s.disablePadding,l=s.centerZoomedOut,c=t??o.scale;return e>0&&c>=i&&!a&&!l?e:0},cs;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(cs||(cs={}));var H5=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},K5=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 q5(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 Qf(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:fr(n,i,a,o)}function V5(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var pl=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 G5(n,e,t){var s,o,i=H5(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=V5(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],v=e.x-a.x,j=e.y-a.y,S=pl(v/x,w,b),k=pl(j/x,w,b),C=g-l,N=v*v+j*j,_=pl(Math.sqrt(N)/C,w,b);n.velocity={velocityX:S,velocityY:k,total:_}}n.lastMousePosition=e,n.velocityTime=g}}function Y5(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=K5(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,v=g.animationType,j=h.sizeX,S=h.sizeY,k=h.velocityAlignmentTime,C=k,N=q5(n,c),_=Math.max(N,C),A=ys(n,j),P=ys(n,S),E=A*o.offsetWidth/100,T=P*o.offsetHeight/100,I=d+E,$=f-E,R=u+T,M=m-T,D=n.state,O=new Date().getTime();N1(n,v,_,function(L){var F=n.state,z=F.scale,W=F.positionX,U=F.positionY,H=new Date().getTime()-O,K=H/C,q=j1[h.animationType],Y=1-q(Math.min(1,K)),G=1-L,J=W+a*G,Q=U+l*G,X=Qf(J,D.positionX,W,w,p,f,d,$,I,Y),Z=Qf(Q,D.positionY,U,b,p,m,u,M,R,Y);if(W!==J||U!==Q){n.setState(z,X,Z);var se=n.props.onPanning;se&&se(Xe(n),{})}})}}function Zf(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},xn(n),wo(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?B5(n,e):F5(n,e)}function C1(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=U5(n);m&&Ns(n,m,d,f)}}function em(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=W5(n,e,t),f=d.x,u=d.y,m=ys(n,l),p=ys(n,c);G5(n,{x:f,y:u},s),k1(n,f,u,m,p)}}function X5(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?Y5(n):C1(n)}}function jd(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=Fr(Ps(e,2),i,a,0,!1),d=wo(n,c),f=_a(n,t,s,c,d,l),u=f.x,m=f.y;return{scale:c,positionX:u,positionY:m}}function Sd(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)&&C1(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,b=s<a?a:l,w=jd(n,b,g,x);w&&Ns(n,w,u,m)}}var ln=function(){return ln=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},ln.apply(this,arguments)};function tm(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 hl={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"}},mc={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},_1=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:hl.scale,p=Math.min(Math.max(m,f),u),h=fr((o=n.initialPositionX)!==null&&o!==void 0?o:hl.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=fr((l=n.initialPositionY)!==null&&l!==void 0?l:hl.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}},nm=function(n){var e=ln({},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]=ln(ln({},As[s]),n[s]):c?e[s]=tm(tm([],As[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},T1=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=Fr(Ps(u,3),l,a,f,!1);return m};function E1(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=T1(n,e,t),v=jd(n,w,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,S=j.onZoomStart,k=j.onZoom,C=j.onZoomStop,N=new MouseEvent("mousemove",{bubbles:!0}),_=Xe(n);Qe(_,N,S),Qe(_,N,k),Ns(n,v,p,o);var A=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;A&&A.setTimeout(function(){n.mounted&&Qe(Xe(n),N,C)},p)}function A1(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,f=a.centerOnInit,u=_1(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=Nd(u.scale,l,c);x=w.positionX,b=w.positionY}var v=wd(n,u.scale),j=zr(x,b,v,d,0,0,l),S={scale:u.scale,positionX:j.x,positionY:j.y};if(!(p===u.scale&&h===u.positionX&&g===u.positionY)){s==null||s();var k=n.props,C=k.onZoomStart,N=k.onZoom,_=k.onZoomStop,A=new MouseEvent("mousemove",{bubbles:!0}),P=Xe(n);Qe(P,A,C),Qe(P,A,N),Ns(n,S,e,t);var E=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;E&&E.setTimeout(function(){n.mounted&&Qe(Xe(n),A,_)},e)}}}function J5(n,e,t,s){var o=n.getBoundingClientRect(),i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),l=i.x*s.scale,c=i.y*s.scale;return{x:(o.x-a.x+l)/s.scale,y:(o.y-a.y+c)/s.scale}}function Q5(n,e,t,s,o){s===void 0&&(s=0),o===void 0&&(o=0);var i=n.wrapperComponent,a=n.contentComponent,l=n.state,c=n.setup,d=c.limitToBounds,f=c.minScale,u=c.maxScale;if(!i||!a)return l;var m=i.getBoundingClientRect(),p=e.getBoundingClientRect(),h=J5(e,i,a,l),g=h.x,x=h.y,b=p.width/l.scale,w=p.height/l.scale,v=i.offsetWidth/b,j=i.offsetHeight/w,S=Fr(t||Math.min(v,j),f,u,0,!1),k=(m.width-b*S)/2,C=(m.height-w*S)/2,N=(m.left-g)*S+k+s,_=(m.top-x)*S+C+o,A=wd(n,S),P=zr(N,_,A,d,0,0,i),E=P.x,T=P.y;return{positionX:E,positionY:T,scale:S}}var Z5=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),E1(n,1,e,t,s)}},eN=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),E1(n,-1,e,t,s)}},tN=function(n){return function(e,t,s,o,i){o===void 0&&(o=300),i===void 0&&(i="easeOut");var a=n.state,l=a.positionX,c=a.positionY,d=a.scale,f=n.wrapperComponent,u=n.contentComponent,m=n.setup.disabled;if(!(m||!f||!u)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?d:s};Ns(n,p,o,i)}}},nN=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),A1(n,e,t)}},sN=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=Nd(e||o.scale,i,a);Ns(n,l,t,s)}}},oN=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),xn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=Q5(n,c,t,i,a);Ns(n,d,s,o)}}},pc=function(n){return{instance:n,state:n.state,zoomIn:Z5(n),zoomOut:eN(n),setTransform:tN(n),resetTransform:nN(n),centerView:sN(n),zoomToElement:oN(n)}},rN=function(n){return{instance:n,state:n.state}},Xe=function(n){var e={};return Object.assign(e,rN(n)),Object.assign(e,pc(n)),e},gl=!1;function xl(){try{var n={get passive(){return gl=!0,!1}};return n}catch{return gl=!1,gl}}var mi=".".concat(mc.wrapperClass),Br=function(n,e){return e.some(function(t){return n.matches("".concat(mi," ").concat(t,", ").concat(mi," .").concat(t,", ").concat(mi," ").concat(t," *, ").concat(mi," .").concat(t," *"))})},mr=function(n){n&&clearTimeout(n)},iN=function(n){return Number.parseFloat(n.toFixed(8))},P1=function(n,e,t){var s=iN(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},Nd=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 aN(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function lN(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var I1=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=Br(d,a);if(u)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},cN=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=I1(n,e);if(l)return!1;var c=e.target,d=Br(c,a);if(d)return!1;var f=n.isPressingKeys(i);return!!f},dN=function(n){return n?n.deltaY<0?1:-1:0};function uN(n,e){var t=dN(n),s=j5(e,t);return s}function R1(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 fN=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=Fr(h,d,c,m,g&&!u);return x},$1=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},mN=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=Br(a,o);return!c},pN=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},hN=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}},M1=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))},gN=5,xN=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/gN),x=t+g,b=x===1/0?0:Ps(x,10);return Fr(b,a,i,f,!u&&!c)},O1=160,D1=100,bN=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(xn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},vN=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=uN(e,null),v=h?b*Math.abs(e.deltaY):b,j=fN(n,w,v,!e.ctrlKey);if(c!==j){var S=wo(n,j),k=R1(e,i,c),C=x||g===0||f||p,N=d&&C,_=_a(n,k.x,k.y,j,S,N),A=_.x,P=_.y;n.previousWheelEvent=e,n.setState(j,A,P),Qe(Xe(n),e,s),Qe(Xe(n),e,o)}},yN=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;mr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Sd(n,e.x,e.y),n.wheelAnimationTimer=null)},D1);var i=$1(n,e);i&&(mr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},O1))},wN=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(xn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},jN=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;mr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Sd(n,e.x,e.y),n.wheelAnimationTimer=null)},D1);var i=$1(n,e);i&&(mr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},O1))},L1=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}},SN=function(n,e){var t=M1(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=L1(e),xn(n)},NN=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=hN(e,a,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=M1(e),v=xN(n,w),j=L1(e),S=a/v,k=(j.x-((i==null?void 0:i.x)||0))*S,C=(j.y-((i==null?void 0:i.y)||0))*S;if(!(v===a&&k===0&&C===0)){n.pinchPreviousCenter=j;var N=wo(n,v),_=h||g===0||d,A=c&&_,P=_a(n,b.x,b.y,v,N,A),E=P.x,T=P.y;if(n.pinchMidpoint=b,n.lastDistance=w,p.disabled||!x)n.setState(v,E,T);else{var I=u.sizeX,$=u.sizeY,R=ys(n,I,v),M=ys(n,$,v),D=E+k,O=T+C,L=zr(D,O,N,c,R,M,o),F=L.x,z=L.y;n.setState(v,F,z)}}}}},kN=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,Sd(n,e==null?void 0:e.x,e==null?void 0:e.y)},z1=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;mr(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Xe(n),e,t)},s)},CN=function(n,e){var t=n.props,s=t.onZoomStart,o=t.onZoom,i=n.setup.doubleClick,a=i.animationTime,l=i.animationType;Qe(Xe(n),e,s),A1(n,a,l,function(){return Qe(Xe(n),e,o)}),z1(n,e)};function _N(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function TN(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 CN(n,e);if(!i)return console.error("No ContentComponent found");var x=_N(m,n.state.scale),b=T1(n,x,p);if(a!==b){Qe(Xe(n),e,c);var w=R1(e,i,a),v=jd(n,b,w.x,w.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Xe(n),e,d),Ns(n,v,h,g),z1(n,e)}}}var EN=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=Br(c,l);return!u},AN=(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&&wo(t,t.state.scale),t.setup=nm(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=xl(),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=xl(),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),xn(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=xl();s.addEventListener("wheel",t.onWheelZoom,o),s.addEventListener("dblclick",t.onDoubleClick,o),s.addEventListener("touchstart",t.onTouchPanningStart,o),s.addEventListener("touchmove",t.onTouchPanning,o),s.addEventListener("touchend",t.onTouchPanningStop,o)},this.handleInitialize=function(s){var o=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(i){return i(Xe(t))}),o&&(t.setCenter(),t.observer=new ResizeObserver(function(){var i,a=s.offsetWidth,l=s.offsetHeight;(a>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(Xe(t))}),t.setCenter(),(i=t.observer)===null||i===void 0||i.disconnect())}),setTimeout(function(){var i;(i=t.observer)===null||i===void 0||i.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var o=t.setup.disabled;if(!o){t.syncModifierKeys(s);var i=I1(t,s);i&&(bN(t,s),vN(t,s),yN(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=cN(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,v=ys(t,b),j=ys(t,w);h===f&&g===u||(wN(t,s),k1(t,h,g,v,j),Qe(Xe(t),s,o),jN(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=Xf(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(),xn(t),Zf(t,s),Qe(Xe(t),s,i)))}}},this.onPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(!o){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var a=Jf(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),em(t,s.clientX,s.clientY,cs.MOUSE),Qe(Xe(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(X5(t,o),Qe(Xe(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=mN(t,s);a&&(SN(t,s),xn(t),Qe(Xe(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=pN(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),NN(t,s),Qe(Xe(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(kN(t),Qe(Xe(t),s,o))},this.onTouchPanningStart=function(s){var o=t.setup,i=o.disabled,a=o.doubleClick,l=t.props.onPanningStart;if(!i){var c=!(a!=null&&a.disabled),d=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&d&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,xn(t);var f=s.touches,u=f.length===1,m=f.length===2,p=Xf(t,s);if(u){if(!p)return;xn(t),Zf(t,s),Qe(Xe(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var o=t.setup.disabled,i=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(o)return;var a=Jf(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];em(t,l.clientX,l.clientY,cs.TOUCH),Qe(Xe(t),s,i)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var o=t.setup.disabled;if(!o){var i=EN(t,s);i&&TN(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=Nd(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):P1(s,o,i)},this.getContext=function(){return Xe(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,o=s.scale,i=s.positionX,a=s.positionY,l=t.handleTransformStyles(i,a,o);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:o,positionX:i,positionY:a,previousScale:t.state.previousScale,ref:Xe(t)})})}},this.setState=function(s,o,i){var a=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(o)&&!Number.isNaN(i)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=o,t.state.positionY=i,t.applyTransformation();var c=Xe(t);t.onChangeCallbacks.forEach(function(d){return d(c)}),Qe(c,{scale:t.state.scale,positionX:o,positionY:i},a)}else console.error("Detected NaN set state values")},this.onTransform=function(s){return t.onTransformCallbacks.has(s)||t.onTransformCallbacks.add(s),function(){t.onTransformCallbacks.delete(s)}},this.onChange=function(s){return t.onChangeCallbacks.has(s)||t.onChangeCallbacks.add(s),function(){t.onChangeCallbacks.delete(s)}},this.onInit=function(s){return t.onInitCallbacks.has(s)||t.onInitCallbacks.add(s),function(){t.onInitCallbacks.delete(s)}},this.init=function(s,o){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=o,wo(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(o),t.initializeWindowEvents(),t.isInitialized=!0;var i=Xe(t);Qe(i,void 0,t.props.onInit),aN(t.props.ref,i)},this.props=e,this.setup=nm(this.props),this.state=_1(this.props)}return n})(),Ta=ve.createContext(null),PN=function(n,e){return typeof n=="function"?n(e):n},IN=ve.forwardRef(function(n,e){var t=y.useRef(new AN(n)).current,s=PN(n.children,pc(t));return y.useImperativeHandle(e,function(){return pc(t)},[t]),y.useEffect(function(){t.update(n)},[t,n]),r.jsx(Ta.Provider,ln({value:t},{children:s}))});ve.forwardRef(function(n,e){var t=y.useRef(null),s=y.useContext(Ta);return y.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",ln({},n,{ref:lN([t,e])}))});function RN(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 $N=`.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
+ `,bl={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};RN($N);var MN=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=y.useContext(Ta),g=h.init,x=h.cleanupWindowEvents,b=y.useRef(null),w=y.useRef(null),v=y.useRef(null);return y.useEffect(function(){var j=b.current,S=w.current;return j!==null&&S!==null&&g&&(g==null||g(j,S)),function(){x==null||x()}},[]),y.useEffect(function(){if(p){var j=v.current;if(j){var S=function(){var k=h.state,C=k.positionX,N=k.positionY;j.style.backgroundPosition="".concat(C,"px ").concat(N,"px")};return S(),h.onChange(S)}}},[p,h]),r.jsxs("div",ln({},d,{ref:b,className:"".concat(mc.wrapperClass," ").concat(bl.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:v,className:bl.infiniteGrid,"aria-hidden":!0}),r.jsx("div",ln({},u,{ref:w,className:"".concat(mc.contentClass," ").concat(bl.content," ").concat(i),style:ln(ln({},l),{transform:P1(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function ON(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 DN(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 v=ON(h,g);return v/w>=p}ve.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=y.useContext(Ta),w=y.useState(!1),v=w[0],j=w[1],S=y.useRef(!1),k=y.useRef(m),C=y.useRef(p);return k.current=m,C.current=p,y.useEffect(function(){var N=function(){var P,E,T=b.wrapperComponent;if(T){var I=DN({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:T.offsetWidth,viewportHeight:T.offsetHeight,margin:l,threshold:d});I!==S.current&&(S.current=I,j(I),I?(P=k.current)===null||P===void 0||P.call(k):(E=C.current)===null||E===void 0||E.call(C))}};N();var _=b.onChange(N),A;return b.wrapperComponent||(A=b.onInit(function(){return N()})),function(){_(),A==null||A()}},[b,t,s,o,i,l,d]),v?r.jsx("div",ln({ref:e,className:g,style:x},{children:h})):u?r.jsx(r.Fragment,{children:u}):null});const sm=8,LN=56;function Mo(n){const e=B.c(8),{label:t,disabled:s,onClick:o,children:i,className:a}=n;let l;e[0]!==a?(l=V("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(ee,{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 kd(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]=y.useState(c),[u,m]=y.useState(100),p=y.useRef(null),h=y.useRef(null),g=s[d];let x;e[0]!==s.length?(x=me=>{f(Math.min(Math.max(me,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 v=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 S=j;if(!g)return null;const k=s.length>1,C=d>0,N=d<s.length-1,_=u>100;let A;e[8]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var me;return(me=p.current)==null?void 0:me.zoomIn()},e[8]=A):A=e[8];const P=A;let E;e[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{var me;return(me=p.current)==null?void 0:me.zoomOut()},e[9]=E):E=e[9];const T=E;let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{var me;return(me=p.current)==null?void 0:me.resetTransform()},e[10]=I):I=e[10];const $=I;let R;e[11]!==N||e[12]!==C||e[13]!==S||e[14]!==v?(R=me=>{me.key==="ArrowLeft"&&C?(me.preventDefault(),v()):me.key==="ArrowRight"&&N?(me.preventDefault(),S()):me.key==="+"||me.key==="="?(me.preventDefault(),P()):me.key==="-"?(me.preventDefault(),T()):me.key==="0"&&(me.preventDefault(),$())},e[11]=N,e[12]=C,e[13]=S,e[14]=v,e[15]=R):R=e[15];const M=R;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D=me=>{if(me.pointerType==="mouse"||me.isPrimary===!1){h.current=null;return}h.current={x:me.clientX,y:me.clientY}},e[16]=D):D=e[16];const O=D;let L;e[17]!==N||e[18]!==C||e[19]!==S||e[20]!==v?(L=me=>{var pe;const Oe=h.current;h.current=null;const Pe=((pe=p.current)==null?void 0:pe.instance.state.scale)??1;if(!Oe||Pe>1.01)return;const Be=me.clientX-Oe.x,oe=me.clientY-Oe.y;Math.abs(Be)<LN||Math.abs(Be)<Math.abs(oe)||(Be>0&&C&&v(),Be<0&&N&&S())},e[17]=N,e[18]=C,e[19]=S,e[20]=v,e[21]=L):L=e[21];const F=L;let z;e[22]!==i?(z=me=>{me||i()},e[22]=i,e[23]=z):z=e[23];let W;e[24]!==a?(W=me=>{me||a==null||a()},e[24]=a,e[25]=W):W=e[25];let U,H,K;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=V("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"),H=r.jsx(Zn,{className:"sr-only",children:"Image viewer"}),K=r.jsx(es,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=U,e[27]=H,e[28]=K):(U=e[26],H=e[27],K=e[28]);let q;e[29]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-white/[0.06]",children:r.jsx(wy,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=q):q=e[29];const Y=g.label||g.alt||"Session image";let G;e[30]!==Y?(G=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:Y}),e[30]=Y,e[31]=G):G=e[31];let J;e[32]!==k||e[33]!==s.length||e[34]!==d?(J=k&&r.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[d+1," of ",s.length]}),e[32]=k,e[33]=s.length,e[34]=d,e[35]=J):J=e[35];let Q;e[36]!==G||e[37]!==J?(Q=r.jsxs("div",{className:"min-w-0 flex-1",children:[G,J]}),e[36]=G,e[37]=J,e[38]=Q):Q=e[38];const X=u<=100;let Z;e[39]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(Fh,{className:"size-3.5","data-icon":"icon"}),e[39]=Z):Z=e[39];let se;e[40]!==X?(se=r.jsx(Mo,{label:"Zoom out",disabled:X,onClick:T,children:Z}),e[40]=X,e[41]=se):se=e[41];let ne;e[42]!==u?(ne=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:$,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]=ne):ne=e[43];const re=u>=sm*100;let ie;e[44]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx($n,{className:"size-3.5","data-icon":"icon"}),e[44]=ie):ie=e[44];let ae;e[45]!==re?(ae=r.jsx(Mo,{label:"Zoom in",disabled:re,onClick:P,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 ue;e[48]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(ct,{className:"size-4","data-icon":"icon"}),e[48]=ue):ue=e[48];let le;e[49]!==i?(le=r.jsx(Mo,{label:"Close image viewer",onClick:i,children:ue}),e[49]=i,e[50]=le):le=e[50];let de;e[51]!==se||e[52]!==ne||e[53]!==ae||e[54]!==le?(de=r.jsxs("div",{className:"flex items-center gap-1",children:[se,ne,ae,te,le]}),e[51]=se,e[52]=ne,e[53]=ae,e[54]=le,e[55]=de):de=e[55];let he;e[56]!==Q||e[57]!==de?(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:[q,Q,de]}),e[56]=Q,e[57]=de,e[58]=he):he=e[58];const xe=g.id;let ce,be,ge;e[59]===Symbol.for("react.memo_cache_sentinel")?(ce={mode:"toggle"},be={step:.005},ge=(me,Oe)=>m(Math.round(Oe.scale*100)),e[59]=ce,e[60]=be,e[61]=ge):(ce=e[59],be=e[60],ge=e[61]);let fe,je;e[62]===Symbol.for("react.memo_cache_sentinel")?(fe={width:"100%",height:"100%"},je={width:"100%",height:"100%"},e[62]=fe,e[63]=je):(fe=e[62],je=e[63]);const Se=g.src,Ae=g.alt,Ie=_?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let Re;e[64]!==Ie?(Re=V("max-h-full max-w-full select-none object-contain",Ie),e[64]=Ie,e[65]=Re):Re=e[65];let De;e[66]!==g.alt||e[67]!==g.src||e[68]!==Re?(De=r.jsx(MN,{wrapperStyle:fe,contentStyle:je,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:Se,alt:Ae,draggable:!1,className:Re})}),e[66]=g.alt,e[67]=g.src,e[68]=Re,e[69]=De):De=e[69];let Le;e[70]!==g.id||e[71]!==De?(Le=r.jsx(IN,{ref:p,minScale:1,maxScale:sm,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ce,wheel:be,onTransform:ge,children:De},xe),e[70]=g.id,e[71]=De,e[72]=Le):Le=e[72];let ze;e[73]!==N||e[74]!==C||e[75]!==S||e[76]!==v||e[77]!==k?(ze=k&&r.jsxs(r.Fragment,{children:[r.jsx(Mo,{label:"Previous image",disabled:!C,onClick:v,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(Vc,{className:"size-5","data-icon":"icon"})}),r.jsx(Mo,{label:"Next image",disabled:!N,onClick:S,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]=N,e[74]=C,e[75]=S,e[76]=v,e[77]=k,e[78]=ze):ze=e[78];let _e;e[79]!==u?(_e=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(la,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=u,e[80]=_e):_e=e[80];let Ce;e[81]!==F||e[82]!==Le||e[83]!==ze||e[84]!==_e?(Ce=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:O,onPointerUp:F,children:[Le,ze,_e]}),e[81]=F,e[82]=Le,e[83]=ze,e[84]=_e,e[85]=Ce):Ce=e[85];let We;e[86]!==b||e[87]!==k||e[88]!==s||e[89]!==d?(We=k&&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((me,Oe)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>b(Oe),"aria-label":`View image ${Oe+1}`,"aria-current":Oe===d?"true":void 0,className:V("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",Oe===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:me.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:Oe+1})]},`${me.id}-${Oe}`))})}),e[86]=b,e[87]=k,e[88]=s,e[89]=d,e[90]=We):We=e[90];let Fe;e[91]!==M||e[92]!==he||e[93]!==Ce||e[94]!==We?(Fe=r.jsxs(Qn,{showCloseButton:!1,onKeyDown:M,className:U,children:[H,K,he,Ce,We]}),e[91]=M,e[92]=he,e[93]=Ce,e[94]=We,e[95]=Fe):Fe=e[95];let Ne;return e[96]!==l||e[97]!==z||e[98]!==W||e[99]!==Fe?(Ne=r.jsx(Jn,{open:l,onOpenChange:z,onOpenChangeComplete:W,children:Fe}),e[96]=l,e[97]=z,e[98]=W,e[99]=Fe,e[100]=Ne):Ne=e[100],Ne}function hc(n){return n.type==="user"}function Cd(n){return n.type==="assistant"}function om(n){return n.type==="progress"}function rm(n){return n.type==="system"}function F1(n){return n.type==="summary"}function zN(n){return n.type==="queue-operation"}function B1(n){return n.type==="attachment"}function FN(n){return n.type==="user"&&n.isCompactSummary===!0}function U1(n){return n.type==="system"&&n.subtype==="compact_boundary"}function im(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function am(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 Ea(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function Aa(n){const e=Ea(n.length);for(const t of n){t.tokenUsage&&am(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=im(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=im(s.toolCalls,e.toolCallCounts),s.tokenUsage&&am(e,s.tokenUsage)}return e}const BN=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,UN=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function WN(n){for(const e of UN){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 HN(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function pr(n){let e=null,t=!1;const s=n.replace(BN,(o,i,a,l)=>(t=!0,e===null&&(e=WN(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const KN=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],qN=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],VN=200,GN=/\bhttps?:\/\/\S+/g;function YN(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,VN).toLowerCase();if(KN.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
52
+ `)+1).slice(-200).replace(GN,"").toLowerCase();return o.includes("?")||qN.some(i=>i.test(o))}function Pa(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
53
+ `)}function lm(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
54
+ `):""}function W1(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 XN=/<task-notification>[\s\S]*?<\/task-notification>/g,JN=/<[^>]*>/g;function QN(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=Pa(n.message.content);return e.includes("<task-notification>")?e.replace(XN,"").replace(JN,"").trim()==="":!1}function ZN(n){if(!B1(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:Pa(t);if(!W1(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??pr(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=pr(s);return{raw:s,sender:i.sender,body:i.body}}const ek=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function tk(n,e){let t=n;for(const[s,o]of ek){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}function nk(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 sk=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,ok=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function rk(n){return Pa(n).trim().replace(sk,"").replace(ok,"").trim()}function ik(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function pi(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 ak(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(v=>v.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 v=b.toolCalls.slice(w+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...x),v.length>0&&e.push({kind:"tool_calls",toolCalls:v,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 lk(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 _d(n){var s;const e=n.map(lk),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 ck(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(F1(o)||U1(o)){t=!1;continue}if(hc(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}Cd(o)&&!t&&(e.push(s),t=!0)}return e}function H1(n){var k,C;const e=[],t=[];let s=null,o=0,i=null,a=null;function l(N){a&&(N.compactionSummary=a.summary,N.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(N,_){let A=x.get(N);A||(A=new Map,x.set(N,A)),A.set(_,(A.get(_)??0)+1)}function w(N,_){const A=x.get(N),P=A==null?void 0:A.get(_);return!A||!P?!1:(P===1?A.delete(_):A.set(_,P-1),!0)}function v(){for(const N of g)N.turn.contentBlocks.push(N.sender?{kind:"agent_message",sender:N.sender,body:N.body,timestamp:N.timestamp}:{kind:"queued_prompt",content:N.content,timestamp:N.timestamp});g.length=0}function j(N){if(!i)return;const _=u.get(N);if(!_||_.length===0)return;i.subAgentActivity.push(..._),u.delete(N);const A=p.has(N)?"background_agent":"sub_agent",P=m.get(N);if(P)P.messages.push(..._);else{const E={kind:A,messages:[..._]};i.contentBlocks.push(E),m.set(N,E)}}function S(){if(i){for(const N of i.toolCalls)j(N.id);for(const[N]of u)j(N);for(const N of i.contentBlocks)if(N.kind==="hook_event")for(const _ of N.events){if(!(_.eventName==="PostToolUse"||_.eventName.startsWith("PostToolUse:"))||!_.toolUseId)continue;const P=i.toolCalls.find(E=>E.id===_.toolUseId);P&&(_.updatedToolOutput&&(P.outputReplacedByHook=!0),_.durationMs!==void 0&&(P.hookDurationMs=(P.hookDurationMs??0)+_.durationMs))}i.contentBlocks=ak(i.contentBlocks),e.push(i),s!==null&&t.push(s),s=null,i=null,m.clear()}}for(o=0;o<n.length;o++){const N=n[o];if(F1(N)){S(),a={summary:N.summary};continue}if(U1(N)){S(),a={meta:ik(N.compactMetadata)};continue}if(FN(N)){S(),s=o,i=pi(N,null),i.compactionSummary=rk(N.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(rm(N)&&N.subtype==="away_summary"&&N.content){c={content:N.content,timestamp:N.timestamp};continue}if(zN(N)){if(i&&N.operation==="enqueue"&&W1(N.content)){const _=pr(N.content);g.push({turn:i,content:N.content,timestamp:N.timestamp,sender:_.sender,body:_.body}),b(i,N.content)}continue}if(B1(N)){const _=ZN(N);i&&_!==null&&!w(i,_.raw)&&g.push({turn:i,content:_.raw,timestamp:((k=N.attachment)==null?void 0:k.timestamp)??N.timestamp,sender:_.sender,body:_.body});continue}if(g.length>0){const _=hc(N)&&!N.isMeta?N.message.content:null;if(typeof _=="string"){const A=g.findIndex(P=>P.content===_);if(A>=0){const[P]=g.splice(A,1);w(P.turn,P.content)}}v()}if(hc(N)&&!N.isMeta){const _=N.message.content;if(typeof _!="string"&&Array.isArray(_)&&_.some(P=>P.type==="tool_result")&&i){for(const E of _)if(E.type==="tool_result"){const T=d.get(E.tool_use_id);T&&(T.turn.toolCalls[T.index].result=lm(E.content),T.turn.toolCalls[T.index].isError=E.is_error===!0,d.delete(E.tool_use_id))}const P=N.toolUseResult;if(P!=null&&P.agentId){const E=((C=_.find(D=>D.type==="tool_result"))==null?void 0:C.tool_use_id)??"",T=h.get(E),I=p.has(E),$=[];if(Array.isArray(P.content))for(const D of P.content)D.type==="text"&&$.push(D.text);const R={agentId:P.agentId,parentToolUseId:E||void 0,agentName:(T==null?void 0:T.name)??null,subagentType:(T==null?void 0:T.subagentType)??null,type:"assistant",content:P.content,toolCalls:[],thinking:[],text:$,timestamp:N.timestamp??"",tokenUsage:P.usage?{input_tokens:P.usage.input_tokens??0,output_tokens:P.usage.output_tokens??0,cache_creation_input_tokens:P.usage.cache_creation_input_tokens??0,cache_read_input_tokens:P.usage.cache_read_input_tokens??0}:null,model:null,isBackground:I,prompt:P.prompt,status:P.status,durationMs:P.totalDurationMs,toolUseCount:P.totalToolUseCount};if(!m.get(E)){i.subAgentActivity.push(R);const O={kind:I?"background_agent":"sub_agent",messages:[R]};i.contentBlocks.push(O),m.set(E,O)}}continue}if(QN(N)){const A={kind:"task_notification",content:Pa(_),timestamp:N.timestamp};if(i){i.contentBlocks.push(A);continue}s=o,i=pi(N,null),i.contentBlocks.push(A),l(i);continue}S(),s=o,i=pi(N,N.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(Cd(N)){let _=function(){I.length>0&&($.contentBlocks.push({kind:"tool_calls",toolCalls:[...I],timestamp:E}),I.length=0)},A=function(){if(T.length>0){const R=$.contentBlocks[$.contentBlocks.length-1];R&&R.kind==="thinking"?R.blocks.push(...T):$.contentBlocks.push({kind:"thinking",blocks:[...T],timestamp:E}),T.length=0}};i||(s=o,i=pi(N,null),l(i)),i.model=N.message.model,N.effort&&(i.effort=N.effort),i.attribution=tk(i.attribution,N);const P=N.message.id;f.has(P)||(f.add(P),i.tokenUsage=nk(i.tokenUsage,N.message.usage));const E=N.timestamp??"",T=[],I=[],$=i;for(const R of N.message.content)if(R.type==="thinking"){_();const M=R;if(!M.thinking)continue;i.thinking.push(M),T.push(M)}else if(R.type==="text"){_(),A();const M=/<thinking>([\s\S]*?)<\/thinking>/g;let D=R.text,O;for(;(O=M.exec(R.text))!==null;){const L=O[1].trim();if(L){const F={type:"thinking",thinking:L,signature:""};i.thinking.push(F),i.contentBlocks.push({kind:"thinking",blocks:[F],timestamp:E})}D=D.replace(O[0],"")}if(D=D.trim(),D){i.assistantText.push(D);const L=i.contentBlocks[i.contentBlocks.length-1];L&&L.kind==="text"?L.text.push(D):i.contentBlocks.push({kind:"text",text:[D],timestamp:E})}}else if(R.type==="tool_use"){A();const M={id:R.id,name:R.name,input:R.input,result:null,isError:!1,timestamp:N.timestamp??""},D=i.toolCalls.length;if(i.toolCalls.push(M),I.push(M),d.set(R.id,{turn:i,index:D}),R.name==="Task"||R.name==="Agent"){const O=R.input;O.run_in_background===!0&&p.add(R.id),h.set(R.id,{name:O.name??null,subagentType:O.subagent_type??null})}}A(),_();continue}if(om(N)&&N.data.type==="agent_progress"){const _=N.data,A=N.parentToolUseID??"";let P=null;if(_.message.type==="assistant"){const R=_.message.message,M=R.id,D=R.usage;D&&M&&!f.has(M)&&(f.add(M),P={input_tokens:D.input_tokens??0,output_tokens:D.output_tokens??0,cache_creation_input_tokens:D.cache_creation_input_tokens??0,cache_read_input_tokens:D.cache_read_input_tokens??0})}const E=_.message.type==="assistant"?_.message.message.model??null:null,T=h.get(A),I={agentId:_.agentId,parentToolUseId:A||void 0,agentName:(T==null?void 0:T.name)??null,subagentType:(T==null?void 0:T.subagentType)??null,type:_.message.type,content:_.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:_.message.timestamp??N.timestamp??"",tokenUsage:P,model:E,isBackground:p.has(A)};if(_.message.type==="assistant"){const R=_.message.message.content;if(Array.isArray(R))for(const M of R)M.type==="thinking"?I.thinking.push(M.thinking):M.type==="text"?I.text.push(M.text):M.type==="tool_use"&&I.toolCalls.push({id:M.id,name:M.name,input:M.input,result:null,isError:!1,timestamp:_.message.timestamp??N.timestamp??""})}else if(_.message.type==="user"){const R=_.message.message.content;if(Array.isArray(R)){for(const M of R)if(M.type==="tool_result"){const D=u.get(A);if(D)for(const O of D){const L=O.toolCalls.find(F=>F.id===M.tool_use_id);L&&(L.result=lm(M.content),L.isError=M.is_error===!0)}}}}let $=u.get(A);$||($=[],u.set(A,$)),$.push(I),i&&j(A);continue}if(om(N)&&N.data.type==="hook_progress"){const _=N.data,A=String(_.hook_event_name??_.hookEvent??"unknown"),P=_.hookSpecificOutput,E={eventName:A,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:(P==null?void 0:P.updatedToolOutput)!==void 0?String(P.updatedToolOutput):void 0,sessionTitle:(P==null?void 0:P.sessionTitle)!==void 0?String(P.sessionTitle):void 0,worktreePath:(P==null?void 0:P.worktreePath)!==void 0?String(P.worktreePath):void 0,timestamp:N.timestamp??""};if(i){const T=i.contentBlocks[i.contentBlocks.length-1];T&&T.kind==="hook_event"?T.events.push(E):i.contentBlocks.push({kind:"hook_event",events:[E],timestamp:N.timestamp})}continue}if(rm(N)&&N.subtype==="turn_duration"&&i){N.durationMs!==void 0&&N.durationMs!==null&&(i.durationMs=(i.durationMs??0)+N.durationMs);continue}}return v(),S(),{turns:_d(e),turnStartIndices:t}}function K1(n){return H1(n).turns}function cm(){return!0}function q1(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function V1(n){return q1(n.split(`
55
+ `))}function G1(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),Cd(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 dk(n){return G1(q1(n))}function uk(n,e){const t=V1(n),s=G1(t),o=K1(t),i=e!=null&&e.skipStats?Ea(o.length):Aa(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function fk(n,e){const t=V1(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=ck(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=K1(o.slice(d)),m=_d([...f,...u]),p=Aa(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 Y1="<task-notification>",mk=/<task-id>([^<]+)<\/task-id>/g,pk=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Rn(n){return typeof n=="object"&&n!==null}function hk(n){const e=Rn(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Rn(s)&&typeof s.text=="string").map(s=>s.text):[]}function gk(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes(Y1)){for(const c of a.matchAll(mk))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(pk))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=Rn(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Rn(a.message)?a.message:null,f=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Rn(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 hk(a))i(c,o);continue}if(a.type==="assistant"){const l=Rn(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!Rn(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const f=Rn(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=Rn(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 xk(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function bk(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=gk(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(Y1))continue;const f=d.operation;f==="enqueue"?e++:(f==="dequeue"||f==="remove")&&e--;continue}if(d.type==="attachment"){const f=Rn(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 xk(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 vk(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function yk(n){return H1(n).turnStartIndices}function X1(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 dm={0:"\0",b:"\b",f:"\f",n:`
56
+ `,r:"\r",t:" ",v:"\v"};function wk(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Li(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 dm){s+=dm[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 Td(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 Ia(n,e){const t=Vn(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=Td(n,e);return s===null?null:{endIndex:s,isString:!1}}function Jt(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=Td(n,t);if(s===null)break;t=s}return t}function Ra(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=Ia(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 J1(n,e){if(!wk(n[e]))return null;let t=e+1;for(;Li(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function jk(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=Jt(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const u=Ra(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 Sk(n){const e=[];for(let t=0;t<n.length;t++){const s=Ia(n,t);if(s){t=s.endIndex-1;continue}if(!n.startsWith("tools",t)||Li(n[t-1])||Li(n[t+5]))continue;let o=Jt(n,t+5),i="";if(n[o]==="."){o=Jt(n,o+1);const c=J1(n,o);if(!c)continue;i=c.value,o=c.endIndex}else if(n[o]==="["){o=Jt(n,o+1);const c=Vn(n,o);if(!c||(o=Jt(n,c.endIndex),n[o]!=="]"))continue;i=c.value,o++}else continue;if(o=Jt(n,o),n[o]!=="(")continue;const a=Ra(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:jk(n,t,l),startIndex:t})}return e}function Q1(n,e){return Vn(n,e)??J1(n,e)}function Nk(n,e,t){const s=[];for(let o=e;o<t;o++){const i=Ia(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 Ed(n,e){let t=Jt(n,0);for(;n[t]==="(";)t=Jt(n,t+1);if(n[t]!=="{")return null;const s=Ra(n,t);if(s===null)return null;let o=t+1;for(;o<s;){if(o=Jt(n,o),n[o]===","){o++;continue}const i=Q1(n,o);if(!i){o++;continue}if(o=Jt(n,i.endIndex),n[o]!==":"){o++;continue}const a=Jt(n,o+1),l=Nk(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=Td(n,o);if(i!==null){o=i-1;continue}const a=Q1(n,o);if(a){if(a.value===e&&!Li(n[o-1])){const l=Jt(n,a.endIndex);if(n[l]===":"){const c=t(Jt(n,l+1));c!==null&&s.push(c)}}o=a.endIndex-1}}return s}function Ad(n,e){return Z1(n,e,t=>{var s;return((s=Vn(n,t))==null?void 0:s.value)??null})}function ex(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 tx(n){const e=Jt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=Ra(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=Ia(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 um(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function kk(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(um(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||!um(d)||s.has(d)||(s.add(d),t.push(d))}return t}function fm(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 mm(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=fm(u.filePath,s),x=fm(h||u.filePath,s),b=p.split(/^@@.*$/m).filter(S=>S.trim()),w=[],v=[];for(const S of b)for(const k of S.split(`
60
+ `))k.startsWith("-")?w.push(k.slice(1)):k.startsWith("+")?v.push(k.slice(1)):k.startsWith(" ")&&(w.push(k.slice(1)),v.push(k.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:v.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:v.join(`
64
+ `)},result:null,isError:!1,timestamp:t})}return o}function nx(n,e,t,s,o=""){return n==="apply_patch"?mm(e,t,s,o):kk(e).flatMap((i,a)=>mm(i,`${t}:patch-${a}`,s,o))}function Ck(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 Pd(n){return typeof n=="object"&&n!==null}const _k=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 hr(n){const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return _k.get(e)??n}function gc(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 Tk(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>Pd(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 Ek(n){return typeof n=="string"?n:Array.isArray(n)?n.filter(e=>Pd(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function sx(n){const e=Ek(n);if(!e)return{text:"",isError:!1};try{const t=JSON.parse(e),s=typeof t.output=="string"?t.output:e,o=Pd(t.metadata)?t.metadata:null,i=o?o.exit_code!==0&&o.exit_code!==void 0:gc(s);return{text:s,isError:i}}catch{return{text:e,isError:gc(e)}}}const Ak=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function Pk(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 Id(n){try{return JSON.parse(n)}catch{return null}}function et(n){return typeof n=="object"&&n!==null}function jo(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 zi(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 Ik=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,Rk=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function ox(n){if(typeof n!="string")return null;const e=Ik.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function rx(n){if(typeof n!="string")return null;const e=Rk.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function $k(n){return Array.isArray(n.images)?n.images.map(ox).filter(e=>e!==null):[]}function Mk(n){return Array.isArray(n.audio)?n.audio.map(rx).filter(e=>e!==null):[]}function ix(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_image").map(e=>ox(e.image_url)).filter(e=>e!==null):[]}function ax(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_audio").map(e=>rx(e.audio_url)).filter(e=>e!==null):[]}function pm(n,e,t=[],s=[],o=[]){const i=[...s.map(l=>`
66
+ ![image](<${l}>)`),...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 Ok(n){var a,l;const e=zi(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 Oo(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function Dk(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function xc(n){const e=n.trim();return!e||Ak.some(t=>e.startsWith(t))?"":e}function Lk(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 zk(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 Fk(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 Js(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 Bk(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 hm(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 Do(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function gm(...n){return n.find(e=>typeof e=="string")}function Uk(n){return n.startsWith("exec-")}function Wk(n){if(!et(n))return{text:Do(n),isError:!1};if("Err"in n)return{text:Do(n.Err),isError:!0};const e=et(n.Ok)?n.Ok:null;if(!e)return{text:Do(n),isError:!1};const t=sx(e.content);return{text:t.text||(e.structuredContent!==void 0?Do(e.structuredContent):Do(e)),isError:e.isError===!0||t.isError}}function Hk(n,e,t){return{id:n?`${n}@${e}`:Pk("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function lx(n){return n.type==="event_msg"&&et(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?xc(n.payload.message):n.type==="response_item"&&et(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?xc(zi(n.payload,"input_text")):""}function Kk(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 lx(n)!==""||ix(e).length>0||ax(e).length>0}return!0}function cx(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 v=et(x.payload.git)?x.payload.git:null;s||(s=v&&typeof v.branch=="string"?v.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=lx(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 dx(n){for(const e of n.split(`
68
+ `)){const t=e.trim();if(t)return jo(Id(t))}return!1}function qk(n){return jo(n[0]??null)}function Vk(n){const e=n.map(Id).filter(jo);return cx(e)}function ux(n,e){const t=cx(n.filter(jo)),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(A,P,E,T={}){const I=c.get(A);let $=u.get(A);if(!$){const M={agentId:A,parentToolUseId:(I==null?void 0:I.parentToolCallId)||void 0,agentName:(I==null?void 0:I.nickname)??(I!=null&&I.agentPath?Oo(I.agentPath):null),subagentType:(I==null?void 0:I.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(I==null?void 0:I.timestamp)??E,tokenUsage:null,model:(I==null?void 0:I.model)??null,isBackground:!1,prompt:(I==null?void 0:I.message)||void 0,status:T.status??"running"};P.subAgentActivity.push(M);const D=P.contentBlocks[P.contentBlocks.length-1];(D==null?void 0:D.kind)==="sub_agent"?D.messages.push(M):P.contentBlocks.push({kind:"sub_agent",messages:[M],timestamp:E}),$={message:M,turn:P},u.set(A,$)}const R=$.message;if(I&&(R.parentToolUseId=I.parentToolCallId||R.parentToolUseId,R.agentName=I.nickname??(I.agentPath?Oo(I.agentPath):R.agentName),R.subagentType=I.agentType,R.model=I.model,R.prompt=I.message||R.prompt),T.text&&!R.text.includes(T.text)&&(R.text.push(T.text),R.content=R.text.join(`
69
+
70
+ `)),T.status){const M=new Set(["completed","failed","interrupted"]);if(T.status==="running"&&R.status&&M.has(R.status)||(R.status=T.status),M.has(T.status)&&R.timestamp&&E){const D=new Date(R.timestamp).getTime(),O=new Date(E).getTime();Number.isFinite(D)&&Number.isFinite(O)&&O>=D&&(R.durationMs=O-D)}}return R}let p=null,h=null,g=t.model||null,x="",b=null,w=!1;const v=[];let j=0,S=null,k=null;function C(A){const P=s.length,E=Bk(s,A,x);return s.length>P&&k!==null&&v.push(k),k=null,E}function N(A,P,E){const T=Hk(A,P,E);return k=S??j,S=null,w||(T.isFragment=!0),b&&(T.compactionSummary=b,b=null),T}function _(A,P,E,T,I){const $=i.get(P);if($){$.input={...$.input,...E},$.result=T,$.isError=T==="failed";return}const R={id:P,name:"WebSearch",input:E,result:T,isError:T==="failed",timestamp:I};i.set(P,R),Js(A,R,I)}for(let A=0;A<n.length;A++){const P=n[A];if(!jo(P))continue;j=A;const E=et(P.payload)?P.payload:void 0,T=P.timestamp??"";if(P.type==="compacted"){p=C(p),b="Conversation compacted",x=T;continue}if(P.type!=="world_state"){if(P.type==="turn_context"){p=C(p),S=A,h=typeof(E==null?void 0:E.turn_id)=="string"?E.turn_id:null,g=typeof(E==null?void 0:E.model)=="string"?E.model:g,x=T,w=!0;continue}if(P.type==="event_msg"&&(E==null?void 0:E.type)==="user_message"&&typeof E.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),w=!0,p??(p=N(h,T,g));const I=(Array.isArray(E.local_images)?E.local_images:[]).filter(R=>typeof R=="string"&&R.length>0),$=(Array.isArray(E.local_audio)?E.local_audio:[]).filter(R=>typeof R=="string"&&R.length>0);p.userMessage=pm(E.message,$k(E),Mk(E),I,$),p.isFragment=!1,p.timestamp=p.timestamp||T,x=T;continue}if(!(!p&&!Kk(P,E))){if(p??(p=N(h,T,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=T),T&&(x=T),P.type==="event_msg"&&(E==null?void 0:E.type)==="token_count"){const I=et(E.info)?E.info:null,$=I?zk(I.last_token_usage):null;$&&(p.tokenUsage=Lk(p.tokenUsage,$));continue}if(P.type==="event_msg"&&(E==null?void 0:E.type)==="web_search_end"&&typeof E.call_id=="string"){const I={};typeof E.query=="string"&&E.query&&(I.query=E.query),et(E.action)&&(I.action=E.action),_(p,E.call_id,I,"completed",T);continue}if(P.type==="event_msg"&&(E==null?void 0:E.type)==="mcp_tool_call_end"&&typeof E.call_id=="string"&&et(E.invocation)){const I=E.invocation,$=typeof I.server=="string"?I.server:"mcp",R=typeof I.tool=="string"?I.tool:"tool",M=et(I.arguments)?I.arguments:{},D=Wk(E.result),O=o.get(E.call_id);O?(O.result=D.text,O.isError=D.isError,o.delete(E.call_id)):Uk(E.call_id)||Js(p,{id:E.call_id,name:`mcp__${$}__${R}`,input:M,result:D.text,isError:D.isError,timestamp:T},T);continue}if(P.type==="event_msg"&&(E==null?void 0:E.type)==="sub_agent_activity"&&typeof E.agent_thread_id=="string"&&typeof E.agent_path=="string"){const I=E.agent_thread_id,$=typeof E.event_id=="string"?E.event_id:"",R=typeof E.kind=="string"?E.kind:"started",M=$?l.get($):void 0,D=d.get(E.agent_path),O=c.get(I)??(D?c.get(D):void 0);if(R!=="started"&&!O&&!M)continue;if(D&&D!==I&&!u.has(I)){const z=u.get(D);z&&(z.message.agentId=I,u.delete(D),u.set(I,z)),c.delete(D)}const L={agentId:I,nickname:(O==null?void 0:O.nickname)??Oo(E.agent_path)??(M==null?void 0:M.taskName)??null,agentPath:E.agent_path,message:(O==null?void 0:O.message)??(M==null?void 0:M.message)??"",model:(O==null?void 0:O.model)??(M==null?void 0:M.model)??null,agentType:(O==null?void 0:O.agentType)??(M==null?void 0:M.agentType)??null,timestamp:(O==null?void 0:O.timestamp)??(T||(M==null?void 0:M.timestamp)||""),parentToolCallId:(O==null?void 0:O.parentToolCallId)??$};c.set(I,L),d.set(E.agent_path,I),$&&(R==="started"||M)&&f.set($,I),m(I,p,T,{status:R==="interrupted"?"interrupted":"running"});continue}if(!(P.type!=="response_item"||!E)){if(E.type==="reasoning"){const I=Array.isArray(E.summary)?E.summary.filter($=>typeof $=="string").join(`
71
+ `):"";Fk(p,I.trim(),T);continue}if(E.type==="message"&&E.role==="assistant"){X1(p,zi(E,"output_text"),T);continue}if(E.type==="message"&&E.role==="user"&&p.userMessage===null){const I=xc(zi(E,"input_text")),$=ix(E),R=ax(E);(I||$.length>0||R.length>0)&&(p.userMessage=pm(I,$,R),p.isFragment=!1,w=!0);continue}if(E.type==="web_search_call"&&typeof E.id=="string"){const I={};et(E.action)&&(I.action=E.action);const $=typeof E.status=="string"?E.status:"completed";_(p,E.id,I,$,T);continue}if(E.type==="tool_search_call"){const I=gm(E.call_id,E.id)??"";if(I){const $={id:I,name:"ToolSearch",input:et(E.arguments)?E.arguments:{},result:null,isError:!1,timestamp:T};o.set(I,$),Js(p,$,T)}continue}if(E.type==="tool_search_output"&&typeof E.call_id=="string"){const I=o.get(E.call_id);if(I){const $=Array.isArray(E.tools)?E.tools:[],R=$.filter(et).map(O=>gm(O.name)??"").filter(Boolean),M=R.length>0?R.length:$.length,D=`Found ${M} tool${M===1?"":"s"}`;I.result=R.length>0?`${D}: ${R.join(", ")}`:D,I.isError=E.status==="failed",o.delete(E.call_id)}continue}if(E.type==="agent_message"&&typeof E.author=="string"){const I=E.author,$=typeof E.recipient=="string"?E.recipient:null,R=Ok(E);if(R.messageType==="NEW_TASK")continue;const M=d.get(I),D=I.startsWith(`${t.agentPath}/`)&&($===null||$===t.agentPath);if(!M&&!D)continue;const O=M??I;M||(c.set(O,{agentId:O,nickname:Oo(I),agentPath:I,message:"",model:null,agentType:null,timestamp:T,parentToolCallId:""}),d.set(I,O));let L;R.messageType==="FINAL_ANSWER"?L="completed":R.messageType==="ERROR"||R.messageType==="FAILED"?L="failed":R.messageType==="INTERRUPTED"?L="interrupted":R.messageType==="MESSAGE"&&(L="running"),m(O,p,T,{status:L,text:R.text||void 0});continue}if(E.type==="function_call"&&typeof E.call_id=="string"){const I=typeof E.name=="string"?E.name:"tool",$=hr(I),R=hm(E.arguments);let M=$,D=R;$==="exec_command"?M="Bash":$==="update_plan"&&(M="TodoWrite",D=Tk(R)),$==="spawn_agent"&&l.set(E.call_id,{callId:E.call_id,message:Dk(R.message),taskName:typeof R.task_name=="string"?R.task_name:null,model:typeof R.model=="string"?R.model:null,agentType:typeof R.agent_type=="string"?R.agent_type:null,timestamp:T});const O={id:E.call_id,name:M,input:D,result:null,isError:!1,timestamp:T};o.set(O.id,O),Js(p,O,T);continue}if(E.type==="function_call_output"&&typeof E.call_id=="string"){const I=o.get(E.call_id);if(!I)continue;const $=typeof E.output=="string"?E.output:null;if(I.result=$,I.isError=gc($),o.delete(E.call_id),I.name==="spawn_agent"&&$)try{const R=JSON.parse($),M=typeof R.agent_id=="string"?R.agent_id:f.get(I.id)??"",D=typeof R.task_name=="string"?R.task_name:null,O=typeof R.nickname=="string"?R.nickname:D?Oo(D):null;if(M){const L=l.get(I.id),F=c.get(M),z={agentId:M,nickname:O??(F==null?void 0:F.nickname)??(L==null?void 0:L.taskName)??null,agentPath:D??(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)??T,parentToolCallId:(F==null?void 0:F.parentToolCallId)??I.id};c.set(M,z),f.set(I.id,M),z.agentPath&&d.set(z.agentPath,M),m(M,p,T,{status:"running"})}}catch{}if(I.name==="wait_agent"&&$&&p)try{const R=JSON.parse($),M=et(R.status)?R.status:{};for(const[D,O]of Object.entries(M)){const L=et(O)?O:{},F=typeof L.completed=="string"?L.completed:"",z=typeof L.failed=="string"?L.failed:typeof L.error=="string"?L.error:"",W=typeof L.interrupted=="string"?L.interrupted:"",U=F?"completed":z?"failed":W?"interrupted":typeof L.status=="string"?L.status:"running";c.has(D)||c.set(D,{agentId:D,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:T,parentToolCallId:""}),m(D,p,T,{status:U,text:F||z||W||void 0})}}catch{}continue}if(E.type==="custom_tool_call"&&typeof E.call_id=="string"){const I=typeof E.name=="string"?E.name:"tool",$=typeof E.input=="string"?E.input:"",R=E.call_id,M=$?nx(I,$,R,T,t.cwd):[];if(I!=="apply_patch"){const D={id:R,name:I==="exec_command"?"Bash":I,input:hm($),result:null,isError:!1,timestamp:T};o.set(D.id,D),Js(p,D,T)}for(const D of M)o.set(D.id,D),Js(p,D,T);M.length>0&&a.set(R,{calls:M,direct:I==="apply_patch"});continue}if(E.type==="custom_tool_call_output"&&typeof E.call_id=="string"){const I=E.call_id,{text:$,isError:R}=sx(E.output),M=a.get(I);if(M){const O=M.direct&&R?new Set(M.calls.map(L=>L.id)):Ck($,R,M.calls);for(const L of M.calls){const F=o.get(L.id);F&&(F.result=$,F.isError=O.has(F.id),o.delete(F.id))}a.delete(I)}const D=o.get(I);D&&(D.result=$,D.isError=R,o.delete(I));continue}}}}}return C(p),{turnStartIndices:v,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?Ea(s.length):Aa(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function Rd(n,e){const t=n.split(`
72
+ `).map(i=>i.trim()).filter(Boolean).map(Id).filter(jo),{turnStartIndices:s,...o}=ux(t,e);return o}function Gk(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
73
+ `);return Rd(t?`${t}
74
+ ${e}`:e)}const Yk=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function Xk(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 hi(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return et(e)?e:null}catch{return null}}function Jk(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=hr(typeof u.name=="string"?u.name:"");if(m==="spawn_agent"){const p=hi(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=hi(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=hi(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=hi(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=Xk(u).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!Yk.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 Qk(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=Jk(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?hr(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 Zk(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 eC(n){return ux(n,{skipStats:!0}).turnStartIndices}const tC=/^(?: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 fx(n){return typeof n.agentId!="string"||n.agentId.length===0}function mx(n){return!Pt(n)||typeof n.type!="string"||!Pt(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||tC.test(n.type)}function px(n){try{const e=JSON.parse(n);return mx(e)?e:null}catch{return null}}function nC(n){return n.split(`
76
+ `).map(e=>e.trim()).filter(Boolean).map(px).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 Ho(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 xm(n){const e=rs(n,"copilot-turn"),t=we(n.data.turnId);return t?`${t}@${e}`:e}function vl(n,e){if(!Pt(n))return;const t=we(n.cwd),s=we(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function hx(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(!fx(t))continue;const{data:s}=t,o=Ho(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))),vl(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){vl(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){vl(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 sC(n){for(const e of n.split(`
77
+ `)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(mx(s))return!0}catch{}}return!1}function oC(n){var e;return bC((e=n[0])==null?void 0:e.type)}function rC(n){const e=n.map(t=>px(t.trim())).filter(t=>t!==null);return hx(e)}function yl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function bm(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 iC(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 aC(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 gx(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=aC(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 lC(n,e){const t=we(n.content),s=gx(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function cC(n,e){return Pt(n.result)?gx([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function Ei(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 bc(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 dC(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=bc(t.usage,!0);s&&(e=Ei(e,s))}return e}function uC(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 fC(n){return Array.isArray(n)?n.map(uC).filter(e=>e!==null):[]}function mC(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:fC(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function pC(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(mC).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function Ko(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 Fi(n,e){const t=Pt(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?pC(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 hC(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?"":yl(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?yl(t.structuredContent):yl(t)}function vm(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 gi(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 qo(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function ym(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=Ko(a);s.push(qo(i,l,Fi(l,o.arguments),e))}return s}function wm(n,e,t,s){n.name=e,n.input=Fi(e,t),n.timestamp=s||n.timestamp}function jm(n,e,t){n.result=hC(e);const s=cC(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function Sm(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 gC(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function xx(n,e){const t=nC(n),s=hx(t),o=iC(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,N){N&&d.set(C,N)}function w(C){return u||(u=Sm(xm(C),Ho(C),null,m,p,!0)),u}function v(){u&&(gC(u)&&i.push(u),u=null)}function j(C){var $;const N=typeof C.agentId=="string"?C.agentId:"";if(!N)return null;const _=l.get(N);if(_)return _.message;const A=C.data,P=we(A.toolCallId),E=P?(($=a.get(P))==null?void 0:$.turn)??u:u;if(!E)return null;const T=we(A.executionMode),I={agentId:N,...P?{parentToolUseId:P}:{},agentName:we(A.agentDisplayName,A.agentName)||null,subagentType:we(A.agentType,A.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:Ho(C),tokenUsage:null,model:we(A.model)||null,isBackground:T==="background",...we(A.description)?{prompt:we(A.description)}:{},status:"running"};return E.subAgentActivity.push(I),E.contentBlocks.push({kind:I.isBackground?"background_agent":"sub_agent",messages:[I],timestamp:I.timestamp}),l.set(N,{message:I,turn:E}),I}function S(C){if(fx(C))return!1;const N=j(C);if(!N)return!0;const{data:_}=C,A=Ho(C);if(C.type==="subagent.started"||C.type==="subagent.configured")return N.parentToolUseId||(N.parentToolUseId=we(_.toolCallId)||void 0),N.agentName=we(_.agentDisplayName,_.agentName)||N.agentName,N.subagentType=we(_.agentType,_.agentName)||N.subagentType,N.model=we(_.model)||N.model,N.prompt||(N.prompt=we(_.description)||void 0),N.isBackground||(N.isBackground=we(_.executionMode)==="background"),N.status="running",!0;if(C.type==="subagent.completed"||C.type==="subagent.failed"){N.agentName=we(_.agentDisplayName,_.agentName)||N.agentName,N.subagentType=we(_.agentType,_.agentName)||N.subagentType,N.model=we(_.model)||N.model,N.durationMs=Hn(_.durationMs)||N.durationMs,N.toolUseCount=Hn(_.totalToolCalls)||N.toolUseCount,N.status=C.type==="subagent.completed"?"completed":"failed";const P=we(_.error,_.message);return P&&!N.text.includes(P)&&N.text.push(P),!0}if(C.type==="user.message")return N.prompt||(N.prompt=we(_.content)||void 0),!0;if(C.type==="assistant.reasoning"){const P=we(_.content);return P&&!N.thinking.includes(P)&&N.thinking.push(P),!0}if(C.type==="assistant.message"){N.model=we(_.model)||N.model;const P=we(_.reasoningText);P&&!N.thinking.includes(P)&&N.thinking.push(P);const E=bm(_.content);E&&!N.text.includes(E)&&N.text.push(E);for(const T of ym(_.toolRequests,A,I=>c.has(I)))N.toolCalls.push(T),c.set(T.id,{call:T,message:N});return!0}if(C.type==="assistant.usage"){N.model=we(_.model)||N.model;const P=bc(_);return P&&(N.tokenUsage=Ei(N.tokenUsage,P)),!0}if(C.type==="tool.execution_start"){const P=we(_.toolCallId)||rs(C,"copilot-agent-tool"),E=we(_.toolName)||"Tool",T=Ko(E),I=c.get(P);if(I)wm(I.call,T,_.arguments,A);else{const $=qo(P,T,Fi(T,_.arguments),A);N.toolCalls.push($),c.set(P,{call:$,message:N})}return!0}if(C.type==="tool.execution_complete"){const P=we(_.toolCallId)||rs(C,"copilot-agent-tool");let E=c.get(P);if(!E){const T=we(_.toolName)||"Tool",I=Ko(T),$=qo(P,I,{},A);N.toolCalls.push($),E={call:$,message:N}}return jm(E.call,_,o),c.delete(P),!0}return!0}for(const C of t){if(S(C))continue;const{data:N}=C,_=Ho(C);if(C.type==="session.start"||C.type==="session.resume"){m=we(N.selectedModel)||m,p=we(N.reasoningEffort)||p;continue}if(C.type==="session.auto_mode_resolved"){m=we(N.chosenModel)||m,u&&(u.model=m);continue}if(C.type==="session.model_change"){m=we(N.newModel)||m;const A=N.reasoningEffort;typeof A=="string"&&(p=A),u&&(u.model=m,p&&(u.effort=p));continue}if(C.type==="session.shutdown"){m=we(N.currentModel)||m,u&&!u.model&&(u.model=m),x=dC(N)??x;const A=Hn(N.totalApiDurationMs);u&&!g&&A&&f.set(u,A);continue}if(C.type==="user.message"){v(),u=Sm(xm(C),_,lC(N,o),m,p,!1),b(u,_);continue}if(C.type==="assistant.turn_start"){m=we(N.model)||m;const A=w(C);A.model=m,p&&(A.effort=p),b(A,_);continue}if(C.type==="assistant.reasoning"){const A=w(C);vm(A,we(N.content),_,we(N.reasoningId)||rs(C,"copilot-thinking")),b(A,_);continue}if(C.type==="assistant.message"){m=we(N.model)||m;const A=w(C);A.model=m,p&&(A.effort=p),vm(A,we(N.reasoningText),_,rs(C,"copilot-thinking")),X1(A,bm(N.content),_);for(const P of ym(N.toolRequests,_,E=>a.has(E)))gi(A,P,_),a.set(P.id,{call:P,turn:A});b(A,_);continue}if(C.type==="assistant.usage"){m=we(N.model)||m,p=we(N.reasoningEffort)||p;const A=bc(N),P=Hn(N.duration);A&&(h=!0),P&&(g=!0);const E=w(C);E.model=m,p&&(E.effort=p),A&&(E.tokenUsage=Ei(E.tokenUsage,A)),P&&f.set(E,(f.get(E)??0)+P),b(E,_);continue}if(C.type==="tool.execution_start"){m=we(N.model)||m;const A=w(C);A.model=m;const P=we(N.toolCallId)||rs(C,"copilot-tool"),E=we(N.toolName)||"Tool",T=Ko(E),I=a.get(P);if(I)wm(I.call,T,N.arguments,_);else{const $=qo(P,T,Fi(T,N.arguments),_);gi(A,$,_),a.set(P,{call:$,turn:A})}b(A,_);continue}if(C.type==="tool.execution_complete"){m=we(N.model)||m;const A=we(N.toolCallId)||rs(C,"copilot-tool");let P=a.get(A);if(!P){const E=w(C),T=we(N.toolName)||"Tool",I=Ko(T),$=qo(A,I,{},_);gi(E,$,_),P={call:$,turn:E}}jm(P.call,N,o),a.delete(A),b(P.turn,_);continue}if(C.type==="session.error"){const A=w(C),E={errorType:we(N.errorType)||"unknown"};typeof N.statusCode=="number"&&(E.statusCode=N.statusCode),typeof N.errorCode=="string"&&(E.errorCode=N.errorCode),gi(A,{id:rs(C,"copilot-error"),name:"Error",input:E,result:we(N.message)||"Copilot session error",isError:!0,timestamp:_},_),b(A,_);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&u&&b(u,_)}if(v(),!h&&x&&i.length===1&&(i[0].tokenUsage=Ei(i[0].tokenUsage,x)),s.model)for(const C of i)C.model||(C.model=s.model);for(const C of i){const N=d.get(C),_=Date.parse(C.timestamp),A=N?Date.parse(N):Number.NaN;if(Number.isFinite(_)&&Number.isFinite(A)&&A>=_)C.durationMs=A-_;else{const P=f.get(C)??0;P&&(C.durationMs=P)}}const k=e!=null&&e.skipStats?Ea(i.length):Aa(i);return!(e!=null&&e.skipStats)&&!h&&x&&i.length>1&&(k.totalInputTokens=x.input_tokens,k.totalOutputTokens=x.output_tokens,k.totalCacheCreationTokens=x.cache_creation_input_tokens??0,k.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:k,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function xC(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
80
+ `);return xx(t?`${t}
81
+ ${e}`:e)}function bC(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 vC(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"?hr(a.toolName):typeof a.name=="string"?hr(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 yC(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function wC(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 bx=ps[ps.length-1],jC={kind:"codex",descriptor:on("codex"),detectsText:dx,detectsRecords:qk,parse:Rd,append:Gk,metadataFromLines:Vk,status:Qk,brandBranch:Zk,turnBoundaries:eC},SC={kind:"copilot",descriptor:on("copilot"),detectsText:sC,detectsRecords:oC,parse:xx,append:xC,metadataFromLines:rC,status:vC,brandBranch:yC,turnBoundaries:wC},NC={kind:"claude",descriptor:on("claude"),detectsText:cm,detectsRecords:cm,parse:uk,append:fk,metadataFromLines:dk,status:bk,brandBranch:vk,turnBoundaries:yk},kC=Object.freeze({claude:NC,codex:jC,copilot:SC});function CC(n){function e(t){for(const s of ps){const o=n[s];if(t(o))return o}return n[bx]}return{formatFor:t=>n[t],formatForText:t=>e(s=>s.detectsText(t)),formatForRecords:t=>e(s=>s.detectsRecords(t))}}const $d=CC(kC);function vx(n){return $d.formatFor(n)}function yx(n){return $d.formatForText(n)}function wx(n){return $d.formatForRecords(n)}function jx(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 Sx(n,e,t){return jx(n,e)[t]??e.length}function _C(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:jx(n,e).find(o=>o>s)??"keep-all"}function TC(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 EC(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 Nx(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||TC(e,o)||s.isError&&EC(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 AC(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
82
+ `)}function $a(n,e){return yx(n).parse(n,e)}function PC(n,e){const t=wx(n.rawMessages);return(t.kind===bx?yx(e):t).append(n,e)}function Ma(n){return n===null?"":typeof n=="string"?n:AC(n)}function kx(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const Cx=y.createContext(null);function IC(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=kx(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 RC(n){const e=B.c(10),{images:t,children:s}=n,[o,i]=y.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(kd,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i($C),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(Cx.Provider,{value:d,children:[s,f]}),e[6]=s,e[7]=f,e[8]=d,e[9]=u):u=e[9],u}function $C(n){return n?{...n,open:!1}:null}function MC(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=IC(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(RC,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function _x(){return y.useContext(Cx)}const Tx=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function OC(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:Tx.has(n.slice(e).toLowerCase())}function Md(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:OC(n)}function DC(n){return n&&(Md(n)?Ar(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function vc(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=Sn("hostFiles"),[d,f]=y.useState(!1),[u,m]=y.useState(!1),[p,h]=y.useState(),g=_x();let x;e[0]!==c||e[1]!==t?(x=Md(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:DC(t),e[3]=b,e[4]=t,e[5]=w):w=e[5];const v=w;let j;e[6]!==s||e[7]!==l||e[8]!==v?(j=v?{id:l,src:v,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=v,e[9]=j):j=e[9];const S=j;let k;e[10]!==g||e[11]!==S?(k=()=>{S&&(g?g.openImage(S):(m(!0),f(!0)))},e[10]=g,e[11]=S,e[12]=k):k=e[12];const C=k;if(b){let D;return e[13]!==s?(D=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=D):D=e[14],D}if(v&&p===v){const D=s?`: ${s}`:"";let O;return e[15]!==D?(O=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",D]}),e[15]=D,e[16]=O):O=e[16],O}const N=`Open ${s||"rendered image"}`;let _;e[17]!==i?(_=V("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 A=s??"";let P;e[19]!==v?(P=()=>h(v),e[19]=v,e[20]=P):P=e[20];let E;e[21]!==a?(E=V("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=E):E=e[22];let T;e[23]!==v||e[24]!==E||e[25]!==A||e[26]!==P?(T=r.jsx("img",{src:v,alt:A,loading:"lazy",decoding:"async",onError:P,className:E}),e[23]=v,e[24]=E,e[25]=A,e[26]=P,e[27]=T):T=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=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(la,{className:"size-3.5","data-icon":"icon"})}),e[28]=I):I=e[28];let $;e[29]!==C||e[30]!==T||e[31]!==N||e[32]!==_?($=r.jsxs(ee,{type:"button",variant:"ghost",onClick:C,"aria-label":N,className:_,children:[T,I]}),e[29]=C,e[30]=T,e[31]=N,e[32]=_,e[33]=$):$=e[33];let R;e[34]!==d||e[35]!==u||e[36]!==S?(R=u&&S&&r.jsx(kd,{open:d,images:[S],initialIndex:0,onClose:()=>f(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=u,e[36]=S,e[37]=R):R=e[37];let M;return e[38]!==$||e[39]!==R?(M=r.jsxs(r.Fragment,{children:[$,R]}),e[38]=$,e[39]=R,e[40]=M):M=e[40],M}function LC(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=V("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 zC(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=V("[&_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 FC(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=V("[&_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 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=V("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 UC(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=V("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 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=V("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 HC(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 KC(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=Sn("hostFiles");let a;e[4]!==s?(a=HC(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?ur(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 qC=[...Tx].map(n=>n.slice(1)).join("|"),VC=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${qC}))[ \\t]*$`,"gim");function Ex(n){return n.replace(VC,(e,t,s)=>`${t}![${s}](${s})`)}const Fn={code:v5,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:KC,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(Rt,{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(LC,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(zC,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(FC,{children:n})},tr({children:n}){return r.jsx(BC,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(UC,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(WC,{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:vc,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Gs=[pa],GC=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],YC=GC.join("|");function Ax(){return new RegExp(`<(${YC})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function Od(n){return n.replace(Ax(),"").trim()}function XC(n){return Ax().test(n)}const JC=/<command-message>([^<]+)<\/command-message>/,QC=/<command-name>([\s\S]*?)<\/command-name>/,ZC=/<command-args>([\s\S]*?)<\/command-args>/;function Px(n){const e=n.match(JC);if(e)return e[1];const t=n.match(QC);return t?t[1].trim().replace(/^\//,""):null}function Ix(n){const e=n.match(ZC);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const Rx={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},e_=new RegExp(`<(${Object.keys(Rx).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function t_(n){const e=[],t=n.replace(e_,(s,o,i)=>(e.push({text:Zg(i).trim(),stream:Rx[o]}),"")).trim();return{outputs:e,remainingText:t}}const n_=/<task-notification>([\s\S]*?)<\/task-notification>/g;function Qs(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function gr(n){const e=[],t=n.replace(n_,(s,o)=>(e.push({taskId:Qs(o,"task-id"),toolUseId:Qs(o,"tool-use-id"),outputFile:Qs(o,"output-file"),status:Qs(o,"status"),summary:Qs(o,"summary"),result:Qs(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const s_=/\[Request interrupted by user[^\]]*\]/g;function $x(n){const e=[],t=n.replace(s_,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const Nm="[SYSTEM NOTIFICATION - NOT USER INPUT]";function Mx(n){const e=n.indexOf(Nm);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+Nm.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 km={Icon:N4,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},Cm={completed:{Icon:S4,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...km,label:"Failed"},error:{...km,label:"Error"},running:{Icon:k4,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function Ox(n){const e=B.c(32),{notification:t}=n,[s,o]=y.useState(!1),i=Cm[t.status]??Cm.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?nt:Je;let d;e[0]!==i.bg?(d=V("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=V("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(Wt,{render:r.jsx(ee,{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(ft,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(On,{components:Fn,remarkPlugins:Gs,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(ut,{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 o_(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}=gr(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(r_)}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 r_(n,e){return r.jsx(Ox,{notification:n},n.taskId||`notification-${e}`)}function i_(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=V("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(xo,{className:V("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 a_(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(e1,{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(On,{components:Fn,remarkPlugins:Gs,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 Dd=y.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=_x(),[l,c]=y.useState(!1),[d,f]=y.useState(!1),[u,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),[b,w]=y.useState(null),v=y.useMemo(()=>Ma(e),[e]),j=y.useMemo(()=>Px(v),[v]),S=y.useMemo(()=>Ix(v),[v]),{sender:k,body:C,matched:N}=y.useMemo(()=>pr(v),[v]),_=y.useMemo(()=>Od(C),[C]),{text:A,isSystemNotification:P}=y.useMemo(()=>Mx(_),[_]),{notifications:E,remainingText:T}=y.useMemo(()=>gr(A),[A]),{outputs:I,remainingText:$}=y.useMemo(()=>t_(T),[T]),{interrupts:R,remainingText:M}=y.useMemo(()=>$x($),[$]),D=y.useCallback(async q=>{if(!q){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!j)){x(!0),m(!0);try{const Y=await o(j,S??void 0);h(Y)}finally{x(!1)}}},[p,o,j,S]),O=y.useMemo(()=>kx(e),[e]),L=y.useMemo(()=>O.map(q=>`data:${q.source.media_type};base64,${q.source.data}`),[O]),F=y.useMemo(()=>L.map((q,Y)=>({id:`message-attachment-${Y}`,src:q,alt:`Attachment ${Y+1}`,label:L.length>1?`Attachment ${Y+1}`:"Attached image"})),[L]),z=y.useMemo(()=>XC(v)||P||N,[v,P,N]),W=d?v:M,H=W.length>500&&!l?W.slice(0,500)+"...":W,K=q=>{const Y=F[q];Y&&(a?a.openImage(Y):w({index:q,open:!0}))};return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:z&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>f(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(ca,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(Co,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&P&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ee,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(xo,{"data-icon":"inline-start"}),"System event"]})}),!d&&N&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ee,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(Xn,{"data-icon":"inline-start"}),k?`From ${k}`:"Teammate message"]})}),j&&r.jsxs(ut,{open:u,onOpenChange:q=>void D(q),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(xo,{"data-icon":"inline-start"}),"/",j,S&&r.jsx("span",{className:"text-muted-foreground",children:S})]}),o&&r.jsxs(Wt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[u?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),u?"Collapse":"Expand"]}),u&&s&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(j),className:"text-muted-foreground",children:[r.jsx(Ws,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(ft,{children:r.jsx(a_,{loading:g,content:p})})]}),L.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:L.map((q,Y)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>K(Y),"aria-label":`Open attached image ${Y+1}`,className:V("group/image relative h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 text-left","transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"),children:[r.jsx("img",{src:q,alt:`Attachment ${Y+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(la,{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]})]},`${O[Y].source.media_type}-${O[Y].source.data.slice(0,24)}-${Y}`))}),!d&&E.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:E.map(q=>r.jsx(Ox,{notification:q},q.taskId))}),!d&&I.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:I.map((q,Y)=>r.jsx(i_,{output:q},Y))}),!d&&R.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((q,Y)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(jy,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:q})]},Y))}),H&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(On,{components:Fn,remarkPlugins:Gs,children:H})}),W.length>500&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>c(!l),className:"mt-1 -ml-2 text-muted-foreground",children:l?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(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(kd,{open:b.open,images:F,initialIndex:b.index,onClose:()=>w(q=>q?{...q,open:!1}:null),onCloseComplete:()=>w(null)},b.index)]})}),Dx=y.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(Dd,{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}),Lx=y.memo(function(e){const t=B.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=y.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=A=>{i==null||i(A),l(A)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-none px-3 py-2"}),t[2]=h):h=t[2];let g;t[3]!==c?(g=c?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Nr,{"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 v=`${w}% of tasks complete`;let j;t[11]!==m||t[12]!==v?(j=r.jsx(rd,{value:m,className:"max-w-[200px] flex-1","aria-label":v}),t[11]=m,t[12]=v,t[13]=j):j=t[13];let S;t[14]!==s.inProgress?(S=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]=S):S=t[15];let k;t[16]!==g||t[17]!==b||t[18]!==j||t[19]!==S?(k=r.jsxs(Wt,{render:h,children:[g,x,b,j,S]}),t[16]=g,t[17]=b,t[18]=j,t[19]=S,t[20]=k):k=t[20];let C;t[21]!==d?(C=d.map(l_),t[21]=d,t[22]=C):C=t[22];let N;t[23]!==C?(N=r.jsx(ft,{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]=N):N=t[24];let _;return t[25]!==c||t[26]!==p||t[27]!==k||t[28]!==N?(_=r.jsxs(ut,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[k,N]}),t[25]=c,t[26]=p,t[27]=k,t[28]=N,t[29]=_):_=t[29],_});function l_(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(Yn,{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(Gc,{className:"size-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:V("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 Ur(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]=y.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 zx(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function c_(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const d_="cogpit:provider-update-dismissals:v1";function u_(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(zx(t)))}async function f_(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 m_(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 p_=360*60*1e3;function h_(){const[n,e]=y.useState([]),[t,s]=Ur(d_,[]),[o,i]=y.useState(null),[a,l]=y.useState(null);y.useEffect(()=>{const f=new AbortController,u=()=>{f_(f.signal).then(e).catch(()=>{})};u();const m=setInterval(u,p_);return()=>{f.abort(),clearInterval(m)}},[]);const c=y.useCallback(async f=>{i(f),l(null);try{const u=await m_(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=y.useCallback(f=>{s(u=>c_(u,zx(f)))},[s]);return{pending:u_(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:y.useCallback(()=>l(null),[])}}const g_=5e3,x_={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 wl(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${x_[n]}`}function _m(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function Fx(){const n=B.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=h_(),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 T=setTimeout(a,g_);return()=>clearTimeout(T)},f=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=f):(d=n[2],f=n[3]),y.useEffect(d,f),s){let T;return n[4]!==a||n[5]!==s.message||n[6]!==c?(T=c?r.jsxs(St,{className:wl("success"),children:[r.jsx(ra,{}),r.jsx(It,{children:s.message}),r.jsx(Nt,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(St,{className:wl("destructive"),children:[r.jsx(Ks,{}),r.jsx(It,{children:"Update did not complete"}),r.jsx(Nt,{className:"text-destructive/80",children:s.message}),r.jsx(vs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(ee,{variant:"ghost",size:"xs",onClick:a,children:"Dismiss"})})]}),n[4]=a,n[5]=s.message,n[6]=c,n[7]=T):T=n[7],T}if(e.length===0)return null;const u=e[0],m=e.filter(T=>T.updateCommand!==null&&l),p=St;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=wl("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(rt,{className:"animate-spin"}):r.jsx(kn,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==u||n[12]!==e?(x=e.length===1?_m(u):`${e.map(b_).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(_m).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 v;n[16]!==w?(v=r.jsx(Nt,{className:"text-warning/80",children:w}),n[16]=w,n[17]=v):v=n[17];const j=vs,S="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let k;n[18]!==e.length||n[19]!==o||n[20]!==t?(k=T=>r.jsxs(ee,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(T.provider),children:[r.jsx(tc,{"data-icon":"inline-start"}),t===T.provider?"Updating…":e.length===1?"Update":`Update ${T.displayName}`]},T.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=k):k=n[21];const C=m.map(k),N=t!==null;let _;n[22]!==i||n[23]!==e?(_=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=_):_=n[24];let A;n[25]!==N||n[26]!==_?(A=r.jsx(ee,{variant:"ghost",size:"xs",disabled:N,onClick:_,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=N,n[26]=_,n[27]=A):A=n[27];let P;n[28]!==j||n[29]!==C||n[30]!==A?(P=r.jsxs(j,{className:S,children:[C,A]}),n[28]=j,n[29]=C,n[30]=A,n[31]=P):P=n[31];let E;return n[32]!==p||n[33]!==P||n[34]!==h||n[35]!==g||n[36]!==b||n[37]!==v?(E=r.jsxs(p,{className:h,children:[g,b,v,P]}),n[32]=p,n[33]=P,n[34]=h,n[35]=g,n[36]=b,n[37]=v,n[38]=E):E=n[38],E}function b_(n){return n.displayName}function Bx(){const n=B.c(27),[e,t]=y.useState(null),[s,o]=y.useState(null),[i,a]=y.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]),y.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(tc,{}),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(Nt,{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(vs,{className:"static col-start-3 row-span-2 row-start-1 self-center",children:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:m,"aria-label":"Dismiss update",children:r.jsx(ct,{"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(tc,{}),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(Nt,{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(ee,{variant:"outline",size:"xs",render:r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer"}),nativeButton:!1,children:[r.jsx(Sy,{"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(ee,{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(vs,{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 Ux=y.createContext(null);function Ai(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(Ux.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Lt(){const n=y.useContext(Ux);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const xr=null,{min:Is,max:gn,abs:Tm,floor:v_}=Math,Wx=(n,e,t)=>Is(t,gn(e,n)),Hx=n=>[...n].sort((e,t)=>e-t),Kx=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},yc=()=>{let n;return[new Promise(e=>{n=e}),n]},qx=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},Zo=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},Vx=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},y_=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=Is(e,n.i),s},Pi=(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+=Vx(n,t),n.u[++t]=s;return n.i=e,s},Zs=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=v_((t+s)/2);Pi(n,i)<=e?(o=i,t=i+1):s=i-1}return Wx(o,0,n.l-1)},Em=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:Is(e-1,n.i),n.l=e,s>0?(Zo(n.u,s),Zo(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))},w_=typeof window<"u",j_=n=>n.documentElement,S_=n=>n.ownerDocument,N_=n=>n.defaultView,Gx=qx(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),k_=qx(()=>"scrollBehavior"in j_(document).style),C_=n=>gn(n.h(),n.p()),__=(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=xr,x=[0,i?gn(t-1,0):-1],b=0,w=!1;const v=((T,I,$)=>({o:I,t:$?Zo($.slice(0,Is(T,$.length)),gn(0,T-$.length)):Zo([],T),l:T,i:-1,u:Zo([],T+1)}))(n,s?s[1]:e,s&&s[0]),j=new Set,S=()=>d-c,k=()=>S()+u+f,C=(T,I)=>(($,R,M,D)=>{if(D=Is(D,$.l-1),Pi($,D)<=R){const O=Zs($,M,D);return[Zs($,R,D,O),O]}{const O=Zs($,R,void 0,D);return[O,Zs($,M,O)]}})(v,T,I,x[0]),N=()=>Pi(v,v.l),_=(T,I)=>{const $=Pi(v,T)-u;return I?N()-$-A(T):$},A=T=>Vx(v,T),P=(T,I=-1)=>v.t[T]===I,E=T=>{T&&(Gx()&&p!==0||g&&h===1?u+=T:f+=T)};return{v:()=>{j.clear()},m:()=>a,_:()=>(T=>[T.t.slice(),T.o])(v),S:(T=200)=>{if(!w||i)return x;let I,$;if(m)[I,$]=x;else{let R=gn(0,k()),M=R+l;o||(T=gn(0,T),p!==1&&(R-=T),p!==2&&(M+=T)),[I,$]=x=C(gn(0,R),gn(0,M)),g&&(I=Is(I,g[0]),$=gn($,g[1]))}return[gn(I,0),Is($,v.l-1)]},$:T=>Zs(v,T-c),I:P,k:_,R:A,T:()=>v.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:N,H:()=>(m=f,f=0,[m,h===2]),W:(T,I)=>{const $=[T,I];return j.add($),()=>{j.delete($)}},B:(T,I)=>{let $,R,M=0;switch(T){case 1:{if(I===d&&h===0)break;const D=m;m=0;const O=I-d,L=Tm(O);D&&L<Tm(D)+1||h!==0||(p=O<0?2:1),i&&(i=!1),d=I,M=4;const F=S();F>=-l&&F<=N()&&(M+=1,R=L>l);break}case 2:M=8,p!==0&&($=!0,M+=1),p=0,h=0,g=xr;break;case 3:{const D=I.filter(([O,L])=>!P(O,L));if(!D.length)break;E(D.reduce((O,[L,F])=>{let z;if(h===2)z=!0;else if(g&&h===1)z=L<g[0];else{const W=S(),U=_(L),H=A(L);z=p!==1&&h===0?U+H<=W:U<W&&U+H<W+l}return z&&(O+=F-A(L)),O},0));for(const[O,L]of D){const F=A(O),z=y_(v,O,L);o&&(b+=z?L:L-F)}o&&l&&b>l&&(E(((O,L)=>{let F=0;const z=[];O.t.forEach((Y,G)=>{Y!==-1&&(z.push(Y),G<L&&F++)}),O.i=-1;const W=Hx(z),U=W.length,H=U/2|0,K=U%2==0?(W[H-1]+W[H])/2:W[H],q=O.o;return((O.o=K)-q)*gn(L-F,0)})(v,Zs(v,k()))),o=!1),M=3,R=!0;break}case 4:l!==I&&(l||(w=R=!0),l=I,M=3);break;case 5:I[1]?(E(Em(v,I[0],!0)),h=2,M=1):(Em(v,I[0]),M=1);break;case 6:c=I;break;case 7:h=1;break;case 8:g=C(I,I+l),M=1}M&&(a=1+(2147483647&a),$&&u&&(f+=u,u=0),j.forEach(([D,O])=>{M&D&&O(R)}))}}},Ld=setTimeout,jl=(n,e)=>e?-n:n,T_=(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!=xr&&clearTimeout(b)},v=()=>{w(),b=Ld(()=>{b=xr,(()=>{if(c||d)return c=!1,void m();f=!1,n.B(2)})()},150)};return v.J=w,v})(),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,Gx()&&(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()))}}},E_=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=yc();return s=()=>{c(!1)},n.p()&&Ld(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&k_())n.B(8,o()),Kx(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()}]},A_=(n,e)=>{let t,s,o=yc(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=E_(n,()=>o[0],(f,u)=>{f=jl(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=T_(n,u,e,()=>jl(u[a],i),(m,p,h)=>{if(h){const g=u.style,x=g[l];g[l]="hidden",Ld(()=>{g[l]=x})}u[a]=jl(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=yc()},P:()=>i,V(f){c(()=>f)},X(f){f+=n.C(),c(()=>f)},Y(f,{align:u,smooth:m,offset:p=0}={}){if(f=Wx(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()}}},P_=n=>{let e;return{j(t){(e||(e=new(N_(S_(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},I_=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=P_(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!=xr&&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}},Bi=w_?y.useLayoutEffect:y.useEffect,Zt="current",Yx=(n,e)=>{if(Array.isArray(n))for(const t of n)Yx(t,e);else n==null||typeof n=="boolean"||e.push(n)},R_=(n,e)=>{const t=n.key;return t??"_"+e},$_=n=>{const e=y.useRef(null);return e[Zt]||(e[Zt]=n())},Am=n=>{const e=y.useRef(n);return Bi(()=>{e[Zt]=n},[n]),e},M_=y.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=y.useRef(null);Bi(()=>e(c[Zt],t),[t]);const d=y.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})}),O_=(n,e)=>y.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return Yx(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),D_=y.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]=O_(n,e),w=y.useRef(null),v=y.useRef(!!d),j=Am(p),S=Am(h),[k,C,N,_]=$_(()=>{const M=!!i,D=__(b,s,d,l,!s);return[D,I_(D,M),A_(D,M),M]});b!==k.T()&&k.B(5,[b,o]),c!==k.O()&&k.B(6,c);const[A,P]=y.useReducer(k.m,void 0,k.m),E=k.M(),T=k.h(),I=N.P(),$=[],R=M=>{const D=x(M);return r.jsx(M_,{ee:C.U,te:M,oe:k.k(M,I),ne:k.I(M),re:u,Z:D,se:_,ie:v[Zt]},R_(D,M))};if(Bi(()=>{v[Zt]=!1,k.W(1,O=>{O?lv.flushSync(P):P()}),k.W(4,()=>{j[Zt]&&j[Zt](k.C())}),k.W(8,()=>{S[Zt]&&S[Zt]()});const M=w[Zt],D=O=>{C.G(O),N.N(M,O)};return m?Kx(()=>{m[Zt]&&D(m[Zt])}):D(M.parentElement),()=>{k.v(),C.v(),N.v()}},[]),Bi(()=>{N.q()},[A]),y.useImperativeHandle(g,()=>({get cache(){return k._()},get scrollOffset(){return k.C()},get scrollSize(){return C_(k)},get viewportSize(){return k.p()},findItemIndex:k.$,getItemOffset:k.k,getItemSize:k.R,scrollToIndex:N.Y,scrollTo:N.V,scrollBy:N.X}),[]),a){const M=new Set(a);for(let[D,O]=k.S(t);D<=O;D++)M.add(D);Hx([...M]).forEach(D=>{$.push(R(D))})}else for(let[M,D]=k.S(t);M<=D;M++)$.push(R(M));return r.jsx(f,{ref:w,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:_?T:"100%",height:_?"100%":T,pointerEvents:E?"none":void 0},children:$})});function Oa(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(ky,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Da(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=V("select-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Ny,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function La(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=V("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(Th,{"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(Ah,{children:r.jsx(Ph,{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 ho(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(Eh,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function WD(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=V("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(Ih,{"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 en(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=V("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(_h,{"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 br(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=V("-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(zc,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function L_(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(Da,{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(Xc,{"data-icon":"inline-start"}),e[5]=f):f=e[5];let u;e[6]!==d?(u=r.jsx(ho,{children:r.jsxs(en,{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(br,{}),r.jsx(ho,{children:r.jsxs(en,{onClick:()=>a(s),children:[r.jsx(Yc,{"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(br,{}),r.jsx(ho,{children:r.jsxs(en,{onClick:()=>l(s),children:[r.jsx(Cn,{"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(La,{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(Oa,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function z_(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(Xc,{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(Rt,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Cy,{"data-icon":"inline-start"}),e[9]=f):f=e[9];let u;e[10]!==s?(u=r.jsxs(ee,{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 Pm=new Map;function F_(n){let e=Pm.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},Pm.set(n,e)}return e}function Xx(n){const e=B.c(5),t="100%",s=y.useRef(null),[o,i]=y.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:f,callbacks:u}=F_(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]),y.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 Ui(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 Im(n){const e=Ui(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Ui(n.lastModified)}function Rm(n,e){return n===e?0:e-n}function $m(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function B_(n,e){const t=Rm(Im(n),Im(e));if(t!==0)return t;const s=Rm(Ui(n.lastModified),Ui(e.lastModified));return s!==0?s:$m(n).localeCompare($m(e))}function zd(n){return[...n].sort(B_)}function Jx(n,e){const t=!!(n.teamName&&n.agentName);return e||vn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const U_="Unknown project";function Fd(n){const e=ya(n);return va(e?e.parentPath:n,2)||U_}function W_(n){return Fd(n.cwd||wn(n.dirName))}function H_(n){const e=zd(n),t=new Map;for(const s of e){const o=W_(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function Qx(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function K_(n,e,t){let s=-1;return n.forEach((o,i)=>{Qx(o,e)&&(s=i)}),Math.max(t,s+1)}const Bd=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),q_=12e4;function V_(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<q_}function Zx(n,e,t=Date.now()){return Qx(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:V_(n,t)}function G_(n,e,t=Date.now()){return n.some(s=>Zx(s,e,t))}const Y_="cogpit:session-list-cache",X_=10080*60*1e3,J_=24,Kn={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},wc=new Map;function Q_(){return{version:1,entries:{}}}function e0(){return Ut(Y_)}function t0(){const n=e0(),e=wc.get(n);if(e)return e;let t=Q_();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 wc.set(n,t),t}function n0(n){const e=t0().entries[n];if(!(!e||Date.now()-e.savedAt>X_))return e.value}function s0(n,e){const t=e0(),o={...t0().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,J_))};wc.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function Wi(n){const e=n0(n);return Array.isArray(e)?e:void 0}function er(n,e){s0(n,e)}function o0(n){return`sessions:${n}`}function Z_(n){const e=n0(o0(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function e6(n,e){s0(o0(n),e)}const t6=2e4;function n6(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 r0=y.createContext(null);function s6({children:n}){const[e]=y.useState(bn),[t,s]=y.useState(()=>Wi(Kn.activeSessions)??[]),[o,i]=y.useState(()=>Wi(Kn.runningProcesses)??[]),[a,l]=y.useState(!1),[c,d]=y.useState(null),[f,u]=y.useState(new Set),m=y.useRef(null),p=y.useRef(null),h=y.useRef(!1);y.useEffect(()=>(h.current=!0,()=>{var k;h.current=!1,(k=p.current)==null||k.abort(),p.current=null}),[]);const g=y.useCallback(async()=>{var N;if(!h.current||bn()!==e)return;(N=p.current)==null||N.abort();const k=new AbortController;p.current=k;const C=()=>h.current&&!k.signal.aborted&&p.current===k&&bn()===e;l(!0);try{const[_,A]=await Promise.all([ye("/api/active-sessions",{signal:k.signal}),ye("/api/running-processes",{signal:k.signal})]);if(!C())return;if(!_.ok||!A.ok)throw new Error("Failed to fetch live data");const[P,E]=await Promise.all([_.json(),A.json()]);if(!C())return;const T=Array.isArray(P)?P:[],I=Array.isArray(E)?E:[];s(T),i(I),er(Kn.activeSessions,T),er(Kn.runningProcesses,I),d(null)}catch(_){if(!C())return;d(_ instanceof Error?_.message:"Failed to load data")}finally{C()&&l(!1),p.current===k&&(p.current=null)}},[e]),x=y.useCallback(()=>{g()},[g]);y.useEffect(()=>{x()},[x]);const b=y.useMemo(()=>n6(o),[o]),w=y.useMemo(()=>G_(t,b),[t,b]);y.useEffect(()=>(window.addEventListener("focus",x),()=>window.removeEventListener("focus",x)),[x]),y.useEffect(()=>{if(!w)return;const k=setInterval(()=>{document.visibilityState==="visible"&&x()},t6);return()=>clearInterval(k)},[w,x]),y.useEffect(()=>{if(t.length===0)return;const k=m.current,C=new Map;for(const N of t)N.agentStatus&&b.has(N.sessionId)&&C.set(N.sessionId,N.agentStatus);k!==null&&u(N=>{let _=null;for(const[A,P]of C)P==="completed"&&k.get(A)!=="completed"&&(_??(_=new Set(N)),_.add(A));for(const A of N)C.get(A)!=="completed"&&(_??(_=new Set(N)),_.delete(A));return _??N}),m.current=C},[t,b]);const v=y.useCallback(k=>{u(C=>{if(!C.has(k))return C;const N=new Set(C);return N.delete(k),N})},[]),j=y.useCallback(k=>{s(C=>{const N=C.filter(_=>_.sessionId!==k);return bn()===e&&er(Kn.activeSessions,N),N})},[e]),S=y.useMemo(()=>({sessions:t,processes:o,procBySession:b,newlyCompleted:f,loading:a,error:c,refresh:x,removeSession:j,acknowledgeCompleted:v}),[t,o,b,f,a,c,x,j,v]);return r.jsx(r0.Provider,{value:S,children:n})}function i0(){const n=Ud();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function Ud(){return y.useContext(r0)}const Mm=[20,50,80,110,140,170,200,230,260,290,320,350];function o6(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return Mm[(e>>>0)%Mm.length]}function Sl(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 r6(n){const e=n.split(`
86
+ `);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=Sl(e[t]??"");return s?{subject:s,preview:Sl(e.slice(t+1).join(`
87
+ `))}:{subject:Sl(n),preview:""}}function jc(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function i6(n,e){return n===null||e===null||e<n?null:e-n}function a6(n){const e=jc(n);return e===null?null:new Date(e).toLocaleTimeString()}function l6(n){var s;const e=(s=Ud())==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=Bd.has(i)?"working":"idle"}return t}const c6=y.memo(function(e){const t=B.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=y.useState(!1);let f;t[0]!==o?(f=HN(o),t[0]=o,t[1]=f):f=t[1];const u=f;let m;t[2]!==u?(m=r6(u),t[2]=u,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=a6(i),t[4]=i,t[5]=g):g=t[5];const x=g,b=l6(s);let w;t[6]!==u?(w=YN(u),t[6]=u,t[7]=w):w=t[7];const v=w,j=v&&!a,S=jc(i),k=a?i6(S,jc(a.timestamp)):null,C=!a&&l===!0,N=!!a||v;Tg(C&&N);const _=!0;let A;t[8]!==s?(A=o6(s),t[8]=s,t[9]=A):A=t[9];const P=String(A);let E;t[10]!==P?(E={"--agent-hue":P},t[10]=P,t[11]=E):E=t[11];const T=E,I="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 $;t[12]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(_y,{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]=$):$=t[12];let R;t[13]!==s?(R=r.jsx("span",{className:"truncate font-mono text-xs font-medium text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]",children:s}),t[13]=s,t[14]=R):R=t[14];let M;t[15]!==b||t[16]!==s?(M=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]=M):M=t[17];let D;t[18]!==R||t[19]!==M?(D=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[$,R,M]}),t[18]=R,t[19]=M,t[20]=D):D=t[20];let O;t[21]!==j?(O=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]=O):O=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]!==O||t[26]!==L?(F=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[O,L]}),t[25]=O,t[26]=L,t[27]=F):F=t[27];let z;t[28]!==D||t[29]!==F?(z=r.jsxs("div",{className:"flex items-center gap-2",children:[D,F]}),t[28]=D,t[29]=F,t[30]=z):z=t[30];let W;t[31]!==u||t[32]!==c||t[33]!==h||t[34]!==p?(W=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(On,{components:Fn,remarkPlugins:Gs,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]=W):W=t[35];const U="mt-1.5 flex items-center justify-end gap-2",H=N&&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:[k===null?"You replied":`You replied ${Mn(k)} later`,a.summary&&` · "${a.summary}"`]}):C?S===null?"Awaiting your reply":`Awaiting your reply · ${Mn(Math.max(0,Date.now()-S))}`:"Never answered"});let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=()=>d(d6),t[36]=K):K=t[36];let q;t[37]!==u||t[38]!==c?(q=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:K,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Je,{"data-icon":"inline-start"})," Expand ·"," ",u.length.toLocaleString("en-US")," ",u.length===1?"char":"chars"]})}),t[37]=u,t[38]=c,t[39]=q):q=t[39];let Y;t[40]!==H||t[41]!==q?(Y=r.jsxs("div",{className:U,children:[H,q]}),t[40]=H,t[41]=q,t[42]=Y):Y=t[42];let G;return t[43]!==z||t[44]!==W||t[45]!==Y||t[46]!==T?(G=r.jsxs("div",{"data-agent-rail":_,style:T,className:I,children:[z,W,Y]}),t[43]=z,t[44]=W,t[45]=Y,t[46]=T,t[47]=G):G=t[47],G});function d6(n){return!n}const u6=1500;function Fs(){const n=B.c(5),[e,t]=y.useState(!1),s=y.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]),y.useEffect(o,i);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async d=>{await Er(d)&&(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),u6))},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 f6=y.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=Ex(s),t[0]=s,t[1]=d):d=t[1];const f=d,[u,m]=Fs();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:Pr(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(ee,{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(mt,{"data-icon":"inline-start"}):r.jsx(Cn,{"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=V("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==f?(x=r.jsx(On,{components:Fn,remarkPlugins:Gs,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}),uo=[];function m6(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 p6(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 Om=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function h6(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){Om.lastIndex=0;let i;for(;(i=Om.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 g6(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 x6(n){return n.filter(e=>e.parentToolUseId===null)}function b6(n,e){return n.filter(t=>t.parentToolUseId===e)}const a0={},l0=y.createContext(uo),c0=y.createContext(a0);function Nl(n){const e=B.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?a0:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(c0.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(l0.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function Wd(){return y.useContext(l0)}function v6(n){return y.useContext(c0)[n]??null}function eo(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 d0={...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},y6={...d0,h1:eo("h1"),h2:eo("h2"),h3:eo("h3"),h4:eo("h4"),h5:eo("h5"),h6:eo("h6")},u0=y.memo(function(e){const t=B.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?y6:d0;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(On,{components:a,remarkPlugins:Gs,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),Dm=400,w6=24,Hd=y.memo(function(e){const t=B.c(24),{toolUseId:s}=e,o=Wd(),i=v6(s),a=y.useRef(null),[l,c]=y.useState(!0);let d,f,u;if(t[0]!==l||t[1]!==o||t[2]!==s){u=b6(o,s).flatMap(j6).filter(S6).map(N6).join(`
89
+ `);const k=u.split(`
90
+ `);d=l&&k.length>Dm,f=d?k.slice(-Dm).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 k=a.current;if(!k)return;const C=k.scrollHeight-k.scrollTop-k.clientHeight<w6;c(N=>N===C?N:C)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const k=a.current;if(!k||!l)return;const C=k.scrollHeight-k.clientHeight;k.scrollTop!==C&&(k.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],y.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 v;t[14]!==b||t[15]!==w?(v=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]=v):v=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(u0,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=u,t[20]=j):j=t[20];let S;return t[21]!==v||t[22]!==j?(S=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[v,j]}),t[21]=v,t[22]=j,t[23]=S):S=t[23],S});function j6(n){return n.blocks}function S6(n){return n.blockType!=="tool_use"&&n.text}function N6(n){return n.text}function Lm(n){return n.length>8?n.slice(0,8):n}function Kd(n,e,t){const s=e??t;return s?`${s} - ${Lm(n)}`:Lm(n)}function k6(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,Kd(t.agentId,t.subagentType,t.agentName));return e}function C6(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 _6(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
92
+ `):""}function f0(n,e){if(dx(n))return Rd(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=_6(u.content),m.isError=u.is_error??!1)}}}return t}const kl=new Map;function T6(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]=y.useState(a),[d,f]=y.useState(!1);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[1]=u):u=t[1];const m=y.useRef(u);let p;if(t[2]!==i||t[3]!==n){let _;t[5]!==i?(_=A=>A.text.length>0||A.thinking.length>0||A.toolCalls.length>0?!1:i?A.durationMs!=null:A.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=ka(window.location.pathname),t[7]=b):b=t[7];const w=b;let v,j;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(v=()=>{if(w||!e||!g||!x||h.length===0)return;const _=[];for(const E of h){const T=Ut(`${g}/${x}/${E.agentId}`);if(!m.current.has(T)){if(kl.has(T)){c(I=>{const $=new Map(I);return $.set(E.agentId,kl.get(T)),$}),m.current.add(T);continue}_.push({agentId:E.agentId,cacheKey:T})}}if(_.length===0)return;let A=!1;return f(!0),async function(){const T=new Map;await Promise.all(_.map(async I=>{const{agentId:$,cacheKey:R}=I;try{const M=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent($)}.jsonl`,D=await ye(M);if(!D.ok)return;const O=await D.text(),L=f0(O,$);kl.set(R,L),m.current.add(R),T.set($,L)}catch{}})),!A&&T.size>0&&c(I=>{const $=new Map(I);for(const[R,M]of T)$.set(R,M);return $}),A||f(!1)}(),()=>{A=!0}},j=[w,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=v,t[13]=j):(v=t[12],j=t[13]),y.useEffect(v,j);let S;e:{if(l.size===0&&h.length===0){S=n;break e}let _;if(t[14]!==l||t[15]!==n){_=[];for(const A of n){const P=l.get(A.agentId);if(P&&P.length>0&&(A.status==="async_launched"||A.durationMs!=null)){const E={...P[0],durationMs:A.durationMs,toolUseCount:A.toolUseCount,status:A.status,prompt:A.prompt,agentName:A.agentName,subagentType:A.subagentType};_.push(E,...P.slice(1))}else _.push(A)}t[14]=l,t[15]=n,t[16]=_}else _=t[16];S=_}const k=S,C=w&&e&&h.length>0;let N;return t[17]!==k||t[18]!==d||t[19]!==C?(N={enrichedMessages:k,isLoading:d,unavailable:C},t[17]=k,t[18]=d,t[19]=C,t[20]=N):N=t[20],N}const m0=y.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]=y.useState(!1),u=o||d,{sessionSource:m,actions:p}=it(),h=m==null?void 0:m.dirName;let g;t[0]!==h?(g=vo(h),t[0]=h,t[1]=g):g=t[1];const x=g.subagentTranscripts,{enrichedMessages:b,isLoading:w,unavailable:v}=T6(s,c&&u&&x);let j;e:{if(!(m!=null&&m.fileName)){j=null;break e}let X;t[2]!==m.fileName?(X=xs(m.fileName),t[2]=m.fileName,t[3]=X):X=t[3];const Z=X;if(Z){j=Z.parentSessionId;break e}let se;if(t[4]!==m.fileName){let re;t[6]===Symbol.for("react.memo_cache_sentinel")?(re=/^([^/]+)\.jsonl$/,t[6]=re):re=t[6],se=m.fileName.match(re),t[4]=m.fileName,t[5]=se}else se=t[5];const ne=se;j=(ne==null?void 0:ne[1])??null}const S=j;let k;t[7]!==b?(k=new Set(b.map(A6)),t[7]=b,t[8]=k):k=t[8];let C;t[9]!==k?(C=[...k],t[9]=k,t[10]=C):C=t[10];const N=C;let _;t[11]!==b?(_=k6(b),t[11]=b,t[12]=_):_=t[12];const A=_;let P;if(t[13]!==b||t[14]!==s){P=new Map;for(const X of[...s,...b]){const Z=P.get(X.agentId)??{};X.durationMs!=null&&(Z.durationMs=X.durationMs),X.toolUseCount!=null&&(Z.toolUseCount=X.toolUseCount),X.status&&(Z.status=X.status),P.set(X.agentId,Z)}t[13]=b,t[14]=s,t[15]=P}else P=t[15];const E=P;let T;t[16]!==b||t[17]!==s?(T=C6([...s,...b]),t[16]=b,t[17]=s,t[18]=T):T=t[18];const I=T;let $,R;if(t[19]!==b){R=new Map,$=new Map;for(const X of b)$.set(X.agentId,X),X.text.length>0&&R.set(X.agentId,X);t[19]=b,t[20]=$,t[21]=R}else $=t[20],R=t[21];let M;if(t[22]!==N||t[23]!==$||t[24]!==R){M=new Map;for(const X of N){const Z=R.get(X)??$.get(X);Z&&M.set(X,Z)}t[22]=N,t[23]=$,t[24]=R,t[25]=M}else M=t[25];const D=M;let O;e:{let X=0,Z=0,se=!1,ne=!0;for(const ie of s)ie.durationMs!=null&&(X=X+ie.durationMs,se=!0),ie.toolUseCount!=null&&(Z=Z+ie.toolUseCount),ie.status&&ie.status!=="completed"&&(ne=!1);if(!se){O=null;break e}let re;t[26]!==ne||t[27]!==X||t[28]!==Z?(re={totalDuration:X,totalToolUses:Z,allCompleted:ne},t[26]=ne,t[27]=X,t[28]=Z,t[29]=re):re=t[29],O=re}const L=O;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(nt,{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 W;t[34]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(Xn,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=W):W=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 H;t[37]!==N.length||t[38]!==a?(H=N.length>1&&r.jsxs(Ee,{variant:"secondary",children:[N.length," ",a]}),t[37]=N.length,t[38]=a,t[39]=H):H=t[39];let K;t[40]!==N||t[41]!==A?(K=N.map(X=>r.jsx(Ee,{variant:"outline",children:A.get(X)},X)),t[40]=N,t[41]=A,t[42]=K):K=t[42];let q;t[43]!==N.length||t[44]!==L?(q=L?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[L.allCompleted?r.jsx(Yn,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(Ks,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Os,{className:"size-3","data-icon":"inline-start"}),Mn(L.totalDuration)]}),L.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ia,{className:"size-3","data-icon":"inline-start"}),L.totalToolUses]})]}):r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.length," agent",N.length!==1?"s":"",")"]}),t[43]=N.length,t[44]=L,t[45]=q):q=t[45];let Y;t[46]!==F||t[47]!==z||t[48]!==U||t[49]!==H||t[50]!==K||t[51]!==q?(Y=r.jsxs(ee,{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,W,U,H,K,q]}),t[46]=F,t[47]=z,t[48]=U,t[49]=H,t[50]=K,t[51]=q,t[52]=Y):Y=t[52];let G;t[53]!==N||t[54]!==u||t[55]!==I?(G=!u&&N.map(X=>{const Z=I.get(X);return Z?r.jsx(Hd,{toolUseId:Z},X):null}),t[53]=N,t[54]=u,t[55]=I,t[56]=G):G=t[56];let J;t[57]!==p||t[58]!==N||t[59]!==A||t[60]!==D||t[61]!==x||t[62]!==w||t[63]!==u||t[64]!==S||t[65]!==I||t[66]!==m||t[67]!==E||t[68]!==v?(J=u&&r.jsxs("div",{className:"motion-enter mt-2 flex flex-col gap-2",children:[v?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..."]}),N.map(X=>{const Z=D.get(X),se=E.get(X),ne=x&&!!m&&!!S&&!v;return r.jsx(E6,{agentLabel:A.get(X)??X,message:Z,stats:se,parentToolUseId:I.get(X),canNavigate:ne,onOpen:()=>{ne&&p.handleLoadSession(m.dirName,`${S}/subagents/agent-${X}.jsonl`)}},X)})]}),t[57]=p,t[58]=N,t[59]=A,t[60]=D,t[61]=x,t[62]=w,t[63]=u,t[64]=S,t[65]=I,t[66]=m,t[67]=E,t[68]=v,t[69]=J):J=t[69];let Q;return t[70]!==Y||t[71]!==G||t[72]!==J?(Q=r.jsxs("div",{children:[Y,G,J]}),t[70]=Y,t[71]=G,t[72]=J,t[73]=Q):Q=t[73],Q});function E6(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=Ex((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(Yn,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Os,{className:"size-3"}),Mn(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ia,{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(ee,{type:"button",variant:"ghost",size:"xs",onClick:l,className:"ml-auto",title:"Open this sub-agent's full chat session",children:[r.jsx(Bh,{"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(On,{components:Fn,remarkPlugins:Gs,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(Hd,{toolUseId:i})]}),e[14]=u,e[15]=m,e[16]=f,e[17]=i,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=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]=v):v=e[21],v}function A6(n){return n.agentId}const P6=y.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(m0,{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}),I6=y.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(m0,{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}),R6=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),$6=y.memo(function(e){const t=B.c(30),{events:s}=e,[o,i]=y.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(M6),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?nt:Je,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let f;t[2]!==d?(f=V("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(ee,{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(sn,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(Ty,{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(O6).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(Wt,{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 v;t[21]!==s?(v=s.map(D6),t[21]=s,t[22]=v):v=t[22];let j;t[23]!==v?(j=r.jsx(ft,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:v})}),t[23]=v,t[24]=j):j=t[24];let S;return t[25]!==o||t[26]!==w||t[27]!==j||t[28]!==f?(S=r.jsxs(ut,{open:o,onOpenChange:i,className:f,children:[w,j]}),t[25]=o,t[26]=w,t[27]=j,t[28]=f,t[29]=S):S=t[29],S});function M6(n){return R6.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function O6(n){return n.eventName}function D6(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 zm=768;function za(){const n=B.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<zm:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${zm-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]),y.useEffect(s,o),e}const L6=24,Lo=[];function z6(n,e){for(let s=0;s<Lo.length;s++){const o=Lo[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=B6(n,e);return Lo.length>=L6&&Lo.shift(),Lo.push({oldStr:n,newStr:e,result:t}),t}const F6=25e4;function B6(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>F6){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,v=w-u;for(let j=1;j<=d;j++)if(b===s[a+j-1])m[w+j]=m[v+j-1]+1;else{const S=m[v+j],k=m[w+j-1];m[w+j]=S>k?S:k}}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 U6(n,e,t,s){const o=B.c(9),[i,a]=y.useState(null),[l,c]=y.useState(null);let d,f;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=w1(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||v1().then(async x=>{if(h||(await y1(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]),y.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 W6={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},Fm={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},H6={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function K6(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:V(e&&"opacity-50"),children:t.content},s))}function q6(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 V6(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(Fh,{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($n,{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 Cl=3;function G6(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<=Cl*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-Cl);a<=Math.min(n.length-1,i+Cl);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 Y6(n){const e=B.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(da,{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(ee,{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 Bm=y.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=q6(s,i,a);const x=W6[s.type];t[10]!==x?(d=V("flex",x),t[10]=x,t[11]=d):d=t[11];const b=Fm[s.type];let w;t[12]!==b?(w=V("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 v=Fm[s.type];let j;t[17]!==v?(j=V("select-none shrink-0 w-5 text-right pr-1 border-r",v),t[17]=v,t[18]=j):j=t[18];let S;t[19]!==s.type?(S=r.jsx(V6,{type:s.type}),t[19]=s.type,t[20]=S):S=t[20],t[21]!==j||t[22]!==S?(u=r.jsx("span",{className:j,children:S}),t[21]=j,t[22]=S,t[23]=u):u=t[23],l="pl-2 whitespace-pre",c=m?K6(m,s.type==="unchanged"):r.jsx("span",{className:H6[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}),Um=120,Wm=60,X6=120;function Hm(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]=y.useState(c);let u;e[1]!==t?(u=G6(t),e[1]=t,e[2]=u):u=e[2];const m=u,p=m.length>Um,[h,g]=y.useState(p?Wm:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>Um?Wm: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],y.useEffect(x,b);let w,v;e[7]!==m.length||e[8]!==h?(w=()=>{if(h>=m.length)return;const E=requestAnimationFrame(()=>{g(T=>Math.min(T+X6,m.length))});return()=>cancelAnimationFrame(E)},v=[h,m.length],e[7]=m.length,e[8]=h,e[9]=w,e[10]=v):(w=e[9],v=e[10]),y.useEffect(w,v);let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=E=>{f(T=>new Set(T).add(E))},e[11]=j):j=e[11];const S=j;let k;e[12]!==m||e[13]!==p||e[14]!==h?(k=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=k):k=e[15];const C=k,N=i&&"max-h-64 overflow-y-auto";let _;e[16]!==N?(_=V("overflow-x-auto font-mono text-xs leading-relaxed",N),e[16]=N,e[17]=_):_=e[17];let A;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let E;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(E=(T,I)=>{if(T.kind==="separator")return d.has(T.fromIdx)?t.slice(T.fromIdx,T.toIdx+1).map((M,D)=>{const O=T.fromIdx+D;return r.jsx(Bm,{line:M,lineNum:M.type==="removed"?(M.oldIdx??0)+l:(M.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${O}`)}):r.jsx(Y6,{count:T.count,onExpand:()=>S(T.fromIdx)},`sep-${I}`);const{line:$}=T,R=$.type==="removed"?($.oldIdx??0)+l:($.newIdx??0)+l;return r.jsx(Bm,{line:$,lineNum:R,oldTokens:s,newTokens:o},I)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=E):E=e[30],A=C.map(E),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=A}else A=e[24];let P;return e[31]!==_||e[32]!==A?(P=r.jsx("div",{className:_,children:A}),e[31]=_,e[32]=A,e[33]=P):P=e[33],P}function Km(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 qd(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]=y.useState(!1),p=Lr();let h;e[0]!==s||e[1]!==t?(h=z6(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:b}=U6(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 v=w,j=c&&"mt-1.5",S=f&&"border-0 rounded-none";let k;e[5]!==j||e[6]!==S?(k=V("overflow-hidden rounded border border-border bg-muted/20",j,S),e[5]=j,e[6]=S,e[7]=k):k=e[7];let C;e[8]!==f||e[9]!==c||e[10]!==g||e[11]!==v?(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:v}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Km,{lines:g}),c&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>m(!0),className:"text-muted-foreground",title:"Expand diff","aria-label":"Expand diff",children:r.jsx(la,{"data-icon":"icon"})})]})]}),e[8]=f,e[9]=c,e[10]=g,e[11]=v,e[12]=C):C=e[12];let N;e[13]!==c||e[14]!==g||e[15]!==b||e[16]!==x||e[17]!==d?(N=r.jsx(Hm,{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]=N):N=e[18];let _;e[19]!==N||e[20]!==k||e[21]!==C?(_=r.jsxs("div",{className:k,children:[C,N]}),e[19]=N,e[20]=k,e[21]=C,e[22]=_):_=e[22];let A;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==u||e[27]!==b||e[28]!==x||e[29]!==d?(A=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(Ss,{children:[r.jsxs(Zn,{className:"font-mono text-sm text-foreground flex items-center gap-3",children:[o,r.jsx(Km,{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(Hm,{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]=A):A=e[30];let P;return e[31]!==_||e[32]!==A?(P=r.jsxs(r.Fragment,{children:[_,A]}),e[31]=_,e[32]=A,e[33]=P):P=e[33],P}function J6(n){return n<1e3?`${n} ms`:n%6e4===0?`${n/6e4} min`:n%1e3===0?`${n/1e3} sec`:`${(n/1e3).toFixed(1)} sec`}function Q6(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function Z6(n){const e=B.c(4),t=Lr(),[s,o]=y.useState(null);let i,a;return e[0]!==n||e[1]!==t?(i=()=>{let l=!1;return yd(n,"typescript",t).then(c=>{!l&&c&&c.length>0&&o(c)}),()=>{l=!0}},a=[n,t],e[0]=n,e[1]=t,e[2]=i,e[3]=a):(i=e[2],a=e[3]),y.useEffect(i,a),s}function qm(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 eT(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*["']([^"']+)["']`));return(t==null?void 0:t[1])??null}function tT(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:Q6(a)});const s=eT(n,"workdir");s&&e.push({key:"workdir",label:"Working directory",value:s});const o=qm(n,"yield_time_ms");o!==null&&e.push({key:"yield-time",label:"Yield",value:J6(o),icon:Cr});const i=qm(n,"max_output_tokens");return i!==null&&e.push({key:"output-limit",label:"Output limit",value:`${i.toLocaleString()} tokens`}),e}function Vm(n){const e=B.c(49),{input:t}=n,s=String(t.raw??""),o=tT(s),[i,a]=Fs(),l=Z6(s);let c,d,f,u,m,p,h,g,x,b;if(e[0]!==i||e[1]!==a||e[2]!==s||e[3]!==l){const N=s.split(`
100
+ `);d=Yt,g="sm",x="mt-1.5";let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(nn,{className:"flex items-center gap-2",children:[r.jsx(Sr,{className:"size-4","aria-hidden":"true"}),"Tool script"]}),e[14]=_):_=e[14];let A;e[15]!==a||e[16]!==s?(A=()=>a(s),e[15]=a,e[16]=s,e[17]=A):A=e[17];const P=i?"Tool script copied":"Copy script",E=i?"Copied":"Copy script";let T;e[18]!==i?(T=i?r.jsx(mt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(Cn,{"data-icon":"inline-start","aria-hidden":"true"}),e[18]=i,e[19]=T):T=e[19],e[20]!==A||e[21]!==P||e[22]!==E||e[23]!==T?(b=r.jsxs(tn,{children:[_,r.jsx(gd,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:A,"aria-label":P,title:E,children:T})})]}),e[20]=A,e[21]=P,e[22]=E,e[23]=T,e[24]=b):b=e[24],c=Xt,h="overflow-x-auto rounded-md bg-muted/50 p-3",p="m-0 min-w-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed [overflow-wrap:anywhere]",f="Codex exec script";const I=!l&&"text-foreground";e[25]!==I?(u=V("block",I),e[25]=I,e[26]=u):u=e[26];let $;e[27]!==l?($=(R,M)=>{const D=l==null?void 0:l[M];return r.jsx("span",{className:"block min-h-lh",children:D?D.map(sT):R||" "},M)},e[27]=l,e[28]=$):$=e[28],m=N.map($),e[0]=i,e[1]=a,e[2]=s,e[3]=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}else c=e[4],d=e[5],f=e[6],u=e[7],m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13];let w;e[29]!==f||e[30]!==u||e[31]!==m?(w=r.jsx("code",{"aria-label":f,className:u,children:m}),e[29]=f,e[30]=u,e[31]=m,e[32]=w):w=e[32];let v;e[33]!==p||e[34]!==w?(v=r.jsx("pre",{className:p,children:w}),e[33]=p,e[34]=w,e[35]=v):v=e[35];let j;e[36]!==v||e[37]!==h?(j=r.jsx("div",{className:h,children:v}),e[36]=v,e[37]=h,e[38]=j):j=e[38];let S;e[39]!==c||e[40]!==j?(S=r.jsx(c,{children:j}),e[39]=c,e[40]=j,e[41]=S):S=e[41];const k=o.length>0&&r.jsx(Ao,{className:"items-stretch",children:r.jsx("dl",{className:"grid w-full gap-1.5","aria-label":"Tool script options",children:o.map(nT)})});let C;return e[42]!==d||e[43]!==S||e[44]!==k||e[45]!==g||e[46]!==x||e[47]!==b?(C=r.jsxs(d,{size:g,className:x,children:[b,S,k]}),e[42]=d,e[43]=S,e[44]=k,e[45]=g,e[46]=x,e[47]=b,e[48]=C):C=e[48],C}function nT(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 sT(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const oT=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function Gm(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function rT(n,e){const t=[],s=[];let o=0;for(const l of n.matchAll(oT)){const c=Gm(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=Gm(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:iT(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 iT(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(`
101
+ `).trim())}const aT=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),lT=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,cT=/\|\||&&|[|;\n]/,dT=new Set(["echo","printf","true","false",":"]),uT=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),fT=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),mT=new Set(["ls","tree","du"]),pT=new Set(["xargs","sudo","env","time","nohup","command"]);function hT(n){const e=n.split(/\s+/);for(;e.length>1&&(pT.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return aT.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:lT.test(n)}const p0=/<<-?\s*['"]?\w+['"]?/,gT=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function xT(n){return n.split(p0)[0].replace(gT,'""').split(cT).map(e=>e.trim()).filter(Boolean)}function bT(n){const e=xT(n);if(e.some(hT))return"write";let t=!1,s=!1,o=!1;for(const i of e){const a=i.split(/\s+/)[0];if(!(!a||dT.has(a)))if(uT.has(a))t=!0;else if(fT.has(a))s=!0;else if(mT.has(a))o=!0;else return"run"}return o?"list":t?"search":s?"read":"run"}const vT=/^["']?((?:~|\.{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 h0(n){const e=new Set;for(const t of n.split(p0)[0].split(/\s+/)){const s=t.match(vT);if(!s)continue;const o=s[1];o.includes("*")||o.includes("{")||o.startsWith("-")||e.add(o)}return[...e]}const yT=/^(?: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 wT(n){const e=n.trim().match(yT);if(!e)return null;const[,t,s,,o]=e;return h0(o).length?t?{path:o,from:Number(t),to:Number(s)}:{path:o}:null}const jT=/(?: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 ST(n,e){return!e||n==="read"&&e.split(`
102
+ `).length>3?!1:jT.test(e)}function g0(n){const e=bT(n.command);return{kind:e,paths:h0(n.command),readFile:e==="read"?wT(n.command):null,failed:ST(e,n.output)}}const NT="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",kT="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function x0(n,e,t){const s=B.c(5),[o,i]=y.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 yd(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]),y.useEffect(a,l),o}function b0(n){const e=B.c(12),{lines:t,tokens:s,lineNums:o,variant:i}=n,a=i==="boxed"?NT:kT;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(CT):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 CT(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const _T=/^(\s*\d+)→(.*)$/;function v0(n){return n.split(/\r\n|\r|\n/)}function TT(n){const e=[],t=[];for(const s of v0(n)){const o=s.match(_T);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function y0(n){const e=B.c(14),{result:t,filePath:s,expanded:o,variant:i}=n,a=i===void 0?"boxed":i,l=Lr();let c;e[0]!==s?(c=w1(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=TT(u),e[5]=u,e[6]=m):m=e[6];const{lineNums:p,codeLines:h}=m;let g;e[7]!==h?(g=h.join(`
103
+ `),e[7]=h,e[8]=g):g=e[8];const b=x0(g,d,l);let w;return e[9]!==h||e[10]!==p||e[11]!==b||e[12]!==a?(w=r.jsx(b0,{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 w0(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 Sc(n){const e=B.c(12),{result:t,expanded:s,alreadyPretty:o,variant:i}=n,a=i===void 0?"boxed":i,l=Lr();let c;e[0]!==o||e[1]!==t?(c=o?t:w0(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=v0(u),e[6]=u,e[7]=m):m=e[7];const p=m,h=x0(u,"json",l);let g;return e[8]!==p||e[9]!==h||e[10]!==a?(g=r.jsx(b0,{lines:p,tokens:h,variant:a}),e[8]=p,e[9]=h,e[10]=a,e[11]=g):g=e[11],g}function j0(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}function ET(n){const e=[],t=new Map;for(const s of n){const o=j0(s),i=g0(s).failed?"failed":"muted",a=t.get(o);if(a){a.count++,i==="failed"&&(a.tone="failed");continue}const l={name:o,tone:i,count:1};e.push(l),t.set(o,l)}return e}const S0={muted:"text-muted-foreground",failed:"border-destructive/30 text-destructive"},Hi={read:{icon:Ci,label:"read",plural:"reads"},search:{icon:dn,label:"search",plural:"searches"},list:{icon:bo,label:"list",plural:"lists"},run:{icon:kr,label:"run",plural:"runs"},write:{icon:ec,label:"write",plural:"writes"}},AT=["read","search","list","run","write"],PT=new Set(["command","cmd","description","timeout","run_in_background"]);function N0(n){return String(n.input.command??n.input.cmd??"")}function k0(n){const e=N0(n);return rT(e,n.result)??[{label:"",command:e,output:n.result}]}function IT(n,e,t){if(!n.isError||t.some(o=>o.failed))return-1;const s=e.findLastIndex(o=>o.output!==null);return s>=0?s:e.length-1}function RT(n){return typeof n!="number"||!Number.isFinite(n)?String(n):n<1e3?`${n} ms timeout`:n%6e4===0?`${n/6e4} min timeout`:n%1e3===0?`${n/1e3} sec timeout`:`${(n/1e3).toFixed(1)} sec timeout`}function $T(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function MT(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 OT(n){const e=[];n.timeout!==void 0&&e.push(RT(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))PT.has(t)||s===void 0||e.push(`${$T(t)} ${MT(s)}`);return e}function DT(n,e){const t=k0(n),s=t.map(g0),o=IT(n,t,s);return{toolCall:n,command:N0(n),description:typeof n.input.description=="string"?n.input.description:void 0,rows:t.map((i,a)=>({section:i,analysis:s[a],failed:s[a].failed||a===o,pending:e&&n.result===null&&a===t.length-1})),options:OT(n.input)}}function C0(n){return n?n.split(`
104
+ `).length:0}function LT(n){if(n.pending)return"running";if(n.section.output===null)return"not run";if(n.section.output==="")return"no output";const e=C0(n.section.output);return e===1?"1 line":`${e} lines`}function zT(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function _0(n){const e=B.c(12),{path:t,line:s,cwd:o,children:i}=n;let a;e[0]!==o||e[1]!==t?(a=zT(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(),ur(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-foreground 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 FT(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(_0,{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 BT=/^([^\s:]+):(\d+)([:-])/,_l="mb-1.5 ml-6 max-h-96 overflow-y-auto whitespace-pre-wrap break-all border-l pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function UT(n){const e=B.c(16),{row:t,cwd:s}=n,o=t.section.output??"";if(t.analysis.readFile&&!t.failed){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=V(_l,"pl-0 [&_pre]:border-0 [&_pre]:pl-3"),e[0]=c):c=e[0];let d;return e[1]!==o||e[2]!==t.analysis.readFile.path?(d=r.jsx("div",{className:c,children:r.jsx(y0,{result:o,filePath:t.analysis.readFile.path,expanded:!0,variant:"unboxed"})}),e[1]=o,e[2]=t.analysis.readFile.path,e[3]=d):d=e[3],d}if(t.analysis.kind==="search"&&!t.failed){let c;if(e[4]!==s||e[5]!==o){let f;e[7]!==s?(f=(u,m)=>{const p=u.match(BT);return r.jsx("span",{className:"block",children:p?r.jsxs(r.Fragment,{children:[r.jsxs(_0,{path:p[1],line:Number(p[2]),cwd:s,children:[p[1],":",p[2]]}),u.slice(p[1].length+p[2].length+1)]}):u||" "},m)},e[7]=s,e[8]=f):f=e[8],c=o.split(`
105
+ `).map(f),e[4]=s,e[5]=o,e[6]=c}else c=e[6];let d;return e[9]!==c?(d=r.jsx("pre",{className:_l,children:c}),e[9]=c,e[10]=d):d=e[10],d}const i=t.failed&&"border-destructive/30 text-destructive";let a;e[11]!==i?(a=V(_l,i),e[11]=i,e[12]=a):a=e[12];let l;return e[13]!==o||e[14]!==a?(l=r.jsx("pre",{className:a,children:o}),e[13]=o,e[14]=a,e[15]=l):l=e[15],l}function WT(n){var W;const e=B.c(56),{row:t,index:s,defaultOpen:o,cwd:i}=n,[a,l]=y.useState(o);let c;e[0]!==t.section?(c=j0(t.section),e[0]=t.section,e[1]=c):c=e[1];const d=c,f=t.section.output!==null&&t.section.output!=="",u=`${d} section: ${t.section.command}`,m=Hi[t.analysis.kind].icon,p=t.failed&&"text-destructive";let h;e[2]!==p?(h=V("w-4 shrink-0 text-right font-mono text-[10px] tabular-nums text-muted-foreground/60",p),e[2]=p,e[3]=h):h=e[3];const g=s+1;let x;e[4]!==h||e[5]!==g?(x=r.jsx("span",{className:h,"aria-hidden":"true",children:g}),e[4]=h,e[5]=g,e[6]=x):x=e[6];const b=Hi[t.analysis.kind];let w;e[7]!==m||e[8]!==b.label?(w=r.jsx(m,{className:"size-3 shrink-0 text-muted-foreground","aria-label":b.label}),e[7]=m,e[8]=b.label,e[9]=w):w=e[9];const v=t.failed&&S0.failed;let j;e[10]!==v?(j=V("h-5 shrink-0 px-1.5 font-mono text-[10px] text-muted-foreground",v),e[10]=v,e[11]=j):j=e[11];let S;e[12]!==d||e[13]!==j?(S=r.jsx(Ee,{variant:"outline",className:j,children:d}),e[12]=d,e[13]=j,e[14]=S):S=e[14];let k;e[15]!==i||e[16]!==t.analysis.paths||e[17]!==t.section.command?(k=r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/85",children:r.jsx(FT,{command:t.section.command,paths:t.analysis.paths,cwd:i})}),e[15]=i,e[16]=t.analysis.paths,e[17]=t.section.command,e[18]=k):k=e[18];let C;e[19]!==t.analysis.readFile?(C=((W=t.analysis.readFile)==null?void 0:W.from)&&r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/60",children:["L",t.analysis.readFile.from,"–",t.analysis.readFile.to]}),e[19]=t.analysis.readFile,e[20]=C):C=e[20];const N=t.failed&&"font-medium text-destructive";let _;e[21]!==N?(_=V("shrink-0 text-[10px] tabular-nums text-muted-foreground",N),e[21]=N,e[22]=_):_=e[22];let A;e[23]!==t?(A=t.failed?"failed":LT(t),e[23]=t,e[24]=A):A=e[24];let P;e[25]!==_||e[26]!==A?(P=r.jsx("span",{className:_,children:A}),e[25]=_,e[26]=A,e[27]=P):P=e[27];const E=a&&"rotate-90",T=!f&&"invisible";let I;e[28]!==E||e[29]!==T?(I=V("size-3 shrink-0 text-muted-foreground/60 transition-transform",E,T),e[28]=E,e[29]=T,e[30]=I):I=e[30];let $;e[31]!==I?($=r.jsx(Je,{className:I,"aria-hidden":"true"}),e[31]=I,e[32]=$):$=e[32];let R;e[33]!==S||e[34]!==k||e[35]!==C||e[36]!==P||e[37]!==$||e[38]!==x||e[39]!==w?(R=r.jsxs(r.Fragment,{children:[x,w,S,k,C,P,$]}),e[33]=S,e[34]=k,e[35]=C,e[36]=P,e[37]=$,e[38]=x,e[39]=w,e[40]=R):R=e[40];const M=R;if(!f){let U;return e[41]!==M||e[42]!==u?(U=r.jsx("div",{className:"group/row flex w-full items-center gap-2 py-2 text-left","aria-label":u,children:M}),e[41]=M,e[42]=u,e[43]=U):U=e[43],U}let D,O;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx("div",{role:"button",tabIndex:0}),O=V("group/row flex w-full items-center gap-2 py-2 text-left","cursor-pointer rounded-sm hover:bg-muted/40"),e[44]=D,e[45]=O):(D=e[44],O=e[45]);let L;e[46]!==M||e[47]!==u?(L=r.jsx(Wt,{nativeButton:!1,render:D,className:O,"aria-label":u,children:M}),e[46]=M,e[47]=u,e[48]=L):L=e[48];let F;e[49]!==i||e[50]!==t?(F=r.jsx(ft,{children:r.jsx(UT,{row:t,cwd:i})}),e[49]=i,e[50]=t,e[51]=F):F=e[51];let z;return e[52]!==a||e[53]!==L||e[54]!==F?(z=r.jsxs(ut,{open:a,onOpenChange:l,children:[L,F]}),e[52]=a,e[53]=L,e[54]=F,e[55]=z):z=e[55],z}function HT(n){const e=new Map;for(const{analysis:t}of n)e.set(t.kind,(e.get(t.kind)??0)+1);return AT.filter(t=>e.has(t)).map(t=>{const s=e.get(t)??0;return`${s} ${s===1?Hi[t].label:Hi[t].plural}`}).join(" · ")}function KT(n){const e=B.c(10),{call:t,index:s}=n,o=s+1;let i;e[0]!==o?(i=r.jsxs("span",{className:"font-medium text-foreground/70",children:["Call ",o]}),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==t.description?(a=t.description&&r.jsx("span",{children:t.description}),e[2]=t.description,e[3]=a):a=e[3];let l;e[4]!==t.options?(l=t.options.map(qT),e[4]=t.options,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==l?(c=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pb-1 pt-2 text-[11px] text-muted-foreground",children:[i,a,l]}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function qT(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function Ym(n){const e=B.c(51),{toolCalls:t,cwd:s,expandAll:o,isAgentActive:i}=n,a=o===void 0?!1:o,l=i===void 0?!1:i;let c;if(e[0]!==l||e[1]!==t){let K;e[3]!==l?(K=q=>DT(q,l),e[3]=l,e[4]=K):K=e[4],c=t.map(K),e[0]=l,e[1]=t,e[2]=c}else c=e[2];const d=c,f=d.flatMap(ZT),u=f.length,m=f.reduce(QT,0),p=f.filter(JT).length,h=f.filter(XT).length,[g,x]=Fs();let b;e[5]!==d?(b=d.map(YT).join(`
106
+
107
+ `),e[5]=d,e[6]=b):b=e[6];const w=b,v=d.length===1?d[0].description:void 0;let j;e[7]!==d[0]||e[8]!==d.length?(j=d.length===1?d[0].options:[],e[7]=d[0],e[8]=d.length,e[9]=j):j=e[9];const S=j;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(xo,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),e[10]=k):k=e[10];const C=an,N="flex flex-wrap items-center gap-x-2 gap-y-1";let _;e[11]!==d.length?(_=d.length>1&&r.jsxs("span",{children:[d.length," calls"]}),e[11]=d.length,e[12]=_):_=e[12];const A=HT(f);let P;e[13]!==A?(P=r.jsx("span",{children:A}),e[13]=A,e[14]=P):P=e[14];let E;e[15]!==v?(E=v&&r.jsx("span",{className:"text-foreground/70",children:v}),e[15]=v,e[16]=E):E=e[16];let T;e[17]!==S?(T=S.map(GT),e[17]=S,e[18]=T):T=e[18];const I=m===1?"line":"lines";let $;e[19]!==p?($=p>0&&r.jsxs("span",{className:"font-medium text-destructive",children:[" · ",p," failed"]}),e[19]=p,e[20]=$):$=e[20];let R;e[21]!==h?(R=h>0&&r.jsxs("span",{children:[" · ",h," not run"]}),e[21]=h,e[22]=R):R=e[22];let M;e[23]!==I||e[24]!==$||e[25]!==R||e[26]!==m?(M=r.jsxs("span",{className:"ml-auto tabular-nums",children:[m," ",I,$,R]}),e[23]=I,e[24]=$,e[25]=R,e[26]=m,e[27]=M):M=e[27];let D;e[28]!==C||e[29]!==P||e[30]!==E||e[31]!==T||e[32]!==M||e[33]!==_?(D=r.jsxs(C,{className:N,children:[_,P,E,T,M]}),e[28]=C,e[29]=P,e[30]=E,e[31]=T,e[32]=M,e[33]=_,e[34]=D):D=e[34];let O;e[35]!==w||e[36]!==x?(O=()=>x(w),e[35]=w,e[36]=x,e[37]=O):O=e[37];const L=g?"Commands copied":u===1?"Copy command":"Copy commands",F=g?"Copied":u===1?"Copy command":"Copy commands";let z;e[38]!==g?(z=g?r.jsx(mt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(Cn,{"data-icon":"inline-start","aria-hidden":"true"}),e[38]=g,e[39]=z):z=e[39];let W;e[40]!==O||e[41]!==L||e[42]!==F||e[43]!==z?(W=r.jsx(gd,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:O,"aria-label":L,title:F,children:z})}),e[40]=O,e[41]=L,e[42]=F,e[43]=z,e[44]=W):W=e[44];let U;e[45]!==d||e[46]!==s||e[47]!==a?(U=d.map((K,q)=>{const Y=d.slice(0,q).reduce(VT,0);return r.jsxs("div",{children:[q>0&&r.jsx(Rt,{}),d.length>1&&r.jsx(KT,{call:K,index:q}),K.rows.map((G,J)=>r.jsx(WT,{row:G,index:Y+J,defaultOpen:a,cwd:s},J))]},K.toolCall.id)}),e[45]=d,e[46]=s,e[47]=a,e[48]=U):U=e[48];let H;return e[49]!==U?(H=r.jsx(Xt,{children:r.jsx("div",{"aria-label":"Command sections",children:U})}),e[49]=U,e[50]=H):H=e[50],r.jsxs(Yt,{size:"sm",className:"mt-1.5",role:"region","aria-label":u===1?"Bash command":"Bash commands",children:[r.jsxs(tn,{children:[r.jsxs(nn,{className:"flex items-center gap-2",children:[k,u," ",u===1?"command":"commands"]}),D,W]}),H]})}function VT(n,e){return n+e.rows.length}function GT(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function YT(n){return n.command}function XT(n){return n.section.output===null&&!n.pending}function JT(n){return n.failed}function QT(n,e){return n+C0(e.section.output)}function ZT(n){return n.rows}const e7=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"}}),T0=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function E0(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=V("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(T0.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(Ay,{"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 A0(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=y.useContext(T0),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=V("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",e7({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(Ey,{"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 t7(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(n7)),e[2]=l,e[3]=c):c=e[3];const[d,f]=y.useState(c),[u,m]=y.useState(!1),[p,h]=y.useState(!1),{chat:g}=Rr(),{sendMessage:x}=g;if(l.length===0)return null;let b;e[4]!==d||e[5]!==l||e[6]!==x?(b=()=>{const E=l.map(T=>{var $;const I=($=d[T.question])==null?void 0:$.trim();return I?l.length>1?`${T.question}
108
+ ${I}`:I:null}).filter(Boolean).join(`
109
+
110
+ `);E&&x(E),h(!0)},e[4]=d,e[5]=l,e[6]=x,e[7]=b):b=e[7];const w=b;let v;if(e[8]!==d||e[9]!==w||e[10]!==s||e[11]!==t.id){const E=async T=>{T.preventDefault(),m(!0);try{(await od(s,t.id,d)).ok?h(!0):w()}catch{w()}m(!1)};v=T=>{E(T)},e[8]=d,e[9]=w,e[10]=s,e[11]=t.id,e[12]=v}else v=e[12];const j=!i&&"mt-2 rounded-md border bg-card p-3",S=p&&"pointer-events-none opacity-50";let k;e[13]!==j||e[14]!==S?(k=V("flex flex-col gap-3",j,S),e[13]=j,e[14]=S,e[15]=k):k=e[15];let C;if(e[16]!==d||e[17]!==l||e[18]!==t.id){let E;e[20]!==d||e[21]!==t.id?(E=(T,I)=>{const $=T.options&&T.options.length>0,R=new Set(T.multiSelect?(d[T.question]??"").split(", ").filter(Boolean):[]),M=`ask-user-answer-${t.id}-${I}`;return r.jsxs(lj,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(T.header||T.question)&&r.jsxs(cj,{variant:"label",className:"flex flex-col items-start gap-1",children:[T.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:T.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:T.question})]}),$?r.jsx(E0,{multiple:T.multiSelect,orientation:"vertical",variant:"outline",value:T.multiSelect?Array.from(R):d[T.question]?[d[T.question]]:[],onValueChange:D=>{if(!T.multiSelect&&D.length===0)return;const O=T.multiSelect?D.join(", "):D[0];f({...d,[T.question]:O})},className:"grid w-full gap-1.5",children:T.options.map((D,O)=>{const L=T.multiSelect?R.has(D.label):d[T.question]===D.label;return r.jsxs(A0,{value:D.label,"aria-label":D.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:[r.jsx("span",{className:V("mt-0.5 flex size-4 shrink-0 items-center justify-center border",T.multiSelect?"rounded":"rounded-full",L?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:L&&r.jsx(mt,{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:D.label}),D.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:D.description})]})]},O)})}):r.jsxs(xt,{children:[r.jsx(bt,{htmlFor:M,children:"Answer"}),r.jsx(Ca,{id:M,value:d[T.question]??"",onChange:D=>{f({...d,[T.question]:D.target.value})},rows:2,placeholder:"Type your answer..."})]})]},I)},e[20]=d,e[21]=t.id,e[22]=E):E=e[22],C=l.map(E),e[16]=d,e[17]=l,e[18]=t.id,e[19]=C}else C=e[19];const N=u||p,_=p?"Sent":u?"Sending...":"Send answer";let A;e[23]!==N||e[24]!==_?(A=r.jsx(ee,{type:"submit",size:"sm",disabled:N,children:_}),e[23]=N,e[24]=_,e[25]=A):A=e[25];let P;return e[26]!==C||e[27]!==A||e[28]!==v||e[29]!==k?(P=r.jsxs("form",{onSubmit:v,className:k,children:[C,A]}),e[26]=C,e[27]=A,e[28]=v,e[29]=k,e[30]=P):P=e[30],P}function n7(n){return[n.question,""]}function s7(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function Xm(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function o7(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[Xm(s[1])]=Xm(s[2]);return e}function r7(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i7(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${r7(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function a7(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=o7(n.result);for(const o of e)if(s[o.question]===void 0){const i=i7(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function Jm(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function l7(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 v;e[6]!==s||e[7]!==t?(v=j=>Jm(t,s,j.label),e[6]=s,e[7]=t,e[8]=v):v=e[8],c=l.filter(v),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((v,j)=>{const S=Jm(t,s,v.label);return r.jsxs("div",{className:V("flex items-start gap-2.5 py-2",S?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:V("mt-0.5 flex size-4 shrink-0 items-center justify-center border",t.multiSelect?"rounded":"rounded-full",S?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:S&&r.jsx(mt,{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:[v.label,S&&r.jsx(Ee,{variant:"secondary",className:"ml-2",children:"Selected"})]}),v.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:v.description})]})]},`${v.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 c7(n){const e=B.c(61),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=y.useState(!1);let c;e[0]!==t?(c=s7(t),e[0]=t,e[1]=c):c=e[1];const d=c;let f;e[2]!==d||e[3]!==t?(f=a7(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?sn:p?Yn:Cr,w=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",v=t.isError&&"border-destructive/30";let j;e[7]!==v?(j=V("my-1 overflow-hidden rounded-lg border bg-card",v),e[7]=v,e[8]=j):j=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Uh,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=S):S=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=k):k=e[10];const C=d.length===1?"question":"questions";let N;e[11]!==d.length||e[12]!==C?(N=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[k,r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",C]})]}),e[11]=d.length,e[12]=C,e[13]=N):N=e[13];const _=t.isError?"destructive":p?"secondary":"outline";let A;e[14]!==b?(A=r.jsx(b,{"data-icon":"inline-start"}),e[14]=b,e[15]=A):A=e[15];let P;e[16]!==w||e[17]!==_||e[18]!==A?(P=r.jsxs(Ee,{variant:_,children:[A,w]}),e[16]=w,e[17]=_,e[18]=A,e[19]=P):P=e[19];let E;e[20]!==P||e[21]!==N?(E=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,P]}),e[20]=P,e[21]=N,e[22]=E):E=e[22];let T;e[23]!==t.timestamp?(T=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]=T):T=e[24];let I;e[25]!==E||e[26]!==T?(I=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[S,E,T]}),e[25]=E,e[26]=T,e[27]=I):I=e[27];let $;e[28]!==u||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?($=h&&i?r.jsx(t7,{toolCall:t,sessionId:i,embedded:!0}):d.length>0?d.map((U,H)=>r.jsx(l7,{question:U,answer:u[U.question],index:H,completed:t.result!==null},`${U.question}-${H}`)):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]=$):$=e[33];let R;e[34]!==x||e[35]!==t.isError||e[36]!==t.result?(R=t.result!==null&&!x&&r.jsxs("div",{className:V("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]=R):R=e[37];let M;e[38]!==$||e[39]!==R?(M=r.jsxs("div",{className:"px-3",children:[$,R]}),e[38]=$,e[39]=R,e[40]=M):M=e[40];let D;e[41]!==s?(D=()=>{s||l(d7)},e[41]=s,e[42]=D):D=e[42];let O;e[43]!==m?(O=m?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),e[43]=m,e[44]=O):O=e[44];let L;e[45]!==m||e[46]!==D||e[47]!==O?(L=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:D,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[O,"Raw details"]}),e[45]=m,e[46]=D,e[47]=O,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 W;return e[56]!==I||e[57]!==M||e[58]!==z||e[59]!==j?(W=r.jsxs("section",{className:j,"aria-label":"Question history",children:[I,M,z]}),e[56]=I,e[57]=M,e[58]=z,e[59]=j,e[60]=W):W=e[60],W}function d7(n){return!n}const u7={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 f7(n){return typeof n=="object"&&n!==null}function cn(...n){return n.find(e=>typeof e=="string")??""}function So(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function Vd(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 Wr(n,e=""){const t=Vd(n);if(t.length===0)return e;const s=So(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function Gd(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const Qm={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function Ki(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 Qm[i]?Qm[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 m7(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 Vt(n,...e){for(const t of e){const s=m7(Ed(n,t));if(s)return s;const o=Ad(n,t)[0];if(o)return o}return""}function p7(n,...e){for(const t of e){const s=ex(n,t)[0];if(s!==void 0)return s}return null}function qi(n){return Vt(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 h7=[{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 Zm(n,e){return e.flatMap(t=>Ad(n,t))}function g7(n,e){const t=e.summaryGroups.map(i=>Zm(n,i)),s=e.detail?ex(n,e.detail.property):[],o=e.countProperties?Zm(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>Wr(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(tx(n),Vd(o).length,s.length,1)}}function x7(n){const e=[];for(const t of h7){const s=Ed(n,t.key);s&&e.push(g7(s,t))}return e}function b7(n){const e=x7(n);return e.length===0?{label:"Browse web",summary:qi(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>Gd(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function P0(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:Ki(e,!0),action:Ki(t.join(" "))}}function v7(n,e){const t=P0(n);if(!t)return{label:Ki(n),summary:qi(e),styleName:"Mcp"};const s=qi(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function y7(n){const e=Vn(n.trim(),0),t=(e==null?void 0:e.value)??n,s=Vd(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return Wr(s,s.length>0?Gd(s.length,"file"):"")}function w7(n){const e=n.argumentSource;switch(n.name){case"exec_command":return{label:"Run command",summary:Vt(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=p7(e,"session_id"),s=Vt(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?So(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:y7(e),styleName:"Edit"};case"web__run":case"web_search":return b7(e);case"view_image":return{label:"View image",summary:Vt(e,"path"),styleName:"Read"};case"update_plan":{const t=Ed(e,"plan"),s=t?tx(t):0;return{label:"Update plan",summary:s>0?Gd(s,"step"):Vt(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:Vt(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TodoWrite"};case"update_goal":return{label:"Update goal",summary:Vt(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:Vt(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:Vt(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[Vt(e,"server"),Vt(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:Vt(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:Vt(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:Vt(e,"prompt"),styleName:"Image"};default:return n.name.startsWith("mcp__")?v7(n.name,e):{label:Ki(n.name),summary:qi(e),styleName:n.name}}}function I0(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function j7(n){const e=Sk(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(w7),s=t[0];if(t.every(i=>i.label===s.label)){const i=Wr(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 S7(n){const e=f7(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:cn(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[cn(e==null?void 0:e.pattern),cn(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=cn(e==null?void 0:e.query,n.query);return{label:"Search web",summary:Wr([o,...s]),styleName:"WebSearch"}}const N7=["summary","headline","verdict","title"];function k7(n){const e=cn(...N7.map(t=>n[t]));if(e)return So(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 C7(n){const e=cn(n.description);if(e)return So(e);const t=cn(n.script);return(t?Ad(t,"name")[0]??"":"")||cn(n.scriptPath)}function ep(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 tp(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=cn(e.to,e.recipient),o=So(cn(e.summary,e.message,e.content));return[s,o].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return So(cn(e.subject,e.description));case"TaskUpdate":{const s=String(e.taskId??""),o=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(a=>typeof a=="string"):[],i=cn(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 C7(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return k7(e)||ep(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 Wr(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 ep(e)}}function Fa(n){if(I0(n))return j7(n.input.raw);if(n.name==="WebSearch")return S7(n.input);const e=P0(n.name);if(e)return{label:e.server,summary:[e.action,tp(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const t=u7[n.name];return{label:(t==null?void 0:t.label)??n.name,summary:tp(n),styleName:(t==null?void 0:t.styleName)??n.name}}function _7(n){return Fa(n).summary}const T7={mutating:"text-foreground",readOnly:"text-muted-foreground"},E7="text-destructive",np=8,A7=4,P7="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground",I7="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border p-2 font-mono text-xs leading-relaxed";function R7(n){return n.split(/\r\n|\r|\n/)}const $7={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"},M7="readOnly";function O7(n){return $7[n]??M7}function R0(n,e=!1){return e?E7:T7[O7(n)]}function Tl(n){const e=B.c(8),{isOpen:t,onClick:s,label:o,controlsId:i}=n,a=t?nt: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(ee,{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 $0(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(Ks,{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"?w0(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=R7(u),e[4]=u,e[5]=m):m=e[5];const p=m,h=Math.max(0,p.length-np);let g;e[6]!==p||e[7]!==u||e[8]!==s?(g=s?u:p.slice(0,np).join(`
111
+ `),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,v=i?"boxed":"unboxed";let j;e[10]!==x||e[11]!==w||e[12]!==v||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(y0,{result:i?a:x,filePath:t.input.file_path,expanded:w,variant:v}):f!==null?r.jsx(Sc,{result:i?f:x,expanded:w,alreadyPretty:!0,variant:v}):r.jsx("pre",{className:V(i?I7:P7,t.isError?V("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]=v,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 S;e[21]!==h||e[22]!==i||e[23]!==o||e[24]!==s||e[25]!==b?(S=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]=S):S=e[26];let k;return e[27]!==j||e[28]!==S?(k=r.jsxs("div",{className:"mt-1.5",children:[j,S]}),e[27]=j,e[28]=S,e[29]=k):k=e[29],k}function L7(n){const e=B.c(12),{chips:t}=n;let s,o,i,a;if(e[0]!==t){const d=t.slice(0,A7);s=t.length-d.length,o="flex min-w-0 items-center gap-1 overflow-hidden",i=`Sections: ${t.map(F7).join(", ")}`,a=d.map(z7),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 z7(n,e){return r.jsxs(Ee,{variant:"outline",className:V("h-4 shrink-0 px-1.5 font-mono text-[10px]",S0[n.tone]),children:[n.name,n.count>1?` ×${n.count}`:""]},e)}function F7(n){return`${n.name}${n.count>1?` ×${n.count}`:""}`}function M0(n){const e=B.c(7),{chips:t,summary:s,isMobile:o}=n;if(t){let c;return e[0]!==t?(c=r.jsx(L7,{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=V("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 sp(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=V("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=V("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(M0,{chips:l,summary:a,isMobile:s}),e[12]=l,e[13]=s,e[14]=a,e[15]=w):w=e[15];let v;e[16]!==h||e[17]!==b||e[18]!==w?(v=r.jsxs("div",{className:h,children:[b,w]}),e[16]=h,e[17]=b,e[18]=w,e[19]=v):v=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 S;e[23]!==t.outputReplacedByHook?(S=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-blue-400",title:"Output replaced by hook",children:"hook"}),e[23]=t.outputReplacedByHook,e[24]=S):S=e[24];let k;e[25]!==o||e[26]!==t?(k=r.jsx($0,{toolCall:t,isAgentActive:o}),e[25]=o,e[26]=t,e[27]=k):k=e[27];let C;e[28]!==S||e[29]!==k||e[30]!==j?(C=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[j,S,k]}),e[28]=S,e[29]=k,e[30]=j,e[31]=C):C=e[31];let N;return e[32]!==m||e[33]!==C||e[34]!==v?(N=r.jsxs(r.Fragment,{children:[m,v,C]}),e[32]=m,e[33]=C,e[34]=v,e[35]=N):N=e[35],N}function B7(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"&&Md(e)?e:null}function op(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(qd,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const U7={AskUserQuestion:"Question",Bash:"Command",exec:"Command",Task:"Agent",WebFetch:"Fetch",WebSearch:"Search",EnterPlanMode:"Plan mode",ExitPlanMode:"Plan review",ToolSearch:"Tool search"},O0=y.memo(function(e){var Le,ze;const t=B.c(164),{toolCall:s,groupedBashCalls:o,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c}=e,d=a===void 0?!1:a,{session:f,pendingInteraction:u}=it(),m=za(),[p,h]=y.useState(!1),[g,x]=y.useState(!1),[b,w]=y.useState(!1),[v,j]=y.useState(!1),[S,k]=y.useState(!1),[C,N]=y.useState(!1),_=y.useId(),A=y.useId(),P=y.useId(),E=y.useId(),T=y.useId(),[I,$]=y.useState(!1);let R;t[0]!==o||t[1]!==s?(R=o??(s.name==="Bash"?[s]:[]),t[0]=o,t[1]=s,t[2]=R):R=t[2];const M=R;let D;t[3]!==M||t[4]!==l||t[5]!==s.result?(D=(M.length>0?M.every(W7):s.result!==null)||!l,t[3]=M,t[4]=l,t[5]=s.result,t[6]=D):D=t[6];const L=m&&D&&!i&&!I;let F;t[7]!==s?(F=Fa(s),t[7]=s,t[8]=F):F=t[8];const z=F;let W;t[9]!==s?(W=I0(s),t[9]=s,t[10]=W):W=t[10];const U=W;let H;t[11]!==M?(H=M.length>0?M.flatMap(k0):null,t[11]=M,t[12]=H):H=t[12];const K=H;let q;t[13]!==K?(q=K?ET(K):void 0,t[13]=K,t[14]=q):q=t[14];const Y=q,G=m&&z.label===s.name?U7[s.name]??s.name:z.label,J=M.length>1?`${G} ×${M.length}`:G,Q=z.label===s.name?s.name:`${z.label} (${s.name})`;let X,Z,se,ne,re,ie,ae,te,ue,le,de,he,xe,ce;if(t[15]!==M||t[16]!==Y||t[17]!==E||t[18]!==S||t[19]!==v||t[20]!==J||t[21]!==i||t[22]!==d||t[23]!==p||t[24]!==l||t[25]!==U||t[26]!==L||t[27]!==m||t[28]!==Q||t[29]!==u||t[30]!==z.styleName||t[31]!==z.summary||t[32]!==b||t[33]!==g||t[34]!==(K==null?void 0:K.length)||t[35]!==(f==null?void 0:f.sessionId)||t[36]!==c||t[37]!==s){he=Symbol.for("react.early_return_sentinel");e:{const _e=R0(z.styleName,s.isError||M.some(H7));let Ce;t:{if(M.length<=1){Ce=s;break t}const Ye=M.some(K7)?null:s.result;let Me;t[52]!==M?(Me=M.some(q7),t[52]=M,t[53]=Me):Me=t[53];let Ue;t[54]!==M?(Ue=M.some(V7),t[54]=M,t[55]=Ue):Ue=t[55];let ot;t[56]!==M?(ot=M.reduce(G7,0),t[56]=M,t[57]=ot):ot=t[57];let Kt;t[58]!==Ye||t[59]!==Me||t[60]!==Ue||t[61]!==ot||t[62]!==s?(Kt={...s,result:Ye,isError:Me,outputReplacedByHook:Ue,hookDurationMs:ot},t[58]=Ye,t[59]=Me,t[60]=Ue,t[61]=ot,t[62]=s,t[63]=Kt):Kt=t[63],Ce=Kt}const We=Ce;let Fe;t[64]!==s.timestamp?(Fe=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[64]=s.timestamp,t[65]=Fe):Fe=t[65];const Ne=Fe;let me;t[66]!==s.timestamp?(me=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[66]=s.timestamp,t[67]=me):me=t[67];const Oe=me;se=d||m&&i,ae=se||p,te=se||g,ie=se||v;const Pe=M.length>1?`${(K==null?void 0:K.length)??M.length} commands`:z.summary;let Be;t[68]!==c||t[69]!==Pe||t[70]!==s.name?(Be=s.name==="Skill"&&c?c.get(Pe)??null:null,t[68]=c,t[69]=Pe,t[70]=s.name,t[71]=Be):Be=t[71],le=Be,ue=le==null?void 0:le.filePath,Z=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string",X=Z?"diff":s.name==="Bash"||U?"command":"result",re=d||S;const oe=B7(s),pe=oe!==null&&((Le=s.result)==null?void 0:Le.trim())==="";let Te;t[72]!==M.length||t[73]!==pe||t[74]!==m||t[75]!==b||t[76]!==s?(Te=s.result!==null&&!pe&&M.length===0?r.jsx(D7,{toolCall:s,resultExpanded:b,onToggleExpanded:()=>w(!b),isMobile:m}):null,t[72]=M.length,t[73]=pe,t[74]=m,t[75]=b,t[76]=s,t[77]=Te):Te=t[77],ne=Te;let $e;t[78]!==L?($e=()=>{L&&$(!0)},t[78]=L,t[79]=$e):$e=t[79];const He=$e;if(s.name==="AskUserQuestion"){const Ye=(u==null?void 0:u.type)==="question"&&u.toolUseId===s.id,Me=f==null?void 0:f.sessionId;let Ue;t[80]!==se||t[81]!==Ye||t[82]!==Me||t[83]!==s?(Ue=r.jsx(c7,{toolCall:s,expandToolPayloads:se,isAwaitingAnswer:Ye,sessionId:Me}),t[80]=se,t[81]=Ye,t[82]=Me,t[83]=s,t[84]=Ue):Ue=t[84],he=Ue;break e}const Ke=L?"py-1":"py-1.5",st=We.isError&&!L&&"rounded-md bg-destructive/5 px-2";t[85]!==Ke||t[86]!==st?(xe=V(Ke,st),t[85]=Ke,t[86]=st,t[87]=xe):xe=t[87],ce=L?r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"h-auto w-full justify-start px-1 py-1 text-left",onClick:He,"aria-label":`Expand ${J} tool call`,title:Ne,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[r.jsx("span",{className:V("shrink-0 font-mono text-xs",_e),title:Q,children:J}),r.jsx(M0,{chips:Y,summary:Pe})]}),r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-end"}),r.jsx($0,{toolCall:We,isAgentActive:l})]}):m?r.jsx("div",{className:"flex items-center gap-1.5",title:Ne,children:r.jsx(sp,{toolCall:We,isMobile:!0,isAgentActive:l,displayName:J,summary:Pe,sectionChips:Y,nameTitle:Q,nameClass:_e,timeLabel:Ne,timeIso:Oe})}):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:Ne,"aria-label":`Toggle ${J} details${Pe?`: ${Pe}`:""}`,"aria-expanded":re,"aria-controls":E,onClick:()=>{d||k(Y7)},children:r.jsx(sp,{toolCall:We,isMobile:!1,isAgentActive:l,displayName:J,summary:Pe,sectionChips:Y,nameTitle:Q,nameClass:_e,timeLabel:Ne,timeIso:Oe})}),de=pe&&!L&&r.jsx(vc,{src:oe,alt:oe.slice(oe.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[15]=M,t[16]=Y,t[17]=E,t[18]=S,t[19]=v,t[20]=J,t[21]=i,t[22]=d,t[23]=p,t[24]=l,t[25]=U,t[26]=L,t[27]=m,t[28]=Q,t[29]=u,t[30]=z.styleName,t[31]=z.summary,t[32]=b,t[33]=g,t[34]=K==null?void 0:K.length,t[35]=f==null?void 0:f.sessionId,t[36]=c,t[37]=s,t[38]=X,t[39]=Z,t[40]=se,t[41]=ne,t[42]=re,t[43]=ie,t[44]=ae,t[45]=te,t[46]=ue,t[47]=le,t[48]=de,t[49]=he,t[50]=xe,t[51]=ce}else X=t[38],Z=t[39],se=t[40],ne=t[41],re=t[42],ie=t[43],ae=t[44],te=t[45],ue=t[46],le=t[47],de=t[48],he=t[49],xe=t[50],ce=t[51];if(he!==Symbol.for("react.early_return_sentinel"))return he;let be;t[88]!==L||t[89]!==s.id||t[90]!==s.resultImages?(be=!L&&((ze=s.resultImages)==null?void 0:ze.map((_e,Ce)=>r.jsx(vc,{src:`data:${_e.source.media_type};base64,${_e.source.data}`,alt:`Tool result image ${Ce+1}`,id:`tool-result-image:${s.id}:${Ce}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${_e.source.media_type}-${_e.source.data.length}-${_e.source.data.slice(0,32)}-${_e.source.data.slice(-32)}`))),t[88]=L,t[89]=s.id,t[90]=s.resultImages,t[91]=be):be=t[91];let ge;t[92]!==L||t[93]!==ue||t[94]!==le?(ge=le&&!L&&r.jsxs("div",{className:"mt-1 flex items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",le.source]}),ue&&(!Ds()||vd())&&r.jsxs(ee,{type:"button",variant:"link",size:"xs",onClick:_e=>{_e.stopPropagation(),ur(ue)},className:"h-auto px-0 text-muted-foreground",title:ue,children:[r.jsx(Bh,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[92]=L,t[93]=ue,t[94]=le,t[95]=ge):ge=t[95];let fe;t[96]!==v||t[97]!==Z||t[98]!==p||t[99]!==L||t[100]!==m||t[101]!==_||t[102]!==A||t[103]!==P||t[104]!==ne||t[105]!==g||t[106]!==ie||t[107]!==ae||t[108]!==te?(fe=m&&!L&&r.jsxs("div",{className:"flex gap-3 mt-1",children:[Z&&r.jsx(Tl,{isOpen:ie,onClick:()=>j(!v),label:"Diff",controlsId:_}),r.jsx(Tl,{isOpen:ae,onClick:()=>h(!p),label:"Input",controlsId:A}),ne&&r.jsx(Tl,{isOpen:te,onClick:()=>x(!g),label:"Result",controlsId:P})]}),t[96]=v,t[97]=Z,t[98]=p,t[99]=L,t[100]=m,t[101]=_,t[102]=A,t[103]=P,t[104]=ne,t[105]=g,t[106]=ie,t[107]=ae,t[108]=te,t[109]=fe):fe=t[109];let je;t[110]!==Z||t[111]!==L||t[112]!==m||t[113]!==_||t[114]!==ie||t[115]!==s?(je=m&&!L&&Z&&r.jsx(ut,{open:ie,children:r.jsx(ft,{id:_,children:r.jsx(op,{toolCall:s})})}),t[110]=Z,t[111]=L,t[112]=m,t[113]=_,t[114]=ie,t[115]=s,t[116]=je):je=t[116];let Se;t[117]!==M||t[118]!==l||t[119]!==U||t[120]!==L||t[121]!==m||t[122]!==A||t[123]!==se||t[124]!==(f==null?void 0:f.cwd)||t[125]!==ae||t[126]!==s.input?(Se=m&&!L&&r.jsx(ut,{open:ae,children:r.jsx(ft,{id:A,children:M.length>0?r.jsx(Ym,{toolCalls:M,cwd:f==null?void 0:f.cwd,expandAll:se,isAgentActive:!!l}):U?r.jsx(Vm,{input:s.input}):r.jsx(Sc,{result:JSON.stringify(s.input),expanded:!0})})}),t[117]=M,t[118]=l,t[119]=U,t[120]=L,t[121]=m,t[122]=A,t[123]=se,t[124]=f==null?void 0:f.cwd,t[125]=ae,t[126]=s.input,t[127]=Se):Se=t[127];let Ae;t[128]!==s.id||t[129]!==s.name||t[130]!==s.result?(Ae=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(Hd,{toolUseId:s.id}),t[128]=s.id,t[129]=s.name,t[130]=s.result,t[131]=Ae):Ae=t[131];let Ie;t[132]!==L||t[133]!==m||t[134]!==P||t[135]!==ne||t[136]!==te?(Ie=m&&!L&&ne&&r.jsx(ut,{open:te,children:r.jsx(ft,{id:P,children:ne})}),t[132]=L,t[133]=m,t[134]=P,t[135]=ne,t[136]=te,t[137]=Ie):Ie=t[137];let Re;t[138]!==M||t[139]!==T||t[140]!==C||t[141]!==E||t[142]!==X||t[143]!==d||t[144]!==Z||t[145]!==l||t[146]!==m||t[147]!==ne||t[148]!==(f==null?void 0:f.cwd)||t[149]!==re||t[150]!==s?(Re=!m&&r.jsx(ut,{open:re,children:r.jsxs(ft,{id:E,onClick:X7,children:[X==="diff"&&Z&&r.jsx(op,{toolCall:s}),X==="command"&&(M.length>0?r.jsx(Ym,{toolCalls:M,cwd:f==null?void 0:f.cwd,expandAll:d,isAgentActive:!!l}):r.jsx(Vm,{input:s.input})),(X==="result"||X==="command")&&ne,r.jsx("button",{type:"button",className:"mt-1 text-[10px] text-muted-foreground/50 transition-colors hover:text-muted-foreground","aria-expanded":C,"aria-controls":T,onClick:_e=>{_e.stopPropagation(),N(J7)},children:"input"}),r.jsx(ut,{open:C,children:r.jsx(ft,{id:T,children:r.jsx(Sc,{result:JSON.stringify(M.length>1?M.map(Q7):s.input),expanded:!0})})})]})}),t[138]=M,t[139]=T,t[140]=C,t[141]=E,t[142]=X,t[143]=d,t[144]=Z,t[145]=l,t[146]=m,t[147]=ne,t[148]=f==null?void 0:f.cwd,t[149]=re,t[150]=s,t[151]=Re):Re=t[151];let De;return t[152]!==de||t[153]!==be||t[154]!==ge||t[155]!==fe||t[156]!==je||t[157]!==Se||t[158]!==Ae||t[159]!==Ie||t[160]!==Re||t[161]!==xe||t[162]!==ce?(De=r.jsxs("div",{className:xe,children:[ce,de,be,ge,fe,je,Se,Ae,Ie,Re]}),t[152]=de,t[153]=be,t[154]=ge,t[155]=fe,t[156]=je,t[157]=Se,t[158]=Ae,t[159]=Ie,t[160]=Re,t[161]=xe,t[162]=ce,t[163]=De):De=t[163],De});function W7(n){return n.result!==null}function H7(n){return n.isError}function K7(n){return n.result===null}function q7(n){return n.isError}function V7(n){return n.outputReplacedByHook}function G7(n,e){return n+(e.hookDurationMs??0)}function Y7(n){return!n}function X7(n){return n.stopPropagation()}function J7(n){return!n}function Q7(n){return n.input}const Z7=y.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,f]=y.useState(!0),u=o.some(j=>j.name==="AskUserQuestion"&&j.result===null),[m,p]=y.useState(null),h=y.useRef(u);y.useEffect(()=>{u&&(h.current=!0)},[u]);const g=i||d,x=i||(m??(u||h.current)),b=s==="approved"?ra:s==="rejected"?Ks:Os,w=g?nt:Je,v=x?nt:Je;return r.jsxs(ut,{open:g,onOpenChange:f,className:V("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(Wt,{render:r.jsx(ee,{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(Py,{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:V("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(ft,{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(On,{remarkPlugins:[pa],components:Fn,children:e})}),o.length>0&&r.jsxs(ut,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs(Wt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(v,{"data-icon":"inline-start"}),o.length," call",o.length===1?"":"s"," during planning"]}),r.jsx(ft,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(j=>r.jsx(O0,{toolCall:j,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},j.id))})})]})]})})]})}),e8=y.memo(function(e){const t=B.c(14),{content:s}=e,[o,i]=y.useState(!0),a=o?nt:Je;let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(ee,{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(Iy,{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(Wt,{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=[pa],t[7]=m):m=t[7];let p;t[8]!==s?(p=r.jsx(ft,{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(On,{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(ut,{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}),El=1;function rp(n,e){return!e||n.length<=El?{visible:[...n],hidden:0}:{visible:n.slice(-El),hidden:n.length-El}}function t8(n){return`${n} earlier step${n===1?"":"s"}`}const n8=y.memo(function(e){const t=B.c(15),{blocks:s,expandAll:o}=e,[i,a]=y.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(Wt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(nt,{"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(s8),t[6]=s,t[7]=f):f=t[7];let u;t[8]!==f?(u=r.jsx(ft,{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(ut,{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 s8(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 vr(n,e){if(!n&&!e)return{add:0,del:0};const t=n?n.split(`
112
+ `):[],s=e?e.split(`
113
+ `):[];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 o8(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(`
114
+ `);if(l){const c=vr("",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(`
115
+ `),o=t.map(a=>a.current).join(`
116
+ `),i=vr(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const r8=new Set(["echo","printf","true","false",":"]),i8=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),a8=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),l8=new Set(["ls","tree","du"]);function c8(n){return n.split(/\|\||&&|[|;\n]/).map(e=>e.trim()).filter(Boolean)}function d8(n){const e=c8(n);let t=!1,s=!1,o=!1,i=!1;for(const a of e){const l=a.split(/\s+/)[0];if(!(!l||r8.has(l)))if(i=!0,i8.has(l))t=!0;else if(a8.has(l))s=!0;else if(l8.has(l))o=!0;else return"shell"}return i?o?"list":t?"search":s?"read":"shell":"shell"}const u8=/[\\/]claude(?:-\d+)?[\\/](?:[^\\/]+[\\/])+scratchpad[\\/]/i;function f8(n){return u8.test(n)}const m8=new Set(["Grep","Glob"]),p8=new Set(["Bash","PowerShell"]),h8=new Set(["Edit","Write","NotebookEdit","MultiEdit"]),g8=new Set(["Task","Agent"]);function ip(n){const e=n.file_path??n.path;return typeof e=="string"?e:null}function x8(n){return typeof n.command=="string"?n.command:null}function b8(n){if(!n.startsWith("mcp__"))return null;const e=n.split("__")[1];return e?e.replace(/^claude[._]ai[._]/i,"").replace(/_/g," "):null}function v8(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=vr(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=vr(t,s);return{added:o.add,removed:o.del}}function to(n,e,t=`${e}s`){return`${n} ${n===1?e:t}`}function y8(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 w8(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 S of n){const k=b8(S.name);if(k){p+=1,o.add(k);continue}if(h8.has(S.name)){const C=ip(S.input),N=v8(S.name,S.input);C&&f8(C)?(l+=1,c+=N.added,d+=N.removed):(t.add(C??S.id),i+=N.added,a+=N.removed);continue}if(S.name==="Read"){const C=ip(S.input);C?s.add(C):u+=1;continue}if(m8.has(S.name)){f+=1;continue}if(p8.has(S.name)){const C=x8(S.input);switch(C===null?"shell":d8(C)){case"search":f+=1;break;case"list":m+=1;break;case"read":u+=1;break;default:x+=1}continue}if(g8.has(S.name)){h+=1;continue}g+=1}const b=s.size>0?s.size:u,w=[],v=(S,k,C=0,N=0)=>{w.push(C>0||N>0?{key:S,text:k,added:C,removed:N}:{key:S,text:k})},j=e.thoughtForMs??0;if(j>0&&v("thought",`thought for ${y8(j)}`),t.size>0&&v("edit",`edited ${to(t.size,"file")}`,i,a),l>0&&v("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),f>0&&v("search",`searched for ${to(f,"pattern")}`),b>0&&v("read",`read ${to(b,"file")}`),m>0&&v("list",`listed ${to(m,"directory","directories")}`),p>0){const S=[...o].join(", ")||"MCP";v("mcp",p>1?`called ${S} ${p} times`:`called ${S}`)}return h>0&&v("agent",`ran ${to(h,"agent")}`),g>0&&v("other",`called ${to(g,"tool")}`),x>0&&v("bash",`ran ${x} shell ${x===1?"command":"commands"}`),{clauses:w}}const ap="text-muted-foreground";function lp(n){const e=B.c(4),{summary:t}=n;let s;e[0]!==t.clauses?(s=t.clauses.map(j8),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 j8(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 cp=y.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]=y.useState(null),b=y.useRef(null),w=m&&s.some(S8);let v;t[0]!==s?(v=s.some(N8),t[0]=s,t[1]=v):v=t[1];const j=v,S=o||j||(g??w),k=g===null&&w&&!o&&!j,C=y.useRef(null),N=y.useRef(null);let _,A;t[2]!==a||t[3]!==s?(_=()=>{if(!a){C.current=null;return}a!==C.current&&s.some(K=>K.id===a)&&(C.current=a,x(!0),N.current=requestAnimationFrame(()=>{N.current=requestAnimationFrame(()=>{var K;N.current=null,(K=b.current)==null||K.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},A=[a,s],t[2]=a,t[3]=s,t[4]=_,t[5]=A):(_=t[4],A=t[5]),y.useEffect(_,A);let P,E;t[6]===Symbol.for("react.memo_cache_sentinel")?(P=()=>()=>{N.current!==null&&cancelAnimationFrame(N.current)},E=[],t[6]=P,t[7]=E):(P=t[6],E=t[7]),y.useEffect(P,E);let T;if(t[8]!==s){const K=new Map;for(const q of s){const{label:Y,styleName:G}=Fa(q),J=K.get(Y);J?(J.count=J.count+1,J.hasError=J.hasError||!!q.isError):K.set(Y,{count:1,styleName:G,hasError:!!q.isError})}T=[...K].sort(k8),t[8]=s,t[9]=T}else T=t[9];const I=T;let $;t[10]!==h||t[11]!==s?($=w8(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=$):$=t[12];const R=$,M=function(q,Y,G){const J=G??[q],Q=m&&Y&&J.some(C8),X=a!==null&&J.some(Z=>Z.id===a);return r.jsx("div",{ref:X?b:void 0,className:V(X&&"rounded-md ring-1 ring-ring"),children:r.jsx(O0,{toolCall:q,groupedBashCalls:G,expandAll:o,expandToolPayloads:i,isAgentActive:Q,skillMetadata:u})},q.id)},D=function(q,Y){const G=[];let J=0;for(;J<q.length;){const Q=q[J];if(Q.name!=="Bash"){G.push(M(Q,Y&&J===q.length-1)),J++;continue}let X=J+1;for(;X<q.length&&q[X].name==="Bash";)X++;const Z=q.slice(J,X);G.push(M(Q,Y&&X===q.length,Z.length>1?Z:void 0)),J=X}return G};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:D(s,!0)});if(S){let K;t[13]!==o||t[14]!==j||t[15]!==R||t[16]!==p?(K=!o&&!j&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(nt,{"data-icon":"inline-start"}),R.clauses.length>0?r.jsx(lp,{summary:R}):r.jsxs("span",{className:V("font-mono text-xs",ap),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=j,t[15]=R,t[16]=p,t[17]=K):K=t[17];const q=c?(()=>{const G=rp(c,k);return r.jsxs(r.Fragment,{children:[G.hidden>0&&r.jsx(dp,{count:G.hidden,onReveal:()=>x(!0)}),(()=>{const J=[];let Q=0;for(;Q<G.visible.length;){const X=G.visible[Q];if(X.kind==="thinking"){J.push(r.jsx(n8,{blocks:X.blocks,expandAll:!1},`thinking-${Q}`)),Q++;continue}const Z=[...X.toolCalls];let se=Q+1;for(;se<G.visible.length&&G.visible[se].kind==="tool_calls";){const ne=G.visible[se];ne.kind==="tool_calls"&&Z.push(...ne.toolCalls),se++}J.push(...D(Z,se===G.visible.length)),Q=se}return J})()]})})():(()=>{const G=rp(s,k);return r.jsxs(r.Fragment,{children:[G.hidden>0&&r.jsx(dp,{count:G.hidden,onReveal:()=>x(!0)}),D(G.visible,!0)]})})();let Y;return t[18]!==K||t[19]!==q?(Y=r.jsxs("div",{className:"motion-enter flex flex-col gap-2",children:[K,q]}),t[18]=K,t[19]=q,t[20]=Y):Y=t[20],Y}let O;t[21]===Symbol.for("react.memo_cache_sentinel")?(O=()=>x(!0),t[21]=O):O=t[21];let L;t[22]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Je,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[22]=L):L=t[22];let F;t[23]!==R?(F=R.clauses.length>0&&r.jsx(lp,{summary:R}),t[23]=R,t[24]=F):F=t[24];let z;t[25]!==p?(z=p>0&&r.jsxs("span",{className:V("font-mono text-xs",ap),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=z):z=t[26];let W;t[27]!==I?(W=I.map(_8),t[27]=I,t[28]=W):W=t[28];let U;t[29]!==z||t[30]!==W?(U=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[z,W]}),t[29]=z,t[30]=W,t[31]=U):U=t[31];let H;return t[32]!==F||t[33]!==U?(H=r.jsxs(ee,{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:[L,r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[F,U]})]}),t[32]=F,t[33]=U,t[34]=H):H=t[34],H});function dp(n){const e=B.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(nt,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=t8(t),e[1]=t,e[2]=i):i=e[2];let a;return e[3]!==s||e[4]!==i?(a=r.jsxs(ee,{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 S8(n){return n.result===null}function N8(n){return n.name==="AskUserQuestion"}function k8(n,e){return e[1].count-n[1].count}function C8(n){return n.result===null}function _8(n){const[e,t]=n,{count:s,styleName:o,hasError:i}=t;return r.jsxs("span",{className:V("font-mono text-xs",R0(o,i)),children:[e,s>1?` ×${s}`:""]},e)}function T8(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=V("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=V("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(ee,{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 D0="synthesizedFrom",up=/[.*+?[\]{}()^$|]/,E8=/[$*?`~]|\\\s/,L0=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,A8=new RegExp(L0,"g");function Yd(n,e,t,s){return{id:e,name:t,input:{...s,[D0]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function P8(n){return typeof n.input[D0]=="string"}function I8(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function fp(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function Ba(n,e){const t=I8(n.trim());return!t||E8.test(t)?null:t.startsWith("/")?fp(t):e?fp(`${e}/${t}`):null}function R8(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 $8(n){const e=n.split(`
117
+ `),t=[];let s=0;for(;s<e.length;){const o=e[s];s++;const i=new Map;for(const a of o.matchAll(A8)){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(`
118
+ `)))}for(const a of R8(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function M8(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?Ba(t[1]??t[2]??t[3]??"",e):null}function O8(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 D8(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(L0);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=O8(n.text);if(!o)return null;const i=Ba(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function mp(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==="|"||!up.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&up.test(i))return null;s+=i}return s}const L8=/^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 z8(n,e){var m;const t=(m=n.text.match(L8))==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=mp(s,"pattern"),f=mp(o,"replacement");if(!d||f===null)return null;const u=Ba(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 z0(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of $8(t)){const a=M8(i.text,o);if(a){o=a;continue}const l=D8(i,o)??z8(i,o);l&&s.push(Yd(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function F0(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=Ba(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(Yd(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:f===!0}))}return i}function B0(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?nx("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Yd(n,s.id,s.name,s.input)):[]}function tr(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(...F0(s,e)):s.name==="Bash"?t.push(...z0(s,e)):s.name==="apply_patch"&&t.push(...B0(s,e)));return t}function Vi(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&F0(t,e).length>0||t.name==="Bash"&&z0(t,e).length>0||t.name==="apply_patch"&&B0(t,e).length>0))return!0;return!1}const F8=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"]),B8={json:vf,jsonc:vf,md:Ci,mdx:Ci,txt:Ci,png:Cs,jpg:Cs,jpeg:Cs,gif:Cs,webp:Cs,svg:Cs,ico:Cs,sh:oi,bash:oi,zsh:oi,fish:oi};function U0(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function U8(n){const e=U0(n);return B8[e]??(F8.has(e)?_r:Lh)}function Nc(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=V("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 pp=5;function Xd(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*pp);i=pp-f,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:f},H8),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},W8),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 W8(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function H8(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const Gi="cogpit:open-subagent";function W0(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 Jd(n){const e=B.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=r.jsx(ee,{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(Gi,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const H0=y.memo(function(e){const t=B.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=Xx(),[d,f]=y.useState(o),[u,m]=y.useState(o),p=y.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Se=>{f(Se),Se?y.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]),y.useEffect(x,b);let w,v;t[4]!==i?(w=()=>{i&&g(!0)},v=[i,g],t[4]=i,t[5]=w,t[6]=v):(w=t[5],v=t[6]),y.useEffect(w,v);let j;t[7]!==s.filePath?(j=U0(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const S=j,k=s.netOriginal,C=s.netCurrent,N=!!(k||C);let _;t[9]!==s.edits?(_=s.edits.some(G8),t[9]=s.edits,t[10]=_):_=t[10];const P=a==="per-edit"?_:N,E=u&&c&&P,[T,I]=y.useState(0);let $;t[11]===Symbol.for("react.memo_cache_sentinel")?($=Se=>{if(!Se)return;const Ae=Se.offsetHeight;I(Ie=>Ie===Ae?Ie:Ae)},t[11]=$):$=t[11];const R=$,M=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,D=s.filePath,O=i?"border-ring ring-2 ring-ring/20":"border-border";let L;t[12]!==O?(L=V("rounded-lg border bg-card transition-colors",O),t[12]=O,t[13]=L):L=t[13];let F;t[14]!==d?(F=()=>g(!d),t[14]=d,t[15]=F):F=t[15];let z;t[16]!==d?(z=d?r.jsx(nt,{"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 W;t[18]!==S?(W=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:S}),t[18]=S,t[19]=W):W=t[19];let U;t[20]!==s.opTypes?(U=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=U):U=t[21];let H;t[22]!==s.opTypes?(H=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=H):H=t[23];let K;t[24]!==U||t[25]!==H?(K=r.jsx(W0,{hasEdit:U,hasWrite:H}),t[24]=U,t[25]=H,t[26]=K):K=t[26];let q;t[27]!==s.shortPath?(q=r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=q):q=t[28];let Y;t[29]!==M?(Y=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:M}),t[29]=M,t[30]=Y):Y=t[30];let G;t[31]!==s.editCount?(G=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]=G):G=t[32];let J;t[33]!==d||t[34]!==F||t[35]!==z||t[36]!==W||t[37]!==K||t[38]!==q||t[39]!==Y||t[40]!==G?(J=r.jsxs(ee,{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,W,K,q,Y,G]}),t[33]=d,t[34]=F,t[35]=z,t[36]=W,t[37]=K,t[38]=q,t[39]=Y,t[40]=G,t[41]=J):J=t[41];let Q;t[42]!==s.subAgentId?(Q=s.subAgentId&&r.jsx(Jd,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=Q):Q=t[43];let X;t[44]!==s.filePath?(X=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>ur(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=X):X=t[45];let Z;t[46]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(Sr,{"data-icon":"inline-start"}),t[46]=Z):Z=t[46];let se;t[47]!==X?(se=r.jsx(Et,{render:X,children:Z}),t[47]=X,t[48]=se):se=t[48];let ne;t[49]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(At,{children:"Open in editor"}),t[49]=ne):ne=t[49];let re;t[50]!==se?(re=r.jsxs(Tt,{children:[se,ne]}),t[50]=se,t[51]=re):re=t[51];let ie;t[52]!==s.filePath?(ie=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>ur(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(Ry,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let te;t[55]!==ie?(te=r.jsx(Et,{render:ie,children:ae}),t[55]=ie,t[56]=te):te=t[56];let ue;t[57]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(At,{children:"View git diff"}),t[57]=ue):ue=t[57];let le;t[58]!==te?(le=r.jsxs(Tt,{children:[te,ue]}),t[58]=te,t[59]=le):le=t[59];let de;t[60]!==re||t[61]!==le?(de=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[re,le]}),t[60]=re,t[61]=le,t[62]=de):de=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 xe;t[65]!==s.delCount?(xe=s.delCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",s.delCount]}),t[65]=s.delCount,t[66]=xe):xe=t[66];let ce;t[67]!==s.addCount||t[68]!==s.delCount?(ce=r.jsx(Xd,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=ce):ce=t[69];let be;t[70]!==Q||t[71]!==de||t[72]!==he||t[73]!==xe||t[74]!==ce?(be=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Q,de,he,xe,ce]}),t[70]=Q,t[71]=de,t[72]=he,t[73]=xe,t[74]=ce,t[75]=be):be=t[75];let ge;t[76]!==J||t[77]!==be?(ge=r.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-card transition-colors hover:bg-accent",children:[J,be]}),t[76]=J,t[77]=be,t[78]=ge):ge=t[78];let fe;t[79]!==a||t[80]!==s.edits||t[81]!==s.filePath||t[82]!==s.netStartLine||t[83]!==P||t[84]!==T||t[85]!==C||t[86]!==k||t[87]!==d||t[88]!==E?(fe=r.jsx(K8,{showDiff:E,open:d,hasDiff:P,diffRef:R,lastDiffHeight:T,oldString:k,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]=P,t[84]=T,t[85]=C,t[86]=k,t[87]=d,t[88]=E,t[89]=fe):fe=t[89];let je;return t[90]!==s.filePath||t[91]!==l||t[92]!==L||t[93]!==ge||t[94]!==fe?(je=r.jsxs("div",{ref:l,"data-file-path":D,className:L,children:[ge,fe]}),t[90]=s.filePath,t[91]=l,t[92]=L,t[93]=ge,t[94]=fe,t[95]=je):je=t[95],je}),K8=y.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(V8,{edits:m,filePath:f}):r.jsx(qd,{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}),hp=3,q8=5,V8=y.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(Y8),l=a.length>hp,[c,d]=y.useState(l?hp:a.length);y.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(b=>Math.min(b+q8,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(Jd,{agentId:x.agentId})]}),r.jsx(qd,{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 G8(n){return!!(n.oldString||n.newString)}function Y8(n){return!!(n.oldString||n.newString)}const Al=new Map;function X8(n){var j;const e=Sn("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=y.useMemo(()=>{let S=0;for(const k of n.turns){S+=k.toolCalls.length;for(const C of k.subAgentActivity)S+=C.toolCalls.length}return S},[i,a]),c=y.useMemo(()=>{const S=[];for(let k=0;k<n.turns.length;k++)for(const C of n.turns[k].subAgentActivity){const N=o&&(C.status==="completed"||C.status==="failed"||C.status==="interrupted");(C.isBackground||N)&&C.toolCalls.length===0&&S.push({agentId:C.agentId,turnIndex:k})}return S},[n.turns,l,o]),[d,f]=y.useState(new Map),u=y.useRef(new Set);y.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const S=[];for(const{agentId:N}of c){const _=Ut(`${s}/${n.sessionId}/${N}`);if(!u.current.has(_)){if(Al.has(_)){f(A=>{const P=new Map(A);return P.set(N,Al.get(_)),P}),u.current.add(_);continue}S.push({agentId:N,cacheKey:_})}}if(S.length===0)return;let k=!1;async function C(){const N=new Map;await Promise.all(S.map(async({agentId:_,cacheKey:A})=>{try{const P=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(_)}.jsonl`,E=await ye(P);if(!E.ok)return;const T=await E.text(),$=f0(T,_).flatMap(R=>tr(R.toolCalls,n.cwd));Al.set(A,$),u.current.add(A),N.set(_,$)}catch{}})),!k&&N.size>0&&f(_=>{const A=new Map(_);for(const[P,E]of N)A.set(P,E);return A})}return C(),()=>{k=!0}},[s,n.sessionId,n.cwd,c]);const m=y.useMemo(()=>{const S=[],k=new Set;for(let C=0;C<n.turns.length;C++){const N=n.turns[C];for(const _ of tr(N.toolCalls,n.cwd))S.push({turnIndex:C,toolCall:_});for(const _ of N.subAgentActivity){for(const A of tr(_.toolCalls,n.cwd))S.push({turnIndex:C,toolCall:A,agentId:_.agentId});if((_.isBackground||o)&&_.toolCalls.length===0&&!k.has(_.agentId)){k.add(_.agentId);const A=d.get(_.agentId);if(A)for(const P of A)S.push({turnIndex:C,toolCall:P,agentId:_.agentId})}}}return S},[l,n.turns,d,o]),p=y.useMemo(()=>{const S=new Set;for(const k of m){const C=K0(k.toolCall);C&&S.add(C)}return[...S]},[m]),[h,g]=y.useState(new Map);y.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let S=!1;return Promise.all(p.map(k=>ye(`/api/file-content?path=${encodeURIComponent(k)}`).then(C=>C.ok?C.text():null).then(C=>C?[k,C]:null).catch(()=>null))).then(k=>{if(S)return;const C=new Map;for(const N of k)N&&C.set(N[0],N[1]);g(C)}),()=>{S=!0}},[e,p]);const x=n.turns.length-1,b=y.useMemo(()=>Yi(m,"all",h),[m,h]),w=y.useMemo(()=>Yi(m,x,h),[m,x,h]),v=y.useMemo(()=>{const S=new Map;for(const k of n.turns)for(const C of k.subAgentActivity)S.has(C.agentId)||S.set(C.agentId,{name:C.agentName,type:C.subagentType});return S},[n.turns]);return{fileChanges:m,fileContents:h,groupedByFile:b,groupedLastTurn:w,lastTurnIndex:x,agentMap:v}}function gp(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]===`
119
+ `&&s++;return s}function K0(n){return String(n.input.file_path??n.input.path??"")}function J8(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 Yi(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=K0(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],v=J8(w.toolCall);l.push(v),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:v.oldString,newString:v.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:gp(h,v.newString||v.oldString)})}const g=o8(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?gp(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 Q8(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=Yi(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 yr="cogpit:focus-file",Z8="cogpit:file-changes-prefs",eE={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function tE(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(Gi,{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(ee,{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=S=>r.jsx(H0,{file:S,defaultOpen:s,isHighlighted:o===S.filePath,diffMode:i},S.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 v;return e[33]!==b||e[34]!==w?(v=r.jsxs("div",{className:"flex flex-col gap-1",children:[b,w]}),e[33]=b,e[34]=w,e[35]=v):v=e[35],v}const nE=y.memo(function({session:e,sessionChangeKey:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(!0),a=y.useRef(!1),l=y.useRef(0),c=y.useRef(e.turns.length),[d,f]=y.useState(!1),[u,m]=y.useState(!1),[p,h]=Ur(Z8,{}),g={...eE,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[v,j]=y.useState(g.scope),S=y.useCallback(G=>{h(J=>({...J,expanded:G}))},[h]),k=y.useCallback(G=>{h(J=>({...J,diffMode:G}))},[h]),C=y.useCallback(G=>{h(J=>({...J,groupByAgent:G}))},[h]);y.useEffect(()=>{typeof v!="number"&&h(G=>({...G,scope:v}))},[v,h]);const[N,_]=y.useState(null),A=y.useRef(null),{fileChanges:P,fileContents:E,groupedByFile:T,groupedLastTurn:I,lastTurnIndex:$,agentMap:R}=X8(e),M=y.useMemo(()=>typeof v!="number"?null:Yi(P,v,E),[P,v,E]);function D(){return typeof v=="number"?M??[]:v==="all"?T:I}const O=D(),L=y.useMemo(()=>w?Q8(P,typeof v=="number"?v:v==="all"?"all":$,R,E):[],[w,P,v,$,R,E]);y.useEffect(()=>{const G=J=>{const Q=J.detail;Q!=null&&Q.filePath&&(j(Q.turnIndex),_(Q.filePath),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>_(null),3e3),requestAnimationFrame(()=>{var Z;const X=(Z=s.current)==null?void 0:Z.querySelector(`[data-file-path="${CSS.escape(Q.filePath)}"]`);X==null||X.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(yr,G),()=>{window.removeEventListener(yr,G),A.current&&clearTimeout(A.current)}},[]);const F=y.useCallback(()=>{const G=s.current;G&&(f(G.scrollTop>10),m(G.scrollHeight-G.scrollTop-G.clientHeight>10))},[]),z=y.useCallback(()=>{const G=s.current;G&&(i.current=G.scrollHeight-G.scrollTop-G.clientHeight<50,F())},[F]);if(y.useEffect(()=>{F()},[P.length,O.length,F]),y.useEffect(()=>{const G=s.current;G&&(G.scrollTop=G.scrollHeight),i.current=!0,a.current=!1,l.current=P.length,c.current=e.turns.length,j(g.scope),_(null),F()},[t]),y.useEffect(()=>{const G=e.turns.length;G>c.current&&(a.current=!0),c.current=G},[e.turns.length]),y.useEffect(()=>{if(P.length<=l.current){l.current=P.length;return}l.current=P.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var G;(G=o.current)==null||G.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[P.length]),P.length===0)return null;let W=0,U=0,H=0;if(w)for(const G of L)W+=G.totalAdd,U+=G.totalDel,H+=G.files.length;else{for(const G of O)W+=G.addCount,U+=G.delCount;H=O.length}function K(){j(v==="last"?"all":"last")}function q(){return typeof v=="number"?`Turn ${v+1}`:v==="all"?"All turns":`Last turn (T${$+1})`}const Y=q();return r.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-card",children:[r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[r.jsx(_r,{"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:[H," file",H!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",W]}),r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",U]}),r.jsxs(Tt,{children:[r.jsx(Et,{render:r.jsx(ee,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(Xn,{"data-icon":"inline-start"})}),r.jsx(At,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(Tt,{children:[r.jsx(Et,{render:r.jsx(ee,{variant:v==="all"?"secondary":"ghost",size:"icon-xs",onClick:K,"aria-label":v==="last"?"Show all turns":"Show last turn only"}),children:v==="all"?r.jsx($y,{"data-icon":"inline-start"}):r.jsx(Os,{"data-icon":"inline-start"})}),r.jsx(At,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(Tt,{children:[r.jsx(Et,{render:r.jsx(ee,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>k(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?r.jsx(My,{"data-icon":"inline-start"}):r.jsx(Oy,{"data-icon":"inline-start"})}),r.jsx(At,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(Tt,{children:[r.jsx(Et,{render:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>S(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(ua,{"data-icon":"inline-start"}):r.jsx(da,{"data-icon":"inline-start"})}),r.jsx(At,{children:x?"Collapse all":"Expand all"})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),v!=="all"&&$>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{const G=typeof v=="number"?v:$;G>0&&j(G-1)},disabled:(typeof v=="number"?v:$)<=0,"aria-label":"Previous turn",children:r.jsx(Vc,{"data-icon":"inline-start"})}),r.jsx("span",{className:V("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:Y}),v!=="all"&&$>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{j(G=>typeof G!="number"?G:G+1>=$?"last":G+1)},disabled:v==="last","aria-label":"Next turn",children:r.jsx(Je,{"data-icon":"inline-start"})}),typeof v=="number"&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:r.jsx(ct,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{className:V("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(G=>r.jsx(tE,{group:G,allExpanded:x,highlightPath:N,diffMode:b},G.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):O.length>0?O.map(G=>r.jsx(H0,{file:G,defaultOpen:x,isHighlighted:N===G.filePath,diffMode:b},G.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:V("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 sE(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=vr(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 tr(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>tr(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 xp(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function oE(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=xp();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=xp(),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,S]=[...u.children.entries()][0];if(S.isFile&&S.children.size===0)break;m+="/"+j,p+="/"+j,u=S}const h=o(u,p);let g=0,x=0,b=u.isFile?u.hasEdit:!1,w=u.isFile?u.hasWrite:!1,v=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&&(v=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:v,children:h}})}return o(s,"")}const rE=y.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=Sn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=sE(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=oE(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const f=d,[u,m]=y.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const I of c)p=p+I.additions,h=h+I.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=V("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=w):w=t[15];let v;t[16]!==w?(v=r.jsx(Je,{"data-icon":"inline-start",className:w}),t[16]=w,t[17]=v):v=t[17];let j;t[18]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(_r,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=j):j=t[18];const S=c.length!==1?"s":"";let k;t[19]!==c.length||t[20]!==S?(k=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",S]}),t[19]=c.length,t[20]=S,t[21]=k):k=t[21];let C,N;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(Nc,{add:x.add,del:x.del,className:"opacity-80"}),N=r.jsx(Xd,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=C,t[25]=N):(C=t[24],N=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 A;t[27]!==C||t[28]!==N||t[29]!==v||t[30]!==k?(A=r.jsxs(Wt,{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:[v,j,k,C,N,_]}),t[27]=C,t[28]=N,t[29]=v,t[30]=k,t[31]=A):A=t[31];let P;if(t[32]!==a||t[33]!==f||t[34]!==o){let I;t[36]!==a||t[37]!==o?(I=$=>r.jsx(iE,{node:$,depth:0,turnIndex:o,canFocusFiles:a},$.fullPath),t[36]=a,t[37]=o,t[38]=I):I=t[38],P=f.map(I),t[32]=a,t[33]=f,t[34]=o,t[35]=P}else P=t[35];let E;t[39]!==P?(E=r.jsx(ft,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:P})}),t[39]=P,t[40]=E):E=t[40];let T;return t[41]!==u||t[42]!==A||t[43]!==E?(T=r.jsxs(ut,{open:u,onOpenChange:m,children:[A,E]}),t[41]=u,t[42]=A,t[43]=E,t[44]=T):T=t[44],T}),iE=y.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=y.useState(!0),l=t*16+8;if(e.isFile){const c=U8(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(yr,{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(ee,{type:"button",variant:"ghost",size:"xs",disabled:!o,className:V("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(W0,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Jd,{agentId:e.subAgentId}),r.jsx(Nc,{add:e.additions,del:e.deletions}),r.jsx(Xd,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-full justify-start gap-1 rounded-sm font-mono text-xs font-normal",style:{paddingLeft:l},onClick:()=>a(!i),"aria-expanded":i,children:[i?r.jsx(nt,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(Dy,{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(Nc,{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 aE(n){const e=B.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let o;e[0]!==s?(o=r.jsx(ee,{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(Yc,{"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(Et,{render:o,children:[i,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7];const c=t!==1?"es":"";let d;e[8]!==t||e[9]!==c?(d=r.jsxs(At,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=r.jsxs(Tt,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function q0(n){return wx(n).status(n)}const lE=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Qd(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 Hr(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&lE.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?Qd(t):"Done";default:return null}}function cE(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(zy,{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(Hs,{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(Ly,{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(ua,{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(go,{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(Yn,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const bp=2e3,V0=600;function G0(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=V("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:`${V0}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(cE,{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=V("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 v;e[14]!==l||e[15]!==i?(v=!l&&i&&r.jsx(Zd,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=v):v=e[16];let j;e[17]!==d?(j=d.length>0&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",title:d.join(`
120
+ `),children:d.join(" · ")}),e[17]=d,e[18]=j):j=e[18];let S;e[19]!==t.pendingQueue?(S=(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]=S):S=e[20];let k;return e[21]!==w||e[22]!==v||e[23]!==j||e[24]!==S||e[25]!==u||e[26]!==p?(k=r.jsxs("div",{className:u,style:m,children:[p,w,v,j,S]}),e[21]=w,e[22]=v,e[23]=j,e[24]=S,e[25]=u,e[26]=p,e[27]=k):k=e[27],k}function dE(n){const e=B.c(28),{status:t,durationLabel:s}=n,[o,i]=y.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),bp),g=setTimeout(()=>i("ready"),bp+V0);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),y.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Yn,{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=V("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?Qd(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 v;e[10]!==s?(v=s&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=v):v=e[11];let j;return e[12]!==w||e[13]!==v?(j=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,v]}),e[12]=w,e[13]=v,e[14]=j):j=e[14],j}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Hr(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(G0,{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 uE=y.memo(function(){const e=B.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=it(),[l,c]=y.useState(!1),[d,f]=y.useState(!1),u=t==null?void 0:t.sessionId,[m,p]=y.useState(u);u!==m&&(p(u),c(!1),f(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I={status:"compacting"},e[0]=I):I=e[0],h=I;break e}const E=t.rawMessages;let T;e[1]!==E?(T=q0(E),e[1]=E,e[2]=T):T=e[2],h=T}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]),y.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 v=w,j=(v==null?void 0:v.status)==="completed",S=(t==null?void 0:t.turns[t.turns.length-1])??null;let k;e:{if(!j||!S){k=null;break e}let E;if(e[8]!==S){const T=ed(S);E=T!==null?Mn(T):null,e[8]=S,e[9]=E}else E=e[9];k=E}const C=k;if(a&&o==="connected"){let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(Uh,{className:"size-5 shrink-0 text-info"}),e[10]=E):E=e[10];const T=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let I;return e[11]!==T?(I=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[E,r.jsx("span",{className:"text-xs font-medium text-info",children:T})]}),e[11]=T,e[12]=I):I=e[12],I}if(!v)return null;if(j){let E;return e[13]!==v||e[14]!==C?(E=r.jsx(dE,{status:v,durationLabel:C}),e[13]=v,e[14]=C,e[15]=E):E=e[15],E}let N;e[16]!==v.pendingAgents||e[17]!==v.status||e[18]!==v.terminalReason||e[19]!==v.toolName?(N=Hr(v.status,v.toolName,v.terminalReason,v.pendingAgents),e[16]=v.pendingAgents,e[17]=v.status,e[18]=v.terminalReason,e[19]=v.toolName,e[20]=N):N=e[20];const _=N;if(!_)return null;const A=S==null?void 0:S.timestamp;let P;return e[21]!==v||e[22]!==_||e[23]!==A?(P=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(G0,{status:v,label:_,startTimestamp:A})}),e[21]=v,e[22]=_,e[23]=A,e[24]=P):P=e[24],P});function Zd(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(fE,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function fE(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=y.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=Mn(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]),y.useEffect(l,c);let d;e[5]!==s?(d=V("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=Mn(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 mE(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 pE=6e5;function hE(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,pE)}function vp(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+=hE(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 kc=new Map,gE=300*1e3;function yp(n){const e=kc.get(n);return e?Date.now()>e.expiresAt?(kc.delete(n),null):e.data:null}function xE(n,e){kc.set(n,{data:e,expiresAt:Date.now()+gE})}function bE(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?yp(Ut(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=y.useState(t),i=y.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||ka(window.location.pathname))return;const c=Ut(n),d=yp(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});xE(c,p),o(p)}).catch(vE),()=>f.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),y.useEffect(a,l),s}function vE(){}const yE=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),wE=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),jE=new Set(["AskUserQuestion","ExitPlanMode"]),SE=new Set(["text","thinking","tool_calls"]);function NE(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>jE.has(e.name)&&e.result==null)}function kE(n){for(let e=n.length-1;e>=0;e--){if(NE(n[e]))return e;if(SE.has(n[e].kind))return-1}return-1}const xi={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function CE(n,e="settled"){if(n.length===0||!n.some(a=>wE.has(a.kind)))return xi;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 xi}const s=kE(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];yE.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?xi:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function _E(n,e){return n!==null&&n>0?`Worked for ${Mn(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const Y0="border border-border bg-prompt-surface",wp="border-l border-border/40",jp="border-l border-border";function X0(n){const e=B.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=Lt(),{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 v=!w;if(w&&m){let _;if(e[0]!==m.rawMessages){const{status:A}=q0(m.rawMessages);_=Bd.has(A),e[0]=m.rawMessages,e[1]=_}else _=e[1];v=!_}const j=(m==null?void 0:m.cwd)??"",S=bE(j),k=c===s,C=!g.enabled||h?void 0:g.requestUndo;let N;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]!==v||e[15]!==S||e[16]!==k||e[17]!==C||e[18]!==t?(N=r.jsx(EE,{turn:t,index:s,branchCount:i,isActive:k,activeToolCallId:d,expandAll:f,expandToolPayloads:u,isAgentActive:w,isSessionLive:b,isTurnDone:v,isMobile:l,cwd:j,skillMetadata:S,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]=v,e[15]=S,e[16]=k,e[17]=C,e[18]=t,e[19]=N):N=e[19],N}function TE(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=_E(ed(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(Zd,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const EE=y.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:v}=Xx(),j=y.useRef(null),S=y.useRef(0);y.useLayoutEffect(()=>{v&&j.current&&(S.current=j.current.offsetHeight)},[v]);const k=Vi(e.toolCalls,m)||e.subAgentActivity.some(I=>Vi(I.toolCalls,m)),C=f?"settled":"working",N=y.useMemo(()=>CE(e.contentBlocks,C),[C,e.contentBlocks]),[_,A]=y.useState(void 0),P=_??(a||!f),{leadingBlocks:E,trailingBlocks:T}=y.useMemo(()=>{if(!N.foldable)return{leadingBlocks:[],trailingBlocks:[]};const I=N.foldAnchorIndex,$=new Set(N.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,I),trailingBlocks:e.contentBlocks.slice(I).filter((R,M)=>P||!$.has(I+M))}},[N,e.contentBlocks,P]);return r.jsxs("div",{ref:w,"data-turn-index":t,className:V("group relative",u?"px-1 py-3":"px-4 py-5",o&&"rounded-lg ring-1 ring-ring/40"),children:[r.jsx(PE,{index:t,turn:e,branchCount:s,isTurnDone:f,isMobile:u,onRestoreToHere:h,onOpenBranches:g}),v?r.jsxs("div",{ref:j,className:V("flex flex-col",u?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx("div",{"data-turn-prompt":!0,className:V(u?"rounded-lg p-2.5":"rounded-lg p-3",Y0),children:r.jsx(Dd,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b,compact:u})}),N.foldable?r.jsxs(r.Fragment,{children:[E.length>0&&r.jsx(Pl,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),r.jsx(T8,{label:r.jsx(TE,{turn:e,isTurnDone:f,hiddenToolCalls:N.hiddenToolCalls}),expanded:P,onToggle:()=>A(!P),compact:u}),T.length>0&&r.jsx(Pl,{blocks:T,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p})]}):r.jsx(Pl,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:p}),f&&k&&r.jsx(rE,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:S.current||AE(e)}})]})});function AE(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function PE(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?ed(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=V("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(IE,{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(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:V("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(Xc,{"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:V(!l&&"ml-auto"),children:r.jsx(aE,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==w?(v=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]=v):v=e[25],v}function IE(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(Os,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=Mn(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(Os,{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(Zd,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function RE(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 Pl(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=(v,j)=>{const S=RE(v)??`at-${j}`,k=x.get(S)??0;return x.set(S,k+1),k===0?S:`${S}#${k}`};let w=0;for(;w<t.length;){const v=t[w];if(v.kind==="thinking"||v.kind==="tool_calls"){const{items:j,toolCalls:S,thinkingCount:k,thoughtForMs:C,nextIndex:N}=vp(t,w),_=j.length===1&&j[0].kind==="tool_calls";p.push(r.jsx("div",{className:V(wp,h),children:r.jsx(cp,{toolCalls:S,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:_?void 0:j,thinkingCount:k,thoughtForMs:C,skillMetadata:u})},b(v,w))),w=N;continue}if(v.kind==="text"){const{items:j,toolCalls:S,thinkingCount:k,thoughtForMs:C,nextIndex:N}=vp(t,w+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:V("flex flex-col",g),children:v.text.map((_,A)=>r.jsx(f6,{text:_,model:s,effort:o,timestamp:v.timestamp,compact:f},A))}),(S.length>0||k>0)&&r.jsx("div",{className:V("mt-1.5",wp,h),children:r.jsx(cp,{toolCalls:S,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:k>0?j:void 0,thinkingCount:k,thoughtForMs:C,skillMetadata:u})})]},b(v,w))),w=N;continue}if(v.kind==="queued_prompt"){p.push(r.jsxs("div",{className:V(f?"rounded-lg p-2.5":"rounded-lg p-3",Y0),children:[r.jsx(Ee,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(Dd,{content:v.content,timestamp:v.timestamp??"",compact:f})]},b(v,w))),w++;continue}if(v.kind==="agent_message"){p.push(r.jsx(c6,{sender:v.sender,body:v.body,reply:v.reply,timestamp:v.timestamp,isLive:d},b(v,w))),w++;continue}if(v.kind==="sub_agent"){p.push(r.jsx("div",{className:V(jp,h),children:r.jsx(P6,{messages:v.messages,expandAll:i})},b(v,w))),w++;continue}if(v.kind==="background_agent"){p.push(r.jsx("div",{className:V(jp,h),children:r.jsx(I6,{messages:v.messages,expandAll:i})},b(v,w))),w++;continue}if(v.kind==="hook_event"){p.push(r.jsx($6,{events:v.events},b(v,w))),w++;continue}if(v.kind==="plan_mode"){p.push(r.jsx(Z7,{plan:v.plan,planFilePath:v.planFilePath,status:v.status,toolCalls:v.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:u},b(v,w))),w++;continue}if(v.kind==="recap"){p.push(r.jsx(e8,{content:v.content,timestamp:v.timestamp},b(v,w))),w++;continue}if(v.kind==="task_notification"){p.push(r.jsx(o_,{content:v.content},b(v,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 $E(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 ME=y.memo(function(e){const t=B.c(30),{summary:s,meta:o}=e,[i,a]=y.useState(!1);let l;t[0]!==o?(l=$E(o),t[0]=o,t[1]=l):l=t[1];const c=l;let d;t[2]!==s?(d=s==null?void 0:s.trim(),t[2]=s,t[3]=d):d=t[3];const f=d;let u;t[4]!==f||t[5]!==i?(u=f&&(i?r.jsx(nt,{className:"size-3","data-icon":"inline-start"}):r.jsx(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(Fy,{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 N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=N):N=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 A;return t[16]!==x?(A=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,_]}),t[16]=x,t[17]=A):A=t[17],A}let b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(ee,{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 v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=v):v=t[20];let j;t[21]!==x?(j=r.jsxs(Wt,{render:b,children:[w,x,v]}),t[21]=x,t[22]=j):j=t[22];let S;t[23]===Symbol.for("react.memo_cache_sentinel")?(S=[pa],t[23]=S):S=t[23];let k;t[24]!==f?(k=r.jsx(ft,{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(On,{remarkPlugins:S,components:Fn,children:f})})}),t[24]=f,t[25]=k):k=t[25];let C;return t[26]!==i||t[27]!==j||t[28]!==k?(C=r.jsxs(ut,{open:i,onOpenChange:a,className:"px-4 py-2",children:[j,k]}),t[26]=i,t[27]=j,t[28]=k,t[29]=C):C=t[29],C}),OE=1.5;function DE(n,e){return e<=0?!1:n<e*OE}function LE(n,e){return n===0&&!e}function zE(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function FE(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const BE=1e3;function UE(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)<=BE?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function J0(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&&FE(i,t)?[...o.slice(0,-1),HE(a,i),...n.slice(1)]:[...o,...n];return _d(UE(l))}function WE(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 HE(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:WE(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function KE(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(L_,{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 qE(){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(z_,{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(X0,{turn:p,index:d+h}),c&&r.jsxs(ee,{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(By,{"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 VE(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 GE(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function YE({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Lt(),{undoRedo:l}=it(),c=y.useRef(null),d=y.useRef(null),[f,u]=y.useState(0),m=y.useMemo(()=>{const v=new Map;return n.map(j=>{const S=v.get(j.turn.id)??0;return v.set(j.turn.id,S+1),{...j,key:S===0?j.turn.id:`${j.turn.id}#${S}`}})},[n]),p=y.useRef(null),h=y.useMemo(()=>zE(p.current,m.map(v=>v.key)),[m]);y.useLayoutEffect(()=>{var v;p.current={firstKey:(v=m[0])==null?void 0:v.key,length:m.length}},[m]);const g=y.useRef(t);y.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;y.useLayoutEffect(()=>{const v=e.current,j=d.current;if(!v||!j)return;const S=j.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;u(k=>Math.abs(k-S)<1?k:S)},[e,x]),y.useEffect(()=>{if(!t||!i||!o||s)return;const v=e.current;if(!v)return;const j=()=>{DE(v.scrollTop,v.clientHeight)&&i()};return j(),v.addEventListener("scroll",j,{passive:!0}),()=>v.removeEventListener("scroll",j)},[t,s,o,i,m.length,e]);const b=y.useMemo(()=>{const v=new Map;for(let j=0;j<m.length;j++)v.set(m[j].index,j);return v},[m]),w=y.useRef(null);return y.useEffect(()=>{var j;if(a===null){w.current=null;return}if(a===w.current)return;w.current=a;const v=b.get(a);v!==void 0&&((j=c.current)==null||j.scrollToIndex(v,{align:"start",smooth:!0}))},[a,b]),r.jsxs(r.Fragment,{children:[x&&r.jsx(VE,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(D_,{ref:c,scrollRef:e,startMargin:f,shift:h,children:m.map(({turn:v,index:j,key:S})=>r.jsx("div",{"data-turn-index":j,children:r.jsx(KE,{index:j,children:r.jsxs("div",{children:[(v.compactionSummary||v.compactionMeta)&&r.jsx(ME,{summary:v.compactionSummary,meta:v.compactionMeta}),!GE(v)&&r.jsx(X0,{turn:v,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]})})},S))})}),r.jsx(qE,{})]})}const XE=y.memo(function(e){const t=B.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=Lt(),{searchQuery:d,sessionChangeKey:f}=c,{session:u}=it(),m=u==null?void 0:u.turns;let p;t[0]!==m?(p=m?m.map(JE):[],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:S}=j;return mE(S,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:LE(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=b):b=t[8];const w=b;let v;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?(v=r.jsx(MC,{children:w?r.jsx(un,{className:"min-h-64 border-0",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:d?r.jsx(Uy,{}):r.jsx(Wh,{})}),r.jsx(mn,{children:d?"No matching turns":"No conversation yet"}),r.jsx(Tn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(YE,{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]=v):v=t[18],v});function JE(n,e){return{turn:n,index:e}}const QE="[data-turn-index]",Q0="[data-turn-prompt]",Sp=1,ZE=120,Np=180;function e9(n){if(!n.userMessage)return null;const e=Ma(n.userMessage),{body:t}=pr(e),{remainingText:s}=gr(t),o=Od(s);if(!o){const a=Px(e);if(!a)return null;const l=Ix(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
121
+ `)[0];return i.length>Np?`${i.slice(0,Np)}...`:i}function t9(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=e9(s);if(o)return{index:t,text:o}}return null}function n9(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(QE)){const c=l.getBoundingClientRect().top;if(c>e+Sp)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(Q0);return(i?i.getBoundingClientRect().bottom>e+Sp:s+ZE>e)?null:o}const s9=y.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=y.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const j=o.current;if(!j)return;let S=null;const k=()=>{S=null;const A=n9(j);a(P=>A===null?null:(P==null?void 0:P.sessionId)===s.sessionId&&P.index===A?P:{sessionId:s.sessionId,index:A})},C=()=>{S===null&&(S=requestAnimationFrame(k))};a(null),j.addEventListener("scroll",C,{passive:!0});const N=new MutationObserver(C);N.observe(j,{childList:!0,subtree:!0});const _=new ResizeObserver(C);return _.observe(j),j.firstElementChild&&_.observe(j.firstElementChild),C(),()=>{j.removeEventListener("scroll",C),N.disconnect(),_.disconnect(),S!==null&&cancelAnimationFrame(S)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.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=t9(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 S=j.querySelector(`[data-turn-index="${f.index}"]`),k=(S==null?void 0:S.querySelector(Q0))??S;if(!k)return;const C=j.scrollTop+k.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(Wh,{"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(Nr,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=w):w=t[15];let v;return t[16]!==f.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==b?(v=r.jsxs(ee,{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]=v):v=t[21],v});function o9(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(kp,{}),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(u0,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(kp,{}),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 kp(){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 r9=y.memo(function(){const e=B.c(9),t=Wd();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=x6(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(i9,-1);return r.jsx("div",{children:f.blocks.map((p,h)=>r.jsx(o9,{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 i9(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const a9=3,Xi=["w-6","w-4","w-2.5","w-2"],l9=Xi[Xi.length-1];function c9(n){return n===null||n<0?l9:Xi[Math.min(n,Xi.length-1)]}function d9(n){return n.type==="text"}function Il(n){return n.replace(/\s+/g," ").trim()}function u9(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(d9).map(l=>l.text).join(" "):"",{text:t}=Mx(e),{remainingText:s}=gr(t),{remainingText:o}=$x(s),i=Il(Od(o));if(i)return i;for(const l of n.contentBlocks){if(l.kind!=="task_notification")continue;const c=gr(l.content).notifications.map(d=>d.summary).find(Boolean);if(c)return Il(c)}return n.assistantText.map(Il).find(Boolean)||"Untitled turn"}const f9=y.memo(function(e){const t=B.c(21),{turns:s,scrollContainerRef:o,onJumpToTurn:i}=e,[a,l]=y.useState(null),c=y.useRef(null),d=s.length;let f;if(t[0]!==s){const j=new Map;f=s.map(S=>{const k=j.get(S.id)??0;return j.set(S.id,k+1),k===0?S.id:`${S.id}#${k}`}),t[0]=s,t[1]=f}else f=t[1];const u=f;let m;t[2]!==o?(m=()=>{const j=o.current,S=c.current;if(!j||!S)return;let k=null;const C=()=>{k=null;const _=j.getBoundingClientRect().top+j.clientHeight/2;let A=null;for(const P of j.querySelectorAll("[data-turn-index]")){const E=P.getBoundingClientRect();if(E.top<=_&&E.bottom>=_){A=Number(P.dataset.turnIndex);break}}for(const P of S.querySelectorAll("[data-tick-index]"))P.dataset.current=String(Number(P.dataset.tickIndex)===A)},N=()=>{k===null&&(k=requestAnimationFrame(C))};return C(),j.addEventListener("scroll",N,{passive:!0}),()=>{j.removeEventListener("scroll",N),k!==null&&cancelAnimationFrame(k)}},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],y.useEffect(m,p);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{const S=j.key==="ArrowDown"?1:j.key==="ArrowUp"?-1:0,k=c.current;if(!k)return;const C=[...k.querySelectorAll("[data-tick-index]")];if(C.length===0)return;let N;if(S!==0){const _=C.indexOf(document.activeElement);N=C[Math.min(Math.max(_+S,0),C.length-1)]}else j.key==="Home"?N=C[0]:j.key==="End"&&(N=C[C.length-1]);N&&(j.preventDefault(),N.focus())},t[7]=h):h=t[7];const g=h;if(d<a9)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=V("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=(S,k)=>{const C=u9(S);return r.jsx(ee,{type:"button",variant:"ghost","data-tick-index":k,onMouseEnter:()=>l(k),onFocus:()=>l(k),onClick:()=>i(k),"aria-label":`Turn ${k+1}: ${C}`,className:V("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",c9(a===null?null:Math.abs(k-a))),children:r.jsxs("span",{className:V("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:k+1}),r.jsx("span",{className:"line-clamp-2 align-middle",children:C})]})},u[k])},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 v;return t[19]!==w?(v=r.jsx("nav",{ref:c,"aria-label":"Conversation timeline",onMouseLeave:x,onKeyDown:g,className:b,children:w}),t[19]=w,t[20]=v):v=t[20],v});class m9 extends y.Component{constructor(t){super(t);si(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(kn,{}),r.jsx(It,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(Nt,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(vs,{className:"static col-start-2 mt-2",children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Dt,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const Cp="find-in-session-highlight",Rl="find-in-session-active";function p9(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 h9=y.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[f,u]=y.useState(d),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==o?(g=()=>{const ne=o.current;if(!ne)return;ne.querySelectorAll(`mark.${Cp}`).forEach(g9)},s[1]=o,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==o?(b=ne=>{if(x(),!ne||!o.current){u([]),p(-1);return}const re=o.current,ie=p9(re),ae=ne.toLowerCase(),te=[];for(const ue of ie){const le=ue.nodeValue||"",de=le.toLowerCase();let he=0;const xe=[];for(;;){const fe=de.indexOf(ae,he);if(fe===-1)break;xe.push(fe),he=fe+1}if(xe.length===0)continue;const ce=ue.parentNode;if(!ce)continue;const be=document.createDocumentFragment();let ge=0;for(const fe of xe){fe>ge&&be.appendChild(document.createTextNode(le.slice(ge,fe)));const je=document.createElement("mark");je.className=Cp,je.textContent=le.slice(fe,fe+ne.length),be.appendChild(je),te.push(je),ge=fe+ne.length}ge<le.length&&be.appendChild(document.createTextNode(le.slice(ge))),ce.replaceChild(be,ue)}u(te),te.length>0?(p(0),te[0].classList.add(Rl),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 v;s[6]!==m||s[7]!==f?(v=ne=>{if(f.length===0)return;m>=0&&m<f.length&&f[m].classList.remove(Rl);const re=(ne%f.length+f.length)%f.length;f[re].classList.add(Rl),f[re].scrollIntoView({block:"center",behavior:"smooth"}),p(re)},s[6]=m,s[7]=f,s[8]=v):v=s[8];const j=v;let S;s[9]!==x?(S=()=>{a(!1),c(""),x(),u([]),p(-1)},s[9]=x,s[10]=S):S=s[10];const k=S;let C,N;s[11]!==k||s[12]!==i?(C=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var ne;return(ne=h.current)==null?void 0:ne.focus()})},close:k,isOpen:i}),N=[k,i],s[11]=k,s[12]=i,s[13]=C,s[14]=N):(C=s[13],N=s[14]),y.useImperativeHandle(t,C,N);let _,A;s[15]!==w||s[16]!==l?(_=()=>{const ne=setTimeout(()=>w(l),150);return()=>clearTimeout(ne)},A=[l,w],s[15]=w,s[16]=l,s[17]=_,s[18]=A):(_=s[17],A=s[18]),y.useEffect(_,A);let P,E;s[19]!==x?(P=()=>()=>x(),E=[x],s[19]=x,s[20]=P,s[21]=E):(P=s[20],E=s[21]),y.useEffect(P,E);let T;s[22]!==m||s[23]!==j||s[24]!==k?(T=ne=>{ne.key==="Escape"?(ne.preventDefault(),ne.stopPropagation(),k()):ne.key==="Enter"&&(ne.preventDefault(),ne.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=k,s[25]=T):T=s[25];const I=T;if(!i)return null;let $;s[26]===Symbol.for("react.memo_cache_sentinel")?($=ne=>c(ne.target.value),s[26]=$):$=s[26];let R;s[27]!==I||s[28]!==l?(R=r.jsx(ss,{ref:h,value:l,onChange:$,onKeyDown:I,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=I,s[28]=l,s[29]=R):R=s[29];const M=l?f.length>0?`${m+1}/${f.length}`:"0/0":"";let D;s[30]!==M?(D=r.jsx(Nn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:M})}),s[30]=M,s[31]=D):D=s[31];let O;s[32]!==R||s[33]!==D?(O=r.jsxs(ns,{className:"w-64",children:[R,D]}),s[32]=R,s[33]=D,s[34]=O):O=s[34];let L;s[35]!==m||s[36]!==j?(L=()=>j(m-1),s[35]=m,s[36]=j,s[37]=L):L=s[37];const F=f.length===0,z=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let W;s[38]!==z?(W=V("text-muted-foreground",z),s[38]=z,s[39]=W):W=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx(Nr,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let H;s[41]!==L||s[42]!==F||s[43]!==W?(H=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:L,disabled:F,className:W,"aria-label":"Previous match",children:U}),s[41]=L,s[42]=F,s[43]=W,s[44]=H):H=s[44];let K;s[45]!==m||s[46]!==j?(K=()=>j(m+1),s[45]=m,s[46]=j,s[47]=K):K=s[47];const q=f.length===0,Y=f.length>0?"hover:text-foreground":"cursor-default opacity-40";let G;s[48]!==Y?(G=V("text-muted-foreground",Y),s[48]=Y,s[49]=G):G=s[49];let J;s[50]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(nt,{"data-icon":"inline-start"}),s[50]=J):J=s[50];let Q;s[51]!==K||s[52]!==q||s[53]!==G?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:K,disabled:q,className:G,"aria-label":"Next match",children:J}),s[51]=K,s[52]=q,s[53]=G,s[54]=Q):Q=s[54];let X;s[55]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(ct,{"data-icon":"inline-start"}),s[55]=X):X=s[55];let Z;s[56]!==k?(Z=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:k,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:X}),s[56]=k,s[57]=Z):Z=s[57];let se;return s[58]!==O||s[59]!==H||s[60]!==Q||s[61]!==Z?(se=r.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[O,H,Q,Z]}),s[58]=O,s[59]=H,s[60]=Q,s[61]=Z,s[62]=se):se=s[62],se});function g9(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const HD=["General","View","Tools"],Ua=[{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}}],Z0="cogpit-keybindings";let Ts=null;function e2(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function wr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function x9(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function eu(){if(Ts)return Ts;try{const n=localStorage.getItem(Z0);if(!n)return Ts={};const e=JSON.parse(n);if(!e||typeof e!="object")return Ts={};const t={};for(const s of Ua){const o=e[s.command];x9(o)&&(t[s.command]=o)}return Ts=t}catch{return Ts={}}}function tu(n){Ts=n;try{localStorage.setItem(Z0,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Kr(n){const e=Ua.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return eu()[n]??e.defaultShortcut}function KD(){return Object.fromEntries(Ua.map(n=>[n.command,Kr(n.command)]))}function qD(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:wr(e.key)};tu({...eu(),[n]:t})}function VD(n){const e={...eu()};delete e[n],tu(e)}function GD(){tu({})}function YD(n){return{key:wr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function t2(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function wt(n,e){const t=Kr(n);return"doubleTapModifier"in t||wr(e.key)!==wr(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 no(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 b9(n){const e=e2();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${no(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${no(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${no(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${no(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${no(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,no(n.key)].filter(Boolean).join("+")}function $l(n){return b9(Kr(n))}function _p(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${wr(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 XD(n,e){const t=new Set(_p(n));return Ua.find(s=>s.command!==e&&_p(Kr(s.command)).some(o=>t.has(o)))??null}function Tp(n){return"doubleTapModifier"in Kr(n)?e2()?"Meta":"Control":null}const v9=["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"],y9="device.cycle";function w9(n){const e=v9.findIndex(t=>wt(t,n));return e===-1?null:e+1}function j9(n){return wt(y9,n)}const Cc="cogpit:find-in-conversation",Wa=y.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}=Lt(),{session:h}=it(),{chat:g,scroll:x}=Rr(),{searchQuery:b}=u,{pendingMessages:w}=g,{chatScrollRef:v,scrollEndRef:j,handleScroll:S,canScrollDown:k,scrollToBottomInstant:C,initialScrollDone:N}=x,_=y.useRef(null);let A;t[0]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{var fe;return(fe=_.current)==null?void 0:fe.open()},t[0]=A):A=t[0];const P=A;let E,T;t[1]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const fe=function(Se){wt("findInConversation",Se)&&(Se.preventDefault(),P())};return window.addEventListener("keydown",fe),window.addEventListener(Cc,P),()=>{window.removeEventListener("keydown",fe),window.removeEventListener(Cc,P)}},T=[P],t[1]=E,t[2]=T):(E=t[1],T=t[2]),y.useEffect(E,T);let I,$;t[3]!==p||t[4]!==f||t[5]!==s?(I=()=>{!p||!f||requestAnimationFrame(()=>{var fe;return(fe=s.current)==null?void 0:fe.focus()})},$=[p,f,s],t[3]=p,t[4]=f,t[5]=s,t[6]=I,t[7]=$):(I=t[6],$=t[7]),y.useEffect(I,$);let R;t[8]!==m?(R=fe=>m({type:"JUMP_TO_TURN",index:fe}),t[8]=m,t[9]=R):R=t[9];const M=R;let D;t[10]!==m||t[11]!==d?(D=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=D):D=t[12];const O=D,L=h,F=L.turns.length>0||w.length===0,z=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let W;t[13]!==z?(W=V("relative bg-background",z),t[13]=z,t[14]=W):W=t[14];let U;t[15]!==O||t[16]!==m||t[17]!==p||t[18]!==f||t[19]!==s||t[20]!==b?(U=p&&f&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(ns,{className:"h-9 flex-1",children:[r.jsx(ss,{ref:s,value:b,onChange:fe=>m({type:"SET_SEARCH_QUERY",value:fe.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(Nn,{align:"inline-start",children:r.jsx(dn,{})})]}),r.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:r.jsx(ct,{"data-icon":"inline-start"})})]}),t[15]=O,t[16]=m,t[17]=p,t[18]=f,t[19]=s,t[20]=b,t[21]=U):U=t[21];const H=p?"flex-1 min-h-0":"h-full";let K;t[22]!==H?(K=V("relative",H),t[22]=H,t[23]=K):K=t[23];let q;t[24]!==v?(q=r.jsx(h9,{ref:_,scrollContainerRef:v}),t[24]=v,t[25]=q):q=t[25];let Y;t[26]!==v||t[27]!==L.turns||t[28]!==M||t[29]!==p?(Y=!p&&r.jsx(f9,{turns:L.turns,scrollContainerRef:v,onJumpToTurn:M}),t[26]=v,t[27]=L.turns,t[28]=M,t[29]=p,t[30]=Y):Y=t[30];let G;t[31]!==v||t[32]!==L?(G=r.jsx(s9,{session:L,scrollContainerRef:v}),t[31]=v,t[32]=L,t[33]=G):G=t[33];const J=p&&"mobile-scroll";let Q;t[34]!==J?(Q=V("h-full overflow-x-hidden overflow-y-auto bg-background",J),t[34]=J,t[35]=Q):Q=t[35];let X;t[36]!==o||t[37]!==p?(X=p?"px-3 py-3 pb-5":V("mx-auto w-full max-w-[var(--chat-width)] px-6 pt-14",o?"pb-48":"pb-32"),t[36]=o,t[37]=p,t[38]=X):X=t[38];let Z;t[39]!==v||t[40]!==i||t[41]!==N||t[42]!==a||t[43]!==l||t[44]!==F?(Z=F&&r.jsx(XE,{chatScrollRef:v,hasMore:i,isLoadingOlder:a,pagingEnabled:N,onLoadMore:l}),t[39]=v,t[40]=i,t[41]=N,t[42]=a,t[43]=l,t[44]=F,t[45]=Z):Z=t[45];let se;t[46]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(r9,{}),t[46]=se):se=t[46];let ne;if(t[47]!==L.turns.length||t[48]!==w){let fe;t[50]!==L.turns.length?(fe=(je,Se)=>r.jsx(Dx,{message:je,turnNumber:L.turns.length+1+Se},Se),t[50]=L.turns.length,t[51]=fe):fe=t[51],ne=w.map(fe),t[47]=L.turns.length,t[48]=w,t[49]=ne}else ne=t[49];let re;t[52]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(uE,{}),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]!==Z||t[56]!==ne||t[57]!==ie?(ae=r.jsxs(m9,{fallbackMessage:"Failed to render conversation timeline",children:[Z,se,ne,re,ie]}),t[55]=Z,t[56]=ne,t[57]=ie,t[58]=ae):ae=t[58];let te;t[59]!==X||t[60]!==ae?(te=r.jsx("div",{className:X,children:ae}),t[59]=X,t[60]=ae,t[61]=te):te=t[61];let ue;t[62]!==v||t[63]!==S||t[64]!==Q||t[65]!==te?(ue=r.jsx("div",{ref:v,onScroll:S,className:Q,children:te}),t[62]=v,t[63]=S,t[64]=Q,t[65]=te,t[66]=ue):ue=t[66];const le=k?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",de=p?"right-3 bottom-3":"right-5 bottom-5";let he;t[67]!==le||t[68]!==de?(he=V("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",le,de),t[67]=le,t[68]=de,t[69]=he):he=t[69];let xe;t[70]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(Wy,{"data-icon":"inline-start"}),t[70]=xe):xe=t[70];let ce;t[71]!==C||t[72]!==he?(ce=r.jsx(ee,{size:"icon",className:he,onClick:C,"aria-label":"Scroll to bottom",children:xe}),t[71]=C,t[72]=he,t[73]=ce):ce=t[73];let be;t[74]!==K||t[75]!==q||t[76]!==Y||t[77]!==G||t[78]!==ue||t[79]!==ce?(be=r.jsxs("div",{className:K,children:[q,Y,G,ue,ce]}),t[74]=K,t[75]=q,t[76]=Y,t[77]=G,t[78]=ue,t[79]=ce,t[80]=be):be=t[80];let ge;return t[81]!==W||t[82]!==U||t[83]!==be?(ge=r.jsxs("div",{className:W,children:[U,be]}),t[81]=W,t[82]=U,t[83]=be,t[84]=ge):ge=t[84],ge}),_c="cogpit-devices-changed",n2="cogpit:devices-changed";function s2(n){typeof n.connectionRevision=="number"&&ww(n.id,n.connectionRevision)}function o2(n,e,t=!1){window.dispatchEvent(new CustomEvent(_c,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(n2,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function Ep(n){s2(n),o2(n.id,n.connectionRevision)}function Ml(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function so(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function r2(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function S9(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function Ha(){const[n,e]=y.useState([]),[t,s]=y.useState(!0),[o,i]=y.useState(()=>gt()),a=y.useRef(0),l=y.useCallback(async()=>{const h=++a.current;try{const g=await as("/api/hub/devices");if(!g.ok)return;const x=await so(g);if(h!==a.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of b)s2(w);e(b)}catch{}finally{h===a.current&&s(!1)}},[]);y.useEffect(()=>{l()},[l]),y.useEffect(()=>{const h=()=>i(gt()),g=()=>void l(),x=v=>{if(v.key===n2){try{const j=JSON.parse(v.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&gt()===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(_c,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(_c,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=y.useMemo(()=>o===jt?void 0:n.find(h=>h.id===o),[n,o]),d=y.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})}),v=await so(w);return(v==null?void 0:v.ok)===!0&&v.hello?{ok:!0,hello:v.hello}:{ok:!1,code:(v==null?void 0:v.code)??"UNREACHABLE",error:typeof(v==null?void 0:v.error)=="string"?v.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),f=y.useCallback(async h=>{try{const g=await as("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await so(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return Ep(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=y.useCallback(async(h,g)=>{try{const x=await as(Ml(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await so(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return Ep(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=y.useCallback(async h=>{try{const g=await as(Ml(h),{method:"DELETE"});if(g.ok)return gt()===h&&gs(jt),o2(h,void 0,!0),{ok:!0};const x=await so(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=y.useCallback(async h=>{try{const g=await as(Ml(h,"/test"),{method:"POST"});return await so(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 N9=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function Ap(n,e){if(!N9.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function Vo(n,e){return`${n}.${e}`}function k9(n){const e=new Set,t=new Set,s=[];for(const o of n){if(Ap("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??[]){Ap("panel",i.id);const a=Vo(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 Rs(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({pressed:o,className:s,children:t,...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]);const a=o?"border-foreground/20 bg-foreground/[0.06] text-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground";let l;e[5]!==s||e[6]!==a?(l=V("inline-flex h-6 shrink-0 items-center gap-1 rounded-full border px-2 text-[11px] leading-none outline-none transition-colors","focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:opacity-40",a,s),e[5]=s,e[6]=a,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==i||e[11]!==l?(c=r.jsx("button",{type:"button","aria-pressed":o,className:l,...i,children:t}),e[8]=t,e[9]=o,e[10]=i,e[11]=l,e[12]=c):c=e[12],c}function $s(n){const e=B.c(2),{children:t}=n;let s;return e[0]!==t?(s=r.jsx("span",{className:"font-mono text-[10px] tabular-nums opacity-70",children:t}),e[0]=t,e[1]=s):s=e[1],s}function Ot(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=V("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 Go="cogpit",_t={worktrees:Vo(Go,"worktrees"),projectFiles:Vo(Go,"project-files"),fileChanges:Vo(Go,"file-changes"),sessionInfo:Vo(Go,"session-info")},C9=y.lazy(()=>qe(()=>import("./CommandPaletteHost-D-VvT_HL.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),_9=y.lazy(()=>qe(()=>import("./index-Bw-DFQut.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),T9=y.lazy(()=>qe(()=>Promise.resolve().then(()=>q9),void 0).then(n=>({default:n.DevicesDialog}))),E9=y.lazy(()=>qe(()=>import("./KeyboardShortcutsDialog-yOs1u5D6.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),A9=y.lazy(()=>qe(()=>import("./ProjectSwitcherModal-DgsuH5CY.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),P9=y.lazy(()=>qe(()=>import("./ThemeSelectorModal-oI9Vm3EH.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function I9(n){const e=B.c(116),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Lt(),{session:c,sessionSource:d}=it(),{devices:f,activeDeviceId:u}=Ha(),[m,p]=y.useState(null),[h,g]=y.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?wn(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=w):w=e[3];const v=w,j=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,S=m??h;let k,C;e[4]!==m?(k=()=>{m&&g(m)},C=[m],e[4]=m,e[5]=k,e[6]=C):(k=e[5],C=e[6]),y.useEffect(k,C);const N=o.onKeyboardShortcutsOpenChange;let _,A;e[7]!==N?(_=()=>{const Te=function(He){wt("keyboardShortcuts",He)&&(t2(document.activeElement)||(He.preventDefault(),N(!0)))};return window.addEventListener("keydown",Te),()=>window.removeEventListener("keydown",Te)},A=[N],e[7]=N,e[8]=_,e[9]=A):(_=e[8],A=e[9]),y.useEffect(_,A);const P=u===jt;let E;e[10]!==P?(E={id:jt,name:"This machine",isLocal:!0,isActive:P},e[10]=P,e[11]=E):E=e[11];let T;if(e[12]!==u||e[13]!==f||e[14]!==E){let Te;e[16]!==u?(Te=$e=>({id:$e.id,name:$e.name,isLocal:!1,isActive:$e.id===u}),e[16]=u,e[17]=Te):Te=e[17],T=[E,...f.map(Te)],e[12]=u,e[13]=f,e[14]=E,e[15]=T}else T=e[15];const I=T;let $;e[18]!==c||e[19]!==(d==null?void 0:d.agentKind)||e[20]!==(d==null?void 0:d.dirName)?($=()=>{if(!c)return;const Te=(d==null?void 0:d.agentKind)??Ct((d==null?void 0:d.dirName)??null);Er(og(Te,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]=$):$=e[21];const R=$,M=R9,D=o.processPanel,O=o.workflowsPanel,L=o.undoDialog,F=o.branchModal,z=a.claudeDir??"";let W;e[22]!==a.handleCloseConfigDialog||e[23]!==a.handleConfigSaved||e[24]!==a.showConfigDialog||e[25]!==z?(W=r.jsx(y.Suspense,{fallback:null,children:r.jsx(_9,{open:a.showConfigDialog,currentPath:z,onClose:a.handleCloseConfigDialog,onSaved:a.handleConfigSaved})}),e[22]=a.handleCloseConfigDialog,e[23]=a.handleConfigSaved,e[24]=a.showConfigDialog,e[25]=z,e[26]=W):W=e[26];const U=(d==null?void 0:d.dirName)??i.pendingDirName??null,H=(c==null?void 0:c.cwd)??i.pendingCwd??null;let K;e[27]!==a.defaultAgentKind||e[28]!==t.onStartNewFolder||e[29]!==t.onStartNewSession||e[30]!==t.panels.handleCloseProjectSwitcher||e[31]!==t.panels.showProjectSwitcher||e[32]!==U||e[33]!==H?(K=r.jsx(y.Suspense,{fallback:null,children:r.jsx(A9,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:U,currentProjectCwd:H})}),e[27]=a.defaultAgentKind,e[28]=t.onStartNewFolder,e[29]=t.onStartNewSession,e[30]=t.panels.handleCloseProjectSwitcher,e[31]=t.panels.showProjectSwitcher,e[32]=U,e[33]=H,e[34]=K):K=e[34];let q;e[35]!==t.panels.handleCloseThemeSelector||e[36]!==t.panels.showThemeSelector||e[37]!==l.setPreview||e[38]!==l.setTheme||e[39]!==l.theme?(q=r.jsx(y.Suspense,{fallback:null,children:r.jsx(P9,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[35]=t.panels.handleCloseThemeSelector,e[36]=t.panels.showThemeSelector,e[37]=l.setPreview,e[38]=l.setTheme,e[39]=l.theme,e[40]=q):q=e[40];const Y=o.commandPaletteOpen,G=o.onCommandPaletteOpenChange,J=t.actions.handleGoHome,Q=t.panels.handleOpenProjectSwitcher,X=t.onOpenPaletteProject,Z=t.actions.handleDashboardSelect,se=t.panels.handleToggleSidebar;let ne,re,ie;e[41]!==t.panels?(ne=()=>t.panels.toggleWorkspacePanel(_t.sessionInfo),re=()=>t.panels.toggleWorkspacePanel(_t.fileChanges),ie=()=>t.panels.toggleWorkspacePanel(_t.worktrees),e[41]=t.panels,e[42]=ne,e[43]=re,e[44]=ie):(ne=e[42],re=e[43],ie=e[44]);const ae=t.panels.handleToggleMission,te=c?t.handlers.handleDuplicateSession:void 0,ue=c?R:void 0,le=c?M:void 0,de=lt("killAny")?o.onKillAll:void 0,he=lt("configWrite")?t.panels.handleToggleConfig:void 0,xe=a.openConfigDialog;let ce;e[45]!==N?(ce=()=>N(!0),e[45]=N,e[46]=ce):ce=e[46];const be=s.currentCwd?s.onTogglePreview:void 0,ge=lt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,fe=t.panels.handleToggleThemeSelector,je=s.onOpenTerminal,Se=o.onFocusComposer,Ae=o.onExpandAll,Ie=o.onExpandToolPayloads,Re=o.onCollapseAll,De=!!(c||i.pendingDirName);let Le;e[47]!==v||e[48]!==(c==null?void 0:c.cwd)||e[49]!==(d==null?void 0:d.dirName)||e[50]!==i.dashboardProject||e[51]!==i.pendingDirName?(Le=lt("terminal")&&!!((c==null?void 0:c.cwd)??v??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[47]=v,e[48]=c==null?void 0:c.cwd,e[49]=d==null?void 0:d.dirName,e[50]=i.dashboardProject,e[51]=i.pendingDirName,e[52]=Le):Le=e[52];const ze=!!c;let _e;e[53]!==s.hasFileChanges?(_e=lt("hostFiles")&&s.hasFileChanges,e[53]=s.hasFileChanges,e[54]=_e):_e=e[54];const Ce=t.panels.activeWorkspacePanel===_t.sessionInfo,We=t.panels.activeWorkspacePanel===_t.fileChanges,Fe=t.panels.activeWorkspacePanel===_t.worktrees,Ne=i.mainView==="config",me=i.mainView==="mission",Oe=(c==null?void 0:c.cwd)??v??null;let Pe;e[55]!==o.commandPaletteOpen||e[56]!==o.onCollapseAll||e[57]!==o.onCommandPaletteOpenChange||e[58]!==o.onExpandAll||e[59]!==o.onExpandToolPayloads||e[60]!==o.onFocusComposer||e[61]!==a.openConfigDialog||e[62]!==j||e[63]!==t.actions.handleDashboardSelect||e[64]!==t.actions.handleGoHome||e[65]!==t.onOpenPaletteProject||e[66]!==t.panels.handleOpenProjectSwitcher||e[67]!==t.panels.handleToggleMission||e[68]!==t.panels.handleToggleSidebar||e[69]!==t.panels.handleToggleThemeSelector||e[70]!==t.panels.showSidebar||e[71]!==I||e[72]!==s.launchTerminalRequest||e[73]!==s.onOpenTerminal||e[74]!==s.processPanel.addProcess||e[75]!==s.showProjectFiles||e[76]!==s.supportsWorktrees||e[77]!==ne||e[78]!==re||e[79]!==ie||e[80]!==te||e[81]!==ue||e[82]!==le||e[83]!==de||e[84]!==he||e[85]!==ce||e[86]!==be||e[87]!==ge||e[88]!==De||e[89]!==Le||e[90]!==ze||e[91]!==_e||e[92]!==Ce||e[93]!==We||e[94]!==Fe||e[95]!==Ne||e[96]!==me||e[97]!==Oe?(Pe=r.jsx(y.Suspense,{fallback:null,children:r.jsx(C9,{open:Y,onOpenChange:G,onGoHome:J,onNewSession:Q,onOpenProject:X,onOpenSession:Z,onToggleSidebar:se,onToggleStats:ne,onToggleFileChanges:re,onToggleWorktrees:ie,onToggleMissionControl:ae,onDuplicateSession:te,onCopyResumeCommand:ue,onFindInConversation:le,onKillAll:de,onOpenConfig:he,onOpenSettings:xe,onOpenKeyboardShortcuts:ce,onTogglePreview:be,onToggleProjectFiles:ge,onOpenTheme:fe,onOpenTerminal:je,onOpenDevices:b?p:void 0,onSwitchDevice:gs,devices:I,onFocusComposer:Se,onExpandAll:Ae,onExpandToolPayloads:Ie,onCollapseAll:Re,canFocusComposer:De,canOpenTerminal:Le,hasSession:ze,hasFileChanges:_e,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ce,showProjectFiles:s.showProjectFiles,showFileChanges:We,showWorktrees:Fe,showConfig:Ne,showMission:me,currentProjectDirName:j,projectCwd:Oe,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[55]=o.commandPaletteOpen,e[56]=o.onCollapseAll,e[57]=o.onCommandPaletteOpenChange,e[58]=o.onExpandAll,e[59]=o.onExpandToolPayloads,e[60]=o.onFocusComposer,e[61]=a.openConfigDialog,e[62]=j,e[63]=t.actions.handleDashboardSelect,e[64]=t.actions.handleGoHome,e[65]=t.onOpenPaletteProject,e[66]=t.panels.handleOpenProjectSwitcher,e[67]=t.panels.handleToggleMission,e[68]=t.panels.handleToggleSidebar,e[69]=t.panels.handleToggleThemeSelector,e[70]=t.panels.showSidebar,e[71]=I,e[72]=s.launchTerminalRequest,e[73]=s.onOpenTerminal,e[74]=s.processPanel.addProcess,e[75]=s.showProjectFiles,e[76]=s.supportsWorktrees,e[77]=ne,e[78]=re,e[79]=ie,e[80]=te,e[81]=ue,e[82]=le,e[83]=de,e[84]=he,e[85]=ce,e[86]=be,e[87]=ge,e[88]=De,e[89]=Le,e[90]=ze,e[91]=_e,e[92]=Ce,e[93]=We,e[94]=Fe,e[95]=Ne,e[96]=me,e[97]=Oe,e[98]=Pe):Pe=e[98];let Be;e[99]!==o.keyboardShortcutsOpen||e[100]!==N?(Be=r.jsx(y.Suspense,{fallback:null,children:r.jsx(E9,{open:o.keyboardShortcutsOpen,onOpenChange:N})}),e[99]=o.keyboardShortcutsOpen,e[100]=N,e[101]=Be):Be=e[101];let oe;e[102]!==m||e[103]!==S?(oe=b&&S!==null&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(T9,{open:m!==null,initialMode:S,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[102]=m,e[103]=S,e[104]=oe):oe=e[104];let pe;return e[105]!==o.branchModal||e[106]!==o.processPanel||e[107]!==o.undoDialog||e[108]!==o.workflowsPanel||e[109]!==W||e[110]!==K||e[111]!==q||e[112]!==Pe||e[113]!==Be||e[114]!==oe?(pe=r.jsxs(r.Fragment,{children:[D,O,L,F,W,K,q,Pe,Be,oe]}),e[105]=o.branchModal,e[106]=o.processPanel,e[107]=o.undoDialog,e[108]=o.workflowsPanel,e[109]=W,e[110]=K,e[111]=q,e[112]=Pe,e[113]=Be,e[114]=oe,e[115]=pe):pe=e[115],pe}function R9(){window.dispatchEvent(new Event(Cc))}function Ol(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(Et,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(At,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(Tt,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const $9="2.3.0",i2={version:$9},M9=i2.version,O9=19384,D9=443,L9=450,z9=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),F9=`${z9?"⌘⇧":"Ctrl+Shift+"}1–9`,B9=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),U9=new Set(["ACCOUNT_DISABLED"]);function Yo(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 a2(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 l2={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function W9(n){const e=B.c(10),{tone:t}=n,s=l2[t];let o;e[0]!==s?(o=V("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(Yn,{"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(kn,{"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(Dt,{"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(Ks,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const H9={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function K9({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=y.useState(!1),[c,d]=y.useState(n.name),[f,u]=y.useState(!1),[m,p]=y.useState(n.username??""),[h,g]=y.useState(""),[x,b]=y.useState(null),[w,v]=y.useState(!1),[j,S]=y.useState(null);y.useEffect(()=>{d(n.name)},[n.name]),y.useEffect(()=>{p(n.username??"")},[n.username]);const k=r2(n),C=k!==void 0&&k!==e,N=S9(n)==="team";async function _(){const P=c.trim();if(!P||P===n.name){l(!1),d(n.name);return}S("rename"),await t(n.id,P),S(null),l(!1)}async function A(){const P=m.trim(),E=n.username??"",T=P!==E,I=h.length>0;if(!T&&!I){u(!1),g(""),b(null);return}if(n.auth==="none"&&!I){b("Enter a password when adding an account to an unauthenticated device.");return}const $={};T&&($.username=P||null),I&&($.password=h),S("credentials"),b(null);const R=await s(n.id,$);if(S(null),!R.ok){b(R.error);return}u(!1),g("")}return r.jsxs("div",{className:"rounded-lg border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[r.jsx("span",{"aria-label":`Status: ${n.runtime.authState}`,className:V("size-2 shrink-0 rounded-full",H9[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Bt,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:P=>d(P.target.value),onKeyDown:P=>{P.key==="Enter"&&_(),P.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}),k&&r.jsxs("span",{className:V("shrink-0 font-mono text-xs",C?"text-warning":"text-muted-foreground"),title:C?`Device runs v${k}; hub runs v${e}`:void 0,children:["v",k,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]}):N?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(ee,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:j==="test",onClick:async()=>{S("test"),await i(n.id),S(null)},children:r.jsx(Dt,{"data-icon":"inline-start",className:V(j==="test"&&"animate-spin")})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{u(P=>!P),p(n.username??""),g(""),b(null)},children:r.jsx(Hy,{"data-icon":"inline-start"})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Ws,{"data-icon":"inline-start"})}),r.jsxs(ld,{open:w,onOpenChange:P=>{j!=="remove"&&v(P)},children:[r.jsx(V4,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${n.name}`,className:"text-destructive hover:bg-destructive/10 hover:text-destructive"}),children:r.jsx(aa,{"data-icon":"inline-start"})}),r.jsxs(cd,{size:"sm",children:[r.jsxs(dd,{children:[r.jsxs(fd,{children:["Remove ",n.name,"?"]}),r.jsx(md,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(ud,{children:[r.jsx(hd,{disabled:j==="remove",children:"Cancel"}),r.jsxs(pd,{variant:"destructive",disabled:j==="remove",onClick:async()=>{S("remove");try{await o(n.id)}finally{S(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(xt,{children:[r.jsxs(bt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Bt,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:P=>p(P.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(xt,{children:[r.jsxs(bt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Bt,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:P=>g(P.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&m.trim()===""&&r.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),x&&r.jsx(fs,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>{u(!1),p(n.username??""),g(""),b(null)},children:"Cancel"}),r.jsx(ee,{size:"sm",disabled:j==="credentials",onClick:()=>void A(),children:j==="credentials"?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function c2(n){var st,Ye;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}=Ha(),[p,h]=y.useState(""),[g,x]=y.useState(""),[b,w]=y.useState(""),[v,j]=y.useState(""),[S,k]=y.useState(!1),[C,N]=y.useState(!1),[_,A]=y.useState(null),[P,E]=y.useState(!1),[T,I]=y.useState(null),$=y.useRef(null),R=y.useRef(0);let M,D;e[0]!==s||e[1]!==t?(M=()=>{t&&(h(""),x(""),w(""),j(""),k(!1),N(!1),A(null),I(null),s==="add"&&requestAnimationFrame(()=>{var Me;return(Me=$.current)==null?void 0:Me.focus()}))},D=[t,s],e[0]=s,e[1]=t,e[2]=M,e[3]=D):(M=e[2],D=e[3]),y.useEffect(M,D);let O;e[4]!==S||e[5]!==g||e[6]!==c?(O=async()=>{const{host:Me,port:Ue,tls:ot}=Yo(g);if(!Me){A(null),N(!1);return}const Kt=R.current=R.current+1;N(!0);const zt=await c(Me,Ue,S,ot);Kt===R.current&&(A({...a2(zt,Me,Ue??(ot?D9:O9)),hello:zt.ok?zt.hello:void 0}),N(!1))},e[4]=S,e[5]=g,e[6]=c,e[7]=O):O=e[7];const L=O;let F,z;e[8]!==g||e[9]!==t||e[10]!==L?(F=()=>{if(!t)return;if(!Yo(g).host){A(null),N(!1);return}const Me=window.setTimeout(()=>void L(),L9);return()=>window.clearTimeout(Me)},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]),y.useEffect(F,z);const W=((st=_==null?void 0:_.hello)==null?void 0:st.edition)==="team",U=W&&((Ye=_==null?void 0:_.hello)==null?void 0:Ye.needsBootstrap)===!0,H=W||!S;let K;e:{if(P){K=!1;break e}if(!Yo(g).host){K=!1;break e}if(C||!_){K=!1;break e}if(U){K=!1;break e}if(H&&!v){K=!1;break e}if(W&&!b.trim()){K=!1;break e}if((_==null?void 0:_.tone)==="error"){K=!1;break e}K=!0}const q=K;let Y;e[13]!==d||e[14]!==S||e[15]!==H||e[16]!==g||e[17]!==p||e[18]!==o||e[19]!==v||e[20]!==W||e[21]!==b?(Y=async function(){const{host:Ue,port:ot,tls:Kt}=Yo(g);if(!Ue)return;E(!0),I(null);const zt=await d({name:p.trim()||void 0,host:Ue,port:ot,tls:Kt,username:W?b.trim():void 0,password:H&&v||void 0,allowLocalTunnel:S});if(E(!1),zt.ok){o(),gs(zt.device.id);return}I({field:U9.has(zt.code)?"username":B9.has(zt.code)?"password":"host",message:zt.error})},e[13]=d,e[14]=S,e[15]=H,e[16]=g,e[17]=p,e[18]=o,e[19]=v,e[20]=W,e[21]=b,e[22]=Y):Y=e[22];const G=Y;let J;e[23]!==f?(J=async(Me,Ue)=>{await f(Me,{name:Ue})},e[23]=f,e[24]=J):J=e[24];const Q=J;let X;e[25]!==u?(X=async Me=>{await u(Me)},e[25]=u,e[26]=X):X=e[26];const Z=X;let se;e[27]!==l||e[28]!==m?(se=async Me=>{await m(Me),await l()},e[27]=l,e[28]=m,e[29]=se):se=e[29];const ne=se;let re;e[30]!==o?(re=Me=>{Me||o()},e[30]=o,e[31]=re):re=e[31];let ie;e[32]!==i?(ie=Me=>{Me||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(Ss,{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 — ",F9," jumps between devices."]})]}),e[34]=ae):ae=e[34];let te;e[35]!==a||e[36]!==Z||e[37]!==Q||e[38]!==ne||e[39]!==f?(te=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(Me=>r.jsx(K9,{device:Me,hubVersion:M9,onRename:Q,onCredentials:f,onRemove:Z,onTest:ne},Me.id))}),e[35]=a,e[36]=Z,e[37]=Q,e[38]=ne,e[39]=f,e[40]=te):te=e[40];let ue;e[41]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx($n,{"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]=ue):ue=e[41];const le=(T==null?void 0:T.field)==="host";let de,he;e[42]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(bt,{htmlFor:"device-host",children:"Host"}),he=r.jsx(yo,{children:"Enter a local address or an HTTPS URL."}),e[42]=de,e[43]=he):(de=e[42],he=e[43]);let xe;e[44]===Symbol.for("react.memo_cache_sentinel")?(xe=Me=>{R.current=R.current+1,x(Me.target.value),w(""),A(null),I(null)},e[44]=xe):xe=e[44];let ce;e[45]!==L?(ce=()=>void L(),e[45]=L,e[46]=ce):ce=e[46];let be;e[47]!==g||e[48]!==ce?(be=r.jsx(Bt,{id:"device-host",ref:$,value:g,onChange:xe,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]=be):be=e[49];let ge;e[50]!==C?(ge=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]=ge):ge=e[51];let fe;e[52]!==_||e[53]!==C?(fe=!C&&_&&r.jsxs("p",{role:"status",className:V("flex items-center gap-1.5 text-xs",l2[_.tone]),children:[r.jsx(W9,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=fe):fe=e[54];let je;e[55]!==T?(je=(T==null?void 0:T.field)==="host"&&r.jsx(fs,{children:T.message}),e[55]=T,e[56]=je):je=e[56];let Se;e[57]!==le||e[58]!==be||e[59]!==ge||e[60]!==fe||e[61]!==je?(Se=r.jsxs(xt,{"data-invalid":le,children:[de,he,be,ge,fe,je]}),e[57]=le,e[58]=be,e[59]=ge,e[60]=fe,e[61]=je,e[62]=Se):Se=e[62];let Ae;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ae=r.jsxs(bt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Ae):Ae=e[63];let Ie;e[64]===Symbol.for("react.memo_cache_sentinel")?(Ie=Me=>h(Me.target.value),e[64]=Ie):Ie=e[64];let Re;e[65]!==p?(Re=r.jsxs(xt,{children:[Ae,r.jsx(Bt,{id:"device-name",value:p,onChange:Ie,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=Re):Re=e[66];let De;e[67]!==T||e[68]!==W||e[69]!==b?(De=W&&r.jsxs(xt,{"data-invalid":(T==null?void 0:T.field)==="username",children:[r.jsx(bt,{htmlFor:"device-username",children:"Username"}),r.jsx(Bt,{id:"device-username",value:b,onChange:Me=>w(Me.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(yo,{children:"Requests through this hub will act as this account on the team server."}),(T==null?void 0:T.field)==="username"&&r.jsx(fs,{children:T.message})]}),e[67]=T,e[68]=W,e[69]=b,e[70]=De):De=e[70];let Le;e[71]!==H||e[72]!==v||e[73]!==T||e[74]!==W?(Le=H&&r.jsxs(xt,{"data-invalid":(T==null?void 0:T.field)==="password",children:[r.jsx(bt,{htmlFor:"device-password",children:"Password"}),r.jsx(Bt,{id:"device-password",type:"password",value:v,onChange:Me=>j(Me.target.value),placeholder:W?"Password for that team account":"Network access password for that device",autoComplete:W?"current-password":"off"}),(T==null?void 0:T.field)==="password"&&r.jsx(fs,{children:T.message})]}),e[71]=H,e[72]=v,e[73]=T,e[74]=W,e[75]=Le):Le=e[75];let ze;e[76]!==Se||e[77]!==Re||e[78]!==De||e[79]!==Le?(ze=r.jsxs(To,{children:[Se,Re,De,Le]}),e[76]=Se,e[77]=Re,e[78]=De,e[79]=Le,e[80]=ze):ze=e[80];let _e;e[81]===Symbol.for("react.memo_cache_sentinel")?(_e=Me=>{R.current=R.current+1,k(Me===!0),A(null),I(null)},e[81]=_e):_e=e[81];let Ce;e[82]!==S?(Ce=r.jsx(l1,{id:"device-local-tunnel",name:"device-local-tunnel",checked:S,onCheckedChange:_e}),e[82]=S,e[83]=Ce):Ce=e[83];const We=W?"":" — no password";let Fe;e[84]!==We?(Fe=r.jsxs(bt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",We]}),e[84]=We,e[85]=Fe):Fe=e[85];let Ne;e[86]!==Ce||e[87]!==Fe?(Ne=r.jsxs(xt,{orientation:"horizontal",children:[Ce,Fe]}),e[86]=Ce,e[87]=Fe,e[88]=Ne):Ne=e[88];let me;e[89]!==S||e[90]!==W?(me=S&&r.jsxs(St,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(Ky,{}),r.jsx(Nt,{className:"text-warning",children:W?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]=S,e[90]=W,e[91]=me):me=e[91];let Oe;e[92]!==o?(Oe=r.jsx(ee,{variant:"outline",onClick:o,children:"Close"}),e[92]=o,e[93]=Oe):Oe=e[93];const Pe=!q;let Be;e[94]!==G?(Be=()=>void G(),e[94]=G,e[95]=Be):Be=e[95];let oe;e[96]!==P?(oe=P?r.jsxs(r.Fragment,{children:[r.jsx(rt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=P,e[97]=oe):oe=e[97];let pe;e[98]!==Pe||e[99]!==Be||e[100]!==oe?(pe=r.jsx(ee,{disabled:Pe,onClick:Be,children:oe}),e[98]=Pe,e[99]=Be,e[100]=oe,e[101]=pe):pe=e[101];let Te;e[102]!==Oe||e[103]!==pe?(Te=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Oe,pe]}),e[102]=Oe,e[103]=pe,e[104]=Te):Te=e[104];let $e;e[105]!==ze||e[106]!==Ne||e[107]!==me||e[108]!==Te?($e=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ue,ze,Ne,me,Te]}),e[105]=ze,e[106]=Ne,e[107]=me,e[108]=Te,e[109]=$e):$e=e[109];let He;e[110]!==te||e[111]!==$e?(He=r.jsxs(Qn,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,te,$e]}),e[110]=te,e[111]=$e,e[112]=He):He=e[112];let Ke;return e[113]!==t||e[114]!==re||e[115]!==ie||e[116]!==He?(Ke=r.jsx(Jn,{open:t,onOpenChange:re,onOpenChangeComplete:ie,children:He}),e[113]=t,e[114]=re,e[115]=ie,e[116]=He,e[117]=Ke):Ke=e[117],Ke}const q9=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:c2,parseHostPort:Yo,probeMessage:a2},Symbol.toStringTag,{value:"Module"})),Pp=i2.version,V9={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},Ip={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function G9(n){const e=B.c(6),{state:t}=n,s=Ip[t],o=Ip[t],i=V9[t];let a;e[0]!==i?(a=V("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 nu(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}=Ha(),[d,f]=y.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(X9))).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 v;e[5]!==w?(v=V("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let j;e[7]!==b||e[8]!==v?(j=r.jsx(ee,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=j):j=e[9];let S;e[10]!==m?(S=m?r.jsx(zh,{"data-icon":"inline-start"}):r.jsx(yf,{"data-icon":"inline-start"}),e[10]=m,e[11]=S):S=e[11];let k;e[12]!==u?(k=r.jsx("span",{className:"truncate",children:u}),e[12]=u,e[13]=k):k=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(nt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let N;e[15]!==j||e[16]!==S||e[17]!==k?(N=r.jsxs(Ln,{render:j,children:[S,k,C]}),e[15]=j,e[16]=S,e[17]=k,e[18]=N):N=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Ls,{children:"Devices"}),e[19]=_):_=e[19];let A,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(yf,{}),P=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=A,e[21]=P):(A=e[20],P=e[21]);let E;e[22]!==m?(E=!m&&r.jsx(mt,{className:"ml-auto text-success"}),e[22]=m,e[23]=E):E=e[23];let T;e[24]!==E?(T=r.jsxs(kt,{onClick:Y9,children:[A,P,E]}),e[24]=E,e[25]=T):T=e[25];let I;if(e[26]!==i||e[27]!==s||e[28]!==o){let F;e[30]!==i||e[31]!==s?(F=z=>{const W=r2(z),U=W!==void 0&&W!==Pp,H=z.id===i;return r.jsxs(kt,{onClick:()=>gs(z.id),className:V(s&&"min-h-10"),children:[r.jsx(G9,{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${W}; hub runs v${Pp}`,children:["v",W]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[z.host,":",z.port,z.auth==="none"&&" · unauthenticated"]})]}),H&&r.jsx(mt,{className:"ml-auto text-success"})]},z.id)},e[30]=i,e[31]=s,e[32]=F):F=e[32],I=o.map(F),e[26]=i,e[27]=s,e[28]=o,e[29]=I}else I=e[29];let $;e[33]!==T||e[34]!==I?($=r.jsxs(Qt,{children:[_,T,I]}),e[33]=T,e[34]=I,e[35]=$):$=e[35];let R;e[36]!==o.length?(R=h&&r.jsxs(r.Fragment,{children:[r.jsx(dr,{}),r.jsxs(Qt,{children:[r.jsxs(kt,{onClick:()=>f("add"),children:[r.jsx($n,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(kt,{onClick:()=>f("manage"),children:[r.jsx(Kc,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=R):R=e[37];let M;e[38]!==$||e[39]!==R?(M=r.jsxs(zn,{align:"end",sideOffset:6,className:"w-64",children:[$,R]}),e[38]=$,e[39]=R,e[40]=M):M=e[40];let D;e[41]!==x||e[42]!==N||e[43]!==M?(D=r.jsxs(Dn,{onOpenChange:x,children:[N,M]}),e[41]=x,e[42]=N,e[43]=M,e[44]=D):D=e[44];let O;e[45]!==d?(O=h&&r.jsx(c2,{open:d!==null,initialMode:d??"manage",onClose:()=>f(null)}),e[45]=d,e[46]=O):O=e[46];let L;return e[47]!==D||e[48]!==O?(L=r.jsxs(r.Fragment,{children:[D,O]}),e[47]=D,e[48]=O,e[49]=L):L=e[49],L}function Y9(){return gs(jt)}function X9(){return null}const J9=6e4;function Q9(){const[n,e]=y.useState([]),[t,s]=y.useState(!1),o=y.useRef(!1),i=y.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=y.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 y.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},J9);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const Z9=6e4;function eA(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=Q9(),[i,a]=y.useState(!1),l=e.length>0,c=e.reduce(sA,0);let d,f;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const E=window.setTimeout(()=>a(!1),Z9);return()=>window.clearTimeout(E)},f=[l],n[0]=l,n[1]=d,n[2]=f):(d=n[1],f=n[2]),y.useEffect(d,f),!l&&!i)return null;const u=Tt,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(nA)):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=V("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(ee,{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(qy,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const v=t?"…":e.length;let j;n[17]!==v?(j=r.jsx("span",{className:"tabular-nums",children:v}),n[17]=v,n[18]=j):j=n[18];let S;n[19]!==j||n[20]!==b?(S=r.jsxs(Et,{render:b,children:[w,j]}),n[19]=j,n[20]=b,n[21]=S):S=n[21];const k=At,C="bottom",N="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(tA),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(Rt,{}),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 A;n[22]!==k||n[23]!==_?(A=r.jsx(k,{side:C,className:N,children:_}),n[22]=k,n[23]=_,n[24]=A):A=n[24];let P;return n[25]!==u||n[26]!==S||n[27]!==A?(P=r.jsxs(u,{children:[S,A]}),n[25]=u,n[26]=S,n[27]=A,n[28]=P):P=n[28],P}function tA(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," · ",Zc(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function nA(n){return n.pid}function sA(n,e){return n+e.cpuPercent}const oA=15e3;function rA(){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]=y.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(),oA);return()=>window.clearInterval(b)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),y.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(b,w)=>{const v=new Date().toISOString();s(j=>j.map(S=>S.readAt===null&&w(S)?{...S,readAt:v}:S));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},aA),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(iA),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 iA(n){return n.readAt===null}function aA(){return!0}function d2(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function lA(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=rA(),[a,l]=y.useState(!1);let c;n[0]!==o?(c=function(N){if(o([N.id]),!N.dirName||!N.sessionId)return;const _=gt(),A=_===jt?"":`/d/${_}`;d2(`${A}/${encodeURIComponent(N.dirName)}/${encodeURIComponent(N.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(ee,{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(wf,{"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(ee,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(Vy,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=w):w=n[16];let v;n[17]!==w?(v=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,w]}),n[17]=w,n[18]=v):v=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(un,{className:"min-h-40 p-6",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(wf,{})}),r.jsx(mn,{children:"No notifications"}),r.jsx(Tn,{children:"Session updates will appear here."})]})}):r.jsx(Qt,{children:e.map(C=>r.jsx(cA,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=j):j=n[21];let S;n[22]!==v||n[23]!==j?(S=r.jsxs(zn,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[v,j]}),n[22]=v,n[23]=j,n[24]=S):S=n[24];let k;return n[25]!==a||n[26]!==f||n[27]!==S||n[28]!==x?(k=r.jsxs(Dn,{open:a,onOpenChange:f,children:[x,S]}),n[25]=a,n[26]=f,n[27]=S,n[28]=x,n[29]=k):k=n[29],k}function cA(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"?sn:fa;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=V("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=V("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=V("truncate text-xs",b),e[13]=b,e[14]=w):w=e[14];let v;e[15]!==t.title||e[16]!==w?(v=r.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=v):v=e[17];let j;e[18]!==c?(j=Zc(c),e[18]=c,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:j}),e[20]=j,e[21]=S):S=e[21];let k;e[22]!==v||e[23]!==S?(k=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[v,S]}),e[22]=v,e[23]=S,e[24]=k):k=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 N;e[27]!==k||e[28]!==C?(N=r.jsxs("span",{className:"min-w-0 flex-1",children:[k,C]}),e[27]=k,e[28]=C,e[29]=N):N=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 A;return e[32]!==N||e[33]!==_||e[34]!==f||e[35]!==p||e[36]!==x?(A=r.jsxs(kt,{onClick:f,className:p,children:[x,N,_]}),e[32]=N,e[33]=_,e[34]=f,e[35]=p,e[36]=x,e[37]=A):A=e[37],A}const dA=2e3;function No(n){return`${n.toFixed(n<10?1:0)}%`}function Ji(n){return`${n.toFixed(0)} MB`}function uA(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function fA(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 mA(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(ee,{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=V("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=No(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=Ji(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=Zc(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 v;e[37]!==g||e[38]!==w?(v=r.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=v):v=e[39];let j;return e[40]!==v||e[41]!==f||e[42]!==u?(j=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[f,u,v]}),e[40]=v,e[41]=f,e[42]=u,e[43]=j):j=e[43],j}function pA(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 hA(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 u2(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=pA(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=V("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=No(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=Ji(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 Rp(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(gA)}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 gA(n,e){const t=fA(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(Rt,{}),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:uA(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 xA(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(bA).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:V("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:No(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 bA(n){return No(n)}function vA(n){var he,xe,ce,be;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=y.useState(null),[a,l]=y.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,f]=y.useState(c),[u,m]=y.useState(null),[p,h]=y.useState(!1),g=y.useRef(!1),[x,b]=Fs();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Re;if(g.current)return;g.current=!0,h(!0);const ge=ye("/api/performance").then(kA),fe=((Re=window.electronPerformance)==null?void 0:Re.getSnapshot())??Promise.resolve(null),[je,Se]=await Promise.allSettled([ge,fe]),Ae=je.status==="fulfilled"?je.value:null,Ie=Se.status==="fulfilled"?Se.value:null;if(Ae&&l(Ae),Ie&&i(Ie),!Ae&&!Ie)m("Performance data is unavailable.");else{m(null);const De=Ie&&Ie.processes.length>0?Ie.processes.reduce(NA,0):(Ae==null?void 0:Ae.cpuPercent)??0;f(Le=>[...Le.slice(-29),De])}g.current=!1,h(!1)},e[1]=w):w=e[1];const v=w;let j,S;e[2]!==t?(j=()=>{if(!t)return;v();const ge=window.setInterval(()=>void v(),dA);return()=>window.clearInterval(ge)},S=[t,v],e[2]=t,e[3]=j,e[4]=S):(j=e[3],S=e[4]),y.useEffect(j,S);let k,C,N,_,A,P,E,T,I,$,R,M,D,O,L,F,z,W,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 ge=[...(o==null?void 0:o.processes)??[]].sort(SA),fe=ge.length>0?ge.reduce(jA,0):(a==null?void 0:a.cpuPercent)??0,je=ge[0];let Se;e[33]!==((he=a==null?void 0:a.system)==null?void 0:he.processes)?(Se=((xe=a==null?void 0:a.system)==null?void 0:xe.processes)??[],e[33]=(ce=a==null?void 0:a.system)==null?void 0:ce.processes,e[34]=Se):Se=e[34],E=Se;const Ae=((be=a==null?void 0:a.system)==null?void 0:be.suspectedLeakCount)??0,Ie=Ae>0||fe>=80?"High":fe>=15?"Active":"Idle";let Re;e[35]===Symbol.for("react.memo_cache_sentinel")?(Re=async ot=>{try{await ye("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[ot]})}),await new Promise(wA)}catch{}v()},e[35]=Re):Re=e[35],P=Re;let De;e[36]!==b||e[37]!==o||e[38]!==d||e[39]!==a?(De=()=>{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]=De):De=e[40];const Le=De;A=Jn,D=t,O=s,_=Qn,$="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 _e=Ie==="High"?"destructive":"secondary";let Ce;e[42]!==Ie||e[43]!==_e?(Ce=r.jsxs("div",{className:"flex items-center gap-2",children:[ze,r.jsx(Ee,{variant:_e,children:Ie})]}),e[42]=Ie,e[43]=_e,e[44]=Ce):Ce=e[44];let We;e[45]===Symbol.for("react.memo_cache_sentinel")?(We=r.jsx(es,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=We):We=e[45];let Fe;e[46]!==Ce?(Fe=r.jsxs("div",{className:"min-w-0 flex-1",children:[Ce,We]}),e[46]=Ce,e[47]=Fe):Fe=e[47];let Ne;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>void v(),e[48]=Ne):Ne=e[48];const me=p&&"animate-spin";let Oe;e[49]!==me?(Oe=V(me),e[49]=me,e[50]=Oe):Oe=e[50];let Pe;e[51]!==Oe?(Pe=r.jsx(Dt,{"data-icon":"inline-start",className:Oe}),e[51]=Oe,e[52]=Pe):Pe=e[52];let Be;e[53]!==p||e[54]!==Pe?(Be=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Ne,disabled:p,children:[Pe,"Refresh"]}),e[53]=p,e[54]=Pe,e[55]=Be):Be=e[55];const oe=!a&&!o;let pe;e[56]!==x?(pe=x?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(Cn,{"data-icon":"inline-start"}),e[56]=x,e[57]=pe):pe=e[57];const Te=x?"Copied":"Copy data";let $e;e[58]!==Le||e[59]!==oe||e[60]!==pe||e[61]!==Te?($e=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Le,disabled:oe,children:[pe,Te]}),e[58]=Le,e[59]=oe,e[60]=pe,e[61]=Te,e[62]=$e):$e=e[62];let He;e[63]!==Be||e[64]!==$e?(He=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Be,$e]}),e[63]=Be,e[64]=$e,e[65]=He):He=e[65],e[66]!==Fe||e[67]!==He?(R=r.jsx(Ss,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Fe,He]})}),e[66]=Fe,e[67]=He,e[68]=R):R=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Rt,{}),e[69]=M):M=e[69],N=Vs,I="min-h-0 min-w-0 flex-1",W="flex flex-col gap-4 p-5",e[70]!==u?(U=u&&r.jsx(St,{variant:"destructive",children:r.jsx(Nt,{children:u})}),e[70]=u,e[71]=U):U=e[71];let Ke;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ke=r.jsx(nn,{children:"Current load"}),e[72]=Ke):Ke=e[72];const st=fe>=80&&"text-destructive";let Ye;e[73]!==st?(Ye=V("font-mono text-lg font-semibold tabular-nums",st),e[73]=st,e[74]=Ye):Ye=e[74];const Me=r.jsxs(tn,{children:[Ke,r.jsx(an,{children:hA(fe,je,Ae)}),r.jsx(gd,{children:r.jsxs("span",{className:Ye,children:[No(fe)," CPU"]})})]});let Ue;e[75]!==d?(Ue=r.jsx(Xt,{children:r.jsx(xA,{values:d})}),e[75]=d,e[76]=Ue):Ue=e[76],e[77]!==Me||e[78]!==Ue?(T=r.jsxs(Yt,{size:"sm",children:[Me,Ue]}),e[77]=Me,e[78]=Ue,e[79]=T):T=e[79],C=Yt,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs(tn,{children:[r.jsx(nn,{children:"Processes"}),r.jsx(an,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],k=Xt,L=ge.length>0?ge.map(yA):a?r.jsx(u2,{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]=k,e[15]=C,e[16]=N,e[17]=_,e[18]=A,e[19]=P,e[20]=E,e[21]=T,e[22]=I,e[23]=$,e[24]=R,e[25]=M,e[26]=D,e[27]=O,e[28]=L,e[29]=F,e[30]=z,e[31]=W,e[32]=U}else k=e[14],C=e[15],N=e[16],_=e[17],A=e[18],P=e[19],E=e[20],T=e[21],I=e[22],$=e[23],R=e[24],M=e[25],D=e[26],O=e[27],L=e[28],F=e[29],z=e[30],W=e[31],U=e[32];let H;e[81]!==k||e[82]!==L?(H=r.jsx(k,{children:L}),e[81]=k,e[82]=L,e[83]=H):H=e[83];let K;e[84]!==C||e[85]!==H||e[86]!==F||e[87]!==z?(K=r.jsxs(C,{size:F,children:[z,H]}),e[84]=C,e[85]=H,e[86]=F,e[87]=z,e[88]=K):K=e[88];let q;e[89]!==P||e[90]!==E?(q=E.length>0&&r.jsxs(Yt,{size:"sm",children:[r.jsxs(tn,{children:[r.jsx(nn,{children:"Agent processes"}),r.jsx(an,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Xt,{children:E.map((ge,fe)=>r.jsxs("div",{children:[fe>0&&r.jsx(Rt,{}),r.jsx(mA,{metric:ge,onKill:je=>void P(je)})]},ge.pid))})]}),e[89]=P,e[90]=E,e[91]=q):q=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(nn,{children:"Server activity"}),e[92]=Y):Y=e[92];const G=(a==null?void 0:a.sampleWindowSeconds)??10;let J;e[93]!==G?(J=r.jsxs(tn,{children:[Y,r.jsxs(an,{children:["File checks, streams, and agent work over the last ",G," seconds."]})]}),e[93]=G,e[94]=J):J=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 X;e[97]!==Q?(X=r.jsx(Xt,{children:r.jsx(Rp,{metrics:Q,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=Q,e[98]=X):X=e[98];let Z;e[99]!==J||e[100]!==X?(Z=r.jsxs(Yt,{size:"sm",children:[J,X]}),e[99]=J,e[100]=X,e[101]=Z):Z=e[101];let se;e[102]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsxs(tn,{children:[r.jsx(nn,{children:"API activity"}),r.jsx(an,{children:"Requests ranked by recent frequency and time."})]}),e[102]=se):se=e[102];let ne;e[103]!==(a==null?void 0:a.requests)?(ne=(a==null?void 0:a.requests)??[],e[103]=a==null?void 0:a.requests,e[104]=ne):ne=e[104];let re;e[105]!==ne?(re=r.jsxs(Yt,{size:"sm",children:[se,r.jsx(Xt,{children:r.jsx(Rp,{metrics:ne,emptyLabel:"No API requests in this sample."})})]}),e[105]=ne,e[106]=re):re=e[106];let ie;e[107]!==Z||e[108]!==re?(ie=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Z,re]}),e[107]=Z,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 ",No(a.eventLoopPercent)," · heap ",Ji(a.memory.heapUsedMb)," · RSS ",Ji(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let te;e[112]!==T||e[113]!==K||e[114]!==q||e[115]!==ie||e[116]!==ae||e[117]!==W||e[118]!==U?(te=r.jsxs("div",{className:W,children:[U,T,K,q,ie,ae]}),e[112]=T,e[113]=K,e[114]=q,e[115]=ie,e[116]=ae,e[117]=W,e[118]=U,e[119]=te):te=e[119];let ue;e[120]!==N||e[121]!==I||e[122]!==te?(ue=r.jsx(N,{className:I,children:te}),e[120]=N,e[121]=I,e[122]=te,e[123]=ue):ue=e[123];let le;e[124]!==_||e[125]!==$||e[126]!==R||e[127]!==M||e[128]!==ue?(le=r.jsxs(_,{className:$,children:[R,M,ue]}),e[124]=_,e[125]=$,e[126]=R,e[127]=M,e[128]=ue,e[129]=le):le=e[129];let de;return e[130]!==A||e[131]!==D||e[132]!==O||e[133]!==le?(de=r.jsx(A,{open:D,onOpenChange:O,children:le}),e[130]=A,e[131]=D,e[132]=O,e[133]=le,e[134]=de):de=e[134],de}function yA(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(Rt,{}),r.jsx(u2,{metric:n})]},n.pid)}function wA(n){return setTimeout(n,1e3)}function jA(n,e){return n+e.cpuPercent}function SA(n,e){return e.cpuPercent-n.cpuPercent}function NA(n,e){return n+e.cpuPercent}async function kA(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function CA(n){return`${n.title??`Pull request #${n.number}`}
122
+ ${n.repo}${n.isDraft?" · draft":""}`}function f2(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:CA(n)}}function Ka(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(TA),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(_A).join(`
123
+ `),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?Hh:Kh;return r.jsxs(Ee,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...f2(p)}),className:V("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 _A(n){return`#${n.number} ${n.title??n.repo}`}function TA(n){const e=n.isDraft?Hh:Kh;return r.jsxs("a",{...f2(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 EA=y.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 P=o?xs(o.fileName):null;p=P?Kd(P.agentId):null,t[0]=o,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(IA),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=vo(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 v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:V(In,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=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(PA,{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 S;t[17]!==i?(S=i&&r.jsx(Sa,{"aria-label":"Session is live"}),t[17]=i,t[18]=S):S=t[18];let k;t[19]!==s.model?(k=s.model&&r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:Pr(s.model)}),t[19]=s.model,t[20]=k):k=t[20];let C;t[21]!==w?(C=r.jsx(Hg,{rawMessages:w}),t[21]=w,t[22]=C):C=t[22];let N;t[23]!==j||t[24]!==S||t[25]!==k||t[26]!==C?(N=r.jsxs(Et,{delay:200,render:v,children:[j,S,k,C]}),t[23]=j,t[24]=S,t[25]=k,t[26]=C,t[27]=N):N=t[27];let _;t[28]!==a||t[29]!==w||t[30]!==s||t[31]!==h||t[32]!==x?(_=r.jsx(At,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(AA,{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 A;return t[34]!==_||t[35]!==N?(A=r.jsxs(Tt,{children:[N,_]}),t[34]=_,t[35]=N,t[36]=A):A=t[36],A});function oo(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 AA(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=Sg(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(oo,{label:"Model",children:[r.jsx("span",{children:Pr(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(oo,{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(oo,{label:"Pull requests",children:r.jsx(Ka,{pullRequests:i})}),e[19]=i,e[20]=f):f=e[20],e[21]!==o?(u=o&&r.jsx(oo,{label:"Agent",children:o}),e[21]=o,e[22]=u):u=e[22],e[23]!==x?(m=x&&r.jsxs(oo,{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(oo,{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 PA(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}=Lt(),u=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Ds(),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 v=w;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=!p||vd(),e[10]=j):j=e[10];const S=j;let k;e[11]!==f||e[12]!==s.dirName?(k=function(){y.startTransition(()=>{f({type:"GO_HOME",isMobile:!1}),f({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=f,e[12]=s.dirName,e[13]=k):k=e[13];const C=k,N=`Copy resume command for ${b}; open session actions with the context menu`;let _;e[14]!==a||e[15]!==N?(_=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":N,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=a,e[15]=N,e[16]=_):_=e[16];let A;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(A=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(mt,{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]=A):A=e[20];let P;e[21]!==_||e[22]!==A?(P=r.jsx(Da,{render:_,children:A}),e[21]=_,e[22]=A,e[23]=P):P=e[23];let E;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(E=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=E):E=e[27];let T;e[28]!==i?(T=i?r.jsx(vt,{className:"size-3.5"}):r.jsx($n,{className:"size-3.5"}),e[28]=i,e[29]=T):T=e[29];let I;e[30]!==i||e[31]!==E||e[32]!==T?(I=r.jsxs(en,{disabled:i,onClick:E,children:[T,"New session in this project"]}),e[30]=i,e[31]=E,e[32]=T,e[33]=I):I=e[33];let $;e[34]!==c?($=c&&r.jsxs(en,{onClick:c,children:[r.jsx(Cn,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=$):$=e[35];let R;e[36]!==u||e[37]!==v?(R=u&&(S||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(br,{}),S&&r.jsxs(en,{onClick:()=>h1(v),children:[r.jsx(Sr,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(en,{onClick:()=>g1(v),children:[r.jsx(qh,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=u,e[37]=v,e[38]=R):R=e[38];let M;e[39]!==d?(M=d&&!p&&lt("terminal")&&r.jsxs(en,{onClick:d,children:[r.jsx(Hs,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=M):M=e[40];let D;e[41]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(br,{}),e[41]=D):D=e[41];let O;e[42]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(bo,{className:"size-3.5"}),e[42]=O):O=e[42];let L;e[43]!==C?(L=r.jsxs(en,{onClick:C,children:[O,"View all sessions in this project"]}),e[43]=C,e[44]=L):L=e[44];let F;e[45]!==I||e[46]!==$||e[47]!==R||e[48]!==M||e[49]!==L?(F=r.jsxs(La,{className:"min-w-56",children:[I,$,R,M,D,L]}),e[45]=I,e[46]=$,e[47]=R,e[48]=M,e[49]=L,e[50]=F):F=e[50];let z;return e[51]!==P||e[52]!==F?(z=r.jsxs(Oa,{children:[P,F]}),e[51]=P,e[52]=F,e[53]=z):z=e[53],z}function IA(n){return n.thinking.length>0}const Tc="Could not reach the server";async function bi(n,e){try{return await ye(n,e)}catch{return null}}async function Dl(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:Tc}function RA(){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]=y.useState(e),[o,i]=y.useState(null),a=y.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]),y.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const k=await bi("/api/shares");if(!(k!=null&&k.ok))return;const C=await k.json().catch(DA);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]),y.useEffect(u,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async k=>{i(null);const C=await bi("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:k})});if(!(C!=null&&C.ok))return a.current&&i(await Dl(C)),null;const N=await C.json().catch(OA);if(!(N!=null&&N.passphrase)||!N.share)return a.current&&i(Tc),null;const _=N.share;return a.current&&s(A=>[...A.filter(P=>P.sessionId!==_.sessionId),_]),N.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async k=>{i(null);const C=await bi(`/api/shares/${encodeURIComponent(k)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await Dl(C)),null;const N=await C.json().catch(MA);return N!=null&&N.passphrase?(f(),N.passphrase):(a.current&&i(Tc),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async k=>{i(null);const C=await bi(`/api/shares/${encodeURIComponent(k)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await Dl(C));return}a.current&&s(N=>N.filter(_=>_.sessionId!==k))},n[8]=b):b=n[8];const w=b;let v;n[9]!==t?(v=async()=>{const k=t.map($A);for(const C of k)await w(C)},n[9]=t,n[10]=v):v=n[10];const j=v;let S;return n[11]!==o||n[12]!==j||n[13]!==t?(S={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]=S):S=n[14],S}function $A(n){return n.sessionId}function MA(){return null}function OA(){return null}function DA(){return null}const LA=5e3,zA="••••";function FA(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function BA({sessionId:n}){const{config:{networkAccessDisabled:e}}=Lt(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=RA(),[c,d]=y.useState(!1),[f,u]=y.useState(null),[m,p]=y.useState(!1),[h,g]=Fs(),[x,b]=Fs(),w=t.find(k=>k.sessionId===n)??null,v=`${window.location.origin}${t4(n)}`;y.useEffect(()=>u(null),[n]),y.useEffect(()=>{if(!c)return;o();const k=setInterval(()=>void o(),LA);return()=>clearInterval(k)},[c,o]);async function j(k){p(!0);try{await k()}finally{p(!1)}}const S=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:k=>{d(k),k||u(null)},children:[r.jsx(Ln,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":w?"Session is shared":"Share session",className:V(w&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:r.jsx(Gy,{"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:v}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(v),children:h?r.jsx(mt,{"data-icon":"inline-start"}):r.jsx(Cn,{"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??zA}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{u(await a(n))}),children:r.jsx(Dt,{"data-icon":"inline-start"})})]}),f?r.jsx(ee,{variant:"secondary",size:"xs",onClick:()=>b(`${v}
124
+ 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."}),S,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:FA(w.guests)}),r.jsx(ee,{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."}),S,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(ee,{size:"xs",disabled:m,onClick:()=>j(async()=>{u(await i(n))}),children:"Enable sharing"})]})})]})}function su(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 jn(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?su(jn(n.utilization),ms(n.resets_at)):void 0}function m2(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:jn(n.monthly_limit),usedCredits:jn(n.used_credits),utilization:jn(n.utilization)}}function UA(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:m2(at(n.extra_usage)),subscriptionType:ms(n.subscriptionType)}}function WA(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:m2(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 HA(n){const e=jn(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function KA(n,e){const t=jn(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function $p(n,e){if(n)return su(jn(n.usedPercent),HA(n.resetsAt),KA(n.windowDurationMins,e))}function qA(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=$p(at(e==null?void 0:e.primary),"Primary"),a=$p(at(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=jn(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 Mp(n,e){if(!n)return;const t=jn(n.remainingPercentage),s=jn(n.usedRequests),o=jn(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),su(i,ms(n.resetDate),e)}function VA(n){var s;if(n.available!==!0)return null;const e=at((s=at(n.quota))==null?void 0:s.quotaSnapshots),t=Mp(at(e==null?void 0:e.chat),"Chat")??Mp(at(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const GA={claude:{endpoint:"/api/claude/runtime",read:WA,legacy:{endpoint:"/api/usage",read:UA}},codex:{endpoint:"/api/codex/runtime",read:qA},copilot:{endpoint:"/api/copilot/runtime",read:VA}};function YA(n){return GA[n]}const XA=300*1e3;function JA(n=qs){const e=Sn("viewUsage"),[t,s]=y.useState(null),[o,i]=y.useState(!1),[a,l]=y.useState(!1),c=y.useRef(0),d=y.useRef(null),f=y.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=YA(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 v=b(w);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return y.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,XA);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 p2(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const h2={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function QA(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?wa(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=p2(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:V("font-semibold",h2[b]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(rd,{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(Rt,{}),"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(Rt,{}),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 ZA(n){var j,S;const e=B.c(22),{agentKind:t}=n,s=t===void 0?qs:t,{usage:o,loading:i,available:a,refresh:l}=JA(s);if(!a||!o)return null;const c=((j=o.fiveHour)==null?void 0:j.utilization)??((S=o.sevenDay)==null?void 0:S.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?wa(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(ee,{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=h2[p2(c)],p=i&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=V("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(Et,{render:u,children:x}),e[14]=u,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==o?(w=r.jsx(At,{side:"bottom",className:"p-3",children:r.jsx(QA,{usage:o})}),e[17]=o,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=r.jsxs(Tt,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function eP(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]=y.useState(s),[a,l]=y.useState(0);let c;t[1]!==n||t[2]!==e?(c=()=>{const p=new AbortController;i(nP);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],y.useEffect(c,d);let f;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>l(tP),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 tP(n){return n+1}function nP(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 oP=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function rP(n,e){const t=sP(e);return t.length===0||oP.has(t)?null:n.get(t)??null}function iP(n,e,t,s){const o=rP(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 aP(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function g2(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=iP(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 lP=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],nr=Ng.map(n=>({key:n,label:on(n).displayName,color:Gw(n)}));function cP(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 Op(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function dP(n){const e=new Map;for(const o of cP(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:Op(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:Op(),days:[],models:[]};for(const o of n.buckets){const i=aP(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 Dp(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const Ll=720,zl=180,uP=18;function fP(n){const e=B.c(41),{days:t,metric:s}=n,[o,i]=y.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=N=>l(N),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=zl-uP,u=Ll/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:Dp(p.day)}),nr.map(C=>{const{key:N,label:_,color:A}=C,P=p.byProvider[N];return l(P)<=0?null:r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:A}}),_,": ",s==="cost"?ls(P.costUsd):tt(P.tokens)]},N)}),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:Ll,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=(N,_)=>{const A=_*u+(u-m)/2;let P=f;const E=o===_;return r.jsxs("g",{onMouseEnter:()=>i(_),children:[r.jsx("rect",{x:_*u,y:0,width:u,height:f,fill:"transparent"}),E&&r.jsx("rect",{x:_*u,y:0,width:u,height:f,fill:"var(--foreground)",opacity:.05,rx:2}),nr.map(T=>{const{key:I,color:$}=T,R=l(N.byProvider[I]);if(R<=0)return null;const M=R/d*(f-6);return P=P-M,r.jsx("rect",{x:A,y:P,width:m,height:Math.max(1,M-1.5),rx:1.5,fill:$,opacity:E?1:.85},I)})]},N.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 v;if(e[27]!==t||e[28]!==u){let C;e[30]!==t.length||e[31]!==u?(C=(N,_)=>_===0||_===t.length-1||t.length>10&&_%7===0&&_<t.length-3?r.jsx("text",{x:_*u+u/2,y:zl-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:Dp(N.day)},N.day):null,e[30]=t.length,e[31]=u,e[32]=C):C=e[32],v=t.map(C),e[27]=t,e[28]=u,e[29]=v}else v=e[29];let j;e[33]!==g||e[34]!==w||e[35]!==v?(j=r.jsxs("svg",{viewBox:`0 0 ${Ll} ${zl}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,w,v]}),e[33]=g,e[34]=w,e[35]=v,e[36]=j):j=e[36];let S;e[37]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:nr.map(mP)}),e[37]=S):S=e[37];let k;return e[38]!==h||e[39]!==j?(k=r.jsxs("div",{className:"relative",children:[h,j,S]}),e[38]=h,e[39]=j,e[40]=k):k=e[40],k}function mP(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 Fl(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 pP(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=eP(t,!0),[l,c]=y.useState("cost");let d;e[0]!==s?(d=s?dP(s):null,e[0]=s,e[1]=d):d=e[1];const f=d;if(i){let F;e[2]!==a?(F=r.jsx(ee,{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(vt,{className:"size-4"})," Scanning transcripts…"]}),e[7]=F):F=e[7],F}const u=o&&"opacity-60";let m;e[8]!==u?(m=V("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 v;e[23]!==l?(v=r.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(F=>r.jsx(ee,{variant:l===F?"secondary":"ghost",size:"xs",onClick:()=>c(F),children:F==="cost"?"Cost":"Tokens"},F))}),e[23]=l,e[24]=v):v=e[24];let j;e[25]!==f.byProvider||e[26]!==l?(j=nr.map(F=>{const{key:z,label:W}=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:[W,": ",l==="cost"?ls(U.costUsd):tt(U.tokens)]},z)}),e[25]=f.byProvider,e[26]=l,e[27]=j):j=e[27];let S;e[28]!==v||e[29]!==j?(S=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,j]}),e[28]=v,e[29]=j,e[30]=S):S=e[30];let k;e[31]!==S||e[32]!==b?(k=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,S]}),e[31]=S,e[32]=b,e[33]=k):k=e[33];let C;e[34]!==f.days||e[35]!==l?(C=r.jsx(fP,{days:f.days,metric:l}),e[34]=f.days,e[35]=l,e[36]=C):C=e[36];let N;e[37]!==f.tokens?(N=tt(f.tokens),e[37]=f.tokens,e[38]=N):N=e[38];let _;e[39]!==N?(_=r.jsx(Fl,{label:"Processed tokens",value:N}),e[39]=N,e[40]=_):_=e[40];let A;e[41]!==f.cacheSavingsUsd?(A=ls(f.cacheSavingsUsd),e[41]=f.cacheSavingsUsd,e[42]=A):A=e[42];let P;e[43]!==A?(P=r.jsx(Fl,{label:"Cache savings",value:A}),e[43]=A,e[44]=P):P=e[44];const E=String(s.scannedFiles);let T;e[45]!==E?(T=r.jsx(Fl,{label:"Files scanned",value:E}),e[45]=E,e[46]=T):T=e[46];let I;e[47]!==_||e[48]!==P||e[49]!==T?(I=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[_,P,T]}),e[47]=_,e[48]=P,e[49]=T,e[50]=I):I=e[50];let $;e[51]===Symbol.for("react.memo_cache_sentinel")?($=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]=$):$=e[51];let R;if(e[52]!==f.costUsd||e[53]!==f.models){let F;e[55]!==f.costUsd?(F=z=>{var W;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:(W=nr.find(U=>U.key===z.provider))==null?void 0:W.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],R=f.models.map(F),e[52]=f.costUsd,e[53]=f.models,e[54]=R}else R=e[54];let M;e[57]!==R?(M=r.jsxs("table",{className:"w-full text-sm",children:[$,r.jsx("tbody",{children:R})]}),e[57]=R,e[58]=M):M=e[58];const D=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let O;e[59]!==D?(O=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",D," ","— not what a subscription bills."]}),e[59]=D,e[60]=O):O=e[60];let L;return e[61]!==k||e[62]!==C||e[63]!==I||e[64]!==M||e[65]!==O||e[66]!==m?(L=r.jsxs("div",{className:m,children:[k,C,I,M,O]}),e[61]=k,e[62]=C,e[63]=I,e[64]=M,e[65]=O,e[66]=m,e[67]=L):L=e[67],L}function hP(n){const e=B.c(15),{open:t,onOpenChange:s}=n,[o,i]=y.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=lP.map(m=>r.jsx(ee,{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(Ss,{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(pP,{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 gP=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,xP=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,Bl=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,bP=[new RegExp(`${Bl}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${Bl}'([^']*)'`),new RegExp(`${Bl}(\\S+)`)];function vP(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 yP(n){return vP(n).find(e=>xP.test(e))??null}function wP(n){for(const e of bP){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function jP(){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=gP.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:wP(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function SP(n){const e=jP();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=yP(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function NP(...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 ro="flex h-8 items-center px-0.5",kP=y.memo(function(e){var Fe;const t=B.c(98),{showSidebar:s,sidebarRendered:o,sidebarShortcut:i,killing:a,creatingSession:l,onNewSession:c,onDuplicateSession:d,onOpenTerminal:f,onBackToMain:u,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x}=e,b=o===void 0?s:o,{config:w}=Lt(),{networkUrl:v,defaultAgentKind:j}=w,{session:S,sessionSource:k,isLive:C}=it(),N=Ud(),_=Sn("viewUsage"),[A,P]=y.useState(!1),[E,T]=y.useState(!1),[I,$]=Fs(),R=S==null?void 0:S.turns;let M;t[0]!==(N==null?void 0:N.sessions)||t[1]!==(S==null?void 0:S.sessionId)?(M=(Fe=N==null?void 0:N.sessions.find(Ne=>Ne.sessionId===(S==null?void 0:S.sessionId)))==null?void 0:Fe.pullRequests,t[0]=N==null?void 0:N.sessions,t[1]=S==null?void 0:S.sessionId,t[2]=M):M=t[2];const D=M;let O;t[3]!==D||t[4]!==R?(O=NP(SP(R??[]),D),t[3]=D,t[4]=R,t[5]=O):O=t[5];const L=O;let F;t[6]!==j||t[7]!==k?(F=k?k.agentKind??Ct(k.dirName):j,t[6]=j,t[7]=k,t[8]=F):F=t[8];const z=F;let W;t[9]!==k?(W=k?xs(k.fileName)!==null:!1,t[9]=k,t[10]=W):W=t[10];const U=W;let H;t[11]!==$||t[12]!==S||t[13]!==(k==null?void 0:k.agentKind)||t[14]!==(k==null?void 0:k.dirName)?(H=function(){if(!S)return;const me=(k==null?void 0:k.agentKind)??Ct((k==null?void 0:k.dirName)??null);$(og(me,S.sessionId,S.cwd))},t[11]=$,t[12]=S,t[13]=k==null?void 0:k.agentKind,t[14]=k==null?void 0:k.dirName,t[15]=H):H=t[15];const K=H;let q;t[16]!==v?(q=function(){v&&Er(v).then(_P)},t[16]=v,t[17]=q):q=t[17];const Y=q;let G,J;t[18]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),G=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]=G,t[19]=J):(G=t[18],J=t[19]);const Q=!b&&"window-inset-start";let X;t[20]!==Q?(X=V("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",Q),t[20]=Q,t[21]=X):X=t[21];let Z;t[22]!==h||t[23]!==s||t[24]!==i?(Z=!s&&r.jsx(CP,{icon:Xy,label:`Show sidebar (${i})`,onClick:h}),t[22]=h,t[23]=s,t[24]=i,t[25]=Z):Z=t[25];let se;t[26]!==U||t[27]!==u||t[28]!==S?(se=S&&U&&u&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:u,className:V(In,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(Je,{className:"size-3 rotate-180"}),"Main"]}),t[26]=U,t[27]=u,t[28]=S,t[29]=se):se=t[29];let ne;t[30]!==I||t[31]!==l||t[32]!==K||t[33]!==C||t[34]!==d||t[35]!==c||t[36]!==f||t[37]!==L||t[38]!==S||t[39]!==k?(ne=S&&r.jsx(EA,{session:S,sessionSource:k,isLive:C,pullRequests:L,copied:I,creatingSession:l,onCopyResume:K,onNewSession:c,onDuplicateSession:d,onOpenTerminal:f}),t[30]=I,t[31]=l,t[32]=K,t[33]=C,t[34]=d,t[35]=c,t[36]=f,t[37]=L,t[38]=S,t[39]=k,t[40]=ne):ne=t[40];let re;t[41]!==m||t[42]!==S||t[43]!==p?(re=S&&m&&(p??0)>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:V(In,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[r.jsx(ma,{className:"size-3"}),"Workflows",r.jsx(Ee,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=S,t[43]=p,t[44]=re):re=t[44];let ie;t[45]!==X||t[46]!==Z||t[47]!==se||t[48]!==ne||t[49]!==re?(ie=r.jsxs("div",{className:X,children:[Z,se,ne,re]}),t[45]=X,t[46]=Z,t[47]=se,t[48]=ne,t[49]=re,t[50]=ie):ie=t[50];let ae,te,ue;t[51]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx("div",{className:V(In,ro,"empty:hidden"),children:r.jsx(eA,{})}),te=r.jsx("div",{className:V(In,ro,"empty:hidden"),children:r.jsx(lA,{})}),ue=V(In,ro,"empty:hidden"),t[51]=ae,t[52]=te,t[53]=ue):(ae=t[51],te=t[52],ue=t[53]);let le;t[54]!==z?(le=r.jsx("div",{className:ue,children:r.jsx(ZA,{agentKind:z})}),t[54]=z,t[55]=le):le=t[55];let de;t[56]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx("div",{className:V(In,ro,"empty:hidden"),children:r.jsx(nu,{})}),t[56]=de):de=t[56];let he;t[57]!==z||t[58]!==S?(he=S&&Ht(z).sharing&&lt("share")&&r.jsx("div",{className:V(In,ro),children:r.jsx(BA,{sessionId:S.sessionId})}),t[57]=z,t[58]=S,t[59]=he):he=t[59];let xe;t[60]===Symbol.for("react.memo_cache_sentinel")?(xe=V(In,ro),t[60]=xe):xe=t[60];let ce;t[61]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(Ln,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(Vh,{"data-icon":"inline-start"})}),t[61]=ce):ce=t[61];let be;t[62]!==_?(be=_&&r.jsxs(kt,{onClick:()=>P(!0),children:[r.jsx(Gh,{}),"Usage & cost…"]}),t[62]=_,t[63]=be):be=t[63];let ge;t[64]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsxs(kt,{onClick:()=>T(!0),children:[r.jsx(Yh,{}),"Server monitor…"]}),t[64]=ge):ge=t[64];let fe;t[65]!==Y||t[66]!==v?(fe=v&&r.jsxs(kt,{onClick:Y,children:[r.jsx(Zl,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:v})]}),t[65]=Y,t[66]=v,t[67]=fe):fe=t[67];let je;t[68]!==be||t[69]!==fe?(je=r.jsxs(Qt,{children:[be,ge,fe]}),t[68]=be,t[69]=fe,t[70]=je):je=t[70];let Se;t[71]===Symbol.for("react.memo_cache_sentinel")?(Se=r.jsx(dr,{}),t[71]=Se):Se=t[71];let Ae;t[72]===Symbol.for("react.memo_cache_sentinel")?(Ae=r.jsx(Jy,{}),t[72]=Ae):Ae=t[72];let Ie;t[73]!==x?(Ie=r.jsx(Qt,{children:r.jsxs(kt,{onClick:x,children:[Ae,"Settings"]})}),t[73]=x,t[74]=Ie):Ie=t[74];let Re;t[75]!==a||t[76]!==g?(Re=lt("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(dr,{}),r.jsx(Qt,{children:r.jsxs(kt,{variant:"destructive",onClick:g,disabled:a,children:[r.jsx(Yy,{}),a?"Stopping processes…":"Stop all agent processes"]})})]}),t[75]=a,t[76]=g,t[77]=Re):Re=t[77];let De;t[78]!==je||t[79]!==Ie||t[80]!==Re?(De=r.jsx("div",{className:xe,children:r.jsxs(Dn,{children:[ce,r.jsxs(zn,{align:"end",sideOffset:6,className:"w-64",children:[je,Se,Ie,Re]})]})}),t[78]=je,t[79]=Ie,t[80]=Re,t[81]=De):De=t[81];let Le;t[82]!==le||t[83]!==he||t[84]!==De?(Le=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ae,te,le,de,he,De]}),t[82]=le,t[83]=he,t[84]=De,t[85]=Le):Le=t[85];let ze;t[86]!==ie||t[87]!==Le?(ze=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:[ie,Le]}),t[86]=ie,t[87]=Le,t[88]=ze):ze=t[88];let _e;t[89]!==_||t[90]!==A?(_e=_&&r.jsx(hP,{open:A,onOpenChange:P}),t[89]=_,t[90]=A,t[91]=_e):_e=t[91];let Ce;t[92]!==E?(Ce=r.jsx(vA,{open:E,onOpenChange:T}),t[92]=E,t[93]=Ce):Ce=t[93];let We;return t[94]!==ze||t[95]!==_e||t[96]!==Ce?(We=r.jsxs(r.Fragment,{children:[J,G,ze,_e,Ce]}),t[94]=ze,t[95]=_e,t[96]=Ce,t[97]=We):We=t[97],We});function CP(n){const e=B.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=V(In,"size-8 shrink-0"),e[0]=i):i=e[0];let a;e[1]!==s||e[2]!==o?(a=r.jsx(ee,{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(Et,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(At,{side:"bottom",children:s}),e[9]=s,e[10]=d):d=e[10];let f;return e[11]!==c||e[12]!==d?(f=r.jsxs(Tt,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=f):f=e[13],f}function _P(n){n&&_s.success("Copied network URL")}const TP=y.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(ul,{icon:Co,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(ul,{icon:dn,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(ul,{icon:Qy,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 EP(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=V("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(t3,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Lp(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(e3,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function AP(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=V("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(Zy,{"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 x2=y.createContext(null);function PP(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(x2.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function ou(){const n=y.useContext(x2);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function b2(n){const e=B.c(18),{title:t,icon:s,active:o,onClick:i,children:a}=n,l=o&&"bg-sidebar-primary text-sidebar-primary-foreground hover:bg-sidebar-primary/90 hover:text-sidebar-primary-foreground";let c;e[0]!==l?(c=V("relative rounded-md",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==o||e[3]!==i||e[4]!==c||e[5]!==t?(d=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t,"aria-pressed":o,onClick:i,className:c}),e[2]=o,e[3]=i,e[4]=c,e[5]=t,e[6]=d):d=e[6];let f;e[7]!==s?(f=r.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=f):f=e[8];let u;e[9]!==a||e[10]!==d||e[11]!==f?(u=r.jsxs(Et,{render:d,children:[f,a]}),e[9]=a,e[10]=d,e[11]=f,e[12]=u):u=e[12];let m;e[13]!==t?(m=r.jsx(At,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==u||e[16]!==m?(p=r.jsxs(Tt,{children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17],p}function v2(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function IP(n){const e=B.c(25),{panels:t,context:s,activePanelId:o,onTogglePanel:i,actions:a}=n;let l;e[0]!==a?(l=a===void 0?[]:a,e[0]=a,e[1]=l):l=e[1];const c=l;let d,f,u,m,p,h;if(e[2]!==c||e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==t){h=Symbol.for("react.early_return_sentinel");e:{const x=v2(t,s);if(x.length===0&&c.length===0){h=null;break e}d="Workspace panels",f="electron-no-drag flex w-11 shrink-0 flex-col items-center gap-1 border-l bg-sidebar py-2 text-sidebar-foreground",e[13]!==c?(u=c.map(RP),e[13]=c,e[14]=u):u=e[14],m=c.length>0&&x.length>0&&r.jsx("div",{"aria-hidden":!0,className:"my-1 h-px w-6 bg-sidebar-border"});let b;e[15]!==o||e[16]!==s||e[17]!==i?(b=w=>{var k;const v=w.id===o,j=(k=w.badge)==null?void 0:k.call(w,s),S=w.indicator;return r.jsx(b2,{title:w.title,icon:w.icon,active:v,onClick:()=>i(w.id),children:S?r.jsx(S,{context:s,active:v}):j!=null&&r.jsx(Ee,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:j})},w.id)},e[15]=o,e[16]=s,e[17]=i,e[18]=b):b=e[18],p=x.map(b)}e[2]=c,e[3]=o,e[4]=s,e[5]=i,e[6]=t,e[7]=d,e[8]=f,e[9]=u,e[10]=m,e[11]=p,e[12]=h}else d=e[7],f=e[8],u=e[9],m=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;return e[19]!==d||e[20]!==f||e[21]!==u||e[22]!==m||e[23]!==p?(g=r.jsxs("aside",{"aria-label":d,className:f,children:[u,m,p]}),e[19]=d,e[20]=f,e[21]=u,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function RP(n){return r.jsx(b2,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function $P(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]=y.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]),y.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:V("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 MP(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 OP(n){const e=B.c(24),{children:t,panels:s,context:o,activePanel:i,services:a,onClosePanel:l,onOpenPanel:c,onTogglePanel:d,actions:f}=n;let u;e[0]!==i?(u=i?MP(i.defaultSize):"100%",e[0]=i,e[1]=u):u=e[1];let m;e[2]!==t||e[3]!==u?(m=r.jsx(Lp,{defaultSize:u,minSize:"320px",children:t}),e[2]=t,e[3]=u,e[4]=m):m=e[4];let p;e[5]!==i||e[6]!==o||e[7]!==l||e[8]!==c||e[9]!==s||e[10]!==a?(p=i&&r.jsxs(r.Fragment,{children:[r.jsx(AP,{withHandle:!0}),r.jsx(Lp,{defaultSize:i.defaultSize??"36%",minSize:i.minSize??"300px",maxSize:i.maxSize??"70%",children:r.jsx(PP,{value:a,children:r.jsx($P,{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]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=r.jsxs(EP,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];const g=(i==null?void 0:i.id)??null;let x;e[15]!==f||e[16]!==o||e[17]!==d||e[18]!==s||e[19]!==g?(x=r.jsx(IP,{panels:s,context:o,activePanelId:g,onTogglePanel:d,actions:f}),e[15]=f,e[16]=o,e[17]=d,e[18]=s,e[19]=g,e[20]=x):x=e[20];let b;return e[21]!==h||e[22]!==x?(b=r.jsxs(r.Fragment,{children:[h,x]}),e[21]=h,e[22]=x,e[23]=b):b=e[23],b}const ru={data:null,error:null,loading:!1,refreshing:!1},zp=new Map,DP=8e3,LP=1e4,zP=new Set(["gh_missing","gh_auth_required","no_git_repository","no_github_remote"]);function iu(n){let e=zp.get(n);return e||(e={snapshot:ru,listeners:new Set,request:null,fetchedAt:0},zp.set(n,e)),e}function Ul(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function y2(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 Wl(n,e=!1){const t=iu(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&zP.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<DP))return Ul(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 y2(s);const o=await s.json();t.fetchedAt=Date.now(),Ul(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;Ul(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 FP(n,e){if(!n)return()=>{};const t=iu(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function BP(n){return n?iu(n).snapshot:ru}function w2(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>FP(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>BP(s),t[2]=s,t[3]=i):i=t[3];const a=y.useSyncExternalStore(o,i,UP);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;Wl(s);const m=window.setInterval(()=>{Wl(s)},LP);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]),y.useEffect(l,c);let d;t[8]!==s?(d=()=>s?Wl(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 UP(){return ru}async function WP(n,e){const t=await ye(`/api/github-actions/jobs?cwd=${encodeURIComponent(n)}&runId=${e}`);if(!t.ok)throw await y2(t);return t.json()}const vi=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function qa(n){return n!=="completed"}function Po(n){return n==="action_required"||n==="failure"||n==="startup_failure"||n==="timed_out"}function au(n,e){return qa(n)?"live":Po(e)?"fail":e==="success"?"pass":"quiet"}const Fp={live:0,fail:1,quiet:2,pass:3};function HP(n){return n.reduce((e,t)=>Fp[t]<Fp[e]?t:e,"pass")}const KP={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success",quiet:"bg-border"};function lu(n,e){return n==="in_progress"?"Running":qa(n)?"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 qP(n,e){const t=Date.parse(n);if(!Number.isFinite(t))return"Unknown time";const s=Math.round((t-e)/1e3);if(Math.abs(s)<60)return vi.format(s,"second");const o=Math.round(s/60);if(Math.abs(o)<60)return vi.format(o,"minute");const i=Math.round(o/60);return Math.abs(i)<24?vi.format(i,"hour"):vi.format(Math.round(i/24),"day")}function cu(n,e,t){const s=n?Date.parse(n):Number.NaN;if(!Number.isFinite(s))return null;const o=e?Date.parse(e):t,i=Math.max(0,Math.round((o-s)/1e3));if(i<60)return`${i}s`;const a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function VP(n){const e=B.c(3),[t,s]=y.useState(GP);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function GP(){return Date.now()}function du(n){const e=B.c(14),{status:t,conclusion:s,className:o}=n;let i;e[0]!==s||e[1]!==t?(i=lu(t,s),e[0]=s,e[1]=t,e[2]=i):i=e[2];const a=i;let l,c,d;if(e[3]!==o||e[4]!==s||e[5]!==a||e[6]!==t){d=Symbol.for("react.early_return_sentinel");e:{const u=V("size-3.5 shrink-0",o);if(t==="in_progress"){d=r.jsx(vt,{className:V(u,"text-info"),"aria-label":a});break e}if(qa(t)){d=r.jsx(Cr,{className:V(u,"text-info"),"aria-label":a});break e}if(s==="success"){d=r.jsx(mt,{className:V(u,"text-success"),"aria-label":a});break e}if(Po(s)){d=r.jsx(ct,{className:V(u,"text-destructive"),"aria-label":a});break e}if(s==="skipped"||s==="cancelled"){d=r.jsx(n3,{className:V(u,"text-muted-foreground"),"aria-label":a});break e}l=Gc,c=V(u,"text-muted-foreground")}e[3]=o,e[4]=s,e[5]=a,e[6]=t,e[7]=l,e[8]=c,e[9]=d}else l=e[7],c=e[8],d=e[9];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;return e[10]!==l||e[11]!==a||e[12]!==c?(f=r.jsx(l,{className:c,"aria-label":a}),e[10]=l,e[11]=a,e[12]=c,e[13]=f):f=e[13],f}function YP(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 XP(){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-5 px-3 py-4","aria-label":"Loading workflow runs",children:[0,1,2].map(JP)}),n[0]=e):e=n[0],e}function JP(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(Ot,{className:"h-3.5 w-3/4"}),r.jsx(Ot,{className:"h-2.5 w-1/2"}),r.jsx(Ot,{className:"h-3 w-full"}),r.jsx(Ot,{className:"h-3 w-full"})]},n)}function QP(n){const e=B.c(19),{step:t,now:s}=n;let o,i,a,l;if(e[0]!==t.conclusion||e[1]!==t.status){const u=Po(t.conclusion);o=t.conclusion==="skipped",a="flex min-w-0 items-center gap-2 py-0.5 text-[11px] leading-5",l=r.jsx(du,{status:t.status,conclusion:t.conclusion,className:"size-3"}),i=V("min-w-0 flex-1 truncate",u&&"font-medium text-destructive",o&&"text-muted-foreground"),e[0]=t.conclusion,e[1]=t.status,e[2]=o,e[3]=i,e[4]=a,e[5]=l}else o=e[2],i=e[3],a=e[4],l=e[5];let c;e[6]!==t.name||e[7]!==i?(c=r.jsx("span",{className:i,children:t.name}),e[6]=t.name,e[7]=i,e[8]=c):c=e[8];let d;e[9]!==s||e[10]!==o||e[11]!==t.completedAt||e[12]!==t.startedAt?(d=!o&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:cu(t.startedAt,t.completedAt,s)}),e[9]=s,e[10]=o,e[11]=t.completedAt,e[12]=t.startedAt,e[13]=d):d=e[13];let f;return e[14]!==a||e[15]!==l||e[16]!==c||e[17]!==d?(f=r.jsxs("li",{className:a,children:[l,c,d]}),e[14]=a,e[15]=l,e[16]=c,e[17]=d,e[18]=f):f=e[18],f}function ZP(n){const e=B.c(39),{job:t,now:s}=n;let o;e[0]!==t.conclusion||e[1]!==t.status?(o=au(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=o):o=e[2];const i=o,[a,l]=y.useState(i==="fail"||i==="live");let c;e[3]!==t.completedAt||e[4]!==t.startedAt||e[5]!==s?(c=cu(t.startedAt,t.completedAt,s),e[3]=t.completedAt,e[4]=t.startedAt,e[5]=s,e[6]=c):c=e[6];const d=c,f=t.name;let u;e[7]!==t.conclusion||e[8]!==t.status?(u=lu(t.status,t.conclusion),e[7]=t.conclusion,e[8]=t.status,e[9]=u):u=e[9];const m=`${f}: ${u}`,p=a&&"rotate-90";let h;e[10]!==p?(h=V("size-3 shrink-0 text-muted-foreground transition-transform",p),e[10]=p,e[11]=h):h=e[11];let g;e[12]!==h?(g=r.jsx(Je,{className:h}),e[12]=h,e[13]=g):g=e[13];let x;e[14]!==t.conclusion||e[15]!==t.status?(x=r.jsx(du,{status:t.status,conclusion:t.conclusion}),e[14]=t.conclusion,e[15]=t.status,e[16]=x):x=e[16];const b=i==="fail"&&"text-destructive";let w;e[17]!==b?(w=V("min-w-0 flex-1 truncate",b),e[17]=b,e[18]=w):w=e[18];let v;e[19]!==t.name||e[20]!==w?(v=r.jsx("span",{className:w,children:t.name}),e[19]=t.name,e[20]=w,e[21]=v):v=e[21];let j;e[22]!==d?(j=d&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:d}),e[22]=d,e[23]=j):j=e[23];let S;e[24]!==v||e[25]!==j||e[26]!==m||e[27]!==g||e[28]!==x?(S=r.jsxs(Wt,{className:"flex w-full min-w-0 items-center gap-2 rounded-sm py-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":m,children:[g,x,v,j]}),e[24]=v,e[25]=j,e[26]=m,e[27]=g,e[28]=x,e[29]=S):S=e[29];let k;e[30]!==t.steps||e[31]!==s?(k=t.steps.length>0&&r.jsx("ul",{className:"ml-[5px] border-l border-border pl-4",children:t.steps.map(_=>r.jsx(QP,{step:_,now:s},_.number))}),e[30]=t.steps,e[31]=s,e[32]=k):k=e[32];let C;e[33]!==k?(C=r.jsx(ft,{children:k}),e[33]=k,e[34]=C):C=e[34];let N;return e[35]!==a||e[36]!==S||e[37]!==C?(N=r.jsxs(ut,{open:a,onOpenChange:l,children:[S,C]}),e[35]=a,e[36]=S,e[37]=C,e[38]=N):N=e[38],N}const eI={data:null,error:null,loading:!1};function tI(n){var G,J,Q;const e=B.c(78),{run:t,projectPath:s,now:o}=n,[i,a]=y.useState(!1),[l,c]=y.useState(eI);let d;e[0]!==t.conclusion||e[1]!==t.status?(d=au(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=d):d=e[2];const f=d,u=f==="live";let m;e[3]!==l.loading||e[4]!==s||e[5]!==t.id?(m=async function(){if(!l.loading){c(nI);try{const Z=await WP(s,t.id);c({data:Z,error:null,loading:!1})}catch(Z){const ne=Z;c({data:null,error:{error:typeof ne.error=="string"?ne.error:"Unable to load workflow jobs",code:ne.code??"github_api_failed"},loading:!1})}}},e[3]=l.loading,e[4]=s,e[5]=t.id,e[6]=m):m=e[6];const p=m;let h;e[7]!==u||e[8]!==l.data||e[9]!==p?(h=function(Z){a(Z),Z&&(!l.data||u)&&p()},e[7]=u,e[8]=l.data,e[9]=p,e[10]=h):h=e[10];const g=h;let x;e[11]!==((G=l.data)==null?void 0:G.jobs)?(x=((J=l.data)==null?void 0:J.jobs)??[],e[11]=(Q=l.data)==null?void 0:Q.jobs,e[12]=x):x=e[12];const b=x,w=u?null:t.updatedAt;let v;e[13]!==o||e[14]!==t.createdAt||e[15]!==w?(v=cu(t.createdAt,w,o),e[13]=o,e[14]=t.createdAt,e[15]=w,e[16]=v):v=e[16];const j=v,S=t.name,k=t.runNumber;let C;e[17]!==t.conclusion||e[18]!==t.status?(C=lu(t.status,t.conclusion),e[17]=t.conclusion,e[18]=t.status,e[19]=C):C=e[19];const N=`${S} #${k}: ${C}`;let _;e[20]!==t.conclusion||e[21]!==t.status?(_=r.jsx(du,{status:t.status,conclusion:t.conclusion}),e[20]=t.conclusion,e[21]=t.status,e[22]=_):_=e[22];const A=f==="quiet"&&"text-muted-foreground";let P;e[23]!==A?(P=V("min-w-0 truncate",A),e[23]=A,e[24]=P):P=e[24];let E;e[25]!==t.name||e[26]!==P?(E=r.jsx("span",{className:P,children:t.name}),e[25]=t.name,e[26]=P,e[27]=E):E=e[27];let T;e[28]!==t.runNumber?(T=r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",t.runNumber]}),e[28]=t.runNumber,e[29]=T):T=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("span",{className:"min-w-0 flex-1"}),e[30]=I):I=e[30];let $;e[31]!==t.branch?($=r.jsx("span",{className:"max-w-24 truncate font-mono text-[10px] text-muted-foreground",children:t.branch}),e[31]=t.branch,e[32]=$):$=e[32];let R;e[33]!==u||e[34]!==j?(R=j&&r.jsx("span",{className:V("w-14 shrink-0 text-right font-mono text-[10px] tabular-nums",u?"text-info":"text-muted-foreground"),children:j}),e[33]=u,e[34]=j,e[35]=R):R=e[35];let M;e[36]!==i||e[37]!==N||e[38]!==_||e[39]!==E||e[40]!==T||e[41]!==$||e[42]!==R?(M=r.jsxs(Wt,{className:"flex h-7 min-w-0 flex-1 items-center gap-2 rounded-sm px-1 text-left text-xs outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":N,"aria-expanded":i,children:[_,E,T,I,$,R]}),e[36]=i,e[37]=N,e[38]=_,e[39]=E,e[40]=T,e[41]=$,e[42]=R,e[43]=M):M=e[43];const D=`Open ${t.name} #${t.runNumber} on GitHub`;let O;e[44]!==t.url?(O=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[44]=t.url,e[45]=O):O=e[45];let L;e[46]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(_o,{}),e[46]=L):L=e[46];let F;e[47]!==D||e[48]!==O?(F=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/run:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":D,onClick:O,children:L}),e[47]=D,e[48]=O,e[49]=F):F=e[49];let z;e[50]!==M||e[51]!==F?(z=r.jsxs("div",{className:"group/run flex items-center gap-1 pr-1",children:[M,F]}),e[50]=M,e[51]=F,e[52]=z):z=e[52];let W;e[53]!==l.data||e[54]!==l.loading?(W=l.loading&&!l.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(vt,{className:"size-3"}),"Loading jobs"]}),e[53]=l.data,e[54]=l.loading,e[55]=W):W=e[55];let U;e[56]!==l.error?(U=l.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:l.error.error}),e[56]=l.error,e[57]=U):U=e[57];let H;e[58]!==b.length||e[59]!==l.data||e[60]!==l.error||e[61]!==l.loading?(H=!l.loading&&!l.error&&l.data&&b.length===0&&r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"GitHub reported no jobs for this run."}),e[58]=b.length,e[59]=l.data,e[60]=l.error,e[61]=l.loading,e[62]=H):H=e[62];let K;if(e[63]!==b||e[64]!==o){let X;e[66]!==o?(X=Z=>r.jsx(ZP,{job:Z,now:o},Z.id),e[66]=o,e[67]=X):X=e[67],K=b.map(X),e[63]=b,e[64]=o,e[65]=K}else K=e[65];let q;e[68]!==W||e[69]!==U||e[70]!==H||e[71]!==K?(q=r.jsx(ft,{children:r.jsxs("div",{className:"ml-[7px] border-l border-border py-1 pl-3 pr-1",children:[W,U,H,K]})}),e[68]=W,e[69]=U,e[70]=H,e[71]=K,e[72]=q):q=e[72];let Y;return e[73]!==g||e[74]!==i||e[75]!==z||e[76]!==q?(Y=r.jsxs(ut,{open:i,onOpenChange:g,children:[z,q]}),e[73]=g,e[74]=i,e[75]=z,e[76]=q,e[77]=Y):Y=e[77],Y}function nI(n){return{...n,error:null,loading:!0}}function sI(n){const e=new Map;for(const s of n){const o=s.commitSha||`run-${s.id}`,i=e.get(o);if(i){i.runs.push(s),s.createdAt>i.createdAt&&(i.createdAt=s.createdAt);continue}e.set(o,{sha:s.commitSha,title:s.displayTitle,actor:s.actor,createdAt:s.createdAt,runs:[s],tone:"pass"})}const t=[...e.values()];for(const s of t)s.tone=HP(s.runs.map(o=>au(o.status,o.conclusion)));return t.sort((s,o)=>{const i=s.tone==="live"?0:1,a=o.tone==="live"?0:1;return i-a||o.createdAt.localeCompare(s.createdAt)})}function oI(n){const e=B.c(41),{group:t,projectPath:s,now:o}=n,i=t.title,a=KP[t.tone];let l;e[0]!==a?(l=V("absolute inset-y-1 left-0 w-0.5 rounded-full",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx("span",{"aria-hidden":!0,className:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t.title?(d=r.jsx("h3",{className:"truncate text-[13px] font-medium leading-5",title:t.title,children:t.title}),e[4]=t.title,e[5]=d):d=e[5];let f;e[6]!==t.sha?(f=t.sha&&r.jsx("span",{className:"font-mono",children:t.sha.slice(0,7)}),e[6]=t.sha,e[7]=f):f=e[7];let u;e[8]!==t.actor?(u=t.actor&&r.jsx("span",{className:"truncate",children:t.actor}),e[8]=t.actor,e[9]=u):u=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("span",{className:"shrink-0",children:"·"}),e[10]=m):m=e[10];const p=t.createdAt;let h;e[11]!==t.createdAt?(h=new Date(t.createdAt).toLocaleString(),e[11]=t.createdAt,e[12]=h):h=e[12];let g;e[13]!==t.createdAt||e[14]!==o?(g=qP(t.createdAt,o),e[13]=t.createdAt,e[14]=o,e[15]=g):g=e[15];let x;e[16]!==t.createdAt||e[17]!==h||e[18]!==g?(x=r.jsx("time",{className:"shrink-0",dateTime:p,title:h,children:g}),e[16]=t.createdAt,e[17]=h,e[18]=g,e[19]=x):x=e[19];let b;e[20]!==x||e[21]!==f||e[22]!==u?(b=r.jsxs("p",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[f,u,m,x]}),e[20]=x,e[21]=f,e[22]=u,e[23]=b):b=e[23];let w;e[24]!==b||e[25]!==d?(w=r.jsxs("header",{className:"mb-1 min-w-0",children:[d,b]}),e[24]=b,e[25]=d,e[26]=w):w=e[26];let v;if(e[27]!==t.runs||e[28]!==o||e[29]!==s){let k;e[31]!==o||e[32]!==s?(k=C=>r.jsx(tI,{run:C,projectPath:s,now:o},C.id),e[31]=o,e[32]=s,e[33]=k):k=e[33],v=t.runs.map(k),e[27]=t.runs,e[28]=o,e[29]=s,e[30]=v}else v=e[30];let j;e[34]!==v?(j=r.jsx("div",{className:"-ml-1 flex flex-col",children:v}),e[34]=v,e[35]=j):j=e[35];let S;return e[36]!==t.title||e[37]!==w||e[38]!==j||e[39]!==c?(S=r.jsxs("article",{className:"relative pl-3","aria-label":i,children:[c,w,j]}),e[36]=t.title,e[37]=w,e[38]=j,e[39]=c,e[40]=S):S=e[40],S}function rI(n){var l;const e=B.c(6),{context:t}=n,{data:s}=w2(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.runs)?(o=(s==null?void 0:s.runs.filter(iI).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?Po(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 iI(n){return qa(n.status)}function aI(n,e,t){return e==="branch"?n.filter(s=>s.branch===t):e==="failed"?n.filter(s=>Po(s.conclusion)):[...n]}function lI(n){const e=B.c(20),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.branch||e[1]!==t.runs||e[2]!==s?(i=aI(t.runs,s,t.branch),e[0]=t.branch,e[1]=t.runs,e[2]=s,e[3]=i):i=e[3];const a=i;let l;e[4]!==a?(l=sI(a),e[4]=a,e[5]=l):l=e[5];const c=l;let d;e[6]!==c?(d=c.some(cI),e[6]=c,e[7]=d):d=e[7];const f=VP(d);if(t.runs.length===0){let p;return e[8]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(un,{className:"border-0",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(ma,{})}),r.jsx(mn,{children:"No workflow runs yet"}),r.jsx(Tn,{children:"Push a commit that triggers a workflow and it will show up here."})]})}),e[8]=p):p=e[8],p}if(c.length===0){const p=s==="failed"?"Nothing failed in the latest runs.":`No recent runs on ${t.branch}.`;let h;return e[9]!==p?(h=r.jsx("p",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:p}),e[9]=p,e[10]=h):h=e[10],h}let u;if(e[11]!==c||e[12]!==f||e[13]!==o){let p;e[15]!==f||e[16]!==o?(p=h=>r.jsx(oI,{group:h,projectPath:o,now:f},h.sha||h.runs[0].id),e[15]=f,e[16]=o,e[17]=p):p=e[17],u=c.map(p),e[11]=c,e[12]=f,e[13]=o,e[14]=u}else u=e[14];let m;return e[18]!==u?(m=r.jsx(Vs,{className:"min-h-0 flex-1",children:r.jsx("div",{className:"flex flex-col gap-5 px-3 py-3",children:u})}),e[18]=u,e[19]=m):m=e[19],m}function cI(n){return n.tone==="live"}function dI(n){const e=B.c(49),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=w2(t.projectPath,s),[f,u]=y.useState("all"),m=t.projectPath;let p;e[0]!==(i==null?void 0:i.runs)?(p=(i==null?void 0:i.runs)??[],e[0]=i==null?void 0:i.runs,e[1]=p):p=e[1];const h=p;let g;e[2]!==h?(g=h.filter(uI),e[2]=h,e[3]=g):g=e[3];const x=g.length,b=(i==null?void 0:i.branch)??null;let w;e[4]!==b||e[5]!==h?(w=b?h.filter(O=>O.branch===b).length:0,e[4]=b,e[5]=h,e[6]=w):w=e[6];const v=w,j=f==="branch"&&!b||f==="failed"&&x===0?"all":f;let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"GitHub Actions"}),e[7]=S):S=e[7];let k;e[8]!==i?(k=r.jsxs("div",{className:"min-w-0 flex-1",children:[S,i?r.jsxs("a",{href:`${i.repositoryUrl}/actions`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:i.repository}),r.jsx(_o,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Current repository"})]}),e[8]=i,e[9]=k):k=e[9];let C;e[10]!==d?(C=()=>{d()},e[10]=d,e[11]=C):C=e[11];const N=l||c||!m;let _;e[12]!==c?(_=c?r.jsx(vt,{}):r.jsx(Dt,{}),e[12]=c,e[13]=_):_=e[13];let A;e[14]!==C||e[15]!==N||e[16]!==_?(A=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:C,disabled:N,"aria-label":"Refresh GitHub Actions",children:_}),e[14]=C,e[15]=N,e[16]=_,e[17]=A):A=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(ct,{}),e[18]=P):P=e[18];let E;e[19]!==o?(E=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close GitHub Actions",children:P}),e[19]=o,e[20]=E):E=e[20];let T;e[21]!==E||e[22]!==k||e[23]!==A?(T=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[k,A,E]}),e[21]=E,e[22]=k,e[23]=A,e[24]=T):T=e[24];let I;e[25]!==b||e[26]!==v||e[27]!==i||e[28]!==j||e[29]!==x||e[30]!==h.length?(I=i&&i.runs.length>0&&r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-3 py-1.5",role:"group","aria-label":"Filter runs",children:[r.jsxs(Rs,{pressed:j==="all",onClick:()=>u("all"),children:["All",r.jsx($s,{children:h.length})]}),b&&r.jsxs(Rs,{pressed:j==="branch",disabled:v===0,onClick:()=>u("branch"),"aria-label":`Only runs on ${b}`,children:[r.jsx(Us,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:b}),r.jsx($s,{children:v})]}),r.jsxs(Rs,{pressed:j==="failed",disabled:x===0,onClick:()=>u("failed"),children:[r.jsx("span",{className:V(x>0&&"text-destructive"),children:"Failed"})," ",r.jsx($s,{children:x})]})]}),e[25]=b,e[26]=v,e[27]=i,e[28]=j,e[29]=x,e[30]=h.length,e[31]=I):I=e[31];let $;e[32]!==i||e[33]!==l?($=l&&!i&&r.jsx(XP,{}),e[32]=i,e[33]=l,e[34]=$):$=e[34];let R;e[35]!==i||e[36]!==a||e[37]!==d?(R=a&&!i&&r.jsx("div",{className:"p-3",children:r.jsxs(St,{variant:"destructive",children:[r.jsx(sn,{}),r.jsx(It,{children:a.error}),r.jsxs(Nt,{className:"flex flex-col items-start gap-2",children:[r.jsx("span",{children:YP(a)}),r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},children:[r.jsx(Dt,{"data-icon":"inline-start"}),"Try again"]})]})]})}),e[35]=i,e[36]=a,e[37]=d,e[38]=R):R=e[38];let M;e[39]!==i||e[40]!==j||e[41]!==m?(M=i&&m&&r.jsx(lI,{data:i,filter:j,projectPath:m}),e[39]=i,e[40]=j,e[41]=m,e[42]=M):M=e[42];let D;return e[43]!==T||e[44]!==I||e[45]!==$||e[46]!==R||e[47]!==M?(D=r.jsxs("section",{className:"flex size-full min-h-0 flex-col","aria-label":"GitHub Actions panel",children:[T,I,$,R,M]}),e[43]=T,e[44]=I,e[45]=$,e[46]=R,e[47]=M,e[48]=D):D=e[48],D}function uI(n){return Po(n.conclusion)}const fI={id:"github-actions",workspacePanels:[{id:"runs",title:"GitHub Actions",icon:ma,component:dI,indicator:rI,order:40,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},uu={data:null,error:null,loading:!1,refreshing:!1},Bp=new Map,mI=8e3,pI=1e4,hI=new Set(["vercel_access_denied","vercel_auth_required","vercel_cli_too_old","vercel_missing","vercel_project_unlinked"]);function fu(n){let e=Bp.get(n);return e||(e={snapshot:uu,listeners:new Set,request:null,fetchedAt:0},Bp.set(n,e)),e}function Hl(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function j2(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`Vercel request failed (${n.status})`,code:"vercel_api_failed"}}async function Kl(n,e=!1){const t=fu(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&hI.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<mI))return Hl(t,{...t.snapshot,error:null,loading:t.snapshot.data===null,refreshing:t.snapshot.data!==null}),t.request=ye(`/api/vercel-deployments?cwd=${encodeURIComponent(n)}&limit=20`).then(async s=>{if(!s.ok)throw await j2(s);const o=await s.json();t.fetchedAt=Date.now(),Hl(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;Hl(t,{...t.snapshot,error:{error:typeof o.error=="string"?o.error:"Unable to load Vercel deployments",code:typeof o.code=="string"?o.code:"vercel_api_failed"},loading:!1,refreshing:!1})}).finally(()=>{t.request=null}),t.request}function gI(n,e){if(!n)return()=>{};const t=fu(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function xI(n){return n?fu(n).snapshot:uu}function S2(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>gI(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>xI(s),t[2]=s,t[3]=i):i=t[3];const a=y.useSyncExternalStore(o,i,bI);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;Kl(s);const m=window.setInterval(()=>{Kl(s)},pI);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]),y.useEffect(l,c);let d;t[8]!==s?(d=()=>s?Kl(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 bI(){return uu}async function vI(n,e){const t=await ye(`/api/vercel-deployments/build-logs?cwd=${encodeURIComponent(n)}&deploymentId=${encodeURIComponent(e)}&limit=200`);if(!t.ok)throw await j2(t);return t.json()}const yI={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success"};function qr(n){return n==="BUILDING"||n==="INITIALIZING"||n==="QUEUED"}function Va(n){return n==="BLOCKED"||n==="CANCELED"||n==="ERROR"}function ko(n){return n.target==="production"}function N2(n){return qr(n)?"live":Va(n)?"fail":"pass"}function mu(n){return n==="READY"?"Ready":n==="BUILDING"?"Building":n==="INITIALIZING"?"Initializing":n==="QUEUED"?"Queued":n==="CANCELED"?"Canceled":n==="BLOCKED"?"Blocked":"Failed"}function k2(n,e){const t=Math.floor((e-n)/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 wI(n,e){const t=n.buildingAt??n.createdAt,s=n.readyAt??(qr(n.state)?e:null);if(s===null)return null;const o=Math.max(0,Math.round((s-t)/1e3));if(o<60)return`${o}s`;const i=Math.floor(o/60);return i<60?`${i}m ${o%60}s`:`${Math.floor(i/60)}h ${i%60}m`}function jI(n){const e=B.c(3),[t,s]=y.useState(SI);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function SI(){return Date.now()}function pu(n){if(!n)return null;try{return new URL(n).host}catch{return null}}function Ec(n){return n.commitMessage.split(`
125
+ `)[0]||pu(n.url)||`${mu(n.state)} deployment`}function NI(n){return[n.errorCode,n.errorMessage].filter(Boolean).join(": ")||null}function C2(n){const e=B.c(12),{state:t,className:s}=n;let o;e[0]!==t?(o=mu(t),e[0]=t,e[1]=o):o=e[1];const i=o;let a,l,c;if(e[2]!==s||e[3]!==i||e[4]!==t){c=Symbol.for("react.early_return_sentinel");e:{const f=V("size-3.5 shrink-0",s);if(t==="BUILDING"){c=r.jsx(vt,{className:V(f,"text-info"),"aria-label":i});break e}if(t==="INITIALIZING"||t==="QUEUED"){c=r.jsx(Cr,{className:V(f,"text-info"),"aria-label":i});break e}if(t==="READY"){c=r.jsx(mt,{className:V(f,"text-success"),"aria-label":i});break e}if(t==="BLOCKED"){c=r.jsx(s3,{className:V(f,"text-destructive"),"aria-label":i});break e}a=ct,l=V(f,"text-destructive")}e[2]=s,e[3]=i,e[4]=t,e[5]=a,e[6]=l,e[7]=c}else a=e[5],l=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[8]!==a||e[9]!==i||e[10]!==l?(d=r.jsx(a,{className:l,"aria-label":i}),e[8]=a,e[9]=i,e[10]=l,e[11]=d):d=e[11],d}function kI(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("span",{className:"shrink-0 rounded-sm border border-foreground/25 px-1 font-mono text-[9px] uppercase leading-[14px] tracking-wide text-foreground/80",children:"prod"}),n[0]=e):e=n[0],e}function CI(n){return n.code==="vercel_missing"?"Install Vercel CLI on the Cogpit host, then refresh.":n.code==="vercel_cli_too_old"?"Update Vercel CLI to 50.5.1 or newer, then refresh.":n.code==="vercel_auth_required"?"Run `vercel login` on the Cogpit host, then refresh.":n.code==="vercel_project_unlinked"?"Run `vercel link` from this exact project root.":n.code==="vercel_access_denied"?"Sign in to an account with access to the linked Vercel project.":"Check the linked project and your Vercel access, then try again."}function _I(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-4 px-3 py-4","aria-label":"Loading Vercel deployments",children:[r.jsxs("div",{className:"flex flex-col gap-2 rounded-md border px-3 py-2.5",children:[r.jsx(Ot,{className:"h-2.5 w-16"}),r.jsx(Ot,{className:"h-3.5 w-3/4"}),r.jsx(Ot,{className:"h-2.5 w-1/2"})]}),[0,1,2,3].map(TI)]}),n[0]=e):e=n[0],e}function TI(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(Ot,{className:"h-3.5 w-4/5"}),r.jsx(Ot,{className:"h-2.5 w-1/2"})]},n)}const EI={data:null,error:null,loading:!1};function AI(n){const e=B.c(5),{logs:t}=n;if(t.events.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"Vercel reported no build output."}),e[0]=i):i=e[0],i}let s;e[1]!==t.events?(s=t.events.map(PI),e[1]=t.events,e[2]=s):s=e[2];let o;return e[3]!==s?(o=r.jsx("div",{className:"max-h-64 overflow-auto rounded-md bg-muted/50 px-2 py-1.5 font-mono text-[10px] leading-4",children:s}),e[3]=s,e[4]=o):o=e[4],o}function PI(n){return r.jsxs("div",{className:V("flex gap-2",n.type==="stderr"&&"text-destructive"),children:[r.jsx("time",{className:"shrink-0 text-muted-foreground tabular-nums",dateTime:new Date(n.createdAt).toISOString(),children:new Date(n.createdAt).toLocaleTimeString([],{hour12:!1})}),r.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words",children:n.text})]},n.id)}function Up(n){const e=B.c(6),{href:t,children:s}=n;let o;e[0]!==s?(o=r.jsx("span",{className:"truncate",children:s}),e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(_o,{className:"size-3 shrink-0"}),e[2]=i):i=e[2];let a;return e[3]!==t||e[4]!==o?(a=r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-w-0 items-center gap-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[o,i]}),e[3]=t,e[4]=o,e[5]=a):a=e[5],a}function II(n){const e=B.c(106),{deployment:t,projectPath:s,now:o}=n,[i,a]=y.useState(!1),[l,c]=y.useState(EI);let d;e[0]!==t.state?(d=N2(t.state),e[0]=t.state,e[1]=d):d=e[1];const f=d;let u;e[2]!==t||e[3]!==o?(u=wI(t,o),e[2]=t,e[3]=o,e[4]=u):u=e[4];const m=u;let p;e[5]!==t?(p=Ec(t),e[5]=t,e[6]=p):p=e[6];const h=p;let g;e[7]!==t?(g=NI(t),e[7]=t,e[8]=g):g=e[8];const x=g;let b;e[9]!==t.url?(b=pu(t.url),e[9]=t.url,e[10]=b):b=e[10];const w=b;let v;e[11]!==t.id||e[12]!==l.loading||e[13]!==s?(v=async function(){if(!l.loading){c(RI);try{const le=await vI(s,t.id);c({data:le,error:null,loading:!1})}catch(le){const he=le;c({data:null,error:{error:typeof he.error=="string"?he.error:"Unable to load build output",code:he.code??"vercel_api_failed"},loading:!1})}}},e[11]=t.id,e[12]=l.loading,e[13]=s,e[14]=v):v=e[14];const j=v;let S;e[15]!==t.state||e[16]!==j||e[17]!==l.data?(S=function(le){a(le),le&&(!l.data||qr(t.state))&&j()},e[15]=t.state,e[16]=j,e[17]=l.data,e[18]=S):S=e[18];const k=S,C=yI[f];let N;e[19]!==C?(N=V("absolute inset-y-1 left-0 w-0.5 rounded-full",C),e[19]=C,e[20]=N):N=e[20];let _;e[21]!==N?(_=r.jsx("span",{"aria-hidden":!0,className:N}),e[21]=N,e[22]=_):_=e[22];let A;e[23]!==t.state?(A=mu(t.state),e[23]=t.state,e[24]=A):A=e[24];const P=`${h}: ${A}`;let E;e[25]!==t.state?(E=r.jsx(C2,{state:t.state}),e[25]=t.state,e[26]=E):E=e[26];const T=f==="fail"&&"text-destructive";let I;e[27]!==T?(I=V("min-w-0 flex-1 truncate text-xs font-medium",T),e[27]=T,e[28]=I):I=e[28];let $;e[29]!==I||e[30]!==h?($=r.jsx("span",{className:I,children:h}),e[29]=I,e[30]=h,e[31]=$):$=e[31];let R;e[32]!==t?(R=ko(t)&&r.jsx(kI,{}),e[32]=t,e[33]=R):R=e[33];let M;e[34]!==t.createdAt||e[35]!==o?(M=k2(t.createdAt,o),e[34]=t.createdAt,e[35]=o,e[36]=M):M=e[36];let D;e[37]!==M?(D=r.jsx("span",{className:"w-7 shrink-0 text-right font-mono text-[10px] text-muted-foreground tabular-nums",children:M}),e[37]=M,e[38]=D):D=e[38];let O;e[39]!==E||e[40]!==$||e[41]!==R||e[42]!==D?(O=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[E,$,R,D]}),e[39]=E,e[40]=$,e[41]=R,e[42]=D,e[43]=O):O=e[43];let L;e[44]!==t.branch?(L=t.branch&&r.jsx("span",{className:"min-w-0 truncate",children:t.branch}),e[44]=t.branch,e[45]=L):L=e[45];let F;e[46]!==t.commitSha?(F=t.commitSha&&r.jsx("span",{className:"shrink-0",children:t.commitSha.slice(0,7)}),e[46]=t.commitSha,e[47]=F):F=e[47];let z;e[48]!==t.branch||e[49]!==t.commitSha?(z=!t.branch&&!t.commitSha&&r.jsx("span",{className:"min-w-0 truncate",children:"deployed from CLI"}),e[48]=t.branch,e[49]=t.commitSha,e[50]=z):z=e[50];let W;e[51]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx("span",{className:"min-w-0 flex-1"}),e[51]=W):W=e[51];let U;e[52]!==m||e[53]!==f?(U=m&&r.jsx("span",{className:V("shrink-0 tabular-nums",f==="live"&&"text-info"),children:m}),e[52]=m,e[53]=f,e[54]=U):U=e[54];let H;e[55]!==L||e[56]!==F||e[57]!==z||e[58]!==U?(H=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2 pl-[22px] font-mono text-[10px] leading-4 text-muted-foreground",children:[L,F,z,W,U]}),e[55]=L,e[56]=F,e[57]=z,e[58]=U,e[59]=H):H=e[59];let K;e[60]!==x?(K=x&&r.jsx("span",{className:"w-full min-w-0 truncate pl-[22px] text-[11px] leading-4 text-destructive",title:x,children:x}),e[60]=x,e[61]=K):K=e[61];let q;e[62]!==i||e[63]!==P||e[64]!==O||e[65]!==H||e[66]!==K?(q=r.jsxs(Wt,{className:"flex min-w-0 flex-1 flex-col gap-0.5 rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":P,"aria-expanded":i,children:[O,H,K]}),e[62]=i,e[63]=P,e[64]=O,e[65]=H,e[66]=K,e[67]=q):q=e[67];let Y;e[68]!==t.url||e[69]!==h?(Y=t.url&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"mt-0.5 size-6 text-muted-foreground opacity-0 transition-opacity group-hover/deployment:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":`Open ${h}`,onClick:()=>window.open(t.url??"","_blank","noopener,noreferrer"),children:r.jsx(_o,{})}),e[68]=t.url,e[69]=h,e[70]=Y):Y=e[70];let G;e[71]!==q||e[72]!==Y?(G=r.jsxs("div",{className:"flex items-start gap-1",children:[q,Y]}),e[71]=q,e[72]=Y,e[73]=G):G=e[73];let J;e[74]!==t.url||e[75]!==w?(J=t.url&&w&&r.jsx(Up,{href:t.url,children:w}),e[74]=t.url,e[75]=w,e[76]=J):J=e[76];let Q;e[77]!==t.inspectorUrl?(Q=t.inspectorUrl&&r.jsx(Up,{href:t.inspectorUrl,children:"Inspect on Vercel"}),e[77]=t.inspectorUrl,e[78]=Q):Q=e[78];let X;e[79]!==t.creator?(X=t.creator&&r.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["by ",t.creator]}),e[79]=t.creator,e[80]=X):X=e[80];let Z;e[81]!==J||e[82]!==Q||e[83]!==X?(Z=r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[J,Q,X]}),e[81]=J,e[82]=Q,e[83]=X,e[84]=Z):Z=e[84];let se;e[85]!==l.data||e[86]!==l.loading?(se=l.loading&&!l.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(vt,{className:"size-3"}),"Loading build output"]}),e[85]=l.data,e[86]=l.loading,e[87]=se):se=e[87];let ne;e[88]!==l.error?(ne=l.error&&r.jsx("p",{className:"text-[11px] text-destructive",children:l.error.error}),e[88]=l.error,e[89]=ne):ne=e[89];let re;e[90]!==l.data?(re=l.data&&r.jsx(AI,{logs:l.data}),e[90]=l.data,e[91]=re):re=e[91];let ie;e[92]!==Z||e[93]!==se||e[94]!==ne||e[95]!==re?(ie=r.jsx(ft,{children:r.jsxs("div",{className:"ml-[7px] flex flex-col gap-2 border-l border-border py-2 pl-4 pr-1",children:[Z,se,ne,re]})}),e[92]=Z,e[93]=se,e[94]=ne,e[95]=re,e[96]=ie):ie=e[96];let ae;e[97]!==_||e[98]!==G||e[99]!==ie||e[100]!==h?(ae=r.jsxs("article",{className:"group/deployment relative pl-3","aria-label":h,children:[_,G,ie]}),e[97]=_,e[98]=G,e[99]=ie,e[100]=h,e[101]=ae):ae=e[101];let te;return e[102]!==k||e[103]!==i||e[104]!==ae?(te=r.jsx(ut,{open:i,onOpenChange:k,children:ae}),e[102]=k,e[103]=i,e[104]=ae,e[105]=te):te=e[105],te}function RI(n){return{...n,error:null,loading:!0}}function $I(n){const e=n.filter(ko),t=e.find(i=>i.state==="READY")??null,s=e[0]??null,o=s&&s!==t&&s.state!=="READY"?s:null;return{live:t,pending:o}}function MI(n){const e=B.c(11),{deployments:t,now:s}=n;let o,i;if(e[0]!==t||e[1]!==s){i=Symbol.for("react.early_return_sentinel");e:{const{live:a,pending:l}=$I(t),c=a??l;if(!c){i=null;break e}const d=Ec(c),f=pu(c.url),u=l?N2(l.state):null,m=a?"border-success/30 bg-success/[0.05]":"border-destructive/30 bg-destructive/[0.05]";let p;e[4]!==m?(p=V("mx-3 mt-3 rounded-md border px-3 py-2.5",m),e[4]=m,e[5]=p):p=e[5];const h=a?"bg-success":"bg-destructive";let g;e[6]!==h?(g=V("size-1.5 rounded-full",h),e[6]=h,e[7]=g):g=e[7];let x;e[8]!==g?(x=r.jsx("span",{"aria-hidden":!0,className:g}),e[8]=g,e[9]=x):x=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("span",{className:"min-w-0 flex-1"}),e[10]=b):b=e[10],o=r.jsxs("section",{"aria-label":"Production",className:p,children:[r.jsxs("p",{className:"mb-1 flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:[x,a?"Live on production":"Production is down",r.jsx("span",{className:"ml-auto font-mono normal-case tracking-normal tabular-nums",children:k2(c.readyAt??c.createdAt,s)})]}),r.jsx("h3",{className:"truncate text-[13px] font-medium leading-5",title:d,children:d}),r.jsxs("p",{className:"mt-0.5 flex min-w-0 items-center gap-2 font-mono text-[10px] text-muted-foreground",children:[c.branch&&r.jsx("span",{className:"truncate",children:c.branch}),c.commitSha&&r.jsx("span",{className:"shrink-0",children:c.commitSha.slice(0,7)}),b,c.url&&f&&r.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-w-0 max-w-[60%] items-center gap-0.5 font-sans text-[11px] text-foreground/80 outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:f}),r.jsx(_o,{className:"size-3 shrink-0"})]})]}),a&&l&&u&&r.jsxs("p",{className:V("mt-1.5 flex items-center gap-1.5 border-t border-border/60 pt-1.5 text-[11px]",u==="fail"?"text-destructive":"text-info"),children:[r.jsx(C2,{state:l.state,className:"size-3"}),r.jsxs("span",{className:"min-w-0 truncate",children:[u==="fail"?"Newer production deploy failed":"Newer production deploy in progress"," · ",Ec(l)]})]})]})}e[0]=t,e[1]=s,e[2]=o,e[3]=i}else o=e[2],i=e[3];return i!==Symbol.for("react.early_return_sentinel")?i:o}function OI(n,e){return e==="failed"?n.filter(t=>Va(t.state)):e==="production"?n.filter(ko):e==="preview"?n.filter(t=>!ko(t)):[...n]}function DI(n){const e=B.c(17),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.deployments||e[1]!==s?(i=OI(t.deployments,s),e[0]=t.deployments,e[1]=s,e[2]=i):i=e[2];const a=i;let l;e[3]!==t.deployments?(l=t.deployments.some(LI),e[3]=t.deployments,e[4]=l):l=e[4];const c=jI(l);if(t.deployments.length===0){let m;return e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(un,{className:"border-0",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(Xh,{})}),r.jsx(mn,{children:"No deployments yet"}),r.jsx(Tn,{children:"New Vercel deployments for this linked project will show up here."})]})}),e[5]=m):m=e[5],m}let d;e[6]!==t.deployments||e[7]!==c?(d=r.jsx(MI,{deployments:t.deployments,now:c}),e[6]=t.deployments,e[7]=c,e[8]=d):d=e[8];let f;e[9]!==a||e[10]!==s||e[11]!==c||e[12]!==o?(f=a.length===0?r.jsxs("p",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:["No recent ",s," deployments."]}):r.jsx("div",{className:"flex flex-col gap-3 px-3 py-3",children:a.map(m=>r.jsx(II,{deployment:m,projectPath:o,now:c},m.id))}),e[9]=a,e[10]=s,e[11]=c,e[12]=o,e[13]=f):f=e[13];let u;return e[14]!==d||e[15]!==f?(u=r.jsxs(Vs,{className:"min-h-0 flex-1",children:[d,f]}),e[14]=d,e[15]=f,e[16]=u):u=e[16],u}function LI(n){return qr(n.state)}function zI(n){const e=B.c(6),{context:t}=n,{data:s}=S2(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.deployments)?(o=(s==null?void 0:s.deployments.filter(FI).length)??0,e[0]=s==null?void 0:s.deployments,e[1]=o):o=e[1];const i=o,a=s!=null&&s.deployments[0]?Va(s.deployments[0].state):!1;if(i>0){const l=`${i} active Vercel deployment${i===1?"":"s"}`;let c;return e[2]!==i||e[3]!==l?(c=r.jsx(Ee,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":l,children:i}),e[2]=i,e[3]=l,e[4]=c):c=e[4],c}if(a){let l;return e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ee,{variant:"destructive",className:"absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]","aria-label":"Latest Vercel deployment failed",children:"!"}),e[5]=l):l=e[5],l}return null}function FI(n){return qr(n.state)}function BI(n){const e=B.c(57),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=S2(t.projectPath,s),[f,u]=y.useState("all"),m=t.projectPath;let p;e[0]!==(i==null?void 0:i.deployments)?(p=(i==null?void 0:i.deployments)??[],e[0]=i==null?void 0:i.deployments,e[1]=p):p=e[1];const h=p,g=h.length;let x;e[2]!==h?(x=h.filter(ko),e[2]=h,e[3]=x):x=e[3];const b=x.length;let w;e[4]!==h?(w=h.filter(WI),e[4]=h,e[5]=w):w=e[5];const v=w.length;let j;e[6]!==h?(j=h.filter(UI),e[6]=h,e[7]=j):j=e[7];let S;e[8]!==h.length||e[9]!==x.length||e[10]!==w.length||e[11]!==j.length?(S={all:g,production:b,preview:v,failed:j.length},e[8]=h.length,e[9]=x.length,e[10]=w.length,e[11]=j.length,e[12]=S):S=e[12];const k=S,C=f!=="all"&&k[f]===0?"all":f;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"Vercel Deployments"}),e[13]=N):N=e[13];let _;e[14]!==i?(_=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,i!=null&&i.projectUrl?r.jsxs("a",{href:i.projectUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-0.5 truncate text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:underline",children:[r.jsx("span",{className:"truncate",children:i.projectName}),r.jsx(_o,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Project linked at the session root"})]}),e[14]=i,e[15]=_):_=e[15];let A;e[16]!==d?(A=()=>{d()},e[16]=d,e[17]=A):A=e[17];const P=l||c||!m;let E;e[18]!==c?(E=c?r.jsx(vt,{}):r.jsx(Dt,{}),e[18]=c,e[19]=E):E=e[19];let T;e[20]!==A||e[21]!==P||e[22]!==E?(T=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:A,disabled:P,"aria-label":"Refresh Vercel deployments",children:E}),e[20]=A,e[21]=P,e[22]=E,e[23]=T):T=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(ct,{}),e[24]=I):I=e[24];let $;e[25]!==o?($=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close Vercel deployments",children:I}),e[25]=o,e[26]=$):$=e[26];let R;e[27]!==_||e[28]!==T||e[29]!==$?(R=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[_,T,$]}),e[27]=_,e[28]=T,e[29]=$,e[30]=R):R=e[30];let M;e[31]!==k||e[32]!==i||e[33]!==C?(M=i&&i.deployments.length>0&&r.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-3 py-1.5",role:"group","aria-label":"Filter deployments",children:[r.jsxs(Rs,{pressed:C==="all",onClick:()=>u("all"),children:["All ",r.jsx($s,{children:k.all})]}),r.jsxs(Rs,{pressed:C==="production",disabled:k.production===0,onClick:()=>u("production"),children:["Production ",r.jsx($s,{children:k.production})]}),r.jsxs(Rs,{pressed:C==="preview",disabled:k.preview===0,onClick:()=>u("preview"),children:["Preview ",r.jsx($s,{children:k.preview})]}),r.jsxs(Rs,{pressed:C==="failed",disabled:k.failed===0,onClick:()=>u("failed"),children:[r.jsx("span",{className:V(k.failed>0&&"text-destructive"),children:"Failed"})," ",r.jsx($s,{children:k.failed})]})]}),e[31]=k,e[32]=i,e[33]=C,e[34]=M):M=e[34];let D;e[35]!==i||e[36]!==l?(D=l&&!i&&r.jsx(_I,{}),e[35]=i,e[36]=l,e[37]=D):D=e[37];let O;e[38]!==i||e[39]!==a||e[40]!==d?(O=a&&!i&&r.jsx("div",{className:"p-3",children:r.jsxs(St,{variant:"destructive",children:[r.jsx(sn,{}),r.jsx(It,{children:a.error}),r.jsxs(Nt,{className:"flex flex-col items-start gap-2",children:[r.jsx("span",{children:CI(a)}),r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},children:[r.jsx(Dt,{"data-icon":"inline-start"}),"Try again"]})]})]})}),e[38]=i,e[39]=a,e[40]=d,e[41]=O):O=e[41];let L;e[42]!==i||e[43]!==C||e[44]!==m?(L=i&&m&&r.jsx(DI,{data:i,filter:C,projectPath:m}),e[42]=i,e[43]=C,e[44]=m,e[45]=L):L=e[45];let F;e[46]!==i||e[47]!==a||e[48]!==l?(F=!l&&!i&&!a&&r.jsx(un,{className:"border-0",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(Hs,{})}),r.jsx(mn,{children:"Select a project session"})]})}),e[46]=i,e[47]=a,e[48]=l,e[49]=F):F=e[49];let z;return e[50]!==R||e[51]!==M||e[52]!==D||e[53]!==O||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex size-full min-h-0 flex-col","aria-label":"Vercel deployments panel",children:[R,M,D,O,L,F]}),e[50]=R,e[51]=M,e[52]=D,e[53]=O,e[54]=L,e[55]=F,e[56]=z):z=e[56],z}function UI(n){return Va(n.state)}function WI(n){return!ko(n)}const HI={id:"vercel-deployments",workspacePanels:[{id:"deployments",title:"Vercel Deployments",icon:Xh,component:BI,indicator:zI,order:45,defaultSize:"42%",minSize:"380px",maxSize:"68%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},KI=[fI,HI],Ac=new Map;let ql=null,Vl=null;async function qI(){try{const n=await ye("/api/usage-cost/rates");if(!n.ok)return Ac;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return Ac}}function _2(){const[n,e]=y.useState(ql??Ac);return y.useEffect(()=>{if(ql!==null)return;let t=!0;return Vl??(Vl=qI().then(s=>(s.size>0&&(ql=s),Vl=null,s))),Vl.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function VI(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=$w(t),f=Mw(t),u=Math.max(d+f,((x=t.tokenUsage)==null?void 0:x.output_tokens)??0),m=t.tokenUsage?g2(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 GI(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 YI(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,v=s-4;let j;e[15]!==w||e[16]!==v?(j=r.jsx("text",{x:w,y:v,className:"fill-muted-foreground text-xs",children:"Think"}),e[15]=w,e[16]=v,e[17]=j):j=e[17];const S=t+155,k=s-7;let C;e[18]!==S||e[19]!==k?(C=r.jsx("circle",{cx:S,cy:k,r:2,fill:"var(--warning)",opacity:.8}),e[18]=S,e[19]=k,e[20]=C):C=e[20];const N=t+162,_=s-4;let A;e[21]!==N||e[22]!==_?(A=r.jsx("text",{x:N,y:_,className:"fill-muted-foreground text-xs",children:"Agent"}),e[21]=N,e[22]=_,e[23]=A):A=e[23];let P;return e[24]!==h||e[25]!==b||e[26]!==j||e[27]!==i||e[28]!==C||e[29]!==A||e[30]!==c||e[31]!==u?(P=r.jsxs(r.Fragment,{children:[i,c,u,h,b,j,C,A]}),e[24]=h,e[25]=b,e[26]=j,e[27]=i,e[28]=C,e[29]=A,e[30]=c,e[31]=u,e[32]=P):P=e[32],P}function XI(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 v;e[6]!==l||e[7]!==i||e[8]!==s||e[9]!==d||e[10]!==u?(v=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]=v):v=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 S;e[18]!==o||e[19]!==a||e[20]!==m||e[21]!==p||e[22]!==s||e[23]!==d?(S=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]=S):S=e[24];let k;e[25]!==o||e[26]!==a||e[27]!==m||e[28]!==p||e[29]!==s||e[30]!==d||e[31]!==h?(k=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]=k):k=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 N;e[39]!==o||e[40]!==a||e[41]!==s||e[42]!==d||e[43]!==g||e[44]!==x?(N=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]=N):N=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 A;return e[51]!==f||e[52]!==w||e[53]!==v||e[54]!==j||e[55]!==S||e[56]!==k||e[57]!==C||e[58]!==N||e[59]!==_?(A=r.jsxs("g",{onMouseEnter:f,style:b,children:[w,v,j,S,k,C,N,_]}),e[51]=f,e[52]=w,e[53]=v,e[54]=j,e[55]=S,e[56]=k,e[57]=C,e[58]=N,e[59]=_,e[60]=A):A=e[60],A}const T2=280,Pc=130,Ii=16,JI=22,Es=36,QI=8,yi=T2-Es-QI,Wp=Pc-Ii-JI;function ZI(n){const e=B.c(34),{turns:t}=n,[s,o]=y.useState(null),i=_2();let a;e[0]!==i||e[1]!==t?(a=VI(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(tR),...l.map(eR)),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,yi/l.length)),u=Math.max(2,(f-1)/2),m=Ii+Wp,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(GI,{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:Es-4,y:Ii,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:b}),e[11]=b,e[12]=w):w=e[12];let v,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("text",{x:Es-4,y:m,textAnchor:"end",dominantBaseline:"central",className:"fill-muted-foreground text-xs",children:"0"}),j=r.jsx("line",{x1:Es,y1:m,x2:Es+yi,y2:m,stroke:"var(--border)",strokeWidth:.5}),e[13]=v,e[14]=j):(v=e[13],j=e[14]);let S;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?(_=(A,P)=>{const E=Es+(l.length===1?(yi-f)/2:P/(l.length-1)*(yi-f));return r.jsx(XI,{data:A,groupX:E,barW:u,groupW:f,baseY:m,chartH:Wp,maxVal:d,isHovered:s===P,onHover:()=>o(P),padTop:Ii},P)},e[21]=u,e[22]=l.length,e[23]=f,e[24]=s,e[25]=d,e[26]=_):_=e[26],S=l.map(_),e[15]=u,e[16]=l,e[17]=f,e[18]=s,e[19]=d,e[20]=S}else S=e[20];let k;e[27]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(YI,{padLeft:Es,svgHeight:Pc}),e[27]=k):k=e[27];let C;e[28]!==S||e[29]!==w?(C=r.jsxs("svg",{width:"100%",viewBox:`0 0 ${T2} ${Pc}`,onMouseLeave:x,children:[w,v,j,S,k]}),e[28]=S,e[29]=w,e[30]=C):C=e[30];let N;return e[31]!==C||e[32]!==g?(N=r.jsxs("section",{className:"relative",children:[h,g,C]}),e[31]=C,e[32]=g,e[33]=N):N=e[33],N}function eR(n){return n.totalOutput}function tR(n){return n.totalInput}const Hp=280,Kp=32;function nR(n){const e=B.c(19),{turns:t}=n,[s,o]=y.useState(null);let i;e[0]!==t?(i=Math.max(1,...t.map(sR)),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,Hp/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(Hp,c)} ${Kp}`;let u;if(e[3]!==a||e[4]!==l||e[5]!==t){let g;e[7]!==a||e[8]!==l?(g=(x,b)=>{const v=.1+x.toolCalls.length/a*.9;return r.jsx("rect",{x:b*l,y:0,width:l-1,height:Kp,rx:2,fill:"var(--foreground)",opacity:v,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 sR(n){return n.toolCalls.length}function oR(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(iR),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(rR),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 rR(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 iR(n,e){const[,t]=n,[,s]=e;return s-t}const aR=["agent","skill","plugin","mcpServer","mcpTool"],lR={agent:"Agents",skill:"Skills",plugin:"Plugins",mcpServer:"MCP servers",mcpTool:"MCP tools"},wi="Unattributed";function qp(n){return n.inputTokens+n.outputTokens}function cR(n,e){var i;const t=new Map;for(const a of n){const l=((i=a.attribution)==null?void 0:i[e])??wi;let c=t.get(l);c||(c={name:l,turns:0,inputTokens:0,outputTokens:0,isUnattributed:l===wi},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(wi);s&&t.delete(wi);const o=[...t.values()].sort((a,l)=>qp(l)-qp(a));return s&&o.push(s),o}function dR(n){return aR.filter(e=>n.some(t=>{var s;return(s=t.attribution)==null?void 0:s[e]}))}function uR(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 v;e[13]!==w?(v=r.jsx("span",{children:w}),e[13]=w,e[14]=v):v=e[14];let j;e[15]!==v||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,v]}),e[15]=v,e[16]=x,e[17]=j):j=e[17];let S;e[18]!==j||e[19]!==h?(S=r.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[h,j]}),e[18]=j,e[19]=h,e[20]=S):S=e[20];const k=t.isUnattributed?"rounded-xs bg-info/35":"rounded-xs bg-info/85",C=`${a*100}%`;let N;e[21]!==C?(N={width:C},e[21]=C,e[22]=N):N=e[22];let _;e[23]!==k||e[24]!==N?(_=r.jsx("div",{className:k,style:N}),e[23]=k,e[24]=N,e[25]=_):_=e[25];const A=t.isUnattributed?"rounded-xs bg-success/35":"rounded-xs bg-success/70",P=`${l*100}%`;let E;e[26]!==P?(E={width:P},e[26]=P,e[27]=E):E=e[27];let T;e[28]!==A||e[29]!==E?(T=r.jsx("div",{className:A,style:E}),e[28]=A,e[29]=E,e[30]=T):T=e[30];let I;e[31]!==_||e[32]!==T?(I=r.jsxs("div",{className:"mt-1.5 flex h-1 gap-[2px]","aria-hidden":"true",children:[_,T]}),e[31]=_,e[32]=T,e[33]=I):I=e[33];let $;return e[34]!==S||e[35]!==I||e[36]!==m?($=r.jsxs("li",{className:"rounded-md border bg-card px-2.5 py-1.5",title:m,children:[S,I]}),e[34]=S,e[35]=I,e[36]=m,e[37]=$):$=e[37],$}function fR(){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 mR(n){const e=B.c(25),{turns:t}=n;let s;e[0]!==t?(s=dR(t),e[0]=t,e[1]=s):s=e[1];const o=s,[i,a]=y.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?cR(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(hR)),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(E0,{"aria-label":"Attribution dimension",value:[c],onValueChange:v=>{const j=v[0];typeof j=="string"&&a(j)},variant:"outline",size:"sm",className:"mb-2 flex-wrap",children:o.map(pR)}),e[11]=c,e[12]=o,e[13]=h):h=e[13];let g;if(e[14]!==f||e[15]!==m){let v;e[17]!==m?(v=j=>r.jsx(uR,{bucket:j,maxTotal:m},j.name),e[17]=m,e[18]=v):v=e[18],g=f.map(v),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(fR,{}),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 pR(n){return r.jsx(A0,{value:n,children:lR[n]},n)}function hR(n){return n.inputTokens+n.outputTokens}function gR(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 xR(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=gR(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(ee,{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 Vp(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||Kd(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(Yn,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(Ks,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(Gc,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=w):w=e[7];const v=w,j=a?"bg-accent":"hover:bg-muted/40";let S;e[8]!==j?(S=V("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]=S):S=e[9];let k;e[10]!==g?(k=r.jsx(Ee,{variant:"outline",children:g}),e[10]=g,e[11]=k):k=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 N;e[14]!==a?(N=a&&r.jsx(Ee,{children:"Viewing"}),e[14]=a,e[15]=N):N=e[15];const _=c==="running"?"active":c;let A;e[16]!==_?(A=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:_}),e[16]=_,e[17]=A):A=e[17];let P;e[18]!==v||e[19]!==A||e[20]!==k||e[21]!==C||e[22]!==N?(P=r.jsxs("div",{className:"flex items-center gap-1.5",children:[v,k,C,N,A]}),e[18]=v,e[19]=A,e[20]=k,e[21]=C,e[22]=N,e[23]=P):P=e[23];let E;e[24]!==i?(E=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=E):E=e[25];let T;e[26]!==b||e[27]!==f?(T=(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(Cr,{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(ia,{className:"size-2.5","data-icon":"inline-start"}),f," tools"]})]}),e[26]=b,e[27]=f,e[28]=T):T=e[28];let I;e[29]!==u||e[30]!==m||e[31]!==P||e[32]!==E||e[33]!==T?(I=r.jsxs(ee,{type:"button",variant:"ghost",onClick:m,disabled:u,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[P,E,T]}),e[29]=u,e[30]=m,e[31]=P,e[32]=E,e[33]=T,e[34]=I):I=e[34];let $;e[35]!==g||e[36]!==p?($=p&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(ct,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=$):$=e[37];let R;return e[38]!==I||e[39]!==$||e[40]!==S?(R=r.jsxs("div",{className:S,children:[I,$]}),e[38]=I,e[39]=$,e[40]=S,e[41]=R):R=e[41],R}function bR(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 Ic(n){return n.split(`
126
+ `).map(e=>e.trim()).find(Boolean)??""}function vR(n){return n.name==="Task"||n.name==="Agent"}function yR(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=bR(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:Ic(((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(!vR(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:Ic(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 wR({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=Wd(),i=y.useMemo(()=>{if(!e)return null;const w=xs(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=y.useMemo(()=>yR(n,o),[n,o]),l=y.useRef(a);y.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=y.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=y.useMemo(()=>d?t.filter(w=>w.parentSessionId===d):t,[t,d]),u=y.useMemo(()=>new Map(c.map(w=>[w.agentId,w])),[c]),m=y.useMemo(()=>{const w=new Set(f.map(v=>v.agentId));return c.filter(v=>!w.has(v.agentId))},[f,c]),p=y.useMemo(()=>[...f].sort((w,v)=>v.modifiedAt-w.modifiedAt),[f]),h=y.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(ee,{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,v)=>{const j=Ic(w.preview??""),S=u.get(w.agentId);return r.jsx(Vp,{agentId:w.agentId,subagentType:(S==null?void 0:S.subagentType)??null,agentName:(S==null?void 0:S.agentName)??null,preview:(S==null?void 0:S.preview)||(j!==w.agentId?j:""),colorIndex:v,isViewing:b===w.agentId,isBackground:!0,status:w.isActive?"running":(S==null?void 0:S.status)==="failed"?"failed":"done",durationMs:S==null?void 0:S.durationMs,toolUseCount:S==null?void 0:S.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,v)=>{const j=!!s&&!!d&&!!e&&!w.agentId.startsWith("tool:");return r.jsx(Vp,{agentId:w.agentId,subagentType:w.subagentType,agentName:w.agentName,preview:w.preview,colorIndex:p.length+v,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 jR(n,e){return`${n.id}-${e}`}function SR(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=y.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=Ma(u.userMessage),h=o===m;return r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>{i(m),s==null||s(m)},className:V("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?vn(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})})]},jR(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 NR(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"?vn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?vn(e.query,40):e.url&&typeof e.url=="string"?vn(e.url,40):vn(_7(n),40)}function kR(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:g2(e,t.model,s)/t.toolCalls.length})}function CR(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=Fa(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 _R(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=_2();let i;e[0]!==o||e[1]!==t?(i=kR(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=CR(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(ut,{children:[r.jsxs(Wt,{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(ft,{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:v}=x,j=NR(w);return r.jsx("div",{children:r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(v,w.id),className:V("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(kn,{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 TR(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Lt(),{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(ua,{"data-icon":"inline-start"}):r.jsx(da,{"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(ee,{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=v=>o({type:"SET_SEARCH_QUERY",value:v.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(Nn,{align:"inline-start",children:r.jsx(dn,{})}),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 E2=y.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}=Lt(),{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=V("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(TR,{searchInputRef:l}),t[2]=l,t[3]=w):w=t[3];const v=u?"p-4":"p-3";let j;t[4]!==v?(j=V(v),t[4]=v,t[5]=j):j=t[5];let S;t[6]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(s1,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(Uo,{value:"activity",children:"Activity"}),r.jsx(Uo,{value:"agents",children:"Agents"}),r.jsx(Uo,{value:"metrics",children:"Metrics"}),r.jsx(Uo,{value:"issues",children:"Issues"})]}),t[6]=S):S=t[6];let k;t[7]!==o||t[8]!==g?(k=r.jsxs(Wo,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(SR,{turns:g,onJumpToTurn:o}),r.jsx(_R,{turns:g,onJumpToTurn:o})]}),t[7]=o,t[8]=g,t[9]=k):k=t[9];let C;t[10]!==a||t[11]!==i||t[12]!==h.cwd||t[13]!==g?(C=r.jsx(a1,{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 N;t[15]!==d?(N=d??[],t[15]=d,t[16]=N):N=t[16];let _;t[17]!==c||t[18]!==h||t[19]!==p||t[20]!==N?(_=r.jsx(wR,{session:h,sessionSource:p,bgAgents:N,onLoadSession:c}),t[17]=c,t[18]=h,t[19]=p,t[20]=N,t[21]=_):_=t[21];let A;t[22]!==_||t[23]!==C?(A=r.jsxs(Wo,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[C,_]}),t[22]=_,t[23]=C,t[24]=A):A=t[24];let P;t[25]!==g?(P=r.jsxs(Wo,{value:"metrics",className:"flex flex-col gap-6 pt-3",children:[r.jsx(ZI,{turns:g}),r.jsx(nR,{turns:g}),r.jsx(oR,{turns:g}),r.jsx(mR,{turns:g})]}),t[25]=g,t[26]=P):P=t[26];let E;t[27]!==o||t[28]!==g?(E=r.jsx(Wo,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(xR,{turns:g,onJumpToTurn:o})}),t[27]=o,t[28]=g,t[29]=E):E=t[29];let T;t[30]!==A||t[31]!==P||t[32]!==E||t[33]!==j||t[34]!==k?(T=r.jsxs(n1,{defaultValue:"activity",className:j,children:[S,k,A,P,E]}),t[30]=A,t[31]=P,t[32]=E,t[33]=j,t[34]=k,t[35]=T):T=t[35];let I;return t[36]!==T||t[37]!==b||t[38]!==w?(I=r.jsxs("aside",{className:b,children:[w,T]}),t[36]=T,t[37]=b,t[38]=w,t[39]=I):I=t[39],I}),ER=y.lazy(()=>qe(()=>import("./ProjectFilesPanel-DppuIFEt.js"),__vite__mapDeps([30,1,31,2,3,4])).then(n=>({default:n.ProjectFilesPanel}))),AR=y.lazy(()=>qe(()=>import("./WorktreePanel-CcSLupr7.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function A2(){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(vt,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function PR(n){const e=B.c(6),{context:t,closePanel:s}=n,o=ou(),i=o.projectFilesRoot??t.projectPath;if(!i)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(A2,{}),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(y.Suspense,{fallback:a,children:r.jsx(ER,{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 IR(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(nE,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function RR(){const n=B.c(7),e=ou();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(E2,{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}function $R(n){const e=B.c(8),{closePanel:t}=n,s=ou();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(A2,{}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(i=r.jsx(y.Suspense,{fallback:o,children:r.jsx(AR,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=i):i=e[7],i}const MR={id:Go,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:Us,component:$R,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:o3,component:PR,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"file-changes",title:"File changes",icon:_r,component:IR,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:r3,component:RR,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},OR=k9([MR,...KI]);function Ga(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:va(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 DR(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=V(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 LR(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=V("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 Gp(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=V("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 zR(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=Oh,s="a",o=Mh({className:V("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 FR(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=V("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 BR(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=V("[&>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 I2(n){const e=B.c(51),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l}=n,[c,d]=y.useState(!1),[f,u]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),u(!0),requestAnimationFrame(()=>{var W;return(W=h.current)==null?void 0:W.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(Da,{render:b,children:t}),e[3]=t,e[4]=w):w=e[4];let v;e[5]!==i||e[6]!==l||e[7]!==x?(v=(l||i)&&r.jsxs(ho,{children:[l&&r.jsxs(en,{onClick:x,children:[r.jsx(Ws,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(en,{onClick:i,children:[r.jsx(Cn,{"data-icon":"inline-start"}),"Duplicate session"]})]}),e[5]=i,e[6]=l,e[7]=x,e[8]=v):v=e[8];let j;e[9]!==a||e[10]!==i||e[11]!==l?(j=a&&r.jsxs(r.Fragment,{children:[(i||l)&&r.jsx(br,{}),r.jsx(ho,{children:r.jsxs(en,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(aa,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[9]=a,e[10]=i,e[11]=l,e[12]=j):j=e[12];let S;e[13]!==v||e[14]!==j?(S=r.jsxs(La,{className:"min-w-44",children:[v,j]}),e[13]=v,e[14]=j,e[15]=S):S=e[15];let k;e[16]!==w||e[17]!==S?(k=r.jsxs(Oa,{children:[w,S]}),e[16]=w,e[17]=S,e[18]=k):k=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(fd,{children:"Delete session?"}),e[19]=C):C=e[19];let N;e[20]!==s?(N=r.jsxs(dd,{children:[C,r.jsxs(md,{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]=N):N=e[21];let _;e[22]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(hd,{size:"sm",children:"Cancel"}),e[22]=_):_=e[22];let A;e[23]!==a?(A=r.jsxs(ud,{children:[_,r.jsx(pd,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),d(!1)},children:"Delete"})]}),e[23]=a,e[24]=A):A=e[24];let P;e[25]!==A||e[26]!==N?(P=r.jsxs(cd,{children:[N,A]}),e[25]=A,e[26]=N,e[27]=P):P=e[27];let E;e[28]!==c||e[29]!==P?(E=r.jsx(ld,{open:c,onOpenChange:d,children:P}),e[28]=c,e[29]=P,e[30]=E):E=e[30];let T;e[31]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsxs(Ss,{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]=T):T=e[31];let I;e[32]!==l||e[33]!==m?(I=z=>{z.preventDefault(),l==null||l(m),u(!1)},e[32]=l,e[33]=m,e[34]=I):I=e[34];let $;e[35]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(bt,{htmlFor:"session-rename",children:"Session name"}),e[35]=$):$=e[35];let R;e[36]===Symbol.for("react.memo_cache_sentinel")?(R=z=>p(z.target.value),e[36]=R):R=e[36];let M;e[37]!==m||e[38]!==s?(M=r.jsxs(xt,{children:[$,r.jsx(Bt,{id:"session-rename",ref:h,value:m,onChange:R,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=M):M=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsxs(zg,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[40]=D):D=e[40];let O;e[41]!==I||e[42]!==M?(O=r.jsxs(Qn,{className:"sm:max-w-md",children:[T,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:I,children:[M,D]})]}),e[41]=I,e[42]=M,e[43]=O):O=e[43];let L;e[44]!==f||e[45]!==O?(L=r.jsx(Jn,{open:f,onOpenChange:u,children:O}),e[44]=f,e[45]=O,e[46]=L):L=e[46];let F;return e[47]!==E||e[48]!==L||e[49]!==k?(F=r.jsxs(r.Fragment,{children:[k,E,L]}),e[47]=E,e[48]=L,e[49]=k,e[50]=F):F=e[50],F}const R2="session-custom-names";function $2(){try{const n=localStorage.getItem(Ut(R2));return n?JSON.parse(n):{}}catch{return{}}}function UR(n){localStorage.setItem(Ut(R2),JSON.stringify(n))}let Qi=$2();const Zi=new Set;if(typeof window<"u"){const n=()=>{Qi=$2();for(const e of Zi)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function WR(n){return Zi.add(n),()=>{Zi.delete(n)}}function HR(){return Qi}function Rc(n,e){const t={...Qi},s=e.trim();s?t[n]=s:delete t[n],UR(t),Qi=t;for(const o of Zi)o()}function M2(){const n=B.c(2),e=y.useSyncExternalStore(WR,HR);let t;return n[0]!==e?(t={names:e,rename:Rc},n[0]=e,n[1]=t):t=n[1],t}function O2(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(Nn,{children:a?r.jsx(rt,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(dn,{"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(Nn,{align:"inline-end",children:r.jsx(Dr,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(ct,{})})}),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 D2(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(kn,{"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(Nt,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Dt,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(vs,{children:r.jsxs(ee,{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 L2(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(Rt,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(Ot,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(Ot,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(Ot,{className:"h-3 w-72 max-w-full"}),r.jsx(Ot,{className:"h-3 w-52 max-w-full"})]}),r.jsx(Ot,{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 jr(n){return n==="idle"||n==="completed"}function hu(n){return jr(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"},KR=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,qR=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,VR=/(?:^|\s)#(\d+)(?=\s|$)/,GR=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function ji(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function YR(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 z2(n){const e=n.trim();if(!e)return null;const t=KR.exec(e);if(t){const l=ji(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=qR.exec(e);if(s){const l=ji(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=VR.exec(e);if(o){const l=ji(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:YR(c)}}const i=GR.exec(e);if(!i)return null;const a=ji(i[1]);return a===null?null:{number:a,repoHint:null}}function Yp(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function XR(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 JR(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Yp(n.repo,s):Yp(n.repo,s)?!0:t.some(o=>XR(o,s)):!0}function F2(n,e,t=[]){var i;const s=z2(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>JR(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 QR=120*1e3;function B2(n){return n?Date.now()-new Date(n).getTime()<QR:!1}function U2(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?vn(s,70):vn(n.sessionId,16)}function Xp(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function ZR(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Xp(t)===Xp(e)?null:vn(t,220)}function e$(n,e){return F2(n,e)}function t$(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Mn(t):null}function n$(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(`
127
+ `)}function s$(n){var t;const e=n.cwd?(t=ya(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:i3,label:e,title:n.cwd}:n.gitBranch?{icon:Us,label:n.gitBranch}:null}function o$(n,e){return n.agentStatus==="deferred"?"attention":e?jr(n.agentStatus)?"idle":"working":null}function r$(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=jr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=Hr(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=hu(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=V("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=Qd(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 Gl(n){const e=B.c(9),{icon:t,title:s,className:o,children:i}=n;let a;e[0]!==o?(a=V("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 i$(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=B2(i),l=o$(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,v,j,S,k,C;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const M=s$(t);let D;e[25]!==i||e[26]!==t.timestamp?(D=t$(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=D):D=e[27];const O=D,L=t.turnCount??0;let F,z;e[28]!==s||e[29]!==t?(z=U2(t,s),F=ZR(t,z),e[28]=s,e[29]=t,e[30]=F,e[31]=z):(F=e[30],z=e[31]);const W=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=n$(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(jf,{className:"size-4"}),e[34]=U):U=e[34];let H;e[35]!==c?(H=c&&r.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:V("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Ms[c])}),e[35]=c,e[36]=H):H=e[36],e[37]!==H?(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,H]}),e[37]=H,e[38]=h):h=e[38],S="flex min-w-0 flex-1 flex-col gap-1";let K;e[39]!==z?(K=r.jsx("span",{className:"truncate text-sm font-medium",children:z}),e[39]=z,e[40]=K):K=e[40];let q;e[41]!==d?(q=d&&r.jsxs(Ee,{variant:"outline",className:"shrink-0",children:[r.jsx(go,{"data-icon":"inline-start"}),vn(d,18)]}),e[41]=d,e[42]=q):q=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(Yc,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let G;e[45]!==a||e[46]!==t?(G=r.jsx(r$,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=G):G=e[47];let J;e[48]!==i?(J=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Ir(i)}),e[48]=i,e[49]=J):J=e[49];let Q;e[50]!==G||e[51]!==J?(Q=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[G,J]}),e[50]=G,e[51]=J,e[52]=Q):Q=e[52],e[53]!==K||e[54]!==q||e[55]!==Y||e[56]!==Q?(k=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[K,q,Y,Q]}),e[53]=K,e[54]=q,e[55]=Y,e[56]=Q,e[57]=k):k=e[57],e[58]!==W?(C=W&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:W}),e[58]=W,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:Pr(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==L?(w=L>0&&r.jsxs(Gl,{icon:jf,children:[L," ",L===1?"turn":"turns"]}),e[62]=L,e[63]=w):w=e[63],e[64]!==O?(v=O&&r.jsx(Gl,{icon:Os,title:"First prompt to last activity",children:O}),e[64]=O,e[65]=v):v=e[65],j=M&&r.jsx(Gl,{icon:M.icon,className:"max-w-40 truncate",title:M.title,children:vn(M.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]=v,e[21]=j,e[22]=S,e[23]=k,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],v=e[20],j=e[21],S=e[22],k=e[23],C=e[24];let N;e[66]!==t.size?(N=jg(t.size),e[66]=t.size,e[67]=N):N=e[67];let _;e[68]!==N?(_=r.jsx("span",{children:N}),e[68]=N,e[69]=_):_=e[69];let A;e[70]!==_||e[71]!==x||e[72]!==b||e[73]!==w||e[74]!==v||e[75]!==j?(A=r.jsxs("span",{className:x,children:[b,w,v,j,_]}),e[70]=_,e[71]=x,e[72]=b,e[73]=w,e[74]=v,e[75]=j,e[76]=A):A=e[76];let P;e[77]!==A||e[78]!==S||e[79]!==k||e[80]!==C?(P=r.jsxs("span",{className:S,children:[k,C,A]}),e[77]=A,e[78]=S,e[79]=k,e[80]=C,e[81]=P):P=e[81];let E;e[82]!==f||e[83]!==u||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==P?(E=r.jsxs("button",{type:f,onClick:u,title:m,className:p,children:[h,P]}),e[82]=f,e[83]=u,e[84]=m,e[85]=p,e[86]=h,e[87]=P,e[88]=E):E=e[88];let T;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(T=t.matchedPullRequestNumber?r.jsxs(Ee,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(Ka,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=T):T=e[91];let I;e[92]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Je,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=I):I=e[92];let $;e[93]!==T?($=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[T,I]}),e[93]=T,e[94]=$):$=e[94];let R;return e[95]!==g||e[96]!==E||e[97]!==$?(R=r.jsxs("div",{className:g,children:[E,$]}),e[95]=g,e[96]=E,e[97]=$,e[98]=R):R=e[98],R}function a$(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:v,rename:j}=M2();let S;e[0]!==t.path?(S=qn(t.path),e[0]=t.path,e[1]=S):S=e[1];const k=S;let C;e[2]!==x?(C=r.jsx(Gp,{children:r.jsx(zR,{render:r.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=C):C=e[3];let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(BR,{}),e[4]=N):N=e[4];let _;e[5]!==k?(_=r.jsx(Gp,{className:"min-w-0",children:r.jsx(FR,{className:"truncate",children:k})}),e[5]=k,e[6]=_):_=e[6];let A;e[7]!==C||e[8]!==_?(A=r.jsx(DR,{children:r.jsxs(LR,{children:[C,N,_]})}),e[7]=C,e[8]=_,e[9]=A):A=e[9];let P;e[10]!==k?(P=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:k}),e[10]=k,e[11]=P):P=e[11];let E;e[12]!==o?(E=r.jsx(Ee,{variant:"secondary",children:o}),e[12]=o,e[13]=E):E=e[13];let T;e[14]!==P||e[15]!==E?(T=r.jsxs("div",{className:"flex items-center gap-2",children:[P,E]}),e[14]=P,e[15]=E,e[16]=T):T=e[16];let I;e[17]!==t.path?(I=va(t.path),e[17]=t.path,e[18]=I):I=e[18];let $;e[19]!==I?($=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:I}),e[19]=I,e[20]=$):$=e[20];let R;e[21]!==$||e[22]!==T?(R=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[T,$]}),e[21]=$,e[22]=T,e[23]=R):R=e[23];let M;e[24]!==l||e[25]!==a||e[26]!==c?(M=r.jsx(O2,{value:l,onChange:c,placeholder:"Search sessions or PRs...",loading:a}),e[24]=l,e[25]=a,e[26]=c,e[27]=M):M=e[27];let D;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(D=m&&r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(vt,{"data-icon":"inline-start"}):r.jsx($n,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=D):D=e[32];let O;e[33]!==M||e[34]!==D?(O=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,D]}),e[33]=M,e[34]=D,e[35]=O):O=e[35];let L;e[36]!==f||e[37]!==b?(L=f&&r.jsx(D2,{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]!==v||e[49]!==s||e[50]!==i||e[51]!==o?(F=(i||a)&&d.length===0?r.jsx(L2,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(un,{className:"min-h-72 border",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(fa,{})}),r.jsx(mn,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(Tn,{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,H)=>r.jsxs(y.Fragment,{children:[H>0&&r.jsx(Rt,{}),r.jsx(I2,{sessionLabel:U2(U),customName:v[U.sessionId],onRename:K=>j(U.sessionId,K),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(i$,{session:U,customName:v[U.sessionId],onSelect:()=>u(t.dirName,U.fileName)})})]},U.fileName))}),s.length<o&&!l&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(ee,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(vt,{"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]=v,e[49]=s,e[50]=i,e[51]=o,e[52]=F):F=e[52];let z;e[53]!==O||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[O,L,F]}),e[53]=O,e[54]=L,e[55]=F,e[56]=z):z=e[56];let W;return e[57]!==R||e[58]!==z||e[59]!==A?(W=r.jsx(Vs,{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:[A,R,z]})}),e[57]=R,e[58]=z,e[59]=A,e[60]=W):W=e[60],W}function l$(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=y.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=Ar(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=V("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 W2(n){const e=B.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=y.useState(!1),[d,f]=y.useState(""),u=y.useRef(null);let m;e[0]!==o?(m=function(){f(o||""),c(!0),requestAnimationFrame(()=>{var I;return(I=u.current)==null?void 0:I.select()})},e[0]=o,e[1]=m):m=e[1];const p=m;let h;e[2]!==i?(h=V("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(Da,{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(Ws,{"data-icon":"inline-start"}),e[9]=b):b=e[9];let w;e[10]!==p?(w=r.jsx(La,{className:"min-w-44",children:r.jsx(ho,{children:r.jsxs(en,{onClick:p,children:[b,"Rename project"]})})}),e[10]=p,e[11]=w):w=e[11];let v;e[12]!==x||e[13]!==w?(v=r.jsxs(Oa,{children:[x,w]}),e[12]=x,e[13]=w,e[14]=v):v=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(Ss,{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 S;e[16]!==a||e[17]!==d?(S=T=>{T.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=S):S=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(bt,{htmlFor:"project-rename",children:"Project name"}),e[19]=k):k=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=T=>f(T.target.value),e[20]=C):C=e[20];let N;e[21]!==s||e[22]!==d?(N=r.jsxs(xt,{children:[k,r.jsx(Bt,{id:"project-rename",ref:u,value:d,onChange:C,placeholder:s})]}),e[21]=s,e[22]=d,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(zg,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[24]=_):_=e[24];let A;e[25]!==N||e[26]!==S?(A=r.jsxs(Qn,{className:"sm:max-w-md",children:[j,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:S,children:[N,_]})]}),e[25]=N,e[26]=S,e[27]=A):A=e[27];let P;e[28]!==l||e[29]!==A?(P=r.jsx(Jn,{open:l,onOpenChange:c,children:A}),e[28]=l,e[29]=A,e[30]=P):P=e[30];let E;return e[31]!==P||e[32]!==v?(E=r.jsxs(r.Fragment,{children:[v,P]}),e[31]=P,e[32]=v,e[33]=E):E=e[33],E}const H2="project-custom-names";function K2(){try{const n=localStorage.getItem(Ut(H2));return n?JSON.parse(n):{}}catch{return{}}}function c$(n){localStorage.setItem(Ut(H2),JSON.stringify(n))}let ea=K2();const ta=new Set;if(typeof window<"u"){const n=()=>{ea=K2();for(const e of ta)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function d$(n){return ta.add(n),()=>{ta.delete(n)}}function u$(){return ea}function f$(n,e){const t={...ea},s=e.trim();s?t[n]=s:delete t[n],c$(t),ea=t;for(const o of ta)o()}function q2(){const n=B.c(2),e=y.useSyncExternalStore(d$,u$);let t;return n[0]!==e?(t={names:e,rename:f$},n[0]=e,n[1]=t):t=n[1],t}function m$(n){const e=B.c(45),{projects:t,activeSessions:s,loading:o,refreshing:i,searchFilter:a,setSearchFilter:l,fetchError:c,selectedProjectDirName:d,onSelectProject:f,onRefresh:u}=n;let m;if(e[0]!==s){m={};for(const R of s)B2(R.lastModified)&&(m[R.dirName]=(m[R.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=q2();let x;e:{if(!a){x=t;break e}let R;if(e[2]!==h||e[3]!==t||e[4]!==a){const M=a.toLowerCase();R=t.filter(D=>{var O;return D.path.toLowerCase().includes(M)||D.shortName.toLowerCase().includes(M)||((O=h[D.dirName])==null?void 0:O.toLowerCase().includes(M))}),e[2]=h,e[3]=t,e[4]=a,e[5]=R}else R=e[5];x=R}const b=x;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=w):w=e[6];let v;e[7]!==t.length?(v=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]=v):v=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 S;e[10]!==v?(S=r.jsxs("header",{className:"flex flex-col gap-1",children:[v,j]}),e[10]=v,e[11]=S):S=e[11];let k;e[12]!==a||e[13]!==l?(k=r.jsx(O2,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=k):k=e[14];const C=i&&"animate-spin";let N;e[15]!==C?(N=V(C),e[15]=C,e[16]=N):N=e[16];let _;e[17]!==N?(_=r.jsx(Dt,{"data-icon":"inline-start",className:N}),e[17]=N,e[18]=_):_=e[18];let A;e[19]!==u||e[20]!==i||e[21]!==_?(A=r.jsxs(ee,{variant:"outline",size:"sm",onClick:u,disabled:i,"aria-label":"Refresh projects",children:[_,"Refresh"]}),e[19]=u,e[20]=i,e[21]=_,e[22]=A):A=e[22];let P;e[23]!==A||e[24]!==k?(P=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[k,A]}),e[23]=A,e[24]=k,e[25]=P):P=e[25];let E;e[26]!==c||e[27]!==u||e[28]!==d?(E=c&&!d&&r.jsx(D2,{message:c,onRetry:u}),e[26]=c,e[27]=u,e[28]=d,e[29]=E):E=e[29];let T;e[30]!==p||e[31]!==b||e[32]!==o||e[33]!==f||e[34]!==h||e[35]!==g||e[36]!==a?(T=o?r.jsx(L2,{}):b.length===0?r.jsx(un,{className:"min-h-72 border",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(bo,{})}),r.jsx(mn,{children:a?"No projects match your search":"No projects yet"}),r.jsx(Tn,{children:a?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]})}):r.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:b.map((R,M)=>{const D=p[R.dirName]||0,O=h[R.dirName],L=qw(Ct(R.dirName));return r.jsxs(y.Fragment,{children:[M>0&&r.jsx(Rt,{}),r.jsx(W2,{projectLabel:qn(R.path),customName:O,onRename:F=>g(R.dirName,F),children:r.jsxs("button",{type:"button",onClick:()=>f==null?void 0:f(R.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:r.jsx(l$,{projectPath:R.path,className:"size-4",fallback:r.jsx(bo,{className:"size-4 text-muted-foreground"})})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-medium",children:O||qn(R.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:va(R.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[D>0&&r.jsxs(Ee,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),D," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[R.sessionCount," ",R.sessionCount===1?"session":"sessions"]}),R.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Ir(R.lastModified)}),r.jsx(Je,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},R.dirName)})}),e[30]=p,e[31]=b,e[32]=o,e[33]=f,e[34]=h,e[35]=g,e[36]=a,e[37]=T):T=e[37];let I;e[38]!==P||e[39]!==E||e[40]!==T?(I=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[P,E,T]}),e[38]=P,e[39]=E,e[40]=T,e[41]=I):I=e[41];let $;return e[42]!==I||e[43]!==S?($=r.jsx(Vs,{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:[S,I]})}),e[42]=I,e[43]=S,e[44]=$):$=e[44],$}const p$=250,h$=400,Jp={results:null,loading:!1,error:null};function V2(n,e){const t=y.useMemo(()=>z2(n),[n]),[s,o]=y.useState(0),[i,a]=y.useState(Jp);y.useEffect(()=>{if(!t){a(Jp);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()},h$);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()},p$);return()=>{clearTimeout(u),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=y.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const g$=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=y.useState(()=>({projects:Wi(Kn.projects),activeSessions:Wi(Kn.activeSessions)})),[d,f]=y.useState(c.projects??[]),[u,m]=y.useState(c.activeSessions??[]),[p,h]=y.useState(c.projects===void 0),[g,x]=y.useState(!1),[b,w]=y.useState([]),[v,j]=y.useState(0),[S,k]=y.useState(1),[C,N]=y.useState(!1),[_,A]=y.useState(""),[P,E]=y.useState(null),T=y.useRef(0),I=y.useRef(null),$=y.useCallback(async(U=!1)=>{U&&x(!0);try{const[H,K]=await Promise.all([ye("/api/projects"),ye("/api/active-sessions")]);if(!H.ok||!K.ok)throw new Error("Failed to fetch dashboard data");const q=await H.json(),Y=await K.json(),G=Array.isArray(q)?q:[],J=Array.isArray(Y)?Y:[];f(G),m(J),er(Kn.projects,G),er(Kn.activeSessions,J),E(null)}catch(H){E(H instanceof Error?H.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);y.useEffect(()=>{$()},[$]);const R=y.useCallback(async(U,H=1,K=!1)=>{var J;const q=++T.current;(J=I.current)==null||J.abort();const Y=new AbortController;I.current=Y;const G=()=>q===T.current;if(N(!0),E(null),!K){const Q=Z_(U);Q?(w(Q.sessions),j(Q.total),k(1)):w([])}try{const Q=await ye(`/api/sessions/${encodeURIComponent(U)}?page=${H}&limit=20`,{signal:Y.signal});if(!Q.ok)throw new Error(`Failed to load sessions (${Q.status})`);const X=await Q.json();if(!G())return;const Z=Array.isArray(X.sessions)?X.sessions:[],se=typeof X.total=="number"?X.total:Z.length;w(ne=>K?[...ne,...Z]:Z),j(se),k(H),K||e6(U,{sessions:Z,total:se})}catch(Q){if(!G()||Y.signal.aborted)return;E(Q instanceof Error?Q.message:"Failed to load sessions")}finally{G()&&(I.current=null,N(!1))}},[]);y.useEffect(()=>{var U;if(!o){T.current+=1,(U=I.current)==null||U.abort(),I.current=null,w([]),j(0),k(1),A(""),N(!1);return}A(""),R(o)},[o,R]),y.useEffect(()=>()=>{var U;T.current+=1,(U=I.current)==null||U.abort()},[]);const M=y.useMemo(()=>{if(!o)return null;const U=d.find(K=>K.dirName===o);if(U)return U;const H=wn(o);return{dirName:o,path:H,shortName:qn(H),sessionCount:v,lastModified:null}},[o,d,v]),D=y.useCallback(()=>{i==null||i(null)},[i]),O=y.useCallback(()=>{o&&R(o,S+1,!0)},[o,S,R]),L=V2(o?_:"",o??void 0),F=y.useMemo(()=>_?b.filter(U=>e$(U,_)):b,[b,_]),z=L.results??F;function W(U,H){l==null||l(U,H),w(K=>K.filter(q=>q.fileName!==H)),j(K=>K-1)}return M?r.jsx(a$,{selectedProject:M,sessions:b,sessionsTotal:v,sessionsLoading:C,searchLoading:L.loading,searchFilter:_,setSearchFilter:A,filteredSessions:z,fetchError:L.error??P,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:W,onBack:D,onRetryFetch:()=>{if(L.error){L.refresh();return}E(null),o&&R(o)},loadMoreSessions:O}):r.jsx(m$,{projects:d,activeSessions:u,loading:p,refreshing:g,searchFilter:_,setSearchFilter:A,fetchError:P,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>$(!0)})});async function G2(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 x$(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 Y2(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 b$(n,e,t){return Y2("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function v$(n,e,t){return Y2("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const y$=3e3,X2=y.createContext(null);async function Yl(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 zo(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 Si(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 w$({children:n}){const[e,t]=y.useState(new Map),[s,o]=y.useState(new Map),[i,a]=y.useState(new Map),[l,c]=y.useState(new Map),[d,f]=y.useState(new Set),[u,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=y.useCallback(async()=>{const[E,T,I]=await Promise.all([Yl("/api/permissions",p),Yl("/api/user-questions",h),Yl("/api/agent-prompts",g)]);E&&(t(zo(E.bySession)),f(new Set(zo(E.plansBySession).keys()))),T&&o(zo(T.bySession)),I&&(a(zo(I.elicitationsBySession)),c(zo(I.dialogsBySession)))},[]);y.useEffect(()=>{const E=()=>{document.visibilityState==="visible"&&x()};E();const T=setInterval(E,y$);return document.addEventListener("visibilitychange",E),()=>{clearInterval(T),document.removeEventListener("visibilitychange",E)}},[x]);const b=y.useCallback(async(E,T)=>{m(I=>new Set(I).add(E));try{return await T()}finally{m(I=>{const $=new Set(I);return $.delete(E),$}),x()}},[x]),w=y.useCallback((E,T,I)=>b(T,async()=>{await G2(E,T,I).catch(()=>!1)&&(t(R=>Si(R,E,M=>M.requestId===T)),p.current="")}),[b]),v=y.useCallback((E,T,I)=>b(T,async()=>{const $=await od(E,T,I);return $.ok&&(o(R=>Si(R,E,M=>M.toolUseId===T)),h.current=""),$}),[b]),j=y.useCallback((E,T,I)=>b(T,async()=>{const $=await b$(E,T,I);return $.ok&&(a(R=>Si(R,E,M=>M.requestId===T)),g.current=""),$}),[b]),S=y.useCallback((E,T,I)=>b(T,async()=>{const $=await v$(E,T,I);return $.ok&&(c(R=>Si(R,E,M=>M.requestId===T)),g.current=""),$}),[b]),k=y.useMemo(()=>new Set(e.keys()),[e]),C=y.useMemo(()=>new Set(s.keys()),[s]),N=y.useMemo(()=>new Set(i.keys()),[i]),_=y.useMemo(()=>new Set(l.keys()),[l]),A=y.useCallback(()=>{x()},[x]),P=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:k,awaitingQuestion:C,awaitingElicitation:N,awaitingDialog:_,awaitingPlan:d,responding:u,respond:w,answerQuestion:v,answerElicitation:j,answerDialog:S,refresh:A}),[e,s,i,l,k,C,N,_,d,u,w,v,j,S,A]);return r.jsx(X2.Provider,{value:P,children:n})}function j$(){const n=y.useContext(X2);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const J2=typeof navigator<"u"&&"vibrate"in navigator;function $c(){J2&&navigator.vibrate(10)}function S$(){J2&&navigator.vibrate(20)}function N$(n){return!!(n.teamName&&n.agentName)}function k$(n,e,t,s,o,i,a){const l=[],c=[];for(const d of zd(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(N$(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||Bd.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function C$(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 gu(n,e){return n?Ht(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const Q2="aw:turnCounts",_$=200,Ya=new Map;try{const n=localStorage.getItem(Q2);if(n){const e=JSON.parse(n);for(const[t,s]of e)Ya.set(t,s)}}catch{}function T$(){try{const n=[...Ya.entries()].slice(-_$);localStorage.setItem(Q2,JSON.stringify(n))}catch{}}function E$(n,e){Ya.set(Ut(n),e),T$()}function A$(n,e){const t=Ya.get(Ut(n));return Math.max(t??0,e??0)}function Z2(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=A$(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:V("font-medium",hu(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(Xn,{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(Ka,{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(Us,{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(fa,{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=jg(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 v;e[21]!==s?(v=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(a3,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=v):v=e[22];const j=t.lastActivityAt||t.lastModified;let S;e[23]!==j?(S=Ir(j),e[23]=j,e[24]=S):S=e[24];let k;e[25]!==S?(k=r.jsx("span",{children:S}),e[25]=S,e[26]=k):k=e[26];let C;e[27]!==v||e[28]!==k||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,v,k]}),e[27]=v,e[28]=k,e[29]=g,e[30]=x,e[31]=w,e[32]=C):C=e[32];let N;return e[33]!==f||e[34]!==C||e[35]!==u||e[36]!==m||e[37]!==p||e[38]!==h?(N=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]=N):N=e[39],N}const P$=120;function eb(n){const e=B.c(7),t=y.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]),y.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,P$))},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 I$=6;function R$(n){const e=B.c(7),{iso:t}=n,[,s]=y.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s($$),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],y.useEffect(o,i);let a;e[3]!==t?(a=Ir(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 $$(n){return n+1}const M$={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"}},O$={permission:Ms.attention,deferred:Ms.attention,waiting:Ms.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function Qp(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=gu(Ct(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const w=b;let v;e[3]!==s||e[4]!==w||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(v=w?"Read-only":Hr(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]=v):v=e[9];const j=v,S=!!h&&!w,{onHoverStart:k,onHoverEnd:C}=eb(g),N=x?"px-2.5 py-2":"border px-2 py-2",_=a&&!x&&"ring-1 ring-ring";let A;e[10]!==i||e[11]!==N||e[12]!==_?(A=V("group relative w-full rounded-md text-left transition-colors",N,i,_),e[10]=i,e[11]=N,e[12]=_,e[13]=A):A=e[13];let P;e[14]!==x||e[15]!==a?(P=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]=P):P=e[16];const E=S&&"pr-20";let T;e[17]!==E?(T=V("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",E),e[17]=E,e[18]=T):T=e[18];let I;e[19]!==C||e[20]!==k||e[21]!==m||e[22]!==T?(I=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:k,onMouseLeave:C,onFocus:k,onBlur:C,className:T}),e[19]=C,e[20]=k,e[21]=m,e[22]=T,e[23]=I):I=e[23];const $=x&&"ring-0";let R;e[24]!==o||e[25]!==$?(R=V("size-1.5 shrink-0 rounded-full",o,$),e[24]=o,e[25]=$,e[26]=R):R=e[26];let M;e[27]!==R?(M=r.jsx("span",{className:R,"aria-hidden":"true"}),e[27]=R,e[28]=M):M=e[28];let D;e[29]!==d||e[30]!==t?(D=Jx(t,d),e[29]=d,e[30]=t,e[31]=D):D=e[31];let O;e[32]!==D?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:D}),e[32]=D,e[33]=O):O=e[33];const L=x?"text-muted-foreground":s.className;let F;e[34]!==L?(F=V("shrink-0",L),e[34]=L,e[35]=F):F=e[35];const z=w?"Read-only":s.label;let W;e[36]!==F||e[37]!==z?(W=r.jsx(Ee,{variant:"outline",className:F,children:z}),e[36]=F,e[37]=z,e[38]=W):W=e[38];let U;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(U=!x&&r.jsx(R$,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=U):U=e[42];let H;e[43]!==M||e[44]!==O||e[45]!==W||e[46]!==U?(H=r.jsxs("span",{className:"flex items-center gap-1.5",children:[M,O,W,U]}),e[43]=M,e[44]=O,e[45]=W,e[46]=U,e[47]=H):H=e[47];let K;e[48]!==f?(K=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[48]=f,e[49]=K):K=e[49];let q;e[50]!==I||e[51]!==H||e[52]!==K?(q=r.jsxs(Et,{render:I,children:[H,K]}),e[50]=I,e[51]=H,e[52]=K,e[53]=q):q=e[53];let Y;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==j?(Y=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(Z2,{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 G;e[59]!==q||e[60]!==Y?(G=r.jsxs(Tt,{children:[q,Y]}),e[59]=q,e[60]=Y,e[61]=G):G=e[61];let J;e[62]!==S||e[63]!==h?(J=S&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx(kr,{"data-icon":"inline-start"}),"Resume"]}),e[62]=S,e[63]=h,e[64]=J):J=e[64];let Q;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(Q=l&&p&&!w&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z=>p(l.pid,Z),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(ct,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=Q):Q=e[69];let X;return e[70]!==G||e[71]!==J||e[72]!==Q||e[73]!==A||e[74]!==P?(X=r.jsxs("div",{className:A,children:[P,G,J,Q]}),e[70]=G,e[71]=J,e[72]=Q,e[73]=A,e[74]=P,e[75]=X):X=e[75],X}function D$(n){const e=B.c(15),{dotClassName:t,labelClassName:s,label:o,count:i}=n;let a;e[0]!==t?(a=V("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=V("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 L$(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]=y.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,I$),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=N=>l[N.dirName]||Fd(N.cwd||wn(N.dirName)),e[3]=l,e[4]=b):b=e[4];const w=b;let v;e[5]!==s||e[6]!==i||e[7]!==u||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(v=N=>{const _=s===`${N.dirName}/${N.fileName}`;return{session:N,isActiveSession:_,proc:o.get(N.sessionId),killingPids:i,customName:a[N.sessionId],projectLabel:w(N),onSelect:()=>c(N.dirName,N.fileName),onPrefetch:u&&!_?()=>u(N.dirName,N.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]=v):v=e[12];const j=v;let S;e[13]!==t.needsYou||e[14]!==d||e[15]!==f||e[16]!==j?(S=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(D$,{dotClassName:Ms.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(N=>{const{session:_,reason:A}=N;return r.jsx(Qp,{...j(_),chip:M$[A],dotClassName:O$[A],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:A==="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]=S):S=e[17];let k;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==j||e[22]!==g?(k=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(N=>r.jsx(Qp,{...j(N),chip:{label:C$(N),className:""},dotClassName:Ms.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${N.dirName}/${N.fileName}`))}),x>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(nt,{"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]=k):k=e[23];let C;return e[24]!==S||e[25]!==k?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[S,k]}),e[24]=S,e[25]=k,e[26]=C):C=e[26],C}function z$(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=v=>a(v.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(Nn,{align:"inline-start",children:i?r.jsx(rt,{className:"animate-spin"}):r.jsx(dn,{})}),e[6]=i,e[7]=f):f=e[7];let u;e[8]!==a||e[9]!==o?(u=o&&r.jsx(Nn,{align:"inline-end",children:r.jsx(Dr,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(ct,{"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=V(h),e[15]=h,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(Dt,{"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(ee,{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 F$=["first","second","third","fourth","fifth"];function B$(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(kn,{}),r.jsx(It,{children:"Could not load sessions"}),r.jsx(Nt,{className:"truncate",children:t}),r.jsx(vs,{children:r.jsx(ee,{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(un,{className:"min-h-56 px-4 py-8",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:o?r.jsx(dn,{}):r.jsx(Yh,{})}),r.jsx(mn,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(Tn,{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:F$.map(U$)}),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 U$(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(Ot,{className:"size-2 shrink-0 rounded-full"}),r.jsx(Ot,{className:"h-4 flex-1"}),r.jsx(Ot,{className:"h-4 w-10"})]},n)}function W$(n){var be;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,v=o!==void 0,j=t.isActive===!0,S=v||j,k=j&&jr(t.agentStatus),C=t.agentStatus==="deferred";let N;e[0]!==o||e[1]!==t.dirName?(N=gu(Ct(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=N):N=e[2];const _=N,[A,P]=y.useState(!1),E=_?"Read-only":S?k?"Running":Hr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,T=C?"attention":S?jr(t.agentStatus)?"idle":"working":null,I=!!(t.teamName&&t.agentName);let $;e[3]!==l||e[4]!==t?($=Jx(t,l),e[3]=l,e[4]=t,e[5]=$):$=e[5];const R=$;let M;e[6]!==s||e[7]!==b||e[8]!==t.dirName||e[9]!==t.fileName?(M=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]=M):M=e[10];const{onHoverStart:D,onHoverEnd:O}=eb(M);let L;e[11]!==w||e[12]!==A||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(L=ge=>{ge.stopPropagation(),!(!w||A)&&(P(!0),w(t.sessionId,t.cwd,t.dirName),setTimeout(()=>P(!1),3e3))},e[11]=w,e[12]=A,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]!==v||e[18]!==s||e[19]!==j||e[20]!==a||e[21]!==t.agentStatus?(z=V("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",H$(s,!j&&v&&t.agentStatus==="completed"&&!!a)),e[17]=v,e[18]=s,e[19]=j,e[20]=a,e[21]=t.agentStatus,e[22]=z):z=e[22];const W=Tt,U=Et;let H;e[23]!==m||e[24]!==t.dirName||e[25]!==t.fileName?(H=()=>m(t.dirName,t.fileName),e[23]=m,e[24]=t.dirName,e[25]=t.fileName,e[26]=H):H=e[26];let K;e[27]!==O||e[28]!==D||e[29]!==H?(K=r.jsx("button",{type:"button","data-live-session":!0,onClick:H,onMouseEnter:D,onMouseLeave:O,onFocus:D,onBlur:O,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[27]=O,e[28]=D,e[29]=H,e[30]=K):K=e[30];let q;e[31]!==T?(q=T&&r.jsx("span",{"data-status-dot":T,className:V("size-1.5 rounded-full",Ms[T])}),e[31]=T,e[32]=q):q=e[32];let Y;e[33]!==q?(Y=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:q}),e[33]=q,e[34]=Y):Y=e[34];let G;e[35]!==R?(G=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:R}),e[35]=R,e[36]=G):G=e[36];let J;e[37]!==I||e[38]!==t.agentName||e[39]!==R?(J=I&&r.jsxs(Ee,{variant:"outline",children:[r.jsx(go,{"data-icon":"inline-start"}),R!==t.agentName?t.agentName:"Agent"]}),e[37]=I,e[38]=t.agentName,e[39]=R,e[40]=J):J=e[40];const Q=S&&!C&&E&&r.jsx(Ee,{variant:"secondary","data-session-live-state":!0,className:V("shrink-0",k&&"text-success",!k&&hu(t.agentStatus)),children:E});let X;e[41]!==C?(X=C&&r.jsx(Ee,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[41]=C,e[42]=X):X=e[42];let Z;e[43]!==c?(Z=c&&r.jsxs(Ee,{variant:"outline",children:[r.jsx(Us,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=Z):Z=e[44];let se;e[45]!==U||e[46]!==G||e[47]!==J||e[48]!==Q||e[49]!==X||e[50]!==Z||e[51]!==K||e[52]!==Y?(se=r.jsxs(U,{render:K,children:[Y,G,J,Q,X,Z]}),e[45]=U,e[46]=G,e[47]=J,e[48]=Q,e[49]=X,e[50]=Z,e[51]=K,e[52]=Y,e[53]=se):se=e[53];let ne;e[54]!==l||e[55]!==o||e[56]!==t||e[57]!==E||e[58]!==c?(ne=r.jsx(At,{side:"right",className:"max-w-[280px]",children:r.jsx(Z2,{session:t,proc:o,statusLabel:E,customName:l,worktreeName:c})}),e[54]=l,e[55]=o,e[56]=t,e[57]=E,e[58]=c,e[59]=ne):ne=e[59];let re;e[60]!==W||e[61]!==se||e[62]!==ne?(re=r.jsxs(W,{children:[se,ne]}),e[60]=W,e[61]=se,e[62]=ne,e[63]=re):re=e[63];let ie;e[64]!==u||e[65]!==d||e[66]!==f?(ie=!!d&&u&&r.jsxs(ee,{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(Xn,{"data-icon":"inline-start"}),d,r.jsx(Je,{"data-icon":"inline-end",className:V("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]!==A?(ae=C&&w&&!_&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:F,disabled:A,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx(kr,{"data-icon":"inline-start"}),"Resume"]}),e[68]=F,e[69]=C,e[70]=_,e[71]=w,e[72]=A,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(Ka,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=te):te=e[76];const ue=t.lastActivityAt||t.lastModified;let le;e[77]!==ue?(le=Ir(ue),e[77]=ue,e[78]=le):le=e[78];let de;e[79]!==le?(de=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:le}),e[79]=le,e[80]=de):de=e[80];let he;e[81]!==v||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(he=v&&p&&!_&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:ge=>p(o.pid,ge),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(ct,{"data-icon":"inline-start"})}),e[81]=v,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=he):he=e[86];let xe;e[87]!==re||e[88]!==ie||e[89]!==ae||e[90]!==te||e[91]!==de||e[92]!==he||e[93]!==z?(xe=r.jsxs("div",{className:z,children:[re,ie,ae,te,de,he]}),e[87]=re,e[88]=ie,e[89]=ae,e[90]=te,e[91]=de,e[92]=he,e[93]=z,e[94]=xe):xe=e[94];const ce=xe;if(h||g||x){let ge;e[95]!==t.firstUserMessage||e[96]!==t.sessionId||e[97]!==t.slug?(ge=t.slug||((be=t.firstUserMessage)==null?void 0:be.slice(0,30))||t.sessionId.slice(0,12),e[95]=t.firstUserMessage,e[96]=t.sessionId,e[97]=t.slug,e[98]=ge):ge=e[98];let fe;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(fe=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=fe):fe=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 Se;e[106]!==x||e[107]!==t.sessionId?(Se=x?Ie=>x(t.sessionId,Ie):void 0,e[106]=x,e[107]=t.sessionId,e[108]=Se):Se=e[108];let Ae;return e[109]!==l||e[110]!==ce||e[111]!==ge||e[112]!==fe||e[113]!==je||e[114]!==Se?(Ae=r.jsx(I2,{sessionLabel:ge,customName:l,onDuplicate:fe,onDelete:je,onRename:Se,children:ce}),e[109]=l,e[110]=ce,e[111]=ge,e[112]=fe,e[113]=je,e[114]=Se,e[115]=Ae):Ae=e[115],Ae}return ce}function H$(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function K$(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function q$(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:v,onNewSession:j,creatingSession:S,onPrefetchSession:k,onResumeSession:C}=n;let N;e[0]!==l||e[1]!==S||e[2]!==d||e[3]!==f||e[4]!==b||e[5]!==x||e[6]!==g||e[7]!==j||e[8]!==k||e[9]!==v||e[10]!==w||e[11]!==C||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==u?(N={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:v,onNewSession:j,creatingSession:S,onPrefetchSession:k,onResumeSession:C},e[0]=l,e[1]=S,e[2]=d,e[3]=f,e[4]=b,e[5]=x,e[6]=g,e[7]=j,e[8]=k,e[9]=v,e[10]=w,e[11]=C,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=u,e[17]=N):N=e[17];const _=N;let A;e[18]!==a?(A=a.trim(),e[18]=a,e[19]=A):A=e[19];const P=!!A;let E;e[20]!==i||e[21]!==P||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==_?(E=[...t.entries()].map(($,R)=>{const[M,D]=$,O=K$(D,c);return y.createElement(Zp,{..._,key:M,projectPath:M,sessions:D,liveCount:O,collapsed:i[M]??(R>=3&&O===0),forceExpand:P,pendingSession:s===M?o:void 0})}),e[20]=i,e[21]=P,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=_,e[27]=E):E=e[27];let T;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==_?(T=s&&!t.has(s)&&o&&y.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]=T):T=e[32];let I;return e[33]!==E||e[34]!==T?(I=r.jsxs(r.Fragment,{children:[E,T]}),e[33]=E,e[34]=T,e[35]=I):I=e[35],I}function Zp(n){var We,Fe;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:v,onNewSession:j,creatingSession:S,pendingSession:k,onPrefetchSession:C,onResumeSession:N}=n,_=p===void 0?!1:p,A=y.useId(),P=!!k,E=_||P?!1:u;let T;e[0]!==s?(T=new Set(s.map(G$)),e[0]=s,e[1]=T):T=e[1];const I=T;let $;if(e[2]!==I||e[3]!==s){const Ne=new Map,me=[];for(const Oe of s){const Pe=Oe.teamLeadSessionId;if(Pe&&Pe!==Oe.sessionId&&I.has(Pe)){const Be=Ne.get(Pe);Be?Be.push(Oe):Ne.set(Pe,[Oe])}else me.push(Oe)}$={topLevelSessions:me,teammatesByLead:Ne},e[2]=I,e[3]=s,e[4]=$}else $=e[4];const{topLevelSessions:R,teammatesByLead:M}=$;let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[5]=D):D=e[5];const[O,L]=y.useState(D);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=Ne=>{L(me=>{const Oe=new Set(me);return Oe.has(Ne)?Oe.delete(Ne):Oe.add(Ne),Oe})},e[6]=F):F=e[6];const z=F,[W,U]=y.useState(!1),H=s.length+(P?1:0);let K,q;e[7]!==_||e[8]!==P||e[9]!==i||e[10]!==W||e[11]!==R?(K=K_(R,i,Math.max(1,5-(P?1:0))),q=_||W?R:R.slice(0,K),e[7]=_,e[8]=P,e[9]=i,e[10]=W,e[11]=R,e[12]=K,e[13]=q):(K=e[12],q=e[13]);const Y=q,G=R.length-Y.length,J=W&&!_&&R.length>K,Q=((We=s.find(V$))==null?void 0:We.dirName)??((Fe=s[0])==null?void 0:Fe.dirName)??(k==null?void 0:k.dirName),X=Q?d[Q]:void 0;let Z;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]!==N||e[23]!==h||e[24]!==i||e[25]!==c?(Z=function(me,Oe,Pe){return r.jsx(W$,{session:me,isActiveSession:o===`${me.dirName}/${me.fileName}`,proc:i.get(me.sessionId),killingPids:a,isNewlyCompleted:l.has(me.sessionId),customName:c[me.sessionId],worktreeName:Oe,teammateCount:Pe==null?void 0:Pe.count,teammatesCollapsed:Pe==null?void 0:Pe.collapsed,onToggleTeammates:Pe==null?void 0:Pe.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:w,onPrefetchSession:C,onResumeSession:N},`${me.dirName}/${me.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]=N,e[23]=h,e[24]=i,e[25]=c,e[26]=Z):Z=e[26];const se=Z,ne=!E;let re;e[27]!==Q||e[28]!==v?(re=Ne=>{Q&&v&&v(Q,Ne)},e[27]=Q,e[28]=v,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=!E,te=_?"Groups stay expanded while searching":void 0,ue=!E&&"rotate-90";let le;e[34]!==ue?(le=V("size-3 shrink-0 text-muted-foreground transition-transform duration-150",ue),e[34]=ue,e[35]=le):le=e[35];let de;e[36]!==le?(de=r.jsx(Je,{className:le}),e[36]=le,e[37]=de):de=e[37];const he=X||t;let xe;e[38]!==he?(xe=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:he}),e[38]=he,e[39]=xe):xe=e[39];let ce;e[40]!==X||e[41]!==t?(ce=X&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=X,e[41]=t,e[42]=ce):ce=e[42];let be;e[43]!==f?(be=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(Sa,{className:"size-1.5","aria-hidden":"true"}),f]}),e[43]=f,e[44]=be):be=e[44];let ge;e[45]!==H?(ge=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:H}),e[45]=H,e[46]=ge):ge=e[46];let fe;e[47]!==_||e[48]!==A||e[49]!==ie||e[50]!==ae||e[51]!==te||e[52]!==de||e[53]!==xe||e[54]!==ce||e[55]!==be||e[56]!==ge?(fe=r.jsxs("button",{type:"button",onClick:ie,disabled:_,"aria-expanded":ae,"aria-controls":A,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:[de,xe,ce,be,ge]}),e[47]=_,e[48]=A,e[49]=ie,e[50]=ae,e[51]=te,e[52]=de,e[53]=xe,e[54]=ce,e[55]=be,e[56]=ge,e[57]=fe):fe=e[57];let je;e[58]!==S||e[59]!==j||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(je=j&&s.length>0&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:S,onClick:Ne=>{Ne.stopPropagation();const me=s[0];j(me.dirName,me.cwd??void 0)},"aria-label":`New session in ${t}`,children:S?r.jsx(rt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx($n,{"data-icon":"inline-start"})}),e[58]=S,e[59]=j,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=je):je=e[63];let Se;e[64]!==fe||e[65]!==je?(Se=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[fe,je]}),e[64]=fe,e[65]=je,e[66]=Se):Se=e[66];let Ae;e[67]!==X||e[68]!==t||e[69]!==Se||e[70]!==re?(Ae=r.jsx(W2,{projectLabel:t,customName:X,className:"sticky top-0 z-20 bg-background",onRename:re,children:Se}),e[67]=X,e[68]=t,e[69]=Se,e[70]=re,e[71]=Ae):Ae=e[71];let Ie;e[72]!==k?(Ie=k&&r.jsx(Y$,{firstMessage:k.firstMessage}),e[72]=k,e[73]=Ie):Ie=e[73];let Re;if(e[74]!==O||e[75]!==se||e[76]!==M||e[77]!==Y){let Ne;e[79]!==O||e[80]!==se||e[81]!==M?(Ne=me=>{const Oe=me.cwd??wn(me.dirName),Pe=ya(Oe),Be=M.get(me.sessionId);if(!Be)return se(me,Pe==null?void 0:Pe.worktreeName);const oe=O.has(me.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[se(me,Pe==null?void 0:Pe.worktreeName,{count:Be.length,collapsed:oe,onToggle:()=>z(me.sessionId)}),!oe&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Be.map(pe=>se(pe))})]},`${me.dirName}/${me.fileName}`)},e[79]=O,e[80]=se,e[81]=M,e[82]=Ne):Ne=e[82],Re=Y.map(Ne),e[74]=O,e[75]=se,e[76]=M,e[77]=Y,e[78]=Re}else Re=e[78];let De;e[83]!==G?(De=G>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!0),className:"justify-start",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Show ",G," more"]}),e[83]=G,e[84]=De):De=e[84];let Le;e[85]!==J?(Le=J&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!1),className:"justify-start",children:[r.jsx(Nr,{"data-icon":"inline-start"}),"Show less"]}),e[85]=J,e[86]=Le):Le=e[86];let ze;e[87]!==Ie||e[88]!==Re||e[89]!==De||e[90]!==Le?(ze=r.jsxs("div",{className:"flex flex-col gap-px",children:[Ie,Re,De,Le]}),e[87]=Ie,e[88]=Re,e[89]=De,e[90]=Le,e[91]=ze):ze=e[91];let _e;e[92]!==A||e[93]!==ze?(_e=r.jsx(ft,{id:A,className:"ml-3 border-l pl-1",children:ze}),e[92]=A,e[93]=ze,e[94]=_e):_e=e[94];let Ce;return e[95]!==Ae||e[96]!==_e||e[97]!==ne?(Ce=r.jsxs(ut,{open:ne,className:"flex flex-col",children:[Ae,_e]}),e[95]=Ae,e[96]=_e,e[97]=ne,e[98]=Ce):Ce=e[98],Ce}function V$(n){return!ya(n.cwd??wn(n.dirName))}function G$(n){return n.sessionId}function Y$(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 X$=y.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}=M2(),{names:h,rename:g}=q2(),x=ad(),b=Sn("terminal"),w=Sn("killAny"),{sessions:v,procBySession:j,newlyCompleted:S,loading:k,error:C,refresh:N,removeSession:_,acknowledgeCompleted:A}=i0(),{awaitingPermission:P,awaitingQuestion:E,awaitingElicitation:T,awaitingDialog:I,awaitingPlan:$}=j$();let R;t[0]!==I||t[1]!==T?(R=new Set([...T,...I]),t[0]=I,t[1]=T,t[2]=R):R=t[2];const M=R;let D;t[3]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,t[3]=D):D=t[3];const[O,L]=y.useState(D),[F,z]=y.useState("");let W,U;t[4]===Symbol.for("react.memo_cache_sentinel")?(W=Ut("live-sessions-collapsed-projects"),U={},t[4]=W,t[5]=U):(W=t[4],U=t[5]);const[H,K]=Ur(W,U);let q;t[6]!==K?(q=(Ve,Ze)=>{K(pt=>({...pt,[Ve]:Ze}))},t[6]=K,t[7]=q):q=t[7];const Y=q,G=y.useRef(v);let J;t[8]===Symbol.for("react.memo_cache_sentinel")?(J=new Set,t[8]=J):J=t[8];const Q=y.useRef(J),X=y.useRef(!1);let Z;t[9]===Symbol.for("react.memo_cache_sentinel")?(Z=(Ve,Ze)=>{if(!X.current)return;const pt=setTimeout(()=>{Q.current.delete(pt),X.current&&Ve()},Ze);Q.current.add(pt)},t[9]=Z):Z=t[9];const se=Z;let ne,re;t[10]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{const Ve=Q.current;return X.current=!0,()=>{X.current=!1;for(const Ze of Ve)clearTimeout(Ze);Ve.clear()}},re=[],t[10]=ne,t[11]=re):(ne=t[10],re=t[11]),y.useEffect(ne,re);let ie,ae;t[12]!==v?(ie=()=>{G.current=v},ae=[v],t[12]=v,t[13]=ie,t[14]=ae):(ie=t[13],ae=t[14]),y.useEffect(ie,ae);let te,ue;t[15]!==N||t[16]!==f?(te=()=>{if(f)return f.current=N,()=>{f.current===N&&(f.current=null)}},ue=[N,f],t[15]=N,t[16]=f,t[17]=te,t[18]=ue):(te=t[17],ue=t[18]),y.useEffect(te,ue);const le=za(),de=V2(F);let he;e:{if(!F.trim()){he=v;break e}let Ve;if(t[19]!==h||t[20]!==F||t[21]!==m||t[22]!==v){let Ze;t[24]!==h||t[25]!==F||t[26]!==m?(Ze=pt=>{const $t=m[pt.sessionId],Un=h[pt.dirName];return F2(pt,F,[$t,Un])},t[24]=h,t[25]=F,t[26]=m,t[27]=Ze):Ze=t[27],Ve=v.filter(Ze),t[19]=h,t[20]=F,t[21]=m,t[22]=v,t[23]=Ve}else Ve=t[23];he=Ve}const xe=he,ce=de.results??xe;let be;t[28]!==ce?(be=H_(ce),t[28]=ce,t[29]=be):be=t[29];const ge=be;let fe;t[30]!==P||t[31]!==$||t[32]!==M||t[33]!==E||t[34]!==S||t[35]!==j||t[36]!==v?(fe=k$(v,j,S,P,E,M,$),t[30]=P,t[31]=$,t[32]=M,t[33]=E,t[34]=S,t[35]=j,t[36]=v,t[37]=fe):fe=t[37];const je=fe,Se=je.needsYou.length>0||je.working.length>0;let Ae;t[38]!==Se||t[39]!==F?(Ae=!F.trim()&&Se,t[38]=Se,t[39]=F,t[40]=Ae):Ae=t[40];const Ie=Ae;let Re;e:{if(!d){Re=null;break e}let Ve;t[41]!==d.cwd||t[42]!==d.dirName?(Ve=d.cwd||wn(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=Ve):Ve=t[43];let Ze;t[44]!==Ve?(Ze=Fd(Ve),t[44]=Ve,t[45]=Ze):Ze=t[45],Re=Ze}const De=Re,Le=y.useRef(!1);let ze,_e;t[46]!==u||t[47]!==v?(ze=()=>{if(Le.current||!u||v.length===0)return;Le.current=!0;const Ve=zd(v).slice(0,3),Ze=globalThis,pt=()=>{for(const Ys of Ve)u(Ys.dirName,Ys.fileName)};let $t=null,Un=null;return typeof Ze.requestIdleCallback=="function"?$t=Ze.requestIdleCallback(pt,{timeout:1500}):Un=setTimeout(pt,300),()=>{$t!=null&&typeof Ze.cancelIdleCallback=="function"&&Ze.cancelIdleCallback($t),Un!=null&&clearTimeout(Un)}},_e=[v,u],t[46]=u,t[47]=v,t[48]=ze,t[49]=_e):(ze=t[48],_e=t[49]),y.useEffect(ze,_e);let Ce;t[50]!==N?(Ce=async(Ve,Ze)=>{Ze.stopPropagation(),L(pt=>new Set(pt).add(Ve));try{await ye("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:Ve})}),se(N,1500)}catch{}se(()=>{L(pt=>{const $t=new Set(pt);return $t.delete(Ve),$t})},2e3)},t[50]=N,t[51]=Ce):Ce=t[51];const We=Ce;let Fe;t[52]!==A||t[53]!==o?(Fe=(Ve,Ze)=>{const pt=G.current.find($t=>$t.dirName===Ve&&$t.fileName===Ze);pt&&A(pt.sessionId),o(Ve,Ze)},t[52]=A,t[53]=o,t[54]=Fe):Fe=t[54];const Ne=Fe;let me;t[55]!==a||t[56]!==_?(me=Ve=>{a==null||a(Ve.dirName,Ve.fileName),_(Ve.sessionId)},t[55]=a,t[56]=_,t[57]=me):me=t[57];const Oe=me;let Pe;t[58]!==N||t[59]!==x?(Pe=(Ve,Ze,pt)=>{const{command:$t,args:Un}=_3(Ct(pt),Ve),Ys=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Ys,name:`Resume ${Ve.slice(0,8)}`,command:$t,args:Un,cwd:Ze??void 0,metadata:{type:"terminal"}}),se(N,3e3)},t[58]=N,t[59]=x,t[60]=Pe):Pe=t[60];const Be=Pe;let oe;t[61]!==N?(oe=()=>{S$(),N()},t[61]=N,t[62]=oe):oe=t[62];let pe;t[63]!==le||t[64]!==k||t[65]!==de.loading||t[66]!==F||t[67]!==oe?(pe=r.jsx(z$,{loading:k,isMobile:le,searchQuery:F,searchLoading:de.loading,onSearchQueryChange:z,onRefresh:oe}),t[63]=le,t[64]=k,t[65]=de.loading,t[66]=F,t[67]=oe,t[68]=pe):pe=t[68];const Te=de.error??C,$e=ce.length===0&&!d&&!k&&!de.loading&&!C&&!de.error;let He;t[69]!==F?(He=F.trim(),t[69]=F,t[70]=He):He=t[70];const Ke=!!He,st=k||de.loading,Ye=de.active?ce.length:v.length,Me=de.error?de.refresh:N;let Ue;t[71]!==Te||t[72]!==$e||t[73]!==Ke||t[74]!==st||t[75]!==Ye||t[76]!==Me?(Ue=r.jsx(B$,{fetchError:Te,showEmpty:$e,searching:Ke,loading:st,sessionCount:Ye,onRetry:Me}),t[71]=Te,t[72]=$e,t[73]=Ke,t[74]=st,t[75]=Ye,t[76]=Me,t[77]=Ue):Ue=t[77];let ot;t[78]!==s||t[79]!==je||t[80]!==w||t[81]!==b||t[82]!==We||t[83]!==Be||t[84]!==Ne||t[85]!==O||t[86]!==u||t[87]!==j||t[88]!==h||t[89]!==m||t[90]!==Ie?(ot=Ie&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(L$,{groups:je,activeSessionKey:s,procBySession:j,killingPids:O,sessionNames:m,projectNames:h,onSelectSession:Ne,onKill:w?We:void 0,onResumeSession:b?Be: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(Rt,{className:"flex-1"})]})]}),t[78]=s,t[79]=je,t[80]=w,t[81]=b,t[82]=We,t[83]=Be,t[84]=Ne,t[85]=O,t[86]=u,t[87]=j,t[88]=h,t[89]=m,t[90]=Ie,t[91]=ot):ot=t[91];const Kt=w?We:void 0,zt=a?Oe:void 0,qt=b?Be:void 0;let Bn;t[92]!==s||t[93]!==H||t[94]!==c||t[95]!==ge||t[96]!==Ne||t[97]!==O||t[98]!==S||t[99]!==i||t[100]!==l||t[101]!==u||t[102]!==De||t[103]!==d||t[104]!==j||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==F||t[109]!==m||t[110]!==Kt||t[111]!==zt||t[112]!==qt||t[113]!==Y?(Bn=r.jsx(q$,{grouped:ge,pendingProjectPath:De,pendingSession:d,collapsedGroups:H,searchQuery:F,activeSessionKey:s,procBySession:j,killingPids:O,newlyCompleted:S,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Ne,onKill:Kt,onDuplicateSession:i,onDeleteSession:zt,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:u,onResumeSession:qt}),t[92]=s,t[93]=H,t[94]=c,t[95]=ge,t[96]=Ne,t[97]=O,t[98]=S,t[99]=i,t[100]=l,t[101]=u,t[102]=De,t[103]=d,t[104]=j,t[105]=h,t[106]=g,t[107]=p,t[108]=F,t[109]=m,t[110]=Kt,t[111]=zt,t[112]=qt,t[113]=Y,t[114]=Bn):Bn=t[114];let Ft;t[115]!==Ue||t[116]!==ot||t[117]!==Bn?(Ft=r.jsx(Vs,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[Ue,ot,Bn]})}),t[115]=Ue,t[116]=ot,t[117]=Bn,t[118]=Ft):Ft=t[118];let ks;return t[119]!==pe||t[120]!==Ft?(ks=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[pe,Ft]}),t[119]=pe,t[120]=Ft,t[121]=ks):ks=t[121],ks}),J$=y.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=V("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(X$,{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}),Q$=y.lazy(()=>qe(()=>import("./index-BVkjlOVU.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.MissionControl})));function tb(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(vt,{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 nb(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(J$,{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 sb(n){const e=B.c(8),{navigation:t}=n,{state:s}=Lt();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(g$,{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 Z$(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(tb,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(y.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(Q$,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function eM({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function tM({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function nM({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}
128
+ `:""}${n} (${a})
129
+ ${i}
130
+ ${e}
131
+ ${i}`}const sM=y.lazy(()=>qe(()=>import("./ConfigBrowser-Cc2lrh85.js"),__vite__mapDeps([34,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),oM=y.lazy(()=>qe(()=>import("./PreviewPanel-BJwfunf9.js"),__vite__mapDeps([35,1,2,3,4])).then(n=>({default:n.PreviewPanel})));function rM(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(Wa,{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(Lx,{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(Ga,{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 iM(n){const e=B.c(36),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Lt(),{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?wn(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(tb,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(sM,{projectPath:tM({sessionCwd:c==null?void 0:c.cwd,pendingPath:f,sessionDirPath:d!=null&&d.dirName?wn(d.dirName):null,dashboardProjectPath:l.dashboardProject?wn(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(y.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(Z$,{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(rM,{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=Ds()?"Only on the machine running this session":void 0;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=vd()?void 0:h,e[17]=g):g=e[17];const x=g,b=!p&&"justify-center gap-4";let w;e[18]!==b?(w=V("flex min-h-0 min-w-0 flex-1 flex-col bg-background",b),e[18]=b,e[19]=w):w=e[19];let v;e[20]!==p||e[21]!==f||e[22]!==s.pendingTurns?(v=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]=v):v=e[23];let j;e[24]!==s.pendingComposer?(j=r.jsx(Ga,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=j):j=e[25];let S;e[26]!==p||e[27]!==o?(S=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[lt("terminal")&&r.jsx(Ol,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(Hs,{"data-icon":"inline-start"}),"Terminal"]})}),lt("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(Ol,{reason:x,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>h1(o.pendingProject),children:[r.jsx(Sr,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(Ol,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>g1(o.pendingProject),children:[r.jsx(qh,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=o,e[28]=S):S=e[28];let k;return e[29]!==w||e[30]!==v||e[31]!==j||e[32]!==S?(k=r.jsxs("div",{className:w,children:[v,j,S]}),e[29]=w,e[30]=v,e[31]=j,e[32]=S,e[33]=k):k=e[33],k}let m;return e[34]!==t?(m=r.jsx(sb,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function aM(n){const e=B.c(100),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Lt(),{session:c,sessionSource:d}=it();let f;e[0]!==s.chatInputRef?(f=function(te){var ge,fe,je;const{path:ue,text:le,startLine:de,endLine:he,comment:xe}=te,ce=nM({path:ue,text:le,startLine:de,endLine:he,comment:xe}),be=((ge=s.chatInputRef.current)==null?void 0:ge.getText().trimEnd())??"";(fe=s.chatInputRef.current)==null||fe.setText(be?`${be}
132
+
133
+ ${ce}
134
+ `:`${ce}
135
+ `),(je=s.chatInputRef.current)==null||je.focus()},e[0]=s.chatInputRef,e[1]=f):f=e[1];const u=f,m=a.mainView,p=!!c;let h;e[2]!==a.mainView||e[3]!==a.pendingDirName||e[4]!==p?(h=eM({mainView:m,hasSession:p,pendingDirName:a.pendingDirName}),e[2]=a.mainView,e[3]=a.pendingDirName,e[4]=p,e[5]=h):h=e[5];const g=h,x=t.panels.handleToggleSidebar,b=t.actions.handleGoHome,w=i.onOpenCommandPalette;let v,j;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=$l("toggleSidebar"),j=$l("commandPalette"),e[6]=v,e[7]=j):(v=e[6],j=e[7]);let S;e[8]!==i.onOpenCommandPalette||e[9]!==t.actions.handleGoHome||e[10]!==t.panels.handleToggleSidebar?(S=r.jsx(TP,{onToggleSidebar:x,onGoHome:b,onOpenCommandPalette:w,sidebarShortcut:v,commandPaletteShortcut:j}),e[8]=i.onOpenCommandPalette,e[9]=t.actions.handleGoHome,e[10]=t.panels.handleToggleSidebar,e[11]=S):S=e[11];const k=S,C=t.panels.showSidebar&&a.mainView!=="config",N=o.currentCwd??null;let _,A,P;e[12]!==t.panels.activeWorkspacePanel||e[13]!==o.hasFileChanges||e[14]!==o.supportsWorktrees||e[15]!==c||e[16]!==a.mainView||e[17]!==a.sessionChangeKey||e[18]!==N?(_={session:c,sessionChangeKey:a.sessionChangeKey,projectPath:N,hasFileChanges:o.hasFileChanges,canAccessHostFiles:lt("hostFiles"),supportsWorktrees:o.supportsWorktrees},P=v2(OR,_),A=a.mainView==="sessions"?P.find(ae=>ae.id===t.panels.activeWorkspacePanel):null,e[12]=t.panels.activeWorkspacePanel,e[13]=o.hasFileChanges,e[14]=o.supportsWorktrees,e[15]=c,e[16]=a.mainView,e[17]=a.sessionChangeKey,e[18]=N,e[19]=_,e[20]=A,e[21]=P):(_=e[19],A=e[20],P=e[21]);const E=A,T=(d==null?void 0:d.dirName)??a.pendingDirName??a.dashboardProject??null;let I;e[22]!==t.panels||e[23]!==o?(I=function(te){o.showPreview&&o.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(te)},e[22]=t.panels,e[23]=o,e[24]=I):I=e[24];const $=I;let R;e[25]!==t.panels||e[26]!==o?(R=function(te){o.showPreview&&o.onCloseRightWorkspace(),t.panels.openWorkspacePanel(te)},e[25]=t.panels,e[26]=o,e[27]=R):R=e[27];const M=R;let D;e[28]!==t.actions||e[29]!==t.panels||e[30]!==T?(D=function(te){T&&(t.actions.handleDashboardSelect(T,`${te}.jsonl`),t.panels.closeWorkspacePanel())},e[28]=t.actions,e[29]=t.panels,e[30]=T,e[31]=D):D=e[31];const O=D,L=t.panels.showSidebar;let F;e[32]===Symbol.for("react.memo_cache_sentinel")?(F=$l("toggleSidebar"),e[32]=F):F=e[32];let z;e[33]!==i.killing||e[34]!==i.onKillAll||e[35]!==l.openConfigDialog||e[36]!==t.creatingSession||e[37]!==t.handlers.handleDuplicateSession||e[38]!==t.onStartNewSession||e[39]!==t.panels.handleToggleSidebar||e[40]!==t.panels.showSidebar||e[41]!==o.onOpenTerminal||e[42]!==s.onBackToMain||e[43]!==s.onShowWorkflows||e[44]!==s.workflowCount||e[45]!==C?(z=r.jsx(kP,{showSidebar:L,sidebarRendered:C,sidebarShortcut:F,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,onKillAll:i.onKillAll,onOpenSettings:l.openConfigDialog}),e[33]=i.killing,e[34]=i.onKillAll,e[35]=l.openConfigDialog,e[36]=t.creatingSession,e[37]=t.handlers.handleDuplicateSession,e[38]=t.onStartNewSession,e[39]=t.panels.handleToggleSidebar,e[40]=t.panels.showSidebar,e[41]=o.onOpenTerminal,e[42]=s.onBackToMain,e[43]=s.onShowWorkflows,e[44]=s.workflowCount,e[45]=C,e[46]=z):z=e[46];const W=z;let U;e[47]!==t||e[48]!==k||e[49]!==C?(U=C&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(nb,{navigation:t,header:k})}),e[47]=t,e[48]=k,e[49]=C,e[50]=U):U=e[50];const H=E??null,K=o.projectFilesRoot??o.currentCwd??null;let q;e[51]!==u||e[52]!==t.actions.handleJumpToTurn||e[53]!==t.handlers.handleLoadSessionScrollAware||e[54]!==O||e[55]!==o.backgroundAgents||e[56]!==o.processPanel.handleServersChanged||e[57]!==o.processPanel.handleToggleServer||e[58]!==o.projectFilesRequest||e[59]!==o.worktrees||e[60]!==s.searchInputRef||e[61]!==K||e[62]!==T?(q={projectFilesRoot:K,projectFilesRequest:o.projectFilesRequest,backgroundAgents:o.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:u,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:o.processPanel.handleToggleServer,serversChanged:o.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:o.worktrees,worktreeDirName:T,openWorktreeSession:O},e[51]=u,e[52]=t.actions.handleJumpToTurn,e[53]=t.handlers.handleLoadSessionScrollAware,e[54]=O,e[55]=o.backgroundAgents,e[56]=o.processPanel.handleServersChanged,e[57]=o.processPanel.handleToggleServer,e[58]=o.projectFilesRequest,e[59]=o.worktrees,e[60]=s.searchInputRef,e[61]=K,e[62]=T,e[63]=q):q=e[63];const Y=a.mainView==="mission";let G;e[64]!==t.panels.handleToggleMission||e[65]!==Y?(G={id:"mission-control",title:"Mission Control",icon:l3,active:Y,onSelect:t.panels.handleToggleMission},e[64]=t.panels.handleToggleMission,e[65]=Y,e[66]=G):G=e[66];let J;e[67]!==t.panels.handleToggleConfig||e[68]!==a.mainView?(J=lt("configWrite")?[{id:"config",title:"Config",icon:c3,active:a.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[67]=t.panels.handleToggleConfig,e[68]=a.mainView,e[69]=J):J=e[69];let Q;e[70]!==G||e[71]!==J?(Q=[G,...J],e[70]=G,e[71]=J,e[72]=Q):Q=e[72];const X=g!=="session"&&W;let Z;e[73]!==W||e[74]!==t||e[75]!==o||e[76]!==s||e[77]!==g?(Z=r.jsx(iM,{navigation:t,sessionView:s,project:o,view:g,floatingChrome:W}),e[73]=W,e[74]=t,e[75]=o,e[76]=s,e[77]=g,e[78]=Z):Z=e[78];let se;e[79]!==X||e[80]!==Z?(se=r.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[X,Z]}),e[79]=X,e[80]=Z,e[81]=se):se=e[81];let ne;e[82]!==t.panels.closeWorkspacePanel||e[83]!==M||e[84]!==_||e[85]!==H||e[86]!==q||e[87]!==Q||e[88]!==se||e[89]!==$||e[90]!==P?(ne=r.jsx(OP,{panels:P,context:_,activePanel:H,services:q,onClosePanel:t.panels.closeWorkspacePanel,onOpenPanel:M,onTogglePanel:$,actions:Q,children:se}),e[82]=t.panels.closeWorkspacePanel,e[83]=M,e[84]=_,e[85]=H,e[86]=q,e[87]=Q,e[88]=se,e[89]=$,e[90]=P,e[91]=ne):ne=e[91];let re;e[92]!==o.currentCwd||e[93]!==o.onCloseRightWorkspace||e[94]!==o.showPreview?(re=o.showPreview&&o.currentCwd&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(oM,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[92]=o.currentCwd,e[93]=o.onCloseRightWorkspace,e[94]=o.showPreview,e[95]=re):re=e[95];let ie;return e[96]!==U||e[97]!==ne||e[98]!==re?(ie=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[U,ne,re]}),e[96]=U,e[97]=ne,e[98]=re,e[99]=ie):ie=e[99],ie}function lM(n){const e=B.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Lt(),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(Bx,{}),d=r.jsx(Fx,{}),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(aM,{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(I9,{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 cM=[{id:"sessions",label:"Sessions",icon:bo},{id:"chat",label:"Chat",icon:fa},{id:"stats",label:"Stats",icon:Gh,requiresSession:!0}],dM=y.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=cM.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:()=>{$c(),o(g.id)},className:V("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:V("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:V("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",b&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(Sa,{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 uM(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 v;e[4]!==o||e[5]!==d?(v=o&&d&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(Vc,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=v):v=e[6];let j,S;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(nu,{compact:!0}),S=r.jsx(Rt,{orientation:"vertical",className:"h-4"}),e[7]=j,e[8]=S):(j=e[7],S=e[8]);let k;e[9]!==i?(k=r.jsx(Hg,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=k):k=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 N;e[13]!==C?(N=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]=N):N=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Ln,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(Vh,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let A;e[16]!==t.cwd?(A=t.cwd?qn(t.cwd):"Current session",e[16]=t.cwd,e[17]=A):A=e[17];let P;e[18]!==A?(P=r.jsx("span",{className:"truncate text-foreground",children:A}),e[18]=A,e[19]=P):P=e[19];let E;e[20]!==t.gitBranch||e[21]!==t.model?(E=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=E):E=e[22];let T;e[23]!==E?(T=r.jsx("span",{className:"truncate font-normal",children:E}),e[23]=E,e[24]=T):T=e[24];let I;e[25]!==P||e[26]!==T?(I=r.jsxs(Ls,{className:"flex flex-col gap-0.5",children:[P,T]}),e[25]=P,e[26]=T,e[27]=I):I=e[27];let $;e[28]!==a||e[29]!==w||e[30]!==s?($=s&&r.jsxs(kt,{onClick:w,disabled:a,children:[a?r.jsx(vt,{}):r.jsx($n,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=w,e[30]=s,e[31]=$):$=e[31];let R;e[32]!==c?(R=c&&r.jsxs(kt,{onClick:c,children:[r.jsx(Cn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=R):R=e[33];let M;e[34]!==I||e[35]!==$||e[36]!==R?(M=r.jsxs(Qt,{children:[I,$,R]}),e[34]=I,e[35]=$,e[36]=R,e[37]=M):M=e[37];let D;e[38]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(dr,{}),e[38]=D):D=e[38];let O;e[39]!==h?(O=h&&r.jsxs(kt,{onClick:h,children:[r.jsx(dn,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=O):O=e[40];let L;e[41]!==g||e[42]!==x?(L=x&&r.jsxs(kt,{onClick:x,children:[g?r.jsx(ua,{}):r.jsx(da,{}),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(kt,{onClick:f,children:[r.jsx(_r,{}),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(kt,{onClick:m,children:[r.jsx(ma,{}),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 W;e[50]!==O||e[51]!==L||e[52]!==F||e[53]!==z?(W=r.jsxs(Qt,{children:[O,L,F,z]}),e[50]=O,e[51]=L,e[52]=F,e[53]=z,e[54]=W):W=e[54];let U;e[55]!==M||e[56]!==W?(U=r.jsxs(Dn,{children:[_,r.jsxs(zn,{align:"end",sideOffset:6,className:"w-72",children:[M,D,W]})]}),e[55]=M,e[56]=W,e[57]=U):U=e[57];let H;return e[58]!==v||e[59]!==U||e[60]!==k||e[61]!==N?(H=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[v,j,S,k,N,U]}),e[58]=v,e[59]=U,e[60]=k,e[61]=N,e[62]=H):H=e[62],H}const fM=y.memo(function(e){const t=B.c(11),{isMobile:s}=Lt(),{session:o,sessionSource:i}=it();if(!s||!o)return null;let a;t[0]!==i?(a=i?xs(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=vo(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(uM,{...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 mM({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=y.useRef(null),i=y.useRef(null),a=y.useRef(n),l=y.useRef(e);return a.current=n,l.current=e,y.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 pM=["sessions","chat","stats"];function hM({hasSession:n,hasPendingSession:e}){return pM.filter(t=>!(t==="stats"&&!n&&!e))}function eh(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const gM=y.lazy(()=>qe(()=>import("./MobileFileChanges-B1dtcdSZ.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function xM(n){const e=B.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Lt(),{session:c,isSubAgentView:d}=it(),f=!!c,u=!!a.pendingDirName;let m;e[0]!==f||e[1]!==u?(m=hM({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=eh(p,a.mobileTab,1);F&&($c(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{const F=eh(p,a.mobileTab,-1);F&&($c(),t.actions.handleMobileTabChange(F))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=mM(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`,v=i.backgroundServers;let j,S;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Bx,{}),S=r.jsx(Fx,{}),e[10]=j,e[11]=S):(j=e[10],S=e[11]);let k;e[12]!==c||e[13]!==a.mobileTab?(k=!(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(nu,{compact:!0})}),e[12]=c,e[13]=a.mobileTab,e[14]=k):k=e[14];const C=a.mobileTab,N=!(a.mobileTab==="chat"&&c)&&"motion-session-enter";let _;e[15]!==N?(_=V("flex min-h-0 min-w-0 flex-1",N),e[15]=N,e[16]=_):_=e[16];let A;e[17]!==t||e[18]!==a.mobileTab?(A=a.mobileTab==="sessions"&&r.jsx(nb,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=A):A=e[19];let P;e[20]!==i||e[21]!==d||e[22]!==t||e[23]!==o||e[24]!==c||e[25]!==s||e[26]!==a.expandAll||e[27]!==a.mobileTab||e[28]!==a.pendingDirName?(P=a.mobileTab==="chat"&&r.jsx("div",{className:"flex flex-1 min-h-0 flex-col min-w-0",children:c?r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,r.jsx(fM,{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(Wa,{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(ee,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(Hs,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(sb,{navigation:t})}),e[20]=i,e[21]=d,e[22]=t,e[23]=o,e[24]=c,e[25]=s,e[26]=a.expandAll,e[27]=a.mobileTab,e[28]=a.pendingDirName,e[29]=P):P=e[29];let E;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(E=a.mobileTab==="stats"&&c&&r.jsx(E2,{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]=E):E=e[34];let T;e[35]!==a.mobileTab||e[36]!==_||e[37]!==A||e[38]!==P||e[39]!==E?(T=r.jsxs("div",{className:_,children:[A,P,E]},C),e[35]=a.mobileTab,e[36]=_,e[37]=A,e[38]=P,e[39]=E,e[40]=T):T=e[40];let I;e[41]!==g||e[42]!==T?(I=r.jsx("main",{ref:g,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:T}),e[41]=g,e[42]=T,e[43]=I):I=e[43];const $=a.mobileTab==="chat"&&i.processPanel;let R;e[44]!==c||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?(R=a.mobileTab==="chat"&&(c||a.pendingDirName)&&r.jsxs(r.Fragment,{children:[s.todoProgress,c?s.activeComposer:s.pendingComposer]}),e[44]=c,e[45]=s,e[46]=a.mobileTab,e[47]=a.pendingDirName,e[48]=R):R=e[48];let M;e[49]!==$||e[50]!==R?(M=r.jsxs("div",{className:"shrink-0",children:[$,R]}),e[49]=$,e[50]=R,e[51]=M):M=e[51];let D;e[52]!==b||e[53]!==a.mobileTab?(D=r.jsx(dM,{activeTab:a.mobileTab,onTabChange:b}),e[52]=b,e[53]=a.mobileTab,e[54]=D):D=e[54];let O;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?(O=c&&o.hasFileChanges&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(gM,{open:i.fileChangesOpen,onClose:()=>i.onFileChangesOpenChange(!1),session:c,sessionChangeKey:a.sessionChangeKey})}),e[55]=i,e[56]=o,e[57]=c,e[58]=a.sessionChangeKey,e[59]=O):O=e[59];let L;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==k||e[65]!==I||e[66]!==M||e[67]!==D||e[68]!==O||e[69]!==w?(L=r.jsxs("div",{className:w,children:[v,j,S,k,I,M,i.workflowsPanel,D,i.undoDialog,i.branchModal,O]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=k,e[65]=I,e[66]=M,e[67]=D,e[68]=O,e[69]=w,e[70]=L):L=e[70],L}function bM(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}=Lt(),{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(Wa,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),f?i:r.jsx(Ga,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(un,{className:"max-w-md",children:r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:s?r.jsx(sn,{}):r.jsx(rt,{className:"animate-spin"})}),r.jsx(mn,{children:s?"Unable to open session":"Opening session"}),r.jsx(Tn,{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 vM=5;function Ni(n,e){const t=bn(),s=hs();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class yM{constructor(){si(this,"cache",new Map)}get(e,t){const s=Ni(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=Ni(e,t);!this.cache.has(d)&&this.cache.size>=vM&&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=Ni(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(Ni(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 yn=new yM,th={};function ob(n,e,t,s,o,i){const[a,l]=y.useState(!1),[c,d]=y.useState("disconnected"),[f,u]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(th),[x,b]=y.useState(null),[w,v]=y.useState(uo),j=y.useRef(""),S=y.useRef(null),k=y.useRef(uo),C=y.useRef("disconnected"),N=y.useRef(e);N.current=e;const _=y.useRef(o);_.current=o;const A=y.useRef(t);A.current=t;const P=y.useRef(s);P.current=s;const E=y.useRef(i??null);E.current=i??null;const T=y.useRef(!1),I=(n==null?void 0:n.dirName)??null,$=(n==null?void 0:n.fileName)??null,R=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(R).byteLength;return y.useEffect(()=>{if(j.current=R,!R){S.current=null,l(!1);return}const D=E.current;if(D){S.current=D;return}A.current(R).then(O=>{S.current=O})},[R]),y.useEffect(()=>{if(b(null),!I||!$){l(!1),d("disconnected");return}d("connecting");const D=`/api/watch/${encodeURIComponent(I)}/${encodeURIComponent($)}?offset=${M}`,O=new EventSource(Ar(D));let L=null;const F=(ae=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),u(!1)},ae)};let z="",W=M,U=!1,H=!1,K=!1,q=null;const Y=()=>{K=!1,q=null,S.current&&N.current(S.current)},G=()=>{K||(K=!0,q=requestAnimationFrame(Y))};let J=!1,Q=null,X=null;const Z=()=>{J=!1,Q=null,v(k.current)},se=()=>{J||(J=!0,Q=requestAnimationFrame(Z))},ne=ae=>{ae!==k.current&&(k.current=ae,se(),ae.length>0&&!X&&(X=setInterval(()=>{const te=g6(k.current);te!==k.current&&(k.current=te,se()),k.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},re=()=>{ne(uo),g(th)},ie=()=>{if(H||U||!z)return;const ae=z;z="",U=!0;const te=S.current;(te?P.current(te,ae):A.current(j.current)).then(le=>{H||(S.current=le,I&&$&&yn.update(I,$,{parsed:le,source:{rawText:j.current,watchOffset:W}}),G())}).catch(le=>{console.error("[useLiveSession] worker parse failed:",le)}).finally(()=>{U=!1,!H&&z&&ie()})};return O.onopen=()=>{var ae;if(C.current!=="connected"){const te=T.current;T.current=!1,C.current="connected",d("connected"),te&&((ae=_.current)==null||ae.call(_))}},O.onmessage=ae=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const te=JSON.parse(ae.data);if(te.type==="init")te.recentlyActive?(l(!0),F(5e3)):F();else if(te.type==="compacting_in_progress")l(!0),u(!0),re(),F();else if(te.type==="subagent_activity")l(!0),F();else if(te.type==="runtime_activity")l(!0),F();else if(te.type==="stream_snapshot")l(!0),F(),ne(m6(te.messages??[]));else if(te.type==="stream_delta")l(!0),F(),p(null),b(null),ne(p6(k.current,te.events??[]));else if(te.type==="agent_progress")l(!0),F(),g(ue=>({...ue,[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(),ne(h6(k.current,te.lines));const ue=te.lines.join(`
136
+ `)+`
137
+ `;W+=new TextEncoder().encode(ue).byteLength,j.current+=ue,z+=ue,ie()}}catch(te){console.error("[useLiveSession] Error processing SSE message:",te)}},O.onerror=()=>{l(!1),u(!1),T.current=C.current==="connected",C.current="disconnected",d("disconnected"),re()},()=>{H=!0,O.close(),l(!1),C.current="disconnected",d("disconnected"),L&&clearTimeout(L),q!==null&&cancelAnimationFrame(q),Q!==null&&cancelAnimationFrame(Q),X&&clearInterval(X),k.current=uo,v(uo)}},[I,$,R,M]),{isLive:a,sseState:c,isCompacting:f,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:x}}const wM=3e4;function rb(n,e,t){const s=B.c(9),o=wM,[i,a]=y.useState(!1),l=y.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]),y.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(Ar(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]),y.useEffect(f,u);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function jM(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return rb(t,e)}function SM(n,e){const[t,s]=y.useState(null),o=y.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=y.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 y.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),jM((t==null?void 0:t.teamName)??null,a),t}function NM(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),rb(o,s)}function kM(n,e,t=!0){const[s,o]=y.useState([]),[i,a]=y.useState(!1),l=y.useRef(0),c=!!n&&!!e,d=y.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]);y.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const f=c&&(t||s.length>0),{isLive:u}=NM(f?n:null,f?e:null,null,d);return{workflows:s,loading:i,isLive:u,refetch:d}}const na={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},CM="cogpit:permissions";function _M(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 nh(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function ib(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 nh(l,i(l));return!l.ok&&t==="codex"&&e&&_M(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await nh(l,i(l))),{res:l,errorMessage:c}}function TM({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]=y.useState("idle"),[g,x]=y.useState(),[b,w]=y.useState([]),v=y.useRef(null),j=y.useRef(null),S=y.useRef(!1),k=n!=null&&n.fileName?sc(n.fileName):null,C=e||k,N=n?Ct(n.dirName):null,_=y.useCallback(()=>{var R;(R=v.current)==null||R.abort(),v.current=null,S.current=!1,h("idle"),x(void 0),w([])},[]);y.useEffect(()=>{var R;j.current!==C&&(S.current?(S.current=!1,(R=v.current)==null||R.abort(),v.current=null,h("idle"),x(void 0)):_(),j.current=C)},[C,_]),y.useEffect(()=>()=>{var R;(R=v.current)==null||R.abort()},[]),y.useEffect(()=>{u&&_()},[u,_]);const A=y.useCallback(async(R,M)=>{if(u)return;if(!C&&m){w(L=>[...L,R]),h("connected"),x(void 0),S.current=!0,o==null||o();try{if(!await m(R,M)){S.current=!1,h("idle"),w([]);return}h("idle")}catch(L){S.current=!1,x(L instanceof Error?L.message:"Failed to create session"),h("error"),w([])}return}if(!C)return;w(L=>[...L,R]),h("connected"),x(void 0);const D=s??na;o==null||o();const O=new AbortController;v.current=O;try{const L={sessionId:C,message:R,images:M||void 0,cwd:t||void 0,permissions:D,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:F,errorMessage:z}=await ib(W=>ye("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:W}),signal:O.signal}),{model:i,agentKind:N,errorFallback:W=>`Request failed (${W.status})`,onModelRejected:f});v.current===O&&(F.ok?h("idle"):(x(z||`Request failed (${F.status})`),h("error"),w(W=>W.slice(0,-1))))}catch(L){if(L instanceof Error&&L.name==="AbortError")return;v.current===O&&(x(L instanceof Error?L.message:"Unknown error"),h("error"),w(F=>F.slice(0,-1)))}},[C,N,t,s,o,i,a,l,c,d,f,u,m]),P=y.useCallback(()=>{_()},[_]),E=y.useCallback(()=>{!C||u||ye("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,u]),T=y.useCallback(()=>{var R;(R=v.current)==null||R.abort(),v.current=null,E(),h("idle"),w([])},[E]),I=T,$=y.useCallback((R=1)=>{w(M=>M.slice(R))},[]);return{status:p,error:g,pendingMessages:b,sendMessage:A,disconnect:P,interrupt:T,stopAgent:I,consumePending:$,isConnected:p==="connected"}}const is={expandAll:!1,expandToolPayloads:!1},EM={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 sh(n,e,t,s){const o=J0(e,t,s);return o===n.turns?n:{...n,turns:o}}function io(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function AM(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...io(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,...io(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,...io(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:sh(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:sh(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...io(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,...io(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,...io(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 ab(){return y.useReducer(AM,EM)}function oh(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function lb({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialContentLen:i=0}){const a=y.useRef(null),l=y.useRef(null),c=y.useRef(!0),d=y.useRef(!1),f=y.useRef(0),u=y.useMemo(()=>(n==null?void 0:n.turns.flatMap(O=>O.contentBlocks.flatMap(L=>L.kind==="queued_prompt"?[{id:JSON.stringify([L.timestamp??"",L.content]),content:L.content}]:[])))??[],[n==null?void 0:n.turns]),m=y.useRef(null),p=y.useRef(!1),[h,g]=y.useState(!1),[x,b]=y.useState(!1),[w,v]=y.useState(null),j=y.useCallback(()=>{requestAnimationFrame(()=>{var O;(O=l.current)==null||O.scrollIntoView({behavior:"smooth"})})},[]),S=y.useCallback(()=>{oh(()=>{const O=a.current;O&&(O.scrollTop=O.scrollHeight),c.current=!0,d.current=!1})},[]),k=y.useCallback(()=>{p.current=!0},[]),C=y.useRef(!1),N=y.useRef(!1),_=y.useCallback(()=>{const O=a.current;if(!O)return;const L=O.scrollTop>10,F=O.scrollHeight-O.scrollTop-O.clientHeight>10;L!==C.current&&(C.current=L,g(L)),F!==N.current&&(N.current=F,b(F))},[]),A=y.useCallback(()=>{const O=a.current;O&&(c.current=O.scrollHeight-O.scrollTop-O.clientHeight<150,_())},[_]),P=y.useCallback(O=>{f.current=O},[]),E=y.useRef(o);y.useEffect(()=>{if(o===E.current)return;E.current=o;const O=p.current;p.current=!1;const L=()=>{const z=a.current;z&&(O?(z.scrollTop=0,c.current=!1):(z.scrollTop=z.scrollHeight,c.current=!0),d.current=!1)};oh(L);const F=setTimeout(()=>{L(),v(o)},150);return()=>clearTimeout(F)},[o]);const T=t.length;y.useEffect(()=>{T>0&&(d.current=!0,j())},[T,j]),y.useEffect(()=>{const O=(n==null?void 0:n.sessionId)??null,L=m.current,F=new Set(u.map(U=>U.id));if(!L||L.sessionId!==O){m.current={sessionId:O,ids:F};return}const z=u.filter(U=>!L.ids.has(U.id));if(m.current={sessionId:O,ids:F},z.length===0||T===0)return;let W=0;for(const U of z){const H=t[W];(H===U.content||(H==null?void 0:H.trim())===""&&U.content.length>0)&&W++}W>0&&s(W)},[n==null?void 0:n.sessionId,u,t,T,s]);const I=(n==null?void 0:n.turns.length)??0;y.useEffect(()=>{if(I===0)return;const O=I-f.current;O>0&&(T>0&&s(Math.min(O,T)),(d.current||c.current)&&(j(),d.current=!1)),f.current=I},[I,T,s,j]);const $=n==null?void 0:n.turns.at(-1),R=($==null?void 0:$.toolCalls.length)??0,M=($==null?void 0:$.assistantText.length)??0;y.useEffect(()=>{if(!(!n||!e)){if(c.current){const O=a.current;O&&(O.scrollTop=O.scrollHeight)}requestAnimationFrame(_)}},[I,R,M,i,e,_]);const D=w===o;return y.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:x,initialScrollDone:D,handleScroll:A,scrollToBottomInstant:S,requestScrollToTop:k,resetTurnCount:P}),[h,x,D,A,S,k,P])}async function cb(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(`
138
+ `);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 Bs(n,e,t,s){const o=yn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=bn(),a=hs(),{parsed:l,source:c,byteOffset:d,hasMore:f}=await cb(n,e,t,s);if(bn()!==i||hs()!==a)return{parsed:l,source:c};const u=yn.get(n,e);return u?{parsed:u.parsed,source:u.source}:(yn.set(n,e,l,c.rawText,d,f,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function db(n,e,t,s){yn.evict(n,e);const o=bn(),i=hs(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await cb(n,e,t,s);return bn()===o&&hs()===i&&yn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function PM({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=y.useState(null),f=y.useCallback((b,w)=>{d(null),y.startTransition(()=>{n({type:"LOAD_SESSION",session:b,source:w,isMobile:e})}),i(b.turns.length),E$(b.sessionId,b.turns.length),o()},[n,e,i,o]),u=y.useCallback(async(b,w)=>{l==null||l(),d(null);try{const{parsed:v,source:j}=await Bs(b,w,a,"session");f(v,j)}catch(v){d(v instanceof Error?v.message:"Failed to load session")}},[f,a,l]),m=y.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:v,fileName:j}=await w.json(),{parsed:S,source:k}=await Bs(v,j,a,`session for ${b.name}`);y.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:S,source:k,memberName:b.name})}),i(S.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=y.useCallback(()=>d(null),[]),h=y.useCallback(()=>{y.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=y.useCallback((b,w)=>{n({type:"JUMP_TO_TURN",index:b,toolCallId:w})},[n]),x=y.useCallback(b=>{b!==t&&y.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 IM=/^\/preview\/([^/]+)\/?$/;function xu(n){const e=IM.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function ub(){const n=gt();return n===jt?"":`/d/${n}`}function Mc(){const n=ub();return n?`${n}/`:"/"}function fb(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function RM(n,e){return C3(n,e)}function $M(n){const e=ub();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=k3(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:Mc()}function rh(n){const e=fb(n),t=xu(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 MM({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=y.useState(null),c=y.useRef(0),d=y.useRef(window.location.pathname),f=y.useRef(!1),u=y.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 Bs(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=RM(m.dirName,m.sessionId);let h;try{h=await Bs(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=Mc();window.history.replaceState(null,"",g),d.current=g,Ro(gt(),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=Mc();window.history.replaceState(null,"",p),d.current=p,Ro(gt(),p)}}finally{c.current--}},[e,t,s,o,i]);return y.useEffect(()=>{if(f.current)return;f.current=!0,Ro(gt(),window.location.pathname);const m=rh(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&u(m)},[u]),y.useEffect(()=>{if(c.current>0||xu(fb(window.location.pathname)))return;const m=$M(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,Ro(gt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),y.useEffect(()=>{const m=()=>{const p=rh(window.location.pathname);d.current=window.location.pathname,Ro(gt(),window.location.pathname),u(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[u]),{previewLoadError:a}}const OM=400;function ih(){return Array.from(document.querySelectorAll("[data-live-session]"))}function DM(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 ah(n){n.focus({preventScroll:!0});const e=DM(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 LM(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:v}=n;let j,S;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==v||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 k=!1,C=!1,N=null;const _=function(T){var M,D;const I=Tp("missionControl");if(I){if(T.key===I){T.repeat||(k=!0,C=T.shiftKey||T.altKey||(I==="Meta"?T.ctrlKey:T.metaKey));return}k&&(C=!0),N=null}if(wt("commandPalette",T)){T.preventDefault(),d==null||d();return}if(wt("integratedTerminal",T)){if(!lt("terminal"))return;T.preventDefault(),p();return}if(wt("preview",T)){T.preventDefault(),h();return}if(wt("projectFiles",T)){if(!lt("hostFiles"))return;T.preventDefault(),g();return}if(wt("expandAll",T)){T.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(wt("expandToolPayloads",T)){T.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(wt("toggleSidebar",T)){T.preventDefault(),a();return}if(wt("toggleStats",T)){T.preventDefault(),l();return}if(wt("missionControl",T)){T.preventDefault(),c();return}if(wt("newSession",T)&&(T.preventDefault(),f()),wt("themeSelector",T)&&(T.preventDefault(),u()),wt("systemTerminal",T)){if(!lt("terminal"))return;T.preventDefault(),m()}if(T.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(M=s.current)==null||M.blur()),(T.metaKey||T.ctrlKey)&&T.shiftKey&&T.code.startsWith("Digit")){const O=parseInt(T.code.charAt(5),10);if(O>=1&&O<=9){T.preventDefault();const F=ih()[O-1];F&&(ah(F),F.click())}}const $=wt("recentSessionForward",T);if($||wt("recentSessionBack",T)){T.preventDefault();const O=$?b():x();O&&w(O.dirName,O.fileName)}wt("focusComposer",T)&&!t2(document.activeElement)&&(T.preventDefault(),(D=o.current)==null||D.focus());const R=wt("nextLiveSession",T);if(R||wt("prevLiveSession",T)){T.preventDefault();const O=ih();if(O.length===0)return;const L=O.findIndex(zM);let F;L===-1?F=R?0:O.length-1:F=Math.max(0,Math.min(O.length-1,L+(R?1:-1))),ah(O[F])}},A=function(T){const I=Tp("missionControl");if(I&&T.key===I&&k){const $=!C;if(k=!1,C=!1,$){const R=Date.now();N!==null&&R-N<=OM?(N=null,T.preventDefault(),c()):N=R}else N=null}T.key==="Control"&&(v==null||v())},P=function(){k=!1,C=!1,N=null};return window.addEventListener("keydown",_),window.addEventListener("keyup",A),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",_),window.removeEventListener("keyup",A),window.removeEventListener("blur",P)}},S=[t,s,o,i,a,l,c,d,f,u,m,p,h,g,x,b,w,v],e[0]=o,e[1]=i,e[2]=t,e[3]=v,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]=S):(j=e[18],S=e[19]),y.useEffect(j,S)}function zM(n){return n===document.activeElement}const lh="cogpit-theme",JD=[{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 FM(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function mb(){const[n,e]=y.useState(()=>{try{const l=localStorage.getItem(lh);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=y.useState(null),o=y.useCallback(l=>{localStorage.setItem(lh,l),e(l),s(null)},[]),i=t??n,a=FM(i);return y.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 BM="cogpit-session-history",Oc=50;function pb(){return Ut(BM)}function UM(){try{const n=localStorage.getItem(pb());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,Oc)}catch{}return[]}function ch(n){try{localStorage.setItem(pb(),JSON.stringify(n))}catch{}}function WM(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=UM(),n[0]=e):e=n[0];const t=y.useRef(e),s=y.useRef(0),o=y.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>Oc&&(t.current.length=Oc),s.current=0,ch(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),ch(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 hb(){return Ut(CM)}function dh(){try{const n=localStorage.getItem(hb());if(n){const e=JSON.parse(n);return{mode:e.mode||na.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return na}function HM(n){localStorage.setItem(hb(),JSON.stringify(n))}function KM(){const n=B.c(21),[e,t]=y.useState(dh),[s,o]=y.useState(dh),i=y.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}HM(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),y.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=S=>{t(k=>({...k,mode:S}))},n[10]=f):f=n[10];const u=f;let m;n[11]===Symbol.for("react.memo_cache_sentinel")?(m=S=>{t(k=>{const C=k.allowedTools.includes(S);return{...k,allowedTools:C?k.allowedTools.filter(N=>N!==S):[...k.allowedTools,S]}})},n[11]=m):m=n[11];const p=m;let h;n[12]===Symbol.for("react.memo_cache_sentinel")?(h=S=>{t(k=>{const C=k.disallowedTools.includes(S);return{...k,disallowedTools:C?k.disallowedTools.filter(N=>N!==S):[...k.disallowedTools,S]}})},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(na)},n[15]=w):w=n[15];const v=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:v},n[16]=s,n[17]=e,n[18]=d,n[19]=b,n[20]=j):j=n[20],j}const qM=2e3;function VM(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function GM(n){const[e,t]=y.useState([]),[s,o]=y.useState(null),[i,a]=y.useState(new Set);y.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=>VM(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,qM);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=y.useCallback(async(d,f)=>{if(n){a(u=>new Set(u).add(d));try{await G2(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=y.useCallback(async d=>{if(n)try{await x$(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function YM(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 XM(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 JM(n){return n.file_path??n.path??""}function gb(n){const e=[];for(const t of n.toolCalls){if(t.isError||P8(t))continue;const s=JM(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 QM(n,e){return{index:e,userMessage:Ma(n.userMessage),toolCalls:gb(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function sa(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=gb(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 ZM(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 sr(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(...ZM(i.toolCalls,i.index))}return t}function xb(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(QM(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 bb(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 vb(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 eO(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 tO(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function ki(n,e){return n.length>0?eO(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function yb(n,e,t){return Sx(vx(Ct(t)),n,e)}function wb(n,e,t,s){const o=vx(Ct(s)),i=e==null?void 0:e.id;if(i){const a=_C(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return Sx(o,n,t)}class Xo extends Error{constructor(){super("abort")}}async function nO(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=sa(e.turns,e.turns.length-1,l),d=l+1,f=o.split(`
139
+ `).filter(Boolean),u=wb(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 Xo;const{retained:p,scooped:h}=bb(s.branches,l),g=xb(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},b=vo(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 sO(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=sr(s.turns,l),f=a?yb(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:v}=vb(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:v.length>0?v:void 0};h=[...t.branches.map(S=>S.id===s.id?j:S),...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(`
140
+ `).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:u,expectedLineCount:x.length},state:g})}async function oO(n,e,t,s,o,i,a){var j;let l=[...t.branches],c=o.split(`
141
+ `).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const S=sa(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...S);const{retained:k,scooped:C}=bb(l,s.branchPointTurnIndex);l=k;const N=s.branchPointTurnIndex+1,_=wb(c,n.turns[s.branchPointTurnIndex],N,e.dirName),A=c.slice(_);if(A.length>0){const P=xb(n.turns,s.branchPointTurnIndex,A,C);l=[...l,P],c=c.slice(0,_)}}const f=i.branchTurnIndex??s.turns.length-1,u=f+1,m=f<s.turns.length-1,p=sr(s.turns,f);d.push(...p);const h=m?yb(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:S,remaining:k}=vb(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:k.length>0?k:void 0},...S]}else w=b;const v={...t,currentTurnIndex:s.branchPointTurnIndex+u,totalTurns:s.branchPointTurnIndex+1+u,branches:[...l.filter(S=>S.id!==s.id),...w],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
142
+ `).filter(Boolean).length},state:v})}const rO=[];function jb(n,e,t,s=!0){const[o,i]=y.useState(null),[a,l]=y.useState(null),[c,d]=y.useState(!1),[f,u]=y.useState(null),m=y.useRef(null),p=y.useRef(0);y.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,!vo(e==null?void 0:e.dirName).redo){i(null);return}const P=n.sessionId,E=new AbortController;return ye(`/api/undo-state/${encodeURIComponent(P)}`,{signal:E.signal}).then(T=>T.ok?T.json():null).then(T=>{m.current===P&&i(T??null)}).catch(T=>{T instanceof Error&&T.name==="AbortError"||m.current===P&&i(null)}),()=>E.abort()},[s,n==null?void 0:n.sessionId]);const h=y.useCallback(async P=>{try{const E=await ye("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:P.operations,session:{dirName:P.sessionSource.dirName,fileName:P.sessionSource.fileName,mutation:P.sessionMutation},state:P.state,checkpoint:P.checkpoint})}),T=await E.json().catch(()=>null);if(!E.ok)throw u((T==null?void 0:T.error)||"Undo transaction failed"),new Xo;i(P.state)}catch(E){throw E instanceof Xo?E:(u(String(E)),new Xo)}},[]),g=(o==null?void 0:o.branches)??rO,{canRedo:x,redoTurnCount:b,redoBranch:w}=y.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let P=g.length-1;P>=0;P--){const E=g[P];if(E.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:E.turns.length,redoBranch:E}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),v=y.useMemo(()=>{if(!w||w.jsonlLines.length===0)return[];try{return $a(w.jsonlLines.join(`
143
+ `)).turns}catch{return[]}},[w]),j=y.useCallback(P=>g.filter(E=>E.branchPointTurnIndex===P),[g]),S=y.useCallback(P=>{if(!s||!n)return;const E=P-1;if(E>=n.turns.length-1||E<-1)return;if(vo(e==null?void 0:e.dirName).nativeRewind){const I=n.turns[P];if(!I)return;const $=n.sessionId,R=++p.current,M=()=>p.current===R&&m.current===$,D=I.id.includes("@")?I.id.slice(I.id.lastIndexOf("@")+1):I.id,O=n.turns.length-P;YM(n.sessionId,D).then(L=>{var W;if(!M())return;const F=((W=L==null?void 0:L.files)==null?void 0:W.map(({path:U})=>U).filter(U=>typeof U=="string"))??[],z=L!=null&&L.available?L.fileCount??F.length:0;l({type:"undo",summary:{turnCount:O,fileCount:z,filePaths:F,operationCount:z},targetTurnIndex:E,nativeRewind:{eventId:D,mode:"conversation",filesAvailable:!!(L!=null&&L.available&&z>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:O,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:E,nativeRewind:{eventId:D,mode:"conversation"}})});return}const T=sa(n.turns,n.turns.length-1,E);l({type:"undo",summary:ki(T,n.turns.length-1-E),targetTurnIndex:E})},[s,n,e==null?void 0:e.dirName]),k=y.useCallback(()=>{if(!s||!x||!w||!n)return;const P=sr(w.turns);l({type:"redo",summary:ki(P,w.turns.length),targetTurnIndex:w.branchPointTurnIndex+w.turns.length,branchId:w.id})},[s,x,w,n]),C=y.useCallback(P=>{if(!s||!x||!w||!n)return;const E=P+1,T=sr(w.turns,P);l({type:"redo",summary:ki(T,E),targetTurnIndex:w.branchPointTurnIndex+E,branchId:w.id,redoUpToArchiveIndex:P})},[s,x,w,n]),N=y.useCallback((P,E)=>{if(!s||!n)return;const T=g.find(M=>M.id===P);if(!T)return;const I=E??T.turns.length-1,$=n.turns.length>T.branchPointTurnIndex+1?sa(n.turns,n.turns.length-1,T.branchPointTurnIndex):[],R=sr(T.turns,I);l({type:"branch-switch",summary:ki([...$,...R],I+1),targetTurnIndex:T.branchPointTurnIndex,branchId:P,branchTurnIndex:I})},[s,n,g]),_=y.useCallback(async(P=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),u(null);try{if(a.nativeRewind){const $=P&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",R=await XM(n.sessionId,a.nativeRewind.eventId,$);if(!R.ok){u(R.error);return}await t(),l(null);return}const E=o??tO(n.sessionId,n.turns.length),T=await ye(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!T.ok){u("Failed to read session file");return}const I=await T.text();if(a.type==="undo")await nO(a,n,e,E,I,h,u);else if(a.type==="redo"){const $=g.find(R=>R.id===a.branchId);if(!$){l(null);return}await sO(a,e,E,$,I,h)}else if(a.type==="branch-switch"){const $=g.find(R=>R.id===a.branchId);if(!$){l(null);return}await oO(n,e,E,$,I,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(E){if(!(E instanceof Xo))throw E}finally{d(!1)}},[s,a,n,e,o,g,h,t]),A=y.useCallback(()=>{p.current+=1,l(null),u(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:b,redoGhostTurns:v,branches:g,branchesAtTurn:j,requestUndo:S,requestRedoAll:k,requestRedoUpTo:C,requestBranchSwitch:N,confirmState:a,confirmApply:_,confirmCancel:A,isApplying:c,applyError:f}}async function iO(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 uh(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:N3(t==null?void 0:t.mode,qs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function aO(){const n=B.c(26),[e,t]=y.useState(!0),[s,o]=y.useState(null),[i,a]=y.useState(null),[l,c]=y.useState(qs),[d,f]=y.useState(!1),[u,m]=y.useState(null),[p,h]=y.useState(!1),[g,x]=y.useState(0),b=y.useRef(null),w=y.useRef(null);let v;n[0]===Symbol.for("react.memo_cache_sentinel")?(v=U=>{a(U.claudeDir),c(U.defaultAgentKind),c5(U.useBuiltInEditor)},n[0]=v):v=n[0];const j=v;let S;n[1]===Symbol.for("react.memo_cache_sentinel")?(S=async()=>{var K;(K=b.current)==null||K.abort();const U=new AbortController;b.current=U;const H=await iO(U.signal);U.signal.aborted||b.current!==U||(m(H.url),h(H.disabled))},n[1]=S):S=n[1];const k=S;let C,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{var U,H;(U=b.current)==null||U.abort(),(H=w.current)==null||H.abort()},N=[],n[2]=C,n[3]=N):(C=n[2],N=n[3]),y.useEffect(C,N);let _;n[4]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const U=new AbortController;return t(!0),o(null),uh(U.signal).then(j).catch(H=>{H instanceof Error&&H.name==="AbortError"||(a(null),o(H instanceof Error?H.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||t(!1)}),()=>U.abort()},n[4]=_):_=n[4];let A;n[5]!==g?(A=[j,g],n[5]=g,n[6]=A):A=n[6],y.useEffect(_,A);let P,E;n[7]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const U=()=>x(cO);return window.addEventListener("cogpit-auth-changed",U),()=>window.removeEventListener("cogpit-auth-changed",U)},E=[],n[7]=P,n[8]=E):(P=n[7],E=n[8]),y.useEffect(P,E);let T;n[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{k()},n[9]=T):T=n[9];let I;n[10]!==i?(I=[i,k],n[10]=i,n[11]=I):I=n[11],y.useEffect(T,I);let $;n[12]===Symbol.for("react.memo_cache_sentinel")?($=()=>f(!1),n[12]=$):$=n[12];const R=$;let M;n[13]!==i?(M=U=>{if(f(!1),U!==i){a(U),window.location.reload();return}x(lO),k()},n[13]=i,n[14]=M):M=n[14];const D=M;let O;n[15]===Symbol.for("react.memo_cache_sentinel")?(O=()=>f(!0),n[15]=O):O=n[15];const L=O;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{var H;(H=w.current)==null||H.abort();const U=new AbortController;w.current=U,t(!0),o(null),uh(U.signal).then(K=>{U.signal.aborted||w.current!==U||j(K)}).catch(K=>{U.signal.aborted||w.current!==U||(a(null),o(K instanceof Error?K.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||w.current!==U||t(!1)})},n[16]=F):F=n[16];const z=F;let W;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==D||n[22]!==p||n[23]!==u||n[24]!==d?(W={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:L,handleCloseConfigDialog:R,handleConfigSaved:D,retryConfig:z,networkUrl:u,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=D,n[22]=p,n[23]=u,n[24]=d,n[25]=W):W=n[25],W}function lO(n){return n+1}function cO(n){return n+1}const fh={authenticated:!0,edition:"personal",user:null,capabilities:Na},hn={authenticated:!1,edition:"personal",user:null,capabilities:Mr},Sb=Object.keys(Na);function mh(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Sb.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function dO(n,e){const t={...Mr};for(const s of Sb)t[s]=n[s]&&e[s];return t}async function ph(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function uO(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 Fo(n){var e;return fo(n),pg(((e=n.user)==null?void 0:e.id)??null),n}function fO(n){const e=B.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...hn,checked:!1},e[0]=t):t=e[0];const[s,o]=y.useState(t),[i,a]=y.useState(0),l=y.useRef(null),c=y.useRef(!1);let d;e[1]!==n?(d=()=>{var v;if((v=l.current)==null||v.abort(),n===null){c.current=!1,fo(hn),o({...hn,checked:!1});return}const p=c.current;c.current=!1,fo(hn),o(j=>p?{...j,capabilities:Mr,checked:!1}:{...hn,checked:!1});const h=new AbortController;l.current=h;const g=Ds(),x=ph(as,h.signal),b=g?uO(h.signal):Promise.resolve(n),w=g?ph(ye,h.signal):Promise.resolve(null);return Promise.all([x,b,w]).then(j=>{const[S,k,C]=j;if(h.signal.aborted)return;const N=mh(S,n)?S:n==="personal"?fh:null;if(!N||k===null){o({...Fo(hn),checked:!1});return}if(!g){o({...Fo(N),checked:!0});return}const _=mh(C,k)?C:k==="personal"?fh:null;if(!_){o({...Fo(hn),checked:!1});return}o({...Fo({authenticated:N.authenticated,edition:N.edition,user:N.user,capabilities:dO(N.capabilities,_.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Fo(hn),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],y.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,fo(hn),pg(null),o({...hn,checked:!1}),a(hO)},h=g=>{var w,v;const x=gt();if(x===jt)return;const b=(w=g.detail)==null?void 0:w.deviceId;b&&b!==x||((v=l.current)==null||v.abort(),c.current=!0,fo(hn),o(pO),a(mO))};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]),y.useEffect(u,m),s}function mO(n){return n+1}function pO(n){return{...n,capabilities:Mr,checked:!1}}function hO(n){return n+1}const gO=3e4;function xO(n){const[e,t]=y.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=y.useRef(0),o=y.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]);y.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),gO);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 bO(){const n=B.c(3),[e,t]=y.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 vO(n,e){return n?`${n}.jsonl`:e??null}async function Nb(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 yO=300,Xl=new Map;function Dc(n,e){const t=Ut(n),s=Xl.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{Xl.delete(t),Ut(n)===t&&(async()=>{try{await ye(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},yO);Xl.set(t,{patch:o,timer:i})}function Lc(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function hh(n){const e=await Nb(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function gh(n,e){Dc(n,{mcpServers:e})}async function wO(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function xh(n,e){try{const t=await ye(n,{signal:e});if(e.aborted)return null;const s=await wO(t);return e.aborted?null:s}catch{return null}}async function bh(n,e,t){const s=Lc(t);if(s.size===0)return[];if(n){const o=await hh(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await hh(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function jO(n,e,t,s=!0){const[o,i]=y.useState([]),[a,l]=y.useState({}),[c,d]=y.useState([]),[f,u]=y.useState(!1),[m,p]=y.useState(!1),h=y.useRef(null),g=y.useRef(e);g.current=e;const x=t??e??null,b=y.useRef(x);b.current=x;const w=y.useRef(void 0);y.useEffect(()=>{var C,N;if(!s||!n){(C=h.current)==null||C.abort(),w.current=void 0,i([]),l({}),d([]),u(!1),p(!1);return}const k=new AbortController;return(N=h.current)==null||N.abort(),i([]),l({}),d([]),u(!0),p(!1),w.current=n,xh(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,k.signal).then(async _=>{if(k.signal.aborted||w.current!==n||!_)return;i(_.servers),l(_.configs);const A=await bh(b.current,g.current,_.servers);k.signal.aborted||w.current!==n||d(A)}).finally(()=>{k.signal.aborted||w.current!==n||(u(!1),p(!0))}),()=>k.abort()},[n,s]),y.useEffect(()=>()=>{var k;return(k=h.current)==null?void 0:k.abort()},[]),y.useEffect(()=>{if(o.length===0||!x)return;let k=!1;return bh(x,e,o).then(C=>{k||b.current!==x||d(C)}),()=>{k=!0}},[x]);const v=y.useCallback(k=>{d(C=>{const N=C.includes(k)?C.filter(_=>_!==k):[...C,k];return b.current&&gh(b.current,N),N})},[]),j=y.useCallback(()=>{var C;if(!s||!n)return;(C=h.current)==null||C.abort();const k=new AbortController;h.current=k,u(!0),xh(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,k.signal).then(N=>{if(k.signal.aborted||w.current!==n||!N)return;i(N.servers),l(N.configs);const _=Lc(N.servers);d(A=>{const P=A.filter(E=>_.has(E));return b.current&&gh(b.current,P),P})}).finally(()=>{k.signal.aborted||h.current!==k||u(!1)})},[n,s]),S=y.useMemo(()=>{if(o.length===0)return null;const k=Lc(o);if(c.length===k.size&&k.size>0&&c.every(_=>k.has(_))||!c.every(_=>a[_]))return null;const N=Object.fromEntries(c.map(_=>[_,a[_]]));return JSON.stringify({mcpServers:N})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:S,loading:f,loaded:m,toggleServer:v,refresh:j}}function SO(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 v=((o=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:o[1])??String(h);p.set(v,{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,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 v=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,{...v,content:b.subject||b.description||v.content,activeForm:b.activeForm||v.activeForm,status:b.status||v.status,owner:b.owner??v.owner,blockedBy:b.addBlockedBy?[...new Set([...v.blockedBy??[],...b.addBlockedBy])]:v.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(kO),e[4]=l,e[5]=c):c=e[5];const d=c.length;let f;e[6]!==l?(f=l.find(NO)??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 NO(n){return n.status==="in_progress"}function kO(n){return n.status==="completed"}function CO(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]=y.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]),y.useEffect(i,a),s}function _O(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]=y.useState(o),[l,c]=y.useState(!1),d=y.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(TO).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]),y.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 TO(n){return n.json()}function vh(n,e){const t=B.c(6),[s,o]=Ur(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 yh(){if(typeof window>"u")return _t.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return _t.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return _t.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return _t.fileChanges}function EO(n,e){const t=B.c(46),[s,o]=vh("panel-sidebar-visible",!0),[i,a]=vh("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=yh(),t[0]=l):l=t[0];const[c,d]=Ur("workspace-panel-active",l);let f;t[1]!==c?(f=typeof c=="string"||c===null?c:yh(),t[1]=c,t[2]=f):f=t[2];const u=f,[m,p]=y.useState(!1),[h,g]=y.useState(!1);let x;t[3]!==o||t[4]!==s?(x=()=>{y.startTransition(()=>o(!s))},t[3]=o,t[4]=s,t[5]=x):x=t[5];const b=x;let w;t[6]!==a?(w=()=>a(PO),t[6]=a,t[7]=w):w=t[7];const v=w;let j;t[8]!==e||t[9]!==d||t[10]!==n.mainView?(j=H=>{y.startTransition(()=>{const K=n.mainView==="config"||n.mainView==="mission";n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(q=>K||q!==H?H:null)})},t[8]=e,t[9]=d,t[10]=n.mainView,t[11]=j):j=t[11];const S=j;let k;t[12]!==e||t[13]!==d||t[14]!==n.mainView?(k=H=>{y.startTransition(()=>{n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(H)})},t[12]=e,t[13]=d,t[14]=n.mainView,t[15]=k):k=t[15];const C=k;let N;t[16]!==d?(N=()=>{y.startTransition(()=>d(null))},t[16]=d,t[17]=N):N=t[17];const _=N;let A;t[18]!==e||t[19]!==n.mainView?(A=()=>{const H=n.mainView==="config";y.startTransition(()=>{e({type:H?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[18]=e,t[19]=n.mainView,t[20]=A):A=t[20];const P=A;let E;t[21]!==e||t[22]!==n.mainView?(E=()=>{const H=n.mainView==="mission";y.startTransition(()=>{e({type:H?"CLOSE_MISSION":"OPEN_MISSION"})})},t[21]=e,t[22]=n.mainView,t[23]=E):E=t[23];const T=E;let I;t[24]!==e?(I=H=>{y.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:H})})},t[24]=e,t[25]=I):I=t[25];const $=I;let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R=()=>p(!0),t[26]=R):R=t[26];const M=R;let D;t[27]===Symbol.for("react.memo_cache_sentinel")?(D=()=>p(!1),t[27]=D):D=t[27];const O=D;let L;t[28]===Symbol.for("react.memo_cache_sentinel")?(L=()=>g(AO),t[28]=L):L=t[28];const F=L;let z;t[29]===Symbol.for("react.memo_cache_sentinel")?(z=()=>g(!1),t[29]=z):z=t[29];const W=z;let U;return t[30]!==u||t[31]!==_||t[32]!==$||t[33]!==P||t[34]!==T||t[35]!==b||t[36]!==v||t[37]!==C||t[38]!==o||t[39]!==a||t[40]!==m||t[41]!==s||t[42]!==h||t[43]!==i||t[44]!==S?(U={showSidebar:s,showWorkflows:i,activeWorkspacePanel:u,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:b,handleToggleWorkflows:v,toggleWorkspacePanel:S,openWorkspacePanel:C,closeWorkspacePanel:_,handleToggleConfig:P,handleToggleMission:T,handleEditConfig:$,handleOpenProjectSwitcher:M,handleCloseProjectSwitcher:O,handleToggleThemeSelector:F,handleCloseThemeSelector:W,setShowSidebar:o,setShowWorkflows:a},t[30]=u,t[31]=_,t[32]=$,t[33]=P,t[34]=T,t[35]=b,t[36]=v,t[37]=C,t[38]=o,t[39]=a,t[40]=m,t[41]=s,t[42]=h,t[43]=i,t[44]=S,t[45]=U):U=t[45],U}function AO(n){return!n}function PO(n){return!n}function IO(n){var K;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:o,markPermissionsApplied:i,hasPermsPendingChanges:a,permissionsConfig:l,selectedModel:c,selectedEffort:d,fastMode:f,ultracode:u,mcpConfig:m,scrollRequestScrollToTop:p,handleDashboardSelect:h,workerParse:g}=n,x=y.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:q,fileName:Y}=e.sessionSource;try{const{parsed:G,source:J}=await db(q,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:G,source:J})}catch{}},[e.sessionSource,t,g]),[b,w]=y.useState(null),v=y.useCallback(q=>w(q),[]),j=y.useCallback(()=>w(null),[]),S=y.useCallback(async(q,Y)=>{try{const G=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:Y})});if(!G.ok)return;const J=await G.json(),{parsed:Q,source:X}=await Bs(J.dirName,J.fileName,g,"session");t({type:"LOAD_SESSION",session:Q,source:X,isMobile:s})}catch{}},[t,s,g]),k=y.useCallback(()=>{e.sessionSource&&S(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,S]),C=y.useCallback(async(q,Y)=>{try{await ye("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:Y})})}catch{}},[]),N=y.useCallback(async q=>{var Q,X;if(!e.sessionSource)return;const{dirName:Y,fileName:G}=e.sessionSource,J=(X=(Q=e.session)==null?void 0:Q.turns[q])==null?void 0:X.id;try{const Z=await ye("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:G,turnIndex:q,turnUuid:J})});if(!Z.ok)return;const se=await Z.json(),{parsed:ne,source:re}=await Bs(se.dirName,se.fileName,g,"session");t({type:"LOAD_SESSION",session:ne,source:re,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),_=y.useCallback((q,Y)=>{o(q,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[A,P]=y.useState({}),E=y.useRef(c);E.current=c;const T=y.useRef(d);T.current=d;const I=y.useRef(m);I.current=m;const $=y.useRef(f);$.current=f;const R=y.useRef(u);R.current=u;const M=y.useRef(l);M.current=l;const D=((K=e.session)==null?void 0:K.sessionId)??null,O=y.useRef(null);y.useEffect(()=>{D!==O.current&&(O.current=D,D&&P(q=>D in q?q:{...q,[D]:{model:E.current,effort:T.current,fastMode:$.current,ultracode:R.current,mcpConfig:I.current}}))},[D]);const L=D?A[D]:void 0,F=m!==((L==null?void 0:L.mcpConfig)??null),z=L!=null&&(c!==L.model||d!==L.effort||f!==L.fastMode||u!==L.ultracode||a||F),W=y.useCallback(async()=>{var se,ne;if(!D)return;const q=E.current,Y=T.current,G=$.current,J=R.current,Q=I.current,X=M.current,Z=((se=e.sessionSource)==null?void 0:se.agentKind)??Ct(((ne=e.sessionSource)==null?void 0:ne.dirName)??null);Ht(Z).settingsApply==="live"&&await ye(`/api/claude/settings/${encodeURIComponent(D)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:q,effort:Y,fastMode:G,ultracode:J,mcpConfig:Q,permissionMode:X.mode,allowedTools:X.allowedTools,disallowedTools:X.disallowedTools})}),P(re=>({...re,[D]:{model:q,effort:Y,fastMode:G,ultracode:J,mcpConfig:Q}})),i()},[D,e.sessionSource,i]),U=y.useCallback(async()=>{if(D)try{await ye("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:D})})}catch{}},[D]),H=y.useCallback((q,Y)=>{xs(Y)&&p(),h(q,Y)},[p,h]);return{reloadSession:x,branchModalTurn:b,setBranchModalTurn:w,handleOpenBranches:v,handleCloseBranchModal:j,handleDuplicateSessionByPath:S,handleDuplicateSession:k,handleDeleteSession:C,handleBranchFromHere:N,handleMobileJumpToTurn:_,hasSettingsChanges:z,handleApplySettings:W,handleStopSession:U,handleLoadSessionScrollAware:H}}function kb(){const n=B.c(6),e=y.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=y.useRef(t),o=y.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]),y.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(()=>$a(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(()=>PC(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 RO=30;function Cb({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(""),f=y.useRef(null),u=`${n??""}::${e??""}::${t}`;return y.useEffect(()=>{d.current=u,f.current=null,c(!1);const p=n&&e?yn.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:y.useCallback(async()=>{if(!n||!e||f.current)return 0;const p=`${n}::${e}::${t}`,h=yn.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=${RO}`);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 yn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),j=b.lines.filter(C=>!v.has(C)),S=await s([...b.headerLines,...j].join(`
144
+ `)),k=J0(h.olderTurns,S.turns,h.source.agentKind);return yn.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset,olderTurns:k}),d.current!==p?0:(o(k),S.turns.length)}finally{f.current===g&&(f.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function $O(n){const e=B.c(50),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??qs,c=vg(l),[d,f]=y.useState(""),[u,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(!1),b=d||(s==null?void 0:s.model);let w;e[0]!==l||e[1]!==b?(w=F3(l,b),e[0]=l,e[1]=b,e[2]=w):w=e[2];const v=w,j=g&&v;let S;e[3]!==l||e[4]!==u||e[5]!==d||e[6]!==j?(S=j?"xhigh":ga(l,u,d),e[3]=l,e[4]=u,e[5]=d,e[6]=j,e[7]=S):S=e[7];const k=S;let C;e[8]!==l||e[9]!==d?(C=cg(l,d),e[8]=l,e[9]=d,e[10]=C):C=e[10];const N=!!C,_=N&&p;let A;e[11]!==l||e[12]!==d?(A=L3(l,d),e[11]=l,e[12]=d,e[13]=A):A=e[13];const P=A,[E,T]=y.useState(null),I=y.useRef(null),$=(o==null?void 0:o.fileName)??null,R=y.useRef($);let M,D;e[14]!==$?(M=()=>{const Z=R.current;R.current=$,!(Z===null||Z===$)&&x(!1)},D=[$],e[14]=$,e[15]=M,e[16]=D):(M=e[15],D=e[16]),y.useEffect(M,D);let O,L;e[17]!==i?(O=()=>{i&&x(!1)},L=[i],e[17]=i,e[18]=O,e[19]=L):(O=e[18],L=e[19]),y.useEffect(O,L);let F;e[20]!==l?(F=Z=>{f(se=>se===Z?"":se),T(`${Z} is unavailable for this account. Cogpit retried the turn with ${on(l).displayName}'s default model.`)},e[20]=l,e[21]=F):F=e[21];const z=F;let W;e[22]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{T(null)},e[22]=W):W=e[22];const U=W;let H,K;e[23]!==c||e[24]!==i||e[25]!==d||e[26]!==o?(H=()=>{d&&(!o&&!i||c.some(Z=>Z.value===d)||f(""))},K=[c,d,o,i],e[23]=c,e[24]=i,e[25]=d,e[26]=o,e[27]=H,e[28]=K):(H=e[27],K=e[28]),y.useEffect(H,K);let q,Y;e[29]!==E?(q=()=>{if(!E)return;const Z=setTimeout(()=>T(null),12e3);return()=>clearTimeout(Z)},Y=[E],e[29]=E,e[30]=q,e[31]=Y):(q=e[30],Y=e[31]),y.useEffect(q,Y);const G=s==null?void 0:s.rawMessages;let J,Q;e[32]!==l||e[33]!==a||e[34]!==G?(J=()=>{if(!a||!G||!Ht(l).modelFallbackNotices)return;let Z;for(let ae=G.length-1;ae>=0;ae=ae-1,ae){const te=G[ae];if(te.type==="system"&&te.subtype==="model_refusal_fallback"){Z=te;break}}if(!Z)return;const se=typeof Z.uuid=="string"?Z.uuid:`${String(Z.original_model)}:${String(Z.fallback_model)}:${String(Z.request_id)}`;if(I.current===se)return;I.current=se;const ne=typeof Z.original_model=="string"?Z.original_model:"Fable",re=typeof Z.fallback_model=="string"?Z.fallback_model:"Opus",ie=typeof Z.api_refusal_explanation=="string"?` ${Z.api_refusal_explanation}`:"";T(`${ne} could not handle this request, so Claude continued with ${re}.${ie}`)},Q=[a,G,l],e[32]=l,e[33]=a,e[34]=G,e[35]=J,e[36]=Q):(J=e[35],Q=e[36]),y.useEffect(J,Q);let X;return e[37]!==k||e[38]!==_||e[39]!==N||e[40]!==p||e[41]!==z||e[42]!==P||e[43]!==E||e[44]!==u||e[45]!==d||e[46]!==j||e[47]!==v||e[48]!==g?(X={selectedModel:d,setSelectedModel:f,selectedEffort:u,setSelectedEffort:m,fastModeEnabled:p,ultracodeEnabled:g,effectiveEffort:k,fastModeAvailable:N,fastModeActive:_,setFastModeEnabled:h,ultracodeAvailable:v,ultracodeActive:j,setUltracodeEnabled:x,imageInputAvailable:P,modelFallbackNotice:E,dismissModelFallbackNotice:U,handleModelRejected:z},e[37]=k,e[38]=_,e[39]=N,e[40]=p,e[41]=z,e[42]=P,e[43]=E,e[44]=u,e[45]=d,e[46]=j,e[47]=v,e[48]=g,e[49]=X):X=e[49],X}const MO=["model","effort","fastMode","ultracode","permissionMode"];function OO({sessionKey:n,values:e,onHydrate:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(t);i.current=t;const a=y.useRef(e);a.current=e,y.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return Nb(n).then(d=>{if(c||d===null)return;if(MO.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 Dc(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);y.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,Dc(n,a.current))},[l,n])}function DO(n){const[e,t]=y.useState(new Map),[s,o]=y.useState(null),[i,a]=y.useState(!0),l=y.useRef(new Map),c=y.useRef(null);y.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=y.useCallback(()=>a(x=>!x),[]),f=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.set(x.id,x),w}),o(x.id),a(!1)},[]),u=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.delete(x),o(v=>{if(v!==x)return v;const j=[...w.keys()];return j.length>0?j[j.length-1]:null}),w})},[]),m=y.useCallback(x=>{o(x),a(!1)},[]),p=y.useCallback((x,b)=>{t(w=>{const v=w.get(x);if(!v||v.status===b)return w;const j=new Map(w);return j.set(x,{...v,status:b}),j})},[]),h=y.useCallback(x=>{t(b=>{let w=!1;const v=new Map(b),j=new Set(x.map(S=>S.id));for(const[S,k]of v)k.type==="task"&&!j.has(S)&&(v.delete(S),w=!0);for(const S of x){const k=v.get(S.id);k?(k.name!==S.title||k.outputPath!==S.outputPath)&&(v.set(S.id,{...k,name:S.title,outputPath:S.outputPath}),w=!0):(v.set(S.id,{id:S.id,name:S.title,type:"task",status:"running",outputPath:S.outputPath}),w=!0)}return w?v:b})},[]),g=y.useCallback((x,b,w)=>{b&&w&&t(v=>{if(v.has(x))return v;const j=new Map(v);return j.set(x,{id:x,name:w,type:"task",status:"running",outputPath:b}),j}),o(v=>v===x?(a(!0),v):(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 LO(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=DO(t),[p,h]=y.useState(null),[g,x]=y.useState(0),b=y.useRef(0),w=s??o??void 0,v=!!(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 S;e[0]!==a||e[1]!==o?(S={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=S):S=e[2];const k=S;let C;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(C=()=>{if(Ds()){console.warn("[open-terminal] unavailable for remote devices");return}const G=s??o??void 0,J=i??a??l??void 0;if(!G&&!J){console.warn("[open-terminal] no project path available");return}ye("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:G,dirName:J})}).then(HO).catch(WO)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=C):C=e[8];const N=C;let _;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(_=G=>{if(Ds()){console.warn("[mcp-auth] unavailable for remote devices");return}const J=s??o??void 0,Q=i??a??l??void 0;!J&&!Q||ye("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:J,dirName:Q,command:"claude /mcp"})}).catch(UO)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=_):_=e[14];const A=_;let P;e[15]!==o||e[16]!==m||e[17]!==s?(P=()=>{const J=[...m.processes.values()].filter(BO).at(-1);if(!J){(s??o)&&x(FO);return}m.activeProcessId===J.id&&!m.collapsed?m.toggleCollapse():m.setActive(J.id)},e[15]=o,e[16]=m,e[17]=s,e[18]=P):P=e[18];const E=P;let T;e[19]!==o||e[20]!==s?(T=()=>{(s??o)&&x(zO)},e[19]=o,e[20]=s,e[21]=T):T=e[21];const I=T;let $;e[22]!==u||e[23]!==w||e[24]!==v?($=()=>{w&&y.startTransition(()=>{u(),h(v?null:{kind:"preview",cwd:w})})},e[22]=u,e[23]=w,e[24]=v,e[25]=$):$=e[25];const R=$;let M;e[26]!==d||e[27]!==u||e[28]!==w||e[29]!==f?(M=()=>{if(w){if(d===_t.projectFiles){u();return}y.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),f(_t.projectFiles)})}},e[26]=d,e[27]=u,e[28]=w,e[29]=f,e[30]=M):M=e[30];const D=M;let O;e[31]!==w||e[32]!==f||e[33]!==c?(O=G=>{if(!c)return!1;const J=u5(G,w);if(!J)return!1;b.current=b.current+1;const Q=b.current;return y.startTransition(()=>h({kind:"project-files",root:J.root,anchorCwd:w??null,request:J.file?{file:J.file,mode:J.mode,line:J.line,token:Q}:null})),f(_t.projectFiles),!0},e[31]=w,e[32]=f,e[33]=c,e[34]=O):O=e[34];const L=O;let F,z;e[35]!==L?(z=()=>d5(L),F=[L],e[35]=L,e[36]=F,e[37]=z):(F=e[36],z=e[37]),y.useEffect(z,F);let W;e[38]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{y.startTransition(()=>h(null))},e[38]=W):W=e[38];const U=W,H=!!(w&&d===_t.projectFiles),K=j==null?void 0:j.root,q=(j==null?void 0:j.request)??null;let Y;return e[39]!==w||e[40]!==A||e[41]!==I||e[42]!==N||e[43]!==E||e[44]!==R||e[45]!==D||e[46]!==g||e[47]!==k||e[48]!==m||e[49]!==v||e[50]!==H||e[51]!==K||e[52]!==q?(Y={processPanel:m,currentCwd:w,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:q,launchTerminalRequest:g,pendingProject:k,handleOpenTerminal:N,handleMcpAuth:A,handleToggleIntegratedTerminal:E,handleNewIntegratedTerminal:I,handleTogglePreview:R,handleToggleProjectFiles:D,closeRightWorkspace:U},e[39]=w,e[40]=A,e[41]=I,e[42]=N,e[43]=E,e[44]=R,e[45]=D,e[46]=g,e[47]=k,e[48]=m,e[49]=v,e[50]=H,e[51]=K,e[52]=q,e[53]=Y):Y=e[53],Y}function zO(n){return n+1}function FO(n){return n+1}function BO(n){return n.type==="terminal"}function UO(n){return console.error("[mcp-auth] open-terminal failed:",n)}function WO(n){return console.error("[open-terminal] fetch failed:",n)}function HO(n){n.ok||n.json().then(qO).catch(KO)}function KO(){}function qO(n){return console.error("[open-terminal]",n.error)}function VO(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
145
+ `)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const GO={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function _b(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:Ct(n.dirName)}}function YO(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...GO},rawMessages:[],agentKind:Ct(n.dirName)}}function Tb(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:$a(n)}}catch{return null}}async function XO(n,e,t=3,s=100,o=!0){if(o){const i=Tb(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:$a(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function JO(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await XO(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:_b(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function wh(n,e,t,s,o){const i=Tb(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??YO(n),c=_b(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),JO(n,e,t,a),n.sessionId}async function QO(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 ZO({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]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),[b,w]=y.useState(""),v=y.useRef(null),j=y.useRef(null),S=y.useRef(null),k=y.useCallback((A,P)=>{j.current=A,S.current=P??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:A,cwd:P,isMobile:t})},[e,t]),C=y.useCallback(async(A,P)=>{var M;const E=j.current;if(!E)return null;const T=Ct(E),I=S.current;(M=v.current)==null||M.abort();const $=new AbortController;v.current=$,m(!0),h(null),o==null||o(A);const R=Date.now();try{const D=VO(A),O=on(T),{capabilities:L}=O,F={dirName:E,cwd:O.dirName.lossy?I??void 0:void 0,message:A,images:P,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:L.ultracode&&d?!0:void 0,name:L.namedSessions&&D||void 0,worktreeName:L.worktrees&&g?b||B3(A):void 0,mcpConfig:L.mcp&&f||void 0},{res:z,errorMessage:W}=await ib(K=>ye("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:K}),signal:$.signal}),{model:a,agentKind:T,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(T==="codex"){const K=await QO(E,A,R,$);if(K){j.current=null,S.current=null;const q=await wh(K,$,e,t,s);return D&&q&&Rc(q,D),q}}return h(W||`Failed to create session (${z.status})`),null}const U=await z.json();j.current=null,S.current=null;const H=await wh(U,$,e,t,s);return D&&H&&Rc(H,D),H}catch(D){return $.signal.aborted||h(D instanceof Error?D.message:"Failed to create session"),null}finally{$.signal.aborted||m(!1)}},[n,a,l,c,d,f,g,b,e,t,s,o,i]),N=y.useCallback(()=>h(null),[]),_=y.useCallback(()=>{var A;(A=v.current)==null||A.abort(),v.current=null,j.current=null,S.current=null,m(!1),h(null)},[]);return{creatingSession:u,createError:p,clearCreateError:N,handleNewSession:k,createAndSend:C,cancelCreation:_,pendingDirNameRef:j,worktreeEnabled:g,setWorktreeEnabled:x,worktreeName:b,setWorktreeName:w}}function eD(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=y.useRef(null),g=y.useRef(null),[x,b]=y.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=U=>{var H;(H=h.current)==null||H.call(h,U),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},300),setTimeout(()=>{var K;return(K=g.current)==null?void 0:K.call(g)},2e3)},e[0]=w):w=e[0];let v;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?(v={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]=v):v=e[10];const j=ZO(v),S=j.handleNewSession,[k,C]=y.useState(null);let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=new Map,e[11]=N):N=e[11];const _=y.useRef(N);let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A=async U=>{if(ri===null)return null;const H=_.current;if(H.has(U))return H.get(U)??null;try{const K=await ye("/api/projects");if(!K.ok)return H.set(U,null),null;const q=await K.json(),Y=T3(q,U,ri);return H.set(U,Y),Y}catch{return H.set(U,null),null}},e[12]=A):A=e[12];const P=A;let E;e[13]!==S?(E=async(U,H)=>{const K=H??null;if(!K){C(null),S(U);return}const q=Ct(U)===ri?ri:null,Y=q?il(q,K):await P(K);C(Y?{discoveredDirName:Y,cwd:K}:null),S(q&&Y?Y:U,K)},e[13]=S,e[14]=E):E=e[14];const T=E;let I;e[15]!==i||e[16]!==T?(I=U=>{const H=il(i,U);T(H,U)},e[15]=i,e[16]=T,e[17]=I):I=e[17];const $=I;let R;e[18]!==S||e[19]!==k?(R=U=>{if(!k)return;const H=il(U,k.cwd,k.discoveredDirName);S(H,k.cwd)},e[18]=S,e[19]=k,e[20]=R):R=e[20];const M=R;let D;e:{if(!j.creatingSession||!a){D=null;break e}const U=x??void 0;let H;e[21]!==l||e[22]!==a||e[23]!==U?(H={dirName:a,cwd:l,firstMessage:U},e[21]=l,e[22]=a,e[23]=U,e[24]=H):H=e[24],D=H}const O=D;let L,F;e[25]!==a?(F=()=>{a||(b(null),C(null))},L=[a],e[25]=a,e[26]=L,e[27]=F):(L=e[26],F=e[27]),y.useEffect(F,L);const z=k?M:void 0;let W;return e[28]!==$||e[29]!==T||e[30]!==j.cancelCreation||e[31]!==j.clearCreateError||e[32]!==j.createAndSend||e[33]!==j.createError||e[34]!==j.creatingSession||e[35]!==j.setWorktreeEnabled||e[36]!==j.worktreeEnabled||e[37]!==O||e[38]!==z?(W={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:O,pendingAgentKindChange:z,handleStartNewSession:T,handleStartNewFolder:$},e[28]=$,e[29]=T,e[30]=j.cancelCreation,e[31]=j.clearCreateError,e[32]=j.createAndSend,e[33]=j.createError,e[34]=j.creatingSession,e[35]=j.setWorktreeEnabled,e[36]=j.worktreeEnabled,e[37]=O,e[38]=z,e[39]=W):W=e[39],W}const Jl=new Set;function tD(n,e){const t=bn(),s=hs();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function nD(n,e,t){const s=tD(n,e);if(!Jl.has(s)&&!yn.get(n,e)){Jl.add(s);try{await Bs(n,e,t,"session prefetch")}catch{}finally{Jl.delete(s)}}}function sD({onAuthenticated:n}){const[e,t]=y.useState(null),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(!1),[d,f]=y.useState(null),[u,m]=y.useState(!1),p=e==="team";y.useEffect(()=>{let x=!1;return xg().then(b=>{x||t(b)}),()=>{x=!0}},[]);const h=y.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?(ba(),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(Yt,{children:[r.jsxs(tn,{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(d3,{className:"size-4"})}),r.jsx(nn,{children:"Sign in to Cogpit"}),r.jsx(an,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Xt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(vt,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Xt,{className:"flex flex-col gap-4",children:[r.jsxs(To,{children:[p&&r.jsxs(xt,{children:[r.jsx(bt,{htmlFor:"login-username",children:"Username"}),r.jsx(Bt,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(xt,{children:[r.jsx(bt,{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(Nn,{align:"inline-end",children:r.jsx(Dr,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(ca,{}):r.jsx(Co,{})})})]})]})]}),d&&r.jsxs(St,{variant:"destructive",children:[r.jsx(sn,{"aria-hidden":"true"}),r.jsx(It,{children:"Sign in failed"}),r.jsx(Nt,{children:d})]})]}),r.jsx(Ao,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g,children:[u&&r.jsx(vt,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const jh=16,Ri="__cogpitBootstrapToken";function oD(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[Ri]=="string"?t[Ri]:"");return e&&window.history.replaceState({...t,[Ri]:e},"",`${window.location.pathname}${window.location.search}`),s}function Sh(){const n={...window.history.state||{}};delete n[Ri],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function rD({onAuthenticated:n,onBootstrapClosed:e}){const[t]=y.useState(oD),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(""),[d,f]=y.useState(""),[u,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),b=d.length>0&&d!==l,w=!t||!s.trim()||l.length<jh||d!==l,v=y.useCallback(async j=>{if(j.preventDefault(),!w){x(!0),h(null);try{const S=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()}:{}})}),k=await S.json();if(S.ok){Sh(),c(""),f(""),o(""),a(""),await e(),n();return}if(S.status===410){Sh(),await e();return}h(k.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:v,className:"w-full max-w-md",children:r.jsxs(Yt,{children:[r.jsxs(tn,{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(u3,{className:"size-4"})}),r.jsx(nn,{children:"Create the first admin"}),r.jsx(an,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Xt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(St,{children:[r.jsx(kn,{"aria-hidden":"true"}),r.jsx(It,{children:"Setup link required"}),r.jsx(Nt,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(To,{children:[r.jsxs(xt,{children:[r.jsx(bt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Bt,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(yo,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(xt,{children:[r.jsxs(bt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Bt,{id:"bootstrap-display-name",type:"text",value:i,onChange:j=>a(j.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(xt,{children:[r.jsx(bt,{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(Nn,{align:"inline-end",children:r.jsx(Dr,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":u?"Hide password":"Show password",children:u?r.jsx(ca,{}):r.jsx(Co,{})})})]}),r.jsxs(yo,{children:["Use at least ",jh," characters."]})]}),r.jsxs(xt,{"data-invalid":b,children:[r.jsx(bt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Bt,{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(sn,{"aria-hidden":"true"}),r.jsx(It,{children:"Could not create the account"}),r.jsx(Nt,{children:p})]})]}),r.jsx(Ao,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(vt,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function iD(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=xa(),n[0]=e):e=n[0];const t=e,[s,o]=y.useState(null),[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(0);let f,u;n[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let E=!1;return gg().then(T=>{E||o(T)}),()=>{E=!0}},u=[],n[1]=f,n[2]=u):(f=n[1],u=n[2]),y.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 E=!1;const T=d.current;return Nw().then(I=>{!E&&d.current===T&&(a(I),c(!0))}),()=>{E=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let E=!1;const T=()=>{const I=d.current=d.current+1,$=()=>{E||d.current!==I||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){$();return}Pf().then(R=>{E||d.current!==I||(o(R),R.edition==="team"&&$())})};return window.addEventListener("cogpit-auth-required",T),()=>{E=!0,window.removeEventListener("cogpit-auth-required",T)}},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],y.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 v=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{o(await Pf())},n[11]=j):j=n[11];const S=j;let k;n[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d.current=d.current+1,a(!1),c(!0),kw().finally(aD)},n[12]=k):k=n[12];const C=k,N=(s==null?void 0:s.edition)??null,_=l&&s!==null,A=(s==null?void 0:s.needsBootstrap)===!0;let P;return n[13]!==i||n[14]!==N||n[15]!==_||n[16]!==A?(P={isRemote:t,edition:N,authChecked:_,authenticated:i,needsBootstrap:A,handleAuthenticated:v,refreshServerState:S,logout:C},n[13]=i,n[14]=N,n[15]=_,n[16]=A,n[17]=P):P=n[17],P}function aD(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const lD=y.lazy(()=>qe(()=>import("./index-7FuVzOBC.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),cD=y.lazy(()=>qe(()=>import("./WorkflowsPanel-SKbsv_IK.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function dD(){var Yu,Xu,Ju,Qu,Zu,ef,tf,nf,sf,of,rf,af,lf,cf,df,uf,ff,mf,pf,hf;const n=xu(window.location.pathname),e=aO(),t=iD(),s=fO(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=za(),d=mb(),[f,u]=ab(),{procBySession:m}=i0(),{parse:p,append:h}=kb(),g=y.useCallback(ke=>{u({type:"SET_OLDER_TURNS",turns:ke})},[u]),x=y.useCallback((ke,Ge)=>{nD(ke,Ge,p)},[p]),b=Cb({dirName:((Yu=f.sessionSource)==null?void 0:Yu.dirName)??null,fileName:((Xu=f.sessionSource)==null?void 0:Xu.fileName)??null,sessionChangeKey:f.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=b,v=!!f.searchQuery&&b.hasMore,j=((Ju=f.session)==null?void 0:Ju.turns.length)??0;y.useEffect(()=>{v&&w()},[v,w,j]);const S=EO(f,u),k=y.useRef(null),C=y.useRef(null),[N,_]=y.useState(!1),[A,P]=y.useState(!1),E=y.useCallback(()=>u({type:"TOGGLE_EXPAND_ALL"}),[u]),T=y.useCallback(()=>_(!0),[]),I=y.useCallback(()=>{var ke;return(ke=C.current)==null?void 0:ke.focus()},[]),$=y.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!0}),[u]),R=y.useCallback(()=>u({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[u]),M=y.useCallback(()=>u({type:"SET_EXPAND_ALL",value:!1}),[u]),D=S.toggleWorkspacePanel,O=y.useCallback(()=>D(_t.sessionInfo),[D]),L=y.useCallback(ke=>{y.startTransition(()=>{u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u]),F=f.pendingCwd??(f.pendingDirName?wn(f.pendingDirName):null),z=((Qu=f.sessionSource)==null?void 0:Qu.agentKind)??Ct(((Zu=f.sessionSource)==null?void 0:Zu.dirName)??f.pendingDirName??null),W=(ef=f.session)!=null&&ef.sessionId?m.get(f.session.sessionId):void 0,U=Ht(z),H=gu(z,W),K=U.worktrees,q=U.mcp,Y=_O(i?((tf=f.session)==null?void 0:tf.cwd)??F??void 0:void 0,i&&U.slashCommands),G=y.useCallback(ke=>{if(!i)return;const Ge=Y.suggestions.find(yt=>yt.name===ke);y.startTransition(()=>{u({type:"OPEN_CONFIG",filePath:Ge==null?void 0:Ge.filePath})})},[i,u,Y.suggestions]),J=y.useCallback(async(ke,Ge)=>{if(!i)return null;const yt=Y.suggestions.find(pn=>pn.name===ke);if(!(yt!=null&&yt.filePath))return null;try{const pn=await ye("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:yt.filePath,args:Ge||""})});return pn.ok?(await pn.json()).content??null:null}catch{return null}},[i,Y.suggestions]),{processPanel:Q,currentCwd:X,showPreview:Z,showProjectFiles:se,projectFilesRoot:ne,projectFilesRequest:re,launchTerminalRequest:ie,pendingProject:ae,handleOpenTerminal:te,handleMcpAuth:ue,handleToggleIntegratedTerminal:le,handleNewIntegratedTerminal:de,handleTogglePreview:he,handleToggleProjectFiles:xe,closeRightWorkspace:ce}=LO({sessionId:(nf=f.session)==null?void 0:nf.sessionId,sessionCwd:(sf=f.session)==null?void 0:sf.cwd,pendingPath:F,sessionDirName:(of=f.sessionSource)==null?void 0:of.dirName,pendingDirName:f.pendingDirName,dashboardProject:f.dashboardProject,supportsFileWorkspace:!c&&a,activeWorkspacePanel:S.activeWorkspacePanel,openWorkspacePanel:S.openWorkspacePanel,closeWorkspacePanel:S.closeWorkspacePanel}),be=SO(f.session??null),[ge,fe]=y.useState(!1),je=((rf=f.sessionSource)==null?void 0:rf.dirName)??f.pendingDirName??f.dashboardProject??null,{activeWorkspacePanel:Se,closeWorkspacePanel:Ae,showWorkflows:Ie}=S,Re=xO(o&&K&&f.mainView==="sessions"&&Se===_t.worktrees?je:null),De=y.useMemo(()=>{const ke=f.session;return ke?ke.turns.some(Ge=>Vi(Ge.toolCalls,ke.cwd)||Ge.subAgentActivity.some(yt=>Vi(yt.toolCalls,ke.cwd))):!1},[f.session]),Le=y.useMemo(()=>{if(!f.session||!U.workflows)return 0;let ke=0;for(const Ge of f.session.turns)for(const yt of Ge.toolCalls)yt.name==="Workflow"&&ke++;return ke},[f.session,U.workflows]),ze=Le>0,_e=y.useMemo(()=>{const ke=f.sessionSource;return!ke||!U.workflows||xs(ke.fileName)?{dirName:null,sessionId:null}:{dirName:ke.dirName,sessionId:sc(ke.fileName)}},[f.sessionSource,U.workflows]),Ce=kM(_e.dirName,_e.sessionId,ze),We=ze||Ce.workflows.length>0,Fe=Ce.workflows.length||Le,Ne=S.setShowWorkflows,me=y.useCallback(()=>Ne(!0),[Ne]),[Oe,Pe]=y.useState(!1),[Be,oe]=y.useState(!1),pe=S.openWorkspacePanel;y.useEffect(()=>{if(!a)return;const ke=()=>{c?Pe(!0):pe(_t.fileChanges)};return window.addEventListener(yr,ke),()=>window.removeEventListener(yr,ke)},[a,pe,c]);const Te=y.useMemo(()=>f.session?Nx(f.session):null,[f.session]),$e=y.useRef(null),{isLive:He,sseState:Ke,isCompacting:st,streamingOverlay:Ye,turnError:Me,agentProgress:Ue,promptSuggestion:ot}=ob(f.sessionSource,ke=>{y.startTransition(()=>{u({type:"UPDATE_SESSION",session:ke})})},p,h,()=>{var ke;return(ke=$e.current)==null?void 0:ke.call($e)},f.session),Kt=y.useMemo(()=>Ye.reduce((ke,Ge)=>ke+Ge.blocks.reduce((yt,pn)=>yt+pn.text.length,0),0),[Ye]),zt=CO(((af=f.session)==null?void 0:af.cwd)??null),qt=KM(),Bn=qt.setMode,Ft=GM(H?null:((lf=f.session)==null?void 0:lf.sessionId)??null),ks=H?null:Ft.plan??Te,{selectedModel:Ve,setSelectedModel:Ze,selectedEffort:pt,setSelectedEffort:$t,fastModeEnabled:Un,ultracodeEnabled:Ys,effectiveEffort:Vr,fastModeAvailable:Pb,fastModeActive:Gr,setFastModeEnabled:Xa,ultracodeAvailable:Ib,ultracodeActive:Yr,setUltracodeEnabled:Ja,imageInputAvailable:bu,modelFallbackNotice:Rb,dismissModelFallbackNotice:$b,handleModelRejected:vu}=$O({agentKind:z,session:f.session,sessionSource:f.sessionSource,pendingDirName:f.pendingDirName,isLive:He}),yu=vO((cf=f.session)==null?void 0:cf.sessionId,(df=f.sessionSource)==null?void 0:df.fileName);OO({sessionKey:yu,values:{model:Ve,effort:pt,fastMode:Un,ultracode:Ys,permissionMode:qt.config.mode},onHydrate:y.useCallback(ke=>{ke.model!==void 0&&Ze(ke.model),ke.effort!==void 0&&$t(ke.effort),ke.fastMode!==void 0&&Xa(ke.fastMode),ke.ultracode!==void 0&&Ja(ke.ultracode),ke.permissionMode&&Bn(ke.permissionMode)},[Ze,$t,Xa,Ja,Bn])});const rn=jO(q&&i?X:void 0,q&&i?je??void 0:void 0,q&&i?yu??void 0:void 0,i);y.useEffect(()=>{!K&&Se===_t.worktrees&&Ae()},[K,Se,Ae]),y.useEffect(()=>{Ie&&!We&&Ne(!1)},[Ie,We,Ne]);const{creatingSession:wu,createError:ju,clearCreateError:Mb,createAndSend:Ob,cancelCreation:Su,worktreeEnabled:Db,setWorktreeEnabled:Lb,sessionFinalizedRef:Xr,liveSessionsRefreshRef:Nu,pendingSessionInfo:ku,pendingAgentKindChange:zb,handleStartNewSession:Cu,handleStartNewFolder:Fb}=eD({permissionsConfig:qt.config,dispatch:u,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:f.pendingDirName,pendingCwd:f.pendingCwd,onModelRejected:vu,model:Ve,effort:Vr,fastMode:Gr,ultracode:Yr,mcpConfig:q&&i?rn.mcpConfigJson:null}),ht=TM({sessionSource:f.sessionSource,parsedSessionId:((uf=f.session)==null?void 0:uf.sessionId)??null,cwd:(ff=f.session)==null?void 0:ff.cwd,permissions:qt.config,onPermissionsApplied:qt.markApplied,model:Ve,effort:Vr,fastMode:Gr,ultracode:Yr,mcpConfig:q&&i?rn.mcpConfigJson:null,onModelRejected:vu,readOnly:H,onCreateSession:f.pendingDirName?Ob:void 0}),Mt=SM(U.agentTeams?((mf=f.sessionSource)==null?void 0:mf.fileName)??null:null,((pf=f.sessionSource)==null?void 0:pf.dirName)??null);y.useEffect(()=>{Mt!=null&&Mt.currentMemberName?u({type:"SET_CURRENT_MEMBER_NAME",name:Mt.currentMemberName}):Mt||u({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Mt==null?void 0:Mt.currentMemberName,Mt,u]),y.useEffect(()=>{c&&u({type:"GUARD_MOBILE_TAB",hasSession:!!f.session||!!f.pendingDirName})},[f.session,f.pendingDirName,f.mobileTab,c,u]);const En=lb({session:f.session,isLive:He,pendingMessages:ht.pendingMessages,consumePending:ht.consumePending,sessionChangeKey:f.sessionChangeKey,partialContentLen:Kt}),_u=En.chatScrollRef,Tu=En.resetTurnCount,Eu=En.scrollToBottomInstant,Bb=y.useCallback(ke=>{fe(ke),requestAnimationFrame(()=>{const Ge=_u.current;Ge&&Ge.scrollTo({top:Ge.scrollTop+(ke?64:-64),behavior:"smooth"})})},[_u]);y.useLayoutEffect(()=>{const ke=Ge=>{Tu(0),Eu()};return Xr.current=ke,()=>{Xr.current===ke&&(Xr.current=null)}},[Tu,Eu,Xr]);const Ub=y.useCallback(()=>{ht.disconnect(),Su()},[ht.disconnect,Su]),An=PM({dispatch:u,isMobile:c,mobileTab:f.mobileTab,teamContext:Mt,scrollToBottomInstant:En.scrollToBottomInstant,resetTurnCount:En.resetTurnCount,workerParse:p,onBeforeSwitch:Ub}),Wb=y.useCallback(ke=>{y.startTransition(()=>{u({type:"GO_HOME",isMobile:c}),u({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[u,c]),{previewLoadError:Hb}=MM({state:f,dispatch:u,isMobile:c,resetTurnCount:En.resetTurnCount,scrollToBottomInstant:En.scrollToBottomInstant,workerParse:p}),Jr=WM(),Au=Jr.push;y.useEffect(()=>{f.sessionSource&&Au(f.sessionSource.dirName,f.sessionSource.fileName)},[f.sessionSource,Au]);const dt=IO({state:{session:f.session,sessionSource:f.sessionSource},dispatch:u,isMobile:c,handleJumpToTurn:An.handleJumpToTurn,markPermissionsApplied:qt.markApplied,hasPermsPendingChanges:qt.hasPendingChanges,permissionsConfig:qt.config,selectedModel:Ve,selectedEffort:Vr,fastMode:Gr,ultracode:Yr,mcpConfig:q&&i?rn.mcpConfigJson:null,scrollRequestScrollToTop:En.requestScrollToTop,handleDashboardSelect:An.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:Pu,handleApplySettings:Iu}=dt,Ru=q&&i&&rn.mcpConfigJson!==null,$u=y.useRef(!1);y.useEffect(()=>{var yt;const ke=rn.loaded&&!$u.current;$u.current=rn.loaded;const Ge=(yt=f.session)==null?void 0:yt.sessionId;ke&&Ge&&Ru&&Pu&&Iu()},[rn.loaded,Ru,Pu,Iu,(hf=f.session)==null?void 0:hf.sessionId]),y.useLayoutEffect(()=>($e.current=dt.reloadSession,()=>{$e.current===dt.reloadSession&&($e.current=null)}),[dt.reloadSession]);const Wn=jb(f.session,f.sessionSource,dt.reloadSession,a),Qr=Wn.requestBranchSwitch,Zr=dt.setBranchModalTurn,Kb=y.useCallback((ke,Ge)=>{Qr(ke,Ge),Zr(null)},[Qr,Zr]),qb=y.useCallback(ke=>{Qr(ke),Zr(null)},[Qr,Zr]);LM({isMobile:c,searchInputRef:k,chatInputRef:C,dispatch:u,onToggleSidebar:S.handleToggleSidebar,onToggleRightSidebar:O,onToggleMissionControl:S.handleToggleMission,onOpenCommandPalette:T,onOpenProjectSwitcher:S.handleOpenProjectSwitcher,onOpenThemeSelector:S.handleToggleThemeSelector,onOpenTerminal:te,onToggleIntegratedTerminal:le,onTogglePreview:he,onToggleProjectFiles:xe,onHistoryBack:Jr.goBack,onHistoryForward:Jr.goForward,onNavigateToSession:An.handleDashboardSelect,onCommitNavigation:Jr.commitNavigation});const{killing:Vb,handleKillAll:Gb}=bO(),os=f.sessionSource?xs(f.sessionSource.fileName):null,Yb=os!==null&&!!(Mt!=null&&Mt.currentMemberName),Qa=os!==null&&!Yb,ei=An.handleDashboardSelect,Mu=y.useCallback(()=>{!f.sessionSource||!os||ei(f.sessionSource.dirName,os.parentFileName)},[f.sessionSource,os,ei]);y.useEffect(()=>{const ke=Ge=>{const{agentId:yt}=Ge.detail??{};if(!yt||!f.sessionSource||!U.subagentTranscripts)return;const pn=os?os.parentSessionId:sc(f.sessionSource.fileName);ei(f.sessionSource.dirName,`${pn}/subagents/agent-${yt}.jsonl`)};return window.addEventListener(Gi,ke),()=>window.removeEventListener(Gi,ke)},[f.sessionSource,os,ei,U.subagentTranscripts]);const[Xb,Ou]=y.useState(null),Jb=dt.branchModalTurn!==null,Xs=dt.branchModalTurn??Xb;y.useEffect(()=>{dt.branchModalTurn!==null&&Ou(dt.branchModalTurn)},[dt.branchModalTurn]);const Du=Xs!==null?Wn.branchesAtTurn(Xs):[],Qb=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(go,{"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,Zb=H?r.jsxs("div",{role:"status",className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[r.jsx(go,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Yw(z)})]}):null,Za=Qb||Zb,ev=An.loadError||ju||null;let el;An.loadError?el=An.clearLoadError:ju&&(el=Mb);const tv=!!(f.session&&f.sessionSource&&Ke==="disconnected"),tl=y.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]),nl=y.useMemo(()=>({session:f.session,sessionSource:f.sessionSource,isLive:He,sseState:Ke,isCompacting:st,turnError:Me,promptSuggestion:ot,undoRedo:Wn,pendingInteraction:ks,permissionRequests:Ft.requests,permissionResponding:Ft.responding,respondPermission:Ft.respond,respondAllPermissions:Ft.respondAll,isSubAgentView:Qa,slashSuggestions:Y.suggestions,slashSuggestionsLoading:Y.loading,actions:{handleStopSession:dt.handleStopSession,handleEditConfig:i?S.handleEditConfig:void 0,handleEditCommand:i?G:void 0,handleExpandCommand:i?J:void 0,handleOpenBranches:dt.handleOpenBranches,handleBranchFromHere:dt.handleBranchFromHere,handleToggleExpandAll:E,handleLoadSession:dt.handleLoadSessionScrollAware}}),[f.session,f.sessionSource,He,Ke,st,Me,ot,Wn,ks,Qa,Ft.requests,Ft.responding,Ft.respond,Ft.respondAll,Y.suggestions,Y.loading,dt.handleStopSession,i,S.handleEditConfig,G,J,dt.handleOpenBranches,dt.handleBranchFromHere,E,dt.handleLoadSessionScrollAware]),sl=y.useMemo(()=>({chat:{status:ht.status,error:ht.error,pendingMessages:ht.pendingMessages,isConnected:ht.isConnected,sendMessage:ht.sendMessage,interrupt:ht.interrupt,stopAgent:ht.stopAgent,consumePending:ht.consumePending},scroll:En}),[ht.status,ht.error,ht.pendingMessages,ht.isConnected,ht.sendMessage,ht.interrupt,ht.stopAgent,ht.consumePending,En]),Io=!!f.pendingDirName&&!f.session;if(y.useEffect(()=>{if(!Io||c)return;const ke=requestAnimationFrame(()=>{var Ge;return(Ge=C.current)==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(ke)},[Io,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(rD,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(sD,{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(un,{children:[r.jsxs(fn,{children:[r.jsx(_n,{variant:"icon",children:r.jsx(kn,{className:"text-destructive"})}),r.jsx(mn,{children:"Failed to connect"}),r.jsx(Tn,{children:e.configError})]}),r.jsx(dg,{children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Dt,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(a5,{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 ol=r.jsx(yw,{activeError:ev,clearActiveError:el,modelFallbackNotice:Rb,dismissModelFallbackNotice:$b,connectionLost:tv,theme:d.activeTheme}),Lu=a?r.jsx(Z4,{state:Wn.confirmState,isApplying:Wn.isApplying,applyError:Wn.applyError,onConfirm:Wn.confirmApply,onCancel:Wn.confirmCancel}):null,nv=Xs!==null&&f.session?f.session.turns.slice(Xs):[],zu=a&&Xs!==null&&Du.length>0&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(lD,{open:Jb,branches:Du,branchPointTurnIndex:Xs,currentTurns:nv,onClose:dt.handleCloseBranchModal,onCloseComplete:()=>Ou(null),onRedoToTurn:Kb,onRedoEntireBranch:qb})}),Fu=l&&r.jsx(U4,{processes:Q.processes,activeProcessId:Q.activeProcessId,collapsed:Q.collapsed,onSetActive:Q.setActive,onRemove:Q.removeProcess,onToggleCollapse:Q.toggleCollapse,onRequestTerminal:lt("terminal")?de:void 0,onAddTerminalContext:ke=>{var gf,xf,bf;const Ge=ke.trim();if(!Ge)return;const yt=Ge.includes("```")?"````":"```",pn=`${yt}terminal
146
+ ${Ge}
147
+ ${yt}`,rl=((gf=C.current)==null?void 0:gf.getText().trimEnd())??"";(xf=C.current)==null||xf.setText(rl?`${rl}
148
+
149
+ ${pn}
150
+ `:`${pn}
151
+ `),(bf=C.current)==null||bf.focus()},onUpdateStatus:Q.updateProcessStatus,projectDir:X,onProcessStarted:Q.addProcess,mobile:c}),Bu=Mt&&r.jsx(Lj,{teamName:Mt.config.name||Mt.teamName,members:Mt.config.members,currentMemberName:f.currentMemberName,loadingMember:f.loadingMember,onMemberClick:An.handleTeamMemberSwitch}),Uu=We&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(cD,{open:S.showWorkflows,onOpenChange:S.setShowWorkflows,dirName:_e.dirName,sessionId:_e.sessionId,workflows:Ce.workflows,isLive:Ce.isLive,onRefetchList:Ce.refetch},`${_e.dirName??""}:${_e.sessionId??""}`)}),ti=U.goals?f.session:null,Wu=ke=>{var Ge;return r.jsx($j,{agentKind:z,onAgentKindChange:Io?zb:void 0,selectedModel:Ve,onModelChange:Ze,selectedEffort:Vr,onEffortChange:$t,fastModeEnabled:Gr,onFastModeEnabledChange:Pb?Xa:void 0,isNewSession:Io,worktreeEnabled:Db,onWorktreeEnabledChange:Io&&K?Lb:void 0,ultracodeEnabled:Yr,onUltracodeEnabledChange:Ib?Ja:void 0,onApplySettings:dt.handleApplySettings,activeModelId:(Ge=f.session)==null?void 0:Ge.model,mcpServers:q&&i?rn.servers:void 0,selectedMcpServers:q&&i?rn.selectedServers:void 0,onToggleMcpServer:q&&i?rn.toggleServer:void 0,onRefreshMcpServers:q&&i?rn.refresh:void 0,mcpLoading:q&&i?rn.loading:void 0,onMcpAuth:q&&i?ue:void 0,permissionMode:qt.config.mode,onPermissionModeChange:qt.setMode,mobileExtra:c&&ke&&ti?r.jsx(x4,{}):void 0,trailingExtra:!c&&ke&&ti?r.jsx(Qg,{}):void 0,mobile:c})},Hu=Wu(!0),Ku=Wu(!1),qu=r.jsxs("div",{className:"shrink-0 bg-background",children:[!c&&r.jsx(Jg,{}),r.jsx(uc,{ref:C,allowImages:bu,agentKind:z,projectCwd:X,compact:c,leadingAccessory:c?Hu:void 0}),!c&&Hu]}),ni=ti?r.jsx(g4,{agentKind:z,session:ti,onSendCommand:ht.sendMessage,children:qu}):qu,sv=r.jsxs("div",{className:"shrink-0 bg-background",children:[r.jsx(uc,{ref:C,allowImages:bu,agentKind:z,projectCwd:X,compact:c,leadingAccessory:c?Ku:void 0}),!c&&Ku]}),Vu=ht.pendingMessages.map((ke,Ge)=>r.jsx(Dx,{message:ke,turnNumber:Ge+1},Ge)),ov=c?f.mobileTab==="stats":S.activeWorkspacePanel===_t.sessionInfo,Gu=f.session&&!ov&&r.jsx("div",{className:"hidden",children:r.jsx(a1,{cwd:f.session.cwd,turns:f.session.turns,onServersChanged:Q.handleServersChanged})});return n?r.jsxs(Ai,{value:tl,children:[r.jsx(fl,{children:r.jsx(Ti,{value:nl,chatValue:sl,children:r.jsx(Nl,{value:Ye,agentProgress:Ue,children:r.jsx(bM,{sessionId:n,loadError:Hb,searchInputRef:k,activeComposer:Za||sv,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore})})})}),ol]}):c?r.jsxs(Ai,{value:tl,children:[r.jsx(fl,{enabled:l,children:r.jsx(Ti,{value:nl,chatValue:sl,children:r.jsx(Nl,{value:Ye,agentProgress:Ue,children:r.jsx(xM,{navigation:{actions:An,handlers:dt,creatingSession:wu,pendingSession:ku,onStartNewSession:Cu,onSelectProject:L,liveSessionsRefreshRef:Nu,onPrefetchSession:x},sessionView:{searchInputRef:k,teamMembersBar:Bu,activeComposer:Za||ni,pendingComposer:ni,pendingTurns:Vu,todoProgress:be&&r.jsx(Lx,{progress:be}),hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Mu,onShowWorkflows:me,onToggleExpandAll:E,workflowCount:Fe,pendingPath:F},project:{processPanel:Q,backgroundAgents:zt,hasFileChanges:a&&De,onOpenTerminal:te},chrome:{backgroundServers:Gu,processPanel:Fu,workflowsPanel:Uu,undoDialog:Lu,branchModal:zu,fileChangesOpen:Oe,onFileChangesOpenChange:Pe,searchOpen:Be,onSearchOpenChange:oe}})})})}),ol]}):r.jsxs(Ai,{value:tl,children:[r.jsx(fl,{enabled:l,children:r.jsx(Ti,{value:nl,chatValue:sl,children:r.jsx(Nl,{value:Ye,agentProgress:Ue,children:r.jsx(lM,{navigation:{panels:S,actions:An,handlers:dt,creatingSession:wu,pendingSession:ku,onStartNewSession:Cu,onStartNewFolder:Fb,onSelectProject:L,onOpenPaletteProject:Wb,liveSessionsRefreshRef:Nu,onPrefetchSession:x},sessionView:{searchInputRef:k,chatInputRef:C,teamMembersBar:Bu,activeComposer:Za||ni,pendingComposer:ni,pendingTurns:Vu,todoProgress:be,todosExpanded:ge,onTodosExpandedChange:Bb,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:Mu,onShowWorkflows:me,workflowCount:Fe},project:{processPanel:Q,worktrees:Re,backgroundAgents:zt,supportsWorktrees:K,hasFileChanges:a&&De,currentCwd:X,showPreview:Z,showProjectFiles:a&&se,projectFilesRoot:ne,projectFilesRequest:re,launchTerminalRequest:ie,pendingProject:ae,onOpenTerminal:te,onTogglePreview:he,onToggleProjectFiles:xe,onCloseRightWorkspace:ce},chrome:{backgroundServers:Gu,processPanel:Fu,workflowsPanel:Uu,undoDialog:Lu,branchModal:zu,killing:Vb,onKillAll:Gb,commandPaletteOpen:N,onCommandPaletteOpenChange:_,onOpenCommandPalette:T,onFocusComposer:I,onExpandAll:$,onExpandToolPayloads:R,onCollapseAll:M,keyboardShortcutsOpen:A,onKeyboardShortcutsOpenChange:P}})})})}),ol]})}function uD(){var w;const[n,e]=y.useState(gt),[t,s]=y.useState(()=>_i(gt())),[o,i]=y.useState(hs),[a,l]=y.useState(0),[c,d]=y.useState(!1),[f,u]=y.useState(!1),[m,p]=y.useState(!1),{devices:h,testDevice:g}=Ha();y.useEffect(()=>{const v=()=>{const j=gt();e(S=>S===j?S:j),s(_i(j))};return window.addEventListener("cogpit-device-changed",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("cogpit-device-changed",v),window.removeEventListener("popstate",v)}},[]),y.useEffect(()=>{const v=j=>{const S=j.detail;(S==null?void 0:S.deviceId)===gt()&&s(_i(S.deviceId))};return window.addEventListener("cogpit-device-scope-changed",v),()=>window.removeEventListener("cogpit-device-scope-changed",v)},[]),y.useEffect(()=>{const v=()=>i(hs());return window.addEventListener("cogpit-identity-changed",v),()=>window.removeEventListener("cogpit-identity-changed",v)},[]),y.useEffect(()=>(window.__cogpitRevealSession=d2,()=>{delete window.__cogpitRevealSession}),[]),y.useEffect(()=>{const v=j=>{const S=[jt,...h.map(_=>_.id)],k=gt();let C;const N=w9(j);if(N!==null)C=S[N-1];else if(j9(j)){const _=S.indexOf(k);C=S[(_+1)%S.length]}!C||C===k||(j.preventDefault(),gs(C))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[h]),y.useEffect(()=>{const v=j=>{const S=j.detail;!(S!=null&&S.deviceId)||S.deviceId!==gt()||(d(!0),S.reason==="DEVICE_AUTH_FAILED"&&u(!0))};return window.addEventListener("cogpit-device-unreachable",v),()=>window.removeEventListener("cogpit-device-unreachable",v)},[]),y.useEffect(()=>{d(!1),u(!1),p(!1)},[n,t]);const x=y.useCallback(async()=>{p(!0);try{const v=await g(n);v.reachable&&v.authState==="bad-password"?u(!0):v.ok&&(d(!1),u(!1),l(j=>j+1))}finally{p(!1)}},[n,g]);y.useEffect(()=>{if(!c||f)return;const v=setInterval(()=>void x(),1e4);return()=>clearInterval(v)},[c,f,x]);const b=((w=h.find(v=>v.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(f3,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(It,{children:f?"Device credentials need attention":"Remote device unavailable"}),r.jsx(Nt,{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(ee,{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(ee,{variant:"outline",size:"xs",onClick:()=>gs(jt),children:"Switch to this machine"})]})]}),r.jsx(s6,{children:r.jsx(w$,{children:r.jsx(dD,{})})},`${n}:${t}:${a}:${o??""}`)]})}const Nh="Invalid link or passphrase.";function fD(n,e){return n===401?Nh: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||Nh}function mD({sessionId:n,onAuthenticated:e}){const[t,s]=y.useState(""),[o,i]=y.useState(!1),[a,l]=y.useState(null),[c,d]=y.useState(!1),f=y.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(fD(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(Yt,{children:[r.jsxs(tn,{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(Xn,{className:"size-4"})}),r.jsx(nn,{children:"Join this session"}),r.jsx(an,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(Xt,{className:"flex flex-col gap-4",children:[r.jsx(To,{children:r.jsxs(xt,{children:[r.jsx(bt,{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(Nn,{align:"inline-end",children:r.jsx(Dr,{size:"icon-xs",onClick:()=>i(u=>!u),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(ca,{}):r.jsx(Co,{})})})]})]})}),a&&r.jsxs(St,{variant:"destructive",children:[r.jsx(sn,{"aria-hidden":"true"}),r.jsx(It,{children:"Could not join"}),r.jsx(Nt,{children:a})]})]}),r.jsx(Ao,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(vt,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function pD(){const n=B.c(9),[e,t]=y.useState("idle"),[s,o]=y.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=y.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>{l(w=>[...w,x]),t("connected"),o(void 0),GS(x,b).then(w=>{if(w.ok){t("idle");return}o(`Request failed (${w.status})`),t("error"),l(xD)}).catch(w=>{o(w instanceof Error?w.message:"Unknown error"),t("error"),l(gD)})},n[1]=c):c=n[1];const d=c;let f;n[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{YS().catch(hD),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 hD(){}function gD(n){return n.slice(0,-1)}function xD(n){return n.slice(0,-1)}const bD=2e3;function vD(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function yD(){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]=y.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=y.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const w=await ZS();h||w===null||s(v=>vD(v,w)?v:w)},x=()=>{document.visibilityState==="visible"&&g()};x();const b=setInterval(x,bD);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]),y.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),JS(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 Eb={authenticated:!0,edition:"personal",user:null,capabilities:Mr};function wD(n){var de,he;const e=B.c(78),{info:t,children:s}=n,o=za(),i=mb(),[a,l]=ab(),{parse:c,append:d}=kb(),[f,u]=y.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],y.useEffect(CD,m);const p=pD(),h=yD();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:xe,source:ce}=await db(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:xe,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=y.useRef(!1);let w,v;e[7]!==x?(w=()=>{b.current||(b.current=!0,x())},v=[x],e[7]=x,e[8]=w,e[9]=v):(w=e[8],v=e[9]),y.useEffect(w,v);let j;e[10]!==l?(j=xe=>{l({type:"UPDATE_SESSION",session:xe})},e[10]=l,e[11]=j):j=e[11];const S=j,{isLive:k,sseState:C,isCompacting:N,turnError:_}=ob(a.sessionSource,S,c,d,void 0,a.session);let A;e[12]!==l?(A=xe=>{l({type:"SET_OLDER_TURNS",turns:xe})},e[12]=l,e[13]=A):A=e[13];const P=A,E=((de=a.sessionSource)==null?void 0:de.dirName)??null,T=((he=a.sessionSource)==null?void 0:he.fileName)??null;let I;e[14]!==P||e[15]!==a.sessionChangeKey||e[16]!==E||e[17]!==T||e[18]!==c?(I={dirName:E,fileName:T,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:P},e[14]=P,e[15]=a.sessionChangeKey,e[16]=E,e[17]=T,e[18]=c,e[19]=I):I=e[19];const $=Cb(I);let R;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==k||e[23]!==a.session||e[24]!==a.sessionChangeKey?(R={session:a.session,isLive:k,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=k,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=R):R=e[25];const M=lb(R),D=jb(a.session,a.sessionSource,x,!1);let O;e[26]!==a.session?(O=a.session?Nx(a.session):null,e[26]=a.session,e[27]=O):O=e[27];const L=O;let F;e[28]!==l?(F=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=F):F=e[29];const z=F,W=ND,U=SD;let H;e[30]!==t.dirName?(H=Ct(t.dirName),e[30]=t.dirName,e[31]=H):H=e[31];let K;e[32]!==H?(K={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:H,setClaudeDir:U,showConfigDialog:!1,openConfigDialog:U,handleCloseConfigDialog:U,handleConfigSaved:U,retryConfig:U,networkUrl:null,networkAccessDisabled:!1},e[32]=H,e[33]=K):K=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q={isRemote:xa(),edition:"personal",authChecked:!0,authenticated:!0,needsBootstrap:!1,handleAuthenticated:U,refreshServerState:jD,logout:U},e[34]=q):q=e[34];let Y;e[35]!==l||e[36]!==o||e[37]!==a||e[38]!==K||e[39]!==i?(Y={state:a,dispatch:l,config:K,theme:i,networkAuth:q,me:Eb,isMobile:o},e[35]=l,e[36]=o,e[37]=a,e[38]=K,e[39]=i,e[40]=Y):Y=e[40];const G=Y;let J;e[41]===Symbol.for("react.memo_cache_sentinel")?(J=[],e[41]=J):J=e[41];let Q;e[42]!==z?(Q={handleStopSession:W,handleOpenBranches:U,handleBranchFromHere:U,handleToggleExpandAll:z,handleLoadSession:U},e[42]=z,e[43]=Q):Q=e[43];let X;e[44]!==N||e[45]!==k||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]!==D?(X={session:a.session,sessionSource:a.sessionSource,isLive:k,sseState:C,isCompacting:N,turnError:_,undoRedo:D,pendingInteraction:L,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:J,slashSuggestionsLoading:!1,promptSuggestion:null,actions:Q},e[44]=N,e[45]=k,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]=D,e[57]=X):X=e[57];const Z=X;let se;e[58]!==p||e[59]!==M?(se={chat:p,scroll:M},e[58]=p,e[59]=M,e[60]=se):se=e[60];const ne=se;let re;e[61]!==$?(re=()=>{$.loadMore()},e[61]=$,e[62]=re):re=e[62];let ie;e[63]!==f||e[64]!==$.hasMore||e[65]!==$.isLoadingOlder||e[66]!==re?(ie={loadState:f,hasMore:$.hasMore,isLoadingOlder:$.isLoadingOlder,loadMore:re},e[63]=f,e[64]=$.hasMore,e[65]=$.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 ue;e[71]!==ne||e[72]!==Z||e[73]!==te?(ue=r.jsx(Ti,{value:Z,chatValue:ne,children:te}),e[71]=ne,e[72]=Z,e[73]=te,e[74]=ue):ue=e[74];let le;return e[75]!==G||e[76]!==ue?(le=r.jsx(Ai,{value:G,children:ue}),e[75]=G,e[76]=ue,e[77]=le):le=e[77],le}function jD(){return Promise.resolve()}function SD(){}async function ND(){await XS().catch(kD)}function kD(){}function CD(){fo(Eb)}function _D(n){const e=B.c(6),{info:t}=n,s=y.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(Xn,{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(sn,{"aria-hidden":"true"}),r.jsx(It,{children:"Session unavailable"}),r.jsx(Nt,{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(vt,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(Wa,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(Ga,{children:r.jsx(uc,{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(wD,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function Ql(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 TD(){const n=B.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Vg(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]=y.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await VS();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]),y.useEffect(c,d);let f,u;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{i(ED)};return window.addEventListener(dc,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(dc,p),window.removeEventListener("cogpit-auth-required",p)}},u=[],n[5]=f,n[6]=u):(f=n[5],u=n[6]),y.useEffect(f,u),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(_D,{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(mD,{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(Ql,{children:r.jsx(Yt,{children:r.jsxs(tn,{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(m3,{className:"size-4"})}),r.jsx(nn,{children:"Sharing has ended"}),r.jsx(an,{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(sn,{"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(Nt,{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(ee,{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(Ql,{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(Ql,{children:r.jsx(Yt,{children:r.jsxs(Xt,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(Xn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(vt,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function ED(n){return n.kind==="ready"?{kind:"ended"}:n}class AD extends y.Component{constructor(){super(...arguments);si(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(Yt,{className:"w-full max-w-lg text-center",children:[r.jsxs(tn,{className:"justify-items-center",children:[r.jsx(kn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(nn,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(an,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(Xt,{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(Ao,{className:"justify-center",children:r.jsxs(ee,{onClick:()=>window.location.reload(),children:[r.jsx(Dt,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Ab=document.getElementById("root");if(!Ab)throw new Error("Root element not found");cv.createRoot(Ab).render(r.jsx(y.StrictMode,{children:r.jsx(AD,{children:ka(window.location.pathname)?r.jsx(TD,{}):r.jsx(uD,{})})}));export{Ut as $,St as A,ee as B,FD as C,Jn as D,un as E,nE as F,mn as G,Tn as H,Nn as I,Wg as J,Ua as K,OD as L,va as M,Bg as N,Ug as O,Fg as P,wt as Q,T3 as R,_j as S,Ha as T,To as U,xt as V,Dr as W,fs as X,E0 as Y,A0 as Z,V as _,Tj as a,s5 as a$,HS as a0,vr as a1,Ee as a2,vt as a3,U8 as a4,Nc as a5,qd as a6,Ca as a7,zg as a8,ld as a9,g1 as aA,Er as aB,JD as aC,Fa as aD,tn as aE,nn as aF,Xt as aG,Ao as aH,Yt as aI,$a as aJ,Ex as aK,Gs as aL,Fn as aM,Fs as aN,Mn as aO,It as aP,an as aQ,gd as aR,rd as aS,NM as aT,Sa as aU,bt as aV,yo as aW,RA as aX,on as aY,LD as aZ,Bt as a_,cd as aa,dd as ab,fd as ac,md as ad,ud as ae,hd as af,pd as ag,Lr as ah,w1 as ai,yd as aj,Sn as ak,Ir as al,ut as am,Wt as an,ft as ao,X4 as ap,_s as aq,$l as ar,v9 as as,fS as at,zD as au,ad as av,Ds as aw,lt as ax,vd as ay,h1 as az,Ej as b,ha as b0,l1 as b1,DD as b2,Tt as b3,Et as b4,At as b5,Oa as b6,Da as b7,La as b8,ho as b9,WD as ba,en as bb,br as bc,V4 as bd,Ot as be,aj as bf,UD as bg,zd as bh,Zx as bi,Bd as bj,Jx as bk,Pr as bl,i0 as bm,j$ as bn,M2 as bo,Ur as bp,vs as bq,W_ as br,Cj as c,wj as d,HD as e,b9 as f,KD as g,Qn as h,Ss as i,Zn as j,es as k,Rt as l,ns as m,ss as n,GD as o,Nt as p,Vs as q,VD as r,YD as s,XD as t,qD as u,q2 as v,ye as w,BD as x,fn as y,_n as z};