cogpit 2.3.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/cli.js +5644 -4349
  2. package/dist/web/assets/{CommandPaletteHost-D-VvT_HL.js → CommandPaletteHost-DJghey7B.js} +1 -1
  3. package/dist/web/assets/{ConfigBrowser-Cc2lrh85.js → ConfigBrowser-x0UdXG0K.js} +1 -1
  4. package/dist/web/assets/{HighlightedEditor-DWNz1Jcz.js → HighlightedEditor-D0TDZx8S.js} +1 -1
  5. package/dist/web/assets/{KeyboardShortcutsDialog-yOs1u5D6.js → KeyboardShortcutsDialog-2606YXAx.js} +1 -1
  6. package/dist/web/assets/{MobileFileChanges-B1dtcdSZ.js → MobileFileChanges-B4dwGXMS.js} +1 -1
  7. package/dist/web/assets/{PreviewPanel-BJwfunf9.js → PreviewPanel-CJdf-VLC.js} +1 -1
  8. package/dist/web/assets/{ProjectFilesPanel-DppuIFEt.js → ProjectFilesPanel-3GzuQyp3.js} +1 -1
  9. package/dist/web/assets/{ProjectSwitcherModal-DgsuH5CY.js → ProjectSwitcherModal-D8boI2Qx.js} +1 -1
  10. package/dist/web/assets/{TerminalOutput-DlGDS0Wx.js → TerminalOutput-C-6RWc6C.js} +1 -1
  11. package/dist/web/assets/{ThemeSelectorModal-oI9Vm3EH.js → ThemeSelectorModal-DZ9JuT6j.js} +1 -1
  12. package/dist/web/assets/{WorkflowsPanel-SKbsv_IK.js → WorkflowsPanel-i3GanFyN.js} +1 -1
  13. package/dist/web/assets/{WorktreePanel-CcSLupr7.js → WorktreePanel-D-BUTFL2.js} +1 -1
  14. package/dist/web/assets/{index-BVkjlOVU.js → index-BBKPLXTq.js} +1 -1
  15. package/dist/web/assets/index-CMQcske6.js +1 -0
  16. package/dist/web/assets/index-C_0XOtqJ.css +1 -0
  17. package/dist/web/assets/index-D6p4gVB_.js +154 -0
  18. package/dist/web/assets/{index-7FuVzOBC.js → index-ztb2qsgi.js} +1 -1
  19. package/dist/web/assets/{session-parser.worker-RMitC4X_.js → session-parser.worker-D3MwyNH5.js} +1 -1
  20. package/dist/web/assets/vendor-ui-RwWl1mlR.js +882 -0
  21. package/dist/web/index.html +3 -3
  22. package/package.json +1 -1
  23. package/dist/web/assets/index-Bw-DFQut.js +0 -1
  24. package/dist/web/assets/index-Du17HzQD.js +0 -151
  25. package/dist/web/assets/index-xdv0cIL2.css +0 -1
  26. package/dist/web/assets/vendor-ui-CdA11Wfh.js +0 -817
@@ -0,0 +1,154 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-C-6RWc6C.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-RwWl1mlR.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-DJghey7B.js","assets/index-CMQcske6.js","assets/KeyboardShortcutsDialog-2606YXAx.js","assets/ProjectSwitcherModal-D8boI2Qx.js","assets/ThemeSelectorModal-DZ9JuT6j.js","assets/ProjectFilesPanel-3GzuQyp3.js","assets/HighlightedEditor-D0TDZx8S.js","assets/WorktreePanel-D-BUTFL2.js","assets/index-BBKPLXTq.js","assets/ConfigBrowser-x0UdXG0K.js","assets/PreviewPanel-CJdf-VLC.js","assets/MobileFileChanges-B4dwGXMS.js","assets/index-ztb2qsgi.js","assets/WorkflowsPanel-i3GanFyN.js"])))=>i.map(i=>d[i]);
2
+ var sy=Object.defineProperty;var oy=(n,e,t)=>e in n?sy(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var hi=(n,e,t)=>oy(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as ye,e as ry,r as w,a as iy,f as ay}from"./vendor-react-gGw_S5I_.js";import{av as ly,aw as cy,ax as dy,ay as ss,ac as lt,az as uy,i as bn,aA as cd,as as Wn,aB as c1,aC as fy,aD as my,aE as py,aF as d1,aG as u1,aH as dd,aI as f1,aJ as m1,aK as hy,O as gt,aL as p1,aM as gy,aN as xy,aO as by,aP as h1,J as Pr,a1 as wo,$ as tt,b as At,aj as vy,aQ as g1,aR as Ki,G as Fn,aS as yy,aT as wy,aU as jy,aV as Sy,aW as Ny,aX as ky,aY as Cy,aZ as _y,a_ as Ty,a$ as Ey,b0 as Py,b1 as Ay,b2 as Ry,b3 as Ar,b4 as $y,b5 as ud,b6 as fd,b7 as md,b8 as x1,b9 as pd,ba as xa,X as st,bb as hd,bc as Iy,N as gd,ad as os,bd as My,be as b1,bf as v1,bg as xo,bh as Ts,bi as Oy,bj as Dy,bk as Ly,bl as zy,bm as ur,S as cn,B as jo,m as y1,bn as Vs,bo as w1,bp as Fy,bq as By,br as Uy,af as Rr,bs as Wy,W as ba,al as xc,a8 as ys,bt as bc,bu as Hy,bv as Ky,bw as qy,bx as Vy,by as Gy,bz as Yy,bA as Xy,bB as xd,bC as Jy,bD as qt,D as Rn,bE as Qy,bF as Zy,bG as e3,bH as t3,bI as n3,bJ as s3,bK as So,bL as $r,bM as o3,o as va,bN as r3,bO as i3,bP as a3,bQ as l3,bR as c3,bS as d3,bT as u3,bU as f3,bV as m3,bW as p3,C as Je,P as Bn,A as Gs,d as j1,bX as h3,bY as g3,bZ as x3,b_ as b3,F as No,ag as Ys,b$ as v3,c0 as S1,U as bd,f as ya,a7 as wa,c1 as y3,c2 as vd,c3 as vc,c4 as w3,R as yd,c5 as j3,c6 as S3,Y as Fs,c as N1,c7 as N3,v as ja,c8 as $o,_ as Di,c9 as k3,ca as C3,cb as k1,cc as _3,cd as T3,ce as gi,cf as $s,ah as Zf,l as Ir,cg as E3,a2 as P3,ch as A3,at as R3,w as Sa,ci as $3,Q as wd,cj as I3,ck as M3,cl as O3,cm as D3,cn as L3,co as z3,cp as F3,cq as C1,cr as B3,cs as U3,ct as jd,aq as W3,r as em,cu as H3,cv as tm,p as Na,cw as K3,cx as Sd,n as Mr,I as _1,cy as q3,a3 as Nd,u as V3,cz as G3,cA as T1,s as E1,au as P1,y as Y3,cB as X3,cC as J3,cD as Q3,cE as Z3,cF as ew,cG as nn,j as A1,cH as tw,an as nm,am as nw,cI as sw,cJ as ow,cK as R1,cL as $1,cM as kd,cN as rw,cO as iw,cP as I1,cQ as aw,cR as yc,cS as lw,cT as cw,cU as M1,cV as dw,h as uw,cW as fw,cX as mw,ab as pw,L as hw,z as gw,ao as xw,cY as bw,aa as vw,cZ as yw}from"./vendor-ui-RwWl1mlR.js";import{c as ww,a as jw}from"./vendor-shiki-DOn6sF-i.js";import{r as ka,M as Hn}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 Sw="modulepreload",Nw=function(n){return"/"+n},sm={},qe=function(e,t,s){let o=Promise.resolve();if(t&&t.length>0){let a=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};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=Nw(d),d in sm)return;sm[d]=!0;const u=d.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${f}`))return;const m=document.createElement("link");if(m.rel=u?"stylesheet":Sw,u||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),u)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)})},ws=["codex","copilot","claude"],wc="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function kw(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 Cw(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 O1(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>kw(n,e),decode:e=>Cw(n,e)}}function D1(n){const e=new RegExp(`(${wc})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const L1={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function z1(n){return`'${n.replace(/'/g,"'\\''")}'`}function fr(n,e){return e?[n,e]:[]}function qi(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const Vi="[0-9a-f-]{36}",F1="codex__",B1="copilot__",_w=new Set(["default","plan","acceptEdits","dontAsk","auto"]),U1={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(F1)&&!n.startsWith(B1),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:D1,...L1},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"]:[..._w.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>fr("--model",n),effort:n=>fr("--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=>qi(n,new RegExp(`--resume(?:=|\\s+)(${Vi})`))??qi(n,new RegExp(`--session-id(?:=|\\s+)(${Vi})`))}},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,nestedSubagents:!1,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,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},om={appServerValue:"priority",cliConfigValue:"fast"},Tw={kind:"codex",displayName:"Codex",binName:"codex",dirName:O1(F1),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:D1,...L1},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${z1(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=>fr("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(om.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:om,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=>qi(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${Vi})`))}},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,nestedSubagents:!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,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"never",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}},Ew={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:O1(B1),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${wc})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${wc})/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 ${z1(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=>fr("--model",n),effort:n=>fr("--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=>qi(n,new RegExp(`--resume(?:=|\\s+)(${Vi})`))}},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,nestedSubagents:!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,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},mr=Object.freeze({claude:U1,codex:Tw,copilot:Ew});function sn(n){return mr[n]}function Ca(){return ws.map(n=>mr[n])}function Pw(n,e){const t=Ca().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function Es(n){for(const e of ws)if(e!=="claude"&&mr[e].dirName.owns(n))return mr[e];return U1}function Rt(n){return Es(n).kind}function Sl(n,e,t){const s=mr[n].dirName;return t&&s.lossy?t:s.encode(e)}const Xs=Es(null).kind;var a1;const xi=((a1=Ca().find(n=>n.dirName.lossy))==null?void 0:a1.kind)??null;function ko(n){return Es(n).capabilities}function Vt(n){return sn(n).capabilities}function Aw(n,e){return ws.find(t=>t===n)??e}function jc(n){for(const e of Ca()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function Rw(n,e){return Es(n).sessionFile.urlId(e)}function $w(n,e){return Es(n).sessionFile.fileNameFromUrlId(e)}function W1(n,e,t){return sn(n).resume.command(e,t)}function Iw(n,e){const t=sn(n);return{command:t.binName,args:[...t.resume.args(e)]}}function rm(n){return n.replace(/\/+$/,"")||"/"}function Mw(n,e,t){var o;const s=rm(e);return((o=n.find(i=>Es(i.dirName).kind===t&&rm(i.path)===s))==null?void 0:o.dirName)??null}const Ow=[{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"}],Cd=[{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"}],H1=[...Cd,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],bi=Cd.slice(0,4);var l1;const Go=[{value:((l1=sn("codex").serviceTier)==null?void 0:l1.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],im={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:H1,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Go},Dw=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...im},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...im},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:H1,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Go},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:Cd,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Go},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:bi,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Go},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:bi,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Go},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:bi,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:bi,inputModalities:["text"],supportsPersonality:!0}],Lw=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],zw={claude:Ow,codex:Dw,copilot:Lw};function Fw(n){return zw[n]}function G(...n){return ly(cy(n))}const K1=new Map,Sc=new Set;function Bw(n,e){!Array.isArray(e)||e.length===0||(K1.set(n,e),Sc.forEach(t=>t()))}function Uw(n){return Sc.add(n),()=>Sc.delete(n)}const Nl="high",Ww=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function q1(n){return K1.get(n)??Fw(n)}function Or(n,e){const t=q1(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 V1(n,e){const t=Or(n,e),s=t==null?void 0:t.supportedReasoningEfforts;return s&&s.length>0?s:(t==null?void 0:t.supportsEffort)===!1||!Vt(n).reasoningEffort?[]:Ww}function Hw(n,e){var t;return((t=Or(n,e))==null?void 0:t.serviceTiers)??[]}function G1(n,e){return Hw(n,e).find(t=>t.value==="fast"||t.value==="priority"||t.label.toLowerCase()==="fast")}function Kw(n,e){var s;const t=(s=Or(n,e))==null?void 0:s.inputModalities;return t?t.includes("image"):Vt(n).imageInput}function qw(n,e){var s;const t=Vt(n).autoPermissionMode;return t==="always"?!0:t==="never"?!1:((s=Or(n,e))==null?void 0:s.supportsAutoMode)===!0}function Vw(n,e){return Vt(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function _a(n,e,t){var l,c;const s=V1(n,t);if(s.length===0)return"";const o=(l=Or(n,t))==null?void 0:l.defaultReasoningEffort,i=o&&s.some(d=>d.value===o)?o:s.some(d=>d.value===Nl)?Nl:((c=s[0])==null?void 0:c.value)??Nl,a=e||i;return s.some(d=>d.value===a)?a:i}function Gw(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Dr(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 Yw=ss("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=G(Yw({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(dy,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function dn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function 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=G("flex max-w-sm flex-col items-center gap-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const Xw=ss("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 vn(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t||e[5]!==i?(a=G(Xw({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 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=G("text-sm font-medium tracking-tight",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function yn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Y1(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"empty-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Jw(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 Qw=n=>{switch(n){case"success":return tj;case"info":return sj;case"warning":return nj;case"error":return oj;default:return null}},Zw=Array(12).fill(0),ej=({visible:n,className:e})=>ye.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},ye.createElement("div",{className:"sonner-spinner"},Zw.map((t,s)=>ye.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),tj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),nj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),sj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),oj=ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},ye.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"})),rj=ye.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"},ye.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ye.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ij=()=>{const[n,e]=ye.useState(document.hidden);return ye.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let aj=1;const lj=100,am=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:aj++};class cj{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-lj;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=am(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],ye.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(uj(d)&&!d.ok){i=!1;const f=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 f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(d instanceof Error){i=!1;const f=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){i=!1;const f=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description,h=typeof f=="object"&&!ye.isValidElement(f)?f:{message:f};this.create({id:s,type:"success",description:m,...h})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){i=!1;const u=typeof t.error=="function"?await t.error(d):t.error,f=typeof t.description=="function"?await t.description(d):t.description,p=typeof u=="object"&&!ye.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:f,...p})}}).finally(()=>{i&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((d,u)=>l.then(()=>a[0]==="reject"?u(a[1]):d(a[1])).catch(u));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=am(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 Jt=new cj,dj=(n,e)=>Jt.message(n,e),uj=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",fj=dj,mj=()=>Jt.toasts,pj=()=>Jt.getActiveToasts(),Is=Object.assign(fj,{success:Jt.success,info:Jt.info,warning:Jt.warning,error:Jt.error,custom:Jt.custom,message:Jt.message,promise:Jt.promise,dismiss:Jt.dismiss,loading:Jt.loading},{getHistory:mj,getToasts:pj});Jw("[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 vi(n){return n.label!==void 0}const hj=3,gj="24px",xj="16px",lm=4e3,bj=356,vj=14,yj=45,wj=200;function Mn(...n){return n.filter(Boolean).join(" ")}function jj(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const Sj=n=>{var e,t,s,o,i,a,l,c,d;const{invert:u,toast:f,unstyled:m,interacting:p,setHeights:h,visibleToasts:g,heights:x,index:b,toasts:y,expanded:v,removeToast:S,defaultRichColors:j,closeButton:k,style:C,cancelButtonStyle:N,actionButtonStyle:_,className:P="",descriptionClassName:A="",duration:T,position:E,gap:R,expandByDefault:I,classNames:$,icons:M,closeButtonAriaLabel:O="Close toast"}=n,[D,L]=ye.useState(null),[F,z]=ye.useState(null),[W,U]=ye.useState(!1),[H,K]=ye.useState(!1),[q,Y]=ye.useState(!1),[V,J]=ye.useState(!1),[Q,X]=ye.useState(!1),[Z,te]=ye.useState(0),[ne,oe]=ye.useState(0),re=ye.useRef(f.duration||T||lm),ae=ye.useRef(null),se=ye.useRef(null),fe=b===0,le=b+1<=g,ce=f.type,me=ce??"default",ue=f.dismissible!==!1,de=f.className||"",be=f.descriptionClassName||"",ge=ye.useMemo(()=>x.findIndex(ie=>ie.toastId===f.id)||0,[x,f.id]),he=ye.useMemo(()=>{var ie;return(ie=f.closeButton)!=null?ie:k},[f.closeButton,k]),je=ye.useMemo(()=>f.duration||T||lm,[f.duration,T]),Se=ye.useRef(0),Pe=ye.useRef(0),Re=ye.useRef(0),$e=ye.useRef(null),[De,Le]=E.split("-"),ze=ye.useMemo(()=>x.reduce((ie,xe,Ee)=>Ee>=ge?ie:ie+xe.height,0),[x,ge]),Te=ij(),_e=ye.useMemo(()=>{var ie;return(ie=n.swipeDirections)!=null?ie:jj(E)},[n.swipeDirections,E]),We=f.invert||u,Fe=ce==="loading";Pe.current=ye.useMemo(()=>ge*R+ze,[ge,ze]),ye.useEffect(()=>{re.current=je},[je]),ye.useEffect(()=>{U(!0)},[]),ye.useEffect(()=>{const ie=se.current;if(ie){const xe=ie.getBoundingClientRect().height;return oe(xe),h(Ee=>[{toastId:f.id,height:xe,position:f.position},...Ee]),()=>h(Ee=>Ee.filter(Ie=>Ie.toastId!==f.id))}},[h,f.id]),ye.useLayoutEffect(()=>{if(!W)return;const ie=se.current,xe=ie.style.height;ie.style.height="auto";const Ee=ie.getBoundingClientRect().height;ie.style.height=xe,oe(Ee),h(Ie=>Ie.find(Ke=>Ke.toastId===f.id)?Ie.map(Ke=>Ke.toastId===f.id?{...Ke,height:Ee}:Ke):[{toastId:f.id,height:Ee,position:f.position},...Ie])},[W,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const Ne=ye.useCallback(()=>{K(!0),te(Pe.current),h(ie=>ie.filter(xe=>xe.toastId!==f.id)),setTimeout(()=>{S(f)},wj)},[f,S,h,Pe]);ye.useEffect(()=>{if(f.promise&&ce==="loading"||f.duration===1/0||f.type==="loading")return;let ie;return v||p||Te?(()=>{if(Re.current<Se.current){const Ie=new Date().getTime()-Se.current;re.current=re.current-Ie}Re.current=new Date().getTime()})():(()=>{re.current!==1/0&&(Se.current=new Date().getTime(),ie=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ne()},re.current))})(),()=>clearTimeout(ie)},[v,p,f,ce,Te,Ne]),ye.useEffect(()=>{f.delete&&(Ne(),f.onDismiss==null||f.onDismiss.call(f,f))},[Ne,f.delete]);function pe(){var ie;if(M!=null&&M.loading){var xe;return ye.createElement("div",{className:Mn($==null?void 0:$.loader,f==null||(xe=f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":ce==="loading"},M.loading)}return ye.createElement(ej,{className:Mn($==null?void 0:$.loader,f==null||(ie=f.classNames)==null?void 0:ie.loader),visible:ce==="loading"})}const Oe=f.icon||(M==null?void 0:M[ce])||Qw(ce);var Ae,Be;return ye.createElement("li",{tabIndex:0,ref:se,className:Mn(P,de,$==null?void 0:$.toast,f==null||(e=f.classNames)==null?void 0:e.toast,$==null?void 0:$[me],f==null||(t=f.classNames)==null?void 0:t[me]),"data-sonner-toast":"","data-rich-colors":(Ae=f.richColors)!=null?Ae:j,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":Q,"data-removed":H,"data-visible":le,"data-y-position":De,"data-x-position":Le,"data-index":b,"data-front":fe,"data-swiping":q,"data-dismissible":ue,"data-type":ce,"data-invert":We,"data-swipe-out":V,"data-swipe-direction":F,"data-expanded":!!(v||I&&W),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":y.length-b,"--offset":`${H?Z:Pe.current}px`,"--initial-height":I?"auto":`${ne}px`,...C,...f.style},onDragEnd:()=>{Y(!1),L(null),$e.current=null},onPointerDown:ie=>{ie.button!==2&&(Fe||!ue||(ae.current=new Date,te(Pe.current),ie.target.setPointerCapture(ie.pointerId),ie.target.tagName!=="BUTTON"&&(Y(!0),$e.current={x:ie.clientX,y:ie.clientY})))},onPointerUp:()=>{var ie,xe,Ee;if(V||!ue)return;$e.current=null;const Ie=Number(((ie=se.current)==null?void 0:ie.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),He=Number(((xe=se.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ke=new Date().getTime()-((Ee=ae.current)==null?void 0:Ee.getTime()),nt=D==="x"?Ie:He,Ye=Math.abs(nt)/Ke;if((D==="x"?_e.includes(Ie>0?"right":"left"):_e.includes(He>0?"bottom":"top"))&&(Math.abs(nt)>=yj||Ye>.11)){te(Pe.current),f.onDismiss==null||f.onDismiss.call(f,f),z(D==="x"?Ie>0?"right":"left":He>0?"down":"up"),Ne(),J(!0);return}else{var Ue,rt;(Ue=se.current)==null||Ue.style.setProperty("--swipe-amount-x","0px"),(rt=se.current)==null||rt.style.setProperty("--swipe-amount-y","0px")}X(!1),Y(!1),L(null)},onPointerMove:ie=>{var xe,Ee,Ie;if(!$e.current||!ue||((xe=window.getSelection())==null?void 0:xe.toString().length)>0)return;const Ke=ie.clientY-$e.current.y,nt=ie.clientX-$e.current.x;!D&&(Math.abs(nt)>1||Math.abs(Ke)>1)&&L(Math.abs(nt)>Math.abs(Ke)?"x":"y");let Ye={x:0,y:0};const Me=Ue=>1/(1.5+Math.abs(Ue)/20);if(D==="y"){if(_e.includes("top")||_e.includes("bottom"))if(_e.includes("top")&&Ke<0||_e.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(D==="x"&&(_e.includes("left")||_e.includes("right")))if(_e.includes("left")&&nt<0||_e.includes("right")&&nt>0)Ye.x=nt;else{const Ue=nt*Me(nt);Ye.x=Math.abs(Ue)<Math.abs(nt)?Ue:nt}(Math.abs(Ye.x)>0||Math.abs(Ye.y)>0)&&X(!0),(Ee=se.current)==null||Ee.style.setProperty("--swipe-amount-x",`${Ye.x}px`),(Ie=se.current)==null||Ie.style.setProperty("--swipe-amount-y",`${Ye.y}px`)}},he&&!f.jsx&&ce!=="loading"?ye.createElement("button",{"aria-label":O,"data-disabled":Fe,"data-close-button":!0,onClick:Fe||!ue?()=>{}:()=>{Ne(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Mn($==null?void 0:$.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(Be=M==null?void 0:M.close)!=null?Be:rj):null,(ce||f.icon||f.promise)&&f.icon!==null&&((M==null?void 0:M[ce])!==null||f.icon)?ye.createElement("div",{"data-icon":"",className:Mn($==null?void 0:$.icon,f==null||(o=f.classNames)==null?void 0:o.icon)},ce==="loading"?f.icon||pe():f.promise?pe():null,ce!=="loading"?Oe:null):null,ye.createElement("div",{"data-content":"",className:Mn($==null?void 0:$.content,f==null||(i=f.classNames)==null?void 0:i.content)},ye.createElement("div",{"data-title":"",className:Mn($==null?void 0:$.title,f==null||(a=f.classNames)==null?void 0:a.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?ye.createElement("div",{"data-description":"",className:Mn(A,be,$==null?void 0:$.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),ye.isValidElement(f.cancel)?f.cancel:f.cancel&&vi(f.cancel)?ye.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||N,onClick:ie=>{vi(f.cancel)&&ue&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,ie),Ne())},className:Mn($==null?void 0:$.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,ye.isValidElement(f.action)?f.action:f.action&&vi(f.action)?ye.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||_,onClick:ie=>{vi(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,ie),!ie.defaultPrevented&&Ne())},className:Mn($==null?void 0:$.actionButton,f==null||(d=f.classNames)==null?void 0:d.actionButton)},f.action.label):null)};function cm(){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 Nj(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?xj:gj;function c(d){["top","right","bottom","left"].forEach(u=>{t[`${a}-${u}`]=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 kj=ye.forwardRef(function(e,t){const{id:s,invert:o,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:u,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:x=hj,toastOptions:b,dir:y=cm(),gap:v=vj,icons:S,customAriaLabel:j,containerAriaLabel:k="Notifications"}=e,[C,N]=ye.useState([]),_=ye.useMemo(()=>s?C.filter(U=>U.toasterId===s):C.filter(U=>!U.toasterId),[C,s]),P=ye.useMemo(()=>Array.from(new Set([i].concat(_.filter(U=>U.position).map(U=>U.position)))),[_,i]),[A,T]=ye.useState([]),[E,R]=ye.useState(!1),[I,$]=ye.useState(!1),[M,O]=ye.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=ye.useRef(null),L=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=ye.useRef(null),z=ye.useRef(!1),W=ye.useCallback(U=>{N(H=>{var K;return(K=H.find(q=>q.id===U.id))!=null&&K.delete||Jt.dismiss(U.id),H.filter(({id:q})=>q!==U.id)})},[]);return ye.useEffect(()=>Jt.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{N(H=>H.map(K=>K.id===U.id?{...K,delete:!0}:K))});return}setTimeout(()=>{ry.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]})})})}),[]),ye.useEffect(()=>{if(m!=="system"){O(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?O("dark"):O("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:H})=>{O(H?"dark":"light")})}catch{U.addListener(({matches:K})=>{try{O(K?"dark":"light")}catch(q){console.error(q)}})}},[m]),ye.useEffect(()=>{C.length<=1&&R(!1)},[C]),ye.useEffect(()=>{const U=H=>{var K;if(a.length>0&&a.every(V=>H[V]||H.code===V)){var Y;R(!0),(Y=D.current)==null||Y.focus()}H.code==="Escape"&&(document.activeElement===D.current||(K=D.current)!=null&&K.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[a]),ye.useEffect(()=>{if(D.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,z.current=!1)}},[D.current]),ye.createElement("section",{ref:t,"aria-label":j??`${k} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},P.map((U,H)=>{var K;const[q,Y]=U.split("-");return _.length?ye.createElement("ol",{key:U,dir:y==="auto"?cm():y,tabIndex:-1,ref:D,className:d,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":q,"data-x-position":Y,style:{"--front-toast-height":`${((K=A[0])==null?void 0:K.height)||0}px`,"--width":`${bj}px`,"--gap":`${v}px`,...g,...Nj(u,f)},onBlur:V=>{z.current&&!V.currentTarget.contains(V.relatedTarget)&&(z.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||z.current||(z.current=!0,F.current=V.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{I||R(!1)},onDragEnd:()=>R(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},_.filter(V=>!V.position&&H===0||V.position===U).map((V,J)=>{var Q,X;return ye.createElement(Sj,{key:V.id,icons:S,index:J,toast:V,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:I,position:U,style:b==null?void 0:b.style,unstyled:b==null?void 0:b.unstyled,classNames:b==null?void 0:b.classNames,cancelButtonStyle:b==null?void 0:b.cancelButtonStyle,actionButtonStyle:b==null?void 0:b.actionButtonStyle,closeButtonAriaLabel:b==null?void 0:b.closeButtonAriaLabel,removeToast:W,toasts:_.filter(Z=>Z.position==V.position),heights:A.filter(Z=>Z.position==V.position),setHeights:T,expandByDefault:l,gap:v,expanded:E,swipeDirections:e.swipeDirections})})):null}))}),Cj=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(Wn,{className:"size-4"}),info:r.jsx(cd,{className:"size-4"}),warning:r.jsx(bn,{className:"size-4"}),error:r.jsx(uy,{className:"size-4"}),loading:r.jsx(lt,{className:"size-4 animate-spin"})},o={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},e[2]=s,e[3]=o):(s=e[2],o=e[3]);let i;return e[4]!==t?(i=r.jsx(kj,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function _j(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){Is.dismiss("app-error");return}Is.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]),w.useEffect(c,d);let u,f;e[4]!==i||e[5]!==o?(u=()=>{if(!o){Is.dismiss("model-fallback");return}Is.warning(o,{id:"model-fallback",duration:1/0,onDismiss:i})},f=[i,o],e[4]=i,e[5]=o,e[6]=u,e[7]=f):(u=e[6],f=e[7]),w.useEffect(u,f);let m,p;e[8]!==a?(m=()=>{if(!a){Is.dismiss("session-connection");return}Is.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]),w.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(Cj,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const Tt="local",X1="cogpit-last-path::",Nc=new Map;function yt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Tt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Tt}function Bs(){return yt()!==Tt}function J1(){const n=yt();return n===Tt?"":`/hub/${n}`}function Q1(n){const e=J1();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")?`${e}${n}`:n}let pr=null;function Z1(n){n!==pr&&(pr=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function js(){return pr}function Li(n){return n===Tt?0:Nc.get(n)??0}function Tj(n,e){if(n===Tt||!Number.isSafeInteger(e)||e<0)return!1;const t=Nc.get(n);return t!==void 0&&e<=t?!1:(Nc.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function kn(){const n=yt(),e=Li(n);return e===0?n:`${n}@${e}`}function Kt(n){const e=yt(),t=kn();return pr!==null?`${n}::${t}::${pr}`:e===Tt?n:`${n}::${t}`}function Fo(n,e){sessionStorage.setItem(`${X1}${n}`,e)}function Ss(n){const t=sessionStorage.getItem(`${X1}${n}`)??(n===Tt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const dm="cogpit-network-token",Ej=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function Ta(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!Ej.has(e)}function Ea(){try{localStorage.removeItem(dm),sessionStorage.removeItem(dm)}catch{}}typeof window<"u"&&Ea();const Pj={edition:"personal",needsBootstrap:!1};let hr=null,bo=null;function eg(){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 bo=e.edition==="team"?"team":"personal",{edition:bo,needsBootstrap:bo==="team"&&e.needsBootstrap===!0}}).catch(()=>(hr=null,Pj))}function tg(){return hr??(hr=eg()),hr}function um(){return hr=eg(),hr}function ng(){return tg().then(n=>n.edition)}async function Aj(){if(!Ta()&&bo!=="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 Rj(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Ea()}}function fm(){return Ea(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function sg(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=Q1(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(Ta()||bo==="team")return fm();if(bo===null)return ng().then(i=>i==="team"?fm():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 ve(n,e){return sg(n,e,!0)}function ps(n,e){return sg(n,e,!1)}function Lr(n){return Q1(n)}let mm=!1;function $j(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 Ij(){if(!mm){mm=!0;try{const n=await ve("/api/models");if(!n.ok)return;const e=await n.json();for(const t of ws){const s=e==null?void 0:e[t];$j(s)&&Bw(t,s)}}catch{}}}function og(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],w.useEffect(Mj,t);let s;return e[1]!==n?(s=()=>q1(n),e[1]=n,e[2]=s):s=e[2],w.useSyncExternalStore(Uw,s)}function Mj(){Ij()}function Kn(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(my,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function qn(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(py,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Vn(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,u=a===void 0?"bottom":a,f=l===void 0?4:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(d1,{"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]!==u||e[15]!==f||e[16]!==p?(h=r.jsx(f1,{children:r.jsx(m1,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:u,sideOffset:f,children:p})}),e[12]=c,e[13]=d,e[14]=u,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function tn(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(u1,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Us(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(p1,{"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 Pt(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=G("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l||e[10]!==a?(c=r.jsx(c1,{"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 Oj(n){const e=B.c(15);let t,s,o,i,a;e[0]!==n?({className:o,children:s,checked:t,inset:i,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);let l;e[6]!==o?(l=G("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o),e[6]=o,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:r.jsx(by,{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(gt,{})})}),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(gy,{"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 Gi(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":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function _d(n){const e=B.c(15);let t,s,o,i,a;e[0]!==n?({className:s,children:t,inset:o,closeOnClick:a,...i}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=a===void 0?!0:a;let c;e[6]!==s?(c=G("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[6]=s,e[7]=c):c=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:r.jsx(hy,{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(gt,{})})}),e[8]=d):d=e[8];let u;return e[9]!==t||e[10]!==l||e[11]!==o||e[12]!==i||e[13]!==c?(u=r.jsxs(fy,{"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]=u):u=e[14],u}function gr(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(dd,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}sn("claude").contextWindow.compactBuffer;function Dj(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=sn(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 Lj(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=Dj(e,t),c=l-sn(t).contextWindow.compactBuffer;return{used:a,limit:l,compactAt:c,percent:Math.min(100,a/c*100),percentAbsolute:Math.min(100,a/l*100)}}function hn(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}const zj=["fable","mythos","opus","sonnet","haiku"];function pm(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Js(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const o of zj){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`${pm(o)}${a}${t}`}if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(pm).join(" ");return`GPT-${o}${a?` ${a}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function mt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Un(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 Fj(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function rg(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function zr(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 Td(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 Cn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function Tn(n){return Es(n).dirName.decode(n)??n}function Pa(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function Aa(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 ts(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function Ns(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function ig(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return Lj(t.message.usage,t.message.model??"","claude")}return null}const ag={claude:wo,codex:Pr,copilot:h1},Pd={claude:"Claude",codex:"Codex",copilot:"Copilot"},Bj={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},Uj={claude:null,codex:"Codex",copilot:"Copilot"},Wj={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"}},Hj={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},Kj={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},qj={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 Vj(n){return qj[n]}function Gj(n){return ag[n]}function Ra(n){return Pd[n]}function rF(n){return Bj[n]}function Yj(n){return Uj[n]}function iF(n){return Wj[n]}function Xj(n){return Kj[n]}function Jj(n){return Hj[n]}const hm=Es(null).kind,lg=[hm,...ws.filter(n=>n!==hm)];function Qj(n){return`This ${Pd[n]} session is controlled by another process. Cogpit can only view it.`}const kc=lg.map(n=>({value:n,label:Pd[n],Icon:ag[n]}));function Zj(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 e4(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?Ad(e,n):"Default"}function Ad(n,e){var t;return((t=Zj(n,e))==null?void 0:t.label)??Js(n)}function cg(n){const e=B.c(11),{option:t,descriptionWidth:s}=n,o=s===void 0?"max-w-64":s,i=t.menuLabel??t.label;let a;e[0]!==i?(a=r.jsx("span",{children:i}),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==o||e[3]!==t.description?(l=t.description&&r.jsx("span",{className:G(o,"truncate text-xs font-normal text-muted-foreground"),children:t.description}),e[2]=o,e[3]=t.description,e[4]=l):l=e[4];let c;e[5]!==a||e[6]!==l?(c=r.jsxs("span",{className:"flex min-w-0 flex-col items-start",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7];let d;return e[8]!==t.value||e[9]!==c?(d=r.jsx(_d,{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 t4(n){var A,T;const e=B.c(33),{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}=n;let c;e[0]!==t?(c=((A=kc.find(E=>E.value===t))==null?void 0:A.label)??t,e[0]=t,e[1]=c):c=e[1];const d=c;let u;e[2]!==i||e[3]!==a||e[4]!==o?(u=((T=a.find(E=>E.value===o))==null?void 0:T.label)??i,e[2]=i,e[3]=a,e[4]=o,e[5]=u):u=e[5];const f=u;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} / ${f}`;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(tt,{"data-icon":"inline-end"}),e[9]=g):g=e[9];let x;e[10]!==h?(x=r.jsxs(qn,{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(Us,{children:"Agent"}),e[12]=b):b=e[12];let y;e[13]!==s?(y=E=>s(E),e[13]=s,e[14]=y):y=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=kc.map(s4),e[15]=v):v=e[15];let S;e[16]!==t||e[17]!==y?(S=r.jsxs(tn,{children:[b,r.jsx(Gi,{value:t,onValueChange:y,children:v})]}),e[16]=t,e[17]=y,e[18]=S):S=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(gr,{}),e[19]=j):j=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Us,{children:"Model"}),e[20]=k):k=e[20];let C;e[21]!==a?(C=a.map(n4),e[21]=a,e[22]=C):C=e[22];let N;e[23]!==l||e[24]!==C||e[25]!==o?(N=r.jsxs(tn,{children:[k,r.jsx(Gi,{value:o,onValueChange:l,children:C})]}),e[23]=l,e[24]=C,e[25]=o,e[26]=N):N=e[26];let _;e[27]!==S||e[28]!==N?(_=r.jsxs(Vn,{"aria-label":"Agent and model",className:"w-80",children:[S,j,N]}),e[27]=S,e[28]=N,e[29]=_):_=e[29];let P;return e[30]!==_||e[31]!==x?(P=r.jsxs(Kn,{children:[x,_]}),e[30]=_,e[31]=x,e[32]=P):P=e[32],P}function n4(n){return r.jsx(cg,{option:n,descriptionWidth:"max-w-80"},n.value)}function s4(n){const e=n.Icon;return r.jsxs(_d,{value:n.value,children:[r.jsx(e,{}),n.label]},n.value)}function o4(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(r4),e[0]=t,e[1]=c):c=e[1];const d=c.length;let u;e[2]!==s?(u=new Set(s),e[2]=s,e[3]=u):u=e[3];const f=u,m=w.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(vy,{"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(At,{"data-icon":"inline-end",className:"animate-spin"}):r.jsx(tt,{"data-icon":"inline-end"}),e[8]=a,e[9]=t.length,e[10]=b):b=e[10];let y;e[11]!==x||e[12]!==b?(y=r.jsxs(qn,{render:p,children:[h,x,b]}),e[11]=x,e[12]=b,e[13]=y):y=e[13];let v;e[14]!==m?(v=r.jsx(Us,{id:m,children:"MCP servers"}),e[14]=m,e[15]=v):v=e[15];const S=a?"animate-spin":void 0;let j;e[16]!==S?(j=r.jsx(At,{"data-icon":"inline-start",className:S}),e[16]=S,e[17]=j):j=e[17];let k;e[18]!==i||e[19]!==j?(k=r.jsxs(Pt,{closeOnClick:!1,onClick:i,children:[j,"Refresh status"]}),e[18]=i,e[19]=j,e[20]=k):k=e[20];let C;e[21]!==a||e[22]!==t.length?(C=t.length===0&&r.jsx(Pt,{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]!==f||e[27]!==t){let T;e[29]!==l||e[30]!==o||e[31]!==f?(T=E=>E.status!=="connected"?r.jsxs(Pt,{onClick:()=>l(E.name),className:"items-center",children:[r.jsx("span",{className:"size-2 rounded-full bg-warning"}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name}),r.jsx("span",{className:"text-xs text-warning",children:"Needs auth"})]},E.name):r.jsxs(Oj,{checked:f.has(E.name),onCheckedChange:()=>o(E.name),children:[r.jsx("span",{className:"size-2 rounded-full bg-success"}),r.jsx("span",{className:"truncate",children:E.name})]},E.name),e[29]=l,e[30]=o,e[31]=f,e[32]=T):T=e[32],N=t.map(T),e[24]=l,e[25]=o,e[26]=f,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(tn,{children:[v,k,C,N]}),e[33]=k,e[34]=C,e[35]=N,e[36]=v,e[37]=_):_=e[37];let P;e[38]!==m||e[39]!==_?(P=r.jsx(Vn,{"aria-labelledby":m,className:"w-64",children:_}),e[38]=m,e[39]=_,e[40]=P):P=e[40];let A;return e[41]!==P||e[42]!==y?(A=r.jsxs(Kn,{children:[y,P]}),e[41]=P,e[42]=y,e[43]=A):A=e[43],A}function r4(n){return n.status==="connected"}function gm(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 u=d,f=w.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]!==u?(p=r.jsx("span",{className:"truncate",children:u}),e[6]=u,e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(tt,{"data-icon":"inline-end"}),e[8]=h):h=e[8];let g;e[9]!==a||e[10]!==m||e[11]!==p?(g=r.jsxs(qn,{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]!==f?(x=r.jsx(Us,{id:f,className:"sr-only",children:c}),e[13]=c,e[14]=f,e[15]=x):x=e[15];let b;e[16]!==o?(b=o.map(i4),e[16]=o,e[17]=b):b=e[17];let y;e[18]!==i||e[19]!==b||e[20]!==t?(y=r.jsx(Gi,{value:t,onValueChange:i,children:b}),e[18]=i,e[19]=b,e[20]=t,e[21]=y):y=e[21];let v;e[22]!==x||e[23]!==y?(v=r.jsxs(tn,{children:[x,y]}),e[22]=x,e[23]=y,e[24]=v):v=e[24];let S;e[25]!==f||e[26]!==v?(S=r.jsx(Vn,{"aria-labelledby":f,className:"w-48",children:v}),e[25]=f,e[26]=v,e[27]=S):S=e[27];let j;return e[28]!==S||e[29]!==g?(j=r.jsxs(Kn,{children:[g,S]}),e[28]=S,e[29]=g,e[30]=j):j=e[30],j}function i4(n){return r.jsx(cg,{option:n},n.value)}function dg(n,e){return Vj(n).filter(t=>t.value!=="auto"||e)}function a4(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,u,f,m,p,h,g,x,b;if(e[0]!==t||e[1]!==a||e[2]!==s||e[3]!==o){const k=dg(t,a),C=k.find(A=>A.value===s)??k[0];u=Kn;let N,_;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),N=r.jsx(g1,{"data-icon":"inline-start"}),e[15]=N,e[16]=_):(N=e[15],_=e[16]);let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(tt,{"data-icon":"inline-end"}),e[17]=P):P=e[17],b=r.jsxs(qn,{render:_,children:[N,r.jsx("span",{className:"truncate",children:C.label}),P]}),d=Vn,g="Access policy",x="w-72",c=tn,e[18]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Us,{children:"Permissions"}),e[18]=h):h=e[18],l=Gi,f=s,e[19]!==o?(m=A=>o(A),e[19]=o,e[20]=m):m=e[20],p=k.map(l4),e[0]=t,e[1]=a,e[2]=s,e[3]=o,e[4]=l,e[5]=c,e[6]=d,e[7]=u,e[8]=f,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],u=e[7],f=e[8],m=e[9],p=e[10],h=e[11],g=e[12],x=e[13],b=e[14];let y;e[21]!==l||e[22]!==f||e[23]!==m||e[24]!==p?(y=r.jsx(l,{value:f,onValueChange:m,children:p}),e[21]=l,e[22]=f,e[23]=m,e[24]=p,e[25]=y):y=e[25];let v;e[26]!==c||e[27]!==h||e[28]!==y?(v=r.jsxs(c,{children:[h,y]}),e[26]=c,e[27]=h,e[28]=y,e[29]=v):v=e[29];let S;e[30]!==d||e[31]!==v||e[32]!==g||e[33]!==x?(S=r.jsx(d,{"aria-label":g,className:x,children:v}),e[30]=d,e[31]=v,e[32]=g,e[33]=x,e[34]=S):S=e[34];let j;return e[35]!==u||e[36]!==S||e[37]!==b?(j=r.jsxs(u,{children:[b,S]}),e[35]=u,e[36]=S,e[37]=b,e[38]=j):j=e[38],j}function l4(n){return r.jsx(_d,{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 c4(n){const e=B.c(62),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,isNewSession:h,worktreeEnabled:g,onWorktreeEnabledChange:x,ultracodeEnabled:b,onUltracodeEnabledChange:y,autoModeAvailable:v,permissionMode:S,onPermissionModeChange:j,mcpServers:k,selectedMcpServers:C,onToggleMcpServer:N,onRefreshMcpServers:_,mcpLoading:P,onMcpAuth:A,changeAndApply:T,trailingExtra:E}=n;let R;e[0]!==t?(R=Vt(t),e[0]=t,e[1]=R):R=e[1];const{worktrees:I,ultracode:$,settingsApply:M}=R,O=w.useId(),D=h?void 0:M==="live"?"Changes apply live":"Changes apply next turn",L=D?O:void 0;let F;e[2]!==D||e[3]!==O?(F=D&&r.jsx("span",{id:O,className:"sr-only",children:D}),e[2]=D,e[3]=O,e[4]=F):F=e[4];let z;e[5]!==t||e[6]!==a||e[7]!==s||e[8]!==l||e[9]!==i||e[10]!==o?(z=s?r.jsx(t4,{agentKind:t,onAgentKindChange:s,value:o,fallbackLabel:i,options:a,onChange:l}):r.jsx(gm,{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]!==u||e[15]!==c||e[16]!==o||e[17]!==b?(W=d.length>0&&r.jsx(gm,{value:_a(t,c,o),fallbackLabel:"Effort",ariaLabel:"Reasoning effort",options:d,onChange:u,disabled:b,title:b?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=t,e[13]=d,e[14]=u,e[15]=c,e[16]=o,e[17]=b,e[18]=W):W=e[18];let U;e[19]!==T||e[20]!==m||e[21]!==f||e[22]!==p?(U=f&&p&&r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost",size:"xs","aria-pressed":!!m,onClick:()=>T(()=>p(!m)),title:f.description,children:[r.jsx(Ki,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]}),e[19]=T,e[20]=m,e[21]=f,e[22]=p,e[23]=U):U=e[23];let H;e[24]!==t||e[25]!==v||e[26]!==T||e[27]!==j||e[28]!==S?(H=j&&S&&r.jsx(a4,{agentKind:t,mode:S,onChange:Q=>T(()=>j(Q)),autoAvailable:v}),e[24]=t,e[25]=v,e[26]=T,e[27]=j,e[28]=S,e[29]=H):H=e[29];let K;e[30]!==h||e[31]!==x||e[32]!==I||e[33]!==g?(K=I&&h&&x&&r.jsxs(ee,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx(Fn,{"data-icon":"inline-start"}),"Worktree"]}),e[30]=h,e[31]=x,e[32]=I,e[33]=g,e[34]=K):K=e[34];let q;e[35]!==T||e[36]!==y||e[37]!==$||e[38]!==b?(q=$&&y&&r.jsxs(ee,{type:"button",variant:b?"secondary":"ghost",size:"xs","aria-pressed":!!b,onClick:()=>T(()=>y(!b)),title:"Ultracode: XHigh effort + standing multi-agent workflow orchestration",children:[r.jsx(Ki,{"data-icon":"inline-start",className:G(b&&"fill-current")}),"Ultracode"]}),e[35]=T,e[36]=y,e[37]=$,e[38]=b,e[39]=q):q=e[39];let Y;e[40]!==T||e[41]!==P||e[42]!==k||e[43]!==A||e[44]!==_||e[45]!==N||e[46]!==C?(Y=N&&_&&A&&(P||k&&k.length>0)&&r.jsx(o4,{servers:k??[],selected:C??[],onToggle:Q=>T(()=>N(Q)),onRefresh:_,loading:P??!1,onAuth:A}),e[40]=T,e[41]=P,e[42]=k,e[43]=A,e[44]=_,e[45]=N,e[46]=C,e[47]=Y):Y=e[47];let V;e[48]!==Y||e[49]!==z||e[50]!==W||e[51]!==U||e[52]!==H||e[53]!==K||e[54]!==q||e[55]!==E?(V=r.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1.5",children:[z,W,U,H,K,q,Y,E]}),e[48]=Y,e[49]=z,e[50]=W,e[51]=U,e[52]=H,e[53]=K,e[54]=q,e[55]=E,e[56]=V):V=e[56];let J;return e[57]!==D||e[58]!==V||e[59]!==L||e[60]!==F?(J=r.jsxs("div",{className:"flex items-center pb-1.5 pl-6 pr-3",role:"group",title:D,"aria-describedby":L,children:[F,V]}),e[57]=D,e[58]=V,e[59]=L,e[60]=F,e[61]=J):J=e[61],J}function kt(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=G("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(dd,{"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 d4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("label",{"data-slot":"label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function u4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("fieldset",{"data-slot":"field-set",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function f4(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"legend":o;let a;e[4]!==t?(a=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==a||e[8]!==i?(l=r.jsx("legend",{"data-slot":"field-legend","data-variant":i,className:a,...s}),e[6]=s,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}function Io(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const m4=ss("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 St(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t||e[5]!==i?(a=G(m4({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 aF(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"field-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Nt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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(d4,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Co(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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 bs(n){var u;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 f;e[5]!==o?(f=[...new Map(o.map(h4)).values()],e[5]=o,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){a=(u=m[0])==null?void 0:u.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(p4)}),e[7]=m,e[8]=p):p=e[8],a=p}const l=a;if(!l)return null;let c;e[9]!==s?(c=G("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let d;return e[11]!==l||e[12]!==i||e[13]!==c?(d=r.jsx("div",{role:"alert","data-slot":"field-error",className:c,...i,children:l}),e[11]=l,e[12]=i,e[13]=c,e[14]=d):d=e[14],d}function p4(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function h4(n){return[n==null?void 0:n.message,n]}const Cc=wy;function g4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("scroll-my-1 p-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx($y,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function _c(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-1 text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Sy,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Tc(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({className:s,size:i,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==s?(l=G("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out select-none data-pressed:scale-[0.98] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none motion-reduce:data-pressed:scale-100 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ky,{render:r.jsx(tt,{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(jy,{"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 Ec(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 u=i===void 0?"bottom":i,f=a===void 0?4:a,m=l===void 0?"center":l,p=c===void 0?0:c,h=d===void 0?!0:d;let g;e[9]!==s?(g=G("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(x4,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=r.jsx(Cy,{children:t}),e[12]=t,e[13]=b):b=e[13];let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(b4,{}),e[14]=y):y=e[14];let v;e[15]!==o||e[16]!==g||e[17]!==b?(v=r.jsxs(Ny,{"data-slot":"select-content",className:g,...o,children:[x,b,y]}),e[15]=o,e[16]=g,e[17]=b,e[18]=v):v=e[18];let S;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==u||e[23]!==f||e[24]!==v?(S=r.jsx(_y,{children:r.jsx(Ty,{side:u,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=u,e[23]=f,e[24]=v,e[25]=S):S=e[25],S}function Pc(n){const e=B.c(13);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(Ey,{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(Py,{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(gt,{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(yy,{"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 x4(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Ar,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Ay,{"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 b4(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(tt,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Ry,{"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 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(x1,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function y4(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Iy,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function w4(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(xa,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function j4(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(pd,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function S4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("fixed inset-0 z-50 bg-black/55 duration-200 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(hd,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function N4(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(S4,{}),e[6]=d):d=e[6];let u;e[7]!==s?(u=G("fixed z-50 flex flex-col border-border bg-popover text-popover-foreground shadow-lg duration-200 ease-out data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-[560px] data-[side=right]:border-l","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-[560px] data-[side=left]:border-r","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b","data-open:animate-in data-open:fade-in-0 data-[side=right]:data-open:slide-in-from-right data-[side=left]:data-open:slide-in-from-left data-[side=bottom]:data-open:slide-in-from-bottom data-[side=top]:data-open:slide-in-from-top","data-closed:animate-out data-closed:fade-out-0 data-[side=right]:data-closed:slide-out-to-right data-[side=left]:data-closed:slide-out-to-left data-[side=bottom]:data-closed:slide-out-to-bottom data-[side=top]:data-closed:slide-out-to-top",s),e[7]=s,e[8]=u):u=e[8];let f;e[9]!==c?(f=c&&r.jsxs(xa,{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(st,{"data-icon":"inline-start",className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]}),e[9]=c,e[10]=f):f=e[10];let m;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==u||e[15]!==f?(m=r.jsxs(j4,{children:[d,r.jsxs(md,{"data-slot":"sheet-content","data-side":l,className:u,...o,children:[t,f]})]}),e[11]=t,e[12]=o,e[13]=l,e[14]=u,e[15]=f,e[16]=m):m=e[16],m}function k4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col gap-1.5 border-b p-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"sheet-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function C4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm font-medium",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ud,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function _4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(fd,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function nr(n){const e=B.c(10),{label:t,children:s,wide:o}=n,a=(o===void 0?!1:o)&&"col-span-2";let l;e[0]!==a?(l=G("min-w-0 gap-1 py-1",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==t?(c=r.jsx(Nt,{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 u;return e[6]!==l||e[7]!==c||e[8]!==d?(u=r.jsxs(St,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=u):u=e[9],u}function yi(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 u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(_c,{}),e[2]=u):u=e[2];let f;e[3]!==s||e[4]!==c?(f=r.jsx(Tc,{"aria-label":s,title:c,className:"h-10 w-full",children:u}),e[3]=s,e[4]=c,e[5]=f):f=e[5];let m;e[6]!==i?(m=i.map(T4),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(Ec,{children:r.jsx(g4,{children:m})}),e[8]=m,e[9]=p):p=e[9];let h;e[10]!==l||e[11]!==d||e[12]!==f||e[13]!==p||e[14]!==o?(h=r.jsxs(Cc,{value:o,onValueChange:d,disabled:l,children:[f,p]}),e[10]=l,e[11]=d,e[12]=f,e[13]=p,e[14]=o,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==h?(g=r.jsx(nr,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function T4(n){return r.jsx(Pc,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function E4(n){const e=B.c(32),{agentKind:t,onAgentKindChange:s,selectedModel:o,onModelChange:i,modelOptions:a,selectedEffort:l,onEffortChange:c,effortOptions:d,ultracodeEnabled:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,permissionMode:h,permissionOptions:g,onPermissionModeChange:x,changeAndApply:b}=n;let y;e[0]!==t||e[1]!==l||e[2]!==o?(y=_a(t,l,o),e[0]=t,e[1]=l,e[2]=o,e[3]=y):y=e[3];const v=y;let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[4]=S):S=e[4];let j;e[5]!==t||e[6]!==s?(j=s&&r.jsx(yi,{label:"Agent",ariaLabel:"Agent",value:t,options:kc,onChange:A=>s(A)}),e[5]=t,e[6]=s,e[7]=j):j=e[7];let k;e[8]!==a||e[9]!==i||e[10]!==o?(k=r.jsx(yi,{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]!==u?(C=d.length>0&&r.jsx(yi,{label:"Reasoning",ariaLabel:"Reasoning effort",value:v,options:d,onChange:c,disabled:u,title:u?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[12]=d,e[13]=v,e[14]=c,e[15]=u,e[16]=C):C=e[16];let N;e[17]!==b||e[18]!==m||e[19]!==f||e[20]!==p?(N=f&&p&&r.jsx(nr,{label:"Speed",children:r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>b(()=>p(!m)),title:f.description,className:"h-10 justify-start",children:[r.jsx(Ki,{"data-icon":"inline-start",className:G(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[17]=b,e[18]=m,e[19]=f,e[20]=p,e[21]=N):N=e[21];let _;e[22]!==x||e[23]!==h||e[24]!==g?(_=x&&h&&r.jsx(yi,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:A=>x(A)}),e[22]=x,e[23]=h,e[24]=g,e[25]=_):_=e[25];let P;return e[26]!==j||e[27]!==k||e[28]!==C||e[29]!==N||e[30]!==_?(P=r.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[S,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[j,k,C,N,_]})]}),e[26]=j,e[27]=k,e[28]=C,e[29]=N,e[30]=_,e[31]=P):P=e[31],P}function P4(n){const e=B.c(30),{agentKind:t,isNewSession:s,worktreeEnabled:o,onWorktreeEnabledChange:i,ultracodeEnabled:a,onUltracodeEnabledChange:l,mcpServers:c,selectedMcpServers:d,onToggleMcpServer:u,onRefreshMcpServers:f,mcpLoading:m,onMcpAuth:p,changeAndApply:h}=n;let g;e[0]!==t?(g=Vt(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:b}=g,y=!!(u&&f&&p&&(m||c&&c.length>0)),v=!!(x&&s&&i||b&&l||y);let S;e[2]!==d?(S=d??[],e[2]=d,e[3]=S):S=e[3];let j;e[4]!==S?(j=new Set(S),e[4]=S,e[5]=j):j=e[5];const k=j;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(nr,{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(Fn,{"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(nr,{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(Ki,{"data-icon":"inline-start",className:G(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=a,e[16]=_):_=e[16];let P;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==u||e[23]!==k||e[24]!==y?(P=y&&u&&f&&p&&r.jsx(nr,{label:"Connections",wide:!0,children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(ee,{type:"button",variant:"ghost",onClick:f,className:"min-h-10 justify-start",children:[r.jsx(At,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(T=>{const E=k.has(T.name),R=T.status==="connected";return r.jsxs(ee,{type:"button",variant:"ghost","aria-pressed":R?E:void 0,onClick:()=>R?h(()=>u(T.name)):p(T.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:G("size-2 shrink-0 rounded-full",R&&E?"bg-success":R?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:R?E?"On":"Off":"Connect"})]},T.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=f,e[22]=u,e[23]=k,e[24]=y,e[25]=P):P=e[25];let A;return e[26]!==N||e[27]!==_||e[28]!==P?(A=r.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[C,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[N,_,P]})]}),e[26]=N,e[27]=_,e[28]=P,e[29]=A):A=e[29],A}function A4(n){var fe,le;const e=B.c(78),{open:t,onOpenChange:s,agentKind:o,onAgentKindChange:i,selectedModel:a,resolvedDefaultName:l,catalogOptions:c,modelOptions:d,onModelChange:u,selectedEffort:f,effortOptions:m,onEffortChange:p,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,isNewSession:b,worktreeEnabled:y,onWorktreeEnabledChange:v,ultracodeEnabled:S,onUltracodeEnabledChange:j,autoModeAvailable:k,permissionMode:C,onPermissionModeChange:N,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:R,mobileExtra:I,changeAndApply:$}=n;let M;e[0]!==o||e[1]!==f||e[2]!==a?(M=_a(o,f,a),e[0]=o,e[1]=f,e[2]=a,e[3]=M):M=e[3];const O=M;let D,L;e[4]!==o||e[5]!==k||e[6]!==C?(D=dg(o,k),L=(fe=D.find(ce=>ce.value===C))==null?void 0:fe.label,e[4]=o,e[5]=k,e[6]=C,e[7]=D,e[8]=L):(D=e[7],L=e[8]);const F=L;let z;e[9]!==c||e[10]!==l||e[11]!==a?(z=a?Ad(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]!==O?(W=(le=m.find(ce=>ce.value===O))==null?void 0:le.label,e[13]=m,e[14]=O,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]!==$||e[21]!==N?(K=ce=>{N&&$(()=>N(ce))},e[20]=$,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(y4,{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(gd,{})}),e[23]=Y):Y=e[23];let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(C4,{children:"Session controls"}),e[24]=V):V=e[24];let J;e[25]!==H?(J=r.jsx(_4,{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(w4,{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(st,{})}),e[27]=Q):Q=e[27];let X;e[28]!==J?(X=r.jsxs(k4,{className:"gap-1 px-4 pb-3 pt-4",children:[V,J,Q]}),e[28]=J,e[29]=X):X=e[29];let Z;e[30]!==o||e[31]!==$||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]!==u||e[41]!==C||e[42]!==D||e[43]!==f||e[44]!==a||e[45]!==S?(Z=r.jsx(E4,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:u,modelOptions:d,selectedEffort:f,onEffortChange:p,effortOptions:m,ultracodeEnabled:S,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:D,onPermissionModeChange:q,changeAndApply:$}),e[30]=o,e[31]=$,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]=u,e[41]=C,e[42]=D,e[43]=f,e[44]=a,e[45]=S,e[46]=Z):Z=e[46];let te;e[47]!==o||e[48]!==$||e[49]!==b||e[50]!==E||e[51]!==_||e[52]!==R||e[53]!==T||e[54]!==A||e[55]!==j||e[56]!==v||e[57]!==P||e[58]!==S||e[59]!==y?(te=r.jsx(P4,{agentKind:o,isNewSession:b,worktreeEnabled:y,onWorktreeEnabledChange:v,ultracodeEnabled:S,onUltracodeEnabledChange:j,mcpServers:_,selectedMcpServers:P,onToggleMcpServer:A,onRefreshMcpServers:T,mcpLoading:E,onMcpAuth:R,changeAndApply:$}),e[47]=o,e[48]=$,e[49]=b,e[50]=E,e[51]=_,e[52]=R,e[53]=T,e[54]=A,e[55]=j,e[56]=v,e[57]=P,e[58]=S,e[59]=y,e[60]=te):te=e[60];let ne;e[61]!==I?(ne=I&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(kt,{className:"mb-3"}),r.jsx("h3",{id:"mobile-goal-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Long-running goal"}),r.jsx("div",{className:"[&>*]:mx-0 [&>*]:mb-0 [&_button]:min-h-10",children:I})]}),e[61]=I,e[62]=ne):ne=e[62];let oe;e[63]!==o||e[64]!==b?(oe=!b&&r.jsx("p",{className:"text-xs text-muted-foreground",children:Vt(o).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[63]=o,e[64]=b,e[65]=oe):oe=e[65];let re;e[66]!==Z||e[67]!==te||e[68]!==ne||e[69]!==oe?(re=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[Z,te,ne,oe]}),e[66]=Z,e[67]=te,e[68]=ne,e[69]=oe,e[70]=re):re=e[70];let ae;e[71]!==X||e[72]!==re?(ae=r.jsxs(N4,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[X,re]}),e[71]=X,e[72]=re,e[73]=ae):ae=e[73];let se;return e[74]!==s||e[75]!==t||e[76]!==ae?(se=r.jsx(r.Fragment,{children:r.jsxs(v4,{open:t,onOpenChange:s,children:[Y,ae]})}),e[74]=s,e[75]=t,e[76]=ae,e[77]=se):se=e[77],se}const R4=w.memo(function(e){const t=B.c(58),{agentKind:s,onAgentKindChange:o,selectedModel:i,onModelChange:a,selectedEffort:l,onEffortChange:c,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,onApplySettings:x,activeModelId:b,mcpServers:y,selectedMcpServers:v,onToggleMcpServer:S,onRefreshMcpServers:j,mcpLoading:k,onMcpAuth:C,permissionMode:N,onPermissionModeChange:_,mobileExtra:P,trailingExtra:A,mobile:T}=e,E=s===void 0?Xs:s,R=T===void 0?!1:T,[I,$]=w.useState(!1);let M;t[0]!==f||t[1]!==x?(M=se=>{se(),!f&&x&&setTimeout(()=>x(),0)},t[0]=f,t[1]=x,t[2]=M):M=t[2];const O=M;let D;t[3]!==O||t[4]!==a?(D=se=>O(()=>a(se)),t[3]=O,t[4]=a,t[5]=D):D=t[5];const L=D;let F;t[6]!==O||t[7]!==c?(F=se=>O(()=>c(se)),t[6]=O,t[7]=c,t[8]=F):F=t[8];const z=F,W=og(E),U=(b==null?void 0:b.toLowerCase().startsWith("gpt-"))??!1,K=b&&(E==="copilot"||U===(E==="codex"))?b:void 0;let q,Y;t[9]!==W||t[10]!==K?(q=K?Ad(K,W):e4(W),Y=W.map(se=>{const fe=[se.description,se.availabilityMessage].filter(Boolean).join(" · ")||void 0;return se.value===""?{...se,description:fe,label:q,menuLabel:se.label}:{...se,description:fe}}),t[9]=W,t[10]=K,t[11]=q,t[12]=Y):(q=t[11],Y=t[12]);const V=Y;let J;t[13]!==E||t[14]!==i?(J=V1(E,i),t[13]=E,t[14]=i,t[15]=J):J=t[15];const Q=J;let X;t[16]!==E||t[17]!==i?(X=G1(E,i),t[16]=E,t[17]=i,t[18]=X):X=t[18];const Z=X;let te;t[19]!==E||t[20]!==i?(te=qw(E,i),t[19]=E,t[20]=i,t[21]=te):te=t[21];const ne=te;let oe;t[22]!==E||t[23]!==ne||t[24]!==O||t[25]!==Q||t[26]!==d||t[27]!==Z||t[28]!==z||t[29]!==L||t[30]!==f||t[31]!==k||t[32]!==y||t[33]!==V||t[34]!==o||t[35]!==u||t[36]!==C||t[37]!==_||t[38]!==j||t[39]!==S||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?(oe={agentKind:E,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:q,modelOptions:V,onModelChange:L,selectedEffort:l,effortOptions:Q,onEffortChange:z,fastTier:Z,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:ne,permissionMode:N,onPermissionModeChange:_,mcpServers:y,selectedMcpServers:v,onToggleMcpServer:S,onRefreshMcpServers:j,mcpLoading:k,onMcpAuth:C,changeAndApply:O},t[22]=E,t[23]=ne,t[24]=O,t[25]=Q,t[26]=d,t[27]=Z,t[28]=z,t[29]=L,t[30]=f,t[31]=k,t[32]=y,t[33]=V,t[34]=o,t[35]=u,t[36]=C,t[37]=_,t[38]=j,t[39]=S,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]=oe):oe=t[49];const re=oe;if(R){let se;return t[50]!==W||t[51]!==re||t[52]!==P||t[53]!==I?(se=r.jsx(A4,{...re,open:I,onOpenChange:$,catalogOptions:W,mobileExtra:P}),t[50]=W,t[51]=re,t[52]=P,t[53]=I,t[54]=se):se=t[54],se}let ae;return t[55]!==re||t[56]!==A?(ae=r.jsx(c4,{...re,trailingExtra:A}),t[55]=re,t[56]=A,t[57]=ae):ae=t[57],ae});function ug(n){return n.agentType==="team-lead"}function $4(n){return ug(n)?void 0:n.color}const I4={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function M4(n){return n?I4[n]??"bg-zinc-400":"bg-zinc-400"}const O4=w.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(os,{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 u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(kt,{orientation:"vertical",className:"h-3.5"}),t[3]=u):u=t[3];let f;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,y=M4($4(g));return r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:G("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[b?r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx("span",{className:G("inline-flex size-1.5 shrink-0 rounded-full",y)}),r.jsx("span",{children:g.name}),ug(g)&&r.jsx(My,{"data-icon":"inline-end",className:"text-warning"})]},g.agentId)},t[9]=i,t[10]=a,t[11]=l,t[12]=h):h=t[12],f=o.map(h),t[4]=i,t[5]=a,t[6]=o,t[7]=l,t[8]=f}else f=t[8];let m;t[13]!==f?(m=r.jsx("div",{className:"flex items-center gap-1",children:f}),t[13]=f,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,u,m]}),t[15]=d,t[16]=m,t[17]=p):p=t[17],p});function fg(n){const e=B.c(3),t=w.useRef(null),[s,o]=w.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]),w.useEffect(i,a),s}const mg=w.createContext(null),pg=w.createContext(null);function zi(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(pg.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(mg.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function ct(){const n=w.useContext(mg);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function Fr(){const n=w.useContext(pg);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const D4=ss("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 Ce(n){const e=B.c(13);let t,s,o,i,a;if(e[0]!==n){const{className:d,variant:u,render:f,...m}=n;t=f,a=u===void 0?"default":u,i=v1,s="span",o=b1({className:G(D4({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 xm=1,L4=.9,z4=.8,F4=.17,kl=.1,Cl=.999,B4=.9999,U4=.99,W4=/[\\\/_+.#"@\[\(\{&]/,H4=/[\\\/_+.#"@\[\(\{&]/g,K4=/[\s-]/,hg=/[\s-]/g;function Ac(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?xm:U4;var l=`${o},${i}`;if(a[l]!==void 0)return a[l];for(var c=s.charAt(i),d=t.indexOf(c,o),u=0,f,m,p,h;d>=0;)f=Ac(n,e,t,s,d+1,i+1,a),f>u&&(d===o?f*=xm:W4.test(n.charAt(d-1))?(f*=z4,p=n.slice(o,d-1).match(H4),p&&o>0&&(f*=Math.pow(Cl,p.length))):K4.test(n.charAt(d-1))?(f*=L4,h=n.slice(o,d-1).match(hg),h&&o>0&&(f*=Math.pow(Cl,h.length))):(f*=F4,o>0&&(f*=Math.pow(Cl,d-o))),n.charAt(d)!==e.charAt(i)&&(f*=B4)),(f<kl&&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*kl>f&&(f=m*kl)),f>u&&(u=f),d=t.indexOf(c,d+1);return a[l]=u,u}function bm(n){return n.toLowerCase().replace(hg," ")}function q4(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,Ac(n,e,bm(n),bm(e),0,0,{})}var Bo='[cmdk-group=""]',_l='[cmdk-group-items=""]',V4='[cmdk-group-heading=""]',gg='[cmdk-item=""]',vm=`${gg}:not([aria-disabled="true"])`,Rc="cmdk-item-select",fo="data-value",G4=(n,e,t)=>q4(n,e,t),xg=w.createContext(void 0),Br=()=>w.useContext(xg),bg=w.createContext(void 0),Rd=()=>w.useContext(bg),vg=w.createContext(void 0),yg=w.forwardRef((n,e)=>{let t=mo(()=>{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=mo(()=>new Set),o=mo(()=>new Map),i=mo(()=>new Map),a=mo(()=>new Set),l=wg(n),{label:c,children:d,value:u,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,y=xo(),v=xo(),S=xo(),j=w.useRef(null),k=r5();Ws(()=>{if(u!==void 0){let z=u.trim();t.current.value=z,C.emit()}},[u]),Ws(()=>{k(6,E)},[]);let C=w.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")T(),P(),k(1,A);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let V=document.getElementById(S);V?V.focus():(H=document.getElementById(y))==null||H.focus()}if(k(7,()=>{var V;t.current.selectedItemId=(V=R())==null?void 0:V.id,C.emit()}),U||k(5,E),((K=l.current)==null?void 0:K.value)!==void 0){let V=W??"";(Y=(q=l.current).onValueChange)==null||Y.call(q,V);return}}C.emit()}},emit:()=>{a.current.forEach(z=>z())}}),[]),N=w.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,()=>{P(),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,()=>{T(),P(),t.current.value||A(),C.emit()}),()=>{i.current.delete(z),s.current.delete(z),t.current.filtered.items.delete(z);let U=R();k(4,()=>{T(),(U==null?void 0:U.getAttribute("id"))===z&&A(),C.emit()})}),group:z=>(o.current.has(z)||o.current.set(z,new Set),()=>{i.current.delete(z),o.current.delete(z)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:y,inputId:S,labelId:v,listInnerRef:j}),[]);function _(z,W){var U,H;let K=(H=(U=l.current)==null?void 0:U.filter)!=null?H:G4;return z?K(z,t.current.search,W):0}function P(){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 V=z.get(Y);q=Math.max(V,q)}),W.push([H,q])});let U=j.current;I().sort((H,K)=>{var q,Y;let V=H.getAttribute("id"),J=K.getAttribute("id");return((q=z.get(J))!=null?q:0)-((Y=z.get(V))!=null?Y:0)}).forEach(H=>{let K=H.closest(_l);K?K.appendChild(H.parentElement===K?H:H.closest(`${_l} > *`)):U.appendChild(H.parentElement===U?H:H.closest(`${_l} > *`))}),W.sort((H,K)=>K[1]-H[1]).forEach(H=>{var K;let q=(K=j.current)==null?void 0:K.querySelector(`${Bo}[${fo}="${encodeURIComponent(H[0])}"]`);q==null||q.parentElement.appendChild(q)})}function A(){let z=I().find(U=>U.getAttribute("aria-disabled")!=="true"),W=z==null?void 0:z.getAttribute(fo);C.setState("value",W||void 0)}function T(){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:"",V=(H=(U=i.current.get(q))==null?void 0:U.keywords)!=null?H:[],J=_(Y,V);t.current.filtered.items.set(q,J),J>0&&K++}for(let[q,Y]of o.current)for(let V of Y)if(t.current.filtered.items.get(V)>0){t.current.filtered.groups.add(q);break}t.current.filtered.count=K}function E(){var z,W,U;let H=R();H&&(((z=H.parentElement)==null?void 0:z.firstChild)===H&&((U=(W=H.closest(Bo))==null?void 0:W.querySelector(V4))==null||U.scrollIntoView({block:"nearest"})),H.scrollIntoView({block:"nearest"}))}function R(){var z;return(z=j.current)==null?void 0:z.querySelector(`${gg}[aria-selected="true"]`)}function I(){var z;return Array.from(((z=j.current)==null?void 0:z.querySelectorAll(vm))||[])}function $(z){let W=I()[z];W&&C.setState("value",W.getAttribute(fo))}function M(z){var W;let U=R(),H=I(),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(fo))}function O(z){let W=R(),U=W==null?void 0:W.closest(Bo),H;for(;U&&!H;)U=z>0?s5(U,Bo):o5(U,Bo),H=U==null?void 0:U.querySelector(vm);H?C.setState("value",H.getAttribute(fo)):M(z)}let D=()=>$(I().length-1),L=z=>{z.preventDefault(),z.metaKey?D():z.altKey?O(1):M(1)},F=z=>{z.preventDefault(),z.metaKey?$(0):z.altKey?O(-1):M(-1)};return w.createElement(Ts.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(),$(0);break}case"End":{z.preventDefault(),D();break}case"Enter":{z.preventDefault();let H=R();if(H){let K=new Event(Rc);H.dispatchEvent(K)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:a5},c),$a(n,z=>w.createElement(bg.Provider,{value:C},w.createElement(xg.Provider,{value:N},z))))}),Y4=w.forwardRef((n,e)=>{var t,s;let o=xo(),i=w.useRef(null),a=w.useContext(vg),l=Br(),c=wg(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;Ws(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let u=jg(o,i,[n.value,n.children,i],n.keywords),f=Rd(),m=ks(k=>k.value&&k.value===u.current),p=ks(k=>d||l.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);w.useEffect(()=>{let k=i.current;if(!(!k||n.disabled))return k.addEventListener(Rc,h),()=>k.removeEventListener(Rc,h)},[p,n.onSelect,n.disabled]);function h(){var k,C;g(),(C=(k=c.current).onSelect)==null||C.call(k,u.current)}function g(){f.setState("value",u.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:y,forceMount:v,keywords:S,...j}=n;return w.createElement(Ts.div,{ref:ur(i,e),...j,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)}),X4=w.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=xo(),l=w.useRef(null),c=w.useRef(null),d=xo(),u=Br(),f=ks(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);Ws(()=>u.group(a),[]),jg(a,l,[n.value,n.heading,c]);let m=w.useMemo(()=>({id:a,forceMount:o}),[o]);return w.createElement(Ts.div,{ref:ur(l,e),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},t&&w.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),$a(n,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},w.createElement(vg.Provider,{value:m},p))))}),J4=w.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=w.useRef(null),i=ks(a=>!a.search);return!t&&!i?null:w.createElement(Ts.div,{ref:ur(o,e),...s,"cmdk-separator":"",role:"separator"})}),Q4=w.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Rd(),a=ks(d=>d.search),l=ks(d=>d.selectedItemId),c=Br();return w.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),w.createElement(Ts.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)}})}),Z4=w.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=w.useRef(null),a=w.useRef(null),l=ks(d=>d.selectedItemId),c=Br();return w.useEffect(()=>{if(a.current&&i.current){let d=a.current,u=i.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=d.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(d),()=>{cancelAnimationFrame(f),m.unobserve(d)}}},[]),w.createElement(Ts.div,{ref:ur(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},$a(n,d=>w.createElement("div",{ref:ur(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),e5=w.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return w.createElement(Oy,{open:t,onOpenChange:s},w.createElement(Dy,{container:a},w.createElement(Ly,{"cmdk-overlay":"",className:o}),w.createElement(zy,{"aria-label":n.label,"cmdk-dialog":"",className:i},w.createElement(yg,{ref:e,...l}))))}),t5=w.forwardRef((n,e)=>ks(t=>t.filtered.count===0)?w.createElement(Ts.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),n5=w.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return w.createElement(Ts.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},$a(n,a=>w.createElement("div",{"aria-hidden":!0},a)))}),Mo=Object.assign(yg,{List:Z4,Item:Y4,Input:Q4,Group:X4,Separator:J4,Dialog:e5,Empty:t5,Loading:n5});function s5(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function o5(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function wg(n){let e=w.useRef(n);return Ws(()=>{e.current=n}),e}var Ws=typeof window>"u"?w.useEffect:w.useLayoutEffect;function mo(n){let e=w.useRef();return e.current===void 0&&(e.current=n()),e}function ks(n){let e=Rd(),t=()=>n(e.snapshot());return w.useSyncExternalStore(e.subscribe,t,t)}function jg(n,e,t,s=[]){let o=w.useRef(),i=Br();return Ws(()=>{var a;let l=(()=>{var d;for(let u of t){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(d=u.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(fo,l),o.current=l}),o}var r5=()=>{let[n,e]=w.useState(),t=mo(()=>new Map);return Ws(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function i5(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function $a({asChild:n,children:e},t){return n&&w.isValidElement(e)?w.cloneElement(i5(e),{ref:e.ref},t(e.props.children)):t(e)}var a5={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function rs(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(x1,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function l5(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(pd,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function c5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(hd,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function is(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(c5,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=G("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let d;e[8]!==a?(d=a&&r.jsxs(xa,{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(st,{"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 u;return e[10]!==t||e[11]!==o||e[12]!==c||e[13]!==d?(u=r.jsxs(l5,{children:[l,r.jsxs(md,{"data-slot":"dialog-content",className:c,...o,children:[t,d]})]}),e[10]=t,e[11]=o,e[12]=c,e[13]=d,e[14]=u):u=e[14],u}function Ps(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Sg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function as(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ud,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ls(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(fd,{"data-slot":"dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Ng(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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(Mo,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function lF(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,u=l===void 0?!1:l;let f;e[7]!==s?(f=G("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",s),e[7]=s,e[8]=f):f=e[8];let m;e[9]!==c?(m=r.jsx(as,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(ls,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(Ps,{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]!==u||e[18]!==f||e[19]!==h?(g=r.jsxs(is,{className:f,showCloseButton:u,children:[h,t]}),e[16]=t,e[17]=u,e[18]=f,e[19]=h,e[20]=g):g=e[20];let x;return e[21]!==o||e[22]!==g?(x=r.jsx(rs,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function cF(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(cn,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=o):o=e[3];let i;e[4]!==t?(i=G("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==i?(a=r.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[o,r.jsx(Mo.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function kg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none transition-[height] duration-100 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Mo.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function dF(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("py-6 text-center text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-100 motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Mo.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Cg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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(Mo.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function _g(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none transition-colors duration-75 in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(gt,{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(Mo.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 d5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("span",{"data-slot":"command-shortcut",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function u5(n){return r.jsx(Ce,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const f5=w.memo(function(e){const t=B.c(38),{suggestions:s,filter:o,loading:i,selectedIndex:a,onSelect:l,onHover:c,onEdit:d}=e;let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,t[0]=u):u=t[0];const f=w.useRef(u);let m,p;if(t[1]!==a?(m=()=>{var A;const P=f.current.get(a);P&&((A=P.scrollIntoView)==null||A.call(P,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),w.useEffect(m,p),i){let P;return t[4]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[r.jsx(lt,{className:"size-3.5 animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=P):P=t[4],P}if(s.length===0){const P=o?`No commands or skills matching "${o}"`:"No commands or skills found";let A;return t[5]!==P?(A=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:P})})}),t[5]=P,t[6]=A):A=t[6],A}let h,g,x,b,y,v,S,j,k;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const P=s.filter(p5),A=[{heading:"Commands",suggestions:P,offset:0},{heading:"Skills",suggestions:s.filter(h5),offset:P.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=Ng,y="slash-suggestions",v=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(S=T=>{const E=s.findIndex(R=>`${R.type}-${R.name}`===T);E>=0&&c(E)},t[21]=c,t[22]=s,t[23]=S):S=t[23],j=!1,k="border shadow-sm",h=kg,b=A.map(T=>T.suggestions.length>0&&r.jsx(Cg,{heading:T.heading,children:T.suggestions.map((E,R)=>{const I=T.offset+R;return r.jsx(m5,{suggestion:E,index:I,isSelected:I===a,onSelect:l,onHover:c,onEdit:d,itemRefs:f},`${E.type}-${E.name}`)})},T.heading)),t[7]=d,t[8]=c,t[9]=l,t[10]=a,t[11]=s,t[12]=h,t[13]=g,t[14]=x,t[15]=b,t[16]=y,t[17]=v,t[18]=S,t[19]=j,t[20]=k}else h=t[12],g=t[13],x=t[14],b=t[15],y=t[16],v=t[17],S=t[18],j=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]!==y||t[30]!==v||t[31]!==S||t[32]!==j||t[33]!==k?(N=r.jsx(g,{id:y,value:v,onValueChange:S,shouldFilter:j,className:k,children:C}),t[27]=g,t[28]=C,t[29]=y,t[30]=v,t[31]=S,t[32]=j,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 m5({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=w.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(_g,{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(jo,{className:"size-4 text-muted-foreground"}):r.jsx(y1,{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]}),u5(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(d5,{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(Vs,{"data-icon":"inline-start"})})]})}function p5(n){return n.type==="command"}function h5(n){return n.type==="skill"}function g5(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=w.useRef(c);let u,f;e[1]!==i?(u=()=>{var v,S;(S=(v=d.current.get(i))==null?void 0:v.scrollIntoView)==null||S.call(v,{block:"nearest"})},f=[i],e[1]=i,e[2]=u,e[3]=f):(u=e[2],f=e[3]),w.useEffect(u,f);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=v=>{const S=t.indexOf(v);S>=0&&l(S)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==o?(h=o&&r.jsx(lt,{"data-icon":"inline-end","aria-label":"Loading project files",className:"size-3.5 animate-spin"}),e[7]=o,e[8]=h):h=e[8];let g;e[9]!==h?(g=r.jsxs("span",{className:"flex items-center justify-between",children:["Project files",h]}),e[9]=h,e[10]=g):g=e[10];let 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,S)=>r.jsxs(_g,{ref:j=>{j?(j.id=`file-suggestion-${S}`,d.current.set(S,j)):d.current.delete(S)},value:v,onMouseEnter:()=>l(S),onSelect:()=>a(v),onMouseDown:x5,children:[r.jsx(w1,{"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}),S===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(kg,{className:"max-h-70",children:r.jsx(Cg,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=b):b=e[20];let y;return e[21]!==m||e[22]!==p||e[23]!==b?(y=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(Ng,{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]=y):y=e[24],y}function x5(n){return n.preventDefault()}const b5=ss("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 pt(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,variant:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t||e[5]!==o?(i=G(b5({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 Et(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ht(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Cs(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("absolute top-2 right-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function it(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":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function $t(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(Uy,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function at(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("h-[var(--collapsible-panel-height)] overflow-hidden opacity-100 transition-[height,opacity] duration-150 ease-out [&[hidden]:not([hidden='until-found'])]:hidden motion-safe:data-starting-style:h-0 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:h-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Fy,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const v5={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function ym(n){return v5[n]??n.replaceAll("_"," ")}function y5(n){const e=B.c(46),{allowedPrompts:t,summary:s,planContent:o,actions:i,recommendedAction:a,responding:l,responseError:c,onApprove:d,onReject:u}=n;let f,m,p,h,g,x,b,y,v,S;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const A=i===void 0?[]:i;p=l===void 0?!1:l;const T=a??A[0],E=A.filter($=>$!==T);m=pt,b="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Rr,{}),v=r.jsx(Et,{children:"Plan ready for review"}),e[15]=y,e[16]=v):(y=e[15],v=e[16]);const R=s||"Approve the plan or ask the agent to revise it.";e[17]!==R?(S=r.jsx(ht,{children:R}),e[17]=R,e[18]=S):S=e[18],f=Cs,h="flex gap-2";let I;e[19]!==p?(I=p&&r.jsx(lt,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=I):I=e[20],g=r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>d(T),children:[I,p?"Sending...":T?ym(T):"Approve"]}),x=E.length>0&&r.jsxs(Kn,{children:[r.jsx(qn,{render:r.jsx(ee,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(tt,{"data-icon":"icon"})}),r.jsx(Vn,{align:"end",children:r.jsx(tn,{children:E.map($=>r.jsx(Pt,{onClick:()=>d($),children:ym($)},$))})})]}),e[0]=d,e[1]=a,e[2]=s,e[3]=i,e[4]=l,e[5]=f,e[6]=m,e[7]=p,e[8]=h,e[9]=g,e[10]=x,e[11]=b,e[12]=y,e[13]=v,e[14]=S}else f=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],b=e[11],y=e[12],v=e[13],S=e[14];let j;e[21]!==u||e[22]!==p?(j=r.jsx(ee,{variant:"ghost",size:"sm",disabled:p,onClick:u,children:"Reject"}),e[21]=u,e[22]=p,e[23]=j):j=e[23];let k;e[24]!==f||e[25]!==j||e[26]!==h||e[27]!==g||e[28]!==x?(k=r.jsxs(f,{className:h,children:[g,x,j]}),e[24]=f,e[25]=j,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(it,{className:"col-span-full mt-2",children:[r.jsx($t,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(at,{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(w5)]}),e[34]=t,e[35]=_):_=e[35];let P;return e[36]!==m||e[37]!==k||e[38]!==C||e[39]!==N||e[40]!==_||e[41]!==b||e[42]!==y||e[43]!==v||e[44]!==S?(P=r.jsxs(m,{className:b,children:[y,v,S,k,C,N,_]}),e[36]=m,e[37]=k,e[38]=C,e[39]=N,e[40]=_,e[41]=b,e[42]=y,e[43]=v,e[44]=S,e[45]=P):P=e[45],P}function w5(n,e){return r.jsx(Ce,{variant:"outline",children:n.prompt},e)}const j5=["allow","allow_always","deny"];function wi(n,e){return(n.availableDecisions??j5).includes(e)}function S5(n){switch(n){case"Bash":return{label:"Run command",icon:jo,tone:"cmd"};case"Edit":return{label:"Edit file",icon:bc,tone:"write"};case"Write":return{label:"Write file",icon:bc,tone:"write"};case"Read":return{label:"Read file",icon:ys,tone:"read"};case"Glob":return{label:"File search",icon:cn,tone:"search"};case"Grep":return{label:"Content search",icon:cn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:xc,tone:"net"};case"WebSearch":return{label:"Web search",icon:xc,tone:"net"};default:return{label:n,icon:ba,tone:"other"}}}function N5(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 k5({requests:n,responding:e,onRespond:t,onRespondAll:s}){var y;const o=n[0],i=n.length,a=o?wi(o,"allow"):!1,l=o?wi(o,"allow_always"):!1,c=o?wi(o,"deny"):!1,d=i>1&&n.every(v=>wi(v,"allow")),u=w.useEffectEvent(v=>{if(!o)return;const S=v.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable)||v.metaKey||v.ctrlKey||v.altKey)return;const j=v.key.toLowerCase();j==="a"&&v.shiftKey&&d?(v.preventDefault(),s("allow")):j==="a"&&a?(v.preventDefault(),t(o.requestId,"allow")):j==="s"&&l?(v.preventDefault(),t(o.requestId,"allow_always")):j==="d"&&c&&(v.preventDefault(),t(o.requestId,"deny"))});w.useEffect(()=>{const v=S=>u(S);return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]);const f=o?S5(o.toolName):null,m=o?N5(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=(((y=o==null?void 0:o.suggestions)==null?void 0:y.length)??0)>0;if(!o||!f)return null;const g=f.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(g1,{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:f.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(Ce,{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(st,{"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(Wy,{"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(gt,{"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 C5=1568,_5=.85,wm=35e5;function T5(n,e){let{width:t,height:s}=n;const o=Math.min(1,C5/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?_5:void 0),u=d.split(",")[1];if(u.length>wm){let f=l?.7:.8;for(;u.length>wm&&f>.3;)d=i.toDataURL("image/jpeg",f),u=d.split(",")[1],f-=.1;return{dataUrl:d,base64:u,mediaType:"image/jpeg"}}return{dataUrl:d,base64:u,mediaType:c}}function E5(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]=w.useState(s),[a,l]=w.useState(!1),[c,d]=w.useState(!1),u=w.useRef(t);let f,m;e[1]!==t?(f=()=>{u.current=t},m=[t],e[1]=t,e[2]=f,e[3]=m):(f=e[2],m=e[3]),w.useEffect(f,m);let p;e[4]!==t?(p=$=>{const M=Array.from($).filter(R5);if(!t){M.length>0&&d(!0);return}d(!1);for(const O of M){const D=new FileReader;D.onload=()=>{if(!u.current){d(!0);return}const L=D.result,F=new Image;F.onload=()=>{if(!u.current){d(!0);return}const z=T5(F,O.type);i(W=>[...W,{id:crypto.randomUUID(),file:O,preview:z.dataUrl,data:z.base64,mediaType:z.mediaType}])},F.src=L},D.onerror=()=>{console.warn(`Failed to read image file: ${O.name}`)},D.readAsDataURL(O)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=$=>{i(M=>M.filter((O,D)=>D!==$)),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 y=b;let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>d(!1),e[8]=v):v=e[8];const S=v;let j;e[9]!==t?(j=$=>{$.preventDefault(),t&&l(!0)},e[9]=t,e[10]=j):j=e[10];const k=j;let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=$=>{$.preventDefault(),$.currentTarget.contains($.relatedTarget)||l(!1)},e[11]=C):C=e[11];const N=C;let _;e[12]!==h?(_=$=>{$.preventDefault(),l(!1),$.dataTransfer.files.length>0&&h($.dataTransfer.files)},e[12]=h,e[13]=_):_=e[13];const P=_;let A;e[14]!==h?(A=$=>{var L;const M=(L=$.clipboardData)==null?void 0:L.items;if(!M)return;const O=Array.from(M).filter(A5);if(O.length===0)return;$.preventDefault();const D=O.map(P5).filter(Boolean);h(D)},e[14]=h,e[15]=A):A=e[15];const T=A,E=!t&&o.length>0?"The selected model does not accept images. Switch models or remove the attachments.":!t&&c?"The selected model does not accept the image you tried to add.":null,R=!t&&o.length>0;let I;return e[16]!==k||e[17]!==P||e[18]!==T||e[19]!==o||e[20]!==a||e[21]!==E||e[22]!==R?(I={images:o,isDragOver:a,imageError:E,hasUnsupportedAttachments:R,dismissImageError:S,removeImage:x,clearImages:y,handleDragOver:k,handleDragLeave:N,handleDrop:P,handlePaste:T},e[16]=k,e[17]=P,e[18]=T,e[19]=o,e[20]=a,e[21]=E,e[22]=R,e[23]=I):I=e[23],I}function P5(n){return n.getAsFile()}function A5(n){return n.type.startsWith("image/")}function R5(n){return n.type.startsWith("image/")}function $5(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(Vy,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function Mt(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($5,{children:r.jsx(qy,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Ot(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(Hy,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Dt(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,u=a===void 0?4:a,f=l===void 0?"center":l,m=c===void 0?0:c;let p;e[8]!==s?(p=G("z-50 w-fit origin-(--transform-origin) overflow-hidden rounded-md bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 text-balance duration-100 ease-out data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[8]=s,e[9]=p):p=e[9];let h;e[10]!==t||e[11]!==o||e[12]!==p?(h=r.jsx(Ky,{"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]!==f||e[15]!==m||e[16]!==d||e[17]!==u||e[18]!==h?(g=r.jsx(Gy,{children:r.jsx(Yy,{align:f,alignOffset:m,side:d,sideOffset:u,className:"isolate z-50",children:h})}),e[14]=f,e[15]=m,e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19],g}const On="rounded-full border bg-background/80 shadow-sm backdrop-blur",Ia=w.memo(function(e){const t=B.c(8);let s,o;t[0]!==e?({className:s,...o}=e,t[0]=e,t[1]=s,t[2]=o):(s=t[1],o=t[2]);let i;t[3]!==s?(i=G("inline-block size-2 shrink-0 rounded-full bg-success",s),t[3]=s,t[4]=i):i=t[4];let a;return t[5]!==o||t[6]!==i?(a=r.jsx("span",{className:i,...o}),t[5]=o,t[6]=i,t[7]=a):a=t[7],a}),Tl=w.memo(function(e){const t=B.c(17),{icon:s,label:o,onClick:i,disabled:a,className:l,iconClassName:c,size:d}=e,f=(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]!==f?(m=r.jsx(ee,{variant:"ghost",size:f,className:l,onClick:i,disabled:a,"aria-label":o}),t[0]=l,t[1]=a,t[2]=o,t[3]=i,t[4]=f,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(Ot,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(Dt,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(Mt,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function I5(n){return n<10?"critical":n<30?"warning":"healthy"}const M5={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Tg=w.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 u,f,m,p,h,g,x,b,y,v,S,j,k;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const P=ig(s);if(!P){x=null;break e}const A=Math.max(0,100-P.percent),T=I5(A);if(d&&T==="healthy"){x=null;break e}const E=Math.max(0,P.compactAt-P.used);let R;t[17]!==A||t[18]!==E||t[19]!==l?(R=l?`${A.toFixed(0)}% · ${mt(E)}`:`${A.toFixed(0)}%`,t[17]=A,t[18]=E,t[19]=l,t[20]=R):R=t[20];const I=R,$=M5[T],M=l&&"gap-1";let O;t[21]!==$||t[22]!==M?(O=G("shrink-0 tabular-nums",$,M),t[21]=$,t[22]=M,t[23]=O):O=t[23];let D;t[24]!==I||t[25]!==O?(D=r.jsx(Ce,{variant:"outline",className:O,children:I}),t[24]=I,t[25]=O,t[26]=D):D=t[26];const L=D;if(!c){x=L;break e}f=Mt,t[27]!==L?(g=r.jsx(Ot,{render:L}),t[27]=L,t[28]=g):g=t[28],u=Dt,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let F;t[30]!==E?(F=mt(E),t[30]=E,t[31]=F):F=t[31];let z;t[32]!==A?(z=A.toFixed(1),t[32]=A,t[33]=z):z=t[33],t[34]!==F||t[35]!==z?(h=r.jsxs("div",{children:[F," remaining (",z,"%)"]}),t[34]=F,t[35]=z,t[36]=h):h=t[36],b="text-muted-foreground",y=mt(P.used),v=" / ",S=mt(P.limit),j=" tokens used (",k=P.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=d,t[4]=u,t[5]=f,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=x,t[11]=b,t[12]=y,t[13]=v,t[14]=S,t[15]=j,t[16]=k}else u=t[4],f=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],b=t[11],y=t[12],v=t[13],S=t[14],j=t[15],k=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==b||t[38]!==y||t[39]!==v||t[40]!==S||t[41]!==j||t[42]!==k?(C=r.jsxs("div",{className:b,children:[y,v,S,j,k,"%)"]}),t[37]=b,t[38]=y,t[39]=v,t[40]=S,t[41]=j,t[42]=k,t[43]=C):C=t[43];let N;t[44]!==u||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==C?(N=r.jsxs(u,{className:m,children:[p,h,C]}),t[44]=u,t[45]=m,t[46]=p,t[47]=h,t[48]=C,t[49]=N):N=t[49];let _;return t[50]!==f||t[51]!==g||t[52]!==N?(_=r.jsxs(f,{children:[g,N]}),t[50]=f,t[51]=g,t[52]=N,t[53]=_):_=t[53],_});function O5(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=ct(),{chat:a}=Fr(),{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:Fj(o)}),r.jsx(Ia,{})]}),e[0]=o,e[1]=t,e[2]=s,e[3]=c,e[4]=d):d=e[4];let u;return e[5]!==d?(u=r.jsx(r.Fragment,{children:d}),e[5]=d,e[6]=u):u=e[6],u}function D5(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}=ct(),{handleStopSession:d}=c,{chat:u}=Fr(),{isConnected:f,interrupt:m}=u,p=f||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)??Rt((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=Xj(g),e[3]=g,e[4]=x):x=e[4];const b=x;let y;e[5]!==b||e[6]!==m||e[7]!==p?(y=p&&r.jsxs(Mt,{children:[r.jsx(Ot,{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(xd,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(Dt,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=y):y=e[8];let v;e[9]!==g||e[10]!==d||e[11]!==p?(v=p&&Vt(g).stopSession&&r.jsxs(Mt,{children:[r.jsx(Ot,{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(Xy,{"data-icon":"inline-start"})}),r.jsx(Dt,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=v):v=e[12];const S=t?"default":"secondary",j=!t&&"text-muted-foreground";let k;e[13]!==j?(k=G("shrink-0 rounded-full",j),e[13]=j,e[14]=k):k=e[14];const C=!t;let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Jy,{"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]!==S?(_=r.jsx(ee,{variant:S,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]=S,e[21]=_):_=e[21];let P;return e[22]!==_||e[23]!==y||e[24]!==v?(P=r.jsxs("div",{className:"flex items-center gap-1",children:[y,v,_]}),e[22]=_,e[23]=y,e[24]=v,e[25]=P):P=e[25],P}function jm(n){const e=B.c(34),{error:t}=n,[s,o]=w.useState(!1),[i,a]=w.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 u=d;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;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(qt,{"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]!==u?(x=u&&r.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=u,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 y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(Ps,{children:[r.jsxs(as,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(qt,{className:"size-4"}),"Error details"]}),r.jsx(ls,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=y):y=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 S;e[19]!==i?(S=i?r.jsx(gt,{"data-icon":"inline-start"}):r.jsx(Rn,{"data-icon":"inline-start"}),e[19]=i,e[20]=S):S=e[20];const j=i?"Copied":"Copy";let k;e[21]!==m||e[22]!==S||e[23]!==j?(k=r.jsx("div",{className:"flex justify-end",children:r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:m,children:[S,j]})}),e[21]=m,e[22]=S,e[23]=j,e[24]=k):k=e[24];let C;e[25]!==v||e[26]!==k?(C=r.jsxs(is,{className:"max-w-2xl",children:[y,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(rs,{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 L5(n){const e=B.c(17),{suggestion:t,onAccept:s}=n,[o,i]=w.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(y1,{"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 u;e[9]!==t?(u=()=>i(t),e[9]=t,e[10]=u):u=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(st,{}),e[11]=f):f=e[11];let m;e[12]!==u?(m=r.jsx(ee,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:u,className:"shrink-0 text-muted-foreground",children:f}),e[12]=u,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 z5(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 F5(n,e,t){return`${n.slice(0,e.start)}@${t} `}const Ma={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Ur={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let Eg=Ma;const $c=new Set;function go(n){Eg=(n==null?void 0:n.capabilities)??Ma;for(const e of $c)e()}function ft(n){return Eg[n]}function B5(n){return $c.add(n),()=>$c.delete(n)}function Pn(n){const e=B.c(3);let t,s;return e[0]!==n?(t=()=>ft(n),s=()=>ft(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),w.useSyncExternalStore(B5,t,s)}function U5(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function W5(n,e,t){const s=Pn("hostFiles"),[o,i]=w.useState([]),[a,l]=w.useState(!1);return w.useEffect(()=>{if(!s||!t||!n){i([]),l(!1);return}const c=new AbortController,d=window.setTimeout(async()=>{l(!0);try{const u=await ve(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!u.ok)throw new Error(`Request failed (${u.status})`);const f=await u.json();c.signal.aborted||i(U5(f))}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 Ic="cogpit-share-revoked";function H5(){window.dispatchEvent(new Event(Ic))}async function Pg(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&&H5(),s}function Wr(n,e){return Pg(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function K5(){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 q5(n,e){return Wr("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function V5(){return Wr("/api/share/interrupt")}function G5(){return Wr("/api/share/stop")}async function Y5(n,e){return(await Wr("/api/share/permission",{requestId:n,behavior:e})).ok}async function X5(n,e){try{const t=await Wr("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function J5(){try{const n=await Pg("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const Q5=/^\/shared\/([^/]+)\/?$/;function Ag(n){const e=Q5.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function Oa(n){return Ag(n)!==null}function Z5(n){return`/shared/${encodeURIComponent(n)}`}function uF(n){return[...n].join(", ")}async function $d(n,e,t){if(Oa(window.location.pathname))return X5(e,t);try{const s=await ve("/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 eS(n,e,t){try{return(await ve(`/api/permissions/${encodeURIComponent(n)}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,...t})})).ok}catch{return!1}}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=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("textarea",{"data-slot":"textarea",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ji(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 tS(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 nS(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 Mc=w.memo(w.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,compact:i=!1},a){var Be;const l=Pn("hostFiles"),{session:c,isLive:d,actions:{handleEditConfig:u},pendingInteraction:f,permissionRequests:m,permissionResponding:p,respondPermission:h,respondAllPermissions:g,slashSuggestions:x,slashSuggestionsLoading:b,turnError:y,promptSuggestion:v}=ct(),{chat:{status:S,error:j,isConnected:k,sendMessage:C,interrupt:N}}=Fr(),_=k||d,[P,A]=w.useState(""),[T,E]=w.useState(!1),[R,I]=w.useState(!1),[$,M]=w.useState(null),O=w.useRef(null),D=w.useRef(null),L=w.useRef(!1),F=w.useRef(""),z=w.useRef(null);w.useEffect(()=>{F.current=P},[P]);const W=w.useCallback(ie=>{L.current=ie,E(ie)},[]),{images:U,isDragOver:H,imageError:K,hasUnsupportedAttachments:q,dismissImageError:Y,removeImage:V,clearImages:J,handleDragOver:Q,handleDragLeave:X,handleDrop:Z,handlePaste:te}=E5(e),[ne,oe]=w.useState(0),[re,ae]=w.useState(0),[se,fe]=w.useState(!1),le=P.startsWith("/")&&!P.includes(" "),ce=le?P.slice(1):"",me=w.useMemo(()=>{if(!le)return[];const ie=ce.toLowerCase(),xe=x.filter(He=>ie?He.name.toLowerCase().includes(ie)||He.description.toLowerCase().includes(ie):!0),Ee=xe.filter(He=>He.type==="command"),Ie=xe.filter(He=>He.type==="skill");return[...Ee,...Ie]},[le,ce,x]),ue=w.useMemo(()=>z5(P),[P]),de=!!(l&&ue&&s&&!se),be=W5(s,(ue==null?void 0:ue.query)??"",de);w.useEffect(()=>{oe(0)},[ce]),w.useEffect(()=>{ae(0)},[ue==null?void 0:ue.query]);const ge=fg(k),he=(f==null?void 0:f.type)==="plan"?f.requestId??null:null;w.useEffect(()=>{D.current=he,O.current=null,I(!1),M(null)},[he]);const je=w.useCallback(async ie=>{const xe=f;if(!(c!=null&&c.sessionId)||(xe==null?void 0:xe.type)!=="question")return;const Ee=xe.questions[0];if(!Ee||!ie.trim())return;(await $d(c.sessionId,xe.toolUseId,{[Ee.question]:ie})).ok||C(ie)},[f,c==null?void 0:c.sessionId,C]),Se=w.useCallback(async(ie,xe,Ee)=>{const Ie=f;if((Ie==null?void 0:Ie.type)==="plan"&&Ie.provider==="copilot"&&Ie.requestId&&(c!=null&&c.sessionId)){const He=Ie.requestId;if(O.current)return!1;O.current=He,I(!0),M(null);try{const Ke=await eS(c.sessionId,He,{approved:ie,...xe?{selectedAction:xe}:{},...Ee?{feedback:Ee}:{}});return!Ke&&D.current===He&&M("Couldn't send the plan response. Try again."),Ke}finally{O.current===He&&(O.current=null,I(!1))}}return C(ie?"yes":Ee||"no"),!0},[f,c==null?void 0:c.sessionId,C]),Pe=w.useCallback(()=>{requestAnimationFrame(()=>{const ie=z.current;ie&&(ie.focus(),ie.selectionStart=ie.selectionEnd=ie.value.length,W(ji(ie,L.current)))})},[W]),Re=w.useCallback(ie=>{A(`/${ie.name} `),oe(0),Pe()},[Pe]),$e=w.useCallback(ie=>{A(ie),Pe()},[Pe]),De=w.useCallback(ie=>{if(!ue)return;const xe=F5(P,ue,ie);A(xe),fe(!0),ae(0),requestAnimationFrame(()=>{const Ee=z.current;Ee&&(Ee.focus(),Ee.selectionStart=Ee.selectionEnd=Ee.value.length,W(ji(Ee,L.current)))})},[ue,P,W]),Le=w.useCallback(async()=>{const ie=P.trim();if(!ie&&U.length===0||!e&&U.length>0)return;if((f==null?void 0:f.type)==="question"){je(ie),A(""),W(!1),z.current&&(z.current.style.height="auto");return}if((f==null?void 0:f.type)==="plan"&&f.provider==="copilot"){if(!ie||!await Se(!1,void 0,ie))return;A(""),W(!1),z.current&&(z.current.style.height="auto");return}const xe=e&&U.length>0?U.map(Ee=>({data:Ee.data,mediaType:Ee.mediaType})):void 0;C(ie,xe),A(""),J(),W(!1),z.current&&(z.current.style.height="auto")},[P,U,e,C,J,W,f,je,Se]),ze=w.useCallback(ie=>{if(de&&ie.key==="Escape"){ie.preventDefault(),fe(!0);return}if(de&&be.files.length>0){if(ie.key==="ArrowDown"){ie.preventDefault(),ae(xe=>xe<be.files.length-1?xe+1:0);return}if(ie.key==="ArrowUp"){ie.preventDefault(),ae(xe=>xe>0?xe-1:be.files.length-1);return}if(ie.key==="Tab"||ie.key==="Enter"&&!ie.shiftKey){ie.preventDefault();const xe=be.files[re];xe&&De(xe);return}}if(le&&me.length>0){if(ie.key==="ArrowDown"){ie.preventDefault(),oe(xe=>xe<me.length-1?xe+1:0);return}if(ie.key==="ArrowUp"){ie.preventDefault(),oe(xe=>xe>0?xe-1:me.length-1);return}if(ie.key==="Tab"||ie.key==="Enter"&&!ie.shiftKey){ie.preventDefault();const xe=me[ne];xe&&Re(xe);return}if(ie.key==="Escape"){ie.preventDefault(),A("");return}}if(ie.key==="Escape"&&_&&N){ie.preventDefault(),N();return}ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),Le())},[Le,_,N,de,be.files,re,De,le,me,ne,Re]),Te=w.useCallback(ie=>{A(ie.target.value),fe(!1),W(ji(ie.target,L.current))},[W]);w.useImperativeHandle(a,()=>({focus:()=>{var ie;return(ie=z.current)==null?void 0:ie.focus()},getText:()=>F.current,setText:ie=>{A(ie),fe(!1),requestAnimationFrame(()=>W(ji(z.current,L.current)))}}),[W]);const _e=(f==null?void 0:f.type)==="plan",We=(f==null?void 0:f.type)==="question",Fe=m.length>0,Ne=(P.trim().length>0||U.length>0)&&!q,pe=Vt(t??Xs).midTurnSteering&&_,Oe=de?"file-suggestions":le?"slash-suggestions":void 0,Ae=de&&be.files[re]?`file-suggestion-${re}`:le&&me[ne]?`slash-suggestion-${ne}`:void 0;return r.jsxs("div",{className:G("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(f5,{suggestions:me,filter:ce,loading:b,selectedIndex:ne,onSelect:Re,onHover:oe,onEdit:u}),de&&r.jsx(g5,{files:be.files,query:(ue==null?void 0:ue.query)??"",loading:be.loading,selectedIndex:re,onSelect:De,onHover:ae}),r.jsxs("div",{children:[_e&&r.jsx(y5,{allowedPrompts:f.allowedPrompts,summary:f.summary,planContent:f.planContent,actions:f.actions,recommendedAction:f.recommendedAction,responding:R,responseError:$,onApprove:ie=>{Se(!0,ie)},onReject:()=>{Se(!1)}}),r.jsx(L5,{suggestion:v,onAccept:$e}),U.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:U.map((ie,xe)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:ie.preview,alt:`Upload ${xe+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>V(xe),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 ${xe+1}`,children:r.jsx(st,{className:"size-3","data-icon":"icon"})})]},ie.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(st,{"data-icon":"icon"})})]}),r.jsxs("div",{className:G("relative overflow-hidden rounded-xl border bg-prompt-surface shadow-xs",nS(_e,We,Fe),"focus-within:ring-3"),children:[Fe&&r.jsx(k5,{requests:m,responding:p,onRespond:h,onRespondAll:g},(Be=m[0])==null?void 0:Be.requestId),r.jsxs("div",{className:G("grid min-w-0 items-end",T?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]"),children:[o&&r.jsx("div",{className:G("flex shrink-0 items-center",T?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:o}),r.jsx(Da,{ref:z,value:P,onChange:Te,onKeyDown:ze,onPaste:te,onFocus:()=>{setTimeout(()=>{var ie;return(ie=z.current)==null?void 0:ie.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:tS(_e,We,k,Fe,pe,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Oe,"aria-controls":Oe,"aria-activedescendant":Ae,rows:1,className:G("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",T?G("col-span-2 row-start-1",i?"py-2.5 pr-3":"py-3 pr-4"):G("col-start-2 row-start-1",i?"py-2 pr-1":"py-2.5 pr-2"),i?"pl-2 text-sm":"pl-4 text-sm")}),r.jsxs("div",{className:G("flex shrink-0 items-center justify-end",T?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"),children:[r.jsx(O5,{isPlanApproval:_e,isUserQuestion:We,elapsedSec:ge}),r.jsx(D5,{hasContent:Ne,onSubmit:Le,submitLabel:pe?"Steer active turn":"Send message"})]})]})]}),S==="error"&&j&&r.jsx(jm,{error:j},j),y&&r.jsx(jm,{error:y},y)]})]})}));function sS(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}function oS(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=sS(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const o=typeof s.condition=="string"?s.condition:"",i=s.met===!0,a=s.failed===!0;return s.sentinel===!0&&i||!o?null:{condition:o,status:a?"failed":i?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}function Si(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Lt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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(Qy,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Hr(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({className:s,children:t,value:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);let a;e[5]!==s?(a=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=a):a=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(rS,{children:r.jsx(iS,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(Zy,{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 rS(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(e3,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function iS(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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(t3,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Rg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm font-medium",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(n3,{className:o,"data-slot":"progress-label",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function $g(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(s3,{className:o,"data-slot":"progress-value",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const aS={section:null,canCreate:!1,beginEditing:()=>{}},Id=w.createContext(aS);function Ig(){return w.useContext(Id)}const Mg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",Og="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function lS(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function cS(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function dS({agentKind:n,threadId:e,children:t}){const s=Ra(n),[o,i]=w.useState(null),[a,l]=w.useState(!0),[c,d]=w.useState(!1),[u,f]=w.useState(""),[m,p]=w.useState(""),[h,g]=w.useState(!1),[x,b]=w.useState(null),y=w.useCallback(async P=>{try{const A=await ve(Si(e),{signal:P});if(A.status===404||A.status===501){l(!1);return}if(!A.ok)return;const T=await A.json();i(T.goal),l(!0)}catch{}},[e]);w.useEffect(()=>{const P=new AbortController;y(P.signal);const A=a?setInterval(()=>void y(),1e4):void 0;return()=>{P.abort(),A!==void 0&&clearInterval(A)}},[y,a]);const v=w.useCallback(()=>{var P;f((o==null?void 0:o.objective)??""),p(((P=o==null?void 0:o.tokenBudget)==null?void 0:P.toString())??""),b(null),d(!0)},[o]),S=async()=>{const P=u.trim();if(!P)return;const A=m.trim()?Number(m):null;if(A!==null&&(!Number.isSafeInteger(A)||A<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const T=await ve(Si(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:P,status:(o==null?void 0:o.status)==="complete"?"active":(o==null?void 0:o.status)??"active",tokenBudget:A})}),E=await T.json();if(!T.ok)throw new Error(E.error||"Could not save goal");i(E.goal),d(!1)}catch(T){b(T instanceof Error?T.message:"Could not save goal")}finally{g(!1)}},j=async P=>{if(o){g(!0);try{const A=await ve(Si(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:P})});A.ok&&i((await A.json()).goal)}finally{g(!1)}}},k=async()=>{g(!0);try{(await ve(Si(e),{method:"DELETE"})).ok&&(i(null),d(!1))}finally{g(!1)}},C=o!=null&&o.tokenBudget?Math.min(100,o.tokensUsed/o.tokenBudget*100):null;let N=null;if(a&&c)N=r.jsxs("form",{className:Og,onSubmit:P=>{P.preventDefault(),S()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(So,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(Io,{className:"gap-2",children:[r.jsxs(St,{children:[r.jsx(Nt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(Da,{id:"goal-objective",value:u,onChange:P=>f(P.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),r.jsxs(St,{orientation:"horizontal","data-invalid":!!x,children:[r.jsx(Nt,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),r.jsx(Lt,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:P=>p(P.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),r.jsx(bs,{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(st,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(ee,{type:"submit",size:"xs",disabled:h||!u.trim(),children:[r.jsx(gt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const P=o.status==="paused",A=o.status==="complete";N=r.jsxs("section",{className:Mg,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(So,{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(Ce,{variant:cS(o.status),children:lS(o.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[mt(o.tokensUsed),o.tokenBudget?` / ${mt(o.tokenBudget)}`:""," · ",Math.max(0,Math.round(o.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx($r,{"data-icon":"icon"})}),!P&&!A&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(o3,{"data-icon":"icon"})}),!A&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(gt,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:r.jsx(Vs,{"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(va,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(Hr,{className:"mt-1 mb-0.5",value:C,"aria-label":`${C.toFixed(0)}% of goal token budget used`})]})}const _=w.useMemo(()=>({section:N,canCreate:a&&!o&&!c,beginEditing:v}),[N,a,o,c,v]);return r.jsx(Id.Provider,{value:_,children:t})}function uS(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function fS(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function mS(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=Ra(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=oS(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const d=c,[u,f]=w.useState(),[m,p]=w.useState(!1),[h,g]=w.useState(""),[x,b]=w.useState(null),y=d?`${d.status}\0${d.condition}`:"",[v,S]=w.useState(y);v!==y&&(S(y),f(void 0));const j=u!==void 0?u:d;let k;e[4]!==(j==null?void 0:j.condition)?(k=()=>{g((j==null?void 0:j.condition)??""),b(null),p(!0)},e[4]=j==null?void 0:j.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}f({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 P;e[9]!==o?(P=()=>{f(null),p(!1),o("/goal clear")},e[9]=o,e[10]=P):P=e[10];const A=P;let T;if(e[11]!==l||e[12]!==C||e[13]!==A||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==j||e[18]!==_){if(T=null,m){let M;e[20]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(So,{className:"size-3.5","data-icon":"inline-start"}),e[20]=M):M=e[20];const O=j?"Replace goal":"Set a long-running goal";let D;e[21]!==O?(D=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,O]}),e[21]=O,e[22]=D):D=e[22];const L=!!x;let F;e[23]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(Nt,{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(Da,{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(bs,{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(St,{"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(st,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=Y):Y=e[35];let V;e[36]!==h?(V=h.trim(),e[36]=h,e[37]=V):V=e[37];const J=!V;let Q;e[38]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(gt,{"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],T=r.jsxs("section",{className:Og,"aria-label":`${l} goal editor`,children:[D,q,X]})}else if(j){let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(So,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=M):M=e[42];let O;e[43]!==j.condition?(O=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:j.condition,children:j.condition}),e[43]=j.condition,e[44]=O):O=e[44];let D;e[45]!==j.status?(D=fS(j.status),e[45]=j.status,e[46]=D):D=e[46];let L;e[47]!==j.status?(L=uS(j.status),e[47]=j.status,e[48]=L):L=e[48];let F;e[49]!==D||e[50]!==L?(F=r.jsx(Ce,{variant:D,children:L}),e[49]=D,e[50]=L,e[51]=F):F=e[51];const z=j.iterations,W=j.iterations===1?"":"s";let U;e[52]!==j.tokens?(U=mt(j.tokens),e[52]=j.tokens,e[53]=U):U=e[53];let H;e[54]!==j.durationMs?(H=Math.round(j.durationMs/6e4),e[54]=j.durationMs,e[55]=H):H=e[55];const K=Math.max(0,H);let q;e[56]!==j.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]=j.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(Vs,{"data-icon":"icon"}),e[61]=Y):Y=e[61];let V;e[62]!==C?(V=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:Y}),e[62]=C,e[63]=V):V=e[63];let J;e[64]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(va,{"data-icon":"icon"}),e[64]=J):J=e[64];let Q;e[65]!==A?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:J}),e[65]=A,e[66]=Q):Q=e[66];let X;e[67]!==V||e[68]!==Q?(X=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[V,Q]}),e[67]=V,e[68]=Q,e[69]=X):X=e[69];let Z;e[70]!==F||e[71]!==q||e[72]!==X||e[73]!==O?(Z=r.jsxs("div",{className:"flex items-center gap-2",children:[M,O,F,q,X]}),e[70]=F,e[71]=q,e[72]=X,e[73]=O,e[74]=Z):Z=e[74];let te;e[75]!==j.reason?(te=j.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:j.reason}),e[75]=j.reason,e[76]=te):te=e[76],T=r.jsxs("section",{className:Mg,"aria-label":`${l} goal`,children:[Z,te]})}e[11]=l,e[12]=C,e[13]=A,e[14]=h,e[15]=m,e[16]=x,e[17]=j,e[18]=_,e[19]=T}else T=e[19];const E=!j&&!m;let R;e[77]!==C||e[78]!==T||e[79]!==E?(R={section:T,canCreate:E,beginEditing:C},e[77]=C,e[78]=T,e[79]=E,e[80]=R):R=e[80];const I=R;let $;return e[81]!==i||e[82]!==I?($=r.jsx(Id.Provider,{value:I,children:i}),e[81]=i,e[82]=I,e[83]=$):$=e[83],$}function pS(n){const e=B.c(9),{agentKind:t,session:s,onSendCommand:o,children:i}=n,a=Vt(t).goals;if(a==="thread-api"){let l;return e[0]!==t||e[1]!==i||e[2]!==s.sessionId?(l=r.jsx(dS,{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(mS,{agentKind:t,session:s,onSendCommand:o,children:i}),e[4]=t,e[5]=i,e[6]=o,e[7]=s,e[8]=l):l=e[8],l}return i}function Dg(){return Ig().section}function Lg(){const n=B.c(3),{canCreate:e,beginEditing:t}=Ig();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(So,{"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 hS(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(Dg,{}),r.jsx(Lg,{})]}),n[0]=e):e=n[0],e}const gS=/\x1b\].*?(?:\x07|\x1b\\)/g,xS=/\x1b\[[0-9;]*[A-Za-z]/g,bS=/\x1b[()][AB012]/g,vS=/\[2K\[1G/g;function zg(n){return n.replace(gS,"").replace(xS,"").replace(bS,"").replace(vS,`
5
+ `).replace(/\r/g,"")}function Gn(n){const e=B.c(14);let t,s,o;e[0]!==n?({className:s,children:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("relative overflow-hidden",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(i3,{"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(yS,{}),c=r.jsx(a3,{}),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(r3,{"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 yS(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"vertical":o;let a;e[4]!==t?(a=G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",t),e[4]=t,e[5]=a):a=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(c3,{"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(l3,{"data-slot":"scroll-area-scrollbar","data-orientation":i,orientation:i,className:a,...s,children:l}),e[7]=i,e[8]=s,e[9]=a,e[10]=c):c=e[10],c}function Fg(n){const e=B.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function wS(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}function jS(n){const e=B.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a=r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e[5]=i,e[6]=a):(i=e[5],a=e[6]);let l;return e[7]!==s||e[8]!==o?(l=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:o,...s,children:[i,a]}),e[7]=s,e[8]=o,e[9]=l):l=e[9],l}function SS(n){const e=B.c(11);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("size-5",t),e[3]=t,e[4]=o):o=e[4];let i,a,l;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a=r.jsx("path",{className:"status-icon-spin",d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),l=r.jsx("path",{className:"status-icon-spin",d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e[5]=i,e[6]=a,e[7]=l):(i=e[5],a=e[6],l=e[7]);let c;return e[8]!==s||e[9]!==o?(c=r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:o,...s,children:[i,a,l]}),e[8]=s,e[9]=o,e[10]=c):c=e[10],c}function ot(n){const e=B.c(10);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o,i;if(e[3]!==t){const l=t==null?void 0:t.replace(/\banimate-spin\b/g,"").trim();o=Fg,i=G(l),e[3]=t,e[4]=o,e[5]=i}else o=e[4],i=e[5];let a;return e[6]!==o||e[7]!==s||e[8]!==i?(a=r.jsx(o,{className:i,...s}),e[6]=o,e[7]=s,e[8]=i,e[9]=a):a=e[9],a}function NS(n){const e=Pn("hostFiles"),[t,s]=w.useState([]),[o,i]=w.useState(!1),a=w.useCallback(async()=>{if(!e||!n){s([]);return}i(!0);try{const l=await ve(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{i(!1)}},[e,n]);return w.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const Sm=500,kS=5e3;function CS(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=w.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=w.useState(i),c=w.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const u=w.useRef(d),f=w.useRef(Sm),m=w.useRef(null),p=w.useRef(!1),h=w.useRef(_S);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=u.current.get(z))==null||W(F,L))},e[2]=g):g=e[2];const x=g;let b,y;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}${J1()}/__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}f.current=Sm,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=f.current;f.current=Math.min(U*2,kS),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)}},y=[t,x],e[3]=t,e[4]=b,e[5]=y):(b=e[4],y=e[5]),w.useEffect(b,y);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 S=v;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=(L,F)=>{u.current.set(L,F)},e[8]=j):j=e[8];const k=j;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=L=>{u.current.delete(L)},e[9]=C):C=e[9];const N=C;let _;e[10]!==S?(_=L=>{const F=L===void 0?{}:L,z=`pty_${crypto.randomUUID().slice(0,8)}`;return S({type:"spawn",id:z,name:F.name??"Terminal",cwd:F.cwd,metadata:{type:"terminal"}}),z},e[10]=S,e[11]=_):_=e[11];const P=_;let A;e[12]!==S?(A=L=>{const F=`script_${crypto.randomUUID().slice(0,8)}`;return S({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]=S,e[13]=A):A=e[13];const T=A;let E;e[14]!==S?(E=L=>{S({type:"kill",id:L})},e[14]=S,e[15]=E):E=e[15];const R=E;let I;e[16]!==S?(I=(L,F)=>{S({type:"input",id:L,data:F})},e[16]=S,e[17]=I):I=e[17];const $=I;let M;e[18]!==S?(M=(L,F,z)=>{S({type:"resize",id:L,cols:F,rows:z})},e[18]=S,e[19]=M):M=e[19];const O=M;let D;return e[20]!==R||e[21]!==O||e[22]!==S||e[23]!==a||e[24]!==T||e[25]!==P||e[26]!==s||e[27]!==$?(D={status:s,send:S,subscribe:k,unsubscribe:N,sessions:a,spawnTerminal:P,spawnScript:T,killSession:R,writeInput:$,resize:O},e[20]=R,e[21]=O,e[22]=S,e[23]=a,e[24]=T,e[25]=P,e[26]=s,e[27]=$,e[28]=D):D=e[28],D}function _S(){}const Bg=w.createContext(null);function El(n){const e=B.c(3),{children:t,enabled:s}=n,i=CS(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(Bg.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function Md(){const n=w.useContext(Bg);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function TS(n){var u;const e=B.c(11),t=Md();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((u=f.metadata)==null?void 0:u.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.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=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;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=f=>{t.killSession(f)},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 ES(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 u;e[0]!==l?(u=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=u):u=e[1];let f;e[2]!==u?(f=r.jsx("span",{className:u}),e[2]=u,e[3]=f):f=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(xd,{"data-icon":"inline-end",className:"fill-current text-destructive"}):r.jsx($r,{"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]!==f||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:[f,m,p]}),e[8]=c,e[9]=d,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const PS=w.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=w.useState(!1),[l,c]=w.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[u,f]=w.useState(d),{scripts:m,loading:p}=NS(s),{runningProcesses:h,runScript:g,stopScript:x}=TS(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 y=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 S=v;if(!s||!p&&m.length===0)return null;let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=function(z){f(W=>{const U=new Set(W);return U.has(z)?U.delete(z):U.add(z),U})},t[6]=j):j=t[6];const k=j;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(ot,{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 P,A;t[10]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{a(AS),c("")},A=r.jsx(cn,{}),t[10]=P,t[11]=A):(P=t[10],A=t[11]);let T;t[12]!==i||t[13]!==_?(T=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":_,"aria-expanded":i,onClick:P,children:A}),t[12]=i,t[13]=_,t[14]=T):T=t[14];let E;t[15]!==N||t[16]!==T?(E=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,N,T]}),t[15]=N,t[16]=T,t[17]=E):E=t[17];let R;t[18]!==i||t[19]!==l?(R=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(Lt,{type:"search",value:l,onChange:F=>c(F.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=i,t[19]=l,t[20]=R):R=t[20];let I;t[21]!==u||t[22]!==y||t[23]!==g||t[24]!==S||t[25]!==l||t[26]!==x?(I=[...y.entries()].map(F=>{const[z,W]=F,U=u.has(z)||!!l,H=W.filter(RS),K=W.filter($S),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:[y.size>1&&r.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:z}),q.map(Y=>{const V=S.get(`${Y.name}:${Y.dir}`);return r.jsx(ES,{script:Y,status:(V==null?void 0:V.status)??null,onRun:()=>g(Y.name,Y.dir,Y.dirLabel),onStop:()=>{V&&x(V.id)}},`${z}:${Y.name}`)}),!l&&K.length>0&&r.jsx(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]=u,t[22]=y,t[23]=g,t[24]=S,t[25]=l,t[26]=x,t[27]=I):I=t[27];let $;t[28]!==y.size||t[29]!==p||t[30]!==l?($=!p&&y.size===0&&l&&r.jsx(dn,{className:"gap-1 p-3",children:r.jsxs(un,{className:"gap-1",children:[r.jsx(fn,{children:"No matching scripts"}),r.jsx(yn,{children:"Try another name."})]})}),t[28]=y.size,t[29]=p,t[30]=l,t[31]=$):$=t[31];let M;t[32]!==I||t[33]!==$?(M=r.jsxs(Gn,{className:"min-h-0 flex-1 px-1 pb-1",children:[I,$]}),t[32]=I,t[33]=$,t[34]=M):M=t[34];let O;t[35]!==R||t[36]!==M||t[37]!==E?(O=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,R,M]}),t[35]=R,t[36]=M,t[37]=E,t[38]=O):O=t[38];let D;t[39]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(kt,{orientation:"vertical"}),t[39]=D):D=t[39];let L;return t[40]!==O?(L=r.jsxs(r.Fragment,{children:[O,D]}),t[40]=O,t[41]=L):L=t[41],L});function AS(n){return!n}function RS(n){return n.isCommon}function $S(n){return!n.isCommon}function La(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,orientation:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"horizontal":o;let a;e[4]!==t?(a=G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==i||e[7]!==s||e[8]!==a?(l=r.jsx(f3,{"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 IS=ss("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 za(n){const e=B.c(17);let t,s,o,i;e[0]!==n?({className:s,children:t,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==s||e[6]!==a?(l=G(IS({variant:a}),"relative isolate",s),e[5]=s,e[6]=a,e[7]=l):l=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5"),e[8]=c):c=e[8];let d;e[9]!==a?(d=r.jsx(p3,{"data-slot":"tabs-indicator","data-variant":a,className:c}),e[9]=a,e[10]=d):d=e[10];let u;return e[11]!==t||e[12]!==o||e[13]!==l||e[14]!==d||e[15]!==a?(u=r.jsxs(u3,{"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]=u):u=e[16],u}function Ln(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(m3,{"data-slot":"tabs-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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(d3,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const MS=w.lazy(()=>qe(()=>import("./TerminalOutput-C-6RWc6C.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function OS({process:n}){const[e,t]=w.useState(""),[s,o]=w.useState(!1),i=w.useRef(null);return w.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=Lr(`/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 u=zg(d.text);u&&t(f=>{const m=f+u;return m.length>1e5?m.slice(-1e5):m})}}catch{}},l.onerror=()=>{},()=>l.close()},[n.id,n.type,n.outputPath]),w.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 DS(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 u;e[0]!==s||e[1]!==o?(u=()=>{s&&o()},e[0]=s,e[1]=o,e[2]=u):u=e[2];const f=a?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&r.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&r.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=r.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=a&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let y;e[13]!==t.type||e[14]!==b?(y=r.jsx(Ce,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=y):y=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==y||e[19]!==u||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=r.jsxs(Ln,{value:c,"aria-label":d,onClick:u,className:m,children:[p,h,g,y]}),e[16]=t.id,e[17]=t.name,e[18]=y,e[19]=u,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const S=`Close ${t.name}`,j=`Close ${t.name}`;let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(st,{"data-icon":"inline-start"}),e[25]=k):k=e[25];let C;e[26]!==i||e[27]!==S||e[28]!==j?(C=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs","aria-label":S,title:j,onClick:i,className:"mr-0.5 text-muted-foreground",children:k}),e[26]=i,e[27]=S,e[28]=j,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 Ug=100,Wg=600,LS=200,Hg="process-panel-height";function zS(){try{const n=localStorage.getItem(Hg);if(n)return Math.min(Wg,Math.max(Ug,Number(n)))}catch{}return LS}const FS=w.memo(function(e){const t=B.c(89),{processes:s,activeProcessId:o,collapsed:i,onSetActive:a,onRemove:l,onToggleCollapse:c,onRequestTerminal:d,onAddTerminalContext:u,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=Md(),[b,y]=w.useState(zS),v=w.useRef(null);let S,j;t[0]!==f||t[1]!==x.sessions?(S=()=>{for(const de of x.sessions)de.status==="exited"&&(f==null||f(de.id,"stopped"))},j=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=S,t[3]=j):(S=t[2],j=t[3]),w.useEffect(S,j);let k;t[4]!==l||t[5]!==x?(k=de=>{de.type!=="task"&&x.killSession(de.id),l(de.id)},t[4]=l,t[5]=x,t[6]=k):k=t[6];const C=k;let N;t[7]!==b?(N=de=>{de.preventDefault(),v.current={startY:de.clientY,startH:b},de.target.setPointerCapture(de.pointerId)},t[7]=b,t[8]=N):N=t[8];const _=N;let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P=de=>{if(!v.current)return;const be=v.current.startY-de.clientY,ge=Math.min(Wg,Math.max(Ug,v.current.startH+be));y(ge)},t[9]=P):P=t[9];const A=P;let T;t[10]!==b?(T=()=>{if(v.current){v.current=null;try{localStorage.setItem(Hg,String(b))}catch{}}},t[10]=b,t[11]=T):T=t[11];const E=T;let R;t[12]!==o||t[13]!==s?(R=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=R):R=t[14];const I=R;let $;t[15]!==s?($=[...s.values()],t[15]=s,t[16]=$):$=t[16];const M=$;let O;t[17]!==a?(O=de=>{typeof de=="string"&&a(de)},t[17]=a,t[18]=O):O=t[18];let D;t[19]!==I||t[20]!==i||t[21]!==g||t[22]!==_||t[23]!==E?(D=!g&&!i&&I&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:_,onPointerMove:A,onPointerUp:E,onPointerCancel:E}),t[19]=I,t[20]=i,t[21]=g,t[22]=_,t[23]=E,t[24]=D):D=t[24];const L=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==L?(F=G("flex shrink-0 items-center border-b bg-card",L),t[25]=L,t[26]=F):F=t[26];const z=i?"Expand terminal panel":"Collapse terminal panel",W=!i;let U;t[27]!==i?(U=i?r.jsx(Je,{"data-icon":"inline-start"}):r.jsx(tt,{"data-icon":"inline-start"}),t[27]=i,t[28]=U):U=t[28];const H=g&&"sr-only";let K;t[29]!==H?(K=G(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 V=!g&&"ml-2";let J;t[39]!==V?(J=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",V),t[39]=V,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(de=>r.jsx(DS,{process:de,isActive:de.id===o,onSelectActive:()=>a(de.id),onClose:()=>C(de),mobile:g},de.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(za,{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(Bn,{})}),t[50]=d,t[51]=m,t[52]=Z):Z=t[52];let te;t[53]!==F||t[54]!==Y||t[55]!==X||t[56]!==Z?(te=r.jsxs("div",{className:F,children:[Y,X,Z]}),t[53]=F,t[54]=Y,t[55]=X,t[56]=Z,t[57]=te):te=t[57];const ne=!i,oe=g?"min(36dvh, 260px)":b;let re;t[58]!==oe?(re={height:oe},t[58]=oe,t[59]=re):re=t[59];let ae;t[60]!==g||t[61]!==p||t[62]!==m?(ae=!g&&r.jsx(PS,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ae):ae=t[63];let se;t[64]!==C||t[65]!==u||t[66]!==d||t[67]!==M?(se=M.map(de=>r.jsx(zn,{value:de.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:de.type==="task"?r.jsx(OS,{process:de}):r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(MS,{processId:de.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(de),onAddContext:u})})},de.id)),t[64]=C,t[65]=u,t[66]=d,t[67]=M,t[68]=se):se=t[68];let fe;t[69]!==I||t[70]!==d||t[71]!==m?(fe=!I&&r.jsxs(dn,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(Gs,{})}),r.jsx(fn,{children:"No terminal open"}),r.jsx(yn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(Y1,{children:r.jsxs(ee,{type:"button",size:"sm",onClick:d,children:[r.jsx(Bn,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=I,t[70]=d,t[71]=m,t[72]=fe):fe=t[72];let le;t[73]!==se||t[74]!==fe?(le=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[se,fe]}),t[73]=se,t[74]=fe,t[75]=le):le=t[75];let ce;t[76]!==re||t[77]!==ae||t[78]!==le?(ce=r.jsx(at,{children:r.jsxs("div",{className:"flex min-h-0",style:re,children:[ae,le]})}),t[76]=re,t[77]=ae,t[78]=le,t[79]=ce):ce=t[79];let me;t[80]!==ne||t[81]!==ce?(me=r.jsx(it,{open:ne,className:"min-h-0",children:ce}),t[80]=ne,t[81]=ce,t[82]=me):me=t[82];let ue;return t[83]!==o||t[84]!==O||t[85]!==D||t[86]!==te||t[87]!==me?(ue=r.jsxs(La,{value:o,onValueChange:O,className:"shrink-0 gap-0 border-t bg-background",children:[D,te,me]}),t[83]=o,t[84]=O,t[85]=D,t[86]=te,t[87]=me,t[88]=ue):ue=t[88],ue});function Kr(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 BS=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function US(n){const e=new Set;for(const t of n.matchAll(BS)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function WS(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(" "),u=US(d);if(u.length===0){const p=a.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&u.push(3e3)}const f=(i.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of u)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 Nm(n){var e;return((e=n.preview.split(`
6
+ `).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function HS(n){const e=B.c(10),{port:t,isActive:s}=n,o=s?"bg-success":"bg-muted-foreground/40";let i;e[0]!==o?(i=G("inline-block size-1.5 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==i?(a=r.jsx("span",{className:i}),e[2]=i,e[3]=a):a=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=r.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(Ce,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Kg({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=w.useState([]),a=WS(e);w.useEffect(()=>{if(!n)return;let c=!1;async function d(){try{const f=await ve(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(c)return;if(f.ok){const h=await f.json();if(c)return;if(h.length>0){i(h);return}}if(a.size===0){i([]);return}const m=[...a.keys()],p=await ve(`/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,y]of a)!h[b]||x.has(b)||(x.add(b),g.push({id:`port-${b}`,outputPath:y.outputPath,ports:[b],portStatus:{[b]:!0},preview:y.description}));i(g)}}catch{}}d();const u=setInterval(d,1e4);return()=>{c=!0,clearInterval(u)}},[n,a]);const l=w.useCallback(async c=>{try{await ve("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:c})}),setTimeout(()=>{i(d=>d.filter(u=>!u.ports.includes(c)))},1500)}catch{}},[]);return w.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Nm(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(Kr,{children:["Active Servers (",o.length,")"]}),r.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(c=>{const d=c.ports.filter(f=>c.portStatus[f]),u=Nm(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(j1,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:u})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[c.ports.map(f=>r.jsx(HS,{port:f,isActive:c.portStatus[f]},f)),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,u),title:"View server output","aria-label":"View server output",children:r.jsx(Gs,{"data-icon":"inline-start"})}),d.length>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(f=>l(f)),title:"Stop server","aria-label":"Stop server",children:[r.jsx(xd,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function Od(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(h3,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function KS(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(g3,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function qS(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(pd,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}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=G("fixed inset-0 isolate z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(hd,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Dd(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(VS,{}),e[4]=a):a=e[4];let l;e[5]!==t?(l=G("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-4 text-popover-foreground shadow-lg duration-150 ease-out outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==i||e[9]!==l?(c=r.jsxs(qS,{children:[a,r.jsx(md,{"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 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=G("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-footer",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function GS(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"alert-dialog-media",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function 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=G("text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(ud,{"data-slot":"alert-dialog-title",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=G("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(fd,{"data-slot":"alert-dialog-description",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=G(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 Wd(n){const e=B.c(14);let t,s,o,i;e[0]!==n?({className:t,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=o===void 0?"outline":o,l=i===void 0?"default":i;let c;e[5]!==t?(c=G(t),e[5]=t,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==a?(d=r.jsx(ee,{variant:a,size:l}),e[7]=l,e[8]=a,e[9]=d):d=e[9];let u;return e[10]!==s||e[11]!==c||e[12]!==d?(u=r.jsx(xa,{"data-slot":"alert-dialog-cancel",className:c,render:d,...s}),e[10]=s,e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function qg(n){const e=B.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-90 group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary motion-reduce:transition-none motion-reduce:active:scale-100 dark:data-checked:bg-primary",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(b3,{"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(gt,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(x3,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const YS={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},XS={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 JS({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var f,m;const i=w.useRef(n),[a,l]=w.useState({key:"",selected:!1});w.useEffect(()=>{n&&(i.current=n)},[n]);const c=n??i.current;if(!c)return null;const d=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,u=a.key===d&&a.selected;return r.jsx(Od,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(Dd,{children:[r.jsxs(Ld,{children:[r.jsx(GS,{children:r.jsx(bn,{className:"text-warning"})}),r.jsx(Fd,{children:YS[c.type]}),r.jsx(Bd,{children:c.nativeRewind?u?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":XS[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(qg,{checked:u,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(pt,{variant:"destructive",children:r.jsx(ht,{children:t})}),r.jsxs(zd,{children:[r.jsx(Wd,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(Ud,{onClick:()=>s(u),disabled:e,children:e?r.jsxs(r.Fragment,{children:[r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Qt(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"default":o;let a;e[4]!==t?(a=G("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==a?(l=r.jsx("div",{"data-slot":"card","data-size":i,className:a,...s}),e[6]=s,e[7]=i,e[8]=a,e[9]=l):l=e[9],l}function 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=G("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ln(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function pn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Hd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"card-action",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Zt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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 Oo(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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 cs(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"input-group",role:"group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const QS=ss("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 An(n){const e=B.c(11);let t,s,o;e[0]!==n?({className:t,align:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);const i=o===void 0?"inline-start":o;let a;e[4]!==i||e[5]!==t?(a=G(QS({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:ZS,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function ZS(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const eN=ss("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 qr(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 u;e[6]!==t||e[7]!==d?(u=G(eN({size:d}),t),e[6]=t,e[7]=d,e[8]=u):u=e[8];let f;return e[9]!==s||e[10]!==d||e[11]!==u||e[12]!==l||e[13]!==c?(f=r.jsx(ee,{type:l,"data-size":d,variant:c,className:u,...s}),e[9]=s,e[10]=d,e[11]=u,e[12]=l,e[13]=c,e[14]=f):f=e[14],f}function ds(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Lt,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function tN(){const[n,e]=w.useState("idle"),[t,s]=w.useState(null),o=w.useRef(void 0),i=w.useCallback(async d=>{if(!d.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await ve(`/api/config/validate?path=${encodeURIComponent(d)}`)).json();f.valid?(e("valid"),s(null)):(e("invalid"),s(f.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),a=w.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=w.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=w.useCallback(async(d,u)=>{try{const f=await ve("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:d,...u})}),m=await f.json();return f.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 w.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}const po=Pw(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),Vg=Ca().filter(n=>n.cli.homeIsDiscoverable);function Gg(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function Yg(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 nN=Gg(Vg.map(n=>n.displayName)),sN=Gg(Vg.map(n=>r.jsx(Yg,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),oN=`~/${po.cli.homeDirName}`;function rN(n){const e=B.c(46),{onConfigured:t}=n,[s,o]=w.useState(""),[i,a]=w.useState(!1),{status:l,error:c,debouncedValidate:d,save:u}=tN();let f;e[0]!==d?(f=D=>{const L=D.target.value;o(L),d(L)},e[0]=d,e[1]=f):f=e[1];const m=f;let p;e[2]!==t||e[3]!==s||e[4]!==u?(p=async()=>{a(!0);const D=await u(s);D.success&&D.claudeDir&&t(D.claudeDir),a(!1)},e[2]=t,e[3]=s,e[4]=u,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==i||e[8]!==l?(g=D=>{D.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(gd,{className:"size-4"})}),b=r.jsx(ln,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsxs(an,{children:[x,b,r.jsxs(pn,{children:["Cogpit detects ",nN," automatically. Existing histories live in"," ",sN,"."," ","For ",po.displayName,", enter its data directory, usually"," ",r.jsx(Yg,{children:oN}),"."]})]}),e[12]=y):y=e[12];const v=l==="invalid";let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(Nt,{htmlFor:"agent-data-directory",children:[po.displayName," data directory"]}),e[13]=S):S=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(An,{children:r.jsx(No,{"aria-hidden":"true"})}),e[14]=j):j=e[14];const k=l==="invalid";let C;e[15]!==m||e[16]!==s||e[17]!==k?(C=r.jsxs(cs,{children:[j,r.jsx(ds,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${po.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(Co,{className:"flex items-center gap-2",children:[r.jsx(ot,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=N):N=e[20];let _;e[21]!==l?(_=l==="valid"&&r.jsxs(Co,{className:"flex items-center gap-2 text-success",children:[r.jsx(Rr,{className:"size-4"}),po.displayName," history found"]}),e[21]=l,e[22]=_):_=e[22];let P;e[23]!==c||e[24]!==l?(P=l==="invalid"&&c&&r.jsxs(bs,{className:"flex items-center gap-2",children:[r.jsx(Ys,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=P):P=e[25];let A;e[26]!==N||e[27]!==_||e[28]!==P?(A=r.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[N,_,P]}),e[26]=N,e[27]=_,e[28]=P,e[29]=A):A=e[29];let T;e[30]!==C||e[31]!==A||e[32]!==v?(T=r.jsx(Zt,{children:r.jsx(Io,{children:r.jsxs(St,{"data-invalid":v,children:[S,C,A]})})}),e[30]=C,e[31]=A,e[32]=v,e[33]=T):T=e[33];const E=l!=="valid"||i;let R;e[34]!==i?(R=i&&r.jsx(ot,{"data-icon":"inline-start"}),e[34]=i,e[35]=R):R=e[35];const I=i?"Saving...":`Connect ${po.displayName}`;let $;e[36]!==E||e[37]!==R||e[38]!==I?($=r.jsx(Oo,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:E,children:[R,I]})}),e[36]=E,e[37]=R,e[38]=I,e[39]=$):$=e[39];let M;e[40]!==T||e[41]!==$?(M=r.jsxs(Qt,{children:[y,T,$]}),e[40]=T,e[41]=$,e[42]=M):M=e[42];let O;return e[43]!==M||e[44]!==g?(O=r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8 text-foreground",children:r.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:M})}),e[43]=M,e[44]=g,e[45]=O):O=e[45],O}const Xg=/^[a-z]:[\\/]/i;function Kd(n){return(Xg.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function km(n){const e=Kd(n);return Xg.test(n)?e.toLowerCase():e}function iN(n){const e=Kd(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Cm(n,e){const t=km(n),s=km(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?Kd(e).slice(o.length):null}let qd=!1;function aN(n){qd=n}function Vd(){return qd}let sr=null;function lN(n){return sr=n,()=>{sr===n&&(sr=null)}}function cN(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=Cm(e,n.path);if(o)return{root:e,file:o,mode:_m(n),line:n.line}}const t=iN(n.path),s=Cm(t,n.path);return s?{root:t,file:s,mode:_m(n),line:n.line}:null}function _m(n){return n.mode==="diff"?"diff":"edit"}function Jg(n){return qd&&sr!==null&&sr(n)}function Qg(n,e){ve(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}function xr(n,e={}){if(ft("hostFiles")&&!Jg({kind:"file",path:n,...e})){if(Bs()){Dr(n);return}Qg("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function Zg(n){ft("hostFiles")&&(n.path&&Jg({kind:"project",path:n.path})||tx("/api/open-in-editor",n))}function ex(n){ft("hostFiles")&&tx("/api/reveal-in-folder",n)}function tx(n,e){!e.path&&!e.dirName||Qg(n,{path:e.path||void 0,dirName:e.dirName||void 0})}let Pl=null;const Oc=new Set,Ni=new Map,Tm=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],nx={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 sx(){return Pl||(Pl=(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),...Tm.map(o=>nx[o]().then(i=>i.default))]),s=await ww({themes:[n,e],langs:t,engine:jw()});for(const o of Tm)Oc.add(o);return s})()),Pl}async function ox(n,e){if(Oc.has(e))return;if(Ni.has(e))return Ni.get(e);const t=nx[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),Oc.add(e)}).finally(()=>Ni.delete(e));Ni.set(e,s),await s}const dN={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 rx(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return dN[e]??null}async function Gd(n,e,t){try{const s=await sx();await ox(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}function Vr(){const n=B.c(2),[e,t]=w.useState(uN);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]),w.useEffect(s,o),e}function uN(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}const fN={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 mN(n){return fN[n.toLowerCase()]??n}function pN(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function hN(n){const e=B.c(10),{text:t}=n,[s,o]=w.useState(!1),i=w.useRef(null),a=w.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]),w.useEffect(l,c);let d;e[2]!==t?(d=function(){const g=a.current=a.current+1;Dr(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 u=d,f=s?"Copied":"Copy code";let m;e[4]!==s?(m=s?r.jsxs(r.Fragment,{children:[r.jsx(gt,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(Rn,{"data-icon":"icon"}),e[4]=s,e[5]=m):m=e[5];let p;return e[6]!==u||e[7]!==f||e[8]!==m?(p=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:u,className:"text-muted-foreground",title:"Copy code","aria-label":f,children:m}),e[6]=u,e[7]=f,e[8]=m,e[9]=p):p=e[9],p}function gN(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 xN(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=pN(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 u=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 f;return e[12]!==u||e[13]!==l||e[14]!==o?(f=r.jsx(bN,{code:u,lang:l,...o}),e[12]=u,e[13]=l,e[14]=o,e[15]=f):f=e[15],f}function bN(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=Vr(),[a,l]=w.useState(null),[c,d]=w.useState(!1),u=t.split(`
8
+ `),f=u.length,m=f>30,p=s?`${s}\0${i?"dark":"light"}\0${t}`:null,h=(a==null?void 0:a.key)===p?a.lines:null;let g,x;e[4]!==t||e[5]!==p||e[6]!==i||e[7]!==s?(g=()=>{if(!s||!p)return;let T=!1;return Gd(t,s,i).then(E=>{T||l({key:p,lines:E})}),()=>{T=!0}},x=[t,s,i,p],e[4]=t,e[5]=p,e[6]=i,e[7]=s,e[8]=g,e[9]=x):(g=e[8],x=e[9]),w.useEffect(g,x);const b=c?Je:tt,y="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 S;e[14]!==s?(S=s&&r.jsx(Ce,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:mN(s)}),e[14]=s,e[15]=S):S=e[15];let j;e[16]!==m||e[17]!==f?(j=m&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[f," lines"]}),e[16]=m,e[17]=f,e[18]=j):j=e[18];let k;e[19]!==v||e[20]!==S||e[21]!==j?(k=r.jsxs("div",{className:"flex items-center gap-2",children:[v,S,j]}),e[19]=v,e[20]=S,e[21]=j,e[22]=k):k=e[22];let C;e[23]!==t?(C=r.jsx(hN,{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:G("block",!h&&"text-foreground/90"),...o,children:u.map((T,E)=>{const R=h==null?void 0:h[E];return r.jsxs("span",{className:"block",children:[r.jsx(gN,{num:E+1}),R?R.map(vN):T||" "]},E)})})})});let P;e[28]!==c||e[29]!==f?(P=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 ${f} lines of code`,children:["Show ",f," lines..."]}),e[28]=c,e[29]=f,e[30]=P):P=e[30];let A;return e[31]!==_||e[32]!==P||e[33]!==N?(A=r.jsxs("div",{className:y,children:[N,_,P]}),e[31]=_,e[32]=P,e[33]=N,e[34]=A):A=e[34],A}function vN(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var Ds=function(n,e){return Number(n.toFixed(e))},yN=function(n,e){return e},Qe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},wN=function(n){return-Math.cos(n*Math.PI)/2+.5},jN=function(n){return n},SN=function(n){return n*n},NN=function(n){return n*(2-n)},kN=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},CN=function(n){return n*n*n},_N=function(n){return--n*n*n+1},TN=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},EN=function(n){return n*n*n*n},PN=function(n){return 1- --n*n*n*n},AN=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},RN=function(n){return n*n*n*n*n},$N=function(n){return 1+--n*n*n*n*n},IN=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},ix={easeOut:wN,linear:jN,easeInQuad:SN,easeOutQuad:NN,easeInOutQuad:kN,easeInCubic:CN,easeOutCubic:_N,easeInOutCubic:TN,easeInQuart:EN,easeOutQuart:PN,easeInOutQuart:AN,easeInQuint:RN,easeOutQuint:$N,easeInOutQuint:IN},ax=function(n){typeof n=="number"&&cancelAnimationFrame(n)},Nn=function(n){n.mounted&&(ax(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function lx(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;Nn(n),n.animation=function(){if(!n.mounted)return ax(n.animation);var a=new Date().getTime()-o,l=a/t,c=ix[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function MN(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function As(n,e,t,s){var o=MN(e);if(!(!n.mounted||!o)){var i=n.setState,a=n.state,l=a.scale,c=a.positionX,d=a.positionY,u=e.scale-l,f=e.positionX-c,m=e.positionY-d;t===0?i(e.scale,e.positionX,e.positionY):lx(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+u*p,g=c+f*p,x=d+m*p;i(h,g,x)})}}function ON(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,u=o-c;return{wrapperWidth:s,wrapperHeight:o,newContentWidth:l,newDiffWidth:d,newContentHeight:c,newDiffHeight:u}}var DN=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,u=l,f=s-o-c,m=c;return{minPositionX:d,maxPositionX:u,minPositionY:f,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},Yd=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=ON(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,u=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=DN(c,u,m,d,f,p,!!i),g=c>=u&&d>=f;a&&g&&!i&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,b=x.minPositionX,y=x.maxPositionX,v=x.minPositionY,S=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),y!=null&&(h.maxPositionX=y*e),v!=null&&(h.minPositionY=d*(1-e)+v*e),S!=null&&(h.maxPositionY=S*e),h},br=function(n,e,t,s){return s?n<e?Ds(e,2):n>t?Ds(t,2):Ds(n,2):Ds(n,2)},_o=function(n,e){var t=Yd(n,e);return n.bounds=t,t};function Gr(n,e,t,s,o,i,a){var l=t.minPositionX,c=t.minPositionY,d=t.maxPositionX,u=t.maxPositionY,f=0,m=0;a&&(f=o,m=i);var p=br(n,l-f,d+f,s),h=br(e,c-m,u+m,s);return{x:p,y:h}}function Fa(n,e,t,s,o,i){var a=n.state,l=a.scale,c=a.positionX,d=a.positionY,u=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 f=c-e*u,m=d-t*u,p=Gr(f,m,o,i,0,0,null);return p}var Em=1e-7;function Yr(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,Em),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,Em)}var Pm=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(u){return u instanceof Element?o==null?void 0:o.contains(u):!1}):o==null?void 0:o.contains(i),c=s&&i&&l;if(!c)return!1;var d=Xr(i,t);return!(d||i.getAttribute("draggable")==="true"||i.getAttribute("contenteditable")==="true"||i.isContentEditable)},Am=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},LN=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}},zN=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 FN(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 u=n.bounds,f=u.maxPositionX,m=u.minPositionX,p=u.maxPositionY,h=u.minPositionY,g=t>f||t<m,x=s>p||s<h,b=t>f?d.offsetWidth:n.setup.minPositionX||0,y=s>p?d.offsetHeight:n.setup.minPositionY||0,v=Fa(n,b,y,o,n.bounds,l||c),S=v.x,j=v.y;return{scale:o,positionX:g?S:t,positionY:x?j:s}}}function cx(n,e,t,s,o){var i=n.setup.limitToBounds,a=n.wrapperComponent,l=n.bounds,c=n.state,d=c.scale,u=c.positionX,f=c.positionY;if(!(a===null||l===null||e===u&&t===f)){var m=Gr(e,t,l,i,s,o,a),p=m.x,h=m.y;n.setState(d,p,h)}}var BN=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 u=e-s.x,f=t-s.y,m=a?c:u,p=l?d:f;return{x:m,y:p}},_s=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},hs;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(hs||(hs={}));var UN=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 u=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return u},WN=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 HN(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 Rm(n,e,t,s,o,i,a,l,c,d){if(o){if(e>a&&t>a){var u=a+(n-a)*d;return u>c?c:u<a?a:u}if(e<i&&t<i){var u=i+(n-i)*d;return u<l?l:u>i?i:u}}return s?e:br(n,i,a,o)}function KN(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Al=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 qN(n,e,t){var s,o,i=UN(n);if(i){var a=n.lastMousePosition,l=n.velocityTime,c=n.setup,d=n.wrapperComponent,u=c.velocityAnimation,f=u.maxStrengthMouse,m=u.maxStrengthTouch,p=u.sensitivityTouch,h=u.sensitivityMouse,g=Date.now();if(a&&l&&d){var x=KN(d),b=(s={},s[hs.TOUCH]=p,s[hs.MOUSE]=h,s)[t],y=(o={},o[hs.TOUCH]=m,o[hs.MOUSE]=f,o)[t],v=e.x-a.x,S=e.y-a.y,j=Al(v/x,y,b),k=Al(S/x,y,b),C=g-l,N=v*v+S*S,_=Al(Math.sqrt(N)/C,y,b);n.velocity={velocityX:j,velocityY:k,total:_}}n.lastMousePosition=e,n.velocityTime=g}}function VN(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=WN(n);if(!(!i||!e||!t||!o)){var a=e.velocityX,l=e.velocityY,c=e.total,d=t.maxPositionX,u=t.minPositionX,f=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,b=x.lockAxisY,y=x.lockAxisX,v=g.animationType,S=h.sizeX,j=h.sizeY,k=h.velocityAlignmentTime,C=k,N=HN(n,c),_=Math.max(N,C),P=_s(n,S),A=_s(n,j),T=P*o.offsetWidth/100,E=A*o.offsetHeight/100,R=d+T,I=u-T,$=f+E,M=m-E,O=n.state,D=new Date().getTime();lx(n,v,_,function(L){var F=n.state,z=F.scale,W=F.positionX,U=F.positionY,H=new Date().getTime()-D,K=H/C,q=ix[h.animationType],Y=1-q(Math.min(1,K)),V=1-L,J=W+a*V,Q=U+l*V,X=Rm(J,O.positionX,W,y,p,u,d,I,R,Y),Z=Rm(Q,O.positionY,U,b,p,m,f,M,$,Y);if(W!==J||U!==Q){n.setState(z,X,Z);var te=n.props.onPanning;te&&te(Xe(n),{})}})}}function $m(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},Nn(n),_o(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?zN(n,e):LN(n,e)}function dx(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,u=i.animationType,f=a||t<o||!l&&!c;if(!f){var m=FN(n);m&&As(n,m,d,u)}}function Im(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=BN(n,e,t),u=d.x,f=d.y,m=_s(n,l),p=_s(n,c);qN(n,{x:u,y:f},s),cx(n,u,f,m,p)}}function GN(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 u=a-d.x,f=l-d.y;if(u*u+f*f<=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?VN(n):dx(n)}}function Xd(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=Yr(Ds(e,2),i,a,0,!1),d=_o(n,c),u=Fa(n,t,s,c,d,l),f=u.x,m=u.y;return{scale:c,positionX:f,positionY:m}}function Jd(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,u=d.disabled,f=d.animationTime,m=d.animationType,p=s>=a&&s<=l,h=u||p;if((s>=1||c)&&dx(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,b=s<a?a:l,y=Xd(n,b,g,x);y&&As(n,y,f,m)}}var gn=function(){return gn=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},gn.apply(this,arguments)};function Mm(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 Rl={scale:1,positionX:0,positionY:0},Os={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"}},Dc={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},ux=function(n){var e,t,s,o,i,a,l,c,d,u=Math.max((e=n.minScale)!==null&&e!==void 0?e:Os.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:Os.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:Rl.scale,p=Math.min(Math.max(m,u),f),h=br((o=n.initialPositionX)!==null&&o!==void 0?o:Rl.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=br((l=n.initialPositionY)!==null&&l!==void 0?l:Rl.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}},Om=function(n){var e=gn({},Os);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof Os[s]<"u";if(i&&o){var a=Object.prototype.toString.call(Os[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=gn(gn({},Os[s]),n[s]):c?e[s]=Mm(Mm([],Os[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},fx=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,u=c.size;if(!o)throw new Error("Wrapper is not mounted");var f=d?s*Math.exp(e*t):s+e*t,m=Yr(Ds(f,3),l,a,u,!1);return m};function mx(n,e,t,s,o){var i,a,l=n.wrapperComponent,c=n.state,d=c.scale,u=c.positionX,f=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-u)/d,b=(g/2-f)/d,y=fx(n,e,t),v=Xd(n,y,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var S=n.props,j=S.onZoomStart,k=S.onZoom,C=S.onZoomStop,N=new MouseEvent("mousemove",{bubbles:!0}),_=Xe(n);Qe(_,N,j),Qe(_,N,k),As(n,v,p,o);var P=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;P&&P.setTimeout(function(){n.mounted&&Qe(Xe(n),N,C)},p)}function px(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,u=a.centerOnInit,f=ux(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,b=f.positionY;if(u&&c){var y=Qd(f.scale,l,c);x=y.positionX,b=y.positionY}var v=Yd(n,f.scale),S=Gr(x,b,v,d,0,0,l),j={scale:f.scale,positionX:S.x,positionY:S.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var k=n.props,C=k.onZoomStart,N=k.onZoom,_=k.onZoomStop,P=new MouseEvent("mousemove",{bubbles:!0}),A=Xe(n);Qe(A,P,C),Qe(A,P,N),As(n,j,e,t);var T=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;T&&T.setTimeout(function(){n.mounted&&Qe(Xe(n),P,_)},e)}}}function YN(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 XN(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,u=c.minScale,f=c.maxScale;if(!i||!a)return l;var m=i.getBoundingClientRect(),p=e.getBoundingClientRect(),h=YN(e,i,a,l),g=h.x,x=h.y,b=p.width/l.scale,y=p.height/l.scale,v=i.offsetWidth/b,S=i.offsetHeight/y,j=Yr(t||Math.min(v,S),u,f,0,!1),k=(m.width-b*j)/2,C=(m.height-y*j)/2,N=(m.left-g)*j+k+s,_=(m.top-x)*j+C+o,P=Yd(n,j),A=Gr(N,_,P,d,0,0,i),T=A.x,E=A.y;return{positionX:T,positionY:E,scale:j}}var JN=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),mx(n,1,e,t,s)}},QN=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),mx(n,-1,e,t,s)}},ZN=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,u=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!u||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?d:s};As(n,p,o,i)}}},ek=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),px(n,e,t)}},tk=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=Qd(e||o.scale,i,a);As(n,l,t,s)}}},nk=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),Nn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=XN(n,c,t,i,a);As(n,d,s,o)}}},Lc=function(n){return{instance:n,state:n.state,zoomIn:JN(n),zoomOut:QN(n),setTransform:ZN(n),resetTransform:ek(n),centerView:tk(n),zoomToElement:nk(n)}},sk=function(n){return{instance:n,state:n.state}},Xe=function(n){var e={};return Object.assign(e,sk(n)),Object.assign(e,Lc(n)),e},$l=!1;function Il(){try{var n={get passive(){return $l=!0,!1}};return n}catch{return $l=!1,$l}}var ki=".".concat(Dc.wrapperClass),Xr=function(n,e){return e.some(function(t){return n.matches("".concat(ki," ").concat(t,", ").concat(ki," .").concat(t,", ").concat(ki," ").concat(t," *, ").concat(ki," .").concat(t," *"))})},vr=function(n){n&&clearTimeout(n)},ok=function(n){return Number.parseFloat(n.toFixed(8))},hx=function(n,e,t){var s=ok(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},Qd=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 rk(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function ik(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var gx=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,u=l&&!c&&!s&&d;if(!u||o&&!e.ctrlKey||i&&e.ctrlKey)return!1;var f=Xr(d,a);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},ak=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=gx(n,e);if(l)return!1;var c=e.target,d=Xr(c,a);if(d)return!1;var u=n.isPressingKeys(i);return!!u},lk=function(n){return n?n.deltaY<0?1:-1:0};function ck(n,e){var t=lk(n),s=yN(e,t);return s}function xx(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 dk=function(n,e,t,s,o){var i=n.state.scale,a=n.wrapperComponent,l=n.setup,c=l.maxScale,d=l.minScale,u=l.zoomAnimation,f=l.disablePadding,m=u.size,p=u.disabled;if(!a)throw new Error("Wrapper is not mounted");var h=i+e*t,g=s?!1:!p,x=Yr(h,d,c,m,g&&!f);return x},bx=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},uk=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=Xr(a,o);return!c},fk=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},mk=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}},vx=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))},pk=5,hk=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,u=l.size,f=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/pk),x=t+g,b=x===1/0?0:Ds(x,10);return Yr(b,a,i,u,!f&&!c)},yx=160,wx=100,gk=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(Nn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},xk=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,u=a.centerZoomedOut,f=a.zoomAnimation,m=a.wheel,p=a.disablePadding,h=a.smooth,g=f.size,x=f.disabled,b=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var y=ck(e,null),v=h?b*Math.abs(e.deltaY):b,S=dk(n,y,v,!e.ctrlKey);if(c!==S){var j=_o(n,S),k=xx(e,i,c),C=x||g===0||u||p,N=d&&C,_=Fa(n,k.x,k.y,S,j,N),P=_.x,A=_.y;n.previousWheelEvent=e,n.setState(S,P,A),Qe(Xe(n),e,s),Qe(Xe(n),e,o)}},bk=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;vr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Jd(n,e.x,e.y),n.wheelAnimationTimer=null)},wx);var i=bx(n,e);i&&(vr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},yx))},vk=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(Nn(n),Qe(Xe(n),e,s),Qe(Xe(n),e,o))},yk=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;vr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Jd(n,e.x,e.y),n.wheelAnimationTimer=null)},wx);var i=bx(n,e);i&&(vr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Qe(Xe(n),e,s),Qe(Xe(n),e,o))},yx))},jx=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}},wk=function(n,e){var t=vx(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=jx(e),Nn(n)},jk=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,u=l.zoomAnimation,f=l.autoAlignment,m=l.pinch,p=l.panning,h=u.disabled,g=u.size,x=m.allowPanning;if(!(s===null||!t)){var b=mk(e,a,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var y=vx(e),v=hk(n,y),S=jx(e),j=a/v,k=(S.x-((i==null?void 0:i.x)||0))*j,C=(S.y-((i==null?void 0:i.y)||0))*j;if(!(v===a&&k===0&&C===0)){n.pinchPreviousCenter=S;var N=_o(n,v),_=h||g===0||d,P=c&&_,A=Fa(n,b.x,b.y,v,N,P),T=A.x,E=A.y;if(n.pinchMidpoint=b,n.lastDistance=y,p.disabled||!x)n.setState(v,T,E);else{var R=f.sizeX,I=f.sizeY,$=_s(n,R,v),M=_s(n,I,v),O=T+k,D=E+C,L=Gr(O,D,N,c,$,M,o),F=L.x,z=L.y;n.setState(v,F,z)}}}}},Sk=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,Jd(n,e==null?void 0:e.x,e==null?void 0:e.y)},Sx=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;vr(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Qe(Xe(n),e,t)},s)},Nk=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),px(n,a,l,function(){return Qe(Xe(n),e,o)}),Sx(n,e)};function kk(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function Ck(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,u=t.doubleClick,f=u.disabled,m=u.mode,p=u.step,h=u.animationTime,g=u.animationType;if(!f&&!s){if(m==="reset")return Nk(n,e);if(!i)return console.error("No ContentComponent found");var x=kk(m,n.state.scale),b=fx(n,x,p);if(a!==b){Qe(Xe(n),e,c);var y=xx(e,i,a),v=Xd(n,b,y.x,y.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");Qe(Xe(n),e,d),As(n,v,h,g),Sx(n,e)}}}var _k=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),u=t&&c&&d&&!a;if(!u)return!1;var f=Xr(c,l);return!f},Tk=(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&&_o(t,t.state.scale),t.setup=Om(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=Il(),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=Il(),d=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,u=d==null?void 0:d.defaultView;u==null||u.removeEventListener("mousedown",t.onPanningStart,c),u==null||u.removeEventListener("mousemove",t.onPanning,c),u==null||u.removeEventListener("mouseup",t.onPanningStop,c),d==null||d.removeEventListener("mouseleave",t.clearPanning,c),u==null||u.removeEventListener("keyup",t.setKeyUnPressed,c),u==null||u.removeEventListener("keydown",t.setKeyPressed,c),u==null||u.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),Nn(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=Il();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=gx(t,s);i&&(gk(t,s),xk(t,s),bk(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=ak(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var d=t.state,u=d.positionX,f=d.positionY,m=u-s.deltaX,p=f-s.deltaY,h=a?u:m,g=l?f:p,x=t.setup.autoAlignment,b=x.sizeX,y=x.sizeY,v=_s(t,b),S=_s(t,y);h===u&&g===f||(vk(t,s),cx(t,h,g,v,S),Qe(Xe(t),s,o),yk(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=Pm(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(),Nn(t),$m(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=Am(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Im(t,s.clientX,s.clientY,hs.MOUSE),Qe(Xe(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(GN(t,o),Qe(Xe(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=uk(t,s);a&&(wk(t,s),Nn(t),Qe(Xe(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=fk(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),jk(t,s),Qe(Xe(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(Sk(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,Nn(t);var u=s.touches,f=u.length===1,m=u.length===2,p=Pm(t,s);if(f){if(!p)return;Nn(t),$m(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=Am(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Im(t,l.clientX,l.clientY,hs.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=_k(t,s);i&&Ck(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=Qd(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):hx(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,_o(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),rk(t.props.ref,i)},this.props=e,this.setup=Om(this.props),this.state=ux(this.props)}return n})(),Ba=ye.createContext(null),Ek=function(n,e){return typeof n=="function"?n(e):n},Pk=ye.forwardRef(function(n,e){var t=w.useRef(new Tk(n)).current,s=Ek(n.children,Lc(t));return w.useImperativeHandle(e,function(){return Lc(t)},[t]),w.useEffect(function(){t.update(n)},[t,n]),r.jsx(Ba.Provider,gn({value:t},{children:s}))});ye.forwardRef(function(n,e){var t=w.useRef(null),s=w.useContext(Ba);return w.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",gn({},n,{ref:ik([t,e])}))});function Ak(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 Rk=`.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
+ `,Ml={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};Ak(Rk);var $k=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,u=n.contentProps,f=u===void 0?{}:u,m=n.infinite,p=m===void 0?!1:m,h=w.useContext(Ba),g=h.init,x=h.cleanupWindowEvents,b=w.useRef(null),y=w.useRef(null),v=w.useRef(null);return w.useEffect(function(){var S=b.current,j=y.current;return S!==null&&j!==null&&g&&(g==null||g(S,j)),function(){x==null||x()}},[]),w.useEffect(function(){if(p){var S=v.current;if(S){var j=function(){var k=h.state,C=k.positionX,N=k.positionY;S.style.backgroundPosition="".concat(C,"px ").concat(N,"px")};return j(),h.onChange(j)}}},[p,h]),r.jsxs("div",gn({},d,{ref:b,className:"".concat(Dc.wrapperClass," ").concat(Ml.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:v,className:Ml.infiniteGrid,"aria-hidden":!0}),r.jsx("div",gn({},f,{ref:y,className:"".concat(Dc.contentClass," ").concat(Ml.content," ").concat(i),style:gn(gn({},l),{transform:hx(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function Ik(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 Mk(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,u=n.margin,f=u===void 0?0:u,m=n.threshold,p=m===void 0?0:m,h={x:-f,y:-f,width:c+2*f,height:d+2*f},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 y=g.width*g.height;if(y<=0)return!1;var v=Ik(h,g);return v/y>=p}ye.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,u=n.placeholder,f=u===void 0?null:u,m=n.onShow,p=n.onHide,h=n.children,g=n.className,x=n.style,b=w.useContext(Ba),y=w.useState(!1),v=y[0],S=y[1],j=w.useRef(!1),k=w.useRef(m),C=w.useRef(p);return k.current=m,C.current=p,w.useEffect(function(){var N=function(){var A,T,E=b.wrapperComponent;if(E){var R=Mk({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:b.state.scale,positionX:b.state.positionX,positionY:b.state.positionY,viewportWidth:E.offsetWidth,viewportHeight:E.offsetHeight,margin:l,threshold:d});R!==j.current&&(j.current=R,S(R),R?(A=k.current)===null||A===void 0||A.call(k):(T=C.current)===null||T===void 0||T.call(C))}};N();var _=b.onChange(N),P;return b.wrapperComponent||(P=b.onInit(function(){return N()})),function(){_(),P==null||P()}},[b,t,s,o,i,l,d]),v?r.jsx("div",gn({ref:e,className:g,style:x},{children:h})):f?r.jsx(r.Fragment,{children:f}):null});const Dm=8,Ok=56;function Uo(n){const e=B.c(8),{label:t,disabled:s,onClick:o,children:i,className:a}=n;let l;e[0]!==a?(l=G("size-8 border border-white/10 bg-white/[0.06] text-white/75","hover:bg-white/10 hover:text-white focus-visible:ring-white/40","disabled:pointer-events-none disabled:opacity-30",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==i||e[3]!==s||e[4]!==t||e[5]!==o||e[6]!==l?(c=r.jsx(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 Zd(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,u]=w.useState(c),[f,m]=w.useState(100),p=w.useRef(null),h=w.useRef(null),g=s[d];let x;e[0]!==s.length?(x=pe=>{u(Math.min(Math.max(pe,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const b=x;let y;e[2]!==b||e[3]!==d?(y=()=>b(d-1),e[2]=b,e[3]=d,e[4]=y):y=e[4];const v=y;let S;e[5]!==b||e[6]!==d?(S=()=>b(d+1),e[5]=b,e[6]=d,e[7]=S):S=e[7];const j=S;if(!g)return null;const k=s.length>1,C=d>0,N=d<s.length-1,_=f>100;let P;e[8]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var pe;return(pe=p.current)==null?void 0:pe.zoomIn()},e[8]=P):P=e[8];const A=P;let T;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{var pe;return(pe=p.current)==null?void 0:pe.zoomOut()},e[9]=T):T=e[9];const E=T;let R;e[10]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{var pe;return(pe=p.current)==null?void 0:pe.resetTransform()},e[10]=R):R=e[10];const I=R;let $;e[11]!==N||e[12]!==C||e[13]!==j||e[14]!==v?($=pe=>{pe.key==="ArrowLeft"&&C?(pe.preventDefault(),v()):pe.key==="ArrowRight"&&N?(pe.preventDefault(),j()):pe.key==="+"||pe.key==="="?(pe.preventDefault(),A()):pe.key==="-"?(pe.preventDefault(),E()):pe.key==="0"&&(pe.preventDefault(),I())},e[11]=N,e[12]=C,e[13]=j,e[14]=v,e[15]=$):$=e[15];const M=$;let O;e[16]===Symbol.for("react.memo_cache_sentinel")?(O=pe=>{if(pe.pointerType==="mouse"||pe.isPrimary===!1){h.current=null;return}h.current={x:pe.clientX,y:pe.clientY}},e[16]=O):O=e[16];const D=O;let L;e[17]!==N||e[18]!==C||e[19]!==j||e[20]!==v?(L=pe=>{var xe;const Oe=h.current;h.current=null;const Ae=((xe=p.current)==null?void 0:xe.instance.state.scale)??1;if(!Oe||Ae>1.01)return;const Be=pe.clientX-Oe.x,ie=pe.clientY-Oe.y;Math.abs(Be)<Ok||Math.abs(Be)<Math.abs(ie)||(Be>0&&C&&v(),Be<0&&N&&j())},e[17]=N,e[18]=C,e[19]=j,e[20]=v,e[21]=L):L=e[21];const F=L;let z;e[22]!==i?(z=pe=>{pe||i()},e[22]=i,e[23]=z):z=e[23];let W;e[24]!==a?(W=pe=>{pe||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=G("flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden rounded-xl border-white/10 bg-black p-0 text-white","sm:h-[min(820px,calc(100dvh-2rem))] sm:w-[min(1120px,calc(100vw-2rem))] sm:max-w-none"),H=r.jsx(as,{className:"sr-only",children:"Image viewer"}),K=r.jsx(ls,{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(v3,{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 V;e[30]!==Y?(V=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:Y}),e[30]=Y,e[31]=V):V=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]!==V||e[37]!==J?(Q=r.jsxs("div",{className:"min-w-0 flex-1",children:[V,J]}),e[36]=V,e[37]=J,e[38]=Q):Q=e[38];const X=f<=100;let Z;e[39]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(S1,{className:"size-3.5","data-icon":"icon"}),e[39]=Z):Z=e[39];let te;e[40]!==X?(te=r.jsx(Uo,{label:"Zoom out",disabled:X,onClick:E,children:Z}),e[40]=X,e[41]=te):te=e[41];let ne;e[42]!==f?(ne=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:I,className:"min-w-12 px-1.5 font-mono text-xs tabular-nums text-white/60 hover:bg-white/[0.06] hover:text-white","aria-label":"Reset zoom",title:"Reset zoom",children:[f,"%"]}),e[42]=f,e[43]=ne):ne=e[43];const oe=f>=Dm*100;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(Bn,{className:"size-3.5","data-icon":"icon"}),e[44]=re):re=e[44];let ae;e[45]!==oe?(ae=r.jsx(Uo,{label:"Zoom in",disabled:oe,onClick:A,children:re}),e[45]=oe,e[46]=ae):ae=e[46];let se;e[47]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx("div",{className:"mx-1 h-5 w-px bg-white/10"}),e[47]=se):se=e[47];let fe;e[48]===Symbol.for("react.memo_cache_sentinel")?(fe=r.jsx(st,{className:"size-4","data-icon":"icon"}),e[48]=fe):fe=e[48];let le;e[49]!==i?(le=r.jsx(Uo,{label:"Close image viewer",onClick:i,children:fe}),e[49]=i,e[50]=le):le=e[50];let ce;e[51]!==te||e[52]!==ne||e[53]!==ae||e[54]!==le?(ce=r.jsxs("div",{className:"flex items-center gap-1",children:[te,ne,ae,se,le]}),e[51]=te,e[52]=ne,e[53]=ae,e[54]=le,e[55]=ce):ce=e[55];let me;e[56]!==Q||e[57]!==ce?(me=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,ce]}),e[56]=Q,e[57]=ce,e[58]=me):me=e[58];const ue=g.id;let de,be,ge;e[59]===Symbol.for("react.memo_cache_sentinel")?(de={mode:"toggle"},be={step:.005},ge=(pe,Oe)=>m(Math.round(Oe.scale*100)),e[59]=de,e[60]=be,e[61]=ge):(de=e[59],be=e[60],ge=e[61]);let he,je;e[62]===Symbol.for("react.memo_cache_sentinel")?(he={width:"100%",height:"100%"},je={width:"100%",height:"100%"},e[62]=he,e[63]=je):(he=e[62],je=e[63]);const Se=g.src,Pe=g.alt,Re=_?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let $e;e[64]!==Re?($e=G("max-h-full max-w-full select-none object-contain",Re),e[64]=Re,e[65]=$e):$e=e[65];let De;e[66]!==g.alt||e[67]!==g.src||e[68]!==$e?(De=r.jsx($k,{wrapperStyle:he,contentStyle:je,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:Se,alt:Pe,draggable:!1,className:$e})}),e[66]=g.alt,e[67]=g.src,e[68]=$e,e[69]=De):De=e[69];let Le;e[70]!==g.id||e[71]!==De?(Le=r.jsx(Pk,{ref:p,minScale:1,maxScale:Dm,centerOnInit:!0,centerZoomedOut:!0,doubleClick:de,wheel:be,onTransform:ge,children:De},ue),e[70]=g.id,e[71]=De,e[72]=Le):Le=e[72];let ze;e[73]!==N||e[74]!==C||e[75]!==j||e[76]!==v||e[77]!==k?(ze=k&&r.jsxs(r.Fragment,{children:[r.jsx(Uo,{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(bd,{className:"size-5","data-icon":"icon"})}),r.jsx(Uo,{label:"Next image",disabled:!N,onClick:j,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]=j,e[76]=v,e[77]=k,e[78]=ze):ze=e[78];let Te;e[79]!==f?(Te=f===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(ya,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=f,e[80]=Te):Te=e[80];let _e;e[81]!==F||e[82]!==Le||e[83]!==ze||e[84]!==Te?(_e=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:D,onPointerUp:F,children:[Le,ze,Te]}),e[81]=F,e[82]=Le,e[83]=ze,e[84]=Te,e[85]=_e):_e=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((pe,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:G("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",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:pe.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})]},`${pe.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]!==me||e[93]!==_e||e[94]!==We?(Fe=r.jsxs(is,{showCloseButton:!1,onKeyDown:M,className:U,children:[H,K,me,_e,We]}),e[91]=M,e[92]=me,e[93]=_e,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(rs,{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 zc(n){return n.type==="user"}function eu(n){return n.type==="assistant"}function Lm(n){return n.type==="progress"}function zm(n){return n.type==="system"}function Nx(n){return n.type==="summary"}function Dk(n){return n.type==="queue-operation"}function kx(n){return n.type==="attachment"}function Lk(n){return n.type==="user"&&n.isCompactSummary===!0}function Cx(n){return n.type==="system"&&n.subtype==="compact_boundary"}function Fm(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function Bm(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 Ua(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function Wa(n){const e=Ua(n.length);for(const t of n){t.tokenUsage&&Bm(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=Fm(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=Fm(s.toolCalls,e.toolCallCounts),s.tokenUsage&&Bm(e,s.tokenUsage)}return e}const zk=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,Fk=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function Bk(n){for(const e of Fk){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 Uk(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function yr(n){let e=null,t=!1;const s=n.replace(zk,(o,i,a,l)=>(t=!0,e===null&&(e=Bk(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const Wk=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],Hk=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],Kk=200,qk=/\bhttps?:\/\/\S+/g;function Vk(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,Kk).toLowerCase();if(Wk.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
52
+ `)+1).slice(-200).replace(qk,"").toLowerCase();return o.includes("?")||Hk.some(i=>i.test(o))}function Ha(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
53
+ `)}function Um(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
54
+ `):""}function _x(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 Gk=/<task-notification>[\s\S]*?<\/task-notification>/g,Yk=/<[^>]*>/g;function Xk(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=Ha(n.message.content);return e.includes("<task-notification>")?e.replace(Gk,"").replace(Yk,"").trim()==="":!1}function Jk(n){if(!kx(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:Ha(t);if(!_x(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??yr(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=yr(s);return{raw:s,sender:i.sender,body:i.body}}const Qk=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function Zk(n,e){let t=n;for(const[s,o]of Qk){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return t}function eC(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 tC=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,nC=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function sC(n){return Ha(n).trim().replace(tC,"").replace(nC,"").trim()}function oC(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function Ci(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 rC(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=[],u=s.toolCalls.slice(o+1),f=u.findIndex(m=>m.name==="ExitPlanMode");if(f!==-1){d.push(...u.slice(0,f));const m=u[f],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=u.slice(f+1);g.length>0&&e.push({kind:"tool_calls",toolCalls:g,timestamp:s.timestamp}),t++;continue}else{d.push(...u);let m,p,h="pending",g=t+1;const x=[];for(;g<n.length;){const b=n[g];if(b.kind==="tool_calls"){const y=b.toolCalls.findIndex(v=>v.name==="ExitPlanMode");if(y!==-1){d.push(...b.toolCalls.slice(0,y)),m=b.toolCalls[y],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const v=b.toolCalls.slice(y+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 iC(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 tu(n){var s;const e=n.map(iC),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 aC(n){const e=[];let t=!1;for(let s=0;s<n.length;s++){const o=n[s];if(Nx(o)||Cx(o)){t=!1;continue}if(zc(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}eu(o)&&!t&&(e.push(s),t=!0)}return e}function Tx(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,u=new Set,f=new Map,m=new Map,p=new Set,h=new Map,g=[],x=new Map;function b(N,_){let P=x.get(N);P||(P=new Map,x.set(N,P)),P.set(_,(P.get(_)??0)+1)}function y(N,_){const P=x.get(N),A=P==null?void 0:P.get(_);return!P||!A?!1:(A===1?P.delete(_):P.set(_,A-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 S(N){if(!i)return;const _=f.get(N);if(!_||_.length===0)return;i.subAgentActivity.push(..._),f.delete(N);const P=p.has(N)?"background_agent":"sub_agent",A=m.get(N);if(A)A.messages.push(..._);else{const T={kind:P,messages:[..._]};i.contentBlocks.push(T),m.set(N,T)}}function j(){if(i){for(const N of i.toolCalls)S(N.id);for(const[N]of f)S(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 A=i.toolCalls.find(T=>T.id===_.toolUseId);A&&(_.updatedToolOutput&&(A.outputReplacedByHook=!0),_.durationMs!==void 0&&(A.hookDurationMs=(A.hookDurationMs??0)+_.durationMs))}i.contentBlocks=rC(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(Nx(N)){j(),a={summary:N.summary};continue}if(Cx(N)){j(),a={meta:oC(N.compactMetadata)};continue}if(Lk(N)){j(),s=o,i=Ci(N,null),i.compactionSummary=sC(N.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(zm(N)&&N.subtype==="away_summary"&&N.content){c={content:N.content,timestamp:N.timestamp};continue}if(Dk(N)){if(i&&N.operation==="enqueue"&&_x(N.content)){const _=yr(N.content);g.push({turn:i,content:N.content,timestamp:N.timestamp,sender:_.sender,body:_.body}),b(i,N.content)}continue}if(kx(N)){const _=Jk(N);i&&_!==null&&!y(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 _=zc(N)&&!N.isMeta?N.message.content:null;if(typeof _=="string"){const P=g.findIndex(A=>A.content===_);if(P>=0){const[A]=g.splice(P,1);y(A.turn,A.content)}}v()}if(zc(N)&&!N.isMeta){const _=N.message.content;if(typeof _!="string"&&Array.isArray(_)&&_.some(A=>A.type==="tool_result")&&i){for(const T of _)if(T.type==="tool_result"){const E=d.get(T.tool_use_id);E&&(E.turn.toolCalls[E.index].result=Um(T.content),E.turn.toolCalls[E.index].isError=T.is_error===!0,d.delete(T.tool_use_id))}const A=N.toolUseResult;if(A!=null&&A.agentId){const T=((C=_.find(O=>O.type==="tool_result"))==null?void 0:C.tool_use_id)??"",E=h.get(T),R=p.has(T),I=[];if(Array.isArray(A.content))for(const O of A.content)O.type==="text"&&I.push(O.text);const $={agentId:A.agentId,parentToolUseId:T||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:"assistant",content:A.content,toolCalls:[],thinking:[],text:I,timestamp:N.timestamp??"",tokenUsage:A.usage?{input_tokens:A.usage.input_tokens??0,output_tokens:A.usage.output_tokens??0,cache_creation_input_tokens:A.usage.cache_creation_input_tokens??0,cache_read_input_tokens:A.usage.cache_read_input_tokens??0}:null,model:null,isBackground:R,prompt:A.prompt,status:A.status,durationMs:A.totalDurationMs,toolUseCount:A.totalToolUseCount};if(!m.get(T)){i.subAgentActivity.push($);const D={kind:R?"background_agent":"sub_agent",messages:[$]};i.contentBlocks.push(D),m.set(T,D)}}continue}if(Xk(N)){const P={kind:"task_notification",content:Ha(_),timestamp:N.timestamp};if(i){i.contentBlocks.push(P);continue}s=o,i=Ci(N,null),i.contentBlocks.push(P),l(i);continue}j(),s=o,i=Ci(N,N.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(eu(N)){let _=function(){R.length>0&&(I.contentBlocks.push({kind:"tool_calls",toolCalls:[...R],timestamp:T}),R.length=0)},P=function(){if(E.length>0){const $=I.contentBlocks[I.contentBlocks.length-1];$&&$.kind==="thinking"?$.blocks.push(...E):I.contentBlocks.push({kind:"thinking",blocks:[...E],timestamp:T}),E.length=0}};i||(s=o,i=Ci(N,null),l(i)),i.model=N.message.model,N.effort&&(i.effort=N.effort),i.attribution=Zk(i.attribution,N);const A=N.message.id;u.has(A)||(u.add(A),i.tokenUsage=eC(i.tokenUsage,N.message.usage));const T=N.timestamp??"",E=[],R=[],I=i;for(const $ of N.message.content)if($.type==="thinking"){_();const M=$;if(!M.thinking)continue;i.thinking.push(M),E.push(M)}else if($.type==="text"){_(),P();const M=/<thinking>([\s\S]*?)<\/thinking>/g;let O=$.text,D;for(;(D=M.exec($.text))!==null;){const L=D[1].trim();if(L){const F={type:"thinking",thinking:L,signature:""};i.thinking.push(F),i.contentBlocks.push({kind:"thinking",blocks:[F],timestamp:T})}O=O.replace(D[0],"")}if(O=O.trim(),O){i.assistantText.push(O);const L=i.contentBlocks[i.contentBlocks.length-1];L&&L.kind==="text"?L.text.push(O):i.contentBlocks.push({kind:"text",text:[O],timestamp:T})}}else if($.type==="tool_use"){P();const M={id:$.id,name:$.name,input:$.input,result:null,isError:!1,timestamp:N.timestamp??""},O=i.toolCalls.length;if(i.toolCalls.push(M),R.push(M),d.set($.id,{turn:i,index:O}),$.name==="Task"||$.name==="Agent"){const D=$.input;D.run_in_background===!0&&p.add($.id),h.set($.id,{name:D.name??null,subagentType:D.subagent_type??null})}}P(),_();continue}if(Lm(N)&&N.data.type==="agent_progress"){const _=N.data,P=N.parentToolUseID??"";let A=null;if(_.message.type==="assistant"){const $=_.message.message,M=$.id,O=$.usage;O&&M&&!u.has(M)&&(u.add(M),A={input_tokens:O.input_tokens??0,output_tokens:O.output_tokens??0,cache_creation_input_tokens:O.cache_creation_input_tokens??0,cache_read_input_tokens:O.cache_read_input_tokens??0})}const T=_.message.type==="assistant"?_.message.message.model??null:null,E=h.get(P),R={agentId:_.agentId,parentToolUseId:P||void 0,agentName:(E==null?void 0:E.name)??null,subagentType:(E==null?void 0:E.subagentType)??null,type:_.message.type,content:_.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:_.message.timestamp??N.timestamp??"",tokenUsage:A,model:T,isBackground:p.has(P)};if(_.message.type==="assistant"){const $=_.message.message.content;if(Array.isArray($))for(const M of $)M.type==="thinking"?R.thinking.push(M.thinking):M.type==="text"?R.text.push(M.text):M.type==="tool_use"&&R.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 $=_.message.message.content;if(Array.isArray($)){for(const M of $)if(M.type==="tool_result"){const O=f.get(P);if(O)for(const D of O){const L=D.toolCalls.find(F=>F.id===M.tool_use_id);L&&(L.result=Um(M.content),L.isError=M.is_error===!0)}}}}let I=f.get(P);I||(I=[],f.set(P,I)),I.push(R),i&&S(P);continue}if(Lm(N)&&N.data.type==="hook_progress"){const _=N.data,P=String(_.hook_event_name??_.hookEvent??"unknown"),A=_.hookSpecificOutput,T={eventName:P,source:_.source!==void 0?String(_.source):void 0,toolName:_.tool_name!==void 0?String(_.tool_name):void 0,toolUseId:_.tool_use_id!==void 0?String(_.tool_use_id):void 0,command:_.command!==void 0?String(_.command):void 0,output:_.output!==void 0?String(_.output):void 0,stderr:_.stderr!==void 0?String(_.stderr):void 0,exitCode:_.exit_code!==void 0?Number(_.exit_code):void 0,decision:_.decision!==void 0?String(_.decision):void 0,durationMs:_.duration_ms!==void 0?Number(_.duration_ms):void 0,updatedToolOutput:(A==null?void 0:A.updatedToolOutput)!==void 0?String(A.updatedToolOutput):void 0,sessionTitle:(A==null?void 0:A.sessionTitle)!==void 0?String(A.sessionTitle):void 0,worktreePath:(A==null?void 0:A.worktreePath)!==void 0?String(A.worktreePath):void 0,timestamp:N.timestamp??""};if(i){const E=i.contentBlocks[i.contentBlocks.length-1];E&&E.kind==="hook_event"?E.events.push(T):i.contentBlocks.push({kind:"hook_event",events:[T],timestamp:N.timestamp})}continue}if(zm(N)&&N.subtype==="turn_duration"&&i){N.durationMs!==void 0&&N.durationMs!==null&&(i.durationMs=(i.durationMs??0)+N.durationMs);continue}}return v(),j(),{turns:tu(e),turnStartIndices:t}}function Ex(n){return Tx(n).turns}function Wm(){return!0}function Px(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function Ax(n){return Px(n.split(`
55
+ `))}function Rx(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),eu(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 lC(n){return Rx(Px(n))}function cC(n,e){const t=Ax(n),s=Rx(t),o=Ex(t),i=e!=null&&e.skipStats?Ua(o.length):Wa(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function dC(n,e){const t=Ax(e);if(t.length===0)return n;const s=n.rawMessages,o=[...s,...t],i=aC(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,u=n.turns.slice(0,a+l),f=Ex(o.slice(d)),m=tu([...u,...f]),p=Wa(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 $x="<task-notification>",uC=/<task-id>([^<]+)<\/task-id>/g,fC=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Dn(n){return typeof n=="object"&&n!==null}function mC(n){const e=Dn(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Dn(s)&&typeof s.text=="string").map(s=>s.text):[]}function pC(n){const e=[],t=new Set,s=new Set,o=new Set;function i(a,l){if(a.includes($x)){for(const c of a.matchAll(uC))t.add(c[1]),l==null||l.add(c[1]);for(const c of a.matchAll(fC))t.add(c[1]),l==null||l.add(c[1])}}for(const a of n){if(a.type==="user"){const l=Dn(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Dn(a.message)?a.message:null,u=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Dn(p)&&p.type==="tool_result").map(p=>p.tool_use_id),f=[l.agentId,l.taskId,...u].filter(p=>typeof p=="string"&&p.length>0),m=[l.description,l.workflowName,l.summary].find(p=>typeof p=="string"&&p.length>0)??"";f.length>0&&e.push({ids:f,description:m})}for(const c of mC(a))i(c,o);continue}if(a.type==="assistant"){const l=Dn(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!Dn(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const u=Dn(d.input)?d.input:null,f=(u==null?void 0:u.task_id)??(u==null?void 0:u.shell_id);typeof f=="string"&&t.add(f)}continue}if(a.type==="attachment"){const l=Dn(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 hC(n,e){return{status:"awaiting_agents",pendingQueue:e,pendingAgents:n.length,pendingAgentDescriptions:n.filter(t=>t.length>0)}}function gC(n){var a,l;let e=0,t=null,s=!1;function o(c,d){const u={status:c,pendingQueue:Math.max(0,e)};return d&&(u.toolName=d),u}function i(){return t??(t=pC(n))}for(let c=n.length-1;c>=0;c--){const d=n[c];if(d.type!=="queue-operation"){if(d.type==="progress"){const u=d.data;if((u==null?void 0:u.type)==="hook_progress"&&(u.decision??((a=u.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($x))continue;const u=d.operation;u==="enqueue"?e++:(u==="dequeue"||u==="remove")&&e--;continue}if(d.type==="attachment"){const u=Dn(d.attachment)?d.attachment:null;(u==null?void 0:u.commandMode)==="task-notification"&&(s=!0);continue}if(d.type==="assistant"){const u=d.message,f=u==null?void 0:u.stop_reason;if(f==="end_turn"){const m=i();if(s||m.undeliveredNotifications>0)return o("processing");if(m.pendingDescriptions.length>0)return hC(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(f==="tool_use"){const m=u==null?void 0:u.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 u=d.reason;if(u)return{status:"completed",terminalReason:u,pendingQueue:Math.max(0,e)};continue}d.type!=="summary"&&d.type==="system"&&d.subtype}return{status:"idle"}}function xC(n,e,t){const s=typeof n.sessionId=="string"?n.sessionId:"";return{record:{...n,sessionId:e,branchedFrom:{sessionId:s,turnIndex:t}},originalId:s}}function bC(n){return Tx(n).turnStartIndices}function Ix(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 Hm={0:"\0",b:"\b",f:"\f",n:`
56
+ `,r:"\r",t:" ",v:"\v"};function vC(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Yi(n){return!!(n&&/[\w$]/.test(n))}function ns(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 Hm){s+=Hm[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 gs={"(":")","[":"]","{":"}"};function nu(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 Ka(n,e){const t=ns(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=nu(n,e);return s===null?null:{endIndex:s,isString:!1}}function en(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=nu(n,t);if(s===null)break;t=s}return t}function qa(n,e){const t=n[e];if(!gs[t])return null;const s=[gs[t]];for(let o=e+1;o<n.length;o++){const i=Ka(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(gs[a]){s.push(gs[a]);continue}if(a===s.at(-1)&&(s.pop(),s.length===0))return o}return null}function Mx(n,e){if(!vC(n[e]))return null;let t=e+1;for(;Yi(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function yC(n,e,t){var u;const s=(u=t.trim().match(/^([A-Za-z_$][\w$]*)$/))==null?void 0:u[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=en(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const f=qa(o,l);if(f!==null)return o.slice(l,f+1).trim()}const d=ns(o,l);return d?o.slice(l,d.endIndex).trim():t}function wC(n){const e=[];for(let t=0;t<n.length;t++){const s=Ka(n,t);if(s){t=s.endIndex-1;continue}if(!n.startsWith("tools",t)||Yi(n[t-1])||Yi(n[t+5]))continue;let o=en(n,t+5),i="";if(n[o]==="."){o=en(n,o+1);const c=Mx(n,o);if(!c)continue;i=c.value,o=c.endIndex}else if(n[o]==="["){o=en(n,o+1);const c=ns(n,o);if(!c||(o=en(n,c.endIndex),n[o]!=="]"))continue;i=c.value,o++}else continue;if(o=en(n,o),n[o]!=="(")continue;const a=qa(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:yC(n,t,l),startIndex:t})}return e}function Ox(n,e){return ns(n,e)??Mx(n,e)}function jC(n,e,t){const s=[];for(let o=e;o<t;o++){const i=Ka(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(gs[a]){s.push(gs[a]);continue}if(s.length>0&&a===s.at(-1)){s.pop();continue}if(s.length===0&&a===",")return o}return t}function su(n,e){let t=en(n,0);for(;n[t]==="(";)t=en(n,t+1);if(n[t]!=="{")return null;const s=qa(n,t);if(s===null)return null;let o=t+1;for(;o<s;){if(o=en(n,o),n[o]===","){o++;continue}const i=Ox(n,o);if(!i){o++;continue}if(o=en(n,i.endIndex),n[o]!==":"){o++;continue}const a=en(n,o+1),l=jC(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function Dx(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=nu(n,o);if(i!==null){o=i-1;continue}const a=Ox(n,o);if(a){if(a.value===e&&!Yi(n[o-1])){const l=en(n,a.endIndex);if(n[l]===":"){const c=t(en(n,l+1));c!==null&&s.push(c)}}o=a.endIndex-1}}return s}function ou(n,e){return Dx(n,e,t=>{var s;return((s=ns(n,t))==null?void 0:s.value)??null})}function Lx(n,e){return Dx(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 zx(n){const e=en(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=qa(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=Ka(n,a);if(l){o||(o=l.isString),a=l.endIndex-1;continue}const c=n[a];gs[c]?(o=!0,i.push(gs[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 Km(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function SC(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=ns(n,a);if(l){if(Km(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=ns(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||!Km(d)||s.has(d)||(s.add(d),t.push(d))}return t}function qm(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 Vm(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 u=0;u<a.length;u++){const f=a[u],m=u+1<a.length?a[u+1].headerIdx:n.length,p=n.slice(f.startIdx,m),h=(d=(c=p.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:c[1])==null?void 0:d.trim(),g=qm(f.filePath,s),x=qm(h||f.filePath,s),b=p.split(/^@@.*$/m).filter(j=>j.trim()),y=[],v=[];for(const j of b)for(const k of j.split(`
60
+ `))k.startsWith("-")?y.push(k.slice(1)):k.startsWith("+")?v.push(k.slice(1)):k.startsWith(" ")&&(y.push(k.slice(1)),v.push(k.slice(1)));const S=a.length>1?`${e}:file-${u}`:e;f.action==="Add File"?o.push({id:S,name:"Write",input:{file_path:x,content:v.join(`
61
+ `)},result:null,isError:!1,timestamp:t}):f.action==="Delete File"?o.push({id:S,name:"Edit",input:{file_path:x,old_string:y.join(`
62
+ `),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:S,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:y.join(`
63
+ `),new_string:v.join(`
64
+ `)},result:null,isError:!1,timestamp:t})}return o}function Fx(n,e,t,s,o=""){return n==="apply_patch"?Vm(e,t,s,o):SC(e).flatMap((i,a)=>Vm(i,`${t}:patch-${a}`,s,o))}function NC(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 u=Number(d),f=s.get(u)??[];f.push(c),s.set(u,f)}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(u=>{const f=String(u.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!f)return!1;const p=f.split("/").filter(Boolean).slice(-2).join("/");return o.includes(f)||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(u=>u.id))??[]}))}function ru(n){return typeof n=="object"&&n!==null}const kC=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 wr(n){const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return kC.get(e)??n}function Fc(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 CC(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>ru(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 _C(n){return typeof n=="string"?n:Array.isArray(n)?n.filter(e=>ru(e)&&typeof e.text=="string").map(e=>e.text).join(""):""}function Bx(n){const e=_C(n);if(!e)return{text:"",isError:!1};try{const t=JSON.parse(e),s=typeof t.output=="string"?t.output:e,o=ru(t.metadata)?t.metadata:null,i=o?o.exit_code!==0&&o.exit_code!==void 0:Fc(s);return{text:s,isError:i}}catch{return{text:e,isError:Fc(e)}}}const TC=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function EC(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 iu(n){try{return JSON.parse(n)}catch{return null}}function et(n){return typeof n=="object"&&n!==null}function To(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 Xi(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 PC=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,AC=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function Ux(n){if(typeof n!="string")return null;const e=PC.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function Wx(n){if(typeof n!="string")return null;const e=AC.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function RC(n){return Array.isArray(n.images)?n.images.map(Ux).filter(e=>e!==null):[]}function $C(n){return Array.isArray(n.audio)?n.audio.map(Wx).filter(e=>e!==null):[]}function Hx(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_image").map(e=>Ux(e.image_url)).filter(e=>e!==null):[]}function Kx(n){return Array.isArray(n.content)?n.content.filter(e=>et(e)&&e.type==="input_audio").map(e=>Wx(e.audio_url)).filter(e=>e!==null):[]}function Gm(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 IC(n){var a,l;const e=Xi(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 Wo(n){return n.split(/[\\/]/).filter(Boolean).at(-1)??null}function MC(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function Bc(n){const e=n.trim();return!e||TC.some(t=>e.startsWith(t))?"":e}function OC(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 DC(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 LC(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 to(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 zC(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 Ym(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 Ho(n){if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n??"")}}function Xm(...n){return n.find(e=>typeof e=="string")}function FC(n){return n.startsWith("exec-")}function BC(n){if(!et(n))return{text:Ho(n),isError:!1};if("Err"in n)return{text:Ho(n.Err),isError:!0};const e=et(n.Ok)?n.Ok:null;if(!e)return{text:Ho(n),isError:!1};const t=Bx(e.content);return{text:t.text||(e.structuredContent!==void 0?Ho(e.structuredContent):Ho(e)),isError:e.isError===!0||t.isError}}function UC(n,e,t){return{id:n?`${n}@${e}`:EC("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function qx(n){return n.type==="event_msg"&&et(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?Bc(n.payload.message):n.type==="response_item"&&et(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?Bc(Xi(n.payload,"input_text")):""}function WC(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 qx(n)!==""||Hx(e).length>0||Kx(e).length>0}return!0}function Vx(n){let e="",t="",s="",o="",i="",a,l="",c="",d="",u="",f=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 S=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";S&&(a={sessionId:S,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const y=et(x.payload.source)?x.payload.source:null;if(y&&et(y.subagent)){m=!0;const S=et(y.subagent.thread_spawn)?y.subagent.thread_spawn:null;S&&typeof S.agent_path=="string"&&(h=S.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=qx(x);b&&b!==g&&(l||(l=b),c=b,g=b,f++,d||(d=x.timestamp??""),u=x.timestamp??u)}return u===""&&(u=d),{sessionId:e,version:t,gitBranch:s,cwd:o,model:i,slug:"",name:"",branchedFrom:a,firstUserMessage:l,lastUserMessage:c,timestamp:d,lastTimestamp:u,turnCount:f,isSubagent:m,parentSessionId:p,agentPath:h}}function Gx(n){for(const e of n.split(`
68
+ `)){const t=e.trim();if(t)return To(iu(t))}return!1}function HC(n){return To(n[0]??null)}function KC(n){const e=n.map(iu).filter(To);return Vx(e)}function Yx(n,e){const t=Vx(n.filter(To)),s=[],o=new Map,i=new Map,a=new Map,l=new Map,c=new Map,d=new Map,u=new Map,f=new Map;function m(P,A,T,E={}){const R=c.get(P);let I=f.get(P);if(!I){const M={agentId:P,parentToolUseId:(R==null?void 0:R.parentToolCallId)||void 0,agentName:(R==null?void 0:R.nickname)??(R!=null&&R.agentPath?Wo(R.agentPath):null),subagentType:(R==null?void 0:R.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(R==null?void 0:R.timestamp)??T,tokenUsage:null,model:(R==null?void 0:R.model)??null,isBackground:!1,prompt:(R==null?void 0:R.message)||void 0,status:E.status??"running"};A.subAgentActivity.push(M);const O=A.contentBlocks[A.contentBlocks.length-1];(O==null?void 0:O.kind)==="sub_agent"?O.messages.push(M):A.contentBlocks.push({kind:"sub_agent",messages:[M],timestamp:T}),I={message:M,turn:A},f.set(P,I)}const $=I.message;if(R&&($.parentToolUseId=R.parentToolCallId||$.parentToolUseId,$.agentName=R.nickname??(R.agentPath?Wo(R.agentPath):$.agentName),$.subagentType=R.agentType,$.model=R.model,$.prompt=R.message||$.prompt),E.text&&!$.text.includes(E.text)&&($.text.push(E.text),$.content=$.text.join(`
69
+
70
+ `)),E.status){const M=new Set(["completed","failed","interrupted"]);if(E.status==="running"&&$.status&&M.has($.status)||($.status=E.status),M.has(E.status)&&$.timestamp&&T){const O=new Date($.timestamp).getTime(),D=new Date(T).getTime();Number.isFinite(O)&&Number.isFinite(D)&&D>=O&&($.durationMs=D-O)}}return $}let p=null,h=null,g=t.model||null,x="",b=null,y=!1;const v=[];let S=0,j=null,k=null;function C(P){const A=s.length,T=zC(s,P,x);return s.length>A&&k!==null&&v.push(k),k=null,T}function N(P,A,T){const E=UC(P,A,T);return k=j??S,j=null,y||(E.isFragment=!0),b&&(E.compactionSummary=b,b=null),E}function _(P,A,T,E,R){const I=i.get(A);if(I){I.input={...I.input,...T},I.result=E,I.isError=E==="failed";return}const $={id:A,name:"WebSearch",input:T,result:E,isError:E==="failed",timestamp:R};i.set(A,$),to(P,$,R)}for(let P=0;P<n.length;P++){const A=n[P];if(!To(A))continue;S=P;const T=et(A.payload)?A.payload:void 0,E=A.timestamp??"";if(A.type==="compacted"){p=C(p),b="Conversation compacted",x=E;continue}if(A.type!=="world_state"){if(A.type==="turn_context"){p=C(p),j=P,h=typeof(T==null?void 0:T.turn_id)=="string"?T.turn_id:null,g=typeof(T==null?void 0:T.model)=="string"?T.model:g,x=E,y=!0;continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="user_message"&&typeof T.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),y=!0,p??(p=N(h,E,g));const R=(Array.isArray(T.local_images)?T.local_images:[]).filter($=>typeof $=="string"&&$.length>0),I=(Array.isArray(T.local_audio)?T.local_audio:[]).filter($=>typeof $=="string"&&$.length>0);p.userMessage=Gm(T.message,RC(T),$C(T),R,I),p.isFragment=!1,p.timestamp=p.timestamp||E,x=E;continue}if(!(!p&&!WC(A,T))){if(p??(p=N(h,E,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=E),E&&(x=E),A.type==="event_msg"&&(T==null?void 0:T.type)==="token_count"){const R=et(T.info)?T.info:null,I=R?DC(R.last_token_usage):null;I&&(p.tokenUsage=OC(p.tokenUsage,I));continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="web_search_end"&&typeof T.call_id=="string"){const R={};typeof T.query=="string"&&T.query&&(R.query=T.query),et(T.action)&&(R.action=T.action),_(p,T.call_id,R,"completed",E);continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="mcp_tool_call_end"&&typeof T.call_id=="string"&&et(T.invocation)){const R=T.invocation,I=typeof R.server=="string"?R.server:"mcp",$=typeof R.tool=="string"?R.tool:"tool",M=et(R.arguments)?R.arguments:{},O=BC(T.result),D=o.get(T.call_id);D?(D.result=O.text,D.isError=O.isError,o.delete(T.call_id)):FC(T.call_id)||to(p,{id:T.call_id,name:`mcp__${I}__${$}`,input:M,result:O.text,isError:O.isError,timestamp:E},E);continue}if(A.type==="event_msg"&&(T==null?void 0:T.type)==="sub_agent_activity"&&typeof T.agent_thread_id=="string"&&typeof T.agent_path=="string"){const R=T.agent_thread_id,I=typeof T.event_id=="string"?T.event_id:"",$=typeof T.kind=="string"?T.kind:"started",M=I?l.get(I):void 0,O=d.get(T.agent_path),D=c.get(R)??(O?c.get(O):void 0);if($!=="started"&&!D&&!M)continue;if(O&&O!==R&&!f.has(R)){const z=f.get(O);z&&(z.message.agentId=R,f.delete(O),f.set(R,z)),c.delete(O)}const L={agentId:R,nickname:(D==null?void 0:D.nickname)??Wo(T.agent_path)??(M==null?void 0:M.taskName)??null,agentPath:T.agent_path,message:(D==null?void 0:D.message)??(M==null?void 0:M.message)??"",model:(D==null?void 0:D.model)??(M==null?void 0:M.model)??null,agentType:(D==null?void 0:D.agentType)??(M==null?void 0:M.agentType)??null,timestamp:(D==null?void 0:D.timestamp)??(E||(M==null?void 0:M.timestamp)||""),parentToolCallId:(D==null?void 0:D.parentToolCallId)??I};c.set(R,L),d.set(T.agent_path,R),I&&($==="started"||M)&&u.set(I,R),m(R,p,E,{status:$==="interrupted"?"interrupted":"running"});continue}if(!(A.type!=="response_item"||!T)){if(T.type==="reasoning"){const R=Array.isArray(T.summary)?T.summary.filter(I=>typeof I=="string").join(`
71
+ `):"";LC(p,R.trim(),E);continue}if(T.type==="message"&&T.role==="assistant"){Ix(p,Xi(T,"output_text"),E);continue}if(T.type==="message"&&T.role==="user"&&p.userMessage===null){const R=Bc(Xi(T,"input_text")),I=Hx(T),$=Kx(T);(R||I.length>0||$.length>0)&&(p.userMessage=Gm(R,I,$),p.isFragment=!1,y=!0);continue}if(T.type==="web_search_call"&&typeof T.id=="string"){const R={};et(T.action)&&(R.action=T.action);const I=typeof T.status=="string"?T.status:"completed";_(p,T.id,R,I,E);continue}if(T.type==="tool_search_call"){const R=Xm(T.call_id,T.id)??"";if(R){const I={id:R,name:"ToolSearch",input:et(T.arguments)?T.arguments:{},result:null,isError:!1,timestamp:E};o.set(R,I),to(p,I,E)}continue}if(T.type==="tool_search_output"&&typeof T.call_id=="string"){const R=o.get(T.call_id);if(R){const I=Array.isArray(T.tools)?T.tools:[],$=I.filter(et).map(D=>Xm(D.name)??"").filter(Boolean),M=$.length>0?$.length:I.length,O=`Found ${M} tool${M===1?"":"s"}`;R.result=$.length>0?`${O}: ${$.join(", ")}`:O,R.isError=T.status==="failed",o.delete(T.call_id)}continue}if(T.type==="agent_message"&&typeof T.author=="string"){const R=T.author,I=typeof T.recipient=="string"?T.recipient:null,$=IC(T);if($.messageType==="NEW_TASK")continue;const M=d.get(R),O=R.startsWith(`${t.agentPath}/`)&&(I===null||I===t.agentPath);if(!M&&!O)continue;const D=M??R;M||(c.set(D,{agentId:D,nickname:Wo(R),agentPath:R,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),d.set(R,D));let L;$.messageType==="FINAL_ANSWER"?L="completed":$.messageType==="ERROR"||$.messageType==="FAILED"?L="failed":$.messageType==="INTERRUPTED"?L="interrupted":$.messageType==="MESSAGE"&&(L="running"),m(D,p,E,{status:L,text:$.text||void 0});continue}if(T.type==="function_call"&&typeof T.call_id=="string"){const R=typeof T.name=="string"?T.name:"tool",I=wr(R),$=Ym(T.arguments);let M=I,O=$;I==="exec_command"?M="Bash":I==="update_plan"&&(M="TodoWrite",O=CC($)),I==="spawn_agent"&&l.set(T.call_id,{callId:T.call_id,message:MC($.message),taskName:typeof $.task_name=="string"?$.task_name:null,model:typeof $.model=="string"?$.model:null,agentType:typeof $.agent_type=="string"?$.agent_type:null,timestamp:E});const D={id:T.call_id,name:M,input:O,result:null,isError:!1,timestamp:E};o.set(D.id,D),to(p,D,E);continue}if(T.type==="function_call_output"&&typeof T.call_id=="string"){const R=o.get(T.call_id);if(!R)continue;const I=typeof T.output=="string"?T.output:null;if(R.result=I,R.isError=Fc(I),o.delete(T.call_id),R.name==="spawn_agent"&&I)try{const $=JSON.parse(I),M=typeof $.agent_id=="string"?$.agent_id:u.get(R.id)??"",O=typeof $.task_name=="string"?$.task_name:null,D=typeof $.nickname=="string"?$.nickname:O?Wo(O):null;if(M){const L=l.get(R.id),F=c.get(M),z={agentId:M,nickname:D??(F==null?void 0:F.nickname)??(L==null?void 0:L.taskName)??null,agentPath:O??(F==null?void 0:F.agentPath)??null,message:(F==null?void 0:F.message)??(L==null?void 0:L.message)??"",model:(F==null?void 0:F.model)??(L==null?void 0:L.model)??null,agentType:(F==null?void 0:F.agentType)??(L==null?void 0:L.agentType)??null,timestamp:(F==null?void 0:F.timestamp)??(L==null?void 0:L.timestamp)??E,parentToolCallId:(F==null?void 0:F.parentToolCallId)??R.id};c.set(M,z),u.set(R.id,M),z.agentPath&&d.set(z.agentPath,M),m(M,p,E,{status:"running"})}}catch{}if(R.name==="wait_agent"&&I&&p)try{const $=JSON.parse(I),M=et($.status)?$.status:{};for(const[O,D]of Object.entries(M)){const L=et(D)?D:{},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(O)||c.set(O,{agentId:O,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:E,parentToolCallId:""}),m(O,p,E,{status:U,text:F||z||W||void 0})}}catch{}continue}if(T.type==="custom_tool_call"&&typeof T.call_id=="string"){const R=typeof T.name=="string"?T.name:"tool",I=typeof T.input=="string"?T.input:"",$=T.call_id,M=I?Fx(R,I,$,E,t.cwd):[];if(R!=="apply_patch"){const O={id:$,name:R==="exec_command"?"Bash":R,input:Ym(I),result:null,isError:!1,timestamp:E};o.set(O.id,O),to(p,O,E)}for(const O of M)o.set(O.id,O),to(p,O,E);M.length>0&&a.set($,{calls:M,direct:R==="apply_patch"});continue}if(T.type==="custom_tool_call_output"&&typeof T.call_id=="string"){const R=T.call_id,{text:I,isError:$}=Bx(T.output),M=a.get(R);if(M){const D=M.direct&&$?new Set(M.calls.map(L=>L.id)):NC(I,$,M.calls);for(const L of M.calls){const F=o.get(L.id);F&&(F.result=I,F.isError=D.has(F.id),o.delete(F.id))}a.delete(R)}const O=o.get(R);O&&(O.result=I,O.isError=$,o.delete(R));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?Ua(s.length):Wa(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function au(n,e){const t=n.split(`
72
+ `).map(i=>i.trim()).filter(Boolean).map(iu).filter(To),{turnStartIndices:s,...o}=Yx(t,e);return o}function qC(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
73
+ `);return au(t?`${t}
74
+ ${e}`:e)}const VC=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function GC(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 _i(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return et(e)?e:null}catch{return null}}function YC(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(u,f){t.has(u)||e.set(u,e.get(u)||f)}for(const u of n){const f=et(u.payload)?u.payload:null;if(f){if(u.type==="event_msg"&&f.type==="sub_agent_activity"&&typeof f.agent_thread_id=="string"&&typeof f.agent_path=="string"){const m=f.agent_thread_id,p=typeof f.kind=="string"?f.kind:"started",h=typeof f.event_id=="string"?f.event_id:"",g=s.get(f.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(f.agent_path,m),p==="interrupted"?(t.add(m),e.delete(m)):l(m,o.get(h)??"");continue}if(u.type==="response_item"){if(f.type==="function_call"&&typeof f.call_id=="string"){const m=wr(typeof f.name=="string"?f.name:"");if(m==="spawn_agent"){const p=_i(f.arguments);o.set(f.call_id,typeof(p==null?void 0:p.task_name)=="string"?p.task_name:"")}else if(m==="wait_agent")i.add(f.call_id);else if(m==="interrupt_agent"){const p=_i(f.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(f.call_id,h)}continue}if(f.type==="function_call_output"&&typeof f.call_id=="string"){const m=f.call_id;if(o.has(m)){const p=_i(f.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=_i(f.output),h=et(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const b=et(x)?x:{},y=typeof b.status=="string"?b.status:"";(typeof b.completed=="string"||typeof b.failed=="string"||typeof b.error=="string"||typeof b.interrupted=="string"||y==="completed"||y==="failed"||y==="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(f.type==="agent_message"&&typeof f.author=="string"){const p=((d=(c=GC(f).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!VC.has(p))continue;const h=s.get(f.author)??f.author;t.add(h),e.delete(h)}}}}return[...e.entries()].filter(([u])=>!t.has(u)).map(([,u])=>u)}function XC(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=YC(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?wr(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 JC(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 QC(n){return Yx(n,{skipStats:!0}).turnStartIndices}const ZC=/^(?: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 zt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Xx(n){return typeof n.agentId!="string"||n.agentId.length===0}function Jx(n){return!zt(n)||typeof n.type!="string"||!zt(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||ZC.test(n.type)}function Qx(n){try{const e=JSON.parse(n);return Jx(e)?e:null}catch{return null}}function e6(n){return n.split(`
76
+ `).map(e=>e.trim()).filter(Boolean).map(Qx).filter(e=>e!==null)}function we(...n){return n.find(e=>typeof e=="string")??""}function Zn(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function Yo(n){return typeof n.timestamp=="string"?n.timestamp:""}function fs(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 Jm(n){const e=fs(n,"copilot-turn"),t=we(n.data.turnId);return t?`${t}@${e}`:e}function Ol(n,e){if(!zt(n))return;const t=we(n.cwd),s=we(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function Zx(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(!Xx(t))continue;const{data:s}=t,o=Yo(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))),Ol(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){Ol(s.context,e),e.model=we(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){Ol(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 t6(n){for(const e of n.split(`
77
+ `)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(Jx(s))return!0}catch{}}return!1}function n6(n){var e;return g6((e=n[0])==null?void 0:e.type)}function s6(n){const e=n.map(t=>Qx(t.trim())).filter(t=>t!==null);return Zx(e)}function Dl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function Qm(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:zt(e)?we(e.text,e.content):"";return t?[t]:[]}).join(`
78
+ `):""}function o6(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 r6(n,e){if(!zt(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 e0(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=r6(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 i6(n,e){const t=we(n.content),s=e0(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function a6(n,e){return zt(n.result)?e0([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function Fi(n,e){var o,i;if(!n)return{...e};const t=((o=n.output_tokens_details)==null?void 0:o.thinking_tokens)??0,s=((i=e.output_tokens_details)==null?void 0:i.thinking_tokens)??0;return{input_tokens:n.input_tokens+e.input_tokens,output_tokens:n.output_tokens+e.output_tokens,cache_creation_input_tokens:(n.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(n.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),...t||s?{output_tokens_details:{thinking_tokens:t+s}}:{}}}function Uc(n,e=!1){const t=Zn(n.cacheWriteTokens),s=Zn(n.cacheReadTokens),o=Zn(n.inputTokens),i={input_tokens:e?Math.max(0,o-t-s):o,output_tokens:Zn(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},a=Zn(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 l6(n){if(!zt(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!zt(t)||!zt(t.usage))continue;const s=Uc(t.usage,!0);s&&(e=Fi(e,s))}return e}function c6(n){if(typeof n=="string")return{label:n};if(!zt(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 d6(n){return Array.isArray(n)?n.map(c6).filter(e=>e!==null):[]}function u6(n){if(!zt(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:d6(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function f6(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(u6).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function Xo(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 Ji(n,e){const t=zt(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?f6(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 m6(n){const e=n.error;if(typeof e=="string")return e;if(zt(e)){const s=we(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!zt(t))return t===void 0?"":Dl(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:zt(o)?we(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
79
+ `);if(s)return s}return t.structuredContent!==void 0?Dl(t.structuredContent):Dl(t)}function Zm(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 Ti(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 Jo(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function ep(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const o of n){if(!zt(o))continue;const i=we(o.toolCallId),a=we(o.name);if(!i||!a||t(i))continue;const l=Xo(a);s.push(Jo(i,l,Ji(l,o.arguments),e))}return s}function tp(n,e,t,s){n.name=e,n.input=Ji(e,t),n.timestamp=s||n.timestamp}function np(n,e,t){n.result=m6(e);const s=a6(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function sp(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 p6(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function t0(n,e){const t=e6(n),s=Zx(t),o=o6(t),i=[],a=new Map,l=new Map,c=new Map,d=new WeakMap,u=new WeakMap;let f=null,m=null,p,h=!1,g=!1,x=null;function b(C,N){N&&d.set(C,N)}function y(C){return f||(f=sp(Jm(C),Yo(C),null,m,p,!0)),f}function v(){f&&(p6(f)&&i.push(f),f=null)}function S(C){var I;const N=typeof C.agentId=="string"?C.agentId:"";if(!N)return null;const _=l.get(N);if(_)return _.message;const P=C.data,A=we(P.toolCallId),T=A?((I=a.get(A))==null?void 0:I.turn)??f:f;if(!T)return null;const E=we(P.executionMode),R={agentId:N,...A?{parentToolUseId:A}:{},agentName:we(P.agentDisplayName,P.agentName)||null,subagentType:we(P.agentType,P.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:Yo(C),tokenUsage:null,model:we(P.model)||null,isBackground:E==="background",...we(P.description)?{prompt:we(P.description)}:{},status:"running"};return T.subAgentActivity.push(R),T.contentBlocks.push({kind:R.isBackground?"background_agent":"sub_agent",messages:[R],timestamp:R.timestamp}),l.set(N,{message:R,turn:T}),R}function j(C){if(Xx(C))return!1;const N=S(C);if(!N)return!0;const{data:_}=C,P=Yo(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=Zn(_.durationMs)||N.durationMs,N.toolUseCount=Zn(_.totalToolCalls)||N.toolUseCount,N.status=C.type==="subagent.completed"?"completed":"failed";const A=we(_.error,_.message);return A&&!N.text.includes(A)&&N.text.push(A),!0}if(C.type==="user.message")return N.prompt||(N.prompt=we(_.content)||void 0),!0;if(C.type==="assistant.reasoning"){const A=we(_.content);return A&&!N.thinking.includes(A)&&N.thinking.push(A),!0}if(C.type==="assistant.message"){N.model=we(_.model)||N.model;const A=we(_.reasoningText);A&&!N.thinking.includes(A)&&N.thinking.push(A);const T=Qm(_.content);T&&!N.text.includes(T)&&N.text.push(T);for(const E of ep(_.toolRequests,P,R=>c.has(R)))N.toolCalls.push(E),c.set(E.id,{call:E,message:N});return!0}if(C.type==="assistant.usage"){N.model=we(_.model)||N.model;const A=Uc(_);return A&&(N.tokenUsage=Fi(N.tokenUsage,A)),!0}if(C.type==="tool.execution_start"){const A=we(_.toolCallId)||fs(C,"copilot-agent-tool"),T=we(_.toolName)||"Tool",E=Xo(T),R=c.get(A);if(R)tp(R.call,E,_.arguments,P);else{const I=Jo(A,E,Ji(E,_.arguments),P);N.toolCalls.push(I),c.set(A,{call:I,message:N})}return!0}if(C.type==="tool.execution_complete"){const A=we(_.toolCallId)||fs(C,"copilot-agent-tool");let T=c.get(A);if(!T){const E=we(_.toolName)||"Tool",R=Xo(E),I=Jo(A,R,{},P);N.toolCalls.push(I),T={call:I,message:N}}return np(T.call,_,o),c.delete(A),!0}return!0}for(const C of t){if(j(C))continue;const{data:N}=C,_=Yo(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,f&&(f.model=m);continue}if(C.type==="session.model_change"){m=we(N.newModel)||m;const P=N.reasoningEffort;typeof P=="string"&&(p=P),f&&(f.model=m,p&&(f.effort=p));continue}if(C.type==="session.shutdown"){m=we(N.currentModel)||m,f&&!f.model&&(f.model=m),x=l6(N)??x;const P=Zn(N.totalApiDurationMs);f&&!g&&P&&u.set(f,P);continue}if(C.type==="user.message"){v(),f=sp(Jm(C),_,i6(N,o),m,p,!1),b(f,_);continue}if(C.type==="assistant.turn_start"){m=we(N.model)||m;const P=y(C);P.model=m,p&&(P.effort=p),b(P,_);continue}if(C.type==="assistant.reasoning"){const P=y(C);Zm(P,we(N.content),_,we(N.reasoningId)||fs(C,"copilot-thinking")),b(P,_);continue}if(C.type==="assistant.message"){m=we(N.model)||m;const P=y(C);P.model=m,p&&(P.effort=p),Zm(P,we(N.reasoningText),_,fs(C,"copilot-thinking")),Ix(P,Qm(N.content),_);for(const A of ep(N.toolRequests,_,T=>a.has(T)))Ti(P,A,_),a.set(A.id,{call:A,turn:P});b(P,_);continue}if(C.type==="assistant.usage"){m=we(N.model)||m,p=we(N.reasoningEffort)||p;const P=Uc(N),A=Zn(N.duration);P&&(h=!0),A&&(g=!0);const T=y(C);T.model=m,p&&(T.effort=p),P&&(T.tokenUsage=Fi(T.tokenUsage,P)),A&&u.set(T,(u.get(T)??0)+A),b(T,_);continue}if(C.type==="tool.execution_start"){m=we(N.model)||m;const P=y(C);P.model=m;const A=we(N.toolCallId)||fs(C,"copilot-tool"),T=we(N.toolName)||"Tool",E=Xo(T),R=a.get(A);if(R)tp(R.call,E,N.arguments,_);else{const I=Jo(A,E,Ji(E,N.arguments),_);Ti(P,I,_),a.set(A,{call:I,turn:P})}b(P,_);continue}if(C.type==="tool.execution_complete"){m=we(N.model)||m;const P=we(N.toolCallId)||fs(C,"copilot-tool");let A=a.get(P);if(!A){const T=y(C),E=we(N.toolName)||"Tool",R=Xo(E),I=Jo(P,R,{},_);Ti(T,I,_),A={call:I,turn:T}}np(A.call,N,o),a.delete(P),b(A.turn,_);continue}if(C.type==="session.error"){const P=y(C),T={errorType:we(N.errorType)||"unknown"};typeof N.statusCode=="number"&&(T.statusCode=N.statusCode),typeof N.errorCode=="string"&&(T.errorCode=N.errorCode),Ti(P,{id:fs(C,"copilot-error"),name:"Error",input:T,result:we(N.message)||"Copilot session error",isError:!0,timestamp:_},_),b(P,_);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&f&&b(f,_)}if(v(),!h&&x&&i.length===1&&(i[0].tokenUsage=Fi(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),P=N?Date.parse(N):Number.NaN;if(Number.isFinite(_)&&Number.isFinite(P)&&P>=_)C.durationMs=P-_;else{const A=u.get(C)??0;A&&(C.durationMs=A)}}const k=e!=null&&e.skipStats?Ua(i.length):Wa(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 h6(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
80
+ `);return t0(t?`${t}
81
+ ${e}`:e)}function g6(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 x6(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=zt(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=zt(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=zt(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"?wr(a.toolName):typeof a.name=="string"?wr(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 b6(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function v6(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 n0=ws[ws.length-1],y6={kind:"codex",descriptor:sn("codex"),detectsText:Gx,detectsRecords:HC,parse:au,append:qC,metadataFromLines:KC,status:XC,brandBranch:JC,turnBoundaries:QC},w6={kind:"copilot",descriptor:sn("copilot"),detectsText:t6,detectsRecords:n6,parse:t0,append:h6,metadataFromLines:s6,status:x6,brandBranch:b6,turnBoundaries:v6},j6={kind:"claude",descriptor:sn("claude"),detectsText:Wm,detectsRecords:Wm,parse:cC,append:dC,metadataFromLines:lC,status:gC,brandBranch:xC,turnBoundaries:bC},S6=Object.freeze({claude:j6,codex:y6,copilot:w6});function N6(n){function e(t){for(const s of ws){const o=n[s];if(t(o))return o}return n[n0]}return{formatFor:t=>n[t],formatForText:t=>e(s=>s.detectsText(t)),formatForRecords:t=>e(s=>s.detectsRecords(t))}}const lu=N6(S6);function s0(n){return lu.formatFor(n)}function o0(n){return lu.formatForText(n)}function r0(n){return lu.formatForRecords(n)}function i0(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 a0(n,e,t){return i0(n,e)[t]??e.length}function k6(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:i0(n,e).find(o=>o>s)??"keep-all"}function C6(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 _6(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 l0(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||C6(e,o)||s.isError&&_6(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 T6(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
82
+ `)}function Va(n,e){return o0(n).parse(n,e)}function E6(n,e){const t=r0(n.rawMessages);return(t.kind===n0?o0(e):t).append(n,e)}function Ga(n){return n===null?"":typeof n=="string"?n:T6(n)}function c0(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const d0=w.createContext(null);function P6(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=c0(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 A6(n){const e=B.c(10),{images:t,children:s}=n,[o,i]=w.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 u;e[4]!==o?(u=o&&r.jsx(Zd,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(R6),onCloseComplete:()=>i(null)},o.key),e[4]=o,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==d?(f=r.jsxs(d0.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f}function R6(n){return n?{...n,open:!1}:null}function $6(n){const e=B.c(7),{children:t}=n,{session:s}=ct();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=P6(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(A6,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function u0(){return w.useContext(d0)}const f0=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function I6(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:f0.has(n.slice(e).toLowerCase())}function cu(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:I6(n)}function M6(n){return n&&(cu(n)?Lr(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function Wc(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=Pn("hostFiles"),[d,u]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=w.useState(),g=u0();let x;e[0]!==c||e[1]!==t?(x=cu(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const b=x;let y;e[3]!==b||e[4]!==t?(y=b?void 0:M6(t),e[3]=b,e[4]=t,e[5]=y):y=e[5];const v=y;let S;e[6]!==s||e[7]!==l||e[8]!==v?(S=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]=S):S=e[9];const j=S;let k;e[10]!==g||e[11]!==j?(k=()=>{j&&(g?g.openImage(j):(m(!0),u(!0)))},e[10]=g,e[11]=j,e[12]=k):k=e[12];const C=k;if(b){let O;return e[13]!==s?(O=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=O):O=e[14],O}if(v&&p===v){const O=s?`: ${s}`:"";let D;return e[15]!==O?(D=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",O]}),e[15]=O,e[16]=D):D=e[16],D}const N=`Open ${s||"rendered image"}`;let _;e[17]!==i?(_=G("group/image relative my-3 block h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 transition-colors hover:bg-muted focus-visible:ring-ring/40",i),e[17]=i,e[18]=_):_=e[18];const P=s??"";let A;e[19]!==v?(A=()=>h(v),e[19]=v,e[20]=A):A=e[20];let T;e[21]!==a?(T=G("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=T):T=e[22];let E;e[23]!==v||e[24]!==T||e[25]!==P||e[26]!==A?(E=r.jsx("img",{src:v,alt:P,loading:"lazy",decoding:"async",onError:A,className:T}),e[23]=v,e[24]=T,e[25]=P,e[26]=A,e[27]=E):E=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(ya,{className:"size-3.5","data-icon":"icon"})}),e[28]=R):R=e[28];let I;e[29]!==C||e[30]!==E||e[31]!==N||e[32]!==_?(I=r.jsxs(ee,{type:"button",variant:"ghost",onClick:C,"aria-label":N,className:_,children:[E,R]}),e[29]=C,e[30]=E,e[31]=N,e[32]=_,e[33]=I):I=e[33];let $;e[34]!==d||e[35]!==f||e[36]!==j?($=f&&j&&r.jsx(Zd,{open:d,images:[j],initialIndex:0,onClose:()=>u(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=f,e[36]=j,e[37]=$):$=e[37];let M;return e[38]!==I||e[39]!==$?(M=r.jsxs(r.Fragment,{children:[I,$]}),e[38]=I,e[39]=$,e[40]=M):M=e[40],M}function O6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("w-full caption-bottom text-sm",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:o,...s})}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function D6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("[&_tr]:border-b",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("thead",{"data-slot":"table-header",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function L6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tbody",{"data-slot":"table-body",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function z6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("tr",{"data-slot":"table-row",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function F6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("th",{"data-slot":"table-head",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function B6(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("td",{"data-slot":"table-cell",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function U6(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 W6(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=Pn("hostFiles");let a;e[4]!==s?(a=U6(s),e[4]=s,e[5]=a):a=e[5];const l=a;if(l&&!i){let f;return e[6]!==t||e[7]!==s?(f=r.jsx("span",{className:"text-muted-foreground",title:s,children:t}),e[6]=t,e[7]=s,e[8]=f):f=e[8],f}let c;e[9]!==l||e[10]!==s?(c=f=>{s&&(f.preventDefault(),l?xr(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 u;return e[12]!==t||e[13]!==d||e[14]!==s||e[15]!==o?(u=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]=u):u=e[16],u}const H6=[...f0].map(n=>n.slice(1)).join("|"),K6=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${H6}))[ \\t]*$`,"gim");function m0(n){return n.replace(K6,(e,t,s)=>`${t}![${s}](${s})`)}const Yn={code:xN,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:W6,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(kt,{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(O6,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(D6,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(L6,{children:n})},tr({children:n}){return r.jsx(z6,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(F6,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(B6,{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:Wc,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Qs=[ka],q6=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],V6=q6.join("|");function p0(){return new RegExp(`<(${V6})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function du(n){return n.replace(p0(),"").trim()}function G6(n){return p0().test(n)}const Y6=/<command-message>([^<]+)<\/command-message>/,X6=/<command-name>([\s\S]*?)<\/command-name>/,J6=/<command-args>([\s\S]*?)<\/command-args>/;function h0(n){const e=n.match(Y6);if(e)return e[1];const t=n.match(X6);return t?t[1].trim().replace(/^\//,""):null}function g0(n){const e=n.match(J6);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const x0={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},Q6=new RegExp(`<(${Object.keys(x0).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function Z6(n){const e=[],t=n.replace(Q6,(s,o,i)=>(e.push({text:zg(i).trim(),stream:x0[o]}),"")).trim();return{outputs:e,remainingText:t}}const e_=/<task-notification>([\s\S]*?)<\/task-notification>/g;function no(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function jr(n){const e=[],t=n.replace(e_,(s,o)=>(e.push({taskId:no(o,"task-id"),toolUseId:no(o,"tool-use-id"),outputFile:no(o,"output-file"),status:no(o,"status"),summary:no(o,"summary"),result:no(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const t_=/\[Request interrupted by user[^\]]*\]/g;function b0(n){const e=[],t=n.replace(t_,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const op="[SYSTEM NOTIFICATION - NOT USER INPUT]";function v0(n){const e=n.indexOf(op);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+op.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 rp={Icon:jS,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},ip={completed:{Icon:wS,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...rp,label:"Failed"},error:{...rp,label:"Error"},running:{Icon:SS,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function y0(n){const e=B.c(32),{notification:t}=n,[s,o]=w.useState(!1),i=ip[t.status]??ip.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?tt:Je;let d;e[0]!==i.bg?(d=G("my-1 rounded-lg border p-3",i.bg),e[0]=i.bg,e[1]=d):d=e[1];let u;e[2]!==i.color?(u=G("mt-0.5 size-4 shrink-0",i.color),e[2]=i.color,e[3]=u):u=e[3];let f;e[4]!==a||e[5]!==u?(f=r.jsx(a,{className:u}),e[4]=a,e[5]=u,e[6]=f):f=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(Ce,{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($t,{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(at,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(Hn,{components:Yn,remarkPlugins:Qs,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]!==f||e[26]!==x?(b=r.jsxs("div",{className:"flex items-start gap-2",children:[f,x]}),e[25]=f,e[26]=x,e[27]=b):b=e[27];let y;return e[28]!==s||e[29]!==d||e[30]!==b?(y=r.jsx(it,{open:s,onOpenChange:o,className:d,children:b}),e[28]=s,e[29]=d,e[30]=b,e[31]=y):y=e[31],y}function n_(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}=jr(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(s_)}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 s_(n,e){return r.jsx(y0,{notification:n},n.taskId||`notification-${e}`)}function o_(n){const e=B.c(15),{output:t}=n,s=t.stream==="stderr",o=t.stream==="input",i=s&&"border-destructive/20 bg-destructive/5 text-destructive",a=o&&"border-border bg-muted/50 text-foreground",l=!s&&!o&&"border-border bg-muted/40 text-muted-foreground";let c;e[0]!==i||e[1]!==a||e[2]!==l?(c=G("rounded-md border px-3 py-2 my-1 font-mono text-xs",i,a,l),e[0]=i,e[1]=a,e[2]=l,e[3]=c):c=e[3];let d;e[4]!==s||e[5]!==o?(d=o?r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(jo,{className:G("size-3 shrink-0",s?"text-destructive":"text-muted-foreground"),"data-icon":"inline-start"}),e[4]=s,e[5]=o,e[6]=d):d=e[6];let u;e[7]!==t.text?(u=r.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.text}),e[7]=t.text,e[8]=u):u=e[8];let f;e[9]!==d||e[10]!==u?(f=r.jsxs("div",{className:"flex items-center gap-1.5",children:[d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(m=r.jsx("div",{className:c,children:f}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}function r_(n){const e=B.c(6),{loading:t,content:s}=n;let o;if(t){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground/60 font-mono",children:[r.jsx(Fg,{className:"w-3 h-3 text-muted-foreground/60"})," Loading..."]}),e[0]=a):a=e[0],o=a}else if(s){let a;e[1]!==s?(a=r.jsx(Hn,{components:Yn,remarkPlugins:Qs,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 uu=w.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=u0(),[l,c]=w.useState(!1),[d,u]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),[b,y]=w.useState(null),v=w.useMemo(()=>Ga(e),[e]),S=w.useMemo(()=>h0(v),[v]),j=w.useMemo(()=>g0(v),[v]),{sender:k,body:C,matched:N}=w.useMemo(()=>yr(v),[v]),_=w.useMemo(()=>du(C),[C]),{text:P,isSystemNotification:A}=w.useMemo(()=>v0(_),[_]),{notifications:T,remainingText:E}=w.useMemo(()=>jr(P),[P]),{outputs:R,remainingText:I}=w.useMemo(()=>Z6(E),[E]),{interrupts:$,remainingText:M}=w.useMemo(()=>b0(I),[I]),O=w.useCallback(async q=>{if(!q){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!S)){x(!0),m(!0);try{const Y=await o(S,j??void 0);h(Y)}finally{x(!1)}}},[p,o,S,j]),D=w.useMemo(()=>c0(e),[e]),L=w.useMemo(()=>D.map(q=>`data:${q.source.media_type};base64,${q.source.data}`),[D]),F=w.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=w.useMemo(()=>G6(v)||A||N,[v,A,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):y({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:()=>u(!d),className:"-ml-2 text-muted-foreground",children:d?r.jsxs(r.Fragment,{children:[r.jsx(wa,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(ys,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&A&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ce,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(jo,{"data-icon":"inline-start"}),"System event"]})}),!d&&N&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ce,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(os,{"data-icon":"inline-start"}),k?`From ${k}`:"Teammate message"]})}),S&&r.jsxs(it,{open:f,onOpenChange:q=>void O(q),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ce,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(jo,{"data-icon":"inline-start"}),"/",S,j&&r.jsx("span",{className:"text-muted-foreground",children:j})]}),o&&r.jsxs($t,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[f?r.jsx(tt,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),f?"Collapse":"Expand"]}),f&&s&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(S),className:"text-muted-foreground",children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(at,{children:r.jsx(r_,{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:G("group/image relative h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 text-left","transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"),children:[r.jsx("img",{src:q,alt:`Attachment ${Y+1}`,loading:"lazy",decoding:"async",className:"max-h-64 max-w-full rounded-lg object-contain sm:max-w-md"}),r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(ya,{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]})]},`${D[Y].source.media_type}-${D[Y].source.data.slice(0,24)}-${Y}`))}),!d&&T.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:T.map(q=>r.jsx(y0,{notification:q},q.taskId))}),!d&&R.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:R.map((q,Y)=>r.jsx(o_,{output:q},Y))}),!d&&$.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:$.map((q,Y)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(y3,{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(Hn,{components:Yn,remarkPlugins:Qs,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(tt,{"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(Zd,{open:b.open,images:F,initialIndex:b.index,onClose:()=>y(q=>q?{...q,open:!1}:null),onCloseComplete:()=>y(null)},b.index)]})}),w0=w.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(Ce,{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(uu,{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}),j0=w.memo(function(e){const t=B.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=w.useState(!1),c=o??a,{todos:d,completed:u,total:f}=s,m=f>0?u/f*100:0;let p;t[0]!==i?(p=P=>{i==null||i(P),l(P)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(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(tt,{"data-icon":"inline-start"}):r.jsx(Ar,{"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]!==u||t[7]!==f?(b=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[u,"/",f]}),t[6]=u,t[7]=f,t[8]=b):b=t[8];let y;t[9]!==m?(y=m.toFixed(0),t[9]=m,t[10]=y):y=t[10];const v=`${y}% of tasks complete`;let S;t[11]!==m||t[12]!==v?(S=r.jsx(Hr,{value:m,className:"max-w-[200px] flex-1","aria-label":v}),t[11]=m,t[12]=v,t[13]=S):S=t[13];let j;t[14]!==s.inProgress?(j=s.inProgress&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[r.jsx(lt,{className:"size-3 shrink-0 animate-spin"}),r.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=j):j=t[15];let k;t[16]!==g||t[17]!==b||t[18]!==S||t[19]!==j?(k=r.jsxs($t,{render:h,children:[g,x,b,S,j]}),t[16]=g,t[17]=b,t[18]=S,t[19]=j,t[20]=k):k=t[20];let C;t[21]!==d?(C=d.map(i_),t[21]=d,t[22]=C):C=t[22];let N;t[23]!==C?(N=r.jsx(at,{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(it,{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 i_(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(Wn,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?r.jsx(lt,{className:"size-3 shrink-0 animate-spin text-info"}):r.jsx(vd,{className:"size-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:G("truncate text-xs",n.status==="in_progress"?"text-foreground":"text-muted-foreground",n.status==="completed"&&"line-through"),children:n.content}),n.owner&&r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:n.owner})]},n.id??e)}function Jr(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]=w.useState(s);let a;t[3]!==n?(a=d=>{i(u=>{const f=typeof d=="function"?d(u):d;try{localStorage.setItem(n,JSON.stringify(f))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return f})},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 S0(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function a_(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const l_="cogpit:provider-update-dismissals:v1";function c_(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(S0(t)))}async function d_(n){const e=await ve("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function u_(n){const e=await ve("/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 f_=360*60*1e3;function m_(){const[n,e]=w.useState([]),[t,s]=Jr(l_,[]),[o,i]=w.useState(null),[a,l]=w.useState(null);w.useEffect(()=>{const u=new AbortController,f=()=>{d_(u.signal).then(e).catch(()=>{})};f();const m=setInterval(f,f_);return()=>{u.abort(),clearInterval(m)}},[]);const c=w.useCallback(async u=>{i(u),l(null);try{const f=await u_(u);l(f),e(m=>m.map(p=>p.provider===u?f.info:p))}catch(f){l({provider:u,status:"failed",message:f instanceof Error?f.message:"Update failed.",output:null})}finally{i(null)}},[]),d=w.useCallback(u=>{s(f=>a_(f,S0(u)))},[s]);return{pending:c_(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:w.useCallback(()=>l(null),[])}}const p_=5e3,h_={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 Ll(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${h_[n]}`}function ap(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function N0(){const n=B.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=m_(),l=ft("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,u;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const E=setTimeout(a,p_);return()=>clearTimeout(E)},u=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=u):(d=n[2],u=n[3]),w.useEffect(d,u),s){let E;return n[4]!==a||n[5]!==s.message||n[6]!==c?(E=c?r.jsxs(pt,{className:Ll("success"),children:[r.jsx(Rr,{}),r.jsx(Et,{children:s.message}),r.jsx(ht,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(pt,{className:Ll("destructive"),children:[r.jsx(Ys,{}),r.jsx(Et,{children:"Update did not complete"}),r.jsx(ht,{className:"text-destructive/80",children:s.message}),r.jsx(Cs,{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]=E):E=n[7],E}if(e.length===0)return null;const f=e[0],m=e.filter(E=>E.updateCommand!==null&&l),p=pt;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=Ll("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(lt,{className:"animate-spin"}):r.jsx(bn,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==f||n[12]!==e?(x=e.length===1?ap(f):`${e.map(g_).join(" and ")} are out of date`,n[11]=f,n[12]=e,n[13]=x):x=n[13];let b;n[14]!==x?(b=r.jsx(Et,{children:x}),n[14]=x,n[15]=b):b=n[15];const y=e.length>1?e.map(ap).join(" · "):m.length===1?`Cogpit can run \`${f.updateCommand}\` for you.`:f.updateCommand?`Run \`${f.updateCommand}\` to upgrade.`:"Update it with whatever installed it — Cogpit could not tell.";let v;n[16]!==y?(v=r.jsx(ht,{className:"text-warning/80",children:y}),n[16]=y,n[17]=v):v=n[17];const S=Cs,j="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=E=>r.jsxs(ee,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(E.provider),children:[r.jsx(vc,{"data-icon":"inline-start"}),t===E.provider?"Updating…":e.length===1?"Update":`Update ${E.displayName}`]},E.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=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 P;n[25]!==N||n[26]!==_?(P=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]=P):P=n[27];let A;n[28]!==S||n[29]!==C||n[30]!==P?(A=r.jsxs(S,{className:j,children:[C,P]}),n[28]=S,n[29]=C,n[30]=P,n[31]=A):A=n[31];let T;return n[32]!==p||n[33]!==A||n[34]!==h||n[35]!==g||n[36]!==b||n[37]!==v?(T=r.jsxs(p,{className:h,children:[g,b,v,A]}),n[32]=p,n[33]=A,n[34]=h,n[35]=g,n[36]=b,n[37]=v,n[38]=T):T=n[38],T}function g_(n){return n.displayName}function k0(){const n=B.c(27),[e,t]=w.useState(null),[s,o]=w.useState(null),[i,a]=w.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const d=window.electronUpdater;d&&(d.onUpdateAvailable(u=>{t(u)}),d.onUpdateDownloaded(u=>{o(u)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),w.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(vc,{}),n[2]=d):d=n[2];let u;n[3]!==s.version?(u=r.jsxs(Et,{children:["Cogpit v",s.version," is ready"]}),n[3]=s.version,n[4]=u):u=n[4];let f;n[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(ht,{className:"text-success/80",children:"Restart to apply the update."}),n[5]=f):f=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(Cs,{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(st,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==u?(h=r.jsxs(pt,{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,u,f,p]}),n[8]=u,n[9]=h):h=n[9],h}if(e&&!i){let d;n[10]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(vc,{}),n[10]=d):d=n[10];let u;n[11]!==e.version?(u=r.jsxs(Et,{children:["Cogpit v",e.version," is available"]}),n[11]=e.version,n[12]=u):u=n[12];let f;n[13]!==e.platform?(f=e.platform!=="mac"&&r.jsx(ht,{children:"Update through your package manager."}),n[13]=e.platform,n[14]=f):f=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(w3,{"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(Cs,{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]!==u||n[24]!==f||n[25]!==h?(g=r.jsxs(pt,{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,u,f,h]}),n[23]=u,n[24]=f,n[25]=h,n[26]=g):g=n[26],g}return null}const C0=w.createContext(null);function Bi(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(C0.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Ut(){const n=w.useContext(C0);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const Sr=null,{min:Ls,max:Sn,abs:lp,floor:x_}=Math,_0=(n,e,t)=>Ls(t,Sn(e,n)),T0=n=>[...n].sort((e,t)=>e-t),E0=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Hc=()=>{let n;return[new Promise(e=>{n=e}),n]},P0=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},or=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},A0=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},b_=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=Ls(e,n.i),s},Ui=(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+=A0(n,t),n.u[++t]=s;return n.i=e,s},so=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=x_((t+s)/2);Ui(n,i)<=e?(o=i,t=i+1):s=i-1}return _0(o,0,n.l-1)},cp=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:Ls(e-1,n.i),n.l=e,s>0?(or(n.u,s),or(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))},v_=typeof window<"u",y_=n=>n.documentElement,w_=n=>n.ownerDocument,j_=n=>n.defaultView,R0=P0(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),S_=P0(()=>"scrollBehavior"in y_(document).style),N_=n=>Sn(n.h(),n.p()),k_=(n,e=40,t=0,s,o=!1)=>{let i=!!t,a=1,l=0,c=0,d=0,u=0,f=0,m=0,p=0,h=0,g=Sr,x=[0,i?Sn(t-1,0):-1],b=0,y=!1;const v=((E,R,I)=>({o:R,t:I?or(I.slice(0,Ls(E,I.length)),Sn(0,E-I.length)):or([],E),l:E,i:-1,u:or([],E+1)}))(n,s?s[1]:e,s&&s[0]),S=new Set,j=()=>d-c,k=()=>j()+f+u,C=(E,R)=>((I,$,M,O)=>{if(O=Ls(O,I.l-1),Ui(I,O)<=$){const D=so(I,M,O);return[so(I,$,O,D),D]}{const D=so(I,$,void 0,O);return[D,so(I,M,D)]}})(v,E,R,x[0]),N=()=>Ui(v,v.l),_=(E,R)=>{const I=Ui(v,E)-f;return R?N()-I-P(E):I},P=E=>A0(v,E),A=(E,R=-1)=>v.t[E]===R,T=E=>{E&&(R0()&&p!==0||g&&h===1?f+=E:u+=E)};return{v:()=>{S.clear()},m:()=>a,_:()=>(E=>[E.t.slice(),E.o])(v),S:(E=200)=>{if(!y||i)return x;let R,I;if(m)[R,I]=x;else{let $=Sn(0,k()),M=$+l;o||(E=Sn(0,E),p!==1&&($-=E),p!==2&&(M+=E)),[R,I]=x=C(Sn(0,$),Sn(0,M)),g&&(R=Ls(R,g[0]),I=Sn(I,g[1]))}return[Sn(R,0),Ls(I,v.l-1)]},$:E=>so(v,E-c),I:A,k:_,R:P,T:()=>v.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:N,H:()=>(m=u,u=0,[m,h===2]),W:(E,R)=>{const I=[E,R];return S.add(I),()=>{S.delete(I)}},B:(E,R)=>{let I,$,M=0;switch(E){case 1:{if(R===d&&h===0)break;const O=m;m=0;const D=R-d,L=lp(D);O&&L<lp(O)+1||h!==0||(p=D<0?2:1),i&&(i=!1),d=R,M=4;const F=j();F>=-l&&F<=N()&&(M+=1,$=L>l);break}case 2:M=8,p!==0&&(I=!0,M+=1),p=0,h=0,g=Sr;break;case 3:{const O=R.filter(([D,L])=>!A(D,L));if(!O.length)break;T(O.reduce((D,[L,F])=>{let z;if(h===2)z=!0;else if(g&&h===1)z=L<g[0];else{const W=j(),U=_(L),H=P(L);z=p!==1&&h===0?U+H<=W:U<W&&U+H<W+l}return z&&(D+=F-P(L)),D},0));for(const[D,L]of O){const F=P(D),z=b_(v,D,L);o&&(b+=z?L:L-F)}o&&l&&b>l&&(T(((D,L)=>{let F=0;const z=[];D.t.forEach((Y,V)=>{Y!==-1&&(z.push(Y),V<L&&F++)}),D.i=-1;const W=T0(z),U=W.length,H=U/2|0,K=U%2==0?(W[H-1]+W[H])/2:W[H],q=D.o;return((D.o=K)-q)*Sn(L-F,0)})(v,so(v,k()))),o=!1),M=3,$=!0;break}case 4:l!==R&&(l||(y=$=!0),l=R,M=3);break;case 5:R[1]?(T(cp(v,R[0],!0)),h=2,M=1):(cp(v,R[0]),M=1);break;case 6:c=R;break;case 7:h=1;break;case 8:g=C(R,R+l),M=1}M&&(a=1+(2147483647&a),I&&f&&(u+=f,f=0),S.forEach(([O,D])=>{M&O&&D($)}))}}},fu=setTimeout,zl=(n,e)=>e?-n:n,C_=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,u=!1,f=!1;const m=(()=>{let b;const y=()=>{b!=Sr&&clearTimeout(b)},v=()=>{y(),b=fu(()=>{b=Sr,(()=>{if(c||d)return c=!1,void m();u=!1,n.B(2)})()},150)};return v.J=y,v})(),p=()=>{l=a(),u&&(f=!0),n.B(1,s()),m()},h=b=>{if(c||!n.M()||b.ctrlKey)return;const y=a()-l;150>y&&50<y&&(t?b.deltaX:b.deltaY)&&(c=!0)},g=()=>{d=!0,u=f=!1},x=()=>{d=!1,R0()&&(u=!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,y]=n.H();b&&(o(b,y,f),f=!1,y&&n.p()>n.h()&&n.B(1,s()))}}},__=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=Hc();return s=()=>{c(!1)},n.p()&&fu(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&S_())n.B(8,o()),E0(async()=>{for(;;){let l=!0;for(let[u,f]=n.S();u<=f;u++)if(n.I(u)){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()}]},T_=(n,e)=>{let t,s,o=Hc(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=__(n,()=>o[0],(u,f)=>{u=zl(u,i),f?t.scrollTo({[e?"left":"top"]:u,behavior:"smooth"}):t[a]=u});return{N(u,f){t=f,e&&(i=getComputedStyle(f).direction==="rtl"),s=C_(n,f,e,()=>zl(f[a],i),(m,p,h)=>{if(h){const g=f.style,x=g[l];g[l]="hidden",fu(()=>{g[l]=x})}f[a]=zl(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=Hc()},P:()=>i,V(u){c(()=>u)},X(u){u+=n.C(),c(()=>u)},Y(u,{align:f,smooth:m,offset:p=0}={}){if(u=_0(u,0,n.T()-1),f==="nearest"){const h=n.k(u),g=n.C();if(h<g)f="start";else{if(!(h+n.R(u)>g+n.p()))return;f="end"}}c(()=>p+n.O()+n.k(u)+(f==="end"?n.R(u)-n.p():f==="center"?(n.R(u)-n.p())/2:0),m)},q:()=>{s&&s.L()}}},E_=n=>{let e;return{j(t){(e||(e=new(j_(w_(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},P_=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=E_(a=>{const l=[];for(const{target:c,contentRect:d}of a)if(c.offsetParent)if(c===t)n.B(4,d[s]);else{const u=o.get(c);u!=Sr&&l.push([u,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}},Qi=v_?w.useLayoutEffect:w.useEffect,on="current",$0=(n,e)=>{if(Array.isArray(n))for(const t of n)$0(t,e);else n==null||typeof n=="boolean"||e.push(n)},A_=(n,e)=>{const t=n.key;return t??"_"+e},R_=n=>{const e=w.useRef(null);return e[on]||(e[on]=n())},dp=n=>{const e=w.useRef(n);return Qi(()=>{e[on]=n},[n]),e},$_=w.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=w.useRef(null);Qi(()=>e(c[on],t),[t]);const d=w.useMemo(()=>{const u={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&&(u.display="inline-flex"),u},[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})}),I_=(n,e)=>w.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return $0(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),M_=w.forwardRef(({children:n,data:e,bufferSize:t,itemSize:s,shift:o,horizontal:i,keepMounted:a,cache:l,startMargin:c=0,ssrCount:d,as:u="div",item:f="div",scrollRef:m,onScroll:p,onScrollEnd:h},g)=>{const[x,b]=I_(n,e),y=w.useRef(null),v=w.useRef(!!d),S=dp(p),j=dp(h),[k,C,N,_]=R_(()=>{const M=!!i,O=k_(b,s,d,l,!s);return[O,P_(O,M),T_(O,M),M]});b!==k.T()&&k.B(5,[b,o]),c!==k.O()&&k.B(6,c);const[P,A]=w.useReducer(k.m,void 0,k.m),T=k.M(),E=k.h(),R=N.P(),I=[],$=M=>{const O=x(M);return r.jsx($_,{ee:C.U,te:M,oe:k.k(M,R),ne:k.I(M),re:f,Z:O,se:_,ie:v[on]},A_(O,M))};if(Qi(()=>{v[on]=!1,k.W(1,D=>{D?iy.flushSync(A):A()}),k.W(4,()=>{S[on]&&S[on](k.C())}),k.W(8,()=>{j[on]&&j[on]()});const M=y[on],O=D=>{C.G(D),N.N(M,D)};return m?E0(()=>{m[on]&&O(m[on])}):O(M.parentElement),()=>{k.v(),C.v(),N.v()}},[]),Qi(()=>{N.q()},[P]),w.useImperativeHandle(g,()=>({get cache(){return k._()},get scrollOffset(){return k.C()},get scrollSize(){return N_(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[O,D]=k.S(t);O<=D;O++)M.add(O);T0([...M]).forEach(O=>{I.push($(O))})}else for(let[M,O]=k.S(t);M<=O;M++)I.push($(M));return r.jsx(u,{ref:y,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:_?E:"100%",height:_?"100%":E,pointerEvents:T?"none":void 0},children:I})});function O_(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(yd,{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(kt,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(j3,{"data-icon":"inline-start"}),e[9]=u):u=e[9];let f;e[10]!==s?(f=r.jsxs(ee,{variant:"default",size:"sm",onClick:s,children:[u,"Redo all"]}),e[10]=s,e[11]=f):f=e[11];let m;return e[12]!==c||e[13]!==f?(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,f]}),e[12]=c,e[13]=f,e[14]=m):m=e[14],m}const up=new Map;function D_(n){let e=up.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},up.set(n,e)}return e}function I0(n){const e=B.c(5),t="100%",s=w.useRef(null),[o,i]=w.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:u,callbacks:f}=D_(t);return f.set(d,i),u.observe(d),()=>{u.unobserve(d),f.delete(d)}},l=[t],e[0]=t,e[1]=a,e[2]=l):(a=e[1],l=e[2]),w.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 Zi(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 fp(n){const e=Zi(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Zi(n.lastModified)}function mp(n,e){return n===e?0:e-n}function pp(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function L_(n,e){const t=mp(fp(n),fp(e));if(t!==0)return t;const s=mp(Zi(n.lastModified),Zi(e.lastModified));return s!==0?s:pp(n).localeCompare(pp(e))}function mu(n){return[...n].sort(L_)}function M0(n,e){const t=!!(n.teamName&&n.agentName);return e||Cn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const z_="Unknown project";function pu(n){const e=Aa(n);return Pa(e?e.parentPath:n,2)||z_}function F_(n){return pu(n.cwd||Tn(n.dirName))}function B_(n){const e=mu(n),t=new Map;for(const s of e){const o=F_(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function O0(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function U_(n,e,t){let s=-1;return n.forEach((o,i)=>{O0(o,e)&&(s=i)}),Math.max(t,s+1)}const hu=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),W_=12e4;function H_(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<W_}function D0(n,e,t=Date.now()){return O0(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:H_(n,t)}function K_(n,e,t=Date.now()){return n.some(s=>D0(s,e,t))}const q_="cogpit:session-list-cache",V_=10080*60*1e3,G_=24,es={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},Kc=new Map;function Y_(){return{version:1,entries:{}}}function L0(){return Kt(q_)}function z0(){const n=L0(),e=Kc.get(n);if(e)return e;let t=Y_();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 Kc.set(n,t),t}function F0(n){const e=z0().entries[n];if(!(!e||Date.now()-e.savedAt>V_))return e.value}function B0(n,e){const t=L0(),o={...z0().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,G_))};Kc.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function ea(n){const e=F0(n);return Array.isArray(e)?e:void 0}function rr(n,e){B0(n,e)}function U0(n){return`sessions:${n}`}function X_(n){const e=F0(U0(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function J_(n,e){B0(U0(n),e)}const Q_=2e4;function Z_(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 W0=w.createContext(null);function e7({children:n}){const[e]=w.useState(kn),[t,s]=w.useState(()=>ea(es.activeSessions)??[]),[o,i]=w.useState(()=>ea(es.runningProcesses)??[]),[a,l]=w.useState(!1),[c,d]=w.useState(null),[u,f]=w.useState(new Set),m=w.useRef(null),p=w.useRef(null),h=w.useRef(!1);w.useEffect(()=>(h.current=!0,()=>{var k;h.current=!1,(k=p.current)==null||k.abort(),p.current=null}),[]);const g=w.useCallback(async()=>{var N;if(!h.current||kn()!==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&&kn()===e;l(!0);try{const[_,P]=await Promise.all([ve("/api/active-sessions",{signal:k.signal}),ve("/api/running-processes",{signal:k.signal})]);if(!C())return;if(!_.ok||!P.ok)throw new Error("Failed to fetch live data");const[A,T]=await Promise.all([_.json(),P.json()]);if(!C())return;const E=Array.isArray(A)?A:[],R=Array.isArray(T)?T:[];s(E),i(R),rr(es.activeSessions,E),rr(es.runningProcesses,R),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=w.useCallback(()=>{g()},[g]);w.useEffect(()=>{x()},[x]);const b=w.useMemo(()=>Z_(o),[o]),y=w.useMemo(()=>K_(t,b),[t,b]);w.useEffect(()=>(window.addEventListener("focus",x),()=>window.removeEventListener("focus",x)),[x]),w.useEffect(()=>{if(!y)return;const k=setInterval(()=>{document.visibilityState==="visible"&&x()},Q_);return()=>clearInterval(k)},[y,x]),w.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&&f(N=>{let _=null;for(const[P,A]of C)A==="completed"&&k.get(P)!=="completed"&&(_??(_=new Set(N)),_.add(P));for(const P of N)C.get(P)!=="completed"&&(_??(_=new Set(N)),_.delete(P));return _??N}),m.current=C},[t,b]);const v=w.useCallback(k=>{f(C=>{if(!C.has(k))return C;const N=new Set(C);return N.delete(k),N})},[]),S=w.useCallback(k=>{s(C=>{const N=C.filter(_=>_.sessionId!==k);return kn()===e&&rr(es.activeSessions,N),N})},[e]),j=w.useMemo(()=>({sessions:t,processes:o,procBySession:b,newlyCompleted:u,loading:a,error:c,refresh:x,removeSession:S,acknowledgeCompleted:v}),[t,o,b,u,a,c,x,S,v]);return r.jsx(W0.Provider,{value:j,children:n})}function H0(){const n=gu();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function gu(){return w.useContext(W0)}const hp=[20,50,80,110,140,170,200,230,260,290,320,350];function t7(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return hp[(e>>>0)%hp.length]}function Fl(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 n7(n){const e=n.split(`
86
+ `);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=Fl(e[t]??"");return s?{subject:s,preview:Fl(e.slice(t+1).join(`
87
+ `))}:{subject:Fl(n),preview:""}}function qc(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function s7(n,e){return n===null||e===null||e<n?null:e-n}function o7(n){const e=qc(n);return e===null?null:new Date(e).toLocaleTimeString()}function r7(n){var s;const e=(s=gu())==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=hu.has(i)?"working":"idle"}return t}const i7=w.memo(function(e){const t=B.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=w.useState(!1);let u;t[0]!==o?(u=Uk(o),t[0]=o,t[1]=u):u=t[1];const f=u;let m;t[2]!==f?(m=n7(f),t[2]=f,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=o7(i),t[4]=i,t[5]=g):g=t[5];const x=g,b=r7(s);let y;t[6]!==f?(y=Vk(f),t[6]=f,t[7]=y):y=t[7];const v=y,S=v&&!a,j=qc(i),k=a?s7(j,qc(a.timestamp)):null,C=!a&&l===!0,N=!!a||v;fg(C&&N);const _=!0;let P;t[8]!==s?(P=t7(s),t[8]=s,t[9]=P):P=t[9];const A=String(P);let T;t[10]!==A?(T={"--agent-hue":A},t[10]=A,t[11]=T):T=t[11];const E=T,R="my-2 rounded-lg border border-l-[3px] border-border bg-card px-3 py-2 [border-left-color:oklch(0.52_0.16_var(--agent-hue))] dark:[border-left-color:oklch(0.74_0.14_var(--agent-hue))]";let I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(S3,{className:"size-3.5 shrink-0 text-[oklch(0.52_0.16_var(--agent-hue))] dark:text-[oklch(0.74_0.14_var(--agent-hue))]","data-icon":"inline-start"}),t[12]=I):I=t[12];let $;t[13]!==s?($=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]=$):$=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 O;t[18]!==$||t[19]!==M?(O=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[I,$,M]}),t[18]=$,t[19]=M,t[20]=O):O=t[20];let D;t[21]!==S?(D=S&&r.jsx(Ce,{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]=S,t[22]=D):D=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]!==D||t[26]!==L?(F=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[D,L]}),t[25]=D,t[26]=L,t[27]=F):F=t[27];let z;t[28]!==O||t[29]!==F?(z=r.jsxs("div",{className:"flex items-center gap-2",children:[O,F]}),t[28]=O,t[29]=F,t[30]=z):z=t[30];let W;t[31]!==f||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(Hn,{components:Yn,remarkPlugins:Qs,children:f})}):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]=f,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 ${Un(k)} later`,a.summary&&` · "${a.summary}"`]}):C?j===null?"Awaiting your reply":`Awaiting your reply · ${Un(Math.max(0,Date.now()-j))}`:"Never answered"});let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=()=>d(a7),t[36]=K):K=t[36];let q;t[37]!==f||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(tt,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Je,{"data-icon":"inline-start"})," Expand ·"," ",f.length.toLocaleString("en-US")," ",f.length===1?"char":"chars"]})}),t[37]=f,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 V;return t[43]!==z||t[44]!==W||t[45]!==Y||t[46]!==E?(V=r.jsxs("div",{"data-agent-rail":_,style:E,className:R,children:[z,W,Y]}),t[43]=z,t[44]=W,t[45]=Y,t[46]=E,t[47]=V):V=t[47],V});function a7(n){return!n}const l7=1500;function Hs(){const n=B.c(5),[e,t]=w.useState(!1),s=w.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]),w.useEffect(o,i);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async d=>{await Dr(d)&&(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),l7))},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 c7=w.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=m0(s),t[0]=s,t[1]=d):d=t[1];const u=d,[f,m]=Hs();if(!s)return null;let p;t[2]!==c||t[3]!==f||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:Js(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":f?"Response copied":"Copy response",title:f?"Copied":"Copy response",children:f?r.jsx(gt,{"data-icon":"inline-start"}):r.jsx(Rn,{"data-icon":"inline-start"})})]}),t[2]=c,t[3]=f,t[4]=m,t[5]=i,t[6]=o,t[7]=s,t[8]=a,t[9]=p):p=t[9];const h=c&&"leading-relaxed";let g;t[10]!==h?(g=G("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==u?(x=r.jsx(Hn,{components:Yn,remarkPlugins:Qs,children:u}),t[12]=u,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 y;return t[17]!==p||t[18]!==b?(y=r.jsxs("div",{className:"group",children:[p,b]}),t[17]=p,t[18]=b,t[19]=y):y=t[19],y}),ho=[];function d7(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 u7(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 gp=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function f7(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){gp.lastIndex=0;let i;for(;(i=gp.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 m7(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 p7(n){return n.filter(e=>e.parentToolUseId===null)}function h7(n,e){return n.filter(t=>t.parentToolUseId===e)}const K0={},q0=w.createContext(ho),V0=w.createContext(K0);function Bl(n){const e=B.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?K0:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(V0.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(q0.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function xu(){return w.useContext(q0)}function g7(n){return w.useContext(V0)[n]??null}function oo(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 G0={...Yn,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},x7={...G0,h1:oo("h1"),h2:oo("h2"),h3:oo("h3"),h4:oo("h4"),h5:oo("h5"),h6:oo("h6")},bu=w.memo(function(e){const t=B.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?x7:G0;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(Hn,{components:a,remarkPlugins:Qs,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),xp=400,b7=24,vu=w.memo(function(e){const t=B.c(24),{toolUseId:s}=e,o=xu(),i=g7(s),a=w.useRef(null),[l,c]=w.useState(!0);let d,u,f;if(t[0]!==l||t[1]!==o||t[2]!==s){f=h7(o,s).flatMap(v7).filter(y7).map(w7).join(`
89
+ `);const k=f.split(`
90
+ `);d=l&&k.length>xp,u=d?k.slice(-xp).join(`
91
+ `):f,t[0]=l,t[1]=o,t[2]=s,t[3]=d,t[4]=u,t[5]=f}else d=t[3],u=t[4],f=t[5];const m=u;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<b7;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],w.useLayoutEffect(g,x),!f&&!i)return null;const b=i?"live-subagent-summary":void 0;let y;t[12]!==i?(y=i??r.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=i,t[13]=y):y=t[13];let v;t[14]!==b||t[15]!==y?(v=r.jsx("div",{"data-testid":b,className:"mb-1 text-xs font-medium text-muted-foreground",children:y}),t[14]=b,t[15]=y,t[16]=v):v=t[16];let S;t[17]!==d||t[18]!==m||t[19]!==f?(S=f&&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(bu,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=f,t[20]=S):S=t[20];let j;return t[21]!==v||t[22]!==S?(j=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[v,S]}),t[21]=v,t[22]=S,t[23]=j):j=t[23],j});function v7(n){return n.blocks}function y7(n){return n.blockType!=="tool_use"&&n.text}function w7(n){return n.text}function bp(n){return n.length>8?n.slice(0,8):n}function yu(n,e,t){const s=e??t;return s?`${s} - ${bp(n)}`:bp(n)}function j7(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,yu(t.agentId,t.subagentType,t.agentName));return e}function S7(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 N7(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
92
+ `):""}function Y0(n,e){if(Gx(n))return au(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,u=a.timestamp??"";if(l==="assistant"){const f={agentId:e,agentName:null,subagentType:null,type:"assistant",content:d,toolCalls:[],thinking:[],text:[],timestamp:u,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")f.thinking.push(m.thinking);else if(m.type==="text")f.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:u};f.toolCalls.push(p),s.set(m.id,p)}}t.push(f)}else if(l==="user"&&Array.isArray(d)){for(const f of d)if(f.type==="tool_result"){const m=s.get(f.tool_use_id);m&&(m.result=N7(f.content),m.isError=f.is_error??!1)}}}return t}const Ul=new Map;function k7(n,e){const t=B.c(21),{session:s,sessionSource:o,isLive:i}=ct();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=w.useState(a),[d,u]=w.useState(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,t[1]=f):f=t[1];const m=w.useRef(f);let p;if(t[2]!==i||t[3]!==n){let _;t[5]!==i?(_=P=>P.text.length>0||P.thinking.length>0||P.toolCalls.length>0?!1:i?P.durationMs!=null:P.status==="async_launched",t[5]=i,t[6]=_):_=t[6],p=n.filter(_),t[2]=i,t[3]=n,t[4]=p}else p=t[4];const h=p,g=o==null?void 0:o.dirName,x=s==null?void 0:s.sessionId;let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=Oa(window.location.pathname),t[7]=b):b=t[7];const y=b;let v,S;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(v=()=>{if(y||!e||!g||!x||h.length===0)return;const _=[];for(const T of h){const E=Kt(`${g}/${x}/${T.agentId}`);if(!m.current.has(E)){if(Ul.has(E)){c(R=>{const I=new Map(R);return I.set(T.agentId,Ul.get(E)),I}),m.current.add(E);continue}_.push({agentId:T.agentId,cacheKey:E})}}if(_.length===0)return;let P=!1;return u(!0),async function(){const E=new Map;await Promise.all(_.map(async R=>{const{agentId:I,cacheKey:$}=R;try{const M=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent(I)}.jsonl`,O=await ve(M);if(!O.ok)return;const D=await O.text(),L=Y0(D,I);Ul.set($,L),m.current.add($),E.set(I,L)}catch{}})),!P&&E.size>0&&c(R=>{const I=new Map(R);for(const[$,M]of E)I.set($,M);return I}),P||u(!1)}(),()=>{P=!0}},S=[y,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=v,t[13]=S):(v=t[12],S=t[13]),w.useEffect(v,S);let j;e:{if(l.size===0&&h.length===0){j=n;break e}let _;if(t[14]!==l||t[15]!==n){_=[];for(const P of n){const A=l.get(P.agentId);if(A&&A.length>0&&(P.status==="async_launched"||P.durationMs!=null)){const T={...A[0],durationMs:P.durationMs,toolUseCount:P.toolUseCount,status:P.status,prompt:P.prompt,agentName:P.agentName,subagentType:P.subagentType};_.push(T,...A.slice(1))}else _.push(P)}t[14]=l,t[15]=n,t[16]=_}else _=t[16];j=_}const k=j,C=y&&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 X0=w.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,u]=w.useState(!1),f=o||d,{sessionSource:m,actions:p}=ct(),h=m==null?void 0:m.dirName;let g;t[0]!==h?(g=ko(h),t[0]=h,t[1]=g):g=t[1];const x=g.subagentTranscripts,{enrichedMessages:b,isLoading:y,unavailable:v}=k7(s,c&&f&&x);let S;e:{if(!(m!=null&&m.fileName)){S=null;break e}let X;t[2]!==m.fileName?(X=Ns(m.fileName),t[2]=m.fileName,t[3]=X):X=t[3];const Z=X;if(Z){S=Z.parentSessionId;break e}let te;if(t[4]!==m.fileName){let oe;t[6]===Symbol.for("react.memo_cache_sentinel")?(oe=/^([^/]+)\.jsonl$/,t[6]=oe):oe=t[6],te=m.fileName.match(oe),t[4]=m.fileName,t[5]=te}else te=t[5];const ne=te;S=(ne==null?void 0:ne[1])??null}const j=S;let k;t[7]!==b?(k=new Set(b.map(_7)),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?(_=j7(b),t[11]=b,t[12]=_):_=t[12];const P=_;let A;if(t[13]!==b||t[14]!==s){A=new Map;for(const X of[...s,...b]){const Z=A.get(X.agentId)??{};X.durationMs!=null&&(Z.durationMs=X.durationMs),X.toolUseCount!=null&&(Z.toolUseCount=X.toolUseCount),X.status&&(Z.status=X.status),A.set(X.agentId,Z)}t[13]=b,t[14]=s,t[15]=A}else A=t[15];const T=A;let E;t[16]!==b||t[17]!==s?(E=S7([...s,...b]),t[16]=b,t[17]=s,t[18]=E):E=t[18];const R=E;let I,$;if(t[19]!==b){$=new Map,I=new Map;for(const X of b)I.set(X.agentId,X),X.text.length>0&&$.set(X.agentId,X);t[19]=b,t[20]=I,t[21]=$}else I=t[20],$=t[21];let M;if(t[22]!==N||t[23]!==I||t[24]!==$){M=new Map;for(const X of N){const Z=$.get(X)??I.get(X);Z&&M.set(X,Z)}t[22]=N,t[23]=I,t[24]=$,t[25]=M}else M=t[25];const O=M;let D;e:{let X=0,Z=0,te=!1,ne=!0;for(const re of s)re.durationMs!=null&&(X=X+re.durationMs,te=!0),re.toolUseCount!=null&&(Z=Z+re.toolUseCount),re.status&&re.status!=="completed"&&(ne=!1);if(!te){D=null;break e}let oe;t[26]!==ne||t[27]!==X||t[28]!==Z?(oe={totalDuration:X,totalToolUses:Z,allCompleted:ne},t[26]=ne,t[27]=X,t[28]=Z,t[29]=oe):oe=t[29],D=oe}const L=D;if(s.length===0)return null;let F;t[30]!==d?(F=()=>u(!d),t[30]=d,t[31]=F):F=t[31];let z;t[32]!==f?(z=f?r.jsx(tt,{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]=f,t[33]=z):z=t[33];let W;t[34]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(os,{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(Ce,{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]!==P?(K=N.map(X=>r.jsx(Ce,{variant:"outline",children:P.get(X)},X)),t[40]=N,t[41]=P,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(Wn,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(Ys,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Fs,{className:"size-3","data-icon":"inline-start"}),Un(L.totalDuration)]}),L.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ba,{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 V;t[53]!==N||t[54]!==f||t[55]!==R?(V=!f&&N.map(X=>{const Z=R.get(X);return Z?r.jsx(vu,{toolUseId:Z},X):null}),t[53]=N,t[54]=f,t[55]=R,t[56]=V):V=t[56];let J;t[57]!==p||t[58]!==N||t[59]!==P||t[60]!==O||t[61]!==x||t[62]!==y||t[63]!==f||t[64]!==j||t[65]!==R||t[66]!==m||t[67]!==T||t[68]!==v?(J=f&&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."}):y&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[r.jsx(lt,{className:"size-3 animate-spin"}),"Loading agent output..."]}),N.map(X=>{const Z=O.get(X),te=T.get(X),ne=x&&!!m&&!!j&&!v;return r.jsx(C7,{agentLabel:P.get(X)??X,message:Z,stats:te,parentToolUseId:R.get(X),canNavigate:ne,onOpen:()=>{ne&&p.handleLoadSession(m.dirName,`${j}/subagents/agent-${X}.jsonl`)}},X)})]}),t[57]=p,t[58]=N,t[59]=P,t[60]=O,t[61]=x,t[62]=y,t[63]=f,t[64]=j,t[65]=R,t[66]=m,t[67]=T,t[68]=v,t[69]=J):J=t[69];let Q;return t[70]!==Y||t[71]!==V||t[72]!==J?(Q=r.jsxs("div",{children:[Y,V,J]}),t[70]=Y,t[71]=V,t[72]=J,t[73]=Q):Q=t[73],Q});function C7(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=m0((c??[]).join(`
96
+
97
+ `)),e[0]=c,e[1]=d):d=e[1];const u=d,f=((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(Ce,{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(Wn,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Fs,{className:"size-3"}),Un(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ba,{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(N1,{"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 y;e[14]!==f||e[15]!==m||e[16]!==u||e[17]!==i?(y=f?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(Hn,{components:Yn,remarkPlugins:Qs,children:u})}):r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"inline-flex items-center gap-1.5 text-xs italic text-muted-foreground",children:m?r.jsxs(r.Fragment,{children:[r.jsx(lt,{className:"size-3 animate-spin"}),"Working — no return yet"]}):r.jsx(r.Fragment,{children:"No return message from this agent"})}),i&&r.jsx(vu,{toolUseId:i})]}),e[14]=f,e[15]=m,e[16]=u,e[17]=i,e[18]=y):y=e[18];let v;return e[19]!==b||e[20]!==y?(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,y]})}),e[19]=b,e[20]=y,e[21]=v):v=e[21],v}function _7(n){return n.agentId}const T7=w.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(X0,{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}),E7=w.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(X0,{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}),P7=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),A7=w.memo(function(e){const t=B.c(30),{events:s}=e,[o,i]=w.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(R7),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?tt:Je,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let u;t[2]!==d?(u=G("my-1 rounded-md border px-2 py-1 text-xs",d),t[2]=d,t[3]=u):u=t[3];let f;t[4]===Symbol.for("react.memo_cache_sentinel")?(f=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]=f):f=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(qt,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(N3,{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($7).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 y;t[16]!==b||t[17]!==m||t[18]!==p||t[19]!==g?(y=r.jsxs($t,{render:f,children:[m,p,g,b]}),t[16]=b,t[17]=m,t[18]=p,t[19]=g,t[20]=y):y=t[20];let v;t[21]!==s?(v=s.map(I7),t[21]=s,t[22]=v):v=t[22];let S;t[23]!==v?(S=r.jsx(at,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:v})}),t[23]=v,t[24]=S):S=t[24];let j;return t[25]!==o||t[26]!==y||t[27]!==S||t[28]!==u?(j=r.jsxs(it,{open:o,onOpenChange:i,className:u,children:[y,S]}),t[25]=o,t[26]=y,t[27]=S,t[28]=u,t[29]=j):j=t[29],j});function R7(n){return P7.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function $7(n){return n.eventName}function I7(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 vp=768;function Ya(){const n=B.c(2),[e,t]=w.useState(typeof window<"u"?window.innerWidth<vp:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${vp-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]),w.useEffect(s,o),e}const M7=24,Ko=[];function O7(n,e){for(let s=0;s<Ko.length;s++){const o=Ko[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=L7(n,e);return Ko.length>=M7&&Ko.shift(),Ko.push({oldStr:n,newStr:e,result:t}),t}const D7=25e4;function L7(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,u=[];for(let f=0;f<a;f++)u.push({type:"unchanged",text:t[f],oldIdx:f,newIdx:f});if(!(c===0&&d===0))if(c===0)for(let f=0;f<d;f++)u.push({type:"added",text:s[a+f],newIdx:a+f});else if(d===0)for(let f=0;f<c;f++)u.push({type:"removed",text:t[a+f],oldIdx:a+f});else if(c*d>D7){for(let f=0;f<c;f++)u.push({type:"removed",text:t[a+f],oldIdx:a+f});for(let f=0;f<d;f++)u.push({type:"added",text:s[a+f],newIdx:a+f})}else{const f=d+1,m=new Int32Array((c+1)*f);for(let x=1;x<=c;x++){const b=t[a+x-1],y=x*f,v=y-f;for(let S=1;S<=d;S++)if(b===s[a+S-1])m[y+S]=m[v+S-1]+1;else{const j=m[v+S],k=m[y+S-1];m[y+S]=j>k?j: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*f+g-1]>=m[(h-1)*f+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(),u.push(...p)}for(let f=0;f<l;f++){const m=o-l+f,p=i-l+f;u.push({type:"unchanged",text:t[m],oldIdx:m,newIdx:p})}return u}function z7(n,e,t,s){const o=B.c(9),[i,a]=w.useState(null),[l,c]=w.useState(null);let d,u;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=rx(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||sx().then(async x=>{if(h||(await ox(x,m),h))return;const b=x.codeToTokens(n,{lang:m,theme:p});if(h)return;a(b.tokens);const y=x.codeToTokens(e,{lang:m,theme:p});h||c(y.tokens)}).catch(x=>{console.warn("[EditDiffView] highlight failed:",x),h||(a(null),c(null))})});return()=>{h=!0,cancelAnimationFrame(g)}},u=[n,e,t,s],o[0]=t,o[1]=s,o[2]=e,o[3]=n,o[4]=d,o[5]=u):(d=o[4],u=o[5]),w.useEffect(d,u);let f;return o[6]!==l||o[7]!==i?(f={oldTokens:i,newTokens:l},o[6]=l,o[7]=i,o[8]=f):f=o[8],f}const F7={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},yp={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},B7={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function U7(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:G(e&&"opacity-50"),children:t.content},s))}function W7(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 H7(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(S1,{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(Bn,{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 Wl=3;function K7(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<=Wl*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-Wl);a<=Math.min(n.length-1,i+Wl);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 q7(n){const e=B.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(ja,{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 wp=w.memo(function(e){const t=B.c(33),{line:s,lineNum:o,oldTokens:i,newTokens:a}=e;let l,c,d,u,f,m;if(t[0]!==s||t[1]!==o||t[2]!==a||t[3]!==i){m=W7(s,i,a);const x=F7[s.type];t[10]!==x?(d=G("flex",x),t[10]=x,t[11]=d):d=t[11];const b=yp[s.type];let y;t[12]!==b?(y=G("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",b),t[12]=b,t[13]=y):y=t[13],t[14]!==o||t[15]!==y?(u=r.jsx("span",{className:y,children:o}),t[14]=o,t[15]=y,t[16]=u):u=t[16];const v=yp[s.type];let S;t[17]!==v?(S=G("select-none shrink-0 w-5 text-right pr-1 border-r",v),t[17]=v,t[18]=S):S=t[18];let j;t[19]!==s.type?(j=r.jsx(H7,{type:s.type}),t[19]=s.type,t[20]=j):j=t[20],t[21]!==S||t[22]!==j?(f=r.jsx("span",{className:S,children:j}),t[21]=S,t[22]=j,t[23]=f):f=t[23],l="pl-2 whitespace-pre",c=m?U7(m,s.type==="unchanged"):r.jsx("span",{className:B7[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]=u,t[8]=f,t[9]=m}else l=t[4],c=t[5],d=t[6],u=t[7],f=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]!==u||t[30]!==f||t[31]!==h?(g=r.jsxs("div",{className:d,children:[u,f,h]}),t[28]=d,t[29]=u,t[30]=f,t[31]=h,t[32]=g):g=t[32],g}),jp=120,Sp=60,V7=120;function Np(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,u]=w.useState(c);let f;e[1]!==t?(f=K7(t),e[1]=t,e[2]=f):f=e[2];const m=f,p=m.length>jp,[h,g]=w.useState(p?Sp:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>jp?Sp: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],w.useEffect(x,b);let y,v;e[7]!==m.length||e[8]!==h?(y=()=>{if(h>=m.length)return;const T=requestAnimationFrame(()=>{g(E=>Math.min(E+V7,m.length))});return()=>cancelAnimationFrame(T)},v=[h,m.length],e[7]=m.length,e[8]=h,e[9]=y,e[10]=v):(y=e[9],v=e[10]),w.useEffect(y,v);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=T=>{u(E=>new Set(E).add(T))},e[11]=S):S=e[11];const j=S;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?(_=G("overflow-x-auto font-mono text-xs leading-relaxed",N),e[16]=N,e[17]=_):_=e[17];let P;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let T;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(T=(E,R)=>{if(E.kind==="separator")return d.has(E.fromIdx)?t.slice(E.fromIdx,E.toIdx+1).map((M,O)=>{const D=E.fromIdx+O;return r.jsx(wp,{line:M,lineNum:M.type==="removed"?(M.oldIdx??0)+l:(M.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${D}`)}):r.jsx(q7,{count:E.count,onExpand:()=>j(E.fromIdx)},`sep-${R}`);const{line:I}=E,$=I.type==="removed"?(I.oldIdx??0)+l:(I.newIdx??0)+l;return r.jsx(wp,{line:I,lineNum:$,oldTokens:s,newTokens:o},R)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=T):T=e[30],P=C.map(T),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=P}else P=e[24];let A;return e[31]!==_||e[32]!==P?(A=r.jsx("div",{className:_,children:P}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}function kp(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 u;e[5]!==a?(u=a>0&&r.jsxs("span",{className:"text-success",children:["+",a]}),e[5]=a,e[6]=u):u=e[6];let f;return e[7]!==c||e[8]!==d||e[9]!==u?(f=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[c,d,u]}),e[7]=c,e[8]=d,e[9]=u,e[10]=f):f=e[10],f}function wu(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,u=l===void 0?!1:l,[f,m]=w.useState(!1),p=Vr();let h;e[0]!==s||e[1]!==t?(h=O7(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:b}=z7(t,s,o,p);let y;e[3]!==o?(y=o.split("/").slice(-3).join("/"),e[3]=o,e[4]=y):y=e[4];const v=y,S=c&&"mt-1.5",j=u&&"border-0 rounded-none";let k;e[5]!==S||e[6]!==j?(k=G("overflow-hidden rounded border border-border bg-muted/20",S,j),e[5]=S,e[6]=j,e[7]=k):k=e[7];let C;e[8]!==u||e[9]!==c||e[10]!==g||e[11]!==v?(C=!u&&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(kp,{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(ya,{"data-icon":"icon"})})]})]}),e[8]=u,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(Np,{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 P;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==f||e[27]!==b||e[28]!==x||e[29]!==d?(P=c&&r.jsx(rs,{open:f,onOpenChange:m,children:r.jsxs(is,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(Ps,{children:[r.jsxs(as,{className:"font-mono text-sm text-foreground flex items-center gap-3",children:[o,r.jsx(kp,{lines:g})]}),r.jsx(ls,{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(Np,{lines:g,oldTokens:x,newTokens:b,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=f,e[27]=b,e[28]=x,e[29]=d,e[30]=P):P=e[30];let A;return e[31]!==_||e[32]!==P?(A=r.jsxs(r.Fragment,{children:[_,P]}),e[31]=_,e[32]=P,e[33]=A):A=e[33],A}function G7(n){return n<1e3?`${n} ms`:n%6e4===0?`${n/6e4} min`:n%1e3===0?`${n/1e3} sec`:`${(n/1e3).toFixed(1)} sec`}function Y7(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function X7(n){const e=B.c(4),t=Vr(),[s,o]=w.useState(null);let i,a;return e[0]!==n||e[1]!==t?(i=()=>{let l=!1;return Gd(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]),w.useEffect(i,a),s}function Cp(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 J7(n,e){const t=n.match(new RegExp(`\\b${e}\\s*:\\s*["']([^"']+)["']`));return(t==null?void 0:t[1])??null}function Q7(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:Y7(a)});const s=J7(n,"workdir");s&&e.push({key:"workdir",label:"Working directory",value:s});const o=Cp(n,"yield_time_ms");o!==null&&e.push({key:"yield-time",label:"Yield",value:G7(o),icon:$o});const i=Cp(n,"max_output_tokens");return i!==null&&e.push({key:"output-limit",label:"Output limit",value:`${i.toLocaleString()} tokens`}),e}function _p(n){const e=B.c(49),{input:t}=n,s=String(t.raw??""),o=Q7(s),[i,a]=Hs(),l=X7(s);let c,d,u,f,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=Qt,g="sm",x="mt-1.5";let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs(ln,{className:"flex items-center gap-2",children:[r.jsx(Pr,{className:"size-4","aria-hidden":"true"}),"Tool script"]}),e[14]=_):_=e[14];let P;e[15]!==a||e[16]!==s?(P=()=>a(s),e[15]=a,e[16]=s,e[17]=P):P=e[17];const A=i?"Tool script copied":"Copy script",T=i?"Copied":"Copy script";let E;e[18]!==i?(E=i?r.jsx(gt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(Rn,{"data-icon":"inline-start","aria-hidden":"true"}),e[18]=i,e[19]=E):E=e[19],e[20]!==P||e[21]!==A||e[22]!==T||e[23]!==E?(b=r.jsxs(an,{children:[_,r.jsx(Hd,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:P,"aria-label":A,title:T,children:E})})]}),e[20]=P,e[21]=A,e[22]=T,e[23]=E,e[24]=b):b=e[24],c=Zt,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]",u="Codex exec script";const R=!l&&"text-foreground";e[25]!==R?(f=G("block",R),e[25]=R,e[26]=f):f=e[26];let I;e[27]!==l?(I=($,M)=>{const O=l==null?void 0:l[M];return r.jsx("span",{className:"block min-h-lh",children:O?O.map(eT):$||" "},M)},e[27]=l,e[28]=I):I=e[28],m=N.map(I),e[0]=i,e[1]=a,e[2]=s,e[3]=l,e[4]=c,e[5]=d,e[6]=u,e[7]=f,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],u=e[6],f=e[7],m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13];let y;e[29]!==u||e[30]!==f||e[31]!==m?(y=r.jsx("code",{"aria-label":u,className:f,children:m}),e[29]=u,e[30]=f,e[31]=m,e[32]=y):y=e[32];let v;e[33]!==p||e[34]!==y?(v=r.jsx("pre",{className:p,children:y}),e[33]=p,e[34]=y,e[35]=v):v=e[35];let S;e[36]!==v||e[37]!==h?(S=r.jsx("div",{className:h,children:v}),e[36]=v,e[37]=h,e[38]=S):S=e[38];let j;e[39]!==c||e[40]!==S?(j=r.jsx(c,{children:S}),e[39]=c,e[40]=S,e[41]=j):j=e[41];const k=o.length>0&&r.jsx(Oo,{className:"items-stretch",children:r.jsx("dl",{className:"grid w-full gap-1.5","aria-label":"Tool script options",children:o.map(Z7)})});let C;return e[42]!==d||e[43]!==j||e[44]!==k||e[45]!==g||e[46]!==x||e[47]!==b?(C=r.jsxs(d,{size:g,className:x,children:[b,j,k]}),e[42]=d,e[43]=j,e[44]=k,e[45]=g,e[46]=x,e[47]=b,e[48]=C):C=e[48],C}function Z7(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 eT(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const tT=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function Tp(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function nT(n,e){const t=[],s=[];let o=0;for(const l of n.matchAll(tT)){const c=Tp(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=Tp(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:sT(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 sT(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 oT=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),rT=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,iT=/\|\||&&|[|;\n]/,aT=new Set(["echo","printf","true","false",":"]),lT=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),cT=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),dT=new Set(["ls","tree","du"]),uT=new Set(["xargs","sudo","env","time","nohup","command"]);function fT(n){const e=n.split(/\s+/);for(;e.length>1&&(uT.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return oT.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:rT.test(n)}const J0=/<<-?\s*['"]?\w+['"]?/,mT=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function pT(n){return n.split(J0)[0].replace(mT,'""').split(iT).map(e=>e.trim()).filter(Boolean)}function hT(n){const e=pT(n);if(e.some(fT))return"write";let t=!1,s=!1,o=!1;for(const i of e){const a=i.split(/\s+/)[0];if(!(!a||aT.has(a)))if(lT.has(a))t=!0;else if(cT.has(a))s=!0;else if(dT.has(a))o=!0;else return"run"}return o?"list":t?"search":s?"read":"run"}const gT=/^["']?((?:~|\.{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 Q0(n){const e=new Set;for(const t of n.split(J0)[0].split(/\s+/)){const s=t.match(gT);if(!s)continue;const o=s[1];o.includes("*")||o.includes("{")||o.startsWith("-")||e.add(o)}return[...e]}const xT=/^(?: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 bT(n){const e=n.trim().match(xT);if(!e)return null;const[,t,s,,o]=e;return Q0(o).length?t?{path:o,from:Number(t),to:Number(s)}:{path:o}:null}const vT=/(?: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 yT(n,e){return!e||n==="read"&&e.split(`
102
+ `).length>3?!1:vT.test(e)}function Z0(n){const e=hT(n.command);return{kind:e,paths:Q0(n.command),readFile:e==="read"?bT(n.command):null,failed:yT(e,n.output)}}const wT="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",jT="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function e2(n,e,t){const s=B.c(5),[o,i]=w.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 Gd(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]),w.useEffect(a,l),o}function t2(n){const e=B.c(12),{lines:t,tokens:s,lineNums:o,variant:i}=n,a=i==="boxed"?wT:jT;let l;if(e[0]!==o||e[1]!==t||e[2]!==s){let u;e[4]!==o||e[5]!==s?(u=(f,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(ST):f||" "]},m)},e[4]=o,e[5]=s,e[6]=u):u=e[6],l=t.map(u),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 ST(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}const NT=/^(\s*\d+)→(.*)$/;function n2(n){return n.split(/\r\n|\r|\n/)}function kT(n){const e=[],t=[];for(const s of n2(n)){const o=s.match(NT);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function s2(n){const e=B.c(14),{result:t,filePath:s,expanded:o,variant:i}=n,a=i===void 0?"boxed":i,l=Vr();let c;e[0]!==s?(c=rx(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]!==o||e[3]!==t?(u=o?t:t.slice(0,500),e[2]=o,e[3]=t,e[4]=u):u=e[4];const f=u;let m;e[5]!==f?(m=kT(f),e[5]=f,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=e2(g,d,l);let y;return e[9]!==h||e[10]!==p||e[11]!==b||e[12]!==a?(y=r.jsx(t2,{lines:h,tokens:b,lineNums:p,variant:a}),e[9]=h,e[10]=p,e[11]=b,e[12]=a,e[13]=y):y=e[13],y}function o2(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 Vc(n){const e=B.c(12),{result:t,expanded:s,alreadyPretty:o,variant:i}=n,a=i===void 0?"boxed":i,l=Vr();let c;e[0]!==o||e[1]!==t?(c=o?t:o2(t)??t,e[0]=o,e[1]=t,e[2]=c):c=e[2];const d=c;let u;e[3]!==s||e[4]!==d?(u=s?d:d.slice(0,2e3),e[3]=s,e[4]=d,e[5]=u):u=e[5];const f=u;let m;e[6]!==f?(m=n2(f),e[6]=f,e[7]=m):m=e[7];const p=m,h=e2(f,"json",l);let g;return e[8]!==p||e[9]!==h||e[10]!==a?(g=r.jsx(t2,{lines:p,tokens:h,variant:a}),e[8]=p,e[9]=h,e[10]=a,e[11]=g):g=e[11],g}function r2(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}function CT(n){const e=[],t=new Map;for(const s of n){const o=r2(s),i=Z0(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 i2={muted:"text-muted-foreground",failed:"border-destructive/30 text-destructive"},ta={read:{icon:Di,label:"read",plural:"reads"},search:{icon:cn,label:"search",plural:"searches"},list:{icon:No,label:"list",plural:"lists"},run:{icon:$r,label:"run",plural:"runs"},write:{icon:bc,label:"write",plural:"writes"}},_T=["read","search","list","run","write"],TT=new Set(["command","cmd","description","timeout","run_in_background"]);function a2(n){return String(n.input.command??n.input.cmd??"")}function l2(n){const e=a2(n);return nT(e,n.result)??[{label:"",command:e,output:n.result}]}function ET(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 PT(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 AT(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function RT(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 $T(n){const e=[];n.timeout!==void 0&&e.push(PT(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))TT.has(t)||s===void 0||e.push(`${AT(t)} ${RT(s)}`);return e}function IT(n,e){const t=l2(n),s=t.map(Z0),o=ET(n,t,s);return{toolCall:n,command:a2(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:$T(n.input)}}function c2(n){return n?n.split(`
104
+ `).length:0}function MT(n){if(n.pending)return"running";if(n.section.output===null)return"not run";if(n.section.output==="")return"no output";const e=c2(n.section.output);return e===1?"1 line":`${e} lines`}function OT(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function d2(n){const e=B.c(12),{path:t,line:s,cwd:o,children:i}=n;let a;e[0]!==o||e[1]!==t?(a=OT(t,o),e[0]=o,e[1]=t,e[2]=a):a=e[2];const l=a;if(!l||!ft("hostFiles")){let f;return e[3]!==i?(f=r.jsx(r.Fragment,{children:i}),e[3]=i,e[4]=f):f=e[4],f}const c=`Open ${l}${s?`:${s}`:""}`;let d;e[5]!==s||e[6]!==l?(d=f=>{f.stopPropagation(),xr(l,s?{line:s}:{})},e[5]=s,e[6]=l,e[7]=d):d=e[7];let u;return e[8]!==i||e[9]!==c||e[10]!==d?(u=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]=u):u=e[11],u}function DT(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=(u,f)=>{const m=u.replace(/^["']|["']?[,:;]?$/g,"");return a.has(m)?r.jsx(d2,{path:m,cwd:o,children:u},f):u},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 LT=/^([^\s:]+):(\d+)([:-])/,Hl="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 zT(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=G(Hl,"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(s2,{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 u;e[7]!==s?(u=(f,m)=>{const p=f.match(LT);return r.jsx("span",{className:"block",children:p?r.jsxs(r.Fragment,{children:[r.jsxs(d2,{path:p[1],line:Number(p[2]),cwd:s,children:[p[1],":",p[2]]}),f.slice(p[1].length+p[2].length+1)]}):f||" "},m)},e[7]=s,e[8]=u):u=e[8],c=o.split(`
105
+ `).map(u),e[4]=s,e[5]=o,e[6]=c}else c=e[6];let d;return e[9]!==c?(d=r.jsx("pre",{className:Hl,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=G(Hl,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 FT(n){var W;const e=B.c(56),{row:t,index:s,defaultOpen:o,cwd:i}=n,[a,l]=w.useState(o);let c;e[0]!==t.section?(c=r2(t.section),e[0]=t.section,e[1]=c):c=e[1];const d=c,u=t.section.output!==null&&t.section.output!=="",f=`${d} section: ${t.section.command}`,m=ta[t.analysis.kind].icon,p=t.failed&&"text-destructive";let h;e[2]!==p?(h=G("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=ta[t.analysis.kind];let y;e[7]!==m||e[8]!==b.label?(y=r.jsx(m,{className:"size-3 shrink-0 text-muted-foreground","aria-label":b.label}),e[7]=m,e[8]=b.label,e[9]=y):y=e[9];const v=t.failed&&i2.failed;let S;e[10]!==v?(S=G("h-5 shrink-0 px-1.5 font-mono text-[10px] text-muted-foreground",v),e[10]=v,e[11]=S):S=e[11];let j;e[12]!==d||e[13]!==S?(j=r.jsx(Ce,{variant:"outline",className:S,children:d}),e[12]=d,e[13]=S,e[14]=j):j=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(DT,{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?(_=G("shrink-0 text-[10px] tabular-nums text-muted-foreground",N),e[21]=N,e[22]=_):_=e[22];let P;e[23]!==t?(P=t.failed?"failed":MT(t),e[23]=t,e[24]=P):P=e[24];let A;e[25]!==_||e[26]!==P?(A=r.jsx("span",{className:_,children:P}),e[25]=_,e[26]=P,e[27]=A):A=e[27];const T=a&&"rotate-90",E=!u&&"invisible";let R;e[28]!==T||e[29]!==E?(R=G("size-3 shrink-0 text-muted-foreground/60 transition-transform",T,E),e[28]=T,e[29]=E,e[30]=R):R=e[30];let I;e[31]!==R?(I=r.jsx(Je,{className:R,"aria-hidden":"true"}),e[31]=R,e[32]=I):I=e[32];let $;e[33]!==j||e[34]!==k||e[35]!==C||e[36]!==A||e[37]!==I||e[38]!==x||e[39]!==y?($=r.jsxs(r.Fragment,{children:[x,y,j,k,C,A,I]}),e[33]=j,e[34]=k,e[35]=C,e[36]=A,e[37]=I,e[38]=x,e[39]=y,e[40]=$):$=e[40];const M=$;if(!u){let U;return e[41]!==M||e[42]!==f?(U=r.jsx("div",{className:"group/row flex w-full items-center gap-2 py-2 text-left","aria-label":f,children:M}),e[41]=M,e[42]=f,e[43]=U):U=e[43],U}let O,D;e[44]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx("div",{role:"button",tabIndex:0}),D=G("group/row flex w-full items-center gap-2 py-2 text-left","cursor-pointer rounded-sm hover:bg-muted/40"),e[44]=O,e[45]=D):(O=e[44],D=e[45]);let L;e[46]!==M||e[47]!==f?(L=r.jsx($t,{nativeButton:!1,render:O,className:D,"aria-label":f,children:M}),e[46]=M,e[47]=f,e[48]=L):L=e[48];let F;e[49]!==i||e[50]!==t?(F=r.jsx(at,{children:r.jsx(zT,{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(it,{open:a,onOpenChange:l,children:[L,F]}),e[52]=a,e[53]=L,e[54]=F,e[55]=z):z=e[55],z}function BT(n){const e=new Map;for(const{analysis:t}of n)e.set(t.kind,(e.get(t.kind)??0)+1);return _T.filter(t=>e.has(t)).map(t=>{const s=e.get(t)??0;return`${s} ${s===1?ta[t].label:ta[t].plural}`}).join(" · ")}function UT(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(WT),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 WT(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function Ep(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=>IT(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,u=d.flatMap(XT),f=u.length,m=u.reduce(YT,0),p=u.filter(GT).length,h=u.filter(VT).length,[g,x]=Hs();let b;e[5]!==d?(b=d.map(qT).join(`
106
+
107
+ `),e[5]=d,e[6]=b):b=e[6];const y=b,v=d.length===1?d[0].description:void 0;let S;e[7]!==d[0]||e[8]!==d.length?(S=d.length===1?d[0].options:[],e[7]=d[0],e[8]=d.length,e[9]=S):S=e[9];const j=S;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(jo,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),e[10]=k):k=e[10];const C=pn,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 P=BT(u);let A;e[13]!==P?(A=r.jsx("span",{children:P}),e[13]=P,e[14]=A):A=e[14];let T;e[15]!==v?(T=v&&r.jsx("span",{className:"text-foreground/70",children:v}),e[15]=v,e[16]=T):T=e[16];let E;e[17]!==j?(E=j.map(KT),e[17]=j,e[18]=E):E=e[18];const R=m===1?"line":"lines";let I;e[19]!==p?(I=p>0&&r.jsxs("span",{className:"font-medium text-destructive",children:[" · ",p," failed"]}),e[19]=p,e[20]=I):I=e[20];let $;e[21]!==h?($=h>0&&r.jsxs("span",{children:[" · ",h," not run"]}),e[21]=h,e[22]=$):$=e[22];let M;e[23]!==R||e[24]!==I||e[25]!==$||e[26]!==m?(M=r.jsxs("span",{className:"ml-auto tabular-nums",children:[m," ",R,I,$]}),e[23]=R,e[24]=I,e[25]=$,e[26]=m,e[27]=M):M=e[27];let O;e[28]!==C||e[29]!==A||e[30]!==T||e[31]!==E||e[32]!==M||e[33]!==_?(O=r.jsxs(C,{className:N,children:[_,A,T,E,M]}),e[28]=C,e[29]=A,e[30]=T,e[31]=E,e[32]=M,e[33]=_,e[34]=O):O=e[34];let D;e[35]!==y||e[36]!==x?(D=()=>x(y),e[35]=y,e[36]=x,e[37]=D):D=e[37];const L=g?"Commands copied":f===1?"Copy command":"Copy commands",F=g?"Copied":f===1?"Copy command":"Copy commands";let z;e[38]!==g?(z=g?r.jsx(gt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(Rn,{"data-icon":"inline-start","aria-hidden":"true"}),e[38]=g,e[39]=z):z=e[39];let W;e[40]!==D||e[41]!==L||e[42]!==F||e[43]!==z?(W=r.jsx(Hd,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:D,"aria-label":L,title:F,children:z})}),e[40]=D,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(HT,0);return r.jsxs("div",{children:[q>0&&r.jsx(kt,{}),d.length>1&&r.jsx(UT,{call:K,index:q}),K.rows.map((V,J)=>r.jsx(FT,{row:V,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(Zt,{children:r.jsx("div",{"aria-label":"Command sections",children:U})}),e[49]=U,e[50]=H):H=e[50],r.jsxs(Qt,{size:"sm",className:"mt-1.5",role:"region","aria-label":f===1?"Bash command":"Bash commands",children:[r.jsxs(an,{children:[r.jsxs(ln,{className:"flex items-center gap-2",children:[k,f," ",f===1?"command":"commands"]}),O,W]}),H]})}function HT(n,e){return n+e.rows.length}function KT(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function qT(n){return n.command}function VT(n){return n.section.output===null&&!n.pending}function GT(n){return n.failed}function YT(n,e){return n+c2(e.section.output)}function XT(n){return n.rows}const JT=ss("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"}}),u2=w.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function QT(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,u=l===void 0?"horizontal":l;let f;e[8]!==d?(f={"--gap":d},e[8]=d,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==u||e[13]!==i||e[14]!==d||e[15]!==c?(h={variant:c,size:i,spacing:d,orientation:u},e[12]=u,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(u2.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==u||e[21]!==o||e[22]!==i||e[23]!==d||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=r.jsx(C3,{"data-slot":"toggle-group","data-variant":c,"data-size":i,"data-spacing":d,"data-orientation":u,orientation:u,style:m,className:p,...o,children:g}),e[20]=u,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 ZT(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=w.useContext(u2),u=d.variant||l,f=d.size||c,m=d.spacing;let p;e[6]!==s||e[7]!==d.size||e[8]!==d.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",JT({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]!==u||e[16]!==f||e[17]!==p?(h=r.jsx(k3,{"data-slot":"toggle-group-item","data-variant":u,"data-size":f,"data-spacing":m,className:p,...o,children:t}),e[12]=t,e[13]=d.spacing,e[14]=o,e[15]=u,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function e8(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(t8)),e[2]=l,e[3]=c):c=e[3];const[d,u]=w.useState(c),[f,m]=w.useState(!1),[p,h]=w.useState(!1),{chat:g}=Fr(),{sendMessage:x}=g;if(l.length===0)return null;let b;e[4]!==d||e[5]!==l||e[6]!==x?(b=()=>{const T=l.map(E=>{var I;const R=(I=d[E.question])==null?void 0:I.trim();return R?l.length>1?`${E.question}
108
+ ${R}`:R:null}).filter(Boolean).join(`
109
+
110
+ `);T&&x(T),h(!0)},e[4]=d,e[5]=l,e[6]=x,e[7]=b):b=e[7];const y=b;let v;if(e[8]!==d||e[9]!==y||e[10]!==s||e[11]!==t.id){const T=async E=>{E.preventDefault(),m(!0);try{(await $d(s,t.id,d)).ok?h(!0):y()}catch{y()}m(!1)};v=E=>{T(E)},e[8]=d,e[9]=y,e[10]=s,e[11]=t.id,e[12]=v}else v=e[12];const S=!i&&"mt-2 rounded-md border bg-card p-3",j=p&&"pointer-events-none opacity-50";let k;e[13]!==S||e[14]!==j?(k=G("flex flex-col gap-3",S,j),e[13]=S,e[14]=j,e[15]=k):k=e[15];let C;if(e[16]!==d||e[17]!==l||e[18]!==t.id){let T;e[20]!==d||e[21]!==t.id?(T=(E,R)=>{const I=E.options&&E.options.length>0,$=new Set(E.multiSelect?(d[E.question]??"").split(", ").filter(Boolean):[]),M=`ask-user-answer-${t.id}-${R}`;return r.jsxs(u4,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(E.header||E.question)&&r.jsxs(f4,{variant:"label",className:"flex flex-col items-start gap-1",children:[E.header&&r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:E.header}),r.jsx("span",{className:"text-sm leading-relaxed text-foreground",children:E.question})]}),I?r.jsx(QT,{multiple:E.multiSelect,orientation:"vertical",variant:"outline",value:E.multiSelect?Array.from($):d[E.question]?[d[E.question]]:[],onValueChange:O=>{if(!E.multiSelect&&O.length===0)return;const D=E.multiSelect?O.join(", "):O[0];u({...d,[E.question]:D})},className:"grid w-full gap-1.5",children:E.options.map((O,D)=>{const L=E.multiSelect?$.has(O.label):d[E.question]===O.label;return r.jsxs(ZT,{value:O.label,"aria-label":O.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",E.multiSelect?"rounded":"rounded-full",L?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:L&&r.jsx(gt,{className:"size-3",strokeWidth:3,"data-icon":"icon"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-xs font-medium",children:O.label}),O.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:O.description})]})]},D)})}):r.jsxs(St,{children:[r.jsx(Nt,{htmlFor:M,children:"Answer"}),r.jsx(Da,{id:M,value:d[E.question]??"",onChange:O=>{u({...d,[E.question]:O.target.value})},rows:2,placeholder:"Type your answer..."})]})]},R)},e[20]=d,e[21]=t.id,e[22]=T):T=e[22],C=l.map(T),e[16]=d,e[17]=l,e[18]=t.id,e[19]=C}else C=e[19];const N=f||p,_=p?"Sent":f?"Sending...":"Send answer";let P;e[23]!==N||e[24]!==_?(P=r.jsx(ee,{type:"submit",size:"sm",disabled:N,children:_}),e[23]=N,e[24]=_,e[25]=P):P=e[25];let A;return e[26]!==C||e[27]!==P||e[28]!==v||e[29]!==k?(A=r.jsxs("form",{onSubmit:v,className:k,children:[C,P]}),e[26]=C,e[27]=P,e[28]=v,e[29]=k,e[30]=A):A=e[30],A}function t8(n){return[n.question,""]}function n8(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function Pp(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function s8(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[Pp(s[1])]=Pp(s[2]);return e}function o8(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r8(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${o8(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function i8(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=s8(n.result);for(const o of e)if(s[o.question]===void 0){const i=r8(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function Ap(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function a8(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=S=>Ap(t,s,S.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,u=i&&s!==void 0&&d===0,f=o+1;let m;e[9]!==f?(m=r.jsx(Ce,{variant:"outline",className:"size-5 rounded-full p-0 font-mono text-muted-foreground",children:f}),e[9]=f,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,S)=>{const j=Ap(t,s,v.label);return r.jsxs("div",{className:G("flex items-start gap-2.5 py-2",j?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:G("mt-0.5 flex size-4 shrink-0 items-center justify-center border",t.multiSelect?"rounded":"rounded-full",j?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30"),"aria-hidden":"true",children:j&&r.jsx(gt,{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,j&&r.jsx(Ce,{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}-${S}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let b;e[22]!==s||e[23]!==u?(b=u&&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]=u,e[24]=b):b=e[24];let y;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==b?(y=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]=y):y=e[29],y}function l8(n){const e=B.c(61),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=w.useState(!1);let c;e[0]!==t?(c=n8(t),e[0]=t,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==t?(u=i8(t,d),e[2]=d,e[3]=t,e[4]=u):u=e[4];const f=u,m=s||a,p=t.result!==null&&!t.isError,h=t.result===null&&o&&!!i&&d.length>0;let g;e[5]!==f?(g=Object.keys(f),e[5]=f,e[6]=g):g=e[6];const x=g.length>0,b=t.isError?qt:p?Wn:$o,y=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",v=t.isError&&"border-destructive/30";let S;e[7]!==v?(S=G("my-1 overflow-hidden rounded-lg border bg-card",v),e[7]=v,e[8]=S):S=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(k1,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=j):j=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 P;e[14]!==b?(P=r.jsx(b,{"data-icon":"inline-start"}),e[14]=b,e[15]=P):P=e[15];let A;e[16]!==y||e[17]!==_||e[18]!==P?(A=r.jsxs(Ce,{variant:_,children:[P,y]}),e[16]=y,e[17]=_,e[18]=P,e[19]=A):A=e[19];let T;e[20]!==A||e[21]!==N?(T=r.jsxs("div",{className:"min-w-0 flex-1",children:[N,A]}),e[20]=A,e[21]=N,e[22]=T):T=e[22];let E;e[23]!==t.timestamp?(E=t.timestamp&&r.jsx("time",{className:"hidden shrink-0 pt-0.5 font-mono text-xs tabular-nums text-muted-foreground sm:block",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e[23]=t.timestamp,e[24]=E):E=e[24];let R;e[25]!==T||e[26]!==E?(R=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[j,T,E]}),e[25]=T,e[26]=E,e[27]=R):R=e[27];let I;e[28]!==f||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?(I=h&&i?r.jsx(e8,{toolCall:t,sessionId:i,embedded:!0}):d.length>0?d.map((U,H)=>r.jsx(a8,{question:U,answer:f[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]=f,e[29]=h,e[30]=d,e[31]=i,e[32]=t,e[33]=I):I=e[33];let $;e[34]!==x||e[35]!==t.isError||e[36]!==t.result?($=t.result!==null&&!x&&r.jsxs("div",{className:G("border-t border-border py-3",t.isError?"text-destructive":"text-muted-foreground"),children:[r.jsx("div",{className:"mb-0.5 text-xs font-semibold uppercase tracking-wide opacity-70",children:"Recorded response"}),r.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:t.result})]}),e[34]=x,e[35]=t.isError,e[36]=t.result,e[37]=$):$=e[37];let M;e[38]!==I||e[39]!==$?(M=r.jsxs("div",{className:"px-3",children:[I,$]}),e[38]=I,e[39]=$,e[40]=M):M=e[40];let O;e[41]!==s?(O=()=>{s||l(c8)},e[41]=s,e[42]=O):O=e[42];let D;e[43]!==m?(D=m?r.jsx(tt,{"data-icon":"inline-start"}):r.jsx(Je,{"data-icon":"inline-start"}),e[43]=m,e[44]=D):D=e[44];let L;e[45]!==m||e[46]!==O||e[47]!==D?(L=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:O,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[D,"Raw details"]}),e[45]=m,e[46]=O,e[47]=D,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]!==R||e[57]!==M||e[58]!==z||e[59]!==S?(W=r.jsxs("section",{className:S,"aria-label":"Question history",children:[R,M,z]}),e[56]=R,e[57]=M,e[58]=z,e[59]=S,e[60]=W):W=e[60],W}function c8(n){return!n}const d8={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 u8(n){return typeof n=="object"&&n!==null}function xn(...n){return n.find(e=>typeof e=="string")??""}function Eo(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function ju(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 Qr(n,e=""){const t=ju(n);if(t.length===0)return e;const s=Eo(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function Su(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const Rp={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function na(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 Rp[i]?Rp[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 f8(n){if(!n)return null;const e=n.trim(),t=ns(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function Xt(n,...e){for(const t of e){const s=f8(su(n,t));if(s)return s;const o=ou(n,t)[0];if(o)return o}return""}function m8(n,...e){for(const t of e){const s=Lx(n,t)[0];if(s!==void 0)return s}return null}function sa(n){return Xt(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 p8=[{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 $p(n,e){return e.flatMap(t=>ou(n,t))}function h8(n,e){const t=e.summaryGroups.map(i=>$p(n,i)),s=e.detail?Lx(n,e.detail.property):[],o=e.countProperties?$p(n,e.countProperties):t[0];return{label:e.label,noun:e.noun,summary:[...t.map(i=>Qr(i)),e.detail&&s.length>0?e.detail.format(s[0]):""].filter(Boolean).join(" · "),count:Math.max(zx(n),ju(o).length,s.length,1)}}function g8(n){const e=[];for(const t of p8){const s=su(n,t.key);s&&e.push(h8(s,t))}return e}function x8(n){const e=g8(n);return e.length===0?{label:"Browse web",summary:sa(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>Su(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function f2(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:na(e,!0),action:na(t.join(" "))}}function b8(n,e){const t=f2(n);if(!t)return{label:na(n),summary:sa(e),styleName:"Mcp"};const s=sa(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function v8(n){const e=ns(n.trim(),0),t=(e==null?void 0:e.value)??n,s=ju(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return Qr(s,s.length>0?Su(s.length,"file"):"")}function y8(n){const e=n.argumentSource;switch(n.name){case"exec_command":return{label:"Run command",summary:Xt(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=m8(e,"session_id"),s=Xt(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?Eo(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:v8(e),styleName:"Edit"};case"web__run":case"web_search":return x8(e);case"view_image":return{label:"View image",summary:Xt(e,"path"),styleName:"Read"};case"update_plan":{const t=su(e,"plan"),s=t?zx(t):0;return{label:"Update plan",summary:s>0?Su(s,"step"):Xt(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:Xt(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TodoWrite"};case"update_goal":return{label:"Update goal",summary:Xt(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:Xt(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:Xt(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[Xt(e,"server"),Xt(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:Xt(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:Xt(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:Xt(e,"prompt"),styleName:"Image"};default:return n.name.startsWith("mcp__")?b8(n.name,e):{label:na(n.name),summary:sa(e),styleName:n.name}}}function m2(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function w8(n){const e=wC(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(y8),s=t[0];if(t.every(i=>i.label===s.label)){const i=Qr(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 j8(n){const e=u8(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:xn(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[xn(e==null?void 0:e.pattern),xn(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=xn(e==null?void 0:e.query,n.query);return{label:"Search web",summary:Qr([o,...s]),styleName:"WebSearch"}}const S8=["summary","headline","verdict","title"];function N8(n){const e=xn(...S8.map(t=>n[t]));if(e)return Eo(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 k8(n){const e=xn(n.description);if(e)return Eo(e);const t=xn(n.script);return(t?ou(t,"name")[0]??"":"")||xn(n.scriptPath)}function Ip(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 Mp(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=xn(e.to,e.recipient),o=Eo(xn(e.summary,e.message,e.content));return[s,o].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return Eo(xn(e.subject,e.description));case"TaskUpdate":{const s=String(e.taskId??""),o=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(a=>typeof a=="string"):[],i=xn(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 k8(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return N8(e)||Ip(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 Qr(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 Ip(e)}}function Xa(n){if(m2(n))return w8(n.input.raw);if(n.name==="WebSearch")return j8(n.input);const e=f2(n.name);if(e)return{label:e.server,summary:[e.action,Mp(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const t=d8[n.name];return{label:(t==null?void 0:t.label)??n.name,summary:Mp(n),styleName:(t==null?void 0:t.styleName)??n.name}}function C8(n){return Xa(n).summary}const _8={mutating:"text-foreground",readOnly:"text-muted-foreground"},T8="text-destructive",Op=8,E8=4,P8="whitespace-pre-wrap break-all border-l border-border pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground",A8="max-h-96 overflow-y-auto whitespace-pre-wrap break-all rounded-md border p-2 font-mono text-xs leading-relaxed";function R8(n){return n.split(/\r\n|\r|\n/)}const $8={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"},I8="readOnly";function M8(n){return $8[n]??I8}function p2(n,e=!1){return e?T8:_8[M8(n)]}function Kl(n){const e=B.c(8),{isOpen:t,onClick:s,label:o,controlsId:i}=n,a=t?tt: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 h2(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(Ys,{role:"img","aria-label":"Tool call failed",className:"size-4 text-destructive","data-icon":"icon"}),e[0]=o):o=e[0],o}if(t.result===null&&s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(lt,{role:"img","aria-label":"Tool call running",className:"size-4 animate-spin text-info","data-icon":"icon"}),e[1]=o):o=e[1],o}return null}function O8(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"?o2(a):null,e[0]=a,e[1]=t.isError,e[2]=t.name,e[3]=d):d=e[3];const u=d,f=u??a;let m;e[4]!==f?(m=R8(f),e[4]=f,e[5]=m):m=e[5];const p=m,h=Math.max(0,p.length-Op);let g;e[6]!==p||e[7]!==f||e[8]!==s?(g=s?f:p.slice(0,Op).join(`
111
+ `),e[6]=p,e[7]=f,e[8]=s,e[9]=g):g=e[9];const x=g,b=i?l:h>0,y=!i||!l||s,v=i?"boxed":"unboxed";let S;e[10]!==x||e[11]!==y||e[12]!==v||e[13]!==i||e[14]!==c||e[15]!==u||e[16]!==a||e[17]!==t.input||e[18]!==t.isError||e[19]!==t.name?(S=t.name==="Read"&&!t.isError&&typeof t.input.file_path=="string"?r.jsx(s2,{result:i?a:x,filePath:t.input.file_path,expanded:y,variant:v}):u!==null?r.jsx(Vc,{result:i?u:x,expanded:y,alreadyPretty:!0,variant:v}):r.jsx("pre",{className:G(i?A8:P8,t.isError?G("border-destructive/20 text-destructive",i&&"bg-destructive/5"):i&&"border-border bg-muted/30 text-muted-foreground"),children:i?c:x}),e[10]=x,e[11]=y,e[12]=v,e[13]=i,e[14]=c,e[15]=u,e[16]=a,e[17]=t.input,e[18]=t.isError,e[19]=t.name,e[20]=S):S=e[20];let j;e[21]!==h||e[22]!==i||e[23]!==o||e[24]!==s||e[25]!==b?(j=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]=j):j=e[26];let k;return e[27]!==S||e[28]!==j?(k=r.jsxs("div",{className:"mt-1.5",children:[S,j]}),e[27]=S,e[28]=j,e[29]=k):k=e[29],k}function D8(n){const e=B.c(12),{chips:t}=n;let s,o,i,a;if(e[0]!==t){const d=t.slice(0,E8);s=t.length-d.length,o="flex min-w-0 items-center gap-1 overflow-hidden",i=`Sections: ${t.map(z8).join(", ")}`,a=d.map(L8),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 L8(n,e){return r.jsxs(Ce,{variant:"outline",className:G("h-4 shrink-0 px-1.5 font-mono text-[10px]",i2[n.tone]),children:[n.name,n.count>1?` ×${n.count}`:""]},e)}function z8(n){return`${n.name}${n.count>1?` ×${n.count}`:""}`}function g2(n){const e=B.c(7),{chips:t,summary:s,isMobile:o}=n;if(t){let c;return e[0]!==t?(c=r.jsx(D8,{chips:t}),e[0]=t,e[1]=c):c=e[1],c}if(!s)return null;const i=o?"text-[11px]":"text-xs";let a;e[2]!==i?(a=G("truncate font-mono text-muted-foreground",i),e[2]=i,e[3]=a):a=e[3];let l;return e[4]!==s||e[5]!==a?(l=r.jsx("span",{className:a,children:s}),e[4]=s,e[5]=a,e[6]=l):l=e[6],l}function Dp(n){const e=B.c(36),{toolCall:t,isMobile:s,isAgentActive:o,displayName:i,summary:a,sectionChips:l,nameTitle:c,nameClass:d,timeLabel:u,timeIso:f}=n;let m;e[0]!==f||e[1]!==u?(m=u&&r.jsx("time",{className:"sr-only",dateTime:f,children:u}),e[0]=f,e[1]=u,e[2]=m):m=e[2];const p=s?"gap-1.5":"gap-2";let h;e[3]!==p?(h=G("flex min-w-0 flex-1 items-center",p),e[3]=p,e[4]=h):h=e[4];const g=s?"text-[10px]":"text-[11px]";let x;e[5]!==d||e[6]!==g?(x=G("shrink-0 font-mono",g,d),e[5]=d,e[6]=g,e[7]=x):x=e[7];let b;e[8]!==i||e[9]!==c||e[10]!==x?(b=r.jsx("span",{className:x,title:c,children:i}),e[8]=i,e[9]=c,e[10]=x,e[11]=b):b=e[11];let y;e[12]!==l||e[13]!==s||e[14]!==a?(y=r.jsx(g2,{chips:l,summary:a,isMobile:s}),e[12]=l,e[13]=s,e[14]=a,e[15]=y):y=e[15];let v;e[16]!==h||e[17]!==b||e[18]!==y?(v=r.jsxs("div",{className:h,children:[b,y]}),e[16]=h,e[17]=b,e[18]=y,e[19]=v):v=e[19];let S;e[20]!==s||e[21]!==t.hookDurationMs?(S=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]=S):S=e[22];let j;e[23]!==t.outputReplacedByHook?(j=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-blue-400",title:"Output replaced by hook",children:"hook"}),e[23]=t.outputReplacedByHook,e[24]=j):j=e[24];let k;e[25]!==o||e[26]!==t?(k=r.jsx(h2,{toolCall:t,isAgentActive:o}),e[25]=o,e[26]=t,e[27]=k):k=e[27];let C;e[28]!==j||e[29]!==k||e[30]!==S?(C=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[S,j,k]}),e[28]=j,e[29]=k,e[30]=S,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 F8(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"&&cu(e)?e:null}function Lp(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(wu,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const B8={AskUserQuestion:"Question",Bash:"Command",exec:"Command",Task:"Agent",WebFetch:"Fetch",WebSearch:"Search",EnterPlanMode:"Plan mode",ExitPlanMode:"Plan review",ToolSearch:"Tool search"},x2=w.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:u,pendingInteraction:f}=ct(),m=Ya(),[p,h]=w.useState(!1),[g,x]=w.useState(!1),[b,y]=w.useState(!1),[v,S]=w.useState(!1),[j,k]=w.useState(!1),[C,N]=w.useState(!1),_=w.useId(),P=w.useId(),A=w.useId(),T=w.useId(),E=w.useId(),[R,I]=w.useState(!1);let $;t[0]!==o||t[1]!==s?($=o??(s.name==="Bash"?[s]:[]),t[0]=o,t[1]=s,t[2]=$):$=t[2];const M=$;let O;t[3]!==M||t[4]!==l||t[5]!==s.result?(O=(M.length>0?M.every(U8):s.result!==null)||!l,t[3]=M,t[4]=l,t[5]=s.result,t[6]=O):O=t[6];const L=m&&O&&!i&&!R;let F;t[7]!==s?(F=Xa(s),t[7]=s,t[8]=F):F=t[8];const z=F;let W;t[9]!==s?(W=m2(s),t[9]=s,t[10]=W):W=t[10];const U=W;let H;t[11]!==M?(H=M.length>0?M.flatMap(l2):null,t[11]=M,t[12]=H):H=t[12];const K=H;let q;t[13]!==K?(q=K?CT(K):void 0,t[13]=K,t[14]=q):q=t[14];const Y=q,V=m&&z.label===s.name?B8[s.name]??s.name:z.label,J=M.length>1?`${V} ×${M.length}`:V,Q=z.label===s.name?s.name:`${z.label} (${s.name})`;let X,Z,te,ne,oe,re,ae,se,fe,le,ce,me,ue,de;if(t[15]!==M||t[16]!==Y||t[17]!==T||t[18]!==j||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]!==f||t[30]!==z.styleName||t[31]!==z.summary||t[32]!==b||t[33]!==g||t[34]!==(K==null?void 0:K.length)||t[35]!==(u==null?void 0:u.sessionId)||t[36]!==c||t[37]!==s){me=Symbol.for("react.early_return_sentinel");e:{const Te=p2(z.styleName,s.isError||M.some(W8));let _e;t:{if(M.length<=1){_e=s;break t}const Ye=M.some(H8)?null:s.result;let Me;t[52]!==M?(Me=M.some(K8),t[52]=M,t[53]=Me):Me=t[53];let Ue;t[54]!==M?(Ue=M.some(q8),t[54]=M,t[55]=Ue):Ue=t[55];let rt;t[56]!==M?(rt=M.reduce(V8,0),t[56]=M,t[57]=rt):rt=t[57];let Gt;t[58]!==Ye||t[59]!==Me||t[60]!==Ue||t[61]!==rt||t[62]!==s?(Gt={...s,result:Ye,isError:Me,outputReplacedByHook:Ue,hookDurationMs:rt},t[58]=Ye,t[59]=Me,t[60]=Ue,t[61]=rt,t[62]=s,t[63]=Gt):Gt=t[63],_e=Gt}const We=_e;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 pe;t[66]!==s.timestamp?(pe=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[66]=s.timestamp,t[67]=pe):pe=t[67];const Oe=pe;te=d||m&&i,ae=te||p,se=te||g,re=te||v;const Ae=M.length>1?`${(K==null?void 0:K.length)??M.length} commands`:z.summary;let Be;t[68]!==c||t[69]!==Ae||t[70]!==s.name?(Be=s.name==="Skill"&&c?c.get(Ae)??null:null,t[68]=c,t[69]=Ae,t[70]=s.name,t[71]=Be):Be=t[71],le=Be,fe=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",oe=d||j;const ie=F8(s),xe=ie!==null&&((Le=s.result)==null?void 0:Le.trim())==="";let Ee;t[72]!==M.length||t[73]!==xe||t[74]!==m||t[75]!==b||t[76]!==s?(Ee=s.result!==null&&!xe&&M.length===0?r.jsx(O8,{toolCall:s,resultExpanded:b,onToggleExpanded:()=>y(!b),isMobile:m}):null,t[72]=M.length,t[73]=xe,t[74]=m,t[75]=b,t[76]=s,t[77]=Ee):Ee=t[77],ne=Ee;let Ie;t[78]!==L?(Ie=()=>{L&&I(!0)},t[78]=L,t[79]=Ie):Ie=t[79];const He=Ie;if(s.name==="AskUserQuestion"){const Ye=(f==null?void 0:f.type)==="question"&&f.toolUseId===s.id,Me=u==null?void 0:u.sessionId;let Ue;t[80]!==te||t[81]!==Ye||t[82]!==Me||t[83]!==s?(Ue=r.jsx(l8,{toolCall:s,expandToolPayloads:te,isAwaitingAnswer:Ye,sessionId:Me}),t[80]=te,t[81]=Ye,t[82]=Me,t[83]=s,t[84]=Ue):Ue=t[84],me=Ue;break e}const Ke=L?"py-1":"py-1.5",nt=We.isError&&!L&&"rounded-md bg-destructive/5 px-2";t[85]!==Ke||t[86]!==nt?(ue=G(Ke,nt),t[85]=Ke,t[86]=nt,t[87]=ue):ue=t[87],de=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:G("shrink-0 font-mono text-xs",Te),title:Q,children:J}),r.jsx(g2,{chips:Y,summary:Ae})]}),r.jsx(Je,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-end"}),r.jsx(h2,{toolCall:We,isAgentActive:l})]}):m?r.jsx("div",{className:"flex items-center gap-1.5",title:Ne,children:r.jsx(Dp,{toolCall:We,isMobile:!0,isAgentActive:l,displayName:J,summary:Ae,sectionChips:Y,nameTitle:Q,nameClass:Te,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${Ae?`: ${Ae}`:""}`,"aria-expanded":oe,"aria-controls":T,onClick:()=>{d||k(G8)},children:r.jsx(Dp,{toolCall:We,isMobile:!1,isAgentActive:l,displayName:J,summary:Ae,sectionChips:Y,nameTitle:Q,nameClass:Te,timeLabel:Ne,timeIso:Oe})}),ce=xe&&!L&&r.jsx(Wc,{src:ie,alt:ie.slice(ie.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[15]=M,t[16]=Y,t[17]=T,t[18]=j,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]=f,t[30]=z.styleName,t[31]=z.summary,t[32]=b,t[33]=g,t[34]=K==null?void 0:K.length,t[35]=u==null?void 0:u.sessionId,t[36]=c,t[37]=s,t[38]=X,t[39]=Z,t[40]=te,t[41]=ne,t[42]=oe,t[43]=re,t[44]=ae,t[45]=se,t[46]=fe,t[47]=le,t[48]=ce,t[49]=me,t[50]=ue,t[51]=de}else X=t[38],Z=t[39],te=t[40],ne=t[41],oe=t[42],re=t[43],ae=t[44],se=t[45],fe=t[46],le=t[47],ce=t[48],me=t[49],ue=t[50],de=t[51];if(me!==Symbol.for("react.early_return_sentinel"))return me;let be;t[88]!==L||t[89]!==s.id||t[90]!==s.resultImages?(be=!L&&((ze=s.resultImages)==null?void 0:ze.map((Te,_e)=>r.jsx(Wc,{src:`data:${Te.source.media_type};base64,${Te.source.data}`,alt:`Tool result image ${_e+1}`,id:`tool-result-image:${s.id}:${_e}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${Te.source.media_type}-${Te.source.data.length}-${Te.source.data.slice(0,32)}-${Te.source.data.slice(-32)}`))),t[88]=L,t[89]=s.id,t[90]=s.resultImages,t[91]=be):be=t[91];let ge;t[92]!==L||t[93]!==fe||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]}),fe&&(!Bs()||Vd())&&r.jsxs(ee,{type:"button",variant:"link",size:"xs",onClick:Te=>{Te.stopPropagation(),xr(fe)},className:"h-auto px-0 text-muted-foreground",title:fe,children:[r.jsx(N1,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[92]=L,t[93]=fe,t[94]=le,t[95]=ge):ge=t[95];let he;t[96]!==v||t[97]!==Z||t[98]!==p||t[99]!==L||t[100]!==m||t[101]!==_||t[102]!==P||t[103]!==A||t[104]!==ne||t[105]!==g||t[106]!==re||t[107]!==ae||t[108]!==se?(he=m&&!L&&r.jsxs("div",{className:"flex gap-3 mt-1",children:[Z&&r.jsx(Kl,{isOpen:re,onClick:()=>S(!v),label:"Diff",controlsId:_}),r.jsx(Kl,{isOpen:ae,onClick:()=>h(!p),label:"Input",controlsId:P}),ne&&r.jsx(Kl,{isOpen:se,onClick:()=>x(!g),label:"Result",controlsId:A})]}),t[96]=v,t[97]=Z,t[98]=p,t[99]=L,t[100]=m,t[101]=_,t[102]=P,t[103]=A,t[104]=ne,t[105]=g,t[106]=re,t[107]=ae,t[108]=se,t[109]=he):he=t[109];let je;t[110]!==Z||t[111]!==L||t[112]!==m||t[113]!==_||t[114]!==re||t[115]!==s?(je=m&&!L&&Z&&r.jsx(it,{open:re,children:r.jsx(at,{id:_,children:r.jsx(Lp,{toolCall:s})})}),t[110]=Z,t[111]=L,t[112]=m,t[113]=_,t[114]=re,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]!==P||t[123]!==te||t[124]!==(u==null?void 0:u.cwd)||t[125]!==ae||t[126]!==s.input?(Se=m&&!L&&r.jsx(it,{open:ae,children:r.jsx(at,{id:P,children:M.length>0?r.jsx(Ep,{toolCalls:M,cwd:u==null?void 0:u.cwd,expandAll:te,isAgentActive:!!l}):U?r.jsx(_p,{input:s.input}):r.jsx(Vc,{result:JSON.stringify(s.input),expanded:!0})})}),t[117]=M,t[118]=l,t[119]=U,t[120]=L,t[121]=m,t[122]=P,t[123]=te,t[124]=u==null?void 0:u.cwd,t[125]=ae,t[126]=s.input,t[127]=Se):Se=t[127];let Pe;t[128]!==s.id||t[129]!==s.name||t[130]!==s.result?(Pe=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(vu,{toolUseId:s.id}),t[128]=s.id,t[129]=s.name,t[130]=s.result,t[131]=Pe):Pe=t[131];let Re;t[132]!==L||t[133]!==m||t[134]!==A||t[135]!==ne||t[136]!==se?(Re=m&&!L&&ne&&r.jsx(it,{open:se,children:r.jsx(at,{id:A,children:ne})}),t[132]=L,t[133]=m,t[134]=A,t[135]=ne,t[136]=se,t[137]=Re):Re=t[137];let $e;t[138]!==M||t[139]!==E||t[140]!==C||t[141]!==T||t[142]!==X||t[143]!==d||t[144]!==Z||t[145]!==l||t[146]!==m||t[147]!==ne||t[148]!==(u==null?void 0:u.cwd)||t[149]!==oe||t[150]!==s?($e=!m&&r.jsx(it,{open:oe,children:r.jsxs(at,{id:T,onClick:Y8,children:[X==="diff"&&Z&&r.jsx(Lp,{toolCall:s}),X==="command"&&(M.length>0?r.jsx(Ep,{toolCalls:M,cwd:u==null?void 0:u.cwd,expandAll:d,isAgentActive:!!l}):r.jsx(_p,{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":E,onClick:Te=>{Te.stopPropagation(),N(X8)},children:"input"}),r.jsx(it,{open:C,children:r.jsx(at,{id:E,children:r.jsx(Vc,{result:JSON.stringify(M.length>1?M.map(J8):s.input),expanded:!0})})})]})}),t[138]=M,t[139]=E,t[140]=C,t[141]=T,t[142]=X,t[143]=d,t[144]=Z,t[145]=l,t[146]=m,t[147]=ne,t[148]=u==null?void 0:u.cwd,t[149]=oe,t[150]=s,t[151]=$e):$e=t[151];let De;return t[152]!==ce||t[153]!==be||t[154]!==ge||t[155]!==he||t[156]!==je||t[157]!==Se||t[158]!==Pe||t[159]!==Re||t[160]!==$e||t[161]!==ue||t[162]!==de?(De=r.jsxs("div",{className:ue,children:[de,ce,be,ge,he,je,Se,Pe,Re,$e]}),t[152]=ce,t[153]=be,t[154]=ge,t[155]=he,t[156]=je,t[157]=Se,t[158]=Pe,t[159]=Re,t[160]=$e,t[161]=ue,t[162]=de,t[163]=De):De=t[163],De});function U8(n){return n.result!==null}function W8(n){return n.isError}function H8(n){return n.result===null}function K8(n){return n.isError}function q8(n){return n.outputReplacedByHook}function V8(n,e){return n+(e.hookDurationMs??0)}function G8(n){return!n}function Y8(n){return n.stopPropagation()}function X8(n){return!n}function J8(n){return n.input}const Q8=w.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,u]=w.useState(!0),f=o.some(S=>S.name==="AskUserQuestion"&&S.result===null),[m,p]=w.useState(null),h=w.useRef(f);w.useEffect(()=>{f&&(h.current=!0)},[f]);const g=i||d,x=i||(m??(f||h.current)),b=s==="approved"?Rr:s==="rejected"?Ys:Fs,y=g?tt:Je,v=x?tt:Je;return r.jsxs(it,{open:g,onOpenChange:u,className:G("my-2 rounded-lg border",s==="approved"?"border-success/20 bg-success/5":s==="rejected"?"border-destructive/20 bg-destructive/5":"border-warning/20 bg-warning/5"),children:[r.jsxs($t,{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(y,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(_3,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(b,{className:G("size-4",s==="approved"?"text-success":s==="rejected"?"text-destructive":"text-warning")}),r.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:s}),t&&r.jsx("span",{className:"ml-auto truncate font-mono text-xs text-muted-foreground",children:t})]}),r.jsx(at,{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(Hn,{remarkPlugins:[ka],components:Yn,children:e})}),o.length>0&&r.jsxs(it,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs($t,{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(at,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(S=>r.jsx(x2,{toolCall:S,expandAll:i,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},S.id))})})]})]})})]})}),Z8=w.memo(function(e){const t=B.c(14),{content:s}=e,[o,i]=w.useState(!0),a=o?tt: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,u;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(T3,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),u=r.jsx("span",{className:"text-sm font-medium",children:"Session recap"}),t[3]=d,t[4]=u):(d=t[3],u=t[4]);let f;t[5]!==c?(f=r.jsxs($t,{render:l,children:[c,d,u]}),t[5]=c,t[6]=f):f=t[6];let m;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=[ka],t[7]=m):m=t[7];let p;t[8]!==s?(p=r.jsx(at,{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(Hn,{remarkPlugins:m,components:Yn,children:s})})}),t[8]=s,t[9]=p):p=t[9];let h;return t[10]!==o||t[11]!==f||t[12]!==p?(h=r.jsxs(it,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[f,p]}),t[10]=o,t[11]=f,t[12]=p,t[13]=h):h=t[13],h}),ql=1;function zp(n,e){return!e||n.length<=ql?{visible:[...n],hidden:0}:{visible:n.slice(-ql),hidden:n.length-ql}}function eE(n){return`${n} earlier step${n===1?"":"s"}`}const tE=w.memo(function(e){const t=B.c(15),{blocks:s,expandAll:o}=e,[i,a]=w.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($t,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(tt,{"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 u;t[6]!==s?(u=s.map(nE),t[6]=s,t[7]=u):u=t[7];let f;t[8]!==u?(f=r.jsx(at,{className:"mt-1 flex flex-col gap-2",children:u}),t[8]=u,t[9]=f):f=t[9];let m;return t[10]!==l||t[11]!==c||t[12]!==d||t[13]!==f?(m=r.jsxs(it,{open:l,onOpenChange:c,children:[d,f]}),t[10]=l,t[11]=c,t[12]=d,t[13]=f,t[14]=m):m=t[14],m});function nE(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 Nr(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 u=new Array(d+1).fill(0),f=new Array(d+1).fill(0);for(let p=1;p<=c;p++){f[0]=0;const h=t[a+p-1];for(let g=1;g<=d;g++)h===s[a+g-1]?f[g]=u[g-1]+1:f[g]=u[g]>f[g-1]?u[g]:f[g-1];[u,f]=[f,u]}const m=u[d];return{add:d-m,del:c-m}}function sE(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=Nr("",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=Nr(s,o);return{originalStr:s,currentStr:o,addCount:i.add,delCount:i.del}}const oE=new Set(["echo","printf","true","false",":"]),rE=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),iE=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),aE=new Set(["ls","tree","du"]);function lE(n){return n.split(/\|\||&&|[|;\n]/).map(e=>e.trim()).filter(Boolean)}function cE(n){const e=lE(n);let t=!1,s=!1,o=!1,i=!1;for(const a of e){const l=a.split(/\s+/)[0];if(!(!l||oE.has(l)))if(i=!0,rE.has(l))t=!0;else if(iE.has(l))s=!0;else if(aE.has(l))o=!0;else return"shell"}return i?o?"list":t?"search":s?"read":"shell":"shell"}const dE=/[\\/]claude(?:-\d+)?[\\/](?:[^\\/]+[\\/])+scratchpad[\\/]/i;function uE(n){return dE.test(n)}const fE=new Set(["Grep","Glob"]),mE=new Set(["Bash","PowerShell"]),pE=new Set(["Edit","Write","NotebookEdit","MultiEdit"]),hE=new Set(["Task","Agent"]);function Fp(n){const e=n.file_path??n.path;return typeof e=="string"?e:null}function gE(n){return typeof n.command=="string"?n.command:null}function xE(n){if(!n.startsWith("mcp__"))return null;const e=n.split("__")[1];return e?e.replace(/^claude[._]ai[._]/i,"").replace(/_/g," "):null}function bE(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,u=Nr(typeof c=="string"?c:"",typeof d=="string"?d:"");i+=u.add,a+=u.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=Nr(t,s);return{added:o.add,removed:o.del}}function ro(n,e,t=`${e}s`){return`${n} ${n===1?e:t}`}function vE(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 yE(n,e={}){const t=new Set,s=new Set,o=new Set;let i=0,a=0,l=0,c=0,d=0,u=0,f=0,m=0,p=0,h=0,g=0,x=0;for(const j of n){const k=xE(j.name);if(k){p+=1,o.add(k);continue}if(pE.has(j.name)){const C=Fp(j.input),N=bE(j.name,j.input);C&&uE(C)?(l+=1,c+=N.added,d+=N.removed):(t.add(C??j.id),i+=N.added,a+=N.removed);continue}if(j.name==="Read"){const C=Fp(j.input);C?s.add(C):f+=1;continue}if(fE.has(j.name)){u+=1;continue}if(mE.has(j.name)){const C=gE(j.input);switch(C===null?"shell":cE(C)){case"search":u+=1;break;case"list":m+=1;break;case"read":f+=1;break;default:x+=1}continue}if(hE.has(j.name)){h+=1;continue}g+=1}const b=s.size>0?s.size:f,y=[],v=(j,k,C=0,N=0)=>{y.push(C>0||N>0?{key:j,text:k,added:C,removed:N}:{key:j,text:k})},S=e.thoughtForMs??0;if(S>0&&v("thought",`thought for ${vE(S)}`),t.size>0&&v("edit",`edited ${ro(t.size,"file")}`,i,a),l>0&&v("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),u>0&&v("search",`searched for ${ro(u,"pattern")}`),b>0&&v("read",`read ${ro(b,"file")}`),m>0&&v("list",`listed ${ro(m,"directory","directories")}`),p>0){const j=[...o].join(", ")||"MCP";v("mcp",p>1?`called ${j} ${p} times`:`called ${j}`)}return h>0&&v("agent",`ran ${ro(h,"agent")}`),g>0&&v("other",`called ${ro(g,"tool")}`),x>0&&v("bash",`ran ${x} shell ${x===1?"command":"commands"}`),{clauses:y}}const Bp="text-muted-foreground";function Up(n){const e=B.c(4),{summary:t}=n;let s;e[0]!==t.clauses?(s=t.clauses.map(wE),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 wE(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 Wp=w.memo(function(e){const t=B.c(35),{toolCalls:s,expandAll:o,expandToolPayloads:i,activeToolCallId:a,isAgentActive:l,activityItems:c,thinkingCount:d,thoughtForMs:u,skillMetadata:f}=e,m=l===void 0?!1:l,p=d===void 0?0:d,h=u===void 0?0:u,[g,x]=w.useState(null),b=w.useRef(null),y=m&&s.some(jE);let v;t[0]!==s?(v=s.some(SE),t[0]=s,t[1]=v):v=t[1];const S=v,j=o||S||(g??y),k=g===null&&y&&!o&&!S,C=w.useRef(null),N=w.useRef(null);let _,P;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"})})}))},P=[a,s],t[2]=a,t[3]=s,t[4]=_,t[5]=P):(_=t[4],P=t[5]),w.useEffect(_,P);let A,T;t[6]===Symbol.for("react.memo_cache_sentinel")?(A=()=>()=>{N.current!==null&&cancelAnimationFrame(N.current)},T=[],t[6]=A,t[7]=T):(A=t[6],T=t[7]),w.useEffect(A,T);let E;if(t[8]!==s){const K=new Map;for(const q of s){const{label:Y,styleName:V}=Xa(q),J=K.get(Y);J?(J.count=J.count+1,J.hasError=J.hasError||!!q.isError):K.set(Y,{count:1,styleName:V,hasError:!!q.isError})}E=[...K].sort(NE),t[8]=s,t[9]=E}else E=t[9];const R=E;let I;t[10]!==h||t[11]!==s?(I=yE(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=I):I=t[12];const $=I,M=function(q,Y,V){const J=V??[q],Q=m&&Y&&J.some(kE),X=a!==null&&J.some(Z=>Z.id===a);return r.jsx("div",{ref:X?b:void 0,className:G(X&&"rounded-md ring-1 ring-ring"),children:r.jsx(x2,{toolCall:q,groupedBashCalls:V,expandAll:o,expandToolPayloads:i,isAgentActive:Q,skillMetadata:f})},q.id)},O=function(q,Y){const V=[];let J=0;for(;J<q.length;){const Q=q[J];if(Q.name!=="Bash"){V.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);V.push(M(Q,Y&&X===q.length,Z.length>1?Z:void 0)),J=X}return V};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:O(s,!0)});if(j){let K;t[13]!==o||t[14]!==S||t[15]!==$||t[16]!==p?(K=!o&&!S&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(tt,{"data-icon":"inline-start"}),$.clauses.length>0?r.jsx(Up,{summary:$}):r.jsxs("span",{className:G("font-mono text-xs",Bp),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=S,t[15]=$,t[16]=p,t[17]=K):K=t[17];const q=c?(()=>{const V=zp(c,k);return r.jsxs(r.Fragment,{children:[V.hidden>0&&r.jsx(Hp,{count:V.hidden,onReveal:()=>x(!0)}),(()=>{const J=[];let Q=0;for(;Q<V.visible.length;){const X=V.visible[Q];if(X.kind==="thinking"){J.push(r.jsx(tE,{blocks:X.blocks,expandAll:!1},`thinking-${Q}`)),Q++;continue}const Z=[...X.toolCalls];let te=Q+1;for(;te<V.visible.length&&V.visible[te].kind==="tool_calls";){const ne=V.visible[te];ne.kind==="tool_calls"&&Z.push(...ne.toolCalls),te++}J.push(...O(Z,te===V.visible.length)),Q=te}return J})()]})})():(()=>{const V=zp(s,k);return r.jsxs(r.Fragment,{children:[V.hidden>0&&r.jsx(Hp,{count:V.hidden,onReveal:()=>x(!0)}),O(V.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 D;t[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>x(!0),t[21]=D):D=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]!==$?(F=$.clauses.length>0&&r.jsx(Up,{summary:$}),t[23]=$,t[24]=F):F=t[24];let z;t[25]!==p?(z=p>0&&r.jsxs("span",{className:G("font-mono text-xs",Bp),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=z):z=t[26];let W;t[27]!==R?(W=R.map(CE),t[27]=R,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:D,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 Hp(n){const e=B.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(tt,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=eE(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 jE(n){return n.result===null}function SE(n){return n.name==="AskUserQuestion"}function NE(n,e){return e[1].count-n[1].count}function kE(n){return n.result===null}function CE(n){const[e,t]=n,{count:s,styleName:o,hasError:i}=t;return r.jsxs("span",{className:G("font-mono text-xs",p2(o,i)),children:[e,s>1?` ×${s}`:""]},e)}function _E(n){const e=B.c(15),{label:t,expanded:s,onToggle:o,compact:i}=n,l=(i===void 0?!1:i)&&"min-h-9";let c;e[0]!==l?(c=G("group/fold h-auto min-h-8 w-full cursor-pointer justify-start gap-1.5 px-1 text-left text-xs font-normal text-muted-foreground",l),e[0]=l,e[1]=c):c=e[1];const d=s&&"rotate-90";let u;e[2]!==d?(u=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",d),e[2]=d,e[3]=u):u=e[3];let f;e[4]!==u?(f=r.jsx(Je,{"data-icon":"inline-start",className:u}),e[4]=u,e[5]=f):f=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]!==f||e[13]!==m?(h=r.jsxs(ee,{type:"button",variant:"ghost",onClick:o,"aria-expanded":s,className:c,children:[f,m,p]}),e[9]=s,e[10]=o,e[11]=c,e[12]=f,e[13]=m,e[14]=h):h=e[14],h}const b2="synthesizedFrom",Kp=/[.*+?[\]{}()^$|]/,TE=/[$*?`~]|\\\s/,v2=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,EE=new RegExp(v2,"g");function Nu(n,e,t,s){return{id:e,name:t,input:{...s,[b2]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function PE(n){return typeof n.input[b2]=="string"}function AE(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function qp(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function Ja(n,e){const t=AE(n.trim());return!t||TE.test(t)?null:t.startsWith("/")?qp(t):e?qp(`${e}/${t}`):null}function RE(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 $E(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(EE)){const[,l,c,d]=a,u=c??d,f=[];for(;s<e.length&&e[s].trim()!==u;)f.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,i.set(u,f.join(`
118
+ `)))}for(const a of RE(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function IE(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?Ja(t[1]??t[2]??t[3]??"",e):null}function ME(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 OE(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(v2);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const o=ME(n.text);if(!o)return null;const i=Ja(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function Vp(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==="|"||!Kp.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&Kp.test(i))return null;s+=i}return s}const DE=/^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 LE(n,e){var m;const t=(m=n.text.match(DE))==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=Vp(s,"pattern"),u=Vp(o,"replacement");if(!d||u===null)return null;const f=Ja(a??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:d,new_string:u,replace_all:i.includes("g")}}:null}function y2(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of $E(t)){const a=IE(i.text,o);if(a){o=a;continue}const l=OE(i,o)??LE(i,o);l&&s.push(Nu(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function w2(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=Ja(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:u}=l;typeof c!="string"||typeof d!="string"||i.push(Nu(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:u===!0}))}return i}function j2(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?Fx("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Nu(n,s.id,s.name,s.input)):[]}function ir(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(...w2(s,e)):s.name==="Bash"?t.push(...y2(s,e)):s.name==="apply_patch"&&t.push(...j2(s,e)));return t}function oa(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&w2(t,e).length>0||t.name==="Bash"&&y2(t,e).length>0||t.name==="apply_patch"&&j2(t,e).length>0))return!0;return!1}const zE=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"]),FE={json:Zf,jsonc:Zf,md:Di,mdx:Di,txt:Di,png:$s,jpg:$s,jpeg:$s,gif:$s,webp:$s,svg:$s,ico:$s,sh:gi,bash:gi,zsh:gi,fish:gi};function S2(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function BE(n){const e=S2(n);return FE[e]??(zE.has(e)?Ir:w1)}function Gc(n){const e=B.c(11),{add:t,del:s,dimmed:o,className:i}=n,a=o&&"opacity-40";let l;e[0]!==i||e[1]!==a?(l=G("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",a,i),e[0]=i,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==t?(c=t>0&&r.jsxs("span",{className:"text-success",children:["+",t]}),e[3]=t,e[4]=c):c=e[4];let d;e[5]!==s?(d=s>0&&r.jsxs("span",{className:"text-destructive",children:["-",s]}),e[5]=s,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==c||e[9]!==d?(u=r.jsxs("span",{className:l,children:[c,d]}),e[7]=l,e[8]=c,e[9]=d,e[10]=u):u=e[10],u}const Gp=5;function ku(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 u=Math.round(t/o*Gp);i=Gp-u,a="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:u},WE),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},UE),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 UE(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function WE(n,e){return r.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const ra="cogpit:open-subagent";function N2(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 Cu(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(ra,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const k2=w.memo(function(e){const t=B.c(96),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=I0(),[d,u]=w.useState(o),[f,m]=w.useState(o),p=w.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Se=>{u(Se),Se?w.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]),w.useEffect(x,b);let y,v;t[4]!==i?(y=()=>{i&&g(!0)},v=[i,g],t[4]=i,t[5]=y,t[6]=v):(y=t[5],v=t[6]),w.useEffect(y,v);let S;t[7]!==s.filePath?(S=S2(s.filePath),t[7]=s.filePath,t[8]=S):S=t[8];const j=S,k=s.netOriginal,C=s.netCurrent,N=!!(k||C);let _;t[9]!==s.edits?(_=s.edits.some(VE),t[9]=s.edits,t[10]=_):_=t[10];const A=a==="per-edit"?_:N,T=f&&c&&A,[E,R]=w.useState(0);let I;t[11]===Symbol.for("react.memo_cache_sentinel")?(I=Se=>{if(!Se)return;const Pe=Se.offsetHeight;R(Re=>Re===Pe?Re:Pe)},t[11]=I):I=t[11];const $=I,M=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,O=s.filePath,D=i?"border-ring ring-2 ring-ring/20":"border-border";let L;t[12]!==D?(L=G("rounded-lg border bg-card transition-colors",D),t[12]=D,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(tt,{"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]!==j?(W=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:j}),t[18]=j,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(N2,{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 V;t[31]!==s.editCount?(V=s.editCount>1&&r.jsxs(Ce,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=V):V=t[32];let J;t[33]!==d||t[34]!==F||t[35]!==z||t[36]!==W||t[37]!==K||t[38]!==q||t[39]!==Y||t[40]!==V?(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,V]}),t[33]=d,t[34]=F,t[35]=z,t[36]=W,t[37]=K,t[38]=q,t[39]=Y,t[40]=V,t[41]=J):J=t[41];let Q;t[42]!==s.subAgentId?(Q=s.subAgentId&&r.jsx(Cu,{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:()=>xr(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(Pr,{"data-icon":"inline-start"}),t[46]=Z):Z=t[46];let te;t[47]!==X?(te=r.jsx(Ot,{render:X,children:Z}),t[47]=X,t[48]=te):te=t[48];let ne;t[49]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(Dt,{children:"Open in editor"}),t[49]=ne):ne=t[49];let oe;t[50]!==te?(oe=r.jsxs(Mt,{children:[te,ne]}),t[50]=te,t[51]=oe):oe=t[51];let re;t[52]!==s.filePath?(re=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>xr(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=re):re=t[53];let ae;t[54]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(E3,{"data-icon":"inline-start"}),t[54]=ae):ae=t[54];let se;t[55]!==re?(se=r.jsx(Ot,{render:re,children:ae}),t[55]=re,t[56]=se):se=t[56];let fe;t[57]===Symbol.for("react.memo_cache_sentinel")?(fe=r.jsx(Dt,{children:"View git diff"}),t[57]=fe):fe=t[57];let le;t[58]!==se?(le=r.jsxs(Mt,{children:[se,fe]}),t[58]=se,t[59]=le):le=t[59];let ce;t[60]!==oe||t[61]!==le?(ce=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[oe,le]}),t[60]=oe,t[61]=le,t[62]=ce):ce=t[62];let me;t[63]!==s.addCount?(me=s.addCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-success",children:["+",s.addCount]}),t[63]=s.addCount,t[64]=me):me=t[64];let ue;t[65]!==s.delCount?(ue=s.delCount>0&&r.jsxs("span",{className:"font-mono text-xs tabular-nums text-destructive",children:["-",s.delCount]}),t[65]=s.delCount,t[66]=ue):ue=t[66];let de;t[67]!==s.addCount||t[68]!==s.delCount?(de=r.jsx(ku,{add:s.addCount,del:s.delCount}),t[67]=s.addCount,t[68]=s.delCount,t[69]=de):de=t[69];let be;t[70]!==Q||t[71]!==ce||t[72]!==me||t[73]!==ue||t[74]!==de?(be=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[Q,ce,me,ue,de]}),t[70]=Q,t[71]=ce,t[72]=me,t[73]=ue,t[74]=de,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 he;t[79]!==a||t[80]!==s.edits||t[81]!==s.filePath||t[82]!==s.netStartLine||t[83]!==A||t[84]!==E||t[85]!==C||t[86]!==k||t[87]!==d||t[88]!==T?(he=r.jsx(HE,{showDiff:T,open:d,hasDiff:A,diffRef:$,lastDiffHeight:E,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]=A,t[84]=E,t[85]=C,t[86]=k,t[87]=d,t[88]=T,t[89]=he):he=t[89];let je;return t[90]!==s.filePath||t[91]!==l||t[92]!==L||t[93]!==ge||t[94]!==he?(je=r.jsxs("div",{ref:l,"data-file-path":O,className:L,children:[ge,he]}),t[90]=s.filePath,t[91]=l,t[92]=L,t[93]=ge,t[94]=he,t[95]=je):je=t[95],je}),HE=w.memo(function(e){const t=B.c(15),{showDiff:s,open:o,hasDiff:i,diffRef:a,lastDiffHeight:l,oldString:c,newString:d,filePath:u,diffMode:f,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==f||t[1]!==m||t[2]!==u||t[3]!==p||t[4]!==d||t[5]!==c?(h=f==="per-edit"?r.jsx(qE,{edits:m,filePath:u}):r.jsx(wu,{oldString:c,newString:d,filePath:u,compact:!1,startLine:p,hideHeader:!0}),t[0]=f,t[1]=m,t[2]=u,t[3]=p,t[4]=d,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==f||t[8]!==a||t[9]!==h?(g=r.jsx("div",{ref:a,className:"motion-enter overflow-hidden rounded-b",children:h},f),t[7]=f,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=f==="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}),Yp=3,KE=5,qE=w.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(GE),l=a.length>Yp,[c,d]=w.useState(l?Yp:a.length);w.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(b=>Math.min(b+KE,a.length))});return()=>cancelAnimationFrame(x)},[c,a.length]);const u=l?a.slice(0,c):a,f="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(Cu,{agentId:x.agentId})]}),r.jsx(wu,{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=u.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:f,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function VE(n){return!!(n.oldString||n.newString)}function GE(n){return!!(n.oldString||n.newString)}const Vl=new Map;function YE(n){var S;const e=Pn("hostFiles"),{sessionSource:t}=ct(),s=t==null?void 0:t.dirName,o=Rt(s)==="codex",i=n.turns.length,a=((S=n.turns.at(-1))==null?void 0:S.toolCalls.length)??0,l=w.useMemo(()=>{let j=0;for(const k of n.turns){j+=k.toolCalls.length;for(const C of k.subAgentActivity)j+=C.toolCalls.length}return j},[i,a]),c=w.useMemo(()=>{const j=[];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&&j.push({agentId:C.agentId,turnIndex:k})}return j},[n.turns,l,o]),[d,u]=w.useState(new Map),f=w.useRef(new Set);w.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const j=[];for(const{agentId:N}of c){const _=Kt(`${s}/${n.sessionId}/${N}`);if(!f.current.has(_)){if(Vl.has(_)){u(P=>{const A=new Map(P);return A.set(N,Vl.get(_)),A}),f.current.add(_);continue}j.push({agentId:N,cacheKey:_})}}if(j.length===0)return;let k=!1;async function C(){const N=new Map;await Promise.all(j.map(async({agentId:_,cacheKey:P})=>{try{const A=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(_)}.jsonl`,T=await ve(A);if(!T.ok)return;const E=await T.text(),I=Y0(E,_).flatMap($=>ir($.toolCalls,n.cwd));Vl.set(P,I),f.current.add(P),N.set(_,I)}catch{}})),!k&&N.size>0&&u(_=>{const P=new Map(_);for(const[A,T]of N)P.set(A,T);return P})}return C(),()=>{k=!0}},[s,n.sessionId,n.cwd,c]);const m=w.useMemo(()=>{const j=[],k=new Set;for(let C=0;C<n.turns.length;C++){const N=n.turns[C];for(const _ of ir(N.toolCalls,n.cwd))j.push({turnIndex:C,toolCall:_});for(const _ of N.subAgentActivity){for(const P of ir(_.toolCalls,n.cwd))j.push({turnIndex:C,toolCall:P,agentId:_.agentId});if((_.isBackground||o)&&_.toolCalls.length===0&&!k.has(_.agentId)){k.add(_.agentId);const P=d.get(_.agentId);if(P)for(const A of P)j.push({turnIndex:C,toolCall:A,agentId:_.agentId})}}}return j},[l,n.turns,d,o]),p=w.useMemo(()=>{const j=new Set;for(const k of m){const C=C2(k.toolCall);C&&j.add(C)}return[...j]},[m]),[h,g]=w.useState(new Map);w.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let j=!1;return Promise.all(p.map(k=>ve(`/api/file-content?path=${encodeURIComponent(k)}`).then(C=>C.ok?C.text():null).then(C=>C?[k,C]:null).catch(()=>null))).then(k=>{if(j)return;const C=new Map;for(const N of k)N&&C.set(N[0],N[1]);g(C)}),()=>{j=!0}},[e,p]);const x=n.turns.length-1,b=w.useMemo(()=>ia(m,"all",h),[m,h]),y=w.useMemo(()=>ia(m,x,h),[m,x,h]),v=w.useMemo(()=>{const j=new Map;for(const k of n.turns)for(const C of k.subAgentActivity)j.has(C.agentId)||j.set(C.agentId,{name:C.agentName,type:C.subagentType});return j},[n.turns]);return{fileChanges:m,fileContents:h,groupedByFile:b,groupedLastTurn:y,lastTurnIndex:x,agentMap:v}}function Xp(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 C2(n){return String(n.input.file_path??n.input.path??"")}function XE(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 ia(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=C2(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,u=-1/0,f=!1,m=!1,p;const h=t==null?void 0:t.get(i);for(let b=0;b<a.length;b++){const y=a[b],v=XE(y.toolCall);l.push(v),y.turnIndex<d&&(d=y.turnIndex),y.turnIndex>u&&(u=y.turnIndex),y.toolCall.name==="Edit"?f=!0:m=!0,y.agentId&&(p=y.agentId),c.push({id:y.toolCall.id,oldString:v.oldString,newString:v.newString,toolName:y.toolCall.name,turnIndex:y.turnIndex,agentId:y.agentId,startLine:y.toolCall.name==="Write"?1:Xp(h,v.newString||v.oldString)})}const g=sE(l),x=[];f&&x.push("Edit"),m&&x.push("Write"),o.push({filePath:i,shortPath:i.split("/").slice(-3).join("/"),editCount:a.length,turnRange:[d,u],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?Xp(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 JE(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=ia(l,"all",s);if(c.length===0)continue;let d=0,u=0;for(const m of c)d+=m.addCount,u+=m.delCount;const f=t.get(a);i.push({agentId:a,agentName:(f==null?void 0:f.name)??null,subagentType:(f==null?void 0:f.type)??null,files:c,totalAdd:d,totalDel:u})}return i.sort((a,l)=>{var u,f;const c=((u=a.files[0])==null?void 0:u.turnRange[0])??0,d=((f=l.files[0])==null?void 0:f.turnRange[0])??0;return c-d}),i}const kr="cogpit:focus-file",QE="cogpit:file-changes-prefs",ZE={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function e9(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 u;e[3]!==t.agentId?(u=()=>{window.dispatchEvent(new CustomEvent(ra,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=u):u=e[4];let f;e[5]!==l||e[6]!==d||e[7]!==u?(f=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:u,children:l}),e[5]=l,e[6]=d,e[7]=u,e[8]=f):f=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(Ce,{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]!==f||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:[f,m,p,h,g,x]}),e[18]=f,e[19]=m,e[20]=p,e[21]=g,e[22]=x,e[23]=b):b=e[23];let y;if(e[24]!==s||e[25]!==i||e[26]!==t.files||e[27]!==o){let S;e[29]!==s||e[30]!==i||e[31]!==o?(S=j=>r.jsx(k2,{file:j,defaultOpen:s,isHighlighted:o===j.filePath,diffMode:i},j.filePath),e[29]=s,e[30]=i,e[31]=o,e[32]=S):S=e[32],y=t.files.map(S),e[24]=s,e[25]=i,e[26]=t.files,e[27]=o,e[28]=y}else y=e[28];let v;return e[33]!==b||e[34]!==y?(v=r.jsxs("div",{className:"flex flex-col gap-1",children:[b,y]}),e[33]=b,e[34]=y,e[35]=v):v=e[35],v}const t9=w.memo(function({session:e,sessionChangeKey:t}){const s=w.useRef(null),o=w.useRef(null),i=w.useRef(!0),a=w.useRef(!1),l=w.useRef(0),c=w.useRef(e.turns.length),[d,u]=w.useState(!1),[f,m]=w.useState(!1),[p,h]=Jr(QE,{}),g={...ZE,...p},x=g.expanded,b=g.diffMode,y=g.groupByAgent,[v,S]=w.useState(g.scope),j=w.useCallback(V=>{h(J=>({...J,expanded:V}))},[h]),k=w.useCallback(V=>{h(J=>({...J,diffMode:V}))},[h]),C=w.useCallback(V=>{h(J=>({...J,groupByAgent:V}))},[h]);w.useEffect(()=>{typeof v!="number"&&h(V=>({...V,scope:v}))},[v,h]);const[N,_]=w.useState(null),P=w.useRef(null),{fileChanges:A,fileContents:T,groupedByFile:E,groupedLastTurn:R,lastTurnIndex:I,agentMap:$}=YE(e),M=w.useMemo(()=>typeof v!="number"?null:ia(A,v,T),[A,v,T]);function O(){return typeof v=="number"?M??[]:v==="all"?E:R}const D=O(),L=w.useMemo(()=>y?JE(A,typeof v=="number"?v:v==="all"?"all":I,$,T):[],[y,A,v,I,$,T]);w.useEffect(()=>{const V=J=>{const Q=J.detail;Q!=null&&Q.filePath&&(S(Q.turnIndex),_(Q.filePath),P.current&&clearTimeout(P.current),P.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(kr,V),()=>{window.removeEventListener(kr,V),P.current&&clearTimeout(P.current)}},[]);const F=w.useCallback(()=>{const V=s.current;V&&(u(V.scrollTop>10),m(V.scrollHeight-V.scrollTop-V.clientHeight>10))},[]),z=w.useCallback(()=>{const V=s.current;V&&(i.current=V.scrollHeight-V.scrollTop-V.clientHeight<50,F())},[F]);if(w.useEffect(()=>{F()},[A.length,D.length,F]),w.useEffect(()=>{const V=s.current;V&&(V.scrollTop=V.scrollHeight),i.current=!0,a.current=!1,l.current=A.length,c.current=e.turns.length,S(g.scope),_(null),F()},[t]),w.useEffect(()=>{const V=e.turns.length;V>c.current&&(a.current=!0),c.current=V},[e.turns.length]),w.useEffect(()=>{if(A.length<=l.current){l.current=A.length;return}l.current=A.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var V;(V=o.current)==null||V.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[A.length]),A.length===0)return null;let W=0,U=0,H=0;if(y)for(const V of L)W+=V.totalAdd,U+=V.totalDel,H+=V.files.length;else{for(const V of D)W+=V.addCount,U+=V.delCount;H=D.length}function K(){S(v==="last"?"all":"last")}function q(){return typeof v=="number"?`Turn ${v+1}`:v==="all"?"All turns":`Last turn (T${I+1})`}const Y=q();return r.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-card",children:[r.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[r.jsx(Ir,{"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(Ce,{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(Mt,{children:[r.jsx(Ot,{render:r.jsx(ee,{variant:y?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!y),"aria-label":y?"Show all changes":"Group by subagent"}),children:r.jsx(os,{"data-icon":"inline-start"})}),r.jsx(Dt,{children:y?"Show all changes":"Group by subagent"})]}),r.jsxs(Mt,{children:[r.jsx(Ot,{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(P3,{"data-icon":"inline-start"}):r.jsx(Fs,{"data-icon":"inline-start"})}),r.jsx(Dt,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(Mt,{children:[r.jsx(Ot,{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(A3,{"data-icon":"inline-start"}):r.jsx(R3,{"data-icon":"inline-start"})}),r.jsx(Dt,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(Mt,{children:[r.jsx(Ot,{render:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>j(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(Sa,{"data-icon":"inline-start"}):r.jsx(ja,{"data-icon":"inline-start"})}),r.jsx(Dt,{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"&&I>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{const V=typeof v=="number"?v:I;V>0&&S(V-1)},disabled:(typeof v=="number"?v:I)<=0,"aria-label":"Previous turn",children:r.jsx(bd,{"data-icon":"inline-start"})}),r.jsx("span",{className:G("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:Y}),v!=="all"&&I>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{S(V=>typeof V!="number"?V:V+1>=I?"last":V+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:()=>S("last"),"aria-label":"Back to last turn",children:r.jsx(st,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{className:G("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-background to-transparent transition-opacity duration-200",d?"opacity-100":"opacity-0")}),r.jsxs("div",{ref:s,onScroll:z,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:y?L.length>0?L.map(V=>r.jsx(e9,{group:V,allExpanded:x,highlightPath:N,diffMode:b},V.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",Y.toLowerCase()]}):D.length>0?D.map(V=>r.jsx(k2,{file:V,defaultOpen:x,isHighlighted:N===V.filePath,diffMode:b},V.filePath)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",Y.toLowerCase()]})}),r.jsx("div",{ref:o})]}),r.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-background to-transparent transition-opacity duration-200",f?"opacity-100":"opacity-0")})]})]})});function n9(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??""),u=Nr(c,d),f=t.get(a)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};f.add+=u.add,f.del+=u.del,l?f.hasEdit=!0:f.hasWrite=!0,i&&(f.subAgentId=i),t.set(a,f)}return ir(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>ir(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 Jp(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function s9(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=Jp();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 u=c.children.get(l[d]);u||(u=Jp(),c.children.set(l[d],u)),d===l.length-1&&(u.isFile=!0,u.absPath=i.filePath,u.additions+=i.additions,u.deletions+=i.deletions,i.hasEdit&&(u.hasEdit=!0),i.hasWrite&&(u.hasWrite=!0),i.subAgentId&&(u.subAgentId=i.subAgentId)),c=u}}function o(i,a){return[...i.children.entries()].sort(([c,d],[u,f])=>{const m=d.isFile&&d.children.size===0,p=f.isFile&&f.children.size===0;return m!==p?m?1:-1:c.localeCompare(u)}).map(([c,d])=>{const u=a?`${a}/${c}`:c;if(d.isFile&&d.children.size===0)return{name:c,fullPath:u,absPath:d.absPath,isFile:!0,additions:d.additions,deletions:d.deletions,hasEdit:d.hasEdit,hasWrite:d.hasWrite,subAgentId:d.subAgentId,children:[]};let f=d,m=c,p=u;for(;!f.isFile&&f.children.size===1;){const[S,j]=[...f.children.entries()][0];if(j.isFile&&j.children.size===0)break;m+="/"+S,p+="/"+S,f=j}const h=o(f,p);let g=0,x=0,b=f.isFile?f.hasEdit:!1,y=f.isFile?f.hasWrite:!1,v=f.isFile?f.subAgentId:null;for(const S of h)g+=S.additions,x+=S.deletions,S.hasEdit&&(b=!0),S.hasWrite&&(y=!0),S.subAgentId&&(v=S.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:y,subAgentId:v,children:h}})}return o(s,"")}const o9=w.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=Pn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=n9(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=s9(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const u=d,[f,m]=w.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const R of c)p=p+R.additions,h=h+R.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const x=g;if(c.length===0)return null;const b=f&&"rotate-90";let y;t[14]!==b?(y=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=y):y=t[15];let v;t[16]!==y?(v=r.jsx(Je,{"data-icon":"inline-start",className:y}),t[16]=y,t[17]=v):v=t[17];let S;t[18]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Ir,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=S):S=t[18];const j=c.length!==1?"s":"";let k;t[19]!==c.length||t[20]!==j?(k=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",j]}),t[19]=c.length,t[20]=j,t[21]=k):k=t[21];let C,N;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(Gc,{add:x.add,del:x.del,className:"opacity-80"}),N=r.jsx(ku,{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 P;t[27]!==C||t[28]!==N||t[29]!==v||t[30]!==k?(P=r.jsxs($t,{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,S,k,C,N,_]}),t[27]=C,t[28]=N,t[29]=v,t[30]=k,t[31]=P):P=t[31];let A;if(t[32]!==a||t[33]!==u||t[34]!==o){let R;t[36]!==a||t[37]!==o?(R=I=>r.jsx(r9,{node:I,depth:0,turnIndex:o,canFocusFiles:a},I.fullPath),t[36]=a,t[37]=o,t[38]=R):R=t[38],A=u.map(R),t[32]=a,t[33]=u,t[34]=o,t[35]=A}else A=t[35];let T;t[39]!==A?(T=r.jsx(at,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:A})}),t[39]=A,t[40]=T):T=t[40];let E;return t[41]!==f||t[42]!==P||t[43]!==T?(E=r.jsxs(it,{open:f,onOpenChange:m,children:[P,T]}),t[41]=f,t[42]=P,t[43]=T,t[44]=E):E=t[44],E}),r9=w.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=w.useState(!0),l=t*16+8;if(e.isFile){const c=BE(e.name),d=()=>{o&&e.absPath&&window.dispatchEvent(new CustomEvent(kr,{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:G("h-7 min-w-0 flex-1 justify-start gap-1.5 rounded-sm px-0 font-mono text-xs font-normal disabled:opacity-100",o&&"cursor-pointer"),onClick:d,title:o?"Click to focus in sidebar":void 0,children:[r.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(N2,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Cu,{agentId:e.subAgentId}),r.jsx(Gc,{add:e.additions,del:e.deletions}),r.jsx(ku,{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(tt,{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($3,{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(Gc,{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 i9(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:f=>{f.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(wd,{"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(Ot,{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(Dt,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=d):d=e[10];let u;return e[11]!==l||e[12]!==d?(u=r.jsxs(Mt,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=u):u=e[13],u}function Qa(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(M3,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Za(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("select-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(I3,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function el(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,u=a===void 0?"right":a,f=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=r.jsx(d1,{"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]!==u||e[15]!==f||e[16]!==p?(h=r.jsx(f1,{children:r.jsx(m1,{className:"isolate z-50 outline-none",align:c,alignOffset:d,side:u,sideOffset:f,children:p})}),e[12]=c,e[13]=d,e[14]=u,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function vo(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(u1,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function fF(n){const e=B.c(10);let t,s,o;e[0]!==n?({className:t,inset:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o||e[8]!==i?(a=r.jsx(p1,{"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 rn(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=G("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l||e[10]!==a?(c=r.jsx(c1,{"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 Cr(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(dd,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function a9(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(Za,{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 u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(yd,{"data-icon":"inline-start"}),e[5]=u):u=e[5];let f;e[6]!==d?(f=r.jsx(vo,{children:r.jsxs(rn,{onClick:d,children:[u,"Restore to this point"]})}),e[6]=d,e[7]=f):f=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(Cr,{}),r.jsx(vo,{children:r.jsxs(rn,{onClick:()=>a(s),children:[r.jsx(wd,{"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(Cr,{}),r.jsx(vo,{children:r.jsxs(rn,{onClick:()=>l(s),children:[r.jsx(Rn,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==f||e[16]!==m||e[17]!==p?(h=r.jsxs(el,{className:"min-w-44",children:[f,m,p]}),e[15]=f,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=r.jsxs(Qa,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function _2(n){return r0(n).status(n)}const l9=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function _u(n){switch(n){case"max_turns":return"Stopped — turn limit reached";case"aborted_tools":return"Stopped — tools aborted";case"blocking_limit":return"Stopped — blocked";default:return`Stopped — ${n.replace(/_/g," ")}`}}function Zr(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&l9.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?_u(t):"Done";default:return null}}function c9(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(D3,{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(Gs,{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(O3,{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(Sa,{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(wo,{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(Wn,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const Qp=2e3,T2=600;function E2(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,u=a?"opacity-0":"opacity-100";let f;e[2]!==u?(f=G("flex items-center gap-2.5 min-w-0 transition-opacity",u),e[2]=u,e[3]=f):f=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m={transitionDuration:`${T2}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(c9,{status:t.status}),e[5]=t.status,e[6]=p):p=e[6];const h=!l&&"text-muted-foreground",g=l&&t.terminalReason&&"text-warning",x=l&&!t.terminalReason&&"text-success";let b;e[7]!==h||e[8]!==g||e[9]!==x?(b=G("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=b):b=e[10];let y;e[11]!==s||e[12]!==b?(y=r.jsx("span",{className:b,children:s}),e[11]=s,e[12]=b,e[13]=y):y=e[13];let v;e[14]!==l||e[15]!==i?(v=!l&&i&&r.jsx(Tu,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=v):v=e[16];let S;e[17]!==d?(S=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]=S):S=e[18];let j;e[19]!==t.pendingQueue?(j=(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]=j):j=e[20];let k;return e[21]!==y||e[22]!==v||e[23]!==S||e[24]!==j||e[25]!==f||e[26]!==p?(k=r.jsxs("div",{className:f,style:m,children:[p,y,v,S,j]}),e[21]=y,e[22]=v,e[23]=S,e[24]=j,e[25]=f,e[26]=p,e[27]=k):k=e[27],k}function d9(n){const e=B.c(28),{status:t,durationLabel:s}=n,[o,i]=w.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),Qp),g=setTimeout(()=>i("ready"),Qp+T2);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),w.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Wn,{className:"size-4 shrink-0 text-success"}),e[2]=h):h=e[2];const g=t.terminalReason?"text-warning":"text-muted-foreground";let x;e[3]!==g?(x=G("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?_u(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let y;e[7]!==x||e[8]!==b?(y=r.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=y):y=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 S;return e[12]!==y||e[13]!==v?(S=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,y,v]}),e[12]=y,e[13]=v,e[14]=S):S=e[14],S}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Zr(t.status,t.toolName,t.terminalReason)??"Done",e[15]=t.status,e[16]=t.terminalReason,e[17]=t.toolName,e[18]=c):c=e[18];const d=c,u=o==="fading";let f;e[19]!==d||e[20]!==t||e[21]!==u?(f=r.jsx(E2,{status:t,label:d,fading:u}),e[19]=d,e[20]=t,e[21]=u,e[22]=f):f=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]!==f||e[26]!==m?(p=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[f,m]}),e[25]=f,e[26]=m,e[27]=p):p=e[27],p}const u9=w.memo(function(){const e=B.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=ct(),[l,c]=w.useState(!1),[d,u]=w.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=w.useState(f);f!==m&&(p(f),c(!1),u(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={status:"compacting"},e[0]=R):R=e[0],h=R;break e}const T=t.rawMessages;let E;e[1]!==T?(E=_2(T),e[1]=T,e[2]=E):E=e[2],h=E}const g=h;let x,b;e[3]!==g||e[4]!==s||e[5]!==d?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!d&&c(!0);return}if(g.status==="completed"){u(!0);return}c(!1),u(!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]),w.useEffect(x,b);let y;e:{if(!g){y=null;break e}if(g.status==="compacting"){y=g;break e}if(g.status==="completed"){if(l){y=null;break e}if(!s&&!d){y=null;break e}y=g;break e}if(!s||g.status==="idle"){y=null;break e}y=g}const v=y,S=(v==null?void 0:v.status)==="completed",j=(t==null?void 0:t.turns[t.turns.length-1])??null;let k;e:{if(!S||!j){k=null;break e}let T;if(e[8]!==j){const E=Ed(j);T=E!==null?Un(E):null,e[8]=j,e[9]=T}else T=e[9];k=T}const C=k;if(a&&o==="connected"){let T;e[10]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(k1,{className:"size-5 shrink-0 text-info"}),e[10]=T):T=e[10];const E=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let R;return e[11]!==E?(R=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[T,r.jsx("span",{className:"text-xs font-medium text-info",children:E})]}),e[11]=E,e[12]=R):R=e[12],R}if(!v)return null;if(S){let T;return e[13]!==v||e[14]!==C?(T=r.jsx(d9,{status:v,durationLabel:C}),e[13]=v,e[14]=C,e[15]=T):T=e[15],T}let N;e[16]!==v.pendingAgents||e[17]!==v.status||e[18]!==v.terminalReason||e[19]!==v.toolName?(N=Zr(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 P=j==null?void 0:j.timestamp;let A;return e[21]!==v||e[22]!==_||e[23]!==P?(A=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(E2,{status:v,label:_,startTimestamp:P})}),e[21]=v,e[22]=_,e[23]=P,e[24]=A):A=e[24],A});function Tu(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(f9,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function f9(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=w.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=Un(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]),w.useEffect(l,c);let d;e[5]!==s?(d=G("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=d):d=e[6];const u=Math.max(0,Date.now()-i);let f;e[7]!==u?(f=Un(u),e[7]=u,e[8]=f):f=e[8];let m;return e[9]!==d||e[10]!==f?(m=r.jsx("span",{ref:a,className:d,children:f}),e[9]=d,e[10]=f,e[11]=m):m=e[11],m}function m9(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 p9=6e5;function h9(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,p9)}function Zp(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+=h9(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 Yc=new Map,g9=300*1e3;function eh(n){const e=Yc.get(n);return e?Date.now()>e.expiresAt?(Yc.delete(n),null):e.data:null}function x9(n,e){Yc.set(n,{data:e,expiresAt:Date.now()+g9})}function b9(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?eh(Kt(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=w.useState(t),i=w.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||Oa(window.location.pathname))return;const c=Kt(n),d=eh(c);if(d){o(d);return}i.current=n;const u=new AbortController;return ve(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:u.signal}).then(async f=>{if(u.signal.aborted||i.current!==n||!f.ok)return;const m=await f.json();if(u.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});x9(c,p),o(p)}).catch(v9),()=>u.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),w.useEffect(a,l),s}function v9(){}const y9=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),w9=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),j9=new Set(["AskUserQuestion","ExitPlanMode"]),S9=new Set(["text","thinking","tool_calls"]);function N9(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>j9.has(e.name)&&e.result==null)}function k9(n){for(let e=n.length-1;e>=0;e--){if(N9(n[e]))return e;if(S9.has(n[e].kind))return-1}return-1}const Ei={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function C9(n,e="settled"){if(n.length===0||!n.some(a=>w9.has(a.kind)))return Ei;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 Ei}const s=k9(n),o=[];let i=0;for(let a=0;a<n.length;a++){if(a===t||a===s)continue;const l=n[a];y9.has(l.kind)||(o.push(a),l.kind==="tool_calls"&&(i+=l.toolCalls.length))}return o.length===0?Ei:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function _9(n,e){return n!==null&&n>0?`Worked for ${Un(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const P2="border border-border bg-prompt-surface",th="border-l border-border/40",nh="border-l border-border";function A2(n){const e=B.c(20),{turn:t,index:s,branchCount:o}=n,i=o===void 0?0:o,{state:a,isMobile:l}=Ut(),{activeTurnIndex:c,activeToolCallId:d,expandAll:u,expandToolPayloads:f}=a,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x}=ct(),b=p&&m!==null,y=b&&s===((m==null?void 0:m.turns.length)??0)-1;let v=!y;if(y&&m){let _;if(e[0]!==m.rawMessages){const{status:P}=_2(m.rawMessages);_=hu.has(P),e[0]=m.rawMessages,e[1]=_}else _=e[1];v=!_}const S=(m==null?void 0:m.cwd)??"",j=b9(S),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]!==S||e[8]!==u||e[9]!==f||e[10]!==s||e[11]!==y||e[12]!==l||e[13]!==b||e[14]!==v||e[15]!==j||e[16]!==k||e[17]!==C||e[18]!==t?(N=r.jsx(P9,{turn:t,index:s,branchCount:i,isActive:k,activeToolCallId:d,expandAll:u,expandToolPayloads:f,isAgentActive:y,isSessionLive:b,isTurnDone:v,isMobile:l,cwd:S,skillMetadata:j,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]=S,e[8]=u,e[9]=f,e[10]=s,e[11]=y,e[12]=l,e[13]=b,e[14]=v,e[15]=j,e[16]=k,e[17]=C,e[18]=t,e[19]=N):N=e[19],N}function T9(n){const e=B.c(12),{index:t,children:s}=n,{session:o,isSubAgentView:i,undoRedo:a,actions:l}=ct(),{requestUndo:c,branchesAtTurn:d}=a,{handleOpenBranches:u,handleBranchFromHere:f}=l,m=t>=((o==null?void 0:o.turns.length)??0);if(!a.enabled||i||m||!c||!u){let g;return e[0]!==s?(g=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=g):g=e[1],g}let p;e[2]!==d||e[3]!==t?(p=d(t),e[2]=d,e[3]=t,e[4]=p):p=e[4];let h;return e[5]!==s||e[6]!==f||e[7]!==u||e[8]!==t||e[9]!==c||e[10]!==p?(h=r.jsx(a9,{turnIndex:t,branches:p,onRestoreToHere:c,onOpenBranches:u,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=u,e[8]=t,e[9]=c,e[10]=p,e[11]=h):h=e[11],h}function E9(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=_9(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(Tu,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const P9=w.memo(function({turn:e,index:t,branchCount:s,isActive:o,activeToolCallId:i,expandAll:a,expandToolPayloads:l,isAgentActive:c,isSessionLive:d,isTurnDone:u,isMobile:f,cwd:m,skillMetadata:p,onRestoreToHere:h,onOpenBranches:g,onEditCommand:x,onExpandCommand:b}){const{ref:y,isNear:v}=I0(),S=w.useRef(null),j=w.useRef(0);w.useLayoutEffect(()=>{v&&S.current&&(j.current=S.current.offsetHeight)},[v]);const k=oa(e.toolCalls,m)||e.subAgentActivity.some(R=>oa(R.toolCalls,m)),C=u?"settled":"working",N=w.useMemo(()=>C9(e.contentBlocks,C),[C,e.contentBlocks]),[_,P]=w.useState(void 0),A=_??(a||!u),{leadingBlocks:T,trailingBlocks:E}=w.useMemo(()=>{if(!N.foldable)return{leadingBlocks:[],trailingBlocks:[]};const R=N.foldAnchorIndex,I=new Set(N.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,R),trailingBlocks:e.contentBlocks.slice(R).filter(($,M)=>A||!I.has(R+M))}},[N,e.contentBlocks,A]);return r.jsxs("div",{ref:y,"data-turn-index":t,className:G("group relative",f?"px-1 py-3":"px-4 py-5",o&&"rounded-lg ring-1 ring-ring/40"),children:[r.jsx(R9,{index:t,turn:e,branchCount:s,isTurnDone:u,isMobile:f,onRestoreToHere:h,onOpenBranches:g}),v?r.jsxs("div",{ref:S,className:G("flex flex-col",f?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx(T9,{index:t,children:r.jsx("div",{"data-turn-prompt":!0,className:G(f?"rounded-lg p-2.5":"rounded-lg p-3",P2),children:r.jsx(uu,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b,compact:f})})}),N.foldable?r.jsxs(r.Fragment,{children:[T.length>0&&r.jsx(Gl,{blocks:T,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p}),r.jsx(_E,{label:r.jsx(E9,{turn:e,isTurnDone:u,hiddenToolCalls:N.hiddenToolCalls}),expanded:A,onToggle:()=>P(!A),compact:f}),E.length>0&&r.jsx(Gl,{blocks:E,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p})]}):r.jsx(Gl,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p}),u&&k&&r.jsx(o9,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:j.current||A9(e)}})]})});function A9(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function R9(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 u;e[0]!==i||e[1]!==s?(u=i?Ed(s):null,e[0]=i,e[1]=s,e[2]=u):u=e[2];const f=u,m=a?"mb-2 gap-1.5":"mb-4 gap-2";let p;e[3]!==m?(p=G("flex items-center",m),e[3]=m,e[4]=p):p=e[4];const h=a?`Turn ${t+1}`:t+1;let g;e[5]!==h?(g=r.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h}),e[5]=h,e[6]=g):g=e[6];let x;e[7]!==f||e[8]!==d||e[9]!==s.timestamp?(x=r.jsx($9,{durationMs:f,showLiveTimer:d,timestamp:s.timestamp}),e[7]=f,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:G("ml-auto text-muted-foreground transition-opacity hover:text-foreground",a?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[r.jsx(yd,{"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 y;e[15]!==o||e[16]!==t||e[17]!==c||e[18]!==l?(y=o>0&&c&&r.jsx("div",{className:G(!l&&"ml-auto"),children:r.jsx(i9,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=y):y=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==y?(v=r.jsxs("div",{className:p,children:[g,x,b,y]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=y,e[25]=v):v=e[25],v}function $9(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(Fs,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=Un(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(Fs,{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(Tu,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function I9(n){var e,t,s;switch(n.kind){case"tool_calls":return((e=n.toolCalls[0])==null?void 0:e.id)??null;case"sub_agent":case"background_agent":return((t=n.messages[0])==null?void 0:t.parentToolUseId)??((s=n.messages[0])==null?void 0:s.agentId)??null;default:return n.timestamp??null}}function Gl(n){const e=B.c(11),{blocks:t,model:s,effort:o,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,isSessionLive:d,isMobile:u,skillMetadata:f}=n;let m;if(e[0]!==l||e[1]!==t||e[2]!==o||e[3]!==i||e[4]!==a||e[5]!==c||e[6]!==u||e[7]!==d||e[8]!==s||e[9]!==f){const p=[],h=u?"ml-0 pl-2":"ml-1 pl-3",g=u?"gap-2":"gap-3",x=new Map,b=(v,S)=>{const j=I9(v)??`at-${S}`,k=x.get(j)??0;return x.set(j,k+1),k===0?j:`${j}#${k}`};let y=0;for(;y<t.length;){const v=t[y];if(v.kind==="thinking"||v.kind==="tool_calls"){const{items:S,toolCalls:j,thinkingCount:k,thoughtForMs:C,nextIndex:N}=Zp(t,y),_=S.length===1&&S[0].kind==="tool_calls";p.push(r.jsx("div",{className:G(th,h),children:r.jsx(Wp,{toolCalls:j,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:_?void 0:S,thinkingCount:k,thoughtForMs:C,skillMetadata:f})},b(v,y))),y=N;continue}if(v.kind==="text"){const{items:S,toolCalls:j,thinkingCount:k,thoughtForMs:C,nextIndex:N}=Zp(t,y+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:G("flex flex-col",g),children:v.text.map((_,P)=>r.jsx(c7,{text:_,model:s,effort:o,timestamp:v.timestamp,compact:u},P))}),(j.length>0||k>0)&&r.jsx("div",{className:G("mt-1.5",th,h),children:r.jsx(Wp,{toolCalls:j,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:k>0?S:void 0,thinkingCount:k,thoughtForMs:C,skillMetadata:f})})]},b(v,y))),y=N;continue}if(v.kind==="queued_prompt"){p.push(r.jsxs("div",{className:G(u?"rounded-lg p-2.5":"rounded-lg p-3",P2),children:[r.jsx(Ce,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(uu,{content:v.content,timestamp:v.timestamp??"",compact:u})]},b(v,y))),y++;continue}if(v.kind==="agent_message"){p.push(r.jsx(i7,{sender:v.sender,body:v.body,reply:v.reply,timestamp:v.timestamp,isLive:d},b(v,y))),y++;continue}if(v.kind==="sub_agent"){p.push(r.jsx("div",{className:G(nh,h),children:r.jsx(T7,{messages:v.messages,expandAll:i})},b(v,y))),y++;continue}if(v.kind==="background_agent"){p.push(r.jsx("div",{className:G(nh,h),children:r.jsx(E7,{messages:v.messages,expandAll:i})},b(v,y))),y++;continue}if(v.kind==="hook_event"){p.push(r.jsx(A7,{events:v.events},b(v,y))),y++;continue}if(v.kind==="plan_mode"){p.push(r.jsx(Q8,{plan:v.plan,planFilePath:v.planFilePath,status:v.status,toolCalls:v.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:f},b(v,y))),y++;continue}if(v.kind==="recap"){p.push(r.jsx(Z8,{content:v.content,timestamp:v.timestamp},b(v,y))),y++;continue}if(v.kind==="task_notification"){p.push(r.jsx(n_,{content:v.content},b(v,y))),y++;continue}y++}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]=u,e[7]=d,e[8]=s,e[9]=f,e[10]=m}else m=e[10];return m}function M9(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${mt(n.preTokens)} → ${mt(n.postTokens)}`:`${e} · ${mt(n.preTokens)}`}const O9=w.memo(function(e){const t=B.c(30),{summary:s,meta:o}=e,[i,a]=w.useState(!1);let l;t[0]!==o?(l=M9(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 u=d;let f;t[4]!==u||t[5]!==i?(f=u&&(i?r.jsx(tt,{className:"size-3","data-icon":"inline-start"}):r.jsx(Je,{className:"size-3","data-icon":"inline-start"})),t[4]=u,t[5]=i,t[6]=f):f=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(L3,{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]!==f||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:[f,m,p,h]}),t[11]=f,t[12]=h,t[13]=g):g=t[13];const x=g;if(!u){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 P;return t[16]!==x?(P=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,_]}),t[16]=x,t[17]=P):P=t[17],P}let b,y;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"}),y=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=b,t[19]=y):(b=t[18],y=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 S;t[21]!==x?(S=r.jsxs($t,{render:b,children:[y,x,v]}),t[21]=x,t[22]=S):S=t[22];let j;t[23]===Symbol.for("react.memo_cache_sentinel")?(j=[ka],t[23]=j):j=t[23];let k;t[24]!==u?(k=r.jsx(at,{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(Hn,{remarkPlugins:j,components:Yn,children:u})})}),t[24]=u,t[25]=k):k=t[25];let C;return t[26]!==i||t[27]!==S||t[28]!==k?(C=r.jsxs(it,{open:i,onOpenChange:a,className:"px-4 py-2",children:[S,k]}),t[26]=i,t[27]=S,t[28]=k,t[29]=C):C=t[29],C}),D9=1.5;function L9(n,e){return e<=0?!1:n<e*D9}function z9(n,e){return n===0&&!e}function F9(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function B9(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const U9=1e3;function W9(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)<=U9?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function R2(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&&B9(i,t)?[...o.slice(0,-1),K9(a,i),...n.slice(1)]:[...o,...n];return tu(W9(l))}function H9(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 K9(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:H9(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function q9(){const n=B.c(10),{session:e,isSubAgentView:t,undoRedo:s}=ct(),{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 u;n[0]!==i||n[1]!==l?(u=r.jsx(O_,{redoTurnCount:i,onRedoAll:l}),n[0]=i,n[1]=l,n[2]=u):u=n[2];let f;n[3]!==a||n[4]!==c||n[5]!==d?(f=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(A2,{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(z3,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=a,n[4]=c,n[5]=d,n[6]=f):f=n[6];let m;return n[7]!==u||n[8]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),n[7]=u,n[8]=f,n[9]=m):m=n[9],m}function V9(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(lt,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:r.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:o}),e[3]=o,e[4]=i):i=e[4],i}function G9(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function Y9({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Ut(),{undoRedo:l}=ct(),c=w.useRef(null),d=w.useRef(null),[u,f]=w.useState(0),m=w.useMemo(()=>{const v=new Map;return n.map(S=>{const j=v.get(S.turn.id)??0;return v.set(S.turn.id,j+1),{...S,key:j===0?S.turn.id:`${S.turn.id}#${j}`}})},[n]),p=w.useRef(null),h=w.useMemo(()=>F9(p.current,m.map(v=>v.key)),[m]);w.useLayoutEffect(()=>{var v;p.current={firstKey:(v=m[0])==null?void 0:v.key,length:m.length}},[m]);const g=w.useRef(t);w.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;w.useLayoutEffect(()=>{const v=e.current,S=d.current;if(!v||!S)return;const j=S.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;f(k=>Math.abs(k-j)<1?k:j)},[e,x]),w.useEffect(()=>{if(!t||!i||!o||s)return;const v=e.current;if(!v)return;const S=()=>{L9(v.scrollTop,v.clientHeight)&&i()};return S(),v.addEventListener("scroll",S,{passive:!0}),()=>v.removeEventListener("scroll",S)},[t,s,o,i,m.length,e]);const b=w.useMemo(()=>{const v=new Map;for(let S=0;S<m.length;S++)v.set(m[S].index,S);return v},[m]),y=w.useRef(null);return w.useEffect(()=>{var S;if(a===null){y.current=null;return}if(a===y.current)return;y.current=a;const v=b.get(a);v!==void 0&&((S=c.current)==null||S.scrollToIndex(v,{align:"start",smooth:!0}))},[a,b]),r.jsxs(r.Fragment,{children:[x&&r.jsx(V9,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(M_,{ref:c,scrollRef:e,startMargin:u,shift:h,children:m.map(({turn:v,index:S,key:j})=>r.jsxs("div",{"data-turn-index":S,children:[(v.compactionSummary||v.compactionMeta)&&r.jsx(O9,{summary:v.compactionSummary,meta:v.compactionMeta}),!G9(v)&&r.jsx(A2,{turn:v,index:S,branchCount:l.branchesAtTurn?l.branchesAtTurn(S).length:0})]},j))})}),r.jsx(q9,{})]})}const X9=w.memo(function(e){const t=B.c(19),{chatScrollRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l}=e,{state:c}=Ut(),{searchQuery:d,sessionChangeKey:u}=c,{session:f}=ct(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(J9):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==d?(g=d?h.filter(S=>{const{turn:j}=S;return m9(j,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:z9(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=b):b=t[8];const y=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]!==u||t[17]!==y?(v=r.jsx($6,{children:y?r.jsx(dn,{className:"min-h-64 border-0",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:d?r.jsx(F3,{}):r.jsx(C1,{})}),r.jsx(fn,{children:d?"No matching turns":"No conversation yet"}),r.jsx(yn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(Y9,{filteredTurns:x,scrollContainerRef:s,hasMore:o,isLoadingOlder:i,pagingEnabled:a,onLoadMore:l},u)}),t[9]=s,t[10]=x,t[11]=o,t[12]=i,t[13]=l,t[14]=a,t[15]=d,t[16]=u,t[17]=y,t[18]=v):v=t[18],v});function J9(n,e){return{turn:n,index:e}}const Q9="[data-turn-index]",$2="[data-turn-prompt]",sh=1,Z9=120,oh=180;function eP(n){if(!n.userMessage)return null;const e=Ga(n.userMessage),{body:t}=yr(e),{remainingText:s}=jr(t),o=du(s);if(!o){const a=h0(e);if(!a)return null;const l=g0(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
121
+ `)[0];return i.length>oh?`${i.slice(0,oh)}...`:i}function tP(n,e){for(let t=e;t>=0;t--){const s=n[t];if(!s)continue;const o=eP(s);if(o)return{index:t,text:o}}return null}function nP(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(Q9)){const c=l.getBoundingClientRect().top;if(c>e+sh)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($2);return(i?i.getBoundingClientRect().bottom>e+sh:s+Z9>e)?null:o}const sP=w.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=w.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const S=o.current;if(!S)return;let j=null;const k=()=>{j=null;const P=nP(S);a(A=>P===null?null:(A==null?void 0:A.sessionId)===s.sessionId&&A.index===P?A:{sessionId:s.sessionId,index:P})},C=()=>{j===null&&(j=requestAnimationFrame(k))};a(null),S.addEventListener("scroll",C,{passive:!0});const N=new MutationObserver(C);N.observe(S,{childList:!0,subtree:!0});const _=new ResizeObserver(C);return _.observe(S),S.firstElementChild&&_.observe(S.firstElementChild),C(),()=>{S.removeEventListener("scroll",C),N.disconnect(),_.disconnect(),j!==null&&cancelAnimationFrame(j)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),w.useEffect(l,c);let d;e:{if(!i||i.sessionId!==s.sessionId){d=null;break e}let S;t[4]!==s.turns||t[5]!==i.index?(S=tP(s.turns,i.index),t[4]=s.turns,t[5]=i.index,t[6]=S):S=t[6],d=S}const u=d;if(!u)return null;let f;t[7]!==u.index||t[8]!==o?(f=()=>{const S=o.current;if(!S)return;const j=S.querySelector(`[data-turn-index="${u.index}"]`),k=(j==null?void 0:j.querySelector($2))??j;if(!k)return;const C=S.scrollTop+k.getBoundingClientRect().top-S.getBoundingClientRect().top;S.scrollTo({top:Math.max(0,C),behavior:"smooth"})},t[7]=u.index,t[8]=o,t[9]=f):f=t[9];const m=f,p=`Scroll to turn ${u.index+1} prompt`;let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(C1,{"data-icon":"inline-start"}),t[10]=h):h=t[10];const g=u.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]!==u.text?(b=r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:u.text}),t[13]=u.text,t[14]=b):b=t[14];let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Ar,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=y):y=t[15];let v;return t[16]!==u.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:u.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,y]}),t[16]=u.text,t[17]=m,t[18]=p,t[19]=x,t[20]=b,t[21]=v):v=t[21],v});function oP(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(rh,{}),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(bu,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(rh,{}),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 rh(){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 rP=w.memo(function(){const e=B.c(9),t=xu();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=p7(t);if(c.length===0){a=null;break e}const d=new Map;s="px-4",o="streaming-turn-overlay",i=c.map(u=>{const f=d.get(u.messageId)??0;d.set(u.messageId,f+1);const m=u.blocks.reduce(iP,-1);return r.jsx("div",{children:u.blocks.map((p,h)=>r.jsx(oP,{block:p,showCursor:!u.stopped&&h===m},p.index))},`${u.messageId}:${f}`)})}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 iP(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}const aP=3,aa=["w-6","w-4","w-2.5","w-2"],lP=aa[aa.length-1];function cP(n){return n===null||n<0?lP:aa[Math.min(n,aa.length-1)]}function dP(n){return n.type==="text"}function Yl(n){return n.replace(/\s+/g," ").trim()}function uP(n){const e=typeof n.userMessage=="string"?n.userMessage:Array.isArray(n.userMessage)?n.userMessage.filter(dP).map(l=>l.text).join(" "):"",{text:t}=v0(e),{remainingText:s}=jr(t),{remainingText:o}=b0(s),i=Yl(du(o));if(i)return i;for(const l of n.contentBlocks){if(l.kind!=="task_notification")continue;const c=jr(l.content).notifications.map(d=>d.summary).find(Boolean);if(c)return Yl(c)}return n.assistantText.map(Yl).find(Boolean)||"Untitled turn"}const fP=w.memo(function(e){const t=B.c(21),{turns:s,scrollContainerRef:o,onJumpToTurn:i}=e,[a,l]=w.useState(null),c=w.useRef(null),d=s.length;let u;if(t[0]!==s){const S=new Map;u=s.map(j=>{const k=S.get(j.id)??0;return S.set(j.id,k+1),k===0?j.id:`${j.id}#${k}`}),t[0]=s,t[1]=u}else u=t[1];const f=u;let m;t[2]!==o?(m=()=>{const S=o.current,j=c.current;if(!S||!j)return;let k=null;const C=()=>{k=null;const _=S.getBoundingClientRect().top+S.clientHeight/2;let P=null;for(const A of S.querySelectorAll("[data-turn-index]")){const T=A.getBoundingClientRect();if(T.top<=_&&T.bottom>=_){P=Number(A.dataset.turnIndex);break}}for(const A of j.querySelectorAll("[data-tick-index]"))A.dataset.current=String(Number(A.dataset.tickIndex)===P)},N=()=>{k===null&&(k=requestAnimationFrame(C))};return C(),S.addEventListener("scroll",N,{passive:!0}),()=>{S.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],w.useEffect(m,p);let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=S=>{const j=S.key==="ArrowDown"?1:S.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(j!==0){const _=C.indexOf(document.activeElement);N=C[Math.min(Math.max(_+j,0),C.length-1)]}else S.key==="Home"?N=C[0]:S.key==="End"&&(N=C[C.length-1]);N&&(S.preventDefault(),N.focus())},t[7]=h):h=t[7];const g=h;if(d<aP)return null;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(null),t[8]=x):x=t[8];let b;t[9]===Symbol.for("react.memo_cache_sentinel")?(b=G("absolute left-0 top-0 hidden h-full max-h-full flex-col items-start gap-1","justify-evenly overflow-y-auto pb-6 pl-2 pt-14","opacity-60 transition-opacity hover:opacity-100 focus-within:opacity-100","[@media(pointer:fine)]:flex"),t[9]=b):b=t[9];let y;if(t[10]!==a||t[11]!==i||t[12]!==f||t[13]!==s){let S;t[15]!==a||t[16]!==i||t[17]!==f?(S=(j,k)=>{const C=uP(j);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:G("group/tick relative h-1 shrink-0 rounded-full bg-muted-foreground/30 p-0","transition-[width,background-color] duration-150 motion-reduce:transition-none","hover:bg-muted-foreground/80 focus-visible:outline-none focus-visible:bg-muted-foreground/80","data-[current=true]:bg-primary/70",cP(a===null?null:Math.abs(k-a))),children:r.jsxs("span",{className:G("pointer-events-none absolute left-full top-1/2 ml-2 hidden w-64 -translate-y-1/2","rounded-md border bg-popover px-2 py-1.5 text-left","text-xs leading-relaxed text-popover-foreground shadow-sm","group-hover/tick:block group-focus-visible/tick:block"),children:[r.jsx("span",{className:"mr-1 font-mono text-muted-foreground/60",children:k+1}),r.jsx("span",{className:"line-clamp-2 align-middle",children:C})]})},f[k])},t[15]=a,t[16]=i,t[17]=f,t[18]=S):S=t[18],y=s.map(S),t[10]=a,t[11]=i,t[12]=f,t[13]=s,t[14]=y}else y=t[14];let v;return t[19]!==y?(v=r.jsx("nav",{ref:c,"aria-label":"Conversation timeline",onMouseLeave:x,onKeyDown:g,className:b,children:y}),t[19]=y,t[20]=v):v=t[20],v});class mP extends w.Component{constructor(t){super(t);hi(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(pt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(bn,{}),r.jsx(Et,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(ht,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(Cs,{className:"static col-start-2 mt-2",children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(At,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const ih="find-in-session-highlight",Xl="find-in-session-active";function pP(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 hP=w.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=w.useState(!1),[l,c]=w.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[u,f]=w.useState(d),[m,p]=w.useState(-1),h=w.useRef(null);let g;s[1]!==o?(g=()=>{const ne=o.current;if(!ne)return;ne.querySelectorAll(`mark.${ih}`).forEach(gP)},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){f([]),p(-1);return}const oe=o.current,re=pP(oe),ae=ne.toLowerCase(),se=[];for(const fe of re){const le=fe.nodeValue||"",ce=le.toLowerCase();let me=0;const ue=[];for(;;){const he=ce.indexOf(ae,me);if(he===-1)break;ue.push(he),me=he+1}if(ue.length===0)continue;const de=fe.parentNode;if(!de)continue;const be=document.createDocumentFragment();let ge=0;for(const he of ue){he>ge&&be.appendChild(document.createTextNode(le.slice(ge,he)));const je=document.createElement("mark");je.className=ih,je.textContent=le.slice(he,he+ne.length),be.appendChild(je),se.push(je),ge=he+ne.length}ge<le.length&&be.appendChild(document.createTextNode(le.slice(ge))),de.replaceChild(be,fe)}f(se),se.length>0?(p(0),se[0].classList.add(Xl),se[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=b):b=s[5];const y=b;let v;s[6]!==m||s[7]!==u?(v=ne=>{if(u.length===0)return;m>=0&&m<u.length&&u[m].classList.remove(Xl);const oe=(ne%u.length+u.length)%u.length;u[oe].classList.add(Xl),u[oe].scrollIntoView({block:"center",behavior:"smooth"}),p(oe)},s[6]=m,s[7]=u,s[8]=v):v=s[8];const S=v;let j;s[9]!==x?(j=()=>{a(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=j):j=s[10];const k=j;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]),w.useImperativeHandle(t,C,N);let _,P;s[15]!==y||s[16]!==l?(_=()=>{const ne=setTimeout(()=>y(l),150);return()=>clearTimeout(ne)},P=[l,y],s[15]=y,s[16]=l,s[17]=_,s[18]=P):(_=s[17],P=s[18]),w.useEffect(_,P);let A,T;s[19]!==x?(A=()=>()=>x(),T=[x],s[19]=x,s[20]=A,s[21]=T):(A=s[20],T=s[21]),w.useEffect(A,T);let E;s[22]!==m||s[23]!==S||s[24]!==k?(E=ne=>{ne.key==="Escape"?(ne.preventDefault(),ne.stopPropagation(),k()):ne.key==="Enter"&&(ne.preventDefault(),ne.shiftKey?S(m-1):S(m+1))},s[22]=m,s[23]=S,s[24]=k,s[25]=E):E=s[25];const R=E;if(!i)return null;let I;s[26]===Symbol.for("react.memo_cache_sentinel")?(I=ne=>c(ne.target.value),s[26]=I):I=s[26];let $;s[27]!==R||s[28]!==l?($=r.jsx(ds,{ref:h,value:l,onChange:I,onKeyDown:R,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=R,s[28]=l,s[29]=$):$=s[29];const M=l?u.length>0?`${m+1}/${u.length}`:"0/0":"";let O;s[30]!==M?(O=r.jsx(An,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:M})}),s[30]=M,s[31]=O):O=s[31];let D;s[32]!==$||s[33]!==O?(D=r.jsxs(cs,{className:"w-64",children:[$,O]}),s[32]=$,s[33]=O,s[34]=D):D=s[34];let L;s[35]!==m||s[36]!==S?(L=()=>S(m-1),s[35]=m,s[36]=S,s[37]=L):L=s[37];const F=u.length===0,z=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let W;s[38]!==z?(W=G("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(Ar,{"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]!==S?(K=()=>S(m+1),s[45]=m,s[46]=S,s[47]=K):K=s[47];const q=u.length===0,Y=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let V;s[48]!==Y?(V=G("text-muted-foreground",Y),s[48]=Y,s[49]=V):V=s[49];let J;s[50]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(tt,{"data-icon":"inline-start"}),s[50]=J):J=s[50];let Q;s[51]!==K||s[52]!==q||s[53]!==V?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:K,disabled:q,className:V,"aria-label":"Next match",children:J}),s[51]=K,s[52]=q,s[53]=V,s[54]=Q):Q=s[54];let X;s[55]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(st,{"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 te;return s[58]!==D||s[59]!==H||s[60]!==Q||s[61]!==Z?(te=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:[D,H,Q,Z]}),s[58]=D,s[59]=H,s[60]=Q,s[61]=Z,s[62]=te):te=s[62],te});function gP(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const mF=["General","View","Tools"],tl=[{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}}],I2="cogpit-keybindings";let Ms=null;function M2(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function _r(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function xP(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(Ms)return Ms;try{const n=localStorage.getItem(I2);if(!n)return Ms={};const e=JSON.parse(n);if(!e||typeof e!="object")return Ms={};const t={};for(const s of tl){const o=e[s.command];xP(o)&&(t[s.command]=o)}return Ms=t}catch{return Ms={}}}function Pu(n){Ms=n;try{localStorage.setItem(I2,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function ei(n){const e=tl.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Eu()[n]??e.defaultShortcut}function pF(){return Object.fromEntries(tl.map(n=>[n.command,ei(n.command)]))}function hF(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:_r(e.key)};Pu({...Eu(),[n]:t})}function gF(n){const e={...Eu()};delete e[n],Pu(e)}function xF(){Pu({})}function bF(n){return{key:_r(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function O2(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function _t(n,e){const t=ei(n);return"doubleTapModifier"in t||_r(e.key)!==_r(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 io(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 bP(n){const e=M2();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${io(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${io(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${io(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${io(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${io(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,io(n.key)].filter(Boolean).join("+")}function Jl(n){return bP(ei(n))}function ah(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${_r(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 vF(n,e){const t=new Set(ah(n));return tl.find(s=>s.command!==e&&ah(ei(s.command)).some(o=>t.has(o)))??null}function lh(n){return"doubleTapModifier"in ei(n)?M2()?"Meta":"Control":null}const vP=["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"],yP="device.cycle";function wP(n){const e=vP.findIndex(t=>_t(t,n));return e===-1?null:e+1}function jP(n){return _t(yP,n)}const Xc="cogpit:find-in-conversation",nl=w.memo(function(e){const t=B.c(85),{searchInputRef:s,hasTodos:o,hasMore:i,isLoadingOlder:a,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:d}=e,u=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=Ut(),{session:h}=ct(),{chat:g,scroll:x}=Fr(),{searchQuery:b}=f,{pendingMessages:y}=g,{chatScrollRef:v,scrollEndRef:S,handleScroll:j,canScrollDown:k,scrollToBottomInstant:C,initialScrollDone:N}=x,_=w.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var he;return(he=_.current)==null?void 0:he.open()},t[0]=P):P=t[0];const A=P;let T,E;t[1]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const he=function(Se){_t("findInConversation",Se)&&(Se.preventDefault(),A())};return window.addEventListener("keydown",he),window.addEventListener(Xc,A),()=>{window.removeEventListener("keydown",he),window.removeEventListener(Xc,A)}},E=[A],t[1]=T,t[2]=E):(T=t[1],E=t[2]),w.useEffect(T,E);let R,I;t[3]!==p||t[4]!==u||t[5]!==s?(R=()=>{!p||!u||requestAnimationFrame(()=>{var he;return(he=s.current)==null?void 0:he.focus()})},I=[p,u,s],t[3]=p,t[4]=u,t[5]=s,t[6]=R,t[7]=I):(R=t[6],I=t[7]),w.useEffect(R,I);let $;t[8]!==m?($=he=>m({type:"JUMP_TO_TURN",index:he}),t[8]=m,t[9]=$):$=t[9];const M=$;let O;t[10]!==m||t[11]!==d?(O=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[10]=m,t[11]=d,t[12]=O):O=t[12];const D=O,L=h,F=L.turns.length>0||y.length===0,z=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let W;t[13]!==z?(W=G("relative bg-background",z),t[13]=z,t[14]=W):W=t[14];let U;t[15]!==D||t[16]!==m||t[17]!==p||t[18]!==u||t[19]!==s||t[20]!==b?(U=p&&u&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(cs,{className:"h-9 flex-1",children:[r.jsx(ds,{ref:s,value:b,onChange:he=>m({type:"SET_SEARCH_QUERY",value:he.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(An,{align:"inline-start",children:r.jsx(cn,{})})]}),r.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:D,"aria-label":"Close conversation search",children:r.jsx(st,{"data-icon":"inline-start"})})]}),t[15]=D,t[16]=m,t[17]=p,t[18]=u,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=G("relative",H),t[22]=H,t[23]=K):K=t[23];let q;t[24]!==v?(q=r.jsx(hP,{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(fP,{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 V;t[31]!==v||t[32]!==L?(V=r.jsx(sP,{session:L,scrollContainerRef:v}),t[31]=v,t[32]=L,t[33]=V):V=t[33];const J=p&&"mobile-scroll";let Q;t[34]!==J?(Q=G("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":G("mx-auto w-full max-w-[var(--chat-width)] px-6 pt-14",o?"pb-48":"pb-32"),t[36]=o,t[37]=p,t[38]=X):X=t[38];let Z;t[39]!==v||t[40]!==i||t[41]!==N||t[42]!==a||t[43]!==l||t[44]!==F?(Z=F&&r.jsx(X9,{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 te;t[46]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx(rP,{}),t[46]=te):te=t[46];let ne;if(t[47]!==L.turns.length||t[48]!==y){let he;t[50]!==L.turns.length?(he=(je,Se)=>r.jsx(w0,{message:je,turnNumber:L.turns.length+1+Se},Se),t[50]=L.turns.length,t[51]=he):he=t[51],ne=y.map(he),t[47]=L.turns.length,t[48]=y,t[49]=ne}else ne=t[49];let oe;t[52]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsx(u9,{}),t[52]=oe):oe=t[52];let re;t[53]!==S?(re=r.jsx("div",{ref:S}),t[53]=S,t[54]=re):re=t[54];let ae;t[55]!==Z||t[56]!==ne||t[57]!==re?(ae=r.jsxs(mP,{fallbackMessage:"Failed to render conversation timeline",children:[Z,te,ne,oe,re]}),t[55]=Z,t[56]=ne,t[57]=re,t[58]=ae):ae=t[58];let se;t[59]!==X||t[60]!==ae?(se=r.jsx("div",{className:X,children:ae}),t[59]=X,t[60]=ae,t[61]=se):se=t[61];let fe;t[62]!==v||t[63]!==j||t[64]!==Q||t[65]!==se?(fe=r.jsx("div",{ref:v,onScroll:j,className:Q,children:se}),t[62]=v,t[63]=j,t[64]=Q,t[65]=se,t[66]=fe):fe=t[66];const le=k?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",ce=p?"right-3 bottom-3":"right-5 bottom-5";let me;t[67]!==le||t[68]!==ce?(me=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",le,ce),t[67]=le,t[68]=ce,t[69]=me):me=t[69];let ue;t[70]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(B3,{"data-icon":"inline-start"}),t[70]=ue):ue=t[70];let de;t[71]!==C||t[72]!==me?(de=r.jsx(ee,{size:"icon",className:me,onClick:C,"aria-label":"Scroll to bottom",children:ue}),t[71]=C,t[72]=me,t[73]=de):de=t[73];let be;t[74]!==K||t[75]!==q||t[76]!==Y||t[77]!==V||t[78]!==fe||t[79]!==de?(be=r.jsxs("div",{className:K,children:[q,Y,V,fe,de]}),t[74]=K,t[75]=q,t[76]=Y,t[77]=V,t[78]=fe,t[79]=de,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}),Jc="cogpit-devices-changed",D2="cogpit:devices-changed";function L2(n){typeof n.connectionRevision=="number"&&Tj(n.id,n.connectionRevision)}function z2(n,e,t=!1){window.dispatchEvent(new CustomEvent(Jc,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(D2,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function ch(n){L2(n),z2(n.id,n.connectionRevision)}function Ql(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}async function ao(n){try{const e=await n.json();return e&&typeof e=="object"?e:null}catch{return null}}function F2(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function SP(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function sl(){const[n,e]=w.useState([]),[t,s]=w.useState(!0),[o,i]=w.useState(()=>yt()),a=w.useRef(0),l=w.useCallback(async()=>{const h=++a.current;try{const g=await ps("/api/hub/devices");if(!g.ok)return;const x=await ao(g);if(h!==a.current)return;const b=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const y of b)L2(y);e(b)}catch{}finally{h===a.current&&s(!1)}},[]);w.useEffect(()=>{l()},[l]),w.useEffect(()=>{const h=()=>i(yt()),g=()=>void l(),x=v=>{if(v.key===D2){try{const S=JSON.parse(v.newValue??"null");(S==null?void 0:S.removed)===!0&&typeof S.deviceId=="string"&&yt()===S.deviceId&&Ss(Tt)}catch{}l()}},b=()=>{a.current+=1,e([]),s(!0),l()},y=()=>{a.current+=1,e([]),s(!1)};return window.addEventListener("cogpit-device-changed",h),window.addEventListener("popstate",h),window.addEventListener(Jc,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-identity-changed",b),window.addEventListener("cogpit-auth-required",y),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(Jc,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-identity-changed",b),window.removeEventListener("cogpit-auth-required",y)}},[l]);const c=w.useMemo(()=>o===Tt?void 0:n.find(h=>h.id===o),[n,o]),d=w.useCallback(async(h,g,x,b)=>{try{const y=await ps("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:b})}),v=await ao(y);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."}}},[]),u=w.useCallback(async h=>{try{const g=await ps("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await ao(g);if(g.ok&&(x!=null&&x.device)){const b=x.device;return ch(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."}}},[]),f=w.useCallback(async(h,g)=>{try{const x=await ps(Ql(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await ao(x);if(x.ok&&(b!=null&&b.device)){const y=b.device;return ch(y),{ok:!0,device:y}}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=w.useCallback(async h=>{try{const g=await ps(Ql(h),{method:"DELETE"});if(g.ok)return yt()===h&&Ss(Tt),z2(h,void 0,!0),{ok:!0};const x=await ao(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=w.useCallback(async h=>{try{const g=await ps(Ql(h,"/test"),{method:"POST"});return await ao(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:u,updateDevice:f,removeDevice:m,testDevice:p}}const NP=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function dh(n,e){if(!NP.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function Qo(n,e){return`${n}.${e}`}function kP(n){const e=new Set,t=new Set,s=[];for(const o of n){if(dh("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??[]){dh("panel",i.id);const a=Qo(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))}const Pi=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function ol(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 Pi.format(s,"second");const o=Math.round(s/60);if(Math.abs(o)<60)return Pi.format(o,"minute");const i=Math.round(o/60);return Math.abs(i)<24?Pi.format(i,"hour"):Pi.format(Math.round(i/24),"day")}function Au(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 rl(n){const e=B.c(3),[t,s]=w.useState(CP);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]),w.useEffect(o,i),t}function CP(){return Date.now()}function Tr(n){const e=B.c(3),{label:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx("div",{className:"no-scrollbar flex shrink-0 items-center gap-1 overflow-x-auto border-b px-3 py-1.5",role:"group","aria-label":t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function il(n){const e=B.c(10),{icon:t,title:s,description:o}=n;let i;e[0]!==t?(i=r.jsx(vn,{variant:"icon",children:r.jsx(t,{})}),e[0]=t,e[1]=i):i=e[1];let a;e[2]!==s?(a=r.jsx(fn,{children:s}),e[2]=s,e[3]=a):a=e[3];let l;e[4]!==o?(l=r.jsx(yn,{children:o}),e[4]=o,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==a||e[8]!==l?(c=r.jsx(dn,{className:"border-0",children:r.jsxs(un,{children:[i,a,l]})}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function Ru(n){const e=B.c(16),{count:t,children:s}=n,[o,i]=w.useState(!1),a=o&&"rotate-90";let l;e[0]!==a?(l=G("size-3 shrink-0 transition-transform",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx(Je,{className:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx("span",{className:"font-mono text-[10px] tabular-nums opacity-70",children:t}),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==o||e[7]!==c||e[8]!==d?(u=r.jsxs($t,{className:"flex h-7 w-full items-center gap-1.5 rounded-sm px-1 text-left text-xs text-muted-foreground outline-none hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-expanded":o,children:[c,"Closed",d]}),e[6]=o,e[7]=c,e[8]=d,e[9]=u):u=e[9];let f;e[10]!==s?(f=r.jsx(at,{children:r.jsx("div",{className:"flex flex-col gap-4 pt-2",children:s})}),e[10]=s,e[11]=f):f=e[11];let m;return e[12]!==o||e[13]!==u||e[14]!==f?(m=r.jsxs(it,{open:o,onOpenChange:i,children:[u,f]}),e[12]=o,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function B2(n){const e=B.c(4),{count:t}=n;if(t===0)return null;const s=`${t} comment${t===1?"":"s"}`;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(U3,{className:"size-3","aria-hidden":!0}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==s?(i=r.jsxs("span",{className:"flex items-center gap-0.5 font-mono text-[10px] text-muted-foreground tabular-nums","aria-label":s,title:s,children:[o,t]}),e[1]=t,e[2]=s,e[3]=i):i=e[3],i}const _P=700,TP=12;function $u(n){const e=B.c(15),{body:t}=n,[s,o]=w.useState(!1);let i;e[0]!==t?(i=t.length>_P||t.split(`
122
+ `).length>TP,e[0]=t,e[1]=i):i=e[1];const a=i,l=a&&!s&&"max-h-52 overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]";let c;e[2]!==l?(c=G("break-words text-xs leading-5",l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx(bu,{text:t,compactHeadings:!0}),e[4]=t,e[5]=d):d=e[5];let u;e[6]!==c||e[7]!==d?(u=r.jsx("div",{className:c,children:d}),e[6]=c,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==a?(f=a&&r.jsx("button",{type:"button",className:"mt-1 text-[11px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:underline",onClick:()=>o(EP),"aria-expanded":s,children:s?"Show less":"Show full description"}),e[9]=s,e[10]=a,e[11]=f):f=e[11];let m;return e[12]!==u||e[13]!==f?(m=r.jsxs("div",{className:"max-w-[72ch]",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14],m}function EP(n){return!n}function wt(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=G("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 jt(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 ut(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("div",{"data-slot":"skeleton",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const Zo="cogpit",It={worktrees:Qo(Zo,"worktrees"),projectFiles:Qo(Zo,"project-files"),fileChanges:Qo(Zo,"file-changes"),sessionInfo:Qo(Zo,"session-info")},PP=w.lazy(()=>qe(()=>import("./CommandPaletteHost-DJghey7B.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),AP=w.lazy(()=>qe(()=>import("./index-CMQcske6.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),RP=w.lazy(()=>qe(()=>Promise.resolve().then(()=>XP),void 0).then(n=>({default:n.DevicesDialog}))),$P=w.lazy(()=>qe(()=>import("./KeyboardShortcutsDialog-2606YXAx.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),IP=w.lazy(()=>qe(()=>import("./ProjectSwitcherModal-D8boI2Qx.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),MP=w.lazy(()=>qe(()=>import("./ThemeSelectorModal-DZ9JuT6j.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function OP(n){const e=B.c(116),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Ut(),{session:c,sessionSource:d}=ct(),{devices:u,activeDeviceId:f}=sl(),[m,p]=w.useState(null),[h,g]=w.useState(null);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=ft("manageDevices"),e[0]=x):x=e[0];const b=x;let y;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(y=i.pendingCwd??(i.pendingDirName?Tn(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=y):y=e[3];const v=y,S=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,j=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]),w.useEffect(k,C);const N=o.onKeyboardShortcutsOpenChange;let _,P;e[7]!==N?(_=()=>{const Ee=function(He){_t("keyboardShortcuts",He)&&(O2(document.activeElement)||(He.preventDefault(),N(!0)))};return window.addEventListener("keydown",Ee),()=>window.removeEventListener("keydown",Ee)},P=[N],e[7]=N,e[8]=_,e[9]=P):(_=e[8],P=e[9]),w.useEffect(_,P);const A=f===Tt;let T;e[10]!==A?(T={id:Tt,name:"This machine",isLocal:!0,isActive:A},e[10]=A,e[11]=T):T=e[11];let E;if(e[12]!==f||e[13]!==u||e[14]!==T){let Ee;e[16]!==f?(Ee=Ie=>({id:Ie.id,name:Ie.name,isLocal:!1,isActive:Ie.id===f}),e[16]=f,e[17]=Ee):Ee=e[17],E=[T,...u.map(Ee)],e[12]=f,e[13]=u,e[14]=T,e[15]=E}else E=e[15];const R=E;let I;e[18]!==c||e[19]!==(d==null?void 0:d.agentKind)||e[20]!==(d==null?void 0:d.dirName)?(I=()=>{if(!c)return;const Ee=(d==null?void 0:d.agentKind)??Rt((d==null?void 0:d.dirName)??null);Dr(W1(Ee,c.sessionId,c.cwd))},e[18]=c,e[19]=d==null?void 0:d.agentKind,e[20]=d==null?void 0:d.dirName,e[21]=I):I=e[21];const $=I,M=DP,O=o.processPanel,D=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(w.Suspense,{fallback:null,children:r.jsx(AP,{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(w.Suspense,{fallback:null,children:r.jsx(IP,{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(w.Suspense,{fallback:null,children:r.jsx(MP,{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,V=o.onCommandPaletteOpenChange,J=t.actions.handleGoHome,Q=t.panels.handleOpenProjectSwitcher,X=t.onOpenPaletteProject,Z=t.actions.handleDashboardSelect,te=t.panels.handleToggleSidebar;let ne,oe,re;e[41]!==t.panels?(ne=()=>t.panels.toggleWorkspacePanel(It.sessionInfo),oe=()=>t.panels.toggleWorkspacePanel(It.fileChanges),re=()=>t.panels.toggleWorkspacePanel(It.worktrees),e[41]=t.panels,e[42]=ne,e[43]=oe,e[44]=re):(ne=e[42],oe=e[43],re=e[44]);const ae=t.panels.handleToggleMission,se=c?t.handlers.handleDuplicateSession:void 0,fe=c?$:void 0,le=c?M:void 0,ce=ft("killAny")?o.onKillAll:void 0,me=ft("configWrite")?t.panels.handleToggleConfig:void 0,ue=a.openConfigDialog;let de;e[45]!==N?(de=()=>N(!0),e[45]=N,e[46]=de):de=e[46];const be=s.currentCwd?s.onTogglePreview:void 0,ge=ft("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0,he=t.panels.handleToggleThemeSelector,je=s.onOpenTerminal,Se=o.onFocusComposer,Pe=o.onExpandAll,Re=o.onExpandToolPayloads,$e=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=ft("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 Te;e[53]!==s.hasFileChanges?(Te=ft("hostFiles")&&s.hasFileChanges,e[53]=s.hasFileChanges,e[54]=Te):Te=e[54];const _e=t.panels.activeWorkspacePanel===It.sessionInfo,We=t.panels.activeWorkspacePanel===It.fileChanges,Fe=t.panels.activeWorkspacePanel===It.worktrees,Ne=i.mainView==="config",pe=i.mainView==="mission",Oe=(c==null?void 0:c.cwd)??v??null;let Ae;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]!==S||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]!==R||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]!==oe||e[79]!==re||e[80]!==se||e[81]!==fe||e[82]!==le||e[83]!==ce||e[84]!==me||e[85]!==de||e[86]!==be||e[87]!==ge||e[88]!==De||e[89]!==Le||e[90]!==ze||e[91]!==Te||e[92]!==_e||e[93]!==We||e[94]!==Fe||e[95]!==Ne||e[96]!==pe||e[97]!==Oe?(Ae=r.jsx(w.Suspense,{fallback:null,children:r.jsx(PP,{open:Y,onOpenChange:V,onGoHome:J,onNewSession:Q,onOpenProject:X,onOpenSession:Z,onToggleSidebar:te,onToggleStats:ne,onToggleFileChanges:oe,onToggleWorktrees:re,onToggleMissionControl:ae,onDuplicateSession:se,onCopyResumeCommand:fe,onFindInConversation:le,onKillAll:ce,onOpenConfig:me,onOpenSettings:ue,onOpenKeyboardShortcuts:de,onTogglePreview:be,onToggleProjectFiles:ge,onOpenTheme:he,onOpenTerminal:je,onOpenDevices:b?p:void 0,onSwitchDevice:Ss,devices:R,onFocusComposer:Se,onExpandAll:Pe,onExpandToolPayloads:Re,onCollapseAll:$e,canFocusComposer:De,canOpenTerminal:Le,hasSession:ze,hasFileChanges:Te,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:_e,showProjectFiles:s.showProjectFiles,showFileChanges:We,showWorktrees:Fe,showConfig:Ne,showMission:pe,currentProjectDirName:S,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]=S,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]=R,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]=oe,e[79]=re,e[80]=se,e[81]=fe,e[82]=le,e[83]=ce,e[84]=me,e[85]=de,e[86]=be,e[87]=ge,e[88]=De,e[89]=Le,e[90]=ze,e[91]=Te,e[92]=_e,e[93]=We,e[94]=Fe,e[95]=Ne,e[96]=pe,e[97]=Oe,e[98]=Ae):Ae=e[98];let Be;e[99]!==o.keyboardShortcutsOpen||e[100]!==N?(Be=r.jsx(w.Suspense,{fallback:null,children:r.jsx($P,{open:o.keyboardShortcutsOpen,onOpenChange:N})}),e[99]=o.keyboardShortcutsOpen,e[100]=N,e[101]=Be):Be=e[101];let ie;e[102]!==m||e[103]!==j?(ie=b&&j!==null&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(RP,{open:m!==null,initialMode:j,onClose:()=>p(null),onCloseComplete:()=>g(null)})}),e[102]=m,e[103]=j,e[104]=ie):ie=e[104];let xe;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]!==Ae||e[113]!==Be||e[114]!==ie?(xe=r.jsxs(r.Fragment,{children:[O,D,L,F,W,K,q,Ae,Be,ie]}),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]=Ae,e[113]=Be,e[114]=ie,e[115]=xe):xe=e[115],xe}function DP(){window.dispatchEvent(new Event(Xc))}function Zl(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(Ot,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(Dt,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(Mt,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const LP="2.4.2",U2={version:LP},zP=U2.version,FP=19384,BP=443,UP=450,WP=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),HP=`${WP?"⌘⇧":"Ctrl+Shift+"}1–9`,KP=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),qP=new Set(["ACCOUNT_DISABLED"]);function er(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 W2(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 H2={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function VP(n){const e=B.c(10),{tone:t}=n,s=H2[t];let o;e[0]!==s?(o=G("size-3.5 shrink-0",s),e[0]=s,e[1]=o):o=e[1];const i=o;if(t==="ok"){let l;return e[2]!==i?(l=r.jsx(Wn,{"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(bn,{"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(At,{"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(Ys,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const GP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function YP({device:n,hubVersion:e,onRename:t,onCredentials:s,onRemove:o,onTest:i}){const[a,l]=w.useState(!1),[c,d]=w.useState(n.name),[u,f]=w.useState(!1),[m,p]=w.useState(n.username??""),[h,g]=w.useState(""),[x,b]=w.useState(null),[y,v]=w.useState(!1),[S,j]=w.useState(null);w.useEffect(()=>{d(n.name)},[n.name]),w.useEffect(()=>{p(n.username??"")},[n.username]);const k=F2(n),C=k!==void 0&&k!==e,N=SP(n)==="team";async function _(){const A=c.trim();if(!A||A===n.name){l(!1),d(n.name);return}j("rename"),await t(n.id,A),j(null),l(!1)}async function P(){const A=m.trim(),T=n.username??"",E=A!==T,R=h.length>0;if(!E&&!R){f(!1),g(""),b(null);return}if(n.auth==="none"&&!R){b("Enter a password when adding an account to an unauthenticated device.");return}const I={};E&&(I.username=A||null),R&&(I.password=h),j("credentials"),b(null);const $=await s(n.id,I);if(j(null),!$.ok){b($.error);return}f(!1),g("")}return r.jsxs("div",{className:"rounded-lg border bg-card",children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[r.jsx("span",{"aria-label":`Status: ${n.runtime.authState}`,className:G("size-2 shrink-0 rounded-full",GP[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[a?r.jsx(Lt,{value:c,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:A=>d(A.target.value),onKeyDown:A=>{A.key==="Enter"&&_(),A.key==="Escape"&&(l(!1),d(n.name))},onBlur:()=>void _(),className:"h-6 text-sm"}):r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm text-foreground",children:n.name}),k&&r.jsxs("span",{className:G("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(Ce,{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:S==="test",onClick:async()=>{j("test"),await i(n.id),j(null)},children:r.jsx(At,{"data-icon":"inline-start",className:G(S==="test"&&"animate-spin")})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{f(A=>!A),p(n.username??""),g(""),b(null)},children:r.jsx(jd,{"data-icon":"inline-start"})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>l(!0),children:r.jsx(Vs,{"data-icon":"inline-start"})}),r.jsxs(Od,{open:y,onOpenChange:A=>{S!=="remove"&&v(A)},children:[r.jsx(KS,{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(va,{"data-icon":"inline-start"})}),r.jsxs(Dd,{size:"sm",children:[r.jsxs(Ld,{children:[r.jsxs(Fd,{children:["Remove ",n.name,"?"]}),r.jsx(Bd,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(zd,{children:[r.jsx(Wd,{disabled:S==="remove",children:"Cancel"}),r.jsxs(Ud,{variant:"destructive",disabled:S==="remove",onClick:async()=>{j("remove");try{await o(n.id)}finally{j(null)}},children:[S==="remove"&&r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),u&&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(St,{children:[r.jsxs(Nt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(Lt,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:m,onChange:A=>p(A.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(St,{children:[r.jsxs(Nt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(Lt,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:h,onChange:A=>g(A.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&m.trim()===""&&r.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),x&&r.jsx(bs,{children:x}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>{f(!1),p(n.username??""),g(""),b(null)},children:"Cancel"}),r.jsx(ee,{size:"sm",disabled:S==="credentials",onClick:()=>void P(),children:S==="credentials"?r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function K2(n){var nt,Ye;const e=B.c(118),{open:t,initialMode:s,onClose:o,onCloseComplete:i}=n,{devices:a,refresh:l,probe:c,addDevice:d,updateDevice:u,removeDevice:f,testDevice:m}=sl(),[p,h]=w.useState(""),[g,x]=w.useState(""),[b,y]=w.useState(""),[v,S]=w.useState(""),[j,k]=w.useState(!1),[C,N]=w.useState(!1),[_,P]=w.useState(null),[A,T]=w.useState(!1),[E,R]=w.useState(null),I=w.useRef(null),$=w.useRef(0);let M,O;e[0]!==s||e[1]!==t?(M=()=>{t&&(h(""),x(""),y(""),S(""),k(!1),N(!1),P(null),R(null),s==="add"&&requestAnimationFrame(()=>{var Me;return(Me=I.current)==null?void 0:Me.focus()}))},O=[t,s],e[0]=s,e[1]=t,e[2]=M,e[3]=O):(M=e[2],O=e[3]),w.useEffect(M,O);let D;e[4]!==j||e[5]!==g||e[6]!==c?(D=async()=>{const{host:Me,port:Ue,tls:rt}=er(g);if(!Me){P(null),N(!1);return}const Gt=$.current=$.current+1;N(!0);const Wt=await c(Me,Ue,j,rt);Gt===$.current&&(P({...W2(Wt,Me,Ue??(rt?BP:FP)),hello:Wt.ok?Wt.hello:void 0}),N(!1))},e[4]=j,e[5]=g,e[6]=c,e[7]=D):D=e[7];const L=D;let F,z;e[8]!==g||e[9]!==t||e[10]!==L?(F=()=>{if(!t)return;if(!er(g).host){P(null),N(!1);return}const Me=window.setTimeout(()=>void L(),UP);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]),w.useEffect(F,z);const W=((nt=_==null?void 0:_.hello)==null?void 0:nt.edition)==="team",U=W&&((Ye=_==null?void 0:_.hello)==null?void 0:Ye.needsBootstrap)===!0,H=W||!j;let K;e:{if(A){K=!1;break e}if(!er(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]!==j||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:rt,tls:Gt}=er(g);if(!Ue)return;T(!0),R(null);const Wt=await d({name:p.trim()||void 0,host:Ue,port:rt,tls:Gt,username:W?b.trim():void 0,password:H&&v||void 0,allowLocalTunnel:j});if(T(!1),Wt.ok){o(),Ss(Wt.device.id);return}R({field:qP.has(Wt.code)?"username":KP.has(Wt.code)?"password":"host",message:Wt.error})},e[13]=d,e[14]=j,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 V=Y;let J;e[23]!==u?(J=async(Me,Ue)=>{await u(Me,{name:Ue})},e[23]=u,e[24]=J):J=e[24];const Q=J;let X;e[25]!==f?(X=async Me=>{await f(Me)},e[25]=f,e[26]=X):X=e[26];const Z=X;let te;e[27]!==l||e[28]!==m?(te=async Me=>{await m(Me),await l()},e[27]=l,e[28]=m,e[29]=te):te=e[29];const ne=te;let oe;e[30]!==o?(oe=Me=>{Me||o()},e[30]=o,e[31]=oe):oe=e[31];let re;e[32]!==i?(re=Me=>{Me||i==null||i()},e[32]=i,e[33]=re):re=e[33];let ae;e[34]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsxs(Ps,{children:[r.jsx(as,{children:"Devices"}),r.jsxs(ls,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",HP," jumps between devices."]})]}),e[34]=ae):ae=e[34];let se;e[35]!==a||e[36]!==Z||e[37]!==Q||e[38]!==ne||e[39]!==u?(se=a.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:a.map(Me=>r.jsx(YP,{device:Me,hubVersion:zP,onRename:Q,onCredentials:u,onRemove:Z,onTest:ne},Me.id))}),e[35]=a,e[36]=Z,e[37]=Q,e[38]=ne,e[39]=u,e[40]=se):se=e[40];let fe;e[41]===Symbol.for("react.memo_cache_sentinel")?(fe=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Bn,{"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]=fe):fe=e[41];const le=(E==null?void 0:E.field)==="host";let ce,me;e[42]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(Nt,{htmlFor:"device-host",children:"Host"}),me=r.jsx(Co,{children:"Enter a local address or an HTTPS URL."}),e[42]=ce,e[43]=me):(ce=e[42],me=e[43]);let ue;e[44]===Symbol.for("react.memo_cache_sentinel")?(ue=Me=>{$.current=$.current+1,x(Me.target.value),y(""),P(null),R(null)},e[44]=ue):ue=e[44];let de;e[45]!==L?(de=()=>void L(),e[45]=L,e[46]=de):de=e[46];let be;e[47]!==g||e[48]!==de?(be=r.jsx(Lt,{id:"device-host",ref:I,value:g,onChange:ue,onBlur:de,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[47]=g,e[48]=de,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(lt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[50]=C,e[51]=ge):ge=e[51];let he;e[52]!==_||e[53]!==C?(he=!C&&_&&r.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",H2[_.tone]),children:[r.jsx(VP,{tone:_.tone}),_.text]}),e[52]=_,e[53]=C,e[54]=he):he=e[54];let je;e[55]!==E?(je=(E==null?void 0:E.field)==="host"&&r.jsx(bs,{children:E.message}),e[55]=E,e[56]=je):je=e[56];let Se;e[57]!==le||e[58]!==be||e[59]!==ge||e[60]!==he||e[61]!==je?(Se=r.jsxs(St,{"data-invalid":le,children:[ce,me,be,ge,he,je]}),e[57]=le,e[58]=be,e[59]=ge,e[60]=he,e[61]=je,e[62]=Se):Se=e[62];let Pe;e[63]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsxs(Nt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[63]=Pe):Pe=e[63];let Re;e[64]===Symbol.for("react.memo_cache_sentinel")?(Re=Me=>h(Me.target.value),e[64]=Re):Re=e[64];let $e;e[65]!==p?($e=r.jsxs(St,{children:[Pe,r.jsx(Lt,{id:"device-name",value:p,onChange:Re,placeholder:"Defaults to the device's own name"})]}),e[65]=p,e[66]=$e):$e=e[66];let De;e[67]!==E||e[68]!==W||e[69]!==b?(De=W&&r.jsxs(St,{"data-invalid":(E==null?void 0:E.field)==="username",children:[r.jsx(Nt,{htmlFor:"device-username",children:"Username"}),r.jsx(Lt,{id:"device-username",value:b,onChange:Me=>y(Me.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(Co,{children:"Requests through this hub will act as this account on the team server."}),(E==null?void 0:E.field)==="username"&&r.jsx(bs,{children:E.message})]}),e[67]=E,e[68]=W,e[69]=b,e[70]=De):De=e[70];let Le;e[71]!==H||e[72]!==v||e[73]!==E||e[74]!==W?(Le=H&&r.jsxs(St,{"data-invalid":(E==null?void 0:E.field)==="password",children:[r.jsx(Nt,{htmlFor:"device-password",children:"Password"}),r.jsx(Lt,{id:"device-password",type:"password",value:v,onChange:Me=>S(Me.target.value),placeholder:W?"Password for that team account":"Network access password for that device",autoComplete:W?"current-password":"off"}),(E==null?void 0:E.field)==="password"&&r.jsx(bs,{children:E.message})]}),e[71]=H,e[72]=v,e[73]=E,e[74]=W,e[75]=Le):Le=e[75];let ze;e[76]!==Se||e[77]!==$e||e[78]!==De||e[79]!==Le?(ze=r.jsxs(Io,{children:[Se,$e,De,Le]}),e[76]=Se,e[77]=$e,e[78]=De,e[79]=Le,e[80]=ze):ze=e[80];let Te;e[81]===Symbol.for("react.memo_cache_sentinel")?(Te=Me=>{$.current=$.current+1,k(Me===!0),P(null),R(null)},e[81]=Te):Te=e[81];let _e;e[82]!==j?(_e=r.jsx(qg,{id:"device-local-tunnel",name:"device-local-tunnel",checked:j,onCheckedChange:Te}),e[82]=j,e[83]=_e):_e=e[83];const We=W?"":" — no password";let Fe;e[84]!==We?(Fe=r.jsxs(Nt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",We]}),e[84]=We,e[85]=Fe):Fe=e[85];let Ne;e[86]!==_e||e[87]!==Fe?(Ne=r.jsxs(St,{orientation:"horizontal",children:[_e,Fe]}),e[86]=_e,e[87]=Fe,e[88]=Ne):Ne=e[88];let pe;e[89]!==j||e[90]!==W?(pe=j&&r.jsxs(pt,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(W3,{}),r.jsx(ht,{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]=j,e[90]=W,e[91]=pe):pe=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 Ae=!q;let Be;e[94]!==V?(Be=()=>void V(),e[94]=V,e[95]=Be):Be=e[95];let ie;e[96]!==A?(ie=A?r.jsxs(r.Fragment,{children:[r.jsx(lt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[96]=A,e[97]=ie):ie=e[97];let xe;e[98]!==Ae||e[99]!==Be||e[100]!==ie?(xe=r.jsx(ee,{disabled:Ae,onClick:Be,children:ie}),e[98]=Ae,e[99]=Be,e[100]=ie,e[101]=xe):xe=e[101];let Ee;e[102]!==Oe||e[103]!==xe?(Ee=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Oe,xe]}),e[102]=Oe,e[103]=xe,e[104]=Ee):Ee=e[104];let Ie;e[105]!==ze||e[106]!==Ne||e[107]!==pe||e[108]!==Ee?(Ie=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[fe,ze,Ne,pe,Ee]}),e[105]=ze,e[106]=Ne,e[107]=pe,e[108]=Ee,e[109]=Ie):Ie=e[109];let He;e[110]!==se||e[111]!==Ie?(He=r.jsxs(is,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[ae,se,Ie]}),e[110]=se,e[111]=Ie,e[112]=He):He=e[112];let Ke;return e[113]!==t||e[114]!==oe||e[115]!==re||e[116]!==He?(Ke=r.jsx(rs,{open:t,onOpenChange:oe,onOpenChangeComplete:re,children:He}),e[113]=t,e[114]=oe,e[115]=re,e[116]=He,e[117]=Ke):Ke=e[117],Ke}const XP=Object.freeze(Object.defineProperty({__proto__:null,DevicesDialog:K2,parseHostPort:er,probeMessage:W2},Symbol.toStringTag,{value:"Module"})),uh=U2.version,JP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},fh={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function QP(n){const e=B.c(6),{state:t}=n,s=fh[t],o=fh[t],i=JP[t];let a;e[0]!==i?(a=G("size-2 shrink-0 rounded-full",i),e[0]=i,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==o||e[4]!==a?(l=r.jsx("span",{"aria-label":s,title:o,className:a}),e[2]=s,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function Iu(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}=sl(),[d,u]=w.useState(null),f=(a==null?void 0:a.name)??"This machine",m=i!==Tt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ft("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(eA))).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",y=s&&"h-10";let v;e[5]!==y?(v=G("max-w-40 justify-start",y),e[5]=y,e[6]=v):v=e[6];let S;e[7]!==b||e[8]!==v?(S=r.jsx(ee,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=S):S=e[9];let j;e[10]!==m?(j=m?r.jsx(j1,{"data-icon":"inline-start"}):r.jsx(em,{"data-icon":"inline-start"}),e[10]=m,e[11]=j):j=e[11];let k;e[12]!==f?(k=r.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=k):k=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(tt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let N;e[15]!==S||e[16]!==j||e[17]!==k?(N=r.jsxs(qn,{render:S,children:[j,k,C]}),e[15]=S,e[16]=j,e[17]=k,e[18]=N):N=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(Us,{children:"Devices"}),e[19]=_):_=e[19];let P,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(em,{}),A=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=P,e[21]=A):(P=e[20],A=e[21]);let T;e[22]!==m?(T=!m&&r.jsx(gt,{className:"ml-auto text-success"}),e[22]=m,e[23]=T):T=e[23];let E;e[24]!==T?(E=r.jsxs(Pt,{onClick:ZP,children:[P,A,T]}),e[24]=T,e[25]=E):E=e[25];let R;if(e[26]!==i||e[27]!==s||e[28]!==o){let F;e[30]!==i||e[31]!==s?(F=z=>{const W=F2(z),U=W!==void 0&&W!==uh,H=z.id===i;return r.jsxs(Pt,{onClick:()=>Ss(z.id),className:G(s&&"min-h-10"),children:[r.jsx(QP,{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${uh}`,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(gt,{className:"ml-auto text-success"})]},z.id)},e[30]=i,e[31]=s,e[32]=F):F=e[32],R=o.map(F),e[26]=i,e[27]=s,e[28]=o,e[29]=R}else R=e[29];let I;e[33]!==E||e[34]!==R?(I=r.jsxs(tn,{children:[_,E,R]}),e[33]=E,e[34]=R,e[35]=I):I=e[35];let $;e[36]!==o.length?($=h&&r.jsxs(r.Fragment,{children:[r.jsx(gr,{}),r.jsxs(tn,{children:[r.jsxs(Pt,{onClick:()=>u("add"),children:[r.jsx(Bn,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(Pt,{onClick:()=>u("manage"),children:[r.jsx(gd,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=$):$=e[37];let M;e[38]!==I||e[39]!==$?(M=r.jsxs(Vn,{align:"end",sideOffset:6,className:"w-64",children:[I,$]}),e[38]=I,e[39]=$,e[40]=M):M=e[40];let O;e[41]!==x||e[42]!==N||e[43]!==M?(O=r.jsxs(Kn,{onOpenChange:x,children:[N,M]}),e[41]=x,e[42]=N,e[43]=M,e[44]=O):O=e[44];let D;e[45]!==d?(D=h&&r.jsx(K2,{open:d!==null,initialMode:d??"manage",onClose:()=>u(null)}),e[45]=d,e[46]=D):D=e[46];let L;return e[47]!==O||e[48]!==D?(L=r.jsxs(r.Fragment,{children:[O,D]}),e[47]=O,e[48]=D,e[49]=L):L=e[49],L}function ZP(){return Ss(Tt)}function eA(){return null}const tA=6e4;function nA(){const[n,e]=w.useState([]),[t,s]=w.useState(!1),o=w.useRef(!1),i=w.useCallback(async()=>{if(!o.current){o.current=!0;try{const l=await ve("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(d=>d.suspectedLeak))}}catch{}finally{o.current=!1}}},[]),a=w.useCallback(async l=>{if(l.length!==0){s(!0);try{await ve("/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 w.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},tA);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const sA=6e4;function oA(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=nA(),[i,a]=w.useState(!1),l=e.length>0,c=e.reduce(aA,0);let d,u;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const T=window.setTimeout(()=>a(!1),sA);return()=>window.clearTimeout(T)},u=[l],n[0]=l,n[1]=d,n[2]=u):(d=n[1],u=n[2]),w.useEffect(d,u),!l&&!i)return null;const f=Mt,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(iA)):o()),n[3]=l,n[4]=s,n[5]=e,n[6]=o,n[7]=h):h=n[7];const g=!l&&"text-muted-foreground";let x;n[8]!==g?(x=G("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=r.jsx(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 y;n[16]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(H3,{"data-icon":"inline-start"}),n[16]=y):y=n[16];const v=t?"…":e.length;let S;n[17]!==v?(S=r.jsx("span",{className:"tabular-nums",children:v}),n[17]=v,n[18]=S):S=n[18];let j;n[19]!==S||n[20]!==b?(j=r.jsxs(Ot,{render:b,children:[y,S]}),n[19]=S,n[20]=b,n[21]=j):j=n[21];const k=Dt,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(rA),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(kt,{}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):r.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[r.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let P;n[22]!==k||n[23]!==_?(P=r.jsx(k,{side:C,className:N,children:_}),n[22]=k,n[23]=_,n[24]=P):P=n[24];let A;return n[25]!==f||n[26]!==j||n[27]!==P?(A=r.jsxs(f,{children:[j,P]}),n[25]=f,n[26]=j,n[27]=P,n[28]=A):A=n[28],A}function rA(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," · ",Td(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function iA(n){return n.pid}function aA(n,e){return n+e.cpuPercent}const lA=15e3;function cA(){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]=w.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const b=await ve("/api/notifications?limit=100");if(!b.ok)return;const y=await b.json();Array.isArray(y.notifications)&&s(y.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(),lA);return()=>window.clearInterval(b)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),w.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(b,y)=>{const v=new Date().toISOString();s(S=>S.map(j=>j.readAt===null&&y(j)?{...j,readAt:v}:j));try{await ve("/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 u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=async b=>d({ids:b},y=>b.includes(y.id)),n[5]=u):u=n[5];const f=u;let m;n[6]===Symbol.for("react.memo_cache_sentinel")?(m=async()=>d({all:!0},uA),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(dA),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:f,markAllRead:p},n[9]=t,n[10]=g,n[11]=x):x=n[11],x}function dA(n){return n.readAt===null}function uA(){return!0}function q2(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function fA(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=cA(),[a,l]=w.useState(!1);let c;n[0]!==o?(c=function(N){if(o([N.id]),!N.dirName||!N.sessionId)return;const _=yt(),P=_===Tt?"":`/d/${_}`;q2(`${P}/${encodeURIComponent(N.dirName)}/${encodeURIComponent(N.sessionId)}`),l(!1)},n[0]=o,n[1]=c):c=n[1];const d=c;let u;n[2]!==s?(u=C=>{l(C),C&&s()},n[2]=s,n[3]=u):u=n[3];const f=a?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==f||n[5]!==m?(p=r.jsx(ee,{type:"button",variant:f,size:"icon-sm",className:"relative","aria-label":m}),n[4]=f,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(tm,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Ce,{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(qn,{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 y;n[14]!==i||n[15]!==t?(y=t>0&&r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(K3,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=y):y=n[16];let v;n[17]!==y?(v=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,y]}),n[17]=y,n[18]=v):v=n[18];let S;n[19]!==e||n[20]!==d?(S=r.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?r.jsx(dn,{className:"min-h-40 p-6",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(tm,{})}),r.jsx(fn,{children:"No notifications"}),r.jsx(yn,{children:"Session updates will appear here."})]})}):r.jsx(tn,{children:e.map(C=>r.jsx(mA,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=S):S=n[21];let j;n[22]!==v||n[23]!==S?(j=r.jsxs(Vn,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[v,S]}),n[22]=v,n[23]=S,n[24]=j):j=n[24];let k;return n[25]!==a||n[26]!==u||n[27]!==j||n[28]!==x?(k=r.jsxs(Kn,{open:a,onOpenChange:u,children:[x,j]}),n[25]=a,n[26]=u,n[27]=j,n[28]=x,n[29]=k):k=n[29],k}function mA(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"?qt:Na;let u;e[2]!==t||e[3]!==s?(u=()=>s(t),e[2]=t,e[3]=s,e[4]=u):u=e[4];const f=!i&&"cursor-default",m=o&&"bg-accent/50";let p;e[5]!==f||e[6]!==m?(p=G("rounded-none border-b px-3 py-2.5 last:border-b-0",f,m),e[5]=f,e[6]=m,e[7]=p):p=e[7];const h=t.kind==="permission"?"text-warning":"text-info";let g;e[8]!==h?(g=G("mt-0.5",h),e[8]=h,e[9]=g):g=e[9];let x;e[10]!==d||e[11]!==g?(x=r.jsx(d,{className:g}),e[10]=d,e[11]=g,e[12]=x):x=e[12];const b=o?"font-medium text-foreground":"text-muted-foreground";let y;e[13]!==b?(y=G("truncate text-xs",b),e[13]=b,e[14]=y):y=e[14];let v;e[15]!==t.title||e[16]!==y?(v=r.jsx("span",{className:y,children:t.title}),e[15]=t.title,e[16]=y,e[17]=v):v=e[17];let S;e[18]!==c?(S=Td(c),e[18]=c,e[19]=S):S=e[19];let j;e[20]!==S?(j=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:S}),e[20]=S,e[21]=j):j=e[21];let k;e[22]!==v||e[23]!==j?(k=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[v,j]}),e[22]=v,e[23]=j,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 P;return e[32]!==N||e[33]!==_||e[34]!==u||e[35]!==p||e[36]!==x?(P=r.jsxs(Pt,{onClick:u,className:p,children:[x,N,_]}),e[32]=N,e[33]=_,e[34]=u,e[35]=p,e[36]=x,e[37]=P):P=e[37],P}const pA=2e3;function Po(n){return`${n.toFixed(n<10?1:0)}%`}function la(n){return`${n.toFixed(0)} MB`}function hA(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function gA(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 xA(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(Ce,{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(Ce,{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(Ce,{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 u;e[16]!==c||e[17]!==d?(u=r.jsxs("div",{className:"min-w-0 flex-1",children:[c,d]}),e[16]=c,e[17]=d,e[18]=u):u=e[18];let f;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(f=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]=f):f=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=G("font-mono text-sm font-semibold tabular-nums",m),e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t.cpuPercent?(h=Po(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=la(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=Td(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let y;e[34]!==x||e[35]!==b?(y=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,e[36]=y):y=e[36];let v;e[37]!==g||e[38]!==y?(v=r.jsxs("div",{className:"shrink-0 text-right",children:[g,y]}),e[37]=g,e[38]=y,e[39]=v):v=e[39];let S;return e[40]!==v||e[41]!==u||e[42]!==f?(S=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[u,f,v]}),e[40]=v,e[41]=u,e[42]=f,e[43]=S):S=e[43],S}function bA(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 vA(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 V2(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(Ce,{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=bA(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 u;e[14]!==d?(u=G("font-mono text-sm font-semibold tabular-nums",d),e[14]=d,e[15]=u):u=e[15];let f;e[16]!==t.cpuPercent?(f=Po(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==u||e[19]!==f?(m=r.jsx("div",{className:u,children:f}),e[18]=u,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=la(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 mh(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(yA)}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 yA(n,e){const t=gA(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(kt,{}),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:hA(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(Ce,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function wA(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(jA).join(", "),e[0]=t,e[1]=o):o=e[1];const i=`Recent Cogpit CPU: ${o}`;let a;e[2]!==s||e[3]!==t?(a=t.length===0?r.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,d)=>r.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:Po(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 jA(n){return Po(n)}function SA(n){var me,ue,de,be;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=w.useState(null),[a,l]=w.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,u]=w.useState(c),[f,m]=w.useState(null),[p,h]=w.useState(!1),g=w.useRef(!1),[x,b]=Hs();let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=async()=>{var $e;if(g.current)return;g.current=!0,h(!0);const ge=ve("/api/performance").then(EA),he=(($e=window.electronPerformance)==null?void 0:$e.getSnapshot())??Promise.resolve(null),[je,Se]=await Promise.allSettled([ge,he]),Pe=je.status==="fulfilled"?je.value:null,Re=Se.status==="fulfilled"?Se.value:null;if(Pe&&l(Pe),Re&&i(Re),!Pe&&!Re)m("Performance data is unavailable.");else{m(null);const De=Re&&Re.processes.length>0?Re.processes.reduce(TA,0):(Pe==null?void 0:Pe.cpuPercent)??0;u(Le=>[...Le.slice(-29),De])}g.current=!1,h(!1)},e[1]=y):y=e[1];const v=y;let S,j;e[2]!==t?(S=()=>{if(!t)return;v();const ge=window.setInterval(()=>void v(),pA);return()=>window.clearInterval(ge)},j=[t,v],e[2]=t,e[3]=S,e[4]=j):(S=e[3],j=e[4]),w.useEffect(S,j);let k,C,N,_,P,A,T,E,R,I,$,M,O,D,L,F,z,W,U;if(e[5]!==x||e[6]!==b||e[7]!==o||e[8]!==f||e[9]!==d||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==a){const ge=[...(o==null?void 0:o.processes)??[]].sort(_A),he=ge.length>0?ge.reduce(CA,0):(a==null?void 0:a.cpuPercent)??0,je=ge[0];let Se;e[33]!==((me=a==null?void 0:a.system)==null?void 0:me.processes)?(Se=((ue=a==null?void 0:a.system)==null?void 0:ue.processes)??[],e[33]=(de=a==null?void 0:a.system)==null?void 0:de.processes,e[34]=Se):Se=e[34],T=Se;const Pe=((be=a==null?void 0:a.system)==null?void 0:be.suspectedLeakCount)??0,Re=Pe>0||he>=80?"High":he>=15?"Active":"Idle";let $e;e[35]===Symbol.for("react.memo_cache_sentinel")?($e=async rt=>{try{await ve("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[rt]})}),await new Promise(kA)}catch{}v()},e[35]=$e):$e=e[35],A=$e;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;P=rs,O=t,D=s,_=is,I="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let ze;e[41]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(as,{children:"Power & activity monitor"}),e[41]=ze):ze=e[41];const Te=Re==="High"?"destructive":"secondary";let _e;e[42]!==Re||e[43]!==Te?(_e=r.jsxs("div",{className:"flex items-center gap-2",children:[ze,r.jsx(Ce,{variant:Te,children:Re})]}),e[42]=Re,e[43]=Te,e[44]=_e):_e=e[44];let We;e[45]===Symbol.for("react.memo_cache_sentinel")?(We=r.jsx(ls,{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]!==_e?(Fe=r.jsxs("div",{className:"min-w-0 flex-1",children:[_e,We]}),e[46]=_e,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 pe=p&&"animate-spin";let Oe;e[49]!==pe?(Oe=G(pe),e[49]=pe,e[50]=Oe):Oe=e[50];let Ae;e[51]!==Oe?(Ae=r.jsx(At,{"data-icon":"inline-start",className:Oe}),e[51]=Oe,e[52]=Ae):Ae=e[52];let Be;e[53]!==p||e[54]!==Ae?(Be=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Ne,disabled:p,children:[Ae,"Refresh"]}),e[53]=p,e[54]=Ae,e[55]=Be):Be=e[55];const ie=!a&&!o;let xe;e[56]!==x?(xe=x?r.jsx(gt,{"data-icon":"inline-start"}):r.jsx(Rn,{"data-icon":"inline-start"}),e[56]=x,e[57]=xe):xe=e[57];const Ee=x?"Copied":"Copy data";let Ie;e[58]!==Le||e[59]!==ie||e[60]!==xe||e[61]!==Ee?(Ie=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Le,disabled:ie,children:[xe,Ee]}),e[58]=Le,e[59]=ie,e[60]=xe,e[61]=Ee,e[62]=Ie):Ie=e[62];let He;e[63]!==Be||e[64]!==Ie?(He=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[Be,Ie]}),e[63]=Be,e[64]=Ie,e[65]=He):He=e[65],e[66]!==Fe||e[67]!==He?($=r.jsx(Ps,{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]=$):$=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(kt,{}),e[69]=M):M=e[69],N=Gn,R="min-h-0 min-w-0 flex-1",W="flex flex-col gap-4 p-5",e[70]!==f?(U=f&&r.jsx(pt,{variant:"destructive",children:r.jsx(ht,{children:f})}),e[70]=f,e[71]=U):U=e[71];let Ke;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ke=r.jsx(ln,{children:"Current load"}),e[72]=Ke):Ke=e[72];const nt=he>=80&&"text-destructive";let Ye;e[73]!==nt?(Ye=G("font-mono text-lg font-semibold tabular-nums",nt),e[73]=nt,e[74]=Ye):Ye=e[74];const Me=r.jsxs(an,{children:[Ke,r.jsx(pn,{children:vA(he,je,Pe)}),r.jsx(Hd,{children:r.jsxs("span",{className:Ye,children:[Po(he)," CPU"]})})]});let Ue;e[75]!==d?(Ue=r.jsx(Zt,{children:r.jsx(wA,{values:d})}),e[75]=d,e[76]=Ue):Ue=e[76],e[77]!==Me||e[78]!==Ue?(E=r.jsxs(Qt,{size:"sm",children:[Me,Ue]}),e[77]=Me,e[78]=Ue,e[79]=E):E=e[79],C=Qt,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs(an,{children:[r.jsx(ln,{children:"Processes"}),r.jsx(pn,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],k=Zt,L=ge.length>0?ge.map(NA):a?r.jsx(V2,{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]=f,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]=P,e[19]=A,e[20]=T,e[21]=E,e[22]=R,e[23]=I,e[24]=$,e[25]=M,e[26]=O,e[27]=D,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],P=e[18],A=e[19],T=e[20],E=e[21],R=e[22],I=e[23],$=e[24],M=e[25],O=e[26],D=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]!==A||e[90]!==T?(q=T.length>0&&r.jsxs(Qt,{size:"sm",children:[r.jsxs(an,{children:[r.jsx(ln,{children:"Agent processes"}),r.jsx(pn,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(Zt,{children:T.map((ge,he)=>r.jsxs("div",{children:[he>0&&r.jsx(kt,{}),r.jsx(xA,{metric:ge,onKill:je=>void A(je)})]},ge.pid))})]}),e[89]=A,e[90]=T,e[91]=q):q=e[91];let Y;e[92]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(ln,{children:"Server activity"}),e[92]=Y):Y=e[92];const V=(a==null?void 0:a.sampleWindowSeconds)??10;let J;e[93]!==V?(J=r.jsxs(an,{children:[Y,r.jsxs(pn,{children:["File checks, streams, and agent work over the last ",V," seconds."]})]}),e[93]=V,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(Zt,{children:r.jsx(mh,{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(Qt,{size:"sm",children:[J,X]}),e[99]=J,e[100]=X,e[101]=Z):Z=e[101];let te;e[102]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsxs(an,{children:[r.jsx(ln,{children:"API activity"}),r.jsx(pn,{children:"Requests ranked by recent frequency and time."})]}),e[102]=te):te=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 oe;e[105]!==ne?(oe=r.jsxs(Qt,{size:"sm",children:[te,r.jsx(Zt,{children:r.jsx(mh,{metrics:ne,emptyLabel:"No API requests in this sample."})})]}),e[105]=ne,e[106]=oe):oe=e[106];let re;e[107]!==Z||e[108]!==oe?(re=r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Z,oe]}),e[107]=Z,e[108]=oe,e[109]=re):re=e[109];let ae;e[110]!==a?(ae=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",Po(a.eventLoopPercent)," · heap ",la(a.memory.heapUsedMb)," · RSS ",la(a.memory.rssMb)]}),e[110]=a,e[111]=ae):ae=e[111];let se;e[112]!==E||e[113]!==K||e[114]!==q||e[115]!==re||e[116]!==ae||e[117]!==W||e[118]!==U?(se=r.jsxs("div",{className:W,children:[U,E,K,q,re,ae]}),e[112]=E,e[113]=K,e[114]=q,e[115]=re,e[116]=ae,e[117]=W,e[118]=U,e[119]=se):se=e[119];let fe;e[120]!==N||e[121]!==R||e[122]!==se?(fe=r.jsx(N,{className:R,children:se}),e[120]=N,e[121]=R,e[122]=se,e[123]=fe):fe=e[123];let le;e[124]!==_||e[125]!==I||e[126]!==$||e[127]!==M||e[128]!==fe?(le=r.jsxs(_,{className:I,children:[$,M,fe]}),e[124]=_,e[125]=I,e[126]=$,e[127]=M,e[128]=fe,e[129]=le):le=e[129];let ce;return e[130]!==P||e[131]!==O||e[132]!==D||e[133]!==le?(ce=r.jsx(P,{open:O,onOpenChange:D,children:le}),e[130]=P,e[131]=O,e[132]=D,e[133]=le,e[134]=ce):ce=e[134],ce}function NA(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(kt,{}),r.jsx(V2,{metric:n})]},n.pid)}function kA(n){return setTimeout(n,1e3)}function CA(n,e){return n+e.cpuPercent}function _A(n,e){return e.cpuPercent-n.cpuPercent}function TA(n,e){return n+e.cpuPercent}async function EA(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function PA(n){return`${n.title??`Pull request #${n.number}`}
123
+ ${n.repo}${n.isDraft?" · draft":""}`}function G2(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:PA(n)}}function al(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 f;e[0]!==t?(f=t.map(RA),e[0]=t,e[1]=f):f=e[1];let m;return e[2]!==f?(m=r.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[2]=f,e[3]=m):m=e[3],m}let c,d;if(e[4]!==o||e[5]!==a||e[6]!==t){const f=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(AA).join(`
124
+ `),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?Sd:Mr;return r.jsxs(Ce,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...G2(p)}),className:G("shrink-0",o&&"px-1"),children:[r.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=o,e[13]=m):m=e[13],d=f.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 u;return e[14]!==c||e[15]!==d?(u=r.jsxs(r.Fragment,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=u):u=e[16],u}function AA(n){return`#${n.number} ${n.title??n.repo}`}function RA(n){const e=n.isDraft?Sd:Mr;return r.jsxs("a",{...G2(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 $A=w.memo(function(e){const t=B.c(37),{session:s,sessionSource:o,isLive:i,pullRequests:a,copied:l,creatingSession:c,onCopyResume:d,onNewSession:u,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==o){const A=o?Ns(o.fileName):null;p=A?yu(A.agentId):null,t[0]=o,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(OA),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=ko(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 y=b;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:G(On,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=t[7];let S;t[8]!==l||t[9]!==c||t[10]!==d||t[11]!==f||t[12]!==u||t[13]!==m||t[14]!==s||t[15]!==o?(S=o?r.jsx(MA,{session:s,sessionSource:o,copied:l,creatingSession:c,onCopyResume:d,onNewSession:u,onDuplicateSession:f,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]=f,t[12]=u,t[13]=m,t[14]=s,t[15]=o,t[16]=S):S=t[16];let j;t[17]!==i?(j=i&&r.jsx(Ia,{"aria-label":"Session is live"}),t[17]=i,t[18]=j):j=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:Js(s.model)}),t[19]=s.model,t[20]=k):k=t[20];let C;t[21]!==y?(C=r.jsx(Tg,{rawMessages:y}),t[21]=y,t[22]=C):C=t[22];let N;t[23]!==S||t[24]!==j||t[25]!==k||t[26]!==C?(N=r.jsxs(Ot,{delay:200,render:v,children:[S,j,k,C]}),t[23]=S,t[24]=j,t[25]=k,t[26]=C,t[27]=N):N=t[27];let _;t[28]!==a||t[29]!==y||t[30]!==s||t[31]!==h||t[32]!==x?(_=r.jsx(Dt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(IA,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:a,rawMessages:y})}),t[28]=a,t[29]=y,t[30]=s,t[31]=h,t[32]=x,t[33]=_):_=t[33];let P;return t[34]!==_||t[35]!==N?(P=r.jsxs(Mt,{children:[N,_]}),t[34]=_,t[35]=N,t[36]=P):P=t[36],P});function lo(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 IA(n){const e=B.c(33),{session:t,thinkingEnabled:s,subAgentLabel:o,pullRequests:i,rawMessages:a}=n;let l,c,d,u,f,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=ig(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(lo,{label:"Model",children:[r.jsx("span",{children:Js(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(lo,{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?(u=i.length>0&&r.jsx(lo,{label:"Pull requests",children:r.jsx(al,{pullRequests:i})}),e[19]=i,e[20]=u):u=e[20],e[21]!==o?(f=o&&r.jsx(lo,{label:"Agent",children:o}),e[21]=o,e[22]=f):f=e[22],e[23]!==x?(m=x&&r.jsxs(lo,{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(lo,{label:"Context",children:[mt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",mt(g.used)," / ",mt(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]=u,e[11]=f,e[12]=m,e[13]=p}else l=e[7],c=e[8],d=e[9],u=e[10],f=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==d||e[28]!==u||e[29]!==f||e[30]!==m||e[31]!==p?(h=r.jsxs("div",{className:l,children:[c,d,u,f,m,p]}),e[25]=l,e[26]=c,e[27]=d,e[28]=u,e[29]=f,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function MA(n){const e=B.c(54),{session:t,sessionSource:s,copied:o,creatingSession:i,onCopyResume:a,onNewSession:l,onDuplicateSession:c,onOpenTerminal:d}=n,{dispatch:u}=Ut(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Bs(),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?`${ts(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;let y;e[7]!==t.cwd||e[8]!==s.dirName?(y={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=y):y=e[9];const v=y;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=!p||Vd(),e[10]=S):S=e[10];const j=S;let k;e[11]!==u||e[12]!==s.dirName?(k=function(){w.startTransition(()=>{u({type:"GO_HOME",isMobile:!1}),u({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=u,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 P;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(P=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(gt,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:ts(t.cwd)}),t.cwd&&r.jsx("span",{className:"text-muted-foreground/50",children:"/"}),r.jsx("span",{className:"truncate",children:g})]}),e[17]=o,e[18]=t.cwd,e[19]=g,e[20]=P):P=e[20];let A;e[21]!==_||e[22]!==P?(A=r.jsx(Za,{render:_,children:P}),e[21]=_,e[22]=P,e[23]=A):A=e[23];let T;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(T=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=T):T=e[27];let E;e[28]!==i?(E=i?r.jsx(ot,{className:"size-3.5"}):r.jsx(Bn,{className:"size-3.5"}),e[28]=i,e[29]=E):E=e[29];let R;e[30]!==i||e[31]!==T||e[32]!==E?(R=r.jsxs(rn,{disabled:i,onClick:T,children:[E,"New session in this project"]}),e[30]=i,e[31]=T,e[32]=E,e[33]=R):R=e[33];let I;e[34]!==c?(I=c&&r.jsxs(rn,{onClick:c,children:[r.jsx(Rn,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=I):I=e[35];let $;e[36]!==f||e[37]!==v?($=f&&(j||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(Cr,{}),j&&r.jsxs(rn,{onClick:()=>Zg(v),children:[r.jsx(Pr,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(rn,{onClick:()=>ex(v),children:[r.jsx(_1,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=f,e[37]=v,e[38]=$):$=e[38];let M;e[39]!==d?(M=d&&!p&&ft("terminal")&&r.jsxs(rn,{onClick:d,children:[r.jsx(Gs,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=M):M=e[40];let O;e[41]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Cr,{}),e[41]=O):O=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(No,{className:"size-3.5"}),e[42]=D):D=e[42];let L;e[43]!==C?(L=r.jsxs(rn,{onClick:C,children:[D,"View all sessions in this project"]}),e[43]=C,e[44]=L):L=e[44];let F;e[45]!==R||e[46]!==I||e[47]!==$||e[48]!==M||e[49]!==L?(F=r.jsxs(el,{className:"min-w-56",children:[R,I,$,M,O,L]}),e[45]=R,e[46]=I,e[47]=$,e[48]=M,e[49]=L,e[50]=F):F=e[50];let z;return e[51]!==A||e[52]!==F?(z=r.jsxs(Qa,{children:[A,F]}),e[51]=A,e[52]=F,e[53]=z):z=e[53],z}function OA(n){return n.thinking.length>0}const Qc="Could not reach the server";async function Ai(n,e){try{return await ve(n,e)}catch{return null}}async function ec(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:Qc}function DA(){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]=w.useState(e),[o,i]=w.useState(null),a=w.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]),w.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const k=await Ai("/api/shares");if(!(k!=null&&k.ok))return;const C=await k.json().catch(BA);a.current&&Array.isArray(C)&&s(C)},n[3]=d):d=n[3];const u=d;let f,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{u()},m=[u],n[4]=f,n[5]=m):(f=n[4],m=n[5]),w.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async k=>{i(null);const C=await Ai("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:k})});if(!(C!=null&&C.ok))return a.current&&i(await ec(C)),null;const N=await C.json().catch(FA);if(!(N!=null&&N.passphrase)||!N.share)return a.current&&i(Qc),null;const _=N.share;return a.current&&s(P=>[...P.filter(A=>A.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 Ai(`/api/shares/${encodeURIComponent(k)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await ec(C)),null;const N=await C.json().catch(zA);return N!=null&&N.passphrase?(u(),N.passphrase):(a.current&&i(Qc),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 Ai(`/api/shares/${encodeURIComponent(k)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await ec(C));return}a.current&&s(N=>N.filter(_=>_.sessionId!==k))},n[8]=b):b=n[8];const y=b;let v;n[9]!==t?(v=async()=>{const k=t.map(LA);for(const C of k)await y(C)},n[9]=t,n[10]=v):v=n[10];const S=v;let j;return n[11]!==o||n[12]!==S||n[13]!==t?(j={shares:t,error:o,refresh:u,create:h,regenerate:x,revoke:y,revokeAll:S},n[11]=o,n[12]=S,n[13]=t,n[14]=j):j=n[14],j}function LA(n){return n.sessionId}function zA(){return null}function FA(){return null}function BA(){return null}const UA=5e3,WA="••••";function HA(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function KA({sessionId:n}){const{config:{networkAccessDisabled:e}}=Ut(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=DA(),[c,d]=w.useState(!1),[u,f]=w.useState(null),[m,p]=w.useState(!1),[h,g]=Hs(),[x,b]=Hs(),y=t.find(k=>k.sessionId===n)??null,v=`${window.location.origin}${Z5(n)}`;w.useEffect(()=>f(null),[n]),w.useEffect(()=>{if(!c)return;o();const k=setInterval(()=>void o(),UA);return()=>clearInterval(k)},[c,o]);async function S(k){p(!0);try{await k()}finally{p(!1)}}const j=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(Kn,{open:c,onOpenChange:k=>{d(k),k||f(null)},children:[r.jsx(qn,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y?"Session is shared":"Share session",className:G(y&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:r.jsx(q3,{"data-icon":"inline-start"})}),r.jsx(Vn,{align:"end",sideOffset:6,className:"w-80 p-3",children:y?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(gt,{"data-icon":"inline-start"}):r.jsx(Rn,{"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:u??WA}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>S(async()=>{f(await a(n))}),children:r.jsx(At,{"data-icon":"inline-start"})})]}),u?r.jsx(ee,{variant:"secondary",size:"xs",onClick:()=>b(`${v}
125
+ Passphrase: ${u}`),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."}),j,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:HA(y.guests)}),r.jsx(ee,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>S(async()=>{await l(n),f(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."}),j,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(ee,{size:"xs",disabled:m,onClick:()=>S(async()=>{f(await i(n))}),children:"Enable sharing"})]})})]})}function Mu(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 dt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function En(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function vs(n){return typeof n=="string"?n:void 0}function xs(n){return n?Mu(En(n.utilization),vs(n.resets_at)):void 0}function Y2(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:En(n.monthly_limit),usedCredits:En(n.used_credits),utilization:En(n.utilization)}}function qA(n){return{fiveHour:xs(dt(n.five_hour)),sevenDay:xs(dt(n.seven_day)),sevenDayOpus:xs(dt(n.seven_day_opus)),sevenDaySonnet:xs(dt(n.seven_day_sonnet)),extraUsage:Y2(dt(n.extra_usage)),subscriptionType:vs(n.subscriptionType)}}function VA(n){if(n.available!==!0)return null;const e=dt(n.usage),t=dt(e==null?void 0:e.rate_limits),s=dt(n.account),o={fiveHour:xs(dt(t==null?void 0:t.five_hour)),sevenDay:xs(dt(t==null?void 0:t.seven_day)),sevenDayOpus:xs(dt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:xs(dt(t==null?void 0:t.seven_day_sonnet)),extraUsage:Y2(dt(t==null?void 0:t.extra_usage)),subscriptionType:vs(e==null?void 0:e.subscription_type)??vs(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function GA(n){const e=En(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function YA(n,e){const t=En(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function ph(n,e){if(n)return Mu(En(n.usedPercent),GA(n.resetsAt),YA(n.windowDurationMins,e))}function XA(n){var d,u,f;if(n.available!==!0)return null;const e=dt((d=dt(n.rateLimits))==null?void 0:d.rateLimits),t=dt((u=dt(n.account))==null?void 0:u.account),s=dt((f=dt(n.usage))==null?void 0:f.summary),o=dt(e==null?void 0:e.credits),i=ph(dt(e==null?void 0:e.primary),"Primary"),a=ph(dt(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=En(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!i&&!a&&c===void 0?null:{fiveHour:i,sevenDay:a,subscriptionType:vs(e==null?void 0:e.planType)??vs(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:vs(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function hh(n,e){if(!n)return;const t=En(n.remainingPercentage),s=En(n.usedRequests),o=En(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),Mu(i,vs(n.resetDate),e)}function JA(n){var s;if(n.available!==!0)return null;const e=dt((s=dt(n.quota))==null?void 0:s.quotaSnapshots),t=hh(dt(e==null?void 0:e.chat),"Chat")??hh(dt(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const QA={claude:{endpoint:"/api/claude/runtime",read:VA,legacy:{endpoint:"/api/usage",read:qA}},codex:{endpoint:"/api/codex/runtime",read:XA},copilot:{endpoint:"/api/copilot/runtime",read:JA}};function ZA(n){return QA[n]}const eR=300*1e3;function tR(n=Xs){const e=Pn("viewUsage"),[t,s]=w.useState(null),[o,i]=w.useState(!1),[a,l]=w.useState(!1),c=w.useRef(0),d=w.useRef(null),u=w.useCallback(async()=>{var h;if(!e)return;const f=++c.current;(h=d.current)==null||h.abort();const m=new AbortController;d.current=m;const p=()=>c.current===f&&!m.signal.aborted;i(!0);try{const g=ZA(n);let x=await ve(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await ve(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 y=await x.json();if(!p())return;const v=b(y);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return w.useEffect(()=>{var m;if(s(null),l(!1),!e){i(!1),c.current+=1,(m=d.current)==null||m.abort(),d.current=null;return}u();const f=setInterval(u,eR);return()=>{var p;clearInterval(f),c.current+=1,(p=d.current)==null||p.abort(),d.current=null}},[n,e,u]),{usage:e?t:null,loading:e&&o,available:e&&a,refresh:u}}function X2(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const J2={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function nR(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 u=[];t.fiveHour&&u.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&u.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&u.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&u.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";let f;e[10]!==t.agentKind?(f=t.agentKind?Ra(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=r.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[f," usage"]}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&r.jsx(Ce,{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=u.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=X2(h.pct);return r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted-foreground",children:h.label}),r.jsxs("span",{className:G("font-semibold",J2[b]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Hr,{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(kt,{}),"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(kt,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",mt(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 sR(n){var S,j;const e=B.c(22),{agentKind:t}=n,s=t===void 0?Xs:t,{usage:o,loading:i,available:a,refresh:l}=tR(s);if(!a||!o)return null;const c=((S=o.fiveHour)==null?void 0:S.utilization)??((j=o.sevenDay)==null?void 0:j.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?Ra(o.agentKind):"agent",e[0]=o.agentKind,e[1]=d):d=e[1];const u=`Refresh ${d} usage`;let f;e[2]!==i||e[3]!==l||e[4]!==u?(f=r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":u,onClick:l,disabled:i,className:"mr-1 font-mono"}),e[2]=i,e[3]=l,e[4]=u,e[5]=f):f=e[5];const m=J2[X2(c)],p=i&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=G("tabular-nums",m,p),e[6]=m,e[7]=p,e[8]=h):h=e[8];let g;e[9]!==c?(g=c.toFixed(0),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==h||e[12]!==g?(x=r.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let b;e[14]!==f||e[15]!==x?(b=r.jsx(Ot,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let y;e[17]!==o?(y=r.jsx(Dt,{side:"bottom",className:"p-3",children:r.jsx(nR,{usage:o})}),e[17]=o,e[18]=y):y=e[18];let v;return e[19]!==b||e[20]!==y?(v=r.jsxs(Mt,{children:[b,y]}),e[19]=b,e[20]=y,e[21]=v):v=e[21],v}function oR(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]=w.useState(s),[a,l]=w.useState(0);let c;t[1]!==n||t[2]!==e?(c=()=>{const p=new AbortController;i(iR);const h=Intl.DateTimeFormat().resolvedOptions().timeZone;return ve(`/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],w.useEffect(c,d);let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=()=>l(rR),t[8]=u):u=t[8];const f=u;let m;return t[9]!==o?(m={...o,refresh:f},t[9]=o,t[10]=m):m=t[10],m}function rR(n){return n+1}function iR(n){return{...n,loading:!0,error:null}}function aR(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const lR=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function cR(n,e){const t=aR(e);return t.length===0||lR.has(t)?null:n.get(t)??null}function dR(n,e){const t=n.longContextThresholdTokens,s=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens,o=t!==null&&s>t;return function(a,l,c){return a<=0?0:c===null||t===null?a*l:n.longContextPricing==="wholeRequest"?a*(o?c:l):a<=t?a*l:t*l+(a-t)*c}}function uR(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function fR(n,e,t,s=null){const o=cR(n,e);if(o===null)return null;const i=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),a=t.cacheCreationTokens-i,l=dR(o,t),c=s==="fast"?o.fastCostMultiplier:1;return{uncachedInputUsd:c*l(t.uncachedInputTokens,o.inputCostPerToken,o.inputCostPerTokenAboveThreshold),cachedInputUsd:c*l(t.cachedInputTokens,o.cacheReadCostPerToken,o.cacheReadCostPerTokenAboveThreshold),cacheCreationUsd:c*(l(a,o.cacheCreationCostPerToken,o.cacheCreationCostPerTokenAboveThreshold)+i*o.cacheCreation1hCostPerToken),outputUsd:c*l(t.outputTokens,o.outputCostPerToken,o.outputCostPerTokenAboveThreshold)}}function mR(n,e,t,s,o=null){const i=fR(n,e,t,o);return i===null?{costUsd:0,costSource:"unpriced"}:{costUsd:uR(i),costSource:"modelPriced"}}function Ou(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function pR(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=mR(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 hR=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],ar=lg.map(n=>({key:n,label:sn(n).displayName,color:Jj(n)}));function gR(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 gh(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function xR(n){const e=new Map;for(const o of gR(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:gh(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:gh(),days:[],models:[]};for(const o of n.buckets){const i=Ou(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 xh(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const tc=720,nc=180,bR=18;function vR(n){const e=B.c(41),{days:t,metric:s}=n,[o,i]=w.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 u=nc-bR,f=tc/t.length,m=Math.max(2,Math.min(28,f-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:xh(p.day)}),ar.map(C=>{const{key:N,label:_,color:P}=C,A=p.byProvider[N];return l(A)<=0?null:r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:P}}),_,": ",s==="cost"?hn(A.costUsd):mt(A.tokens)]},N)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?hn(p.costUsd):mt(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:u,x2:tc,y2:u,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let y;if(e[14]!==m||e[15]!==t||e[16]!==o||e[17]!==d||e[18]!==f||e[19]!==l){let C;e[21]!==m||e[22]!==o||e[23]!==d||e[24]!==f||e[25]!==l?(C=(N,_)=>{const P=_*f+(f-m)/2;let A=u;const T=o===_;return r.jsxs("g",{onMouseEnter:()=>i(_),children:[r.jsx("rect",{x:_*f,y:0,width:f,height:u,fill:"transparent"}),T&&r.jsx("rect",{x:_*f,y:0,width:f,height:u,fill:"var(--foreground)",opacity:.05,rx:2}),ar.map(E=>{const{key:R,color:I}=E,$=l(N.byProvider[R]);if($<=0)return null;const M=$/d*(u-6);return A=A-M,r.jsx("rect",{x:P,y:A,width:m,height:Math.max(1,M-1.5),rx:1.5,fill:I,opacity:T?1:.85},R)})]},N.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=f,e[25]=l,e[26]=C):C=e[26],y=t.map(C),e[14]=m,e[15]=t,e[16]=o,e[17]=d,e[18]=f,e[19]=l,e[20]=y}else y=e[20];let v;if(e[27]!==t||e[28]!==f){let C;e[30]!==t.length||e[31]!==f?(C=(N,_)=>_===0||_===t.length-1||t.length>10&&_%7===0&&_<t.length-3?r.jsx("text",{x:_*f+f/2,y:nc-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:xh(N.day)},N.day):null,e[30]=t.length,e[31]=f,e[32]=C):C=e[32],v=t.map(C),e[27]=t,e[28]=f,e[29]=v}else v=e[29];let S;e[33]!==g||e[34]!==y||e[35]!==v?(S=r.jsxs("svg",{viewBox:`0 0 ${tc} ${nc}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,y,v]}),e[33]=g,e[34]=y,e[35]=v,e[36]=S):S=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:ar.map(yR)}),e[37]=j):j=e[37];let k;return e[38]!==h||e[39]!==S?(k=r.jsxs("div",{className:"relative",children:[h,S,j]}),e[38]=h,e[39]=S,e[40]=k):k=e[40],k}function yR(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 sc(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 wR(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=oR(t,!0),[l,c]=w.useState("cost");let d;e[0]!==s?(d=s?xR(s):null,e[0]=s,e[1]=d):d=e[1];const u=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(!u||!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(ot,{className:"size-4"})," Scanning transcripts…"]}),e[7]=F):F=e[7],F}const f=o&&"opacity-60";let m;e[8]!==f?(m=G("flex flex-col gap-5",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==u.costUsd||e[11]!==u.tokens||e[12]!==l?(p=l==="cost"?hn(u.costUsd):mt(u.tokens),e[10]=u.costUsd,e[11]=u.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 y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=["cost","tokens"],e[22]=y):y=e[22];let v;e[23]!==l?(v=r.jsx("div",{className:"flex rounded-md border p-0.5",children:y.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 S;e[25]!==u.byProvider||e[26]!==l?(S=ar.map(F=>{const{key:z,label:W}=F,U=u.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"?hn(U.costUsd):mt(U.tokens)]},z)}),e[25]=u.byProvider,e[26]=l,e[27]=S):S=e[27];let j;e[28]!==v||e[29]!==S?(j=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,S]}),e[28]=v,e[29]=S,e[30]=j):j=e[30];let k;e[31]!==j||e[32]!==b?(k=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,j]}),e[31]=j,e[32]=b,e[33]=k):k=e[33];let C;e[34]!==u.days||e[35]!==l?(C=r.jsx(vR,{days:u.days,metric:l}),e[34]=u.days,e[35]=l,e[36]=C):C=e[36];let N;e[37]!==u.tokens?(N=mt(u.tokens),e[37]=u.tokens,e[38]=N):N=e[38];let _;e[39]!==N?(_=r.jsx(sc,{label:"Processed tokens",value:N}),e[39]=N,e[40]=_):_=e[40];let P;e[41]!==u.cacheSavingsUsd?(P=hn(u.cacheSavingsUsd),e[41]=u.cacheSavingsUsd,e[42]=P):P=e[42];let A;e[43]!==P?(A=r.jsx(sc,{label:"Cache savings",value:P}),e[43]=P,e[44]=A):A=e[44];const T=String(s.scannedFiles);let E;e[45]!==T?(E=r.jsx(sc,{label:"Files scanned",value:T}),e[45]=T,e[46]=E):E=e[46];let R;e[47]!==_||e[48]!==A||e[49]!==E?(R=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[_,A,E]}),e[47]=_,e[48]=A,e[49]=E,e[50]=R):R=e[50];let I;e[51]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("thead",{children:r.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[r.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),r.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=I):I=e[51];let $;if(e[52]!==u.costUsd||e[53]!==u.models){let F;e[55]!==u.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=ar.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?"—":hn(z.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:u.costUsd>0&&!z.unpriced?`${(z.costUsd/u.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:mt(z.tokens)})]},`${z.provider}:${z.model}`)},e[55]=u.costUsd,e[56]=F):F=e[56],$=u.models.map(F),e[52]=u.costUsd,e[53]=u.models,e[54]=$}else $=e[54];let M;e[57]!==$?(M=r.jsxs("table",{className:"w-full text-sm",children:[I,r.jsx("tbody",{children:$})]}),e[57]=$,e[58]=M):M=e[58];const O=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let D;e[59]!==O?(D=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",O," ","— not what a subscription bills."]}),e[59]=O,e[60]=D):D=e[60];let L;return e[61]!==k||e[62]!==C||e[63]!==R||e[64]!==M||e[65]!==D||e[66]!==m?(L=r.jsxs("div",{className:m,children:[k,C,R,M,D]}),e[61]=k,e[62]=C,e[63]=R,e[64]=M,e[65]=D,e[66]=m,e[67]=L):L=e[67],L}function jR(n){const e=B.c(15),{open:t,onOpenChange:s}=n,[o,i]=w.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(as,{children:"API usage"}),r.jsx(ls,{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=hR.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(Ps,{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(wR,{days:o}),e[5]=o,e[6]=t,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=r.jsxs(is,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let f;return e[11]!==s||e[12]!==t||e[13]!==u?(f=r.jsx(rs,{open:t,onOpenChange:s,children:u}),e[11]=s,e[12]=t,e[13]=u,e[14]=f):f=e[14],f}const SR=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,NR=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,oc=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,kR=[new RegExp(`${oc}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${oc}'([^']*)'`),new RegExp(`${oc}(\\S+)`)];function CR(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 _R(n){return CR(n).find(e=>NR.test(e))??null}function TR(n){for(const e of kR){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function ER(){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=SR.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:TR(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function PR(n){const e=ER();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=_R(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function AR(...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 co="flex h-8 items-center px-0.5",RR=w.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:u,onBackToMain:f,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x}=e,b=o===void 0?s:o,{config:y}=Ut(),{networkUrl:v,defaultAgentKind:S}=y,{session:j,sessionSource:k,isLive:C}=ct(),N=gu(),_=Pn("viewUsage"),[P,A]=w.useState(!1),[T,E]=w.useState(!1),[R,I]=Hs(),$=j==null?void 0:j.turns;let M;t[0]!==(N==null?void 0:N.sessions)||t[1]!==(j==null?void 0:j.sessionId)?(M=(Fe=N==null?void 0:N.sessions.find(Ne=>Ne.sessionId===(j==null?void 0:j.sessionId)))==null?void 0:Fe.pullRequests,t[0]=N==null?void 0:N.sessions,t[1]=j==null?void 0:j.sessionId,t[2]=M):M=t[2];const O=M;let D;t[3]!==O||t[4]!==$?(D=AR(PR($??[]),O),t[3]=O,t[4]=$,t[5]=D):D=t[5];const L=D;let F;t[6]!==S||t[7]!==k?(F=k?k.agentKind??Rt(k.dirName):S,t[6]=S,t[7]=k,t[8]=F):F=t[8];const z=F;let W;t[9]!==k?(W=k?Ns(k.fileName)!==null:!1,t[9]=k,t[10]=W):W=t[10];const U=W;let H;t[11]!==I||t[12]!==j||t[13]!==(k==null?void 0:k.agentKind)||t[14]!==(k==null?void 0:k.dirName)?(H=function(){if(!j)return;const pe=(k==null?void 0:k.agentKind)??Rt((k==null?void 0:k.dirName)??null);I(W1(pe,j.sessionId,j.cwd))},t[11]=I,t[12]=j,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&&Dr(v).then(IR)},t[16]=v,t[17]=q):q=t[17];const Y=q;let V,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"}),V=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]=V,t[19]=J):(V=t[18],J=t[19]);const Q=!b&&"window-inset-start";let X;t[20]!==Q?(X=G("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($R,{icon:G3,label:`Show sidebar (${i})`,onClick:h}),t[22]=h,t[23]=s,t[24]=i,t[25]=Z):Z=t[25];let te;t[26]!==U||t[27]!==f||t[28]!==j?(te=j&&U&&f&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:G(On,"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]=f,t[28]=j,t[29]=te):te=t[29];let ne;t[30]!==R||t[31]!==l||t[32]!==K||t[33]!==C||t[34]!==d||t[35]!==c||t[36]!==u||t[37]!==L||t[38]!==j||t[39]!==k?(ne=j&&r.jsx($A,{session:j,sessionSource:k,isLive:C,pullRequests:L,copied:R,creatingSession:l,onCopyResume:K,onNewSession:c,onDuplicateSession:d,onOpenTerminal:u}),t[30]=R,t[31]=l,t[32]=K,t[33]=C,t[34]=d,t[35]=c,t[36]=u,t[37]=L,t[38]=j,t[39]=k,t[40]=ne):ne=t[40];let oe;t[41]!==m||t[42]!==j||t[43]!==p?(oe=j&&m&&(p??0)>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:G(On,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[r.jsx(Nd,{className:"size-3"}),"Workflows",r.jsx(Ce,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=j,t[43]=p,t[44]=oe):oe=t[44];let re;t[45]!==X||t[46]!==Z||t[47]!==te||t[48]!==ne||t[49]!==oe?(re=r.jsxs("div",{className:X,children:[Z,te,ne,oe]}),t[45]=X,t[46]=Z,t[47]=te,t[48]=ne,t[49]=oe,t[50]=re):re=t[50];let ae,se,fe;t[51]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx("div",{className:G(On,co,"empty:hidden"),children:r.jsx(oA,{})}),se=r.jsx("div",{className:G(On,co,"empty:hidden"),children:r.jsx(fA,{})}),fe=G(On,co,"empty:hidden"),t[51]=ae,t[52]=se,t[53]=fe):(ae=t[51],se=t[52],fe=t[53]);let le;t[54]!==z?(le=r.jsx("div",{className:fe,children:r.jsx(sR,{agentKind:z})}),t[54]=z,t[55]=le):le=t[55];let ce;t[56]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx("div",{className:G(On,co,"empty:hidden"),children:r.jsx(Iu,{})}),t[56]=ce):ce=t[56];let me;t[57]!==z||t[58]!==j?(me=j&&Vt(z).sharing&&ft("share")&&r.jsx("div",{className:G(On,co),children:r.jsx(KA,{sessionId:j.sessionId})}),t[57]=z,t[58]=j,t[59]=me):me=t[59];let ue;t[60]===Symbol.for("react.memo_cache_sentinel")?(ue=G(On,co),t[60]=ue):ue=t[60];let de;t[61]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(qn,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(T1,{"data-icon":"inline-start"})}),t[61]=de):de=t[61];let be;t[62]!==_?(be=_&&r.jsxs(Pt,{onClick:()=>A(!0),children:[r.jsx(E1,{}),"Usage & cost…"]}),t[62]=_,t[63]=be):be=t[63];let ge;t[64]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsxs(Pt,{onClick:()=>E(!0),children:[r.jsx(P1,{}),"Server monitor…"]}),t[64]=ge):ge=t[64];let he;t[65]!==Y||t[66]!==v?(he=v&&r.jsxs(Pt,{onClick:Y,children:[r.jsx(xc,{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]=he):he=t[67];let je;t[68]!==be||t[69]!==he?(je=r.jsxs(tn,{children:[be,ge,he]}),t[68]=be,t[69]=he,t[70]=je):je=t[70];let Se;t[71]===Symbol.for("react.memo_cache_sentinel")?(Se=r.jsx(gr,{}),t[71]=Se):Se=t[71];let Pe;t[72]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsx(Y3,{}),t[72]=Pe):Pe=t[72];let Re;t[73]!==x?(Re=r.jsx(tn,{children:r.jsxs(Pt,{onClick:x,children:[Pe,"Settings"]})}),t[73]=x,t[74]=Re):Re=t[74];let $e;t[75]!==a||t[76]!==g?($e=ft("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(gr,{}),r.jsx(tn,{children:r.jsxs(Pt,{variant:"destructive",onClick:g,disabled:a,children:[r.jsx(V3,{}),a?"Stopping processes…":"Stop all agent processes"]})})]}),t[75]=a,t[76]=g,t[77]=$e):$e=t[77];let De;t[78]!==je||t[79]!==Re||t[80]!==$e?(De=r.jsx("div",{className:ue,children:r.jsxs(Kn,{children:[de,r.jsxs(Vn,{align:"end",sideOffset:6,className:"w-64",children:[je,Se,Re,$e]})]})}),t[78]=je,t[79]=Re,t[80]=$e,t[81]=De):De=t[81];let Le;t[82]!==le||t[83]!==me||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,se,le,ce,me,De]}),t[82]=le,t[83]=me,t[84]=De,t[85]=Le):Le=t[85];let ze;t[86]!==re||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:[re,Le]}),t[86]=re,t[87]=Le,t[88]=ze):ze=t[88];let Te;t[89]!==_||t[90]!==P?(Te=_&&r.jsx(jR,{open:P,onOpenChange:A}),t[89]=_,t[90]=P,t[91]=Te):Te=t[91];let _e;t[92]!==T?(_e=r.jsx(SA,{open:T,onOpenChange:E}),t[92]=T,t[93]=_e):_e=t[93];let We;return t[94]!==ze||t[95]!==Te||t[96]!==_e?(We=r.jsxs(r.Fragment,{children:[J,V,ze,Te,_e]}),t[94]=ze,t[95]=Te,t[96]=_e,t[97]=We):We=t[97],We});function $R(n){const e=B.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=G(On,"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(Ot,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(Dt,{side:"bottom",children:s}),e[9]=s,e[10]=d):d=e[10];let u;return e[11]!==c||e[12]!==d?(u=r.jsxs(Mt,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function IR(n){n&&Is.success("Copied network URL")}const MR=w.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(Tl,{icon:ys,label:"Home",onClick:o,size:"default"}),t[1]=o,t[2]=d):d=t[2];const u=`Search (${l})`;let f;t[3]!==i||t[4]!==u?(f=r.jsx(Tl,{icon:cn,label:u,onClick:i,size:"default"}),t[3]=i,t[4]=u,t[5]=f):f=t[5];const m=`Hide sidebar (${a})`;let p;t[6]!==s||t[7]!==m?(p=r.jsx(Tl,{icon:X3,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]!==f||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,f,p]}),t[9]=d,t[10]=f,t[11]=p,t[12]=h):h=t[12],h});function OR(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Z3,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function bh(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(Q3,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function DR(n){const e=B.c(12);let t,s,o;e[0]!==n?({withHandle:o,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==t?(i=G("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),e[4]=t,e[5]=i):i=e[5];let a;e[6]!==o?(a=o&&r.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=o,e[7]=a):a=e[7];let l;return e[8]!==s||e[9]!==i||e[10]!==a?(l=r.jsx(J3,{"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 Q2=w.createContext(null);function LR(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(Q2.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Du(){const n=w.useContext(Q2);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function Z2(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=G("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 u;e[7]!==s?(u=r.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=u):u=e[8];let f;e[9]!==a||e[10]!==d||e[11]!==u?(f=r.jsxs(Ot,{render:d,children:[u,a]}),e[9]=a,e[10]=d,e[11]=u,e[12]=f):f=e[12];let m;e[13]!==t?(m=r.jsx(Dt,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==f||e[16]!==m?(p=r.jsxs(Mt,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function eb(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function zR(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,u,f,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=eb(t,s);if(x.length===0&&c.length===0){h=null;break e}d="Workspace panels",u="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?(f=c.map(FR),e[13]=c,e[14]=f):f=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=y=>{var k;const v=y.id===o,S=(k=y.badge)==null?void 0:k.call(y,s),j=y.indicator;return r.jsx(Z2,{title:y.title,icon:y.icon,active:v,onClick:()=>i(y.id),children:j?r.jsx(j,{context:s,active:v}):S!=null&&r.jsx(Ce,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:S})},y.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]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=h}else d=e[7],u=e[8],f=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]!==u||e[21]!==f||e[22]!==m||e[23]!==p?(g=r.jsxs("aside",{"aria-label":d,className:u,children:[f,m,p]}),e[19]=d,e[20]=u,e[21]=f,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function FR(n){return r.jsx(Z2,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function BR(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]=w.useState(l);let u,f;e[2]!==o?(u=()=>{d(h=>{if(h.has(o))return h;const g=new Set(h);return g.add(o),g})},f=[o],e[2]=o,e[3]=u,e[4]=f):(u=e[3],f=e[4]),w.useEffect(u,f);let m;if(e[5]!==o||e[6]!==s||e[7]!==i||e[8]!==a||e[9]!==t||e[10]!==c){let h;e[12]!==o||e[13]!==s||e[14]!==i||e[15]!==a||e[16]!==c?(h=g=>{const x=g.id===o;if(!x&&(!g.keepAlive||!c.has(g.id)))return null;const b=g.component;return r.jsx("div",{className:G("absolute inset-0 min-h-0",!x&&"hidden"),"aria-hidden":!x,children:r.jsx(b,{context:s,active:x,closePanel:i,openPanel:a})},g.id)},e[12]=o,e[13]=s,e[14]=i,e[15]=a,e[16]=c,e[17]=h):h=e[17],m=t.map(h),e[5]=o,e[6]=s,e[7]=i,e[8]=a,e[9]=t,e[10]=c,e[11]=m}else m=e[11];let p;return e[18]!==m?(p=r.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-background",children:m}),e[18]=m,e[19]=p):p=e[19],p}function UR(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 WR(n){const e=B.c(24),{children:t,panels:s,context:o,activePanel:i,services:a,onClosePanel:l,onOpenPanel:c,onTogglePanel:d,actions:u}=n;let f;e[0]!==i?(f=i?UR(i.defaultSize):"100%",e[0]=i,e[1]=f):f=e[1];let m;e[2]!==t||e[3]!==f?(m=r.jsx(bh,{defaultSize:f,minSize:"320px",children:t}),e[2]=t,e[3]=f,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(DR,{withHandle:!0}),r.jsx(bh,{defaultSize:i.defaultSize??"36%",minSize:i.minSize??"300px",maxSize:i.maxSize??"70%",children:r.jsx(LR,{value:a,children:r.jsx(BR,{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(OR,{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]!==u||e[16]!==o||e[17]!==d||e[18]!==s||e[19]!==g?(x=r.jsx(zR,{panels:s,context:o,activePanelId:g,onTogglePanel:d,actions:u}),e[15]=u,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 ti={data:null,error:null,loading:!1,refreshing:!1},HR=8e3,KR=new Set(["clickup_not_configured","clickup_auth_failed","project_unlinked"]),ll="*",Lu={endpoint:()=>"/api/clickup/status",pollIntervalMs:5*6e4,fallbackError:"Unable to reach ClickUp",stores:new Map},tb={endpoint:()=>"/api/clickup/tasks/mine",pollIntervalMs:6e4,fallbackError:"Unable to load your ClickUp tasks",stores:new Map},ca={endpoint:n=>`/api/clickup/tasks/list?cwd=${encodeURIComponent(n)}`,pollIntervalMs:6e4,fallbackError:"Unable to load the linked ClickUp list",stores:new Map};function da(n,e){let t=n.stores.get(e);return t||(t={snapshot:ti,listeners:new Set,request:null,fetchedAt:0},n.stores.set(e,t)),t}function lr(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function nb(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`ClickUp request failed (${n.status})`,code:"clickup_api_failed"}}function cr(n,e){const t=n;return{error:typeof t.error=="string"?t.error:e,code:typeof t.code=="string"?t.code:"clickup_api_failed"}}async function yo(n,e,t=!1){const s=da(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&KR.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<HR))return(t||s.snapshot.data===null)&&lr(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=ve(n.endpoint(e)).then(async o=>{if(!o.ok)throw await nb(o);const i=await o.json();s.fetchedAt=Date.now(),lr(s,{data:i,error:null,loading:!1,refreshing:!1})}).catch(o=>{lr(s,{...s.snapshot,error:cr(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function zu(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==n||s[1]!==o?(i=p=>{if(!o)return VR;const h=da(n,o);return h.listeners.add(p),()=>h.listeners.delete(p)},s[0]=n,s[1]=o,s[2]=i):i=s[2];let a;s[3]!==n||s[4]!==o?(a=()=>o?da(n,o).snapshot:ti,s[3]=n,s[4]=o,s[5]=a):a=s[5];const l=w.useSyncExternalStore(i,a,qR);let c,d;s[6]!==t||s[7]!==n||s[8]!==o?(c=()=>{if(!t||!o)return;yo(n,o);const p=window.setInterval(()=>{yo(n,o)},n.pollIntervalMs);return()=>window.clearInterval(p)},d=[n,t,o],s[6]=t,s[7]=n,s[8]=o,s[9]=c,s[10]=d):(c=s[9],d=s[10]),w.useEffect(c,d);let u;s[11]!==n||s[12]!==o?(u=()=>o?yo(n,o,!0):Promise.resolve(),s[11]=n,s[12]=o,s[13]=u):u=s[13];const f=u;let m;return s[14]!==f||s[15]!==l?(m={...l,refresh:f},s[14]=f,s[15]=l,s[16]=m):m=s[16],m}function qR(){return ti}function VR(){}function sb(n){return zu(Lu,ll,n)}function ob(n){return zu(tb,ll,n)}function GR(n,e){return zu(ca,n,e)}async function ni(n,e){const t=await ve(n,e);if(!t.ok)throw await nb(t);return t.json()}function rb(n,e){return{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}}function ib(){for(const n of[tb,ca])for(const e of n.stores.values())e.fetchedAt=0,lr(e,ti)}async function YR(n){await ni("/api/clickup/token",rb("POST",{token:n})),ib(),await yo(Lu,ll,!0)}async function XR(){await ni("/api/clickup/token",{method:"DELETE"}),ib(),await yo(Lu,ll,!0)}async function ab(n,e){await ni("/api/clickup/project-list",rb("PUT",{cwd:n,listId:e}));const t=da(ca,n);t.fetchedAt=0,lr(t,ti),e!==null&&await yo(ca,n,!0)}function JR(){return ni("/api/clickup/spaces")}function QR(n){return ni(`/api/clickup/lists?spaceId=${encodeURIComponent(n)}`)}const vh={status:null,due:"all",priority:null,query:""},yh={urgent:0,high:1,normal:2,low:3},wh=1440*60*1e3;function Do(n){return n.status.type==="closed"}function lb(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Ao(n,e){return n.dueAt!==null&&!Do(n)&&n.dueAt<lb(e)}function cb(n,e,t){if(e==="all")return!0;if(e==="none")return n.dueAt===null;if(n.dueAt===null)return!1;const s=lb(t);switch(e){case"overdue":return Ao(n,t);case"today":return n.dueAt>=s&&n.dueAt<s+wh;case"week":return n.dueAt>=s&&n.dueAt<s+7*wh}}function ZR(n,e){const t=e.trim().toLowerCase();return t?[n.name,n.customId??"",n.listName,n.folderName??"",...n.tags.map(s=>s.name)].some(s=>s.toLowerCase().includes(t)):!0}function e$(n,e,t){return n.filter(s=>(e.status===null||s.status.name===e.status)&&(e.priority===null||s.priority===e.priority)&&cb(s,e.due,t)&&ZR(s,e.query))}function t$(n){const e=new Map;for(const t of n)e.has(t.status.name)||e.set(t.status.name,t.status);return[...e.values()].sort((t,s)=>t.order-s.order||t.name.localeCompare(s.name))}function n$(n,e){return[...n].sort((t,s)=>{const o=Number(Ao(s,e))-Number(Ao(t,e));if(o!==0)return o;if(t.dueAt!==s.dueAt)return t.dueAt===null?1:s.dueAt===null?-1:t.dueAt-s.dueAt;const i=(t.priority?yh[t.priority]:4)-(s.priority?yh[s.priority]:4);return i!==0?i:s.updatedAt-t.updatedAt})}function Fu(n,e){return n?`${n} › ${e}`:e}function s$(n){const e=n.customId??n.id,t=n.description.trim();return[`Work on ClickUp task ${e}: ${n.name}`,n.url,...t?["",t]:[]].join(`
126
+ `)}function o$(n){const e=n.trim();if(/^\d+$/.test(e))return e;const t=e.match(/\/li\/(\d+)/)??e.match(/\/list\/(\d+)/);return t?t[1]:null}const r$={urgent:"text-destructive",high:"text-warning",normal:"text-info",low:"text-muted-foreground"},i$=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"});function db(n){const e=B.c(5),{priority:t}=n;if(!t)return null;const s=r$[t];let o;e[0]!==s?(o=G("size-3 shrink-0",s),e[0]=s,e[1]=o):o=e[1];const i=`${t} priority`;let a;return e[2]!==o||e[3]!==i?(a=r.jsx(So,{className:o,"aria-label":i,role:"img",fill:"currentColor"}),e[2]=o,e[3]=i,e[4]=a):a=e[4],a}function a$(n){const e=B.c(14),{task:t,now:s}=n;if(t.dueAt===null)return null;const o=Ao(t,s);let i;e[0]!==t.dueAt?(i=new Date(t.dueAt).toLocaleDateString(),e[0]=t.dueAt,e[1]=i):i=e[1];const a=`Due ${i}`,l=o?"text-destructive":"text-muted-foreground";let c;e[2]!==l?(c=G("flex shrink-0 items-center gap-0.5 text-[10px] tabular-nums",l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t.dueAt?(d=new Date(t.dueAt).toISOString(),e[4]=t.dueAt,e[5]=d):d=e[5];const u=o?`${a} (overdue)`:a;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(tw,{className:"size-3","aria-hidden":!0}),e[6]=f):f=e[6];let m;e[7]!==t.dueAt?(m=i$.format(t.dueAt),e[7]=t.dueAt,e[8]=m):m=e[8];let p;return e[9]!==c||e[10]!==d||e[11]!==u||e[12]!==m?(p=r.jsxs("time",{className:c,dateTime:d,title:u,children:[f,m]}),e[9]=c,e[10]=d,e[11]=u,e[12]=m,e[13]=p):p=e[13],p}function l$(n){const e=B.c(14),{assignees:t,viewer:s}=n;let o,i,a,l,c;if(e[0]!==t||e[1]!==s){c=Symbol.for("react.early_return_sentinel");e:{let u;e[7]!==s?(u=p=>p.id!==s.id,e[7]=s,e[8]=u):u=e[8];const f=t.filter(u);if(f.length===0){c=null;break e}const m=`Also assigned to ${f.map(d$).join(", ")}`;o="flex shrink-0 -space-x-1",i=m,a=m,l=f.slice(0,3).map(c$)}e[0]=t,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=l,e[6]=c}else o=e[2],i=e[3],a=e[4],l=e[5],c=e[6];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==l?(d=r.jsx("span",{className:o,"aria-label":i,title:a,children:l}),e[9]=o,e[10]=i,e[11]=a,e[12]=l,e[13]=d):d=e[13],d}function c$(n){return r.jsx("span",{className:"flex size-4 items-center justify-center rounded-full border border-background text-[8px] font-medium text-white",style:{backgroundColor:n.color??"#6b7280"},"aria-hidden":!0,children:n.initials.slice(0,2)},n.id)}function d$(n){return n.username}function u$(n){const e=B.c(130),{task:t,viewer:s,now:o,onPickStatus:i,composePrompt:a}=n,[l,c]=w.useState(!1);let d,u,f,m,p,h,g,x,b,y,v,S,j,k,C,N;if(e[0]!==l||e[1]!==t){const de=Do(t);let be;e[18]!==t.description?(be=t.description.trim(),e[18]=t.description,e[19]=be):be=e[19],f=be;let ge;e[20]!==t.folderName||e[21]!==t.listName?(ge=Fu(t.folderName,t.listName),e[20]=t.folderName,e[21]=t.listName,e[22]=ge):ge=e[22],m=ge,h="relative pl-3",g=t.name,e[23]!==t.status.color?(x=r.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-1 left-0 w-0.5 rounded-full",style:{backgroundColor:t.status.color}}),e[23]=t.status.color,e[24]=x):x=e[24],u=it,C=l,N=c,k="group/task flex items-start gap-1 pr-1",d=$t,v="flex min-w-0 flex-1 flex-col rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20",S=`${t.name}: ${t.status.name}`,j=l,b="flex min-w-0 items-center gap-2",e[25]!==t.priority?(y=r.jsx(db,{priority:t.priority}),e[25]=t.priority,e[26]=y):y=e[26],p=G("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",de&&"text-muted-foreground line-through decoration-border"),e[0]=l,e[1]=t,e[2]=d,e[3]=u,e[4]=f,e[5]=m,e[6]=p,e[7]=h,e[8]=g,e[9]=x,e[10]=b,e[11]=y,e[12]=v,e[13]=S,e[14]=j,e[15]=k,e[16]=C,e[17]=N}else d=e[2],u=e[3],f=e[4],m=e[5],p=e[6],h=e[7],g=e[8],x=e[9],b=e[10],y=e[11],v=e[12],S=e[13],j=e[14],k=e[15],C=e[16],N=e[17];let _;e[27]!==p||e[28]!==t.name?(_=r.jsx("span",{className:p,children:t.name}),e[27]=p,e[28]=t.name,e[29]=_):_=e[29];let P;e[30]!==t.customId?(P=t.customId&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:t.customId}),e[30]=t.customId,e[31]=P):P=e[31];let A;e[32]!==_||e[33]!==P||e[34]!==b||e[35]!==y?(A=r.jsxs("span",{className:b,children:[y,_,P]}),e[32]=_,e[33]=P,e[34]=b,e[35]=y,e[36]=A):A=e[36];let T;e[37]!==t.status.color?(T={color:t.status.color},e[37]=t.status.color,e[38]=T):T=e[38];let E;e[39]!==T||e[40]!==t.status.name?(E=r.jsx("span",{className:"shrink-0 rounded-sm px-1 text-[10px] uppercase tracking-wide",style:T,children:t.status.name}),e[39]=T,e[40]=t.status.name,e[41]=E):E=e[41];let R;e[42]!==m?(R=r.jsx("span",{className:"truncate",children:m}),e[42]=m,e[43]=R):R=e[43];let I;e[44]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("span",{className:"shrink-0",children:"·"}),e[44]=I):I=e[44];let $;e[45]!==t.updatedAt?($=new Date(t.updatedAt).toISOString(),e[45]=t.updatedAt,e[46]=$):$=e[46];let M;e[47]!==t.updatedAt?(M=new Date(t.updatedAt).toLocaleString(),e[47]=t.updatedAt,e[48]=M):M=e[48];let O;e[49]!==o||e[50]!==t.updatedAt?(O=ol(new Date(t.updatedAt).toISOString(),o),e[49]=o,e[50]=t.updatedAt,e[51]=O):O=e[51];let D;e[52]!==$||e[53]!==M||e[54]!==O?(D=r.jsx("time",{className:"shrink-0",dateTime:$,title:M,children:O}),e[52]=$,e[53]=M,e[54]=O,e[55]=D):D=e[55];let L;e[56]!==E||e[57]!==R||e[58]!==D?(L=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[E,R,I,D]}),e[56]=E,e[57]=R,e[58]=D,e[59]=L):L=e[59];let F;e[60]!==d||e[61]!==A||e[62]!==L||e[63]!==v||e[64]!==S||e[65]!==j?(F=r.jsxs(d,{className:v,"aria-label":S,"aria-expanded":j,children:[A,L]}),e[60]=d,e[61]=A,e[62]=L,e[63]=v,e[64]=S,e[65]=j,e[66]=F):F=e[66];let z;e[67]!==o||e[68]!==t?(z=r.jsx(a$,{task:t,now:o}),e[67]=o,e[68]=t,e[69]=z):z=e[69];let W;e[70]!==t.assignees||e[71]!==s?(W=r.jsx(l$,{assignees:t.assignees,viewer:s}),e[70]=t.assignees,e[71]=s,e[72]=W):W=e[72];const U=`Open ${t.customId??t.name} in ClickUp`;let H;e[73]!==t.url?(H=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[73]=t.url,e[74]=H):H=e[74];let K;e[75]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(nn,{}),e[75]=K):K=e[75];let q;e[76]!==U||e[77]!==H?(q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/task:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":U,onClick:H,children:K}),e[76]=U,e[77]=H,e[78]=q):q=e[78];let Y;e[79]!==z||e[80]!==W||e[81]!==q?(Y=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1.5",children:[z,W,q]}),e[79]=z,e[80]=W,e[81]=q,e[82]=Y):Y=e[82];let V;e[83]!==F||e[84]!==Y||e[85]!==k?(V=r.jsxs("div",{className:k,children:[F,Y]}),e[83]=F,e[84]=Y,e[85]=k,e[86]=V):V=e[86];let J;e[87]!==f?(J=f?r.jsx($u,{body:f}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[87]=f,e[88]=J):J=e[88];let Q;e[89]!==i||e[90]!==t.status.name?(Q=()=>i(t.status.name),e[89]=i,e[90]=t.status.name,e[91]=Q):Q=e[91];const X=`Only tasks in ${t.status.name}`;let Z;e[92]!==t.status.color?(Z=r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:t.status.color}}),e[92]=t.status.color,e[93]=Z):Z=e[93];let te;e[94]!==Q||e[95]!==X||e[96]!==Z||e[97]!==t.status.name?(te=r.jsx("li",{children:r.jsxs("button",{type:"button",className:"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20",onClick:Q,"aria-label":X,children:[Z,t.status.name]})}),e[94]=Q,e[95]=X,e[96]=Z,e[97]=t.status.name,e[98]=te):te=e[98];let ne;e[99]!==t.tags?(ne=t.tags.map(f$),e[99]=t.tags,e[100]=ne):ne=e[100];let oe;e[101]!==te||e[102]!==ne?(oe=r.jsxs("ul",{className:"flex flex-wrap gap-1","aria-label":"Task details",children:[te,ne]}),e[101]=te,e[102]=ne,e[103]=oe):oe=e[103];let re;e[104]!==a||e[105]!==t?(re=a&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>a(s$(t)),children:[r.jsx(A1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[104]=a,e[105]=t,e[106]=re):re=e[106];let ae;e[107]!==t.url?(ae=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[107]=t.url,e[108]=ae):ae=e[108];let se;e[109]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(nn,{"data-icon":"inline-end"}),e[109]=se):se=e[109];let fe;e[110]!==ae?(fe=r.jsxs(ee,{variant:"outline",size:"xs",render:ae,children:["Open in ClickUp",se]}),e[110]=ae,e[111]=fe):fe=e[111];let le;e[112]!==re||e[113]!==fe?(le=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[re,fe]}),e[112]=re,e[113]=fe,e[114]=le):le=e[114];let ce;e[115]!==J||e[116]!==oe||e[117]!==le?(ce=r.jsx(at,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-1 pr-1",children:[J,oe,le]})}),e[115]=J,e[116]=oe,e[117]=le,e[118]=ce):ce=e[118];let me;e[119]!==u||e[120]!==V||e[121]!==ce||e[122]!==C||e[123]!==N?(me=r.jsxs(u,{open:C,onOpenChange:N,children:[V,ce]}),e[119]=u,e[120]=V,e[121]=ce,e[122]=C,e[123]=N,e[124]=me):me=e[124];let ue;return e[125]!==h||e[126]!==g||e[127]!==x||e[128]!==me?(ue=r.jsxs("article",{className:h,"aria-label":g,children:[x,me]}),e[125]=h,e[126]=g,e[127]=x,e[128]=me,e[129]=ue):ue=e[129],ue}function f$(n){return r.jsx("li",{className:"inline-flex h-5 items-center rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground",children:n.name},n.name)}function ub(n){const e=B.c(75),{tasks:t,viewer:s,composePrompt:o,emptyTitle:i,emptyDescription:a,truncated:l}=n,[c,d]=w.useState(vh),u=rl(!1);if(t.length===0){let C;return e[0]!==a||e[1]!==i?(C=r.jsx(il,{icon:ew,title:i,description:a}),e[0]=a,e[1]=i,e[2]=C):C=e[2],C}let f,m,p,h,g,x,b,y;if(e[3]!==o||e[4]!==c||e[5]!==u||e[6]!==t||e[7]!==s){const C=t.filter(g$),N=t$(C),_=[...new Set(C.flatMap(h$))],P=ue=>C.filter(de=>cb(de,ue,u)).length,A=P("overdue"),T=P("today"),E=P("week"),R=e$(t,c,u),I=n$(R.filter(p$),u),$=R.filter(Do).sort(m$);let M;e[16]===Symbol.for("react.memo_cache_sentinel")?(M=ue=>d(de=>({...de,...ue})),e[16]=M):M=e[16];const O=M;let D;e[17]!==c.due||e[18]!==c.priority||e[19]!==c.query||e[20]!==c.status?(D=c.status!==null||c.due!=="all"||c.priority!==null||c.query.trim()!=="",e[17]=c.due,e[18]=c.priority,e[19]=c.query,e[20]=c.status,e[21]=D):D=e[21];const L=D;let F;e[22]!==o||e[23]!==u||e[24]!==s?(F=ue=>r.jsx(u$,{task:ue,viewer:s,now:u,onPickStatus:de=>O({status:de}),composePrompt:o},ue.id),e[22]=o,e[23]=u,e[24]=s,e[25]=F):F=e[25];const z=F;let W;e[26]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(cn,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),e[26]=W):W=e[26];let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=ue=>O({query:ue.target.value}),e[27]=U):U=e[27];let H;e[28]!==c.query?(H=r.jsx(Lt,{type:"search",value:c.query,onChange:U,placeholder:"Search tasks","aria-label":"Search tasks",className:"h-7 border-0 bg-transparent px-0 text-xs shadow-none focus-visible:ring-0"}),e[28]=c.query,e[29]=H):H=e[29];let K;e[30]!==L?(K=L&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(vh),"aria-label":"Clear filters",children:[r.jsx(st,{"data-icon":"inline-start"}),"Clear"]}),e[30]=L,e[31]=K):K=e[31],e[32]!==H||e[33]!==K?(x=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-1.5",children:[W,H,K]}),e[32]=H,e[33]=K,e[34]=x):x=e[34];let q;e[35]===Symbol.for("react.memo_cache_sentinel")?(q=()=>O({due:"all"}),e[35]=q):q=e[35];const Y=c.due==="overdue",V=A===0;let J;e[36]===Symbol.for("react.memo_cache_sentinel")?(J=()=>O({due:"overdue"}),e[36]=J):J=e[36];const Q=A>0&&c.due!=="overdue"?"text-destructive":void 0;let X;e[37]!==A?(X=r.jsx(jt,{children:A}),e[37]=A,e[38]=X):X=e[38];let Z;e[39]!==Y||e[40]!==V||e[41]!==Q||e[42]!==X?(Z=r.jsxs(wt,{pressed:Y,disabled:V,onClick:J,className:Q,children:["Overdue",X]}),e[39]=Y,e[40]=V,e[41]=Q,e[42]=X,e[43]=Z):Z=e[43];const te=c.due==="today",ne=T===0;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>O({due:"today"}),e[44]=oe):oe=e[44];let re;e[45]!==T?(re=r.jsx(jt,{children:T}),e[45]=T,e[46]=re):re=e[46];let ae;e[47]!==te||e[48]!==ne||e[49]!==re?(ae=r.jsxs(wt,{pressed:te,disabled:ne,onClick:oe,children:["Today",re]}),e[47]=te,e[48]=ne,e[49]=re,e[50]=ae):ae=e[50];const se=c.due==="week",fe=E===0;let le;e[51]===Symbol.for("react.memo_cache_sentinel")?(le=()=>O({due:"week"}),e[51]=le):le=e[51];let ce;e[52]!==E?(ce=r.jsx(jt,{children:E}),e[52]=E,e[53]=ce):ce=e[53];let me;e[54]!==se||e[55]!==fe||e[56]!==ce?(me=r.jsxs(wt,{pressed:se,disabled:fe,onClick:le,children:["This week",ce]}),e[54]=se,e[55]=fe,e[56]=ce,e[57]=me):me=e[57],b=r.jsxs(Tr,{label:"Filter by due date and priority",children:[r.jsxs(wt,{pressed:c.due==="all",onClick:q,children:["All",r.jsx(jt,{children:C.length})]}),Z,ae,me,_.length>0&&r.jsx("span",{className:"mx-1 h-4 w-px shrink-0 bg-border","aria-hidden":!0}),_.map(ue=>r.jsxs(wt,{pressed:c.priority===ue,onClick:()=>O({priority:c.priority===ue?null:ue}),"aria-label":`Only ${ue} priority tasks`,children:[r.jsx(db,{priority:ue}),ue,r.jsx(jt,{children:C.filter(de=>de.priority===ue).length})]},ue))]}),y=N.length>1&&r.jsx(Tr,{label:"Filter by status",children:N.map(ue=>r.jsxs(wt,{pressed:c.status===ue.name,onClick:()=>O({status:c.status===ue.name?null:ue.name}),"aria-label":`Only tasks in ${ue.name}`,children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:ue.color}}),ue.name,r.jsx(jt,{children:C.filter(de=>de.status.name===ue.name).length})]},ue.name))}),f=Gn,g="min-h-0 flex-1",m="flex flex-col gap-4 px-3 py-3",p=I.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:L?"No tasks match these filters.":"Nothing open here."}):I.map(z),h=$.length>0&&r.jsx(Ru,{count:$.length,children:$.map(z)}),e[3]=o,e[4]=c,e[5]=u,e[6]=t,e[7]=s,e[8]=f,e[9]=m,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=b,e[15]=y}else f=e[8],m=e[9],p=e[10],h=e[11],g=e[12],x=e[13],b=e[14],y=e[15];let v;e[58]!==t.length||e[59]!==l?(v=l&&r.jsxs("p",{className:"px-1 text-center text-[11px] text-muted-foreground",children:["Showing the first ",t.length," tasks; narrow it down in ClickUp to see the rest."]}),e[58]=t.length,e[59]=l,e[60]=v):v=e[60];let S;e[61]!==m||e[62]!==p||e[63]!==h||e[64]!==v?(S=r.jsxs("div",{className:m,children:[p,h,v]}),e[61]=m,e[62]=p,e[63]=h,e[64]=v,e[65]=S):S=e[65];let j;e[66]!==f||e[67]!==g||e[68]!==S?(j=r.jsx(f,{className:g,children:S}),e[66]=f,e[67]=g,e[68]=S,e[69]=j):j=e[69];let k;return e[70]!==j||e[71]!==x||e[72]!==b||e[73]!==y?(k=r.jsxs(r.Fragment,{children:[x,b,y,j]}),e[70]=j,e[71]=x,e[72]=b,e[73]=y,e[74]=k):k=e[74],k}function m$(n,e){return(e.closedAt??e.updatedAt)-(n.closedAt??n.updatedAt)}function p$(n){return!Do(n)}function h$(n){return n.priority?[n.priority]:[]}function g$(n){return!Do(n)}function x$(n,e){return n?e===null?"Loading lists…":"Choose a list":"Choose a space first"}function b$({projectPath:n,onLinked:e}){const[t,s]=w.useState(""),[o,i]=w.useState(null),[a,l]=w.useState(""),[c,d]=w.useState(null),[u,f]=w.useState(""),[m,p]=w.useState(!1),[h,g]=w.useState(null);w.useEffect(()=>{let y=!1;return JR().then(v=>{y||i(v.spaces)}).catch(v=>{y||g(cr(v,"Unable to load spaces").error)}),()=>{y=!0}},[]),w.useEffect(()=>{if(!a)return;let y=!1;return d(null),f(""),QR(a).then(v=>{y||d(v.lists)}).catch(v=>{y||g(cr(v,"Unable to load lists").error)}),()=>{y=!0}},[a]);async function x(y){if(!y){g("Paste a ClickUp list URL such as https://app.clickup.com/…/v/li/901700000000");return}p(!0),g(null);try{await ab(n,y),e()}catch(v){g(cr(v,"Unable to link that list").error)}finally{p(!1)}}function b(y){y.preventDefault(),x(o$(t))}return r.jsxs("div",{className:"flex flex-col gap-4 p-4","aria-label":"Link a ClickUp list",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium",children:"Link this project to a ClickUp list"}),r.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Tasks from the linked list show up here, next to the code they belong to."})]}),r.jsxs("form",{className:"flex flex-col gap-2",onSubmit:b,children:[r.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",htmlFor:"clickup-list-url",children:"List URL or id"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Lt,{id:"clickup-list-url",value:t,onChange:y=>s(y.target.value),placeholder:"https://app.clickup.com/…/v/li/901700000000",className:"h-8 text-xs",autoComplete:"off",spellCheck:!1}),r.jsxs(ee,{type:"submit",size:"sm",disabled:m||!t.trim(),children:[m?r.jsx(ot,{}):r.jsx(nm,{"data-icon":"inline-start"}),"Link"]})]})]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"h-px flex-1 bg-border","aria-hidden":!0}),"or browse",r.jsx("span",{className:"h-px flex-1 bg-border","aria-hidden":!0})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs(Cc,{value:a,onValueChange:y=>l(y??""),children:[r.jsx(Tc,{className:"h-8 text-xs","aria-label":"Space",disabled:o===null,children:r.jsx(_c,{placeholder:o===null?"Loading spaces…":"Choose a space"})}),r.jsx(Ec,{children:o==null?void 0:o.map(y=>r.jsx(Pc,{value:y.id,children:y.name},y.id))})]}),r.jsxs(Cc,{value:u,onValueChange:y=>f(y??""),children:[r.jsx(Tc,{className:"h-8 text-xs","aria-label":"List",disabled:!a||c===null,children:r.jsx(_c,{placeholder:x$(a,c)})}),r.jsxs(Ec,{children:[c==null?void 0:c.map(y=>r.jsx(Pc,{value:y.id,children:Fu(y.folderName,y.name)},y.id)),(c==null?void 0:c.length)===0&&r.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:"This space has no lists."})]})]}),r.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:m||!u,onClick:()=>{x(u)},children:[m?r.jsx(ot,{}):r.jsx(nm,{"data-icon":"inline-start"}),"Link selected list"]})]}),h&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:h})]})}function v$({data:n,projectPath:e,composePrompt:t,onUnlinked:s}){const[o,i]=w.useState(!1),a=Fu(n.list.folderName,n.list.name);async function l(){i(!0);try{await ab(e,null),s()}finally{i(!1)}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 border-b px-3 text-[11px] text-muted-foreground",children:[r.jsx("a",{href:n.list.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate outline-none hover:text-foreground focus-visible:underline",title:a,children:a}),r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>{l()},disabled:o,"aria-label":"Unlink this project from ClickUp",children:[o?r.jsx(ot,{}):r.jsx(nw,{"data-icon":"inline-start"}),"Unlink"]})]}),r.jsx(ub,{tasks:n.tasks,viewer:n.viewer,composePrompt:t,emptyTitle:"No tasks in this list",emptyDescription:"Tasks added to the linked list will show up here.",truncated:n.truncated})]})}const y$="https://app.clickup.com/settings/apps";function w$(n){return n==="mine"||n==="project"}function j$(n){return n.code==="clickup_auth_failed"?"Generate a new personal token in ClickUp and add it again.":n.code==="clickup_rate_limited"?"ClickUp allows 100 requests a minute per token; the panel retries on its own.":"Check your ClickUp access, then try again."}function fb(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(S$),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsx("div",{className:"flex flex-col gap-5 px-3 py-4","aria-label":t,children:s}),e[1]=t,e[2]=o):o=e[2],o}function S$(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ut,{className:"h-3.5 w-3/4"}),r.jsx(ut,{className:"h-2.5 w-1/2"})]},n)}function jh(n){const e=B.c(23),{state:t,loadingLabel:s,onRetry:o,children:i}=n;if(t.data){let l;e[0]!==i||e[1]!==t.data?(l=i(t.data),e[0]=i,e[1]=t.data,e[2]=l):l=e[2];let c;return e[3]!==l?(c=r.jsx(r.Fragment,{children:l}),e[3]=l,e[4]=c):c=e[4],c}if(t.error){let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(qt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(Et,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=j$(t.error),e[8]=t.error,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{children:d}),e[10]=d,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(At,{"data-icon":"inline-start"}),e[12]=f):f=e[12];let m;e[13]!==o?(m=r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:o,children:[f,"Try again"]}),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=r.jsxs(ht,{className:"flex flex-col items-start gap-2",children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17];let h;return e[18]!==c||e[19]!==p?(h=r.jsx("div",{className:"p-3",children:r.jsxs(pt,{variant:"destructive",children:[l,c,p]})}),e[18]=c,e[19]=p,e[20]=h):h=e[20],h}let a;return e[21]!==s?(a=r.jsx(fb,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function N$({error:n}){const[e,t]=w.useState(""),[s,o]=w.useState(!1),[i,a]=w.useState(null);async function l(c){c.preventDefault(),o(!0),a(null);try{await YR(e.trim()),t("")}catch(d){a(cr(d,"Unable to save the token").error)}finally{o(!1)}}return r.jsxs("form",{className:"flex flex-col gap-4 p-4",onSubmit:c=>{l(c)},"aria-label":"Connect ClickUp",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-medium",children:"Connect ClickUp"}),r.jsxs("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:["Paste a personal API token. Cogpit keeps it on this machine, in ",r.jsx("code",{className:"font-mono",children:"~/.cogpit/clickup.json"}),", and never shows it again. A ",r.jsx("code",{className:"font-mono",children:"CLICKUP_API_TOKEN"})," in the server environment works too."]})]}),n&&n.code!=="clickup_not_configured"&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:n.error}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("label",{className:"text-[11px] font-medium text-muted-foreground",htmlFor:"clickup-token",children:"Personal API token"}),r.jsx(Lt,{id:"clickup-token",type:"password",value:e,onChange:c=>t(c.target.value),placeholder:"pk_…",className:"h-8 font-mono text-xs",autoComplete:"off",spellCheck:!1})]}),i&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(ee,{type:"submit",size:"sm",disabled:s||!e.trim(),children:[s?r.jsx(ot,{}):r.jsx(jd,{"data-icon":"inline-start"}),"Connect"]}),r.jsxs(ee,{variant:"outline",size:"sm",render:r.jsx("a",{href:y$,target:"_blank",rel:"noopener noreferrer"}),children:["Get a token",r.jsx(nn,{"data-icon":"inline-end"})]})]})]})}function Sh(n){const e=B.c(5),{value:t,attention:s}=n;if(t===null||t===0)return null;const o=s?"text-destructive":"text-muted-foreground";let i;e[0]!==o?(i=G("font-mono text-[10px] tabular-nums",o),e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==i||e[3]!==t?(a=r.jsx("span",{className:i,children:t}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}function k$(){var l;const n=B.c(5),e=sb(!0),{data:t}=ob(((l=e.data)==null?void 0:l.configured)===!0);let s;if(n[0]!==(t==null?void 0:t.tasks)){const c=Date.now();s=(t==null?void 0:t.tasks.filter(d=>Ao(d,c)).length)??0,n[0]=t==null?void 0:t.tasks,n[1]=s}else s=n[1];const o=s;if(o===0)return null;const i=`${o} overdue ClickUp task${o===1?"":"s"}`;let a;return n[2]!==o||n[3]!==i?(a=r.jsx(Ce,{variant:"destructive",className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":i,children:o}),n[2]=o,n[3]=i,n[4]=a):a=n[4],a}function C$(n){var I,$,M,O,D,L,F;const e=B.c(69),{context:t,active:s,closePanel:o}=n,[i,a]=w.useState("mine"),l=t.projectPath,c=sb(s),d=((I=c.data)==null?void 0:I.configured)===!0,u=ob(s&&d),f=GR(l,s&&d&&i==="project"),m=i==="mine"?u:f;let p;if(e[0]!==u.data){const z=Date.now();p=u.data?u.data.tasks.filter(W=>Ao(W,z)).length:null,e[0]=u.data,e[1]=p}else p=e[1];const h=p,g=u.data?u.data.tasks.length:null,x=(($=c.data)==null?void 0:$.workspace)??null;let b;if(c.data===null&&c.error===null){let z;e[2]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(fb,{label:"Checking ClickUp connection"}),e[2]=z):z=e[2],b=z}else if(d){const z=h||g,W=!!h;let U;e[5]!==z||e[6]!==W?(U=r.jsxs(Ln,{value:"mine",className:"h-full flex-none rounded-none px-0 text-xs",children:["My tasks",r.jsx(Sh,{value:z,attention:W})]}),e[5]=z,e[6]=W,e[7]=U):U=e[7];const H=!l;let K;e[8]!==f.data?(K=f.data?f.data.tasks.filter(T$).length:null,e[8]=f.data,e[9]=K):K=e[9];let q;e[10]!==K?(q=r.jsx(Sh,{value:K}),e[10]=K,e[11]=q):q=e[11];let Y;e[12]!==H||e[13]!==q?(Y=r.jsxs(Ln,{value:"project",className:"h-full flex-none rounded-none px-0 text-xs",disabled:H,children:["This project",q]}),e[12]=H,e[13]=q,e[14]=Y):Y=e[14];let V;e[15]!==U||e[16]!==Y?(V=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(za,{variant:"line",className:"h-full gap-3 p-0","aria-label":"ClickUp views",children:[U,Y]})}),e[15]=U,e[16]=Y,e[17]=V):V=e[17];let J;e[18]!==u?(J=()=>{u.refresh()},e[18]=u,e[19]=J):J=e[19];let Q;e[20]!==t.composePrompt?(Q=re=>r.jsx(ub,{tasks:re.tasks,viewer:re.viewer,composePrompt:t.composePrompt,emptyTitle:"Nothing assigned to you",emptyDescription:"Open tasks assigned to you anywhere in the workspace will show up here.",truncated:re.truncated}),e[20]=t.composePrompt,e[21]=Q):Q=e[21];let X;e[22]!==u||e[23]!==J||e[24]!==Q?(X=r.jsx(zn,{value:"mine",className:"flex min-h-0 flex-col",children:r.jsx(jh,{state:u,loadingLabel:"Loading your tasks",onRetry:J,children:Q})}),e[22]=u,e[23]=J,e[24]=Q,e[25]=X):X=e[25];let Z;e[26]!==t.composePrompt||e[27]!==f||e[28]!==l?(Z=l&&(((M=f.error)==null?void 0:M.code)==="project_unlinked"?r.jsx(b$,{projectPath:l,onLinked:()=>{f.refresh()}}):r.jsx(jh,{state:f,loadingLabel:"Loading the linked list",onRetry:()=>{f.refresh()},children:re=>r.jsx(v$,{data:re,projectPath:l,composePrompt:t.composePrompt,onUnlinked:()=>{f.refresh()}})})),e[26]=t.composePrompt,e[27]=f,e[28]=l,e[29]=Z):Z=e[29];let te;e[30]!==Z?(te=r.jsx(zn,{value:"project",className:"flex min-h-0 flex-col",children:Z}),e[30]=Z,e[31]=te):te=e[31];let ne;e[32]!==X||e[33]!==te?(ne=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[X,te]}),e[32]=X,e[33]=te,e[34]=ne):ne=e[34];let oe;e[35]!==ne||e[36]!==V?(oe=r.jsxs(r.Fragment,{children:[V,ne]}),e[35]=ne,e[36]=V,e[37]=oe):oe=e[37],b=oe}else{let z;e[3]!==c.error?(z=r.jsx(N$,{error:c.error}),e[3]=c.error,e[4]=z):z=e[4],b=z}let y;e[38]===Symbol.for("react.memo_cache_sentinel")?(y=z=>{w$(z)&&a(z)},e[38]=y):y=e[38];let v;e[39]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"ClickUp"}),e[39]=v):v=e[39];let S;e[40]!==c.data||e[41]!==x?(S=r.jsxs("div",{className:"min-w-0 flex-1",children:[v,x?r.jsxs("a",{href:`https://app.clickup.com/${x.id}/home`,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.jsxs("span",{className:"truncate",children:[x.name,(O=c.data)!=null&&O.viewer?` · ${c.data.viewer.username}`:""]}),r.jsx(nn,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Not connected"})]}),e[40]=c.data,e[41]=x,e[42]=S):S=e[42];let j;e[43]!==d||e[44]!==((D=c.data)==null?void 0:D.tokenFromEnv)?(j=d&&!((L=c.data)!=null&&L.tokenFromEnv)&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:_$,"aria-label":"Disconnect ClickUp",title:"Disconnect ClickUp",children:r.jsx(jd,{})}),e[43]=d,e[44]=(F=c.data)==null?void 0:F.tokenFromEnv,e[45]=j):j=e[45];let k;e[46]!==d||e[47]!==m||e[48]!==c?(k=()=>{d?m.refresh():c.refresh()},e[46]=d,e[47]=m,e[48]=c,e[49]=k):k=e[49];const C=m.loading||m.refreshing||c.loading,N=i==="mine"?"Refresh my tasks":"Refresh project tasks";let _;e[50]!==m.refreshing?(_=m.refreshing?r.jsx(ot,{}):r.jsx(At,{}),e[50]=m.refreshing,e[51]=_):_=e[51];let P;e[52]!==k||e[53]!==C||e[54]!==N||e[55]!==_?(P=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:k,disabled:C,"aria-label":N,children:_}),e[52]=k,e[53]=C,e[54]=N,e[55]=_,e[56]=P):P=e[56];let A;e[57]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(st,{}),e[57]=A):A=e[57];let T;e[58]!==o?(T=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close ClickUp",children:A}),e[58]=o,e[59]=T):T=e[59];let E;e[60]!==P||e[61]!==T||e[62]!==S||e[63]!==j?(E=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[S,j,P,T]}),e[60]=P,e[61]=T,e[62]=S,e[63]=j,e[64]=E):E=e[64];let R;return e[65]!==b||e[66]!==E||e[67]!==i?(R=r.jsxs(La,{value:i,onValueChange:y,className:"size-full min-h-0 gap-0","aria-label":"ClickUp panel",children:[E,b]}),e[65]=b,e[66]=E,e[67]=i,e[68]=R):R=e[68],R}function _$(){XR()}function T$(n){return!Do(n)}const E$={id:"clickup",workspacePanels:[{id:"tasks",title:"ClickUp",icon:sw,component:C$,indicator:k$,order:42,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles}]},Bu={data:null,error:null,loading:!1,refreshing:!1},P$=8e3,A$=1500,R$=10,$$=new Set(["gh_missing","gh_auth_required","no_git_repository","no_github_remote"]),I$={endpoint:n=>`/api/github/actions?cwd=${encodeURIComponent(n)}&limit=20`,pollIntervalMs:1e4,fallbackError:"Unable to load GitHub Actions",stores:new Map},M$={endpoint:n=>`/api/github/pulls?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:3e4,fallbackError:"Unable to load pull requests",stores:new Map},O$={endpoint:n=>`/api/github/issues?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:6e4,fallbackError:"Unable to load issues",stores:new Map},D$={endpoint:n=>`/api/github/pulls/sessions?cwd=${encodeURIComponent(n)}`,pollIntervalMs:3e4,fallbackError:"Unable to match sessions to pull requests",stores:new Map,settling:n=>n.pending>0};function Zc(n,e){let t=n.stores.get(e);return t||(t={snapshot:Bu,listeners:new Set,request:null,fetchedAt:0,settleTimer:null,settleAttempts:0},n.stores.set(e,t)),t}function rc(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function mb(n){try{const e=await n.json();if(typeof e.error=="string"&&typeof e.code=="string")return e}catch{}return{error:`GitHub request failed (${n.status})`,code:"github_api_failed"}}function pb(n,e){const t=n;return{error:typeof t.error=="string"?t.error:e,code:typeof t.code=="string"?t.code:"github_api_failed"}}async function Wi(n,e,t=!1){const s=Zc(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&$$.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<P$))return(t||s.snapshot.data===null)&&rc(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=ve(n.endpoint(e)).then(async o=>{var a;if(!o.ok)throw await mb(o);const i=await o.json();s.fetchedAt=Date.now(),rc(s,{data:i,error:null,loading:!1,refreshing:!1}),(a=n.settling)!=null&&a.call(n,i)&&s.settleAttempts<R$?(s.settleAttempts+=1,s.settleTimer=window.setTimeout(()=>{s.settleTimer=null,Wi(n,e,!0)},A$)):s.settleAttempts=0}).catch(o=>{rc(s,{...s.snapshot,error:pb(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function cl(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==o||s[1]!==n?(i=p=>{if(!o)return z$;const h=Zc(n,o);return h.listeners.add(p),()=>h.listeners.delete(p)},s[0]=o,s[1]=n,s[2]=i):i=s[2];let a;s[3]!==o||s[4]!==n?(a=()=>o?Zc(n,o).snapshot:Bu,s[3]=o,s[4]=n,s[5]=a):a=s[5];const l=w.useSyncExternalStore(i,a,L$);let c,d;s[6]!==t||s[7]!==o||s[8]!==n?(c=()=>{if(!t||!o)return;Wi(n,o);const p=window.setInterval(()=>{Wi(n,o)},n.pollIntervalMs);return()=>window.clearInterval(p)},d=[n,t,o],s[6]=t,s[7]=o,s[8]=n,s[9]=c,s[10]=d):(c=s[9],d=s[10]),w.useEffect(c,d);let u;s[11]!==o||s[12]!==n?(u=()=>o?Wi(n,o,!0):Promise.resolve(),s[11]=o,s[12]=n,s[13]=u):u=s[13];const f=u;let m;return s[14]!==f||s[15]!==l?(m={...l,refresh:f},s[14]=f,s[15]=l,s[16]=m):m=s[16],m}function L$(){return Bu}function z$(){}function hb(n,e){return cl(I$,n,e)}function gb(n,e){return cl(M$,n,e)}function F$(n,e){return cl(O$,n,e)}function B$(n,e){return cl(D$,n,e)}async function xb(n){const e=await ve(n);if(!e.ok)throw await mb(e);return e.json()}function U$(n,e){return xb(`/api/github/actions/jobs?cwd=${encodeURIComponent(n)}&runId=${e}`)}function W$(n,e){return xb(`/api/github/pulls/files?cwd=${encodeURIComponent(n)}&number=${e}`)}const H$={data:null,error:null,loading:!1};function bb(n,e,t){const s=B.c(12),o=t===void 0?!1:t,[i,a]=w.useState(!1),[l,c]=w.useState(H$);let d;s[0]!==e||s[1]!==n||s[2]!==l?(d=async function(){if(!l.loading){c(K$);try{c({data:await n(),error:null,loading:!1})}catch(g){c({data:null,error:pb(g,e),loading:!1})}}},s[0]=e,s[1]=n,s[2]=l,s[3]=d):d=s[3];const u=d;let f;s[4]!==u||s[5]!==o||s[6]!==l?(f=function(g){a(g),g&&(!l.data||o)&&u()},s[4]=u,s[5]=o,s[6]=l,s[7]=f):f=s[7];const m=f;let p;return s[8]!==m||s[9]!==i||s[10]!==l?(p={open:i,state:l,onOpenChange:m},s[8]=m,s[9]=i,s[10]=l,s[11]=p):p=s[11],p}function K$(n){return{...n,error:null,loading:!0}}function si(n){return n!=="completed"}function Lo(n){return n==="action_required"||n==="failure"||n==="startup_failure"||n==="timed_out"}function Uu(n,e){return si(n)?"live":Lo(e)?"fail":e==="success"?"pass":"quiet"}const Nh={live:0,fail:1,quiet:2,pass:3};function q$(n){return n.reduce((e,t)=>Nh[t]<Nh[e]?t:e,"pass")}const V$={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success",quiet:"bg-border"};function Wu(n,e){return n==="in_progress"?"Running":si(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 Hu(n){const e=B.c(14),{status:t,conclusion:s,className:o}=n;let i;e[0]!==s||e[1]!==t?(i=Wu(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 f=G("size-3.5 shrink-0",o);if(t==="in_progress"){d=r.jsx(ot,{className:G(f,"text-info"),"aria-label":a});break e}if(si(t)){d=r.jsx($o,{className:G(f,"text-info"),"aria-label":a});break e}if(s==="success"){d=r.jsx(gt,{className:G(f,"text-success"),"aria-label":a});break e}if(Lo(s)){d=r.jsx(st,{className:G(f,"text-destructive"),"aria-label":a});break e}if(s==="skipped"||s==="cancelled"){d=r.jsx(ow,{className:G(f,"text-muted-foreground"),"aria-label":a});break e}l=vd,c=G(f,"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 u;return e[10]!==l||e[11]!==a||e[12]!==c?(u=r.jsx(l,{className:c,"aria-label":a}),e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13],u}function G$(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 f=Lo(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(Hu,{status:t.status,conclusion:t.conclusion,className:"size-3"}),i=G("min-w-0 flex-1 truncate",f&&"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:Au(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 u;return e[14]!==a||e[15]!==l||e[16]!==c||e[17]!==d?(u=r.jsxs("li",{className:a,children:[l,c,d]}),e[14]=a,e[15]=l,e[16]=c,e[17]=d,e[18]=u):u=e[18],u}function Y$(n){const e=B.c(39),{job:t,now:s}=n;let o;e[0]!==t.conclusion||e[1]!==t.status?(o=Uu(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=o):o=e[2];const i=o,[a,l]=w.useState(i==="fail"||i==="live");let c;e[3]!==t.completedAt||e[4]!==t.startedAt||e[5]!==s?(c=Au(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,u=t.name;let f;e[7]!==t.conclusion||e[8]!==t.status?(f=Wu(t.status,t.conclusion),e[7]=t.conclusion,e[8]=t.status,e[9]=f):f=e[9];const m=`${u}: ${f}`,p=a&&"rotate-90";let h;e[10]!==p?(h=G("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(Hu,{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 y;e[17]!==b?(y=G("min-w-0 flex-1 truncate",b),e[17]=b,e[18]=y):y=e[18];let v;e[19]!==t.name||e[20]!==y?(v=r.jsx("span",{className:y,children:t.name}),e[19]=t.name,e[20]=y,e[21]=v):v=e[21];let S;e[22]!==d?(S=d&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:d}),e[22]=d,e[23]=S):S=e[23];let j;e[24]!==v||e[25]!==S||e[26]!==m||e[27]!==g||e[28]!==x?(j=r.jsxs($t,{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,S]}),e[24]=v,e[25]=S,e[26]=m,e[27]=g,e[28]=x,e[29]=j):j=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(G$,{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(at,{children:k}),e[33]=k,e[34]=C):C=e[34];let N;return e[35]!==a||e[36]!==j||e[37]!==C?(N=r.jsxs(it,{open:a,onOpenChange:l,children:[j,C]}),e[35]=a,e[36]=j,e[37]=C,e[38]=N):N=e[38],N}function X$(n){var H,K,q;const e=B.c(73),{run:t,projectPath:s,now:o}=n;let i;e[0]!==t.conclusion||e[1]!==t.status?(i=Uu(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=i):i=e[2];const a=i,l=a==="live";let c;e[3]!==s||e[4]!==t.id?(c=()=>U$(s,t.id),e[3]=s,e[4]=t.id,e[5]=c):c=e[5];const{open:d,state:u,onOpenChange:f}=bb(c,"Unable to load workflow jobs",l);let m;e[6]!==((H=u.data)==null?void 0:H.jobs)?(m=((K=u.data)==null?void 0:K.jobs)??[],e[6]=(q=u.data)==null?void 0:q.jobs,e[7]=m):m=e[7];const p=m,h=l?null:t.updatedAt;let g;e[8]!==o||e[9]!==t.createdAt||e[10]!==h?(g=Au(t.createdAt,h,o),e[8]=o,e[9]=t.createdAt,e[10]=h,e[11]=g):g=e[11];const x=g,b=t.name,y=t.runNumber;let v;e[12]!==t.conclusion||e[13]!==t.status?(v=Wu(t.status,t.conclusion),e[12]=t.conclusion,e[13]=t.status,e[14]=v):v=e[14];const S=`${b} #${y}: ${v}`;let j;e[15]!==t.conclusion||e[16]!==t.status?(j=r.jsx(Hu,{status:t.status,conclusion:t.conclusion}),e[15]=t.conclusion,e[16]=t.status,e[17]=j):j=e[17];const k=a==="quiet"&&"text-muted-foreground";let C;e[18]!==k?(C=G("min-w-0 truncate",k),e[18]=k,e[19]=C):C=e[19];let N;e[20]!==t.name||e[21]!==C?(N=r.jsx("span",{className:C,children:t.name}),e[20]=t.name,e[21]=C,e[22]=N):N=e[22];let _;e[23]!==t.runNumber?(_=r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",t.runNumber]}),e[23]=t.runNumber,e[24]=_):_=e[24];let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("span",{className:"min-w-0 flex-1"}),e[25]=P):P=e[25];let A;e[26]!==t.branch?(A=r.jsx("span",{className:"max-w-24 truncate font-mono text-[10px] text-muted-foreground",children:t.branch}),e[26]=t.branch,e[27]=A):A=e[27];let T;e[28]!==l||e[29]!==x?(T=x&&r.jsx("span",{className:G("w-14 shrink-0 text-right font-mono text-[10px] tabular-nums",l?"text-info":"text-muted-foreground"),children:x}),e[28]=l,e[29]=x,e[30]=T):T=e[30];let E;e[31]!==d||e[32]!==j||e[33]!==N||e[34]!==_||e[35]!==A||e[36]!==T||e[37]!==S?(E=r.jsxs($t,{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":S,"aria-expanded":d,children:[j,N,_,P,A,T]}),e[31]=d,e[32]=j,e[33]=N,e[34]=_,e[35]=A,e[36]=T,e[37]=S,e[38]=E):E=e[38];const R=`Open ${t.name} #${t.runNumber} on GitHub`;let I;e[39]!==t.url?(I=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[39]=t.url,e[40]=I):I=e[40];let $;e[41]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(nn,{}),e[41]=$):$=e[41];let M;e[42]!==R||e[43]!==I?(M=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":R,onClick:I,children:$}),e[42]=R,e[43]=I,e[44]=M):M=e[44];let O;e[45]!==E||e[46]!==M?(O=r.jsxs("div",{className:"group/run flex items-center gap-1 pr-1",children:[E,M]}),e[45]=E,e[46]=M,e[47]=O):O=e[47];let D;e[48]!==u.data||e[49]!==u.loading?(D=u.loading&&!u.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(ot,{className:"size-3"}),"Loading jobs"]}),e[48]=u.data,e[49]=u.loading,e[50]=D):D=e[50];let L;e[51]!==u.error?(L=u.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:u.error.error}),e[51]=u.error,e[52]=L):L=e[52];let F;e[53]!==p.length||e[54]!==u.data||e[55]!==u.error||e[56]!==u.loading?(F=!u.loading&&!u.error&&u.data&&p.length===0&&r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"GitHub reported no jobs for this run."}),e[53]=p.length,e[54]=u.data,e[55]=u.error,e[56]=u.loading,e[57]=F):F=e[57];let z;if(e[58]!==p||e[59]!==o){let Y;e[61]!==o?(Y=V=>r.jsx(Y$,{job:V,now:o},V.id),e[61]=o,e[62]=Y):Y=e[62],z=p.map(Y),e[58]=p,e[59]=o,e[60]=z}else z=e[60];let W;e[63]!==D||e[64]!==L||e[65]!==F||e[66]!==z?(W=r.jsx(at,{children:r.jsxs("div",{className:"ml-[7px] border-l border-border py-1 pl-3 pr-1",children:[D,L,F,z]})}),e[63]=D,e[64]=L,e[65]=F,e[66]=z,e[67]=W):W=e[67];let U;return e[68]!==f||e[69]!==d||e[70]!==O||e[71]!==W?(U=r.jsxs(it,{open:d,onOpenChange:f,children:[O,W]}),e[68]=f,e[69]=d,e[70]=O,e[71]=W,e[72]=U):U=e[72],U}function J$(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=q$(s.runs.map(o=>Uu(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 Q$(n){const e=B.c(41),{group:t,projectPath:s,now:o}=n,i=t.title,a=V$[t.tone];let l;e[0]!==a?(l=G("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 u;e[6]!==t.sha?(u=t.sha&&r.jsx("span",{className:"font-mono",children:t.sha.slice(0,7)}),e[6]=t.sha,e[7]=u):u=e[7];let f;e[8]!==t.actor?(f=t.actor&&r.jsx("span",{className:"truncate",children:t.actor}),e[8]=t.actor,e[9]=f):f=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=ol(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]!==u||e[22]!==f?(b=r.jsxs("p",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[u,f,m,x]}),e[20]=x,e[21]=u,e[22]=f,e[23]=b):b=e[23];let y;e[24]!==b||e[25]!==d?(y=r.jsxs("header",{className:"mb-1 min-w-0",children:[d,b]}),e[24]=b,e[25]=d,e[26]=y):y=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(X$,{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 S;e[34]!==v?(S=r.jsx("div",{className:"-ml-1 flex flex-col",children:v}),e[34]=v,e[35]=S):S=e[35];let j;return e[36]!==t.title||e[37]!==y||e[38]!==S||e[39]!==c?(j=r.jsxs("article",{className:"relative pl-3","aria-label":i,children:[c,y,S]}),e[36]=t.title,e[37]=y,e[38]=S,e[39]=c,e[40]=j):j=e[40],j}function Z$(n,e){return e==="failed"?n.filter(t=>Lo(t.conclusion)):e==="all"?[...n]:n.filter(t=>t.branch===e.branch)}function eI(n,e){return n==="failed"?"Nothing failed in the latest runs.":n==="all"?`No recent runs on ${e}.`:`No recent runs on ${n.branch}.`}function tI(n){const e=B.c(22),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.runs||e[1]!==s?(i=Z$(t.runs,s),e[0]=t.runs,e[1]=s,e[2]=i):i=e[2];const a=i;let l;e[3]!==a?(l=J$(a),e[3]=a,e[4]=l):l=e[4];const c=l;let d;e[5]!==c?(d=c.some(nI),e[5]=c,e[6]=d):d=e[6];const u=rl(d);if(t.runs.length===0){let p;return e[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(il,{icon:Nd,title:"No workflow runs yet",description:"Push a commit that triggers a workflow and it will show up here."}),e[7]=p):p=e[7],p}if(c.length===0){let p;e[8]!==t.branch||e[9]!==s?(p=eI(s,t.branch),e[8]=t.branch,e[9]=s,e[10]=p):p=e[10];let h;return e[11]!==p?(h=r.jsx("p",{className:"px-4 py-6 text-center text-xs text-muted-foreground",children:p}),e[11]=p,e[12]=h):h=e[12],h}let f;if(e[13]!==c||e[14]!==u||e[15]!==o){let p;e[17]!==u||e[18]!==o?(p=h=>r.jsx(Q$,{group:h,projectPath:o,now:u},h.sha||h.runs[0].id),e[17]=u,e[18]=o,e[19]=p):p=e[19],f=c.map(p),e[13]=c,e[14]=u,e[15]=o,e[16]=f}else f=e[16];let m;return e[20]!==f?(m=r.jsx(Gn,{className:"min-h-0 flex-1",children:r.jsx("div",{className:"flex flex-col gap-5 px-3 py-3",children:f})}),e[20]=f,e[21]=m):m=e[21],m}function nI(n){return n.tone==="live"}function sI(n){const e=B.c(23),{data:t,projectPath:s,focus:o}=n,[i,a]=w.useState("all");let l,c;e[0]!==o?(l=()=>{o&&a({branch:o.branch})},c=[o],e[0]=o,e[1]=l,e[2]=c):(l=e[1],c=e[2]),w.useEffect(l,c);const d=t.runs;let u;e[3]!==d?(u=d.filter(oI),e[3]=d,e[4]=u):u=e[4];const f=u.length,m=t.branch;let p;e[5]!==m||e[6]!==d?(p=m?d.filter(j=>j.branch===m).length:0,e[5]=m,e[6]=d,e[7]=p):p=e[7];const h=p,g=typeof i=="object"&&i.branch!==m?i.branch:null,x=typeof i=="object"&&!g,b=x&&!m||i==="failed"&&f===0?"all":i;let y;e[8]!==m||e[9]!==h||e[10]!==x||e[11]!==b||e[12]!==f||e[13]!==g||e[14]!==d?(y=d.length>0&&r.jsxs(Tr,{label:"Filter runs",children:[r.jsxs(wt,{pressed:b==="all",onClick:()=>a("all"),children:["All",r.jsx(jt,{children:d.length})]}),m&&r.jsxs(wt,{pressed:x&&b!=="all",disabled:h===0,onClick:()=>a({branch:m}),"aria-label":`Only runs on ${m}`,children:[r.jsx(Fn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:m}),r.jsx(jt,{children:h})]}),g&&r.jsxs(wt,{pressed:!0,onClick:()=>a("all"),"aria-label":`Only runs on ${g}`,children:[r.jsx(Fn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:g}),r.jsx(jt,{children:d.filter(j=>j.branch===g).length}),r.jsx(st,{className:"size-3","aria-hidden":!0})]}),r.jsxs(wt,{pressed:b==="failed",disabled:f===0,onClick:()=>a("failed"),children:[r.jsx("span",{className:G(f>0&&"text-destructive"),children:"Failed"})," ",r.jsx(jt,{children:f})]})]}),e[8]=m,e[9]=h,e[10]=x,e[11]=b,e[12]=f,e[13]=g,e[14]=d,e[15]=y):y=e[15];let v;e[16]!==t||e[17]!==b||e[18]!==s?(v=r.jsx(tI,{data:t,filter:b,projectPath:s}),e[16]=t,e[17]=b,e[18]=s,e[19]=v):v=e[19];let S;return e[20]!==y||e[21]!==v?(S=r.jsxs(r.Fragment,{children:[y,v]}),e[20]=y,e[21]=v,e[22]=S):S=e[22],S}function oI(n){return Lo(n.conclusion)}const vb={open:"Open",completed:"Completed",not_planned:"Not planned"},rI={open:"bg-success",completed:"bg-info",not_planned:"bg-border"};function iI(n){const e=B.c(9),{state:t}=n,s=vb[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-success"),e[0]=a):a=e[0];let l;return e[1]!==s?(l=r.jsx(R1,{className:a,"aria-label":s}),e[1]=s,e[2]=l):l=e[2],l}if(t==="completed"){let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-info"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(Wn,{className:a,"aria-label":s}),e[4]=s,e[5]=l):l=e[5],l}let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=G("size-3.5 shrink-0","text-muted-foreground"),e[6]=o):o=e[6];let i;return e[7]!==s?(i=r.jsx(iw,{className:o,"aria-label":s}),e[7]=s,e[8]=i):i=e[8],i}function yb(n){const e=B.c(2),{label:t}=n,s=`#${t.color}`;let o;return e[0]!==s?(o=r.jsx("span",{"aria-hidden":!0,className:"inline-block size-2 shrink-0 rounded-full",style:{backgroundColor:s}}),e[0]=s,e[1]=o):o=e[1],o}function aI(n){const e=n.body.trim();return[`Work on GitHub issue #${n.number}: ${n.title}`,n.url,...e?["",e]:[]].join(`
127
+ `)}function lI(n){const e=B.c(7),{issue:t,viewer:s}=n;if(s!==null&&t.assignees.includes(s)){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx($1,{className:"size-3 text-info","aria-label":"Assigned to you",role:"img"}),e[0]=d):d=e[0],d}if(t.assignees.length===0)return null;let o;e[1]!==t.assignees?(o=t.assignees.join(", "),e[1]=t.assignees,e[2]=o):o=e[2];const i=`Assigned to ${o}`;let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(kd,{className:"size-3","aria-hidden":!0}),e[3]=a):a=e[3];const l=t.assignees.length>1&&t.assignees.length;let c;return e[4]!==i||e[5]!==l?(c=r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground","aria-label":i,title:i,children:[a,l]}),e[4]=i,e[5]=l,e[6]=c):c=e[6],c}function cI(n){const e=B.c(5),{state:t}=n;if(t==="merged"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(I1,{className:"size-3 text-info","aria-hidden":!0}),e[0]=a):a=e[0],a}const s=t==="closed"?"text-destructive":"text-success";let o;e[1]!==s?(o=G("size-3",s),e[1]=s,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsx(Mr,{className:o,"aria-hidden":!0}),e[3]=o,e[4]=i):i=e[4],i}function dI(n){const e=B.c(12),{issue:t,viewer:s,onShowPull:o}=n,i=t.linkedPulls[0];let a;e[0]!==t||e[1]!==s?(a=r.jsx(lI,{issue:t,viewer:s}),e[0]=t,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==o||e[4]!==i?(l=i&&r.jsxs("button",{type:"button",className:"flex items-center gap-0.5 rounded-sm font-mono text-[10px] text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":`Pull request #${i.number} (${i.state}), show pull requests`,title:`Pull request #${i.number} · ${i.state}`,onClick:o,children:[r.jsx(cI,{state:i.state}),"#",i.number]}),e[3]=o,e[4]=i,e[5]=l):l=e[5];let c;e[6]!==t.comments?(c=r.jsx(B2,{count:t.comments}),e[6]=t.comments,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d=r.jsxs("span",{className:"flex h-5 shrink-0 items-center gap-1.5",children:[a,l,c]}),e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function uI(n){const e=B.c(86),{issue:t,viewer:s,now:o,onPickLabel:i,onShowPull:a,composePrompt:l}=n,[c,d]=w.useState(!1),u=t.state==="open"?t.updatedAt:t.closedAt??t.updatedAt;let f;e[0]!==t.body?(f=t.body.trim(),e[0]=t.body,e[1]=f):f=e[1];const m=f,p=t.title,h=rI[t.state];let g;e[2]!==h?(g=G("absolute inset-y-1 left-0 w-0.5 rounded-full",h),e[2]=h,e[3]=g):g=e[3];let x;e[4]!==g?(x=r.jsx("span",{"aria-hidden":!0,className:g}),e[4]=g,e[5]=x):x=e[5];const b=`${t.title} #${t.number}: ${vb[t.state]}`;let y;e[6]!==t.state?(y=r.jsx(iI,{state:t.state}),e[6]=t.state,e[7]=y):y=e[7];const v=t.state!=="open"&&"text-muted-foreground";let S;e[8]!==v?(S=G("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",v),e[8]=v,e[9]=S):S=e[9];let j;e[10]!==t.title||e[11]!==S?(j=r.jsx("span",{className:S,children:t.title}),e[10]=t.title,e[11]=S,e[12]=j):j=e[12];let k;e[13]!==t.number?(k=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[13]=t.number,e[14]=k):k=e[14];let C;e[15]!==j||e[16]!==k||e[17]!==y?(C=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[y,j,k]}),e[15]=j,e[16]=k,e[17]=y,e[18]=C):C=e[18];let N;e[19]!==t.author?(N=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[19]=t.author,e[20]=N):N=e[20];let _;e[21]!==t.labels?(_=t.labels.length>0&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate",children:[t.labels.slice(0,3).map(fI),t.labels.length>3&&r.jsxs("span",{children:["+",t.labels.length-3]})]}),e[21]=t.labels,e[22]=_):_=e[22];let P;e[23]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("span",{className:"shrink-0",children:"·"}),e[23]=P):P=e[23];let A;e[24]!==u?(A=new Date(u).toLocaleString(),e[24]=u,e[25]=A):A=e[25];let T;e[26]!==u||e[27]!==o?(T=ol(u,o),e[26]=u,e[27]=o,e[28]=T):T=e[28];let E;e[29]!==u||e[30]!==A||e[31]!==T?(E=r.jsx("time",{className:"shrink-0",dateTime:u,title:A,children:T}),e[29]=u,e[30]=A,e[31]=T,e[32]=E):E=e[32];let R;e[33]!==N||e[34]!==_||e[35]!==E?(R=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[N,_,P,E]}),e[33]=N,e[34]=_,e[35]=E,e[36]=R):R=e[36];let I;e[37]!==c||e[38]!==C||e[39]!==R||e[40]!==b?(I=r.jsxs($t,{className:"flex min-w-0 flex-1 flex-col 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":b,"aria-expanded":c,children:[C,R]}),e[37]=c,e[38]=C,e[39]=R,e[40]=b,e[41]=I):I=e[41];let $;e[42]!==t||e[43]!==a||e[44]!==s?($=r.jsx(dI,{issue:t,viewer:s,onShowPull:a}),e[42]=t,e[43]=a,e[44]=s,e[45]=$):$=e[45];const M=`Open #${t.number} on GitHub`;let O;e[46]!==t.url?(O=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[46]=t.url,e[47]=O):O=e[47];let D;e[48]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(nn,{}),e[48]=D):D=e[48];let L;e[49]!==M||e[50]!==O?(L=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/issue:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":M,onClick:O,children:D}),e[49]=M,e[50]=O,e[51]=L):L=e[51];let F;e[52]!==$||e[53]!==L?(F=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[$,L]}),e[52]=$,e[53]=L,e[54]=F):F=e[54];let z;e[55]!==I||e[56]!==F?(z=r.jsxs("div",{className:"group/issue flex items-start gap-1 pr-1",children:[I,F]}),e[55]=I,e[56]=F,e[57]=z):z=e[57];let W;e[58]!==m?(W=m?r.jsx($u,{body:m}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[58]=m,e[59]=W):W=e[59];let U;e[60]!==t.labels||e[61]!==i?(U=t.labels.length>0&&r.jsx("ul",{className:"flex flex-wrap gap-1","aria-label":"Labels",children:t.labels.map(Z=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20",onClick:()=>i(Z.name),"aria-label":`Only issues labeled ${Z.name}`,children:[r.jsx(yb,{label:Z}),Z.name]})},Z.name))}),e[60]=t.labels,e[61]=i,e[62]=U):U=e[62];let H;e[63]!==l||e[64]!==t?(H=l&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>l(aI(t)),children:[r.jsx(A1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[63]=l,e[64]=t,e[65]=H):H=e[65];let K;e[66]!==t.url?(K=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[66]=t.url,e[67]=K):K=e[67];let q;e[68]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(nn,{"data-icon":"inline-end"}),e[68]=q):q=e[68];let Y;e[69]!==K?(Y=r.jsxs(ee,{variant:"outline",size:"xs",render:K,children:["Open issue on GitHub",q]}),e[69]=K,e[70]=Y):Y=e[70];let V;e[71]!==H||e[72]!==Y?(V=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[H,Y]}),e[71]=H,e[72]=Y,e[73]=V):V=e[73];let J;e[74]!==W||e[75]!==U||e[76]!==V?(J=r.jsx(at,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[W,U,V]})}),e[74]=W,e[75]=U,e[76]=V,e[77]=J):J=e[77];let Q;e[78]!==c||e[79]!==z||e[80]!==J?(Q=r.jsxs(it,{open:c,onOpenChange:d,children:[z,J]}),e[78]=c,e[79]=z,e[80]=J,e[81]=Q):Q=e[81];let X;return e[82]!==t.title||e[83]!==Q||e[84]!==x?(X=r.jsxs("article",{className:"relative pl-3","aria-label":p,children:[x,Q]}),e[82]=t.title,e[83]=Q,e[84]=x,e[85]=X):X=e[85],X}function fI(n){return r.jsxs("span",{className:"flex items-center gap-1 truncate",children:[r.jsx(yb,{label:n}),r.jsx("span",{className:"truncate",children:n.name})]},n.name)}function kh(n,e,t){return e==="assigned"?t!==null&&n.assignees.includes(t):e==="opened"?t!==null&&n.author===t:e==="unassigned"?n.assignees.length===0:!0}function mI(n){const e=B.c(75),{data:t,composePrompt:s,onShowPulls:o}=n,[i,a]=w.useState("all"),[l,c]=w.useState(null),d=rl(!1),u=t.viewer;let f;e[0]!==t.issues||e[1]!==u?(f=I=>t.issues.filter($=>kh($,I,u)).length,e[0]=t.issues,e[1]=u,e[2]=f):f=e[2];const m=f;let p;e[3]!==m?(p=m("assigned"),e[3]=m,e[4]=p):p=e[4];const h=p;let g;e[5]!==m?(g=m("opened"),e[5]=m,e[6]=g):g=e[6];const x=g;let b;e[7]!==m?(b=m("unassigned"),e[7]=m,e[8]=b):b=e[8];const y=b,v=i==="assigned"&&h===0||i==="opened"&&x===0||i==="unassigned"&&y===0?"all":i,S=t.issues;let j,k,C,N,_,P,A;if(e[9]!==h||e[10]!==s||e[11]!==t.issues||e[12]!==v||e[13]!==l||e[14]!==d||e[15]!==o||e[16]!==x||e[17]!==y||e[18]!==u){C=Symbol.for("react.early_return_sentinel");e:{let I;e[26]!==v||e[27]!==l||e[28]!==u?(I=te=>kh(te,v,u)&&(l===null||te.labels.some(ne=>ne.name===l)),e[26]=v,e[27]=l,e[28]=u,e[29]=I):I=e[29];const $=S.filter(I),M=$.filter(hI),O=$.filter(pI);if(t.issues.length===0){let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx(il,{icon:R1,title:"No issues yet",description:"Issues opened on this repository will show up here."}),e[30]=te):te=e[30],C=te;break e}let D;e[31]!==s||e[32]!==d||e[33]!==o||e[34]!==u?(D=te=>r.jsx(uI,{issue:te,viewer:u,now:d,onPickLabel:c,onShowPull:o,composePrompt:s},te.number),e[31]=s,e[32]=d,e[33]=o,e[34]=u,e[35]=D):D=e[35];const L=D,F=v==="all";let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=()=>a("all"),e[36]=z):z=e[36];let W;e[37]!==t.issues.length?(W=r.jsx(jt,{children:t.issues.length}),e[37]=t.issues.length,e[38]=W):W=e[38];let U;e[39]!==F||e[40]!==W?(U=r.jsxs(wt,{pressed:F,onClick:z,children:["All",W]}),e[39]=F,e[40]=W,e[41]=U):U=e[41];let H;e[42]!==h||e[43]!==v||e[44]!==u?(H=u&&r.jsxs(wt,{pressed:v==="assigned",disabled:h===0,onClick:()=>a("assigned"),"aria-label":"Only issues assigned to you",children:[r.jsx($1,{className:"size-3"}),"Mine",r.jsx(jt,{children:h})]}),e[42]=h,e[43]=v,e[44]=u,e[45]=H):H=e[45];let K;e[46]!==v||e[47]!==x||e[48]!==u?(K=u&&r.jsxs(wt,{pressed:v==="opened",disabled:x===0,onClick:()=>a("opened"),"aria-label":"Only issues you opened",children:[r.jsx(kd,{className:"size-3"}),"Opened",r.jsx(jt,{children:x})]}),e[46]=v,e[47]=x,e[48]=u,e[49]=K):K=e[49];const q=v==="unassigned",Y=y===0;let V;e[50]===Symbol.for("react.memo_cache_sentinel")?(V=()=>a("unassigned"),e[50]=V):V=e[50];let J;e[51]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(rw,{className:"size-3"}),e[51]=J):J=e[51];let Q;e[52]!==y?(Q=r.jsx(jt,{children:y}),e[52]=y,e[53]=Q):Q=e[53];let X;e[54]!==q||e[55]!==Y||e[56]!==Q?(X=r.jsxs(wt,{pressed:q,disabled:Y,onClick:V,"aria-label":"Only unassigned issues",children:[J,"Unassigned",Q]}),e[54]=q,e[55]=Y,e[56]=Q,e[57]=X):X=e[57];const Z=l&&r.jsxs(wt,{pressed:!0,onClick:()=>c(null),"aria-label":`Clear label filter ${l}`,children:[r.jsx("span",{className:"max-w-28 truncate",children:l}),r.jsx(jt,{children:$.length}),r.jsx(st,{className:"size-3","aria-hidden":!0})]});e[58]!==U||e[59]!==H||e[60]!==K||e[61]!==X||e[62]!==Z?(k=r.jsxs(Tr,{label:"Filter issues",children:[U,H,K,X,Z]}),e[58]=U,e[59]=H,e[60]=K,e[61]=X,e[62]=Z,e[63]=k):k=e[63],j=Gn,A="min-h-0 flex-1",N="flex flex-col gap-4 px-3 py-3",_=M.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open here."}):M.map(L),P=O.length>0&&r.jsx(Ru,{count:O.length,children:O.map(L)})}e[9]=h,e[10]=s,e[11]=t.issues,e[12]=v,e[13]=l,e[14]=d,e[15]=o,e[16]=x,e[17]=y,e[18]=u,e[19]=j,e[20]=k,e[21]=C,e[22]=N,e[23]=_,e[24]=P,e[25]=A}else j=e[19],k=e[20],C=e[21],N=e[22],_=e[23],P=e[24],A=e[25];if(C!==Symbol.for("react.early_return_sentinel"))return C;let T;e[64]!==N||e[65]!==_||e[66]!==P?(T=r.jsxs("div",{className:N,children:[_,P]}),e[64]=N,e[65]=_,e[66]=P,e[67]=T):T=e[67];let E;e[68]!==j||e[69]!==T||e[70]!==A?(E=r.jsx(j,{className:A,children:T}),e[68]=j,e[69]=T,e[70]=A,e[71]=E):E=e[71];let R;return e[72]!==k||e[73]!==E?(R=r.jsxs(r.Fragment,{children:[k,E]}),e[72]=k,e[73]=E,e[74]=R):R=e[74],R}function pI(n){return n.state!=="open"}function hI(n){return n.state==="open"}const wb={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},gI={open:"bg-success",draft:"bg-border",merged:"bg-info",closed:"bg-destructive"};function Ks(n){return n.state==="open"||n.state==="draft"}function xI(n){const e=B.c(12),{state:t}=n,s=wb[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-success"),e[0]=a):a=e[0];let l;return e[1]!==s?(l=r.jsx(Mr,{className:a,"aria-label":s}),e[1]=s,e[2]=l):l=e[2],l}if(t==="draft"){let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-muted-foreground"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(Sd,{className:a,"aria-label":s}),e[4]=s,e[5]=l):l=e[5],l}if(t==="merged"){let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=G("size-3.5 shrink-0","text-info"),e[6]=a):a=e[6];let l;return e[7]!==s?(l=r.jsx(I1,{className:a,"aria-label":s}),e[7]=s,e[8]=l):l=e[8],l}let o;e[9]===Symbol.for("react.memo_cache_sentinel")?(o=G("size-3.5 shrink-0","text-destructive"),e[9]=o):o=e[9];let i;return e[10]!==s?(i=r.jsx(aw,{className:o,"aria-label":s}),e[10]=s,e[11]=i):i=e[11],i}function Ch(n){return n==="success"?"Checks passed":n==="failure"?"Checks failed":"Checks running"}function bI(n){const e=B.c(3),{checks:t}=n;if(t==="success"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(gt,{className:"size-3 text-success"}),e[0]=o):o=e[0],o}if(t==="failure"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(st,{className:"size-3 text-destructive"}),e[1]=o):o=e[1],o}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx($o,{className:"size-3 text-info"}),e[2]=s):s=e[2],s}function vI(n){return n.reviewRequested?{icon:r.jsx(ys,{className:"size-3 text-info"}),label:"Your review is requested"}:n.review==="approved"?{icon:r.jsx(Rr,{className:"size-3 text-success"}),label:"Approved"}:n.review==="changes_requested"?{icon:r.jsx(qt,{className:"size-3 text-warning"}),label:"Changes requested"}:n.review==="review_required"&&Ks(n)?{icon:r.jsx(ys,{className:"size-3 text-muted-foreground"}),label:"Review required"}:null}function yI(n){const e=B.c(17),{pull:t,onShowChecks:s}=n;let o;e[0]!==t?(o=vI(t),e[0]=t,e[1]=o):o=e[1];const i=o;let a;e[2]!==s||e[3]!==t.checks||e[4]!==t.headBranch?(a=t.checks&&r.jsx("button",{type:"button",className:"rounded-sm outline-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":`${Ch(t.checks)}, show runs`,title:Ch(t.checks),onClick:()=>s(t.headBranch),children:r.jsx(bI,{checks:t.checks})}),e[2]=s,e[3]=t.checks,e[4]=t.headBranch,e[5]=a):a=e[5];let l;e[6]!==i?(l=i&&r.jsx("span",{"aria-label":i.label,title:i.label,role:"img",children:i.icon}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.conflicts?(c=t.conflicts&&r.jsx(bn,{className:"size-3 text-warning","aria-label":"Has merge conflicts",role:"img"}),e[8]=t.conflicts,e[9]=c):c=e[9];let d;e[10]!==t.comments?(d=r.jsx(B2,{count:t.comments}),e[10]=t.comments,e[11]=d):d=e[11];let u;return e[12]!==a||e[13]!==l||e[14]!==c||e[15]!==d?(u=r.jsxs("span",{className:"flex h-5 shrink-0 items-center gap-1.5",children:[a,l,c,d]}),e[12]=a,e[13]=l,e[14]=c,e[15]=d,e[16]=u):u=e[16],u}function wI(n){return n==="added"||n==="copied"?{mark:"A",className:"text-success"}:n==="removed"?{mark:"D",className:"text-destructive"}:n==="renamed"?{mark:"R",className:"text-info"}:{mark:"M",className:"text-warning"}}function jI(n){const e=n.lastIndexOf("/");return e===-1?{directory:"",name:n}:{directory:n.slice(0,e+1),name:n.slice(e+1)}}function SI(n){const e=B.c(38),{file:t}=n;let s,o,i,a,l,c;if(e[0]!==t.path||e[1]!==t.status){const{mark:S,className:j}=wI(t.status);o=S;let k;e[8]!==t.path?(k=jI(t.path),e[8]=t.path,e[9]=k):k=e[9],{directory:s,name:i}=k,l="flex min-w-0 items-center gap-2 py-0.5 font-mono text-[11px] leading-5",c=t.path,a=G("w-3 shrink-0 text-center font-medium",j),e[0]=t.path,e[1]=t.status,e[2]=s,e[3]=o,e[4]=i,e[5]=a,e[6]=l,e[7]=c}else s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7];let d;e[10]!==t.status||e[11]!==o||e[12]!==a?(d=r.jsx("span",{className:a,"aria-label":t.status,children:o}),e[10]=t.status,e[11]=o,e[12]=a,e[13]=d):d=e[13];let u;e[14]!==s?(u=r.jsx("span",{className:"text-muted-foreground",children:s}),e[14]=s,e[15]=u):u=e[15];const f=t.status==="removed"&&"line-through text-muted-foreground";let m;e[16]!==f?(m=G(f),e[16]=f,e[17]=m):m=e[17];let p;e[18]!==i||e[19]!==m?(p=r.jsx("span",{className:m,children:i}),e[18]=i,e[19]=m,e[20]=p):p=e[20];let h;e[21]!==u||e[22]!==p?(h=r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[u,p]}),e[21]=u,e[22]=p,e[23]=h):h=e[23];let g;e[24]!==t.additions?(g=t.additions>0&&r.jsxs("span",{className:"text-success",children:["+",t.additions]}),e[24]=t.additions,e[25]=g):g=e[25];const x=t.additions>0&&t.deletions>0&&" ";let b;e[26]!==t.deletions?(b=t.deletions>0&&r.jsxs("span",{className:"text-destructive",children:["−",t.deletions]}),e[26]=t.deletions,e[27]=b):b=e[27];let y;e[28]!==g||e[29]!==x||e[30]!==b?(y=r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums",children:[g,x,b]}),e[28]=g,e[29]=x,e[30]=b,e[31]=y):y=e[31];let v;return e[32]!==y||e[33]!==l||e[34]!==c||e[35]!==d||e[36]!==h?(v=r.jsxs("li",{className:l,title:c,children:[d,h,y]}),e[32]=y,e[33]=l,e[34]=c,e[35]=d,e[36]=h,e[37]=v):v=e[37],v}function NI(n){var j,k,C,N,_,P;const e=B.c(40),{pull:t,files:s}=n;let o;e[0]!==t.body?(o=t.body.trim(),e[0]=t.body,e[1]=o):o=e[1];const i=o;let a;e[2]!==((j=s.data)==null?void 0:j.files)?(a=((k=s.data)==null?void 0:k.files)??[],e[2]=(C=s.data)==null?void 0:C.files,e[3]=a):a=e[3];const l=a;let c;e[4]!==i?(c=i?r.jsx($u,{body:i}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[4]=i,e[5]=c):c=e[5];let d;e[6]!==s.data||e[7]!==l.length?(d=s.data&&r.jsx("span",{className:"font-mono text-[10px] font-normal text-muted-foreground tabular-nums",children:s.data.truncated?`${l.length}+`:l.length}),e[6]=s.data,e[7]=l.length,e[8]=d):d=e[8];let u;e[9]!==d?(u=r.jsxs("h4",{className:"flex items-center gap-1.5 text-[11px] font-medium leading-5",children:["Files changed",d]}),e[9]=d,e[10]=u):u=e[10];let f;e[11]!==s.data||e[12]!==s.loading?(f=s.loading&&!s.data&&r.jsxs("div",{className:"flex items-center gap-2 py-1 text-[11px] text-muted-foreground",role:"status",children:[r.jsx(ot,{className:"size-3"}),"Loading files"]}),e[11]=s.data,e[12]=s.loading,e[13]=f):f=e[13];let m;e[14]!==s.error?(m=s.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:s.error.error}),e[14]=s.error,e[15]=m):m=e[15];let p;e[16]!==s.data||e[17]!==l.length?(p=s.data&&l.length===0&&r.jsx("p",{className:"py-1 text-[11px] text-muted-foreground",children:"No file changes on this pull request."}),e[16]=s.data,e[17]=l.length,e[18]=p):p=e[18];let h;e[19]!==l?(h=l.length>0&&r.jsx("ul",{className:"border-l border-border pl-2",children:l.map(kI)}),e[19]=l,e[20]=h):h=e[20];let g;e[21]!==((N=s.data)==null?void 0:N.truncated)||e[22]!==l.length?(g=((_=s.data)==null?void 0:_.truncated)&&r.jsxs("p",{className:"py-1 text-[11px] text-muted-foreground",children:["GitHub lists the first ",l.length," files here. The full set is on the pull request."]}),e[21]=(P=s.data)==null?void 0:P.truncated,e[22]=l.length,e[23]=g):g=e[23];let x;e[24]!==g||e[25]!==u||e[26]!==f||e[27]!==m||e[28]!==p||e[29]!==h?(x=r.jsxs("section",{"aria-label":"Files changed",className:"min-w-0",children:[u,f,m,p,h,g]}),e[24]=g,e[25]=u,e[26]=f,e[27]=m,e[28]=p,e[29]=h,e[30]=x):x=e[30];let b;e[31]!==t.url?(b=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[31]=t.url,e[32]=b):b=e[32];let y;e[33]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(nn,{"data-icon":"inline-end"}),e[33]=y):y=e[33];let v;e[34]!==b?(v=r.jsxs(ee,{variant:"outline",size:"xs",className:"self-start",render:b,children:["Open pull request on GitHub",y]}),e[34]=b,e[35]=v):v=e[35];let S;return e[36]!==x||e[37]!==v||e[38]!==c?(S=r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[c,x,v]}),e[36]=x,e[37]=v,e[38]=c,e[39]=S):S=e[39],S}function kI(n){return r.jsx(SI,{file:n},n.path)}function CI(n){const e=B.c(7),{sessions:t,openSession:s}=n;let o;if(e[0]!==s||e[1]!==t){let a;e[3]!==s?(a=l=>r.jsxs("button",{type:"button",className:"inline-flex h-5 max-w-full items-center gap-1 rounded-full border px-1.5 text-[10px] leading-none text-muted-foreground outline-none hover:border-foreground/30 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:cursor-default disabled:hover:border-border disabled:hover:text-muted-foreground",onClick:()=>s==null?void 0:s(l.dirName,l.fileName),disabled:!s,"aria-label":`Open session: ${l.title||l.sessionId}`,title:l.title||l.sessionId,children:[r.jsx(yc,{className:"size-3 shrink-0","aria-hidden":!0}),r.jsx("span",{className:"truncate",children:l.title||l.sessionId.slice(0,8)})]},l.sessionId),e[3]=s,e[4]=a):a=e[4],o=t.map(a),e[0]=s,e[1]=t,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=r.jsx("div",{className:"flex flex-wrap gap-1 pl-[26px] pr-1 pb-1","aria-label":"Sessions on this pull request",children:o}),e[5]=o,e[6]=i):i=e[6],i}function _I(n){const e=B.c(88),{pull:t,projectPath:s,currentBranch:o,sessions:i,openSession:a,onShowChecks:l,now:c}=n;let d;e[0]!==s||e[1]!==t.number?(d=()=>W$(s,t.number),e[0]=s,e[1]=t.number,e[2]=d):d=e[2];const{open:u,state:f,onOpenChange:m}=bb(d,"Unable to load changed files"),p=o!==null&&t.headBranch===o,h=Ks(t)?t.updatedAt:t.closedAt??t.updatedAt,g=t.title,x=gI[t.state];let b;e[3]!==x?(b=G("absolute inset-y-1 left-0 w-0.5 rounded-full",x),e[3]=x,e[4]=b):b=e[4];let y;e[5]!==b?(y=r.jsx("span",{"aria-hidden":!0,className:b}),e[5]=b,e[6]=y):y=e[6];const v=`${t.title} #${t.number}: ${wb[t.state]}`;let S;e[7]!==t.state?(S=r.jsx(xI,{state:t.state}),e[7]=t.state,e[8]=S):S=e[8];let j;e[9]!==t?(j=!Ks(t)&&"text-muted-foreground",e[9]=t,e[10]=j):j=e[10];let k;e[11]!==j?(k=G("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",j),e[11]=j,e[12]=k):k=e[12];let C;e[13]!==t.title||e[14]!==k?(C=r.jsx("span",{className:k,children:t.title}),e[13]=t.title,e[14]=k,e[15]=C):C=e[15];let N;e[16]!==t.number?(N=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[16]=t.number,e[17]=N):N=e[17];let _;e[18]!==C||e[19]!==N||e[20]!==S?(_=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[S,C,N]}),e[18]=C,e[19]=N,e[20]=S,e[21]=_):_=e[21];let P;e[22]!==t.author?(P=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[22]=t.author,e[23]=P):P=e[23];let A;e[24]!==p?(A=p&&r.jsx(Fn,{className:"size-3 shrink-0 text-foreground","aria-label":"Current branch"}),e[24]=p,e[25]=A):A=e[25];const T=p&&"text-foreground";let E;e[26]!==T?(E=G("truncate",T),e[26]=T,e[27]=E):E=e[27];let R;e[28]!==t.headBranch||e[29]!==E?(R=r.jsx("span",{className:E,children:t.headBranch}),e[28]=t.headBranch,e[29]=E,e[30]=R):R=e[30];let I;e[31]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(lw,{className:"size-3 shrink-0","aria-hidden":!0}),e[31]=I):I=e[31];let $;e[32]!==t.baseBranch?($=r.jsx("span",{className:"max-w-24 shrink-0 truncate",children:t.baseBranch}),e[32]=t.baseBranch,e[33]=$):$=e[33];let M;e[34]!==A||e[35]!==R||e[36]!==$?(M=r.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono",children:[A,R,I,$]}),e[34]=A,e[35]=R,e[36]=$,e[37]=M):M=e[37];let O;e[38]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx("span",{className:"shrink-0",children:"·"}),e[38]=O):O=e[38];let D;e[39]!==h?(D=new Date(h).toLocaleString(),e[39]=h,e[40]=D):D=e[40];let L;e[41]!==h||e[42]!==c?(L=ol(h,c),e[41]=h,e[42]=c,e[43]=L):L=e[43];let F;e[44]!==h||e[45]!==D||e[46]!==L?(F=r.jsx("time",{className:"shrink-0",dateTime:h,title:D,children:L}),e[44]=h,e[45]=D,e[46]=L,e[47]=F):F=e[47];let z;e[48]!==P||e[49]!==M||e[50]!==F?(z=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[P,M,O,F]}),e[48]=P,e[49]=M,e[50]=F,e[51]=z):z=e[51];let W;e[52]!==u||e[53]!==_||e[54]!==z||e[55]!==v?(W=r.jsxs($t,{className:"flex min-w-0 flex-1 flex-col 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":v,"aria-expanded":u,children:[_,z]}),e[52]=u,e[53]=_,e[54]=z,e[55]=v,e[56]=W):W=e[56];let U;e[57]!==l||e[58]!==t?(U=r.jsx(yI,{pull:t,onShowChecks:l}),e[57]=l,e[58]=t,e[59]=U):U=e[59];const H=`Open #${t.number} on GitHub`;let K;e[60]!==t.url?(K=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[60]=t.url,e[61]=K):K=e[61];let q;e[62]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(nn,{}),e[62]=q):q=e[62];let Y;e[63]!==H||e[64]!==K?(Y=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"size-6 text-muted-foreground opacity-0 transition-opacity group-hover/pull:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100","aria-label":H,onClick:K,children:q}),e[63]=H,e[64]=K,e[65]=Y):Y=e[65];let V;e[66]!==U||e[67]!==Y?(V=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[U,Y]}),e[66]=U,e[67]=Y,e[68]=V):V=e[68];let J;e[69]!==W||e[70]!==V?(J=r.jsxs("div",{className:"group/pull flex items-start gap-1 pr-1",children:[W,V]}),e[69]=W,e[70]=V,e[71]=J):J=e[71];let Q;e[72]!==a||e[73]!==i?(Q=i.length>0&&r.jsx(CI,{sessions:i,openSession:a}),e[72]=a,e[73]=i,e[74]=Q):Q=e[74];let X;e[75]!==f||e[76]!==t?(X=r.jsx(at,{children:r.jsx(NI,{pull:t,files:f})}),e[75]=f,e[76]=t,e[77]=X):X=e[77];let Z;e[78]!==m||e[79]!==u||e[80]!==J||e[81]!==Q||e[82]!==X?(Z=r.jsxs(it,{open:u,onOpenChange:m,children:[J,Q,X]}),e[78]=m,e[79]=u,e[80]=J,e[81]=Q,e[82]=X,e[83]=Z):Z=e[83];let te;return e[84]!==t.title||e[85]!==Z||e[86]!==y?(te=r.jsxs("article",{className:"relative pl-3","aria-label":g,children:[y,Z]}),e[84]=t.title,e[85]=Z,e[86]=y,e[87]=te):te=e[87],te}function TI(n,e,t){return e==="mine"?n.filter(s=>s.author===t.viewer):e==="branch"?n.filter(s=>s.headBranch===t.branch):[...n]}function EI(n){const e=new Map;for(const t of n)for(const s of t.numbers){const o=e.get(s);o?o.push(t):e.set(s,[t])}return e}function PI(n){const e=B.c(61),{data:t,sessions:s,projectPath:o,openSession:i,onShowChecks:a}=n,[l,c]=w.useState("all"),d=rl(!1);let u;e[0]!==s?(u=EI(s),e[0]=s,e[1]=u):u=e[1];const f=u;let m;e[2]!==t.pulls||e[3]!==t.viewer?(m=t.viewer?t.pulls.filter(A=>A.author===t.viewer).length:0,e[2]=t.pulls,e[3]=t.viewer,e[4]=m):m=e[4];const p=m;let h;e[5]!==t.branch||e[6]!==t.pulls?(h=t.branch?t.pulls.filter(A=>A.headBranch===t.branch).length:0,e[5]=t.branch,e[6]=t.pulls,e[7]=h):h=e[7];const g=h,x=l==="mine"&&p===0||l==="branch"&&g===0?"all":l;let b,y,v,S,j,k,C;if(e[8]!==g||e[9]!==t||e[10]!==x||e[11]!==f||e[12]!==p||e[13]!==d||e[14]!==a||e[15]!==i||e[16]!==o){C=Symbol.for("react.early_return_sentinel");e:{const A=TI(t.pulls,x,t),T=A.filter(Ks),E=A.filter(AI);if(t.pulls.length===0){let z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(il,{icon:Mr,title:"No pull requests yet",description:"Open one from a branch and it will show up here."}),e[24]=z):z=e[24],C=z;break e}let R;e[25]!==t.branch||e[26]!==f||e[27]!==d||e[28]!==a||e[29]!==i||e[30]!==o?(R=z=>r.jsx(_I,{pull:z,projectPath:o,currentBranch:t.branch,sessions:f.get(z.number)??[],openSession:i,onShowChecks:a,now:d},z.number),e[25]=t.branch,e[26]=f,e[27]=d,e[28]=a,e[29]=i,e[30]=o,e[31]=R):R=e[31];const I=R,$=x==="all";let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=()=>c("all"),e[32]=M):M=e[32];let O;e[33]!==t.pulls.length?(O=r.jsx(jt,{children:t.pulls.length}),e[33]=t.pulls.length,e[34]=O):O=e[34];let D;e[35]!==$||e[36]!==O?(D=r.jsxs(wt,{pressed:$,onClick:M,children:["All",O]}),e[35]=$,e[36]=O,e[37]=D):D=e[37];let L;e[38]!==t.viewer||e[39]!==x||e[40]!==p?(L=t.viewer&&r.jsxs(wt,{pressed:x==="mine",disabled:p===0,onClick:()=>c("mine"),"aria-label":`Only pull requests by ${t.viewer}`,children:[r.jsx(kd,{className:"size-3"}),"Mine",r.jsx(jt,{children:p})]}),e[38]=t.viewer,e[39]=x,e[40]=p,e[41]=L):L=e[41];let F;e[42]!==g||e[43]!==t.branch||e[44]!==x?(F=t.branch&&r.jsxs(wt,{pressed:x==="branch",disabled:g===0,onClick:()=>c("branch"),"aria-label":`Only pull requests from ${t.branch}`,children:[r.jsx(Fn,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:t.branch}),r.jsx(jt,{children:g})]}),e[42]=g,e[43]=t.branch,e[44]=x,e[45]=F):F=e[45],e[46]!==D||e[47]!==L||e[48]!==F?(k=r.jsxs(Tr,{label:"Filter pull requests",children:[D,L,F]}),e[46]=D,e[47]=L,e[48]=F,e[49]=k):k=e[49],b=Gn,j="min-h-0 flex-1",y="flex flex-col gap-4 px-3 py-3",v=T.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open right now."}):T.map(I),S=E.length>0&&r.jsx(Ru,{count:E.length,children:E.map(I)})}e[8]=g,e[9]=t,e[10]=x,e[11]=f,e[12]=p,e[13]=d,e[14]=a,e[15]=i,e[16]=o,e[17]=b,e[18]=y,e[19]=v,e[20]=S,e[21]=j,e[22]=k,e[23]=C}else b=e[17],y=e[18],v=e[19],S=e[20],j=e[21],k=e[22],C=e[23];if(C!==Symbol.for("react.early_return_sentinel"))return C;let N;e[50]!==y||e[51]!==v||e[52]!==S?(N=r.jsxs("div",{className:y,children:[v,S]}),e[50]=y,e[51]=v,e[52]=S,e[53]=N):N=e[53];let _;e[54]!==b||e[55]!==N||e[56]!==j?(_=r.jsx(b,{className:j,children:N}),e[54]=b,e[55]=N,e[56]=j,e[57]=_):_=e[57];let P;return e[58]!==_||e[59]!==k?(P=r.jsxs(r.Fragment,{children:[k,_]}),e[58]=_,e[59]=k,e[60]=P):P=e[60],P}function AI(n){return!Ks(n)}const RI={actions:"Refresh GitHub Actions",pulls:"Refresh pull requests",issues:"Refresh issues"};function $I(n){return n==="actions"||n==="pulls"||n==="issues"}function II(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 MI(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(OI),e[0]=s):s=e[0];let o;return e[1]!==t?(o=r.jsx("div",{className:"flex flex-col gap-5 px-3 py-4","aria-label":t,children:s}),e[1]=t,e[2]=o):o=e[2],o}function OI(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ut,{className:"h-3.5 w-3/4"}),r.jsx(ut,{className:"h-2.5 w-1/2"}),r.jsx(ut,{className:"h-3 w-full"}),r.jsx(ut,{className:"h-3 w-full"})]},n)}function ic(n){const e=B.c(23),{state:t,loadingLabel:s,onRetry:o,children:i}=n;if(t.data){let l;e[0]!==i||e[1]!==t.data?(l=i(t.data),e[0]=i,e[1]=t.data,e[2]=l):l=e[2];let c;return e[3]!==l?(c=r.jsx(r.Fragment,{children:l}),e[3]=l,e[4]=c):c=e[4],c}if(t.error){let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(qt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(Et,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=II(t.error),e[8]=t.error,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{children:d}),e[10]=d,e[11]=u):u=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(At,{"data-icon":"inline-start"}),e[12]=f):f=e[12];let m;e[13]!==o?(m=r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:o,children:[f,"Try again"]}),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==u||e[16]!==m?(p=r.jsxs(ht,{className:"flex flex-col items-start gap-2",children:[u,m]}),e[15]=u,e[16]=m,e[17]=p):p=e[17];let h;return e[18]!==c||e[19]!==p?(h=r.jsx("div",{className:"p-3",children:r.jsxs(pt,{variant:"destructive",children:[l,c,p]})}),e[18]=c,e[19]=p,e[20]=h):h=e[20],h}let a;return e[21]!==s?(a=r.jsx(MI,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function ac(n){const e=B.c(5),{value:t,attention:s}=n;if(t===null||t===0)return null;const o=s?"text-info":"text-muted-foreground";let i;e[0]!==o?(i=G("font-mono text-[10px] tabular-nums",o),e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==i||e[3]!==t?(a=r.jsx("span",{className:i,children:t}),e[2]=i,e[3]=t,e[4]=a):a=e[4],a}function DI(n){var f,m,p,h;const e=B.c(11),{context:t}=n,s=t.projectPath!==null,{data:o}=hb(t.projectPath,s),i=gb(t.projectPath,s);let a;e[0]!==(o==null?void 0:o.runs)?(a=(o==null?void 0:o.runs.filter(zI).length)??0,e[0]=o==null?void 0:o.runs,e[1]=a):a=e[1];const l=a,c=(f=o==null?void 0:o.runs[0])!=null&&f.conclusion?Lo(o.runs[0].conclusion):!1;let d;e[2]!==((m=i.data)==null?void 0:m.pulls)?(d=((p=i.data)==null?void 0:p.pulls.filter(LI).length)??0,e[2]=(h=i.data)==null?void 0:h.pulls,e[3]=d):d=e[3];const u=d;if(l>0){const g=`${l} active GitHub Actions run${l===1?"":"s"}`;let x;return e[4]!==l||e[5]!==g?(x=r.jsx(Ce,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:l}),e[4]=l,e[5]=g,e[6]=x):x=e[6],x}if(c){let g;return e[7]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(Ce,{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[7]=g):g=e[7],g}if(u>0){const g=`${u} pull request${u===1?"":"s"} waiting for your review`;let x;return e[8]!==u||e[9]!==g?(x=r.jsx(Ce,{variant:"secondary",className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]","aria-label":g,children:u}),e[8]=u,e[9]=g,e[10]=x):x=e[10],x}return null}function LI(n){return Ks(n)&&n.reviewRequested}function zI(n){return si(n.status)}function FI(n){const e=B.c(78),{context:t,active:s,closePanel:o}=n,[i,a]=w.useState("actions"),[l,c]=w.useState(null),d=t.projectPath,u=hb(d,s),f=gb(d,s),m=B$(d,s&&i==="pulls"),p=F$(d,s&&i==="issues");let h;e[0]!==p||e[1]!==f||e[2]!==u?(h={actions:u,pulls:f,issues:p},e[0]=p,e[1]=f,e[2]=u,e[3]=h):h=e[3];const g=h[i];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=function(oe){c({branch:oe}),a("actions")},e[4]=x):x=e[4];const b=x,y=u.data??f.data??p.data;let v;e[5]!==u.data?(v=u.data?u.data.runs.filter(UI).length:null,e[5]=u.data,e[6]=v):v=e[6];const S=v;let j;e[7]!==f.data?(j=f.data?f.data.pulls.filter(Ks).length:null,e[7]=f.data,e[8]=j):j=e[8];const k=j;let C;e[9]!==p.data?(C=p.data?p.data.issues.filter(BI).length:null,e[9]=p.data,e[10]=C):C=e[10];const N=C;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=ne=>{$I(ne)&&a(ne)},e[11]=_):_=e[11];let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"GitHub"}),e[12]=P):P=e[12];let A;e[13]!==y||e[14]!==i?(A=r.jsxs("div",{className:"min-w-0 flex-1",children:[P,y?r.jsxs("a",{href:`${y.repositoryUrl}/${i}`,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:y.repository}),r.jsx(nn,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Current repository"})]}),e[13]=y,e[14]=i,e[15]=A):A=e[15];let T;e[16]!==g?(T=()=>{g.refresh()},e[16]=g,e[17]=T):T=e[17];const E=g.loading||g.refreshing||!d,R=RI[i];let I;e[18]!==g.refreshing?(I=g.refreshing?r.jsx(ot,{}):r.jsx(At,{}),e[18]=g.refreshing,e[19]=I):I=e[19];let $;e[20]!==E||e[21]!==R||e[22]!==I||e[23]!==T?($=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:T,disabled:E,"aria-label":R,children:I}),e[20]=E,e[21]=R,e[22]=I,e[23]=T,e[24]=$):$=e[24];let M;e[25]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(st,{}),e[25]=M):M=e[25];let O;e[26]!==o?(O=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close GitHub",children:M}),e[26]=o,e[27]=O):O=e[27];let D;e[28]!==$||e[29]!==O||e[30]!==A?(D=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[A,$,O]}),e[28]=$,e[29]=O,e[30]=A,e[31]=D):D=e[31];let L;e[32]!==S?(L=r.jsxs(Ln,{value:"actions",className:"h-full flex-none rounded-none px-0 text-xs",children:["Actions",r.jsx(ac,{value:S,attention:!0})]}),e[32]=S,e[33]=L):L=e[33];let F;e[34]!==k?(F=r.jsxs(Ln,{value:"pulls",className:"h-full flex-none rounded-none px-0 text-xs",children:["Pull requests",r.jsx(ac,{value:k})]}),e[34]=k,e[35]=F):F=e[35];let z;e[36]!==N?(z=r.jsxs(Ln,{value:"issues",className:"h-full flex-none rounded-none px-0 text-xs",children:["Issues",r.jsx(ac,{value:N})]}),e[36]=N,e[37]=z):z=e[37];let W;e[38]!==L||e[39]!==F||e[40]!==z?(W=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(za,{variant:"line",className:"h-full gap-3 p-0","aria-label":"GitHub views",children:[L,F,z]})}),e[38]=L,e[39]=F,e[40]=z,e[41]=W):W=e[41];let U;e[42]!==u?(U=()=>{u.refresh()},e[42]=u,e[43]=U):U=e[43];let H;e[44]!==l||e[45]!==d?(H=ne=>d&&r.jsx(sI,{data:ne,projectPath:d,focus:l}),e[44]=l,e[45]=d,e[46]=H):H=e[46];let K;e[47]!==u||e[48]!==U||e[49]!==H?(K=r.jsx(zn,{value:"actions",className:"flex min-h-0 flex-col",children:r.jsx(ic,{state:u,loadingLabel:"Loading workflow runs",onRetry:U,children:H})}),e[47]=u,e[48]=U,e[49]=H,e[50]=K):K=e[50];let q;e[51]!==f?(q=()=>{f.refresh()},e[51]=f,e[52]=q):q=e[52];let Y;e[53]!==t.openSession||e[54]!==d||e[55]!==m?(Y=ne=>{var oe;return d&&r.jsx(PI,{data:ne,sessions:((oe=m.data)==null?void 0:oe.sessions)??[],projectPath:d,openSession:t.openSession,onShowChecks:b})},e[53]=t.openSession,e[54]=d,e[55]=m,e[56]=Y):Y=e[56];let V;e[57]!==f||e[58]!==q||e[59]!==Y?(V=r.jsx(zn,{value:"pulls",className:"flex min-h-0 flex-col",children:r.jsx(ic,{state:f,loadingLabel:"Loading pull requests",onRetry:q,children:Y})}),e[57]=f,e[58]=q,e[59]=Y,e[60]=V):V=e[60];let J;e[61]!==p?(J=()=>{p.refresh()},e[61]=p,e[62]=J):J=e[62];let Q;e[63]!==t.composePrompt?(Q=ne=>r.jsx(mI,{data:ne,composePrompt:t.composePrompt,onShowPulls:()=>a("pulls")}),e[63]=t.composePrompt,e[64]=Q):Q=e[64];let X;e[65]!==p||e[66]!==J||e[67]!==Q?(X=r.jsx(zn,{value:"issues",className:"flex min-h-0 flex-col",children:r.jsx(ic,{state:p,loadingLabel:"Loading issues",onRetry:J,children:Q})}),e[65]=p,e[66]=J,e[67]=Q,e[68]=X):X=e[68];let Z;e[69]!==K||e[70]!==V||e[71]!==X?(Z=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K,V,X]}),e[69]=K,e[70]=V,e[71]=X,e[72]=Z):Z=e[72];let te;return e[73]!==D||e[74]!==W||e[75]!==Z||e[76]!==i?(te=r.jsxs(La,{value:i,onValueChange:_,className:"size-full min-h-0 gap-0","aria-label":"GitHub panel",children:[D,W,Z]}),e[73]=D,e[74]=W,e[75]=Z,e[76]=i,e[77]=te):te=e[77],te}function BI(n){return n.state==="open"}function UI(n){return si(n.status)}const WI={id:"github",workspacePanels:[{id:"repository",title:"GitHub",icon:h1,component:FI,indicator:DI,order:40,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},Ku={data:null,error:null,loading:!1,refreshing:!1},_h=new Map,HI=8e3,KI=1e4,qI=new Set(["vercel_access_denied","vercel_auth_required","vercel_cli_too_old","vercel_missing","vercel_project_unlinked"]);function qu(n){let e=_h.get(n);return e||(e={snapshot:Ku,listeners:new Set,request:null,fetchedAt:0},_h.set(n,e)),e}function lc(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function jb(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 cc(n,e=!1){const t=qu(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&qI.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<HI))return lc(t,{...t.snapshot,error:null,loading:t.snapshot.data===null,refreshing:t.snapshot.data!==null}),t.request=ve(`/api/vercel-deployments?cwd=${encodeURIComponent(n)}&limit=20`).then(async s=>{if(!s.ok)throw await jb(s);const o=await s.json();t.fetchedAt=Date.now(),lc(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;lc(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 VI(n,e){if(!n)return()=>{};const t=qu(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function GI(n){return n?qu(n).snapshot:Ku}function Sb(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>VI(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>GI(s),t[2]=s,t[3]=i):i=t[3];const a=w.useSyncExternalStore(o,i,YI);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;cc(s);const m=window.setInterval(()=>{cc(s)},KI);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]),w.useEffect(l,c);let d;t[8]!==s?(d=()=>s?cc(s,!0):Promise.resolve(),t[8]=s,t[9]=d):d=t[9];const u=d;let f;return t[10]!==u||t[11]!==a?(f={...a,refresh:u},t[10]=u,t[11]=a,t[12]=f):f=t[12],f}function YI(){return Ku}async function XI(n,e){const t=await ve(`/api/vercel-deployments/build-logs?cwd=${encodeURIComponent(n)}&deploymentId=${encodeURIComponent(e)}&limit=200`);if(!t.ok)throw await jb(t);return t.json()}const JI={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success"};function oi(n){return n==="BUILDING"||n==="INITIALIZING"||n==="QUEUED"}function dl(n){return n==="BLOCKED"||n==="CANCELED"||n==="ERROR"}function Ro(n){return n.target==="production"}function Nb(n){return oi(n)?"live":dl(n)?"fail":"pass"}function Vu(n){return n==="READY"?"Ready":n==="BUILDING"?"Building":n==="INITIALIZING"?"Initializing":n==="QUEUED"?"Queued":n==="CANCELED"?"Canceled":n==="BLOCKED"?"Blocked":"Failed"}function kb(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 QI(n,e){const t=n.buildingAt??n.createdAt,s=n.readyAt??(oi(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 ZI(n){const e=B.c(3),[t,s]=w.useState(eM);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]),w.useEffect(o,i),t}function eM(){return Date.now()}function Gu(n){if(!n)return null;try{return new URL(n).host}catch{return null}}function ed(n){return n.commitMessage.split(`
128
+ `)[0]||Gu(n.url)||`${Vu(n.state)} deployment`}function tM(n){return[n.errorCode,n.errorMessage].filter(Boolean).join(": ")||null}function Cb(n){const e=B.c(12),{state:t,className:s}=n;let o;e[0]!==t?(o=Vu(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 u=G("size-3.5 shrink-0",s);if(t==="BUILDING"){c=r.jsx(ot,{className:G(u,"text-info"),"aria-label":i});break e}if(t==="INITIALIZING"||t==="QUEUED"){c=r.jsx($o,{className:G(u,"text-info"),"aria-label":i});break e}if(t==="READY"){c=r.jsx(gt,{className:G(u,"text-success"),"aria-label":i});break e}if(t==="BLOCKED"){c=r.jsx(cw,{className:G(u,"text-destructive"),"aria-label":i});break e}a=st,l=G(u,"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 nM(){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 sM(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 oM(){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(ut,{className:"h-2.5 w-16"}),r.jsx(ut,{className:"h-3.5 w-3/4"}),r.jsx(ut,{className:"h-2.5 w-1/2"})]}),[0,1,2,3].map(rM)]}),n[0]=e):e=n[0],e}function rM(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(ut,{className:"h-3.5 w-4/5"}),r.jsx(ut,{className:"h-2.5 w-1/2"})]},n)}const iM={data:null,error:null,loading:!1};function aM(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(lM),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 lM(n){return r.jsxs("div",{className:G("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 Th(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(nn,{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 cM(n){const e=B.c(106),{deployment:t,projectPath:s,now:o}=n,[i,a]=w.useState(!1),[l,c]=w.useState(iM);let d;e[0]!==t.state?(d=Nb(t.state),e[0]=t.state,e[1]=d):d=e[1];const u=d;let f;e[2]!==t||e[3]!==o?(f=QI(t,o),e[2]=t,e[3]=o,e[4]=f):f=e[4];const m=f;let p;e[5]!==t?(p=ed(t),e[5]=t,e[6]=p):p=e[6];const h=p;let g;e[7]!==t?(g=tM(t),e[7]=t,e[8]=g):g=e[8];const x=g;let b;e[9]!==t.url?(b=Gu(t.url),e[9]=t.url,e[10]=b):b=e[10];const y=b;let v;e[11]!==t.id||e[12]!==l.loading||e[13]!==s?(v=async function(){if(!l.loading){c(dM);try{const le=await XI(s,t.id);c({data:le,error:null,loading:!1})}catch(le){const me=le;c({data:null,error:{error:typeof me.error=="string"?me.error:"Unable to load build output",code:me.code??"vercel_api_failed"},loading:!1})}}},e[11]=t.id,e[12]=l.loading,e[13]=s,e[14]=v):v=e[14];const S=v;let j;e[15]!==t.state||e[16]!==S||e[17]!==l.data?(j=function(le){a(le),le&&(!l.data||oi(t.state))&&S()},e[15]=t.state,e[16]=S,e[17]=l.data,e[18]=j):j=e[18];const k=j,C=JI[u];let N;e[19]!==C?(N=G("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 P;e[23]!==t.state?(P=Vu(t.state),e[23]=t.state,e[24]=P):P=e[24];const A=`${h}: ${P}`;let T;e[25]!==t.state?(T=r.jsx(Cb,{state:t.state}),e[25]=t.state,e[26]=T):T=e[26];const E=u==="fail"&&"text-destructive";let R;e[27]!==E?(R=G("min-w-0 flex-1 truncate text-xs font-medium",E),e[27]=E,e[28]=R):R=e[28];let I;e[29]!==R||e[30]!==h?(I=r.jsx("span",{className:R,children:h}),e[29]=R,e[30]=h,e[31]=I):I=e[31];let $;e[32]!==t?($=Ro(t)&&r.jsx(nM,{}),e[32]=t,e[33]=$):$=e[33];let M;e[34]!==t.createdAt||e[35]!==o?(M=kb(t.createdAt,o),e[34]=t.createdAt,e[35]=o,e[36]=M):M=e[36];let O;e[37]!==M?(O=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]=O):O=e[38];let D;e[39]!==T||e[40]!==I||e[41]!==$||e[42]!==O?(D=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[T,I,$,O]}),e[39]=T,e[40]=I,e[41]=$,e[42]=O,e[43]=D):D=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]!==u?(U=m&&r.jsx("span",{className:G("shrink-0 tabular-nums",u==="live"&&"text-info"),children:m}),e[52]=m,e[53]=u,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]!==A||e[64]!==D||e[65]!==H||e[66]!==K?(q=r.jsxs($t,{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":A,"aria-expanded":i,children:[D,H,K]}),e[62]=i,e[63]=A,e[64]=D,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(nn,{})}),e[68]=t.url,e[69]=h,e[70]=Y):Y=e[70];let V;e[71]!==q||e[72]!==Y?(V=r.jsxs("div",{className:"flex items-start gap-1",children:[q,Y]}),e[71]=q,e[72]=Y,e[73]=V):V=e[73];let J;e[74]!==t.url||e[75]!==y?(J=t.url&&y&&r.jsx(Th,{href:t.url,children:y}),e[74]=t.url,e[75]=y,e[76]=J):J=e[76];let Q;e[77]!==t.inspectorUrl?(Q=t.inspectorUrl&&r.jsx(Th,{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 te;e[85]!==l.data||e[86]!==l.loading?(te=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(ot,{className:"size-3"}),"Loading build output"]}),e[85]=l.data,e[86]=l.loading,e[87]=te):te=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 oe;e[90]!==l.data?(oe=l.data&&r.jsx(aM,{logs:l.data}),e[90]=l.data,e[91]=oe):oe=e[91];let re;e[92]!==Z||e[93]!==te||e[94]!==ne||e[95]!==oe?(re=r.jsx(at,{children:r.jsxs("div",{className:"ml-[7px] flex flex-col gap-2 border-l border-border py-2 pl-4 pr-1",children:[Z,te,ne,oe]})}),e[92]=Z,e[93]=te,e[94]=ne,e[95]=oe,e[96]=re):re=e[96];let ae;e[97]!==_||e[98]!==V||e[99]!==re||e[100]!==h?(ae=r.jsxs("article",{className:"group/deployment relative pl-3","aria-label":h,children:[_,V,re]}),e[97]=_,e[98]=V,e[99]=re,e[100]=h,e[101]=ae):ae=e[101];let se;return e[102]!==k||e[103]!==i||e[104]!==ae?(se=r.jsx(it,{open:i,onOpenChange:k,children:ae}),e[102]=k,e[103]=i,e[104]=ae,e[105]=se):se=e[105],se}function dM(n){return{...n,error:null,loading:!0}}function uM(n){const e=n.filter(Ro),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 fM(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}=uM(t),c=a??l;if(!c){i=null;break e}const d=ed(c),u=Gu(c.url),f=l?Nb(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=G("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=G("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:kb(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&&u&&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:u}),r.jsx(nn,{className:"size-3 shrink-0"})]})]}),a&&l&&f&&r.jsxs("p",{className:G("mt-1.5 flex items-center gap-1.5 border-t border-border/60 pt-1.5 text-[11px]",f==="fail"?"text-destructive":"text-info"),children:[r.jsx(Cb,{state:l.state,className:"size-3"}),r.jsxs("span",{className:"min-w-0 truncate",children:[f==="fail"?"Newer production deploy failed":"Newer production deploy in progress"," · ",ed(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 mM(n,e){return e==="failed"?n.filter(t=>dl(t.state)):e==="production"?n.filter(Ro):e==="preview"?n.filter(t=>!Ro(t)):[...n]}function pM(n){const e=B.c(17),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.deployments||e[1]!==s?(i=mM(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(hM),e[3]=t.deployments,e[4]=l):l=e[4];const c=ZI(l);if(t.deployments.length===0){let m;return e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(dn,{className:"border-0",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(M1,{})}),r.jsx(fn,{children:"No deployments yet"}),r.jsx(yn,{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(fM,{deployments:t.deployments,now:c}),e[6]=t.deployments,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==a||e[10]!==s||e[11]!==c||e[12]!==o?(u=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(cM,{deployment:m,projectPath:o,now:c},m.id))}),e[9]=a,e[10]=s,e[11]=c,e[12]=o,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==u?(f=r.jsxs(Gn,{className:"min-h-0 flex-1",children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16],f}function hM(n){return oi(n.state)}function gM(n){const e=B.c(6),{context:t}=n,{data:s}=Sb(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.deployments)?(o=(s==null?void 0:s.deployments.filter(xM).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]?dl(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(Ce,{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(Ce,{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 xM(n){return oi(n.state)}function bM(n){const e=B.c(57),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=Sb(t.projectPath,s),[u,f]=w.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(Ro),e[2]=h,e[3]=x):x=e[3];const b=x.length;let y;e[4]!==h?(y=h.filter(yM),e[4]=h,e[5]=y):y=e[5];const v=y.length;let S;e[6]!==h?(S=h.filter(vM),e[6]=h,e[7]=S):S=e[7];let j;e[8]!==h.length||e[9]!==x.length||e[10]!==y.length||e[11]!==S.length?(j={all:g,production:b,preview:v,failed:S.length},e[8]=h.length,e[9]=x.length,e[10]=y.length,e[11]=S.length,e[12]=j):j=e[12];const k=j,C=u!=="all"&&k[u]===0?"all":u;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(nn,{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 P;e[16]!==d?(P=()=>{d()},e[16]=d,e[17]=P):P=e[17];const A=l||c||!m;let T;e[18]!==c?(T=c?r.jsx(ot,{}):r.jsx(At,{}),e[18]=c,e[19]=T):T=e[19];let E;e[20]!==P||e[21]!==A||e[22]!==T?(E=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:P,disabled:A,"aria-label":"Refresh Vercel deployments",children:T}),e[20]=P,e[21]=A,e[22]=T,e[23]=E):E=e[23];let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(st,{}),e[24]=R):R=e[24];let I;e[25]!==o?(I=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close Vercel deployments",children:R}),e[25]=o,e[26]=I):I=e[26];let $;e[27]!==_||e[28]!==E||e[29]!==I?($=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[_,E,I]}),e[27]=_,e[28]=E,e[29]=I,e[30]=$):$=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(wt,{pressed:C==="all",onClick:()=>f("all"),children:["All ",r.jsx(jt,{children:k.all})]}),r.jsxs(wt,{pressed:C==="production",disabled:k.production===0,onClick:()=>f("production"),children:["Production ",r.jsx(jt,{children:k.production})]}),r.jsxs(wt,{pressed:C==="preview",disabled:k.preview===0,onClick:()=>f("preview"),children:["Preview ",r.jsx(jt,{children:k.preview})]}),r.jsxs(wt,{pressed:C==="failed",disabled:k.failed===0,onClick:()=>f("failed"),children:[r.jsx("span",{className:G(k.failed>0&&"text-destructive"),children:"Failed"})," ",r.jsx(jt,{children:k.failed})]})]}),e[31]=k,e[32]=i,e[33]=C,e[34]=M):M=e[34];let O;e[35]!==i||e[36]!==l?(O=l&&!i&&r.jsx(oM,{}),e[35]=i,e[36]=l,e[37]=O):O=e[37];let D;e[38]!==i||e[39]!==a||e[40]!==d?(D=a&&!i&&r.jsx("div",{className:"p-3",children:r.jsxs(pt,{variant:"destructive",children:[r.jsx(qt,{}),r.jsx(Et,{children:a.error}),r.jsxs(ht,{className:"flex flex-col items-start gap-2",children:[r.jsx("span",{children:sM(a)}),r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},children:[r.jsx(At,{"data-icon":"inline-start"}),"Try again"]})]})]})}),e[38]=i,e[39]=a,e[40]=d,e[41]=D):D=e[41];let L;e[42]!==i||e[43]!==C||e[44]!==m?(L=i&&m&&r.jsx(pM,{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(dn,{className:"border-0",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(Gs,{})}),r.jsx(fn,{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]!==$||e[51]!==M||e[52]!==O||e[53]!==D||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:[$,M,O,D,L,F]}),e[50]=$,e[51]=M,e[52]=O,e[53]=D,e[54]=L,e[55]=F,e[56]=z):z=e[56],z}function vM(n){return dl(n.state)}function yM(n){return!Ro(n)}const wM={id:"vercel-deployments",workspacePanels:[{id:"deployments",title:"Vercel Deployments",icon:M1,component:bM,indicator:gM,order:45,defaultSize:"42%",minSize:"380px",maxSize:"68%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},jM=[WI,E$,wM];function SM(n,e,t){const s=B.c(16);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o={summary:null,loading:!1,error:null},s[0]=o):o=s[0];const[i,a]=w.useState(o),[l,c]=w.useState(0);let d,u;s[1]!==n||s[2]!==e?(d=()=>{a({summary:null,loading:!!(n&&e),error:null})},u=[n,e],s[1]=n,s[2]=e,s[3]=d,s[4]=u):(d=s[3],u=s[4]),w.useEffect(d,u);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;a(kM);const b=new URLSearchParams({dirName:n,fileName:e});return ve(`/api/usage-cost/session?${b}`,{signal:x.signal}).then(async y=>{if(!y.ok)throw new Error(`Cost scan failed (${y.status})`);const v=await y.json();a({summary:v,loading:!1,error:null})}).catch(y=>{x.signal.aborted||a(v=>({...v,loading:!1,error:y instanceof Error?y.message:"Cost scan failed"}))}),()=>x.abort()},s[5]=n,s[6]=e,s[7]=f):f=s[7];let m;s[8]!==n||s[9]!==e||s[10]!==l||s[11]!==t?(m=[n,e,l,t],s[8]=n,s[9]=e,s[10]=l,s[11]=t,s[12]=m):m=s[12],w.useEffect(f,m);let p;s[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(NM),s[13]=p):p=s[13];const h=p;let g;return s[14]!==i?(g={...i,refresh:h},s[14]=i,s[15]=g):g=s[15],g}function NM(n){return n+1}function kM(n){return{...n,loading:!0,error:null}}function CM(n){return n.records===0?"No usage":n.unpricedRecords===n.records?"Rates unavailable":n.unpricedRecords>0?"Partial estimate":n.providerReportedRecords===n.records?"Provider reported":n.providerReportedRecords>0?"Transcript + API rates":"Current API rates"}function _M(n){return[{label:"New input",tokens:n.totals.uncachedInputTokens,costUsd:n.breakdown.uncachedInputUsd},{label:"Cache reads",tokens:n.totals.cachedInputTokens,costUsd:n.breakdown.cachedInputUsd},{label:"Cache writes",tokens:n.totals.cacheCreationTokens,costUsd:n.breakdown.cacheCreationUsd},{label:"Output",tokens:n.totals.outputTokens,costUsd:n.breakdown.outputUsd},{label:"Provider total",tokens:0,costUsd:n.breakdown.unallocatedUsd}].filter(e=>e.tokens>0||e.costUsd>0)}function TM(){const n=B.c(3);let e,t;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(ut,{className:"h-4 w-24"}),r.jsx(ut,{className:"h-10 w-32"}),r.jsx(ut,{className:"h-3 w-44"})]}),t=r.jsx(ut,{className:"h-20 w-full"}),n[0]=e,n[1]=t):(e=n[0],t=n[1]);let s;return n[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsxs("div",{className:"flex flex-col gap-5 pt-2",role:"status","aria-label":"Reading session cost",children:[e,t,r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(ut,{className:"h-8 w-full"}),r.jsx(ut,{className:"h-8 w-full"}),r.jsx(ut,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function EM(n){const e=B.c(10),{message:t,retry:s}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(cd,{}),i=r.jsx(Et,{children:"Cost unavailable"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(ht,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(At,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsxs(ee,{variant:"outline",size:"xs",onClick:s,className:"mt-2",children:[l,"Retry"]}),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=r.jsxs(pt,{variant:"destructive",className:"mt-2",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Ri(n){const e=B.c(7),{label:t,value:s}=n;let o;e[0]!==t?(o=r.jsx("dt",{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("dd",{className:"truncate 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 PM(n){const e=B.c(22),{row:t,totalCost:s}=n,o=s>0?t.costUsd/s*100:0;let i;e[0]!==t.label?(i=r.jsx(Rg,{children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let a;e[2]!==t.costUsd?(a=r.jsx($g,{children:()=>hn(t.costUsd)}),e[2]=t.costUsd,e[3]=a):a=e[3];let l;e[4]!==o||e[5]!==i||e[6]!==a?(l=r.jsxs(Hr,{value:o,children:[i,a]}),e[4]=o,e[5]=i,e[6]=a,e[7]=l):l=e[7];let c;e[8]!==t.tokens?(c=t.tokens>0?mt(t.tokens):"Reported by provider",e[8]=t.tokens,e[9]=c):c=e[9];let d;e[10]!==c?(d=r.jsx("span",{children:c}),e[10]=c,e[11]=d):d=e[11];let u;e[12]!==o?(u=o>0?`${o.toFixed(1)}%`:"—",e[12]=o,e[13]=u):u=e[13];let f;e[14]!==u?(f=r.jsx("span",{children:u}),e[14]=u,e[15]=f):f=e[15];let m;e[16]!==d||e[17]!==f?(m=r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[d,f]}),e[16]=d,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==l||e[20]!==m?(p=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[l,m]}),e[19]=l,e[20]=m,e[21]=p):p=e[21],p}function AM(n){const e=B.c(8),{summary:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("h3",{id:"cost-models-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),e[0]=s):s=e[0];let o;if(e[1]!==t.costUsd||e[2]!==t.models){let a;e[4]!==t.costUsd?(a=l=>{const c=t.costUsd>0?l.costUsd/t.costUsd*100:0;return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs(Hr,{value:c,children:[r.jsx(Rg,{title:l.model,children:Js(l.model)}),r.jsx($g,{children:()=>l.costSource==="unpriced"?"Unpriced":hn(l.costUsd)})]}),r.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[r.jsxs("span",{children:[l.records," ",l.records===1?"call":"calls"]}),r.jsxs("span",{children:[mt(Ou(l.totals))," tokens"]})]})]},l.model)},e[4]=t.costUsd,e[5]=a):a=e[5],o=t.models.map(a),e[1]=t.costUsd,e[2]=t.models,e[3]=o}else o=e[3];let i;return e[6]!==o?(i=r.jsxs("section",{"aria-labelledby":"cost-models-heading",className:"flex flex-col gap-3",children:[s,r.jsx("div",{className:"flex flex-col gap-3",children:o})]}),e[6]=o,e[7]=i):i=e[7],i}function RM(n){return n.map((e,t)=>({...e,call:t+1})).filter(e=>e.costSource!=="unpriced").sort((e,t)=>t.costUsd-e.costUsd).slice(0,5)}function $M(n){const e=B.c(5),{rows:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("h3",{id:"cost-calls-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Most expensive calls"}),e[0]=s):s=e[0];let o;e[1]!==t?(o=t.map(IM),e[1]=t,e[2]=o):o=e[2];let i;return e[3]!==o?(i=r.jsxs("section",{"aria-labelledby":"cost-calls-heading",className:"flex flex-col gap-2",children:[s,r.jsx("ol",{className:"flex flex-col gap-0.5",children:o})]}),e[3]=o,e[4]=i):i=e[4],i}function IM(n){return r.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted/50",children:[r.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:["Call ",n.call," · ",Js(n.model)]}),n.isSubagent&&r.jsx(Ce,{variant:"outline",children:"Agent"}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:hn(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function MM(n){const e=B.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=Gj(t.provider),e[0]=t.provider,e[1]=s):s=e[1];const o=s;let i,a,l,c,d,u;if(e[2]!==o||e[3]!==t){const g=Ou(t.totals),x=_M(t);let b;e[10]!==t.calls?(b=RM(t.calls),e[10]=t.calls,e[11]=b):b=e[11],u=b;const y=t.providerReportedRecords+t.modelPricedRecords>0;i="flex flex-col gap-5 pt-2";let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=v):v=e[12];let S;e[13]!==o?(S=r.jsx(o,{"aria-hidden":"true"}),e[13]=o,e[14]=S):S=e[14];let j;e[15]!==t.provider?(j=sn(t.provider),e[15]=t.provider,e[16]=j):j=e[16];let k;e[17]!==j.displayName||e[18]!==S?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,r.jsxs(Ce,{variant:"outline",children:[S,j.displayName]})]}),e[17]=j.displayName,e[18]=S,e[19]=k):k=e[19];let C;e[20]!==y||e[21]!==t.costUsd?(C=y?hn(t.costUsd):"—",e[20]=y,e[21]=t.costUsd,e[22]=C):C=e[22];let N;e[23]!==C?(N=r.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:C}),e[23]=C,e[24]=N):N=e[24];const _=t.unpricedRecords>0?"secondary":"outline";let P;e[25]!==t?(P=CM(t),e[25]=t,e[26]=P):P=e[26];let A;e[27]!==_||e[28]!==P?(A=r.jsx(Ce,{variant:_,children:P}),e[27]=_,e[28]=P,e[29]=A):A=e[29];let T;e[30]!==N||e[31]!==A?(T=r.jsxs("div",{className:"flex items-end justify-between gap-3",children:[N,A]}),e[30]=N,e[31]=A,e[32]=T):T=e[32];const E=t.records===1?"model call":"model calls",R=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let I;e[33]!==t.records||e[34]!==E||e[35]!==R?(I=r.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",E,R]}),e[33]=t.records,e[34]=E,e[35]=R,e[36]=I):I=e[36],e[37]!==k||e[38]!==T||e[39]!==I?(a=r.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[k,T,I]}),e[37]=k,e[38]=T,e[39]=I,e[40]=a):a=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(kt,{}),e[41]=l):l=e[41];const $=mt(g);let M;e[42]!==$?(M=r.jsx(Ri,{label:"Processed tokens",value:$}),e[42]=$,e[43]=M):M=e[43];let O;e[44]!==t.cacheSavingsUsd?(O=hn(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=O):O=e[45];let D;e[46]!==O?(D=r.jsx(Ri,{label:"Cache savings",value:O}),e[46]=O,e[47]=D):D=e[47];let L;e[48]!==t.totals.cachedInputTokens?(L=mt(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=L):L=e[49];let F;e[50]!==L?(F=r.jsx(Ri,{label:"Cached input",value:L}),e[50]=L,e[51]=F):F=e[51];let z;e[52]!==t.totals.reasoningTokens?(z=mt(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=z):z=e[53];let W;e[54]!==z?(W=r.jsx(Ri,{label:"Reasoning",value:z}),e[54]=z,e[55]=W):W=e[55],e[56]!==M||e[57]!==D||e[58]!==F||e[59]!==W?(c=r.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[M,D,F,W]}),e[56]=M,e[57]=D,e[58]=F,e[59]=W,e[60]=c):c=e[60],d=x.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(kt,{}),r.jsxs("section",{"aria-labelledby":"cost-breakdown-heading",className:"flex flex-col gap-3",children:[r.jsx("h3",{id:"cost-breakdown-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Cost by token type"}),r.jsx("div",{className:"flex flex-col gap-4",children:x.map(U=>r.jsx(PM,{row:U,totalCost:t.costUsd},U.label))})]})]}),e[2]=o,e[3]=t,e[4]=i,e[5]=a,e[6]=l,e[7]=c,e[8]=d,e[9]=u}else i=e[4],a=e[5],l=e[6],c=e[7],d=e[8],u=e[9];let f;e[61]!==t?(f=t.models.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(kt,{}),r.jsx(AM,{summary:t})]}),e[61]=t,e[62]=f):f=e[62];let m;e[63]!==u?(m=u.length>=2&&r.jsxs(r.Fragment,{children:[r.jsx(kt,{}),r.jsx($M,{rows:u})]}),e[63]=u,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsxs(pt,{children:[r.jsx(cd,{}),r.jsx(Et,{children:"How this is calculated"}),r.jsx(ht,{children:"Token counts come from the provider transcript. Costs use provider totals when present, then current LiteLLM API rates, the same pricing source as ccusage. This is not a subscription bill."})]}),e[65]=p):p=e[65];let h;return e[66]!==i||e[67]!==a||e[68]!==l||e[69]!==c||e[70]!==d||e[71]!==f||e[72]!==m?(h=r.jsxs("div",{className:i,children:[a,l,c,d,f,m,p]}),e[66]=i,e[67]=a,e[68]=l,e[69]=c,e[70]=d,e[71]=f,e[72]=m,e[73]=h):h=e[73],h}function OM(n){const e=B.c(7),{dirName:t,fileName:s,revision:o}=n,{summary:i,loading:a,error:l,refresh:c}=SM(t,s,o);if(l){let u;return e[0]!==l||e[1]!==c?(u=r.jsx(EM,{message:l,retry:c}),e[0]=l,e[1]=c,e[2]=u):u=e[2],u}if(!i){if(a){let f;return e[3]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(TM,{}),e[3]=f):f=e[3],f}let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(dn,{className:"mt-2 min-h-52",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(dw,{})}),r.jsx(fn,{children:"No transcript cost yet"}),r.jsx(yn,{children:"Cost appears after the first model response is written."})]})}),e[4]=u):u=e[4],u}let d;return e[5]!==i?(d=r.jsx(MM,{summary:i}),e[5]=i,e[6]=d):d=e[6],d}function DM(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 LM(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=DM(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(Kr,{children:["Errors (",i.length,")"]}),e[2]=i.length,e[3]=a):a=e[3];let l;if(e[4]!==i||e[5]!==s){let u;e[7]!==s?(u=(f,m)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>s==null?void 0:s(f.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:f.toolName}),r.jsxs("span",{className:"text-muted-foreground",children:["Turn ",f.turnIndex+1]})]}),r.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:f.message})]},m),e[7]=s,e[8]=u):u=e[8],l=i.map(u),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 Eh(n){const e=B.c(42),{agentId:t,subagentType:s,agentName:o,preview:i,isViewing:a,isBackground:l,status:c,durationMs:d,toolUseCount:u,disabled:f,onClick:m,onStop:p}=n;let h;e[0]!==t||e[1]!==o||e[2]!==s?(h=o||yu(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 y;e[6]!==c?(y=c==="running"?r.jsx(lt,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?r.jsx(Wn,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(Ys,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(vd,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=y):y=e[7];const v=y,S=a?"bg-accent":"hover:bg-muted/40";let j;e[8]!==S?(j=G("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",S),e[8]=S,e[9]=j):j=e[9];let k;e[10]!==g?(k=r.jsx(Ce,{variant:"outline",children:g}),e[10]=g,e[11]=k):k=e[11];let C;e[12]!==l?(C=l&&r.jsx(Ce,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let N;e[14]!==a?(N=a&&r.jsx(Ce,{children:"Viewing"}),e[14]=a,e[15]=N):N=e[15];const _=c==="running"?"active":c;let P;e[16]!==_?(P=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:_}),e[16]=_,e[17]=P):P=e[17];let A;e[18]!==v||e[19]!==P||e[20]!==k||e[21]!==C||e[22]!==N?(A=r.jsxs("div",{className:"flex items-center gap-1.5",children:[v,k,C,N,P]}),e[18]=v,e[19]=P,e[20]=k,e[21]=C,e[22]=N,e[23]=A):A=e[23];let T;e[24]!==i?(T=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=T):T=e[25];let E;e[26]!==b||e[27]!==u?(E=(b||u!=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($o,{className:"size-2.5","data-icon":"inline-start"}),b]}),u!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ba,{className:"size-2.5","data-icon":"inline-start"}),u," tools"]})]}),e[26]=b,e[27]=u,e[28]=E):E=e[28];let R;e[29]!==f||e[30]!==m||e[31]!==A||e[32]!==T||e[33]!==E?(R=r.jsxs(ee,{type:"button",variant:"ghost",onClick:m,disabled:f,className:"h-auto min-w-0 flex-1 flex-col items-stretch rounded-none px-2.5 py-2 text-left whitespace-normal",children:[A,T,E]}),e[29]=f,e[30]=m,e[31]=A,e[32]=T,e[33]=E,e[34]=R):R=e[34];let I;e[35]!==g||e[36]!==p?(I=p&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(st,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=I):I=e[37];let $;return e[38]!==R||e[39]!==I||e[40]!==j?($=r.jsxs("div",{className:j,children:[R,I]}),e[38]=R,e[39]=I,e[40]=j,e[41]=$):$=e[41],$}function zM(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 td(n){return n.split(`
129
+ `).map(e=>e.trim()).find(Boolean)??""}function FM(n){return n.name==="Task"||n.name==="Agent"}function BM(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),u=zM(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:td(((i=c.prompt)==null?void 0:i.trim())||c.text.find(f=>f.trim())||"")||(d==null?void 0:d.preview)||"No task summary recorded",isBackground:c.isBackground||(d==null?void 0:d.isBackground)||!1,status:u==="seen"&&(d!=null&&d.status)?d.status:u,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(!FM(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:td(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 UM({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=xu(),i=w.useMemo(()=>{if(!e)return null;const y=Ns(e.fileName);return y?{...y,dirName:e.dirName}:null},[e]),a=w.useMemo(()=>BM(n,o),[n,o]),l=w.useRef(a);w.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=w.useMemo(()=>{if(i)return i.parentSessionId;if(e!=null&&e.fileName){const y=e.fileName.match(/^([^/]+)\.jsonl$/);if(y)return y[1]}return null},[i,e]),u=w.useMemo(()=>d?t.filter(y=>y.parentSessionId===d):t,[t,d]),f=w.useMemo(()=>new Map(c.map(y=>[y.agentId,y])),[c]),m=w.useMemo(()=>{const y=new Set(u.map(v=>v.agentId));return c.filter(v=>!y.has(v.agentId))},[u,c]),p=w.useMemo(()=>[...u].sort((y,v)=>v.modifiedAt-y.modifiedAt),[u]),h=w.useMemo(()=>[...m].reverse(),[m]),g=u.length+m.length;if(g===0)return null;const x=y=>{ve(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(y)}`,{method:"DELETE"})},b=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(Kr,{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((y,v)=>{const S=td(y.preview??""),j=f.get(y.agentId);return r.jsx(Eh,{agentId:y.agentId,subagentType:(j==null?void 0:j.subagentType)??null,agentName:(j==null?void 0:j.agentName)??null,preview:(j==null?void 0:j.preview)||(S!==y.agentId?S:""),colorIndex:v,isViewing:b===y.agentId,isBackground:!0,status:y.isActive?"running":(j==null?void 0:j.status)==="failed"?"failed":"done",durationMs:j==null?void 0:j.durationMs,toolUseCount:j==null?void 0:j.toolUseCount,disabled:!s,onStop:y.isActive?()=>x(y.agentId):void 0,onClick:()=>s==null?void 0:s(y.dirName,y.fileName)},y.agentId)}),h.map((y,v)=>{const S=!!s&&!!d&&!!e&&!y.agentId.startsWith("tool:");return r.jsx(Eh,{agentId:y.agentId,subagentType:y.subagentType,agentName:y.agentName,preview:y.preview,colorIndex:p.length+v,isViewing:b===y.agentId,isBackground:y.isBackground,status:y.status,durationMs:y.durationMs,toolUseCount:y.toolUseCount,disabled:!S,onClick:()=>{S&&s(e.dirName,`${d}/subagents/agent-${y.agentId}.jsonl`)}},y.agentId)})]})]})}function WM(n,e){return`${n.id}-${e}`}function HM(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=w.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(Kr,{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 u;e[6]!==o||e[7]!==s?(u=(f,m)=>{const p=Ga(f.userMessage),h=o===m;return r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>{i(m),s==null||s(m)},className:G("group h-auto w-full justify-start gap-2 px-2 py-1.5 text-left font-normal",h?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[r.jsx("span",{className:"mt-0.5 shrink-0 font-mono text-xs text-muted-foreground",children:String(m+1).padStart(2,"0")}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:p?Cn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:f.toolCalls.length>0&&r.jsx(Ce,{variant:"secondary",className:"font-normal",children:f.toolCalls.length})})]},WM(f,m))},e[6]=o,e[7]=s,e[8]=u):u=e[8],l=t.map(u),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}const nd=new Map;let dc=null,uc=null;async function KM(){try{const n=await ve("/api/usage-cost/rates");if(!n.ok)return nd;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return nd}}function qM(){const[n,e]=w.useState(dc??nd);return w.useEffect(()=>{if(dc!==null)return;let t=!0;return uc??(uc=KM().then(s=>(s.size>0&&(dc=s),uc=null,s))),uc.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function VM(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"?Cn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?Cn(e.query,40):e.url&&typeof e.url=="string"?Cn(e.url,40):Cn(C8(n),40)}function GM(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:pR(e,t.model,s)/t.toolCalls.length})}function YM(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=Xa(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 XM(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=qM();let i;e[0]!==o||e[1]!==t?(i=GM(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=YM(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(Kr,{children:"Tool Calls"}),e[6]=d):d=e[6];let u;if(e[7]!==s||e[8]!==c){let m;e[10]!==s?(m=p=>{const[h,g]=p;return r.jsxs(it,{children:[r.jsxs($t,{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:hn(g.estimatedCost)}),r.jsx(Ce,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(at,{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:y,turnIndex:v}=x,S=VM(y);return r.jsx("div",{children:r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(v,y.id),className:G("h-auto w-full justify-start gap-1 px-1.5 py-0.5 text-left font-mono text-xs font-normal",y.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[y.isError&&r.jsx(bn,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),r.jsx("span",{className:"truncate",children:S||y.id.slice(0,8)})]})},`${y.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],u=c.map(m),e[7]=s,e[8]=c,e[9]=u}else u=e[9];let f;return e[12]!==u?(f=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:u})})]}),e[12]=u,e[13]=f):f=e[13],f}function JM(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Ut(),{searchQuery:i,expandAll:a}=s,{actions:l}=ct(),{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 u=a?"Collapse all":"Expand all";let f;e[1]!==a?(f=a?r.jsx(Sa,{"data-icon":"inline-start"}):r.jsx(ja,{"data-icon":"inline-start"}),e[1]=a,e[2]=f):f=e[2];let m;e[3]!==c||e[4]!==u||e[5]!==f?(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":u,children:f})]}),e[3]=c,e[4]=u,e[5]=f,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(ds,{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(An,{align:"inline-start",children:r.jsx(cn,{})}),e[13]=x):x=e[13];let b;e[14]!==g?(b=r.jsxs(cs,{children:[g,x]}),e[14]=g,e[15]=b):b=e[15];let y;return e[16]!==b||e[17]!==m?(y=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]=y):y=e[18],y}const _b=w.memo(function(e){const t=B.c(48),{embedded:s,onJumpToTurn:o,onToggleServer:i,onServersChanged:a,searchInputRef:l,onLoadSession:c,backgroundAgents:d}=e,u=s===void 0?!1:s,{isMobile:f}=Ut(),{session:m,sessionSource:p}=ct(),h=m,{turns:g}=h;let x;t[0]!==h.stats.totalCacheCreationTokens||t[1]!==h.stats.totalCacheReadTokens||t[2]!==h.stats.totalInputTokens||t[3]!==h.stats.totalOutputTokens||t[4]!==g.length?(x=[h.stats.totalInputTokens,h.stats.totalOutputTokens,h.stats.totalCacheCreationTokens,h.stats.totalCacheReadTokens,g.length],t[0]=h.stats.totalCacheCreationTokens,t[1]=h.stats.totalCacheReadTokens,t[2]=h.stats.totalInputTokens,t[3]=h.stats.totalOutputTokens,t[4]=g.length,t[5]=x):x=t[5];const b=x.join(":"),y=f?"mobile-scroll w-full flex-1":u?"w-full":"view-transition-right-panel panel-enter-right w-[320px] border-l";let v;t[6]!==y?(v=G("h-full min-h-0 shrink-0 overflow-y-auto bg-background",y),t[6]=y,t[7]=v):v=t[7];let S;t[8]!==l?(S=l&&r.jsx(JM,{searchInputRef:l}),t[8]=l,t[9]=S):S=t[9];const j=f?"p-4":"p-3";let k;t[10]!==j?(k=G(j),t[10]=j,t[11]=k):k=t[11];let C;t[12]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsxs(za,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(Ln,{value:"activity",children:"Activity"}),r.jsx(Ln,{value:"agents",children:"Agents"}),r.jsx(Ln,{value:"cost",children:"Cost"}),r.jsx(Ln,{value:"issues",children:"Issues"})]}),t[12]=C):C=t[12];let N;t[13]!==o||t[14]!==g?(N=r.jsxs(zn,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(HM,{turns:g,onJumpToTurn:o}),r.jsx(XM,{turns:g,onJumpToTurn:o})]}),t[13]=o,t[14]=g,t[15]=N):N=t[15];let _;t[16]!==a||t[17]!==i||t[18]!==h.cwd||t[19]!==g?(_=r.jsx(Kg,{cwd:h.cwd,turns:g,onToggleServer:i,onServersChanged:a}),t[16]=a,t[17]=i,t[18]=h.cwd,t[19]=g,t[20]=_):_=t[20];let P;t[21]!==d?(P=d??[],t[21]=d,t[22]=P):P=t[22];let A;t[23]!==c||t[24]!==h||t[25]!==p||t[26]!==P?(A=r.jsx(UM,{session:h,sessionSource:p,bgAgents:P,onLoadSession:c}),t[23]=c,t[24]=h,t[25]=p,t[26]=P,t[27]=A):A=t[27];let T;t[28]!==_||t[29]!==A?(T=r.jsxs(zn,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[_,A]}),t[28]=_,t[29]=A,t[30]=T):T=t[30];const E=(p==null?void 0:p.dirName)??null,R=(p==null?void 0:p.fileName)??null;let I;t[31]!==b||t[32]!==E||t[33]!==R?(I=r.jsx(zn,{value:"cost",className:"pt-3",children:r.jsx(OM,{dirName:E,fileName:R,revision:b})}),t[31]=b,t[32]=E,t[33]=R,t[34]=I):I=t[34];let $;t[35]!==o||t[36]!==g?($=r.jsx(zn,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(LM,{turns:g,onJumpToTurn:o})}),t[35]=o,t[36]=g,t[37]=$):$=t[37];let M;t[38]!==T||t[39]!==I||t[40]!==$||t[41]!==k||t[42]!==N?(M=r.jsxs(La,{defaultValue:"activity",className:k,children:[C,N,T,I,$]}),t[38]=T,t[39]=I,t[40]=$,t[41]=k,t[42]=N,t[43]=M):M=t[43];let O;return t[44]!==M||t[45]!==v||t[46]!==S?(O=r.jsxs("aside",{className:v,children:[S,M]}),t[44]=M,t[45]=v,t[46]=S,t[47]=O):O=t[47],O}),QM=w.lazy(()=>qe(()=>import("./ProjectFilesPanel-3GzuQyp3.js"),__vite__mapDeps([30,1,31,2,3,4])).then(n=>({default:n.ProjectFilesPanel}))),ZM=w.lazy(()=>qe(()=>import("./WorktreePanel-D-BUTFL2.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel})));function Tb(){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(ot,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function eO(n){const e=B.c(6),{context:t,closePanel:s}=n,o=Du(),i=o.projectFilesRoot??t.projectPath;if(!i)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Tb,{}),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(w.Suspense,{fallback:a,children:r.jsx(QM,{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 tO(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(t9,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function nO(){const n=B.c(7),e=Du();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(_b,{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 sO(n){const e=B.c(8),{closePanel:t}=n,s=Du();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Tb,{}),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(w.Suspense,{fallback:o,children:r.jsx(ZM,{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 oO={id:Zo,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:Fn,component:sO,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:uw,component:eO,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"file-changes",title:"File changes",icon:Ir,component:tO,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:fw,component:nO,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},rO=kP([oO,...jM]);function ul(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 Eb(n){const e=B.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?ts(t):null,e[0]=t,e[1]=s):s=e[1];const o=s;let i;e[2]!==o?(i=o?r.jsxs(r.Fragment,{children:["What should we build in"," ",r.jsx("span",{children:o}),"?"]}):"What should we build?",e[2]=o,e[3]=i):i=e[3];let a;e[4]!==i?(a=r.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[4]=i,e[5]=a):a=e[5];let l;e[6]!==t?(l=t&&r.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:Pa(t)}),e[6]=t,e[7]=l):l=e[7];let c;return e[8]!==a||e[9]!==l?(c=r.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[a,l]}),e[8]=a,e[9]=l,e[10]=c):c=e[10],c}function iO(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G(t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function aO(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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 Ph(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx("li",{"data-slot":"breadcrumb-item",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function lO(n){const e=B.c(10);let t,s,o,i;if(e[0]!==n){const{className:c,render:d,...u}=n;t=d,i=v1,s="a",o=b1({className:G("transition-colors hover:text-foreground",c)},u),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 cO(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=G("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 dO(n){const e=B.c(12);let t,s,o;e[0]!==n?({children:t,className:s,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o):(t=e[1],s=e[2],o=e[3]);let i;e[4]!==s?(i=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=t??r.jsx(Je,{}),e[6]=t,e[7]=a):a=e[7];let l;return e[8]!==o||e[9]!==i||e[10]!==a?(l=r.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:i,...o,children:a}),e[8]=o,e[9]=i,e[10]=a,e[11]=l):l=e[11],l}function Pb(n){const e=B.c(51),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l}=n,[c,d]=w.useState(!1),[u,f]=w.useState(!1),[m,p]=w.useState(""),h=w.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),f(!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 y;e[3]!==t?(y=r.jsx(Za,{render:b,children:t}),e[3]=t,e[4]=y):y=e[4];let v;e[5]!==i||e[6]!==l||e[7]!==x?(v=(l||i)&&r.jsxs(vo,{children:[l&&r.jsxs(rn,{onClick:x,children:[r.jsx(Vs,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(rn,{onClick:i,children:[r.jsx(Rn,{"data-icon":"inline-start"}),"Duplicate session"]})]}),e[5]=i,e[6]=l,e[7]=x,e[8]=v):v=e[8];let S;e[9]!==a||e[10]!==i||e[11]!==l?(S=a&&r.jsxs(r.Fragment,{children:[(i||l)&&r.jsx(Cr,{}),r.jsx(vo,{children:r.jsxs(rn,{variant:"destructive",onClick:()=>d(!0),children:[r.jsx(va,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[9]=a,e[10]=i,e[11]=l,e[12]=S):S=e[12];let j;e[13]!==v||e[14]!==S?(j=r.jsxs(el,{className:"min-w-44",children:[v,S]}),e[13]=v,e[14]=S,e[15]=j):j=e[15];let k;e[16]!==y||e[17]!==j?(k=r.jsxs(Qa,{children:[y,j]}),e[16]=y,e[17]=j,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(Ld,{children:[C,r.jsxs(Bd,{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(Wd,{size:"sm",children:"Cancel"}),e[22]=_):_=e[22];let P;e[23]!==a?(P=r.jsxs(zd,{children:[_,r.jsx(Ud,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),d(!1)},children:"Delete"})]}),e[23]=a,e[24]=P):P=e[24];let A;e[25]!==P||e[26]!==N?(A=r.jsxs(Dd,{children:[N,P]}),e[25]=P,e[26]=N,e[27]=A):A=e[27];let T;e[28]!==c||e[29]!==A?(T=r.jsx(Od,{open:c,onOpenChange:d,children:A}),e[28]=c,e[29]=A,e[30]=T):T=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsxs(Ps,{children:[r.jsx(as,{className:"text-foreground",children:"Rename session"}),r.jsx(ls,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[31]=E):E=e[31];let R;e[32]!==l||e[33]!==m?(R=z=>{z.preventDefault(),l==null||l(m),f(!1)},e[32]=l,e[33]=m,e[34]=R):R=e[34];let I;e[35]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Nt,{htmlFor:"session-rename",children:"Session name"}),e[35]=I):I=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=z=>p(z.target.value),e[36]=$):$=e[36];let M;e[37]!==m||e[38]!==s?(M=r.jsxs(St,{children:[I,r.jsx(Lt,{id:"session-rename",ref:h,value:m,onChange:$,placeholder:s})]}),e[37]=m,e[38]=s,e[39]=M):M=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsxs(Sg,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[40]=O):O=e[40];let D;e[41]!==R||e[42]!==M?(D=r.jsxs(is,{className:"sm:max-w-md",children:[E,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:R,children:[M,O]})]}),e[41]=R,e[42]=M,e[43]=D):D=e[43];let L;e[44]!==u||e[45]!==D?(L=r.jsx(rs,{open:u,onOpenChange:f,children:D}),e[44]=u,e[45]=D,e[46]=L):L=e[46];let F;return e[47]!==T||e[48]!==L||e[49]!==k?(F=r.jsxs(r.Fragment,{children:[k,T,L]}),e[47]=T,e[48]=L,e[49]=k,e[50]=F):F=e[50],F}const Ab="session-custom-names";function Rb(){try{const n=localStorage.getItem(Kt(Ab));return n?JSON.parse(n):{}}catch{return{}}}function uO(n){localStorage.setItem(Kt(Ab),JSON.stringify(n))}let ua=Rb();const fa=new Set;if(typeof window<"u"){const n=()=>{ua=Rb();for(const e of fa)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function fO(n){return fa.add(n),()=>{fa.delete(n)}}function mO(){return ua}function sd(n,e){const t={...ua},s=e.trim();s?t[n]=s:delete t[n],uO(t),ua=t;for(const o of fa)o()}function $b(){const n=B.c(2),e=w.useSyncExternalStore(fO,mO);let t;return n[0]!==e?(t={names:e,rename:sd},n[0]=e,n[1]=t):t=n[1],t}function Ib(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(An,{children:a?r.jsx(lt,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(cn,{"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(ds,{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 u;e[9]!==s||e[10]!==t?(u=t&&r.jsx(An,{align:"inline-end",children:r.jsx(qr,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(st,{})})}),e[9]=s,e[10]=t,e[11]=u):u=e[11];let f;return e[12]!==l||e[13]!==d||e[14]!==u?(f=r.jsxs(cs,{className:"w-full sm:max-w-sm",children:[l,d,u]}),e[12]=l,e[13]=d,e[14]=u,e[15]=f):f=e[15],f}function Mb(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(bn,{"aria-hidden":"true"}),i=r.jsx(Et,{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(ht,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(At,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(Cs,{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(pt,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Ob(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(kt,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(ut,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(ut,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(ut,{className:"h-3 w-72 max-w-full"}),r.jsx(ut,{className:"h-3 w-52 max-w-full"})]}),r.jsx(ut,{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 Er(n){return n==="idle"||n==="completed"}function Yu(n){return Er(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const zs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},pO=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,hO=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,gO=/(?:^|\s)#(\d+)(?=\s|$)/,xO=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function $i(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function bO(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 Db(n){const e=n.trim();if(!e)return null;const t=pO.exec(e);if(t){const l=$i(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=hO.exec(e);if(s){const l=$i(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=gO.exec(e);if(o){const l=$i(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:bO(c)}}const i=xO.exec(e);if(!i)return null;const a=$i(i[1]);return a===null?null:{number:a,repoHint:null}}function Ah(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function vO(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 yO(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Ah(n.repo,s):Ah(n.repo,s)?!0:t.some(o=>vO(o,s)):!0}function Lb(n,e,t=[]){var i;const s=Db(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>yO(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 wO=120*1e3;function zb(n){return n?Date.now()-new Date(n).getTime()<wO:!1}function Fb(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Cn(s,70):Cn(n.sessionId,16)}function Rh(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function jO(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Rh(t)===Rh(e)?null:Cn(t,220)}function SO(n,e){return Lb(n,e)}function NO(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Un(t):null}function kO(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(`
130
+ `)}function CO(n){var t;const e=n.cwd?(t=Aa(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:mw,label:e,title:n.cwd}:n.gitBranch?{icon:Fn,label:n.gitBranch}:null}function _O(n,e){return n.agentStatus==="deferred"?"attention":e?Er(n.agentStatus)?"idle":"working":null}function TO(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(Ce,{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=Er(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=Zr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=i):i=e[5];const a=i;let l;e[6]!==t.agentStatus?(l=Yu(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=o?"bg-success/60":"bg-current";let d;e[8]!==c?(d=G("size-1.5 rounded-full",c),e[8]=c,e[9]=d):d=e[9];let u;e[10]!==d?(u=r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:d}),e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==a||e[13]!==l||e[14]!==u?(f=r.jsxs(Ce,{variant:"secondary",className:l,children:[u,a]}),e[12]=a,e[13]=l,e[14]=u,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let o;e[16]!==t.agentTerminalReason?(o=_u(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Ce,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function fc(n){const e=B.c(9),{icon:t,title:s,className:o,children:i}=n;let a;e[0]!==o?(a=G("flex items-center gap-1",o),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==t?(l=r.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==i||e[5]!==a||e[6]!==l||e[7]!==s?(c=r.jsxs("span",{className:a,title:s,children:[l,i]}),e[4]=i,e[5]=a,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function EO(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=zb(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 u,f,m,p,h,g,x,b,y,v,S,j,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=CO(t);let O;e[25]!==i||e[26]!==t.timestamp?(O=NO(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=O):O=e[27];const D=O,L=t.turnCount??0;let F,z;e[28]!==s||e[29]!==t?(z=Fb(t,s),F=jO(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",u="button",f=o,e[32]!==t?(m=kO(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(yc,{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:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",zs[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],j="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(Ce,{variant:"outline",className:"shrink-0",children:[r.jsx(wo,{"data-icon":"inline-start"}),Cn(d,18)]}),e[41]=d,e[42]=q):q=e[42];let Y;e[43]!==t.branchedFrom?(Y=t.branchedFrom&&r.jsxs(Ce,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(wd,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=Y):Y=e[44];let V;e[45]!==a||e[46]!==t?(V=r.jsx(TO,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=V):V=e[47];let J;e[48]!==i?(J=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:zr(i)}),e[48]=i,e[49]=J):J=e[49];let Q;e[50]!==V||e[51]!==J?(Q=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[V,J]}),e[50]=V,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(Ce,{variant:"outline",children:Js(t.model)}),e[60]=t.model,e[61]=b):b=e[61],e[62]!==L?(y=L>0&&r.jsxs(fc,{icon:yc,children:[L," ",L===1?"turn":"turns"]}),e[62]=L,e[63]=y):y=e[63],e[64]!==D?(v=D&&r.jsx(fc,{icon:Fs,title:"First prompt to last activity",children:D}),e[64]=D,e[65]=v):v=e[65],S=M&&r.jsx(fc,{icon:M.icon,className:"max-w-40 truncate",title:M.title,children:Cn(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]=u,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=y,e[20]=v,e[21]=S,e[22]=j,e[23]=k,e[24]=C}else u=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],y=e[19],v=e[20],S=e[21],j=e[22],k=e[23],C=e[24];let N;e[66]!==t.size?(N=rg(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 P;e[70]!==_||e[71]!==x||e[72]!==b||e[73]!==y||e[74]!==v||e[75]!==S?(P=r.jsxs("span",{className:x,children:[b,y,v,S,_]}),e[70]=_,e[71]=x,e[72]=b,e[73]=y,e[74]=v,e[75]=S,e[76]=P):P=e[76];let A;e[77]!==P||e[78]!==j||e[79]!==k||e[80]!==C?(A=r.jsxs("span",{className:j,children:[k,C,P]}),e[77]=P,e[78]=j,e[79]=k,e[80]=C,e[81]=A):A=e[81];let T;e[82]!==u||e[83]!==f||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==A?(T=r.jsxs("button",{type:u,onClick:f,title:m,className:p,children:[h,A]}),e[82]=u,e[83]=f,e[84]=m,e[85]=p,e[86]=h,e[87]=A,e[88]=T):T=e[88];let E;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(E=t.matchedPullRequestNumber?r.jsxs(Ce,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(al,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=E):E=e[91];let R;e[92]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Je,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=R):R=e[92];let I;e[93]!==E?(I=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[E,R]}),e[93]=E,e[94]=I):I=e[94];let $;return e[95]!==g||e[96]!==T||e[97]!==I?($=r.jsxs("div",{className:g,children:[T,I]}),e[95]=g,e[96]=T,e[97]=I,e[98]=$):$=e[98],$}function PO(n){const e=B.c(61),{selectedProject:t,sessions:s,sessionsTotal:o,sessionsLoading:i,searchLoading:a,searchFilter:l,setSearchFilter:c,filteredSessions:d,fetchError:u,onSelectSession:f,onNewSession:m,creatingSession:p,onDuplicateSession:h,onDeleteSession:g,onBack:x,onRetryFetch:b,loadMoreSessions:y}=n,{names:v,rename:S}=$b();let j;e[0]!==t.path?(j=ts(t.path),e[0]=t.path,e[1]=j):j=e[1];const k=j;let C;e[2]!==x?(C=r.jsx(Ph,{children:r.jsx(lO,{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(dO,{}),e[4]=N):N=e[4];let _;e[5]!==k?(_=r.jsx(Ph,{className:"min-w-0",children:r.jsx(cO,{className:"truncate",children:k})}),e[5]=k,e[6]=_):_=e[6];let P;e[7]!==C||e[8]!==_?(P=r.jsx(iO,{children:r.jsxs(aO,{children:[C,N,_]})}),e[7]=C,e[8]=_,e[9]=P):P=e[9];let A;e[10]!==k?(A=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:k}),e[10]=k,e[11]=A):A=e[11];let T;e[12]!==o?(T=r.jsx(Ce,{variant:"secondary",children:o}),e[12]=o,e[13]=T):T=e[13];let E;e[14]!==A||e[15]!==T?(E=r.jsxs("div",{className:"flex items-center gap-2",children:[A,T]}),e[14]=A,e[15]=T,e[16]=E):E=e[16];let R;e[17]!==t.path?(R=Pa(t.path),e[17]=t.path,e[18]=R):R=e[18];let I;e[19]!==R?(I=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:R}),e[19]=R,e[20]=I):I=e[20];let $;e[21]!==I||e[22]!==E?($=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[E,I]}),e[21]=I,e[22]=E,e[23]=$):$=e[23];let M;e[24]!==l||e[25]!==a||e[26]!==c?(M=r.jsx(Ib,{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 O;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(O=m&&r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(ot,{"data-icon":"inline-start"}):r.jsx(Bn,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=O):O=e[32];let D;e[33]!==M||e[34]!==O?(D=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,O]}),e[33]=M,e[34]=O,e[35]=D):D=e[35];let L;e[36]!==u||e[37]!==b?(L=u&&r.jsx(Mb,{message:u,onRetry:b}),e[36]=u,e[37]=b,e[38]=L):L=e[38];let F;e[39]!==d||e[40]!==y||e[41]!==g||e[42]!==h||e[43]!==f||e[44]!==S||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(Ob,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(dn,{className:"min-h-72 border",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(Na,{})}),r.jsx(fn,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(yn,{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(w.Fragment,{children:[H>0&&r.jsx(kt,{}),r.jsx(Pb,{sessionLabel:Fb(U),customName:v[U.sessionId],onRename:K=>S(U.sessionId,K),onDuplicate:h?()=>h(t.dirName,U.fileName):void 0,onDelete:g?()=>g(t.dirName,U.fileName):void 0,children:r.jsx(EO,{session:U,customName:v[U.sessionId],onSelect:()=>f(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:y,children:[i&&r.jsx(ot,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=y,e[41]=g,e[42]=h,e[43]=f,e[44]=S,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]!==D||e[54]!==L||e[55]!==F?(z=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[D,L,F]}),e[53]=D,e[54]=L,e[55]=F,e[56]=z):z=e[56];let W;return e[57]!==$||e[58]!==z||e[59]!==P?(W=r.jsx(Gn,{className:"h-full",children:r.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[P,$,z]})}),e[57]=$,e[58]=z,e[59]=P,e[60]=W):W=e[60],W}function AO(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=w.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=Lr(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 u;e[6]!==o?(u=G("size-3.5 shrink-0 rounded-[3px] object-contain",o),e[6]=o,e[7]=u):u=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==d||e[11]!==u?(f=r.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:d,className:u},t),e[8]=t,e[9]=c,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function Bb(n){const e=B.c(34),{children:t,projectLabel:s,customName:o,className:i,onRename:a}=n,[l,c]=w.useState(!1),[d,u]=w.useState(""),f=w.useRef(null);let m;e[0]!==o?(m=function(){u(o||""),c(!0),requestAnimationFrame(()=>{var R;return(R=f.current)==null?void 0:R.select()})},e[0]=o,e[1]=m):m=e[1];const p=m;let h;e[2]!==i?(h=G("w-full",i),e[2]=i,e[3]=h):h=e[3];let g;e[4]!==h?(g=r.jsx("div",{className:h}),e[4]=h,e[5]=g):g=e[5];let x;e[6]!==t||e[7]!==g?(x=r.jsx(Za,{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(Vs,{"data-icon":"inline-start"}),e[9]=b):b=e[9];let y;e[10]!==p?(y=r.jsx(el,{className:"min-w-44",children:r.jsx(vo,{children:r.jsxs(rn,{onClick:p,children:[b,"Rename project"]})})}),e[10]=p,e[11]=y):y=e[11];let v;e[12]!==x||e[13]!==y?(v=r.jsxs(Qa,{children:[x,y]}),e[12]=x,e[13]=y,e[14]=v):v=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(Ps,{children:[r.jsx(as,{className:"text-foreground",children:"Rename project"}),r.jsx(ls,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[15]=S):S=e[15];let j;e[16]!==a||e[17]!==d?(j=E=>{E.preventDefault(),a(d),c(!1)},e[16]=a,e[17]=d,e[18]=j):j=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(Nt,{htmlFor:"project-rename",children:"Project name"}),e[19]=k):k=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=E=>u(E.target.value),e[20]=C):C=e[20];let N;e[21]!==s||e[22]!==d?(N=r.jsxs(St,{children:[k,r.jsx(Lt,{id:"project-rename",ref:f,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(Sg,{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 P;e[25]!==N||e[26]!==j?(P=r.jsxs(is,{className:"sm:max-w-md",children:[S,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:j,children:[N,_]})]}),e[25]=N,e[26]=j,e[27]=P):P=e[27];let A;e[28]!==l||e[29]!==P?(A=r.jsx(rs,{open:l,onOpenChange:c,children:P}),e[28]=l,e[29]=P,e[30]=A):A=e[30];let T;return e[31]!==A||e[32]!==v?(T=r.jsxs(r.Fragment,{children:[v,A]}),e[31]=A,e[32]=v,e[33]=T):T=e[33],T}const Ub="project-custom-names";function Wb(){try{const n=localStorage.getItem(Kt(Ub));return n?JSON.parse(n):{}}catch{return{}}}function RO(n){localStorage.setItem(Kt(Ub),JSON.stringify(n))}let ma=Wb();const pa=new Set;if(typeof window<"u"){const n=()=>{ma=Wb();for(const e of pa)e()};window.addEventListener("cogpit-device-changed",n),window.addEventListener("cogpit-identity-changed",n)}function $O(n){return pa.add(n),()=>{pa.delete(n)}}function IO(){return ma}function MO(n,e){const t={...ma},s=e.trim();s?t[n]=s:delete t[n],RO(t),ma=t;for(const o of pa)o()}function Hb(){const n=B.c(2),e=w.useSyncExternalStore($O,IO);let t;return n[0]!==e?(t={names:e,rename:MO},n[0]=e,n[1]=t):t=n[1],t}function OO(n){const e=B.c(45),{projects:t,activeSessions:s,loading:o,refreshing:i,searchFilter:a,setSearchFilter:l,fetchError:c,selectedProjectDirName:d,onSelectProject:u,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const $ of s)zb($.lastModified)&&(m[$.dirName]=(m[$.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=Hb();let x;e:{if(!a){x=t;break e}let $;if(e[2]!==h||e[3]!==t||e[4]!==a){const M=a.toLowerCase();$=t.filter(O=>{var D;return O.path.toLowerCase().includes(M)||O.shortName.toLowerCase().includes(M)||((D=h[O.dirName])==null?void 0:D.toLowerCase().includes(M))}),e[2]=h,e[3]=t,e[4]=a,e[5]=$}else $=e[5];x=$}const b=x;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=y):y=e[6];let v;e[7]!==t.length?(v=r.jsxs("div",{className:"flex items-center gap-2",children:[y,r.jsx(Ce,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=v):v=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=S):S=e[9];let j;e[10]!==v?(j=r.jsxs("header",{className:"flex flex-col gap-1",children:[v,S]}),e[10]=v,e[11]=j):j=e[11];let k;e[12]!==a||e[13]!==l?(k=r.jsx(Ib,{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=G(C),e[15]=C,e[16]=N):N=e[16];let _;e[17]!==N?(_=r.jsx(At,{"data-icon":"inline-start",className:N}),e[17]=N,e[18]=_):_=e[18];let P;e[19]!==f||e[20]!==i||e[21]!==_?(P=r.jsxs(ee,{variant:"outline",size:"sm",onClick:f,disabled:i,"aria-label":"Refresh projects",children:[_,"Refresh"]}),e[19]=f,e[20]=i,e[21]=_,e[22]=P):P=e[22];let A;e[23]!==P||e[24]!==k?(A=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[k,P]}),e[23]=P,e[24]=k,e[25]=A):A=e[25];let T;e[26]!==c||e[27]!==f||e[28]!==d?(T=c&&!d&&r.jsx(Mb,{message:c,onRetry:f}),e[26]=c,e[27]=f,e[28]=d,e[29]=T):T=e[29];let E;e[30]!==p||e[31]!==b||e[32]!==o||e[33]!==u||e[34]!==h||e[35]!==g||e[36]!==a?(E=o?r.jsx(Ob,{}):b.length===0?r.jsx(dn,{className:"min-h-72 border",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(No,{})}),r.jsx(fn,{children:a?"No projects match your search":"No projects yet"}),r.jsx(yn,{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(($,M)=>{const O=p[$.dirName]||0,D=h[$.dirName],L=Yj(Rt($.dirName));return r.jsxs(w.Fragment,{children:[M>0&&r.jsx(kt,{}),r.jsx(Bb,{projectLabel:ts($.path),customName:D,onRename:F=>g($.dirName,F),children:r.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u($.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(AO,{projectPath:$.path,className:"size-4",fallback:r.jsx(No,{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:D||ts($.path)}),L&&r.jsx(Ce,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:L})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:Pa($.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[O>0&&r.jsxs(Ce,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),O," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[$.sessionCount," ",$.sessionCount===1?"session":"sessions"]}),$.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:zr($.lastModified)}),r.jsx(Je,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},$.dirName)})}),e[30]=p,e[31]=b,e[32]=o,e[33]=u,e[34]=h,e[35]=g,e[36]=a,e[37]=E):E=e[37];let R;e[38]!==A||e[39]!==T||e[40]!==E?(R=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,T,E]}),e[38]=A,e[39]=T,e[40]=E,e[41]=R):R=e[41];let I;return e[42]!==R||e[43]!==j?(I=r.jsx(Gn,{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:[j,R]})}),e[42]=R,e[43]=j,e[44]=I):I=e[44],I}const DO=250,LO=400,$h={results:null,loading:!1,error:null};function Kb(n,e){const t=w.useMemo(()=>Db(n),[n]),[s,o]=w.useState(0),[i,a]=w.useState($h);w.useEffect(()=>{if(!t){a($h);return}const c=new AbortController;a({results:null,loading:!0,error:null});let d=null;const u=async()=>{const m=new URLSearchParams({search:n.trim(),limit:"200"});e&&m.set("project",e);try{const p=await ve(`/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(()=>{u()},LO);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"})}},f=setTimeout(()=>{u()},DO);return()=>{clearTimeout(f),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=w.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const zO=w.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=w.useState(()=>({projects:ea(es.projects),activeSessions:ea(es.activeSessions)})),[d,u]=w.useState(c.projects??[]),[f,m]=w.useState(c.activeSessions??[]),[p,h]=w.useState(c.projects===void 0),[g,x]=w.useState(!1),[b,y]=w.useState([]),[v,S]=w.useState(0),[j,k]=w.useState(1),[C,N]=w.useState(!1),[_,P]=w.useState(""),[A,T]=w.useState(null),E=w.useRef(0),R=w.useRef(null),I=w.useCallback(async(U=!1)=>{U&&x(!0);try{const[H,K]=await Promise.all([ve("/api/projects"),ve("/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(),V=Array.isArray(q)?q:[],J=Array.isArray(Y)?Y:[];u(V),m(J),rr(es.projects,V),rr(es.activeSessions,J),T(null)}catch(H){T(H instanceof Error?H.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);w.useEffect(()=>{I()},[I]);const $=w.useCallback(async(U,H=1,K=!1)=>{var J;const q=++E.current;(J=R.current)==null||J.abort();const Y=new AbortController;R.current=Y;const V=()=>q===E.current;if(N(!0),T(null),!K){const Q=X_(U);Q?(y(Q.sessions),S(Q.total),k(1)):y([])}try{const Q=await ve(`/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(!V())return;const Z=Array.isArray(X.sessions)?X.sessions:[],te=typeof X.total=="number"?X.total:Z.length;y(ne=>K?[...ne,...Z]:Z),S(te),k(H),K||J_(U,{sessions:Z,total:te})}catch(Q){if(!V()||Y.signal.aborted)return;T(Q instanceof Error?Q.message:"Failed to load sessions")}finally{V()&&(R.current=null,N(!1))}},[]);w.useEffect(()=>{var U;if(!o){E.current+=1,(U=R.current)==null||U.abort(),R.current=null,y([]),S(0),k(1),P(""),N(!1);return}P(""),$(o)},[o,$]),w.useEffect(()=>()=>{var U;E.current+=1,(U=R.current)==null||U.abort()},[]);const M=w.useMemo(()=>{if(!o)return null;const U=d.find(K=>K.dirName===o);if(U)return U;const H=Tn(o);return{dirName:o,path:H,shortName:ts(H),sessionCount:v,lastModified:null}},[o,d,v]),O=w.useCallback(()=>{i==null||i(null)},[i]),D=w.useCallback(()=>{o&&$(o,j+1,!0)},[o,j,$]),L=Kb(o?_:"",o??void 0),F=w.useMemo(()=>_?b.filter(U=>SO(U,_)):b,[b,_]),z=L.results??F;function W(U,H){l==null||l(U,H),y(K=>K.filter(q=>q.fileName!==H)),S(K=>K-1)}return M?r.jsx(PO,{selectedProject:M,sessions:b,sessionsTotal:v,sessionsLoading:C,searchLoading:L.loading,searchFilter:_,setSearchFilter:P,filteredSessions:z,fetchError:L.error??A,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:W,onBack:O,onRetryFetch:()=>{if(L.error){L.refresh();return}T(null),o&&$(o)},loadMoreSessions:D}):r.jsx(OO,{projects:d,activeSessions:f,loading:p,refreshing:g,searchFilter:_,setSearchFilter:P,fetchError:A,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>I(!0)})});async function qb(n,e,t){return(await ve(`/api/permissions/${encodeURIComponent(n)}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,behavior:t})})).ok}async function FO(n,e){return(await ve(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({behavior:e})})).ok}async function Vb(n,e){try{const t=await ve(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 BO(n,e,t){return Vb("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function UO(n,e,t){return Vb("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const WO=3e3,Gb=w.createContext(null);async function mc(n,e){try{const t=await ve(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 qo(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 Ii(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 HO({children:n}){const[e,t]=w.useState(new Map),[s,o]=w.useState(new Map),[i,a]=w.useState(new Map),[l,c]=w.useState(new Map),[d,u]=w.useState(new Set),[f,m]=w.useState(new Set),p=w.useRef(""),h=w.useRef(""),g=w.useRef(""),x=w.useCallback(async()=>{const[T,E,R]=await Promise.all([mc("/api/permissions",p),mc("/api/user-questions",h),mc("/api/agent-prompts",g)]);T&&(t(qo(T.bySession)),u(new Set(qo(T.plansBySession).keys()))),E&&o(qo(E.bySession)),R&&(a(qo(R.elicitationsBySession)),c(qo(R.dialogsBySession)))},[]);w.useEffect(()=>{const T=()=>{document.visibilityState==="visible"&&x()};T();const E=setInterval(T,WO);return document.addEventListener("visibilitychange",T),()=>{clearInterval(E),document.removeEventListener("visibilitychange",T)}},[x]);const b=w.useCallback(async(T,E)=>{m(R=>new Set(R).add(T));try{return await E()}finally{m(R=>{const I=new Set(R);return I.delete(T),I}),x()}},[x]),y=w.useCallback((T,E,R)=>b(E,async()=>{await qb(T,E,R).catch(()=>!1)&&(t($=>Ii($,T,M=>M.requestId===E)),p.current="")}),[b]),v=w.useCallback((T,E,R)=>b(E,async()=>{const I=await $d(T,E,R);return I.ok&&(o($=>Ii($,T,M=>M.toolUseId===E)),h.current=""),I}),[b]),S=w.useCallback((T,E,R)=>b(E,async()=>{const I=await BO(T,E,R);return I.ok&&(a($=>Ii($,T,M=>M.requestId===E)),g.current=""),I}),[b]),j=w.useCallback((T,E,R)=>b(E,async()=>{const I=await UO(T,E,R);return I.ok&&(c($=>Ii($,T,M=>M.requestId===E)),g.current=""),I}),[b]),k=w.useMemo(()=>new Set(e.keys()),[e]),C=w.useMemo(()=>new Set(s.keys()),[s]),N=w.useMemo(()=>new Set(i.keys()),[i]),_=w.useMemo(()=>new Set(l.keys()),[l]),P=w.useCallback(()=>{x()},[x]),A=w.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:k,awaitingQuestion:C,awaitingElicitation:N,awaitingDialog:_,awaitingPlan:d,responding:f,respond:y,answerQuestion:v,answerElicitation:S,answerDialog:j,refresh:P}),[e,s,i,l,k,C,N,_,d,f,y,v,S,j,P]);return r.jsx(Gb.Provider,{value:A,children:n})}function KO(){const n=w.useContext(Gb);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const Yb=typeof navigator<"u"&&"vibrate"in navigator;function od(){Yb&&navigator.vibrate(10)}function qO(){Yb&&navigator.vibrate(20)}function VO(n){return!!(n.teamName&&n.agentName)}function GO(n,e,t,s,o,i,a){const l=[],c=[];for(const d of mu(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(VO(d))continue;const u=D0(d,e);if(d.agentStatus==="completed"||!u){t.has(d.sessionId)&&l.push({session:d,reason:"done"});continue}if(d.agentStatus==="idle"){l.push({session:d,reason:"waiting"});continue}(!d.agentStatus||hu.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function YO(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 Xu(n,e){return n?Vt(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const Xb="aw:turnCounts",XO=200,fl=new Map;try{const n=localStorage.getItem(Xb);if(n){const e=JSON.parse(n);for(const[t,s]of e)fl.set(t,s)}}catch{}function JO(){try{const n=[...fl.entries()].slice(-XO);localStorage.setItem(Xb,JSON.stringify(n))}catch{}}function QO(n,e){fl.set(Kt(n),e),JO()}function ZO(n,e){const t=fl.get(Kt(n));return Math.max(t??0,e??0)}function Jb(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=ZO(t.sessionId,t.turnCount);let u;e[0]!==l?(u=l&&r.jsx("span",{className:"font-medium leading-snug text-foreground",children:l}),e[0]=l,e[1]=u):u=e[1];let f;e[2]!==t.agentStatus||e[3]!==o?(f=o&&r.jsx("span",{className:G("font-medium",Yu(t.agentStatus)),children:o}),e[2]=t.agentStatus,e[3]=o,e[4]=f):f=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(os,{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(al,{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(Fn,{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(Na,{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=rg(t.size),e[17]=t.size,e[18]=b):b=e[18];let y;e[19]!==b?(y=r.jsx("span",{children:b}),e[19]=b,e[20]=y):y=e[20];let v;e[21]!==s?(v=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(pw,{className:"size-2.5"}),s.memMB," MB"]}),e[21]=s,e[22]=v):v=e[22];const S=t.lastActivityAt||t.lastModified;let j;e[23]!==S?(j=zr(S),e[23]=S,e[24]=j):j=e[24];let k;e[25]!==j?(k=r.jsx("span",{children:j}),e[25]=j,e[26]=k):k=e[26];let C;e[27]!==v||e[28]!==k||e[29]!==g||e[30]!==x||e[31]!==y?(C=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[g,x,y,v,k]}),e[27]=v,e[28]=k,e[29]=g,e[30]=x,e[31]=y,e[32]=C):C=e[32];let N;return e[33]!==u||e[34]!==C||e[35]!==f||e[36]!==m||e[37]!==p||e[38]!==h?(N=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[u,f,m,p,h,C]}),e[33]=u,e[34]=C,e[35]=f,e[36]=m,e[37]=p,e[38]=h,e[39]=N):N=e[39],N}const eD=120;function Qb(n){const e=B.c(7),t=w.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]),w.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,eD))},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 tD=6;function nD(n){const e=B.c(7),{iso:t}=n,[,s]=w.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(sD),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],w.useEffect(o,i);let a;e[3]!==t?(a=zr(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 sD(n){return n+1}const oD={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"}},rD={permission:zs.attention,deferred:zs.attention,waiting:zs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function Ih(n){const e=B.c(76),{session:t,chip:s,dotClassName:o,cardClassName:i,isActiveSession:a,proc:l,killingPids:c,customName:d,projectLabel:u,compact:f,onSelect:m,onKill:p,onResume:h,onPrefetch:g}=n,x=f===void 0?!1:f;let b;e[0]!==l||e[1]!==t.dirName?(b=Xu(Rt(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=b):b=e[2];const y=b;let v;e[3]!==s||e[4]!==y||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(v=y?"Read-only":Zr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=y,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=v):v=e[9];const S=v,j=!!h&&!y,{onHoverStart:k,onHoverEnd:C}=Qb(g),N=x?"px-2.5 py-2":"border px-2 py-2",_=a&&!x&&"ring-1 ring-ring";let P;e[10]!==i||e[11]!==N||e[12]!==_?(P=G("group relative w-full rounded-md text-left transition-colors",N,i,_),e[10]=i,e[11]=N,e[12]=_,e[13]=P):P=e[13];let A;e[14]!==x||e[15]!==a?(A=x&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=a,e[16]=A):A=e[16];const T=j&&"pr-20";let E;e[17]!==T?(E=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",T),e[17]=T,e[18]=E):E=e[18];let R;e[19]!==C||e[20]!==k||e[21]!==m||e[22]!==E?(R=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:k,onMouseLeave:C,onFocus:k,onBlur:C,className:E}),e[19]=C,e[20]=k,e[21]=m,e[22]=E,e[23]=R):R=e[23];const I=x&&"ring-0";let $;e[24]!==o||e[25]!==I?($=G("size-1.5 shrink-0 rounded-full",o,I),e[24]=o,e[25]=I,e[26]=$):$=e[26];let M;e[27]!==$?(M=r.jsx("span",{className:$,"aria-hidden":"true"}),e[27]=$,e[28]=M):M=e[28];let O;e[29]!==d||e[30]!==t?(O=M0(t,d),e[29]=d,e[30]=t,e[31]=O):O=e[31];let D;e[32]!==O?(D=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:O}),e[32]=O,e[33]=D):D=e[33];const L=x?"text-muted-foreground":s.className;let F;e[34]!==L?(F=G("shrink-0",L),e[34]=L,e[35]=F):F=e[35];const z=y?"Read-only":s.label;let W;e[36]!==F||e[37]!==z?(W=r.jsx(Ce,{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(nD,{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]!==D||e[45]!==W||e[46]!==U?(H=r.jsxs("span",{className:"flex items-center gap-1.5",children:[M,D,W,U]}),e[43]=M,e[44]=D,e[45]=W,e[46]=U,e[47]=H):H=e[47];let K;e[48]!==u?(K=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:u}),e[48]=u,e[49]=K):K=e[49];let q;e[50]!==R||e[51]!==H||e[52]!==K?(q=r.jsxs(Ot,{render:R,children:[H,K]}),e[50]=R,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]!==S?(Y=r.jsx(Dt,{side:"right",className:"max-w-[280px]",children:r.jsx(Jb,{session:t,proc:l,statusLabel:S,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=S,e[58]=Y):Y=e[58];let V;e[59]!==q||e[60]!==Y?(V=r.jsxs(Mt,{children:[q,Y]}),e[59]=q,e[60]=Y,e[61]=V):V=e[61];let J;e[62]!==j||e[63]!==h?(J=j&&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($r,{"data-icon":"inline-start"}),"Resume"]}),e[62]=j,e[63]=h,e[64]=J):J=e[64];let Q;e[65]!==y||e[66]!==c||e[67]!==p||e[68]!==l?(Q=l&&p&&!y&&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(st,{"data-icon":"inline-start"})}),e[65]=y,e[66]=c,e[67]=p,e[68]=l,e[69]=Q):Q=e[69];let X;return e[70]!==V||e[71]!==J||e[72]!==Q||e[73]!==P||e[74]!==A?(X=r.jsxs("div",{className:P,children:[A,V,J,Q]}),e[70]=V,e[71]=J,e[72]=Q,e[73]=P,e[74]=A,e[75]=X):X=e[75],X}function iD(n){const e=B.c(15),{dotClassName:t,labelClassName:s,label:o,count:i}=n;let a;e[0]!==t?(a=G("size-1.5 rounded-full",t),e[0]=t,e[1]=a):a=e[1];let l;e[2]!==a?(l=r.jsx("span",{className:a,"aria-hidden":"true"}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let d;e[6]!==o||e[7]!==c?(d=r.jsx("span",{className:c,children:o}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==i?(u=r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:i}),e[9]=i,e[10]=u):u=e[10];let f;return e[11]!==l||e[12]!==d||e[13]!==u?(f=r.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,d,u]}),e[11]=l,e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function aD(n){const e=B.c(27),{groups:t,activeSessionKey:s,procBySession:o,killingPids:i,sessionNames:a,projectNames:l,onSelectSession:c,onKill:d,onResumeSession:u,onPrefetchSession:f}=n,[m,p]=w.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,tD),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]||pu(N.cwd||Tn(N.dirName)),e[3]=l,e[4]=b):b=e[4];const y=b;let v;e[5]!==s||e[6]!==i||e[7]!==f||e[8]!==c||e[9]!==o||e[10]!==y||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:y(N),onSelect:()=>c(N.dirName,N.fileName),onPrefetch:f&&!_?()=>f(N.dirName,N.fileName):void 0}},e[5]=s,e[6]=i,e[7]=f,e[8]=c,e[9]=o,e[10]=y,e[11]=a,e[12]=v):v=e[12];const S=v;let j;e[13]!==t.needsYou||e[14]!==d||e[15]!==u||e[16]!==S?(j=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(iD,{dotClassName:zs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(N=>{const{session:_,reason:P}=N;return r.jsx(Ih,{...S(_),chip:oD[P],dotClassName:rD[P],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:P==="deferred"&&u?()=>u(_.sessionId,_.cwd,_.dirName):void 0},`${_.dirName}/${_.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=u,e[16]=S,e[17]=j):j=e[17];let k;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==S||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(Ih,{...S(N),chip:{label:YO(N),className:""},dotClassName:zs.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(tt,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=S,e[22]=g,e[23]=k):k=e[23];let C;return e[24]!==j||e[25]!==k?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[j,k]}),e[24]=j,e[25]=k,e[26]=C):C=e[26],C}function lD(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(ds,{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 u;e[6]!==i?(u=r.jsx(An,{align:"inline-start",children:i?r.jsx(lt,{className:"animate-spin"}):r.jsx(cn,{})}),e[6]=i,e[7]=u):u=e[7];let f;e[8]!==a||e[9]!==o?(f=o&&r.jsx(An,{align:"inline-end",children:r.jsx(qr,{size:"icon-xs",onClick:()=>a(""),"aria-label":"Clear session search",children:r.jsx(st,{"data-icon":"inline-start"})})}),e[8]=a,e[9]=o,e[10]=f):f=e[10];let m;e[11]!==d||e[12]!==u||e[13]!==f?(m=r.jsxs(cs,{children:[d,u,f]}),e[11]=d,e[12]=u,e[13]=f,e[14]=m):m=e[14];const p=s?"icon-sm":"icon-xs",h=t&&"animate-spin";let g;e[15]!==h?(g=G(h),e[15]=h,e[16]=g):g=e[16];let x;e[17]!==g?(x=r.jsx(At,{"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 y;return e[23]!==b||e[24]!==m?(y=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]=y):y=e[25],y}const cD=["first","second","third","fourth","fifth"];function dD(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(pt,{variant:"destructive",children:[r.jsx(bn,{}),r.jsx(Et,{children:"Could not load sessions"}),r.jsx(ht,{className:"truncate",children:t}),r.jsx(Cs,{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(dn,{className:"min-h-56 px-4 py-8",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:o?r.jsx(cn,{}):r.jsx(P1,{})}),r.jsx(fn,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(yn,{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 u;e[6]!==i||e[7]!==a?(u=i&&a===0&&r.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:cD.map(uD)}),e[6]=i,e[7]=a,e[8]=u):u=e[8];let f;return e[9]!==c||e[10]!==d||e[11]!==u?(f=r.jsxs(r.Fragment,{children:[c,d,u]}),e[9]=c,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function uD(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(ut,{className:"size-2 shrink-0 rounded-full"}),r.jsx(ut,{className:"h-4 flex-1"}),r.jsx(ut,{className:"h-4 w-10"})]},n)}function fD(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:u,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onRenameSession:x,onPrefetchSession:b,onResumeSession:y}=n,v=o!==void 0,S=t.isActive===!0,j=v||S,k=S&&Er(t.agentStatus),C=t.agentStatus==="deferred";let N;e[0]!==o||e[1]!==t.dirName?(N=Xu(Rt(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=N):N=e[2];const _=N,[P,A]=w.useState(!1),T=_?"Read-only":j?k?"Running":Zr(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,E=C?"attention":j?Er(t.agentStatus)?"idle":"working":null,R=!!(t.teamName&&t.agentName);let I;e[3]!==l||e[4]!==t?(I=M0(t,l),e[3]=l,e[4]=t,e[5]=I):I=e[5];const $=I;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:O,onHoverEnd:D}=Qb(M);let L;e[11]!==y||e[12]!==P||e[13]!==t.cwd||e[14]!==t.dirName||e[15]!==t.sessionId?(L=ge=>{ge.stopPropagation(),!(!y||P)&&(A(!0),y(t.sessionId,t.cwd,t.dirName),setTimeout(()=>A(!1),3e3))},e[11]=y,e[12]=P,e[13]=t.cwd,e[14]=t.dirName,e[15]=t.sessionId,e[16]=L):L=e[16];const F=L;let z;e[17]!==v||e[18]!==s||e[19]!==S||e[20]!==a||e[21]!==t.agentStatus?(z=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",mD(s,!S&&v&&t.agentStatus==="completed"&&!!a)),e[17]=v,e[18]=s,e[19]=S,e[20]=a,e[21]=t.agentStatus,e[22]=z):z=e[22];const W=Mt,U=Ot;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]!==D||e[28]!==O||e[29]!==H?(K=r.jsx("button",{type:"button","data-live-session":!0,onClick:H,onMouseEnter:O,onMouseLeave:D,onFocus:O,onBlur:D,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[27]=D,e[28]=O,e[29]=H,e[30]=K):K=e[30];let q;e[31]!==E?(q=E&&r.jsx("span",{"data-status-dot":E,className:G("size-1.5 rounded-full",zs[E])}),e[31]=E,e[32]=q):q=e[32];let Y;e[33]!==q?(Y=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:q}),e[33]=q,e[34]=Y):Y=e[34];let V;e[35]!==$?(V=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:$}),e[35]=$,e[36]=V):V=e[36];let J;e[37]!==R||e[38]!==t.agentName||e[39]!==$?(J=R&&r.jsxs(Ce,{variant:"outline",children:[r.jsx(wo,{"data-icon":"inline-start"}),$!==t.agentName?t.agentName:"Agent"]}),e[37]=R,e[38]=t.agentName,e[39]=$,e[40]=J):J=e[40];const Q=j&&!C&&T&&r.jsx(Ce,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",k&&"text-success",!k&&Yu(t.agentStatus)),children:T});let X;e[41]!==C?(X=C&&r.jsx(Ce,{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(Ce,{variant:"outline",children:[r.jsx(Fn,{"data-icon":"inline-start"}),c]}),e[43]=c,e[44]=Z):Z=e[44];let te;e[45]!==U||e[46]!==V||e[47]!==J||e[48]!==Q||e[49]!==X||e[50]!==Z||e[51]!==K||e[52]!==Y?(te=r.jsxs(U,{render:K,children:[Y,V,J,Q,X,Z]}),e[45]=U,e[46]=V,e[47]=J,e[48]=Q,e[49]=X,e[50]=Z,e[51]=K,e[52]=Y,e[53]=te):te=e[53];let ne;e[54]!==l||e[55]!==o||e[56]!==t||e[57]!==T||e[58]!==c?(ne=r.jsx(Dt,{side:"right",className:"max-w-[280px]",children:r.jsx(Jb,{session:t,proc:o,statusLabel:T,customName:l,worktreeName:c})}),e[54]=l,e[55]=o,e[56]=t,e[57]=T,e[58]=c,e[59]=ne):ne=e[59];let oe;e[60]!==W||e[61]!==te||e[62]!==ne?(oe=r.jsxs(W,{children:[te,ne]}),e[60]=W,e[61]=te,e[62]=ne,e[63]=oe):oe=e[63];let re;e[64]!==f||e[65]!==d||e[66]!==u?(re=!!d&&f&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:u?"Show team agents":"Hide team agents","aria-label":u?`Show ${d} team agents`:`Hide ${d} team agents`,"aria-expanded":!u,children:[r.jsx(os,{"data-icon":"inline-start"}),d,r.jsx(Je,{"data-icon":"inline-end",className:G("transition-transform duration-150",!u&&"rotate-90")})]}),e[64]=f,e[65]=d,e[66]=u,e[67]=re):re=e[67];let ae;e[68]!==F||e[69]!==C||e[70]!==_||e[71]!==y||e[72]!==P?(ae=C&&y&&!_&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:F,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[r.jsx($r,{"data-icon":"inline-start"}),"Resume"]}),e[68]=F,e[69]=C,e[70]=_,e[71]=y,e[72]=P,e[73]=ae):ae=e[73];let se;e[74]!==t.matchedPullRequestNumber||e[75]!==t.pullRequests?(se=t.matchedPullRequestNumber?r.jsxs(Ce,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(al,{pullRequests:t.pullRequests,max:1,compact:!0}),e[74]=t.matchedPullRequestNumber,e[75]=t.pullRequests,e[76]=se):se=e[76];const fe=t.lastActivityAt||t.lastModified;let le;e[77]!==fe?(le=zr(fe),e[77]=fe,e[78]=le):le=e[78];let ce;e[79]!==le?(ce=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:le}),e[79]=le,e[80]=ce):ce=e[80];let me;e[81]!==v||e[82]!==_||e[83]!==i||e[84]!==p||e[85]!==o?(me=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(st,{"data-icon":"inline-start"})}),e[81]=v,e[82]=_,e[83]=i,e[84]=p,e[85]=o,e[86]=me):me=e[86];let ue;e[87]!==oe||e[88]!==re||e[89]!==ae||e[90]!==se||e[91]!==ce||e[92]!==me||e[93]!==z?(ue=r.jsxs("div",{className:z,children:[oe,re,ae,se,ce,me]}),e[87]=oe,e[88]=re,e[89]=ae,e[90]=se,e[91]=ce,e[92]=me,e[93]=z,e[94]=ue):ue=e[94];const de=ue;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 he;e[99]!==h||e[100]!==t.dirName||e[101]!==t.fileName?(he=h?()=>h(t.dirName,t.fileName):void 0,e[99]=h,e[100]=t.dirName,e[101]=t.fileName,e[102]=he):he=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?Re=>x(t.sessionId,Re):void 0,e[106]=x,e[107]=t.sessionId,e[108]=Se):Se=e[108];let Pe;return e[109]!==l||e[110]!==de||e[111]!==ge||e[112]!==he||e[113]!==je||e[114]!==Se?(Pe=r.jsx(Pb,{sessionLabel:ge,customName:l,onDuplicate:he,onDelete:je,onRename:Se,children:de}),e[109]=l,e[110]=de,e[111]=ge,e[112]=he,e[113]=je,e[114]=Se,e[115]=Pe):Pe=e[115],Pe}return de}function mD(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function pD(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function hD(n){const e=B.c(36),{grouped:t,pendingProjectPath:s,pendingSession:o,collapsedGroups:i,searchQuery:a,activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:u,sessionNames:f,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:y,onRenameProject:v,onNewSession:S,creatingSession:j,onPrefetchSession:k,onResumeSession:C}=n;let N;e[0]!==l||e[1]!==j||e[2]!==d||e[3]!==u||e[4]!==b||e[5]!==x||e[6]!==g||e[7]!==S||e[8]!==k||e[9]!==v||e[10]!==y||e[11]!==C||e[12]!==h||e[13]!==p||e[14]!==c||e[15]!==m||e[16]!==f?(N={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:u,sessionNames:f,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:y,onRenameProject:v,onNewSession:S,creatingSession:j,onPrefetchSession:k,onResumeSession:C},e[0]=l,e[1]=j,e[2]=d,e[3]=u,e[4]=b,e[5]=x,e[6]=g,e[7]=S,e[8]=k,e[9]=v,e[10]=y,e[11]=C,e[12]=h,e[13]=p,e[14]=c,e[15]=m,e[16]=f,e[17]=N):N=e[17];const _=N;let P;e[18]!==a?(P=a.trim(),e[18]=a,e[19]=P):P=e[19];const A=!!P;let T;e[20]!==i||e[21]!==A||e[22]!==t||e[23]!==s||e[24]!==o||e[25]!==c||e[26]!==_?(T=[...t.entries()].map((I,$)=>{const[M,O]=I,D=pD(O,c);return w.createElement(Mh,{..._,key:M,projectPath:M,sessions:O,liveCount:D,collapsed:i[M]??($>=3&&D===0),forceExpand:A,pendingSession:s===M?o:void 0})}),e[20]=i,e[21]=A,e[22]=t,e[23]=s,e[24]=o,e[25]=c,e[26]=_,e[27]=T):T=e[27];let E;e[28]!==t||e[29]!==s||e[30]!==o||e[31]!==_?(E=s&&!t.has(s)&&o&&w.createElement(Mh,{..._,key:`pending-${s}`,projectPath:s,sessions:[],liveCount:0,collapsed:!1,pendingSession:o}),e[28]=t,e[29]=s,e[30]=o,e[31]=_,e[32]=E):E=e[32];let R;return e[33]!==T||e[34]!==E?(R=r.jsxs(r.Fragment,{children:[T,E]}),e[33]=T,e[34]=E,e[35]=R):R=e[35],R}function Mh(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:u,collapsed:f,onToggleCollapsed:m,forceExpand:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:y,onRenameProject:v,onNewSession:S,creatingSession:j,pendingSession:k,onPrefetchSession:C,onResumeSession:N}=n,_=p===void 0?!1:p,P=w.useId(),A=!!k,T=_||A?!1:f;let E;e[0]!==s?(E=new Set(s.map(xD)),e[0]=s,e[1]=E):E=e[1];const R=E;let I;if(e[2]!==R||e[3]!==s){const Ne=new Map,pe=[];for(const Oe of s){const Ae=Oe.teamLeadSessionId;if(Ae&&Ae!==Oe.sessionId&&R.has(Ae)){const Be=Ne.get(Ae);Be?Be.push(Oe):Ne.set(Ae,[Oe])}else pe.push(Oe)}I={topLevelSessions:pe,teammatesByLead:Ne},e[2]=R,e[3]=s,e[4]=I}else I=e[4];const{topLevelSessions:$,teammatesByLead:M}=I;let O;e[5]===Symbol.for("react.memo_cache_sentinel")?(O=new Set,e[5]=O):O=e[5];const[D,L]=w.useState(O);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=Ne=>{L(pe=>{const Oe=new Set(pe);return Oe.has(Ne)?Oe.delete(Ne):Oe.add(Ne),Oe})},e[6]=F):F=e[6];const z=F,[W,U]=w.useState(!1),H=s.length+(A?1:0);let K,q;e[7]!==_||e[8]!==A||e[9]!==i||e[10]!==W||e[11]!==$?(K=U_($,i,Math.max(1,5-(A?1:0))),q=_||W?$:$.slice(0,K),e[7]=_,e[8]=A,e[9]=i,e[10]=W,e[11]=$,e[12]=K,e[13]=q):(K=e[12],q=e[13]);const Y=q,V=$.length-Y.length,J=W&&!_&&$.length>K,Q=((We=s.find(gD))==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]!==y||e[22]!==N||e[23]!==h||e[24]!==i||e[25]!==c?(Z=function(pe,Oe,Ae){return r.jsx(fD,{session:pe,isActiveSession:o===`${pe.dirName}/${pe.fileName}`,proc:i.get(pe.sessionId),killingPids:a,isNewlyCompleted:l.has(pe.sessionId),customName:c[pe.sessionId],worktreeName:Oe,teammateCount:Ae==null?void 0:Ae.count,teammatesCollapsed:Ae==null?void 0:Ae.collapsed,onToggleTeammates:Ae==null?void 0:Ae.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:b,onRenameSession:y,onPrefetchSession:C,onResumeSession:N},`${pe.dirName}/${pe.fileName}`)},e[14]=o,e[15]=a,e[16]=l,e[17]=b,e[18]=x,e[19]=g,e[20]=C,e[21]=y,e[22]=N,e[23]=h,e[24]=i,e[25]=c,e[26]=Z):Z=e[26];const te=Z,ne=!T;let oe;e[27]!==Q||e[28]!==v?(oe=Ne=>{Q&&v&&v(Q,Ne)},e[27]=Q,e[28]=v,e[29]=oe):oe=e[29];let re;e[30]!==f||e[31]!==m||e[32]!==t?(re=()=>m(t,!f),e[30]=f,e[31]=m,e[32]=t,e[33]=re):re=e[33];const ae=!T,se=_?"Groups stay expanded while searching":void 0,fe=!T&&"rotate-90";let le;e[34]!==fe?(le=G("size-3 shrink-0 text-muted-foreground transition-transform duration-150",fe),e[34]=fe,e[35]=le):le=e[35];let ce;e[36]!==le?(ce=r.jsx(Je,{className:le}),e[36]=le,e[37]=ce):ce=e[37];const me=X||t;let ue;e[38]!==me?(ue=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:me}),e[38]=me,e[39]=ue):ue=e[39];let de;e[40]!==X||e[41]!==t?(de=X&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[40]=X,e[41]=t,e[42]=de):de=e[42];let be;e[43]!==u?(be=u>0&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":`${u} live sessions`,children:[r.jsx(Ia,{className:"size-1.5","aria-hidden":"true"}),u]}),e[43]=u,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 he;e[47]!==_||e[48]!==P||e[49]!==re||e[50]!==ae||e[51]!==se||e[52]!==ce||e[53]!==ue||e[54]!==de||e[55]!==be||e[56]!==ge?(he=r.jsxs("button",{type:"button",onClick:re,disabled:_,"aria-expanded":ae,"aria-controls":P,title:se,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:[ce,ue,de,be,ge]}),e[47]=_,e[48]=P,e[49]=re,e[50]=ae,e[51]=se,e[52]=ce,e[53]=ue,e[54]=de,e[55]=be,e[56]=ge,e[57]=he):he=e[57];let je;e[58]!==j||e[59]!==S||e[60]!==t||e[61]!==s[0]||e[62]!==s.length?(je=S&&s.length>0&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:j,onClick:Ne=>{Ne.stopPropagation();const pe=s[0];S(pe.dirName,pe.cwd??void 0)},"aria-label":`New session in ${t}`,children:j?r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(Bn,{"data-icon":"inline-start"})}),e[58]=j,e[59]=S,e[60]=t,e[61]=s[0],e[62]=s.length,e[63]=je):je=e[63];let Se;e[64]!==he||e[65]!==je?(Se=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[he,je]}),e[64]=he,e[65]=je,e[66]=Se):Se=e[66];let Pe;e[67]!==X||e[68]!==t||e[69]!==Se||e[70]!==oe?(Pe=r.jsx(Bb,{projectLabel:t,customName:X,className:"sticky top-0 z-20 bg-background",onRename:oe,children:Se}),e[67]=X,e[68]=t,e[69]=Se,e[70]=oe,e[71]=Pe):Pe=e[71];let Re;e[72]!==k?(Re=k&&r.jsx(bD,{firstMessage:k.firstMessage}),e[72]=k,e[73]=Re):Re=e[73];let $e;if(e[74]!==D||e[75]!==te||e[76]!==M||e[77]!==Y){let Ne;e[79]!==D||e[80]!==te||e[81]!==M?(Ne=pe=>{const Oe=pe.cwd??Tn(pe.dirName),Ae=Aa(Oe),Be=M.get(pe.sessionId);if(!Be)return te(pe,Ae==null?void 0:Ae.worktreeName);const ie=D.has(pe.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[te(pe,Ae==null?void 0:Ae.worktreeName,{count:Be.length,collapsed:ie,onToggle:()=>z(pe.sessionId)}),!ie&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Be.map(xe=>te(xe))})]},`${pe.dirName}/${pe.fileName}`)},e[79]=D,e[80]=te,e[81]=M,e[82]=Ne):Ne=e[82],$e=Y.map(Ne),e[74]=D,e[75]=te,e[76]=M,e[77]=Y,e[78]=$e}else $e=e[78];let De;e[83]!==V?(De=V>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>U(!0),className:"justify-start",children:[r.jsx(tt,{"data-icon":"inline-start"}),"Show ",V," more"]}),e[83]=V,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(Ar,{"data-icon":"inline-start"}),"Show less"]}),e[85]=J,e[86]=Le):Le=e[86];let ze;e[87]!==Re||e[88]!==$e||e[89]!==De||e[90]!==Le?(ze=r.jsxs("div",{className:"flex flex-col gap-px",children:[Re,$e,De,Le]}),e[87]=Re,e[88]=$e,e[89]=De,e[90]=Le,e[91]=ze):ze=e[91];let Te;e[92]!==P||e[93]!==ze?(Te=r.jsx(at,{id:P,className:"ml-3 border-l pl-1",children:ze}),e[92]=P,e[93]=ze,e[94]=Te):Te=e[94];let _e;return e[95]!==Pe||e[96]!==Te||e[97]!==ne?(_e=r.jsxs(it,{open:ne,className:"flex flex-col",children:[Pe,Te]}),e[95]=Pe,e[96]=Te,e[97]=ne,e[98]=_e):_e=e[98],_e}function gD(n){return!Aa(n.cwd??Tn(n.dirName))}function xD(n){return n.sessionId}function bD(n){const e=B.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(lt,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const o=t||"New session";let i;return e[1]!==o?(i=r.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-md bg-accent px-2 py-2 text-left",children:[s,r.jsx("span",{className:"flex-1 truncate text-xs leading-tight text-foreground",children:o})]}),e[1]=o,e[2]=i):i=e[2],i}const vD=w.memo(function(e){const t=B.c(122),{activeSessionKey:s,onSelectSession:o,onDuplicateSession:i,onDeleteSession:a,onNewSession:l,creatingSession:c,pendingSession:d,refreshRef:u,onPrefetchSession:f}=e,{names:m,rename:p}=$b(),{names:h,rename:g}=Hb(),x=Md(),b=Pn("terminal"),y=Pn("killAny"),{sessions:v,procBySession:S,newlyCompleted:j,loading:k,error:C,refresh:N,removeSession:_,acknowledgeCompleted:P}=H0(),{awaitingPermission:A,awaitingQuestion:T,awaitingElicitation:E,awaitingDialog:R,awaitingPlan:I}=KO();let $;t[0]!==R||t[1]!==E?($=new Set([...E,...R]),t[0]=R,t[1]=E,t[2]=$):$=t[2];const M=$;let O;t[3]===Symbol.for("react.memo_cache_sentinel")?(O=new Set,t[3]=O):O=t[3];const[D,L]=w.useState(O),[F,z]=w.useState("");let W,U;t[4]===Symbol.for("react.memo_cache_sentinel")?(W=Kt("live-sessions-collapsed-projects"),U={},t[4]=W,t[5]=U):(W=t[4],U=t[5]);const[H,K]=Jr(W,U);let q;t[6]!==K?(q=(Ve,Ze)=>{K(bt=>({...bt,[Ve]:Ze}))},t[6]=K,t[7]=q):q=t[7];const Y=q,V=w.useRef(v);let J;t[8]===Symbol.for("react.memo_cache_sentinel")?(J=new Set,t[8]=J):J=t[8];const Q=w.useRef(J),X=w.useRef(!1);let Z;t[9]===Symbol.for("react.memo_cache_sentinel")?(Z=(Ve,Ze)=>{if(!X.current)return;const bt=setTimeout(()=>{Q.current.delete(bt),X.current&&Ve()},Ze);Q.current.add(bt)},t[9]=Z):Z=t[9];const te=Z;let ne,oe;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()}},oe=[],t[10]=ne,t[11]=oe):(ne=t[10],oe=t[11]),w.useEffect(ne,oe);let re,ae;t[12]!==v?(re=()=>{V.current=v},ae=[v],t[12]=v,t[13]=re,t[14]=ae):(re=t[13],ae=t[14]),w.useEffect(re,ae);let se,fe;t[15]!==N||t[16]!==u?(se=()=>{if(u)return u.current=N,()=>{u.current===N&&(u.current=null)}},fe=[N,u],t[15]=N,t[16]=u,t[17]=se,t[18]=fe):(se=t[17],fe=t[18]),w.useEffect(se,fe);const le=Ya(),ce=Kb(F);let me;e:{if(!F.trim()){me=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=bt=>{const Ft=m[bt.sessionId],Jn=h[bt.dirName];return Lb(bt,F,[Ft,Jn])},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];me=Ve}const ue=me,de=ce.results??ue;let be;t[28]!==de?(be=B_(de),t[28]=de,t[29]=be):be=t[29];const ge=be;let he;t[30]!==A||t[31]!==I||t[32]!==M||t[33]!==T||t[34]!==j||t[35]!==S||t[36]!==v?(he=GO(v,S,j,A,T,M,I),t[30]=A,t[31]=I,t[32]=M,t[33]=T,t[34]=j,t[35]=S,t[36]=v,t[37]=he):he=t[37];const je=he,Se=je.needsYou.length>0||je.working.length>0;let Pe;t[38]!==Se||t[39]!==F?(Pe=!F.trim()&&Se,t[38]=Se,t[39]=F,t[40]=Pe):Pe=t[40];const Re=Pe;let $e;e:{if(!d){$e=null;break e}let Ve;t[41]!==d.cwd||t[42]!==d.dirName?(Ve=d.cwd||Tn(d.dirName),t[41]=d.cwd,t[42]=d.dirName,t[43]=Ve):Ve=t[43];let Ze;t[44]!==Ve?(Ze=pu(Ve),t[44]=Ve,t[45]=Ze):Ze=t[45],$e=Ze}const De=$e,Le=w.useRef(!1);let ze,Te;t[46]!==f||t[47]!==v?(ze=()=>{if(Le.current||!f||v.length===0)return;Le.current=!0;const Ve=mu(v).slice(0,3),Ze=globalThis,bt=()=>{for(const Zs of Ve)f(Zs.dirName,Zs.fileName)};let Ft=null,Jn=null;return typeof Ze.requestIdleCallback=="function"?Ft=Ze.requestIdleCallback(bt,{timeout:1500}):Jn=setTimeout(bt,300),()=>{Ft!=null&&typeof Ze.cancelIdleCallback=="function"&&Ze.cancelIdleCallback(Ft),Jn!=null&&clearTimeout(Jn)}},Te=[v,f],t[46]=f,t[47]=v,t[48]=ze,t[49]=Te):(ze=t[48],Te=t[49]),w.useEffect(ze,Te);let _e;t[50]!==N?(_e=async(Ve,Ze)=>{Ze.stopPropagation(),L(bt=>new Set(bt).add(Ve));try{await ve("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:Ve})}),te(N,1500)}catch{}te(()=>{L(bt=>{const Ft=new Set(bt);return Ft.delete(Ve),Ft})},2e3)},t[50]=N,t[51]=_e):_e=t[51];const We=_e;let Fe;t[52]!==P||t[53]!==o?(Fe=(Ve,Ze)=>{const bt=V.current.find(Ft=>Ft.dirName===Ve&&Ft.fileName===Ze);bt&&P(bt.sessionId),o(Ve,Ze)},t[52]=P,t[53]=o,t[54]=Fe):Fe=t[54];const Ne=Fe;let pe;t[55]!==a||t[56]!==_?(pe=Ve=>{a==null||a(Ve.dirName,Ve.fileName),_(Ve.sessionId)},t[55]=a,t[56]=_,t[57]=pe):pe=t[57];const Oe=pe;let Ae;t[58]!==N||t[59]!==x?(Ae=(Ve,Ze,bt)=>{const{command:Ft,args:Jn}=Iw(Rt(bt),Ve),Zs=`resume_${crypto.randomUUID().slice(0,8)}`;x.send({type:"spawn",id:Zs,name:`Resume ${Ve.slice(0,8)}`,command:Ft,args:Jn,cwd:Ze??void 0,metadata:{type:"terminal"}}),te(N,3e3)},t[58]=N,t[59]=x,t[60]=Ae):Ae=t[60];const Be=Ae;let ie;t[61]!==N?(ie=()=>{qO(),N()},t[61]=N,t[62]=ie):ie=t[62];let xe;t[63]!==le||t[64]!==k||t[65]!==ce.loading||t[66]!==F||t[67]!==ie?(xe=r.jsx(lD,{loading:k,isMobile:le,searchQuery:F,searchLoading:ce.loading,onSearchQueryChange:z,onRefresh:ie}),t[63]=le,t[64]=k,t[65]=ce.loading,t[66]=F,t[67]=ie,t[68]=xe):xe=t[68];const Ee=ce.error??C,Ie=de.length===0&&!d&&!k&&!ce.loading&&!C&&!ce.error;let He;t[69]!==F?(He=F.trim(),t[69]=F,t[70]=He):He=t[70];const Ke=!!He,nt=k||ce.loading,Ye=ce.active?de.length:v.length,Me=ce.error?ce.refresh:N;let Ue;t[71]!==Ee||t[72]!==Ie||t[73]!==Ke||t[74]!==nt||t[75]!==Ye||t[76]!==Me?(Ue=r.jsx(dD,{fetchError:Ee,showEmpty:Ie,searching:Ke,loading:nt,sessionCount:Ye,onRetry:Me}),t[71]=Ee,t[72]=Ie,t[73]=Ke,t[74]=nt,t[75]=Ye,t[76]=Me,t[77]=Ue):Ue=t[77];let rt;t[78]!==s||t[79]!==je||t[80]!==y||t[81]!==b||t[82]!==We||t[83]!==Be||t[84]!==Ne||t[85]!==D||t[86]!==f||t[87]!==S||t[88]!==h||t[89]!==m||t[90]!==Re?(rt=Re&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(aD,{groups:je,activeSessionKey:s,procBySession:S,killingPids:D,sessionNames:m,projectNames:h,onSelectSession:Ne,onKill:y?We:void 0,onResumeSession:b?Be:void 0,onPrefetchSession:f}),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(kt,{className:"flex-1"})]})]}),t[78]=s,t[79]=je,t[80]=y,t[81]=b,t[82]=We,t[83]=Be,t[84]=Ne,t[85]=D,t[86]=f,t[87]=S,t[88]=h,t[89]=m,t[90]=Re,t[91]=rt):rt=t[91];const Gt=y?We:void 0,Wt=a?Oe:void 0,Yt=b?Be:void 0;let Xn;t[92]!==s||t[93]!==H||t[94]!==c||t[95]!==ge||t[96]!==Ne||t[97]!==D||t[98]!==j||t[99]!==i||t[100]!==l||t[101]!==f||t[102]!==De||t[103]!==d||t[104]!==S||t[105]!==h||t[106]!==g||t[107]!==p||t[108]!==F||t[109]!==m||t[110]!==Gt||t[111]!==Wt||t[112]!==Yt||t[113]!==Y?(Xn=r.jsx(hD,{grouped:ge,pendingProjectPath:De,pendingSession:d,collapsedGroups:H,searchQuery:F,activeSessionKey:s,procBySession:S,killingPids:D,newlyCompleted:j,sessionNames:m,projectNames:h,onToggleCollapsed:Y,onSelectSession:Ne,onKill:Gt,onDuplicateSession:i,onDeleteSession:Wt,onRenameSession:p,onRenameProject:g,onNewSession:l,creatingSession:c,onPrefetchSession:f,onResumeSession:Yt}),t[92]=s,t[93]=H,t[94]=c,t[95]=ge,t[96]=Ne,t[97]=D,t[98]=j,t[99]=i,t[100]=l,t[101]=f,t[102]=De,t[103]=d,t[104]=S,t[105]=h,t[106]=g,t[107]=p,t[108]=F,t[109]=m,t[110]=Gt,t[111]=Wt,t[112]=Yt,t[113]=Y,t[114]=Xn):Xn=t[114];let Ht;t[115]!==Ue||t[116]!==rt||t[117]!==Xn?(Ht=r.jsx(Gn,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[Ue,rt,Xn]})}),t[115]=Ue,t[116]=rt,t[117]=Xn,t[118]=Ht):Ht=t[118];let Rs;return t[119]!==xe||t[120]!==Ht?(Rs=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[xe,Ht]}),t[119]=xe,t[120]=Ht,t[121]=Rs):Rs=t[121],Rs}),yD=w.memo(function(e){const t=B.c(16),{activeSessionKey:s,onSelectSession:o,onNewSession:i,creatingSession:a,isMobile:l,onDuplicateSession:c,onDeleteSession:d,pendingSession:u,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==a||t[4]!==f||t[5]!==d||t[6]!==c||t[7]!==i||t[8]!==m||t[9]!==o||t[10]!==u?(x=r.jsx(vD,{activeSessionKey:s,onSelectSession:o,onDuplicateSession:c,onDeleteSession:d,onNewSession:i,creatingSession:a,pendingSession:u,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=a,t[4]=f,t[5]=d,t[6]=c,t[7]=i,t[8]=m,t[9]=o,t[10]=u,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}),wD=w.lazy(()=>qe(()=>import("./index-BBKPLXTq.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.MissionControl})));function Zb(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ot,{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 ev(n){const e=B.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=ct(),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(yD,{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 tv(n){const e=B.c(8),{navigation:t}=n,{state:s}=Ut();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(zO,{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 jD(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Zb,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(w.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx(wD,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function SD({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function ND({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function kD({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}
131
+ `:""}${n} (${a})
132
+ ${i}
133
+ ${e}
134
+ ${i}`}const CD=w.lazy(()=>qe(()=>import("./ConfigBrowser-x0UdXG0K.js"),__vite__mapDeps([34,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),_D=w.lazy(()=>qe(()=>import("./PreviewPanel-CJdf-VLC.js"),__vite__mapDeps([35,1,2,3,4])).then(n=>({default:n.PreviewPanel})));function TD(n){const e=B.c(20),{sessionView:t,floatingChrome:s}=n,{session:o}=ct();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(nl,{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(j0,{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(ul,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=d):d=e[14];let u;return e[15]!==s||e[16]!==i||e[17]!==l||e[18]!==d?(u=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]=u):u=e[19],u}function ED(n){const e=B.c(36),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Ut(),{session:c,sessionSource:d}=ct();let u,f;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){f=Symbol.for("react.early_return_sentinel");e:if(u=l.pendingCwd??(l.pendingDirName?Tn(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(Zb,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(CD,{projectPath:ND({sessionCwd:c==null?void 0:c.cwd,pendingPath:u,sessionDirPath:d!=null&&d.dirName?Tn(d.dirName):null,dashboardProjectPath:l.dashboardProject?Tn(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(w.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],f=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]=u,e[8]=f}else u=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;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(jD,{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(TD,{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=Bs()?"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 y;e[18]!==b?(y=G("flex min-h-0 min-w-0 flex-1 flex-col bg-background",b),e[18]=b,e[19]=y):y=e[19];let v;e[20]!==p||e[21]!==u||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(Eb,{projectPath:u}),e[20]=p,e[21]=u,e[22]=s.pendingTurns,e[23]=v):v=e[23];let S;e[24]!==s.pendingComposer?(S=r.jsx(ul,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=S):S=e[25];let j;e[26]!==p||e[27]!==o?(j=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[ft("terminal")&&r.jsx(Zl,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(Gs,{"data-icon":"inline-start"}),"Terminal"]})}),ft("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(Zl,{reason:x,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>Zg(o.pendingProject),children:[r.jsx(Pr,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(Zl,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>ex(o.pendingProject),children:[r.jsx(_1,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=o,e[28]=j):j=e[28];let k;return e[29]!==y||e[30]!==v||e[31]!==S||e[32]!==j?(k=r.jsxs("div",{className:y,children:[v,S,j]}),e[29]=y,e[30]=v,e[31]=S,e[32]=j,e[33]=k):k=e[33],k}let m;return e[34]!==t?(m=r.jsx(tv,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function PD(n){const e=B.c(104),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Ut(),{session:c,sessionSource:d}=ct();let u;e[0]!==s.chatInputRef?(u=function(le){var me,ue,de;const ce=((me=s.chatInputRef.current)==null?void 0:me.getText().trimEnd())??"";(ue=s.chatInputRef.current)==null||ue.setText(ce?`${ce}
135
+
136
+ ${le}
137
+ `:`${le}
138
+ `),(de=s.chatInputRef.current)==null||de.focus()},e[0]=s.chatInputRef,e[1]=u):u=e[1];const f=u;let m;e[2]!==f?(m=function(le){const{path:ce,text:me,startLine:ue,endLine:de,comment:be}=le;f(kD({path:ce,text:me,startLine:ue,endLine:de,comment:be}))},e[2]=f,e[3]=m):m=e[3];const p=m,h=a.mainView,g=!!c;let x;e[4]!==a.mainView||e[5]!==a.pendingDirName||e[6]!==g?(x=SD({mainView:h,hasSession:g,pendingDirName:a.pendingDirName}),e[4]=a.mainView,e[5]=a.pendingDirName,e[6]=g,e[7]=x):x=e[7];const b=x,y=t.panels.handleToggleSidebar,v=t.actions.handleGoHome,S=i.onOpenCommandPalette;let j,k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=Jl("toggleSidebar"),j=Jl("commandPalette"),e[8]=j,e[9]=k):(j=e[8],k=e[9]);let C;e[10]!==i.onOpenCommandPalette||e[11]!==t.actions.handleGoHome||e[12]!==t.panels.handleToggleSidebar?(C=r.jsx(MR,{onToggleSidebar:y,onGoHome:v,onOpenCommandPalette:S,sidebarShortcut:k,commandPaletteShortcut:j}),e[10]=i.onOpenCommandPalette,e[11]=t.actions.handleGoHome,e[12]=t.panels.handleToggleSidebar,e[13]=C):C=e[13];const N=C,_=t.panels.showSidebar&&a.mainView!=="config",P=o.currentCwd??null;let A,T,E;e[14]!==f||e[15]!==t.handlers.handleLoadSessionScrollAware||e[16]!==t.panels.activeWorkspacePanel||e[17]!==o.hasFileChanges||e[18]!==o.supportsWorktrees||e[19]!==c||e[20]!==a.mainView||e[21]!==a.sessionChangeKey||e[22]!==P?(A={session:c,sessionChangeKey:a.sessionChangeKey,projectPath:P,hasFileChanges:o.hasFileChanges,canAccessHostFiles:ft("hostFiles"),supportsWorktrees:o.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:f},E=eb(rO,A),T=a.mainView==="sessions"?E.find(fe=>fe.id===t.panels.activeWorkspacePanel):null,e[14]=f,e[15]=t.handlers.handleLoadSessionScrollAware,e[16]=t.panels.activeWorkspacePanel,e[17]=o.hasFileChanges,e[18]=o.supportsWorktrees,e[19]=c,e[20]=a.mainView,e[21]=a.sessionChangeKey,e[22]=P,e[23]=A,e[24]=T,e[25]=E):(A=e[23],T=e[24],E=e[25]);const R=T,I=(d==null?void 0:d.dirName)??a.pendingDirName??a.dashboardProject??null;let $;e[26]!==t.panels||e[27]!==o?($=function(le){o.showPreview&&o.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(le)},e[26]=t.panels,e[27]=o,e[28]=$):$=e[28];const M=$;let O;e[29]!==t.panels||e[30]!==o?(O=function(le){o.showPreview&&o.onCloseRightWorkspace(),t.panels.openWorkspacePanel(le)},e[29]=t.panels,e[30]=o,e[31]=O):O=e[31];const D=O;let L;e[32]!==t.actions||e[33]!==t.panels||e[34]!==I?(L=function(le){I&&(t.actions.handleDashboardSelect(I,`${le}.jsonl`),t.panels.closeWorkspacePanel())},e[32]=t.actions,e[33]=t.panels,e[34]=I,e[35]=L):L=e[35];const F=L,z=t.panels.showSidebar;let W;e[36]===Symbol.for("react.memo_cache_sentinel")?(W=Jl("toggleSidebar"),e[36]=W):W=e[36];let U;e[37]!==i.killing||e[38]!==i.onKillAll||e[39]!==l.openConfigDialog||e[40]!==t.creatingSession||e[41]!==t.handlers.handleDuplicateSession||e[42]!==t.onStartNewSession||e[43]!==t.panels.handleToggleSidebar||e[44]!==t.panels.showSidebar||e[45]!==o.onOpenTerminal||e[46]!==s.onBackToMain||e[47]!==s.onShowWorkflows||e[48]!==s.workflowCount||e[49]!==_?(U=r.jsx(RR,{showSidebar:z,sidebarRendered:_,sidebarShortcut:W,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[37]=i.killing,e[38]=i.onKillAll,e[39]=l.openConfigDialog,e[40]=t.creatingSession,e[41]=t.handlers.handleDuplicateSession,e[42]=t.onStartNewSession,e[43]=t.panels.handleToggleSidebar,e[44]=t.panels.showSidebar,e[45]=o.onOpenTerminal,e[46]=s.onBackToMain,e[47]=s.onShowWorkflows,e[48]=s.workflowCount,e[49]=_,e[50]=U):U=e[50];const H=U;let K;e[51]!==t||e[52]!==N||e[53]!==_?(K=_&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(ev,{navigation:t,header:N})}),e[51]=t,e[52]=N,e[53]=_,e[54]=K):K=e[54];const q=R??null,Y=o.projectFilesRoot??o.currentCwd??null;let V;e[55]!==p||e[56]!==t.actions.handleJumpToTurn||e[57]!==t.handlers.handleLoadSessionScrollAware||e[58]!==F||e[59]!==o.backgroundAgents||e[60]!==o.processPanel.handleServersChanged||e[61]!==o.processPanel.handleToggleServer||e[62]!==o.projectFilesRequest||e[63]!==o.worktrees||e[64]!==s.searchInputRef||e[65]!==Y||e[66]!==I?(V={projectFilesRoot:Y,projectFilesRequest:o.projectFilesRequest,backgroundAgents:o.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:p,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:o.processPanel.handleToggleServer,serversChanged:o.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:o.worktrees,worktreeDirName:I,openWorktreeSession:F},e[55]=p,e[56]=t.actions.handleJumpToTurn,e[57]=t.handlers.handleLoadSessionScrollAware,e[58]=F,e[59]=o.backgroundAgents,e[60]=o.processPanel.handleServersChanged,e[61]=o.processPanel.handleToggleServer,e[62]=o.projectFilesRequest,e[63]=o.worktrees,e[64]=s.searchInputRef,e[65]=Y,e[66]=I,e[67]=V):V=e[67];const J=a.mainView==="mission";let Q;e[68]!==t.panels.handleToggleMission||e[69]!==J?(Q={id:"mission-control",title:"Mission Control",icon:hw,active:J,onSelect:t.panels.handleToggleMission},e[68]=t.panels.handleToggleMission,e[69]=J,e[70]=Q):Q=e[70];let X;e[71]!==t.panels.handleToggleConfig||e[72]!==a.mainView?(X=ft("configWrite")?[{id:"config",title:"Config",icon:gw,active:a.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[71]=t.panels.handleToggleConfig,e[72]=a.mainView,e[73]=X):X=e[73];let Z;e[74]!==Q||e[75]!==X?(Z=[Q,...X],e[74]=Q,e[75]=X,e[76]=Z):Z=e[76];const te=b!=="session"&&H;let ne;e[77]!==H||e[78]!==t||e[79]!==o||e[80]!==s||e[81]!==b?(ne=r.jsx(ED,{navigation:t,sessionView:s,project:o,view:b,floatingChrome:H}),e[77]=H,e[78]=t,e[79]=o,e[80]=s,e[81]=b,e[82]=ne):ne=e[82];let oe;e[83]!==te||e[84]!==ne?(oe=r.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[te,ne]}),e[83]=te,e[84]=ne,e[85]=oe):oe=e[85];let re;e[86]!==t.panels.closeWorkspacePanel||e[87]!==D||e[88]!==A||e[89]!==q||e[90]!==V||e[91]!==Z||e[92]!==oe||e[93]!==M||e[94]!==E?(re=r.jsx(WR,{panels:E,context:A,activePanel:q,services:V,onClosePanel:t.panels.closeWorkspacePanel,onOpenPanel:D,onTogglePanel:M,actions:Z,children:oe}),e[86]=t.panels.closeWorkspacePanel,e[87]=D,e[88]=A,e[89]=q,e[90]=V,e[91]=Z,e[92]=oe,e[93]=M,e[94]=E,e[95]=re):re=e[95];let ae;e[96]!==o.currentCwd||e[97]!==o.onCloseRightWorkspace||e[98]!==o.showPreview?(ae=o.showPreview&&o.currentCwd&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(_D,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[96]=o.currentCwd,e[97]=o.onCloseRightWorkspace,e[98]=o.showPreview,e[99]=ae):ae=e[99];let se;return e[100]!==K||e[101]!==re||e[102]!==ae?(se=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[K,re,ae]}),e[100]=K,e[101]=re,e[102]=ae,e[103]=se):se=e[103],se}function AD(n){const e=B.c(16),{navigation:t,sessionView:s,project:o,chrome:i}=n,{theme:a}=Ut(),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(k0,{}),d=r.jsx(N0,{}),e[0]=c,e[1]=d):(c=e[0],d=e[1]);let u;e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s?(u=r.jsx(PD,{navigation:t,sessionView:s,project:o,chrome:i}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=u):u=e[6];let f;e[7]!==i||e[8]!==t||e[9]!==o?(f=r.jsx(OP,{navigation:t,project:o,chrome:i}),e[7]=i,e[8]=t,e[9]=o,e[10]=f):f=e[10];let m;return e[11]!==i.backgroundServers||e[12]!==l||e[13]!==u||e[14]!==f?(m=r.jsxs("div",{className:l,children:[i.backgroundServers,c,d,u,f]}),e[11]=i.backgroundServers,e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}const RD=[{id:"sessions",label:"Sessions",icon:No},{id:"chat",label:"Chat",icon:Na},{id:"stats",label:"Stats",icon:E1,requiresSession:!0}],$D=w.memo(function(e){const t=B.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=ct(),l=i!==null;let c,d,u;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=RD.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:()=>{od(),o(g.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",b?"text-foreground":"text-muted-foreground hover:text-foreground"),children:r.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",b?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",b&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(Ia,{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],u=p.map(h),t[0]=s,t[1]=l,t[2]=a,t[3]=o,t[4]=c,t[5]=d,t[6]=u}else c=t[4],d=t[5],u=t[6];let f;return t[13]!==c||t[14]!==d||t[15]!==u?(f=r.jsx("nav",{className:c,"aria-label":d,children:u}),t[13]=c,t[14]=d,t[15]=u,t[16]=f):f=t[16],f});function ID(n){const e=B.c(63),{session:t,sessionSource:s,isSubAgentView:o,claudeRawMessages:i,creatingSession:a,onNewSession:l,onDuplicateSession:c,onBackToMain:d,onShowFileChanges:u,hasFileChanges:f,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 y=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(bd,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=v):v=e[6];let S,j;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Iu,{compact:!0}),j=r.jsx(kt,{orientation:"vertical",className:"h-4"}),e[7]=S,e[8]=j):(S=e[7],j=e[8]);let k;e[9]!==i?(k=r.jsx(Tg,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=k):k=e[10];let C;e[11]!==t.cwd?(C=t.cwd?ts(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(qn,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(T1,{"data-icon":"inline-start"})}),e[15]=_):_=e[15];let P;e[16]!==t.cwd?(P=t.cwd?ts(t.cwd):"Current session",e[16]=t.cwd,e[17]=P):P=e[17];let A;e[18]!==P?(A=r.jsx("span",{className:"truncate text-foreground",children:P}),e[18]=P,e[19]=A):A=e[19];let T;e[20]!==t.gitBranch||e[21]!==t.model?(T=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=T):T=e[22];let E;e[23]!==T?(E=r.jsx("span",{className:"truncate font-normal",children:T}),e[23]=T,e[24]=E):E=e[24];let R;e[25]!==A||e[26]!==E?(R=r.jsxs(Us,{className:"flex flex-col gap-0.5",children:[A,E]}),e[25]=A,e[26]=E,e[27]=R):R=e[27];let I;e[28]!==a||e[29]!==y||e[30]!==s?(I=s&&r.jsxs(Pt,{onClick:y,disabled:a,children:[a?r.jsx(ot,{}):r.jsx(Bn,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=y,e[30]=s,e[31]=I):I=e[31];let $;e[32]!==c?($=c&&r.jsxs(Pt,{onClick:c,children:[r.jsx(Rn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=$):$=e[33];let M;e[34]!==R||e[35]!==I||e[36]!==$?(M=r.jsxs(tn,{children:[R,I,$]}),e[34]=R,e[35]=I,e[36]=$,e[37]=M):M=e[37];let O;e[38]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(gr,{}),e[38]=O):O=e[38];let D;e[39]!==h?(D=h&&r.jsxs(Pt,{onClick:h,children:[r.jsx(cn,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=D):D=e[40];let L;e[41]!==g||e[42]!==x?(L=x&&r.jsxs(Pt,{onClick:x,children:[g?r.jsx(Sa,{}):r.jsx(ja,{}),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]!==f||e[45]!==u?(F=f&&u&&r.jsxs(Pt,{onClick:u,children:[r.jsx(Ir,{}),r.jsx("span",{children:"File changes"})]}),e[44]=f,e[45]=u,e[46]=F):F=e[46];let z;e[47]!==m||e[48]!==p?(z=m&&(p??0)>0&&r.jsxs(Pt,{onClick:m,children:[r.jsx(Nd,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Ce,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=z):z=e[49];let W;e[50]!==D||e[51]!==L||e[52]!==F||e[53]!==z?(W=r.jsxs(tn,{children:[D,L,F,z]}),e[50]=D,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(Kn,{children:[_,r.jsxs(Vn,{align:"end",sideOffset:6,className:"w-72",children:[M,O,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,S,j,k,N,U]}),e[58]=v,e[59]=U,e[60]=k,e[61]=N,e[62]=H):H=e[62],H}const MD=w.memo(function(e){const t=B.c(11),{isMobile:s}=Ut(),{session:o,sessionSource:i}=ct();if(!s||!o)return null;let a;t[0]!==i?(a=i?Ns(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=ko(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,u=l!==null;let f;return t[5]!==d||t[6]!==e||t[7]!==o||t[8]!==i||t[9]!==u?(f=r.jsx(ID,{...e,onDuplicateSession:e.onDuplicateSession,session:o,sessionSource:i,isSubAgentView:u,claudeRawMessages:d}),t[5]=d,t[6]=e,t[7]=o,t[8]=i,t[9]=u,t[10]=f):f=t[10],f});function OD({onSwipeLeft:n,onSwipeRight:e,threshold:t=50,enabled:s=!0}){const o=w.useRef(null),i=w.useRef(null),a=w.useRef(n),l=w.useRef(e);return a.current=n,l.current=e,w.useEffect(()=>{const c=o.current;if(!c||!s)return;function d(f){const m=f.touches[0];i.current={x:m.clientX,y:m.clientY}}function u(f){var g,x;if(!i.current)return;const m=f.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",u,{passive:!0}),()=>{c.removeEventListener("touchstart",d),c.removeEventListener("touchend",u)}},[s,t]),o}const DD=["sessions","chat","stats"];function LD({hasSession:n,hasPendingSession:e}){return DD.filter(t=>!(t==="stats"&&!n&&!e))}function Oh(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const zD=w.lazy(()=>qe(()=>import("./MobileFileChanges-B4dwGXMS.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function FD(n){const e=B.c(71),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,theme:l}=Ut(),{session:c,isSubAgentView:d}=ct(),u=!!c,f=!!a.pendingDirName;let m;e[0]!==u||e[1]!==f?(m=LD({hasSession:u,hasPendingSession:f}),e[0]=u,e[1]=f,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=Oh(p,a.mobileTab,1);F&&(od(),t.actions.handleMobileTabChange(F))},onSwipeRight:()=>{const F=Oh(p,a.mobileTab,-1);F&&(od(),t.actions.handleMobileTabChange(F))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=p,e[6]=h):h=e[6];const g=OD(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,y=`${l.themeClasses} flex h-dvh flex-col bg-background text-foreground`,v=i.backgroundServers;let S,j;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(k0,{}),j=r.jsx(N0,{}),e[10]=S,e[11]=j):(S=e[10],j=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(Iu,{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?(_=G("flex min-h-0 min-w-0 flex-1",N),e[15]=N,e[16]=_):_=e[16];let P;e[17]!==t||e[18]!==a.mobileTab?(P=a.mobileTab==="sessions"&&r.jsx(ev,{navigation:t,mobile:!0}),e[17]=t,e[18]=a.mobileTab,e[19]=P):P=e[19];let A;e[20]!==i||e[21]!==d||e[22]!==t||e[23]!==o||e[24]!==c||e[25]!==s||e[26]!==a.expandAll||e[27]!==a.mobileTab||e[28]!==a.pendingDirName?(A=a.mobileTab==="chat"&&r.jsx("div",{className:"flex flex-1 min-h-0 flex-col min-w-0",children:c?r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,r.jsx(MD,{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(nl,{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(Eb,{projectPath:s.pendingPath??null}),ft("terminal")&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(Gs,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(tv,{navigation:t})}),e[20]=i,e[21]=d,e[22]=t,e[23]=o,e[24]=c,e[25]=s,e[26]=a.expandAll,e[27]=a.mobileTab,e[28]=a.pendingDirName,e[29]=A):A=e[29];let T;e[30]!==t.handlers||e[31]!==o||e[32]!==c||e[33]!==a.mobileTab?(T=a.mobileTab==="stats"&&c&&r.jsx(_b,{onJumpToTurn:t.handlers.handleMobileJumpToTurn,onToggleServer:o.processPanel.handleToggleServer,onServersChanged:o.processPanel.handleServersChanged,onLoadSession:t.handlers.handleLoadSessionScrollAware,backgroundAgents:o.backgroundAgents}),e[30]=t.handlers,e[31]=o,e[32]=c,e[33]=a.mobileTab,e[34]=T):T=e[34];let E;e[35]!==a.mobileTab||e[36]!==_||e[37]!==P||e[38]!==A||e[39]!==T?(E=r.jsxs("div",{className:_,children:[P,A,T]},C),e[35]=a.mobileTab,e[36]=_,e[37]=P,e[38]=A,e[39]=T,e[40]=E):E=e[40];let R;e[41]!==g||e[42]!==E?(R=r.jsx("main",{ref:g,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:E}),e[41]=g,e[42]=E,e[43]=R):R=e[43];const I=a.mobileTab==="chat"&&i.processPanel;let $;e[44]!==c||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?($=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]=$):$=e[48];let M;e[49]!==I||e[50]!==$?(M=r.jsxs("div",{className:"shrink-0",children:[I,$]}),e[49]=I,e[50]=$,e[51]=M):M=e[51];let O;e[52]!==b||e[53]!==a.mobileTab?(O=r.jsx($D,{activeTab:a.mobileTab,onTabChange:b}),e[52]=b,e[53]=a.mobileTab,e[54]=O):O=e[54];let D;e[55]!==i||e[56]!==o||e[57]!==c||e[58]!==a.sessionChangeKey?(D=c&&o.hasFileChanges&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(zD,{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]=D):D=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]!==R||e[66]!==M||e[67]!==O||e[68]!==D||e[69]!==y?(L=r.jsxs("div",{className:y,children:[v,S,j,k,R,M,i.workflowsPanel,O,i.undoDialog,i.branchModal,D]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=k,e[65]=R,e[66]=M,e[67]=O,e[68]=D,e[69]=y,e[70]=L):L=e[70],L}function BD(n){const e=B.c(13),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{theme:d,isMobile:u}=Ut(),{session:f}=ct(),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]!==u||e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==f||e[8]!==t?(p=f?r.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[r.jsx(nl,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),u?i:r.jsx(ul,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(dn,{className:"max-w-md",children:r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:s?r.jsx(qt,{}):r.jsx(lt,{className:"animate-spin"})}),r.jsx(fn,{children:s?"Unable to open session":"Opening session"}),r.jsx(yn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})}),e[0]=i,e[1]=a,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=o,e[7]=f,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 UD=5;function Mi(n,e){const t=kn(),s=js();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class WD{constructor(){hi(this,"cache",new Map)}get(e,t){const s=Mi(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=Mi(e,t);!this.cache.has(d)&&this.cache.size>=UD&&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=Mi(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(Mi(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 _n=new WD,Dh={};function nv(n,e,t,s,o,i){const[a,l]=w.useState(!1),[c,d]=w.useState("disconnected"),[u,f]=w.useState(!1),[m,p]=w.useState(null),[h,g]=w.useState(Dh),[x,b]=w.useState(null),[y,v]=w.useState(ho),S=w.useRef(""),j=w.useRef(null),k=w.useRef(ho),C=w.useRef("disconnected"),N=w.useRef(e);N.current=e;const _=w.useRef(o);_.current=o;const P=w.useRef(t);P.current=t;const A=w.useRef(s);A.current=s;const T=w.useRef(i??null);T.current=i??null;const E=w.useRef(!1),R=(n==null?void 0:n.dirName)??null,I=(n==null?void 0:n.fileName)??null,$=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode($).byteLength;return w.useEffect(()=>{if(S.current=$,!$){j.current=null,l(!1);return}const O=T.current;if(O){j.current=O;return}P.current($).then(D=>{j.current=D})},[$]),w.useEffect(()=>{if(b(null),!R||!I){l(!1),d("disconnected");return}d("connecting");const O=`/api/watch/${encodeURIComponent(R)}/${encodeURIComponent(I)}?offset=${M}`,D=new EventSource(Lr(O));let L=null;const F=(ae=3e4)=>{L&&clearTimeout(L),L=setTimeout(()=>{l(!1),f(!1)},ae)};let z="",W=M,U=!1,H=!1,K=!1,q=null;const Y=()=>{K=!1,q=null,j.current&&N.current(j.current)},V=()=>{K||(K=!0,q=requestAnimationFrame(Y))};let J=!1,Q=null,X=null;const Z=()=>{J=!1,Q=null,v(k.current)},te=()=>{J||(J=!0,Q=requestAnimationFrame(Z))},ne=ae=>{ae!==k.current&&(k.current=ae,te(),ae.length>0&&!X&&(X=setInterval(()=>{const se=m7(k.current);se!==k.current&&(k.current=se,te()),k.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},oe=()=>{ne(ho),g(Dh)},re=()=>{if(H||U||!z)return;const ae=z;z="",U=!0;const se=j.current;(se?A.current(se,ae):P.current(S.current)).then(le=>{H||(j.current=le,R&&I&&_n.update(R,I,{parsed:le,source:{rawText:S.current,watchOffset:W}}),V())}).catch(le=>{console.error("[useLiveSession] worker parse failed:",le)}).finally(()=>{U=!1,!H&&z&&re()})};return D.onopen=()=>{var ae;if(C.current!=="connected"){const se=E.current;E.current=!1,C.current="connected",d("connected"),se&&((ae=_.current)==null||ae.call(_))}},D.onmessage=ae=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const se=JSON.parse(ae.data);if(se.type==="init")se.recentlyActive?(l(!0),F(5e3)):F();else if(se.type==="compacting_in_progress")l(!0),f(!0),oe(),F();else if(se.type==="subagent_activity")l(!0),F();else if(se.type==="runtime_activity")l(!0),F();else if(se.type==="stream_snapshot")l(!0),F(),ne(d7(se.messages??[]));else if(se.type==="stream_delta")l(!0),F(),p(null),b(null),ne(u7(k.current,se.events??[]));else if(se.type==="agent_progress")l(!0),F(),g(fe=>({...fe,[se.toolUseId]:se.summary}));else if(se.type==="prompt_suggestion")b(typeof se.suggestion=="string"?se.suggestion:null);else if(se.type==="turn_error")p(typeof se.message=="string"?se.message:"The turn failed");else if(se.type==="stream_clear")oe();else if(se.type==="lines"&&se.lines.length>0){l(!0),f(!1),F(),ne(f7(k.current,se.lines));const fe=se.lines.join(`
139
+ `)+`
140
+ `;W+=new TextEncoder().encode(fe).byteLength,S.current+=fe,z+=fe,re()}}catch(se){console.error("[useLiveSession] Error processing SSE message:",se)}},D.onerror=()=>{l(!1),f(!1),E.current=C.current==="connected",C.current="disconnected",d("disconnected"),oe()},()=>{H=!0,D.close(),l(!1),C.current="disconnected",d("disconnected"),L&&clearTimeout(L),q!==null&&cancelAnimationFrame(q),Q!==null&&cancelAnimationFrame(Q),X&&clearInterval(X),k.current=ho,v(ho)}},[R,I,$,M]),{isLive:a,sseState:c,isCompacting:u,streamingOverlay:y,turnError:m,agentProgress:h,promptSuggestion:x}}const HD=3e4;function sv(n,e,t){const s=B.c(9),o=HD,[i,a]=w.useState(!1),l=w.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]),w.useEffect(c,d);let u,f;s[3]!==o||s[4]!==n?(u=()=>{if(!n){a(!1);return}let p=!0,h=null;const g=new EventSource(Lr(n));a(!1);const x=()=>{h&&clearTimeout(h),h=setTimeout(()=>{p&&a(!1)},o)};return g.onmessage=b=>{if(p)try{const y=JSON.parse(b.data);y.type==="init"?x():y.type==="update"&&(a(!0),x(),l.current())}catch{}},g.onerror=()=>{p&&a(!1)},()=>{p=!1,g.close(),h&&clearTimeout(h)}},f=[n,o],s[3]=o,s[4]=n,s[5]=u,s[6]=f):(u=s[5],f=s[6]),w.useEffect(u,f);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function KD(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return sv(t,e)}function qD(n,e){const[t,s]=w.useState(null),o=w.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 u=new URLSearchParams({leadSessionId:l});return c&&u.set("subagentFile",c),e&&u.set("dirName",e),u.toString()})();o.current=i;const a=w.useCallback(async()=>{const l=o.current;if(l)try{const c=await ve(`/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 w.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),KD((t==null?void 0:t.teamName)??null,a),t}function VD(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),sv(o,s)}function GD(n,e,t=!0){const[s,o]=w.useState([]),[i,a]=w.useState(!1),l=w.useRef(0),c=!!n&&!!e,d=w.useCallback(async()=>{const m=++l.current;if(!c){o([]);return}try{const p=await ve(`/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]);w.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const u=c&&(t||s.length>0),{isLive:f}=VD(u?n:null,u?e:null,null,d);return{workflows:s,loading:i,isLive:f,refetch:d}}const ha={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},YD="cogpit:permissions";function XD(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 Lh(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function ov(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 Lh(l,i(l));return!l.ok&&t==="codex"&&e&&XD(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await Lh(l,i(l))),{res:l,errorMessage:c}}function JD({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:o,model:i,effort:a,fastMode:l,ultracode:c,mcpConfig:d,onModelRejected:u,readOnly:f=!1,onCreateSession:m}){const[p,h]=w.useState("idle"),[g,x]=w.useState(),[b,y]=w.useState([]),v=w.useRef(null),S=w.useRef(null),j=w.useRef(!1),k=n!=null&&n.fileName?jc(n.fileName):null,C=e||k,N=n?Rt(n.dirName):null,_=w.useCallback(()=>{var $;($=v.current)==null||$.abort(),v.current=null,j.current=!1,h("idle"),x(void 0),y([])},[]);w.useEffect(()=>{var $;S.current!==C&&(j.current?(j.current=!1,($=v.current)==null||$.abort(),v.current=null,h("idle"),x(void 0)):_(),S.current=C)},[C,_]),w.useEffect(()=>()=>{var $;($=v.current)==null||$.abort()},[]),w.useEffect(()=>{f&&_()},[f,_]);const P=w.useCallback(async($,M)=>{if(f)return;if(!C&&m){y(L=>[...L,$]),h("connected"),x(void 0),j.current=!0,o==null||o();try{if(!await m($,M)){j.current=!1,h("idle"),y([]);return}h("idle")}catch(L){j.current=!1,x(L instanceof Error?L.message:"Failed to create session"),h("error"),y([])}return}if(!C)return;y(L=>[...L,$]),h("connected"),x(void 0);const O=s??ha;o==null||o();const D=new AbortController;v.current=D;try{const L={sessionId:C,message:$,images:M||void 0,cwd:t||void 0,permissions:O,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:F,errorMessage:z}=await ov(W=>ve("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,model:W}),signal:D.signal}),{model:i,agentKind:N,errorFallback:W=>`Request failed (${W.status})`,onModelRejected:u});v.current===D&&(F.ok?h("idle"):(x(z||`Request failed (${F.status})`),h("error"),y(W=>W.slice(0,-1))))}catch(L){if(L instanceof Error&&L.name==="AbortError")return;v.current===D&&(x(L instanceof Error?L.message:"Unknown error"),h("error"),y(F=>F.slice(0,-1)))}},[C,N,t,s,o,i,a,l,c,d,u,f,m]),A=w.useCallback(()=>{_()},[_]),T=w.useCallback(()=>{!C||f||ve("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,f]),E=w.useCallback(()=>{var $;($=v.current)==null||$.abort(),v.current=null,T(),h("idle"),y([])},[T]),R=E,I=w.useCallback(($=1)=>{y(M=>M.slice($))},[]);return{status:p,error:g,pendingMessages:b,sendMessage:P,disconnect:A,interrupt:E,stopAgent:R,consumePending:I,isConnected:p==="connected"}}const ms={expandAll:!1,expandToolPayloads:!1},QD={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ms,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function zh(n,e,t,s){const o=R2(e,t,s);return o===n.turns?n:{...n,turns:o}}function uo(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function ZD(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...uo(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ms,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...uo(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ms,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...uo(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...ms,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,...ms};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,...ms}:{...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:zh(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:zh(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...uo(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,...uo(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ms,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...uo(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ms,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 rv(){return w.useReducer(ZD,QD)}function Fh(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function iv({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialContentLen:i=0}){const a=w.useRef(null),l=w.useRef(null),c=w.useRef(!0),d=w.useRef(!1),u=w.useRef(0),f=w.useMemo(()=>(n==null?void 0:n.turns.flatMap(D=>D.contentBlocks.flatMap(L=>L.kind==="queued_prompt"?[{id:JSON.stringify([L.timestamp??"",L.content]),content:L.content}]:[])))??[],[n==null?void 0:n.turns]),m=w.useRef(null),p=w.useRef(!1),[h,g]=w.useState(!1),[x,b]=w.useState(!1),[y,v]=w.useState(null),S=w.useCallback(()=>{requestAnimationFrame(()=>{var D;(D=l.current)==null||D.scrollIntoView({behavior:"smooth"})})},[]),j=w.useCallback(()=>{Fh(()=>{const D=a.current;D&&(D.scrollTop=D.scrollHeight),c.current=!0,d.current=!1})},[]),k=w.useCallback(()=>{p.current=!0},[]),C=w.useRef(!1),N=w.useRef(!1),_=w.useCallback(()=>{const D=a.current;if(!D)return;const L=D.scrollTop>10,F=D.scrollHeight-D.scrollTop-D.clientHeight>10;L!==C.current&&(C.current=L,g(L)),F!==N.current&&(N.current=F,b(F))},[]),P=w.useCallback(()=>{const D=a.current;D&&(c.current=D.scrollHeight-D.scrollTop-D.clientHeight<150,_())},[_]),A=w.useCallback(D=>{u.current=D},[]),T=w.useRef(o);w.useEffect(()=>{if(o===T.current)return;T.current=o;const D=p.current;p.current=!1;const L=()=>{const z=a.current;z&&(D?(z.scrollTop=0,c.current=!1):(z.scrollTop=z.scrollHeight,c.current=!0),d.current=!1)};Fh(L);const F=setTimeout(()=>{L(),v(o)},150);return()=>clearTimeout(F)},[o]);const E=t.length;w.useEffect(()=>{E>0&&(d.current=!0,S())},[E,S]),w.useEffect(()=>{const D=(n==null?void 0:n.sessionId)??null,L=m.current,F=new Set(f.map(U=>U.id));if(!L||L.sessionId!==D){m.current={sessionId:D,ids:F};return}const z=f.filter(U=>!L.ids.has(U.id));if(m.current={sessionId:D,ids:F},z.length===0||E===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,f,t,E,s]);const R=(n==null?void 0:n.turns.length)??0;w.useEffect(()=>{if(R===0)return;const D=R-u.current;D>0&&(E>0&&s(Math.min(D,E)),(d.current||c.current)&&(S(),d.current=!1)),u.current=R},[R,E,s,S]);const I=n==null?void 0:n.turns.at(-1),$=(I==null?void 0:I.toolCalls.length)??0,M=(I==null?void 0:I.assistantText.length)??0;w.useEffect(()=>{if(!(!n||!e)){if(c.current){const D=a.current;D&&(D.scrollTop=D.scrollHeight)}requestAnimationFrame(_)}},[R,$,M,i,e,_]);const O=y===o;return w.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollUp:h,canScrollDown:x,initialScrollDone:O,handleScroll:P,scrollToBottomInstant:j,requestScrollToTop:k,resetTurnCount:A}),[h,x,O,P,j,k,A])}async function av(n,e,t,s){const o=await ve(`/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(u=>!a.has(u)),c=[...i.headerLines,...l].join(`
141
+ `);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:Rt(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function qs(n,e,t,s){const o=_n.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=kn(),a=js(),{parsed:l,source:c,byteOffset:d,hasMore:u}=await av(n,e,t,s);if(kn()!==i||js()!==a)return{parsed:l,source:c};const f=_n.get(n,e);return f?{parsed:f.parsed,source:f.source}:(_n.set(n,e,l,c.rawText,d,u,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function lv(n,e,t,s){_n.evict(n,e);const o=kn(),i=js(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await av(n,e,t,s);return kn()===o&&js()===i&&_n.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function eL({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=w.useState(null),u=w.useCallback((b,y)=>{d(null),w.startTransition(()=>{n({type:"LOAD_SESSION",session:b,source:y,isMobile:e})}),i(b.turns.length),QO(b.sessionId,b.turns.length),o()},[n,e,i,o]),f=w.useCallback(async(b,y)=>{l==null||l(),d(null);try{const{parsed:v,source:S}=await qs(b,y,a,"session");u(v,S)}catch(v){d(v instanceof Error?v.message:"Failed to load session")}},[u,a,l]),m=w.useCallback(async b=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:b.name});try{const y=await ve(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(b.name)}`);if(!y.ok)throw new Error(`Failed to find session for ${b.name}`);const{dirName:v,fileName:S}=await y.json(),{parsed:j,source:k}=await qs(v,S,a,`session for ${b.name}`);w.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:j,source:k,memberName:b.name})}),i(j.turns.length),o()}catch(y){d(y instanceof Error?y.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,i,o,a,l]),p=w.useCallback(()=>d(null),[]),h=w.useCallback(()=>{w.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=w.useCallback((b,y)=>{n({type:"JUMP_TO_TURN",index:b,toolCallId:y})},[n]),x=w.useCallback(b=>{b!==t&&w.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:b})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:u,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const tL=/^\/preview\/([^/]+)\/?$/;function Ju(n){const e=tL.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function cv(){const n=yt();return n===Tt?"":`/d/${n}`}function rd(){const n=cv();return n?`${n}/`:"/"}function dv(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function nL(n,e){return $w(n,e)}function sL(n){const e=cv();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=Rw(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:rd()}function Bh(n){const e=dv(n),t=Ju(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 oL({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=w.useState(null),c=w.useRef(0),d=w.useRef(window.location.pathname),u=w.useRef(!1),f=w.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await ve(`/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 qs(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=nL(m.dirName,m.sessionId);let h;try{h=await qs(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=rd();window.history.replaceState(null,"",g),d.current=g,Fo(yt(),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=rd();window.history.replaceState(null,"",p),d.current=p,Fo(yt(),p)}}finally{c.current--}},[e,t,s,o,i]);return w.useEffect(()=>{if(u.current)return;u.current=!0,Fo(yt(),window.location.pathname);const m=Bh(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),w.useEffect(()=>{if(c.current>0||Ju(dv(window.location.pathname)))return;const m=sL(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,Fo(yt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),w.useEffect(()=>{const m=()=>{const p=Bh(window.location.pathname);d.current=window.location.pathname,Fo(yt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:a}}const rL=400;function Uh(){return Array.from(document.querySelectorAll("[data-live-session]"))}function iL(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 Wh(n){n.focus({preventScroll:!0});const e=iL(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 aL(n){const e=B.c(20),{isMobile:t,searchInputRef:s,chatInputRef:o,dispatch:i,onToggleSidebar:a,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:d,onOpenProjectSwitcher:u,onOpenThemeSelector:f,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:b,onNavigateToSession:y,onCommitNavigation:v}=n;let S,j;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==v||e[4]!==x||e[5]!==b||e[6]!==y||e[7]!==d||e[8]!==u||e[9]!==m||e[10]!==f||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==a||e[17]!==s?(S=()=>{if(t)return;let k=!1,C=!1,N=null;const _=function(E){var M,O;const R=lh("missionControl");if(R){if(E.key===R){E.repeat||(k=!0,C=E.shiftKey||E.altKey||(R==="Meta"?E.ctrlKey:E.metaKey));return}k&&(C=!0),N=null}if(_t("commandPalette",E)){E.preventDefault(),d==null||d();return}if(_t("integratedTerminal",E)){if(!ft("terminal"))return;E.preventDefault(),p();return}if(_t("preview",E)){E.preventDefault(),h();return}if(_t("projectFiles",E)){if(!ft("hostFiles"))return;E.preventDefault(),g();return}if(_t("expandAll",E)){E.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(_t("expandToolPayloads",E)){E.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(_t("toggleSidebar",E)){E.preventDefault(),a();return}if(_t("toggleStats",E)){E.preventDefault(),l();return}if(_t("missionControl",E)){E.preventDefault(),c();return}if(_t("newSession",E)&&(E.preventDefault(),u()),_t("themeSelector",E)&&(E.preventDefault(),f()),_t("systemTerminal",E)){if(!ft("terminal"))return;E.preventDefault(),m()}if(E.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(M=s.current)==null||M.blur()),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.code.startsWith("Digit")){const D=parseInt(E.code.charAt(5),10);if(D>=1&&D<=9){E.preventDefault();const F=Uh()[D-1];F&&(Wh(F),F.click())}}const I=_t("recentSessionForward",E);if(I||_t("recentSessionBack",E)){E.preventDefault();const D=I?b():x();D&&y(D.dirName,D.fileName)}_t("focusComposer",E)&&!O2(document.activeElement)&&(E.preventDefault(),(O=o.current)==null||O.focus());const $=_t("nextLiveSession",E);if($||_t("prevLiveSession",E)){E.preventDefault();const D=Uh();if(D.length===0)return;const L=D.findIndex(lL);let F;L===-1?F=$?0:D.length-1:F=Math.max(0,Math.min(D.length-1,L+($?1:-1))),Wh(D[F])}},P=function(E){const R=lh("missionControl");if(R&&E.key===R&&k){const I=!C;if(k=!1,C=!1,I){const $=Date.now();N!==null&&$-N<=rL?(N=null,E.preventDefault(),c()):N=$}else N=null}E.key==="Control"&&(v==null||v())},A=function(){k=!1,C=!1,N=null};return window.addEventListener("keydown",_),window.addEventListener("keyup",P),window.addEventListener("blur",A),()=>{window.removeEventListener("keydown",_),window.removeEventListener("keyup",P),window.removeEventListener("blur",A)}},j=[t,s,o,i,a,l,c,d,u,f,m,p,h,g,x,b,y,v],e[0]=o,e[1]=i,e[2]=t,e[3]=v,e[4]=x,e[5]=b,e[6]=y,e[7]=d,e[8]=u,e[9]=m,e[10]=f,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=a,e[17]=s,e[18]=S,e[19]=j):(S=e[18],j=e[19]),w.useEffect(S,j)}function lL(n){return n===document.activeElement}const Hh="cogpit-theme",yF=[{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 cL(n){switch(n){case"dark":return"dark";case"oled":return"dark theme-oled";case"light":return""}}function uv(){const[n,e]=w.useState(()=>{try{const l=localStorage.getItem(Hh);if(l==="dark"||l==="oled"||l==="light")return l}catch{}return"dark"}),[t,s]=w.useState(null),o=w.useCallback(l=>{localStorage.setItem(Hh,l),e(l),s(null)},[]),i=t??n,a=cL(i);return w.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 dL="cogpit-session-history",id=50;function fv(){return Kt(dL)}function uL(){try{const n=localStorage.getItem(fv());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,id)}catch{}return[]}function Kh(n){try{localStorage.setItem(fv(),JSON.stringify(n))}catch{}}function fL(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=uL(),n[0]=e):e=n[0];const t=w.useRef(e),s=w.useRef(0),o=w.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>id&&(t.current.length=id),s.current=0,Kh(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 u=d;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{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),Kh(t.current)),s.current=0,o.current=!1},n[4]=f):f=n[4];const m=f;let p;return n[5]===Symbol.for("react.memo_cache_sentinel")?(p={push:a,goBack:c,goForward:u,commitNavigation:m},n[5]=p):p=n[5],p}function mv(){return Kt(YD)}function qh(){try{const n=localStorage.getItem(mv());if(n){const e=JSON.parse(n);return{mode:e.mode||ha.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return ha}function mL(n){localStorage.setItem(mv(),JSON.stringify(n))}function pL(){const n=B.c(21),[e,t]=w.useState(qh),[s,o]=w.useState(qh),i=w.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}mL(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),w.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 u;n[10]===Symbol.for("react.memo_cache_sentinel")?(u=j=>{t(k=>({...k,mode:j}))},n[10]=u):u=n[10];const f=u;let m;n[11]===Symbol.for("react.memo_cache_sentinel")?(m=j=>{t(k=>{const C=k.allowedTools.includes(j);return{...k,allowedTools:C?k.allowedTools.filter(N=>N!==j):[...k.allowedTools,j]}})},n[11]=m):m=n[11];const p=m;let h;n[12]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{t(k=>{const C=k.disallowedTools.includes(j);return{...k,disallowedTools:C?k.disallowedTools.filter(N=>N!==j):[...k.disallowedTools,j]}})},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 y;n[15]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{t(ha)},n[15]=y):y=n[15];const v=y;let S;return n[16]!==s||n[17]!==e||n[18]!==d||n[19]!==b?(S={config:e,appliedConfig:s,hasPendingChanges:d,setMode:f,toggleAllowedTool:p,toggleDisallowedTool:g,markApplied:b,resetToDefault:v},n[16]=s,n[17]=e,n[18]=d,n[19]=b,n[20]=S):S=n[20],S}const hL=2e3;function gL(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function xL(n){const[e,t]=w.useState([]),[s,o]=w.useState(null),[i,a]=w.useState(new Set);w.useEffect(()=>{if(!n){t([]),o(null);return}let d=!1;const u=async()=>{if(!d)try{const h=await ve(`/api/permissions/${encodeURIComponent(n)}`);if(d)return;if(h.ok){const g=await h.json();if(d)return;t(b=>gL(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{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&u()},m=()=>{document.visibilityState==="visible"&&u()};f();const p=setInterval(f,hL);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=w.useCallback(async(d,u)=>{if(n){a(f=>new Set(f).add(d));try{await qb(n,d,u)&&t(f=>f.filter(m=>m.requestId!==d))}finally{a(f=>{const m=new Set(f);return m.delete(d),m})}}},[n]),c=w.useCallback(async d=>{if(n)try{await FO(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function bL(n,e){const t=await ve(`/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 vL(n,e,t){const s=await ve(`/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 yL(n){return n.file_path??n.path??""}function pv(n){const e=[];for(const t of n.toolCalls){if(t.isError||PE(t))continue;const s=yL(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 wL(n,e){return{index:e,userMessage:Ga(n.userMessage),toolCalls:pv(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function ga(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=pv(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 jL(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 dr(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(...jL(i.toolCalls,i.index))}return t}function hv(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push(wL(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 gv(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 xv(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 SL(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 NL(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function Oi(n,e){return n.length>0?SL(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function bv(n,e,t){return a0(s0(Rt(t)),n,e)}function vv(n,e,t,s){const o=s0(Rt(s)),i=e==null?void 0:e.id;if(i){const a=k6(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return a0(o,n,t)}class tr extends Error{constructor(){super("abort")}}async function kL(n,e,t,s,o,i,a){var y;const l=n.targetTurnIndex,c=ga(e.turns,e.turns.length-1,l),d=l+1,u=o.split(`
142
+ `).filter(Boolean),f=vv(u,e.turns[l],d,t.dirName),m=u.slice(f);if(m.length===0)throw a("Unable to locate the selected turn in the current session file"),new tr;const{retained:p,scooped:h}=gv(s.branches,l),g=hv(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},b=ko(t.dirName).fileCheckpoints?(y=e.turns[l+1])==null?void 0:y.id:void 0;await i({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:f,expectedLineCount:u.length},state:x,...b?{checkpoint:{sessionId:e.sessionId,userMessageId:b,cwd:e.cwd}}:{}})}async function CL(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=dr(s.turns,l),u=a?bv(s.jsonlLines,c,e.dirName):s.jsonlLines.length,f=s.jsonlLines.slice(0,u),m=s.jsonlLines.slice(u),p=s.childBranches??[];let h;if(a&&m.length>0){const{restored:y,remaining:v}=xv(p,s.branchPointTurnIndex,c),S={...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(j=>j.id===s.id?S:j),...y]}else h=[...t.branches.filter(y=>y.id!==s.id),...p];const g={...t,currentTurnIndex:t.currentTurnIndex+c,totalTurns:t.totalTurns+c,branches:h,activeBranchId:null},x=o.split(`
143
+ `).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:f,expectedLineCount:x.length},state:g})}async function _L(n,e,t,s,o,i,a){var S;let l=[...t.branches],c=o.split(`
144
+ `).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const j=ga(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...j);const{retained:k,scooped:C}=gv(l,s.branchPointTurnIndex);l=k;const N=s.branchPointTurnIndex+1,_=vv(c,n.turns[s.branchPointTurnIndex],N,e.dirName),P=c.slice(_);if(P.length>0){const A=hv(n.turns,s.branchPointTurnIndex,P,C);l=[...l,A],c=c.slice(0,_)}}const u=i.branchTurnIndex??s.turns.length-1,f=u+1,m=u<s.turns.length-1,p=dr(s.turns,u);d.push(...p);const h=m?bv(s.jsonlLines,f,e.dirName):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),x=s.jsonlLines.slice(h),b=s.childBranches??[];let y;if(m&&x.length>0){const{restored:j,remaining:k}=xv(b,s.branchPointTurnIndex,f);y=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+f,turns:s.turns.slice(f),jsonlLines:x,label:((S=s.turns[f])==null?void 0:S.userMessage)||s.label,childBranches:k.length>0?k:void 0},...j]}else y=b;const v={...t,currentTurnIndex:s.branchPointTurnIndex+f,totalTurns:s.branchPointTurnIndex+1+f,branches:[...l.filter(j=>j.id!==s.id),...y],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
145
+ `).filter(Boolean).length},state:v})}const TL=[];function yv(n,e,t,s=!0){const[o,i]=w.useState(null),[a,l]=w.useState(null),[c,d]=w.useState(!1),[u,f]=w.useState(null),m=w.useRef(null),p=w.useRef(0);w.useEffect(()=>{if(p.current+=1,!s||!n){i(null),l(null),f(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!ko(e==null?void 0:e.dirName).redo){i(null);return}const A=n.sessionId,T=new AbortController;return ve(`/api/undo-state/${encodeURIComponent(A)}`,{signal:T.signal}).then(E=>E.ok?E.json():null).then(E=>{m.current===A&&i(E??null)}).catch(E=>{E instanceof Error&&E.name==="AbortError"||m.current===A&&i(null)}),()=>T.abort()},[s,n==null?void 0:n.sessionId]);const h=w.useCallback(async A=>{try{const T=await ve("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:A.operations,session:{dirName:A.sessionSource.dirName,fileName:A.sessionSource.fileName,mutation:A.sessionMutation},state:A.state,checkpoint:A.checkpoint})}),E=await T.json().catch(()=>null);if(!T.ok)throw f((E==null?void 0:E.error)||"Undo transaction failed"),new tr;i(A.state)}catch(T){throw T instanceof tr?T:(f(String(T)),new tr)}},[]),g=(o==null?void 0:o.branches)??TL,{canRedo:x,redoTurnCount:b,redoBranch:y}=w.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let A=g.length-1;A>=0;A--){const T=g[A];if(T.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:T.turns.length,redoBranch:T}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),v=w.useMemo(()=>{if(!y||y.jsonlLines.length===0)return[];try{return Va(y.jsonlLines.join(`
146
+ `)).turns}catch{return[]}},[y]),S=w.useCallback(A=>g.filter(T=>T.branchPointTurnIndex===A),[g]),j=w.useCallback(A=>{if(!s||!n)return;const T=A-1;if(T>=n.turns.length-1||T<-1)return;if(ko(e==null?void 0:e.dirName).nativeRewind){const R=n.turns[A];if(!R)return;const I=n.sessionId,$=++p.current,M=()=>p.current===$&&m.current===I,O=R.id.includes("@")?R.id.slice(R.id.lastIndexOf("@")+1):R.id,D=n.turns.length-A;bL(n.sessionId,O).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:D,fileCount:z,filePaths:F,operationCount:z},targetTurnIndex:T,nativeRewind:{eventId:O,mode:"conversation",filesAvailable:!!(L!=null&&L.available&&z>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:D,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:T,nativeRewind:{eventId:O,mode:"conversation"}})});return}const E=ga(n.turns,n.turns.length-1,T);l({type:"undo",summary:Oi(E,n.turns.length-1-T),targetTurnIndex:T})},[s,n,e==null?void 0:e.dirName]),k=w.useCallback(()=>{if(!s||!x||!y||!n)return;const A=dr(y.turns);l({type:"redo",summary:Oi(A,y.turns.length),targetTurnIndex:y.branchPointTurnIndex+y.turns.length,branchId:y.id})},[s,x,y,n]),C=w.useCallback(A=>{if(!s||!x||!y||!n)return;const T=A+1,E=dr(y.turns,A);l({type:"redo",summary:Oi(E,T),targetTurnIndex:y.branchPointTurnIndex+T,branchId:y.id,redoUpToArchiveIndex:A})},[s,x,y,n]),N=w.useCallback((A,T)=>{if(!s||!n)return;const E=g.find(M=>M.id===A);if(!E)return;const R=T??E.turns.length-1,I=n.turns.length>E.branchPointTurnIndex+1?ga(n.turns,n.turns.length-1,E.branchPointTurnIndex):[],$=dr(E.turns,R);l({type:"branch-switch",summary:Oi([...I,...$],R+1),targetTurnIndex:E.branchPointTurnIndex,branchId:A,branchTurnIndex:R})},[s,n,g]),_=w.useCallback(async(A=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),f(null);try{if(a.nativeRewind){const I=A&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",$=await vL(n.sessionId,a.nativeRewind.eventId,I);if(!$.ok){f($.error);return}await t(),l(null);return}const T=o??NL(n.sessionId,n.turns.length),E=await ve(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!E.ok){f("Failed to read session file");return}const R=await E.text();if(a.type==="undo")await kL(a,n,e,T,R,h,f);else if(a.type==="redo"){const I=g.find($=>$.id===a.branchId);if(!I){l(null);return}await CL(a,e,T,I,R,h)}else if(a.type==="branch-switch"){const I=g.find($=>$.id===a.branchId);if(!I){l(null);return}await _L(n,e,T,I,R,a,h)}try{await ve("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(T){if(!(T instanceof tr))throw T}finally{d(!1)}},[s,a,n,e,o,g,h,t]),P=w.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:b,redoGhostTurns:v,branches:g,branchesAtTurn:S,requestUndo:j,requestRedoAll:k,requestRedoUpTo:C,requestBranchSwitch:N,confirmState:a,confirmApply:_,confirmCancel:P,isApplying:c,applyError:u}}async function EL(n){try{const t=await(await ps("/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 Vh(n){const e=await ve("/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:Aw(t==null?void 0:t.mode,Xs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function PL(){const n=B.c(26),[e,t]=w.useState(!0),[s,o]=w.useState(null),[i,a]=w.useState(null),[l,c]=w.useState(Xs),[d,u]=w.useState(!1),[f,m]=w.useState(null),[p,h]=w.useState(!1),[g,x]=w.useState(0),b=w.useRef(null),y=w.useRef(null);let v;n[0]===Symbol.for("react.memo_cache_sentinel")?(v=U=>{a(U.claudeDir),c(U.defaultAgentKind),aN(U.useBuiltInEditor)},n[0]=v):v=n[0];const S=v;let j;n[1]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{var K;(K=b.current)==null||K.abort();const U=new AbortController;b.current=U;const H=await EL(U.signal);U.signal.aborted||b.current!==U||(m(H.url),h(H.disabled))},n[1]=j):j=n[1];const k=j;let C,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{var U,H;(U=b.current)==null||U.abort(),(H=y.current)==null||H.abort()},N=[],n[2]=C,n[3]=N):(C=n[2],N=n[3]),w.useEffect(C,N);let _;n[4]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const U=new AbortController;return t(!0),o(null),Vh(U.signal).then(S).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 P;n[5]!==g?(P=[S,g],n[5]=g,n[6]=P):P=n[6],w.useEffect(_,P);let A,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const U=()=>x(RL);return window.addEventListener("cogpit-auth-changed",U),()=>window.removeEventListener("cogpit-auth-changed",U)},T=[],n[7]=A,n[8]=T):(A=n[7],T=n[8]),w.useEffect(A,T);let E;n[9]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{k()},n[9]=E):E=n[9];let R;n[10]!==i?(R=[i,k],n[10]=i,n[11]=R):R=n[11],w.useEffect(E,R);let I;n[12]===Symbol.for("react.memo_cache_sentinel")?(I=()=>u(!1),n[12]=I):I=n[12];const $=I;let M;n[13]!==i?(M=U=>{if(u(!1),U!==i){a(U),window.location.reload();return}x(AL),k()},n[13]=i,n[14]=M):M=n[14];const O=M;let D;n[15]===Symbol.for("react.memo_cache_sentinel")?(D=()=>u(!0),n[15]=D):D=n[15];const L=D;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{var H;(H=y.current)==null||H.abort();const U=new AbortController;y.current=U,t(!0),o(null),Vh(U.signal).then(K=>{U.signal.aborted||y.current!==U||S(K)}).catch(K=>{U.signal.aborted||y.current!==U||(a(null),o(K instanceof Error?K.message:"Failed to load configuration"))}).finally(()=>{U.signal.aborted||y.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]!==O||n[22]!==p||n[23]!==f||n[24]!==d?(W={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:L,handleCloseConfigDialog:$,handleConfigSaved:O,retryConfig:z,networkUrl:f,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=O,n[22]=p,n[23]=f,n[24]=d,n[25]=W):W=n[25],W}function AL(n){return n+1}function RL(n){return n+1}const Gh={authenticated:!0,edition:"personal",user:null,capabilities:Ma},jn={authenticated:!1,edition:"personal",user:null,capabilities:Ur},wv=Object.keys(Ma);function Yh(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&wv.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function $L(n,e){const t={...Ur};for(const s of wv)t[s]=n[s]&&e[s];return t}async function Xh(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function IL(n){try{const e=await ve("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function Vo(n){var e;return go(n),Z1(((e=n.user)==null?void 0:e.id)??null),n}function ML(n){const e=B.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...jn,checked:!1},e[0]=t):t=e[0];const[s,o]=w.useState(t),[i,a]=w.useState(0),l=w.useRef(null),c=w.useRef(!1);let d;e[1]!==n?(d=()=>{var v;if((v=l.current)==null||v.abort(),n===null){c.current=!1,go(jn),o({...jn,checked:!1});return}const p=c.current;c.current=!1,go(jn),o(S=>p?{...S,capabilities:Ur,checked:!1}:{...jn,checked:!1});const h=new AbortController;l.current=h;const g=Bs(),x=Xh(ps,h.signal),b=g?IL(h.signal):Promise.resolve(n),y=g?Xh(ve,h.signal):Promise.resolve(null);return Promise.all([x,b,y]).then(S=>{const[j,k,C]=S;if(h.signal.aborted)return;const N=Yh(j,n)?j:n==="personal"?Gh:null;if(!N||k===null){o({...Vo(jn),checked:!1});return}if(!g){o({...Vo(N),checked:!0});return}const _=Yh(C,k)?C:k==="personal"?Gh:null;if(!_){o({...Vo(jn),checked:!1});return}o({...Vo({authenticated:N.authenticated,edition:N.edition,user:N.user,capabilities:$L(N.capabilities,_.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Vo(jn),checked:!1})}),()=>{h.abort(),l.current===h&&(l.current=null)}},e[1]=n,e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==i?(u=[n,i],e[3]=n,e[4]=i,e[5]=u):u=e[5],w.useEffect(d,u);let f,m;return e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const p=()=>{var g;(g=l.current)==null||g.abort(),c.current=!1,go(jn),Z1(null),o({...jn,checked:!1}),a(LL)},h=g=>{var y,v;const x=yt();if(x===Tt)return;const b=(y=g.detail)==null?void 0:y.deviceId;b&&b!==x||((v=l.current)==null||v.abort(),c.current=!0,go(jn),o(DL),a(OL))};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]=f,e[7]=m):(f=e[6],m=e[7]),w.useEffect(f,m),s}function OL(n){return n+1}function DL(n){return{...n,capabilities:Ur,checked:!1}}function LL(n){return n+1}const zL=3e4;function FL(n){const[e,t]=w.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=w.useRef(0),o=w.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 ve(`/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]);w.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),zL);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 BL(){const n=B.c(3),[e,t]=w.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await ve("/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 UL(n,e){return n?`${n}.jsonl`:e??null}async function jv(n){try{const e=await ve(`/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 WL=300,pc=new Map;function ad(n,e){const t=Kt(n),s=pc.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{pc.delete(t),Kt(n)===t&&(async()=>{try{await ve(`/api/session-config/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{}})()},WL);pc.set(t,{patch:o,timer:i})}function ld(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function Jh(n){const e=await jv(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function Qh(n,e){ad(n,{mcpServers:e})}async function HL(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function Zh(n,e){try{const t=await ve(n,{signal:e});if(e.aborted)return null;const s=await HL(t);return e.aborted?null:s}catch{return null}}async function e1(n,e,t){const s=ld(t);if(s.size===0)return[];if(n){const o=await Jh(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await Jh(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function KL(n,e,t,s=!0){const[o,i]=w.useState([]),[a,l]=w.useState({}),[c,d]=w.useState([]),[u,f]=w.useState(!1),[m,p]=w.useState(!1),h=w.useRef(null),g=w.useRef(e);g.current=e;const x=t??e??null,b=w.useRef(x);b.current=x;const y=w.useRef(void 0);w.useEffect(()=>{var C,N;if(!s||!n){(C=h.current)==null||C.abort(),y.current=void 0,i([]),l({}),d([]),f(!1),p(!1);return}const k=new AbortController;return(N=h.current)==null||N.abort(),i([]),l({}),d([]),f(!0),p(!1),y.current=n,Zh(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,k.signal).then(async _=>{if(k.signal.aborted||y.current!==n||!_)return;i(_.servers),l(_.configs);const P=await e1(b.current,g.current,_.servers);k.signal.aborted||y.current!==n||d(P)}).finally(()=>{k.signal.aborted||y.current!==n||(f(!1),p(!0))}),()=>k.abort()},[n,s]),w.useEffect(()=>()=>{var k;return(k=h.current)==null?void 0:k.abort()},[]),w.useEffect(()=>{if(o.length===0||!x)return;let k=!1;return e1(x,e,o).then(C=>{k||b.current!==x||d(C)}),()=>{k=!0}},[x]);const v=w.useCallback(k=>{d(C=>{const N=C.includes(k)?C.filter(_=>_!==k):[...C,k];return b.current&&Qh(b.current,N),N})},[]),S=w.useCallback(()=>{var C;if(!s||!n)return;(C=h.current)==null||C.abort();const k=new AbortController;h.current=k,f(!0),Zh(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,k.signal).then(N=>{if(k.signal.aborted||y.current!==n||!N)return;i(N.servers),l(N.configs);const _=ld(N.servers);d(P=>{const A=P.filter(T=>_.has(T));return b.current&&Qh(b.current,A),A})}).finally(()=>{k.signal.aborted||h.current!==k||f(!1)})},[n,s]),j=w.useMemo(()=>{if(o.length===0)return null;const k=ld(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:j,loading:u,loaded:m,toggleServer:v,refresh:S}}function qL(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,y=String(b.taskId??"");if(!y)continue;if(b.status==="deleted"){p.delete(y);continue}const v=p.get(y)??{id:y,content:b.subject||b.description||`Task ${y}`,activeForm:b.activeForm||b.subject||`Working on task ${y}`,status:"pending"};p.set(y,{...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(GL),e[4]=l,e[5]=c):c=e[5];const d=c.length;let u;e[6]!==l?(u=l.find(VL)??null,e[6]=l,e[7]=u):u=e[7];const f=u;let m;e[8]!==d||e[9]!==f||e[10]!==l?(m={todos:l,completed:d,total:l.length,inProgress:f},e[8]=d,e[9]=f,e[10]=l,e[11]=m):m=e[11],t=m}return t}function VL(n){return n.status==="in_progress"}function GL(n){return n.status==="completed"}function YL(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]=w.useState(t);let i,a;return e[1]!==n?(i=()=>{if(!n){o([]);return}let l=!1;const c=async function(){try{const f=await ve(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(l)return;if(f.ok){const m=await f.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]),w.useEffect(i,a),s}function XL(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]=w.useState(o),[l,c]=w.useState(!1),d=w.useRef(void 0);let u,f;t[1]!==n||t[2]!==s?(u=()=>{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)}`:"";ve(`/api/slash-suggestions${p}`).then(JL).then(h=>a(h.suggestions||[])).catch(()=>a([])).finally(()=>c(!1))},f=[n,s],t[1]=n,t[2]=s,t[3]=u,t[4]=f):(u=t[3],f=t[4]),w.useEffect(u,f);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 JL(n){return n.json()}function t1(n,e){const t=B.c(6),[s,o]=Jr(n,e),i=typeof s=="boolean"?s:e;let a;t[0]!==e||t[1]!==o?(a=d=>{o(u=>typeof d=="function"?d(typeof u=="boolean"?u: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 n1(){if(typeof window>"u")return It.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return It.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return It.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return It.fileChanges}function QL(n,e){const t=B.c(46),[s,o]=t1("panel-sidebar-visible",!0),[i,a]=t1("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=n1(),t[0]=l):l=t[0];const[c,d]=Jr("workspace-panel-active",l);let u;t[1]!==c?(u=typeof c=="string"||c===null?c:n1(),t[1]=c,t[2]=u):u=t[2];const f=u,[m,p]=w.useState(!1),[h,g]=w.useState(!1);let x;t[3]!==o||t[4]!==s?(x=()=>{w.startTransition(()=>o(!s))},t[3]=o,t[4]=s,t[5]=x):x=t[5];const b=x;let y;t[6]!==a?(y=()=>a(ez),t[6]=a,t[7]=y):y=t[7];const v=y;let S;t[8]!==e||t[9]!==d||t[10]!==n.mainView?(S=H=>{w.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]=S):S=t[11];const j=S;let k;t[12]!==e||t[13]!==d||t[14]!==n.mainView?(k=H=>{w.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=()=>{w.startTransition(()=>d(null))},t[16]=d,t[17]=N):N=t[17];const _=N;let P;t[18]!==e||t[19]!==n.mainView?(P=()=>{const H=n.mainView==="config";w.startTransition(()=>{e({type:H?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[18]=e,t[19]=n.mainView,t[20]=P):P=t[20];const A=P;let T;t[21]!==e||t[22]!==n.mainView?(T=()=>{const H=n.mainView==="mission";w.startTransition(()=>{e({type:H?"CLOSE_MISSION":"OPEN_MISSION"})})},t[21]=e,t[22]=n.mainView,t[23]=T):T=t[23];const E=T;let R;t[24]!==e?(R=H=>{w.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:H})})},t[24]=e,t[25]=R):R=t[25];const I=R;let $;t[26]===Symbol.for("react.memo_cache_sentinel")?($=()=>p(!0),t[26]=$):$=t[26];const M=$;let O;t[27]===Symbol.for("react.memo_cache_sentinel")?(O=()=>p(!1),t[27]=O):O=t[27];const D=O;let L;t[28]===Symbol.for("react.memo_cache_sentinel")?(L=()=>g(ZL),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]!==f||t[31]!==_||t[32]!==I||t[33]!==A||t[34]!==E||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]!==j?(U={showSidebar:s,showWorkflows:i,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:b,handleToggleWorkflows:v,toggleWorkspacePanel:j,openWorkspacePanel:C,closeWorkspacePanel:_,handleToggleConfig:A,handleToggleMission:E,handleEditConfig:I,handleOpenProjectSwitcher:M,handleCloseProjectSwitcher:D,handleToggleThemeSelector:F,handleCloseThemeSelector:W,setShowSidebar:o,setShowWorkflows:a},t[30]=f,t[31]=_,t[32]=I,t[33]=A,t[34]=E,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]=j,t[45]=U):U=t[45],U}function ZL(n){return!n}function ez(n){return!n}function tz(n){var K;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:o,markPermissionsApplied:i,hasPermsPendingChanges:a,permissionsConfig:l,selectedModel:c,selectedEffort:d,fastMode:u,ultracode:f,mcpConfig:m,scrollRequestScrollToTop:p,handleDashboardSelect:h,workerParse:g}=n,x=w.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:q,fileName:Y}=e.sessionSource;try{const{parsed:V,source:J}=await lv(q,Y,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:V,source:J})}catch{}},[e.sessionSource,t,g]),[b,y]=w.useState(null),v=w.useCallback(q=>y(q),[]),S=w.useCallback(()=>y(null),[]),j=w.useCallback(async(q,Y)=>{try{const V=await ve("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:Y})});if(!V.ok)return;const J=await V.json(),{parsed:Q,source:X}=await qs(J.dirName,J.fileName,g,"session");t({type:"LOAD_SESSION",session:Q,source:X,isMobile:s})}catch{}},[t,s,g]),k=w.useCallback(()=>{e.sessionSource&&j(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,j]),C=w.useCallback(async(q,Y)=>{try{await ve("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:Y})})}catch{}},[]),N=w.useCallback(async q=>{var Q,X;if(!e.sessionSource)return;const{dirName:Y,fileName:V}=e.sessionSource,J=(X=(Q=e.session)==null?void 0:Q.turns[q])==null?void 0:X.id;try{const Z=await ve("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:Y,fileName:V,turnIndex:q,turnUuid:J})});if(!Z.ok)return;const te=await Z.json(),{parsed:ne,source:oe}=await qs(te.dirName,te.fileName,g,"session");t({type:"LOAD_SESSION",session:ne,source:oe,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),_=w.useCallback((q,Y)=>{o(q,Y),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[P,A]=w.useState({}),T=w.useRef(c);T.current=c;const E=w.useRef(d);E.current=d;const R=w.useRef(m);R.current=m;const I=w.useRef(u);I.current=u;const $=w.useRef(f);$.current=f;const M=w.useRef(l);M.current=l;const O=((K=e.session)==null?void 0:K.sessionId)??null,D=w.useRef(null);w.useEffect(()=>{O!==D.current&&(D.current=O,O&&A(q=>O in q?q:{...q,[O]:{model:T.current,effort:E.current,fastMode:I.current,ultracode:$.current,mcpConfig:R.current}}))},[O]);const L=O?P[O]:void 0,F=m!==((L==null?void 0:L.mcpConfig)??null),z=L!=null&&(c!==L.model||d!==L.effort||u!==L.fastMode||f!==L.ultracode||a||F),W=w.useCallback(async()=>{var te,ne;if(!O)return;const q=T.current,Y=E.current,V=I.current,J=$.current,Q=R.current,X=M.current,Z=((te=e.sessionSource)==null?void 0:te.agentKind)??Rt(((ne=e.sessionSource)==null?void 0:ne.dirName)??null);Vt(Z).settingsApply==="live"&&await ve(`/api/claude/settings/${encodeURIComponent(O)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:q,effort:Y,fastMode:V,ultracode:J,mcpConfig:Q,permissionMode:X.mode,allowedTools:X.allowedTools,disallowedTools:X.disallowedTools})}),A(oe=>({...oe,[O]:{model:q,effort:Y,fastMode:V,ultracode:J,mcpConfig:Q}})),i()},[O,e.sessionSource,i]),U=w.useCallback(async()=>{if(O)try{await ve("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:O})})}catch{}},[O]),H=w.useCallback((q,Y)=>{Ns(Y)&&p(),h(q,Y)},[p,h]);return{reloadSession:x,branchModalTurn:b,setBranchModalTurn:y,handleOpenBranches:v,handleCloseBranchModal:S,handleDuplicateSessionByPath:j,handleDuplicateSession:k,handleDeleteSession:C,handleBranchFromHere:N,handleMobileJumpToTurn:_,hasSettingsChanges:z,handleApplySettings:W,handleStopSession:U,handleLoadSessionScrollAware:H}}function Sv(){const n=B.c(6),e=w.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=w.useRef(t),o=w.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-D3MwyNH5.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]),w.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(()=>Va(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(()=>E6(m,p))},n[4]=d):d=n[4];const u=d;let f;return n[5]===Symbol.for("react.memo_cache_sentinel")?(f={parse:c,append:u},n[5]=f):f=n[5],f}const nz=30;function Nv({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=w.useState(!1),[l,c]=w.useState(!1),d=w.useRef(""),u=w.useRef(null),f=`${n??""}::${e??""}::${t}`;return w.useEffect(()=>{d.current=f,u.current=null,c(!1);const p=n&&e?_n.get(n,e):void 0;a((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&o(p.olderTurns)},[f,n,e,t,o]),{loadMore:w.useCallback(async()=>{if(!n||!e||u.current)return 0;const p=`${n}::${e}::${t}`,h=_n.get(n,e);if(!(h!=null&&h.hasMore))return d.current===p&&a(!1),0;const g=Symbol("paging-flight");u.current=g,c(!0);try{const x=await ve(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${nz}`);if(!x.ok)return 0;const b=await x.json(),y=b.lines.length>0&&b.hasMore;if(d.current===p&&a(y),b.lines.length===0)return _n.update(n,e,{hasMore:y,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),S=b.lines.filter(C=>!v.has(C)),j=await s([...b.headerLines,...S].join(`
147
+ `)),k=R2(h.olderTurns,j.turns,h.source.agentKind);return _n.update(n,e,{hasMore:y,nextByteOffset:b.byteOffset,olderTurns:k}),d.current!==p?0:(o(k),j.turns.length)}finally{u.current===g&&(u.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function sz(n){const e=B.c(50),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??Xs,c=og(l),[d,u]=w.useState(""),[f,m]=w.useState(""),[p,h]=w.useState(!1),[g,x]=w.useState(!1),b=d||(s==null?void 0:s.model);let y;e[0]!==l||e[1]!==b?(y=Vw(l,b),e[0]=l,e[1]=b,e[2]=y):y=e[2];const v=y,S=g&&v;let j;e[3]!==l||e[4]!==f||e[5]!==d||e[6]!==S?(j=S?"xhigh":_a(l,f,d),e[3]=l,e[4]=f,e[5]=d,e[6]=S,e[7]=j):j=e[7];const k=j;let C;e[8]!==l||e[9]!==d?(C=G1(l,d),e[8]=l,e[9]=d,e[10]=C):C=e[10];const N=!!C,_=N&&p;let P;e[11]!==l||e[12]!==d?(P=Kw(l,d),e[11]=l,e[12]=d,e[13]=P):P=e[13];const A=P,[T,E]=w.useState(null),R=w.useRef(null),I=(o==null?void 0:o.fileName)??null,$=w.useRef(I);let M,O;e[14]!==I?(M=()=>{const Z=$.current;$.current=I,!(Z===null||Z===I)&&x(!1)},O=[I],e[14]=I,e[15]=M,e[16]=O):(M=e[15],O=e[16]),w.useEffect(M,O);let D,L;e[17]!==i?(D=()=>{i&&x(!1)},L=[i],e[17]=i,e[18]=D,e[19]=L):(D=e[18],L=e[19]),w.useEffect(D,L);let F;e[20]!==l?(F=Z=>{u(te=>te===Z?"":te),E(`${Z} is unavailable for this account. Cogpit retried the turn with ${sn(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=()=>{E(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)||u(""))},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]),w.useEffect(H,K);let q,Y;e[29]!==T?(q=()=>{if(!T)return;const Z=setTimeout(()=>E(null),12e3);return()=>clearTimeout(Z)},Y=[T],e[29]=T,e[30]=q,e[31]=Y):(q=e[30],Y=e[31]),w.useEffect(q,Y);const V=s==null?void 0:s.rawMessages;let J,Q;e[32]!==l||e[33]!==a||e[34]!==V?(J=()=>{if(!a||!V||!Vt(l).modelFallbackNotices)return;let Z;for(let ae=V.length-1;ae>=0;ae=ae-1,ae){const se=V[ae];if(se.type==="system"&&se.subtype==="model_refusal_fallback"){Z=se;break}}if(!Z)return;const te=typeof Z.uuid=="string"?Z.uuid:`${String(Z.original_model)}:${String(Z.fallback_model)}:${String(Z.request_id)}`;if(R.current===te)return;R.current=te;const ne=typeof Z.original_model=="string"?Z.original_model:"Fable",oe=typeof Z.fallback_model=="string"?Z.fallback_model:"Opus",re=typeof Z.api_refusal_explanation=="string"?` ${Z.api_refusal_explanation}`:"";E(`${ne} could not handle this request, so Claude continued with ${oe}.${re}`)},Q=[a,V,l],e[32]=l,e[33]=a,e[34]=V,e[35]=J,e[36]=Q):(J=e[35],Q=e[36]),w.useEffect(J,Q);let X;return e[37]!==k||e[38]!==_||e[39]!==N||e[40]!==p||e[41]!==z||e[42]!==A||e[43]!==T||e[44]!==f||e[45]!==d||e[46]!==S||e[47]!==v||e[48]!==g?(X={selectedModel:d,setSelectedModel:u,selectedEffort:f,setSelectedEffort:m,fastModeEnabled:p,ultracodeEnabled:g,effectiveEffort:k,fastModeAvailable:N,fastModeActive:_,setFastModeEnabled:h,ultracodeAvailable:v,ultracodeActive:S,setUltracodeEnabled:x,imageInputAvailable:A,modelFallbackNotice:T,dismissModelFallbackNotice:U,handleModelRejected:z},e[37]=k,e[38]=_,e[39]=N,e[40]=p,e[41]=z,e[42]=A,e[43]=T,e[44]=f,e[45]=d,e[46]=S,e[47]=v,e[48]=g,e[49]=X):X=e[49],X}const oz=["model","effort","fastMode","ultracode","permissionMode"];function rz({sessionKey:n,values:e,onHydrate:t}){const s=w.useRef(null),o=w.useRef(null),i=w.useRef(t);i.current=t;const a=w.useRef(e);a.current=e,w.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return jv(n).then(d=>{if(c||d===null)return;if(oz.some(f=>d[f]!==void 0)){i.current(d);const f=a.current,m={model:d.model??f.model,effort:d.effort??f.effort,fastMode:d.fastMode??f.fastMode,ultracode:d.ultracode??f.ultracode,permissionMode:d.permissionMode??f.permissionMode};o.current=JSON.stringify(m)}else ad(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);w.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,ad(n,a.current))},[l,n])}function iz(n){const[e,t]=w.useState(new Map),[s,o]=w.useState(null),[i,a]=w.useState(!0),l=w.useRef(new Map),c=w.useRef(null);w.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:i}),x!==b){const y=x?l.current.get(x):null;y?(o(y.activeId),a(y.collapsed)):(o(null),a(!0))}c.current=x},[n]);const d=w.useCallback(()=>a(x=>!x),[]),u=w.useCallback(x=>{t(b=>{const y=new Map(b);return y.set(x.id,x),y}),o(x.id),a(!1)},[]),f=w.useCallback(x=>{t(b=>{const y=new Map(b);return y.delete(x),o(v=>{if(v!==x)return v;const S=[...y.keys()];return S.length>0?S[S.length-1]:null}),y})},[]),m=w.useCallback(x=>{o(x),a(!1)},[]),p=w.useCallback((x,b)=>{t(y=>{const v=y.get(x);if(!v||v.status===b)return y;const S=new Map(y);return S.set(x,{...v,status:b}),S})},[]),h=w.useCallback(x=>{t(b=>{let y=!1;const v=new Map(b),S=new Set(x.map(j=>j.id));for(const[j,k]of v)k.type==="task"&&!S.has(j)&&(v.delete(j),y=!0);for(const j of x){const k=v.get(j.id);k?(k.name!==j.title||k.outputPath!==j.outputPath)&&(v.set(j.id,{...k,name:j.title,outputPath:j.outputPath}),y=!0):(v.set(j.id,{id:j.id,name:j.title,type:"task",status:"running",outputPath:j.outputPath}),y=!0)}return y?v:b})},[]),g=w.useCallback((x,b,y)=>{b&&y&&t(v=>{if(v.has(x))return v;const S=new Map(v);return S.set(x,{id:x,name:y,type:"task",status:"running",outputPath:b}),S}),o(v=>v===x?(a(!0),v):(a(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:i,toggleCollapse:d,addProcess:u,removeProcess:f,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function az(n){const e=B.c(54),{sessionId:t,sessionCwd:s,pendingPath:o,sessionDirName:i,pendingDirName:a,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:d,openWorkspacePanel:u,closeWorkspacePanel:f}=n,m=iz(t),[p,h]=w.useState(null),[g,x]=w.useState(0),b=w.useRef(0),y=s??o??void 0,v=!!(y&&(p==null?void 0:p.kind)==="preview"&&p.cwd===y),S=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(y??null)?p:null;let j;e[0]!==a||e[1]!==o?(j={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=j):j=e[2];const k=j;let C;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(C=()=>{if(Bs()){console.warn("[open-terminal] unavailable for remote devices");return}const V=s??o??void 0,J=i??a??l??void 0;if(!V&&!J){console.warn("[open-terminal] no project path available");return}ve("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:V,dirName:J})}).then(mz).catch(fz)},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?(_=V=>{if(Bs()){console.warn("[mcp-auth] unavailable for remote devices");return}const J=s??o??void 0,Q=i??a??l??void 0;!J&&!Q||ve("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:J,dirName:Q,command:"claude /mcp"})}).catch(uz)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=_):_=e[14];const P=_;let A;e[15]!==o||e[16]!==m||e[17]!==s?(A=()=>{const J=[...m.processes.values()].filter(dz).at(-1);if(!J){(s??o)&&x(cz);return}m.activeProcessId===J.id&&!m.collapsed?m.toggleCollapse():m.setActive(J.id)},e[15]=o,e[16]=m,e[17]=s,e[18]=A):A=e[18];const T=A;let E;e[19]!==o||e[20]!==s?(E=()=>{(s??o)&&x(lz)},e[19]=o,e[20]=s,e[21]=E):E=e[21];const R=E;let I;e[22]!==f||e[23]!==y||e[24]!==v?(I=()=>{y&&w.startTransition(()=>{f(),h(v?null:{kind:"preview",cwd:y})})},e[22]=f,e[23]=y,e[24]=v,e[25]=I):I=e[25];const $=I;let M;e[26]!==d||e[27]!==f||e[28]!==y||e[29]!==u?(M=()=>{if(y){if(d===It.projectFiles){f();return}w.startTransition(()=>{h({kind:"project-files",root:y,anchorCwd:y,request:null}),u(It.projectFiles)})}},e[26]=d,e[27]=f,e[28]=y,e[29]=u,e[30]=M):M=e[30];const O=M;let D;e[31]!==y||e[32]!==u||e[33]!==c?(D=V=>{if(!c)return!1;const J=cN(V,y);if(!J)return!1;b.current=b.current+1;const Q=b.current;return w.startTransition(()=>h({kind:"project-files",root:J.root,anchorCwd:y??null,request:J.file?{file:J.file,mode:J.mode,line:J.line,token:Q}:null})),u(It.projectFiles),!0},e[31]=y,e[32]=u,e[33]=c,e[34]=D):D=e[34];const L=D;let F,z;e[35]!==L?(z=()=>lN(L),F=[L],e[35]=L,e[36]=F,e[37]=z):(F=e[36],z=e[37]),w.useEffect(z,F);let W;e[38]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{w.startTransition(()=>h(null))},e[38]=W):W=e[38];const U=W,H=!!(y&&d===It.projectFiles),K=S==null?void 0:S.root,q=(S==null?void 0:S.request)??null;let Y;return e[39]!==y||e[40]!==P||e[41]!==R||e[42]!==N||e[43]!==T||e[44]!==$||e[45]!==O||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:y,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:q,launchTerminalRequest:g,pendingProject:k,handleOpenTerminal:N,handleMcpAuth:P,handleToggleIntegratedTerminal:T,handleNewIntegratedTerminal:R,handleTogglePreview:$,handleToggleProjectFiles:O,closeRightWorkspace:U},e[39]=y,e[40]=P,e[41]=R,e[42]=N,e[43]=T,e[44]=$,e[45]=O,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 lz(n){return n+1}function cz(n){return n+1}function dz(n){return n.type==="terminal"}function uz(n){return console.error("[mcp-auth] open-terminal failed:",n)}function fz(n){return console.error("[open-terminal] fetch failed:",n)}function mz(n){n.ok||n.json().then(hz).catch(pz)}function pz(){}function hz(n){return console.error("[open-terminal]",n.error)}function gz(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
148
+ `)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const xz={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function kv(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:Rt(n.dirName)}}function bz(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...xz},rawMessages:[],agentKind:Rt(n.dirName)}}function Cv(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:Va(n)}}catch{return null}}async function vz(n,e,t=3,s=100,o=!0){if(o){const i=Cv(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 ve(`/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:Va(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function yz(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await vz(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:kv(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function s1(n,e,t,s,o){const i=Cv(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??bz(n),c=kv(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),yz(n,e,t,a),n.sessionId}async function wz(n,e,t,s){const o=await ve(`/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(u=>{const f=u.lastModified?new Date(u.lastModified).getTime():0;return Number.isFinite(f)&&f>=a}),d=c.find(u=>{var f,m;return((f=u.firstUserMessage)==null?void 0:f.trim())===l||((m=u.lastUserMessage)==null?void 0:m.trim())===l})??c[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function jz({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:o,onModelRejected:i,model:a,effort:l,fastMode:c,ultracode:d,mcpConfig:u}){const[f,m]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),[b,y]=w.useState(""),v=w.useRef(null),S=w.useRef(null),j=w.useRef(null),k=w.useCallback((P,A)=>{S.current=P,j.current=A??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:P,cwd:A,isMobile:t})},[e,t]),C=w.useCallback(async(P,A)=>{var M;const T=S.current;if(!T)return null;const E=Rt(T),R=j.current;(M=v.current)==null||M.abort();const I=new AbortController;v.current=I,m(!0),h(null),o==null||o(P);const $=Date.now();try{const O=gz(P),D=sn(E),{capabilities:L}=D,F={dirName:T,cwd:D.dirName.lossy?R??void 0:void 0,message:P,images:A,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:L.ultracode&&d?!0:void 0,name:L.namedSessions&&O||void 0,worktreeName:L.worktrees&&g?b||Gw(P):void 0,mcpConfig:L.mcp&&u||void 0},{res:z,errorMessage:W}=await ov(K=>ve("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:K}),signal:I.signal}),{model:a,agentKind:E,errorFallback:"Unknown error",onModelRejected:i});if(!z.ok){if(E==="codex"){const K=await wz(T,P,$,I);if(K){S.current=null,j.current=null;const q=await s1(K,I,e,t,s);return O&&q&&sd(q,O),q}}return h(W||`Failed to create session (${z.status})`),null}const U=await z.json();S.current=null,j.current=null;const H=await s1(U,I,e,t,s);return O&&H&&sd(H,O),H}catch(O){return I.signal.aborted||h(O instanceof Error?O.message:"Failed to create session"),null}finally{I.signal.aborted||m(!1)}},[n,a,l,c,d,u,g,b,e,t,s,o,i]),N=w.useCallback(()=>h(null),[]),_=w.useCallback(()=>{var P;(P=v.current)==null||P.abort(),v.current=null,S.current=null,j.current=null,m(!1),h(null)},[]);return{creatingSession:f,createError:p,clearCreateError:N,handleNewSession:k,createAndSend:C,cancelCreation:_,pendingDirNameRef:S,worktreeEnabled:g,setWorktreeEnabled:x,worktreeName:b,setWorktreeName:y}}function Sz(n){const e=B.c(40),{permissionsConfig:t,dispatch:s,isMobile:o,defaultAgentKind:i,pendingDirName:a,pendingCwd:l,model:c,effort:d,fastMode:u,ultracode:f,mcpConfig:m,onModelRejected:p}=n,h=w.useRef(null),g=w.useRef(null),[x,b]=w.useState(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=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]=y):y=e[0];let v;e[1]!==s||e[2]!==d||e[3]!==u||e[4]!==o||e[5]!==m||e[6]!==c||e[7]!==p||e[8]!==t||e[9]!==f?(v={permissionsConfig:t,dispatch:s,isMobile:o,onSessionFinalized:y,onCreateStarted:b,onModelRejected:p,model:c,effort:d,fastMode:u,ultracode:f,mcpConfig:m},e[1]=s,e[2]=d,e[3]=u,e[4]=o,e[5]=m,e[6]=c,e[7]=p,e[8]=t,e[9]=f,e[10]=v):v=e[10];const S=jz(v),j=S.handleNewSession,[k,C]=w.useState(null);let N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=new Map,e[11]=N):N=e[11];const _=w.useRef(N);let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=async U=>{if(xi===null)return null;const H=_.current;if(H.has(U))return H.get(U)??null;try{const K=await ve("/api/projects");if(!K.ok)return H.set(U,null),null;const q=await K.json(),Y=Mw(q,U,xi);return H.set(U,Y),Y}catch{return H.set(U,null),null}},e[12]=P):P=e[12];const A=P;let T;e[13]!==j?(T=async(U,H)=>{const K=H??null;if(!K){C(null),j(U);return}const q=Rt(U)===xi?xi:null,Y=q?Sl(q,K):await A(K);C(Y?{discoveredDirName:Y,cwd:K}:null),j(q&&Y?Y:U,K)},e[13]=j,e[14]=T):T=e[14];const E=T;let R;e[15]!==i||e[16]!==E?(R=U=>{const H=Sl(i,U);E(H,U)},e[15]=i,e[16]=E,e[17]=R):R=e[17];const I=R;let $;e[18]!==j||e[19]!==k?($=U=>{if(!k)return;const H=Sl(U,k.cwd,k.discoveredDirName);j(H,k.cwd)},e[18]=j,e[19]=k,e[20]=$):$=e[20];const M=$;let O;e:{if(!S.creatingSession||!a){O=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],O=H}const D=O;let L,F;e[25]!==a?(F=()=>{a||(b(null),C(null))},L=[a],e[25]=a,e[26]=L,e[27]=F):(L=e[26],F=e[27]),w.useEffect(F,L);const z=k?M:void 0;let W;return e[28]!==I||e[29]!==E||e[30]!==S.cancelCreation||e[31]!==S.clearCreateError||e[32]!==S.createAndSend||e[33]!==S.createError||e[34]!==S.creatingSession||e[35]!==S.setWorktreeEnabled||e[36]!==S.worktreeEnabled||e[37]!==D||e[38]!==z?(W={creatingSession:S.creatingSession,createError:S.createError,clearCreateError:S.clearCreateError,createAndSend:S.createAndSend,cancelCreation:S.cancelCreation,worktreeEnabled:S.worktreeEnabled,setWorktreeEnabled:S.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:D,pendingAgentKindChange:z,handleStartNewSession:E,handleStartNewFolder:I},e[28]=I,e[29]=E,e[30]=S.cancelCreation,e[31]=S.clearCreateError,e[32]=S.createAndSend,e[33]=S.createError,e[34]=S.creatingSession,e[35]=S.setWorktreeEnabled,e[36]=S.worktreeEnabled,e[37]=D,e[38]=z,e[39]=W):W=e[39],W}const hc=new Set;function Nz(n,e){const t=kn(),s=js();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function kz(n,e,t){const s=Nz(n,e);if(!hc.has(s)&&!_n.get(n,e)){hc.add(s);try{await qs(n,e,t,"session prefetch")}catch{}finally{hc.delete(s)}}}function Cz({onAuthenticated:n}){const[e,t]=w.useState(null),[s,o]=w.useState(""),[i,a]=w.useState(""),[l,c]=w.useState(!1),[d,u]=w.useState(null),[f,m]=w.useState(!1),p=e==="team";w.useEffect(()=>{let x=!1;return ng().then(b=>{x||t(b)}),()=>{x=!0}},[]);const h=w.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),u(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"}}),y=await b.json();b.ok&&y.valid?(Ea(),a(""),o(""),n()):u(y.error||(p?"Invalid credentials":"Invalid password"))}catch{u("Failed to connect to server")}finally{m(!1)}}},[p,n,i,s]),g=f||!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(Qt,{children:[r.jsxs(an,{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(xw,{className:"size-4"})}),r.jsx(ln,{children:"Sign in to Cogpit"}),r.jsx(pn,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(Zt,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(ot,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(Zt,{className:"flex flex-col gap-4",children:[r.jsxs(Io,{children:[p&&r.jsxs(St,{children:[r.jsx(Nt,{htmlFor:"login-username",children:"Username"}),r.jsx(Lt,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(St,{children:[r.jsx(Nt,{htmlFor:"login-password",children:"Password"}),r.jsxs(cs,{children:[r.jsx(ds,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(An,{align:"inline-end",children:r.jsx(qr,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(wa,{}):r.jsx(ys,{})})})]})]})]}),d&&r.jsxs(pt,{variant:"destructive",children:[r.jsx(qt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Sign in failed"}),r.jsx(ht,{children:d})]})]}),r.jsx(Oo,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g,children:[f&&r.jsx(ot,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const o1=16,Hi="__cogpitBootstrapToken";function _z(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[Hi]=="string"?t[Hi]:"");return e&&window.history.replaceState({...t,[Hi]:e},"",`${window.location.pathname}${window.location.search}`),s}function r1(){const n={...window.history.state||{}};delete n[Hi],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function Tz({onAuthenticated:n,onBootstrapClosed:e}){const[t]=w.useState(_z),[s,o]=w.useState(""),[i,a]=w.useState(""),[l,c]=w.useState(""),[d,u]=w.useState(""),[f,m]=w.useState(!1),[p,h]=w.useState(null),[g,x]=w.useState(!1),b=d.length>0&&d!==l,y=!t||!s.trim()||l.length<o1||d!==l,v=w.useCallback(async S=>{if(S.preventDefault(),!y){x(!0),h(null);try{const j=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 j.json();if(j.ok){r1(),c(""),u(""),o(""),a(""),await e(),n();return}if(j.status===410){r1(),await e();return}h(k.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!1)}}},[t,i,y,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(Qt,{children:[r.jsxs(an,{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(bw,{className:"size-4"})}),r.jsx(ln,{children:"Create the first admin"}),r.jsx(pn,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(Zt,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(pt,{children:[r.jsx(bn,{"aria-hidden":"true"}),r.jsx(Et,{children:"Setup link required"}),r.jsx(ht,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(Io,{children:[r.jsxs(St,{children:[r.jsx(Nt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(Lt,{id:"bootstrap-username",type:"text",value:s,onChange:S=>o(S.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(Co,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(St,{children:[r.jsxs(Nt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(Lt,{id:"bootstrap-display-name",type:"text",value:i,onChange:S=>a(S.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(St,{children:[r.jsx(Nt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(cs,{children:[r.jsx(ds,{id:"bootstrap-password",type:f?"text":"password",value:l,onChange:S=>c(S.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(An,{align:"inline-end",children:r.jsx(qr,{size:"icon-xs",onClick:()=>m(S=>!S),"aria-label":f?"Hide password":"Show password",children:f?r.jsx(wa,{}):r.jsx(ys,{})})})]}),r.jsxs(Co,{children:["Use at least ",o1," characters."]})]}),r.jsxs(St,{"data-invalid":b,children:[r.jsx(Nt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(Lt,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:S=>u(S.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":b}),b&&r.jsx(bs,{children:"Passwords do not match"})]})]}),p&&r.jsxs(pt,{variant:"destructive",children:[r.jsx(qt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Could not create the account"}),r.jsx(ht,{children:p})]})]}),r.jsx(Oo,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g||y,children:[g&&r.jsx(ot,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function Ez(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ta(),n[0]=e):e=n[0];const t=e,[s,o]=w.useState(null),[i,a]=w.useState(!1),[l,c]=w.useState(!1),d=w.useRef(0);let u,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{let T=!1;return tg().then(E=>{T||o(E)}),()=>{T=!0}},f=[],n[1]=u,n[2]=f):(u=n[1],f=n[2]),w.useEffect(u,f);const m=t?!0:s===null?null:s.edition==="team";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){a(!0),c(!0);return}let T=!1;const E=d.current;return Aj().then(R=>{!T&&d.current===E&&(a(R),c(!0))}),()=>{T=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),w.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let T=!1;const E=()=>{const R=d.current=d.current+1,I=()=>{T||d.current!==R||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){I();return}um().then($=>{T||d.current!==R||(o($),$.edition==="team"&&I())})};return window.addEventListener("cogpit-auth-required",E),()=>{T=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],w.useEffect(g,b);let y;n[10]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{d.current=d.current+1,a(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=y):y=n[10];const v=y;let S;n[11]===Symbol.for("react.memo_cache_sentinel")?(S=async()=>{o(await um())},n[11]=S):S=n[11];const j=S;let k;n[12]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{d.current=d.current+1,a(!1),c(!0),Rj().finally(Pz)},n[12]=k):k=n[12];const C=k,N=(s==null?void 0:s.edition)??null,_=l&&s!==null,P=(s==null?void 0:s.needsBootstrap)===!0;let A;return n[13]!==i||n[14]!==N||n[15]!==_||n[16]!==P?(A={isRemote:t,edition:N,authChecked:_,authenticated:i,needsBootstrap:P,handleAuthenticated:v,refreshServerState:j,logout:C},n[13]=i,n[14]=N,n[15]=_,n[16]=P,n[17]=A):A=n[17],A}function Pz(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const Az=w.lazy(()=>qe(()=>import("./index-ztb2qsgi.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.BranchModal}))),Rz=w.lazy(()=>qe(()=>import("./WorkflowsPanel-i3GanFyN.js"),__vite__mapDeps([38,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function $z(){var Pf,Af,Rf,$f,If,Mf,Of,Df,Lf,zf,Ff,Bf,Uf,Wf,Hf,Kf,qf,Vf,Gf,Yf;const n=Ju(window.location.pathname),e=PL(),t=Ez(),s=ML(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=Ya(),d=uv(),[u,f]=rv(),{procBySession:m}=H0(),{parse:p,append:h}=Sv(),g=w.useCallback(ke=>{f({type:"SET_OLDER_TURNS",turns:ke})},[f]),x=w.useCallback((ke,Ge)=>{kz(ke,Ge,p)},[p]),b=Nv({dirName:((Pf=u.sessionSource)==null?void 0:Pf.dirName)??null,fileName:((Af=u.sessionSource)==null?void 0:Af.fileName)??null,sessionChangeKey:u.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:y}=b,v=!!u.searchQuery&&b.hasMore,S=((Rf=u.session)==null?void 0:Rf.turns.length)??0;w.useEffect(()=>{v&&y()},[v,y,S]);const j=QL(u,f),k=w.useRef(null),C=w.useRef(null),[N,_]=w.useState(!1),[P,A]=w.useState(!1),T=w.useCallback(()=>f({type:"TOGGLE_EXPAND_ALL"}),[f]),E=w.useCallback(()=>_(!0),[]),R=w.useCallback(()=>{var ke;return(ke=C.current)==null?void 0:ke.focus()},[]),I=w.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!0}),[f]),$=w.useCallback(()=>f({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[f]),M=w.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!1}),[f]),O=j.toggleWorkspacePanel,D=w.useCallback(()=>O(It.sessionInfo),[O]),L=w.useCallback(ke=>{w.startTransition(()=>{f({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[f]),F=u.pendingCwd??(u.pendingDirName?Tn(u.pendingDirName):null),z=(($f=u.sessionSource)==null?void 0:$f.agentKind)??Rt(((If=u.sessionSource)==null?void 0:If.dirName)??u.pendingDirName??null),W=(Mf=u.session)!=null&&Mf.sessionId?m.get(u.session.sessionId):void 0,U=Vt(z),H=Xu(z,W),K=U.worktrees,q=U.mcp,Y=XL(i?((Of=u.session)==null?void 0:Of.cwd)??F??void 0:void 0,i&&U.slashCommands),V=w.useCallback(ke=>{if(!i)return;const Ge=Y.suggestions.find(Ct=>Ct.name===ke);w.startTransition(()=>{f({type:"OPEN_CONFIG",filePath:Ge==null?void 0:Ge.filePath})})},[i,f,Y.suggestions]),J=w.useCallback(async(ke,Ge)=>{if(!i)return null;const Ct=Y.suggestions.find(wn=>wn.name===ke);if(!(Ct!=null&&Ct.filePath))return null;try{const wn=await ve("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:Ct.filePath,args:Ge||""})});return wn.ok?(await wn.json()).content??null:null}catch{return null}},[i,Y.suggestions]),{processPanel:Q,currentCwd:X,showPreview:Z,showProjectFiles:te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ae,handleOpenTerminal:se,handleMcpAuth:fe,handleToggleIntegratedTerminal:le,handleNewIntegratedTerminal:ce,handleTogglePreview:me,handleToggleProjectFiles:ue,closeRightWorkspace:de}=az({sessionId:(Df=u.session)==null?void 0:Df.sessionId,sessionCwd:(Lf=u.session)==null?void 0:Lf.cwd,pendingPath:F,sessionDirName:(zf=u.sessionSource)==null?void 0:zf.dirName,pendingDirName:u.pendingDirName,dashboardProject:u.dashboardProject,supportsFileWorkspace:!c&&a,activeWorkspacePanel:j.activeWorkspacePanel,openWorkspacePanel:j.openWorkspacePanel,closeWorkspacePanel:j.closeWorkspacePanel}),be=qL(u.session??null),[ge,he]=w.useState(!1),je=((Ff=u.sessionSource)==null?void 0:Ff.dirName)??u.pendingDirName??u.dashboardProject??null,{activeWorkspacePanel:Se,closeWorkspacePanel:Pe,showWorkflows:Re}=j,$e=FL(o&&K&&u.mainView==="sessions"&&Se===It.worktrees?je:null),De=w.useMemo(()=>{const ke=u.session;return ke?ke.turns.some(Ge=>oa(Ge.toolCalls,ke.cwd)||Ge.subAgentActivity.some(Ct=>oa(Ct.toolCalls,ke.cwd))):!1},[u.session]),Le=w.useMemo(()=>{if(!u.session||!U.workflows)return 0;let ke=0;for(const Ge of u.session.turns)for(const Ct of Ge.toolCalls)Ct.name==="Workflow"&&ke++;return ke},[u.session,U.workflows]),ze=Le>0,Te=w.useMemo(()=>{const ke=u.sessionSource;return!ke||!U.workflows||Ns(ke.fileName)?{dirName:null,sessionId:null}:{dirName:ke.dirName,sessionId:jc(ke.fileName)}},[u.sessionSource,U.workflows]),_e=GD(Te.dirName,Te.sessionId,ze),We=ze||_e.workflows.length>0,Fe=_e.workflows.length||Le,Ne=j.setShowWorkflows,pe=w.useCallback(()=>Ne(!0),[Ne]),[Oe,Ae]=w.useState(!1),[Be,ie]=w.useState(!1),xe=j.openWorkspacePanel;w.useEffect(()=>{if(!a)return;const ke=()=>{c?Ae(!0):xe(It.fileChanges)};return window.addEventListener(kr,ke),()=>window.removeEventListener(kr,ke)},[a,xe,c]);const Ee=w.useMemo(()=>u.session?l0(u.session):null,[u.session]),Ie=w.useRef(null),{isLive:He,sseState:Ke,isCompacting:nt,streamingOverlay:Ye,turnError:Me,agentProgress:Ue,promptSuggestion:rt}=nv(u.sessionSource,ke=>{w.startTransition(()=>{f({type:"UPDATE_SESSION",session:ke})})},p,h,()=>{var ke;return(ke=Ie.current)==null?void 0:ke.call(Ie)},u.session),Gt=w.useMemo(()=>Ye.reduce((ke,Ge)=>ke+Ge.blocks.reduce((Ct,wn)=>Ct+wn.text.length,0),0),[Ye]),Wt=YL(((Bf=u.session)==null?void 0:Bf.cwd)??null),Yt=pL(),Xn=Yt.setMode,Ht=xL(H?null:((Uf=u.session)==null?void 0:Uf.sessionId)??null),Rs=H?null:Ht.plan??Ee,{selectedModel:Ve,setSelectedModel:Ze,selectedEffort:bt,setSelectedEffort:Ft,fastModeEnabled:Jn,ultracodeEnabled:Zs,effectiveEffort:ri,fastModeAvailable:Ev,fastModeActive:ii,setFastModeEnabled:ml,ultracodeAvailable:Pv,ultracodeActive:ai,setUltracodeEnabled:pl,imageInputAvailable:Qu,modelFallbackNotice:Av,dismissModelFallbackNotice:Rv,handleModelRejected:Zu}=sz({agentKind:z,session:u.session,sessionSource:u.sessionSource,pendingDirName:u.pendingDirName,isLive:He}),ef=UL((Wf=u.session)==null?void 0:Wf.sessionId,(Hf=u.sessionSource)==null?void 0:Hf.fileName);rz({sessionKey:ef,values:{model:Ve,effort:bt,fastMode:Jn,ultracode:Zs,permissionMode:Yt.config.mode},onHydrate:w.useCallback(ke=>{ke.model!==void 0&&Ze(ke.model),ke.effort!==void 0&&Ft(ke.effort),ke.fastMode!==void 0&&ml(ke.fastMode),ke.ultracode!==void 0&&pl(ke.ultracode),ke.permissionMode&&Xn(ke.permissionMode)},[Ze,Ft,ml,pl,Xn])});const mn=KL(q&&i?X:void 0,q&&i?je??void 0:void 0,q&&i?ef??void 0:void 0,i);w.useEffect(()=>{!K&&Se===It.worktrees&&Pe()},[K,Se,Pe]),w.useEffect(()=>{Re&&!We&&Ne(!1)},[Re,We,Ne]);const{creatingSession:tf,createError:nf,clearCreateError:$v,createAndSend:Iv,cancelCreation:sf,worktreeEnabled:Mv,setWorktreeEnabled:Ov,sessionFinalizedRef:li,liveSessionsRefreshRef:of,pendingSessionInfo:rf,pendingAgentKindChange:Dv,handleStartNewSession:af,handleStartNewFolder:Lv}=Sz({permissionsConfig:Yt.config,dispatch:f,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:u.pendingDirName,pendingCwd:u.pendingCwd,onModelRejected:Zu,model:Ve,effort:ri,fastMode:ii,ultracode:ai,mcpConfig:q&&i?mn.mcpConfigJson:null}),vt=JD({sessionSource:u.sessionSource,parsedSessionId:((Kf=u.session)==null?void 0:Kf.sessionId)??null,cwd:(qf=u.session)==null?void 0:qf.cwd,permissions:Yt.config,onPermissionsApplied:Yt.markApplied,model:Ve,effort:ri,fastMode:ii,ultracode:ai,mcpConfig:q&&i?mn.mcpConfigJson:null,onModelRejected:Zu,readOnly:H,onCreateSession:u.pendingDirName?Iv:void 0}),Bt=qD(U.agentTeams?((Vf=u.sessionSource)==null?void 0:Vf.fileName)??null:null,((Gf=u.sessionSource)==null?void 0:Gf.dirName)??null);w.useEffect(()=>{Bt!=null&&Bt.currentMemberName?f({type:"SET_CURRENT_MEMBER_NAME",name:Bt.currentMemberName}):Bt||f({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Bt==null?void 0:Bt.currentMemberName,Bt,f]),w.useEffect(()=>{c&&f({type:"GUARD_MOBILE_TAB",hasSession:!!u.session||!!u.pendingDirName})},[u.session,u.pendingDirName,u.mobileTab,c,f]);const $n=iv({session:u.session,isLive:He,pendingMessages:vt.pendingMessages,consumePending:vt.consumePending,sessionChangeKey:u.sessionChangeKey,partialContentLen:Gt}),lf=$n.chatScrollRef,cf=$n.resetTurnCount,df=$n.scrollToBottomInstant,zv=w.useCallback(ke=>{he(ke),requestAnimationFrame(()=>{const Ge=lf.current;Ge&&Ge.scrollTo({top:Ge.scrollTop+(ke?64:-64),behavior:"smooth"})})},[lf]);w.useLayoutEffect(()=>{const ke=Ge=>{cf(0),df()};return li.current=ke,()=>{li.current===ke&&(li.current=null)}},[cf,df,li]);const Fv=w.useCallback(()=>{vt.disconnect(),sf()},[vt.disconnect,sf]),In=eL({dispatch:f,isMobile:c,mobileTab:u.mobileTab,teamContext:Bt,scrollToBottomInstant:$n.scrollToBottomInstant,resetTurnCount:$n.resetTurnCount,workerParse:p,onBeforeSwitch:Fv}),Bv=w.useCallback(ke=>{w.startTransition(()=>{f({type:"GO_HOME",isMobile:c}),f({type:"SET_DASHBOARD_PROJECT",dirName:ke})})},[f,c]),{previewLoadError:Uv}=oL({state:u,dispatch:f,isMobile:c,resetTurnCount:$n.resetTurnCount,scrollToBottomInstant:$n.scrollToBottomInstant,workerParse:p}),ci=fL(),uf=ci.push;w.useEffect(()=>{u.sessionSource&&uf(u.sessionSource.dirName,u.sessionSource.fileName)},[u.sessionSource,uf]);const xt=tz({state:{session:u.session,sessionSource:u.sessionSource},dispatch:f,isMobile:c,handleJumpToTurn:In.handleJumpToTurn,markPermissionsApplied:Yt.markApplied,hasPermsPendingChanges:Yt.hasPendingChanges,permissionsConfig:Yt.config,selectedModel:Ve,selectedEffort:ri,fastMode:ii,ultracode:ai,mcpConfig:q&&i?mn.mcpConfigJson:null,scrollRequestScrollToTop:$n.requestScrollToTop,handleDashboardSelect:In.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:ff,handleApplySettings:mf}=xt,pf=q&&i&&mn.mcpConfigJson!==null,hf=w.useRef(!1);w.useEffect(()=>{var Ct;const ke=mn.loaded&&!hf.current;hf.current=mn.loaded;const Ge=(Ct=u.session)==null?void 0:Ct.sessionId;ke&&Ge&&pf&&ff&&mf()},[mn.loaded,pf,ff,mf,(Yf=u.session)==null?void 0:Yf.sessionId]),w.useLayoutEffect(()=>(Ie.current=xt.reloadSession,()=>{Ie.current===xt.reloadSession&&(Ie.current=null)}),[xt.reloadSession]);const Qn=yv(u.session,u.sessionSource,xt.reloadSession,a),di=Qn.requestBranchSwitch,ui=xt.setBranchModalTurn,Wv=w.useCallback((ke,Ge)=>{di(ke,Ge),ui(null)},[di,ui]),Hv=w.useCallback(ke=>{di(ke),ui(null)},[di,ui]);aL({isMobile:c,searchInputRef:k,chatInputRef:C,dispatch:f,onToggleSidebar:j.handleToggleSidebar,onToggleRightSidebar:D,onToggleMissionControl:j.handleToggleMission,onOpenCommandPalette:E,onOpenProjectSwitcher:j.handleOpenProjectSwitcher,onOpenThemeSelector:j.handleToggleThemeSelector,onOpenTerminal:se,onToggleIntegratedTerminal:le,onTogglePreview:me,onToggleProjectFiles:ue,onHistoryBack:ci.goBack,onHistoryForward:ci.goForward,onNavigateToSession:In.handleDashboardSelect,onCommitNavigation:ci.commitNavigation});const{killing:Kv,handleKillAll:qv}=BL(),us=u.sessionSource?Ns(u.sessionSource.fileName):null,Vv=us!==null&&!!(Bt!=null&&Bt.currentMemberName),hl=us!==null&&!Vv,fi=In.handleDashboardSelect,gf=w.useCallback(()=>{!u.sessionSource||!us||fi(u.sessionSource.dirName,us.parentFileName)},[u.sessionSource,us,fi]);w.useEffect(()=>{const ke=Ge=>{const{agentId:Ct}=Ge.detail??{};if(!Ct||!u.sessionSource||!U.subagentTranscripts)return;const wn=us?us.parentSessionId:jc(u.sessionSource.fileName);fi(u.sessionSource.dirName,`${wn}/subagents/agent-${Ct}.jsonl`)};return window.addEventListener(ra,ke),()=>window.removeEventListener(ra,ke)},[u.sessionSource,us,fi,U.subagentTranscripts]);const[Gv,xf]=w.useState(null),Yv=xt.branchModalTurn!==null,eo=xt.branchModalTurn??Gv;w.useEffect(()=>{xt.branchModalTurn!==null&&xf(xt.branchModalTurn)},[xt.branchModalTurn]);const bf=eo!==null?Qn.branchesAtTurn(eo):[],Xv=hl?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(wo,{"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,Jv=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(wo,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Qj(z)})]}):null,gl=Xv||Jv,Qv=In.loadError||nf||null;let xl;In.loadError?xl=In.clearLoadError:nf&&(xl=$v);const Zv=!!(u.session&&u.sessionSource&&Ke==="disconnected"),bl=w.useMemo(()=>({state:u,dispatch:f,config:e,theme:d,networkAuth:t,me:s,isMobile:c}),[u.activeTurnIndex,u.activeToolCallId,u.searchQuery,u.expandAll,u.expandToolPayloads,u.mainView,u.mobileTab,u.dashboardProject,u.pendingDirName,u.pendingCwd,u.currentMemberName,u.loadingMember,u.configFilePath,u.sessionChangeKey,f,e,d,t,s,c]),vl=w.useMemo(()=>({session:u.session,sessionSource:u.sessionSource,isLive:He,sseState:Ke,isCompacting:nt,turnError:Me,promptSuggestion:rt,undoRedo:Qn,pendingInteraction:Rs,permissionRequests:Ht.requests,permissionResponding:Ht.responding,respondPermission:Ht.respond,respondAllPermissions:Ht.respondAll,isSubAgentView:hl,slashSuggestions:Y.suggestions,slashSuggestionsLoading:Y.loading,actions:{handleStopSession:xt.handleStopSession,handleEditConfig:i?j.handleEditConfig:void 0,handleEditCommand:i?V:void 0,handleExpandCommand:i?J:void 0,handleOpenBranches:xt.handleOpenBranches,handleBranchFromHere:xt.handleBranchFromHere,handleToggleExpandAll:T,handleLoadSession:xt.handleLoadSessionScrollAware}}),[u.session,u.sessionSource,He,Ke,nt,Me,rt,Qn,Rs,hl,Ht.requests,Ht.responding,Ht.respond,Ht.respondAll,Y.suggestions,Y.loading,xt.handleStopSession,i,j.handleEditConfig,V,J,xt.handleOpenBranches,xt.handleBranchFromHere,T,xt.handleLoadSessionScrollAware]),yl=w.useMemo(()=>({chat:{status:vt.status,error:vt.error,pendingMessages:vt.pendingMessages,isConnected:vt.isConnected,sendMessage:vt.sendMessage,interrupt:vt.interrupt,stopAgent:vt.stopAgent,consumePending:vt.consumePending},scroll:$n}),[vt.status,vt.error,vt.pendingMessages,vt.isConnected,vt.sendMessage,vt.interrupt,vt.stopAgent,vt.consumePending,$n]),zo=!!u.pendingDirName&&!u.session;if(w.useEffect(()=>{if(!zo||c)return;const ke=requestAnimationFrame(()=>{var Ge;return(Ge=C.current)==null?void 0:Ge.focus()});return()=>cancelAnimationFrame(ke)},[zo,c,u.pendingDirName]),!t.authChecked)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Checking authentication",children:r.jsx(lt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx(Tz,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(Cz,{onAuthenticated:t.handleAuthenticated});if(!o)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading identity",children:r.jsx(lt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configLoading)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background",role:"status","aria-label":"Loading",children:r.jsx(lt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return r.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-background text-foreground",children:r.jsxs(dn,{children:[r.jsxs(un,{children:[r.jsx(vn,{variant:"icon",children:r.jsx(bn,{className:"text-destructive"})}),r.jsx(fn,{children:"Failed to connect"}),r.jsx(yn,{children:e.configError})]}),r.jsx(Y1,{children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(At,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(rN,{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 wl=r.jsx(_j,{activeError:Qv,clearActiveError:xl,modelFallbackNotice:Av,dismissModelFallbackNotice:Rv,connectionLost:Zv,theme:d.activeTheme}),vf=a?r.jsx(JS,{state:Qn.confirmState,isApplying:Qn.isApplying,applyError:Qn.applyError,onConfirm:Qn.confirmApply,onCancel:Qn.confirmCancel}):null,ey=eo!==null&&u.session?u.session.turns.slice(eo):[],yf=a&&eo!==null&&bf.length>0&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(Az,{open:Yv,branches:bf,branchPointTurnIndex:eo,currentTurns:ey,onClose:xt.handleCloseBranchModal,onCloseComplete:()=>xf(null),onRedoToTurn:Wv,onRedoEntireBranch:Hv})}),wf=l&&r.jsx(FS,{processes:Q.processes,activeProcessId:Q.activeProcessId,collapsed:Q.collapsed,onSetActive:Q.setActive,onRemove:Q.removeProcess,onToggleCollapse:Q.toggleCollapse,onRequestTerminal:ft("terminal")?ce:void 0,onAddTerminalContext:ke=>{var Xf,Jf,Qf;const Ge=ke.trim();if(!Ge)return;const Ct=Ge.includes("```")?"````":"```",wn=`${Ct}terminal
149
+ ${Ge}
150
+ ${Ct}`,jl=((Xf=C.current)==null?void 0:Xf.getText().trimEnd())??"";(Jf=C.current)==null||Jf.setText(jl?`${jl}
151
+
152
+ ${wn}
153
+ `:`${wn}
154
+ `),(Qf=C.current)==null||Qf.focus()},onUpdateStatus:Q.updateProcessStatus,projectDir:X,onProcessStarted:Q.addProcess,mobile:c}),jf=Bt&&r.jsx(O4,{teamName:Bt.config.name||Bt.teamName,members:Bt.config.members,currentMemberName:u.currentMemberName,loadingMember:u.loadingMember,onMemberClick:In.handleTeamMemberSwitch}),Sf=We&&r.jsx(w.Suspense,{fallback:null,children:r.jsx(Rz,{open:j.showWorkflows,onOpenChange:j.setShowWorkflows,dirName:Te.dirName,sessionId:Te.sessionId,workflows:_e.workflows,isLive:_e.isLive,onRefetchList:_e.refetch},`${Te.dirName??""}:${Te.sessionId??""}`)}),mi=U.goals?u.session:null,Nf=ke=>{var Ge;return r.jsx(R4,{agentKind:z,onAgentKindChange:zo?Dv:void 0,selectedModel:Ve,onModelChange:Ze,selectedEffort:ri,onEffortChange:Ft,fastModeEnabled:ii,onFastModeEnabledChange:Ev?ml:void 0,isNewSession:zo,worktreeEnabled:Mv,onWorktreeEnabledChange:zo&&K?Ov:void 0,ultracodeEnabled:ai,onUltracodeEnabledChange:Pv?pl:void 0,onApplySettings:xt.handleApplySettings,activeModelId:(Ge=u.session)==null?void 0:Ge.model,mcpServers:q&&i?mn.servers:void 0,selectedMcpServers:q&&i?mn.selectedServers:void 0,onToggleMcpServer:q&&i?mn.toggleServer:void 0,onRefreshMcpServers:q&&i?mn.refresh:void 0,mcpLoading:q&&i?mn.loading:void 0,onMcpAuth:q&&i?fe:void 0,permissionMode:Yt.config.mode,onPermissionModeChange:Yt.setMode,mobileExtra:c&&ke&&mi?r.jsx(hS,{}):void 0,trailingExtra:!c&&ke&&mi?r.jsx(Lg,{}):void 0,mobile:c})},kf=Nf(!0),Cf=Nf(!1),_f=r.jsxs("div",{className:"shrink-0 bg-background",children:[!c&&r.jsx(Dg,{}),r.jsx(Mc,{ref:C,allowImages:Qu,agentKind:z,projectCwd:X,compact:c,leadingAccessory:c?kf:void 0}),!c&&kf]}),pi=mi?r.jsx(pS,{agentKind:z,session:mi,onSendCommand:vt.sendMessage,children:_f}):_f,ty=r.jsxs("div",{className:"shrink-0 bg-background",children:[r.jsx(Mc,{ref:C,allowImages:Qu,agentKind:z,projectCwd:X,compact:c,leadingAccessory:c?Cf:void 0}),!c&&Cf]}),Tf=vt.pendingMessages.map((ke,Ge)=>r.jsx(w0,{message:ke,turnNumber:Ge+1},Ge)),ny=c?u.mobileTab==="stats":j.activeWorkspacePanel===It.sessionInfo,Ef=u.session&&!ny&&r.jsx("div",{className:"hidden",children:r.jsx(Kg,{cwd:u.session.cwd,turns:u.session.turns,onServersChanged:Q.handleServersChanged})});return n?r.jsxs(Bi,{value:bl,children:[r.jsx(El,{children:r.jsx(zi,{value:vl,chatValue:yl,children:r.jsx(Bl,{value:Ye,agentProgress:Ue,children:r.jsx(BD,{sessionId:n,loadError:Uv,searchInputRef:k,activeComposer:gl||ty,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore})})})}),wl]}):c?r.jsxs(Bi,{value:bl,children:[r.jsx(El,{enabled:l,children:r.jsx(zi,{value:vl,chatValue:yl,children:r.jsx(Bl,{value:Ye,agentProgress:Ue,children:r.jsx(FD,{navigation:{actions:In,handlers:xt,creatingSession:tf,pendingSession:rf,onStartNewSession:af,onSelectProject:L,liveSessionsRefreshRef:of,onPrefetchSession:x},sessionView:{searchInputRef:k,teamMembersBar:jf,activeComposer:gl||pi,pendingComposer:pi,pendingTurns:Tf,todoProgress:be&&r.jsx(j0,{progress:be}),hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:gf,onShowWorkflows:pe,onToggleExpandAll:T,workflowCount:Fe,pendingPath:F},project:{processPanel:Q,backgroundAgents:Wt,hasFileChanges:a&&De,onOpenTerminal:se},chrome:{backgroundServers:Ef,processPanel:wf,workflowsPanel:Sf,undoDialog:vf,branchModal:yf,fileChangesOpen:Oe,onFileChangesOpenChange:Ae,searchOpen:Be,onSearchOpenChange:ie}})})})}),wl]}):r.jsxs(Bi,{value:bl,children:[r.jsx(El,{enabled:l,children:r.jsx(zi,{value:vl,chatValue:yl,children:r.jsx(Bl,{value:Ye,agentProgress:Ue,children:r.jsx(AD,{navigation:{panels:j,actions:In,handlers:xt,creatingSession:tf,pendingSession:rf,onStartNewSession:af,onStartNewFolder:Lv,onSelectProject:L,onOpenPaletteProject:Bv,liveSessionsRefreshRef:of,onPrefetchSession:x},sessionView:{searchInputRef:k,chatInputRef:C,teamMembersBar:jf,activeComposer:gl||pi,pendingComposer:pi,pendingTurns:Tf,todoProgress:be,todosExpanded:ge,onTodosExpandedChange:zv,hasMoreTurns:b.hasMore,isLoadingOlderTurns:b.isLoadingOlder,onLoadMoreTurns:b.loadMore,onBackToMain:gf,onShowWorkflows:pe,workflowCount:Fe},project:{processPanel:Q,worktrees:$e,backgroundAgents:Wt,supportsWorktrees:K,hasFileChanges:a&&De,currentCwd:X,showPreview:Z,showProjectFiles:a&&te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ae,onOpenTerminal:se,onTogglePreview:me,onToggleProjectFiles:ue,onCloseRightWorkspace:de},chrome:{backgroundServers:Ef,processPanel:wf,workflowsPanel:Sf,undoDialog:vf,branchModal:yf,killing:Kv,onKillAll:qv,commandPaletteOpen:N,onCommandPaletteOpenChange:_,onOpenCommandPalette:E,onFocusComposer:R,onExpandAll:I,onExpandToolPayloads:$,onCollapseAll:M,keyboardShortcutsOpen:P,onKeyboardShortcutsOpenChange:A}})})})}),wl]})}function Iz(){var y;const[n,e]=w.useState(yt),[t,s]=w.useState(()=>Li(yt())),[o,i]=w.useState(js),[a,l]=w.useState(0),[c,d]=w.useState(!1),[u,f]=w.useState(!1),[m,p]=w.useState(!1),{devices:h,testDevice:g}=sl();w.useEffect(()=>{const v=()=>{const S=yt();e(j=>j===S?j:S),s(Li(S))};return window.addEventListener("cogpit-device-changed",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("cogpit-device-changed",v),window.removeEventListener("popstate",v)}},[]),w.useEffect(()=>{const v=S=>{const j=S.detail;(j==null?void 0:j.deviceId)===yt()&&s(Li(j.deviceId))};return window.addEventListener("cogpit-device-scope-changed",v),()=>window.removeEventListener("cogpit-device-scope-changed",v)},[]),w.useEffect(()=>{const v=()=>i(js());return window.addEventListener("cogpit-identity-changed",v),()=>window.removeEventListener("cogpit-identity-changed",v)},[]),w.useEffect(()=>(window.__cogpitRevealSession=q2,()=>{delete window.__cogpitRevealSession}),[]),w.useEffect(()=>{const v=S=>{const j=[Tt,...h.map(_=>_.id)],k=yt();let C;const N=wP(S);if(N!==null)C=j[N-1];else if(jP(S)){const _=j.indexOf(k);C=j[(_+1)%j.length]}!C||C===k||(S.preventDefault(),Ss(C))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[h]),w.useEffect(()=>{const v=S=>{const j=S.detail;!(j!=null&&j.deviceId)||j.deviceId!==yt()||(d(!0),j.reason==="DEVICE_AUTH_FAILED"&&f(!0))};return window.addEventListener("cogpit-device-unreachable",v),()=>window.removeEventListener("cogpit-device-unreachable",v)},[]),w.useEffect(()=>{d(!1),f(!1),p(!1)},[n,t]);const x=w.useCallback(async()=>{p(!0);try{const v=await g(n);v.reachable&&v.authState==="bad-password"?f(!0):v.ok&&(d(!1),f(!1),l(S=>S+1))}finally{p(!1)}},[n,g]);w.useEffect(()=>{if(!c||u)return;const v=setInterval(()=>void x(),1e4);return()=>clearInterval(v)},[c,u,x]);const b=((y=h.find(v=>v.id===n))==null?void 0:y.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==Tt&&r.jsxs(pt,{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(vw,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(Et,{children:u?"Device credentials need attention":"Remote device unavailable"}),r.jsx(ht,{children:u?`${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:[!u&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:()=>void x(),disabled:m,children:[m&&r.jsx(lt,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),r.jsx(ee,{variant:"outline",size:"xs",onClick:()=>Ss(Tt),children:"Switch to this machine"})]})]}),r.jsx(e7,{children:r.jsx(HO,{children:r.jsx($z,{})})},`${n}:${t}:${a}:${o??""}`)]})}const i1="Invalid link or passphrase.";function Mz(n,e){return n===401?i1: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||i1}function Oz({sessionId:n,onAuthenticated:e}){const[t,s]=w.useState(""),[o,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(!1),u=w.useCallback(async f=>{if(f.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(Mz(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:u,className:"w-full max-w-sm",children:r.jsxs(Qt,{children:[r.jsxs(an,{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(os,{className:"size-4"})}),r.jsx(ln,{children:"Join this session"}),r.jsx(pn,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(Zt,{className:"flex flex-col gap-4",children:[r.jsx(Io,{children:r.jsxs(St,{children:[r.jsx(Nt,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(cs,{children:[r.jsx(ds,{id:"share-passphrase",type:o?"text":"password",value:t,onChange:f=>s(f.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),r.jsx(An,{align:"inline-end",children:r.jsx(qr,{size:"icon-xs",onClick:()=>i(f=>!f),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(wa,{}):r.jsx(ys,{})})})]})]})}),a&&r.jsxs(pt,{variant:"destructive",children:[r.jsx(qt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Could not join"}),r.jsx(ht,{children:a})]})]}),r.jsx(Oo,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(ot,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function Dz(){const n=B.c(9),[e,t]=w.useState("idle"),[s,o]=w.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=w.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>{l(y=>[...y,x]),t("connected"),o(void 0),q5(x,b).then(y=>{if(y.ok){t("idle");return}o(`Request failed (${y.status})`),t("error"),l(Fz)}).catch(y=>{o(y instanceof Error?y.message:"Unknown error"),t("error"),l(zz)})},n[1]=c):c=n[1];const d=c;let u;n[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{V5().catch(Lz),t("idle"),l([])},n[2]=u):u=n[2];const f=u;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const b=x===void 0?1:x;l(y=>y.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:f,stopAgent:f,consumePending:p},n[4]=s,n[5]=a,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function Lz(){}function zz(n){return n.slice(0,-1)}function Fz(n){return n.slice(0,-1)}const Bz=2e3;function Uz(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function Wz(){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]=w.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=w.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const y=await J5();h||y===null||s(v=>Uz(v,y)?v:y)},x=()=>{document.visibilityState==="visible"&&g()};x();const b=setInterval(x,Bz);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]),w.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),Y5(h,g).then(x=>{x&&s(b=>b.filter(y=>y.requestId!==h))}).finally(()=>{a(x=>{const b=new Set(x);return b.delete(h),b})})},n[4]=d):d=n[4];const u=d;let f;n[5]!==t?(f=h=>{for(const g of t)u(g.requestId,h)},n[5]=t,n[6]=f):f=n[6];const m=f;let p;return n[7]!==t||n[8]!==m||n[9]!==i?(p={requests:t,responding:i,respond:u,respondAll:m},n[7]=t,n[8]=m,n[9]=i,n[10]=p):p=n[10],p}const _v={authenticated:!0,edition:"personal",user:null,capabilities:Ur};function Hz(n){var ce,me;const e=B.c(78),{info:t,children:s}=n,o=Ya(),i=uv(),[a,l]=rv(),{parse:c,append:d}=Sv(),[u,f]=w.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],w.useEffect(Yz,m);const p=Dz(),h=Wz();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:ue,source:de}=await lv(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:ue,source:de,isMobile:o}),f("ready")}catch{f("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=w.useRef(!1);let y,v;e[7]!==x?(y=()=>{b.current||(b.current=!0,x())},v=[x],e[7]=x,e[8]=y,e[9]=v):(y=e[8],v=e[9]),w.useEffect(y,v);let S;e[10]!==l?(S=ue=>{l({type:"UPDATE_SESSION",session:ue})},e[10]=l,e[11]=S):S=e[11];const j=S,{isLive:k,sseState:C,isCompacting:N,turnError:_}=nv(a.sessionSource,j,c,d,void 0,a.session);let P;e[12]!==l?(P=ue=>{l({type:"SET_OLDER_TURNS",turns:ue})},e[12]=l,e[13]=P):P=e[13];const A=P,T=((ce=a.sessionSource)==null?void 0:ce.dirName)??null,E=((me=a.sessionSource)==null?void 0:me.fileName)??null;let R;e[14]!==A||e[15]!==a.sessionChangeKey||e[16]!==T||e[17]!==E||e[18]!==c?(R={dirName:T,fileName:E,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:A},e[14]=A,e[15]=a.sessionChangeKey,e[16]=T,e[17]=E,e[18]=c,e[19]=R):R=e[19];const I=Nv(R);let $;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==k||e[23]!==a.session||e[24]!==a.sessionChangeKey?($={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]=$):$=e[25];const M=iv($),O=yv(a.session,a.sessionSource,x,!1);let D;e[26]!==a.session?(D=a.session?l0(a.session):null,e[26]=a.session,e[27]=D):D=e[27];const L=D;let F;e[28]!==l?(F=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=F):F=e[29];const z=F,W=Vz,U=qz;let H;e[30]!==t.dirName?(H=Rt(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:Ta(),edition:"personal",authChecked:!0,authenticated:!0,needsBootstrap:!1,handleAuthenticated:U,refreshServerState:Kz,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:_v,isMobile:o},e[35]=l,e[36]=o,e[37]=a,e[38]=K,e[39]=i,e[40]=Y):Y=e[40];const V=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]!==O?(X={session:a.session,sessionSource:a.sessionSource,isLive:k,sseState:C,isCompacting:N,turnError:_,undoRedo:O,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]=O,e[57]=X):X=e[57];const Z=X;let te;e[58]!==p||e[59]!==M?(te={chat:p,scroll:M},e[58]=p,e[59]=M,e[60]=te):te=e[60];const ne=te;let oe;e[61]!==I?(oe=()=>{I.loadMore()},e[61]=I,e[62]=oe):oe=e[62];let re;e[63]!==u||e[64]!==I.hasMore||e[65]!==I.isLoadingOlder||e[66]!==oe?(re={loadState:u,hasMore:I.hasMore,isLoadingOlder:I.isLoadingOlder,loadMore:oe},e[63]=u,e[64]=I.hasMore,e[65]=I.isLoadingOlder,e[66]=oe,e[67]=re):re=e[67];const ae=re;let se;e[68]!==s||e[69]!==ae?(se=s(ae),e[68]=s,e[69]=ae,e[70]=se):se=e[70];let fe;e[71]!==ne||e[72]!==Z||e[73]!==se?(fe=r.jsx(zi,{value:Z,chatValue:ne,children:se}),e[71]=ne,e[72]=Z,e[73]=se,e[74]=fe):fe=e[74];let le;return e[75]!==V||e[76]!==fe?(le=r.jsx(Bi,{value:V,children:fe}),e[75]=V,e[76]=fe,e[77]=le):le=e[77],le}function Kz(){return Promise.resolve()}function qz(){}async function Vz(){await G5().catch(Gz)}function Gz(){}function Yz(){go(_v)}function Xz(n){const e=B.c(6),{info:t}=n,s=w.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(os,{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(pt,{variant:"destructive",className:"max-w-sm",children:[r.jsx(qt,{"aria-hidden":"true"}),r.jsx(Et,{children:"Session unavailable"}),r.jsx(ht,{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(ot,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(nl,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(ul,{children:r.jsx(Mc,{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(Hz,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function gc(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 Jz(){const n=B.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ag(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]=w.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await K5();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]),w.useEffect(c,d);let u,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=()=>{i(Qz)};return window.addEventListener(Ic,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(Ic,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=u,n[6]=f):(u=n[5],f=n[6]),w.useEffect(u,f),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(Xz,{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(Oz,{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(gc,{children:r.jsx(Qt,{children:r.jsxs(an,{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(yw,{className:"size-4"})}),r.jsx(ln,{children:"Sharing has ended"}),r.jsx(pn,{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(qt,{"aria-hidden":"true"}),h=r.jsx(Et,{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(pt,{variant:"destructive",children:[p,h,r.jsx(ht,{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(gc,{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(gc,{children:r.jsx(Qt,{children:r.jsxs(Zt,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(os,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(ot,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function Qz(n){return n.kind==="ready"?{kind:"ended"}:n}class Zz extends w.Component{constructor(){super(...arguments);hi(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(Qt,{className:"w-full max-w-lg text-center",children:[r.jsxs(an,{className:"justify-items-center",children:[r.jsx(bn,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(ln,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(pn,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(Zt,{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(Oo,{className:"justify-center",children:r.jsxs(ee,{onClick:()=>window.location.reload(),children:[r.jsx(At,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Tv=document.getElementById("root");if(!Tv)throw new Error("Root element not found");ay.createRoot(Tv).render(r.jsx(w.StrictMode,{children:r.jsx(Zz,{children:Oa(window.location.pathname)?r.jsx(Jz,{}):r.jsx(Iz,{})})}));export{Kt as $,pt as A,ee as B,cF as C,rs as D,dn as E,t9 as F,fn as G,yn as H,An as I,_g as J,tl as K,rF as L,Pa as M,kg as N,Cg as O,Ng as P,_t as Q,Mw as R,k4 as S,sl as T,Io as U,St as V,qr as W,bs as X,QT as Y,ZT as Z,G as _,C4 as a,tN as a$,U5 as a0,Nr as a1,Ce as a2,ot as a3,BE as a4,Gc as a5,wu as a6,Da as a7,Sg as a8,Od as a9,ex as aA,Dr as aB,yF as aC,Xa as aD,an as aE,ln as aF,Zt as aG,Oo as aH,Qt as aI,Va as aJ,m0 as aK,Qs as aL,Yn as aM,Hs as aN,Un as aO,Et as aP,pn as aQ,Hd as aR,Hr as aS,VD as aT,Ia as aU,Nt as aV,Co as aW,DA as aX,sn as aY,aF as aZ,Lt as a_,Dd as aa,Ld as ab,Fd as ac,Bd as ad,zd as ae,Wd as af,Ud as ag,Vr as ah,rx as ai,Gd as aj,Pn as ak,zr as al,it as am,$t as an,at as ao,GS as ap,Is as aq,Jl as ar,vP as as,d5 as at,lF as au,Md as av,Bs as aw,ft as ax,Vd as ay,Zg as az,_4 as b,Ca as b0,qg as b1,iF as b2,Mt as b3,Ot as b4,Dt as b5,Qa as b6,Za as b7,el as b8,vo as b9,fF as ba,rn as bb,Cr as bc,KS as bd,ut as be,d4 as bf,uF as bg,mu as bh,D0 as bi,hu as bj,M0 as bk,Js as bl,H0 as bm,KO as bn,$b as bo,Jr as bp,Cs as bq,F_ as br,N4 as c,v4 as d,mF as e,bP as f,pF as g,is as h,Ps as i,as as j,ls as k,kt as l,cs as m,ds as n,xF as o,ht as p,Gn as q,gF as r,bF as s,vF as t,hF as u,Hb as v,ve as w,dF as x,un as y,vn as z};