cogpit 2.6.0 → 2.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2323 -2393
- package/dist/web/assets/{CommandPaletteHost-DfaMCzBW.js → CommandPaletteHost-DrCXDZkP.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-CYyPu1XZ.js → ConfigBrowser-B3IvCBt5.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-D0E4fNIR.js → HighlightedEditor-Cm-79JuL.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-Cmk72Wcu.js → KeyboardShortcutsDialog-DKPBP4Tr.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B5e6WRrN.js → MobileFileChanges-B2aGoWIm.js} +1 -1
- package/dist/web/assets/{PreviewPanel-L5TxNJuc.js → PreviewPanel-Bo7DnIca.js} +1 -1
- package/dist/web/assets/ProjectFilesPanel-BURFV70d.js +4 -0
- package/dist/web/assets/{ProjectSwitcherModal-D37bS3Y8.js → ProjectSwitcherModal-lncPQd9P.js} +1 -1
- package/dist/web/assets/{TerminalOutput-qo7CUaKh.js → TerminalOutput-fFrlHJcb.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-DeKpqiLO.js → ThemeSelectorModal-E23TFwmi.js} +1 -1
- package/dist/web/assets/WorkflowsPanel-dlTy3KtX.js +1 -0
- package/dist/web/assets/WorktreePanel-psgNQDIs.js +1 -0
- package/dist/web/assets/{index-C1O8__7w.js → index-BtpxC457.js} +1 -1
- package/dist/web/assets/index-C-D_sWB4.js +1 -0
- package/dist/web/assets/{index-aYw7Kb2u.js → index-CImOF4Hf.js} +1 -1
- package/dist/web/assets/index-CriFWu3H.js +1 -0
- package/dist/web/assets/index-DOkVkYA9.js +157 -0
- package/dist/web/assets/index-DpPYXAB1.css +1 -0
- package/dist/web/assets/session-parser.worker-DlF00ZHH.js +29 -0
- package/dist/web/assets/vendor-ui-DpPWL3l4.js +922 -0
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/ProjectFilesPanel-9mVexNJQ.js +0 -4
- package/dist/web/assets/WorkflowsPanel-Dvy1NPzW.js +0 -1
- package/dist/web/assets/WorktreePanel-DJdlsguj.js +0 -1
- package/dist/web/assets/index-BnTYSkBh.css +0 -1
- package/dist/web/assets/index-CdXCbj1g.js +0 -157
- package/dist/web/assets/index-CyRmDc3P.js +0 -1
- package/dist/web/assets/index-vzYZixNy.js +0 -1
- package/dist/web/assets/session-parser.worker-CnmfpqaO.js +0 -29
- package/dist/web/assets/vendor-ui-CevbH8m5.js +0 -907
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-fFrlHJcb.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-DpPWL3l4.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-DrCXDZkP.js","assets/index-C-D_sWB4.js","assets/KeyboardShortcutsDialog-DKPBP4Tr.js","assets/ProjectSwitcherModal-lncPQd9P.js","assets/ThemeSelectorModal-E23TFwmi.js","assets/ProjectFilesPanel-BURFV70d.js","assets/HighlightedEditor-Cm-79JuL.js","assets/WorktreePanel-psgNQDIs.js","assets/index-CriFWu3H.js","assets/index-CImOF4Hf.js","assets/ConfigBrowser-B3IvCBt5.js","assets/PreviewPanel-Bo7DnIca.js","assets/MobileFileChanges-B2aGoWIm.js","assets/index-BtpxC457.js","assets/WorkflowsPanel-dlTy3KtX.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var my=Object.defineProperty;var py=(n,e,t)=>e in n?my(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var gi=(n,e,t)=>py(n,typeof e!="symbol"?e+"":e,t);import{c as B,j as r,d as je,e as hy,r as y,a as gy,f as xy}from"./vendor-react-gGw_S5I_.js";import{aC as by,aD as vy,aE as yy,aF as Qn,ae as tt,aG as wy,N as un,aH as id,at as On,aI as jy,aJ as Sy,aK as Ny,aL as ky,aM as Cy,aN as _y,a2 as nt,aO as Ty,J as lt,aP as Ey,al as Ay,b as Et,aQ as Py,aR as x1,aS as $y,aT as Iy,aU as Ry,aV as My,aW as Oy,aX as b1,aY as Vi,h as Gi,aZ as v1,G as $n,a_ as ad,a$ as Ly,b0 as Dy,b1 as zy,b2 as Fy,b3 as By,b4 as Uy,b5 as Wy,b6 as Hy,b7 as qy,b8 as Ky,b9 as Vy,ba as Gy,bb as Yy,bc as Er,bd as Xy,be as ld,bf as cd,bg as dd,bh as y1,bi as ud,bj as Ar,X as Qe,bk as fd,bl as Jy,I as md,af as Zn,bm as Qy,bn as w1,bo as j1,bp as uo,bq as ks,br as Zy,bs as e3,bt as t3,bu as n3,bv as dr,S as tn,z as go,bw as Us,bx as S1,by as s3,bz as o3,bA as N1,bB as k1,bC as C1,bD as r3,bE as i3,bF as _1,bG as T1,bH as a3,bI as E1,bJ as l3,bK as c3,bL as d3,ah as Pr,bM as u3,$ as ha,o as Yi,aa as gs,bN as mc,bO as f3,bP as m3,bQ as p3,bR as h3,bS as g3,bT as x3,bU as b3,bV as pd,bW as v3,bX as Wt,A as fn,bY as y3,bZ as w3,b_ as j3,b$ as S3,c0 as N3,c1 as k3,c2 as xo,c3 as $r,c4 as C3,j as ga,c5 as _3,c6 as T3,c7 as E3,c8 as A3,c9 as P3,ca as $3,cb as I3,cc as R3,cd as M3,ce as O3,C as Ve,P as In,y as Ws,d as A1,cf as L3,cg as D3,ch as z3,ci as F3,F as bo,ai as Hs,cj as B3,ck as P1,W as hd,f as xa,a9 as ba,cl as U3,cm as va,cn as pc,co as W3,R as gd,cp as H3,cq as q3,a0 as Ls,c as $1,cr as K3,t as ya,cs as xd,a1 as zi,ct as V3,cu as Ir,cv as I1,cw as G3,cx as Y3,cy as xi,cz as Es,aj as im,k as Rr,D as bd,cA as X3,a5 as J3,cB as Q3,au as Z3,u as wa,O as ew,V as vd,cC as tw,cD as nw,a4 as ur,cE as sw,cF as ow,cG as rw,cH as iw,cI as aw,cJ as R1,cK as lw,cL as yd,ar as cw,cM as dw,n as am,cN as uw,cO as lm,l as ja,cP as fw,cQ as wd,i as Mr,B as M1,cR as mw,a6 as jd,s as pw,cS as hw,cT as O1,q as L1,av as D1,w as gw,cU as xw,cV as bw,cW as vw,cX as yw,cY as ww,cZ as Vt,Q as z1,c_ as jw,ao as cm,an as Sw,c$ as Nw,d0 as kw,d1 as F1,d2 as Sd,d3 as Cw,d4 as _w,d5 as B1,d6 as Tw,d7 as hc,ay as Ew,d8 as Aw,d9 as U1,da as Pw,p as $w,db as Iw,dc as W1,dd as xs,de as Rw,ad as Mw,L as Ow,x as Lw,ap as Dw,df as zw,ac as Fw,dg as Bw}from"./vendor-ui-DpPWL3l4.js";import{c as Uw,a as Ww}from"./vendor-shiki-DOn6sF-i.js";import{r as Hw,M as Ln}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 qw="modulepreload",Kw=function(n){return"/"+n},dm={},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=Kw(d),d in dm)return;dm[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":qw,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)})},bs=["codex","copilot","claude"],gc="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";function Vw(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 Gw(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 H1(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),encode:e=>Vw(n,e),decode:e=>Gw(n,e)}}function q1(n){const e=new RegExp(`(${gc})\\.jsonl$`,"i").exec(n);return e?e[1]:null}const K1={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function V1(n){return`'${n.replace(/'/g,"'\\''")}'`}function fr(n,e){return e?[n,e]:[]}function Xi(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const Ji="[0-9a-f-]{36}",G1="codex__",Y1="copilot__",Yw=new Set(["default","plan","acceptEdits","dontAsk","auto"]),X1={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(G1)&&!n.startsWith(Y1),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:q1,...K1},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"]:[...Yw.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=>Xi(n,new RegExp(`--resume(?:=|\\s+)(${Ji})`))??Xi(n,new RegExp(`--session-id(?:=|\\s+)(${Ji})`))}},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",pluginManifestDir:".claude-plugin"},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,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}},um={appServerValue:"priority",cliConfigValue:"fast"},Xw={kind:"codex",displayName:"Codex",binName:"codex",dirName:H1(G1),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:q1,...K1},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${V1(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(um.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:um,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=>Xi(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${Ji})`))}},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,pluginManifestDir: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,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}},Jw={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:H1(Y1),sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:n=>{const e=new RegExp(`^(${gc})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null},urlId:n=>{const e=new RegExp(`^(${gc})/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 ${V1(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=>Xi(n,new RegExp(`--resume(?:=|\\s+)(${Ji})`))}},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,pluginManifestDir: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,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:X1,codex:Xw,copilot:Jw});function on(n){return mr[n]}function Sa(){return bs.map(n=>mr[n])}function Qw(n,e){const t=Sa().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function Cs(n){for(const e of bs)if(e!=="claude"&&mr[e].dirName.owns(n))return mr[e];return X1}function At(n){return Cs(n).kind}function wl(n,e,t){const s=mr[n].dirName;return t&&s.lossy?t:s.encode(e)}const qs=Cs(null).kind;var h1;const bi=((h1=Sa().find(n=>n.dirName.lossy))==null?void 0:h1.kind)??null;function vo(n){return Cs(n).capabilities}function Bt(n){return on(n).capabilities}function Zw(n,e){return bs.find(t=>t===n)??e}function xc(n){for(const e of Sa()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function ej(n,e){return Cs(n).sessionFile.urlId(e)}function tj(n,e){return Cs(n).sessionFile.fileNameFromUrlId(e)}function J1(n,e,t){return on(n).resume.command(e,t)}function nj(n,e){const t=on(n);return{command:t.binName,args:[...t.resume.args(e)]}}function fm(n){return n.replace(/\/+$/,"")||"/"}function sj(n,e,t){var o;const s=fm(e);return((o=n.find(i=>Cs(i.dirName).kind===t&&fm(i.path)===s))==null?void 0:o.dirName)??null}const oj=[{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"}],Nd=[{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"}],Q1=[...Nd,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],vi=Nd.slice(0,4);var g1;const Yo=[{value:((g1=on("codex").serviceTier)==null?void 0:g1.appServerValue)??"priority",label:"Fast",description:"1.5× speed with increased usage"}],mm={isDefault:!0,defaultReasoningEffort:"medium",supportedReasoningEfforts:Q1,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Yo},rj=[{value:"",label:"Default",description:"Use Codex's recommended model (GPT-5.6 Sol)",resolvedModel:"gpt-5.6-sol",...mm},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Flagship model for the most ambitious work",...mm},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Balanced model for everyday work",defaultReasoningEffort:"medium",supportedReasoningEfforts:Q1,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Yo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Fastest, most cost-efficient model",defaultReasoningEffort:"medium",supportedReasoningEfforts:Nd,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:Yo},{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex real-world work",defaultReasoningEffort:"medium",supportedReasoningEfforts:vi,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Yo},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong model for everyday coding",defaultReasoningEffort:"medium",supportedReasoningEfforts:vi,inputModalities:["text","image"],supportsPersonality:!0,serviceTiers:Yo},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Small, fast model for simpler tasks",defaultReasoningEffort:"medium",supportedReasoningEfforts:vi,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:vi,inputModalities:["text"],supportsPersonality:!0}],ij=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],aj={claude:oj,codex:rj,copilot:ij};function lj(n){return aj[n]}function K(...n){return by(vy(n))}const Z1=new Map,bc=new Set;function cj(n,e){!Array.isArray(e)||e.length===0||(Z1.set(n,e),bc.forEach(t=>t()))}function dj(n){return bc.add(n),()=>bc.delete(n)}const pm="high",uj=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function fj(n){return Z1.get(n)??lj(n)}function Or(n,e){return e?n.find(t=>t.value===e):n.find(t=>t.value!==""&&t.isDefault)??n.find(t=>t.value==="")??n.find(t=>t.value!=="")}function eg(n,e,t){const s=Or(e,t),o=s==null?void 0:s.supportedReasoningEfforts;return o&&o.length>0?o:(s==null?void 0:s.supportsEffort)===!1||!Bt(n).reasoningEffort?[]:uj}function mj(n,e){var t,s;return(s=(t=Or(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(o=>o.value==="fast"||o.value==="priority"||o.label.toLowerCase()==="fast")}function pj(n,e,t){var o;const s=(o=Or(e,t))==null?void 0:o.inputModalities;return s?s.includes("image"):Bt(n).imageInput}function hj(n,e,t){var o;const s=Bt(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((o=Or(e,t))==null?void 0:o.supportsAutoMode)===!0}function gj(n,e){return Bt(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function xj(n,e,t,s){var l;const o=eg(n,e,s);if(o.length===0)return"";const i=c=>!!c&&o.some(d=>d.value===c);if(i(t))return t;const a=(l=Or(e,s))==null?void 0:l.defaultReasoningEffort;return i(a)?a:i(pm)?pm:o[0].value}function bj(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Na(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.activeElement,t=document.createElement("textarea");t.value=n,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),s}}const vj=Qn("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=K(vj({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(yy,{"data-slot":"button",className:a,...s}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Gt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Yt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 yj=Qn("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 nn(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=K(yj({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 Xt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 sn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 tg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 wj(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 jj=n=>{switch(n){case"success":return kj;case"info":return _j;case"warning":return Cj;case"error":return Tj;default:return null}},Sj=Array(12).fill(0),Nj=({visible:n,className:e})=>je.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},je.createElement("div",{className:"sonner-spinner"},Sj.map((t,s)=>je.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),kj=je.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},je.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"})),Cj=je.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},je.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"})),_j=je.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},je.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"})),Tj=je.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},je.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"})),Ej=je.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"},je.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),je.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Aj=()=>{const[n,e]=je.useState(document.hidden);return je.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let Pj=1;const $j=100,hm=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:Pj++};class Ij{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-$j;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=hm(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],je.isValidElement(d))i=!1,this.create({id:s,type:"default",message:d});else if(Mj(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"&&!je.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"&&!je.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"&&!je.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"&&!je.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=hm(t);return this.create({...t,jsx:e(s),id:s,type:void 0}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}}const qt=new Ij,Rj=(n,e)=>qt.message(n,e),Mj=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",Oj=Rj,Lj=()=>qt.toasts,Dj=()=>qt.getActiveToasts(),qn=Object.assign(Oj,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:Lj,getToasts:Dj});wj("[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 yi(n){return n.label!==void 0}const zj=3,Fj="24px",Bj="16px",gm=4e3,Uj=356,Wj=14,Hj=45,qj=200;function Cn(...n){return n.filter(Boolean).join(" ")}function Kj(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const Vj=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:v,toasts:w,expanded:b,removeToast:j,defaultRichColors:S,closeButton:N,style:C,cancelButtonStyle:k,actionButtonStyle:T,className:E="",descriptionClassName:P="",duration:_,position:A,gap:I,expandByDefault:R,classNames:$,icons:M,closeButtonAriaLabel:L="Close toast"}=n,[D,F]=je.useState(null),[z,O]=je.useState(null),[H,W]=je.useState(!1),[U,V]=je.useState(!1),[q,X]=je.useState(!1),[G,Y]=je.useState(!1),[J,Q]=je.useState(!1),[Z,te]=je.useState(0),[ne,oe]=je.useState(0),re=je.useRef(f.duration||_||gm),ie=je.useRef(null),se=je.useRef(null),de=v===0,ce=v+1<=g,ue=f.type,me=ue??"default",fe=f.dismissible!==!1,ae=f.className||"",ve=f.descriptionClassName||"",ge=je.useMemo(()=>x.findIndex(Ee=>Ee.toastId===f.id)||0,[x,f.id]),ye=je.useMemo(()=>{var Ee;return(Ee=f.closeButton)!=null?Ee:N},[f.closeButton,N]),Pe=je.useMemo(()=>f.duration||_||gm,[f.duration,_]),De=je.useRef(0),Te=je.useRef(0),Ae=je.useRef(0),pe=je.useRef(null),[xe,ke]=A.split("-"),$e=je.useMemo(()=>x.reduce((Ee,Be,le)=>le>=ge?Ee:Ee+Be.height,0),[x,ge]),we=Aj(),be=je.useMemo(()=>{var Ee;return(Ee=n.swipeDirections)!=null?Ee:Kj(A)},[n.swipeDirections,A]),Le=f.invert||u,Se=ue==="loading";Te.current=je.useMemo(()=>ge*I+$e,[ge,$e]),je.useEffect(()=>{re.current=Pe},[Pe]),je.useEffect(()=>{W(!0)},[]),je.useEffect(()=>{const Ee=se.current;if(Ee){const Be=Ee.getBoundingClientRect().height;return oe(Be),h(le=>[{toastId:f.id,height:Be,position:f.position},...le]),()=>h(le=>le.filter(he=>he.toastId!==f.id))}},[h,f.id]),je.useLayoutEffect(()=>{if(!H)return;const Ee=se.current,Be=Ee.style.height;Ee.style.height="auto";const le=Ee.getBoundingClientRect().height;Ee.style.height=Be,oe(le),h(he=>he.find(ze=>ze.toastId===f.id)?he.map(ze=>ze.toastId===f.id?{...ze,height:le}:ze):[{toastId:f.id,height:le,position:f.position},...he])},[H,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const Re=je.useCallback(()=>{V(!0),te(Te.current),h(Ee=>Ee.filter(Be=>Be.toastId!==f.id)),setTimeout(()=>{j(f)},qj)},[f,j,h,Te]);je.useEffect(()=>{if(f.promise&&ue==="loading"||f.duration===1/0||f.type==="loading")return;let Ee;return b||p||we?(()=>{if(Ae.current<De.current){const he=new Date().getTime()-De.current;re.current=re.current-he}Ae.current=new Date().getTime()})():(()=>{re.current!==1/0&&(De.current=new Date().getTime(),Ee=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Re()},re.current))})(),()=>clearTimeout(Ee)},[b,p,f,ue,we,Re]),je.useEffect(()=>{f.delete&&(Re(),f.onDismiss==null||f.onDismiss.call(f,f))},[Re,f.delete]);function Ne(){var Ee;if(M!=null&&M.loading){var Be;return je.createElement("div",{className:Cn($==null?void 0:$.loader,f==null||(Be=f.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":ue==="loading"},M.loading)}return je.createElement(Nj,{className:Cn($==null?void 0:$.loader,f==null||(Ee=f.classNames)==null?void 0:Ee.loader),visible:ue==="loading"})}const Fe=f.icon||(M==null?void 0:M[ue])||jj(ue);var He,We;return je.createElement("li",{tabIndex:0,ref:se,className:Cn(E,ae,$==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":(He=f.richColors)!=null?He:S,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":H,"data-promise":!!f.promise,"data-swiped":J,"data-removed":U,"data-visible":ce,"data-y-position":xe,"data-x-position":ke,"data-index":v,"data-front":de,"data-swiping":q,"data-dismissible":fe,"data-type":ue,"data-invert":Le,"data-swipe-out":G,"data-swipe-direction":z,"data-expanded":!!(b||R&&H),"data-testid":f.testId,style:{"--index":v,"--toasts-before":v,"--z-index":w.length-v,"--offset":`${U?Z:Te.current}px`,"--initial-height":R?"auto":`${ne}px`,...C,...f.style},onDragEnd:()=>{X(!1),F(null),pe.current=null},onPointerDown:Ee=>{Ee.button!==2&&(Se||!fe||(ie.current=new Date,te(Te.current),Ee.target.setPointerCapture(Ee.pointerId),Ee.target.tagName!=="BUTTON"&&(X(!0),pe.current={x:Ee.clientX,y:Ee.clientY})))},onPointerUp:()=>{var Ee,Be,le;if(G||!fe)return;pe.current=null;const he=Number(((Ee=se.current)==null?void 0:Ee.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ue=Number(((Be=se.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ze=new Date().getTime()-((le=ie.current)==null?void 0:le.getTime()),Oe=D==="x"?he:Ue,Ye=Math.abs(Oe)/ze;if((D==="x"?be.includes(he>0?"right":"left"):be.includes(Ue>0?"bottom":"top"))&&(Math.abs(Oe)>=Hj||Ye>.11)){te(Te.current),f.onDismiss==null||f.onDismiss.call(f,f),O(D==="x"?he>0?"right":"left":Ue>0?"down":"up"),Re(),Y(!0);return}else{var ut,ot;(ut=se.current)==null||ut.style.setProperty("--swipe-amount-x","0px"),(ot=se.current)==null||ot.style.setProperty("--swipe-amount-y","0px")}Q(!1),X(!1),F(null)},onPointerMove:Ee=>{var Be,le,he;if(!pe.current||!fe||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;const ze=Ee.clientY-pe.current.y,Oe=Ee.clientX-pe.current.x;!D&&(Math.abs(Oe)>1||Math.abs(ze)>1)&&F(Math.abs(Oe)>Math.abs(ze)?"x":"y");let Ye={x:0,y:0};const Mt=ut=>1/(1.5+Math.abs(ut)/20);if(D==="y"){if(be.includes("top")||be.includes("bottom"))if(be.includes("top")&&ze<0||be.includes("bottom")&&ze>0)Ye.y=ze;else{const ut=ze*Mt(ze);Ye.y=Math.abs(ut)<Math.abs(ze)?ut:ze}}else if(D==="x"&&(be.includes("left")||be.includes("right")))if(be.includes("left")&&Oe<0||be.includes("right")&&Oe>0)Ye.x=Oe;else{const ut=Oe*Mt(Oe);Ye.x=Math.abs(ut)<Math.abs(Oe)?ut:Oe}(Math.abs(Ye.x)>0||Math.abs(Ye.y)>0)&&Q(!0),(le=se.current)==null||le.style.setProperty("--swipe-amount-x",`${Ye.x}px`),(he=se.current)==null||he.style.setProperty("--swipe-amount-y",`${Ye.y}px`)}},ye&&!f.jsx&&ue!=="loading"?je.createElement("button",{"aria-label":L,"data-disabled":Se,"data-close-button":!0,onClick:Se||!fe?()=>{}:()=>{Re(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Cn($==null?void 0:$.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(We=M==null?void 0:M.close)!=null?We:Ej):null,(ue||f.icon||f.promise)&&f.icon!==null&&((M==null?void 0:M[ue])!==null||f.icon)?je.createElement("div",{"data-icon":"",className:Cn($==null?void 0:$.icon,f==null||(o=f.classNames)==null?void 0:o.icon)},ue==="loading"?f.icon||Ne():f.promise?Ne():null,ue!=="loading"?Fe:null):null,je.createElement("div",{"data-content":"",className:Cn($==null?void 0:$.content,f==null||(i=f.classNames)==null?void 0:i.content)},je.createElement("div",{"data-title":"",className:Cn($==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?je.createElement("div",{"data-description":"",className:Cn(P,ve,$==null?void 0:$.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),je.isValidElement(f.cancel)?f.cancel:f.cancel&&yi(f.cancel)?je.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||k,onClick:Ee=>{yi(f.cancel)&&fe&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,Ee),Re())},className:Cn($==null?void 0:$.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,je.isValidElement(f.action)?f.action:f.action&&yi(f.action)?je.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||T,onClick:Ee=>{yi(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,Ee),!Ee.defaultPrevented&&Re())},className:Cn($==null?void 0:$.actionButton,f==null||(d=f.classNames)==null?void 0:d.actionButton)},f.action.label):null)};function xm(){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 Gj(n,e){const t={};return[n,e].forEach((s,o)=>{const i=o===1,a=i?"--mobile-offset":"--offset",l=i?Bj:Fj;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 Yj=je.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=zj,toastOptions:v,dir:w=xm(),gap:b=Wj,icons:j,customAriaLabel:S,containerAriaLabel:N="Notifications"}=e,[C,k]=je.useState([]),T=je.useMemo(()=>s?C.filter(W=>W.toasterId===s):C.filter(W=>!W.toasterId),[C,s]),E=je.useMemo(()=>Array.from(new Set([i].concat(T.filter(W=>W.position).map(W=>W.position)))),[T,i]),[P,_]=je.useState([]),[A,I]=je.useState(!1),[R,$]=je.useState(!1),[M,L]=je.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=je.useRef(null),F=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),z=je.useRef(null),O=je.useRef(!1),H=je.useCallback(W=>{k(U=>{var V;return(V=U.find(q=>q.id===W.id))!=null&&V.delete||qt.dismiss(W.id),U.filter(({id:q})=>q!==W.id)})},[]);return je.useEffect(()=>qt.subscribe(W=>{if(W.dismiss){requestAnimationFrame(()=>{k(U=>U.map(V=>V.id===W.id?{...V,delete:!0}:V))});return}setTimeout(()=>{hy.flushSync(()=>{k(U=>{const V=U.findIndex(q=>q.id===W.id);return V!==-1?[...U.slice(0,V),{...U[V],...W},...U.slice(V+1)]:[W,...U]})})})}),[]),je.useEffect(()=>{if(m!=="system"){L(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),typeof window>"u")return;const W=window.matchMedia("(prefers-color-scheme: dark)");try{W.addEventListener("change",({matches:U})=>{L(U?"dark":"light")})}catch{W.addListener(({matches:V})=>{try{L(V?"dark":"light")}catch(q){console.error(q)}})}},[m]),je.useEffect(()=>{C.length<=1&&I(!1)},[C]),je.useEffect(()=>{const W=U=>{var V;if(a.length>0&&a.every(G=>U[G]||U.code===G)){var X;I(!0),(X=D.current)==null||X.focus()}U.code==="Escape"&&(document.activeElement===D.current||(V=D.current)!=null&&V.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[a]),je.useEffect(()=>{if(D.current)return()=>{z.current&&(z.current.focus({preventScroll:!0}),z.current=null,O.current=!1)}},[D.current]),je.createElement("section",{ref:t,"aria-label":S??`${N} ${F}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},E.map((W,U)=>{var V;const[q,X]=W.split("-");return T.length?je.createElement("ol",{key:W,dir:w==="auto"?xm():w,tabIndex:-1,ref:D,className:d,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":q,"data-x-position":X,style:{"--front-toast-height":`${((V=P[0])==null?void 0:V.height)||0}px`,"--width":`${Uj}px`,"--gap":`${b}px`,...g,...Gj(u,f)},onBlur:G=>{O.current&&!G.currentTarget.contains(G.relatedTarget)&&(O.current=!1,z.current&&(z.current.focus({preventScroll:!0}),z.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||O.current||(O.current=!0,z.current=G.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{R||I(!1)},onDragEnd:()=>I(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},T.filter(G=>!G.position&&U===0||G.position===W).map((G,Y)=>{var J,Q;return je.createElement(Vj,{key:G.id,icons:j,index:Y,toast:G,defaultRichColors:p,duration:(J=v==null?void 0:v.duration)!=null?J:h,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:o,visibleToasts:x,closeButton:(Q=v==null?void 0:v.closeButton)!=null?Q:c,interacting:R,position:W,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,closeButtonAriaLabel:v==null?void 0:v.closeButtonAriaLabel,removeToast:H,toasts:T.filter(Z=>Z.position==G.position),heights:P.filter(Z=>Z.position==G.position),setHeights:_,expandByDefault:l,gap:b,expanded:A,swipeDirections:e.swipeDirections})})):null}))}),Xj=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(On,{className:"size-4"}),info:r.jsx(id,{className:"size-4"}),warning:r.jsx(un,{className:"size-4"}),error:r.jsx(wy,{className:"size-4"}),loading:r.jsx(tt,{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(Yj,{className:"toaster group",icons:s,style:o,...t}),e[4]=t,e[5]=i):i=e[5],i};function Jj(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){qn.dismiss("app-error");return}qn.error(t,{id:"app-error",duration:8e3,onDismiss:s,onAutoClose:s})},d=[t,s],e[0]=t,e[1]=s,e[2]=c,e[3]=d):(c=e[2],d=e[3]),y.useEffect(c,d);let u,f;e[4]!==i||e[5]!==o?(u=()=>{if(!o){qn.dismiss("model-fallback");return}qn.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]),y.useEffect(u,f);let m,p;e[8]!==a?(m=()=>{if(!a){qn.dismiss("session-connection");return}qn.warning("Connection lost",{id:"session-connection",description:"Reconnecting to the live session…",duration:1/0})},p=[a],e[8]=a,e[9]=m,e[10]=p):(m=e[9],p=e[10]),y.useEffect(m,p);const h=l==="light"?"light":"dark";let g;return e[11]!==h?(g=r.jsx(Xj,{theme:h,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[11]=h,e[12]=g):g=e[12],g}const Nt="local",ng="cogpit-last-path::",vc=new Map;function gt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Nt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Nt}function Ds(){return gt()!==Nt}function sg(){const n=gt();return n===Nt?"":`/hub/${n}`}function og(n){const e=sg();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let pr=null;function rg(n){n!==pr&&(pr=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function vs(){return pr}function Fi(n){return n===Nt?0:vc.get(n)??0}function Qj(n,e){if(n===Nt||!Number.isSafeInteger(e)||e<0)return!1;const t=vc.get(n);return t!==void 0&&e<=t?!1:(vc.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function gn(){const n=gt(),e=Fi(n);return e===0?n:`${n}@${e}`}function Ht(n){const e=gt(),t=gn();return pr!==null?`${n}::${t}::${pr}`:e===Nt?n:`${n}::${t}`}function zo(n,e){sessionStorage.setItem(`${ng}${n}`,e)}function ys(n){const t=sessionStorage.getItem(`${ng}${n}`)??(n===Nt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const bm="cogpit-network-token",Zj=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function kd(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!Zj.has(e)}function ka(){try{localStorage.removeItem(bm),sessionStorage.removeItem(bm)}catch{}}typeof window<"u"&&ka();const e4={edition:"personal",needsBootstrap:!1};let hr=null,fo=null;function ig(){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 fo=e.edition==="team"?"team":"personal",{edition:fo,needsBootstrap:fo==="team"&&e.needsBootstrap===!0}}).catch(()=>(hr=null,e4))}function ag(){return hr??(hr=ig()),hr}function vm(){return hr=ig(),hr}function lg(){return ag().then(n=>n.edition)}async function t4(){if(!kd()&&fo!=="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 n4(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{ka()}}function ym(){return ka(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function cg(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=og(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(kd()||fo==="team")return ym();if(fo===null)return lg().then(i=>i==="team"?ym():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 _e(n,e){return cg(n,e,!0)}function Dn(n,e,t={}){return _e(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function cs(n,e){return cg(n,e,!1)}function Lr(n){return og(n)}const s4=300*1e3,o4=30*1e3;let yc=0,Fo=null;function r4(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 i4(){try{const n=await _e("/api/models");if(!n.ok)throw new Error(`GET /api/models → ${n.status}`);const e=await n.json();for(const t of bs){const s=e==null?void 0:e[t];r4(s)&&cj(t,s)}yc=Date.now()+s4}catch{yc=Date.now()+o4}}function Cd(){return Fo||(Date.now()<yc?Promise.resolve():(Fo=i4().finally(()=>{Fo=null}),Fo))}function a4(){const n=()=>{document.visibilityState==="visible"&&Cd()};return window.addEventListener("focus",n),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",n)}}function l4(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],y.useEffect(c4,t);let s;return e[1]!==n?(s=()=>fj(n),e[1]=n,e[2]=s):s=e[2],y.useSyncExternalStore(dj,s)}function c4(){return Cd(),a4()}function dg(n,e){const t=B.c(26),s=l4(n);let o;t[0]!==n||t[1]!==e||t[2]!==s?(o=eg(n,s,e),t[0]=n,t[1]=e,t[2]=s,t[3]=o):o=t[3];let i;t[4]!==e||t[5]!==s?(i=mj(s,e),t[4]=e,t[5]=s,t[6]=i):i=t[6];let a;t[7]!==n||t[8]!==e||t[9]!==s?(a=pj(n,s,e),t[7]=n,t[8]=e,t[9]=s,t[10]=a):a=t[10];let l;t[11]!==n||t[12]!==e||t[13]!==s?(l=hj(n,s,e),t[11]=n,t[12]=e,t[13]=s,t[14]=l):l=t[14];let c;t[15]!==n||t[16]!==e||t[17]!==s?(c=u=>xj(n,s,u,e),t[15]=n,t[16]=e,t[17]=s,t[18]=c):c=t[18];let d;return t[19]!==s||t[20]!==o||t[21]!==i||t[22]!==a||t[23]!==l||t[24]!==c?(d={options:s,effortOptions:o,fastTier:i,imageInput:a,autoPermissionMode:l,normalizeEffort:c},t[19]=s,t[20]=o,t[21]=i,t[22]=a,t[23]=l,t[24]=c,t[25]=d):d=t[25],d}function _d(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(jy,{"data-slot":"popover",...t}),e[2]=t,e[3]=s):s=e[3],s}function Td(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(Sy,{"data-slot":"popover-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function d4(n){const e=B.c(22);let t,s,o,i,a,l,c,d;e[0]!==n?({align:i,alignOffset:a,side:l,sideOffset:c,collisionPadding:d,collisionAvoidance:s,className: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,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?"start":i,f=a===void 0?0:a,m=l===void 0?"bottom":l,p=c===void 0?6:c,h=d===void 0?8:d;let g;e[9]!==t?(g=K("z-50 max-h-(--available-height) origin-(--transform-origin) rounded-xl bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10 outline-none duration-100 ease-out data-[side=bottom]:slide-in-from-top-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[9]=t,e[10]=g):g=e[10];let x;e[11]!==o||e[12]!==g?(x=r.jsx(Ny,{"data-slot":"popover-content",className:g,...o}),e[11]=o,e[12]=g,e[13]=x):x=e[13];let v;return e[14]!==u||e[15]!==f||e[16]!==s||e[17]!==h||e[18]!==m||e[19]!==p||e[20]!==x?(v=r.jsx(ky,{children:r.jsx(Cy,{className:"isolate z-50 outline-none",align:u,alignOffset:f,side:m,sideOffset:p,collisionPadding:h,collisionAvoidance:s,children:x})}),e[14]=u,e[15]=f,e[16]=s,e[17]=h,e[18]=m,e[19]=p,e[20]=x,e[21]=v):v=e[21],v}const u4=new Set(["mcp","server","servers","api","app","the","and"]),f4=/^([\w-]+\.[a-z]{2,})\s+(.+)$/i;function ug(n){const e=f4.exec(n.trim());return e?{short:e[2],namespace:e[1]}:{short:n.trim()}}function m4(n){const{short:e}=ug(n),t=e.split(/[^a-z0-9]+/i).filter(i=>i&&!u4.has(i.toLowerCase())),s=t.length>0?t:[e];return(s.length>=2?s[0][0]+s[1][0]:s[0].slice(0,2)).toUpperCase()}function Ed(n){return n?"bottom":"top"}function Ad(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=K("max-w-72 data-popup-open:bg-accent data-popup-open:text-accent-foreground",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(nt,{"data-icon":"inline-end",className:"opacity-60"}),e[6]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function Pd(n){const e=B.c(13);let t,s,o,i;e[0]!==n?({side:o,align:i,className:t,...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=i===void 0?"start":i;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l={side:"none",align:"shift",fallbackAxisSide:"none"},e[5]=l):l=e[5];let c;e[6]!==t?(c=K("flex flex-col overflow-hidden p-0",t),e[6]=t,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==s||e[10]!==o||e[11]!==c?(d=r.jsx(d4,{side:o,align:a,collisionAvoidance:l,className:c,...s}),e[8]=a,e[9]=s,e[10]=o,e[11]=c,e[12]=d):d=e[12],d}function mo(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("px-2 pb-1 pt-1.5 text-[11px] font-medium uppercase tracking-wide 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",{className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function wc(n){const e=B.c(16);let t,s,o,i,a;e[0]!==n?({value:a,onValueChange:i,className:o,children:s,...t}=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]!==i?(l=u=>i(u),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==o?(c=K("flex flex-col gap-px",o),e[8]=o,e[9]=c):c=e[9];let d;return e[10]!==t||e[11]!==s||e[12]!==l||e[13]!==c||e[14]!==a?(d=r.jsx(_y,{value:a,onValueChange:l,className:c,...t,children:s}),e[10]=t,e[11]=s,e[12]=l,e[13]=c,e[14]=a,e[15]=d):d=e[15],d}const p4="flex w-full cursor-pointer select-none items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm outline-none transition-colors duration-100 hover:bg-accent/70 focus-visible:ring-2 focus-visible:ring-ring/40";function $d(n){const e=B.c(16),{value:t,title:s,description:o,icon:i,disabled:a}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=K(p4,"group/option data-checked:bg-accent data-checked:text-accent-foreground data-disabled:cursor-not-allowed data-disabled:opacity-40 data-disabled:hover:bg-transparent"),e[0]=l):l=e[0];let c;e[1]!==i?(c=i&&r.jsx(i,{className:"size-4 shrink-0 text-muted-foreground group-data-checked/option:text-foreground"}),e[1]=i,e[2]=c):c=e[2];let d;e[3]!==s?(d=r.jsx("span",{className:"truncate leading-5 group-data-checked/option:font-medium",children:s}),e[3]=s,e[4]=d):d=e[4];let u;e[5]!==o?(u=o&&r.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground",title:o,children:o}),e[5]=o,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[d,u]}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ty,{keepMounted:!0,className:"shrink-0 text-foreground opacity-0 transition-opacity duration-100 data-checked:opacity-100",children:r.jsx(lt,{className:"size-4"})}),e[10]=m):m=e[10];let p;return e[11]!==a||e[12]!==c||e[13]!==f||e[14]!==t?(p=r.jsxs(Ey,{value:t,disabled:a,className:l,children:[c,f,m]}),e[11]=a,e[12]=c,e[13]=f,e[14]=t,e[15]=p):p=e[15],p}const h4=8;function g4(n){const e=B.c(89),{servers:t,selected:s,onToggle:o,onSetSelection:i,onRefresh:a,loading:l,onAuth:c,isNewSession:d}=n,[u,f]=y.useState(""),m=y.useId();let p,h,g,x,v,w,b,j,S,N,C,k,T,E,P,_,A;if(e[0]!==u||e[1]!==d||e[2]!==m||e[3]!==l||e[4]!==c||e[5]!==a||e[6]!==i||e[7]!==o||e[8]!==s||e[9]!==t){const M=t.filter(v4),L=t.filter(b4);let D;e[27]!==s?(D=new Set(s),e[27]=s,e[28]=D):D=e[28];const F=D;let z;e[29]!==F?(z=ce=>F.has(ce.name),e[29]=F,e[30]=z):z=e[30];const O=M.filter(z).length,H=l&&t.length===0,W=H?"MCPs":`MCPs ${O}/${M.length}`,U=u.trim().toLowerCase(),V=ce=>!U||ce.name.toLowerCase().includes(U),q=M.filter(V),X=L.filter(V);h=_d,b=!1,e[31]===Symbol.for("react.memo_cache_sentinel")?(j=ce=>{ce||f("")},e[31]=j):j=e[31];let G;e[32]!==W?(G=r.jsx(Ad,{"aria-label":W}),e[32]=W,e[33]=G):G=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Ay,{"data-icon":"inline-start"}),e[34]=Y):Y=e[34];let J;e[35]!==W?(J=r.jsx("span",{className:"truncate",children:W}),e[35]=W,e[36]=J):J=e[36];let Q;e[37]!==H?(Q=H&&r.jsx(Et,{className:"size-3 animate-spin","aria-hidden":!0}),e[37]=H,e[38]=Q):Q=e[38],e[39]!==G||e[40]!==J||e[41]!==Q?(S=r.jsxs(Td,{render:G,children:[Y,J,Q]}),e[39]=G,e[40]=J,e[41]=Q,e[42]=S):S=e[42],p=Pd,e[43]!==d?(_=Ed(d),e[43]=d,e[44]=_):_=e[44],A="MCP servers",x="w-[23rem]";const Z=M.length>0&&r.jsxs("span",{"aria-hidden":!0,className:"ml-1.5 font-normal normal-case tracking-normal",children:[O," on"]});let te;e[45]!==m||e[46]!==Z?(te=r.jsxs(mo,{id:m,className:"pt-1",children:["MCP servers",Z]}),e[45]=m,e[46]=Z,e[47]=te):te=e[47];const ne=i&&M.length>1&&r.jsxs(r.Fragment,{children:[r.jsx(wm,{label:"Turn every server on",disabled:O===M.length,onClick:()=>i(M.map(x4)),children:"All"}),r.jsx(wm,{label:"Turn every server off",disabled:O===0,onClick:()=>i([]),children:"None"})]}),oe=l&&"animate-spin";let re;e[48]!==oe?(re=K(oe),e[48]=oe,e[49]=re):re=e[49];let ie;e[50]!==re?(ie=r.jsx(Et,{className:re}),e[50]=re,e[51]=ie):ie=e[51];let se;e[52]!==a||e[53]!==ie?(se=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:a,"aria-label":"Refresh status",title:"Refresh status",className:"text-muted-foreground",children:ie}),e[52]=a,e[53]=ie,e[54]=se):se=e[54];let de;e[55]!==ne||e[56]!==se?(de=r.jsxs("div",{className:"flex items-center gap-0.5",children:[ne,se]}),e[55]=ne,e[56]=se,e[57]=de):de=e[57],e[58]!==te||e[59]!==de?(v=r.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-1.5 pt-1.5",children:[te,de]}),e[58]=te,e[59]=de,e[60]=v):v=e[60],e[61]!==u||e[62]!==t.length?(w=t.length>h4&&r.jsx("div",{className:"shrink-0 px-1.5 pt-1",children:r.jsx("input",{type:"search",value:u,onChange:ce=>f(ce.target.value),placeholder:"Filter servers…","aria-label":"Filter servers",className:"h-7 w-full rounded-md bg-muted/60 px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/40 [&::-webkit-search-cancel-button]:hidden"})}),e[61]=u,e[62]=t.length,e[63]=w):w=e[63],g="group",N=m,C="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-1.5",e[64]!==l||e[65]!==t.length?(k=t.length===0&&r.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:l?"Loading…":"No MCP servers configured"}),e[64]=l,e[65]=t.length,e[66]=k):k=e[66],T=t.length>0&&q.length===0&&X.length===0&&r.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:"No servers match."}),E=q.length>0&&r.jsx("div",{className:"grid grid-cols-2 gap-1",children:q.map(ce=>r.jsx(jm,{server:ce,on:F.has(ce.name),onClick:()=>o(ce.name)},ce.name))}),P=X.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(mo,{className:"px-0.5 pt-2 text-warning/80",children:"Needs sign-in"}),r.jsx("div",{className:"grid grid-cols-2 gap-1",children:X.map(ce=>r.jsx(jm,{server:ce,onClick:()=>c(ce.name)},ce.name))})]}),e[0]=u,e[1]=d,e[2]=m,e[3]=l,e[4]=c,e[5]=a,e[6]=i,e[7]=o,e[8]=s,e[9]=t,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=v,e[15]=w,e[16]=b,e[17]=j,e[18]=S,e[19]=N,e[20]=C,e[21]=k,e[22]=T,e[23]=E,e[24]=P,e[25]=_,e[26]=A}else p=e[10],h=e[11],g=e[12],x=e[13],v=e[14],w=e[15],b=e[16],j=e[17],S=e[18],N=e[19],C=e[20],k=e[21],T=e[22],E=e[23],P=e[24],_=e[25],A=e[26];let I;e[67]!==g||e[68]!==N||e[69]!==C||e[70]!==k||e[71]!==T||e[72]!==E||e[73]!==P?(I=r.jsxs("div",{role:g,"aria-labelledby":N,className:C,children:[k,T,E,P]}),e[67]=g,e[68]=N,e[69]=C,e[70]=k,e[71]=T,e[72]=E,e[73]=P,e[74]=I):I=e[74];let R;e[75]!==p||e[76]!==x||e[77]!==v||e[78]!==w||e[79]!==I||e[80]!==_||e[81]!==A?(R=r.jsxs(p,{side:_,"aria-label":A,className:x,children:[v,w,I]}),e[75]=p,e[76]=x,e[77]=v,e[78]=w,e[79]=I,e[80]=_,e[81]=A,e[82]=R):R=e[82];let $;return e[83]!==h||e[84]!==b||e[85]!==j||e[86]!==S||e[87]!==R?($=r.jsxs(h,{modal:b,onOpenChange:j,children:[S,R]}),e[83]=h,e[84]=b,e[85]=j,e[86]=S,e[87]=R,e[88]=$):$=e[88],$}function x4(n){return n.name}function b4(n){return n.status!=="connected"}function v4(n){return n.status==="connected"}function wm(n){const e=B.c(5),{label:t,disabled:s,onClick:o,children:i}=n;let a;return e[0]!==i||e[1]!==s||e[2]!==t||e[3]!==o?(a=r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-label":t,title:t,disabled:s,onClick:o,className:"h-6 px-1.5 text-[11px] text-muted-foreground",children:i}),e[0]=i,e[1]=s,e[2]=t,e[3]=o,e[4]=a):a=e[4],a}function jm(n){const e=B.c(34),{server:t,on:s,onClick:o}=n;let i;e[0]!==t.name?(i=ug(t.name),e[0]=t.name,e[1]=i):i=e[1];const{short:a,namespace:l}=i,c=s===void 0,d=c?void 0:"checkbox",u=c?void 0:s,f=c?`${t.name}, needs sign-in`:t.name,m=c?`${t.name} · Sign in to connect`:t.name,p=c&&"bg-warning/5 ring-warning/25 hover:bg-warning/10",h=s===!0&&"bg-accent text-accent-foreground ring-foreground/10",g=s===!1&&"text-muted-foreground ring-transparent hover:bg-accent/60 hover:text-foreground";let x;e[2]!==p||e[3]!==h||e[4]!==g?(x=K("flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm outline-none ring-1 ring-inset transition-[background-color,box-shadow,color] duration-100 focus-visible:ring-2 focus-visible:ring-ring/40",p,h,g),e[2]=p,e[3]=h,e[4]=g,e[5]=x):x=e[5];const v=c&&"bg-warning/15 text-warning",w=s===!0&&"bg-primary text-primary-foreground",b=s===!1&&"bg-muted text-muted-foreground";let j;e[6]!==v||e[7]!==w||e[8]!==b?(j=K("flex size-6 shrink-0 items-center justify-center rounded-md text-[10px] font-semibold tracking-wide transition-colors duration-100",v,w,b),e[6]=v,e[7]=w,e[8]=b,e[9]=j):j=e[9];let S;e[10]!==t.name?(S=m4(t.name),e[10]=t.name,e[11]=S):S=e[11];let N;e[12]!==j||e[13]!==S?(N=r.jsx("span",{"aria-hidden":!0,className:j,children:S}),e[12]=j,e[13]=S,e[14]=N):N=e[14];let C;e[15]!==a?(C=r.jsx("span",{className:"truncate leading-4",children:a}),e[15]=a,e[16]=C):C=e[16];let k;e[17]!==l?(k=l&&r.jsx("span",{className:"truncate text-[10px] leading-3 text-muted-foreground",children:l}),e[17]=l,e[18]=k):k=e[18];let T;e[19]!==C||e[20]!==k?(T=r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,k]}),e[19]=C,e[20]=k,e[21]=T):T=e[21];let E;e[22]!==c?(E=c&&r.jsx(Py,{className:"size-3.5 shrink-0 text-warning","aria-hidden":!0}),e[22]=c,e[23]=E):E=e[23];let P;return e[24]!==o||e[25]!==N||e[26]!==T||e[27]!==E||e[28]!==d||e[29]!==u||e[30]!==f||e[31]!==m||e[32]!==x?(P=r.jsxs("button",{type:"button",role:d,"aria-checked":u,"aria-label":f,title:m,onClick:o,className:x,children:[N,T,E]}),e[24]=o,e[25]=N,e[26]=T,e[27]=E,e[28]=d,e[29]=u,e[30]=f,e[31]=m,e[32]=x,e[33]=P):P=e[33],P}const fg=Qn("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"}});function y4(n){const e=B.c(12);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?"default":o,l=i===void 0?"default":i;let c;e[5]!==t||e[6]!==l||e[7]!==a?(c=K(fg({variant:a,size:l,className:t})),e[5]=t,e[6]=l,e[7]=a,e[8]=c):c=e[8];let d;return e[9]!==s||e[10]!==c?(d=r.jsx(x1,{"data-slot":"toggle",className:c,...s}),e[9]=s,e[10]=c,e[11]=d):d=e[11],d}function w4(n){const e=B.c(34),{options:t,value:s,onChange:o,disabled:i,labelId:a}=n,l=t.length-1;let c;if(e[0]!==t||e[1]!==s){let b;e[3]!==s?(b=j=>j.value===s,e[3]=s,e[4]=b):b=e[4],c=t.findIndex(b),e[0]=t,e[1]=s,e[2]=c}else c=e[2];const d=Math.max(0,c);let u;e[5]!==o||e[6]!==t||e[7]!==s?(u=b=>{const j=t[b];j&&j.value!==s&&o(j.value)},e[5]=o,e[6]=t,e[7]=s,e[8]=u):u=e[8];const f=i&&"opacity-50";let m;e[9]!==f?(m=K("w-full",f),e[9]=f,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx($y,{className:"rounded-full bg-primary"}),e[11]=p):p=e[11];let h;if(e[12]!==d||e[13]!==l||e[14]!==t){let b;e[16]!==d||e[17]!==l?(b=(j,S)=>r.jsx("span",{"aria-hidden":!0,className:K("pointer-events-none absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full transition-colors duration-150",S<=d?"bg-primary":"bg-muted-foreground/40"),style:{left:l===0?"50%":`${S/l*100}%`}},j.value),e[16]=d,e[17]=l,e[18]=b):b=e[18],h=t.map(b),e[12]=d,e[13]=l,e[14]=t,e[15]=h}else h=e[15];let g;e[19]!==t?(g=(b,j)=>{var S;return((S=t[j])==null?void 0:S.label)??""},e[19]=t,e[20]=g):g=e[20];let x;e[21]!==a||e[22]!==g?(x=r.jsx(Iy,{"aria-labelledby":a,getAriaValueText:g,className:"size-3.5 rounded-full bg-primary shadow-[0_0_0_3px_var(--popover)] outline-none transition-transform duration-100 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring/50 has-[:focus-visible]:ring-offset-2 has-[:focus-visible]:ring-offset-popover data-dragging:scale-125 motion-reduce:transition-none"}),e[21]=a,e[22]=g,e[23]=x):x=e[23];let v;e[24]!==h||e[25]!==x?(v=r.jsx(Ry,{className:"flex h-6 w-full touch-none select-none items-center px-1.5",children:r.jsxs(My,{className:"relative h-1 w-full rounded-full bg-muted-foreground/20",children:[p,h,x]})}),e[24]=h,e[25]=x,e[26]=v):v=e[26];let w;return e[27]!==i||e[28]!==d||e[29]!==l||e[30]!==u||e[31]!==m||e[32]!==v?(w=r.jsx(Oy,{value:d,min:0,max:l,step:1,disabled:i,onValueChange:u,className:m,children:v}),e[27]=i,e[28]=d,e[29]=l,e[30]=u,e[31]=m,e[32]=v,e[33]=w):w=e[33],w}function j4(n,e){var a;const{defaultLimit:t,limits:s,extendedContext:o}=on(e).contextWindow,i=n.trim().toLowerCase();return o&&i.includes(o.marker)?o.limit:((a=s.find(l=>i.includes(l.match)))==null?void 0:a.limit)??t}function S4(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=j4(e,t),c=l-on(t).contextWindow.compactBuffer;return{used:a,limit:l,compactAt:c,percent:Math.min(100,a/c*100),percentAbsolute:Math.min(100,a/l*100)}}const N4=["fable","mythos","opus","sonnet","haiku"];function Sm(n){return n.charAt(0).toUpperCase()+n.slice(1)}function Ks(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const o of N4){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`${Sm(o)}${a}${t}`}if(s.startsWith("gpt-")){const[o,...i]=s.slice(4).split("-"),a=i.map(Sm).join(" ");return`GPT-${o}${a?` ${a}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function cn(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function at(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Rn(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 k4(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m ${t}s`}function mg(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Dr(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 Id(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 Rd(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 xn(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function vn(n){return Cs(n).dirName.decode(n)??n}function Ca(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function _a(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 Yn(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function ws(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function pg(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return S4(t.message.usage,t.message.model??"","claude")}return null}function hg(n,e){const t=y.forwardRef(function(o,i){const a=B.c(4);let l;a[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("path",{d:e}),a[0]=l):l=a[0];let c;return a[1]!==o||a[2]!==i?(c=r.jsx("svg",{ref:i,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:24,height:24,fill:"currentColor","aria-hidden":!0,...o,children:l}),a[1]=o,a[2]=i,a[3]=c):c=a[3],c});return t.displayName=n,t}const C4=hg("AnthropicIcon","M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.1256 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"),_4=hg("OpenAIIcon","M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"),gg={claude:C4,codex:_4,copilot:b1},Md={claude:"Claude",codex:"Codex",copilot:"Copilot"},T4={claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},E4={claude:null,codex:"Codex",copilot:"Copilot"},A4={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"}},P4={claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},$4={claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},I4={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 R4(n){return I4[n]}function M4(n){return gg[n]}function Ta(n){return Md[n]}function bB(n){return T4[n]}function O4(n){return E4[n]}function vB(n){return A4[n]}function L4(n){return $4[n]}function D4(n){return P4[n]}const Nm=Cs(null).kind,xg=[Nm,...bs.filter(n=>n!==Nm)];function z4(n){return`This ${Md[n]} session is controlled by another process. Cogpit can only view it.`}const jc=xg.map(n=>({value:n,label:Md[n],Icon:gg[n]}));function F4(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 B4(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?Od(e,n):"Default"}function Od(n,e){var t;return((t=F4(n,e))==null?void 0:t.label)??Ks(n)}function U4(n){var Le;const e=B.c(109),{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,isNewSession:x}=n,v=m===void 0?!1:m,w=h===void 0?!1:h;let b;e[0]!==t?(b=Bt(t),e[0]=t,e[1]=b):b=e[1];const j=b;let S;e[2]!==t?(S=jc.find(Se=>Se.value===t),e[2]=t,e[3]=S):S=e[3];const N=S,C=N==null?void 0:N.Icon,k=(N==null?void 0:N.label)??t;let T;e[4]!==a||e[5]!==i||e[6]!==o?(T=((Le=a.find(Se=>Se.value===o))==null?void 0:Le.label)??i,e[4]=a,e[5]=i,e[6]=o,e[7]=T):T=e[7];const E=T;let P;if(e[8]!==d||e[9]!==c){let Se;e[11]!==c?(Se=Re=>Re.value===c,e[11]=c,e[12]=Se):Se=e[12],P=d.find(Se),e[8]=d,e[9]=c,e[10]=P}else P=e[10];const _=P,A=!s,I=j.reasoningEffort,R=j.fastTier,$=j.ultracode,M=!!f&&!!p,L=!!g,D=v&&M,F=w&&L,z=F?"Pinned by Ultracode":_==null?void 0:_.description,O=_==null?void 0:_.label;let H;e[13]!==E||e[14]!==k||e[15]!==O?(H=[k,E,O].filter(Boolean),e[13]=E,e[14]=k,e[15]=O,e[16]=H):H=e[16];const W=H.join(" · "),U=D?"Fast mode on":null,V=F?"Ultracode on":null;let q;e[17]!==V||e[18]!==U?(q=[U,V].filter(Boolean),e[17]=V,e[18]=U,e[19]=q):q=e[19];const X=q.join(", "),G=y.useId(),Y=y.useId(),J=y.useId(),Q=X?`${W} (${X})`:W,Z=X?`${W} · ${X}`:void 0;let te;e[20]!==Q||e[21]!==Z?(te=r.jsx(Ad,{"aria-label":Q,title:Z}),e[20]=Q,e[21]=Z,e[22]=te):te=e[22];let ne;e[23]!==C?(ne=C&&r.jsx(C,{"data-icon":"inline-start"}),e[23]=C,e[24]=ne):ne=e[24];let oe;e[25]!==E?(oe=r.jsx("span",{className:"truncate",children:E}),e[25]=E,e[26]=oe):oe=e[26];let re;e[27]!==_?(re=_&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/60","aria-hidden":!0,children:"·"}),r.jsx("span",{className:"shrink-0 text-muted-foreground",children:_.label})]}),e[27]=_,e[28]=re):re=e[28];let ie;e[29]!==oe||e[30]!==re?(ie=r.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[oe,re]}),e[29]=oe,e[30]=re,e[31]=ie):ie=e[31];let se;e[32]!==D?(se=D&&r.jsx(Vi,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[32]=D,e[33]=se):se=e[33];let de;e[34]!==F?(de=F&&r.jsx(Gi,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[34]=F,e[35]=de):de=e[35];let ce;e[36]!==te||e[37]!==ne||e[38]!==ie||e[39]!==se||e[40]!==de?(ce=r.jsxs(Td,{render:te,children:[ne,ie,se,de]}),e[36]=te,e[37]=ne,e[38]=ie,e[39]=se,e[40]=de,e[41]=ce):ce=e[41];let ue;e[42]!==x?(ue=Ed(x),e[42]=x,e[43]=ue):ue=e[43];let me;e[44]!==G?(me=r.jsx(mo,{id:G,children:"Provider"}),e[44]=G,e[45]=me):me=e[45];let fe;e[46]!==s?(fe=Se=>s==null?void 0:s(Se),e[46]=s,e[47]=fe):fe=e[47];let ae;e[48]!==t||e[49]!==A?(ae=jc.map(Se=>r.jsx($d,{value:Se.value,title:Se.label,icon:Se.Icon,disabled:A&&Se.value!==t},Se.value)),e[48]=t,e[49]=A,e[50]=ae):ae=e[50];let ve;e[51]!==t||e[52]!==G||e[53]!==fe||e[54]!==ae?(ve=r.jsx(wc,{value:t,onValueChange:fe,"aria-labelledby":G,children:ae}),e[51]=t,e[52]=G,e[53]=fe,e[54]=ae,e[55]=ve):ve=e[55];let ge;e[56]!==x||e[57]!==A?(ge=A&&!x&&r.jsx("p",{className:"mt-auto px-2 pb-1 pt-3 text-[11px] leading-4 text-muted-foreground",children:"Fixed for this session. Start a new one to switch."}),e[56]=x,e[57]=A,e[58]=ge):ge=e[58];let ye;e[59]!==me||e[60]!==ve||e[61]!==ge?(ye=r.jsxs("div",{className:"flex flex-col border-r bg-muted/30 p-1.5",children:[me,ve,ge]}),e[59]=me,e[60]=ve,e[61]=ge,e[62]=ye):ye=e[62];let Pe;e[63]!==Y?(Pe=r.jsx(mo,{id:Y,children:"Model"}),e[63]=Y,e[64]=Pe):Pe=e[64];let De;e[65]!==M||e[66]!==D||e[67]!==(f==null?void 0:f.description)||e[68]!==E||e[69]!==p||e[70]!==g||e[71]!==R||e[72]!==$||e[73]!==L||e[74]!==F?(De=(R||$)&&r.jsxs("div",{className:"flex items-center gap-1",children:[R&&r.jsx(km,{label:"Fast mode",pressed:D,onPressedChange:Se=>p==null?void 0:p(Se),disabled:!M,title:M?`Fast mode · ${(f==null?void 0:f.description)??"Lower latency with increased usage"}`:`Fast mode isn't offered for ${E}`,children:r.jsx(Vi,{className:K(D&&"fill-current")})}),$&&r.jsxs(km,{label:"Ultracode",pressed:F,onPressedChange:Se=>g==null?void 0:g(Se),disabled:!L,title:L?"Ultracode · Extra High effort with standing multi-agent orchestration":`Ultracode isn't available for ${E}`,children:[r.jsx(Gi,{className:K(F&&"fill-current")}),"Ultracode"]})]}),e[65]=M,e[66]=D,e[67]=f==null?void 0:f.description,e[68]=E,e[69]=p,e[70]=g,e[71]=R,e[72]=$,e[73]=L,e[74]=F,e[75]=De):De=e[75];let Te;e[76]!==Pe||e[77]!==De?(Te=r.jsxs("div",{className:"flex items-center justify-between gap-2 pr-0.5",children:[Pe,De]}),e[76]=Pe,e[77]=De,e[78]=Te):Te=e[78];let Ae;e[79]!==a?(Ae=a.map(W4),e[79]=a,e[80]=Ae):Ae=e[80];let pe;e[81]!==Y||e[82]!==l||e[83]!==o||e[84]!==Ae?(pe=r.jsx(wc,{value:o,onValueChange:l,"aria-labelledby":Y,className:"max-h-56 min-h-0 flex-1 overflow-y-auto",children:Ae}),e[81]=Y,e[82]=l,e[83]=o,e[84]=Ae,e[85]=pe):pe=e[85];let xe;e[86]!==Te||e[87]!==pe?(xe=r.jsxs("div",{className:"flex min-h-0 flex-col p-1.5",children:[Te,pe]}),e[86]=Te,e[87]=pe,e[88]=xe):xe=e[88];let ke;e[89]!==ye||e[90]!==xe?(ke=r.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[10.5rem_minmax(0,1fr)] overflow-hidden",children:[ye,xe]}),e[89]=ye,e[90]=xe,e[91]=ke):ke=e[91];let $e;e[92]!==z||e[93]!==J||e[94]!==d||e[95]!==E||e[96]!==u||e[97]!==c||e[98]!==_||e[99]!==I||e[100]!==F?($e=I&&r.jsxs("div",{className:"shrink-0 border-t px-2 pb-1.5 pt-2",children:[r.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-1.5",children:[r.jsxs(mo,{id:J,className:"flex items-baseline gap-1.5 p-0",children:["Reasoning",_&&r.jsx("span",{className:"text-xs font-medium normal-case tracking-normal text-foreground motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200",children:_.label},_.value)]}),z&&r.jsx("span",{className:"truncate text-[11px] leading-4 text-muted-foreground",children:z})]}),d.length>0?r.jsx(w4,{options:d,value:c,onChange:u,disabled:F,labelId:J}):r.jsxs("p",{className:"px-1.5 pb-1 text-xs leading-5 text-muted-foreground",children:["Not adjustable for ",E,"."]})]}),e[92]=z,e[93]=J,e[94]=d,e[95]=E,e[96]=u,e[97]=c,e[98]=_,e[99]=I,e[100]=F,e[101]=$e):$e=e[101];let we;e[102]!==ue||e[103]!==ke||e[104]!==$e?(we=r.jsxs(Pd,{side:ue,align:"end","aria-label":"Model settings",className:"w-[34rem] max-w-[calc(100vw-1.5rem)]",children:[ke,$e]}),e[102]=ue,e[103]=ke,e[104]=$e,e[105]=we):we=e[105];let be;return e[106]!==ce||e[107]!==we?(be=r.jsxs(_d,{modal:!1,onOpenChange:H4,children:[ce,we]}),e[106]=ce,e[107]=we,e[108]=be):be=e[108],be}function W4(n){return r.jsx($d,{value:n.value,title:n.menuLabel??n.label,description:n.description},n.value)}function H4(n){n&&Cd()}function km(n){const e=B.c(7),{label:t,pressed:s,onPressedChange:o,disabled:i,title:a,children:l}=n;let c;return e[0]!==l||e[1]!==i||e[2]!==t||e[3]!==o||e[4]!==s||e[5]!==a?(c=r.jsx(y4,{variant:"outline",size:"sm",pressed:s,onPressedChange:o,disabled:i,"aria-label":t,title:a,className:"h-6 gap-1 px-1.5 text-xs text-muted-foreground data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/90 [&_svg:not([class*='size-'])]:size-3.5",children:l}),e[0]=l,e[1]=i,e[2]=t,e[3]=o,e[4]=s,e[5]=a,e[6]=c):c=e[6],c}function bg(n,e){return R4(n).filter(t=>t.value!=="auto"||e)}function q4(n){const e=B.c(22),{agentKind:t,mode:s,onChange:o,autoAvailable:i,isNewSession:a}=n,l=i===void 0?!1:i,[c,d]=y.useState(!1),u=bg(t,l),f=u.find(_=>_.value===s)??u[0],m=y.useId(),p=`Permissions: ${f.label}`;let h;e[0]!==p?(h=r.jsx(Ad,{"aria-label":p}),e[0]=p,e[1]=h):h=e[1];let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(v1,{"data-icon":"inline-start"}),e[2]=g):g=e[2];const x=Pd;let v;e[3]!==a?(v=Ed(a),e[3]=a,e[4]=v):v=e[4];const w="Permissions",b="w-80",j="p-1.5";let S;e[5]!==m?(S=r.jsx(mo,{id:m,children:"Permissions"}),e[5]=m,e[6]=S):S=e[6];const N=wc;let C;e[7]!==o?(C=_=>{o(_),d(!1)},e[7]=o,e[8]=C):C=e[8];const k=u.map(K4);let T;e[9]!==N||e[10]!==m||e[11]!==s||e[12]!==C||e[13]!==k?(T=r.jsx(N,{value:s,onValueChange:C,"aria-labelledby":m,children:k}),e[9]=N,e[10]=m,e[11]=s,e[12]=C,e[13]=k,e[14]=T):T=e[14];let E;e[15]!==T||e[16]!==S?(E=r.jsxs("div",{className:j,children:[S,T]}),e[15]=T,e[16]=S,e[17]=E):E=e[17];let P;return e[18]!==x||e[19]!==E||e[20]!==v?(P=r.jsx(x,{side:v,"aria-label":w,className:b,children:E}),e[18]=x,e[19]=E,e[20]=v,e[21]=P):P=e[21],r.jsxs(_d,{modal:!1,open:c,onOpenChange:d,children:[r.jsxs(Td,{render:h,children:[g,r.jsx("span",{className:"truncate",children:f.label})]}),P]})}function K4(n){return r.jsx($d,{value:n.value,title:n.label,description:n.description},n.value)}function V4(n){const e=B.c(54),{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:v,onUltracodeEnabledChange:w,autoModeAvailable:b,permissionMode:j,onPermissionModeChange:S,mcpServers:N,selectedMcpServers:C,onToggleMcpServer:k,onSetMcpServers:T,onRefreshMcpServers:E,mcpLoading:P,onMcpAuth:_,changeAndApply:A,trailingExtra:I}=n;let R;e[0]!==t?(R=Bt(t),e[0]=t,e[1]=R):R=e[1];const{worktrees:$}=R;let M;e[2]!==t||e[3]!==b||e[4]!==A||e[5]!==h||e[6]!==S||e[7]!==j?(M=S&&j&&r.jsx(q4,{agentKind:t,mode:j,onChange:U=>A(()=>S(U)),autoAvailable:b,isNewSession:h}),e[2]=t,e[3]=b,e[4]=A,e[5]=h,e[6]=S,e[7]=j,e[8]=M):M=e[8];let L;e[9]!==h||e[10]!==x||e[11]!==$||e[12]!==g?(L=$&&h&&x&&r.jsxs(ee,{type:"button",variant:g?"secondary":"ghost",size:"xs","aria-pressed":!!g,onClick:()=>x(!g),children:[r.jsx($n,{"data-icon":"inline-start"}),"Worktree"]}),e[9]=h,e[10]=x,e[11]=$,e[12]=g,e[13]=L):L=e[13];let D;e[14]!==A||e[15]!==h||e[16]!==P||e[17]!==N||e[18]!==_||e[19]!==E||e[20]!==T||e[21]!==k||e[22]!==C?(D=k&&E&&_&&(P||N&&N.length>0)&&r.jsx(g4,{servers:N??[],selected:C??[],onToggle:U=>A(()=>k(U)),onSetSelection:T?U=>A(()=>T(U)):void 0,onRefresh:E,loading:P??!1,onAuth:_,isNewSession:h}),e[14]=A,e[15]=h,e[16]=P,e[17]=N,e[18]=_,e[19]=E,e[20]=T,e[21]=k,e[22]=C,e[23]=D):D=e[23];let F;e[24]!==M||e[25]!==L||e[26]!==D||e[27]!==I?(F=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[M,L,D,I]}),e[24]=M,e[25]=L,e[26]=D,e[27]=I,e[28]=F):F=e[28];let z;e[29]!==A||e[30]!==p?(z=p?U=>A(()=>p(U)):void 0,e[29]=A,e[30]=p,e[31]=z):z=e[31];let O;e[32]!==A||e[33]!==w?(O=w?U=>A(()=>w(U)):void 0,e[32]=A,e[33]=w,e[34]=O):O=e[34];let H;e[35]!==t||e[36]!==d||e[37]!==m||e[38]!==f||e[39]!==h||e[40]!==a||e[41]!==s||e[42]!==u||e[43]!==l||e[44]!==i||e[45]!==c||e[46]!==o||e[47]!==z||e[48]!==O||e[49]!==v?(H=r.jsx(U4,{agentKind:t,onAgentKindChange:s,selectedModel:o,resolvedDefaultName:i,modelOptions:a,onModelChange:l,selectedEffort:c,effortOptions:d,onEffortChange:u,fastTier:f,fastModeEnabled:m,onFastModeEnabledChange:z,ultracodeEnabled:v,onUltracodeEnabledChange:O,isNewSession:h}),e[35]=t,e[36]=d,e[37]=m,e[38]=f,e[39]=h,e[40]=a,e[41]=s,e[42]=u,e[43]=l,e[44]=i,e[45]=c,e[46]=o,e[47]=z,e[48]=O,e[49]=v,e[50]=H):H=e[50];let W;return e[51]!==F||e[52]!==H?(W=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",role:"group","aria-label":"Session settings",children:[F,H]}),e[51]=F,e[52]=H,e[53]=W):W=e[53],W}function wt(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=K("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(ad,{"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 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=K("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 Y4(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 X4(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=K("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=a):a=e[5];let l;return e[6]!==s||e[7]!==a||e[8]!==i?(l=r.jsx("legend",{"data-slot":"field-legend","data-variant":i,className:a,...s}),e[6]=s,e[7]=a,e[8]=i,e[9]=l):l=e[9],l}function To(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 J4=Qn("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 vt(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=K(J4({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 yB(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 yt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(G4,{"data-slot":"field-label",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function yo(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 ps(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(Z4)).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(Q4)}),e[7]=m,e[8]=p):p=e[8],a=p}const l=a;if(!l)return null;let c;e[9]!==s?(c=K("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 Q4(n,e){return(n==null?void 0:n.message)&&r.jsx("li",{children:n.message},e)}function Z4(n){return[n==null?void 0:n.message,n]}const Sc=Dy;function e5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(Xy,{"data-slot":"select-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Nc(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(Fy,{"data-slot":"select-value",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function kc(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=K("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(Uy,{render:r.jsx(nt,{className:"pointer-events-none size-4 text-muted-foreground transition-transform duration-150 ease-out group-data-popup-open/select-trigger:rotate-180 motion-reduce:transition-none"})}),e[7]=c):c=e[7];let d;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==l?(d=r.jsxs(zy,{"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 Cc(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=K("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(t5,{}),e[11]=x):x=e[11];let v;e[12]!==t?(v=r.jsx(Wy,{children:t}),e[12]=t,e[13]=v):v=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(n5,{}),e[14]=w):w=e[14];let b;e[15]!==o||e[16]!==g||e[17]!==v?(b=r.jsxs(By,{"data-slot":"select-content",className:g,...o,children:[x,v,w]}),e[15]=o,e[16]=g,e[17]=v,e[18]=b):b=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==u||e[23]!==f||e[24]!==b?(j=r.jsx(Hy,{children:r.jsx(qy,{side:u,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:b})}),e[19]=m,e[20]=h,e[21]=p,e[22]=u,e[23]=f,e[24]=b,e[25]=j):j=e[25],j}function _c(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=K("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(Ky,{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(Vy,{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(lt,{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(Ly,{"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 t5(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=K("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(Er,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Gy,{"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 n5(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=K("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=o):o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(nt,{}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(Yy,{"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 s5(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(y1,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function o5(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(Jy,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function r5(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(Ar,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function i5(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(ud,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function a5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(fd,{"data-slot":"sheet-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function l5(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(a5,{}),e[6]=d):d=e[6];let u;e[7]!==s?(u=K("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(Ar,{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(Qe,{"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(i5,{children:[d,r.jsxs(dd,{"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 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=K("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 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=K("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(ld,{"data-slot":"sheet-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function u5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(cd,{"data-slot":"sheet-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function tr(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=K("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(yt,{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(vt,{className:l,children:[c,d]}),e[6]=l,e[7]=c,e[8]=d,e[9]=u):u=e[9],u}function wi(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(Nc,{}),e[2]=u):u=e[2];let f;e[3]!==s||e[4]!==c?(f=r.jsx(kc,{"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(f5),e[6]=i,e[7]=m):m=e[7];let p;e[8]!==m?(p=r.jsx(Cc,{children:r.jsx(e5,{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(Sc,{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(tr,{label:t,children:h}),e[16]=t,e[17]=h,e[18]=g):g=e[18],g}function f5(n){return r.jsx(_c,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function m5(n){const e=B.c(28),{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:v}=n;let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[0]=w):w=e[0];let b;e[1]!==t||e[2]!==s?(b=s&&r.jsx(wi,{label:"Agent",ariaLabel:"Agent",value:t,options:jc,onChange:T=>s(T)}),e[1]=t,e[2]=s,e[3]=b):b=e[3];let j;e[4]!==a||e[5]!==i||e[6]!==o?(j=r.jsx(wi,{label:"Model",ariaLabel:"Model",value:o,options:a,onChange:i}),e[4]=a,e[5]=i,e[6]=o,e[7]=j):j=e[7];let S;e[8]!==d||e[9]!==c||e[10]!==l||e[11]!==u?(S=d.length>0&&r.jsx(wi,{label:"Reasoning",ariaLabel:"Reasoning effort",value:l,options:d,onChange:c,disabled:u,title:u?"Effort is pinned to XHigh while Ultracode is on":void 0}),e[8]=d,e[9]=c,e[10]=l,e[11]=u,e[12]=S):S=e[12];let N;e[13]!==v||e[14]!==m||e[15]!==f||e[16]!==p?(N=f&&p&&r.jsx(tr,{label:"Speed",children:r.jsxs(ee,{type:"button",variant:m?"secondary":"ghost","aria-pressed":!!m,onClick:()=>v(()=>p(!m)),title:f.description,className:"h-10 justify-start",children:[r.jsx(Vi,{"data-icon":"inline-start",className:K(m&&"fill-current")}),m?"Fast":"Standard"]})}),e[13]=v,e[14]=m,e[15]=f,e[16]=p,e[17]=N):N=e[17];let C;e[18]!==x||e[19]!==h||e[20]!==g?(C=x&&h&&r.jsx(wi,{label:"Access",ariaLabel:"Access policy",value:h,options:g,onChange:T=>x(T)}),e[18]=x,e[19]=h,e[20]=g,e[21]=C):C=e[21];let k;return e[22]!==b||e[23]!==j||e[24]!==S||e[25]!==N||e[26]!==C?(k=r.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[w,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[b,j,S,N,C]})]}),e[22]=b,e[23]=j,e[24]=S,e[25]=N,e[26]=C,e[27]=k):k=e[27],k}function p5(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=Bt(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:v}=g,w=!!(u&&f&&p&&(m||c&&c.length>0)),b=!!(x&&s&&i||v&&l||w);let j;e[2]!==d?(j=d??[],e[2]=d,e[3]=j):j=e[3];let S;e[4]!==j?(S=new Set(j),e[4]=j,e[5]=S):S=e[5];const N=S;if(!b)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 k;e[7]!==s||e[8]!==i||e[9]!==x||e[10]!==o?(k=x&&s&&i&&r.jsx(tr,{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($n,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=i,e[9]=x,e[10]=o,e[11]=k):k=e[11];let T;e[12]!==h||e[13]!==l||e[14]!==v||e[15]!==a?(T=v&&l&&r.jsx(tr,{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(Vi,{"data-icon":"inline-start",className:K(a&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=v,e[15]=a,e[16]=T):T=e[16];let E;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==u||e[23]!==N||e[24]!==w?(E=w&&u&&f&&p&&r.jsx(tr,{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(Et,{"data-icon":"inline-start",className:K(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(_=>{const A=N.has(_.name),I=_.status==="connected";return r.jsxs(ee,{type:"button",variant:"ghost","aria-pressed":I?A:void 0,onClick:()=>I?h(()=>u(_.name)):p(_.name),className:"min-h-10 justify-start text-left",children:[r.jsx("span",{className:K("size-2 shrink-0 rounded-full",I&&A?"bg-success":I?"bg-muted-foreground":"bg-warning")}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:_.name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:I?A?"On":"Off":"Connect"})]},_.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=f,e[22]=u,e[23]=N,e[24]=w,e[25]=E):E=e[25];let P;return e[26]!==k||e[27]!==T||e[28]!==E?(P=r.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[C,r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[k,T,E]})]}),e[26]=k,e[27]=T,e[28]=E,e[29]=P):P=e[29],P}function h5(n){var ie,se;const e=B.c(74),{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:v,worktreeEnabled:w,onWorktreeEnabledChange:b,ultracodeEnabled:j,onUltracodeEnabledChange:S,autoModeAvailable:N,permissionMode:C,onPermissionModeChange:k,mcpServers:T,selectedMcpServers:E,onToggleMcpServer:P,onRefreshMcpServers:_,mcpLoading:A,onMcpAuth:I,mobileExtra:R,changeAndApply:$}=n;let M,L;e[0]!==o||e[1]!==N||e[2]!==C?(M=bg(o,N),L=(ie=M.find(de=>de.value===C))==null?void 0:ie.label,e[0]=o,e[1]=N,e[2]=C,e[3]=M,e[4]=L):(M=e[3],L=e[4]);const D=L;let F;e[5]!==c||e[6]!==l||e[7]!==a?(F=a?Od(a,c):l,e[5]=c,e[6]=l,e[7]=a,e[8]=F):F=e[8];let z;e[9]!==m||e[10]!==f?(z=(se=m.find(de=>de.value===f))==null?void 0:se.label,e[9]=m,e[10]=f,e[11]=z):z=e[11];let O;e[12]!==D||e[13]!==F||e[14]!==z?(O=[F,z,D].filter(Boolean),e[12]=D,e[13]=F,e[14]=z,e[15]=O):O=e[15];const H=O.join(" · ");let W;e[16]!==$||e[17]!==k?(W=de=>{k&&$(()=>k(de))},e[16]=$,e[17]=k,e[18]=W):W=e[18];const U=W;let V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(o5,{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(md,{})}),e[19]=V):V=e[19];let q;e[20]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(d5,{children:"Session controls"}),e[20]=q):q=e[20];let X;e[21]!==H?(X=r.jsx(u5,{className:"truncate text-xs",children:H}),e[21]=H,e[22]=X):X=e[22];let G;e[23]===Symbol.for("react.memo_cache_sentinel")?(G=r.jsx(r5,{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(Qe,{})}),e[23]=G):G=e[23];let Y;e[24]!==X?(Y=r.jsxs(c5,{className:"gap-1 px-4 pb-3 pt-4",children:[q,X,G]}),e[24]=X,e[25]=Y):Y=e[25];let J;e[26]!==o||e[27]!==$||e[28]!==U||e[29]!==m||e[30]!==g||e[31]!==h||e[32]!==d||e[33]!==i||e[34]!==p||e[35]!==x||e[36]!==u||e[37]!==C||e[38]!==M||e[39]!==f||e[40]!==a||e[41]!==j?(J=r.jsx(m5,{agentKind:o,onAgentKindChange:i,selectedModel:a,onModelChange:u,modelOptions:d,selectedEffort:f,onEffortChange:p,effortOptions:m,ultracodeEnabled:j,fastTier:h,fastModeEnabled:g,onFastModeEnabledChange:x,permissionMode:C,permissionOptions:M,onPermissionModeChange:U,changeAndApply:$}),e[26]=o,e[27]=$,e[28]=U,e[29]=m,e[30]=g,e[31]=h,e[32]=d,e[33]=i,e[34]=p,e[35]=x,e[36]=u,e[37]=C,e[38]=M,e[39]=f,e[40]=a,e[41]=j,e[42]=J):J=e[42];let Q;e[43]!==o||e[44]!==$||e[45]!==v||e[46]!==A||e[47]!==T||e[48]!==I||e[49]!==_||e[50]!==P||e[51]!==S||e[52]!==b||e[53]!==E||e[54]!==j||e[55]!==w?(Q=r.jsx(p5,{agentKind:o,isNewSession:v,worktreeEnabled:w,onWorktreeEnabledChange:b,ultracodeEnabled:j,onUltracodeEnabledChange:S,mcpServers:T,selectedMcpServers:E,onToggleMcpServer:P,onRefreshMcpServers:_,mcpLoading:A,onMcpAuth:I,changeAndApply:$}),e[43]=o,e[44]=$,e[45]=v,e[46]=A,e[47]=T,e[48]=I,e[49]=_,e[50]=P,e[51]=S,e[52]=b,e[53]=E,e[54]=j,e[55]=w,e[56]=Q):Q=e[56];let Z;e[57]!==R?(Z=R&&r.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[r.jsx(wt,{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:R})]}),e[57]=R,e[58]=Z):Z=e[58];let te;e[59]!==o||e[60]!==v?(te=!v&&r.jsx("p",{className:"text-xs text-muted-foreground",children:Bt(o).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[59]=o,e[60]=v,e[61]=te):te=e[61];let ne;e[62]!==J||e[63]!==Q||e[64]!==Z||e[65]!==te?(ne=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[J,Q,Z,te]}),e[62]=J,e[63]=Q,e[64]=Z,e[65]=te,e[66]=ne):ne=e[66];let oe;e[67]!==Y||e[68]!==ne?(oe=r.jsxs(l5,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[Y,ne]}),e[67]=Y,e[68]=ne,e[69]=oe):oe=e[69];let re;return e[70]!==s||e[71]!==t||e[72]!==oe?(re=r.jsx(r.Fragment,{children:r.jsxs(s5,{open:t,onOpenChange:s,children:[V,oe]})}),e[70]=s,e[71]=t,e[72]=oe,e[73]=re):re=e[73],re}const g5=y.memo(function(e){const t=B.c(53),{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:v,mcpServers:w,selectedMcpServers:b,onToggleMcpServer:j,onSetMcpServers:S,onRefreshMcpServers:N,mcpLoading:C,onMcpAuth:k,permissionMode:T,onPermissionModeChange:E,mobileExtra:P,trailingExtra:_,mobile:A}=e,I=s===void 0?qs:s,R=A===void 0?!1:A,[$,M]=y.useState(!1);let L;t[0]!==f||t[1]!==x?(L=se=>{se(),!f&&x&&setTimeout(()=>x(),0)},t[0]=f,t[1]=x,t[2]=L):L=t[2];const D=L;let F;t[3]!==D||t[4]!==a?(F=se=>D(()=>a(se)),t[3]=D,t[4]=a,t[5]=F):F=t[5];const z=F;let O;t[6]!==D||t[7]!==c?(O=se=>D(()=>c(se)),t[6]=D,t[7]=c,t[8]=O):O=t[8];const H=O,{options:W,effortOptions:U,fastTier:V,autoPermissionMode:q,normalizeEffort:X}=dg(I,i),G=(v==null?void 0:v.toLowerCase().startsWith("gpt-"))??!1,J=v&&(I==="copilot"||G===(I==="codex"))?v:void 0;let Q,Z;t[9]!==W||t[10]!==J?(Q=J?Od(J,W):B4(W),Z=W.map(se=>{const de=[se.description,se.availabilityMessage].filter(Boolean).join(" · ")||void 0;return se.value===""?{...se,description:de,label:Q,menuLabel:se.label}:{...se,description:de}}),t[9]=W,t[10]=J,t[11]=Q,t[12]=Z):(Q=t[11],Z=t[12]);const te=Z;let ne;t[13]!==X||t[14]!==l?(ne=X(l),t[13]=X,t[14]=l,t[15]=ne):ne=t[15];let oe;t[16]!==I||t[17]!==q||t[18]!==D||t[19]!==U||t[20]!==d||t[21]!==V||t[22]!==H||t[23]!==z||t[24]!==f||t[25]!==C||t[26]!==w||t[27]!==te||t[28]!==o||t[29]!==u||t[30]!==k||t[31]!==E||t[32]!==N||t[33]!==S||t[34]!==j||t[35]!==g||t[36]!==p||t[37]!==T||t[38]!==Q||t[39]!==b||t[40]!==i||t[41]!==ne||t[42]!==h||t[43]!==m?(oe={agentKind:I,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:Q,modelOptions:te,onModelChange:z,selectedEffort:ne,effortOptions:U,onEffortChange:H,fastTier:V,fastModeEnabled:d,onFastModeEnabledChange:u,isNewSession:f,worktreeEnabled:m,onWorktreeEnabledChange:p,ultracodeEnabled:h,onUltracodeEnabledChange:g,autoModeAvailable:q,permissionMode:T,onPermissionModeChange:E,mcpServers:w,selectedMcpServers:b,onToggleMcpServer:j,onSetMcpServers:S,onRefreshMcpServers:N,mcpLoading:C,onMcpAuth:k,changeAndApply:D},t[16]=I,t[17]=q,t[18]=D,t[19]=U,t[20]=d,t[21]=V,t[22]=H,t[23]=z,t[24]=f,t[25]=C,t[26]=w,t[27]=te,t[28]=o,t[29]=u,t[30]=k,t[31]=E,t[32]=N,t[33]=S,t[34]=j,t[35]=g,t[36]=p,t[37]=T,t[38]=Q,t[39]=b,t[40]=i,t[41]=ne,t[42]=h,t[43]=m,t[44]=oe):oe=t[44];const re=oe;if(R){let se;return t[45]!==W||t[46]!==re||t[47]!==P||t[48]!==$?(se=r.jsx(h5,{...re,open:$,onOpenChange:M,catalogOptions:W,mobileExtra:P}),t[45]=W,t[46]=re,t[47]=P,t[48]=$,t[49]=se):se=t[49],se}let ie;return t[50]!==re||t[51]!==_?(ie=r.jsx(V4,{...re,trailingExtra:_}),t[50]=re,t[51]=_,t[52]=ie):ie=t[52],ie});function vg(n){return n.agentType==="team-lead"}function x5(n){return vg(n)?void 0:n.color}const b5={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function v5(n){return n?b5[n]??"bg-zinc-400":"bg-zinc-400"}const y5=y.memo(function(e){const t=B.c(18),{teamName:s,members:o,currentMemberName:i,loadingMember:a,onMemberClick:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Zn,{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(wt,{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,v=g.name===a,w=v5(x5(g));return r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:v,className:K("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[v?r.jsx(tt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx("span",{className:K("inline-flex size-1.5 shrink-0 rounded-full",w)}),r.jsx("span",{children:g.name}),vg(g)&&r.jsx(Qy,{"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 yg(n){const e=B.c(3),t=y.useRef(null),[s,o]=y.useState(0);let i,a;return e[0]!==n?(i=()=>{if(!n){t.current=null,o(0);return}t.current=Date.now(),o(0);const l=setInterval(()=>{t.current!==null&&o(Math.floor((Date.now()-t.current)/1e3))},1e3);return()=>clearInterval(l)},a=[n],e[0]=n,e[1]=i,e[2]=a):(i=e[1],a=e[2]),y.useEffect(i,a),s}const wg=y.createContext(null),jg=y.createContext(null);function Bi(n){const e=B.c(6),{value:t,chatValue:s,children:o}=n;let i;e[0]!==s||e[1]!==o?(i=r.jsx(jg.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(wg.Provider,{value:t,children:i}),e[3]=i,e[4]=t,e[5]=a):a=e[5],a}function st(){const n=y.useContext(wg);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function zr(){const n=y.useContext(jg);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}const w5=Qn("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 Ie(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=j1,s="span",o=w1({className:K(w5({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 Cm=1,j5=.9,S5=.8,N5=.17,jl=.1,Sl=.999,k5=.9999,C5=.99,_5=/[\\\/_+.#"@\[\(\{&]/,T5=/[\\\/_+.#"@\[\(\{&]/g,E5=/[\s-]/,Sg=/[\s-]/g;function Tc(n,e,t,s,o,i,a){if(i===e.length)return o===n.length?Cm:C5;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=Tc(n,e,t,s,d+1,i+1,a),f>u&&(d===o?f*=Cm:_5.test(n.charAt(d-1))?(f*=S5,p=n.slice(o,d-1).match(T5),p&&o>0&&(f*=Math.pow(Sl,p.length))):E5.test(n.charAt(d-1))?(f*=j5,h=n.slice(o,d-1).match(Sg),h&&o>0&&(f*=Math.pow(Sl,h.length))):(f*=N5,o>0&&(f*=Math.pow(Sl,d-o))),n.charAt(d)!==e.charAt(i)&&(f*=k5)),(f<jl&&t.charAt(d-1)===s.charAt(i+1)||s.charAt(i+1)===s.charAt(i)&&t.charAt(d-1)!==s.charAt(i))&&(m=Tc(n,e,t,s,d+1,i+2,a),m*jl>f&&(f=m*jl)),f>u&&(u=f),d=t.indexOf(c,d+1);return a[l]=u,u}function _m(n){return n.toLowerCase().replace(Sg," ")}function A5(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,Tc(n,e,_m(n),_m(e),0,0,{})}var Bo='[cmdk-group=""]',Nl='[cmdk-group-items=""]',P5='[cmdk-group-heading=""]',Ng='[cmdk-item=""]',Tm=`${Ng}:not([aria-disabled="true"])`,Ec="cmdk-item-select",so="data-value",$5=(n,e,t)=>A5(n,e,t),kg=y.createContext(void 0),Fr=()=>y.useContext(kg),Cg=y.createContext(void 0),Ld=()=>y.useContext(Cg),_g=y.createContext(void 0),Tg=y.forwardRef((n,e)=>{let t=oo(()=>{var O,H;return{search:"",value:(H=(O=n.value)!=null?O:n.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=oo(()=>new Set),o=oo(()=>new Map),i=oo(()=>new Map),a=oo(()=>new Set),l=Eg(n),{label:c,children:d,value:u,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...v}=n,w=uo(),b=uo(),j=uo(),S=y.useRef(null),N=W5();zs(()=>{if(u!==void 0){let O=u.trim();t.current.value=O,C.emit()}},[u]),zs(()=>{N(6,A)},[]);let C=y.useMemo(()=>({subscribe:O=>(a.current.add(O),()=>a.current.delete(O)),snapshot:()=>t.current,setState:(O,H,W)=>{var U,V,q,X;if(!Object.is(t.current[O],H)){if(t.current[O]=H,O==="search")_(),E(),N(1,P);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(j);G?G.focus():(U=document.getElementById(w))==null||U.focus()}if(N(7,()=>{var G;t.current.selectedItemId=(G=I())==null?void 0:G.id,C.emit()}),W||N(5,A),((V=l.current)==null?void 0:V.value)!==void 0){let G=H??"";(X=(q=l.current).onValueChange)==null||X.call(q,G);return}}C.emit()}},emit:()=>{a.current.forEach(O=>O())}}),[]),k=y.useMemo(()=>({value:(O,H,W)=>{var U;H!==((U=i.current.get(O))==null?void 0:U.value)&&(i.current.set(O,{value:H,keywords:W}),t.current.filtered.items.set(O,T(H,W)),N(2,()=>{E(),C.emit()}))},item:(O,H)=>(s.current.add(O),H&&(o.current.has(H)?o.current.get(H).add(O):o.current.set(H,new Set([O]))),N(3,()=>{_(),E(),t.current.value||P(),C.emit()}),()=>{i.current.delete(O),s.current.delete(O),t.current.filtered.items.delete(O);let W=I();N(4,()=>{_(),(W==null?void 0:W.getAttribute("id"))===O&&P(),C.emit()})}),group:O=>(o.current.has(O)||o.current.set(O,new Set),()=>{i.current.delete(O),o.current.delete(O)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:w,inputId:j,labelId:b,listInnerRef:S}),[]);function T(O,H){var W,U;let V=(U=(W=l.current)==null?void 0:W.filter)!=null?U:$5;return O?V(O,t.current.search,H):0}function E(){if(!t.current.search||l.current.shouldFilter===!1)return;let O=t.current.filtered.items,H=[];t.current.filtered.groups.forEach(U=>{let V=o.current.get(U),q=0;V.forEach(X=>{let G=O.get(X);q=Math.max(G,q)}),H.push([U,q])});let W=S.current;R().sort((U,V)=>{var q,X;let G=U.getAttribute("id"),Y=V.getAttribute("id");return((q=O.get(Y))!=null?q:0)-((X=O.get(G))!=null?X:0)}).forEach(U=>{let V=U.closest(Nl);V?V.appendChild(U.parentElement===V?U:U.closest(`${Nl} > *`)):W.appendChild(U.parentElement===W?U:U.closest(`${Nl} > *`))}),H.sort((U,V)=>V[1]-U[1]).forEach(U=>{var V;let q=(V=S.current)==null?void 0:V.querySelector(`${Bo}[${so}="${encodeURIComponent(U[0])}"]`);q==null||q.parentElement.appendChild(q)})}function P(){let O=R().find(W=>W.getAttribute("aria-disabled")!=="true"),H=O==null?void 0:O.getAttribute(so);C.setState("value",H||void 0)}function _(){var O,H,W,U;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let V=0;for(let q of s.current){let X=(H=(O=i.current.get(q))==null?void 0:O.value)!=null?H:"",G=(U=(W=i.current.get(q))==null?void 0:W.keywords)!=null?U:[],Y=T(X,G);t.current.filtered.items.set(q,Y),Y>0&&V++}for(let[q,X]of o.current)for(let G of X)if(t.current.filtered.items.get(G)>0){t.current.filtered.groups.add(q);break}t.current.filtered.count=V}function A(){var O,H,W;let U=I();U&&(((O=U.parentElement)==null?void 0:O.firstChild)===U&&((W=(H=U.closest(Bo))==null?void 0:H.querySelector(P5))==null||W.scrollIntoView({block:"nearest"})),U.scrollIntoView({block:"nearest"}))}function I(){var O;return(O=S.current)==null?void 0:O.querySelector(`${Ng}[aria-selected="true"]`)}function R(){var O;return Array.from(((O=S.current)==null?void 0:O.querySelectorAll(Tm))||[])}function $(O){let H=R()[O];H&&C.setState("value",H.getAttribute(so))}function M(O){var H;let W=I(),U=R(),V=U.findIndex(X=>X===W),q=U[V+O];(H=l.current)!=null&&H.loop&&(q=V+O<0?U[U.length-1]:V+O===U.length?U[0]:U[V+O]),q&&C.setState("value",q.getAttribute(so))}function L(O){let H=I(),W=H==null?void 0:H.closest(Bo),U;for(;W&&!U;)W=O>0?B5(W,Bo):U5(W,Bo),U=W==null?void 0:W.querySelector(Tm);U?C.setState("value",U.getAttribute(so)):M(O)}let D=()=>$(R().length-1),F=O=>{O.preventDefault(),O.metaKey?D():O.altKey?L(1):M(1)},z=O=>{O.preventDefault(),O.metaKey?$(0):O.altKey?L(-1):M(-1)};return y.createElement(ks.div,{ref:e,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:O=>{var H;(H=v.onKeyDown)==null||H.call(v,O);let W=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||W))switch(O.key){case"n":case"j":{x&&O.ctrlKey&&F(O);break}case"ArrowDown":{F(O);break}case"p":case"k":{x&&O.ctrlKey&&z(O);break}case"ArrowUp":{z(O);break}case"Home":{O.preventDefault(),$(0);break}case"End":{O.preventDefault(),D();break}case"Enter":{O.preventDefault();let U=I();if(U){let V=new Event(Ec);U.dispatchEvent(V)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:q5},c),Ea(n,O=>y.createElement(Cg.Provider,{value:C},y.createElement(kg.Provider,{value:k},O))))}),I5=y.forwardRef((n,e)=>{var t,s;let o=uo(),i=y.useRef(null),a=y.useContext(_g),l=Fr(),c=Eg(n),d=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:a==null?void 0:a.forceMount;zs(()=>{if(!d)return l.item(o,a==null?void 0:a.id)},[d]);let u=Ag(o,i,[n.value,n.children,i],n.keywords),f=Ld(),m=js(N=>N.value&&N.value===u.current),p=js(N=>d||l.filter()===!1?!0:N.search?N.filtered.items.get(o)>0:!0);y.useEffect(()=>{let N=i.current;if(!(!N||n.disabled))return N.addEventListener(Ec,h),()=>N.removeEventListener(Ec,h)},[p,n.onSelect,n.disabled]);function h(){var N,C;g(),(C=(N=c.current).onSelect)==null||C.call(N,u.current)}function g(){f.setState("value",u.current,!0)}if(!p)return null;let{disabled:x,value:v,onSelect:w,forceMount:b,keywords:j,...S}=n;return y.createElement(ks.div,{ref:dr(i,e),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||l.getDisablePointerSelection()?void 0:g,onClick:x?void 0:h},n.children)}),R5=y.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:o,...i}=n,a=uo(),l=y.useRef(null),c=y.useRef(null),d=uo(),u=Fr(),f=js(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);zs(()=>u.group(a),[]),Ag(a,l,[n.value,n.heading,c]);let m=y.useMemo(()=>({id:a,forceMount:o}),[o]);return y.createElement(ks.div,{ref:dr(l,e),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},t&&y.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},t),Ea(n,p=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?d:void 0},y.createElement(_g.Provider,{value:m},p))))}),M5=y.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,o=y.useRef(null),i=js(a=>!a.search);return!t&&!i?null:y.createElement(ks.div,{ref:dr(o,e),...s,"cmdk-separator":"",role:"separator"})}),O5=y.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,o=n.value!=null,i=Ld(),a=js(d=>d.search),l=js(d=>d.selectedItemId),c=Fr();return y.useEffect(()=>{n.value!=null&&i.setState("search",n.value)},[n.value]),y.createElement(ks.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)}})}),L5=y.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...o}=n,i=y.useRef(null),a=y.useRef(null),l=js(d=>d.selectedItemId),c=Fr();return y.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)}}},[]),y.createElement(ks.div,{ref:dr(i,e),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Ea(n,d=>y.createElement("div",{ref:dr(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),D5=y.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:o,contentClassName:i,container:a,...l}=n;return y.createElement(Zy,{open:t,onOpenChange:s},y.createElement(e3,{container:a},y.createElement(t3,{"cmdk-overlay":"",className:o}),y.createElement(n3,{"aria-label":n.label,"cmdk-dialog":"",className:i},y.createElement(Tg,{ref:e,...l}))))}),z5=y.forwardRef((n,e)=>js(t=>t.filtered.count===0)?y.createElement(ks.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),F5=y.forwardRef((n,e)=>{let{progress:t,children:s,label:o="Loading...",...i}=n;return y.createElement(ks.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ea(n,a=>y.createElement("div",{"aria-hidden":!0},a)))}),Eo=Object.assign(Tg,{List:L5,Item:I5,Input:O5,Group:R5,Separator:M5,Dialog:D5,Empty:z5,Loading:F5});function B5(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function U5(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function Eg(n){let e=y.useRef(n);return zs(()=>{e.current=n}),e}var zs=typeof window>"u"?y.useEffect:y.useLayoutEffect;function oo(n){let e=y.useRef();return e.current===void 0&&(e.current=n()),e}function js(n){let e=Ld(),t=()=>n(e.snapshot());return y.useSyncExternalStore(e.subscribe,t,t)}function Ag(n,e,t,s=[]){let o=y.useRef(),i=Fr();return zs(()=>{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(so,l),o.current=l}),o}var W5=()=>{let[n,e]=y.useState(),t=oo(()=>new Map);return zs(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,o)=>{t.current.set(s,o),e({})}};function H5(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Ea({asChild:n,children:e},t){return n&&y.isValidElement(e)?y.cloneElement(H5(e),{ref:e.ref},t(e.props.children)):t(e)}var q5={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function es(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(y1,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function K5(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(ud,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function wB(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(Ar,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function V5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(fd,{"data-slot":"dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ts(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(V5,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=K("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(Ar,{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(Qe,{"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(K5,{children:[l,r.jsxs(dd,{"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 _s(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Pg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 ns(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(ld,{"data-slot":"dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ss(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(cd,{"data-slot":"dialog-description",className:o,...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=K("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo,{"data-slot":"command",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function jB(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=K("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(ns,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==d?(p=r.jsx(ss,{children:d}),e[11]=d,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=r.jsxs(_s,{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(ts,{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(es,{...o,children:g}),e[21]=o,e[22]=g,e[23]=x):x=e[23],x}function SB(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(tn,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=o):o=e[3];let i;e[4]!==t?(i=K("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),e[4]=t,e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==i?(a=r.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[o,r.jsx(Eo.Input,{"data-slot":"command-input",className:i,...s})]}),e[6]=s,e[7]=i,e[8]=a):a=e[8],a}function Ig(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none transition-[height] duration-100 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo.List,{"data-slot":"command-list",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function NB(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("py-6 text-center text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-100 motion-reduce:animate-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo.Empty,{"data-slot":"command-empty",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function 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=K("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(Eo.Group,{"data-slot":"command-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Mg(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=K("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(lt,{className:"ml-auto scale-75 opacity-0 transition-[opacity,transform,scale] duration-100 ease-out group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:scale-100 group-data-[checked=true]/command-item:opacity-100 motion-reduce:transition-none"}),e[6]=a):a=e[6];let l;return e[7]!==t||e[8]!==o||e[9]!==i?(l=r.jsxs(Eo.Item,{"data-slot":"command-item",className:i,...o,children:[t,a]}),e[7]=t,e[8]=o,e[9]=i,e[10]=l):l=e[10],l}function G5(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Y5(n){return r.jsx(Ie,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const X5=y.memo(function(e){const t=B.c(38),{suggestions:s,filter:o,loading:i,selectedIndex:a,onSelect:l,onHover:c,onEdit:d}=e;let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,t[0]=u):u=t[0];const f=y.useRef(u);let m,p;if(t[1]!==a?(m=()=>{var P;const E=f.current.get(a);E&&((P=E.scrollIntoView)==null||P.call(E,{block:"nearest"}))},p=[a],t[1]=a,t[2]=m,t[3]=p):(m=t[2],p=t[3]),y.useEffect(m,p),i){let E;return t[4]===Symbol.for("react.memo_cache_sentinel")?(E=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(tt,{className:"size-3.5 animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=E):E=t[4],E}if(s.length===0){const E=o?`No commands or skills matching "${o}"`:"No commands or skills found";let P;return t[5]!==E?(P=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:r.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:E})})}),t[5]=E,t[6]=P):P=t[6],P}let h,g,x,v,w,b,j,S,N;if(t[7]!==d||t[8]!==c||t[9]!==l||t[10]!==a||t[11]!==s){const E=s.filter(Q5),P=[{heading:"Commands",suggestions:E,offset:0},{heading:"Skills",suggestions:s.filter(Z5),offset:E.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=$g,w="slash-suggestions",b=s[a]?`${s[a].type}-${s[a].name}`:void 0,t[21]!==c||t[22]!==s?(j=_=>{const A=s.findIndex(I=>`${I.type}-${I.name}`===_);A>=0&&c(A)},t[21]=c,t[22]=s,t[23]=j):j=t[23],S=!1,N="border shadow-sm",h=Ig,v=P.map(_=>_.suggestions.length>0&&r.jsx(Rg,{heading:_.heading,children:_.suggestions.map((A,I)=>{const R=_.offset+I;return r.jsx(J5,{suggestion:A,index:R,isSelected:R===a,onSelect:l,onHover:c,onEdit:d,itemRefs:f},`${A.type}-${A.name}`)})},_.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]=v,t[16]=w,t[17]=b,t[18]=j,t[19]=S,t[20]=N}else h=t[12],g=t[13],x=t[14],v=t[15],w=t[16],b=t[17],j=t[18],S=t[19],N=t[20];let C;t[24]!==h||t[25]!==v?(C=r.jsx(h,{children:v}),t[24]=h,t[25]=v,t[26]=C):C=t[26];let k;t[27]!==g||t[28]!==C||t[29]!==w||t[30]!==b||t[31]!==j||t[32]!==S||t[33]!==N?(k=r.jsx(g,{id:w,value:b,onValueChange:j,shouldFilter:S,className:N,children:C}),t[27]=g,t[28]=C,t[29]=w,t[30]=b,t[31]=j,t[32]=S,t[33]=N,t[34]=k):k=t[34];let T;return t[35]!==x||t[36]!==k?(T=r.jsx("div",{className:x,children:k}),t[35]=x,t[36]=k,t[37]=T):T=t[37],T});function J5({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:o,onEdit:i,itemRefs:a}){const l=y.useCallback(c=>{c?(c.id=`slash-suggestion-${e}`,a.current.set(e,c)):a.current.delete(e)},[e,a]);return r.jsxs("div",{className:"group/suggestion relative",children:[r.jsxs(Mg,{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(go,{className:"size-4 text-muted-foreground"}):r.jsx(Gi,{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]}),Y5(n)]}),n.description&&r.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&r.jsx(G5,{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(Us,{"data-icon":"inline-start"})})]})}function Q5(n){return n.type==="command"}function Z5(n){return n.type==="skill"}function eS(n){const e=B.c(25),{files:t,query:s,loading:o,selectedIndex:i,onSelect:a,onHover:l}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Map,e[0]=c):c=e[0];const d=y.useRef(c);let u,f;e[1]!==i?(u=()=>{var b,j;(j=(b=d.current.get(i))==null?void 0:b.scrollIntoView)==null||j.call(b,{block:"nearest"})},f=[i],e[1]=i,e[2]=u,e[3]=f):(u=e[2],f=e[3]),y.useEffect(u,f);const m=t[i];let p;e[4]!==t||e[5]!==l?(p=b=>{const j=t.indexOf(b);j>=0&&l(j)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==o?(h=o&&r.jsx(tt,{"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((b,j)=>r.jsxs(Mg,{ref:S=>{S?(S.id=`file-suggestion-${j}`,d.current.set(j,S)):d.current.delete(j)},value:b,onMouseEnter:()=>l(j),onSelect:()=>a(b),onMouseDown:tS,children:[r.jsx(S1,{"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:b}),j===i&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},b)),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 v;e[18]!==g||e[19]!==x?(v=r.jsx(Ig,{className:"max-h-70",children:r.jsx(Rg,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=v):v=e[20];let w;return e[21]!==m||e[22]!==p||e[23]!==v?(w=r.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-1.5 max-w-[var(--chat-width)]",children:r.jsx($g,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:v})}),e[21]=m,e[22]=p,e[23]=v,e[24]=w):w=e[24],w}function tS(n){return n.preventDefault()}const nS=Qn("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 ft(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=K(nS({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 kt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 mt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Ss(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Ao(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(s3,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Po(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(o3,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function $o(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=K("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(N1,{"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(_1,{children:r.jsx(T1,{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 Gn(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(k1,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Og(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=K("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(E1,{"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 zt(n){const e=B.c(12);let t,s,o,i;e[0]!==n?({className:t,inset:s,variant:i,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i):(t=e[1],s=e[2],o=e[3],i=e[4]);const a=i===void 0?"default":i;let l;e[5]!==t?(l=K("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 kB(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(i3,{"data-slot":"dropdown-menu-radio-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function CB(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=K("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(a3,{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(lt,{})})}),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(r3,{"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 Qi(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("-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(ad,{"data-slot":"dropdown-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function ct(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(c3,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=s):s=e[3],s}function Pt(n){const e=B.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=r.jsx(d3,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function dt(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(l3,{"data-slot":"collapsible-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const sS={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function Em(n){return sS[n]??n.replaceAll("_"," ")}function oS(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,v,w,b,j;if(e[0]!==d||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==l){const P=i===void 0?[]:i;p=l===void 0?!1:l;const _=a??P[0],A=P.filter($=>$!==_);m=ft,v="mb-3 pr-44",e[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Pr,{}),b=r.jsx(kt,{children:"Plan ready for review"}),e[15]=w,e[16]=b):(w=e[15],b=e[16]);const I=s||"Approve the plan or ask the agent to revise it.";e[17]!==I?(j=r.jsx(mt,{children:I}),e[17]=I,e[18]=j):j=e[18],f=Ss,h="flex gap-2";let R;e[19]!==p?(R=p&&r.jsx(tt,{className:"animate-spin","data-icon":"inline-start"}),e[19]=p,e[20]=R):R=e[20],g=r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>d(_),children:[R,p?"Sending...":_?Em(_):"Approve"]}),x=A.length>0&&r.jsxs(Ao,{children:[r.jsx(Po,{render:r.jsx(ee,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:p}),children:r.jsx(nt,{"data-icon":"icon"})}),r.jsx($o,{align:"end",children:r.jsx(Gn,{children:A.map($=>r.jsx(zt,{onClick:()=>d($),children:Em($)},$))})})]}),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]=v,e[12]=w,e[13]=b,e[14]=j}else f=e[5],m=e[6],p=e[7],h=e[8],g=e[9],x=e[10],v=e[11],w=e[12],b=e[13],j=e[14];let S;e[21]!==u||e[22]!==p?(S=r.jsx(ee,{variant:"ghost",size:"sm",disabled:p,onClick:u,children:"Reject"}),e[21]=u,e[22]=p,e[23]=S):S=e[23];let N;e[24]!==f||e[25]!==S||e[26]!==h||e[27]!==g||e[28]!==x?(N=r.jsxs(f,{className:h,children:[g,x,S]}),e[24]=f,e[25]=S,e[26]=h,e[27]=g,e[28]=x,e[29]=N):N=e[29];let C;e[30]!==c?(C=c&&r.jsx("div",{role:"alert",className:"col-span-full mt-2 text-xs text-destructive",children:c}),e[30]=c,e[31]=C):C=e[31];let k;e[32]!==o?(k=o&&r.jsxs(ct,{className:"col-span-full mt-2",children:[r.jsx(Pt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),r.jsx(dt,{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]=k):k=e[33];let T;e[34]!==t?(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(rS)]}),e[34]=t,e[35]=T):T=e[35];let E;return e[36]!==m||e[37]!==N||e[38]!==C||e[39]!==k||e[40]!==T||e[41]!==v||e[42]!==w||e[43]!==b||e[44]!==j?(E=r.jsxs(m,{className:v,children:[w,b,j,N,C,k,T]}),e[36]=m,e[37]=N,e[38]=C,e[39]=k,e[40]=T,e[41]=v,e[42]=w,e[43]=b,e[44]=j,e[45]=E):E=e[45],E}function rS(n,e){return r.jsx(Ie,{variant:"outline",children:n.prompt},e)}const iS=["allow","allow_always","deny"];function ji(n,e){return(n.availableDecisions??iS).includes(e)}function aS(n){switch(n){case"Bash":return{label:"Run command",icon:go,tone:"cmd"};case"Edit":return{label:"Edit file",icon:mc,tone:"write"};case"Write":return{label:"Write file",icon:mc,tone:"write"};case"Read":return{label:"Read file",icon:gs,tone:"read"};case"Glob":return{label:"File search",icon:tn,tone:"search"};case"Grep":return{label:"Content search",icon:tn,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:Yi,tone:"net"};case"WebSearch":return{label:"Web search",icon:Yi,tone:"net"};default:return{label:n,icon:ha,tone:"other"}}}function lS(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 cS({requests:n,responding:e,onRespond:t,onRespondAll:s}){var w;const o=n[0],i=n.length,a=o?ji(o,"allow"):!1,l=o?ji(o,"allow_always"):!1,c=o?ji(o,"deny"):!1,d=i>1&&n.every(b=>ji(b,"allow")),u=y.useEffectEvent(b=>{if(!o)return;const j=b.target;if(j&&(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable)||b.metaKey||b.ctrlKey||b.altKey)return;const S=b.key.toLowerCase();S==="a"&&b.shiftKey&&d?(b.preventDefault(),s("allow")):S==="a"&&a?(b.preventDefault(),t(o.requestId,"allow")):S==="s"&&l?(b.preventDefault(),t(o.requestId,"allow_always")):S==="d"&&c&&(b.preventDefault(),t(o.requestId,"deny"))});y.useEffect(()=>{const b=j=>u(j);return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[]);const f=o?aS(o.toolName):null,m=o?lS(o.toolName,o.input):null,p=(o==null?void 0:o.decisionReason)||(o==null?void 0:o.description)||(o==null?void 0:o.blockedPath),h=(((w=o==null?void 0:o.suggestions)==null?void 0:w.length)??0)>0;if(!o||!f)return null;const g=f.icon,x=e.has(o.requestId),v=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(v1,{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}),v&&r.jsxs(Ie,{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(Qe,{"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(u3,{"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(lt,{"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 dS=1568,uS=.85,Am=35e5;function fS(n,e){let{width:t,height:s}=n;const o=Math.min(1,dS/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?uS:void 0),u=d.split(",")[1];if(u.length>Am){let f=l?.7:.8;for(;u.length>Am&&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 mS(n){const e=B.c(24),t=n===void 0?!0:n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[o,i]=y.useState(s),[a,l]=y.useState(!1),[c,d]=y.useState(!1),u=y.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]),y.useEffect(f,m);let p;e[4]!==t?(p=$=>{const M=Array.from($).filter(gS);if(!t){M.length>0&&d(!0);return}d(!1);for(const L of M){const D=new FileReader;D.onload=()=>{if(!u.current){d(!0);return}const F=D.result,z=new Image;z.onload=()=>{if(!u.current){d(!0);return}const O=fS(z,L.type);i(H=>[...H,{id:crypto.randomUUID(),file:L,preview:O.dataUrl,data:O.base64,mediaType:O.mediaType}])},z.src=F},D.onerror=()=>{console.warn(`Failed to read image file: ${L.name}`)},D.readAsDataURL(L)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=$=>{i(M=>M.filter((L,D)=>D!==$)),d(!1)},e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{i([]),d(!1)},e[7]=v):v=e[7];const w=v;let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=()=>d(!1),e[8]=b):b=e[8];const j=b;let S;e[9]!==t?(S=$=>{$.preventDefault(),t&&l(!0)},e[9]=t,e[10]=S):S=e[10];const N=S;let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=$=>{$.preventDefault(),$.currentTarget.contains($.relatedTarget)||l(!1)},e[11]=C):C=e[11];const k=C;let T;e[12]!==h?(T=$=>{$.preventDefault(),l(!1),$.dataTransfer.files.length>0&&h($.dataTransfer.files)},e[12]=h,e[13]=T):T=e[13];const E=T;let P;e[14]!==h?(P=$=>{var F;const M=(F=$.clipboardData)==null?void 0:F.items;if(!M)return;const L=Array.from(M).filter(hS);if(L.length===0)return;$.preventDefault();const D=L.map(pS).filter(Boolean);h(D)},e[14]=h,e[15]=P):P=e[15];const _=P,A=!t&&o.length>0?"The selected model does not accept images. Switch models or remove the attachments.":!t&&c?"The selected model does not accept the image you tried to add.":null,I=!t&&o.length>0;let R;return e[16]!==N||e[17]!==E||e[18]!==_||e[19]!==o||e[20]!==a||e[21]!==A||e[22]!==I?(R={images:o,isDragOver:a,imageError:A,hasUnsupportedAttachments:I,dismissImageError:j,removeImage:x,clearImages:w,handleDragOver:N,handleDragLeave:k,handleDrop:E,handlePaste:_},e[16]=N,e[17]=E,e[18]=_,e[19]=o,e[20]=a,e[21]=A,e[22]=I,e[23]=R):R=e[23],R}function pS(n){return n.getAsFile()}function hS(n){return n.type.startsWith("image/")}function gS(n){return n.type.startsWith("image/")}function xS(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(h3,{"data-slot":"tooltip-provider",delay:o,...t}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function Ct(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(xS,{children:r.jsx(p3,{"data-slot":"tooltip",...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(f3,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Tt(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=K("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(m3,{"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(g3,{children:r.jsx(x3,{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 _n="rounded-full border bg-background/80 shadow-sm backdrop-blur",Aa=y.memo(function(e){const t=B.c(8);let s,o;t[0]!==e?({className:s,...o}=e,t[0]=e,t[1]=s,t[2]=o):(s=t[1],o=t[2]);let i;t[3]!==s?(i=K("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}),kl=y.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(_t,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==o?(g=r.jsx(Tt,{children:o}),t[12]=o,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=r.jsxs(Ct,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function bS(n){return n<10?"critical":n<30?"warning":"healthy"}const vS={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},Lg=y.memo(function(e){const t=B.c(54),{rawMessages:s,showRemaining:o,showTooltip:i,warnOnly:a}=e,l=o===void 0?!1:o,c=i===void 0?!1:i,d=a===void 0?!1:a;let u,f,m,p,h,g,x,v,w,b,j,S,N;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==d){x=Symbol.for("react.early_return_sentinel");e:{const E=pg(s);if(!E){x=null;break e}const P=Math.max(0,100-E.percent),_=bS(P);if(d&&_==="healthy"){x=null;break e}const A=Math.max(0,E.compactAt-E.used);let I;t[17]!==P||t[18]!==A||t[19]!==l?(I=l?`${P.toFixed(0)}% · ${at(A)}`:`${P.toFixed(0)}%`,t[17]=P,t[18]=A,t[19]=l,t[20]=I):I=t[20];const R=I,$=vS[_],M=l&&"gap-1";let L;t[21]!==$||t[22]!==M?(L=K("shrink-0 tabular-nums",$,M),t[21]=$,t[22]=M,t[23]=L):L=t[23];let D;t[24]!==R||t[25]!==L?(D=r.jsx(Ie,{variant:"outline",className:L,children:R}),t[24]=R,t[25]=L,t[26]=D):D=t[26];const F=D;if(!c){x=F;break e}f=Ct,t[27]!==F?(g=r.jsx(_t,{render:F}),t[27]=F,t[28]=g):g=t[28],u=Tt,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 z;t[30]!==A?(z=at(A),t[30]=A,t[31]=z):z=t[31];let O;t[32]!==P?(O=P.toFixed(1),t[32]=P,t[33]=O):O=t[33],t[34]!==z||t[35]!==O?(h=r.jsxs("div",{children:[z," remaining (",O,"%)"]}),t[34]=z,t[35]=O,t[36]=h):h=t[36],v="text-muted-foreground",w=at(E.used),b=" / ",j=at(E.limit),S=" tokens used (",N=E.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]=v,t[12]=w,t[13]=b,t[14]=j,t[15]=S,t[16]=N}else u=t[4],f=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],v=t[11],w=t[12],b=t[13],j=t[14],S=t[15],N=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let C;t[37]!==v||t[38]!==w||t[39]!==b||t[40]!==j||t[41]!==S||t[42]!==N?(C=r.jsxs("div",{className:v,children:[w,b,j,S,N,"%)"]}),t[37]=v,t[38]=w,t[39]=b,t[40]=j,t[41]=S,t[42]=N,t[43]=C):C=t[43];let k;t[44]!==u||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==C?(k=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]=k):k=t[49];let T;return t[50]!==f||t[51]!==g||t[52]!==k?(T=r.jsxs(f,{children:[g,k]}),t[50]=f,t[51]=g,t[52]=k,t[53]=T):T=t[53],T});function yS(n){const e=B.c(7),{isPlanApproval:t,isUserQuestion:s,elapsedSec:o}=n,{isLive:i}=st(),{chat:a}=zr(),{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:k4(o)}),r.jsx(Aa,{})]}),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 wS(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}=st(),{handleStopSession:d}=c,{chat:u}=zr(),{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)??At((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=L4(g),e[3]=g,e[4]=x):x=e[4];const v=x;let w;e[5]!==v||e[6]!==m||e[7]!==p?(w=p&&r.jsxs(Ct,{children:[r.jsx(_t,{render:r.jsx(ee,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":v,title:v}),children:r.jsx(pd,{"data-icon":"inline-start",className:"fill-current"})}),r.jsxs(Tt,{children:[v," (Esc)"]})]}),e[5]=v,e[6]=m,e[7]=p,e[8]=w):w=e[8];let b;e[9]!==g||e[10]!==d||e[11]!==p?(b=p&&Bt(g).stopSession&&r.jsxs(Ct,{children:[r.jsx(_t,{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(b3,{"data-icon":"inline-start"})}),r.jsx(Tt,{children:"Stop session"})]}),e[9]=g,e[10]=d,e[11]=p,e[12]=b):b=e[12];const j=t?"default":"secondary",S=!t&&"text-muted-foreground";let N;e[13]!==S?(N=K("shrink-0 rounded-full",S),e[13]=S,e[14]=N):N=e[14];const C=!t;let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(v3,{"data-icon":"inline-start"}),e[15]=k):k=e[15];let T;e[16]!==s||e[17]!==i||e[18]!==N||e[19]!==C||e[20]!==j?(T=r.jsx(ee,{variant:j,size:"icon-sm",className:N,disabled:C,onClick:s,"aria-label":i,title:i,children:k}),e[16]=s,e[17]=i,e[18]=N,e[19]=C,e[20]=j,e[21]=T):T=e[21];let E;return e[22]!==T||e[23]!==w||e[24]!==b?(E=r.jsxs("div",{className:"flex items-center gap-1",children:[w,b,T]}),e[22]=T,e[23]=w,e[24]=b,e[25]=E):E=e[25],E}function Pm(n){const e=B.c(34),{error:t}=n,[s,o]=y.useState(!1),[i,a]=y.useState(!1);let l;e[0]!==t?(l=t.split(`
|
|
3
|
+
`),e[0]=t,e[1]=l):l=e[1];const c=l[0];let d;e[2]!==t||e[3]!==c?(d=t.includes(`
|
|
4
|
+
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=d):d=e[4];const 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(Wt,{"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 v;e[13]!==g||e[14]!==x?(v=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]=v):v=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(_s,{children:[r.jsxs(ns,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(Wt,{className:"size-4"}),"Error details"]}),r.jsx(ss,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let b;e[17]!==t?(b=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]=b):b=e[18];let j;e[19]!==i?(j=i?r.jsx(lt,{"data-icon":"inline-start"}):r.jsx(fn,{"data-icon":"inline-start"}),e[19]=i,e[20]=j):j=e[20];const S=i?"Copied":"Copy";let N;e[21]!==m||e[22]!==j||e[23]!==S?(N=r.jsx("div",{className:"flex justify-end",children:r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,S]})}),e[21]=m,e[22]=j,e[23]=S,e[24]=N):N=e[24];let C;e[25]!==b||e[26]!==N?(C=r.jsxs(ts,{className:"max-w-2xl",children:[w,b,N]}),e[25]=b,e[26]=N,e[27]=C):C=e[27];let k;e[28]!==s||e[29]!==C?(k=r.jsx(es,{open:s,onOpenChange:o,children:C}),e[28]=s,e[29]=C,e[30]=k):k=e[30];let T;return e[31]!==k||e[32]!==v?(T=r.jsxs(r.Fragment,{children:[v,k]}),e[31]=k,e[32]=v,e[33]=T):T=e[33],T}function jS(n){const e=B.c(17),{suggestion:t,onAccept:s}=n,[o,i]=y.useState(null);if(!t||t===o)return null;let a;e[0]!==s||e[1]!==t?(a=()=>{i(t),s(t)},e[0]=s,e[1]=t,e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Gi,{"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(Qe,{}),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 SS(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 NS(n,e,t){return`${n.slice(0,e.start)}@${t} `}const Pa={terminal:!0,configWrite:!0,hostFiles:!0,manageUsers:!0,manageWorkspaces:!0,manageDevices:!0,killAny:!0,viewAllSessions:!0,viewUsage:!0,share:!0,runFlows:!0},Br={terminal:!1,configWrite:!1,hostFiles:!1,manageUsers:!1,manageWorkspaces:!1,manageDevices:!1,killAny:!1,viewAllSessions:!1,viewUsage:!1,share:!1,runFlows:!1};let Dg=Pa;const Ac=new Set;function co(n){Dg=(n==null?void 0:n.capabilities)??Pa;for(const e of Ac)e()}function et(n){return Dg[n]}function kS(n){return Ac.add(n),()=>Ac.delete(n)}function jn(n){const e=B.c(3);let t,s;return e[0]!==n?(t=()=>et(n),s=()=>et(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(kS,t,s)}function CS(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function _S(n,e,t){const s=jn("hostFiles"),[o,i]=y.useState([]),[a,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){i([]),l(!1);return}const c=new AbortController,d=window.setTimeout(async()=>{l(!0);try{const u=await _e(`/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(CS(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 Pc="cogpit-share-revoked";function TS(){window.dispatchEvent(new Event(Pc))}async function zg(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&&TS(),s}function Ur(n,e){return zg(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function ES(){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 AS(n,e){return Ur("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function PS(){return Ur("/api/share/interrupt")}function $S(){return Ur("/api/share/stop")}async function IS(n,e){return(await Ur("/api/share/permission",{requestId:n,behavior:e})).ok}async function RS(n,e){try{const t=await Ur("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function MS(){try{const n=await zg("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const OS=/^\/shared\/([^/]+)\/?$/;function Fg(n){const e=OS.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function $a(n){return Fg(n)!==null}function LS(n){return`/shared/${encodeURIComponent(n)}`}function _B(n){return[...n].join(", ")}async function Dd(n,e){try{const t=await Dn(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function zd(n,e,t){return $a(window.location.pathname)?RS(e,t):Dd("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t})}async function DS(n,e,t){try{return(await Dn(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function Ia(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Si(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 zS(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 FS(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"}function BS(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?K("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):K("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function US(n,e){return n?"gap-1 px-2 pb-2 pt-0.5":e?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"}const $c=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:o,footer:i,compact:a=!1},l){var Be;const c=jn("hostFiles"),{session:d,isLive:u,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:v,slashSuggestionsLoading:w,turnError:b,promptSuggestion:j}=st(),{chat:{status:S,error:N,isConnected:C,sendMessage:k,interrupt:T}}=zr(),E=C||u,[P,_]=y.useState(""),[A,I]=y.useState(!1),[R,$]=y.useState(!1),[M,L]=y.useState(null),D=y.useRef(null),F=y.useRef(null),z=y.useRef(!1),O=y.useRef(""),H=y.useRef(null);y.useEffect(()=>{O.current=P},[P]);const W=y.useCallback(le=>{z.current=le,I(le)},[]),{images:U,isDragOver:V,imageError:q,hasUnsupportedAttachments:X,dismissImageError:G,removeImage:Y,clearImages:J,handleDragOver:Q,handleDragLeave:Z,handleDrop:te,handlePaste:ne}=mS(e),[oe,re]=y.useState(0),[ie,se]=y.useState(0),[de,ce]=y.useState(!1),ue=P.startsWith("/")&&!P.includes(" "),me=ue?P.slice(1):"",fe=y.useMemo(()=>{if(!ue)return[];const le=me.toLowerCase(),he=v.filter(Oe=>le?Oe.name.toLowerCase().includes(le)||Oe.description.toLowerCase().includes(le):!0),Ue=he.filter(Oe=>Oe.type==="command"),ze=he.filter(Oe=>Oe.type==="skill");return[...Ue,...ze]},[ue,me,v]),ae=y.useMemo(()=>SS(P),[P]),ve=!!(c&&ae&&s&&!de),ge=_S(s,(ae==null?void 0:ae.query)??"",ve);y.useEffect(()=>{re(0)},[me]),y.useEffect(()=>{se(0)},[ae==null?void 0:ae.query]);const ye=yg(C),Pe=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{F.current=Pe,D.current=null,$(!1),L(null)},[Pe]);const De=y.useCallback(async le=>{const he=m;if(!(d!=null&&d.sessionId)||(he==null?void 0:he.type)!=="question")return;const Ue=he.questions[0];if(!Ue||!le.trim())return;(await zd(d.sessionId,he.toolUseId,{[Ue.question]:le})).ok||k(le)},[m,d==null?void 0:d.sessionId,k]),Te=y.useCallback(async(le,he,Ue)=>{const ze=m;if((ze==null?void 0:ze.type)==="plan"&&ze.provider==="copilot"&&ze.requestId&&(d!=null&&d.sessionId)){const Oe=ze.requestId;if(D.current)return!1;D.current=Oe,$(!0),L(null);try{const Ye=await DS(d.sessionId,Oe,{approved:le,...he?{selectedAction:he}:{},...Ue?{feedback:Ue}:{}});return!Ye&&F.current===Oe&&L("Couldn't send the plan response. Try again."),Ye}finally{D.current===Oe&&(D.current=null,$(!1))}}return k(le?"yes":Ue||"no"),!0},[m,d==null?void 0:d.sessionId,k]),Ae=y.useCallback(()=>{requestAnimationFrame(()=>{const le=H.current;le&&(le.focus(),le.selectionStart=le.selectionEnd=le.value.length,W(Si(le,z.current)))})},[W]),pe=y.useCallback(le=>{_(`/${le.name} `),re(0),Ae()},[Ae]),xe=y.useCallback(le=>{_(le),Ae()},[Ae]),ke=y.useCallback(le=>{if(!ae)return;const he=NS(P,ae,le);_(he),ce(!0),se(0),requestAnimationFrame(()=>{const Ue=H.current;Ue&&(Ue.focus(),Ue.selectionStart=Ue.selectionEnd=Ue.value.length,W(Si(Ue,z.current)))})},[ae,P,W]),$e=y.useCallback(async()=>{const le=P.trim();if(!le&&U.length===0||!e&&U.length>0)return;if((m==null?void 0:m.type)==="question"){De(le),_(""),W(!1),H.current&&(H.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!le||!await Te(!1,void 0,le))return;_(""),W(!1),H.current&&(H.current.style.height="auto");return}const he=e&&U.length>0?U.map(Ue=>({data:Ue.data,mediaType:Ue.mediaType})):void 0;k(le,he),_(""),J(),W(!1),H.current&&(H.current.style.height="auto")},[P,U,e,k,J,W,m,De,Te]),we=y.useCallback(le=>{if(ve&&le.key==="Escape"){le.preventDefault(),ce(!0);return}if(ve&&ge.files.length>0){if(le.key==="ArrowDown"){le.preventDefault(),se(he=>he<ge.files.length-1?he+1:0);return}if(le.key==="ArrowUp"){le.preventDefault(),se(he=>he>0?he-1:ge.files.length-1);return}if(le.key==="Tab"||le.key==="Enter"&&!le.shiftKey){le.preventDefault();const he=ge.files[ie];he&&ke(he);return}}if(ue&&fe.length>0){if(le.key==="ArrowDown"){le.preventDefault(),re(he=>he<fe.length-1?he+1:0);return}if(le.key==="ArrowUp"){le.preventDefault(),re(he=>he>0?he-1:fe.length-1);return}if(le.key==="Tab"||le.key==="Enter"&&!le.shiftKey){le.preventDefault();const he=fe[oe];he&&pe(he);return}if(le.key==="Escape"){le.preventDefault(),_("");return}}if(le.key==="Escape"&&E&&T){le.preventDefault(),T();return}le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),$e())},[$e,E,T,ve,ge.files,ie,ke,ue,fe,oe,pe]),be=y.useCallback(le=>{_(le.target.value),ce(!1),W(Si(le.target,z.current))},[W]);y.useImperativeHandle(l,()=>({focus:()=>{var le;return(le=H.current)==null?void 0:le.focus()},getText:()=>O.current,setText:le=>{_(le),ce(!1),requestAnimationFrame(()=>W(Si(H.current,z.current)))}}),[W]);const Le=(m==null?void 0:m.type)==="plan",Se=(m==null?void 0:m.type)==="question",Re=p.length>0,Ne=!!i,Fe=(P.trim().length>0||U.length>0)&&!X,He=Bt(t??qs).midTurnSteering&&E,We=ve?"file-suggestions":ue?"slash-suggestions":void 0,Ee=ve&&ge.files[ie]?`file-suggestion-${ie}`:ue&&fe[oe]?`slash-suggestion-${oe}`:void 0;return r.jsxs("div",{className:K("relative pb-0",a?"px-2 pt-2":"px-3 pt-2",V&&"ring-2 ring-info/40 ring-inset"),onDragOver:Q,onDragLeave:Z,onDrop:te,children:[V&&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"})}),ue&&r.jsx(X5,{suggestions:fe,filter:me,loading:w,selectedIndex:oe,onSelect:pe,onHover:re,onEdit:f}),ve&&r.jsx(eS,{files:ge.files,query:(ae==null?void 0:ae.query)??"",loading:ge.loading,selectedIndex:ie,onSelect:ke,onHover:se}),r.jsxs("div",{children:[Le&&r.jsx(oS,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:R,responseError:M,onApprove:le=>{Te(!0,le)},onReject:()=>{Te(!1)}}),r.jsx(jS,{suggestion:j,onAccept:xe}),U.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:U.map((le,he)=>r.jsxs("div",{className:"motion-list-item relative group/thumb",children:[r.jsx("img",{src:le.preview,alt:`Upload ${he+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(he),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 ${he+1}`,children:r.jsx(Qe,{className:"size-3","data-icon":"icon"})})]},le.id))}),q&&r.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[r.jsx("span",{className:"flex-1",children:q}),!X&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:G,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:r.jsx(Qe,{"data-icon":"icon"})})]}),r.jsxs("div",{className:K("relative overflow-hidden border bg-composer-surface/85 shadow-lg shadow-black/5 backdrop-blur-xl transition-[border-color,box-shadow] duration-150",Ne?"rounded-3xl":"rounded-xl",FS(Le,Se,Re),"focus-within:ring-3"),children:[Re&&r.jsx(cS,{requests:p,responding:h,onRespond:g,onRespondAll:x},(Be=p[0])==null?void 0:Be.requestId),r.jsxs("div",{className:K("min-w-0",Ne?"flex flex-col":"grid items-end",!Ne&&(A?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[o&&r.jsx("div",{className:K("flex shrink-0 items-center",A?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:o}),r.jsx(Ia,{ref:H,value:P,onChange:be,onKeyDown:we,onPaste:ne,onFocus:()=>{setTimeout(()=>{var le;return(le=H.current)==null?void 0:le.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:zS(Le,Se,C,Re,He,a),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!We,"aria-controls":We,"aria-activedescendant":Ee,rows:1,className:K("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-sm text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0 dark:bg-transparent",BS(Ne,A,a))}),r.jsxs("div",{className:K("flex shrink-0 items-center justify-end",US(Ne,A)),children:[i,r.jsx(yS,{isPlanApproval:Le,isUserQuestion:Se,elapsedSec:ye}),r.jsx(wS,{hasContent:Fe,onSubmit:$e,submitLabel:He?"Steer active turn":"Send message"})]})]})]}),S==="error"&&N&&r.jsx(Pm,{error:N},N),b&&r.jsx(Pm,{error:b},b)]})]})}));function WS(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function HS(n){return WS(n)?n:null}function qS(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=HS(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 Ni(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function It(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(y3,{"data-slot":"input",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wr(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=K("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(KS,{children:r.jsx(VS,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==o||e[10]!==a||e[11]!==i?(c=r.jsxs(w3,{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 KS(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(j3,{className:o,"data-slot":"progress-track",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function VS(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(S3,{"data-slot":"progress-indicator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Bg(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Ug(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(k3,{className:o,"data-slot":"progress-value",...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const GS={section:null,canCreate:!1,beginEditing:()=>{}},Fd=y.createContext(GS);function Wg(){return y.useContext(Fd)}const Hg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",qg="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function YS(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function XS(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function JS({agentKind:n,threadId:e,children:t}){const s=Ta(n),[o,i]=y.useState(null),[a,l]=y.useState(!0),[c,d]=y.useState(!1),[u,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,v]=y.useState(null),w=y.useCallback(async E=>{try{const P=await _e(Ni(e),{signal:E});if(P.status===404||P.status===501){l(!1);return}if(!P.ok)return;const _=await P.json();i(_.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const E=new AbortController;w(E.signal);const P=a?setInterval(()=>void w(),1e4):void 0;return()=>{E.abort(),P!==void 0&&clearInterval(P)}},[w,a]);const b=y.useCallback(()=>{var E;f((o==null?void 0:o.objective)??""),p(((E=o==null?void 0:o.tokenBudget)==null?void 0:E.toString())??""),v(null),d(!0)},[o]),j=async()=>{const E=u.trim();if(!E)return;const P=m.trim()?Number(m):null;if(P!==null&&(!Number.isSafeInteger(P)||P<=0)){v("Token budget must be a positive whole number");return}g(!0),v(null);try{const _=await _e(Ni(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:E,status:(o==null?void 0:o.status)==="complete"?"active":(o==null?void 0:o.status)??"active",tokenBudget:P})}),A=await _.json();if(!_.ok)throw new Error(A.error||"Could not save goal");i(A.goal),d(!1)}catch(_){v(_ instanceof Error?_.message:"Could not save goal")}finally{g(!1)}},S=async E=>{if(o){g(!0);try{const P=await _e(Ni(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:E})});P.ok&&i((await P.json()).goal)}finally{g(!1)}}},N=async()=>{g(!0);try{(await _e(Ni(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 k=null;if(a&&c)k=r.jsxs("form",{className:qg,onSubmit:E=>{E.preventDefault(),j()},children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[r.jsx(xo,{className:"size-3.5","data-icon":"inline-start"}),o?"Edit long-running goal":"Set a long-running goal"]}),r.jsxs(To,{className:"gap-2",children:[r.jsxs(vt,{children:[r.jsx(yt,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),r.jsx(Ia,{id:"goal-objective",value:u,onChange:E=>f(E.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),r.jsxs(vt,{orientation:"horizontal","data-invalid":!!x,children:[r.jsx(yt,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),r.jsx(It,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:E=>p(E.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),r.jsx(ps,{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(Qe,{"data-icon":"inline-start"}),"Cancel"]}),r.jsxs(ee,{type:"submit",size:"xs",disabled:h||!u.trim(),children:[r.jsx(lt,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(a&&o){const E=o.status==="paused",P=o.status==="complete";k=r.jsxs("section",{className:Hg,"aria-label":`${s} goal`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(xo,{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(Ie,{variant:XS(o.status),children:YS(o.status)}),r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[at(o.tokensUsed),o.tokenBudget?` / ${at(o.tokenBudget)}`:""," · ",Math.max(0,Math.round(o.timeUsedSeconds/60)),"m"]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[E&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("active"),disabled:h,"aria-label":"Resume goal",children:r.jsx($r,{"data-icon":"icon"})}),!E&&!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("paused"),disabled:h,"aria-label":"Pause goal",children:r.jsx(C3,{"data-icon":"icon"})}),!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void S("complete"),disabled:h,"aria-label":"Mark goal complete",children:r.jsx(lt,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:b,"aria-label":"Edit goal",children:r.jsx(Us,{"data-icon":"icon"})}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void N(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:r.jsx(ga,{"data-icon":"icon"})})]})]}),C!==null&&r.jsx(Wr,{className:"mt-1 mb-0.5",value:C,"aria-label":`${C.toFixed(0)}% of goal token budget used`})]})}const T=y.useMemo(()=>({section:k,canCreate:a&&!o&&!c,beginEditing:b}),[k,a,o,c,b]);return r.jsx(Fd.Provider,{value:T,children:t})}function QS(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function ZS(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function eN(n){const e=B.c(84),{agentKind:t,session:s,onSendCommand:o,children:i}=n;let a;e[0]!==t?(a=Ta(t),e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==s.rawMessages?(c=qS(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const d=c,[u,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,v]=y.useState(null),w=d?`${d.status}\0${d.condition}`:"",[b,j]=y.useState(w);b!==w&&(j(w),f(void 0));const S=u!==void 0?u:d;let N;e[4]!==(S==null?void 0:S.condition)?(N=()=>{g((S==null?void 0:S.condition)??""),v(null),p(!0)},e[4]=S==null?void 0:S.condition,e[5]=N):N=e[5];const C=N;let k;e[6]!==h||e[7]!==o?(k=()=>{const M=h.trim();if(M){if(M.length>4e3){v("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]=k):k=e[8];const T=k;let E;e[9]!==o?(E=()=>{f(null),p(!1),o("/goal clear")},e[9]=o,e[10]=E):E=e[10];const P=E;let _;if(e[11]!==l||e[12]!==C||e[13]!==P||e[14]!==h||e[15]!==m||e[16]!==x||e[17]!==S||e[18]!==T){if(_=null,m){let M;e[20]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(xo,{className:"size-3.5","data-icon":"inline-start"}),e[20]=M):M=e[20];const L=S?"Replace goal":"Set a long-running goal";let D;e[21]!==L?(D=r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,L]}),e[21]=L,e[22]=D):D=e[22];const F=!!x;let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(yt,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[23]=z):z=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=Z=>g(Z.target.value),e[24]=O):O=e[24];const H=`A measurable condition ${l} should keep working toward…`,W=!!x;let U;e[25]!==h||e[26]!==H||e[27]!==W?(U=r.jsx(Ia,{id:"goal-condition",value:h,onChange:O,placeholder:H,rows:2,maxLength:4e3,"aria-invalid":W,autoFocus:!0}),e[25]=h,e[26]=H,e[27]=W,e[28]=U):U=e[28];let V;e[29]!==x?(V=r.jsx(ps,{children:x}),e[29]=x,e[30]=V):V=e[30];let q;e[31]!==U||e[32]!==V||e[33]!==F?(q=r.jsxs(vt,{"data-invalid":F,children:[z,U,V]}),e[31]=U,e[32]=V,e[33]=F,e[34]=q):q=e[34];let X;e[35]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[r.jsx(Qe,{"data-icon":"inline-start"}),"Cancel"]}),e[35]=X):X=e[35];let G;e[36]!==h?(G=h.trim(),e[36]=h,e[37]=G):G=e[37];const Y=!G;let J;e[38]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(lt,{"data-icon":"inline-start"}),e[38]=J):J=e[38];let Q;e[39]!==T||e[40]!==Y?(Q=r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[X,r.jsxs(ee,{type:"button",size:"xs",onClick:T,disabled:Y,children:[J,"Start goal"]})]}),e[39]=T,e[40]=Y,e[41]=Q):Q=e[41],_=r.jsxs("section",{className:qg,"aria-label":`${l} goal editor`,children:[D,q,Q]})}else if(S){let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(xo,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[42]=M):M=e[42];let L;e[43]!==S.condition?(L=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:S.condition,children:S.condition}),e[43]=S.condition,e[44]=L):L=e[44];let D;e[45]!==S.status?(D=ZS(S.status),e[45]=S.status,e[46]=D):D=e[46];let F;e[47]!==S.status?(F=QS(S.status),e[47]=S.status,e[48]=F):F=e[48];let z;e[49]!==D||e[50]!==F?(z=r.jsx(Ie,{variant:D,children:F}),e[49]=D,e[50]=F,e[51]=z):z=e[51];const O=S.iterations,H=S.iterations===1?"":"s";let W;e[52]!==S.tokens?(W=at(S.tokens),e[52]=S.tokens,e[53]=W):W=e[53];let U;e[54]!==S.durationMs?(U=Math.round(S.durationMs/6e4),e[54]=S.durationMs,e[55]=U):U=e[55];const V=Math.max(0,U);let q;e[56]!==S.iterations||e[57]!==H||e[58]!==W||e[59]!==V?(q=r.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[O," turn",H," · ",W," · ",V,"m"]}),e[56]=S.iterations,e[57]=H,e[58]=W,e[59]=V,e[60]=q):q=e[60];let X;e[61]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(Us,{"data-icon":"icon"}),e[61]=X):X=e[61];let G;e[62]!==C?(G=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:C,"aria-label":"Replace goal",children:X}),e[62]=C,e[63]=G):G=e[63];let Y;e[64]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(ga,{"data-icon":"icon"}),e[64]=Y):Y=e[64];let J;e[65]!==P?(J=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:P,"aria-label":"Clear goal",children:Y}),e[65]=P,e[66]=J):J=e[66];let Q;e[67]!==G||e[68]!==J?(Q=r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[G,J]}),e[67]=G,e[68]=J,e[69]=Q):Q=e[69];let Z;e[70]!==z||e[71]!==q||e[72]!==Q||e[73]!==L?(Z=r.jsxs("div",{className:"flex items-center gap-2",children:[M,L,z,q,Q]}),e[70]=z,e[71]=q,e[72]=Q,e[73]=L,e[74]=Z):Z=e[74];let te;e[75]!==S.reason?(te=S.reason&&r.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:S.reason}),e[75]=S.reason,e[76]=te):te=e[76],_=r.jsxs("section",{className:Hg,"aria-label":`${l} goal`,children:[Z,te]})}e[11]=l,e[12]=C,e[13]=P,e[14]=h,e[15]=m,e[16]=x,e[17]=S,e[18]=T,e[19]=_}else _=e[19];const A=!S&&!m;let I;e[77]!==C||e[78]!==_||e[79]!==A?(I={section:_,canCreate:A,beginEditing:C},e[77]=C,e[78]=_,e[79]=A,e[80]=I):I=e[80];const R=I;let $;return e[81]!==i||e[82]!==R?($=r.jsx(Fd.Provider,{value:R,children:i}),e[81]=i,e[82]=R,e[83]=$):$=e[83],$}function tN(n){const e=B.c(9),{agentKind:t,session:s,onSendCommand:o,children:i}=n,a=Bt(t).goals;if(a==="thread-api"){let l;return e[0]!==t||e[1]!==i||e[2]!==s.sessionId?(l=r.jsx(JS,{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(eN,{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 Kg(){return Wg().section}function Vg(){const n=B.c(3),{canCreate:e,beginEditing:t}=Wg();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(xo,{"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 nN(){const n=B.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs(r.Fragment,{children:[r.jsx(Kg,{}),r.jsx(Vg,{})]}),n[0]=e):e=n[0],e}const sN=/\x1b\].*?(?:\x07|\x1b\\)/g,oN=/\x1b\[[0-9;]*[A-Za-z]/g,rN=/\x1b[()][AB012]/g,iN=/\[2K\[1G/g;function Gg(n){return n.replace(sN,"").replace(oN,"").replace(rN,"").replace(iN,`
|
|
5
|
+
`).replace(/\r/g,"")}function zn(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=K("relative overflow-hidden",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=r.jsx(T3,{"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(aN,{}),c=r.jsx(E3,{}),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(_3,{"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 aN(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=K("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(P3,{"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(A3,{"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 Yg(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=K("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 lN(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=K("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 cN(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=K("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 dN(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=K("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 Ze(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=Yg,i=K(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 uN(n){const e=jn("hostFiles"),[t,s]=y.useState([]),[o,i]=y.useState(!1),a=y.useCallback(async()=>{if(!e||!n){s([]);return}i(!0);try{const l=await _e(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{i(!1)}},[e,n]);return y.useEffect(()=>{a()},[a]),{scripts:t,loading:o,refresh:a}}const $m=500,fN=5e3;function mN(n){const e=B.c(29),t=n===void 0?!0:n,[s,o]=y.useState("disconnected");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[a,l]=y.useState(i),c=y.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,e[1]=d):d=e[1];const u=y.useRef(d),f=y.useRef($m),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(pN);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=F=>{var H;const z=F.type,O=F.id;if(z==="sessions"){l(F.sessions??[]);return}O&&((H=u.current.get(O))==null||H(z,F))},e[2]=g):g=e[2];const x=g;let v,w;e[3]!==t?(v=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const F=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${sg()}/__pty`},z=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;o("connecting");const H=new WebSocket(F());c.current=H,H.onopen=()=>{if(p.current){H.close();return}f.current=$m,o("connected"),H.send(JSON.stringify({type:"list"}))},H.onmessage=W=>{try{const U=JSON.parse(W.data);x(U)}catch{}},H.onclose=()=>{if(p.current)return;o("disconnected"),c.current=null;const W=f.current;f.current=Math.min(W*2,fN),m.current=setTimeout(()=>h.current(),W)}};return h.current=z,z(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},w=[t,x],e[3]=t,e[4]=v,e[5]=w):(v=e[4],w=e[5]),y.useEffect(v,w);let b;e[6]!==t?(b=F=>{if(!t)return;const z=c.current;z&&z.readyState===WebSocket.OPEN&&z.send(JSON.stringify(F))},e[6]=t,e[7]=b):b=e[7];const j=b;let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=(F,z)=>{u.current.set(F,z)},e[8]=S):S=e[8];const N=S;let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=F=>{u.current.delete(F)},e[9]=C):C=e[9];const k=C;let T;e[10]!==j?(T=F=>{const z=F===void 0?{}:F,O=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:O,name:z.name??"Terminal",cwd:z.cwd,metadata:{type:"terminal"}}),O},e[10]=j,e[11]=T):T=e[11];const E=T;let P;e[12]!==j?(P=F=>{const z=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:z,name:F.name,cwd:F.cwd,args:["run",F.scriptName],command:"bun",metadata:{type:"script",source:F.source,scriptName:F.scriptName}}),z},e[12]=j,e[13]=P):P=e[13];const _=P;let A;e[14]!==j?(A=F=>{j({type:"kill",id:F})},e[14]=j,e[15]=A):A=e[15];const I=A;let R;e[16]!==j?(R=(F,z)=>{j({type:"input",id:F,data:z})},e[16]=j,e[17]=R):R=e[17];const $=R;let M;e[18]!==j?(M=(F,z,O)=>{j({type:"resize",id:F,cols:z,rows:O})},e[18]=j,e[19]=M):M=e[19];const L=M;let D;return e[20]!==I||e[21]!==L||e[22]!==j||e[23]!==a||e[24]!==_||e[25]!==E||e[26]!==s||e[27]!==$?(D={status:s,send:j,subscribe:N,unsubscribe:k,sessions:a,spawnTerminal:E,spawnScript:_,killSession:I,writeInput:$,resize:L},e[20]=I,e[21]=L,e[22]=j,e[23]=a,e[24]=_,e[25]=E,e[26]=s,e[27]=$,e[28]=D):D=e[28],D}function pN(){}const Xg=y.createContext(null);function Cl(n){const e=B.c(3),{children:t,enabled:s}=n,i=mN(s===void 0?!0:s);let a;return e[0]!==t||e[1]!==i?(a=r.jsx(Xg.Provider,{value:i,children:t}),e[0]=t,e[1]=i,e[2]=a):a=e[2],a}function Bd(){const n=y.useContext(Xg);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function hN(n){var u;const e=B.c(11),t=Bd();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 gN(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=K("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(pd,{"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 xN=y.memo(function(e){const t=B.c(42),{projectDir:s,onProcessStarted:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,t[0]=d):d=t[0];const[u,f]=y.useState(d),{scripts:m,loading:p}=uN(s),{runningProcesses:h,runScript:g,stopScript:x}=hN(o);let v;if(t[1]!==m||t[2]!==l){const z=l.trim().toLowerCase(),O=z?m.filter(H=>H.name.toLowerCase().includes(z)||H.dirLabel.toLowerCase().includes(z)):m;v=new Map;for(const H of O){const W=v.get(H.dirLabel)??[];W.push(H),v.set(H.dirLabel,W)}t[1]=m,t[2]=l,t[3]=v}else v=t[3];const w=v;let b;if(t[4]!==h){b=new Map;for(const[z,O]of h)b.set(`${O.name}:${O.cwd}`,{id:z,status:O.status});t[4]=h,t[5]=b}else b=t[5];const j=b;if(!s||!p&&m.length===0)return null;let S;t[6]===Symbol.for("react.memo_cache_sentinel")?(S=function(O){f(H=>{const W=new Set(H);return W.has(O)?W.delete(O):W.add(O),W})},t[6]=S):S=t[6];const N=S;let C;t[7]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=C):C=t[7];let k;t[8]!==p?(k=p&&r.jsx(Ze,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=k):k=t[9];const T=i?"Close script search":"Search scripts";let E,P;t[10]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{a(bN),c("")},P=r.jsx(tn,{}),t[10]=E,t[11]=P):(E=t[10],P=t[11]);let _;t[12]!==i||t[13]!==T?(_=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":T,"aria-expanded":i,onClick:E,children:P}),t[12]=i,t[13]=T,t[14]=_):_=t[14];let A;t[15]!==k||t[16]!==_?(A=r.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[C,k,_]}),t[15]=k,t[16]=_,t[17]=A):A=t[17];let I;t[18]!==i||t[19]!==l?(I=i&&r.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:r.jsx(It,{type:"search",value:l,onChange:z=>c(z.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=i,t[19]=l,t[20]=I):I=t[20];let R;t[21]!==u||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?(R=[...w.entries()].map(z=>{const[O,H]=z,W=u.has(O)||!!l,U=H.filter(vN),V=H.filter(yN),q=W?H:U.length>0?U:H.slice(0,1);return r.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&r.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:O}),q.map(X=>{const G=j.get(`${X.name}:${X.dir}`);return r.jsx(gN,{script:X,status:(G==null?void 0:G.status)??null,onRun:()=>g(X.name,X.dir,X.dirLabel),onStop:()=>{G&&x(G.id)}},`${O}:${X.name}`)}),!l&&V.length>0&&r.jsx(ee,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>N(O),children:W?"Show less":`Show ${V.length} more`})]},O)}),t[21]=u,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=R):R=t[27];let $;t[28]!==w.size||t[29]!==p||t[30]!==l?($=!p&&w.size===0&&l&&r.jsx(Gt,{className:"gap-1 p-3",children:r.jsxs(Yt,{className:"gap-1",children:[r.jsx(Xt,{children:"No matching scripts"}),r.jsx(sn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=$):$=t[31];let M;t[32]!==R||t[33]!==$?(M=r.jsxs(zn,{className:"min-h-0 flex-1 px-1 pb-1",children:[R,$]}),t[32]=R,t[33]=$,t[34]=M):M=t[34];let L;t[35]!==I||t[36]!==M||t[37]!==A?(L=r.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[A,I,M]}),t[35]=I,t[36]=M,t[37]=A,t[38]=L):L=t[38];let D;t[39]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(wt,{orientation:"vertical"}),t[39]=D):D=t[39];let F;return t[40]!==L?(F=r.jsxs(r.Fragment,{children:[L,D]}),t[40]=L,t[41]=F):F=t[41],F});function bN(n){return!n}function vN(n){return n.isCommon}function yN(n){return!n.isCommon}function Ra(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=K("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(R3,{"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 wN=Qn("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 Ma(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=K(wN({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=K("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(O3,{"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(I3,{"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 En(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 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=K("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($3,{"data-slot":"tabs-content",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}const jN=y.lazy(()=>qe(()=>import("./TerminalOutput-fFrlHJcb.js"),__vite__mapDeps([0,1,2,3,4,5])).then(n=>({default:n.TerminalOutput})));function SN({process:n}){const[e,t]=y.useState(""),[s,o]=y.useState(!1),i=y.useRef(null);return y.useEffect(()=>{let a;if(n.type==="task"&&n.outputPath)a=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=Gg(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]),y.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e]),r.jsx("pre",{ref:i,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||r.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function NN(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=K("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 v;e[11]!==x?(v=K("px-1 py-0 font-normal",x),e[11]=x,e[12]=v):v=e[12];let w;e[13]!==t.type||e[14]!==v?(w=r.jsx(Ie,{variant:"secondary",className:v,children:t.type}),e[13]=t.type,e[14]=v,e[15]=w):w=e[15];let b;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==u||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(b=r.jsxs(En,{value:c,"aria-label":d,onClick:u,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=u,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=b):b=e[24];const j=`Close ${t.name}`,S=`Close ${t.name}`;let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(Qe,{"data-icon":"inline-start"}),e[25]=N):N=e[25];let C;e[26]!==i||e[27]!==j||e[28]!==S?(C=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:S,onClick:i,className:"mr-0.5 text-muted-foreground",children:N}),e[26]=i,e[27]=j,e[28]=S,e[29]=C):C=e[29];let k;return e[30]!==l||e[31]!==b||e[32]!==C?(k=r.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[b,C]}),e[30]=l,e[31]=b,e[32]=C,e[33]=k):k=e[33],k}const Jg=100,Qg=600,kN=200,Zg="process-panel-height";function CN(){try{const n=localStorage.getItem(Zg);if(n)return Math.min(Qg,Math.max(Jg,Number(n)))}catch{}return kN}const _N=y.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=Bd(),[v,w]=y.useState(CN),b=y.useRef(null);let j,S;t[0]!==f||t[1]!==x.sessions?(j=()=>{for(const ae of x.sessions)ae.status==="exited"&&(f==null||f(ae.id,"stopped"))},S=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=j,t[3]=S):(j=t[2],S=t[3]),y.useEffect(j,S);let N;t[4]!==l||t[5]!==x?(N=ae=>{ae.type!=="task"&&x.killSession(ae.id),l(ae.id)},t[4]=l,t[5]=x,t[6]=N):N=t[6];const C=N;let k;t[7]!==v?(k=ae=>{ae.preventDefault(),b.current={startY:ae.clientY,startH:v},ae.target.setPointerCapture(ae.pointerId)},t[7]=v,t[8]=k):k=t[8];const T=k;let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E=ae=>{if(!b.current)return;const ve=b.current.startY-ae.clientY,ge=Math.min(Qg,Math.max(Jg,b.current.startH+ve));w(ge)},t[9]=E):E=t[9];const P=E;let _;t[10]!==v?(_=()=>{if(b.current){b.current=null;try{localStorage.setItem(Zg,String(v))}catch{}}},t[10]=v,t[11]=_):_=t[11];const A=_;let I;t[12]!==o||t[13]!==s?(I=o?s.get(o):null,t[12]=o,t[13]=s,t[14]=I):I=t[14];const R=I;let $;t[15]!==s?($=[...s.values()],t[15]=s,t[16]=$):$=t[16];const M=$;let L;t[17]!==a?(L=ae=>{typeof ae=="string"&&a(ae)},t[17]=a,t[18]=L):L=t[18];let D;t[19]!==R||t[20]!==i||t[21]!==g||t[22]!==T||t[23]!==A?(D=!g&&!i&&R&&r.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:T,onPointerMove:P,onPointerUp:A,onPointerCancel:A}),t[19]=R,t[20]=i,t[21]=g,t[22]=T,t[23]=A,t[24]=D):D=t[24];const F=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let z;t[25]!==F?(z=K("flex shrink-0 items-center border-b bg-card",F),t[25]=F,t[26]=z):z=t[26];const O=i?"Expand terminal panel":"Collapse terminal panel",H=!i;let W;t[27]!==i?(W=i?r.jsx(Ve,{"data-icon":"inline-start"}):r.jsx(nt,{"data-icon":"inline-start"}),t[27]=i,t[28]=W):W=t[28];const U=g&&"sr-only";let V;t[29]!==U?(V=K(U),t[29]=U,t[30]=V):V=t[30];let q;t[31]!==V?(q=r.jsx("span",{className:V,children:"Terminal"}),t[31]=V,t[32]=q):q=t[32];let X;t[33]!==c||t[34]!==O||t[35]!==H||t[36]!==W||t[37]!==q?(X=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":O,"aria-expanded":H,children:[W,q]}),t[33]=c,t[34]=O,t[35]=H,t[36]=W,t[37]=q,t[38]=X):X=t[38];const G=!g&&"ml-2";let Y;t[39]!==G?(Y=K("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",G),t[39]=G,t[40]=Y):Y=t[40];let J;t[41]!==o||t[42]!==C||t[43]!==g||t[44]!==a||t[45]!==M?(J=M.map(ae=>r.jsx(NN,{process:ae,isActive:ae.id===o,onSelectActive:()=>a(ae.id),onClose:()=>C(ae),mobile:g},ae.id)),t[41]=o,t[42]=C,t[43]=g,t[44]=a,t[45]=M,t[46]=J):J=t[46];let Q;t[47]!==Y||t[48]!==J?(Q=r.jsx(Ma,{variant:"default","aria-label":"Open processes",className:Y,children:J}),t[47]=Y,t[48]=J,t[49]=Q):Q=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(In,{})}),t[50]=d,t[51]=m,t[52]=Z):Z=t[52];let te;t[53]!==z||t[54]!==X||t[55]!==Q||t[56]!==Z?(te=r.jsxs("div",{className:z,children:[X,Q,Z]}),t[53]=z,t[54]=X,t[55]=Q,t[56]=Z,t[57]=te):te=t[57];const ne=!i,oe=g?"min(36dvh, 260px)":v;let re;t[58]!==oe?(re={height:oe},t[58]=oe,t[59]=re):re=t[59];let ie;t[60]!==g||t[61]!==p||t[62]!==m?(ie=!g&&r.jsx(xN,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ie):ie=t[63];let se;t[64]!==C||t[65]!==u||t[66]!==d||t[67]!==M?(se=M.map(ae=>r.jsx(An,{value:ae.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ae.type==="task"?r.jsx(SN,{process:ae}):r.jsx(y.Suspense,{fallback:r.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:r.jsx(jN,{processId:ae.id,autoFocus:!0,onRequestNew:d,onRequestClose:()=>C(ae),onAddContext:u})})},ae.id)),t[64]=C,t[65]=u,t[66]=d,t[67]=M,t[68]=se):se=t[68];let de;t[69]!==R||t[70]!==d||t[71]!==m?(de=!R&&r.jsxs(Gt,{className:"col-start-1 row-start-1 rounded-none",children:[r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(Ws,{})}),r.jsx(Xt,{children:"No terminal open"}),r.jsx(sn,{children:"Start a terminal here or run a project script from the left."})]}),d&&m&&r.jsx(tg,{children:r.jsxs(ee,{type:"button",size:"sm",onClick:d,children:[r.jsx(In,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=R,t[70]=d,t[71]=m,t[72]=de):de=t[72];let ce;t[73]!==se||t[74]!==de?(ce=r.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[se,de]}),t[73]=se,t[74]=de,t[75]=ce):ce=t[75];let ue;t[76]!==re||t[77]!==ie||t[78]!==ce?(ue=r.jsx(dt,{children:r.jsxs("div",{className:"flex min-h-0",style:re,children:[ie,ce]})}),t[76]=re,t[77]=ie,t[78]=ce,t[79]=ue):ue=t[79];let me;t[80]!==ne||t[81]!==ue?(me=r.jsx(ct,{open:ne,className:"min-h-0",children:ue}),t[80]=ne,t[81]=ue,t[82]=me):me=t[82];let fe;return t[83]!==o||t[84]!==L||t[85]!==D||t[86]!==te||t[87]!==me?(fe=r.jsxs(Ra,{value:o,onValueChange:L,className:"shrink-0 gap-0 border-t bg-background",children:[D,te,me]}),t[83]=o,t[84]=L,t[85]=D,t[86]=te,t[87]=me,t[88]=fe):fe=t[88],fe});function Hr(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 TN=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function EN(n){const e=new Set;for(const t of n.matchAll(TN)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function AN(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=EN(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 Im(n){var e;return((e=n.preview.split(`
|
|
6
|
+
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function PN(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=K("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(Ie,{variant:"secondary",className:"font-mono",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function ex({cwd:n,turns:e,onToggleServer:t,onServersChanged:s}){const[o,i]=y.useState([]),a=AN(e);y.useEffect(()=>{if(!n)return;let c=!1;async function d(){try{const f=await _e(`/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 _e(`/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[v,w]of a)!h[v]||x.has(v)||(x.add(v),g.push({id:`port-${v}`,outputPath:w.outputPath,ports:[v],portStatus:{[v]:!0},preview:w.description}));i(g)}}catch{}}d();const u=setInterval(d,1e4);return()=>{c=!0,clearInterval(u)}},[n,a]);const l=y.useCallback(async c=>{try{await _e("/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 y.useEffect(()=>{if(!s)return;const c=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Im(d)}));s(c)},[o,s]),o.length===0?null:r.jsxs("section",{children:[r.jsxs(Hr,{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=Im(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(A1,{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(PN,{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(Ws,{"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(pd,{"data-icon":"inline-start",className:"fill-current"}),r.jsx("span",{children:"Stop"})]})]})]},c.id)})})]})}function Ud(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(L3,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function $N(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(D3,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function IN(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(ud,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function RN(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(fd,{"data-slot":"alert-dialog-overlay",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Wd(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(RN,{}),e[4]=a):a=e[4];let l;e[5]!==t?(l=K("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(IN,{children:[a,r.jsx(dd,{"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 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=K("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 qd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("-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 MN(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 Kd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(ld,{"data-slot":"alert-dialog-title",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(cd,{"data-slot":"alert-dialog-description",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Gd(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K(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 Yd(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=K(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(Ar,{"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 tx(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=K("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(F3,{"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(lt,{})}),e[5]=i):i=e[5];let a;return e[6]!==s||e[7]!==o?(a=r.jsx(z3,{"data-slot":"checkbox",className:o,...s,children:i}),e[6]=s,e[7]=o,e[8]=a):a=e[8],a}const ON={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},LN={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 DN({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:o}){var f,m;const i=y.useRef(n),[a,l]=y.useState({key:"",selected:!1});y.useEffect(()=>{n&&(i.current=n)},[n]);const c=n??i.current;if(!c)return null;const d=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,u=a.key===d&&a.selected;return r.jsx(Ud,{open:n!==null,onOpenChange:p=>{p||o()},onOpenChangeComplete:p=>{p||(i.current=null,l({key:"",selected:!1}))},children:r.jsxs(Wd,{children:[r.jsxs(Hd,{children:[r.jsx(MN,{children:r.jsx(un,{className:"text-warning"})}),r.jsx(Kd,{children:ON[c.type]}),r.jsx(Vd,{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.":LN[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(tx,{checked:u,disabled:e,onCheckedChange:p=>l({key:d,selected:p===!0})}),"Restore captured file changes"]})]}),t&&r.jsx(ft,{variant:"destructive",children:r.jsx(mt,{children:t})}),r.jsxs(qd,{children:[r.jsx(Yd,{onClick:o,disabled:e,children:"Cancel"}),r.jsx(Gd,{onClick:()=>s(u),disabled:e,children:e?r.jsxs(r.Fragment,{children:[r.jsx(tt,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Zt(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=K("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 rn(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 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=K("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 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=K("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 nx(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 en(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 qr(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 os(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 zN=Qn("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 Sn(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=K(zN({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:FN,...s}),e[7]=i,e[8]=s,e[9]=a,e[10]=l):l=e[10],l}function FN(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const BN=Qn("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 Kr(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=K(BN({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 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=K("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(It,{"data-slot":"input-group-control",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function UN(){const[n,e]=y.useState("idle"),[t,s]=y.useState(null),o=y.useRef(void 0),i=y.useCallback(async d=>{if(!d.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await _e(`/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=y.useCallback(d=>{clearTimeout(o.current),o.current=setTimeout(()=>i(d),400)},[i]),l=y.useCallback(()=>{e("idle"),s(null),clearTimeout(o.current)},[]),c=y.useCallback(async(d,u)=>{try{const f=await _e("/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 y.useEffect(()=>()=>clearTimeout(o.current),[]),{status:n,error:t,debouncedValidate:a,validate:i,reset:l,save:c}}const ro=Qw(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),sx=Sa().filter(n=>n.cli.homeIsDiscoverable);function ox(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function rx(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 WN=ox(sx.map(n=>n.displayName)),HN=ox(sx.map(n=>r.jsx(rx,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),qN=`~/${ro.cli.homeDirName}`;function KN(n){const e=B.c(46),{onConfigured:t}=n,[s,o]=y.useState(""),[i,a]=y.useState(!1),{status:l,error:c,debouncedValidate:d,save:u}=UN();let f;e[0]!==d?(f=D=>{const F=D.target.value;o(F),d(F)},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,v;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(md,{className:"size-4"})}),v=r.jsx(an,{children:"Connect your coding agent"}),e[10]=x,e[11]=v):(x=e[10],v=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsxs(rn,{children:[x,v,r.jsxs(ln,{children:["Cogpit detects ",WN," automatically. Existing histories live in"," ",HN,"."," ","For ",ro.displayName,", enter its data directory, usually"," ",r.jsx(rx,{children:qN}),"."]})]}),e[12]=w):w=e[12];const b=l==="invalid";let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsxs(yt,{htmlFor:"agent-data-directory",children:[ro.displayName," data directory"]}),e[13]=j):j=e[13];let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Sn,{children:r.jsx(bo,{"aria-hidden":"true"})}),e[14]=S):S=e[14];const N=l==="invalid";let C;e[15]!==m||e[16]!==s||e[17]!==N?(C=r.jsxs(os,{children:[S,r.jsx(rs,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${ro.cli.homeDirName}`,autoFocus:!0,"aria-invalid":N,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=N,e[18]=C):C=e[18];let k;e[19]!==l?(k=l==="validating"&&r.jsxs(yo,{className:"flex items-center gap-2",children:[r.jsx(Ze,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=k):k=e[20];let T;e[21]!==l?(T=l==="valid"&&r.jsxs(yo,{className:"flex items-center gap-2 text-success",children:[r.jsx(Pr,{className:"size-4"}),ro.displayName," history found"]}),e[21]=l,e[22]=T):T=e[22];let E;e[23]!==c||e[24]!==l?(E=l==="invalid"&&c&&r.jsxs(ps,{className:"flex items-center gap-2",children:[r.jsx(Hs,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=E):E=e[25];let P;e[26]!==k||e[27]!==T||e[28]!==E?(P=r.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[k,T,E]}),e[26]=k,e[27]=T,e[28]=E,e[29]=P):P=e[29];let _;e[30]!==C||e[31]!==P||e[32]!==b?(_=r.jsx(en,{children:r.jsx(To,{children:r.jsxs(vt,{"data-invalid":b,children:[j,C,P]})})}),e[30]=C,e[31]=P,e[32]=b,e[33]=_):_=e[33];const A=l!=="valid"||i;let I;e[34]!==i?(I=i&&r.jsx(Ze,{"data-icon":"inline-start"}),e[34]=i,e[35]=I):I=e[35];const R=i?"Saving...":`Connect ${ro.displayName}`;let $;e[36]!==A||e[37]!==I||e[38]!==R?($=r.jsx(qr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:A,children:[I,R]})}),e[36]=A,e[37]=I,e[38]=R,e[39]=$):$=e[39];let M;e[40]!==_||e[41]!==$?(M=r.jsxs(Zt,{children:[w,_,$]}),e[40]=_,e[41]=$,e[42]=M):M=e[42];let L;return e[43]!==M||e[44]!==g?(L=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]=L):L=e[45],L}const ix=/^[a-z]:[\\/]/i;function Xd(n){return(ix.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function Rm(n){const e=Xd(n);return ix.test(n)?e.toLowerCase():e}function VN(n){const e=Xd(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function Mm(n,e){const t=Rm(n),s=Rm(e);if(t===s)return"";const o=t==="/"?"/":`${t}/`;return s.startsWith(o)?Xd(e).slice(o.length):null}let Jd=!1;function GN(n){Jd=n}function Qd(){return Jd}let nr=null;function YN(n){return nr=n,()=>{nr===n&&(nr=null)}}function XN(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const o=Mm(e,n.path);if(o)return{root:e,file:o,mode:Om(n),line:n.line}}const t=VN(n.path),s=Mm(t,n.path);return s?{root:t,file:s,mode:Om(n),line:n.line}:null}function Om(n){return n.mode==="diff"?"diff":"edit"}function ax(n){return Jd&&nr!==null&&nr(n)}function lx(n,e){Dn(n,e).catch(()=>{})}function gr(n,e={}){if(et("hostFiles")&&!ax({kind:"file",path:n,...e})){if(Ds()){Na(n);return}lx("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function cx(n){et("hostFiles")&&(n.path&&ax({kind:"project",path:n.path})||ux("/api/open-in-editor",n))}function dx(n){et("hostFiles")&&ux("/api/reveal-in-folder",n)}function ux(n,e){!e.path&&!e.dirName||lx(n,{path:e.path||void 0,dirName:e.dirName||void 0})}const JN=1500;function Xn(){const n=B.c(5),[e,t]=y.useState(!1),s=y.useRef(null),o=y.useRef(!0);let i,a;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>(o.current=!0,()=>{o.current=!1,s.current&&clearTimeout(s.current)}),a=[],n[0]=i,n[1]=a):(i=n[0],a=n[1]),y.useEffect(i,a);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async u=>{!await Na(u)||!o.current||(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),JN))},n[2]=l):l=n[2];const c=l;let d;return n[3]!==e?(d=[e,c],n[3]=e,n[4]=d):d=n[4],d}function Vr(){const n=B.c(2),[e,t]=y.useState(QN);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=document.documentElement,a=()=>t(i.classList.contains("dark")),l=new MutationObserver(a);return l.observe(i,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),y.useEffect(s,o),e}function QN(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}let _l=null;const Ic=new Set,ki=new Map,Lm=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],fx={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 mx(){return _l||(_l=(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),...Lm.map(o=>fx[o]().then(i=>i.default))]),s=await Uw({themes:[n,e],langs:t,engine:Ww()});for(const o of Lm)Ic.add(o);return s})()),_l}async function px(n,e){if(Ic.has(e))return;if(ki.has(e))return ki.get(e);const t=fx[e];if(!t)return;const s=t().then(async o=>{await n.loadLanguage(o.default),Ic.add(e)}).finally(()=>ki.delete(e));ki.set(e,s),await s}const ZN={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 hx(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return ZN[e]??null}async function ek(n,e,t){try{const s=await mx();await px(s,e);const o=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:o}).tokens}catch{return null}}const tk="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted/30 p-2 font-mono text-xs leading-relaxed text-muted-foreground",gx="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] border-l border-border pl-3 font-mono text-xs leading-relaxed text-muted-foreground";function Oa(n,e,t){const s=B.c(5),[o,i]=y.useState(null);let a,l;return s[0]!==n||s[1]!==t||s[2]!==e?(a=()=>{if(!e)return;let c=!1;return ek(n,e,t).then(d=>{c||i({code:n,lang:e,isDark:t,tokens:d})}).catch(nk),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=a,s[4]=l):(a=s[3],l=s[4]),y.useEffect(a,l),(o==null?void 0:o.code)===n&&o.lang===e&&o.isDark===t?o.tokens:null}function nk(){}function Zd(n){const e=B.c(13),{lines:t,tokens:s,lineNums:o,variant:i,label:a}=n,l=i==="boxed"?tk:gx;let c;if(e[0]!==o||e[1]!==t||e[2]!==s){let f;e[4]!==o||e[5]!==s?(f=(m,p)=>{const h=s==null?void 0:s[p];return r.jsxs("span",{className:"block",children:[(o==null?void 0:o[p])&&r.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground/30 select-none",children:o[p]}),h?h.map(sk):m||" "]},p)},e[4]=o,e[5]=s,e[6]=f):f=e[6],c=t.map(f),e[0]=o,e[1]=t,e[2]=s,e[3]=c}else c=e[3];let d;e[7]!==a||e[8]!==c?(d=r.jsx("code",{className:"block","aria-label":a,children:c}),e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==l||e[11]!==d?(u=r.jsx("pre",{tabIndex:0,className:l,children:d}),e[10]=l,e[11]=d,e[12]=u):u=e[12],u}function sk(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}function xx(n){const e=B.c(6),{code:t,language:s,label:o}=n,i=Vr(),a=Oa(t,s,i);let l;e[0]!==t?(l=xr(t),e[0]=t,e[1]=l):l=e[1];const c=l;let d;return e[2]!==o||e[3]!==c||e[4]!==a?(d=r.jsx(Zd,{lines:c,tokens:a,variant:"unboxed",label:o}),e[2]=o,e[3]=c,e[4]=a,e[5]=d):d=e[5],d}const ok=/^(\s*\d+)→(.*)$/;function xr(n){return n.split(/\r\n|\r|\n/)}function rk(n){const e=[],t=[];for(const s of xr(n)){const o=s.match(ok);o?(e.push(o[1]),t.push(o[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function bx(n){const e=B.c(11),{result:t,filePath:s,variant:o}=n,i=o===void 0?"boxed":o,a=Vr();let l;e[0]!==s?(l=hx(s),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==t?(d=rk(t),e[2]=t,e[3]=d):d=e[3];const{lineNums:u,codeLines:f}=d;let m;e[4]!==f?(m=f.join(`
|
|
7
|
+
`),e[4]=f,e[5]=m):m=e[5];const h=Oa(m,c,a);let g;return e[6]!==f||e[7]!==u||e[8]!==h||e[9]!==i?(g=r.jsx(Zd,{lines:f,tokens:h,lineNums:u,variant:i}),e[6]=f,e[7]=u,e[8]=h,e[9]=i,e[10]=g):g=e[10],g}function vx(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 yx(n){const e=B.c(9),{result:t,alreadyPretty:s,variant:o}=n,i=o===void 0?"boxed":o,a=Vr();let l;e[0]!==s||e[1]!==t?(l=s?t:vx(t)??t,e[0]=s,e[1]=t,e[2]=l):l=e[2];const c=l;let d;e[3]!==c?(d=xr(c),e[3]=c,e[4]=d):d=e[4];const u=d,f=Oa(c,"json",a);let m;return e[5]!==u||e[6]!==f||e[7]!==i?(m=r.jsx(Zd,{lines:u,tokens:f,variant:i}),e[5]=u,e[6]=f,e[7]=i,e[8]=m):m=e[8],m}function ik(n){const e=xr(n),t=e.slice(0,8).join(`
|
|
8
|
+
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-xr(s).length),truncated:e.length>8||t.length>1e3}}function ak(n){const e=B.c(36),{result:t,isError:s,filePath:o}=n,i=s===void 0?!1:s,[a,l]=y.useState(!1),[c,d]=Xn(),u=y.useId();let f;e[0]!==o||e[1]!==i||e[2]!==t?(f=!i&&!o?vx(t):null,e[0]=o,e[1]=i,e[2]=t,e[3]=f):f=e[3];const m=f,p=m??t;let h;e[4]!==p?(h=ik(p),e[4]=p,e[5]=h):h=e[5];const g=h,x=a?p:g.text,v=i&&"text-destructive";let w;e[6]!==v?(w=K("text-xs text-muted-foreground",v),e[6]=v,e[7]=w):w=e[7];const b=i?"Error":"Result";let j;e[8]!==w||e[9]!==b?(j=r.jsx("span",{className:w,children:b}),e[8]=w,e[9]=b,e[10]=j):j=e[10];let S;e[11]!==c||e[12]!==d||e[13]!==t?(S=t.trim()&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":c?"Result copied":"Copy result",children:c?r.jsx(lt,{"data-icon":"icon"}):r.jsx(fn,{"data-icon":"icon"})}),e[11]=c,e[12]=d,e[13]=t,e[14]=S):S=e[14];let N;e[15]!==j||e[16]!==S?(N=r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[j,S]}),e[15]=j,e[16]=S,e[17]=N):N=e[17];let C;e[18]!==o||e[19]!==i||e[20]!==m||e[21]!==t||e[22]!==x?(C=t.trim()?o&&!i?r.jsx(bx,{result:x,filePath:o,variant:"unboxed"}):m!==null?r.jsx(yx,{result:x,alreadyPretty:!0,variant:"unboxed"}):r.jsx("pre",{tabIndex:0,className:K(gx,i&&"border-destructive/30 text-destructive"),children:x}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=o,e[19]=i,e[20]=m,e[21]=t,e[22]=x,e[23]=C):C=e[23];let k;e[24]!==u||e[25]!==C?(k=r.jsx("div",{id:u,children:C}),e[24]=u,e[25]=C,e[26]=k):k=e[26];let T;e[27]!==a||e[28]!==g.hiddenLines||e[29]!==g.truncated||e[30]!==u?(T=g.truncated&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>l(lk),"aria-expanded":a,"aria-controls":u,children:a?"Show less":g.hiddenLines>0?`+${g.hiddenLines} ${g.hiddenLines===1?"line":"lines"}`:"Show more"}),e[27]=a,e[28]=g.hiddenLines,e[29]=g.truncated,e[30]=u,e[31]=T):T=e[31];let E;return e[32]!==k||e[33]!==T||e[34]!==N?(E=r.jsxs("section",{className:"mt-1.5 min-w-0","aria-label":"Result",children:[N,k,T]}),e[32]=k,e[33]=T,e[34]=N,e[35]=E):E=e[35],E}function lk(n){return!n}const ck={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 dk(n){return ck[n.toLowerCase()]??n}function uk(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function fk(n){const e=B.c(9),{text:t}=n,[s,o]=Xn();let i;e[0]!==o||e[1]!==t?(i=()=>o(t),e[0]=o,e[1]=t,e[2]=i):i=e[2];const a=s?"Copied":"Copy code";let l;e[3]!==s?(l=s?r.jsxs(r.Fragment,{children:[r.jsx(lt,{className:"text-success","data-icon":"inline-start"}),r.jsx("span",{className:"text-success",children:"Copied"})]}):r.jsx(fn,{"data-icon":"icon"}),e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==a||e[7]!==l?(c=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:i,className:"text-muted-foreground",title:"Copy code","aria-label":a,children:l}),e[5]=i,e[6]=a,e[7]=l,e[8]=c):c=e[8],c}function mk(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 pk(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(`
|
|
9
|
+
`);let a;e[4]!==s?(a=uk(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(hk,{code:u,lang:l,...o}),e[12]=u,e[13]=l,e[14]=o,e[15]=f):f=e[15],f}function hk(n){const e=B.c(39);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=Oa(t,s,i),[l,c]=y.useState(!1);let d,u,f,m;if(e[4]!==t||e[5]!==l||e[6]!==s||e[7]!==o||e[8]!==a){const g=t.split(`
|
|
10
|
+
`);d=g.length;const x=d>30,v=l?Ve:nt;u="my-3 overflow-hidden rounded-lg border border-border bg-muted/20";let w;e[13]!==v||e[14]!==l||e[15]!==x?(w=x&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>c(!l),className:"text-muted-foreground","aria-label":l?"Expand code":"Collapse code",children:r.jsx(v,{"data-icon":"icon"})}),e[13]=v,e[14]=l,e[15]=x,e[16]=w):w=e[16];let b;e[17]!==s?(b=s&&r.jsx(Ie,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:dk(s)}),e[17]=s,e[18]=b):b=e[18];let j;e[19]!==x||e[20]!==d?(j=x&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d," lines"]}),e[19]=x,e[20]=d,e[21]=j):j=e[21];let S;e[22]!==w||e[23]!==b||e[24]!==j?(S=r.jsxs("div",{className:"flex items-center gap-2",children:[w,b,j]}),e[22]=w,e[23]=b,e[24]=j,e[25]=S):S=e[25];let N;e[26]!==t?(N=r.jsx(fk,{text:t}),e[26]=t,e[27]=N):N=e[27],e[28]!==S||e[29]!==N?(f=r.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/40 px-3 py-1.5",children:[S,N]}),e[28]=S,e[29]=N,e[30]=f):f=e[30],m=!l&&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:K("block",!a&&"text-foreground/90"),...o,children:g.map((C,k)=>{const T=a==null?void 0:a[k];return r.jsxs("span",{className:"block",children:[r.jsx(mk,{num:k+1}),T?T.map(gk):C||" "]},k)})})})}),e[4]=t,e[5]=l,e[6]=s,e[7]=o,e[8]=a,e[9]=d,e[10]=u,e[11]=f,e[12]=m}else d=e[9],u=e[10],f=e[11],m=e[12];let p;e[31]!==l||e[32]!==d?(p=l&&r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),className:"h-auto w-full justify-start rounded-none px-3 py-2 text-xs text-muted-foreground","aria-label":`Expand ${d} lines of code`,children:["Show ",d," lines..."]}),e[31]=l,e[32]=d,e[33]=p):p=e[33];let h;return e[34]!==u||e[35]!==f||e[36]!==m||e[37]!==p?(h=r.jsxs("div",{className:u,children:[f,m,p]}),e[34]=u,e[35]=f,e[36]=m,e[37]=p,e[38]=h):h=e[38],h}function gk(n,e){return r.jsx("span",{style:{color:n.color},children:n.content},e)}var Is=function(n,e){return Number(n.toFixed(e))},xk=function(n,e){return e},Xe=function(n,e,t){t&&typeof t=="function"&&t(n,e)},bk=function(n){return-Math.cos(n*Math.PI)/2+.5},vk=function(n){return n},yk=function(n){return n*n},wk=function(n){return n*(2-n)},jk=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},Sk=function(n){return n*n*n},Nk=function(n){return--n*n*n+1},kk=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},Ck=function(n){return n*n*n*n},_k=function(n){return 1- --n*n*n*n},Tk=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},Ek=function(n){return n*n*n*n*n},Ak=function(n){return 1+--n*n*n*n*n},Pk=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},wx={easeOut:bk,linear:vk,easeInQuad:yk,easeOutQuad:wk,easeInOutQuad:jk,easeInCubic:Sk,easeOutCubic:Nk,easeInOutCubic:kk,easeInQuart:Ck,easeOutQuart:_k,easeInOutQuart:Tk,easeInQuint:Ek,easeOutQuint:Ak,easeInOutQuint:Pk},jx=function(n){typeof n=="number"&&cancelAnimationFrame(n)},hn=function(n){n.mounted&&(jx(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function Sx(n,e,t,s){if(n.mounted){var o=new Date().getTime(),i=1;hn(n),n.animation=function(){if(!n.mounted)return jx(n.animation);var a=new Date().getTime()-o,l=a/t,c=wx[e],d=c(l);a>=t?(s(i),n.animation=null):n.animation&&(s(d),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function $k(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function Ts(n,e,t,s){var o=$k(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):Sx(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 Ik(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 Rk=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}},eu=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=Ik(t,s,e),c=l.wrapperWidth,d=l.wrapperHeight,u=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=Rk(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,v=x.minPositionX,w=x.maxPositionX,b=x.minPositionY,j=x.maxPositionY;return v!=null&&(h.minPositionX=c*(1-e)+v*e),w!=null&&(h.maxPositionX=w*e),b!=null&&(h.minPositionY=d*(1-e)+b*e),j!=null&&(h.maxPositionY=j*e),h},br=function(n,e,t,s){return s?n<e?Is(e,2):n>t?Is(t,2):Is(n,2):Is(n,2)},wo=function(n,e){var t=eu(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 La(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 Dm=1e-7;function Yr(n,e,t,s,o){var i=o?s:0,a=Math.max(e-i,Dm),l=t+i;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=a?a:Math.max(n,Dm)}var zm=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)},Fm=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,o=s.panning.disabled,i=e&&t&&!o;return!!i},Mk=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}},Ok=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 Lk(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,v=t>f?d.offsetWidth:n.setup.minPositionX||0,w=s>p?d.offsetHeight:n.setup.minPositionY||0,b=La(n,v,w,o,n.bounds,l||c),j=b.x,S=b.y;return{scale:o,positionX:g?j:t,positionY:x?S:s}}}function Nx(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 Dk=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}},Ns=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},ds;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(ds||(ds={}));var zk=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},Fk=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 Bk(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 Bm(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 Uk(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Tl=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 Wk(n,e,t){var s,o,i=zk(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=Uk(d),v=(s={},s[ds.TOUCH]=p,s[ds.MOUSE]=h,s)[t],w=(o={},o[ds.TOUCH]=m,o[ds.MOUSE]=f,o)[t],b=e.x-a.x,j=e.y-a.y,S=Tl(b/x,w,v),N=Tl(j/x,w,v),C=g-l,k=b*b+j*j,T=Tl(Math.sqrt(k)/C,w,v);n.velocity={velocityX:S,velocityY:N,total:T}}n.lastMousePosition=e,n.velocityTime=g}}function Hk(n){var e=n.velocity,t=n.bounds,s=n.setup,o=n.wrapperComponent,i=Fk(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,v=x.lockAxisY,w=x.lockAxisX,b=g.animationType,j=h.sizeX,S=h.sizeY,N=h.velocityAlignmentTime,C=N,k=Bk(n,c),T=Math.max(k,C),E=Ns(n,j),P=Ns(n,S),_=E*o.offsetWidth/100,A=P*o.offsetHeight/100,I=d+_,R=u-_,$=f+A,M=m-A,L=n.state,D=new Date().getTime();Sx(n,b,T,function(F){var z=n.state,O=z.scale,H=z.positionX,W=z.positionY,U=new Date().getTime()-D,V=U/C,q=wx[h.animationType],X=1-q(Math.min(1,V)),G=1-F,Y=H+a*G,J=W+l*G,Q=Bm(Y,L.positionX,H,w,p,u,d,R,I,X),Z=Bm(J,L.positionY,W,v,p,m,f,M,$,X);if(H!==Y||W!==J){n.setState(O,Q,Z);var te=n.props.onPanning;te&&te(Ge(n),{})}})}}function Um(n,e){var t=n.state,s=t.scale,o=t.positionX,i=t.positionY;n.panStartPosition={x:o,y:i},hn(n),wo(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?Ok(n,e):Mk(n,e)}function kx(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=Lk(n);m&&Ts(n,m,d,u)}}function Wm(n,e,t,s){var o=n.startCoords,i=n.setup,a=i.autoAlignment,l=a.sizeX,c=a.sizeY;if(o){var d=Dk(n,e,t),u=d.x,f=d.y,m=Ns(n,l),p=Ns(n,c);Wk(n,{x:u,y:f},s),Nx(n,u,f,m,p)}}function qk(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,v=!e&&t&&t.total>.1&&x;v?Hk(n):kx(n)}}function tu(n,e,t,s){var o=n.setup,i=o.minScale,a=o.maxScale,l=o.limitToBounds,c=Yr(Is(e,2),i,a,0,!1),d=wo(n,c),u=La(n,t,s,c,d,l),f=u.x,m=u.y;return{scale:c,positionX:f,positionY:m}}function nu(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)&&kx(n),!(h||!o||!n.mounted)){var g=e||o.offsetWidth/2,x=t||o.offsetHeight/2,v=s<a?a:l,w=tu(n,v,g,x);w&&Ts(n,w,f,m)}}var dn=function(){return dn=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},dn.apply(this,arguments)};function Hm(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 El={scale:1,positionX:0,positionY:0},$s={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"}},Rc={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Cx=function(n){var e,t,s,o,i,a,l,c,d,u=Math.max((e=n.minScale)!==null&&e!==void 0?e:$s.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:$s.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:El.scale,p=Math.min(Math.max(m,u),f),h=br((o=n.initialPositionX)!==null&&o!==void 0?o:El.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:El.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}},qm=function(n){var e=dn({},$s);return Object.keys(n).forEach(function(t){var s=t,o=typeof n[s]<"u",i=typeof $s[s]<"u";if(i&&o){var a=Object.prototype.toString.call($s[s]),l=a==="[object Object]",c=a==="[object Array]";l?e[s]=dn(dn({},$s[s]),n[s]):c?e[s]=Hm(Hm([],$s[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},_x=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(Is(f,3),l,a,u,!1);return m};function Tx(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,v=(g/2-f)/d,w=_x(n,e,t),b=tu(n,w,x,v);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,S=j.onZoomStart,N=j.onZoom,C=j.onZoomStop,k=new MouseEvent("mousemove",{bubbles:!0}),T=Ge(n);Xe(T,k,S),Xe(T,k,N),Ts(n,b,p,o);var E=(a=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&a!==void 0?a:typeof window<"u"?window:null;E&&E.setTimeout(function(){n.mounted&&Xe(Ge(n),k,C)},p)}function Ex(n,e,t,s){var o,i,a=n.setup,l=n.wrapperComponent,c=n.contentComponent,d=a.limitToBounds,u=a.centerOnInit,f=Cx(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,v=f.positionY;if(u&&c){var w=su(f.scale,l,c);x=w.positionX,v=w.positionY}var b=eu(n,f.scale),j=Gr(x,v,b,d,0,0,l),S={scale:f.scale,positionX:j.x,positionY:j.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var N=n.props,C=N.onZoomStart,k=N.onZoom,T=N.onZoomStop,E=new MouseEvent("mousemove",{bubbles:!0}),P=Ge(n);Xe(P,E,C),Xe(P,E,k),Ts(n,S,e,t);var _=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;_&&_.setTimeout(function(){n.mounted&&Xe(Ge(n),E,T)},e)}}}function Kk(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 Vk(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=Kk(e,i,a,l),g=h.x,x=h.y,v=p.width/l.scale,w=p.height/l.scale,b=i.offsetWidth/v,j=i.offsetHeight/w,S=Yr(t||Math.min(b,j),u,f,0,!1),N=(m.width-v*S)/2,C=(m.height-w*S)/2,k=(m.left-g)*S+N+s,T=(m.top-x)*S+C+o,E=eu(n,S),P=Gr(k,T,E,d,0,0,i),_=P.x,A=P.y;return{positionX:_,positionY:A,scale:S}}var Gk=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Tx(n,1,e,t,s)}},Yk=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),Tx(n,-1,e,t,s)}},Xk=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};Ts(n,p,o,i)}}},Jk=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),Ex(n,e,t)}},Qk=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=su(e||o.scale,i,a);Ts(n,l,t,s)}}},Zk=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),hn(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var d=Vk(n,c,t,i,a);Ts(n,d,s,o)}}},Mc=function(n){return{instance:n,state:n.state,zoomIn:Gk(n),zoomOut:Yk(n),setTransform:Xk(n),resetTransform:Jk(n),centerView:Qk(n),zoomToElement:Zk(n)}},e6=function(n){return{instance:n,state:n.state}},Ge=function(n){var e={};return Object.assign(e,e6(n)),Object.assign(e,Mc(n)),e},Al=!1;function Pl(){try{var n={get passive(){return Al=!0,!1}};return n}catch{return Al=!1,Al}}var Ci=".".concat(Rc.wrapperClass),Xr=function(n,e){return e.some(function(t){return n.matches("".concat(Ci," ").concat(t,", ").concat(Ci," .").concat(t,", ").concat(Ci," ").concat(t," *, ").concat(Ci," .").concat(t," *"))})},vr=function(n){n&&clearTimeout(n)},t6=function(n){return Number.parseFloat(n.toFixed(8))},Ax=function(n,e,t){var s=t6(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},su=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 n6(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function s6(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var Px=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},o6=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=Px(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},r6=function(n){return n?n.deltaY<0?1:-1:0};function i6(n,e){var t=r6(n),s=xk(e,t);return s}function $x(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 a6=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},Ix=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},l6=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},c6=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,o=t&&!e&&s!==null;return!!o},d6=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}},Rx=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))},u6=5,f6=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/u6),x=t+g,v=x===1/0?0:Is(x,10);return Yr(v,a,i,u,!f&&!c)},Mx=160,Ox=100,m6=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onZoomStart;n.wheelStopEventTimer||(hn(n),Xe(Ge(n),e,s),Xe(Ge(n),e,o))},p6=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,v=m.step;if(!i)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=i6(e,null),b=h?v*Math.abs(e.deltaY):v,j=a6(n,w,b,!e.ctrlKey);if(c!==j){var S=wo(n,j),N=$x(e,i,c),C=x||g===0||u||p,k=d&&C,T=La(n,N.x,N.y,j,S,k),E=T.x,P=T.y;n.previousWheelEvent=e,n.setState(j,E,P),Xe(Ge(n),e,s),Xe(Ge(n),e,o)}},h6=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onZoomStop;vr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(nu(n,e.x,e.y),n.wheelAnimationTimer=null)},Ox);var i=Ix(n,e);i&&(vr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Xe(Ge(n),e,s),Xe(Ge(n),e,o))},Mx))},g6=function(n,e){var t=n.props,s=t.onWheelStart,o=t.onPanningStart;n.wheelStopEventTimer||(hn(n),Xe(Ge(n),e,s),Xe(Ge(n),e,o))},x6=function(n,e){var t=n.props,s=t.onWheelStop,o=t.onPanningStop;vr(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(nu(n,e.x,e.y),n.wheelAnimationTimer=null)},Ox);var i=Ix(n,e);i&&(vr(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,Xe(Ge(n),e,s),Xe(Ge(n),e,o))},Mx))},Lx=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}},b6=function(n,e){var t=Rx(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=Lx(e),hn(n)},v6=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 v=d6(e,a,t);if(!(!Number.isFinite(v.x)||!Number.isFinite(v.y))){var w=Rx(e),b=f6(n,w),j=Lx(e),S=a/b,N=(j.x-((i==null?void 0:i.x)||0))*S,C=(j.y-((i==null?void 0:i.y)||0))*S;if(!(b===a&&N===0&&C===0)){n.pinchPreviousCenter=j;var k=wo(n,b),T=h||g===0||d,E=c&&T,P=La(n,v.x,v.y,b,k,E),_=P.x,A=P.y;if(n.pinchMidpoint=v,n.lastDistance=w,p.disabled||!x)n.setState(b,_,A);else{var I=f.sizeX,R=f.sizeY,$=Ns(n,I,b),M=Ns(n,R,b),L=_+N,D=A+C,F=Gr(L,D,k,c,$,M,o),z=F.x,O=F.y;n.setState(b,z,O)}}}}},y6=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,nu(n,e==null?void 0:e.x,e==null?void 0:e.y)},Dx=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;vr(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,Xe(Ge(n),e,t)},s)},w6=function(n,e){var t=n.props,s=t.onZoomStart,o=t.onZoom,i=n.setup.doubleClick,a=i.animationTime,l=i.animationType;Xe(Ge(n),e,s),Ex(n,a,l,function(){return Xe(Ge(n),e,o)}),Dx(n,e)};function j6(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function S6(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 w6(n,e);if(!i)return console.error("No ContentComponent found");var x=j6(m,n.state.scale),v=_x(n,x,p);if(a!==v){Xe(Ge(n),e,c);var w=$x(e,i,a),b=tu(n,v,w.x,w.y);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");Xe(Ge(n),e,d),Ts(n,b,h,g),Dx(n,e)}}}var N6=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},k6=(function(){function n(e){var t=this;this.mounted=!0,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.onTransformCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.panStartPosition=null,this.lastTouch=null,this.isPinching=!1,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.pinchPreviousCenter=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.isAnimating=!1,this.animation=null,this.pressedKeys={},this.mount=function(){t.initializeWindowEvents()},this.unmount=function(){t.cleanupWindowEvents()},this.update=function(s){t.props=s,t.wrapperComponent&&t.contentComponent&&wo(t,t.state.scale),t.setup=qm(s)},this.initializeWindowEvents=function(){var s,o,i,a,l=Pl(),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=Pl(),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),hn(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var o=Pl();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(Ge(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(Ge(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=Px(t,s);i&&(m6(t,s),p6(t,s),h6(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=o6(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,v=x.sizeX,w=x.sizeY,b=Ns(t,v),j=Ns(t,w);h===u&&g===f||(g6(t,s),Nx(t,h,g,b,j),Xe(Ge(t),s,o),x6(t,s))}},this.onPanningStart=function(s){var o=t.setup.disabled,i=t.props.onPanningStart;if(!o){t.syncModifierKeys(s);var a=zm(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(),hn(t),Um(t,s),Xe(Ge(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=Fm(t);if(a){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Wm(t,s.clientX,s.clientY,ds.MOUSE),Xe(Ge(t),s,i))}}},this.onPanningStop=function(s){var o=t.setup.panning.velocityDisabled,i=t.props.onPanningStop;t.isPanning&&(qk(t,o),Xe(Ge(t),s,i))},this.onPinchStart=function(s){var o=t.setup.disabled,i=t.props.onPinchStart;if(!o){var a=l6(t,s);a&&(b6(t,s),hn(t),Xe(Ge(t),s,i))}},this.onPinch=function(s){var o=t.setup.disabled,i=t.props.onPinch;if(!o){var a=c6(t);a&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),v6(t,s),Xe(Ge(t),s,i))}},this.onPinchStop=function(s){var o=t.props.onPinchStop;t.pinchStartScale&&(y6(t),Xe(Ge(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,hn(t);var u=s.touches,f=u.length===1,m=u.length===2,p=zm(t,s);if(f){if(!p)return;hn(t),Um(t,s),Xe(Ge(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=Fm(t);if(!a)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Wm(t,l.clientX,l.clientY,ds.TOUCH),Xe(Ge(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=N6(t,s);i&&S6(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=su(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):Ax(s,o,i)},this.getContext=function(){return Ge(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:Ge(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=Ge(t);t.onChangeCallbacks.forEach(function(d){return d(c)}),Xe(c,{scale:t.state.scale,positionX:o,positionY:i},a)}else console.error("Detected NaN set state values")},this.onTransform=function(s){return t.onTransformCallbacks.has(s)||t.onTransformCallbacks.add(s),function(){t.onTransformCallbacks.delete(s)}},this.onChange=function(s){return t.onChangeCallbacks.has(s)||t.onChangeCallbacks.add(s),function(){t.onChangeCallbacks.delete(s)}},this.onInit=function(s){return t.onInitCallbacks.has(s)||t.onInitCallbacks.add(s),function(){t.onInitCallbacks.delete(s)}},this.init=function(s,o){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=o,wo(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(o),t.initializeWindowEvents(),t.isInitialized=!0;var i=Ge(t);Xe(i,void 0,t.props.onInit),n6(t.props.ref,i)},this.props=e,this.setup=qm(this.props),this.state=Cx(this.props)}return n})(),Da=je.createContext(null),C6=function(n,e){return typeof n=="function"?n(e):n},_6=je.forwardRef(function(n,e){var t=y.useRef(new k6(n)).current,s=C6(n.children,Mc(t));return y.useImperativeHandle(e,function(){return Mc(t)},[t]),y.useEffect(function(){t.update(n)},[t,n]),r.jsx(Da.Provider,dn({value:t},{children:s}))});je.forwardRef(function(n,e){var t=y.useRef(null),s=y.useContext(Da);return y.useEffect(function(){return s.onChange(function(o){if(t.current){var i=0,a=0;t.current.style.transform=s.handleTransformStyles(i,a,1/o.instance.state.scale)}})},[s]),r.jsx("div",dn({},n,{ref:s6([t,e])}))});function T6(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 E6=`.transform-component-module_wrapper__SPB86 {
|
|
11
|
+
position: relative;
|
|
12
|
+
width: -moz-fit-content;
|
|
13
|
+
width: fit-content;
|
|
14
|
+
height: -moz-fit-content;
|
|
15
|
+
height: fit-content;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
18
|
+
-webkit-user-select: none; /* Safari */
|
|
19
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
20
|
+
-moz-user-select: none; /* Firefox */
|
|
21
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
22
|
+
user-select: none;
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
transform: translate3d(0, 0, 0);
|
|
26
|
+
}
|
|
27
|
+
.transform-component-module_content__FBWxo {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
width: -moz-fit-content;
|
|
31
|
+
width: fit-content;
|
|
32
|
+
height: -moz-fit-content;
|
|
33
|
+
height: fit-content;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
transform-origin: 0% 0%;
|
|
37
|
+
}
|
|
38
|
+
.transform-component-module_content__FBWxo img {
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
}
|
|
41
|
+
.transform-component-module_infiniteGrid__Z-aP3 {
|
|
42
|
+
position: absolute;
|
|
43
|
+
inset: 0;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
background-image: radial-gradient(
|
|
46
|
+
circle,
|
|
47
|
+
rgba(0, 0, 0, 0.12) 1px,
|
|
48
|
+
transparent 1px
|
|
49
|
+
);
|
|
50
|
+
background-size: 20px 20px;
|
|
51
|
+
background-position: 0 0;
|
|
52
|
+
}
|
|
53
|
+
`,$l={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};T6(E6);var A6=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=y.useContext(Da),g=h.init,x=h.cleanupWindowEvents,v=y.useRef(null),w=y.useRef(null),b=y.useRef(null);return y.useEffect(function(){var j=v.current,S=w.current;return j!==null&&S!==null&&g&&(g==null||g(j,S)),function(){x==null||x()}},[]),y.useEffect(function(){if(p){var j=b.current;if(j){var S=function(){var N=h.state,C=N.positionX,k=N.positionY;j.style.backgroundPosition="".concat(C,"px ").concat(k,"px")};return S(),h.onChange(S)}}},[p,h]),r.jsxs("div",dn({},d,{ref:v,className:"".concat(Rc.wrapperClass," ").concat($l.wrapper," ").concat(s),style:a},{children:[p&&r.jsx("div",{ref:b,className:$l.infiniteGrid,"aria-hidden":!0}),r.jsx("div",dn({},f,{ref:w,className:"".concat(Rc.contentClass," ").concat($l.content," ").concat(i),style:dn(dn({},l),{transform:Ax(h.state.positionX,h.state.positionY,h.state.scale)})},{children:e}))]}))};function P6(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 $6(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,v=g.y<h.y+h.height&&g.y+g.height>h.y;return x&&v}var w=g.width*g.height;if(w<=0)return!1;var b=P6(h,g);return b/w>=p}je.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,v=y.useContext(Da),w=y.useState(!1),b=w[0],j=w[1],S=y.useRef(!1),N=y.useRef(m),C=y.useRef(p);return N.current=m,C.current=p,y.useEffect(function(){var k=function(){var P,_,A=v.wrapperComponent;if(A){var I=$6({elementX:t,elementY:s,elementWidth:o,elementHeight:i,scale:v.state.scale,positionX:v.state.positionX,positionY:v.state.positionY,viewportWidth:A.offsetWidth,viewportHeight:A.offsetHeight,margin:l,threshold:d});I!==S.current&&(S.current=I,j(I),I?(P=N.current)===null||P===void 0||P.call(N):(_=C.current)===null||_===void 0||_.call(C))}};k();var T=v.onChange(k),E;return v.wrapperComponent||(E=v.onInit(function(){return k()})),function(){T(),E==null||E()}},[v,t,s,o,i,l,d]),b?r.jsx("div",dn({ref:e,className:g,style:x},{children:h})):f?r.jsx(r.Fragment,{children:f}):null});const Km=8,I6=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=K("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 ou(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]=y.useState(c),[f,m]=y.useState(100),p=y.useRef(null),h=y.useRef(null),g=s[d];let x;e[0]!==s.length?(x=Ne=>{u(Math.min(Math.max(Ne,0),s.length-1)),m(100)},e[0]=s.length,e[1]=x):x=e[1];const v=x;let w;e[2]!==v||e[3]!==d?(w=()=>v(d-1),e[2]=v,e[3]=d,e[4]=w):w=e[4];const b=w;let j;e[5]!==v||e[6]!==d?(j=()=>v(d+1),e[5]=v,e[6]=d,e[7]=j):j=e[7];const S=j;if(!g)return null;const N=s.length>1,C=d>0,k=d<s.length-1,T=f>100;let E;e[8]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{var Ne;return(Ne=p.current)==null?void 0:Ne.zoomIn()},e[8]=E):E=e[8];const P=E;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{var Ne;return(Ne=p.current)==null?void 0:Ne.zoomOut()},e[9]=_):_=e[9];const A=_;let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{var Ne;return(Ne=p.current)==null?void 0:Ne.resetTransform()},e[10]=I):I=e[10];const R=I;let $;e[11]!==k||e[12]!==C||e[13]!==S||e[14]!==b?($=Ne=>{Ne.key==="ArrowLeft"&&C?(Ne.preventDefault(),b()):Ne.key==="ArrowRight"&&k?(Ne.preventDefault(),S()):Ne.key==="+"||Ne.key==="="?(Ne.preventDefault(),P()):Ne.key==="-"?(Ne.preventDefault(),A()):Ne.key==="0"&&(Ne.preventDefault(),R())},e[11]=k,e[12]=C,e[13]=S,e[14]=b,e[15]=$):$=e[15];const M=$;let L;e[16]===Symbol.for("react.memo_cache_sentinel")?(L=Ne=>{if(Ne.pointerType==="mouse"||Ne.isPrimary===!1){h.current=null;return}h.current={x:Ne.clientX,y:Ne.clientY}},e[16]=L):L=e[16];const D=L;let F;e[17]!==k||e[18]!==C||e[19]!==S||e[20]!==b?(F=Ne=>{var Be;const Fe=h.current;h.current=null;const He=((Be=p.current)==null?void 0:Be.instance.state.scale)??1;if(!Fe||He>1.01)return;const We=Ne.clientX-Fe.x,Ee=Ne.clientY-Fe.y;Math.abs(We)<I6||Math.abs(We)<Math.abs(Ee)||(We>0&&C&&b(),We<0&&k&&S())},e[17]=k,e[18]=C,e[19]=S,e[20]=b,e[21]=F):F=e[21];const z=F;let O;e[22]!==i?(O=Ne=>{Ne||i()},e[22]=i,e[23]=O):O=e[23];let H;e[24]!==a?(H=Ne=>{Ne||a==null||a()},e[24]=a,e[25]=H):H=e[25];let W,U,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(W=K("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"),U=r.jsx(ns,{className:"sr-only",children:"Image viewer"}),V=r.jsx(ss,{className:"sr-only",children:"View and navigate images from this session."}),e[26]=W,e[27]=U,e[28]=V):(W=e[26],U=e[27],V=e[28]);let q;e[29]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-white/[0.06]",children:r.jsx(B3,{className:"size-3.5 text-white/65","data-icon":"icon"})}),e[29]=q):q=e[29];const X=g.label||g.alt||"Session image";let G;e[30]!==X?(G=r.jsx("div",{className:"truncate text-xs font-medium text-white/90",children:X}),e[30]=X,e[31]=G):G=e[31];let Y;e[32]!==N||e[33]!==s.length||e[34]!==d?(Y=N&&r.jsxs("div",{className:"text-xs tabular-nums text-white/50",children:[d+1," of ",s.length]}),e[32]=N,e[33]=s.length,e[34]=d,e[35]=Y):Y=e[35];let J;e[36]!==G||e[37]!==Y?(J=r.jsxs("div",{className:"min-w-0 flex-1",children:[G,Y]}),e[36]=G,e[37]=Y,e[38]=J):J=e[38];const Q=f<=100;let Z;e[39]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(P1,{className:"size-3.5","data-icon":"icon"}),e[39]=Z):Z=e[39];let te;e[40]!==Q?(te=r.jsx(Uo,{label:"Zoom out",disabled:Q,onClick:A,children:Z}),e[40]=Q,e[41]=te):te=e[41];let ne;e[42]!==f?(ne=r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:R,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>=Km*100;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsx(In,{className:"size-3.5","data-icon":"icon"}),e[44]=re):re=e[44];let ie;e[45]!==oe?(ie=r.jsx(Uo,{label:"Zoom in",disabled:oe,onClick:P,children:re}),e[45]=oe,e[46]=ie):ie=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 de;e[48]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(Qe,{className:"size-4","data-icon":"icon"}),e[48]=de):de=e[48];let ce;e[49]!==i?(ce=r.jsx(Uo,{label:"Close image viewer",onClick:i,children:de}),e[49]=i,e[50]=ce):ce=e[50];let ue;e[51]!==te||e[52]!==ne||e[53]!==ie||e[54]!==ce?(ue=r.jsxs("div",{className:"flex items-center gap-1",children:[te,ne,ie,se,ce]}),e[51]=te,e[52]=ne,e[53]=ie,e[54]=ce,e[55]=ue):ue=e[55];let me;e[56]!==J||e[57]!==ue?(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,J,ue]}),e[56]=J,e[57]=ue,e[58]=me):me=e[58];const fe=g.id;let ae,ve,ge;e[59]===Symbol.for("react.memo_cache_sentinel")?(ae={mode:"toggle"},ve={step:.005},ge=(Ne,Fe)=>m(Math.round(Fe.scale*100)),e[59]=ae,e[60]=ve,e[61]=ge):(ae=e[59],ve=e[60],ge=e[61]);let ye,Pe;e[62]===Symbol.for("react.memo_cache_sentinel")?(ye={width:"100%",height:"100%"},Pe={width:"100%",height:"100%"},e[62]=ye,e[63]=Pe):(ye=e[62],Pe=e[63]);const De=g.src,Te=g.alt,Ae=T?"cursor-grab active:cursor-grabbing":"cursor-zoom-in";let pe;e[64]!==Ae?(pe=K("max-h-full max-w-full select-none object-contain",Ae),e[64]=Ae,e[65]=pe):pe=e[65];let xe;e[66]!==g.alt||e[67]!==g.src||e[68]!==pe?(xe=r.jsx(A6,{wrapperStyle:ye,contentStyle:Pe,contentClass:"flex items-center justify-center p-3 sm:p-6",children:r.jsx("img",{src:De,alt:Te,draggable:!1,className:pe})}),e[66]=g.alt,e[67]=g.src,e[68]=pe,e[69]=xe):xe=e[69];let ke;e[70]!==g.id||e[71]!==xe?(ke=r.jsx(_6,{ref:p,minScale:1,maxScale:Km,centerOnInit:!0,centerZoomedOut:!0,doubleClick:ae,wheel:ve,onTransform:ge,children:xe},fe),e[70]=g.id,e[71]=xe,e[72]=ke):ke=e[72];let $e;e[73]!==k||e[74]!==C||e[75]!==S||e[76]!==b||e[77]!==N?($e=N&&r.jsxs(r.Fragment,{children:[r.jsx(Uo,{label:"Previous image",disabled:!C,onClick:b,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(hd,{className:"size-5","data-icon":"icon"})}),r.jsx(Uo,{label:"Next image",disabled:!k,onClick:S,className:"absolute right-2 top-1/2 size-10 -translate-y-1/2 rounded-full bg-black/45 backdrop-blur sm:right-3",children:r.jsx(Ve,{className:"size-5","data-icon":"icon"})})]}),e[73]=k,e[74]=C,e[75]=S,e[76]=b,e[77]=N,e[78]=$e):$e=e[78];let we;e[79]!==f?(we=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(xa,{className:"size-3","data-icon":"inline-start"}),"Scroll or double-click to zoom · drag to pan"]}),e[79]=f,e[80]=we):we=e[80];let be;e[81]!==z||e[82]!==ke||e[83]!==$e||e[84]!==we?(be=r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-black",onPointerDown:D,onPointerUp:z,children:[ke,$e,we]}),e[81]=z,e[82]=ke,e[83]=$e,e[84]=we,e[85]=be):be=e[85];let Le;e[86]!==v||e[87]!==N||e[88]!==s||e[89]!==d?(Le=N&&r.jsx("footer",{className:"shrink-0 border-t border-white/10 bg-black/25 px-2 py-2",children:r.jsx("div",{className:"flex gap-1.5 overflow-x-auto overscroll-x-contain pb-0.5",children:s.map((Ne,Fe)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>v(Fe),"aria-label":`View image ${Fe+1}`,"aria-current":Fe===d?"true":void 0,className:K("relative size-12 shrink-0 overflow-hidden rounded-md border bg-white/[0.04] p-0.5 sm:h-14 sm:w-[4.5rem]",Fe===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:Ne.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:Fe+1})]},`${Ne.id}-${Fe}`))})}),e[86]=v,e[87]=N,e[88]=s,e[89]=d,e[90]=Le):Le=e[90];let Se;e[91]!==M||e[92]!==me||e[93]!==be||e[94]!==Le?(Se=r.jsxs(ts,{showCloseButton:!1,onKeyDown:M,className:W,children:[U,V,me,be,Le]}),e[91]=M,e[92]=me,e[93]=be,e[94]=Le,e[95]=Se):Se=e[95];let Re;return e[96]!==l||e[97]!==O||e[98]!==H||e[99]!==Se?(Re=r.jsx(es,{open:l,onOpenChange:O,onOpenChangeComplete:H,children:Se}),e[96]=l,e[97]=O,e[98]=H,e[99]=Se,e[100]=Re):Re=e[100],Re}const Vm={0:"\0",b:"\b",f:"\f",n:`
|
|
54
|
+
`,r:"\r",t:" ",v:"\v"};function R6(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Zi(n){return!!(n&&/[\w$]/.test(n))}function Mn(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 Vm){s+=Vm[a],o++;continue}if(a===`
|
|
55
|
+
`){o++;continue}if(a==="\r"){o+=n[o+1]===`
|
|
56
|
+
`?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 us={"(":")","[":"]","{":"}"};function ru(n,e){if(n[e]!=="/")return null;if(n[e+1]==="/"){const t=n.indexOf(`
|
|
57
|
+
`,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 Jr(n,e){const t=Mn(n,e);if(t)return{endIndex:t.endIndex,isString:!0};const s=ru(n,e);return s===null?null:{endIndex:s,isString:!1}}function Kt(n,e){let t=e;for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}const s=ru(n,t);if(s===null)break;t=s}return t}function za(n,e){const t=n[e];if(!us[t])return null;const s=[us[t]];for(let o=e+1;o<n.length;o++){const i=Jr(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(us[a]){s.push(us[a]);continue}if(a===s.at(-1)&&(s.pop(),s.length===0))return o}return null}function zx(n,e){if(!R6(n[e]))return null;let t=e+1;for(;Zi(n[t]);)t++;return{value:n.slice(e,t),endIndex:t}}function M6(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*=`,"y");let a=null;for(let f=0;f<o.length;f++){const m=Jr(o,f);if(m){f=m.endIndex-1;continue}i.lastIndex=f;const p=i.exec(o);p&&(a=p,f+=p[0].length-1)}if(!a||a.index===void 0)return t;const l=Kt(o,a.index+a[0].length),c=o[l];if(c==="{"||c==="["||c==="("){const f=za(o,l);if(f!==null)return o.slice(l,f+1).trim()}const d=Mn(o,l);return d?o.slice(l,d.endIndex).trim():t}function Fx(n){const e=[];let t="";for(let s=0;s<n.length;s++){const o=Jr(n,s);if(o){o.isString&&(t="literal"),s=o.endIndex-1;continue}const i=t===".";if(/\s/.test(n[s])||(t=n[s]),i||!n.startsWith("tools",s)||Zi(n[s-1])||Zi(n[s+5]))continue;let a=Kt(n,s+5),l="";if(n[a]==="."){a=Kt(n,a+1);const u=zx(n,a);if(!u)continue;l=u.value,a=u.endIndex}else if(n[a]==="["){a=Kt(n,a+1);const u=Mn(n,a);if(!u||(a=Kt(n,u.endIndex),n[a]!=="]"))continue;l=u.value,a++}else continue;if(a=Kt(n,a),n[a]!=="(")continue;const c=za(n,a);if(c===null){e.push({name:l,argumentSource:n.slice(a+1).trim(),startIndex:s});break}const d=n.slice(a+1,c).trim();e.push({name:l,argumentSource:M6(n,s,d),startIndex:s})}return e}function Bx(n,e){return Mn(n,e)??zx(n,e)}function O6(n,e,t){const s=[];for(let o=e;o<t;o++){const i=Jr(n,o);if(i){o=i.endIndex-1;continue}const a=n[o];if(us[a]){s.push(us[a]);continue}if(s.length>0&&a===s.at(-1)){s.pop();continue}if(s.length===0&&a===",")return o}return t}function Fa(n,e){let t=Kt(n,0);for(;n[t]==="(";)t=Kt(n,t+1);if(n[t]!=="{")return null;const s=za(n,t);if(s===null)return null;let o=t+1;for(;o<s;){if(o=Kt(n,o),n[o]===","){o++;continue}const i=Bx(n,o);if(!i){o++;continue}if(o=Kt(n,i.endIndex),n[o]!==":"){o++;continue}const a=Kt(n,o+1),l=O6(n,a,s);if(i.value===e)return n.slice(a,l).trim();o=l+1}return null}function Ux(n,e,t){const s=[];for(let o=0;o<n.length;o++){const i=ru(n,o);if(i!==null){o=i-1;continue}const a=Bx(n,o);if(a){if(a.value===e&&!Zi(n[o-1])){const l=Kt(n,a.endIndex);if(n[l]===":"){const c=t(Kt(n,l+1));c!==null&&s.push(c)}}o=a.endIndex-1}}return s}function iu(n,e){return Ux(n,e,t=>{var s;return((s=Mn(n,t))==null?void 0:s.value)??null})}function Wx(n,e){return Ux(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 Hx(n){const e=Kt(n,0);if(!n.slice(e).trim())return 0;if(n[e]!=="[")return 1;const t=za(n,e);if(t===null)return 1;let s=0,o=!1;const i=[];for(let a=e+1;a<t;a++){const l=Jr(n,a);if(l){o||(o=l.isString),a=l.endIndex-1;continue}const c=n[a];us[c]?(o=!0,i.push(us[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)}const L6=["cmd","command","workdir","description","timeout","yield_time_ms","max_output_tokens","session_id","chars","tty","login","shell","path","file_path","pattern","query","url","prompt","message","target","task_name","agent_id","agent_ids","model","agent_type","fork_turns","reasoning_effort","questions","plan","explanation","search_query","image_query","open","click","find","screenshot","finance","weather","sports","time","response_length","server","uri","cursor","name","code","old_string","new_string","content","replace_all","patch","input"];function Gm(n){try{return{value:JSON.parse(n)}}catch{}if(n.startsWith("`")&&n.includes("${"))return null;const e=Mn(n,0);return e&&e.endIndex===n.length?{value:e.value}:null}function au(n){return typeof n.input.raw=="string"&&/(?:^|__|[.:/])exec$/.test(n.name)}function qx(n){return typeof n.raw!="string"?[]:Fx(n.raw).map(({name:e,argumentSource:t})=>{const s=t.trim(),o=Gm(s);if(o){const a=o.value;return a&&typeof a=="object"&&!Array.isArray(a)?{name:e,input:a}:{name:e,input:typeof a=="string"?{raw:a}:{value:a}}}const i={raw:t};for(const a of L6){const l=Fa(s,a);if(l===null)continue;const c=Gm(l);c&&(i[a]=c.value)}return{name:e,input:i}})}function Oc(n){return n.type==="user"}function lu(n){return n.type==="assistant"}function Ym(n){return n.type==="progress"}function Xm(n){return n.type==="system"}function Kx(n){return n.type==="summary"}function D6(n){return n.type==="queue-operation"}function Vx(n){return n.type==="attachment"}function z6(n){return n.type==="user"&&n.isCompactSummary===!0}function Gx(n){return n.type==="system"&&n.subtype==="compact_boundary"}function Jm(n,e){let t=0;for(const s of n)e[s.name]=(e[s.name]??0)+1,s.isError&&t++;return t}function Qm(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 Ba(n){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:n}}function Ua(n){const e=Ba(n.length);for(const t of n){t.tokenUsage&&Qm(e,t.tokenUsage),t.durationMs&&(e.totalDurationMs+=t.durationMs),e.errorCount+=Jm(t.toolCalls,e.toolCallCounts);for(const s of t.subAgentActivity)e.errorCount+=Jm(s.toolCalls,e.toolCallCounts),s.tokenUsage&&Qm(e,s.tokenUsage)}return e}function po(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 F6=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,B6=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function U6(n){for(const e of B6){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 W6(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(F6,(o,i,a,l)=>(t=!0,e===null&&(e=U6(a)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const H6=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],q6=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],K6=200,V6=/\bhttps?:\/\/\S+/g;function G6(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,K6).toLowerCase();if(H6.some(i=>i.test(t)))return!0;const o=e.slice(e.lastIndexOf(`
|
|
58
|
+
`)+1).slice(-200).replace(V6,"").toLowerCase();return o.includes("?")||q6.some(i=>i.test(o))}function Wa(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
59
|
+
`)}function Zm(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
60
|
+
`):""}function Yx(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 Y6=/<task-notification>[\s\S]*?<\/task-notification>/g,X6=/<[^>]*>/g;function J6(n){var t;if(((t=n.origin)==null?void 0:t.kind)==="task-notification")return!0;const e=Wa(n.message.content);return e.includes("<task-notification>")?e.replace(Y6,"").replace(X6,"").trim()==="":!1}function Q6(n){if(!Vx(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:Wa(t);if(!Yx(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 Z6=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function eC(n,e){let t=n;for(const[s,o]of Z6){const i=e[s];typeof i!="string"||!i||(t={...t,[o]:i})}return 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 Wa(n).trim().replace(tC,"").replace(nC,"").trim()}function oC(n){if(n)return{trigger:n.trigger,preTokens:n.preTokens,postTokens:n.postTokens}}function _i(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 v=n[g];if(v.kind==="tool_calls"){const w=v.toolCalls.findIndex(b=>b.name==="ExitPlanMode");if(w!==-1){d.push(...v.toolCalls.slice(0,w)),m=v.toolCalls[w],p=m.input.path?String(m.input.path):void 0,m.result!==null&&(h=m.isError?"rejected":"approved");const b=v.toolCalls.slice(w+1);e.push({kind:"plan_mode",plan:a,planFilePath:p,status:h,toolCalls:d,timestamp:l}),e.push(...x),b.length>0&&e.push({kind:"tool_calls",toolCalls:b,timestamp:v.timestamp}),t=g+1;break}else d.push(...v.toolCalls),g++}else if(v.kind==="hook_event"||v.kind==="text"||v.kind==="queued_prompt"||v.kind==="agent_message")x.push(v),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 cu(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(Kx(o)||Gx(o)){t=!1;continue}if(Oc(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}lu(o)&&!t&&(e.push(s),t=!0)}return e}function Xx(n){var N,C;const e=[],t=[];let s=null,o=0,i=null,a=null;function l(k){a&&(k.compactionSummary=a.summary,k.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 v(k,T){let E=x.get(k);E||(E=new Map,x.set(k,E)),E.set(T,(E.get(T)??0)+1)}function w(k,T){const E=x.get(k),P=E==null?void 0:E.get(T);return!E||!P?!1:(P===1?E.delete(T):E.set(T,P-1),!0)}function b(){for(const k of g)k.turn.contentBlocks.push(k.sender?{kind:"agent_message",sender:k.sender,body:k.body,timestamp:k.timestamp}:{kind:"queued_prompt",content:k.content,timestamp:k.timestamp});g.length=0}function j(k){if(!i)return;const T=f.get(k);if(!T||T.length===0)return;i.subAgentActivity.push(...T),f.delete(k);const E=p.has(k)?"background_agent":"sub_agent",P=m.get(k);if(P)P.messages.push(...T);else{const _={kind:E,messages:[...T]};i.contentBlocks.push(_),m.set(k,_)}}function S(){if(i){for(const k of i.toolCalls)j(k.id);for(const[k]of f)j(k);for(const k of i.contentBlocks)if(k.kind==="hook_event")for(const T of k.events){if(!(T.eventName==="PostToolUse"||T.eventName.startsWith("PostToolUse:"))||!T.toolUseId)continue;const P=i.toolCalls.find(_=>_.id===T.toolUseId);P&&(T.updatedToolOutput&&(P.outputReplacedByHook=!0),T.durationMs!==void 0&&(P.hookDurationMs=(P.hookDurationMs??0)+T.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 k=n[o];if(Kx(k)){S(),a={summary:k.summary};continue}if(Gx(k)){S(),a={meta:oC(k.compactMetadata)};continue}if(z6(k)){S(),s=o,i=_i(k,null),i.compactionSummary=sC(k.message.content),i.compactionMeta=a==null?void 0:a.meta,a=null;continue}if(Xm(k)&&k.subtype==="away_summary"&&k.content){c={content:k.content,timestamp:k.timestamp};continue}if(D6(k)){if(i&&k.operation==="enqueue"&&Yx(k.content)){const T=yr(k.content);g.push({turn:i,content:k.content,timestamp:k.timestamp,sender:T.sender,body:T.body}),v(i,k.content)}continue}if(Vx(k)){const T=Q6(k);i&&T!==null&&!w(i,T.raw)&&g.push({turn:i,content:T.raw,timestamp:((N=k.attachment)==null?void 0:N.timestamp)??k.timestamp,sender:T.sender,body:T.body});continue}if(g.length>0){const T=Oc(k)&&!k.isMeta?k.message.content:null;if(typeof T=="string"){const E=g.findIndex(P=>P.content===T);if(E>=0){const[P]=g.splice(E,1);w(P.turn,P.content)}}b()}if(Oc(k)&&!k.isMeta){const T=k.message.content;if(typeof T!="string"&&Array.isArray(T)&&T.some(P=>P.type==="tool_result")&&i){for(const _ of T)if(_.type==="tool_result"){const A=d.get(_.tool_use_id);A&&(A.turn.toolCalls[A.index].result=Zm(_.content),A.turn.toolCalls[A.index].isError=_.is_error===!0,d.delete(_.tool_use_id))}const P=k.toolUseResult;if(P!=null&&P.agentId){const _=((C=T.find(L=>L.type==="tool_result"))==null?void 0:C.tool_use_id)??"",A=h.get(_),I=p.has(_),R=[];if(Array.isArray(P.content))for(const L of P.content)L.type==="text"&&R.push(L.text);const $={agentId:P.agentId,parentToolUseId:_||void 0,agentName:(A==null?void 0:A.name)??null,subagentType:(A==null?void 0:A.subagentType)??null,type:"assistant",content:P.content,toolCalls:[],thinking:[],text:R,timestamp:k.timestamp??"",tokenUsage:P.usage?{input_tokens:P.usage.input_tokens??0,output_tokens:P.usage.output_tokens??0,cache_creation_input_tokens:P.usage.cache_creation_input_tokens??0,cache_read_input_tokens:P.usage.cache_read_input_tokens??0}:null,model:null,isBackground:I,prompt:P.prompt,status:P.status,durationMs:P.totalDurationMs,toolUseCount:P.totalToolUseCount};if(!m.get(_)){i.subAgentActivity.push($);const D={kind:I?"background_agent":"sub_agent",messages:[$]};i.contentBlocks.push(D),m.set(_,D)}}continue}if(J6(k)){const E={kind:"task_notification",content:Wa(T),timestamp:k.timestamp};if(i){i.contentBlocks.push(E);continue}s=o,i=_i(k,null),i.contentBlocks.push(E),l(i);continue}S(),s=o,i=_i(k,k.message.content),l(i),c&&(i.contentBlocks.push({kind:"recap",content:c.content,timestamp:c.timestamp}),c=null);continue}if(lu(k)){let T=function(){I.length>0&&(R.contentBlocks.push({kind:"tool_calls",toolCalls:[...I],timestamp:_}),I.length=0)},E=function(){if(A.length>0){const $=R.contentBlocks[R.contentBlocks.length-1];$&&$.kind==="thinking"?$.blocks.push(...A):R.contentBlocks.push({kind:"thinking",blocks:[...A],timestamp:_}),A.length=0}};i||(s=o,i=_i(k,null),l(i)),i.model=k.message.model,k.effort&&(i.effort=k.effort),i.attribution=eC(i.attribution,k);const P=k.message.id;u.has(P)||(u.add(P),i.tokenUsage=po(i.tokenUsage,k.message.usage));const _=k.timestamp??"",A=[],I=[],R=i;for(const $ of k.message.content)if($.type==="thinking"){T();const M=$;if(!M.thinking)continue;i.thinking.push(M),A.push(M)}else if($.type==="text"){T(),E();const M=/<thinking>([\s\S]*?)<\/thinking>/g;let L=$.text,D;for(;(D=M.exec($.text))!==null;){const F=D[1].trim();if(F){const z={type:"thinking",thinking:F,signature:""};i.thinking.push(z),i.contentBlocks.push({kind:"thinking",blocks:[z],timestamp:_})}L=L.replace(D[0],"")}if(L=L.trim(),L){i.assistantText.push(L);const F=i.contentBlocks[i.contentBlocks.length-1];F&&F.kind==="text"?F.text.push(L):i.contentBlocks.push({kind:"text",text:[L],timestamp:_})}}else if($.type==="tool_use"){E();const M={id:$.id,name:$.name,input:$.input,result:null,isError:!1,timestamp:k.timestamp??""},L=i.toolCalls.length;if(i.toolCalls.push(M),I.push(M),d.set($.id,{turn:i,index:L}),$.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})}}E(),T();continue}if(Ym(k)&&k.data.type==="agent_progress"){const T=k.data,E=k.parentToolUseID??"";let P=null;if(T.message.type==="assistant"){const $=T.message.message,M=$.id,L=$.usage;L&&M&&!u.has(M)&&(u.add(M),P={input_tokens:L.input_tokens??0,output_tokens:L.output_tokens??0,cache_creation_input_tokens:L.cache_creation_input_tokens??0,cache_read_input_tokens:L.cache_read_input_tokens??0})}const _=T.message.type==="assistant"?T.message.message.model??null:null,A=h.get(E),I={agentId:T.agentId,parentToolUseId:E||void 0,agentName:(A==null?void 0:A.name)??null,subagentType:(A==null?void 0:A.subagentType)??null,type:T.message.type,content:T.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:T.message.timestamp??k.timestamp??"",tokenUsage:P,model:_,isBackground:p.has(E)};if(T.message.type==="assistant"){const $=T.message.message.content;if(Array.isArray($))for(const M of $)M.type==="thinking"?I.thinking.push(M.thinking):M.type==="text"?I.text.push(M.text):M.type==="tool_use"&&I.toolCalls.push({id:M.id,name:M.name,input:M.input,result:null,isError:!1,timestamp:T.message.timestamp??k.timestamp??""})}else if(T.message.type==="user"){const $=T.message.message.content;if(Array.isArray($)){for(const M of $)if(M.type==="tool_result"){const L=f.get(E);if(L)for(const D of L){const F=D.toolCalls.find(z=>z.id===M.tool_use_id);F&&(F.result=Zm(M.content),F.isError=M.is_error===!0)}}}}let R=f.get(E);R||(R=[],f.set(E,R)),R.push(I),i&&j(E);continue}if(Ym(k)&&k.data.type==="hook_progress"){const T=k.data,E=String(T.hook_event_name??T.hookEvent??"unknown"),P=T.hookSpecificOutput,_={eventName:E,source:T.source!==void 0?String(T.source):void 0,toolName:T.tool_name!==void 0?String(T.tool_name):void 0,toolUseId:T.tool_use_id!==void 0?String(T.tool_use_id):void 0,command:T.command!==void 0?String(T.command):void 0,output:T.output!==void 0?String(T.output):void 0,stderr:T.stderr!==void 0?String(T.stderr):void 0,exitCode:T.exit_code!==void 0?Number(T.exit_code):void 0,decision:T.decision!==void 0?String(T.decision):void 0,durationMs:T.duration_ms!==void 0?Number(T.duration_ms):void 0,updatedToolOutput:(P==null?void 0:P.updatedToolOutput)!==void 0?String(P.updatedToolOutput):void 0,sessionTitle:(P==null?void 0:P.sessionTitle)!==void 0?String(P.sessionTitle):void 0,worktreePath:(P==null?void 0:P.worktreePath)!==void 0?String(P.worktreePath):void 0,timestamp:k.timestamp??""};if(i){const A=i.contentBlocks[i.contentBlocks.length-1];A&&A.kind==="hook_event"?A.events.push(_):i.contentBlocks.push({kind:"hook_event",events:[_],timestamp:k.timestamp})}continue}if(Xm(k)&&k.subtype==="turn_duration"&&i){k.durationMs!==void 0&&k.durationMs!==null&&(i.durationMs=(i.durationMs??0)+k.durationMs);continue}}return b(),S(),{turns:cu(e),turnStartIndices:t}}function Jx(n){return Xx(n).turns}function ep(){return!0}function Qx(n){const e=[];for(const t of n){const s=t.trim();if(s)try{e.push(JSON.parse(s))}catch{}}return e}function Zx(n){return Qx(n.split(`
|
|
61
|
+
`))}function e0(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),lu(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 e0(Qx(n))}function cC(n,e){const t=Zx(n),s=e0(t),o=Jx(t),i=e!=null&&e.skipStats?Ba(o.length):Ua(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"claude"}}function dC(n,e){const t=Zx(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=Jx(o.slice(d)),m=cu([...u,...f]),p=Ua(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 t0="<task-notification>",uC=/<task-id>([^<]+)<\/task-id>/g,fC=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function Tn(n){return typeof n=="object"&&n!==null}function mC(n){const e=Tn(n.message)?n.message:null,t=e==null?void 0:e.content;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>Tn(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(t0)){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=Tn(a.toolUseResult)?a.toolUseResult:null;if((l==null?void 0:l.status)==="async_launched"){const c=Tn(a.message)?a.message:null,u=(Array.isArray(c==null?void 0:c.content)?c.content:[]).filter(p=>Tn(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=Tn(a.message)?a.message:null,c=Array.isArray(l==null?void 0:l.content)?l.content:[];for(const d of c){if(!Tn(d)||d.type!=="tool_use"||d.name!=="TaskStop")continue;const u=Tn(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=Tn(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(t0))continue;const u=d.operation;u==="enqueue"?e++:(u==="dequeue"||u==="remove")&&e--;continue}if(d.type==="attachment"){const u=Tn(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 Xx(n).turnStartIndices}function n0(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})}function tp(n){return n.includes("*** Begin Patch")&&n.includes("*** End Patch")}function vC(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=Mn(n,a);if(l){if(tp(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=Mn(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||!tp(d)||s.has(d)||(s.add(d),t.push(d))}return t}function np(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 sp(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=np(f.filePath,s),x=np(h||f.filePath,s),v=p.split(/^@@.*$/m).filter(S=>S.trim()),w=[],b=[];for(const S of v)for(const N of S.split(`
|
|
62
|
+
`))N.startsWith("-")?w.push(N.slice(1)):N.startsWith("+")?b.push(N.slice(1)):N.startsWith(" ")&&(w.push(N.slice(1)),b.push(N.slice(1)));const j=a.length>1?`${e}:file-${u}`:e;f.action==="Add File"?o.push({id:j,name:"Write",input:{file_path:x,content:b.join(`
|
|
63
|
+
`)},result:null,isError:!1,timestamp:t}):f.action==="Delete File"?o.push({id:j,name:"Edit",input:{file_path:x,old_string:w.join(`
|
|
64
|
+
`),new_string:""},result:null,isError:!1,timestamp:t}):o.push({id:j,name:"Edit",input:{file_path:x,...h?{old_path:g}:{},old_string:w.join(`
|
|
65
|
+
`),new_string:b.join(`
|
|
66
|
+
`)},result:null,isError:!1,timestamp:t})}return o}function s0(n,e,t,s,o=""){return n==="apply_patch"?sp(e,t,s,o):vC(e).flatMap((i,a)=>sp(i,`${t}:patch-${a}`,s,o))}function yC(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 Pn(n){return typeof n=="object"&&n!==null}const wC=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"]]),jC=new Set(["exec","exec_command","write_stdin","apply_patch","update_plan","view_image","request_user_input","request_user_input_async","tool_search","list_mcp_resources","list_mcp_resource_templates","read_mcp_resource","request_plugin_install","create_goal","get_goal","update_goal","wait"]);function yn(n){if(n.startsWith("mcp__"))return n;const e=n.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??n;return wC.get(e)??(jC.has(e)?e:n)}function SC(n){const e=n==null?void 0:n.match(/Process exited with code (\d+)/);return e?e[1]!=="0":!1}function NC(n){return n==="request_user_input"||n==="request_user_input_async"}function kC(n){const t=(Array.isArray(n.questions)?n.questions:[n]).filter(s=>Pn(s)).map(s=>{const o=typeof s.question=="string"?s.question:typeof s.title=="string"?s.title:"",i=Array.isArray(s.options)?s.options:[];return{question:o,...typeof s.header=="string"&&s.header?{header:s.header}:{},options:i.map(a=>typeof a=="string"?{label:a}:!Pn(a)||typeof a.label!="string"?null:{label:a.label,...typeof a.description=="string"&&a.description?{description:a.description}:{}}).filter(a=>a!==null)}}).filter(s=>s.question);return t.length>0?{...n,questions:t}:n}function CC(n){return{todos:(Array.isArray(n.plan)?n.plan:[]).filter(s=>Pn(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){if(n.type!=="image"&&n.type!=="input_image"&&n.type!=="image_url")return null;const e=Pn(n.source)?n.source:n,t=e.media_type??e.mimeType;if(typeof t=="string"&&t.startsWith("image/")&&typeof e.data=="string"&&e.data)return{type:"image",source:{type:"base64",media_type:t,data:e.data}};const s=Pn(n.image_url)?n.image_url.url:n.image_url,o=typeof s=="string"?/^data:(image\/[^;,]+);base64,(.+)$/is.exec(s):null;return o?{type:"image",source:{type:"base64",media_type:o[1].toLowerCase(),data:o[2]}}:null}function op(n){if(typeof n=="string")return{parts:[n],text:n,images:[]};if(!Array.isArray(n)){const s=n==null?"":JSON.stringify(n);return{parts:[s],text:s,images:[]}}const e=[],t=[];for(const s of n){if(!Pn(s))continue;typeof s.text=="string"&&e.push(s.text);const o=_C(s);o&&t.push(o)}return{parts:e,text:e.join(""),images:t}}const TC=/^Script (?:completed|failed|running)\b/;function o0(n,e){Pn(n)&&(n.status==="rejected"?e.push(1):n.status==="fulfilled"?o0(n.value,e):typeof n.exit_code=="number"&&e.push(n.exit_code))}function EC(n){const e=n[0]??"";if(!TC.test(e))return;if(e.startsWith("Script failed"))return!0;const t=[];for(const s of n.slice(1)){let o;try{o=JSON.parse(s)}catch{continue}for(const i of Array.isArray(o)?o:[o])o0(i,t)}return t.length>0?t.some(s=>s!==0):void 0}function Lc(n){const e=op(n);let t=Pn(n)&&!Array.isArray(n)?n:null;try{const d=t??JSON.parse(e.text);Pn(d)&&!Array.isArray(d)&&(t=d)}catch{}const s=t&&("output"in t||"content"in t)?op(t.output??t.content):e,o=s===e?e.images:[...e.images,...s.images],i=Pn(t==null?void 0:t.metadata)?t.metadata:null,a=(i==null?void 0:i.exit_code)??(t==null?void 0:t.exit_code),l=typeof(t==null?void 0:t.isError)=="boolean"?t.isError:typeof(t==null?void 0:t.is_error)=="boolean"?t.is_error:void 0,c=l===!0||(typeof a=="number"?a!==0:l??EC(e.parts)??SC(s.text));return{text:s.text,isError:c,...o.length>0?{images:o}:{}}}const AC=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function PC(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 du(n){try{return JSON.parse(n)}catch{return null}}function Je(n){return typeof n=="object"&&n!==null}function jo(n){return!n||typeof n.type!="string"?!1:n.type==="session_meta"||n.type==="turn_context"||n.type==="event_msg"||n.type==="response_item"||n.type==="inter_agent_communication_metadata"||n.type==="compacted"||n.type==="world_state"}function ea(n,e){const t=n==null?void 0:n.content;return Array.isArray(t)?t.filter(s=>Je(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
67
|
+
`).trim():""}const $C=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,IC=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function r0(n){if(typeof n!="string")return null;const e=$C.exec(n);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function i0(n){if(typeof n!="string")return null;const e=IC.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(r0).filter(e=>e!==null):[]}function MC(n){return Array.isArray(n.audio)?n.audio.map(i0).filter(e=>e!==null):[]}function a0(n){return Array.isArray(n.content)?n.content.filter(e=>Je(e)&&e.type==="input_image").map(e=>r0(e.image_url)).filter(e=>e!==null):[]}function l0(n){return Array.isArray(n.content)?n.content.filter(e=>Je(e)&&e.type==="input_audio").map(e=>i0(e.audio_url)).filter(e=>e!==null):[]}function rp(n,e,t=[],s=[],o=[]){const i=[...s.map(l=>`
|
|
68
|
+
`),...o.map(l=>`
|
|
69
|
+
[audio attachment](<${l}>)`)].join(""),a=n+i;return e.length===0&&t.length===0?a:[...e,...t,...a?[{type:"text",text:a}]:[]]}function OC(n){var a,l;const e=ea(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 LC(n){if(typeof n!="string")return"";const e=n.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function Dc(n){const e=n.trim();return!e||AC.some(t=>e.startsWith(t))?"":e}function DC(n){if(!Je(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 zC(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 Gs(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 FC(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 ip(n){if(typeof n!="string"||!n.trim())return{};try{const e=JSON.parse(n);return Je(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 ap(...n){return n.find(e=>typeof e=="string")}function BC(n){return n.startsWith("exec-")}function UC(n){var o;if(!Je(n))return{text:Ho(n),isError:!1};if("Err"in n)return{text:Ho(n.Err),isError:!0};const e=Je(n.Ok)?n.Ok:null;if(!e)return{text:Ho(n),isError:!1};const t=Lc({...e,content:e.content}),s=t.text||((o=t.images)!=null&&o.length?"":e.structuredContent!==void 0?Ho(e.structuredContent):Ho(e));return{...t,text:s,isError:t.isError}}function WC(n,e,t){return{id:n?`${n}@${e}`:PC("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:t}}function c0(n){return n.type==="event_msg"&&Je(n.payload)&&n.payload.type==="user_message"&&typeof n.payload.message=="string"?Dc(n.payload.message):n.type==="response_item"&&Je(n.payload)&&n.payload.type==="message"&&n.payload.role==="user"?Dc(ea(n.payload,"input_text")):""}function HC(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 c0(n)!==""||a0(e).length>0||l0(e).length>0}return!0}function d0(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(!Je(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&&Je(x.payload.branchedFrom)){const j=typeof x.payload.branchedFrom.sessionId=="string"?x.payload.branchedFrom.sessionId:"";j&&(a={sessionId:j,turnIndex:typeof x.payload.branchedFrom.turnIndex=="number"?x.payload.branchedFrom.turnIndex:null})}const w=Je(x.payload.source)?x.payload.source:null;if(w&&Je(w.subagent)){m=!0;const j=Je(w.subagent.thread_spawn)?w.subagent.thread_spawn:null;j&&typeof j.agent_path=="string"&&(h=j.agent_path)}typeof x.payload.forked_from_id=="string"&&x.payload.forked_from_id&&(p=x.payload.forked_from_id);const b=Je(x.payload.git)?x.payload.git:null;s||(s=b&&typeof b.branch=="string"?b.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 v=c0(x);v&&v!==g&&(l||(l=v),c=v,g=v,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 u0(n){for(const e of n.split(`
|
|
70
|
+
`)){const t=e.trim();if(t)return jo(du(t))}return!1}function qC(n){return jo(n[0]??null)}function KC(n){const e=n.map(du).filter(jo);return d0(e)}function f0(n,e){const t=d0(n.filter(jo)),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(E,P,_,A={}){const I=c.get(E);let R=f.get(E);if(!R){const M={agentId:E,parentToolUseId:(I==null?void 0:I.parentToolCallId)||void 0,agentName:(I==null?void 0:I.nickname)??(I!=null&&I.agentPath?Wo(I.agentPath):null),subagentType:(I==null?void 0:I.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(I==null?void 0:I.timestamp)??_,tokenUsage:null,model:(I==null?void 0:I.model)??null,isBackground:!1,prompt:(I==null?void 0:I.message)||void 0,status:A.status??"running"};P.subAgentActivity.push(M);const L=P.contentBlocks[P.contentBlocks.length-1];(L==null?void 0:L.kind)==="sub_agent"?L.messages.push(M):P.contentBlocks.push({kind:"sub_agent",messages:[M],timestamp:_}),R={message:M,turn:P},f.set(E,R)}const $=R.message;if(I&&($.parentToolUseId=I.parentToolCallId||$.parentToolUseId,$.agentName=I.nickname??(I.agentPath?Wo(I.agentPath):$.agentName),$.subagentType=I.agentType,$.model=I.model,$.prompt=I.message||$.prompt),A.text&&!$.text.includes(A.text)&&($.text.push(A.text),$.content=$.text.join(`
|
|
71
|
+
|
|
72
|
+
`)),A.status){const M=new Set(["completed","failed","interrupted"]);if(A.status==="running"&&$.status&&M.has($.status)||($.status=A.status),M.has(A.status)&&$.timestamp&&_){const L=new Date($.timestamp).getTime(),D=new Date(_).getTime();Number.isFinite(L)&&Number.isFinite(D)&&D>=L&&($.durationMs=D-L)}}return $}let p=null,h=null,g=t.model||null,x="",v=null,w=!1;const b=[];let j=0,S=null,N=null;function C(E){const P=s.length,_=FC(s,E,x);return s.length>P&&N!==null&&b.push(N),N=null,_}function k(E,P,_){const A=WC(E,P,_);return N=S??j,S=null,w||(A.isFragment=!0),v&&(A.compactionSummary=v,v=null),A}function T(E,P,_,A,I){const R=i.get(P);if(R){R.input={...R.input,..._},R.result=A,R.isError=A==="failed";return}const $={id:P,name:"WebSearch",input:_,result:A,isError:A==="failed",timestamp:I};i.set(P,$),Gs(E,$,I)}for(let E=0;E<n.length;E++){const P=n[E];if(!jo(P))continue;j=E;const _=Je(P.payload)?P.payload:void 0,A=P.timestamp??"";if(P.type==="compacted"){p=C(p),v="Conversation compacted",x=A;continue}if(P.type!=="world_state"){if(P.type==="turn_context"){p=C(p),S=E,h=typeof(_==null?void 0:_.turn_id)=="string"?_.turn_id:null,g=typeof(_==null?void 0:_.model)=="string"?_.model:g,x=A,w=!0;continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="user_message"&&typeof _.message=="string"){p&&(p.assistantText.length>0||p.toolCalls.length>0||p.thinking.length>0)&&(p=C(p)),w=!0,p??(p=k(h,A,g));const I=(Array.isArray(_.local_images)?_.local_images:[]).filter($=>typeof $=="string"&&$.length>0),R=(Array.isArray(_.local_audio)?_.local_audio:[]).filter($=>typeof $=="string"&&$.length>0);p.userMessage=rp(_.message,RC(_),MC(_),I,R),p.isFragment=!1,p.timestamp=p.timestamp||A,x=A;continue}if(!(!p&&!HC(P,_))){if(p??(p=k(h,A,g)),!p.model&&g&&(p.model=g),p.timestamp||(p.timestamp=A),A&&(x=A),P.type==="event_msg"&&(_==null?void 0:_.type)==="token_count"){const I=Je(_.info)?_.info:null,R=I?DC(I.last_token_usage):null;R&&(p.tokenUsage=po(p.tokenUsage,R));continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="web_search_end"&&typeof _.call_id=="string"){const I={};typeof _.query=="string"&&_.query&&(I.query=_.query),Je(_.action)&&(I.action=_.action),T(p,_.call_id,I,"completed",A);continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="mcp_tool_call_end"&&typeof _.call_id=="string"&&Je(_.invocation)){const I=_.invocation,R=typeof I.server=="string"?I.server:"mcp",$=typeof I.tool=="string"?I.tool:"tool",M=Je(I.arguments)?I.arguments:{},L=UC(_.result),D=o.get(_.call_id);D?(D.result=L.text,D.isError=L.isError,L.images&&(D.resultImages=L.images),o.delete(_.call_id)):BC(_.call_id)||Gs(p,{id:_.call_id,name:`mcp__${R}__${$}`,input:M,result:L.text,isError:L.isError,...L.images?{resultImages:L.images}:{},timestamp:A},A);continue}if(P.type==="event_msg"&&(_==null?void 0:_.type)==="sub_agent_activity"&&typeof _.agent_thread_id=="string"&&typeof _.agent_path=="string"){const I=_.agent_thread_id,R=typeof _.event_id=="string"?_.event_id:"",$=typeof _.kind=="string"?_.kind:"started",M=R?l.get(R):void 0,L=d.get(_.agent_path),D=c.get(I)??(L?c.get(L):void 0);if($!=="started"&&!D&&!M)continue;if(L&&L!==I&&!f.has(I)){const O=f.get(L);O&&(O.message.agentId=I,f.delete(L),f.set(I,O)),c.delete(L)}const F={agentId:I,nickname:(D==null?void 0:D.nickname)??Wo(_.agent_path)??(M==null?void 0:M.taskName)??null,agentPath:_.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)??(A||(M==null?void 0:M.timestamp)||""),parentToolCallId:(D==null?void 0:D.parentToolCallId)??R};c.set(I,F),d.set(_.agent_path,I),R&&($==="started"||M)&&u.set(R,I),m(I,p,A,{status:$==="interrupted"?"interrupted":"running"});continue}if(!(P.type!=="response_item"||!_)){if(_.type==="reasoning"){const I=Array.isArray(_.summary)?_.summary.filter(R=>typeof R=="string").join(`
|
|
73
|
+
`):"";zC(p,I.trim(),A);continue}if(_.type==="message"&&_.role==="assistant"){n0(p,ea(_,"output_text"),A);continue}if(_.type==="message"&&_.role==="user"&&p.userMessage===null){const I=Dc(ea(_,"input_text")),R=a0(_),$=l0(_);(I||R.length>0||$.length>0)&&(p.userMessage=rp(I,R,$),p.isFragment=!1,w=!0);continue}if(_.type==="web_search_call"&&typeof _.id=="string"){const I={};Je(_.action)&&(I.action=_.action);const R=typeof _.status=="string"?_.status:"completed";T(p,_.id,I,R,A);continue}if(_.type==="tool_search_call"){const I=ap(_.call_id,_.id)??"";if(I){const R={id:I,name:"ToolSearch",input:Je(_.arguments)?_.arguments:{},result:null,isError:!1,timestamp:A};o.set(I,R),Gs(p,R,A)}continue}if(_.type==="tool_search_output"&&typeof _.call_id=="string"){const I=o.get(_.call_id);if(I){const R=Array.isArray(_.tools)?_.tools:[],$=R.filter(Je).map(D=>ap(D.name)??"").filter(Boolean),M=$.length>0?$.length:R.length,L=`Found ${M} tool${M===1?"":"s"}`;I.result=$.length>0?`${L}: ${$.join(", ")}`:L,I.isError=_.status==="failed",o.delete(_.call_id)}continue}if(_.type==="agent_message"&&typeof _.author=="string"){const I=_.author,R=typeof _.recipient=="string"?_.recipient:null,$=OC(_);if($.messageType==="NEW_TASK")continue;const M=d.get(I),L=I.startsWith(`${t.agentPath}/`)&&(R===null||R===t.agentPath);if(!M&&!L)continue;const D=M??I;M||(c.set(D,{agentId:D,nickname:Wo(I),agentPath:I,message:"",model:null,agentType:null,timestamp:A,parentToolCallId:""}),d.set(I,D));let F;$.messageType==="FINAL_ANSWER"?F="completed":$.messageType==="ERROR"||$.messageType==="FAILED"?F="failed":$.messageType==="INTERRUPTED"?F="interrupted":$.messageType==="MESSAGE"&&(F="running"),m(D,p,A,{status:F,text:$.text||void 0});continue}if(_.type==="function_call"&&typeof _.call_id=="string"){const I=typeof _.name=="string"?_.name:"tool",R=yn(I),$=ip(_.arguments);let M=R,L=$;R==="exec_command"?M="Bash":R==="update_plan"?(M="TodoWrite",L=CC($)):NC(R)&&(M="AskUserQuestion",L=kC($)),R==="spawn_agent"&&l.set(_.call_id,{callId:_.call_id,message:LC($.message),taskName:typeof $.task_name=="string"?$.task_name:null,model:typeof $.model=="string"?$.model:null,agentType:typeof $.agent_type=="string"?$.agent_type:null,timestamp:A});const D={id:_.call_id,name:M,input:L,result:null,isError:!1,timestamp:A,...R==="request_user_input_async"?{asyncQuestion:!0}:{}};o.set(D.id,D),Gs(p,D,A);continue}if(_.type==="function_call_output"&&typeof _.call_id=="string"){const I=o.get(_.call_id);if(!I)continue;const R=Lc(_.output),$=R.text;if(I.result=$,I.isError=R.isError,R.images&&(I.resultImages=R.images),o.delete(_.call_id),I.name==="spawn_agent"&&$)try{const M=JSON.parse($),L=typeof M.agent_id=="string"?M.agent_id:u.get(I.id)??"",D=typeof M.task_name=="string"?M.task_name:null,F=typeof M.nickname=="string"?M.nickname:D?Wo(D):null;if(L){const z=l.get(I.id),O=c.get(L),H={agentId:L,nickname:F??(O==null?void 0:O.nickname)??(z==null?void 0:z.taskName)??null,agentPath:D??(O==null?void 0:O.agentPath)??null,message:(O==null?void 0:O.message)??(z==null?void 0:z.message)??"",model:(O==null?void 0:O.model)??(z==null?void 0:z.model)??null,agentType:(O==null?void 0:O.agentType)??(z==null?void 0:z.agentType)??null,timestamp:(O==null?void 0:O.timestamp)??(z==null?void 0:z.timestamp)??A,parentToolCallId:(O==null?void 0:O.parentToolCallId)??I.id};c.set(L,H),u.set(I.id,L),H.agentPath&&d.set(H.agentPath,L),m(L,p,A,{status:"running"})}}catch{}if(I.name==="wait_agent"&&$&&p)try{const M=JSON.parse($),L=Je(M.status)?M.status:{};for(const[D,F]of Object.entries(L)){const z=Je(F)?F:{},O=typeof z.completed=="string"?z.completed:"",H=typeof z.failed=="string"?z.failed:typeof z.error=="string"?z.error:"",W=typeof z.interrupted=="string"?z.interrupted:"",U=O?"completed":H?"failed":W?"interrupted":typeof z.status=="string"?z.status:"running";c.has(D)||c.set(D,{agentId:D,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:A,parentToolCallId:""}),m(D,p,A,{status:U,text:O||H||W||void 0})}}catch{}continue}if(_.type==="custom_tool_call"&&typeof _.call_id=="string"){const I=yn(typeof _.name=="string"?_.name:"tool"),R=typeof _.input=="string"?_.input:"",$=_.call_id,M=R?s0(I,R,$,A,t.cwd):[];if(I!=="apply_patch"){const L={id:$,name:I==="exec_command"?"Bash":I,input:ip(R),result:null,isError:!1,timestamp:A};o.set(L.id,L),Gs(p,L,A)}for(const L of M)o.set(L.id,L),Gs(p,L,A);M.length>0&&a.set($,{calls:M,direct:I==="apply_patch"});continue}if(_.type==="custom_tool_call_output"&&typeof _.call_id=="string"){const I=_.call_id,{text:R,isError:$,images:M}=Lc(_.output),L=a.get(I);if(L){const F=L.direct&&$?new Set(L.calls.map(z=>z.id)):yC(R,$,L.calls);for(const z of L.calls){const O=o.get(z.id);O&&(O.result=R,O.isError=F.has(O.id),o.delete(O.id))}a.delete(I)}const D=o.get(I);D&&(D.result=R,D.isError=$,M&&(D.resultImages=M),o.delete(I));continue}}}}}return C(p),{turnStartIndices:b,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?Ba(s.length):Ua(s),rawMessages:e!=null&&e.skipStats?[]:n,branchedFrom:t.branchedFrom,agentKind:"codex"}}function uu(n,e){const t=n.split(`
|
|
74
|
+
`).map(i=>i.trim()).filter(Boolean).map(du).filter(jo),{turnStartIndices:s,...o}=f0(t,e);return o}function VC(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
75
|
+
`);return uu(t?`${t}
|
|
76
|
+
${e}`:e)}const GC=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function YC(n){const e=n.content;return Array.isArray(e)?e.filter(t=>Je(t)&&t.type==="input_text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
77
|
+
`):""}function Ti(n){if(typeof n!="string")return null;try{const e=JSON.parse(n);return Je(e)?e:null}catch{return null}}function XC(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=Je(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=yn(typeof f.name=="string"?f.name:"");if(m==="spawn_agent"){const p=Ti(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=Ti(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=Ti(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=Ti(f.output),h=Je(p==null?void 0:p.status)?p.status:{};for(const[g,x]of Object.entries(h)){const v=Je(x)?x:{},w=typeof v.status=="string"?v.status:"";(typeof v.completed=="string"||typeof v.failed=="string"||typeof v.error=="string"||typeof v.interrupted=="string"||w==="completed"||w==="failed"||w==="interrupted")&&(t.add(g),e.delete(g))}}else if(a.has(m))for(const p of a.get(m)??[])t.add(p),e.delete(p);continue}if(f.type==="agent_message"&&typeof f.author=="string"){const p=((d=(c=YC(f).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:c[1])==null?void 0:d.trim().toUpperCase())??"";if(!GC.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 JC(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=XC(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?yn(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 QC(n,e,t){const s=Je(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 ZC(n){return f0(n,{skipStats:!0}).turnStartIndices}const e_=/^(?: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 Rt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function m0(n){return typeof n.agentId!="string"||n.agentId.length===0}function p0(n){return!Rt(n)||typeof n.type!="string"||!Rt(n.data)?!1:n.type==="abort"||n.type==="binary_asset"||n.type==="user.message"||e_.test(n.type)}function h0(n){try{const e=JSON.parse(n);return p0(e)?e:null}catch{return null}}function t_(n){return n.split(`
|
|
78
|
+
`).map(e=>e.trim()).filter(Boolean).map(h0).filter(e=>e!==null)}function Ce(...n){return n.find(e=>typeof e=="string")??""}function Kn(n){return typeof n=="number"&&Number.isFinite(n)?n:0}function Xo(n){return typeof n.timestamp=="string"?n.timestamp:""}function as(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 lp(n){const e=as(n,"copilot-turn"),t=Ce(n.data.turnId);return t?`${t}@${e}`:e}function Il(n,e){if(!Rt(n))return;const t=Ce(n.cwd),s=Ce(n.branch);t&&(e.cwd=t),s&&(e.gitBranch=s)}function g0(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(!m0(t))continue;const{data:s}=t,o=Xo(t);if(o&&(e.lastTimestamp=o),t.type==="session.start"){e.sessionId||(e.sessionId=Ce(s.sessionId)),e.version||(e.version=Ce(s.copilotVersion)||(typeof s.version=="number"?String(s.version):Ce(s.version))),Il(s.context,e),e.model=Ce(s.selectedModel)||e.model;continue}if(t.type==="session.resume"){Il(s.context,e),e.model=Ce(s.selectedModel)||e.model;continue}if(t.type==="session.context_changed"){Il(s,e);continue}if(t.type==="session.auto_mode_resolved"){e.model=Ce(s.chosenModel)||e.model;continue}if(t.type==="session.model_change"){e.model=Ce(s.newModel)||e.model;continue}if(t.type==="session.title_changed"){e.name=Ce(s.title)||e.name;continue}if(t.type==="session.shutdown"){e.model=Ce(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=Ce(s.model)||e.model),t.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=o);const i=Ce(s.content).trim();i&&(e.firstUserMessage||(e.firstUserMessage=i),e.lastUserMessage=i)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function n_(n){for(const e of n.split(`
|
|
79
|
+
`)){const t=e.trim();if(t)try{const s=JSON.parse(t);if(p0(s))return!0}catch{}}return!1}function s_(n){var e;return x_((e=n[0])==null?void 0:e.type)}function o_(n){const e=n.map(t=>h0(t.trim())).filter(t=>t!==null);return g0(e)}function Rl(n){if(typeof n=="string")return n;if(n===void 0)return"";try{return JSON.stringify(n)}catch{return String(n)}}function cp(n){return typeof n=="string"?n:Array.isArray(n)?n.flatMap(e=>{const t=typeof e=="string"?e:Rt(e)?Ce(e.text,e.content):"";return t?[t]:[]}).join(`
|
|
80
|
+
`):""}function r_(n){const e=new Map;for(const t of n){if(t.type!=="session.binary_asset"&&t.type!=="binary_asset")continue;const s=Ce(t.data.assetId),o=Ce(t.data.data),i=Ce(t.data.mimeType);s&&o&&i&&e.set(s,{data:o,mimeType:i})}return e}function i_(n,e){if(!Rt(n))return null;const t=e.get(Ce(n.assetId)),s=Ce(n.mimeType,t==null?void 0:t.mimeType).toLowerCase(),o=Ce(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 x0(n,e){if(!Array.isArray(n))return[];const t=[],s=new Set;for(const o of n){const i=i_(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 a_(n,e){const t=Ce(n.content),s=x0(n.attachments,e);return s.length===0?t:[...s,...t?[{type:"text",text:t}]:[]]}function l_(n,e){return Rt(n.result)?x0([...Array.isArray(n.result.contents)?n.result.contents:[],...Array.isArray(n.result.binaryResultsForLlm)?n.result.binaryResultsForLlm:[]],e):[]}function zc(n,e=!1){const t=Kn(n.cacheWriteTokens),s=Kn(n.cacheReadTokens),o=Kn(n.inputTokens),i={input_tokens:e?Math.max(0,o-t-s):o,output_tokens:Kn(n.outputTokens),cache_creation_input_tokens:t,cache_read_input_tokens:s},a=Kn(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 c_(n){if(!Rt(n.modelMetrics))return null;let e=null;for(const t of Object.values(n.modelMetrics)){if(!Rt(t)||!Rt(t.usage))continue;const s=zc(t.usage,!0);s&&(e=po(e,s))}return e}function d_(n){if(typeof n=="string")return{label:n};if(!Rt(n))return null;const e=Ce(n.label,n.title,n.value,n.name);if(!e)return null;const t=Ce(n.description);return t?{label:e,description:t}:{label:e}}function u_(n){return Array.isArray(n)?n.map(d_).filter(e=>e!==null):[]}function f_(n){if(!Rt(n))return null;const e=Ce(n.question,n.prompt,n.text,n.message);if(!e)return null;const t=Ce(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:u_(n.options??n.choices),...s===void 0?{}:{multiSelect:s}}}function m_(n){const t=(Array.isArray(n.questions)?n.questions:[n]).map(f_).filter(s=>s!==null);return t.length>0?{...n,questions:t}:n}function Jo(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 ta(n,e){const t=Rt(e)?e:e===void 0?{}:{value:e};return n==="AskUserQuestion"?m_(t):n==="Edit"?{...t,file_path:Ce(t.file_path,t.path),old_string:Ce(t.old_string,t.old_str),new_string:Ce(t.new_string,t.new_str)}:n==="Write"?{...t,file_path:Ce(t.file_path,t.path),content:Ce(t.content,t.file_text)}:n==="Bash"&&typeof t.command!="string"&&typeof t.cmd=="string"?{...t,command:t.cmd}:t}function p_(n){const e=n.error;if(typeof e=="string")return e;if(Rt(e)){const s=Ce(e.message,e.code);if(s)return s}const t=n.result;if(typeof t=="string")return t;if(!Rt(t))return t===void 0?"":Rl(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:Rt(o)?Ce(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
|
|
81
|
+
`);if(s)return s}return t.structuredContent!==void 0?Rl(t.structuredContent):Rl(t)}function dp(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 Ei(n,e,t){n.toolCalls.push(e);const s=n.contentBlocks[n.contentBlocks.length-1];if((s==null?void 0:s.kind)==="tool_calls"){s.toolCalls.push(e);return}n.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:t})}function Qo(n,e,t,s){return{id:n,name:e,input:t,result:null,isError:!1,timestamp:s}}function up(n,e,t){if(!Array.isArray(n))return[];const s=[];for(const o of n){if(!Rt(o))continue;const i=Ce(o.toolCallId),a=Ce(o.name);if(!i||!a||t(i))continue;const l=Jo(a);s.push(Qo(i,l,ta(l,o.arguments),e))}return s}function fp(n,e,t,s){n.name=e,n.input=ta(e,t),n.timestamp=s||n.timestamp}function mp(n,e,t){n.result=p_(e);const s=l_(e,t);s.length>0&&(n.resultImages=s),n.isError=e.success===!1||e.error!==void 0&&e.error!==null}function pp(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 h_(n){return n.userMessage!==null||n.assistantText.length>0||n.thinking.length>0||n.toolCalls.length>0||n.subAgentActivity.length>0}function b0(n,e){const t=t_(n),s=g0(t),o=r_(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 v(C,k){k&&d.set(C,k)}function w(C){return f||(f=pp(lp(C),Xo(C),null,m,p,!0)),f}function b(){f&&(h_(f)&&i.push(f),f=null)}function j(C){var R;const k=typeof C.agentId=="string"?C.agentId:"";if(!k)return null;const T=l.get(k);if(T)return T.message;const E=C.data,P=Ce(E.toolCallId),_=P?((R=a.get(P))==null?void 0:R.turn)??f:f;if(!_)return null;const A=Ce(E.executionMode),I={agentId:k,...P?{parentToolUseId:P}:{},agentName:Ce(E.agentDisplayName,E.agentName)||null,subagentType:Ce(E.agentType,E.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:Xo(C),tokenUsage:null,model:Ce(E.model)||null,isBackground:A==="background",...Ce(E.description)?{prompt:Ce(E.description)}:{},status:"running"};return _.subAgentActivity.push(I),_.contentBlocks.push({kind:I.isBackground?"background_agent":"sub_agent",messages:[I],timestamp:I.timestamp}),l.set(k,{message:I,turn:_}),I}function S(C){if(m0(C))return!1;const k=j(C);if(!k)return!0;const{data:T}=C,E=Xo(C);if(C.type==="subagent.started"||C.type==="subagent.configured")return k.parentToolUseId||(k.parentToolUseId=Ce(T.toolCallId)||void 0),k.agentName=Ce(T.agentDisplayName,T.agentName)||k.agentName,k.subagentType=Ce(T.agentType,T.agentName)||k.subagentType,k.model=Ce(T.model)||k.model,k.prompt||(k.prompt=Ce(T.description)||void 0),k.isBackground||(k.isBackground=Ce(T.executionMode)==="background"),k.status="running",!0;if(C.type==="subagent.completed"||C.type==="subagent.failed"){k.agentName=Ce(T.agentDisplayName,T.agentName)||k.agentName,k.subagentType=Ce(T.agentType,T.agentName)||k.subagentType,k.model=Ce(T.model)||k.model,k.durationMs=Kn(T.durationMs)||k.durationMs,k.toolUseCount=Kn(T.totalToolCalls)||k.toolUseCount,k.status=C.type==="subagent.completed"?"completed":"failed";const P=Ce(T.error,T.message);return P&&!k.text.includes(P)&&k.text.push(P),!0}if(C.type==="user.message")return k.prompt||(k.prompt=Ce(T.content)||void 0),!0;if(C.type==="assistant.reasoning"){const P=Ce(T.content);return P&&!k.thinking.includes(P)&&k.thinking.push(P),!0}if(C.type==="assistant.message"){k.model=Ce(T.model)||k.model;const P=Ce(T.reasoningText);P&&!k.thinking.includes(P)&&k.thinking.push(P);const _=cp(T.content);_&&!k.text.includes(_)&&k.text.push(_);for(const A of up(T.toolRequests,E,I=>c.has(I)))k.toolCalls.push(A),c.set(A.id,{call:A,message:k});return!0}if(C.type==="assistant.usage"){k.model=Ce(T.model)||k.model;const P=zc(T);return P&&(k.tokenUsage=po(k.tokenUsage,P)),!0}if(C.type==="tool.execution_start"){const P=Ce(T.toolCallId)||as(C,"copilot-agent-tool"),_=Ce(T.toolName)||"Tool",A=Jo(_),I=c.get(P);if(I)fp(I.call,A,T.arguments,E);else{const R=Qo(P,A,ta(A,T.arguments),E);k.toolCalls.push(R),c.set(P,{call:R,message:k})}return!0}if(C.type==="tool.execution_complete"){const P=Ce(T.toolCallId)||as(C,"copilot-agent-tool");let _=c.get(P);if(!_){const A=Ce(T.toolName)||"Tool",I=Jo(A),R=Qo(P,I,{},E);k.toolCalls.push(R),_={call:R,message:k}}return mp(_.call,T,o),c.delete(P),!0}return!0}for(const C of t){if(S(C))continue;const{data:k}=C,T=Xo(C);if(C.type==="session.start"||C.type==="session.resume"){m=Ce(k.selectedModel)||m,p=Ce(k.reasoningEffort)||p;continue}if(C.type==="session.auto_mode_resolved"){m=Ce(k.chosenModel)||m,f&&(f.model=m);continue}if(C.type==="session.model_change"){m=Ce(k.newModel)||m;const E=k.reasoningEffort;typeof E=="string"&&(p=E),f&&(f.model=m,p&&(f.effort=p));continue}if(C.type==="session.shutdown"){m=Ce(k.currentModel)||m,f&&!f.model&&(f.model=m),x=c_(k)??x;const E=Kn(k.totalApiDurationMs);f&&!g&&E&&u.set(f,E);continue}if(C.type==="user.message"){b(),f=pp(lp(C),T,a_(k,o),m,p,!1),v(f,T);continue}if(C.type==="assistant.turn_start"){m=Ce(k.model)||m;const E=w(C);E.model=m,p&&(E.effort=p),v(E,T);continue}if(C.type==="assistant.reasoning"){const E=w(C);dp(E,Ce(k.content),T,Ce(k.reasoningId)||as(C,"copilot-thinking")),v(E,T);continue}if(C.type==="assistant.message"){m=Ce(k.model)||m;const E=w(C);E.model=m,p&&(E.effort=p),dp(E,Ce(k.reasoningText),T,as(C,"copilot-thinking")),n0(E,cp(k.content),T);for(const P of up(k.toolRequests,T,_=>a.has(_)))Ei(E,P,T),a.set(P.id,{call:P,turn:E});v(E,T);continue}if(C.type==="assistant.usage"){m=Ce(k.model)||m,p=Ce(k.reasoningEffort)||p;const E=zc(k),P=Kn(k.duration);E&&(h=!0),P&&(g=!0);const _=w(C);_.model=m,p&&(_.effort=p),E&&(_.tokenUsage=po(_.tokenUsage,E)),P&&u.set(_,(u.get(_)??0)+P),v(_,T);continue}if(C.type==="tool.execution_start"){m=Ce(k.model)||m;const E=w(C);E.model=m;const P=Ce(k.toolCallId)||as(C,"copilot-tool"),_=Ce(k.toolName)||"Tool",A=Jo(_),I=a.get(P);if(I)fp(I.call,A,k.arguments,T);else{const R=Qo(P,A,ta(A,k.arguments),T);Ei(E,R,T),a.set(P,{call:R,turn:E})}v(E,T);continue}if(C.type==="tool.execution_complete"){m=Ce(k.model)||m;const E=Ce(k.toolCallId)||as(C,"copilot-tool");let P=a.get(E);if(!P){const _=w(C),A=Ce(k.toolName)||"Tool",I=Jo(A),R=Qo(E,I,{},T);Ei(_,R,T),P={call:R,turn:_}}mp(P.call,k,o),a.delete(E),v(P.turn,T);continue}if(C.type==="session.error"){const E=w(C),_={errorType:Ce(k.errorType)||"unknown"};typeof k.statusCode=="number"&&(_.statusCode=k.statusCode),typeof k.errorCode=="string"&&(_.errorCode=k.errorCode),Ei(E,{id:as(C,"copilot-error"),name:"Error",input:_,result:Ce(k.message)||"Copilot session error",isError:!0,timestamp:T},T),v(E,T);continue}(C.type==="assistant.turn_end"||C.type==="assistant.idle"||C.type==="session.idle")&&f&&v(f,T)}if(b(),!h&&x&&i.length===1&&(i[0].tokenUsage=po(i[0].tokenUsage,x)),s.model)for(const C of i)C.model||(C.model=s.model);for(const C of i){const k=d.get(C),T=Date.parse(C.timestamp),E=k?Date.parse(k):Number.NaN;if(Number.isFinite(T)&&Number.isFinite(E)&&E>=T)C.durationMs=E-T;else{const P=u.get(C)??0;P&&(C.durationMs=P)}}const N=e!=null&&e.skipStats?Ba(i.length):Ua(i);return!(e!=null&&e.skipStats)&&!h&&x&&i.length>1&&(N.totalInputTokens=x.input_tokens,N.totalOutputTokens=x.output_tokens,N.totalCacheCreationTokens=x.cache_creation_input_tokens??0,N.totalCacheReadTokens=x.cache_read_input_tokens??0),{sessionId:s.sessionId,version:s.version,gitBranch:s.gitBranch,cwd:s.cwd,slug:s.slug,name:s.name,model:s.model,turns:i,stats:N,rawMessages:e!=null&&e.skipStats?[]:t,agentKind:"copilot"}}function g_(n,e){const t=n.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
82
|
+
`);return b0(t?`${t}
|
|
83
|
+
${e}`:e)}function x_(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 b_(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=Rt(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=Rt(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=Rt(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"?yn(a.toolName):typeof a.name=="string"?yn(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 v_(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function y_(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 v0=bs[bs.length-1],w_={kind:"codex",descriptor:on("codex"),detectsText:u0,detectsRecords:qC,parse:uu,append:VC,metadataFromLines:KC,status:JC,brandBranch:QC,turnBoundaries:ZC},j_={kind:"copilot",descriptor:on("copilot"),detectsText:n_,detectsRecords:s_,parse:b0,append:g_,metadataFromLines:o_,status:b_,brandBranch:v_,turnBoundaries:y_},S_={kind:"claude",descriptor:on("claude"),detectsText:ep,detectsRecords:ep,parse:cC,append:dC,metadataFromLines:lC,status:gC,brandBranch:xC,turnBoundaries:bC},Ui=Object.freeze({claude:S_,codex:w_,copilot:j_});function y0(n){for(const e of bs)if(n(Ui[e]))return Ui[e];return Ui[v0]}function w0(n){return Ui[n]}function j0(n){return y0(e=>e.detectsText(n))}function S0(n){return y0(e=>e.detectsRecords(n))}function N0(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 k0(n,e,t){return N0(n,e)[t]??e.length}function N_(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:N0(n,e).find(o=>o>s)??"keep-all"}function k_(n){return au(n)?qx(n.input):[n]}function C_(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 __(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 T_(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==="queued_prompt")}function E_(n){for(let e=n.toolCalls.length-1;e>=0;e--){const t=n.toolCalls[e];if(!t.asyncQuestion||t.isError)continue;if(T_(n,t.id))return null;const s=t.input.questions;if(s&&s.length>0)return{type:"question",toolUseId:t.id,questions:s}}return null}function A_(n,e){const t=e.toolCalls[e.toolCalls.length-1];if(!t||t.asyncQuestion)return null;const{name:s}=t;if(s!=="ExitPlanMode"&&s!=="AskUserQuestion"||t.result!==null&&!t.isError||C_(n,s)||t.isError&&__(e,t.id))return null;const o=t.input;if(s==="ExitPlanMode")return{type:"plan",allowedPrompts:o.allowedPrompts};const i=o.questions;return i&&i.length>0?{type:"question",toolUseId:t.id,questions:i}:null}function C0(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];return!t||t.toolCalls.length===0?null:A_(e,t)??E_(t)}function P_(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
84
|
+
`)}function Ha(n,e){return j0(n).parse(n,e)}function $_(n,e){const t=S0(n.rawMessages);return(t.kind===v0?j0(e):t).append(n,e)}function qa(n){return n===null?"":typeof n=="string"?n:P_(n)}function _0(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const T0=y.createContext(null);function I_(n){const e=[];for(let t=0;t<n.length;t+=1){const s=n[t],o=_0(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 R_(n){const e=B.c(10),{images:t,children:s}=n,[o,i]=y.useState(null);let a;e[0]!==t?(a=m=>{const p=t.findIndex(g=>g.src===m.src),h=p>=0?t:[...t,{...m,id:m.id??`supplemental-image-${t.length}`}];i(g=>({key:((g==null?void 0:g.key)??0)+1,open:!0,images:h,index:p>=0?p:h.length-1}))},e[0]=t,e[1]=a):a=e[1];const l=a;let c;e[2]!==l?(c={openImage:l},e[2]=l,e[3]=c):c=e[3];const d=c;let u;e[4]!==o?(u=o&&r.jsx(ou,{open:o.open,images:o.images,initialIndex:o.index,onClose:()=>i(M_),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(T0.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f}function M_(n){return n?{...n,open:!1}:null}function O_(n){const e=B.c(7),{children:t}=n,{session:s}=st();s==null||s.turns;let o;e[0]!==(s==null?void 0:s.turns)?(o=(s==null?void 0:s.turns)??[],e[0]=s==null?void 0:s.turns,e[1]=o):o=e[1];let i;e[2]!==o?(i=I_(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(R_,{images:a,children:t}),e[4]=t,e[5]=a,e[6]=l):l=e[6],l}function E0(){return y.useContext(T0)}const A0=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function L_(n){if(!n)return!1;const e=n.lastIndexOf(".");return e===-1?!1:A0.has(n.slice(e).toLowerCase())}function fu(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")||!n.startsWith("/")?!1:L_(n)}function D_(n){return n&&(fu(n)?Lr(`/api/local-file?path=${encodeURIComponent(n)}`):n)}function Fc(n){const e=B.c(41),{src:t,alt:s,id:o,className:i,thumbnailClassName:a}=n,l=o===void 0?"markdown-image":o,c=jn("hostFiles"),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=y.useState(),g=E0();let x;e[0]!==c||e[1]!==t?(x=fu(t)&&!c,e[0]=c,e[1]=t,e[2]=x):x=e[2];const v=x;let w;e[3]!==v||e[4]!==t?(w=v?void 0:D_(t),e[3]=v,e[4]=t,e[5]=w):w=e[5];const b=w;let j;e[6]!==s||e[7]!==l||e[8]!==b?(j=b?{id:l,src:b,alt:s??"Rendered image",label:s||"Rendered image"}:null,e[6]=s,e[7]=l,e[8]=b,e[9]=j):j=e[9];const S=j;let N;e[10]!==g||e[11]!==S?(N=()=>{S&&(g?g.openImage(S):(m(!0),u(!0)))},e[10]=g,e[11]=S,e[12]=N):N=e[12];const C=N;if(v){let L;return e[13]!==s?(L=s?r.jsx("span",{className:"text-muted-foreground",children:s}):null,e[13]=s,e[14]=L):L=e[14],L}if(b&&p===b){const L=s?`: ${s}`:"";let D;return e[15]!==L?(D=r.jsxs("span",{role:"status",className:"my-3 block text-xs text-muted-foreground",children:["Image unavailable",L]}),e[15]=L,e[16]=D):D=e[16],D}const k=`Open ${s||"rendered image"}`;let T;e[17]!==i?(T=K("group/image relative my-3 block h-auto max-w-full overflow-hidden rounded-lg border border-border bg-background p-1 transition-colors hover:bg-muted focus-visible:ring-ring/40",i),e[17]=i,e[18]=T):T=e[18];const E=s??"";let P;e[19]!==b?(P=()=>h(b),e[19]=b,e[20]=P):P=e[20];let _;e[21]!==a?(_=K("max-h-96 max-w-full rounded-lg object-contain",a),e[21]=a,e[22]=_):_=e[22];let A;e[23]!==b||e[24]!==_||e[25]!==E||e[26]!==P?(A=r.jsx("img",{src:b,alt:E,loading:"lazy",decoding:"async",onError:P,className:_}),e[23]=b,e[24]=_,e[25]=E,e[26]=P,e[27]=A):A=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("span",{className:"absolute right-2 top-2 flex size-7 items-center justify-center rounded-md border border-white/10 bg-black/45 text-white/70 opacity-80 backdrop-blur transition-[color,background-color,opacity] group-hover/image:bg-black/65 group-hover/image:text-white sm:opacity-0 sm:group-hover/image:opacity-100 sm:group-focus-visible/image:opacity-100",children:r.jsx(xa,{className:"size-3.5","data-icon":"icon"})}),e[28]=I):I=e[28];let R;e[29]!==C||e[30]!==A||e[31]!==k||e[32]!==T?(R=r.jsxs(ee,{type:"button",variant:"ghost",onClick:C,"aria-label":k,className:T,children:[A,I]}),e[29]=C,e[30]=A,e[31]=k,e[32]=T,e[33]=R):R=e[33];let $;e[34]!==d||e[35]!==f||e[36]!==S?($=f&&S&&r.jsx(ou,{open:d,images:[S],initialIndex:0,onClose:()=>u(!1),onCloseComplete:()=>m(!1)}),e[34]=d,e[35]=f,e[36]=S,e[37]=$):$=e[37];let M;return e[38]!==R||e[39]!==$?(M=r.jsxs(r.Fragment,{children:[R,$]}),e[38]=R,e[39]=$,e[40]=M):M=e[40],M}function z_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 F_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("[&_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 B_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("[&_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 U_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 W_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 H_(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 q_(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 K_(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=jn("hostFiles");let a;e[4]!==s?(a=q_(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?gr(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 V_=[...A0].map(n=>n.slice(1)).join("|"),G_=new RegExp(`^([ \\t]*)(\\/[^\\s]+\\.(?:${V_}))[ \\t]*$`,"gim");function P0(n){return n.replace(G_,(e,t,s)=>`${t}`)}const Fn={code:pk,pre({children:n}){return r.jsx(r.Fragment,{children:n})},a:K_,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(wt,{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(z_,{className:"border-collapse text-sm",children:n})})},thead({children:n}){return r.jsx(F_,{className:"bg-muted/50",children:n})},tbody({children:n}){return r.jsx(B_,{children:n})},tr({children:n}){return r.jsx(U_,{className:"even:bg-muted/20",children:n})},th({children:n}){return r.jsx(W_,{className:"h-9 px-3 py-2 text-xs font-medium text-muted-foreground",children:n})},td({children:n}){return r.jsx(H_,{className:"px-3 py-2 text-foreground/90",children:n})},strong({children:n}){return r.jsx("strong",{className:"font-semibold text-foreground",children:n})},em({children:n}){return r.jsx("em",{className:"italic text-foreground/90",children:n})},del({children:n}){return r.jsx("del",{className:"line-through text-muted-foreground",children:n})},img:Fc,input({checked:n,...e}){return r.jsx("input",{type:"checkbox",checked:n,readOnly:!0,className:"mr-2 rounded border-border accent-primary",...e})}},Bn=[Hw],Y_=["system-reminder","local-command-caveat","command-name","command-message","command-args","env","claude_background_info","fast_mode_info","gitStatus","user-prompt-submit-hook"],X_=Y_.join("|");function $0(){return new RegExp(`<(${X_})[^>]*>[\\s\\S]*?<\\/\\1>`,"g")}function I0(n){return n.replace($0(),"").trim()}function J_(n){return $0().test(n)}const Q_=/<command-message>([^<]+)<\/command-message>/,Z_=/<command-name>([\s\S]*?)<\/command-name>/,e7=/<command-args>([\s\S]*?)<\/command-args>/;function R0(n){const e=n.match(Q_);if(e)return e[1];const t=n.match(Z_);return t?t[1].trim().replace(/^\//,""):null}function M0(n){const e=n.match(e7);if(!e)return null;const t=e[1].trim();return t.length>0?t:null}const O0={"local-command-stdout":"stdout","local-command-stderr":"stderr","bash-input":"input","bash-stdout":"stdout","bash-stderr":"stderr"},t7=new RegExp(`<(${Object.keys(O0).join("|")})>([\\s\\S]*?)<\\/\\1>`,"g");function n7(n){const e=[],t=n.replace(t7,(s,o,i)=>(e.push({text:Gg(i).trim(),stream:O0[o]}),"")).trim();return{outputs:e,remainingText:t}}const s7=/<task-notification>([\s\S]*?)<\/task-notification>/g;function Ys(n,e){const t=n.match(new RegExp(`<${e}>([\\s\\S]*?)<\\/${e}>`));return t?t[1].trim():""}function mu(n){const e=[],t=n.replace(s7,(s,o)=>(e.push({taskId:Ys(o,"task-id"),toolUseId:Ys(o,"tool-use-id"),outputFile:Ys(o,"output-file"),status:Ys(o,"status"),summary:Ys(o,"summary"),result:Ys(o,"result")}),"")).trim();return{notifications:e,remainingText:t}}const o7=/\[Request interrupted by user[^\]]*\]/g;function r7(n){const e=[],t=n.replace(o7,s=>(e.push(s),"")).trim();return{interrupts:e,remainingText:t}}const hp="[SYSTEM NOTIFICATION - NOT USER INPUT]";function i7(n){const e=n.indexOf(hp);if(e===-1)return{text:n,isSystemNotification:!1};const t=e+hp.length,s=n.indexOf(`
|
|
85
|
+
|
|
86
|
+
`,t),o=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(o)).trim(),isSystemNotification:!0}}const gp={Icon:cN,color:"text-destructive",bg:"border-destructive/20 bg-destructive/5",badgeVariant:"destructive"},xp={completed:{Icon:lN,color:"text-success",bg:"border-success/20 bg-success/5",badgeVariant:"secondary",label:"Completed"},failed:{...gp,label:"Failed"},error:{...gp,label:"Error"},running:{Icon:dN,color:"text-warning",bg:"border-warning/20 bg-warning/5",badgeVariant:"outline",label:"Running"}};function L0(n){const e=B.c(32),{notification:t}=n,[s,o]=y.useState(!1),i=xp[t.status]??xp.running,{Icon:a}=i,l=t.result.length>0||t.outputFile.length>0,c=s?nt:Ve;let d;e[0]!==i.bg?(d=K("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=K("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(Ie,{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(Pt,{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(dt,{children:r.jsxs("div",{className:"mt-2 border-t border-border/30 pt-2 text-sm text-foreground/90",children:[t.result&&r.jsx(Ln,{components:Fn,remarkPlugins:Bn,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 v;e[25]!==f||e[26]!==x?(v=r.jsxs("div",{className:"flex items-start gap-2",children:[f,x]}),e[25]=f,e[26]=x,e[27]=v):v=e[27];let w;return e[28]!==s||e[29]!==d||e[30]!==v?(w=r.jsx(ct,{open:s,onOpenChange:o,className:d,children:v}),e[28]=s,e[29]=d,e[30]=v,e[31]=w):w=e[31],w}function a7(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}=mu(t);if(l.length===0){i=null;break e}s="flex flex-col",o=l.map(l7)}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 l7(n,e){return r.jsx(L0,{notification:n},n.taskId||`notification-${e}`)}function c7(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=K("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(Ve,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(go,{className:K("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 d7(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(Yg,{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(Ln,{components:Fn,remarkPlugins:Bn,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 pu=y.memo(function({content:e,timestamp:t,onEditCommand:s,onExpandCommand:o,compact:i=!1}){const a=E0(),[l,c]=y.useState(!1),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),[v,w]=y.useState(null),b=y.useMemo(()=>qa(e),[e]),j=y.useMemo(()=>R0(b),[b]),S=y.useMemo(()=>M0(b),[b]),{sender:N,body:C,matched:k}=y.useMemo(()=>yr(b),[b]),T=y.useMemo(()=>I0(C),[C]),{text:E,isSystemNotification:P}=y.useMemo(()=>i7(T),[T]),{notifications:_,remainingText:A}=y.useMemo(()=>mu(E),[E]),{outputs:I,remainingText:R}=y.useMemo(()=>n7(A),[A]),{interrupts:$,remainingText:M}=y.useMemo(()=>r7(R),[R]),L=y.useCallback(async q=>{if(!q){m(!1);return}if(p!==null){m(!0);return}if(!(!o||!j)){x(!0),m(!0);try{const X=await o(j,S??void 0);h(X)}finally{x(!1)}}},[p,o,j,S]),D=y.useMemo(()=>_0(e),[e]),F=y.useMemo(()=>D.map(q=>`data:${q.source.media_type};base64,${q.source.data}`),[D]),z=y.useMemo(()=>F.map((q,X)=>({id:`message-attachment-${X}`,src:q,alt:`Attachment ${X+1}`,label:F.length>1?`Attachment ${X+1}`:"Attached image"})),[F]),O=y.useMemo(()=>J_(b)||P||k,[b,P,k]),H=d?b:M,U=H.length>500&&!l?H.slice(0,500)+"...":H,V=q=>{const X=z[q];X&&(a?a.openImage(X):w({index:q,open:!0}))};return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:O&&r.jsx(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(ba,{"data-icon":"inline-start"})," Hide raw"]}):r.jsxs(r.Fragment,{children:[r.jsx(gs,{"data-icon":"inline-start"})," Show raw"]})})}),!d&&P&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ie,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(go,{"data-icon":"inline-start"}),"System event"]})}),!d&&k&&r.jsx("div",{className:"mb-2",children:r.jsxs(Ie,{variant:"outline",className:"text-muted-foreground",children:[r.jsx(Zn,{"data-icon":"inline-start"}),N?`From ${N}`:"Teammate message"]})}),j&&r.jsxs(ct,{open:f,onOpenChange:q=>void L(q),className:"mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ie,{variant:"outline",className:"font-mono text-foreground",children:[r.jsx(go,{"data-icon":"inline-start"}),"/",j,S&&r.jsx("span",{className:"text-muted-foreground",children:S})]}),o&&r.jsxs(Pt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground"}),children:[f?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Ve,{"data-icon":"inline-start"}),f?"Collapse":"Expand"]}),f&&s&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s(j),className:"text-muted-foreground",children:[r.jsx(Us,{"data-icon":"inline-start"}),"Edit"]})]}),r.jsx(dt,{children:r.jsx(d7,{loading:g,content:p})})]}),F.length>0&&r.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:F.map((q,X)=>r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>V(X),"aria-label":`Open attached image ${X+1}`,className:K("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 ${X+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(xa,{className:"size-3.5","data-icon":"icon"})}),F.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:[X+1," / ",F.length]})]},`${D[X].source.media_type}-${D[X].source.data.slice(0,24)}-${X}`))}),!d&&_.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-2",children:_.map(q=>r.jsx(L0,{notification:q},q.taskId))}),!d&&I.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:I.map((q,X)=>r.jsx(c7,{output:q},X))}),!d&&$.length>0&&r.jsx("div",{className:"mb-2 flex flex-col gap-1",children:$.map((q,X)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-destructive",children:[r.jsx(U3,{className:"size-3 shrink-0","data-icon":"inline-start"}),r.jsx("span",{children:q})]},X))}),U&&r.jsx("div",{className:"max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Ln,{components:Fn,remarkPlugins:Bn,children:U})}),H.length>500&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>c(!l),className:"mt-1 -ml-2 text-muted-foreground",children:l?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ve,{"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()})})]}),v!==null&&r.jsx(ou,{open:v.open,images:z,initialIndex:v.index,onClose:()=>w(q=>q?{...q,open:!1}:null),onCloseComplete:()=>w(null)},v.index)]})}),D0=y.memo(function(e){const t=B.c(10),{message:s,turnNumber:o}=e;let i;t[0]!==o?(i=r.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Turn ",o]}),t[0]=o,t[1]=i):i=t[1];let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Ie,{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(pu,{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}),z0=y.memo(function(e){const t=B.c(30),{progress:s,expanded:o,onExpandedChange:i}=e,[a,l]=y.useState(!1),c=o??a,{todos:d,completed:u,total:f}=s,m=f>0?u/f*100:0;let p;t[0]!==i?(p=E=>{i==null||i(E),l(E)},t[0]=i,t[1]=p):p=t[1];let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-none px-3 py-2"}),t[2]=h):h=t[2];let g;t[3]!==c?(g=c?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Er,{"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 v;t[6]!==u||t[7]!==f?(v=r.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:[u,"/",f]}),t[6]=u,t[7]=f,t[8]=v):v=t[8];let w;t[9]!==m?(w=m.toFixed(0),t[9]=m,t[10]=w):w=t[10];const b=`${w}% of tasks complete`;let j;t[11]!==m||t[12]!==b?(j=r.jsx(Wr,{value:m,className:"max-w-[200px] flex-1","aria-label":b}),t[11]=m,t[12]=b,t[13]=j):j=t[13];let S;t[14]!==s.inProgress?(S=s.inProgress&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate text-xs text-info",children:[r.jsx(tt,{className:"size-3 shrink-0 animate-spin"}),r.jsx("span",{className:"truncate",children:s.inProgress.activeForm})]}),t[14]=s.inProgress,t[15]=S):S=t[15];let N;t[16]!==g||t[17]!==v||t[18]!==j||t[19]!==S?(N=r.jsxs(Pt,{render:h,children:[g,x,v,j,S]}),t[16]=g,t[17]=v,t[18]=j,t[19]=S,t[20]=N):N=t[20];let C;t[21]!==d?(C=d.map(u7),t[21]=d,t[22]=C):C=t[22];let k;t[23]!==C?(k=r.jsx(dt,{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]=k):k=t[24];let T;return t[25]!==c||t[26]!==p||t[27]!==N||t[28]!==k?(T=r.jsxs(ct,{open:c,onOpenChange:p,className:"shrink-0 border-t bg-background",children:[N,k]}),t[25]=c,t[26]=p,t[27]=N,t[28]=k,t[29]=T):T=t[29],T});function u7(n,e){return r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.status==="completed"?r.jsx(On,{className:"size-3 shrink-0 text-success"}):n.status==="in_progress"?r.jsx(tt,{className:"size-3 shrink-0 animate-spin text-info"}):r.jsx(va,{className:"size-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:K("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 Io(n,e){const t=B.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const d=localStorage.getItem(n);return d===null?e:JSON.parse(d)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[o,i]=y.useState(s);let a;t[3]!==n?(a=d=>{i(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 F0(n){return`${n.provider}:${n.latestVersion??"unknown"}`}function f7(n,e){const t=e.split(":")[0];return[...n.filter(s=>s.split(":")[0]!==t),e]}const m7="cogpit:provider-update-dismissals:v1";function p7(n,e){return n.filter(t=>t.status==="behind"&&!e.includes(F0(t)))}async function h7(n){const e=await _e("/api/provider-updates",{signal:n});if(!e.ok)throw new Error(`Provider update check failed (${e.status})`);return(await e.json()).providers??[]}async function g7(n){const e=await Dn("/api/provider-updates/run",{provider:n}),t=await e.json();if(!t.status)throw new Error(t.error??`Update failed (${e.status})`);return t}const x7=360*60*1e3;function b7(){const[n,e]=y.useState([]),[t,s]=Io(m7,[]),[o,i]=y.useState(null),[a,l]=y.useState(null);y.useEffect(()=>{const u=new AbortController,f=()=>{h7(u.signal).then(e).catch(()=>{})};f();const m=setInterval(f,x7);return()=>{u.abort(),clearInterval(m)}},[]);const c=y.useCallback(async u=>{i(u),l(null);try{const f=await g7(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=y.useCallback(u=>{s(f=>f7(f,F0(u)))},[s]);return{pending:p7(n,t),updating:o,outcome:a,update:c,dismiss:d,clearOutcome:y.useCallback(()=>l(null),[])}}const v7=5e3,y7={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 Ml(n){return`grid-cols-[auto_minmax(0,1fr)_auto] rounded-none border-x-0 border-t-0 px-4 py-2 ${y7[n]}`}function bp(n){const e=n.currentVersion?`v${n.currentVersion}`:"an older build";return`${n.displayName} ${e} → v${n.latestVersion}`}function B0(){const n=B.c(39),{pending:e,updating:t,outcome:s,update:o,dismiss:i,clearOutcome:a}=b7(),l=et("configWrite"),c=(s==null?void 0:s.status)==="succeeded";let d,u;if(n[0]!==a||n[1]!==c?(d=()=>{if(!c)return;const A=setTimeout(a,v7);return()=>clearTimeout(A)},u=[c,a],n[0]=a,n[1]=c,n[2]=d,n[3]=u):(d=n[2],u=n[3]),y.useEffect(d,u),s){let A;return n[4]!==a||n[5]!==s.message||n[6]!==c?(A=c?r.jsxs(ft,{className:Ml("success"),children:[r.jsx(Pr,{}),r.jsx(kt,{children:s.message}),r.jsx(mt,{className:"text-success/80",children:"New sessions will use the updated CLI."})]}):r.jsxs(ft,{className:Ml("destructive"),children:[r.jsx(Hs,{}),r.jsx(kt,{children:"Update did not complete"}),r.jsx(mt,{className:"text-destructive/80",children:s.message}),r.jsx(Ss,{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]=A):A=n[7],A}if(e.length===0)return null;const f=e[0],m=e.filter(A=>A.updateCommand!==null&&l),p=ft;let h;n[8]===Symbol.for("react.memo_cache_sentinel")?(h=Ml("warning"),n[8]=h):h=n[8];let g;n[9]!==t?(g=t?r.jsx(tt,{className:"animate-spin"}):r.jsx(un,{}),n[9]=t,n[10]=g):g=n[10];let x;n[11]!==f||n[12]!==e?(x=e.length===1?bp(f):`${e.map(w7).join(" and ")} are out of date`,n[11]=f,n[12]=e,n[13]=x):x=n[13];let v;n[14]!==x?(v=r.jsx(kt,{children:x}),n[14]=x,n[15]=v):v=n[15];const w=e.length>1?e.map(bp).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 b;n[16]!==w?(b=r.jsx(mt,{className:"text-warning/80",children:w}),n[16]=w,n[17]=b):b=n[17];const j=Ss,S="static col-start-3 row-span-2 row-start-1 flex items-center gap-2 self-center";let N;n[18]!==e.length||n[19]!==o||n[20]!==t?(N=A=>r.jsxs(ee,{variant:"outline",size:"xs",disabled:t!==null,onClick:()=>void o(A.provider),children:[r.jsx(pc,{"data-icon":"inline-start"}),t===A.provider?"Updating…":e.length===1?"Update":`Update ${A.displayName}`]},A.provider),n[18]=e.length,n[19]=o,n[20]=t,n[21]=N):N=n[21];const C=m.map(N),k=t!==null;let T;n[22]!==i||n[23]!==e?(T=()=>e.forEach(i),n[22]=i,n[23]=e,n[24]=T):T=n[24];let E;n[25]!==k||n[26]!==T?(E=r.jsx(ee,{variant:"ghost",size:"xs",disabled:k,onClick:T,className:"whitespace-nowrap text-muted-foreground",children:"Don't show again"}),n[25]=k,n[26]=T,n[27]=E):E=n[27];let P;n[28]!==j||n[29]!==C||n[30]!==E?(P=r.jsxs(j,{className:S,children:[C,E]}),n[28]=j,n[29]=C,n[30]=E,n[31]=P):P=n[31];let _;return n[32]!==p||n[33]!==P||n[34]!==h||n[35]!==g||n[36]!==v||n[37]!==b?(_=r.jsxs(p,{className:h,children:[g,v,b,P]}),n[32]=p,n[33]=P,n[34]=h,n[35]=g,n[36]=v,n[37]=b,n[38]=_):_=n[38],_}function w7(n){return n.displayName}function U0(){const n=B.c(27),[e,t]=y.useState(null),[s,o]=y.useState(null),[i,a]=y.useState(!1);let l,c;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const d=window.electronUpdater;d&&(d.onUpdateAvailable(u=>{t(u)}),d.onUpdateDownloaded(u=>{o(u)}))},c=[],n[0]=l,n[1]=c):(l=n[0],c=n[1]),y.useEffect(l,c),s&&!i){let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(pc,{}),n[2]=d):d=n[2];let u;n[3]!==s.version?(u=r.jsxs(kt,{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(mt,{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(Ss,{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(Qe,{"data-icon":"inline-start"})})}),n[7]=p):p=n[7];let h;return n[8]!==u?(h=r.jsxs(ft,{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(pc,{}),n[10]=d):d=n[10];let u;n[11]!==e.version?(u=r.jsxs(kt,{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(mt,{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(Ss,{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(ft,{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 wr=null,{min:Rs,max:pn,abs:vp,floor:j7}=Math,W0=(n,e,t)=>Rs(t,pn(e,n)),H0=n=>[...n].sort((e,t)=>e-t),q0=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)},Bc=()=>{let n;return[new Promise(e=>{n=e}),n]},K0=n=>{let e;return()=>(n&&(e=n(),n=void 0),e)},sr=(n,e,t)=>{const s=t?"unshift":"push";for(let o=0;o<e;o++)n[s](-1);return n},V0=(n,e)=>{const t=n.t[e];return t===-1?n.o:t},S7=(n,e,t)=>{const s=n.t[e]===-1;return n.t[e]=t,n.i=Rs(e,n.i),s},Wi=(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+=V0(n,t),n.u[++t]=s;return n.i=e,s},Xs=(n,e,t=0,s=n.l-1)=>{let o=t;for(;t<=s;){const i=j7((t+s)/2);Wi(n,i)<=e?(o=i,t=i+1):s=i-1}return W0(o,0,n.l-1)},yp=(n,e,t)=>{const s=e-n.l;return n.i=t?-1:Rs(e-1,n.i),n.l=e,s>0?(sr(n.u,s),sr(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))},N7=typeof window<"u",k7=n=>n.documentElement,C7=n=>n.ownerDocument,_7=n=>n.defaultView,G0=K0(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>0),T7=K0(()=>"scrollBehavior"in k7(document).style),E7=n=>pn(n.h(),n.p()),A7=(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=wr,x=[0,i?pn(t-1,0):-1],v=0,w=!1;const b=((A,I,R)=>({o:I,t:R?sr(R.slice(0,Rs(A,R.length)),pn(0,A-R.length)):sr([],A),l:A,i:-1,u:sr([],A+1)}))(n,s?s[1]:e,s&&s[0]),j=new Set,S=()=>d-c,N=()=>S()+f+u,C=(A,I)=>((R,$,M,L)=>{if(L=Rs(L,R.l-1),Wi(R,L)<=$){const D=Xs(R,M,L);return[Xs(R,$,L,D),D]}{const D=Xs(R,$,void 0,L);return[D,Xs(R,M,D)]}})(b,A,I,x[0]),k=()=>Wi(b,b.l),T=(A,I)=>{const R=Wi(b,A)-f;return I?k()-R-E(A):R},E=A=>V0(b,A),P=(A,I=-1)=>b.t[A]===I,_=A=>{A&&(G0()&&p!==0||g&&h===1?f+=A:u+=A)};return{v:()=>{j.clear()},m:()=>a,_:()=>(A=>[A.t.slice(),A.o])(b),S:(A=200)=>{if(!w||i)return x;let I,R;if(m)[I,R]=x;else{let $=pn(0,N()),M=$+l;o||(A=pn(0,A),p!==1&&($-=A),p!==2&&(M+=A)),[I,R]=x=C(pn(0,$),pn(0,M)),g&&(I=Rs(I,g[0]),R=pn(R,g[1]))}return[pn(I,0),Rs(R,b.l-1)]},$:A=>Xs(b,A-c),I:P,k:T,R:E,T:()=>b.l,C:()=>d,M:()=>p!==0,p:()=>l,O:()=>c,h:k,H:()=>(m=u,u=0,[m,h===2]),W:(A,I)=>{const R=[A,I];return j.add(R),()=>{j.delete(R)}},B:(A,I)=>{let R,$,M=0;switch(A){case 1:{if(I===d&&h===0)break;const L=m;m=0;const D=I-d,F=vp(D);L&&F<vp(L)+1||h!==0||(p=D<0?2:1),i&&(i=!1),d=I,M=4;const z=S();z>=-l&&z<=k()&&(M+=1,$=F>l);break}case 2:M=8,p!==0&&(R=!0,M+=1),p=0,h=0,g=wr;break;case 3:{const L=I.filter(([D,F])=>!P(D,F));if(!L.length)break;_(L.reduce((D,[F,z])=>{let O;if(h===2)O=!0;else if(g&&h===1)O=F<g[0];else{const H=S(),W=T(F),U=E(F);O=p!==1&&h===0?W+U<=H:W<H&&W+U<H+l}return O&&(D+=z-E(F)),D},0));for(const[D,F]of L){const z=E(D),O=S7(b,D,F);o&&(v+=O?F:F-z)}o&&l&&v>l&&(_(((D,F)=>{let z=0;const O=[];D.t.forEach((X,G)=>{X!==-1&&(O.push(X),G<F&&z++)}),D.i=-1;const H=H0(O),W=H.length,U=W/2|0,V=W%2==0?(H[U-1]+H[U])/2:H[U],q=D.o;return((D.o=V)-q)*pn(F-z,0)})(b,Xs(b,N()))),o=!1),M=3,$=!0;break}case 4:l!==I&&(l||(w=$=!0),l=I,M=3);break;case 5:I[1]?(_(yp(b,I[0],!0)),h=2,M=1):(yp(b,I[0]),M=1);break;case 6:c=I;break;case 7:h=1;break;case 8:g=C(I,I+l),M=1}M&&(a=1+(2147483647&a),R&&f&&(u+=f,f=0),j.forEach(([L,D])=>{M&L&&D($)}))}}},hu=setTimeout,Ol=(n,e)=>e?-n:n,P7=(n,e,t,s,o,i)=>{const a=Date.now;let l=0,c=!1,d=!1,u=!1,f=!1;const m=(()=>{let v;const w=()=>{v!=wr&&clearTimeout(v)},b=()=>{w(),v=hu(()=>{v=wr,(()=>{if(c||d)return c=!1,void m();u=!1,n.B(2)})()},150)};return b.J=w,b})(),p=()=>{l=a(),u&&(f=!0),n.B(1,s()),m()},h=v=>{if(c||!n.M()||v.ctrlKey)return;const w=a()-l;150>w&&50<w&&(t?v.deltaX:v.deltaY)&&(c=!0)},g=()=>{d=!0,u=f=!1},x=()=>{d=!1,G0()&&(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[v,w]=n.H();v&&(o(v,w,f),f=!1,w&&n.p()>n.h()&&n.B(1,s()))}}},$7=(n,e,t)=>{let s;return[async(o,i)=>{if(!await e())return;s&&s();const a=()=>{const[l,c]=Bc();return s=()=>{c(!1)},n.p()&&hu(s,150),[l,n.W(2,()=>{c(!0)})]};if(i&&T7())n.B(8,o()),q0(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()}]},I7=(n,e)=>{let t,s,o=Bc(),i=!1;const a=e?"scrollLeft":"scrollTop",l=e?"overflowX":"overflowY",[c,d]=$7(n,()=>o[0],(u,f)=>{u=Ol(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=P7(n,f,e,()=>Ol(f[a],i),(m,p,h)=>{if(h){const g=f.style,x=g[l];g[l]="hidden",hu(()=>{g[l]=x})}f[a]=Ol(n.C()+m,i),p&&d()}),o[1](!0)},v(){s&&s.A(),o[1](!1),o=Bc()},P:()=>i,V(u){c(()=>u)},X(u){u+=n.C(),c(()=>u)},Y(u,{align:f,smooth:m,offset:p=0}={}){if(u=W0(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()}}},R7=n=>{let e;return{j(t){(e||(e=new(_7(C7(t))).ResizeObserver(n))).observe(t)},D(t){e.unobserve(t)},A(){e&&e.disconnect()}}},M7=(n,e)=>{let t;const s=e?"width":"height",o=new WeakMap,i=R7(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!=wr&&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}},na=N7?y.useLayoutEffect:y.useEffect,Qt="current",Y0=(n,e)=>{if(Array.isArray(n))for(const t of n)Y0(t,e);else n==null||typeof n=="boolean"||e.push(n)},O7=(n,e)=>{const t=n.key;return t??"_"+e},L7=n=>{const e=y.useRef(null);return e[Qt]||(e[Qt]=n())},wp=n=>{const e=y.useRef(n);return na(()=>{e[Qt]=n},[n]),e},D7=y.memo(({Z:n,ee:e,te:t,oe:s,ne:o,re:i,se:a,ie:l})=>{const c=y.useRef(null);na(()=>e(c[Qt],t),[t]);const d=y.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})}),z7=(n,e)=>y.useMemo(()=>{if(typeof n=="function")return[s=>n(e[s],s),e.length];const t=(s=>{const o=[];return Y0(s,o),o})(n);return[s=>t[s],t.length]},[n,e]),F7=y.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,v]=z7(n,e),w=y.useRef(null),b=y.useRef(!!d),j=wp(p),S=wp(h),[N,C,k,T]=L7(()=>{const M=!!i,L=A7(v,s,d,l,!s);return[L,M7(L,M),I7(L,M),M]});v!==N.T()&&N.B(5,[v,o]),c!==N.O()&&N.B(6,c);const[E,P]=y.useReducer(N.m,void 0,N.m),_=N.M(),A=N.h(),I=k.P(),R=[],$=M=>{const L=x(M);return r.jsx(D7,{ee:C.U,te:M,oe:N.k(M,I),ne:N.I(M),re:f,Z:L,se:T,ie:b[Qt]},O7(L,M))};if(na(()=>{b[Qt]=!1,N.W(1,D=>{D?gy.flushSync(P):P()}),N.W(4,()=>{j[Qt]&&j[Qt](N.C())}),N.W(8,()=>{S[Qt]&&S[Qt]()});const M=w[Qt],L=D=>{C.G(D),k.N(M,D)};return m?q0(()=>{m[Qt]&&L(m[Qt])}):L(M.parentElement),()=>{N.v(),C.v(),k.v()}},[]),na(()=>{k.q()},[E]),y.useImperativeHandle(g,()=>({get cache(){return N._()},get scrollOffset(){return N.C()},get scrollSize(){return E7(N)},get viewportSize(){return N.p()},findItemIndex:N.$,getItemOffset:N.k,getItemSize:N.R,scrollToIndex:k.Y,scrollTo:k.V,scrollBy:k.X}),[]),a){const M=new Set(a);for(let[L,D]=N.S(t);L<=D;L++)M.add(L);H0([...M]).forEach(L=>{R.push($(L))})}else for(let[M,L]=N.S(t);M<=L;M++)R.push($(M));return r.jsx(u,{ref:w,style:{contain:"size style",overflowAnchor:"none",flex:"none",position:"relative",width:T?A:"100%",height:T?"100%":A,pointerEvents:_?"none":void 0},children:R})});function B7(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(gd,{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(wt,{orientation:"vertical",className:"h-4"}),e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(H3,{"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 jp=new Map;function U7(n){let e=jp.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},jp.set(n,e)}return e}function X0(n){const e=B.c(5),t="100%",s=y.useRef(null),[o,i]=y.useState(!0);let a,l;e[0]!==t?(a=()=>{const d=s.current;if(!d)return;const{observer:u,callbacks:f}=U7(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]),y.useEffect(a,l);let c;return e[3]!==o?(c={ref:s,isNear:o},e[3]=o,e[4]=c):c=e[4],c}function sa(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 Sp(n){const e=sa(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:sa(n.lastModified)}function Np(n,e){return n===e?0:e-n}function kp(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function W7(n,e){const t=Np(Sp(n),Sp(e));if(t!==0)return t;const s=Np(sa(n.lastModified),sa(e.lastModified));return s!==0?s:kp(n).localeCompare(kp(e))}function gu(n){return[...n].sort(W7)}function oa(n,e){const t=!!(n.teamName&&n.agentName);return e||xn(n.aiTitle||(t?n.agentName:"")||n.lastUserMessage||n.firstUserMessage||n.slug||n.sessionId,50)}const H7="Unknown project";function xu(n){const e=_a(n);return Ca(e?e.parentPath:n,2)||H7}function q7(n){return xu(n.cwd||vn(n.dirName))}function J0(n){return n==="inactive"?"Archived after two weeks without activity":"Archived"}function K7(n,e){return e?n:n.filter(t=>!t.archived)}function V7(n){const e=gu(n),t=new Map;for(const s of e){const o=q7(s),i=t.get(o);i?i.push(s):t.set(o,[s])}return t}function bu(n,e){return n.isActive?!0:e.has(n.sessionId)?n.agentStatus!=="completed":!1}function G7(n,e,t){let s=-1;return n.forEach((o,i)=>{bu(o,e)&&(s=i)}),Math.max(t,s+1)}const vu=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),Y7=12e4;function X7(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<Y7}function Q0(n,e,t=Date.now()){return bu(n,e)?!0:n.agentStatus==="completed"||!n.agentStatus?!1:X7(n,t)}function J7(n,e,t=Date.now()){return n.some(s=>Q0(s,e,t))}const Q7="cogpit:session-list-cache",Z7=10080*60*1e3,eT=24,Vn={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"},Uc=new Map;function tT(){return{version:1,entries:{}}}function Z0(){return Ht(Q7)}function e2(){const n=Z0(),e=Uc.get(n);if(e)return e;let t=tT();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 Uc.set(n,t),t}function t2(n){const e=e2().entries[n];if(!(!e||Date.now()-e.savedAt>Z7))return e.value}function n2(n,e){const t=Z0(),o={...e2().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,eT))};Uc.set(t,a);try{localStorage.setItem(t,JSON.stringify(a))}catch{}}function ra(n){const e=t2(n);return Array.isArray(e)?e:void 0}function or(n,e){n2(n,e)}function s2(n){return`sessions:${n}`}function nT(n){const e=t2(s2(n));if(!e||typeof e!="object")return;const t=e;if(!(!Array.isArray(t.sessions)||typeof t.total!="number"))return t}function sT(n,e){n2(s2(n),e)}const oT=2e4;function rT(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 o2=y.createContext(null);function iT({children:n}){const[e]=y.useState(gn),[t,s]=y.useState(()=>ra(Vn.activeSessions)??[]),[o,i]=y.useState(()=>ra(Vn.runningProcesses)??[]),[a,l]=y.useState(!1),[c,d]=y.useState(null),[u,f]=y.useState(new Set),[m,p]=Io(Ht("live-sessions-show-archived"),!1),h=m===!0,[g,x]=y.useState(!1),v=h||g,[w,b]=y.useState(0),j=y.useRef(null),S=y.useRef(t),N=y.useRef(null),C=y.useRef(!1);y.useEffect(()=>(C.current=!0,()=>{var M;C.current=!1,(M=N.current)==null||M.abort(),N.current=null}),[]);const k=y.useCallback(async()=>{var D;if(!C.current||gn()!==e)return;(D=N.current)==null||D.abort();const M=new AbortController;N.current=M;const L=()=>C.current&&!M.signal.aborted&&N.current===M&&gn()===e;l(!0);try{const[F,z]=await Promise.all([_e(v?"/api/active-sessions?archived=include":"/api/active-sessions",{signal:M.signal}),_e("/api/running-processes",{signal:M.signal})]);if(!L())return;if(!F.ok||!z.ok)throw new Error("Failed to fetch live data");const[O,H]=await Promise.all([F.json(),z.json()]);if(!L())return;const W=Array.isArray(O)?O:[],U=Array.isArray(H)?H:[];S.current=W,s(W),i(U),b(Number(F.headers.get("X-Cogpit-Archived-Count"))||0),or(Vn.activeSessions,W),or(Vn.runningProcesses,U),d(null)}catch(F){if(!L())return;d(F instanceof Error?F.message:"Failed to load data")}finally{L()&&l(!1),N.current===M&&(N.current=null)}},[e,v]),T=y.useCallback(()=>{k()},[k]);y.useEffect(()=>{T()},[T]);const E=y.useMemo(()=>rT(o),[o]),P=y.useMemo(()=>J7(t,E),[t,E]);y.useEffect(()=>(window.addEventListener("focus",T),()=>window.removeEventListener("focus",T)),[T]),y.useEffect(()=>{if(!P)return;const M=setInterval(()=>{document.visibilityState==="visible"&&T()},oT);return()=>clearInterval(M)},[P,T]),y.useEffect(()=>{if(t.length===0)return;const M=j.current,L=new Map;for(const D of t)D.agentStatus&&E.has(D.sessionId)&&L.set(D.sessionId,D.agentStatus);M!==null&&f(D=>{let F=null;for(const[z,O]of L)O==="completed"&&M.get(z)!=="completed"&&(F??(F=new Set(D)),F.add(z));for(const z of D)L.get(z)!=="completed"&&(F??(F=new Set(D)),F.delete(z));return F??D}),j.current=L},[t,E]);const _=y.useCallback(M=>{f(L=>{if(!L.has(M))return L;const D=new Set(L);return D.delete(M),D})},[]),A=y.useCallback(M=>{S.current=M,s(M),gn()===e&&or(Vn.activeSessions,M)},[e]),I=y.useCallback(M=>{A(S.current.filter(L=>L.sessionId!==M))},[A]),R=y.useCallback((M,L)=>{const D=new Set(M),F=S.current,z=new Set(F.filter(H=>D.has(H.sessionId)&&!!H.archived!==L).map(H=>H.sessionId));if(z.size===0)return;A(F.map(H=>{if(!z.has(H.sessionId))return H;if(L)return{...H,archived:!0,archivedReason:"manual"};const{archived:W,archivedReason:U,...V}=H;return V}));const O=L?z.size:-z.size;b(H=>Math.max(0,H+O))},[A]),$=y.useMemo(()=>({sessions:t,processes:o,procBySession:E,newlyCompleted:u,loading:a,error:c,refresh:T,removeSession:I,acknowledgeCompleted:_,showArchived:h,setShowArchived:p,setSearchActive:x,archivedCount:w,setArchived:R}),[t,o,E,u,a,c,T,I,_,h,p,w,R]);return r.jsx(o2.Provider,{value:$,children:n})}function r2(){const n=yu();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function yu(){return y.useContext(o2)}const Cp=[20,50,80,110,140,170,200,230,260,290,320,350];function aT(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return Cp[(e>>>0)%Cp.length]}function Ll(n){const e=[];let t=!1;for(const s of n.split(`
|
|
87
|
+
`)){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 lT(n){const e=n.split(`
|
|
88
|
+
`);let t=0;for(;t<e.length&&e[t].trim()==="";)t++;const s=Ll(e[t]??"");return s?{subject:s,preview:Ll(e.slice(t+1).join(`
|
|
89
|
+
`))}:{subject:Ll(n),preview:""}}function Wc(n){if(!n)return null;const e=new Date(n).getTime();return Number.isNaN(e)?null:e}function cT(n,e){return n===null||e===null||e<n?null:e-n}function dT(n){const e=Wc(n);return e===null?null:new Date(e).toLocaleTimeString()}function uT(n){var s;const e=(s=yu())==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=vu.has(i)?"working":"idle"}return t}const fT=y.memo(function(e){const t=B.c(48),{sender:s,body:o,timestamp:i,reply:a,isLive:l}=e,[c,d]=y.useState(!1);let u;t[0]!==o?(u=W6(o),t[0]=o,t[1]=u):u=t[1];const f=u;let m;t[2]!==f?(m=lT(f),t[2]=f,t[3]=m):m=t[3];const{subject:p,preview:h}=m;let g;t[4]!==i?(g=dT(i),t[4]=i,t[5]=g):g=t[5];const x=g,v=uT(s);let w;t[6]!==f?(w=G6(f),t[6]=f,t[7]=w):w=t[7];const b=w,j=b&&!a,S=Wc(i),N=a?cT(S,Wc(a.timestamp)):null,C=!a&&l===!0,k=!!a||b;yg(C&&k);const T=!0;let E;t[8]!==s?(E=aT(s),t[8]=s,t[9]=E):E=t[9];const P=String(E);let _;t[10]!==P?(_={"--agent-hue":P},t[10]=P,t[11]=_):_=t[11];const A=_,I="my-2 rounded-lg border border-l-[3px] border-border bg-card px-3 py-2 [border-left-color:oklch(0.52_0.16_var(--agent-hue))] dark:[border-left-color:oklch(0.74_0.14_var(--agent-hue))]";let R;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(q3,{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]=R):R=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]!==v||t[16]!==s?(M=v&&r.jsx("span",{"data-testid":"agent-liveness","data-live":v,title:v==="working"?`${s} is working now`:`${s} is idle`,className:`inline-flex size-1.5 shrink-0 rounded-full ${v==="working"?"animate-pulse bg-warning":"bg-success"}`}),t[15]=v,t[16]=s,t[17]=M):M=t[17];let L;t[18]!==$||t[19]!==M?(L=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[R,$,M]}),t[18]=$,t[19]=M,t[20]=L):L=t[20];let D;t[21]!==j?(D=j&&r.jsx(Ie,{variant:"outline",className:"h-4 border-warning/30 bg-warning/10 px-1.5 text-[10px] tracking-wide text-warning uppercase",children:"Needs you"}),t[21]=j,t[22]=D):D=t[22];let F;t[23]!==x?(F=x&&r.jsx("span",{className:"text-xs text-muted-foreground",children:x}),t[23]=x,t[24]=F):F=t[24];let z;t[25]!==D||t[26]!==F?(z=r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[D,F]}),t[25]=D,t[26]=F,t[27]=z):z=t[27];let O;t[28]!==L||t[29]!==z?(O=r.jsxs("div",{className:"flex items-center gap-2",children:[L,z]}),t[28]=L,t[29]=z,t[30]=O):O=t[30];let H;t[31]!==f||t[32]!==c||t[33]!==h||t[34]!==p?(H=c?r.jsx("div",{"data-testid":"agent-message-body",className:"mt-1.5 max-w-none overflow-hidden break-words text-sm leading-relaxed",children:r.jsx(Ln,{components:Fn,remarkPlugins:Bn,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]=H):H=t[35];const W="mt-1.5 flex items-center justify-end gap-2",U=k&&r.jsx("p",{"data-testid":"agent-message-state",className:`min-w-0 flex-1 truncate text-xs ${C?"text-warning":"text-muted-foreground"}`,children:a?r.jsxs(r.Fragment,{children:[N===null?"You replied":`You replied ${Rn(N)} later`,a.summary&&` · "${a.summary}"`]}):C?S===null?"Awaiting your reply":`Awaiting your reply · ${Rn(Math.max(0,Date.now()-S))}`:"Never answered"});let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=()=>d(mT),t[36]=V):V=t[36];let q;t[37]!==f||t[38]!==c?(q=r.jsx(ee,{type:"button",variant:"ghost",size:"xs",onClick:V,className:"-mr-2 text-muted-foreground",children:c?r.jsxs(r.Fragment,{children:[r.jsx(nt,{"data-icon":"inline-start"})," Collapse"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ve,{"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 X;t[40]!==U||t[41]!==q?(X=r.jsxs("div",{className:W,children:[U,q]}),t[40]=U,t[41]=q,t[42]=X):X=t[42];let G;return t[43]!==O||t[44]!==H||t[45]!==X||t[46]!==A?(G=r.jsxs("div",{"data-agent-rail":T,style:A,className:I,children:[O,H,X]}),t[43]=O,t[44]=H,t[45]=X,t[46]=A,t[47]=G):G=t[47],G});function mT(n){return!n}const pT=y.memo(function(e){const t=B.c(20),{text:s,model:o,effort:i,timestamp:a,compact:l}=e,c=l===void 0?!1:l;let d;t[0]!==s?(d=P0(s),t[0]=s,t[1]=d):d=t[1];const u=d,[f,m]=Xn();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:Ks(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(lt,{"data-icon":"inline-start"}):r.jsx(fn,{"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=K("overflow-hidden break-words text-sm",h),t[10]=h,t[11]=g):g=t[11];let x;t[12]!==u?(x=r.jsx(Ln,{components:Fn,remarkPlugins:Bn,children:u}),t[12]=u,t[13]=x):x=t[13];let v;t[14]!==g||t[15]!==x?(v=r.jsx("div",{className:g,children:x}),t[14]=g,t[15]=x,t[16]=v):v=t[16];let w;return t[17]!==p||t[18]!==v?(w=r.jsxs("div",{className:"group",children:[p,v]}),t[17]=p,t[18]=v,t[19]=w):w=t[19],w}),io=[];function hT(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 gT(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 _p=/"id"\s*:\s*"(msg_[A-Za-z0-9]+)"/g;function xT(n,e){if(n.length===0||e.length===0)return n;const t=new Set;for(const o of e){_p.lastIndex=0;let i;for(;(i=_p.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 bT(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 vT(n){return n.filter(e=>e.parentToolUseId===null)}function yT(n,e){return n.filter(t=>t.parentToolUseId===e)}const i2={},a2=y.createContext(io),l2=y.createContext(i2);function Dl(n){const e=B.c(6),{value:t,agentProgress:s,children:o}=n,i=s===void 0?i2:s;let a;e[0]!==i||e[1]!==o?(a=r.jsx(l2.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(a2.Provider,{value:t,children:a}),e[3]=a,e[4]=t,e[5]=l):l=e[5],l}function wu(){return y.useContext(a2)}function wT(n){return y.useContext(l2)[n]??null}function Js(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 c2={...Fn,code({className:n,children:e}){return!n&&typeof e=="string"&&!e.includes(`
|
|
90
|
+
`)?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},jT={...c2,h1:Js("h1"),h2:Js("h2"),h3:Js("h3"),h4:Js("h4"),h5:Js("h5"),h6:Js("h6")},ju=y.memo(function(e){const t=B.c(3),{text:s,compactHeadings:o}=e,a=(o===void 0?!1:o)?jT:c2;let l;return t[0]!==a||t[1]!==s?(l=r.jsx(Ln,{components:a,remarkPlugins:Bn,children:s}),t[0]=a,t[1]=s,t[2]=l):l=t[2],l}),Tp=400,ST=24,Su=y.memo(function(e){const t=B.c(24),{toolUseId:s}=e,o=wu(),i=wT(s),a=y.useRef(null),[l,c]=y.useState(!0);let d,u,f;if(t[0]!==l||t[1]!==o||t[2]!==s){f=yT(o,s).flatMap(NT).filter(kT).map(CT).join(`
|
|
91
|
+
`);const N=f.split(`
|
|
92
|
+
`);d=l&&N.length>Tp,u=d?N.slice(-Tp).join(`
|
|
93
|
+
`):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 N=a.current;if(!N)return;const C=N.scrollHeight-N.scrollTop-N.clientHeight<ST;c(k=>k===C?k:C)},t[6]=p):p=t[6];const h=p;let g;t[7]!==l?(g=()=>{const N=a.current;if(!N||!l)return;const C=N.scrollHeight-N.clientHeight;N.scrollTop!==C&&(N.scrollTop=C)},t[7]=l,t[8]=g):g=t[8];let x;if(t[9]!==l||t[10]!==m?(x=[m,l],t[9]=l,t[10]=m,t[11]=x):x=t[11],y.useLayoutEffect(g,x),!f&&!i)return null;const v=i?"live-subagent-summary":void 0;let w;t[12]!==i?(w=i??r.jsx("span",{className:"uppercase tracking-wide",children:"Live"}),t[12]=i,t[13]=w):w=t[13];let b;t[14]!==v||t[15]!==w?(b=r.jsx("div",{"data-testid":v,className:"mb-1 text-xs font-medium text-muted-foreground",children:w}),t[14]=v,t[15]=w,t[16]=b):b=t[16];let j;t[17]!==d||t[18]!==m||t[19]!==f?(j=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(ju,{text:m,compactHeadings:!0})]}),t[17]=d,t[18]=m,t[19]=f,t[20]=j):j=t[20];let S;return t[21]!==b||t[22]!==j?(S=r.jsxs("div",{className:"mt-2 rounded-md border bg-muted/30 px-3 py-2","data-testid":"live-subagent-transcript",children:[b,j]}),t[21]=b,t[22]=j,t[23]=S):S=t[23],S});function NT(n){return n.blocks}function kT(n){return n.blockType!=="tool_use"&&n.text}function CT(n){return n.text}function Ep(n){return n.length>8?n.slice(0,8):n}function Nu(n,e,t){const s=e??t;return s?`${s} - ${Ep(n)}`:Ep(n)}function _T(n){const e=new Map;for(const t of n)e.has(t.agentId)||e.set(t.agentId,Nu(t.agentId,t.subagentType,t.agentName));return e}function TT(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 ET(n){return n?typeof n=="string"?n:n.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
94
|
+
`):""}function d2(n,e){if(u0(n))return uu(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(`
|
|
95
|
+
|
|
96
|
+
`),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(`
|
|
97
|
+
`)){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=ET(f.content),m.isError=f.is_error??!1)}}}return t}const zl=new Map;function AT(n,e){const t=B.c(21),{session:s,sessionSource:o,isLive:i}=st();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,t[0]=a):a=t[0];const[l,c]=y.useState(a),[d,u]=y.useState(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,t[1]=f):f=t[1];const m=y.useRef(f);let p;if(t[2]!==i||t[3]!==n){let T;t[5]!==i?(T=E=>E.text.length>0||E.thinking.length>0||E.toolCalls.length>0?!1:i?E.durationMs!=null:E.status==="async_launched",t[5]=i,t[6]=T):T=t[6],p=n.filter(T),t[2]=i,t[3]=n,t[4]=p}else p=t[4];const h=p,g=o==null?void 0:o.dirName,x=s==null?void 0:s.sessionId;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=$a(window.location.pathname),t[7]=v):v=t[7];const w=v;let b,j;t[8]!==h||t[9]!==g||t[10]!==e||t[11]!==x?(b=()=>{if(w||!e||!g||!x||h.length===0)return;const T=[];for(const _ of h){const A=Ht(`${g}/${x}/${_.agentId}`);if(!m.current.has(A)){if(zl.has(A)){c(I=>{const R=new Map(I);return R.set(_.agentId,zl.get(A)),R}),m.current.add(A);continue}T.push({agentId:_.agentId,cacheKey:A})}}if(T.length===0)return;let E=!1;return u(!0),async function(){const A=new Map;await Promise.all(T.map(async I=>{const{agentId:R,cacheKey:$}=I;try{const M=`/api/sessions/${encodeURIComponent(g)}/${encodeURIComponent(x)}/subagents/agent-${encodeURIComponent(R)}.jsonl`,L=await _e(M);if(!L.ok)return;const D=await L.text(),F=d2(D,R);zl.set($,F),m.current.add($),A.set(R,F)}catch{}})),!E&&A.size>0&&c(I=>{const R=new Map(I);for(const[$,M]of A)R.set($,M);return R}),E||u(!1)}(),()=>{E=!0}},j=[w,e,g,x,h],t[8]=h,t[9]=g,t[10]=e,t[11]=x,t[12]=b,t[13]=j):(b=t[12],j=t[13]),y.useEffect(b,j);let S;e:{if(l.size===0&&h.length===0){S=n;break e}let T;if(t[14]!==l||t[15]!==n){T=[];for(const E of n){const P=l.get(E.agentId);if(P&&P.length>0&&(E.status==="async_launched"||E.durationMs!=null)){const _={...P[0],durationMs:E.durationMs,toolUseCount:E.toolUseCount,status:E.status,prompt:E.prompt,agentName:E.agentName,subagentType:E.subagentType};T.push(_,...P.slice(1))}else T.push(E)}t[14]=l,t[15]=n,t[16]=T}else T=t[16];S=T}const N=S,C=w&&e&&h.length>0;let k;return t[17]!==N||t[18]!==d||t[19]!==C?(k={enrichedMessages:N,isLoading:d,unavailable:C},t[17]=N,t[18]=d,t[19]=C,t[20]=k):k=t[20],k}const Ap=y.memo(function(e){const t=B.c(74),{messages:s,expandAll:o,label:i,countLabel:a}=e,[l,c]=y.useState(!1),d=o||l,{sessionSource:u,actions:f}=st(),m=u==null?void 0:u.dirName;let p;t[0]!==m?(p=vo(m),t[0]=m,t[1]=p):p=t[1];const h=p.subagentTranscripts,{enrichedMessages:g,isLoading:x,unavailable:v}=AT(s,d&&h);let w;e:{if(!(u!=null&&u.fileName)){w=null;break e}let Y;t[2]!==u.fileName?(Y=ws(u.fileName),t[2]=u.fileName,t[3]=Y):Y=t[3];const J=Y;if(J){w=J.parentSessionId;break e}let Q;if(t[4]!==u.fileName){let te;t[6]===Symbol.for("react.memo_cache_sentinel")?(te=/^([^/]+)\.jsonl$/,t[6]=te):te=t[6],Q=u.fileName.match(te),t[4]=u.fileName,t[5]=Q}else Q=t[5];const Z=Q;w=(Z==null?void 0:Z[1])??null}const b=w;let j;t[7]!==g?(j=new Set(g.map($T)),t[7]=g,t[8]=j):j=t[8];let S;t[9]!==j?(S=[...j],t[9]=j,t[10]=S):S=t[10];const N=S;let C;t[11]!==g?(C=_T(g),t[11]=g,t[12]=C):C=t[12];const k=C;let T;if(t[13]!==g||t[14]!==s){T=new Map;for(const Y of[...s,...g]){const J=T.get(Y.agentId)??{};Y.durationMs!=null&&(J.durationMs=Y.durationMs),Y.toolUseCount!=null&&(J.toolUseCount=Y.toolUseCount),Y.status&&(J.status=Y.status),T.set(Y.agentId,J)}t[13]=g,t[14]=s,t[15]=T}else T=t[15];const E=T;let P;t[16]!==g||t[17]!==s?(P=TT([...s,...g]),t[16]=g,t[17]=s,t[18]=P):P=t[18];const _=P;let A,I;if(t[19]!==g){I=new Map,A=new Map;for(const Y of g)A.set(Y.agentId,Y),Y.text.length>0&&I.set(Y.agentId,Y);t[19]=g,t[20]=A,t[21]=I}else A=t[20],I=t[21];let R;if(t[22]!==N||t[23]!==A||t[24]!==I){R=new Map;for(const Y of N){const J=I.get(Y)??A.get(Y);J&&R.set(Y,J)}t[22]=N,t[23]=A,t[24]=I,t[25]=R}else R=t[25];const $=R;let M;e:{let Y=0,J=0,Q=!1,Z=!0;for(const ne of s)ne.durationMs!=null&&(Y=Y+ne.durationMs,Q=!0),ne.toolUseCount!=null&&(J=J+ne.toolUseCount),ne.status&&ne.status!=="completed"&&(Z=!1);if(!Q){M=null;break e}let te;t[26]!==Z||t[27]!==Y||t[28]!==J?(te={totalDuration:Y,totalToolUses:J,allCompleted:Z},t[26]=Z,t[27]=Y,t[28]=J,t[29]=te):te=t[29],M=te}const L=M;if(s.length===0)return null;let D;t[30]!==l?(D=()=>c(!l),t[30]=l,t[31]=D):D=t[31];let F;t[32]!==d?(F=d?r.jsx(nt,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Ve,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[32]=d,t[33]=F):F=t[33];let z;t[34]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsx(Zn,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[34]=z):z=t[34];let O;t[35]!==i?(O=r.jsx("span",{className:"text-xs font-medium text-foreground",children:i}),t[35]=i,t[36]=O):O=t[36];let H;t[37]!==N.length||t[38]!==a?(H=N.length>1&&r.jsxs(Ie,{variant:"secondary",children:[N.length," ",a]}),t[37]=N.length,t[38]=a,t[39]=H):H=t[39];let W;t[40]!==N||t[41]!==k?(W=N.map(Y=>r.jsx(Ie,{variant:"outline",children:k.get(Y)},Y)),t[40]=N,t[41]=k,t[42]=W):W=t[42];let U;t[43]!==N.length||t[44]!==L?(U=L?r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[L.allCompleted?r.jsx(On,{className:"size-3 text-success","data-icon":"inline-start"}):r.jsx(Hs,{className:"size-3 text-destructive","data-icon":"inline-start"}),r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Ls,{className:"size-3","data-icon":"inline-start"}),Rn(L.totalDuration)]}),L.totalToolUses>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ha,{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]=U):U=t[45];let V;t[46]!==F||t[47]!==O||t[48]!==H||t[49]!==W||t[50]!==U||t[51]!==D?(V=r.jsxs(ee,{type:"button",variant:"ghost",onClick:D,className:"h-auto w-full min-w-0 flex-wrap justify-start gap-2 px-0 py-1 text-left whitespace-normal",children:[F,z,O,H,W,U]}),t[46]=F,t[47]=O,t[48]=H,t[49]=W,t[50]=U,t[51]=D,t[52]=V):V=t[52];let q;t[53]!==N||t[54]!==d||t[55]!==_?(q=!d&&N.map(Y=>{const J=_.get(Y);return J?r.jsx(Su,{toolUseId:J},Y):null}),t[53]=N,t[54]=d,t[55]=_,t[56]=q):q=t[56];let X;t[57]!==f||t[58]!==N||t[59]!==k||t[60]!==$||t[61]!==h||t[62]!==x||t[63]!==d||t[64]!==b||t[65]!==_||t[66]!==u||t[67]!==E||t[68]!==v?(X=d&&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."}):x&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[r.jsx(tt,{className:"size-3 animate-spin"}),"Loading agent output..."]}),N.map(Y=>{const J=$.get(Y),Q=E.get(Y),Z=h&&!!u&&!!b&&!v;return r.jsx(PT,{agentLabel:k.get(Y)??Y,message:J,stats:Q,parentToolUseId:_.get(Y),canNavigate:Z,onOpen:()=>{Z&&f.handleLoadSession(u.dirName,`${b}/subagents/agent-${Y}.jsonl`)}},Y)})]}),t[57]=f,t[58]=N,t[59]=k,t[60]=$,t[61]=h,t[62]=x,t[63]=d,t[64]=b,t[65]=_,t[66]=u,t[67]=E,t[68]=v,t[69]=X):X=t[69];let G;return t[70]!==V||t[71]!==q||t[72]!==X?(G=r.jsxs("div",{children:[V,q,X]}),t[70]=V,t[71]=q,t[72]=X,t[73]=G):G=t[73],G});function PT(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=P0((c??[]).join(`
|
|
98
|
+
|
|
99
|
+
`)),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(Ie,{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(On,{className:"size-3 text-success"}),o.durationMs!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Ls,{className:"size-3"}),Rn(o.durationMs)]}),o.toolUseCount!=null&&o.toolUseCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ha,{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($1,{"data-icon":"inline-start"}),"Open chat"]}),e[7]=a,e[8]=l,e[9]=x):x=e[9];let v;e[10]!==h||e[11]!==g||e[12]!==x?(v=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]=v):v=e[13];let w;e[14]!==f||e[15]!==m||e[16]!==u||e[17]!==i?(w=f?r.jsx("div",{className:"text-xs break-words overflow-hidden",children:r.jsx(Ln,{components:Fn,remarkPlugins:Bn,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(tt,{className:"size-3 animate-spin"}),"Working — no return yet"]}):r.jsx(r.Fragment,{children:"No return message from this agent"})}),i&&r.jsx(Su,{toolUseId:i})]}),e[14]=f,e[15]=m,e[16]=u,e[17]=i,e[18]=w):w=e[18];let b;return e[19]!==v||e[20]!==w?(b=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:[v,w]})}),e[19]=v,e[20]=w,e[21]=b):b=e[21],b}function $T(n){return n.agentId}const IT=new Set(["StopFailure","PermissionDenied","PostToolUseFailure"]),RT=y.memo(function(e){const t=B.c(30),{events:s}=e,[o,i]=y.useState(!1);if(s.length===0)return null;let a;t[0]!==s?(a=s.some(MT),t[0]=s,t[1]=a):a=t[1];const l=a,c=o?nt:Ve,d=l?"border-destructive/20 bg-destructive/5":"bg-muted/30";let u;t[2]!==d?(u=K("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(Wt,{className:"size-3 text-destructive","data-icon":"inline-start"}):r.jsx(K3,{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(OT).join(", "),t[12]=s,t[13]=x):x=t[13];let v;t[14]!==x?(v=r.jsx("span",{className:"truncate text-muted-foreground/60",children:x}),t[14]=x,t[15]=v):v=t[15];let w;t[16]!==v||t[17]!==m||t[18]!==p||t[19]!==g?(w=r.jsxs(Pt,{render:f,children:[m,p,g,v]}),t[16]=v,t[17]=m,t[18]=p,t[19]=g,t[20]=w):w=t[20];let b;t[21]!==s?(b=s.map(LT),t[21]=s,t[22]=b):b=t[22];let j;t[23]!==b?(j=r.jsx(dt,{children:r.jsx("ul",{className:"ml-5 mt-1 flex flex-col gap-0.5 font-mono",children:b})}),t[23]=b,t[24]=j):j=t[24];let S;return t[25]!==o||t[26]!==w||t[27]!==j||t[28]!==u?(S=r.jsxs(ct,{open:o,onOpenChange:i,className:u,children:[w,j]}),t[25]=o,t[26]=w,t[27]=j,t[28]=u,t[29]=S):S=t[29],S});function MT(n){return IT.has(n.eventName)||n.exitCode!==void 0&&n.exitCode!==0}function OT(n){return n.eventName}function LT(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 DT=24,qo=[];function zT(n,e){for(let s=0;s<qo.length;s++){const o=qo[s];if(o.oldStr===n&&o.newStr===e)return o.result}const t=BT(n,e);return qo.length>=DT&&qo.shift(),qo.push({oldStr:n,newStr:e,result:t}),t}const FT=25e4;function BT(n,e){const t=n.split(`
|
|
100
|
+
`),s=e.split(`
|
|
101
|
+
`),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>FT){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 v=t[a+x-1],w=x*f,b=w-f;for(let j=1;j<=d;j++)if(v===s[a+j-1])m[w+j]=m[b+j-1]+1;else{const S=m[b+j],N=m[w+j-1];m[w+j]=S>N?S:N}}const p=[];let h=c,g=d;for(;h>0||g>0;)h>0&&g>0&&t[a+h-1]===s[a+g-1]?(p.push({type:"unchanged",text:t[a+h-1],oldIdx:a+h-1,newIdx:a+g-1}),h--,g--):g>0&&(h===0||m[h*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 UT(n,e,t,s){const o=B.c(9),[i,a]=y.useState(null),[l,c]=y.useState(null);let d,u;o[0]!==t||o[1]!==s||o[2]!==e||o[3]!==n?(d=()=>{const m=hx(t);if(!m){a(null),c(null);return}const p=s?"github-dark":"github-light";let h=!1;const g=requestAnimationFrame(()=>{h||mx().then(async x=>{if(h||(await px(x,m),h))return;const v=x.codeToTokens(n,{lang:m,theme:p});if(h)return;a(v.tokens);const w=x.codeToTokens(e,{lang:m,theme:p});h||c(w.tokens)}).catch(x=>{console.warn("[EditDiffView] highlight failed:",x),h||(a(null),c(null))})});return()=>{h=!0,cancelAnimationFrame(g)}},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]),y.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 WT={removed:"bg-destructive/10",added:"bg-success/10",unchanged:""},Pp={removed:"border-destructive/20 text-destructive/70",added:"border-success/20 text-success/70",unchanged:"border-border text-muted-foreground"},HT={removed:"text-destructive",added:"text-success",unchanged:"text-muted-foreground"};function qT(n,e){return n.map((t,s)=>r.jsx("span",{style:{color:t.color},className:K(e&&"opacity-50"),children:t.content},s))}function KT(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 VT(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(P1,{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(In,{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 Fl=3;function GT(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<=Fl*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-Fl);a<=Math.min(n.length-1,i+Fl);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 YT(n){const e=B.c(7),{count:t,onExpand:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(ya,{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 $p=y.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=KT(s,i,a);const x=WT[s.type];t[10]!==x?(d=K("flex",x),t[10]=x,t[11]=d):d=t[11];const v=Pp[s.type];let w;t[12]!==v?(w=K("w-8 shrink-0 select-none border-r pr-1 text-right text-xs leading-relaxed tabular-nums",v),t[12]=v,t[13]=w):w=t[13],t[14]!==o||t[15]!==w?(u=r.jsx("span",{className:w,children:o}),t[14]=o,t[15]=w,t[16]=u):u=t[16];const b=Pp[s.type];let j;t[17]!==b?(j=K("select-none shrink-0 w-5 text-right pr-1 border-r",b),t[17]=b,t[18]=j):j=t[18];let S;t[19]!==s.type?(S=r.jsx(VT,{type:s.type}),t[19]=s.type,t[20]=S):S=t[20],t[21]!==j||t[22]!==S?(f=r.jsx("span",{className:j,children:S}),t[21]=j,t[22]=S,t[23]=f):f=t[23],l="pl-2 whitespace-pre",c=m?qT(m,s.type==="unchanged"):r.jsx("span",{className:HT[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}),Ip=120,Rp=60,XT=120;function Mp(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]=y.useState(c);let f;e[1]!==t?(f=GT(t),e[1]=t,e[2]=f):f=e[2];const m=f,p=m.length>Ip,[h,g]=y.useState(p?Rp:m.length);let x;e[3]!==m.length?(x=()=>{g(m.length>Ip?Rp:m.length)},e[3]=m.length,e[4]=x):x=e[4];let v;e[5]!==m?(v=[m],e[5]=m,e[6]=v):v=e[6],y.useEffect(x,v);let w,b;e[7]!==m.length||e[8]!==h?(w=()=>{if(h>=m.length)return;const _=requestAnimationFrame(()=>{g(A=>Math.min(A+XT,m.length))});return()=>cancelAnimationFrame(_)},b=[h,m.length],e[7]=m.length,e[8]=h,e[9]=w,e[10]=b):(w=e[9],b=e[10]),y.useEffect(w,b);let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=_=>{u(A=>new Set(A).add(_))},e[11]=j):j=e[11];const S=j;let N;e[12]!==m||e[13]!==p||e[14]!==h?(N=p?m.slice(0,h):m,e[12]=m,e[13]=p,e[14]=h,e[15]=N):N=e[15];const C=N,k=i&&"max-h-64 overflow-y-auto";let T;e[16]!==k?(T=K("overflow-x-auto font-mono text-xs leading-relaxed",k),e[16]=k,e[17]=T):T=e[17];let E;if(e[18]!==d||e[19]!==C||e[20]!==t||e[21]!==o||e[22]!==s||e[23]!==l){let _;e[25]!==d||e[26]!==t||e[27]!==o||e[28]!==s||e[29]!==l?(_=(A,I)=>{if(A.kind==="separator")return d.has(A.fromIdx)?t.slice(A.fromIdx,A.toIdx+1).map((M,L)=>{const D=A.fromIdx+L;return r.jsx($p,{line:M,lineNum:M.type==="removed"?(M.oldIdx??0)+l:(M.newIdx??0)+l,oldTokens:s,newTokens:o},`exp-${D}`)}):r.jsx(YT,{count:A.count,onExpand:()=>S(A.fromIdx)},`sep-${I}`);const{line:R}=A,$=R.type==="removed"?(R.oldIdx??0)+l:(R.newIdx??0)+l;return r.jsx($p,{line:R,lineNum:$,oldTokens:s,newTokens:o},I)},e[25]=d,e[26]=t,e[27]=o,e[28]=s,e[29]=l,e[30]=_):_=e[30],E=C.map(_),e[18]=d,e[19]=C,e[20]=t,e[21]=o,e[22]=s,e[23]=l,e[24]=E}else E=e[24];let P;return e[31]!==T||e[32]!==E?(P=r.jsx("div",{className:T,children:E}),e[31]=T,e[32]=E,e[33]=P):P=e[33],P}function Op(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 ku(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]=y.useState(!1),p=Vr();let h;e[0]!==s||e[1]!==t?(h=zT(t,s),e[0]=s,e[1]=t,e[2]=h):h=e[2];const g=h,{oldTokens:x,newTokens:v}=UT(t,s,o,p);let w;e[3]!==o?(w=o.split("/").slice(-3).join("/"),e[3]=o,e[4]=w):w=e[4];const b=w,j=c&&"mt-1.5",S=u&&"border-0 rounded-none";let N;e[5]!==j||e[6]!==S?(N=K("overflow-hidden rounded border border-border bg-muted/20",j,S),e[5]=j,e[6]=S,e[7]=N):N=e[7];let C;e[8]!==u||e[9]!==c||e[10]!==g||e[11]!==b?(C=!u&&r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 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:b}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(Op,{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(xa,{"data-icon":"icon"})})]})]}),e[8]=u,e[9]=c,e[10]=g,e[11]=b,e[12]=C):C=e[12];let k;e[13]!==c||e[14]!==g||e[15]!==v||e[16]!==x||e[17]!==d?(k=r.jsx(Mp,{lines:g,oldTokens:x,newTokens:v,compact:c,startLine:d}),e[13]=c,e[14]=g,e[15]=v,e[16]=x,e[17]=d,e[18]=k):k=e[18];let T;e[19]!==k||e[20]!==N||e[21]!==C?(T=r.jsxs("div",{className:N,children:[C,k]}),e[19]=k,e[20]=N,e[21]=C,e[22]=T):T=e[22];let E;e[23]!==o||e[24]!==c||e[25]!==g||e[26]!==f||e[27]!==v||e[28]!==x||e[29]!==d?(E=c&&r.jsx(es,{open:f,onOpenChange:m,children:r.jsxs(ts,{className:"flex max-h-[85vh] flex-col border-border bg-background sm:max-w-4xl",children:[r.jsxs(_s,{children:[r.jsxs(ns,{className:"font-mono text-sm text-foreground flex min-w-0 flex-wrap items-center gap-3 [overflow-wrap:anywhere]",children:[o,r.jsx(Op,{lines:g})]}),r.jsx(ss,{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(Mp,{lines:g,oldTokens:x,newTokens:v,startLine:d})})]})}),e[23]=o,e[24]=c,e[25]=g,e[26]=f,e[27]=v,e[28]=x,e[29]=d,e[30]=E):E=e[30];let P;return e[31]!==T||e[32]!==E?(P=r.jsxs(r.Fragment,{children:[T,E]}),e[31]=T,e[32]=E,e[33]=P):P=e[33],P}const ia={Read:{label:"Read file",styleName:"Read"},Write:{label:"Write file",styleName:"Write"},Edit:{label:"Edit file",styleName:"Edit"},Bash:{label:"Run command",styleName:"Bash"},Grep:{label:"Search files",styleName:"Grep"},Glob:{label:"Find files",styleName:"Glob"},Task:{label:"Spawn agent",styleName:"Task"},Agent:{label:"Spawn agent",styleName:"Task"},WebFetch:{label:"Open page",styleName:"WebFetch"},TodoWrite:{label:"Update plan",styleName:"TodoWrite"},AskUserQuestion:{label:"Ask question",styleName:"AskUserQuestion"},Skill:{label:"Use skill",styleName:"Skill"},ToolSearch:{label:"Find tools",styleName:"ToolSearch"},SendMessage:{label:"Message agent",styleName:"SendMessage"},ListAgents:{label:"List agents",styleName:"ListAgents"},TaskCreate:{label:"Create task",styleName:"TaskCreate"},TaskUpdate:{label:"Update task",styleName:"TaskUpdate"},TaskList:{label:"List tasks",styleName:"TaskList"},TaskOutput:{label:"Read task output",styleName:"TaskOutput"},TaskStop:{label:"Stop task",styleName:"TaskStop"},NotebookEdit:{label:"Edit notebook",styleName:"Edit"},EnterPlanMode:{label:"Enter plan mode",styleName:"EnterPlanMode"},ExitPlanMode:{label:"Exit plan mode",styleName:"ExitPlanMode"},EnterWorktree:{label:"Enter worktree",styleName:"EnterWorktree"},ExitWorktree:{label:"Exit worktree",styleName:"ExitWorktree"},Workflow:{label:"Run workflow",styleName:"Workflow"},exec_command:{label:"Run command",styleName:"Bash"},write_stdin:{label:"Continue command",styleName:"Bash"},apply_patch:{label:"Apply patch",styleName:"Edit"},update_plan:{label:"Update plan",styleName:"TodoWrite"},request_user_input:{label:"Ask question",styleName:"AskUserQuestion"},request_user_input_async:{label:"Ask question",styleName:"AskUserQuestion"},wait:{label:"Wait for tools",styleName:"Mcp"},spawn_agent:{label:"Spawn agent",styleName:"Task"},wait_agent:{label:"Wait for agents",styleName:"TaskOutput"},send_message:{label:"Message agent",styleName:"SendMessage"},followup_task:{label:"Follow up",styleName:"Task"},list_agents:{label:"List agents",styleName:"ListAgents"},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:"TaskList"},update_goal:{label:"Update goal",styleName:"TodoWrite"},view_image:{label:"View image",styleName:"Read"}},JT=new Set(["Write","Edit","Bash","exec","Task","Agent","Skill","TodoWrite","Image","AskUserQuestion","CronCreate","CronDelete","ScheduleWakeup","RemoteTrigger","PushNotification","EnterWorktree","ExitWorktree","SendMessage","EndConversation","TaskCreate","TaskUpdate","TaskStop","Workflow"]);function QT(n){var t;const e=yn(n);return JT.has(((t=ia[e])==null?void 0:t.styleName)??e)?"mutating":"readOnly"}function u2(n){return typeof n=="object"&&n!==null}function Dt(...n){return n.find(e=>typeof e=="string")??""}function fs(n){return typeof n!="string"?"":/^gAAAAA[A-Za-z0-9_-]+={0,2}$/.test(n.trim())?"Encrypted message":n}function Ro(n){const e=n.command??n.cmd;return typeof e=="string"?e:!Array.isArray(e)||!e.every(t=>typeof t=="string")?"":e.map(t=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(t)?t:`'${t.replace(/'/g,`'"'"'`)}'`).join(" ")}function Jn(n,e=140){const t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}…`:t}function Cu(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=Cu(n);if(t.length===0)return e;const s=Jn(t[0]);return t.length===1?s:`${s} · +${t.length-1} more`}function Ka(n,e){return n===1?`1 ${e}`:`${n} ${e}${/(?:ch|sh|s|x|z)$/.test(e)?"es":"s"}`}const Lp={mcp:"MCP",api:"API",url:"URL",openai:"OpenAI",figma:"Figma",clickup:"ClickUp"};function jr(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 Lp[i]?Lp[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 ZT(n){if(!n)return null;const e=n.trim(),t=Mn(e,0);return(t==null?void 0:t.endIndex)===e.length?t.value:null}function Lt(n,...e){for(const t of e){const s=ZT(Fa(n,t));if(s)return s;const o=iu(n,t)[0];if(o)return o}return""}function e8(n,...e){for(const t of e){const s=Wx(n,t)[0];if(s!==void 0)return s}return null}function aa(n){return Lt(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 t8=[{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 Dp(n,e){return e.flatMap(t=>iu(n,t))}function n8(n,e){const t=e.summaryGroups.map(i=>Dp(n,i)),s=e.detail?Wx(n,e.detail.property):[],o=e.countProperties?Dp(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(Hx(n),Cu(o).length,s.length,1)}}function s8(n){const e=[];for(const t of t8){const s=Fa(n,t.key);s&&e.push(n8(s,t))}return e}function f2(n){const e=s8(n);return e.length===0?{label:"Browse web",summary:aa(n),styleName:"WebSearch"}:e.length===1?{label:e[0].label,summary:e[0].summary,styleName:"WebSearch"}:{label:"Browse web",summary:e.map(t=>Ka(t.count,t.noun)).join(" · "),styleName:"WebSearch"}}function m2(n){if(!n.startsWith("mcp__"))return null;const[,e,...t]=n.split("__");return!e||t.length===0?null:{server:jr(e,!0),action:jr(t.join(" "))}}function o8(n,e){const t=m2(n);if(!t)return{label:jr(n),summary:aa(e),styleName:"Mcp"};const s=aa(e);return{label:t.server,summary:[t.action,s].filter(Boolean).join(" · "),styleName:"Mcp"}}function p2(n){const e=Mn(n.trim(),0),t=(e==null?void 0:e.value)??n,s=Cu(Array.from(t.matchAll(/^\*\*\*\s+(?:Update|Add|Delete) File:\s*(.+)$/gm),o=>o[1]));return Qr(s,s.length>0?Ka(s.length,"file"):"")}function r8(n){const e=n.argumentSource;switch(yn(n.name)){case"exec_command":return{label:"Run command",summary:Lt(e,"cmd","command"),styleName:"Bash"};case"write_stdin":{const t=e8(e,"session_id"),s=Lt(e,"chars");return{label:"Continue command",summary:[t!==null?`session ${t}`:"",s?Jn(s,60):""].filter(Boolean).join(" · "),styleName:"Bash"}}case"apply_patch":return{label:"Apply patch",summary:p2(e),styleName:"Edit"};case"web__run":case"web_search":return f2(e);case"view_image":return{label:"View image",summary:Lt(e,"path"),styleName:"Read"};case"update_plan":{const t=Fa(e,"plan"),s=t?Hx(t):0;return{label:"Update plan",summary:s>0?Ka(s,"step"):Lt(e,"explanation"),styleName:"TodoWrite"}}case"create_goal":return{label:"Create goal",summary:Lt(e,"objective"),styleName:"TodoWrite"};case"get_goal":return{label:"Check goal",summary:"",styleName:"TaskList"};case"update_goal":return{label:"Update goal",summary:Lt(e,"status"),styleName:"TodoWrite"};case"list_mcp_resources":return{label:"List MCP resources",summary:Lt(e,"server"),styleName:"Mcp"};case"list_mcp_resource_templates":return{label:"List MCP templates",summary:Lt(e,"server"),styleName:"Mcp"};case"read_mcp_resource":return{label:"Read MCP resource",summary:[Lt(e,"server"),Lt(e,"uri")].filter(Boolean).join(" · "),styleName:"Mcp"};case"request_plugin_install":return{label:"Install plugin",summary:Lt(e,"plugin_id"),styleName:"Mcp"};case"tool_search":return{label:"Find tools",summary:Lt(e,"query"),styleName:"ToolSearch"};case"image_gen__imagegen":return{label:"Generate image",summary:Lt(e,"prompt"),styleName:"Image"};case"spawn_agent":return{label:"Spawn agent",summary:fs(Lt(e,"task_name","message")),styleName:"Task"};case"send_message":case"followup_task":return{...ia[yn(n.name)],summary:[Lt(e,"target"),fs(Lt(e,"message"))].filter(Boolean).join(" · ")};default:{const t=yn(n.name),s=ia[t];return t.startsWith("mcp__")?o8(t,e):{label:(s==null?void 0:s.label)??jr(t),summary:fs(aa(e)),styleName:(s==null?void 0:s.styleName)??t}}}}function i8(n){const e=Fx(n);if(e.length===0)return{label:"Run tool script",summary:"",styleName:"exec"};const t=e.map(r8),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 a8(n){const e=u2(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:Dt(e==null?void 0:e.url,n.query),styleName:"WebSearch"};if(t==="find_in_page"||t==="findInPage")return{label:"Find on page",summary:[Dt(e==null?void 0:e.pattern),Dt(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=Dt(e==null?void 0:e.query,n.query);return{label:"Search web",summary:Qr([o,...s]),styleName:"WebSearch"}}const l8=["summary","headline","verdict","title"];function c8(n){const e=Dt(...l8.map(t=>n[t]));if(e)return Jn(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 d8(n){const e=Dt(n.description);if(e)return Jn(e);const t=Dt(n.script);return(t?iu(t,"name")[0]??"":"")||Dt(n.scriptPath)}function zp(n){const e=Dt(...["description","summary","query","q","command","cmd","file_path","path","url","uri","pattern","prompt","objective","message","title","name"].map(s=>n[s]));if(e)return Jn(e);const t=Object.entries(n).find(([s,o])=>s!=="raw"&&s!=="script"&&typeof o=="string");return t?Jn(t[1]):""}function Fp(n){const e=n.input;switch(n.name){case"Read":case"Write":case"Edit":return String(e.file_path??e.path??"");case"Bash":case"exec_command":return Ro(e);case"write_stdin":return[e.session_id!==void 0?`session ${e.session_id}`:"",Dt(e.chars)].filter(Boolean).join(" · ");case"apply_patch":return p2(Dt(e.patch,e.raw,e.input));case"TodoWrite":case"update_plan":{const t=Array.isArray(e.todos)?e.todos:Array.isArray(e.plan)?e.plan:[];return t.length>0?Ka(t.length,"step"):Dt(e.explanation)}case"Grep":case"Glob":return String(e.pattern??"");case"Task":case"Agent":return fs(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":case"request_user_input":case"request_user_input_async":{const t=Array.isArray(e.questions)?e.questions.find(u2):null;return Dt(t==null?void 0:t.question,t==null?void 0:t.title)}case"Monitor":{const t=String(e.bash_id??""),s=e.filter?` · filter=${e.filter}`:"";return`${t}${s}`}case"CronCreate":{const t=String(e.schedule??e.cron??""),s=String(e.prompt??""),o=s.length>60?s.slice(0,60)+"...":s;return t&&o?`${t} → ${o}`:t||o}case"CronList":return"";case"CronDelete":return String(e.id??e.cron_id??"");case"ScheduleWakeup":{const t=Number(e.delaySeconds??0),s=Math.round(t/60),o=t>=3600?`${Math.round(t/3600)}h`:t>=60?`${s}m`:`${t}s`,i=e.reason?` · ${e.reason}`:"";return`in ${o}${i}`}case"RemoteTrigger":{const t=String(e.action??""),s=String(e.id??e.trigger_id??"");return[t,s].filter(Boolean).join(" ")}case"PushNotification":return String(e.title??e.body??"");case"EnterWorktree":{const t=String(e.name??e.branch??""),s=e.path?` (${e.path})`:"";return`${t}${s}`}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 t=Dt(e.to,e.recipient),s=Jn(fs(Dt(e.summary,e.message,e.content)));return[t,s].filter(Boolean).join(" · ")}case"ListAgents":case"TaskList":return"";case"TaskCreate":return Jn(Dt(e.subject,e.description));case"TaskUpdate":{const t=String(e.taskId??""),s=Array.isArray(e.addBlockedBy)?e.addBlockedBy.filter(i=>typeof i=="string"):[],o=Dt(e.status)||(s.length>0?`blocked by ${s.join(", ")}`:"");return o?`${t} → ${o}`:t}case"TaskOutput":case"TaskStop":return String(e.task_id??"");case"Workflow":return d8(e);case"StructuredOutput":case"ReportFindings":case"DesignSync":case"Artifact":case"LSP":return c8(e)||zp(e);case"spawn_agent":return fs(e.task_name??e.message);case"wait_agent":{const t=Array.isArray(e.ids)?e.ids.filter(s=>typeof s=="string"):[];return Qr(t)}case"send_message":case"followup_task":return[e.target,fs(e.message)].filter(t=>typeof t=="string"&&t.length>0).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(t=>typeof t=="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 zp(e)}}function Zr(n){if(au(n))return i8(n.input.raw);const e=yn(n.name);if(e==="WebSearch"||e==="web_search")return a8(n.input);if(e==="web__run"||e==="web.run")return f2(JSON.stringify(n.input));const t=m2(n.name);if(t)return{label:t.server,summary:[t.action,Fp(n)].filter(Boolean).join(" · "),styleName:"Mcp"};const s=ia[e];return{label:(s==null?void 0:s.label)??jr(e),summary:Jn(Fp({name:e,input:n.input})),styleName:(s==null?void 0:s.styleName)??e}}function u8(n){return Zr(n).summary}const f8={file_path:"File",path:"Path",target:"Recipient",recipient:"Recipient",recipient_agent_id:"Recipient",agent_id:"Agent",agent_type:"Agent type",subagent_type:"Agent type",task_name:"Task",description:"Description",message:"Message",prompt:"Task",content:"Content",query:"Query",pattern:"Pattern",url:"URL",workdir:"Working directory",cwd:"Working directory",max_output_tokens:"Output limit",yield_time_ms:"Yield",timeout_ms:"Timeout"};function m8(n){return f8[n]??n.replace(/_/g," ").replace(/^./,e=>e.toUpperCase())}function p8(n,e){if(typeof e=="number"){if(n==="max_output_tokens")return`${e.toLocaleString()} tokens`;if(n.endsWith("_ms"))return e<1e3?`${e} ms`:`${e/1e3} sec`}return String(e)}function Sr(n){const e=B.c(20),{value:t}=n,[s,o]=y.useState(!1),i=y.useId();let a,l,c,d;if(e[0]!==s||e[1]!==i||e[2]!==t){const p=fs(t);a=p.length>800,l=i;const h=s&&"max-h-96 overflow-auto";e[7]!==h?(c=K("whitespace-pre-wrap break-words [overflow-wrap:anywhere]",h),e[7]=h,e[8]=c):c=e[8],d=a&&!s?`${p.slice(0,800)}…`:p,e[0]=s,e[1]=i,e[2]=t,e[3]=a,e[4]=l,e[5]=c,e[6]=d}else a=e[3],l=e[4],c=e[5],d=e[6];let u;e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{id:l,className:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12];let f;e[13]!==s||e[14]!==i||e[15]!==a?(f=a&&r.jsx(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":s,"aria-controls":i,onClick:()=>o(h8),children:s?"Show less":"Show more"}),e[13]=s,e[14]=i,e[15]=a,e[16]=f):f=e[16];let m;return e[17]!==u||e[18]!==f?(m=r.jsxs(r.Fragment,{children:[u,f]}),e[17]=u,e[18]=f,e[19]=m):m=e[19],m}function h8(n){return!n}function g8(n){const e=n.todos??n.plan;return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t,o=s.content??s.step??s.description;return typeof o=="string"?[{text:o,status:typeof s.status=="string"?s.status:"pending"}]:[]}):[]}function x8(n){const e=B.c(4),{steps:t}=n;let s;e[0]!==t?(s=t.map(b8),e[0]=t,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("section",{className:"mt-2 min-w-0","aria-label":"Plan",children:r.jsx("ol",{className:"flex flex-col gap-2",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function b8(n,e){const t=n.status==="completed",s=n.status==="in_progress",o=t?lt:s?xd:va,i=t?"Completed":s?"In progress":"Pending";return r.jsxs("li",{className:"flex min-w-0 items-start gap-2 text-xs",children:[r.jsx(o,{role:"img","aria-label":i,className:K("mt-0.5 size-3 shrink-0 text-muted-foreground",s&&"text-info")}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(Sr,{value:n.text})}),r.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:i})]},e)}function v8(n){const e=B.c(4),{questions:t}=n;let s;e[0]!==t?(s=t.map(y8),e[0]=t,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("section",{className:"mt-2 flex min-w-0 flex-col gap-3","aria-label":"Questions",children:s}),e[2]=s,e[3]=o):o=e[3],o}function y8(n,e){return r.jsxs("div",{className:"min-w-0 text-xs",children:[r.jsx(Sr,{value:String(n.question??n.title)}),Array.isArray(n.options)&&r.jsx("ul",{className:"mt-2 flex min-w-0 flex-col gap-1.5 border-l border-border pl-3",children:n.options.map(w8)})]},e)}function w8(n,e){const t=typeof n=="string"?{label:n}:n;return!t||typeof t.label!="string"?null:r.jsxs("li",{className:"min-w-0",children:[r.jsx(Sr,{value:t.label}),typeof t.description=="string"&&r.jsx("div",{className:"mt-0.5 text-muted-foreground",children:r.jsx(Sr,{value:t.description})})]},e)}function h2(n){const e=B.c(21),{input:t}=n;let s;e[0]!==t?(s=g8(t),e[0]=t,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.questions?(i=Array.isArray(t.questions)?t.questions.filter(N8):[],e[2]=t.questions,e[3]=i):i=e[3];const a=i;let l,c,d,u,f;if(e[4]!==t||e[5]!==a||e[6]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=Object.entries(t).filter(S8);if(o.length===0&&p.length===0&&a.length===0){f=null;break e}l="min-w-0",e[12]!==o?(c=o.length>0&&r.jsx(x8,{steps:o}),e[12]=o,e[13]=c):c=e[13],e[14]!==a?(d=a.length>0&&r.jsx(v8,{questions:a}),e[14]=a,e[15]=d):d=e[15],u=p.length>0&&r.jsx("dl",{className:"mt-2 flex min-w-0 flex-col gap-2","aria-label":"Call details",children:p.map(j8)})}e[4]=t,e[5]=a,e[6]=o,e[7]=l,e[8]=c,e[9]=d,e[10]=u,e[11]=f}else l=e[7],c=e[8],d=e[9],u=e[10],f=e[11];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[16]!==l||e[17]!==c||e[18]!==d||e[19]!==u?(m=r.jsxs("div",{className:l,children:[c,d,u]}),e[16]=l,e[17]=c,e[18]=d,e[19]=u,e[20]=m):m=e[20],m}function j8(n){const[e,t]=n;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(4rem,auto)_minmax(0,1fr)] items-start gap-x-3 text-xs",children:[r.jsx("dt",{className:"max-w-32 break-words text-muted-foreground",children:m8(e)}),r.jsx("dd",{className:"min-w-0",children:r.jsx(Sr,{value:p8(e,t)})})]},e)}function S8(n){const[e,t]=n;return e!=="raw"&&e!=="type"&&(typeof t=="string"?t.length>0:typeof t=="number"||typeof t=="boolean")}function N8(n){return n!==null&&typeof n=="object"&&typeof(n.question??n.title)=="string"}function k8(n){const e=B.c(25),{name:t,input:s}=n;let o;e[0]!==s||e[1]!==t?(o=Zr(typeof s.raw=="string"&&s.raw.startsWith("{")?{name:"exec",input:{raw:`tools.${t}(${s.raw})`}}:{name:t,input:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2];const i=o;let a;e[3]!==s?(a=Ro(s),e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]!==l||e[6]!==s?(c=l?Object.fromEntries(Object.entries(s).filter(C8)):s,e[5]=l,e[6]=s,e[7]=c):c=e[7];const d=c;let u;e[8]!==i.label?(u=r.jsx("span",{className:"font-medium",children:i.label}),e[8]=i.label,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==i.summary?(f=i.summary&&!l&&r.jsx("span",{className:"truncate text-muted-foreground",children:i.summary}),e[10]=l,e[11]=i.summary,e[12]=f):f=e[12];let m;e[13]!==u||e[14]!==f?(m=r.jsxs("div",{className:"mb-1 flex min-w-0 flex-wrap items-center gap-x-2 text-xs",children:[u,f]}),e[13]=u,e[14]=f,e[15]=m):m=e[15];let p;e[16]!==l?(p=l&&r.jsx(xx,{code:l,language:"bash",label:"Command"}),e[16]=l,e[17]=p):p=e[17];let h;e[18]!==d?(h=r.jsx(h2,{input:d}),e[18]=d,e[19]=h):h=e[19];let g;return e[20]!==i.label||e[21]!==m||e[22]!==p||e[23]!==h?(g=r.jsxs("section",{className:"min-w-0","aria-label":i.label,children:[m,p,h]}),e[20]=i.label,e[21]=m,e[22]=p,e[23]=h,e[24]=g):g=e[24],g}function C8(n){const[e]=n;return e!=="command"&&e!=="cmd"}function _8(n){const e=B.c(32),{input:t}=n,s=String(t.raw??"");let o;e[0]!==t?(o=qx(t),e[0]=t,e[1]=o):o=e[1];const i=o,[a,l]=y.useState(!1),[c,d]=Xn(),u=y.useId(),f=i.length===0||a;let m;e[2]!==i?(m=i.length>0&&r.jsx("div",{className:"flex min-w-0 flex-col gap-3",children:i.map(E8)}),e[2]=i,e[3]=m):m=e[3];let p;e[4]!==i.length||e[5]!==f||e[6]!==u?(p=i.length>0?r.jsxs(ee,{type:"button",variant:"ghost",size:"xs","aria-expanded":f,"aria-controls":u,onClick:()=>l(T8),children:[r.jsx(Ve,{"data-icon":"inline-start",className:K(f&&"rotate-90")}),"Source"]}):r.jsx("span",{className:"text-xs text-muted-foreground",children:"Script"}),e[4]=i.length,e[5]=f,e[6]=u,e[7]=p):p=e[7];let h;e[8]!==d||e[9]!==s?(h=()=>d(s),e[8]=d,e[9]=s,e[10]=h):h=e[10];const g=c?"Tool script copied":"Copy script";let x;e[11]!==c?(x=c?r.jsx(lt,{"data-icon":"icon"}):r.jsx(fn,{"data-icon":"icon"}),e[11]=c,e[12]=x):x=e[12];let v;e[13]!==h||e[14]!==g||e[15]!==x?(v=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:h,"aria-label":g,children:x}),e[13]=h,e[14]=g,e[15]=x,e[16]=v):v=e[16];let w;e[17]!==p||e[18]!==v?(w=r.jsxs("div",{className:"mb-1 mt-1 flex items-center justify-between gap-2",children:[p,v]}),e[17]=p,e[18]=v,e[19]=w):w=e[19];let b;e[20]!==s?(b=r.jsx(xx,{code:s,language:"typescript",label:"Codex exec script"}),e[20]=s,e[21]=b):b=e[21];let j;e[22]!==u||e[23]!==b?(j=r.jsx(dt,{id:u,children:b}),e[22]=u,e[23]=b,e[24]=j):j=e[24];let S;e[25]!==f||e[26]!==j?(S=r.jsx(ct,{open:f,children:j}),e[25]=f,e[26]=j,e[27]=S):S=e[27];let N;return e[28]!==S||e[29]!==m||e[30]!==w?(N=r.jsxs("section",{className:"mt-2 min-w-0","aria-label":"Tool script",children:[m,w,S]}),e[28]=S,e[29]=m,e[30]=w,e[31]=N):N=e[31],N}function T8(n){return!n}function E8(n,e){return r.jsx(k8,{...n},e)}const A8=/(?:^|;|&&)\s*echo\s+(["']?)---([\w.-]*)\1\s*(?=;|&&|$)/g;function Bp(n){return n.replace(/^\s*(?:;|&&)/,"").trim()}function P8(n,e){const t=[],s=[];let o=0;for(const l of n.matchAll(A8)){const c=Bp(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=Bp(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:$8(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 $8(n,e){const t=[[]];let s=0;for(const o of n.split(/\r\n|\r|\n/))s<e.length&&o===`---${e[s]}`?(t.push([]),s++):t[t.length-1].push(o);return t.map(o=>o.join(`
|
|
102
|
+
`).trim())}const I8=new Set(["mv","cp","rm","mkdir","touch","tee","ln","chmod","chown","install","rsync"]),R8=/(?:^|[^\d&])>{1,2}(?!\s*&|\s*\/dev\/null)/,M8=/\|\||&&|[|;\n]/,O8=new Set(["echo","printf","true","false",":"]),L8=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),D8=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr","sed","diff","xxd","od"]),z8=new Set(["ls","tree","du"]),F8=new Set(["xargs","sudo","env","time","nohup","command"]);function B8(n){const e=n.split(/\s+/);for(;e.length>1&&(F8.has(e[0])||/^-/.test(e[0]));)e.shift();const[t,...s]=e;return I8.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:R8.test(n)}const g2=/<<-?\s*['"]?\w+['"]?/,U8=/'[^']*'|"(?:[^"\\]|\\.)*"/g;function W8(n){return n.split(g2)[0].replace(U8,'""').split(M8).map(e=>e.trim()).filter(Boolean)}function H8(n){const e=W8(n);if(e.some(B8))return"write";let t=!1,s=!1,o=!1;for(const i of e){const a=i.split(/\s+/)[0];if(!(!a||O8.has(a)))if(L8.has(a))t=!0;else if(D8.has(a))s=!0;else if(z8.has(a))o=!0;else return"run"}return o?"list":t?"search":s?"read":"run"}const q8=/^["']?((?:~|\.{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 x2(n){const e=new Set;for(const t of n.split(g2)[0].split(/\s+/)){const s=t.match(q8);if(!s)continue;const o=s[1];o.includes("*")||o.includes("{")||o.startsWith("-")||e.add(o)}return[...e]}const K8=/^(?: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 V8(n){const e=n.trim().match(K8);if(!e)return null;const[,t,s,,o]=e;return x2(o).length?t?{path:o,from:Number(t),to:Number(s)}:{path:o}:null}const G8=/(?: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 Y8(n,e){return!e||n==="read"&&e.split(`
|
|
103
|
+
`).length>3?!1:G8.test(e)}function b2(n){const e=H8(n.command);return{kind:e,paths:x2(n.command),readFile:e==="read"?V8(n.command):null,failed:Y8(e,n.output)}}function v2(n){var e;return n.label||((e=n.command.match(/^[\w.-]+/))==null?void 0:e[0])||"…"}function X8(n){const e=[],t=new Map;for(const s of n){const o=v2(s),i=b2(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 y2={muted:"text-muted-foreground",failed:"border-destructive/30 text-destructive"},la={read:{icon:zi,label:"read",plural:"reads"},search:{icon:tn,label:"search",plural:"searches"},list:{icon:bo,label:"list",plural:"lists"},run:{icon:$r,label:"run",plural:"runs"},write:{icon:mc,label:"write",plural:"writes"}},J8=["read","search","list","run","write"],Q8=new Set(["command","cmd","description","timeout","run_in_background"]);function w2(n){const e=Ro(n.input);return P8(e,n.result)??[{label:"",command:e,output:n.result}]}function Z8(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 e9(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 t9(n){return n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function n9(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 s9(n){const e=[];n.timeout!==void 0&&e.push(e9(n.timeout)),typeof n.run_in_background=="boolean"&&e.push(n.run_in_background?"Background":"Foreground");for(const[t,s]of Object.entries(n))Q8.has(t)||s===void 0||e.push(`${t9(t)} ${n9(s)}`);return e}function o9(n,e){const t=w2(n),s=t.map(b2),o=Z8(n,t,s);return{toolCall:n,command:Ro(n.input),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:s9(n.input)}}function j2(n){return n?n.split(`
|
|
104
|
+
`).length:0}function r9(n){if(n.pending)return"running";if(n.section.output===null)return"not run";if(n.section.output==="")return"no output";const e=j2(n.section.output);return e===1?"1 line":`${e} lines`}function i9(n,e){return n.startsWith("/")?n:n.startsWith("~")||!e?null:`${e.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}function S2(n){const e=B.c(12),{path:t,line:s,cwd:o,children:i}=n;let a;e[0]!==o||e[1]!==t?(a=i9(t,o),e[0]=o,e[1]=t,e[2]=a):a=e[2];const l=a;if(!l||!et("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(),gr(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 a9(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(S2,{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 l9=/^([^\s:]+):(\d+)([:-])/,Bl="mb-1.5 ml-6 min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] border-l pl-3 font-mono text-[11px] leading-relaxed text-muted-foreground";function c9(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=K(Bl,"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(bx,{result:o,filePath:t.analysis.readFile.path,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(l9);return r.jsx("span",{className:"block",children:p?r.jsxs(r.Fragment,{children:[r.jsxs(S2,{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:Bl,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=K(Bl,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 d9(n){var H;const e=B.c(56),{row:t,index:s,defaultOpen:o,cwd:i}=n,[a,l]=y.useState(o);let c;e[0]!==t.section?(c=v2(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=la[t.analysis.kind].icon,p=t.failed&&"text-destructive";let h;e[2]!==p?(h=K("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 v=la[t.analysis.kind];let w;e[7]!==m||e[8]!==v.label?(w=r.jsx(m,{className:"size-3 shrink-0 text-muted-foreground","aria-label":v.label}),e[7]=m,e[8]=v.label,e[9]=w):w=e[9];const b=t.failed&&y2.failed;let j;e[10]!==b?(j=K("h-5 shrink-0 px-1.5 font-mono text-[10px] text-muted-foreground",b),e[10]=b,e[11]=j):j=e[11];let S;e[12]!==d||e[13]!==j?(S=r.jsx(Ie,{variant:"outline",className:j,children:d}),e[12]=d,e[13]=j,e[14]=S):S=e[14];let N;e[15]!==i||e[16]!==t.analysis.paths||e[17]!==t.section.command?(N=r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/85",children:r.jsx(a9,{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]=N):N=e[18];let C;e[19]!==t.analysis.readFile?(C=((H=t.analysis.readFile)==null?void 0:H.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 k=t.failed&&"font-medium text-destructive";let T;e[21]!==k?(T=K("shrink-0 text-[10px] tabular-nums text-muted-foreground",k),e[21]=k,e[22]=T):T=e[22];let E;e[23]!==t?(E=t.failed?"failed":r9(t),e[23]=t,e[24]=E):E=e[24];let P;e[25]!==T||e[26]!==E?(P=r.jsx("span",{className:T,children:E}),e[25]=T,e[26]=E,e[27]=P):P=e[27];const _=a&&"rotate-90",A=!u&&"invisible";let I;e[28]!==_||e[29]!==A?(I=K("size-3 shrink-0 text-muted-foreground/60 transition-transform",_,A),e[28]=_,e[29]=A,e[30]=I):I=e[30];let R;e[31]!==I?(R=r.jsx(Ve,{className:I,"aria-hidden":"true"}),e[31]=I,e[32]=R):R=e[32];let $;e[33]!==S||e[34]!==N||e[35]!==C||e[36]!==P||e[37]!==R||e[38]!==x||e[39]!==w?($=r.jsxs(r.Fragment,{children:[x,w,S,N,C,P,R]}),e[33]=S,e[34]=N,e[35]=C,e[36]=P,e[37]=R,e[38]=x,e[39]=w,e[40]=$):$=e[40];const M=$;if(!u){let W;return e[41]!==M||e[42]!==f?(W=r.jsx("div",{className:"group/row flex min-w-0 w-full items-center gap-2 py-2 text-left","aria-label":f,children:M}),e[41]=M,e[42]=f,e[43]=W):W=e[43],W}let L,D;e[44]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("div",{role:"button",tabIndex:0}),D=K("group/row flex min-w-0 w-full items-center gap-2 py-2 text-left","cursor-pointer rounded-sm hover:bg-muted/40"),e[44]=L,e[45]=D):(L=e[44],D=e[45]);let F;e[46]!==M||e[47]!==f?(F=r.jsx(Pt,{nativeButton:!1,render:L,className:D,"aria-label":f,children:M}),e[46]=M,e[47]=f,e[48]=F):F=e[48];let z;e[49]!==i||e[50]!==t?(z=r.jsx(dt,{children:r.jsx(c9,{row:t,cwd:i})}),e[49]=i,e[50]=t,e[51]=z):z=e[51];let O;return e[52]!==a||e[53]!==F||e[54]!==z?(O=r.jsxs(ct,{open:a,onOpenChange:l,children:[F,z]}),e[52]=a,e[53]=F,e[54]=z,e[55]=O):O=e[55],O}function u9(n){const e=new Map;for(const{analysis:t}of n)e.set(t.kind,(e.get(t.kind)??0)+1);return J8.filter(t=>e.has(t)).map(t=>{const s=e.get(t)??0;return`${s} ${s===1?la[t].label:la[t].plural}`}).join(" · ")}function f9(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(m9),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 m9(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function p9(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 V;e[3]!==l?(V=q=>o9(q,l),e[3]=l,e[4]=V):V=e[4],c=t.map(V),e[0]=l,e[1]=t,e[2]=c}else c=e[2];const d=c,u=d.flatMap(w9),f=u.length,m=u.reduce(y9,0),p=u.filter(v9).length,h=u.filter(b9).length,[g,x]=Xn();let v;e[5]!==d?(v=d.map(x9).join(`
|
|
106
|
+
|
|
107
|
+
`),e[5]=d,e[6]=v):v=e[6];const w=v,b=d.length===1?d[0].description:void 0;let j;e[7]!==d[0]||e[8]!==d.length?(j=d.length===1?d[0].options:[],e[7]=d[0],e[8]=d.length,e[9]=j):j=e[9];const S=j;let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(go,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),e[10]=N):N=e[10];const C=ln,k="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 [overflow-wrap:anywhere]";let T;e[11]!==d.length?(T=d.length>1&&r.jsxs("span",{children:[d.length," calls"]}),e[11]=d.length,e[12]=T):T=e[12];const E=u9(u);let P;e[13]!==E?(P=r.jsx("span",{children:E}),e[13]=E,e[14]=P):P=e[14];let _;e[15]!==b?(_=b&&r.jsx("span",{className:"text-foreground/70",children:b}),e[15]=b,e[16]=_):_=e[16];let A;e[17]!==S?(A=S.map(g9),e[17]=S,e[18]=A):A=e[18];const I=m===1?"line":"lines";let R;e[19]!==p?(R=p>0&&r.jsxs("span",{className:"font-medium text-destructive",children:[" · ",p," failed"]}),e[19]=p,e[20]=R):R=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]!==I||e[24]!==R||e[25]!==$||e[26]!==m?(M=r.jsxs("span",{className:"ml-auto tabular-nums",children:[m," ",I,R,$]}),e[23]=I,e[24]=R,e[25]=$,e[26]=m,e[27]=M):M=e[27];let L;e[28]!==C||e[29]!==P||e[30]!==_||e[31]!==A||e[32]!==M||e[33]!==T?(L=r.jsxs(C,{className:k,children:[T,P,_,A,M]}),e[28]=C,e[29]=P,e[30]=_,e[31]=A,e[32]=M,e[33]=T,e[34]=L):L=e[34];let D;e[35]!==w||e[36]!==x?(D=()=>x(w),e[35]=w,e[36]=x,e[37]=D):D=e[37];const F=g?"Commands copied":f===1?"Copy command":"Copy commands",z=g?"Copied":f===1?"Copy command":"Copy commands";let O;e[38]!==g?(O=g?r.jsx(lt,{"data-icon":"inline-start","aria-hidden":"true"}):r.jsx(fn,{"data-icon":"inline-start","aria-hidden":"true"}),e[38]=g,e[39]=O):O=e[39];let H;e[40]!==D||e[41]!==F||e[42]!==z||e[43]!==O?(H=r.jsx(nx,{children:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:D,"aria-label":F,title:z,children:O})}),e[40]=D,e[41]=F,e[42]=z,e[43]=O,e[44]=H):H=e[44];let W;e[45]!==d||e[46]!==s||e[47]!==a?(W=d.map((V,q)=>{const X=d.slice(0,q).reduce(h9,0);return r.jsxs("div",{children:[q>0&&r.jsx(wt,{}),d.length>1&&r.jsx(f9,{call:V,index:q}),V.rows.map((G,Y)=>r.jsx(d9,{row:G,index:X+Y,defaultOpen:a,cwd:s},Y))]},V.toolCall.id)}),e[45]=d,e[46]=s,e[47]=a,e[48]=W):W=e[48];let U;return e[49]!==W?(U=r.jsx(en,{children:r.jsx("div",{"aria-label":"Command sections",children:W})}),e[49]=W,e[50]=U):U=e[50],r.jsxs(Zt,{size:"sm",className:"mt-1.5 min-w-0",role:"region","aria-label":f===1?"Bash command":"Bash commands",children:[r.jsxs(rn,{children:[r.jsxs(an,{className:"flex min-w-0 items-center gap-2",children:[N,f," ",f===1?"command":"commands"]}),L,H]}),U]})}function h9(n,e){return n+e.rows.length}function g9(n){return r.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:n},n)}function x9(n){return n.command}function b9(n){return n.section.output===null&&!n.pending}function v9(n){return n.failed}function y9(n,e){return n+j2(e.section.output)}function w9(n){return n.rows}const N2=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function j9(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=K("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(N2.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(V3,{"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 S9(n){const e=B.c(19);let t,s,o,i,a;e[0]!==n?({className:s,children:t,variant:i,size:a,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=a):(t=e[1],s=e[2],o=e[3],i=e[4],a=e[5]);const l=i===void 0?"default":i,c=a===void 0?"default":a,d=y.useContext(N2),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=K("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",fg({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(x1,{"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 k2(n){const e=B.c(22),{option:t,multiSelect:s,selected:o,showSelectedBadge:i}=n,a=i===void 0?!1:i,l=s?"rounded":"rounded-full",c=o?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/30";let d;e[0]!==l||e[1]!==c?(d=K("mt-0.5 flex size-4 shrink-0 items-center justify-center border",l,c),e[0]=l,e[1]=c,e[2]=d):d=e[2];let u;e[3]!==o?(u=o&&r.jsx(lt,{className:"size-3",strokeWidth:3,"data-icon":"icon"}),e[3]=o,e[4]=u):u=e[4];let f;e[5]!==d||e[6]!==u?(f=r.jsx("span",{className:d,"aria-hidden":"true",children:u}),e[5]=d,e[6]=u,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=a&&o&&r.jsx(Ie,{variant:"secondary",className:"ml-2",children:"Selected"}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]!==t.label||e[12]!==m?(p=r.jsxs("span",{className:"block text-xs font-medium",children:[t.label,m]}),e[11]=t.label,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t.description?(h=t.description&&r.jsx("span",{className:"mt-0.5 block text-xs leading-relaxed text-muted-foreground",children:t.description}),e[14]=t.description,e[15]=h):h=e[15];let g;e[16]!==p||e[17]!==h?(g=r.jsxs("span",{className:"min-w-0 flex-1",children:[p,h]}),e[16]=p,e[17]=h,e[18]=g):g=e[18];let x;return e[19]!==g||e[20]!==f?(x=r.jsxs(r.Fragment,{children:[f,g]}),e[19]=g,e[20]=f,e[21]=x):x=e[21],x}function N9(n){const e=B.c(30),{toolCall:t,sessionId:s}=n;let o;e[0]!==t.input.questions?(o=t.input.questions??[],e[0]=t.input.questions,e[1]=o):o=e[1];const i=o;let a;e[2]!==i?(a=()=>Object.fromEntries(i.map(k9)),e[2]=i,e[3]=a):a=e[3];const[l,c]=y.useState(a),[d,u]=y.useState(!1),[f,m]=y.useState(!1),{chat:p}=zr(),{sendMessage:h}=p;if(i.length===0)return null;let g;e[4]!==l||e[5]!==i||e[6]!==h?(g=()=>{const T=i.map(E=>{var _;const P=(_=l[E.question])==null?void 0:_.trim();return P?i.length>1?`${E.question}
|
|
108
|
+
${P}`:P:null}).filter(Boolean).join(`
|
|
109
|
+
|
|
110
|
+
`);T&&h(T),m(!0)},e[4]=l,e[5]=i,e[6]=h,e[7]=g):g=e[7];const x=g;let v;if(e[8]!==l||e[9]!==x||e[10]!==s||e[11]!==t.id){const T=async E=>{E.preventDefault(),u(!0);try{(await zd(s,t.id,l)).ok?m(!0):x()}catch{x()}u(!1)};v=E=>{T(E)},e[8]=l,e[9]=x,e[10]=s,e[11]=t.id,e[12]=v}else v=e[12];const w=f&&"pointer-events-none opacity-50";let b;e[13]!==w?(b=K("flex flex-col gap-3",w),e[13]=w,e[14]=b):b=e[14];let j;if(e[15]!==l||e[16]!==i||e[17]!==t.id){let T;e[19]!==l||e[20]!==t.id?(T=(E,P)=>{const _=E.options&&E.options.length>0,A=new Set(E.multiSelect?(l[E.question]??"").split(", ").filter(Boolean):[]),I=`ask-user-answer-${t.id}-${P}`;return r.jsxs(Y4,{className:"gap-2 border-b border-border pb-3 last:border-b-0 last:pb-0",children:[(E.header||E.question)&&r.jsxs(X4,{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})]}),_?r.jsx(j9,{multiple:E.multiSelect,orientation:"vertical",variant:"outline",value:E.multiSelect?Array.from(A):l[E.question]?[l[E.question]]:[],onValueChange:R=>{if(!E.multiSelect&&R.length===0)return;const $=E.multiSelect?R.join(", "):R[0];c({...l,[E.question]:$})},className:"grid w-full gap-1.5",children:E.options.map((R,$)=>{const M=E.multiSelect?A.has(R.label):l[E.question]===R.label;return r.jsx(S9,{value:R.label,"aria-label":R.label,className:"h-auto w-full justify-start whitespace-normal px-3 py-2.5 text-left",children:r.jsx(k2,{option:R,multiSelect:E.multiSelect,selected:M})},$)})}):r.jsxs(vt,{children:[r.jsx(yt,{htmlFor:I,children:"Answer"}),r.jsx(Ia,{id:I,value:l[E.question]??"",onChange:R=>{c({...l,[E.question]:R.target.value})},rows:2,placeholder:"Type your answer..."})]})]},P)},e[19]=l,e[20]=t.id,e[21]=T):T=e[21],j=i.map(T),e[15]=l,e[16]=i,e[17]=t.id,e[18]=j}else j=e[18];const S=d||f,N=f?"Sent":d?"Sending...":"Send answer";let C;e[22]!==N||e[23]!==S?(C=r.jsx(ee,{type:"submit",size:"sm",disabled:S,children:N}),e[22]=N,e[23]=S,e[24]=C):C=e[24];let k;return e[25]!==C||e[26]!==v||e[27]!==b||e[28]!==j?(k=r.jsxs("form",{onSubmit:v,className:b,children:[j,C]}),e[25]=C,e[26]=v,e[27]=b,e[28]=j,e[29]=k):k=e[29],k}function k9(n){return[n.question,""]}function C9(n){return Array.isArray(n.input.questions)?n.input.questions.filter(e=>typeof e=="object"&&e!==null&&typeof e.question=="string"):[]}function Up(n){try{return JSON.parse(`"${n}"`)}catch{return n.replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function _9(n){const e={},t=/"((?:\\.|[^"\\])*)"\s*=\s*"((?:\\.|[^"\\])*)"/g;let s;for(;(s=t.exec(n))!==null;)e[Up(s[1])]=Up(s[2]);return e}function T9(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function E9(n,e){const t=(n.options??[]).filter(s=>{const o=s.label.trim();return o?new RegExp(`(^|[^\\p{L}\\p{N}])${T9(o)}(?=$|[^\\p{L}\\p{N}])`,"iu").test(e):!1});return t.length===1?t[0].label:void 0}function A9(n,e){if(n.asyncQuestion)return{};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=_9(n.result);for(const o of e)if(s[o.question]===void 0){const i=E9(o,n.result);i!==void 0&&(s[o.question]=i)}return s}function Wp(n,e,t){return e===void 0?!1:n.multiSelect?e.split(/,\s*/).includes(t):e===t}function P9(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 b;e[6]!==s||e[7]!==t?(b=j=>Wp(t,s,j.label),e[6]=s,e[7]=t,e[8]=b):b=e[8],c=l.filter(b),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(Ie,{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((b,j)=>{const S=Wp(t,s,b.label);return r.jsx("div",{className:K("flex items-start gap-2.5 py-2",S?"text-foreground":"text-muted-foreground"),children:r.jsx(k2,{option:b,multiSelect:t.multiSelect,selected:S,showSelectedBadge:!0})},`${b.label}-${j}`)})}),e[18]=s,e[19]=l,e[20]=t,e[21]=x):x=e[21];let v;e[22]!==s||e[23]!==u?(v=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]=v):v=e[24];let w;return e[25]!==h||e[26]!==g||e[27]!==x||e[28]!==v?(w=r.jsxs("div",{className:"border-b border-border py-3 last:border-b-0",children:[h,g,x,v]}),e[25]=h,e[26]=g,e[27]=x,e[28]=v,e[29]=w):w=e[29],w}function $9(n){const e=B.c(62),{toolCall:t,expandToolPayloads:s,isAwaitingAnswer:o,sessionId:i}=n,[a,l]=y.useState(!1);let c;e[0]!==t?(c=C9(t),e[0]=t,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==t?(u=A9(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&&!t.asyncQuestion,h=!p&&!t.isError&&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,v=t.isError?Wt:p?On:Ir,w=t.isError?"Not answered":p?"Answered":h?"Waiting for answer":"No answer recorded",b=t.isError&&"border-destructive/30";let j;e[7]!==b?(j=K("my-1 overflow-hidden rounded-lg border bg-card",b),e[7]=b,e[8]=j):j=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(I1,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[9]=S):S=e[9];let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Decision requested"}),e[10]=N):N=e[10];const C=d.length===1?"question":"questions";let k;e[11]!==d.length||e[12]!==C?(k=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[N,r.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length," ",C]})]}),e[11]=d.length,e[12]=C,e[13]=k):k=e[13];const T=t.isError?"destructive":p?"secondary":"outline";let E;e[14]!==v?(E=r.jsx(v,{"data-icon":"inline-start"}),e[14]=v,e[15]=E):E=e[15];let P;e[16]!==w||e[17]!==T||e[18]!==E?(P=r.jsxs(Ie,{variant:T,children:[E,w]}),e[16]=w,e[17]=T,e[18]=E,e[19]=P):P=e[19];let _;e[20]!==P||e[21]!==k?(_=r.jsxs("div",{className:"min-w-0 flex-1",children:[k,P]}),e[20]=P,e[21]=k,e[22]=_):_=e[22];let A;e[23]!==t.timestamp?(A=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]=A):A=e[24];let I;e[25]!==_||e[26]!==A?(I=r.jsxs("header",{className:"flex items-start gap-2.5 border-b px-3 py-2.5",children:[S,_,A]}),e[25]=_,e[26]=A,e[27]=I):I=e[27];let R;e[28]!==f||e[29]!==h||e[30]!==d||e[31]!==i||e[32]!==t?(R=h&&i?r.jsx(N9,{toolCall:t,sessionId:i}):d.length>0?d.map((W,U)=>r.jsx(P9,{question:W,answer:f[W.question],index:U,completed:t.result!==null&&!t.asyncQuestion},`${W.question}-${U}`)):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]=R):R=e[33];let $;e[34]!==x||e[35]!==t.asyncQuestion||e[36]!==t.isError||e[37]!==t.result?($=t.result!==null&&!t.asyncQuestion&&!x&&r.jsxs("div",{className:K("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.asyncQuestion,e[36]=t.isError,e[37]=t.result,e[38]=$):$=e[38];let M;e[39]!==R||e[40]!==$?(M=r.jsxs("div",{className:"px-3",children:[R,$]}),e[39]=R,e[40]=$,e[41]=M):M=e[41];let L;e[42]!==s?(L=()=>{s||l(I9)},e[42]=s,e[43]=L):L=e[43];let D;e[44]!==m?(D=m?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Ve,{"data-icon":"inline-start"}),e[44]=m,e[45]=D):D=e[45];let F;e[46]!==m||e[47]!==L||e[48]!==D?(F=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:L,className:"-ml-2 text-muted-foreground","aria-expanded":m,children:[D,"Raw details"]}),e[46]=m,e[47]=L,e[48]=D,e[49]=F):F=e[49];let z;e[50]!==m||e[51]!==t.input||e[52]!==t.result?(z=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[50]=m,e[51]=t.input,e[52]=t.result,e[53]=z):z=e[53];let O;e[54]!==F||e[55]!==z?(O=r.jsxs("div",{className:"border-t px-3 py-1.5",children:[F,z]}),e[54]=F,e[55]=z,e[56]=O):O=e[56];let H;return e[57]!==I||e[58]!==M||e[59]!==O||e[60]!==j?(H=r.jsxs("section",{className:j,"aria-label":"Question history",children:[I,M,O]}),e[57]=I,e[58]=M,e[59]=O,e[60]=j,e[61]=H):H=e[61],H}function I9(n){return!n}const R9=4;function C2(n,e=!1){return e?"text-destructive":QT(n)==="mutating"?"text-foreground":"text-muted-foreground"}function M9(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(Hs,{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(tt,{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 O9(n){const e=B.c(12),{chips:t}=n;let s,o,i,a;if(e[0]!==t){const d=t.slice(0,R9);s=t.length-d.length,o="flex min-w-0 items-center gap-1 overflow-hidden",i=`Sections: ${t.map(D9).join(", ")}`,a=d.map(L9),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 L9(n,e){return r.jsxs(Ie,{variant:"outline",className:K("h-4 shrink-0 px-1.5 font-mono text-[10px]",y2[n.tone]),children:[n.name,n.count>1?` ×${n.count}`:""]},e)}function D9(n){return`${n.name}${n.count>1?` ×${n.count}`:""}`}function z9(n){const e=B.c(4),{chips:t,summary:s}=n;if(t){let i;return e[0]!==t?(i=r.jsx(O9,{chips:t}),e[0]=t,e[1]=i):i=e[1],i}if(!s)return null;let o;return e[2]!==s?(o=r.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3],o}function F9(n){const e=B.c(30),{toolCall:t,isAgentActive:s,displayName:o,summary:i,sectionChips:a,nameTitle:l,nameClass:c,timeLabel:d,timeIso:u}=n;let f;e[0]!==u||e[1]!==d?(f=d&&r.jsx("time",{className:"sr-only",dateTime:u,children:d}),e[0]=u,e[1]=d,e[2]=f):f=e[2];let m;e[3]!==c?(m=K("max-w-[50%] shrink-0 truncate font-mono text-xs",c),e[3]=c,e[4]=m):m=e[4];let p;e[5]!==o||e[6]!==l||e[7]!==m?(p=r.jsx("span",{className:m,title:l,children:o}),e[5]=o,e[6]=l,e[7]=m,e[8]=p):p=e[8];let h;e[9]!==a||e[10]!==i?(h=r.jsx(z9,{chips:a,summary:i}),e[9]=a,e[10]=i,e[11]=h):h=e[11];let g;e[12]!==p||e[13]!==h?(g=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[p,h]}),e[12]=p,e[13]=h,e[14]=g):g=e[14];let x;e[15]!==t.hookDurationMs?(x=t.hookDurationMs!==void 0&&t.hookDurationMs>0&&r.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",title:"PostToolUse hook duration",children:[t.hookDurationMs,"ms"]}),e[15]=t.hookDurationMs,e[16]=x):x=e[16];let v;e[17]!==t.outputReplacedByHook?(v=t.outputReplacedByHook&&r.jsx("span",{className:"text-[10px] text-info",title:"Output replaced by hook",children:"hook"}),e[17]=t.outputReplacedByHook,e[18]=v):v=e[18];let w;e[19]!==s||e[20]!==t?(w=r.jsx(M9,{toolCall:t,isAgentActive:s}),e[19]=s,e[20]=t,e[21]=w):w=e[21];let b;e[22]!==x||e[23]!==v||e[24]!==w?(b=r.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[x,v,w]}),e[22]=x,e[23]=v,e[24]=w,e[25]=b):b=e[25];let j;return e[26]!==f||e[27]!==g||e[28]!==b?(j=r.jsxs(r.Fragment,{children:[f,g,b]}),e[26]=f,e[27]=g,e[28]=b,e[29]=j):j=e[29],j}function B9(n){if(n.isError)return null;const e=n.name==="Read"?n.input.file_path:/(?:^|[._])view_image$/.test(n.name)?n.input.path:null;return typeof e=="string"&&fu(e)?e:null}function U9(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(ku,{oldString:s,newString:o,filePath:i}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):a=e[3],a}const _2=y.memo(function(e){var pe,xe,ke,$e;const t=B.c(167),{toolCall:s,groupedBashCalls:o,expandToolPayloads:i,isAgentActive:a,skillMetadata:l}=e,c=i===void 0?!1:i,{session:d,pendingInteraction:u}=st(),[f,m]=y.useState(!1),[p,h]=y.useState(!1),g=y.useId(),x=y.useId();let v;t[0]!==s?(v=au(s),t[0]=s,t[1]=v):v=t[1];const w=v;let b;t[2]!==w||t[3]!==s.input||t[4]!==s.name?(b=!w&&(s.name==="Bash"||/(?:^|[._])exec_command$/.test(s.name))&&!!Ro(s.input),t[2]=w,t[3]=s.input,t[4]=s.name,t[5]=b):b=t[5];const j=b;let S;t[6]!==o||t[7]!==j||t[8]!==s?(S=o??(j?[s]:[]),t[6]=o,t[7]=j,t[8]=s,t[9]=S):S=t[9];const N=S;let C;t[10]!==s?(C=Zr(s),t[10]=s,t[11]=C):C=t[11];const k=C;let T;t[12]!==N?(T=N.length>0?N.flatMap(w2):null,t[12]=N,t[13]=T):T=t[13];const E=T;let P;t[14]!==E?(P=E&&(E.length>1||E.some(W9))?X8(E):void 0,t[14]=E,t[15]=P):P=t[15];const _=P,A=N.length>1?`${k.label} ×${N.length}`:k.label,I=k.label===s.name?s.name:`${k.label} (${s.name})`;let R;t[16]!==N||t[17]!==s.isError?(R=s.isError||N.some(H9),t[16]=N,t[17]=s.isError,t[18]=R):R=t[18];let $;t[19]!==k.styleName||t[20]!==R?($=C2(k.styleName,R),t[19]=k.styleName,t[20]=R,t[21]=$):$=t[21];const M=$;let L;e:{if(N.length<=1){L=s;break e}const we=N.some(q9)?null:s.result;let be;t[22]!==N?(be=N.some(K9),t[22]=N,t[23]=be):be=t[23];let Le;t[24]!==N?(Le=N.some(V9),t[24]=N,t[25]=Le):Le=t[25];let Se;t[26]!==N?(Se=N.reduce(G9,0),t[26]=N,t[27]=Se):Se=t[27];let Re;t[28]!==we||t[29]!==be||t[30]!==Le||t[31]!==Se||t[32]!==s?(Re={...s,result:we,isError:be,outputReplacedByHook:Le,hookDurationMs:Se},t[28]=we,t[29]=be,t[30]=Le,t[31]=Se,t[32]=s,t[33]=Re):Re=t[33],L=Re}const D=L;let F;t[34]!==s.timestamp?(F=s.timestamp?new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):void 0,t[34]=s.timestamp,t[35]=F):F=t[35];const z=F;let O;t[36]!==s.timestamp?(O=s.timestamp?new Date(s.timestamp).toISOString():void 0,t[36]=s.timestamp,t[37]=O):O=t[37];const H=O,W=c||f,U=N.length>1?`${(E==null?void 0:E.length)??N.length} commands`:k.summary;let V;t[38]!==l||t[39]!==U||t[40]!==s.name?(V=s.name==="Skill"&&l?l.get(U)??null:null,t[38]=l,t[39]=U,t[40]=s.name,t[41]=V):V=t[41];const q=V,X=q==null?void 0:q.filePath,G=s.name==="Edit"&&typeof s.input.old_string=="string"&&typeof s.input.new_string=="string"&&typeof s.input.file_path=="string";let Y,J,Q,Z,te;if(t[42]!==N.length||t[43]!==_||t[44]!==A||t[45]!==c||t[46]!==G||t[47]!==a||t[48]!==M||t[49]!==I||t[50]!==g||t[51]!==u||t[52]!==(d==null?void 0:d.sessionId)||t[53]!==W||t[54]!==D||t[55]!==U||t[56]!==H||t[57]!==z||t[58]!==s){te=Symbol.for("react.early_return_sentinel");e:{const we=B9(s),be=!!((pe=s.resultImages)!=null&&pe.length),Le=we!==null&&((xe=s.result)==null?void 0:xe.trim())===""&&!be;let Se;if(t[64]!==N.length||t[65]!==G||t[66]!==Le||t[67]!==be||t[68]!==s.isError||t[69]!==s.result?(Se=s.result!==null&&!Le&&N.length===0&&(!be||!!((ke=s.result)!=null&&ke.trim()))&&(!G||s.isError),t[64]=N.length,t[65]=G,t[66]=Le,t[67]=be,t[68]=s.isError,t[69]=s.result,t[70]=Se):Se=t[70],Y=Se,s.name==="AskUserQuestion"){const le=(u==null?void 0:u.type)==="question"&&u.toolUseId===s.id,he=d==null?void 0:d.sessionId;let Ue;t[71]!==c||t[72]!==le||t[73]!==he||t[74]!==s?(Ue=r.jsx($9,{toolCall:s,expandToolPayloads:c,isAwaitingAnswer:le,sessionId:he}),t[71]=c,t[72]=le,t[73]=he,t[74]=s,t[75]=Ue):Ue=t[75],te=Ue;break e}const Re=D.isError&&"rounded-md bg-destructive/5 px-2";t[76]!==Re?(J=K("min-w-0 py-1",Re),t[76]=Re,t[77]=J):J=t[77];const Ne=`Toggle ${A} details${U?`: ${U}`:""}`;let Fe;t[78]!==c?(Fe=()=>{c||m(Y9)},t[78]=c,t[79]=Fe):Fe=t[79];const He=W&&"rotate-90";let We;t[80]!==He?(We=K("size-3 shrink-0 text-muted-foreground transition-transform",He),t[80]=He,t[81]=We):We=t[81];let Ee;t[82]!==We?(Ee=r.jsx(Ve,{className:We,"aria-hidden":"true"}),t[82]=We,t[83]=Ee):Ee=t[83];let Be;t[84]!==_||t[85]!==A||t[86]!==a||t[87]!==M||t[88]!==I||t[89]!==D||t[90]!==U||t[91]!==H||t[92]!==z?(Be=r.jsx(F9,{toolCall:D,isAgentActive:a,displayName:A,summary:U,sectionChips:_,nameTitle:I,nameClass:M,timeLabel:z,timeIso:H}),t[84]=_,t[85]=A,t[86]=a,t[87]=M,t[88]=I,t[89]=D,t[90]=U,t[91]=H,t[92]=z,t[93]=Be):Be=t[93],t[94]!==g||t[95]!==W||t[96]!==Ne||t[97]!==Fe||t[98]!==Ee||t[99]!==Be||t[100]!==z?(Q=r.jsxs("button",{type:"button",className:"flex min-h-11 w-full min-w-0 items-center gap-2 rounded-sm text-left hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring sm:min-h-7",title:z,"aria-label":Ne,"aria-expanded":W,"aria-controls":g,onClick:Fe,children:[Ee,Be]}),t[94]=g,t[95]=W,t[96]=Ne,t[97]=Fe,t[98]=Ee,t[99]=Be,t[100]=z,t[101]=Q):Q=t[101],Z=Le&&r.jsx(Fc,{src:we,alt:we.slice(we.lastIndexOf("/")+1),id:`tool-image:${s.id}`,className:"my-1.5",thumbnailClassName:"max-h-40"})}t[42]=N.length,t[43]=_,t[44]=A,t[45]=c,t[46]=G,t[47]=a,t[48]=M,t[49]=I,t[50]=g,t[51]=u,t[52]=d==null?void 0:d.sessionId,t[53]=W,t[54]=D,t[55]=U,t[56]=H,t[57]=z,t[58]=s,t[59]=Y,t[60]=J,t[61]=Q,t[62]=Z,t[63]=te}else Y=t[59],J=t[60],Q=t[61],Z=t[62],te=t[63];if(te!==Symbol.for("react.early_return_sentinel"))return te;let ne;t[102]!==s.id||t[103]!==s.resultImages?(ne=($e=s.resultImages)==null?void 0:$e.map((we,be)=>r.jsx(Fc,{src:`data:${we.source.media_type};base64,${we.source.data}`,alt:`Tool result image ${be+1}`,id:`tool-result-image:${s.id}:${be}`,className:"my-1.5",thumbnailClassName:"max-h-40"},`${we.source.media_type}-${we.source.data.length}-${we.source.data.slice(0,32)}-${we.source.data.slice(-32)}`)),t[102]=s.id,t[103]=s.resultImages,t[104]=ne):ne=t[104];let oe;t[105]!==X||t[106]!==q?(oe=q&&r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-xs text-muted-foreground",children:[r.jsxs("span",{children:["source: ",q.source]}),X&&(!Ds()||Qd())&&r.jsxs(ee,{type:"button",variant:"link",size:"xs",onClick:()=>gr(X),title:X,children:[r.jsx($1,{"data-icon":"inline-start"}),"Open SKILL.md"]})]}),t[105]=X,t[106]=q,t[107]=oe):oe=t[107];let re;t[108]!==G||t[109]!==s?(re=G&&r.jsx(U9,{toolCall:s}),t[108]=G,t[109]=s,t[110]=re):re=t[110];let ie;t[111]!==N||t[112]!==c||t[113]!==G||t[114]!==a||t[115]!==w||t[116]!==(d==null?void 0:d.cwd)||t[117]!==s.input?(ie=N.length>0?r.jsx(p9,{toolCalls:N,cwd:d==null?void 0:d.cwd,expandAll:c,isAgentActive:!!a}):w?r.jsx(_8,{input:s.input}):G?null:r.jsx(h2,{input:s.input}),t[111]=N,t[112]=c,t[113]=G,t[114]=a,t[115]=w,t[116]=d==null?void 0:d.cwd,t[117]=s.input,t[118]=ie):ie=t[118];let se;t[119]!==Y||t[120]!==s.input||t[121]!==s.isError||t[122]!==s.name||t[123]!==s.result?(se=Y&&r.jsx(ak,{result:s.result??"",isError:s.isError,filePath:s.name==="Read"&&typeof s.input.file_path=="string"?s.input.file_path:void 0}),t[119]=Y,t[120]=s.input,t[121]=s.isError,t[122]=s.name,t[123]=s.result,t[124]=se):se=t[124];let de;t[125]===Symbol.for("react.memo_cache_sentinel")?(de=()=>h(X9),t[125]=de):de=t[125];const ce=p&&"rotate-90";let ue;t[126]!==ce?(ue=K(ce),t[126]=ce,t[127]=ue):ue=t[127];let me;t[128]!==ue?(me=r.jsx(Ve,{"data-icon":"inline-start",className:ue}),t[128]=ue,t[129]=me):me=t[129];let fe;t[130]!==x||t[131]!==p||t[132]!==me?(fe=r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"mt-1","aria-expanded":p,"aria-controls":x,onClick:de,children:[me,"Input"]}),t[130]=x,t[131]=p,t[132]=me,t[133]=fe):fe=t[133];let ae;t[134]!==N||t[135]!==s.input?(ae=JSON.stringify(N.length>1?N.map(J9):s.input),t[134]=N,t[135]=s.input,t[136]=ae):ae=t[136];let ve;t[137]!==ae?(ve=r.jsx(yx,{result:ae}),t[137]=ae,t[138]=ve):ve=t[138];let ge;t[139]!==x||t[140]!==ve?(ge=r.jsx(dt,{id:x,children:ve}),t[139]=x,t[140]=ve,t[141]=ge):ge=t[141];let ye;t[142]!==p||t[143]!==fe||t[144]!==ge?(ye=r.jsxs(ct,{open:p,children:[fe,ge]}),t[142]=p,t[143]=fe,t[144]=ge,t[145]=ye):ye=t[145];let Pe;t[146]!==g||t[147]!==re||t[148]!==ie||t[149]!==se||t[150]!==ye?(Pe=r.jsxs(dt,{id:g,children:[re,ie,se,ye]}),t[146]=g,t[147]=re,t[148]=ie,t[149]=se,t[150]=ye,t[151]=Pe):Pe=t[151];let De;t[152]!==W||t[153]!==Pe?(De=r.jsx(ct,{open:W,children:Pe}),t[152]=W,t[153]=Pe,t[154]=De):De=t[154];let Te;t[155]!==s.id||t[156]!==s.name||t[157]!==s.result?(Te=(s.name==="Task"||s.name==="Agent")&&s.result===null&&r.jsx(Su,{toolUseId:s.id}),t[155]=s.id,t[156]=s.name,t[157]=s.result,t[158]=Te):Te=t[158];let Ae;return t[159]!==J||t[160]!==Q||t[161]!==Z||t[162]!==ne||t[163]!==oe||t[164]!==De||t[165]!==Te?(Ae=r.jsxs("div",{className:J,children:[Q,Z,ne,oe,De,Te]}),t[159]=J,t[160]=Q,t[161]=Z,t[162]=ne,t[163]=oe,t[164]=De,t[165]=Te,t[166]=Ae):Ae=t[166],Ae});function W9(n){return n.label}function H9(n){return n.isError}function q9(n){return n.result===null}function K9(n){return n.isError}function V9(n){return n.outputReplacedByHook}function G9(n,e){return n+(e.hookDurationMs??0)}function Y9(n){return!n}function X9(n){return!n}function J9(n){return n.input}const Q9=y.memo(function({plan:e,planFilePath:t,status:s,toolCalls:o,expandAll:i=!1,expandToolPayloads:a=!1,isAgentActive:l,skillMetadata:c}){const[d,u]=y.useState(!0),f=o.some(j=>j.name==="AskUserQuestion"&&j.result===null),[m,p]=y.useState(null),h=y.useRef(f);y.useEffect(()=>{f&&(h.current=!0)},[f]);const g=i||d,x=i||(m??(f||h.current)),v=s==="approved"?Pr:s==="rejected"?Hs:Ls,w=g?nt:Ve,b=x?nt:Ve;return r.jsxs(ct,{open:g,onOpenChange:u,className:K("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(Pt,{render:r.jsx(ee,{type:"button",variant:"ghost",className:"h-auto w-full justify-start rounded-b-none p-2 text-left"}),children:[r.jsx(w,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(G3,{className:"size-4 text-muted-foreground","data-icon":"inline-start"}),r.jsx("span",{className:"text-sm font-medium",children:"Plan Mode"}),r.jsx(v,{className:K("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(dt,{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(Ln,{remarkPlugins:Bn,components:Fn,children:e})}),o.length>0&&r.jsxs(ct,{open:x,onOpenChange:p,className:"mt-2",children:[r.jsxs(Pt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[r.jsx(b,{"data-icon":"inline-start"}),o.length," call",o.length===1?"":"s"," during planning"]}),r.jsx(dt,{children:r.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-1",children:o.map(j=>r.jsx(_2,{toolCall:j,expandToolPayloads:a,isAgentActive:l,skillMetadata:c},j.id))})})]})]})})]})}),Z9=y.memo(function(e){const t=B.c(13),{content:s}=e,[o,i]=y.useState(!0),a=o?nt:Ve;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(Y3,{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(Pt,{render:l,children:[c,d,u]}),t[5]=c,t[6]=f):f=t[6];let m;t[7]!==s?(m=r.jsx(dt,{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(Ln,{remarkPlugins:Bn,components:Fn,children:s})})}),t[7]=s,t[8]=m):m=t[8];let p;return t[9]!==o||t[10]!==f||t[11]!==m?(p=r.jsxs(ct,{open:o,onOpenChange:i,className:"my-2 rounded-lg border bg-card",children:[f,m]}),t[9]=o,t[10]=f,t[11]=m,t[12]=p):p=t[12],p}),Ul=1;function Hp(n,e){return!e||n.length<=Ul?{visible:[...n],hidden:0}:{visible:n.slice(-Ul),hidden:n.length-Ul}}function eE(n){return`${n} earlier step${n===1?"":"s"}`}const tE=y.memo(function(e){const t=B.c(15),{blocks:s,expandAll:o}=e,[i,a]=y.useState(!1),l=o||i;if(s.length===0)return null;let c;t[0]!==o?(c=p=>{o||a(p)},t[0]=o,t[1]=c):c=t[1];let d;t[2]!==s.length||t[3]!==o||t[4]!==l?(d=!o&&r.jsxs(Pt,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 text-muted-foreground"}),children:[l?r.jsx(nt,{"data-icon":"inline-start"}):r.jsx(Ve,{"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(dt,{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(ct,{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(`
|
|
111
|
+
`):[],s=e?e.split(`
|
|
112
|
+
`):[];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(`
|
|
113
|
+
`);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(`
|
|
114
|
+
`),o=t.map(a=>a.current).join(`
|
|
115
|
+
`),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 qp(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 Qs(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 S of n){const N=xE(S.name);if(N){p+=1,o.add(N);continue}if(pE.has(S.name)){const C=qp(S.input),k=bE(S.name,S.input);C&&uE(C)?(l+=1,c+=k.added,d+=k.removed):(t.add(C??S.id),i+=k.added,a+=k.removed);continue}if(S.name==="Read"){const C=qp(S.input);C?s.add(C):f+=1;continue}if(fE.has(S.name)){u+=1;continue}if(mE.has(S.name)){const C=gE(S.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(S.name)){h+=1;continue}g+=1}const v=s.size>0?s.size:f,w=[],b=(S,N,C=0,k=0)=>{w.push(C>0||k>0?{key:S,text:N,added:C,removed:k}:{key:S,text:N})},j=e.thoughtForMs??0;if(j>0&&b("thought",`thought for ${vE(j)}`),t.size>0&&b("edit",`edited ${Qs(t.size,"file")}`,i,a),l>0&&b("scratchpad",`made ${l} scratchpad ${l===1?"edit":"edits"}`,c,d),u>0&&b("search",`searched for ${Qs(u,"pattern")}`),v>0&&b("read",`read ${Qs(v,"file")}`),m>0&&b("list",`listed ${Qs(m,"directory","directories")}`),p>0){const S=[...o].join(", ")||"MCP";b("mcp",p>1?`called ${S} ${p} times`:`called ${S}`)}return h>0&&b("agent",`ran ${Qs(h,"agent")}`),g>0&&b("other",`called ${Qs(g,"tool")}`),x>0&&b("bash",`ran ${x} shell ${x===1?"command":"commands"}`),{clauses:w}}const Kp="text-muted-foreground";function Vp(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 Gp=y.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]=y.useState(null),v=y.useRef(null),w=m&&s.some(jE);let b;t[0]!==s?(b=s.some(SE),t[0]=s,t[1]=b):b=t[1];const j=b,S=o||j||(g??w),N=g===null&&w&&!o&&!j,C=y.useRef(null),k=y.useRef(null);let T,E;t[2]!==a||t[3]!==s?(T=()=>{if(!a){C.current=null;return}a!==C.current&&s.some(V=>V.id===a)&&(C.current=a,x(!0),k.current=requestAnimationFrame(()=>{k.current=requestAnimationFrame(()=>{var V;k.current=null,(V=v.current)==null||V.scrollIntoView({behavior:"smooth",block:"nearest"})})}))},E=[a,s],t[2]=a,t[3]=s,t[4]=T,t[5]=E):(T=t[4],E=t[5]),y.useEffect(T,E);let P,_;t[6]===Symbol.for("react.memo_cache_sentinel")?(P=()=>()=>{k.current!==null&&cancelAnimationFrame(k.current)},_=[],t[6]=P,t[7]=_):(P=t[6],_=t[7]),y.useEffect(P,_);let A;if(t[8]!==s){const V=new Map;for(const q of s){const{label:X,styleName:G}=Zr(q),Y=V.get(X);Y?(Y.count=Y.count+1,Y.hasError=Y.hasError||!!q.isError):V.set(X,{count:1,styleName:G,hasError:!!q.isError})}A=[...V].sort(NE),t[8]=s,t[9]=A}else A=t[9];const I=A;let R;t[10]!==h||t[11]!==s?(R=yE(s,{thoughtForMs:h}),t[10]=h,t[11]=s,t[12]=R):R=t[12];const $=R,M=function(q,X,G){const Y=G??[q],J=m&&X&&Y.some(kE),Q=a!==null&&Y.some(Z=>Z.id===a);return r.jsx("div",{ref:Q?v:void 0,className:K(Q&&"rounded-md ring-1 ring-ring"),children:r.jsx(_2,{toolCall:q,groupedBashCalls:G,expandToolPayloads:i,isAgentActive:J,skillMetadata:f})},q.id)},L=function(q,X){const G=[];let Y=0;for(;Y<q.length;){const J=q[Y];if(J.name!=="Bash"){G.push(M(J,X&&Y===q.length-1)),Y++;continue}let Q=Y+1;for(;Q<q.length&&q[Q].name==="Bash";)Q++;const Z=q.slice(Y,Q);G.push(M(J,X&&Q===q.length,Z.length>1?Z:void 0)),Y=Q}return G};if(s.length===1&&p===0&&!c)return r.jsx("div",{className:"flex flex-col gap-2",children:L(s,!0)});if(S){let V;t[13]!==o||t[14]!==j||t[15]!==$||t[16]!==p?(V=!o&&!j&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>x(!1),className:"-ml-2 text-muted-foreground",children:[r.jsx(nt,{"data-icon":"inline-start"}),$.clauses.length>0?r.jsx(Vp,{summary:$}):r.jsxs("span",{className:K("font-mono text-xs",Kp),children:["Thinking",p>1?` ×${p}`:""]})]}),t[13]=o,t[14]=j,t[15]=$,t[16]=p,t[17]=V):V=t[17];const q=c?(()=>{const G=Hp(c,N);return r.jsxs(r.Fragment,{children:[G.hidden>0&&r.jsx(Yp,{count:G.hidden,onReveal:()=>x(!0)}),(()=>{const Y=[];let J=0;for(;J<G.visible.length;){const Q=G.visible[J];if(Q.kind==="thinking"){Y.push(r.jsx(tE,{blocks:Q.blocks,expandAll:!1},`thinking-${J}`)),J++;continue}const Z=[...Q.toolCalls];let te=J+1;for(;te<G.visible.length&&G.visible[te].kind==="tool_calls";){const ne=G.visible[te];ne.kind==="tool_calls"&&Z.push(...ne.toolCalls),te++}Y.push(...L(Z,te===G.visible.length)),J=te}return Y})()]})})():(()=>{const G=Hp(s,N);return r.jsxs(r.Fragment,{children:[G.hidden>0&&r.jsx(Yp,{count:G.hidden,onReveal:()=>x(!0)}),L(G.visible,!0)]})})();let X;return t[18]!==V||t[19]!==q?(X=r.jsxs("div",{className:"motion-enter flex flex-col gap-2",children:[V,q]}),t[18]=V,t[19]=q,t[20]=X):X=t[20],X}let D;t[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>x(!0),t[21]=D):D=t[21];let F;t[22]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(Ve,{className:"mt-0.5 size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),t[22]=F):F=t[22];let z;t[23]!==$?(z=$.clauses.length>0&&r.jsx(Vp,{summary:$}),t[23]=$,t[24]=z):z=t[24];let O;t[25]!==p?(O=p>0&&r.jsxs("span",{className:K("font-mono text-xs",Kp),children:["Thinking",p>1?` ×${p}`:""]}),t[25]=p,t[26]=O):O=t[26];let H;t[27]!==I?(H=I.map(CE),t[27]=I,t[28]=H):H=t[28];let W;t[29]!==O||t[30]!==H?(W=r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[O,H]}),t[29]=O,t[30]=H,t[31]=W):W=t[31];let U;return t[32]!==z||t[33]!==W?(U=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:[F,r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[z,W]})]}),t[32]=z,t[33]=W,t[34]=U):U=t[34],U});function Yp(n){const e=B.c(6),{count:t,onReveal:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(nt,{"data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=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:K("font-mono text-xs",C2(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=K("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=K("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(Ve,{"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 T2="synthesizedFrom",Xp=/[.*+?[\]{}()^$|]/,TE=/[$*?`~]|\\\s/,E2=/<<(-?)\s*(?:'([^']+)'|"([^"]+)")/,EE=new RegExp(E2,"g");function _u(n,e,t,s){return{id:e,name:t,input:{...s,[T2]:n.name},result:null,isError:!1,timestamp:n.timestamp}}function AE(n){return typeof n.input[T2]=="string"}function PE(n){const e=n[0];return(e==='"'||e==="'")&&n.at(-1)===e?n.slice(1,-1):n}function Jp(n){const e=[];for(const t of n.split("/"))!t||t==="."||(t===".."?e.pop():e.push(t));return`/${e.join("/")}`}function Va(n,e){const t=PE(n.trim());return!t||TE.test(t)?null:t.startsWith("/")?Jp(t):e?Jp(`${e}/${t}`):null}function $E(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 IE(n){const e=n.split(`
|
|
116
|
+
`),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(`
|
|
117
|
+
`)))}for(const a of $E(o))t.push({text:a.text,bodies:i,piped:a.piped})}return t}function RE(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?Va(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(E2);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=Va(o,e);return i?{name:"Write",input:{file_path:i,content:s}}:null}function Qp(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==="|"||!Xp.test(a)&&!"\\/&#".includes(a))return null;s+=a,o++;continue}if(i==="&"&&t||!t&&Xp.test(i))return null;s+=i}return s}const LE=/^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 DE(n,e){var m;const t=(m=n.text.match(LE))==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=Qp(s,"pattern"),u=Qp(o,"replacement");if(!d||u===null)return null;const f=Va(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 A2(n,e=null){const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let o=e;for(const i of IE(t)){const a=RE(i.text,o);if(a){o=a;continue}const l=OE(i,o)??DE(i,o);l&&s.push(_u(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function P2(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=Va(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(_u(n,`${n.id}:edit-${a}`,"Edit",{file_path:o,old_string:c,new_string:d,replace_all:u===!0}))}return i}function $2(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?s0("apply_patch",t,n.id,n.timestamp,e??"").map(s=>_u(n,s.id,s.name,s.input)):[]}function rr(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(...P2(s,e)):s.name==="Bash"?t.push(...A2(s,e)):s.name==="apply_patch"&&t.push(...$2(s,e)));return t}function ca(n,e=null){for(const t of n)if(!t.isError&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&P2(t,e).length>0||t.name==="Bash"&&A2(t,e).length>0||t.name==="apply_patch"&&$2(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:im,jsonc:im,md:zi,mdx:zi,txt:zi,png:Es,jpg:Es,jpeg:Es,gif:Es,webp:Es,svg:Es,ico:Es,sh:xi,bash:xi,zsh:xi,fish:xi};function I2(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function BE(n){const e=I2(n);return FE[e]??(zE.has(e)?Rr:S1)}function So(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=K("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 Zp=5;function Tu(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*Zp);i=Zp-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 da="cogpit:open-subagent";function R2(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 Eu(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(da,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const M2=y.memo(function(e){const t=B.c(92),{file:s,defaultOpen:o,isHighlighted:i,diffMode:a}=e,{ref:l,isNear:c}=X0(),[d,u]=y.useState(o),[f,m]=y.useState(o),p=y.useRef(o);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=Pe=>{u(Pe),Pe?y.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,v;t[1]!==o?(x=()=>{p.current!==o&&(p.current=o,g(o))},v=[o,g],t[1]=o,t[2]=x,t[3]=v):(x=t[2],v=t[3]),y.useEffect(x,v);let w,b;t[4]!==i?(w=()=>{i&&g(!0)},b=[i,g],t[4]=i,t[5]=w,t[6]=b):(w=t[5],b=t[6]),y.useEffect(w,b);let j;t[7]!==s.filePath?(j=I2(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const S=j,N=s.netOriginal,C=s.netCurrent,k=!!(N||C);let T;t[9]!==s.edits?(T=s.edits.some(VE),t[9]=s.edits,t[10]=T):T=t[10];const P=a==="per-edit"?T:k,_=f&&c&&P,[A,I]=y.useState(0);let R;t[11]===Symbol.for("react.memo_cache_sentinel")?(R=Pe=>{if(!Pe)return;const De=Pe.offsetHeight;I(Te=>Te===De?Te:De)},t[11]=R):R=t[11];const $=R,M=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,L=s.filePath,D=i?"border-ring ring-2 ring-ring/20":"border-border";let F;t[12]!==D?(F=K("rounded-lg border bg-card transition-colors",D),t[12]=D,t[13]=F):F=t[13];let z;t[14]!==d?(z=()=>g(!d),t[14]=d,t[15]=z):z=t[15];let O;t[16]!==d?(O=d?r.jsx(nt,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):r.jsx(Ve,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=d,t[17]=O):O=t[17];let H;t[18]!==S?(H=r.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:S}),t[18]=S,t[19]=H):H=t[19];let W;t[20]!==s.opTypes?(W=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=W):W=t[21];let U;t[22]!==s.opTypes?(U=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=U):U=t[23];let V;t[24]!==W||t[25]!==U?(V=r.jsx(R2,{hasEdit:W,hasWrite:U}),t[24]=W,t[25]=U,t[26]=V):V=t[26];let q;t[27]!==s.shortPath?(q=r.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=q):q=t[28];let X;t[29]!==M?(X=r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:M}),t[29]=M,t[30]=X):X=t[30];let G;t[31]!==s.editCount?(G=s.editCount>1&&r.jsxs(Ie,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=G):G=t[32];let Y;t[33]!==d||t[34]!==z||t[35]!==O||t[36]!==H||t[37]!==V||t[38]!==q||t[39]!==X||t[40]!==G?(Y=r.jsxs(ee,{type:"button",variant:"ghost",onClick:z,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":d,children:[O,H,V,q,X,G]}),t[33]=d,t[34]=z,t[35]=O,t[36]=H,t[37]=V,t[38]=q,t[39]=X,t[40]=G,t[41]=Y):Y=t[41];let J;t[42]!==s.subAgentId?(J=s.subAgentId&&r.jsx(Eu,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=J):J=t[43];let Q;t[44]!==s.filePath?(Q=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>gr(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=Q):Q=t[45];let Z;t[46]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(bd,{"data-icon":"inline-start"}),t[46]=Z):Z=t[46];let te;t[47]!==Q?(te=r.jsx(_t,{render:Q,children:Z}),t[47]=Q,t[48]=te):te=t[48];let ne;t[49]===Symbol.for("react.memo_cache_sentinel")?(ne=r.jsx(Tt,{children:"Open in editor"}),t[49]=ne):ne=t[49];let oe;t[50]!==te?(oe=r.jsxs(Ct,{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:()=>gr(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=re):re=t[53];let ie;t[54]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx(X3,{"data-icon":"inline-start"}),t[54]=ie):ie=t[54];let se;t[55]!==re?(se=r.jsx(_t,{render:re,children:ie}),t[55]=re,t[56]=se):se=t[56];let de;t[57]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(Tt,{children:"View git diff"}),t[57]=de):de=t[57];let ce;t[58]!==se?(ce=r.jsxs(Ct,{children:[se,de]}),t[58]=se,t[59]=ce):ce=t[59];let ue;t[60]!==oe||t[61]!==ce?(ue=r.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[oe,ce]}),t[60]=oe,t[61]=ce,t[62]=ue):ue=t[62];let me,fe;t[63]!==s.addCount||t[64]!==s.delCount?(me=r.jsx(So,{add:s.addCount,del:s.delCount}),fe=r.jsx(Tu,{add:s.addCount,del:s.delCount}),t[63]=s.addCount,t[64]=s.delCount,t[65]=me,t[66]=fe):(me=t[65],fe=t[66]);let ae;t[67]!==J||t[68]!==ue||t[69]!==me||t[70]!==fe?(ae=r.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[J,ue,me,fe]}),t[67]=J,t[68]=ue,t[69]=me,t[70]=fe,t[71]=ae):ae=t[71];let ve;t[72]!==Y||t[73]!==ae?(ve=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:[Y,ae]}),t[72]=Y,t[73]=ae,t[74]=ve):ve=t[74];let ge;t[75]!==a||t[76]!==s.edits||t[77]!==s.filePath||t[78]!==s.netStartLine||t[79]!==P||t[80]!==A||t[81]!==C||t[82]!==N||t[83]!==d||t[84]!==_?(ge=r.jsx(HE,{showDiff:_,open:d,hasDiff:P,diffRef:$,lastDiffHeight:A,oldString:N,newString:C,filePath:s.filePath,diffMode:a,edits:s.edits,netStartLine:s.netStartLine}),t[75]=a,t[76]=s.edits,t[77]=s.filePath,t[78]=s.netStartLine,t[79]=P,t[80]=A,t[81]=C,t[82]=N,t[83]=d,t[84]=_,t[85]=ge):ge=t[85];let ye;return t[86]!==s.filePath||t[87]!==l||t[88]!==F||t[89]!==ve||t[90]!==ge?(ye=r.jsxs("div",{ref:l,"data-file-path":L,className:F,children:[ve,ge]}),t[86]=s.filePath,t[87]=l,t[88]=F,t[89]=ve,t[90]=ge,t[91]=ye):ye=t[91],ye}),HE=y.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(KE,{edits:m,filePath:u}):r.jsx(ku,{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}),eh=3,qE=5,KE=y.memo(function(e){const t=B.c(9),{edits:s,filePath:o}=e,i=s.length,a=s.filter(GE),l=a.length>eh,[c,d]=y.useState(l?eh:a.length);y.useEffect(()=>{if(c>=a.length)return;const x=requestAnimationFrame(()=>{d(v=>Math.min(v+qE,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,v)=>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," ",v+1,"/",i]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&r.jsx(Eu,{agentId:x.agentId})]}),r.jsx(ku,{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 Wl=new Map;function YE(n){var w;const e=jn("hostFiles"),{sessionSource:t}=st(),s=t==null?void 0:t.dirName,o=At(s)==="codex",i=n.turns.length,a=((w=n.turns.at(-1))==null?void 0:w.toolCalls.length)??0,l=y.useMemo(()=>{let b=0;for(const j of n.turns){b+=j.toolCalls.length;for(const S of j.subAgentActivity)b+=S.toolCalls.length}return b},[i,a]),c=y.useMemo(()=>{const b=[];for(let j=0;j<n.turns.length;j++)for(const S of n.turns[j].subAgentActivity){const N=o&&(S.status==="completed"||S.status==="failed"||S.status==="interrupted");(S.isBackground||N)&&S.toolCalls.length===0&&b.push({agentId:S.agentId,turnIndex:j})}return b},[n.turns,l,o]),[d,u]=y.useState(new Map),f=y.useRef(new Set);y.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const b=[];for(const{agentId:N}of c){const C=Ht(`${s}/${n.sessionId}/${N}`);if(!f.current.has(C)){if(Wl.has(C)){u(k=>{const T=new Map(k);return T.set(N,Wl.get(C)),T}),f.current.add(C);continue}b.push({agentId:N,cacheKey:C})}}if(b.length===0)return;let j=!1;async function S(){const N=new Map;await Promise.all(b.map(async({agentId:C,cacheKey:k})=>{try{const T=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(C)}.jsonl`,E=await _e(T);if(!E.ok)return;const P=await E.text(),A=d2(P,C).flatMap(I=>rr(I.toolCalls,n.cwd));Wl.set(k,A),f.current.add(k),N.set(C,A)}catch{}})),!j&&N.size>0&&u(C=>{const k=new Map(C);for(const[T,E]of N)k.set(T,E);return k})}return S(),()=>{j=!0}},[s,n.sessionId,n.cwd,c]);const m=y.useMemo(()=>{const b=[],j=new Set;for(let S=0;S<n.turns.length;S++){const N=n.turns[S];for(const C of rr(N.toolCalls,n.cwd))b.push({turnIndex:S,toolCall:C});for(const C of N.subAgentActivity){for(const k of rr(C.toolCalls,n.cwd))b.push({turnIndex:S,toolCall:k,agentId:C.agentId});if((C.isBackground||o)&&C.toolCalls.length===0&&!j.has(C.agentId)){j.add(C.agentId);const k=d.get(C.agentId);if(k)for(const T of k)b.push({turnIndex:S,toolCall:T,agentId:C.agentId})}}}return b},[l,n.turns,d,o]),p=y.useMemo(()=>{const b=new Set;for(const j of m){const S=O2(j.toolCall);S&&b.add(S)}return[...b]},[m]),[h,g]=y.useState(new Map);y.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let b=!1;return Promise.all(p.map(j=>_e(`/api/file-content?path=${encodeURIComponent(j)}`).then(S=>S.ok?S.text():null).then(S=>S?[j,S]:null).catch(()=>null))).then(j=>{if(b)return;const S=new Map;for(const N of j)N&&S.set(N[0],N[1]);g(S)}),()=>{b=!0}},[e,p]);const x=n.turns.length-1,v=y.useMemo(()=>{const b=new Map;for(const j of n.turns)for(const S of j.subAgentActivity)b.has(S.agentId)||b.set(S.agentId,{name:S.agentName,type:S.subagentType});return b},[n.turns]);return{fileChanges:m,fileContents:h,lastTurnIndex:x,agentMap:v}}function th(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]===`
|
|
118
|
+
`&&s++;return s}function O2(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 L2(n,e,t){const s=new Map;for(const i of n){if(e!=="all"&&i.turnIndex!==e)continue;const a=O2(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 v=0;v<a.length;v++){const w=a[v],b=XE(w.toolCall);l.push(b),w.turnIndex<d&&(d=w.turnIndex),w.turnIndex>u&&(u=w.turnIndex),w.toolCall.name==="Edit"?f=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:b.oldString,newString:b.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:th(h,b.newString||b.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?th(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=L2(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 eA(n){const e=B.c(34),{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(da,{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(Ie,{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||e[15]!==t.totalDel?(g=r.jsx(So,{add:t.totalAdd,del:t.totalDel}),e[14]=t.totalAdd,e[15]=t.totalDel,e[16]=g):g=e[16];let x;e[17]!==f||e[18]!==m||e[19]!==p||e[20]!==g?(x=r.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[f,m,p,h,g]}),e[17]=f,e[18]=m,e[19]=p,e[20]=g,e[21]=x):x=e[21];let v;if(e[22]!==s||e[23]!==i||e[24]!==t.files||e[25]!==o){let b;e[27]!==s||e[28]!==i||e[29]!==o?(b=j=>r.jsx(M2,{file:j,defaultOpen:s,isHighlighted:o===j.filePath,diffMode:i},j.filePath),e[27]=s,e[28]=i,e[29]=o,e[30]=b):b=e[30],v=t.files.map(b),e[22]=s,e[23]=i,e[24]=t.files,e[25]=o,e[26]=v}else v=e[26];let w;return e[31]!==v||e[32]!==x?(w=r.jsxs("div",{className:"flex flex-col gap-1",children:[x,v]}),e[31]=v,e[32]=x,e[33]=w):w=e[33],w}const tA=y.memo(function({session:e,sessionChangeKey:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(!0),a=y.useRef(!1),l=y.useRef(0),c=y.useRef(e.turns.length),[d,u]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=Io(QE,{}),g={...ZE,...p},x=g.expanded,v=g.diffMode,w=g.groupByAgent,[b,j]=y.useState(g.scope),S=y.useCallback(U=>{h(V=>({...V,expanded:U}))},[h]),N=y.useCallback(U=>{h(V=>({...V,diffMode:U}))},[h]),C=y.useCallback(U=>{h(V=>({...V,groupByAgent:U}))},[h]);y.useEffect(()=>{typeof b!="number"&&h(U=>({...U,scope:b}))},[b,h]);const[k,T]=y.useState(null),E=y.useRef(null),{fileChanges:P,fileContents:_,lastTurnIndex:A,agentMap:I}=YE(e),R=y.useMemo(()=>L2(P,typeof b=="number"?b:b==="all"?"all":A,_),[P,b,A,_]),$=y.useMemo(()=>w?JE(P,typeof b=="number"?b:b==="all"?"all":A,I,_):[],[w,P,b,A,I,_]);y.useEffect(()=>{const U=V=>{const q=V.detail;q!=null&&q.filePath&&(j(q.turnIndex),T(q.filePath),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>T(null),3e3),requestAnimationFrame(()=>{var G;const X=(G=s.current)==null?void 0:G.querySelector(`[data-file-path="${CSS.escape(q.filePath)}"]`);X==null||X.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(kr,U),()=>{window.removeEventListener(kr,U),E.current&&clearTimeout(E.current)}},[]);const M=y.useCallback(()=>{const U=s.current;U&&(u(U.scrollTop>10),m(U.scrollHeight-U.scrollTop-U.clientHeight>10))},[]),L=y.useCallback(()=>{const U=s.current;U&&(i.current=U.scrollHeight-U.scrollTop-U.clientHeight<50,M())},[M]);if(y.useEffect(()=>{M()},[P.length,R.length,M]),y.useEffect(()=>{const U=s.current;U&&(U.scrollTop=U.scrollHeight),i.current=!0,a.current=!1,l.current=P.length,c.current=e.turns.length,j(g.scope),T(null),M()},[t]),y.useEffect(()=>{const U=e.turns.length;U>c.current&&(a.current=!0),c.current=U},[e.turns.length]),y.useEffect(()=>{if(P.length<=l.current){l.current=P.length;return}l.current=P.length,(a.current||i.current)&&(requestAnimationFrame(()=>{var U;(U=o.current)==null||U.scrollIntoView({behavior:"smooth"})}),a.current=!1)},[P.length]),P.length===0)return null;let D=0,F=0,z=0;if(w)for(const U of $)D+=U.totalAdd,F+=U.totalDel,z+=U.files.length;else{for(const U of R)D+=U.addCount,F+=U.delCount;z=R.length}function O(){j(b==="last"?"all":"last")}function H(){return typeof b=="number"?`Turn ${b+1}`:b==="all"?"All turns":`Last turn (T${A+1})`}const W=H();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(Rr,{"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(Ie,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[z," file",z!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsx(So,{add:D,del:F}),r.jsxs(Ct,{children:[r.jsx(_t,{render:r.jsx(ee,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>C(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:r.jsx(Zn,{"data-icon":"inline-start"})}),r.jsx(Tt,{children:w?"Show all changes":"Group by subagent"})]}),r.jsxs(Ct,{children:[r.jsx(_t,{render:r.jsx(ee,{variant:b==="all"?"secondary":"ghost",size:"icon-xs",onClick:O,"aria-label":b==="last"?"Show all turns":"Show last turn only"}),children:b==="all"?r.jsx(J3,{"data-icon":"inline-start"}):r.jsx(Ls,{"data-icon":"inline-start"})}),r.jsx(Tt,{children:b==="last"?"Click for all turns":"Click for last turn only"})]}),r.jsxs(Ct,{children:[r.jsx(_t,{render:r.jsx(ee,{variant:v==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>N(v==="net"?"per-edit":"net"),"aria-label":v==="net"?"Show per-edit diffs":"Show net diff"}),children:v==="net"?r.jsx(Q3,{"data-icon":"inline-start"}):r.jsx(Z3,{"data-icon":"inline-start"})}),r.jsx(Tt,{children:v==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),r.jsxs(Ct,{children:[r.jsx(_t,{render:r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>S(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?r.jsx(wa,{"data-icon":"inline-start"}):r.jsx(ya,{"data-icon":"inline-start"})}),r.jsx(Tt,{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:"}),b!=="all"&&A>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{const U=typeof b=="number"?b:A;U>0&&j(U-1)},disabled:(typeof b=="number"?b:A)<=0,"aria-label":"Previous turn",children:r.jsx(hd,{"data-icon":"inline-start"})}),r.jsx("span",{className:K("text-xs font-medium",typeof b=="number"?"text-foreground":"text-muted-foreground"),children:W}),b!=="all"&&A>0&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>{j(U=>typeof U!="number"?U:U+1>=A?"last":U+1)},disabled:b==="last","aria-label":"Next turn",children:r.jsx(Ve,{"data-icon":"inline-start"})}),typeof b=="number"&&r.jsx(ee,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:r.jsx(Qe,{"data-icon":"inline-start"})})]}),r.jsxs("div",{className:"relative flex-1 min-h-0",children:[r.jsx("div",{className:K("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:L,className:"h-full overflow-y-auto",children:[r.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?$.length>0?$.map(U=>r.jsx(eA,{group:U,allExpanded:x,highlightPath:k,diffMode:v},U.agentId)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",W.toLowerCase()]}):R.length>0?R.map(U=>r.jsx(M2,{file:U,defaultOpen:x,isHighlighted:k===U.filePath,diffMode:v},U.filePath)):r.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",W.toLowerCase()]})}),r.jsx("div",{ref:o})]}),r.jsx("div",{className:K("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 nA(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 rr(n.toolCalls,e).forEach(o=>s(o)),n.subAgentActivity.forEach(o=>rr(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 nh(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function sA(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=nh();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=nh(),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[j,S]=[...f.children.entries()][0];if(S.isFile&&S.children.size===0)break;m+="/"+j,p+="/"+j,f=S}const h=o(f,p);let g=0,x=0,v=f.isFile?f.hasEdit:!1,w=f.isFile?f.hasWrite:!1,b=f.isFile?f.subAgentId:null;for(const j of h)g+=j.additions,x+=j.deletions,j.hasEdit&&(v=!0),j.hasWrite&&(w=!0),j.subAgentId&&(b=j.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:v,hasWrite:w,subAgentId:b,children:h}})}return o(s,"")}const oA=y.memo(function(e){const t=B.c(45),{turn:s,turnIndex:o,cwd:i}=e,a=jn("hostFiles");let l;t[0]!==i||t[1]!==s?(l=nA(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=sA(c,i),t[3]=i,t[4]=c,t[5]=d):d=t[5];const u=d,[f,m]=y.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const I of c)p=p+I.additions,h=h+I.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const x=g;if(c.length===0)return null;const v=f&&"rotate-90";let w;t[14]!==v?(w=K("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",v),t[14]=v,t[15]=w):w=t[15];let b;t[16]!==w?(b=r.jsx(Ve,{"data-icon":"inline-start",className:w}),t[16]=w,t[17]=b):b=t[17];let j;t[18]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Rr,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=j):j=t[18];const S=c.length!==1?"s":"";let N;t[19]!==c.length||t[20]!==S?(N=r.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",S]}),t[19]=c.length,t[20]=S,t[21]=N):N=t[21];let C,k;t[22]!==x.add||t[23]!==x.del?(C=r.jsx(So,{add:x.add,del:x.del,className:"opacity-80"}),k=r.jsx(Tu,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=C,t[25]=k):(C=t[24],k=t[25]);let T;t[26]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/files:bg-border/70"}),t[26]=T):T=t[26];let E;t[27]!==C||t[28]!==k||t[29]!==b||t[30]!==N?(E=r.jsxs(Pt,{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:[b,j,N,C,k,T]}),t[27]=C,t[28]=k,t[29]=b,t[30]=N,t[31]=E):E=t[31];let P;if(t[32]!==a||t[33]!==u||t[34]!==o){let I;t[36]!==a||t[37]!==o?(I=R=>r.jsx(rA,{node:R,depth:0,turnIndex:o,canFocusFiles:a},R.fullPath),t[36]=a,t[37]=o,t[38]=I):I=t[38],P=u.map(I),t[32]=a,t[33]=u,t[34]=o,t[35]=P}else P=t[35];let _;t[39]!==P?(_=r.jsx(dt,{className:"ml-1 border-l border-border/40 pl-3",children:r.jsx("div",{className:"py-0.5",children:P})}),t[39]=P,t[40]=_):_=t[40];let A;return t[41]!==f||t[42]!==E||t[43]!==_?(A=r.jsxs(ct,{open:f,onOpenChange:m,children:[E,_]}),t[41]=f,t[42]=E,t[43]=_,t[44]=A):A=t[44],A}),rA=y.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:o}){const[i,a]=y.useState(!0),l=t*16+8;if(e.isFile){const c=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:K("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(R2,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),r.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&r.jsx(Eu,{agentId:e.subAgentId}),r.jsx(So,{add:e.additions,del:e.deletions}),r.jsx(Tu,{add:e.additions,del:e.deletions})]})}return r.jsxs(r.Fragment,{children:[r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-full justify-start gap-1 rounded-sm font-mono text-xs font-normal",style:{paddingLeft:l},onClick:()=>a(!i),"aria-expanded":i,children:[i?r.jsx(nt,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):r.jsx(Ve,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),r.jsx(ew,{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(So,{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 iA(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(vd,{"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(_t,{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(Tt,{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(Ct,{children:[l,d]}),e[11]=l,e[12]=d,e[13]=u):u=e[13],u}function Ga(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(nw,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Ya(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("select-none",t),e[3]=t,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=r.jsx(tw,{"data-slot":"context-menu-trigger",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Xa(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=K("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(N1,{"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(_1,{children:r.jsx(T1,{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 Ms(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(k1,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function TB(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=K("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(E1,{"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 Ft(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=K("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 No(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("-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(ad,{"data-slot":"context-menu-separator",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function aA(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(Ya,{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(gd,{"data-icon":"inline-start"}),e[5]=u):u=e[5];let f;e[6]!==d?(f=r.jsx(Ms,{children:r.jsxs(Ft,{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(No,{}),r.jsx(Ms,{children:r.jsxs(Ft,{onClick:()=>a(s),children:[r.jsx(vd,{"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(No,{}),r.jsx(Ms,{children:r.jsxs(Ft,{onClick:()=>l(s),children:[r.jsx(fn,{"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(Xa,{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(Ga,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function D2(n){return S0(n).status(n)}const lA=new Set(["Agent","TaskOutput","spawn_agent","wait_agent"]);function Au(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 ei(n,e,t,s){switch(n){case"thinking":return"Thinking...";case"tool_use":return e&&lA.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?Au(t):"Done";default:return null}}function cA(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(ow,{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(Ws,{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(sw,{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(wa,{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(ur,{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(On,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const sh=2e3,z2=600;function F2(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=K("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:`${z2}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=r.jsx(cA,{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 v;e[7]!==h||e[8]!==g||e[9]!==x?(v=K("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=v):v=e[10];let w;e[11]!==s||e[12]!==v?(w=r.jsx("span",{className:v,children:s}),e[11]=s,e[12]=v,e[13]=w):w=e[13];let b;e[14]!==l||e[15]!==i?(b=!l&&i&&r.jsx(Pu,{startTimestamp:i}),e[14]=l,e[15]=i,e[16]=b):b=e[16];let j;e[17]!==d?(j=d.length>0&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",title:d.join(`
|
|
119
|
+
`),children:d.join(" · ")}),e[17]=d,e[18]=j):j=e[18];let S;e[19]!==t.pendingQueue?(S=(t.pendingQueue??0)>0&&r.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[19]=t.pendingQueue,e[20]=S):S=e[20];let N;return e[21]!==w||e[22]!==b||e[23]!==j||e[24]!==S||e[25]!==f||e[26]!==p?(N=r.jsxs("div",{className:f,style:m,children:[p,w,b,j,S]}),e[21]=w,e[22]=b,e[23]=j,e[24]=S,e[25]=f,e[26]=p,e[27]=N):N=e[27],N}function dA(n){const e=B.c(28),{status:t,durationLabel:s}=n,[o,i]=y.useState("visible");let a,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=setTimeout(()=>i("fading"),sh),g=setTimeout(()=>i("ready"),sh+z2);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=a,e[1]=l):(a=e[0],l=e[1]),y.useEffect(a,l),o==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(On,{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=K("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let v;e[5]!==t.terminalReason?(v=t.terminalReason?Au(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=v):v=e[6];let w;e[7]!==x||e[8]!==v?(w=r.jsx("span",{className:x,children:v}),e[7]=x,e[8]=v,e[9]=w):w=e[9];let b;e[10]!==s?(b=s&&r.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=b):b=e[11];let j;return e[12]!==w||e[13]!==b?(j=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,b]}),e[12]=w,e[13]=b,e[14]=j):j=e[14],j}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=ei(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(F2,{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 uA=y.memo(function(){const e=B.c(25),{session:t,isLive:s,sseState:o,isCompacting:i,pendingInteraction:a}=st(),[l,c]=y.useState(!1),[d,u]=y.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=y.useState(f);f!==m&&(p(f),c(!1),u(!1));let h;e:{if(!t||o!=="connected"){h=null;break e}if(i){let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I={status:"compacting"},e[0]=I):I=e[0],h=I;break e}const _=t.rawMessages;let A;e[1]!==_?(A=D2(_),e[1]=_,e[2]=A):A=e[2],h=A}const g=h;let x,v;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)}},v=[g,s,d],e[3]=g,e[4]=s,e[5]=d,e[6]=x,e[7]=v):(x=e[6],v=e[7]),y.useEffect(x,v);let w;e:{if(!g){w=null;break e}if(g.status==="compacting"){w=g;break e}if(g.status==="completed"){if(l){w=null;break e}if(!s&&!d){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const b=w,j=(b==null?void 0:b.status)==="completed",S=(t==null?void 0:t.turns[t.turns.length-1])??null;let N;e:{if(!j||!S){N=null;break e}let _;if(e[8]!==S){const A=Rd(S);_=A!==null?Rn(A):null,e[8]=S,e[9]=_}else _=e[9];N=_}const C=N;if(a&&o==="connected"){let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(I1,{className:"size-5 shrink-0 text-info"}),e[10]=_):_=e[10];const A=a.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let I;return e[11]!==A?(I=r.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[_,r.jsx("span",{className:"text-xs font-medium text-info",children:A})]}),e[11]=A,e[12]=I):I=e[12],I}if(!b)return null;if(j){let _;return e[13]!==b||e[14]!==C?(_=r.jsx(dA,{status:b,durationLabel:C}),e[13]=b,e[14]=C,e[15]=_):_=e[15],_}let k;e[16]!==b.pendingAgents||e[17]!==b.status||e[18]!==b.terminalReason||e[19]!==b.toolName?(k=ei(b.status,b.toolName,b.terminalReason,b.pendingAgents),e[16]=b.pendingAgents,e[17]=b.status,e[18]=b.terminalReason,e[19]=b.toolName,e[20]=k):k=e[20];const T=k;if(!T)return null;const E=S==null?void 0:S.timestamp;let P;return e[21]!==b||e[22]!==T||e[23]!==E?(P=r.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:r.jsx(F2,{status:b,label:T,startTimestamp:E})}),e[21]=b,e[22]=T,e[23]=E,e[24]=P):P=e[24],P});function Pu(n){const e=B.c(3),{startTimestamp:t,className:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(fA,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function fA(n){const e=B.c(12),{startTimestamp:t,className:s}=n;let o;e[0]!==t?(o=new Date(t).getTime(),e[0]=t,e[1]=o):o=e[1];const i=o,a=y.useRef(null);let l,c;e[2]!==i?(l=()=>{const h=setInterval(()=>{const g=a.current;g&&(g.textContent=Rn(Math.max(0,Date.now()-i)))},1e3);return()=>clearInterval(h)},c=[i],e[2]=i,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c);let d;e[5]!==s?(d=K("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=Rn(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 mA(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 pA=6e5;function hA(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,pA)}function oh(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+=hA(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 B2=y.createContext(null);function Hi(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(B2.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Ut(){const n=y.useContext(B2);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const Hc=new Map,gA=300*1e3;function rh(n){const e=Hc.get(n);return e?Date.now()>e.expiresAt?(Hc.delete(n),null):e.data:null}function xA(n,e){Hc.set(n,{data:e,expiresAt:Date.now()+gA})}function bA(n){const e=B.c(5);let t;e[0]!==n?(t=()=>n?rh(Ht(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,o]=y.useState(t),i=y.useRef("");let a,l;return e[2]!==n?(a=()=>{if(!n||$a(window.location.pathname))return;const c=Ht(n),d=rh(c);if(d){o(d);return}i.current=n;const u=new AbortController;return _e(`/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});xA(c,p),o(p)}).catch(vA),()=>u.abort()},l=[n],e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),y.useEffect(a,l),s}function vA(){}const yA=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification"]),wA=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),jA=new Set(["AskUserQuestion","ExitPlanMode"]),SA=new Set(["text","thinking","tool_calls"]);function NA(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>jA.has(e.name)&&e.result==null)}function kA(n,e){for(let t=n.length-1;t>=0;t--){if(NA(n[t]))return t;if(SA.has(n[t].kind))break}return e?n.findIndex(t=>t.kind==="tool_calls"&&t.toolCalls.some(s=>s.id===e&&s.asyncQuestion)):-1}const Ai={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function CA(n,e="settled",t){if(n.length===0||!n.some(l=>wA.has(l.kind)))return Ai;let s=-1;if(e==="settled"){for(let l=n.length-1;l>=0;l--)if(n[l].kind==="text"){s=l;break}if(s===-1)return Ai}const o=kA(n,t),i=[];let a=0;for(let l=0;l<n.length;l++){if(l===s||l===o)continue;const c=n[l];yA.has(c.kind)||(i.push(l),c.kind==="tool_calls"&&(a+=c.toolCalls.length))}return i.length===0?Ai:{foldedIndices:i,foldAnchorIndex:i[0],foldable:!0,hiddenToolCalls:a}}function _A(n,e){return n!==null&&n>0?`Worked for ${Rn(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const U2="border border-border bg-prompt-surface",ih="border-l border-border/40",ah="border-l border-border";function W2(n){const e=B.c(21),{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,pendingInteraction:v}=st(),w=p&&m!==null,b=w&&s===((m==null?void 0:m.turns.length)??0)-1;let j=!b;if(b&&m){let P;if(e[0]!==m.rawMessages){const{status:_}=D2(m.rawMessages);P=vu.has(_),e[0]=m.rawMessages,e[1]=P}else P=e[1];j=!P}const S=(m==null?void 0:m.cwd)??"",N=bA(S),C=(v==null?void 0:v.type)==="question"?v.toolUseId:void 0,k=c===s,T=!g.enabled||h?void 0:g.requestUndo;let E;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]!==b||e[12]!==l||e[13]!==w||e[14]!==j||e[15]!==C||e[16]!==N||e[17]!==k||e[18]!==T||e[19]!==t?(E=r.jsx(AA,{turn:t,openQuestionId:C,index:s,branchCount:i,isActive:k,activeToolCallId:d,expandAll:u,expandToolPayloads:f,isAgentActive:b,isSessionLive:w,isTurnDone:j,isMobile:l,cwd:S,skillMetadata:N,onRestoreToHere:T,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]=b,e[12]=l,e[13]=w,e[14]=j,e[15]=C,e[16]=N,e[17]=k,e[18]=T,e[19]=t,e[20]=E):E=e[20],E}function TA(n){const e=B.c(12),{index:t,children:s}=n,{session:o,isSubAgentView:i,undoRedo:a,actions:l}=st(),{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(aA,{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 EA(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=_A(Rd(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(Pu,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=i):i=e[4],i}const AA=y.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:v,openQuestionId:w}){const{ref:b,isNear:j}=X0(),S=y.useRef(null),N=y.useRef(0);y.useLayoutEffect(()=>{j&&S.current&&(N.current=S.current.offsetHeight)},[j]);const C=ca(e.toolCalls,m)||e.subAgentActivity.some(R=>ca(R.toolCalls,m)),k=u?"settled":"working",T=y.useMemo(()=>CA(e.contentBlocks,k,w),[k,w,e.contentBlocks]),[E,P]=y.useState(void 0),_=E??(a||!u),{leadingBlocks:A,trailingBlocks:I}=y.useMemo(()=>{if(!T.foldable)return{leadingBlocks:[],trailingBlocks:[]};const R=T.foldAnchorIndex,$=new Set(T.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,R),trailingBlocks:e.contentBlocks.slice(R).filter((M,L)=>_||!$.has(R+L))}},[T,e.contentBlocks,_]);return r.jsxs("div",{ref:b,"data-turn-index":t,className:K("group relative",f?"px-1 py-3":"px-4 py-5",o&&"rounded-lg ring-1 ring-ring/40"),children:[r.jsx($A,{index:t,turn:e,branchCount:s,isTurnDone:u,isMobile:f,onRestoreToHere:h,onOpenBranches:g}),j?r.jsxs("div",{ref:S,className:K("flex flex-col",f?"gap-2":"gap-3"),children:[e.userMessage&&r.jsx(TA,{index:t,children:r.jsx("div",{"data-turn-prompt":!0,className:K(f?"rounded-lg p-2.5":"rounded-lg p-3",U2),children:r.jsx(pu,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:v,compact:f})})}),T.foldable?r.jsxs(r.Fragment,{children:[A.length>0&&r.jsx(Hl,{blocks:A,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(EA,{turn:e,isTurnDone:u,hiddenToolCalls:T.hiddenToolCalls}),expanded:_,onToggle:()=>P(!_),compact:f}),I.length>0&&r.jsx(Hl,{blocks:I,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p})]}):r.jsx(Hl,{blocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:a,expandToolPayloads:l,activeToolCallId:i,isAgentActive:c,isSessionLive:d,isMobile:f,skillMetadata:p}),u&&C&&r.jsx(oA,{turn:e,turnIndex:t,cwd:m})]}):r.jsx("div",{style:{minHeight:N.current||PA(e)}})]})});function PA(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function $A(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?Rd(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=K("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(IA,{durationMs:f,showLiveTimer:d,timestamp:s.timestamp}),e[7]=f,e[8]=d,e[9]=s.timestamp,e[10]=x):x=e[10];let v;e[11]!==t||e[12]!==a||e[13]!==l?(v=l&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:K("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(gd,{"data-icon":"inline-start"}),r.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=a,e[13]=l,e[14]=v):v=e[14];let w;e[15]!==o||e[16]!==t||e[17]!==c||e[18]!==l?(w=o>0&&c&&r.jsx("div",{className:K(!l&&"ml-auto"),children:r.jsx(iA,{branchCount:o,onClick:()=>c(t)})}),e[15]=o,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let b;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==v||e[24]!==w?(b=r.jsxs("div",{className:p,children:[g,x,v,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=v,e[24]=w,e[25]=b):b=e[25],b}function IA(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(Ls,{className:"size-3","data-icon":"inline-start"}),e[0]=i):i=e[0];let a;e[1]!==t?(a=Rn(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(Ls,{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(Pu,{startTimestamp:o,className:"tabular-nums"})]}),e[6]=o,e[7]=a):a=e[7],a}return null}function RA(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 Hl(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,v=(b,j)=>{const S=RA(b)??`at-${j}`,N=x.get(S)??0;return x.set(S,N+1),N===0?S:`${S}#${N}`};let w=0;for(;w<t.length;){const b=t[w];if(b.kind==="thinking"||b.kind==="tool_calls"){const{items:j,toolCalls:S,thinkingCount:N,thoughtForMs:C,nextIndex:k}=oh(t,w),T=j.length===1&&j[0].kind==="tool_calls";p.push(r.jsx("div",{className:K(ih,h),children:r.jsx(Gp,{toolCalls:S,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:T?void 0:j,thinkingCount:N,thoughtForMs:C,skillMetadata:f})},v(b,w))),w=k;continue}if(b.kind==="text"){const{items:j,toolCalls:S,thinkingCount:N,thoughtForMs:C,nextIndex:k}=oh(t,w+1);p.push(r.jsxs("div",{children:[r.jsx("div",{className:K("flex flex-col",g),children:b.text.map((T,E)=>r.jsx(pT,{text:T,model:s,effort:o,timestamp:b.timestamp,compact:u},E))}),(S.length>0||N>0)&&r.jsx("div",{className:K("mt-1.5",ih,h),children:r.jsx(Gp,{toolCalls:S,expandAll:i,expandToolPayloads:a,activeToolCallId:l,isAgentActive:c,activityItems:N>0?j:void 0,thinkingCount:N,thoughtForMs:C,skillMetadata:f})})]},v(b,w))),w=k;continue}if(b.kind==="queued_prompt"){p.push(r.jsxs("div",{className:K(u?"rounded-lg p-2.5":"rounded-lg p-3",U2),children:[r.jsx(Ie,{variant:"outline",className:"mb-2",children:"Queued while working"}),r.jsx(pu,{content:b.content,timestamp:b.timestamp??"",compact:u})]},v(b,w))),w++;continue}if(b.kind==="agent_message"){p.push(r.jsx(fT,{sender:b.sender,body:b.body,reply:b.reply,timestamp:b.timestamp,isLive:d},v(b,w))),w++;continue}if(b.kind==="sub_agent"){p.push(r.jsx("div",{className:K(ah,h),children:r.jsx(Ap,{messages:b.messages,expandAll:i,label:"Sub-agent activity",countLabel:"subagents active"})},v(b,w))),w++;continue}if(b.kind==="background_agent"){p.push(r.jsx("div",{className:K(ah,h),children:r.jsx(Ap,{messages:b.messages,expandAll:i,label:"Background agent activity",countLabel:"agents active"})},v(b,w))),w++;continue}if(b.kind==="hook_event"){p.push(r.jsx(RT,{events:b.events},v(b,w))),w++;continue}if(b.kind==="plan_mode"){p.push(r.jsx(Q9,{plan:b.plan,planFilePath:b.planFilePath,status:b.status,toolCalls:b.toolCalls,expandAll:i,expandToolPayloads:a,isAgentActive:c,skillMetadata:f},v(b,w))),w++;continue}if(b.kind==="recap"){p.push(r.jsx(Z9,{content:b.content},v(b,w))),w++;continue}if(b.kind==="task_notification"){p.push(r.jsx(a7,{content:b.content},v(b,w))),w++;continue}w++}m=r.jsx(r.Fragment,{children:p}),e[0]=l,e[1]=t,e[2]=o,e[3]=i,e[4]=a,e[5]=c,e[6]=u,e[7]=d,e[8]=s,e[9]=f,e[10]=m}else m=e[10];return m}function MA(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${at(n.preTokens)} → ${at(n.postTokens)}`:`${e} · ${at(n.preTokens)}`}const OA=y.memo(function(e){const t=B.c(29),{summary:s,meta:o}=e,[i,a]=y.useState(!1);let l;t[0]!==o?(l=MA(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(nt,{className:"size-3","data-icon":"inline-start"}):r.jsx(Ve,{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(rw,{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 C;t[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=C):C=t[14];let k;t[15]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=k):k=t[15];let T;return t[16]!==x?(T=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[C,x,k]}),t[16]=x,t[17]=T):T=t[17],T}let v,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(ee,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),w=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=v,t[19]=w):(v=t[18],w=t[19]);let b;t[20]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=b):b=t[20];let j;t[21]!==x?(j=r.jsxs(Pt,{render:v,children:[w,x,b]}),t[21]=x,t[22]=j):j=t[22];let S;t[23]!==u?(S=r.jsx(dt,{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(Ln,{remarkPlugins:Bn,components:Fn,children:u})})}),t[23]=u,t[24]=S):S=t[24];let N;return t[25]!==i||t[26]!==j||t[27]!==S?(N=r.jsxs(ct,{open:i,onOpenChange:a,className:"px-4 py-2",children:[j,S]}),t[25]=i,t[26]=j,t[27]=S,t[28]=N):N=t[28],N}),LA=1.5;function DA(n,e){return e<=0?!1:n<e*LA}function zA(n,e){return n===0&&!e}function FA(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function BA(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const UA=1e3;function WA(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)<=UA?!1:(e.set(a,i),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function H2(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&&BA(i,t)?[...o.slice(0,-1),qA(a,i),...n.slice(1)]:[...o,...n];return cu(WA(l))}function HA(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 qA(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:HA(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function KA(){const n=B.c(10),{session:e,isSubAgentView:t,undoRedo:s}=st(),{canRedo:o,redoTurnCount:i,redoGhostTurns:a,requestRedoAll:l,requestRedoUpTo:c}=s,d=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!o||!l)return null;let u;n[0]!==i||n[1]!==l?(u=r.jsx(B7,{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(W2,{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(iw,{"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 VA(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(tt,{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 GA(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function YA({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:o=!1,onLoadMore:i}){const{state:{activeTurnIndex:a}}=Ut(),{undoRedo:l}=st(),c=y.useRef(null),d=y.useRef(null),[u,f]=y.useState(0),m=y.useMemo(()=>{const b=new Map;return n.map(j=>{const S=b.get(j.turn.id)??0;return b.set(j.turn.id,S+1),{...j,key:S===0?j.turn.id:`${j.turn.id}#${S}`}})},[n]),p=y.useRef(null),h=y.useMemo(()=>FA(p.current,m.map(b=>b.key)),[m]);y.useLayoutEffect(()=>{var b;p.current={firstKey:(b=m[0])==null?void 0:b.key,length:m.length}},[m]);const g=y.useRef(t);y.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;y.useLayoutEffect(()=>{const b=e.current,j=d.current;if(!b||!j)return;const S=j.getBoundingClientRect().top-b.getBoundingClientRect().top+b.scrollTop;f(N=>Math.abs(N-S)<1?N:S)},[e,x]),y.useEffect(()=>{if(!t||!i||!o||s)return;const b=e.current;if(!b)return;const j=()=>{DA(b.scrollTop,b.clientHeight)&&i()};return j(),b.addEventListener("scroll",j,{passive:!0}),()=>b.removeEventListener("scroll",j)},[t,s,o,i,m.length,e]);const v=y.useMemo(()=>{const b=new Map;for(let j=0;j<m.length;j++)b.set(m[j].index,j);return b},[m]),w=y.useRef(null);return y.useEffect(()=>{var j;if(a===null){w.current=null;return}if(a===w.current)return;w.current=a;const b=v.get(a);b!==void 0&&((j=c.current)==null||j.scrollToIndex(b,{align:"start",smooth:!0}))},[a,v]),r.jsxs(r.Fragment,{children:[x&&r.jsx(VA,{hasMore:t,isLoadingOlder:s}),r.jsx("div",{ref:d,className:"motion-session-enter",children:r.jsx(F7,{ref:c,scrollRef:e,startMargin:u,shift:h,children:m.map(({turn:b,index:j,key:S})=>r.jsxs("div",{"data-turn-index":j,children:[(b.compactionSummary||b.compactionMeta)&&r.jsx(OA,{summary:b.compactionSummary,meta:b.compactionMeta}),!GA(b)&&r.jsx(W2,{turn:b,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]},S))})}),r.jsx(KA,{})]})}const XA=y.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}=st(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(JA):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==d?(g=d?h.filter(j=>{const{turn:S}=j;return mA(S,d)}):h,t[2]=h,t[3]=d,t[4]=g):g=t[4];const x=g;let v;t[5]!==x.length||t[6]!==o||t[7]!==d?(v=d?x.length===0:zA(x.length,o??!1),t[5]=x.length,t[6]=o,t[7]=d,t[8]=v):v=t[8];const w=v;let b;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]!==w?(b=r.jsx(O_,{children:w?r.jsx(Gt,{className:"min-h-64 border-0",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:d?r.jsx(aw,{}):r.jsx(R1,{})}),r.jsx(Xt,{children:d?"No matching turns":"No conversation yet"}),r.jsx(sn,{children:d?"Try a different search term.":"Messages and tool activity will appear here."})]})}):r.jsx(YA,{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]=w,t[18]=b):b=t[18],b});function JA(n,e){return{turn:n,index:e}}const QA="[data-turn-index]",q2="[data-turn-prompt]",lh=1,ZA=120,ch=180;function eP(n){if(!n.userMessage)return null;const e=qa(n.userMessage),{body:t}=yr(e),{remainingText:s}=mu(t),o=I0(s);if(!o){const a=R0(e);if(!a)return null;const l=M0(e);return l?`/${a} ${l}`:`/${a}`}const i=o.split(`
|
|
120
|
+
`)[0];return i.length>ch?`${i.slice(0,ch)}...`: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(QA)){const c=l.getBoundingClientRect().top;if(c>e+lh)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(q2);return(i?i.getBoundingClientRect().bottom>e+lh:s+ZA>e)?null:o}const sP=y.memo(function(e){const t=B.c(22),{session:s,scrollContainerRef:o}=e,[i,a]=y.useState(null);let l,c;t[0]!==o||t[1]!==s.sessionId?(l=()=>{const j=o.current;if(!j)return;let S=null;const N=()=>{S=null;const E=nP(j);a(P=>E===null?null:(P==null?void 0:P.sessionId)===s.sessionId&&P.index===E?P:{sessionId:s.sessionId,index:E})},C=()=>{S===null&&(S=requestAnimationFrame(N))};a(null),j.addEventListener("scroll",C,{passive:!0});const k=new MutationObserver(C);k.observe(j,{childList:!0,subtree:!0});const T=new ResizeObserver(C);return T.observe(j),j.firstElementChild&&T.observe(j.firstElementChild),C(),()=>{j.removeEventListener("scroll",C),k.disconnect(),T.disconnect(),S!==null&&cancelAnimationFrame(S)}},c=[o,s.sessionId],t[0]=o,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);let d;e:{if(!i||i.sessionId!==s.sessionId){d=null;break e}let j;t[4]!==s.turns||t[5]!==i.index?(j=tP(s.turns,i.index),t[4]=s.turns,t[5]=i.index,t[6]=j):j=t[6],d=j}const u=d;if(!u)return null;let f;t[7]!==u.index||t[8]!==o?(f=()=>{const j=o.current;if(!j)return;const S=j.querySelector(`[data-turn-index="${u.index}"]`),N=(S==null?void 0:S.querySelector(q2))??S;if(!N)return;const C=j.scrollTop+N.getBoundingClientRect().top-j.getBoundingClientRect().top;j.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(R1,{"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 v;t[13]!==u.text?(v=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]=v):v=t[14];let w;t[15]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Er,{"data-icon":"inline-end",className:"ml-auto"}),t[15]=w):w=t[15];let b;return t[16]!==u.text||t[17]!==m||t[18]!==p||t[19]!==x||t[20]!==v?(b=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,v,w]}),t[16]=u.text,t[17]=m,t[18]=p,t[19]=x,t[20]=v,t[21]=b):b=t[21],b});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(dh,{}),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(ju,{text:t.text}),e[7]=t.text,e[8]=o):o=e[8];let i;e[9]!==s?(i=s&&r.jsx(dh,{}),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 dh(){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=y.memo(function(){const e=B.c(9),t=wu();let s,o,i,a;if(e[0]!==t){a=Symbol.for("react.early_return_sentinel");e:{const c=vT(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}class aP extends y.Component{constructor(t){super(t);gi(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(ft,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[r.jsx(un,{}),r.jsx(kt,{children:r.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&r.jsx(mt,{className:"font-mono text-xs",children:this.state.error.message}),r.jsx(Ss,{className:"static col-start-2 mt-2",children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[r.jsx(Et,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const uh="find-in-session-highlight",ql="find-in-session-active";function lP(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 cP=y.forwardRef(function(e,t){const s=B.c(63),{scrollContainerRef:o}=e,[i,a]=y.useState(!1),[l,c]=y.useState("");let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],s[0]=d):d=s[0];const[u,f]=y.useState(d),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==o?(g=()=>{const ne=o.current;if(!ne)return;ne.querySelectorAll(`mark.${uh}`).forEach(dP)},s[1]=o,s[2]=g):g=s[2];const x=g;let v;s[3]!==x||s[4]!==o?(v=ne=>{if(x(),!ne||!o.current){f([]),p(-1);return}const oe=o.current,re=lP(oe),ie=ne.toLowerCase(),se=[];for(const de of re){const ce=de.nodeValue||"",ue=ce.toLowerCase();let me=0;const fe=[];for(;;){const ye=ue.indexOf(ie,me);if(ye===-1)break;fe.push(ye),me=ye+1}if(fe.length===0)continue;const ae=de.parentNode;if(!ae)continue;const ve=document.createDocumentFragment();let ge=0;for(const ye of fe){ye>ge&&ve.appendChild(document.createTextNode(ce.slice(ge,ye)));const Pe=document.createElement("mark");Pe.className=uh,Pe.textContent=ce.slice(ye,ye+ne.length),ve.appendChild(Pe),se.push(Pe),ge=ye+ne.length}ge<ce.length&&ve.appendChild(document.createTextNode(ce.slice(ge))),ae.replaceChild(ve,de)}f(se),se.length>0?(p(0),se[0].classList.add(ql),se[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=o,s[5]=v):v=s[5];const w=v;let b;s[6]!==m||s[7]!==u?(b=ne=>{if(u.length===0)return;m>=0&&m<u.length&&u[m].classList.remove(ql);const oe=(ne%u.length+u.length)%u.length;u[oe].classList.add(ql),u[oe].scrollIntoView({block:"center",behavior:"smooth"}),p(oe)},s[6]=m,s[7]=u,s[8]=b):b=s[8];const j=b;let S;s[9]!==x?(S=()=>{a(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=S):S=s[10];const N=S;let C,k;s[11]!==N||s[12]!==i?(C=()=>({open:()=>{a(!0),requestAnimationFrame(()=>{var ne;return(ne=h.current)==null?void 0:ne.focus()})},close:N,isOpen:i}),k=[N,i],s[11]=N,s[12]=i,s[13]=C,s[14]=k):(C=s[13],k=s[14]),y.useImperativeHandle(t,C,k);let T,E;s[15]!==w||s[16]!==l?(T=()=>{const ne=setTimeout(()=>w(l),150);return()=>clearTimeout(ne)},E=[l,w],s[15]=w,s[16]=l,s[17]=T,s[18]=E):(T=s[17],E=s[18]),y.useEffect(T,E);let P,_;s[19]!==x?(P=()=>()=>x(),_=[x],s[19]=x,s[20]=P,s[21]=_):(P=s[20],_=s[21]),y.useEffect(P,_);let A;s[22]!==m||s[23]!==j||s[24]!==N?(A=ne=>{ne.key==="Escape"?(ne.preventDefault(),ne.stopPropagation(),N()):ne.key==="Enter"&&(ne.preventDefault(),ne.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=N,s[25]=A):A=s[25];const I=A;if(!i)return null;let R;s[26]===Symbol.for("react.memo_cache_sentinel")?(R=ne=>c(ne.target.value),s[26]=R):R=s[26];let $;s[27]!==I||s[28]!==l?($=r.jsx(rs,{ref:h,value:l,onChange:R,onKeyDown:I,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=I,s[28]=l,s[29]=$):$=s[29];const M=l?u.length>0?`${m+1}/${u.length}`:"0/0":"";let L;s[30]!==M?(L=r.jsx(Sn,{align:"inline-end",children:r.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:M})}),s[30]=M,s[31]=L):L=s[31];let D;s[32]!==$||s[33]!==L?(D=r.jsxs(os,{className:"w-64",children:[$,L]}),s[32]=$,s[33]=L,s[34]=D):D=s[34];let F;s[35]!==m||s[36]!==j?(F=()=>j(m-1),s[35]=m,s[36]=j,s[37]=F):F=s[37];const z=u.length===0,O=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let H;s[38]!==O?(H=K("text-muted-foreground",O),s[38]=O,s[39]=H):H=s[39];let W;s[40]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(Er,{"data-icon":"inline-start"}),s[40]=W):W=s[40];let U;s[41]!==F||s[42]!==z||s[43]!==H?(U=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,disabled:z,className:H,"aria-label":"Previous match",children:W}),s[41]=F,s[42]=z,s[43]=H,s[44]=U):U=s[44];let V;s[45]!==m||s[46]!==j?(V=()=>j(m+1),s[45]=m,s[46]=j,s[47]=V):V=s[47];const q=u.length===0,X=u.length>0?"hover:text-foreground":"cursor-default opacity-40";let G;s[48]!==X?(G=K("text-muted-foreground",X),s[48]=X,s[49]=G):G=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(nt,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let J;s[51]!==V||s[52]!==q||s[53]!==G?(J=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:V,disabled:q,className:G,"aria-label":"Next match",children:Y}),s[51]=V,s[52]=q,s[53]=G,s[54]=J):J=s[54];let Q;s[55]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(Qe,{"data-icon":"inline-start"}),s[55]=Q):Q=s[55];let Z;s[56]!==N?(Z=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:N,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:Q}),s[56]=N,s[57]=Z):Z=s[57];let te;return s[58]!==D||s[59]!==U||s[60]!==J||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,U,J,Z]}),s[58]=D,s[59]=U,s[60]=J,s[61]=Z,s[62]=te):te=s[62],te});function dP(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const K2=[1,2,3,4,5,6,7,8,9],EB=["General","View","Tools"],Ja=[{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}},...K2.map(n=>({command:`device.switch.${n}`,label:`Switch to device ${n}`,description:n===1?"Jump to this machine (the local device)":`Jump to the ${n}${n===2?"nd":n===3?"rd":"th"} device in the switcher`,group:"General",defaultShortcut:{key:String(n),platformChord:!0}})),{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],V2="cogpit-keybindings";let As=null;function G2(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function Cr(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function uP(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function $u(){if(As)return As;try{const n=localStorage.getItem(V2);if(!n)return As={};const e=JSON.parse(n);if(!e||typeof e!="object")return As={};const t={};for(const s of Ja){const o=e[s.command];uP(o)&&(t[s.command]=o)}return As=t}catch{return As={}}}function Iu(n){As=n;try{localStorage.setItem(V2,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function ti(n){const e=Ja.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return $u()[n]??e.defaultShortcut}function AB(){return Object.fromEntries(Ja.map(n=>[n.command,ti(n.command)]))}function PB(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:Cr(e.key)};Iu({...$u(),[n]:t})}function $B(n){const e={...$u()};delete e[n],Iu(e)}function IB(){Iu({})}function RB(n){return{key:Cr(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function Y2(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function jt(n,e){const t=ti(n);return"doubleTapModifier"in t||Cr(e.key)!==Cr(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 Zs(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 fP(n){const e=G2();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Zs(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Zs(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Zs(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Zs(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Zs(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Zs(n.key)].filter(Boolean).join("+")}function Kl(n){return fP(ti(n))}function fh(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,o,i)=>`${Cr(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 MB(n,e){const t=new Set(fh(n));return Ja.find(s=>s.command!==e&&fh(ti(s.command)).some(o=>t.has(o)))??null}function mh(n){return"doubleTapModifier"in ti(n)?G2()?"Meta":"Control":null}const mP=K2.map(n=>`device.switch.${n}`),pP="device.cycle";function hP(n){const e=mP.findIndex(t=>jt(t,n));return e===-1?null:e+1}function gP(n){return jt(pP,n)}const qc="cogpit:find-in-conversation",Qa=y.memo(function(e){const t=B.c(77),{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}=st(),{chat:g,scroll:x}=zr(),{searchQuery:v}=f,{pendingMessages:w}=g,{chatScrollRef:b,scrollEndRef:j,handleScroll:S,canScrollDown:N,scrollToBottomInstant:C,initialScrollDone:k}=x,T=y.useRef(null);let E;t[0]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{var ae;return(ae=T.current)==null?void 0:ae.open()},t[0]=E):E=t[0];const P=E;let _,A;t[1]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const ae=function(ge){jt("findInConversation",ge)&&(ge.preventDefault(),P())};return window.addEventListener("keydown",ae),window.addEventListener(qc,P),()=>{window.removeEventListener("keydown",ae),window.removeEventListener(qc,P)}},A=[P],t[1]=_,t[2]=A):(_=t[1],A=t[2]),y.useEffect(_,A);let I,R;t[3]!==p||t[4]!==u||t[5]!==s?(I=()=>{!p||!u||requestAnimationFrame(()=>{var ae;return(ae=s.current)==null?void 0:ae.focus()})},R=[p,u,s],t[3]=p,t[4]=u,t[5]=s,t[6]=I,t[7]=R):(I=t[6],R=t[7]),y.useEffect(I,R);let $;t[8]!==m||t[9]!==d?($=()=>{m({type:"SET_SEARCH_QUERY",value:""}),d==null||d()},t[8]=m,t[9]=d,t[10]=$):$=t[10];const M=$,L=h,D=L.turns.length>0||w.length===0,F=p?"flex min-h-0 flex-1 flex-col":"min-h-0 flex-1";let z;t[11]!==F?(z=K("relative bg-background",F),t[11]=F,t[12]=z):z=t[12];let O;t[13]!==M||t[14]!==m||t[15]!==p||t[16]!==u||t[17]!==s||t[18]!==v?(O=p&&u&&r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[r.jsxs(os,{className:"h-9 flex-1",children:[r.jsx(rs,{ref:s,value:v,onChange:ae=>m({type:"SET_SEARCH_QUERY",value:ae.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),r.jsx(Sn,{align:"inline-start",children:r.jsx(tn,{})})]}),r.jsx(ee,{variant:"ghost",size:"icon-sm",onClick:M,"aria-label":"Close conversation search",children:r.jsx(Qe,{"data-icon":"inline-start"})})]}),t[13]=M,t[14]=m,t[15]=p,t[16]=u,t[17]=s,t[18]=v,t[19]=O):O=t[19];const H=p?"flex-1 min-h-0":"h-full";let W;t[20]!==H?(W=K("relative",H),t[20]=H,t[21]=W):W=t[21];let U;t[22]!==b?(U=r.jsx(cP,{ref:T,scrollContainerRef:b}),t[22]=b,t[23]=U):U=t[23];let V;t[24]!==b||t[25]!==L?(V=r.jsx(sP,{session:L,scrollContainerRef:b}),t[24]=b,t[25]=L,t[26]=V):V=t[26];const q=p&&"mobile-scroll";let X;t[27]!==q?(X=K("h-full overflow-x-hidden overflow-y-auto bg-background",q),t[27]=q,t[28]=X):X=t[28];let G;t[29]!==o||t[30]!==p?(G=p?"px-3 py-3 pb-5":K("mx-auto w-full max-w-[var(--chat-width)] px-6 pt-14",o?"pb-48":"pb-32"),t[29]=o,t[30]=p,t[31]=G):G=t[31];let Y;t[32]!==b||t[33]!==i||t[34]!==k||t[35]!==a||t[36]!==l||t[37]!==D?(Y=D&&r.jsx(XA,{chatScrollRef:b,hasMore:i,isLoadingOlder:a,pagingEnabled:k,onLoadMore:l}),t[32]=b,t[33]=i,t[34]=k,t[35]=a,t[36]=l,t[37]=D,t[38]=Y):Y=t[38];let J;t[39]===Symbol.for("react.memo_cache_sentinel")?(J=r.jsx(rP,{}),t[39]=J):J=t[39];let Q;if(t[40]!==L.turns.length||t[41]!==w){let ae;t[43]!==L.turns.length?(ae=(ve,ge)=>r.jsx(D0,{message:ve,turnNumber:L.turns.length+1+ge},ge),t[43]=L.turns.length,t[44]=ae):ae=t[44],Q=w.map(ae),t[40]=L.turns.length,t[41]=w,t[42]=Q}else Q=t[42];let Z;t[45]===Symbol.for("react.memo_cache_sentinel")?(Z=r.jsx(uA,{}),t[45]=Z):Z=t[45];let te;t[46]!==j?(te=r.jsx("div",{ref:j}),t[46]=j,t[47]=te):te=t[47];let ne;t[48]!==Y||t[49]!==Q||t[50]!==te?(ne=r.jsxs(aP,{fallbackMessage:"Failed to render conversation timeline",children:[Y,J,Q,Z,te]}),t[48]=Y,t[49]=Q,t[50]=te,t[51]=ne):ne=t[51];let oe;t[52]!==G||t[53]!==ne?(oe=r.jsx("div",{className:G,children:ne}),t[52]=G,t[53]=ne,t[54]=oe):oe=t[54];let re;t[55]!==b||t[56]!==S||t[57]!==X||t[58]!==oe?(re=r.jsx("div",{ref:b,onScroll:S,className:X,children:oe}),t[55]=b,t[56]=S,t[57]=X,t[58]=oe,t[59]=re):re=t[59];const ie=N?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",se=p?"right-3 bottom-3":"right-5 bottom-5";let de;t[60]!==ie||t[61]!==se?(de=K("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",ie,se),t[60]=ie,t[61]=se,t[62]=de):de=t[62];let ce;t[63]===Symbol.for("react.memo_cache_sentinel")?(ce=r.jsx(lw,{"data-icon":"inline-start"}),t[63]=ce):ce=t[63];let ue;t[64]!==C||t[65]!==de?(ue=r.jsx(ee,{size:"icon",className:de,onClick:C,"aria-label":"Scroll to bottom",children:ce}),t[64]=C,t[65]=de,t[66]=ue):ue=t[66];let me;t[67]!==W||t[68]!==U||t[69]!==V||t[70]!==re||t[71]!==ue?(me=r.jsxs("div",{className:W,children:[U,V,re,ue]}),t[67]=W,t[68]=U,t[69]=V,t[70]=re,t[71]=ue,t[72]=me):me=t[72];let fe;return t[73]!==O||t[74]!==me||t[75]!==z?(fe=r.jsxs("div",{className:z,children:[O,me]}),t[73]=O,t[74]=me,t[75]=z,t[76]=fe):fe=t[76],fe});async function Ps(n){try{const e=await(n==null?void 0:n.json());return e&&typeof e=="object"?e:null}catch{return null}}async function Vl(n,e){const t=await Ps(n);return typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:e}const Kc="cogpit-devices-changed",X2="cogpit:devices-changed";function J2(n){typeof n.connectionRevision=="number"&&Qj(n.id,n.connectionRevision)}function Q2(n,e,t=!1){window.dispatchEvent(new CustomEvent(Kc,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(X2,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function ph(n){J2(n),Q2(n.id,n.connectionRevision)}function Gl(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function Z2(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function xP(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.edition;if(t==="team"||t==="personal")return t}}function Za(){const[n,e]=y.useState([]),[t,s]=y.useState(!0),[o,i]=y.useState(()=>gt()),a=y.useRef(0),l=y.useCallback(async()=>{const h=++a.current;try{const g=await cs("/api/hub/devices");if(!g.ok)return;const x=await Ps(g);if(h!==a.current)return;const v=Array.isArray(x==null?void 0:x.devices)?x.devices:[];for(const w of v)J2(w);e(v)}catch{}finally{h===a.current&&s(!1)}},[]);y.useEffect(()=>{l()},[l]),y.useEffect(()=>{const h=()=>i(gt()),g=()=>void l(),x=b=>{if(b.key===X2){try{const j=JSON.parse(b.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&>()===j.deviceId&&ys(Nt)}catch{}l()}},v=()=>{a.current+=1,e([]),s(!0),l()},w=()=>{a.current+=1,e([]),s(!1)};return window.addEventListener("cogpit-device-changed",h),window.addEventListener("popstate",h),window.addEventListener(Kc,g),window.addEventListener("storage",x),window.addEventListener("cogpit-auth-changed",v),window.addEventListener("cogpit-identity-changed",v),window.addEventListener("cogpit-auth-required",w),()=>{window.removeEventListener("cogpit-device-changed",h),window.removeEventListener("popstate",h),window.removeEventListener(Kc,g),window.removeEventListener("storage",x),window.removeEventListener("cogpit-auth-changed",v),window.removeEventListener("cogpit-identity-changed",v),window.removeEventListener("cogpit-auth-required",w)}},[l]);const c=y.useMemo(()=>o===Nt?void 0:n.find(h=>h.id===o),[n,o]),d=y.useCallback(async(h,g,x,v)=>{try{const w=await cs("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:h,port:g,allowLocalTunnel:x,tls:v})}),b=await Ps(w);return(b==null?void 0:b.ok)===!0&&b.hello?{ok:!0,hello:b.hello}:{ok:!1,code:(b==null?void 0:b.code)??"UNREACHABLE",error:typeof(b==null?void 0:b.error)=="string"?b.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),u=y.useCallback(async h=>{try{const g=await cs("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)}),x=await Ps(g);if(g.ok&&(x!=null&&x.device)){const v=x.device;return ph(v),{ok:!0,device:v}}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=y.useCallback(async(h,g)=>{try{const x=await cs(Gl(h),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),v=await Ps(x);if(x.ok&&(v!=null&&v.device)){const w=v.device;return ph(w),{ok:!0,device:w}}return{ok:!1,code:(v==null?void 0:v.code)??"ERROR",error:typeof(v==null?void 0:v.error)=="string"?v.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),m=y.useCallback(async h=>{try{const g=await cs(Gl(h),{method:"DELETE"});if(g.ok)return gt()===h&&ys(Nt),Q2(h,void 0,!0),{ok:!0};const x=await Ps(g);return{ok:!1,error:typeof(x==null?void 0:x.error)=="string"?x.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),p=y.useCallback(async h=>{try{const g=await cs(Gl(h,"/test"),{method:"POST"});return await Ps(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 bP="2.6.5",eb={version:bP},hh=eb.version,vP=19384,yP=443,wP=450,jP=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),SP=`${jP?"⌘⇧":"Ctrl+Shift+"}1–9`,NP=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),kP=new Set(["ACCOUNT_DISABLED"]);function Pi(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 CP(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 tb={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function _P(n){const e=B.c(10),{tone:t}=n,s=tb[t];let o;e[0]!==s?(o=K("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(On,{"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(un,{"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(Et,{"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(Hs,{"data-icon":"inline-start",className:i}),e[8]=i,e[9]=a):a=e[9],a}const TP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function EP({device:n,onRename:e,onCredentials:t,onRemove:s,onTest:o}){const[i,a]=y.useState(!1),[l,c]=y.useState(n.name),[d,u]=y.useState(!1),[f,m]=y.useState(n.username??""),[p,h]=y.useState(""),[g,x]=y.useState(null),[v,w]=y.useState(!1),[b,j]=y.useState(null);y.useEffect(()=>{c(n.name)},[n.name]),y.useEffect(()=>{m(n.username??"")},[n.username]);const S=Z2(n),N=S!==void 0&&S!==hh,C=xP(n)==="team";async function k(){const E=l.trim();if(!E||E===n.name){a(!1),c(n.name);return}j("rename"),await e(n.id,E),j(null),a(!1)}async function T(){const E=f.trim(),P=n.username??"",_=E!==P,A=p.length>0;if(!_&&!A){u(!1),h(""),x(null);return}if(n.auth==="none"&&!A){x("Enter a password when adding an account to an unauthenticated device.");return}const I={};_&&(I.username=E||null),A&&(I.password=p),j("credentials"),x(null);const R=await t(n.id,I);if(j(null),!R.ok){x(R.error);return}u(!1),h("")}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:K("size-2 shrink-0 rounded-full",TP[n.runtime.authState])}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[i?r.jsx(It,{value:l,autoFocus:!0,"aria-label":`Rename ${n.name}`,onChange:E=>c(E.target.value),onKeyDown:E=>{E.key==="Enter"&&k(),E.key==="Escape"&&(a(!1),c(n.name))},onBlur:()=>void k(),className:"h-6 text-sm"}):r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm text-foreground",children:n.name}),S&&r.jsxs("span",{className:K("shrink-0 font-mono text-xs",N?"text-warning":"text-muted-foreground"),title:N?`Device runs v${S}; hub runs v${hh}`:void 0,children:["v",S,N&&" ≠ hub"]}),n.auth==="none"&&r.jsx(Ie,{variant:"secondary",children:"Unauthenticated"})]}),r.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[n.tls?"https://":"",n.host,":",n.port]}),n.username?r.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:n.username,children:["Team account: ",n.username]}):C?r.jsx("span",{className:"text-xs text-warning",children:"Team account not configured"}):null]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Re-test ${n.name}`,disabled:b==="test",onClick:async()=>{j("test"),await o(n.id),j(null)},children:r.jsx(Et,{"data-icon":"inline-start",className:K(b==="test"&&"animate-spin")})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Edit account for ${n.name}`,onClick:()=>{u(E=>!E),m(n.username??""),h(""),x(null)},children:r.jsx(yd,{"data-icon":"inline-start"})}),r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":`Rename ${n.name}`,onClick:()=>a(!0),children:r.jsx(Us,{"data-icon":"inline-start"})}),r.jsxs(Ud,{open:v,onOpenChange:E=>{b!=="remove"&&w(E)},children:[r.jsx($N,{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(ga,{"data-icon":"inline-start"})}),r.jsxs(Wd,{size:"sm",children:[r.jsxs(Hd,{children:[r.jsxs(Kd,{children:["Remove ",n.name,"?"]}),r.jsx(Vd,{children:"This device will disappear from Cogpit. You can add it again later."})]}),r.jsxs(qd,{children:[r.jsx(Yd,{disabled:b==="remove",children:"Cancel"}),r.jsxs(Gd,{variant:"destructive",disabled:b==="remove",onClick:async()=>{j("remove");try{await s(n.id)}finally{j(null)}},children:[b==="remove"&&r.jsx(tt,{"data-icon":"inline-start",className:"animate-spin"}),"Remove device"]})]})]})]})]})]}),d&&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(vt,{children:[r.jsxs(yt,{htmlFor:`device-username-${n.id}`,children:["Username ",r.jsx("span",{className:"text-muted-foreground/60",children:"(team devices)"})]}),r.jsx(It,{id:`device-username-${n.id}`,"aria-label":`Username for ${n.name}`,value:f,onChange:E=>m(E.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),r.jsxs(vt,{children:[r.jsxs(yt,{htmlFor:`device-password-${n.id}`,children:["New password ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),r.jsx(It,{id:`device-password-${n.id}`,"aria-label":`New password for ${n.name}`,type:"password",value:p,onChange:E=>h(E.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),n.username&&f.trim()===""&&r.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."}),g&&r.jsx(ps,{children:g}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>{u(!1),m(n.username??""),h(""),x(null)},children:"Cancel"}),r.jsx(ee,{size:"sm",disabled:b==="credentials",onClick:()=>void T(),children:b==="credentials"?r.jsx(tt,{"data-icon":"inline-start",className:"animate-spin"}):"Save account"})]})]})]})}function nb(n){var Ue,ze;const e=B.c(115),{open:t,initialMode:s,onClose:o}=n,{devices:i,refresh:a,probe:l,addDevice:c,updateDevice:d,removeDevice:u,testDevice:f}=Za(),[m,p]=y.useState(""),[h,g]=y.useState(""),[x,v]=y.useState(""),[w,b]=y.useState(""),[j,S]=y.useState(!1),[N,C]=y.useState(!1),[k,T]=y.useState(null),[E,P]=y.useState(!1),[_,A]=y.useState(null),I=y.useRef(null),R=y.useRef(0);let $,M;e[0]!==s||e[1]!==t?($=()=>{t&&(p(""),g(""),v(""),b(""),S(!1),C(!1),T(null),A(null),s==="add"&&requestAnimationFrame(()=>{var Oe;return(Oe=I.current)==null?void 0:Oe.focus()}))},M=[t,s],e[0]=s,e[1]=t,e[2]=$,e[3]=M):($=e[2],M=e[3]),y.useEffect($,M);let L;e[4]!==j||e[5]!==h||e[6]!==l?(L=async()=>{const{host:Oe,port:Ye,tls:Mt}=Pi(h);if(!Oe){T(null),C(!1);return}const ut=R.current=R.current+1;C(!0);const ot=await l(Oe,Ye,j,Mt);ut===R.current&&(T({...CP(ot,Oe,Ye??(Mt?yP:vP)),hello:ot.ok?ot.hello:void 0}),C(!1))},e[4]=j,e[5]=h,e[6]=l,e[7]=L):L=e[7];const D=L;let F,z;e[8]!==h||e[9]!==t||e[10]!==D?(F=()=>{if(!t)return;if(!Pi(h).host){T(null),C(!1);return}const Oe=window.setTimeout(()=>void D(),wP);return()=>window.clearTimeout(Oe)},z=[t,h,D],e[8]=h,e[9]=t,e[10]=D,e[11]=F,e[12]=z):(F=e[11],z=e[12]),y.useEffect(F,z);const O=((Ue=k==null?void 0:k.hello)==null?void 0:Ue.edition)==="team",H=O&&((ze=k==null?void 0:k.hello)==null?void 0:ze.needsBootstrap)===!0,W=O||!j;let U;e:{if(E){U=!1;break e}if(!Pi(h).host){U=!1;break e}if(N||!k){U=!1;break e}if(H){U=!1;break e}if(W&&!w){U=!1;break e}if(O&&!x.trim()){U=!1;break e}if((k==null?void 0:k.tone)==="error"){U=!1;break e}U=!0}const V=U;let q;e[13]!==c||e[14]!==j||e[15]!==W||e[16]!==h||e[17]!==m||e[18]!==o||e[19]!==w||e[20]!==O||e[21]!==x?(q=async function(){const{host:Ye,port:Mt,tls:ut}=Pi(h);if(!Ye)return;P(!0),A(null);const ot=await c({name:m.trim()||void 0,host:Ye,port:Mt,tls:ut,username:O?x.trim():void 0,password:W&&w||void 0,allowLocalTunnel:j});if(P(!1),ot.ok){o(),ys(ot.device.id);return}A({field:kP.has(ot.code)?"username":NP.has(ot.code)?"password":"host",message:ot.error})},e[13]=c,e[14]=j,e[15]=W,e[16]=h,e[17]=m,e[18]=o,e[19]=w,e[20]=O,e[21]=x,e[22]=q):q=e[22];const X=q;let G;e[23]!==d?(G=async(Oe,Ye)=>{await d(Oe,{name:Ye})},e[23]=d,e[24]=G):G=e[24];const Y=G;let J;e[25]!==u?(J=async Oe=>{await u(Oe)},e[25]=u,e[26]=J):J=e[26];const Q=J;let Z;e[27]!==a||e[28]!==f?(Z=async Oe=>{await f(Oe),await a()},e[27]=a,e[28]=f,e[29]=Z):Z=e[29];const te=Z;let ne;e[30]!==o?(ne=Oe=>{Oe||o()},e[30]=o,e[31]=ne):ne=e[31];let oe;e[32]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsxs(_s,{children:[r.jsx(ns,{children:"Devices"}),r.jsxs(ss,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",SP," jumps between devices."]})]}),e[32]=oe):oe=e[32];let re;e[33]!==i||e[34]!==Q||e[35]!==Y||e[36]!==te||e[37]!==d?(re=i.length>0&&r.jsx("div",{className:"flex flex-col gap-2",children:i.map(Oe=>r.jsx(EP,{device:Oe,onRename:Y,onCredentials:d,onRemove:Q,onTest:te},Oe.id))}),e[33]=i,e[34]=Q,e[35]=Y,e[36]=te,e[37]=d,e[38]=re):re=e[38];let ie;e[39]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(In,{"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[39]=ie):ie=e[39];const se=(_==null?void 0:_.field)==="host";let de,ce;e[40]===Symbol.for("react.memo_cache_sentinel")?(de=r.jsx(yt,{htmlFor:"device-host",children:"Host"}),ce=r.jsx(yo,{children:"Enter a local address or an HTTPS URL."}),e[40]=de,e[41]=ce):(de=e[40],ce=e[41]);let ue;e[42]===Symbol.for("react.memo_cache_sentinel")?(ue=Oe=>{R.current=R.current+1,g(Oe.target.value),v(""),T(null),A(null)},e[42]=ue):ue=e[42];let me;e[43]!==D?(me=()=>void D(),e[43]=D,e[44]=me):me=e[44];let fe;e[45]!==h||e[46]!==me?(fe=r.jsx(It,{id:"device-host",ref:I,value:h,onChange:ue,onBlur:me,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[45]=h,e[46]=me,e[47]=fe):fe=e[47];let ae;e[48]!==N?(ae=N&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(tt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[48]=N,e[49]=ae):ae=e[49];let ve;e[50]!==k||e[51]!==N?(ve=!N&&k&&r.jsxs("p",{role:"status",className:K("flex items-center gap-1.5 text-xs",tb[k.tone]),children:[r.jsx(_P,{tone:k.tone}),k.text]}),e[50]=k,e[51]=N,e[52]=ve):ve=e[52];let ge;e[53]!==_?(ge=(_==null?void 0:_.field)==="host"&&r.jsx(ps,{children:_.message}),e[53]=_,e[54]=ge):ge=e[54];let ye;e[55]!==se||e[56]!==fe||e[57]!==ae||e[58]!==ve||e[59]!==ge?(ye=r.jsxs(vt,{"data-invalid":se,children:[de,ce,fe,ae,ve,ge]}),e[55]=se,e[56]=fe,e[57]=ae,e[58]=ve,e[59]=ge,e[60]=ye):ye=e[60];let Pe;e[61]===Symbol.for("react.memo_cache_sentinel")?(Pe=r.jsxs(yt,{htmlFor:"device-name",children:["Name ",r.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[61]=Pe):Pe=e[61];let De;e[62]===Symbol.for("react.memo_cache_sentinel")?(De=Oe=>p(Oe.target.value),e[62]=De):De=e[62];let Te;e[63]!==m?(Te=r.jsxs(vt,{children:[Pe,r.jsx(It,{id:"device-name",value:m,onChange:De,placeholder:"Defaults to the device's own name"})]}),e[63]=m,e[64]=Te):Te=e[64];let Ae;e[65]!==_||e[66]!==O||e[67]!==x?(Ae=O&&r.jsxs(vt,{"data-invalid":(_==null?void 0:_.field)==="username",children:[r.jsx(yt,{htmlFor:"device-username",children:"Username"}),r.jsx(It,{id:"device-username",value:x,onChange:Oe=>v(Oe.target.value),placeholder:"Team account username",autoComplete:"username",spellCheck:!1}),r.jsx(yo,{children:"Requests through this hub will act as this account on the team server."}),(_==null?void 0:_.field)==="username"&&r.jsx(ps,{children:_.message})]}),e[65]=_,e[66]=O,e[67]=x,e[68]=Ae):Ae=e[68];let pe;e[69]!==W||e[70]!==w||e[71]!==_||e[72]!==O?(pe=W&&r.jsxs(vt,{"data-invalid":(_==null?void 0:_.field)==="password",children:[r.jsx(yt,{htmlFor:"device-password",children:"Password"}),r.jsx(It,{id:"device-password",type:"password",value:w,onChange:Oe=>b(Oe.target.value),placeholder:O?"Password for that team account":"Network access password for that device",autoComplete:O?"current-password":"off"}),(_==null?void 0:_.field)==="password"&&r.jsx(ps,{children:_.message})]}),e[69]=W,e[70]=w,e[71]=_,e[72]=O,e[73]=pe):pe=e[73];let xe;e[74]!==ye||e[75]!==Te||e[76]!==Ae||e[77]!==pe?(xe=r.jsxs(To,{children:[ye,Te,Ae,pe]}),e[74]=ye,e[75]=Te,e[76]=Ae,e[77]=pe,e[78]=xe):xe=e[78];let ke;e[79]===Symbol.for("react.memo_cache_sentinel")?(ke=Oe=>{R.current=R.current+1,S(Oe===!0),T(null),A(null)},e[79]=ke):ke=e[79];let $e;e[80]!==j?($e=r.jsx(tx,{id:"device-local-tunnel",name:"device-local-tunnel",checked:j,onCheckedChange:ke}),e[80]=j,e[81]=$e):$e=e[81];const we=O?"":" — no password";let be;e[82]!==we?(be=r.jsxs(yt,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",we]}),e[82]=we,e[83]=be):be=e[83];let Le;e[84]!==$e||e[85]!==be?(Le=r.jsxs(vt,{orientation:"horizontal",children:[$e,be]}),e[84]=$e,e[85]=be,e[86]=Le):Le=e[86];let Se;e[87]!==j||e[88]!==O?(Se=j&&r.jsxs(ft,{className:"border-warning/40 bg-warning/10 text-warning",children:[r.jsx(cw,{}),r.jsx(mt,{className:"text-warning",children:O?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[87]=j,e[88]=O,e[89]=Se):Se=e[89];let Re;e[90]!==o?(Re=r.jsx(ee,{variant:"outline",onClick:o,children:"Close"}),e[90]=o,e[91]=Re):Re=e[91];const Ne=!V;let Fe;e[92]!==X?(Fe=()=>void X(),e[92]=X,e[93]=Fe):Fe=e[93];let He;e[94]!==E?(He=E?r.jsxs(r.Fragment,{children:[r.jsx(tt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[94]=E,e[95]=He):He=e[95];let We;e[96]!==Ne||e[97]!==Fe||e[98]!==He?(We=r.jsx(ee,{disabled:Ne,onClick:Fe,children:He}),e[96]=Ne,e[97]=Fe,e[98]=He,e[99]=We):We=e[99];let Ee;e[100]!==Re||e[101]!==We?(Ee=r.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[Re,We]}),e[100]=Re,e[101]=We,e[102]=Ee):Ee=e[102];let Be;e[103]!==xe||e[104]!==Le||e[105]!==Se||e[106]!==Ee?(Be=r.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ie,xe,Le,Se,Ee]}),e[103]=xe,e[104]=Le,e[105]=Se,e[106]=Ee,e[107]=Be):Be=e[107];let le;e[108]!==re||e[109]!==Be?(le=r.jsxs(ts,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[oe,re,Be]}),e[108]=re,e[109]=Be,e[110]=le):le=e[110];let he;return e[111]!==t||e[112]!==ne||e[113]!==le?(he=r.jsx(es,{open:t,onOpenChange:ne,children:le}),e[111]=t,e[112]=ne,e[113]=le,e[114]=he):he=e[114],he}const AP=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function gh(n,e){if(!AP.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function ao(n,e){return`${n}.${e}`}function PP(n){const e=new Set,t=new Set,s=[];for(const o of n){if(gh("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??[]){gh("panel",i.id);const a=ao(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 $i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function el(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 $i.format(s,"second");const o=Math.round(s/60);if(Math.abs(o)<60)return $i.format(o,"minute");const i=Math.round(o/60);return Math.abs(i)<24?$i.format(i,"hour"):$i.format(Math.round(i/24),"day")}function Ru(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 tl(n){const e=B.c(3),[t,s]=y.useState($P);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function $P(){return Date.now()}function _r(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 nl(n){const e=B.c(10),{icon:t,title:s,description:o}=n;let i;e[0]!==t?(i=r.jsx(nn,{variant:"icon",children:r.jsx(t,{})}),e[0]=t,e[1]=i):i=e[1];let a;e[2]!==s?(a=r.jsx(Xt,{children:s}),e[2]=s,e[3]=a):a=e[3];let l;e[4]!==o?(l=r.jsx(sn,{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(Gt,{className:"border-0",children:r.jsxs(Yt,{children:[i,a,l]})}),e[6]=i,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function Mu(n){const e=B.c(16),{count:t,children:s}=n,[o,i]=y.useState(!1),a=o&&"rotate-90";let l;e[0]!==a?(l=K("size-3 shrink-0 transition-transform",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==l?(c=r.jsx(Ve,{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(Pt,{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(dt,{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(ct,{open:o,onOpenChange:i,children:[u,f]}),e[12]=o,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function sb(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(dw,{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 IP=700,RP=12;function Ou(n){const e=B.c(15),{body:t}=n,[s,o]=y.useState(!1);let i;e[0]!==t?(i=t.length>IP||t.split(`
|
|
121
|
+
`).length>RP,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=K("break-words text-xs leading-5",l),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==t?(d=r.jsx(ju,{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(MP),"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 MP(n){return!n}function xt(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=K("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 bt(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 it(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 lo="cogpit",St={worktrees:ao(lo,"worktrees"),projectFiles:ao(lo,"project-files"),browser:ao(lo,"browser"),fileChanges:ao(lo,"file-changes"),sessionInfo:ao(lo,"session-info")},OP=y.lazy(()=>qe(()=>import("./CommandPaletteHost-DrCXDZkP.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),LP=y.lazy(()=>qe(()=>import("./index-C-D_sWB4.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.ConfigDialog}))),DP=y.lazy(()=>qe(()=>import("./KeyboardShortcutsDialog-DKPBP4Tr.js"),__vite__mapDeps([27,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),zP=y.lazy(()=>qe(()=>import("./ProjectSwitcherModal-lncPQd9P.js"),__vite__mapDeps([28,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),FP=y.lazy(()=>qe(()=>import("./ThemeSelectorModal-E23TFwmi.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function BP(n){const e=B.c(116),{navigation:t,project:s,chrome:o}=n,{state:i,config:a,theme:l}=Ut(),{session:c,sessionSource:d}=st(),{devices:u,activeDeviceId:f}=Za(),[m,p]=y.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=et("manageDevices"),e[0]=h):h=e[0];const g=h;let x;e[1]!==i.pendingCwd||e[2]!==i.pendingDirName?(x=i.pendingCwd??(i.pendingDirName?vn(i.pendingDirName):null),e[1]=i.pendingCwd,e[2]=i.pendingDirName,e[3]=x):x=e[3];const v=x,w=(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject??null,b=o.onKeyboardShortcutsOpenChange;let j,S;e[4]!==b?(j=()=>{const We=function(Be){jt("keyboardShortcuts",Be)&&(Y2(document.activeElement)||(Be.preventDefault(),b(!0)))};return window.addEventListener("keydown",We),()=>window.removeEventListener("keydown",We)},S=[b],e[4]=b,e[5]=j,e[6]=S):(j=e[5],S=e[6]),y.useEffect(j,S);const N=f===Nt;let C;e[7]!==N?(C={id:Nt,name:"This machine",isLocal:!0,isActive:N},e[7]=N,e[8]=C):C=e[8];let k;if(e[9]!==f||e[10]!==u||e[11]!==C){let We;e[13]!==f?(We=Ee=>({id:Ee.id,name:Ee.name,isLocal:!1,isActive:Ee.id===f}),e[13]=f,e[14]=We):We=e[14],k=[C,...u.map(We)],e[9]=f,e[10]=u,e[11]=C,e[12]=k}else k=e[12];const T=k;let E;e[15]!==c||e[16]!==(d==null?void 0:d.agentKind)||e[17]!==(d==null?void 0:d.dirName)?(E=()=>{if(!c)return;const We=(d==null?void 0:d.agentKind)??At((d==null?void 0:d.dirName)??null);Na(J1(We,c.sessionId,c.cwd))},e[15]=c,e[16]=d==null?void 0:d.agentKind,e[17]=d==null?void 0:d.dirName,e[18]=E):E=e[18];const P=E,_=UP,A=o.processPanel,I=o.workflowsPanel,R=o.undoDialog,$=o.branchModal,M=a.claudeDir??"";let L;e[19]!==a.handleCloseConfigDialog||e[20]!==a.handleConfigSaved||e[21]!==a.showConfigDialog||e[22]!==M?(L=r.jsx(y.Suspense,{fallback:null,children:r.jsx(LP,{open:a.showConfigDialog,currentPath:M,onClose:a.handleCloseConfigDialog,onSaved:a.handleConfigSaved})}),e[19]=a.handleCloseConfigDialog,e[20]=a.handleConfigSaved,e[21]=a.showConfigDialog,e[22]=M,e[23]=L):L=e[23];const D=(d==null?void 0:d.dirName)??i.pendingDirName??null,F=(c==null?void 0:c.cwd)??i.pendingCwd??null;let z;e[24]!==a.defaultAgentKind||e[25]!==t.onStartNewFolder||e[26]!==t.onStartNewSession||e[27]!==t.panels.handleCloseProjectSwitcher||e[28]!==t.panels.showProjectSwitcher||e[29]!==D||e[30]!==F?(z=r.jsx(y.Suspense,{fallback:null,children:r.jsx(zP,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:a.defaultAgentKind,currentProjectDirName:D,currentProjectCwd:F})}),e[24]=a.defaultAgentKind,e[25]=t.onStartNewFolder,e[26]=t.onStartNewSession,e[27]=t.panels.handleCloseProjectSwitcher,e[28]=t.panels.showProjectSwitcher,e[29]=D,e[30]=F,e[31]=z):z=e[31];let O;e[32]!==t.panels.handleCloseThemeSelector||e[33]!==t.panels.showThemeSelector||e[34]!==l.setPreview||e[35]!==l.setTheme||e[36]!==l.theme?(O=r.jsx(y.Suspense,{fallback:null,children:r.jsx(FP,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[32]=t.panels.handleCloseThemeSelector,e[33]=t.panels.showThemeSelector,e[34]=l.setPreview,e[35]=l.setTheme,e[36]=l.theme,e[37]=O):O=e[37];const H=o.commandPaletteOpen,W=o.onCommandPaletteOpenChange,U=t.actions.handleGoHome,V=t.panels.handleOpenProjectSwitcher,q=t.onOpenPaletteProject,X=t.actions.handleDashboardSelect,G=t.panels.handleToggleSidebar;let Y,J,Q;e[38]!==t.panels?(Y=()=>t.panels.toggleWorkspacePanel(St.sessionInfo),J=()=>t.panels.toggleWorkspacePanel(St.fileChanges),Q=()=>t.panels.toggleWorkspacePanel(St.worktrees),e[38]=t.panels,e[39]=Y,e[40]=J,e[41]=Q):(Y=e[39],J=e[40],Q=e[41]);const Z=t.panels.handleToggleMission,te=c?t.handlers.handleDuplicateSession:void 0,ne=c?P:void 0,oe=c?_:void 0,re=et("killAny")?o.onKillAll:void 0,ie=et("configWrite")?t.panels.handleToggleConfig:void 0,se=a.openConfigDialog;let de;e[42]!==b?(de=()=>b(!0),e[42]=b,e[43]=de):de=e[43];const ce=s.currentCwd?s.onTogglePreview:void 0,ue=et("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let me;e[44]!==t.panels?(me=et("hostFiles")?()=>t.panels.toggleWorkspacePanel(St.browser):void 0,e[44]=t.panels,e[45]=me):me=e[45];const fe=t.panels.handleToggleThemeSelector,ae=s.onOpenTerminal,ve=o.onFocusComposer,ge=o.onExpandAll,ye=o.onExpandToolPayloads,Pe=o.onCollapseAll,De=!!(c||i.pendingDirName);let Te;e[46]!==v||e[47]!==(c==null?void 0:c.cwd)||e[48]!==(d==null?void 0:d.dirName)||e[49]!==i.dashboardProject||e[50]!==i.pendingDirName?(Te=et("terminal")&&!!((c==null?void 0:c.cwd)??v??(d==null?void 0:d.dirName)??i.pendingDirName??i.dashboardProject),e[46]=v,e[47]=c==null?void 0:c.cwd,e[48]=d==null?void 0:d.dirName,e[49]=i.dashboardProject,e[50]=i.pendingDirName,e[51]=Te):Te=e[51];const Ae=!!c;let pe;e[52]!==s.hasFileChanges?(pe=et("hostFiles")&&s.hasFileChanges,e[52]=s.hasFileChanges,e[53]=pe):pe=e[53];const xe=t.panels.activeWorkspacePanel===St.sessionInfo,ke=t.panels.activeWorkspacePanel===St.browser,$e=t.panels.activeWorkspacePanel===St.fileChanges,we=t.panels.activeWorkspacePanel===St.worktrees,be=i.mainView==="config",Le=i.mainView==="mission",Se=(c==null?void 0:c.cwd)??v??null;let Re;e[54]!==o.commandPaletteOpen||e[55]!==o.onCollapseAll||e[56]!==o.onCommandPaletteOpenChange||e[57]!==o.onExpandAll||e[58]!==o.onExpandToolPayloads||e[59]!==o.onFocusComposer||e[60]!==a.openConfigDialog||e[61]!==w||e[62]!==t.actions.handleDashboardSelect||e[63]!==t.actions.handleGoHome||e[64]!==t.onOpenPaletteProject||e[65]!==t.panels.handleOpenProjectSwitcher||e[66]!==t.panels.handleToggleMission||e[67]!==t.panels.handleToggleSidebar||e[68]!==t.panels.handleToggleThemeSelector||e[69]!==t.panels.showSidebar||e[70]!==T||e[71]!==s.launchTerminalRequest||e[72]!==s.onOpenTerminal||e[73]!==s.processPanel.addProcess||e[74]!==s.showProjectFiles||e[75]!==s.supportsWorktrees||e[76]!==Y||e[77]!==J||e[78]!==Q||e[79]!==te||e[80]!==ne||e[81]!==oe||e[82]!==re||e[83]!==ie||e[84]!==de||e[85]!==ce||e[86]!==ue||e[87]!==me||e[88]!==De||e[89]!==Te||e[90]!==Ae||e[91]!==pe||e[92]!==xe||e[93]!==ke||e[94]!==$e||e[95]!==we||e[96]!==be||e[97]!==Le||e[98]!==Se?(Re=r.jsx(y.Suspense,{fallback:null,children:r.jsx(OP,{open:H,onOpenChange:W,onGoHome:U,onNewSession:V,onOpenProject:q,onOpenSession:X,onToggleSidebar:G,onToggleStats:Y,onToggleFileChanges:J,onToggleWorktrees:Q,onToggleMissionControl:Z,onDuplicateSession:te,onCopyResumeCommand:ne,onFindInConversation:oe,onKillAll:re,onOpenConfig:ie,onOpenSettings:se,onOpenKeyboardShortcuts:de,onTogglePreview:ce,onToggleProjectFiles:ue,onToggleBrowser:me,onOpenTheme:fe,onOpenTerminal:ae,onOpenDevices:g?p:void 0,onSwitchDevice:ys,devices:T,onFocusComposer:ve,onExpandAll:ge,onExpandToolPayloads:ye,onCollapseAll:Pe,canFocusComposer:De,canOpenTerminal:Te,hasSession:Ae,hasFileChanges:pe,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:xe,showProjectFiles:s.showProjectFiles,showBrowser:ke,showFileChanges:$e,showWorktrees:we,showConfig:be,showMission:Le,currentProjectDirName:w,projectCwd:Se,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[54]=o.commandPaletteOpen,e[55]=o.onCollapseAll,e[56]=o.onCommandPaletteOpenChange,e[57]=o.onExpandAll,e[58]=o.onExpandToolPayloads,e[59]=o.onFocusComposer,e[60]=a.openConfigDialog,e[61]=w,e[62]=t.actions.handleDashboardSelect,e[63]=t.actions.handleGoHome,e[64]=t.onOpenPaletteProject,e[65]=t.panels.handleOpenProjectSwitcher,e[66]=t.panels.handleToggleMission,e[67]=t.panels.handleToggleSidebar,e[68]=t.panels.handleToggleThemeSelector,e[69]=t.panels.showSidebar,e[70]=T,e[71]=s.launchTerminalRequest,e[72]=s.onOpenTerminal,e[73]=s.processPanel.addProcess,e[74]=s.showProjectFiles,e[75]=s.supportsWorktrees,e[76]=Y,e[77]=J,e[78]=Q,e[79]=te,e[80]=ne,e[81]=oe,e[82]=re,e[83]=ie,e[84]=de,e[85]=ce,e[86]=ue,e[87]=me,e[88]=De,e[89]=Te,e[90]=Ae,e[91]=pe,e[92]=xe,e[93]=ke,e[94]=$e,e[95]=we,e[96]=be,e[97]=Le,e[98]=Se,e[99]=Re):Re=e[99];let Ne;e[100]!==o.keyboardShortcutsOpen||e[101]!==b?(Ne=r.jsx(y.Suspense,{fallback:null,children:r.jsx(DP,{open:o.keyboardShortcutsOpen,onOpenChange:b})}),e[100]=o.keyboardShortcutsOpen,e[101]=b,e[102]=Ne):Ne=e[102];let Fe;e[103]!==m?(Fe=g&&r.jsx(nb,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[103]=m,e[104]=Fe):Fe=e[104];let He;return e[105]!==o.branchModal||e[106]!==o.processPanel||e[107]!==o.undoDialog||e[108]!==o.workflowsPanel||e[109]!==L||e[110]!==z||e[111]!==O||e[112]!==Re||e[113]!==Ne||e[114]!==Fe?(He=r.jsxs(r.Fragment,{children:[A,I,R,$,L,z,O,Re,Ne,Fe]}),e[105]=o.branchModal,e[106]=o.processPanel,e[107]=o.undoDialog,e[108]=o.workflowsPanel,e[109]=L,e[110]=z,e[111]=O,e[112]=Re,e[113]=Ne,e[114]=Fe,e[115]=He):He=e[115],He}function UP(){window.dispatchEvent(new Event(qc))}function Yl(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(_t,{render:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4];let a;e[5]!==t?(a=r.jsx(Tt,{children:t}),e[5]=t,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l=r.jsxs(Ct,{children:[i,a]}),e[7]=i,e[8]=a,e[9]=l):l=e[9],l}const xh=eb.version,WP={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},bh={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function HP(n){const e=B.c(6),{state:t}=n,s=bh[t],o=bh[t],i=WP[t];let a;e[0]!==i?(a=K("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 Lu(n){const e=B.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:o,activeDeviceId:i,activeDevice:a,refresh:l,testDevice:c}=Za(),[d,u]=y.useState(null),f=(a==null?void 0:a.name)??"This machine",m=i!==Nt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=et("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==o||e[2]!==l||e[3]!==c?(g=z=>{!z||o.length===0||Promise.all(o.map(O=>c(O.id).catch(KP))).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 v=s?"sm":"xs",w=s&&"h-10";let b;e[5]!==w?(b=K("max-w-40 justify-start",w),e[5]=w,e[6]=b):b=e[6];let j;e[7]!==v||e[8]!==b?(j=r.jsx(ee,{variant:"ghost",size:v,"aria-label":"Switch device",className:b}),e[7]=v,e[8]=b,e[9]=j):j=e[9];let S;e[10]!==m?(S=m?r.jsx(A1,{"data-icon":"inline-start"}):r.jsx(am,{"data-icon":"inline-start"}),e[10]=m,e[11]=S):S=e[11];let N;e[12]!==f?(N=r.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(nt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=C):C=e[14];let k;e[15]!==j||e[16]!==S||e[17]!==N?(k=r.jsxs(Po,{render:j,children:[S,N,C]}),e[15]=j,e[16]=S,e[17]=N,e[18]=k):k=e[18];let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Og,{children:"Devices"}),e[19]=T):T=e[19];let E,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(am,{}),P=r.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=E,e[21]=P):(E=e[20],P=e[21]);let _;e[22]!==m?(_=!m&&r.jsx(lt,{className:"ml-auto text-success"}),e[22]=m,e[23]=_):_=e[23];let A;e[24]!==_?(A=r.jsxs(zt,{onClick:qP,children:[E,P,_]}),e[24]=_,e[25]=A):A=e[25];let I;if(e[26]!==i||e[27]!==s||e[28]!==o){let z;e[30]!==i||e[31]!==s?(z=O=>{const H=Z2(O),W=H!==void 0&&H!==xh,U=O.id===i;return r.jsxs(zt,{onClick:()=>ys(O.id),className:K(s&&"min-h-10"),children:[r.jsx(HP,{state:O.runtime.authState}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"truncate",children:O.name}),W&&r.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${H}; hub runs v${xh}`,children:["v",H]})]}),r.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[O.host,":",O.port,O.auth==="none"&&" · unauthenticated"]})]}),U&&r.jsx(lt,{className:"ml-auto text-success"})]},O.id)},e[30]=i,e[31]=s,e[32]=z):z=e[32],I=o.map(z),e[26]=i,e[27]=s,e[28]=o,e[29]=I}else I=e[29];let R;e[33]!==A||e[34]!==I?(R=r.jsxs(Gn,{children:[T,A,I]}),e[33]=A,e[34]=I,e[35]=R):R=e[35];let $;e[36]!==o.length?($=h&&r.jsxs(r.Fragment,{children:[r.jsx(Qi,{}),r.jsxs(Gn,{children:[r.jsxs(zt,{onClick:()=>u("add"),children:[r.jsx(In,{}),r.jsx("span",{children:"Add device…"})]}),o.length>0&&r.jsxs(zt,{onClick:()=>u("manage"),children:[r.jsx(md,{}),r.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=o.length,e[37]=$):$=e[37];let M;e[38]!==R||e[39]!==$?(M=r.jsxs($o,{align:"end",sideOffset:6,className:"w-64",children:[R,$]}),e[38]=R,e[39]=$,e[40]=M):M=e[40];let L;e[41]!==x||e[42]!==k||e[43]!==M?(L=r.jsxs(Ao,{onOpenChange:x,children:[k,M]}),e[41]=x,e[42]=k,e[43]=M,e[44]=L):L=e[44];let D;e[45]!==d?(D=h&&r.jsx(nb,{open:d!==null,initialMode:d??"manage",onClose:()=>u(null)}),e[45]=d,e[46]=D):D=e[46];let F;return e[47]!==L||e[48]!==D?(F=r.jsxs(r.Fragment,{children:[L,D]}),e[47]=L,e[48]=D,e[49]=F):F=e[49],F}function qP(){return ys(Nt)}function KP(){return null}const VP=6e4;function GP(){const[n,e]=y.useState([]),[t,s]=y.useState(!1),o=y.useRef(!1),i=y.useCallback(async()=>{if(!o.current){o.current=!0;try{const l=await _e("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(d=>d.suspectedLeak))}}catch{}finally{o.current=!1}}},[]),a=y.useCallback(async l=>{if(l.length!==0){s(!0);try{await _e("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:l})}),await new Promise(c=>setTimeout(c,1e3)),await i()}catch{}finally{s(!1)}}},[i]);return y.useEffect(()=>{i();const l=window.setInterval(()=>{document.visibilityState==="visible"&&i()},VP);return()=>window.clearInterval(l)},[i]),{leaks:n,killing:t,killLeaks:a,refresh:i}}const YP=6e4;function XP(){const n=B.c(29),{leaks:e,killing:t,killLeaks:s,refresh:o}=GP(),[i,a]=y.useState(!1),l=e.length>0,c=e.reduce(ZP,0);let d,u;if(n[0]!==l?(d=()=>{if(l){a(!0);return}const _=window.setTimeout(()=>a(!1),YP);return()=>window.clearTimeout(_)},u=[l],n[0]=l,n[1]=d,n[2]=u):(d=n[1],u=n[2]),y.useEffect(d,u),!l&&!i)return null;const f=Ct,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(QP)):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=K("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let v;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(v=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]=v):v=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(uw,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const b=t?"…":e.length;let j;n[17]!==b?(j=r.jsx("span",{className:"tabular-nums",children:b}),n[17]=b,n[18]=j):j=n[18];let S;n[19]!==j||n[20]!==v?(S=r.jsxs(_t,{render:v,children:[w,j]}),n[19]=j,n[20]=v,n[21]=S):S=n[21];const N=Tt,C="bottom",k="p-3",T=l?r.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[r.jsxs("div",{className:"text-xs font-medium",children:["Leaked agent processes · ",c.toFixed(0),"% CPU"]}),e.slice(0,6).map(JP),e.length>6&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),r.jsx(wt,{}),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 E;n[22]!==N||n[23]!==T?(E=r.jsx(N,{side:C,className:k,children:T}),n[22]=N,n[23]=T,n[24]=E):E=n[24];let P;return n[25]!==f||n[26]!==S||n[27]!==E?(P=r.jsxs(f,{children:[S,E]}),n[25]=f,n[26]=S,n[27]=E,n[28]=P):P=n[28],P}function JP(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," · ",Id(n.ageSeconds)]}),r.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function QP(n){return n.pid}function ZP(n,e){return n+e.cpuPercent}const e$=15e3;function t$(){const n=B.c(12);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{try{const v=await _e("/api/notifications?limit=100");if(!v.ok)return;const w=await v.json();Array.isArray(w.notifications)&&s(w.notifications)}catch{}},n[1]=o):o=n[1];const i=o;let a,l;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{i();const v=window.setInterval(()=>void i(),e$);return()=>window.clearInterval(v)},l=[i],n[2]=a,n[3]=l):(a=n[2],l=n[3]),y.useEffect(a,l);let c;n[4]===Symbol.for("react.memo_cache_sentinel")?(c=async(v,w)=>{const b=new Date().toISOString();s(j=>j.map(S=>S.readAt===null&&w(S)?{...S,readAt:b}:S));try{await _e("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)})}catch{}},n[4]=c):c=n[4];const d=c;let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u=async v=>d({ids:v},w=>v.includes(w.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},s$),n[6]=m):m=n[6];const p=m;let h;n[7]!==t?(h=t.filter(n$),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 n$(n){return n.readAt===null}function s$(){return!0}function ob(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function o$(){const n=B.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:o,markAllRead:i}=t$(),[a,l]=y.useState(!1);let c;n[0]!==o?(c=function(k){if(o([k.id]),!k.dirName||!k.sessionId)return;const T=gt(),E=T===Nt?"":`/d/${T}`;ob(`${E}/${encodeURIComponent(k.dirName)}/${encodeURIComponent(k.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(lm,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&r.jsx(Ie,{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(Po,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let v;n[13]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=v):v=n[13];let w;n[14]!==i||n[15]!==t?(w=t>0&&r.jsxs(ee,{variant:"ghost",size:"xs",onClick:()=>void i(),children:[r.jsx(fw,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=i,n[15]=t,n[16]=w):w=n[16];let b;n[17]!==w?(b=r.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[v,w]}),n[17]=w,n[18]=b):b=n[18];let j;n[19]!==e||n[20]!==d?(j=r.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?r.jsx(Gt,{className:"min-h-40 p-6",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(lm,{})}),r.jsx(Xt,{children:"No notifications"}),r.jsx(sn,{children:"Session updates will appear here."})]})}):r.jsx(Gn,{children:e.map(C=>r.jsx(r$,{notification:C,onOpen:d},C.id))})}),n[19]=e,n[20]=d,n[21]=j):j=n[21];let S;n[22]!==b||n[23]!==j?(S=r.jsxs($o,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[b,j]}),n[22]=b,n[23]=j,n[24]=S):S=n[24];let N;return n[25]!==a||n[26]!==u||n[27]!==S||n[28]!==x?(N=r.jsxs(Ao,{open:a,onOpenChange:u,children:[x,S]}),n[25]=a,n[26]=u,n[27]=S,n[28]=x,n[29]=N):N=n[29],N}function r$(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"?Wt:ja;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=K("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=K("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 v=o?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==v?(w=K("truncate text-xs",v),e[13]=v,e[14]=w):w=e[14];let b;e[15]!==t.title||e[16]!==w?(b=r.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=b):b=e[17];let j;e[18]!==c?(j=Id(c),e[18]=c,e[19]=j):j=e[19];let S;e[20]!==j?(S=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:j}),e[20]=j,e[21]=S):S=e[21];let N;e[22]!==b||e[23]!==S?(N=r.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[b,S]}),e[22]=b,e[23]=S,e[24]=N):N=e[24];let C;e[25]!==t.body?(C=r.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=C):C=e[26];let k;e[27]!==N||e[28]!==C?(k=r.jsxs("span",{className:"min-w-0 flex-1",children:[N,C]}),e[27]=N,e[28]=C,e[29]=k):k=e[29];let T;e[30]!==o?(T=o&&r.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=o,e[31]=T):T=e[31];let E;return e[32]!==k||e[33]!==T||e[34]!==u||e[35]!==p||e[36]!==x?(E=r.jsxs(zt,{onClick:u,className:p,children:[x,k,T]}),e[32]=k,e[33]=T,e[34]=u,e[35]=p,e[36]=x,e[37]=E):E=e[37],E}const i$=2e3;function ko(n){return`${n.toFixed(n<10?1:0)}%`}function ua(n){return`${n.toFixed(0)} MB`}function a$(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function l$(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 c$(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(Ie,{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(Ie,{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(Ie,{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=K("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=ko(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=ua(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let v;e[32]!==t.ageSeconds?(v=Id(t.ageSeconds),e[32]=t.ageSeconds,e[33]=v):v=e[33];let w;e[34]!==x||e[35]!==v?(w=r.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",v]}),e[34]=x,e[35]=v,e[36]=w):w=e[36];let b;e[37]!==g||e[38]!==w?(b=r.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=b):b=e[39];let j;return e[40]!==b||e[41]!==u||e[42]!==f?(j=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[u,f,b]}),e[40]=b,e[41]=u,e[42]=f,e[43]=j):j=e[43],j}function d$(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 u$(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 rb(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(Ie,{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=d$(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=K("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=ko(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=ua(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 v;return e[31]!==x||e[32]!==c?(v=r.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=v):v=e[33],v}function vh(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(f$)}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 f$(n,e){const t=l$(n.bytesPerSecond);return r.jsxs("div",{children:[e>0&&r.jsx(wt,{}),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:a$(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(Ie,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function m$(n){const e=B.c(8),{values:t}=n,s=Math.max(100,...t);let o;e[0]!==t?(o=t.map(p$).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:K("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:ko(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 p$(n){return ko(n)}function h$(n){var me,fe,ae,ve;const e=B.c(135),{open:t,onOpenChange:s}=n,[o,i]=y.useState(null),[a,l]=y.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[d,u]=y.useState(c),[f,m]=y.useState(null),[p,h]=y.useState(!1),g=y.useRef(!1),[x,v]=Xn();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var pe;if(g.current)return;g.current=!0,h(!0);const ge=_e("/api/performance").then(w$),ye=((pe=window.electronPerformance)==null?void 0:pe.getSnapshot())??Promise.resolve(null),[Pe,De]=await Promise.allSettled([ge,ye]),Te=Pe.status==="fulfilled"?Pe.value:null,Ae=De.status==="fulfilled"?De.value:null;if(Te&&l(Te),Ae&&i(Ae),!Te&&!Ae)m("Performance data is unavailable.");else{m(null);const xe=Ae&&Ae.processes.length>0?Ae.processes.reduce(y$,0):(Te==null?void 0:Te.cpuPercent)??0;u(ke=>[...ke.slice(-29),xe])}g.current=!1,h(!1)},e[1]=w):w=e[1];const b=w;let j,S;e[2]!==t?(j=()=>{if(!t)return;b();const ge=window.setInterval(()=>void b(),i$);return()=>window.clearInterval(ge)},S=[t,b],e[2]=t,e[3]=j,e[4]=S):(j=e[3],S=e[4]),y.useEffect(j,S);let N,C,k,T,E,P,_,A,I,R,$,M,L,D,F,z,O,H,W;if(e[5]!==x||e[6]!==v||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(v$),ye=ge.length>0?ge.reduce(b$,0):(a==null?void 0:a.cpuPercent)??0,Pe=ge[0];let De;e[33]!==((me=a==null?void 0:a.system)==null?void 0:me.processes)?(De=((fe=a==null?void 0:a.system)==null?void 0:fe.processes)??[],e[33]=(ae=a==null?void 0:a.system)==null?void 0:ae.processes,e[34]=De):De=e[34],_=De;const Te=((ve=a==null?void 0:a.system)==null?void 0:ve.suspectedLeakCount)??0,Ae=Te>0||ye>=80?"High":ye>=15?"Active":"Idle";let pe;e[35]===Symbol.for("react.memo_cache_sentinel")?(pe=async ot=>{try{await _e("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[ot]})}),await new Promise(x$)}catch{}b()},e[35]=pe):pe=e[35],P=pe;let xe;e[36]!==v||e[37]!==o||e[38]!==d||e[39]!==a?(xe=()=>{v(JSON.stringify({capturedAt:new Date().toISOString(),electron:o,server:a,cpuHistory:d},null,2))},e[36]=v,e[37]=o,e[38]=d,e[39]=a,e[40]=xe):xe=e[40];const ke=xe;E=es,L=t,D=s,T=ts,R="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let $e;e[41]===Symbol.for("react.memo_cache_sentinel")?($e=r.jsx(ns,{children:"Power & activity monitor"}),e[41]=$e):$e=e[41];const we=Ae==="High"?"destructive":"secondary";let be;e[42]!==Ae||e[43]!==we?(be=r.jsxs("div",{className:"flex items-center gap-2",children:[$e,r.jsx(Ie,{variant:we,children:Ae})]}),e[42]=Ae,e[43]=we,e[44]=be):be=e[44];let Le;e[45]===Symbol.for("react.memo_cache_sentinel")?(Le=r.jsx(ss,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=Le):Le=e[45];let Se;e[46]!==be?(Se=r.jsxs("div",{className:"min-w-0 flex-1",children:[be,Le]}),e[46]=be,e[47]=Se):Se=e[47];let Re;e[48]===Symbol.for("react.memo_cache_sentinel")?(Re=()=>void b(),e[48]=Re):Re=e[48];const Ne=p&&"animate-spin";let Fe;e[49]!==Ne?(Fe=K(Ne),e[49]=Ne,e[50]=Fe):Fe=e[50];let He;e[51]!==Fe?(He=r.jsx(Et,{"data-icon":"inline-start",className:Fe}),e[51]=Fe,e[52]=He):He=e[52];let We;e[53]!==p||e[54]!==He?(We=r.jsxs(ee,{variant:"outline",size:"sm",onClick:Re,disabled:p,children:[He,"Refresh"]}),e[53]=p,e[54]=He,e[55]=We):We=e[55];const Ee=!a&&!o;let Be;e[56]!==x?(Be=x?r.jsx(lt,{"data-icon":"inline-start"}):r.jsx(fn,{"data-icon":"inline-start"}),e[56]=x,e[57]=Be):Be=e[57];const le=x?"Copied":"Copy data";let he;e[58]!==ke||e[59]!==Ee||e[60]!==Be||e[61]!==le?(he=r.jsxs(ee,{variant:"outline",size:"sm",onClick:ke,disabled:Ee,children:[Be,le]}),e[58]=ke,e[59]=Ee,e[60]=Be,e[61]=le,e[62]=he):he=e[62];let Ue;e[63]!==We||e[64]!==he?(Ue=r.jsxs("div",{className:"flex shrink-0 gap-1",children:[We,he]}),e[63]=We,e[64]=he,e[65]=Ue):Ue=e[65],e[66]!==Se||e[67]!==Ue?($=r.jsx(_s,{className:"p-5 pb-4",children:r.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[Se,Ue]})}),e[66]=Se,e[67]=Ue,e[68]=$):$=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(wt,{}),e[69]=M):M=e[69],k=zn,I="min-h-0 min-w-0 flex-1",H="flex flex-col gap-4 p-5",e[70]!==f?(W=f&&r.jsx(ft,{variant:"destructive",children:r.jsx(mt,{children:f})}),e[70]=f,e[71]=W):W=e[71];let ze;e[72]===Symbol.for("react.memo_cache_sentinel")?(ze=r.jsx(an,{children:"Current load"}),e[72]=ze):ze=e[72];const Oe=ye>=80&&"text-destructive";let Ye;e[73]!==Oe?(Ye=K("font-mono text-lg font-semibold tabular-nums",Oe),e[73]=Oe,e[74]=Ye):Ye=e[74];const Mt=r.jsxs(rn,{children:[ze,r.jsx(ln,{children:u$(ye,Pe,Te)}),r.jsx(nx,{children:r.jsxs("span",{className:Ye,children:[ko(ye)," CPU"]})})]});let ut;e[75]!==d?(ut=r.jsx(en,{children:r.jsx(m$,{values:d})}),e[75]=d,e[76]=ut):ut=e[76],e[77]!==Mt||e[78]!==ut?(A=r.jsxs(Zt,{size:"sm",children:[Mt,ut]}),e[77]=Mt,e[78]=ut,e[79]=A):A=e[79],C=Zt,z="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsxs(rn,{children:[r.jsx(an,{children:"Processes"}),r.jsx(ln,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=O):O=e[80],N=en,F=ge.length>0?ge.map(g$):a?r.jsx(rb,{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]=v,e[7]=o,e[8]=f,e[9]=d,e[10]=s,e[11]=t,e[12]=p,e[13]=a,e[14]=N,e[15]=C,e[16]=k,e[17]=T,e[18]=E,e[19]=P,e[20]=_,e[21]=A,e[22]=I,e[23]=R,e[24]=$,e[25]=M,e[26]=L,e[27]=D,e[28]=F,e[29]=z,e[30]=O,e[31]=H,e[32]=W}else N=e[14],C=e[15],k=e[16],T=e[17],E=e[18],P=e[19],_=e[20],A=e[21],I=e[22],R=e[23],$=e[24],M=e[25],L=e[26],D=e[27],F=e[28],z=e[29],O=e[30],H=e[31],W=e[32];let U;e[81]!==N||e[82]!==F?(U=r.jsx(N,{children:F}),e[81]=N,e[82]=F,e[83]=U):U=e[83];let V;e[84]!==C||e[85]!==U||e[86]!==z||e[87]!==O?(V=r.jsxs(C,{size:z,children:[O,U]}),e[84]=C,e[85]=U,e[86]=z,e[87]=O,e[88]=V):V=e[88];let q;e[89]!==P||e[90]!==_?(q=_.length>0&&r.jsxs(Zt,{size:"sm",children:[r.jsxs(rn,{children:[r.jsx(an,{children:"Agent processes"}),r.jsx(ln,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),r.jsx(en,{children:_.map((ge,ye)=>r.jsxs("div",{children:[ye>0&&r.jsx(wt,{}),r.jsx(c$,{metric:ge,onKill:Pe=>void P(Pe)})]},ge.pid))})]}),e[89]=P,e[90]=_,e[91]=q):q=e[91];let X;e[92]===Symbol.for("react.memo_cache_sentinel")?(X=r.jsx(an,{children:"Server activity"}),e[92]=X):X=e[92];const G=(a==null?void 0:a.sampleWindowSeconds)??10;let Y;e[93]!==G?(Y=r.jsxs(rn,{children:[X,r.jsxs(ln,{children:["File checks, streams, and agent work over the last ",G," seconds."]})]}),e[93]=G,e[94]=Y):Y=e[94];let J;e[95]!==(a==null?void 0:a.activities)?(J=(a==null?void 0:a.activities)??[],e[95]=a==null?void 0:a.activities,e[96]=J):J=e[96];let Q;e[97]!==J?(Q=r.jsx(en,{children:r.jsx(vh,{metrics:J,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=J,e[98]=Q):Q=e[98];let Z;e[99]!==Y||e[100]!==Q?(Z=r.jsxs(Zt,{size:"sm",children:[Y,Q]}),e[99]=Y,e[100]=Q,e[101]=Z):Z=e[101];let te;e[102]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsxs(rn,{children:[r.jsx(an,{children:"API activity"}),r.jsx(ln,{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(Zt,{size:"sm",children:[te,r.jsx(en,{children:r.jsx(vh,{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 ie;e[110]!==a?(ie=a&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",ko(a.eventLoopPercent)," · heap ",ua(a.memory.heapUsedMb)," · RSS ",ua(a.memory.rssMb)]}),e[110]=a,e[111]=ie):ie=e[111];let se;e[112]!==A||e[113]!==V||e[114]!==q||e[115]!==re||e[116]!==ie||e[117]!==H||e[118]!==W?(se=r.jsxs("div",{className:H,children:[W,A,V,q,re,ie]}),e[112]=A,e[113]=V,e[114]=q,e[115]=re,e[116]=ie,e[117]=H,e[118]=W,e[119]=se):se=e[119];let de;e[120]!==k||e[121]!==I||e[122]!==se?(de=r.jsx(k,{className:I,children:se}),e[120]=k,e[121]=I,e[122]=se,e[123]=de):de=e[123];let ce;e[124]!==T||e[125]!==R||e[126]!==$||e[127]!==M||e[128]!==de?(ce=r.jsxs(T,{className:R,children:[$,M,de]}),e[124]=T,e[125]=R,e[126]=$,e[127]=M,e[128]=de,e[129]=ce):ce=e[129];let ue;return e[130]!==E||e[131]!==L||e[132]!==D||e[133]!==ce?(ue=r.jsx(E,{open:L,onOpenChange:D,children:ce}),e[130]=E,e[131]=L,e[132]=D,e[133]=ce,e[134]=ue):ue=e[134],ue}function g$(n,e){return r.jsxs("div",{children:[e>0&&r.jsx(wt,{}),r.jsx(rb,{metric:n})]},n.pid)}function x$(n){return setTimeout(n,1e3)}function b$(n,e){return n+e.cpuPercent}function v$(n,e){return e.cpuPercent-n.cpuPercent}function y$(n,e){return n+e.cpuPercent}async function w$(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function j$(n){return`${n.title??`Pull request #${n.number}`}
|
|
122
|
+
${n.repo}${n.isDraft?" · draft":""}`}function ib(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:j$(n)}}function sl(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(N$),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(S$).join(`
|
|
123
|
+
`),children:["+",p.length]}),e[9]=a,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==o?(m=p=>{const h=p.isDraft?wd:Mr;return r.jsxs(Ie,{variant:p.isDraft?"outline":"secondary",render:r.jsx("a",{...ib(p)}),className:K("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 S$(n){return`#${n.number} ${n.title??n.repo}`}function N$(n){const e=n.isDraft?wd:Mr;return r.jsxs("a",{...ib(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 k$=y.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 P=o?ws(o.fileName):null;p=P?Nu(P.agentId):null,t[0]=o,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(T$),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let v;t[4]!==s.rawMessages||t[5]!==(o==null?void 0:o.dirName)?(v=vo(o==null?void 0:o.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=o==null?void 0:o.dirName,t[6]=v):v=t[6];const w=v;let b;t[7]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("div",{className:K(_n,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=b):b=t[7];let j;t[8]!==l||t[9]!==c||t[10]!==d||t[11]!==f||t[12]!==u||t[13]!==m||t[14]!==s||t[15]!==o?(j=o?r.jsx(_$,{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]=j):j=t[16];let S;t[17]!==i?(S=i&&r.jsx(Aa,{"aria-label":"Session is live"}),t[17]=i,t[18]=S):S=t[18];let N;t[19]!==s.model?(N=s.model&&r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-foreground/80",children:Ks(s.model)}),t[19]=s.model,t[20]=N):N=t[20];let C;t[21]!==w?(C=r.jsx(Lg,{rawMessages:w}),t[21]=w,t[22]=C):C=t[22];let k;t[23]!==j||t[24]!==S||t[25]!==N||t[26]!==C?(k=r.jsxs(_t,{delay:200,render:b,children:[j,S,N,C]}),t[23]=j,t[24]=S,t[25]=N,t[26]=C,t[27]=k):k=t[27];let T;t[28]!==a||t[29]!==w||t[30]!==s||t[31]!==h||t[32]!==x?(T=r.jsx(Tt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:r.jsx(C$,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:a,rawMessages:w})}),t[28]=a,t[29]=w,t[30]=s,t[31]=h,t[32]=x,t[33]=T):T=t[33];let E;return t[34]!==T||t[35]!==k?(E=r.jsxs(Ct,{children:[k,T]}),t[34]=T,t[35]=k,t[36]=E):E=t[36],E});function eo(n){const e=B.c(7),{label:t,children:s}=n;let o;e[0]!==t?(o=r.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==s?(i=r.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=i):i=e[3];let a;return e[4]!==o||e[5]!==i?(a=r.jsxs("div",{className:"flex gap-3",children:[o,i]}),e[4]=o,e[5]=i,e[6]=a):a=e[6],a}function C$(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=pg(a),x=t.branchedFrom;l="flex min-w-64 max-w-96 flex-col gap-1.5 text-xs",e[14]!==t.model||e[15]!==s?(c=t.model&&r.jsxs(eo,{label:"Model",children:[r.jsx("span",{children:Ks(t.model)}),s&&r.jsx("span",{className:"text-muted-foreground",children:"· thinking"})]}),e[14]=t.model,e[15]=s,e[16]=c):c=e[16],e[17]!==t.gitBranch?(d=t.gitBranch&&r.jsx(eo,{label:"Branch",children:r.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=d):d=e[18],e[19]!==i?(u=i.length>0&&r.jsx(eo,{label:"Pull requests",children:r.jsx(sl,{pullRequests:i})}),e[19]=i,e[20]=u):u=e[20],e[21]!==o?(f=o&&r.jsx(eo,{label:"Agent",children:o}),e[21]=o,e[22]=f):f=e[22],e[23]!==x?(m=x&&r.jsxs(eo,{label:"Duplicated from",children:[x.sessionId.slice(0,8),x.turnIndex!=null?` at turn ${x.turnIndex+1}`:""]}),e[23]=x,e[24]=m):m=e[24],p=g&&r.jsxs(eo,{label:"Context",children:[at(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",at(g.used)," / ",at(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 _$(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=Ds(),e[0]=m):m=e[0];const p=m;let h;e[1]!==t.sessionId||e[2]!==t.slug?(h=t.slug||t.sessionId.slice(0,8),e[1]=t.sessionId,e[2]=t.slug,e[3]=h):h=e[3];const g=h;let x;e[4]!==t.cwd||e[5]!==g?(x=t.cwd?`${Yn(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const v=x;let w;e[7]!==t.cwd||e[8]!==s.dirName?(w={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=w):w=e[9];const b=w;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=!p||Qd(),e[10]=j):j=e[10];const S=j;let N;e[11]!==u||e[12]!==s.dirName?(N=function(){y.startTransition(()=>{u({type:"GO_HOME",isMobile:!1}),u({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[11]=u,e[12]=s.dirName,e[13]=N):N=e[13];const C=N,k=`Copy resume command for ${v}; open session actions with the context menu`;let T;e[14]!==a||e[15]!==k?(T=r.jsx("button",{type:"button",onClick:a,className:"flex min-w-0 max-w-80 items-center gap-1.5 truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent","aria-label":k,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[14]=a,e[15]=k,e[16]=T):T=e[16];let E;e[17]!==o||e[18]!==t.cwd||e[19]!==g?(E=o?r.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[r.jsx(lt,{className:"size-3"})," Copied"]}):r.jsxs(r.Fragment,{children:[t.cwd&&r.jsx("span",{className:"truncate text-muted-foreground",children:Yn(t.cwd)}),t.cwd&&r.jsx("span",{className:"text-muted-foreground/50",children:"/"}),r.jsx("span",{className:"truncate",children:g})]}),e[17]=o,e[18]=t.cwd,e[19]=g,e[20]=E):E=e[20];let P;e[21]!==T||e[22]!==E?(P=r.jsx(Ya,{render:T,children:E}),e[21]=T,e[22]=E,e[23]=P):P=e[23];let _;e[24]!==l||e[25]!==t.cwd||e[26]!==s.dirName?(_=()=>l(s.dirName,t.cwd),e[24]=l,e[25]=t.cwd,e[26]=s.dirName,e[27]=_):_=e[27];let A;e[28]!==i?(A=i?r.jsx(Ze,{className:"size-3.5"}):r.jsx(In,{className:"size-3.5"}),e[28]=i,e[29]=A):A=e[29];let I;e[30]!==i||e[31]!==_||e[32]!==A?(I=r.jsxs(Ft,{disabled:i,onClick:_,children:[A,"New session in this project"]}),e[30]=i,e[31]=_,e[32]=A,e[33]=I):I=e[33];let R;e[34]!==c?(R=c&&r.jsxs(Ft,{onClick:c,children:[r.jsx(fn,{className:"size-3.5"}),"Duplicate this session"]}),e[34]=c,e[35]=R):R=e[35];let $;e[36]!==f||e[37]!==b?($=f&&(S||!p)&&r.jsxs(r.Fragment,{children:[r.jsx(No,{}),S&&r.jsxs(Ft,{onClick:()=>cx(b),children:[r.jsx(bd,{className:"size-3.5"}),"Open project in editor"]}),!p&&r.jsxs(Ft,{onClick:()=>dx(b),children:[r.jsx(M1,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[36]=f,e[37]=b,e[38]=$):$=e[38];let M;e[39]!==d?(M=d&&!p&&et("terminal")&&r.jsxs(Ft,{onClick:d,children:[r.jsx(Ws,{className:"size-3.5"}),"Open terminal in project"]}),e[39]=d,e[40]=M):M=e[40];let L;e[41]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(No,{}),e[41]=L):L=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(bo,{className:"size-3.5"}),e[42]=D):D=e[42];let F;e[43]!==C?(F=r.jsxs(Ft,{onClick:C,children:[D,"View all sessions in this project"]}),e[43]=C,e[44]=F):F=e[44];let z;e[45]!==I||e[46]!==R||e[47]!==$||e[48]!==M||e[49]!==F?(z=r.jsxs(Xa,{className:"min-w-56",children:[I,R,$,M,L,F]}),e[45]=I,e[46]=R,e[47]=$,e[48]=M,e[49]=F,e[50]=z):z=e[50];let O;return e[51]!==P||e[52]!==z?(O=r.jsxs(Ga,{children:[P,z]}),e[51]=P,e[52]=z,e[53]=O):O=e[53],O}function T$(n){return n.thinking.length>0}const Ko="Could not reach the server";async function Ii(n,e){try{return await _e(n,e)}catch{return null}}function E$(){const n=B.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e),[o,i]=y.useState(null),a=y.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(a.current=!0,()=>{a.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),y.useEffect(l,c);let d;n[3]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{const N=await Ii("/api/shares");if(!(N!=null&&N.ok))return;const C=await N.json().catch(I$);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]),y.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async N=>{i(null);const C=await Ii("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:N})});if(!(C!=null&&C.ok))return a.current&&i(await Vl(C,Ko)),null;const k=await C.json().catch($$);if(!(k!=null&&k.passphrase)||!k.share)return a.current&&i(Ko),null;const T=k.share;return a.current&&s(E=>[...E.filter(P=>P.sessionId!==T.sessionId),T]),k.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async N=>{i(null);const C=await Ii(`/api/shares/${encodeURIComponent(N)}/regenerate`,{method:"POST"});if(!(C!=null&&C.ok))return a.current&&i(await Vl(C,Ko)),null;const k=await C.json().catch(P$);return k!=null&&k.passphrase?(u(),k.passphrase):(a.current&&i(Ko),null)},n[7]=g):g=n[7];const x=g;let v;n[8]===Symbol.for("react.memo_cache_sentinel")?(v=async N=>{i(null);const C=await Ii(`/api/shares/${encodeURIComponent(N)}`,{method:"DELETE"});if(!(C!=null&&C.ok)){a.current&&i(await Vl(C,Ko));return}a.current&&s(k=>k.filter(T=>T.sessionId!==N))},n[8]=v):v=n[8];const w=v;let b;n[9]!==t?(b=async()=>{const N=t.map(A$);for(const C of N)await w(C)},n[9]=t,n[10]=b):b=n[10];const j=b;let S;return n[11]!==o||n[12]!==j||n[13]!==t?(S={shares:t,error:o,refresh:u,create:h,regenerate:x,revoke:w,revokeAll:j},n[11]=o,n[12]=j,n[13]=t,n[14]=S):S=n[14],S}function A$(n){return n.sessionId}function P$(){return null}function $$(){return null}function I$(){return null}const R$=5e3,M$="••••";function O$(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function L$({sessionId:n}){const{config:{networkAccessDisabled:e}}=Ut(),{shares:t,error:s,refresh:o,create:i,regenerate:a,revoke:l}=E$(),[c,d]=y.useState(!1),[u,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=Xn(),[x,v]=Xn(),w=t.find(N=>N.sessionId===n)??null,b=`${window.location.origin}${LS(n)}`;y.useEffect(()=>f(null),[n]),y.useEffect(()=>{if(!c)return;o();const N=setInterval(()=>void o(),R$);return()=>clearInterval(N)},[c,o]);async function j(N){p(!0);try{await N()}finally{p(!1)}}const S=e&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return r.jsxs(Ao,{open:c,onOpenChange:N=>{d(N),N||f(null)},children:[r.jsx(Po,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":w?"Session is shared":"Share session",className:K(w&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:r.jsx(mw,{"data-icon":"inline-start"})}),r.jsx($o,{align:"end",sideOffset:6,className:"w-80 p-3",children:w?r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:b}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(b),children:h?r.jsx(lt,{"data-icon":"inline-start"}):r.jsx(fn,{"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??M$}),r.jsx(ee,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>j(async()=>{f(await a(n))}),children:r.jsx(Et,{"data-icon":"inline-start"})})]}),u?r.jsx(ee,{variant:"secondary",size:"xs",onClick:()=>v(`${b}
|
|
124
|
+
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."}),S,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:O$(w.guests)}),r.jsx(ee,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>j(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."}),S,s&&r.jsx("p",{className:"text-xs text-destructive",children:s}),r.jsx(ee,{size:"xs",disabled:m,onClick:()=>j(async()=>{f(await i(n))}),children:"Enable sharing"})]})})]})}function Du(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 rt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function wn(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function hs(n){return typeof n=="string"?n:void 0}function ms(n){return n?Du(wn(n.utilization),hs(n.resets_at)):void 0}function ab(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:wn(n.monthly_limit),usedCredits:wn(n.used_credits),utilization:wn(n.utilization)}}function D$(n){return{fiveHour:ms(rt(n.five_hour)),sevenDay:ms(rt(n.seven_day)),sevenDayOpus:ms(rt(n.seven_day_opus)),sevenDaySonnet:ms(rt(n.seven_day_sonnet)),extraUsage:ab(rt(n.extra_usage)),subscriptionType:hs(n.subscriptionType)}}function z$(n){if(n.available!==!0)return null;const e=rt(n.usage),t=rt(e==null?void 0:e.rate_limits),s=rt(n.account),o={fiveHour:ms(rt(t==null?void 0:t.five_hour)),sevenDay:ms(rt(t==null?void 0:t.seven_day)),sevenDayOpus:ms(rt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:ms(rt(t==null?void 0:t.seven_day_sonnet)),extraUsage:ab(rt(t==null?void 0:t.extra_usage)),subscriptionType:hs(e==null?void 0:e.subscription_type)??hs(s==null?void 0:s.subscriptionType)};return o.fiveHour||o.sevenDay||o.extraUsage||o.subscriptionType?o:null}function F$(n){const e=wn(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function B$(n,e){const t=wn(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function yh(n,e){if(n)return Du(wn(n.usedPercent),F$(n.resetsAt),B$(n.windowDurationMins,e))}function U$(n){var d,u,f;if(n.available!==!0)return null;const e=rt((d=rt(n.rateLimits))==null?void 0:d.rateLimits),t=rt((u=rt(n.account))==null?void 0:u.account),s=rt((f=rt(n.usage))==null?void 0:f.summary),o=rt(e==null?void 0:e.credits),i=yh(rt(e==null?void 0:e.primary),"Primary"),a=yh(rt(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=wn(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0);return!i&&!a&&c===void 0?null:{fiveHour:i,sevenDay:a,subscriptionType:hs(e==null?void 0:e.planType)??hs(t==null?void 0:t.planType),lifetimeTokens:c,creditBalance:hs(o==null?void 0:o.balance),creditsUnlimited:(o==null?void 0:o.unlimited)===!0}}function wh(n,e){if(!n)return;const t=wn(n.remainingPercentage),s=wn(n.usedRequests),o=wn(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),Du(i,hs(n.resetDate),e)}function W$(n){var s;if(n.available!==!0)return null;const e=rt((s=rt(n.quota))==null?void 0:s.quotaSnapshots),t=wh(rt(e==null?void 0:e.chat),"Chat")??wh(rt(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const H$={claude:{endpoint:"/api/claude/runtime",read:z$,legacy:{endpoint:"/api/usage",read:D$}},codex:{endpoint:"/api/codex/runtime",read:U$},copilot:{endpoint:"/api/copilot/runtime",read:W$}};function q$(n){return H$[n]}const K$=300*1e3;function V$(n=qs){const e=jn("viewUsage"),[t,s]=y.useState(null),[o,i]=y.useState(!1),[a,l]=y.useState(!1),c=y.useRef(0),d=y.useRef(null),u=y.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=q$(n);let x=await _e(g.endpoint,{signal:m.signal}),v=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await _e(g.legacy.endpoint,{signal:m.signal}),v=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const w=await x.json();if(!p())return;const b=v(w);l(b!==null),s(b?{...b,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(d.current=null,i(!1))}},[n,e]);return y.useEffect(()=>{var m;if(s(null),l(!1),!e){i(!1),c.current+=1,(m=d.current)==null||m.abort(),d.current=null;return}u();const f=setInterval(u,K$);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 lb(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const cb={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function G$(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?Ta(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(Ie,{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,v=lb(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:K("font-semibold",cb[v]),children:[h.pct.toFixed(1),"%"]})]}),r.jsx(Wr,{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(wt,{}),"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(wt,{}),t.lifetimeTokens!=null&&r.jsxs("div",{children:["Lifetime: ",at(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 Y$(n){var j,S;const e=B.c(22),{agentKind:t}=n,s=t===void 0?qs:t,{usage:o,loading:i,available:a,refresh:l}=V$(s);if(!a||!o)return null;const c=((j=o.fiveHour)==null?void 0:j.utilization)??((S=o.sevenDay)==null?void 0:S.utilization);if(c==null)return null;let d;e[0]!==o.agentKind?(d=o.agentKind?Ta(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=cb[lb(c)],p=i&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=K("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 v;e[14]!==f||e[15]!==x?(v=r.jsx(_t,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=v):v=e[16];let w;e[17]!==o?(w=r.jsx(Tt,{side:"bottom",className:"p-3",children:r.jsx(G$,{usage:o})}),e[17]=o,e[18]=w):w=e[18];let b;return e[19]!==v||e[20]!==w?(b=r.jsxs(Ct,{children:[v,w]}),e[19]=v,e[20]=w,e[21]=b):b=e[21],b}function X$(n){const e=B.c(9);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={summary:null,loading:!1,error:null},e[0]=t):t=e[0];const[s,o]=y.useState(t),[i,a]=y.useState(0);let l;e[1]!==n?(l=()=>{const m=new AbortController;o(Q$);const p=Intl.DateTimeFormat().resolvedOptions().timeZone;return _e(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(p)}`,{signal:m.signal}).then(async h=>{if(!h.ok)throw new Error(`Usage scan failed (${h.status})`);const g=await h.json();o({summary:g,loading:!1,error:null})}).catch(h=>{m.signal.aborted||o(g=>({...g,loading:!1,error:h instanceof Error?h.message:"Usage scan failed"}))}),()=>m.abort()},e[1]=n,e[2]=l):l=e[2];let c;e[3]!==n||e[4]!==i?(c=[n,i],e[3]=n,e[4]=i,e[5]=c):c=e[5],y.useEffect(l,c);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(J$),e[6]=d):d=e[6];const u=d;let f;return e[7]!==s?(f={...s,refresh:u},e[7]=s,e[8]=f):f=e[8],f}function J$(n){return n+1}function Q$(n){return{...n,loading:!0,error:null}}function Z$(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const eI=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function tI(n,e){const t=Z$(e);return t.length===0||eI.has(t)?null:n.get(t)??null}function nI(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 sI(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function oI(n,e,t,s=null){const o=tI(n,e);if(o===null)return null;const i=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),a=t.cacheCreationTokens-i,l=nI(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 rI(n,e,t,s,o=null){const i=oI(n,e,t,o);return i===null?{costUsd:0,costSource:"unpriced"}:{costUsd:sI(i),costSource:"modelPriced"}}function zu(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function iI(n,e,t){if(!e)return 0;const{costUsd:s,costSource:o}=rI(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 aI=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],ir=xg.map(n=>({key:n,label:on(n).displayName,color:D4(n)}));function lI(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 jh(){return{claude:{costUsd:0,tokens:0},codex:{costUsd:0,tokens:0},copilot:{costUsd:0,tokens:0}}}function cI(n){const e=new Map;for(const o of lI(n.sinceDay,n.untilDay))e.set(o,{day:o,byProvider:jh(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:jh(),days:[],models:[]};for(const o of n.buckets){const i=zu(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 Sh(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const Xl=720,Jl=180,dI=18;function uI(n){const e=B.c(41),{days:t,metric:s}=n,[o,i]=y.useState(null);let a;e[0]!==s?(a=C=>s==="cost"?C.costUsd:C.tokens,e[0]=s,e[1]=a):a=e[1];const l=a;let c;if(e[2]!==t||e[3]!==l){let C;e[5]!==l?(C=k=>l(k),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=Jl-dI,f=Xl/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:Sh(p.day)}),ir.map(C=>{const{key:k,label:T,color:E}=C,P=p.byProvider[k];return l(P)<=0?null:r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:E}}),T,": ",s==="cost"?cn(P.costUsd):at(P.tokens)]},k)}),r.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?cn(p.costUsd):at(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,v;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>i(null),v=r.jsx("line",{x1:0,y1:u,x2:Xl,y2:u,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=v):(x=e[12],v=e[13]);let w;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=(k,T)=>{const E=T*f+(f-m)/2;let P=u;const _=o===T;return r.jsxs("g",{onMouseEnter:()=>i(T),children:[r.jsx("rect",{x:T*f,y:0,width:f,height:u,fill:"transparent"}),_&&r.jsx("rect",{x:T*f,y:0,width:f,height:u,fill:"var(--foreground)",opacity:.05,rx:2}),ir.map(A=>{const{key:I,color:R}=A,$=l(k.byProvider[I]);if($<=0)return null;const M=$/d*(u-6);return P=P-M,r.jsx("rect",{x:E,y:P,width:m,height:Math.max(1,M-1.5),rx:1.5,fill:R,opacity:_?1:.85},I)})]},k.day)},e[21]=m,e[22]=o,e[23]=d,e[24]=f,e[25]=l,e[26]=C):C=e[26],w=t.map(C),e[14]=m,e[15]=t,e[16]=o,e[17]=d,e[18]=f,e[19]=l,e[20]=w}else w=e[20];let b;if(e[27]!==t||e[28]!==f){let C;e[30]!==t.length||e[31]!==f?(C=(k,T)=>T===0||T===t.length-1||t.length>10&&T%7===0&&T<t.length-3?r.jsx("text",{x:T*f+f/2,y:Jl-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:Sh(k.day)},k.day):null,e[30]=t.length,e[31]=f,e[32]=C):C=e[32],b=t.map(C),e[27]=t,e[28]=f,e[29]=b}else b=e[29];let j;e[33]!==g||e[34]!==w||e[35]!==b?(j=r.jsxs("svg",{viewBox:`0 0 ${Xl} ${Jl}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[v,w,b]}),e[33]=g,e[34]=w,e[35]=b,e[36]=j):j=e[36];let S;e[37]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"mt-1 flex items-center gap-4",children:ir.map(fI)}),e[37]=S):S=e[37];let N;return e[38]!==h||e[39]!==j?(N=r.jsxs("div",{className:"relative",children:[h,j,S]}),e[38]=h,e[39]=j,e[40]=N):N=e[40],N}function fI(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 Ql(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 mI(n){const e=B.c(68),{days:t}=n,{summary:s,loading:o,error:i,refresh:a}=X$(t),[l,c]=y.useState("cost");let d;e[0]!==s?(d=s?cI(s):null,e[0]=s,e[1]=d):d=e[1];const u=d;if(i){let z;e[2]!==a?(z=r.jsx(ee,{variant:"outline",size:"sm",onClick:a,children:"Retry"}),e[2]=a,e[3]=z):z=e[3];let O;return e[4]!==i||e[5]!==z?(O=r.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[i,z]}),e[4]=i,e[5]=z,e[6]=O):O=e[6],O}if(!u||!s){let z;return e[7]===Symbol.for("react.memo_cache_sentinel")?(z=r.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[r.jsx(Ze,{className:"size-4"})," Scanning transcripts…"]}),e[7]=z):z=e[7],z}const f=o&&"opacity-60";let m;e[8]!==f?(m=K("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"?cn(u.costUsd):at(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 v;e[19]!==h||e[20]!==x?(v=r.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=v):v=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let b;e[23]!==l?(b=r.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(z=>r.jsx(ee,{variant:l===z?"secondary":"ghost",size:"xs",onClick:()=>c(z),children:z==="cost"?"Cost":"Tokens"},z))}),e[23]=l,e[24]=b):b=e[24];let j;e[25]!==u.byProvider||e[26]!==l?(j=ir.map(z=>{const{key:O,label:H}=z,W=u.byProvider[O];return W.costUsd===0&&W.tokens===0?null:r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[H,": ",l==="cost"?cn(W.costUsd):at(W.tokens)]},O)}),e[25]=u.byProvider,e[26]=l,e[27]=j):j=e[27];let S;e[28]!==b||e[29]!==j?(S=r.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[b,j]}),e[28]=b,e[29]=j,e[30]=S):S=e[30];let N;e[31]!==S||e[32]!==v?(N=r.jsxs("div",{className:"flex items-end justify-between gap-4",children:[v,S]}),e[31]=S,e[32]=v,e[33]=N):N=e[33];let C;e[34]!==u.days||e[35]!==l?(C=r.jsx(uI,{days:u.days,metric:l}),e[34]=u.days,e[35]=l,e[36]=C):C=e[36];let k;e[37]!==u.tokens?(k=at(u.tokens),e[37]=u.tokens,e[38]=k):k=e[38];let T;e[39]!==k?(T=r.jsx(Ql,{label:"Processed tokens",value:k}),e[39]=k,e[40]=T):T=e[40];let E;e[41]!==u.cacheSavingsUsd?(E=cn(u.cacheSavingsUsd),e[41]=u.cacheSavingsUsd,e[42]=E):E=e[42];let P;e[43]!==E?(P=r.jsx(Ql,{label:"Cache savings",value:E}),e[43]=E,e[44]=P):P=e[44];const _=String(s.scannedFiles);let A;e[45]!==_?(A=r.jsx(Ql,{label:"Files scanned",value:_}),e[45]=_,e[46]=A):A=e[46];let I;e[47]!==T||e[48]!==P||e[49]!==A?(I=r.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[T,P,A]}),e[47]=T,e[48]=P,e[49]=A,e[50]=I):I=e[50];let R;e[51]===Symbol.for("react.memo_cache_sentinel")?(R=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]=R):R=e[51];let $;if(e[52]!==u.costUsd||e[53]!==u.models){let z;e[55]!==u.costUsd?(z=O=>{var H;return r.jsxs("tr",{className:"border-b border-border/50",children:[r.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(H=ir.find(W=>W.key===O.provider))==null?void 0:H.color}}),O.model]})}),r.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:O.unpriced?"—":cn(O.costUsd)}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:u.costUsd>0&&!O.unpriced?`${(O.costUsd/u.costUsd*100).toFixed(1)}%`:"—"}),r.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:at(O.tokens)})]},`${O.provider}:${O.model}`)},e[55]=u.costUsd,e[56]=z):z=e[56],$=u.models.map(z),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:[R,r.jsx("tbody",{children:$})]}),e[57]=$,e[58]=M):M=e[58];const L=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let D;e[59]!==L?(D=r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",L," ","— not what a subscription bills."]}),e[59]=L,e[60]=D):D=e[60];let F;return e[61]!==N||e[62]!==C||e[63]!==I||e[64]!==M||e[65]!==D||e[66]!==m?(F=r.jsxs("div",{className:m,children:[N,C,I,M,D]}),e[61]=N,e[62]=C,e[63]=I,e[64]=M,e[65]=D,e[66]=m,e[67]=F):F=e[67],F}function pI(n){const e=B.c(15),{open:t,onOpenChange:s}=n,[o,i]=y.useState(30);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{children:[r.jsx(ns,{children:"API usage"}),r.jsx(ss,{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=aI.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(_s,{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(mI,{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(ts,{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(es,{open:t,onOpenChange:s,children:u}),e[11]=s,e[12]=t,e[13]=u,e[14]=f):f=e[14],f}const hI=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,gI=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,Zl=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,xI=[new RegExp(`${Zl}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${Zl}'([^']*)'`),new RegExp(`${Zl}(\\S+)`)];function bI(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 vI(n){return bI(n).find(e=>gI.test(e))??null}function yI(n){for(const e of xI){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function wI(){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=hI.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:yI(o),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(o),toolCallId:i,timestamp:a})}}}function jI(n){const e=wI();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const o=vI(s.input);o&&e.record(s.result,o,s.id,s.timestamp)}return e.pullRequests}function SI(...n){const e=new Map;for(const t of n)for(const s of t??[])e.has(s.url)||e.set(s.url,s);return[...e.values()].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}const to="flex h-8 items-center px-0.5",NI=y.memo(function(e){var Se;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,v=o===void 0?s:o,{config:w}=Ut(),{networkUrl:b,defaultAgentKind:j}=w,{session:S,sessionSource:N,isLive:C}=st(),k=yu(),T=jn("viewUsage"),[E,P]=y.useState(!1),[_,A]=y.useState(!1),[I,R]=Xn(),$=S==null?void 0:S.turns;let M;t[0]!==(k==null?void 0:k.sessions)||t[1]!==(S==null?void 0:S.sessionId)?(M=(Se=k==null?void 0:k.sessions.find(Re=>Re.sessionId===(S==null?void 0:S.sessionId)))==null?void 0:Se.pullRequests,t[0]=k==null?void 0:k.sessions,t[1]=S==null?void 0:S.sessionId,t[2]=M):M=t[2];const L=M;let D;t[3]!==L||t[4]!==$?(D=SI(jI($??[]),L),t[3]=L,t[4]=$,t[5]=D):D=t[5];const F=D;let z;t[6]!==j||t[7]!==N?(z=N?N.agentKind??At(N.dirName):j,t[6]=j,t[7]=N,t[8]=z):z=t[8];const O=z;let H;t[9]!==N?(H=N?ws(N.fileName)!==null:!1,t[9]=N,t[10]=H):H=t[10];const W=H;let U;t[11]!==R||t[12]!==S||t[13]!==(N==null?void 0:N.agentKind)||t[14]!==(N==null?void 0:N.dirName)?(U=function(){if(!S)return;const Ne=(N==null?void 0:N.agentKind)??At((N==null?void 0:N.dirName)??null);R(J1(Ne,S.sessionId,S.cwd))},t[11]=R,t[12]=S,t[13]=N==null?void 0:N.agentKind,t[14]=N==null?void 0:N.dirName,t[15]=U):U=t[15];const V=U;let q;t[16]!==b?(q=function(){b&&Na(b).then(CI)},t[16]=b,t[17]=q):q=t[17];const X=q;let G,Y;t[18]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),G=r.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-gradient-to-b from-background from-50% to-transparent"}),t[18]=G,t[19]=Y):(G=t[18],Y=t[19]);const J=!v&&"window-inset-start";let Q;t[20]!==J?(Q=K("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",J),t[20]=J,t[21]=Q):Q=t[21];let Z;t[22]!==h||t[23]!==s||t[24]!==i?(Z=!s&&r.jsx(kI,{icon:hw,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]!==W||t[27]!==f||t[28]!==S?(te=S&&W&&f&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:f,className:K(_n,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[r.jsx(Ve,{className:"size-3 rotate-180"}),"Main"]}),t[26]=W,t[27]=f,t[28]=S,t[29]=te):te=t[29];let ne;t[30]!==I||t[31]!==l||t[32]!==V||t[33]!==C||t[34]!==d||t[35]!==c||t[36]!==u||t[37]!==F||t[38]!==S||t[39]!==N?(ne=S&&r.jsx(k$,{session:S,sessionSource:N,isLive:C,pullRequests:F,copied:I,creatingSession:l,onCopyResume:V,onNewSession:c,onDuplicateSession:d,onOpenTerminal:u}),t[30]=I,t[31]=l,t[32]=V,t[33]=C,t[34]=d,t[35]=c,t[36]=u,t[37]=F,t[38]=S,t[39]=N,t[40]=ne):ne=t[40];let oe;t[41]!==m||t[42]!==S||t[43]!==p?(oe=S&&m&&(p??0)>0&&r.jsxs(ee,{variant:"ghost",size:"xs",className:K(_n,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[r.jsx(jd,{className:"size-3"}),"Workflows",r.jsx(Ie,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[41]=m,t[42]=S,t[43]=p,t[44]=oe):oe=t[44];let re;t[45]!==Q||t[46]!==Z||t[47]!==te||t[48]!==ne||t[49]!==oe?(re=r.jsxs("div",{className:Q,children:[Z,te,ne,oe]}),t[45]=Q,t[46]=Z,t[47]=te,t[48]=ne,t[49]=oe,t[50]=re):re=t[50];let ie,se,de;t[51]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx("div",{className:K(_n,to,"empty:hidden"),children:r.jsx(XP,{})}),se=r.jsx("div",{className:K(_n,to,"empty:hidden"),children:r.jsx(o$,{})}),de=K(_n,to,"empty:hidden"),t[51]=ie,t[52]=se,t[53]=de):(ie=t[51],se=t[52],de=t[53]);let ce;t[54]!==O?(ce=r.jsx("div",{className:de,children:r.jsx(Y$,{agentKind:O})}),t[54]=O,t[55]=ce):ce=t[55];let ue;t[56]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx("div",{className:K(_n,to,"empty:hidden"),children:r.jsx(Lu,{})}),t[56]=ue):ue=t[56];let me;t[57]!==O||t[58]!==S?(me=S&&Bt(O).sharing&&et("share")&&r.jsx("div",{className:K(_n,to),children:r.jsx(L$,{sessionId:S.sessionId})}),t[57]=O,t[58]=S,t[59]=me):me=t[59];let fe;t[60]===Symbol.for("react.memo_cache_sentinel")?(fe=K(_n,to),t[60]=fe):fe=t[60];let ae;t[61]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(Po,{render:r.jsx(ee,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:r.jsx(O1,{"data-icon":"inline-start"})}),t[61]=ae):ae=t[61];let ve;t[62]!==T?(ve=T&&r.jsxs(zt,{onClick:()=>P(!0),children:[r.jsx(L1,{}),"Usage & cost…"]}),t[62]=T,t[63]=ve):ve=t[63];let ge;t[64]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsxs(zt,{onClick:()=>A(!0),children:[r.jsx(D1,{}),"Server monitor…"]}),t[64]=ge):ge=t[64];let ye;t[65]!==X||t[66]!==b?(ye=b&&r.jsxs(zt,{onClick:X,children:[r.jsx(Yi,{className:"text-success"}),"Copy network URL",r.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:b})]}),t[65]=X,t[66]=b,t[67]=ye):ye=t[67];let Pe;t[68]!==ve||t[69]!==ye?(Pe=r.jsxs(Gn,{children:[ve,ge,ye]}),t[68]=ve,t[69]=ye,t[70]=Pe):Pe=t[70];let De;t[71]===Symbol.for("react.memo_cache_sentinel")?(De=r.jsx(Qi,{}),t[71]=De):De=t[71];let Te;t[72]===Symbol.for("react.memo_cache_sentinel")?(Te=r.jsx(gw,{}),t[72]=Te):Te=t[72];let Ae;t[73]!==x?(Ae=r.jsx(Gn,{children:r.jsxs(zt,{onClick:x,children:[Te,"Settings"]})}),t[73]=x,t[74]=Ae):Ae=t[74];let pe;t[75]!==a||t[76]!==g?(pe=et("killAny")&&r.jsxs(r.Fragment,{children:[r.jsx(Qi,{}),r.jsx(Gn,{children:r.jsxs(zt,{variant:"destructive",onClick:g,disabled:a,children:[r.jsx(pw,{}),a?"Stopping processes…":"Stop all agent processes"]})})]}),t[75]=a,t[76]=g,t[77]=pe):pe=t[77];let xe;t[78]!==Pe||t[79]!==Ae||t[80]!==pe?(xe=r.jsx("div",{className:fe,children:r.jsxs(Ao,{children:[ae,r.jsxs($o,{align:"end",sideOffset:6,className:"w-64",children:[Pe,De,Ae,pe]})]})}),t[78]=Pe,t[79]=Ae,t[80]=pe,t[81]=xe):xe=t[81];let ke;t[82]!==ce||t[83]!==me||t[84]!==xe?(ke=r.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ie,se,ce,ue,me,xe]}),t[82]=ce,t[83]=me,t[84]=xe,t[85]=ke):ke=t[85];let $e;t[86]!==re||t[87]!==ke?($e=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,ke]}),t[86]=re,t[87]=ke,t[88]=$e):$e=t[88];let we;t[89]!==T||t[90]!==E?(we=T&&r.jsx(pI,{open:E,onOpenChange:P}),t[89]=T,t[90]=E,t[91]=we):we=t[91];let be;t[92]!==_?(be=r.jsx(h$,{open:_,onOpenChange:A}),t[92]=_,t[93]=be):be=t[93];let Le;return t[94]!==$e||t[95]!==we||t[96]!==be?(Le=r.jsxs(r.Fragment,{children:[Y,G,$e,we,be]}),t[94]=$e,t[95]=we,t[96]=be,t[97]=Le):Le=t[97],Le});function kI(n){const e=B.c(14),{icon:t,label:s,onClick:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=K(_n,"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(_t,{render:a,children:l}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==s?(d=r.jsx(Tt,{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(Ct,{children:[c,d]}),e[11]=c,e[12]=d,e[13]=u):u=e[13],u}function CI(n){n&&qn.success("Copied network URL")}const _I=y.memo(function(e){const t=B.c(13),{onToggleSidebar:s,onGoHome:o,onOpenCommandPalette:i,sidebarShortcut:a,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let d;t[1]!==o?(d=r.jsx(kl,{icon:gs,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(kl,{icon:tn,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(kl,{icon:xw,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 TI(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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(yw,{"data-slot":"resizable-panel-group",className:o,...s}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Nh(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(vw,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function EI(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=K("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(bw,{"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 db=y.createContext(null);function AI(n){const e=B.c(3),{value:t,children:s}=n;let o;return e[0]!==s||e[1]!==t?(o=r.jsx(db.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=o):o=e[2],o}function Fu(){const n=y.useContext(db);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function ub(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=K("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(_t,{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(Tt,{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(Ct,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function fb(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function PI(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=fb(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($I),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 v;e[15]!==o||e[16]!==s||e[17]!==i?(v=w=>{var N;const b=w.id===o,j=(N=w.badge)==null?void 0:N.call(w,s),S=w.indicator;return r.jsx(ub,{title:w.title,icon:w.icon,active:b,onClick:()=>i(w.id),children:S?r.jsx(S,{context:s,active:b}):j!=null&&r.jsx(Ie,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:j})},w.id)},e[15]=o,e[16]=s,e[17]=i,e[18]=v):v=e[18],p=x.map(v)}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 $I(n){return r.jsx(ub,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function II(n){const e=B.c(18),{panels:t,context:s,activePanelId:o,onClosePanel:i}=n;let a;e[0]!==o?(a=()=>new Set([o]),e[0]=o,e[1]=a):a=e[1];const[l,c]=y.useState(a);let d,u;e[2]!==o?(d=()=>{c(p=>{if(p.has(o))return p;const h=new Set(p);return h.add(o),h})},u=[o],e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),y.useEffect(d,u);let f;if(e[5]!==o||e[6]!==s||e[7]!==i||e[8]!==t||e[9]!==l){let p;e[11]!==o||e[12]!==s||e[13]!==i||e[14]!==l?(p=h=>{const g=h.id===o;if(!g&&(!h.keepAlive||!l.has(h.id)))return null;const x=h.component;return r.jsx("div",{className:K("absolute inset-0 min-h-0",!g&&"hidden"),"aria-hidden":!g,children:r.jsx(x,{context:s,active:g,closePanel:i})},h.id)},e[11]=o,e[12]=s,e[13]=i,e[14]=l,e[15]=p):p=e[15],f=t.map(p),e[5]=o,e[6]=s,e[7]=i,e[8]=t,e[9]=l,e[10]=f}else f=e[10];let m;return e[16]!==f?(m=r.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-background",children:f}),e[16]=f,e[17]=m):m=e[17],m}function RI(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 MI(n){const e=B.c(23),{children:t,panels:s,context:o,activePanel:i,services:a,onClosePanel:l,onTogglePanel:c,actions:d}=n;let u;e[0]!==i?(u=i?RI(i.defaultSize):"100%",e[0]=i,e[1]=u):u=e[1];let f;e[2]!==t||e[3]!==u?(f=r.jsx(Nh,{defaultSize:u,minSize:"320px",children:t}),e[2]=t,e[3]=u,e[4]=f):f=e[4];let m;e[5]!==i||e[6]!==o||e[7]!==l||e[8]!==s||e[9]!==a?(m=i&&r.jsxs(r.Fragment,{children:[r.jsx(EI,{withHandle:!0}),r.jsx(Nh,{defaultSize:i.defaultSize??"36%",minSize:i.minSize??"300px",maxSize:i.maxSize??"70%",children:r.jsx(AI,{value:a,children:r.jsx(II,{panels:s,context:o,activePanelId:i.id,onClosePanel:l})})})]}),e[5]=i,e[6]=o,e[7]=l,e[8]=s,e[9]=a,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=r.jsxs(TI,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];const h=(i==null?void 0:i.id)??null;let g;e[14]!==d||e[15]!==o||e[16]!==c||e[17]!==s||e[18]!==h?(g=r.jsx(PI,{panels:s,context:o,activePanelId:h,onTogglePanel:c,actions:d}),e[14]=d,e[15]=o,e[16]=c,e[17]=s,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=r.jsxs(r.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}const ni={data:null,error:null,loading:!1,refreshing:!1},OI=8e3,LI=new Set(["clickup_not_configured","clickup_auth_failed","project_unlinked"]),ol="*",Bu={endpoint:()=>"/api/clickup/status",pollIntervalMs:5*6e4,fallbackError:"Unable to reach ClickUp",stores:new Map},mb={endpoint:()=>"/api/clickup/tasks/mine",pollIntervalMs:6e4,fallbackError:"Unable to load your ClickUp tasks",stores:new Map},fa={endpoint:n=>`/api/clickup/tasks/list?cwd=${encodeURIComponent(n)}`,pollIntervalMs:6e4,fallbackError:"Unable to load the linked ClickUp list",stores:new Map};function ma(n,e){let t=n.stores.get(e);return t||(t={snapshot:ni,listeners:new Set,request:null,fetchedAt:0},n.stores.set(e,t)),t}function ar(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function pb(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 lr(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 ho(n,e,t=!1){const s=ma(n,e);if(s.request)return s.request;if(!(!t&&s.snapshot.error&&LI.has(s.snapshot.error.code))&&!(!t&&s.fetchedAt>0&&Date.now()-s.fetchedAt<OI))return(t||s.snapshot.data===null)&&ar(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=_e(n.endpoint(e)).then(async o=>{if(!o.ok)throw await pb(o);const i=await o.json();s.fetchedAt=Date.now(),ar(s,{data:i,error:null,loading:!1,refreshing:!1})}).catch(o=>{ar(s,{...s.snapshot,error:lr(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function Uu(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==n||s[1]!==o?(i=p=>{if(!o)return zI;const h=ma(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?ma(n,o).snapshot:ni,s[3]=n,s[4]=o,s[5]=a):a=s[5];const l=y.useSyncExternalStore(i,a,DI);let c,d;s[6]!==t||s[7]!==n||s[8]!==o?(c=()=>{if(!t||!o)return;ho(n,o);const p=window.setInterval(()=>{ho(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]),y.useEffect(c,d);let u;s[11]!==n||s[12]!==o?(u=()=>o?ho(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 DI(){return ni}function zI(){}function hb(n){return Uu(Bu,ol,n)}function gb(n){return Uu(mb,ol,n)}function FI(n,e){return Uu(fa,n,e)}async function si(n,e){const t=await _e(n,e);if(!t.ok)throw await pb(t);return t.json()}function xb(n,e){return{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}}function bb(){for(const n of[mb,fa])for(const e of n.stores.values())e.fetchedAt=0,ar(e,ni)}async function BI(n){await si("/api/clickup/token",xb("POST",{token:n})),bb(),await ho(Bu,ol,!0)}async function UI(){await si("/api/clickup/token",{method:"DELETE"}),bb(),await ho(Bu,ol,!0)}async function vb(n,e){await si("/api/clickup/project-list",xb("PUT",{cwd:n,listId:e}));const t=ma(fa,n);t.fetchedAt=0,ar(t,ni),e!==null&&await ho(fa,n,!0)}function WI(){return si("/api/clickup/spaces")}function HI(n){return si(`/api/clickup/lists?spaceId=${encodeURIComponent(n)}`)}const kh={status:null,due:"all",priority:null,query:""},Ch={urgent:0,high:1,normal:2,low:3},_h=1440*60*1e3;function Mo(n){return n.status.type==="closed"}function yb(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Co(n,e){return n.dueAt!==null&&!Mo(n)&&n.dueAt<yb(e)}function wb(n,e,t){if(e==="all")return!0;if(e==="none")return n.dueAt===null;if(n.dueAt===null)return!1;const s=yb(t);switch(e){case"overdue":return Co(n,t);case"today":return n.dueAt>=s&&n.dueAt<s+_h;case"week":return n.dueAt>=s&&n.dueAt<s+7*_h}}function qI(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 KI(n,e,t){return n.filter(s=>(e.status===null||s.status.name===e.status)&&(e.priority===null||s.priority===e.priority)&&wb(s,e.due,t)&&qI(s,e.query))}function VI(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 GI(n,e){return[...n].sort((t,s)=>{const o=Number(Co(s,e))-Number(Co(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?Ch[t.priority]:4)-(s.priority?Ch[s.priority]:4);return i!==0?i:s.updatedAt-t.updatedAt})}function Wu(n,e){return n?`${n} › ${e}`:e}function YI(n){const e=n.customId??n.id,t=n.description.trim();return[`Work on ClickUp task ${e}: ${n.name}`,n.url,...t?["",t]:[]].join(`
|
|
125
|
+
`)}function XI(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 JI={urgent:"text-destructive",high:"text-warning",normal:"text-info",low:"text-muted-foreground"},QI=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"});function jb(n){const e=B.c(5),{priority:t}=n;if(!t)return null;const s=JI[t];let o;e[0]!==s?(o=K("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(xo,{className:o,"aria-label":i,role:"img",fill:"currentColor"}),e[2]=o,e[3]=i,e[4]=a):a=e[4],a}function ZI(n){const e=B.c(14),{task:t,now:s}=n;if(t.dueAt===null)return null;const o=Co(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=K("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(jw,{className:"size-3","aria-hidden":!0}),e[6]=f):f=e[6];let m;e[7]!==t.dueAt?(m=QI.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 eR(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(nR).join(", ")}`;o="flex shrink-0 -space-x-1",i=m,a=m,l=f.slice(0,3).map(tR)}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 tR(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 nR(n){return n.username}function sR(n){const e=B.c(130),{task:t,viewer:s,now:o,onPickStatus:i,composePrompt:a}=n,[l,c]=y.useState(!1);let d,u,f,m,p,h,g,x,v,w,b,j,S,N,C,k;if(e[0]!==l||e[1]!==t){const ae=Mo(t);let ve;e[18]!==t.description?(ve=t.description.trim(),e[18]=t.description,e[19]=ve):ve=e[19],f=ve;let ge;e[20]!==t.folderName||e[21]!==t.listName?(ge=Wu(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=ct,C=l,k=c,N="group/task flex items-start gap-1 pr-1",d=Pt,b="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",j=`${t.name}: ${t.status.name}`,S=l,v="flex min-w-0 items-center gap-2",e[25]!==t.priority?(w=r.jsx(jb,{priority:t.priority}),e[25]=t.priority,e[26]=w):w=e[26],p=K("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",ae&&"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]=v,e[11]=w,e[12]=b,e[13]=j,e[14]=S,e[15]=N,e[16]=C,e[17]=k}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],v=e[10],w=e[11],b=e[12],j=e[13],S=e[14],N=e[15],C=e[16],k=e[17];let T;e[27]!==p||e[28]!==t.name?(T=r.jsx("span",{className:p,children:t.name}),e[27]=p,e[28]=t.name,e[29]=T):T=e[29];let E;e[30]!==t.customId?(E=t.customId&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:t.customId}),e[30]=t.customId,e[31]=E):E=e[31];let P;e[32]!==T||e[33]!==E||e[34]!==v||e[35]!==w?(P=r.jsxs("span",{className:v,children:[w,T,E]}),e[32]=T,e[33]=E,e[34]=v,e[35]=w,e[36]=P):P=e[36];let _;e[37]!==t.status.color?(_={color:t.status.color},e[37]=t.status.color,e[38]=_):_=e[38];let A;e[39]!==_||e[40]!==t.status.name?(A=r.jsx("span",{className:"shrink-0 rounded-sm px-1 text-[10px] uppercase tracking-wide",style:_,children:t.status.name}),e[39]=_,e[40]=t.status.name,e[41]=A):A=e[41];let I;e[42]!==m?(I=r.jsx("span",{className:"truncate",children:m}),e[42]=m,e[43]=I):I=e[43];let R;e[44]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx("span",{className:"shrink-0",children:"·"}),e[44]=R):R=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 L;e[49]!==o||e[50]!==t.updatedAt?(L=el(new Date(t.updatedAt).toISOString(),o),e[49]=o,e[50]=t.updatedAt,e[51]=L):L=e[51];let D;e[52]!==$||e[53]!==M||e[54]!==L?(D=r.jsx("time",{className:"shrink-0",dateTime:$,title:M,children:L}),e[52]=$,e[53]=M,e[54]=L,e[55]=D):D=e[55];let F;e[56]!==A||e[57]!==I||e[58]!==D?(F=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[A,I,R,D]}),e[56]=A,e[57]=I,e[58]=D,e[59]=F):F=e[59];let z;e[60]!==d||e[61]!==P||e[62]!==F||e[63]!==b||e[64]!==j||e[65]!==S?(z=r.jsxs(d,{className:b,"aria-label":j,"aria-expanded":S,children:[P,F]}),e[60]=d,e[61]=P,e[62]=F,e[63]=b,e[64]=j,e[65]=S,e[66]=z):z=e[66];let O;e[67]!==o||e[68]!==t?(O=r.jsx(ZI,{task:t,now:o}),e[67]=o,e[68]=t,e[69]=O):O=e[69];let H;e[70]!==t.assignees||e[71]!==s?(H=r.jsx(eR,{assignees:t.assignees,viewer:s}),e[70]=t.assignees,e[71]=s,e[72]=H):H=e[72];const W=`Open ${t.customId??t.name} in ClickUp`;let U;e[73]!==t.url?(U=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[73]=t.url,e[74]=U):U=e[74];let V;e[75]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Vt,{}),e[75]=V):V=e[75];let q;e[76]!==W||e[77]!==U?(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":W,onClick:U,children:V}),e[76]=W,e[77]=U,e[78]=q):q=e[78];let X;e[79]!==O||e[80]!==H||e[81]!==q?(X=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1.5",children:[O,H,q]}),e[79]=O,e[80]=H,e[81]=q,e[82]=X):X=e[82];let G;e[83]!==z||e[84]!==X||e[85]!==N?(G=r.jsxs("div",{className:N,children:[z,X]}),e[83]=z,e[84]=X,e[85]=N,e[86]=G):G=e[86];let Y;e[87]!==f?(Y=f?r.jsx(Ou,{body:f}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[87]=f,e[88]=Y):Y=e[88];let J;e[89]!==i||e[90]!==t.status.name?(J=()=>i(t.status.name),e[89]=i,e[90]=t.status.name,e[91]=J):J=e[91];const Q=`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]!==J||e[95]!==Q||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:J,"aria-label":Q,children:[Z,t.status.name]})}),e[94]=J,e[95]=Q,e[96]=Z,e[97]=t.status.name,e[98]=te):te=e[98];let ne;e[99]!==t.tags?(ne=t.tags.map(oR),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(YI(t)),children:[r.jsx(z1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[104]=a,e[105]=t,e[106]=re):re=e[106];let ie;e[107]!==t.url?(ie=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[107]=t.url,e[108]=ie):ie=e[108];let se;e[109]===Symbol.for("react.memo_cache_sentinel")?(se=r.jsx(Vt,{"data-icon":"inline-end"}),e[109]=se):se=e[109];let de;e[110]!==ie?(de=r.jsxs(ee,{variant:"outline",size:"xs",render:ie,children:["Open in ClickUp",se]}),e[110]=ie,e[111]=de):de=e[111];let ce;e[112]!==re||e[113]!==de?(ce=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[re,de]}),e[112]=re,e[113]=de,e[114]=ce):ce=e[114];let ue;e[115]!==Y||e[116]!==oe||e[117]!==ce?(ue=r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-1 pr-1",children:[Y,oe,ce]})}),e[115]=Y,e[116]=oe,e[117]=ce,e[118]=ue):ue=e[118];let me;e[119]!==u||e[120]!==G||e[121]!==ue||e[122]!==C||e[123]!==k?(me=r.jsxs(u,{open:C,onOpenChange:k,children:[G,ue]}),e[119]=u,e[120]=G,e[121]=ue,e[122]=C,e[123]=k,e[124]=me):me=e[124];let fe;return e[125]!==h||e[126]!==g||e[127]!==x||e[128]!==me?(fe=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]=fe):fe=e[129],fe}function oR(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 Sb(n){const e=B.c(75),{tasks:t,viewer:s,composePrompt:o,emptyTitle:i,emptyDescription:a,truncated:l}=n,[c,d]=y.useState(kh),u=tl(!1);if(t.length===0){let C;return e[0]!==a||e[1]!==i?(C=r.jsx(nl,{icon:ww,title:i,description:a}),e[0]=a,e[1]=i,e[2]=C):C=e[2],C}let f,m,p,h,g,x,v,w;if(e[3]!==o||e[4]!==c||e[5]!==u||e[6]!==t||e[7]!==s){const C=t.filter(lR),k=VI(C),T=[...new Set(C.flatMap(aR))],E=fe=>C.filter(ae=>wb(ae,fe,u)).length,P=E("overdue"),_=E("today"),A=E("week"),I=KI(t,c,u),R=GI(I.filter(iR),u),$=I.filter(Mo).sort(rR);let M;e[16]===Symbol.for("react.memo_cache_sentinel")?(M=fe=>d(ae=>({...ae,...fe})),e[16]=M):M=e[16];const L=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 F=D;let z;e[22]!==o||e[23]!==u||e[24]!==s?(z=fe=>r.jsx(sR,{task:fe,viewer:s,now:u,onPickStatus:ae=>L({status:ae}),composePrompt:o},fe.id),e[22]=o,e[23]=u,e[24]=s,e[25]=z):z=e[25];const O=z;let H;e[26]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx(tn,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),e[26]=H):H=e[26];let W;e[27]===Symbol.for("react.memo_cache_sentinel")?(W=fe=>L({query:fe.target.value}),e[27]=W):W=e[27];let U;e[28]!==c.query?(U=r.jsx(It,{type:"search",value:c.query,onChange:W,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]=U):U=e[29];let V;e[30]!==F?(V=F&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>d(kh),"aria-label":"Clear filters",children:[r.jsx(Qe,{"data-icon":"inline-start"}),"Clear"]}),e[30]=F,e[31]=V):V=e[31],e[32]!==U||e[33]!==V?(x=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-1.5",children:[H,U,V]}),e[32]=U,e[33]=V,e[34]=x):x=e[34];let q;e[35]===Symbol.for("react.memo_cache_sentinel")?(q=()=>L({due:"all"}),e[35]=q):q=e[35];const X=c.due==="overdue",G=P===0;let Y;e[36]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>L({due:"overdue"}),e[36]=Y):Y=e[36];const J=P>0&&c.due!=="overdue"?"text-destructive":void 0;let Q;e[37]!==P?(Q=r.jsx(bt,{children:P}),e[37]=P,e[38]=Q):Q=e[38];let Z;e[39]!==X||e[40]!==G||e[41]!==J||e[42]!==Q?(Z=r.jsxs(xt,{pressed:X,disabled:G,onClick:Y,className:J,children:["Overdue",Q]}),e[39]=X,e[40]=G,e[41]=J,e[42]=Q,e[43]=Z):Z=e[43];const te=c.due==="today",ne=_===0;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>L({due:"today"}),e[44]=oe):oe=e[44];let re;e[45]!==_?(re=r.jsx(bt,{children:_}),e[45]=_,e[46]=re):re=e[46];let ie;e[47]!==te||e[48]!==ne||e[49]!==re?(ie=r.jsxs(xt,{pressed:te,disabled:ne,onClick:oe,children:["Today",re]}),e[47]=te,e[48]=ne,e[49]=re,e[50]=ie):ie=e[50];const se=c.due==="week",de=A===0;let ce;e[51]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>L({due:"week"}),e[51]=ce):ce=e[51];let ue;e[52]!==A?(ue=r.jsx(bt,{children:A}),e[52]=A,e[53]=ue):ue=e[53];let me;e[54]!==se||e[55]!==de||e[56]!==ue?(me=r.jsxs(xt,{pressed:se,disabled:de,onClick:ce,children:["This week",ue]}),e[54]=se,e[55]=de,e[56]=ue,e[57]=me):me=e[57],v=r.jsxs(_r,{label:"Filter by due date and priority",children:[r.jsxs(xt,{pressed:c.due==="all",onClick:q,children:["All",r.jsx(bt,{children:C.length})]}),Z,ie,me,T.length>0&&r.jsx("span",{className:"mx-1 h-4 w-px shrink-0 bg-border","aria-hidden":!0}),T.map(fe=>r.jsxs(xt,{pressed:c.priority===fe,onClick:()=>L({priority:c.priority===fe?null:fe}),"aria-label":`Only ${fe} priority tasks`,children:[r.jsx(jb,{priority:fe}),fe,r.jsx(bt,{children:C.filter(ae=>ae.priority===fe).length})]},fe))]}),w=k.length>1&&r.jsx(_r,{label:"Filter by status",children:k.map(fe=>r.jsxs(xt,{pressed:c.status===fe.name,onClick:()=>L({status:c.status===fe.name?null:fe.name}),"aria-label":`Only tasks in ${fe.name}`,children:[r.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:fe.color}}),fe.name,r.jsx(bt,{children:C.filter(ae=>ae.status.name===fe.name).length})]},fe.name))}),f=zn,g="min-h-0 flex-1",m="flex flex-col gap-4 px-3 py-3",p=R.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:F?"No tasks match these filters.":"Nothing open here."}):R.map(O),h=$.length>0&&r.jsx(Mu,{count:$.length,children:$.map(O)}),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]=v,e[15]=w}else f=e[8],m=e[9],p=e[10],h=e[11],g=e[12],x=e[13],v=e[14],w=e[15];let b;e[58]!==t.length||e[59]!==l?(b=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]=b):b=e[60];let j;e[61]!==m||e[62]!==p||e[63]!==h||e[64]!==b?(j=r.jsxs("div",{className:m,children:[p,h,b]}),e[61]=m,e[62]=p,e[63]=h,e[64]=b,e[65]=j):j=e[65];let S;e[66]!==f||e[67]!==g||e[68]!==j?(S=r.jsx(f,{className:g,children:j}),e[66]=f,e[67]=g,e[68]=j,e[69]=S):S=e[69];let N;return e[70]!==S||e[71]!==x||e[72]!==v||e[73]!==w?(N=r.jsxs(r.Fragment,{children:[x,v,w,S]}),e[70]=S,e[71]=x,e[72]=v,e[73]=w,e[74]=N):N=e[74],N}function rR(n,e){return(e.closedAt??e.updatedAt)-(n.closedAt??n.updatedAt)}function iR(n){return!Mo(n)}function aR(n){return n.priority?[n.priority]:[]}function lR(n){return!Mo(n)}function cR(n,e){return n?e===null?"Loading lists…":"Choose a list":"Choose a space first"}function dR({projectPath:n,onLinked:e}){const[t,s]=y.useState(""),[o,i]=y.useState(null),[a,l]=y.useState(""),[c,d]=y.useState(null),[u,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(null);y.useEffect(()=>{let w=!1;return WI().then(b=>{w||i(b.spaces)}).catch(b=>{w||g(lr(b,"Unable to load spaces").error)}),()=>{w=!0}},[]),y.useEffect(()=>{if(!a)return;let w=!1;return d(null),f(""),HI(a).then(b=>{w||d(b.lists)}).catch(b=>{w||g(lr(b,"Unable to load lists").error)}),()=>{w=!0}},[a]);async function x(w){if(!w){g("Paste a ClickUp list URL such as https://app.clickup.com/…/v/li/901700000000");return}p(!0),g(null);try{await vb(n,w),e()}catch(b){g(lr(b,"Unable to link that list").error)}finally{p(!1)}}function v(w){w.preventDefault(),x(XI(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:v,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(It,{id:"clickup-list-url",value:t,onChange:w=>s(w.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(Ze,{}):r.jsx(cm,{"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(Sc,{value:a,onValueChange:w=>l(w??""),children:[r.jsx(kc,{className:"h-8 text-xs","aria-label":"Space",disabled:o===null,children:r.jsx(Nc,{placeholder:o===null?"Loading spaces…":"Choose a space"})}),r.jsx(Cc,{children:o==null?void 0:o.map(w=>r.jsx(_c,{value:w.id,children:w.name},w.id))})]}),r.jsxs(Sc,{value:u,onValueChange:w=>f(w??""),children:[r.jsx(kc,{className:"h-8 text-xs","aria-label":"List",disabled:!a||c===null,children:r.jsx(Nc,{placeholder:cR(a,c)})}),r.jsxs(Cc,{children:[c==null?void 0:c.map(w=>r.jsx(_c,{value:w.id,children:Wu(w.folderName,w.name)},w.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(Ze,{}):r.jsx(cm,{"data-icon":"inline-start"}),"Link selected list"]})]}),h&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:h})]})}function uR({data:n,projectPath:e,composePrompt:t,onUnlinked:s}){const[o,i]=y.useState(!1),a=Wu(n.list.folderName,n.list.name);async function l(){i(!0);try{await vb(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(Ze,{}):r.jsx(Sw,{"data-icon":"inline-start"}),"Unlink"]})]}),r.jsx(Sb,{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 fR="https://app.clickup.com/settings/apps";function mR(n){return n==="mine"||n==="project"}function pR(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 Nb(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(hR),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 hR(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(it,{className:"h-3.5 w-3/4"}),r.jsx(it,{className:"h-2.5 w-1/2"})]},n)}function Th(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(Wt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(kt,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=pR(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(Et,{"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(mt,{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(ft,{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(Nb,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function gR({error:n}){const[e,t]=y.useState(""),[s,o]=y.useState(!1),[i,a]=y.useState(null);async function l(c){c.preventDefault(),o(!0),a(null);try{await BI(e.trim()),t("")}catch(d){a(lr(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(It,{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(Ze,{}):r.jsx(yd,{"data-icon":"inline-start"}),"Connect"]}),r.jsxs(ee,{variant:"outline",size:"sm",render:r.jsx("a",{href:fR,target:"_blank",rel:"noopener noreferrer"}),children:["Get a token",r.jsx(Vt,{"data-icon":"inline-end"})]})]})]})}function Eh(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=K("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 xR(){var l;const n=B.c(5),e=hb(!0),{data:t}=gb(((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=>Co(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(Ie,{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 bR(n){var R,$,M,L,D,F,z;const e=B.c(69),{context:t,active:s,closePanel:o}=n,[i,a]=y.useState("mine"),l=t.projectPath,c=hb(s),d=((R=c.data)==null?void 0:R.configured)===!0,u=gb(s&&d),f=FI(l,s&&d&&i==="project"),m=i==="mine"?u:f;let p;if(e[0]!==u.data){const O=Date.now();p=u.data?u.data.tasks.filter(H=>Co(H,O)).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 v;if(c.data===null&&c.error===null){let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(Nb,{label:"Checking ClickUp connection"}),e[2]=O):O=e[2],v=O}else if(d){const O=h||g,H=!!h;let W;e[5]!==O||e[6]!==H?(W=r.jsxs(En,{value:"mine",className:"h-full flex-none rounded-none px-0 text-xs",children:["My tasks",r.jsx(Eh,{value:O,attention:H})]}),e[5]=O,e[6]=H,e[7]=W):W=e[7];const U=!l;let V;e[8]!==f.data?(V=f.data?f.data.tasks.filter(yR).length:null,e[8]=f.data,e[9]=V):V=e[9];let q;e[10]!==V?(q=r.jsx(Eh,{value:V}),e[10]=V,e[11]=q):q=e[11];let X;e[12]!==U||e[13]!==q?(X=r.jsxs(En,{value:"project",className:"h-full flex-none rounded-none px-0 text-xs",disabled:U,children:["This project",q]}),e[12]=U,e[13]=q,e[14]=X):X=e[14];let G;e[15]!==W||e[16]!==X?(G=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(Ma,{variant:"line",className:"h-full gap-3 p-0","aria-label":"ClickUp views",children:[W,X]})}),e[15]=W,e[16]=X,e[17]=G):G=e[17];let Y;e[18]!==u?(Y=()=>{u.refresh()},e[18]=u,e[19]=Y):Y=e[19];let J;e[20]!==t.composePrompt?(J=re=>r.jsx(Sb,{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]=J):J=e[21];let Q;e[22]!==u||e[23]!==Y||e[24]!==J?(Q=r.jsx(An,{value:"mine",className:"flex min-h-0 flex-col",children:r.jsx(Th,{state:u,loadingLabel:"Loading your tasks",onRetry:Y,children:J})}),e[22]=u,e[23]=Y,e[24]=J,e[25]=Q):Q=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(dR,{projectPath:l,onLinked:()=>{f.refresh()}}):r.jsx(Th,{state:f,loadingLabel:"Loading the linked list",onRetry:()=>{f.refresh()},children:re=>r.jsx(uR,{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(An,{value:"project",className:"flex min-h-0 flex-col",children:Z}),e[30]=Z,e[31]=te):te=e[31];let ne;e[32]!==Q||e[33]!==te?(ne=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[Q,te]}),e[32]=Q,e[33]=te,e[34]=ne):ne=e[34];let oe;e[35]!==ne||e[36]!==G?(oe=r.jsxs(r.Fragment,{children:[G,ne]}),e[35]=ne,e[36]=G,e[37]=oe):oe=e[37],v=oe}else{let O;e[3]!==c.error?(O=r.jsx(gR,{error:c.error}),e[3]=c.error,e[4]=O):O=e[4],v=O}let w;e[38]===Symbol.for("react.memo_cache_sentinel")?(w=O=>{mR(O)&&a(O)},e[38]=w):w=e[38];let b;e[39]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"ClickUp"}),e[39]=b):b=e[39];let j;e[40]!==c.data||e[41]!==x?(j=r.jsxs("div",{className:"min-w-0 flex-1",children:[b,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,(L=c.data)!=null&&L.viewer?` · ${c.data.viewer.username}`:""]}),r.jsx(Vt,{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]=j):j=e[42];let S;e[43]!==d||e[44]!==((D=c.data)==null?void 0:D.tokenFromEnv)?(S=d&&!((F=c.data)!=null&&F.tokenFromEnv)&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:vR,"aria-label":"Disconnect ClickUp",title:"Disconnect ClickUp",children:r.jsx(yd,{})}),e[43]=d,e[44]=(z=c.data)==null?void 0:z.tokenFromEnv,e[45]=S):S=e[45];let N;e[46]!==d||e[47]!==m||e[48]!==c?(N=()=>{d?m.refresh():c.refresh()},e[46]=d,e[47]=m,e[48]=c,e[49]=N):N=e[49];const C=m.loading||m.refreshing||c.loading,k=i==="mine"?"Refresh my tasks":"Refresh project tasks";let T;e[50]!==m.refreshing?(T=m.refreshing?r.jsx(Ze,{}):r.jsx(Et,{}),e[50]=m.refreshing,e[51]=T):T=e[51];let E;e[52]!==N||e[53]!==C||e[54]!==k||e[55]!==T?(E=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:N,disabled:C,"aria-label":k,children:T}),e[52]=N,e[53]=C,e[54]=k,e[55]=T,e[56]=E):E=e[56];let P;e[57]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Qe,{}),e[57]=P):P=e[57];let _;e[58]!==o?(_=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close ClickUp",children:P}),e[58]=o,e[59]=_):_=e[59];let A;e[60]!==E||e[61]!==_||e[62]!==j||e[63]!==S?(A=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[j,S,E,_]}),e[60]=E,e[61]=_,e[62]=j,e[63]=S,e[64]=A):A=e[64];let I;return e[65]!==v||e[66]!==A||e[67]!==i?(I=r.jsxs(Ra,{value:i,onValueChange:w,className:"size-full min-h-0 gap-0","aria-label":"ClickUp panel",children:[A,v]}),e[65]=v,e[66]=A,e[67]=i,e[68]=I):I=e[68],I}function vR(){UI()}function yR(n){return!Mo(n)}const wR={id:"clickup",workspacePanels:[{id:"tasks",title:"ClickUp",icon:Nw,component:bR,indicator:xR,order:42,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles}]},Hu={data:null,error:null,loading:!1,refreshing:!1},jR=8e3,SR=1500,NR=10,kR=new Set(["gh_missing","gh_auth_required","no_git_repository","no_github_remote"]),CR={endpoint:n=>`/api/github/actions?cwd=${encodeURIComponent(n)}&limit=20`,pollIntervalMs:1e4,fallbackError:"Unable to load GitHub Actions",stores:new Map},_R={endpoint:n=>`/api/github/pulls?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:3e4,fallbackError:"Unable to load pull requests",stores:new Map},TR={endpoint:n=>`/api/github/issues?cwd=${encodeURIComponent(n)}&limit=30`,pollIntervalMs:6e4,fallbackError:"Unable to load issues",stores:new Map},ER={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 Vc(n,e){let t=n.stores.get(e);return t||(t={snapshot:Hu,listeners:new Set,request:null,fetchedAt:0,settleTimer:null,settleAttempts:0},n.stores.set(e,t)),t}function ec(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function kb(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 Cb(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 qi(n,e,t=!1){const s=Vc(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<jR))return(t||s.snapshot.data===null)&&ec(s,{...s.snapshot,error:t?null:s.snapshot.error,loading:s.snapshot.data===null,refreshing:s.snapshot.data!==null}),s.request=_e(n.endpoint(e)).then(async o=>{var a;if(!o.ok)throw await kb(o);const i=await o.json();s.fetchedAt=Date.now(),ec(s,{data:i,error:null,loading:!1,refreshing:!1}),(a=n.settling)!=null&&a.call(n,i)&&s.settleAttempts<NR?(s.settleAttempts+=1,s.settleTimer=window.setTimeout(()=>{s.settleTimer=null,qi(n,e,!0)},SR)):s.settleAttempts=0}).catch(o=>{ec(s,{...s.snapshot,error:Cb(o,n.fallbackError),loading:!1,refreshing:!1})}).finally(()=>{s.request=null}),s.request}function rl(n,e,t){const s=B.c(17),o=e??"";let i;s[0]!==o||s[1]!==n?(i=p=>{if(!o)return PR;const h=Vc(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?Vc(n,o).snapshot:Hu,s[3]=o,s[4]=n,s[5]=a):a=s[5];const l=y.useSyncExternalStore(i,a,AR);let c,d;s[6]!==t||s[7]!==o||s[8]!==n?(c=()=>{if(!t||!o)return;qi(n,o);const p=window.setInterval(()=>{qi(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]),y.useEffect(c,d);let u;s[11]!==o||s[12]!==n?(u=()=>o?qi(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 AR(){return Hu}function PR(){}function _b(n,e){return rl(CR,n,e)}function Tb(n,e){return rl(_R,n,e)}function $R(n,e){return rl(TR,n,e)}function IR(n,e){return rl(ER,n,e)}async function Eb(n){const e=await _e(n);if(!e.ok)throw await kb(e);return e.json()}function RR(n,e){return Eb(`/api/github/actions/jobs?cwd=${encodeURIComponent(n)}&runId=${e}`)}function MR(n,e){return Eb(`/api/github/pulls/files?cwd=${encodeURIComponent(n)}&number=${e}`)}const OR={data:null,error:null,loading:!1};function Ab(n,e,t){const s=B.c(12),o=t===void 0?!1:t,[i,a]=y.useState(!1),[l,c]=y.useState(OR);let d;s[0]!==e||s[1]!==n||s[2]!==l?(d=async function(){if(!l.loading){c(LR);try{c({data:await n(),error:null,loading:!1})}catch(g){c({data:null,error:Cb(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 LR(n){return{...n,error:null,loading:!0}}function oi(n){return n!=="completed"}function Oo(n){return n==="action_required"||n==="failure"||n==="startup_failure"||n==="timed_out"}function qu(n,e){return oi(n)?"live":Oo(e)?"fail":e==="success"?"pass":"quiet"}const Ah={live:0,fail:1,quiet:2,pass:3};function DR(n){return n.reduce((e,t)=>Ah[t]<Ah[e]?t:e,"pass")}const zR={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success",quiet:"bg-border"};function Ku(n,e){return n==="in_progress"?"Running":oi(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 Vu(n){const e=B.c(14),{status:t,conclusion:s,className:o}=n;let i;e[0]!==s||e[1]!==t?(i=Ku(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=K("size-3.5 shrink-0",o);if(t==="in_progress"){d=r.jsx(Ze,{className:K(f,"text-info"),"aria-label":a});break e}if(oi(t)){d=r.jsx(Ir,{className:K(f,"text-info"),"aria-label":a});break e}if(s==="success"){d=r.jsx(lt,{className:K(f,"text-success"),"aria-label":a});break e}if(Oo(s)){d=r.jsx(Qe,{className:K(f,"text-destructive"),"aria-label":a});break e}if(s==="skipped"||s==="cancelled"){d=r.jsx(kw,{className:K(f,"text-muted-foreground"),"aria-label":a});break e}l=va,c=K(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 FR(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=Oo(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(Vu,{status:t.status,conclusion:t.conclusion,className:"size-3"}),i=K("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:Ru(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 BR(n){const e=B.c(39),{job:t,now:s}=n;let o;e[0]!==t.conclusion||e[1]!==t.status?(o=qu(t.status,t.conclusion),e[0]=t.conclusion,e[1]=t.status,e[2]=o):o=e[2];const i=o,[a,l]=y.useState(i==="fail"||i==="live");let c;e[3]!==t.completedAt||e[4]!==t.startedAt||e[5]!==s?(c=Ru(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=Ku(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=K("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(Ve,{className:h}),e[12]=h,e[13]=g):g=e[13];let x;e[14]!==t.conclusion||e[15]!==t.status?(x=r.jsx(Vu,{status:t.status,conclusion:t.conclusion}),e[14]=t.conclusion,e[15]=t.status,e[16]=x):x=e[16];const v=i==="fail"&&"text-destructive";let w;e[17]!==v?(w=K("min-w-0 flex-1 truncate",v),e[17]=v,e[18]=w):w=e[18];let b;e[19]!==t.name||e[20]!==w?(b=r.jsx("span",{className:w,children:t.name}),e[19]=t.name,e[20]=w,e[21]=b):b=e[21];let j;e[22]!==d?(j=d&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums",children:d}),e[22]=d,e[23]=j):j=e[23];let S;e[24]!==b||e[25]!==j||e[26]!==m||e[27]!==g||e[28]!==x?(S=r.jsxs(Pt,{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,b,j]}),e[24]=b,e[25]=j,e[26]=m,e[27]=g,e[28]=x,e[29]=S):S=e[29];let N;e[30]!==t.steps||e[31]!==s?(N=t.steps.length>0&&r.jsx("ul",{className:"ml-[5px] border-l border-border pl-4",children:t.steps.map(T=>r.jsx(FR,{step:T,now:s},T.number))}),e[30]=t.steps,e[31]=s,e[32]=N):N=e[32];let C;e[33]!==N?(C=r.jsx(dt,{children:N}),e[33]=N,e[34]=C):C=e[34];let k;return e[35]!==a||e[36]!==S||e[37]!==C?(k=r.jsxs(ct,{open:a,onOpenChange:l,children:[S,C]}),e[35]=a,e[36]=S,e[37]=C,e[38]=k):k=e[38],k}function UR(n){var U,V,q;const e=B.c(73),{run:t,projectPath:s,now:o}=n;let i;e[0]!==t.conclusion||e[1]!==t.status?(i=qu(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=()=>RR(s,t.id),e[3]=s,e[4]=t.id,e[5]=c):c=e[5];const{open:d,state:u,onOpenChange:f}=Ab(c,"Unable to load workflow jobs",l);let m;e[6]!==((U=u.data)==null?void 0:U.jobs)?(m=((V=u.data)==null?void 0:V.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=Ru(t.createdAt,h,o),e[8]=o,e[9]=t.createdAt,e[10]=h,e[11]=g):g=e[11];const x=g,v=t.name,w=t.runNumber;let b;e[12]!==t.conclusion||e[13]!==t.status?(b=Ku(t.status,t.conclusion),e[12]=t.conclusion,e[13]=t.status,e[14]=b):b=e[14];const j=`${v} #${w}: ${b}`;let S;e[15]!==t.conclusion||e[16]!==t.status?(S=r.jsx(Vu,{status:t.status,conclusion:t.conclusion}),e[15]=t.conclusion,e[16]=t.status,e[17]=S):S=e[17];const N=a==="quiet"&&"text-muted-foreground";let C;e[18]!==N?(C=K("min-w-0 truncate",N),e[18]=N,e[19]=C):C=e[19];let k;e[20]!==t.name||e[21]!==C?(k=r.jsx("span",{className:C,children:t.name}),e[20]=t.name,e[21]=C,e[22]=k):k=e[22];let T;e[23]!==t.runNumber?(T=r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",t.runNumber]}),e[23]=t.runNumber,e[24]=T):T=e[24];let E;e[25]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("span",{className:"min-w-0 flex-1"}),e[25]=E):E=e[25];let P;e[26]!==t.branch?(P=r.jsx("span",{className:"max-w-24 truncate font-mono text-[10px] text-muted-foreground",children:t.branch}),e[26]=t.branch,e[27]=P):P=e[27];let _;e[28]!==l||e[29]!==x?(_=x&&r.jsx("span",{className:K("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]=_):_=e[30];let A;e[31]!==d||e[32]!==S||e[33]!==k||e[34]!==T||e[35]!==P||e[36]!==_||e[37]!==j?(A=r.jsxs(Pt,{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":j,"aria-expanded":d,children:[S,k,T,E,P,_]}),e[31]=d,e[32]=S,e[33]=k,e[34]=T,e[35]=P,e[36]=_,e[37]=j,e[38]=A):A=e[38];const I=`Open ${t.name} #${t.runNumber} on GitHub`;let R;e[39]!==t.url?(R=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[39]=t.url,e[40]=R):R=e[40];let $;e[41]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(Vt,{}),e[41]=$):$=e[41];let M;e[42]!==I||e[43]!==R?(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":I,onClick:R,children:$}),e[42]=I,e[43]=R,e[44]=M):M=e[44];let L;e[45]!==A||e[46]!==M?(L=r.jsxs("div",{className:"group/run flex items-center gap-1 pr-1",children:[A,M]}),e[45]=A,e[46]=M,e[47]=L):L=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(Ze,{className:"size-3"}),"Loading jobs"]}),e[48]=u.data,e[49]=u.loading,e[50]=D):D=e[50];let F;e[51]!==u.error?(F=u.error&&r.jsx("p",{className:"py-1 text-[11px] text-destructive",children:u.error.error}),e[51]=u.error,e[52]=F):F=e[52];let z;e[53]!==p.length||e[54]!==u.data||e[55]!==u.error||e[56]!==u.loading?(z=!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]=z):z=e[57];let O;if(e[58]!==p||e[59]!==o){let X;e[61]!==o?(X=G=>r.jsx(BR,{job:G,now:o},G.id),e[61]=o,e[62]=X):X=e[62],O=p.map(X),e[58]=p,e[59]=o,e[60]=O}else O=e[60];let H;e[63]!==D||e[64]!==F||e[65]!==z||e[66]!==O?(H=r.jsx(dt,{children:r.jsxs("div",{className:"ml-[7px] border-l border-border py-1 pl-3 pr-1",children:[D,F,z,O]})}),e[63]=D,e[64]=F,e[65]=z,e[66]=O,e[67]=H):H=e[67];let W;return e[68]!==f||e[69]!==d||e[70]!==L||e[71]!==H?(W=r.jsxs(ct,{open:d,onOpenChange:f,children:[L,H]}),e[68]=f,e[69]=d,e[70]=L,e[71]=H,e[72]=W):W=e[72],W}function WR(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=DR(s.runs.map(o=>qu(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 HR(n){const e=B.c(41),{group:t,projectPath:s,now:o}=n,i=t.title,a=zR[t.tone];let l;e[0]!==a?(l=K("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=el(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 v;e[20]!==x||e[21]!==u||e[22]!==f?(v=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]=v):v=e[23];let w;e[24]!==v||e[25]!==d?(w=r.jsxs("header",{className:"mb-1 min-w-0",children:[d,v]}),e[24]=v,e[25]=d,e[26]=w):w=e[26];let b;if(e[27]!==t.runs||e[28]!==o||e[29]!==s){let N;e[31]!==o||e[32]!==s?(N=C=>r.jsx(UR,{run:C,projectPath:s,now:o},C.id),e[31]=o,e[32]=s,e[33]=N):N=e[33],b=t.runs.map(N),e[27]=t.runs,e[28]=o,e[29]=s,e[30]=b}else b=e[30];let j;e[34]!==b?(j=r.jsx("div",{className:"-ml-1 flex flex-col",children:b}),e[34]=b,e[35]=j):j=e[35];let S;return e[36]!==t.title||e[37]!==w||e[38]!==j||e[39]!==c?(S=r.jsxs("article",{className:"relative pl-3","aria-label":i,children:[c,w,j]}),e[36]=t.title,e[37]=w,e[38]=j,e[39]=c,e[40]=S):S=e[40],S}function qR(n,e){return e==="failed"?n.filter(t=>Oo(t.conclusion)):e==="all"?[...n]:n.filter(t=>t.branch===e.branch)}function KR(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 VR(n){const e=B.c(22),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.runs||e[1]!==s?(i=qR(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=WR(a),e[3]=a,e[4]=l):l=e[4];const c=l;let d;e[5]!==c?(d=c.some(GR),e[5]=c,e[6]=d):d=e[6];const u=tl(d);if(t.runs.length===0){let p;return e[7]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(nl,{icon:jd,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=KR(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(HR,{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(zn,{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 GR(n){return n.tone==="live"}function YR(n){const e=B.c(23),{data:t,projectPath:s,focus:o}=n,[i,a]=y.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]),y.useEffect(l,c);const d=t.runs;let u;e[3]!==d?(u=d.filter(XR),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(S=>S.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,v=x&&!m||i==="failed"&&f===0?"all":i;let w;e[8]!==m||e[9]!==h||e[10]!==x||e[11]!==v||e[12]!==f||e[13]!==g||e[14]!==d?(w=d.length>0&&r.jsxs(_r,{label:"Filter runs",children:[r.jsxs(xt,{pressed:v==="all",onClick:()=>a("all"),children:["All",r.jsx(bt,{children:d.length})]}),m&&r.jsxs(xt,{pressed:x&&v!=="all",disabled:h===0,onClick:()=>a({branch:m}),"aria-label":`Only runs on ${m}`,children:[r.jsx($n,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:m}),r.jsx(bt,{children:h})]}),g&&r.jsxs(xt,{pressed:!0,onClick:()=>a("all"),"aria-label":`Only runs on ${g}`,children:[r.jsx($n,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:g}),r.jsx(bt,{children:d.filter(S=>S.branch===g).length}),r.jsx(Qe,{className:"size-3","aria-hidden":!0})]}),r.jsxs(xt,{pressed:v==="failed",disabled:f===0,onClick:()=>a("failed"),children:[r.jsx("span",{className:K(f>0&&"text-destructive"),children:"Failed"})," ",r.jsx(bt,{children:f})]})]}),e[8]=m,e[9]=h,e[10]=x,e[11]=v,e[12]=f,e[13]=g,e[14]=d,e[15]=w):w=e[15];let b;e[16]!==t||e[17]!==v||e[18]!==s?(b=r.jsx(VR,{data:t,filter:v,projectPath:s}),e[16]=t,e[17]=v,e[18]=s,e[19]=b):b=e[19];let j;return e[20]!==w||e[21]!==b?(j=r.jsxs(r.Fragment,{children:[w,b]}),e[20]=w,e[21]=b,e[22]=j):j=e[22],j}function XR(n){return Oo(n.conclusion)}const Pb={open:"Open",completed:"Completed",not_planned:"Not planned"},JR={open:"bg-success",completed:"bg-info",not_planned:"bg-border"};function QR(n){const e=B.c(9),{state:t}=n,s=Pb[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=K("size-3.5 shrink-0","text-success"),e[0]=a):a=e[0];let l;return e[1]!==s?(l=r.jsx(xd,{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=K("size-3.5 shrink-0","text-info"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(On,{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=K("size-3.5 shrink-0","text-muted-foreground"),e[6]=o):o=e[6];let i;return e[7]!==s?(i=r.jsx(_w,{className:o,"aria-label":s}),e[7]=s,e[8]=i):i=e[8],i}function $b(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 ZR(n){const e=n.body.trim();return[`Work on GitHub issue #${n.number}: ${n.title}`,n.url,...e?["",e]:[]].join(`
|
|
126
|
+
`)}function eM(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(F1,{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(Sd,{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 tM(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(B1,{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=K("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 nM(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(eM,{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(tM,{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(sb,{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 sM(n){const e=B.c(86),{issue:t,viewer:s,now:o,onPickLabel:i,onShowPull:a,composePrompt:l}=n,[c,d]=y.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=JR[t.state];let g;e[2]!==h?(g=K("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 v=`${t.title} #${t.number}: ${Pb[t.state]}`;let w;e[6]!==t.state?(w=r.jsx(QR,{state:t.state}),e[6]=t.state,e[7]=w):w=e[7];const b=t.state!=="open"&&"text-muted-foreground";let j;e[8]!==b?(j=K("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",b),e[8]=b,e[9]=j):j=e[9];let S;e[10]!==t.title||e[11]!==j?(S=r.jsx("span",{className:j,children:t.title}),e[10]=t.title,e[11]=j,e[12]=S):S=e[12];let N;e[13]!==t.number?(N=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[13]=t.number,e[14]=N):N=e[14];let C;e[15]!==S||e[16]!==N||e[17]!==w?(C=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[w,S,N]}),e[15]=S,e[16]=N,e[17]=w,e[18]=C):C=e[18];let k;e[19]!==t.author?(k=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[19]=t.author,e[20]=k):k=e[20];let T;e[21]!==t.labels?(T=t.labels.length>0&&r.jsxs("span",{className:"flex min-w-0 items-center gap-1 truncate",children:[t.labels.slice(0,3).map(oM),t.labels.length>3&&r.jsxs("span",{children:["+",t.labels.length-3]})]}),e[21]=t.labels,e[22]=T):T=e[22];let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("span",{className:"shrink-0",children:"·"}),e[23]=E):E=e[23];let P;e[24]!==u?(P=new Date(u).toLocaleString(),e[24]=u,e[25]=P):P=e[25];let _;e[26]!==u||e[27]!==o?(_=el(u,o),e[26]=u,e[27]=o,e[28]=_):_=e[28];let A;e[29]!==u||e[30]!==P||e[31]!==_?(A=r.jsx("time",{className:"shrink-0",dateTime:u,title:P,children:_}),e[29]=u,e[30]=P,e[31]=_,e[32]=A):A=e[32];let I;e[33]!==k||e[34]!==T||e[35]!==A?(I=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[k,T,E,A]}),e[33]=k,e[34]=T,e[35]=A,e[36]=I):I=e[36];let R;e[37]!==c||e[38]!==C||e[39]!==I||e[40]!==v?(R=r.jsxs(Pt,{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":c,children:[C,I]}),e[37]=c,e[38]=C,e[39]=I,e[40]=v,e[41]=R):R=e[41];let $;e[42]!==t||e[43]!==a||e[44]!==s?($=r.jsx(nM,{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 L;e[46]!==t.url?(L=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[46]=t.url,e[47]=L):L=e[47];let D;e[48]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(Vt,{}),e[48]=D):D=e[48];let F;e[49]!==M||e[50]!==L?(F=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:L,children:D}),e[49]=M,e[50]=L,e[51]=F):F=e[51];let z;e[52]!==$||e[53]!==F?(z=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[$,F]}),e[52]=$,e[53]=F,e[54]=z):z=e[54];let O;e[55]!==R||e[56]!==z?(O=r.jsxs("div",{className:"group/issue flex items-start gap-1 pr-1",children:[R,z]}),e[55]=R,e[56]=z,e[57]=O):O=e[57];let H;e[58]!==m?(H=m?r.jsx(Ou,{body:m}):r.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"No description."}),e[58]=m,e[59]=H):H=e[59];let W;e[60]!==t.labels||e[61]!==i?(W=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($b,{label:Z}),Z.name]})},Z.name))}),e[60]=t.labels,e[61]=i,e[62]=W):W=e[62];let U;e[63]!==l||e[64]!==t?(U=l&&r.jsxs(ee,{type:"button",size:"xs",onClick:()=>l(ZR(t)),children:[r.jsx(z1,{"data-icon":"inline-start"}),"Add to prompt"]}),e[63]=l,e[64]=t,e[65]=U):U=e[65];let V;e[66]!==t.url?(V=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[66]=t.url,e[67]=V):V=e[67];let q;e[68]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(Vt,{"data-icon":"inline-end"}),e[68]=q):q=e[68];let X;e[69]!==V?(X=r.jsxs(ee,{variant:"outline",size:"xs",render:V,children:["Open issue on GitHub",q]}),e[69]=V,e[70]=X):X=e[70];let G;e[71]!==U||e[72]!==X?(G=r.jsxs("div",{className:"flex flex-wrap gap-2",children:[U,X]}),e[71]=U,e[72]=X,e[73]=G):G=e[73];let Y;e[74]!==H||e[75]!==W||e[76]!==G?(Y=r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[H,W,G]})}),e[74]=H,e[75]=W,e[76]=G,e[77]=Y):Y=e[77];let J;e[78]!==c||e[79]!==O||e[80]!==Y?(J=r.jsxs(ct,{open:c,onOpenChange:d,children:[O,Y]}),e[78]=c,e[79]=O,e[80]=Y,e[81]=J):J=e[81];let Q;return e[82]!==t.title||e[83]!==J||e[84]!==x?(Q=r.jsxs("article",{className:"relative pl-3","aria-label":p,children:[x,J]}),e[82]=t.title,e[83]=J,e[84]=x,e[85]=Q):Q=e[85],Q}function oM(n){return r.jsxs("span",{className:"flex items-center gap-1 truncate",children:[r.jsx($b,{label:n}),r.jsx("span",{className:"truncate",children:n.name})]},n.name)}function Ph(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 rM(n){const e=B.c(75),{data:t,composePrompt:s,onShowPulls:o}=n,[i,a]=y.useState("all"),[l,c]=y.useState(null),d=tl(!1),u=t.viewer;let f;e[0]!==t.issues||e[1]!==u?(f=R=>t.issues.filter($=>Ph($,R,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 v;e[7]!==m?(v=m("unassigned"),e[7]=m,e[8]=v):v=e[8];const w=v,b=i==="assigned"&&h===0||i==="opened"&&x===0||i==="unassigned"&&w===0?"all":i,j=t.issues;let S,N,C,k,T,E,P;if(e[9]!==h||e[10]!==s||e[11]!==t.issues||e[12]!==b||e[13]!==l||e[14]!==d||e[15]!==o||e[16]!==x||e[17]!==w||e[18]!==u){C=Symbol.for("react.early_return_sentinel");e:{let R;e[26]!==b||e[27]!==l||e[28]!==u?(R=te=>Ph(te,b,u)&&(l===null||te.labels.some(ne=>ne.name===l)),e[26]=b,e[27]=l,e[28]=u,e[29]=R):R=e[29];const $=j.filter(R),M=$.filter(aM),L=$.filter(iM);if(t.issues.length===0){let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx(nl,{icon:xd,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(sM,{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 F=D,z=b==="all";let O;e[36]===Symbol.for("react.memo_cache_sentinel")?(O=()=>a("all"),e[36]=O):O=e[36];let H;e[37]!==t.issues.length?(H=r.jsx(bt,{children:t.issues.length}),e[37]=t.issues.length,e[38]=H):H=e[38];let W;e[39]!==z||e[40]!==H?(W=r.jsxs(xt,{pressed:z,onClick:O,children:["All",H]}),e[39]=z,e[40]=H,e[41]=W):W=e[41];let U;e[42]!==h||e[43]!==b||e[44]!==u?(U=u&&r.jsxs(xt,{pressed:b==="assigned",disabled:h===0,onClick:()=>a("assigned"),"aria-label":"Only issues assigned to you",children:[r.jsx(F1,{className:"size-3"}),"Mine",r.jsx(bt,{children:h})]}),e[42]=h,e[43]=b,e[44]=u,e[45]=U):U=e[45];let V;e[46]!==b||e[47]!==x||e[48]!==u?(V=u&&r.jsxs(xt,{pressed:b==="opened",disabled:x===0,onClick:()=>a("opened"),"aria-label":"Only issues you opened",children:[r.jsx(Sd,{className:"size-3"}),"Opened",r.jsx(bt,{children:x})]}),e[46]=b,e[47]=x,e[48]=u,e[49]=V):V=e[49];const q=b==="unassigned",X=w===0;let G;e[50]===Symbol.for("react.memo_cache_sentinel")?(G=()=>a("unassigned"),e[50]=G):G=e[50];let Y;e[51]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx(Cw,{className:"size-3"}),e[51]=Y):Y=e[51];let J;e[52]!==w?(J=r.jsx(bt,{children:w}),e[52]=w,e[53]=J):J=e[53];let Q;e[54]!==q||e[55]!==X||e[56]!==J?(Q=r.jsxs(xt,{pressed:q,disabled:X,onClick:G,"aria-label":"Only unassigned issues",children:[Y,"Unassigned",J]}),e[54]=q,e[55]=X,e[56]=J,e[57]=Q):Q=e[57];const Z=l&&r.jsxs(xt,{pressed:!0,onClick:()=>c(null),"aria-label":`Clear label filter ${l}`,children:[r.jsx("span",{className:"max-w-28 truncate",children:l}),r.jsx(bt,{children:$.length}),r.jsx(Qe,{className:"size-3","aria-hidden":!0})]});e[58]!==W||e[59]!==U||e[60]!==V||e[61]!==Q||e[62]!==Z?(N=r.jsxs(_r,{label:"Filter issues",children:[W,U,V,Q,Z]}),e[58]=W,e[59]=U,e[60]=V,e[61]=Q,e[62]=Z,e[63]=N):N=e[63],S=zn,P="min-h-0 flex-1",k="flex flex-col gap-4 px-3 py-3",T=M.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open here."}):M.map(F),E=L.length>0&&r.jsx(Mu,{count:L.length,children:L.map(F)})}e[9]=h,e[10]=s,e[11]=t.issues,e[12]=b,e[13]=l,e[14]=d,e[15]=o,e[16]=x,e[17]=w,e[18]=u,e[19]=S,e[20]=N,e[21]=C,e[22]=k,e[23]=T,e[24]=E,e[25]=P}else S=e[19],N=e[20],C=e[21],k=e[22],T=e[23],E=e[24],P=e[25];if(C!==Symbol.for("react.early_return_sentinel"))return C;let _;e[64]!==k||e[65]!==T||e[66]!==E?(_=r.jsxs("div",{className:k,children:[T,E]}),e[64]=k,e[65]=T,e[66]=E,e[67]=_):_=e[67];let A;e[68]!==S||e[69]!==_||e[70]!==P?(A=r.jsx(S,{className:P,children:_}),e[68]=S,e[69]=_,e[70]=P,e[71]=A):A=e[71];let I;return e[72]!==N||e[73]!==A?(I=r.jsxs(r.Fragment,{children:[N,A]}),e[72]=N,e[73]=A,e[74]=I):I=e[74],I}function iM(n){return n.state!=="open"}function aM(n){return n.state==="open"}const Ib={open:"Open",draft:"Draft",merged:"Merged",closed:"Closed"},lM={open:"bg-success",draft:"bg-border",merged:"bg-info",closed:"bg-destructive"};function Fs(n){return n.state==="open"||n.state==="draft"}function cM(n){const e=B.c(12),{state:t}=n,s=Ib[t];if(t==="open"){let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=K("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=K("size-3.5 shrink-0","text-muted-foreground"),e[3]=a):a=e[3];let l;return e[4]!==s?(l=r.jsx(wd,{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=K("size-3.5 shrink-0","text-info"),e[6]=a):a=e[6];let l;return e[7]!==s?(l=r.jsx(B1,{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=K("size-3.5 shrink-0","text-destructive"),e[9]=o):o=e[9];let i;return e[10]!==s?(i=r.jsx(Tw,{className:o,"aria-label":s}),e[10]=s,e[11]=i):i=e[11],i}function $h(n){return n==="success"?"Checks passed":n==="failure"?"Checks failed":"Checks running"}function dM(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(lt,{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(Qe,{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(Ir,{className:"size-3 text-info"}),e[2]=s):s=e[2],s}function uM(n){return n.reviewRequested?{icon:r.jsx(gs,{className:"size-3 text-info"}),label:"Your review is requested"}:n.review==="approved"?{icon:r.jsx(Pr,{className:"size-3 text-success"}),label:"Approved"}:n.review==="changes_requested"?{icon:r.jsx(Wt,{className:"size-3 text-warning"}),label:"Changes requested"}:n.review==="review_required"&&Fs(n)?{icon:r.jsx(gs,{className:"size-3 text-muted-foreground"}),label:"Review required"}:null}function fM(n){const e=B.c(17),{pull:t,onShowChecks:s}=n;let o;e[0]!==t?(o=uM(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":`${$h(t.checks)}, show runs`,title:$h(t.checks),onClick:()=>s(t.headBranch),children:r.jsx(dM,{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(un,{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(sb,{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 mM(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 pM(n){const e=n.lastIndexOf("/");return e===-1?{directory:"",name:n}:{directory:n.slice(0,e+1),name:n.slice(e+1)}}function hM(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:j,className:S}=mM(t.status);o=j;let N;e[8]!==t.path?(N=pM(t.path),e[8]=t.path,e[9]=N):N=e[9],{directory:s,name:i}=N,l="flex min-w-0 items-center gap-2 py-0.5 font-mono text-[11px] leading-5",c=t.path,a=K("w-3 shrink-0 text-center font-medium",S),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=K(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 v;e[26]!==t.deletions?(v=t.deletions>0&&r.jsxs("span",{className:"text-destructive",children:["−",t.deletions]}),e[26]=t.deletions,e[27]=v):v=e[27];let w;e[28]!==g||e[29]!==x||e[30]!==v?(w=r.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums",children:[g,x,v]}),e[28]=g,e[29]=x,e[30]=v,e[31]=w):w=e[31];let b;return e[32]!==w||e[33]!==l||e[34]!==c||e[35]!==d||e[36]!==h?(b=r.jsxs("li",{className:l,title:c,children:[d,h,w]}),e[32]=w,e[33]=l,e[34]=c,e[35]=d,e[36]=h,e[37]=b):b=e[37],b}function gM(n){var S,N,C,k,T,E;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]!==((S=s.data)==null?void 0:S.files)?(a=((N=s.data)==null?void 0:N.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(Ou,{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(Ze,{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(xM)}),e[19]=l,e[20]=h):h=e[20];let g;e[21]!==((k=s.data)==null?void 0:k.truncated)||e[22]!==l.length?(g=((T=s.data)==null?void 0:T.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]=(E=s.data)==null?void 0:E.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 v;e[31]!==t.url?(v=r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"}),e[31]=t.url,e[32]=v):v=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Vt,{"data-icon":"inline-end"}),e[33]=w):w=e[33];let b;e[34]!==v?(b=r.jsxs(ee,{variant:"outline",size:"xs",className:"self-start",render:v,children:["Open pull request on GitHub",w]}),e[34]=v,e[35]=b):b=e[35];let j;return e[36]!==x||e[37]!==b||e[38]!==c?(j=r.jsxs("div",{className:"flex flex-col gap-3 py-2 pl-[22px] pr-1",children:[c,x,b]}),e[36]=x,e[37]=b,e[38]=c,e[39]=j):j=e[39],j}function xM(n){return r.jsx(hM,{file:n},n.path)}function bM(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(hc,{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 vM(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=()=>MR(s,t.number),e[0]=s,e[1]=t.number,e[2]=d):d=e[2];const{open:u,state:f,onOpenChange:m}=Ab(d,"Unable to load changed files"),p=o!==null&&t.headBranch===o,h=Fs(t)?t.updatedAt:t.closedAt??t.updatedAt,g=t.title,x=lM[t.state];let v;e[3]!==x?(v=K("absolute inset-y-1 left-0 w-0.5 rounded-full",x),e[3]=x,e[4]=v):v=e[4];let w;e[5]!==v?(w=r.jsx("span",{"aria-hidden":!0,className:v}),e[5]=v,e[6]=w):w=e[6];const b=`${t.title} #${t.number}: ${Ib[t.state]}`;let j;e[7]!==t.state?(j=r.jsx(cM,{state:t.state}),e[7]=t.state,e[8]=j):j=e[8];let S;e[9]!==t?(S=!Fs(t)&&"text-muted-foreground",e[9]=t,e[10]=S):S=e[10];let N;e[11]!==S?(N=K("min-w-0 flex-1 truncate text-[13px] font-medium leading-5",S),e[11]=S,e[12]=N):N=e[12];let C;e[13]!==t.title||e[14]!==N?(C=r.jsx("span",{className:N,children:t.title}),e[13]=t.title,e[14]=N,e[15]=C):C=e[15];let k;e[16]!==t.number?(k=r.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground",children:["#",t.number]}),e[16]=t.number,e[17]=k):k=e[17];let T;e[18]!==C||e[19]!==k||e[20]!==j?(T=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[j,C,k]}),e[18]=C,e[19]=k,e[20]=j,e[21]=T):T=e[21];let E;e[22]!==t.author?(E=t.author&&r.jsx("span",{className:"shrink-0",children:t.author}),e[22]=t.author,e[23]=E):E=e[23];let P;e[24]!==p?(P=p&&r.jsx($n,{className:"size-3 shrink-0 text-foreground","aria-label":"Current branch"}),e[24]=p,e[25]=P):P=e[25];const _=p&&"text-foreground";let A;e[26]!==_?(A=K("truncate",_),e[26]=_,e[27]=A):A=e[27];let I;e[28]!==t.headBranch||e[29]!==A?(I=r.jsx("span",{className:A,children:t.headBranch}),e[28]=t.headBranch,e[29]=A,e[30]=I):I=e[30];let R;e[31]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Ew,{className:"size-3 shrink-0","aria-hidden":!0}),e[31]=R):R=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]!==P||e[35]!==I||e[36]!==$?(M=r.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono",children:[P,I,R,$]}),e[34]=P,e[35]=I,e[36]=$,e[37]=M):M=e[37];let L;e[38]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("span",{className:"shrink-0",children:"·"}),e[38]=L):L=e[38];let D;e[39]!==h?(D=new Date(h).toLocaleString(),e[39]=h,e[40]=D):D=e[40];let F;e[41]!==h||e[42]!==c?(F=el(h,c),e[41]=h,e[42]=c,e[43]=F):F=e[43];let z;e[44]!==h||e[45]!==D||e[46]!==F?(z=r.jsx("time",{className:"shrink-0",dateTime:h,title:D,children:F}),e[44]=h,e[45]=D,e[46]=F,e[47]=z):z=e[47];let O;e[48]!==E||e[49]!==M||e[50]!==z?(O=r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 pl-[22px] text-[11px] leading-4 text-muted-foreground",children:[E,M,L,z]}),e[48]=E,e[49]=M,e[50]=z,e[51]=O):O=e[51];let H;e[52]!==u||e[53]!==T||e[54]!==O||e[55]!==b?(H=r.jsxs(Pt,{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":u,children:[T,O]}),e[52]=u,e[53]=T,e[54]=O,e[55]=b,e[56]=H):H=e[56];let W;e[57]!==l||e[58]!==t?(W=r.jsx(fM,{pull:t,onShowChecks:l}),e[57]=l,e[58]=t,e[59]=W):W=e[59];const U=`Open #${t.number} on GitHub`;let V;e[60]!==t.url?(V=()=>window.open(t.url,"_blank","noopener,noreferrer"),e[60]=t.url,e[61]=V):V=e[61];let q;e[62]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(Vt,{}),e[62]=q):q=e[62];let X;e[63]!==U||e[64]!==V?(X=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":U,onClick:V,children:q}),e[63]=U,e[64]=V,e[65]=X):X=e[65];let G;e[66]!==W||e[67]!==X?(G=r.jsxs("div",{className:"mt-1 flex shrink-0 items-center gap-1",children:[W,X]}),e[66]=W,e[67]=X,e[68]=G):G=e[68];let Y;e[69]!==H||e[70]!==G?(Y=r.jsxs("div",{className:"group/pull flex items-start gap-1 pr-1",children:[H,G]}),e[69]=H,e[70]=G,e[71]=Y):Y=e[71];let J;e[72]!==a||e[73]!==i?(J=i.length>0&&r.jsx(bM,{sessions:i,openSession:a}),e[72]=a,e[73]=i,e[74]=J):J=e[74];let Q;e[75]!==f||e[76]!==t?(Q=r.jsx(dt,{children:r.jsx(gM,{pull:t,files:f})}),e[75]=f,e[76]=t,e[77]=Q):Q=e[77];let Z;e[78]!==m||e[79]!==u||e[80]!==Y||e[81]!==J||e[82]!==Q?(Z=r.jsxs(ct,{open:u,onOpenChange:m,children:[Y,J,Q]}),e[78]=m,e[79]=u,e[80]=Y,e[81]=J,e[82]=Q,e[83]=Z):Z=e[83];let te;return e[84]!==t.title||e[85]!==Z||e[86]!==w?(te=r.jsxs("article",{className:"relative pl-3","aria-label":g,children:[w,Z]}),e[84]=t.title,e[85]=Z,e[86]=w,e[87]=te):te=e[87],te}function yM(n,e,t){return e==="mine"?n.filter(s=>s.author===t.viewer):e==="branch"?n.filter(s=>s.headBranch===t.branch):[...n]}function wM(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 jM(n){const e=B.c(61),{data:t,sessions:s,projectPath:o,openSession:i,onShowChecks:a}=n,[l,c]=y.useState("all"),d=tl(!1);let u;e[0]!==s?(u=wM(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(P=>P.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(P=>P.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 v,w,b,j,S,N,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 P=yM(t.pulls,x,t),_=P.filter(Fs),A=P.filter(SM);if(t.pulls.length===0){let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsx(nl,{icon:Mr,title:"No pull requests yet",description:"Open one from a branch and it will show up here."}),e[24]=O):O=e[24],C=O;break e}let I;e[25]!==t.branch||e[26]!==f||e[27]!==d||e[28]!==a||e[29]!==i||e[30]!==o?(I=O=>r.jsx(vM,{pull:O,projectPath:o,currentBranch:t.branch,sessions:f.get(O.number)??[],openSession:i,onShowChecks:a,now:d},O.number),e[25]=t.branch,e[26]=f,e[27]=d,e[28]=a,e[29]=i,e[30]=o,e[31]=I):I=e[31];const R=I,$=x==="all";let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=()=>c("all"),e[32]=M):M=e[32];let L;e[33]!==t.pulls.length?(L=r.jsx(bt,{children:t.pulls.length}),e[33]=t.pulls.length,e[34]=L):L=e[34];let D;e[35]!==$||e[36]!==L?(D=r.jsxs(xt,{pressed:$,onClick:M,children:["All",L]}),e[35]=$,e[36]=L,e[37]=D):D=e[37];let F;e[38]!==t.viewer||e[39]!==x||e[40]!==p?(F=t.viewer&&r.jsxs(xt,{pressed:x==="mine",disabled:p===0,onClick:()=>c("mine"),"aria-label":`Only pull requests by ${t.viewer}`,children:[r.jsx(Sd,{className:"size-3"}),"Mine",r.jsx(bt,{children:p})]}),e[38]=t.viewer,e[39]=x,e[40]=p,e[41]=F):F=e[41];let z;e[42]!==g||e[43]!==t.branch||e[44]!==x?(z=t.branch&&r.jsxs(xt,{pressed:x==="branch",disabled:g===0,onClick:()=>c("branch"),"aria-label":`Only pull requests from ${t.branch}`,children:[r.jsx($n,{className:"size-3"}),r.jsx("span",{className:"max-w-28 truncate",children:t.branch}),r.jsx(bt,{children:g})]}),e[42]=g,e[43]=t.branch,e[44]=x,e[45]=z):z=e[45],e[46]!==D||e[47]!==F||e[48]!==z?(N=r.jsxs(_r,{label:"Filter pull requests",children:[D,F,z]}),e[46]=D,e[47]=F,e[48]=z,e[49]=N):N=e[49],v=zn,S="min-h-0 flex-1",w="flex flex-col gap-4 px-3 py-3",b=_.length===0?r.jsx("p",{className:"px-1 py-3 text-center text-xs text-muted-foreground",children:"Nothing open right now."}):_.map(R),j=A.length>0&&r.jsx(Mu,{count:A.length,children:A.map(R)})}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]=v,e[18]=w,e[19]=b,e[20]=j,e[21]=S,e[22]=N,e[23]=C}else v=e[17],w=e[18],b=e[19],j=e[20],S=e[21],N=e[22],C=e[23];if(C!==Symbol.for("react.early_return_sentinel"))return C;let k;e[50]!==w||e[51]!==b||e[52]!==j?(k=r.jsxs("div",{className:w,children:[b,j]}),e[50]=w,e[51]=b,e[52]=j,e[53]=k):k=e[53];let T;e[54]!==v||e[55]!==k||e[56]!==S?(T=r.jsx(v,{className:S,children:k}),e[54]=v,e[55]=k,e[56]=S,e[57]=T):T=e[57];let E;return e[58]!==T||e[59]!==N?(E=r.jsxs(r.Fragment,{children:[N,T]}),e[58]=T,e[59]=N,e[60]=E):E=e[60],E}function SM(n){return!Fs(n)}const NM={actions:"Refresh GitHub Actions",pulls:"Refresh pull requests",issues:"Refresh issues"};function kM(n){return n==="actions"||n==="pulls"||n==="issues"}function CM(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 _M(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[0,1,2].map(TM),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 TM(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(it,{className:"h-3.5 w-3/4"}),r.jsx(it,{className:"h-2.5 w-1/2"}),r.jsx(it,{className:"h-3 w-full"}),r.jsx(it,{className:"h-3 w-full"})]},n)}function tc(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(Wt,{}),e[5]=l):l=e[5];let c;e[6]!==t.error.error?(c=r.jsx(kt,{children:t.error.error}),e[6]=t.error.error,e[7]=c):c=e[7];let d;e[8]!==t.error?(d=CM(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(Et,{"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(mt,{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(ft,{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(_M,{label:s}),e[21]=s,e[22]=a):a=e[22],a}function nc(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=K("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 EM(n){var f,m,p,h;const e=B.c(11),{context:t}=n,s=t.projectPath!==null,{data:o}=_b(t.projectPath,s),i=Tb(t.projectPath,s);let a;e[0]!==(o==null?void 0:o.runs)?(a=(o==null?void 0:o.runs.filter(PM).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?Oo(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(AM).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(Ie,{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(Ie,{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(Ie,{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 AM(n){return Fs(n)&&n.reviewRequested}function PM(n){return oi(n.status)}function $M(n){const e=B.c(78),{context:t,active:s,closePanel:o}=n,[i,a]=y.useState("actions"),[l,c]=y.useState(null),d=t.projectPath,u=_b(d,s),f=Tb(d,s),m=IR(d,s&&i==="pulls"),p=$R(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 v=x,w=u.data??f.data??p.data;let b;e[5]!==u.data?(b=u.data?u.data.runs.filter(RM).length:null,e[5]=u.data,e[6]=b):b=e[6];const j=b;let S;e[7]!==f.data?(S=f.data?f.data.pulls.filter(Fs).length:null,e[7]=f.data,e[8]=S):S=e[8];const N=S;let C;e[9]!==p.data?(C=p.data?p.data.issues.filter(IM).length:null,e[9]=p.data,e[10]=C):C=e[10];const k=C;let T;e[11]===Symbol.for("react.memo_cache_sentinel")?(T=ne=>{kM(ne)&&a(ne)},e[11]=T):T=e[11];let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"GitHub"}),e[12]=E):E=e[12];let P;e[13]!==w||e[14]!==i?(P=r.jsxs("div",{className:"min-w-0 flex-1",children:[E,w?r.jsxs("a",{href:`${w.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:w.repository}),r.jsx(Vt,{className:"size-3 shrink-0"})]}):r.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:"Current repository"})]}),e[13]=w,e[14]=i,e[15]=P):P=e[15];let _;e[16]!==g?(_=()=>{g.refresh()},e[16]=g,e[17]=_):_=e[17];const A=g.loading||g.refreshing||!d,I=NM[i];let R;e[18]!==g.refreshing?(R=g.refreshing?r.jsx(Ze,{}):r.jsx(Et,{}),e[18]=g.refreshing,e[19]=R):R=e[19];let $;e[20]!==A||e[21]!==I||e[22]!==R||e[23]!==_?($=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,disabled:A,"aria-label":I,children:R}),e[20]=A,e[21]=I,e[22]=R,e[23]=_,e[24]=$):$=e[24];let M;e[25]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(Qe,{}),e[25]=M):M=e[25];let L;e[26]!==o?(L=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close GitHub",children:M}),e[26]=o,e[27]=L):L=e[27];let D;e[28]!==$||e[29]!==L||e[30]!==P?(D=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[P,$,L]}),e[28]=$,e[29]=L,e[30]=P,e[31]=D):D=e[31];let F;e[32]!==j?(F=r.jsxs(En,{value:"actions",className:"h-full flex-none rounded-none px-0 text-xs",children:["Actions",r.jsx(nc,{value:j,attention:!0})]}),e[32]=j,e[33]=F):F=e[33];let z;e[34]!==N?(z=r.jsxs(En,{value:"pulls",className:"h-full flex-none rounded-none px-0 text-xs",children:["Pull requests",r.jsx(nc,{value:N})]}),e[34]=N,e[35]=z):z=e[35];let O;e[36]!==k?(O=r.jsxs(En,{value:"issues",className:"h-full flex-none rounded-none px-0 text-xs",children:["Issues",r.jsx(nc,{value:k})]}),e[36]=k,e[37]=O):O=e[37];let H;e[38]!==F||e[39]!==z||e[40]!==O?(H=r.jsx("div",{className:"flex h-9 shrink-0 items-end border-b px-3",children:r.jsxs(Ma,{variant:"line",className:"h-full gap-3 p-0","aria-label":"GitHub views",children:[F,z,O]})}),e[38]=F,e[39]=z,e[40]=O,e[41]=H):H=e[41];let W;e[42]!==u?(W=()=>{u.refresh()},e[42]=u,e[43]=W):W=e[43];let U;e[44]!==l||e[45]!==d?(U=ne=>d&&r.jsx(YR,{data:ne,projectPath:d,focus:l}),e[44]=l,e[45]=d,e[46]=U):U=e[46];let V;e[47]!==u||e[48]!==W||e[49]!==U?(V=r.jsx(An,{value:"actions",className:"flex min-h-0 flex-col",children:r.jsx(tc,{state:u,loadingLabel:"Loading workflow runs",onRetry:W,children:U})}),e[47]=u,e[48]=W,e[49]=U,e[50]=V):V=e[50];let q;e[51]!==f?(q=()=>{f.refresh()},e[51]=f,e[52]=q):q=e[52];let X;e[53]!==t.openSession||e[54]!==d||e[55]!==m?(X=ne=>{var oe;return d&&r.jsx(jM,{data:ne,sessions:((oe=m.data)==null?void 0:oe.sessions)??[],projectPath:d,openSession:t.openSession,onShowChecks:v})},e[53]=t.openSession,e[54]=d,e[55]=m,e[56]=X):X=e[56];let G;e[57]!==f||e[58]!==q||e[59]!==X?(G=r.jsx(An,{value:"pulls",className:"flex min-h-0 flex-col",children:r.jsx(tc,{state:f,loadingLabel:"Loading pull requests",onRetry:q,children:X})}),e[57]=f,e[58]=q,e[59]=X,e[60]=G):G=e[60];let Y;e[61]!==p?(Y=()=>{p.refresh()},e[61]=p,e[62]=Y):Y=e[62];let J;e[63]!==t.composePrompt?(J=ne=>r.jsx(rM,{data:ne,composePrompt:t.composePrompt,onShowPulls:()=>a("pulls")}),e[63]=t.composePrompt,e[64]=J):J=e[64];let Q;e[65]!==p||e[66]!==Y||e[67]!==J?(Q=r.jsx(An,{value:"issues",className:"flex min-h-0 flex-col",children:r.jsx(tc,{state:p,loadingLabel:"Loading issues",onRetry:Y,children:J})}),e[65]=p,e[66]=Y,e[67]=J,e[68]=Q):Q=e[68];let Z;e[69]!==V||e[70]!==G||e[71]!==Q?(Z=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[V,G,Q]}),e[69]=V,e[70]=G,e[71]=Q,e[72]=Z):Z=e[72];let te;return e[73]!==D||e[74]!==H||e[75]!==Z||e[76]!==i?(te=r.jsxs(Ra,{value:i,onValueChange:T,className:"size-full min-h-0 gap-0","aria-label":"GitHub panel",children:[D,H,Z]}),e[73]=D,e[74]=H,e[75]=Z,e[76]=i,e[77]=te):te=e[77],te}function IM(n){return n.state==="open"}function RM(n){return oi(n.status)}const MM={id:"github",workspacePanels:[{id:"repository",title:"GitHub",icon:b1,component:$M,indicator:EM,order:40,defaultSize:"38%",minSize:"360px",maxSize:"62%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},Gu={data:null,error:null,loading:!1,refreshing:!1},Ih=new Map,OM=8e3,LM=1e4,DM=new Set(["vercel_access_denied","vercel_auth_required","vercel_cli_too_old","vercel_missing","vercel_project_unlinked"]);function Yu(n){let e=Ih.get(n);return e||(e={snapshot:Gu,listeners:new Set,request:null,fetchedAt:0},Ih.set(n,e)),e}function sc(n,e){n.snapshot=e;for(const t of n.listeners)t()}async function Rb(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 oc(n,e=!1){const t=Yu(n);if(t.request)return t.request;if(!(!e&&t.snapshot.error&&DM.has(t.snapshot.error.code))&&!(!e&&t.fetchedAt>0&&Date.now()-t.fetchedAt<OM))return sc(t,{...t.snapshot,error:null,loading:t.snapshot.data===null,refreshing:t.snapshot.data!==null}),t.request=_e(`/api/vercel-deployments?cwd=${encodeURIComponent(n)}&limit=20`).then(async s=>{if(!s.ok)throw await Rb(s);const o=await s.json();t.fetchedAt=Date.now(),sc(t,{data:o,error:null,loading:!1,refreshing:!1})}).catch(s=>{const o=s;sc(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 zM(n,e){if(!n)return()=>{};const t=Yu(n);return t.listeners.add(e),()=>t.listeners.delete(e)}function FM(n){return n?Yu(n).snapshot:Gu}function Mb(n,e){const t=B.c(13),s=n??"";let o;t[0]!==s?(o=m=>zM(s,m),t[0]=s,t[1]=o):o=t[1];let i;t[2]!==s?(i=()=>FM(s),t[2]=s,t[3]=i):i=t[3];const a=y.useSyncExternalStore(o,i,BM);let l,c;t[4]!==e||t[5]!==s?(l=()=>{if(!e||!s)return;oc(s);const m=window.setInterval(()=>{oc(s)},LM);return()=>window.clearInterval(m)},c=[e,s],t[4]=e,t[5]=s,t[6]=l,t[7]=c):(l=t[6],c=t[7]),y.useEffect(l,c);let d;t[8]!==s?(d=()=>s?oc(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 BM(){return Gu}async function UM(n,e){const t=await _e(`/api/vercel-deployments/build-logs?cwd=${encodeURIComponent(n)}&deploymentId=${encodeURIComponent(e)}&limit=200`);if(!t.ok)throw await Rb(t);return t.json()}const WM={live:"bg-info motion-safe:animate-pulse",fail:"bg-destructive",pass:"bg-success"};function ri(n){return n==="BUILDING"||n==="INITIALIZING"||n==="QUEUED"}function il(n){return n==="BLOCKED"||n==="CANCELED"||n==="ERROR"}function _o(n){return n.target==="production"}function Ob(n){return ri(n)?"live":il(n)?"fail":"pass"}function Xu(n){return n==="READY"?"Ready":n==="BUILDING"?"Building":n==="INITIALIZING"?"Initializing":n==="QUEUED"?"Queued":n==="CANCELED"?"Canceled":n==="BLOCKED"?"Blocked":"Failed"}function Lb(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 HM(n,e){const t=n.buildingAt??n.createdAt,s=n.readyAt??(ri(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 qM(n){const e=B.c(3),[t,s]=y.useState(KM);let o,i;return e[0]!==n?(o=()=>{if(s(Date.now()),!n)return;const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},i=[n],e[0]=n,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useEffect(o,i),t}function KM(){return Date.now()}function Ju(n){if(!n)return null;try{return new URL(n).host}catch{return null}}function Gc(n){return n.commitMessage.split(`
|
|
127
|
+
`)[0]||Ju(n.url)||`${Xu(n.state)} deployment`}function VM(n){return[n.errorCode,n.errorMessage].filter(Boolean).join(": ")||null}function Db(n){const e=B.c(12),{state:t,className:s}=n;let o;e[0]!==t?(o=Xu(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=K("size-3.5 shrink-0",s);if(t==="BUILDING"){c=r.jsx(Ze,{className:K(u,"text-info"),"aria-label":i});break e}if(t==="INITIALIZING"||t==="QUEUED"){c=r.jsx(Ir,{className:K(u,"text-info"),"aria-label":i});break e}if(t==="READY"){c=r.jsx(lt,{className:K(u,"text-success"),"aria-label":i});break e}if(t==="BLOCKED"){c=r.jsx(Aw,{className:K(u,"text-destructive"),"aria-label":i});break e}a=Qe,l=K(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 GM(){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 YM(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 XM(){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(it,{className:"h-2.5 w-16"}),r.jsx(it,{className:"h-3.5 w-3/4"}),r.jsx(it,{className:"h-2.5 w-1/2"})]}),[0,1,2,3].map(JM)]}),n[0]=e):e=n[0],e}function JM(n){return r.jsxs("div",{className:"flex flex-col gap-2 border-l-2 border-border pl-3",children:[r.jsx(it,{className:"h-3.5 w-4/5"}),r.jsx(it,{className:"h-2.5 w-1/2"})]},n)}const QM={data:null,error:null,loading:!1};function ZM(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(eO),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 eO(n){return r.jsxs("div",{className:K("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 Rh(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(Vt,{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 tO(n){const e=B.c(106),{deployment:t,projectPath:s,now:o}=n,[i,a]=y.useState(!1),[l,c]=y.useState(QM);let d;e[0]!==t.state?(d=Ob(t.state),e[0]=t.state,e[1]=d):d=e[1];const u=d;let f;e[2]!==t||e[3]!==o?(f=HM(t,o),e[2]=t,e[3]=o,e[4]=f):f=e[4];const m=f;let p;e[5]!==t?(p=Gc(t),e[5]=t,e[6]=p):p=e[6];const h=p;let g;e[7]!==t?(g=VM(t),e[7]=t,e[8]=g):g=e[8];const x=g;let v;e[9]!==t.url?(v=Ju(t.url),e[9]=t.url,e[10]=v):v=e[10];const w=v;let b;e[11]!==t.id||e[12]!==l.loading||e[13]!==s?(b=async function(){if(!l.loading){c(nO);try{const ce=await UM(s,t.id);c({data:ce,error:null,loading:!1})}catch(ce){const me=ce;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]=b):b=e[14];const j=b;let S;e[15]!==t.state||e[16]!==j||e[17]!==l.data?(S=function(ce){a(ce),ce&&(!l.data||ri(t.state))&&j()},e[15]=t.state,e[16]=j,e[17]=l.data,e[18]=S):S=e[18];const N=S,C=WM[u];let k;e[19]!==C?(k=K("absolute inset-y-1 left-0 w-0.5 rounded-full",C),e[19]=C,e[20]=k):k=e[20];let T;e[21]!==k?(T=r.jsx("span",{"aria-hidden":!0,className:k}),e[21]=k,e[22]=T):T=e[22];let E;e[23]!==t.state?(E=Xu(t.state),e[23]=t.state,e[24]=E):E=e[24];const P=`${h}: ${E}`;let _;e[25]!==t.state?(_=r.jsx(Db,{state:t.state}),e[25]=t.state,e[26]=_):_=e[26];const A=u==="fail"&&"text-destructive";let I;e[27]!==A?(I=K("min-w-0 flex-1 truncate text-xs font-medium",A),e[27]=A,e[28]=I):I=e[28];let R;e[29]!==I||e[30]!==h?(R=r.jsx("span",{className:I,children:h}),e[29]=I,e[30]=h,e[31]=R):R=e[31];let $;e[32]!==t?($=_o(t)&&r.jsx(GM,{}),e[32]=t,e[33]=$):$=e[33];let M;e[34]!==t.createdAt||e[35]!==o?(M=Lb(t.createdAt,o),e[34]=t.createdAt,e[35]=o,e[36]=M):M=e[36];let L;e[37]!==M?(L=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]=L):L=e[38];let D;e[39]!==_||e[40]!==R||e[41]!==$||e[42]!==L?(D=r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[_,R,$,L]}),e[39]=_,e[40]=R,e[41]=$,e[42]=L,e[43]=D):D=e[43];let F;e[44]!==t.branch?(F=t.branch&&r.jsx("span",{className:"min-w-0 truncate",children:t.branch}),e[44]=t.branch,e[45]=F):F=e[45];let z;e[46]!==t.commitSha?(z=t.commitSha&&r.jsx("span",{className:"shrink-0",children:t.commitSha.slice(0,7)}),e[46]=t.commitSha,e[47]=z):z=e[47];let O;e[48]!==t.branch||e[49]!==t.commitSha?(O=!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]=O):O=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=r.jsx("span",{className:"min-w-0 flex-1"}),e[51]=H):H=e[51];let W;e[52]!==m||e[53]!==u?(W=m&&r.jsx("span",{className:K("shrink-0 tabular-nums",u==="live"&&"text-info"),children:m}),e[52]=m,e[53]=u,e[54]=W):W=e[54];let U;e[55]!==F||e[56]!==z||e[57]!==O||e[58]!==W?(U=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:[F,z,O,H,W]}),e[55]=F,e[56]=z,e[57]=O,e[58]=W,e[59]=U):U=e[59];let V;e[60]!==x?(V=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]=V):V=e[61];let q;e[62]!==i||e[63]!==P||e[64]!==D||e[65]!==U||e[66]!==V?(q=r.jsxs(Pt,{className:"flex min-w-0 flex-1 flex-col gap-0.5 rounded-sm px-1 py-1 text-left outline-none hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/20","aria-label":P,"aria-expanded":i,children:[D,U,V]}),e[62]=i,e[63]=P,e[64]=D,e[65]=U,e[66]=V,e[67]=q):q=e[67];let X;e[68]!==t.url||e[69]!==h?(X=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(Vt,{})}),e[68]=t.url,e[69]=h,e[70]=X):X=e[70];let G;e[71]!==q||e[72]!==X?(G=r.jsxs("div",{className:"flex items-start gap-1",children:[q,X]}),e[71]=q,e[72]=X,e[73]=G):G=e[73];let Y;e[74]!==t.url||e[75]!==w?(Y=t.url&&w&&r.jsx(Rh,{href:t.url,children:w}),e[74]=t.url,e[75]=w,e[76]=Y):Y=e[76];let J;e[77]!==t.inspectorUrl?(J=t.inspectorUrl&&r.jsx(Rh,{href:t.inspectorUrl,children:"Inspect on Vercel"}),e[77]=t.inspectorUrl,e[78]=J):J=e[78];let Q;e[79]!==t.creator?(Q=t.creator&&r.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["by ",t.creator]}),e[79]=t.creator,e[80]=Q):Q=e[80];let Z;e[81]!==Y||e[82]!==J||e[83]!==Q?(Z=r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[Y,J,Q]}),e[81]=Y,e[82]=J,e[83]=Q,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(Ze,{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(ZM,{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(dt,{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 ie;e[97]!==T||e[98]!==G||e[99]!==re||e[100]!==h?(ie=r.jsxs("article",{className:"group/deployment relative pl-3","aria-label":h,children:[T,G,re]}),e[97]=T,e[98]=G,e[99]=re,e[100]=h,e[101]=ie):ie=e[101];let se;return e[102]!==N||e[103]!==i||e[104]!==ie?(se=r.jsx(ct,{open:i,onOpenChange:N,children:ie}),e[102]=N,e[103]=i,e[104]=ie,e[105]=se):se=e[105],se}function nO(n){return{...n,error:null,loading:!0}}function sO(n){const e=n.filter(_o),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 oO(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}=sO(t),c=a??l;if(!c){i=null;break e}const d=Gc(c),u=Ju(c.url),f=l?Ob(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=K("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=K("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 v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("span",{className:"min-w-0 flex-1"}),e[10]=v):v=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:Lb(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)}),v,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(Vt,{className:"size-3 shrink-0"})]})]}),a&&l&&f&&r.jsxs("p",{className:K("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(Db,{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"," · ",Gc(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 rO(n,e){return e==="failed"?n.filter(t=>il(t.state)):e==="production"?n.filter(_o):e==="preview"?n.filter(t=>!_o(t)):[...n]}function iO(n){const e=B.c(17),{data:t,filter:s,projectPath:o}=n;let i;e[0]!==t.deployments||e[1]!==s?(i=rO(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(aO),e[3]=t.deployments,e[4]=l):l=e[4];const c=qM(l);if(t.deployments.length===0){let m;return e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Gt,{className:"border-0",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(U1,{})}),r.jsx(Xt,{children:"No deployments yet"}),r.jsx(sn,{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(oO,{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(tO,{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(zn,{className:"min-h-0 flex-1",children:[d,u]}),e[14]=d,e[15]=u,e[16]=f):f=e[16],f}function aO(n){return ri(n.state)}function lO(n){const e=B.c(6),{context:t}=n,{data:s}=Mb(t.projectPath,t.projectPath!==null);let o;e[0]!==(s==null?void 0:s.deployments)?(o=(s==null?void 0:s.deployments.filter(cO).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]?il(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(Ie,{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(Ie,{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 cO(n){return ri(n.state)}function dO(n){const e=B.c(57),{context:t,active:s,closePanel:o}=n,{data:i,error:a,loading:l,refreshing:c,refresh:d}=Mb(t.projectPath,s),[u,f]=y.useState("all"),m=t.projectPath;let p;e[0]!==(i==null?void 0:i.deployments)?(p=(i==null?void 0:i.deployments)??[],e[0]=i==null?void 0:i.deployments,e[1]=p):p=e[1];const h=p,g=h.length;let x;e[2]!==h?(x=h.filter(_o),e[2]=h,e[3]=x):x=e[3];const v=x.length;let w;e[4]!==h?(w=h.filter(fO),e[4]=h,e[5]=w):w=e[5];const b=w.length;let j;e[6]!==h?(j=h.filter(uO),e[6]=h,e[7]=j):j=e[7];let S;e[8]!==h.length||e[9]!==x.length||e[10]!==w.length||e[11]!==j.length?(S={all:g,production:v,preview:b,failed:j.length},e[8]=h.length,e[9]=x.length,e[10]=w.length,e[11]=j.length,e[12]=S):S=e[12];const N=S,C=u!=="all"&&N[u]===0?"all":u;let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("h2",{className:"text-sm font-medium leading-tight",children:"Vercel Deployments"}),e[13]=k):k=e[13];let T;e[14]!==i?(T=r.jsxs("div",{className:"min-w-0 flex-1",children:[k,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(Vt,{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]=T):T=e[15];let E;e[16]!==d?(E=()=>{d()},e[16]=d,e[17]=E):E=e[17];const P=l||c||!m;let _;e[18]!==c?(_=c?r.jsx(Ze,{}):r.jsx(Et,{}),e[18]=c,e[19]=_):_=e[19];let A;e[20]!==E||e[21]!==P||e[22]!==_?(A=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:E,disabled:P,"aria-label":"Refresh Vercel deployments",children:_}),e[20]=E,e[21]=P,e[22]=_,e[23]=A):A=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Qe,{}),e[24]=I):I=e[24];let R;e[25]!==o?(R=r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:o,"aria-label":"Close Vercel deployments",children:I}),e[25]=o,e[26]=R):R=e[26];let $;e[27]!==T||e[28]!==A||e[29]!==R?($=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b pl-4 pr-2",children:[T,A,R]}),e[27]=T,e[28]=A,e[29]=R,e[30]=$):$=e[30];let M;e[31]!==N||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(xt,{pressed:C==="all",onClick:()=>f("all"),children:["All ",r.jsx(bt,{children:N.all})]}),r.jsxs(xt,{pressed:C==="production",disabled:N.production===0,onClick:()=>f("production"),children:["Production ",r.jsx(bt,{children:N.production})]}),r.jsxs(xt,{pressed:C==="preview",disabled:N.preview===0,onClick:()=>f("preview"),children:["Preview ",r.jsx(bt,{children:N.preview})]}),r.jsxs(xt,{pressed:C==="failed",disabled:N.failed===0,onClick:()=>f("failed"),children:[r.jsx("span",{className:K(N.failed>0&&"text-destructive"),children:"Failed"})," ",r.jsx(bt,{children:N.failed})]})]}),e[31]=N,e[32]=i,e[33]=C,e[34]=M):M=e[34];let L;e[35]!==i||e[36]!==l?(L=l&&!i&&r.jsx(XM,{}),e[35]=i,e[36]=l,e[37]=L):L=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(ft,{variant:"destructive",children:[r.jsx(Wt,{}),r.jsx(kt,{children:a.error}),r.jsxs(mt,{className:"flex flex-col items-start gap-2",children:[r.jsx("span",{children:YM(a)}),r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},children:[r.jsx(Et,{"data-icon":"inline-start"}),"Try again"]})]})]})}),e[38]=i,e[39]=a,e[40]=d,e[41]=D):D=e[41];let F;e[42]!==i||e[43]!==C||e[44]!==m?(F=i&&m&&r.jsx(iO,{data:i,filter:C,projectPath:m}),e[42]=i,e[43]=C,e[44]=m,e[45]=F):F=e[45];let z;e[46]!==i||e[47]!==a||e[48]!==l?(z=!l&&!i&&!a&&r.jsx(Gt,{className:"border-0",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(Ws,{})}),r.jsx(Xt,{children:"Select a project session"})]})}),e[46]=i,e[47]=a,e[48]=l,e[49]=z):z=e[49];let O;return e[50]!==$||e[51]!==M||e[52]!==L||e[53]!==D||e[54]!==F||e[55]!==z?(O=r.jsxs("section",{className:"flex size-full min-h-0 flex-col","aria-label":"Vercel deployments panel",children:[$,M,L,D,F,z]}),e[50]=$,e[51]=M,e[52]=L,e[53]=D,e[54]=F,e[55]=z,e[56]=O):O=e[56],O}function uO(n){return il(n.state)}function fO(n){return!_o(n)}const mO={id:"vercel-deployments",workspacePanels:[{id:"deployments",title:"Vercel Deployments",icon:U1,component:dO,indicator:lO,order:45,defaultSize:"42%",minSize:"380px",maxSize:"68%",when:n=>n.canAccessHostFiles&&n.projectPath!==null}]},pO=[MM,wR,mO];function hO(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]=y.useState(o),[l,c]=y.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]),y.useEffect(d,u);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;a(xO);const v=new URLSearchParams({dirName:n,fileName:e});return _e(`/api/usage-cost/session?${v}`,{signal:x.signal}).then(async w=>{if(!w.ok)throw new Error(`Cost scan failed (${w.status})`);const b=await w.json();a({summary:b,loading:!1,error:null})}).catch(w=>{x.signal.aborted||a(b=>({...b,loading:!1,error:w instanceof Error?w.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],y.useEffect(f,m);let p;s[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(gO),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 gO(n){return n+1}function xO(n){return{...n,loading:!0,error:null}}function bO(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 vO(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 yO(){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(it,{className:"h-4 w-24"}),r.jsx(it,{className:"h-10 w-32"}),r.jsx(it,{className:"h-3 w-44"})]}),t=r.jsx(it,{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(it,{className:"h-8 w-full"}),r.jsx(it,{className:"h-8 w-full"}),r.jsx(it,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function wO(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(id,{}),i=r.jsx(kt,{children:"Cost unavailable"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let a;e[2]!==t?(a=r.jsx(mt,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Et,{"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(ft,{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 jO(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(Bg,{children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let a;e[2]!==t.costUsd?(a=r.jsx(Ug,{children:()=>cn(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(Wr,{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?at(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 SO(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(Wr,{value:c,children:[r.jsx(Bg,{title:l.model,children:Ks(l.model)}),r.jsx(Ug,{children:()=>l.costSource==="unpriced"?"Unpriced":cn(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:[at(zu(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 NO(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 kO(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(CO),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 CO(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," · ",Ks(n.model)]}),n.isSubagent&&r.jsx(Ie,{variant:"outline",children:"Agent"}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:cn(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function _O(n){const e=B.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=M4(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=zu(t.totals),x=vO(t);let v;e[10]!==t.calls?(v=NO(t.calls),e[10]=t.calls,e[11]=v):v=e[11],u=v;const w=t.providerReportedRecords+t.modelPricedRecords>0;i="flex flex-col gap-5 pt-2";let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=b):b=e[12];let j;e[13]!==o?(j=r.jsx(o,{"aria-hidden":"true"}),e[13]=o,e[14]=j):j=e[14];let S;e[15]!==t.provider?(S=on(t.provider),e[15]=t.provider,e[16]=S):S=e[16];let N;e[17]!==S.displayName||e[18]!==j?(N=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[b,r.jsxs(Ie,{variant:"outline",children:[j,S.displayName]})]}),e[17]=S.displayName,e[18]=j,e[19]=N):N=e[19];let C;e[20]!==w||e[21]!==t.costUsd?(C=w?cn(t.costUsd):"—",e[20]=w,e[21]=t.costUsd,e[22]=C):C=e[22];let k;e[23]!==C?(k=r.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:C}),e[23]=C,e[24]=k):k=e[24];const T=t.unpricedRecords>0?"secondary":"outline";let E;e[25]!==t?(E=bO(t),e[25]=t,e[26]=E):E=e[26];let P;e[27]!==T||e[28]!==E?(P=r.jsx(Ie,{variant:T,children:E}),e[27]=T,e[28]=E,e[29]=P):P=e[29];let _;e[30]!==k||e[31]!==P?(_=r.jsxs("div",{className:"flex items-end justify-between gap-3",children:[k,P]}),e[30]=k,e[31]=P,e[32]=_):_=e[32];const A=t.records===1?"model call":"model calls",I=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let R;e[33]!==t.records||e[34]!==A||e[35]!==I?(R=r.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",A,I]}),e[33]=t.records,e[34]=A,e[35]=I,e[36]=R):R=e[36],e[37]!==N||e[38]!==_||e[39]!==R?(a=r.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[N,_,R]}),e[37]=N,e[38]=_,e[39]=R,e[40]=a):a=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(wt,{}),e[41]=l):l=e[41];const $=at(g);let M;e[42]!==$?(M=r.jsx(Ri,{label:"Processed tokens",value:$}),e[42]=$,e[43]=M):M=e[43];let L;e[44]!==t.cacheSavingsUsd?(L=cn(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=L):L=e[45];let D;e[46]!==L?(D=r.jsx(Ri,{label:"Cache savings",value:L}),e[46]=L,e[47]=D):D=e[47];let F;e[48]!==t.totals.cachedInputTokens?(F=at(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=F):F=e[49];let z;e[50]!==F?(z=r.jsx(Ri,{label:"Cached input",value:F}),e[50]=F,e[51]=z):z=e[51];let O;e[52]!==t.totals.reasoningTokens?(O=at(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=O):O=e[53];let H;e[54]!==O?(H=r.jsx(Ri,{label:"Reasoning",value:O}),e[54]=O,e[55]=H):H=e[55],e[56]!==M||e[57]!==D||e[58]!==z||e[59]!==H?(c=r.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[M,D,z,H]}),e[56]=M,e[57]=D,e[58]=z,e[59]=H,e[60]=c):c=e[60],d=x.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(wt,{}),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(W=>r.jsx(jO,{row:W,totalCost:t.costUsd},W.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(wt,{}),r.jsx(SO,{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(wt,{}),r.jsx(kO,{rows:u})]}),e[63]=u,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsxs(ft,{children:[r.jsx(id,{}),r.jsx(kt,{children:"How this is calculated"}),r.jsx(mt,{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 TO(n){const e=B.c(7),{dirName:t,fileName:s,revision:o}=n,{summary:i,loading:a,error:l,refresh:c}=hO(t,s,o);if(l){let u;return e[0]!==l||e[1]!==c?(u=r.jsx(wO,{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(yO,{}),e[3]=f):f=e[3],f}let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Gt,{className:"mt-2 min-h-52",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(Pw,{})}),r.jsx(Xt,{children:"No transcript cost yet"}),r.jsx(sn,{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(_O,{summary:i}),e[5]=i,e[6]=d):d=e[6],d}function EO(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 AO(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n;let o;e[0]!==t?(o=EO(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(Hr,{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 Mh(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||Nu(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 v=x;let w;e[6]!==c?(w=c==="running"?r.jsx(tt,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?r.jsx(On,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?r.jsx(Hs,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):r.jsx(va,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=w):w=e[7];const b=w,j=a?"bg-accent":"hover:bg-muted/40";let S;e[8]!==j?(S=K("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",j),e[8]=j,e[9]=S):S=e[9];let N;e[10]!==g?(N=r.jsx(Ie,{variant:"outline",children:g}),e[10]=g,e[11]=N):N=e[11];let C;e[12]!==l?(C=l&&r.jsx(Ie,{variant:"outline",children:"Background"}),e[12]=l,e[13]=C):C=e[13];let k;e[14]!==a?(k=a&&r.jsx(Ie,{children:"Viewing"}),e[14]=a,e[15]=k):k=e[15];const T=c==="running"?"active":c;let E;e[16]!==T?(E=r.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:T}),e[16]=T,e[17]=E):E=e[17];let P;e[18]!==b||e[19]!==E||e[20]!==N||e[21]!==C||e[22]!==k?(P=r.jsxs("div",{className:"flex items-center gap-1.5",children:[b,N,C,k,E]}),e[18]=b,e[19]=E,e[20]=N,e[21]=C,e[22]=k,e[23]=P):P=e[23];let _;e[24]!==i?(_=i&&r.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:i}),e[24]=i,e[25]=_):_=e[25];let A;e[26]!==v||e[27]!==u?(A=(v||u!=null)&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[v&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(Ir,{className:"size-2.5","data-icon":"inline-start"}),v]}),u!=null&&r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx(ha,{className:"size-2.5","data-icon":"inline-start"}),u," tools"]})]}),e[26]=v,e[27]=u,e[28]=A):A=e[28];let I;e[29]!==f||e[30]!==m||e[31]!==P||e[32]!==_||e[33]!==A?(I=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:[P,_,A]}),e[29]=f,e[30]=m,e[31]=P,e[32]=_,e[33]=A,e[34]=I):I=e[34];let R;e[35]!==g||e[36]!==p?(R=p&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:p,"aria-label":`Stop ${g}`,children:r.jsx(Qe,{"data-icon":"inline-start"})}),e[35]=g,e[36]=p,e[37]=R):R=e[37];let $;return e[38]!==I||e[39]!==R||e[40]!==S?($=r.jsxs("div",{className:S,children:[I,R]}),e[38]=I,e[39]=R,e[40]=S,e[41]=$):$=e[41],$}function PO(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 Yc(n){return n.split(`
|
|
128
|
+
`).map(e=>e.trim()).find(Boolean)??""}function $O(n){return n.name==="Task"||n.name==="Agent"}function IO(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=PO(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:Yc(((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(!$O(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:Yc(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 RO({session:n,sessionSource:e,bgAgents:t,onLoadSession:s}){const o=wu(),i=y.useMemo(()=>{if(!e)return null;const w=ws(e.fileName);return w?{...w,dirName:e.dirName}:null},[e]),a=y.useMemo(()=>IO(n,o),[n,o]),l=y.useRef(a);y.useEffect(()=>{!i&&a.length>0&&(l.current=a)},[i,a]);const c=i&&a.length===0?l.current:a,d=y.useMemo(()=>{if(i)return i.parentSessionId;if(e!=null&&e.fileName){const w=e.fileName.match(/^([^/]+)\.jsonl$/);if(w)return w[1]}return null},[i,e]),u=y.useMemo(()=>d?t.filter(w=>w.parentSessionId===d):t,[t,d]),f=y.useMemo(()=>new Map(c.map(w=>[w.agentId,w])),[c]),m=y.useMemo(()=>{const w=new Set(u.map(b=>b.agentId));return c.filter(b=>!w.has(b.agentId))},[u,c]),p=y.useMemo(()=>[...u].sort((w,b)=>b.modifiedAt-w.modifiedAt),[u]),h=y.useMemo(()=>[...m].reverse(),[m]),g=u.length+m.length;if(g===0)return null;const x=w=>{_e(`/api/claude/tasks/${encodeURIComponent(n.sessionId)}/${encodeURIComponent(w)}`,{method:"DELETE"})},v=(i==null?void 0:i.agentId)??null;return r.jsxs("section",{children:[r.jsxs(Hr,{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(Ve,{"data-icon":"inline-start",className:"rotate-180"}),"Back to Main Agent"]}),r.jsxs("div",{className:"flex max-h-[280px] flex-col gap-1.5 overflow-y-auto pr-0.5",children:[p.map(w=>{const b=Yc(w.preview??""),j=f.get(w.agentId);return r.jsx(Mh,{agentId:w.agentId,subagentType:(j==null?void 0:j.subagentType)??null,agentName:(j==null?void 0:j.agentName)??null,preview:(j==null?void 0:j.preview)||(b!==w.agentId?b:""),isViewing:v===w.agentId,isBackground:!0,status:w.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:w.isActive?()=>x(w.agentId):void 0,onClick:()=>s==null?void 0:s(w.dirName,w.fileName)},w.agentId)}),h.map(w=>{const b=!!s&&!!d&&!!e&&!w.agentId.startsWith("tool:");return r.jsx(Mh,{agentId:w.agentId,subagentType:w.subagentType,agentName:w.agentName,preview:w.preview,isViewing:v===w.agentId,isBackground:w.isBackground,status:w.status,durationMs:w.durationMs,toolUseCount:w.toolUseCount,disabled:!b,onClick:()=>{b&&s(e.dirName,`${d}/subagents/agent-${w.agentId}.jsonl`)}},w.agentId)})]})]})}function MO(n,e){return`${n.id}-${e}`}function OO(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,[o,i]=y.useState(null);if(t.length===0)return null;let a;e[0]!==t.length?(a=r.jsxs(Hr,{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=qa(f.userMessage),h=o===m;return r.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>{i(m),s==null||s(m)},className:K("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?xn(p,50):"(no message)"}),r.jsx("span",{className:"flex shrink-0 items-center gap-1",children:f.toolCalls.length>0&&r.jsx(Ie,{variant:"secondary",className:"font-normal",children:f.toolCalls.length})})]},MO(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 Xc=new Map;let rc=null,ic=null;async function LO(){try{const n=await _e("/api/usage-cost/rates");if(!n.ok)return Xc;const e=await n.json();return new Map(Object.entries(e.rates??{}))}catch{return Xc}}function DO(){const[n,e]=y.useState(rc??Xc);return y.useEffect(()=>{if(rc!==null)return;let t=!0;return ic??(ic=LO().then(s=>(s.size>0&&(rc=s),ic=null,s))),ic.then(s=>{t&&e(s)}),()=>{t=!1}},[]),n}function zO(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"?xn(e.command,40):e.pattern&&typeof e.pattern=="string"?e.pattern:e.query&&typeof e.query=="string"?xn(e.query,40):e.url&&typeof e.url=="string"?xn(e.url,40):xn(u8(n),40)}function FO(n,e){return n.map(t=>{const s=t.tokenUsage;return!s||t.toolCalls.length===0?0:iI(e,t.model,s)/t.toolCalls.length})}function BO(n,e){const t=new Map;for(let s=0;s<n.length;s++)for(const o of n[s].toolCalls){const i=Zr(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 UO(n){const e=B.c(14),{turns:t,onJumpToTurn:s}=n,o=DO();let i;e[0]!==o||e[1]!==t?(i=FO(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=BO(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(Hr,{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(ct,{children:[r.jsxs(Pt,{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(Ve,{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:cn(g.estimatedCost)}),r.jsx(Ie,{variant:"secondary",className:"font-normal",children:g.count})]})]}),r.jsx(dt,{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,v)=>{const{tc:w,turnIndex:b}=x,j=zO(w);return r.jsx("div",{children:r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>s==null?void 0:s(b,w.id),className:K("h-auto w-full justify-start gap-1 px-1.5 py-0.5 text-left font-mono text-xs font-normal",w.isError?"text-destructive hover:bg-destructive/10":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[w.isError&&r.jsx(un,{className:"size-2.5 shrink-0 text-destructive","data-icon":"inline-start"}),r.jsx("span",{className:"truncate",children:j||w.id.slice(0,8)})]})},`${w.id}-${v}`)}),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 WO(n){const e=B.c(19),{searchInputRef:t}=n,{state:s,dispatch:o}=Ut(),{searchQuery:i,expandAll:a}=s,{actions:l}=st(),{handleToggleExpandAll:c}=l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Session details"}),e[0]=d):d=e[0];const u=a?"Collapse all":"Expand all";let f;e[1]!==a?(f=a?r.jsx(wa,{"data-icon":"inline-start"}):r.jsx(ya,{"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=b=>o({type:"SET_SEARCH_QUERY",value:b.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(rs,{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(Sn,{align:"inline-start",children:r.jsx(tn,{})}),e[13]=x):x=e[13];let v;e[14]!==g?(v=r.jsxs(os,{children:[g,x]}),e[14]=g,e[15]=v):v=e[15];let w;return e[16]!==v||e[17]!==m?(w=r.jsxs("div",{className:"sticky top-0 border-b bg-background px-3 py-3",children:[m,v]}),e[16]=v,e[17]=m,e[18]=w):w=e[18],w}const zb=y.memo(function(e){const t=B.c(48),{onJumpToTurn:s,onToggleServer:o,onServersChanged:i,searchInputRef:a,onLoadSession:l,backgroundAgents:c}=e,{isMobile:d}=Ut(),{session:u,sessionSource:f}=st(),m=u,{turns:p}=m;let h;t[0]!==m.stats.totalCacheCreationTokens||t[1]!==m.stats.totalCacheReadTokens||t[2]!==m.stats.totalInputTokens||t[3]!==m.stats.totalOutputTokens||t[4]!==p.length?(h=[m.stats.totalInputTokens,m.stats.totalOutputTokens,m.stats.totalCacheCreationTokens,m.stats.totalCacheReadTokens,p.length],t[0]=m.stats.totalCacheCreationTokens,t[1]=m.stats.totalCacheReadTokens,t[2]=m.stats.totalInputTokens,t[3]=m.stats.totalOutputTokens,t[4]=p.length,t[5]=h):h=t[5];const g=h.join(":"),x=d?"mobile-scroll w-full flex-1":"w-full";let v;t[6]!==x?(v=K("h-full min-h-0 shrink-0 overflow-y-auto bg-background",x),t[6]=x,t[7]=v):v=t[7];let w;t[8]!==a?(w=a&&r.jsx(WO,{searchInputRef:a}),t[8]=a,t[9]=w):w=t[9];const b=d?"p-4":"p-3";let j;t[10]!==b?(j=K(b),t[10]=b,t[11]=j):j=t[11];let S;t[12]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsxs(Ma,{variant:"line",className:"grid w-full grid-cols-4",children:[r.jsx(En,{value:"activity",children:"Activity"}),r.jsx(En,{value:"agents",children:"Agents"}),r.jsx(En,{value:"cost",children:"Cost"}),r.jsx(En,{value:"issues",children:"Issues"})]}),t[12]=S):S=t[12];let N;t[13]!==s||t[14]!==p?(N=r.jsxs(An,{value:"activity",className:"flex flex-col gap-6 pt-3",children:[r.jsx(OO,{turns:p,onJumpToTurn:s}),r.jsx(UO,{turns:p,onJumpToTurn:s})]}),t[13]=s,t[14]=p,t[15]=N):N=t[15];let C;t[16]!==i||t[17]!==o||t[18]!==m.cwd||t[19]!==p?(C=r.jsx(ex,{cwd:m.cwd,turns:p,onToggleServer:o,onServersChanged:i}),t[16]=i,t[17]=o,t[18]=m.cwd,t[19]=p,t[20]=C):C=t[20];let k;t[21]!==c?(k=c??[],t[21]=c,t[22]=k):k=t[22];let T;t[23]!==l||t[24]!==m||t[25]!==f||t[26]!==k?(T=r.jsx(RO,{session:m,sessionSource:f,bgAgents:k,onLoadSession:l}),t[23]=l,t[24]=m,t[25]=f,t[26]=k,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==C?(E=r.jsxs(An,{value:"agents",className:"flex flex-col gap-6 pt-3",children:[C,T]}),t[28]=T,t[29]=C,t[30]=E):E=t[30];const P=(f==null?void 0:f.dirName)??null,_=(f==null?void 0:f.fileName)??null;let A;t[31]!==g||t[32]!==P||t[33]!==_?(A=r.jsx(An,{value:"cost",className:"pt-3",children:r.jsx(TO,{dirName:P,fileName:_,revision:g})}),t[31]=g,t[32]=P,t[33]=_,t[34]=A):A=t[34];let I;t[35]!==s||t[36]!==p?(I=r.jsx(An,{value:"issues",className:"flex flex-col gap-6 pt-3",children:r.jsx(AO,{turns:p,onJumpToTurn:s})}),t[35]=s,t[36]=p,t[37]=I):I=t[37];let R;t[38]!==E||t[39]!==A||t[40]!==I||t[41]!==j||t[42]!==N?(R=r.jsxs(Ra,{defaultValue:"activity",className:j,children:[S,N,E,A,I]}),t[38]=E,t[39]=A,t[40]=I,t[41]=j,t[42]=N,t[43]=R):R=t[43];let $;return t[44]!==R||t[45]!==v||t[46]!==w?($=r.jsxs("aside",{className:v,children:[w,R]}),t[44]=R,t[45]=v,t[46]=w,t[47]=$):$=t[47],$}),HO="default",qO="tmp-",KO=/^[a-z0-9][a-z0-9_-]{0,39}$/;function VO(n){return KO.test(n)}function GO(n){return n.startsWith(qO)}function Oh(n,e){let t="",s="",o=!0,i=e;for(;i<n.length;i++){const a=n[i],l=n[i+1];if(!s&&/[\s;&|()<>]/.test(a))break;if(a==="\\"&&s!=="'"){if(l===void 0)return null;if(!s||/[$`"\\\n]/.test(l)){l!==`
|
|
129
|
+
`&&(t+=l),i++;continue}}if(a===s){s="";continue}if(!s&&(a==="'"||a==='"')){s=a;continue}if(s!=="'"){if(a==="`"||a==="$"&&/[('"{]/.test(l??""))return null;(a==="$"||!s&&/[*?[{}~]/.test(a))&&(o=!1)}t+=a}return s?null:{value:t,start:e,end:i,literal:o}}function YO(n){const e=[];let t=[],s=0,o=0;const i=()=>({commands:[...e,{words:t,end:n.length,pipeline:s}],complete:!1});for(let a=0;a<n.length;){const l=n[a];if(l==="\\"&&n[a+1]===`
|
|
130
|
+
`){a+=2;continue}if(l==="#"){const u=n.indexOf(`
|
|
131
|
+
`,a);e.push({words:t,end:a,pipeline:s}),t.length>0&&o===0&&s++,t=[],a=u<0?n.length:u;continue}if(/[^\S\n]/.test(l)){a++;continue}if(/[;&|()\n]/.test(l)){const u=n[a+1],f=l==="|"&&u!=="|";if(l==="("&&o++,l===")"&&o--,o<0)return i();e.push({words:t,end:a,pipeline:s}),o===0&&!f&&l!=="("&&l!==")"&&(l!==`
|
|
132
|
+
`||t.length>0)&&s++,t=[],a+=(l==="&"||l==="|")&&(u===l||f&&u==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(a)))return i();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(a));if(c){for(a+=c[0].length;/[^\S\n]/.test(n[a]??"");)a++;const u=Oh(n,a);if(!u||u.end===a)return i();a=u.end;continue}const d=Oh(n,a);if(!d||d.end===a)return i();t.push(d),a=d.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:o===0}}const Zo="agent-browser",XO=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),JO=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),QO=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),ZO=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,eL=/^[A-Za-z_][A-Za-z_\d]*=/;function Fb(n){return n.slice(n.lastIndexOf("/")+1)}function tL(n,e){var s,o;let t=0;for(;t<n.length;){const i=n[t];if(eL.test(e.slice(i.start,i.end))){t++;continue}if(!i.literal||ZO.test(i.value))return null;const a=Fb(i.value);if(a==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=XO.get(a);if(!l)return t;for(t++;(o=n[t])!=null&&o.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function nL(n,e,t){const[s,...o]=n;if(o.some(l=>!l.literal))return null;let i=HO,a=null;for(let l=0;l<o.length;l++){const c=o[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(a!==null)return null;const d=c.value==="--session"?o[++l]:c;if(i=c.value==="--session"?d==null?void 0:d.value:c.value.slice(10),!i||!VO(i)||d!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,d.start)))return null;a={start:c.start,end:d.end}}return{text:Zo+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:i,sessionFlag:a}}function sL(n){var l;const{commands:e,complete:t}=YO(n),s=[],o=e.some(({words:c})=>c.some(({value:d})=>d.includes(Zo)));if(!t)return{invocations:s,ambiguous:o||n.includes(Zo)};const i=new Set(e.filter(({words:c})=>c.some(({value:d})=>d.includes(Zo))).map(({pipeline:c})=>c));let a=!1;for(const{words:c,end:d,pipeline:u}of e){const f=tL(c,n);if(f===null){a||(a=o);continue}if(f<0)continue;const m=Fb(c[f].value);if(m!==Zo){!(JO.has(m)||m==="git"&&QO.has((l=c[f+1])==null?void 0:l.value))&&i.has(u)&&(a=!0);continue}const p=nL(c.slice(f),d,n);p===null?a=!0:s.push(p)}return{invocations:s,ambiguous:a}}function oL(n){return sL(n).invocations}const Lh=120,rL=/(?:^|[._])exec_command$/;function iL(n){return n==="Bash"||rL.test(n)}function aL(n){return k_(n).filter(e=>iL(e.name)).map(e=>Ro(e.input))}function lL(n){for(const e of aL(n)){const[t]=oL(e);if(t===void 0||GO(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>Lh?`${s.slice(0,Lh-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function cL(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let o=s.length-1;o>=0;o--){const i=lL(s[o]);if(i)return i}}return null}const Dh=1e4,dL=y.lazy(()=>qe(()=>import("./ProjectFilesPanel-BURFV70d.js"),__vite__mapDeps([30,1,31,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),uL=y.lazy(()=>qe(()=>import("./WorktreePanel-psgNQDIs.js"),__vite__mapDeps([32,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),fL=y.lazy(()=>qe(()=>import("./index-CriFWu3H.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function Qu(){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(Ze,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function mL(n){const e=B.c(6),{context:t,closePanel:s}=n,o=Fu(),i=o.projectFilesRoot??t.projectPath;if(!i)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Qu,{}),e[0]=a):a=e[0];let l;return e[1]!==s||e[2]!==i||e[3]!==o.addProjectContext||e[4]!==o.projectFilesRequest?(l=r.jsx(y.Suspense,{fallback:a,children:r.jsx(dL,{cwd:i,onClose:s,onAddToPrompt:o.addProjectContext,openRequest:o.projectFilesRequest},i)}),e[1]=s,e[2]=i,e[3]=o.addProjectContext,e[4]=o.projectFilesRequest,e[5]=l):l=e[5],l}function pL(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(tA,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function hL(){const n=B.c(7),e=Fu();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(zb,{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 gL(n){const e=B.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=r.jsx(Qu,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=r.jsx(y.Suspense,{fallback:t,children:r.jsx(fL,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function xL(n){var d;const e=B.c(8),{context:t}=n,[,s]=y.useState(0);let o;e[0]!==t.session?(o=Date.parse(((d=cL(t.session))==null?void 0:d.timestamp)??""),e[0]=t.session,e[1]=o):o=e[1];const i=o;let a;e[2]!==i||e[3]!==s?(a=()=>{const u=i+Dh-Date.now();if(Number.isNaN(u)||u<=0)return;const f=setTimeout(()=>s(bL),u);return()=>clearTimeout(f)},e[2]=i,e[3]=s,e[4]=a):a=e[4];let l;if(e[5]!==i?(l=[i],e[5]=i,e[6]=l):l=e[6],y.useEffect(a,l),Number.isNaN(i)||Date.now()-i>=Dh)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500 motion-safe:animate-pulse"}),e[7]=c):c=e[7],c}function bL(n){return n+1}function vL(n){const e=B.c(8),{closePanel:t}=n,s=Fu();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Qu,{}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(i=r.jsx(y.Suspense,{fallback:o,children:r.jsx(uL,{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 yL={id:lo,workspacePanels:[{id:"worktrees",title:"Worktrees",icon:$n,component:vL,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:$w,component:mL,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:Yi,component:gL,indicator:xL,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles},{id:"file-changes",title:"File changes",icon:Rr,component:pL,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:Iw,component:hL,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},wL=PP([yL,...pO]);function al(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 bg-gradient-to-t from-background via-background/70 to-transparent pt-4",children:r.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-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 pb-3",children:s})}),e[2]=s,e[3]=o):o=e[3],o}function Bb(n){const e=B.c(11),{projectPath:t}=n;let s;e[0]!==t?(s=t?Yn(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:Ca(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 jL(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K(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 SL(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 zh(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 NL(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=j1,s="a",o=w1({className:K("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 kL(n){const e=B.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=K("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 CL(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=K("[&>svg]:size-3.5",s),e[4]=s,e[5]=i):i=e[5];let a;e[6]!==t?(a=t??r.jsx(Ve,{}),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 Ub(n){const e=B.c(56),{children:t,sessionLabel:s,customName:o,onDuplicate:i,onDelete:a,onRename:l,onArchive:c,onUnarchive:d,archiveDisabled:u}=n,f=u===void 0?!1:u,[m,p]=y.useState(!1),[h,g]=y.useState(!1),[x,v]=y.useState(""),w=y.useRef(null);let b;e[0]!==o?(b=function(){v(o||""),g(!0),requestAnimationFrame(()=>{var q;return(q=w.current)==null?void 0:q.select()})},e[0]=o,e[1]=b):b=e[1];const j=b;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx("div",{className:"w-full"}),e[2]=S):S=e[2];let N;e[3]!==t?(N=r.jsx(Ya,{render:S,children:t}),e[3]=t,e[4]=N):N=e[4];let C;e[5]!==f||e[6]!==c||e[7]!==i||e[8]!==l||e[9]!==d||e[10]!==j?(C=(l||i||c||d)&&r.jsxs(Ms,{children:[l&&r.jsxs(Ft,{onClick:j,children:[r.jsx(Us,{"data-icon":"inline-start"}),"Rename session"]}),i&&r.jsxs(Ft,{onClick:i,children:[r.jsx(fn,{"data-icon":"inline-start"}),"Duplicate session"]}),d?r.jsxs(Ft,{onClick:d,children:[r.jsx(W1,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&r.jsxs(Ft,{onClick:c,disabled:f,children:[r.jsx(xs,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=i,e[8]=l,e[9]=d,e[10]=j,e[11]=C):C=e[11];let k;e[12]!==c||e[13]!==a||e[14]!==i||e[15]!==l||e[16]!==d?(k=a&&r.jsxs(r.Fragment,{children:[(i||l||c||d)&&r.jsx(No,{}),r.jsx(Ms,{children:r.jsxs(Ft,{variant:"destructive",onClick:()=>p(!0),children:[r.jsx(ga,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=a,e[14]=i,e[15]=l,e[16]=d,e[17]=k):k=e[17];let T;e[18]!==C||e[19]!==k?(T=r.jsxs(Xa,{className:"min-w-44",children:[C,k]}),e[18]=C,e[19]=k,e[20]=T):T=e[20];let E;e[21]!==N||e[22]!==T?(E=r.jsxs(Ga,{children:[N,T]}),e[21]=N,e[22]=T,e[23]=E):E=e[23];let P;e[24]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(Kd,{children:"Delete session?"}),e[24]=P):P=e[24];let _;e[25]!==s?(_=r.jsxs(Hd,{children:[P,r.jsxs(Vd,{children:["This will permanently delete"," ",r.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[25]=s,e[26]=_):_=e[26];let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(Yd,{size:"sm",children:"Cancel"}),e[27]=A):A=e[27];let I;e[28]!==a?(I=r.jsxs(qd,{children:[A,r.jsx(Gd,{variant:"destructive",size:"sm",onClick:()=>{a==null||a(),p(!1)},children:"Delete"})]}),e[28]=a,e[29]=I):I=e[29];let R;e[30]!==_||e[31]!==I?(R=r.jsxs(Wd,{children:[_,I]}),e[30]=_,e[31]=I,e[32]=R):R=e[32];let $;e[33]!==m||e[34]!==R?($=r.jsx(Ud,{open:m,onOpenChange:p,children:R}),e[33]=m,e[34]=R,e[35]=$):$=e[35];let M;e[36]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsxs(_s,{children:[r.jsx(ns,{className:"text-foreground",children:"Rename session"}),r.jsx(ss,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=M):M=e[36];let L;e[37]!==l||e[38]!==x?(L=V=>{V.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=L):L=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx(yt,{htmlFor:"session-rename",children:"Session name"}),e[40]=D):D=e[40];let F;e[41]===Symbol.for("react.memo_cache_sentinel")?(F=V=>v(V.target.value),e[41]=F):F=e[41];let z;e[42]!==x||e[43]!==s?(z=r.jsxs(vt,{children:[D,r.jsx(It,{id:"session-rename",ref:w,value:x,onChange:F,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=z):z=e[44];let O;e[45]===Symbol.for("react.memo_cache_sentinel")?(O=r.jsxs(Pg,{children:[r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),r.jsx(ee,{type:"submit",size:"sm",children:"Save"})]}),e[45]=O):O=e[45];let H;e[46]!==L||e[47]!==z?(H=r.jsxs(ts,{className:"sm:max-w-md",children:[M,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:L,children:[z,O]})]}),e[46]=L,e[47]=z,e[48]=H):H=e[48];let W;e[49]!==h||e[50]!==H?(W=r.jsx(es,{open:h,onOpenChange:g,children:H}),e[49]=h,e[50]=H,e[51]=W):W=e[51];let U;return e[52]!==$||e[53]!==W||e[54]!==E?(U=r.jsxs(r.Fragment,{children:[E,$,W]}),e[52]=$,e[53]=W,e[54]=E,e[55]=U):U=e[55],U}function Wb(n){function e(){try{const a=localStorage.getItem(Ht(n));return a?JSON.parse(a):{}}catch{return{}}}let t=e();const s=new Set;function o(){for(const a of s)a()}function i(){t=e(),o()}return typeof window<"u"&&(window.addEventListener("cogpit-device-changed",i),window.addEventListener("cogpit-identity-changed",i)),{subscribe:a=>(s.add(a),()=>{s.delete(a)}),getSnapshot:()=>t,rename:(a,l)=>{const c={...t},d=l.trim();d?c[a]=d:delete c[a],localStorage.setItem(Ht(n),JSON.stringify(c)),t=c,o()}}}const Jc=Wb("session-custom-names"),Qc=Jc.rename;function Hb(){const n=B.c(2),e=y.useSyncExternalStore(Jc.subscribe,Jc.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:Qc},n[0]=e,n[1]=t):t=n[1],t}function qb(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(Sn,{children:a?r.jsx(tt,{className:"animate-spin","aria-label":"Searching session history"}):r.jsx(tn,{"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(rs,{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(Sn,{align:"inline-end",children:r.jsx(Kr,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:r.jsx(Qe,{})})}),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(os,{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 Kb(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(un,{"aria-hidden":"true"}),i=r.jsx(kt,{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(mt,{children:t}),e[2]=t,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Et,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=r.jsx(Ss,{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(ft,{variant:"destructive",children:[o,i,a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function Vb(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(wt,{}),r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[r.jsx(it,{className:"size-8 shrink-0 rounded-md"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[r.jsx(it,{className:"h-4 w-40 max-w-full"}),i&&r.jsx(it,{className:"h-3 w-72 max-w-full"}),r.jsx(it,{className:"h-3 w-52 max-w-full"})]}),r.jsx(it,{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 Tr(n){return n==="idle"||n==="completed"}function Zu(n){return Tr(n)?"text-success":n==="thinking"||n==="deferred"?"text-warning":"text-info"}const Os={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},_L=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,TL=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,EL=/(?:^|\s)#(\d+)(?=\s|$)/,AL=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Mi(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function PL(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 Gb(n){const e=n.trim();if(!e)return null;const t=_L.exec(e);if(t){const l=Mi(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=TL.exec(e);if(s){const l=Mi(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const o=EL.exec(e);if(o){const l=Mi(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:PL(c)}}const i=AL.exec(e);if(!i)return null;const a=Mi(i[1]);return a===null?null:{number:a,repoHint:null}}function Fh(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function $L(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 IL(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Fh(n.repo,s):Fh(n.repo,s)?!0:t.some(o=>$L(o,s)):!0}function Yb(n,e,t=[]){var i;const s=Gb(e);if(s){const a=[n.cwd,n.projectShortName,...t];return((i=n.pullRequests)==null?void 0:i.some(l=>IL(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 RL=120*1e3;function Xb(n){return n?Date.now()-new Date(n).getTime()<RL:!1}function Jb(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?xn(s,70):xn(n.sessionId,16)}function Bh(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function ML(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Bh(t)===Bh(e)?null:xn(t,220)}function OL(n,e){return Yb(n,e)}function LL(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Rn(t):null}function DL(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(`
|
|
133
|
+
`)}function zL(n){var t;const e=n.cwd?(t=_a(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:Rw,label:e,title:n.cwd}:n.gitBranch?{icon:$n,label:n.gitBranch}:null}function FL(n,e){return n.agentStatus==="deferred"?"attention":e?Tr(n.agentStatus)?"idle":"working":null}function BL(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(Ie,{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=Tr(t.agentStatus);let i;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(i=ei(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=Zu(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=K("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(Ie,{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=Au(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=o):o=e[17];let i;return e[18]!==o?(i=r.jsx(Ie,{variant:"outline",className:"max-w-44 truncate text-warning",children:o}),e[18]=o,e[19]=i):i=e[19],i}return null}function ac(n){const e=B.c(9),{icon:t,title:s,className:o,children:i}=n;let a;e[0]!==o?(a=K("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 UL(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=Xb(i),l=FL(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,v,w,b,j,S,N,C;if(e[4]!==s||e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==o||e[9]!==t||e[10]!==d){const M=zL(t);let L;e[25]!==i||e[26]!==t.timestamp?(L=LL(t.timestamp,i),e[25]=i,e[26]=t.timestamp,e[27]=L):L=e[27];const D=L,F=t.turnCount??0;let z,O;e[28]!==s||e[29]!==t?(O=Jb(t,s),z=ML(t,O),e[28]=s,e[29]=t,e[30]=z,e[31]=O):(z=e[30],O=e[31]);const H=z;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=DL(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 W;e[34]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsx(hc,{className:"size-4"}),e[34]=W):W=e[34];let U;e[35]!==c?(U=c&&r.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:K("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Os[c])}),e[35]=c,e[36]=U):U=e[36],e[37]!==U?(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:[W,U]}),e[37]=U,e[38]=h):h=e[38],S="flex min-w-0 flex-1 flex-col gap-1";let V;e[39]!==O?(V=r.jsx("span",{className:"truncate text-sm font-medium",children:O}),e[39]=O,e[40]=V):V=e[40];let q;e[41]!==d?(q=d&&r.jsxs(Ie,{variant:"outline",className:"shrink-0",children:[r.jsx(ur,{"data-icon":"inline-start"}),xn(d,18)]}),e[41]=d,e[42]=q):q=e[42];let X;e[43]!==t.branchedFrom?(X=t.branchedFrom&&r.jsxs(Ie,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[r.jsx(vd,{"data-icon":"inline-start"}),"branch"]}),e[43]=t.branchedFrom,e[44]=X):X=e[44];let G;e[45]!==a||e[46]!==t?(G=r.jsx(BL,{session:t,live:a}),e[45]=a,e[46]=t,e[47]=G):G=e[47];let Y;e[48]!==i?(Y=i&&r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Dr(i)}),e[48]=i,e[49]=Y):Y=e[49];let J;e[50]!==G||e[51]!==Y?(J=r.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[G,Y]}),e[50]=G,e[51]=Y,e[52]=J):J=e[52],e[53]!==V||e[54]!==q||e[55]!==X||e[56]!==J?(N=r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[V,q,X,J]}),e[53]=V,e[54]=q,e[55]=X,e[56]=J,e[57]=N):N=e[57],e[58]!==H?(C=H&&r.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:H}),e[58]=H,e[59]=C):C=e[59],x="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[60]!==t.model?(v=t.model&&r.jsx(Ie,{variant:"outline",children:Ks(t.model)}),e[60]=t.model,e[61]=v):v=e[61],e[62]!==F?(w=F>0&&r.jsxs(ac,{icon:hc,children:[F," ",F===1?"turn":"turns"]}),e[62]=F,e[63]=w):w=e[63],e[64]!==D?(b=D&&r.jsx(ac,{icon:Ls,title:"First prompt to last activity",children:D}),e[64]=D,e[65]=b):b=e[65],j=M&&r.jsx(ac,{icon:M.icon,className:"max-w-40 truncate",title:M.title,children:xn(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]=v,e[19]=w,e[20]=b,e[21]=j,e[22]=S,e[23]=N,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],v=e[18],w=e[19],b=e[20],j=e[21],S=e[22],N=e[23],C=e[24];let k;e[66]!==t.size?(k=mg(t.size),e[66]=t.size,e[67]=k):k=e[67];let T;e[68]!==k?(T=r.jsx("span",{children:k}),e[68]=k,e[69]=T):T=e[69];let E;e[70]!==T||e[71]!==x||e[72]!==v||e[73]!==w||e[74]!==b||e[75]!==j?(E=r.jsxs("span",{className:x,children:[v,w,b,j,T]}),e[70]=T,e[71]=x,e[72]=v,e[73]=w,e[74]=b,e[75]=j,e[76]=E):E=e[76];let P;e[77]!==E||e[78]!==S||e[79]!==N||e[80]!==C?(P=r.jsxs("span",{className:S,children:[N,C,E]}),e[77]=E,e[78]=S,e[79]=N,e[80]=C,e[81]=P):P=e[81];let _;e[82]!==u||e[83]!==f||e[84]!==m||e[85]!==p||e[86]!==h||e[87]!==P?(_=r.jsxs("button",{type:u,onClick:f,title:m,className:p,children:[h,P]}),e[82]=u,e[83]=f,e[84]=m,e[85]=p,e[86]=h,e[87]=P,e[88]=_):_=e[88];let A;e[89]!==t.matchedPullRequestNumber||e[90]!==t.pullRequests?(A=t.matchedPullRequestNumber?r.jsxs(Ie,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(sl,{pullRequests:t.pullRequests,max:2,compact:!0}),e[89]=t.matchedPullRequestNumber,e[90]=t.pullRequests,e[91]=A):A=e[91];let I;e[92]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Ve,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[92]=I):I=e[92];let R;e[93]!==A?(R=r.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[A,I]}),e[93]=A,e[94]=R):R=e[94];let $;return e[95]!==g||e[96]!==_||e[97]!==R?($=r.jsxs("div",{className:g,children:[_,R]}),e[95]=g,e[96]=_,e[97]=R,e[98]=$):$=e[98],$}function WL(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:v,loadMoreSessions:w}=n,{names:b,rename:j}=Hb();let S;e[0]!==t.path?(S=Yn(t.path),e[0]=t.path,e[1]=S):S=e[1];const N=S;let C;e[2]!==x?(C=r.jsx(zh,{children:r.jsx(NL,{render:r.jsx("button",{type:"button",onClick:x}),children:"Projects"})}),e[2]=x,e[3]=C):C=e[3];let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(CL,{}),e[4]=k):k=e[4];let T;e[5]!==N?(T=r.jsx(zh,{className:"min-w-0",children:r.jsx(kL,{className:"truncate",children:N})}),e[5]=N,e[6]=T):T=e[6];let E;e[7]!==C||e[8]!==T?(E=r.jsx(jL,{children:r.jsxs(SL,{children:[C,k,T]})}),e[7]=C,e[8]=T,e[9]=E):E=e[9];let P;e[10]!==N?(P=r.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:N}),e[10]=N,e[11]=P):P=e[11];let _;e[12]!==o?(_=r.jsx(Ie,{variant:"secondary",children:o}),e[12]=o,e[13]=_):_=e[13];let A;e[14]!==P||e[15]!==_?(A=r.jsxs("div",{className:"flex items-center gap-2",children:[P,_]}),e[14]=P,e[15]=_,e[16]=A):A=e[16];let I;e[17]!==t.path?(I=Ca(t.path),e[17]=t.path,e[18]=I):I=e[18];let R;e[19]!==I?(R=r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:I}),e[19]=I,e[20]=R):R=e[20];let $;e[21]!==R||e[22]!==A?($=r.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[A,R]}),e[21]=R,e[22]=A,e[23]=$):$=e[23];let M;e[24]!==l||e[25]!==a||e[26]!==c?(M=r.jsx(qb,{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 L;e[28]!==p||e[29]!==m||e[30]!==t.dirName||e[31]!==t.path?(L=m&&r.jsxs(ee,{size:"sm",disabled:p,onClick:()=>m(t.dirName,t.path),children:[p?r.jsx(Ze,{"data-icon":"inline-start"}):r.jsx(In,{"data-icon":"inline-start"}),"New Session"]}),e[28]=p,e[29]=m,e[30]=t.dirName,e[31]=t.path,e[32]=L):L=e[32];let D;e[33]!==M||e[34]!==L?(D=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,L]}),e[33]=M,e[34]=L,e[35]=D):D=e[35];let F;e[36]!==u||e[37]!==v?(F=u&&r.jsx(Kb,{message:u,onRetry:v}),e[36]=u,e[37]=v,e[38]=F):F=e[38];let z;e[39]!==d||e[40]!==w||e[41]!==g||e[42]!==h||e[43]!==f||e[44]!==j||e[45]!==l||e[46]!==a||e[47]!==t.dirName||e[48]!==b||e[49]!==s||e[50]!==i||e[51]!==o?(z=(i||a)&&d.length===0?r.jsx(Vb,{includeMessagePlaceholder:!0}):d.length===0?r.jsx(Gt,{className:"min-h-72 border",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(ja,{})}),r.jsx(Xt,{children:l?"No sessions match your search":"No sessions yet"}),r.jsx(sn,{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((W,U)=>r.jsxs(y.Fragment,{children:[U>0&&r.jsx(wt,{}),r.jsx(Ub,{sessionLabel:Jb(W),customName:b[W.sessionId],onRename:V=>j(W.sessionId,V),onDuplicate:h?()=>h(t.dirName,W.fileName):void 0,onDelete:g?()=>g(t.dirName,W.fileName):void 0,children:r.jsx(UL,{session:W,customName:b[W.sessionId],onSelect:()=>f(t.dirName,W.fileName)})})]},W.fileName))}),s.length<o&&!l&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(ee,{variant:"outline",size:"sm",disabled:i,onClick:w,children:[i&&r.jsx(Ze,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=d,e[40]=w,e[41]=g,e[42]=h,e[43]=f,e[44]=j,e[45]=l,e[46]=a,e[47]=t.dirName,e[48]=b,e[49]=s,e[50]=i,e[51]=o,e[52]=z):z=e[52];let O;e[53]!==D||e[54]!==F||e[55]!==z?(O=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[D,F,z]}),e[53]=D,e[54]=F,e[55]=z,e[56]=O):O=e[56];let H;return e[57]!==$||e[58]!==O||e[59]!==E?(H=r.jsx(zn,{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:[E,$,O]})}),e[57]=$,e[58]=O,e[59]=E,e[60]=H):H=e[60],H}function HL(n){const e=B.c(13),{projectPath:t,fallback:s,className:o}=n,[i,a]=y.useState(null);if(!t||i===t){let m;return e[0]!==s?(m=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=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=K("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 Qb(n){const e=B.c(40),{children:t,projectLabel:s,customName:o,className:i,onRename:a,archivableCount:l,onArchiveIdle:c}=n,d=l===void 0?0:l,[u,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==o?(g=function(){p(o||""),f(!0),requestAnimationFrame(()=>{var D;return(D=h.current)==null?void 0:D.select()})},e[0]=o,e[1]=g):g=e[1];const x=g;let v;e[2]!==i?(v=K("w-full",i),e[2]=i,e[3]=v):v=e[3];let w;e[4]!==v?(w=r.jsx("div",{className:v}),e[4]=v,e[5]=w):w=e[5];let b;e[6]!==t||e[7]!==w?(b=r.jsx(Ya,{render:w,children:t}),e[6]=t,e[7]=w,e[8]=b):b=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Us,{"data-icon":"inline-start"}),e[9]=j):j=e[9];let S;e[10]!==x?(S=r.jsx(Ms,{children:r.jsxs(Ft,{onClick:x,children:[j,"Rename project"]})}),e[10]=x,e[11]=S):S=e[11];let N;e[12]!==d||e[13]!==c?(N=c&&r.jsxs(r.Fragment,{children:[r.jsx(No,{}),r.jsx(Ms,{children:r.jsxs(Ft,{onClick:c,disabled:d===0,children:[r.jsx(xs,{"data-icon":"inline-start"}),d>0?`Archive ${d} idle ${d===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=d,e[13]=c,e[14]=N):N=e[14];let C;e[15]!==S||e[16]!==N?(C=r.jsxs(Xa,{className:"min-w-44",children:[S,N]}),e[15]=S,e[16]=N,e[17]=C):C=e[17];let k;e[18]!==b||e[19]!==C?(k=r.jsxs(Ga,{children:[b,C]}),e[18]=b,e[19]=C,e[20]=k):k=e[20];let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsxs(_s,{children:[r.jsx(ns,{className:"text-foreground",children:"Rename project"}),r.jsx(ss,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=T):T=e[21];let E;e[22]!==a||e[23]!==m?(E=L=>{L.preventDefault(),a(m),f(!1)},e[22]=a,e[23]=m,e[24]=E):E=e[24];let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(yt,{htmlFor:"project-rename",children:"Project name"}),e[25]=P):P=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=L=>p(L.target.value),e[26]=_):_=e[26];let A;e[27]!==s||e[28]!==m?(A=r.jsxs(vt,{children:[P,r.jsx(It,{id:"project-rename",ref:h,value:m,onChange:_,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=A):A=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsxs(Pg,{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[30]=I):I=e[30];let R;e[31]!==E||e[32]!==A?(R=r.jsxs(ts,{className:"sm:max-w-md",children:[T,r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:E,children:[A,I]})]}),e[31]=E,e[32]=A,e[33]=R):R=e[33];let $;e[34]!==u||e[35]!==R?($=r.jsx(es,{open:u,onOpenChange:f,children:R}),e[34]=u,e[35]=R,e[36]=$):$=e[36];let M;return e[37]!==k||e[38]!==$?(M=r.jsxs(r.Fragment,{children:[k,$]}),e[37]=k,e[38]=$,e[39]=M):M=e[39],M}const Zc=Wb("project-custom-names"),qL=Zc.rename;function Zb(){const n=B.c(2),e=y.useSyncExternalStore(Zc.subscribe,Zc.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:qL},n[0]=e,n[1]=t):t=n[1],t}function KL(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)Xb($.lastModified)&&(m[$.dirName]=(m[$.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=Zb();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(L=>{var D;return L.path.toLowerCase().includes(M)||L.shortName.toLowerCase().includes(M)||((D=h[L.dirName])==null?void 0:D.toLowerCase().includes(M))}),e[2]=h,e[3]=t,e[4]=a,e[5]=$}else $=e[5];x=$}const v=x;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[6]=w):w=e[6];let b;e[7]!==t.length?(b=r.jsxs("div",{className:"flex items-center gap-2",children:[w,r.jsx(Ie,{variant:"secondary",children:t.length})]}),e[7]=t.length,e[8]=b):b=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[9]=j):j=e[9];let S;e[10]!==b?(S=r.jsxs("header",{className:"flex flex-col gap-1",children:[b,j]}),e[10]=b,e[11]=S):S=e[11];let N;e[12]!==a||e[13]!==l?(N=r.jsx(qb,{value:a,onChange:l,placeholder:"Filter projects..."}),e[12]=a,e[13]=l,e[14]=N):N=e[14];const C=i&&"animate-spin";let k;e[15]!==C?(k=K(C),e[15]=C,e[16]=k):k=e[16];let T;e[17]!==k?(T=r.jsx(Et,{"data-icon":"inline-start",className:k}),e[17]=k,e[18]=T):T=e[18];let E;e[19]!==f||e[20]!==i||e[21]!==T?(E=r.jsxs(ee,{variant:"outline",size:"sm",onClick:f,disabled:i,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[19]=f,e[20]=i,e[21]=T,e[22]=E):E=e[22];let P;e[23]!==E||e[24]!==N?(P=r.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[N,E]}),e[23]=E,e[24]=N,e[25]=P):P=e[25];let _;e[26]!==c||e[27]!==f||e[28]!==d?(_=c&&!d&&r.jsx(Kb,{message:c,onRetry:f}),e[26]=c,e[27]=f,e[28]=d,e[29]=_):_=e[29];let A;e[30]!==p||e[31]!==v||e[32]!==o||e[33]!==u||e[34]!==h||e[35]!==g||e[36]!==a?(A=o?r.jsx(Vb,{}):v.length===0?r.jsx(Gt,{className:"min-h-72 border",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(bo,{})}),r.jsx(Xt,{children:a?"No projects match your search":"No projects yet"}),r.jsx(sn,{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:v.map(($,M)=>{const L=p[$.dirName]||0,D=h[$.dirName],F=O4(At($.dirName));return r.jsxs(y.Fragment,{children:[M>0&&r.jsx(wt,{}),r.jsx(Qb,{projectLabel:Yn($.path),customName:D,onRename:z=>g($.dirName,z),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(HL,{projectPath:$.path,className:"size-4",fallback:r.jsx(bo,{className:"size-4 text-muted-foreground"})})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-medium",children:D||Yn($.path)}),F&&r.jsx(Ie,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:F})]}),r.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:Ca($.path)})]})]}),r.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[L>0&&r.jsxs(Ie,{variant:"secondary",children:[r.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),L," active"]}),r.jsxs("span",{className:"whitespace-nowrap",children:[$.sessionCount," ",$.sessionCount===1?"session":"sessions"]}),$.lastModified&&r.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Dr($.lastModified)}),r.jsx(Ve,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})})]},$.dirName)})}),e[30]=p,e[31]=v,e[32]=o,e[33]=u,e[34]=h,e[35]=g,e[36]=a,e[37]=A):A=e[37];let I;e[38]!==P||e[39]!==_||e[40]!==A?(I=r.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[P,_,A]}),e[38]=P,e[39]=_,e[40]=A,e[41]=I):I=e[41];let R;return e[42]!==I||e[43]!==S?(R=r.jsx(zn,{className:"h-full",children:r.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[S,I]})}),e[42]=I,e[43]=S,e[44]=R):R=e[44],R}const VL=250,GL=400,Uh={results:null,loading:!1,error:null};function ev(n,e){const t=y.useMemo(()=>Gb(n),[n]),[s,o]=y.useState(0),[i,a]=y.useState(Uh);y.useEffect(()=>{if(!t){a(Uh);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 _e(`/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()},GL);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()},VL);return()=>{clearTimeout(f),d&&clearTimeout(d),c.abort()}},[e,t,n,s]);const l=y.useCallback(()=>o(c=>c+1),[]);return{...i,active:t!==null,refresh:l}}const YL=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:o,onSelectProject:i,onDuplicateSession:a,onDeleteSession:l}){const[c]=y.useState(()=>({projects:ra(Vn.projects),activeSessions:ra(Vn.activeSessions)})),[d,u]=y.useState(c.projects??[]),[f,m]=y.useState(c.activeSessions??[]),[p,h]=y.useState(c.projects===void 0),[g,x]=y.useState(!1),[v,w]=y.useState([]),[b,j]=y.useState(0),[S,N]=y.useState(1),[C,k]=y.useState(!1),[T,E]=y.useState(""),[P,_]=y.useState(null),A=y.useRef(0),I=y.useRef(null),R=y.useCallback(async(W=!1)=>{W&&x(!0);try{const[U,V]=await Promise.all([_e("/api/projects"),_e("/api/active-sessions")]);if(!U.ok||!V.ok)throw new Error("Failed to fetch dashboard data");const q=await U.json(),X=await V.json(),G=Array.isArray(q)?q:[],Y=Array.isArray(X)?X:[];u(G),m(Y),or(Vn.projects,G),or(Vn.activeSessions,Y),_(null)}catch(U){_(U instanceof Error?U.message:"Failed to load data")}finally{h(!1),x(!1)}},[]);y.useEffect(()=>{R()},[R]);const $=y.useCallback(async(W,U=1,V=!1)=>{var Y;const q=++A.current;(Y=I.current)==null||Y.abort();const X=new AbortController;I.current=X;const G=()=>q===A.current;if(k(!0),_(null),!V){const J=nT(W);J?(w(J.sessions),j(J.total),N(1)):w([])}try{const J=await _e(`/api/sessions/${encodeURIComponent(W)}?page=${U}&limit=20`,{signal:X.signal});if(!J.ok)throw new Error(`Failed to load sessions (${J.status})`);const Q=await J.json();if(!G())return;const Z=Array.isArray(Q.sessions)?Q.sessions:[],te=typeof Q.total=="number"?Q.total:Z.length;w(ne=>V?[...ne,...Z]:Z),j(te),N(U),V||sT(W,{sessions:Z,total:te})}catch(J){if(!G()||X.signal.aborted)return;_(J instanceof Error?J.message:"Failed to load sessions")}finally{G()&&(I.current=null,k(!1))}},[]);y.useEffect(()=>{var W;if(!o){A.current+=1,(W=I.current)==null||W.abort(),I.current=null,w([]),j(0),N(1),E(""),k(!1);return}E(""),$(o)},[o,$]),y.useEffect(()=>()=>{var W;A.current+=1,(W=I.current)==null||W.abort()},[]);const M=y.useMemo(()=>{if(!o)return null;const W=d.find(V=>V.dirName===o);if(W)return W;const U=vn(o);return{dirName:o,path:U,shortName:Yn(U),sessionCount:b,lastModified:null}},[o,d,b]),L=y.useCallback(()=>{i==null||i(null)},[i]),D=y.useCallback(()=>{o&&$(o,S+1,!0)},[o,S,$]),F=ev(o?T:"",o??void 0),z=y.useMemo(()=>T?v.filter(W=>OL(W,T)):v,[v,T]),O=F.results??z;function H(W,U){l==null||l(W,U),w(V=>V.filter(q=>q.fileName!==U)),j(V=>V-1)}return M?r.jsx(WL,{selectedProject:M,sessions:v,sessionsTotal:b,sessionsLoading:C,searchLoading:F.loading,searchFilter:T,setSearchFilter:E,filteredSessions:O,fetchError:F.error??P,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:a,onDeleteSession:H,onBack:L,onRetryFetch:()=>{if(F.error){F.refresh();return}_(null),o&&$(o)},loadMoreSessions:D}):r.jsx(KL,{projects:d,activeSessions:f,loading:p,refreshing:g,searchFilter:T,setSearchFilter:E,fetchError:P,selectedProjectDirName:o??null,onSelectProject:i,onRefresh:()=>R(!0)})});async function tv(n,e,t){return(await Dn(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function XL(n,e){return(await Dn(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function JL(n,e,t){return Dd("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function QL(n,e,t){return Dd("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const ZL=3e3,nv=y.createContext(null);async function lc(n,e){try{const t=await _e(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 Vo(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 Oi(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 eD({children:n}){const[e,t]=y.useState(new Map),[s,o]=y.useState(new Map),[i,a]=y.useState(new Map),[l,c]=y.useState(new Map),[d,u]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=y.useCallback(async()=>{const[_,A,I]=await Promise.all([lc("/api/permissions",p),lc("/api/user-questions",h),lc("/api/agent-prompts",g)]);_&&(t(Vo(_.bySession)),u(new Set(Vo(_.plansBySession).keys()))),A&&o(Vo(A.bySession)),I&&(a(Vo(I.elicitationsBySession)),c(Vo(I.dialogsBySession)))},[]);y.useEffect(()=>{const _=()=>{document.visibilityState==="visible"&&x()};_();const A=setInterval(_,ZL);return document.addEventListener("visibilitychange",_),()=>{clearInterval(A),document.removeEventListener("visibilitychange",_)}},[x]);const v=y.useCallback(async(_,A)=>{m(I=>new Set(I).add(_));try{return await A()}finally{m(I=>{const R=new Set(I);return R.delete(_),R}),x()}},[x]),w=y.useCallback((_,A,I)=>v(A,async()=>{await tv(_,A,I).catch(()=>!1)&&(t($=>Oi($,_,M=>M.requestId===A)),p.current="")}),[v]),b=y.useCallback((_,A,I)=>v(A,async()=>{const R=await zd(_,A,I);return R.ok&&(o($=>Oi($,_,M=>M.toolUseId===A)),h.current=""),R}),[v]),j=y.useCallback((_,A,I)=>v(A,async()=>{const R=await JL(_,A,I);return R.ok&&(a($=>Oi($,_,M=>M.requestId===A)),g.current=""),R}),[v]),S=y.useCallback((_,A,I)=>v(A,async()=>{const R=await QL(_,A,I);return R.ok&&(c($=>Oi($,_,M=>M.requestId===A)),g.current=""),R}),[v]),N=y.useMemo(()=>new Set(e.keys()),[e]),C=y.useMemo(()=>new Set(s.keys()),[s]),k=y.useMemo(()=>new Set(i.keys()),[i]),T=y.useMemo(()=>new Set(l.keys()),[l]),E=y.useCallback(()=>{x()},[x]),P=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:i,dialogsBySession:l,awaitingPermission:N,awaitingQuestion:C,awaitingElicitation:k,awaitingDialog:T,awaitingPlan:d,responding:f,respond:w,answerQuestion:b,answerElicitation:j,answerDialog:S,refresh:E}),[e,s,i,l,N,C,k,T,d,f,w,b,j,S,E]);return r.jsx(nv.Provider,{value:P,children:n})}function tD(){const n=y.useContext(nv);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}const Wh=768;function ef(){const n=B.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<Wh:!1);let s,o;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const i=window.matchMedia(`(max-width: ${Wh-1}px)`),a=l=>t(l.matches);return i.addEventListener("change",a),t(i.matches),()=>i.removeEventListener("change",a)},o=[],n[0]=s,n[1]=o):(s=n[0],o=n[1]),y.useEffect(s,o),e}const sv=typeof navigator<"u"&&"vibrate"in navigator;function ed(){sv&&navigator.vibrate(10)}function nD(){sv&&navigator.vibrate(20)}async function sD(n,e){try{return(await Dn("/api/archive-sessions",{sessionIds:n,archived:e})).ok}catch{return!1}}function oD(n){return!!(n.teamName&&n.agentName)}function rD(n,e,t,s,o,i,a){const l=[],c=[];for(const d of gu(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(oD(d))continue;const u=Q0(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||vu.has(d.agentStatus))&&c.push(d)}return{needsYou:l,working:c}}function iD(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 tf(n,e){return n?Bt(n).externalProcesses&&(e==null?void 0:e.managed)===!1:!1}const ov="aw:turnCounts",aD=200,ll=new Map;try{const n=localStorage.getItem(ov);if(n){const e=JSON.parse(n);for(const[t,s]of e)ll.set(t,s)}}catch{}function lD(){try{const n=[...ll.entries()].slice(-aD);localStorage.setItem(ov,JSON.stringify(n))}catch{}}function cD(n,e){ll.set(Ht(n),e),lD()}function dD(n,e){const t=ll.get(Ht(n));return Math.max(t??0,e??0)}function rv(n){const e=B.c(44),{session:t,proc:s,statusLabel:o,customName:i,worktreeName:a}=n,l=i||t.aiTitle,c=t.lastUserMessage||t.firstUserMessage,d=dD(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:K("font-medium",Zu(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(Zn,{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]!==t.archived||e[9]!==t.archivedReason?(p=t.archived&&r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(xs,{className:"size-3"}),J0(t.archivedReason)]}),e[8]=t.archived,e[9]=t.archivedReason,e[10]=p):p=e[10];let h;e[11]!==c?(h=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[11]=c,e[12]=h):h=e[12];let g;e[13]!==t.pullRequests?(g=r.jsx(sl,{pullRequests:t.pullRequests,layout:"list"}),e[13]=t.pullRequests,e[14]=g):g=e[14];let x;e[15]!==t.gitBranch||e[16]!==a?(x=t.gitBranch&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx($n,{className:"size-2.5"}),a?`${t.gitBranch} · ${a}`:t.gitBranch]}),e[15]=t.gitBranch,e[16]=a,e[17]=x):x=e[17];let v;e[18]!==d?(v=d>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(ja,{className:"size-2.5"}),d," ",d===1?"turn":"turns"]}),e[18]=d,e[19]=v):v=e[19];let w;e[20]!==t.size?(w=mg(t.size),e[20]=t.size,e[21]=w):w=e[21];let b;e[22]!==w?(b=r.jsx("span",{children:w}),e[22]=w,e[23]=b):b=e[23];let j;e[24]!==s?(j=s&&r.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[r.jsx(Mw,{className:"size-2.5"}),s.memMB," MB"]}),e[24]=s,e[25]=j):j=e[25];const S=t.lastActivityAt||t.lastModified;let N;e[26]!==S?(N=Dr(S),e[26]=S,e[27]=N):N=e[27];let C;e[28]!==N?(C=r.jsx("span",{children:N}),e[28]=N,e[29]=C):C=e[29];let k;e[30]!==b||e[31]!==j||e[32]!==C||e[33]!==x||e[34]!==v?(k=r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[x,v,b,j,C]}),e[30]=b,e[31]=j,e[32]=C,e[33]=x,e[34]=v,e[35]=k):k=e[35];let T;return e[36]!==u||e[37]!==k||e[38]!==f||e[39]!==m||e[40]!==p||e[41]!==h||e[42]!==g?(T=r.jsxs("div",{className:"flex w-64 flex-col gap-2 text-xs",children:[u,f,m,p,h,g,k]}),e[36]=u,e[37]=k,e[38]=f,e[39]=m,e[40]=p,e[41]=h,e[42]=g,e[43]=T):T=e[43],T}const uD=120;function iv(n){const e=B.c(7),t=y.useRef(null);let s,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},o=[],e[0]=s,e[1]=o):(s=e[0],o=e[1]),y.useEffect(s,o);let i;e[2]!==n?(i=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,uD))},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 fD=6;function mD(n){const e=B.c(7),{iso:t}=n,[,s]=y.useState(0);let o;e[0]!==s?(o=()=>{const c=setInterval(()=>s(pD),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[2]=i):i=e[2],y.useEffect(o,i);let a;e[3]!==t?(a=Dr(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 pD(n){return n+1}const hD={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"}},gD={permission:Os.attention,deferred:Os.attention,waiting:Os.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success"};function Hh(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 v;e[0]!==l||e[1]!==t.dirName?(v=tf(At(t.dirName),l),e[0]=l,e[1]=t.dirName,e[2]=v):v=e[2];const w=v;let b;e[3]!==s||e[4]!==w||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(b=w?"Read-only":ei(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=w,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=b):b=e[9];const j=b,S=!!h&&!w,{onHoverStart:N,onHoverEnd:C}=iv(g),k=x?"px-2.5 py-2":"border px-2 py-2",T=a&&!x&&"ring-1 ring-ring";let E;e[10]!==i||e[11]!==k||e[12]!==T?(E=K("group relative w-full rounded-md text-left transition-colors",k,i,T),e[10]=i,e[11]=k,e[12]=T,e[13]=E):E=e[13];let P;e[14]!==x||e[15]!==a?(P=x&&a&&r.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=x,e[15]=a,e[16]=P):P=e[16];const _=S&&"pr-20";let A;e[17]!==_?(A=K("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",_),e[17]=_,e[18]=A):A=e[18];let I;e[19]!==C||e[20]!==N||e[21]!==m||e[22]!==A?(I=r.jsx("button",{type:"button","data-attention-session":!0,onClick:m,onMouseEnter:N,onMouseLeave:C,onFocus:N,onBlur:C,className:A}),e[19]=C,e[20]=N,e[21]=m,e[22]=A,e[23]=I):I=e[23];const R=x&&"ring-0";let $;e[24]!==o||e[25]!==R?($=K("size-1.5 shrink-0 rounded-full",o,R),e[24]=o,e[25]=R,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 L;e[29]!==d||e[30]!==t?(L=oa(t,d),e[29]=d,e[30]=t,e[31]=L):L=e[31];let D;e[32]!==L?(D=r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:L}),e[32]=L,e[33]=D):D=e[33];const F=x?"text-muted-foreground":s.className;let z;e[34]!==F?(z=K("shrink-0",F),e[34]=F,e[35]=z):z=e[35];const O=w?"Read-only":s.label;let H;e[36]!==z||e[37]!==O?(H=r.jsx(Ie,{variant:"outline",className:z,children:O}),e[36]=z,e[37]=O,e[38]=H):H=e[38];let W;e[39]!==x||e[40]!==t.lastActivityAt||e[41]!==t.lastModified?(W=!x&&r.jsx(mD,{iso:t.lastActivityAt||t.lastModified}),e[39]=x,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=W):W=e[42];let U;e[43]!==M||e[44]!==D||e[45]!==H||e[46]!==W?(U=r.jsxs("span",{className:"flex items-center gap-1.5",children:[M,D,H,W]}),e[43]=M,e[44]=D,e[45]=H,e[46]=W,e[47]=U):U=e[47];let V;e[48]!==u?(V=r.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:u}),e[48]=u,e[49]=V):V=e[49];let q;e[50]!==I||e[51]!==U||e[52]!==V?(q=r.jsxs(_t,{render:I,children:[U,V]}),e[50]=I,e[51]=U,e[52]=V,e[53]=q):q=e[53];let X;e[54]!==d||e[55]!==l||e[56]!==t||e[57]!==j?(X=r.jsx(Tt,{side:"right",className:"max-w-[280px]",children:r.jsx(rv,{session:t,proc:l,statusLabel:j,customName:d})}),e[54]=d,e[55]=l,e[56]=t,e[57]=j,e[58]=X):X=e[58];let G;e[59]!==q||e[60]!==X?(G=r.jsxs(Ct,{children:[q,X]}),e[59]=q,e[60]=X,e[61]=G):G=e[61];let Y;e[62]!==S||e[63]!==h?(Y=S&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:h,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[r.jsx($r,{"data-icon":"inline-start"}),"Resume"]}),e[62]=S,e[63]=h,e[64]=Y):Y=e[64];let J;e[65]!==w||e[66]!==c||e[67]!==p||e[68]!==l?(J=l&&p&&!w&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z=>p(l.pid,Z),disabled:c.has(l.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:r.jsx(Qe,{"data-icon":"inline-start"})}),e[65]=w,e[66]=c,e[67]=p,e[68]=l,e[69]=J):J=e[69];let Q;return e[70]!==G||e[71]!==Y||e[72]!==J||e[73]!==E||e[74]!==P?(Q=r.jsxs("div",{className:E,children:[P,G,Y,J]}),e[70]=G,e[71]=Y,e[72]=J,e[73]=E,e[74]=P,e[75]=Q):Q=e[75],Q}function xD(n){const e=B.c(15),{dotClassName:t,labelClassName:s,label:o,count:i}=n;let a;e[0]!==t?(a=K("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=K("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 bD(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]=y.useState(!1);let h;e[0]!==t.working||e[1]!==m?(h=m?t.working:t.working.slice(0,fD),e[0]=t.working,e[1]=m,e[2]=h):h=e[2];const g=h,x=t.working.length-g.length;let v;e[3]!==l?(v=k=>l[k.dirName]||xu(k.cwd||vn(k.dirName)),e[3]=l,e[4]=v):v=e[4];const w=v;let b;e[5]!==s||e[6]!==i||e[7]!==f||e[8]!==c||e[9]!==o||e[10]!==w||e[11]!==a?(b=k=>{const T=s===`${k.dirName}/${k.fileName}`;return{session:k,isActiveSession:T,proc:o.get(k.sessionId),killingPids:i,customName:a[k.sessionId],projectLabel:w(k),onSelect:()=>c(k.dirName,k.fileName),onPrefetch:f&&!T?()=>f(k.dirName,k.fileName):void 0}},e[5]=s,e[6]=i,e[7]=f,e[8]=c,e[9]=o,e[10]=w,e[11]=a,e[12]=b):b=e[12];const j=b;let S;e[13]!==t.needsYou||e[14]!==d||e[15]!==u||e[16]!==j?(S=t.needsYou.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(xD,{dotClassName:Os.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(k=>{const{session:T,reason:E}=k;return r.jsx(Hh,{...j(T),chip:hD[E],dotClassName:gD[E],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onKill:d,onResume:E==="deferred"&&u?()=>u(T.sessionId,T.cwd,T.dirName):void 0},`${T.dirName}/${T.fileName}`)})]}),e[13]=t.needsYou,e[14]=d,e[15]=u,e[16]=j,e[17]=S):S=e[17];let N;e[18]!==t.working.length||e[19]!==x||e[20]!==d||e[21]!==j||e[22]!==g?(N=t.working.length>0&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center justify-between px-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),r.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),r.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:g.map(k=>r.jsx(Hh,{...j(k),chip:{label:iD(k),className:""},dotClassName:Os.working,cardClassName:"hover:bg-accent/50",compact:!0,onKill:d},`${k.dirName}/${k.fileName}`))}),x>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!0),className:"justify-start",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Show ",x," more"]})]}),e[18]=t.working.length,e[19]=x,e[20]=d,e[21]=j,e[22]=g,e[23]=N):N=e[23];let C;return e[24]!==S||e[25]!==N?(C=r.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[S,N]}),e[24]=S,e[25]=N,e[26]=C):C=e[26],C}function vD(n){const e=B.c(44),{loading:t,isMobile:s,searchQuery:o,searchLoading:i,showArchived:a,archivedCount:l,onSearchQueryChange:c,onToggleShowArchived:d,onRefresh:u}=n,f=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let m;e[0]!==c?(m=M=>c(M.target.value),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==i||e[3]!==o||e[4]!==m?(p=r.jsx(rs,{type:"search",value:o,onChange:m,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]=m,e[5]=p):p=e[5];let h;e[6]!==i?(h=r.jsx(Sn,{align:"inline-start",children:i?r.jsx(tt,{className:"animate-spin"}):r.jsx(tn,{})}),e[6]=i,e[7]=h):h=e[7];let g;e[8]!==c||e[9]!==o?(g=o&&r.jsx(Sn,{align:"inline-end",children:r.jsx(Kr,{size:"icon-xs",onClick:()=>c(""),"aria-label":"Clear session search",children:r.jsx(Qe,{"data-icon":"inline-start"})})}),e[8]=c,e[9]=o,e[10]=g):g=e[10];let x;e[11]!==p||e[12]!==h||e[13]!==g?(x=r.jsxs(os,{children:[p,h,g]}),e[11]=p,e[12]=h,e[13]=g,e[14]=x):x=e[14];const v=s?"icon-sm":"icon-xs",w=a?"Hide archived sessions":"Show archived sessions",b=a&&"bg-accent text-accent-foreground";let j;e[15]!==b?(j=K(b),e[15]=b,e[16]=j):j=e[16];let S;e[17]!==d||e[18]!==a||e[19]!==v||e[20]!==w||e[21]!==j?(S=r.jsx(ee,{variant:"ghost",size:v,onClick:d,"aria-pressed":a,"aria-label":w,className:j}),e[17]=d,e[18]=a,e[19]=v,e[20]=w,e[21]=j,e[22]=S):S=e[22];let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx(xs,{"data-icon":"inline-start"}),e[23]=N):N=e[23];let C;e[24]!==S?(C=r.jsx(_t,{render:S,children:N}),e[24]=S,e[25]=C):C=e[25];const k=a?"Hide archived":"Show archived";let T;e[26]!==f||e[27]!==k?(T=r.jsxs(Tt,{side:"bottom",children:[k," · ",f]}),e[26]=f,e[27]=k,e[28]=T):T=e[28];let E;e[29]!==C||e[30]!==T?(E=r.jsxs(Ct,{children:[C,T]}),e[29]=C,e[30]=T,e[31]=E):E=e[31];const P=s?"icon-sm":"icon-xs",_=t&&"animate-spin";let A;e[32]!==_?(A=K(_),e[32]=_,e[33]=A):A=e[33];let I;e[34]!==A?(I=r.jsx(Et,{"data-icon":"inline-start",className:A}),e[34]=A,e[35]=I):I=e[35];let R;e[36]!==u||e[37]!==P||e[38]!==I?(R=r.jsx(ee,{variant:"ghost",size:P,onClick:u,"aria-label":"Refresh sessions",children:I}),e[36]=u,e[37]=P,e[38]=I,e[39]=R):R=e[39];let $;return e[40]!==E||e[41]!==R||e[42]!==x?($=r.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[x,E,R]}),e[40]=E,e[41]=R,e[42]=x,e[43]=$):$=e[43],$}const yD=["first","second","third","fourth","fifth"];function wD(n){const e=B.c(19),{fetchError:t,showEmpty:s,searching:o,loading:i,sessionCount:a,hiddenArchivedCount:l,onShowArchived:c,onRetry:d}=n,u=s&&!o&&l>0;let f;e[0]!==t||e[1]!==d?(f=t&&r.jsxs(ft,{variant:"destructive",children:[r.jsx(un,{}),r.jsx(kt,{children:"Could not load sessions"}),r.jsx(mt,{className:"truncate",children:t}),r.jsx(Ss,{children:r.jsx(ee,{variant:"outline",size:"xs",onClick:d,children:"Retry"})})]}),e[0]=t,e[1]=d,e[2]=f):f=e[2];let m;e[3]!==u||e[4]!==l||e[5]!==c?(m=u&&r.jsxs(Gt,{className:"min-h-56 px-4 py-8",children:[r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(xs,{})}),r.jsx(Xt,{children:"Everything is archived"}),r.jsx(sn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:c,children:[r.jsx(xs,{"data-icon":"inline-start"}),"Show archived"]})]}),e[3]=u,e[4]=l,e[5]=c,e[6]=m):m=e[6];let p;e[7]!==u||e[8]!==o||e[9]!==s?(p=s&&!u&&r.jsx(Gt,{className:"min-h-56 px-4 py-8",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:o?r.jsx(tn,{}):r.jsx(D1,{})}),r.jsx(Xt,{children:o?"No matching sessions":"No sessions yet"}),r.jsx(sn,{children:o?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[7]=u,e[8]=o,e[9]=s,e[10]=p):p=e[10];let h;e[11]!==i||e[12]!==a?(h=i&&a===0&&r.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:yD.map(jD)}),e[11]=i,e[12]=a,e[13]=h):h=e[13];let g;return e[14]!==f||e[15]!==m||e[16]!==p||e[17]!==h?(g=r.jsxs(r.Fragment,{children:[f,m,p,h]}),e[14]=f,e[15]=m,e[16]=p,e[17]=h,e[18]=g):g=e[18],g}function jD(n){return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(it,{className:"size-2 shrink-0 rounded-full"}),r.jsx(it,{className:"h-4 flex-1"}),r.jsx(it,{className:"h-4 w-10"})]},n)}function SD(n){var $e;const e=B.c(144),{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,onArchiveSession:x,onUnarchiveSession:v,onRenameSession:w,onPrefetchSession:b,onResumeSession:j}=n,S=o!==void 0,N=t.isActive===!0,C=S||N,k=N&&Tr(t.agentStatus),T=t.agentStatus==="deferred";let E;e[0]!==o||e[1]!==t.dirName?(E=tf(At(t.dirName),o),e[0]=o,e[1]=t.dirName,e[2]=E):E=e[2];const P=E,[_,A]=y.useState(!1),I=P?"Read-only":C?k?"Running":ei(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Running":null,R=T?"attention":C?Tr(t.agentStatus)?"idle":"working":null,$=!!(t.teamName&&t.agentName),M=t.archived===!0;let L;e[3]!==t.archivedReason?(L=J0(t.archivedReason),e[3]=t.archivedReason,e[4]=L):L=e[4];const D=L;let F;e[5]!==l||e[6]!==t?(F=oa(t,l),e[5]=l,e[6]=t,e[7]=F):F=e[7];const z=F;let O;e[8]!==M||e[9]!==C||e[10]!==x||e[11]!==v||e[12]!==t?(O=M?v&&{label:"Restore from archive",icon:W1,run:()=>v(t)}:x&&!C&&{label:"Archive session",icon:xs,run:()=>x(t)},e[8]=M,e[9]=C,e[10]=x,e[11]=v,e[12]=t,e[13]=O):O=e[13];const H=O;let W;e[14]!==s||e[15]!==b||e[16]!==t.dirName||e[17]!==t.fileName?(W=b&&!s?()=>b(t.dirName,t.fileName):void 0,e[14]=s,e[15]=b,e[16]=t.dirName,e[17]=t.fileName,e[18]=W):W=e[18];const{onHoverStart:U,onHoverEnd:V}=iv(W);let q;e[19]!==j||e[20]!==_||e[21]!==t.cwd||e[22]!==t.dirName||e[23]!==t.sessionId?(q=we=>{we.stopPropagation(),!(!j||_)&&(A(!0),j(t.sessionId,t.cwd,t.dirName),setTimeout(()=>A(!1),3e3))},e[19]=j,e[20]=_,e[21]=t.cwd,e[22]=t.dirName,e[23]=t.sessionId,e[24]=q):q=e[24];const X=q;let G;e[25]!==S||e[26]!==s||e[27]!==M||e[28]!==N||e[29]!==a||e[30]!==t.agentStatus?(G=K("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",ND(s,!N&&S&&t.agentStatus==="completed"&&!!a),M&&"opacity-60 hover:opacity-100 focus-within:opacity-100"),e[25]=S,e[26]=s,e[27]=M,e[28]=N,e[29]=a,e[30]=t.agentStatus,e[31]=G):G=e[31];const Y=M||void 0,J=Ct,Q=_t;let Z;e[32]!==m||e[33]!==t.dirName||e[34]!==t.fileName?(Z=()=>m(t.dirName,t.fileName),e[32]=m,e[33]=t.dirName,e[34]=t.fileName,e[35]=Z):Z=e[35];let te;e[36]!==V||e[37]!==U||e[38]!==Z?(te=r.jsx("button",{type:"button","data-live-session":!0,onClick:Z,onMouseEnter:U,onMouseLeave:V,onFocus:U,onBlur:V,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[36]=V,e[37]=U,e[38]=Z,e[39]=te):te=e[39];let ne;e[40]!==R?(ne=R&&r.jsx("span",{"data-status-dot":R,className:K("size-1.5 rounded-full",Os[R])}),e[40]=R,e[41]=ne):ne=e[41];let oe;e[42]!==ne?(oe=r.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:ne}),e[42]=ne,e[43]=oe):oe=e[43];let re;e[44]!==z?(re=r.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:z}),e[44]=z,e[45]=re):re=e[45];let ie;e[46]!==$||e[47]!==t.agentName||e[48]!==z?(ie=$&&r.jsxs(Ie,{variant:"outline",children:[r.jsx(ur,{"data-icon":"inline-start"}),z!==t.agentName?t.agentName:"Agent"]}),e[46]=$,e[47]=t.agentName,e[48]=z,e[49]=ie):ie=e[49];const se=C&&!T&&I&&r.jsx(Ie,{variant:"secondary","data-session-live-state":!0,className:K("shrink-0",k&&"text-success",!k&&Zu(t.agentStatus)),children:I});let de;e[50]!==T?(de=T&&r.jsx(Ie,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[50]=T,e[51]=de):de=e[51];let ce;e[52]!==c?(ce=c&&r.jsxs(Ie,{variant:"outline",children:[r.jsx($n,{"data-icon":"inline-start"}),c]}),e[52]=c,e[53]=ce):ce=e[53];let ue;e[54]!==Q||e[55]!==te||e[56]!==oe||e[57]!==re||e[58]!==ie||e[59]!==se||e[60]!==de||e[61]!==ce?(ue=r.jsxs(Q,{render:te,children:[oe,re,ie,se,de,ce]}),e[54]=Q,e[55]=te,e[56]=oe,e[57]=re,e[58]=ie,e[59]=se,e[60]=de,e[61]=ce,e[62]=ue):ue=e[62];let me;e[63]!==l||e[64]!==o||e[65]!==t||e[66]!==I||e[67]!==c?(me=r.jsx(Tt,{side:"right",className:"max-w-[280px]",children:r.jsx(rv,{session:t,proc:o,statusLabel:I,customName:l,worktreeName:c})}),e[63]=l,e[64]=o,e[65]=t,e[66]=I,e[67]=c,e[68]=me):me=e[68];let fe;e[69]!==J||e[70]!==ue||e[71]!==me?(fe=r.jsxs(J,{children:[ue,me]}),e[69]=J,e[70]=ue,e[71]=me,e[72]=fe):fe=e[72];let ae;e[73]!==f||e[74]!==d||e[75]!==u?(ae=!!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(Zn,{"data-icon":"inline-start"}),d,r.jsx(Ve,{"data-icon":"inline-end",className:K("transition-transform duration-150",!u&&"rotate-90")})]}),e[73]=f,e[74]=d,e[75]=u,e[76]=ae):ae=e[76];let ve;e[77]!==X||e[78]!==T||e[79]!==P||e[80]!==j||e[81]!==_?(ve=T&&j&&!P&&r.jsxs(ee,{type:"button",variant:"outline",size:"xs",onClick:X,disabled:_,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[77]=X,e[78]=T,e[79]=P,e[80]=j,e[81]=_,e[82]=ve):ve=e[82];let ge;e[83]!==t.matchedPullRequestNumber||e[84]!==t.pullRequests?(ge=t.matchedPullRequestNumber?r.jsxs(Ie,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):r.jsx(sl,{pullRequests:t.pullRequests,max:1,compact:!0}),e[83]=t.matchedPullRequestNumber,e[84]=t.pullRequests,e[85]=ge):ge=e[85];let ye;e[86]!==D||e[87]!==M?(ye=M&&r.jsx(xs,{className:"size-3 shrink-0 text-muted-foreground","aria-label":D,role:"img"}),e[86]=D,e[87]=M,e[88]=ye):ye=e[88];const Pe=t.lastActivityAt||t.lastModified;let De;e[89]!==Pe?(De=Dr(Pe),e[89]=Pe,e[90]=De):De=e[90];let Te;e[91]!==De?(Te=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:De}),e[91]=De,e[92]=Te):Te=e[92];let Ae;e[93]!==H?(Ae=H&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:we=>{we.stopPropagation(),H.run()},className:"absolute right-0 top-0 bg-background/80 text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:H.label,"aria-label":H.label,children:r.jsx(H.icon,{"data-icon":"inline-start"})}),e[93]=H,e[94]=Ae):Ae=e[94];let pe;e[95]!==S||e[96]!==P||e[97]!==i||e[98]!==p||e[99]!==o?(pe=S&&p&&!P&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",onClick:we=>p(o.pid,we),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(Qe,{"data-icon":"inline-start"})}),e[95]=S,e[96]=P,e[97]=i,e[98]=p,e[99]=o,e[100]=pe):pe=e[100];let xe;e[101]!==fe||e[102]!==ae||e[103]!==ve||e[104]!==ge||e[105]!==ye||e[106]!==Te||e[107]!==Ae||e[108]!==pe||e[109]!==G||e[110]!==Y?(xe=r.jsxs("div",{className:G,"data-archived":Y,children:[fe,ae,ve,ge,ye,Te,Ae,pe]}),e[101]=fe,e[102]=ae,e[103]=ve,e[104]=ge,e[105]=ye,e[106]=Te,e[107]=Ae,e[108]=pe,e[109]=G,e[110]=Y,e[111]=xe):xe=e[111];const ke=xe;if(h||g||w||x||v){let we;e[112]!==t.firstUserMessage||e[113]!==t.sessionId||e[114]!==t.slug?(we=t.slug||(($e=t.firstUserMessage)==null?void 0:$e.slice(0,30))||t.sessionId.slice(0,12),e[112]=t.firstUserMessage,e[113]=t.sessionId,e[114]=t.slug,e[115]=we):we=e[115];let be;e[116]!==h||e[117]!==t.dirName||e[118]!==t.fileName?(be=h?()=>h(t.dirName,t.fileName):void 0,e[116]=h,e[117]=t.dirName,e[118]=t.fileName,e[119]=be):be=e[119];let Le;e[120]!==g||e[121]!==t?(Le=g?()=>g(t):void 0,e[120]=g,e[121]=t,e[122]=Le):Le=e[122];let Se;e[123]!==w||e[124]!==t.sessionId?(Se=w?He=>w(t.sessionId,He):void 0,e[123]=w,e[124]=t.sessionId,e[125]=Se):Se=e[125];let Re;e[126]!==M||e[127]!==x||e[128]!==t?(Re=x&&!M?()=>x(t):void 0,e[126]=M,e[127]=x,e[128]=t,e[129]=Re):Re=e[129];let Ne;e[130]!==M||e[131]!==v||e[132]!==t?(Ne=v&&M?()=>v(t):void 0,e[130]=M,e[131]=v,e[132]=t,e[133]=Ne):Ne=e[133];let Fe;return e[134]!==l||e[135]!==C||e[136]!==ke||e[137]!==we||e[138]!==be||e[139]!==Le||e[140]!==Se||e[141]!==Re||e[142]!==Ne?(Fe=r.jsx(Ub,{sessionLabel:we,customName:l,onDuplicate:be,onDelete:Le,onRename:Se,onArchive:Re,onUnarchive:Ne,archiveDisabled:C,children:ke}),e[134]=l,e[135]=C,e[136]=ke,e[137]=we,e[138]=be,e[139]=Le,e[140]=Se,e[141]=Re,e[142]=Ne,e[143]=Fe):Fe=e[143],Fe}return ke}function ND(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}function kD(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function CD(n){const e=B.c(39),{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:v,onArchiveSession:w,onUnarchiveSession:b,onArchiveSessions:j,onRenameSession:S,onRenameProject:N,onNewSession:C,creatingSession:k,onPrefetchSession:T,onResumeSession:E}=n;let P;e[0]!==l||e[1]!==k||e[2]!==d||e[3]!==u||e[4]!==w||e[5]!==j||e[6]!==v||e[7]!==x||e[8]!==g||e[9]!==C||e[10]!==T||e[11]!==N||e[12]!==S||e[13]!==E||e[14]!==h||e[15]!==p||e[16]!==b||e[17]!==c||e[18]!==m||e[19]!==f?(P={activeSessionKey:l,procBySession:c,killingPids:d,newlyCompleted:u,sessionNames:f,projectNames:m,onToggleCollapsed:p,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:v,onArchiveSession:w,onUnarchiveSession:b,onArchiveSessions:j,onRenameSession:S,onRenameProject:N,onNewSession:C,creatingSession:k,onPrefetchSession:T,onResumeSession:E},e[0]=l,e[1]=k,e[2]=d,e[3]=u,e[4]=w,e[5]=j,e[6]=v,e[7]=x,e[8]=g,e[9]=C,e[10]=T,e[11]=N,e[12]=S,e[13]=E,e[14]=h,e[15]=p,e[16]=b,e[17]=c,e[18]=m,e[19]=f,e[20]=P):P=e[20];const _=P;let A;e[21]!==a?(A=a.trim(),e[21]=a,e[22]=A):A=e[22];const I=!!A;let R;e[23]!==i||e[24]!==I||e[25]!==t||e[26]!==s||e[27]!==o||e[28]!==c||e[29]!==_?(R=[...t.entries()].map((L,D)=>{const[F,z]=L,O=kD(z,c);return y.createElement(qh,{..._,key:F,projectPath:F,sessions:z,liveCount:O,collapsed:i[F]??(D>=3&&O===0),forceExpand:I,pendingSession:s===F?o:void 0})}),e[23]=i,e[24]=I,e[25]=t,e[26]=s,e[27]=o,e[28]=c,e[29]=_,e[30]=R):R=e[30];let $;e[31]!==t||e[32]!==s||e[33]!==o||e[34]!==_?($=s&&!t.has(s)&&o&&y.createElement(qh,{..._,key:`pending-${s}`,projectPath:s,sessions:[],liveCount:0,collapsed:!1,pendingSession:o}),e[31]=t,e[32]=s,e[33]=o,e[34]=_,e[35]=$):$=e[35];let M;return e[36]!==R||e[37]!==$?(M=r.jsxs(r.Fragment,{children:[R,$]}),e[36]=R,e[37]=$,e[38]=M):M=e[38],M}function qh(n){var Ee,Be;const e=B.c(111),{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:v,onArchiveSession:w,onUnarchiveSession:b,onArchiveSessions:j,onRenameSession:S,onRenameProject:N,onNewSession:C,creatingSession:k,pendingSession:T,onPrefetchSession:E,onResumeSession:P}=n,_=p===void 0?!1:p,A=y.useId(),I=!!T,R=_||I?!1:f;let $;e[0]!==s?($=new Set(s.map(TD)),e[0]=s,e[1]=$):$=e[1];const M=$;let L;if(e[2]!==M||e[3]!==s){const le=new Map,he=[];for(const Ue of s){const ze=Ue.teamLeadSessionId;if(ze&&ze!==Ue.sessionId&&M.has(ze)){const Oe=le.get(ze);Oe?Oe.push(Ue):le.set(ze,[Ue])}else he.push(Ue)}L={topLevelSessions:he,teammatesByLead:le},e[2]=M,e[3]=s,e[4]=L}else L=e[4];const{topLevelSessions:D,teammatesByLead:F}=L;let z;e[5]===Symbol.for("react.memo_cache_sentinel")?(z=new Set,e[5]=z):z=e[5];const[O,H]=y.useState(z);let W;e[6]===Symbol.for("react.memo_cache_sentinel")?(W=le=>{H(he=>{const Ue=new Set(he);return Ue.has(le)?Ue.delete(le):Ue.add(le),Ue})},e[6]=W):W=e[6];const U=W,[V,q]=y.useState(!1),X=s.length+(I?1:0);let G,Y;e[7]!==_||e[8]!==I||e[9]!==i||e[10]!==V||e[11]!==D?(G=G7(D,i,Math.max(1,5-(I?1:0))),Y=_||V?D:D.slice(0,G),e[7]=_,e[8]=I,e[9]=i,e[10]=V,e[11]=D,e[12]=G,e[13]=Y):(G=e[12],Y=e[13]);const J=Y,Q=D.length-J.length,Z=V&&!_&&D.length>G,te=((Ee=s.find(_D))==null?void 0:Ee.dirName)??((Be=s[0])==null?void 0:Be.dirName)??(T==null?void 0:T.dirName),ne=te?d[te]:void 0;let oe;if(e[14]!==i||e[15]!==s){let le;e[17]!==i?(le=he=>!he.archived&&!bu(he,i),e[17]=i,e[18]=le):le=e[18],oe=s.filter(le),e[14]=i,e[15]=s,e[16]=oe}else oe=e[16];const re=oe;let ie;e[19]!==o||e[20]!==a||e[21]!==l||e[22]!==w||e[23]!==v||e[24]!==x||e[25]!==g||e[26]!==E||e[27]!==S||e[28]!==P||e[29]!==h||e[30]!==b||e[31]!==i||e[32]!==c?(ie=function(he,Ue,ze){return r.jsx(SD,{session:he,isActiveSession:o===`${he.dirName}/${he.fileName}`,proc:i.get(he.sessionId),killingPids:a,isNewlyCompleted:l.has(he.sessionId),customName:c[he.sessionId],worktreeName:Ue,teammateCount:ze==null?void 0:ze.count,teammatesCollapsed:ze==null?void 0:ze.collapsed,onToggleTeammates:ze==null?void 0:ze.onToggle,onSelectSession:h,onKill:g,onDuplicateSession:x,onDeleteSession:v,onArchiveSession:w,onUnarchiveSession:b,onRenameSession:S,onPrefetchSession:E,onResumeSession:P},`${he.dirName}/${he.fileName}`)},e[19]=o,e[20]=a,e[21]=l,e[22]=w,e[23]=v,e[24]=x,e[25]=g,e[26]=E,e[27]=S,e[28]=P,e[29]=h,e[30]=b,e[31]=i,e[32]=c,e[33]=ie):ie=e[33];const se=ie,de=!R,ce=re.length;let ue;e[34]!==re||e[35]!==j?(ue=j?()=>j(re):void 0,e[34]=re,e[35]=j,e[36]=ue):ue=e[36];let me;e[37]!==te||e[38]!==N?(me=le=>{te&&N&&N(te,le)},e[37]=te,e[38]=N,e[39]=me):me=e[39];let fe;e[40]!==f||e[41]!==m||e[42]!==t?(fe=()=>m(t,!f),e[40]=f,e[41]=m,e[42]=t,e[43]=fe):fe=e[43];const ae=!R,ve=_?"Groups stay expanded while searching":void 0,ge=!R&&"rotate-90";let ye;e[44]!==ge?(ye=K("size-3 shrink-0 text-muted-foreground transition-transform duration-150",ge),e[44]=ge,e[45]=ye):ye=e[45];let Pe;e[46]!==ye?(Pe=r.jsx(Ve,{className:ye}),e[46]=ye,e[47]=Pe):Pe=e[47];const De=ne||t;let Te;e[48]!==De?(Te=r.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:De}),e[48]=De,e[49]=Te):Te=e[49];let Ae;e[50]!==ne||e[51]!==t?(Ae=ne&&r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t}),e[50]=ne,e[51]=t,e[52]=Ae):Ae=e[52];let pe;e[53]!==u?(pe=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(Aa,{className:"size-1.5","aria-hidden":"true"}),u]}),e[53]=u,e[54]=pe):pe=e[54];let xe;e[55]!==X?(xe=r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:X}),e[55]=X,e[56]=xe):xe=e[56];let ke;e[57]!==_||e[58]!==A||e[59]!==fe||e[60]!==ae||e[61]!==ve||e[62]!==Pe||e[63]!==Te||e[64]!==Ae||e[65]!==pe||e[66]!==xe?(ke=r.jsxs("button",{type:"button",onClick:fe,disabled:_,"aria-expanded":ae,"aria-controls":A,title:ve,className:"flex min-w-0 flex-1 items-center gap-1 rounded-md px-1 py-1 text-left transition-colors hover:bg-accent",children:[Pe,Te,Ae,pe,xe]}),e[57]=_,e[58]=A,e[59]=fe,e[60]=ae,e[61]=ve,e[62]=Pe,e[63]=Te,e[64]=Ae,e[65]=pe,e[66]=xe,e[67]=ke):ke=e[67];let $e;e[68]!==k||e[69]!==C||e[70]!==t||e[71]!==s[0]||e[72]!==s.length?($e=C&&s.length>0&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-xs",className:"shrink-0",disabled:k,onClick:le=>{le.stopPropagation();const he=s[0];C(he.dirName,he.cwd??void 0)},"aria-label":`New session in ${t}`,children:k?r.jsx(tt,{"data-icon":"inline-start",className:"animate-spin"}):r.jsx(In,{"data-icon":"inline-start"})}),e[68]=k,e[69]=C,e[70]=t,e[71]=s[0],e[72]=s.length,e[73]=$e):$e=e[73];let we;e[74]!==ke||e[75]!==$e?(we=r.jsxs("div",{className:"flex w-full items-center gap-1 px-2 pb-1 pt-3",children:[ke,$e]}),e[74]=ke,e[75]=$e,e[76]=we):we=e[76];let be;e[77]!==re.length||e[78]!==ne||e[79]!==t||e[80]!==ue||e[81]!==me||e[82]!==we?(be=r.jsx(Qb,{projectLabel:t,customName:ne,className:"sticky top-0 z-20 bg-background",archivableCount:ce,onArchiveIdle:ue,onRename:me,children:we}),e[77]=re.length,e[78]=ne,e[79]=t,e[80]=ue,e[81]=me,e[82]=we,e[83]=be):be=e[83];let Le;e[84]!==T?(Le=T&&r.jsx(ED,{firstMessage:T.firstMessage}),e[84]=T,e[85]=Le):Le=e[85];let Se;if(e[86]!==O||e[87]!==se||e[88]!==F||e[89]!==J){let le;e[91]!==O||e[92]!==se||e[93]!==F?(le=he=>{const Ue=he.cwd??vn(he.dirName),ze=_a(Ue),Oe=F.get(he.sessionId);if(!Oe)return se(he,ze==null?void 0:ze.worktreeName);const Ye=O.has(he.sessionId);return r.jsxs("div",{className:"flex flex-col gap-px",children:[se(he,ze==null?void 0:ze.worktreeName,{count:Oe.length,collapsed:Ye,onToggle:()=>U(he.sessionId)}),!Ye&&r.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:Oe.map(Mt=>se(Mt))})]},`${he.dirName}/${he.fileName}`)},e[91]=O,e[92]=se,e[93]=F,e[94]=le):le=e[94],Se=J.map(le),e[86]=O,e[87]=se,e[88]=F,e[89]=J,e[90]=Se}else Se=e[90];let Re;e[95]!==Q?(Re=Q>0&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>q(!0),className:"justify-start",children:[r.jsx(nt,{"data-icon":"inline-start"}),"Show ",Q," more"]}),e[95]=Q,e[96]=Re):Re=e[96];let Ne;e[97]!==Z?(Ne=Z&&r.jsxs(ee,{type:"button",variant:"ghost",size:"xs",onClick:()=>q(!1),className:"justify-start",children:[r.jsx(Er,{"data-icon":"inline-start"}),"Show less"]}),e[97]=Z,e[98]=Ne):Ne=e[98];let Fe;e[99]!==Le||e[100]!==Se||e[101]!==Re||e[102]!==Ne?(Fe=r.jsxs("div",{className:"flex flex-col gap-px",children:[Le,Se,Re,Ne]}),e[99]=Le,e[100]=Se,e[101]=Re,e[102]=Ne,e[103]=Fe):Fe=e[103];let He;e[104]!==A||e[105]!==Fe?(He=r.jsx(dt,{id:A,className:"ml-3 border-l pl-1",children:Fe}),e[104]=A,e[105]=Fe,e[106]=He):He=e[106];let We;return e[107]!==be||e[108]!==He||e[109]!==de?(We=r.jsxs(ct,{open:de,className:"flex flex-col",children:[be,He]}),e[107]=be,e[108]=He,e[109]=de,e[110]=We):We=e[110],We}function _D(n){return!_a(n.cwd??vn(n.dirName))}function TD(n){return n.sessionId}function ED(n){const e=B.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(tt,{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 AD=y.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:o,onNewSession:i,creatingSession:a,pendingSession:l,refreshRef:c,onPrefetchSession:d}){const{names:u,rename:f}=Hb(),{names:m,rename:p}=Zb(),h=Bd(),g=jn("terminal"),x=jn("killAny"),{sessions:v,procBySession:w,newlyCompleted:b,loading:j,error:S,refresh:N,removeSession:C,acknowledgeCompleted:k,showArchived:T,setShowArchived:E,setSearchActive:P,archivedCount:_,setArchived:A}=r2(),{awaitingPermission:I,awaitingQuestion:R,awaitingElicitation:$,awaitingDialog:M,awaitingPlan:L}=tD(),D=y.useMemo(()=>new Set([...$,...M]),[$,M]),[F,z]=y.useState(new Set),[O,H]=y.useState(""),[W,U]=Io(Ht("live-sessions-collapsed-projects"),{}),V=y.useCallback((pe,xe)=>{U(ke=>({...ke,[pe]:xe}))},[U]),q=!!O.trim(),X=T||q;y.useEffect(()=>(P(q),()=>P(!1)),[q,P]);const G=y.useRef(v),Y=y.useRef(new Set),J=y.useRef(!1),Q=y.useCallback((pe,xe)=>{if(!J.current)return;const ke=setTimeout(()=>{Y.current.delete(ke),J.current&&pe()},xe);Y.current.add(ke)},[]);y.useEffect(()=>{const pe=Y.current;return J.current=!0,()=>{J.current=!1;for(const xe of pe)clearTimeout(xe);pe.clear()}},[]),y.useEffect(()=>{G.current=v},[v]),y.useEffect(()=>{if(c)return c.current=N,()=>{c.current===N&&(c.current=null)}},[N,c]);const Z=ef(),te=ev(O),ne=y.useMemo(()=>K7(v,X),[v,X]),oe=X?0:_,re=y.useMemo(()=>q?ne.filter(pe=>{const xe=u[pe.sessionId],ke=m[pe.dirName];return Yb(pe,O,[xe,ke])}):ne,[ne,q,O,u,m]),ie=te.results??re,se=y.useMemo(()=>V7(ie),[ie]),de=y.useMemo(()=>rD(ne,w,b,I,R,D,L),[ne,w,b,I,R,D,L]),ce=de.needsYou.length>0||de.working.length>0,ue=!q&&ce,me=y.useMemo(()=>l?xu(l.cwd||vn(l.dirName)):null,[l]),fe=y.useRef(!1);y.useEffect(()=>{if(fe.current||!d||v.length===0)return;fe.current=!0;const pe=gu(v).slice(0,3),xe=globalThis,ke=()=>{for(const be of pe)d(be.dirName,be.fileName)};let $e=null,we=null;return typeof xe.requestIdleCallback=="function"?$e=xe.requestIdleCallback(ke,{timeout:1500}):we=setTimeout(ke,300),()=>{$e!=null&&typeof xe.cancelIdleCallback=="function"&&xe.cancelIdleCallback($e),we!=null&&clearTimeout(we)}},[v,d]);const ae=y.useCallback(async(pe,xe)=>{xe.stopPropagation(),z(ke=>new Set(ke).add(pe));try{await _e("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:pe})}),Q(N,1500)}catch{}Q(()=>{z(ke=>{const $e=new Set(ke);return $e.delete(pe),$e})},2e3)},[N,Q]),ve=y.useCallback((pe,xe)=>{const ke=G.current.find($e=>$e.dirName===pe&&$e.fileName===xe);ke&&k(ke.sessionId),t(pe,xe)},[t,k]),ge=y.useCallback(pe=>{o==null||o(pe.dirName,pe.fileName),C(pe.sessionId)},[o,C]),ye=y.useCallback(async(pe,xe,ke)=>{if(A(pe,xe),!await sD(pe,xe)){A(pe,!xe),qn.error(xe?"Could not archive session":"Could not restore session");return}N(),ke&&qn(ke,{action:{label:"Undo",onClick:()=>{ye(pe,!xe,null)}}})},[A,N]),Pe=y.useCallback(pe=>{ye([pe.sessionId],!0,`Archived “${oa(pe,u[pe.sessionId])}”`)},[ye,u]),De=y.useCallback(pe=>{ye([pe.sessionId],!1,`Restored “${oa(pe,u[pe.sessionId])}”`)},[ye,u]),Te=y.useCallback(pe=>{if(pe.length===0)return;const xe=pe.map(ke=>ke.sessionId);ye(xe,!0,`Archived ${xe.length} ${xe.length===1?"session":"sessions"}`)},[ye]),Ae=y.useCallback((pe,xe,ke)=>{const{command:$e,args:we}=nj(At(ke),pe),be=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:be,name:`Resume ${pe.slice(0,8)}`,command:$e,args:we,cwd:xe??void 0,metadata:{type:"terminal"}}),Q(N,3e3)},[h,N,Q]);return r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r.jsx(vD,{loading:j,isMobile:Z,searchQuery:O,searchLoading:te.loading,showArchived:T,archivedCount:_,onSearchQueryChange:H,onToggleShowArchived:()=>E(!T),onRefresh:()=>{nD(),N()}}),r.jsx(zn,{className:"flex-1",children:r.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[r.jsx(wD,{fetchError:te.error??S,showEmpty:ie.length===0&&!l&&!j&&!te.loading&&!S&&!te.error,searching:q,loading:j||te.loading,sessionCount:te.active?ie.length:ne.length,hiddenArchivedCount:oe,onShowArchived:()=>E(!0),onRetry:te.error?te.refresh:N}),ue&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(bD,{groups:de,activeSessionKey:e,procBySession:w,killingPids:F,sessionNames:u,projectNames:m,onSelectSession:ve,onKill:x?ae:void 0,onResumeSession:g?Ae:void 0,onPrefetchSession:d}),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(wt,{className:"flex-1"})]})]}),r.jsx(CD,{grouped:se,pendingProjectPath:me,pendingSession:l,collapsedGroups:W,searchQuery:O,activeSessionKey:e,procBySession:w,killingPids:F,newlyCompleted:b,sessionNames:u,projectNames:m,onToggleCollapsed:V,onSelectSession:ve,onKill:x?ae:void 0,onDuplicateSession:s,onDeleteSession:o?ge:void 0,onArchiveSession:Pe,onUnarchiveSession:De,onArchiveSessions:Te,onRenameSession:f,onRenameProject:p,onNewSession:i,creatingSession:a,onPrefetchSession:d,onResumeSession:g?Ae:void 0})]})})]})}),PD=y.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=K("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(AD,{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 v;return t[12]!==p||t[13]!==g||t[14]!==x?(v=r.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=v):v=t[15],v}),$D=y.lazy(()=>qe(()=>import("./index-CImOF4Hf.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.MissionControl})));function av(n){const e=B.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ze,{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 lv(n){const e=B.c(12),{navigation:t,mobile:s,header:o}=n,i=s===void 0?!1:s,{sessionSource:a}=st(),l=a?`${a.dirName}/${a.fileName}`:null;let c;return e[0]!==l||e[1]!==o||e[2]!==i||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=r.jsx(PD,{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 cv(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(YL,{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 ID(n){const e=B.c(3),{navigation:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(av,{label:"Loading Mission Control…"}),e[0]=s):s=e[0];let o;return e[1]!==t.actions.handleDashboardSelect?(o=r.jsx(y.Suspense,{fallback:s,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:r.jsx($D,{onSelectSession:t.actions.handleDashboardSelect})})}),e[1]=t.actions.handleDashboardSelect,e[2]=o):o=e[2],o}function RD({mainView:n,hasSession:e,pendingDirName:t}){return n==="config"?"config":n==="mission"?"mission":e?"session":t?"pending":"dashboard"}function MD({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function OD({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}
|
|
134
|
+
`:""}${n} (${a})
|
|
135
|
+
${i}
|
|
136
|
+
${e}
|
|
137
|
+
${i}`}const LD=y.lazy(()=>qe(()=>import("./ConfigBrowser-B3IvCBt5.js"),__vite__mapDeps([35,1,2,31,3,4])).then(n=>({default:n.ConfigBrowser}))),DD=y.lazy(()=>qe(()=>import("./PreviewPanel-Bo7DnIca.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.PreviewPanel})));function zD(n){const e=B.c(20),{sessionView:t,floatingChrome:s}=n,{session:o}=st();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(Qa,{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(z0,{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(al,{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 FD(n){const e=B.c(36),{navigation:t,sessionView:s,project:o,view:i,floatingChrome:a}=n,{state:l}=Ut(),{session:c,sessionSource:d}=st();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?vn(l.pendingDirName):null),i==="config"){let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(av,{label:"Loading configuration…"}),e[9]=p):p=e[9];const h=r.jsx(LD,{projectPath:MD({sessionCwd:c==null?void 0:c.cwd,pendingPath:u,sessionDirPath:d!=null&&d.dirName?vn(d.dirName):null,dashboardProjectPath:l.dashboardProject?vn(l.dashboardProject):null}),initialFilePath:l.configFilePath});let g;e[10]!==h?(g=r.jsx(y.Suspense,{fallback:p,children:r.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:h})}),e[10]=h,e[11]=g):g=e[11],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(ID,{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(zD,{sessionView:s,floatingChrome:a}),e[14]=a,e[15]=s,e[16]=p):p=e[16],p}if(i==="pending"){const p=s.pendingTurns.length>0,h=Ds()?"Only on the machine running this session":void 0;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=Qd()?void 0:h,e[17]=g):g=e[17];const x=g,v=!p&&"justify-center gap-4";let w;e[18]!==v?(w=K("flex min-h-0 min-w-0 flex-1 flex-col bg-background",v),e[18]=v,e[19]=w):w=e[19];let b;e[20]!==p||e[21]!==u||e[22]!==s.pendingTurns?(b=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(Bb,{projectPath:u}),e[20]=p,e[21]=u,e[22]=s.pendingTurns,e[23]=b):b=e[23];let j;e[24]!==s.pendingComposer?(j=r.jsx(al,{children:s.pendingComposer}),e[24]=s.pendingComposer,e[25]=j):j=e[25];let S;e[26]!==p||e[27]!==o?(S=!p&&r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[et("terminal")&&r.jsx(Yl,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:o.onOpenTerminal,children:[r.jsx(Ws,{"data-icon":"inline-start"}),"Terminal"]})}),et("hostFiles")&&r.jsxs(r.Fragment,{children:[r.jsx(Yl,{reason:x,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>cx(o.pendingProject),children:[r.jsx(bd,{"data-icon":"inline-start"}),"Open in editor"]})}),r.jsx(Yl,{reason:h,children:r.jsxs(ee,{variant:"outline",size:"xs",disabled:!!h,onClick:()=>dx(o.pendingProject),children:[r.jsx(M1,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[26]=p,e[27]=o,e[28]=S):S=e[28];let N;return e[29]!==w||e[30]!==b||e[31]!==j||e[32]!==S?(N=r.jsxs("div",{className:w,children:[b,j,S]}),e[29]=w,e[30]=b,e[31]=j,e[32]=S,e[33]=N):N=e[33],N}let m;return e[34]!==t?(m=r.jsx(cv,{navigation:t}),e[34]=t,e[35]=m):m=e[35],m}function BD(n){const e=B.c(100),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a,config:l}=Ut(),{session:c,sessionSource:d}=st();let u;e[0]!==s.chatInputRef?(u=function(se){var ce,ue,me;const de=((ce=s.chatInputRef.current)==null?void 0:ce.getText().trimEnd())??"";(ue=s.chatInputRef.current)==null||ue.setText(de?`${de}
|
|
138
|
+
|
|
139
|
+
${se}
|
|
140
|
+
`:`${se}
|
|
141
|
+
`),(me=s.chatInputRef.current)==null||me.focus()},e[0]=s.chatInputRef,e[1]=u):u=e[1];const f=u;let m;e[2]!==f?(m=function(se){const{path:de,text:ce,startLine:ue,endLine:me,comment:fe}=se;f(OD({path:de,text:ce,startLine:ue,endLine:me,comment:fe}))},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=RD({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 v=x,w=t.panels.handleToggleSidebar,b=t.actions.handleGoHome,j=i.onOpenCommandPalette;let S,N;e[8]===Symbol.for("react.memo_cache_sentinel")?(N=Kl("toggleSidebar"),S=Kl("commandPalette"),e[8]=S,e[9]=N):(S=e[8],N=e[9]);let C;e[10]!==i.onOpenCommandPalette||e[11]!==t.actions.handleGoHome||e[12]!==t.panels.handleToggleSidebar?(C=r.jsx(_I,{onToggleSidebar:w,onGoHome:b,onOpenCommandPalette:j,sidebarShortcut:N,commandPaletteShortcut:S}),e[10]=i.onOpenCommandPalette,e[11]=t.actions.handleGoHome,e[12]=t.panels.handleToggleSidebar,e[13]=C):C=e[13];const k=C,T=t.panels.showSidebar&&a.mainView!=="config",E=o.currentCwd??null;let P,_,A;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]!==E?(P={session:c,sessionChangeKey:a.sessionChangeKey,projectPath:E,hasFileChanges:o.hasFileChanges,canAccessHostFiles:et("hostFiles"),supportsWorktrees:o.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:f},A=fb(wL,P),_=a.mainView==="sessions"?A.find(ie=>ie.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]=E,e[23]=P,e[24]=_,e[25]=A):(P=e[23],_=e[24],A=e[25]);const I=_,R=(d==null?void 0:d.dirName)??a.pendingDirName??a.dashboardProject??null;let $;e[26]!==t.panels||e[27]!==o?($=function(se){o.showPreview&&o.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(se)},e[26]=t.panels,e[27]=o,e[28]=$):$=e[28];const M=$;let L;e[29]!==t.actions||e[30]!==t.panels||e[31]!==R?(L=function(se){R&&(t.actions.handleDashboardSelect(R,`${se}.jsonl`),t.panels.closeWorkspacePanel())},e[29]=t.actions,e[30]=t.panels,e[31]=R,e[32]=L):L=e[32];const D=L,F=t.panels.showSidebar;let z;e[33]===Symbol.for("react.memo_cache_sentinel")?(z=Kl("toggleSidebar"),e[33]=z):z=e[33];let O;e[34]!==i.killing||e[35]!==i.onKillAll||e[36]!==l.openConfigDialog||e[37]!==t.creatingSession||e[38]!==t.handlers.handleDuplicateSession||e[39]!==t.onStartNewSession||e[40]!==t.panels.handleToggleSidebar||e[41]!==t.panels.showSidebar||e[42]!==o.onOpenTerminal||e[43]!==s.onBackToMain||e[44]!==s.onShowWorkflows||e[45]!==s.workflowCount||e[46]!==T?(O=r.jsx(NI,{showSidebar:F,sidebarRendered:T,sidebarShortcut:z,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[34]=i.killing,e[35]=i.onKillAll,e[36]=l.openConfigDialog,e[37]=t.creatingSession,e[38]=t.handlers.handleDuplicateSession,e[39]=t.onStartNewSession,e[40]=t.panels.handleToggleSidebar,e[41]=t.panels.showSidebar,e[42]=o.onOpenTerminal,e[43]=s.onBackToMain,e[44]=s.onShowWorkflows,e[45]=s.workflowCount,e[46]=T,e[47]=O):O=e[47];const H=O;let W;e[48]!==t||e[49]!==k||e[50]!==T?(W=T&&r.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:r.jsx(lv,{navigation:t,header:k})}),e[48]=t,e[49]=k,e[50]=T,e[51]=W):W=e[51];const U=I??null,V=o.projectFilesRoot??o.currentCwd??null;let q;e[52]!==p||e[53]!==t.actions.handleJumpToTurn||e[54]!==t.handlers.handleLoadSessionScrollAware||e[55]!==D||e[56]!==o.backgroundAgents||e[57]!==o.processPanel.handleServersChanged||e[58]!==o.processPanel.handleToggleServer||e[59]!==o.projectFilesRequest||e[60]!==o.worktrees||e[61]!==s.searchInputRef||e[62]!==V||e[63]!==R?(q={projectFilesRoot:V,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:R,openWorktreeSession:D},e[52]=p,e[53]=t.actions.handleJumpToTurn,e[54]=t.handlers.handleLoadSessionScrollAware,e[55]=D,e[56]=o.backgroundAgents,e[57]=o.processPanel.handleServersChanged,e[58]=o.processPanel.handleToggleServer,e[59]=o.projectFilesRequest,e[60]=o.worktrees,e[61]=s.searchInputRef,e[62]=V,e[63]=R,e[64]=q):q=e[64];const X=a.mainView==="mission";let G;e[65]!==t.panels.handleToggleMission||e[66]!==X?(G={id:"mission-control",title:"Mission Control",icon:Ow,active:X,onSelect:t.panels.handleToggleMission},e[65]=t.panels.handleToggleMission,e[66]=X,e[67]=G):G=e[67];let Y;e[68]!==t.panels.handleToggleConfig||e[69]!==a.mainView?(Y=et("configWrite")?[{id:"config",title:"Config",icon:Lw,active:a.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[68]=t.panels.handleToggleConfig,e[69]=a.mainView,e[70]=Y):Y=e[70];let J;e[71]!==G||e[72]!==Y?(J=[G,...Y],e[71]=G,e[72]=Y,e[73]=J):J=e[73];const Q=v!=="session"&&H;let Z;e[74]!==H||e[75]!==t||e[76]!==o||e[77]!==s||e[78]!==v?(Z=r.jsx(FD,{navigation:t,sessionView:s,project:o,view:v,floatingChrome:H}),e[74]=H,e[75]=t,e[76]=o,e[77]=s,e[78]=v,e[79]=Z):Z=e[79];let te;e[80]!==Q||e[81]!==Z?(te=r.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[Q,Z]}),e[80]=Q,e[81]=Z,e[82]=te):te=e[82];let ne;e[83]!==t.panels.closeWorkspacePanel||e[84]!==P||e[85]!==U||e[86]!==q||e[87]!==J||e[88]!==te||e[89]!==M||e[90]!==A?(ne=r.jsx(MI,{panels:A,context:P,activePanel:U,services:q,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:M,actions:J,children:te}),e[83]=t.panels.closeWorkspacePanel,e[84]=P,e[85]=U,e[86]=q,e[87]=J,e[88]=te,e[89]=M,e[90]=A,e[91]=ne):ne=e[91];let oe;e[92]!==o.currentCwd||e[93]!==o.onCloseRightWorkspace||e[94]!==o.showPreview?(oe=o.showPreview&&o.currentCwd&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(DD,{cwd:o.currentCwd,onClose:o.onCloseRightWorkspace})}),e[92]=o.currentCwd,e[93]=o.onCloseRightWorkspace,e[94]=o.showPreview,e[95]=oe):oe=e[95];let re;return e[96]!==W||e[97]!==ne||e[98]!==oe?(re=r.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden bg-background",children:[W,ne,oe]}),e[96]=W,e[97]=ne,e[98]=oe,e[99]=re):re=e[99],re}function UD(n){const e=B.c(15),{navigation:t,sessionView:s,project:o,chrome:i}=n;let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(U0,{}),l=r.jsx(B0,{}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let c;e[2]!==i||e[3]!==t||e[4]!==o||e[5]!==s?(c=r.jsx(BD,{navigation:t,sessionView:s,project:o,chrome:i}),e[2]=i,e[3]=t,e[4]=o,e[5]=s,e[6]=c):c=e[6];let d;e[7]!==i||e[8]!==t||e[9]!==o?(d=r.jsx(BP,{navigation:t,project:o,chrome:i}),e[7]=i,e[8]=t,e[9]=o,e[10]=d):d=e[10];let u;return e[11]!==i.backgroundServers||e[12]!==c||e[13]!==d?(u=r.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[i.backgroundServers,a,l,c,d]}),e[11]=i.backgroundServers,e[12]=c,e[13]=d,e[14]=u):u=e[14],u}const WD=[{id:"sessions",label:"Sessions",icon:bo},{id:"chat",label:"Chat",icon:ja},{id:"stats",label:"Stats",icon:L1,requiresSession:!0}],HD=y.memo(function(e){const t=B.c(17),{activeTab:s,onTabChange:o}=e,{session:i,isLive:a}=st(),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=WD.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,v=s===g.id;return r.jsx("button",{type:"button","aria-current":v?"page":void 0,"aria-label":g.label,title:g.label,onClick:()=>{ed(),o(g.id)},className:K("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",v?"text-foreground":"text-muted-foreground hover:text-foreground"),children:r.jsxs("div",{className:K("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",v?"scale-100 bg-accent":"scale-95"),children:[r.jsx(x,{className:K("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",v&&"scale-110"),"aria-hidden":"true"}),g.id==="chat"&&a&&r.jsx(Aa,{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 qD(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 v;e[0]!==l||e[1]!==t.cwd||e[2]!==s?(v=()=>{s&&l(s.dirName,t.cwd)},e[0]=l,e[1]=t.cwd,e[2]=s,e[3]=v):v=e[3];const w=v;let b;e[4]!==o||e[5]!==d?(b=o&&d&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":"Back to main agent",children:r.jsx(hd,{"data-icon":"inline-start"})}),e[4]=o,e[5]=d,e[6]=b):b=e[6];let j,S;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(Lu,{compact:!0}),S=r.jsx(wt,{orientation:"vertical",className:"h-4"}),e[7]=j,e[8]=S):(j=e[7],S=e[8]);let N;e[9]!==i?(N=r.jsx(Lg,{rawMessages:i,warnOnly:!0}),e[9]=i,e[10]=N):N=e[10];let C;e[11]!==t.cwd?(C=t.cwd?Yn(t.cwd):"Session",e[11]=t.cwd,e[12]=C):C=e[12];let k;e[13]!==C?(k=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]=k):k=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Po,{render:r.jsx(ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:r.jsx(O1,{"data-icon":"inline-start"})}),e[15]=T):T=e[15];let E;e[16]!==t.cwd?(E=t.cwd?Yn(t.cwd):"Current session",e[16]=t.cwd,e[17]=E):E=e[17];let P;e[18]!==E?(P=r.jsx("span",{className:"truncate text-foreground",children:E}),e[18]=E,e[19]=P):P=e[19];let _;e[20]!==t.gitBranch||e[21]!==t.model?(_=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[20]=t.gitBranch,e[21]=t.model,e[22]=_):_=e[22];let A;e[23]!==_?(A=r.jsx("span",{className:"truncate font-normal",children:_}),e[23]=_,e[24]=A):A=e[24];let I;e[25]!==P||e[26]!==A?(I=r.jsxs(Og,{className:"flex flex-col gap-0.5",children:[P,A]}),e[25]=P,e[26]=A,e[27]=I):I=e[27];let R;e[28]!==a||e[29]!==w||e[30]!==s?(R=s&&r.jsxs(zt,{onClick:w,disabled:a,children:[a?r.jsx(Ze,{}):r.jsx(In,{}),r.jsx("span",{children:"New session"})]}),e[28]=a,e[29]=w,e[30]=s,e[31]=R):R=e[31];let $;e[32]!==c?($=c&&r.jsxs(zt,{onClick:c,children:[r.jsx(fn,{}),r.jsx("span",{children:"Duplicate session"})]}),e[32]=c,e[33]=$):$=e[33];let M;e[34]!==I||e[35]!==R||e[36]!==$?(M=r.jsxs(Gn,{children:[I,R,$]}),e[34]=I,e[35]=R,e[36]=$,e[37]=M):M=e[37];let L;e[38]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Qi,{}),e[38]=L):L=e[38];let D;e[39]!==h?(D=h&&r.jsxs(zt,{onClick:h,children:[r.jsx(tn,{}),r.jsx("span",{children:"Search conversation"})]}),e[39]=h,e[40]=D):D=e[40];let F;e[41]!==g||e[42]!==x?(F=x&&r.jsxs(zt,{onClick:x,children:[g?r.jsx(wa,{}):r.jsx(ya,{}),r.jsx("span",{children:g?"Collapse tool calls":"Expand tool calls"})]}),e[41]=g,e[42]=x,e[43]=F):F=e[43];let z;e[44]!==f||e[45]!==u?(z=f&&u&&r.jsxs(zt,{onClick:u,children:[r.jsx(Rr,{}),r.jsx("span",{children:"File changes"})]}),e[44]=f,e[45]=u,e[46]=z):z=e[46];let O;e[47]!==m||e[48]!==p?(O=m&&(p??0)>0&&r.jsxs(zt,{onClick:m,children:[r.jsx(jd,{}),r.jsx("span",{className:"flex-1",children:"Workflows"}),r.jsx(Ie,{variant:"secondary",children:p})]}),e[47]=m,e[48]=p,e[49]=O):O=e[49];let H;e[50]!==D||e[51]!==F||e[52]!==z||e[53]!==O?(H=r.jsxs(Gn,{children:[D,F,z,O]}),e[50]=D,e[51]=F,e[52]=z,e[53]=O,e[54]=H):H=e[54];let W;e[55]!==M||e[56]!==H?(W=r.jsxs(Ao,{children:[T,r.jsxs($o,{align:"end",sideOffset:6,className:"w-72",children:[M,L,H]})]}),e[55]=M,e[56]=H,e[57]=W):W=e[57];let U;return e[58]!==b||e[59]!==W||e[60]!==N||e[61]!==k?(U=r.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[b,j,S,N,k,W]}),e[58]=b,e[59]=W,e[60]=N,e[61]=k,e[62]=U):U=e[62],U}const KD=y.memo(function(e){const t=B.c(11),{isMobile:s}=Ut(),{session:o,sessionSource:i}=st();if(!s||!o)return null;let a;t[0]!==i?(a=i?ws(i.fileName):null,t[0]=i,t[1]=a):a=t[1];const l=a;let c;t[2]!==o||t[3]!==(i==null?void 0:i.dirName)?(c=vo(i==null?void 0:i.dirName).contextWindow?o.rawMessages:[],t[2]=o,t[3]=i==null?void 0:i.dirName,t[4]=c):c=t[4];const d=c,u=l!==null;let f;return t[5]!==d||t[6]!==e||t[7]!==o||t[8]!==i||t[9]!==u?(f=r.jsx(qD,{...e,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}),VD=50;function GD({onSwipeLeft:n,onSwipeRight:e}){const t=y.useRef(null),s=y.useRef(null),o=y.useRef(n),i=y.useRef(e);return o.current=n,i.current=e,y.useEffect(()=>{const a=t.current;if(!a)return;function l(d){const u=d.touches[0];s.current={x:u.clientX,y:u.clientY}}function c(d){var p,h;if(!s.current)return;const u=d.changedTouches[0],f=u.clientX-s.current.x,m=u.clientY-s.current.y;s.current=null,!(Math.abs(f)<VD||Math.abs(f)<Math.abs(m))&&(f>0?(p=i.current)==null||p.call(i):(h=o.current)==null||h.call(o))}return a.addEventListener("touchstart",l,{passive:!0}),a.addEventListener("touchend",c,{passive:!0}),()=>{a.removeEventListener("touchstart",l),a.removeEventListener("touchend",c)}},[]),t}const YD=["sessions","chat","stats"];function XD({hasSession:n,hasPendingSession:e}){return YD.filter(t=>!(t==="stats"&&!n&&!e))}function Kh(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}const JD=y.lazy(()=>qe(()=>import("./MobileFileChanges-B2aGoWIm.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function QD(n){const e=B.c(70),{navigation:t,sessionView:s,project:o,chrome:i}=n,{state:a}=Ut(),{session:l,isSubAgentView:c}=st(),[d,u]=y.useState(!1),f=!!l,m=!!a.pendingDirName;let p;e[0]!==f||e[1]!==m?(p=XD({hasSession:f,hasPendingSession:m}),e[0]=f,e[1]=m,e[2]=p):p=e[2];const h=p;let g;e[3]!==t.actions||e[4]!==a.mobileTab||e[5]!==h?(g={onSwipeLeft:()=>{const z=Kh(h,a.mobileTab,1);z&&(ed(),t.actions.handleMobileTabChange(z))},onSwipeRight:()=>{const z=Kh(h,a.mobileTab,-1);z&&(ed(),t.actions.handleMobileTabChange(z))}},e[3]=t.actions,e[4]=a.mobileTab,e[5]=h,e[6]=g):g=e[6];const x=GD(g);let v;e[7]!==t.actions?(v=z=>{u(!1),t.actions.handleMobileTabChange(z)},e[7]=t.actions,e[8]=v):v=e[8];const w=v,b=i.backgroundServers;let j,S;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(U0,{}),S=r.jsx(B0,{}),e[9]=j,e[10]=S):(j=e[9],S=e[10]);let N;e[11]!==l||e[12]!==a.mobileTab?(N=!(a.mobileTab==="chat"&&l)&&r.jsx("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:r.jsx(Lu,{compact:!0})}),e[11]=l,e[12]=a.mobileTab,e[13]=N):N=e[13];const C=a.mobileTab,k=!(a.mobileTab==="chat"&&l)&&"motion-session-enter";let T;e[14]!==k?(T=K("flex min-h-0 min-w-0 flex-1",k),e[14]=k,e[15]=T):T=e[15];let E;e[16]!==t||e[17]!==a.mobileTab?(E=a.mobileTab==="sessions"&&r.jsx(lv,{navigation:t,mobile:!0}),e[16]=t,e[17]=a.mobileTab,e[18]=E):E=e[18];let P;e[19]!==i||e[20]!==c||e[21]!==t||e[22]!==o||e[23]!==d||e[24]!==l||e[25]!==s||e[26]!==a.expandAll||e[27]!==a.mobileTab||e[28]!==a.pendingDirName?(P=a.mobileTab==="chat"&&r.jsx("div",{className:"flex flex-1 min-h-0 flex-col min-w-0",children:l?r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,r.jsx(KD,{creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:c?s.onBackToMain:void 0,onShowFileChanges:()=>i.onFileChangesOpenChange(!0),hasFileChanges:o.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>u(!0),expandAll:a.expandAll,onToggleExpandAll:s.onToggleExpandAll}),r.jsx(Qa,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:d,onMobileSearchClose:()=>u(!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(Bb,{projectPath:s.pendingPath??null}),et("terminal")&&r.jsxs(ee,{variant:"outline",size:"xs",onClick:o.onOpenTerminal,children:[r.jsx(Ws,{"data-icon":"inline-start"}),"Terminal"]})]})}):r.jsx(cv,{navigation:t})}),e[19]=i,e[20]=c,e[21]=t,e[22]=o,e[23]=d,e[24]=l,e[25]=s,e[26]=a.expandAll,e[27]=a.mobileTab,e[28]=a.pendingDirName,e[29]=P):P=e[29];let _;e[30]!==t.handlers||e[31]!==o||e[32]!==l||e[33]!==a.mobileTab?(_=a.mobileTab==="stats"&&l&&r.jsx(zb,{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]=l,e[33]=a.mobileTab,e[34]=_):_=e[34];let A;e[35]!==a.mobileTab||e[36]!==T||e[37]!==E||e[38]!==P||e[39]!==_?(A=r.jsxs("div",{className:T,children:[E,P,_]},C),e[35]=a.mobileTab,e[36]=T,e[37]=E,e[38]=P,e[39]=_,e[40]=A):A=e[40];let I;e[41]!==x||e[42]!==A?(I=r.jsx("main",{ref:x,className:"app-view-transition flex flex-1 min-h-0 overflow-hidden",children:A}),e[41]=x,e[42]=A,e[43]=I):I=e[43];const R=a.mobileTab==="chat"&&i.processPanel;let $;e[44]!==l||e[45]!==s||e[46]!==a.mobileTab||e[47]!==a.pendingDirName?($=a.mobileTab==="chat"&&(l||a.pendingDirName)&&r.jsxs(r.Fragment,{children:[s.todoProgress,l?s.activeComposer:s.pendingComposer]}),e[44]=l,e[45]=s,e[46]=a.mobileTab,e[47]=a.pendingDirName,e[48]=$):$=e[48];let M;e[49]!==R||e[50]!==$?(M=r.jsxs("div",{className:"shrink-0",children:[R,$]}),e[49]=R,e[50]=$,e[51]=M):M=e[51];let L;e[52]!==w||e[53]!==a.mobileTab?(L=r.jsx(HD,{activeTab:a.mobileTab,onTabChange:w}),e[52]=w,e[53]=a.mobileTab,e[54]=L):L=e[54];let D;e[55]!==i||e[56]!==o||e[57]!==l||e[58]!==a.sessionChangeKey?(D=l&&o.hasFileChanges&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(JD,{open:i.fileChangesOpen,onClose:()=>i.onFileChangesOpenChange(!1),session:l,sessionChangeKey:a.sessionChangeKey})}),e[55]=i,e[56]=o,e[57]=l,e[58]=a.sessionChangeKey,e[59]=D):D=e[59];let F;return e[60]!==i.backgroundServers||e[61]!==i.branchModal||e[62]!==i.undoDialog||e[63]!==i.workflowsPanel||e[64]!==I||e[65]!==M||e[66]!==L||e[67]!==D||e[68]!==N?(F=r.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[b,j,S,N,I,M,i.workflowsPanel,L,i.undoDialog,i.branchModal,D]}),e[60]=i.backgroundServers,e[61]=i.branchModal,e[62]=i.undoDialog,e[63]=i.workflowsPanel,e[64]=I,e[65]=M,e[66]=L,e[67]=D,e[68]=N,e[69]=F):F=e[69],F}function ZD(n){const e=B.c(10),{sessionId:t,loadError:s,searchInputRef:o,activeComposer:i,hasMoreTurns:a,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:d}=Ut(),{session:u}=st();let f;return e[0]!==i||e[1]!==a||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==u||e[8]!==t?(f=r.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-background text-foreground",children:u?r.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[r.jsx(Qa,{searchInputRef:o,hasMore:a,isLoadingOlder:l,onLoadMore:c}),d?i:r.jsx(al,{floating:!0,children:i})]}):r.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:r.jsx(Gt,{className:"max-w-md",children:r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:s?r.jsx(Wt,{}):r.jsx(tt,{className:"animate-spin"})}),r.jsx(Xt,{children:s?"Unable to open session":"Opening session"}),r.jsx(sn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=i,e[1]=a,e[2]=l,e[3]=d,e[4]=s,e[5]=c,e[6]=o,e[7]=u,e[8]=t,e[9]=f):f=e[9],f}const ez=5;function Li(n,e){const t=gn(),s=vs();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}class tz{constructor(){gi(this,"cache",new Map)}get(e,t){const s=Li(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=Li(e,t);!this.cache.has(d)&&this.cache.size>=ez&&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=Li(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(Li(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 bn=new tz,Vh={};function dv(n,e,t,s,o,i){const[a,l]=y.useState(!1),[c,d]=y.useState("disconnected"),[u,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(Vh),[x,v]=y.useState(null),[w,b]=y.useState(io),j=y.useRef(""),S=y.useRef(null),N=y.useRef(io),C=y.useRef("disconnected"),k=y.useRef(e);k.current=e;const T=y.useRef(o);T.current=o;const E=y.useRef(t);E.current=t;const P=y.useRef(s);P.current=s;const _=y.useRef(i??null);_.current=i??null;const A=y.useRef(!1),I=(n==null?void 0:n.dirName)??null,R=(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 y.useEffect(()=>{if(j.current=$,!$){S.current=null,l(!1);return}const L=_.current;if(L){S.current=L;return}E.current($).then(D=>{S.current=D})},[$]),y.useEffect(()=>{if(v(null),!I||!R){l(!1),d("disconnected");return}d("connecting");const L=`/api/watch/${encodeURIComponent(I)}/${encodeURIComponent(R)}?offset=${M}`,D=new EventSource(Lr(L));let F=null;const z=(ie=3e4)=>{F&&clearTimeout(F),F=setTimeout(()=>{l(!1),f(!1)},ie)};let O="",H=M,W=!1,U=!1,V=!1,q=null;const X=()=>{V=!1,q=null,S.current&&k.current(S.current)},G=()=>{V||(V=!0,q=requestAnimationFrame(X))};let Y=!1,J=null,Q=null;const Z=()=>{Y=!1,J=null,b(N.current)},te=()=>{Y||(Y=!0,J=requestAnimationFrame(Z))},ne=ie=>{ie!==N.current&&(N.current=ie,te(),ie.length>0&&!Q&&(Q=setInterval(()=>{const se=bT(N.current);se!==N.current&&(N.current=se,te()),N.current.length===0&&Q&&(clearInterval(Q),Q=null)},5e3)))},oe=()=>{ne(io),g(Vh)},re=()=>{if(U||W||!O)return;const ie=O;O="",W=!0;const se=S.current;(se?P.current(se,ie):E.current(j.current)).then(ce=>{U||(S.current=ce,I&&R&&bn.update(I,R,{parsed:ce,source:{rawText:j.current,watchOffset:H}}),G())}).catch(ce=>{console.error("[useLiveSession] worker parse failed:",ce)}).finally(()=>{W=!1,!U&&O&&re()})};return D.onopen=()=>{var ie;if(C.current!=="connected"){const se=A.current;A.current=!1,C.current="connected",d("connected"),se&&((ie=T.current)==null||ie.call(T))}},D.onmessage=ie=>{try{C.current!=="connected"&&(C.current="connected",d("connected"));const se=JSON.parse(ie.data);if(se.type==="init")se.recentlyActive?(l(!0),z(5e3)):z();else if(se.type==="compacting")se.active&&(l(!0),oe(),z()),f(se.active===!0);else if(se.type==="subagent_activity")l(!0),z();else if(se.type==="runtime_activity")l(!0),z();else if(se.type==="stream_snapshot")l(!0),z(),ne(hT(se.messages??[]));else if(se.type==="stream_delta")l(!0),z(),p(null),v(null),ne(gT(N.current,se.events??[]));else if(se.type==="agent_progress")l(!0),z(),g(de=>({...de,[se.toolUseId]:se.summary}));else if(se.type==="prompt_suggestion")v(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(),f(!1);else if(se.type==="lines"&&se.lines.length>0){l(!0),f(!1),z(),ne(xT(N.current,se.lines));const de=se.lines.join(`
|
|
142
|
+
`)+`
|
|
143
|
+
`;H+=new TextEncoder().encode(de).byteLength,j.current+=de,O+=de,re()}}catch(se){console.error("[useLiveSession] Error processing SSE message:",se)}},D.onerror=()=>{l(!1),f(!1),A.current=C.current==="connected",C.current="disconnected",d("disconnected"),oe()},()=>{U=!0,D.close(),l(!1),C.current="disconnected",d("disconnected"),F&&clearTimeout(F),q!==null&&cancelAnimationFrame(q),J!==null&&cancelAnimationFrame(J),Q&&clearInterval(Q),N.current=io,b(io)}},[I,R,$,M]),{isLive:a,sseState:c,isCompacting:u,streamingOverlay:w,turnError:m,agentProgress:h,promptSuggestion:x}}const nz=3e4;function uv(n,e,t){const s=B.c(9),o=nz,[i,a]=y.useState(!1),l=y.useRef(e);let c,d;s[0]!==e?(c=()=>{l.current=e},d=[e],s[0]=e,s[1]=c,s[2]=d):(c=s[1],d=s[2]),y.useEffect(c,d);let 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=v=>{if(p)try{const w=JSON.parse(v.data);w.type==="init"?x():w.type==="update"&&(a(!0),x(),l.current())}catch{}},g.onerror=()=>{p&&a(!1)},()=>{p=!1,g.close(),h&&clearTimeout(h)}},f=[n,o],s[3]=o,s[4]=n,s[5]=u,s[6]=f):(u=s[5],f=s[6]),y.useEffect(u,f);let m;return s[7]!==i?(m={isLive:i},s[7]=i,s[8]=m):m=s[8],m}function sz(n,e){const t=n?`/api/team-watch/${encodeURIComponent(n)}`:null;return uv(t,e)}function oz(n,e){const[t,s]=y.useState(null),o=y.useRef(null),i=(()=>{if(!n)return null;let l,c=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(l=d[1],c=d[2]):l=n.replace(".jsonl","");const u=new URLSearchParams({leadSessionId:l});return c&&u.set("subagentFile",c),e&&u.set("dirName",e),u.toString()})();o.current=i;const a=y.useCallback(async()=>{const l=o.current;if(l)try{const c=await _e(`/api/session-team?${l}`);if(!c.ok){s(null);return}const d=await c.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);return y.useEffect(()=>{if(!n){s(null);return}a()},[n,a]),sz((t==null?void 0:t.teamName)??null,a),t}function rz(n,e,t,s){let o=null;return n&&e&&(o=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(o=o+`/${encodeURIComponent(t)}`)),uv(o,s)}function iz(n,e,t=!0){const[s,o]=y.useState([]),[i,a]=y.useState(!1),l=y.useRef(0),c=!!n&&!!e,d=y.useCallback(async()=>{const m=++l.current;if(!c){o([]);return}try{const p=await _e(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&o([]);return}const h=await p.json();m===l.current&&o(Array.isArray(h)?h:[])}catch{m===l.current&&o([])}finally{m===l.current&&a(!1)}},[c,n,e]);y.useEffect(()=>{if(!c){o([]),a(!1);return}a(!0),d()},[c,d]);const u=c&&(t||s.length>0),{isLive:f}=rz(u?n:null,u?e:null,null,d);return{workflows:s,loading:i,isLive:f,refetch:d}}const td={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},az="cogpit:permissions";function lz(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 Gh(n,e){const t=await n.json().catch(()=>({error:e}));return typeof t.error=="string"&&t.error?t.error:e}async function fv(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 Gh(l,i(l));return!l.ok&&t==="codex"&&e&&lz(c)&&(o==null||o(e),l=await n(void 0),c=l.ok?null:await Gh(l,i(l))),{res:l,errorMessage:c}}function cz({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]=y.useState("idle"),[g,x]=y.useState(),[v,w]=y.useState([]),b=y.useRef(null),j=y.useRef(null),S=y.useRef(!1),N=n!=null&&n.fileName?xc(n.fileName):null,C=e||N,k=n?At(n.dirName):null,T=y.useCallback(()=>{var $;($=b.current)==null||$.abort(),b.current=null,S.current=!1,h("idle"),x(void 0),w([])},[]);y.useEffect(()=>{var $;j.current!==C&&(S.current?(S.current=!1,($=b.current)==null||$.abort(),b.current=null,h("idle"),x(void 0)):T(),j.current=C)},[C,T]),y.useEffect(()=>()=>{var $;($=b.current)==null||$.abort()},[]),y.useEffect(()=>{f&&T()},[f,T]);const E=y.useCallback(async($,M)=>{if(f)return;if(!C&&m){w(F=>[...F,$]),h("connected"),x(void 0),S.current=!0,o==null||o();try{if(!await m($,M)){S.current=!1,h("idle"),w([]);return}h("idle")}catch(F){S.current=!1,x(F instanceof Error?F.message:"Failed to create session"),h("error"),w([])}return}if(!C)return;w(F=>[...F,$]),h("connected"),x(void 0);const L=s??td;o==null||o();const D=new AbortController;b.current=D;try{const F={sessionId:C,message:$,images:M||void 0,cwd:t||void 0,permissions:L,effort:a||void 0,fastMode:l?!0:void 0,ultracode:c?!0:void 0,mcpConfig:d||void 0},{res:z,errorMessage:O}=await fv(H=>_e("/api/send-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:H}),signal:D.signal}),{model:i,agentKind:k,errorFallback:H=>`Request failed (${H.status})`,onModelRejected:u});b.current===D&&(z.ok?h("idle"):(x(O||`Request failed (${z.status})`),h("error"),w(H=>H.slice(0,-1))))}catch(F){if(F instanceof Error&&F.name==="AbortError")return;b.current===D&&(x(F instanceof Error?F.message:"Unknown error"),h("error"),w(z=>z.slice(0,-1)))}},[C,k,t,s,o,i,a,l,c,d,u,f,m]),P=y.useCallback(()=>{T()},[T]),_=y.useCallback(()=>{!C||f||_e("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C})}).catch(()=>{})},[C,f]),A=y.useCallback(()=>{var $;($=b.current)==null||$.abort(),b.current=null,_(),h("idle"),w([])},[_]),I=A,R=y.useCallback(($=1)=>{w(M=>M.slice($))},[]);return{status:p,error:g,pendingMessages:v,sendMessage:E,disconnect:P,interrupt:A,stopAgent:I,consumePending:R,isConnected:p==="connected"}}const ls={expandAll:!1,expandToolPayloads:!1},dz={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ls,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",configFilePath:null,mobileTab:"sessions",dashboardProject:null};function Yh(n,e,t,s){const o=H2(e,t,s);return o===n.turns?n:{...n,turns:o}}function no(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function uz(n,e){var t,s;switch(e.type){case"LOAD_SESSION":return{...n,...no(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ls,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"GO_HOME":return{...n,...no(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ls,mainView:"sessions",currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile?"sessions":n.mobileTab};case"SWITCH_TEAM_MEMBER":return{...n,...no(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...ls,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,...ls};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,...ls}:{...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:Yh(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:Yh(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...no(e.session),sessionSource:e.source,sessionChangeKey:n.sessionChangeKey+1};case"SET_CURRENT_MEMBER_NAME":return n.currentMemberName===e.name?n:{...n,currentMemberName:e.name};case"GUARD_MOBILE_TAB":{let o=n.mobileTab;return!e.hasSession&&(o==="stats"||o==="chat")&&(o="sessions"),o!==n.mobileTab?{...n,mobileTab:o}:n}case"SET_LOADING_MEMBER":return n.loadingMember===e.name?n:{...n,loadingMember:e.name};case"SET_DASHBOARD_PROJECT":return n.dashboardProject===e.dirName?n:{...n,dashboardProject:e.dirName};case"INIT_PENDING_SESSION":return{...n,...no(null),sessionSource:null,pendingDirName:e.dirName,pendingCwd:e.cwd??null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ls,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab};case"FINALIZE_SESSION":return{...n,...no(e.session),sessionSource:e.source,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...ls,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 mv(){return y.useReducer(uz,dz)}function Xh(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function pv({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:o,partialSignal:i}){const a=y.useRef(null),l=y.useRef(null),c=y.useRef(!0),d=y.useRef(!1),u=y.useRef(0),f=y.useMemo(()=>(n==null?void 0:n.turns.flatMap($=>$.contentBlocks.flatMap(M=>M.kind==="queued_prompt"?[{id:JSON.stringify([M.timestamp??"",M.content]),content:M.content}]:[])))??[],[n==null?void 0:n.turns]),m=y.useRef(null),p=y.useRef(!1),[h,g]=y.useState(!1),[x,v]=y.useState(null),w=y.useCallback(()=>{requestAnimationFrame(()=>{var $;($=l.current)==null||$.scrollIntoView({behavior:"smooth"})})},[]),b=y.useCallback(()=>{Xh(()=>{const $=a.current;$&&($.scrollTop=$.scrollHeight),c.current=!0,d.current=!1})},[]),j=y.useCallback(()=>{p.current=!0},[]),S=y.useRef(!1),N=y.useCallback(()=>{const $=a.current;if(!$)return;const M=$.scrollHeight-$.scrollTop-$.clientHeight>10;M!==S.current&&(S.current=M,g(M))},[]),C=y.useCallback(()=>{const $=a.current;$&&(c.current=$.scrollHeight-$.scrollTop-$.clientHeight<150,N())},[N]),k=y.useCallback($=>{u.current=$},[]),T=y.useRef(o);y.useEffect(()=>{if(o===T.current)return;T.current=o;const $=p.current;p.current=!1;const M=()=>{const D=a.current;D&&($?(D.scrollTop=0,c.current=!1):(D.scrollTop=D.scrollHeight,c.current=!0),d.current=!1)};Xh(M);const L=setTimeout(()=>{M(),v(o)},150);return()=>clearTimeout(L)},[o]);const E=t.length;y.useEffect(()=>{E>0&&(d.current=!0,w())},[E,w]),y.useEffect(()=>{const $=(n==null?void 0:n.sessionId)??null,M=m.current,L=new Set(f.map(z=>z.id));if(!M||M.sessionId!==$){m.current={sessionId:$,ids:L};return}const D=f.filter(z=>!M.ids.has(z.id));if(m.current={sessionId:$,ids:L},D.length===0||E===0)return;let F=0;for(const z of D){const O=t[F];(O===z.content||(O==null?void 0:O.trim())===""&&z.content.length>0)&&F++}F>0&&s(F)},[n==null?void 0:n.sessionId,f,t,E,s]);const P=(n==null?void 0:n.turns.length)??0;y.useEffect(()=>{if(P===0)return;const $=P-u.current;$>0&&(E>0&&s(Math.min($,E)),(d.current||c.current)&&(w(),d.current=!1)),u.current=P},[P,E,s,w]);const _=n==null?void 0:n.turns.at(-1),A=(_==null?void 0:_.toolCalls.length)??0,I=(_==null?void 0:_.assistantText.length)??0;y.useEffect(()=>{if(!(!n||!e)){if(c.current){const $=a.current;$&&($.scrollTop=$.scrollHeight)}requestAnimationFrame(N)}},[P,A,I,i,e,N]);const R=x===o;return y.useMemo(()=>({chatScrollRef:a,scrollEndRef:l,canScrollDown:h,initialScrollDone:R,handleScroll:C,scrollToBottomInstant:b,requestScrollToTop:j,resetTurnCount:k}),[h,R,C,b,j,k])}async function hv(n,e,t,s){const o=await _e(`/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(`
|
|
144
|
+
`);return{parsed:await t(c),source:{dirName:n,fileName:e,rawText:c,agentKind:At(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function Bs(n,e,t,s){const o=bn.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=gn(),a=vs(),{parsed:l,source:c,byteOffset:d,hasMore:u}=await hv(n,e,t,s);if(gn()!==i||vs()!==a)return{parsed:l,source:c};const f=bn.get(n,e);return f?{parsed:f.parsed,source:f.source}:(bn.set(n,e,l,c.rawText,d,u,c.agentKind,c.watchOffset),{parsed:l,source:c})}async function gv(n,e,t,s){bn.evict(n,e);const o=gn(),i=vs(),{parsed:a,source:l,byteOffset:c,hasMore:d}=await hv(n,e,t,s);return gn()===o&&vs()===i&&bn.set(n,e,a,l.rawText,c,d,l.agentKind,l.watchOffset),{parsed:a,source:l}}function fz({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:o,resetTurnCount:i,workerParse:a,onBeforeSwitch:l}){const[c,d]=y.useState(null),u=y.useCallback((v,w)=>{d(null),y.startTransition(()=>{n({type:"LOAD_SESSION",session:v,source:w,isMobile:e})}),i(v.turns.length),cD(v.sessionId,v.turns.length),o()},[n,e,i,o]),f=y.useCallback(async(v,w)=>{l==null||l(),d(null);try{const{parsed:b,source:j}=await Bs(v,w,a,"session");u(b,j)}catch(b){d(b instanceof Error?b.message:"Failed to load session")}},[u,a,l]),m=y.useCallback(async v=>{if(s){l==null||l(),d(null),n({type:"SET_LOADING_MEMBER",name:v.name});try{const w=await _e(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(v.name)}`);if(!w.ok)throw new Error(`Failed to find session for ${v.name}`);const{dirName:b,fileName:j}=await w.json(),{parsed:S,source:N}=await Bs(b,j,a,`session for ${v.name}`);y.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:S,source:N,memberName:v.name})}),i(S.turns.length),o()}catch(w){d(w instanceof Error?w.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,i,o,a,l]),p=y.useCallback(()=>d(null),[]),h=y.useCallback(()=>{y.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=y.useCallback((v,w)=>{n({type:"JUMP_TO_TURN",index:v,toolCallId:w})},[n]),x=y.useCallback(v=>{v!==t&&y.startTransition(()=>{n({type:"SET_MOBILE_TAB",tab:v})})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:u,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleJumpToTurn:g,handleMobileTabChange:x}}const mz=/^\/preview\/([^/]+)\/?$/;function nf(n){const e=mz.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function xv(){const n=gt();return n===Nt?"":`/d/${n}`}function nd(){const n=xv();return n?`${n}/`:"/"}function bv(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function pz(n,e){return tj(n,e)}function hz(n){const e=xv();if(n.sessionSource){const{dirName:t,fileName:s}=n.sessionSource,o=ej(t,s);return`${e}/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}return n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:nd()}function Jh(n){const e=bv(n),t=nf(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 gz({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:o,workerParse:i}){const[a,l]=y.useState(null),c=y.useRef(0),d=y.useRef(window.location.pathname),u=y.useRef(!1),f=y.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await _e(`/api/find-session/${encodeURIComponent(m.sessionId)}`);if(!p.ok)throw new Error(p.status===404?`Session ${m.sessionId} was not found.`:`Failed to resolve session (${p.status}).`);const h=await p.json();if(!h.dirName||!h.fileName)throw new Error("Cogpit returned an invalid session location.");const g=await Bs(h.dirName,h.fileName,i,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),o()}catch(p){e({type:"GO_HOME",isMobile:t}),l(p instanceof Error?p.message:"Failed to load session preview.")}}else if(m.type==="session"&&m.dirName&&m.sessionId){l(null);const p=pz(m.dirName,m.sessionId);let h;try{h=await Bs(m.dirName,p,i,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=nd();window.history.replaceState(null,"",g),d.current=g,zo(gt(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),o()}else if(m.type==="project"&&m.dirName)l(null),e({type:"SET_DASHBOARD_PROJECT",dirName:m.dirName});else if(l(null),e({type:"GO_HOME",isMobile:t}),m.normalizeHome){const p=nd();window.history.replaceState(null,"",p),d.current=p,zo(gt(),p)}}finally{c.current--}},[e,t,s,o,i]);return y.useEffect(()=>{if(u.current)return;u.current=!0,zo(gt(),window.location.pathname);const m=Jh(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),y.useEffect(()=>{if(c.current>0||nf(bv(window.location.pathname)))return;const m=hz(n);m!==d.current&&(window.history.pushState(null,"",m),d.current=m,zo(gt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),y.useEffect(()=>{const m=()=>{const p=Jh(window.location.pathname);d.current=window.location.pathname,zo(gt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:a}}const xz=400;function Qh(){return Array.from(document.querySelectorAll("[data-live-session]"))}function bz(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 Zh(n){n.focus({preventScroll:!0});const e=bz(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 vz(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:v,onNavigateToSession:w,onCommitNavigation:b}=n;let j,S;e[0]!==o||e[1]!==i||e[2]!==t||e[3]!==b||e[4]!==x||e[5]!==v||e[6]!==w||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?(j=()=>{if(t)return;let N=!1,C=!1,k=null;const T=function(A){var M,L;const I=mh("missionControl");if(I){if(A.key===I){A.repeat||(N=!0,C=A.shiftKey||A.altKey||(I==="Meta"?A.ctrlKey:A.metaKey));return}N&&(C=!0),k=null}if(jt("commandPalette",A)){A.preventDefault(),d==null||d();return}if(jt("integratedTerminal",A)){if(!et("terminal"))return;A.preventDefault(),p();return}if(jt("preview",A)){A.preventDefault(),h();return}if(jt("projectFiles",A)){if(!et("hostFiles"))return;A.preventDefault(),g();return}if(jt("expandAll",A)){A.preventDefault(),i({type:"SET_EXPAND_ALL",value:!0});return}if(jt("expandToolPayloads",A)){A.preventDefault(),i({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(jt("toggleSidebar",A)){A.preventDefault(),a();return}if(jt("toggleStats",A)){A.preventDefault(),l();return}if(jt("missionControl",A)){A.preventDefault(),c();return}if(jt("newSession",A)&&(A.preventDefault(),u()),jt("themeSelector",A)&&(A.preventDefault(),f()),jt("systemTerminal",A)){if(!et("terminal"))return;A.preventDefault(),m()}if(A.key==="Escape"&&(i({type:"SET_SEARCH_QUERY",value:""}),(M=s.current)==null||M.blur()),(A.metaKey||A.ctrlKey)&&A.shiftKey&&A.code.startsWith("Digit")){const D=parseInt(A.code.charAt(5),10);if(D>=1&&D<=9){A.preventDefault();const z=Qh()[D-1];z&&(Zh(z),z.click())}}const R=jt("recentSessionForward",A);if(R||jt("recentSessionBack",A)){A.preventDefault();const D=R?v():x();D&&w(D.dirName,D.fileName)}jt("focusComposer",A)&&!Y2(document.activeElement)&&(A.preventDefault(),(L=o.current)==null||L.focus());const $=jt("nextLiveSession",A);if($||jt("prevLiveSession",A)){A.preventDefault();const D=Qh();if(D.length===0)return;const F=D.findIndex(yz);let z;F===-1?z=$?0:D.length-1:z=Math.max(0,Math.min(D.length-1,F+($?1:-1))),Zh(D[z])}},E=function(A){const I=mh("missionControl");if(I&&A.key===I&&N){const R=!C;if(N=!1,C=!1,R){const $=Date.now();k!==null&&$-k<=xz?(k=null,A.preventDefault(),c()):k=$}else k=null}A.key==="Control"&&(b==null||b())},P=function(){N=!1,C=!1,k=null};return window.addEventListener("keydown",T),window.addEventListener("keyup",E),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",T),window.removeEventListener("keyup",E),window.removeEventListener("blur",P)}},S=[t,s,o,i,a,l,c,d,u,f,m,p,h,g,x,v,w,b],e[0]=o,e[1]=i,e[2]=t,e[3]=b,e[4]=x,e[5]=v,e[6]=w,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]=j,e[19]=S):(j=e[18],S=e[19]),y.useEffect(j,S)}function yz(n){return n===document.activeElement}const e1="cogpit-theme",OB=[{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 vv(){const[n,e]=y.useState(()=>{try{const a=localStorage.getItem(e1);if(a==="dark"||a==="oled"||a==="light")return a}catch{}return"dark"}),[t,s]=y.useState(null),o=y.useCallback(a=>{localStorage.setItem(e1,a),e(a),s(null)},[]),i=t??n;return y.useEffect(()=>{const a=document.documentElement.classList;a.remove("dark","theme-oled"),i==="dark"?a.add("dark"):i==="oled"&&a.add("dark","theme-oled")},[i]),{theme:n,activeTheme:i,setTheme:o,setPreview:s}}const wz="cogpit-session-history",sd=50;function yv(){return Ht(wz)}function jz(){try{const n=localStorage.getItem(yv());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,sd)}catch{}return[]}function t1(n){try{localStorage.setItem(yv(),JSON.stringify(n))}catch{}}function Sz(){const n=B.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=jz(),n[0]=e):e=n[0];const t=y.useRef(e),s=y.useRef(0),o=y.useRef(!1);let i;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=(h,g)=>{if(o.current){o.current=!1;return}const x=`${h}/${g}`;t.current=t.current.filter(v=>`${v.dirName}/${v.fileName}`!==x),t.current.unshift({dirName:h,fileName:g}),t.current.length>sd&&(t.current.length=sd),s.current=0,t1(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),t1(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 wv(){return Ht(az)}function n1(){try{const n=localStorage.getItem(wv());if(n){const e=JSON.parse(n);return{mode:e.mode||td.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return td}function Nz(n){localStorage.setItem(wv(),JSON.stringify(n))}function kz(){const n=B.c(17),[e,t]=y.useState(n1),[s,o]=y.useState(n1),i=y.useRef(!0);let a,l;n[0]!==e?(a=()=>{if(i.current){i.current=!1;return}Nz(e)},l=[e],n[0]=e,n[1]=a,n[2]=l):(a=n[1],l=n[2]),y.useEffect(a,l);let c;n[3]!==s.allowedTools||n[4]!==s.disallowedTools||n[5]!==s.mode||n[6]!==e.allowedTools||n[7]!==e.disallowedTools||n[8]!==e.mode?(c=e.mode!==s.mode||JSON.stringify(e.allowedTools)!==JSON.stringify(s.allowedTools)||JSON.stringify(e.disallowedTools)!==JSON.stringify(s.disallowedTools),n[3]=s.allowedTools,n[4]=s.disallowedTools,n[5]=s.mode,n[6]=e.allowedTools,n[7]=e.disallowedTools,n[8]=e.mode,n[9]=c):c=n[9];const d=c;let u;n[10]===Symbol.for("react.memo_cache_sentinel")?(u=g=>{t(x=>({...x,mode:g}))},n[10]=u):u=n[10];const f=u;let m;n[11]!==e?(m=()=>{o(e)},n[11]=e,n[12]=m):m=n[12];const p=m;let h;return n[13]!==e||n[14]!==d||n[15]!==p?(h={config:e,hasPendingChanges:d,setMode:f,markApplied:p},n[13]=e,n[14]=d,n[15]=p,n[16]=h):h=n[16],h}const Cz=2e3;function _z(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function Tz(n){const[e,t]=y.useState([]),[s,o]=y.useState(null),[i,a]=y.useState(new Set);y.useEffect(()=>{if(!n){t([]),o(null);return}let d=!1;const u=async()=>{if(!d)try{const h=await _e(`/api/permissions/${encodeURIComponent(n)}`);if(d)return;if(h.ok){const g=await h.json();if(d)return;t(v=>_z(v,g.permissions)?v:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;o(v=>JSON.stringify(v)===JSON.stringify(x)?v:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&u()},m=()=>{document.visibilityState==="visible"&&u()};f();const p=setInterval(f,Cz);return document.addEventListener("visibilitychange",m),()=>{d=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=y.useCallback(async(d,u)=>{if(n){a(f=>new Set(f).add(d));try{await tv(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=y.useCallback(async d=>{if(n)try{await XL(n,d)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:i,respond:l,respondAll:c}}async function Ez(n,e){const t=await Dn(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{eventId:e});return t.ok?await t.json():null}async function Az(n,e,t){const s=await Dn(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{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 Pz(n){return n.file_path??n.path??""}function jv(n){const e=[];for(const t of n.toolCalls){if(t.isError||AE(t))continue;const s=Pz(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 $z(n,e){return{index:e,userMessage:qa(n.userMessage),toolCalls:jv(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function pa(n,e,t){const s=[];for(let o=e;o>t;o--){const i=n[o];if(!i)continue;const a=jv(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 Iz(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 cr(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(...Iz(i.toolCalls,i.index))}return t}function Sv(n,e,t,s){var l;const o=[];for(let c=e+1;c<n.length;c++){const d=n[c];d&&o.push($z(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 Nv(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 kv(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 Rz(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 Mz(n,e){return{sessionId:n,currentTurnIndex:e-1,totalTurns:e,branches:[],activeBranchId:null}}function Di(n,e){return n.length>0?Rz(n):{turnCount:e,fileCount:0,filePaths:[],operationCount:0}}function Cv(n,e,t){return k0(w0(At(t)),n,e)}function _v(n,e,t,s){const o=w0(At(s)),i=e==null?void 0:e.id;if(i){const a=N_(o,n,i);if(a==="keep-all")return n.length;if(a!==null)return a}return k0(o,n,t)}class er extends Error{constructor(){super("abort")}}async function Oz(n,e,t,s,o,i,a){var w;const l=n.targetTurnIndex,c=pa(e.turns,e.turns.length-1,l),d=l+1,u=o.split(`
|
|
145
|
+
`).filter(Boolean),f=_v(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 er;const{retained:p,scooped:h}=Nv(s.branches,l),g=Sv(e.turns,l,m,h),x={...s,currentTurnIndex:l,totalTurns:d,branches:[...p,g],activeBranchId:null},v=vo(t.dirName).fileCheckpoints?(w=e.turns[l+1])==null?void 0:w.id:void 0;await i({operations:c,sessionSource:t,sessionMutation:{type:"truncate",keepLines:f,expectedLineCount:u.length},state:x,...v?{checkpoint:{sessionId:e.sessionId,userMessageId:v,cwd:e.cwd}}:{}})}async function Lz(n,e,t,s,o,i){var v;const a=n.redoUpToArchiveIndex!==void 0&&n.redoUpToArchiveIndex<s.turns.length-1,l=n.redoUpToArchiveIndex??s.turns.length-1,c=l+1,d=cr(s.turns,l),u=a?Cv(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:w,remaining:b}=kv(p,s.branchPointTurnIndex,c),j={...s,branchPointTurnIndex:s.branchPointTurnIndex+c,turns:s.turns.slice(c),jsonlLines:m,label:((v=s.turns[c])==null?void 0:v.userMessage)||s.label,childBranches:b.length>0?b:void 0};h=[...t.branches.map(S=>S.id===s.id?j:S),...w]}else h=[...t.branches.filter(w=>w.id!==s.id),...p];const g={...t,currentTurnIndex:t.currentTurnIndex+c,totalTurns:t.totalTurns+c,branches:h,activeBranchId:null},x=o.split(`
|
|
146
|
+
`).filter(Boolean);await i({operations:d,sessionSource:e,sessionMutation:{type:"append",lines:f,expectedLineCount:x.length},state:g})}async function Dz(n,e,t,s,o,i,a){var j;let l=[...t.branches],c=o.split(`
|
|
147
|
+
`).filter(Boolean);const d=[];if(n.turns.length>s.branchPointTurnIndex+1){const S=pa(n.turns,n.turns.length-1,s.branchPointTurnIndex);d.push(...S);const{retained:N,scooped:C}=Nv(l,s.branchPointTurnIndex);l=N;const k=s.branchPointTurnIndex+1,T=_v(c,n.turns[s.branchPointTurnIndex],k,e.dirName),E=c.slice(T);if(E.length>0){const P=Sv(n.turns,s.branchPointTurnIndex,E,C);l=[...l,P],c=c.slice(0,T)}}const u=i.branchTurnIndex??s.turns.length-1,f=u+1,m=u<s.turns.length-1,p=cr(s.turns,u);d.push(...p);const h=m?Cv(s.jsonlLines,f,e.dirName):s.jsonlLines.length,g=s.jsonlLines.slice(0,h),x=s.jsonlLines.slice(h),v=s.childBranches??[];let w;if(m&&x.length>0){const{restored:S,remaining:N}=kv(v,s.branchPointTurnIndex,f);w=[{...s,branchPointTurnIndex:s.branchPointTurnIndex+f,turns:s.turns.slice(f),jsonlLines:x,label:((j=s.turns[f])==null?void 0:j.userMessage)||s.label,childBranches:N.length>0?N:void 0},...S]}else w=v;const b={...t,currentTurnIndex:s.branchPointTurnIndex+f,totalTurns:s.branchPointTurnIndex+1+f,branches:[...l.filter(S=>S.id!==s.id),...w],activeBranchId:null};await a({operations:d,sessionSource:e,sessionMutation:{type:"splice",keepLines:c.length,lines:g,expectedLineCount:o.split(`
|
|
148
|
+
`).filter(Boolean).length},state:b})}const zz=[];function Tv(n,e,t,s=!0){const[o,i]=y.useState(null),[a,l]=y.useState(null),[c,d]=y.useState(!1),[u,f]=y.useState(null),m=y.useRef(null),p=y.useRef(0);y.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,!vo(e==null?void 0:e.dirName).redo){i(null);return}const P=n.sessionId,_=new AbortController;return _e(`/api/undo-state/${encodeURIComponent(P)}`,{signal:_.signal}).then(A=>A.ok?A.json():null).then(A=>{m.current===P&&i(A??null)}).catch(A=>{A instanceof Error&&A.name==="AbortError"||m.current===P&&i(null)}),()=>_.abort()},[s,n==null?void 0:n.sessionId]);const h=y.useCallback(async P=>{try{const _=await _e("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:P.operations,session:{dirName:P.sessionSource.dirName,fileName:P.sessionSource.fileName,mutation:P.sessionMutation},state:P.state,checkpoint:P.checkpoint})}),A=await _.json().catch(()=>null);if(!_.ok)throw f((A==null?void 0:A.error)||"Undo transaction failed"),new er;i(P.state)}catch(_){throw _ instanceof er?_:(f(String(_)),new er)}},[]),g=(o==null?void 0:o.branches)??zz,{canRedo:x,redoTurnCount:v,redoBranch:w}=y.useMemo(()=>{if(!n||g.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let P=g.length-1;P>=0;P--){const _=g[P];if(_.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:_.turns.length,redoBranch:_}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,g]),b=y.useMemo(()=>{if(!w||w.jsonlLines.length===0)return[];try{return Ha(w.jsonlLines.join(`
|
|
149
|
+
`)).turns}catch{return[]}},[w]),j=y.useCallback(P=>g.filter(_=>_.branchPointTurnIndex===P),[g]),S=y.useCallback(P=>{if(!s||!n)return;const _=P-1;if(_>=n.turns.length-1||_<-1)return;if(vo(e==null?void 0:e.dirName).nativeRewind){const I=n.turns[P];if(!I)return;const R=n.sessionId,$=++p.current,M=()=>p.current===$&&m.current===R,L=I.id.includes("@")?I.id.slice(I.id.lastIndexOf("@")+1):I.id,D=n.turns.length-P;Ez(n.sessionId,L).then(F=>{var H;if(!M())return;const z=((H=F==null?void 0:F.files)==null?void 0:H.map(({path:W})=>W).filter(W=>typeof W=="string"))??[],O=F!=null&&F.available?F.fileCount??z.length:0;l({type:"undo",summary:{turnCount:D,fileCount:O,filePaths:z,operationCount:O},targetTurnIndex:_,nativeRewind:{eventId:L,mode:"conversation",filesAvailable:!!(F!=null&&F.available&&O>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:D,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:_,nativeRewind:{eventId:L,mode:"conversation"}})});return}const A=pa(n.turns,n.turns.length-1,_);l({type:"undo",summary:Di(A,n.turns.length-1-_),targetTurnIndex:_})},[s,n,e==null?void 0:e.dirName]),N=y.useCallback(()=>{if(!s||!x||!w||!n)return;const P=cr(w.turns);l({type:"redo",summary:Di(P,w.turns.length),targetTurnIndex:w.branchPointTurnIndex+w.turns.length,branchId:w.id})},[s,x,w,n]),C=y.useCallback(P=>{if(!s||!x||!w||!n)return;const _=P+1,A=cr(w.turns,P);l({type:"redo",summary:Di(A,_),targetTurnIndex:w.branchPointTurnIndex+_,branchId:w.id,redoUpToArchiveIndex:P})},[s,x,w,n]),k=y.useCallback((P,_)=>{if(!s||!n)return;const A=g.find(M=>M.id===P);if(!A)return;const I=_??A.turns.length-1,R=n.turns.length>A.branchPointTurnIndex+1?pa(n.turns,n.turns.length-1,A.branchPointTurnIndex):[],$=cr(A.turns,I);l({type:"branch-switch",summary:Di([...R,...$],I+1),targetTurnIndex:A.branchPointTurnIndex,branchId:P,branchTurnIndex:I})},[s,n,g]),T=y.useCallback(async(P=!1)=>{if(!s||!a||!n||!e){l(null);return}d(!0),f(null);try{if(a.nativeRewind){const R=P&&a.nativeRewind.filesAvailable?"conversation-and-files":"conversation",$=await Az(n.sessionId,a.nativeRewind.eventId,R);if(!$.ok){f($.error);return}await t(),l(null);return}const _=o??Mz(n.sessionId,n.turns.length),A=await _e(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!A.ok){f("Failed to read session file");return}const I=await A.text();if(a.type==="undo")await Oz(a,n,e,_,I,h,f);else if(a.type==="redo"){const R=g.find($=>$.id===a.branchId);if(!R){l(null);return}await Lz(a,e,_,R,I,h)}else if(a.type==="branch-switch"){const R=g.find($=>$.id===a.branchId);if(!R){l(null);return}await Dz(n,e,_,R,I,a,h)}try{await _e("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(_){if(!(_ instanceof er))throw _}finally{d(!1)}},[s,a,n,e,o,g,h,t]),E=y.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:o,canRedo:x,redoTurnCount:v,redoGhostTurns:b,branches:g,branchesAtTurn:j,requestUndo:S,requestRedoAll:N,requestRedoUpTo:C,requestBranchSwitch:k,confirmState:a,confirmApply:T,confirmCancel:E,isApplying:c,applyError:u}}async function Fz(n){try{const t=await(await cs("/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 Bz(n){const e=await _e("/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:Zw(t==null?void 0:t.mode,qs),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function Uz(){const n=B.c(26),[e,t]=y.useState(!0),[s,o]=y.useState(null),[i,a]=y.useState(null),[l,c]=y.useState(qs),[d,u]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(!1),[g,x]=y.useState(0),v=y.useRef(null);let w;n[0]===Symbol.for("react.memo_cache_sentinel")?(w=H=>{a(H.claudeDir),c(H.defaultAgentKind),GN(H.useBuiltInEditor)},n[0]=w):w=n[0];const b=w;let j;n[1]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{var U;(U=v.current)==null||U.abort();const H=new AbortController;v.current=H;const W=await Fz(H.signal);H.signal.aborted||v.current!==H||(m(W.url),h(W.disabled))},n[1]=j):j=n[1];const S=j;let N,C;n[2]===Symbol.for("react.memo_cache_sentinel")?(N=()=>()=>{var H;(H=v.current)==null||H.abort()},C=[],n[2]=N,n[3]=C):(N=n[2],C=n[3]),y.useEffect(N,C);let k;n[4]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{const H=new AbortController;return t(!0),o(null),Bz(H.signal).then(b).catch(W=>{W instanceof Error&&W.name==="AbortError"||(a(null),o(W instanceof Error?W.message:"Failed to load configuration"))}).finally(()=>{H.signal.aborted||t(!1)}),()=>H.abort()},n[4]=k):k=n[4];let T;n[5]!==g?(T=[b,g],n[5]=g,n[6]=T):T=n[6],y.useEffect(k,T);let E,P;n[7]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const H=()=>x(qz);return window.addEventListener("cogpit-auth-changed",H),()=>window.removeEventListener("cogpit-auth-changed",H)},P=[],n[7]=E,n[8]=P):(E=n[7],P=n[8]),y.useEffect(E,P);let _;n[9]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{S()},n[9]=_):_=n[9];let A;n[10]!==i?(A=[i,S],n[10]=i,n[11]=A):A=n[11],y.useEffect(_,A);let I;n[12]===Symbol.for("react.memo_cache_sentinel")?(I=()=>u(!1),n[12]=I):I=n[12];const R=I;let $;n[13]!==i?($=H=>{if(u(!1),H!==i){a(H),window.location.reload();return}x(Hz),S()},n[13]=i,n[14]=$):$=n[14];const M=$;let L;n[15]===Symbol.for("react.memo_cache_sentinel")?(L=()=>u(!0),n[15]=L):L=n[15];const D=L;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>x(Wz),n[16]=F):F=n[16];const z=F;let O;return n[17]!==i||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==M||n[22]!==p||n[23]!==f||n[24]!==d?(O={configLoading:e,configError:s,claudeDir:i,defaultAgentKind:l,setClaudeDir:a,showConfigDialog:d,openConfigDialog:D,handleCloseConfigDialog:R,handleConfigSaved:M,retryConfig:z,networkUrl:f,networkAccessDisabled:p},n[17]=i,n[18]=s,n[19]=e,n[20]=l,n[21]=M,n[22]=p,n[23]=f,n[24]=d,n[25]=O):O=n[25],O}function Wz(n){return n+1}function Hz(n){return n+1}function qz(n){return n+1}const s1={authenticated:!0,edition:"personal",user:null,capabilities:Pa},mn={authenticated:!1,edition:"personal",user:null,capabilities:Br},Ev=Object.keys(Pa);function o1(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Ev.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function Kz(n,e){const t={...Br};for(const s of Ev)t[s]=n[s]&&e[s];return t}async function r1(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?await t.json():null}catch{return null}}async function Vz(n){try{const e=await _e("/api/hello",{signal:n});return e.ok?(await e.json()).edition==="team"?"team":"personal":null}catch{return null}}function Go(n){var e;return co(n),rg(((e=n.user)==null?void 0:e.id)??null),n}function Gz(n){const e=B.c(8);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={...mn,checked:!1},e[0]=t):t=e[0];const[s,o]=y.useState(t),[i,a]=y.useState(0),l=y.useRef(null),c=y.useRef(!1);let d;e[1]!==n?(d=()=>{var b;if((b=l.current)==null||b.abort(),n===null){c.current=!1,co(mn),o({...mn,checked:!1});return}const p=c.current;c.current=!1,co(mn),o(j=>p?{...j,capabilities:Br,checked:!1}:{...mn,checked:!1});const h=new AbortController;l.current=h;const g=Ds(),x=r1(cs,h.signal),v=g?Vz(h.signal):Promise.resolve(n),w=g?r1(_e,h.signal):Promise.resolve(null);return Promise.all([x,v,w]).then(j=>{const[S,N,C]=j;if(h.signal.aborted)return;const k=o1(S,n)?S:n==="personal"?s1:null;if(!k||N===null){o({...Go(mn),checked:!1});return}if(!g){o({...Go(k),checked:!0});return}const T=o1(C,N)?C:N==="personal"?s1:null;if(!T){o({...Go(mn),checked:!1});return}o({...Go({authenticated:k.authenticated,edition:k.edition,user:k.user,capabilities:Kz(k.capabilities,T.capabilities)}),checked:!0})}).catch(()=>{h.signal.aborted||o({...Go(mn),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],y.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,co(mn),rg(null),o({...mn,checked:!1}),a(Jz)},h=g=>{var w,b;const x=gt();if(x===Nt)return;const v=(w=g.detail)==null?void 0:w.deviceId;v&&v!==x||((b=l.current)==null||b.abort(),c.current=!0,co(mn),o(Xz),a(Yz))};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]),y.useEffect(f,m),s}function Yz(n){return n+1}function Xz(n){return{...n,capabilities:Br,checked:!1}}function Jz(n){return n+1}const Qz=3e4;function Zz(n){const[e,t]=y.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=y.useRef(0),o=y.useCallback(async()=>{if(!n)return;const a=++s.current;t(l=>l.dirName===n&&l.loading?l:{dirName:n,worktrees:l.dirName===n?l.worktrees:[],loading:!0,error:l.dirName===n?l.error:null});try{const l=await _e(`/api/worktrees/${encodeURIComponent(n)}`);if(a!==s.current)return;if(l.ok){const c=await l.json();if(a!==s.current)return;t({dirName:n,worktrees:c,loading:!1,error:null});return}t(c=>c.dirName===n?{...c,loading:!1,error:"Failed to fetch worktrees"}:c)}catch(l){if(a!==s.current)return;t(c=>c.dirName===n?{...c,loading:!1,error:l instanceof Error?l.message:"Unknown error"}:c)}},[n]);y.useEffect(()=>{if(!n){s.current+=1;return}o();const a=setInterval(()=>void o(),Qz);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 eF(){const n=B.c(3),[e,t]=y.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await _e("/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 tF(n,e){return n?`${n}.jsonl`:e??null}async function Av(n){try{const e=await _e(`/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 nF=300,cc=new Map;function od(n,e){const t=Ht(n),s=cc.get(t),o=s?{...s.patch,...e}:e;s&&clearTimeout(s.timer);const i=setTimeout(()=>{cc.delete(t),Ht(n)===t&&(async()=>{try{await Dn(`/api/session-config/${encodeURIComponent(n)}`,o,{method:"PUT"})}catch{}})()},nF);cc.set(t,{patch:o,timer:i})}function rd(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function i1(n){const e=await Av(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function dc(n,e){od(n,{mcpServers:e})}async function sF(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function a1(n,e){try{const t=await _e(n,{signal:e});if(e.aborted)return null;const s=await sF(t);return e.aborted?null:s}catch{return null}}async function l1(n,e,t){const s=rd(t);if(s.size===0)return[];if(n){const o=await i1(n);if(o)return o.filter(i=>s.has(i))}if(e&&n!==e){const o=await i1(e);if(o)return o.filter(i=>s.has(i))}return[...s]}function oF(n,e,t,s=!0){const[o,i]=y.useState([]),[a,l]=y.useState({}),[c,d]=y.useState([]),[u,f]=y.useState(!1),[m,p]=y.useState(!1),h=y.useRef(null),g=y.useRef(e);g.current=e;const x=t??e??null,v=y.useRef(x);v.current=x;const w=y.useRef(void 0);y.useEffect(()=>{var k,T;if(!s||!n){(k=h.current)==null||k.abort(),w.current=void 0,i([]),l({}),d([]),f(!1),p(!1);return}const C=new AbortController;return(T=h.current)==null||T.abort(),i([]),l({}),d([]),f(!0),p(!1),w.current=n,a1(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,C.signal).then(async E=>{if(C.signal.aborted||w.current!==n||!E)return;i(E.servers),l(E.configs);const P=await l1(v.current,g.current,E.servers);C.signal.aborted||w.current!==n||d(P)}).finally(()=>{C.signal.aborted||w.current!==n||(f(!1),p(!0))}),()=>C.abort()},[n,s]),y.useEffect(()=>()=>{var C;return(C=h.current)==null?void 0:C.abort()},[]),y.useEffect(()=>{if(o.length===0||!x)return;let C=!1;return l1(x,e,o).then(k=>{C||v.current!==x||d(k)}),()=>{C=!0}},[x]);const b=y.useCallback(C=>{d(k=>{const T=k.includes(C)?k.filter(E=>E!==C):[...k,C];return v.current&&dc(v.current,T),T})},[]),j=y.useCallback(C=>{d(()=>(v.current&&dc(v.current,C),C))},[]),S=y.useCallback(()=>{var k;if(!s||!n)return;(k=h.current)==null||k.abort();const C=new AbortController;h.current=C,f(!0),a1(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,C.signal).then(T=>{if(C.signal.aborted||w.current!==n||!T)return;i(T.servers),l(T.configs);const E=rd(T.servers);d(P=>{const _=P.filter(A=>E.has(A));return v.current&&dc(v.current,_),_})}).finally(()=>{C.signal.aborted||h.current!==C||f(!1)})},[n,s]),N=y.useMemo(()=>{if(o.length===0)return null;const C=rd(o);if(c.length===C.size&&C.size>0&&c.every(E=>C.has(E))||!c.every(E=>a[E]))return null;const T=Object.fromEntries(c.map(E=>[E,a[E]]));return JSON.stringify({mcpServers:T})},[c,a,o]);return{servers:o,selectedServers:c,mcpConfigJson:N,loading:u,loaded:m,toggleServer:b,setSelection:j,refresh:S}}function rF(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 v=x.input;Array.isArray(v.todos)&&(i=v.todos);continue}if(x.name==="TaskCreate"){const v=x.input;h=h+1;const b=((o=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:o[1])??String(h);p.set(b,{id:b,content:v.subject||v.description||`Task ${b}`,activeForm:v.activeForm||v.subject||`Working on task ${b}`,status:"pending",owner:v.owner});continue}if(x.name==="TaskUpdate"){const v=x.input,w=String(v.taskId??"");if(!w)continue;if(v.status==="deleted"){p.delete(w);continue}const b=p.get(w)??{id:w,content:v.subject||v.description||`Task ${w}`,activeForm:v.activeForm||v.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...b,content:v.subject||v.description||b.content,activeForm:v.activeForm||b.activeForm,status:v.status||b.status,owner:v.owner??b.owner,blockedBy:v.addBlockedBy?[...new Set([...b.blockedBy??[],...v.addBlockedBy])]:b.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(aF),e[4]=l,e[5]=c):c=e[5];const d=c.length;let u;e[6]!==l?(u=l.find(iF)??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 iF(n){return n.status==="in_progress"}function aF(n){return n.status==="completed"}function lF(n){const e=B.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,o]=y.useState(t);let i,a;return e[1]!==n?(i=()=>{if(!n){o([]);return}let l=!1;const c=async function(){try{const f=await _e(`/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]),y.useEffect(i,a),s}function cF(n,e){const t=B.c(8),s=e===void 0?!0:e;let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];const[i,a]=y.useState(o),[l,c]=y.useState(!1),d=y.useRef(void 0);let 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)}`:"";_e(`/api/slash-suggestions${p}`).then(dF).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]),y.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 dF(n){return n.json()}function c1(n,e){const t=B.c(6),[s,o]=Io(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 d1(){if(typeof window>"u")return St.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return St.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return St.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return St.fileChanges}function uF(n,e){const t=B.c(42),[s,o]=c1("panel-sidebar-visible",!0),[i,a]=c1("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=d1(),t[0]=l):l=t[0];const[c,d]=Io("workspace-panel-active",l);let u;t[1]!==c?(u=typeof c=="string"||c===null?c:d1(),t[1]=c,t[2]=u):u=t[2];const f=u,[m,p]=y.useState(!1),[h,g]=y.useState(!1);let x;t[3]!==o||t[4]!==s?(x=()=>{y.startTransition(()=>o(!s))},t[3]=o,t[4]=s,t[5]=x):x=t[5];const v=x;let w;t[6]!==e||t[7]!==d||t[8]!==n.mainView?(w=H=>{y.startTransition(()=>{const W=n.mainView==="config"||n.mainView==="mission";n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(U=>W||U!==H?H:null)})},t[6]=e,t[7]=d,t[8]=n.mainView,t[9]=w):w=t[9];const b=w;let j;t[10]!==e||t[11]!==d||t[12]!==n.mainView?(j=H=>{y.startTransition(()=>{n.mainView==="config"&&e({type:"CLOSE_CONFIG"}),n.mainView==="mission"&&e({type:"CLOSE_MISSION"}),d(H)})},t[10]=e,t[11]=d,t[12]=n.mainView,t[13]=j):j=t[13];const S=j;let N;t[14]!==d?(N=()=>{y.startTransition(()=>d(null))},t[14]=d,t[15]=N):N=t[15];const C=N;let k;t[16]!==e||t[17]!==n.mainView?(k=()=>{const H=n.mainView==="config";y.startTransition(()=>{e({type:H?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=n.mainView,t[18]=k):k=t[18];const T=k;let E;t[19]!==e||t[20]!==n.mainView?(E=()=>{const H=n.mainView==="mission";y.startTransition(()=>{e({type:H?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=n.mainView,t[21]=E):E=t[21];const P=E;let _;t[22]!==e?(_=H=>{y.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:H})})},t[22]=e,t[23]=_):_=t[23];const A=_;let I;t[24]===Symbol.for("react.memo_cache_sentinel")?(I=()=>p(!0),t[24]=I):I=t[24];const R=I;let $;t[25]===Symbol.for("react.memo_cache_sentinel")?($=()=>p(!1),t[25]=$):$=t[25];const M=$;let L;t[26]===Symbol.for("react.memo_cache_sentinel")?(L=()=>g(fF),t[26]=L):L=t[26];const D=L;let F;t[27]===Symbol.for("react.memo_cache_sentinel")?(F=()=>g(!1),t[27]=F):F=t[27];const z=F;let O;return t[28]!==f||t[29]!==C||t[30]!==A||t[31]!==T||t[32]!==P||t[33]!==v||t[34]!==S||t[35]!==a||t[36]!==m||t[37]!==s||t[38]!==h||t[39]!==i||t[40]!==b?(O={showSidebar:s,showWorkflows:i,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:v,toggleWorkspacePanel:b,openWorkspacePanel:S,closeWorkspacePanel:C,handleToggleConfig:T,handleToggleMission:P,handleEditConfig:A,handleOpenProjectSwitcher:R,handleCloseProjectSwitcher:M,handleToggleThemeSelector:D,handleCloseThemeSelector:z,setShowWorkflows:a},t[28]=f,t[29]=C,t[30]=A,t[31]=T,t[32]=P,t[33]=v,t[34]=S,t[35]=a,t[36]=m,t[37]=s,t[38]=h,t[39]=i,t[40]=b,t[41]=O):O=t[41],O}function fF(n){return!n}function mF(n){var V;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=y.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:q,fileName:X}=e.sessionSource;try{const{parsed:G,source:Y}=await gv(q,X,g,"session");t({type:"RELOAD_SESSION_CONTENT",session:G,source:Y})}catch{}},[e.sessionSource,t,g]),[v,w]=y.useState(null),b=y.useCallback(q=>w(q),[]),j=y.useCallback(()=>w(null),[]),S=y.useCallback(async(q,X)=>{try{const G=await _e("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:X})});if(!G.ok)return;const Y=await G.json(),{parsed:J,source:Q}=await Bs(Y.dirName,Y.fileName,g,"session");t({type:"LOAD_SESSION",session:J,source:Q,isMobile:s})}catch{}},[t,s,g]),N=y.useCallback(()=>{e.sessionSource&&S(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,S]),C=y.useCallback(async(q,X)=>{try{await _e("/api/delete-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:q,fileName:X})})}catch{}},[]),k=y.useCallback(async q=>{var J,Q;if(!e.sessionSource)return;const{dirName:X,fileName:G}=e.sessionSource,Y=(Q=(J=e.session)==null?void 0:J.turns[q])==null?void 0:Q.id;try{const Z=await _e("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dirName:X,fileName:G,turnIndex:q,turnUuid:Y})});if(!Z.ok)return;const te=await Z.json(),{parsed:ne,source:oe}=await Bs(te.dirName,te.fileName,g,"session");t({type:"LOAD_SESSION",session:ne,source:oe,isMobile:s})}catch{}},[e.sessionSource,e.session,t,s,g]),T=y.useCallback((q,X)=>{o(q,X),t({type:"SET_MOBILE_TAB",tab:"chat"})},[o,t]),[E,P]=y.useState({}),_=y.useRef(c);_.current=c;const A=y.useRef(d);A.current=d;const I=y.useRef(m);I.current=m;const R=y.useRef(u);R.current=u;const $=y.useRef(f);$.current=f;const M=y.useRef(l);M.current=l;const L=((V=e.session)==null?void 0:V.sessionId)??null,D=y.useRef(null);y.useEffect(()=>{L!==D.current&&(D.current=L,L&&P(q=>L in q?q:{...q,[L]:{model:_.current,effort:A.current,fastMode:R.current,ultracode:$.current,mcpConfig:I.current}}))},[L]);const F=L?E[L]:void 0,z=m!==((F==null?void 0:F.mcpConfig)??null),O=F!=null&&(c!==F.model||d!==F.effort||u!==F.fastMode||f!==F.ultracode||a||z),H=y.useCallback(async()=>{var te,ne;if(!L)return;const q=_.current,X=A.current,G=R.current,Y=$.current,J=I.current,Q=M.current,Z=((te=e.sessionSource)==null?void 0:te.agentKind)??At(((ne=e.sessionSource)==null?void 0:ne.dirName)??null);Bt(Z).settingsApply==="live"&&await _e(`/api/claude/settings/${encodeURIComponent(L)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:q,effort:X,fastMode:G,ultracode:Y,mcpConfig:J,permissionMode:Q.mode,allowedTools:Q.allowedTools,disallowedTools:Q.disallowedTools})}),P(oe=>({...oe,[L]:{model:q,effort:X,fastMode:G,ultracode:Y,mcpConfig:J}})),i()},[L,e.sessionSource,i]),W=y.useCallback(async()=>{if(L)try{await _e("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:L})})}catch{}},[L]),U=y.useCallback((q,X)=>{ws(X)&&p(),h(q,X)},[p,h]);return{reloadSession:x,branchModalTurn:v,setBranchModalTurn:w,handleOpenBranches:b,handleCloseBranchModal:j,handleDuplicateSessionByPath:S,handleDuplicateSession:N,handleDeleteSession:C,handleBranchFromHere:k,handleMobileJumpToTurn:T,hasSettingsChanges:O,handleApplySettings:H,handleStopSession:W,handleLoadSessionScrollAware:U}}function Pv(){const n=B.c(6),e=y.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=y.useRef(t),o=y.useRef(0);let i,a;n[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const m=s.current,p=new Worker(new URL("/assets/session-parser.worker-DlF00ZHH.js",import.meta.url),{type:"module"});return p.onmessage=h=>{const g=h.data,x=m.get(g.id);x&&(m.delete(g.id),g.type==="result"?x.resolve(g.session):x.reject(new Error(g.error)))},p.onerror=h=>{for(const[,g]of m)g.reject(new Error(`Worker error: ${h.message}`));m.clear()},e.current=p,()=>{p.terminate(),e.current=null;for(const[,h]of m)h.reject(new Error("Worker terminated"));m.clear()}},a=[],n[1]=i,n[2]=a):(i=n[1],a=n[2]),y.useEffect(i,a);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{o.current=o.current+1;const x=o.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>Ha(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 v=o.current;s.current.set(v,{resolve:g,reject:x}),h.postMessage({type:"append",id:v,existing:m,newText:p})}):Promise.resolve().then(()=>$_(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 pF=30;function $v({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:o}){const[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(""),u=y.useRef(null),f=`${n??""}::${e??""}::${t}`;return y.useEffect(()=>{d.current=f,u.current=null,c(!1);const p=n&&e?bn.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:y.useCallback(async()=>{if(!n||!e||u.current)return 0;const p=`${n}::${e}::${t}`,h=bn.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 _e(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${pF}`);if(!x.ok)return 0;const v=await x.json(),w=v.lines.length>0&&v.hasMore;if(d.current===p&&a(w),v.lines.length===0)return bn.update(n,e,{hasMore:w,nextByteOffset:v.byteOffset}),0;const b=new Set(v.headerLines),j=v.lines.filter(C=>!b.has(C)),S=await s([...v.headerLines,...j].join(`
|
|
150
|
+
`)),N=H2(h.olderTurns,S.turns,h.source.agentKind);return bn.update(n,e,{hasMore:w,nextByteOffset:v.byteOffset,olderTurns:N}),d.current!==p?0:(o(N),S.turns.length)}finally{u.current===g&&(u.current=null,d.current===p&&c(!1))}},[n,e,t,s,o]),hasMore:i,isLoadingOlder:l}}function hF(n){const e=B.c(43),{agentKind:t,session:s,sessionSource:o,pendingDirName:i,isLive:a}=n,l=t??qs,[c,d]=y.useState(""),[u,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(!1),{options:x,fastTier:v,imageInput:w,normalizeEffort:b}=dg(l,c),j=c||(s==null?void 0:s.model);let S;e[0]!==l||e[1]!==j?(S=gj(l,j),e[0]=l,e[1]=j,e[2]=S):S=e[2];const N=S,C=h&&N;let k;e[3]!==b||e[4]!==u||e[5]!==C?(k=C?"xhigh":b(u),e[3]=b,e[4]=u,e[5]=C,e[6]=k):k=e[6];const T=k,E=!!v,P=E&&m,[_,A]=y.useState(null),I=y.useRef(null),R=(o==null?void 0:o.fileName)??null,$=y.useRef(R);let M,L;e[7]!==R?(M=()=>{const Z=$.current;$.current=R,!(Z===null||Z===R)&&g(!1)},L=[R],e[7]=R,e[8]=M,e[9]=L):(M=e[8],L=e[9]),y.useEffect(M,L);let D,F;e[10]!==i?(D=()=>{i&&g(!1)},F=[i],e[10]=i,e[11]=D,e[12]=F):(D=e[11],F=e[12]),y.useEffect(D,F);let z;e[13]!==l?(z=Z=>{d(te=>te===Z?"":te),A(`${Z} is unavailable for this account. Cogpit retried the turn with ${on(l).displayName}'s default model.`)},e[13]=l,e[14]=z):z=e[14];const O=z;let H;e[15]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{A(null)},e[15]=H):H=e[15];const W=H;let U,V;e[16]!==x||e[17]!==i||e[18]!==c||e[19]!==o?(U=()=>{c&&(!o&&!i||x.some(Z=>Z.value===c)||d(""))},V=[x,c,o,i],e[16]=x,e[17]=i,e[18]=c,e[19]=o,e[20]=U,e[21]=V):(U=e[20],V=e[21]),y.useEffect(U,V);let q,X;e[22]!==_?(q=()=>{if(!_)return;const Z=setTimeout(()=>A(null),12e3);return()=>clearTimeout(Z)},X=[_],e[22]=_,e[23]=q,e[24]=X):(q=e[23],X=e[24]),y.useEffect(q,X);const G=s==null?void 0:s.rawMessages;let Y,J;e[25]!==l||e[26]!==a||e[27]!==G?(Y=()=>{if(!a||!G||!Bt(l).modelFallbackNotices)return;let Z;for(let ie=G.length-1;ie>=0;ie=ie-1,ie){const se=G[ie];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(I.current===te)return;I.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}`:"";A(`${ne} could not handle this request, so Claude continued with ${oe}.${re}`)},J=[a,G,l],e[25]=l,e[26]=a,e[27]=G,e[28]=Y,e[29]=J):(Y=e[28],J=e[29]),y.useEffect(Y,J);let Q;return e[30]!==T||e[31]!==P||e[32]!==E||e[33]!==m||e[34]!==O||e[35]!==w||e[36]!==_||e[37]!==u||e[38]!==c||e[39]!==C||e[40]!==N||e[41]!==h?(Q={selectedModel:c,setSelectedModel:d,selectedEffort:u,setSelectedEffort:f,fastModeEnabled:m,ultracodeEnabled:h,effectiveEffort:T,fastModeAvailable:E,fastModeActive:P,setFastModeEnabled:p,ultracodeAvailable:N,ultracodeActive:C,setUltracodeEnabled:g,imageInputAvailable:w,modelFallbackNotice:_,dismissModelFallbackNotice:W,handleModelRejected:O},e[30]=T,e[31]=P,e[32]=E,e[33]=m,e[34]=O,e[35]=w,e[36]=_,e[37]=u,e[38]=c,e[39]=C,e[40]=N,e[41]=h,e[42]=Q):Q=e[42],Q}const gF=["model","effort","fastMode","ultracode","permissionMode"];function xF({sessionKey:n,values:e,onHydrate:t}){const s=y.useRef(null),o=y.useRef(null),i=y.useRef(t);i.current=t;const a=y.useRef(e);a.current=e,y.useEffect(()=>{if(s.current=null,o.current=null,!n)return;let c=!1;return Av(n).then(d=>{if(c||d===null)return;if(gF.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 od(n,a.current),o.current=JSON.stringify(a.current);s.current=n}),()=>{c=!0}},[n]);const l=JSON.stringify(e);y.useEffect(()=>{!n||s.current!==n||l!==o.current&&(o.current=l,od(n,a.current))},[l,n])}function bF(n){const[e,t]=y.useState(new Map),[s,o]=y.useState(null),[i,a]=y.useState(!0),l=y.useRef(new Map),c=y.useRef(null);y.useEffect(()=>{const x=n??null,v=c.current;if(v&&v!==x&&l.current.set(v,{activeId:s,collapsed:i}),x!==v){const w=x?l.current.get(x):null;w?(o(w.activeId),a(w.collapsed)):(o(null),a(!0))}c.current=x},[n]);const d=y.useCallback(()=>a(x=>!x),[]),u=y.useCallback(x=>{t(v=>{const w=new Map(v);return w.set(x.id,x),w}),o(x.id),a(!1)},[]),f=y.useCallback(x=>{t(v=>{const w=new Map(v);return w.delete(x),o(b=>{if(b!==x)return b;const j=[...w.keys()];return j.length>0?j[j.length-1]:null}),w})},[]),m=y.useCallback(x=>{o(x),a(!1)},[]),p=y.useCallback((x,v)=>{t(w=>{const b=w.get(x);if(!b||b.status===v)return w;const j=new Map(w);return j.set(x,{...b,status:v}),j})},[]),h=y.useCallback(x=>{t(v=>{let w=!1;const b=new Map(v),j=new Set(x.map(S=>S.id));for(const[S,N]of b)N.type==="task"&&!j.has(S)&&(b.delete(S),w=!0);for(const S of x){const N=b.get(S.id);N?(N.name!==S.title||N.outputPath!==S.outputPath)&&(b.set(S.id,{...N,name:S.title,outputPath:S.outputPath}),w=!0):(b.set(S.id,{id:S.id,name:S.title,type:"task",status:"running",outputPath:S.outputPath}),w=!0)}return w?b:v})},[]),g=y.useCallback((x,v,w)=>{v&&w&&t(b=>{if(b.has(x))return b;const j=new Map(b);return j.set(x,{id:x,name:w,type:"task",status:"running",outputPath:v}),j}),o(b=>b===x?(a(!0),b):(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 vF(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=bF(t),[p,h]=y.useState(null),[g,x]=y.useState(0),v=y.useRef(0),w=s??o??void 0,b=!!(w&&(p==null?void 0:p.kind)==="preview"&&p.cwd===w),j=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(w??null)?p:null;let S;e[0]!==a||e[1]!==o?(S={path:o,dirName:a},e[0]=a,e[1]=o,e[2]=S):S=e[2];const N=S;let C;e[3]!==l||e[4]!==a||e[5]!==o||e[6]!==s||e[7]!==i?(C=()=>{if(Ds()){console.warn("[open-terminal] unavailable for remote devices");return}const G=s??o??void 0,Y=i??a??l??void 0;if(!G&&!Y){console.warn("[open-terminal] no project path available");return}_e("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:G,dirName:Y})}).then(kF).catch(NF)},e[3]=l,e[4]=a,e[5]=o,e[6]=s,e[7]=i,e[8]=C):C=e[8];const k=C;let T;e[9]!==l||e[10]!==a||e[11]!==o||e[12]!==s||e[13]!==i?(T=G=>{if(Ds()){console.warn("[mcp-auth] unavailable for remote devices");return}const Y=s??o??void 0,J=i??a??l??void 0;!Y&&!J||_e("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Y,dirName:J,command:"claude /mcp"})}).catch(SF)},e[9]=l,e[10]=a,e[11]=o,e[12]=s,e[13]=i,e[14]=T):T=e[14];const E=T;let P;e[15]!==o||e[16]!==m||e[17]!==s?(P=()=>{const Y=[...m.processes.values()].filter(jF).at(-1);if(!Y){(s??o)&&x(wF);return}m.activeProcessId===Y.id&&!m.collapsed?m.toggleCollapse():m.setActive(Y.id)},e[15]=o,e[16]=m,e[17]=s,e[18]=P):P=e[18];const _=P;let A;e[19]!==o||e[20]!==s?(A=()=>{(s??o)&&x(yF)},e[19]=o,e[20]=s,e[21]=A):A=e[21];const I=A;let R;e[22]!==f||e[23]!==w||e[24]!==b?(R=()=>{w&&y.startTransition(()=>{f(),h(b?null:{kind:"preview",cwd:w})})},e[22]=f,e[23]=w,e[24]=b,e[25]=R):R=e[25];const $=R;let M;e[26]!==d||e[27]!==f||e[28]!==w||e[29]!==u?(M=()=>{if(w){if(d===St.projectFiles){f();return}y.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),u(St.projectFiles)})}},e[26]=d,e[27]=f,e[28]=w,e[29]=u,e[30]=M):M=e[30];const L=M;let D;e[31]!==w||e[32]!==u||e[33]!==c?(D=G=>{if(!c)return!1;const Y=XN(G,w);if(!Y)return!1;v.current=v.current+1;const J=v.current;return y.startTransition(()=>h({kind:"project-files",root:Y.root,anchorCwd:w??null,request:Y.file?{file:Y.file,mode:Y.mode,line:Y.line,token:J}:null})),u(St.projectFiles),!0},e[31]=w,e[32]=u,e[33]=c,e[34]=D):D=e[34];const F=D;let z,O;e[35]!==F?(O=()=>YN(F),z=[F],e[35]=F,e[36]=z,e[37]=O):(z=e[36],O=e[37]),y.useEffect(O,z);let H;e[38]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{y.startTransition(()=>h(null))},e[38]=H):H=e[38];const W=H,U=!!(w&&d===St.projectFiles),V=j==null?void 0:j.root,q=(j==null?void 0:j.request)??null;let X;return e[39]!==w||e[40]!==E||e[41]!==I||e[42]!==k||e[43]!==_||e[44]!==$||e[45]!==L||e[46]!==g||e[47]!==N||e[48]!==m||e[49]!==b||e[50]!==U||e[51]!==V||e[52]!==q?(X={processPanel:m,currentCwd:w,showPreview:b,showProjectFiles:U,projectFilesRoot:V,projectFilesRequest:q,launchTerminalRequest:g,pendingProject:N,handleOpenTerminal:k,handleMcpAuth:E,handleToggleIntegratedTerminal:_,handleNewIntegratedTerminal:I,handleTogglePreview:$,handleToggleProjectFiles:L,closeRightWorkspace:W},e[39]=w,e[40]=E,e[41]=I,e[42]=k,e[43]=_,e[44]=$,e[45]=L,e[46]=g,e[47]=N,e[48]=m,e[49]=b,e[50]=U,e[51]=V,e[52]=q,e[53]=X):X=e[53],X}function yF(n){return n+1}function wF(n){return n+1}function jF(n){return n.type==="terminal"}function SF(n){return console.error("[mcp-auth] open-terminal failed:",n)}function NF(n){return console.error("[open-terminal] fetch failed:",n)}function kF(n){n.ok||n.json().then(_F).catch(CF)}function CF(){}function _F(n){return console.error("[open-terminal]",n.error)}function TF(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
151
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const EF={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function Iv(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:At(n.dirName)}}function AF(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...EF},rawMessages:[],agentKind:At(n.dirName)}}function Rv(n){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:Ha(n)}}catch{return null}}async function PF(n,e,t=3,s=100,o=!0){if(o){const i=Rv(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 _e(`/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:Ha(l)}}catch{}}i<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function $F(n,e,t,s){let o=s;for(let i=0;i<30;i++){if(e.signal.aborted)return;const a=await PF(n,e,1,0,!1);if(a&&a.rawText!==o){t({type:"RELOAD_SESSION_CONTENT",session:a.parsed,source:Iv(n,a.rawText)});return}o=(a==null?void 0:a.rawText)??o,await new Promise(l=>setTimeout(l,200))}}async function u1(n,e,t,s,o){const i=Rv(n.initialContent),a=(i==null?void 0:i.rawText)??"",l=(i==null?void 0:i.parsed)??AF(n),c=Iv(n,a);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),o(l,c),$F(n,e,t,a),n.sessionId}async function IF(n,e,t,s){const o=await _e(`/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 RF({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]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),v=y.useRef(null),w=y.useRef(null),b=y.useRef(null),j=y.useCallback((k,T)=>{w.current=k,b.current=T??null,h(null),m(!1),e({type:"INIT_PENDING_SESSION",dirName:k,cwd:T,isMobile:t})},[e,t]),S=y.useCallback(async(k,T)=>{var R;const E=w.current;if(!E)return null;const P=At(E),_=b.current;(R=v.current)==null||R.abort();const A=new AbortController;v.current=A,m(!0),h(null),o==null||o(k);const I=Date.now();try{const $=TF(k),M=on(P),{capabilities:L}=M,D={dirName:E,cwd:M.dirName.lossy?_??void 0:void 0,message:k,images:T,permissions:n,effort:l||void 0,fastMode:c?!0:void 0,ultracode:L.ultracode&&d?!0:void 0,name:L.namedSessions&&$||void 0,worktreeName:L.worktrees&&g?bj(k):void 0,mcpConfig:L.mcp&&u||void 0},{res:F,errorMessage:z}=await fv(W=>_e("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...D,model:W}),signal:A.signal}),{model:a,agentKind:P,errorFallback:"Unknown error",onModelRejected:i});if(!F.ok){if(P==="codex"){const W=await IF(E,k,I,A);if(W){w.current=null,b.current=null;const U=await u1(W,A,e,t,s);return $&&U&&Qc(U,$),U}}return h(z||`Failed to create session (${F.status})`),null}const O=await F.json();w.current=null,b.current=null;const H=await u1(O,A,e,t,s);return $&&H&&Qc(H,$),H}catch($){return A.signal.aborted||h($ instanceof Error?$.message:"Failed to create session"),null}finally{A.signal.aborted||m(!1)}},[n,a,l,c,d,u,g,e,t,s,o,i]),N=y.useCallback(()=>h(null),[]),C=y.useCallback(()=>{var k;(k=v.current)==null||k.abort(),v.current=null,w.current=null,b.current=null,m(!1),h(null)},[]);return{creatingSession:f,createError:p,clearCreateError:N,handleNewSession:j,createAndSend:S,cancelCreation:C,worktreeEnabled:g,setWorktreeEnabled:x}}function MF(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=y.useRef(null),g=y.useRef(null),[x,v]=y.useState(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=U=>{var V;(V=h.current)==null||V.call(h,U),setTimeout(()=>{var q;return(q=g.current)==null?void 0:q.call(g)},300),setTimeout(()=>{var q;return(q=g.current)==null?void 0:q.call(g)},2e3)},e[0]=w):w=e[0];let b;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?(b={permissionsConfig:t,dispatch:s,isMobile:o,onSessionFinalized:w,onCreateStarted:v,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]=b):b=e[10];const j=RF(b),S=j.handleNewSession,[N,C]=y.useState(null);let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=new Map,e[11]=k):k=e[11];const T=y.useRef(k),E=OF;let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=async U=>{if(bi===null)return null;const V=T.current;if(V.has(U))return V.get(U)??null;const q=sj(await E(),U,bi);return V.set(U,q),q},e[12]=P):P=e[12];const _=P;let A;e[13]!==S?(A=async(U,V)=>{var Y;const q=V??((Y=(await E()).find(J=>J.dirName===U))==null?void 0:Y.path)??null;if(!q){C(null),S(U);return}const X=At(U)===bi?bi:null,G=X?wl(X,q):await _(q);C(G?{discoveredDirName:G,cwd:q}:null),S(X&&G?G:U,q)},e[13]=S,e[14]=A):A=e[14];const I=A;let R;e[15]!==i||e[16]!==I?(R=U=>{const V=wl(i,U);I(V,U)},e[15]=i,e[16]=I,e[17]=R):R=e[17];const $=R;let M;e[18]!==S||e[19]!==N?(M=U=>{if(!N)return;const V=wl(U,N.cwd,N.discoveredDirName);S(V,N.cwd)},e[18]=S,e[19]=N,e[20]=M):M=e[20];const L=M;let D;e:{if(!j.creatingSession||!a){D=null;break e}const U=x??void 0;let V;e[21]!==l||e[22]!==a||e[23]!==U?(V={dirName:a,cwd:l,firstMessage:U},e[21]=l,e[22]=a,e[23]=U,e[24]=V):V=e[24],D=V}const F=D;let z,O;e[25]!==a?(O=()=>{a||(v(null),C(null))},z=[a],e[25]=a,e[26]=z,e[27]=O):(z=e[26],O=e[27]),y.useEffect(O,z);const H=N?L:void 0;let W;return e[28]!==$||e[29]!==I||e[30]!==j.cancelCreation||e[31]!==j.clearCreateError||e[32]!==j.createAndSend||e[33]!==j.createError||e[34]!==j.creatingSession||e[35]!==j.setWorktreeEnabled||e[36]!==j.worktreeEnabled||e[37]!==F||e[38]!==H?(W={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:h,liveSessionsRefreshRef:g,pendingSessionInfo:F,pendingAgentKindChange:H,handleStartNewSession:I,handleStartNewFolder:$},e[28]=$,e[29]=I,e[30]=j.cancelCreation,e[31]=j.clearCreateError,e[32]=j.createAndSend,e[33]=j.createError,e[34]=j.creatingSession,e[35]=j.setWorktreeEnabled,e[36]=j.worktreeEnabled,e[37]=F,e[38]=H,e[39]=W):W=e[39],W}async function OF(){try{const n=await _e("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const uc=new Set;function LF(n,e){const t=gn(),s=vs();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function DF(n,e,t){const s=LF(n,e);if(!uc.has(s)&&!bn.get(n,e)){uc.add(s);try{await Bs(n,e,t,"session prefetch")}catch{}finally{uc.delete(s)}}}function zF({onAuthenticated:n}){const[e,t]=y.useState(null),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(!1),[d,u]=y.useState(null),[f,m]=y.useState(!1),p=e==="team";y.useEffect(()=>{let x=!1;return lg().then(v=>{x||t(v)}),()=>{x=!0}},[]);const h=y.useCallback(async x=>{if(x.preventDefault(),!(!i.trim()||p&&!s.trim())){m(!0),u(null);try{const v=await fetch("/api/auth/verify",p?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:s.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),w=await v.json();v.ok&&w.valid?(ka(),a(""),o(""),n()):u(w.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(Zt,{children:[r.jsxs(rn,{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(Dw,{className:"size-4"})}),r.jsx(an,{children:"Sign in to Cogpit"}),r.jsx(ln,{children:p?"Use your team account to continue.":"Enter the server password to continue."})]}),e===null?r.jsx(en,{children:r.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:r.jsx(Ze,{className:"size-5 text-muted-foreground"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(en,{className:"flex flex-col gap-4",children:[r.jsxs(To,{children:[p&&r.jsxs(vt,{children:[r.jsx(yt,{htmlFor:"login-username",children:"Username"}),r.jsx(It,{id:"login-username",type:"text",value:s,onChange:x=>o(x.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),r.jsxs(vt,{children:[r.jsx(yt,{htmlFor:"login-password",children:"Password"}),r.jsxs(os,{children:[r.jsx(rs,{id:"login-password",type:l?"text":"password",value:i,onChange:x=>a(x.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!p}),r.jsx(Sn,{align:"inline-end",children:r.jsx(Kr,{size:"icon-xs",onClick:()=>c(x=>!x),"aria-label":l?"Hide password":"Show password",children:l?r.jsx(ba,{}):r.jsx(gs,{})})})]})]})]}),d&&r.jsxs(ft,{variant:"destructive",children:[r.jsx(Wt,{"aria-hidden":"true"}),r.jsx(kt,{children:"Sign in failed"}),r.jsx(mt,{children:d})]})]}),r.jsx(qr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g,children:[f&&r.jsx(Ze,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}const f1=16,Ki="__cogpitBootstrapToken";function FF(){const e=new URLSearchParams(window.location.hash.replace(/^#/,"")).get("bootstrap")||"",t=window.history.state||{},s=e||(typeof t[Ki]=="string"?t[Ki]:"");return e&&window.history.replaceState({...t,[Ki]:e},"",`${window.location.pathname}${window.location.search}`),s}function m1(){const n={...window.history.state||{}};delete n[Ki],window.history.replaceState(n,"",`${window.location.pathname}${window.location.search}`)}function BF({onAuthenticated:n,onBootstrapClosed:e}){const[t]=y.useState(FF),[s,o]=y.useState(""),[i,a]=y.useState(""),[l,c]=y.useState(""),[d,u]=y.useState(""),[f,m]=y.useState(!1),[p,h]=y.useState(null),[g,x]=y.useState(!1),v=d.length>0&&d!==l,w=!t||!s.trim()||l.length<f1||d!==l,b=y.useCallback(async j=>{if(j.preventDefault(),!w){x(!0),h(null);try{const S=await fetch("/api/team/bootstrap",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1","X-Cogpit-Bootstrap-Token":t},body:JSON.stringify({username:s.trim(),password:l,...i.trim()?{displayName:i.trim()}:{}})}),N=await S.json();if(S.ok){m1(),c(""),u(""),o(""),a(""),await e(),n();return}if(S.status===410){m1(),await e();return}h(N.error||"Could not create the admin account")}catch{h("Failed to connect to server")}finally{x(!1)}}},[t,i,w,n,e,l,s]);return r.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-4 py-8",children:r.jsx("form",{onSubmit:b,className:"w-full max-w-md",children:r.jsxs(Zt,{children:[r.jsxs(rn,{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(zw,{className:"size-4"})}),r.jsx(an,{children:"Create the first admin"}),r.jsx(ln,{children:"Set up the account that will manage this Cogpit team server."})]}),r.jsxs(en,{className:"flex flex-col gap-4",children:[!t&&r.jsxs(ft,{children:[r.jsx(un,{"aria-hidden":"true"}),r.jsx(kt,{children:"Setup link required"}),r.jsx(mt,{children:"Open the one-time setup URL shown in the Cogpit server log."})]}),r.jsxs(To,{children:[r.jsxs(vt,{children:[r.jsx(yt,{htmlFor:"bootstrap-username",children:"Username"}),r.jsx(It,{id:"bootstrap-username",type:"text",value:s,onChange:j=>o(j.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0}),r.jsx(yo,{children:"Use 2 to 32 lowercase letters, numbers, dots, underscores, or hyphens."})]}),r.jsxs(vt,{children:[r.jsxs(yt,{htmlFor:"bootstrap-display-name",children:["Display name ",r.jsx("span",{className:"font-normal text-muted-foreground",children:"Optional"})]}),r.jsx(It,{id:"bootstrap-display-name",type:"text",value:i,onChange:j=>a(j.target.value),placeholder:"Display name (optional)",autoComplete:"name"})]}),r.jsxs(vt,{children:[r.jsx(yt,{htmlFor:"bootstrap-password",children:"Password"}),r.jsxs(os,{children:[r.jsx(rs,{id:"bootstrap-password",type:f?"text":"password",value:l,onChange:j=>c(j.target.value),placeholder:"Password",autoComplete:"new-password"}),r.jsx(Sn,{align:"inline-end",children:r.jsx(Kr,{size:"icon-xs",onClick:()=>m(j=>!j),"aria-label":f?"Hide password":"Show password",children:f?r.jsx(ba,{}):r.jsx(gs,{})})})]}),r.jsxs(yo,{children:["Use at least ",f1," characters."]})]}),r.jsxs(vt,{"data-invalid":v,children:[r.jsx(yt,{htmlFor:"bootstrap-confirm-password",children:"Confirm password"}),r.jsx(It,{id:"bootstrap-confirm-password",type:f?"text":"password",value:d,onChange:j=>u(j.target.value),placeholder:"Confirm password",autoComplete:"new-password","aria-invalid":v}),v&&r.jsx(ps,{children:"Passwords do not match"})]})]}),p&&r.jsxs(ft,{variant:"destructive",children:[r.jsx(Wt,{"aria-hidden":"true"}),r.jsx(kt,{children:"Could not create the account"}),r.jsx(mt,{children:p})]})]}),r.jsx(qr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:g||w,children:[g&&r.jsx(Ze,{"data-icon":"inline-start"}),"Create admin account"]})})]})})})}function UF(){const n=B.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=kd(),n[0]=e):e=n[0];const t=e,[s,o]=y.useState(null),[i,a]=y.useState(!1),[l,c]=y.useState(!1),d=y.useRef(0);let u,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{let _=!1;return ag().then(A=>{_||o(A)}),()=>{_=!0}},f=[],n[1]=u,n[2]=f):(u=n[1],f=n[2]),y.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 _=!1;const A=d.current;return t4().then(I=>{!_&&d.current===A&&(a(I),c(!0))}),()=>{_=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.edition)?(g=()=>{let _=!1;const A=()=>{const I=d.current=d.current+1,R=()=>{_||d.current!==I||(a(!1),c(!0))};if(t||(s==null?void 0:s.edition)==="team"){R();return}vm().then($=>{_||d.current!==I||(o($),$.edition==="team"&&R())})};return window.addEventListener("cogpit-auth-required",A),()=>{_=!0,window.removeEventListener("cogpit-auth-required",A)}},n[6]=s==null?void 0:s.edition,n[7]=g):g=n[7];const x=s==null?void 0:s.edition;let v;n[8]!==x?(v=[x,t],n[8]=x,n[9]=v):v=n[9],y.useEffect(g,v);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{d.current=d.current+1,a(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const b=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{o(await vm())},n[11]=j):j=n[11];const S=j;let N;n[12]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{d.current=d.current+1,a(!1),c(!0),n4().finally(WF)},n[12]=N):N=n[12];const C=N,k=(s==null?void 0:s.edition)??null,T=l&&s!==null,E=(s==null?void 0:s.needsBootstrap)===!0;let P;return n[13]!==i||n[14]!==k||n[15]!==T||n[16]!==E?(P={isRemote:t,edition:k,authChecked:T,authenticated:i,needsBootstrap:E,handleAuthenticated:b,refreshServerState:S,logout:C},n[13]=i,n[14]=k,n[15]=T,n[16]=E,n[17]=P):P=n[17],P}function WF(){window.dispatchEvent(new Event("cogpit-auth-changed"))}const HF=y.lazy(()=>qe(()=>import("./index-BtpxC457.js"),__vite__mapDeps([38,1,2,3,4])).then(n=>({default:n.BranchModal}))),qF=y.lazy(()=>qe(()=>import("./WorkflowsPanel-dlTy3KtX.js"),__vite__mapDeps([39,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function KF(){var Lf,Df,zf,Ff,Bf,Uf,Wf,Hf,qf,Kf,Vf,Gf,Yf,Xf,Jf,Qf,Zf,em,tm,nm;const n=nf(window.location.pathname),e=Uz(),t=UF(),s=Gz(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=ef(),d=vv(),[u,f]=mv(),{procBySession:m}=r2(),{parse:p,append:h}=Pv(),g=y.useCallback(Me=>{f({type:"SET_OLDER_TURNS",turns:Me})},[f]),x=y.useCallback((Me,Ke)=>{DF(Me,Ke,p)},[p]),v=$v({dirName:((Lf=u.sessionSource)==null?void 0:Lf.dirName)??null,fileName:((Df=u.sessionSource)==null?void 0:Df.fileName)??null,sessionChangeKey:u.sessionChangeKey,workerParse:p,onOlderTurns:g}),{loadMore:w}=v,b=!!u.searchQuery&&v.hasMore,j=((zf=u.session)==null?void 0:zf.turns.length)??0;y.useEffect(()=>{b&&w()},[b,w,j]);const S=uF(u,f),N=y.useRef(null),C=y.useRef(null),[k,T]=y.useState(!1),[E,P]=y.useState(!1),_=y.useCallback(()=>f({type:"TOGGLE_EXPAND_ALL"}),[f]),A=y.useCallback(()=>T(!0),[]),I=y.useCallback(()=>{var Me;return(Me=C.current)==null?void 0:Me.focus()},[]),R=y.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!0}),[f]),$=y.useCallback(()=>f({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[f]),M=y.useCallback(()=>f({type:"SET_EXPAND_ALL",value:!1}),[f]),L=S.toggleWorkspacePanel,D=y.useCallback(()=>L(St.sessionInfo),[L]),F=y.useCallback(Me=>{y.startTransition(()=>{f({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[f]),z=u.pendingCwd??(u.pendingDirName?vn(u.pendingDirName):null),O=((Ff=u.sessionSource)==null?void 0:Ff.agentKind)??At(((Bf=u.sessionSource)==null?void 0:Bf.dirName)??u.pendingDirName??null),H=(Uf=u.session)!=null&&Uf.sessionId?m.get(u.session.sessionId):void 0,W=Bt(O),U=tf(O,H),V=W.worktrees,q=W.mcp,X=cF(i?((Wf=u.session)==null?void 0:Wf.cwd)??z??void 0:void 0,i&&W.slashCommands),G=y.useCallback(Me=>{if(!i)return;const Ke=X.suggestions.find($t=>$t.name===Me);y.startTransition(()=>{f({type:"OPEN_CONFIG",filePath:Ke==null?void 0:Ke.filePath})})},[i,f,X.suggestions]),Y=y.useCallback(async(Me,Ke)=>{if(!i)return null;const $t=X.suggestions.find(Hn=>Hn.name===Me);if(!($t!=null&&$t.filePath))return null;try{const Hn=await _e("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:$t.filePath,args:Ke||""})});return Hn.ok?(await Hn.json()).content??null:null}catch{return null}},[i,X.suggestions]),{processPanel:J,currentCwd:Q,showPreview:Z,showProjectFiles:te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ie,handleOpenTerminal:se,handleMcpAuth:de,handleToggleIntegratedTerminal:ce,handleNewIntegratedTerminal:ue,handleTogglePreview:me,handleToggleProjectFiles:fe,closeRightWorkspace:ae}=vF({sessionId:(Hf=u.session)==null?void 0:Hf.sessionId,sessionCwd:(qf=u.session)==null?void 0:qf.cwd,pendingPath:z,sessionDirName:(Kf=u.sessionSource)==null?void 0:Kf.dirName,pendingDirName:u.pendingDirName,dashboardProject:u.dashboardProject,supportsFileWorkspace:!c&&a,activeWorkspacePanel:S.activeWorkspacePanel,openWorkspacePanel:S.openWorkspacePanel,closeWorkspacePanel:S.closeWorkspacePanel}),ve=rF(u.session??null),[ge,ye]=y.useState(!1),Pe=((Vf=u.sessionSource)==null?void 0:Vf.dirName)??u.pendingDirName??u.dashboardProject??null,{activeWorkspacePanel:De,closeWorkspacePanel:Te,showWorkflows:Ae}=S,pe=Zz(o&&V&&u.mainView==="sessions"&&De===St.worktrees?Pe:null),xe=y.useMemo(()=>{const Me=u.session;return Me?Me.turns.some(Ke=>ca(Ke.toolCalls,Me.cwd)||Ke.subAgentActivity.some($t=>ca($t.toolCalls,Me.cwd))):!1},[u.session]),ke=y.useMemo(()=>{if(!u.session||!W.workflows)return 0;let Me=0;for(const Ke of u.session.turns)for(const $t of Ke.toolCalls)$t.name==="Workflow"&&Me++;return Me},[u.session,W.workflows]),$e=ke>0,we=y.useMemo(()=>{const Me=u.sessionSource;return!Me||!W.workflows||ws(Me.fileName)?{dirName:null,sessionId:null}:{dirName:Me.dirName,sessionId:xc(Me.fileName)}},[u.sessionSource,W.workflows]),be=iz(we.dirName,we.sessionId,$e),Le=$e||be.workflows.length>0,Se=be.workflows.length||ke,Re=S.setShowWorkflows,Ne=y.useCallback(()=>Re(!0),[Re]),[Fe,He]=y.useState(!1),We=S.openWorkspacePanel;y.useEffect(()=>{if(!a)return;const Me=()=>{c?He(!0):We(St.fileChanges)};return window.addEventListener(kr,Me),()=>window.removeEventListener(kr,Me)},[a,We,c]);const Ee=y.useMemo(()=>u.session?C0(u.session):null,[u.session]),Be=y.useRef(null),{isLive:le,sseState:he,isCompacting:Ue,streamingOverlay:ze,turnError:Oe,agentProgress:Ye,promptSuggestion:Mt}=dv(u.sessionSource,Me=>{y.startTransition(()=>{f({type:"UPDATE_SESSION",session:Me})})},p,h,()=>{var Me;return(Me=Be.current)==null?void 0:Me.call(Be)},u.session),ut=lF(((Gf=u.session)==null?void 0:Gf.cwd)??null),ot=kz(),sf=ot.setMode,Un=Tz(U?null:((Yf=u.session)==null?void 0:Yf.sessionId)??null),of=U?null:Un.plan??Ee,{selectedModel:Lo,setSelectedModel:cl,selectedEffort:Ov,setSelectedEffort:dl,fastModeEnabled:Lv,ultracodeEnabled:Dv,effectiveEffort:ii,fastModeAvailable:zv,fastModeActive:ai,setFastModeEnabled:ul,ultracodeAvailable:Fv,ultracodeActive:li,setUltracodeEnabled:fl,imageInputAvailable:rf,modelFallbackNotice:Bv,dismissModelFallbackNotice:Uv,handleModelRejected:af}=hF({agentKind:O,session:u.session,sessionSource:u.sessionSource,pendingDirName:u.pendingDirName,isLive:le}),lf=tF((Xf=u.session)==null?void 0:Xf.sessionId,(Jf=u.sessionSource)==null?void 0:Jf.fileName);xF({sessionKey:lf,values:{model:Lo,effort:Ov,fastMode:Lv,ultracode:Dv,permissionMode:ot.config.mode},onHydrate:y.useCallback(Me=>{Me.model!==void 0&&cl(Me.model),Me.effort!==void 0&&dl(Me.effort),Me.fastMode!==void 0&&ul(Me.fastMode),Me.ultracode!==void 0&&fl(Me.ultracode),Me.permissionMode&&sf(Me.permissionMode)},[cl,dl,ul,fl,sf])});const Jt=oF(q&&i?Q:void 0,q&&i?Pe??void 0:void 0,q&&i?lf??void 0:void 0,i);y.useEffect(()=>{!V&&De===St.worktrees&&Te()},[V,De,Te]),y.useEffect(()=>{Ae&&!Le&&Re(!1)},[Ae,Le,Re]);const{creatingSession:cf,createError:df,clearCreateError:Wv,createAndSend:Hv,cancelCreation:uf,worktreeEnabled:qv,setWorktreeEnabled:Kv,sessionFinalizedRef:ci,liveSessionsRefreshRef:ff,pendingSessionInfo:mf,pendingAgentKindChange:Vv,handleStartNewSession:pf,handleStartNewFolder:Gv}=MF({permissionsConfig:ot.config,dispatch:f,isMobile:c,defaultAgentKind:e.defaultAgentKind,pendingDirName:u.pendingDirName,pendingCwd:u.pendingCwd,onModelRejected:af,model:Lo,effort:ii,fastMode:ai,ultracode:li,mcpConfig:q&&i?Jt.mcpConfigJson:null}),ht=cz({sessionSource:u.sessionSource,parsedSessionId:((Qf=u.session)==null?void 0:Qf.sessionId)??null,cwd:(Zf=u.session)==null?void 0:Zf.cwd,permissions:ot.config,onPermissionsApplied:ot.markApplied,model:Lo,effort:ii,fastMode:ai,ultracode:li,mcpConfig:q&&i?Jt.mcpConfigJson:null,onModelRejected:af,readOnly:U,onCreateSession:u.pendingDirName?Hv:void 0}),Ot=oz(W.agentTeams?((em=u.sessionSource)==null?void 0:em.fileName)??null:null,((tm=u.sessionSource)==null?void 0:tm.dirName)??null);y.useEffect(()=>{Ot!=null&&Ot.currentMemberName?f({type:"SET_CURRENT_MEMBER_NAME",name:Ot.currentMemberName}):Ot||f({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Ot==null?void 0:Ot.currentMemberName,Ot,f]),y.useEffect(()=>{c&&f({type:"GUARD_MOBILE_TAB",hasSession:!!u.session||!!u.pendingDirName})},[u.session,u.pendingDirName,u.mobileTab,c,f]);const Nn=pv({session:u.session,isLive:le,pendingMessages:ht.pendingMessages,consumePending:ht.consumePending,sessionChangeKey:u.sessionChangeKey,partialSignal:ze}),hf=Nn.chatScrollRef,gf=Nn.resetTurnCount,xf=Nn.scrollToBottomInstant,Yv=y.useCallback(Me=>{ye(Me),requestAnimationFrame(()=>{const Ke=hf.current;Ke&&Ke.scrollTo({top:Ke.scrollTop+(Me?64:-64),behavior:"smooth"})})},[hf]);y.useLayoutEffect(()=>{const Me=Ke=>{gf(0),xf()};return ci.current=Me,()=>{ci.current===Me&&(ci.current=null)}},[gf,xf,ci]);const Xv=y.useCallback(()=>{ht.disconnect(),uf()},[ht.disconnect,uf]),kn=fz({dispatch:f,isMobile:c,mobileTab:u.mobileTab,teamContext:Ot,scrollToBottomInstant:Nn.scrollToBottomInstant,resetTurnCount:Nn.resetTurnCount,workerParse:p,onBeforeSwitch:Xv}),Jv=y.useCallback(Me=>{y.startTransition(()=>{f({type:"GO_HOME",isMobile:c}),f({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[f,c]),{previewLoadError:Qv}=gz({state:u,dispatch:f,isMobile:c,resetTurnCount:Nn.resetTurnCount,scrollToBottomInstant:Nn.scrollToBottomInstant,workerParse:p}),di=Sz(),bf=di.push;y.useEffect(()=>{u.sessionSource&&bf(u.sessionSource.dirName,u.sessionSource.fileName)},[u.sessionSource,bf]);const pt=mF({state:{session:u.session,sessionSource:u.sessionSource},dispatch:f,isMobile:c,handleJumpToTurn:kn.handleJumpToTurn,markPermissionsApplied:ot.markApplied,hasPermsPendingChanges:ot.hasPendingChanges,permissionsConfig:ot.config,selectedModel:Lo,selectedEffort:ii,fastMode:ai,ultracode:li,mcpConfig:q&&i?Jt.mcpConfigJson:null,scrollRequestScrollToTop:Nn.requestScrollToTop,handleDashboardSelect:kn.handleDashboardSelect,workerParse:p}),{hasSettingsChanges:vf,handleApplySettings:yf}=pt,wf=q&&i&&Jt.mcpConfigJson!==null,jf=y.useRef(!1);y.useEffect(()=>{var $t;const Me=Jt.loaded&&!jf.current;jf.current=Jt.loaded;const Ke=($t=u.session)==null?void 0:$t.sessionId;Me&&Ke&&wf&&vf&&yf()},[Jt.loaded,wf,vf,yf,(nm=u.session)==null?void 0:nm.sessionId]),y.useLayoutEffect(()=>(Be.current=pt.reloadSession,()=>{Be.current===pt.reloadSession&&(Be.current=null)}),[pt.reloadSession]);const Wn=Tv(u.session,u.sessionSource,pt.reloadSession,a),ui=Wn.requestBranchSwitch,fi=pt.setBranchModalTurn,Zv=y.useCallback((Me,Ke)=>{ui(Me,Ke),fi(null)},[ui,fi]),ey=y.useCallback(Me=>{ui(Me),fi(null)},[ui,fi]);vz({isMobile:c,searchInputRef:N,chatInputRef:C,dispatch:f,onToggleSidebar:S.handleToggleSidebar,onToggleRightSidebar:D,onToggleMissionControl:S.handleToggleMission,onOpenCommandPalette:A,onOpenProjectSwitcher:S.handleOpenProjectSwitcher,onOpenThemeSelector:S.handleToggleThemeSelector,onOpenTerminal:se,onToggleIntegratedTerminal:ce,onTogglePreview:me,onToggleProjectFiles:fe,onHistoryBack:di.goBack,onHistoryForward:di.goForward,onNavigateToSession:kn.handleDashboardSelect,onCommitNavigation:di.commitNavigation});const{killing:ty,handleKillAll:ny}=eF(),is=u.sessionSource?ws(u.sessionSource.fileName):null,sy=is!==null&&!!(Ot!=null&&Ot.currentMemberName),ml=is!==null&&!sy,mi=kn.handleDashboardSelect,Sf=y.useCallback(()=>{!u.sessionSource||!is||mi(u.sessionSource.dirName,is.parentFileName)},[u.sessionSource,is,mi]);y.useEffect(()=>{const Me=Ke=>{const{agentId:$t}=Ke.detail??{};if(!$t||!u.sessionSource||!W.subagentTranscripts)return;const Hn=is?is.parentSessionId:xc(u.sessionSource.fileName);mi(u.sessionSource.dirName,`${Hn}/subagents/agent-${$t}.jsonl`)};return window.addEventListener(da,Me),()=>window.removeEventListener(da,Me)},[u.sessionSource,is,mi,W.subagentTranscripts]);const[oy,Nf]=y.useState(null),ry=pt.branchModalTurn!==null,Vs=pt.branchModalTurn??oy;y.useEffect(()=>{pt.branchModalTurn!==null&&Nf(pt.branchModalTurn)},[pt.branchModalTurn]);const kf=Vs!==null?Wn.branchesAtTurn(Vs):[],iy=ml?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(ur,{"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,ay=U?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(ur,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:z4(O)})]}):null,pl=iy||ay,ly=kn.loadError||df||null;let hl;kn.loadError?hl=kn.clearLoadError:df&&(hl=Wv);const cy=!!(u.session&&u.sessionSource&&he==="disconnected"),gl=y.useMemo(()=>({state:u,dispatch:f,config:e,theme:d,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,c]),xl=y.useMemo(()=>({session:u.session,sessionSource:u.sessionSource,isLive:le,sseState:he,isCompacting:Ue,turnError:Oe,promptSuggestion:Mt,undoRedo:Wn,pendingInteraction:of,permissionRequests:Un.requests,permissionResponding:Un.responding,respondPermission:Un.respond,respondAllPermissions:Un.respondAll,isSubAgentView:ml,slashSuggestions:X.suggestions,slashSuggestionsLoading:X.loading,actions:{handleStopSession:pt.handleStopSession,handleEditConfig:i?S.handleEditConfig:void 0,handleEditCommand:i?G:void 0,handleExpandCommand:i?Y:void 0,handleOpenBranches:pt.handleOpenBranches,handleBranchFromHere:pt.handleBranchFromHere,handleToggleExpandAll:_,handleLoadSession:pt.handleLoadSessionScrollAware}}),[u.session,u.sessionSource,le,he,Ue,Oe,Mt,Wn,of,ml,Un.requests,Un.responding,Un.respond,Un.respondAll,X.suggestions,X.loading,pt.handleStopSession,i,S.handleEditConfig,G,Y,pt.handleOpenBranches,pt.handleBranchFromHere,_,pt.handleLoadSessionScrollAware]),bl=y.useMemo(()=>({chat:{status:ht.status,error:ht.error,pendingMessages:ht.pendingMessages,isConnected:ht.isConnected,sendMessage:ht.sendMessage,interrupt:ht.interrupt,stopAgent:ht.stopAgent,consumePending:ht.consumePending},scroll:Nn}),[ht.status,ht.error,ht.pendingMessages,ht.isConnected,ht.sendMessage,ht.interrupt,ht.stopAgent,ht.consumePending,Nn]),Do=!!u.pendingDirName&&!u.session;if(y.useEffect(()=>{if(!Do||c)return;const Me=requestAnimationFrame(()=>{var Ke;return(Ke=C.current)==null?void 0:Ke.focus()});return()=>cancelAnimationFrame(Me)},[Do,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(tt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated)return t.needsBootstrap?r.jsx(BF,{onAuthenticated:t.handleAuthenticated,onBootstrapClosed:t.refreshServerState}):r.jsx(zF,{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(tt,{"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(tt,{"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(Gt,{children:[r.jsxs(Yt,{children:[r.jsx(nn,{variant:"icon",children:r.jsx(un,{className:"text-destructive"})}),r.jsx(Xt,{children:"Failed to connect"}),r.jsx(sn,{children:e.configError})]}),r.jsx(tg,{children:r.jsxs(ee,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[r.jsx(Et,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return i?r.jsx(KN,{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 vl=r.jsx(Jj,{activeError:ly,clearActiveError:hl,modelFallbackNotice:Bv,dismissModelFallbackNotice:Uv,connectionLost:cy,theme:d.activeTheme}),Cf=a?r.jsx(DN,{state:Wn.confirmState,isApplying:Wn.isApplying,applyError:Wn.applyError,onConfirm:Wn.confirmApply,onCancel:Wn.confirmCancel}):null,dy=Vs!==null&&u.session?u.session.turns.slice(Vs):[],_f=a&&Vs!==null&&kf.length>0&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(HF,{open:ry,branches:kf,branchPointTurnIndex:Vs,currentTurns:dy,onClose:pt.handleCloseBranchModal,onCloseComplete:()=>Nf(null),onRedoToTurn:Zv,onRedoEntireBranch:ey})}),Tf=l&&r.jsx(_N,{processes:J.processes,activeProcessId:J.activeProcessId,collapsed:J.collapsed,onSetActive:J.setActive,onRemove:J.removeProcess,onToggleCollapse:J.toggleCollapse,onRequestTerminal:et("terminal")?ue:void 0,onAddTerminalContext:Me=>{var sm,om,rm;const Ke=Me.trim();if(!Ke)return;const $t=Ke.includes("```")?"````":"```",Hn=`${$t}terminal
|
|
152
|
+
${Ke}
|
|
153
|
+
${$t}`,yl=((sm=C.current)==null?void 0:sm.getText().trimEnd())??"";(om=C.current)==null||om.setText(yl?`${yl}
|
|
154
|
+
|
|
155
|
+
${Hn}
|
|
156
|
+
`:`${Hn}
|
|
157
|
+
`),(rm=C.current)==null||rm.focus()},onUpdateStatus:J.updateProcessStatus,projectDir:Q,onProcessStarted:J.addProcess,mobile:c}),Ef=Ot&&r.jsx(y5,{teamName:Ot.config.name||Ot.teamName,members:Ot.config.members,currentMemberName:u.currentMemberName,loadingMember:u.loadingMember,onMemberClick:kn.handleTeamMemberSwitch}),Af=Le&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(qF,{open:S.showWorkflows,onOpenChange:S.setShowWorkflows,dirName:we.dirName,sessionId:we.sessionId,workflows:be.workflows,isLive:be.isLive,onRefetchList:be.refetch},`${we.dirName??""}:${we.sessionId??""}`)}),pi=W.goals?u.session:null,Pf=Me=>{var Ke;return r.jsx(g5,{agentKind:O,onAgentKindChange:Do?Vv:void 0,selectedModel:Lo,onModelChange:cl,selectedEffort:ii,onEffortChange:dl,fastModeEnabled:ai,onFastModeEnabledChange:zv?ul:void 0,isNewSession:Do,worktreeEnabled:qv,onWorktreeEnabledChange:Do&&V?Kv:void 0,ultracodeEnabled:li,onUltracodeEnabledChange:Fv?fl:void 0,onApplySettings:pt.handleApplySettings,activeModelId:(Ke=u.session)==null?void 0:Ke.model,mcpServers:q&&i?Jt.servers:void 0,selectedMcpServers:q&&i?Jt.selectedServers:void 0,onToggleMcpServer:q&&i?Jt.toggleServer:void 0,onSetMcpServers:q&&i?Jt.setSelection:void 0,onRefreshMcpServers:q&&i?Jt.refresh:void 0,mcpLoading:q&&i?Jt.loading:void 0,onMcpAuth:q&&i?de:void 0,permissionMode:ot.config.mode,onPermissionModeChange:ot.setMode,mobileExtra:c&&Me&&pi?r.jsx(nN,{}):void 0,trailingExtra:!c&&Me&&pi?r.jsx(Vg,{}):void 0,mobile:c})},$f=Pf(!0),If=Pf(!1),Rf=r.jsxs("div",{className:K("shrink-0",c&&"bg-background"),children:[!c&&r.jsx(Kg,{}),r.jsx($c,{ref:C,allowImages:rf,agentKind:O,projectCwd:Q,compact:c,leadingAccessory:c?$f:void 0,footer:c?void 0:$f})]}),hi=pi?r.jsx(tN,{agentKind:O,session:pi,onSendCommand:ht.sendMessage,children:Rf}):Rf,uy=r.jsx("div",{className:K("shrink-0",c&&"bg-background"),children:r.jsx($c,{ref:C,allowImages:rf,agentKind:O,projectCwd:Q,compact:c,leadingAccessory:c?If:void 0,footer:c?void 0:If})}),Mf=ht.pendingMessages.map((Me,Ke)=>r.jsx(D0,{message:Me,turnNumber:Ke+1},Ke)),fy=c?u.mobileTab==="stats":S.activeWorkspacePanel===St.sessionInfo,Of=u.session&&!fy&&r.jsx("div",{className:"hidden",children:r.jsx(ex,{cwd:u.session.cwd,turns:u.session.turns,onServersChanged:J.handleServersChanged})});return n?r.jsxs(Hi,{value:gl,children:[r.jsx(Cl,{children:r.jsx(Bi,{value:xl,chatValue:bl,children:r.jsx(Dl,{value:ze,agentProgress:Ye,children:r.jsx(ZD,{sessionId:n,loadError:Qv,searchInputRef:N,activeComposer:pl||uy,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore})})})}),vl]}):c?r.jsxs(Hi,{value:gl,children:[r.jsx(Cl,{enabled:l,children:r.jsx(Bi,{value:xl,chatValue:bl,children:r.jsx(Dl,{value:ze,agentProgress:Ye,children:r.jsx(QD,{navigation:{actions:kn,handlers:pt,creatingSession:cf,pendingSession:mf,onStartNewSession:pf,onSelectProject:F,liveSessionsRefreshRef:ff,onPrefetchSession:x},sessionView:{searchInputRef:N,teamMembersBar:Ef,activeComposer:pl||hi,pendingComposer:hi,pendingTurns:Mf,todoProgress:ve&&r.jsx(z0,{progress:ve}),hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Sf,onShowWorkflows:Ne,onToggleExpandAll:_,workflowCount:Se,pendingPath:z},project:{processPanel:J,backgroundAgents:ut,hasFileChanges:a&&xe,onOpenTerminal:se},chrome:{backgroundServers:Of,processPanel:Tf,workflowsPanel:Af,undoDialog:Cf,branchModal:_f,fileChangesOpen:Fe,onFileChangesOpenChange:He}})})})}),vl]}):r.jsxs(Hi,{value:gl,children:[r.jsx(Cl,{enabled:l,children:r.jsx(Bi,{value:xl,chatValue:bl,children:r.jsx(Dl,{value:ze,agentProgress:Ye,children:r.jsx(UD,{navigation:{panels:S,actions:kn,handlers:pt,creatingSession:cf,pendingSession:mf,onStartNewSession:pf,onStartNewFolder:Gv,onSelectProject:F,onOpenPaletteProject:Jv,liveSessionsRefreshRef:ff,onPrefetchSession:x},sessionView:{searchInputRef:N,chatInputRef:C,teamMembersBar:Ef,activeComposer:pl||hi,pendingComposer:hi,pendingTurns:Mf,todoProgress:ve,todosExpanded:ge,onTodosExpandedChange:Yv,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Sf,onShowWorkflows:Ne,workflowCount:Se},project:{processPanel:J,worktrees:pe,backgroundAgents:ut,supportsWorktrees:V,hasFileChanges:a&&xe,currentCwd:Q,showPreview:Z,showProjectFiles:a&&te,projectFilesRoot:ne,projectFilesRequest:oe,launchTerminalRequest:re,pendingProject:ie,onOpenTerminal:se,onTogglePreview:me,onToggleProjectFiles:fe,onCloseRightWorkspace:ae},chrome:{backgroundServers:Of,processPanel:Tf,workflowsPanel:Af,undoDialog:Cf,branchModal:_f,killing:ty,onKillAll:ny,commandPaletteOpen:k,onCommandPaletteOpenChange:T,onOpenCommandPalette:A,onFocusComposer:I,onExpandAll:R,onExpandToolPayloads:$,onCollapseAll:M,keyboardShortcutsOpen:E,onKeyboardShortcutsOpenChange:P}})})})}),vl]})}function VF(){var w;const[n,e]=y.useState(gt),[t,s]=y.useState(()=>Fi(gt())),[o,i]=y.useState(vs),[a,l]=y.useState(0),[c,d]=y.useState(!1),[u,f]=y.useState(!1),[m,p]=y.useState(!1),{devices:h,testDevice:g}=Za();y.useEffect(()=>{const b=()=>{const j=gt();e(S=>S===j?S:j),s(Fi(j))};return window.addEventListener("cogpit-device-changed",b),window.addEventListener("popstate",b),()=>{window.removeEventListener("cogpit-device-changed",b),window.removeEventListener("popstate",b)}},[]),y.useEffect(()=>{const b=j=>{const S=j.detail;(S==null?void 0:S.deviceId)===gt()&&s(Fi(S.deviceId))};return window.addEventListener("cogpit-device-scope-changed",b),()=>window.removeEventListener("cogpit-device-scope-changed",b)},[]),y.useEffect(()=>{const b=()=>i(vs());return window.addEventListener("cogpit-identity-changed",b),()=>window.removeEventListener("cogpit-identity-changed",b)},[]),y.useEffect(()=>(window.__cogpitRevealSession=ob,()=>{delete window.__cogpitRevealSession}),[]),y.useEffect(()=>{const b=j=>{const S=[Nt,...h.map(T=>T.id)],N=gt();let C;const k=hP(j);if(k!==null)C=S[k-1];else if(gP(j)){const T=S.indexOf(N);C=S[(T+1)%S.length]}!C||C===N||(j.preventDefault(),ys(C))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[h]),y.useEffect(()=>{const b=j=>{const S=j.detail;!(S!=null&&S.deviceId)||S.deviceId!==gt()||(d(!0),S.reason==="DEVICE_AUTH_FAILED"&&f(!0))};return window.addEventListener("cogpit-device-unreachable",b),()=>window.removeEventListener("cogpit-device-unreachable",b)},[]),y.useEffect(()=>{d(!1),f(!1),p(!1)},[n,t]);const x=y.useCallback(async()=>{p(!0);try{const b=await g(n);b.reachable&&b.authState==="bad-password"?f(!0):b.ok&&(d(!1),f(!1),l(j=>j+1))}finally{p(!1)}},[n,g]);y.useEffect(()=>{if(!c||u)return;const b=setInterval(()=>void x(),1e4);return()=>clearInterval(b)},[c,u,x]);const v=((w=h.find(b=>b.id===n))==null?void 0:w.name)??n;return r.jsxs(r.Fragment,{children:[c&&n!==Nt&&r.jsxs(ft,{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(Fw,{"data-icon":"inline-start",className:"text-warning"}),r.jsx(kt,{children:u?"Device credentials need attention":"Remote device unavailable"}),r.jsx(mt,{children:u?`${v} rejected the stored password. Update it in Devices.`:`Can’t reach ${v}. 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(tt,{"data-icon":"inline-start",className:"animate-spin"}),m?"Retrying":"Retry now"]}),r.jsx(ee,{variant:"outline",size:"xs",onClick:()=>ys(Nt),children:"Switch to this machine"})]})]}),r.jsx(iT,{children:r.jsx(eD,{children:r.jsx(KF,{})})},`${n}:${t}:${a}:${o??""}`)]})}const p1="Invalid link or passphrase.";function GF(n,e){return n===401?p1: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||p1}function YF({sessionId:n,onAuthenticated:e}){const[t,s]=y.useState(""),[o,i]=y.useState(!1),[a,l]=y.useState(null),[c,d]=y.useState(!1),u=y.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(GF(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(Zt,{children:[r.jsxs(rn,{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(Zn,{className:"size-4"})}),r.jsx(an,{children:"Join this session"}),r.jsx(ln,{children:"Enter the passphrase you were given to join the shared session."})]}),r.jsxs(en,{className:"flex flex-col gap-4",children:[r.jsx(To,{children:r.jsxs(vt,{children:[r.jsx(yt,{htmlFor:"share-passphrase",children:"Passphrase"}),r.jsxs(os,{children:[r.jsx(rs,{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(Sn,{align:"inline-end",children:r.jsx(Kr,{size:"icon-xs",onClick:()=>i(f=>!f),"aria-label":o?"Hide passphrase":"Show passphrase",children:o?r.jsx(ba,{}):r.jsx(gs,{})})})]})]})}),a&&r.jsxs(ft,{variant:"destructive",children:[r.jsx(Wt,{"aria-hidden":"true"}),r.jsx(kt,{children:"Could not join"}),r.jsx(mt,{children:a})]})]}),r.jsx(qr,{children:r.jsxs(ee,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&r.jsx(Ze,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function XF(){const n=B.c(9),[e,t]=y.useState("idle"),[s,o]=y.useState();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],n[0]=i):i=n[0];const[a,l]=y.useState(i);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,v)=>{l(w=>[...w,x]),t("connected"),o(void 0),AS(x,v).then(w=>{if(w.ok){t("idle");return}o(`Request failed (${w.status})`),t("error"),l(ZF)}).catch(w=>{o(w instanceof Error?w.message:"Unknown error"),t("error"),l(QF)})},n[1]=c):c=n[1];const d=c;let u;n[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{PS().catch(JF),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 v=x===void 0?1:x;l(w=>w.slice(v))},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 JF(){}function QF(n){return n.slice(0,-1)}function ZF(n){return n.slice(0,-1)}const eB=2e3;function tB(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function nB(){const n=B.c(11);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,n[1]=o):o=n[1];const[i,a]=y.useState(o);let l,c;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let h=!1;const g=async()=>{const w=await MS();h||w===null||s(b=>tB(b,w)?b:w)},x=()=>{document.visibilityState==="visible"&&g()};x();const v=setInterval(x,eB);return document.addEventListener("visibilitychange",x),()=>{h=!0,clearInterval(v),document.removeEventListener("visibilitychange",x)}},c=[],n[2]=l,n[3]=c):(l=n[2],c=n[3]),y.useEffect(l,c);let d;n[4]===Symbol.for("react.memo_cache_sentinel")?(d=(h,g)=>{a(x=>new Set(x).add(h)),IS(h,g).then(x=>{x&&s(v=>v.filter(w=>w.requestId!==h))}).finally(()=>{a(x=>{const v=new Set(x);return v.delete(h),v})})},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 sB={capabilities:Br};function oB(n){var ce,ue;const e=B.c(77),{info:t,children:s}=n,o=ef(),i=vv(),[a,l]=mv(),{parse:c,append:d}=Pv(),[u,f]=y.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],y.useEffect(lB,m);const p=XF(),h=nB();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==o||e[5]!==c?(g=async()=>{try{const{parsed:me,source:fe}=await gv(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:me,source:fe,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,v=y.useRef(!1);let w,b;e[7]!==x?(w=()=>{v.current||(v.current=!0,x())},b=[x],e[7]=x,e[8]=w,e[9]=b):(w=e[8],b=e[9]),y.useEffect(w,b);let j;e[10]!==l?(j=me=>{l({type:"UPDATE_SESSION",session:me})},e[10]=l,e[11]=j):j=e[11];const S=j,{isLive:N,sseState:C,isCompacting:k,turnError:T}=dv(a.sessionSource,S,c,d,void 0,a.session);let E;e[12]!==l?(E=me=>{l({type:"SET_OLDER_TURNS",turns:me})},e[12]=l,e[13]=E):E=e[13];const P=E,_=((ce=a.sessionSource)==null?void 0:ce.dirName)??null,A=((ue=a.sessionSource)==null?void 0:ue.fileName)??null;let I;e[14]!==P||e[15]!==a.sessionChangeKey||e[16]!==_||e[17]!==A||e[18]!==c?(I={dirName:_,fileName:A,sessionChangeKey:a.sessionChangeKey,workerParse:c,onOlderTurns:P},e[14]=P,e[15]=a.sessionChangeKey,e[16]=_,e[17]=A,e[18]=c,e[19]=I):I=e[19];const R=$v(I);let $;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==N||e[23]!==a.session||e[24]!==a.sessionChangeKey?($={session:a.session,isLive:N,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:a.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=N,e[23]=a.session,e[24]=a.sessionChangeKey,e[25]=$):$=e[25];const M=pv($),L=Tv(a.session,a.sessionSource,x,!1);let D;e[26]!==a.session?(D=a.session?C0(a.session):null,e[26]=a.session,e[27]=D):D=e[27];const F=D;let z;e[28]!==l?(z=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=z):z=e[29];const O=z,H=iB,W=rB;let U;e[30]!==t.dirName?(U=At(t.dirName),e[30]=t.dirName,e[31]=U):U=e[31];let V;e[32]!==U?(V={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:U,setClaudeDir:W,showConfigDialog:!1,openConfigDialog:W,handleCloseConfigDialog:W,handleConfigSaved:W,retryConfig:W,networkUrl:null,networkAccessDisabled:!1},e[32]=U,e[33]=V):V=e[33];let q;e[34]!==l||e[35]!==o||e[36]!==a||e[37]!==V||e[38]!==i?(q={state:a,dispatch:l,config:V,theme:i,isMobile:o},e[34]=l,e[35]=o,e[36]=a,e[37]=V,e[38]=i,e[39]=q):q=e[39];const X=q;let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=[],e[40]=G):G=e[40];let Y;e[41]!==O?(Y={handleStopSession:H,handleOpenBranches:W,handleBranchFromHere:W,handleToggleExpandAll:O,handleLoadSession:W},e[41]=O,e[42]=Y):Y=e[42];let J;e[43]!==k||e[44]!==N||e[45]!==F||e[46]!==h.requests||e[47]!==h.respond||e[48]!==h.respondAll||e[49]!==h.responding||e[50]!==C||e[51]!==a.session||e[52]!==a.sessionSource||e[53]!==Y||e[54]!==T||e[55]!==L?(J={session:a.session,sessionSource:a.sessionSource,isLive:N,sseState:C,isCompacting:k,turnError:T,undoRedo:L,pendingInteraction:F,permissionRequests:h.requests,permissionResponding:h.responding,respondPermission:h.respond,respondAllPermissions:h.respondAll,isSubAgentView:!1,slashSuggestions:G,slashSuggestionsLoading:!1,promptSuggestion:null,actions:Y},e[43]=k,e[44]=N,e[45]=F,e[46]=h.requests,e[47]=h.respond,e[48]=h.respondAll,e[49]=h.responding,e[50]=C,e[51]=a.session,e[52]=a.sessionSource,e[53]=Y,e[54]=T,e[55]=L,e[56]=J):J=e[56];const Q=J;let Z;e[57]!==p||e[58]!==M?(Z={chat:p,scroll:M},e[57]=p,e[58]=M,e[59]=Z):Z=e[59];const te=Z;let ne;e[60]!==R?(ne=()=>{R.loadMore()},e[60]=R,e[61]=ne):ne=e[61];let oe;e[62]!==u||e[63]!==R.hasMore||e[64]!==R.isLoadingOlder||e[65]!==ne?(oe={loadState:u,hasMore:R.hasMore,isLoadingOlder:R.isLoadingOlder,loadMore:ne},e[62]=u,e[63]=R.hasMore,e[64]=R.isLoadingOlder,e[65]=ne,e[66]=oe):oe=e[66];const re=oe;let ie;e[67]!==s||e[68]!==re?(ie=s(re),e[67]=s,e[68]=re,e[69]=ie):ie=e[69];let se;e[70]!==te||e[71]!==Q||e[72]!==ie?(se=r.jsx(Bi,{value:Q,chatValue:te,children:ie}),e[70]=te,e[71]=Q,e[72]=ie,e[73]=se):se=e[73];let de;return e[74]!==X||e[75]!==se?(de=r.jsx(Hi,{value:X,children:se}),e[74]=X,e[75]=se,e[76]=de):de=e[76],de}function rB(){}async function iB(){await $S().catch(aB)}function aB(){}function lB(){co(sB)}function cB(n){const e=B.c(6),{info:t}=n,s=y.useRef(null);let o;e[0]!==t.provider||e[1]!==t.title?(o=a=>r.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-background",children:[r.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[r.jsx(Zn,{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(ft,{variant:"destructive",className:"max-w-sm",children:[r.jsx(Wt,{"aria-hidden":"true"}),r.jsx(kt,{children:"Session unavailable"}),r.jsx(mt,{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(Ze,{className:"size-5 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsx(Qa,{searchInputRef:s,hasMore:a.hasMore,isLoadingOlder:a.isLoadingOlder,onLoadMore:a.loadMore}),r.jsx(al,{children:r.jsx($c,{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(oB,{info:t,children:o}),e[3]=t,e[4]=o,e[5]=i):i=e[5],i}function fc(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 dB(){const n=B.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Fg(window.location.pathname),n[0]=e):e=n[0];const t=e;let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=t?{kind:"probing"}:{kind:"error",message:"This share link is not valid."},n[1]=s):s=n[1];const[o,i]=y.useState(s);let a;n[2]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{i({kind:"probing"});const p=await ES();i(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=a):a=n[2];const l=a;let c,d;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},d=[l,t],n[3]=c,n[4]=d):(c=n[3],d=n[4]),y.useEffect(c,d);let u,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const p=()=>{i(uB)};return window.addEventListener(Pc,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(Pc,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=u,n[6]=f):(u=n[5],f=n[6]),y.useEffect(u,f),o.kind==="ready"){let p;return n[7]!==o.info?(p=r.jsx(cB,{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(YF,{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(fc,{children:r.jsx(Zt,{children:r.jsxs(rn,{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(an,{children:"Sharing has ended"}),r.jsx(ln,{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(Wt,{"aria-hidden":"true"}),h=r.jsx(kt,{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(ft,{variant:"destructive",children:[p,h,r.jsx(mt,{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 v;return n[16]!==g?(v=r.jsxs(fc,{children:[g,x]}),n[16]=g,n[17]=v):v=n[17],v}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(fc,{children:r.jsx(Zt,{children:r.jsxs(en,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[r.jsx(Zn,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r.jsx(Ze,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function uB(n){return n.kind==="ready"?{kind:"ended"}:n}class fB extends y.Component{constructor(){super(...arguments);gi(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(Zt,{className:"w-full max-w-lg text-center",children:[r.jsxs(rn,{className:"justify-items-center",children:[r.jsx(un,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),r.jsx(an,{children:r.jsx("h1",{children:"Cogpit hit a render error"})}),r.jsx(ln,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),r.jsx(en,{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(qr,{className:"justify-center",children:r.jsxs(ee,{onClick:()=>window.location.reload(),children:[r.jsx(Et,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Mv=document.getElementById("root");if(!Mv)throw new Error("Root element not found");xy.createRoot(Mv).render(r.jsx(y.StrictMode,{children:r.jsx(fB,{children:$a(window.location.pathname)?r.jsx(dB,{}):r.jsx(VF,{})})}));export{Ht as $,ft as A,ee as B,SB as C,es as D,Gt as E,tA as F,Xt as G,sn as H,Sn as I,Mg as J,Ja as K,bB as L,Ca as M,Ig as N,Rg as O,$g as P,jt as Q,sj as R,c5 as S,Za as T,To as U,vt as V,Kr as W,ps as X,j9 as Y,S9 as Z,K as _,d5 as a,on as a$,Vr as a0,hx as a1,ek as a2,jn as a3,Ie as a4,Dr as a5,ct as a6,Pt as a7,So as a8,dt as a9,Fc as aA,Nr as aB,ku as aC,Bn as aD,Ia as aE,Pg as aF,Zr as aG,rn as aH,an as aI,en as aJ,qr as aK,Zt as aL,Ha as aM,WS as aN,P0 as aO,Xn as aP,at as aQ,Rn as aR,kt as aS,ln as aT,nx as aU,Wr as aV,rz as aW,Aa as aX,yt as aY,yo as aZ,E$ as a_,Ud as aa,Wd as ab,Hd as ac,MN as ad,Kd as ae,Vd as af,qd as ag,Yd as ah,Gd as ai,qn as aj,Kl as ak,mP as al,Ze as am,G5 as an,jB as ao,Bd as ap,Ds as aq,et as ar,Qd as as,cx as at,dx as au,Na as av,OB as aw,BE as ax,CS as ay,Fn as az,u5 as b,yB as b0,It as b1,Vl as b2,UN as b3,Sa as b4,tx as b5,vB as b6,Ct as b7,_t as b8,Tt as b9,zt as bA,Po as bB,CB as bC,kB as bD,Qi as bE,$o as bF,Ao as bG,y4 as bH,wB as bI,cL as bJ,Ga as ba,Ya as bb,Xa as bc,Ms as bd,TB as be,Ft as bf,No as bg,$N as bh,it as bi,G4 as bj,_B as bk,gu as bl,Q0 as bm,vu as bn,oa as bo,Ks as bp,r2 as bq,tD as br,Hb as bs,Io as bt,Ss as bu,q7 as bv,og as bw,Ps as bx,sg as by,tg as bz,l5 as c,s5 as d,EB as e,fP as f,AB as g,ts as h,_s as i,ns as j,ss as k,wt as l,os as m,rs as n,IB as o,mt as p,zn as q,$B as r,RB as s,MB as t,PB as u,Zb as v,_e as w,NB as x,Yt as y,nn as z};
|