cogpit 3.5.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-runtime.js +1462 -260
- package/dist/instance-worker.js +3 -3
- package/dist/web/assets/{CogpitBlock-Ku77iAFz.js → CogpitBlock-ZgOubpsS.js} +1 -1
- package/dist/web/assets/{CommandPaletteHost-CjZO-FyZ.js → CommandPaletteHost-Djn2jqYR.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-B6jQRpcW.js → ConfigBrowser-CRwh8BXq.js} +1 -1
- package/dist/web/assets/{CrewPanel-DvHboAAW.js → CrewPanel-BxPl5D7h.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-5NbcDE8n.js → HighlightedEditor-D9A-dW2Z.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-yO3h4xr-.js → KeyboardShortcutsDialog-L7rRhApI.js} +1 -1
- package/dist/web/assets/{MissionHome-CZpQbWs3.js → MissionHome-zp7VebSO.js} +2 -2
- package/dist/web/assets/{MobileFileChanges-DERAdWVc.js → MobileFileChanges-O-SvMq9F.js} +1 -1
- package/dist/web/assets/{PluginsDialog-DusZU8fA.js → PluginsDialog-CBOyfoUX.js} +1 -1
- package/dist/web/assets/{PreviewPanel-BpCD0UAz.js → PreviewPanel-_pKuUaps.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-CPHWyVwU.js → ProjectFilesPanel-BsbpTgWK.js} +1 -1
- package/dist/web/assets/{ProjectSwitcherModal-BmYW6es0.js → ProjectSwitcherModal-D4MzdPVH.js} +1 -1
- package/dist/web/assets/{TerminalOutput-4YZ5J0ny.js → TerminalOutput-DOX29EmA.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-CHFAl7zz.js → ThemeSelectorModal-7CWXZB-z.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-B6whBEyJ.js → WorkflowsPanel-aOz1o3kA.js} +1 -1
- package/dist/web/assets/{WorktreePanel-ASvzuwqm.js → WorktreePanel-BFve9bpC.js} +1 -1
- package/dist/web/assets/{edition-ui-DZ5m565z.js → edition-ui-CFxEM3WF.js} +1 -1
- package/dist/web/assets/{index-BFA_YkUM.js → index-By5-_P50.js} +1 -1
- package/dist/web/assets/{index-yM7CTfeg.js → index-CPTFl4Qh.js} +13 -13
- package/dist/web/assets/index-DjpYbGVZ.js +2 -0
- package/dist/web/assets/{index-D262IRnL.js → index-DmMg-zf3.js} +1 -1
- package/dist/web/assets/{switch-BBkU1zqg.js → switch-DS7UyNS2.js} +1 -1
- package/dist/web/assets/{vendor-ui-DkzcTXCS.js → vendor-ui-DQeMoSiV.js} +195 -190
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-C9bzBC6T.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-
|
|
2
|
-
var EP=Object.defineProperty;var TP=(n,e,t)=>e in n?EP(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ge=(n,e,t)=>TP(n,typeof e!="symbol"?e+"":e,t);import{j as a,c as V,r as y,d as _e,e as AP,a as IP,f as PP}from"./vendor-react-gGw_S5I_.js";import{aY as $P,aZ as RP,a_ as OP,a$ as io,b0 as m4,b1 as Q1,b2 as ex,b3 as tx,b4 as nx,b5 as bc,X as Mt,b6 as sx,b7 as LP,b8 as MP,b9 as zP,ba as DP,bb as FP,bc as UP,bd as BP,be as WP,a5 as Et,bf as qP,bg as VP,bh as HP,bi as KP,bj as GP,N as nn,bk as ZP,bl as YP,bm as ja,bn as p4,bo as h4,ar as rx,C as it,af as St,bp as XP,O as er,bq as yf,br as Pr,bs as JP,bt as QP,bu as e$,bv as t$,bw as n$,bx as s$,by as r$,bz as o$,al as g4,a as Fn,bA as i$,bB as x4,bC as a$,bD as l$,bE as c$,bF as u$,bG as d$,bH as b4,A as Io,bI as Sd,i as ql,bJ as v4,G as Zr,bK as ox,bL as f$,J as ix,ag as tr,bM as m$,bN as Gi,bO as Uo,bP as p$,bQ as h$,bR as g$,bS as x$,bT as Vl,S as ss,ap as wr,bU as y4,bV as b$,bW as v$,bX as w4,bY as S4,bZ as k4,b_ as j4,b$ as N4,c0 as C4,c1 as y$,c2 as w$,c3 as S$,ai as wf,c4 as k$,a2 as Sf,p as sa,ab as Na,c5 as xg,c6 as _4,c7 as E4,c8 as T4,c9 as A4,ca as I4,cb as P4,cc as j$,au as ax,ak as N$,Y as Sr,B as Es,cd as C$,ce as _$,cf as E$,cg as T$,ch as A$,ci as Hl,cj as Ca,ck as I$,k as kf,am as lx,cl as P$,cm as $$,an as R$,c as cx,cn as O$,co as L$,cp as M$,cq as z$,cr as D$,cs as F$,ct as U$,cu as B$,cv as W$,cw as q$,P as kr,z as _a,cx as V$,cy as H$,cz as K$,cA as G$,n as Yr,aj as Bo,cB as Z$,as as $4,$ as ux,e as jf,cC as Y$,cD as X$,cE as R4,j as dx,aE as O4,aU as J$,a7 as mi,cF as bg,cG as L4,cH as Q$,aa as fx,cI as e8,cJ as mx,cK as px,cL as vg,cM as t8,aF as n8,R as hx,cN as s8,cO as r8,a3 as Po,b as M4,cP as o8,u as Ea,a4 as kl,cQ as kd,cR as gx,m as vc,cS as i8,cT as a8,cU as l8,cV as z4,cW as D4,cX as mu,cY as Yo,av as vy,F as yc,I as xx,cZ as c8,a8 as jd,c_ as u8,c$ as d8,v as Nf,Q as ra,_ as bx,d0 as f8,d1 as m8,d2 as p8,d3 as h8,d4 as g8,d5 as x8,d6 as b8,d7 as v8,d8 as F4,d9 as y8,da as w8,aL as S8,o as yg,db as k8,dc as U4,D as wc,dd as j8,aH as Cf,aG as Ns,a9 as B4,de as W4,t as N8,df as C8,aP as q4,r as _8,dg as wg,x as E8,dh as T8,di as A8,dj as I8,dk as P8,dl as $8,q as R8,dm as O8,dn as L8,dp as M8,dq as z8,aC as vx,U as yx,H as D8,dr as V4,ds as F8,ae as U8,L as H4,y as K4,ah as B8,aA as W8,aS as q8,dt as V8,du as H8,dv as K8,ad as G8,dw as Z8}from"./vendor-ui-DkzcTXCS.js";import{c as Y8,a as X8}from"./vendor-shiki-DOn6sF-i.js";import{r as G4,M as nr}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function t(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=t(r);fetch(r.href,o)}})();const J8="modulepreload",Q8=function(n){return"/"+n},yy={},nt=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let i=function(u){return Promise.all(u.map(d=>Promise.resolve(d).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"));r=i(t.map(u=>{if(u=Q8(u),u in yy)return;yy[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":J8,d||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),d)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return e().catch(o)})},Ys=["acp","codex","copilot","claude"];function Nd(n,e){if(n==="default")return e;const t=new TextEncoder().encode(e),s=btoa(Array.from(t,r=>String.fromCharCode(r)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`i-${n}__${s}`}function Sg(n){const e=/^i-([A-Za-z0-9-]+)__([A-Za-z0-9_-]+)$/.exec(n);if(!e)return{instanceId:"default",nativeId:n};try{const t=Uint8Array.from(atob(e[2].replace(/-/g,"+").replace(/_/g,"/")),s=>s.charCodeAt(0));return{instanceId:e[1],nativeId:new TextDecoder("utf-8",{fatal:!0}).decode(t)}}catch{throw new Error("Invalid instance session ID")}}function eR(n,e){return n==="default"?e:`instance__${n}__${e}`}function Xr(n){const e=/^instance__([A-Za-z0-9-]+)__(.+)$/.exec(n??"");return e?{instanceId:e[1],nativeDirName:e[2]}:{instanceId:"default",nativeDirName:n??""}}function oa(n,e){return e==="default"?n:{...n,instanceId:e,sessionId:Nd(e,Sg(n.sessionId).nativeId),...n.branchedFrom?{branchedFrom:{...n.branchedFrom,sessionId:Nd(e,Sg(n.branchedFrom.sessionId).nativeId)}}:{}}}const wx="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",tR=new RegExp(`^${wx}$`,"i");function wy(n,e){const t=new TextEncoder().encode(e);let s="";for(const o of t)s+=String.fromCharCode(o);const r=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${r}`}function Sy(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),r=Uint8Array.from(s,o=>o.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function Sx(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),recognizes:e=>{const t=Sy(n,e);return t!==null&&t!==""&&wy(n,t)===e},encode:e=>wy(n,e),decode:e=>Sy(n,e)}}function Kl(n){const e=new RegExp(`(${wx})\\.jsonl(?:\\.zst)?$`,"i").exec(n);return e?e[1]:null}function _f(n){return n?{rootSessionId:n.toLowerCase(),isRootTranscript:!0}:null}function kx(n){const e=n.split("/");return e.every(s=>s!==""&&s!=="."&&s!==".."&&!s.includes("\\"))?e:null}const jx={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function Z4(n){return`'${n.replace(/'/g,"'\\''")}'`}function Gl(n,e){return e?[n,e]:[]}function Cd(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const _d="[0-9a-f-]{36}",Y4="codex__",X4="copilot__",nR=new Set(["default","plan","acceptEdits","dontAsk","auto"]),sR=new Set(["subagents","workflows"]);function rR(n){const e=kx(n);if(!e)return null;const[t,s]=e;if(e.length===1){const r=t.replace(/\.jsonl$/,"");return r!==t&&jy(r)?_f(r):null}return e.length>2&&sR.has(s)&&jy(t)?{rootSessionId:t.toLowerCase(),isRootTranscript:!1}:null}const J4={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(Y4)&&!n.startsWith(X4),recognizes:n=>/^(?:(?:-|[A-Za-z]--)[A-Za-z0-9-]*|[A-Za-z]-)$/.test(n),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,"/")}},projectWorktreeDir:".claude/worktrees",sessionFile:{name:n=>`${n}.jsonl`,sessionId:Kl,...jx,transcriptRoot:rR},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"]:[...nR.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>Gl("--model",n),effort:n=>Gl("--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,sdkHomeEnvVar:"CLAUDE_CONFIG_DIR",installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>Cd(n,new RegExp(`--resume(?:=|\\s+)(${_d})`))??Cd(n,new RegExp(`--session-id(?:=|\\s+)(${_d})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]},{in:"scope",path:"AGENTS.md",scopes:["project"],fallback:!0}],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,configurableContextWindow:!1,fastTier:!0,lowPriorityInTerminal:!0,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",toolPermissionRules:!0,settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},ky={appServerValue:"priority",cliConfigValue:"fast"},oR={kind:"codex",displayName:"Codex",binName:"codex",dirName:Sx(Y4),projectWorktreeDir:null,sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${r}/rollout-${t}-${s}-${r}T${o}-${i}-${l}-${n}.jsonl`},sessionId:Kl,...jx,transcriptRoot:n=>kx(n)?_f(Kl(n)):null},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${Z4(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"]:e==="auto"?["--approve-for-me"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:n=>Gl("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(ky.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:ky,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",sessionIdEnvVar:"CODEX_THREAD_ID",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>Cd(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${_d})`))}},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:!0,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!0,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,configurableContextWindow:!0,fastTier:!0,lowPriorityInTerminal:!1,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}};function Km(n){const e=new RegExp(`^(${wx})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null}const sl={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:Sx(X4),projectWorktreeDir:null,sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:Km,urlId:n=>Km(n)??n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`,transcriptRoot:n=>_f(Km(n))},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${Z4(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=>Gl("--model",n),effort:n=>Gl("--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=>Cd(n,new RegExp(`--resume(?:=|\\s+)(${_d})`))}},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,configurableContextWindow:!1,fastTier:!1,lowPriorityInTerminal:!1,imageInput:!1,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},iR={...sl,kind:"acp",displayName:"ACP agent",binName:"acp",dirName:Sx("acp__"),sessionFile:{name:n=>`${n}.jsonl`,sessionId:Kl,...jx,transcriptRoot:n=>{const e=kx(n);return(e==null?void 0:e.length)===1?_f(Kl(n)):null}},resume:{command:()=>"Resume this session in Cogpit",args:()=>[]},launchArgs:{permissions:()=>[],model:()=>[],effort:()=>[],fastTier:()=>[]},cli:{...sl.cli,packageName:"",homebrew:null,wingetId:null,selfUpdate:null,requiresConfiguration:!0,homeDirName:".cogpit-acp",homeEnvVar:"COGPIT_ACP_HOME",homeIsDiscoverable:!0,installMarker:"projects"},config:{...sl.config,rootDirName:".cogpit-acp",instructions:[],settings:[],skillsDir:null},capabilities:{...sl.capabilities,undo:!1,redo:!1,nativeRewind:!1,nativeFork:!1,midTurnSteering:!1,activeNotifications:!1,externalProcesses:!1,autoPermissionMode:"never",toolPermissionRules:!1,namedSessions:!1}},Zl=Object.freeze({claude:J4,codex:oR,copilot:sl,acp:iR});function Cn(n){return Zl[n]}function Sc(){return Ys.map(n=>Zl[n])}function aR(n,e){const t=Sc().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function vs(n){const e=Xr(n);if(e.instanceId!=="default"){const t=vs(e.nativeDirName);return{...t,dirName:{...t.dirName,encode:s=>eR(e.instanceId,t.dirName.encode(s)),decode:s=>t.dirName.decode(Xr(s).nativeDirName)},sessionFile:{...t.sessionFile,name:s=>t.sessionFile.name(Sg(s).nativeId),sessionId:s=>{const r=t.sessionFile.sessionId(s);return r?Nd(e.instanceId,r):null},transcriptRoot:s=>{const r=t.sessionFile.transcriptRoot(s);return r?{...r,rootSessionId:Nd(e.instanceId,r.rootSessionId)}:null}}}}for(const t of Ys)if(t!=="claude"&&Zl[t].dirName.owns(n))return Zl[t];return J4}function un(n){return vs(n).kind}function Gm(n,e,t){const s=Zl[n].dirName;return t&&s.lossy?t:s.encode(e)}function jy(n){return tR.test(n)}const Wo=vs(null).kind;var d4;const pu=((d4=Sc().find(n=>n.dirName.lossy))==null?void 0:d4.kind)??null;function ia(n){return vs(n).capabilities}function bn(n){return Cn(n).capabilities}function lR(n,e){return Ys.find(t=>t===n)??e}function Ed(n){for(const e of Sc()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function Nx(n,e){var t;return((t=vs(n).sessionFile.transcriptRoot(e))==null?void 0:t.rootSessionId)??null}function cR(n,e){const t=vs(n).sessionFile.transcriptRoot(e);return t!=null&&t.isRootTranscript?t.rootSessionId:null}function Q4(n,e){return vs(n).sessionFile.urlId(e)}function uR(n,e){return vs(n).sessionFile.fileNameFromUrlId(e)}function Cx(n,e,t){return Cn(n).resume.command(e,t)}function dR(n,e){const t=Cn(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Ny(n){return n.replace(/\/+$/,"")||"/"}function fR(n,e,t){var r;const s=Ny(e);return((r=n.find(o=>vs(o.dirName).kind===t&&Ny(o.path)===s))==null?void 0:r.dirName)??null}const Ot="local",eN="cogpit-last-path::",kg=new Map;function Kt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Ot;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Ot}function qo(){return Kt()!==Ot}function _x(){const n=Kt();return n===Ot?"":`/d/${n}`}function tN(){const n=Kt();return n===Ot?"":`/hub/${n}`}function Ex(n){const e=tN();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let Yl=null;function mR(n){n!==Yl&&(Yl=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function Zn(){return Yl}function Qu(n){return n===Ot?0:kg.get(n)??0}function pR(n,e){if(n===Ot||!Number.isSafeInteger(e)||e<0)return!1;const t=kg.get(n);return t!==void 0&&e<=t?!1:(kg.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function cn(){const n=Kt(),e=Qu(n);return e===0?n:`${n}@${e}`}function sn(n){const e=Kt(),t=cn();return Yl!==null?`${n}::${t}::${Yl}`:e===Ot?n:`${n}::${t}`}function Va(n,e){sessionStorage.setItem(`${eN}${n}`,e)}function Xs(n){const t=sessionStorage.getItem(`${eN}${n}`)??(n===Ot?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const hR=["personal","team"];function nN(n){return hR.includes(n)}const gR="X-Cogpit-Gate",Tx={terminal:!0,configWrite:!0,hostFiles:!0,manageDevices:!0,killAny:!0,viewUsage:!0,share:!0,browser:!0},Ta={terminal:!1,configWrite:!1,hostFiles:!1,manageDevices:!1,killAny:!1,viewUsage:!1,share:!1,browser:!1},jg="cogpit-gate";function xR(n){n.status===403&&n.headers.has(gR)&&window.dispatchEvent(new Event(jg))}function bR(n){return window.addEventListener(jg,n),()=>window.removeEventListener(jg,n)}const vR="/api/session-access/",Ax="X-Cogpit-Session-Access",yR="X-Cogpit-Session-Id",Cy="access",_y="session-config",sN="cogpit-session-access-lost",rN="cogpit-session-access-changed",oN="cogpit-session-deleted",wR=6e4,ed=new Map,SR=["none","view","interact","own"];function iN(n){return typeof n=="string"&&SR.includes(n)}function aN(n,e,t=!1){window.dispatchEvent(new CustomEvent(n,{detail:{sessionId:e,background:t}}))}function lN(n,e,t=!1){aN(e==="none"?sN:rN,n,t)}function kR(n){return n.headers.has(Ax)}function cN(n){return n.headers.get(Ax)==="none"}function jR(n,e=!1){const t=n.headers.get(Ax),s=n.headers.get(yR);iN(t)&&s&&lN(s,t,e)}function NR(n){function e(t){let s;try{s=JSON.parse(t.data)}catch{return}iN(s.level)&&typeof s.sessionId=="string"&&lN(s.sessionId,s.level)}return n.addEventListener(Cy,e),()=>n.removeEventListener(Cy,e)}function Ix(n,e,t){function s(r){const o=r.detail,i=o==null?void 0:o.sessionId;typeof i!="string"||t!==void 0&&i!==t||e(i,(o==null?void 0:o.background)===!0)}return window.addEventListener(n,s),()=>window.removeEventListener(n,s)}function CR(n){return Ix(sN,n)}function _R(n,e){const t=e.catch(()=>!1);ed.set(n,t);const s=()=>{ed.get(n)===t&&ed.delete(n)};return t.then(r=>(r?(aN(oN,n),setTimeout(s,wR)):s(),r))}function ER(n){return ed.get(n)??Promise.resolve(!1)}function TR(n){return Ix(oN,n)}function uN(n,e){return Ix(rN,n,e)}let dN=null;function Td(){return dN}function AR(n){dN=n}const IR=["DEVICE_AUTH_FAILED","DEVICE_UNREACHABLE","DEVICE_REFUSED"],Ey="cogpit-network-token",PR=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function Ef(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!PR.has(e)}function Tf(){try{localStorage.removeItem(Ey),sessionStorage.removeItem(Ey)}catch{}}typeof window<"u"&&Tf();const $R={edition:"personal",signIn:"password",setupRequired:!1};let Xl=null;function fN(){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(),t=e.signIn==="account"?"account":"password";return AR(t),{edition:nN(e.edition)?e.edition:"personal",signIn:t,setupRequired:t==="account"&&e.setupRequired===!0}}).catch(()=>(Xl=null,$R))}function mN(){return Xl??(Xl=fN()),Xl}function Ty(){return Xl=fN(),Xl}function pN(){return mN().then(n=>n.signIn)}async function RR(){if(!Ef()&&Td()!=="account")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 OR(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Tf()}}const LR=new Set(IR);function Ay(){return Tf(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function hN(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=Ex(n));const{background:s=!1,...r}=e??{},o=new Headers(r.headers);return o.delete("Authorization"),o.set("X-Cogpit-Client","1"),fetch(n,{...r,headers:o,credentials:"same-origin"}).then(i=>{if(jR(i,s),xR(i),i.status===401){if(Ef()||Td()==="account")return Ay();if(Td()===null)return pN().then(l=>l==="account"?Ay():i)}if(i.status===502){const l=i.headers.get("X-Cogpit-Hub-Error"),c=i.headers.get("X-Cogpit-Device");c&&l&&LR.has(l)&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:c,reason:l}}))}return i})}function Ce(n,e){return hN(n,e,!0)}function is(n,e,t={}){return Ce(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function Ur(n,e){return hN(n,e,!1)}function Af(n){return Ex(n)}const jl={conversation:null,commands:[],cursor:0,freshness:"waiting"},Jl=new Map;class MR{constructor(e,t){Ge(this,"state",jl);Ge(this,"listeners",new Set);Ge(this,"timer");Ge(this,"pending");Ge(this,"attempts",0);Ge(this,"stopped",!1);Ge(this,"identityChanged",()=>{var e;this.stopped=!0,clearTimeout(this.timer),(e=this.pending)==null||e.abort(),this.apply({...jl,freshness:"stale",error:"Account or device changed"}),Jl.delete(this.key)});Ge(this,"refresh",()=>{document.visibilityState!=="hidden"&&this.fetch()});Ge(this,"subscribe",e=>(this.listeners.add(e),this.listeners.size===1&&(window.addEventListener("cogpit-command-accepted",this.refresh),window.addEventListener("online",this.refresh),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),document.addEventListener("visibilitychange",this.refresh),this.fetch()),()=>{var t;this.listeners.delete(e),this.listeners.size||(clearTimeout(this.timer),(t=this.pending)==null||t.abort(),window.removeEventListener("cogpit-command-accepted",this.refresh),window.removeEventListener("online",this.refresh),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),document.removeEventListener("visibilitychange",this.refresh),Jl.delete(this.key))}));Ge(this,"snapshot",()=>this.state);this.key=e,this.url=t}get watched(){return this.listeners.size>0}admit(e){this.state.commands.some(t=>t.id===e.id)||this.apply({...this.state,commands:[...this.state.commands,e]})}apply(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}async fetch(){if(this.stopped||this.pending||!this.listeners.size||document.visibilityState==="hidden")return;clearTimeout(this.timer);const e=new AbortController;this.pending=e;let t=!1;try{const s=await Ce(`${this.url}&after=${this.state.cursor}`,{signal:e.signal});if(!s.ok)throw t=[401,403,404].includes(s.status),new Error(`Queue unavailable (${s.status})`);const r=await s.json();if(e.signal.aborted)return;if(!r.conversation||!Array.isArray(r.commands)||!r.replay||!Number.isSafeInteger(r.replay.cursor))throw new Error("Invalid queue snapshot");this.apply({conversation:r.conversation,commands:r.commands,cursor:r.replay.cursor,freshness:"current",currentAddress:r.currentAddress,pendingTransition:r.pendingTransition}),this.attempts=0}catch(s){e.signal.aborted||this.apply({...t?jl:this.state,freshness:"stale",error:s instanceof Error?s.message:"Queue unavailable"}),this.attempts++}finally{this.pending=void 0,!this.stopped&&this.listeners.size&&!t&&(this.timer=setTimeout(()=>{this.fetch()},Math.min(3e4,2e3*2**Math.min(this.attempts,4))*(.8+Math.random()*.4)))}}async action(e){if(this.stopped)throw new Error("Account or device changed; reopen the conversation");const t=await Ce(this.url.split("?")[0],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw new Error(s.error??"Queue update failed")}await this.fetch()}}function gN(n){const e=Af(`/api/session-commands?sessionId=${encodeURIComponent(n)}`);return{key:JSON.stringify([cn(),Zn(),e]),url:e}}function If(n){const{key:e,url:t}=gN(n);let s=Jl.get(e);return s||(s=new MR(e,t),Jl.set(e,s)),s}function zR(n){const e=Jl.get(gN(n.sessionId).key);return e!=null&&e.watched?(e.admit(n),!0):!1}function G(...n){return $P(RP(n))}const DR=io("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 Q({className:n,variant:e,size:t,...s}){return a.jsx(OP,{"data-slot":"button",className:G(DR({variant:e,size:t,className:n})),...s})}const FR=[{value:"",label:"Default"},{value:"opus",label:"Opus"},{value:"fable",label:"Fable"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}],Ng=[{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"}],UR=[...Ng,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}];var f4;const Px=((f4=Cn("codex").serviceTier)==null?void 0:f4.appServerValue)??"priority",BR=[{value:Px,label:"Fast",description:"1.5× speed with increased usage"}],Iy=[{value:Px,label:"Fast",description:"1.5× speed"}],Py=[{value:Px,label:"Fast",description:"2× speed with increased usage"}],Xo={defaultReasoningEffort:"medium",supportedReasoningEfforts:UR,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:BR},WR=[{value:"",label:"Default",description:"Use the model configured in Codex"},{value:"gpt-6.1-sol",label:"GPT-6.1 Sol",description:"Latest workhorse model for coding and everyday work",...Xo,defaultReasoningEffort:"low",serviceTiers:Py},{value:"gpt-6-astra",label:"GPT-6 Astra",description:"Frontier intelligence for the most demanding work",...Xo,serviceTiers:Py},{value:"gpt-6-sol",label:"GPT-6 Sol",description:"Previous generation workhorse model",...Xo,serviceTiers:Iy},{value:"gpt-6-luna",label:"GPT-6 Luna",description:"Fast and affordable model for easier tasks",...Xo,supportedReasoningEfforts:Ng,serviceTiers:Iy},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Older generation workhorse model",...Xo,defaultReasoningEffort:"low"},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Older balanced model for straightforward work",...Xo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Older fast and efficient model",...Xo,supportedReasoningEfforts:Ng}],qR=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],VR={acp:[{value:"",label:"Provider default"}],claude:FR,codex:WR,copilot:qR};function HR(n){return VR[n]}const $x=new Map,Ad=new Set;function KR(n,e){!Array.isArray(e)||e.length===0||($x.set(n,e),Ad.forEach(t=>t()))}function GR(n){return Ad.add(n),()=>Ad.delete(n)}function ZR(){$x.clear(),Ad.forEach(n=>n())}const $y="high",YR=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function XR(n){return $x.get(n)??HR(n)}function kc(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 xN(n,e,t){const s=kc(e,t),r=s==null?void 0:s.supportedReasoningEfforts;return r&&r.length>0?r:(s==null?void 0:s.supportsEffort)===!1||!bn(n).reasoningEffort?[]:YR}function JR(n,e){var t,s;return(s=(t=kc(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(r=>r.value==="fast"||r.value==="priority"||r.label.toLowerCase()==="fast")}function QR(n,e,t){var r;const s=(r=kc(e,t))==null?void 0:r.inputModalities;return s?s.includes("image"):bn(n).imageInput}function e9(n,e,t){var r;const s=bn(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((r=kc(e,t))==null?void 0:r.supportsAutoMode)===!0}function t9(n,e){return bn(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function n9(n,e,t,s){var l;const r=xN(n,e,s);if(r.length===0)return"";const o=c=>!!c&&r.some(u=>u.value===c);if(o(t))return t;const i=(l=kc(e,s))==null?void 0:l.defaultReasoningEffort;return o(i)?i:o($y)?$y:r[0].value}function s9(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Pf(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}}function sr(n){const e=V.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=a.jsx(m4,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function r9(n){const e=V.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=a.jsx(nx,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function k2e(n){const e=V.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=a.jsx(bc,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function o9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(sx,{"data-slot":"dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function rr(n){const e=V.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,showCloseButton:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?!0:o;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(o9,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=G("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let u;e[8]!==i?(u=i&&a.jsxs(bc,{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:[a.jsx(Mt,{"data-icon":"inline-start",className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==t||e[11]!==r||e[12]!==c||e[13]!==u?(d=a.jsxs(r9,{children:[l,a.jsxs(Q1,{"data-slot":"dialog-content",className:c,...r,children:[t,u]})]}),e[10]=t,e[11]=r,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}function ao(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Rx(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function or(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ex,{"data-slot":"dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ir(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(tx,{"data-slot":"dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function i9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("label",{"data-slot":"label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function a9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("fieldset",{"data-slot":"field-set",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function l9(n){const e=V.c(10);let t,s,r;e[0]!==n?({className:t,variant:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"legend":r;let i;e[4]!==t?(i=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==o?(l=a.jsx("legend",{"data-slot":"field-legend","data-variant":o,className:i,...s}),e[6]=s,e[7]=i,e[8]=o,e[9]=l):l=e[9],l}function Aa(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const c9=io("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 fn(n){const e=V.c(11);let t,s,r;e[0]!==n?({className:t,orientation:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"vertical":r;let i;e[4]!==t||e[5]!==o?(i=G(c9({orientation:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"field","data-orientation":o,className:i,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function j2e(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function mn(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(i9,{"data-slot":"field-label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function aa(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-left text-sm leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("p",{"data-slot":"field-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Eo(n){var d;const e=V.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,errors:r,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e:{if(t){i=t;break e}if(!(r!=null&&r.length)){i=null;break e}let f;e[5]!==r?(f=[...new Map(r.map(d9)).values()],e[5]=r,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){i=(d=m[0])==null?void 0:d.message;break e}let p;e[7]!==m?(p=a.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(u9)}),e[7]=m,e[8]=p):p=e[8],i=p}const l=i;if(!l)return null;let c;e[9]!==s?(c=G("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let u;return e[11]!==l||e[12]!==o||e[13]!==c?(u=a.jsx("div",{role:"alert","data-slot":"field-error",className:c,...o,children:l}),e[11]=l,e[12]=o,e[13]=c,e[14]=u):u=e[14],u}function u9(n,e){return(n==null?void 0:n.message)&&a.jsx("li",{children:n.message},e)}function d9(n){return[n==null?void 0:n.message,n]}function On({className:n,...e}){return a.jsx(LP,{"data-slot":"input",className:G("h-8 w-full min-w-0 rounded-lg border border-input bg-background 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:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...e})}const f9=io("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 kt({className:n,variant:e,...t}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:G(f9({variant:e}),n),...t})}function Xt({className:n,...e}){return a.jsx("div",{"data-slot":"alert-title",className:G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",n),...e})}function _t({className:n,...e}){return a.jsx("div",{"data-slot":"alert-description",className:G("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",n),...e})}function Hr({className:n,...e}){return a.jsx("div",{"data-slot":"alert-action",className:G("absolute top-2 right-2",n),...e})}const bN=MP;function vN(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("scroll-my-1 p-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(DP,{"data-slot":"select-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function yN(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-1 text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(UP,{"data-slot":"select-value",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function wN(n){const e=V.c(13);let t,s,r,o;e[0]!==n?({className:s,size:o,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==s?(l=G("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input 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 bg-background hover:bg-accent 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=a.jsx(WP,{render:a.jsx(Et,{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 u;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==l?(u=a.jsxs(FP,{"data-slot":"select-trigger","data-size":i,className:l,...r,children:[t,c]}),e[8]=t,e[9]=r,e[10]=i,e[11]=l,e[12]=u):u=e[12],u}function SN(n){const e=V.c(26);let t,s,r,o,i,l,c,u;e[0]!==n?({className:s,children:t,side:o,sideOffset:i,align:l,alignOffset:c,alignItemWithTrigger:u,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7],u=e[8]);const d=o===void 0?"bottom":o,f=i===void 0?4:i,m=l===void 0?"center":l,p=c===void 0?0:c,h=u===void 0?!0:u;let g;e[9]!==s?(g=G("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(m9,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=a.jsx(qP,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(p9,{}),e[14]=w):w=e[14];let v;e[15]!==r||e[16]!==g||e[17]!==b?(v=a.jsxs(zP,{"data-slot":"select-content",className:g,...r,children:[x,b,w]}),e[15]=r,e[16]=g,e[17]=b,e[18]=v):v=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==d||e[23]!==f||e[24]!==v?(j=a.jsx(VP,{children:a.jsx(HP,{side:d,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=d,e[23]=f,e[24]=v,e[25]=j):j=e[25],j}function Cg(n){const e=V.c(13);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=a.jsx(KP,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(GP,{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:a.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:a.jsx(nn,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==r||e[10]!==o||e[11]!==i?(c=a.jsxs(BP,{"data-slot":"select-item",className:o,...r,children:[i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=c):c=e[12],c}function m9(n){const e=V.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 r;e[3]!==t?(r=G("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(ja,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(ZP,{"data-slot":"select-scroll-up-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function p9(n){const e=V.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 r;e[3]!==t?(r=G("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Et,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(YP,{"data-slot":"select-scroll-down-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function h9({sessionId:n,onOpen:e,open:t,onOpenChange:s}){var E,T,$;const r=y.useMemo(()=>If(n),[n]),o=y.useSyncExternalStore(r.subscribe,r.snapshot),[i,l]=y.useState([]),[c,u]=y.useState(Ys.at(-1)),[d,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=y.useRef(null),[v,j]=y.useState(null),[k,_]=y.useState(!t),N=y.useRef(0);y.useEffect(()=>{t&&_(!1)},[t]),y.useEffect(()=>{const A=++N.current,R=new AbortController;return Ce("/api/provider-instances",{signal:R.signal}).then(async P=>{if(P.ok){const z=await P.json();A===N.current&&l(z.instances.filter(L=>!L.retired))}}).catch(()=>{}),()=>{N.current=A+1,R.abort()}},[n]),y.useEffect(()=>{!k||!v||v.epoch!==N.current||(j(null),e(v.dirName,v.fileName))},[k,v,e]);async function S(A){if(!o.conversation)return;const R=N.current,P=i.find(M=>M.id===c),z=o.conversation.binding,L={sessionId:n,expectedRevision:o.conversation.revision,mode:A,agent:A==="resume"?z.agent:(P==null?void 0:P.agent)??c,instanceId:A==="resume"?z.instanceId:(P==null?void 0:P.id)??"default",message:d},I=JSON.stringify(L);(!w.current||w.current.payload!==I)&&(w.current={id:crypto.randomUUID(),payload:I}),p(!0),b(null);try{const M=await Ce("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,commandId:w.current.id})}),F=await M.json();if(R!==N.current)return;if(!M.ok)throw new Error(F.error||"Provider handoff failed");F.dirName&&F.fileName&&j({dirName:F.dirName,fileName:F.fileName,epoch:R}),s(!1),w.current=null}catch(M){R===N.current&&b(M instanceof Error?M.message:"Provider handoff failed")}finally{R===N.current&&p(!1)}}async function C(A=!1){if(!o.pendingTransition||A&&!window.confirm("Confirm you inspected the target provider’s history and no session was created for this handoff. This releases the conversation so you can start a new handoff."))return;const R=N.current;p(!0),b(null);try{const P=await Ce("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"resolve",sessionId:n,commandId:o.pendingTransition.id,confirmNotCreated:A,targetSessionId:A?void 0:h||o.pendingTransition.sessionId})}),z=await P.json();if(R!==N.current)return;if(!P.ok)throw new Error(z.error||"Handoff reconciliation failed");w.current=null,window.dispatchEvent(new Event("cogpit-command-accepted")),z.dirName&&z.fileName&&e(z.dirName,z.fileName)}catch(P){R===N.current&&b(P instanceof Error?P.message:"Handoff reconciliation failed")}finally{R===N.current&&p(!1)}}return a.jsxs("div",{className:"flex flex-col gap-2 px-3 empty:hidden",children:[o.conversation&&o.conversation.binding.sessionId!==n&&o.currentAddress&&a.jsx(Q,{size:"xs",variant:"outline",onClick:()=>e(o.currentAddress.dirName,o.currentAddress.fileName),children:"Open current conversation session"}),o.pendingTransition&&a.jsx(kt,{children:a.jsxs(_t,{className:"flex flex-col gap-2",children:[a.jsx("p",{children:"A provider handoff needs reconciliation. Inspect the target provider’s history before choosing a recovery action."}),a.jsx(On,{"aria-label":"Recovered session ID",placeholder:o.pendingTransition.sessionId||"Native session ID found in history",value:h,onChange:A=>g(A.target.value)}),a.jsx(Q,{size:"xs",disabled:m||!(h||o.pendingTransition.sessionId),onClick:()=>void C(),children:"Attach recovered session"}),a.jsx(Q,{size:"xs",variant:"outline",disabled:m,onClick:()=>void C(!0),children:"Confirm no session was created"})]})}),a.jsx(sr,{open:t,onOpenChange:A=>{A&&_(!1),s(A)},onOpenChangeComplete:A=>{_(!A)},children:a.jsxs(rr,{children:[a.jsxs(ao,{children:[a.jsx(or,{children:"Continue this conversation"}),a.jsx(ir,{children:"Native resume keeps the current provider and account. Context handoff starts a new native session with up to 12 recent turns and 24,000 characters of text context. Files remain in the same project."})]}),a.jsxs(aa,{children:["Conversation: ",((E=o.conversation)==null?void 0:E.id)||"Loading…"]}),x&&a.jsx(kt,{variant:"destructive",children:a.jsx(_t,{children:x})}),a.jsxs(Aa,{children:[a.jsxs(fn,{children:[a.jsx(mn,{children:"Target provider or account"}),a.jsxs(bN,{value:c,onValueChange:A=>A&&u(A),children:[a.jsx(wN,{"aria-label":"Handoff provider",children:a.jsx(yN,{children:((T=i.find(A=>A.id===c))==null?void 0:T.label)||(($=Cn(c))==null?void 0:$.displayName)})}),a.jsx(SN,{children:a.jsxs(vN,{children:[Ys.map(A=>a.jsxs(Cg,{value:A,children:[Cn(A).displayName," · Default profile"]},A)),i.map(A=>a.jsx(Cg,{value:A.id,children:A.label},A.id))]})})]})]}),a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"handoff-message",children:"Next request"}),a.jsx(On,{id:"handoff-message",value:d,onChange:A=>f(A.target.value)}),a.jsx(aa,{children:"Tool state and permissions are established by the new provider."})]}),a.jsx(Q,{disabled:m||!o.conversation,onClick:()=>void S("handoff"),children:"Start context handoff"}),a.jsx(Q,{variant:"outline",disabled:m||!o.conversation,onClick:()=>void S("resume"),children:"Keep current native session"})]})]})}),!t&&x&&a.jsx(kt,{variant:"destructive",children:a.jsx(_t,{children:x})})]})}function Ry(n){return n.split(/\r?\n/).filter(t=>!t.trimStart().startsWith("[ede_diagnostic]")).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-DOX29EmA.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-DQeMoSiV.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","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/CogpitBlock-ZgOubpsS.js","assets/ProjectSwitcherModal-D4MzdPVH.js","assets/CommandPaletteHost-Djn2jqYR.js","assets/index-DjpYbGVZ.js","assets/switch-DS7UyNS2.js","assets/password-BV9mqUzz.js","assets/KeyboardShortcutsDialog-L7rRhApI.js","assets/ThemeSelectorModal-7CWXZB-z.js","assets/ProjectFilesPanel-BsbpTgWK.js","assets/HighlightedEditor-D9A-dW2Z.js","assets/WorktreePanel-BFve9bpC.js","assets/CrewPanel-BxPl5D7h.js","assets/index-DmMg-zf3.js","assets/MissionHome-zp7VebSO.js","assets/ConfigBrowser-CRwh8BXq.js","assets/PreviewPanel-_pKuUaps.js","assets/PluginsDialog-CBOyfoUX.js","assets/MobileFileChanges-O-SvMq9F.js","assets/edition-ui-CFxEM3WF.js","assets/index-By5-_P50.js","assets/WorkflowsPanel-aOz1o3kA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var EP=Object.defineProperty;var TP=(n,e,t)=>e in n?EP(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ge=(n,e,t)=>TP(n,typeof e!="symbol"?e+"":e,t);import{j as a,c as V,r as y,d as _e,e as AP,a as IP,f as PP}from"./vendor-react-gGw_S5I_.js";import{aZ as $P,a_ as RP,a$ as OP,b0 as io,b1 as m4,b2 as Q1,b3 as ex,b4 as tx,b5 as nx,b6 as bc,X as Mt,b7 as sx,b8 as LP,b9 as MP,ba as zP,bb as DP,bc as FP,bd as UP,be as BP,bf as WP,a5 as Et,bg as qP,bh as VP,bi as HP,bj as KP,bk as GP,N as nn,bl as ZP,bm as YP,bn as ja,bo as p4,bp as h4,ah as rx,C as it,aq as St,bq as XP,O as er,br as yf,bs as Pr,bt as JP,bu as QP,bv as e$,bw as t$,bx as n$,by as s$,bz as r$,bA as o$,ab as g4,a as Fn,bB as i$,bC as x4,bD as a$,bE as l$,bF as c$,bG as u$,bH as d$,bI as b4,A as Io,bJ as Sd,i as ql,bK as v4,G as Zr,bL as ox,bM as f$,J as ix,ar as tr,bN as m$,bO as Gi,bP as Uo,bQ as p$,bR as h$,bS as g$,bT as x$,bU as Vl,S as ss,af as wr,bV as y4,bW as b$,bX as v$,bY as w4,bZ as S4,b_ as k4,b$ as j4,c0 as N4,c1 as C4,c2 as y$,c3 as w$,c4 as S$,au as wf,c5 as k$,a2 as Sf,p as sa,am as Na,c6 as xg,c7 as _4,c8 as E4,c9 as T4,ca as A4,cb as I4,cc as P4,cd as j$,ak as ax,aa as N$,Y as Sr,B as Es,ce as C$,cf as _$,cg as E$,ch as T$,ci as A$,cj as Hl,ck as Ca,cl as I$,k as kf,ac as lx,cm as P$,cn as $$,ad as R$,c as cx,co as O$,cp as L$,cq as M$,cr as z$,cs as D$,ct as F$,cu as U$,cv as B$,cw as W$,cx as q$,P as kr,z as _a,cy as V$,cz as H$,cA as K$,cB as G$,n as Yr,av as Bo,cC as Z$,ai as $4,$ as ux,e as jf,cD as Y$,cE as X$,cF as R4,j as dx,aF as O4,aV as J$,a7 as mi,cG as bg,cH as L4,cI as Q$,al as fx,cJ as e8,cK as mx,cL as px,cM as vg,cN as t8,aG as n8,R as hx,cO as s8,cP as r8,a3 as Po,b as M4,cQ as o8,u as Ea,a4 as kl,cR as kd,cS as gx,m as vc,cT as i8,cU as a8,cV as l8,cW as z4,cX as D4,cY as mu,cZ as Yo,aw as vy,F as yc,I as xx,c_ as c8,a8 as jd,c$ as u8,d0 as d8,v as Nf,Q as ra,_ as bx,d1 as f8,d2 as m8,d3 as p8,d4 as h8,d5 as g8,d6 as x8,d7 as b8,d8 as v8,d9 as F4,da as y8,db as w8,aM as S8,o as yg,dc as k8,dd as U4,D as wc,de as j8,aI as Cf,aH as Ns,a9 as B4,df as W4,t as N8,dg as C8,aQ as q4,r as _8,dh as wg,x as E8,di as T8,dj as A8,dk as I8,dl as P8,dm as $8,q as R8,dn as O8,dp as L8,dq as M8,dr as z8,aD as vx,U as yx,H as D8,ds as V4,dt as F8,ap as U8,L as H4,y as K4,at as B8,aB as W8,aT as q8,du as V8,dv as H8,dw as K8,ao as G8,dx as Z8}from"./vendor-ui-DQeMoSiV.js";import{c as Y8,a as X8}from"./vendor-shiki-DOn6sF-i.js";import{r as G4,M as nr}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function t(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=t(r);fetch(r.href,o)}})();const J8="modulepreload",Q8=function(n){return"/"+n},yy={},nt=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let i=function(u){return Promise.all(u.map(d=>Promise.resolve(d).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"));r=i(t.map(u=>{if(u=Q8(u),u in yy)return;yy[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":J8,d||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),d)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return e().catch(o)})},Ys=["acp","codex","copilot","claude"];function Nd(n,e){if(n==="default")return e;const t=new TextEncoder().encode(e),s=btoa(Array.from(t,r=>String.fromCharCode(r)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`i-${n}__${s}`}function Sg(n){const e=/^i-([A-Za-z0-9-]+)__([A-Za-z0-9_-]+)$/.exec(n);if(!e)return{instanceId:"default",nativeId:n};try{const t=Uint8Array.from(atob(e[2].replace(/-/g,"+").replace(/_/g,"/")),s=>s.charCodeAt(0));return{instanceId:e[1],nativeId:new TextDecoder("utf-8",{fatal:!0}).decode(t)}}catch{throw new Error("Invalid instance session ID")}}function eR(n,e){return n==="default"?e:`instance__${n}__${e}`}function Xr(n){const e=/^instance__([A-Za-z0-9-]+)__(.+)$/.exec(n??"");return e?{instanceId:e[1],nativeDirName:e[2]}:{instanceId:"default",nativeDirName:n??""}}function oa(n,e){return e==="default"?n:{...n,instanceId:e,sessionId:Nd(e,Sg(n.sessionId).nativeId),...n.branchedFrom?{branchedFrom:{...n.branchedFrom,sessionId:Nd(e,Sg(n.branchedFrom.sessionId).nativeId)}}:{}}}const wx="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",tR=new RegExp(`^${wx}$`,"i");function wy(n,e){const t=new TextEncoder().encode(e);let s="";for(const o of t)s+=String.fromCharCode(o);const r=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${r}`}function Sy(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),r=Uint8Array.from(s,o=>o.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function Sx(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),recognizes:e=>{const t=Sy(n,e);return t!==null&&t!==""&&wy(n,t)===e},encode:e=>wy(n,e),decode:e=>Sy(n,e)}}function Kl(n){const e=new RegExp(`(${wx})\\.jsonl(?:\\.zst)?$`,"i").exec(n);return e?e[1]:null}function _f(n){return n?{rootSessionId:n.toLowerCase(),isRootTranscript:!0}:null}function kx(n){const e=n.split("/");return e.every(s=>s!==""&&s!=="."&&s!==".."&&!s.includes("\\"))?e:null}const jx={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function Z4(n){return`'${n.replace(/'/g,"'\\''")}'`}function Gl(n,e){return e?[n,e]:[]}function Cd(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const _d="[0-9a-f-]{36}",Y4="codex__",X4="copilot__",nR=new Set(["default","plan","acceptEdits","dontAsk","auto"]),sR=new Set(["subagents","workflows"]);function rR(n){const e=kx(n);if(!e)return null;const[t,s]=e;if(e.length===1){const r=t.replace(/\.jsonl$/,"");return r!==t&&jy(r)?_f(r):null}return e.length>2&&sR.has(s)&&jy(t)?{rootSessionId:t.toLowerCase(),isRootTranscript:!1}:null}const J4={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(Y4)&&!n.startsWith(X4),recognizes:n=>/^(?:(?:-|[A-Za-z]--)[A-Za-z0-9-]*|[A-Za-z]-)$/.test(n),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,"/")}},projectWorktreeDir:".claude/worktrees",sessionFile:{name:n=>`${n}.jsonl`,sessionId:Kl,...jx,transcriptRoot:rR},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"]:[...nR.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>Gl("--model",n),effort:n=>Gl("--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,sdkHomeEnvVar:"CLAUDE_CONFIG_DIR",installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>Cd(n,new RegExp(`--resume(?:=|\\s+)(${_d})`))??Cd(n,new RegExp(`--session-id(?:=|\\s+)(${_d})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]},{in:"scope",path:"AGENTS.md",scopes:["project"],fallback:!0}],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,configurableContextWindow:!1,fastTier:!0,lowPriorityInTerminal:!0,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",toolPermissionRules:!0,settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},ky={appServerValue:"priority",cliConfigValue:"fast"},oR={kind:"codex",displayName:"Codex",binName:"codex",dirName:Sx(Y4),projectWorktreeDir:null,sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${r}/rollout-${t}-${s}-${r}T${o}-${i}-${l}-${n}.jsonl`},sessionId:Kl,...jx,transcriptRoot:n=>kx(n)?_f(Kl(n)):null},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${Z4(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"]:e==="auto"?["--approve-for-me"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:n=>Gl("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(ky.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:ky,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",sessionIdEnvVar:"CODEX_THREAD_ID",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>Cd(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${_d})`))}},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:!0,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!0,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,configurableContextWindow:!0,fastTier:!0,lowPriorityInTerminal:!1,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}};function Km(n){const e=new RegExp(`^(${wx})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null}const sl={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:Sx(X4),projectWorktreeDir:null,sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:Km,urlId:n=>Km(n)??n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`,transcriptRoot:n=>_f(Km(n))},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${Z4(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=>Gl("--model",n),effort:n=>Gl("--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=>Cd(n,new RegExp(`--resume(?:=|\\s+)(${_d})`))}},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,configurableContextWindow:!1,fastTier:!1,lowPriorityInTerminal:!1,imageInput:!1,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},iR={...sl,kind:"acp",displayName:"ACP agent",binName:"acp",dirName:Sx("acp__"),sessionFile:{name:n=>`${n}.jsonl`,sessionId:Kl,...jx,transcriptRoot:n=>{const e=kx(n);return(e==null?void 0:e.length)===1?_f(Kl(n)):null}},resume:{command:()=>"Resume this session in Cogpit",args:()=>[]},launchArgs:{permissions:()=>[],model:()=>[],effort:()=>[],fastTier:()=>[]},cli:{...sl.cli,packageName:"",homebrew:null,wingetId:null,selfUpdate:null,requiresConfiguration:!0,homeDirName:".cogpit-acp",homeEnvVar:"COGPIT_ACP_HOME",homeIsDiscoverable:!0,installMarker:"projects"},config:{...sl.config,rootDirName:".cogpit-acp",instructions:[],settings:[],skillsDir:null},capabilities:{...sl.capabilities,undo:!1,redo:!1,nativeRewind:!1,nativeFork:!1,midTurnSteering:!1,activeNotifications:!1,externalProcesses:!1,autoPermissionMode:"never",toolPermissionRules:!1,namedSessions:!1}},Zl=Object.freeze({claude:J4,codex:oR,copilot:sl,acp:iR});function Cn(n){return Zl[n]}function Sc(){return Ys.map(n=>Zl[n])}function aR(n,e){const t=Sc().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function vs(n){const e=Xr(n);if(e.instanceId!=="default"){const t=vs(e.nativeDirName);return{...t,dirName:{...t.dirName,encode:s=>eR(e.instanceId,t.dirName.encode(s)),decode:s=>t.dirName.decode(Xr(s).nativeDirName)},sessionFile:{...t.sessionFile,name:s=>t.sessionFile.name(Sg(s).nativeId),sessionId:s=>{const r=t.sessionFile.sessionId(s);return r?Nd(e.instanceId,r):null},transcriptRoot:s=>{const r=t.sessionFile.transcriptRoot(s);return r?{...r,rootSessionId:Nd(e.instanceId,r.rootSessionId)}:null}}}}for(const t of Ys)if(t!=="claude"&&Zl[t].dirName.owns(n))return Zl[t];return J4}function un(n){return vs(n).kind}function Gm(n,e,t){const s=Zl[n].dirName;return t&&s.lossy?t:s.encode(e)}function jy(n){return tR.test(n)}const Wo=vs(null).kind;var d4;const pu=((d4=Sc().find(n=>n.dirName.lossy))==null?void 0:d4.kind)??null;function ia(n){return vs(n).capabilities}function bn(n){return Cn(n).capabilities}function lR(n,e){return Ys.find(t=>t===n)??e}function Ed(n){for(const e of Sc()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function Nx(n,e){var t;return((t=vs(n).sessionFile.transcriptRoot(e))==null?void 0:t.rootSessionId)??null}function cR(n,e){const t=vs(n).sessionFile.transcriptRoot(e);return t!=null&&t.isRootTranscript?t.rootSessionId:null}function Q4(n,e){return vs(n).sessionFile.urlId(e)}function uR(n,e){return vs(n).sessionFile.fileNameFromUrlId(e)}function Cx(n,e,t){return Cn(n).resume.command(e,t)}function dR(n,e){const t=Cn(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Ny(n){return n.replace(/\/+$/,"")||"/"}function fR(n,e,t){var r;const s=Ny(e);return((r=n.find(o=>vs(o.dirName).kind===t&&Ny(o.path)===s))==null?void 0:r.dirName)??null}const Ot="local",eN="cogpit-last-path::",kg=new Map;function Kt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Ot;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Ot}function qo(){return Kt()!==Ot}function _x(){const n=Kt();return n===Ot?"":`/d/${n}`}function tN(){const n=Kt();return n===Ot?"":`/hub/${n}`}function Ex(n){const e=tN();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let Yl=null;function mR(n){n!==Yl&&(Yl=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function Zn(){return Yl}function Qu(n){return n===Ot?0:kg.get(n)??0}function pR(n,e){if(n===Ot||!Number.isSafeInteger(e)||e<0)return!1;const t=kg.get(n);return t!==void 0&&e<=t?!1:(kg.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function cn(){const n=Kt(),e=Qu(n);return e===0?n:`${n}@${e}`}function sn(n){const e=Kt(),t=cn();return Yl!==null?`${n}::${t}::${Yl}`:e===Ot?n:`${n}::${t}`}function Va(n,e){sessionStorage.setItem(`${eN}${n}`,e)}function Xs(n){const t=sessionStorage.getItem(`${eN}${n}`)??(n===Ot?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const hR=["personal","team"];function nN(n){return hR.includes(n)}const gR="X-Cogpit-Gate",Tx={terminal:!0,configWrite:!0,hostFiles:!0,manageDevices:!0,killAny:!0,viewUsage:!0,share:!0,browser:!0},Ta={terminal:!1,configWrite:!1,hostFiles:!1,manageDevices:!1,killAny:!1,viewUsage:!1,share:!1,browser:!1},jg="cogpit-gate";function xR(n){n.status===403&&n.headers.has(gR)&&window.dispatchEvent(new Event(jg))}function bR(n){return window.addEventListener(jg,n),()=>window.removeEventListener(jg,n)}const vR="/api/session-access/",Ax="X-Cogpit-Session-Access",yR="X-Cogpit-Session-Id",Cy="access",_y="session-config",sN="cogpit-session-access-lost",rN="cogpit-session-access-changed",oN="cogpit-session-deleted",wR=6e4,ed=new Map,SR=["none","view","interact","own"];function iN(n){return typeof n=="string"&&SR.includes(n)}function aN(n,e,t=!1){window.dispatchEvent(new CustomEvent(n,{detail:{sessionId:e,background:t}}))}function lN(n,e,t=!1){aN(e==="none"?sN:rN,n,t)}function kR(n){return n.headers.has(Ax)}function cN(n){return n.headers.get(Ax)==="none"}function jR(n,e=!1){const t=n.headers.get(Ax),s=n.headers.get(yR);iN(t)&&s&&lN(s,t,e)}function NR(n){function e(t){let s;try{s=JSON.parse(t.data)}catch{return}iN(s.level)&&typeof s.sessionId=="string"&&lN(s.sessionId,s.level)}return n.addEventListener(Cy,e),()=>n.removeEventListener(Cy,e)}function Ix(n,e,t){function s(r){const o=r.detail,i=o==null?void 0:o.sessionId;typeof i!="string"||t!==void 0&&i!==t||e(i,(o==null?void 0:o.background)===!0)}return window.addEventListener(n,s),()=>window.removeEventListener(n,s)}function CR(n){return Ix(sN,n)}function _R(n,e){const t=e.catch(()=>!1);ed.set(n,t);const s=()=>{ed.get(n)===t&&ed.delete(n)};return t.then(r=>(r?(aN(oN,n),setTimeout(s,wR)):s(),r))}function ER(n){return ed.get(n)??Promise.resolve(!1)}function TR(n){return Ix(oN,n)}function uN(n,e){return Ix(rN,n,e)}let dN=null;function Td(){return dN}function AR(n){dN=n}const IR=["DEVICE_AUTH_FAILED","DEVICE_UNREACHABLE","DEVICE_REFUSED"],Ey="cogpit-network-token",PR=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function Ef(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!PR.has(e)}function Tf(){try{localStorage.removeItem(Ey),sessionStorage.removeItem(Ey)}catch{}}typeof window<"u"&&Tf();const $R={edition:"personal",signIn:"password",setupRequired:!1};let Xl=null;function fN(){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(),t=e.signIn==="account"?"account":"password";return AR(t),{edition:nN(e.edition)?e.edition:"personal",signIn:t,setupRequired:t==="account"&&e.setupRequired===!0}}).catch(()=>(Xl=null,$R))}function mN(){return Xl??(Xl=fN()),Xl}function Ty(){return Xl=fN(),Xl}function pN(){return mN().then(n=>n.signIn)}async function RR(){if(!Ef()&&Td()!=="account")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 OR(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{Tf()}}const LR=new Set(IR);function Ay(){return Tf(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function hN(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=Ex(n));const{background:s=!1,...r}=e??{},o=new Headers(r.headers);return o.delete("Authorization"),o.set("X-Cogpit-Client","1"),fetch(n,{...r,headers:o,credentials:"same-origin"}).then(i=>{if(jR(i,s),xR(i),i.status===401){if(Ef()||Td()==="account")return Ay();if(Td()===null)return pN().then(l=>l==="account"?Ay():i)}if(i.status===502){const l=i.headers.get("X-Cogpit-Hub-Error"),c=i.headers.get("X-Cogpit-Device");c&&l&&LR.has(l)&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:c,reason:l}}))}return i})}function Ce(n,e){return hN(n,e,!0)}function is(n,e,t={}){return Ce(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function Ur(n,e){return hN(n,e,!1)}function Af(n){return Ex(n)}const jl={conversation:null,commands:[],cursor:0,freshness:"waiting"},Jl=new Map;class MR{constructor(e,t){Ge(this,"state",jl);Ge(this,"listeners",new Set);Ge(this,"timer");Ge(this,"pending");Ge(this,"attempts",0);Ge(this,"stopped",!1);Ge(this,"identityChanged",()=>{var e;this.stopped=!0,clearTimeout(this.timer),(e=this.pending)==null||e.abort(),this.apply({...jl,freshness:"stale",error:"Account or device changed"}),Jl.delete(this.key)});Ge(this,"refresh",()=>{document.visibilityState!=="hidden"&&this.fetch()});Ge(this,"subscribe",e=>(this.listeners.add(e),this.listeners.size===1&&(window.addEventListener("cogpit-command-accepted",this.refresh),window.addEventListener("online",this.refresh),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),document.addEventListener("visibilitychange",this.refresh),this.fetch()),()=>{var t;this.listeners.delete(e),this.listeners.size||(clearTimeout(this.timer),(t=this.pending)==null||t.abort(),window.removeEventListener("cogpit-command-accepted",this.refresh),window.removeEventListener("online",this.refresh),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),document.removeEventListener("visibilitychange",this.refresh),Jl.delete(this.key))}));Ge(this,"snapshot",()=>this.state);this.key=e,this.url=t}get watched(){return this.listeners.size>0}admit(e){this.state.commands.some(t=>t.id===e.id)||this.apply({...this.state,commands:[...this.state.commands,e]})}apply(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}async fetch(){if(this.stopped||this.pending||!this.listeners.size||document.visibilityState==="hidden")return;clearTimeout(this.timer);const e=new AbortController;this.pending=e;let t=!1;try{const s=await Ce(`${this.url}&after=${this.state.cursor}`,{signal:e.signal});if(!s.ok)throw t=[401,403,404].includes(s.status),new Error(`Queue unavailable (${s.status})`);const r=await s.json();if(e.signal.aborted)return;if(!r.conversation||!Array.isArray(r.commands)||!r.replay||!Number.isSafeInteger(r.replay.cursor))throw new Error("Invalid queue snapshot");this.apply({conversation:r.conversation,commands:r.commands,cursor:r.replay.cursor,freshness:"current",currentAddress:r.currentAddress,pendingTransition:r.pendingTransition}),this.attempts=0}catch(s){e.signal.aborted||this.apply({...t?jl:this.state,freshness:"stale",error:s instanceof Error?s.message:"Queue unavailable"}),this.attempts++}finally{this.pending=void 0,!this.stopped&&this.listeners.size&&!t&&(this.timer=setTimeout(()=>{this.fetch()},Math.min(3e4,2e3*2**Math.min(this.attempts,4))*(.8+Math.random()*.4)))}}async action(e){if(this.stopped)throw new Error("Account or device changed; reopen the conversation");const t=await Ce(this.url.split("?")[0],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw new Error(s.error??"Queue update failed")}await this.fetch()}}function gN(n){const e=Af(`/api/session-commands?sessionId=${encodeURIComponent(n)}`);return{key:JSON.stringify([cn(),Zn(),e]),url:e}}function If(n){const{key:e,url:t}=gN(n);let s=Jl.get(e);return s||(s=new MR(e,t),Jl.set(e,s)),s}function zR(n){const e=Jl.get(gN(n.sessionId).key);return e!=null&&e.watched?(e.admit(n),!0):!1}function G(...n){return $P(RP(n))}const DR=io("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 Q({className:n,variant:e,size:t,...s}){return a.jsx(OP,{"data-slot":"button",className:G(DR({variant:e,size:t,className:n})),...s})}const FR=[{value:"",label:"Default"},{value:"opus",label:"Opus"},{value:"fable",label:"Fable"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}],Ng=[{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"}],UR=[...Ng,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}];var f4;const Px=((f4=Cn("codex").serviceTier)==null?void 0:f4.appServerValue)??"priority",BR=[{value:Px,label:"Fast",description:"1.5× speed with increased usage"}],Iy=[{value:Px,label:"Fast",description:"1.5× speed"}],Py=[{value:Px,label:"Fast",description:"2× speed with increased usage"}],Xo={defaultReasoningEffort:"medium",supportedReasoningEfforts:UR,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:BR},WR=[{value:"",label:"Default",description:"Use the model configured in Codex"},{value:"gpt-6.1-sol",label:"GPT-6.1 Sol",description:"Latest workhorse model for coding and everyday work",...Xo,defaultReasoningEffort:"low",serviceTiers:Py},{value:"gpt-6-astra",label:"GPT-6 Astra",description:"Frontier intelligence for the most demanding work",...Xo,serviceTiers:Py},{value:"gpt-6-sol",label:"GPT-6 Sol",description:"Previous generation workhorse model",...Xo,serviceTiers:Iy},{value:"gpt-6-luna",label:"GPT-6 Luna",description:"Fast and affordable model for easier tasks",...Xo,supportedReasoningEfforts:Ng,serviceTiers:Iy},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Older generation workhorse model",...Xo,defaultReasoningEffort:"low"},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Older balanced model for straightforward work",...Xo},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Older fast and efficient model",...Xo,supportedReasoningEfforts:Ng}],qR=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],VR={acp:[{value:"",label:"Provider default"}],claude:FR,codex:WR,copilot:qR};function HR(n){return VR[n]}const $x=new Map,Ad=new Set;function KR(n,e){!Array.isArray(e)||e.length===0||($x.set(n,e),Ad.forEach(t=>t()))}function GR(n){return Ad.add(n),()=>Ad.delete(n)}function ZR(){$x.clear(),Ad.forEach(n=>n())}const $y="high",YR=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function XR(n){return $x.get(n)??HR(n)}function kc(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 xN(n,e,t){const s=kc(e,t),r=s==null?void 0:s.supportedReasoningEfforts;return r&&r.length>0?r:(s==null?void 0:s.supportsEffort)===!1||!bn(n).reasoningEffort?[]:YR}function JR(n,e){var t,s;return(s=(t=kc(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(r=>r.value==="fast"||r.value==="priority"||r.label.toLowerCase()==="fast")}function QR(n,e,t){var r;const s=(r=kc(e,t))==null?void 0:r.inputModalities;return s?s.includes("image"):bn(n).imageInput}function e9(n,e,t){var r;const s=bn(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((r=kc(e,t))==null?void 0:r.supportsAutoMode)===!0}function t9(n,e){return bn(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function n9(n,e,t,s){var l;const r=xN(n,e,s);if(r.length===0)return"";const o=c=>!!c&&r.some(u=>u.value===c);if(o(t))return t;const i=(l=kc(e,s))==null?void 0:l.defaultReasoningEffort;return o(i)?i:o($y)?$y:r[0].value}function s9(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function Pf(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}}function sr(n){const e=V.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=a.jsx(m4,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function r9(n){const e=V.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=a.jsx(nx,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function k2e(n){const e=V.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=a.jsx(bc,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function o9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(sx,{"data-slot":"dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function rr(n){const e=V.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,showCloseButton:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?!0:o;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(o9,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=G("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let u;e[8]!==i?(u=i&&a.jsxs(bc,{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:[a.jsx(Mt,{"data-icon":"inline-start",className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==t||e[11]!==r||e[12]!==c||e[13]!==u?(d=a.jsxs(r9,{children:[l,a.jsxs(Q1,{"data-slot":"dialog-content",className:c,...r,children:[t,u]})]}),e[10]=t,e[11]=r,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}function ao(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Rx(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function or(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ex,{"data-slot":"dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ir(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(tx,{"data-slot":"dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function i9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("label",{"data-slot":"label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function a9(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("fieldset",{"data-slot":"field-set",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function l9(n){const e=V.c(10);let t,s,r;e[0]!==n?({className:t,variant:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"legend":r;let i;e[4]!==t?(i=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==o?(l=a.jsx("legend",{"data-slot":"field-legend","data-variant":o,className:i,...s}),e[6]=s,e[7]=i,e[8]=o,e[9]=l):l=e[9],l}function Aa(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const c9=io("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 fn(n){const e=V.c(11);let t,s,r;e[0]!==n?({className:t,orientation:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"vertical":r;let i;e[4]!==t||e[5]!==o?(i=G(c9({orientation:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"field","data-orientation":o,className:i,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function j2e(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function mn(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(i9,{"data-slot":"field-label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function aa(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-left text-sm leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("p",{"data-slot":"field-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Eo(n){var d;const e=V.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,errors:r,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e:{if(t){i=t;break e}if(!(r!=null&&r.length)){i=null;break e}let f;e[5]!==r?(f=[...new Map(r.map(d9)).values()],e[5]=r,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){i=(d=m[0])==null?void 0:d.message;break e}let p;e[7]!==m?(p=a.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(u9)}),e[7]=m,e[8]=p):p=e[8],i=p}const l=i;if(!l)return null;let c;e[9]!==s?(c=G("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let u;return e[11]!==l||e[12]!==o||e[13]!==c?(u=a.jsx("div",{role:"alert","data-slot":"field-error",className:c,...o,children:l}),e[11]=l,e[12]=o,e[13]=c,e[14]=u):u=e[14],u}function u9(n,e){return(n==null?void 0:n.message)&&a.jsx("li",{children:n.message},e)}function d9(n){return[n==null?void 0:n.message,n]}function On({className:n,...e}){return a.jsx(LP,{"data-slot":"input",className:G("h-8 w-full min-w-0 rounded-lg border border-input bg-background 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:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...e})}const f9=io("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 kt({className:n,variant:e,...t}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:G(f9({variant:e}),n),...t})}function Xt({className:n,...e}){return a.jsx("div",{"data-slot":"alert-title",className:G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",n),...e})}function _t({className:n,...e}){return a.jsx("div",{"data-slot":"alert-description",className:G("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",n),...e})}function Hr({className:n,...e}){return a.jsx("div",{"data-slot":"alert-action",className:G("absolute top-2 right-2",n),...e})}const bN=MP;function vN(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("scroll-my-1 p-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(DP,{"data-slot":"select-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function yN(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-1 text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(UP,{"data-slot":"select-value",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function wN(n){const e=V.c(13);let t,s,r,o;e[0]!==n?({className:s,size:o,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==s?(l=G("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input 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 bg-background hover:bg-accent 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=a.jsx(WP,{render:a.jsx(Et,{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 u;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==l?(u=a.jsxs(FP,{"data-slot":"select-trigger","data-size":i,className:l,...r,children:[t,c]}),e[8]=t,e[9]=r,e[10]=i,e[11]=l,e[12]=u):u=e[12],u}function SN(n){const e=V.c(26);let t,s,r,o,i,l,c,u;e[0]!==n?({className:s,children:t,side:o,sideOffset:i,align:l,alignOffset:c,alignItemWithTrigger:u,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7],u=e[8]);const d=o===void 0?"bottom":o,f=i===void 0?4:i,m=l===void 0?"center":l,p=c===void 0?0:c,h=u===void 0?!0:u;let g;e[9]!==s?(g=G("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(m9,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=a.jsx(qP,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(p9,{}),e[14]=w):w=e[14];let v;e[15]!==r||e[16]!==g||e[17]!==b?(v=a.jsxs(zP,{"data-slot":"select-content",className:g,...r,children:[x,b,w]}),e[15]=r,e[16]=g,e[17]=b,e[18]=v):v=e[18];let j;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==d||e[23]!==f||e[24]!==v?(j=a.jsx(VP,{children:a.jsx(HP,{side:d,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=d,e[23]=f,e[24]=v,e[25]=j):j=e[25],j}function Cg(n){const e=V.c(13);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=a.jsx(KP,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(GP,{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:a.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:a.jsx(nn,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==r||e[10]!==o||e[11]!==i?(c=a.jsxs(BP,{"data-slot":"select-item",className:o,...r,children:[i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=c):c=e[12],c}function m9(n){const e=V.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 r;e[3]!==t?(r=G("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(ja,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(ZP,{"data-slot":"select-scroll-up-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function p9(n){const e=V.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 r;e[3]!==t?(r=G("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Et,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(YP,{"data-slot":"select-scroll-down-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function h9({sessionId:n,onOpen:e,open:t,onOpenChange:s}){var E,T,$;const r=y.useMemo(()=>If(n),[n]),o=y.useSyncExternalStore(r.subscribe,r.snapshot),[i,l]=y.useState([]),[c,u]=y.useState(Ys.at(-1)),[d,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=y.useRef(null),[v,j]=y.useState(null),[k,_]=y.useState(!t),N=y.useRef(0);y.useEffect(()=>{t&&_(!1)},[t]),y.useEffect(()=>{const A=++N.current,R=new AbortController;return Ce("/api/provider-instances",{signal:R.signal}).then(async P=>{if(P.ok){const z=await P.json();A===N.current&&l(z.instances.filter(L=>!L.retired))}}).catch(()=>{}),()=>{N.current=A+1,R.abort()}},[n]),y.useEffect(()=>{!k||!v||v.epoch!==N.current||(j(null),e(v.dirName,v.fileName))},[k,v,e]);async function S(A){if(!o.conversation)return;const R=N.current,P=i.find(M=>M.id===c),z=o.conversation.binding,L={sessionId:n,expectedRevision:o.conversation.revision,mode:A,agent:A==="resume"?z.agent:(P==null?void 0:P.agent)??c,instanceId:A==="resume"?z.instanceId:(P==null?void 0:P.id)??"default",message:d},I=JSON.stringify(L);(!w.current||w.current.payload!==I)&&(w.current={id:crypto.randomUUID(),payload:I}),p(!0),b(null);try{const M=await Ce("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...L,commandId:w.current.id})}),F=await M.json();if(R!==N.current)return;if(!M.ok)throw new Error(F.error||"Provider handoff failed");F.dirName&&F.fileName&&j({dirName:F.dirName,fileName:F.fileName,epoch:R}),s(!1),w.current=null}catch(M){R===N.current&&b(M instanceof Error?M.message:"Provider handoff failed")}finally{R===N.current&&p(!1)}}async function C(A=!1){if(!o.pendingTransition||A&&!window.confirm("Confirm you inspected the target provider’s history and no session was created for this handoff. This releases the conversation so you can start a new handoff."))return;const R=N.current;p(!0),b(null);try{const P=await Ce("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"resolve",sessionId:n,commandId:o.pendingTransition.id,confirmNotCreated:A,targetSessionId:A?void 0:h||o.pendingTransition.sessionId})}),z=await P.json();if(R!==N.current)return;if(!P.ok)throw new Error(z.error||"Handoff reconciliation failed");w.current=null,window.dispatchEvent(new Event("cogpit-command-accepted")),z.dirName&&z.fileName&&e(z.dirName,z.fileName)}catch(P){R===N.current&&b(P instanceof Error?P.message:"Handoff reconciliation failed")}finally{R===N.current&&p(!1)}}return a.jsxs("div",{className:"flex flex-col gap-2 px-3 empty:hidden",children:[o.conversation&&o.conversation.binding.sessionId!==n&&o.currentAddress&&a.jsx(Q,{size:"xs",variant:"outline",onClick:()=>e(o.currentAddress.dirName,o.currentAddress.fileName),children:"Open current conversation session"}),o.pendingTransition&&a.jsx(kt,{children:a.jsxs(_t,{className:"flex flex-col gap-2",children:[a.jsx("p",{children:"A provider handoff needs reconciliation. Inspect the target provider’s history before choosing a recovery action."}),a.jsx(On,{"aria-label":"Recovered session ID",placeholder:o.pendingTransition.sessionId||"Native session ID found in history",value:h,onChange:A=>g(A.target.value)}),a.jsx(Q,{size:"xs",disabled:m||!(h||o.pendingTransition.sessionId),onClick:()=>void C(),children:"Attach recovered session"}),a.jsx(Q,{size:"xs",variant:"outline",disabled:m,onClick:()=>void C(!0),children:"Confirm no session was created"})]})}),a.jsx(sr,{open:t,onOpenChange:A=>{A&&_(!1),s(A)},onOpenChangeComplete:A=>{_(!A)},children:a.jsxs(rr,{children:[a.jsxs(ao,{children:[a.jsx(or,{children:"Continue this conversation"}),a.jsx(ir,{children:"Native resume keeps the current provider and account. Context handoff starts a new native session with up to 12 recent turns and 24,000 characters of text context. Files remain in the same project."})]}),a.jsxs(aa,{children:["Conversation: ",((E=o.conversation)==null?void 0:E.id)||"Loading…"]}),x&&a.jsx(kt,{variant:"destructive",children:a.jsx(_t,{children:x})}),a.jsxs(Aa,{children:[a.jsxs(fn,{children:[a.jsx(mn,{children:"Target provider or account"}),a.jsxs(bN,{value:c,onValueChange:A=>A&&u(A),children:[a.jsx(wN,{"aria-label":"Handoff provider",children:a.jsx(yN,{children:((T=i.find(A=>A.id===c))==null?void 0:T.label)||(($=Cn(c))==null?void 0:$.displayName)})}),a.jsx(SN,{children:a.jsxs(vN,{children:[Ys.map(A=>a.jsxs(Cg,{value:A,children:[Cn(A).displayName," · Default profile"]},A)),i.map(A=>a.jsx(Cg,{value:A.id,children:A.label},A.id))]})})]})]}),a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"handoff-message",children:"Next request"}),a.jsx(On,{id:"handoff-message",value:d,onChange:A=>f(A.target.value)}),a.jsx(aa,{children:"Tool state and permissions are established by the new provider."})]}),a.jsx(Q,{disabled:m||!o.conversation,onClick:()=>void S("handoff"),children:"Start context handoff"}),a.jsx(Q,{variant:"outline",disabled:m||!o.conversation,onClick:()=>void S("resume"),children:"Keep current native session"})]})]})}),!t&&x&&a.jsx(kt,{variant:"destructive",children:a.jsx(_t,{children:x})})]})}function Ry(n){return n.split(/\r?\n/).filter(t=>!t.trimStart().startsWith("[ede_diagnostic]")).join(`
|
|
3
3
|
`).trim()||"The agent stopped before completing this turn. You can continue the conversation."}function jr(n,e){const t=V.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const u=localStorage.getItem(n);return u===null?e:JSON.parse(u)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[r,o]=y.useState(s);let i;t[3]!==n?(i=u=>{o(d=>{const f=typeof u=="function"?u(d):u;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]=i):i=t[4];const l=i;let c;return t[5]!==l||t[6]!==r?(c=[r,l],t[5]=l,t[6]=r,t[7]=c):c=t[7],c}const g9=io("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 Fe(n){const e=V.c(13);let t,s,r,o,i;if(e[0]!==n){const{className:u,variant:d,render:f,...m}=n;t=f,i=d===void 0?"default":d,o=h4,s="span",r=p4({className:G(g9({variant:i}),u)},m),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i}else t=e[1],s=e[2],r=e[3],o=e[4],i=e[5];let l;e[6]!==i?(l={slot:"badge",variant:i},e[6]=i,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==s||e[10]!==r||e[11]!==l?(c={defaultTagName:s,props:r,render:t,state:l},e[8]=t,e[9]=s,e[10]=r,e[11]=l,e[12]=c):c=e[12],o(c)}function Id(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 Nr(n){const e=Id(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:Id(n.lastModified)}function Oy(n,e){return n===e?0:e-n}function Ly(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function x9(n,e){const t=Oy(Nr(n),Nr(e));if(t!==0)return t;const s=Oy(Id(n.lastModified),Id(e.lastModified));return s!==0?s:Ly(n).localeCompare(Ly(e))}function Ia(n){return[...n].sort(x9)}function b9(n,e){var i;const{defaultLimit:t,limits:s,extendedContext:r}=Cn(e).contextWindow,o=n.trim().toLowerCase();return r&&o.includes(r.marker)?r.limit:((i=s.find(l=>o.includes(l.match)))==null?void 0:i.limit)??t}function v9(n,e,t){const s=typeof n.input_tokens=="number"?n.input_tokens:0,r=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,i=s+r+o,l=b9(e,t),c=l-Cn(t).contextWindow.compactBuffer;return{used:i,limit:l,compactAt:c,percent:Math.min(100,i/c*100),percentAbsolute:Math.min(100,i/l*100)}}const y9=["fable","mythos","opus","sonnet","haiku"];function My(n){return n.charAt(0).toUpperCase()+n.slice(1)}function lo(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const r of y9){const o=s.match(new RegExp(`${r}(?:-(\\d+)(?:-(\\d{1,2}))?(?!\\d))?`));if(!o)continue;const i=o[1]?` ${o[1]}${o[2]?`.${o[2]}`:""}`:"";return`${My(r)}${i}${t}`}if(s.startsWith("gpt-")){const[r,...o]=s.slice(4).split("-"),i=o.map(My).join(" ");return`GPT-${r}${i?` ${i}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function w9(n){return n.split("/").map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]")}const S9=new RegExp(`[\\\\/](?:${[...Sc().map(n=>n.projectWorktreeDir),".worktrees"].filter(n=>n!==null).map(w9).join("|")})[\\\\/]([^\\\\/]+)`);function Cr(n){const e=S9.exec(n);return e?{parentPath:n.slice(0,e.index),worktreeName:e[1]}:null}function N2e(n,e){return e===`worktree-${n}`}function gs(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function vt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function Js(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 kN(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function _r(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 r=Math.floor(s/24);return r<7?`${r}d`:new Date(n).toLocaleDateString()}function jN(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 Ox(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e=0,t=n.timestamp,s="";const r=i=>{i&&i>s&&(s=i)},o=()=>{if(!s)return;const i=new Date(s).getTime()-new Date(t).getTime();i>0&&(e+=i),s=""};for(const i of n.contentBlocks){if(i.kind==="task_notification"){o(),i.timestamp&&(t=i.timestamp);continue}if(r(i.timestamp),i.kind==="tool_calls"||i.kind==="plan_mode")for(const l of i.toolCalls)r(l.timestamp)}return o(),e>0?e:null}function Bs(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function xs(n){return vs(n).dirName.decode(n)??n}function jc(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function Er(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function $o(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function NN(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return v9(t.message.usage,t.message.model??"","claude")}return null}function pi(n,e){return e||Bs(_N(n),50)}const k9="Untitled session";function CN(n,e){const t=n.teamName&&n.agentName?n.agentName:"";return e||n.customTitle||n.aiTitle||t||n.lastUserMessage||n.firstUserMessage||n.slug||void 0}function _N(n,e){return CN(n,e)??k9}function j9(n,e){return CN(n,e)===void 0}function N9(n){const e=new Set(n.map(r=>r.sessionId)),t=new Map,s=[];for(const r of n){const o=r.teamLeadSessionId;if(o&&o!==r.sessionId&&e.has(o)){const i=t.get(o);i?i.push(r):t.set(o,[r])}else s.push(r)}return{topLevelSessions:s,teammatesByLead:t}}function C9(n){return n.find(e=>!Cr(e.cwd??xs(e.dirName)))??n[0]}const _9="Unknown project";function Lx(n){const e=Cr(n);return jc(e?e.parentPath:n,2)||_9}function Nl(n){return Lx(n.cwd||xs(n.dirName))}function Mx(n){return n==="inactive"?"Archived after two weeks without activity":"Archived"}function E9(n,e){return e?n:n.filter(t=>!t.archived)}function T9(n){const e=Ia(n),t=new Map;for(const s of e){const r=Nl(s),o=t.get(r);o?o.push(s):t.set(r,[s])}return t}function zx(n,e){return n.isActive?!0:e?n.agentStatus!=="completed":!1}const $f=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),A9=12e4;function EN(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<A9}function Dx(n,e,t=Date.now()){return zx(n,e.get(n.sessionId))?!0:n.agentStatus==="completed"||!n.agentStatus?!1:EN(n,t)}function I9(n,e,t=Date.now()){return n.some(s=>Dx(s,e,t))}const P9={awaitingPermission:new Set,awaitingQuestion:new Set,awaitingPrompt:new Set,awaitingPlan:new Set};function Fx(n){var o,i;const e=new Map(n.map(l=>[l.sessionId,l])),t=l=>{const c=e.get(l);return c!==void 0&&!c.archived},s=[],r=new Map;for(const l of n){const c=l.crew;if(!c){s.push(l);continue}const u=[];let d=c.parentId;for(;d&&d!==l.sessionId&&e.has(d)&&!u.includes(d);)u.push(d),d=(i=(o=e.get(d))==null?void 0:o.crew)==null?void 0:i.parentId;c.hostId&&c.hostId!==l.sessionId&&!u.includes(c.hostId)&&u.push(c.hostId),c.rootId!==l.sessionId&&!u.includes(c.rootId)&&u.push(c.rootId);const f=[...u].reverse().find(t);if(!f){s.push(l);continue}const m=r.get(f);m?m.push(l):r.set(f,[l])}for(const l of r.values())l.sort((c,u)=>{var d,f;return(((d=c.crew)==null?void 0:d.startedAt)??0)-(((f=u.crew)==null?void 0:f.startedAt)??0)});return{topLevel:s,crewOf:r}}function TN(n,e,t){const s=n.sessionId;return t.awaitingPermission.has(s)?{state:"needs-you",need:"permission"}:t.awaitingQuestion.has(s)?{state:"needs-you",need:"question"}:t.awaitingPrompt.has(s)?{state:"needs-you",need:"input"}:t.awaitingPlan.has(s)?{state:"needs-you",need:"plan"}:n.agentStatus==="deferred"?{state:"needs-you",need:"deferred"}:{state:Dx(n,e)&&(!n.agentStatus||$f.has(n.agentStatus))?"working":"done"}}function Ux(n,e){const t={size:n.length,needsYou:0,working:0,done:0};let s;for(const r of n){const{state:o}=e(r);o==="needs-you"?(t.needsYou++,(!s||Nr(r)<Nr(s))&&(s=r)):o==="working"?t.working++:t.done++}return s&&(t.longestWaitSince=s.lastActivityAt||s.lastModified),t}function zy(n,e){const t=e.reduce((s,r)=>Nr(r)>Nr(s)?r:s,n);return t.lastActivityAt||t.lastModified}function Dy(n){var e;return((e=n==null?void 0:n.cwd)==null?void 0:e.replace(/\/+$/,"").split("/").at(-1))||void 0}function Pd(n,{customName:e,parent:t}){var r;if(e)return e;if((r=n.crew)!=null&&r.name)return n.crew.name;if(n.customTitle)return n.customTitle;const s=Dy(n);return s&&s!==Dy(t)?s:$9(n.firstUserMessage)??pi(n)}const Fy=60;function $9(n){const e=n==null?void 0:n.split(`
|
|
4
4
|
`).map(t=>t.replace(/^#+\s*/,"").trim()).find(Boolean);if(e)return e.length>Fy?`${e.slice(0,Fy-1)}…`:e}function R9(n,e){return e.filter(t=>{var s;return((s=t.crew)==null?void 0:s.parentId)===n}).length}function $d(n,e,t){const s=e.get(n);if(!s)return;const r=t[n];return s.crew?Pd(s,{customName:r,parent:e.get(s.crew.parentId)}):pi(s,r)}const O9={capabilities:Tx,user:{edition:"personal",user:null,hubUser:null,enforcesSessionAccess:!1},gate:null},AN={capabilities:Ta,user:{edition:null,user:null,hubUser:null,enforcesSessionAccess:null},gate:null};let IN=O9,_g=null;const Eg=new Set;function Cl(n,e=(n==null?void 0:n.user)??null){IN=n?{capabilities:n.capabilities,user:{edition:n.edition,user:n.user,hubUser:e,enforcesSessionAccess:n.enforcesSessionAccess===!0},gate:n.gate??null}:AN,_g=cn();for(const t of Eg)t()}function Bx(){return _g===null||_g===cn()?IN:AN}function xt(n){const{capabilities:e}=Bx();return Object.hasOwn(e,n)&&e[n]===!0}function Rd(){return Bx().user}function Uy(){return Bx().gate}function Rf(n){return Eg.add(n),()=>Eg.delete(n)}function PN(){return y.useSyncExternalStore(Rf,Rd,Rd)}function $N(){return y.useSyncExternalStore(Rf,Uy,Uy)}function Wx(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function L9(n){return Wx(n)?n:null}const M9="cogpit:session-list-cache",z9=10080*60*1e3,D9=24,Ql={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"};function RN(n,e){return e===null?n:`${n}:${e}`}function td(n){return RN(Ql.activeSessions,n)}const Od=new Map;function F9(){return{version:1,entries:{}}}function Of(){return Td()==="account"&&Zn()===null?null:sn(M9)}function qx(n){const e=Od.get(n);if(e)return e;let t=F9();try{const s=localStorage.getItem(n);if(s){const r=JSON.parse(s);r.version===1&&r.entries&&typeof r.entries=="object"&&(t=r)}}catch{}return Od.set(n,t),t}function ON(n,e){Od.set(n,e);try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function LN(n){const e=Of(),t=e===null?void 0:qx(e).entries[n];if(!(!t||Date.now()-t.savedAt>z9))return t.value}function MN(n,e){const t=Of();if(t===null)return;const s={...qx(t).entries,[n]:{savedAt:Date.now(),value:e}},r=Object.entries(s).sort(([,o],[,i])=>i.savedAt-o.savedAt);ON(t,{version:1,entries:Object.fromEntries(r.slice(0,D9))})}function zN(n){return Wx(n)&&Array.isArray(n.sessions)&&typeof n.total=="number"}function By(n,e){return n.filter(t=>!(Wx(t)&&t.sessionId===e))}function U9(n,e){if(Array.isArray(n)){const r=By(n,e);return r.length===n.length?n:r}if(!zN(n))return n;const t=By(n.sessions,e),s=n.sessions.length-t.length;return s===0?n:{sessions:t,total:n.total-s}}function Zi(n){const e=LN(n);return Array.isArray(e)?e:void 0}function _l(n,e){MN(n,e)}function DN(n,e){return RN(`sessions:${n}`,e)}function B9(n,e){const t=LN(DN(n,e));return zN(t)?t:void 0}function W9(n,e,t){MN(DN(n,e),t)}function q9(n){const e=Of();if(e===null)return;const t=qx(e);let s=!1;const r={};for(const[o,i]of Object.entries(t.entries)){const l=U9(i.value,n);s||(s=l!==i.value),r[o]=l===i.value?i:{...i,value:l}}s&&ON(e,{version:1,entries:r})}function V9(){const n=Of();if(n!==null){Od.delete(n);try{localStorage.removeItem(n)}catch{}}}const H9=Object.freeze({});let Nc=H9,Pa="idle";const Tg=new Set;function Lf(n,e){Nc=n,Pa=e;for(const t of Tg)t()}function Ag(){return Nc}function ec(){return Pa}function Vx(n){return Tg.add(n),()=>Tg.delete(n)}function K9(n){if(Pa==="installed")throw new Error(`An edition UI is already installed; ${n.edition} cannot replace it`);Lf(n.ui,"installed")}function G9(){Pa!=="installed"&&Lf(Nc,"loading")}function Z9(){Pa!=="installed"&&Lf(Nc,"unavailable")}function Y9(){Pa!=="installed"&&Lf(Nc,"failed")}const X9=[],Wy=new WeakMap;function qy(){const n=Rd();let e=Wy.get(n);return e||(e={...n,can:xt},Wy.set(n,e)),e}function $r(){return y.useSyncExternalStore(Vx,Ag,Ag)}function Vy(){return ec()==="unavailable"}function J9(){return y.useSyncExternalStore(Vx,Vy,Vy)}function Q9(){return y.useSyncExternalStore(Rf,qy,qy)}function Hx(){const n=V.c(5),{mainViews:e}=$r(),t=e===void 0?X9:e,s=Q9();let r;if(n[0]!==s||n[1]!==t){let o;n[3]!==s?(o=i=>i.isAvailable(s),n[3]=s,n[4]=o):o=n[4],r=t.filter(o),n[0]=s,n[1]=t,n[2]=r}else r=n[2];return r}function FN(n){const e=V.c(3),t=Hx();let s;return e[0]!==n||e[1]!==t?(s=n===null?null:t.find(r=>r.id===n)??null,e[0]=n,e[1]=t,e[2]=s):s=e[2],s}const eO=Object.freeze({key:null,query:Object.freeze({})});function tO(){return()=>{}}function nO(){return null}function Mf(){const n=V.c(7),{sessionListFilter:e}=$r();let t;n[0]!==e?(t=c=>(e==null?void 0:e.subscribe(c))??tO(),n[0]=e,n[1]=t):t=n[1];const s=t;let r;n[2]!==e?(r=e?()=>e.getKey():nO,n[2]=e,n[3]=r):r=n[3];const o=r,i=y.useSyncExternalStore(s,o,o);let l;return n[4]!==i||n[5]!==e?(l=e&&i!==null?{key:i,query:e.getQuery()}:eO,n[4]=i,n[5]=e,n[6]=l):l=n[6],l}function El(n,e,t={}){const s=new URLSearchParams(t);for(const[o,i]of Object.entries(e.query))s.set(o,i);const r=s.toString();return r?`${n}?${r}`:n}function zf(n,e){return El("/api/active-sessions",e,n)}async function zs(n){try{const e=await(n==null?void 0:n.json());return e&&typeof e=="object"?e:null}catch{return null}}async function Tl(n,e){const t=await zs(n);return typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:e}const sO=["view","interact","own"],rO=1e3,oO=3e4,Ld=new Map,UN=new Set,nd=new Map,hi=new Set,Ig=new Set;let Hy=0;function Vo(n){return`${sn("session-access")}::${n}`}function $a(n){for(const e of n)e()}function Cc(n,e,t){e!=="none"&&UN.add(n);const s=Ld.get(n);return s&&s.ticket>t?!1:(Ld.set(n,{level:e,ticket:t}),(s==null?void 0:s.level)!==e)}function iO(n){return sO.includes(n==null?void 0:n.level)}function aO(n){var e;return(e=Ld.get(Vo(n)))==null?void 0:e.level}function lO(n){return UN.has(Vo(n))}function cO(n){return hi.add(n),()=>hi.delete(n)}function Jr(){return Hy+=1,Hy}function la(n,e){let t=!1;for(const{sessionId:s,access:r}of n)r&&(t=Cc(Vo(s),r.level,e)||t);t&&$a(hi)}async function uO(n){let e;try{e=await Ce(`${vR}${encodeURIComponent(n)}`)}catch{return null}if(e.status===404&&cN(e))return"none";if(!e.ok)return null;const t=await zs(e);return iO(t)?t.level:null}async function dO(n,e){var r;const t=Jr(),s=await uO(n);return s===null?null:(Cc(e,s,t)&&$a(hi),((r=Ld.get(e))==null?void 0:r.level)??null)}function BN(n){const e=Vo(n),t=dO(n,e).finally(()=>{nd.get(e)===t&&nd.delete(e)});return nd.set(e,t),t}function Ky(n){return nd.get(Vo(n))??BN(n)}function C2e(n,e,t){Cc(Vo(n),e,t)&&$a(hi)}function fO(n){Cc(Vo(n),"none",Jr())&&$a(hi)}function WN(n){const{enforcesSessionAccess:e,user:t}=Rd();!e||!t||Cc(Vo(n),"own",Jr())&&$a(hi)}function qN(){$a(Ig)}function Df(n){return Ig.add(n),()=>Ig.delete(n)}function mO(n){let e=!1,t=0,s=0,r;async function o(l){const c=++s;clearTimeout(r);const u=await l();if(e||c!==s)return;if(u){t=0;return}const d=Math.min(rO*2**t,oO);t+=1,r=setTimeout(()=>void o(()=>Ky(n)),d)}o(()=>Ky(n));const i=uN(()=>{t=0,o(()=>BN(n))},n);return()=>{e=!0,clearTimeout(r),i()}}const pO=2e4;function hO(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}function Gy(n,e){let t=null;for(const s of e){const r=!!s.archived;n.has(s.sessionId)!==r&&(t??(t=new Set(n)),r?t.add(s.sessionId):t.delete(s.sessionId))}return t??n}const VN=y.createContext(null);function gO({children:n}){const[e]=y.useState(cn),t=Mf(),s=$N()!==null,r=td(t.key),[o,i]=y.useState(()=>Zi(r)??[]),[l,c]=y.useState(()=>Zi(Ql.runningProcesses)??[]),[u,d]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(new Set),[g,x]=jr(sn("live-sessions-show-archived"),!1),b=g===!0,[w,v]=y.useState(!1),j=b||w,[k,_]=y.useState(0),N=y.useRef(Gy(new Set,o)),[S,C]=y.useState(N.current),E=y.useCallback(H=>{N.current=H,C(H)},[]),T=y.useRef(null),$=y.useRef(!1),A=y.useRef(o),R=y.useRef(r),P=y.useRef(null),z=y.useRef(!1);y.useEffect(()=>(z.current=!0,()=>{var H;z.current=!1,(H=P.current)==null||H.abort(),P.current=null}),[]);const L=y.useCallback(async()=>{var Y;if(s||!z.current||cn()!==e)return;(Y=P.current)==null||Y.abort();const H=new AbortController;P.current=H;const K=()=>z.current&&!H.signal.aborted&&P.current===H&&cn()===e;d(!0);const Z=Jr();try{const[J,ee]=await Promise.all([Ce(zf(j?{archived:"include"}:{},t),{signal:H.signal}),Ce("/api/running-processes",{signal:H.signal})]);if(!K())return;if(!J.ok||!ee.ok)throw new Error("Failed to fetch live data");const[te,se]=await Promise.all([J.json(),ee.json()]);if(!K())return;const X=Array.isArray(te)?te:[],ne=Array.isArray(se)?se:[];la(X,Z),$.current&&($.current=!1,T.current=null),A.current=X,i(X),c(ne),E(Gy(N.current,X)),_(Number(J.headers.get("X-Cogpit-Archived-Count"))||0),_l(r,X),_l(Ql.runningProcesses,ne),m(null)}catch(J){if(!K())return;m(J instanceof Error?J.message:"Failed to load data")}finally{K()&&d(!1),P.current===H&&(P.current=null)}},[s,e,j,t,r,E]),I=y.useCallback(()=>{L()},[L]);y.useEffect(()=>{if(R.current===r)return;R.current=r,$.current=!0;const H=Zi(r)??[];A.current=H,i(H)},[r]),y.useEffect(()=>{I()},[I]),y.useEffect(()=>Df(()=>{$.current=!0,I()}),[I]);const M=y.useMemo(()=>hO(l),[l]),F=y.useMemo(()=>I9(o,M),[o,M]);y.useEffect(()=>(window.addEventListener("focus",I),()=>window.removeEventListener("focus",I)),[I]),y.useEffect(()=>{if(!F)return;const H=setInterval(()=>{document.visibilityState==="visible"&&I()},pO);return()=>clearInterval(H)},[F,I]),y.useEffect(()=>{if(o.length===0||$.current)return;const H=T.current,K=new Map;for(const Z of o)Z.agentStatus&&M.has(Z.sessionId)&&K.set(Z.sessionId,Z.agentStatus);H!==null&&h(Z=>{let Y=null;for(const[J,ee]of K)ee==="completed"&&H.has(J)&&H.get(J)!=="completed"&&(Y??(Y=new Set(Z)),Y.add(J));for(const J of Z)K.get(J)!=="completed"&&(Y??(Y=new Set(Z)),Y.delete(J));return Y??Z}),T.current=K},[o,M]);const U=y.useCallback(H=>{h(K=>{if(!K.has(H))return K;const Z=new Set(K);return Z.delete(H),Z})},[]),O=y.useCallback(H=>{A.current=H,i(H),cn()===e&&_l(r,H)},[e,r]),D=y.useCallback(H=>{O(A.current.filter(K=>K.sessionId!==H))},[O]),B=y.useCallback((H,K)=>{const Z=N.current,Y=new Set(H.filter(te=>Z.has(te)!==K));if(Y.size===0)return;const J=new Set(Z);for(const te of Y)K?J.add(te):J.delete(te);E(J),O(A.current.map(te=>{if(!Y.has(te.sessionId))return te;if(K)return{...te,archived:!0,archivedReason:"manual"};const{archived:se,archivedReason:X,...ne}=te;return ne}));const ee=K?Y.size:-Y.size;_(te=>Math.max(0,te+ee))},[E,O]),q=y.useCallback(H=>S.has(H),[S]),W=y.useMemo(()=>({sessions:o,processes:l,procBySession:M,newlyCompleted:p,loading:u,error:f,refresh:I,removeSession:D,acknowledgeCompleted:U,showArchived:b,setShowArchived:x,setSearchActive:v,archivedCount:k,isArchived:q,setArchived:B}),[o,l,M,p,u,f,I,D,U,b,x,k,q,B]);return a.jsx(VN.Provider,{value:W,children:n})}function Kx(){const n=ar();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function ar(){return y.useContext(VN)}function HN(n){function e(){try{const i=localStorage.getItem(sn(n));return i?JSON.parse(i):{}}catch{return{}}}let t=e();const s=new Set;function r(){for(const i of s)i()}function o(){t=e(),r()}return typeof window<"u"&&(window.addEventListener("cogpit-device-changed",o),window.addEventListener("cogpit-identity-changed",o)),{subscribe:i=>(s.add(i),()=>{s.delete(i)}),getSnapshot:()=>t,rename:(i,l)=>{const c={...t},u=l.trim();u?c[i]=u:delete c[i],localStorage.setItem(sn(n),JSON.stringify(c)),t=c,r()}}}const Pg=HN("session-custom-names"),KN=Pg.rename;function Ff(){const n=V.c(2),e=y.useSyncExternalStore(Pg.subscribe,Pg.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:KN},n[0]=e,n[1]=t):t=n[1],t}function Ra(){const n=V.c(5),e=ar(),{names:t}=Ff();e==null||e.sessions;let s;n[0]!==(e==null?void 0:e.sessions)?(s=new Map(((e==null?void 0:e.sessions)??[]).map(xO)),n[0]=e==null?void 0:e.sessions,n[1]=s):s=n[1];const r=s;let o;return n[2]!==r||n[3]!==t?(o=i=>$d(i,r,t),n[2]=r,n[3]=t,n[4]=o):o=n[4],o}function xO(n){return[n.sessionId,n]}const bO=/\x1b\].*?(?:\x07|\x1b\\)/g,vO=/\x1b\[[0-9;]*[A-Za-z]/g,yO=/\x1b[()][AB012]/g,wO=/\[2K\[1G/g;function GN(n){return n.replace(bO,"").replace(vO,"").replace(yO,"").replace(wO,`
|
|
5
5
|
`).replace(/\r/g,"")}const SO=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,kO=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function jO(n){for(const e of kO){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 NO(n){return n.replace(/^\s*<(?:agent-message|teammate-message)\b[^>]*>/,"").replace(/<\/(?:agent-message|teammate-message)>\s*$/,"").trim()}function ca(n){let e=null,t=!1;const s=n.replace(SO,(r,o,i,l)=>(t=!0,e===null&&(e=jO(i)),l.trim()));return{sender:e,matched:t,body:t?s.trim():n}}const CO=[/\bblocking question\b/,/\bbefore i touch\b/,/\bshould i\b/,/\btell me one of\b/,/\byour call\b/,/\bwho owns\b/,/\bconfirm whether\b/],_O=[/(?:^|[,;:.!?—–-]\s*)tell me\b/,/(?:^|[,;:.!?—–-]\s*)say so\b/],EO=200,TO=/\bhttps?:\/\/\S+/g;function AO(n){const e=n.trim();if(!e)return!1;const t=e.slice(0,EO).toLowerCase();if(CO.some(o=>o.test(t)))return!0;const r=e.slice(e.lastIndexOf(`
|
|
@@ -67,7 +67,7 @@ ${t.join(`
|
|
|
67
67
|
|
|
68
68
|
`)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()};let i;const l=nc,c=!Qs.jitless,d=c&&rD.value,f=e.catchall;let m;n._zod.parse=(p,h)=>{m??(m=s.value);const g=p.value;return l(g)?c&&d&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(i||(i=o(e.shape)),p=i(p,h),f?oC([],g,p,h,m,n,(h==null?void 0:h.abortEarly)===!0):p):t(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:n}),p)}});function j2(n,e,t,s){for(const o of n)if(o.issues.length===0)return e.value=o.value,e;const r=n.filter(o=>!Vr(o));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(o=>o.issues.map(i=>Oo(i,s,Tr())))}),e)}const iC=he("$ZodUnion",(n,e)=>{Bt.init(n,e),wt(n,"optin",s=>s.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":s.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),wt(n,"optout",s=>s.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),wt(n,"values",s=>{if(s.def.options.every(r=>r._zod.values))return new Set(s.def.options.flatMap(r=>Array.from(r._zod.values)))}),wt(n,"pattern",s=>{if(s.def.options.every(r=>r._zod.pattern)){const r=s.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>c0(o.source)).join("|")})$`)}});const t=e.options.length===1?e.options[0]._zod.run:null;n._zod.parse=(s,r)=>{if(t)return t(s,r);let o=!1;const i=[];for(const l of e.options){const c=l._zod.run({value:s.value,issues:[]},r);if(c instanceof Promise)i.push(c),o=!0;else{if(c.issues.length===0)return c;i.push(c)}}return o?Promise.all(i).then(l=>j2(l,s,n,r)):j2(i,s,n,r)}});function CU(n){var t;const e=new Map;for(const s of n.options){const r=(t=s._zod.propValues)==null?void 0:t[n.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${n.options.indexOf(s)}"`);for(const o of r)if(e.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);e.set(o,null)}else e.set(o,s)}return e}const _U=he("$ZodDiscriminatedUnion",(n,e)=>{e.inclusive=!1,iC.init(n,e);const t=n._zod.parse;wt(n,"propValues",r=>{var l,c;const o={};let i=0;for(const u of r.def.options){const d=u._zod.propValues;if(!d||Object.keys(d).length===0)throw new Error(`Invalid discriminated union option at index "${r.def.options.indexOf(u)}"`);(l=d[r.def.discriminator])!=null&&l.has(void 0)&&i++;for(const[f,m]of Object.entries(d)){Object.prototype.hasOwnProperty.call(o,f)||co(o,f,new Set);for(const p of m)o[f].add(p)}}return!r.def.unionFallback&&i>1&&((c=o[r.def.discriminator])==null||c.delete(void 0)),o}),e.options.forEach((r,o)=>{const i=u0(r._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,e.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const s=Vf(()=>CU(e));n._zod.parse=(r,o)=>{const i=r.value;if(!nc(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:n}),r;const l=i==null?void 0:i[e.discriminator],c=s.value.get(l);return c&&(l!==void 0||o.direction!=="backward")?c._zod.run(r,o):e.unionFallback||o.direction==="backward"?t(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(s.value.keys()).filter(u=>s.value.get(u)!==null),input:i,path:[e.discriminator],inst:n}),r)}}),EU=he("$ZodIntersection",(n,e)=>{Bt.init(n,e),n._zod.parse=(t,s)=>{const r=t.value,o=e.left._zod.run({value:r,issues:[]},s),i=e.right._zod.run({value:r,issues:[]},s);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,u])=>N2(t,c,u)):N2(t,o,i)}});function Wg(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(ua(n)&&ua(e)){const t=Object.keys(e),s=Object.keys(n).filter(o=>t.indexOf(o)!==-1),r={...n,...e};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(const o of s){if(o==="__proto__")continue;const i=Wg(n[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r[o]=i.data}return{valid:!0,data:r}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let s=0;s<n.length;s++){const r=n[s],o=e[s],i=Wg(r,o);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};t.push(i.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function N2(n,e,t){const s=new Map;let r;const o=new Map,i=(u,d)=>{var m,p;let f;if(u.code==="unrecognized_keys"&&!((m=u.path)!=null&&m.length))r??(r=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&((p=u.path)==null?void 0:p.length)===1){const h=String(u.path[0]);o.has(h)||o.set(h,u),f=[h]}else return!1;for(const h of f)s.has(h)||s.set(h,{}),s.get(h)[d]=!0;return!0};for(const u of e.issues)i(u,"l")||n.issues.push(u);for(const u of t.issues)i(u,"r")||n.issues.push(u);const l=[...s].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(l.length){const u=r?l.filter(d=>r.keys.includes(d)):[];u.length&&n.issues.push({...r,keys:u});for(const d of l)!u.includes(d)&&o.has(d)&&n.issues.push(o.get(d))}const c=Wg(e.value,t.value);if(!c.valid){if(Vr(n))return n;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return n.value=c.data,n}const TU=he("$ZodRecord",(n,e)=>{Bt.init(n,e);const t=Qs.memoizer;t==null||t.attach(n),n._zod.parse=(s,r)=>{const o=s.value;if(!ua(o))return s.issues.push({expected:"record",code:"invalid_type",input:o,inst:n}),s;const i=[],l=e.keyType._zod.values;if(l&&!e.partial){s.value=t?t.alloc(n,s,{},r):{};const c=new Set;for(const d of l)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){if(c.add(typeof d=="number"?d.toString():d),d==="__proto__")continue;const f=e.keyType._zod.run({value:d,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){s.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(h=>Oo(h,r,Tr())),input:d,path:[d],inst:n});continue}const m=f.value;if(m==="__proto__")continue;const p=e.valueType._zod.run({value:o[d],issues:[]},r);p instanceof Promise?i.push(p.then(h=>{h.issues.length&&s.issues.push(...qi(d,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...qi(d,p.issues)),s.value[m]=p.value)}let u;for(const d in o)if(!c.has(d))if(e.mode==="loose"){if(d==="__proto__")continue;s.value[d]=o[d]}else u=u??[],u.push(d);u&&u.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:n,keys:u,continue:!0})}else{s.value=t?t.alloc(n,s,{},r):{};let c;for(const u of Reflect.ownKeys(o)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,u))continue;let d=e.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&x0.test(u)&&d.issues.length){const h=e.keyType._zod.run({value:Number(u),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(d=h)}if(d.issues.length){e.mode==="loose"?s.value[u]=o[u]:l?(c=c??[],c.push(u)):s.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>Oo(h,r,Tr())),input:u,path:[u],inst:n});continue}const m=d.value;if(m==="__proto__")continue;const p=e.valueType._zod.run({value:o[u],issues:[]},r);p instanceof Promise?i.push(p.then(h=>{h.issues.length&&s.issues.push(...qi(u,h.issues)),s.value[m]=h.value})):(p.issues.length&&s.issues.push(...qi(u,p.issues)),s.value[m]=p.value)}c&&c.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:n,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>s):s}}),AU=he("$ZodEnum",(n,e)=>{Bt.init(n,e);const t=Dg(e.entries),s=new Set(t);n._zod.values=s,wt(n,"pattern",r=>{const o=Dg(r.def.entries).filter(i=>oD.has(typeof i));return new RegExp(o.length?`^(${o.map(i=>da(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(r,o)=>{const i=r.value;return s.has(i)||r.issues.push({code:"invalid_value",values:t,input:i,inst:n}),r}}),IU=he("$ZodLiteral",(n,e)=>{Bt.init(n,e);const t=new Set(e.values);n._zod.values=t,wt(n,"pattern",s=>{const r=s.def.values;return new RegExp(r.length?`^(${r.map(o=>typeof o=="string"?da(o):o?da(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(s,r)=>{const o=s.value;return t.has(o)||s.issues.push({code:"invalid_value",values:e.values,input:o,inst:n}),s}}),PU=he("$ZodTransform",(n,e)=>{var t;Bt.init(n,e),n._zod.optin="optional",(t=Qs.memoizer)==null||t.guard(n),n._zod.parse=(s,r)=>{if(r.direction==="backward")throw new V5(n.constructor.name);const o=e.transform(s.value,s);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(l=>(s.value=l,s));if(o instanceof Promise)throw new di;return s.value=o,s}});function C2(n,e){return n.value=e.issues.length?void 0:e.value,n}const aC=he("$ZodOptional",(n,e)=>{Bt.init(n,e),wt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",wt(n,"values",t=>{const s=t.def.innerType._zod.values;return s?new Set([...s,void 0]):void 0}),wt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${c0(s.source)})?$`):void 0}),n._zod.parse=(t,s)=>{if(t.value===void 0){if(e.innerType._zod.optin!=="defaulted")return t;const r=e.innerType._zod.run({value:t.value,issues:[]},s);return r instanceof Promise?r.then(o=>C2(t,o)):C2(t,r)}return e.innerType._zod.run(t,s)}}),$U=he("$ZodExactOptional",(n,e)=>{aC.init(n,e),wt(n,"values",t=>t.def.innerType._zod.values),wt(n,"pattern",t=>t.def.innerType._zod.pattern),n._zod.parse=(t,s)=>e.innerType._zod.run(t,s)}),RU=he("$ZodNullable",(n,e)=>{Bt.init(n,e),wt(n,"optin",t=>t.def.innerType._zod.optin),wt(n,"optout",t=>t.def.innerType._zod.optout),wt(n,"pattern",t=>{const s=t.def.innerType._zod.pattern;return s?new RegExp(`^(${c0(s.source)}|null)$`):void 0}),wt(n,"values",t=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),n._zod.parse=(t,s)=>t.value===null?t:e.innerType._zod.run(t,s)}),OU=he("$ZodDefault",(n,e)=>{Bt.init(n,e),n._zod.optin="defaulted",wt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);if(t.value===void 0)return t.value=e.defaultValue,t;const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(o=>_2(o,e)):_2(r,e)}});function _2(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const LU=he("$ZodPrefault",(n,e)=>{Bt.init(n,e),n._zod.optin="defaulted",wt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>(s.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,s))}),MU=he("$ZodNonOptional",(n,e)=>{Bt.init(n,e),wt(n,"values",t=>{const s=t.def.innerType._zod.values;return s?new Set([...s].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,s)=>{const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(o=>E2(o,n)):E2(r,n)}});function E2(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}function T2(n,e,t,s){return e.issues.length?(n.value=t.catchValue({...e,value:n.value,error:{issues:e.issues.map(r=>Oo(r,s,Tr()))},input:n.value}),n):(n.value=e.value,e.memo&&(n.memo=!0),n)}const zU=he("$ZodCatch",(n,e)=>{Bt.init(n,e),wt(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),wt(n,"optout",t=>t.def.innerType._zod.optout),wt(n,"values",t=>t.def.innerType._zod.values),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);const r=e.innerType._zod.run({value:t.value,issues:[]},s);return r instanceof Promise?r.then(o=>T2(t,o,e,s)):T2(t,r,e,s)}}),DU=he("$ZodPipe",(n,e)=>{Bt.init(n,e),wt(n,"values",t=>t.def.in._zod.values),wt(n,"optin",t=>t.def.in._zod.optin),wt(n,"optout",t=>t.def.out._zod.optout),wt(n,"propValues",t=>t.def.in._zod.propValues),n._zod.parse=(t,s)=>{if(s.direction==="backward"){const o=e.out._zod.run(t,s);return o instanceof Promise?o.then(i=>bu(i,e.in,s)):bu(o,e.in,s)}const r=e.in._zod.run(t,s);return r instanceof Promise?r.then(o=>bu(o,e.out,s)):bu(r,e.out,s)}});function bu(n,e,t){return n.issues.some(s=>s.code!=="unrecognized_keys")?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const FU=he("$ZodReadonly",(n,e)=>{Bt.init(n,e),wt(n,"propValues",t=>t.def.innerType._zod.propValues),wt(n,"values",t=>t.def.innerType._zod.values),wt(n,"optin",t=>{var s,r;return(r=(s=t.def.innerType)==null?void 0:s._zod)==null?void 0:r.optin}),wt(n,"optout",t=>{var s,r;return(r=(s=t.def.innerType)==null?void 0:s._zod)==null?void 0:r.optout}),n._zod.parse=(t,s)=>{if(s.direction==="backward")return e.innerType._zod.run(t,s);const r=e.innerType._zod.run(t,s);return r instanceof Promise?r.then(A2):A2(r)}});function A2(n){return n.memo||(n.value=Object.freeze(n.value)),n}const UU=he("$ZodCustom",(n,e)=>{as.init(n,e),Bt.init(n,e),n._zod.parse=(t,s)=>t,n._zod.check=t=>{const s=t.value,r=e.fn(s);if(r instanceof Promise)return r.then(o=>I2(o,t,s,n));I2(r,t,s,n)}});function I2(n,e,t,s){if(!n){const r={code:"custom",input:t,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(r.params=s._zod.def.params),e.issues.push(sc(r))}}class BU extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const qg="~memo",P2=[];function lC(n){return n!==null&&typeof n=="object"}function tp(n){return n.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const cC=new WeakMap,rl=0,ad=1,$l=2;function ld(n,e,t){const s=cC.get(n);if(s!==void 0)return s?$l:rl;if(e.has(n))return $l;e.add(n);let r=rl;const o=d=>{if(r!==$l&&(d!=null&&d._zod)){const f=ld(d,e);f>r&&(r=f)}},i=(d,f)=>{var p;let m=rl;for(const h of Reflect.ownKeys(d)){const g=Object.getOwnPropertyDescriptor(d,h);if(!g.enumerable)continue;const x=g.get?ad:(p=g.value)!=null&&p._zod?ld(g.value,e):rl;x>m&&(m=x)}return m},l=d=>{d>r&&(r=d)},c=n._zod.def;switch(c.type){case"object":{const d=u0(c);l(d?i(d):ad),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(const d of c.items)o(d);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(const d of c.options)o(d);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{const d=c._cachedInner??void 0;l(d?ld(d,e):ad);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const d in c){const f=Object.getOwnPropertyDescriptor(c,d);if(!f||f.get)continue;const m=f.value;if(!(!m||typeof m!="object")){if(m._zod)o(m);else if(Array.isArray(m))for(const p of m)o(p)}}}return e.delete(n),WU(n,r)}function WU(n,e){return e!==ad&&cC.set(n,e===$l),e}function qU(n,e){let t=n.buckets.get(e);return t||(t=new WeakMap,n.buckets.set(e,t)),t}let vu;const yu=[],VU={alloc(n,e,t){const s=vu;if(!s)return t;vu=void 0;const r={value:t,issues:null};return s.set(e.value,r),yu.push(r),t},guard(n){var e;(e=n._zod).deferred??(e.deferred=[]),n._zod.deferred.push(()=>{const t=n._zod.parse,s=(r,o)=>{if(o.direction!=="backward"&&KU(o,r.value))throw new BU;return t(r,o)};n._zod.parse=s,n._zod.run===t&&(n._zod.run=s)})},attach(n){var e;let t,s=!1,r,o;(e=n._zod).deferred??(e.deferred=[]),n._zod.deferred.push(()=>{const i=n._zod.parse,l=(c,u)=>{if(t===void 0){const b=ld(n,new Set);if(b===rl)return n._zod.parse=i,n._zod.run===l&&(n._zod.run=i),i(c,u);b===$l||s?t=!0:s=!0}const d=c.value;if(!lC(d))return i(c,u);let f=u[qg];f||(f={buckets:new WeakMap,backEdges:void 0},u[qg]=f);let m;r===u?m=o:(m=qU(f,n),r=u,o=m);const p=m.get(d);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...tp(p.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(p.value)),c;vu=m;const h=yu.length,g=i(c,u);vu=void 0;const x=yu.length>h?yu.pop():void 0;return g instanceof Promise?g.then(b=>(x&&(x.issues=b.issues.length?tp(b.issues):P2),b)):(x&&(x.issues=g.issues.length?tp(g.issues):P2),g)};n._zod.parse=l,n._zod.run===i&&(n._zod.run=l)})}};function HU(){return VU}function KU(n,e){var s;const t=(s=n[qg])==null?void 0:s.backEdges;return t!==void 0&&lC(e)&&t.has(e)}const GU=()=>{const n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return n[o]??null}const t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},s={nan:"NaN"};function r(o,i){return o==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):s[o]??o}return o=>{switch(o.code){case"invalid_type":{const i=r(o.expected),l=gD(o.input),c=r(l,o.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${F5(o.values[0])}`:`Invalid option: expected one of ${h2(o.values,"|")}`;case"too_big":{const i=o.exact?"exactly ":o.inclusive?"<=":"<",l=e(o.origin);return l?`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${l.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{const i=o.exact?"exactly ":o.inclusive?">=":">",l=e(o.origin);return l?`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${l.unit}`:`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{const i=o;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${t[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${h2(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(l=>`'${l}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function ZU(){return{localeError:GU()}}var $2;class YU{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const s=t[0];return this._map.set(e,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const s={...this.get(t)??{}};delete s.id;const r={...s,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function XU(){return new YU}($2=globalThis).__zod_globalRegistry??($2.__zod_globalRegistry=XU());const ol=globalThis.__zod_globalRegistry;function uC(n){return n.checks&&(n.checks=[...n.checks]),n}function JU(n,e){return new n(uC({type:"string",...Ye(e)}))}function QU(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...Ye(e)})}function eB(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...Ye(e)})}function tB(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...Ye(e)})}function nB(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ye(e)})}function sB(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ye(e)})}function rB(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ye(e)})}function oB(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...Ye(e)})}function iB(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...Ye(e)})}function aB(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ye(e)})}function lB(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...Ye(e)})}function cB(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ye(e)})}function uB(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...Ye(e)})}function dB(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...Ye(e)})}function fB(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ye(e)})}function mB(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ye(e)})}function pB(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ye(e)})}function hB(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ye(e)})}function gB(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ye(e)})}function xB(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...Ye(e)})}function bB(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...Ye(e)})}function vB(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...Ye(e)})}function yB(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...Ye(e)})}function wB(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ye(e)})}function SB(n,e){return new n({type:"string",format:"date",check:"string_format",...Ye(e)})}function kB(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...Ye(e)})}function jB(n,e){return new n({type:"string",format:"duration",check:"string_format",...Ye(e)})}function NB(n,e){return new n(uC({type:"number",checks:[],...Ye(e)}))}function CB(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...Ye(e)})}function _B(n,e){return new n({type:"boolean",...Ye(e)})}function EB(n,e){return new n({type:"null",...Ye(e)})}function TB(n){return new n({type:"unknown"})}function AB(n,e){return new n({type:"never",...Ye(e)})}function R2(n,e){return new G5({check:"less_than",...Ye(e),value:n,inclusive:!1})}function np(n,e){return new G5({check:"less_than",...Ye(e),value:n,inclusive:!0})}function O2(n,e){return new Z5({check:"greater_than",...Ye(e),value:n,inclusive:!1})}function sp(n,e){return new Z5({check:"greater_than",...Ye(e),value:n,inclusive:!0})}function L2(n,e){return new SF({check:"multiple_of",...Ye(e),value:n})}function dC(n,e){return new jF({check:"max_length",...Ye(e),maximum:n})}function Bd(n,e){return new NF({check:"min_length",...Ye(e),minimum:n})}function fC(n,e){return new CF({check:"length_equals",...Ye(e),length:n})}function IB(n,e){return new _F({check:"string_format",format:"regex",...Ye(e),pattern:n})}function PB(n){return new EF({check:"string_format",format:"lowercase",...Ye(n)})}function $B(n){return new TF({check:"string_format",format:"uppercase",...Ye(n)})}function RB(n,e){return new AF({check:"string_format",format:"includes",...Ye(e),includes:n})}function OB(n,e){return new IF({check:"string_format",format:"starts_with",...Ye(e),prefix:n})}function LB(n,e){return new PF({check:"string_format",format:"ends_with",...Ye(e),suffix:n})}function Ma(n){return new $F({check:"overwrite",tx:n})}function MB(n){return Ma(e=>e.normalize(n))}function zB(){return Ma(n=>n.trim())}function DB(){return Ma(n=>n.toLowerCase())}function FB(){return Ma(n=>n.toUpperCase())}function UB(){return Ma(n=>sD(n))}function BB(n,e,t){return new n({type:"array",element:e,...Ye(t)})}function WB(n,e,t){const s=Ye(t);return s.abort??(s.abort=!0),new n({type:"custom",check:"custom",fn:e,...s})}function qB(n,e,t){return new n({type:"custom",check:"custom",fn:e,...Ye(t)})}function VB(n,e){const t=HB(s=>(s.addIssue=r=>{if(typeof r=="string")s.issues.push(sc(r,s.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=s.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),s.issues.push(sc(o))}},n(s.value,s)),e);return t}function HB(n,e){const t=new as({check:"custom",...Ye(e)});return t._zod.check=n,t}function Rl(n,...e){for(const t of e)for(const s of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,s)&&co(n,s,t[s]);return n}function mC(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??ol,target:e,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",intersections:[],deferred:[],external:(n==null?void 0:n.external)??void 0}}function Mo(n,e,t,s,r){const o=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:n,path:s.path,message:r}):e.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(r);return Object.assign(t,o),!0}function pn(n,e,t={path:[],schemaPath:[]}){var d,f;var s;const r=n._zod.def,o=e.seen.get(n);if(o)return o.count++,t.schemaPath.includes(n)&&(o.cycle=t.path),o.schema;const i={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,i),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;const l=(f=(d=n._zod).toJSONSchema)==null?void 0:f.call(d);if(l)i.schema=l;else{const m={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,i.schema,m);else{const h=i.schema,g=e.processors[r.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);g(n,e,h,m)}const p=n._zod.parent;p&&(i.ref||(i.ref=p),pn(p,e,m),e.seen.get(p).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Rl(i.schema,c),e.io==="input"&&qn(n)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((s=i.schema).default??(s.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(n).schema}function M2(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}function pC(n,e){var i,l,c,u;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");if(n.external&&n.sharedDefsExtractedFor===n.external)return;const s=new Map;for(const d of n.seen.entries()){const f=(i=n.metadataRegistry.get(d[0]))==null?void 0:i.id;if(f){const m=s.get(f);if(m&&m!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(f,d[0])}}const r=d=>{var g;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const x=(g=n.external.registry.get(d[0]))==null?void 0:g.id,b=n.external.uri??(v=>v);if(x)return{ref:b(x)};const w=d[1].defId??d[1].schema.id??`schema${n.counter++}`;return d[1].defId=w,{defId:w,ref:`${b("__shared")}#/${f}/${M2(w)}`}}const m="#",p=`${m}/${f}/`;if(d[1]===t&&!d[1].schema.id)return{ref:m};const h=d[1].schema.id??`__schema${n.counter++}`;return{defId:h,ref:p+M2(h)}},o=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:m,defId:p}=r(d);f.def={...f.schema},p&&(f.defId=p);const h=f.schema;for(const g in h)delete h[g];h.$ref=m};if(n.cycles==="throw")for(const d of n.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(l=f.cycle)==null?void 0:l.join("/")}/<root>
|
|
69
69
|
|
|
70
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){o(d);continue}if(n.external){const p=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&p){o(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){o(d);continue}if(f.cycle){o(d);continue}f.count>1&&n.reused==="ref"&&o(d)}n.external&&(n.sharedDefsExtractedFor=n.external)}function hC(n){const e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;const t=[];for(const s of e){if(!s||typeof s!="object")return;hC(s);const r=Object.keys(s);if(r.length!==1||r[0]!=="type")return;const o=s.type;for(const i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;t.includes(i)||t.push(i)}}delete n.anyOf,n.type=t.length===1?t[0]:t}const gC=new Set(["type","properties","required","additionalProperties"]),z2=["oneOf","anyOf"];function D2(n){const e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Vg(n){var o;const e=[];for(const i of n){if(typeof i!="object"||i.type!=="object")return null;for(const l in i)if(!gC.has(l))return null;e.push(i)}const t={},s=new Set;for(const i of e){for(const l in i.properties){if(Object.prototype.hasOwnProperty.call(t,l))continue;const c=[];for(const d of e){const f=((o=d.properties)==null?void 0:o[l])??D2(d);f!=null&&(c.some(m=>JSON.stringify(m)===JSON.stringify(f))||c.push(f))}const u=c.length===1?c[0]:Vg(c)??{allOf:c};co(t,l,u)}for(const l of i.required??[])s.add(l)}const r={type:"object",properties:t};if(s.size&&(r.required=[...s]),e.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{const i=[];for(const l of e){const c=D2(l);c&&!i.some(u=>JSON.stringify(u)===JSON.stringify(c))&&i.push(c)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function KB(n){const e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(const r of gC)if(r in n)return;const t=e.filter(r=>z2.some(o=>Array.isArray(r[o])));let s=null;if(!t.length)s=Vg(e);else{const r=t[0],o=z2.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;const i=e.filter(c=>c!==r),l=r[o].map(c=>Vg([...i,c]));if(l.some(c=>!c))return;s={[o]:l}}s&&(delete n.allOf,Rl(n,s))}function xC(n,e){var l,c,u,d;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=f=>{const m=n.seen.get(f);if(m.ref===null)return;const p=m.def??m.schema,h={...p},g=m.ref;if(m.ref=null,g){s(g);const b=n.seen.get(g),w=b.schema;if(w.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(w)):Rl(p,w),Rl(p,h),f._zod.parent===g)for(const j in p)j==="$ref"||j==="allOf"||j in h||delete p[j];if(w.$ref&&b.def)for(const j in p)j==="$ref"||j==="allOf"||j in b.def&&JSON.stringify(p[j])===JSON.stringify(b.def[j])&&delete p[j]}const x=f._zod.parent;if(x&&x!==g){s(x);const b=n.seen.get(x);if(b!=null&&b.schema.$ref&&(p.$ref=b.schema.$ref,b.def))for(const w in p)w==="$ref"||w==="allOf"||w in b.def&&JSON.stringify(p[w])===JSON.stringify(b.def[w])&&delete p[w]}n.override({zodSchema:f,jsonSchema:p,path:m.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(const f of[...n.seen.entries()].reverse())s(f[0]);if(n.target!=="openapi-3.0")for(const f of n.seen.entries())hC(f[1].def??f[1].schema);for(const f of n.deferred)f();if(n.intersections.length){const f=new Map;for(const m of n.seen.values())for(const p of[m.schema,m.def]){const h=p==null?void 0:p.allOf;if(!Array.isArray(h))continue;const g=f.get(h);g?g.push(p):f.set(h,[p])}for(const m of n.intersections)for(const p of f.get(m)??[])KB(p)}}const r={};if(n.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":n.target,(l=n.external)!=null&&l.uri){const f=(c=n.external.registry.get(e))==null?void 0:c.id;if(!f)throw new Error("Schema is missing an `id` property");r.$id=n.external.uri(f)}Rl(r,t.defId?t.schema:t.def??t.schema);const o=(u=n.metadataRegistry.get(e))==null?void 0:u.id;o!==void 0&&r.id===o&&delete r.id;const i=((d=n.external)==null?void 0:d.defs)??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(const f of n.seen.entries()){const m=f[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,co(i,m.defId,m.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(i).length>0&&(n.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const f=JSON.parse(JSON.stringify(r));return Object.defineProperty(f,"~standard",{value:{...e["~standard"],jsonSchema:{input:Wd(e,"input",n.processors),output:Wd(e,"output",n.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function qn(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const s=n._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return qn(s.element,t);if(s.type==="set")return qn(s.valueType,t);if(s.type==="lazy")return qn(s.getter(),t);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault"||s.type==="catch")return qn(s.innerType,t);if(s.type==="intersection")return qn(s.left,t)||qn(s.right,t);if(s.type==="record"||s.type==="map")return qn(s.keyType,t)||qn(s.valueType,t);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:qn(s.in,t)||qn(s.out,t);if(s.type==="object"){for(const r in s.shape)if(qn(s.shape[r],t))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(qn(r,t))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(qn(r,t))return!0;return!!(s.rest&&qn(s.rest,t))}return!1}const GB=(n,e={})=>t=>{const s=mC({...t,processors:e});return pn(n,s),pC(s,n),xC(s,n)},Wd=(n,e,t={})=>s=>{const{libraryOptions:r,target:o}=s??{},i=mC({...r??{},target:o,io:e,processors:t});return pn(n,i),pC(i,n),xC(i,n)},fa=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},ma=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},F2=(n,e)=>{fa(n,"minimum",e),ma(n,"maximum",e)},bC=(n,e)=>{n.multipleOf??(n.multipleOf=[]),n.multipleOf.includes(e)||n.multipleOf.push(e)},vC=(n,e)=>{n.patterns??(n.patterns=new Set),n.patterns.add(e)},yC=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},wC=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},U2=(n,e)=>fa(n,"minimum",e.minimum),B2=(n,e)=>ma(n,"maximum",e.maximum),W2=n=>(e,t)=>{wC(e,t.format);const[s,r]=n[t.format];fa(e,"minimum",s),ma(e,"maximum",r)},rp={greater_than:(n,e)=>fa(n,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(n,e)=>ma(n,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(n,e)=>bC(n,e.value),number_format:W2(U5),bigint_format:W2(aD),min_length:U2,max_length:B2,length_equals:(n,e)=>F2(n,e.length),min_size:U2,max_size:B2,size_equals:(n,e)=>F2(n,e.size),string_format:(n,e)=>{wC(n,e.format),e.pattern&&vC(n,e.pattern),(e.format==="base64"||e.format==="base64url")&&(n.contentEncoding=e.format),(e.local||e.precision===-1)&&(n.laxFormat=!0)},mime_type:(n,e)=>yC(n,e.mime)};function Ws(n){var o;const e={},t=n._zod.def,s=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(const i of s)(o=rp[i._zod.def.check])==null||o.call(rp,e,i._zod.def);const r=n._zod.bag;r.minimum!==void 0&&fa(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&fa(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&ma(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&ma(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&bC(e,r.multipleOf),r.format!==void 0&&(e.format??(e.format=r.format),r.format.includes("int")&&(e.isInt=!0)),r.mime&&yC(e,r.mime);for(const i of r.patterns??[])vC(e,i);return e}const ZB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},YB=new Map([[nC,lF],[y0,cF]]),SC=n=>YB.get(n)??n,XB=(n,e,t,s)=>{const r=t;r.type="string";const{minimum:o,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=Ws(n);if(typeof o=="number"&&(r.minLength=o),typeof i=="number"&&(r.maxLength=i),l&&(r.format=ZB[l]??l,r.format===""&&delete r.format,(l==="time"||d)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const f=[...c].map(SC);f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(m=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},JB=(n,e,t,s)=>{const r=t,{minimum:o,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=Ws(n);r.type=d?"integer":"number";const f=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(f?p?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),m?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof i=="number"&&(r.maximum=i),l){const h=new Set;for(const b of l)Number.isFinite(b)&&b!==0?h.add(Math.abs(b)):Mo(n,e,r,s,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);const[g,...x]=h;g!==void 0&&(r.multipleOf=g),x.length&&(r.allOf=[...r.allOf??[],...x.map(b=>({multipleOf:b}))])}},QB=(n,e,t,s)=>{t.type="boolean"},eW=(n,e,t,s)=>{e.target==="openapi-3.0"?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"},tW=(n,e,t,s)=>{t.not={}},nW=(n,e,t,s)=>{},sW=(n,e,t,s)=>{const r=n._zod.def,o=Dg(r.entries);if(o.length===0){t.not={};return}o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),t.enum=o},rW=(n,e,t,s)=>{const r=n._zod.def;if(r.values.length===0){t.not={};return}const o=[];for(const i of r.values)if(i===void 0){if(Mo(n,e,t,s,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Mo(n,e,t,s,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){const i=o[0];t.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[i]:t.const=i}else o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),o.every(i=>typeof i=="boolean")&&(t.type="boolean"),o.every(i=>i===null)&&(t.type="null"),t.enum=o},oW=(n,e,t,s)=>{Mo(n,e,t,s,"Custom types cannot be represented in JSON Schema")},iW=(n,e,t,s)=>{Mo(n,e,t,s,"Transforms cannot be represented in JSON Schema")},aW=(n,e,t,s)=>{const r=t,o=n._zod.def,{minimum:i,maximum:l}=Ws(n);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=pn(o.element,e,{...s,path:[...s.path,"items"]})};function qd(n){const e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?qd(e.out):e.type==="catch"?qd(e.innerType):n._zod.optin}const lW=(n,e,t,s)=>{var u;const r=t,o=n._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Mo(n,e,r,s,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const d in i)co(r.properties,d,pn(i[d],e,{...s,path:[...s.path,"properties",d]}));const c=[];for(const d of Object.keys(i)){const f=o.shape[d];(e.io==="input"?qd(f)===void 0:f._zod.optout===void 0)&&c.push(d)}c.length>0&&(r.required=c),((u=o.catchall)==null?void 0:u._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=pn(o.catchall,e,{...s,path:[...s.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},cW=(n,e,t,s)=>{const r=n._zod.def,o=r.inclusive===!1,i=r.options.map((l,c)=>pn(l,e,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?t.oneOf=i:t.anyOf=i},uW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.left,e,{...s,path:[...s.path,"allOf",0]}),i=pn(r.right,e,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(o)?o.allOf:[o],...l(i)?i.allOf:[i]];t.allOf=c,e.intersections.push(c)};function Hg(n,e,t){var h;if(e.$ref){if(t.has(e))return e;t.add(e);const g=(h=n.get(e))==null?void 0:h.def;if(!g)return e;const x=Hg(n,g,t);return x===g?e:x}for(const g of["anyOf","oneOf"]){const x=e[g];if(!Array.isArray(x))continue;const b=x.map(w=>Hg(n,w,t));b.some((w,v)=>w!==x[v])&&(e={...e,[g]:b})}const s=Array.isArray(e.type)?e.type:[e.type],r=!s.includes("string")&&s.some(g=>g==="number"||g==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!(o!=null&&o.some(g=>typeof g=="number")))return e;const{minimum:i,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:f,id:m,...p}=e;return p.enum?p.enum=p.enum.map(g=>typeof g=="number"?String(g):g):typeof p.const=="number"&&(p.const=String(p.const)),r&&(p.type="string",o||(p.pattern=(s.includes("number")?x0:xF).source)),p}const Kg=new WeakMap;function dW(n){var s;const e=new Map;for(const r of n.seen.values())r.def&&!e.has(r.schema)&&e.set(r.schema,r);const t=new Map;for(const r of Kg.get(n)??[]){const o=n.seen.get(r),i=(s=(o==null?void 0:o.def)??(o==null?void 0:o.schema))==null?void 0:s.propertyNames;if(!i||i===!0||t.has(i))continue;const l=Hg(e,i,new Set);l!==i&&t.set(i,l)}if(t.size)for(const r of n.seen.values())for(const o of[r.schema,r.def]){const i=o&&t.get(o.propertyNames);i&&(o.propertyNames=i)}}const fW=(n,e,t,s)=>{const r=t,o=n._zod.def;r.type="object";const i=o.keyType,l=Ws(i).patterns;if(o.mode==="loose"&&l&&l.size>0){const d=pn(o.valueType,e,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)co(r.patternProperties,SC(f).source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){r.propertyNames=pn(o.keyType,e,{...s,path:[...s.path,"propertyNames"]});let d=Kg.get(e);d||(d=[],Kg.set(e,d),e.deferred.push(()=>dW(e))),d.push(n)}r.additionalProperties=pn(o.valueType,e,{...s,path:[...s.path,"additionalProperties"]})}const c=i._zod.values,u=e.io==="input"&&qd(o.valueType)!==void 0;if(c&&!o.partial&&!u){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(r.required=d.map(String))}},mW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.innerType,e,s),i=e.seen.get(n);e.target==="openapi-3.0"?(i.ref=r.innerType,t.nullable=!0):t.anyOf=[o,{type:"null"}]},pW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},w0=Symbol();function kC(n,e,t,s,r){let o=!1;const i=JSON.stringify(n,(l,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Mo(e,t,s,r,"BigInt defaults cannot be represented in JSON Schema"),w0):JSON.parse(i)}const hW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;const i=kC(r.defaultValue,n,e,t,s);i!==w0&&(t.default=i)},gW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);if(o.ref=r.innerType,e.io!=="input")return;const i=kC(r.defaultValue,n,e,t,s);i!==w0&&(t._prefault=i)},xW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{Mo(n,e,t,s,"Dynamic catch values are not supported in JSON Schema");return}t.default=i},bW=(n,e,t,s)=>{const r=n._zod.def,o=r.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?o?r.out:r.in:r.out;pn(i,e,s);const l=e.seen.get(n);l.ref=i},vW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType,t.readOnly=!0},jC=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},q2=new WeakSet([Object.prototype,Error.prototype]);function wu(n,e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){const s=t(this);return Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0})}})}const yW=(n,e)=>{TD.init(n,e),n.name="ZodError";const t=Object.getPrototypeOf(n);q2.has(t)||(q2.add(t),wu(t,"format",s=>r=>PD(s,r)),wu(t,"flatten",s=>r=>ID(s,r)),wu(t,"addIssue",s=>r=>{s.issues.push(r),s.message=JSON.stringify(s.issues,Fg,2)}),wu(t,"addIssues",s=>r=>{s.issues.push(...r),s.message=JSON.stringify(s.issues,Fg,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ts=he("ZodError",yW,void 0,{Parent:Error}),wW=m0(Ts),SW=p0(Ts),kW=h0(Ts),jW=g0(Ts),NW=zD(Ts),CW=DD(Ts),_W=FD(Ts),EW=UD(Ts),TW=BD(Ts),AW=WD(Ts),IW=qD(Ts),PW=VD(Ts);function $W(){Qs.localeError||Tr(ZU())}function Zf(){Qs.memoizer||Tr({memoizer:HU()})}const qt=he("ZodType",(n,e)=>($W(),Bt.init(n,e),n.def=e,n.type=e.type,n),{check(...n){const e=this.def;return this.clone(hs(e,{checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,e){return Ho(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(Eq(n,e))},superRefine(n,e){return this.check(Tq(n,e))},overwrite(n){return this.check(Ma(n))},optional(){return K2(this)},exactOptional(){return gq(this)},nullable(){return G2(this)},nullish(){return K2(G2(this))},nonoptional(n){return Sq(this,n)},array(){return at(this)},or(n){return to([this,n])},and(n){return fq(this,n)},transform(n){return Z2(this,hq(n))},default(n){return vq(this,n)},prefault(n){return wq(this,n)},catch(n){return jq(this,n)},pipe(n){return Z2(this,n)},readonly(){return _q(this)},describe(n){const e=this.clone();return ol.add(e,{description:n}),e},meta(...n){if(n.length===0)return ol.get(this);const e=this.clone();return ol.add(e,n[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n,...e){return e.length===0?n(this):n(this,...e)},get"~standard"(){return W5(this,"~standard",{...X5(this),jsonSchema:{input:Wd(this,"input"),output:Wd(this,"output")}})},set"~standard"(n){Lo(this,"~standard",n)},parse:function n(e,t){return wW(this,e,t,{callee:n})},parseAsync:async function n(e,t){return await SW(this,e,t,{callee:n})},safeParse(n,e){return kW(this,n,e)},async safeParseAsync(n,e){return jW(this,n,e)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(n){Lo(this,"spa",n)},validate(n,e){return OD(this,n,e)},validateAsync(n,e){return MD(this,n,e)},encode:function n(e,t){return NW(this,e,t,{callee:n})},decode:function n(e,t){return CW(this,e,t,{callee:n})},encodeAsync:async function n(e,t){return await _W(this,e,t,{callee:n})},decodeAsync:async function n(e,t){return await EW(this,e,t,{callee:n})},safeEncode(n,e){return TW(this,n,e)},safeDecode(n,e){return AW(this,n,e)},async safeEncodeAsync(n,e){return IW(this,n,e)},async safeDecodeAsync(n,e){return PW(this,n,e)},toJSONSchema(n){return GB(this,{})(n)},get description(){var n;return(n=ol.get(this))==null?void 0:n.description},get _def(){return this._zod.def}}),NC=he("_ZodString",(n,e)=>{v0.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>XB(n,t,s)},q5({format:n=>Ws(n).format??null,minLength:n=>Ws(n).minimum??null,maxLength:n=>Ws(n).maximum??null},{regex(...n){return this.check(IB(...n))},includes(...n){return this.check(RB(...n))},startsWith(...n){return this.check(OB(...n))},endsWith(...n){return this.check(LB(...n))},min(...n){return this.check(Bd(...n))},max(...n){return this.check(dC(...n))},length(...n){return this.check(fC(...n))},nonempty(...n){return this.check(Bd(1,...n))},lowercase(n){return this.check(PB(n))},uppercase(n){return this.check($B(n))},trim(){return this.check(zB())},normalize(...n){return this.check(MB(...n))},toLowerCase(){return this.check(DB())},toUpperCase(){return this.check(FB())},slugify(){return this.check(UB())}})),RW=he("ZodString",(n,e)=>{v0.init(n,e),NC.init(n,e)},{email(n){return this.check(QU(DW,n))},url(n){return this.check(oB(UW,n))},jwt(n){return this.check(yB(nq,n))},emoji(n){return this.check(iB(BW,n))},guid(n){return this.check(eB(FW,n))},uuid(n){return this.check(tB(Su,n))},uuidv4(n){return this.check(nB(Su,n))},uuidv6(n){return this.check(sB(Su,n))},uuidv7(n){return this.check(rB(Su,n))},nanoid(n){return this.check(aB(WW,n))},cuid(n){return this.check(lB(qW,n))},cuid2(n){return this.check(cB(VW,n))},ulid(n){return this.check(uB(HW,n))},base64(n){return this.check(xB(QW,n))},base64url(n){return this.check(bB(eq,n))},xid(n){return this.check(dB(KW,n))},ksuid(n){return this.check(fB(GW,n))},ipv4(n){return this.check(mB(ZW,n))},ipv6(n){return this.check(pB(YW,n))},cidrv4(n){return this.check(hB(XW,n))},cidrv6(n){return this.check(gB(JW,n))},e164(n){return this.check(vB(tq,n))},datetime(n){return this.check(wB(OW,n))},date(n){return this.check(SB(LW,n))},time(n){return this.check(kB(MW,n))},duration(n){return this.check(jB(zW,n))}});function Le(n){return JU(RW,n)}const Jt=he("ZodStringFormat",(n,e)=>{Wt.init(n,e),NC.init(n,e)}),OW=he("ZodISODateTime",(n,e)=>{QF.init(n,e),Jt.init(n,e)}),LW=he("ZodISODate",(n,e)=>{eU.init(n,e),Jt.init(n,e)}),MW=he("ZodISOTime",(n,e)=>{tU.init(n,e),Jt.init(n,e)}),zW=he("ZodISODuration",(n,e)=>{nU.init(n,e),Jt.init(n,e)}),DW=he("ZodEmail",(n,e)=>{DF.init(n,e),Jt.init(n,e)}),FW=he("ZodGUID",(n,e)=>{MF.init(n,e),Jt.init(n,e)}),Su=he("ZodUUID",(n,e)=>{zF.init(n,e),Jt.init(n,e)}),UW=he("ZodURL",(n,e)=>{VF.init(n,e),Jt.init(n,e)}),BW=he("ZodEmoji",(n,e)=>{HF.init(n,e),Jt.init(n,e)}),WW=he("ZodNanoID",(n,e)=>{KF.init(n,e),Jt.init(n,e)}),qW=he("ZodCUID",(n,e)=>{GF.init(n,e),Jt.init(n,e)}),VW=he("ZodCUID2",(n,e)=>{ZF.init(n,e),Jt.init(n,e)}),HW=he("ZodULID",(n,e)=>{YF.init(n,e),Jt.init(n,e)}),KW=he("ZodXID",(n,e)=>{XF.init(n,e),Jt.init(n,e)}),GW=he("ZodKSUID",(n,e)=>{JF.init(n,e),Jt.init(n,e)}),ZW=he("ZodIPv4",(n,e)=>{sU.init(n,e),Jt.init(n,e)}),YW=he("ZodIPv6",(n,e)=>{oU.init(n,e),Jt.init(n,e)}),XW=he("ZodCIDRv4",(n,e)=>{iU.init(n,e),Jt.init(n,e)}),JW=he("ZodCIDRv6",(n,e)=>{lU.init(n,e),Jt.init(n,e)}),QW=he("ZodBase64",(n,e)=>{cU.init(n,e),Jt.init(n,e)}),eq=he("ZodBase64URL",(n,e)=>{dU.init(n,e),Jt.init(n,e)}),tq=he("ZodE164",(n,e)=>{fU.init(n,e),Jt.init(n,e)}),nq=he("ZodJWT",(n,e)=>{pU.init(n,e),Jt.init(n,e)}),CC=he("ZodNumber",(n,e)=>{sC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>JB(n,t,s,r),n.isFinite=!0},q5({minValue:n=>{const{minimum:e,exclusiveMinimum:t}=Ws(n);return Math.max(e??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:n=>{const{maximum:e,exclusiveMaximum:t}=Ws(n);return Math.min(e??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:n=>{const{isInt:e,multipleOf:t}=Ws(n);return!!e||!!(t!=null&&t.some(Number.isSafeInteger))},format:n=>Ws(n).format??null},{gt(n,e){return this.check(O2(n,e))},gte(n,e){return this.check(sp(n,e))},min(n,e){return this.check(sp(n,e))},lt(n,e){return this.check(R2(n,e))},lte(n,e){return this.check(np(n,e))},max(n,e){return this.check(np(n,e))},int(n){return this.check(V2(n))},safe(n){return this.check(V2(n))},positive(n){return this.check(O2(0,n))},nonnegative(n){return this.check(sp(0,n))},negative(n){return this.check(R2(0,n))},nonpositive(n){return this.check(np(0,n))},multipleOf(n,e){return this.check(L2(n,e))},step(n,e){return this.check(L2(n,e))},finite(){return this}}));function bt(n){return NB(CC,n)}const sq=he("ZodNumberFormat",(n,e)=>{hU.init(n,e),CC.init(n,e)});function V2(n){return CB(sq,n)}const rq=he("ZodBoolean",(n,e)=>{gU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>QB(n,t,s)});function Ft(n){return _B(rq,n)}const oq=he("ZodNull",(n,e)=>{xU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>eW(n,t,s)});function _C(n){return EB(oq,n)}const iq=he("ZodUnknown",(n,e)=>{bU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>nW()});function eo(){return TB(iq)}const aq=he("ZodNever",(n,e)=>{vU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>tW(n,t,s)});function EC(n){return AB(aq,n)}const lq=he("ZodArray",(n,e)=>{Zf(),SU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>aW(n,t,s,r),n.element=e.element},{min(n,e){return this.check(Bd(n,e))},nonempty(n){return this.check(Bd(1,n))},max(n,e){return this.check(dC(n,e))},length(n,e){return this.check(fC(n,e))},unwrap(){return this.element}});function at(n,e){return BB(lq,n,e)}const TC=he("ZodObject",(n,e)=>{Zf(),NU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>lW(n,t,s,r),wD(n,"shape",t=>t._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(n){return this.clone(hs(this._zod.def,{catchall:n}))},passthrough(){return this.clone(hs(this._zod.def,{catchall:eo()}))},loose(){return this.clone(hs(this._zod.def,{catchall:eo()}))},strict(){return this.clone(hs(this._zod.def,{catchall:EC()}))},strip(){return this.clone(hs(this._zod.def,{catchall:void 0}))},extend(n){return uD(this,n)},safeExtend(n){return dD(this,n)},merge(n){return fD(this,n)},pick(n){return lD(this,n)},omit(n){return cD(this,n)},partial(...n){return g2(IC,this,n[0])},exactPartial(...n){return g2(PC,this,n[0],"exactPartial")},required(...n){return mD($C,this,n[0])}});function cq(n,e){const t={type:"object",shape:n??{},...Ye(e)};return new TC(t)}function xe(n,e){return new TC({type:"object",shape:n,catchall:EC(),...Ye(e)})}const AC=he("ZodUnion",(n,e)=>{iC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>cW(n,t,s,r),n.options=e.options});function to(n,e){return new AC({type:"union",options:n,...Ye(e)})}const uq=he("ZodDiscriminatedUnion",(n,e)=>{AC.init(n,e),_U.init(n,e)});function Rr(n,e,t){return new uq({type:"union",options:e,discriminator:n,...Ye(t)})}const dq=he("ZodIntersection",(n,e)=>{EU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>uW(n,t,s,r)});function fq(n,e){return new dq({type:"intersection",left:n,right:e})}const H2=he("ZodRecord",(n,e)=>{Zf(),TU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>fW(n,t,s,r),n.keyType=e.keyType,n.valueType=e.valueType});function Xn(n,e,t){return!e||!e._zod?new H2({type:"record",keyType:Le(),valueType:n,...Ye(e)}):new H2({type:"record",keyType:n,valueType:e,...Ye(t)})}const Gg=he("ZodEnum",(n,e)=>{AU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(s,r,o)=>sW(n,s,r),n.enum=e.entries,n.options=[...n._zod.values];const t=new Set(Object.keys(e.entries));n.extract=(s,r)=>{const o={};for(const i of s)if(t.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Gg({...e,checks:[],...Ye(r),entries:o})},n.exclude=(s,r)=>{const o={...e.entries};for(const i of s)if(t.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Gg({...e,checks:[],...Ye(r),entries:o})}});function Ct(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new Gg({type:"enum",entries:t,...Ye(e)})}const mq=he("ZodLiteral",(n,e)=>{IU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>rW(n,t,s,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ze(n,e){return new mq({type:"literal",values:Array.isArray(n)?n:[n],...Ye(e)})}const pq=he("ZodTransform",(n,e)=>{Zf(),PU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>iW(n,t,s,r),n._zod.parse=(t,s)=>{if(s.direction==="backward")throw new V5(n.constructor.name);t.addIssue=o=>{if(typeof o=="string")t.issues.push(sc(o,t.value,e));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=t.value),i.inst??(i.inst=n),t.issues.push(sc(i))}};const r=e.transform(t.value,t);return r instanceof Promise?r.then(o=>(t.value=o,t)):(t.value=r,t)}});function hq(n){return new pq({type:"transform",transform:n})}const IC=he("ZodOptional",(n,e)=>{aC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>jC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function K2(n){return new IC({type:"optional",innerType:n})}const PC=he("ZodExactOptional",(n,e)=>{$U.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>jC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function gq(n){return new PC({type:"optional",innerType:n})}const xq=he("ZodNullable",(n,e)=>{RU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>mW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function G2(n){return new xq({type:"nullable",innerType:n})}const bq=he("ZodDefault",(n,e)=>{OU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>hW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function vq(n,e){return new bq({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():D5(e)}})}const yq=he("ZodPrefault",(n,e)=>{LU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>gW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function wq(n,e){return new yq({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():D5(e)}})}const $C=he("ZodNonOptional",(n,e)=>{MU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>pW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function Sq(n,e){return new $C({type:"nonoptional",innerType:n,...Ye(e)})}const kq=he("ZodCatch",(n,e)=>{zU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>xW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function jq(n,e){return new kq({type:"catch",innerType:n,catchValue:typeof e=="function"?e:kD(e)})}const Nq=he("ZodPipe",(n,e)=>{DU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>bW(n,t,s,r),n.in=e.in,n.out=e.out});function Z2(n,e){return new Nq({type:"pipe",in:n,out:e})}const Cq=he("ZodReadonly",(n,e)=>{FU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>vW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function _q(n){return new Cq({type:"readonly",innerType:n})}const RC=he("ZodCustom",(n,e)=>{UU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>oW(n,t,s,r)});function OC(n,e){return WB(RC,n??(()=>!0),e)}function Eq(n,e={}){return qB(RC,n,e)}function Tq(n,e){return VB(n,e)}var ku={exports:{}},op,Y2;function Lc(){if(Y2)return op;Y2=1;const n="2.0.0",e=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,r=e-6;return op={MAX_LENGTH:e,MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:r,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:n,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},op}var ip,X2;function Yf(){if(X2)return ip;X2=1;var n={};return ip=typeof process=="object"&&n&&n.NODE_DEBUG&&/\bsemver\b/i.test(n.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{},ip}var J2;function Mc(){return J2||(J2=1,(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:r}=Lc(),o=Yf();e=n.exports={};const i=e.re=[],l=e.safeRe=[],c=e.src=[],u=e.safeSrc=[],d=e.t={};let f=0;const m="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",r],[m,s]],h=x=>{for(const[b,w]of p)x=x.split(`${b}*`).join(`${b}{0,${w}}`).split(`${b}+`).join(`${b}{1,${w}}`);return x},g=(x,b,w)=>{const v=h(b),j=f++;o(x,j,b),d[x]=j,c[j]=b,u[j]=v,i[j]=new RegExp(b,w?"g":void 0),l[j]=new RegExp(v,w?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m}*`),g("MAINVERSION",`(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASE",`(?:-(${c[d.PRERELEASEIDENTIFIER]}(?:\\.${c[d.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${c[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[d.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${m}+`),g("BUILD",`(?:\\+(${c[d.BUILDIDENTIFIER]}(?:\\.${c[d.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${c[d.MAINVERSION]}${c[d.PRERELEASE]}?${c[d.BUILD]}?`),g("FULL",`^${c[d.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${c[d.MAINVERSIONLOOSE]}${c[d.PRERELEASELOOSE]}?${c[d.BUILD]}?`),g("LOOSE",`^${c[d.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${c[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${c[d.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:${c[d.PRERELEASE]})?${c[d.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:${c[d.PRERELEASELOOSE]})?${c[d.BUILD]}?)?)?`),g("XRANGE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAINLOOSE]}$`),g("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),g("COERCE",`${c[d.COERCEPLAIN]}(?:$|[^\\d])`),g("COERCEFULL",c[d.COERCEPLAIN]+`(?:${c[d.PRERELEASE]})?(?:${c[d.BUILD]})?(?:$|[^\\d])`),g("COERCERTL",c[d.COERCE],!0),g("COERCERTLFULL",c[d.COERCEFULL],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${c[d.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",g("TILDE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${c[d.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",g("CARET",`^${c[d.LONECARET]}${c[d.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${c[d.LONECARET]}${c[d.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${c[d.GTLT]}\\s*(${c[d.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]}|${c[d.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${c[d.XRANGEPLAIN]})\\s+-\\s+(${c[d.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${c[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[d.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(ku,ku.exports)),ku.exports}var ap,Q2;function S0(){if(Q2)return ap;Q2=1;const n=Object.freeze({loose:!0}),e=Object.freeze({});return ap=s=>s?typeof s!="object"?n:s:e,ap}var lp,ew;function LC(){if(ew)return lp;ew=1;const n=/^[0-9]+$/,e=(s,r)=>{if(typeof s=="number"&&typeof r=="number")return s===r?0:s<r?-1:1;const o=n.test(s),i=n.test(r);return o&&i&&(s=+s,r=+r),s===r?0:o&&!i?-1:i&&!o?1:s<r?-1:1};return lp={compareIdentifiers:e,rcompareIdentifiers:(s,r)=>e(r,s)},lp}var cp,tw;function Wn(){if(tw)return cp;tw=1;const n=Yf(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:t}=Lc(),{safeRe:s,t:r}=Mc(),o=S0(),{compareIdentifiers:i}=LC(),l=(u,d)=>{const f=d.split(".");if(f.length>u.length)return!1;for(let m=0;m<f.length;m++)if(i(u[m],f[m])!==0)return!1;return!0};class c{constructor(d,f){if(f=o(f),d instanceof c){if(d.loose===!!f.loose&&d.includePrerelease===!!f.includePrerelease)return d;d=d.version}else if(typeof d!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof d}".`);if(d.length>e)throw new TypeError(`version is longer than ${e} characters`);n("SemVer",d,f),this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease;const m=d.trim().match(f.loose?s[r.LOOSE]:s[r.FULL]);if(!m)throw new TypeError(`Invalid Version: ${d}`);if(this.raw=d,this.major=+m[1],this.minor=+m[2],this.patch=+m[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");m[4]?this.prerelease=m[4].split(".").map(p=>{if(/^[0-9]+$/.test(p)){const h=+p;if(h>=0&&h<t)return h}return p}):this.prerelease=[],this.build=m[5]?m[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(d){if(n("SemVer.compare",this.version,this.options,d),!(d instanceof c)){if(typeof d=="string"&&d===this.version)return 0;d=new c(d,this.options)}return d.version===this.version?0:this.compareMain(d)||this.comparePre(d)}compareMain(d){return d instanceof c||(d=new c(d,this.options)),this.major<d.major?-1:this.major>d.major?1:this.minor<d.minor?-1:this.minor>d.minor?1:this.patch<d.patch?-1:this.patch>d.patch?1:0}comparePre(d){if(d instanceof c||(d=new c(d,this.options)),this.prerelease.length&&!d.prerelease.length)return-1;if(!this.prerelease.length&&d.prerelease.length)return 1;if(!this.prerelease.length&&!d.prerelease.length)return 0;let f=0;do{const m=this.prerelease[f],p=d.prerelease[f];if(n("prerelease compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}compareBuild(d){d instanceof c||(d=new c(d,this.options));let f=0;do{const m=this.build[f],p=d.build[f];if(n("build compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}inc(d,f,m){if(d.startsWith("pre")){if(!f&&m===!1)throw new Error("invalid increment argument: identifier is empty");if(f){const p=`-${f}`.match(this.options.loose?s[r.PRERELEASELOOSE]:s[r.PRERELEASE]);if(!p||p[1]!==f)throw new Error(`invalid identifier: ${f}`)}}switch(d){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",f,m);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",f,m);break;case"prepatch":this.prerelease.length=0,this.inc("patch",f,m),this.inc("pre",f,m);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",f,m),this.inc("pre",f,m);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const p=Number(m)?1:0;if(this.prerelease.length===0)this.prerelease=[p];else{let h=this.prerelease.length;for(;--h>=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(f===this.prerelease.join(".")&&m===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(p)}}if(f){let h=[f,p];if(m===!1&&(h=[f]),l(this.prerelease,f)){const g=this.prerelease[f.split(".").length];isNaN(g)&&(this.prerelease=h)}else this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${d}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return cp=c,cp}var up,nw;function wi(){if(nw)return up;nw=1;const n=Wn();return up=(t,s,r=!1)=>{if(t instanceof n)return t;try{return new n(t,s)}catch(o){if(!r)return null;throw o}},up}var dp,sw;function Aq(){if(sw)return dp;sw=1;const n=wi();return dp=(t,s)=>{const r=n(t,s);return r?r.version:null},dp}var fp,rw;function Iq(){if(rw)return fp;rw=1;const n=wi();return fp=(t,s)=>{const r=n(t.trim().replace(/^[=v]+/,""),s);return r?r.version:null},fp}var mp,ow;function Pq(){if(ow)return mp;ow=1;const n=Wn();return mp=(t,s,r,o,i)=>{typeof r=="string"&&(i=o,o=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(s,o,i).version}catch{return null}},mp}var pp,iw;function $q(){if(iw)return pp;iw=1;const n=wi();return pp=(t,s)=>{const r=n(t,null,!0),o=n(s,null,!0),i=r.compare(o);if(i===0)return null;const l=i>0,c=l?r:o,u=l?o:r,d=!!c.prerelease.length;if(!!u.prerelease.length&&!d){if(!u.patch&&!u.minor)return"major";if(u.compareMain(c)===0)return u.minor&&!u.patch?"minor":"patch"}const m=d?"pre":"";return r.major!==o.major?m+"major":r.minor!==o.minor?m+"minor":r.patch!==o.patch?m+"patch":"prerelease"},pp}var hp,aw;function Rq(){if(aw)return hp;aw=1;const n=Wn();return hp=(t,s)=>new n(t,s).major,hp}var gp,lw;function Oq(){if(lw)return gp;lw=1;const n=Wn();return gp=(t,s)=>new n(t,s).minor,gp}var xp,cw;function Lq(){if(cw)return xp;cw=1;const n=Wn();return xp=(t,s)=>new n(t,s).patch,xp}var bp,uw;function Mq(){if(uw)return bp;uw=1;const n=wi();return bp=(t,s)=>{const r=n(t,s);return r&&r.prerelease.length?r.prerelease:null},bp}var vp,dw;function lr(){if(dw)return vp;dw=1;const n=Wn();return vp=(t,s,r)=>new n(t,r).compare(new n(s,r)),vp}var yp,fw;function zq(){if(fw)return yp;fw=1;const n=lr();return yp=(t,s,r)=>n(s,t,r),yp}var wp,mw;function Dq(){if(mw)return wp;mw=1;const n=lr();return wp=(t,s)=>n(t,s,!0),wp}var Sp,pw;function k0(){if(pw)return Sp;pw=1;const n=Wn();return Sp=(t,s,r)=>{const o=new n(t,r),i=new n(s,r);return o.compare(i)||o.compareBuild(i)},Sp}var kp,hw;function Fq(){if(hw)return kp;hw=1;const n=k0();return kp=(t,s)=>t.sort((r,o)=>n(r,o,s)),kp}var jp,gw;function Uq(){if(gw)return jp;gw=1;const n=k0();return jp=(t,s)=>t.sort((r,o)=>n(o,r,s)),jp}var Np,xw;function Xf(){if(xw)return Np;xw=1;const n=lr();return Np=(t,s,r)=>n(t,s,r)>0,Np}var Cp,bw;function j0(){if(bw)return Cp;bw=1;const n=lr();return Cp=(t,s,r)=>n(t,s,r)<0,Cp}var _p,vw;function MC(){if(vw)return _p;vw=1;const n=lr();return _p=(t,s,r)=>n(t,s,r)===0,_p}var Ep,yw;function zC(){if(yw)return Ep;yw=1;const n=lr();return Ep=(t,s,r)=>n(t,s,r)!==0,Ep}var Tp,ww;function N0(){if(ww)return Tp;ww=1;const n=lr();return Tp=(t,s,r)=>n(t,s,r)>=0,Tp}var Ap,Sw;function C0(){if(Sw)return Ap;Sw=1;const n=lr();return Ap=(t,s,r)=>n(t,s,r)<=0,Ap}var Ip,kw;function DC(){if(kw)return Ip;kw=1;const n=MC(),e=zC(),t=Xf(),s=N0(),r=j0(),o=C0();return Ip=(l,c,u,d)=>{switch(c){case"===":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l===u;case"!==":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l!==u;case"":case"=":case"==":return n(l,u,d);case"!=":return e(l,u,d);case">":return t(l,u,d);case">=":return s(l,u,d);case"<":return r(l,u,d);case"<=":return o(l,u,d);default:throw new TypeError(`Invalid operator: ${c}`)}},Ip}var Pp,jw;function Bq(){if(jw)return Pp;jw=1;const n=Wn(),e=wi(),{safeRe:t,t:s}=Mc();return Pp=(o,i)=>{if(o instanceof n)return o;if(typeof o=="number"&&(o=String(o)),typeof o!="string")return null;i=i||{};let l=null;if(!i.rtl)l=o.match(i.includePrerelease?t[s.COERCEFULL]:t[s.COERCE]);else{const p=i.includePrerelease?t[s.COERCERTLFULL]:t[s.COERCERTL];let h;for(;(h=p.exec(o))&&(!l||l.index+l[0].length!==o.length);)(!l||h.index+h[0].length!==l.index+l[0].length)&&(l=h),p.lastIndex=h.index+h[1].length+h[2].length;p.lastIndex=-1}if(l===null)return null;const c=l[2],u=l[3]||"0",d=l[4]||"0",f=i.includePrerelease&&l[5]?`-${l[5]}`:"",m=i.includePrerelease&&l[6]?`+${l[6]}`:"";return e(`${c}.${u}.${d}${f}${m}`,i)},Pp}var $p,Nw;function Wq(){if(Nw)return $p;Nw=1;const n=wi(),e=Lc(),t=Wn(),s=(l,c,u)=>{if(!e.RELEASE_TYPES.includes(c))return null;const d=r(l,u);return d&&o(d,c)},r=(l,c)=>{const u=l instanceof t?l.version:l;return n(u,c)},o=(l,c)=>{if(i(c))return l.version;switch(l.prerelease=[],c){case"major":l.minor=0,l.patch=0;break;case"minor":l.patch=0;break}return l.format()},i=l=>l.startsWith("pre");return $p=s,$p}var Rp,Cw;function qq(){if(Cw)return Rp;Cw=1;class n{constructor(){this.max=1e3,this.map=new Map}get(t){const s=this.map.get(t);if(s!==void 0)return this.map.delete(t),this.map.set(t,s),s}delete(t){return this.map.delete(t)}set(t,s){if(!this.delete(t)&&s!==void 0){if(this.map.size>=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(t,s)}return this}}return Rp=n,Rp}var Op,_w;function cr(){if(_w)return Op;_w=1;const n=/\s+/g;class e{constructor(I,M){if(M=r(M),I instanceof e)return I.loose===!!M.loose&&I.includePrerelease===!!M.includePrerelease?I:new e(I.raw,M);if(I instanceof o)return this.raw=I.value,this.set=[[I]],this.formatted=void 0,this;if(this.options=M,this.loose=!!M.loose,this.includePrerelease=!!M.includePrerelease,this.raw=I.trim().replace(n," "),this.set=this.raw.split("||").map(F=>this.parseRange(F.trim())).filter(F=>F.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const F=this.set[0];if(this.set=this.set.filter(U=>!b(U[0])),this.set.length===0)this.set=[F];else if(this.set.length>1){for(const U of this.set)if(U.length===1&&w(U[0])){this.set=[U];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let I=0;I<this.set.length;I++){I>0&&(this.formatted+="||");const M=this.set[I];for(let F=0;F<M.length;F++)F>0&&(this.formatted+=" "),this.formatted+=M[F].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(I){I=I.replace(x,"");const F=((this.options.includePrerelease&&h)|(this.options.loose&&g))+":"+I,U=s.get(F);if(U)return U;const O=this.options.loose,D=O?c[d.HYPHENRANGELOOSE]:c[d.HYPHENRANGE];I=I.replace(D,P(this.options.includePrerelease)),i("hyphen replace",I),I=I.replace(c[d.COMPARATORTRIM],f),i("comparator trim",I),I=I.replace(c[d.TILDETRIM],m),i("tilde trim",I),I=I.replace(c[d.CARETTRIM],p),i("caret trim",I);let B=I.split(" ").map(K=>j(K,this.options)).join(" ").split(/\s+/).map(K=>R(K,this.options));O&&(B=B.filter(K=>(i("loose invalid filter",K,this.options),!!K.match(c[d.COMPARATORLOOSE])))),i("range list",B);const q=new Map,W=B.map(K=>new o(K,this.options));for(const K of W){if(b(K))return[K];q.set(K.value,K)}q.size>1&&q.has("")&&q.delete("");const H=[...q.values()];return s.set(F,H),H}intersects(I,M){if(!(I instanceof e))throw new TypeError("a Range is required");return this.set.some(F=>v(F,M)&&I.set.some(U=>v(U,M)&&F.every(O=>U.every(D=>O.intersects(D,M)))))}test(I){if(!I)return!1;if(typeof I=="string")try{I=new l(I,this.options)}catch{return!1}for(let M=0;M<this.set.length;M++)if(z(this.set[M],I,this.options))return!0;return!1}}Op=e;const t=qq(),s=new t,r=S0(),o=Jf(),i=Yf(),l=Wn(),{safeRe:c,src:u,t:d,comparatorTrimReplace:f,tildeTrimReplace:m,caretTrimReplace:p}=Mc(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:g}=Lc(),x=new RegExp(u[d.BUILD],"g"),b=L=>L.value==="<0.0.0-0",w=L=>L.value==="",v=(L,I)=>{let M=!0;const F=L.slice();let U=F.pop();for(;M&&F.length;)M=F.every(O=>U.intersects(O,I)),U=F.pop();return M},j=(L,I)=>(L=L.replace(c[d.BUILD],""),i("comp",L,I),L=C(L,I),i("caret",L),L=N(L,I),i("tildes",L),L=T(L,I),i("xrange",L),L=A(L,I),i("stars",L),L),k=L=>!L||L.toLowerCase()==="x"||L==="*",_=(L,I,M)=>k(L)&&!k(I)||k(I)&&M&&!k(M),N=(L,I)=>L.trim().split(/\s+/).map(M=>S(M,I)).join(" "),S=(L,I)=>{const M=I.loose?c[d.TILDELOOSE]:c[d.TILDE],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("tilde",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:q?(i("replaceTilde pr",q),W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`):W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`,i("tilde return",W),W})},C=(L,I)=>L.trim().split(/\s+/).map(M=>E(M,I)).join(" "),E=(L,I)=>{i("caret",L,I);const M=I.loose?c[d.CARETLOOSE]:c[d.CARET],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("caret",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?O==="0"?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.0${F} <${+O+1}.0.0-0`:q?(i("replaceCaret pr",q),O==="0"?D==="0"?W=`>=${O}.${D}.${B}-${q} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B}-${q} <${+O+1}.0.0-0`):(i("no pr"),O==="0"?D==="0"?W=`>=${O}.${D}.${B} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B} <${+O+1}.0.0-0`),i("caret return",W),W})},T=(L,I)=>(i("replaceXRanges",L,I),L.split(/\s+/).map(M=>$(M,I)).join(" ")),$=(L,I)=>{L=L.trim();const M=I.loose?c[d.XRANGELOOSE]:c[d.XRANGE];return L.replace(M,(F,U,O,D,B,q)=>{if(i("xRange",L,F,U,O,D,B,q),_(O,D,B))return L;const W=k(O),H=W||k(D),K=H||k(B),Z=K;return U==="="&&Z&&(U=""),q=I.includePrerelease?"-0":"",W?U===">"||U==="<"?F="<0.0.0-0":F="*":U&&Z?(H&&(D=0),B=0,U===">"?(U=">=",H?(O=+O+1,D=0,B=0):(D=+D+1,B=0)):U==="<="&&(U="<",H?O=+O+1:D=+D+1),U==="<"&&(q="-0"),F=`${U+O}.${D}.${B}${q}`):H?F=`>=${O}.0.0${q} <${+O+1}.0.0-0`:K&&(F=`>=${O}.${D}.0${q} <${O}.${+D+1}.0-0`),i("xRange return",F),F})},A=(L,I)=>(i("replaceStars",L,I),L.trim().replace(c[d.STAR],"")),R=(L,I)=>(i("replaceGTE0",L,I),L.trim().replace(c[I.includePrerelease?d.GTE0PRE:d.GTE0],"")),P=L=>(I,M,F,U,O,D,B,q,W,H,K,Z)=>(k(F)?M="":k(U)?M=`>=${F}.0.0${L?"-0":""}`:k(O)?M=`>=${F}.${U}.0${L?"-0":""}`:D?M=`>=${M}`:M=`>=${M}${L?"-0":""}`,k(W)?q="":k(H)?q=`<${+W+1}.0.0-0`:k(K)?q=`<${W}.${+H+1}.0-0`:Z?q=`<=${W}.${H}.${K}-${Z}`:L?q=`<${W}.${H}.${+K+1}-0`:q=`<=${q}`,`${M} ${q}`.trim()),z=(L,I,M)=>{for(let F=0;F<L.length;F++)if(!L[F].test(I))return!1;if(I.prerelease.length&&!M.includePrerelease){for(let F=0;F<L.length;F++)if(i(L[F].semver),L[F].semver!==o.ANY&&L[F].semver.prerelease.length>0){const U=L[F].semver;if(U.major===I.major&&U.minor===I.minor&&U.patch===I.patch)return!0}return!1}return!0};return Op}var Lp,Ew;function Jf(){if(Ew)return Lp;Ew=1;const n=Symbol("SemVer ANY");class e{static get ANY(){return n}constructor(d,f){if(f=t(f),d instanceof e){if(d.loose===!!f.loose)return d;d=d.value}d=d.trim().split(/\s+/).join(" "),i("comparator",d,f),this.options=f,this.loose=!!f.loose,this.parse(d),this.semver===n?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(d){const f=this.options.loose?s[r.COMPARATORLOOSE]:s[r.COMPARATOR],m=d.match(f);if(!m)throw new TypeError(`Invalid comparator: ${d}`);this.operator=m[1]!==void 0?m[1]:"",this.operator==="="&&(this.operator=""),m[2]?this.semver=new l(m[2],this.options.loose):this.semver=n}toString(){return this.value}test(d){if(i("Comparator.test",d,this.options.loose),this.semver===n||d===n)return!0;if(typeof d=="string")try{d=new l(d,this.options)}catch{return!1}return o(d,this.operator,this.semver,this.options)}intersects(d,f){if(!(d instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(d.value,f).test(this.value):d.operator===""?d.value===""?!0:new c(this.value,f).test(d.semver):(f=t(f),f.includePrerelease&&(this.value==="<0.0.0-0"||d.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||d.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&d.operator.startsWith(">")||this.operator.startsWith("<")&&d.operator.startsWith("<")||this.semver.version===d.semver.version&&this.operator.includes("=")&&d.operator.includes("=")||o(this.semver,"<",d.semver,f)&&this.operator.startsWith(">")&&d.operator.startsWith("<")||o(this.semver,">",d.semver,f)&&this.operator.startsWith("<")&&d.operator.startsWith(">")))}}Lp=e;const t=S0(),{safeRe:s,t:r}=Mc(),o=DC(),i=Yf(),l=Wn(),c=cr();return Lp}var Mp,Tw;function Qf(){if(Tw)return Mp;Tw=1;const n=cr();return Mp=(t,s,r)=>{try{s=new n(s,r)}catch{return!1}return s.test(t)},Mp}var zp,Aw;function Vq(){if(Aw)return zp;Aw=1;const n=cr();return zp=(t,s)=>new n(t,s).set.map(r=>r.map(o=>o.value).join(" ").trim().split(" ")),zp}var Dp,Iw;function Hq(){if(Iw)return Dp;Iw=1;const n=Wn(),e=cr();return Dp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===-1)&&(i=u,l=new n(i,o))}),i},Dp}var Fp,Pw;function Kq(){if(Pw)return Fp;Pw=1;const n=Wn(),e=cr();return Fp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===1)&&(i=u,l=new n(i,o))}),i},Fp}var Up,$w;function Gq(){if($w)return Up;$w=1;const n=Wn(),e=cr(),t=Xf();return Up=(r,o)=>{r=new e(r,o);let i=new n("0.0.0");if(r.test(i)||(i=new n("0.0.0-0"),r.test(i)))return i;i=null;for(let l=0;l<r.set.length;++l){const c=r.set[l];let u=null;c.forEach(d=>{const f=new n(d.semver.version);switch(d.operator){case">":f.prerelease.length===0?f.patch++:f.prerelease.push(0),f.raw=f.format();case"":case">=":(!u||t(f,u))&&(u=f);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${d.operator}`)}}),u&&(!i||t(i,u))&&(i=u)}return i&&r.test(i)?i:null},Up}var Bp,Rw;function Zq(){if(Rw)return Bp;Rw=1;const n=cr();return Bp=(t,s)=>{try{return new n(t,s).range||"*"}catch{return null}},Bp}var Wp,Ow;function _0(){if(Ow)return Wp;Ow=1;const n=Wn(),e=Jf(),{ANY:t}=e,s=cr(),r=Qf(),o=Xf(),i=j0(),l=C0(),c=N0();return Wp=(d,f,m,p)=>{d=new n(d,p),f=new s(f,p);let h,g,x,b,w;switch(m){case">":h=o,g=l,x=i,b=">",w=">=";break;case"<":h=i,g=c,x=o,b="<",w="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(r(d,f,p))return!1;for(let v=0;v<f.set.length;++v){const j=f.set[v];let k=null,_=null;if(j.forEach(N=>{N.semver===t&&(N=new e(">=0.0.0")),k=k||N,_=_||N,h(N.semver,k.semver,p)?k=N:x(N.semver,_.semver,p)&&(_=N)}),k.operator===b||k.operator===w||(!_.operator||_.operator===b)&&g(d,_.semver))return!1;if(_.operator===w&&x(d,_.semver))return!1}return!0},Wp}var qp,Lw;function Yq(){if(Lw)return qp;Lw=1;const n=_0();return qp=(t,s,r)=>n(t,s,">",r),qp}var Vp,Mw;function Xq(){if(Mw)return Vp;Mw=1;const n=_0();return Vp=(t,s,r)=>n(t,s,"<",r),Vp}var Hp,zw;function Jq(){if(zw)return Hp;zw=1;const n=cr();return Hp=(t,s,r)=>(t=new n(t,r),s=new n(s,r),t.intersects(s,r)),Hp}var Kp,Dw;function Qq(){if(Dw)return Kp;Dw=1;const n=Qf(),e=lr();return Kp=(t,s,r)=>{const o=[];let i=null,l=null;const c=t.sort((m,p)=>e(m,p,r));for(const m of c)n(m,s,r)?(l=m,i||(i=m)):(l&&o.push([i,l]),l=null,i=null);i&&o.push([i,null]);const u=[];for(const[m,p]of o)m===p?u.push(m):!p&&m===c[0]?u.push("*"):p?m===c[0]?u.push(`<=${p}`):u.push(`${m} - ${p}`):u.push(`>=${m}`);const d=u.join(" || "),f=typeof s.raw=="string"?s.raw:String(s);return d.length<f.length?d:s},Kp}var Gp,Fw;function eV(){if(Fw)return Gp;Fw=1;const n=cr(),e=Jf(),{ANY:t}=e,s=Qf(),r=lr(),o=(f,m,p={})=>{if(f===m)return!0;f=new n(f,p),m=new n(m,p);let h=!1;e:for(const g of f.set){for(const x of m.set){const b=c(g,x,p);if(h=h||b!==null,b)continue e}if(h)return!1}return!0},i=[new e(">=0.0.0-0")],l=[new e(">=0.0.0")],c=(f,m,p)=>{if(f===m)return!0;if(f.length===1&&f[0].semver===t){if(m.length===1&&m[0].semver===t)return!0;p.includePrerelease?f=i:f=l}if(m.length===1&&m[0].semver===t){if(p.includePrerelease)return!0;m=l}const h=new Set;let g,x;for(const S of f)S.operator===">"||S.operator===">="?g=u(g,S,p):S.operator==="<"||S.operator==="<="?x=d(x,S,p):h.add(S.semver);if(h.size>1)return null;let b;if(g&&x){if(b=r(g.semver,x.semver,p),b>0)return null;if(b===0&&(g.operator!==">="||x.operator!=="<="))return null}for(const S of h){if(g&&!s(S,String(g),p)||x&&!s(S,String(x),p))return null;for(const C of m)if(!s(S,String(C),p))return!1;return!0}let w,v,j,k,_=x&&!p.includePrerelease&&x.semver.prerelease.length?x.semver:!1,N=g&&!p.includePrerelease&&g.semver.prerelease.length?g.semver:!1;_&&_.prerelease.length===1&&x.operator==="<"&&_.prerelease[0]===0&&(_=!1);for(const S of m){if(k=k||S.operator===">"||S.operator===">=",j=j||S.operator==="<"||S.operator==="<=",g){if(N&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===N.major&&S.semver.minor===N.minor&&S.semver.patch===N.patch&&(N=!1),S.operator===">"||S.operator===">="){if(w=u(g,S,p),w===S&&w!==g)return!1}else if(g.operator===">="&&!S.test(g.semver))return!1}if(x){if(_&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===_.major&&S.semver.minor===_.minor&&S.semver.patch===_.patch&&(_=!1),S.operator==="<"||S.operator==="<="){if(v=d(x,S,p),v===S&&v!==x)return!1}else if(x.operator==="<="&&!S.test(x.semver))return!1}if(!S.operator&&(x||g)&&b!==0)return!1}return!(g&&j&&!x&&b!==0||x&&k&&!g&&b!==0||N||_)},u=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h>0?f:h<0||m.operator===">"&&f.operator===">="?m:f},d=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h<0?f:h>0||m.operator==="<"&&f.operator==="<="?m:f};return Gp=o,Gp}var Zp,Uw;function tV(){if(Uw)return Zp;Uw=1;const n=Mc(),e=Lc(),t=Wn(),s=LC(),r=wi(),o=Aq(),i=Iq(),l=Pq(),c=$q(),u=Rq(),d=Oq(),f=Lq(),m=Mq(),p=lr(),h=zq(),g=Dq(),x=k0(),b=Fq(),w=Uq(),v=Xf(),j=j0(),k=MC(),_=zC(),N=N0(),S=C0(),C=DC(),E=Bq(),T=Wq(),$=Jf(),A=cr(),R=Qf(),P=Vq(),z=Hq(),L=Kq(),I=Gq(),M=Zq(),F=_0(),U=Yq(),O=Xq(),D=Jq(),B=Qq(),q=eV();return Zp={parse:r,valid:o,clean:i,inc:l,diff:c,major:u,minor:d,patch:f,prerelease:m,compare:p,rcompare:h,compareLoose:g,compareBuild:x,sort:b,rsort:w,gt:v,lt:j,eq:k,neq:_,gte:N,lte:S,cmp:C,coerce:E,truncate:T,Comparator:$,Range:A,satisfies:R,toComparators:P,maxSatisfying:z,minSatisfying:L,minVersion:I,validRange:M,outside:F,gtr:U,ltr:O,intersects:D,simplifyRange:B,subset:q,SemVer:t,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers},Zp}var Vn=tV();const lt=Le().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n),"Reserved identifier"),_s=Le().min(1).max(128).refine(n=>[...n].every(e=>e.charCodeAt(0)>=32&&e.charCodeAt(0)!==127),"Control characters are forbidden"),Cs=n=>Le().refine(e=>Pl(e)<=n,"Text exceeds byte limit"),il=Le().min(1).max(256).refine(n=>/^[A-Za-z0-9_./-]+$/u.test(n)?n.split("/").every(e=>e!==""&&e!=="."&&e!==".."&&!e.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/iu.test(e)):!1,"Expected a canonical portable package path");function zo(n,e,t,s){const r=n.safeParse(l0(e,{maxBytes:t,maxNodes:s}));if(!r.success)throw new tc(r.error.issues.map(o=>({path:o.path.length?`$.${o.path.map(String).join(".")}`:"$",message:o.message})));return r.data}const nV=["actions","actionJobs","pulls","pullFiles","pullSessions","issues","mergePull"],sV=["deployments","buildLogs"],rV=["workspace","deployments","version"],Yp=n=>at(Ct(n)).min(1).max(n.length).refine(e=>new Set(e).size===e.length,"Duplicate operation"),oV=Rr("id",[xe({id:Ze("github"),operations:Yp(nV)}),xe({id:Ze("vercel"),operations:Yp(sV)}),xe({id:Ze("cloudflare"),operations:Yp(rV)})]),Br=bt().int().positive().max(Number.MAX_SAFE_INTEGER),Qo={integration:Ze("github")},Bw={integration:Ze("vercel")},Xp={integration:Ze("cloudflare")},Ww=Le().regex(/^[A-Za-z0-9_-]+$/).max(64).optional(),Jp=Le().max(240).regex(/^(?:[^/\\]+\/)*wrangler\.(?:json|jsonc|toml)$/).refine(n=>n.split("/").every(e=>e!=="."&&e!==".."),"Invalid configuration path").optional(),iV=Rr("operation",[xe({...Qo,operation:Ze("actions"),limit:Br.max(30).optional()}),xe({...Qo,operation:Ze("actionJobs"),runId:Br}),xe({...Qo,operation:Ze("pulls"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("pullFiles"),number:Br}),xe({...Qo,operation:Ze("pullSessions")}),xe({...Qo,operation:Ze("issues"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("mergePull"),number:Br,method:Ct(["merge","squash","rebase"]),headSha:Le().regex(/^[0-9a-f]{40}$/)})]),aV=Rr("operation",[xe({...Bw,operation:Ze("deployments"),limit:Br.max(30).optional()}),xe({...Bw,operation:Ze("buildLogs"),deploymentId:Le().regex(/^dpl_[A-Za-z0-9]+$/).max(128),limit:Br.max(500).optional()})]),lV=Rr("operation",[xe({...Xp,operation:Ze("workspace"),config:Jp}),xe({...Xp,operation:Ze("deployments"),config:Jp,environment:Ww,limit:Br.max(30).optional()}),xe({...Xp,operation:Ze("version"),config:Jp,environment:Ww,versionId:Le().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)})]),cV=Rr("integration",[iV,aV,lV]),uV=Rr("ok",[xe({ok:Ze(!0),data:OC(()=>!0)}),xe({ok:Ze(!1),error:xe({code:Le().min(1).max(64),message:Le().min(1).max(512)})})]),ju={id:lt,label:_s,description:Cs(512).optional()},dV=Rr("type",[xe({...ju,type:Ze("string"),default:Cs(4096).default(""),maxLength:bt().int().min(1).max(4096).default(256)}),xe({...ju,type:Ze("boolean"),default:Ft().default(!1)}),xe({...ju,type:Ze("number"),default:bt().finite(),min:bt().finite(),max:bt().finite(),step:bt().positive().optional()}),xe({...ju,type:Ze("select"),default:Cs(256),options:at(xe({value:Cs(256),label:_s})).min(1).max(64)})]).superRefine((n,e)=>{n.type==="number"&&(n.min>n.max||n.default<n.min||n.default>n.max)&&e.addIssue({code:"custom",message:"Invalid numeric setting bounds/default"}),n.type==="string"&&n.default.length>n.maxLength&&e.addIssue({code:"custom",message:"Default exceeds setting length"}),n.type==="select"&&(!n.options.some(t=>t.value===n.default)||new Set(n.options.map(t=>t.value)).size!==n.options.length)&&e.addIssue({code:"custom",message:"Invalid select options/default"})}),fV=xe({scope:Ct(["plugin","project"]),fields:at(dV).min(1).max(32).refine(n=>new Set(n.map(e=>e.id)).size===n.length,"Duplicate setting ID")}).refine(n=>new TextEncoder().encode(JSON.stringify(Object.fromEntries(n.fields.map(e=>[e.id,e.default])))).byteLength<=16384,"Default settings exceed 16 KiB"),mV=xe({id:lt,title:_s,description:Cs(512),source:il.refine(n=>n.endsWith(".md"),"Skill source must be Markdown")}),pV=xe({id:Le().regex(/^[a-z][a-z0-9-]{0,63}$/u),title:_s,height:bt().int().min(80).max(800).default(240)}),hV=xe({id:lt,title:_s,skill:lt,prompt:Cs(4096).refine(n=>n.trim().length>0,"Action prompt is required")});function A2e(n,e){const t={};for(const s of n.fields)t[s.id]=s.type==="string"?Le().max(s.maxLength).default(s.default):s.type==="boolean"?Ft().default(s.default):s.type==="number"?bt().finite().min(s.min).max(s.max).default(s.default):Ct(s.options.map(r=>r.value)).default(s.default);return xe(t).parse(e)}function FC(n){const e=n==null?void 0:n.match(/^cogpit:([a-z][a-z0-9-]*\.[a-z][a-z0-9-]*):([a-z][a-z0-9-]{0,63})$/u);return e?{pluginId:e[1],blockId:e[2]}:null}const Ss=1,gV="1.2.0",UC="browser-iife-v1",Zg=Le().max(128).refine(n=>Vn.valid(n)===n,"Expected strict SemVer"),cd=Le().min(1).max(256).refine(n=>Vn.validRange(n)!==null,"Expected a SemVer range"),qw=Xn(lt,cd).refine(n=>Object.keys(n).length<=32,"Too many capabilities"),Vw=xe({client:qw,host:qw}),al=n=>new Set(n).size===n.length,xV=at(lt).max(32).refine(al,"Duplicate identifier"),Hw=Le().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/u),Qp=Le().regex(/^(?:[1-9][0-9]{0,3}px|(?:[1-9][0-9]?|100)%)$/u),bV=xe({manifestVersion:Ze(1),id:Le().max(128).regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/u),publisher:Hw,name:_s,version:Zg,runtime:Ze(UC),entry:il.refine(n=>n.endsWith(".js"),"Entry must be JavaScript").optional(),style:il.refine(n=>n.endsWith(".css"),"Style must be CSS").optional(),engines:xe({pluginApi:cd,client:cd,host:cd}),protocol:Ze(Ss).default(Ss),requires:Vw,optional:Vw.default({client:{},host:{}}),browser:at(Ct(["message-channel","blob-script","web-crypto"])).max(3).refine(al).default([]),contributes:xe({panels:at(xe({id:Hw,title:_s,icon:il.refine(n=>/\.(png|jpe?g|webp)$/u.test(n),"Expected a raster icon"),order:bt().int().min(0).max(1e3).optional(),defaultSize:Qp.optional(),minSize:Qp.optional(),maxSize:Qp.optional(),when:Ct(["always","project-selected"]).default("project-selected")})).max(8).default([]),settings:fV.optional(),skills:at(mV).max(16).optional(),chatBlocks:at(pV).max(8).optional(),sessionActions:at(hV).max(8).optional()}),permissions:xe({context:at(Ct(["project.identity","session.identity"])).max(2).refine(al).default([]),composer:at(Ze("append")).max(1).default([]),navigation:at(Ct(["external","session"])).max(2).refine(al).default([]),connections:at(xe({id:lt,definition:il,operations:xV.min(1)})).max(8).default([]),integrations:at(oV).max(2).default([]),storage:xe({scope:Ct(["project","plugin"]),quotaKiB:bt().int().min(1).max(1024)}).optional()}),stateVersion:bt().int().min(1).max(Number.MAX_SAFE_INTEGER)}).superRefine((n,e)=>{var t,s,r,o;!n.contributes.panels.length&&!((t=n.contributes.skills)!=null&&t.length)&&!((s=n.contributes.chatBlocks)!=null&&s.length)&&!n.contributes.settings&&e.addIssue({code:"custom",path:["contributes"],message:"At least one contribution is required"}),(n.contributes.panels.length||(r=n.contributes.chatBlocks)!=null&&r.length)&&!n.entry&&e.addIssue({code:"custom",path:["entry"],message:"Visual contributions require a JavaScript entry"}),n.style&&!n.entry&&e.addIssue({code:"custom",path:["style"],message:"Styles require a JavaScript entry"});for(const i of n.contributes.sessionActions??[])(o=n.contributes.skills)!=null&&o.some(l=>l.id===i.skill)||e.addIssue({code:"custom",path:["contributes","sessionActions"],message:"Session actions must reference a declared skill"});n.id.startsWith(`${n.publisher}.`)||e.addIssue({code:"custom",path:["id"],message:"Plugin ID must belong to its publisher"}),["cogpit.worktrees","cogpit.project-files","cogpit.browser","cogpit.file-changes","cogpit.session-info"].includes(n.id)&&e.addIssue({code:"custom",path:["id"],message:"Reserved built-in ID"});for(const[i,l]of[["panels",n.contributes.panels],["skills",n.contributes.skills??[]],["chatBlocks",n.contributes.chatBlocks??[]],["sessionActions",n.contributes.sessionActions??[]],["connections",n.permissions.connections],["integrations",n.permissions.integrations]])al(l.map(c=>c.id))||e.addIssue({code:"custom",path:[i],message:"Duplicate contribution ID"});for(const i of["client","host"])for(const l of Object.keys(n.optional[i]))Object.hasOwn(n.requires[i],l)&&e.addIssue({code:"custom",path:["optional",i,l],message:"Capability is already required"})});function BC(n){return zo(bV,n,en.manifestBytes)}const E0=8*1024*1024,WC=Ct(["audio/mpeg","audio/wav","audio/flac","audio/ogg","audio/opus","audio/aac"]);function em(n){var r,o;if(!n||typeof n!="object"||Object.keys(n).length!==2)throw new tc([{path:"$",message:"Invalid media response"}]);const e=Object.getOwnPropertyDescriptors(n),t=WC.safeParse((r=e.mimeType)==null?void 0:r.value),s=(o=e.bytes)==null?void 0:o.value;if(!t.success||!(s instanceof ArrayBuffer)||s.byteLength===0||s.byteLength>E0)throw new tc([{path:"$",message:"Invalid or oversized audio response"}]);return{mimeType:t.data,bytes:s}}const qC=Le().max(256).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&e.origin===n&&!e.username&&!e.password&&!e.port&&/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/u.test(e.hostname)&&!/\.(?:localhost|local|internal)$/u.test(e.hostname)}catch{return!1}},"Expected an exact public HTTPS origin"),So=Le().max(256).refine(n=>(!n||n.startsWith("/"))&&!/~(?![01])/u.test(n)&&n.split("/").length<=9&&!n.split("/").some(e=>["__proto__","prototype","constructor"].includes(e)),"Invalid bounded JSON pointer"),VC=Le().min(1).max(1024).regex(/^[a-zA-Z0-9._~-]+$/u).refine(n=>n!=="."&&n!==".."),vV=Rr("type",[xe({type:Ze("string"),required:Ft().optional(),maxLength:bt().int().min(1).max(16384),multiline:Ft().optional(),enum:at(_s).min(1).max(64).optional()}),xe({type:Ze("integer"),required:Ft().optional(),min:bt().int().min(Number.MIN_SAFE_INTEGER),max:bt().int().max(Number.MAX_SAFE_INTEGER)}),xe({type:Ze("number"),required:Ft().optional(),min:bt().finite(),max:bt().finite()}),xe({type:Ze("boolean"),required:Ft().optional()})]),yV=to([xe({literal:VC}),xe({resource:lt}),xe({arg:lt})]),Kw=to([lt,xe({literal:to([Le().max(1024),bt().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER),Ft()])}),xe({arg:lt}),xe({resource:lt}),xe({identity:lt})]),wV=xe({audience:Ct(["setup","panel"]),origin:qC,method:Ct(["GET","POST"]),path:at(yV).min(1).max(16),args:Xn(lt,vV).refine(n=>Object.keys(n).length<=16),query:Xn(Le().max(68).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*(?:\[\])?$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n.replace(/\[\]$/u,""))),Kw).refine(n=>Object.keys(n).length<=16),body:Xn(lt,Kw).refine(n=>Object.keys(n).length<=16).optional(),response:xe({type:Ze("audio"),mimeTypes:at(WC).min(1).max(6),maxBytes:bt().int().min(1).max(E0)}).optional()}),Gw=xe({operation:lt,items:So,nested:So.optional(),id:So,label:So}),SV=xe({label:_s,scope:Ct(["connection","project"]).optional(),dependsOn:at(lt).max(7).refine(n=>new Set(n).size===n.length).optional(),options:to([Gw,at(Gw).min(1).max(4)]).optional(),input:xe({allowId:Ft(),urls:at(xe({origin:qC,pathMarker:VC})).min(1).max(8).optional(),validation:xe({operation:lt,argument:lt,id:So.optional(),label:So,parents:Xn(lt,So).refine(n=>Object.keys(n).length<=7).optional()})}).optional()}).refine(n=>!!n.options||!!n.input,"Expected listed or validated entered resources"),kV=xe({version:Ze(1),id:lt,label:_s,secret:xe({id:lt,label:_s}),auth:xe({header:Le().max(64).regex(/^(?:Authorization|X-[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)$/iu).refine(n=>!/^x-(?:forwarded|http-method|original|rewrite)(?:-|$)/iu.test(n),"Unsafe credential header"),scheme:Ct(["raw","bearer"])}),validationOperation:lt,identity:Xn(lt,So).refine(n=>Object.keys(n).length<=8).optional(),resources:Xn(lt,SV).refine(n=>Object.keys(n).length<=8),operations:Xn(lt,wV).refine(n=>Object.keys(n).length>0&&Object.keys(n).length<=32)});function Vd(n){return n?[...n.path.flatMap(e=>"resource"in e?[e.resource]:[]),...Object.values(n.query).flatMap(e=>typeof e=="object"&&"resource"in e?[e.resource]:[])]:[]}function Zw(n,e){const t=n.resources[e];if(!t)return[];const s=t.options?Array.isArray(t.options)?t.options:[t.options]:[];return[...new Set([...t.dependsOn??[],...s.flatMap(r=>Vd(n.operations[r.operation])),...Vd(t.input?n.operations[t.input.validation.operation]:void 0)])]}const jV=kV.superRefine((n,e)=>{var u,d;const t=(f,m)=>e.addIssue({code:"custom",path:f,message:m}),s=f=>{var m;return((m=n.operations[f])==null?void 0:m.audience)==="setup"},r=(f,m)=>f&&Object.entries(f.args).every(([p,h])=>!h.required||p===m),o=n.operations[n.validationOperation];(!s(n.validationOperation)||!r(o)||Vd(o).length||Object.values((o==null?void 0:o.query)??{}).some(f=>typeof f=="object"&&"identity"in f))&&t(["validationOperation"],"Expected an independent setup operation without required arguments");for(const[f,m]of Object.entries(n.resources)){const p=Zw(n,f);for(const g of p)(g===f||!Object.hasOwn(n.resources,g))&&t(["resources",f,"dependsOn"],"Unknown or self-dependent resource"),(m.scope??"connection")==="connection"&&((u=n.resources[g])==null?void 0:u.scope)==="project"&&t(["resources",f,"scope"],"Connection resource cannot depend on a project resource");const h=m.options?Array.isArray(m.options)?m.options:[m.options]:[];for(const g of h){const x=n.operations[g.operation];(!s(g.operation)||!r(x))&&t(["resources",f,"options"],"Expected a setup operation without required arguments"),p.some(b=>!Vd(x).includes(b))&&t(["resources",f,"options"],"Every options source must bind all parent resources")}if(m.input){const g=m.input,x=g.validation,b=n.operations[x.operation],w=b==null?void 0:b.args[x.argument];!g.allowId&&!g.urls&&t(["resources",f,"input"],"Expected an accepted input format"),(!s(x.operation)||!r(b,x.argument)||(w==null?void 0:w.type)!=="string"||!w.required||b.path.filter(v=>"arg"in v&&v.arg===x.argument).length!==1)&&t(["resources",f,"input","validation"],"Validation must request the candidate as one required path argument"),(p.some(v=>!Object.hasOwn(x.parents??{},v))||Object.keys(x.parents??{}).some(v=>!p.includes(v)))&&t(["resources",f,"input","validation","parents"],"Validation must prove each selected parent")}}const i=new Set,l=new Set,c=f=>{if(i.has(f)){t(["resources",f,"dependsOn"],"Resource dependency cycle");return}if(!l.has(f)){i.add(f);for(const m of Zw(n,f))Object.hasOwn(n.resources,m)&&c(m);i.delete(f),l.add(f)}};for(const f of Object.keys(n.resources))c(f);for(const[f,m]of Object.entries(n.operations)){m.audience==="setup"&&(m.method!=="GET"||m.response)&&t(["operations",f],"Setup operations must return JSON from GET"),m.body&&m.method!=="POST"&&t(["operations",f,"body"],"Only POST operations have a body");const p=new Set;for(const[h,g]of Object.entries(m.args))(Object.hasOwn(n.resources,h)||Object.hasOwn(n.identity??{},h))&&t(["operations",f,"args",h],"Argument shadows a host-owned binding"),(g.type==="integer"||g.type==="number")&&g.min>g.max&&t(["operations",f,"args",h],"Inverted numeric bounds"),g.type==="string"&&((d=g.enum)!=null&&d.some(x=>new TextEncoder().encode(x).byteLength>g.maxLength))&&t(["operations",f,"args",h],"Enum exceeds string limit");for(const h of m.path)if("resource"in h&&!Object.hasOwn(n.resources,h.resource)&&t(["operations",f,"path"],"Unknown selected resource"),"arg"in h){const g=m.args[h.arg];((g==null?void 0:g.type)!=="string"||g.required!==!0)&&t(["operations",f,"path"],"Path argument must be a required string"),p.add(h.arg)}for(const h of[...Object.values(m.query),...Object.values(m.body??{})]){const g=typeof h=="string"?h:"arg"in h?h.arg:void 0;g!==void 0?(Object.hasOwn(m.args,g)||t(["operations",f,"query"],"Unknown query argument"),p.add(g)):typeof h=="object"&&"resource"in h&&!Object.hasOwn(n.resources,h.resource)?t(["operations",f,"query"],"Unknown selected resource"):typeof h=="object"&&"identity"in h&&!Object.hasOwn(n.identity??{},h.identity)&&t(["operations",f,"query"],"Unknown validated identity")}Object.keys(m.args).some(h=>!p.has(h))&&t(["operations",f,"args"],"Unused argument")}});function Yg(n){return zo(jV,n,en.definitionBytes)}const HC={appVersion:Le().min(1).max(128),apiVersions:at(Zg).max(16),manifestVersions:at(bt().int().min(1).max(1024)).max(16),protocolVersions:at(bt().int().min(1).max(1024)).max(16),runtimes:at(Le().min(1).max(64)).max(16),capabilities:Xn(lt,Zg).refine(n=>Object.keys(n).length<=64)},NV=xe({...HC,browser:at(Le().min(1).max(64)).max(16)}),CV=xe({...HC,platform:Le().min(1).max(32),registryRevision:bt().int().min(0).max(Number.MAX_SAFE_INTEGER)});function _V(n){return zo(NV,n,16*1024)}function EV(n){return zo(CV,n,16*1024)}function T0(n,e,t,s={}){var f;const r=[],o=[],i=(m,p)=>!!Vn.valid(m)&&!!Vn.validRange(p)&&Vn.satisfies(m,p,{includePrerelease:s.allowPrerelease===!0}),l=(m,p,h,g,x)=>r.push({side:m,code:p,name:h,required:g,actual:x});s.revoked&&l("package","REVOKED",n.id,"non-revoked package",n.version),Vn.prerelease(n.version)&&!s.allowPrerelease&&l("package","PRERELEASE",n.id,"stable release",n.version);for(const m of["client","host"]){const p=m==="client"?e:t;i(p.appVersion,n.engines[m])||l(m,"APP_VERSION","app",n.engines[m],p.appVersion),p.manifestVersions.includes(n.manifestVersion)||l(m,"MANIFEST_VERSION","manifest",String(n.manifestVersion),p.manifestVersions.join(",")),p.protocolVersions.includes(n.protocol)||l(m,"PROTOCOL_VERSION","protocol",String(n.protocol),p.protocolVersions.join(",")),p.runtimes.includes(n.runtime)||l(m,"RUNTIME","runtime",n.runtime,p.runtimes.join(","));for(const[h,g]of Object.entries(n.requires[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&l(m,"CAPABILITY",h,g,x)}for(const[h,g]of Object.entries(n.optional[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&o.push({side:m,name:h,required:g,actual:x})}}for(const m of n.browser)e.browser.includes(m)||l("client","BROWSER",m,"available",null);const c=[],u=new Vn.Range(n.engines.pluginApi,{includePrerelease:s.allowPrerelease===!0});for(const m of e.apiVersions.filter(p=>Vn.valid(p)))for(const p of t.apiVersions.filter(h=>Vn.valid(h))){if(Vn.major(m)!==Vn.major(p))continue;const h=Vn.compare(m,p)<=0?m:p;i(h,n.engines.pluginApi)&&c.push(h);for(const g of u.set){const x=`${g.map(w=>w.value).join(" ")} >=${Vn.major(h)}.0.0 <=${h}`,b=(f=Vn.minVersion(x))==null?void 0:f.version;b&&i(b,n.engines.pluginApi)&&c.push(b)}}const d=c.sort(Vn.rcompare)[0]??null;if(!d){for(const m of["client","host"]){const p=m==="client"?e.apiVersions:t.apiVersions;p.some(h=>i(h,n.engines.pluginApi))||l(m,"API_VERSION","pluginApi",n.engines.pluginApi,p.join(","))}r.some(m=>m.code==="API_VERSION")||l("host","API_VERSION","pluginApi","common API version",t.apiVersions.join(","))}return{compatible:r.length===0,apiVersion:d,issues:r,unavailableOptional:o}}const Hd=OC(()=>!0),Yw=xe({}),TV=xe({id:lt,name:_s}).nullable(),KC=xe({mode:Ct(["light","dark"]),tokens:Xn(Le().regex(/^--[a-z][a-z0-9-]{0,63}$/u),Cs(256)).refine(n=>Object.keys(n).length<=64)}),GC=Le().regex(/^s_[a-f0-9]{48}$/u),AV=xe({handle:GC}).nullable().optional(),IV=xe({type:Ze("chat-block"),id:lt,source:Cs(16384)}).optional(),ZC=xe({project:TV,theme:KC,locale:Le().min(1).max(64),reducedMotion:Ft(),visible:Ft(),session:AV,surface:IV});function Xw(n){return zo(ZC,n,en.responseBytes)}const YC=["INVALID_REQUEST","INVALID_RESPONSE","INCOMPATIBLE_HOST","INCOMPATIBLE_CLIENT","PERMISSION_REQUIRED","CONNECTION_REQUIRED","RESOURCE_REQUIRED","STALE_ACTIVATION","RATE_LIMITED","PLUGIN_DISABLED","CAPABILITY_UNAVAILABLE","UPSTREAM_FAILED","CANCELED","TIMEOUT","DISPOSED"],PV=xe({code:Ct(YC),message:Cs(512)}),ll=Le().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/u),$V=Le().min(1).max(2048).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&!e.username&&!e.password}catch{return!1}},"Expected an HTTPS URL without credentials"),eh=lt,XC={"lifecycle.ready":Yw,"connections.request":xe({handle:lt,operationId:lt,args:Xn(lt,to([Le(),bt().finite(),Ft()]))}),"connections.media":xe({handle:lt,operationId:lt,args:Xn(lt,to([Le(),bt().finite(),Ft()]))}),"connections.status":xe({handle:lt}),"integrations.request":cV,"storage.get":xe({key:eh}),"storage.set":xe({key:eh,value:Hd}),"storage.delete":xe({key:eh}),"composer.append":xe({text:Cs(en.composerBytes)}),"navigation.openExternal":xe({url:$V}),"navigation.openSession":xe({handle:lt}),"settings.get":Yw,"ui.resize":xe({height:bt().int().min(80).max(800)})},RV=xe({configured:Ft(),readOnly:Ft(),selected:Xn(lt,xe({id:Cs(1024),label:Cs(256)})).refine(n=>Object.keys(n).length<=8)}),OV=Rr("event",[xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("context"),value:ZC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("theme"),value:KC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("visibility"),value:Ft()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("session"),value:xe({handle:GC}).nullable()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("dispose"),value:_C()})]),LV=to([xe({protocol:Ze(Ss),type:Ze("request"),id:ll,method:Ct(Object.keys(XC)),params:Hd}),xe({protocol:Ze(Ss),type:Ze("result"),id:ll,value:Hd}),xe({protocol:Ze(Ss),type:Ze("error"),id:ll,error:PV}),xe({protocol:Ze(Ss),type:Ze("cancel"),id:ll}),OV]);function Jw(n){var s,r,o,i,l;if(n&&typeof n=="object"&&((s=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:s.value)==="media-result"){const c=Object.getOwnPropertyDescriptors(n);if(Object.keys(c).length!==4||((r=c.protocol)==null?void 0:r.value)!==1)throw new Error("Invalid media envelope");return{protocol:1,type:"media-result",id:ll.parse((o=c.id)==null?void 0:o.value),value:em((i=c.value)==null?void 0:i.value)}}const e=n!==null&&typeof n=="object"&&((l=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:l.value)==="result",t=zo(LV,n,e?en.resultMessageBytes:en.messageBytes,e?en.responseNodes+16:en.nodes);if(t.type==="request"){const c=t.method==="connections.media"?en.messageBytes:t.method==="composer.append"?en.composerBytes+64:t.method==="storage.set"?en.storageValueBytes:en.argumentBytes,u=zo(XC[t.method],t.params,c);return{...t,params:u}}return t.type==="result"?{...t,value:l0(t.value,{maxBytes:en.responseBytes,maxNodes:en.responseNodes})}:t}function JC(n,e){if(n==="connections.media")return em(e);const t=n==="integrations.request"?uV:n==="connections.status"?RV:n==="connections.request"||n==="storage.get"||n==="settings.get"?Hd:_C();return zo(t,e,en.responseBytes,en.responseNodes)}const Qw=xe({values:Xn(Le(),to([Le().max(4096),bt().finite(),Ft()])),revision:bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),adjustedFields:at(Le().max(64)).max(32).optional()}),zc=bt().int().min(0).max(Number.MAX_SAFE_INTEGER),tm=Le().regex(/^[a-f0-9]{64}$/),rc=eo().transform(BC),QC=Rr("type",[xe({type:Ze("all")}),xe({type:Ze("projects"),projectIds:at(Le().min(1).max(512)).max(128).refine(n=>new Set(n).size===n.length)})]),MV=xe({digest:tm,manifest:rc,targetPath:Le().min(1).max(512),installedAt:zc,unavailableReason:Le().max(1e3).optional()}),zV=xe({id:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),selectedDigest:tm,manifest:rc,enabled:Ft(),scope:QC,pinned:Ft(),versions:at(MV).min(1).max(64),lastError:Le().max(1e3).optional()}),DV=xe({id:Le().max(128),label:Le().max(128),kind:Ct(["official","development"]),fingerprint:Le().max(128),verifiedAt:zc.optional()}),e_=xe({available:Ft(),error:Le().max(2e3).optional(),revision:zc,plugins:at(zV).max(256),publishers:at(DV).max(256),legacyPluginIds:at(Ct(["github","clickup","vercel-deployments"])).max(3).optional(),availableSeeds:at(xe({manifest:rc,digest:tm})).max(256).optional(),recoveryCode:Ct(["STORE_LOCKED","STORE_VERSION","STORE_CORRUPT","STORE_UNAVAILABLE"]).optional()}),FV=xe({side:Ct(["client","host"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()}),UV=xe({compatible:Ft(),apiVersion:Le().max(128).nullable(),issues:at(xe({side:Ct(["client","host","package"]),code:Ct(["APP_VERSION","API_VERSION","MANIFEST_VERSION","PROTOCOL_VERSION","RUNTIME","CAPABILITY","BROWSER","PRERELEASE","REVOKED"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()})).max(128),unavailableOptional:at(FV).max(128)});eo().transform(_V);const ud=xe({transactionId:Le().uuid(),manifest:rc,digest:tm,compatibility:UV,connectionDefinitions:at(eo().transform(Yg)).max(8),oldVersion:Le().max(128).nullable(),registryRevision:zc,publisherKind:Ct(["official","development"]),scope:QC,operation:Ct(["install","update","rollback"]).optional(),previousManifest:rc.optional(),previousConnectionDefinitions:at(eo().transform(Yg)).max(8).optional(),incompatibleClients:at(Le().max(256)).max(256).optional()}),t_=xe({id:Le().regex(/^p_[a-f0-9]{40}$/),name:Le().max(512),paths:at(Le().max(8192)).max(256)}),BV=xe({runtime:eo().transform(EV),host:xe({name:Le().max(256),instanceId:Le().max(128)}),store:e_,projects:at(t_).max(1024),safeMode:Ft(),connectionRevision:zc.optional()}),Xg=Le().regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/).max(64),A0=bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),n_=xe({pluginId:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),projectId:Le().regex(/^p_[a-f0-9]{40}$/).nullable()});n_.extend({expectedRevision:A0});const WV=n_.extend({connectionId:Xg});WV.extend({expectedRevision:A0});const s_=xe({id:Le().min(1).max(1024),label:Le().min(1).max(256)}),qV=at(s_).max(1e3),eS=xe({revision:A0,connections:at(xe({id:Xg,label:Le().min(1).max(128),status:Ct(["disconnected","connected","environment"]),readOnly:Ft(),legacyImportAvailable:Ft().optional(),selected:Xn(Xg,s_).refine(n=>Object.keys(n).length<=8),definition:eo().transform(Yg)})).max(8)}),r_="3.5.0",o_={version:r_};function cl(n=globalThis){var u,d,f,m,p,h,g,x,b,w,v,j,k,_,N,S,C,E;const e=T=>typeof T=="function",t=e(n.MessageChannel)&&e((d=(u=n.MessagePort)==null?void 0:u.prototype)==null?void 0:d.postMessage)&&e((m=(f=n.MessagePort)==null?void 0:f.prototype)==null?void 0:m.start)&&e((h=(p=n.MessagePort)==null?void 0:p.prototype)==null?void 0:h.close),s=e(n.Blob)&&e((g=n.URL)==null?void 0:g.createObjectURL)&&e((x=n.URL)==null?void 0:x.revokeObjectURL),r=e((w=(b=n.crypto)==null?void 0:b.subtle)==null?void 0:w.digest)&&e((v=n.crypto)==null?void 0:v.getRandomValues),o=n.isSecureContext===!0,l=[["secure context (HTTPS or localhost)",o],["MessageChannel",t],["Blob URLs",s],["Web Crypto",r],["AbortController",e(n.AbortController)],["AbortSignal.any",e((j=n.AbortSignal)==null?void 0:j.any)],["AbortSignal.timeout",e((k=n.AbortSignal)==null?void 0:k.timeout)],["AbortSignal.throwIfAborted",e((N=(_=n.AbortSignal)==null?void 0:_.prototype)==null?void 0:N.throwIfAborted)],["structuredClone",e(n.structuredClone)],["Object.hasOwn",e((S=n.Object)==null?void 0:S.hasOwn)],["fetch",e(n.fetch)],["Headers",e(n.Headers)],["ReadableStream",e((E=(C=n.ReadableStream)==null?void 0:C.prototype)==null?void 0:E.getReader)],["TextEncoder",e(n.TextEncoder)],["TextDecoder",e(n.TextDecoder)]].filter(([,T])=>!T).map(([T])=>T),c=[];return t&&c.push("message-channel"),s&&c.push("blob-script"),r&&o&&c.push("web-crypto"),{supported:l.length===0,browser:c,missing:l,error:l.length?`Runtime plugins are unavailable in this browser. Missing: ${l.join(", ")}. Update your browser or use a secure connection.`:null}}const VV=xe({sessionId:Le().regex(/^[a-f0-9]{64}$/),expiresAt:bt().int().positive()}),tS=xe({id:Le().min(1).max(128),expiresAt:bt().int().positive()}),HV=xe({deadline:bt().int().positive()}),KV=xe({status:Ct(["prepared","trial","committing","committed","cancelled","abandoned"]),preview:ud,deadline:bt().int().positive().optional()}),Jg={status:null,error:null,activation:""};function vo(){const n=cl();return{appVersion:r_,apiVersions:[gV],manifestVersions:[1],protocolVersions:[Ss],runtimes:n.supported?[UC]:[],capabilities:n.supported?{"workspace.panel":"1.0.0","composer.append":"1.0.0","navigation.external":"1.0.0","navigation.session":"1.0.0","chat.blocks":"1.0.0","session.actions":"1.0.0","media.audio":"1.0.0","settings.fields":"1.0.0"}:{},browser:n.browser}}class Qg extends Error{constructor(e,t,s){super(e),this.code=t,this.status=s}}async function e1(n,e){var c;const t=n.headers.get("Content-Length");if(t&&Number(t)>e)throw await((c=n.body)==null?void 0:c.cancel()),new Error("Plugin response exceeds its size limit");if(!n.body)throw new Error("Plugin host returned an empty response");const s=n.body.getReader(),r=[];let o=0;try{for(;;){const{done:u,value:d}=await s.read();if(u)break;if(o+=d.byteLength,o>e)throw new Error("Plugin response exceeds its size limit");r.push(d)}}catch(u){throw await s.cancel().catch(()=>{}),u}finally{s.releaseLock()}const i=new Uint8Array(o);let l=0;for(const u of r)i.set(u,l),l+=u.byteLength;return i.buffer}async function Ga(n){const e=await e1(n,4194304);let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new Error("This host does not support runtime plugins, or returned an invalid response")}if(!n.ok){const s=cq({error:Le().max(2e3),code:Le().max(128).optional()}).safeParse(t);throw new Qg(s.success?s.data.error:"Plugin request failed",s.success?s.data.code??"HOST_ERROR":"HOST_ERROR",n.status)}return t}class GV{constructor(){Ge(this,"scope",cn());Ge(this,"identity",Zn());Ge(this,"base",new URL(Ex("/api/plugins/"),window.location.origin));Ge(this,"lifetimeController");Ge(this,"session",null);Ge(this,"renewal",null);Ge(this,"refreshPromise",null);Ge(this,"timer");Ge(this,"listeners",new Set);Ge(this,"state",Jg);Ge(this,"running",!1);Ge(this,"getSnapshot",()=>this.state);Ge(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));Ge(this,"hostChanged",()=>{(this.scope!==cn()||this.identity!==Zn())&&this.stop()})}get controller(){const e=cl();if(!e.supported)throw new Qg(e.error,"UNSUPPORTED_BROWSER",0);if(!this.lifetimeController)throw new Error("The plugin client has not started");return this.lifetimeController}publish(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}assertCurrent(e){const t=this.controller.signal;if((e??t).throwIfAborted(),!this.running||this.scope!==cn()||this.identity!==Zn())throw new Error("The connected host or signed-in user changed")}start(){if(this.running)return;const e=cl();if(!e.supported){this.publish({status:null,error:e.error,activation:""});return}this.running=!0,this.lifetimeController=new AbortController;for(const t of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.addEventListener(t,this.hostChanged);this.refresh(),this.timer=setInterval(()=>{this.refresh()},5e3)}stop(){var t;this.running=!1,clearInterval(this.timer),(t=this.lifetimeController)==null||t.abort();const e=this.session;this.session=null,this.renewal=null,this.refreshPromise=null;for(const s of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.removeEventListener(s,this.hostChanged);this.publish(Jg),e&&this.releaseSession(e.sessionId)}releaseSession(e){cl().supported&&Ce(new URL("session",this.base),{method:"DELETE",headers:{"X-Cogpit-Plugin-Session":e},signal:AbortSignal.timeout(5e3),keepalive:!0}).catch(()=>{})}async ensureSession(){if(this.assertCurrent(),this.session&&this.session.expiresAt-Date.now()>25e3)return;if(this.renewal)return this.renewal;const e=this.controller.signal,t=new Headers;t.set("Content-Type","application/json"),this.session&&t.set("X-Cogpit-Plugin-Session",this.session.sessionId);const s=(async()=>{const r=await Ce(new URL("session",this.base),{method:"POST",headers:t,body:JSON.stringify({client:vo()}),signal:AbortSignal.any([e,AbortSignal.timeout(2e4)])}),o=VV.parse(await Ga(r));try{this.assertCurrent(e)}catch(i){throw this.releaseSession(o.sessionId),i}this.session=o})();this.renewal=s;try{await s}finally{this.renewal===s&&(this.renewal=null)}}async request(e,t={}){const s=this.controller.signal;await this.ensureSession(),this.assertCurrent(s);const r=new Headers(t.headers);r.set("X-Cogpit-Plugin-Session",this.session.sessionId);const o=await Ce(new URL(e,this.base),{...t,headers:r,signal:AbortSignal.any([s,...t.signal?[t.signal]:[],AbortSignal.timeout(3e4)])});return this.assertCurrent(s),o}async json(e,t,s="POST",r){const o=this.controller.signal,i=await this.request(e,{method:s,signal:r,...t===void 0?{}:{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}}}),l=await Ga(i);return this.assertCurrent(o),l}refresh(){const e=cl();if(!e.supported)return this.stop(),this.publish({status:null,error:e.error,activation:""}),Promise.resolve();if(this.refreshPromise)return this.refreshPromise;const t=this.controller.signal,s=(async()=>{var r;try{const o=BV.parse(await this.json("status",void 0,"GET"));if(this.assertCurrent(t),((r=this.state.status)==null?void 0:r.host.instanceId)===o.host.instanceId&&this.state.status.store.revision>o.store.revision)return;this.publish({status:o,error:null,activation:`${this.scope}:${this.identity??"personal"}:${o.host.instanceId}:${this.session.sessionId}:${o.connectionRevision??0}`})}catch(o){if(t.aborted||!this.running)return;o instanceof Qg&&o.code==="STALE_ACTIVATION"&&(this.session=null),this.publish({status:null,error:o instanceof Error?o.message:"Plugin host is unavailable",activation:""})}})();return this.refreshPromise=s,s.finally(()=>{this.refreshPromise===s&&(this.refreshPromise=null)}),s}async stageSeed(e,t){return ud.parse(await this.json("stage-seed",{pluginId:e,scope:t,client:vo()}))}async stage(e,t){const s=this.controller.signal;if(e.size>4*1024*1024)throw new Error("Choose a plugin package smaller than 4 MiB");const r=ud.parse(await Ga(await this.request("stage",{method:"POST",body:e,headers:{"Content-Type":"application/octet-stream","X-Cogpit-Plugin-Client":JSON.stringify(vo()),"X-Cogpit-Plugin-Scope":JSON.stringify(t)}})));return this.assertCurrent(s),r}async payload(e,t){const s=this.controller.signal,r=await this.request(`payload/${encodeURIComponent(e)}`,{signal:t});r.ok||await Ga(r);const o=await e1(r,4*1024*1024);return this.assertCurrent(s),t==null||t.throwIfAborted(),o}async settings(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return Qw.parse(await this.json(`settings?${s}`,void 0,"GET",t))}async saveSettings(e,t,s,r){return Qw.parse(await this.json("settings",{...e,values:t,expectedRevision:s},"POST",r))}async media(e,t,s){var l;const r=this.controller.signal,o=await this.request(`leases/${encodeURIComponent(e)}/call`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:s});o.ok||await Ga(o);const i=await e1(o,E0);return this.assertCurrent(r),s==null||s.throwIfAborted(),em({mimeType:(l=o.headers.get("Content-Type"))==null?void 0:l.split(";")[0],bytes:i})}acceptStore(e){const t=e_.parse(e),s=this.state.status;s&&t.revision>=s.store.revision&&this.publish({...this.state,status:{...s,store:t,runtime:{...s.runtime,registryRevision:t.revision}}})}async beginTrial(e,t){return HV.parse(await this.json(`transactions/${e.transactionId}/trial`,void 0,"POST",t)).deadline}async commit(e,t){this.acceptStore(await this.json(`transactions/${e.transactionId}/commit`,{expectedRevision:e.registryRevision},"POST",t)),await this.refresh()}async transactionOutcome(e){return KV.parse(await this.json(`transactions/${e.transactionId}`,void 0,"GET"))}async cancel(e){await this.json(`transactions/${e.transactionId}`,void 0,"DELETE")}async enrollDeveloper(e){this.acceptStore(await this.json("publishers",{...e,development:!0})),await this.refresh()}async changeInstalled(e,t,s,r){const o=`installed/${encodeURIComponent(e)}${t==="uninstall"?"":`/${t}`}`;this.acceptStore(await this.json(o,{...s,expectedRevision:r},t==="uninstall"?"DELETE":"POST")),await this.refresh()}async rollback(e,t,s){return ud.parse(await this.json(`installed/${encodeURIComponent(e)}/rollback`,{digest:t,scope:s,client:vo()}))}async lease(e,t,s,r,o){return tS.parse(await this.json("leases",{pluginId:e,projectId:t,contextEpoch:s,...o?{workspacePath:o}:{},client:vo()},"POST",r))}async renewLease(e,t){return tS.parse(await this.json(`leases/${encodeURIComponent(e)}/renew`,void 0,"POST",t))}async revokeLease(e){await this.json(`leases/${encodeURIComponent(e)}`,void 0,"DELETE")}async call(e,t,s){if(t.method==="connections.media")throw new Error("Use the binary media transport for audio");const r=xe({value:eo()}).parse(await this.json(`leases/${encodeURIComponent(e)}/call`,t,"POST",s));return JC(t.method,r.value)}async resolveSession(e,t,s){return xe({dirName:Le().min(1).max(8192),fileName:Le().min(1).max(8192)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session`,{handle:t},"POST",s))}async sessionHandle(e,t,s){return xe({handle:Le().regex(/^s_[a-f0-9]{48}$/)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session-handle`,t,"POST",s)).handle}async resolveWorkspace(e,t){return t_.nullable().parse(await this.json("workspace/resolve",{workspacePath:e},"POST",t))}async connections(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return eS.parse(await this.json(`connections?${s}`,void 0,"GET",t))}async connectionOptions(e,t,s,r){return qV.parse(await this.json("connections/options",{...e,connectionId:t,resourceId:s},"POST",r))}async changeConnection(e,t,s,r,o,i){const l=eS.parse(await this.json(`connections/${s}`,{...e,connectionId:t,...r,expectedRevision:o},"POST",i));return await this.refresh(),l}async clearPluginData(e,t,s){await this.json("connections/clear-data",{pluginId:e,expectedRevision:t},"POST",s),await this.refresh()}}const yo=0,Te=1,ot=2,ln=3,$t=4,bs=5,Dc=6,An=7,Hn=8,mt=9,rt=10,Ht=11,ft=12,Ut=13,Fc=14,ts=15,Un=16,Bn=17,ls=18,cs=19,os=20,ht=21,et=22,wn=23,Jn=24,gn=25,ZV=0;function In(n){return n>=48&&n<=57}function Do(n){return In(n)||n>=65&&n<=70||n>=97&&n<=102}function I0(n){return n>=65&&n<=90}function YV(n){return n>=97&&n<=122}function XV(n){return I0(n)||YV(n)}function JV(n){return n>=128}function Kd(n){return XV(n)||JV(n)||n===95}function i_(n){return Kd(n)||In(n)||n===45}function QV(n){return n>=0&&n<=8||n===11||n>=14&&n<=31||n===127}function Gd(n){return n===10||n===13||n===12}function vi(n){return Gd(n)||n===32||n===9}function qs(n,e){return!(n!==92||Gd(e)||e===ZV)}function dd(n,e,t){return n===45?Kd(e)||e===45||qs(e,t):Kd(n)?!0:n===92?qs(n,e):!1}function th(n,e,t){return n===43||n===45?In(e)?2:e===46&&In(t)?3:0:n===46?In(e)?2:0:In(n)?1:0}function a_(n){return n===65279||n===65534?1:0}const t1=new Array(128),eH=128,fd=130,l_=131,P0=132,c_=133;for(let n=0;n<t1.length;n++)t1[n]=vi(n)&&fd||In(n)&&l_||Kd(n)&&P0||QV(n)&&c_||n||eH;function nh(n){return n<128?t1[n]:P0}function Xi(n,e){return e<n.length?n.charCodeAt(e):0}function n1(n,e,t){return t===13&&Xi(n,e+1)===10?2:1}function Ji(n,e,t){let s=n.charCodeAt(e);return I0(s)&&(s=s|32),s===t}function oc(n,e,t,s){if(t-e!==s.length||e<0||t>n.length)return!1;for(let r=e;r<t;r++){const o=s.charCodeAt(r-e);let i=n.charCodeAt(r);if(I0(i)&&(i=i|32),i!==o)return!1}return!0}function tH(n,e){for(;e>=0&&vi(n.charCodeAt(e));e--);return e+1}function Nu(n,e){for(;e<n.length&&vi(n.charCodeAt(e));e++);return e}function sh(n,e){for(;e<n.length&&In(n.charCodeAt(e));e++);return e}function yi(n,e){if(e+=2,Do(Xi(n,e-1))){for(const s=Math.min(n.length,e+5);e<s&&Do(Xi(n,e));e++);const t=Xi(n,e);vi(t)&&(e+=n1(n,e,t))}return e}function Cu(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(!i_(t)){if(qs(t,Xi(n,e+1))){e=yi(n,e)-1;continue}break}}return e}function nm(n,e){let t=n.charCodeAt(e);if((t===43||t===45)&&(t=n.charCodeAt(e+=1)),In(t)&&(e=sh(n,e+1),t=n.charCodeAt(e)),t===46&&In(n.charCodeAt(e+1))&&(e+=2,e=sh(n,e)),Ji(n,e,101)){let s=0;t=n.charCodeAt(e+1),(t===45||t===43)&&(s=1,t=n.charCodeAt(e+2)),In(t)&&(e=sh(n,e+1+s+1))}return e}function rh(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(t===41){e++;break}qs(t,Xi(n,e+1))&&(e=yi(n,e))}return e}function $0(n){if(n.length===1&&!Do(n.charCodeAt(0)))return n[0];let e=parseInt(n,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const s1=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],nH=16*1024;function Zd(n=null,e){return n===null||n.length<e?new Uint32Array(Math.max(e+1024,nH)):n}const nS=10,sH=12,sS=13;function rS(n){const e=n.source,t=e.length,s=e.length>0?a_(e.charCodeAt(0)):0,r=Zd(n.lines,t),o=Zd(n.columns,t);let i=n.startLine,l=n.startColumn;for(let c=s;c<t;c++){const u=e.charCodeAt(c);r[c]=i,o[c]=l++,(u===nS||u===sS||u===sH)&&(u===sS&&c+1<t&&e.charCodeAt(c+1)===nS&&(c++,r[c]=i,o[c]=l),i++,l=1)}r[t]=i,o[t]=l,n.lines=r,n.columns=o,n.computed=!0}class rH{constructor(e,t,s,r){this.setSource(e,t,s,r),this.lines=null,this.columns=null}setSource(e="",t=0,s=1,r=1){this.source=e,this.startOffset=t,this.startLine=s,this.startColumn=r,this.computed=!1}getLocation(e,t){return this.computed||rS(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,s){return this.computed||rS(this),{source:s,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}}const Rs=16777215,Os=24,Uc=1,sm=2,ko=new Uint8Array(32);ko[ot]=et;ko[ht]=et;ko[cs]=os;ko[wn]=Jn;const Vs=new Uint8Array(32);Vs[ot]=Uc;Vs[ht]=Uc;Vs[cs]=Uc;Vs[wn]=Uc;Vs[et]=sm;Vs[os]=sm;Vs[Jn]=sm;function oS(n,e,t){return n<e?e:n>t?t:n}class oH{constructor(e,t){this.setSource(e,t)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",t=()=>{}){e=String(e||"");const s=e.length,r=Zd(this.offsetAndType,e.length+1),o=Zd(this.balance,e.length+1);let i=0,l=-1,c=0,u=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),t(e,(d,f,m)=>{const p=i++;if(r[p]=d<<Os|m,l===-1&&(l=f),o[p]=u,d===c){const h=o[u];o[u]=p,u=h,c=ko[r[h]>>Os]}else this.isBlockOpenerTokenType(d)&&(u=p,c=ko[d])}),r[i]=yo<<Os|s,o[i]=i;for(let d=0;d<i;d++){const f=o[d];if(f<=d){const m=o[f];m!==d&&(o[d]=m)}else f>i&&(o[d]=i)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=i,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>Os:yo}lookupTypeNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return s}return yo}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.source.length}lookupOffsetNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return t-this.tokenIndex}return yo}lookupValue(e,t){return e+=this.tokenIndex,e<this.tokenCount?oc(this.source,this.offsetAndType[e-1]&Rs,this.offsetAndType[e]&Rs,t):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.offsetAndType[this.tokenCount]&Rs:this.firstCharOffset}getTokenEnd(e){return e===this.tokenIndex?this.tokenEnd:this.offsetAndType[oS(e,0,this.tokenCount)]&Rs}getTokenType(e){return e===this.tokenIndex?this.tokenType:this.offsetAndType[oS(e,0,this.tokenCount)]>>Os}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBlockOpenerTokenType(e){return Vs[e]===Uc}isBlockCloserTokenType(e){return Vs[e]===sm}getBlockTokenPairIndex(e){const t=this.getTokenType(e);if(Vs[t]===1){const s=this.balance[e],r=this.getTokenType(s);return ko[t]===r?s:-1}else if(Vs[t]===2){const s=this.balance[e],r=this.getTokenType(s);return ko[r]===t?s:-1}return-1}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,t){return t?this.lookupType(t)===mt&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===mt&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.offsetAndType[t-1]&Rs,t=this.offsetAndType[t],this.tokenType=t>>Os,this.tokenEnd=t&Rs):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Os,this.tokenEnd=e&Rs):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=yo,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===Ut||this.tokenType===gn;)this.next()}skipUntilBalanced(e,t){let s=e,r=0,o=0;e:for(;s<this.tokenCount;s++){if(r=this.balance[s],r<e)break e;switch(o=s>0?this.offsetAndType[s-1]&Rs:this.firstCharOffset,t(this.source.charCodeAt(o))){case 1:break e;case 2:s++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[s]>>Os)&&(s=r)}}this.skip(s-this.tokenIndex)}forEachToken(e){for(let t=0,s=this.firstCharOffset;t<this.tokenCount;t++){const r=s,o=this.offsetAndType[t],i=o&Rs,l=o>>Os;s=i,e(l,r,i,t)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((t,s,r,o)=>{e[o]={idx:o,type:s1[t],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function rm(n,e){function t(f){return f<l?n.charCodeAt(f):0}function s(){if(u=nm(n,u),dd(t(u),t(u+1),t(u+2))){d=ft,u=Cu(n,u);return}if(t(u)===37){d=Ht,u++;return}d=rt}function r(){const f=u;if(u=Cu(n,u),oc(n,f,u,"url")&&t(u)===40){if(u=Nu(n,u+1),t(u)===34||t(u)===39){d=ot,u=f+4;return}i();return}if(t(u)===40){d=ot,u++;return}d=Te}function o(f){for(f||(f=t(u++)),d=bs;u<n.length;u++){const m=n.charCodeAt(u);switch(nh(m)){case f:u++;return;case fd:if(Gd(m)){u+=n1(n,u,m),d=Dc;return}break;case 92:if(u===n.length-1)break;const p=t(u+1);Gd(p)?u+=n1(n,u+1,p):qs(m,p)&&(u=yi(n,u)-1);break}}}function i(){for(d=An,u=Nu(n,u);u<n.length;u++){const f=n.charCodeAt(u);switch(nh(f)){case 41:u++;return;case fd:if(u=Nu(n,u),t(u)===41||u>=n.length){u<n.length&&u++;return}u=rh(n,u),d=Hn;return;case 34:case 39:case 40:case c_:u=rh(n,u),d=Hn;return;case 92:if(qs(f,t(u+1))){u=yi(n,u)-1;break}u=rh(n,u),d=Hn;return}}}n=String(n||"");const l=n.length;let c=a_(t(0)),u=c,d;for(;u<l;){const f=n.charCodeAt(u);switch(nh(f)){case fd:d=Ut,u=Nu(n,u+1);break;case 34:o();break;case 35:i_(t(u+1))||qs(t(u+1),t(u+2))?(d=$t,u=Cu(n,u+1)):(d=mt,u++);break;case 39:o();break;case 40:d=ht,u++;break;case 41:d=et,u++;break;case 43:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 44:d=ls,u++;break;case 45:th(f,t(u+1),t(u+2))?s():t(u+1)===45&&t(u+2)===62?(d=ts,u=u+3):dd(f,t(u+1),t(u+2))?r():(d=mt,u++);break;case 46:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 47:t(u+1)===42?(d=gn,u=n.indexOf("*/",u+2),u=u===-1?n.length:u+2):(d=mt,u++);break;case 58:d=Un,u++;break;case 59:d=Bn,u++;break;case 60:t(u+1)===33&&t(u+2)===45&&t(u+3)===45?(d=Fc,u=u+4):(d=mt,u++);break;case 64:dd(t(u+1),t(u+2),t(u+3))?(d=ln,u=Cu(n,u+1)):(d=mt,u++);break;case 91:d=cs,u++;break;case 92:qs(f,t(u+1))?r():(d=mt,u++);break;case 93:d=os,u++;break;case 123:d=wn,u++;break;case 125:d=Jn,u++;break;case l_:s();break;case P0:r();break;default:d=mt,u++}e(d,c,c=u)}}let Ei=null;class jn{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return jn.createItem(e)}allocateCursor(e,t){let s;return Ei!==null?(s=Ei,Ei=Ei.cursor,s.prev=e,s.next=t,s.cursor=this.cursor):s={prev:e,next:t,cursor:this.cursor},this.cursor=s,s}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=Ei,Ei=e}updateCursors(e,t,s,r){let{cursor:o}=this;for(;o!==null;)o.prev===e&&(o.prev=t),o.next===s&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let t=this.head;t!==null;t=t.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let t=null;this.head=null;for(let s of e){const r=jn.createItem(s);t!==null?t.next=r:this.head=r,r.prev=t,t=r}return this.tail=t,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,t=this){const s=this.allocateCursor(null,this.head);for(;s.next!==null;){const r=s.next;s.next=r.next,e.call(t,r.data,r,this)}this.releaseCursor()}forEachRight(e,t=this){const s=this.allocateCursor(this.tail,null);for(;s.prev!==null;){const r=s.prev;s.prev=r.prev,e.call(t,r.data,r,this)}this.releaseCursor()}reduce(e,t,s=this){let r=this.allocateCursor(null,this.head),o=t,i;for(;r.next!==null;)i=r.next,r.next=i.next,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}reduceRight(e,t,s=this){let r=this.allocateCursor(this.tail,null),o=t,i;for(;r.prev!==null;)i=r.prev,r.prev=i.prev,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}some(e,t=this){for(let s=this.head;s!==null;s=s.next)if(e.call(t,s.data,s,this))return!0;return!1}map(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)s.appendData(e.call(t,r.data,r,this));return s}filter(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)e.call(t,r.data,r,this)&&s.appendData(r.data);return s}nextUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(null,e);for(;r.next!==null;){const o=r.next;if(r.next=o.next,t.call(s,o.data,o,this))break}this.releaseCursor()}prevUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(e,null);for(;r.prev!==null;){const o=r.prev;if(r.prev=o.prev,t.call(s,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new jn;for(let t of this)e.appendData(t);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(jn.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(jn.createItem(e))}insert(e,t=null){if(t!==null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,t){return this.insert(jn.createItem(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(jn.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(jn.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,t){return e.head===null?this:(t!=null?(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)}}function om(n,e){const t=Object.create(SyntaxError.prototype),s=new Error;return Object.assign(t,{name:n,message:e,get stack(){return(s.stack||"").replace(/^(.+\n){1,3}/,`${n}: ${e}
|
|
70
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of n.seen.entries()){const f=d[1];if(e===d[0]){o(d);continue}if(n.external){const p=(c=n.external.registry.get(d[0]))==null?void 0:c.id;if(e!==d[0]&&p){o(d);continue}}if((u=n.metadataRegistry.get(d[0]))==null?void 0:u.id){o(d);continue}if(f.cycle){o(d);continue}f.count>1&&n.reused==="ref"&&o(d)}n.external&&(n.sharedDefsExtractedFor=n.external)}function hC(n){const e=n.anyOf;if(!Array.isArray(e)||e.length===0||n.type!==void 0)return;const t=[];for(const s of e){if(!s||typeof s!="object")return;hC(s);const r=Object.keys(s);if(r.length!==1||r[0]!=="type")return;const o=s.type;for(const i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;t.includes(i)||t.push(i)}}delete n.anyOf,n.type=t.length===1?t[0]:t}const gC=new Set(["type","properties","required","additionalProperties"]),z2=["oneOf","anyOf"];function D2(n){const e=n.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Vg(n){var o;const e=[];for(const i of n){if(typeof i!="object"||i.type!=="object")return null;for(const l in i)if(!gC.has(l))return null;e.push(i)}const t={},s=new Set;for(const i of e){for(const l in i.properties){if(Object.prototype.hasOwnProperty.call(t,l))continue;const c=[];for(const d of e){const f=((o=d.properties)==null?void 0:o[l])??D2(d);f!=null&&(c.some(m=>JSON.stringify(m)===JSON.stringify(f))||c.push(f))}const u=c.length===1?c[0]:Vg(c)??{allOf:c};co(t,l,u)}for(const l of i.required??[])s.add(l)}const r={type:"object",properties:t};if(s.size&&(r.required=[...s]),e.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{const i=[];for(const l of e){const c=D2(l);c&&!i.some(u=>JSON.stringify(u)===JSON.stringify(c))&&i.push(c)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function KB(n){const e=n.allOf;if(!Array.isArray(e)||e.length<2)return;for(const r of gC)if(r in n)return;const t=e.filter(r=>z2.some(o=>Array.isArray(r[o])));let s=null;if(!t.length)s=Vg(e);else{const r=t[0],o=z2.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;const i=e.filter(c=>c!==r),l=r[o].map(c=>Vg([...i,c]));if(l.some(c=>!c))return;s={[o]:l}}s&&(delete n.allOf,Rl(n,s))}function xC(n,e){var l,c,u,d;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=f=>{const m=n.seen.get(f);if(m.ref===null)return;const p=m.def??m.schema,h={...p},g=m.ref;if(m.ref=null,g){s(g);const b=n.seen.get(g),w=b.schema;if(w.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(w)):Rl(p,w),Rl(p,h),f._zod.parent===g)for(const j in p)j==="$ref"||j==="allOf"||j in h||delete p[j];if(w.$ref&&b.def)for(const j in p)j==="$ref"||j==="allOf"||j in b.def&&JSON.stringify(p[j])===JSON.stringify(b.def[j])&&delete p[j]}const x=f._zod.parent;if(x&&x!==g){s(x);const b=n.seen.get(x);if(b!=null&&b.schema.$ref&&(p.$ref=b.schema.$ref,b.def))for(const w in p)w==="$ref"||w==="allOf"||w in b.def&&JSON.stringify(p[w])===JSON.stringify(b.def[w])&&delete p[w]}n.override({zodSchema:f,jsonSchema:p,path:m.path??[]})};if(!n.external||n.sharedEmitDoneFor!==n.external){for(const f of[...n.seen.entries()].reverse())s(f[0]);if(n.target!=="openapi-3.0")for(const f of n.seen.entries())hC(f[1].def??f[1].schema);for(const f of n.deferred)f();if(n.intersections.length){const f=new Map;for(const m of n.seen.values())for(const p of[m.schema,m.def]){const h=p==null?void 0:p.allOf;if(!Array.isArray(h))continue;const g=f.get(h);g?g.push(p):f.set(h,[p])}for(const m of n.intersections)for(const p of f.get(m)??[])KB(p)}}const r={};if(n.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":n.target,(l=n.external)!=null&&l.uri){const f=(c=n.external.registry.get(e))==null?void 0:c.id;if(!f)throw new Error("Schema is missing an `id` property");r.$id=n.external.uri(f)}Rl(r,t.defId?t.schema:t.def??t.schema);const o=(u=n.metadataRegistry.get(e))==null?void 0:u.id;o!==void 0&&r.id===o&&delete r.id;const i=((d=n.external)==null?void 0:d.defs)??{};if(!n.external||n.sharedEmitDoneFor!==n.external)for(const f of n.seen.entries()){const m=f[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,co(i,m.defId,m.def))}n.external&&(n.sharedEmitDoneFor=n.external),n.external||Object.keys(i).length>0&&(n.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const f=JSON.parse(JSON.stringify(r));return Object.defineProperty(f,"~standard",{value:{...e["~standard"],jsonSchema:{input:Wd(e,"input",n.processors),output:Wd(e,"output",n.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function qn(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const s=n._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return qn(s.element,t);if(s.type==="set")return qn(s.valueType,t);if(s.type==="lazy")return qn(s.getter(),t);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault"||s.type==="catch")return qn(s.innerType,t);if(s.type==="intersection")return qn(s.left,t)||qn(s.right,t);if(s.type==="record"||s.type==="map")return qn(s.keyType,t)||qn(s.valueType,t);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:qn(s.in,t)||qn(s.out,t);if(s.type==="object"){for(const r in s.shape)if(qn(s.shape[r],t))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(qn(r,t))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(qn(r,t))return!0;return!!(s.rest&&qn(s.rest,t))}return!1}const GB=(n,e={})=>t=>{const s=mC({...t,processors:e});return pn(n,s),pC(s,n),xC(s,n)},Wd=(n,e,t={})=>s=>{const{libraryOptions:r,target:o}=s??{},i=mC({...r??{},target:o,io:e,processors:t});return pn(n,i),pC(i,n),xC(i,n)},fa=(n,e,t)=>{(n[e]===void 0||t>n[e])&&(n[e]=t)},ma=(n,e,t)=>{(n[e]===void 0||t<n[e])&&(n[e]=t)},F2=(n,e)=>{fa(n,"minimum",e),ma(n,"maximum",e)},bC=(n,e)=>{n.multipleOf??(n.multipleOf=[]),n.multipleOf.includes(e)||n.multipleOf.push(e)},vC=(n,e)=>{n.patterns??(n.patterns=new Set),n.patterns.add(e)},yC=(n,e)=>{n.mime=n.mime?n.mime.filter(t=>e.includes(t)):[...e]},wC=(n,e)=>{n.format=e,e.includes("int")&&(n.isInt=!0)},U2=(n,e)=>fa(n,"minimum",e.minimum),B2=(n,e)=>ma(n,"maximum",e.maximum),W2=n=>(e,t)=>{wC(e,t.format);const[s,r]=n[t.format];fa(e,"minimum",s),ma(e,"maximum",r)},rp={greater_than:(n,e)=>fa(n,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(n,e)=>ma(n,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(n,e)=>bC(n,e.value),number_format:W2(U5),bigint_format:W2(aD),min_length:U2,max_length:B2,length_equals:(n,e)=>F2(n,e.length),min_size:U2,max_size:B2,size_equals:(n,e)=>F2(n,e.size),string_format:(n,e)=>{wC(n,e.format),e.pattern&&vC(n,e.pattern),(e.format==="base64"||e.format==="base64url")&&(n.contentEncoding=e.format),(e.local||e.precision===-1)&&(n.laxFormat=!0)},mime_type:(n,e)=>yC(n,e.mime)};function Ws(n){var o;const e={},t=n._zod.def,s=n._zod.traits.has("$ZodCheck")?[n,...t.checks??[]]:t.checks??[];for(const i of s)(o=rp[i._zod.def.check])==null||o.call(rp,e,i._zod.def);const r=n._zod.bag;r.minimum!==void 0&&fa(e,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&fa(e,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&ma(e,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&ma(e,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&bC(e,r.multipleOf),r.format!==void 0&&(e.format??(e.format=r.format),r.format.includes("int")&&(e.isInt=!0)),r.mime&&yC(e,r.mime);for(const i of r.patterns??[])vC(e,i);return e}const ZB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},YB=new Map([[nC,lF],[y0,cF]]),SC=n=>YB.get(n)??n,XB=(n,e,t,s)=>{const r=t;r.type="string";const{minimum:o,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=Ws(n);if(typeof o=="number"&&(r.minLength=o),typeof i=="number"&&(r.maxLength=i),l&&(r.format=ZB[l]??l,r.format===""&&delete r.format,(l==="time"||d)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const f=[...c].map(SC);f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(m=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},JB=(n,e,t,s)=>{const r=t,{minimum:o,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=Ws(n);r.type=d?"integer":"number";const f=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(f?p?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),m?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof i=="number"&&(r.maximum=i),l){const h=new Set;for(const b of l)Number.isFinite(b)&&b!==0?h.add(Math.abs(b)):Mo(n,e,r,s,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);const[g,...x]=h;g!==void 0&&(r.multipleOf=g),x.length&&(r.allOf=[...r.allOf??[],...x.map(b=>({multipleOf:b}))])}},QB=(n,e,t,s)=>{t.type="boolean"},eW=(n,e,t,s)=>{e.target==="openapi-3.0"?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"},tW=(n,e,t,s)=>{t.not={}},nW=(n,e,t,s)=>{},sW=(n,e,t,s)=>{const r=n._zod.def,o=Dg(r.entries);if(o.length===0){t.not={};return}o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),t.enum=o},rW=(n,e,t,s)=>{const r=n._zod.def;if(r.values.length===0){t.not={};return}const o=[];for(const i of r.values)if(i===void 0){if(Mo(n,e,t,s,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Mo(n,e,t,s,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){const i=o[0];t.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[i]:t.const=i}else o.every(i=>typeof i=="number")&&(t.type="number"),o.every(i=>typeof i=="string")&&(t.type="string"),o.every(i=>typeof i=="boolean")&&(t.type="boolean"),o.every(i=>i===null)&&(t.type="null"),t.enum=o},oW=(n,e,t,s)=>{Mo(n,e,t,s,"Custom types cannot be represented in JSON Schema")},iW=(n,e,t,s)=>{Mo(n,e,t,s,"Transforms cannot be represented in JSON Schema")},aW=(n,e,t,s)=>{const r=t,o=n._zod.def,{minimum:i,maximum:l}=Ws(n);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=pn(o.element,e,{...s,path:[...s.path,"items"]})};function qd(n){const e=n._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?qd(e.out):e.type==="catch"?qd(e.innerType):n._zod.optin}const lW=(n,e,t,s)=>{var u;const r=t,o=n._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Mo(n,e,r,s,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const d in i)co(r.properties,d,pn(i[d],e,{...s,path:[...s.path,"properties",d]}));const c=[];for(const d of Object.keys(i)){const f=o.shape[d];(e.io==="input"?qd(f)===void 0:f._zod.optout===void 0)&&c.push(d)}c.length>0&&(r.required=c),((u=o.catchall)==null?void 0:u._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=pn(o.catchall,e,{...s,path:[...s.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},cW=(n,e,t,s)=>{const r=n._zod.def,o=r.inclusive===!1,i=r.options.map((l,c)=>pn(l,e,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?t.oneOf=i:t.anyOf=i},uW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.left,e,{...s,path:[...s.path,"allOf",0]}),i=pn(r.right,e,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(o)?o.allOf:[o],...l(i)?i.allOf:[i]];t.allOf=c,e.intersections.push(c)};function Hg(n,e,t){var h;if(e.$ref){if(t.has(e))return e;t.add(e);const g=(h=n.get(e))==null?void 0:h.def;if(!g)return e;const x=Hg(n,g,t);return x===g?e:x}for(const g of["anyOf","oneOf"]){const x=e[g];if(!Array.isArray(x))continue;const b=x.map(w=>Hg(n,w,t));b.some((w,v)=>w!==x[v])&&(e={...e,[g]:b})}const s=Array.isArray(e.type)?e.type:[e.type],r=!s.includes("string")&&s.some(g=>g==="number"||g==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!r&&!(o!=null&&o.some(g=>typeof g=="number")))return e;const{minimum:i,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:f,id:m,...p}=e;return p.enum?p.enum=p.enum.map(g=>typeof g=="number"?String(g):g):typeof p.const=="number"&&(p.const=String(p.const)),r&&(p.type="string",o||(p.pattern=(s.includes("number")?x0:xF).source)),p}const Kg=new WeakMap;function dW(n){var s;const e=new Map;for(const r of n.seen.values())r.def&&!e.has(r.schema)&&e.set(r.schema,r);const t=new Map;for(const r of Kg.get(n)??[]){const o=n.seen.get(r),i=(s=(o==null?void 0:o.def)??(o==null?void 0:o.schema))==null?void 0:s.propertyNames;if(!i||i===!0||t.has(i))continue;const l=Hg(e,i,new Set);l!==i&&t.set(i,l)}if(t.size)for(const r of n.seen.values())for(const o of[r.schema,r.def]){const i=o&&t.get(o.propertyNames);i&&(o.propertyNames=i)}}const fW=(n,e,t,s)=>{const r=t,o=n._zod.def;r.type="object";const i=o.keyType,l=Ws(i).patterns;if(o.mode==="loose"&&l&&l.size>0){const d=pn(o.valueType,e,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)co(r.patternProperties,SC(f).source,d)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){r.propertyNames=pn(o.keyType,e,{...s,path:[...s.path,"propertyNames"]});let d=Kg.get(e);d||(d=[],Kg.set(e,d),e.deferred.push(()=>dW(e))),d.push(n)}r.additionalProperties=pn(o.valueType,e,{...s,path:[...s.path,"additionalProperties"]})}const c=i._zod.values,u=e.io==="input"&&qd(o.valueType)!==void 0;if(c&&!o.partial&&!u){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(r.required=d.map(String))}},mW=(n,e,t,s)=>{const r=n._zod.def,o=pn(r.innerType,e,s),i=e.seen.get(n);e.target==="openapi-3.0"?(i.ref=r.innerType,t.nullable=!0):t.anyOf=[o,{type:"null"}]},pW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},w0=Symbol();function kC(n,e,t,s,r){let o=!1;const i=JSON.stringify(n,(l,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Mo(e,t,s,r,"BigInt defaults cannot be represented in JSON Schema"),w0):JSON.parse(i)}const hW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;const i=kC(r.defaultValue,n,e,t,s);i!==w0&&(t.default=i)},gW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);if(o.ref=r.innerType,e.io!=="input")return;const i=kC(r.defaultValue,n,e,t,s);i!==w0&&(t._prefault=i)},xW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{Mo(n,e,t,s,"Dynamic catch values are not supported in JSON Schema");return}t.default=i},bW=(n,e,t,s)=>{const r=n._zod.def,o=r.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?o?r.out:r.in:r.out;pn(i,e,s);const l=e.seen.get(n);l.ref=i},vW=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType,t.readOnly=!0},jC=(n,e,t,s)=>{const r=n._zod.def;pn(r.innerType,e,s);const o=e.seen.get(n);o.ref=r.innerType},q2=new WeakSet([Object.prototype,Error.prototype]);function wu(n,e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){const s=t(this);return Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,e,{value:s,configurable:!0,writable:!0})}})}const yW=(n,e)=>{TD.init(n,e),n.name="ZodError";const t=Object.getPrototypeOf(n);q2.has(t)||(q2.add(t),wu(t,"format",s=>r=>PD(s,r)),wu(t,"flatten",s=>r=>ID(s,r)),wu(t,"addIssue",s=>r=>{s.issues.push(r),s.message=JSON.stringify(s.issues,Fg,2)}),wu(t,"addIssues",s=>r=>{s.issues.push(...r),s.message=JSON.stringify(s.issues,Fg,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ts=he("ZodError",yW,void 0,{Parent:Error}),wW=m0(Ts),SW=p0(Ts),kW=h0(Ts),jW=g0(Ts),NW=zD(Ts),CW=DD(Ts),_W=FD(Ts),EW=UD(Ts),TW=BD(Ts),AW=WD(Ts),IW=qD(Ts),PW=VD(Ts);function $W(){Qs.localeError||Tr(ZU())}function Zf(){Qs.memoizer||Tr({memoizer:HU()})}const qt=he("ZodType",(n,e)=>($W(),Bt.init(n,e),n.def=e,n.type=e.type,n),{check(...n){const e=this.def;return this.clone(hs(e,{checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,e){return Ho(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},refine(n,e){return this.check(Eq(n,e))},superRefine(n,e){return this.check(Tq(n,e))},overwrite(n){return this.check(Ma(n))},optional(){return K2(this)},exactOptional(){return gq(this)},nullable(){return G2(this)},nullish(){return K2(G2(this))},nonoptional(n){return Sq(this,n)},array(){return at(this)},or(n){return to([this,n])},and(n){return fq(this,n)},transform(n){return Z2(this,hq(n))},default(n){return vq(this,n)},prefault(n){return wq(this,n)},catch(n){return jq(this,n)},pipe(n){return Z2(this,n)},readonly(){return _q(this)},describe(n){const e=this.clone();return ol.add(e,{description:n}),e},meta(...n){if(n.length===0)return ol.get(this);const e=this.clone();return ol.add(e,n[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n,...e){return e.length===0?n(this):n(this,...e)},get"~standard"(){return W5(this,"~standard",{...X5(this),jsonSchema:{input:Wd(this,"input"),output:Wd(this,"output")}})},set"~standard"(n){Lo(this,"~standard",n)},parse:function n(e,t){return wW(this,e,t,{callee:n})},parseAsync:async function n(e,t){return await SW(this,e,t,{callee:n})},safeParse(n,e){return kW(this,n,e)},async safeParseAsync(n,e){return jW(this,n,e)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(n){Lo(this,"spa",n)},validate(n,e){return OD(this,n,e)},validateAsync(n,e){return MD(this,n,e)},encode:function n(e,t){return NW(this,e,t,{callee:n})},decode:function n(e,t){return CW(this,e,t,{callee:n})},encodeAsync:async function n(e,t){return await _W(this,e,t,{callee:n})},decodeAsync:async function n(e,t){return await EW(this,e,t,{callee:n})},safeEncode(n,e){return TW(this,n,e)},safeDecode(n,e){return AW(this,n,e)},async safeEncodeAsync(n,e){return IW(this,n,e)},async safeDecodeAsync(n,e){return PW(this,n,e)},toJSONSchema(n){return GB(this,{})(n)},get description(){var n;return(n=ol.get(this))==null?void 0:n.description},get _def(){return this._zod.def}}),NC=he("_ZodString",(n,e)=>{v0.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>XB(n,t,s)},q5({format:n=>Ws(n).format??null,minLength:n=>Ws(n).minimum??null,maxLength:n=>Ws(n).maximum??null},{regex(...n){return this.check(IB(...n))},includes(...n){return this.check(RB(...n))},startsWith(...n){return this.check(OB(...n))},endsWith(...n){return this.check(LB(...n))},min(...n){return this.check(Bd(...n))},max(...n){return this.check(dC(...n))},length(...n){return this.check(fC(...n))},nonempty(...n){return this.check(Bd(1,...n))},lowercase(n){return this.check(PB(n))},uppercase(n){return this.check($B(n))},trim(){return this.check(zB())},normalize(...n){return this.check(MB(...n))},toLowerCase(){return this.check(DB())},toUpperCase(){return this.check(FB())},slugify(){return this.check(UB())}})),RW=he("ZodString",(n,e)=>{v0.init(n,e),NC.init(n,e)},{email(n){return this.check(QU(DW,n))},url(n){return this.check(oB(UW,n))},jwt(n){return this.check(yB(nq,n))},emoji(n){return this.check(iB(BW,n))},guid(n){return this.check(eB(FW,n))},uuid(n){return this.check(tB(Su,n))},uuidv4(n){return this.check(nB(Su,n))},uuidv6(n){return this.check(sB(Su,n))},uuidv7(n){return this.check(rB(Su,n))},nanoid(n){return this.check(aB(WW,n))},cuid(n){return this.check(lB(qW,n))},cuid2(n){return this.check(cB(VW,n))},ulid(n){return this.check(uB(HW,n))},base64(n){return this.check(xB(QW,n))},base64url(n){return this.check(bB(eq,n))},xid(n){return this.check(dB(KW,n))},ksuid(n){return this.check(fB(GW,n))},ipv4(n){return this.check(mB(ZW,n))},ipv6(n){return this.check(pB(YW,n))},cidrv4(n){return this.check(hB(XW,n))},cidrv6(n){return this.check(gB(JW,n))},e164(n){return this.check(vB(tq,n))},datetime(n){return this.check(wB(OW,n))},date(n){return this.check(SB(LW,n))},time(n){return this.check(kB(MW,n))},duration(n){return this.check(jB(zW,n))}});function Le(n){return JU(RW,n)}const Jt=he("ZodStringFormat",(n,e)=>{Wt.init(n,e),NC.init(n,e)}),OW=he("ZodISODateTime",(n,e)=>{QF.init(n,e),Jt.init(n,e)}),LW=he("ZodISODate",(n,e)=>{eU.init(n,e),Jt.init(n,e)}),MW=he("ZodISOTime",(n,e)=>{tU.init(n,e),Jt.init(n,e)}),zW=he("ZodISODuration",(n,e)=>{nU.init(n,e),Jt.init(n,e)}),DW=he("ZodEmail",(n,e)=>{DF.init(n,e),Jt.init(n,e)}),FW=he("ZodGUID",(n,e)=>{MF.init(n,e),Jt.init(n,e)}),Su=he("ZodUUID",(n,e)=>{zF.init(n,e),Jt.init(n,e)}),UW=he("ZodURL",(n,e)=>{VF.init(n,e),Jt.init(n,e)}),BW=he("ZodEmoji",(n,e)=>{HF.init(n,e),Jt.init(n,e)}),WW=he("ZodNanoID",(n,e)=>{KF.init(n,e),Jt.init(n,e)}),qW=he("ZodCUID",(n,e)=>{GF.init(n,e),Jt.init(n,e)}),VW=he("ZodCUID2",(n,e)=>{ZF.init(n,e),Jt.init(n,e)}),HW=he("ZodULID",(n,e)=>{YF.init(n,e),Jt.init(n,e)}),KW=he("ZodXID",(n,e)=>{XF.init(n,e),Jt.init(n,e)}),GW=he("ZodKSUID",(n,e)=>{JF.init(n,e),Jt.init(n,e)}),ZW=he("ZodIPv4",(n,e)=>{sU.init(n,e),Jt.init(n,e)}),YW=he("ZodIPv6",(n,e)=>{oU.init(n,e),Jt.init(n,e)}),XW=he("ZodCIDRv4",(n,e)=>{iU.init(n,e),Jt.init(n,e)}),JW=he("ZodCIDRv6",(n,e)=>{lU.init(n,e),Jt.init(n,e)}),QW=he("ZodBase64",(n,e)=>{cU.init(n,e),Jt.init(n,e)}),eq=he("ZodBase64URL",(n,e)=>{dU.init(n,e),Jt.init(n,e)}),tq=he("ZodE164",(n,e)=>{fU.init(n,e),Jt.init(n,e)}),nq=he("ZodJWT",(n,e)=>{pU.init(n,e),Jt.init(n,e)}),CC=he("ZodNumber",(n,e)=>{sC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>JB(n,t,s,r),n.isFinite=!0},q5({minValue:n=>{const{minimum:e,exclusiveMinimum:t}=Ws(n);return Math.max(e??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:n=>{const{maximum:e,exclusiveMaximum:t}=Ws(n);return Math.min(e??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:n=>{const{isInt:e,multipleOf:t}=Ws(n);return!!e||!!(t!=null&&t.some(Number.isSafeInteger))},format:n=>Ws(n).format??null},{gt(n,e){return this.check(O2(n,e))},gte(n,e){return this.check(sp(n,e))},min(n,e){return this.check(sp(n,e))},lt(n,e){return this.check(R2(n,e))},lte(n,e){return this.check(np(n,e))},max(n,e){return this.check(np(n,e))},int(n){return this.check(V2(n))},safe(n){return this.check(V2(n))},positive(n){return this.check(O2(0,n))},nonnegative(n){return this.check(sp(0,n))},negative(n){return this.check(R2(0,n))},nonpositive(n){return this.check(np(0,n))},multipleOf(n,e){return this.check(L2(n,e))},step(n,e){return this.check(L2(n,e))},finite(){return this}}));function bt(n){return NB(CC,n)}const sq=he("ZodNumberFormat",(n,e)=>{hU.init(n,e),CC.init(n,e)});function V2(n){return CB(sq,n)}const rq=he("ZodBoolean",(n,e)=>{gU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>QB(n,t,s)});function Ft(n){return _B(rq,n)}const oq=he("ZodNull",(n,e)=>{xU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>eW(n,t,s)});function _C(n){return EB(oq,n)}const iq=he("ZodUnknown",(n,e)=>{bU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>nW()});function eo(){return TB(iq)}const aq=he("ZodNever",(n,e)=>{vU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>tW(n,t,s)});function EC(n){return AB(aq,n)}const lq=he("ZodArray",(n,e)=>{Zf(),SU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>aW(n,t,s,r),n.element=e.element},{min(n,e){return this.check(Bd(n,e))},nonempty(n){return this.check(Bd(1,n))},max(n,e){return this.check(dC(n,e))},length(n,e){return this.check(fC(n,e))},unwrap(){return this.element}});function at(n,e){return BB(lq,n,e)}const TC=he("ZodObject",(n,e)=>{Zf(),NU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>lW(n,t,s,r),wD(n,"shape",t=>t._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(n){return this.clone(hs(this._zod.def,{catchall:n}))},passthrough(){return this.clone(hs(this._zod.def,{catchall:eo()}))},loose(){return this.clone(hs(this._zod.def,{catchall:eo()}))},strict(){return this.clone(hs(this._zod.def,{catchall:EC()}))},strip(){return this.clone(hs(this._zod.def,{catchall:void 0}))},extend(n){return uD(this,n)},safeExtend(n){return dD(this,n)},merge(n){return fD(this,n)},pick(n){return lD(this,n)},omit(n){return cD(this,n)},partial(...n){return g2(IC,this,n[0])},exactPartial(...n){return g2(PC,this,n[0],"exactPartial")},required(...n){return mD($C,this,n[0])}});function cq(n,e){const t={type:"object",shape:n??{},...Ye(e)};return new TC(t)}function xe(n,e){return new TC({type:"object",shape:n,catchall:EC(),...Ye(e)})}const AC=he("ZodUnion",(n,e)=>{iC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>cW(n,t,s,r),n.options=e.options});function to(n,e){return new AC({type:"union",options:n,...Ye(e)})}const uq=he("ZodDiscriminatedUnion",(n,e)=>{AC.init(n,e),_U.init(n,e)});function Rr(n,e,t){return new uq({type:"union",options:e,discriminator:n,...Ye(t)})}const dq=he("ZodIntersection",(n,e)=>{EU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>uW(n,t,s,r)});function fq(n,e){return new dq({type:"intersection",left:n,right:e})}const H2=he("ZodRecord",(n,e)=>{Zf(),TU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>fW(n,t,s,r),n.keyType=e.keyType,n.valueType=e.valueType});function Xn(n,e,t){return!e||!e._zod?new H2({type:"record",keyType:Le(),valueType:n,...Ye(e)}):new H2({type:"record",keyType:n,valueType:e,...Ye(t)})}const Gg=he("ZodEnum",(n,e)=>{AU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(s,r,o)=>sW(n,s,r),n.enum=e.entries,n.options=[...n._zod.values];const t=new Set(Object.keys(e.entries));n.extract=(s,r)=>{const o={};for(const i of s)if(t.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Gg({...e,checks:[],...Ye(r),entries:o})},n.exclude=(s,r)=>{const o={...e.entries};for(const i of s)if(t.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Gg({...e,checks:[],...Ye(r),entries:o})}});function Ct(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new Gg({type:"enum",entries:t,...Ye(e)})}const mq=he("ZodLiteral",(n,e)=>{IU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>rW(n,t,s,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ze(n,e){return new mq({type:"literal",values:Array.isArray(n)?n:[n],...Ye(e)})}const pq=he("ZodTransform",(n,e)=>{Zf(),PU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>iW(n,t,s,r),n._zod.parse=(t,s)=>{if(s.direction==="backward")throw new V5(n.constructor.name);t.addIssue=o=>{if(typeof o=="string")t.issues.push(sc(o,t.value,e));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=t.value),i.inst??(i.inst=n),t.issues.push(sc(i))}};const r=e.transform(t.value,t);return r instanceof Promise?r.then(o=>(t.value=o,t)):(t.value=r,t)}});function hq(n){return new pq({type:"transform",transform:n})}const IC=he("ZodOptional",(n,e)=>{aC.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>jC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function K2(n){return new IC({type:"optional",innerType:n})}const PC=he("ZodExactOptional",(n,e)=>{$U.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>jC(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function gq(n){return new PC({type:"optional",innerType:n})}const xq=he("ZodNullable",(n,e)=>{RU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>mW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function G2(n){return new xq({type:"nullable",innerType:n})}const bq=he("ZodDefault",(n,e)=>{OU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>hW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function vq(n,e){return new bq({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():D5(e)}})}const yq=he("ZodPrefault",(n,e)=>{LU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>gW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function wq(n,e){return new yq({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():D5(e)}})}const $C=he("ZodNonOptional",(n,e)=>{MU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>pW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function Sq(n,e){return new $C({type:"nonoptional",innerType:n,...Ye(e)})}const kq=he("ZodCatch",(n,e)=>{zU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>xW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function jq(n,e){return new kq({type:"catch",innerType:n,catchValue:typeof e=="function"?e:kD(e)})}const Nq=he("ZodPipe",(n,e)=>{DU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>bW(n,t,s,r),n.in=e.in,n.out=e.out});function Z2(n,e){return new Nq({type:"pipe",in:n,out:e})}const Cq=he("ZodReadonly",(n,e)=>{FU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>vW(n,t,s,r),n.unwrap=()=>n._zod.def.innerType});function _q(n){return new Cq({type:"readonly",innerType:n})}const RC=he("ZodCustom",(n,e)=>{UU.init(n,e),qt.init(n,e),n._zod.processJSONSchema=(t,s,r)=>oW(n,t,s,r)});function OC(n,e){return WB(RC,n??(()=>!0),e)}function Eq(n,e={}){return qB(RC,n,e)}function Tq(n,e){return VB(n,e)}var ku={exports:{}},op,Y2;function Lc(){if(Y2)return op;Y2=1;const n="2.0.0",e=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,r=e-6;return op={MAX_LENGTH:e,MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:r,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:n,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},op}var ip,X2;function Yf(){if(X2)return ip;X2=1;var n={};return ip=typeof process=="object"&&n&&n.NODE_DEBUG&&/\bsemver\b/i.test(n.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{},ip}var J2;function Mc(){return J2||(J2=1,(function(n,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:r}=Lc(),o=Yf();e=n.exports={};const i=e.re=[],l=e.safeRe=[],c=e.src=[],u=e.safeSrc=[],d=e.t={};let f=0;const m="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",r],[m,s]],h=x=>{for(const[b,w]of p)x=x.split(`${b}*`).join(`${b}{0,${w}}`).split(`${b}+`).join(`${b}{1,${w}}`);return x},g=(x,b,w)=>{const v=h(b),j=f++;o(x,j,b),d[x]=j,c[j]=b,u[j]=v,i[j]=new RegExp(b,w?"g":void 0),l[j]=new RegExp(v,w?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m}*`),g("MAINVERSION",`(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})\\.(${c[d.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})\\.(${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${c[d.NONNUMERICIDENTIFIER]}|${c[d.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASE",`(?:-(${c[d.PRERELEASEIDENTIFIER]}(?:\\.${c[d.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${c[d.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[d.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${m}+`),g("BUILD",`(?:\\+(${c[d.BUILDIDENTIFIER]}(?:\\.${c[d.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${c[d.MAINVERSION]}${c[d.PRERELEASE]}?${c[d.BUILD]}?`),g("FULL",`^${c[d.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${c[d.MAINVERSIONLOOSE]}${c[d.PRERELEASELOOSE]}?${c[d.BUILD]}?`),g("LOOSE",`^${c[d.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${c[d.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${c[d.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:\\.(${c[d.XRANGEIDENTIFIER]})(?:${c[d.PRERELEASE]})?${c[d.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[d.XRANGEIDENTIFIERLOOSE]})(?:${c[d.PRERELEASELOOSE]})?${c[d.BUILD]}?)?)?`),g("XRANGE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${c[d.GTLT]}\\s*${c[d.XRANGEPLAINLOOSE]}$`),g("COERCEPLAIN",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?`),g("COERCE",`${c[d.COERCEPLAIN]}(?:$|[^\\d])`),g("COERCEFULL",c[d.COERCEPLAIN]+`(?:${c[d.PRERELEASE]})?(?:${c[d.BUILD]})?(?:$|[^\\d])`),g("COERCERTL",c[d.COERCE],!0),g("COERCERTLFULL",c[d.COERCEFULL],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${c[d.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",g("TILDE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${c[d.LONETILDE]}${c[d.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${c[d.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",g("CARET",`^${c[d.LONECARET]}${c[d.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${c[d.LONECARET]}${c[d.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${c[d.GTLT]}\\s*(${c[d.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${c[d.GTLT]}\\s*(${c[d.LOOSEPLAIN]}|${c[d.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${c[d.XRANGEPLAIN]})\\s+-\\s+(${c[d.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${c[d.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[d.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(ku,ku.exports)),ku.exports}var ap,Q2;function S0(){if(Q2)return ap;Q2=1;const n=Object.freeze({loose:!0}),e=Object.freeze({});return ap=s=>s?typeof s!="object"?n:s:e,ap}var lp,ew;function LC(){if(ew)return lp;ew=1;const n=/^[0-9]+$/,e=(s,r)=>{if(typeof s=="number"&&typeof r=="number")return s===r?0:s<r?-1:1;const o=n.test(s),i=n.test(r);return o&&i&&(s=+s,r=+r),s===r?0:o&&!i?-1:i&&!o?1:s<r?-1:1};return lp={compareIdentifiers:e,rcompareIdentifiers:(s,r)=>e(r,s)},lp}var cp,tw;function Wn(){if(tw)return cp;tw=1;const n=Yf(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:t}=Lc(),{safeRe:s,t:r}=Mc(),o=S0(),{compareIdentifiers:i}=LC(),l=(u,d)=>{const f=d.split(".");if(f.length>u.length)return!1;for(let m=0;m<f.length;m++)if(i(u[m],f[m])!==0)return!1;return!0};class c{constructor(d,f){if(f=o(f),d instanceof c){if(d.loose===!!f.loose&&d.includePrerelease===!!f.includePrerelease)return d;d=d.version}else if(typeof d!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof d}".`);if(d.length>e)throw new TypeError(`version is longer than ${e} characters`);n("SemVer",d,f),this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease;const m=d.trim().match(f.loose?s[r.LOOSE]:s[r.FULL]);if(!m)throw new TypeError(`Invalid Version: ${d}`);if(this.raw=d,this.major=+m[1],this.minor=+m[2],this.patch=+m[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");m[4]?this.prerelease=m[4].split(".").map(p=>{if(/^[0-9]+$/.test(p)){const h=+p;if(h>=0&&h<t)return h}return p}):this.prerelease=[],this.build=m[5]?m[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(d){if(n("SemVer.compare",this.version,this.options,d),!(d instanceof c)){if(typeof d=="string"&&d===this.version)return 0;d=new c(d,this.options)}return d.version===this.version?0:this.compareMain(d)||this.comparePre(d)}compareMain(d){return d instanceof c||(d=new c(d,this.options)),this.major<d.major?-1:this.major>d.major?1:this.minor<d.minor?-1:this.minor>d.minor?1:this.patch<d.patch?-1:this.patch>d.patch?1:0}comparePre(d){if(d instanceof c||(d=new c(d,this.options)),this.prerelease.length&&!d.prerelease.length)return-1;if(!this.prerelease.length&&d.prerelease.length)return 1;if(!this.prerelease.length&&!d.prerelease.length)return 0;let f=0;do{const m=this.prerelease[f],p=d.prerelease[f];if(n("prerelease compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}compareBuild(d){d instanceof c||(d=new c(d,this.options));let f=0;do{const m=this.build[f],p=d.build[f];if(n("build compare",f,m,p),m===void 0&&p===void 0)return 0;if(p===void 0)return 1;if(m===void 0)return-1;if(m===p)continue;return i(m,p)}while(++f)}inc(d,f,m){if(d.startsWith("pre")){if(!f&&m===!1)throw new Error("invalid increment argument: identifier is empty");if(f){const p=`-${f}`.match(this.options.loose?s[r.PRERELEASELOOSE]:s[r.PRERELEASE]);if(!p||p[1]!==f)throw new Error(`invalid identifier: ${f}`)}}switch(d){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",f,m);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",f,m);break;case"prepatch":this.prerelease.length=0,this.inc("patch",f,m),this.inc("pre",f,m);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",f,m),this.inc("pre",f,m);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const p=Number(m)?1:0;if(this.prerelease.length===0)this.prerelease=[p];else{let h=this.prerelease.length;for(;--h>=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(f===this.prerelease.join(".")&&m===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(p)}}if(f){let h=[f,p];if(m===!1&&(h=[f]),l(this.prerelease,f)){const g=this.prerelease[f.split(".").length];isNaN(g)&&(this.prerelease=h)}else this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${d}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return cp=c,cp}var up,nw;function wi(){if(nw)return up;nw=1;const n=Wn();return up=(t,s,r=!1)=>{if(t instanceof n)return t;try{return new n(t,s)}catch(o){if(!r)return null;throw o}},up}var dp,sw;function Aq(){if(sw)return dp;sw=1;const n=wi();return dp=(t,s)=>{const r=n(t,s);return r?r.version:null},dp}var fp,rw;function Iq(){if(rw)return fp;rw=1;const n=wi();return fp=(t,s)=>{const r=n(t.trim().replace(/^[=v]+/,""),s);return r?r.version:null},fp}var mp,ow;function Pq(){if(ow)return mp;ow=1;const n=Wn();return mp=(t,s,r,o,i)=>{typeof r=="string"&&(i=o,o=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(s,o,i).version}catch{return null}},mp}var pp,iw;function $q(){if(iw)return pp;iw=1;const n=wi();return pp=(t,s)=>{const r=n(t,null,!0),o=n(s,null,!0),i=r.compare(o);if(i===0)return null;const l=i>0,c=l?r:o,u=l?o:r,d=!!c.prerelease.length;if(!!u.prerelease.length&&!d){if(!u.patch&&!u.minor)return"major";if(u.compareMain(c)===0)return u.minor&&!u.patch?"minor":"patch"}const m=d?"pre":"";return r.major!==o.major?m+"major":r.minor!==o.minor?m+"minor":r.patch!==o.patch?m+"patch":"prerelease"},pp}var hp,aw;function Rq(){if(aw)return hp;aw=1;const n=Wn();return hp=(t,s)=>new n(t,s).major,hp}var gp,lw;function Oq(){if(lw)return gp;lw=1;const n=Wn();return gp=(t,s)=>new n(t,s).minor,gp}var xp,cw;function Lq(){if(cw)return xp;cw=1;const n=Wn();return xp=(t,s)=>new n(t,s).patch,xp}var bp,uw;function Mq(){if(uw)return bp;uw=1;const n=wi();return bp=(t,s)=>{const r=n(t,s);return r&&r.prerelease.length?r.prerelease:null},bp}var vp,dw;function lr(){if(dw)return vp;dw=1;const n=Wn();return vp=(t,s,r)=>new n(t,r).compare(new n(s,r)),vp}var yp,fw;function zq(){if(fw)return yp;fw=1;const n=lr();return yp=(t,s,r)=>n(s,t,r),yp}var wp,mw;function Dq(){if(mw)return wp;mw=1;const n=lr();return wp=(t,s)=>n(t,s,!0),wp}var Sp,pw;function k0(){if(pw)return Sp;pw=1;const n=Wn();return Sp=(t,s,r)=>{const o=new n(t,r),i=new n(s,r);return o.compare(i)||o.compareBuild(i)},Sp}var kp,hw;function Fq(){if(hw)return kp;hw=1;const n=k0();return kp=(t,s)=>t.sort((r,o)=>n(r,o,s)),kp}var jp,gw;function Uq(){if(gw)return jp;gw=1;const n=k0();return jp=(t,s)=>t.sort((r,o)=>n(o,r,s)),jp}var Np,xw;function Xf(){if(xw)return Np;xw=1;const n=lr();return Np=(t,s,r)=>n(t,s,r)>0,Np}var Cp,bw;function j0(){if(bw)return Cp;bw=1;const n=lr();return Cp=(t,s,r)=>n(t,s,r)<0,Cp}var _p,vw;function MC(){if(vw)return _p;vw=1;const n=lr();return _p=(t,s,r)=>n(t,s,r)===0,_p}var Ep,yw;function zC(){if(yw)return Ep;yw=1;const n=lr();return Ep=(t,s,r)=>n(t,s,r)!==0,Ep}var Tp,ww;function N0(){if(ww)return Tp;ww=1;const n=lr();return Tp=(t,s,r)=>n(t,s,r)>=0,Tp}var Ap,Sw;function C0(){if(Sw)return Ap;Sw=1;const n=lr();return Ap=(t,s,r)=>n(t,s,r)<=0,Ap}var Ip,kw;function DC(){if(kw)return Ip;kw=1;const n=MC(),e=zC(),t=Xf(),s=N0(),r=j0(),o=C0();return Ip=(l,c,u,d)=>{switch(c){case"===":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l===u;case"!==":return typeof l=="object"&&(l=l.version),typeof u=="object"&&(u=u.version),l!==u;case"":case"=":case"==":return n(l,u,d);case"!=":return e(l,u,d);case">":return t(l,u,d);case">=":return s(l,u,d);case"<":return r(l,u,d);case"<=":return o(l,u,d);default:throw new TypeError(`Invalid operator: ${c}`)}},Ip}var Pp,jw;function Bq(){if(jw)return Pp;jw=1;const n=Wn(),e=wi(),{safeRe:t,t:s}=Mc();return Pp=(o,i)=>{if(o instanceof n)return o;if(typeof o=="number"&&(o=String(o)),typeof o!="string")return null;i=i||{};let l=null;if(!i.rtl)l=o.match(i.includePrerelease?t[s.COERCEFULL]:t[s.COERCE]);else{const p=i.includePrerelease?t[s.COERCERTLFULL]:t[s.COERCERTL];let h;for(;(h=p.exec(o))&&(!l||l.index+l[0].length!==o.length);)(!l||h.index+h[0].length!==l.index+l[0].length)&&(l=h),p.lastIndex=h.index+h[1].length+h[2].length;p.lastIndex=-1}if(l===null)return null;const c=l[2],u=l[3]||"0",d=l[4]||"0",f=i.includePrerelease&&l[5]?`-${l[5]}`:"",m=i.includePrerelease&&l[6]?`+${l[6]}`:"";return e(`${c}.${u}.${d}${f}${m}`,i)},Pp}var $p,Nw;function Wq(){if(Nw)return $p;Nw=1;const n=wi(),e=Lc(),t=Wn(),s=(l,c,u)=>{if(!e.RELEASE_TYPES.includes(c))return null;const d=r(l,u);return d&&o(d,c)},r=(l,c)=>{const u=l instanceof t?l.version:l;return n(u,c)},o=(l,c)=>{if(i(c))return l.version;switch(l.prerelease=[],c){case"major":l.minor=0,l.patch=0;break;case"minor":l.patch=0;break}return l.format()},i=l=>l.startsWith("pre");return $p=s,$p}var Rp,Cw;function qq(){if(Cw)return Rp;Cw=1;class n{constructor(){this.max=1e3,this.map=new Map}get(t){const s=this.map.get(t);if(s!==void 0)return this.map.delete(t),this.map.set(t,s),s}delete(t){return this.map.delete(t)}set(t,s){if(!this.delete(t)&&s!==void 0){if(this.map.size>=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(t,s)}return this}}return Rp=n,Rp}var Op,_w;function cr(){if(_w)return Op;_w=1;const n=/\s+/g;class e{constructor(I,M){if(M=r(M),I instanceof e)return I.loose===!!M.loose&&I.includePrerelease===!!M.includePrerelease?I:new e(I.raw,M);if(I instanceof o)return this.raw=I.value,this.set=[[I]],this.formatted=void 0,this;if(this.options=M,this.loose=!!M.loose,this.includePrerelease=!!M.includePrerelease,this.raw=I.trim().replace(n," "),this.set=this.raw.split("||").map(F=>this.parseRange(F.trim())).filter(F=>F.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const F=this.set[0];if(this.set=this.set.filter(U=>!b(U[0])),this.set.length===0)this.set=[F];else if(this.set.length>1){for(const U of this.set)if(U.length===1&&w(U[0])){this.set=[U];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let I=0;I<this.set.length;I++){I>0&&(this.formatted+="||");const M=this.set[I];for(let F=0;F<M.length;F++)F>0&&(this.formatted+=" "),this.formatted+=M[F].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(I){I=I.replace(x,"");const F=((this.options.includePrerelease&&h)|(this.options.loose&&g))+":"+I,U=s.get(F);if(U)return U;const O=this.options.loose,D=O?c[d.HYPHENRANGELOOSE]:c[d.HYPHENRANGE];I=I.replace(D,P(this.options.includePrerelease)),i("hyphen replace",I),I=I.replace(c[d.COMPARATORTRIM],f),i("comparator trim",I),I=I.replace(c[d.TILDETRIM],m),i("tilde trim",I),I=I.replace(c[d.CARETTRIM],p),i("caret trim",I);let B=I.split(" ").map(K=>j(K,this.options)).join(" ").split(/\s+/).map(K=>R(K,this.options));O&&(B=B.filter(K=>(i("loose invalid filter",K,this.options),!!K.match(c[d.COMPARATORLOOSE])))),i("range list",B);const q=new Map,W=B.map(K=>new o(K,this.options));for(const K of W){if(b(K))return[K];q.set(K.value,K)}q.size>1&&q.has("")&&q.delete("");const H=[...q.values()];return s.set(F,H),H}intersects(I,M){if(!(I instanceof e))throw new TypeError("a Range is required");return this.set.some(F=>v(F,M)&&I.set.some(U=>v(U,M)&&F.every(O=>U.every(D=>O.intersects(D,M)))))}test(I){if(!I)return!1;if(typeof I=="string")try{I=new l(I,this.options)}catch{return!1}for(let M=0;M<this.set.length;M++)if(z(this.set[M],I,this.options))return!0;return!1}}Op=e;const t=qq(),s=new t,r=S0(),o=Jf(),i=Yf(),l=Wn(),{safeRe:c,src:u,t:d,comparatorTrimReplace:f,tildeTrimReplace:m,caretTrimReplace:p}=Mc(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:g}=Lc(),x=new RegExp(u[d.BUILD],"g"),b=L=>L.value==="<0.0.0-0",w=L=>L.value==="",v=(L,I)=>{let M=!0;const F=L.slice();let U=F.pop();for(;M&&F.length;)M=F.every(O=>U.intersects(O,I)),U=F.pop();return M},j=(L,I)=>(L=L.replace(c[d.BUILD],""),i("comp",L,I),L=C(L,I),i("caret",L),L=N(L,I),i("tildes",L),L=T(L,I),i("xrange",L),L=A(L,I),i("stars",L),L),k=L=>!L||L.toLowerCase()==="x"||L==="*",_=(L,I,M)=>k(L)&&!k(I)||k(I)&&M&&!k(M),N=(L,I)=>L.trim().split(/\s+/).map(M=>S(M,I)).join(" "),S=(L,I)=>{const M=I.loose?c[d.TILDELOOSE]:c[d.TILDE],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("tilde",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:q?(i("replaceTilde pr",q),W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`):W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`,i("tilde return",W),W})},C=(L,I)=>L.trim().split(/\s+/).map(M=>E(M,I)).join(" "),E=(L,I)=>{i("caret",L,I);const M=I.loose?c[d.CARETLOOSE]:c[d.CARET],F=I.includePrerelease?"-0":"";return L.replace(M,(U,O,D,B,q)=>{i("caret",L,U,O,D,B,q);let W;return k(O)?W="":k(D)?W=`>=${O}.0.0${F} <${+O+1}.0.0-0`:k(B)?O==="0"?W=`>=${O}.${D}.0${F} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.0${F} <${+O+1}.0.0-0`:q?(i("replaceCaret pr",q),O==="0"?D==="0"?W=`>=${O}.${D}.${B}-${q} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B}-${q} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B}-${q} <${+O+1}.0.0-0`):(i("no pr"),O==="0"?D==="0"?W=`>=${O}.${D}.${B} <${O}.${D}.${+B+1}-0`:W=`>=${O}.${D}.${B} <${O}.${+D+1}.0-0`:W=`>=${O}.${D}.${B} <${+O+1}.0.0-0`),i("caret return",W),W})},T=(L,I)=>(i("replaceXRanges",L,I),L.split(/\s+/).map(M=>$(M,I)).join(" ")),$=(L,I)=>{L=L.trim();const M=I.loose?c[d.XRANGELOOSE]:c[d.XRANGE];return L.replace(M,(F,U,O,D,B,q)=>{if(i("xRange",L,F,U,O,D,B,q),_(O,D,B))return L;const W=k(O),H=W||k(D),K=H||k(B),Z=K;return U==="="&&Z&&(U=""),q=I.includePrerelease?"-0":"",W?U===">"||U==="<"?F="<0.0.0-0":F="*":U&&Z?(H&&(D=0),B=0,U===">"?(U=">=",H?(O=+O+1,D=0,B=0):(D=+D+1,B=0)):U==="<="&&(U="<",H?O=+O+1:D=+D+1),U==="<"&&(q="-0"),F=`${U+O}.${D}.${B}${q}`):H?F=`>=${O}.0.0${q} <${+O+1}.0.0-0`:K&&(F=`>=${O}.${D}.0${q} <${O}.${+D+1}.0-0`),i("xRange return",F),F})},A=(L,I)=>(i("replaceStars",L,I),L.trim().replace(c[d.STAR],"")),R=(L,I)=>(i("replaceGTE0",L,I),L.trim().replace(c[I.includePrerelease?d.GTE0PRE:d.GTE0],"")),P=L=>(I,M,F,U,O,D,B,q,W,H,K,Z)=>(k(F)?M="":k(U)?M=`>=${F}.0.0${L?"-0":""}`:k(O)?M=`>=${F}.${U}.0${L?"-0":""}`:D?M=`>=${M}`:M=`>=${M}${L?"-0":""}`,k(W)?q="":k(H)?q=`<${+W+1}.0.0-0`:k(K)?q=`<${W}.${+H+1}.0-0`:Z?q=`<=${W}.${H}.${K}-${Z}`:L?q=`<${W}.${H}.${+K+1}-0`:q=`<=${q}`,`${M} ${q}`.trim()),z=(L,I,M)=>{for(let F=0;F<L.length;F++)if(!L[F].test(I))return!1;if(I.prerelease.length&&!M.includePrerelease){for(let F=0;F<L.length;F++)if(i(L[F].semver),L[F].semver!==o.ANY&&L[F].semver.prerelease.length>0){const U=L[F].semver;if(U.major===I.major&&U.minor===I.minor&&U.patch===I.patch)return!0}return!1}return!0};return Op}var Lp,Ew;function Jf(){if(Ew)return Lp;Ew=1;const n=Symbol("SemVer ANY");class e{static get ANY(){return n}constructor(d,f){if(f=t(f),d instanceof e){if(d.loose===!!f.loose)return d;d=d.value}d=d.trim().split(/\s+/).join(" "),i("comparator",d,f),this.options=f,this.loose=!!f.loose,this.parse(d),this.semver===n?this.value="":this.value=this.operator+this.semver.version,i("comp",this)}parse(d){const f=this.options.loose?s[r.COMPARATORLOOSE]:s[r.COMPARATOR],m=d.match(f);if(!m)throw new TypeError(`Invalid comparator: ${d}`);this.operator=m[1]!==void 0?m[1]:"",this.operator==="="&&(this.operator=""),m[2]?this.semver=new l(m[2],this.options.loose):this.semver=n}toString(){return this.value}test(d){if(i("Comparator.test",d,this.options.loose),this.semver===n||d===n)return!0;if(typeof d=="string")try{d=new l(d,this.options)}catch{return!1}return o(d,this.operator,this.semver,this.options)}intersects(d,f){if(!(d instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(d.value,f).test(this.value):d.operator===""?d.value===""?!0:new c(this.value,f).test(d.semver):(f=t(f),f.includePrerelease&&(this.value==="<0.0.0-0"||d.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||d.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&d.operator.startsWith(">")||this.operator.startsWith("<")&&d.operator.startsWith("<")||this.semver.version===d.semver.version&&this.operator.includes("=")&&d.operator.includes("=")||o(this.semver,"<",d.semver,f)&&this.operator.startsWith(">")&&d.operator.startsWith("<")||o(this.semver,">",d.semver,f)&&this.operator.startsWith("<")&&d.operator.startsWith(">")))}}Lp=e;const t=S0(),{safeRe:s,t:r}=Mc(),o=DC(),i=Yf(),l=Wn(),c=cr();return Lp}var Mp,Tw;function Qf(){if(Tw)return Mp;Tw=1;const n=cr();return Mp=(t,s,r)=>{try{s=new n(s,r)}catch{return!1}return s.test(t)},Mp}var zp,Aw;function Vq(){if(Aw)return zp;Aw=1;const n=cr();return zp=(t,s)=>new n(t,s).set.map(r=>r.map(o=>o.value).join(" ").trim().split(" ")),zp}var Dp,Iw;function Hq(){if(Iw)return Dp;Iw=1;const n=Wn(),e=cr();return Dp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===-1)&&(i=u,l=new n(i,o))}),i},Dp}var Fp,Pw;function Kq(){if(Pw)return Fp;Pw=1;const n=Wn(),e=cr();return Fp=(s,r,o)=>{let i=null,l=null,c=null;try{c=new e(r,o)}catch{return null}return s.forEach(u=>{c.test(u)&&(!i||l.compare(u)===1)&&(i=u,l=new n(i,o))}),i},Fp}var Up,$w;function Gq(){if($w)return Up;$w=1;const n=Wn(),e=cr(),t=Xf();return Up=(r,o)=>{r=new e(r,o);let i=new n("0.0.0");if(r.test(i)||(i=new n("0.0.0-0"),r.test(i)))return i;i=null;for(let l=0;l<r.set.length;++l){const c=r.set[l];let u=null;c.forEach(d=>{const f=new n(d.semver.version);switch(d.operator){case">":f.prerelease.length===0?f.patch++:f.prerelease.push(0),f.raw=f.format();case"":case">=":(!u||t(f,u))&&(u=f);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${d.operator}`)}}),u&&(!i||t(i,u))&&(i=u)}return i&&r.test(i)?i:null},Up}var Bp,Rw;function Zq(){if(Rw)return Bp;Rw=1;const n=cr();return Bp=(t,s)=>{try{return new n(t,s).range||"*"}catch{return null}},Bp}var Wp,Ow;function _0(){if(Ow)return Wp;Ow=1;const n=Wn(),e=Jf(),{ANY:t}=e,s=cr(),r=Qf(),o=Xf(),i=j0(),l=C0(),c=N0();return Wp=(d,f,m,p)=>{d=new n(d,p),f=new s(f,p);let h,g,x,b,w;switch(m){case">":h=o,g=l,x=i,b=">",w=">=";break;case"<":h=i,g=c,x=o,b="<",w="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(r(d,f,p))return!1;for(let v=0;v<f.set.length;++v){const j=f.set[v];let k=null,_=null;if(j.forEach(N=>{N.semver===t&&(N=new e(">=0.0.0")),k=k||N,_=_||N,h(N.semver,k.semver,p)?k=N:x(N.semver,_.semver,p)&&(_=N)}),k.operator===b||k.operator===w||(!_.operator||_.operator===b)&&g(d,_.semver))return!1;if(_.operator===w&&x(d,_.semver))return!1}return!0},Wp}var qp,Lw;function Yq(){if(Lw)return qp;Lw=1;const n=_0();return qp=(t,s,r)=>n(t,s,">",r),qp}var Vp,Mw;function Xq(){if(Mw)return Vp;Mw=1;const n=_0();return Vp=(t,s,r)=>n(t,s,"<",r),Vp}var Hp,zw;function Jq(){if(zw)return Hp;zw=1;const n=cr();return Hp=(t,s,r)=>(t=new n(t,r),s=new n(s,r),t.intersects(s,r)),Hp}var Kp,Dw;function Qq(){if(Dw)return Kp;Dw=1;const n=Qf(),e=lr();return Kp=(t,s,r)=>{const o=[];let i=null,l=null;const c=t.sort((m,p)=>e(m,p,r));for(const m of c)n(m,s,r)?(l=m,i||(i=m)):(l&&o.push([i,l]),l=null,i=null);i&&o.push([i,null]);const u=[];for(const[m,p]of o)m===p?u.push(m):!p&&m===c[0]?u.push("*"):p?m===c[0]?u.push(`<=${p}`):u.push(`${m} - ${p}`):u.push(`>=${m}`);const d=u.join(" || "),f=typeof s.raw=="string"?s.raw:String(s);return d.length<f.length?d:s},Kp}var Gp,Fw;function eV(){if(Fw)return Gp;Fw=1;const n=cr(),e=Jf(),{ANY:t}=e,s=Qf(),r=lr(),o=(f,m,p={})=>{if(f===m)return!0;f=new n(f,p),m=new n(m,p);let h=!1;e:for(const g of f.set){for(const x of m.set){const b=c(g,x,p);if(h=h||b!==null,b)continue e}if(h)return!1}return!0},i=[new e(">=0.0.0-0")],l=[new e(">=0.0.0")],c=(f,m,p)=>{if(f===m)return!0;if(f.length===1&&f[0].semver===t){if(m.length===1&&m[0].semver===t)return!0;p.includePrerelease?f=i:f=l}if(m.length===1&&m[0].semver===t){if(p.includePrerelease)return!0;m=l}const h=new Set;let g,x;for(const S of f)S.operator===">"||S.operator===">="?g=u(g,S,p):S.operator==="<"||S.operator==="<="?x=d(x,S,p):h.add(S.semver);if(h.size>1)return null;let b;if(g&&x){if(b=r(g.semver,x.semver,p),b>0)return null;if(b===0&&(g.operator!==">="||x.operator!=="<="))return null}for(const S of h){if(g&&!s(S,String(g),p)||x&&!s(S,String(x),p))return null;for(const C of m)if(!s(S,String(C),p))return!1;return!0}let w,v,j,k,_=x&&!p.includePrerelease&&x.semver.prerelease.length?x.semver:!1,N=g&&!p.includePrerelease&&g.semver.prerelease.length?g.semver:!1;_&&_.prerelease.length===1&&x.operator==="<"&&_.prerelease[0]===0&&(_=!1);for(const S of m){if(k=k||S.operator===">"||S.operator===">=",j=j||S.operator==="<"||S.operator==="<=",g){if(N&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===N.major&&S.semver.minor===N.minor&&S.semver.patch===N.patch&&(N=!1),S.operator===">"||S.operator===">="){if(w=u(g,S,p),w===S&&w!==g)return!1}else if(g.operator===">="&&!S.test(g.semver))return!1}if(x){if(_&&S.semver.prerelease&&S.semver.prerelease.length&&S.semver.major===_.major&&S.semver.minor===_.minor&&S.semver.patch===_.patch&&(_=!1),S.operator==="<"||S.operator==="<="){if(v=d(x,S,p),v===S&&v!==x)return!1}else if(x.operator==="<="&&!S.test(x.semver))return!1}if(!S.operator&&(x||g)&&b!==0)return!1}return!(g&&j&&!x&&b!==0||x&&k&&!g&&b!==0||N||_)},u=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h>0?f:h<0||m.operator===">"&&f.operator===">="?m:f},d=(f,m,p)=>{if(!f)return m;const h=r(f.semver,m.semver,p);return h<0?f:h>0||m.operator==="<"&&f.operator==="<="?m:f};return Gp=o,Gp}var Zp,Uw;function tV(){if(Uw)return Zp;Uw=1;const n=Mc(),e=Lc(),t=Wn(),s=LC(),r=wi(),o=Aq(),i=Iq(),l=Pq(),c=$q(),u=Rq(),d=Oq(),f=Lq(),m=Mq(),p=lr(),h=zq(),g=Dq(),x=k0(),b=Fq(),w=Uq(),v=Xf(),j=j0(),k=MC(),_=zC(),N=N0(),S=C0(),C=DC(),E=Bq(),T=Wq(),$=Jf(),A=cr(),R=Qf(),P=Vq(),z=Hq(),L=Kq(),I=Gq(),M=Zq(),F=_0(),U=Yq(),O=Xq(),D=Jq(),B=Qq(),q=eV();return Zp={parse:r,valid:o,clean:i,inc:l,diff:c,major:u,minor:d,patch:f,prerelease:m,compare:p,rcompare:h,compareLoose:g,compareBuild:x,sort:b,rsort:w,gt:v,lt:j,eq:k,neq:_,gte:N,lte:S,cmp:C,coerce:E,truncate:T,Comparator:$,Range:A,satisfies:R,toComparators:P,maxSatisfying:z,minSatisfying:L,minVersion:I,validRange:M,outside:F,gtr:U,ltr:O,intersects:D,simplifyRange:B,subset:q,SemVer:t,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers},Zp}var Vn=tV();const lt=Le().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n),"Reserved identifier"),_s=Le().min(1).max(128).refine(n=>[...n].every(e=>e.charCodeAt(0)>=32&&e.charCodeAt(0)!==127),"Control characters are forbidden"),Cs=n=>Le().refine(e=>Pl(e)<=n,"Text exceeds byte limit"),il=Le().min(1).max(256).refine(n=>/^[A-Za-z0-9_./-]+$/u.test(n)?n.split("/").every(e=>e!==""&&e!=="."&&e!==".."&&!e.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/iu.test(e)):!1,"Expected a canonical portable package path");function zo(n,e,t,s){const r=n.safeParse(l0(e,{maxBytes:t,maxNodes:s}));if(!r.success)throw new tc(r.error.issues.map(o=>({path:o.path.length?`$.${o.path.map(String).join(".")}`:"$",message:o.message})));return r.data}const nV=["actions","actionJobs","pulls","pullFiles","pullSessions","issues","mergePull"],sV=["deployments","buildLogs"],rV=["workspace","deployments","version"],Yp=n=>at(Ct(n)).min(1).max(n.length).refine(e=>new Set(e).size===e.length,"Duplicate operation"),oV=Rr("id",[xe({id:Ze("github"),operations:Yp(nV)}),xe({id:Ze("vercel"),operations:Yp(sV)}),xe({id:Ze("cloudflare"),operations:Yp(rV)})]),Br=bt().int().positive().max(Number.MAX_SAFE_INTEGER),Qo={integration:Ze("github")},Bw={integration:Ze("vercel")},Xp={integration:Ze("cloudflare")},Ww=Le().regex(/^[A-Za-z0-9_-]+$/).max(64).optional(),Jp=Le().max(240).regex(/^(?:[^/\\]+\/)*wrangler\.(?:json|jsonc|toml)$/).refine(n=>n.split("/").every(e=>e!=="."&&e!==".."),"Invalid configuration path").optional(),iV=Rr("operation",[xe({...Qo,operation:Ze("actions"),limit:Br.max(30).optional()}),xe({...Qo,operation:Ze("actionJobs"),runId:Br}),xe({...Qo,operation:Ze("pulls"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("pullFiles"),number:Br}),xe({...Qo,operation:Ze("pullSessions")}),xe({...Qo,operation:Ze("issues"),limit:Br.max(50).optional()}),xe({...Qo,operation:Ze("mergePull"),number:Br,method:Ct(["merge","squash","rebase"]),headSha:Le().regex(/^[0-9a-f]{40}$/)})]),aV=Rr("operation",[xe({...Bw,operation:Ze("deployments"),limit:Br.max(30).optional()}),xe({...Bw,operation:Ze("buildLogs"),deploymentId:Le().regex(/^dpl_[A-Za-z0-9]+$/).max(128),limit:Br.max(500).optional()})]),lV=Rr("operation",[xe({...Xp,operation:Ze("workspace"),config:Jp}),xe({...Xp,operation:Ze("deployments"),config:Jp,environment:Ww,limit:Br.max(30).optional()}),xe({...Xp,operation:Ze("version"),config:Jp,environment:Ww,versionId:Le().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)})]),cV=Rr("integration",[iV,aV,lV]),uV=Rr("ok",[xe({ok:Ze(!0),data:OC(()=>!0)}),xe({ok:Ze(!1),error:xe({code:Le().min(1).max(64),message:Le().min(1).max(512)})})]),ju={id:lt,label:_s,description:Cs(512).optional()},dV=Rr("type",[xe({...ju,type:Ze("string"),default:Cs(4096).default(""),maxLength:bt().int().min(1).max(4096).default(256)}),xe({...ju,type:Ze("boolean"),default:Ft().default(!1)}),xe({...ju,type:Ze("number"),default:bt().finite(),min:bt().finite(),max:bt().finite(),step:bt().positive().optional()}),xe({...ju,type:Ze("select"),default:Cs(256),options:at(xe({value:Cs(256),label:_s})).min(1).max(64)})]).superRefine((n,e)=>{n.type==="number"&&(n.min>n.max||n.default<n.min||n.default>n.max)&&e.addIssue({code:"custom",message:"Invalid numeric setting bounds/default"}),n.type==="string"&&n.default.length>n.maxLength&&e.addIssue({code:"custom",message:"Default exceeds setting length"}),n.type==="select"&&(!n.options.some(t=>t.value===n.default)||new Set(n.options.map(t=>t.value)).size!==n.options.length)&&e.addIssue({code:"custom",message:"Invalid select options/default"})}),fV=xe({scope:Ct(["plugin","project"]),fields:at(dV).min(1).max(32).refine(n=>new Set(n.map(e=>e.id)).size===n.length,"Duplicate setting ID")}).refine(n=>new TextEncoder().encode(JSON.stringify(Object.fromEntries(n.fields.map(e=>[e.id,e.default])))).byteLength<=16384,"Default settings exceed 16 KiB"),mV=xe({id:lt,title:_s,description:Cs(512),source:il.refine(n=>n.endsWith(".md"),"Skill source must be Markdown")}),pV=xe({id:Le().regex(/^[a-z][a-z0-9-]{0,63}$/u),title:_s,height:bt().int().min(80).max(800).default(240)}),hV=xe({id:lt,title:_s,skill:lt,prompt:Cs(4096).refine(n=>n.trim().length>0,"Action prompt is required")});function A2e(n,e){const t={};for(const s of n.fields)t[s.id]=s.type==="string"?Le().max(s.maxLength).default(s.default):s.type==="boolean"?Ft().default(s.default):s.type==="number"?bt().finite().min(s.min).max(s.max).default(s.default):Ct(s.options.map(r=>r.value)).default(s.default);return xe(t).parse(e)}function FC(n){const e=n==null?void 0:n.match(/^cogpit:([a-z][a-z0-9-]*\.[a-z][a-z0-9-]*):([a-z][a-z0-9-]{0,63})$/u);return e?{pluginId:e[1],blockId:e[2]}:null}const Ss=1,gV="1.2.0",UC="browser-iife-v1",Zg=Le().max(128).refine(n=>Vn.valid(n)===n,"Expected strict SemVer"),cd=Le().min(1).max(256).refine(n=>Vn.validRange(n)!==null,"Expected a SemVer range"),qw=Xn(lt,cd).refine(n=>Object.keys(n).length<=32,"Too many capabilities"),Vw=xe({client:qw,host:qw}),al=n=>new Set(n).size===n.length,xV=at(lt).max(32).refine(al,"Duplicate identifier"),Hw=Le().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/u),Qp=Le().regex(/^(?:[1-9][0-9]{0,3}px|(?:[1-9][0-9]?|100)%)$/u),bV=xe({manifestVersion:Ze(1),id:Le().max(128).regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/u),publisher:Hw,name:_s,version:Zg,runtime:Ze(UC),entry:il.refine(n=>n.endsWith(".js"),"Entry must be JavaScript").optional(),style:il.refine(n=>n.endsWith(".css"),"Style must be CSS").optional(),engines:xe({pluginApi:cd,client:cd,host:cd}),protocol:Ze(Ss).default(Ss),requires:Vw,optional:Vw.default({client:{},host:{}}),browser:at(Ct(["message-channel","blob-script","web-crypto"])).max(3).refine(al).default([]),contributes:xe({panels:at(xe({id:Hw,title:_s,icon:il.refine(n=>/\.(png|jpe?g|webp)$/u.test(n),"Expected a raster icon"),order:bt().int().min(0).max(1e3).optional(),defaultSize:Qp.optional(),minSize:Qp.optional(),maxSize:Qp.optional(),when:Ct(["always","project-selected"]).default("project-selected")})).max(8).default([]),settings:fV.optional(),skills:at(mV).max(16).optional(),chatBlocks:at(pV).max(8).optional(),sessionActions:at(hV).max(8).optional()}),permissions:xe({context:at(Ct(["project.identity","session.identity"])).max(2).refine(al).default([]),composer:at(Ze("append")).max(1).default([]),navigation:at(Ct(["external","session"])).max(2).refine(al).default([]),connections:at(xe({id:lt,definition:il,operations:xV.min(1)})).max(8).default([]),integrations:at(oV).max(2).default([]),storage:xe({scope:Ct(["project","plugin"]),quotaKiB:bt().int().min(1).max(1024)}).optional()}),stateVersion:bt().int().min(1).max(Number.MAX_SAFE_INTEGER)}).superRefine((n,e)=>{var t,s,r,o;!n.contributes.panels.length&&!((t=n.contributes.skills)!=null&&t.length)&&!((s=n.contributes.chatBlocks)!=null&&s.length)&&!n.contributes.settings&&e.addIssue({code:"custom",path:["contributes"],message:"At least one contribution is required"}),(n.contributes.panels.length||(r=n.contributes.chatBlocks)!=null&&r.length)&&!n.entry&&e.addIssue({code:"custom",path:["entry"],message:"Visual contributions require a JavaScript entry"}),n.style&&!n.entry&&e.addIssue({code:"custom",path:["style"],message:"Styles require a JavaScript entry"});for(const i of n.contributes.sessionActions??[])(o=n.contributes.skills)!=null&&o.some(l=>l.id===i.skill)||e.addIssue({code:"custom",path:["contributes","sessionActions"],message:"Session actions must reference a declared skill"});n.id.startsWith(`${n.publisher}.`)||e.addIssue({code:"custom",path:["id"],message:"Plugin ID must belong to its publisher"}),["cogpit.worktrees","cogpit.project-files","cogpit.browser","cogpit.file-changes","cogpit.session-info"].includes(n.id)&&e.addIssue({code:"custom",path:["id"],message:"Reserved built-in ID"});for(const[i,l]of[["panels",n.contributes.panels],["skills",n.contributes.skills??[]],["chatBlocks",n.contributes.chatBlocks??[]],["sessionActions",n.contributes.sessionActions??[]],["connections",n.permissions.connections],["integrations",n.permissions.integrations]])al(l.map(c=>c.id))||e.addIssue({code:"custom",path:[i],message:"Duplicate contribution ID"});for(const i of["client","host"])for(const l of Object.keys(n.optional[i]))Object.hasOwn(n.requires[i],l)&&e.addIssue({code:"custom",path:["optional",i,l],message:"Capability is already required"})});function BC(n){return zo(bV,n,en.manifestBytes)}const E0=8*1024*1024,WC=Ct(["audio/mpeg","audio/wav","audio/flac","audio/ogg","audio/opus","audio/aac"]);function em(n){var r,o;if(!n||typeof n!="object"||Object.keys(n).length!==2)throw new tc([{path:"$",message:"Invalid media response"}]);const e=Object.getOwnPropertyDescriptors(n),t=WC.safeParse((r=e.mimeType)==null?void 0:r.value),s=(o=e.bytes)==null?void 0:o.value;if(!t.success||!(s instanceof ArrayBuffer)||s.byteLength===0||s.byteLength>E0)throw new tc([{path:"$",message:"Invalid or oversized audio response"}]);return{mimeType:t.data,bytes:s}}const qC=Le().max(256).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&e.origin===n&&!e.username&&!e.password&&!e.port&&/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/u.test(e.hostname)&&!/\.(?:localhost|local|internal)$/u.test(e.hostname)}catch{return!1}},"Expected an exact public HTTPS origin"),So=Le().max(256).refine(n=>(!n||n.startsWith("/"))&&!/~(?![01])/u.test(n)&&n.split("/").length<=9&&!n.split("/").some(e=>["__proto__","prototype","constructor"].includes(e)),"Invalid bounded JSON pointer"),VC=Le().min(1).max(1024).regex(/^[a-zA-Z0-9._~-]+$/u).refine(n=>n!=="."&&n!==".."),vV=Rr("type",[xe({type:Ze("string"),required:Ft().optional(),maxLength:bt().int().min(1).max(16384),multiline:Ft().optional(),enum:at(_s).min(1).max(64).optional()}),xe({type:Ze("integer"),required:Ft().optional(),min:bt().int().min(Number.MIN_SAFE_INTEGER),max:bt().int().max(Number.MAX_SAFE_INTEGER)}),xe({type:Ze("number"),required:Ft().optional(),min:bt().finite(),max:bt().finite()}),xe({type:Ze("boolean"),required:Ft().optional()})]),yV=to([xe({literal:VC}),xe({resource:lt}),xe({arg:lt})]),Kw=to([lt,xe({literal:to([Le().max(1024),bt().int().min(Number.MIN_SAFE_INTEGER).max(Number.MAX_SAFE_INTEGER),Ft()])}),xe({arg:lt}),xe({resource:lt}),xe({identity:lt})]),wV=xe({audience:Ct(["setup","panel"]),origin:qC,method:Ct(["GET","POST"]),path:at(yV).min(1).max(16),args:Xn(lt,vV).refine(n=>Object.keys(n).length<=16),query:Xn(Le().max(68).regex(/^[a-zA-Z][a-zA-Z0-9_.-]*(?:\[\])?$/u).refine(n=>!["constructor","prototype","__proto__"].includes(n.replace(/\[\]$/u,""))),Kw).refine(n=>Object.keys(n).length<=16),body:Xn(lt,Kw).refine(n=>Object.keys(n).length<=16).optional(),response:xe({type:Ze("audio"),mimeTypes:at(WC).min(1).max(6),maxBytes:bt().int().min(1).max(E0)}).optional()}),Gw=xe({operation:lt,items:So,nested:So.optional(),id:So,label:So}),SV=xe({label:_s,scope:Ct(["connection","project"]).optional(),dependsOn:at(lt).max(7).refine(n=>new Set(n).size===n.length).optional(),options:to([Gw,at(Gw).min(1).max(4)]).optional(),input:xe({allowId:Ft(),urls:at(xe({origin:qC,pathMarker:VC})).min(1).max(8).optional(),validation:xe({operation:lt,argument:lt,id:So.optional(),label:So,parents:Xn(lt,So).refine(n=>Object.keys(n).length<=7).optional()})}).optional()}).refine(n=>!!n.options||!!n.input,"Expected listed or validated entered resources"),kV=xe({version:Ze(1),id:lt,label:_s,secret:xe({id:lt,label:_s}),auth:xe({header:Le().max(64).regex(/^(?:Authorization|X-[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)$/iu).refine(n=>!/^x-(?:forwarded|http-method|original|rewrite)(?:-|$)/iu.test(n),"Unsafe credential header"),scheme:Ct(["raw","bearer"])}),validationOperation:lt,identity:Xn(lt,So).refine(n=>Object.keys(n).length<=8).optional(),resources:Xn(lt,SV).refine(n=>Object.keys(n).length<=8),operations:Xn(lt,wV).refine(n=>Object.keys(n).length>0&&Object.keys(n).length<=32)});function Vd(n){return n?[...n.path.flatMap(e=>"resource"in e?[e.resource]:[]),...Object.values(n.query).flatMap(e=>typeof e=="object"&&"resource"in e?[e.resource]:[])]:[]}function Zw(n,e){const t=n.resources[e];if(!t)return[];const s=t.options?Array.isArray(t.options)?t.options:[t.options]:[];return[...new Set([...t.dependsOn??[],...s.flatMap(r=>Vd(n.operations[r.operation])),...Vd(t.input?n.operations[t.input.validation.operation]:void 0)])]}const jV=kV.superRefine((n,e)=>{var u,d;const t=(f,m)=>e.addIssue({code:"custom",path:f,message:m}),s=f=>{var m;return((m=n.operations[f])==null?void 0:m.audience)==="setup"},r=(f,m)=>f&&Object.entries(f.args).every(([p,h])=>!h.required||p===m),o=n.operations[n.validationOperation];(!s(n.validationOperation)||!r(o)||Vd(o).length||Object.values((o==null?void 0:o.query)??{}).some(f=>typeof f=="object"&&"identity"in f))&&t(["validationOperation"],"Expected an independent setup operation without required arguments");for(const[f,m]of Object.entries(n.resources)){const p=Zw(n,f);for(const g of p)(g===f||!Object.hasOwn(n.resources,g))&&t(["resources",f,"dependsOn"],"Unknown or self-dependent resource"),(m.scope??"connection")==="connection"&&((u=n.resources[g])==null?void 0:u.scope)==="project"&&t(["resources",f,"scope"],"Connection resource cannot depend on a project resource");const h=m.options?Array.isArray(m.options)?m.options:[m.options]:[];for(const g of h){const x=n.operations[g.operation];(!s(g.operation)||!r(x))&&t(["resources",f,"options"],"Expected a setup operation without required arguments"),p.some(b=>!Vd(x).includes(b))&&t(["resources",f,"options"],"Every options source must bind all parent resources")}if(m.input){const g=m.input,x=g.validation,b=n.operations[x.operation],w=b==null?void 0:b.args[x.argument];!g.allowId&&!g.urls&&t(["resources",f,"input"],"Expected an accepted input format"),(!s(x.operation)||!r(b,x.argument)||(w==null?void 0:w.type)!=="string"||!w.required||b.path.filter(v=>"arg"in v&&v.arg===x.argument).length!==1)&&t(["resources",f,"input","validation"],"Validation must request the candidate as one required path argument"),(p.some(v=>!Object.hasOwn(x.parents??{},v))||Object.keys(x.parents??{}).some(v=>!p.includes(v)))&&t(["resources",f,"input","validation","parents"],"Validation must prove each selected parent")}}const i=new Set,l=new Set,c=f=>{if(i.has(f)){t(["resources",f,"dependsOn"],"Resource dependency cycle");return}if(!l.has(f)){i.add(f);for(const m of Zw(n,f))Object.hasOwn(n.resources,m)&&c(m);i.delete(f),l.add(f)}};for(const f of Object.keys(n.resources))c(f);for(const[f,m]of Object.entries(n.operations)){m.audience==="setup"&&(m.method!=="GET"||m.response)&&t(["operations",f],"Setup operations must return JSON from GET"),m.body&&m.method!=="POST"&&t(["operations",f,"body"],"Only POST operations have a body");const p=new Set;for(const[h,g]of Object.entries(m.args))(Object.hasOwn(n.resources,h)||Object.hasOwn(n.identity??{},h))&&t(["operations",f,"args",h],"Argument shadows a host-owned binding"),(g.type==="integer"||g.type==="number")&&g.min>g.max&&t(["operations",f,"args",h],"Inverted numeric bounds"),g.type==="string"&&((d=g.enum)!=null&&d.some(x=>new TextEncoder().encode(x).byteLength>g.maxLength))&&t(["operations",f,"args",h],"Enum exceeds string limit");for(const h of m.path)if("resource"in h&&!Object.hasOwn(n.resources,h.resource)&&t(["operations",f,"path"],"Unknown selected resource"),"arg"in h){const g=m.args[h.arg];((g==null?void 0:g.type)!=="string"||g.required!==!0)&&t(["operations",f,"path"],"Path argument must be a required string"),p.add(h.arg)}for(const h of[...Object.values(m.query),...Object.values(m.body??{})]){const g=typeof h=="string"?h:"arg"in h?h.arg:void 0;g!==void 0?(Object.hasOwn(m.args,g)||t(["operations",f,"query"],"Unknown query argument"),p.add(g)):typeof h=="object"&&"resource"in h&&!Object.hasOwn(n.resources,h.resource)?t(["operations",f,"query"],"Unknown selected resource"):typeof h=="object"&&"identity"in h&&!Object.hasOwn(n.identity??{},h.identity)&&t(["operations",f,"query"],"Unknown validated identity")}Object.keys(m.args).some(h=>!p.has(h))&&t(["operations",f,"args"],"Unused argument")}});function Yg(n){return zo(jV,n,en.definitionBytes)}const HC={appVersion:Le().min(1).max(128),apiVersions:at(Zg).max(16),manifestVersions:at(bt().int().min(1).max(1024)).max(16),protocolVersions:at(bt().int().min(1).max(1024)).max(16),runtimes:at(Le().min(1).max(64)).max(16),capabilities:Xn(lt,Zg).refine(n=>Object.keys(n).length<=64)},NV=xe({...HC,browser:at(Le().min(1).max(64)).max(16)}),CV=xe({...HC,platform:Le().min(1).max(32),registryRevision:bt().int().min(0).max(Number.MAX_SAFE_INTEGER)});function _V(n){return zo(NV,n,16*1024)}function EV(n){return zo(CV,n,16*1024)}function T0(n,e,t,s={}){var f;const r=[],o=[],i=(m,p)=>!!Vn.valid(m)&&!!Vn.validRange(p)&&Vn.satisfies(m,p,{includePrerelease:s.allowPrerelease===!0}),l=(m,p,h,g,x)=>r.push({side:m,code:p,name:h,required:g,actual:x});s.revoked&&l("package","REVOKED",n.id,"non-revoked package",n.version),Vn.prerelease(n.version)&&!s.allowPrerelease&&l("package","PRERELEASE",n.id,"stable release",n.version);for(const m of["client","host"]){const p=m==="client"?e:t;i(p.appVersion,n.engines[m])||l(m,"APP_VERSION","app",n.engines[m],p.appVersion),p.manifestVersions.includes(n.manifestVersion)||l(m,"MANIFEST_VERSION","manifest",String(n.manifestVersion),p.manifestVersions.join(",")),p.protocolVersions.includes(n.protocol)||l(m,"PROTOCOL_VERSION","protocol",String(n.protocol),p.protocolVersions.join(",")),p.runtimes.includes(n.runtime)||l(m,"RUNTIME","runtime",n.runtime,p.runtimes.join(","));for(const[h,g]of Object.entries(n.requires[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&l(m,"CAPABILITY",h,g,x)}for(const[h,g]of Object.entries(n.optional[m])){const x=p.capabilities[h]??null;(!x||!i(x,g))&&o.push({side:m,name:h,required:g,actual:x})}}for(const m of n.browser)e.browser.includes(m)||l("client","BROWSER",m,"available",null);const c=[],u=new Vn.Range(n.engines.pluginApi,{includePrerelease:s.allowPrerelease===!0});for(const m of e.apiVersions.filter(p=>Vn.valid(p)))for(const p of t.apiVersions.filter(h=>Vn.valid(h))){if(Vn.major(m)!==Vn.major(p))continue;const h=Vn.compare(m,p)<=0?m:p;i(h,n.engines.pluginApi)&&c.push(h);for(const g of u.set){const x=`${g.map(w=>w.value).join(" ")} >=${Vn.major(h)}.0.0 <=${h}`,b=(f=Vn.minVersion(x))==null?void 0:f.version;b&&i(b,n.engines.pluginApi)&&c.push(b)}}const d=c.sort(Vn.rcompare)[0]??null;if(!d){for(const m of["client","host"]){const p=m==="client"?e.apiVersions:t.apiVersions;p.some(h=>i(h,n.engines.pluginApi))||l(m,"API_VERSION","pluginApi",n.engines.pluginApi,p.join(","))}r.some(m=>m.code==="API_VERSION")||l("host","API_VERSION","pluginApi","common API version",t.apiVersions.join(","))}return{compatible:r.length===0,apiVersion:d,issues:r,unavailableOptional:o}}const Hd=OC(()=>!0),Yw=xe({}),TV=xe({id:lt,name:_s}).nullable(),KC=xe({mode:Ct(["light","dark"]),tokens:Xn(Le().regex(/^--[a-z][a-z0-9-]{0,63}$/u),Cs(256)).refine(n=>Object.keys(n).length<=64)}),GC=Le().regex(/^s_[a-f0-9]{48}$/u),AV=xe({handle:GC}).nullable().optional(),IV=xe({type:Ze("chat-block"),id:lt,source:Cs(16384)}).optional(),ZC=xe({project:TV,theme:KC,locale:Le().min(1).max(64),reducedMotion:Ft(),visible:Ft(),session:AV,surface:IV});function Xw(n){return zo(ZC,n,en.responseBytes)}const YC=["INVALID_REQUEST","INVALID_RESPONSE","INCOMPATIBLE_HOST","INCOMPATIBLE_CLIENT","PERMISSION_REQUIRED","CONNECTION_REQUIRED","RESOURCE_REQUIRED","STALE_ACTIVATION","RATE_LIMITED","PLUGIN_DISABLED","CAPABILITY_UNAVAILABLE","UPSTREAM_FAILED","CANCELED","TIMEOUT","DISPOSED"],PV=xe({code:Ct(YC),message:Cs(512)}),ll=Le().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/u),$V=Le().min(1).max(2048).refine(n=>{try{const e=new URL(n);return e.protocol==="https:"&&!e.username&&!e.password}catch{return!1}},"Expected an HTTPS URL without credentials"),eh=lt,XC={"lifecycle.ready":Yw,"connections.request":xe({handle:lt,operationId:lt,args:Xn(lt,to([Le(),bt().finite(),Ft()]))}),"connections.media":xe({handle:lt,operationId:lt,args:Xn(lt,to([Le(),bt().finite(),Ft()]))}),"connections.status":xe({handle:lt}),"integrations.request":cV,"storage.get":xe({key:eh}),"storage.set":xe({key:eh,value:Hd}),"storage.delete":xe({key:eh}),"composer.append":xe({text:Cs(en.composerBytes)}),"navigation.openExternal":xe({url:$V}),"navigation.openSession":xe({handle:lt}),"settings.get":Yw,"ui.resize":xe({height:bt().int().min(80).max(800)})},RV=xe({configured:Ft(),readOnly:Ft(),selected:Xn(lt,xe({id:Cs(1024),label:Cs(256)})).refine(n=>Object.keys(n).length<=8)}),OV=Rr("event",[xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("context"),value:ZC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("theme"),value:KC}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("visibility"),value:Ft()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("session"),value:xe({handle:GC}).nullable()}),xe({protocol:Ze(Ss),type:Ze("event"),event:Ze("dispose"),value:_C()})]),LV=to([xe({protocol:Ze(Ss),type:Ze("request"),id:ll,method:Ct(Object.keys(XC)),params:Hd}),xe({protocol:Ze(Ss),type:Ze("result"),id:ll,value:Hd}),xe({protocol:Ze(Ss),type:Ze("error"),id:ll,error:PV}),xe({protocol:Ze(Ss),type:Ze("cancel"),id:ll}),OV]);function Jw(n){var s,r,o,i,l;if(n&&typeof n=="object"&&((s=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:s.value)==="media-result"){const c=Object.getOwnPropertyDescriptors(n);if(Object.keys(c).length!==4||((r=c.protocol)==null?void 0:r.value)!==1)throw new Error("Invalid media envelope");return{protocol:1,type:"media-result",id:ll.parse((o=c.id)==null?void 0:o.value),value:em((i=c.value)==null?void 0:i.value)}}const e=n!==null&&typeof n=="object"&&((l=Object.getOwnPropertyDescriptor(n,"type"))==null?void 0:l.value)==="result",t=zo(LV,n,e?en.resultMessageBytes:en.messageBytes,e?en.responseNodes+16:en.nodes);if(t.type==="request"){const c=t.method==="connections.media"?en.messageBytes:t.method==="composer.append"?en.composerBytes+64:t.method==="storage.set"?en.storageValueBytes:en.argumentBytes,u=zo(XC[t.method],t.params,c);return{...t,params:u}}return t.type==="result"?{...t,value:l0(t.value,{maxBytes:en.responseBytes,maxNodes:en.responseNodes})}:t}function JC(n,e){if(n==="connections.media")return em(e);const t=n==="integrations.request"?uV:n==="connections.status"?RV:n==="connections.request"||n==="storage.get"||n==="settings.get"?Hd:_C();return zo(t,e,en.responseBytes,en.responseNodes)}const Qw=xe({values:Xn(Le(),to([Le().max(4096),bt().finite(),Ft()])),revision:bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),adjustedFields:at(Le().max(64)).max(32).optional()}),zc=bt().int().min(0).max(Number.MAX_SAFE_INTEGER),tm=Le().regex(/^[a-f0-9]{64}$/),rc=eo().transform(BC),QC=Rr("type",[xe({type:Ze("all")}),xe({type:Ze("projects"),projectIds:at(Le().min(1).max(512)).max(128).refine(n=>new Set(n).size===n.length)})]),MV=xe({digest:tm,manifest:rc,targetPath:Le().min(1).max(512),installedAt:zc,unavailableReason:Le().max(1e3).optional()}),zV=xe({id:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),selectedDigest:tm,manifest:rc,enabled:Ft(),scope:QC,pinned:Ft(),versions:at(MV).min(1).max(64),lastError:Le().max(1e3).optional()}),DV=xe({id:Le().max(128),label:Le().max(128),kind:Ct(["official","development"]),fingerprint:Le().max(128),verifiedAt:zc.optional()}),e_=xe({available:Ft(),error:Le().max(2e3).optional(),revision:zc,plugins:at(zV).max(256),publishers:at(DV).max(256),legacyPluginIds:at(Ct(["github","clickup","vercel-deployments"])).max(3).optional(),availableSeeds:at(xe({manifest:rc,digest:tm})).max(256).optional(),recoveryCode:Ct(["STORE_LOCKED","STORE_VERSION","STORE_CORRUPT","STORE_UNAVAILABLE"]).optional()}),FV=xe({side:Ct(["client","host"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()}),UV=xe({compatible:Ft(),apiVersion:Le().max(128).nullable(),issues:at(xe({side:Ct(["client","host","package"]),code:Ct(["APP_VERSION","API_VERSION","MANIFEST_VERSION","PROTOCOL_VERSION","RUNTIME","CAPABILITY","BROWSER","PRERELEASE","REVOKED"]),name:Le().max(128),required:Le().max(256),actual:Le().max(512).nullable()})).max(128),unavailableOptional:at(FV).max(128)});eo().transform(_V);const ud=xe({transactionId:Le().uuid(),manifest:rc,digest:tm,compatibility:UV,connectionDefinitions:at(eo().transform(Yg)).max(8),oldVersion:Le().max(128).nullable(),registryRevision:zc,publisherKind:Ct(["official","development"]),scope:QC,operation:Ct(["install","update","rollback"]).optional(),previousManifest:rc.optional(),previousConnectionDefinitions:at(eo().transform(Yg)).max(8).optional(),incompatibleClients:at(Le().max(256)).max(256).optional()}),t_=xe({id:Le().regex(/^p_[a-f0-9]{40}$/),name:Le().max(512),paths:at(Le().max(8192)).max(256)}),BV=xe({runtime:eo().transform(EV),host:xe({name:Le().max(256),instanceId:Le().max(128)}),store:e_,projects:at(t_).max(1024),safeMode:Ft(),connectionRevision:zc.optional()}),Xg=Le().regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/).max(64),A0=bt().int().nonnegative().max(Number.MAX_SAFE_INTEGER),n_=xe({pluginId:Le().regex(/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/).max(128),projectId:Le().regex(/^p_[a-f0-9]{40}$/).nullable()});n_.extend({expectedRevision:A0});const WV=n_.extend({connectionId:Xg});WV.extend({expectedRevision:A0});const s_=xe({id:Le().min(1).max(1024),label:Le().min(1).max(256)}),qV=at(s_).max(1e3),eS=xe({revision:A0,connections:at(xe({id:Xg,label:Le().min(1).max(128),status:Ct(["disconnected","connected","environment"]),readOnly:Ft(),legacyImportAvailable:Ft().optional(),selected:Xn(Xg,s_).refine(n=>Object.keys(n).length<=8),definition:eo().transform(Yg)})).max(8)}),r_="3.5.1",o_={version:r_};function cl(n=globalThis){var u,d,f,m,p,h,g,x,b,w,v,j,k,_,N,S,C,E;const e=T=>typeof T=="function",t=e(n.MessageChannel)&&e((d=(u=n.MessagePort)==null?void 0:u.prototype)==null?void 0:d.postMessage)&&e((m=(f=n.MessagePort)==null?void 0:f.prototype)==null?void 0:m.start)&&e((h=(p=n.MessagePort)==null?void 0:p.prototype)==null?void 0:h.close),s=e(n.Blob)&&e((g=n.URL)==null?void 0:g.createObjectURL)&&e((x=n.URL)==null?void 0:x.revokeObjectURL),r=e((w=(b=n.crypto)==null?void 0:b.subtle)==null?void 0:w.digest)&&e((v=n.crypto)==null?void 0:v.getRandomValues),o=n.isSecureContext===!0,l=[["secure context (HTTPS or localhost)",o],["MessageChannel",t],["Blob URLs",s],["Web Crypto",r],["AbortController",e(n.AbortController)],["AbortSignal.any",e((j=n.AbortSignal)==null?void 0:j.any)],["AbortSignal.timeout",e((k=n.AbortSignal)==null?void 0:k.timeout)],["AbortSignal.throwIfAborted",e((N=(_=n.AbortSignal)==null?void 0:_.prototype)==null?void 0:N.throwIfAborted)],["structuredClone",e(n.structuredClone)],["Object.hasOwn",e((S=n.Object)==null?void 0:S.hasOwn)],["fetch",e(n.fetch)],["Headers",e(n.Headers)],["ReadableStream",e((E=(C=n.ReadableStream)==null?void 0:C.prototype)==null?void 0:E.getReader)],["TextEncoder",e(n.TextEncoder)],["TextDecoder",e(n.TextDecoder)]].filter(([,T])=>!T).map(([T])=>T),c=[];return t&&c.push("message-channel"),s&&c.push("blob-script"),r&&o&&c.push("web-crypto"),{supported:l.length===0,browser:c,missing:l,error:l.length?`Runtime plugins are unavailable in this browser. Missing: ${l.join(", ")}. Update your browser or use a secure connection.`:null}}const VV=xe({sessionId:Le().regex(/^[a-f0-9]{64}$/),expiresAt:bt().int().positive()}),tS=xe({id:Le().min(1).max(128),expiresAt:bt().int().positive()}),HV=xe({deadline:bt().int().positive()}),KV=xe({status:Ct(["prepared","trial","committing","committed","cancelled","abandoned"]),preview:ud,deadline:bt().int().positive().optional()}),Jg={status:null,error:null,activation:""};function vo(){const n=cl();return{appVersion:r_,apiVersions:[gV],manifestVersions:[1],protocolVersions:[Ss],runtimes:n.supported?[UC]:[],capabilities:n.supported?{"workspace.panel":"1.0.0","composer.append":"1.0.0","navigation.external":"1.0.0","navigation.session":"1.0.0","chat.blocks":"1.0.0","session.actions":"1.0.0","media.audio":"1.0.0","settings.fields":"1.0.0"}:{},browser:n.browser}}class Qg extends Error{constructor(e,t,s){super(e),this.code=t,this.status=s}}async function e1(n,e){var c;const t=n.headers.get("Content-Length");if(t&&Number(t)>e)throw await((c=n.body)==null?void 0:c.cancel()),new Error("Plugin response exceeds its size limit");if(!n.body)throw new Error("Plugin host returned an empty response");const s=n.body.getReader(),r=[];let o=0;try{for(;;){const{done:u,value:d}=await s.read();if(u)break;if(o+=d.byteLength,o>e)throw new Error("Plugin response exceeds its size limit");r.push(d)}}catch(u){throw await s.cancel().catch(()=>{}),u}finally{s.releaseLock()}const i=new Uint8Array(o);let l=0;for(const u of r)i.set(u,l),l+=u.byteLength;return i.buffer}async function Ga(n){const e=await e1(n,4194304);let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new Error("This host does not support runtime plugins, or returned an invalid response")}if(!n.ok){const s=cq({error:Le().max(2e3),code:Le().max(128).optional()}).safeParse(t);throw new Qg(s.success?s.data.error:"Plugin request failed",s.success?s.data.code??"HOST_ERROR":"HOST_ERROR",n.status)}return t}class GV{constructor(){Ge(this,"scope",cn());Ge(this,"identity",Zn());Ge(this,"base",new URL(Ex("/api/plugins/"),window.location.origin));Ge(this,"lifetimeController");Ge(this,"session",null);Ge(this,"renewal",null);Ge(this,"refreshPromise",null);Ge(this,"timer");Ge(this,"listeners",new Set);Ge(this,"state",Jg);Ge(this,"running",!1);Ge(this,"getSnapshot",()=>this.state);Ge(this,"subscribe",e=>(this.listeners.add(e),()=>this.listeners.delete(e)));Ge(this,"hostChanged",()=>{(this.scope!==cn()||this.identity!==Zn())&&this.stop()})}get controller(){const e=cl();if(!e.supported)throw new Qg(e.error,"UNSUPPORTED_BROWSER",0);if(!this.lifetimeController)throw new Error("The plugin client has not started");return this.lifetimeController}publish(e){if(JSON.stringify(this.state)!==JSON.stringify(e)){this.state=e;for(const t of this.listeners)t()}}assertCurrent(e){const t=this.controller.signal;if((e??t).throwIfAborted(),!this.running||this.scope!==cn()||this.identity!==Zn())throw new Error("The connected host or signed-in user changed")}start(){if(this.running)return;const e=cl();if(!e.supported){this.publish({status:null,error:e.error,activation:""});return}this.running=!0,this.lifetimeController=new AbortController;for(const t of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.addEventListener(t,this.hostChanged);this.refresh(),this.timer=setInterval(()=>{this.refresh()},5e3)}stop(){var t;this.running=!1,clearInterval(this.timer),(t=this.lifetimeController)==null||t.abort();const e=this.session;this.session=null,this.renewal=null,this.refreshPromise=null;for(const s of["cogpit-device-changed","cogpit-device-scope-changed","cogpit-identity-changed","popstate"])window.removeEventListener(s,this.hostChanged);this.publish(Jg),e&&this.releaseSession(e.sessionId)}releaseSession(e){cl().supported&&Ce(new URL("session",this.base),{method:"DELETE",headers:{"X-Cogpit-Plugin-Session":e},signal:AbortSignal.timeout(5e3),keepalive:!0}).catch(()=>{})}async ensureSession(){if(this.assertCurrent(),this.session&&this.session.expiresAt-Date.now()>25e3)return;if(this.renewal)return this.renewal;const e=this.controller.signal,t=new Headers;t.set("Content-Type","application/json"),this.session&&t.set("X-Cogpit-Plugin-Session",this.session.sessionId);const s=(async()=>{const r=await Ce(new URL("session",this.base),{method:"POST",headers:t,body:JSON.stringify({client:vo()}),signal:AbortSignal.any([e,AbortSignal.timeout(2e4)])}),o=VV.parse(await Ga(r));try{this.assertCurrent(e)}catch(i){throw this.releaseSession(o.sessionId),i}this.session=o})();this.renewal=s;try{await s}finally{this.renewal===s&&(this.renewal=null)}}async request(e,t={}){const s=this.controller.signal;await this.ensureSession(),this.assertCurrent(s);const r=new Headers(t.headers);r.set("X-Cogpit-Plugin-Session",this.session.sessionId);const o=await Ce(new URL(e,this.base),{...t,headers:r,signal:AbortSignal.any([s,...t.signal?[t.signal]:[],AbortSignal.timeout(3e4)])});return this.assertCurrent(s),o}async json(e,t,s="POST",r){const o=this.controller.signal,i=await this.request(e,{method:s,signal:r,...t===void 0?{}:{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}}}),l=await Ga(i);return this.assertCurrent(o),l}refresh(){const e=cl();if(!e.supported)return this.stop(),this.publish({status:null,error:e.error,activation:""}),Promise.resolve();if(this.refreshPromise)return this.refreshPromise;const t=this.controller.signal,s=(async()=>{var r;try{const o=BV.parse(await this.json("status",void 0,"GET"));if(this.assertCurrent(t),((r=this.state.status)==null?void 0:r.host.instanceId)===o.host.instanceId&&this.state.status.store.revision>o.store.revision)return;this.publish({status:o,error:null,activation:`${this.scope}:${this.identity??"personal"}:${o.host.instanceId}:${this.session.sessionId}:${o.connectionRevision??0}`})}catch(o){if(t.aborted||!this.running)return;o instanceof Qg&&o.code==="STALE_ACTIVATION"&&(this.session=null),this.publish({status:null,error:o instanceof Error?o.message:"Plugin host is unavailable",activation:""})}})();return this.refreshPromise=s,s.finally(()=>{this.refreshPromise===s&&(this.refreshPromise=null)}),s}async stageSeed(e,t){return ud.parse(await this.json("stage-seed",{pluginId:e,scope:t,client:vo()}))}async stage(e,t){const s=this.controller.signal;if(e.size>4*1024*1024)throw new Error("Choose a plugin package smaller than 4 MiB");const r=ud.parse(await Ga(await this.request("stage",{method:"POST",body:e,headers:{"Content-Type":"application/octet-stream","X-Cogpit-Plugin-Client":JSON.stringify(vo()),"X-Cogpit-Plugin-Scope":JSON.stringify(t)}})));return this.assertCurrent(s),r}async payload(e,t){const s=this.controller.signal,r=await this.request(`payload/${encodeURIComponent(e)}`,{signal:t});r.ok||await Ga(r);const o=await e1(r,4*1024*1024);return this.assertCurrent(s),t==null||t.throwIfAborted(),o}async settings(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return Qw.parse(await this.json(`settings?${s}`,void 0,"GET",t))}async saveSettings(e,t,s,r){return Qw.parse(await this.json("settings",{...e,values:t,expectedRevision:s},"POST",r))}async media(e,t,s){var l;const r=this.controller.signal,o=await this.request(`leases/${encodeURIComponent(e)}/call`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:s});o.ok||await Ga(o);const i=await e1(o,E0);return this.assertCurrent(r),s==null||s.throwIfAborted(),em({mimeType:(l=o.headers.get("Content-Type"))==null?void 0:l.split(";")[0],bytes:i})}acceptStore(e){const t=e_.parse(e),s=this.state.status;s&&t.revision>=s.store.revision&&this.publish({...this.state,status:{...s,store:t,runtime:{...s.runtime,registryRevision:t.revision}}})}async beginTrial(e,t){return HV.parse(await this.json(`transactions/${e.transactionId}/trial`,void 0,"POST",t)).deadline}async commit(e,t){this.acceptStore(await this.json(`transactions/${e.transactionId}/commit`,{expectedRevision:e.registryRevision},"POST",t)),await this.refresh()}async transactionOutcome(e){return KV.parse(await this.json(`transactions/${e.transactionId}`,void 0,"GET"))}async cancel(e){await this.json(`transactions/${e.transactionId}`,void 0,"DELETE")}async enrollDeveloper(e){this.acceptStore(await this.json("publishers",{...e,development:!0})),await this.refresh()}async changeInstalled(e,t,s,r){const o=`installed/${encodeURIComponent(e)}${t==="uninstall"?"":`/${t}`}`;this.acceptStore(await this.json(o,{...s,expectedRevision:r},t==="uninstall"?"DELETE":"POST")),await this.refresh()}async rollback(e,t,s){return ud.parse(await this.json(`installed/${encodeURIComponent(e)}/rollback`,{digest:t,scope:s,client:vo()}))}async lease(e,t,s,r,o){return tS.parse(await this.json("leases",{pluginId:e,projectId:t,contextEpoch:s,...o?{workspacePath:o}:{},client:vo()},"POST",r))}async renewLease(e,t){return tS.parse(await this.json(`leases/${encodeURIComponent(e)}/renew`,void 0,"POST",t))}async revokeLease(e){await this.json(`leases/${encodeURIComponent(e)}`,void 0,"DELETE")}async call(e,t,s){if(t.method==="connections.media")throw new Error("Use the binary media transport for audio");const r=xe({value:eo()}).parse(await this.json(`leases/${encodeURIComponent(e)}/call`,t,"POST",s));return JC(t.method,r.value)}async resolveSession(e,t,s){return xe({dirName:Le().min(1).max(8192),fileName:Le().min(1).max(8192)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session`,{handle:t},"POST",s))}async sessionHandle(e,t,s){return xe({handle:Le().regex(/^s_[a-f0-9]{48}$/)}).parse(await this.json(`leases/${encodeURIComponent(e)}/session-handle`,t,"POST",s)).handle}async resolveWorkspace(e,t){return t_.nullable().parse(await this.json("workspace/resolve",{workspacePath:e},"POST",t))}async connections(e,t){const s=new URLSearchParams({pluginId:e.pluginId,...e.projectId?{projectId:e.projectId}:{}});return eS.parse(await this.json(`connections?${s}`,void 0,"GET",t))}async connectionOptions(e,t,s,r){return qV.parse(await this.json("connections/options",{...e,connectionId:t,resourceId:s},"POST",r))}async changeConnection(e,t,s,r,o,i){const l=eS.parse(await this.json(`connections/${s}`,{...e,connectionId:t,...r,expectedRevision:o},"POST",i));return await this.refresh(),l}async clearPluginData(e,t,s){await this.json("connections/clear-data",{pluginId:e,expectedRevision:t},"POST",s),await this.refresh()}}const yo=0,Te=1,ot=2,ln=3,$t=4,bs=5,Dc=6,An=7,Hn=8,mt=9,rt=10,Ht=11,ft=12,Ut=13,Fc=14,ts=15,Un=16,Bn=17,ls=18,cs=19,os=20,ht=21,et=22,wn=23,Jn=24,gn=25,ZV=0;function In(n){return n>=48&&n<=57}function Do(n){return In(n)||n>=65&&n<=70||n>=97&&n<=102}function I0(n){return n>=65&&n<=90}function YV(n){return n>=97&&n<=122}function XV(n){return I0(n)||YV(n)}function JV(n){return n>=128}function Kd(n){return XV(n)||JV(n)||n===95}function i_(n){return Kd(n)||In(n)||n===45}function QV(n){return n>=0&&n<=8||n===11||n>=14&&n<=31||n===127}function Gd(n){return n===10||n===13||n===12}function vi(n){return Gd(n)||n===32||n===9}function qs(n,e){return!(n!==92||Gd(e)||e===ZV)}function dd(n,e,t){return n===45?Kd(e)||e===45||qs(e,t):Kd(n)?!0:n===92?qs(n,e):!1}function th(n,e,t){return n===43||n===45?In(e)?2:e===46&&In(t)?3:0:n===46?In(e)?2:0:In(n)?1:0}function a_(n){return n===65279||n===65534?1:0}const t1=new Array(128),eH=128,fd=130,l_=131,P0=132,c_=133;for(let n=0;n<t1.length;n++)t1[n]=vi(n)&&fd||In(n)&&l_||Kd(n)&&P0||QV(n)&&c_||n||eH;function nh(n){return n<128?t1[n]:P0}function Xi(n,e){return e<n.length?n.charCodeAt(e):0}function n1(n,e,t){return t===13&&Xi(n,e+1)===10?2:1}function Ji(n,e,t){let s=n.charCodeAt(e);return I0(s)&&(s=s|32),s===t}function oc(n,e,t,s){if(t-e!==s.length||e<0||t>n.length)return!1;for(let r=e;r<t;r++){const o=s.charCodeAt(r-e);let i=n.charCodeAt(r);if(I0(i)&&(i=i|32),i!==o)return!1}return!0}function tH(n,e){for(;e>=0&&vi(n.charCodeAt(e));e--);return e+1}function Nu(n,e){for(;e<n.length&&vi(n.charCodeAt(e));e++);return e}function sh(n,e){for(;e<n.length&&In(n.charCodeAt(e));e++);return e}function yi(n,e){if(e+=2,Do(Xi(n,e-1))){for(const s=Math.min(n.length,e+5);e<s&&Do(Xi(n,e));e++);const t=Xi(n,e);vi(t)&&(e+=n1(n,e,t))}return e}function Cu(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(!i_(t)){if(qs(t,Xi(n,e+1))){e=yi(n,e)-1;continue}break}}return e}function nm(n,e){let t=n.charCodeAt(e);if((t===43||t===45)&&(t=n.charCodeAt(e+=1)),In(t)&&(e=sh(n,e+1),t=n.charCodeAt(e)),t===46&&In(n.charCodeAt(e+1))&&(e+=2,e=sh(n,e)),Ji(n,e,101)){let s=0;t=n.charCodeAt(e+1),(t===45||t===43)&&(s=1,t=n.charCodeAt(e+2)),In(t)&&(e=sh(n,e+1+s+1))}return e}function rh(n,e){for(;e<n.length;e++){const t=n.charCodeAt(e);if(t===41){e++;break}qs(t,Xi(n,e+1))&&(e=yi(n,e))}return e}function $0(n){if(n.length===1&&!Do(n.charCodeAt(0)))return n[0];let e=parseInt(n,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const s1=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],nH=16*1024;function Zd(n=null,e){return n===null||n.length<e?new Uint32Array(Math.max(e+1024,nH)):n}const nS=10,sH=12,sS=13;function rS(n){const e=n.source,t=e.length,s=e.length>0?a_(e.charCodeAt(0)):0,r=Zd(n.lines,t),o=Zd(n.columns,t);let i=n.startLine,l=n.startColumn;for(let c=s;c<t;c++){const u=e.charCodeAt(c);r[c]=i,o[c]=l++,(u===nS||u===sS||u===sH)&&(u===sS&&c+1<t&&e.charCodeAt(c+1)===nS&&(c++,r[c]=i,o[c]=l),i++,l=1)}r[t]=i,o[t]=l,n.lines=r,n.columns=o,n.computed=!0}class rH{constructor(e,t,s,r){this.setSource(e,t,s,r),this.lines=null,this.columns=null}setSource(e="",t=0,s=1,r=1){this.source=e,this.startOffset=t,this.startLine=s,this.startColumn=r,this.computed=!1}getLocation(e,t){return this.computed||rS(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,s){return this.computed||rS(this),{source:s,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}}const Rs=16777215,Os=24,Uc=1,sm=2,ko=new Uint8Array(32);ko[ot]=et;ko[ht]=et;ko[cs]=os;ko[wn]=Jn;const Vs=new Uint8Array(32);Vs[ot]=Uc;Vs[ht]=Uc;Vs[cs]=Uc;Vs[wn]=Uc;Vs[et]=sm;Vs[os]=sm;Vs[Jn]=sm;function oS(n,e,t){return n<e?e:n>t?t:n}class oH{constructor(e,t){this.setSource(e,t)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",t=()=>{}){e=String(e||"");const s=e.length,r=Zd(this.offsetAndType,e.length+1),o=Zd(this.balance,e.length+1);let i=0,l=-1,c=0,u=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),t(e,(d,f,m)=>{const p=i++;if(r[p]=d<<Os|m,l===-1&&(l=f),o[p]=u,d===c){const h=o[u];o[u]=p,u=h,c=ko[r[h]>>Os]}else this.isBlockOpenerTokenType(d)&&(u=p,c=ko[d])}),r[i]=yo<<Os|s,o[i]=i;for(let d=0;d<i;d++){const f=o[d];if(f<=d){const m=o[f];m!==d&&(o[d]=m)}else f>i&&(o[d]=i)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=i,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>Os:yo}lookupTypeNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return s}return yo}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.source.length}lookupOffsetNonSC(e){for(let t=this.tokenIndex;t<this.tokenCount;t++){const s=this.offsetAndType[t]>>Os;if(s!==Ut&&s!==gn&&e--===0)return t-this.tokenIndex}return yo}lookupValue(e,t){return e+=this.tokenIndex,e<this.tokenCount?oc(this.source,this.offsetAndType[e-1]&Rs,this.offsetAndType[e]&Rs,t):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&Rs:this.offsetAndType[this.tokenCount]&Rs:this.firstCharOffset}getTokenEnd(e){return e===this.tokenIndex?this.tokenEnd:this.offsetAndType[oS(e,0,this.tokenCount)]&Rs}getTokenType(e){return e===this.tokenIndex?this.tokenType:this.offsetAndType[oS(e,0,this.tokenCount)]>>Os}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBlockOpenerTokenType(e){return Vs[e]===Uc}isBlockCloserTokenType(e){return Vs[e]===sm}getBlockTokenPairIndex(e){const t=this.getTokenType(e);if(Vs[t]===1){const s=this.balance[e],r=this.getTokenType(s);return ko[t]===r?s:-1}else if(Vs[t]===2){const s=this.balance[e],r=this.getTokenType(s);return ko[r]===t?s:-1}return-1}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,t){return t?this.lookupType(t)===mt&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===mt&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.offsetAndType[t-1]&Rs,t=this.offsetAndType[t],this.tokenType=t>>Os,this.tokenEnd=t&Rs):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Os,this.tokenEnd=e&Rs):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=yo,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===Ut||this.tokenType===gn;)this.next()}skipUntilBalanced(e,t){let s=e,r=0,o=0;e:for(;s<this.tokenCount;s++){if(r=this.balance[s],r<e)break e;switch(o=s>0?this.offsetAndType[s-1]&Rs:this.firstCharOffset,t(this.source.charCodeAt(o))){case 1:break e;case 2:s++;break e;default:this.isBlockOpenerTokenType(this.offsetAndType[s]>>Os)&&(s=r)}}this.skip(s-this.tokenIndex)}forEachToken(e){for(let t=0,s=this.firstCharOffset;t<this.tokenCount;t++){const r=s,o=this.offsetAndType[t],i=o&Rs,l=o>>Os;s=i,e(l,r,i,t)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((t,s,r,o)=>{e[o]={idx:o,type:s1[t],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function rm(n,e){function t(f){return f<l?n.charCodeAt(f):0}function s(){if(u=nm(n,u),dd(t(u),t(u+1),t(u+2))){d=ft,u=Cu(n,u);return}if(t(u)===37){d=Ht,u++;return}d=rt}function r(){const f=u;if(u=Cu(n,u),oc(n,f,u,"url")&&t(u)===40){if(u=Nu(n,u+1),t(u)===34||t(u)===39){d=ot,u=f+4;return}i();return}if(t(u)===40){d=ot,u++;return}d=Te}function o(f){for(f||(f=t(u++)),d=bs;u<n.length;u++){const m=n.charCodeAt(u);switch(nh(m)){case f:u++;return;case fd:if(Gd(m)){u+=n1(n,u,m),d=Dc;return}break;case 92:if(u===n.length-1)break;const p=t(u+1);Gd(p)?u+=n1(n,u+1,p):qs(m,p)&&(u=yi(n,u)-1);break}}}function i(){for(d=An,u=Nu(n,u);u<n.length;u++){const f=n.charCodeAt(u);switch(nh(f)){case 41:u++;return;case fd:if(u=Nu(n,u),t(u)===41||u>=n.length){u<n.length&&u++;return}u=rh(n,u),d=Hn;return;case 34:case 39:case 40:case c_:u=rh(n,u),d=Hn;return;case 92:if(qs(f,t(u+1))){u=yi(n,u)-1;break}u=rh(n,u),d=Hn;return}}}n=String(n||"");const l=n.length;let c=a_(t(0)),u=c,d;for(;u<l;){const f=n.charCodeAt(u);switch(nh(f)){case fd:d=Ut,u=Nu(n,u+1);break;case 34:o();break;case 35:i_(t(u+1))||qs(t(u+1),t(u+2))?(d=$t,u=Cu(n,u+1)):(d=mt,u++);break;case 39:o();break;case 40:d=ht,u++;break;case 41:d=et,u++;break;case 43:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 44:d=ls,u++;break;case 45:th(f,t(u+1),t(u+2))?s():t(u+1)===45&&t(u+2)===62?(d=ts,u=u+3):dd(f,t(u+1),t(u+2))?r():(d=mt,u++);break;case 46:th(f,t(u+1),t(u+2))?s():(d=mt,u++);break;case 47:t(u+1)===42?(d=gn,u=n.indexOf("*/",u+2),u=u===-1?n.length:u+2):(d=mt,u++);break;case 58:d=Un,u++;break;case 59:d=Bn,u++;break;case 60:t(u+1)===33&&t(u+2)===45&&t(u+3)===45?(d=Fc,u=u+4):(d=mt,u++);break;case 64:dd(t(u+1),t(u+2),t(u+3))?(d=ln,u=Cu(n,u+1)):(d=mt,u++);break;case 91:d=cs,u++;break;case 92:qs(f,t(u+1))?r():(d=mt,u++);break;case 93:d=os,u++;break;case 123:d=wn,u++;break;case 125:d=Jn,u++;break;case l_:s();break;case P0:r();break;default:d=mt,u++}e(d,c,c=u)}}let Ei=null;class jn{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return jn.createItem(e)}allocateCursor(e,t){let s;return Ei!==null?(s=Ei,Ei=Ei.cursor,s.prev=e,s.next=t,s.cursor=this.cursor):s={prev:e,next:t,cursor:this.cursor},this.cursor=s,s}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=Ei,Ei=e}updateCursors(e,t,s,r){let{cursor:o}=this;for(;o!==null;)o.prev===e&&(o.prev=t),o.next===s&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let t=this.head;t!==null;t=t.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let t=null;this.head=null;for(let s of e){const r=jn.createItem(s);t!==null?t.next=r:this.head=r,r.prev=t,t=r}return this.tail=t,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,t=this){const s=this.allocateCursor(null,this.head);for(;s.next!==null;){const r=s.next;s.next=r.next,e.call(t,r.data,r,this)}this.releaseCursor()}forEachRight(e,t=this){const s=this.allocateCursor(this.tail,null);for(;s.prev!==null;){const r=s.prev;s.prev=r.prev,e.call(t,r.data,r,this)}this.releaseCursor()}reduce(e,t,s=this){let r=this.allocateCursor(null,this.head),o=t,i;for(;r.next!==null;)i=r.next,r.next=i.next,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}reduceRight(e,t,s=this){let r=this.allocateCursor(this.tail,null),o=t,i;for(;r.prev!==null;)i=r.prev,r.prev=i.prev,o=e.call(s,o,i.data,i,this);return this.releaseCursor(),o}some(e,t=this){for(let s=this.head;s!==null;s=s.next)if(e.call(t,s.data,s,this))return!0;return!1}map(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)s.appendData(e.call(t,r.data,r,this));return s}filter(e,t=this){const s=new jn;for(let r=this.head;r!==null;r=r.next)e.call(t,r.data,r,this)&&s.appendData(r.data);return s}nextUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(null,e);for(;r.next!==null;){const o=r.next;if(r.next=o.next,t.call(s,o.data,o,this))break}this.releaseCursor()}prevUntil(e,t,s=this){if(e===null)return;const r=this.allocateCursor(e,null);for(;r.prev!==null;){const o=r.prev;if(r.prev=o.prev,t.call(s,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new jn;for(let t of this)e.appendData(t);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(jn.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(jn.createItem(e))}insert(e,t=null){if(t!==null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,t){return this.insert(jn.createItem(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(jn.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(jn.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,t){return e.head===null?this:(t!=null?(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)}}function om(n,e){const t=Object.create(SyntaxError.prototype),s=new Error;return Object.assign(t,{name:n,message:e,get stack(){return(s.stack||"").replace(/^(.+\n){1,3}/,`${n}: ${e}
|
|
71
71
|
`)}})}const oh=100,iS=60,aS=" ";function lS({source:n,line:e,column:t,baseLine:s,baseColumn:r},o){function i(h,g){return u.slice(h,g).map((x,b)=>String(h+b+1).padStart(m)+" |"+x).join(`
|
|
72
72
|
`)}const l=`
|
|
73
73
|
`.repeat(Math.max(s-1,0)),c=" ".repeat(Math.max(r-1,0)),u=(l+c+n).split(/\r\n?|\n|\f/),d=Math.max(1,e-o)-1,f=Math.min(e+o,u.length+1),m=Math.max(4,String(f).length)+1;let p=0;t+=(aS.length-1)*(u[e-1].substr(0,t-1).match(/\t/g)||[]).length,t>oh&&(p=t-iS+3,t=iS-2);for(let h=d;h<=f;h++)h>=0&&h<u.length&&(u[h]=u[h].replace(/\t/g,aS),u[h]=(p>0&&u[h].length>p?"…":"")+u[h].substr(p,oh-2)+(u[h].length>p+oh-1?"…":""));return[i(d,e),new Array(t+m+2).join("-")+"^",i(e,f)].filter(Boolean).join(`
|
|
@@ -331,7 +331,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
331
331
|
}
|
|
332
332
|
`,XQ=[...Array.from(YQ.matchAll(/--color-[\w-]+:\s*var\((--[\w-]+)\)/g),n=>n[1]),"--surface-opacity","--surface-rgb","--surface","--surface-hover","--radius","--font-sans","--font-mono"];function pk(){const n=document.documentElement,e=getComputedStyle(n),t={};for(const s of XQ){const r=e.getPropertyValue(s).trim();r&&new TextEncoder().encode(r).byteLength<=256&&(t[s]=r)}return{theme:{mode:n.classList.contains("dark")?"dark":"light",tokens:t},locale:(n.lang||navigator.language||"en").slice(0,64),reducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function BE(n,e,t,s,r=null){let o="";for(const l of(e==null?void 0:e.name.trim())??""){if(o.length+l.length>128)break;l.charCodeAt(0)>=32&&l.charCodeAt(0)!==127&&(o+=l)}const i=n.permissions.context.includes("session.identity")?{session:r?{handle:r}:null}:{};return{...s,project:e&&n.permissions.context.includes("project.identity")?{id:e.id,name:o.trim()||"Project"}:null,visible:t,...i}}function WE(){const n=V.c(2),[e,t]=y.useState(pk);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=()=>{const c=pk();t(u=>JSON.stringify(u)===JSON.stringify(c)?u:c)},i=new MutationObserver(o);i.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","lang"]});const l=window.matchMedia("(prefers-reduced-motion: reduce)");return l.addEventListener("change",o),window.addEventListener("languagechange",o),()=>{i.disconnect(),l.removeEventListener("change",o),window.removeEventListener("languagechange",o)}},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}function JQ(n,e,t){if(!e)return null;const s=l=>{const c=(t==="win32"?l.replaceAll("\\","/").toLowerCase():l).replace(/\/+$/,"")||"/";return c.split("/").some(u=>u==="."||u==="..")?null:c},r=s(e);if(!r)return null;let o=null,i=-1;for(const l of n)for(const c of l.paths){const u=s(c);u&&u.length>i&&(r===u||r.startsWith(u.endsWith("/")?u:`${u}/`))&&(o=l,i=u.length)}return o}function qE(n){const e=V.c(22),{client:t,status:s,activation:r,projectPath:o}=n,i=!!(s!=null&&s.store.available)&&!!r;let l;e[0]!==i||e[1]!==o||e[2]!==s?(l=i?JQ(s.projects,o,s.runtime.platform):null,e[0]=i,e[1]=o,e[2]=s,e[3]=l):l=e[3];const c=l,u=i&&!c?o:null;let d;e[4]!==r||e[5]!==o||e[6]!==(s==null?void 0:s.connectionRevision)||e[7]!==(s==null?void 0:s.host.instanceId)||e[8]!==(s==null?void 0:s.projects)||e[9]!==(s==null?void 0:s.store)?(d=JSON.stringify([r,o,s==null?void 0:s.host.instanceId,s==null?void 0:s.store.revision,s==null?void 0:s.connectionRevision,s==null?void 0:s.projects]),e[4]=r,e[5]=o,e[6]=s==null?void 0:s.connectionRevision,e[7]=s==null?void 0:s.host.instanceId,e[8]=s==null?void 0:s.projects,e[9]=s==null?void 0:s.store,e[10]=d):d=e[10];const f=d,[m,p]=y.useState(null);let h,g;if(e[11]!==t||e[12]!==f||e[13]!==u?(h=()=>{if(!u)return;const b=new AbortController;return Promise.resolve().then(()=>(b.signal.throwIfAborted(),t.resolveWorkspace(u,b.signal))).then(w=>{b.signal.aborted||p({key:f,project:w})}).catch(()=>{b.signal.aborted||p({key:f,project:null})}),()=>b.abort()},g=[t,f,u],e[11]=t,e[12]=f,e[13]=u,e[14]=h,e[15]=g):(h=e[14],g=e[15]),y.useEffect(h,g),!i||!o){let b;return e[16]===Symbol.for("react.memo_cache_sentinel")?(b={project:null,resolving:!1},e[16]=b):b=e[16],b}if(c){let b;return e[17]!==c?(b={project:c,resolving:!1},e[17]=c,e[18]=b):b=e[18],b}let x;return e[19]!==f||e[20]!==m?(x=(m==null?void 0:m.key)===f?{project:m.project,resolving:!1}:{project:null,resolving:!0},e[19]=f,e[20]=m,e[21]=x):x=e[21],x}const VE=()=>new URLSearchParams(window.location.search).get("pluginSafeMode")==="1",QQ=n=>(window.addEventListener("popstate",n),()=>window.removeEventListener("popstate",n)),J0=()=>y.useSyncExternalStore(QQ,VE,eee);function B2e(n){const e=new URL(window.location.href);n?e.searchParams.set("pluginSafeMode","1"):e.searchParams.delete("pluginSafeMode"),window.history.replaceState(window.history.state,"",e),window.dispatchEvent(new PopStateEvent("popstate"))}function eee(){return!0}const Q0=y.createContext(null),tee=()=>y.useContext(Q0);function HE(n){const e=V.c(13),{runtime:t,workspacePath:s,children:r}=n,o=J0();let i;e[0]!==t||e[1]!==s?(i={...t,projectPath:s},e[0]=t,e[1]=s,e[2]=i):i=e[2];const{project:l,resolving:c}=qE(i),{client:u,status:d,error:f,activation:m}=t,p=o||c?"":m;let h;e[3]!==u||e[4]!==f||e[5]!==l||e[6]!==d||e[7]!==p||e[8]!==s?(h={client:u,status:d,error:f,activation:p,project:l,workspacePath:s},e[3]=u,e[4]=f,e[5]=l,e[6]=d,e[7]=p,e[8]=s,e[9]=h):h=e[9];const g=h;let x;return e[10]!==r||e[11]!==g?(x=a.jsx(Q0.Provider,{value:g,children:r}),e[10]=r,e[11]=g,e[12]=x):x=e[12],x}function nee(n){var g,x,b,w;const e=V.c(21),{language:t,source:s,instanceKey:r,fallback:o}=n,i=y.useContext(Q0);let l;e[0]!==t?(l=FC(t),e[0]=t,e[1]=l):l=e[1];const c=l;let u,d,f,m;if(e[2]!==o||e[3]!==r||e[4]!==i||e[5]!==s||e[6]!==(c==null?void 0:c.blockId)||e[7]!==(c==null?void 0:c.pluginId)){m=Symbol.for("react.early_return_sentinel");e:{if(d=(g=i==null?void 0:i.status)==null?void 0:g.store.plugins.find(v=>v.id===(c==null?void 0:c.pluginId)),u=(x=d==null?void 0:d.manifest.contributes.chatBlocks)==null?void 0:x.find(v=>v.id===(c==null?void 0:c.blockId)),!(i!=null&&i.activation)||!((b=i.status)!=null&&b.store.available)||i.status.safeMode||!(d!=null&&d.enabled)||!u||Pl(s)>16384||d.scope.type==="projects"&&(!i.project||!d.scope.projectIds.includes(i.project.id))||!T0(d.manifest,vo(),i.status.runtime,{allowPrerelease:d.manifest.publisher.startsWith("dev-")}).compatible){let v;e[12]!==o?(v=a.jsx(a.Fragment,{children:o}),e[12]=o,e[13]=v):v=e[13],m=v;break e}f=JSON.stringify([i.activation,i.status.store.revision,d.selectedDigest,(w=i.project)==null?void 0:w.id,i.workspacePath,u.id,r,s])}e[2]=o,e[3]=r,e[4]=i,e[5]=s,e[6]=c==null?void 0:c.blockId,e[7]=c==null?void 0:c.pluginId,e[8]=u,e[9]=d,e[10]=f,e[11]=m}else u=e[8],d=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=f;let h;return e[14]!==u||e[15]!==o||e[16]!==p||e[17]!==d||e[18]!==i||e[19]!==s?(h=a.jsx(see,{runtime:i,plugin:d,block:u,source:s,fallback:o},p),e[14]=u,e[15]=o,e[16]=p,e[17]=d,e[18]=i,e[19]=s,e[20]=h):h=e[20],h}function see(n){const e=V.c(16),{runtime:t,plugin:s,block:r,source:o,fallback:i}=n,l=y.useRef(null),[c,u]=y.useState(!1),[d,f]=y.useState(r.height);let m,p;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{if(!l.current)return;if(typeof IntersectionObserver>"u"){u(!0);return}const w=new IntersectionObserver(v=>u(v.some(ree)),{rootMargin:"200px"});return w.observe(l.current),()=>w.disconnect()},p=[],e[0]=m,e[1]=p):(m=e[0],p=e[1]),y.useEffect(m,p);let h;e[2]!==d?(h={minHeight:d},e[2]=d,e[3]=h):h=e[3];const g=`${s.id}:${r.id}`;let x;e[4]!==r||e[5]!==i||e[6]!==d||e[7]!==s||e[8]!==t||e[9]!==o||e[10]!==c?(x=c?a.jsx(oee,{runtime:t,plugin:s,block:r,source:o,height:d,resize:f,fallback:i}):a.jsxs("div",{className:"rounded-lg border bg-card p-3 text-sm",children:[a.jsx("p",{className:"mb-2 font-medium",children:r.title}),a.jsx("p",{className:"whitespace-pre-wrap",children:o})]}),e[4]=r,e[5]=i,e[6]=d,e[7]=s,e[8]=t,e[9]=o,e[10]=c,e[11]=x):x=e[11];let b;return e[12]!==h||e[13]!==g||e[14]!==x?(b=a.jsx("div",{ref:l,style:h,className:"my-3","data-plugin-block":g,children:x}),e[12]=h,e[13]=g,e[14]=x,e[15]=b):b=e[15],b}function ree(n){return n.isIntersecting}function oee(n){const e=V.c(40),{runtime:t,plugin:s,block:r,source:o,height:i,resize:l,fallback:c}=n,u=WE(),[d,f]=y.useState(null),[m,p]=y.useState(null),[h]=y.useState(iee);let g,x;e[0]!==h||e[1]!==s.id||e[2]!==s.selectedDigest||e[3]!==l||e[4]!==t.client||e[5]!==t.project||e[6]!==t.workspacePath?(g=()=>{var E;const C=UE({client:t.client,pluginId:s.id,digest:s.selectedDigest,projectId:((E=t.project)==null?void 0:E.id)??null,workspacePath:t.project?t.workspacePath:null,contextEpoch:h,active:!0,resize:l,onLoaded:(T,$)=>f({payload:T,leaseId:$,activation:C}),onError:T=>p(T.message)});return()=>C.dispose()},x=[t.client,t.project,t.workspacePath,s.id,s.selectedDigest,h,l],e[0]=h,e[1]=s.id,e[2]=s.selectedDigest,e[3]=l,e[4]=t.client,e[5]=t.project,e[6]=t.workspacePath,e[7]=g,e[8]=x):(g=e[7],x=e[8]),y.useEffect(g,x);let b;e[9]!==s.manifest||e[10]!==u||e[11]!==t.project?(b=BE(s.manifest,t.project,!0,u),e[9]=s.manifest,e[10]=u,e[11]=t.project,e[12]=b):b=e[12];let w;e[13]!==r.id||e[14]!==o?(w={type:"chat-block",id:r.id,source:o},e[13]=r.id,e[14]=o,e[15]=w):w=e[15];let v;e[16]!==b||e[17]!==w?(v={...b,surface:w},e[16]=b,e[17]=w,e[18]=v):v=e[18];const j=v;if(m){let C;e[19]!==r.title||e[20]!==m?(C=a.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[r.title," could not load. ",m]}),e[19]=r.title,e[20]=m,e[21]=C):C=e[21];let E;return e[22]!==c||e[23]!==C?(E=a.jsxs(a.Fragment,{children:[c,C]}),e[22]=c,e[23]=C,e[24]=E):E=e[24],E}if(!d){let C;return e[25]!==r.title?(C=a.jsxs("div",{role:"status",className:"rounded-lg border bg-card p-3 text-sm",children:["Loading ",r.title,"…"]}),e[25]=r.title,e[26]=C):C=e[26],C}let k;e[27]!==i?(k={height:i},e[27]=i,e[28]=k):k=e[28];const _=`${h}:${d.leaseId}`;let N;e[29]!==r.title||e[30]!==j||e[31]!==d.activation.execute||e[32]!==d.activation.fail||e[33]!==d.payload||e[34]!==s.selectedDigest||e[35]!==_?(N=a.jsx(FE,{payload:d.payload,digest:s.selectedDigest,activationKey:_,context:j,active:!0,title:r.title,execute:d.activation.execute,onError:d.activation.fail}),e[29]=r.title,e[30]=j,e[31]=d.activation.execute,e[32]=d.activation.fail,e[33]=d.payload,e[34]=s.selectedDigest,e[35]=_,e[36]=N):N=e[36];let S;return e[37]!==k||e[38]!==N?(S=a.jsx("div",{style:k,children:N}),e[37]=k,e[38]=N,e[39]=S):S=e[39],S}function iee(){return crypto.randomUUID()}function aee(){const n=V.c(2),e=tee();let t;return n[0]!==e?(t=e?a.jsx(lee,{runtime:e}):null,n[0]=e,n[1]=t):t=n[1],t}function lee({runtime:n}){var m,p;const e=nz(),t=sz(),[s,r]=y.useState(null),[o,i]=y.useState(null),l=y.useRef({epoch:0,locked:!1}),c=(m=e==null?void 0:e.session)==null?void 0:m.sessionId;if(y.useEffect(()=>{const h=l.current;return h.epoch++,h.locked=!1,r(null),i(null),()=>{h.epoch++,h.locked=!1}},[c,n.activation]),!(n!=null&&n.activation)||!((p=n.status)!=null&&p.store.available)||n.status.safeMode||!t||!c||(e==null?void 0:e.permissions.send)===!1)return null;const u=n.status.store.plugins.filter(h=>h.enabled&&(h.scope.type==="all"||!!n.project&&h.scope.projectIds.includes(n.project.id))&&T0(h.manifest,vo(),n.status.runtime,{allowPrerelease:h.manifest.publisher.startsWith("dev-")}).compatible).flatMap(h=>(h.manifest.contributes.sessionActions??[]).map(g=>({...g,key:`${h.id}:${g.id}`})));if(!u.length)return null;const d=!!s;async function f(h){const g=l.current;if(!t||d||g.locked)return;g.locked=!0;const x=++g.epoch;r(h.key),i(null);try{!await t.chat.sendMessage(h.prompt)&&g.epoch===x&&i("The request could not be sent. Try again when the session is ready.")}catch{g.epoch===x&&i("The request could not be sent.")}finally{g.epoch===x&&(g.locked=!1,r(null))}}return a.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[u.map(h=>a.jsx(Q,{type:"button",size:"xs",variant:"ghost",className:"text-muted-foreground hover:text-foreground",disabled:d,"aria-busy":s===h.key,onClick:()=>{f(h)},children:s===h.key?"Sending…":h.title},h.key)),o&&a.jsx("span",{role:"alert",className:"text-xs text-destructive",children:o})]})}function hk(n){const e=V.c(34),{error:t}=n,[s,r]=y.useState(!1),[o,i]=y.useState(!1);let l;e[0]!==t?(l=t.split(`
|
|
333
333
|
`),e[0]=t,e[1]=l):l=e[1];const c=l[0];let u;e[2]!==t||e[3]!==c?(u=t.includes(`
|
|
334
|
-
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!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=()=>r(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Sr,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=a.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==d?(x=d&&a.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=d,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(ao,{children:[a.jsxs(or,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(Sr,{className:"size-4"}),"Error details"]}),a.jsx(ir,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=a.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let j;e[19]!==o?(j=o?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),e[19]=o,e[20]=j):j=e[20];const k=o?"Copied":"Copy";let _;e[21]!==m||e[22]!==j||e[23]!==k?(_=a.jsx("div",{className:"flex justify-end",children:a.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,k]})}),e[21]=m,e[22]=j,e[23]=k,e[24]=_):_=e[24];let N;e[25]!==v||e[26]!==_?(N=a.jsxs(rr,{className:"max-w-2xl",children:[w,v,_]}),e[25]=v,e[26]=_,e[27]=N):N=e[27];let S;e[28]!==s||e[29]!==N?(S=a.jsx(sr,{open:s,onOpenChange:r,children:N}),e[28]=s,e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==S||e[32]!==b?(C=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=C):C=e[33],C}function cee(n){const e=V.c(17),{suggestion:t,onAccept:s}=n,[r,o]=y.useState(null);if(!t||t===r)return null;let i;e[0]!==s||e[1]!==t?(i=()=>{o(t),s(t)},e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ql,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=a.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==i||e[7]!==c?(u=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:i,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=i,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==t?(d=()=>o(t),e[9]=t,e[10]=d):d=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Mt,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(Q,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:d,className:"shrink-0 text-muted-foreground",children:f}),e[12]=d,e[13]=m):m=e[13];let p;return e[14]!==u||e[15]!==m?(p=a.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16],p}function uee(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 dee(n,e,t){return`${n.slice(0,e.start)}@${t} `}function Nn(n){const e=V.c(3);let t,s;return e[0]!==n?(t=()=>xt(n),s=()=>xt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(Rf,t,s)}function fee(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function mee(n,e,t){const s=Nn("hostFiles"),[r,o]=y.useState([]),[i,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){o([]),l(!1);return}const c=new AbortController,u=window.setTimeout(async()=>{l(!0);try{const d=await Ce(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!d.ok)throw new Error(`Request failed (${d.status})`);const f=await d.json();c.signal.aborted||o(fee(f))}catch{c.signal.aborted||o([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(u),c.abort()}},[s,n,t,e]),{files:r,loading:i}}const g1="cogpit-share-revoked";function pee(){window.dispatchEvent(new Event(g1))}async function KE(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&&pee(),s}function Bc(n,e){return KE(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function hee(){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 gee(n,e){return Bc("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function xee(){return Bc("/api/share/interrupt")}function bee(){return Bc("/api/share/stop")}async function vee(n,e){return(await Bc("/api/share/permission",{requestId:n,behavior:e})).ok}async function yee(n,e){try{const t=await Bc("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function wee(){try{const n=await KE("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const See=/^\/shared\/([^/]+)\/?$/;function GE(n){const e=See.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function lm(n){return GE(n)!==null}function kee(n){return`/shared/${encodeURIComponent(n)}`}function jee(n,e){return`${e?new URL(`${e.tls?"https":"http"}://${e.host.includes(":")?`[${e.host}]`:e.host}:${e.port}`).origin:window.location.origin}${kee(n)}`}async function ZE(n,e,t){const s=typeof e.commandId=="string"?e.commandId:crypto.randomUUID(),r={...e,commandId:s};for(let o=0;;o++)try{const i=await(t?Ce(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:t}):is(n,r));return i.ok&&window.dispatchEvent(new CustomEvent("cogpit-command-accepted",{detail:{commandId:s,sessionId:e.sessionId}})),i}catch(i){if(i instanceof Error&&i.name==="AbortError")throw i;if(t!=null&&t.aborted||o>=1)throw new Error(`Delivery could not be confirmed. Your draft is retained. Check receipt ${s} before sending again.`,{cause:i})}}function Nee(n){return[...n].join(", ")}async function YE(n,e){try{const t=await is(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function eb(n,e,t){return lm(window.location.pathname)?yee(e,t):ZE("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t}).then(s=>({ok:s.ok,gone:s.status===404}),()=>({ok:!1,gone:!1}))}async function Cee(n,e,t){try{return(await is(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function Wc(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background 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:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("textarea",{"data-slot":"textarea",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ou(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 r;if(e){const i=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,r=n.scrollHeight>48,n.style.width=i}else r=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",r}function _ee(n,e,t,s,r,o){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":o?r?"Steer…":"Message…":r?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function Eee(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 Tee(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?G("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):G("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function Aee(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 x1=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var He;const c=Nn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:w,turnError:v,promptSuggestion:j}=jt(),{chat:{status:k,error:_,isConnected:N,sendMessage:S,interrupt:C}}=Wf(),E=N||d,[T,$]=y.useState(""),[A,R]=y.useState(!1),[P,z]=y.useState(!1),[L,I]=y.useState(null),M=y.useRef(null),F=y.useRef(null),U=y.useRef(!1),O=y.useRef(""),D=y.useRef(null);y.useEffect(()=>{O.current=T},[T]);const B=y.useCallback(me=>{U.current=me,R(me)},[]),{images:q,isDragOver:W,imageError:H,hasUnsupportedAttachments:K,dismissImageError:Z,removeImage:Y,clearImages:J,restoreImages:ee,handleDragOver:te,handleDragLeave:se,handleDrop:X,handlePaste:ne}=Vz(e),ae=y.useRef(q);y.useEffect(()=>{ae.current=q},[q]);const ie=(u==null?void 0:u.sessionId)??null,re=y.useRef(null),de=y.useRef(null);y.useEffect(()=>{const me=()=>O.current.trim()!==""||ae.current.length>0;re.current={sessionId:ie};const je=ie&&!me()?Zz(ie):void 0;return je&&(de.current=ie,O.current=je.text,ae.current=je.images,$(je.text),ee(je.images)),()=>{re.current=null,ie&&de.current===ie&&me()&&(p2(ie,{text:O.current,images:ae.current}),O.current="",ae.current=[],$(""),J()),de.current=null}},[ie,ee,J]);const[ce,oe]=y.useState(0),[fe,ue]=y.useState(0),[le,pe]=y.useState(!1),ge=T.startsWith("/")&&!T.includes(" "),be=ge?T.slice(1):"",ve=y.useMemo(()=>{if(!ge)return[];const me=be.toLowerCase(),je=b.filter(dt=>me?dt.name.toLowerCase().includes(me)||dt.description.toLowerCase().includes(me):!0),Xe=je.filter(dt=>dt.type==="command"),tt=je.filter(dt=>dt.type==="skill");return[...Xe,...tt]},[ge,be,b]),Se=y.useMemo(()=>uee(T),[T]),we=!!(c&&Se&&s&&!le),Ee=mee(s,(Se==null?void 0:Se.query)??"",we);y.useEffect(()=>{oe(0)},[be]),y.useEffect(()=>{ue(0)},[Se==null?void 0:Se.query]);const $e=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{F.current=$e,M.current=null,z(!1),I(null)},[$e]);const Be=y.useCallback(async me=>{const je=m;if(!(u!=null&&u.sessionId)||(je==null?void 0:je.type)!=="question")return;const Xe=je.questions[0];if(!Xe||!me.trim())return;(await eb(u.sessionId,je.toolUseId,{[Xe.question]:me})).ok||S(me)},[m,u==null?void 0:u.sessionId,S]),qe=y.useCallback(async(me,je,Xe)=>{const tt=m;if((tt==null?void 0:tt.type)==="plan"&&tt.provider==="copilot"&&tt.requestId&&(u!=null&&u.sessionId)){const dt=tt.requestId;if(M.current)return!1;M.current=dt,z(!0),I(null);try{const zt=await Cee(u.sessionId,dt,{approved:me,...je?{selectedAction:je}:{},...Xe?{feedback:Xe}:{}});return!zt&&F.current===dt&&I("Couldn't send the plan response. Try again."),zt}finally{M.current===dt&&(M.current=null,z(!1))}}return S(me?"yes":Xe||"no"),!0},[m,u==null?void 0:u.sessionId,S]),ze=y.useCallback(()=>{requestAnimationFrame(()=>{const me=D.current;me&&(me.focus(),me.selectionStart=me.selectionEnd=me.value.length,B(Ou(me,U.current)))})},[B]),Ie=y.useCallback(me=>{$(`/${me.name} `),oe(0),ze()},[ze]),Me=y.useCallback(me=>{$(me),ze()},[ze]),Ue=y.useCallback(me=>{if(!Se)return;const je=dee(T,Se,me);$(je),pe(!0),ue(0),requestAnimationFrame(()=>{const Xe=D.current;Xe&&(Xe.focus(),Xe.selectionStart=Xe.selectionEnd=Xe.value.length,B(Ou(Xe,U.current)))})},[Se,T,B]),De=y.useCallback(async()=>{const me=T.trim();if(!me&&q.length===0||!e&&q.length>0)return;if((m==null?void 0:m.type)==="question"){Be(me),$(""),B(!1),D.current&&(D.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!me||!await qe(!1,void 0,me))return;$(""),B(!1),D.current&&(D.current.style.height="auto");return}const je=e&&q.length>0?q.map(tt=>({data:tt.data,mediaType:tt.mediaType})):void 0,Xe={text:T,images:q};de.current=null,S(me,je).then(tt=>{var dt;if(!tt){if(((dt=re.current)==null?void 0:dt.sessionId)!==ie){ie&&p2(ie,Xe);return}de.current=ie,$(zt=>zt||Xe.text),ee(Xe.images)}}),$(""),J(),B(!1),D.current&&(D.current.style.height="auto")},[T,q,e,S,J,ee,B,m,Be,qe,ie]),Ke=y.useCallback(me=>{if(we&&me.key==="Escape"){me.preventDefault(),pe(!0);return}if(we&&Ee.files.length>0){if(me.key==="ArrowDown"){me.preventDefault(),ue(je=>je<Ee.files.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),ue(je=>je>0?je-1:Ee.files.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=Ee.files[fe];je&&Ue(je);return}}if(ge&&ve.length>0){if(me.key==="ArrowDown"){me.preventDefault(),oe(je=>je<ve.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),oe(je=>je>0?je-1:ve.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=ve[ce];je&&Ie(je);return}if(me.key==="Escape"){me.preventDefault(),$("");return}}if(me.key==="Escape"&&E&&C){me.preventDefault(),C();return}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),De())},[De,E,C,we,Ee.files,fe,Ue,ge,ve,ce,Ie]),Ne=y.useCallback(me=>{$(me.target.value),pe(!1),B(Ou(me.target,U.current))},[B]);y.useImperativeHandle(l,()=>({focus:()=>{var me;return(me=D.current)==null?void 0:me.focus()},getText:()=>O.current,setText:me=>{$(me),pe(!1),requestAnimationFrame(()=>B(Ou(D.current,U.current)))}}),[B]);const Ae=(m==null?void 0:m.type)==="plan",Qe=(m==null?void 0:m.type)==="question",Je=p.length>0,ke=!!o,We=(T.trim().length>0||q.length>0)&&!K,ye=bn(t??Wo).midTurnSteering&&E,Re=we?"file-suggestions":ge?"slash-suggestions":void 0,Ve=we&&Ee.files[fe]?`file-suggestion-${fe}`:ge&&ve[ce]?`slash-suggestion-${ce}`:void 0;return a.jsxs("div",{className:G("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",W&&"ring-2 ring-info/40 ring-inset"),onDragOver:te,onDragLeave:se,onDrop:X,children:[W&&a.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:a.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),ge&&a.jsx(Iz,{suggestions:ve,filter:be,loading:w,selectedIndex:ce,onSelect:Ie,onHover:oe,onEdit:f}),we&&a.jsx(Oz,{files:Ee.files,query:(Se==null?void 0:Se.query)??"",loading:Ee.loading,selectedIndex:fe,onSelect:Ue,onHover:ue}),a.jsxs("div",{children:[Ae&&a.jsx($5,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:P,responseError:L,onApprove:me=>{qe(!0,me)},onReject:()=>{qe(!1)}}),a.jsx(cee,{suggestion:j,onAccept:Me}),q.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:q.map((me,je)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:me.preview,alt:`Upload ${je+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(je),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-popover 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 ${je+1}`,children:a.jsx(Mt,{className:"size-3","data-icon":"icon"})})]},me.id))}),H&&a.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[a.jsx("span",{className:"flex-1",children:H}),!K&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(Mt,{"data-icon":"icon"})})]}),a.jsxs("div",{className:G("relative overflow-hidden border bg-popover shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150",ke?"rounded-3xl":"rounded-xl",Eee(Ae,Qe,Je),"focus-within:ring-3"),children:[Je&&a.jsx(R5,{requests:p,responding:h,onRespond:g,onRespondAll:x},(He=p[0])==null?void 0:He.requestId),a.jsxs("div",{className:G("min-w-0",ke?"flex flex-col":"grid items-end",!ke&&(A?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:G("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:r}),a.jsx(Wc,{ref:D,value:T,onChange:Ne,onKeyDown:Ke,onPaste:ne,onFocus:()=>{setTimeout(()=>{var me;return(me=D.current)==null?void 0:me.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:_ee(Ae,Qe,N,Je,ye,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Re,"aria-controls":Re,"aria-activedescendant":Ve,rows:1,className:G("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",Tee(ke,A,i))}),a.jsxs("div",{className:G("flex shrink-0 items-center justify-end",Aee(ke,A)),children:[o,a.jsx(aee,{}),a.jsx(Xz,{hasContent:We,onSubmit:De,submitLabel:ye?"Steer active turn":"Send message"})]})]})]}),k==="error"&&_&&a.jsx(hk,{error:_},_),v&&a.jsx(hk,{error:v},v)]})]})}));function Iee(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=L9(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const r=typeof s.condition=="string"?s.condition:"",o=s.met===!0,i=s.failed===!0;return s.sentinel===!0&&o||!r?null:{condition:r,status:i?"failed":o?"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 Lu(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function qc(n){const e=V.c(13);let t,s,r,o;e[0]!==n?({className:s,children:t,value:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e[5]!==s?(i=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Pee,{children:a.jsx($ee,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(C$,{value:o,"data-slot":"progress",className:i,...r,children:[t,l]}),e[8]=t,e[9]=r,e[10]=i,e[11]=o,e[12]=c):c=e[12],c}function Pee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(_$,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function $ee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(E$,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function XE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(T$,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function JE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(A$,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const Ree={section:null,canCreate:!1,beginEditing:()=>{}},tb=y.createContext(Ree);function QE(){return y.useContext(tb)}const eT="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",tT="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function Oee(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function Lee(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function Mee({agentKind:n,threadId:e,children:t}){const s=Bf(n),[r,o]=y.useState(null),[i,l]=y.useState(!0),[c,u]=y.useState(!1),[d,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async E=>{try{const T=await Ce(Lu(e),{signal:E});if(T.status===404||T.status===501){l(!1);return}if(!T.ok)return;const $=await T.json();o($.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const E=new AbortController;w(E.signal);const T=i?setInterval(()=>void w(),1e4):void 0;return()=>{E.abort(),T!==void 0&&clearInterval(T)}},[w,i]);const v=y.useCallback(()=>{var E;f((r==null?void 0:r.objective)??""),p(((E=r==null?void 0:r.tokenBudget)==null?void 0:E.toString())??""),b(null),u(!0)},[r]),j=async()=>{const E=d.trim();if(!E)return;const T=m.trim()?Number(m):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const $=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:E,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:T})}),A=await $.json();if(!$.ok)throw new Error(A.error||"Could not save goal");o(A.goal),u(!1)}catch($){b($ instanceof Error?$.message:"Could not save goal")}finally{g(!1)}},k=async E=>{if(r){g(!0);try{const T=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:E})});T.ok&&o((await T.json()).goal)}finally{g(!1)}}},_=async()=>{g(!0);try{(await Ce(Lu(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},N=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:tT,onSubmit:E=>{E.preventDefault(),j()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(Aa,{className:"gap-2",children:[a.jsxs(fn,{children:[a.jsx(mn,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(Wc,{id:"goal-objective",value:d,onChange:E=>f(E.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(fn,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(mn,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(On,{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})]})]}),a.jsx(Eo,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(Q,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(nn,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const E=r.status==="paused",T=r.status==="complete";S=a.jsxs("section",{className:eT,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hl,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:r.objective,children:r.objective}),a.jsx(Fe,{variant:Lee(r.status),children:Oee(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[vt(r.tokensUsed),r.tokenBudget?` / ${vt(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[E&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(Ca,{"data-icon":"icon"})}),!E&&!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(I$,{"data-icon":"icon"})}),!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(nn,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:a.jsx(wr,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void _(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(kf,{"data-icon":"icon"})})]})]}),N!==null&&a.jsx(qc,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const C=y.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:v}),[S,i,r,c,v]);return a.jsx(tb.Provider,{value:C,children:t})}function zee(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function Dee(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function Fee(n){const e=V.c(89),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=Bf(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=Iee(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const u=c,[d,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=u?`${u.status}\0${u.condition}`:"",[v,j]=y.useState(w);v!==w&&(j(w),f(void 0));const k=d!==void 0?d:u;let _;e[4]!==(k==null?void 0:k.condition)?(_=()=>{g((k==null?void 0:k.condition)??""),b(null),p(!0)},e[4]=k==null?void 0:k.condition,e[5]=_):_=e[5];const N=_;let S;e[6]!==r||e[7]!==d?(S=async(M,F)=>{const U=d;f(F),p(!1);const O=await r(M);return O||f(U),O},e[6]=r,e[7]=d,e[8]=S):S=e[8];const C=S;let E;e[9]!==h||e[10]!==C?(E=async()=>{const M=h.trim();if(!M)return;if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}await C(`/goal ${M}`,{condition:M,status:"active",iterations:0,durationMs:0,tokens:0})||(g(M),p(!0))},e[9]=h,e[10]=C,e[11]=E):E=e[11];const T=E;let $;e[12]!==C?($=()=>void C("/goal clear",null),e[12]=C,e[13]=$):$=e[13];const A=$;let R;if(e[14]!==l||e[15]!==N||e[16]!==A||e[17]!==h||e[18]!==m||e[19]!==x||e[20]!==k||e[21]!==T){if(R=null,m){let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),e[23]=M):M=e[23];const F=k?"Replace goal":"Set a long-running goal";let U;e[24]!==F?(U=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,F]}),e[24]=F,e[25]=U):U=e[25];const O=!!x;let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(mn,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[26]=D):D=e[26];let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=ne=>g(ne.target.value),e[27]=B):B=e[27];const q=`A measurable condition ${l} should keep working toward…`,W=!!x;let H;e[28]!==h||e[29]!==q||e[30]!==W?(H=a.jsx(Wc,{id:"goal-condition",value:h,onChange:B,placeholder:q,rows:2,maxLength:4e3,"aria-invalid":W,autoFocus:!0}),e[28]=h,e[29]=q,e[30]=W,e[31]=H):H=e[31];let K;e[32]!==x?(K=a.jsx(Eo,{children:x}),e[32]=x,e[33]=K):K=e[33];let Z;e[34]!==O||e[35]!==H||e[36]!==K?(Z=a.jsxs(fn,{"data-invalid":O,children:[D,H,K]}),e[34]=O,e[35]=H,e[36]=K,e[37]=Z):Z=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),e[38]=Y):Y=e[38];let J;e[39]!==T?(J=()=>void T(),e[39]=T,e[40]=J):J=e[40];let ee;e[41]!==h?(ee=h.trim(),e[41]=h,e[42]=ee):ee=e[42];const te=!ee;let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsx(nn,{"data-icon":"inline-start"}),e[43]=se):se=e[43];let X;e[44]!==J||e[45]!==te?(X=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,a.jsxs(Q,{type:"button",size:"xs",onClick:J,disabled:te,children:[se,"Start goal"]})]}),e[44]=J,e[45]=te,e[46]=X):X=e[46],R=a.jsxs("section",{className:tT,"aria-label":`${l} goal editor`,children:[U,Z,X]})}else if(k){let M;e[47]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[47]=M):M=e[47];let F;e[48]!==k.condition?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:k.condition,children:k.condition}),e[48]=k.condition,e[49]=F):F=e[49];let U;e[50]!==k.status?(U=Dee(k.status),e[50]=k.status,e[51]=U):U=e[51];let O;e[52]!==k.status?(O=zee(k.status),e[52]=k.status,e[53]=O):O=e[53];let D;e[54]!==O||e[55]!==U?(D=a.jsx(Fe,{variant:U,children:O}),e[54]=O,e[55]=U,e[56]=D):D=e[56];const B=k.iterations,q=k.iterations===1?"":"s";let W;e[57]!==k.tokens?(W=vt(k.tokens),e[57]=k.tokens,e[58]=W):W=e[58];let H;e[59]!==k.durationMs?(H=Math.round(k.durationMs/6e4),e[59]=k.durationMs,e[60]=H):H=e[60];const K=Math.max(0,H);let Z;e[61]!==k.iterations||e[62]!==q||e[63]!==W||e[64]!==K?(Z=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[B," turn",q," · ",W," · ",K,"m"]}),e[61]=k.iterations,e[62]=q,e[63]=W,e[64]=K,e[65]=Z):Z=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(wr,{"data-icon":"icon"}),e[66]=Y):Y=e[66];let J;e[67]!==N?(J=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:N,"aria-label":"Replace goal",children:Y}),e[67]=N,e[68]=J):J=e[68];let ee;e[69]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(kf,{"data-icon":"icon"}),e[69]=ee):ee=e[69];let te;e[70]!==A?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:ee}),e[70]=A,e[71]=te):te=e[71];let se;e[72]!==J||e[73]!==te?(se=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[J,te]}),e[72]=J,e[73]=te,e[74]=se):se=e[74];let X;e[75]!==D||e[76]!==Z||e[77]!==se||e[78]!==F?(X=a.jsxs("div",{className:"flex items-center gap-2",children:[M,F,D,Z,se]}),e[75]=D,e[76]=Z,e[77]=se,e[78]=F,e[79]=X):X=e[79];let ne;e[80]!==k.reason?(ne=k.reason&&a.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:k.reason}),e[80]=k.reason,e[81]=ne):ne=e[81],R=a.jsxs("section",{className:eT,"aria-label":`${l} goal`,children:[X,ne]})}e[14]=l,e[15]=N,e[16]=A,e[17]=h,e[18]=m,e[19]=x,e[20]=k,e[21]=T,e[22]=R}else R=e[22];const P=!k&&!m;let z;e[82]!==N||e[83]!==R||e[84]!==P?(z={section:R,canCreate:P,beginEditing:N},e[82]=N,e[83]=R,e[84]=P,e[85]=z):z=e[85];const L=z;let I;return e[86]!==o||e[87]!==L?(I=a.jsx(tb.Provider,{value:L,children:o}),e[86]=o,e[87]=L,e[88]=I):I=e[88],I}function Uee(n){const e=V.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=bn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx(Mee,{agentKind:t,threadId:s.sessionId,children:o}),e[0]=t,e[1]=o,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(i==="transcript"){let l;return e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==s?(l=a.jsx(Fee,{agentKind:t,session:s,onSendCommand:r,children:o}),e[4]=t,e[5]=o,e[6]=r,e[7]=s,e[8]=l):l=e[8],l}return o}function Bee(){return QE().section}function gk(){const n=V.c(3),{canCreate:e,beginEditing:t}=QE();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Hl,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(Q,{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]=r):r=n[2],r}const Wee=["allow","allow_always","deny"],qee=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function Vee(n,e){return(n.availableDecisions??Wee).includes(e)}function Hee(n){const e=V.c(22),{request:t,queued:s,responding:r,onRespond:o}=n;let i;if(e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r){let l;e[5]!==t?(l=w=>Vee(t,w.decision),e[5]=t,e[6]=l):l=e[6];const c=qee.filter(l);t.defaultToNo&&c.sort(Gee);const u=c.some(Kee);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(lx,{className:"text-warning"}),e[7]=d):d=e[7];const f=t.title||`Allow ${t.toolName}?`;let m;e[8]!==f?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==s?(p=s>0&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",s]}),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=a.jsxs(Xt,{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==t.toolName?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=g):g=e[16];let x;e[17]!==t.summary?(x=t.summary&&a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=x):x=e[18];let b;e[19]!==g||e[20]!==x?(b=a.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[g,x]}),e[19]=g,e[20]=x,e[21]=b):b=e[21],i=a.jsxs(kt,{className:"border-warning/40 bg-warning/5",children:[d,h,b,o&&(u?a.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:c.map(w=>{const{decision:v,label:j,variant:k}=w;return a.jsx(Q,{autoFocus:t.defaultToNo&&v==="deny",size:"xs",variant:k,disabled:r,onClick:()=>o(t.requestId,v),children:j},`${t.requestId}:${v}`)})}):a.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"}))]}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i}else i=e[4];return i}function Kee(n){return n.decision!=="allow_always"}function Gee(n,e){return+(e.decision==="deny")-+(n.decision==="deny")}const nT=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function sT(n){const e=V.c(29);let t,s,r,o,i,l,c;e[0]!==n?({className:s,variant:c,size:o,spacing:i,orientation:l,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=i===void 0?2:i,d=l===void 0?"horizontal":l;let f;e[8]!==u?(f={"--gap":u},e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==d||e[13]!==o||e[14]!==u||e[15]!==c?(h={variant:c,size:o,spacing:u,orientation:d},e[12]=d,e[13]=o,e[14]=u,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=a.jsx(nT.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==d||e[21]!==r||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=a.jsx(P$,{"data-slot":"toggle-group","data-variant":c,"data-size":o,"data-spacing":u,"data-orientation":d,orientation:d,style:m,className:p,...r,children:g}),e[20]=d,e[21]=r,e[22]=o,e[23]=u,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function b1(n){const e=V.c(19);let t,s,r,o,i;e[0]!==n?({className:s,children:t,variant:o,size:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"default":o,c=i===void 0?"default":i,u=y.useContext(nT),d=u.variant||l,f=u.size||c,m=u.spacing;let p;e[6]!==s||e[7]!==u.size||e[8]!==u.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",g5({variant:u.variant||l,size:u.size||c}),s),e[6]=s,e[7]=u.size,e[8]=u.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==u.spacing||e[14]!==r||e[15]!==d||e[16]!==f||e[17]!==p?(h=a.jsx(x4,{"data-slot":"toggle-group-item","data-variant":d,"data-size":f,"data-spacing":m,className:p,...r,children:t}),e[12]=t,e[13]=u.spacing,e[14]=r,e[15]=d,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function Zee(n){return n.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function Yee(n){const e=V.c(64),{request:t,responding:s,gone:r,onAnswer:o,onOpenSession:i}=n,l=t.questions,[c,u]=y.useState(0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const f=y.useRef(d);let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[1]=m):m=e[1];const[p,h]=y.useState(m);if(l.length===0)return null;if(Zee(l)){let M;e[2]!==l[0].question?(M=a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:l[0].question}),e[2]=l[0].question,e[3]=M):M=e[3];let F;e[4]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(it,{"data-icon":"inline-end"}),e[4]=F):F=e[4];let U;e[5]!==i?(U=a.jsxs(Q,{variant:"outline",size:"sm",onClick:i,className:"mt-3",children:["Open full question",F]}),e[5]=i,e[6]=U):U=e[6];let O;return e[7]!==M||e[8]!==U?(O=a.jsxs(xk,{children:[M,U]}),e[7]=M,e[8]=U,e[9]=O):O=e[9],O}const g=l[c],x=s||!o;let b;e[10]!==g.question||e[11]!==c||e[12]!==o||e[13]!==l.length||e[14]!==t.toolUseId?(b=function(F){const U={...f.current,[g.question]:F};if(c+1<l.length){f.current=U,h(new Set),u(c+1);return}o==null||o(t.toolUseId,U)},e[10]=g.question,e[11]=c,e[12]=o,e[13]=l.length,e[14]=t.toolUseId,e[15]=b):b=e[15];const w=b;let v;e[16]!==g.header?(v=g.header&&a.jsx(Fe,{variant:"outline",className:"border-info/40 text-info",children:g.header}),e[16]=g.header,e[17]=v):v=e[17];let j;e[18]!==c||e[19]!==l.length?(j=l.length>1&&a.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[c+1," of ",l.length]}),e[18]=c,e[19]=l.length,e[20]=j):j=e[20];let k;e[21]!==v||e[22]!==j?(k=a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[v,j]}),e[21]=v,e[22]=j,e[23]=k):k=e[23];let _;e[24]!==g.question?(_=a.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:g.question,children:g.question}),e[24]=g.question,e[25]=_):_=e[25];let N;e[26]!==p?(N=[...p],e[26]=p,e[27]=N):N=e[27];let S;e[28]!==w||e[29]!==g.multiSelect?(S=M=>{g.multiSelect?h(new Set(M)):M[0]&&w(M[0])},e[28]=w,e[29]=g.multiSelect,e[30]=S):S=e[30];const C=g.multiSelect,E=g.question;let T;if(e[31]!==g.options||e[32]!==x){let M;e[34]!==x?(M=F=>a.jsx(Xee,{option:F,disabled:x},F.label),e[34]=x,e[35]=M):M=e[35],T=g.options.map(M),e[31]=g.options,e[32]=x,e[33]=T}else T=e[33];let $;e[36]!==g.multiSelect||e[37]!==g.question||e[38]!==T||e[39]!==N||e[40]!==S?($=a.jsx(sT,{value:N,onValueChange:S,multiple:C,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":E,children:T}),e[36]=g.multiSelect,e[37]=g.question,e[38]=T,e[39]=N,e[40]=S,e[41]=$):$=e[41];let A;e[42]!==w||e[43]!==g.multiSelect||e[44]!==c||e[45]!==o||e[46]!==l.length||e[47]!==s||e[48]!==p?(A=g.multiSelect&&o&&a.jsx(Q,{size:"sm",disabled:s||p.size===0,onClick:()=>w(Nee(p)),children:c+1<l.length?"Next":"Send"}),e[42]=w,e[43]=g.multiSelect,e[44]=c,e[45]=o,e[46]=l.length,e[47]=s,e[48]=p,e[49]=A):A=e[49];let R;e[50]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx(it,{"data-icon":"inline-end"}),e[50]=R):R=e[50];let P;e[51]!==i?(P=a.jsxs(Q,{variant:"ghost",size:"sm",onClick:i,className:"ml-auto text-muted-foreground",children:["Open session",R]}),e[51]=i,e[52]=P):P=e[52];let z;e[53]!==A||e[54]!==P?(z=a.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[A,P]}),e[53]=A,e[54]=P,e[55]=z):z=e[55];let L;e[56]!==r?(L=r&&a.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[56]=r,e[57]=L):L=e[57];let I;return e[58]!==$||e[59]!==z||e[60]!==L||e[61]!==k||e[62]!==_?(I=a.jsxs(xk,{children:[k,_,$,z,L]}),e[58]=$,e[59]=z,e[60]=L,e[61]=k,e[62]=_,e[63]=I):I=e[63],I}function Xee(n){const e=V.c(17),{option:t,disabled:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];const o=r;if(!t.description){let d;return e[2]!==s||e[3]!==o||e[4]!==t.label?(d=a.jsx(b1,{value:t.label,disabled:s,className:"w-full justify-start px-3",children:o}),e[2]=s,e[3]=o,e[4]=t.label,e[5]=d):d=e[5],d}let i;e[6]!==s||e[7]!==t.label?(i=a.jsx(b1,{value:t.label,disabled:s,className:"w-full justify-start px-3"}),e[6]=s,e[7]=t.label,e[8]=i):i=e[8];let l;e[9]!==o||e[10]!==i?(l=a.jsx(Zt,{render:i,children:o}),e[9]=o,e[10]=i,e[11]=l):l=e[11];let c;e[12]!==t.description?(c=a.jsx(Yt,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=c):c=e[13];let u;return e[14]!==l||e[15]!==c?(u=a.jsxs(Gt,{children:[l,c]}),e[14]=l,e[15]=c,e[16]=u):u=e[16],u}function xk(n){const e=V.c(4),{children:t}=n;let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx($$,{className:"text-info"}),r=a.jsx(Xt,{children:"Answer to continue"}),e[0]=s,e[1]=r):(s=e[0],r=e[1]);let o;return e[2]!==t?(o=a.jsxs(kt,{className:"border-info/40 bg-info/5",children:[s,r,a.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=o):o=e[3],o}function Jee(n){const e=V.c(45),{sessionId:t,pending:s,queued:r,responding:o,onRespond:i,onOpen:l}=n;switch(s.kind){case"permission":{let c;e[0]!==s||e[1]!==t?(c={...s,sessionId:t,timestamp:0},e[0]=s,e[1]=t,e[2]=c):c=e[2];let u;e[3]!==i?(u=(f,m)=>i(f,{decision:m}),e[3]=i,e[4]=u):u=e[4];let d;return e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==u?(d=a.jsx(Hee,{request:c,queued:r,responding:o,onRespond:u}),e[5]=r,e[6]=o,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}case"question":{const c=s.requestId;let u;e[10]!==s.questions?(u=s.questions.map(Qee),e[10]=s.questions,e[11]=u):u=e[11];let d;e[12]!==s.requestId||e[13]!==t||e[14]!==u?(d={sessionId:t,toolUseId:c,askedAt:0,questions:u},e[12]=s.requestId,e[13]=t,e[14]=u,e[15]=d):d=e[15];let f;e[16]!==i?(f=(p,h)=>i(p,{answers:h}),e[16]=i,e[17]=f):f=e[17];let m;return e[18]!==l||e[19]!==o||e[20]!==d||e[21]!==f?(m=a.jsx(Yee,{request:d,responding:o,gone:!1,onAnswer:f,onOpenSession:l}),e[18]=l,e[19]=o,e[20]=d,e[21]=f,e[22]=m):m=e[22],m}case"plan":{let c,u;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(R$,{className:"text-info"}),u=a.jsx(Xt,{children:"Approve the plan?"}),e[23]=c,e[24]=u):(c=e[23],u=e[24]);let d;e[25]!==s.summary?(d=s.summary&&a.jsx("p",{className:"col-start-2 mt-1 line-clamp-3 text-sm text-foreground",children:s.summary}),e[25]=s.summary,e[26]=d):d=e[26];let f;e[27]!==i||e[28]!==s.requestId?(f=()=>i(s.requestId,{approved:!0}),e[27]=i,e[28]=s.requestId,e[29]=f):f=e[29];let m;e[30]!==o||e[31]!==f?(m=a.jsx(Q,{size:"xs",disabled:o,onClick:f,children:"Approve"}),e[30]=o,e[31]=f,e[32]=m):m=e[32];let p;e[33]!==i||e[34]!==s.requestId?(p=()=>i(s.requestId,{approved:!1}),e[33]=i,e[34]=s.requestId,e[35]=p):p=e[35];let h;e[36]!==o||e[37]!==p?(h=a.jsx(Q,{size:"xs",variant:"destructive",disabled:o,onClick:p,children:"Reject"}),e[36]=o,e[37]=p,e[38]=h):h=e[38];let g;e[39]!==m||e[40]!==h?(g=a.jsxs("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:[m,h]}),e[39]=m,e[40]=h,e[41]=g):g=e[41];let x;return e[42]!==d||e[43]!==g?(x=a.jsxs(kt,{className:"border-info/40 bg-info/5",children:[c,u,d,g]}),e[42]=d,e[43]=g,e[44]=x):x=e[44],x}}}function Qee(n){return{question:n.question,multiSelect:n.multiSelect,options:n.options.map(ete)}}function ete(n){return{label:n,hasPreview:!1}}const tte=3e3;function nte(n){const[e,t]=y.useState([]),[s,r]=y.useState(new Set),o=y.useCallback(async l=>{if(n)try{const c=await Ce(`/api/session-requests?parent=${encodeURIComponent(n)}`);if(!l()||!c.ok)return;const u=await c.json();if(!l())return;t(d=>JSON.stringify(d)===JSON.stringify(u.requests)?d:u.requests)}catch{}},[n]);Oa(n?o:null,tte),y.useEffect(()=>{t([])},[n]);const i=y.useCallback(async(l,c,u)=>{r(d=>new Set(d).add(c));try{const d=await is("/api/session-respond",{sessionId:l,requestId:c,...u});(d.ok||d.status===404)&&t(f=>f.map(m=>m.sessionId===l?{...m,waiting:m.waiting.filter(p=>p.requestId!==c)}:m).filter(m=>m.waiting.length>0))}finally{r(d=>{const f=new Set(d);return f.delete(c),f})}},[]);return{requests:e,responding:s,respond:i}}function za(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function ha(n,e,t){return`${t===void 0?_x():`/d/${encodeURIComponent(t)}`}/${encodeURIComponent(n)}/${encodeURIComponent(Q4(n,e))}`}async function cm(n){let e;try{e=await Ce(`/api/find-session/${encodeURIComponent(n)}`)}catch{return!1}const t=e.ok?await zs(e):null;return typeof(t==null?void 0:t.dirName)!="string"||typeof t.fileName!="string"?!1:(za(ha(t.dirName,t.fileName)),!0)}function ste(n){var o;if(!n.address)return null;const{dirName:e,fileName:t}=n.address,s=((o=n.device)==null?void 0:o.id)??Kt();return`${s===Ot?"":`/d/${encodeURIComponent(s)}`}/${encodeURIComponent(e)}/${encodeURIComponent(Q4(e,t))}`}function rte(n){const e=V.c(9),{sessionId:t}=n,{requests:s,responding:r,respond:o}=nte(t);if(s.length===0)return null;let i;if(e[0]!==s||e[1]!==o||e[2]!==r){let c;e[4]!==o||e[5]!==r?(c=u=>a.jsx(ote,{request:u,responding:r,onRespond:(d,f)=>void o(u.sessionId,d,f)},u.sessionId),e[4]=o,e[5]=r,e[6]=c):c=e[6],i=s.map(c),e[0]=s,e[1]=o,e[2]=r,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=a.jsx("div",{className:"flex flex-col gap-2 px-3 pb-2",children:i}),e[7]=i,e[8]=l):l=e[8],l}function ote(n){const e=V.c(26),{request:t,responding:s,onRespond:r}=n;let o;e[0]!==t?(o=ste(t),e[0]=t,e[1]=o):o=e[1];const i=o;let l;e[2]!==i?(l=()=>{i&&za(i)},e[2]=i,e[3]=l):l=e[3];const c=l,[u]=t.waiting;if(!u)return null;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(cx,{className:"size-3.5"}),e[4]=d):d=e[4];const f=t.device?`Delegated session on ${t.device.name}`:"Delegated session";let m;e[5]!==f?(m=a.jsx("span",{className:"truncate",children:f}),e[5]=f,e[6]=m):m=e[6];let p;e[7]!==c||e[8]!==i?(p=i&&a.jsxs(Q,{variant:"ghost",size:"xs",className:"ml-auto",onClick:c,children:["Open",a.jsx(it,{"data-icon":"inline-end"})]}),e[7]=c,e[8]=i,e[9]=p):p=e[9];let h;e[10]!==m||e[11]!==p?(h=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[d,m,p]}),e[10]=m,e[11]=p,e[12]=h):h=e[12];const g=u.requestId,x=t.sessionId,b=t.waiting.length-1;let w;e[13]!==u.requestId||e[14]!==s?(w=s.has(u.requestId),e[13]=u.requestId,e[14]=s,e[15]=w):w=e[15];let v;e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==t.sessionId||e[20]!==b||e[21]!==w?(v=a.jsx(Jee,{sessionId:x,pending:u,queued:b,responding:w,onRespond:r,onOpen:c},g),e[16]=r,e[17]=c,e[18]=u,e[19]=t.sessionId,e[20]=b,e[21]=w,e[22]=v):v=e[22];let j;return e[23]!==v||e[24]!==h?(j=a.jsxs("div",{className:"flex flex-col gap-1",children:[h,v]}),e[23]=v,e[24]=h,e[25]=j):j=e[25],j}const v1="cogpit-session-config-changed";function ite(n){if(typeof n!="string")return null;let e;try{e=JSON.parse(n)}catch{e=n.trim()}if(typeof e=="string")return e||null;const t=e==null?void 0:e.sessionId;return typeof t=="string"?t:null}function ate(n){function e(t){const s=ite(t.data);s&&window.dispatchEvent(new CustomEvent(v1,{detail:{sessionId:s}}))}return n.addEventListener(_y,e),()=>n.removeEventListener(_y,e)}function lte(n,e){function t(s){var r;((r=s.detail)==null?void 0:r.sessionId)===n&&e()}return window.addEventListener(v1,t),()=>window.removeEventListener(v1,t)}const nf=new Map;class cte extends EventTarget{constructor(t,s){super();Ge(this,"CONNECTING",0);Ge(this,"OPEN",1);Ge(this,"CLOSED",2);Ge(this,"withCredentials",!1);Ge(this,"onopen",null);Ge(this,"onmessage",null);Ge(this,"onerror",null);this.owner=t,this.options=s;for(const r of["open","message","error"])super.addEventListener(r,o=>{const i=r==="open"?this.onopen:r==="message"?this.onmessage:this.onerror;i==null||i.call(this,o)})}get url(){return this.owner.url}get readyState(){var t;return((t=this.owner.source)==null?void 0:t.readyState)??(this.owner.health.transport==="denied"?2:0)}addEventListener(t,s,r){this.owner.listen(t),super.addEventListener(t,s,r)}close(){this.owner.remove(this)}emit(t){this.dispatchEvent(t instanceof MessageEvent?new MessageEvent(t.type,{data:t.data,origin:t.origin,lastEventId:t.lastEventId}):new Event(t.type))}}class ute{constructor(e,t){Ge(this,"source",null);Ge(this,"health",{transport:"connecting",freshness:"waiting",lastEventAt:null});Ge(this,"subscribers",new Set);Ge(this,"types",new Set(["open","error","message","access","session-config"]));Ge(this,"linked",new Set);Ge(this,"asking",null);Ge(this,"timer");Ge(this,"attempts",0);Ge(this,"generation",0);Ge(this,"retryingGeneration",null);Ge(this,"stopped",!1);Ge(this,"stopFrames",[]);Ge(this,"foreground",()=>{document.visibilityState==="hidden"||this.stopped||this.health.transport==="denied"||(!this.source||this.health.transport!=="open"||this.health.lastEventAt!==null&&Date.now()-this.health.lastEventAt>45e3)&&this.connect()});Ge(this,"identityChanged",()=>this.stop());this.key=e,this.url=t,window.addEventListener("online",this.foreground),document.addEventListener("visibilitychange",this.foreground),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),this.connect()}add(e){const t=new cte(this,e);return this.subscribers.add(t),queueMicrotask(()=>{var s,r;this.subscribers.has(t)&&((s=e.onState)==null||s.call(e,this.health),this.health.transport==="open"?t.emit(new Event("open")):this.health.transport==="denied"&&((r=e.onLost)==null||r.call(e)))}),t}remove(e){this.subscribers.delete(e),this.subscribers.size||this.stop()}listen(e){this.types.add(e),this.link(e)}link(e){const t=this.source,s=this.generation;!t||this.linked.has(e)||(this.linked.add(e),t.addEventListener(e,r=>{if(!(this.stopped||s!==this.generation)){if(e==="open")this.attempts=0,this.setHealth({...this.health,transport:"open"});else if(e==="error"){if(this.retryingGeneration===s)return;this.retryingGeneration=s,this.setHealth({...this.health,transport:"retrying",freshness:"stale"});const o=t.readyState===EventSource.CLOSED;t.close(),this.retry(s,o)}else this.setHealth({transport:"open",freshness:"current",lastEventAt:Date.now()});for(const o of this.subscribers)o.emit(r)}}))}setHealth(e){var t,s;this.health=e;for(const r of this.subscribers)(s=(t=r.options).onState)==null||s.call(t,e)}connect(){var e,t;if(!this.stopped){clearTimeout(this.timer),(e=this.asking)==null||e.abort();for(const s of this.stopFrames)s();(t=this.source)==null||t.close(),this.generation++,this.retryingGeneration=null,this.linked.clear(),this.setHealth({...this.health,transport:"connecting"}),this.source=new EventSource(this.url),this.stopFrames=[NR(this.source),ate(this.source)];for(const s of this.types)this.link(s)}}async retry(e,t){var o,i,l;const s=new AbortController;if(this.asking=s,t)try{const c=await Ce(this.url,{signal:s.signal});if((o=c.body)==null||o.cancel(),this.stopped||e!==this.generation||s.signal.aborted)return;if(c.status===401||c.status===403||cN(c)){this.setHealth({...this.health,transport:"denied",freshness:"stale"});for(const u of this.subscribers)(l=(i=u.options).onLost)==null||l.call(i);return}}catch{if(this.stopped||s.signal.aborted)return}if(this.stopped||e!==this.generation)return;const r=Math.min(3e4,500*2**Math.min(this.attempts++,6))*(.75+Math.random()*.5);this.timer=setTimeout(()=>this.connect(),r)}stop(){var e,t;this.stopped=!0,this.generation++,clearTimeout(this.timer),(e=this.asking)==null||e.abort(),(t=this.source)==null||t.close();for(const s of this.stopFrames)s();window.removeEventListener("online",this.foreground),document.removeEventListener("visibilitychange",this.foreground),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),this.setHealth({...this.health,transport:"closed",freshness:"stale"}),nf.get(this.key)===this&&nf.delete(this.key)}}function nb(n,e={}){const t=Af(n),s=JSON.stringify([cn(),Zn(),t]);let r=nf.get(s);r||(r=new ute(s,t),nf.set(s,r));const o=r.add(e);return{source:o,close:()=>o.close(),state:()=>r.health}}function Vc({className:n,children:e,...t}){return a.jsxs(O$,{"data-slot":"scroll-area",className:G("relative overflow-hidden",n),...t,children:[a.jsx(L$,{"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:e}),a.jsx(dte,{}),a.jsx(M$,{})]})}function dte({className:n,orientation:e="vertical",...t}){return a.jsx(z$,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",n),...t,children:a.jsx(D$,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function rT({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function fte({className:n,...e}){return a.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:G("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function mte({className:n,...e}){return a.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:G("size-5",n),...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function pte({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Pn({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(rT,{className:G(t),...e})}function hte(n){const e=Nn("hostFiles"),[t,s]=y.useState([]),[r,o]=y.useState(!1),i=y.useCallback(async()=>{if(!e||!n){s([]);return}o(!0);try{const l=await Ce(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{o(!1)}},[e,n]);return y.useEffect(()=>{i()},[i]),{scripts:t,loading:r,refresh:i}}const bk=500,gte=5e3;function xte(n){const e=V.c(29),t=n===void 0?!0:n,[s,r]=y.useState("disconnected");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=y.useState(o),c=y.useRef(null);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,e[1]=u):u=e[1];const d=y.useRef(u),f=y.useRef(bk),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(bte);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=F=>{var D;const U=F.type,O=F.id;if(U==="sessions"){l(F.sessions??[]);return}O&&((D=d.current.get(O))==null||D(U,F))},e[2]=g):g=e[2];const x=g;let b,w;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const F=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${tN()}/__pty`},U=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const D=new WebSocket(F());c.current=D,D.onopen=()=>{if(p.current){D.close();return}f.current=bk,r("connected"),D.send(JSON.stringify({type:"list"}))},D.onmessage=B=>{try{const q=JSON.parse(B.data);x(q)}catch{}},D.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const B=f.current;f.current=Math.min(B*2,gte),m.current=setTimeout(()=>h.current(),B)}};return h.current=U,U(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},w=[t,x],e[3]=t,e[4]=b,e[5]=w):(b=e[4],w=e[5]),y.useEffect(b,w);let v;e[6]!==t?(v=F=>{if(!t)return;const U=c.current;U&&U.readyState===WebSocket.OPEN&&U.send(JSON.stringify(F))},e[6]=t,e[7]=v):v=e[7];const j=v;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=(F,U)=>{d.current.set(F,U)},e[8]=k):k=e[8];const _=k;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=F=>{d.current.delete(F)},e[9]=N):N=e[9];const S=N;let C;e[10]!==j?(C=F=>{const U=F===void 0?{}:F,O=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:O,name:U.name??"Terminal",cwd:U.cwd,metadata:{type:"terminal"}}),O},e[10]=j,e[11]=C):C=e[11];const E=C;let T;e[12]!==j?(T=F=>{const U=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:U,name:F.name,cwd:F.cwd,args:["run",F.scriptName],command:"bun",metadata:{type:"script",source:F.source,scriptName:F.scriptName}}),U},e[12]=j,e[13]=T):T=e[13];const $=T;let A;e[14]!==j?(A=F=>{j({type:"kill",id:F})},e[14]=j,e[15]=A):A=e[15];const R=A;let P;e[16]!==j?(P=(F,U)=>{j({type:"input",id:F,data:U})},e[16]=j,e[17]=P):P=e[17];const z=P;let L;e[18]!==j?(L=(F,U,O)=>{j({type:"resize",id:F,cols:U,rows:O})},e[18]=j,e[19]=L):L=e[19];const I=L;let M;return e[20]!==R||e[21]!==I||e[22]!==j||e[23]!==i||e[24]!==$||e[25]!==E||e[26]!==s||e[27]!==z?(M={status:s,send:j,subscribe:_,unsubscribe:S,sessions:i,spawnTerminal:E,spawnScript:$,killSession:R,writeInput:z,resize:I},e[20]=R,e[21]=I,e[22]=j,e[23]=i,e[24]=$,e[25]=E,e[26]=s,e[27]=z,e[28]=M):M=e[28],M}function bte(){}const oT=y.createContext(null);function _h(n){const e=V.c(3),{children:t,enabled:s}=n,o=xte(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(oT.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function sb(){const n=y.useContext(oT);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function vte(n){var d;const e=V.c(11),t=sb();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((d=f.metadata)==null?void 0:d.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 r=s;let o;e[2]!==n||e[3]!==t?(o=(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]=o):o=e[4];const i=o;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let u;return e[7]!==i||e[8]!==r||e[9]!==c?(u={runningProcesses:r,runScript:i,stopScript:c},e[7]=i,e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function yte(n){const e=V.c(14),{script:t,status:s,onRun:r,onStop:o}=n,i=s==="running";let l="bg-transparent";i?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=i?o:r,u=i?`Stop ${t.name}`:`Run: ${t.command}`;let d;e[0]!==l?(d=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=d):d=e[1];let f;e[2]!==d?(f=a.jsx("span",{className:d}),e[2]=d,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=a.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]!==i?(p=i?a.jsx(ax,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(Ca,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=i,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==p?(h=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:u,children:[f,m,p]}),e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const wte=y.memo(function(e){const t=V.c(42),{projectDir:s,onProcessStarted:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const[d,f]=y.useState(u),{scripts:m,loading:p}=hte(s),{runningProcesses:h,runScript:g,stopScript:x}=vte(r);let b;if(t[1]!==m||t[2]!==l){const U=l.trim().toLowerCase(),O=U?m.filter(D=>D.name.toLowerCase().includes(U)||D.dirLabel.toLowerCase().includes(U)):m;b=new Map;for(const D of O){const B=b.get(D.dirLabel)??[];B.push(D),b.set(D.dirLabel,B)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let v;if(t[4]!==h){v=new Map;for(const[U,O]of h)v.set(`${O.name}:${O.cwd}`,{id:U,status:O.status});t[4]=h,t[5]=v}else v=t[5];const j=v;if(!s||!p&&m.length===0)return null;let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=function(O){f(D=>{const B=new Set(D);return B.has(O)?B.delete(O):B.add(O),B})},t[6]=k):k=t[6];const _=k;let N;t[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=N):N=t[7];let S;t[8]!==p?(S=p&&a.jsx(Pn,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const C=o?"Close script search":"Search scripts";let E,T;t[10]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{i(Ste),c("")},T=a.jsx(ss,{}),t[10]=E,t[11]=T):(E=t[10],T=t[11]);let $;t[12]!==o||t[13]!==C?($=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":C,"aria-expanded":o,onClick:E,children:T}),t[12]=o,t[13]=C,t[14]=$):$=t[14];let A;t[15]!==S||t[16]!==$?(A=a.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[N,S,$]}),t[15]=S,t[16]=$,t[17]=A):A=t[17];let R;t[18]!==o||t[19]!==l?(R=o&&a.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:a.jsx(On,{type:"search",value:l,onChange:U=>c(U.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=o,t[19]=l,t[20]=R):R=t[20];let P;t[21]!==d||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?(P=[...w.entries()].map(U=>{const[O,D]=U,B=d.has(O)||!!l,q=D.filter(kte),W=D.filter(jte),H=B?D:q.length>0?q:D.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:O}),H.map(K=>{const Z=j.get(`${K.name}:${K.dir}`);return a.jsx(yte,{script:K,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(K.name,K.dir,K.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${O}:${K.name}`)}),!l&&W.length>0&&a.jsx(Q,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>_(O),children:B?"Show less":`Show ${W.length} more`})]},O)}),t[21]=d,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=P):P=t[27];let z;t[28]!==w.size||t[29]!==p||t[30]!==l?(z=!p&&w.size===0&&l&&a.jsx(Ln,{className:"gap-1 p-3",children:a.jsxs(Mn,{className:"gap-1",children:[a.jsx(zn,{children:"No matching scripts"}),a.jsx(Dn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=z):z=t[31];let L;t[32]!==P||t[33]!==z?(L=a.jsxs(Vc,{className:"min-h-0 flex-1 px-1 pb-1",children:[P,z]}),t[32]=P,t[33]=z,t[34]=L):L=t[34];let I;t[35]!==R||t[36]!==L||t[37]!==A?(I=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[A,R,L]}),t[35]=R,t[36]=L,t[37]=A,t[38]=I):I=t[38];let M;t[39]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(tn,{orientation:"vertical"}),t[39]=M):M=t[39];let F;return t[40]!==I?(F=a.jsxs(a.Fragment,{children:[I,M]}),t[40]=I,t[41]=F):F=t[41],F});function Ste(n){return!n}function kte(n){return n.isCommon}function jte(n){return!n.isCommon}function iT({className:n,orientation:e="horizontal",...t}){return a.jsx(W$,{"data-slot":"tabs","data-orientation":e,className:G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",n),...t})}const Nte=io("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 aT({className:n,children:e,variant:t="default",...s}){return a.jsxs(U$,{"data-slot":"tabs-list","data-variant":t,className:G(Nte({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(B$,{"data-slot":"tabs-indicator","data-variant":t,className:G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5")})]})}function hl({className:n,...e}){return a.jsx(q$,{"data-slot":"tabs-trigger",className:G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function gl({className:n,...e}){return a.jsx(F$,{"data-slot":"tabs-content",className:G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",n),...e})}const Cte=y.lazy(()=>nt(()=>import("./TerminalOutput-4YZ5J0ny.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.TerminalOutput})));function _te({process:n}){const[e,t]=y.useState(""),[s,r]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(n.type!=="task"||!n.outputPath)return;t(""),r(!1);const i=nb(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`),l=i.source;return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=GN(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},i.close},[n.id,n.type,n.outputPath]),y.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e]),a.jsx("pre",{ref:o,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||a.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function Ete(n){const e=V.c(34),{process:t,isActive:s,onSelectActive:r,onClose:o,mobile:i}=n,l=t.source??t.name,c=t.id,u=t.name;let d;e[0]!==s||e[1]!==r?(d=()=>{s&&r()},e[0]=s,e[1]=r,e[2]=d):d=e[2];const f=i?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&a.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"&&a.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=a.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=i&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=a.jsx(Fe,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=a.jsxs(hl,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const j=`Close ${t.name}`,k=`Close ${t.name}`;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(Mt,{"data-icon":"inline-start"}),e[25]=_):_=e[25];let N;e[26]!==o||e[27]!==j||e[28]!==k?(N=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:k,onClick:o,className:"mr-0.5 text-muted-foreground",children:_}),e[26]=o,e[27]=j,e[28]=k,e[29]=N):N=e[29];let S;return e[30]!==l||e[31]!==v||e[32]!==N?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,N]}),e[30]=l,e[31]=v,e[32]=N,e[33]=S):S=e[33],S}const lT=100,cT=600,Tte=200,uT="process-panel-height";function Ate(){try{const n=localStorage.getItem(uT);if(n)return Math.min(cT,Math.max(lT,Number(n)))}catch{}return Tte}const Ite=y.memo(function(e){const t=V.c(89),{processes:s,activeProcessId:r,collapsed:o,onSetActive:i,onRemove:l,onToggleCollapse:c,onRequestTerminal:u,onAddTerminalContext:d,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=sb(),[b,w]=y.useState(Ate),v=y.useRef(null);let j,k;t[0]!==f||t[1]!==x.sessions?(j=()=>{for(const le of x.sessions)le.status==="exited"&&(f==null||f(le.id,"stopped"))},k=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=j,t[3]=k):(j=t[2],k=t[3]),y.useEffect(j,k);let _;t[4]!==l||t[5]!==x?(_=le=>{le.type!=="task"&&x.killSession(le.id),l(le.id)},t[4]=l,t[5]=x,t[6]=_):_=t[6];const N=_;let S;t[7]!==b?(S=le=>{le.preventDefault(),v.current={startY:le.clientY,startH:b},le.target.setPointerCapture(le.pointerId)},t[7]=b,t[8]=S):S=t[8];const C=S;let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E=le=>{if(!v.current)return;const pe=v.current.startY-le.clientY,ge=Math.min(cT,Math.max(lT,v.current.startH+pe));w(ge)},t[9]=E):E=t[9];const T=E;let $;t[10]!==b?($=()=>{if(v.current){v.current=null;try{localStorage.setItem(uT,String(b))}catch{}}},t[10]=b,t[11]=$):$=t[11];const A=$;let R;t[12]!==r||t[13]!==s?(R=r?s.get(r):null,t[12]=r,t[13]=s,t[14]=R):R=t[14];const P=R;let z;t[15]!==s?(z=[...s.values()],t[15]=s,t[16]=z):z=t[16];const L=z;let I;t[17]!==i?(I=le=>{typeof le=="string"&&i(le)},t[17]=i,t[18]=I):I=t[18];let M;t[19]!==P||t[20]!==o||t[21]!==g||t[22]!==C||t[23]!==A?(M=!g&&!o&&P&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:C,onPointerMove:T,onPointerUp:A,onPointerCancel:A}),t[19]=P,t[20]=o,t[21]=g,t[22]=C,t[23]=A,t[24]=M):M=t[24];const F=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let U;t[25]!==F?(U=G("flex shrink-0 items-center border-b bg-card",F),t[25]=F,t[26]=U):U=t[26];const O=o?"Expand terminal panel":"Collapse terminal panel",D=!o;let B;t[27]!==o?(B=o?a.jsx(it,{"data-icon":"inline-start"}):a.jsx(Et,{"data-icon":"inline-start"}),t[27]=o,t[28]=B):B=t[28];const q=g&&"sr-only";let W;t[29]!==q?(W=G(q),t[29]=q,t[30]=W):W=t[30];let H;t[31]!==W?(H=a.jsx("span",{className:W,children:"Terminal"}),t[31]=W,t[32]=H):H=t[32];let K;t[33]!==c||t[34]!==O||t[35]!==D||t[36]!==B||t[37]!==H?(K=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":O,"aria-expanded":D,children:[B,H]}),t[33]=c,t[34]=O,t[35]=D,t[36]=B,t[37]=H,t[38]=K):K=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",Z),t[39]=Z,t[40]=Y):Y=t[40];let J;t[41]!==r||t[42]!==N||t[43]!==g||t[44]!==i||t[45]!==L?(J=L.map(le=>a.jsx(Ete,{process:le,isActive:le.id===r,onSelectActive:()=>i(le.id),onClose:()=>N(le),mobile:g},le.id)),t[41]=r,t[42]=N,t[43]=g,t[44]=i,t[45]=L,t[46]=J):J=t[46];let ee;t[47]!==Y||t[48]!==J?(ee=a.jsx(aT,{variant:"default","aria-label":"Open processes",className:Y,children:J}),t[47]=Y,t[48]=J,t[49]=ee):ee=t[49];let te;t[50]!==u||t[51]!==m?(te=u&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:u,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:a.jsx(kr,{})}),t[50]=u,t[51]=m,t[52]=te):te=t[52];let se;t[53]!==U||t[54]!==K||t[55]!==ee||t[56]!==te?(se=a.jsxs("div",{className:U,children:[K,ee,te]}),t[53]=U,t[54]=K,t[55]=ee,t[56]=te,t[57]=se):se=t[57];const X=!o,ne=g?"min(36dvh, 260px)":b;let ae;t[58]!==ne?(ae={height:ne},t[58]=ne,t[59]=ae):ae=t[59];let ie;t[60]!==g||t[61]!==p||t[62]!==m?(ie=!g&&a.jsx(wte,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ie):ie=t[63];let re;t[64]!==N||t[65]!==d||t[66]!==u||t[67]!==L?(re=L.map(le=>a.jsx(gl,{value:le.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:le.type==="task"?a.jsx(_te,{process:le}):a.jsx(y.Suspense,{fallback:a.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:a.jsx(Cte,{processId:le.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>N(le),onAddContext:d})})},le.id)),t[64]=N,t[65]=d,t[66]=u,t[67]=L,t[68]=re):re=t[68];let de;t[69]!==P||t[70]!==u||t[71]!==m?(de=!P&&a.jsxs(Ln,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(_a,{})}),a.jsx(zn,{children:"No terminal open"}),a.jsx(Dn,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(_c,{children:a.jsxs(Q,{type:"button",size:"sm",onClick:u,children:[a.jsx(kr,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=P,t[70]=u,t[71]=m,t[72]=de):de=t[72];let ce;t[73]!==re||t[74]!==de?(ce=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[re,de]}),t[73]=re,t[74]=de,t[75]=ce):ce=t[75];let oe;t[76]!==ae||t[77]!==ie||t[78]!==ce?(oe=a.jsx(yn,{children:a.jsxs("div",{className:"flex min-h-0",style:ae,children:[ie,ce]})}),t[76]=ae,t[77]=ie,t[78]=ce,t[79]=oe):oe=t[79];let fe;t[80]!==X||t[81]!==oe?(fe=a.jsx(vn,{open:X,className:"min-h-0",children:oe}),t[80]=X,t[81]=oe,t[82]=fe):fe=t[82];let ue;return t[83]!==r||t[84]!==I||t[85]!==M||t[86]!==se||t[87]!==fe?(ue=a.jsxs(iT,{value:r,onValueChange:I,className:"shrink-0 gap-0 border-t bg-background",children:[M,se,fe]}),t[83]=r,t[84]=I,t[85]=M,t[86]=se,t[87]=fe,t[88]=ue):ue=t[88],ue});function Hc(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.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 Pte=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function $te(n){const e=new Set;for(const t of n.matchAll(Pte)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function Rte(n){var s;const e=V.c(2);let t;if(e[0]!==n){t=new Map;for(let r=0;r<n.length;r++)for(const o of n[r].toolCalls){if(o.name!=="Bash"||!o.input.run_in_background)continue;const i=o.input.command||"",l=o.input.description||"",c=((s=n[r].assistantText)==null?void 0:s.join(" "))||"",u=[i,l,o.result||"",c].join(" "),d=$te(u);if(d.length===0){const p=i.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&d.push(3e3)}const f=(o.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of d)t.set(p,{description:l||i.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function vk(n){var e;return((e=n.preview.split(`
|
|
334
|
+
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!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=()=>r(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Sr,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=a.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==d?(x=d&&a.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=d,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(ao,{children:[a.jsxs(or,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(Sr,{className:"size-4"}),"Error details"]}),a.jsx(ir,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=a.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let j;e[19]!==o?(j=o?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),e[19]=o,e[20]=j):j=e[20];const k=o?"Copied":"Copy";let _;e[21]!==m||e[22]!==j||e[23]!==k?(_=a.jsx("div",{className:"flex justify-end",children:a.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:m,children:[j,k]})}),e[21]=m,e[22]=j,e[23]=k,e[24]=_):_=e[24];let N;e[25]!==v||e[26]!==_?(N=a.jsxs(rr,{className:"max-w-2xl",children:[w,v,_]}),e[25]=v,e[26]=_,e[27]=N):N=e[27];let S;e[28]!==s||e[29]!==N?(S=a.jsx(sr,{open:s,onOpenChange:r,children:N}),e[28]=s,e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==S||e[32]!==b?(C=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=C):C=e[33],C}function cee(n){const e=V.c(17),{suggestion:t,onAccept:s}=n,[r,o]=y.useState(null);if(!t||t===r)return null;let i;e[0]!==s||e[1]!==t?(i=()=>{o(t),s(t)},e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ql,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=a.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==i||e[7]!==c?(u=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:i,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=i,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==t?(d=()=>o(t),e[9]=t,e[10]=d):d=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Mt,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(Q,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:d,className:"shrink-0 text-muted-foreground",children:f}),e[12]=d,e[13]=m):m=e[13];let p;return e[14]!==u||e[15]!==m?(p=a.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16],p}function uee(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 dee(n,e,t){return`${n.slice(0,e.start)}@${t} `}function Nn(n){const e=V.c(3);let t,s;return e[0]!==n?(t=()=>xt(n),s=()=>xt(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(Rf,t,s)}function fee(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function mee(n,e,t){const s=Nn("hostFiles"),[r,o]=y.useState([]),[i,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){o([]),l(!1);return}const c=new AbortController,u=window.setTimeout(async()=>{l(!0);try{const d=await Ce(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!d.ok)throw new Error(`Request failed (${d.status})`);const f=await d.json();c.signal.aborted||o(fee(f))}catch{c.signal.aborted||o([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(u),c.abort()}},[s,n,t,e]),{files:r,loading:i}}const g1="cogpit-share-revoked";function pee(){window.dispatchEvent(new Event(g1))}async function KE(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&&pee(),s}function Bc(n,e){return KE(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function hee(){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 gee(n,e){return Bc("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function xee(){return Bc("/api/share/interrupt")}function bee(){return Bc("/api/share/stop")}async function vee(n,e){return(await Bc("/api/share/permission",{requestId:n,behavior:e})).ok}async function yee(n,e){try{const t=await Bc("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function wee(){try{const n=await KE("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const See=/^\/shared\/([^/]+)\/?$/;function GE(n){const e=See.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function lm(n){return GE(n)!==null}function kee(n){return`/shared/${encodeURIComponent(n)}`}function jee(n,e){return`${e?new URL(`${e.tls?"https":"http"}://${e.host.includes(":")?`[${e.host}]`:e.host}:${e.port}`).origin:window.location.origin}${kee(n)}`}async function ZE(n,e,t){const s=typeof e.commandId=="string"?e.commandId:crypto.randomUUID(),r={...e,commandId:s};for(let o=0;;o++)try{const i=await(t?Ce(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:t}):is(n,r));return i.ok&&window.dispatchEvent(new CustomEvent("cogpit-command-accepted",{detail:{commandId:s,sessionId:e.sessionId}})),i}catch(i){if(i instanceof Error&&i.name==="AbortError")throw i;if(t!=null&&t.aborted||o>=1)throw new Error(`Delivery could not be confirmed. Your draft is retained. Check receipt ${s} before sending again.`,{cause:i})}}function Nee(n){return[...n].join(", ")}async function YE(n,e){try{const t=await is(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function eb(n,e,t){return lm(window.location.pathname)?yee(e,t):ZE("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t}).then(s=>({ok:s.ok,gone:s.status===404}),()=>({ok:!1,gone:!1}))}async function Cee(n,e,t){try{return(await is(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function Wc(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background 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:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("textarea",{"data-slot":"textarea",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ou(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 r;if(e){const i=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,r=n.scrollHeight>48,n.style.width=i}else r=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",r}function _ee(n,e,t,s,r,o){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":o?r?"Steer…":"Message…":r?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function Eee(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 Tee(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?G("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):G("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function Aee(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 x1=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var He;const c=Nn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:w,turnError:v,promptSuggestion:j}=jt(),{chat:{status:k,error:_,isConnected:N,sendMessage:S,interrupt:C}}=Wf(),E=N||d,[T,$]=y.useState(""),[A,R]=y.useState(!1),[P,z]=y.useState(!1),[L,I]=y.useState(null),M=y.useRef(null),F=y.useRef(null),U=y.useRef(!1),O=y.useRef(""),D=y.useRef(null);y.useEffect(()=>{O.current=T},[T]);const B=y.useCallback(me=>{U.current=me,R(me)},[]),{images:q,isDragOver:W,imageError:H,hasUnsupportedAttachments:K,dismissImageError:Z,removeImage:Y,clearImages:J,restoreImages:ee,handleDragOver:te,handleDragLeave:se,handleDrop:X,handlePaste:ne}=Vz(e),ae=y.useRef(q);y.useEffect(()=>{ae.current=q},[q]);const ie=(u==null?void 0:u.sessionId)??null,re=y.useRef(null),de=y.useRef(null);y.useEffect(()=>{const me=()=>O.current.trim()!==""||ae.current.length>0;re.current={sessionId:ie};const je=ie&&!me()?Zz(ie):void 0;return je&&(de.current=ie,O.current=je.text,ae.current=je.images,$(je.text),ee(je.images)),()=>{re.current=null,ie&&de.current===ie&&me()&&(p2(ie,{text:O.current,images:ae.current}),O.current="",ae.current=[],$(""),J()),de.current=null}},[ie,ee,J]);const[ce,oe]=y.useState(0),[fe,ue]=y.useState(0),[le,pe]=y.useState(!1),ge=T.startsWith("/")&&!T.includes(" "),be=ge?T.slice(1):"",ve=y.useMemo(()=>{if(!ge)return[];const me=be.toLowerCase(),je=b.filter(dt=>me?dt.name.toLowerCase().includes(me)||dt.description.toLowerCase().includes(me):!0),Xe=je.filter(dt=>dt.type==="command"),tt=je.filter(dt=>dt.type==="skill");return[...Xe,...tt]},[ge,be,b]),Se=y.useMemo(()=>uee(T),[T]),we=!!(c&&Se&&s&&!le),Ee=mee(s,(Se==null?void 0:Se.query)??"",we);y.useEffect(()=>{oe(0)},[be]),y.useEffect(()=>{ue(0)},[Se==null?void 0:Se.query]);const $e=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{F.current=$e,M.current=null,z(!1),I(null)},[$e]);const Be=y.useCallback(async me=>{const je=m;if(!(u!=null&&u.sessionId)||(je==null?void 0:je.type)!=="question")return;const Xe=je.questions[0];if(!Xe||!me.trim())return;(await eb(u.sessionId,je.toolUseId,{[Xe.question]:me})).ok||S(me)},[m,u==null?void 0:u.sessionId,S]),qe=y.useCallback(async(me,je,Xe)=>{const tt=m;if((tt==null?void 0:tt.type)==="plan"&&tt.provider==="copilot"&&tt.requestId&&(u!=null&&u.sessionId)){const dt=tt.requestId;if(M.current)return!1;M.current=dt,z(!0),I(null);try{const zt=await Cee(u.sessionId,dt,{approved:me,...je?{selectedAction:je}:{},...Xe?{feedback:Xe}:{}});return!zt&&F.current===dt&&I("Couldn't send the plan response. Try again."),zt}finally{M.current===dt&&(M.current=null,z(!1))}}return S(me?"yes":Xe||"no"),!0},[m,u==null?void 0:u.sessionId,S]),ze=y.useCallback(()=>{requestAnimationFrame(()=>{const me=D.current;me&&(me.focus(),me.selectionStart=me.selectionEnd=me.value.length,B(Ou(me,U.current)))})},[B]),Ie=y.useCallback(me=>{$(`/${me.name} `),oe(0),ze()},[ze]),Me=y.useCallback(me=>{$(me),ze()},[ze]),Ue=y.useCallback(me=>{if(!Se)return;const je=dee(T,Se,me);$(je),pe(!0),ue(0),requestAnimationFrame(()=>{const Xe=D.current;Xe&&(Xe.focus(),Xe.selectionStart=Xe.selectionEnd=Xe.value.length,B(Ou(Xe,U.current)))})},[Se,T,B]),De=y.useCallback(async()=>{const me=T.trim();if(!me&&q.length===0||!e&&q.length>0)return;if((m==null?void 0:m.type)==="question"){Be(me),$(""),B(!1),D.current&&(D.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!me||!await qe(!1,void 0,me))return;$(""),B(!1),D.current&&(D.current.style.height="auto");return}const je=e&&q.length>0?q.map(tt=>({data:tt.data,mediaType:tt.mediaType})):void 0,Xe={text:T,images:q};de.current=null,S(me,je).then(tt=>{var dt;if(!tt){if(((dt=re.current)==null?void 0:dt.sessionId)!==ie){ie&&p2(ie,Xe);return}de.current=ie,$(zt=>zt||Xe.text),ee(Xe.images)}}),$(""),J(),B(!1),D.current&&(D.current.style.height="auto")},[T,q,e,S,J,ee,B,m,Be,qe,ie]),Ke=y.useCallback(me=>{if(we&&me.key==="Escape"){me.preventDefault(),pe(!0);return}if(we&&Ee.files.length>0){if(me.key==="ArrowDown"){me.preventDefault(),ue(je=>je<Ee.files.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),ue(je=>je>0?je-1:Ee.files.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=Ee.files[fe];je&&Ue(je);return}}if(ge&&ve.length>0){if(me.key==="ArrowDown"){me.preventDefault(),oe(je=>je<ve.length-1?je+1:0);return}if(me.key==="ArrowUp"){me.preventDefault(),oe(je=>je>0?je-1:ve.length-1);return}if(me.key==="Tab"||me.key==="Enter"&&!me.shiftKey){me.preventDefault();const je=ve[ce];je&&Ie(je);return}if(me.key==="Escape"){me.preventDefault(),$("");return}}if(me.key==="Escape"&&E&&C){me.preventDefault(),C();return}me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),De())},[De,E,C,we,Ee.files,fe,Ue,ge,ve,ce,Ie]),Ne=y.useCallback(me=>{$(me.target.value),pe(!1),B(Ou(me.target,U.current))},[B]);y.useImperativeHandle(l,()=>({focus:()=>{var me;return(me=D.current)==null?void 0:me.focus()},getText:()=>O.current,setText:me=>{$(me),pe(!1),requestAnimationFrame(()=>B(Ou(D.current,U.current)))}}),[B]);const Ae=(m==null?void 0:m.type)==="plan",Qe=(m==null?void 0:m.type)==="question",Je=p.length>0,ke=!!o,We=(T.trim().length>0||q.length>0)&&!K,ye=bn(t??Wo).midTurnSteering&&E,Re=we?"file-suggestions":ge?"slash-suggestions":void 0,Ve=we&&Ee.files[fe]?`file-suggestion-${fe}`:ge&&ve[ce]?`slash-suggestion-${ce}`:void 0;return a.jsxs("div",{className:G("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",W&&"ring-2 ring-info/40 ring-inset"),onDragOver:te,onDragLeave:se,onDrop:X,children:[W&&a.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:a.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),ge&&a.jsx(Iz,{suggestions:ve,filter:be,loading:w,selectedIndex:ce,onSelect:Ie,onHover:oe,onEdit:f}),we&&a.jsx(Oz,{files:Ee.files,query:(Se==null?void 0:Se.query)??"",loading:Ee.loading,selectedIndex:fe,onSelect:Ue,onHover:ue}),a.jsxs("div",{children:[Ae&&a.jsx($5,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:P,responseError:L,onApprove:me=>{qe(!0,me)},onReject:()=>{qe(!1)}}),a.jsx(cee,{suggestion:j,onAccept:Me}),q.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:q.map((me,je)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:me.preview,alt:`Upload ${je+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(je),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-popover 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 ${je+1}`,children:a.jsx(Mt,{className:"size-3","data-icon":"icon"})})]},me.id))}),H&&a.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[a.jsx("span",{className:"flex-1",children:H}),!K&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(Mt,{"data-icon":"icon"})})]}),a.jsxs("div",{className:G("relative overflow-hidden border bg-popover shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150",ke?"rounded-3xl":"rounded-xl",Eee(Ae,Qe,Je),"focus-within:ring-3"),children:[Je&&a.jsx(R5,{requests:p,responding:h,onRespond:g,onRespondAll:x},(He=p[0])==null?void 0:He.requestId),a.jsxs("div",{className:G("min-w-0",ke?"flex flex-col":"grid items-end",!ke&&(A?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:G("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:r}),a.jsx(Wc,{ref:D,value:T,onChange:Ne,onKeyDown:Ke,onPaste:ne,onFocus:()=>{setTimeout(()=>{var me;return(me=D.current)==null?void 0:me.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:_ee(Ae,Qe,N,Je,ye,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!Re,"aria-controls":Re,"aria-activedescendant":Ve,rows:1,className:G("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",Tee(ke,A,i))}),a.jsxs("div",{className:G("flex shrink-0 items-center justify-end",Aee(ke,A)),children:[o,a.jsx(aee,{}),a.jsx(Xz,{hasContent:We,onSubmit:De,submitLabel:ye?"Steer active turn":"Send message"})]})]})]}),k==="error"&&_&&a.jsx(hk,{error:_},_),v&&a.jsx(hk,{error:v},v)]})]})}));function Iee(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=L9(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const r=typeof s.condition=="string"?s.condition:"",o=s.met===!0,i=s.failed===!0;return s.sentinel===!0&&o||!r?null:{condition:r,status:i?"failed":o?"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 Lu(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function qc(n){const e=V.c(13);let t,s,r,o;e[0]!==n?({className:s,children:t,value:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e[5]!==s?(i=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Pee,{children:a.jsx($ee,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(C$,{value:o,"data-slot":"progress",className:i,...r,children:[t,l]}),e[8]=t,e[9]=r,e[10]=i,e[11]=o,e[12]=c):c=e[12],c}function Pee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(_$,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function $ee(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(E$,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function XE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(T$,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function JE(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(A$,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const Ree={section:null,canCreate:!1,beginEditing:()=>{}},tb=y.createContext(Ree);function QE(){return y.useContext(tb)}const eT="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",tT="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function Oee(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function Lee(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function Mee({agentKind:n,threadId:e,children:t}){const s=Bf(n),[r,o]=y.useState(null),[i,l]=y.useState(!0),[c,u]=y.useState(!1),[d,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async E=>{try{const T=await Ce(Lu(e),{signal:E});if(T.status===404||T.status===501){l(!1);return}if(!T.ok)return;const $=await T.json();o($.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const E=new AbortController;w(E.signal);const T=i?setInterval(()=>void w(),1e4):void 0;return()=>{E.abort(),T!==void 0&&clearInterval(T)}},[w,i]);const v=y.useCallback(()=>{var E;f((r==null?void 0:r.objective)??""),p(((E=r==null?void 0:r.tokenBudget)==null?void 0:E.toString())??""),b(null),u(!0)},[r]),j=async()=>{const E=d.trim();if(!E)return;const T=m.trim()?Number(m):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const $=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:E,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:T})}),A=await $.json();if(!$.ok)throw new Error(A.error||"Could not save goal");o(A.goal),u(!1)}catch($){b($ instanceof Error?$.message:"Could not save goal")}finally{g(!1)}},k=async E=>{if(r){g(!0);try{const T=await Ce(Lu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:E})});T.ok&&o((await T.json()).goal)}finally{g(!1)}}},_=async()=>{g(!0);try{(await Ce(Lu(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},N=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:tT,onSubmit:E=>{E.preventDefault(),j()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(Aa,{className:"gap-2",children:[a.jsxs(fn,{children:[a.jsx(mn,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(Wc,{id:"goal-objective",value:d,onChange:E=>f(E.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(fn,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(mn,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(On,{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})]})]}),a.jsx(Eo,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(Q,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(nn,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const E=r.status==="paused",T=r.status==="complete";S=a.jsxs("section",{className:eT,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hl,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:r.objective,children:r.objective}),a.jsx(Fe,{variant:Lee(r.status),children:Oee(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[vt(r.tokensUsed),r.tokenBudget?` / ${vt(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[E&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(Ca,{"data-icon":"icon"})}),!E&&!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(I$,{"data-icon":"icon"})}),!T&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void k("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(nn,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:a.jsx(wr,{"data-icon":"icon"})}),a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void _(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(kf,{"data-icon":"icon"})})]})]}),N!==null&&a.jsx(qc,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const C=y.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:v}),[S,i,r,c,v]);return a.jsx(tb.Provider,{value:C,children:t})}function zee(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function Dee(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function Fee(n){const e=V.c(89),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=Bf(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=Iee(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const u=c,[d,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=u?`${u.status}\0${u.condition}`:"",[v,j]=y.useState(w);v!==w&&(j(w),f(void 0));const k=d!==void 0?d:u;let _;e[4]!==(k==null?void 0:k.condition)?(_=()=>{g((k==null?void 0:k.condition)??""),b(null),p(!0)},e[4]=k==null?void 0:k.condition,e[5]=_):_=e[5];const N=_;let S;e[6]!==r||e[7]!==d?(S=async(M,F)=>{const U=d;f(F),p(!1);const O=await r(M);return O||f(U),O},e[6]=r,e[7]=d,e[8]=S):S=e[8];const C=S;let E;e[9]!==h||e[10]!==C?(E=async()=>{const M=h.trim();if(!M)return;if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}await C(`/goal ${M}`,{condition:M,status:"active",iterations:0,durationMs:0,tokens:0})||(g(M),p(!0))},e[9]=h,e[10]=C,e[11]=E):E=e[11];const T=E;let $;e[12]!==C?($=()=>void C("/goal clear",null),e[12]=C,e[13]=$):$=e[13];const A=$;let R;if(e[14]!==l||e[15]!==N||e[16]!==A||e[17]!==h||e[18]!==m||e[19]!==x||e[20]!==k||e[21]!==T){if(R=null,m){let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5","data-icon":"inline-start"}),e[23]=M):M=e[23];const F=k?"Replace goal":"Set a long-running goal";let U;e[24]!==F?(U=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,F]}),e[24]=F,e[25]=U):U=e[25];const O=!!x;let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(mn,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[26]=D):D=e[26];let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=ne=>g(ne.target.value),e[27]=B):B=e[27];const q=`A measurable condition ${l} should keep working toward…`,W=!!x;let H;e[28]!==h||e[29]!==q||e[30]!==W?(H=a.jsx(Wc,{id:"goal-condition",value:h,onChange:B,placeholder:q,rows:2,maxLength:4e3,"aria-invalid":W,autoFocus:!0}),e[28]=h,e[29]=q,e[30]=W,e[31]=H):H=e[31];let K;e[32]!==x?(K=a.jsx(Eo,{children:x}),e[32]=x,e[33]=K):K=e[33];let Z;e[34]!==O||e[35]!==H||e[36]!==K?(Z=a.jsxs(fn,{"data-invalid":O,children:[D,H,K]}),e[34]=O,e[35]=H,e[36]=K,e[37]=Z):Z=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(Mt,{"data-icon":"inline-start"}),"Cancel"]}),e[38]=Y):Y=e[38];let J;e[39]!==T?(J=()=>void T(),e[39]=T,e[40]=J):J=e[40];let ee;e[41]!==h?(ee=h.trim(),e[41]=h,e[42]=ee):ee=e[42];const te=!ee;let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=a.jsx(nn,{"data-icon":"inline-start"}),e[43]=se):se=e[43];let X;e[44]!==J||e[45]!==te?(X=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,a.jsxs(Q,{type:"button",size:"xs",onClick:J,disabled:te,children:[se,"Start goal"]})]}),e[44]=J,e[45]=te,e[46]=X):X=e[46],R=a.jsxs("section",{className:tT,"aria-label":`${l} goal editor`,children:[U,Z,X]})}else if(k){let M;e[47]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Hl,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[47]=M):M=e[47];let F;e[48]!==k.condition?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:k.condition,children:k.condition}),e[48]=k.condition,e[49]=F):F=e[49];let U;e[50]!==k.status?(U=Dee(k.status),e[50]=k.status,e[51]=U):U=e[51];let O;e[52]!==k.status?(O=zee(k.status),e[52]=k.status,e[53]=O):O=e[53];let D;e[54]!==O||e[55]!==U?(D=a.jsx(Fe,{variant:U,children:O}),e[54]=O,e[55]=U,e[56]=D):D=e[56];const B=k.iterations,q=k.iterations===1?"":"s";let W;e[57]!==k.tokens?(W=vt(k.tokens),e[57]=k.tokens,e[58]=W):W=e[58];let H;e[59]!==k.durationMs?(H=Math.round(k.durationMs/6e4),e[59]=k.durationMs,e[60]=H):H=e[60];const K=Math.max(0,H);let Z;e[61]!==k.iterations||e[62]!==q||e[63]!==W||e[64]!==K?(Z=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[B," turn",q," · ",W," · ",K,"m"]}),e[61]=k.iterations,e[62]=q,e[63]=W,e[64]=K,e[65]=Z):Z=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(wr,{"data-icon":"icon"}),e[66]=Y):Y=e[66];let J;e[67]!==N?(J=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:N,"aria-label":"Replace goal",children:Y}),e[67]=N,e[68]=J):J=e[68];let ee;e[69]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(kf,{"data-icon":"icon"}),e[69]=ee):ee=e[69];let te;e[70]!==A?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:A,"aria-label":"Clear goal",children:ee}),e[70]=A,e[71]=te):te=e[71];let se;e[72]!==J||e[73]!==te?(se=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[J,te]}),e[72]=J,e[73]=te,e[74]=se):se=e[74];let X;e[75]!==D||e[76]!==Z||e[77]!==se||e[78]!==F?(X=a.jsxs("div",{className:"flex items-center gap-2",children:[M,F,D,Z,se]}),e[75]=D,e[76]=Z,e[77]=se,e[78]=F,e[79]=X):X=e[79];let ne;e[80]!==k.reason?(ne=k.reason&&a.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:k.reason}),e[80]=k.reason,e[81]=ne):ne=e[81],R=a.jsxs("section",{className:eT,"aria-label":`${l} goal`,children:[X,ne]})}e[14]=l,e[15]=N,e[16]=A,e[17]=h,e[18]=m,e[19]=x,e[20]=k,e[21]=T,e[22]=R}else R=e[22];const P=!k&&!m;let z;e[82]!==N||e[83]!==R||e[84]!==P?(z={section:R,canCreate:P,beginEditing:N},e[82]=N,e[83]=R,e[84]=P,e[85]=z):z=e[85];const L=z;let I;return e[86]!==o||e[87]!==L?(I=a.jsx(tb.Provider,{value:L,children:o}),e[86]=o,e[87]=L,e[88]=I):I=e[88],I}function Uee(n){const e=V.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=bn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx(Mee,{agentKind:t,threadId:s.sessionId,children:o}),e[0]=t,e[1]=o,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(i==="transcript"){let l;return e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==s?(l=a.jsx(Fee,{agentKind:t,session:s,onSendCommand:r,children:o}),e[4]=t,e[5]=o,e[6]=r,e[7]=s,e[8]=l):l=e[8],l}return o}function Bee(){return QE().section}function gk(){const n=V.c(3),{canCreate:e,beginEditing:t}=QE();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Hl,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(Q,{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]=r):r=n[2],r}const Wee=["allow","allow_always","deny"],qee=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function Vee(n,e){return(n.availableDecisions??Wee).includes(e)}function Hee(n){const e=V.c(22),{request:t,queued:s,responding:r,onRespond:o}=n;let i;if(e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r){let l;e[5]!==t?(l=w=>Vee(t,w.decision),e[5]=t,e[6]=l):l=e[6];const c=qee.filter(l);t.defaultToNo&&c.sort(Gee);const u=c.some(Kee);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(lx,{className:"text-warning"}),e[7]=d):d=e[7];const f=t.title||`Allow ${t.toolName}?`;let m;e[8]!==f?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==s?(p=s>0&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",s]}),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=a.jsxs(Xt,{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==t.toolName?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=g):g=e[16];let x;e[17]!==t.summary?(x=t.summary&&a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=x):x=e[18];let b;e[19]!==g||e[20]!==x?(b=a.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[g,x]}),e[19]=g,e[20]=x,e[21]=b):b=e[21],i=a.jsxs(kt,{className:"border-warning/40 bg-warning/5",children:[d,h,b,o&&(u?a.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:c.map(w=>{const{decision:v,label:j,variant:k}=w;return a.jsx(Q,{autoFocus:t.defaultToNo&&v==="deny",size:"xs",variant:k,disabled:r,onClick:()=>o(t.requestId,v),children:j},`${t.requestId}:${v}`)})}):a.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"}))]}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i}else i=e[4];return i}function Kee(n){return n.decision!=="allow_always"}function Gee(n,e){return+(e.decision==="deny")-+(n.decision==="deny")}const nT=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function sT(n){const e=V.c(29);let t,s,r,o,i,l,c;e[0]!==n?({className:s,variant:c,size:o,spacing:i,orientation:l,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=i===void 0?2:i,d=l===void 0?"horizontal":l;let f;e[8]!==u?(f={"--gap":u},e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==d||e[13]!==o||e[14]!==u||e[15]!==c?(h={variant:c,size:o,spacing:u,orientation:d},e[12]=d,e[13]=o,e[14]=u,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=a.jsx(nT.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==d||e[21]!==r||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=a.jsx(P$,{"data-slot":"toggle-group","data-variant":c,"data-size":o,"data-spacing":u,"data-orientation":d,orientation:d,style:m,className:p,...r,children:g}),e[20]=d,e[21]=r,e[22]=o,e[23]=u,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function b1(n){const e=V.c(19);let t,s,r,o,i;e[0]!==n?({className:s,children:t,variant:o,size:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"default":o,c=i===void 0?"default":i,u=y.useContext(nT),d=u.variant||l,f=u.size||c,m=u.spacing;let p;e[6]!==s||e[7]!==u.size||e[8]!==u.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",g5({variant:u.variant||l,size:u.size||c}),s),e[6]=s,e[7]=u.size,e[8]=u.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==u.spacing||e[14]!==r||e[15]!==d||e[16]!==f||e[17]!==p?(h=a.jsx(x4,{"data-slot":"toggle-group-item","data-variant":d,"data-size":f,"data-spacing":m,className:p,...r,children:t}),e[12]=t,e[13]=u.spacing,e[14]=r,e[15]=d,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function Zee(n){return n.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function Yee(n){const e=V.c(64),{request:t,responding:s,gone:r,onAnswer:o,onOpenSession:i}=n,l=t.questions,[c,u]=y.useState(0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const f=y.useRef(d);let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[1]=m):m=e[1];const[p,h]=y.useState(m);if(l.length===0)return null;if(Zee(l)){let M;e[2]!==l[0].question?(M=a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:l[0].question}),e[2]=l[0].question,e[3]=M):M=e[3];let F;e[4]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(it,{"data-icon":"inline-end"}),e[4]=F):F=e[4];let U;e[5]!==i?(U=a.jsxs(Q,{variant:"outline",size:"sm",onClick:i,className:"mt-3",children:["Open full question",F]}),e[5]=i,e[6]=U):U=e[6];let O;return e[7]!==M||e[8]!==U?(O=a.jsxs(xk,{children:[M,U]}),e[7]=M,e[8]=U,e[9]=O):O=e[9],O}const g=l[c],x=s||!o;let b;e[10]!==g.question||e[11]!==c||e[12]!==o||e[13]!==l.length||e[14]!==t.toolUseId?(b=function(F){const U={...f.current,[g.question]:F};if(c+1<l.length){f.current=U,h(new Set),u(c+1);return}o==null||o(t.toolUseId,U)},e[10]=g.question,e[11]=c,e[12]=o,e[13]=l.length,e[14]=t.toolUseId,e[15]=b):b=e[15];const w=b;let v;e[16]!==g.header?(v=g.header&&a.jsx(Fe,{variant:"outline",className:"border-info/40 text-info",children:g.header}),e[16]=g.header,e[17]=v):v=e[17];let j;e[18]!==c||e[19]!==l.length?(j=l.length>1&&a.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[c+1," of ",l.length]}),e[18]=c,e[19]=l.length,e[20]=j):j=e[20];let k;e[21]!==v||e[22]!==j?(k=a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[v,j]}),e[21]=v,e[22]=j,e[23]=k):k=e[23];let _;e[24]!==g.question?(_=a.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:g.question,children:g.question}),e[24]=g.question,e[25]=_):_=e[25];let N;e[26]!==p?(N=[...p],e[26]=p,e[27]=N):N=e[27];let S;e[28]!==w||e[29]!==g.multiSelect?(S=M=>{g.multiSelect?h(new Set(M)):M[0]&&w(M[0])},e[28]=w,e[29]=g.multiSelect,e[30]=S):S=e[30];const C=g.multiSelect,E=g.question;let T;if(e[31]!==g.options||e[32]!==x){let M;e[34]!==x?(M=F=>a.jsx(Xee,{option:F,disabled:x},F.label),e[34]=x,e[35]=M):M=e[35],T=g.options.map(M),e[31]=g.options,e[32]=x,e[33]=T}else T=e[33];let $;e[36]!==g.multiSelect||e[37]!==g.question||e[38]!==T||e[39]!==N||e[40]!==S?($=a.jsx(sT,{value:N,onValueChange:S,multiple:C,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":E,children:T}),e[36]=g.multiSelect,e[37]=g.question,e[38]=T,e[39]=N,e[40]=S,e[41]=$):$=e[41];let A;e[42]!==w||e[43]!==g.multiSelect||e[44]!==c||e[45]!==o||e[46]!==l.length||e[47]!==s||e[48]!==p?(A=g.multiSelect&&o&&a.jsx(Q,{size:"sm",disabled:s||p.size===0,onClick:()=>w(Nee(p)),children:c+1<l.length?"Next":"Send"}),e[42]=w,e[43]=g.multiSelect,e[44]=c,e[45]=o,e[46]=l.length,e[47]=s,e[48]=p,e[49]=A):A=e[49];let R;e[50]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx(it,{"data-icon":"inline-end"}),e[50]=R):R=e[50];let P;e[51]!==i?(P=a.jsxs(Q,{variant:"ghost",size:"sm",onClick:i,className:"ml-auto text-muted-foreground",children:["Open session",R]}),e[51]=i,e[52]=P):P=e[52];let z;e[53]!==A||e[54]!==P?(z=a.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[A,P]}),e[53]=A,e[54]=P,e[55]=z):z=e[55];let L;e[56]!==r?(L=r&&a.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[56]=r,e[57]=L):L=e[57];let I;return e[58]!==$||e[59]!==z||e[60]!==L||e[61]!==k||e[62]!==_?(I=a.jsxs(xk,{children:[k,_,$,z,L]}),e[58]=$,e[59]=z,e[60]=L,e[61]=k,e[62]=_,e[63]=I):I=e[63],I}function Xee(n){const e=V.c(17),{option:t,disabled:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];const o=r;if(!t.description){let d;return e[2]!==s||e[3]!==o||e[4]!==t.label?(d=a.jsx(b1,{value:t.label,disabled:s,className:"w-full justify-start px-3",children:o}),e[2]=s,e[3]=o,e[4]=t.label,e[5]=d):d=e[5],d}let i;e[6]!==s||e[7]!==t.label?(i=a.jsx(b1,{value:t.label,disabled:s,className:"w-full justify-start px-3"}),e[6]=s,e[7]=t.label,e[8]=i):i=e[8];let l;e[9]!==o||e[10]!==i?(l=a.jsx(Zt,{render:i,children:o}),e[9]=o,e[10]=i,e[11]=l):l=e[11];let c;e[12]!==t.description?(c=a.jsx(Yt,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=c):c=e[13];let u;return e[14]!==l||e[15]!==c?(u=a.jsxs(Gt,{children:[l,c]}),e[14]=l,e[15]=c,e[16]=u):u=e[16],u}function xk(n){const e=V.c(4),{children:t}=n;let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx($$,{className:"text-info"}),r=a.jsx(Xt,{children:"Answer to continue"}),e[0]=s,e[1]=r):(s=e[0],r=e[1]);let o;return e[2]!==t?(o=a.jsxs(kt,{className:"border-info/40 bg-info/5",children:[s,r,a.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=o):o=e[3],o}function Jee(n){const e=V.c(45),{sessionId:t,pending:s,queued:r,responding:o,onRespond:i,onOpen:l}=n;switch(s.kind){case"permission":{let c;e[0]!==s||e[1]!==t?(c={...s,sessionId:t,timestamp:0},e[0]=s,e[1]=t,e[2]=c):c=e[2];let u;e[3]!==i?(u=(f,m)=>i(f,{decision:m}),e[3]=i,e[4]=u):u=e[4];let d;return e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==u?(d=a.jsx(Hee,{request:c,queued:r,responding:o,onRespond:u}),e[5]=r,e[6]=o,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}case"question":{const c=s.requestId;let u;e[10]!==s.questions?(u=s.questions.map(Qee),e[10]=s.questions,e[11]=u):u=e[11];let d;e[12]!==s.requestId||e[13]!==t||e[14]!==u?(d={sessionId:t,toolUseId:c,askedAt:0,questions:u},e[12]=s.requestId,e[13]=t,e[14]=u,e[15]=d):d=e[15];let f;e[16]!==i?(f=(p,h)=>i(p,{answers:h}),e[16]=i,e[17]=f):f=e[17];let m;return e[18]!==l||e[19]!==o||e[20]!==d||e[21]!==f?(m=a.jsx(Yee,{request:d,responding:o,gone:!1,onAnswer:f,onOpenSession:l}),e[18]=l,e[19]=o,e[20]=d,e[21]=f,e[22]=m):m=e[22],m}case"plan":{let c,u;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(R$,{className:"text-info"}),u=a.jsx(Xt,{children:"Approve the plan?"}),e[23]=c,e[24]=u):(c=e[23],u=e[24]);let d;e[25]!==s.summary?(d=s.summary&&a.jsx("p",{className:"col-start-2 mt-1 line-clamp-3 text-sm text-foreground",children:s.summary}),e[25]=s.summary,e[26]=d):d=e[26];let f;e[27]!==i||e[28]!==s.requestId?(f=()=>i(s.requestId,{approved:!0}),e[27]=i,e[28]=s.requestId,e[29]=f):f=e[29];let m;e[30]!==o||e[31]!==f?(m=a.jsx(Q,{size:"xs",disabled:o,onClick:f,children:"Approve"}),e[30]=o,e[31]=f,e[32]=m):m=e[32];let p;e[33]!==i||e[34]!==s.requestId?(p=()=>i(s.requestId,{approved:!1}),e[33]=i,e[34]=s.requestId,e[35]=p):p=e[35];let h;e[36]!==o||e[37]!==p?(h=a.jsx(Q,{size:"xs",variant:"destructive",disabled:o,onClick:p,children:"Reject"}),e[36]=o,e[37]=p,e[38]=h):h=e[38];let g;e[39]!==m||e[40]!==h?(g=a.jsxs("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:[m,h]}),e[39]=m,e[40]=h,e[41]=g):g=e[41];let x;return e[42]!==d||e[43]!==g?(x=a.jsxs(kt,{className:"border-info/40 bg-info/5",children:[c,u,d,g]}),e[42]=d,e[43]=g,e[44]=x):x=e[44],x}}}function Qee(n){return{question:n.question,multiSelect:n.multiSelect,options:n.options.map(ete)}}function ete(n){return{label:n,hasPreview:!1}}const tte=3e3;function nte(n){const[e,t]=y.useState([]),[s,r]=y.useState(new Set),o=y.useCallback(async l=>{if(n)try{const c=await Ce(`/api/session-requests?parent=${encodeURIComponent(n)}`);if(!l()||!c.ok)return;const u=await c.json();if(!l())return;t(d=>JSON.stringify(d)===JSON.stringify(u.requests)?d:u.requests)}catch{}},[n]);Oa(n?o:null,tte),y.useEffect(()=>{t([])},[n]);const i=y.useCallback(async(l,c,u)=>{r(d=>new Set(d).add(c));try{const d=await is("/api/session-respond",{sessionId:l,requestId:c,...u});(d.ok||d.status===404)&&t(f=>f.map(m=>m.sessionId===l?{...m,waiting:m.waiting.filter(p=>p.requestId!==c)}:m).filter(m=>m.waiting.length>0))}finally{r(d=>{const f=new Set(d);return f.delete(c),f})}},[]);return{requests:e,responding:s,respond:i}}function za(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function ha(n,e,t){return`${t===void 0?_x():`/d/${encodeURIComponent(t)}`}/${encodeURIComponent(n)}/${encodeURIComponent(Q4(n,e))}`}async function cm(n){let e;try{e=await Ce(`/api/find-session/${encodeURIComponent(n)}`)}catch{return!1}const t=e.ok?await zs(e):null;return typeof(t==null?void 0:t.dirName)!="string"||typeof t.fileName!="string"?!1:(za(ha(t.dirName,t.fileName)),!0)}function ste(n){var o;if(!n.address)return null;const{dirName:e,fileName:t}=n.address,s=((o=n.device)==null?void 0:o.id)??Kt();return`${s===Ot?"":`/d/${encodeURIComponent(s)}`}/${encodeURIComponent(e)}/${encodeURIComponent(Q4(e,t))}`}function rte(n){const e=V.c(9),{sessionId:t}=n,{requests:s,responding:r,respond:o}=nte(t);if(s.length===0)return null;let i;if(e[0]!==s||e[1]!==o||e[2]!==r){let c;e[4]!==o||e[5]!==r?(c=u=>a.jsx(ote,{request:u,responding:r,onRespond:(d,f)=>void o(u.sessionId,d,f)},u.sessionId),e[4]=o,e[5]=r,e[6]=c):c=e[6],i=s.map(c),e[0]=s,e[1]=o,e[2]=r,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=a.jsx("div",{className:"flex flex-col gap-2 px-3 pb-2",children:i}),e[7]=i,e[8]=l):l=e[8],l}function ote(n){const e=V.c(26),{request:t,responding:s,onRespond:r}=n;let o;e[0]!==t?(o=ste(t),e[0]=t,e[1]=o):o=e[1];const i=o;let l;e[2]!==i?(l=()=>{i&&za(i)},e[2]=i,e[3]=l):l=e[3];const c=l,[u]=t.waiting;if(!u)return null;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(cx,{className:"size-3.5"}),e[4]=d):d=e[4];const f=t.device?`Delegated session on ${t.device.name}`:"Delegated session";let m;e[5]!==f?(m=a.jsx("span",{className:"truncate",children:f}),e[5]=f,e[6]=m):m=e[6];let p;e[7]!==c||e[8]!==i?(p=i&&a.jsxs(Q,{variant:"ghost",size:"xs",className:"ml-auto",onClick:c,children:["Open",a.jsx(it,{"data-icon":"inline-end"})]}),e[7]=c,e[8]=i,e[9]=p):p=e[9];let h;e[10]!==m||e[11]!==p?(h=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[d,m,p]}),e[10]=m,e[11]=p,e[12]=h):h=e[12];const g=u.requestId,x=t.sessionId,b=t.waiting.length-1;let w;e[13]!==u.requestId||e[14]!==s?(w=s.has(u.requestId),e[13]=u.requestId,e[14]=s,e[15]=w):w=e[15];let v;e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==t.sessionId||e[20]!==b||e[21]!==w?(v=a.jsx(Jee,{sessionId:x,pending:u,queued:b,responding:w,onRespond:r,onOpen:c},g),e[16]=r,e[17]=c,e[18]=u,e[19]=t.sessionId,e[20]=b,e[21]=w,e[22]=v):v=e[22];let j;return e[23]!==v||e[24]!==h?(j=a.jsxs("div",{className:"flex flex-col gap-1",children:[h,v]}),e[23]=v,e[24]=h,e[25]=j):j=e[25],j}const v1="cogpit-session-config-changed";function ite(n){if(typeof n!="string")return null;let e;try{e=JSON.parse(n)}catch{e=n.trim()}if(typeof e=="string")return e||null;const t=e==null?void 0:e.sessionId;return typeof t=="string"?t:null}function ate(n){function e(t){const s=ite(t.data);s&&window.dispatchEvent(new CustomEvent(v1,{detail:{sessionId:s}}))}return n.addEventListener(_y,e),()=>n.removeEventListener(_y,e)}function lte(n,e){function t(s){var r;((r=s.detail)==null?void 0:r.sessionId)===n&&e()}return window.addEventListener(v1,t),()=>window.removeEventListener(v1,t)}const nf=new Map;class cte extends EventTarget{constructor(t,s){super();Ge(this,"CONNECTING",0);Ge(this,"OPEN",1);Ge(this,"CLOSED",2);Ge(this,"withCredentials",!1);Ge(this,"onopen",null);Ge(this,"onmessage",null);Ge(this,"onerror",null);this.owner=t,this.options=s;for(const r of["open","message","error"])super.addEventListener(r,o=>{const i=r==="open"?this.onopen:r==="message"?this.onmessage:this.onerror;i==null||i.call(this,o)})}get url(){return this.owner.url}get readyState(){var t;return((t=this.owner.source)==null?void 0:t.readyState)??(this.owner.health.transport==="denied"?2:0)}addEventListener(t,s,r){this.owner.listen(t),super.addEventListener(t,s,r)}close(){this.owner.remove(this)}emit(t){this.dispatchEvent(t instanceof MessageEvent?new MessageEvent(t.type,{data:t.data,origin:t.origin,lastEventId:t.lastEventId}):new Event(t.type))}}class ute{constructor(e,t){Ge(this,"source",null);Ge(this,"health",{transport:"connecting",freshness:"waiting",lastEventAt:null});Ge(this,"subscribers",new Set);Ge(this,"types",new Set(["open","error","message","access","session-config"]));Ge(this,"linked",new Set);Ge(this,"asking",null);Ge(this,"timer");Ge(this,"attempts",0);Ge(this,"generation",0);Ge(this,"retryingGeneration",null);Ge(this,"stopped",!1);Ge(this,"stopFrames",[]);Ge(this,"foreground",()=>{document.visibilityState==="hidden"||this.stopped||this.health.transport==="denied"||(!this.source||this.health.transport!=="open"||this.health.lastEventAt!==null&&Date.now()-this.health.lastEventAt>45e3)&&this.connect()});Ge(this,"identityChanged",()=>this.stop());this.key=e,this.url=t,window.addEventListener("online",this.foreground),document.addEventListener("visibilitychange",this.foreground),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),this.connect()}add(e){const t=new cte(this,e);return this.subscribers.add(t),queueMicrotask(()=>{var s,r;this.subscribers.has(t)&&((s=e.onState)==null||s.call(e,this.health),this.health.transport==="open"?t.emit(new Event("open")):this.health.transport==="denied"&&((r=e.onLost)==null||r.call(e)))}),t}remove(e){this.subscribers.delete(e),this.subscribers.size||this.stop()}listen(e){this.types.add(e),this.link(e)}link(e){const t=this.source,s=this.generation;!t||this.linked.has(e)||(this.linked.add(e),t.addEventListener(e,r=>{if(!(this.stopped||s!==this.generation)){if(e==="open")this.attempts=0,this.setHealth({...this.health,transport:"open"});else if(e==="error"){if(this.retryingGeneration===s)return;this.retryingGeneration=s,this.setHealth({...this.health,transport:"retrying",freshness:"stale"});const o=t.readyState===EventSource.CLOSED;t.close(),this.retry(s,o)}else this.setHealth({transport:"open",freshness:"current",lastEventAt:Date.now()});for(const o of this.subscribers)o.emit(r)}}))}setHealth(e){var t,s;this.health=e;for(const r of this.subscribers)(s=(t=r.options).onState)==null||s.call(t,e)}connect(){var e,t;if(!this.stopped){clearTimeout(this.timer),(e=this.asking)==null||e.abort();for(const s of this.stopFrames)s();(t=this.source)==null||t.close(),this.generation++,this.retryingGeneration=null,this.linked.clear(),this.setHealth({...this.health,transport:"connecting"}),this.source=new EventSource(this.url),this.stopFrames=[NR(this.source),ate(this.source)];for(const s of this.types)this.link(s)}}async retry(e,t){var o,i,l;const s=new AbortController;if(this.asking=s,t)try{const c=await Ce(this.url,{signal:s.signal});if((o=c.body)==null||o.cancel(),this.stopped||e!==this.generation||s.signal.aborted)return;if(c.status===401||c.status===403||cN(c)){this.setHealth({...this.health,transport:"denied",freshness:"stale"});for(const u of this.subscribers)(l=(i=u.options).onLost)==null||l.call(i);return}}catch{if(this.stopped||s.signal.aborted)return}if(this.stopped||e!==this.generation)return;const r=Math.min(3e4,500*2**Math.min(this.attempts++,6))*(.75+Math.random()*.5);this.timer=setTimeout(()=>this.connect(),r)}stop(){var e,t;this.stopped=!0,this.generation++,clearTimeout(this.timer),(e=this.asking)==null||e.abort(),(t=this.source)==null||t.close();for(const s of this.stopFrames)s();window.removeEventListener("online",this.foreground),document.removeEventListener("visibilitychange",this.foreground),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),this.setHealth({...this.health,transport:"closed",freshness:"stale"}),nf.get(this.key)===this&&nf.delete(this.key)}}function nb(n,e={}){const t=Af(n),s=JSON.stringify([cn(),Zn(),t]);let r=nf.get(s);r||(r=new ute(s,t),nf.set(s,r));const o=r.add(e);return{source:o,close:()=>o.close(),state:()=>r.health}}function Vc({className:n,children:e,...t}){return a.jsxs(O$,{"data-slot":"scroll-area",className:G("relative overflow-hidden",n),...t,children:[a.jsx(L$,{"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:e}),a.jsx(dte,{}),a.jsx(M$,{})]})}function dte({className:n,orientation:e="vertical",...t}){return a.jsx(z$,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",n),...t,children:a.jsx(D$,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function rT({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function fte({className:n,...e}){return a.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:G("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function mte({className:n,...e}){return a.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:G("size-5",n),...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function pte({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Pn({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(rT,{className:G(t),...e})}function hte(n){const e=Nn("hostFiles"),[t,s]=y.useState([]),[r,o]=y.useState(!1),i=y.useCallback(async()=>{if(!e||!n){s([]);return}o(!0);try{const l=await Ce(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{o(!1)}},[e,n]);return y.useEffect(()=>{i()},[i]),{scripts:t,loading:r,refresh:i}}const bk=500,gte=5e3;function xte(n){const e=V.c(29),t=n===void 0?!0:n,[s,r]=y.useState("disconnected");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=y.useState(o),c=y.useRef(null);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,e[1]=u):u=e[1];const d=y.useRef(u),f=y.useRef(bk),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(bte);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=F=>{var D;const U=F.type,O=F.id;if(U==="sessions"){l(F.sessions??[]);return}O&&((D=d.current.get(O))==null||D(U,F))},e[2]=g):g=e[2];const x=g;let b,w;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const F=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${tN()}/__pty`},U=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const D=new WebSocket(F());c.current=D,D.onopen=()=>{if(p.current){D.close();return}f.current=bk,r("connected"),D.send(JSON.stringify({type:"list"}))},D.onmessage=B=>{try{const q=JSON.parse(B.data);x(q)}catch{}},D.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const B=f.current;f.current=Math.min(B*2,gte),m.current=setTimeout(()=>h.current(),B)}};return h.current=U,U(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},w=[t,x],e[3]=t,e[4]=b,e[5]=w):(b=e[4],w=e[5]),y.useEffect(b,w);let v;e[6]!==t?(v=F=>{if(!t)return;const U=c.current;U&&U.readyState===WebSocket.OPEN&&U.send(JSON.stringify(F))},e[6]=t,e[7]=v):v=e[7];const j=v;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=(F,U)=>{d.current.set(F,U)},e[8]=k):k=e[8];const _=k;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=F=>{d.current.delete(F)},e[9]=N):N=e[9];const S=N;let C;e[10]!==j?(C=F=>{const U=F===void 0?{}:F,O=`pty_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:O,name:U.name??"Terminal",cwd:U.cwd,metadata:{type:"terminal"}}),O},e[10]=j,e[11]=C):C=e[11];const E=C;let T;e[12]!==j?(T=F=>{const U=`script_${crypto.randomUUID().slice(0,8)}`;return j({type:"spawn",id:U,name:F.name,cwd:F.cwd,args:["run",F.scriptName],command:"bun",metadata:{type:"script",source:F.source,scriptName:F.scriptName}}),U},e[12]=j,e[13]=T):T=e[13];const $=T;let A;e[14]!==j?(A=F=>{j({type:"kill",id:F})},e[14]=j,e[15]=A):A=e[15];const R=A;let P;e[16]!==j?(P=(F,U)=>{j({type:"input",id:F,data:U})},e[16]=j,e[17]=P):P=e[17];const z=P;let L;e[18]!==j?(L=(F,U,O)=>{j({type:"resize",id:F,cols:U,rows:O})},e[18]=j,e[19]=L):L=e[19];const I=L;let M;return e[20]!==R||e[21]!==I||e[22]!==j||e[23]!==i||e[24]!==$||e[25]!==E||e[26]!==s||e[27]!==z?(M={status:s,send:j,subscribe:_,unsubscribe:S,sessions:i,spawnTerminal:E,spawnScript:$,killSession:R,writeInput:z,resize:I},e[20]=R,e[21]=I,e[22]=j,e[23]=i,e[24]=$,e[25]=E,e[26]=s,e[27]=z,e[28]=M):M=e[28],M}function bte(){}const oT=y.createContext(null);function _h(n){const e=V.c(3),{children:t,enabled:s}=n,o=xte(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(oT.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function sb(){const n=y.useContext(oT);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function vte(n){var d;const e=V.c(11),t=sb();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((d=f.metadata)==null?void 0:d.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 r=s;let o;e[2]!==n||e[3]!==t?(o=(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]=o):o=e[4];const i=o;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let u;return e[7]!==i||e[8]!==r||e[9]!==c?(u={runningProcesses:r,runScript:i,stopScript:c},e[7]=i,e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function yte(n){const e=V.c(14),{script:t,status:s,onRun:r,onStop:o}=n,i=s==="running";let l="bg-transparent";i?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=i?o:r,u=i?`Stop ${t.name}`:`Run: ${t.command}`;let d;e[0]!==l?(d=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=d):d=e[1];let f;e[2]!==d?(f=a.jsx("span",{className:d}),e[2]=d,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=a.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]!==i?(p=i?a.jsx(ax,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(Ca,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=i,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==p?(h=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:u,children:[f,m,p]}),e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const wte=y.memo(function(e){const t=V.c(42),{projectDir:s,onProcessStarted:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const[d,f]=y.useState(u),{scripts:m,loading:p}=hte(s),{runningProcesses:h,runScript:g,stopScript:x}=vte(r);let b;if(t[1]!==m||t[2]!==l){const U=l.trim().toLowerCase(),O=U?m.filter(D=>D.name.toLowerCase().includes(U)||D.dirLabel.toLowerCase().includes(U)):m;b=new Map;for(const D of O){const B=b.get(D.dirLabel)??[];B.push(D),b.set(D.dirLabel,B)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let v;if(t[4]!==h){v=new Map;for(const[U,O]of h)v.set(`${O.name}:${O.cwd}`,{id:U,status:O.status});t[4]=h,t[5]=v}else v=t[5];const j=v;if(!s||!p&&m.length===0)return null;let k;t[6]===Symbol.for("react.memo_cache_sentinel")?(k=function(O){f(D=>{const B=new Set(D);return B.has(O)?B.delete(O):B.add(O),B})},t[6]=k):k=t[6];const _=k;let N;t[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=N):N=t[7];let S;t[8]!==p?(S=p&&a.jsx(Pn,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const C=o?"Close script search":"Search scripts";let E,T;t[10]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{i(Ste),c("")},T=a.jsx(ss,{}),t[10]=E,t[11]=T):(E=t[10],T=t[11]);let $;t[12]!==o||t[13]!==C?($=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":C,"aria-expanded":o,onClick:E,children:T}),t[12]=o,t[13]=C,t[14]=$):$=t[14];let A;t[15]!==S||t[16]!==$?(A=a.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[N,S,$]}),t[15]=S,t[16]=$,t[17]=A):A=t[17];let R;t[18]!==o||t[19]!==l?(R=o&&a.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:a.jsx(On,{type:"search",value:l,onChange:U=>c(U.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=o,t[19]=l,t[20]=R):R=t[20];let P;t[21]!==d||t[22]!==w||t[23]!==g||t[24]!==j||t[25]!==l||t[26]!==x?(P=[...w.entries()].map(U=>{const[O,D]=U,B=d.has(O)||!!l,q=D.filter(kte),W=D.filter(jte),H=B?D:q.length>0?q:D.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:O}),H.map(K=>{const Z=j.get(`${K.name}:${K.dir}`);return a.jsx(yte,{script:K,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(K.name,K.dir,K.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${O}:${K.name}`)}),!l&&W.length>0&&a.jsx(Q,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>_(O),children:B?"Show less":`Show ${W.length} more`})]},O)}),t[21]=d,t[22]=w,t[23]=g,t[24]=j,t[25]=l,t[26]=x,t[27]=P):P=t[27];let z;t[28]!==w.size||t[29]!==p||t[30]!==l?(z=!p&&w.size===0&&l&&a.jsx(Ln,{className:"gap-1 p-3",children:a.jsxs(Mn,{className:"gap-1",children:[a.jsx(zn,{children:"No matching scripts"}),a.jsx(Dn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=z):z=t[31];let L;t[32]!==P||t[33]!==z?(L=a.jsxs(Vc,{className:"min-h-0 flex-1 px-1 pb-1",children:[P,z]}),t[32]=P,t[33]=z,t[34]=L):L=t[34];let I;t[35]!==R||t[36]!==L||t[37]!==A?(I=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[A,R,L]}),t[35]=R,t[36]=L,t[37]=A,t[38]=I):I=t[38];let M;t[39]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(tn,{orientation:"vertical"}),t[39]=M):M=t[39];let F;return t[40]!==I?(F=a.jsxs(a.Fragment,{children:[I,M]}),t[40]=I,t[41]=F):F=t[41],F});function Ste(n){return!n}function kte(n){return n.isCommon}function jte(n){return!n.isCommon}function iT({className:n,orientation:e="horizontal",...t}){return a.jsx(W$,{"data-slot":"tabs","data-orientation":e,className:G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",n),...t})}const Nte=io("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 aT({className:n,children:e,variant:t="default",...s}){return a.jsxs(U$,{"data-slot":"tabs-list","data-variant":t,className:G(Nte({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(B$,{"data-slot":"tabs-indicator","data-variant":t,className:G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5")})]})}function hl({className:n,...e}){return a.jsx(q$,{"data-slot":"tabs-trigger",className:G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function gl({className:n,...e}){return a.jsx(F$,{"data-slot":"tabs-content",className:G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",n),...e})}const Cte=y.lazy(()=>nt(()=>import("./TerminalOutput-DOX29EmA.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.TerminalOutput})));function _te({process:n}){const[e,t]=y.useState(""),[s,r]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(n.type!=="task"||!n.outputPath)return;t(""),r(!1);const i=nb(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`),l=i.source;return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=GN(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},i.close},[n.id,n.type,n.outputPath]),y.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e]),a.jsx("pre",{ref:o,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||a.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function Ete(n){const e=V.c(34),{process:t,isActive:s,onSelectActive:r,onClose:o,mobile:i}=n,l=t.source??t.name,c=t.id,u=t.name;let d;e[0]!==s||e[1]!==r?(d=()=>{s&&r()},e[0]=s,e[1]=r,e[2]=d):d=e[2];const f=i?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&a.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"&&a.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=a.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=i&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=a.jsx(Fe,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=a.jsxs(hl,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const j=`Close ${t.name}`,k=`Close ${t.name}`;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(Mt,{"data-icon":"inline-start"}),e[25]=_):_=e[25];let N;e[26]!==o||e[27]!==j||e[28]!==k?(N=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs","aria-label":j,title:k,onClick:o,className:"mr-0.5 text-muted-foreground",children:_}),e[26]=o,e[27]=j,e[28]=k,e[29]=N):N=e[29];let S;return e[30]!==l||e[31]!==v||e[32]!==N?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,N]}),e[30]=l,e[31]=v,e[32]=N,e[33]=S):S=e[33],S}const lT=100,cT=600,Tte=200,uT="process-panel-height";function Ate(){try{const n=localStorage.getItem(uT);if(n)return Math.min(cT,Math.max(lT,Number(n)))}catch{}return Tte}const Ite=y.memo(function(e){const t=V.c(89),{processes:s,activeProcessId:r,collapsed:o,onSetActive:i,onRemove:l,onToggleCollapse:c,onRequestTerminal:u,onAddTerminalContext:d,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=sb(),[b,w]=y.useState(Ate),v=y.useRef(null);let j,k;t[0]!==f||t[1]!==x.sessions?(j=()=>{for(const le of x.sessions)le.status==="exited"&&(f==null||f(le.id,"stopped"))},k=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=j,t[3]=k):(j=t[2],k=t[3]),y.useEffect(j,k);let _;t[4]!==l||t[5]!==x?(_=le=>{le.type!=="task"&&x.killSession(le.id),l(le.id)},t[4]=l,t[5]=x,t[6]=_):_=t[6];const N=_;let S;t[7]!==b?(S=le=>{le.preventDefault(),v.current={startY:le.clientY,startH:b},le.target.setPointerCapture(le.pointerId)},t[7]=b,t[8]=S):S=t[8];const C=S;let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E=le=>{if(!v.current)return;const pe=v.current.startY-le.clientY,ge=Math.min(cT,Math.max(lT,v.current.startH+pe));w(ge)},t[9]=E):E=t[9];const T=E;let $;t[10]!==b?($=()=>{if(v.current){v.current=null;try{localStorage.setItem(uT,String(b))}catch{}}},t[10]=b,t[11]=$):$=t[11];const A=$;let R;t[12]!==r||t[13]!==s?(R=r?s.get(r):null,t[12]=r,t[13]=s,t[14]=R):R=t[14];const P=R;let z;t[15]!==s?(z=[...s.values()],t[15]=s,t[16]=z):z=t[16];const L=z;let I;t[17]!==i?(I=le=>{typeof le=="string"&&i(le)},t[17]=i,t[18]=I):I=t[18];let M;t[19]!==P||t[20]!==o||t[21]!==g||t[22]!==C||t[23]!==A?(M=!g&&!o&&P&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:C,onPointerMove:T,onPointerUp:A,onPointerCancel:A}),t[19]=P,t[20]=o,t[21]=g,t[22]=C,t[23]=A,t[24]=M):M=t[24];const F=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let U;t[25]!==F?(U=G("flex shrink-0 items-center border-b bg-card",F),t[25]=F,t[26]=U):U=t[26];const O=o?"Expand terminal panel":"Collapse terminal panel",D=!o;let B;t[27]!==o?(B=o?a.jsx(it,{"data-icon":"inline-start"}):a.jsx(Et,{"data-icon":"inline-start"}),t[27]=o,t[28]=B):B=t[28];const q=g&&"sr-only";let W;t[29]!==q?(W=G(q),t[29]=q,t[30]=W):W=t[30];let H;t[31]!==W?(H=a.jsx("span",{className:W,children:"Terminal"}),t[31]=W,t[32]=H):H=t[32];let K;t[33]!==c||t[34]!==O||t[35]!==D||t[36]!==B||t[37]!==H?(K=a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":O,"aria-expanded":D,children:[B,H]}),t[33]=c,t[34]=O,t[35]=D,t[36]=B,t[37]=H,t[38]=K):K=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",Z),t[39]=Z,t[40]=Y):Y=t[40];let J;t[41]!==r||t[42]!==N||t[43]!==g||t[44]!==i||t[45]!==L?(J=L.map(le=>a.jsx(Ete,{process:le,isActive:le.id===r,onSelectActive:()=>i(le.id),onClose:()=>N(le),mobile:g},le.id)),t[41]=r,t[42]=N,t[43]=g,t[44]=i,t[45]=L,t[46]=J):J=t[46];let ee;t[47]!==Y||t[48]!==J?(ee=a.jsx(aT,{variant:"default","aria-label":"Open processes",className:Y,children:J}),t[47]=Y,t[48]=J,t[49]=ee):ee=t[49];let te;t[50]!==u||t[51]!==m?(te=u&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:u,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:a.jsx(kr,{})}),t[50]=u,t[51]=m,t[52]=te):te=t[52];let se;t[53]!==U||t[54]!==K||t[55]!==ee||t[56]!==te?(se=a.jsxs("div",{className:U,children:[K,ee,te]}),t[53]=U,t[54]=K,t[55]=ee,t[56]=te,t[57]=se):se=t[57];const X=!o,ne=g?"min(36dvh, 260px)":b;let ae;t[58]!==ne?(ae={height:ne},t[58]=ne,t[59]=ae):ae=t[59];let ie;t[60]!==g||t[61]!==p||t[62]!==m?(ie=!g&&a.jsx(wte,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ie):ie=t[63];let re;t[64]!==N||t[65]!==d||t[66]!==u||t[67]!==L?(re=L.map(le=>a.jsx(gl,{value:le.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:le.type==="task"?a.jsx(_te,{process:le}):a.jsx(y.Suspense,{fallback:a.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:a.jsx(Cte,{processId:le.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>N(le),onAddContext:d})})},le.id)),t[64]=N,t[65]=d,t[66]=u,t[67]=L,t[68]=re):re=t[68];let de;t[69]!==P||t[70]!==u||t[71]!==m?(de=!P&&a.jsxs(Ln,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(_a,{})}),a.jsx(zn,{children:"No terminal open"}),a.jsx(Dn,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(_c,{children:a.jsxs(Q,{type:"button",size:"sm",onClick:u,children:[a.jsx(kr,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=P,t[70]=u,t[71]=m,t[72]=de):de=t[72];let ce;t[73]!==re||t[74]!==de?(ce=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[re,de]}),t[73]=re,t[74]=de,t[75]=ce):ce=t[75];let oe;t[76]!==ae||t[77]!==ie||t[78]!==ce?(oe=a.jsx(yn,{children:a.jsxs("div",{className:"flex min-h-0",style:ae,children:[ie,ce]})}),t[76]=ae,t[77]=ie,t[78]=ce,t[79]=oe):oe=t[79];let fe;t[80]!==X||t[81]!==oe?(fe=a.jsx(vn,{open:X,className:"min-h-0",children:oe}),t[80]=X,t[81]=oe,t[82]=fe):fe=t[82];let ue;return t[83]!==r||t[84]!==I||t[85]!==M||t[86]!==se||t[87]!==fe?(ue=a.jsxs(iT,{value:r,onValueChange:I,className:"shrink-0 gap-0 border-t bg-background",children:[M,se,fe]}),t[83]=r,t[84]=I,t[85]=M,t[86]=se,t[87]=fe,t[88]=ue):ue=t[88],ue});function Hc(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.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 Pte=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function $te(n){const e=new Set;for(const t of n.matchAll(Pte)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function Rte(n){var s;const e=V.c(2);let t;if(e[0]!==n){t=new Map;for(let r=0;r<n.length;r++)for(const o of n[r].toolCalls){if(o.name!=="Bash"||!o.input.run_in_background)continue;const i=o.input.command||"",l=o.input.description||"",c=((s=n[r].assistantText)==null?void 0:s.join(" "))||"",u=[i,l,o.result||"",c].join(" "),d=$te(u);if(d.length===0){const p=i.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&d.push(3e3)}const f=(o.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of d)t.set(p,{description:l||i.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function vk(n){var e;return((e=n.preview.split(`
|
|
335
335
|
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function Ote(n){const e=V.c(10),{port:t,isActive:s}=n,r=s?"bg-success":"bg-muted-foreground/40";let o;e[0]!==r?(o=G("inline-block size-1.5 rounded-full",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=a.jsx("span",{className:o}),e[2]=o,e[3]=i):i=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=a.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(Fe,{variant:"secondary",className:"font-mono",children:[i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function dT({cwd:n,turns:e,canStop:t=!1,onToggleServer:s,onServersChanged:r}){const[o,i]=y.useState([]),l=Rte(e),c=y.useRef(l);y.useLayoutEffect(()=>{c.current=l},[l]);const u=y.useCallback(async f=>{const m=p=>{f()&&i(h=>JSON.stringify(h)===JSON.stringify(p)?h:p)};try{const p=await Ce(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(!f())return;if(p.ok){const w=await p.json();if(!f())return;if(w.length>0){m(w);return}}const h=c.current;if(h.size===0){m([]);return}const g=await Ce(`/api/check-ports?ports=${[...h.keys()].join(",")}`);if(!g.ok||!f())return;const x=await g.json(),b=[];for(const[w,v]of h)x[w]&&b.push({id:`port-${w}`,outputPath:v.outputPath,ports:[w],portStatus:{[w]:!0},preview:v.description});m(b)}catch{}},[n]);Oa(n?u:null,1e4);const d=y.useCallback(async f=>{try{await Ce("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:f})}),setTimeout(()=>{i(m=>m.filter(p=>!p.ports.includes(f)))},1500)}catch{}},[]);return y.useEffect(()=>{if(!r)return;const f=o.filter(m=>m.outputPath).map(m=>({id:m.id,outputPath:m.outputPath,title:vk(m)}));r(f)},[o,r]),o.length===0?null:a.jsxs("section",{children:[a.jsxs(Hc,{children:["Active Servers (",o.length,")"]}),a.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(f=>{const m=f.ports.filter(h=>f.portStatus[h]),p=vk(f);return a.jsxs("div",{className:"border-b border-border px-2 py-2 last:border-b-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(cx,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:p})]}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[f.ports.map(h=>a.jsx(Ote,{port:h,isActive:f.portStatus[h]},h)),a.jsx("div",{className:"flex-1"}),f.outputPath&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>s==null?void 0:s(f.id,f.outputPath,p),title:"View server output","aria-label":"View server output",children:a.jsx(_a,{"data-icon":"inline-start"})}),t&&m.length>0&&a.jsxs(Q,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>m.forEach(h=>d(h)),title:"Stop server","aria-label":"Stop server",children:[a.jsx(ax,{"data-icon":"inline-start",className:"fill-current"}),a.jsx("span",{children:"Stop"})]})]})]},f.id)})})]})}function rb(n){const e=V.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=a.jsx(V$,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function Lte(n){const e=V.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=a.jsx(H$,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Mte(n){const e=V.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=a.jsx(nx,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function zte(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 isolate z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(sx,{"data-slot":"alert-dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ob(n){const e=V.c(11);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(zte,{}),e[4]=i):i=e[4];let l;e[5]!==t?(l=G("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-4 text-popover-foreground shadow-lg duration-150 ease-out outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l?(c=a.jsxs(Mte,{children:[i,a.jsx(Q1,{"data-slot":"alert-dialog-content","data-size":o,className:l,...s})]}),e[7]=s,e[8]=o,e[9]=l,e[10]=c):c=e[10],c}function ib(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ab(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Dte(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-media",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function lb(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ex,{"data-slot":"alert-dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function cb(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(tx,{"data-slot":"alert-dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ub(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Q,{"data-slot":"alert-dialog-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function db(n){const e=V.c(14);let t,s,r,o;e[0]!==n?({className:t,variant:r,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=r===void 0?"outline":r,l=o===void 0?"default":o;let c;e[5]!==t?(c=G(t),e[5]=t,e[6]=c):c=e[6];let u;e[7]!==l||e[8]!==i?(u=a.jsx(Q,{variant:i,size:l}),e[7]=l,e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==s||e[11]!==c||e[12]!==u?(d=a.jsx(bc,{"data-slot":"alert-dialog-cancel",className:c,render:u,...s}),e[10]=s,e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function fT(n){const e=V.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 r;e[3]!==t?(r=G("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-90 group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary bg-background 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",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(G$,{"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:a.jsx(nn,{})}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(K$,{"data-slot":"checkbox",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}const Fte={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},Ute={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 Bte({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:r}){var f,m;const o=y.useRef(n),[i,l]=y.useState({key:"",selected:!1});y.useEffect(()=>{n&&(o.current=n)},[n]);const c=n??o.current;if(!c)return null;const u=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,d=i.key===u&&i.selected;return a.jsx(rb,{open:n!==null,onOpenChange:p=>{p||r()},onOpenChangeComplete:p=>{p||(o.current=null,l({key:"",selected:!1}))},children:a.jsxs(ob,{children:[a.jsxs(ib,{children:[a.jsx(Dte,{children:a.jsx(er,{className:"text-warning"})}),a.jsx(lb,{children:Fte[c.type]}),a.jsx(cb,{children:c.nativeRewind?d?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":Ute[c.type]})]}),a.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.turnCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.fileCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Operations"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.operationCount})]}),c.summary.filePaths.length>0&&a.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=>a.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:p},p))}),((m=c.nativeRewind)==null?void 0:m.filesAvailable)&&a.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[a.jsx(fT,{checked:d,disabled:e,onCheckedChange:p=>l({key:u,selected:p===!0})}),"Restore captured file changes"]})]}),t&&a.jsx(kt,{variant:"destructive",children:a.jsx(_t,{children:t})}),a.jsxs(ab,{children:[a.jsx(db,{onClick:r,disabled:e,children:"Cancel"}),a.jsx(ub,{onClick:()=>s(d),disabled:e,children:e?a.jsxs(a.Fragment,{children:[a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Ds(n){const e=V.c(10);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]!==t?(i=G("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==o||e[8]!==i?(l=a.jsx("div",{"data-slot":"card","data-size":o,className:i,...s}),e[6]=s,e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function xr(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function br(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function vr(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Wte(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Fs(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("px-4 group-data-[size=sm]/card:px-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function um(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ko(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto bg-background 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]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"input-group",role:"group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const qte=io("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 Ar(n){const e=V.c(11);let t,s,r;e[0]!==n?({className:t,align:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"inline-start":r;let i;e[4]!==o||e[5]!==t?(i=G(qte({align:o}),t),e[4]=o,e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":o,className:i,onClick:Vte,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function Vte(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const Hte=io("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 dm(n){const e=V.c(15);let t,s,r,o,i;e[0]!==n?({className:t,type:r,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=r===void 0?"button":r,c=o===void 0?"ghost":o,u=i===void 0?"xs":i;let d;e[6]!==t||e[7]!==u?(d=G(Hte({size:u}),t),e[6]=t,e[7]=u,e[8]=d):d=e[8];let f;return e[9]!==s||e[10]!==u||e[11]!==d||e[12]!==l||e[13]!==c?(f=a.jsx(Q,{type:l,"data-size":u,variant:c,className:d,...s}),e[9]=s,e[10]=u,e[11]=d,e[12]=l,e[13]=c,e[14]=f):f=e[14],f}function Go(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(On,{"data-slot":"input-group-control",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Kte(){const[n,e]=y.useState("idle"),[t,s]=y.useState(null),r=y.useRef(void 0),o=y.useCallback(async u=>{if(!u.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await Ce(`/api/config/validate?path=${encodeURIComponent(u)}`)).json();f.valid?(e("valid"),s(null)):(e("invalid"),s(f.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),i=y.useCallback(u=>{clearTimeout(r.current),r.current=setTimeout(()=>o(u),400)},[o]),l=y.useCallback(()=>{e("idle"),s(null),clearTimeout(r.current)},[]),c=y.useCallback(async(u,d)=>{try{const f=await Ce("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:u,...d})}),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(r.current),[]),{status:n,error:t,debouncedValidate:i,validate:o,reset:l,save:c}}const Bi=aR(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),mT=Sc().filter(n=>n.cli.homeIsDiscoverable&&!n.cli.requiresConfiguration);function pT(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function hT(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.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 Gte=pT(mT.map(n=>n.displayName)),Zte=pT(mT.map(n=>a.jsx(hT,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),Yte=`~/${Bi.cli.homeDirName}`;function Xte(n){const e=V.c(46),{onConfigured:t}=n,[s,r]=y.useState(""),[o,i]=y.useState(!1),{status:l,error:c,debouncedValidate:u,save:d}=Kte();let f;e[0]!==u?(f=M=>{const F=M.target.value;r(F),u(F)},e[0]=u,e[1]=f):f=e[1];const m=f;let p;e[2]!==t||e[3]!==s||e[4]!==d?(p=async()=>{i(!0);const M=await d(s);M.success&&M.claudeDir&&t(M.claudeDir),i(!1)},e[2]=t,e[3]=s,e[4]=d,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==o||e[8]!==l?(g=M=>{M.preventDefault(),l==="valid"&&!o&&h()},e[6]=h,e[7]=o,e[8]=l,e[9]=g):g=e[9];let x,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(ix,{className:"size-4"})}),b=a.jsx(br,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(xr,{children:[x,b,a.jsxs(vr,{children:["Cogpit detects ",Gte," automatically. Existing histories live in"," ",Zte,"."," ","For ",Bi.displayName,", enter its data directory, usually"," ",a.jsx(hT,{children:Yte}),"."]})]}),e[12]=w):w=e[12];const v=l==="invalid";let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsxs(mn,{htmlFor:"agent-data-directory",children:[Bi.displayName," data directory"]}),e[13]=j):j=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(Ar,{children:a.jsx(Yr,{"aria-hidden":"true"})}),e[14]=k):k=e[14];const _=l==="invalid";let N;e[15]!==m||e[16]!==s||e[17]!==_?(N=a.jsxs(Ko,{children:[k,a.jsx(Go,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${Bi.cli.homeDirName}`,autoFocus:!0,"aria-invalid":_,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=_,e[18]=N):N=e[18];let S;e[19]!==l?(S=l==="validating"&&a.jsxs(aa,{className:"flex items-center gap-2",children:[a.jsx(Pn,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=S):S=e[20];let C;e[21]!==l?(C=l==="valid"&&a.jsxs(aa,{className:"flex items-center gap-2 text-success",children:[a.jsx(wf,{className:"size-4"}),Bi.displayName," history found"]}),e[21]=l,e[22]=C):C=e[22];let E;e[23]!==c||e[24]!==l?(E=l==="invalid"&&c&&a.jsxs(Eo,{className:"flex items-center gap-2",children:[a.jsx(Bo,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=E):E=e[25];let T;e[26]!==S||e[27]!==C||e[28]!==E?(T=a.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[S,C,E]}),e[26]=S,e[27]=C,e[28]=E,e[29]=T):T=e[29];let $;e[30]!==N||e[31]!==T||e[32]!==v?($=a.jsx(Fs,{children:a.jsx(Aa,{children:a.jsxs(fn,{"data-invalid":v,children:[j,N,T]})})}),e[30]=N,e[31]=T,e[32]=v,e[33]=$):$=e[33];const A=l!=="valid"||o;let R;e[34]!==o?(R=o&&a.jsx(Pn,{"data-icon":"inline-start"}),e[34]=o,e[35]=R):R=e[35];const P=o?"Saving...":`Connect ${Bi.displayName}`;let z;e[36]!==A||e[37]!==R||e[38]!==P?(z=a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:A,children:[R,P]})}),e[36]=A,e[37]=R,e[38]=P,e[39]=z):z=e[39];let L;e[40]!==$||e[41]!==z?(L=a.jsxs(Ds,{children:[w,$,z]}),e[40]=$,e[41]=z,e[42]=L):L=e[42];let I;return e[43]!==L||e[44]!==g?(I=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8 text-foreground",children:a.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:L})}),e[43]=L,e[44]=g,e[45]=I):I=e[45],I}const yk={0:"\0",b:"\b",f:"\f",n:`
|
|
336
336
|
`,r:"\r",t:" ",v:"\v"};function Jte(n){return!!(n&&/[A-Za-z_$]/.test(n))}function sf(n){return!!(n&&/[\w$]/.test(n))}function Ir(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",r=e+1;for(;r<n.length;){const o=n[r];if(o===t)return{endIndex:r+1,value:s};if(o!=="\\"){s+=o,r++;continue}if(r++,r>=n.length)return null;const i=n[r];if(i in yk){s+=yk[i],r++;continue}if(i===`
|
|
337
337
|
`){r++;continue}if(i==="\r"){r+=n[r+1]===`
|
|
@@ -370,7 +370,7 @@ ${e}`:e)}function $se(n){return typeof n=="string"&&(n==="abort"||n==="binary_as
|
|
|
370
370
|
`),{skipStats:!0}).turns;return s.length!==t.length?null:t.map((r,o)=>({line:r,id:s[o].id}))}function Use(n){return pb(n)?ST(n.input):[n]}function Bse(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 Wse(n,e){const t=n.contentBlocks,s=t.findIndex(r=>r.kind==="tool_calls"&&r.toolCalls.some(o=>o.id===e));return s===-1?!1:t.slice(s+1).some(r=>r.kind==="text"||r.kind==="thinking"||r.kind==="tool_calls")}function qse(n){for(let e=n.toolCalls.length-1;e>=0;e--){const t=n.toolCalls[e];if(!t.asyncQuestion||t.isError)continue;if(t.asyncAnswer!==void 0)return null;const s=t.input.questions;if(s&&s.length>0)return{type:"question",toolUseId:t.id,questions:s}}return null}function Vse(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||Bse(n,s)||t.isError&&Wse(e,t.id))return null;const r=t.input;if(s==="ExitPlanMode")return{type:"plan",allowedPrompts:r.allowedPrompts};const o=r.questions;return o&&o.length>0?{type:"question",toolUseId:t.id,questions:o}:null}function i6(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];return!t||t.toolCalls.length===0?null:Vse(e,t)??qse(t)}function Hse(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
371
371
|
`)}function xm(n,e){return s6(n).parse(n,e)}function Kse(n,e){const t=r6(n.rawMessages),r=(t.kind===QT?s6(e):t).append(n,e);return n.instanceId?oa(r,n.instanceId):r}function Da(n){return n===null?"":typeof n=="string"?n:Hse(n)}function a6(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const l6=/^[a-z]:[\\/]/i;function wb(n){return(l6.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function qk(n){const e=wb(n);return l6.test(n)?e.toLowerCase():e}function Gse(n){const e=wb(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function C1(n,e){const t=qk(n),s=qk(e);if(t===s)return"";const r=t==="/"?"/":`${t}/`;return s.startsWith(r)?wb(e).slice(r.length):null}let Sb=!1;function Zse(n){Sb=n}function kb(){return Sb}let Dl=null;function Yse(n){return Dl=n,()=>{Dl===n&&(Dl=null)}}function Xse(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const r=C1(e,n.path);if(r)return{root:e,file:r,mode:Vk(n),line:n.line}}const t=Gse(n.path),s=C1(t,n.path);return s?{root:t,file:s,mode:Vk(n),line:n.line}:null}function Vk(n){return n.mode==="diff"?"diff":"edit"}function c6(n){return Sb&&Dl!==null&&Dl(n)}function u6(n,e){is(n,e).catch(()=>{})}function cc(n,e={}){if(xt("hostFiles")&&!c6({kind:"file",path:n,...e})){if(qo()){Pf(n);return}u6("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function d6(n){xt("hostFiles")&&(n.path&&c6({kind:"project",path:n.path})||m6("/api/open-in-editor",n))}function f6(n){xt("hostFiles")&&m6("/api/reveal-in-folder",n)}function m6(n,e){!e.path&&!e.dirName||u6(n,{path:e.path||void 0,dirName:e.dirName||void 0})}const Jse=1500;function so(){const n=V.c(5),[e,t]=y.useState(!1),s=y.useRef(null),r=y.useRef(!0);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(r.current=!0,()=>{r.current=!1,s.current&&clearTimeout(s.current)}),i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),y.useEffect(o,i);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async d=>{!await Pf(d)||!r.current||(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),Jse))},n[2]=l):l=n[2];const c=l;let u;return n[3]!==e?(u=[e,c],n[3]=e,n[4]=u):u=n[4],u}function Gc(){const n=V.c(2),[e,t]=y.useState(Qse);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=document.documentElement,i=()=>t(o.classList.contains("dark")),l=new MutationObserver(i);return l.observe(o,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}function Qse(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}let Ih=null;const _1=new Set,Uu=new Map,Hk=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],p6={typescript:()=>nt(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>nt(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>nt(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>nt(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>nt(()=>import("./json-Cp-IABpG.js"),[]),css:()=>nt(()=>import("./css-DPfMkruS.js"),[]),html:()=>nt(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([5,6,7])),python:()=>nt(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>nt(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>nt(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>nt(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>nt(()=>import("./rust-B1yitclQ.js"),[]),go:()=>nt(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>nt(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>nt(()=>import("./sql-BLtJtn59.js"),[]),c:()=>nt(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>nt(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([8,9,10])),java:()=>nt(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>nt(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([11,5,6,7,12,13,10,14,15,16,8,9,17,18])),swift:()=>nt(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>nt(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>nt(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([19,5,6,7,12,13,10,20])),vue:()=>nt(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([21,7,6,14,20,5])),svelte:()=>nt(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([22,6,14,7])),scss:()=>nt(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([23,7]))};function h6(){return Ih||(Ih=(async()=>{const[n,e,...t]=await Promise.all([nt(()=>import("./github-dark-DHJKELXO.js"),[]).then(r=>r.default),nt(()=>import("./github-light-DAi9KRSo.js"),[]).then(r=>r.default),...Hk.map(r=>p6[r]().then(o=>o.default))]),s=await Y8({themes:[n,e],langs:t,engine:X8()});for(const r of Hk)_1.add(r);return s})()),Ih}async function g6(n,e){if(_1.has(e))return;if(Uu.has(e))return Uu.get(e);const t=p6[e];if(!t)return;const s=t().then(async r=>{await n.loadLanguage(r.default),_1.add(e)}).finally(()=>Uu.delete(e));Uu.set(e,s),await s}const ere={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 x6(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return ere[e]??null}async function tre(n,e,t){try{const s=await h6();await g6(s,e);const r=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:r}).tokens}catch{return null}}const nre="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85",jb="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85";function bm(n,e,t){const s=V.c(5),[r,o]=y.useState(null);let i,l;return s[0]!==n||s[1]!==t||s[2]!==e?(i=()=>{if(!e)return;let c=!1;return tre(n,e,t).then(u=>{c||o({code:n,lang:e,isDark:t,tokens:u})}).catch(sre),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=i,s[4]=l):(i=s[3],l=s[4]),y.useEffect(i,l),(r==null?void 0:r.code)===n&&r.lang===e&&r.isDark===t?r.tokens:null}function sre(){}function Nb(n){const e=V.c(13),{lines:t,tokens:s,lineNums:r,variant:o,label:i}=n,l=o==="boxed"?nre:jb;let c;if(e[0]!==r||e[1]!==t||e[2]!==s){let f;e[4]!==r||e[5]!==s?(f=(m,p)=>{const h=s==null?void 0:s[p];return a.jsxs("span",{className:"block",children:[(r==null?void 0:r[p])&&a.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground select-none",children:r[p]}),h?h.map(rre):m||" "]},p)},e[4]=r,e[5]=s,e[6]=f):f=e[6],c=t.map(f),e[0]=r,e[1]=t,e[2]=s,e[3]=c}else c=e[3];let u;e[7]!==i||e[8]!==c?(u=a.jsx("code",{className:"block","aria-label":i,children:c}),e[7]=i,e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==l||e[11]!==u?(d=a.jsx("pre",{tabIndex:0,className:l,children:u}),e[10]=l,e[11]=u,e[12]=d):d=e[12],d}function rre(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}function b6(n){const e=V.c(6),{code:t,language:s,label:r}=n,o=Gc(),i=bm(t,s,o);let l;e[0]!==t?(l=uc(t),e[0]=t,e[1]=l):l=e[1];const c=l;let u;return e[2]!==r||e[3]!==c||e[4]!==i?(u=a.jsx(Nb,{lines:c,tokens:i,variant:"unboxed",label:r}),e[2]=r,e[3]=c,e[4]=i,e[5]=u):u=e[5],u}const ore=/^(\s*\d+)→(.*)$/;function uc(n){return n.split(/\r\n|\r|\n/)}function ire(n){const e=[],t=[];for(const s of uc(n)){const r=s.match(ore);r?(e.push(r[1]),t.push(r[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function are(n){const e=V.c(11),{result:t,filePath:s,variant:r}=n,o=r===void 0?"boxed":r,i=Gc();let l;e[0]!==s?(l=x6(s),e[0]=s,e[1]=l):l=e[1];const c=l;let u;e[2]!==t?(u=ire(t),e[2]=t,e[3]=u):u=e[3];const{lineNums:d,codeLines:f}=u;let m;e[4]!==f?(m=f.join(`
|
|
372
372
|
`),e[4]=f,e[5]=m):m=e[5];const h=bm(m,c,i);let g;return e[6]!==f||e[7]!==d||e[8]!==h||e[9]!==o?(g=a.jsx(Nb,{lines:f,tokens:h,lineNums:d,variant:o}),e[6]=f,e[7]=d,e[8]=h,e[9]=o,e[10]=g):g=e[10],g}function v6(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 y6(n){const e=V.c(9),{result:t,alreadyPretty:s,variant:r}=n,o=r===void 0?"boxed":r,i=Gc();let l;e[0]!==s||e[1]!==t?(l=s?t:v6(t)??t,e[0]=s,e[1]=t,e[2]=l):l=e[2];const c=l;let u;e[3]!==c?(u=uc(c),e[3]=c,e[4]=u):u=e[4];const d=u,f=bm(c,"json",i);let m;return e[5]!==d||e[6]!==f||e[7]!==o?(m=a.jsx(Nb,{lines:d,tokens:f,variant:o}),e[5]=d,e[6]=f,e[7]=o,e[8]=m):m=e[8],m}function lre(n){const e=uc(n),t=e.slice(0,8).join(`
|
|
373
|
-
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-uc(s).length),truncated:e.length>8||t.length>1e3}}function w6(n){const e=V.c(37),{result:t,isError:s,filePath:r,renderResult:o}=n,i=s===void 0?!1:s,[l,c]=y.useState(!1),[u,d]=so(),f=y.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?v6(t):null,e[0]=r,e[1]=i,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=lre(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,w=i&&"text-destructive";let v;e[6]!==w?(v=G("text-xs text-muted-foreground",w),e[6]=w,e[7]=v):v=e[7];const j=i?"Error":"Result";let k;e[8]!==v||e[9]!==j?(k=a.jsx("span",{className:v,children:j}),e[8]=v,e[9]=j,e[10]=k):k=e[10];let _;e[11]!==u||e[12]!==d||e[13]!==t?(_=t.trim()&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(nn,{"data-icon":"icon"}):a.jsx(Es,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==r||e[19]!==i||e[20]!==p||e[21]!==o||e[22]!==t||e[23]!==b?(S=t.trim()?o?o(b):r&&!i?a.jsx(are,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(y6,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:G(jb,i&&"border-destructive/30 text-destructive"),children:b}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=r,e[19]=i,e[20]=p,e[21]=o,e[22]=t,e[23]=b,e[24]=S):S=e[24];let C;e[25]!==f||e[26]!==S?(C=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=C):C=e[27];let E;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(E=x.truncated&&a.jsx(Q,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(cre),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=E):E=e[32];let T;return e[33]!==C||e[34]!==E||e[35]!==N?(T=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[N,C,E]}),e[33]=C,e[34]=E,e[35]=N,e[36]=T):T=e[36],T}function cre(n){return!n}const ure={"cogpit-status":"status","cogpit-decisions":"decisions","cogpit-checklist":"checklist"};function dre(n){return n&&ure[n.toLowerCase()]||null}const S6=y.createContext(null),fre=y.lazy(()=>nt(()=>import("./CogpitBlock-
|
|
373
|
+
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-uc(s).length),truncated:e.length>8||t.length>1e3}}function w6(n){const e=V.c(37),{result:t,isError:s,filePath:r,renderResult:o}=n,i=s===void 0?!1:s,[l,c]=y.useState(!1),[u,d]=so(),f=y.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?v6(t):null,e[0]=r,e[1]=i,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=lre(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,w=i&&"text-destructive";let v;e[6]!==w?(v=G("text-xs text-muted-foreground",w),e[6]=w,e[7]=v):v=e[7];const j=i?"Error":"Result";let k;e[8]!==v||e[9]!==j?(k=a.jsx("span",{className:v,children:j}),e[8]=v,e[9]=j,e[10]=k):k=e[10];let _;e[11]!==u||e[12]!==d||e[13]!==t?(_=t.trim()&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(nn,{"data-icon":"icon"}):a.jsx(Es,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==r||e[19]!==i||e[20]!==p||e[21]!==o||e[22]!==t||e[23]!==b?(S=t.trim()?o?o(b):r&&!i?a.jsx(are,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(y6,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:G(jb,i&&"border-destructive/30 text-destructive"),children:b}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=r,e[19]=i,e[20]=p,e[21]=o,e[22]=t,e[23]=b,e[24]=S):S=e[24];let C;e[25]!==f||e[26]!==S?(C=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=C):C=e[27];let E;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(E=x.truncated&&a.jsx(Q,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(cre),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=E):E=e[32];let T;return e[33]!==C||e[34]!==E||e[35]!==N?(T=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[N,C,E]}),e[33]=C,e[34]=E,e[35]=N,e[36]=T):T=e[36],T}function cre(n){return!n}const ure={"cogpit-status":"status","cogpit-decisions":"decisions","cogpit-checklist":"checklist"};function dre(n){return n&&ure[n.toLowerCase()]||null}const S6=y.createContext(null),fre=y.lazy(()=>nt(()=>import("./CogpitBlock-ZgOubpsS.js"),__vite__mapDeps([24,1,2,3,4]))),mre={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 pre(n){return mre[n.toLowerCase()]??n}function hre(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function gre(n){const e=V.c(9),{text:t}=n,[s,r]=so();let o;e[0]!==r||e[1]!==t?(o=()=>r(t),e[0]=r,e[1]=t,e[2]=o):o=e[2];const i=s?"Copied":"Copy code";let l;e[3]!==s?(l=s?a.jsxs(a.Fragment,{children:[a.jsx(nn,{className:"text-success","data-icon":"inline-start"}),a.jsx("span",{className:"text-success",children:"Copied"})]}):a.jsx(Es,{"data-icon":"icon"}),e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==o||e[6]!==i||e[7]!==l?(c=a.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:o,className:"text-muted-foreground",title:"Copy code","aria-label":i,children:l}),e[5]=o,e[6]=i,e[7]=l,e[8]=c):c=e[8],c}function xre(n){const e=V.c(2),{num:t}=n;let s;return e[0]!==t?(s=a.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 Cb(n){var b,w,v;const e=V.c(33);let t,s,r,o;e[0]!==n?({children:s,className:r,node:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=y.useContext(S6),l=!r&&typeof s=="string"&&!s.includes(`
|
|
374
374
|
`);let c;e[5]!==r?(c=hre(r),e[5]=r,e[6]=c):c=e[6];const u=c,d=String(s);let f;if(e[7]!==d){let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=/\n$/,e[9]=j):j=e[9],f=d.replace(j,""),e[7]=d,e[8]=f}else f=e[8];const m=f;if(l){let j;return e[10]!==s||e[11]!==o?(j=a.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:s}),e[10]=s,e[11]=o,e[12]=j):j=e[12],j}let p;e[13]!==m||e[14]!==u||e[15]!==o?(p=a.jsx(bre,{code:m,lang:u,...o}),e[13]=m,e[14]=u,e[15]=o,e[16]=p):p=e[16];const h=p;if(i&&u&&FC(u)){const j=`${i.messageKey}:${((b=t==null?void 0:t.position)==null?void 0:b.start.offset)??0}`;let k;return e[17]!==m||e[18]!==u||e[19]!==h||e[20]!==j?(k=a.jsx(nee,{language:u,source:m,instanceKey:j,fallback:h}),e[17]=m,e[18]=u,e[19]=h,e[20]=j,e[21]=k):k=e[21],k}let g;e[22]!==i||e[23]!==u?(g=i?dre(u):null,e[22]=i,e[23]=u,e[24]=g):g=e[24];const x=g;if(x){const j=String(((w=t==null?void 0:t.position)==null?void 0:w.start.offset)??((v=t==null?void 0:t.position)==null?void 0:v.start.line)??0);let k;e[25]!==x||e[26]!==m||e[27]!==h||e[28]!==j?(k=a.jsx(fre,{kind:x,source:m,occurrence:j,fallback:h}),e[25]=x,e[26]=m,e[27]=h,e[28]=j,e[29]=k):k=e[29];let _;return e[30]!==h||e[31]!==k?(_=a.jsx(y.Suspense,{fallback:h,children:k}),e[30]=h,e[31]=k,e[32]=_):_=e[32],_}return h}function bre(n){const e=V.c(39);let t,s,r;e[0]!==n?({code:t,lang:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=Gc(),i=bm(t,s,o),[l,c]=y.useState(!1);let u,d,f,m;if(e[4]!==t||e[5]!==l||e[6]!==s||e[7]!==r||e[8]!==i){const g=t.split(`
|
|
375
375
|
`);u=g.length;const x=u>30,b=l?it:Et;d="my-3 overflow-hidden rounded-lg border border-border bg-muted";let w;e[13]!==b||e[14]!==l||e[15]!==x?(w=x&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>c(!l),className:"text-muted-foreground","aria-label":l?"Expand code":"Collapse code",children:a.jsx(b,{"data-icon":"icon"})}),e[13]=b,e[14]=l,e[15]=x,e[16]=w):w=e[16];let v;e[17]!==s?(v=s&&a.jsx(Fe,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:pre(s)}),e[17]=s,e[18]=v):v=e[18];let j;e[19]!==x||e[20]!==u?(j=x&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[19]=x,e[20]=u,e[21]=j):j=e[21];let k;e[22]!==w||e[23]!==v||e[24]!==j?(k=a.jsxs("div",{className:"flex items-center gap-2",children:[w,v,j]}),e[22]=w,e[23]=v,e[24]=j,e[25]=k):k=e[25];let _;e[26]!==t?(_=a.jsx(gre,{text:t}),e[26]=t,e[27]=_):_=e[27],e[28]!==k||e[29]!==_?(f=a.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted px-3 py-1.5",children:[k,_]}),e[28]=k,e[29]=_,e[30]=f):f=e[30],m=!l&&a.jsx("div",{className:"overflow-x-auto",children:a.jsx("pre",{className:"m-0 p-3 font-mono text-xs leading-relaxed",children:a.jsx("code",{className:G("block",!i&&"text-foreground/90"),...r,children:g.map((N,S)=>{const C=i==null?void 0:i[S];return a.jsxs("span",{className:"block",children:[a.jsx(xre,{num:S+1}),C?C.map(vre):N||" "]},S)})})})}),e[4]=t,e[5]=l,e[6]=s,e[7]=r,e[8]=i,e[9]=u,e[10]=d,e[11]=f,e[12]=m}else u=e[9],d=e[10],f=e[11],m=e[12];let p;e[31]!==l||e[32]!==u?(p=l&&a.jsxs(Q,{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 ${u} lines of code`,children:["Show ",u," lines..."]}),e[31]=l,e[32]=u,e[33]=p):p=e[33];let h;return e[34]!==d||e[35]!==f||e[36]!==m||e[37]!==p?(h=a.jsxs("div",{className:d,children:[f,m,p]}),e[34]=d,e[35]=f,e[36]=m,e[37]=p,e[38]=h):h=e[38],h}function vre(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}var li=function(n,e){return Number(n.toFixed(e))},yre=function(n,e){return e},gt=function(n,e,t){t&&typeof t=="function"&&t(n,e)},wre=function(n){return-Math.cos(n*Math.PI)/2+.5},Sre=function(n){return n},kre=function(n){return n*n},jre=function(n){return n*(2-n)},Nre=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},Cre=function(n){return n*n*n},_re=function(n){return--n*n*n+1},Ere=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},Tre=function(n){return n*n*n*n},Are=function(n){return 1- --n*n*n*n},Ire=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},Pre=function(n){return n*n*n*n*n},$re=function(n){return 1+--n*n*n*n*n},Rre=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},k6={easeOut:wre,linear:Sre,easeInQuad:kre,easeOutQuad:jre,easeInOutQuad:Nre,easeInCubic:Cre,easeOutCubic:_re,easeInOutCubic:Ere,easeInQuart:Tre,easeOutQuart:Are,easeInOutQuart:Ire,easeInQuint:Pre,easeOutQuint:$re,easeInOutQuint:Rre},j6=function(n){typeof n=="number"&&cancelAnimationFrame(n)},Us=function(n){n.mounted&&(j6(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function N6(n,e,t,s){if(n.mounted){var r=new Date().getTime(),o=1;Us(n),n.animation=function(){if(!n.mounted)return j6(n.animation);var i=new Date().getTime()-r,l=i/t,c=k6[e],u=c(l);i>=t?(s(o),n.animation=null):n.animation&&(s(u),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function Ore(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function Zo(n,e,t,s){var r=Ore(e);if(!(!n.mounted||!r)){var o=n.setState,i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=e.scale-l,f=e.positionX-c,m=e.positionY-u;t===0?o(e.scale,e.positionX,e.positionY):N6(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+d*p,g=c+f*p,x=u+m*p;o(h,g,x)})}}function Lre(n,e,t){var s=n.offsetWidth,r=n.offsetHeight,o=e.offsetWidth,i=e.offsetHeight,l=o*t,c=i*t,u=s-l,d=r-c;return{wrapperWidth:s,wrapperHeight:r,newContentWidth:l,newDiffWidth:u,newContentHeight:c,newDiffHeight:d}}var Mre=function(n,e,t,s,r,o,i){var l=n>e?t*(i?.5:1):0,c=s>r?o*(i?.5:1):0,u=n-e-l,d=l,f=s-r-c,m=c;return{minPositionX:u,maxPositionX:d,minPositionY:f,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},_b=function(n,e){var t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.centerZoomedOut,i=r.disablePadding;if(!t||!s)throw new Error("Components are not mounted");var l=Lre(t,s,e),c=l.wrapperWidth,u=l.wrapperHeight,d=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=Mre(c,d,m,u,f,p,!!o),g=c>=d&&u>=f;i&&g&&!o&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,b=x.minPositionX,w=x.maxPositionX,v=x.minPositionY,j=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),w!=null&&(h.maxPositionX=w*e),v!=null&&(h.minPositionY=u*(1-e)+v*e),j!=null&&(h.maxPositionY=j*e),h},dc=function(n,e,t,s){return s?n<e?li(e,2):n>t?li(t,2):li(n,2):li(n,2)},xa=function(n,e){var t=_b(n,e);return n.bounds=t,t};function Zc(n,e,t,s,r,o,i){var l=t.minPositionX,c=t.minPositionY,u=t.maxPositionX,d=t.maxPositionY,f=0,m=0;i&&(f=r,m=o);var p=dc(n,l-f,u+f,s),h=dc(e,c-m,d+m,s);return{x:p,y:h}}function vm(n,e,t,s,r,o){var i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:u};var f=c-e*d,m=u-t*d,p=Zc(f,m,r,o,0,0,null);return p}var Kk=1e-7;function Yc(n,e,t,s,r){var o=r?s:0,i=Math.max(e-o,Kk),l=t+o;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=i?i:Math.max(n,Kk)}var Gk=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,r=n.wrapperComponent,o=e.target,i="shadowRoot"in o&&"composedPath"in e,l=i?e.composedPath().some(function(d){return d instanceof Element?r==null?void 0:r.contains(d):!1}):r==null?void 0:r.contains(o),c=s&&o&&l;if(!c)return!1;var u=Xc(o,t);return!(u||o.getAttribute("draggable")==="true"||o.getAttribute("contenteditable")==="true"||o.isContentEditable)},Zk=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,r=s.panning.disabled,o=e&&t&&!r;return!!o},zre=function(n,e){var t=n.state,s=t.positionX,r=t.positionY;n.isPanning=!0;var o=e.clientX,i=e.clientY;n.startCoords={x:o-s,y:i-r}},Dre=function(n,e){var t=e.touches,s=n.state,r=s.positionX,o=s.positionY;n.isPanning=!0;var i=t.length===1;if(i){var l=t[0].clientX,c=t[0].clientY;n.startCoords={x:l-r,y:c-o}}};function Fre(n){var e=n.state,t=e.positionX,s=e.positionY,r=e.scale,o=n.setup,i=o.disabled,l=o.limitToBounds,c=o.centerZoomedOut,u=n.wrapperComponent;if(!(i||!u||!n.bounds)){var d=n.bounds,f=d.maxPositionX,m=d.minPositionX,p=d.maxPositionY,h=d.minPositionY,g=t>f||t<m,x=s>p||s<h,b=t>f?u.offsetWidth:n.setup.minPositionX||0,w=s>p?u.offsetHeight:n.setup.minPositionY||0,v=vm(n,b,w,r,n.bounds,l||c),j=v.x,k=v.y;return{scale:r,positionX:g?j:t,positionY:x?k:s}}}function C6(n,e,t,s,r){var o=n.setup.limitToBounds,i=n.wrapperComponent,l=n.bounds,c=n.state,u=c.scale,d=c.positionX,f=c.positionY;if(!(i===null||l===null||e===d&&t===f)){var m=Zc(e,t,l,o,s,r,i),p=m.x,h=m.y;n.setState(u,p,h)}}var Ure=function(n,e,t){var s=n.startCoords,r=n.state,o=n.setup.panning,i=o.lockAxisX,l=o.lockAxisY,c=r.positionX,u=r.positionY;if(!s)return{x:c,y:u};var d=e-s.x,f=t-s.y,m=i?c:d,p=l?u:f;return{x:m,y:p}},Fo=function(n,e,t){var s=n.setup,r=n.state,o=s.minScale,i=s.disablePadding,l=s.centerZoomedOut,c=t??r.scale;return e>0&&c>=o&&!i&&!l?e:0},No;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(No||(No={}));var Bre=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=r.limitToBounds,c=n.state.scale,u=i.disabled;if(u||o||!e||!t||!s)return!1;if(!l)return!0;var d=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return d},Wre=function(n){var e=n.mounted,t=n.velocity,s=n.bounds,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=i.disabled,c=!l&&!o&&e;return!(!c||!t||!s)};function qre(n,e){var t=n.setup.velocityAnimation,s=t.animationTime,r=t.maxAnimationTime,o=t.inertia;return Math.min(s*Math.max(1,Math.abs(e/o)),r)}function Yk(n,e,t,s,r,o,i,l,c,u){if(r){if(e>i&&t>i){var d=i+(n-i)*u;return d>c?c:d<i?i:d}if(e<o&&t<o){var d=o+(n-o)*u;return d<l?l:d>o?o:d}}return s?e:dc(n,o,i,r)}function Vre(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Ph=function(n,e,t){var s=0,r=n*t;return Number.isNaN(r)?s:n<0?Math.max(r,-e):Math.min(r,e)};function Hre(n,e,t){var s,r,o=Bre(n);if(o){var i=n.lastMousePosition,l=n.velocityTime,c=n.setup,u=n.wrapperComponent,d=c.velocityAnimation,f=d.maxStrengthMouse,m=d.maxStrengthTouch,p=d.sensitivityTouch,h=d.sensitivityMouse,g=Date.now();if(i&&l&&u){var x=Vre(u),b=(s={},s[No.TOUCH]=p,s[No.MOUSE]=h,s)[t],w=(r={},r[No.TOUCH]=m,r[No.MOUSE]=f,r)[t],v=e.x-i.x,j=e.y-i.y,k=Ph(v/x,w,b),_=Ph(j/x,w,b),N=g-l,S=v*v+j*j,C=Ph(Math.sqrt(S)/N,w,b);n.velocity={velocityX:k,velocityY:_,total:C}}n.lastMousePosition=e,n.velocityTime=g}}function Kre(n){var e=n.velocity,t=n.bounds,s=n.setup,r=n.wrapperComponent,o=Wre(n);if(!(!o||!e||!t||!r)){var i=e.velocityX,l=e.velocityY,c=e.total,u=t.maxPositionX,d=t.minPositionX,f=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,b=x.lockAxisY,w=x.lockAxisX,v=g.animationType,j=h.sizeX,k=h.sizeY,_=h.velocityAlignmentTime,N=_,S=qre(n,c),C=Math.max(S,N),E=Fo(n,j),T=Fo(n,k),$=E*r.offsetWidth/100,A=T*r.offsetHeight/100,R=u+$,P=d-$,z=f+A,L=m-A,I=n.state,M=new Date().getTime();N6(n,v,C,function(F){var U=n.state,O=U.scale,D=U.positionX,B=U.positionY,q=new Date().getTime()-M,W=q/N,H=k6[h.animationType],K=1-H(Math.min(1,W)),Z=1-F,Y=D+i*Z,J=B+l*Z,ee=Yk(Y,I.positionX,D,w,p,d,u,P,R,K),te=Yk(J,I.positionY,B,b,p,m,f,L,z,K);if(D!==Y||B!==J){n.setState(O,ee,te);var se=n.props.onPanning;se&&se(pt(n),{})}})}}function Xk(n,e){var t=n.state,s=t.scale,r=t.positionX,o=t.positionY;n.panStartPosition={x:r,y:o},Us(n),xa(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?Dre(n,e):zre(n,e)}function _6(n,e){var t=n.state.scale,s=n.setup,r=s.minScale,o=s.autoAlignment,i=o.disabled,l=o.sizeX,c=o.sizeY,u=o.animationTime,d=o.animationType,f=i||t<r||!l&&!c;if(!f){var m=Fre(n);m&&Zo(n,m,u,d)}}function Jk(n,e,t,s){var r=n.startCoords,o=n.setup,i=o.autoAlignment,l=i.sizeX,c=i.sizeY;if(r){var u=Ure(n,e,t),d=u.x,f=u.y,m=Fo(n,l),p=Fo(n,c);Hre(n,{x:d,y:f},s),C6(n,d,f,m,p)}}function Gre(n,e){if(n.isPanning){var t=n.velocity,s=n.wrapperComponent,r=n.contentComponent;n.isPanning=!1;var o=n.state,i=o.positionX,l=o.positionY,c=o.scale,u=n.panStartPosition;if(n.panStartPosition=null,u){var d=i-u.x,f=l-u.y;if(d*d+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=((r==null?void 0:r.offsetWidth)||0)*c,g=((r==null?void 0:r.offsetHeight)||0)*c,x=!n.setup.limitToBounds||m<h||p<g,b=!e&&t&&t.total>.1&&x;b?Kre(n):_6(n)}}function Eb(n,e,t,s){var r=n.setup,o=r.minScale,i=r.maxScale,l=r.limitToBounds,c=Yc(li(e,2),o,i,0,!1),u=xa(n,c),d=vm(n,t,s,c,u,l),f=d.x,m=d.y;return{scale:c,positionX:f,positionY:m}}function Tb(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.minScale,l=o.maxScale,c=o.limitToBounds,u=o.zoomAnimation,d=u.disabled,f=u.animationTime,m=u.animationType,p=s>=i&&s<=l,h=d||p;if((s>=1||c)&&_6(n),!(h||!r||!n.mounted)){var g=e||r.offsetWidth/2,x=t||r.offsetHeight/2,b=s<i?i:l,w=Eb(n,b,g,x);w&&Zo(n,w,f,m)}}var ks=function(){return ks=Object.assign||function(e){for(var t,s=1,r=arguments.length;s<r;s++){t=arguments[s];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ks.apply(this,arguments)};function Qk(n,e,t){for(var s=0,r=e.length,o;s<r;s++)(o||!(s in e))&&(o||(o=Array.prototype.slice.call(e,0,s)),o[s]=e[s]);return n.concat(o||Array.prototype.slice.call(e))}var $h={scale:1,positionX:0,positionY:0},ai={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"}},E1={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},E6=function(n){var e,t,s,r,o,i,l,c,u,d=Math.max((e=n.minScale)!==null&&e!==void 0?e:ai.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:ai.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:$h.scale,p=Math.min(Math.max(m,d),f),h=dc((r=n.initialPositionX)!==null&&r!==void 0?r:$h.positionX,(o=n.minPositionX)!==null&&o!==void 0?o:-1/0,(i=n.maxPositionX)!==null&&i!==void 0?i:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=dc((l=n.initialPositionY)!==null&&l!==void 0?l:$h.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(u=n.maxPositionY)!==null&&u!==void 0?u:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},e3=function(n){var e=ks({},ai);return Object.keys(n).forEach(function(t){var s=t,r=typeof n[s]<"u",o=typeof ai[s]<"u";if(o&&r){var i=Object.prototype.toString.call(ai[s]),l=i==="[object Object]",c=i==="[object Array]";l?e[s]=ks(ks({},ai[s]),n[s]):c?e[s]=Qk(Qk([],ai[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},T6=function(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.maxScale,l=o.minScale,c=o.zoomAnimation,u=o.smooth,d=c.size;if(!r)throw new Error("Wrapper is not mounted");var f=u?s*Math.exp(e*t):s+e*t,m=Yc(li(f,3),l,i,d,!1);return m};function A6(n,e,t,s,r){var o,i,l=n.wrapperComponent,c=n.state,u=c.scale,d=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-d)/u,b=(g/2-f)/u,w=T6(n,e,t),v=Eb(n,w,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var j=n.props,k=j.onZoomStart,_=j.onZoom,N=j.onZoomStop,S=new MouseEvent("mousemove",{bubbles:!0}),C=pt(n);gt(C,S,k),gt(C,S,_),Zo(n,v,p,r);var E=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;E&&E.setTimeout(function(){n.mounted&>(pt(n),S,N)},p)}function I6(n,e,t,s){var r,o,i=n.setup,l=n.wrapperComponent,c=n.contentComponent,u=i.limitToBounds,d=i.centerOnInit,f=E6(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,b=f.positionY;if(d&&c){var w=Ab(f.scale,l,c);x=w.positionX,b=w.positionY}var v=_b(n,f.scale),j=Zc(x,b,v,u,0,0,l),k={scale:f.scale,positionX:j.x,positionY:j.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var _=n.props,N=_.onZoomStart,S=_.onZoom,C=_.onZoomStop,E=new MouseEvent("mousemove",{bubbles:!0}),T=pt(n);gt(T,E,N),gt(T,E,S),Zo(n,k,e,t);var $=(o=(r=l.ownerDocument)===null||r===void 0?void 0:r.defaultView)!==null&&o!==void 0?o:typeof window<"u"?window:null;$&&$.setTimeout(function(){n.mounted&>(pt(n),E,C)},e)}}}function Zre(n,e,t,s){var r=n.getBoundingClientRect(),o=e.getBoundingClientRect(),i=t.getBoundingClientRect(),l=o.x*s.scale,c=o.y*s.scale;return{x:(r.x-i.x+l)/s.scale,y:(r.y-i.y+c)/s.scale}}function Yre(n,e,t,s,r){s===void 0&&(s=0),r===void 0&&(r=0);var o=n.wrapperComponent,i=n.contentComponent,l=n.state,c=n.setup,u=c.limitToBounds,d=c.minScale,f=c.maxScale;if(!o||!i)return l;var m=o.getBoundingClientRect(),p=e.getBoundingClientRect(),h=Zre(e,o,i,l),g=h.x,x=h.y,b=p.width/l.scale,w=p.height/l.scale,v=o.offsetWidth/b,j=o.offsetHeight/w,k=Yc(t||Math.min(v,j),d,f,0,!1),_=(m.width-b*k)/2,N=(m.height-w*k)/2,S=(m.left-g)*k+_+s,C=(m.top-x)*k+N+r,E=_b(n,k),T=Zc(S,C,E,u,0,0,o),$=T.x,A=T.y;return{positionX:$,positionY:A,scale:k}}var Xre=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),A6(n,1,e,t,s)}},Jre=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),A6(n,-1,e,t,s)}},Qre=function(n){return function(e,t,s,r,o){r===void 0&&(r=300),o===void 0&&(o="easeOut");var i=n.state,l=i.positionX,c=i.positionY,u=i.scale,d=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!d||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?u:s};Zo(n,p,r,o)}}},eoe=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),I6(n,e,t)}},toe=function(n){return function(e,t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut");var r=n.state,o=n.wrapperComponent,i=n.contentComponent;if(o&&i){var l=Ab(e||r.scale,o,i);Zo(n,l,t,s)}}},noe=function(n){return function(e,t,s,r,o,i){s===void 0&&(s=600),r===void 0&&(r="easeOut"),o===void 0&&(o=0),i===void 0&&(i=0),Us(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var u=Yre(n,c,t,o,i);Zo(n,u,s,r)}}},T1=function(n){return{instance:n,state:n.state,zoomIn:Xre(n),zoomOut:Jre(n),setTransform:Qre(n),resetTransform:eoe(n),centerView:toe(n),zoomToElement:noe(n)}},soe=function(n){return{instance:n,state:n.state}},pt=function(n){var e={};return Object.assign(e,soe(n)),Object.assign(e,T1(n)),e},Rh=!1;function Oh(){try{var n={get passive(){return Rh=!0,!1}};return n}catch{return Rh=!1,Rh}}var Bu=".".concat(E1.wrapperClass),Xc=function(n,e){return e.some(function(t){return n.matches("".concat(Bu," ").concat(t,", ").concat(Bu," .").concat(t,", ").concat(Bu," ").concat(t," *, ").concat(Bu," .").concat(t," *"))})},fc=function(n){n&&clearTimeout(n)},roe=function(n){return Number.parseFloat(n.toFixed(8))},P6=function(n,e,t){var s=roe(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},Ab=function(n,e,t){var s=t.offsetWidth*n,r=t.offsetHeight*n,o=(e.offsetWidth-s)/2,i=(e.offsetHeight-r)/2;return{scale:n,positionX:o,positionY:i}};function ooe(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function ioe(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var $6=function(n,e){var t=n.setup.wheel,s=t.disabled,r=t.wheelDisabled,o=t.touchPadDisabled,i=t.excluded,l=n.isInitialized,c=n.isPanning,u=e.target,d=l&&!c&&!s&&u;if(!d||r&&!e.ctrlKey||o&&e.ctrlKey)return!1;var f=Xc(u,i);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},aoe=function(n,e){var t=n.setup,s=t.disabled,r=t.trackPadPanning,o=r.activationKeys,i=r.excluded;if(!n.wrapperComponent||!n.contentComponent||s||r.disabled||e.ctrlKey)return!1;var l=$6(n,e);if(l)return!1;var c=e.target,u=Xc(c,i);if(u)return!1;var d=n.isPressingKeys(o);return!!d},loe=function(n){return n?n.deltaY<0?1:-1:0};function coe(n,e){var t=loe(n),s=yre(e,t);return s}function R6(n,e,t){var s=e.getBoundingClientRect(),r=0,o=0;if("clientX"in n)r=(n.clientX-s.left)/t,o=(n.clientY-s.top)/t;else{var i=n.touches[0];r=(i.clientX-s.left)/t,o=(i.clientY-s.top)/t}return Number.isNaN(r)||Number.isNaN(o)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:r,y:o}}var uoe=function(n,e,t,s,r){var o=n.state.scale,i=n.wrapperComponent,l=n.setup,c=l.maxScale,u=l.minScale,d=l.zoomAnimation,f=l.disablePadding,m=d.size,p=d.disabled;if(!i)throw new Error("Wrapper is not mounted");var h=o+e*t,g=s?!1:!p,x=Yc(h,u,c,m,g&&!f);return x},O6=function(n,e){var t=n.previousWheelEvent,s=n.state.scale,r=n.setup,o=r.maxScale,i=r.minScale;return t?s<o||s>i||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},doe=function(n,e){var t=n.setup.pinch,s=t.disabled,r=t.excluded,o=n.isInitialized,i=e.target,l=o&&!s&&i;if(!l)return!1;var c=Xc(i,r);return!c},foe=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,r=t&&!e&&s!==null;return!!r},moe=function(n,e,t){var s=t.getBoundingClientRect(),r=n.touches,o=r[0].clientX-s.left,i=r[0].clientY-s.top,l=r[1].clientX-s.left,c=r[1].clientY-s.top;return{x:(o+l)/2/e,y:(i+c)/2/e}},L6=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))},poe=5,hoe=function(n,e){var t=n.pinchStartScale,s=n.pinchStartDistance,r=n.setup,o=r.maxScale,i=r.minScale,l=r.zoomAnimation,c=r.disablePadding,u=r.pinch,d=l.size,f=l.disabled,m=u.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/poe),x=t+g,b=x===1/0?0:li(x,10);return Yc(b,i,o,d,!f&&!c)},M6=160,z6=100,goe=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onZoomStart;n.wheelStopEventTimer||(Us(n),gt(pt(n),e,s),gt(pt(n),e,r))},xoe=function(n,e){var t=n.props,s=t.onWheel,r=t.onZoom,o=n.contentComponent,i=n.setup,l=n.state,c=l.scale,u=i.limitToBounds,d=i.centerZoomedOut,f=i.zoomAnimation,m=i.wheel,p=i.disablePadding,h=i.smooth,g=f.size,x=f.disabled,b=m.step;if(!o)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=coe(e,null),v=h?b*Math.abs(e.deltaY):b,j=uoe(n,w,v,!e.ctrlKey);if(c!==j){var k=xa(n,j),_=R6(e,o,c),N=x||g===0||d||p,S=u&&N,C=vm(n,_.x,_.y,j,k,S),E=C.x,T=C.y;n.previousWheelEvent=e,n.setState(j,E,T),gt(pt(n),e,s),gt(pt(n),e,r)}},boe=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onZoomStop;fc(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Tb(n,e.x,e.y),n.wheelAnimationTimer=null)},z6);var o=O6(n,e);o&&(fc(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,gt(pt(n),e,s),gt(pt(n),e,r))},M6))},voe=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onPanningStart;n.wheelStopEventTimer||(Us(n),gt(pt(n),e,s),gt(pt(n),e,r))},yoe=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onPanningStop;fc(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(Tb(n,e.x,e.y),n.wheelAnimationTimer=null)},z6);var o=O6(n,e);o&&(fc(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,gt(pt(n),e,s),gt(pt(n),e,r))},M6))},D6=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 r=e/2,o=t/2;return{x:r,y:o}},woe=function(n,e){var t=L6(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=D6(e),Us(n)},Soe=function(n,e){var t=n.contentComponent,s=n.pinchStartDistance,r=n.wrapperComponent,o=n.pinchPreviousCenter,i=n.state.scale,l=n.setup,c=l.limitToBounds,u=l.centerZoomedOut,d=l.zoomAnimation,f=l.autoAlignment,m=l.pinch,p=l.panning,h=d.disabled,g=d.size,x=m.allowPanning;if(!(s===null||!t)){var b=moe(e,i,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=L6(e),v=hoe(n,w),j=D6(e),k=i/v,_=(j.x-((o==null?void 0:o.x)||0))*k,N=(j.y-((o==null?void 0:o.y)||0))*k;if(!(v===i&&_===0&&N===0)){n.pinchPreviousCenter=j;var S=xa(n,v),C=h||g===0||u,E=c&&C,T=vm(n,b.x,b.y,v,S,E),$=T.x,A=T.y;if(n.pinchMidpoint=b,n.lastDistance=w,p.disabled||!x)n.setState(v,$,A);else{var R=f.sizeX,P=f.sizeY,z=Fo(n,R,v),L=Fo(n,P,v),I=$+_,M=A+N,F=Zc(I,M,S,c,z,L,r),U=F.x,O=F.y;n.setState(v,U,O)}}}}},koe=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,Tb(n,e==null?void 0:e.x,e==null?void 0:e.y)},F6=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;fc(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,gt(pt(n),e,t)},s)},joe=function(n,e){var t=n.props,s=t.onZoomStart,r=t.onZoom,o=n.setup.doubleClick,i=o.animationTime,l=o.animationType;gt(pt(n),e,s),I6(n,i,l,function(){return gt(pt(n),e,r)}),F6(n,e)};function Noe(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function Coe(n,e){var t=n.setup,s=n.doubleClickStopEventTimer,r=n.state,o=n.contentComponent,i=r.scale,l=n.props,c=l.onZoomStart,u=l.onZoom,d=t.doubleClick,f=d.disabled,m=d.mode,p=d.step,h=d.animationTime,g=d.animationType;if(!f&&!s){if(m==="reset")return joe(n,e);if(!o)return console.error("No ContentComponent found");var x=Noe(m,n.state.scale),b=T6(n,x,p);if(i!==b){gt(pt(n),e,c);var w=R6(e,o,i),v=Eb(n,b,w.x,w.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");gt(pt(n),e,u),Zo(n,v,h,g),F6(n,e)}}}var _oe=function(n,e){var t=n.isInitialized,s=n.setup,r=n.wrapperComponent,o=s.doubleClick,i=o.disabled,l=o.excluded,c=e.target,u=r==null?void 0:r.contains(c),d=t&&c&&u&&!i;if(!d)return!1;var f=Xc(c,l);return!f},Eoe=(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&&xa(t,t.state.scale),t.setup=e3(s)},this.initializeWindowEvents=function(){var s,r,o,i,l=Oh(),c=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,u=c==null?void 0:c.defaultView;(r=t.wrapperComponent)===null||r===void 0||r.addEventListener("wheel",t.onWheelPanning,l),(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("keyup",t.setKeyUnPressed,l),(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("mousedown",t.onPanningStart,l),u==null||u.addEventListener("mousemove",t.onPanning,l),u==null||u.addEventListener("mouseup",t.onPanningStop,l),c==null||c.addEventListener("mouseleave",t.clearPanning,l),u==null||u.addEventListener("keyup",t.setKeyUnPressed,l),u==null||u.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var s,r,o,i,l,c=Oh(),u=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,d=u==null?void 0:u.defaultView;d==null||d.removeEventListener("mousedown",t.onPanningStart,c),d==null||d.removeEventListener("mousemove",t.onPanning,c),d==null||d.removeEventListener("mouseup",t.onPanningStop,c),u==null||u.removeEventListener("mouseleave",t.clearPanning,c),d==null||d.removeEventListener("keyup",t.setKeyUnPressed,c),d==null||d.removeEventListener("keydown",t.setKeyPressed,c),d==null||d.removeEventListener("blur",t.handleWindowBlur),document.removeEventListener("mouseleave",t.clearPanning,c),(r=t.wrapperComponent)===null||r===void 0||r.removeEventListener("wheel",t.onWheelPanning,c),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("keyup",t.setKeyUnPressed,c),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("keydown",t.setKeyPressed,c),Us(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var r=Oh();s.addEventListener("wheel",t.onWheelZoom,r),s.addEventListener("dblclick",t.onDoubleClick,r),s.addEventListener("touchstart",t.onTouchPanningStart,r),s.addEventListener("touchmove",t.onTouchPanning,r),s.addEventListener("touchend",t.onTouchPanningStop,r)},this.handleInitialize=function(s){var r=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(o){return o(pt(t))}),r&&(t.setCenter(),t.observer=new ResizeObserver(function(){var o,i=s.offsetWidth,l=s.offsetHeight;(i>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(pt(t))}),t.setCenter(),(o=t.observer)===null||o===void 0||o.disconnect())}),setTimeout(function(){var o;(o=t.observer)===null||o===void 0||o.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var r=t.setup.disabled;if(!r){t.syncModifierKeys(s);var o=$6(t,s);o&&(goe(t,s),xoe(t,s),boe(t,s))}},this.onWheelPanning=function(s){var r=t.props.onPanning,o=t.setup.trackPadPanning,i=o.lockAxisX,l=o.lockAxisY;t.syncModifierKeys(s);var c=aoe(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var u=t.state,d=u.positionX,f=u.positionY,m=d-s.deltaX,p=f-s.deltaY,h=i?d:m,g=l?f:p,x=t.setup.autoAlignment,b=x.sizeX,w=x.sizeY,v=Fo(t,b),j=Fo(t,w);h===d&&g===f||(voe(t,s),C6(t,h,g,v,j),gt(pt(t),s,r),yoe(t,s))}},this.onPanningStart=function(s){var r=t.setup.disabled,o=t.props.onPanningStart;if(!r){t.syncModifierKeys(s);var i=Gk(t,s);if(i){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(),Us(t),Xk(t,s),gt(pt(t),s,o)))}}},this.onPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(!r){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var i=Zk(t);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Jk(t,s.clientX,s.clientY,No.MOUSE),gt(pt(t),s,o))}}},this.onPanningStop=function(s){var r=t.setup.panning.velocityDisabled,o=t.props.onPanningStop;t.isPanning&&(Gre(t,r),gt(pt(t),s,o))},this.onPinchStart=function(s){var r=t.setup.disabled,o=t.props.onPinchStart;if(!r){var i=doe(t,s);i&&(woe(t,s),Us(t),gt(pt(t),s,o))}},this.onPinch=function(s){var r=t.setup.disabled,o=t.props.onPinch;if(!r){var i=foe(t);i&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),Soe(t,s),gt(pt(t),s,o))}},this.onPinchStop=function(s){var r=t.props.onPinchStop;t.pinchStartScale&&(koe(t),gt(pt(t),s,r))},this.onTouchPanningStart=function(s){var r=t.setup,o=r.disabled,i=r.doubleClick,l=t.props.onPanningStart;if(!o){var c=!(i!=null&&i.disabled),u=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&u&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,Us(t);var d=s.touches,f=d.length===1,m=d.length===2,p=Gk(t,s);if(f){if(!p)return;Us(t),Xk(t,s),gt(pt(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(r)return;var i=Zk(t);if(!i)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];Jk(t,l.clientX,l.clientY,No.TOUCH),gt(pt(t),s,o)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var r=t.setup.disabled;if(!r){var o=_oe(t,s);o&&Coe(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 r=s.ctrlKey,o=s.metaKey,i=s.shiftKey,l=s.altKey;typeof r=="boolean"&&(t.pressedKeys.Control=r),typeof o=="boolean"&&(t.pressedKeys.Meta=o),typeof i=="boolean"&&(t.pressedKeys.Shift=i),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(r){var o=r[1];return o}).map(function(r){var o=r[0];return o})):s.length?!!s.every(function(r){return t.pressedKeys[r]}):!0},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var s=Ab(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,r,o){return t.props.customTransform?t.props.customTransform(s,r,o):P6(s,r,o)},this.getContext=function(){return pt(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,r=s.scale,o=s.positionX,i=s.positionY,l=t.handleTransformStyles(o,i,r);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:r,positionX:o,positionY:i,previousScale:t.state.previousScale,ref:pt(t)})})}},this.setState=function(s,r,o){var i=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(r)&&!Number.isNaN(o)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=r,t.state.positionY=o,t.applyTransformation();var c=pt(t);t.onChangeCallbacks.forEach(function(u){return u(c)}),gt(c,{scale:t.state.scale,positionX:r,positionY:o},i)}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,r){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=r,xa(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(r),t.initializeWindowEvents(),t.isInitialized=!0;var o=pt(t);gt(o,void 0,t.props.onInit),ooe(t.props.ref,o)},this.props=e,this.setup=e3(this.props),this.state=E6(this.props)}return n})(),ym=_e.createContext(null),Toe=function(n,e){return typeof n=="function"?n(e):n},Aoe=_e.forwardRef(function(n,e){var t=y.useRef(new Eoe(n)).current,s=Toe(n.children,T1(t));return y.useImperativeHandle(e,function(){return T1(t)},[t]),y.useEffect(function(){t.update(n)},[t,n]),a.jsx(ym.Provider,ks({value:t},{children:s}))});_e.forwardRef(function(n,e){var t=y.useRef(null),s=y.useContext(ym);return y.useEffect(function(){return s.onChange(function(r){if(t.current){var o=0,i=0;t.current.style.transform=s.handleTransformStyles(o,i,1/r.instance.state.scale)}})},[s]),a.jsx("div",ks({},n,{ref:ioe([t,e])}))});function Ioe(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}}var Poe=`.transform-component-module_wrapper__SPB86 {
|
|
376
376
|
position: relative;
|
|
@@ -458,7 +458,7 @@ ${R}`:R:null}).filter(Boolean).join(`
|
|
|
458
458
|
`),t=[];let s=0;for(;s<e.length;){const r=e[s];s++;const o=new Map;for(const i of r.matchAll(kde)){const[,l,c,u]=i,d=c??u,f=[];for(;s<e.length&&e[s].trim()!==d;)f.push(l?e[s].replace(/^\t+/,""):e[s]),s++;s>=e.length||(s++,o.set(d,f.join(`
|
|
459
459
|
`)))}for(const i of Cde(r))t.push({text:i.text,bodies:o,piped:i.piped})}return t}function Ede(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?jm(t[1]??t[2]??t[3]??"",e):null}function Tde(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 Ade(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(eI);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const r=Tde(n.text);if(!r)return null;const o=jm(r,e);return o?{name:"Write",input:{file_path:o,content:s}}:null}function M3(n,e){const t=e==="replacement";let s="";for(let r=0;r<n.length;r++){const o=n[r];if(o==="\\"){const i=n[r+1];if(i===void 0||i==="|"||!O3.test(i)&&!"\\/&#".includes(i))return null;s+=i,r++;continue}if(o==="&"&&t||!t&&O3.test(o))return null;s+=o}return s}const Ide=/^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 Pde(n,e){var m;const t=(m=n.text.match(Ide))==null?void 0:m.groups;if(!t)return null;const{pattern:s,replacement:r,flags:o,dquoted:i,squoted:l,bare:c}=t;if(/[^g]/.test(o))return null;const u=M3(s,"pattern"),d=M3(r,"replacement");if(!u||d===null)return null;const f=jm(i??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:u,new_string:d,replace_all:o.includes("g")}}:null}function tI(n,e=null){if(n.fileDiffs)return ine(n.fileDiffs).map((o,i)=>({...ff(n,`${n.id}:bash-${i}`,"Edit",{file_path:o.filePath,old_string:o.oldString,new_string:o.newString}),diffLineCounts:o.diffLineCounts}));const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let r=e;for(const o of _de(t)){const i=Ede(o.text,r);if(i){r=i;continue}const l=Ade(o,r)??Pde(o,r);l&&s.push(ff(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function nI(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const r=jm(s,e)??s,o=[];for(const[i,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:u,replace_all:d}=l;typeof c!="string"||typeof u!="string"||o.push(ff(n,`${n.id}:edit-${i}`,"Edit",{file_path:r,old_string:c,new_string:u,replace_all:d===!0}))}return o}function sI(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?MT("apply_patch",t,n.id,n.timestamp,e??"").map(s=>ff(n,s.id,s.name,s.input)):[]}function Ul(n,e=null){const t=[];for(const s of n)s.isError||s.awaitingReview||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(...nI(s,e)):s.name==="Bash"?t.push(...tI(s,e)):s.name==="apply_patch"&&t.push(...sI(s,e)));return t}function mf(n,e=null){for(const t of n)if(!(t.isError||t.awaitingReview)&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&nI(t,e).length>0||t.name==="Bash"&&tI(t,e).length>0||t.name==="apply_patch"&&sI(t,e).length>0))return!0;return!1}const pf=new Map;function $de(n,e,t){let s=pf.get(e);if(!s){const r=new Map;s={observer:new IntersectionObserver(i=>{for(const l of i){if(!l.isIntersecting)continue;const c=r.get(l.target);z3(l.target,e),c==null||c()}},{rootMargin:e}),reveal:r},pf.set(e,s)}return s.reveal.set(n,t),s.observer.observe(n),()=>z3(n,e)}function z3(n,e){const t=pf.get(e);t!=null&&t.reveal.delete(n)&&(t.observer.unobserve(n),!(t.reveal.size>0)&&(t.observer.disconnect(),pf.delete(e)))}function Rde(n){const e=V.c(6),t="100%",s=y.useRef(null),[r,o]=y.useState(!1);let i,l;e[0]!==r||e[1]!==t?(i=()=>{const u=s.current;if(!(!u||r))return $de(u,t,()=>o(!0))},l=[t,r],e[0]=r,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]),y.useEffect(i,l);let c;return e[4]!==r?(c={ref:s,revealed:r},e[4]=r,e[5]=c):c=e[5],c}const Ode=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"]),Lde={json:vy,jsonc:vy,md:kl,mdx:kl,txt:kl,png:Yo,jpg:Yo,jpeg:Yo,gif:Yo,webp:Yo,svg:Yo,ico:Yo,sh:mu,bash:mu,zsh:mu,fish:mu};function rI(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Mde(n){const e=rI(n);return Lde[e]??(Ode.has(e)?yc:y4)}function ba({add:n,del:e,dimmed:t,className:s,breakdown:r,onBreakdownRequest:o}){const i=G("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",t&&"opacity-40",s),l=a.jsxs(a.Fragment,{children:[n>0&&a.jsxs("span",{className:"text-success",children:["+",n]}),e>0&&a.jsxs("span",{className:"text-destructive",children:["-",e]})]});return r===void 0||n+e===0?a.jsx("span",{className:i,children:l}):a.jsx(A4,{delay:0,children:a.jsxs(_4,{onOpenChange:c=>{c&&(o==null||o())},children:[a.jsx(E4,{render:a.jsx("span",{}),tabIndex:0,className:G(i,"cursor-default rounded-xs underline decoration-dotted underline-offset-4 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"),children:l}),a.jsx(I4,{children:a.jsx(P4,{side:"bottom",sideOffset:6,className:"isolate z-50",children:a.jsx(T4,{className:"z-50 w-fit origin-(--transform-origin) rounded-md bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 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 motion-reduce:animate-none",children:r===null?a.jsx("span",{className:"text-muted-foreground",children:"Loading breakdown…"}):a.jsxs("div",{className:"grid grid-cols-[auto_auto_auto] items-baseline gap-x-4 gap-y-1 font-mono tabular-nums",children:[r.map(c=>a.jsx(D3,{...c},c.label)),a.jsx("div",{className:"col-span-3 my-0.5 border-t border-border"}),a.jsx(D3,{label:"Total",additions:n,deletions:e})]})})})})]})})}function D3({label:n,additions:e,deletions:t}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"font-sans",children:n}),a.jsxs("span",{className:"text-right text-success",children:["+",e]}),a.jsxs("span",{className:"text-right text-destructive",children:["-",t]})]})}const F3=5;function Hb(n){const e=V.c(11),{add:t,del:s}=n,r=t+s;if(r===0)return null;let o,i,l;if(e[0]!==t||e[1]!==r){const d=Math.round(t/r*F3);o=F3-d,i="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:d},Dde),e[0]=t,e[1]=r,e[2]=o,e[3]=i,e[4]=l}else o=e[2],i=e[3],l=e[4];let c;e[5]!==o?(c=Array.from({length:o},zde),e[5]=o,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==l||e[9]!==c?(u=a.jsxs("span",{className:i,children:[l,c]}),e[7]=i,e[8]=l,e[9]=c,e[10]=u):u=e[10],u}function zde(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function Dde(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const hf="cogpit:open-subagent";function oI(n){const e=V.c(3),{hasEdit:t,hasWrite:s}=n;if(t&&s){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E+W"}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-success",children:"W"}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E"}),e[2]=r):r=e[2],r}function Kb(n){const e=V.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=a.jsx(Q,{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:r=>{r.stopPropagation(),window.dispatchEvent(new CustomEvent(hf,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const iI=y.memo(function(e){const t=V.c(92),{file:s,defaultOpen:r,isHighlighted:o,diffMode:i}=e,{ref:l,revealed:c}=Rde(),[u,d]=y.useState(r),[f,m]=y.useState(r),p=y.useRef(r);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=ve=>{d(ve),ve?y.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,b;t[1]!==r?(x=()=>{p.current!==r&&(p.current=r,g(r))},b=[r,g],t[1]=r,t[2]=x,t[3]=b):(x=t[2],b=t[3]),y.useEffect(x,b);let w,v;t[4]!==o?(w=()=>{o&&g(!0)},v=[o,g],t[4]=o,t[5]=w,t[6]=v):(w=t[5],v=t[6]),y.useEffect(w,v);let j;t[7]!==s.filePath?(j=rI(s.filePath),t[7]=s.filePath,t[8]=j):j=t[8];const k=j,_=s.netOriginal,N=s.netCurrent,S=!!(_||N);let C;t[9]!==s.edits?(C=s.edits.some(Wde),t[9]=s.edits,t[10]=C):C=t[10];const T=i==="per-edit"?C:S,$=f&&c&&T,[A,R]=y.useState(0);let P;t[11]===Symbol.for("react.memo_cache_sentinel")?(P=ve=>{if(!ve)return;const Se=ve.offsetHeight;R(we=>we===Se?we:Se)},t[11]=P):P=t[11];const z=P,L=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,I=s.filePath,M=o?"border-ring ring-2 ring-ring/20":"border-border";let F;t[12]!==M?(F=G("rounded-lg border bg-card transition-colors",M),t[12]=M,t[13]=F):F=t[13];let U;t[14]!==u?(U=()=>g(!u),t[14]=u,t[15]=U):U=t[15];let O;t[16]!==u?(O=u?a.jsx(Et,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):a.jsx(it,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=u,t[17]=O):O=t[17];let D;t[18]!==k?(D=a.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:k}),t[18]=k,t[19]=D):D=t[19];let B;t[20]!==s.opTypes?(B=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=B):B=t[21];let q;t[22]!==s.opTypes?(q=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=q):q=t[23];let W;t[24]!==B||t[25]!==q?(W=a.jsx(oI,{hasEdit:B,hasWrite:q}),t[24]=B,t[25]=q,t[26]=W):W=t[26];let H;t[27]!==s.shortPath?(H=a.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=H):H=t[28];let K;t[29]!==L?(K=a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:L}),t[29]=L,t[30]=K):K=t[30];let Z;t[31]!==s.editCount?(Z=s.editCount>1&&a.jsxs(Fe,{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]=Z):Z=t[32];let Y;t[33]!==u||t[34]!==U||t[35]!==O||t[36]!==D||t[37]!==W||t[38]!==H||t[39]!==K||t[40]!==Z?(Y=a.jsxs(Q,{type:"button",variant:"ghost",onClick:U,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":u,children:[O,D,W,H,K,Z]}),t[33]=u,t[34]=U,t[35]=O,t[36]=D,t[37]=W,t[38]=H,t[39]=K,t[40]=Z,t[41]=Y):Y=t[41];let J;t[42]!==s.subAgentId?(J=s.subAgentId&&a.jsx(Kb,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=J):J=t[43];let ee;t[44]!==s.filePath?(ee=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>cc(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=ee):ee=t[45];let te;t[46]===Symbol.for("react.memo_cache_sentinel")?(te=a.jsx(xx,{"data-icon":"inline-start"}),t[46]=te):te=t[46];let se;t[47]!==ee?(se=a.jsx(Zt,{render:ee,children:te}),t[47]=ee,t[48]=se):se=t[48];let X;t[49]===Symbol.for("react.memo_cache_sentinel")?(X=a.jsx(Yt,{children:"Open in editor"}),t[49]=X):X=t[49];let ne;t[50]!==se?(ne=a.jsxs(Gt,{children:[se,X]}),t[50]=se,t[51]=ne):ne=t[51];let ae;t[52]!==s.filePath?(ae=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>cc(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=ae):ae=t[53];let ie;t[54]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsx(c8,{"data-icon":"inline-start"}),t[54]=ie):ie=t[54];let re;t[55]!==ae?(re=a.jsx(Zt,{render:ae,children:ie}),t[55]=ae,t[56]=re):re=t[56];let de;t[57]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsx(Yt,{children:"View git diff"}),t[57]=de):de=t[57];let ce;t[58]!==re?(ce=a.jsxs(Gt,{children:[re,de]}),t[58]=re,t[59]=ce):ce=t[59];let oe;t[60]!==ne||t[61]!==ce?(oe=a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[ne,ce]}),t[60]=ne,t[61]=ce,t[62]=oe):oe=t[62];let fe,ue;t[63]!==s.addCount||t[64]!==s.delCount?(fe=a.jsx(ba,{add:s.addCount,del:s.delCount}),ue=a.jsx(Hb,{add:s.addCount,del:s.delCount}),t[63]=s.addCount,t[64]=s.delCount,t[65]=fe,t[66]=ue):(fe=t[65],ue=t[66]);let le;t[67]!==J||t[68]!==oe||t[69]!==fe||t[70]!==ue?(le=a.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[J,oe,fe,ue]}),t[67]=J,t[68]=oe,t[69]=fe,t[70]=ue,t[71]=le):le=t[71];let pe;t[72]!==Y||t[73]!==le?(pe=a.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-popover",children:[Y,le]}),t[72]=Y,t[73]=le,t[74]=pe):pe=t[74];let ge;t[75]!==i||t[76]!==s.edits||t[77]!==s.filePath||t[78]!==s.netStartLine||t[79]!==T||t[80]!==A||t[81]!==N||t[82]!==_||t[83]!==u||t[84]!==$?(ge=a.jsx(Fde,{showDiff:$,open:u,hasDiff:T,diffRef:z,lastDiffHeight:A,oldString:_,newString:N,filePath:s.filePath,diffMode:i,edits:s.edits,netStartLine:s.netStartLine}),t[75]=i,t[76]=s.edits,t[77]=s.filePath,t[78]=s.netStartLine,t[79]=T,t[80]=A,t[81]=N,t[82]=_,t[83]=u,t[84]=$,t[85]=ge):ge=t[85];let be;return t[86]!==s.filePath||t[87]!==l||t[88]!==F||t[89]!==pe||t[90]!==ge?(be=a.jsxs("div",{ref:l,"data-file-path":I,className:F,children:[pe,ge]}),t[86]=s.filePath,t[87]=l,t[88]=F,t[89]=pe,t[90]=ge,t[91]=be):be=t[91],be}),Fde=y.memo(function(e){const t=V.c(15),{showDiff:s,open:r,hasDiff:o,diffRef:i,lastDiffHeight:l,oldString:c,newString:u,filePath:d,diffMode:f,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==f||t[1]!==m||t[2]!==d||t[3]!==p||t[4]!==u||t[5]!==c?(h=f==="per-edit"?a.jsx(Bde,{edits:m,filePath:d}):a.jsx(Wb,{oldString:c,newString:u,filePath:d,compact:!1,startLine:p,hideHeader:!0}),t[0]=f,t[1]=m,t[2]=d,t[3]=p,t[4]=u,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==f||t[8]!==i||t[9]!==h?(g=a.jsx("div",{ref:i,className:"motion-enter overflow-hidden rounded-b",children:h},f),t[7]=f,t[8]=i,t[9]=h,t[10]=g):g=t[10],g}if(r&&l>0){let h;return t[11]!==l?(h=a.jsx("div",{style:{height:l}}),t[11]=l,t[12]=h):h=t[12],h}if(r&&!o){const h=f==="per-edit"?"No edits":"No net changes (all edits cancelled out)";let g;return t[13]!==h?(g=a.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}),U3=3,Ude=5,Bde=y.memo(function(e){const t=V.c(9),{edits:s,filePath:r}=e,o=s.length,i=s.filter(qde),l=i.length>U3,[c,u]=y.useState(l?U3:i.length);y.useEffect(()=>{if(c>=i.length)return;const x=requestAnimationFrame(()=>{u(b=>Math.min(b+Ude,i.length))});return()=>cancelAnimationFrame(x)},[c,i.length]);const d=l?i.slice(0,c):i,f="divide-y divide-border/30";let m;t[0]!==r||t[1]!==o?(m=(x,b)=>a.jsxs("div",{children:[o>1&&a.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[x.toolName," ",b+1,"/",o]}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&a.jsx(Kb,{agentId:x.agentId})]}),a.jsx(Wb,{oldString:x.oldString,newString:x.newString,filePath:r,compact:!1,startLine:x.startLine,hideHeader:!0})]},x.id),t[0]=r,t[1]=o,t[2]=m):m=t[2];const p=d.map(m);let h;t[3]!==i.length||t[4]!==c?(h=c<i.length&&a.jsxs("div",{className:"py-1.5 text-center text-xs text-muted-foreground",children:["Loading ",i.length-c," more edits…"]}),t[3]=i.length,t[4]=c,t[5]=h):h=t[5];let g;return t[6]!==p||t[7]!==h?(g=a.jsxs("div",{className:f,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function Wde(n){return!!(n.oldString||n.newString)}function qde(n){return!!(n.oldString||n.newString)}const Yh=new Map;function Vde(n){var _;const e=Nn("hostFiles"),{sessionSource:t}=jt(),s=t==null?void 0:t.dirName,r=un(s)==="codex",o=n.turns.length,i=((_=n.turns.at(-1))==null?void 0:_.toolCalls.length)??0,l=y.useMemo(()=>{let N=0;for(const S of n.turns){N+=S.toolCalls.length;for(const C of S.subAgentActivity)N+=C.toolCalls.length}return N},[o,i]),c=y.useMemo(()=>{const N=[];for(let S=0;S<n.turns.length;S++)for(const C of n.turns[S].subAgentActivity){const E=r&&(C.status==="completed"||C.status==="failed"||C.status==="interrupted");(C.isBackground||E)&&C.toolCalls.length===0&&N.push({agentId:C.agentId,turnIndex:S})}return N},[n.turns,l,r]),[u,d]=y.useState(new Map),f=y.useRef(new Set);y.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const N=[];for(const{agentId:E}of c){const T=sn(`${s}/${n.sessionId}/${E}`);if(!f.current.has(T)){if(Yh.has(T)){d($=>{const A=new Map($);return A.set(E,Yh.get(T)),A}),f.current.add(T);continue}N.push({agentId:E,cacheKey:T})}}if(N.length===0)return;let S=!1;async function C(){const E=new Map;await Promise.all(N.map(async({agentId:T,cacheKey:$})=>{try{const A=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(T)}.jsonl`,R=await Ce(A);if(!R.ok)return;const P=await R.text(),L=RA(P,T).flatMap(I=>Ul(I.toolCalls,n.cwd));Yh.set($,L),f.current.add($),E.set(T,L)}catch{}})),!S&&E.size>0&&d(T=>{const $=new Map(T);for(const[A,R]of E)$.set(A,R);return $})}return C(),()=>{S=!0}},[s,n.sessionId,n.cwd,c]);const m=y.useMemo(()=>{const N=[],S=new Set;for(let C=0;C<n.turns.length;C++){const E=n.turns[C];for(const T of Ul(E.toolCalls,n.cwd))N.push({turnIndex:C,toolCall:T});for(const T of E.subAgentActivity){for(const $ of Ul(T.toolCalls,n.cwd))N.push({turnIndex:C,toolCall:$,agentId:T.agentId});if((T.isBackground||r)&&T.toolCalls.length===0&&!S.has(T.agentId)){S.add(T.agentId);const $=u.get(T.agentId);if($)for(const A of $)N.push({turnIndex:C,toolCall:A,agentId:T.agentId})}}}return N},[l,n.turns,u,r]),p=y.useMemo(()=>{const N=new Map;for(const{toolCall:S}of m){const C=aI(S);C&&N.set(C,JSON.stringify([S.id,S.input,S.result]))}return JSON.stringify([...N])},[m]),h=sn(JSON.stringify([s,n.sessionId,n.cwd])),[g,x]=y.useState(new Map),b=y.useRef(new Map),[w,v]=y.useState(0);y.useEffect(()=>{const N=()=>v(S=>S+1);return window.addEventListener("focus",N),()=>window.removeEventListener("focus",N)},[]),y.useEffect(()=>{b.current=new Map},[h,t==null?void 0:t.rawText,w]),y.useEffect(()=>{const N=JSON.parse(p);if(!e||N.length===0){x(E=>E.size?new Map:E);return}let S=!1;const C=b.current;return Promise.all(N.map(async([E,T])=>{const $=C.get(E);if(($==null?void 0:$.revision)===T)return[E,$.text];try{const A=await Ce(`/api/file-content?path=${encodeURIComponent(E)}`);if(!A.ok)return null;const R=await A.text();return S?null:(C.set(E,{revision:T,text:R}),[E,R])}catch{return null}})).then(E=>{if(S)return;const T=new Map;for(const $ of E)$&&T.set(...$);for(const $ of C.keys())T.has($)||C.delete($);x($=>$.size===T.size&&[...T].every(([A,R])=>$.get(A)===R)?$:T)}),()=>{S=!0}},[e,p,h,t==null?void 0:t.rawText,w]);const j=n.turns.length-1,k=y.useMemo(()=>{const N=new Map;for(const S of n.turns)for(const C of S.subAgentActivity)N.has(C.agentId)||N.set(C.agentId,{name:C.agentName,type:C.subagentType});return N},[n.turns]);return{fileChanges:m,fileContents:g,lastTurnIndex:j,agentMap:k}}function B3(n,e){if(!n||!e)return 1;const t=n.indexOf(e);if(t===-1)return 1;let s=1;for(let r=0;r<t;r++)n[r]===`
|
|
460
460
|
`&&s++;return s}function aI(n){return String(n.input.file_path??n.input.path??"")}function Hde(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,diffLineCounts:n.diffLineCounts}}function lI(n,e,t){const s=new Map;for(const o of n){if(e!=="all"&&o.turnIndex!==e)continue;const i=aI(o.toolCall);if(!i)continue;let l=s.get(i);l||(l=[],s.set(i,l)),l.push(o)}const r=[];for(const[o,i]of s){const l=[],c=[];let u=1/0,d=-1/0,f=!1,m=!1,p;const h=t==null?void 0:t.get(o);for(let b=0;b<i.length;b++){const w=i[b],v=Hde(w.toolCall);l.push(v),w.turnIndex<u&&(u=w.turnIndex),w.turnIndex>d&&(d=w.turnIndex),w.toolCall.name==="Edit"?f=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:v.oldString,newString:v.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:B3(h,v.newString||v.oldString)})}const g=Gle(l),x=[];f&&x.push("Edit"),m&&x.push("Write"),r.push({filePath:o,shortPath:o.split("/").slice(-3).join("/"),editCount:i.length,turnRange:[u,d],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?B3(h,g.currentStr):c.length>0?c[0].startLine:1})}return r.sort((o,i)=>o.turnRange[1]-i.turnRange[1]||o.turnRange[0]-i.turnRange[0]||o.filePath.localeCompare(i.filePath)),r}function Kde(n,e,t,s){const r=new Map;for(const i of n){if(!i.agentId||e!=="all"&&i.turnIndex!==e)continue;let l=r.get(i.agentId);l||(l=[],r.set(i.agentId,l)),l.push(i)}const o=[];for(const[i,l]of r){const c=lI(l,"all",s);if(c.length===0)continue;let u=0,d=0;for(const m of c)u+=m.addCount,d+=m.delCount;const f=t.get(i);o.push({agentId:i,agentName:(f==null?void 0:f.name)??null,subagentType:(f==null?void 0:f.type)??null,files:c,totalAdd:u,totalDel:d})}return o.sort((i,l)=>{var d,f;const c=((d=i.files[0])==null?void 0:d.turnRange[0])??0,u=((f=l.files[0])==null?void 0:f.turnRange[0])??0;return c-u}),o}const cI={code:"Code",tests:"Tests",mocks:"Mocks",generated:"Generated",docs:"Docs"},W3=Object.keys(cI),Gde=new Set(["bun.lock","bun.lockb","cargo.lock","composer.lock","deno.lock","flake.lock","gemfile.lock","go.sum","gradle.lockfile","mix.lock","npm-shrinkwrap.json","package-lock.json","packages.lock.json","pipfile.lock","pnpm-lock.yaml","podfile.lock","poetry.lock","pubspec.lock","uv.lock","yarn.lock"]),Zde=/(\.generated\.|\.gen\.|\.g\.dart$|\.pb\.go$|_pb2(_grpc)?\.py$|\.pb\.(cc|h)$|\.min\.(js|css)$|\.(js|css)\.map$)/,Yde=new Set(["__generated__","generated"]),Xde=/(\.snap$|\.(mocks?|fixtures?|stubs?|fakes?)\.[^.]+$|^(mocks?|fixtures?|stubs?|fakes?)([-_.A-Z]|$))/,Jde=new Set(["__fixtures__","__mocks__","__snapshots__","fakes","fixture","fixtures","mock","mocks","stubs","testdata"]),Qde=/(\.(test|spec|e2e)\.[^.]+$|_(test|spec)\.[^.]+$|^test_.+\.py$|^conftest\.py$|^(vitest|jest)\.setup\.[^.]+$)/i,efe=/(Tests?|Spec)\.(java|kt|kts|scala|groovy|cs|php|swift|m)$/,tfe=new Set(["__tests__","__test__","cypress","e2e","spec","specs","test","tests"]),nfe=/\.(md|mdx|markdown|rst|adoc|txt)$/i,sfe=/^(requirements.*|constraints.*|CMakeLists|robots|llms)\.txt$/i;function rfe(n){const e=n.replaceAll("\\","/").split("/"),t=e.pop()??"",s=e.map(o=>o.toLowerCase()),r=o=>s.some(i=>o.has(i));return Gde.has(t.toLowerCase())||Zde.test(t)||r(Yde)?"generated":Xde.test(t)||r(Jde)?"mocks":Qde.test(t)||efe.test(t)||r(tfe)?"tests":nfe.test(t)&&!sfe.test(t)?"docs":"code"}function ofe(n){const e=W3.map(t=>({kind:t,label:cI[t],additions:0,deletions:0}));for(const t of n){const s=e[W3.indexOf(rfe(t.path))];s.additions+=t.additions,s.deletions+=t.deletions}return e.filter(t=>t.additions>0||t.deletions>0)}function uI(n,e){return ofe(Array.from(e,t=>({path:C1(n,t.filePath)??t.filePath,additions:t.additions,deletions:t.deletions})))}const gc="cogpit:focus-file",ife="cogpit:file-changes-prefs",afe={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function dI(n,e){return uI(n,e.map(t=>({filePath:t.filePath,additions:t.addCount,deletions:t.delCount})))}function lfe(n){const e=V.c(38),{group:t,cwd:s,allExpanded:r,highlightPath:o,diffMode:i}=n;let l;e[0]!==t.agentId||e[1]!==t.agentName?(l=t.agentName||t.agentId.slice(0,8),e[0]=t.agentId,e[1]=t.agentName,e[2]=l):l=e[2];const c=l,u=t.subagentType,d=`Open subagent ${t.agentId}`;let f;e[3]!==t.agentId?(f=()=>{window.dispatchEvent(new CustomEvent(hf,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=f):f=e[4];let m;e[5]!==c||e[6]!==d||e[7]!==f?(m=a.jsx(Q,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:d,onClick:f,children:c}),e[5]=c,e[6]=d,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==u?(p=u&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",children:u}),e[9]=u,e[10]=p):p=e[10];let h;e[11]!==t.files.length?(h=a.jsx(Fe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:t.files.length}),e[11]=t.files.length,e[12]=h):h=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx("div",{className:"flex-1"}),e[13]=g):g=e[13];const x=t.totalAdd,b=t.totalDel;let w;e[14]!==s||e[15]!==t.files?(w=dI(s,t.files),e[14]=s,e[15]=t.files,e[16]=w):w=e[16];let v;e[17]!==t.totalAdd||e[18]!==t.totalDel||e[19]!==w?(v=a.jsx(ba,{add:x,del:b,breakdown:w}),e[17]=t.totalAdd,e[18]=t.totalDel,e[19]=w,e[20]=v):v=e[20];let j;e[21]!==v||e[22]!==m||e[23]!==p||e[24]!==h?(j=a.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[m,p,h,g,v]}),e[21]=v,e[22]=m,e[23]=p,e[24]=h,e[25]=j):j=e[25];let k;if(e[26]!==r||e[27]!==i||e[28]!==t.files||e[29]!==o){let N;e[31]!==r||e[32]!==i||e[33]!==o?(N=S=>a.jsx(iI,{file:S,defaultOpen:r,isHighlighted:o===S.filePath,diffMode:i},S.filePath),e[31]=r,e[32]=i,e[33]=o,e[34]=N):N=e[34],k=t.files.map(N),e[26]=r,e[27]=i,e[28]=t.files,e[29]=o,e[30]=k}else k=e[30];let _;return e[35]!==j||e[36]!==k?(_=a.jsxs("div",{className:"flex flex-col gap-1",children:[j,k]}),e[35]=j,e[36]=k,e[37]=_):_=e[37],_}const cfe=y.memo(function({session:e,sessionChangeKey:t}){const s=y.useRef(null),r=y.useRef(null),o=y.useRef(!0),i=y.useRef(!1),l=y.useRef(0),c=y.useRef(e.turns.length),[u,d]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=jr(ife,{}),g={...afe,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[v,j]=y.useState(g.scope),k=y.useCallback(W=>{h(H=>({...H,expanded:W}))},[h]),_=y.useCallback(W=>{h(H=>({...H,diffMode:W}))},[h]),N=y.useCallback(W=>{h(H=>({...H,groupByAgent:W}))},[h]);y.useEffect(()=>{typeof v!="number"&&h(W=>({...W,scope:v}))},[v,h]);const[S,C]=y.useState(null),E=y.useRef(null),{fileChanges:T,fileContents:$,lastTurnIndex:A,agentMap:R}=Vde(e),P=y.useMemo(()=>lI(T,typeof v=="number"?v:v==="all"?"all":A,$),[T,v,A,$]),z=y.useMemo(()=>w?Kde(T,typeof v=="number"?v:v==="all"?"all":A,R,$):[],[w,T,v,A,R,$]);y.useEffect(()=>{const W=H=>{const K=H.detail;K!=null&&K.filePath&&(j(K.turnIndex),C(K.filePath),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>C(null),3e3),requestAnimationFrame(()=>{var Y;const Z=(Y=s.current)==null?void 0:Y.querySelector(`[data-file-path="${CSS.escape(K.filePath)}"]`);Z==null||Z.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(gc,W),()=>{window.removeEventListener(gc,W),E.current&&clearTimeout(E.current)}},[]);const L=y.useCallback(()=>{const W=s.current;W&&(d(W.scrollTop>10),m(W.scrollHeight-W.scrollTop-W.clientHeight>10))},[]),I=y.useCallback(()=>{const W=s.current;W&&(o.current=W.scrollHeight-W.scrollTop-W.clientHeight<50,L())},[L]);if(y.useEffect(()=>{L()},[T.length,P.length,L]),y.useEffect(()=>{const W=s.current;W&&(W.scrollTop=W.scrollHeight),o.current=!0,i.current=!1,l.current=T.length,c.current=e.turns.length,j(g.scope),C(null),L()},[t]),y.useEffect(()=>{const W=e.turns.length;W>c.current&&(i.current=!0),c.current=W},[e.turns.length]),y.useEffect(()=>{if(T.length<=l.current){l.current=T.length;return}l.current=T.length,(i.current||o.current)&&(requestAnimationFrame(()=>{var W;(W=r.current)==null||W.scrollIntoView({behavior:"smooth"})}),i.current=!1)},[T.length]),T.length===0)return null;const M=w?z.flatMap(W=>W.files):P;let F=0,U=0;for(const W of M)F+=W.addCount,U+=W.delCount;const O=M.length;function D(){j(v==="last"?"all":"last")}function B(){return typeof v=="number"?`Turn ${v+1}`:v==="all"?"All turns":`Last turn (T${A+1})`}const q=B();return a.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-canvas",children:[a.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[a.jsx(yc,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),a.jsxs(Fe,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[O," file",O!==1?"s":""]}),a.jsx("div",{className:"flex-1"}),a.jsx(ba,{add:F,del:U,breakdown:dI(e.cwd,M)}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>N(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:a.jsx(tr,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:w?"Show all changes":"Group by subagent"})]}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:v==="all"?"secondary":"ghost",size:"icon-xs",onClick:D,"aria-label":v==="last"?"Show all turns":"Show last turn only"}),children:v==="all"?a.jsx(jd,{"data-icon":"inline-start"}):a.jsx(Po,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>_(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?a.jsx(u8,{"data-icon":"inline-start"}):a.jsx(d8,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>k(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?a.jsx(Nf,{"data-icon":"inline-start"}):a.jsx(Ea,{"data-icon":"inline-start"})}),a.jsx(Yt,{children:x?"Collapse all":"Expand all"})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),v!=="all"&&A>0&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>{const W=typeof v=="number"?v:A;W>0&&j(W-1)},disabled:(typeof v=="number"?v:A)<=0,"aria-label":"Previous turn",children:a.jsx(ux,{"data-icon":"inline-start"})}),a.jsx("span",{className:G("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:q}),v!=="all"&&A>0&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>{j(W=>typeof W!="number"?W:W+1>=A?"last":W+1)},disabled:v==="last","aria-label":"Next turn",children:a.jsx(it,{"data-icon":"inline-start"})}),typeof v=="number"&&a.jsx(Q,{variant:"ghost",size:"icon-xs",onClick:()=>j("last"),"aria-label":"Back to last turn",children:a.jsx(Mt,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-canvas to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")}),a.jsxs("div",{ref:s,onScroll:I,className:"h-full overflow-y-auto",children:[a.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?z.length>0?z.map(W=>a.jsx(lfe,{group:W,cwd:e.cwd,allExpanded:x,highlightPath:S,diffMode:b},W.agentId)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",q.toLowerCase()]}):P.length>0?P.map(W=>a.jsx(iI,{file:W,defaultOpen:x,isHighlighted:S===W.filePath,diffMode:b},W.filePath)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",q.toLowerCase()]})}),a.jsx("div",{ref:r})]}),a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-canvas to-transparent transition-opacity duration-200",f?"opacity-100":"opacity-0")})]})]})});function ufe(n,e){const t=new Map;function s(r,o){const i=String(r.input.file_path??r.input.path??"");if(!i)return;const l=r.name==="Edit",c=l?String(r.input.old_string??""):"",u=String(l?r.input.new_string??"":r.input.content??""),d=r.diffLineCounts??$1(c,u),f=t.get(i)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};f.add+=d.add,f.del+=d.del,l?f.hasEdit=!0:f.hasWrite=!0,o&&(f.subAgentId=o),t.set(i,f)}return Ul(n.toolCalls,e).forEach(r=>s(r)),n.subAgentActivity.forEach(r=>Ul(r.toolCalls,e).forEach(o=>s(o,r.agentId))),[...t.entries()].map(([r,{add:o,del:i,hasEdit:l,hasWrite:c,subAgentId:u}])=>({filePath:r,additions:o,deletions:i,hasEdit:l,hasWrite:c,subAgentId:u}))}function q3(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function dfe(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=q3();for(const o of n){let i=o.filePath;t&&i.startsWith(t+"/")?i=i.slice(t.length+1):i.startsWith("/")&&(i=i.slice(1));const l=i.split("/");let c=s;for(let u=0;u<l.length;u++){let d=c.children.get(l[u]);d||(d=q3(),c.children.set(l[u],d)),u===l.length-1&&(d.isFile=!0,d.absPath=o.filePath,d.additions+=o.additions,d.deletions+=o.deletions,o.hasEdit&&(d.hasEdit=!0),o.hasWrite&&(d.hasWrite=!0),o.subAgentId&&(d.subAgentId=o.subAgentId)),c=d}}function r(o,i){return[...o.children.entries()].sort(([c,u],[d,f])=>{const m=u.isFile&&u.children.size===0,p=f.isFile&&f.children.size===0;return m!==p?m?1:-1:c.localeCompare(d)}).map(([c,u])=>{const d=i?`${i}/${c}`:c;if(u.isFile&&u.children.size===0)return{name:c,fullPath:d,absPath:u.absPath,isFile:!0,additions:u.additions,deletions:u.deletions,hasEdit:u.hasEdit,hasWrite:u.hasWrite,subAgentId:u.subAgentId,children:[]};let f=u,m=c,p=d;for(;!f.isFile&&f.children.size===1;){const[j,k]=[...f.children.entries()][0];if(k.isFile&&k.children.size===0)break;m+="/"+j,p+="/"+j,f=k}const h=r(f,p);let g=0,x=0,b=f.isFile?f.hasEdit:!1,w=f.isFile?f.hasWrite:!1,v=f.isFile?f.subAgentId:null;for(const j of h)g+=j.additions,x+=j.deletions,j.hasEdit&&(b=!0),j.hasWrite&&(w=!0),j.subAgentId&&(v=j.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:w,subAgentId:v,children:h}})}return r(s,"")}const ffe=y.memo(function(e){const t=V.c(54),{turn:s,turnIndex:r,cwd:o}=e,i=Nn("hostFiles");let l;t[0]!==o||t[1]!==s?(l=ufe(s,o),t[0]=o,t[1]=s,t[2]=l):l=t[2];const c=l;let u;t[3]!==o||t[4]!==c?(u=dfe(c,o),t[3]=o,t[4]=c,t[5]=u):u=t[5];const d=u,[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];const g=p,x=h;let b;t[11]!==o||t[12]!==c?(b=uI(o,c),t[11]=o,t[12]=c,t[13]=b):b=t[13];let w;t[14]!==p||t[15]!==h||t[16]!==b?(w={add:g,del:x,breakdown:b},t[14]=p,t[15]=h,t[16]=b,t[17]=w):w=t[17];const v=w;if(c.length===0)return null;const j=f&&"rotate-90";let k;t[18]!==j?(k=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",j),t[18]=j,t[19]=k):k=t[19];let _;t[20]!==k?(_=a.jsx(it,{"data-icon":"inline-start",className:k}),t[20]=k,t[21]=_):_=t[21];let N;t[22]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(yc,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[22]=N):N=t[22];const S=c.length!==1?"s":"";let C;t[23]!==c.length||t[24]!==S?(C=a.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",S]}),t[23]=c.length,t[24]=S,t[25]=C):C=t[25];let E;t[26]!==C||t[27]!==_?(E=a.jsxs(rs,{className:"flex cursor-pointer items-center gap-1.5 text-left outline-none after:absolute after:inset-0 after:rounded-md focus-visible:after:ring-[3px] focus-visible:after:ring-ring/50",children:[_,N,C]}),t[26]=C,t[27]=_,t[28]=E):E=t[28];let T;t[29]!==v.add||t[30]!==v.breakdown||t[31]!==v.del?(T=a.jsx(ba,{add:v.add,del:v.del,breakdown:v.breakdown,className:"relative opacity-80"}),t[29]=v.add,t[30]=v.breakdown,t[31]=v.del,t[32]=T):T=t[32];let $;t[33]!==v.add||t[34]!==v.del?($=a.jsx(Hb,{add:v.add,del:v.del}),t[33]=v.add,t[34]=v.del,t[35]=$):$=t[35];let A;t[36]===Symbol.for("react.memo_cache_sentinel")?(A=a.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[36]=A):A=t[36];let R;t[37]!==E||t[38]!==T||t[39]!==$?(R=a.jsxs("div",{className:"group/files relative flex min-h-7 w-full items-center gap-1.5 px-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[E,T,$,A]}),t[37]=E,t[38]=T,t[39]=$,t[40]=R):R=t[40];let P;if(t[41]!==i||t[42]!==d||t[43]!==r){let I;t[45]!==i||t[46]!==r?(I=M=>a.jsx(mfe,{node:M,depth:0,turnIndex:r,canFocusFiles:i},M.fullPath),t[45]=i,t[46]=r,t[47]=I):I=t[47],P=d.map(I),t[41]=i,t[42]=d,t[43]=r,t[44]=P}else P=t[44];let z;t[48]!==P?(z=a.jsx(yn,{className:"ml-1 border-l border-border/40 pl-3",children:a.jsx("div",{className:"py-0.5",children:P})}),t[48]=P,t[49]=z):z=t[49];let L;return t[50]!==f||t[51]!==R||t[52]!==z?(L=a.jsxs(vn,{open:f,onOpenChange:m,children:[R,z]}),t[50]=f,t[51]=R,t[52]=z,t[53]=L):L=t[53],L}),mfe=y.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:r}){const[o,i]=y.useState(!0),l=t*16+8;if(e.isFile){const c=Mde(e.name),u=()=>{r&&e.absPath&&window.dispatchEvent(new CustomEvent(gc,{detail:{filePath:e.absPath,turnIndex:s}}))};return a.jsxs("div",{className:"flex h-7 w-full items-center gap-1.5 font-mono text-xs",style:{paddingLeft:l},children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",disabled:!r,className:G("h-7 min-w-0 flex-1 justify-start gap-1.5 rounded-sm px-0 font-mono text-xs font-normal disabled:opacity-100",r&&"cursor-pointer"),onClick:u,title:r?"Click to focus in sidebar":void 0,children:[a.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(oI,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),a.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&a.jsx(Kb,{agentId:e.subAgentId}),a.jsx(ba,{add:e.additions,del:e.deletions}),a.jsx(Hb,{add:e.additions,del:e.deletions})]})}return a.jsxs(a.Fragment,{children:[a.jsxs(Q,{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:()=>i(!o),"aria-expanded":o,children:[o?a.jsx(Et,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(it,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(ra,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-foreground/70",children:e.name}),a.jsx("div",{className:"flex-1 min-w-2"}),!o&&a.jsx(ba,{add:e.additions,del:e.deletions,dimmed:!0})]}),o&&e.children.map(c=>a.jsx(n,{node:c,depth:t+1,turnIndex:s,canFocusFiles:r},c.fullPath))]})});function pfe(n){const e=V.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let r;e[0]!==s?(r=a.jsx(Q,{variant:"ghost",size:"xs",onClick:f=>{f.stopPropagation(),s()},className:"h-6 text-muted-foreground"}),e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(bx,{"data-icon":"inline-start"}),e[2]=o):o=e[2];let i;e[3]!==t?(i=a.jsx("span",{className:"font-mono text-xs",children:t}),e[3]=t,e[4]=i):i=e[4];let l;e[5]!==r||e[6]!==i?(l=a.jsxs(Zt,{render:r,children:[o,i]}),e[5]=r,e[6]=i,e[7]=l):l=e[7];const c=t!==1?"es":"";let u;e[8]!==t||e[9]!==c?(u=a.jsxs(Yt,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=u):u=e[10];let d;return e[11]!==l||e[12]!==u?(d=a.jsxs(Gt,{children:[l,u]}),e[11]=l,e[12]=u,e[13]=d):d=e[13],d}function Nm(n){const e=V.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=a.jsx(m8,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Cm(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("select-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(f8,{"data-slot":"context-menu-trigger",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function _m(n){const e=V.c(18);let t,s,r,o,i,l;e[0]!==n?({className:t,align:r,alignOffset:o,side:i,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=r===void 0?"start":r,u=o===void 0?4:o,d=i===void 0?"right":i,f=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=a.jsx(w4,{"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]!==u||e[14]!==d||e[15]!==f||e[16]!==p?(h=a.jsx(j4,{children:a.jsx(N4,{className:"isolate z-50 outline-none",align:c,alignOffset:u,side:d,sideOffset:f,children:p})}),e[12]=c,e[13]=u,e[14]=d,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function fi(n){const e=V.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=a.jsx(S4,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function H2e(n){const e=V.c(10);let t,s,r;e[0]!==n?({className:t,inset:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r||e[8]!==o?(i=a.jsx(C4,{"data-slot":"context-menu-label","data-inset":s,className:o,...r}),e[6]=s,e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function Rn(n){const e=V.c(12);let t,s,r,o;e[0]!==n?({className:t,inset:s,variant:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==t?(l=G("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==r||e[9]!==l||e[10]!==i?(c=a.jsx(k4,{"data-slot":"context-menu-item","data-inset":s,"data-variant":i,className:l,...r}),e[7]=s,e[8]=r,e[9]=l,e[10]=i,e[11]=c):c=e[11],c}function va(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(ox,{"data-slot":"context-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function hfe(n){const e=V.c(22),{children:t,turnIndex:s,branches:r,onRestoreToHere:o,onOpenBranches:i,onBranchFromHere:l}=n;let c;e[0]!==t?(c=a.jsx(Cm,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let u;e[2]!==o||e[3]!==s?(u=()=>o(s),e[2]=o,e[3]=s,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(hx,{"data-icon":"inline-start"}),e[5]=d):d=e[5];let f;e[6]!==u?(f=a.jsx(fi,{children:a.jsxs(Rn,{onClick:u,children:[d,"Restore to this point"]})}),e[6]=u,e[7]=f):f=e[7];let m;e[8]!==r.length||e[9]!==i||e[10]!==s?(m=r.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(va,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:()=>i(s),children:[a.jsx(bx,{"data-icon":"inline-start"}),"View branches (",r.length,")"]})})]}),e[8]=r.length,e[9]=i,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&a.jsxs(a.Fragment,{children:[a.jsx(va,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:()=>l(s),children:[a.jsx(Es,{"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=a.jsxs(_m,{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=a.jsxs(Nm,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function gfe(n){const e=V.c(5),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(g8,{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=a.jsx(_a,{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=a.jsx(h8,{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=a.jsx(Nf,{className:"size-5 text-warning"}),e[3]=s):s=e[3],s}case"completed":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pr,{className:"size-5 text-success"}),e[4]=s):s=e[4],s}default:return null}}const V3=2e3,fI=600;function mI(n){const e=V.c(23),{status:t,label:s,fading:r,startTimestamp:o}=n,i=r===void 0?!1:r,l=t.status==="completed",c=i?"opacity-0":"opacity-100";let u;e[0]!==c?(u=G("flex items-center gap-2.5 min-w-0 transition-opacity",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={transitionDuration:`${fI}ms`},e[2]=d):d=e[2];let f;e[3]!==t.status?(f=a.jsx(gfe,{status:t.status}),e[3]=t.status,e[4]=f):f=e[4];const m=!l&&"text-muted-foreground",p=l&&t.terminalReason&&"text-warning",h=l&&!t.terminalReason&&"text-success";let g;e[5]!==m||e[6]!==p||e[7]!==h?(g=G("text-xs font-medium shrink-0",m,p,h),e[5]=m,e[6]=p,e[7]=h,e[8]=g):g=e[8];let x;e[9]!==s||e[10]!==g?(x=a.jsx("span",{className:g,children:s}),e[9]=s,e[10]=g,e[11]=x):x=e[11];let b;e[12]!==l||e[13]!==o?(b=!l&&o&&a.jsx(tu,{startTimestamp:o}),e[12]=l,e[13]=o,e[14]=b):b=e[14];let w;e[15]!==t.pendingQueue?(w=(t.pendingQueue??0)>0&&a.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[15]=t.pendingQueue,e[16]=w):w=e[16];let v;return e[17]!==x||e[18]!==b||e[19]!==w||e[20]!==u||e[21]!==f?(v=a.jsxs("div",{className:u,style:d,children:[f,x,b,w]}),e[17]=x,e[18]=b,e[19]=w,e[20]=u,e[21]=f,e[22]=v):v=e[22],v}function xfe(n){var E;const e=V.c(36),{status:t,startTimestamp:s}=n,[r,o]=y.useState(!0);let i;e[0]!==t.backgroundAgents?(i=t.backgroundAgents??[],e[0]=t.backgroundAgents,e[1]=i):i=e[1];const l=i;let c;e[2]!==l?(c=l.filter(yfe),e[2]=l,e[3]=c):c=e[3];const u=c.length;let d;e[4]!==l||e[5]!==s?(d=((E=l.find(vfe))==null?void 0:E.startedAt)??s,e[4]=l,e[5]=s,e[6]=d):d=e[6];const f=d;let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(mi,{className:"size-4 shrink-0 text-info"}),e[7]=m):m=e[7];const p=u<l.length?`Waiting on ${u} of ${l.length} agents`:`Waiting on ${u} agent${u===1?"":"s"}`;let h;e[8]!==p?(h=a.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:p}),e[8]=p,e[9]=h):h=e[9];let g;e[10]!==t.pendingQueue?(g=(t.pendingQueue??0)>0&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[10]=t.pendingQueue,e[11]=g):g=e[11];let x;e[12]!==f?(x=f&&a.jsx(tu,{startTimestamp:f}),e[12]=f,e[13]=x):x=e[13];const b=!r&&"-rotate-90";let w;e[14]!==b?(w=G("size-3.5 text-muted-foreground transition-transform",b),e[14]=b,e[15]=w):w=e[15];let v;e[16]!==w?(v=a.jsx(Et,{className:w}),e[16]=w,e[17]=v):v=e[17];let j;e[18]!==v||e[19]!==g||e[20]!==x?(j=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[g,x,v]}),e[18]=v,e[19]=g,e[20]=x,e[21]=j):j=e[21];let k;e[22]!==j||e[23]!==h?(k=a.jsxs(rs,{className:"flex w-full min-w-0 items-center gap-2.5 px-3 py-2 text-left",children:[m,h,j]}),e[22]=j,e[23]=h,e[24]=k):k=e[24];let _;e[25]!==l?(_=l.length>1&&a.jsx(wfe,{agents:l}),e[25]=l,e[26]=_):_=e[26];let N;e[27]!==l?(N=l.map(bfe),e[27]=l,e[28]=N):N=e[28];let S;e[29]!==N?(S=a.jsx(yn,{children:a.jsx("ul",{className:"flex flex-col border-t border-border/40 py-1",children:N})}),e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==r||e[32]!==k||e[33]!==_||e[34]!==S?(C=a.jsxs(vn,{open:r,onOpenChange:o,className:"mx-4 my-3 rounded-lg border border-border/60 bg-muted/20","data-testid":"awaiting-agents",children:[k,_,S]}),e[31]=r,e[32]=k,e[33]=_,e[34]=S,e[35]=C):C=e[35],C}function bfe(n,e){return a.jsx(kfe,{agent:n},n.toolUseId??e)}function vfe(n){return n.startedAt}function yfe(n){return!n.done}function wfe(n){const e=V.c(4),{agents:t}=n;let s;e[0]!==t?(s=t.map(Sfe),e[0]=t,e[1]=s):s=e[1];let r;return e[2]!==s?(r=a.jsx("div",{className:"px-3 pb-2.5","aria-hidden":!0,children:a.jsx("div",{className:"flex h-1 gap-0.5",children:s})}),e[2]=s,e[3]=r):r=e[3],r}function Sfe(n,e){return a.jsx("span",{className:G("flex-1 rounded-full",n.done?"bg-success":"bg-info/25")},e)}function kfe(n){const e=V.c(21),{agent:t}=n,s=AA(t.done?void 0:t.toolUseId),r=t.done||void 0;let o;e[0]!==t.done?(o=t.done?a.jsx(Pr,{className:"mt-px size-3.5 shrink-0 text-success"}):a.jsx(p8,{className:"mt-px size-3.5 shrink-0 text-info"}),e[0]=t.done,e[1]=o):o=e[1];const i=t.done?"text-muted-foreground":"text-foreground";let l;e[2]!==i?(l=G("truncate text-xs",i),e[2]=i,e[3]=l):l=e[3];const c=t.description||void 0,u=t.description||"Agent";let d;e[4]!==l||e[5]!==c||e[6]!==u?(d=a.jsx("span",{className:l,title:c,children:u}),e[4]=l,e[5]=c,e[6]=u,e[7]=d):d=e[7];let f;e[8]!==s?(f=s&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s,children:s}),e[8]=s,e[9]=f):f=e[9];let m;e[10]!==d||e[11]!==f?(m=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[d,f]}),e[10]=d,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==t.done||e[14]!==t.startedAt?(p=t.done?a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"Done"}):t.startedAt&&a.jsx(tu,{startTimestamp:t.startedAt,className:"shrink-0"}),e[13]=t.done,e[14]=t.startedAt,e[15]=p):p=e[15];let h;return e[16]!==r||e[17]!==p||e[18]!==o||e[19]!==m?(h=a.jsxs("li",{className:"flex min-w-0 items-start gap-2.5 px-3 py-1.5","data-agent-done":r,children:[o,m,p]}),e[16]=r,e[17]=p,e[18]=o,e[19]=m,e[20]=h):h=e[20],h}function jfe(n){const e=V.c(28),{status:t,durationLabel:s}=n,[r,o]=y.useState("visible");let i,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const h=setTimeout(()=>o("fading"),V3),g=setTimeout(()=>o("ready"),V3+fI);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=i,e[1]=l):(i=e[0],l=e[1]),y.useEffect(i,l),r==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Pr,{className:"size-4 shrink-0 text-success"}),e[2]=h):h=e[2];const g=t.terminalReason?"text-warning":"text-muted-foreground";let x;e[3]!==g?(x=G("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?Rb(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let w;e[7]!==x||e[8]!==b?(w=a.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=w):w=e[9];let v;e[10]!==s?(v=s&&a.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=v):v=e[11];let j;return e[12]!==w||e[13]!==v?(j=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,v]}),e[12]=w,e[13]=v,e[14]=j):j=e[14],j}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Jc(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 u=c,d=r==="fading";let f;e[19]!==u||e[20]!==t||e[21]!==d?(f=a.jsx(mI,{status:t,label:u,fading:d}),e[19]=u,e[20]=t,e[21]=d,e[22]=f):f=e[22];let m;e[23]!==s?(m=s&&a.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=a.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 Nfe=y.memo(function(){const e=V.c(27),{session:t,isLive:s,sseState:r,isCompacting:o,pendingInteraction:i}=jt(),[l,c]=y.useState(!1),[u,d]=y.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=y.useState(f);f!==m&&(p(f),c(!1),d(!1));let h;e:{if(!t||r!=="connected"){h=null;break e}if(o){let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={status:"compacting"},e[0]=R):R=e[0],h=R;break e}const $=t.rawMessages;let A;e[1]!==$?(A=X6($),e[1]=$,e[2]=A):A=e[2],h=A}const g=h;let x,b;e[3]!==g||e[4]!==s||e[5]!==u?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!u&&c(!0);return}if(g.status==="completed"){d(!0);return}c(!1),d(!1)}},b=[g,s,u],e[3]=g,e[4]=s,e[5]=u,e[6]=x,e[7]=b):(x=e[6],b=e[7]),y.useEffect(x,b);let w;e:{if(!g){w=null;break e}if(g.status==="compacting"){w=g;break e}if(g.status==="completed"){if(l){w=null;break e}if(!s&&!u){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const v=w,j=(v==null?void 0:v.status)==="completed",k=(t==null?void 0:t.turns[t.turns.length-1])??null;let _;e:{if(!j||!k){_=null;break e}let $;if(e[8]!==k){const A=Ox(k);$=A!==null?Js(A):null,e[8]=k,e[9]=$}else $=e[9];_=$}const N=_;if(i&&r==="connected"){let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(gx,{className:"size-5 shrink-0 text-info"}),e[10]=$):$=e[10];const A=i.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let R;return e[11]!==A?(R=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[$,a.jsx("span",{className:"text-xs font-medium text-info",children:A})]}),e[11]=A,e[12]=R):R=e[12],R}if(!v)return null;if(j){let $;return e[13]!==v||e[14]!==N?($=a.jsx(jfe,{status:v,durationLabel:N}),e[13]=v,e[14]=N,e[15]=$):$=e[15],$}if(v.status==="awaiting_agents"){const $=k==null?void 0:k.timestamp;let A;return e[16]!==v||e[17]!==$?(A=a.jsx(xfe,{status:v,startTimestamp:$}),e[16]=v,e[17]=$,e[18]=A):A=e[18],A}let S;e[19]!==v.status||e[20]!==v.terminalReason||e[21]!==v.toolName?(S=Jc(v.status,v.toolName,v.terminalReason),e[19]=v.status,e[20]=v.terminalReason,e[21]=v.toolName,e[22]=S):S=e[22];const C=S;if(!C)return null;const E=k==null?void 0:k.timestamp;let T;return e[23]!==v||e[24]!==C||e[25]!==E?(T=a.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:a.jsx(mI,{status:v,label:C,startTimestamp:E})}),e[23]=v,e[24]=C,e[25]=E,e[26]=T):T=e[26],T});function tu(n){const e=V.c(3),{startTimestamp:t,className:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(Cfe,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Cfe(n){const e=V.c(12),{startTimestamp:t,className:s}=n;let r;e[0]!==t?(r=new Date(t).getTime(),e[0]=t,e[1]=r):r=e[1];const o=r,i=y.useRef(null);let l,c;e[2]!==o?(l=()=>{const h=setInterval(()=>{const g=i.current;g&&(g.textContent=Js(Math.max(0,Date.now()-o)))},1e3);return()=>clearInterval(h)},c=[o],e[2]=o,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c);let u;e[5]!==s?(u=G("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=u):u=e[6];const d=Math.max(0,Date.now()-o);let f;e[7]!==d?(f=Js(d),e[7]=d,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=a.jsx("span",{ref:i,className:u,children:f}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function _fe(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 r of n.assistantText)if(r.toLowerCase().includes(t))return!0;for(const r of n.contentBlocks)if(r.kind==="queued_prompt"&&r.content.toLowerCase().includes(t)||r.kind==="agent_message"&&(r.sender.toLowerCase().includes(t)||r.body.toLowerCase().includes(t)))return!0;for(const r of n.thinking)if(r.thinking.toLowerCase().includes(t))return!0;for(const r of n.toolCalls)if(r.name.toLowerCase().includes(t)||JSON.stringify(r.input).toLowerCase().includes(t)||(s=r.result)!=null&&s.toLowerCase().includes(t))return!0;return!1}const Efe=6e5;function Tfe(n,e){const t=n[e].timestamp,s=e>0?n[e-1].timestamp:void 0;if(!t||!s)return 0;const r=Date.parse(t)-Date.parse(s);return!Number.isFinite(r)||r<=0?0:Math.min(r,Efe)}function H3(n,e){const t=[],s=[];let r=0,o=0,i=e;for(;i<n.length;){const l=n[i];if(l.kind==="thinking")t.push({kind:"thinking",blocks:l.blocks}),r+=l.blocks.length,o+=Tfe(n,i),i++;else if(l.kind==="tool_calls")t.push({kind:"tool_calls",toolCalls:l.toolCalls}),s.push(...l.toolCalls),i++;else break}return{items:t,toolCalls:s,thinkingCount:r,thoughtForMs:o,nextIndex:i}}const pI=y.createContext(null);function bd(n){const e=V.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(pI.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Sn(){const n=y.useContext(pI);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const O1=new Map,Afe=300*1e3;function K3(n){const e=O1.get(n);return e?Date.now()>e.expiresAt?(O1.delete(n),null):e.data:null}function Ife(n,e){O1.set(n,{data:e,expiresAt:Date.now()+Afe})}function Pfe(n){const e=V.c(5);let t;e[0]!==n?(t=()=>n?K3(sn(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,r]=y.useState(t),o=y.useRef("");let i,l;return e[2]!==n?(i=()=>{if(!n||lm(window.location.pathname))return;const c=sn(n),u=K3(c);if(u){r(u);return}o.current=n;const d=new AbortController;return Ce(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:d.signal}).then(async f=>{if(d.signal.aborted||o.current!==n||!f.ok)return;const m=await f.json();if(d.signal.aborted||o.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});Ife(c,p),r(p)}).catch($fe),()=>d.abort()},l=[n],e[2]=n,e[3]=i,e[4]=l):(i=e[3],l=e[4]),y.useEffect(i,l),s}function $fe(){}const Rfe=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification","local_command"]),Ofe=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),Lfe=new Set(["AskUserQuestion","ExitPlanMode"]),Mfe=new Set(["text","thinking","tool_calls"]);function zfe(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>Lfe.has(e.name)&&e.result==null)}function Dfe(n,e){for(let t=n.length-1;t>=0;t--){if(zfe(n[t]))return t;if(Mfe.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 Wu={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function Ffe(n,e="settled",t){if(n.length===0||!n.some(l=>Ofe.has(l.kind)))return Wu;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 Wu}const r=Dfe(n,t),o=[];let i=0;for(let l=0;l<n.length;l++){if(l===s||l===r)continue;const c=n[l];Rfe.has(c.kind)||(o.push(l),c.kind==="tool_calls"&&(i+=c.toolCalls.length))}return o.length===0?Wu:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function Ufe(n,e){return n!==null&&n>0?`Worked for ${Js(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const hI="border border-border bg-prompt-surface",G3="border-l border-border/40",Z3="border-l border-border";function gI(n){const e=V.c(21),{turn:t,index:s,branchCount:r}=n,o=r===void 0?0:r,{state:i,isMobile:l}=Sn(),{activeTurnIndex:c,activeToolCallId:u,expandAll:d,expandToolPayloads:f}=i,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x,pendingInteraction:b}=jt(),w=p&&m!==null,v=w&&s===((m==null?void 0:m.turns.length)??0)-1;let j=!v;if(v&&m){let T;if(e[0]!==m.rawMessages){const{status:$}=X6(m.rawMessages);T=$f.has($),e[0]=m.rawMessages,e[1]=T}else T=e[1];j=!T}const k=(m==null?void 0:m.cwd)??"",_=Pfe(k),N=(b==null?void 0:b.type)==="question"?b.toolUseId:void 0,S=c===s,C=!g.enabled||h?void 0:g.requestUndo;let E;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.handleOpenBranches||e[5]!==u||e[6]!==o||e[7]!==k||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==v||e[12]!==l||e[13]!==w||e[14]!==j||e[15]!==N||e[16]!==_||e[17]!==S||e[18]!==C||e[19]!==t?(E=a.jsx(qfe,{turn:t,openQuestionId:N,index:s,branchCount:o,isActive:S,activeToolCallId:u,expandAll:d,expandToolPayloads:f,isAgentActive:v,isSessionLive:w,isTurnDone:j,isMobile:l,cwd:k,skillMetadata:_,onRestoreToHere:C,onOpenBranches:x.handleOpenBranches,onEditCommand:x.handleEditCommand,onExpandCommand:x.handleExpandCommand}),e[2]=x.handleEditCommand,e[3]=x.handleExpandCommand,e[4]=x.handleOpenBranches,e[5]=u,e[6]=o,e[7]=k,e[8]=d,e[9]=f,e[10]=s,e[11]=v,e[12]=l,e[13]=w,e[14]=j,e[15]=N,e[16]=_,e[17]=S,e[18]=C,e[19]=t,e[20]=E):E=e[20],E}function Bfe(n){const e=V.c(12),{index:t,children:s}=n,{session:r,isSubAgentView:o,undoRedo:i,actions:l}=jt(),{requestUndo:c,branchesAtTurn:u}=i,{handleOpenBranches:d,handleBranchFromHere:f}=l,m=t>=((r==null?void 0:r.turns.length)??0);if(!i.enabled||o||m||!c||!d){let g;return e[0]!==s?(g=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=g):g=e[1],g}let p;e[2]!==u||e[3]!==t?(p=u(t),e[2]=u,e[3]=t,e[4]=p):p=e[4];let h;return e[5]!==s||e[6]!==f||e[7]!==d||e[8]!==t||e[9]!==c||e[10]!==p?(h=a.jsx(hfe,{turnIndex:t,branches:p,onRestoreToHere:c,onOpenBranches:d,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=d,e[8]=t,e[9]=c,e[10]=p,e[11]=h):h=e[11],h}function Wfe(n){const e=V.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:r}=n;if(s){let i;return e[0]!==r||e[1]!==t?(i=Ufe(Ox(t),r),e[0]=r,e[1]=t,e[2]=i):i=e[2],i}if(!t.timestamp)return"Working";let o;return e[3]!==t.timestamp?(o=a.jsxs("span",{className:"inline-flex items-baseline gap-1",children:["Working for",a.jsx(tu,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=o):o=e[4],o}const qfe=y.memo(function(e){const t=V.c(83),{turn:s,index:r,branchCount:o,isActive:i,activeToolCallId:l,expandAll:c,expandToolPayloads:u,isAgentActive:d,isSessionLive:f,isTurnDone:m,isMobile:p,cwd:h,skillMetadata:g,onRestoreToHere:x,onOpenBranches:b,onEditCommand:w,onExpandCommand:v,openQuestionId:j}=e;let k;t[0]!==h||t[1]!==s.subAgentActivity||t[2]!==s.toolCalls?(k=mf(s.toolCalls,h)||s.subAgentActivity.some(K=>mf(K.toolCalls,h)),t[0]=h,t[1]=s.subAgentActivity,t[2]=s.toolCalls,t[3]=k):k=t[3];const _=k,N=m?"settled":"working";let S;t[4]!==N||t[5]!==j||t[6]!==s.contentBlocks?(S=Ffe(s.contentBlocks,N,j),t[4]=N,t[5]=j,t[6]=s.contentBlocks,t[7]=S):S=t[7];const C=S;let E;t[8]!==m?(E=()=>m?void 0:!0,t[8]=m,t[9]=E):E=t[9];const[T,$]=y.useState(E),A=T??(c||!m);let R;e:{if(!C.foldable){let se;t[10]===Symbol.for("react.memo_cache_sentinel")?(se=[],t[10]=se):se=t[10];let X;t[11]===Symbol.for("react.memo_cache_sentinel")?(X=[],t[11]=X):X=t[11];let ne;t[12]===Symbol.for("react.memo_cache_sentinel")?(ne={leadingBlocks:se,trailingBlocks:X},t[12]=ne):ne=t[12],R=ne;break e}const K=C.foldAnchorIndex;let Z;t[13]!==C.foldedIndices?(Z=new Set(C.foldedIndices),t[13]=C.foldedIndices,t[14]=Z):Z=t[14];const Y=Z;let J;t[15]!==K||t[16]!==s.contentBlocks?(J=s.contentBlocks.slice(0,K),t[15]=K,t[16]=s.contentBlocks,t[17]=J):J=t[17];let ee;if(t[18]!==K||t[19]!==Y||t[20]!==s.contentBlocks||t[21]!==A){let se;t[23]!==K||t[24]!==Y||t[25]!==A?(se=(X,ne)=>A||!Y.has(K+ne),t[23]=K,t[24]=Y,t[25]=A,t[26]=se):se=t[26],ee=s.contentBlocks.slice(K).filter(se),t[18]=K,t[19]=Y,t[20]=s.contentBlocks,t[21]=A,t[22]=ee}else ee=t[22];let te;t[27]!==J||t[28]!==ee?(te={leadingBlocks:J,trailingBlocks:ee},t[27]=J,t[28]=ee,t[29]=te):te=t[29],R=te}const{leadingBlocks:P,trailingBlocks:z}=R;let L;t[30]!==l||t[31]!==c||t[32]!==u||t[33]!==d||t[34]!==p||t[35]!==f||t[36]!==g||t[37]!==s.contentBlocks||t[38]!==s.effort||t[39]!==s.id||t[40]!==s.model?(L={turnId:s.id,originalBlocks:s.contentBlocks,model:s.model,effort:s.effort,expandAll:c,expandToolPayloads:u,activeToolCallId:l,isAgentActive:d,isSessionLive:f,isMobile:p,skillMetadata:g},t[30]=l,t[31]=c,t[32]=u,t[33]=d,t[34]=p,t[35]=f,t[36]=g,t[37]=s.contentBlocks,t[38]=s.effort,t[39]=s.id,t[40]=s.model,t[41]=L):L=t[41];const I=L,M=p?"px-0 py-5":"px-4 py-5",F=i&&"rounded-lg ring-1 ring-ring/40";let U;t[42]!==M||t[43]!==F?(U=G("group relative",M,F),t[42]=M,t[43]=F,t[44]=U):U=t[44];let O;t[45]!==o||t[46]!==r||t[47]!==p||t[48]!==m||t[49]!==b||t[50]!==x||t[51]!==s?(O=a.jsx(Vfe,{index:r,turn:s,branchCount:o,isTurnDone:m,isMobile:p,onRestoreToHere:x,onOpenBranches:b}),t[45]=o,t[46]=r,t[47]=p,t[48]=m,t[49]=b,t[50]=x,t[51]=s,t[52]=O):O=t[52];let D;t[53]!==r||t[54]!==w||t[55]!==v||t[56]!==s.timestamp||t[57]!==s.userMessage?(D=s.userMessage&&a.jsx(Bfe,{index:r,children:a.jsx("div",{"data-turn-prompt":!0,className:G("rounded-lg p-3",hI),children:a.jsx(zb,{content:s.userMessage,timestamp:s.timestamp,onEditCommand:w,onExpandCommand:v})})}),t[53]=r,t[54]=w,t[55]=v,t[56]=s.timestamp,t[57]=s.userMessage,t[58]=D):D=t[58];let B;t[59]!==I||t[60]!==C.foldable||t[61]!==C.hiddenToolCalls||t[62]!==m||t[63]!==P||t[64]!==z||t[65]!==s||t[66]!==A?(B=C.foldable?a.jsxs(a.Fragment,{children:[P.length>0&&a.jsx(Xh,{blocks:P,...I}),a.jsx(wde,{label:a.jsx(Wfe,{turn:s,isTurnDone:m,hiddenToolCalls:C.hiddenToolCalls}),expanded:A,onToggle:()=>$(!A)}),z.length>0&&a.jsx(Xh,{blocks:z,...I})]}):a.jsx(Xh,{blocks:s.contentBlocks,...I}),t[59]=I,t[60]=C.foldable,t[61]=C.hiddenToolCalls,t[62]=m,t[63]=P,t[64]=z,t[65]=s,t[66]=A,t[67]=B):B=t[67];let q;t[68]!==h||t[69]!==_||t[70]!==r||t[71]!==m||t[72]!==s?(q=m&&_&&a.jsx(ffe,{turn:s,turnIndex:r,cwd:h}),t[68]=h,t[69]=_,t[70]=r,t[71]=m,t[72]=s,t[73]=q):q=t[73];let W;t[74]!==D||t[75]!==B||t[76]!==q?(W=a.jsxs("div",{className:"flex flex-col gap-3",children:[D,B,q]}),t[74]=D,t[75]=B,t[76]=q,t[77]=W):W=t[77];let H;return t[78]!==r||t[79]!==W||t[80]!==U||t[81]!==O?(H=a.jsxs("div",{"data-turn-index":r,className:U,children:[O,W]}),t[78]=r,t[79]=W,t[80]=U,t[81]=O,t[82]=H):H=t[82],H});function Vfe(n){const e=V.c(26),{index:t,turn:s,branchCount:r,isTurnDone:o,isMobile:i,onRestoreToHere:l,onOpenBranches:c}=n,u=!o&&!!s.timestamp;let d;e[0]!==o||e[1]!==s?(d=o?Ox(s):null,e[0]=o,e[1]=s,e[2]=d):d=e[2];const f=d,m=i?"mb-2 gap-1.5":"mb-4 gap-2";let p;e[3]!==m?(p=G("flex items-center",m),e[3]=m,e[4]=p):p=e[4];const h=t+1;let g;e[5]!==h?(g=a.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]!==u||e[9]!==s.timestamp?(x=a.jsx(Hfe,{durationMs:f,showLiveTimer:u,timestamp:s.timestamp}),e[7]=f,e[8]=u,e[9]=s.timestamp,e[10]=x):x=e[10];let b;e[11]!==t||e[12]!==i||e[13]!==l?(b=l&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:G("ml-auto text-muted-foreground transition-opacity hover:text-foreground",i?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[a.jsx(hx,{"data-icon":"inline-start"}),a.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=i,e[13]=l,e[14]=b):b=e[14];let w;e[15]!==r||e[16]!==t||e[17]!==c||e[18]!==l?(w=r>0&&c&&a.jsx("div",{className:G(!l&&"ml-auto"),children:a.jsx(pfe,{branchCount:r,onClick:()=>c(t)})}),e[15]=r,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==w?(v=a.jsxs("div",{className:p,children:[g,x,b,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=w,e[25]=v):v=e[25],v}function Hfe(n){const e=V.c(8),{durationMs:t,showLiveTimer:s,timestamp:r}=n;if(t!==null){let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Po,{className:"size-3","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=Js(t),e[1]=t,e[2]=i):i=e[2];let l;return e[3]!==i?(l=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[o,i]}),e[3]=i,e[4]=l):l=e[4],l}if(s){let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Po,{className:"size-3","data-icon":"inline-start"}),e[5]=o):o=e[5];let i;return e[6]!==r?(i=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[o,a.jsx(tu,{startTimestamp:r,className:"tabular-nums"})]}),e[6]=r,e[7]=i):i=e[7],i}return null}function Kfe(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 Xh(n){const e=V.c(13),{blocks:t,turnId:s,originalBlocks:r,model:o,effort:i,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,isSessionLive:f,isMobile:m,skillMetadata:p}=n;let h;if(e[0]!==u||e[1]!==t||e[2]!==i||e[3]!==l||e[4]!==c||e[5]!==d||e[6]!==m||e[7]!==f||e[8]!==o||e[9]!==r||e[10]!==p||e[11]!==s){const g=[],x=m?"ml-0 pl-2":"ml-1 pl-3",b=new Map,w=(j,k)=>{const _=Kfe(j)??`at-${k}`,N=b.get(_)??0;return b.set(_,N+1),N===0?_:`${_}#${N}`};let v=0;for(;v<t.length;){const j=t[v];if(j.kind==="thinking"||j.kind==="tool_calls"){const{items:k,toolCalls:_,thinkingCount:N,thoughtForMs:S,nextIndex:C}=H3(t,v),E=k.length===1&&k[0].kind==="tool_calls";g.push(a.jsx("div",{className:G(G3,x),children:a.jsx(R3,{toolCalls:_,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,activityItems:E?void 0:k,thinkingCount:N,thoughtForMs:S,skillMetadata:p})},w(j,v))),v=C;continue}if(j.kind==="text"){const{items:k,toolCalls:_,thinkingCount:N,thoughtForMs:S,nextIndex:C}=H3(t,v+1);g.push(a.jsxs("div",{children:[a.jsx("div",{className:G("flex flex-col","gap-3"),children:j.text.map((E,T)=>a.jsx(jle,{text:E,model:o,effort:i,timestamp:j.timestamp,messageKey:`${s}:${r.indexOf(j)}:${T}`},T))}),(_.length>0||N>0)&&a.jsx("div",{className:G("mt-1.5",G3,x),children:a.jsx(R3,{toolCalls:_,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,activityItems:N>0?k:void 0,thinkingCount:N,thoughtForMs:S,skillMetadata:p})})]},w(j,v))),v=C;continue}if(j.kind==="queued_prompt"){g.push(a.jsxs("div",{className:G("rounded-lg p-3",hI),children:[a.jsx(Fe,{variant:"outline",className:"mb-2",children:"Queued while working"}),a.jsx(zb,{content:j.content,timestamp:j.timestamp??""})]},w(j,v))),v++;continue}if(j.kind==="agent_message"){g.push(a.jsx(Sle,{sender:j.sender,body:j.body,reply:j.reply,timestamp:j.timestamp,isLive:f},w(j,v))),v++;continue}if(j.kind==="sub_agent"){g.push(a.jsx("div",{className:G(Z3,x),children:a.jsx(v3,{messages:j.messages,expandAll:l,label:"Sub-agent activity",countLabel:"subagents active"})},w(j,v))),v++;continue}if(j.kind==="background_agent"){g.push(a.jsx("div",{className:G(Z3,x),children:a.jsx(v3,{messages:j.messages,expandAll:l,label:"Background agent activity",countLabel:"agents active"})},w(j,v))),v++;continue}if(j.kind==="hook_event"){g.push(a.jsx(qle,{events:j.events},w(j,v))),v++;continue}if(j.kind==="plan_mode"){g.push(a.jsx(hde,{plan:j.plan,planFilePath:j.planFilePath,status:j.status,toolCalls:j.toolCalls,expandAll:l,expandToolPayloads:c,isAgentActive:d,skillMetadata:p},w(j,v))),v++;continue}if(j.kind==="recap"){g.push(a.jsx(gde,{content:j.content},w(j,v))),v++;continue}if(j.kind==="task_notification"){g.push(a.jsx(rie,{content:j.content},w(j,v))),v++;continue}if(j.kind==="local_command"){g.push(a.jsx(jae,{content:j.content,contextUsage:j.contextUsage,usageReport:j.usageReport},w(j,v))),v++;continue}v++}h=a.jsx(a.Fragment,{children:g}),e[0]=u,e[1]=t,e[2]=i,e[3]=l,e[4]=c,e[5]=d,e[6]=m,e[7]=f,e[8]=o,e[9]=r,e[10]=p,e[11]=s,e[12]=h}else h=e[12];return h}const Gfe={auto:"auto",manual:"manual",idle:"while idle"};function Zfe(n){if(!n)return null;const e=Gfe[n.trigger]??"auto";return n.postTokens!=null?`${e} · ${vt(n.preTokens)} → ${vt(n.postTokens)}`:`${e} · ${vt(n.preTokens)}`}const Yfe=y.memo(function(e){const t=V.c(29),{summary:s,meta:r}=e,[o,i]=y.useState(!1);let l;t[0]!==r?(l=Zfe(r),t[0]=r,t[1]=l):l=t[1];const c=l;let u;t[2]!==s?(u=s==null?void 0:s.trim(),t[2]=s,t[3]=u):u=t[3];const d=u;let f;t[4]!==d||t[5]!==o?(f=d&&(o?a.jsx(Et,{className:"size-3","data-icon":"inline-start"}):a.jsx(it,{className:"size-3","data-icon":"inline-start"})),t[4]=d,t[5]=o,t[6]=f):f=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(x8,{className:"size-3","data-icon":"inline-start"}),p=a.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&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:c})]}),t[9]=c,t[10]=h):h=t[10];let g;t[11]!==f||t[12]!==h?(g=a.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(!d){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=N):N=t[14];let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=S):S=t[15];let C;return t[16]!==x?(C=a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,S]}),t[16]=x,t[17]=C):C=t[17],C}let b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx(Q,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),w=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=b,t[19]=w):(b=t[18],w=t[19]);let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=v):v=t[20];let j;t[21]!==x?(j=a.jsxs(rs,{render:b,children:[w,x,v]}),t[21]=x,t[22]=j):j=t[22];let k;t[23]!==d?(k=a.jsx(yn,{children:a.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:a.jsx(nr,{remarkPlugins:Or,components:As,children:d})})}),t[23]=d,t[24]=k):k=t[24];let _;return t[25]!==o||t[26]!==j||t[27]!==k?(_=a.jsxs(vn,{open:o,onOpenChange:i,className:"px-4 py-2",children:[j,k]}),t[25]=o,t[26]=j,t[27]=k,t[28]=_):_=t[28],_}),Xfe=1.5;function Jfe(n,e){return e<=0?!1:n<e*Xfe}function Qfe(n,e){return n===0&&!e}function eme(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function tme(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const nme=/<image\b[^>]*>[\s\S]*?<\/image>|!\[image\]\(<[^>]*>\)|\[audio attachment\]\(<[^>]*>\)/g;function Y3(n){return n.replace(nme,"").trim()}function sme(n,e){const t=n[n.length-1],s=t==null?void 0:t.contentBlocks[t.contentBlocks.length-1];if(!(e!=null&&e.opensOnPrompt)||(s==null?void 0:s.kind)!=="queued_prompt")return n;const r=Y3(s.content);return!r||r!==Y3(Da(e.userMessage))?n:[...n.slice(0,-1),{...t,contentBlocks:t.contentBlocks.slice(0,-1)}]}const rme=1e3;function ome(n){const e=new Map;return n.map(t=>{if(!t.contentBlocks.some(r=>r.kind==="agent_message"))return t;const s=t.contentBlocks.filter(r=>{if(r.kind!=="agent_message")return!0;const o=Date.parse(r.timestamp??"");if(Number.isNaN(o))return!0;const i=`${r.sender}\0${r.body}`,l=e.get(i);return l!==void 0&&Math.abs(o-l)<=rme?!1:(e.set(i,o),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function xI(n,e,t){const s=new Set(n.map(u=>u.id)),r=e.filter(u=>!s.has(u.id));if(r.length===0)return n;const o=sme(r,n[0]),i=n[0],l=o[o.length-1],c=i&&l&&tme(i,t)?[...o.slice(0,-1),ame(l,i),...n.slice(1)]:[...o,...n];return LT(xb(ome(c)))}function ime(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 ame(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:ime(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function lme(){const n=V.c(10),{session:e,isSubAgentView:t,undoRedo:s}=jt(),{canRedo:r,redoTurnCount:o,redoGhostTurns:i,requestRedoAll:l,requestRedoUpTo:c}=s,u=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!r||!l)return null;let d;n[0]!==o||n[1]!==l?(d=a.jsx(hle,{redoTurnCount:o,onRedoAll:l}),n[0]=o,n[1]=l,n[2]=d):d=n[2];let f;n[3]!==i||n[4]!==c||n[5]!==u?(f=i.length>0&&a.jsx("div",{className:"select-none",children:i.map((p,h)=>a.jsxs("div",{className:"group/ghost relative opacity-25 hover:opacity-40 transition-opacity",children:[a.jsx(gI,{turn:p,index:u+h}),c&&a.jsxs(Q,{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:[a.jsx(b8,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=i,n[4]=c,n[5]=u,n[6]=f):f=n[6];let m;return n[7]!==d||n[8]!==f?(m=a.jsxs(a.Fragment,{children:[d,f]}),n[7]=d,n[8]=f,n[9]=m):m=n[9],m}function cme(n){const e=V.c(5),{hasMore:t,isLoadingOlder:s}=n;let r;e[0]!==t||e[1]!==s?(r=s?a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(St,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:a.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=a.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:r}),e[3]=r,e[4]=o):o=e[4],o}function ume(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function dme({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:r=!1,onLoadMore:o}){const{state:{activeTurnIndex:i}}=Sn(),{undoRedo:l}=jt(),c=y.useRef(null),u=y.useRef(null),[d,f]=y.useState(0),m=y.useMemo(()=>{const v=new Map;return n.map(j=>{const k=v.get(j.turn.id)??0;return v.set(j.turn.id,k+1),{...j,key:k===0?j.turn.id:`${j.turn.id}#${k}`}})},[n]),p=y.useRef(null),h=y.useMemo(()=>eme(p.current,m.map(v=>v.key)),[m]);y.useLayoutEffect(()=>{var v;p.current={firstKey:(v=m[0])==null?void 0:v.key,length:m.length}},[m]);const g=y.useRef(t);y.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;y.useLayoutEffect(()=>{const v=e.current,j=u.current;if(!v||!j)return;const k=j.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;f(_=>Math.abs(_-k)<1?_:k)},[e,x]),y.useEffect(()=>{if(!t||!o||!r||s)return;const v=e.current;if(!v)return;const j=()=>{Jfe(v.scrollTop,v.clientHeight)&&o()};return j(),v.addEventListener("scroll",j,{passive:!0}),()=>v.removeEventListener("scroll",j)},[t,s,r,o,m.length,e]);const b=y.useMemo(()=>{const v=new Map;for(let j=0;j<m.length;j++)v.set(m[j].index,j);return v},[m]),w=y.useRef(null);return y.useEffect(()=>{var j;if(i===null){w.current=null;return}if(i===w.current)return;w.current=i;const v=b.get(i);v!==void 0&&((j=c.current)==null||j.scrollToIndex(v,{align:"start",smooth:!0}))},[i,b]),a.jsxs(a.Fragment,{children:[x&&a.jsx(cme,{hasMore:t,isLoadingOlder:s}),a.jsx("div",{ref:u,className:"motion-session-enter",children:a.jsx(ple,{ref:c,scrollRef:e,startMargin:d,shift:h,children:m.map(({turn:v,index:j,key:k})=>a.jsxs("div",{"data-turn-index":j,children:[(v.compactionSummary||v.compactionMeta)&&a.jsx(Yfe,{summary:v.compactionSummary,meta:v.compactionMeta}),!ume(v)&&a.jsx(gI,{turn:v,index:j,branchCount:l.branchesAtTurn?l.branchesAtTurn(j).length:0})]},k))})}),a.jsx(lme,{})]})}const fme=y.memo(function(e){const t=V.c(19),{chatScrollRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l}=e,{state:c}=Sn(),{searchQuery:u,sessionChangeKey:d}=c,{session:f}=jt(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(mme):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==u?(g=u?h.filter(j=>{const{turn:k}=j;return _fe(k,u)}):h,t[2]=h,t[3]=u,t[4]=g):g=t[4];const x=g;let b;t[5]!==x.length||t[6]!==r||t[7]!==u?(b=u?x.length===0:Qfe(x.length,r??!1),t[5]=x.length,t[6]=r,t[7]=u,t[8]=b):b=t[8];const w=b;let v;return t[9]!==s||t[10]!==x||t[11]!==r||t[12]!==o||t[13]!==l||t[14]!==i||t[15]!==u||t[16]!==d||t[17]!==w?(v=a.jsx(Foe,{children:w?a.jsx(Ln,{className:"min-h-64 border-0",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:u?a.jsx(v8,{}):a.jsx(F4,{})}),a.jsx(zn,{children:u?"No matching turns":"No conversation yet"}),a.jsx(Dn,{children:u?"Try a different search term.":"Messages and tool activity will appear here."})]})}):a.jsx(dme,{filteredTurns:x,scrollContainerRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l},d)}),t[9]=s,t[10]=x,t[11]=r,t[12]=o,t[13]=l,t[14]=i,t[15]=u,t[16]=d,t[17]=w,t[18]=v):v=t[18],v});function mme(n,e){return{turn:n,index:e}}const pme="[data-turn-index]",bI="[data-turn-prompt]",X3=1,hme=120,J3=180;function gme(n,e){if(!n.userMessage)return null;const t=Da(n.userMessage),{body:s}=ca(t),{remainingText:r}=Gx(s),o=e5(r),i=Zx(o,e);if(i)return i;if(!o){const c=t5(t);if(!c)return null;const u=n5(t);return u?`/${c} ${u}`:`/${c}`}const l=o.split(`
|
|
461
|
-
`)[0];return l.length>J3?`${l.slice(0,J3)}...`:l}function xme(n,e,t){for(let s=e;s>=0;s--){const r=n[s];if(!r)continue;const o=gme(r,t);if(o)return{index:s,text:o}}return null}function bme(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(pme)){const c=l.getBoundingClientRect().top;if(c>e+X3)break;t=l,s=c}if(!t)return null;const r=Number(t.dataset.turnIndex);if(!Number.isInteger(r))return null;const o=t.querySelector(bI);return(o?o.getBoundingClientRect().bottom>e+X3:s+hme>e)?null:r}const vme=y.memo(function(e){const t=V.c(23),{session:s,scrollContainerRef:r}=e,[o,i]=y.useState(null);let l,c;t[0]!==r||t[1]!==s.sessionId?(l=()=>{const k=r.current;if(!k)return;let _=null;const N=()=>{_=null;const T=bme(k);i($=>T===null?null:($==null?void 0:$.sessionId)===s.sessionId&&$.index===T?$:{sessionId:s.sessionId,index:T})},S=()=>{_===null&&(_=requestAnimationFrame(N))};i(null),k.addEventListener("scroll",S,{passive:!0});const C=new MutationObserver(S);C.observe(k,{childList:!0,subtree:!0});const E=new ResizeObserver(S);return E.observe(k),k.firstElementChild&&E.observe(k.firstElementChild),S(),()=>{k.removeEventListener("scroll",S),C.disconnect(),E.disconnect(),_!==null&&cancelAnimationFrame(_)}},c=[r,s.sessionId],t[0]=r,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);const u=Ra();let d;e:{if(!o||o.sessionId!==s.sessionId){d=null;break e}let k;t[4]!==u||t[5]!==s.turns||t[6]!==o.index?(k=xme(s.turns,o.index,u),t[4]=u,t[5]=s.turns,t[6]=o.index,t[7]=k):k=t[7],d=k}const f=d;if(!f)return null;let m;t[8]!==f.index||t[9]!==r?(m=()=>{const k=r.current;if(!k)return;const _=k.querySelector(`[data-turn-index="${f.index}"]`),N=(_==null?void 0:_.querySelector(bI))??_;if(!N)return;const S=k.scrollTop+N.getBoundingClientRect().top-k.getBoundingClientRect().top;k.scrollTo({top:Math.max(0,S),behavior:"smooth"})},t[8]=f.index,t[9]=r,t[10]=m):m=t[10];const p=m,h=`Scroll to turn ${f.index+1} prompt`;let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(F4,{"data-icon":"inline-start"}),t[11]=g):g=t[11];const x=f.index+1;let b;t[12]!==x?(b=a.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",x]}),t[12]=x,t[13]=b):b=t[13];let w;t[14]!==f.text?(w=a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[14]=f.text,t[15]=w):w=t[15];let v;t[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(ja,{"data-icon":"inline-end",className:"ml-auto"}),t[16]=v):v=t[16];let j;return t[17]!==f.text||t[18]!==p||t[19]!==h||t[20]!==b||t[21]!==w?(j=a.jsxs(Q,{type:"button",variant:"outline",size:"sm","aria-label":h,title:f.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-popover px-3 text-left shadow-sm",onClick:p,children:[g,b,w,v]}),t[17]=f.text,t[18]=p,t[19]=h,t[20]=b,t[21]=w,t[22]=j):j=t[22],j});function L1({path:n,dirName:e,command:t}){return qo()?(console.warn("[open-terminal] unavailable for remote devices"),!1):!n&&!e?(console.warn("[open-terminal] no project path available"),!1):(Ce("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,dirName:e,...t?{command:t}:{}})}).then(s=>{s.ok||s.json().then(r=>console.error("[open-terminal]",r.error)).catch(()=>{})}).catch(s=>console.error("[open-terminal] fetch failed:",s)),!0)}const yme={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},wme=1440*60*1e3;function Sme(n){return(n&&yme[n])??"usage"}function kme(n){if(n===null)return null;const e=new Date(n*1e3);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now()>wme;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function jme(n){return n===void 0?"":n?"Extra usage is on but did not cover this. ":"Extra usage is off for this account. "}function Nme(n){const e=V.c(36),{block:t,dirName:s,fileName:r,cwd:o,terminal:i}=n;let l,c;e[0]!==o||e[1]!==s||e[2]!==r?(l=vs(s),c=Cx(l.kind,Ed(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=l,e[4]=c):(l=e[3],c=e[4]);const u=c;let d;e[5]!==t.resetsAt?(d=kme(t.resetsAt),e[5]=t.resetsAt,e[6]=d):d=e[6];const f=d,m=t.lowPriority&&l.capabilities.lowPriorityInTerminal;let p;e[7]!==m||e[8]!==i?(p=m&&i&&!qo(),e[7]=m,e[8]=i,e[9]=p):p=e[9];const h=p;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Po,{}),e[10]=g):g=e[10];const x=l.displayName;let b;e[11]!==t.limit?(b=Sme(t.limit),e[11]=t.limit,e[12]=b):b=e[12];let w;e[13]!==l.displayName||e[14]!==b?(w=a.jsxs(Xt,{children:[x," hit its ",b," limit"]}),e[13]=l.displayName,e[14]=b,e[15]=w):w=e[15];const v=f?`Resets at ${f}. `:"";let j;e[16]!==t.extraUsage?(j=jme(t.extraUsage),e[16]=t.extraUsage,e[17]=j):j=e[17];let k;e[18]!==u||e[19]!==m?(k=m?a.jsxs(a.Fragment,{children:["It can keep this session going before then at lower priority, spending your weekly allowance to do it — a mode that exists only in its own terminal. Resume there with ",a.jsx("code",{className:"font-mono",children:u}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[18]=u,e[19]=m,e[20]=k):k=e[20];let _;e[21]!==k||e[22]!==v||e[23]!==j?(_=a.jsxs("span",{children:[v,j,k]}),e[21]=k,e[22]=v,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==h||e[26]!==u||e[27]!==o||e[28]!==s?(N=h&&a.jsx(Q,{size:"sm",variant:"outline",onClick:()=>L1({path:o??void 0,dirName:s,command:u}),children:"Open in terminal"}),e[25]=h,e[26]=u,e[27]=o,e[28]=s,e[29]=N):N=e[29];let S;e[30]!==_||e[31]!==N?(S=a.jsxs(_t,{className:"flex flex-col items-start gap-2",children:[_,N]}),e[30]=_,e[31]=N,e[32]=S):S=e[32];let C;return e[33]!==S||e[34]!==w?(C=a.jsxs(kt,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[g,w,S]}),e[33]=S,e[34]=w,e[35]=C):C=e[35],C}function Cme(n){const e=V.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=a.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&&a.jsx(Q3,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=a.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 r;e[7]!==t.text?(r=a.jsx(PA,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(Q3,{}),e[9]=s,e[10]=o):o=e[10];let i;return e[11]!==r||e[12]!==o?(i=a.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[r,o]}),e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function Q3(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.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 _me=y.memo(function(){const e=V.c(9),t=Fb();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=Tle(t);if(c.length===0){i=null;break e}const u=new Map;s="px-4",r="streaming-turn-overlay",o=c.map(d=>{const f=u.get(d.messageId)??0;u.set(d.messageId,f+1);const m=d.blocks.reduce(Eme,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(Cme,{block:p,showCursor:!d.stopped&&h===m},p.index))},`${d.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i}else s=e[1],r=e[2],o=e[3],i=e[4];if(i!==Symbol.for("react.early_return_sentinel"))return i;let l;return e[5]!==s||e[6]!==r||e[7]!==o?(l=a.jsx("div",{className:s,"data-testid":r,children:o}),e[5]=s,e[6]=r,e[7]=o,e[8]=l):l=e[8],l});function Eme(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class vI extends y.Component{constructor(t){super(t);Ge(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?a.jsx("div",{className:"flex justify-center p-8",children:a.jsxs(kt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(er,{}),a.jsx(Xt,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(_t,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(Hr,{className:"static col-start-2 mt-2",children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const ej="find-in-session-highlight",Jh="find-in-session-active";function Tme(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 Ame=y.forwardRef(function(e,t){const s=V.c(63),{scrollContainerRef:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],s[0]=u):u=s[0];const[d,f]=y.useState(u),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==r?(g=()=>{const X=r.current;if(!X)return;X.querySelectorAll(`mark.${ej}`).forEach(Ime)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=X=>{if(x(),!X||!r.current){f([]),p(-1);return}const ne=r.current,ae=Tme(ne),ie=X.toLowerCase(),re=[];for(const de of ae){const ce=de.nodeValue||"",oe=ce.toLowerCase();let fe=0;const ue=[];for(;;){const be=oe.indexOf(ie,fe);if(be===-1)break;ue.push(be),fe=be+1}if(ue.length===0)continue;const le=de.parentNode;if(!le)continue;const pe=document.createDocumentFragment();let ge=0;for(const be of ue){be>ge&&pe.appendChild(document.createTextNode(ce.slice(ge,be)));const ve=document.createElement("mark");ve.className=ej,ve.textContent=ce.slice(be,be+X.length),pe.appendChild(ve),re.push(ve),ge=be+X.length}ge<ce.length&&pe.appendChild(document.createTextNode(ce.slice(ge))),le.replaceChild(pe,de)}f(re),re.length>0?(p(0),re[0].classList.add(Jh),re[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==d?(v=X=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(Jh);const ne=(X%d.length+d.length)%d.length;d[ne].classList.add(Jh),d[ne].scrollIntoView({block:"center",behavior:"smooth"}),p(ne)},s[6]=m,s[7]=d,s[8]=v):v=s[8];const j=v;let k;s[9]!==x?(k=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=k):k=s[10];const _=k;let N,S;s[11]!==_||s[12]!==o?(N=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var X;return(X=h.current)==null?void 0:X.focus()})},close:_,isOpen:o}),S=[_,o],s[11]=_,s[12]=o,s[13]=N,s[14]=S):(N=s[13],S=s[14]),y.useImperativeHandle(t,N,S);let C,E;s[15]!==w||s[16]!==l?(C=()=>{const X=setTimeout(()=>w(l),150);return()=>clearTimeout(X)},E=[l,w],s[15]=w,s[16]=l,s[17]=C,s[18]=E):(C=s[17],E=s[18]),y.useEffect(C,E);let T,$;s[19]!==x?(T=()=>()=>x(),$=[x],s[19]=x,s[20]=T,s[21]=$):(T=s[20],$=s[21]),y.useEffect(T,$);let A;s[22]!==m||s[23]!==j||s[24]!==_?(A=X=>{X.key==="Escape"?(X.preventDefault(),X.stopPropagation(),_()):X.key==="Enter"&&(X.preventDefault(),X.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=_,s[25]=A):A=s[25];const R=A;if(!o)return null;let P;s[26]===Symbol.for("react.memo_cache_sentinel")?(P=X=>c(X.target.value),s[26]=P):P=s[26];let z;s[27]!==R||s[28]!==l?(z=a.jsx(Go,{ref:h,value:l,onChange:P,onKeyDown:R,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=R,s[28]=l,s[29]=z):z=s[29];const L=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let I;s[30]!==L?(I=a.jsx(Ar,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:L})}),s[30]=L,s[31]=I):I=s[31];let M;s[32]!==z||s[33]!==I?(M=a.jsxs(Ko,{className:"w-64",children:[z,I]}),s[32]=z,s[33]=I,s[34]=M):M=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 U=d.length===0,O=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let D;s[38]!==O?(D=G("text-muted-foreground",O),s[38]=O,s[39]=D):D=s[39];let B;s[40]===Symbol.for("react.memo_cache_sentinel")?(B=a.jsx(ja,{"data-icon":"inline-start"}),s[40]=B):B=s[40];let q;s[41]!==F||s[42]!==U||s[43]!==D?(q=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,disabled:U,className:D,"aria-label":"Previous match",children:B}),s[41]=F,s[42]=U,s[43]=D,s[44]=q):q=s[44];let W;s[45]!==m||s[46]!==j?(W=()=>j(m+1),s[45]=m,s[46]=j,s[47]=W):W=s[47];const H=d.length===0,K=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==K?(Z=G("text-muted-foreground",K),s[48]=K,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(Et,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let J;s[51]!==W||s[52]!==H||s[53]!==Z?(J=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:W,disabled:H,className:Z,"aria-label":"Next match",children:Y}),s[51]=W,s[52]=H,s[53]=Z,s[54]=J):J=s[54];let ee;s[55]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(Mt,{"data-icon":"inline-start"}),s[55]=ee):ee=s[55];let te;s[56]!==_?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:ee}),s[56]=_,s[57]=te):te=s[57];let se;return s[58]!==M||s[59]!==q||s[60]!==J||s[61]!==te?(se=a.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:[M,q,J,te]}),s[58]=M,s[59]=q,s[60]=J,s[61]=te,s[62]=se):se=s[62],se});function Ime(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const yI=[1,2,3,4,5,6,7,8,9],K2e=["General","View","Tools"],Em=[{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}},...yI.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}}],wI="cogpit-keybindings";let oi=null;function SI(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function xc(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function Pme(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Gb(){if(oi)return oi;try{const n=localStorage.getItem(wI);if(!n)return oi={};const e=JSON.parse(n);if(!e||typeof e!="object")return oi={};const t={};for(const s of Em){const r=e[s.command];Pme(r)&&(t[s.command]=r)}return oi=t}catch{return oi={}}}function Zb(n){oi=n;try{localStorage.setItem(wI,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function nu(n){const e=Em.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Gb()[n]??e.defaultShortcut}function G2e(){return Object.fromEntries(Em.map(n=>[n.command,nu(n.command)]))}function Z2e(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:xc(e.key)};Zb({...Gb(),[n]:t})}function Y2e(n){const e={...Gb()};delete e[n],Zb(e)}function X2e(){Zb({})}function J2e(n){return{key:xc(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function kI(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function on(n,e){const t=nu(n);return"doubleTapModifier"in t||xc(e.key)!==xc(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 Mi(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 $me(n){const e=SI();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Mi(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Mi(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Mi(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Mi(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Mi(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Mi(n.key)].filter(Boolean).join("+")}function ea(n){return $me(nu(n))}function tj(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${xc(n.key)}|${t}|${s}|${r}|${o}`;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 Q2e(n,e){const t=new Set(tj(n));return Em.find(s=>s.command!==e&&tj(nu(s.command)).some(r=>t.has(r)))??null}function nj(n){return"doubleTapModifier"in nu(n)?SI()?"Meta":"Control":null}const Rme=yI.map(n=>`device.switch.${n}`),Ome="device.cycle";function Lme(n){const e=Rme.findIndex(t=>on(t,n));return e===-1?null:e+1}function Mme(n){return on(Ome,n)}const M1="cogpit:find-in-conversation",Tm=y.memo(function(e){const t=V.c(87),{searchInputRef:s,hasTodos:r,hasMore:o,isLoadingOlder:i,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:u}=e,d=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=Sn(),{session:h,sessionSource:g,rateLimit:x,permissions:b,isSubAgentView:w}=jt(),v=Nn("terminal"),{chat:j,scroll:k}=Wf(),{searchQuery:_}=f,{pendingMessages:N}=j,{chatScrollRef:S,observeChatContent:C,handleScroll:E,canScrollDown:T,scrollToBottomInstant:$,initialScrollDone:A}=k,R=y.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var we;return(we=R.current)==null?void 0:we.open()},t[0]=P):P=t[0];const z=P;let L,I;t[1]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{const we=function($e){on("findInConversation",$e)&&($e.preventDefault(),z())};return window.addEventListener("keydown",we),window.addEventListener(M1,z),()=>{window.removeEventListener("keydown",we),window.removeEventListener(M1,z)}},I=[z],t[1]=L,t[2]=I):(L=t[1],I=t[2]),y.useEffect(L,I);let M,F;t[3]!==p||t[4]!==d||t[5]!==s?(M=()=>{!p||!d||requestAnimationFrame(()=>{var we;return(we=s.current)==null?void 0:we.focus()})},F=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=M,t[7]=F):(M=t[6],F=t[7]),y.useEffect(M,F);let U;t[8]!==m||t[9]!==u?(U=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=U):U=t[10];const O=U,D=h;let B;t[11]!==x||t[12]!==g?(B=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=B):B=t[13];const q=B,W=D.turns.length>0||N.length===0;let H;t[14]!==O||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==_?(H=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(Ko,{className:"h-9 flex-1",children:[a.jsx(Go,{ref:s,value:_,onChange:we=>m({type:"SET_SEARCH_QUERY",value:we.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(Ar,{align:"inline-start",children:a.jsx(ss,{})})]}),a.jsx(Q,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:a.jsx(Mt,{"data-icon":"inline-start"})})]}),t[14]=O,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=_,t[20]=H):H=t[20];let K;t[21]!==v||t[22]!==D.cwd||t[23]!==p||t[24]!==b.send||t[25]!==q?(K=q&&a.jsx("div",{className:G("shrink-0",!p&&"pt-10"),children:a.jsx(Nme,{...q,cwd:D.cwd,terminal:v&&b.send})}),t[21]=v,t[22]=D.cwd,t[23]=p,t[24]=b.send,t[25]=q,t[26]=K):K=t[26];let Z;t[27]!==S?(Z=a.jsx(Ame,{ref:R,scrollContainerRef:S}),t[27]=S,t[28]=Z):Z=t[28];let Y;t[29]!==S||t[30]!==D?(Y=a.jsx(vme,{session:D,scrollContainerRef:S}),t[29]=S,t[30]=D,t[31]=Y):Y=t[31];const J=p&&"mobile-scroll";let ee;t[32]!==J?(ee=G("h-full overflow-x-hidden overflow-y-auto",J),t[32]=J,t[33]=ee):ee=t[33];let te;t[34]!==p||t[35]!==q?(te=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6",q?"pt-4":"pt-14"),t[34]=p,t[35]=q,t[36]=te):te=t[36];let se;t[37]!==r||t[38]!==p?(se=p?void 0:{paddingBottom:`max(var(--session-footer-height, 0px), ${r?12:8}rem)`},t[37]=r,t[38]=p,t[39]=se):se=t[39];let X;t[40]!==S||t[41]!==o||t[42]!==A||t[43]!==i||t[44]!==l||t[45]!==W?(X=W&&a.jsx(fme,{chatScrollRef:S,hasMore:o,isLoadingOlder:i,pagingEnabled:A,onLoadMore:l}),t[40]=S,t[41]=o,t[42]=A,t[43]=i,t[44]=l,t[45]=W,t[46]=X):X=t[46];let ne,ae;t[47]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(_me,{}),ae=a.jsx(Nfe,{}),t[47]=ne,t[48]=ae):(ne=t[47],ae=t[48]);const ie=b.send&&!w;let re;t[49]!==D.sessionId||t[50]!==D.turns||t[51]!==p||t[52]!==N||t[53]!==ie?(re=a.jsx(hA,{sessionId:D.sessionId,turns:D.turns,pendingMessages:N,canManage:ie,isMobile:p}),t[49]=D.sessionId,t[50]=D.turns,t[51]=p,t[52]=N,t[53]=ie,t[54]=re):re=t[54];let de;t[55]!==X||t[56]!==re?(de=a.jsxs(vI,{fallbackMessage:"Failed to render conversation timeline",children:[X,ne,ae,re]}),t[55]=X,t[56]=re,t[57]=de):de=t[57];let ce;t[58]!==C||t[59]!==te||t[60]!==se||t[61]!==de?(ce=a.jsx("div",{ref:C,className:te,style:se,children:de}),t[58]=C,t[59]=te,t[60]=se,t[61]=de,t[62]=ce):ce=t[62];let oe;t[63]!==S||t[64]!==E||t[65]!==ee||t[66]!==ce?(oe=a.jsx("div",{ref:S,onScroll:E,className:ee,children:ce}),t[63]=S,t[64]=E,t[65]=ee,t[66]=ce,t[67]=oe):oe=t[67];const fe=T?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",ue=p?"right-3 bottom-3":"right-5";let le;t[68]!==fe||t[69]!==ue?(le=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",fe,ue),t[68]=fe,t[69]=ue,t[70]=le):le=t[70];let pe;t[71]!==p?(pe=p?void 0:{bottom:"calc(var(--session-footer-height, 0px) + 1.25rem)"},t[71]=p,t[72]=pe):pe=t[72];let ge;t[73]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx(y8,{"data-icon":"inline-start"}),t[73]=ge):ge=t[73];let be;t[74]!==$||t[75]!==le||t[76]!==pe?(be=a.jsx(Q,{size:"icon",className:le,style:pe,onClick:$,"aria-label":"Scroll to bottom",children:ge}),t[74]=$,t[75]=le,t[76]=pe,t[77]=be):be=t[77];let ve;t[78]!==Z||t[79]!==Y||t[80]!==oe||t[81]!==be?(ve=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[Z,Y,oe,be]}),t[78]=Z,t[79]=Y,t[80]=oe,t[81]=be,t[82]=ve):ve=t[82];let Se;return t[83]!==K||t[84]!==ve||t[85]!==H?(Se=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[H,K,ve]}),t[83]=K,t[84]=ve,t[85]=H,t[86]=Se):Se=t[86],Se});function zme({open:n,onOpenChange:e,trigger:t,title:s,description:r,confirmLabel:o,destructive:i=!1,onConfirm:l}){const[c,u]=y.useState(!1),[d,f]=y.useState(null);function m(h){c||(f(null),e(h))}async function p(){u(!0),f(null);try{f(await l())}finally{u(!1)}}return a.jsxs(rb,{open:n,onOpenChange:m,children:[t&&a.jsx(Lte,{render:t}),a.jsxs(ob,{size:"sm",children:[a.jsxs(ib,{children:[a.jsx(lb,{children:s}),a.jsx(cb,{children:r})]}),d&&a.jsx(Eo,{className:"text-center",children:d}),a.jsxs(ab,{children:[a.jsx(db,{disabled:c,children:"Cancel"}),a.jsxs(ub,{variant:i?"destructive":"default",disabled:c,onClick:()=>void p(),children:[c&&a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),o]})]})]})]})}function Dme(n){const e=V.c(21),{children:t,error:s,busy:r,saveLabel:o,onCancel:i,onSave:l,className:c}=n;let u;e[0]!==c?(u=G("flex flex-col gap-3 border-t px-3 py-3",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]!==s?(d=s&&a.jsx(Eo,{children:s}),e[2]=s,e[3]=d):d=e[3];let f;e[4]!==i?(f=a.jsx(Q,{variant:"outline",size:"sm",onClick:i,children:"Cancel"}),e[4]=i,e[5]=f):f=e[5];let m;e[6]!==r||e[7]!==o?(m=r?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):o,e[6]=r,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==l||e[11]!==m?(p=a.jsx(Q,{size:"sm",disabled:r,onClick:l,children:m}),e[9]=r,e[10]=l,e[11]=m,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==p?(h=a.jsxs("div",{className:"flex justify-end gap-1.5",children:[f,p]}),e[13]=f,e[14]=p,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==u||e[18]!==d||e[19]!==h?(g=a.jsxs("div",{className:u,children:[t,d,h]}),e[16]=t,e[17]=u,e[18]=d,e[19]=h,e[20]=g):g=e[20],g}const Fme={ArrowUp:-1,ArrowDown:1};function sj(n,e,t){const s=n.filter(r=>r!==e);return s.splice(t,0,e),s}function rj(n,e){return n.length===e.length&&n.every((t,s)=>t===e[s])}function Ume(n,e){const t=V.c(26),[s,r]=y.useState(null),[o,i]=y.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Map,t[0]=l):l=t[0];const c=y.useRef(l),u=y.useRef(null),d=y.useRef(0),f=y.useRef(null);let m;t[1]!==s||t[2]!==n?(m=s??[...n],t[1]=s,t[2]=n,t[3]=m):m=t[3];const p=m;let h;t[4]!==n||t[5]!==e?(h={ids:n,onCommit:e},t[4]=n,t[5]=e,t[6]=h):h=t[6];const g=y.useRef(h);let x;t[7]!==n||t[8]!==e?(x=()=>{g.current={ids:n,onCommit:e}},t[7]=n,t[8]=e,t[9]=x):x=t[9],y.useLayoutEffect(x);let b;t[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const L=u.current,I=L&&c.current.get(L.id);if(!L||!I)return;I.style.transform="";const M=I.getBoundingClientRect().top;I.style.transform=`translateY(${d.current-L.grabOffset-M}px)`},t[10]=b):b=t[10];const w=b;let v;t[11]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{w()},t[11]=v):v=t[11];let j;t[12]!==s?(j=[s,w],t[12]=s,t[13]=j):j=t[13],y.useLayoutEffect(v,j);let k;t[14]===Symbol.for("react.memo_cache_sentinel")?(k=L=>I=>{I?c.current.set(L,I):c.current.delete(L)},t[14]=k):k=t[14];const _=k,N=y.useRef(null);let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=L=>{var U;const I=u.current;if(!I)return;u.current=null,(U=N.current)==null||U.call(N),N.current=null;const M=c.current.get(I.id);M&&(M.style.transform="");const F=f.current;f.current=null,i(null),r(null),L&&F&&!rj(F,I.startOrder)&&g.current.onCommit(F)},t[15]=S):S=t[15];const C=S;let E,T;t[16]===Symbol.for("react.memo_cache_sentinel")?(T=()=>()=>{var L;return(L=N.current)==null?void 0:L.call(N)},E=[],t[16]=E,t[17]=T):(E=t[16],T=t[17]),y.useEffect(T,E);let $;t[18]===Symbol.for("react.memo_cache_sentinel")?($=L=>{const I=u.current;if(!I||I.pointerId!==L.pointerId)return;d.current=L.clientY;const M=f.current;if(!M)return;const F=M.filter(O=>{var B;if(O===I.id)return!1;const D=(B=c.current.get(O))==null?void 0:B.getBoundingClientRect();return!!D&&D.top+D.height/2<L.clientY}).length,U=sj(M,I.id,F);rj(U,M)||(f.current=U,r(U)),w()},t[18]=$):$=t[18];const A=$;let R;t[19]!==n||t[20]!==e?(R=L=>({onPointerDown:I=>{if(I.button!==0||u.current)return;const M=c.current.get(L);if(!M)return;d.current=I.clientY,u.current={id:L,pointerId:I.pointerId,grabOffset:I.clientY-M.getBoundingClientRect().top,startOrder:[...n]};const F=[...n];f.current=F,i(L),r(F);const U=D=>{D.pointerId===I.pointerId&&C(!0)},O=D=>{D.pointerId===I.pointerId&&C(!1)};window.addEventListener("pointermove",A),window.addEventListener("pointerup",U),window.addEventListener("pointercancel",O),N.current=()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",O)}},onKeyDown:I=>{const M=Fme[I.key];if(M===void 0)return;I.preventDefault();const F=n.indexOf(L),U=F+M;F===-1||U<0||U>=n.length||e(sj(n,L,U))}}),t[19]=n,t[20]=e,t[21]=R):R=t[21];const P=R;let z;return t[22]!==o||t[23]!==P||t[24]!==p?(z={order:p,draggingId:o,rowRef:_,handleProps:P},t[22]=o,t[23]=P,t[24]=p,t[25]=z):z=t[25],z}const z1="cogpit-devices-changed",jI="cogpit:devices-changed";function NI(n){typeof n.connectionRevision=="number"&&pR(n.id,n.connectionRevision)}function D1(n,e,t=!1){window.dispatchEvent(new CustomEvent(z1,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(jI,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function oj(n){NI(n),D1(n.id,n.connectionRevision)}function ij(n){const e=Kt();e!==Ot&&!n.some(t=>t.id===e)&&Xs(Ot)}function Qh(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function CI(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function Bme(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.signIn;if(t==="account"||t==="password")return t}}function Si({enabled:n=!0}={}){const[e,t]=y.useState([]),[s,r]=y.useState(!0),[o,i]=y.useState(()=>Kt()),l=y.useRef(0),c=y.useRef(Promise.resolve()),u=y.useRef(0),d=y.useCallback(async()=>{const w=++l.current;if(!n){t([]),r(!1);return}try{const v=await Ur("/api/hub/devices");if(v.status===403&&w===l.current&&ij([]),!v.ok)return;const j=await zs(v);if(w!==l.current)return;const k=Array.isArray(j==null?void 0:j.devices)?j.devices:[];for(const _ of k)NI(_);if(u.current>0)return;t(k),ij(k)}catch{}finally{w===l.current&&r(!1)}},[n]);y.useEffect(()=>{d()},[d]),y.useEffect(()=>{const w=()=>i(Kt()),v=()=>void d(),j=N=>{if(N.key===jI){try{const S=JSON.parse(N.newValue??"null");(S==null?void 0:S.removed)===!0&&typeof S.deviceId=="string"&&Kt()===S.deviceId&&Xs(Ot)}catch{}d()}},k=()=>{l.current+=1,t([]),r(!0),d()},_=()=>{l.current+=1,t([]),r(!1)};return window.addEventListener("cogpit-device-changed",w),window.addEventListener("popstate",w),window.addEventListener(z1,v),window.addEventListener("storage",j),window.addEventListener("cogpit-auth-changed",k),window.addEventListener("cogpit-identity-changed",k),window.addEventListener("cogpit-auth-required",_),()=>{window.removeEventListener("cogpit-device-changed",w),window.removeEventListener("popstate",w),window.removeEventListener(z1,v),window.removeEventListener("storage",j),window.removeEventListener("cogpit-auth-changed",k),window.removeEventListener("cogpit-identity-changed",k),window.removeEventListener("cogpit-auth-required",_)}},[d]);const f=y.useMemo(()=>o===Ot?void 0:e.find(w=>w.id===o),[e,o]),m=y.useCallback(async(w,v,j,k)=>{try{const _=await Ur("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:w,port:v,allowLocalTunnel:j,tls:k})}),N=await zs(_);return(N==null?void 0:N.ok)===!0&&N.hello?{ok:!0,hello:N.hello}:{ok:!1,code:(N==null?void 0:N.code)??"UNREACHABLE",error:typeof(N==null?void 0:N.error)=="string"?N.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),p=y.useCallback(async w=>{try{const v=await Ur("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w)}),j=await zs(v);if(v.ok&&(j!=null&&j.device)){const k=j.device;return oj(k),{ok:!0,device:k}}return{ok:!1,code:(j==null?void 0:j.code)??"ERROR",error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),h=y.useCallback(async(w,v)=>{try{const j=await Ur(Qh(w),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(v)}),k=await zs(j);if(j.ok&&(k!=null&&k.device)){const _=k.device;return oj(_),{ok:!0,device:_}}return{ok:!1,code:(k==null?void 0:k.code)??"ERROR",error:typeof(k==null?void 0:k.error)=="string"?k.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),g=y.useCallback(async w=>{try{const v=await Ur(Qh(w),{method:"DELETE"});if(v.ok)return Kt()===w&&Xs(Ot),D1(w,void 0,!0),{ok:!0};const j=await zs(v);return{ok:!1,error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),x=y.useCallback(async w=>{const v=new Map(w.map((C,E)=>[C,E])),j=C=>v.get(C.id)??w.length;t(C=>[...C].sort((E,T)=>j(E)-j(T))),u.current+=1;const k=async()=>{try{const C=await Ur("/api/hub/devices/order",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ids:w})}),E=await zs(C);return C.ok&&Array.isArray(E==null?void 0:E.devices)?{result:{ok:!0},devices:E.devices}:{result:{ok:!1,error:typeof(E==null?void 0:E.error)=="string"?E.error:"Could not reorder the devices."}}}catch{return{result:{ok:!1,error:"Could not reorder the devices."}}}},_=c.current.then(k);c.current=_.then(()=>{});const{result:N,devices:S}=await _;return u.current-=1,u.current===0&&(S?(t(S),D1("")):d()),N},[d]),b=y.useCallback(async w=>{try{const v=await Ur(Qh(w,"/test"),{method:"POST"});return await zs(v)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:e,activeDeviceId:o,activeDevice:f,loading:s,refresh:d,probe:m,addDevice:p,updateDevice:h,removeDevice:g,reorderDevices:x,testDevice:b}}const aj=o_.version,Wme=19384,qme=443,Vme=450,Hme=ea("device.switch.1").replace(/1$/,"1–9"),Kme=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),Gme=new Set(["ACCOUNT_REFUSED"]);function qu(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),r=/^(.+):(\d+)$/.exec(s),o=r?r[1]:s,i=r?Number(r[2]):void 0;return t?{host:o,port:i,tls:!0}:{host:o,port:i}}function Zme(n,e,t){if(n.ok){if(n.hello.signIn==="account"&&n.hello.setupRequired===!0)return{tone:"info",text:"Reachable server — finish its setup before adding it here."};if(n.hello.signIn!=="account"&&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}"`:"",r=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${r}.`}}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 _I={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function Yme(n){const e=V.c(10),{tone:t}=n,s=_I[t];let r;e[0]!==s?(r=G("size-3.5 shrink-0",s),e[0]=s,e[1]=r):r=e[1];const o=r;if(t==="ok"){let l;return e[2]!==o?(l=a.jsx(Pr,{"data-icon":"inline-start",className:o}),e[2]=o,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==o?(l=a.jsx(er,{"data-icon":"inline-start",className:o}),e[4]=o,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==o?(l=a.jsx(Fn,{"data-icon":"inline-start",className:o}),e[6]=o,e[7]=l):l=e[7],l}let i;return e[8]!==o?(i=a.jsx(Bo,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const Xme={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function Jme(n){const e=V.c(119),{device:t,onRename:s,onCredentials:r,onRemove:o,onTest:i,slot:l,rowRef:c,dragging:u,dragHandleProps:d}=n,[f,m]=y.useState(!1),[p,h]=y.useState(t.name),[g,x]=y.useState(!1),[b,w]=y.useState(t.username??""),[v,j]=y.useState(""),[k,_]=y.useState(null),[N,S]=y.useState(!1),[C,E]=y.useState(null);let T,$;e[0]!==t.name?(T=()=>{h(t.name)},$=[t.name],e[0]=t.name,e[1]=T,e[2]=$):(T=e[1],$=e[2]),y.useEffect(T,$);let A,R;e[3]!==t.username?(A=()=>{w(t.username??"")},R=[t.username],e[3]=t.username,e[4]=A,e[5]=R):(A=e[4],R=e[5]),y.useEffect(A,R);let P;e[6]!==t?(P=CI(t),e[6]=t,e[7]=P):P=e[7];const z=P,L=z!==void 0&&z!==aj;let I;e[8]!==t?(I=Bme(t),e[8]=t,e[9]=I):I=e[9];const M=I==="account",F=l<=9;let U;e[10]!==t.id||e[11]!==t.name||e[12]!==p||e[13]!==s?(U=async function(){const ye=p.trim();if(!ye||ye===t.name){m(!1),h(t.name);return}E("rename"),await s(t.id,ye),E(null),m(!1)},e[10]=t.id,e[11]=t.name,e[12]=p,e[13]=s,e[14]=U):U=e[14];const O=U;let D;e[15]!==v||e[16]!==b||e[17]!==t.auth||e[18]!==t.id||e[19]!==t.username||e[20]!==r?(D=async function(){const ye=b.trim(),Re=t.username??"",Ve=ye!==Re,He=v.length>0;if(!Ve&&!He){x(!1),j(""),_(null);return}if(t.auth==="none"&&!He){_("Enter a password when adding an account to an unauthenticated device.");return}const me={};Ve&&(me.username=ye||null),He&&(me.password=v),E("credentials"),_(null);const je=await r(t.id,me);if(E(null),!je.ok){_(je.error);return}x(!1),j("")},e[15]=v,e[16]=b,e[17]=t.auth,e[18]=t.id,e[19]=t.username,e[20]=r,e[21]=D):D=e[21];const B=D,q=u&&"relative z-10 shadow-lg";let W;e[22]!==q?(W=G("rounded-lg border bg-card",q),e[22]=q,e[23]=W):W=e[23];const H=`Reorder ${t.name}`;let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(w8,{className:"size-4"}),e[24]=K):K=e[24];let Z;e[25]!==d||e[26]!==H?(Z=a.jsx("button",{type:"button","aria-label":H,title:"Drag to reorder (or use ↑ ↓)",className:"-ml-1 flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",...d,children:K}),e[25]=d,e[26]=H,e[27]=Z):Z=e[27];let Y;e[28]!==F||e[29]!==l?(Y=F?`${ea(`device.switch.${l}`)} opens this device`:"No shortcut",e[28]=F,e[29]=l,e[30]=Y):Y=e[30];const J=F&&l;let ee;e[31]!==Y||e[32]!==J?(ee=a.jsx("span",{className:"w-4 shrink-0 text-center font-mono text-xs text-muted-foreground",title:Y,children:J}),e[31]=Y,e[32]=J,e[33]=ee):ee=e[33];const te=`Status: ${t.runtime.authState}`,se=Xme[t.runtime.authState];let X;e[34]!==se?(X=G("size-2 shrink-0 rounded-full",se),e[34]=se,e[35]=X):X=e[35];let ne;e[36]!==te||e[37]!==X?(ne=a.jsx("span",{"aria-label":te,className:X}),e[36]=te,e[37]=X,e[38]=ne):ne=e[38];let ae;e[39]!==t.auth||e[40]!==t.name||e[41]!==f||e[42]!==p||e[43]!==O||e[44]!==L||e[45]!==z?(ae=f?a.jsx(On,{value:p,autoFocus:!0,"aria-label":`Rename ${t.name}`,onChange:We=>h(We.target.value),onKeyDown:We=>{We.key==="Enter"&&O(),We.key==="Escape"&&(m(!1),h(t.name))},onBlur:()=>void O(),className:"h-6 text-sm"}):a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate text-sm text-foreground",children:t.name}),z&&a.jsxs("span",{className:G("shrink-0 font-mono text-xs",L?"text-warning":"text-muted-foreground"),title:L?`Device runs v${z}; hub runs v${aj}`:void 0,children:["v",z,L&&" ≠ hub"]}),t.auth==="none"&&a.jsx(Fe,{variant:"secondary",children:"Unauthenticated"})]}),e[39]=t.auth,e[40]=t.name,e[41]=f,e[42]=p,e[43]=O,e[44]=L,e[45]=z,e[46]=ae):ae=e[46];const ie=t.tls?"https://":"";let re;e[47]!==t.host||e[48]!==t.port||e[49]!==ie?(re=a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[ie,t.host,":",t.port]}),e[47]=t.host,e[48]=t.port,e[49]=ie,e[50]=re):re=e[50];let de;e[51]!==M||e[52]!==t.username?(de=t.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:t.username,children:["Account: ",t.username]}):M?a.jsx("span",{className:"text-xs text-warning",children:"Account not configured"}):null,e[51]=M,e[52]=t.username,e[53]=de):de=e[53];let ce;e[54]!==ae||e[55]!==re||e[56]!==de?(ce=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[ae,re,de]}),e[54]=ae,e[55]=re,e[56]=de,e[57]=ce):ce=e[57];const oe=`Re-test ${t.name}`,fe=C==="test";let ue;e[58]!==t.id||e[59]!==i?(ue=async()=>{E("test"),await i(t.id),E(null)},e[58]=t.id,e[59]=i,e[60]=ue):ue=e[60];const le=C==="test"&&"animate-spin";let pe;e[61]!==le?(pe=G(le),e[61]=le,e[62]=pe):pe=e[62];let ge;e[63]!==pe?(ge=a.jsx(Fn,{"data-icon":"inline-start",className:pe}),e[63]=pe,e[64]=ge):ge=e[64];let be;e[65]!==oe||e[66]!==fe||e[67]!==ue||e[68]!==ge?(be=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":oe,disabled:fe,onClick:ue,children:ge}),e[65]=oe,e[66]=fe,e[67]=ue,e[68]=ge,e[69]=be):be=e[69];const ve=`Edit account for ${t.name}`;let Se;e[70]!==t.username?(Se=()=>{x(Qme),w(t.username??""),j(""),_(null)},e[70]=t.username,e[71]=Se):Se=e[71];let we;e[72]===Symbol.for("react.memo_cache_sentinel")?(we=a.jsx(S8,{"data-icon":"inline-start"}),e[72]=we):we=e[72];let Ee;e[73]!==ve||e[74]!==Se?(Ee=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":ve,onClick:Se,children:we}),e[73]=ve,e[74]=Se,e[75]=Ee):Ee=e[75];const $e=`Rename ${t.name}`;let Be,qe;e[76]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>m(!0),qe=a.jsx(wr,{"data-icon":"inline-start"}),e[76]=Be,e[77]=qe):(Be=e[76],qe=e[77]);let ze;e[78]!==$e?(ze=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":$e,onClick:Be,children:qe}),e[78]=$e,e[79]=ze):ze=e[79];const Ie=`Remove ${t.name}`;let Me;e[80]===Symbol.for("react.memo_cache_sentinel")?(Me=a.jsx(kf,{"data-icon":"inline-start"}),e[80]=Me):Me=e[80];let Ue;e[81]!==Ie?(Ue=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":Ie,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:Me}),e[81]=Ie,e[82]=Ue):Ue=e[82];let De;e[83]!==t.name?(De=a.jsxs(a.Fragment,{children:["Remove ",t.name,"?"]}),e[83]=t.name,e[84]=De):De=e[84];let Ke;e[85]!==t.id||e[86]!==o?(Ke=async()=>(await o(t.id),null),e[85]=t.id,e[86]=o,e[87]=Ke):Ke=e[87];let Ne;e[88]!==N||e[89]!==Ue||e[90]!==De||e[91]!==Ke?(Ne=a.jsx(zme,{open:N,onOpenChange:S,trigger:Ue,title:De,description:"This device will disappear from Cogpit. You can add it again later.",confirmLabel:"Remove device",destructive:!0,onConfirm:Ke}),e[88]=N,e[89]=Ue,e[90]=De,e[91]=Ke,e[92]=Ne):Ne=e[92];let Ae;e[93]!==be||e[94]!==Ee||e[95]!==ze||e[96]!==Ne?(Ae=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[be,Ee,ze,Ne]}),e[93]=be,e[94]=Ee,e[95]=ze,e[96]=Ne,e[97]=Ae):Ae=e[97];let Qe;e[98]!==Z||e[99]!==ee||e[100]!==ne||e[101]!==ce||e[102]!==Ae?(Qe=a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[Z,ee,ne,ce,Ae]}),e[98]=Z,e[99]=ee,e[100]=ne,e[101]=ce,e[102]=Ae,e[103]=Qe):Qe=e[103];let Je;e[104]!==C||e[105]!==k||e[106]!==v||e[107]!==b||e[108]!==t.id||e[109]!==t.name||e[110]!==t.username||e[111]!==g||e[112]!==B?(Je=g&&a.jsxs(Dme,{error:k,busy:C==="credentials",saveLabel:"Save account",onCancel:()=>{x(!1),w(t.username??""),j(""),_(null)},onSave:()=>void B(),children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-username-${t.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(account sign-in)"})]}),a.jsx(On,{id:`device-username-${t.id}`,"aria-label":`Username for ${t.name}`,value:b,onChange:We=>w(We.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-password-${t.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(On,{id:`device-password-${t.id}`,"aria-label":`New password for ${t.name}`,type:"password",value:v,onChange:We=>j(We.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),t.username&&b.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."})]}),e[104]=C,e[105]=k,e[106]=v,e[107]=b,e[108]=t.id,e[109]=t.name,e[110]=t.username,e[111]=g,e[112]=B,e[113]=Je):Je=e[113];let ke;return e[114]!==c||e[115]!==W||e[116]!==Qe||e[117]!==Je?(ke=a.jsxs("div",{ref:c,className:W,children:[Qe,Je]}),e[114]=c,e[115]=W,e[116]=Qe,e[117]=Je,e[118]=ke):ke=e[118],ke}function Qme(n){return!n}function EI(n){var dt,zt;const e=V.c(121),{open:t,initialMode:s,onClose:r}=n,{devices:o,refresh:i,probe:l,addDevice:c,updateDevice:u,removeDevice:d,reorderDevices:f,testDevice:m}=Si(),[p,h]=y.useState(""),[g,x]=y.useState(""),[b,w]=y.useState(""),[v,j]=y.useState(""),[k,_]=y.useState(!1),[N,S]=y.useState(!1),[C,E]=y.useState(null),[T,$]=y.useState(!1),[A,R]=y.useState(null),P=y.useRef(null),z=y.useRef(0);let L,I;e[0]!==s||e[1]!==t?(L=()=>{t&&(h(""),x(""),w(""),j(""),_(!1),S(!1),E(null),R(null),s==="add"&&requestAnimationFrame(()=>{var st;return(st=P.current)==null?void 0:st.focus()}))},I=[t,s],e[0]=s,e[1]=t,e[2]=L,e[3]=I):(L=e[2],I=e[3]),y.useEffect(L,I);let M;e[4]!==k||e[5]!==g||e[6]!==l?(M=async()=>{const{host:st,port:Tt,tls:At}=qu(g);if(!st){E(null),S(!1);return}const Qt=z.current=z.current+1;S(!0);const It=await l(st,Tt,k,At);Qt===z.current&&(E({...Zme(It,st,Tt??(At?qme:Wme)),hello:It.ok?It.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=l,e[7]=M):M=e[7];const F=M;let U,O;e[8]!==g||e[9]!==t||e[10]!==F?(U=()=>{if(!t)return;if(!qu(g).host){E(null),S(!1);return}const st=window.setTimeout(()=>void F(),Vme);return()=>window.clearTimeout(st)},O=[t,g,F],e[8]=g,e[9]=t,e[10]=F,e[11]=U,e[12]=O):(U=e[11],O=e[12]),y.useEffect(U,O);const D=((dt=C==null?void 0:C.hello)==null?void 0:dt.signIn)==="account",B=D&&((zt=C==null?void 0:C.hello)==null?void 0:zt.setupRequired)===!0,q=D||!k;let W;e:{if(T){W=!1;break e}if(!qu(g).host){W=!1;break e}if(N||!C){W=!1;break e}if(B){W=!1;break e}if(q&&!v){W=!1;break e}if(D&&!b.trim()){W=!1;break e}if((C==null?void 0:C.tone)==="error"){W=!1;break e}W=!0}const H=W;let K;e[13]!==c||e[14]!==k||e[15]!==q||e[16]!==g||e[17]!==p||e[18]!==r||e[19]!==v||e[20]!==D||e[21]!==b?(K=async function(){const{host:Tt,port:At,tls:Qt}=qu(g);if(!Tt)return;$(!0),R(null);const It=await c({name:p.trim()||void 0,host:Tt,port:At,tls:Qt,username:D?b.trim():void 0,password:q&&v||void 0,allowLocalTunnel:k});if($(!1),It.ok){r(),Xs(It.device.id);return}R({field:Gme.has(It.code)?"username":Kme.has(It.code)?"password":"host",message:It.error})},e[13]=c,e[14]=k,e[15]=q,e[16]=g,e[17]=p,e[18]=r,e[19]=v,e[20]=D,e[21]=b,e[22]=K):K=e[22];const Z=K;let Y;e[23]!==u?(Y=async(st,Tt)=>{await u(st,{name:Tt})},e[23]=u,e[24]=Y):Y=e[24];const J=Y;let ee;e[25]!==d?(ee=async st=>{await d(st)},e[25]=d,e[26]=ee):ee=e[26];const te=ee;let se;e[27]!==o?(se=o.map(epe),e[27]=o,e[28]=se):se=e[28];const{order:X,draggingId:ne,rowRef:ae,handleProps:ie}=Ume(se,f);let re;e[29]!==i||e[30]!==m?(re=async st=>{await m(st),await i()},e[29]=i,e[30]=m,e[31]=re):re=e[31];const de=re;let ce;e[32]!==r?(ce=st=>{st||r()},e[32]=r,e[33]=ce):ce=e[33];let oe;e[34]===Symbol.for("react.memo_cache_sentinel")?(oe=a.jsxs(ao,{children:[a.jsx(or,{children:"Devices"}),a.jsxs(ir,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",Hme," jumps between devices. Drag a device by its handle to change its number; this machine is always 1."]})]}),e[34]=oe):oe=e[34];let fe;e[35]!==o||e[36]!==ne||e[37]!==ie||e[38]!==te||e[39]!==J||e[40]!==de||e[41]!==X||e[42]!==ae||e[43]!==u?(fe=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:X.map((st,Tt)=>{const At=o.find(Qt=>Qt.id===st);return At?a.jsx(Jme,{device:At,slot:Tt+2,rowRef:ae(At.id),dragging:ne===At.id,dragHandleProps:ie(At.id),onRename:J,onCredentials:u,onRemove:te,onTest:de},At.id):null})}),e[35]=o,e[36]=ne,e[37]=ie,e[38]=te,e[39]=J,e[40]=de,e[41]=X,e[42]=ae,e[43]=u,e[44]=fe):fe=e[44];let ue;e[45]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kr,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),a.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[45]=ue):ue=e[45];const le=(A==null?void 0:A.field)==="host";let pe,ge;e[46]===Symbol.for("react.memo_cache_sentinel")?(pe=a.jsx(mn,{htmlFor:"device-host",children:"Host"}),ge=a.jsx(aa,{children:"Enter a local address or an HTTPS URL."}),e[46]=pe,e[47]=ge):(pe=e[46],ge=e[47]);let be;e[48]===Symbol.for("react.memo_cache_sentinel")?(be=st=>{z.current=z.current+1,x(st.target.value),w(""),E(null),R(null)},e[48]=be):be=e[48];let ve;e[49]!==F?(ve=()=>void F(),e[49]=F,e[50]=ve):ve=e[50];let Se;e[51]!==g||e[52]!==ve?(Se=a.jsx(On,{id:"device-host",ref:P,value:g,onChange:be,onBlur:ve,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[51]=g,e[52]=ve,e[53]=Se):Se=e[53];let we;e[54]!==N?(we=N&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(St,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[54]=N,e[55]=we):we=e[55];let Ee;e[56]!==C||e[57]!==N?(Ee=!N&&C&&a.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",_I[C.tone]),children:[a.jsx(Yme,{tone:C.tone}),C.text]}),e[56]=C,e[57]=N,e[58]=Ee):Ee=e[58];let $e;e[59]!==A?($e=(A==null?void 0:A.field)==="host"&&a.jsx(Eo,{children:A.message}),e[59]=A,e[60]=$e):$e=e[60];let Be;e[61]!==le||e[62]!==Se||e[63]!==we||e[64]!==Ee||e[65]!==$e?(Be=a.jsxs(fn,{"data-invalid":le,children:[pe,ge,Se,we,Ee,$e]}),e[61]=le,e[62]=Se,e[63]=we,e[64]=Ee,e[65]=$e,e[66]=Be):Be=e[66];let qe;e[67]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsxs(mn,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[67]=qe):qe=e[67];let ze;e[68]===Symbol.for("react.memo_cache_sentinel")?(ze=st=>h(st.target.value),e[68]=ze):ze=e[68];let Ie;e[69]!==p?(Ie=a.jsxs(fn,{children:[qe,a.jsx(On,{id:"device-name",value:p,onChange:ze,placeholder:"Defaults to the device's own name"})]}),e[69]=p,e[70]=Ie):Ie=e[70];let Me;e[71]!==A||e[72]!==D||e[73]!==b?(Me=D&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="username",children:[a.jsx(mn,{htmlFor:"device-username",children:"Username"}),a.jsx(On,{id:"device-username",value:b,onChange:st=>w(st.target.value),placeholder:"Account username",autoComplete:"username",spellCheck:!1}),a.jsx(aa,{children:"Requests through this hub act as this account on that server."}),(A==null?void 0:A.field)==="username"&&a.jsx(Eo,{children:A.message})]}),e[71]=A,e[72]=D,e[73]=b,e[74]=Me):Me=e[74];let Ue;e[75]!==q||e[76]!==v||e[77]!==A||e[78]!==D?(Ue=q&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="password",children:[a.jsx(mn,{htmlFor:"device-password",children:"Password"}),a.jsx(On,{id:"device-password",type:"password",value:v,onChange:st=>j(st.target.value),placeholder:D?"Password for that account":"Network access password for that device",autoComplete:D?"current-password":"off"}),(A==null?void 0:A.field)==="password"&&a.jsx(Eo,{children:A.message})]}),e[75]=q,e[76]=v,e[77]=A,e[78]=D,e[79]=Ue):Ue=e[79];let De;e[80]!==Be||e[81]!==Ie||e[82]!==Me||e[83]!==Ue?(De=a.jsxs(Aa,{children:[Be,Ie,Me,Ue]}),e[80]=Be,e[81]=Ie,e[82]=Me,e[83]=Ue,e[84]=De):De=e[84];let Ke;e[85]===Symbol.for("react.memo_cache_sentinel")?(Ke=st=>{z.current=z.current+1,_(st===!0),E(null),R(null)},e[85]=Ke):Ke=e[85];let Ne;e[86]!==k?(Ne=a.jsx(fT,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Ke}),e[86]=k,e[87]=Ne):Ne=e[87];const Ae=D?"":" — no password";let Qe;e[88]!==Ae?(Qe=a.jsxs(mn,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",Ae]}),e[88]=Ae,e[89]=Qe):Qe=e[89];let Je;e[90]!==Ne||e[91]!==Qe?(Je=a.jsxs(fn,{orientation:"horizontal",children:[Ne,Qe]}),e[90]=Ne,e[91]=Qe,e[92]=Je):Je=e[92];let ke;e[93]!==k||e[94]!==D?(ke=k&&a.jsxs(kt,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(lx,{}),a.jsx(_t,{className:"text-warning",children:D?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; account sign-in still applies."}):a.jsxs(a.Fragment,{children:["Traffic to this device is forwarded ",a.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[93]=k,e[94]=D,e[95]=ke):ke=e[95];let We;e[96]!==r?(We=a.jsx(Q,{variant:"outline",onClick:r,children:"Close"}),e[96]=r,e[97]=We):We=e[97];const ye=!H;let Re;e[98]!==Z?(Re=()=>void Z(),e[98]=Z,e[99]=Re):Re=e[99];let Ve;e[100]!==T?(Ve=T?a.jsxs(a.Fragment,{children:[a.jsx(St,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[100]=T,e[101]=Ve):Ve=e[101];let He;e[102]!==ye||e[103]!==Re||e[104]!==Ve?(He=a.jsx(Q,{disabled:ye,onClick:Re,children:Ve}),e[102]=ye,e[103]=Re,e[104]=Ve,e[105]=He):He=e[105];let me;e[106]!==We||e[107]!==He?(me=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[We,He]}),e[106]=We,e[107]=He,e[108]=me):me=e[108];let je;e[109]!==De||e[110]!==Je||e[111]!==ke||e[112]!==me?(je=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ue,De,Je,ke,me]}),e[109]=De,e[110]=Je,e[111]=ke,e[112]=me,e[113]=je):je=e[113];let Xe;e[114]!==fe||e[115]!==je?(Xe=a.jsxs(rr,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[oe,fe,je]}),e[114]=fe,e[115]=je,e[116]=Xe):Xe=e[116];let tt;return e[117]!==t||e[118]!==ce||e[119]!==Xe?(tt=a.jsx(sr,{open:t,onOpenChange:ce,children:Xe}),e[117]=t,e[118]=ce,e[119]=Xe,e[120]=tt):tt=e[120],tt}function epe(n){return n.id}const tpe="Browsing folders needs a newer Cogpit on this machine.";async function TI(n){const e=await Tl(n,`Request failed (${n.status})`);return new Error(n.status===404&&e==="Not found"?tpe:e)}async function npe(n,e){const t=await Ce(n?`/api/folders?path=${encodeURIComponent(n)}`:"/api/folders",{signal:e});if(!t.ok)throw await TI(t);return await t.json()}async function spe(n,e){const t=await is("/api/folders",{parent:n,name:e});if(!t.ok)throw await TI(t);return(await t.json()).path}function rpe(n,e=null){const t=ope(n);if(e===null)return t;const s=o=>o.replace(/[\\/]+$/,""),r=t.findIndex(o=>s(o.path)===s(e));return r===-1?t:t.slice(r)}function ope(n){const e=n.split(/[\\/]+/).filter(Boolean);let t,s,r;if(n.startsWith("\\\\")){const[o="",i="",...l]=e;t={label:`\\\\${o}\\${i}`,path:`\\\\${o}\\${i}\\`},s=l,r="\\"}else if(/^[a-z]:/i.test(n)){const[o="",...i]=e;t={label:o,path:`${o}\\`},s=i,r="\\"}else t={label:"/",path:"/"},s=e,r="/";return[t,...s.map((o,i)=>({label:o,path:t.path+s.slice(0,i+1).join(r)}))]}const F1="cogpit-browse-folders";function AI(){window.dispatchEvent(new Event(F1))}function ipe(n){return window.addEventListener(F1,n),()=>window.removeEventListener(F1,n)}const ape=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-BmYW6es0.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal})));function II(n){const e=V.c(8),{onNewSession:t,onNewFolder:s,defaultAgentKind:r}=n,[o,i]=y.useState(null);let l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>ipe(()=>i(!0)),c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),y.useEffect(l,c),o===null)return null;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(!1),e[2]=u):u=e[2];let d;return e[3]!==r||e[4]!==s||e[5]!==t||e[6]!==o?(d=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ape,{open:o,onClose:u,onNewSession:t,onNewFolder:s,defaultAgentKind:r,currentProjectDirName:null,currentProjectCwd:null,initialView:"folders"})}),e[3]=r,e[4]=s,e[5]=t,e[6]=o,e[7]=d):d=e[7],d}const lpe=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function lj(n,e){if(!lpe.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function bo(n,e){return`${n}.${e}`}function cpe(n){const e=new Set,t=new Set,s=[];for(const r of n){if(lj("plugin",r.id),e.has(r.id))throw new Error(`Duplicate Cogpit plugin id "${r.id}"`);e.add(r.id);for(const o of r.workspacePanels??[]){lj("panel",o.id);const i=bo(r.id,o.id);if(t.has(i))throw new Error(`Duplicate Cogpit workspace panel id "${i}"`);t.add(i),s.push({...o,id:i,pluginId:r.id,localId:o.id})}}return s.sort((r,o)=>(r.order??100)-(o.order??100)||r.title.localeCompare(o.title))}function Gn({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}const ii="cogpit",Lt={worktrees:bo(ii,"worktrees"),projectFiles:bo(ii,"project-files"),browser:bo(ii,"browser"),fileChanges:bo(ii,"file-changes"),sessionInfo:bo(ii,"session-info"),crew:bo(ii,"crew")},upe=y.lazy(()=>nt(()=>import("./CommandPaletteHost-CjZO-FyZ.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),dpe=y.lazy(()=>nt(()=>import("./index-C9bzBC6T.js"),__vite__mapDeps([27,1,28,2,29,3,4])).then(n=>({default:n.ConfigDialog}))),fpe=y.lazy(()=>nt(()=>import("./KeyboardShortcutsDialog-yO3h4xr-.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),mpe=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-BmYW6es0.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),ppe=y.lazy(()=>nt(()=>import("./ThemeSelectorModal-CHFAl7zz.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function hpe(n){const e=V.c(131),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=Sn(),{session:c,sessionSource:u}=jt(),{devices:d,activeDeviceId:f}=Si(),[m,p]=y.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=xt("manageDevices"),e[0]=h):h=e[0];const g=h,x=Hx(),b=o.mainView==="extension"?o.extensionViewId:null;let w;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(w=o.pendingCwd??(o.pendingDirName?xs(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=w):w=e[3];const v=w,j=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,k=r.onKeyboardShortcutsOpenChange;let _,N;e[4]!==k?(_=()=>{const me=function(Xe){on("keyboardShortcuts",Xe)&&(kI(document.activeElement)||(Xe.preventDefault(),k(!0)))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},N=[k],e[4]=k,e[5]=_,e[6]=N):(_=e[5],N=e[6]),y.useEffect(_,N);const S=f===Ot;let C;e[7]!==S?(C={id:Ot,name:"This machine",isLocal:!0,isActive:S},e[7]=S,e[8]=C):C=e[8];let E;if(e[9]!==f||e[10]!==d||e[11]!==C){let me;e[13]!==f?(me=je=>({id:je.id,name:je.name,isLocal:!1,isActive:je.id===f}),e[13]=f,e[14]=me):me=e[14],E=[C,...d.map(me)],e[9]=f,e[10]=d,e[11]=C,e[12]=E}else E=e[12];const T=E,{openMainView:$,closeMainView:A}=t.panels;let R;if(e[15]!==A||e[16]!==x||e[17]!==$||e[18]!==b){let me;e[20]!==A||e[21]!==$||e[22]!==b?(me=je=>{const Xe=je.id===b;return{id:`main-view-${je.id}`,label:`${Xe?"Close":"Open"} ${je.label}`,keywords:je.keywords,icon:je.icon,onSelect:Xe?A:()=>$(je.id)}},e[20]=A,e[21]=$,e[22]=b,e[23]=me):me=e[23],R=x.map(me),e[15]=A,e[16]=x,e[17]=$,e[18]=b,e[19]=R}else R=e[19];const P=R;let z;e[24]!==c||e[25]!==(u==null?void 0:u.agentKind)||e[26]!==(u==null?void 0:u.dirName)?(z=()=>{if(!c)return;const me=(u==null?void 0:u.agentKind)??un((u==null?void 0:u.dirName)??null);Pf(Cx(me,c.sessionId,c.cwd))},e[24]=c,e[25]=u==null?void 0:u.agentKind,e[26]=u==null?void 0:u.dirName,e[27]=z):z=e[27];const L=z,I=gpe,M=r.processPanel,F=r.workflowsPanel,U=r.undoDialog,O=r.branchModal,D=i.claudeDir??"";let B;e[28]!==i.handleCloseConfigDialog||e[29]!==i.handleConfigSaved||e[30]!==i.showConfigDialog||e[31]!==D?(B=a.jsx(y.Suspense,{fallback:null,children:a.jsx(dpe,{open:i.showConfigDialog,currentPath:D,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[28]=i.handleCloseConfigDialog,e[29]=i.handleConfigSaved,e[30]=i.showConfigDialog,e[31]=D,e[32]=B):B=e[32];const q=(u==null?void 0:u.dirName)??o.pendingDirName??null,W=(c==null?void 0:c.cwd)??o.pendingCwd??null;let H;e[33]!==i.defaultAgentKind||e[34]!==t.onStartNewFolder||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleCloseProjectSwitcher||e[37]!==t.panels.showProjectSwitcher||e[38]!==q||e[39]!==W?(H=a.jsx(y.Suspense,{fallback:null,children:a.jsx(mpe,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:q,currentProjectCwd:W})}),e[33]=i.defaultAgentKind,e[34]=t.onStartNewFolder,e[35]=t.onStartNewSession,e[36]=t.panels.handleCloseProjectSwitcher,e[37]=t.panels.showProjectSwitcher,e[38]=q,e[39]=W,e[40]=H):H=e[40];let K;e[41]!==i.defaultAgentKind||e[42]!==t.onStartNewFolder||e[43]!==t.onStartNewSession?(K=a.jsx(II,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind}),e[41]=i.defaultAgentKind,e[42]=t.onStartNewFolder,e[43]=t.onStartNewSession,e[44]=K):K=e[44];let Z;e[45]!==t.panels.handleCloseThemeSelector||e[46]!==t.panels.showThemeSelector||e[47]!==l.setPreview||e[48]!==l.setTheme||e[49]!==l.theme?(Z=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ppe,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[45]=t.panels.handleCloseThemeSelector,e[46]=t.panels.showThemeSelector,e[47]=l.setPreview,e[48]=l.setTheme,e[49]=l.theme,e[50]=Z):Z=e[50];const Y=r.commandPaletteOpen,J=r.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,te=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,X=t.actions.handleDashboardSelect,ne=t.panels.handleToggleSidebar;let ae,ie,re;e[51]!==t.panels?(ae=()=>t.panels.toggleWorkspacePanel(Lt.sessionInfo),ie=()=>t.panels.toggleWorkspacePanel(Lt.fileChanges),re=()=>t.panels.toggleWorkspacePanel(Lt.worktrees),e[51]=t.panels,e[52]=ae,e[53]=ie,e[54]=re):(ae=e[52],ie=e[53],re=e[54]);const de=t.panels.handleToggleMission,ce=c?t.handlers.handleDuplicateSession:void 0,oe=c?L:void 0,fe=c?I:void 0,ue=xt("killAny")?r.onKillAll:void 0,le=xt("configWrite")?t.panels.handleToggleConfig:void 0,pe=i.openConfigDialog;let ge;e[55]!==k?(ge=()=>k(!0),e[55]=k,e[56]=ge):ge=e[56];const be=s.currentCwd?s.onTogglePreview:void 0,ve=xt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let Se;e[57]!==t.panels?(Se=xt("browser")?()=>t.panels.toggleWorkspacePanel(Lt.browser):void 0,e[57]=t.panels,e[58]=Se):Se=e[58];const we=t.panels.handleToggleThemeSelector,Ee=s.onOpenTerminal,$e=r.onFocusComposer,Be=r.onExpandAll,qe=r.onExpandToolPayloads,ze=r.onCollapseAll,Ie=!!(c||o.pendingDirName);let Me;e[59]!==v||e[60]!==(c==null?void 0:c.cwd)||e[61]!==(u==null?void 0:u.dirName)||e[62]!==o.dashboardProject||e[63]!==o.pendingDirName?(Me=xt("terminal")&&!!((c==null?void 0:c.cwd)??v??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[59]=v,e[60]=c==null?void 0:c.cwd,e[61]=u==null?void 0:u.dirName,e[62]=o.dashboardProject,e[63]=o.pendingDirName,e[64]=Me):Me=e[64];const Ue=!!c;let De;e[65]!==s.hasFileChanges?(De=xt("hostFiles")&&s.hasFileChanges,e[65]=s.hasFileChanges,e[66]=De):De=e[66];const Ke=t.panels.activeWorkspacePanel===Lt.sessionInfo,Ne=t.panels.activeWorkspacePanel===Lt.browser,Ae=t.panels.activeWorkspacePanel===Lt.fileChanges,Qe=t.panels.activeWorkspacePanel===Lt.worktrees,Je=o.mainView==="config",ke=o.mainView==="mission",We=(c==null?void 0:c.cwd)??v??null;let ye;e[67]!==r.commandPaletteOpen||e[68]!==r.onCollapseAll||e[69]!==r.onCommandPaletteOpenChange||e[70]!==r.onExpandAll||e[71]!==r.onExpandToolPayloads||e[72]!==r.onFocusComposer||e[73]!==i.openConfigDialog||e[74]!==j||e[75]!==P||e[76]!==t.actions.handleDashboardSelect||e[77]!==t.actions.handleGoHome||e[78]!==t.onOpenPaletteProject||e[79]!==t.panels.handleOpenProjectSwitcher||e[80]!==t.panels.handleToggleMission||e[81]!==t.panels.handleToggleSidebar||e[82]!==t.panels.handleToggleThemeSelector||e[83]!==t.panels.showSidebar||e[84]!==T||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==ae||e[91]!==ie||e[92]!==re||e[93]!==ce||e[94]!==oe||e[95]!==fe||e[96]!==ue||e[97]!==le||e[98]!==ge||e[99]!==be||e[100]!==ve||e[101]!==Se||e[102]!==Ie||e[103]!==Me||e[104]!==Ue||e[105]!==De||e[106]!==Ke||e[107]!==Ne||e[108]!==Ae||e[109]!==Qe||e[110]!==Je||e[111]!==ke||e[112]!==We?(ye=a.jsx(y.Suspense,{fallback:null,children:a.jsx(upe,{open:Y,onOpenChange:J,onGoHome:ee,onNewSession:te,onOpenProject:se,onOpenSession:X,onToggleSidebar:ne,onToggleStats:ae,onToggleFileChanges:ie,onToggleWorktrees:re,onToggleMissionControl:de,extraActions:P,onDuplicateSession:ce,onCopyResumeCommand:oe,onFindInConversation:fe,onKillAll:ue,onOpenConfig:le,onOpenSettings:pe,onOpenKeyboardShortcuts:ge,onTogglePreview:be,onToggleProjectFiles:ve,onToggleBrowser:Se,onOpenTheme:we,onOpenTerminal:Ee,onOpenDevices:g?p:void 0,onSwitchDevice:Xs,devices:T,onFocusComposer:$e,onExpandAll:Be,onExpandToolPayloads:qe,onCollapseAll:ze,canFocusComposer:Ie,canOpenTerminal:Me,hasSession:Ue,hasFileChanges:De,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ke,showProjectFiles:s.showProjectFiles,showBrowser:Ne,showFileChanges:Ae,showWorktrees:Qe,showConfig:Je,showMission:ke,currentProjectDirName:j,projectCwd:We,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[67]=r.commandPaletteOpen,e[68]=r.onCollapseAll,e[69]=r.onCommandPaletteOpenChange,e[70]=r.onExpandAll,e[71]=r.onExpandToolPayloads,e[72]=r.onFocusComposer,e[73]=i.openConfigDialog,e[74]=j,e[75]=P,e[76]=t.actions.handleDashboardSelect,e[77]=t.actions.handleGoHome,e[78]=t.onOpenPaletteProject,e[79]=t.panels.handleOpenProjectSwitcher,e[80]=t.panels.handleToggleMission,e[81]=t.panels.handleToggleSidebar,e[82]=t.panels.handleToggleThemeSelector,e[83]=t.panels.showSidebar,e[84]=T,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=ae,e[91]=ie,e[92]=re,e[93]=ce,e[94]=oe,e[95]=fe,e[96]=ue,e[97]=le,e[98]=ge,e[99]=be,e[100]=ve,e[101]=Se,e[102]=Ie,e[103]=Me,e[104]=Ue,e[105]=De,e[106]=Ke,e[107]=Ne,e[108]=Ae,e[109]=Qe,e[110]=Je,e[111]=ke,e[112]=We,e[113]=ye):ye=e[113];let Re;e[114]!==r.keyboardShortcutsOpen||e[115]!==k?(Re=a.jsx(y.Suspense,{fallback:null,children:a.jsx(fpe,{open:r.keyboardShortcutsOpen,onOpenChange:k})}),e[114]=r.keyboardShortcutsOpen,e[115]=k,e[116]=Re):Re=e[116];let Ve;e[117]!==m?(Ve=g&&a.jsx(EI,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[117]=m,e[118]=Ve):Ve=e[118];let He;return e[119]!==r.branchModal||e[120]!==r.processPanel||e[121]!==r.undoDialog||e[122]!==r.workflowsPanel||e[123]!==B||e[124]!==H||e[125]!==K||e[126]!==Z||e[127]!==ye||e[128]!==Re||e[129]!==Ve?(He=a.jsxs(a.Fragment,{children:[M,F,U,O,B,H,K,Z,ye,Re,Ve]}),e[119]=r.branchModal,e[120]=r.processPanel,e[121]=r.undoDialog,e[122]=r.workflowsPanel,e[123]=B,e[124]=H,e[125]=K,e[126]=Z,e[127]=ye,e[128]=Re,e[129]=Ve,e[130]=He):He=e[130],He}function gpe(){window.dispatchEvent(new Event(M1))}const PI={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function cj(n){return n===null?null:PI[n]??n}function $I(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===PI[n])??null:null}async function RI(n,e,t){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function xpe(n,e){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function bpe(n,e,t){return YE("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function vpe(n,e,t){return YE("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const ype=3e3,Yb=y.createContext(null);async function eg(n){try{const e=await Ce(n);return e.ok?await e.text():void 0}catch{return}}function tg(n,e){if(!(n===void 0||n===e.current))try{const t=JSON.parse(n);return e.current=n,t}catch{return}}function el(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 Vu(n,e,t){const s=new Map(n),r=(s.get(e)??[]).filter(o=>!t(o));return r.length>0?s.set(e,r):s.delete(e),s}function wpe({children:n}){const[e,t]=y.useState(new Map),[s,r]=y.useState(new Map),[o,i]=y.useState(new Map),[l,c]=y.useState(new Map),[u,d]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=Mf(),b=$N()!==null,w=y.useRef(x.key);y.useLayoutEffect(()=>{w.current=x.key},[x.key]);const v=y.useCallback(async()=>{const[P,z,L]=await Promise.all([eg(El("/api/permissions",x)),eg(El("/api/user-questions",x)),eg(El("/api/agent-prompts",x))]);if(w.current!==x.key)return;const I=tg(P,p),M=tg(z,h),F=tg(L,g);I&&(t(el(I.bySession)),d(new Set(el(I.plansBySession).keys()))),M&&r(el(M.bySession)),F&&(i(el(F.elicitationsBySession)),c(el(F.dialogsBySession)))},[x]);y.useEffect(()=>{if(b)return;const P=()=>{document.visibilityState==="visible"&&v()};P();const z=setInterval(P,ype);return document.addEventListener("visibilitychange",P),()=>{clearInterval(z),document.removeEventListener("visibilitychange",P)}},[v,b]);const j=y.useCallback(async(P,z)=>{m(L=>new Set(L).add(P));try{return await z()}finally{m(L=>{const I=new Set(L);return I.delete(P),I}),v()}},[v]),k=y.useCallback((P,z,L)=>j(z,async()=>{await RI(P,z,L).catch(()=>!1)&&(t(M=>Vu(M,P,F=>F.requestId===z)),p.current="")}),[j]),_=y.useCallback((P,z,L)=>j(z,async()=>{const I=await eb(P,z,L);return I.ok&&(r(M=>Vu(M,P,F=>F.toolUseId===z)),h.current=""),I}),[j]),N=y.useCallback((P,z,L)=>j(z,async()=>{const I=await bpe(P,z,L);return I.ok&&(i(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),S=y.useCallback((P,z,L)=>j(z,async()=>{const I=await vpe(P,z,L);return I.ok&&(c(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),C=y.useMemo(()=>new Set(e.keys()),[e]),E=y.useMemo(()=>new Set(s.keys()),[s]),T=y.useMemo(()=>new Set(o.keys()),[o]),$=y.useMemo(()=>new Set(l.keys()),[l]),A=y.useCallback(()=>{v()},[v]),R=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:E,awaitingElicitation:T,awaitingDialog:$,awaitingPlan:u,responding:f,respond:k,answerQuestion:_,answerElicitation:N,answerDialog:S,refresh:A}),[e,s,o,l,C,E,T,$,u,f,k,_,N,S,A]);return a.jsx(Yb.Provider,{value:R,children:n})}function Spe(){const n=y.useContext(Yb);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}function kpe(){return y.useContext(Yb)}function OI(n){var d;const e=V.c(29),t=ar(),s=kpe(),r=i5(n),o=t==null?void 0:t.sessions,i=t==null?void 0:t.procBySession;let l;e[0]!==s?(l=s?{awaitingPermission:s.awaitingPermission,awaitingQuestion:s.awaitingQuestion,awaitingPrompt:new Set([...s.awaitingElicitation,...s.awaitingDialog]),awaitingPlan:s.awaitingPlan}:P9,e[0]=s,e[1]=l):l=e[1];const c=l;let u;if(e[2]!==c||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==r){e:{if(!n||!o||!i){u=null;break e}let f;if(e[8]!==n||e[9]!==o){let v;e[11]!==n?(v=j=>j.sessionId===n,e[11]=n,e[12]=v):v=e[12],f=o.find(v),e[8]=n,e[9]=o,e[10]=f}else f=e[10];const m=f,p=((d=m==null?void 0:m.crew)==null?void 0:d.rootId)??n;let h;e[13]!==p?(h=v=>{var j;return((j=v.crew)==null?void 0:j.rootId)===p},e[13]=p,e[14]=h):h=e[14];const g=o.filter(h);if(g.length===0){if(r.length===0){u=null;break e}const v=r.length;let j;e[15]!==r?(j=r.filter(jpe),e[15]=r,e[16]=j):j=e[16];let k;e[17]!==p||e[18]!==j.length||e[19]!==r.length?(k={rootId:p,size:v,needsYou:0,working:j.length},e[17]=p,e[18]=j.length,e[19]=r.length,e[20]=k):k=e[20],u=k;break e}let x;e[21]!==c||e[22]!==i?(x=v=>TN(v,i,c),e[21]=c,e[22]=i,e[23]=x):x=e[23];const b=Ux(g,x);let w;e[24]!==b.needsYou||e[25]!==b.size||e[26]!==b.working||e[27]!==p?(w={rootId:p,size:b.size,needsYou:b.needsYou,working:b.working},e[24]=b.needsYou,e[25]=b.size,e[26]=b.working,e[27]=p,e[28]=w):w=e[28],u=w}e[2]=c,e[3]=i,e[4]=n,e[5]=o,e[6]=r,e[7]=u}else u=e[7];return u}function jpe(n){return n.state==="running"}function vd(n){const e=V.c(10),{reason:t,children:s}=n;if(!t)return s;let r;e[0]!==t?(r=a.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s||e[3]!==r?(o=a.jsx(Zt,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Yt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Gt,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function Npe(n){var k;const e=V.c(22),{sessionId:t}=n,s=ar(),{names:r}=Ff();s==null||s.sessions;let o;e[0]!==(s==null?void 0:s.sessions)?(o=new Map(((s==null?void 0:s.sessions)??[]).map(Cpe)),e[0]=s==null?void 0:s.sessions,e[1]=o):o=e[1];const i=o;let l,c,u,d;if(e[2]!==i||e[3]!==r||e[4]!==t){d=Symbol.for("react.early_return_sentinel");e:{if(l=(k=i.get(t))==null?void 0:k.crew,!l){d=null;break e}c=i.get(l.parentId),u=$d(l.parentId,i,r)??l.parentTitle??"the session that started it"}e[2]=i,e[3]=r,e[4]=t,e[5]=l,e[6]=c,e[7]=u,e[8]=d}else l=e[5],c=e[6],u=e[7],d=e[8];if(d!==Symbol.for("react.early_return_sentinel"))return d;const f=u;let m;e[9]!==l||e[10]!==c?(m=()=>{c?za(ha(c.dirName,c.fileName)):cm(l.parentId)},e[9]=l,e[10]=c,e[11]=m):m=e[11];const p=m,h=`Reports to ${f}`,g=`Open ${f}, which started this session`;let x,b,w;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=G(fs,"h-8 min-w-12 max-w-56 shrink-[4] gap-1.5 px-2.5 text-xs text-muted-foreground hover:text-foreground"),b=a.jsx(mx,{className:"size-3 shrink-0","aria-hidden":"true"}),w=a.jsx("span",{className:"shrink-0 max-[1200px]:hidden",children:"Reports to"}),e[12]=x,e[13]=b,e[14]=w):(x=e[12],b=e[13],w=e[14]);let v;e[15]!==f?(v=a.jsx("span",{className:"truncate font-medium text-foreground",children:f}),e[15]=f,e[16]=v):v=e[16];let j;return e[17]!==p||e[18]!==v||e[19]!==h||e[20]!==g?(j=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs","data-crew-parent":!0,onClick:p,"aria-label":h,title:g,className:x,children:[b,w,v]}),e[17]=p,e[18]=v,e[19]=h,e[20]=g,e[21]=j):j=e[21],j}function Cpe(n){return[n.sessionId,n]}const uj=o_.version,_pe={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},dj={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function Epe(n){const e=V.c(6),{state:t}=n,s=dj[t],r=dj[t],o=_pe[t];let i;e[0]!==o?(i=G("size-2 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==r||e[4]!==i?(l=a.jsx("span",{"aria-label":s,title:r,className:i}),e[2]=s,e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function fj(n){const e=V.c(2),{slot:t}=n;if(t>9)return null;let s;return e[0]!==t?(s=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}function Xb(n){const e=V.c(51),{compact:t}=n,s=t===void 0?!1:t,{devices:r,activeDeviceId:o,activeDevice:i,refresh:l,testDevice:c}=Si(),[u,d]=y.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Ot;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=xt("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==r||e[2]!==l||e[3]!==c?(g=O=>{!O||r.length===0||Promise.all(r.map(D=>c(D.id).catch(Ape))).then(()=>l())},e[1]=r,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&r.length===0&&!m)return null;const b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=G("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let j;e[7]!==b||e[8]!==v?(j=a.jsx(Q,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=j):j=e[9];let k;e[10]!==m?(k=m?a.jsx(cx,{"data-icon":"inline-start"}):a.jsx(yg,{"data-icon":"inline-start"}),e[10]=m,e[11]=k):k=e[11];let _;e[12]!==f?(_=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=_):_=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(Et,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=N):N=e[14];let S;e[15]!==j||e[16]!==k||e[17]!==_?(S=a.jsxs(Rc,{render:j,children:[k,_,N]}),e[15]=j,e[16]=k,e[17]=_,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(P5,{children:"Devices"}),e[19]=C):C=e[19];let E,T,$;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(yg,{}),T=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),$=a.jsx(fj,{slot:1}),e[20]=E,e[21]=T,e[22]=$):(E=e[20],T=e[21],$=e[22]);let A;e[23]!==m?(A=!m&&a.jsx(nn,{className:"ml-auto text-success"}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==A?(R=a.jsxs(hn,{onClick:Tpe,children:[E,T,$,A]}),e[25]=A,e[26]=R):R=e[26];let P;if(e[27]!==o||e[28]!==s||e[29]!==r){let O;e[31]!==o||e[32]!==s?(O=(D,B)=>{const q=CI(D),W=q!==void 0&&q!==uj,H=D.id===o;return a.jsxs(hn,{onClick:()=>Xs(D.id),className:G(s&&"min-h-10"),children:[a.jsx(Epe,{state:D.runtime.authState}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"truncate",children:D.name}),W&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${q}; hub runs v${uj}`,children:["v",q]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[D.host,":",D.port,D.auth==="none"&&" · unauthenticated"]})]}),a.jsx(fj,{slot:B+2}),H&&a.jsx(nn,{className:"ml-auto text-success"})]},D.id)},e[31]=o,e[32]=s,e[33]=O):O=e[33],P=r.map(O),e[27]=o,e[28]=s,e[29]=r,e[30]=P}else P=e[30];let z;e[34]!==R||e[35]!==P?(z=a.jsxs(qr,{children:[C,R,P]}),e[34]=R,e[35]=P,e[36]=z):z=e[36];let L;e[37]!==r.length?(L=h&&a.jsxs(a.Fragment,{children:[a.jsx(Il,{}),a.jsxs(qr,{children:[a.jsxs(hn,{onClick:()=>d("add"),children:[a.jsx(kr,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(hn,{onClick:()=>d("manage"),children:[a.jsx(ix,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[37]=r.length,e[38]=L):L=e[38];let I;e[39]!==z||e[40]!==L?(I=a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-64",children:[z,L]}),e[39]=z,e[40]=L,e[41]=I):I=e[41];let M;e[42]!==x||e[43]!==S||e[44]!==I?(M=a.jsxs($c,{onOpenChange:x,children:[S,I]}),e[42]=x,e[43]=S,e[44]=I,e[45]=M):M=e[45];let F;e[46]!==u?(F=h&&a.jsx(EI,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[46]=u,e[47]=F):F=e[47];let U;return e[48]!==M||e[49]!==F?(U=a.jsxs(a.Fragment,{children:[M,F]}),e[48]=M,e[49]=F,e[50]=U):U=e[50],U}function Tpe(){return Xs(Ot)}function Ape(){return null}const Ipe=6e4;function Ppe(){const[n,e]=y.useState([]),t=y.useCallback(async s=>{try{const r=await Ce("/api/system-processes");if(r.ok){const o=await r.json();if(s()){const i=(o.processes??[]).filter(l=>l.suspectedLeak);e(l=>JSON.stringify(l)===JSON.stringify(i)?l:i)}}}catch{}},[]);return Oa(t,Ipe),{leaks:n}}const $pe=6e4;function Rpe(n){const e=V.c(23),{onReview:t}=n,{leaks:s}=Ppe(),[r,o]=y.useState(!1),i=s.length>0,l=s.reduce(Lpe,0);let c,u;if(e[0]!==i?(c=()=>{if(i){o(!0);return}const C=window.setTimeout(()=>o(!1),$pe);return()=>window.clearTimeout(C)},u=[i],e[0]=i,e[1]=c,e[2]=u):(c=e[1],u=e[2]),y.useEffect(c,u),!i&&!r)return null;const d=Gt,f=i?"destructive":"ghost",m=i?`Review ${s.length} flagged ${s.length===1?"process":"processes"}`:"Leak monitor. No flagged processes",p=!i&&"text-muted-foreground";let h;e[3]!==p?(h=G("mr-1 font-mono",p),e[3]=p,e[4]=h):h=e[4];let g;e[5]!==t||e[6]!==f||e[7]!==m||e[8]!==h?(g=a.jsx(Q,{variant:f,size:"xs","aria-label":m,onClick:t,className:h}),e[5]=t,e[6]=f,e[7]=m,e[8]=h,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(k8,{"data-icon":"inline-start"}),e[10]=x):x=e[10];let b;e[11]!==s.length?(b=a.jsx("span",{className:"tabular-nums",children:s.length}),e[11]=s.length,e[12]=b):b=e[12];let w;e[13]!==g||e[14]!==b?(w=a.jsxs(Zt,{render:g,children:[x,b]}),e[13]=g,e[14]=b,e[15]=w):w=e[15];const v=Yt,j="bottom",k="p-3",_=i?a.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[a.jsxs("div",{className:"text-xs font-medium",children:["Flagged processes · ",l.toFixed(0),"% CPU"]}),s.slice(0,6).map(Ope),s.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",s.length-6," more"]}),a.jsx(tn,{}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Review ownership and stop individual processes"})]}):a.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"No flagged processes. Click to open the power monitor."})]});let N;e[16]!==v||e[17]!==_?(N=a.jsx(v,{side:j,className:k,children:_}),e[16]=v,e[17]=_,e[18]=N):N=e[18];let S;return e[19]!==d||e[20]!==w||e[21]!==N?(S=a.jsxs(d,{children:[w,N]}),e[19]=d,e[20]=w,e[21]=N,e[22]=S):S=e[22],S}function Ope(n){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[a.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",jN(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function Lpe(n,e){return n+e.cpuPercent}const Mpe=2e3;function ya(n){return`${n.toFixed(n<10?1:0)}%`}function gf(n){return`${n.toFixed(0)} MB`}function zpe(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function Dpe(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 Fpe(n){const e=V.c(50),{metric:t,onStop:s,stopping:r,onNavigate:o}=n;let i;e[0]!==t.label?(i=a.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let l;e[2]!==t.pid?(l=a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=l):l=e[3];let c;e[4]!==t.suspectedLeak||e[5]!==t.warning?(c=t.suspectedLeak&&a.jsx(Fe,{variant:"destructive",children:t.warning==="sustained-cpu"?"sustained high CPU":"possible leak"}),e[4]=t.suspectedLeak,e[5]=t.warning,e[6]=c):c=e[6];let u;e[7]!==t.orphaned||e[8]!==t.suspectedLeak?(u=t.orphaned&&!t.suspectedLeak&&a.jsx(Fe,{variant:"secondary",children:"orphaned"}),e[7]=t.orphaned,e[8]=t.suspectedLeak,e[9]=u):u=e[9];let d;e[10]!==i||e[11]!==l||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i,l,c,u]}),e[10]=i,e[11]=l,e[12]=c,e[13]=u,e[14]=d):d=e[14];let f;e[15]!==t.command?(f=a.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[15]=t.command,e[16]=f):f=e[16];let m;e[17]!==t.kind||e[18]!==t.owner||e[19]!==o?(m=t.owner?a.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[t.owner.dirName&&t.owner.fileName?a.jsx("a",{className:"underline",href:ha(t.owner.dirName,t.owner.fileName),onClick:S=>{S.metaKey||S.ctrlKey||S.shiftKey||S.altKey||(S.preventDefault(),za(ha(t.owner.dirName,t.owner.fileName)),o())},children:t.owner.title||"Originating session"}):a.jsx("span",{children:"Originating session"}),a.jsxs("div",{className:"break-all",children:[t.owner.sessionId," · task ",t.owner.taskId]})]}):t.kind!=="cogpit"&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Session ownership unknown"}),e[17]=t.kind,e[18]=t.owner,e[19]=o,e[20]=m):m=e[20];let p;e[21]!==d||e[22]!==f||e[23]!==m?(p=a.jsxs("div",{className:"min-w-0 flex-1",children:[d,f,m]}),e[21]=d,e[22]=f,e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t||e[26]!==s||e[27]!==r?(h=t.canStop&&t.identity&&a.jsx(Q,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t),disabled:r,"aria-label":`Stop process ${t.pid}`,children:r?"Stopping…":"Stop"}),e[25]=t,e[26]=s,e[27]=r,e[28]=h):h=e[28];const g=t.cpuPercent>=20&&"text-destructive";let x;e[29]!==g?(x=G("font-mono text-sm font-semibold tabular-nums",g),e[29]=g,e[30]=x):x=e[30];let b;e[31]!==t.cpuPercent?(b=ya(t.cpuPercent),e[31]=t.cpuPercent,e[32]=b):b=e[32];let w;e[33]!==x||e[34]!==b?(w=a.jsx("div",{className:x,children:b}),e[33]=x,e[34]=b,e[35]=w):w=e[35];let v;e[36]!==t.memoryMb?(v=gf(t.memoryMb),e[36]=t.memoryMb,e[37]=v):v=e[37];let j;e[38]!==t.ageSeconds?(j=jN(t.ageSeconds),e[38]=t.ageSeconds,e[39]=j):j=e[39];let k;e[40]!==v||e[41]!==j?(k=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[v," · ",j]}),e[40]=v,e[41]=j,e[42]=k):k=e[42];let _;e[43]!==w||e[44]!==k?(_=a.jsxs("div",{className:"shrink-0 text-right",children:[w,k]}),e[43]=w,e[44]=k,e[45]=_):_=e[45];let N;return e[46]!==_||e[47]!==p||e[48]!==h?(N=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[p,h,_]}),e[46]=_,e[47]=p,e[48]=h,e[49]=N):N=e[49],N}function Upe(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 Bpe(n,e,t=0){return t>0?t===1?'1 process needs review. See "Agent and runtime processes" below.':`${t} processes need review. See "Agent and runtime 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 mj(n){const e=V.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=a.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let r;e[2]!==t.pid?(r=t.pid>0&&a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=r):r=e[3];let o;e[4]!==s||e[5]!==r?(o=a.jsxs("div",{className:"flex items-center gap-2",children:[s,r]}),e[4]=s,e[5]=r,e[6]=o):o=e[6];let i;e[7]!==t?(i=Upe(t),e[7]=t,e[8]=i):i=e[8];let l;e[9]!==i?(l=a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=l):l=e[10];let c;e[11]!==o||e[12]!==l?(c=a.jsxs("div",{className:"min-w-0 flex-1",children:[o,l]}),e[11]=o,e[12]=l,e[13]=c):c=e[13];const u=t.cpuPercent>=50&&"text-destructive";let d;e[14]!==u?(d=G("font-mono text-sm font-semibold tabular-nums",u),e[14]=u,e[15]=d):d=e[15];let f;e[16]!==t.cpuPercent?(f=ya(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==d||e[19]!==f?(m=a.jsx("div",{className:d,children:f}),e[18]=d,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=gf(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=a.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&&a.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=a.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function pj(n){const e=V.c(6),{metrics:t,emptyLabel:s}=n;let r,o;if(e[0]!==s||e[1]!==t){o=Symbol.for("react.early_return_sentinel");e:{const i=t.slice(0,8);if(i.length===0){let l;e[4]!==s?(l=a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],o=l;break e}r=i.map(Wpe)}e[0]=s,e[1]=t,e[2]=r,e[3]=o}else r=e[2],o=e[3];return o!==Symbol.for("react.early_return_sentinel")?o:r}function Wpe(n,e){const t=Dpe(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(tn,{}),a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm",children:n.name}),a.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:zpe(n.ratePerSecond)}),t&&a.jsx("span",{children:t}),n.averageDurationMs!==void 0&&a.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&a.jsxs(Fe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function qpe(n){const e=V.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(Vpe).join(", "),e[0]=t,e[1]=r):r=e[1];const o=`Recent Cogpit CPU: ${r}`;let i;e[2]!==s||e[3]!==t?(i=t.length===0?a.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,u)=>a.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:ya(c)},u)),e[2]=s,e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==o||e[6]!==i?(l=a.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":o,children:i}),e[5]=o,e[6]=i,e[7]=l):l=e[7],l}function Vpe(n){return ya(n)}function Hpe({open:n,onOpenChange:e}){var $,A;const[t,s]=y.useState(null),[r,o]=y.useState(null),[i,l]=y.useState([]),[c,u]=y.useState(null),[d,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=y.useState(null),x=y.useRef(!1),[b,w]=so(),v=y.useCallback(async()=>{var F;if(x.current)return;x.current=!0,p(!0);const R=Ce("/api/performance").then(async U=>{if(!U.ok)throw new Error(`Server monitor returned ${U.status}`);return U.json()}),P=((F=window.electronPerformance)==null?void 0:F.getSnapshot())??Promise.resolve(null),[z,L]=await Promise.allSettled([R,P]),I=z.status==="fulfilled"?z.value:null,M=L.status==="fulfilled"?L.value:null;if(I&&o(I),M&&s(M),!I&&!M)u("Performance data is unavailable.");else{u(null);const U=M&&M.processes.length>0?M.processes.reduce((O,D)=>O+D.cpuPercent,0):(I==null?void 0:I.cpuPercent)??0;l(O=>[...O.slice(-29),U])}x.current=!1,p(!1)},[]);y.useEffect(()=>{if(!n)return;const R=()=>{document.visibilityState==="visible"&&v()};R();const P=window.setInterval(R,Mpe);return document.addEventListener("visibilitychange",R),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",R)}},[n,v]);const j=[...(t==null?void 0:t.processes)??[]].sort((R,P)=>P.cpuPercent-R.cpuPercent),k=j.length>0?j.reduce((R,P)=>R+P.cpuPercent,0):(r==null?void 0:r.cpuPercent)??0,_=j[0],N=(($=r==null?void 0:r.system)==null?void 0:$.processes)??[],S=((A=r==null?void 0:r.system)==null?void 0:A.suspectedLeakCount)??0,C=S>0||k>=80?"High":k>=15?"Active":"Idle",E=async R=>{if(!(!R.identity||h!==null)){f(null),g(R.pid);try{const P=await Ce("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processes:[{pid:R.pid,identity:R.identity}]})});if(!P.ok)throw new Error("Could not stop this process.");if(!(await P.json()).killed.includes(R.pid))throw new Error("The process changed or is no longer eligible. Refresh and review it again.");await v()}catch{f("Process was not stopped. Refresh and review its current identity and access.")}finally{g(null)}}},T=()=>{w(JSON.stringify({capturedAt:new Date().toISOString(),electron:t,server:r,cpuHistory:i},null,2))};return a.jsx(sr,{open:n,onOpenChange:e,children:a.jsxs(rr,{className:"h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl",children:[a.jsx(ao,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(or,{children:"Power & activity monitor"}),a.jsx(Fe,{variant:C==="High"?"destructive":"secondary",children:C})]}),a.jsx(ir,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."})]}),a.jsxs("div",{className:"flex shrink-0 gap-1",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>void v(),disabled:m,children:[a.jsx(Fn,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh"]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:T,disabled:!r&&!t,children:[b?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),b?"Copied":"Copy data"]})]})]})}),a.jsx(tn,{}),a.jsx(Vc,{className:"min-h-0 min-w-0 flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-5",children:[(c||d)&&a.jsx(kt,{variant:"destructive",children:a.jsx(_t,{children:d||c})}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Current load"}),a.jsx(vr,{children:Bpe(k,_,S)}),a.jsx(Wte,{children:a.jsxs("span",{className:G("font-mono text-lg font-semibold tabular-nums",k>=80&&"text-destructive"),children:[ya(k)," CPU"]})})]}),a.jsx(Fs,{children:a.jsx(qpe,{values:i})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Processes"}),a.jsx(vr,{children:"Which part of Cogpit is consuming CPU and memory."})]}),a.jsx(Fs,{children:j.length>0?j.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(tn,{}),a.jsx(mj,{metric:R})]},R.pid)):r?a.jsx(mj,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:r.cpuPercent,memoryMb:r.memory.rssMb}}):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"})})]}),N.length>0&&a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Agent and runtime processes"}),a.jsx(vr,{children:"Agent sessions, browsers, and long-running scripts. Unknown runtimes are flagged after sustained high CPU; stopping them is manual."})]}),a.jsx(Fs,{children:N.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(tn,{}),a.jsx(Fpe,{metric:R,onStop:z=>void E(z),stopping:h!==null,onNavigate:()=>e(!1)})]},R.pid))})]}),a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Server activity"}),a.jsxs(vr,{children:["File checks, streams, and agent work over the last ",(r==null?void 0:r.sampleWindowSeconds)??10," seconds."]})]}),a.jsx(Fs,{children:a.jsx(pj,{metrics:(r==null?void 0:r.activities)??[],emptyLabel:"No watched-file or stream activity in this sample."})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"API activity"}),a.jsx(vr,{children:"Requests ranked by recent frequency and time."})]}),a.jsx(Fs,{children:a.jsx(pj,{metrics:(r==null?void 0:r.requests)??[],emptyLabel:"No API requests in this sample."})})]})]}),r&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",ya(r.eventLoopPercent)," · heap ",gf(r.memory.heapUsedMb)," · RSS ",gf(r.memory.rssMb)]})]})})]})})}function Kpe(n){return`${n.title??`Pull request #${n.number}`}
|
|
461
|
+
`)[0];return l.length>J3?`${l.slice(0,J3)}...`:l}function xme(n,e,t){for(let s=e;s>=0;s--){const r=n[s];if(!r)continue;const o=gme(r,t);if(o)return{index:s,text:o}}return null}function bme(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(pme)){const c=l.getBoundingClientRect().top;if(c>e+X3)break;t=l,s=c}if(!t)return null;const r=Number(t.dataset.turnIndex);if(!Number.isInteger(r))return null;const o=t.querySelector(bI);return(o?o.getBoundingClientRect().bottom>e+X3:s+hme>e)?null:r}const vme=y.memo(function(e){const t=V.c(23),{session:s,scrollContainerRef:r}=e,[o,i]=y.useState(null);let l,c;t[0]!==r||t[1]!==s.sessionId?(l=()=>{const k=r.current;if(!k)return;let _=null;const N=()=>{_=null;const T=bme(k);i($=>T===null?null:($==null?void 0:$.sessionId)===s.sessionId&&$.index===T?$:{sessionId:s.sessionId,index:T})},S=()=>{_===null&&(_=requestAnimationFrame(N))};i(null),k.addEventListener("scroll",S,{passive:!0});const C=new MutationObserver(S);C.observe(k,{childList:!0,subtree:!0});const E=new ResizeObserver(S);return E.observe(k),k.firstElementChild&&E.observe(k.firstElementChild),S(),()=>{k.removeEventListener("scroll",S),C.disconnect(),E.disconnect(),_!==null&&cancelAnimationFrame(_)}},c=[r,s.sessionId],t[0]=r,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);const u=Ra();let d;e:{if(!o||o.sessionId!==s.sessionId){d=null;break e}let k;t[4]!==u||t[5]!==s.turns||t[6]!==o.index?(k=xme(s.turns,o.index,u),t[4]=u,t[5]=s.turns,t[6]=o.index,t[7]=k):k=t[7],d=k}const f=d;if(!f)return null;let m;t[8]!==f.index||t[9]!==r?(m=()=>{const k=r.current;if(!k)return;const _=k.querySelector(`[data-turn-index="${f.index}"]`),N=(_==null?void 0:_.querySelector(bI))??_;if(!N)return;const S=k.scrollTop+N.getBoundingClientRect().top-k.getBoundingClientRect().top;k.scrollTo({top:Math.max(0,S),behavior:"smooth"})},t[8]=f.index,t[9]=r,t[10]=m):m=t[10];const p=m,h=`Scroll to turn ${f.index+1} prompt`;let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(F4,{"data-icon":"inline-start"}),t[11]=g):g=t[11];const x=f.index+1;let b;t[12]!==x?(b=a.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",x]}),t[12]=x,t[13]=b):b=t[13];let w;t[14]!==f.text?(w=a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[14]=f.text,t[15]=w):w=t[15];let v;t[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(ja,{"data-icon":"inline-end",className:"ml-auto"}),t[16]=v):v=t[16];let j;return t[17]!==f.text||t[18]!==p||t[19]!==h||t[20]!==b||t[21]!==w?(j=a.jsxs(Q,{type:"button",variant:"outline",size:"sm","aria-label":h,title:f.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-popover px-3 text-left shadow-sm",onClick:p,children:[g,b,w,v]}),t[17]=f.text,t[18]=p,t[19]=h,t[20]=b,t[21]=w,t[22]=j):j=t[22],j});function L1({path:n,dirName:e,command:t}){return qo()?(console.warn("[open-terminal] unavailable for remote devices"),!1):!n&&!e?(console.warn("[open-terminal] no project path available"),!1):(Ce("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,dirName:e,...t?{command:t}:{}})}).then(s=>{s.ok||s.json().then(r=>console.error("[open-terminal]",r.error)).catch(()=>{})}).catch(s=>console.error("[open-terminal] fetch failed:",s)),!0)}const yme={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},wme=1440*60*1e3;function Sme(n){return(n&&yme[n])??"usage"}function kme(n){if(n===null)return null;const e=new Date(n*1e3);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now()>wme;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function jme(n){return n===void 0?"":n?"Extra usage is on but did not cover this. ":"Extra usage is off for this account. "}function Nme(n){const e=V.c(36),{block:t,dirName:s,fileName:r,cwd:o,terminal:i}=n;let l,c;e[0]!==o||e[1]!==s||e[2]!==r?(l=vs(s),c=Cx(l.kind,Ed(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=l,e[4]=c):(l=e[3],c=e[4]);const u=c;let d;e[5]!==t.resetsAt?(d=kme(t.resetsAt),e[5]=t.resetsAt,e[6]=d):d=e[6];const f=d,m=t.lowPriority&&l.capabilities.lowPriorityInTerminal;let p;e[7]!==m||e[8]!==i?(p=m&&i&&!qo(),e[7]=m,e[8]=i,e[9]=p):p=e[9];const h=p;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Po,{}),e[10]=g):g=e[10];const x=l.displayName;let b;e[11]!==t.limit?(b=Sme(t.limit),e[11]=t.limit,e[12]=b):b=e[12];let w;e[13]!==l.displayName||e[14]!==b?(w=a.jsxs(Xt,{children:[x," hit its ",b," limit"]}),e[13]=l.displayName,e[14]=b,e[15]=w):w=e[15];const v=f?`Resets at ${f}. `:"";let j;e[16]!==t.extraUsage?(j=jme(t.extraUsage),e[16]=t.extraUsage,e[17]=j):j=e[17];let k;e[18]!==u||e[19]!==m?(k=m?a.jsxs(a.Fragment,{children:["It can keep this session going before then at lower priority, spending your weekly allowance to do it — a mode that exists only in its own terminal. Resume there with ",a.jsx("code",{className:"font-mono",children:u}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[18]=u,e[19]=m,e[20]=k):k=e[20];let _;e[21]!==k||e[22]!==v||e[23]!==j?(_=a.jsxs("span",{children:[v,j,k]}),e[21]=k,e[22]=v,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==h||e[26]!==u||e[27]!==o||e[28]!==s?(N=h&&a.jsx(Q,{size:"sm",variant:"outline",onClick:()=>L1({path:o??void 0,dirName:s,command:u}),children:"Open in terminal"}),e[25]=h,e[26]=u,e[27]=o,e[28]=s,e[29]=N):N=e[29];let S;e[30]!==_||e[31]!==N?(S=a.jsxs(_t,{className:"flex flex-col items-start gap-2",children:[_,N]}),e[30]=_,e[31]=N,e[32]=S):S=e[32];let C;return e[33]!==S||e[34]!==w?(C=a.jsxs(kt,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[g,w,S]}),e[33]=S,e[34]=w,e[35]=C):C=e[35],C}function Cme(n){const e=V.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=a.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&&a.jsx(Q3,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=a.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 r;e[7]!==t.text?(r=a.jsx(PA,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(Q3,{}),e[9]=s,e[10]=o):o=e[10];let i;return e[11]!==r||e[12]!==o?(i=a.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[r,o]}),e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function Q3(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.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 _me=y.memo(function(){const e=V.c(9),t=Fb();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=Tle(t);if(c.length===0){i=null;break e}const u=new Map;s="px-4",r="streaming-turn-overlay",o=c.map(d=>{const f=u.get(d.messageId)??0;u.set(d.messageId,f+1);const m=d.blocks.reduce(Eme,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(Cme,{block:p,showCursor:!d.stopped&&h===m},p.index))},`${d.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i}else s=e[1],r=e[2],o=e[3],i=e[4];if(i!==Symbol.for("react.early_return_sentinel"))return i;let l;return e[5]!==s||e[6]!==r||e[7]!==o?(l=a.jsx("div",{className:s,"data-testid":r,children:o}),e[5]=s,e[6]=r,e[7]=o,e[8]=l):l=e[8],l});function Eme(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class vI extends y.Component{constructor(t){super(t);Ge(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?a.jsx("div",{className:"flex justify-center p-8",children:a.jsxs(kt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(er,{}),a.jsx(Xt,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(_t,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(Hr,{className:"static col-start-2 mt-2",children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const ej="find-in-session-highlight",Jh="find-in-session-active";function Tme(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 Ame=y.forwardRef(function(e,t){const s=V.c(63),{scrollContainerRef:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],s[0]=u):u=s[0];const[d,f]=y.useState(u),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==r?(g=()=>{const X=r.current;if(!X)return;X.querySelectorAll(`mark.${ej}`).forEach(Ime)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=X=>{if(x(),!X||!r.current){f([]),p(-1);return}const ne=r.current,ae=Tme(ne),ie=X.toLowerCase(),re=[];for(const de of ae){const ce=de.nodeValue||"",oe=ce.toLowerCase();let fe=0;const ue=[];for(;;){const be=oe.indexOf(ie,fe);if(be===-1)break;ue.push(be),fe=be+1}if(ue.length===0)continue;const le=de.parentNode;if(!le)continue;const pe=document.createDocumentFragment();let ge=0;for(const be of ue){be>ge&&pe.appendChild(document.createTextNode(ce.slice(ge,be)));const ve=document.createElement("mark");ve.className=ej,ve.textContent=ce.slice(be,be+X.length),pe.appendChild(ve),re.push(ve),ge=be+X.length}ge<ce.length&&pe.appendChild(document.createTextNode(ce.slice(ge))),le.replaceChild(pe,de)}f(re),re.length>0?(p(0),re[0].classList.add(Jh),re[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==d?(v=X=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(Jh);const ne=(X%d.length+d.length)%d.length;d[ne].classList.add(Jh),d[ne].scrollIntoView({block:"center",behavior:"smooth"}),p(ne)},s[6]=m,s[7]=d,s[8]=v):v=s[8];const j=v;let k;s[9]!==x?(k=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=k):k=s[10];const _=k;let N,S;s[11]!==_||s[12]!==o?(N=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var X;return(X=h.current)==null?void 0:X.focus()})},close:_,isOpen:o}),S=[_,o],s[11]=_,s[12]=o,s[13]=N,s[14]=S):(N=s[13],S=s[14]),y.useImperativeHandle(t,N,S);let C,E;s[15]!==w||s[16]!==l?(C=()=>{const X=setTimeout(()=>w(l),150);return()=>clearTimeout(X)},E=[l,w],s[15]=w,s[16]=l,s[17]=C,s[18]=E):(C=s[17],E=s[18]),y.useEffect(C,E);let T,$;s[19]!==x?(T=()=>()=>x(),$=[x],s[19]=x,s[20]=T,s[21]=$):(T=s[20],$=s[21]),y.useEffect(T,$);let A;s[22]!==m||s[23]!==j||s[24]!==_?(A=X=>{X.key==="Escape"?(X.preventDefault(),X.stopPropagation(),_()):X.key==="Enter"&&(X.preventDefault(),X.shiftKey?j(m-1):j(m+1))},s[22]=m,s[23]=j,s[24]=_,s[25]=A):A=s[25];const R=A;if(!o)return null;let P;s[26]===Symbol.for("react.memo_cache_sentinel")?(P=X=>c(X.target.value),s[26]=P):P=s[26];let z;s[27]!==R||s[28]!==l?(z=a.jsx(Go,{ref:h,value:l,onChange:P,onKeyDown:R,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=R,s[28]=l,s[29]=z):z=s[29];const L=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let I;s[30]!==L?(I=a.jsx(Ar,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:L})}),s[30]=L,s[31]=I):I=s[31];let M;s[32]!==z||s[33]!==I?(M=a.jsxs(Ko,{className:"w-64",children:[z,I]}),s[32]=z,s[33]=I,s[34]=M):M=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 U=d.length===0,O=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let D;s[38]!==O?(D=G("text-muted-foreground",O),s[38]=O,s[39]=D):D=s[39];let B;s[40]===Symbol.for("react.memo_cache_sentinel")?(B=a.jsx(ja,{"data-icon":"inline-start"}),s[40]=B):B=s[40];let q;s[41]!==F||s[42]!==U||s[43]!==D?(q=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:F,disabled:U,className:D,"aria-label":"Previous match",children:B}),s[41]=F,s[42]=U,s[43]=D,s[44]=q):q=s[44];let W;s[45]!==m||s[46]!==j?(W=()=>j(m+1),s[45]=m,s[46]=j,s[47]=W):W=s[47];const H=d.length===0,K=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==K?(Z=G("text-muted-foreground",K),s[48]=K,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(Et,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let J;s[51]!==W||s[52]!==H||s[53]!==Z?(J=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:W,disabled:H,className:Z,"aria-label":"Next match",children:Y}),s[51]=W,s[52]=H,s[53]=Z,s[54]=J):J=s[54];let ee;s[55]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(Mt,{"data-icon":"inline-start"}),s[55]=ee):ee=s[55];let te;s[56]!==_?(te=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:ee}),s[56]=_,s[57]=te):te=s[57];let se;return s[58]!==M||s[59]!==q||s[60]!==J||s[61]!==te?(se=a.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:[M,q,J,te]}),s[58]=M,s[59]=q,s[60]=J,s[61]=te,s[62]=se):se=s[62],se});function Ime(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const yI=[1,2,3,4,5,6,7,8,9],K2e=["General","View","Tools"],Em=[{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}},...yI.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}}],wI="cogpit-keybindings";let oi=null;function SI(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function xc(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function Pme(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function Gb(){if(oi)return oi;try{const n=localStorage.getItem(wI);if(!n)return oi={};const e=JSON.parse(n);if(!e||typeof e!="object")return oi={};const t={};for(const s of Em){const r=e[s.command];Pme(r)&&(t[s.command]=r)}return oi=t}catch{return oi={}}}function Zb(n){oi=n;try{localStorage.setItem(wI,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function nu(n){const e=Em.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return Gb()[n]??e.defaultShortcut}function G2e(){return Object.fromEntries(Em.map(n=>[n.command,nu(n.command)]))}function Z2e(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:xc(e.key)};Zb({...Gb(),[n]:t})}function Y2e(n){const e={...Gb()};delete e[n],Zb(e)}function X2e(){Zb({})}function J2e(n){return{key:xc(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function kI(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function on(n,e){const t=nu(n);return"doubleTapModifier"in t||xc(e.key)!==xc(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 Mi(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 $me(n){const e=SI();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Mi(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Mi(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Mi(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Mi(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Mi(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Mi(n.key)].filter(Boolean).join("+")}function ea(n){return $me(nu(n))}function tj(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${xc(n.key)}|${t}|${s}|${r}|${o}`;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 Q2e(n,e){const t=new Set(tj(n));return Em.find(s=>s.command!==e&&tj(nu(s.command)).some(r=>t.has(r)))??null}function nj(n){return"doubleTapModifier"in nu(n)?SI()?"Meta":"Control":null}const Rme=yI.map(n=>`device.switch.${n}`),Ome="device.cycle";function Lme(n){const e=Rme.findIndex(t=>on(t,n));return e===-1?null:e+1}function Mme(n){return on(Ome,n)}const M1="cogpit:find-in-conversation",Tm=y.memo(function(e){const t=V.c(87),{searchInputRef:s,hasTodos:r,hasMore:o,isLoadingOlder:i,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:u}=e,d=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=Sn(),{session:h,sessionSource:g,rateLimit:x,permissions:b,isSubAgentView:w}=jt(),v=Nn("terminal"),{chat:j,scroll:k}=Wf(),{searchQuery:_}=f,{pendingMessages:N}=j,{chatScrollRef:S,observeChatContent:C,handleScroll:E,canScrollDown:T,scrollToBottomInstant:$,initialScrollDone:A}=k,R=y.useRef(null);let P;t[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{var we;return(we=R.current)==null?void 0:we.open()},t[0]=P):P=t[0];const z=P;let L,I;t[1]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{const we=function($e){on("findInConversation",$e)&&($e.preventDefault(),z())};return window.addEventListener("keydown",we),window.addEventListener(M1,z),()=>{window.removeEventListener("keydown",we),window.removeEventListener(M1,z)}},I=[z],t[1]=L,t[2]=I):(L=t[1],I=t[2]),y.useEffect(L,I);let M,F;t[3]!==p||t[4]!==d||t[5]!==s?(M=()=>{!p||!d||requestAnimationFrame(()=>{var we;return(we=s.current)==null?void 0:we.focus()})},F=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=M,t[7]=F):(M=t[6],F=t[7]),y.useEffect(M,F);let U;t[8]!==m||t[9]!==u?(U=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=U):U=t[10];const O=U,D=h;let B;t[11]!==x||t[12]!==g?(B=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=B):B=t[13];const q=B,W=D.turns.length>0||N.length===0;let H;t[14]!==O||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==_?(H=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(Ko,{className:"h-9 flex-1",children:[a.jsx(Go,{ref:s,value:_,onChange:we=>m({type:"SET_SEARCH_QUERY",value:we.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(Ar,{align:"inline-start",children:a.jsx(ss,{})})]}),a.jsx(Q,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":"Close conversation search",children:a.jsx(Mt,{"data-icon":"inline-start"})})]}),t[14]=O,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=_,t[20]=H):H=t[20];let K;t[21]!==v||t[22]!==D.cwd||t[23]!==p||t[24]!==b.send||t[25]!==q?(K=q&&a.jsx("div",{className:G("shrink-0",!p&&"pt-10"),children:a.jsx(Nme,{...q,cwd:D.cwd,terminal:v&&b.send})}),t[21]=v,t[22]=D.cwd,t[23]=p,t[24]=b.send,t[25]=q,t[26]=K):K=t[26];let Z;t[27]!==S?(Z=a.jsx(Ame,{ref:R,scrollContainerRef:S}),t[27]=S,t[28]=Z):Z=t[28];let Y;t[29]!==S||t[30]!==D?(Y=a.jsx(vme,{session:D,scrollContainerRef:S}),t[29]=S,t[30]=D,t[31]=Y):Y=t[31];const J=p&&"mobile-scroll";let ee;t[32]!==J?(ee=G("h-full overflow-x-hidden overflow-y-auto",J),t[32]=J,t[33]=ee):ee=t[33];let te;t[34]!==p||t[35]!==q?(te=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6",q?"pt-4":"pt-14"),t[34]=p,t[35]=q,t[36]=te):te=t[36];let se;t[37]!==r||t[38]!==p?(se=p?void 0:{paddingBottom:`max(var(--session-footer-height, 0px), ${r?12:8}rem)`},t[37]=r,t[38]=p,t[39]=se):se=t[39];let X;t[40]!==S||t[41]!==o||t[42]!==A||t[43]!==i||t[44]!==l||t[45]!==W?(X=W&&a.jsx(fme,{chatScrollRef:S,hasMore:o,isLoadingOlder:i,pagingEnabled:A,onLoadMore:l}),t[40]=S,t[41]=o,t[42]=A,t[43]=i,t[44]=l,t[45]=W,t[46]=X):X=t[46];let ne,ae;t[47]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(_me,{}),ae=a.jsx(Nfe,{}),t[47]=ne,t[48]=ae):(ne=t[47],ae=t[48]);const ie=b.send&&!w;let re;t[49]!==D.sessionId||t[50]!==D.turns||t[51]!==p||t[52]!==N||t[53]!==ie?(re=a.jsx(hA,{sessionId:D.sessionId,turns:D.turns,pendingMessages:N,canManage:ie,isMobile:p}),t[49]=D.sessionId,t[50]=D.turns,t[51]=p,t[52]=N,t[53]=ie,t[54]=re):re=t[54];let de;t[55]!==X||t[56]!==re?(de=a.jsxs(vI,{fallbackMessage:"Failed to render conversation timeline",children:[X,ne,ae,re]}),t[55]=X,t[56]=re,t[57]=de):de=t[57];let ce;t[58]!==C||t[59]!==te||t[60]!==se||t[61]!==de?(ce=a.jsx("div",{ref:C,className:te,style:se,children:de}),t[58]=C,t[59]=te,t[60]=se,t[61]=de,t[62]=ce):ce=t[62];let oe;t[63]!==S||t[64]!==E||t[65]!==ee||t[66]!==ce?(oe=a.jsx("div",{ref:S,onScroll:E,className:ee,children:ce}),t[63]=S,t[64]=E,t[65]=ee,t[66]=ce,t[67]=oe):oe=t[67];const fe=T?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",ue=p?"right-3 bottom-3":"right-5";let le;t[68]!==fe||t[69]!==ue?(le=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",fe,ue),t[68]=fe,t[69]=ue,t[70]=le):le=t[70];let pe;t[71]!==p?(pe=p?void 0:{bottom:"calc(var(--session-footer-height, 0px) + 1.25rem)"},t[71]=p,t[72]=pe):pe=t[72];let ge;t[73]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx(y8,{"data-icon":"inline-start"}),t[73]=ge):ge=t[73];let be;t[74]!==$||t[75]!==le||t[76]!==pe?(be=a.jsx(Q,{size:"icon",className:le,style:pe,onClick:$,"aria-label":"Scroll to bottom",children:ge}),t[74]=$,t[75]=le,t[76]=pe,t[77]=be):be=t[77];let ve;t[78]!==Z||t[79]!==Y||t[80]!==oe||t[81]!==be?(ve=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[Z,Y,oe,be]}),t[78]=Z,t[79]=Y,t[80]=oe,t[81]=be,t[82]=ve):ve=t[82];let Se;return t[83]!==K||t[84]!==ve||t[85]!==H?(Se=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[H,K,ve]}),t[83]=K,t[84]=ve,t[85]=H,t[86]=Se):Se=t[86],Se});function zme({open:n,onOpenChange:e,trigger:t,title:s,description:r,confirmLabel:o,destructive:i=!1,onConfirm:l}){const[c,u]=y.useState(!1),[d,f]=y.useState(null);function m(h){c||(f(null),e(h))}async function p(){u(!0),f(null);try{f(await l())}finally{u(!1)}}return a.jsxs(rb,{open:n,onOpenChange:m,children:[t&&a.jsx(Lte,{render:t}),a.jsxs(ob,{size:"sm",children:[a.jsxs(ib,{children:[a.jsx(lb,{children:s}),a.jsx(cb,{children:r})]}),d&&a.jsx(Eo,{className:"text-center",children:d}),a.jsxs(ab,{children:[a.jsx(db,{disabled:c,children:"Cancel"}),a.jsxs(ub,{variant:i?"destructive":"default",disabled:c,onClick:()=>void p(),children:[c&&a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),o]})]})]})]})}function Dme(n){const e=V.c(21),{children:t,error:s,busy:r,saveLabel:o,onCancel:i,onSave:l,className:c}=n;let u;e[0]!==c?(u=G("flex flex-col gap-3 border-t px-3 py-3",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]!==s?(d=s&&a.jsx(Eo,{children:s}),e[2]=s,e[3]=d):d=e[3];let f;e[4]!==i?(f=a.jsx(Q,{variant:"outline",size:"sm",onClick:i,children:"Cancel"}),e[4]=i,e[5]=f):f=e[5];let m;e[6]!==r||e[7]!==o?(m=r?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):o,e[6]=r,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==l||e[11]!==m?(p=a.jsx(Q,{size:"sm",disabled:r,onClick:l,children:m}),e[9]=r,e[10]=l,e[11]=m,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==p?(h=a.jsxs("div",{className:"flex justify-end gap-1.5",children:[f,p]}),e[13]=f,e[14]=p,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==u||e[18]!==d||e[19]!==h?(g=a.jsxs("div",{className:u,children:[t,d,h]}),e[16]=t,e[17]=u,e[18]=d,e[19]=h,e[20]=g):g=e[20],g}const Fme={ArrowUp:-1,ArrowDown:1};function sj(n,e,t){const s=n.filter(r=>r!==e);return s.splice(t,0,e),s}function rj(n,e){return n.length===e.length&&n.every((t,s)=>t===e[s])}function Ume(n,e){const t=V.c(26),[s,r]=y.useState(null),[o,i]=y.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Map,t[0]=l):l=t[0];const c=y.useRef(l),u=y.useRef(null),d=y.useRef(0),f=y.useRef(null);let m;t[1]!==s||t[2]!==n?(m=s??[...n],t[1]=s,t[2]=n,t[3]=m):m=t[3];const p=m;let h;t[4]!==n||t[5]!==e?(h={ids:n,onCommit:e},t[4]=n,t[5]=e,t[6]=h):h=t[6];const g=y.useRef(h);let x;t[7]!==n||t[8]!==e?(x=()=>{g.current={ids:n,onCommit:e}},t[7]=n,t[8]=e,t[9]=x):x=t[9],y.useLayoutEffect(x);let b;t[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const L=u.current,I=L&&c.current.get(L.id);if(!L||!I)return;I.style.transform="";const M=I.getBoundingClientRect().top;I.style.transform=`translateY(${d.current-L.grabOffset-M}px)`},t[10]=b):b=t[10];const w=b;let v;t[11]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{w()},t[11]=v):v=t[11];let j;t[12]!==s?(j=[s,w],t[12]=s,t[13]=j):j=t[13],y.useLayoutEffect(v,j);let k;t[14]===Symbol.for("react.memo_cache_sentinel")?(k=L=>I=>{I?c.current.set(L,I):c.current.delete(L)},t[14]=k):k=t[14];const _=k,N=y.useRef(null);let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=L=>{var U;const I=u.current;if(!I)return;u.current=null,(U=N.current)==null||U.call(N),N.current=null;const M=c.current.get(I.id);M&&(M.style.transform="");const F=f.current;f.current=null,i(null),r(null),L&&F&&!rj(F,I.startOrder)&&g.current.onCommit(F)},t[15]=S):S=t[15];const C=S;let E,T;t[16]===Symbol.for("react.memo_cache_sentinel")?(T=()=>()=>{var L;return(L=N.current)==null?void 0:L.call(N)},E=[],t[16]=E,t[17]=T):(E=t[16],T=t[17]),y.useEffect(T,E);let $;t[18]===Symbol.for("react.memo_cache_sentinel")?($=L=>{const I=u.current;if(!I||I.pointerId!==L.pointerId)return;d.current=L.clientY;const M=f.current;if(!M)return;const F=M.filter(O=>{var B;if(O===I.id)return!1;const D=(B=c.current.get(O))==null?void 0:B.getBoundingClientRect();return!!D&&D.top+D.height/2<L.clientY}).length,U=sj(M,I.id,F);rj(U,M)||(f.current=U,r(U)),w()},t[18]=$):$=t[18];const A=$;let R;t[19]!==n||t[20]!==e?(R=L=>({onPointerDown:I=>{if(I.button!==0||u.current)return;const M=c.current.get(L);if(!M)return;d.current=I.clientY,u.current={id:L,pointerId:I.pointerId,grabOffset:I.clientY-M.getBoundingClientRect().top,startOrder:[...n]};const F=[...n];f.current=F,i(L),r(F);const U=D=>{D.pointerId===I.pointerId&&C(!0)},O=D=>{D.pointerId===I.pointerId&&C(!1)};window.addEventListener("pointermove",A),window.addEventListener("pointerup",U),window.addEventListener("pointercancel",O),N.current=()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",O)}},onKeyDown:I=>{const M=Fme[I.key];if(M===void 0)return;I.preventDefault();const F=n.indexOf(L),U=F+M;F===-1||U<0||U>=n.length||e(sj(n,L,U))}}),t[19]=n,t[20]=e,t[21]=R):R=t[21];const P=R;let z;return t[22]!==o||t[23]!==P||t[24]!==p?(z={order:p,draggingId:o,rowRef:_,handleProps:P},t[22]=o,t[23]=P,t[24]=p,t[25]=z):z=t[25],z}const z1="cogpit-devices-changed",jI="cogpit:devices-changed";function NI(n){typeof n.connectionRevision=="number"&&pR(n.id,n.connectionRevision)}function D1(n,e,t=!1){window.dispatchEvent(new CustomEvent(z1,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(jI,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function oj(n){NI(n),D1(n.id,n.connectionRevision)}function ij(n){const e=Kt();e!==Ot&&!n.some(t=>t.id===e)&&Xs(Ot)}function Qh(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function CI(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function Bme(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.signIn;if(t==="account"||t==="password")return t}}function Si({enabled:n=!0}={}){const[e,t]=y.useState([]),[s,r]=y.useState(!0),[o,i]=y.useState(()=>Kt()),l=y.useRef(0),c=y.useRef(Promise.resolve()),u=y.useRef(0),d=y.useCallback(async()=>{const w=++l.current;if(!n){t([]),r(!1);return}try{const v=await Ur("/api/hub/devices");if(v.status===403&&w===l.current&&ij([]),!v.ok)return;const j=await zs(v);if(w!==l.current)return;const k=Array.isArray(j==null?void 0:j.devices)?j.devices:[];for(const _ of k)NI(_);if(u.current>0)return;t(k),ij(k)}catch{}finally{w===l.current&&r(!1)}},[n]);y.useEffect(()=>{d()},[d]),y.useEffect(()=>{const w=()=>i(Kt()),v=()=>void d(),j=N=>{if(N.key===jI){try{const S=JSON.parse(N.newValue??"null");(S==null?void 0:S.removed)===!0&&typeof S.deviceId=="string"&&Kt()===S.deviceId&&Xs(Ot)}catch{}d()}},k=()=>{l.current+=1,t([]),r(!0),d()},_=()=>{l.current+=1,t([]),r(!1)};return window.addEventListener("cogpit-device-changed",w),window.addEventListener("popstate",w),window.addEventListener(z1,v),window.addEventListener("storage",j),window.addEventListener("cogpit-auth-changed",k),window.addEventListener("cogpit-identity-changed",k),window.addEventListener("cogpit-auth-required",_),()=>{window.removeEventListener("cogpit-device-changed",w),window.removeEventListener("popstate",w),window.removeEventListener(z1,v),window.removeEventListener("storage",j),window.removeEventListener("cogpit-auth-changed",k),window.removeEventListener("cogpit-identity-changed",k),window.removeEventListener("cogpit-auth-required",_)}},[d]);const f=y.useMemo(()=>o===Ot?void 0:e.find(w=>w.id===o),[e,o]),m=y.useCallback(async(w,v,j,k)=>{try{const _=await Ur("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:w,port:v,allowLocalTunnel:j,tls:k})}),N=await zs(_);return(N==null?void 0:N.ok)===!0&&N.hello?{ok:!0,hello:N.hello}:{ok:!1,code:(N==null?void 0:N.code)??"UNREACHABLE",error:typeof(N==null?void 0:N.error)=="string"?N.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),p=y.useCallback(async w=>{try{const v=await Ur("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w)}),j=await zs(v);if(v.ok&&(j!=null&&j.device)){const k=j.device;return oj(k),{ok:!0,device:k}}return{ok:!1,code:(j==null?void 0:j.code)??"ERROR",error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),h=y.useCallback(async(w,v)=>{try{const j=await Ur(Qh(w),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(v)}),k=await zs(j);if(j.ok&&(k!=null&&k.device)){const _=k.device;return oj(_),{ok:!0,device:_}}return{ok:!1,code:(k==null?void 0:k.code)??"ERROR",error:typeof(k==null?void 0:k.error)=="string"?k.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),g=y.useCallback(async w=>{try{const v=await Ur(Qh(w),{method:"DELETE"});if(v.ok)return Kt()===w&&Xs(Ot),D1(w,void 0,!0),{ok:!0};const j=await zs(v);return{ok:!1,error:typeof(j==null?void 0:j.error)=="string"?j.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),x=y.useCallback(async w=>{const v=new Map(w.map((C,E)=>[C,E])),j=C=>v.get(C.id)??w.length;t(C=>[...C].sort((E,T)=>j(E)-j(T))),u.current+=1;const k=async()=>{try{const C=await Ur("/api/hub/devices/order",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ids:w})}),E=await zs(C);return C.ok&&Array.isArray(E==null?void 0:E.devices)?{result:{ok:!0},devices:E.devices}:{result:{ok:!1,error:typeof(E==null?void 0:E.error)=="string"?E.error:"Could not reorder the devices."}}}catch{return{result:{ok:!1,error:"Could not reorder the devices."}}}},_=c.current.then(k);c.current=_.then(()=>{});const{result:N,devices:S}=await _;return u.current-=1,u.current===0&&(S?(t(S),D1("")):d()),N},[d]),b=y.useCallback(async w=>{try{const v=await Ur(Qh(w,"/test"),{method:"POST"});return await zs(v)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:e,activeDeviceId:o,activeDevice:f,loading:s,refresh:d,probe:m,addDevice:p,updateDevice:h,removeDevice:g,reorderDevices:x,testDevice:b}}const aj=o_.version,Wme=19384,qme=443,Vme=450,Hme=ea("device.switch.1").replace(/1$/,"1–9"),Kme=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),Gme=new Set(["ACCOUNT_REFUSED"]);function qu(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),r=/^(.+):(\d+)$/.exec(s),o=r?r[1]:s,i=r?Number(r[2]):void 0;return t?{host:o,port:i,tls:!0}:{host:o,port:i}}function Zme(n,e,t){if(n.ok){if(n.hello.signIn==="account"&&n.hello.setupRequired===!0)return{tone:"info",text:"Reachable server — finish its setup before adding it here."};if(n.hello.signIn!=="account"&&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}"`:"",r=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${r}.`}}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 _I={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function Yme(n){const e=V.c(10),{tone:t}=n,s=_I[t];let r;e[0]!==s?(r=G("size-3.5 shrink-0",s),e[0]=s,e[1]=r):r=e[1];const o=r;if(t==="ok"){let l;return e[2]!==o?(l=a.jsx(Pr,{"data-icon":"inline-start",className:o}),e[2]=o,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==o?(l=a.jsx(er,{"data-icon":"inline-start",className:o}),e[4]=o,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==o?(l=a.jsx(Fn,{"data-icon":"inline-start",className:o}),e[6]=o,e[7]=l):l=e[7],l}let i;return e[8]!==o?(i=a.jsx(Bo,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const Xme={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function Jme(n){const e=V.c(119),{device:t,onRename:s,onCredentials:r,onRemove:o,onTest:i,slot:l,rowRef:c,dragging:u,dragHandleProps:d}=n,[f,m]=y.useState(!1),[p,h]=y.useState(t.name),[g,x]=y.useState(!1),[b,w]=y.useState(t.username??""),[v,j]=y.useState(""),[k,_]=y.useState(null),[N,S]=y.useState(!1),[C,E]=y.useState(null);let T,$;e[0]!==t.name?(T=()=>{h(t.name)},$=[t.name],e[0]=t.name,e[1]=T,e[2]=$):(T=e[1],$=e[2]),y.useEffect(T,$);let A,R;e[3]!==t.username?(A=()=>{w(t.username??"")},R=[t.username],e[3]=t.username,e[4]=A,e[5]=R):(A=e[4],R=e[5]),y.useEffect(A,R);let P;e[6]!==t?(P=CI(t),e[6]=t,e[7]=P):P=e[7];const z=P,L=z!==void 0&&z!==aj;let I;e[8]!==t?(I=Bme(t),e[8]=t,e[9]=I):I=e[9];const M=I==="account",F=l<=9;let U;e[10]!==t.id||e[11]!==t.name||e[12]!==p||e[13]!==s?(U=async function(){const ye=p.trim();if(!ye||ye===t.name){m(!1),h(t.name);return}E("rename"),await s(t.id,ye),E(null),m(!1)},e[10]=t.id,e[11]=t.name,e[12]=p,e[13]=s,e[14]=U):U=e[14];const O=U;let D;e[15]!==v||e[16]!==b||e[17]!==t.auth||e[18]!==t.id||e[19]!==t.username||e[20]!==r?(D=async function(){const ye=b.trim(),Re=t.username??"",Ve=ye!==Re,He=v.length>0;if(!Ve&&!He){x(!1),j(""),_(null);return}if(t.auth==="none"&&!He){_("Enter a password when adding an account to an unauthenticated device.");return}const me={};Ve&&(me.username=ye||null),He&&(me.password=v),E("credentials"),_(null);const je=await r(t.id,me);if(E(null),!je.ok){_(je.error);return}x(!1),j("")},e[15]=v,e[16]=b,e[17]=t.auth,e[18]=t.id,e[19]=t.username,e[20]=r,e[21]=D):D=e[21];const B=D,q=u&&"relative z-10 shadow-lg";let W;e[22]!==q?(W=G("rounded-lg border bg-card",q),e[22]=q,e[23]=W):W=e[23];const H=`Reorder ${t.name}`;let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(w8,{className:"size-4"}),e[24]=K):K=e[24];let Z;e[25]!==d||e[26]!==H?(Z=a.jsx("button",{type:"button","aria-label":H,title:"Drag to reorder (or use ↑ ↓)",className:"-ml-1 flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",...d,children:K}),e[25]=d,e[26]=H,e[27]=Z):Z=e[27];let Y;e[28]!==F||e[29]!==l?(Y=F?`${ea(`device.switch.${l}`)} opens this device`:"No shortcut",e[28]=F,e[29]=l,e[30]=Y):Y=e[30];const J=F&&l;let ee;e[31]!==Y||e[32]!==J?(ee=a.jsx("span",{className:"w-4 shrink-0 text-center font-mono text-xs text-muted-foreground",title:Y,children:J}),e[31]=Y,e[32]=J,e[33]=ee):ee=e[33];const te=`Status: ${t.runtime.authState}`,se=Xme[t.runtime.authState];let X;e[34]!==se?(X=G("size-2 shrink-0 rounded-full",se),e[34]=se,e[35]=X):X=e[35];let ne;e[36]!==te||e[37]!==X?(ne=a.jsx("span",{"aria-label":te,className:X}),e[36]=te,e[37]=X,e[38]=ne):ne=e[38];let ae;e[39]!==t.auth||e[40]!==t.name||e[41]!==f||e[42]!==p||e[43]!==O||e[44]!==L||e[45]!==z?(ae=f?a.jsx(On,{value:p,autoFocus:!0,"aria-label":`Rename ${t.name}`,onChange:We=>h(We.target.value),onKeyDown:We=>{We.key==="Enter"&&O(),We.key==="Escape"&&(m(!1),h(t.name))},onBlur:()=>void O(),className:"h-6 text-sm"}):a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate text-sm text-foreground",children:t.name}),z&&a.jsxs("span",{className:G("shrink-0 font-mono text-xs",L?"text-warning":"text-muted-foreground"),title:L?`Device runs v${z}; hub runs v${aj}`:void 0,children:["v",z,L&&" ≠ hub"]}),t.auth==="none"&&a.jsx(Fe,{variant:"secondary",children:"Unauthenticated"})]}),e[39]=t.auth,e[40]=t.name,e[41]=f,e[42]=p,e[43]=O,e[44]=L,e[45]=z,e[46]=ae):ae=e[46];const ie=t.tls?"https://":"";let re;e[47]!==t.host||e[48]!==t.port||e[49]!==ie?(re=a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[ie,t.host,":",t.port]}),e[47]=t.host,e[48]=t.port,e[49]=ie,e[50]=re):re=e[50];let de;e[51]!==M||e[52]!==t.username?(de=t.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:t.username,children:["Account: ",t.username]}):M?a.jsx("span",{className:"text-xs text-warning",children:"Account not configured"}):null,e[51]=M,e[52]=t.username,e[53]=de):de=e[53];let ce;e[54]!==ae||e[55]!==re||e[56]!==de?(ce=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[ae,re,de]}),e[54]=ae,e[55]=re,e[56]=de,e[57]=ce):ce=e[57];const oe=`Re-test ${t.name}`,fe=C==="test";let ue;e[58]!==t.id||e[59]!==i?(ue=async()=>{E("test"),await i(t.id),E(null)},e[58]=t.id,e[59]=i,e[60]=ue):ue=e[60];const le=C==="test"&&"animate-spin";let pe;e[61]!==le?(pe=G(le),e[61]=le,e[62]=pe):pe=e[62];let ge;e[63]!==pe?(ge=a.jsx(Fn,{"data-icon":"inline-start",className:pe}),e[63]=pe,e[64]=ge):ge=e[64];let be;e[65]!==oe||e[66]!==fe||e[67]!==ue||e[68]!==ge?(be=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":oe,disabled:fe,onClick:ue,children:ge}),e[65]=oe,e[66]=fe,e[67]=ue,e[68]=ge,e[69]=be):be=e[69];const ve=`Edit account for ${t.name}`;let Se;e[70]!==t.username?(Se=()=>{x(Qme),w(t.username??""),j(""),_(null)},e[70]=t.username,e[71]=Se):Se=e[71];let we;e[72]===Symbol.for("react.memo_cache_sentinel")?(we=a.jsx(S8,{"data-icon":"inline-start"}),e[72]=we):we=e[72];let Ee;e[73]!==ve||e[74]!==Se?(Ee=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":ve,onClick:Se,children:we}),e[73]=ve,e[74]=Se,e[75]=Ee):Ee=e[75];const $e=`Rename ${t.name}`;let Be,qe;e[76]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>m(!0),qe=a.jsx(wr,{"data-icon":"inline-start"}),e[76]=Be,e[77]=qe):(Be=e[76],qe=e[77]);let ze;e[78]!==$e?(ze=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":$e,onClick:Be,children:qe}),e[78]=$e,e[79]=ze):ze=e[79];const Ie=`Remove ${t.name}`;let Me;e[80]===Symbol.for("react.memo_cache_sentinel")?(Me=a.jsx(kf,{"data-icon":"inline-start"}),e[80]=Me):Me=e[80];let Ue;e[81]!==Ie?(Ue=a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":Ie,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:Me}),e[81]=Ie,e[82]=Ue):Ue=e[82];let De;e[83]!==t.name?(De=a.jsxs(a.Fragment,{children:["Remove ",t.name,"?"]}),e[83]=t.name,e[84]=De):De=e[84];let Ke;e[85]!==t.id||e[86]!==o?(Ke=async()=>(await o(t.id),null),e[85]=t.id,e[86]=o,e[87]=Ke):Ke=e[87];let Ne;e[88]!==N||e[89]!==Ue||e[90]!==De||e[91]!==Ke?(Ne=a.jsx(zme,{open:N,onOpenChange:S,trigger:Ue,title:De,description:"This device will disappear from Cogpit. You can add it again later.",confirmLabel:"Remove device",destructive:!0,onConfirm:Ke}),e[88]=N,e[89]=Ue,e[90]=De,e[91]=Ke,e[92]=Ne):Ne=e[92];let Ae;e[93]!==be||e[94]!==Ee||e[95]!==ze||e[96]!==Ne?(Ae=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[be,Ee,ze,Ne]}),e[93]=be,e[94]=Ee,e[95]=ze,e[96]=Ne,e[97]=Ae):Ae=e[97];let Qe;e[98]!==Z||e[99]!==ee||e[100]!==ne||e[101]!==ce||e[102]!==Ae?(Qe=a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[Z,ee,ne,ce,Ae]}),e[98]=Z,e[99]=ee,e[100]=ne,e[101]=ce,e[102]=Ae,e[103]=Qe):Qe=e[103];let Je;e[104]!==C||e[105]!==k||e[106]!==v||e[107]!==b||e[108]!==t.id||e[109]!==t.name||e[110]!==t.username||e[111]!==g||e[112]!==B?(Je=g&&a.jsxs(Dme,{error:k,busy:C==="credentials",saveLabel:"Save account",onCancel:()=>{x(!1),w(t.username??""),j(""),_(null)},onSave:()=>void B(),children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-username-${t.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(account sign-in)"})]}),a.jsx(On,{id:`device-username-${t.id}`,"aria-label":`Username for ${t.name}`,value:b,onChange:We=>w(We.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(fn,{children:[a.jsxs(mn,{htmlFor:`device-password-${t.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(On,{id:`device-password-${t.id}`,"aria-label":`New password for ${t.name}`,type:"password",value:v,onChange:We=>j(We.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),t.username&&b.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."})]}),e[104]=C,e[105]=k,e[106]=v,e[107]=b,e[108]=t.id,e[109]=t.name,e[110]=t.username,e[111]=g,e[112]=B,e[113]=Je):Je=e[113];let ke;return e[114]!==c||e[115]!==W||e[116]!==Qe||e[117]!==Je?(ke=a.jsxs("div",{ref:c,className:W,children:[Qe,Je]}),e[114]=c,e[115]=W,e[116]=Qe,e[117]=Je,e[118]=ke):ke=e[118],ke}function Qme(n){return!n}function EI(n){var dt,zt;const e=V.c(121),{open:t,initialMode:s,onClose:r}=n,{devices:o,refresh:i,probe:l,addDevice:c,updateDevice:u,removeDevice:d,reorderDevices:f,testDevice:m}=Si(),[p,h]=y.useState(""),[g,x]=y.useState(""),[b,w]=y.useState(""),[v,j]=y.useState(""),[k,_]=y.useState(!1),[N,S]=y.useState(!1),[C,E]=y.useState(null),[T,$]=y.useState(!1),[A,R]=y.useState(null),P=y.useRef(null),z=y.useRef(0);let L,I;e[0]!==s||e[1]!==t?(L=()=>{t&&(h(""),x(""),w(""),j(""),_(!1),S(!1),E(null),R(null),s==="add"&&requestAnimationFrame(()=>{var st;return(st=P.current)==null?void 0:st.focus()}))},I=[t,s],e[0]=s,e[1]=t,e[2]=L,e[3]=I):(L=e[2],I=e[3]),y.useEffect(L,I);let M;e[4]!==k||e[5]!==g||e[6]!==l?(M=async()=>{const{host:st,port:Tt,tls:At}=qu(g);if(!st){E(null),S(!1);return}const Qt=z.current=z.current+1;S(!0);const It=await l(st,Tt,k,At);Qt===z.current&&(E({...Zme(It,st,Tt??(At?qme:Wme)),hello:It.ok?It.hello:void 0}),S(!1))},e[4]=k,e[5]=g,e[6]=l,e[7]=M):M=e[7];const F=M;let U,O;e[8]!==g||e[9]!==t||e[10]!==F?(U=()=>{if(!t)return;if(!qu(g).host){E(null),S(!1);return}const st=window.setTimeout(()=>void F(),Vme);return()=>window.clearTimeout(st)},O=[t,g,F],e[8]=g,e[9]=t,e[10]=F,e[11]=U,e[12]=O):(U=e[11],O=e[12]),y.useEffect(U,O);const D=((dt=C==null?void 0:C.hello)==null?void 0:dt.signIn)==="account",B=D&&((zt=C==null?void 0:C.hello)==null?void 0:zt.setupRequired)===!0,q=D||!k;let W;e:{if(T){W=!1;break e}if(!qu(g).host){W=!1;break e}if(N||!C){W=!1;break e}if(B){W=!1;break e}if(q&&!v){W=!1;break e}if(D&&!b.trim()){W=!1;break e}if((C==null?void 0:C.tone)==="error"){W=!1;break e}W=!0}const H=W;let K;e[13]!==c||e[14]!==k||e[15]!==q||e[16]!==g||e[17]!==p||e[18]!==r||e[19]!==v||e[20]!==D||e[21]!==b?(K=async function(){const{host:Tt,port:At,tls:Qt}=qu(g);if(!Tt)return;$(!0),R(null);const It=await c({name:p.trim()||void 0,host:Tt,port:At,tls:Qt,username:D?b.trim():void 0,password:q&&v||void 0,allowLocalTunnel:k});if($(!1),It.ok){r(),Xs(It.device.id);return}R({field:Gme.has(It.code)?"username":Kme.has(It.code)?"password":"host",message:It.error})},e[13]=c,e[14]=k,e[15]=q,e[16]=g,e[17]=p,e[18]=r,e[19]=v,e[20]=D,e[21]=b,e[22]=K):K=e[22];const Z=K;let Y;e[23]!==u?(Y=async(st,Tt)=>{await u(st,{name:Tt})},e[23]=u,e[24]=Y):Y=e[24];const J=Y;let ee;e[25]!==d?(ee=async st=>{await d(st)},e[25]=d,e[26]=ee):ee=e[26];const te=ee;let se;e[27]!==o?(se=o.map(epe),e[27]=o,e[28]=se):se=e[28];const{order:X,draggingId:ne,rowRef:ae,handleProps:ie}=Ume(se,f);let re;e[29]!==i||e[30]!==m?(re=async st=>{await m(st),await i()},e[29]=i,e[30]=m,e[31]=re):re=e[31];const de=re;let ce;e[32]!==r?(ce=st=>{st||r()},e[32]=r,e[33]=ce):ce=e[33];let oe;e[34]===Symbol.for("react.memo_cache_sentinel")?(oe=a.jsxs(ao,{children:[a.jsx(or,{children:"Devices"}),a.jsxs(ir,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",Hme," jumps between devices. Drag a device by its handle to change its number; this machine is always 1."]})]}),e[34]=oe):oe=e[34];let fe;e[35]!==o||e[36]!==ne||e[37]!==ie||e[38]!==te||e[39]!==J||e[40]!==de||e[41]!==X||e[42]!==ae||e[43]!==u?(fe=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:X.map((st,Tt)=>{const At=o.find(Qt=>Qt.id===st);return At?a.jsx(Jme,{device:At,slot:Tt+2,rowRef:ae(At.id),dragging:ne===At.id,dragHandleProps:ie(At.id),onRename:J,onCredentials:u,onRemove:te,onTest:de},At.id):null})}),e[35]=o,e[36]=ne,e[37]=ie,e[38]=te,e[39]=J,e[40]=de,e[41]=X,e[42]=ae,e[43]=u,e[44]=fe):fe=e[44];let ue;e[45]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kr,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),a.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[45]=ue):ue=e[45];const le=(A==null?void 0:A.field)==="host";let pe,ge;e[46]===Symbol.for("react.memo_cache_sentinel")?(pe=a.jsx(mn,{htmlFor:"device-host",children:"Host"}),ge=a.jsx(aa,{children:"Enter a local address or an HTTPS URL."}),e[46]=pe,e[47]=ge):(pe=e[46],ge=e[47]);let be;e[48]===Symbol.for("react.memo_cache_sentinel")?(be=st=>{z.current=z.current+1,x(st.target.value),w(""),E(null),R(null)},e[48]=be):be=e[48];let ve;e[49]!==F?(ve=()=>void F(),e[49]=F,e[50]=ve):ve=e[50];let Se;e[51]!==g||e[52]!==ve?(Se=a.jsx(On,{id:"device-host",ref:P,value:g,onChange:be,onBlur:ve,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[51]=g,e[52]=ve,e[53]=Se):Se=e[53];let we;e[54]!==N?(we=N&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(St,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[54]=N,e[55]=we):we=e[55];let Ee;e[56]!==C||e[57]!==N?(Ee=!N&&C&&a.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",_I[C.tone]),children:[a.jsx(Yme,{tone:C.tone}),C.text]}),e[56]=C,e[57]=N,e[58]=Ee):Ee=e[58];let $e;e[59]!==A?($e=(A==null?void 0:A.field)==="host"&&a.jsx(Eo,{children:A.message}),e[59]=A,e[60]=$e):$e=e[60];let Be;e[61]!==le||e[62]!==Se||e[63]!==we||e[64]!==Ee||e[65]!==$e?(Be=a.jsxs(fn,{"data-invalid":le,children:[pe,ge,Se,we,Ee,$e]}),e[61]=le,e[62]=Se,e[63]=we,e[64]=Ee,e[65]=$e,e[66]=Be):Be=e[66];let qe;e[67]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsxs(mn,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[67]=qe):qe=e[67];let ze;e[68]===Symbol.for("react.memo_cache_sentinel")?(ze=st=>h(st.target.value),e[68]=ze):ze=e[68];let Ie;e[69]!==p?(Ie=a.jsxs(fn,{children:[qe,a.jsx(On,{id:"device-name",value:p,onChange:ze,placeholder:"Defaults to the device's own name"})]}),e[69]=p,e[70]=Ie):Ie=e[70];let Me;e[71]!==A||e[72]!==D||e[73]!==b?(Me=D&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="username",children:[a.jsx(mn,{htmlFor:"device-username",children:"Username"}),a.jsx(On,{id:"device-username",value:b,onChange:st=>w(st.target.value),placeholder:"Account username",autoComplete:"username",spellCheck:!1}),a.jsx(aa,{children:"Requests through this hub act as this account on that server."}),(A==null?void 0:A.field)==="username"&&a.jsx(Eo,{children:A.message})]}),e[71]=A,e[72]=D,e[73]=b,e[74]=Me):Me=e[74];let Ue;e[75]!==q||e[76]!==v||e[77]!==A||e[78]!==D?(Ue=q&&a.jsxs(fn,{"data-invalid":(A==null?void 0:A.field)==="password",children:[a.jsx(mn,{htmlFor:"device-password",children:"Password"}),a.jsx(On,{id:"device-password",type:"password",value:v,onChange:st=>j(st.target.value),placeholder:D?"Password for that account":"Network access password for that device",autoComplete:D?"current-password":"off"}),(A==null?void 0:A.field)==="password"&&a.jsx(Eo,{children:A.message})]}),e[75]=q,e[76]=v,e[77]=A,e[78]=D,e[79]=Ue):Ue=e[79];let De;e[80]!==Be||e[81]!==Ie||e[82]!==Me||e[83]!==Ue?(De=a.jsxs(Aa,{children:[Be,Ie,Me,Ue]}),e[80]=Be,e[81]=Ie,e[82]=Me,e[83]=Ue,e[84]=De):De=e[84];let Ke;e[85]===Symbol.for("react.memo_cache_sentinel")?(Ke=st=>{z.current=z.current+1,_(st===!0),E(null),R(null)},e[85]=Ke):Ke=e[85];let Ne;e[86]!==k?(Ne=a.jsx(fT,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:Ke}),e[86]=k,e[87]=Ne):Ne=e[87];const Ae=D?"":" — no password";let Qe;e[88]!==Ae?(Qe=a.jsxs(mn,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",Ae]}),e[88]=Ae,e[89]=Qe):Qe=e[89];let Je;e[90]!==Ne||e[91]!==Qe?(Je=a.jsxs(fn,{orientation:"horizontal",children:[Ne,Qe]}),e[90]=Ne,e[91]=Qe,e[92]=Je):Je=e[92];let ke;e[93]!==k||e[94]!==D?(ke=k&&a.jsxs(kt,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(lx,{}),a.jsx(_t,{className:"text-warning",children:D?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; account sign-in still applies."}):a.jsxs(a.Fragment,{children:["Traffic to this device is forwarded ",a.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[93]=k,e[94]=D,e[95]=ke):ke=e[95];let We;e[96]!==r?(We=a.jsx(Q,{variant:"outline",onClick:r,children:"Close"}),e[96]=r,e[97]=We):We=e[97];const ye=!H;let Re;e[98]!==Z?(Re=()=>void Z(),e[98]=Z,e[99]=Re):Re=e[99];let Ve;e[100]!==T?(Ve=T?a.jsxs(a.Fragment,{children:[a.jsx(St,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[100]=T,e[101]=Ve):Ve=e[101];let He;e[102]!==ye||e[103]!==Re||e[104]!==Ve?(He=a.jsx(Q,{disabled:ye,onClick:Re,children:Ve}),e[102]=ye,e[103]=Re,e[104]=Ve,e[105]=He):He=e[105];let me;e[106]!==We||e[107]!==He?(me=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[We,He]}),e[106]=We,e[107]=He,e[108]=me):me=e[108];let je;e[109]!==De||e[110]!==Je||e[111]!==ke||e[112]!==me?(je=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ue,De,Je,ke,me]}),e[109]=De,e[110]=Je,e[111]=ke,e[112]=me,e[113]=je):je=e[113];let Xe;e[114]!==fe||e[115]!==je?(Xe=a.jsxs(rr,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[oe,fe,je]}),e[114]=fe,e[115]=je,e[116]=Xe):Xe=e[116];let tt;return e[117]!==t||e[118]!==ce||e[119]!==Xe?(tt=a.jsx(sr,{open:t,onOpenChange:ce,children:Xe}),e[117]=t,e[118]=ce,e[119]=Xe,e[120]=tt):tt=e[120],tt}function epe(n){return n.id}const tpe="Browsing folders needs a newer Cogpit on this machine.";async function TI(n){const e=await Tl(n,`Request failed (${n.status})`);return new Error(n.status===404&&e==="Not found"?tpe:e)}async function npe(n,e){const t=await Ce(n?`/api/folders?path=${encodeURIComponent(n)}`:"/api/folders",{signal:e});if(!t.ok)throw await TI(t);return await t.json()}async function spe(n,e){const t=await is("/api/folders",{parent:n,name:e});if(!t.ok)throw await TI(t);return(await t.json()).path}function rpe(n,e=null){const t=ope(n);if(e===null)return t;const s=o=>o.replace(/[\\/]+$/,""),r=t.findIndex(o=>s(o.path)===s(e));return r===-1?t:t.slice(r)}function ope(n){const e=n.split(/[\\/]+/).filter(Boolean);let t,s,r;if(n.startsWith("\\\\")){const[o="",i="",...l]=e;t={label:`\\\\${o}\\${i}`,path:`\\\\${o}\\${i}\\`},s=l,r="\\"}else if(/^[a-z]:/i.test(n)){const[o="",...i]=e;t={label:o,path:`${o}\\`},s=i,r="\\"}else t={label:"/",path:"/"},s=e,r="/";return[t,...s.map((o,i)=>({label:o,path:t.path+s.slice(0,i+1).join(r)}))]}const F1="cogpit-browse-folders";function AI(){window.dispatchEvent(new Event(F1))}function ipe(n){return window.addEventListener(F1,n),()=>window.removeEventListener(F1,n)}const ape=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-D4MzdPVH.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal})));function II(n){const e=V.c(8),{onNewSession:t,onNewFolder:s,defaultAgentKind:r}=n,[o,i]=y.useState(null);let l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>ipe(()=>i(!0)),c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),y.useEffect(l,c),o===null)return null;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(!1),e[2]=u):u=e[2];let d;return e[3]!==r||e[4]!==s||e[5]!==t||e[6]!==o?(d=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ape,{open:o,onClose:u,onNewSession:t,onNewFolder:s,defaultAgentKind:r,currentProjectDirName:null,currentProjectCwd:null,initialView:"folders"})}),e[3]=r,e[4]=s,e[5]=t,e[6]=o,e[7]=d):d=e[7],d}const lpe=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function lj(n,e){if(!lpe.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function bo(n,e){return`${n}.${e}`}function cpe(n){const e=new Set,t=new Set,s=[];for(const r of n){if(lj("plugin",r.id),e.has(r.id))throw new Error(`Duplicate Cogpit plugin id "${r.id}"`);e.add(r.id);for(const o of r.workspacePanels??[]){lj("panel",o.id);const i=bo(r.id,o.id);if(t.has(i))throw new Error(`Duplicate Cogpit workspace panel id "${i}"`);t.add(i),s.push({...o,id:i,pluginId:r.id,localId:o.id})}}return s.sort((r,o)=>(r.order??100)-(o.order??100)||r.title.localeCompare(o.title))}function Gn({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}const ii="cogpit",Lt={worktrees:bo(ii,"worktrees"),projectFiles:bo(ii,"project-files"),browser:bo(ii,"browser"),fileChanges:bo(ii,"file-changes"),sessionInfo:bo(ii,"session-info"),crew:bo(ii,"crew")},upe=y.lazy(()=>nt(()=>import("./CommandPaletteHost-Djn2jqYR.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),dpe=y.lazy(()=>nt(()=>import("./index-DjpYbGVZ.js"),__vite__mapDeps([27,1,28,2,29,3,4])).then(n=>({default:n.ConfigDialog}))),fpe=y.lazy(()=>nt(()=>import("./KeyboardShortcutsDialog-L7rRhApI.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),mpe=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-D4MzdPVH.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),ppe=y.lazy(()=>nt(()=>import("./ThemeSelectorModal-7CWXZB-z.js"),__vite__mapDeps([31,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function hpe(n){const e=V.c(131),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=Sn(),{session:c,sessionSource:u}=jt(),{devices:d,activeDeviceId:f}=Si(),[m,p]=y.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=xt("manageDevices"),e[0]=h):h=e[0];const g=h,x=Hx(),b=o.mainView==="extension"?o.extensionViewId:null;let w;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(w=o.pendingCwd??(o.pendingDirName?xs(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=w):w=e[3];const v=w,j=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,k=r.onKeyboardShortcutsOpenChange;let _,N;e[4]!==k?(_=()=>{const me=function(Xe){on("keyboardShortcuts",Xe)&&(kI(document.activeElement)||(Xe.preventDefault(),k(!0)))};return window.addEventListener("keydown",me),()=>window.removeEventListener("keydown",me)},N=[k],e[4]=k,e[5]=_,e[6]=N):(_=e[5],N=e[6]),y.useEffect(_,N);const S=f===Ot;let C;e[7]!==S?(C={id:Ot,name:"This machine",isLocal:!0,isActive:S},e[7]=S,e[8]=C):C=e[8];let E;if(e[9]!==f||e[10]!==d||e[11]!==C){let me;e[13]!==f?(me=je=>({id:je.id,name:je.name,isLocal:!1,isActive:je.id===f}),e[13]=f,e[14]=me):me=e[14],E=[C,...d.map(me)],e[9]=f,e[10]=d,e[11]=C,e[12]=E}else E=e[12];const T=E,{openMainView:$,closeMainView:A}=t.panels;let R;if(e[15]!==A||e[16]!==x||e[17]!==$||e[18]!==b){let me;e[20]!==A||e[21]!==$||e[22]!==b?(me=je=>{const Xe=je.id===b;return{id:`main-view-${je.id}`,label:`${Xe?"Close":"Open"} ${je.label}`,keywords:je.keywords,icon:je.icon,onSelect:Xe?A:()=>$(je.id)}},e[20]=A,e[21]=$,e[22]=b,e[23]=me):me=e[23],R=x.map(me),e[15]=A,e[16]=x,e[17]=$,e[18]=b,e[19]=R}else R=e[19];const P=R;let z;e[24]!==c||e[25]!==(u==null?void 0:u.agentKind)||e[26]!==(u==null?void 0:u.dirName)?(z=()=>{if(!c)return;const me=(u==null?void 0:u.agentKind)??un((u==null?void 0:u.dirName)??null);Pf(Cx(me,c.sessionId,c.cwd))},e[24]=c,e[25]=u==null?void 0:u.agentKind,e[26]=u==null?void 0:u.dirName,e[27]=z):z=e[27];const L=z,I=gpe,M=r.processPanel,F=r.workflowsPanel,U=r.undoDialog,O=r.branchModal,D=i.claudeDir??"";let B;e[28]!==i.handleCloseConfigDialog||e[29]!==i.handleConfigSaved||e[30]!==i.showConfigDialog||e[31]!==D?(B=a.jsx(y.Suspense,{fallback:null,children:a.jsx(dpe,{open:i.showConfigDialog,currentPath:D,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[28]=i.handleCloseConfigDialog,e[29]=i.handleConfigSaved,e[30]=i.showConfigDialog,e[31]=D,e[32]=B):B=e[32];const q=(u==null?void 0:u.dirName)??o.pendingDirName??null,W=(c==null?void 0:c.cwd)??o.pendingCwd??null;let H;e[33]!==i.defaultAgentKind||e[34]!==t.onStartNewFolder||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleCloseProjectSwitcher||e[37]!==t.panels.showProjectSwitcher||e[38]!==q||e[39]!==W?(H=a.jsx(y.Suspense,{fallback:null,children:a.jsx(mpe,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:q,currentProjectCwd:W})}),e[33]=i.defaultAgentKind,e[34]=t.onStartNewFolder,e[35]=t.onStartNewSession,e[36]=t.panels.handleCloseProjectSwitcher,e[37]=t.panels.showProjectSwitcher,e[38]=q,e[39]=W,e[40]=H):H=e[40];let K;e[41]!==i.defaultAgentKind||e[42]!==t.onStartNewFolder||e[43]!==t.onStartNewSession?(K=a.jsx(II,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind}),e[41]=i.defaultAgentKind,e[42]=t.onStartNewFolder,e[43]=t.onStartNewSession,e[44]=K):K=e[44];let Z;e[45]!==t.panels.handleCloseThemeSelector||e[46]!==t.panels.showThemeSelector||e[47]!==l.setPreview||e[48]!==l.setTheme||e[49]!==l.theme?(Z=a.jsx(y.Suspense,{fallback:null,children:a.jsx(ppe,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[45]=t.panels.handleCloseThemeSelector,e[46]=t.panels.showThemeSelector,e[47]=l.setPreview,e[48]=l.setTheme,e[49]=l.theme,e[50]=Z):Z=e[50];const Y=r.commandPaletteOpen,J=r.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,te=t.panels.handleOpenProjectSwitcher,se=t.onOpenPaletteProject,X=t.actions.handleDashboardSelect,ne=t.panels.handleToggleSidebar;let ae,ie,re;e[51]!==t.panels?(ae=()=>t.panels.toggleWorkspacePanel(Lt.sessionInfo),ie=()=>t.panels.toggleWorkspacePanel(Lt.fileChanges),re=()=>t.panels.toggleWorkspacePanel(Lt.worktrees),e[51]=t.panels,e[52]=ae,e[53]=ie,e[54]=re):(ae=e[52],ie=e[53],re=e[54]);const de=t.panels.handleToggleMission,ce=c?t.handlers.handleDuplicateSession:void 0,oe=c?L:void 0,fe=c?I:void 0,ue=xt("killAny")?r.onKillAll:void 0,le=xt("configWrite")?t.panels.handleToggleConfig:void 0,pe=i.openConfigDialog;let ge;e[55]!==k?(ge=()=>k(!0),e[55]=k,e[56]=ge):ge=e[56];const be=s.currentCwd?s.onTogglePreview:void 0,ve=xt("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let Se;e[57]!==t.panels?(Se=xt("browser")?()=>t.panels.toggleWorkspacePanel(Lt.browser):void 0,e[57]=t.panels,e[58]=Se):Se=e[58];const we=t.panels.handleToggleThemeSelector,Ee=s.onOpenTerminal,$e=r.onFocusComposer,Be=r.onExpandAll,qe=r.onExpandToolPayloads,ze=r.onCollapseAll,Ie=!!(c||o.pendingDirName);let Me;e[59]!==v||e[60]!==(c==null?void 0:c.cwd)||e[61]!==(u==null?void 0:u.dirName)||e[62]!==o.dashboardProject||e[63]!==o.pendingDirName?(Me=xt("terminal")&&!!((c==null?void 0:c.cwd)??v??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[59]=v,e[60]=c==null?void 0:c.cwd,e[61]=u==null?void 0:u.dirName,e[62]=o.dashboardProject,e[63]=o.pendingDirName,e[64]=Me):Me=e[64];const Ue=!!c;let De;e[65]!==s.hasFileChanges?(De=xt("hostFiles")&&s.hasFileChanges,e[65]=s.hasFileChanges,e[66]=De):De=e[66];const Ke=t.panels.activeWorkspacePanel===Lt.sessionInfo,Ne=t.panels.activeWorkspacePanel===Lt.browser,Ae=t.panels.activeWorkspacePanel===Lt.fileChanges,Qe=t.panels.activeWorkspacePanel===Lt.worktrees,Je=o.mainView==="config",ke=o.mainView==="mission",We=(c==null?void 0:c.cwd)??v??null;let ye;e[67]!==r.commandPaletteOpen||e[68]!==r.onCollapseAll||e[69]!==r.onCommandPaletteOpenChange||e[70]!==r.onExpandAll||e[71]!==r.onExpandToolPayloads||e[72]!==r.onFocusComposer||e[73]!==i.openConfigDialog||e[74]!==j||e[75]!==P||e[76]!==t.actions.handleDashboardSelect||e[77]!==t.actions.handleGoHome||e[78]!==t.onOpenPaletteProject||e[79]!==t.panels.handleOpenProjectSwitcher||e[80]!==t.panels.handleToggleMission||e[81]!==t.panels.handleToggleSidebar||e[82]!==t.panels.handleToggleThemeSelector||e[83]!==t.panels.showSidebar||e[84]!==T||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==ae||e[91]!==ie||e[92]!==re||e[93]!==ce||e[94]!==oe||e[95]!==fe||e[96]!==ue||e[97]!==le||e[98]!==ge||e[99]!==be||e[100]!==ve||e[101]!==Se||e[102]!==Ie||e[103]!==Me||e[104]!==Ue||e[105]!==De||e[106]!==Ke||e[107]!==Ne||e[108]!==Ae||e[109]!==Qe||e[110]!==Je||e[111]!==ke||e[112]!==We?(ye=a.jsx(y.Suspense,{fallback:null,children:a.jsx(upe,{open:Y,onOpenChange:J,onGoHome:ee,onNewSession:te,onOpenProject:se,onOpenSession:X,onToggleSidebar:ne,onToggleStats:ae,onToggleFileChanges:ie,onToggleWorktrees:re,onToggleMissionControl:de,extraActions:P,onDuplicateSession:ce,onCopyResumeCommand:oe,onFindInConversation:fe,onKillAll:ue,onOpenConfig:le,onOpenSettings:pe,onOpenKeyboardShortcuts:ge,onTogglePreview:be,onToggleProjectFiles:ve,onToggleBrowser:Se,onOpenTheme:we,onOpenTerminal:Ee,onOpenDevices:g?p:void 0,onSwitchDevice:Xs,devices:T,onFocusComposer:$e,onExpandAll:Be,onExpandToolPayloads:qe,onCollapseAll:ze,canFocusComposer:Ie,canOpenTerminal:Me,hasSession:Ue,hasFileChanges:De,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:Ke,showProjectFiles:s.showProjectFiles,showBrowser:Ne,showFileChanges:Ae,showWorktrees:Qe,showConfig:Je,showMission:ke,currentProjectDirName:j,projectCwd:We,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[67]=r.commandPaletteOpen,e[68]=r.onCollapseAll,e[69]=r.onCommandPaletteOpenChange,e[70]=r.onExpandAll,e[71]=r.onExpandToolPayloads,e[72]=r.onFocusComposer,e[73]=i.openConfigDialog,e[74]=j,e[75]=P,e[76]=t.actions.handleDashboardSelect,e[77]=t.actions.handleGoHome,e[78]=t.onOpenPaletteProject,e[79]=t.panels.handleOpenProjectSwitcher,e[80]=t.panels.handleToggleMission,e[81]=t.panels.handleToggleSidebar,e[82]=t.panels.handleToggleThemeSelector,e[83]=t.panels.showSidebar,e[84]=T,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=ae,e[91]=ie,e[92]=re,e[93]=ce,e[94]=oe,e[95]=fe,e[96]=ue,e[97]=le,e[98]=ge,e[99]=be,e[100]=ve,e[101]=Se,e[102]=Ie,e[103]=Me,e[104]=Ue,e[105]=De,e[106]=Ke,e[107]=Ne,e[108]=Ae,e[109]=Qe,e[110]=Je,e[111]=ke,e[112]=We,e[113]=ye):ye=e[113];let Re;e[114]!==r.keyboardShortcutsOpen||e[115]!==k?(Re=a.jsx(y.Suspense,{fallback:null,children:a.jsx(fpe,{open:r.keyboardShortcutsOpen,onOpenChange:k})}),e[114]=r.keyboardShortcutsOpen,e[115]=k,e[116]=Re):Re=e[116];let Ve;e[117]!==m?(Ve=g&&a.jsx(EI,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[117]=m,e[118]=Ve):Ve=e[118];let He;return e[119]!==r.branchModal||e[120]!==r.processPanel||e[121]!==r.undoDialog||e[122]!==r.workflowsPanel||e[123]!==B||e[124]!==H||e[125]!==K||e[126]!==Z||e[127]!==ye||e[128]!==Re||e[129]!==Ve?(He=a.jsxs(a.Fragment,{children:[M,F,U,O,B,H,K,Z,ye,Re,Ve]}),e[119]=r.branchModal,e[120]=r.processPanel,e[121]=r.undoDialog,e[122]=r.workflowsPanel,e[123]=B,e[124]=H,e[125]=K,e[126]=Z,e[127]=ye,e[128]=Re,e[129]=Ve,e[130]=He):He=e[130],He}function gpe(){window.dispatchEvent(new Event(M1))}const PI={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function cj(n){return n===null?null:PI[n]??n}function $I(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===PI[n])??null:null}async function RI(n,e,t){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function xpe(n,e){return(await is(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function bpe(n,e,t){return YE("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function vpe(n,e,t){return YE("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const ype=3e3,Yb=y.createContext(null);async function eg(n){try{const e=await Ce(n);return e.ok?await e.text():void 0}catch{return}}function tg(n,e){if(!(n===void 0||n===e.current))try{const t=JSON.parse(n);return e.current=n,t}catch{return}}function el(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 Vu(n,e,t){const s=new Map(n),r=(s.get(e)??[]).filter(o=>!t(o));return r.length>0?s.set(e,r):s.delete(e),s}function wpe({children:n}){const[e,t]=y.useState(new Map),[s,r]=y.useState(new Map),[o,i]=y.useState(new Map),[l,c]=y.useState(new Map),[u,d]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=Mf(),b=$N()!==null,w=y.useRef(x.key);y.useLayoutEffect(()=>{w.current=x.key},[x.key]);const v=y.useCallback(async()=>{const[P,z,L]=await Promise.all([eg(El("/api/permissions",x)),eg(El("/api/user-questions",x)),eg(El("/api/agent-prompts",x))]);if(w.current!==x.key)return;const I=tg(P,p),M=tg(z,h),F=tg(L,g);I&&(t(el(I.bySession)),d(new Set(el(I.plansBySession).keys()))),M&&r(el(M.bySession)),F&&(i(el(F.elicitationsBySession)),c(el(F.dialogsBySession)))},[x]);y.useEffect(()=>{if(b)return;const P=()=>{document.visibilityState==="visible"&&v()};P();const z=setInterval(P,ype);return document.addEventListener("visibilitychange",P),()=>{clearInterval(z),document.removeEventListener("visibilitychange",P)}},[v,b]);const j=y.useCallback(async(P,z)=>{m(L=>new Set(L).add(P));try{return await z()}finally{m(L=>{const I=new Set(L);return I.delete(P),I}),v()}},[v]),k=y.useCallback((P,z,L)=>j(z,async()=>{await RI(P,z,L).catch(()=>!1)&&(t(M=>Vu(M,P,F=>F.requestId===z)),p.current="")}),[j]),_=y.useCallback((P,z,L)=>j(z,async()=>{const I=await eb(P,z,L);return I.ok&&(r(M=>Vu(M,P,F=>F.toolUseId===z)),h.current=""),I}),[j]),N=y.useCallback((P,z,L)=>j(z,async()=>{const I=await bpe(P,z,L);return I.ok&&(i(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),S=y.useCallback((P,z,L)=>j(z,async()=>{const I=await vpe(P,z,L);return I.ok&&(c(M=>Vu(M,P,F=>F.requestId===z)),g.current=""),I}),[j]),C=y.useMemo(()=>new Set(e.keys()),[e]),E=y.useMemo(()=>new Set(s.keys()),[s]),T=y.useMemo(()=>new Set(o.keys()),[o]),$=y.useMemo(()=>new Set(l.keys()),[l]),A=y.useCallback(()=>{v()},[v]),R=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:E,awaitingElicitation:T,awaitingDialog:$,awaitingPlan:u,responding:f,respond:k,answerQuestion:_,answerElicitation:N,answerDialog:S,refresh:A}),[e,s,o,l,C,E,T,$,u,f,k,_,N,S,A]);return a.jsx(Yb.Provider,{value:R,children:n})}function Spe(){const n=y.useContext(Yb);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}function kpe(){return y.useContext(Yb)}function OI(n){var d;const e=V.c(29),t=ar(),s=kpe(),r=i5(n),o=t==null?void 0:t.sessions,i=t==null?void 0:t.procBySession;let l;e[0]!==s?(l=s?{awaitingPermission:s.awaitingPermission,awaitingQuestion:s.awaitingQuestion,awaitingPrompt:new Set([...s.awaitingElicitation,...s.awaitingDialog]),awaitingPlan:s.awaitingPlan}:P9,e[0]=s,e[1]=l):l=e[1];const c=l;let u;if(e[2]!==c||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==r){e:{if(!n||!o||!i){u=null;break e}let f;if(e[8]!==n||e[9]!==o){let v;e[11]!==n?(v=j=>j.sessionId===n,e[11]=n,e[12]=v):v=e[12],f=o.find(v),e[8]=n,e[9]=o,e[10]=f}else f=e[10];const m=f,p=((d=m==null?void 0:m.crew)==null?void 0:d.rootId)??n;let h;e[13]!==p?(h=v=>{var j;return((j=v.crew)==null?void 0:j.rootId)===p},e[13]=p,e[14]=h):h=e[14];const g=o.filter(h);if(g.length===0){if(r.length===0){u=null;break e}const v=r.length;let j;e[15]!==r?(j=r.filter(jpe),e[15]=r,e[16]=j):j=e[16];let k;e[17]!==p||e[18]!==j.length||e[19]!==r.length?(k={rootId:p,size:v,needsYou:0,working:j.length},e[17]=p,e[18]=j.length,e[19]=r.length,e[20]=k):k=e[20],u=k;break e}let x;e[21]!==c||e[22]!==i?(x=v=>TN(v,i,c),e[21]=c,e[22]=i,e[23]=x):x=e[23];const b=Ux(g,x);let w;e[24]!==b.needsYou||e[25]!==b.size||e[26]!==b.working||e[27]!==p?(w={rootId:p,size:b.size,needsYou:b.needsYou,working:b.working},e[24]=b.needsYou,e[25]=b.size,e[26]=b.working,e[27]=p,e[28]=w):w=e[28],u=w}e[2]=c,e[3]=i,e[4]=n,e[5]=o,e[6]=r,e[7]=u}else u=e[7];return u}function jpe(n){return n.state==="running"}function vd(n){const e=V.c(10),{reason:t,children:s}=n;if(!t)return s;let r;e[0]!==t?(r=a.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s||e[3]!==r?(o=a.jsx(Zt,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Yt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Gt,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function Npe(n){var k;const e=V.c(22),{sessionId:t}=n,s=ar(),{names:r}=Ff();s==null||s.sessions;let o;e[0]!==(s==null?void 0:s.sessions)?(o=new Map(((s==null?void 0:s.sessions)??[]).map(Cpe)),e[0]=s==null?void 0:s.sessions,e[1]=o):o=e[1];const i=o;let l,c,u,d;if(e[2]!==i||e[3]!==r||e[4]!==t){d=Symbol.for("react.early_return_sentinel");e:{if(l=(k=i.get(t))==null?void 0:k.crew,!l){d=null;break e}c=i.get(l.parentId),u=$d(l.parentId,i,r)??l.parentTitle??"the session that started it"}e[2]=i,e[3]=r,e[4]=t,e[5]=l,e[6]=c,e[7]=u,e[8]=d}else l=e[5],c=e[6],u=e[7],d=e[8];if(d!==Symbol.for("react.early_return_sentinel"))return d;const f=u;let m;e[9]!==l||e[10]!==c?(m=()=>{c?za(ha(c.dirName,c.fileName)):cm(l.parentId)},e[9]=l,e[10]=c,e[11]=m):m=e[11];const p=m,h=`Reports to ${f}`,g=`Open ${f}, which started this session`;let x,b,w;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=G(fs,"h-8 min-w-12 max-w-56 shrink-[4] gap-1.5 px-2.5 text-xs text-muted-foreground hover:text-foreground"),b=a.jsx(mx,{className:"size-3 shrink-0","aria-hidden":"true"}),w=a.jsx("span",{className:"shrink-0 max-[1200px]:hidden",children:"Reports to"}),e[12]=x,e[13]=b,e[14]=w):(x=e[12],b=e[13],w=e[14]);let v;e[15]!==f?(v=a.jsx("span",{className:"truncate font-medium text-foreground",children:f}),e[15]=f,e[16]=v):v=e[16];let j;return e[17]!==p||e[18]!==v||e[19]!==h||e[20]!==g?(j=a.jsxs(Q,{type:"button",variant:"ghost",size:"xs","data-crew-parent":!0,onClick:p,"aria-label":h,title:g,className:x,children:[b,w,v]}),e[17]=p,e[18]=v,e[19]=h,e[20]=g,e[21]=j):j=e[21],j}function Cpe(n){return[n.sessionId,n]}const uj=o_.version,_pe={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},dj={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function Epe(n){const e=V.c(6),{state:t}=n,s=dj[t],r=dj[t],o=_pe[t];let i;e[0]!==o?(i=G("size-2 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==r||e[4]!==i?(l=a.jsx("span",{"aria-label":s,title:r,className:i}),e[2]=s,e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function fj(n){const e=V.c(2),{slot:t}=n;if(t>9)return null;let s;return e[0]!==t?(s=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}function Xb(n){const e=V.c(51),{compact:t}=n,s=t===void 0?!1:t,{devices:r,activeDeviceId:o,activeDevice:i,refresh:l,testDevice:c}=Si(),[u,d]=y.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Ot;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=xt("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==r||e[2]!==l||e[3]!==c?(g=O=>{!O||r.length===0||Promise.all(r.map(D=>c(D.id).catch(Ape))).then(()=>l())},e[1]=r,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&r.length===0&&!m)return null;const b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=G("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let j;e[7]!==b||e[8]!==v?(j=a.jsx(Q,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=j):j=e[9];let k;e[10]!==m?(k=m?a.jsx(cx,{"data-icon":"inline-start"}):a.jsx(yg,{"data-icon":"inline-start"}),e[10]=m,e[11]=k):k=e[11];let _;e[12]!==f?(_=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=_):_=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(Et,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=N):N=e[14];let S;e[15]!==j||e[16]!==k||e[17]!==_?(S=a.jsxs(Rc,{render:j,children:[k,_,N]}),e[15]=j,e[16]=k,e[17]=_,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(P5,{children:"Devices"}),e[19]=C):C=e[19];let E,T,$;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(yg,{}),T=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),$=a.jsx(fj,{slot:1}),e[20]=E,e[21]=T,e[22]=$):(E=e[20],T=e[21],$=e[22]);let A;e[23]!==m?(A=!m&&a.jsx(nn,{className:"ml-auto text-success"}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==A?(R=a.jsxs(hn,{onClick:Tpe,children:[E,T,$,A]}),e[25]=A,e[26]=R):R=e[26];let P;if(e[27]!==o||e[28]!==s||e[29]!==r){let O;e[31]!==o||e[32]!==s?(O=(D,B)=>{const q=CI(D),W=q!==void 0&&q!==uj,H=D.id===o;return a.jsxs(hn,{onClick:()=>Xs(D.id),className:G(s&&"min-h-10"),children:[a.jsx(Epe,{state:D.runtime.authState}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"truncate",children:D.name}),W&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${q}; hub runs v${uj}`,children:["v",q]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[D.host,":",D.port,D.auth==="none"&&" · unauthenticated"]})]}),a.jsx(fj,{slot:B+2}),H&&a.jsx(nn,{className:"ml-auto text-success"})]},D.id)},e[31]=o,e[32]=s,e[33]=O):O=e[33],P=r.map(O),e[27]=o,e[28]=s,e[29]=r,e[30]=P}else P=e[30];let z;e[34]!==R||e[35]!==P?(z=a.jsxs(qr,{children:[C,R,P]}),e[34]=R,e[35]=P,e[36]=z):z=e[36];let L;e[37]!==r.length?(L=h&&a.jsxs(a.Fragment,{children:[a.jsx(Il,{}),a.jsxs(qr,{children:[a.jsxs(hn,{onClick:()=>d("add"),children:[a.jsx(kr,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(hn,{onClick:()=>d("manage"),children:[a.jsx(ix,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[37]=r.length,e[38]=L):L=e[38];let I;e[39]!==z||e[40]!==L?(I=a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-64",children:[z,L]}),e[39]=z,e[40]=L,e[41]=I):I=e[41];let M;e[42]!==x||e[43]!==S||e[44]!==I?(M=a.jsxs($c,{onOpenChange:x,children:[S,I]}),e[42]=x,e[43]=S,e[44]=I,e[45]=M):M=e[45];let F;e[46]!==u?(F=h&&a.jsx(EI,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[46]=u,e[47]=F):F=e[47];let U;return e[48]!==M||e[49]!==F?(U=a.jsxs(a.Fragment,{children:[M,F]}),e[48]=M,e[49]=F,e[50]=U):U=e[50],U}function Tpe(){return Xs(Ot)}function Ape(){return null}const Ipe=6e4;function Ppe(){const[n,e]=y.useState([]),t=y.useCallback(async s=>{try{const r=await Ce("/api/system-processes");if(r.ok){const o=await r.json();if(s()){const i=(o.processes??[]).filter(l=>l.suspectedLeak);e(l=>JSON.stringify(l)===JSON.stringify(i)?l:i)}}}catch{}},[]);return Oa(t,Ipe),{leaks:n}}const $pe=6e4;function Rpe(n){const e=V.c(23),{onReview:t}=n,{leaks:s}=Ppe(),[r,o]=y.useState(!1),i=s.length>0,l=s.reduce(Lpe,0);let c,u;if(e[0]!==i?(c=()=>{if(i){o(!0);return}const C=window.setTimeout(()=>o(!1),$pe);return()=>window.clearTimeout(C)},u=[i],e[0]=i,e[1]=c,e[2]=u):(c=e[1],u=e[2]),y.useEffect(c,u),!i&&!r)return null;const d=Gt,f=i?"destructive":"ghost",m=i?`Review ${s.length} flagged ${s.length===1?"process":"processes"}`:"Leak monitor. No flagged processes",p=!i&&"text-muted-foreground";let h;e[3]!==p?(h=G("mr-1 font-mono",p),e[3]=p,e[4]=h):h=e[4];let g;e[5]!==t||e[6]!==f||e[7]!==m||e[8]!==h?(g=a.jsx(Q,{variant:f,size:"xs","aria-label":m,onClick:t,className:h}),e[5]=t,e[6]=f,e[7]=m,e[8]=h,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(k8,{"data-icon":"inline-start"}),e[10]=x):x=e[10];let b;e[11]!==s.length?(b=a.jsx("span",{className:"tabular-nums",children:s.length}),e[11]=s.length,e[12]=b):b=e[12];let w;e[13]!==g||e[14]!==b?(w=a.jsxs(Zt,{render:g,children:[x,b]}),e[13]=g,e[14]=b,e[15]=w):w=e[15];const v=Yt,j="bottom",k="p-3",_=i?a.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[a.jsxs("div",{className:"text-xs font-medium",children:["Flagged processes · ",l.toFixed(0),"% CPU"]}),s.slice(0,6).map(Ope),s.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",s.length-6," more"]}),a.jsx(tn,{}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Review ownership and stop individual processes"})]}):a.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"No flagged processes. Click to open the power monitor."})]});let N;e[16]!==v||e[17]!==_?(N=a.jsx(v,{side:j,className:k,children:_}),e[16]=v,e[17]=_,e[18]=N):N=e[18];let S;return e[19]!==d||e[20]!==w||e[21]!==N?(S=a.jsxs(d,{children:[w,N]}),e[19]=d,e[20]=w,e[21]=N,e[22]=S):S=e[22],S}function Ope(n){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[a.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",jN(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function Lpe(n,e){return n+e.cpuPercent}const Mpe=2e3;function ya(n){return`${n.toFixed(n<10?1:0)}%`}function gf(n){return`${n.toFixed(0)} MB`}function zpe(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function Dpe(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 Fpe(n){const e=V.c(50),{metric:t,onStop:s,stopping:r,onNavigate:o}=n;let i;e[0]!==t.label?(i=a.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];let l;e[2]!==t.pid?(l=a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=l):l=e[3];let c;e[4]!==t.suspectedLeak||e[5]!==t.warning?(c=t.suspectedLeak&&a.jsx(Fe,{variant:"destructive",children:t.warning==="sustained-cpu"?"sustained high CPU":"possible leak"}),e[4]=t.suspectedLeak,e[5]=t.warning,e[6]=c):c=e[6];let u;e[7]!==t.orphaned||e[8]!==t.suspectedLeak?(u=t.orphaned&&!t.suspectedLeak&&a.jsx(Fe,{variant:"secondary",children:"orphaned"}),e[7]=t.orphaned,e[8]=t.suspectedLeak,e[9]=u):u=e[9];let d;e[10]!==i||e[11]!==l||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i,l,c,u]}),e[10]=i,e[11]=l,e[12]=c,e[13]=u,e[14]=d):d=e[14];let f;e[15]!==t.command?(f=a.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[15]=t.command,e[16]=f):f=e[16];let m;e[17]!==t.kind||e[18]!==t.owner||e[19]!==o?(m=t.owner?a.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[t.owner.dirName&&t.owner.fileName?a.jsx("a",{className:"underline",href:ha(t.owner.dirName,t.owner.fileName),onClick:S=>{S.metaKey||S.ctrlKey||S.shiftKey||S.altKey||(S.preventDefault(),za(ha(t.owner.dirName,t.owner.fileName)),o())},children:t.owner.title||"Originating session"}):a.jsx("span",{children:"Originating session"}),a.jsxs("div",{className:"break-all",children:[t.owner.sessionId," · task ",t.owner.taskId]})]}):t.kind!=="cogpit"&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Session ownership unknown"}),e[17]=t.kind,e[18]=t.owner,e[19]=o,e[20]=m):m=e[20];let p;e[21]!==d||e[22]!==f||e[23]!==m?(p=a.jsxs("div",{className:"min-w-0 flex-1",children:[d,f,m]}),e[21]=d,e[22]=f,e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t||e[26]!==s||e[27]!==r?(h=t.canStop&&t.identity&&a.jsx(Q,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t),disabled:r,"aria-label":`Stop process ${t.pid}`,children:r?"Stopping…":"Stop"}),e[25]=t,e[26]=s,e[27]=r,e[28]=h):h=e[28];const g=t.cpuPercent>=20&&"text-destructive";let x;e[29]!==g?(x=G("font-mono text-sm font-semibold tabular-nums",g),e[29]=g,e[30]=x):x=e[30];let b;e[31]!==t.cpuPercent?(b=ya(t.cpuPercent),e[31]=t.cpuPercent,e[32]=b):b=e[32];let w;e[33]!==x||e[34]!==b?(w=a.jsx("div",{className:x,children:b}),e[33]=x,e[34]=b,e[35]=w):w=e[35];let v;e[36]!==t.memoryMb?(v=gf(t.memoryMb),e[36]=t.memoryMb,e[37]=v):v=e[37];let j;e[38]!==t.ageSeconds?(j=jN(t.ageSeconds),e[38]=t.ageSeconds,e[39]=j):j=e[39];let k;e[40]!==v||e[41]!==j?(k=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[v," · ",j]}),e[40]=v,e[41]=j,e[42]=k):k=e[42];let _;e[43]!==w||e[44]!==k?(_=a.jsxs("div",{className:"shrink-0 text-right",children:[w,k]}),e[43]=w,e[44]=k,e[45]=_):_=e[45];let N;return e[46]!==_||e[47]!==p||e[48]!==h?(N=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[p,h,_]}),e[46]=_,e[47]=p,e[48]=h,e[49]=N):N=e[49],N}function Upe(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 Bpe(n,e,t=0){return t>0?t===1?'1 process needs review. See "Agent and runtime processes" below.':`${t} processes need review. See "Agent and runtime 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 mj(n){const e=V.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=a.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let r;e[2]!==t.pid?(r=t.pid>0&&a.jsxs(Fe,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=r):r=e[3];let o;e[4]!==s||e[5]!==r?(o=a.jsxs("div",{className:"flex items-center gap-2",children:[s,r]}),e[4]=s,e[5]=r,e[6]=o):o=e[6];let i;e[7]!==t?(i=Upe(t),e[7]=t,e[8]=i):i=e[8];let l;e[9]!==i?(l=a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=l):l=e[10];let c;e[11]!==o||e[12]!==l?(c=a.jsxs("div",{className:"min-w-0 flex-1",children:[o,l]}),e[11]=o,e[12]=l,e[13]=c):c=e[13];const u=t.cpuPercent>=50&&"text-destructive";let d;e[14]!==u?(d=G("font-mono text-sm font-semibold tabular-nums",u),e[14]=u,e[15]=d):d=e[15];let f;e[16]!==t.cpuPercent?(f=ya(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==d||e[19]!==f?(m=a.jsx("div",{className:d,children:f}),e[18]=d,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=gf(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=a.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&&a.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=a.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function pj(n){const e=V.c(6),{metrics:t,emptyLabel:s}=n;let r,o;if(e[0]!==s||e[1]!==t){o=Symbol.for("react.early_return_sentinel");e:{const i=t.slice(0,8);if(i.length===0){let l;e[4]!==s?(l=a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],o=l;break e}r=i.map(Wpe)}e[0]=s,e[1]=t,e[2]=r,e[3]=o}else r=e[2],o=e[3];return o!==Symbol.for("react.early_return_sentinel")?o:r}function Wpe(n,e){const t=Dpe(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(tn,{}),a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm",children:n.name}),a.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:zpe(n.ratePerSecond)}),t&&a.jsx("span",{children:t}),n.averageDurationMs!==void 0&&a.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&a.jsxs(Fe,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function qpe(n){const e=V.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(Vpe).join(", "),e[0]=t,e[1]=r):r=e[1];const o=`Recent Cogpit CPU: ${r}`;let i;e[2]!==s||e[3]!==t?(i=t.length===0?a.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,u)=>a.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:ya(c)},u)),e[2]=s,e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==o||e[6]!==i?(l=a.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":o,children:i}),e[5]=o,e[6]=i,e[7]=l):l=e[7],l}function Vpe(n){return ya(n)}function Hpe({open:n,onOpenChange:e}){var $,A;const[t,s]=y.useState(null),[r,o]=y.useState(null),[i,l]=y.useState([]),[c,u]=y.useState(null),[d,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=y.useState(null),x=y.useRef(!1),[b,w]=so(),v=y.useCallback(async()=>{var F;if(x.current)return;x.current=!0,p(!0);const R=Ce("/api/performance").then(async U=>{if(!U.ok)throw new Error(`Server monitor returned ${U.status}`);return U.json()}),P=((F=window.electronPerformance)==null?void 0:F.getSnapshot())??Promise.resolve(null),[z,L]=await Promise.allSettled([R,P]),I=z.status==="fulfilled"?z.value:null,M=L.status==="fulfilled"?L.value:null;if(I&&o(I),M&&s(M),!I&&!M)u("Performance data is unavailable.");else{u(null);const U=M&&M.processes.length>0?M.processes.reduce((O,D)=>O+D.cpuPercent,0):(I==null?void 0:I.cpuPercent)??0;l(O=>[...O.slice(-29),U])}x.current=!1,p(!1)},[]);y.useEffect(()=>{if(!n)return;const R=()=>{document.visibilityState==="visible"&&v()};R();const P=window.setInterval(R,Mpe);return document.addEventListener("visibilitychange",R),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",R)}},[n,v]);const j=[...(t==null?void 0:t.processes)??[]].sort((R,P)=>P.cpuPercent-R.cpuPercent),k=j.length>0?j.reduce((R,P)=>R+P.cpuPercent,0):(r==null?void 0:r.cpuPercent)??0,_=j[0],N=(($=r==null?void 0:r.system)==null?void 0:$.processes)??[],S=((A=r==null?void 0:r.system)==null?void 0:A.suspectedLeakCount)??0,C=S>0||k>=80?"High":k>=15?"Active":"Idle",E=async R=>{if(!(!R.identity||h!==null)){f(null),g(R.pid);try{const P=await Ce("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processes:[{pid:R.pid,identity:R.identity}]})});if(!P.ok)throw new Error("Could not stop this process.");if(!(await P.json()).killed.includes(R.pid))throw new Error("The process changed or is no longer eligible. Refresh and review it again.");await v()}catch{f("Process was not stopped. Refresh and review its current identity and access.")}finally{g(null)}}},T=()=>{w(JSON.stringify({capturedAt:new Date().toISOString(),electron:t,server:r,cpuHistory:i},null,2))};return a.jsx(sr,{open:n,onOpenChange:e,children:a.jsxs(rr,{className:"h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl",children:[a.jsx(ao,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(or,{children:"Power & activity monitor"}),a.jsx(Fe,{variant:C==="High"?"destructive":"secondary",children:C})]}),a.jsx(ir,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."})]}),a.jsxs("div",{className:"flex shrink-0 gap-1",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:()=>void v(),disabled:m,children:[a.jsx(Fn,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh"]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:T,disabled:!r&&!t,children:[b?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"}),b?"Copied":"Copy data"]})]})]})}),a.jsx(tn,{}),a.jsx(Vc,{className:"min-h-0 min-w-0 flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-5",children:[(c||d)&&a.jsx(kt,{variant:"destructive",children:a.jsx(_t,{children:d||c})}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Current load"}),a.jsx(vr,{children:Bpe(k,_,S)}),a.jsx(Wte,{children:a.jsxs("span",{className:G("font-mono text-lg font-semibold tabular-nums",k>=80&&"text-destructive"),children:[ya(k)," CPU"]})})]}),a.jsx(Fs,{children:a.jsx(qpe,{values:i})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Processes"}),a.jsx(vr,{children:"Which part of Cogpit is consuming CPU and memory."})]}),a.jsx(Fs,{children:j.length>0?j.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(tn,{}),a.jsx(mj,{metric:R})]},R.pid)):r?a.jsx(mj,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:r.cpuPercent,memoryMb:r.memory.rssMb}}):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"})})]}),N.length>0&&a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Agent and runtime processes"}),a.jsx(vr,{children:"Agent sessions, browsers, and long-running scripts. Unknown runtimes are flagged after sustained high CPU; stopping them is manual."})]}),a.jsx(Fs,{children:N.map((R,P)=>a.jsxs("div",{children:[P>0&&a.jsx(tn,{}),a.jsx(Fpe,{metric:R,onStop:z=>void E(z),stopping:h!==null,onNavigate:()=>e(!1)})]},R.pid))})]}),a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"Server activity"}),a.jsxs(vr,{children:["File checks, streams, and agent work over the last ",(r==null?void 0:r.sampleWindowSeconds)??10," seconds."]})]}),a.jsx(Fs,{children:a.jsx(pj,{metrics:(r==null?void 0:r.activities)??[],emptyLabel:"No watched-file or stream activity in this sample."})})]}),a.jsxs(Ds,{size:"sm",children:[a.jsxs(xr,{children:[a.jsx(br,{children:"API activity"}),a.jsx(vr,{children:"Requests ranked by recent frequency and time."})]}),a.jsx(Fs,{children:a.jsx(pj,{metrics:(r==null?void 0:r.requests)??[],emptyLabel:"No API requests in this sample."})})]})]}),r&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",ya(r.eventLoopPercent)," · heap ",gf(r.memory.heapUsedMb)," · RSS ",gf(r.memory.rssMb)]})]})})]})})}function Kpe(n){return`${n.title??`Pull request #${n.number}`}
|
|
462
462
|
${n.repo}${n.isDraft?" · draft":""}`}function LI(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:Kpe(n)}}function su(n){const e=V.c(17),{pullRequests:t,max:s,compact:r,layout:o}=n,i=s===void 0?3:s,l=o===void 0?"chips":o;if(!(t!=null&&t.length))return null;if(l==="list"){let f;e[0]!==t?(f=t.map(Zpe),e[0]=t,e[1]=f):f=e[1];let m;return e[2]!==f?(m=a.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[2]=f,e[3]=m):m=e[3],m}let c,u;if(e[4]!==r||e[5]!==i||e[6]!==t){const f=t.slice(-i);if(e[9]!==i||e[10]!==t){const p=t.slice(0,-i);c=p.length>0&&a.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",title:p.map(Gpe).join(`
|
|
463
463
|
`),children:["+",p.length]}),e[9]=i,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==r?(m=p=>{const h=p.isDraft?U4:dx;return a.jsxs(Fe,{variant:p.isDraft?"outline":"secondary",render:a.jsx("a",{...LI(p)}),className:G("shrink-0",r&&"px-1"),children:[a.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=r,e[13]=m):m=e[13],u=f.map(m),e[4]=r,e[5]=i,e[6]=t,e[7]=c,e[8]=u}else c=e[7],u=e[8];let d;return e[14]!==c||e[15]!==u?(d=a.jsxs(a.Fragment,{children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function Gpe(n){return`#${n.number} ${n.title??n.repo}`}function Zpe(n){const e=n.isDraft?U4:dx;return a.jsxs("a",{...LI(n),className:"flex items-center gap-1 text-foreground hover:underline",children:[a.jsx(e,{className:"size-2.5 shrink-0"}),a.jsxs("span",{className:"shrink-0",children:["#",n.number]}),n.title&&a.jsx("span",{className:"truncate text-muted-foreground",children:n.title})]},n.url)}const Ype=y.memo(function(e){const t=V.c(34),{session:s,sessionSource:r,isLive:o,pullRequests:i,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==r){const E=r?$o(r.fileName):null;p=E?Bb(E.agentId):null,t[0]=r,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(Qpe),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let b;t[4]!==s.rawMessages||t[5]!==(r==null?void 0:r.dirName)?(b=ia(r==null?void 0:r.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=r==null?void 0:r.dirName,t[6]=b):b=t[6];const w=b;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:G(fs,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=t[7];let j;t[8]!==l||t[9]!==c||t[10]!==u||t[11]!==f||t[12]!==d||t[13]!==m||t[14]!==s||t[15]!==r?(j=r?a.jsx(Jpe,{session:s,sessionSource:r,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}):a.jsx("button",{type:"button",onClick:u,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]=u,t[11]=f,t[12]=d,t[13]=m,t[14]=s,t[15]=r,t[16]=j):j=t[16];let k;t[17]!==o?(k=o&&a.jsx(Sm,{"aria-label":"Session is live"}),t[17]=o,t[18]=k):k=t[18];let _;t[19]!==w?(_=a.jsx(dA,{rawMessages:w}),t[19]=w,t[20]=_):_=t[20];let N;t[21]!==j||t[22]!==k||t[23]!==_?(N=a.jsxs(Zt,{delay:200,render:v,children:[j,k,_]}),t[21]=j,t[22]=k,t[23]=_,t[24]=N):N=t[24];let S;t[25]!==i||t[26]!==w||t[27]!==s||t[28]!==h||t[29]!==x?(S=a.jsx(Yt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:a.jsx(Xpe,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:i,rawMessages:w})}),t[25]=i,t[26]=w,t[27]=s,t[28]=h,t[29]=x,t[30]=S):S=t[30];let C;return t[31]!==N||t[32]!==S?(C=a.jsxs(Gt,{children:[N,S]}),t[31]=N,t[32]=S,t[33]=C):C=t[33],C});function zi(n){const e=V.c(7),{label:t,children:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex gap-3",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function Xpe(n){const e=V.c(33),{session:t,thinkingEnabled:s,subAgentLabel:r,pullRequests:o,rawMessages:i}=n;let l,c,u,d,f,m,p;if(e[0]!==o||e[1]!==i||e[2]!==t.branchedFrom||e[3]!==t.gitBranch||e[4]!==t.model||e[5]!==r||e[6]!==s){const g=NN(i),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&&a.jsxs(zi,{label:"Model",children:[a.jsx("span",{children:lo(t.model)}),s&&a.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?(u=t.gitBranch&&a.jsx(zi,{label:"Branch",children:a.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=u):u=e[18],e[19]!==o?(d=o.length>0&&a.jsx(zi,{label:"Pull requests",children:a.jsx(su,{pullRequests:o})}),e[19]=o,e[20]=d):d=e[20],e[21]!==r?(f=r&&a.jsx(zi,{label:"Agent",children:r}),e[21]=r,e[22]=f):f=e[22],e[23]!==x?(m=x&&a.jsxs(zi,{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&&a.jsxs(zi,{label:"Context",children:[vt(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",vt(g.used)," / ",vt(g.limit)]}),e[0]=o,e[1]=i,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=r,e[6]=s,e[7]=l,e[8]=c,e[9]=u,e[10]=d,e[11]=f,e[12]=m,e[13]=p}else l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==u||e[28]!==d||e[29]!==f||e[30]!==m||e[31]!==p?(h=a.jsxs("div",{className:l,children:[c,u,d,f,m,p]}),e[25]=l,e[26]=c,e[27]=u,e[28]=d,e[29]=f,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function Jpe(n){const e=V.c(55),{session:t,sessionSource:s,copied:r,creatingSession:o,onCopyResume:i,onNewSession:l,onDuplicateSession:c,onOpenTerminal:u}=n,{dispatch:d}=Sn(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=qo(),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?`${Er(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;let w;e[7]!==t.cwd||e[8]!==s.dirName?(w={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=w):w=e[9];const v=w;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=xt("hostFiles"),e[10]=j):j=e[10];const k=j;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=k&&(!p||kb()),e[11]=_):_=e[11];const N=_,S=k&&!p;let C;e[12]!==d||e[13]!==s.dirName?(C=function(){y.startTransition(()=>{d({type:"GO_HOME",isMobile:!1}),d({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[12]=d,e[13]=s.dirName,e[14]=C):C=e[14];const E=C,T=`Copy resume command for ${b}; open session actions with the context menu`;let $;e[15]!==i||e[16]!==T?($=a.jsx("button",{type:"button",onClick:i,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":T,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[15]=i,e[16]=T,e[17]=$):$=e[17];let A;e[18]!==r||e[19]!==t.cwd||e[20]!==g?(A=r?a.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[a.jsx(nn,{className:"size-3"})," Copied"]}):a.jsxs(a.Fragment,{children:[t.cwd&&a.jsx("span",{className:"truncate text-muted-foreground",children:Er(t.cwd)}),t.cwd&&a.jsx("span",{className:"text-muted-foreground/50",children:"/"}),a.jsx("span",{className:"truncate",children:g})]}),e[18]=r,e[19]=t.cwd,e[20]=g,e[21]=A):A=e[21];let R;e[22]!==A||e[23]!==$?(R=a.jsx(Cm,{render:$,children:A}),e[22]=A,e[23]=$,e[24]=R):R=e[24];let P;e[25]!==l||e[26]!==t.cwd||e[27]!==s.dirName?(P=()=>l(s.dirName,t.cwd),e[25]=l,e[26]=t.cwd,e[27]=s.dirName,e[28]=P):P=e[28];let z;e[29]!==o?(z=o?a.jsx(Pn,{className:"size-3.5"}):a.jsx(kr,{className:"size-3.5"}),e[29]=o,e[30]=z):z=e[30];let L;e[31]!==o||e[32]!==P||e[33]!==z?(L=a.jsxs(Rn,{disabled:o,onClick:P,children:[z,"New session in this project"]}),e[31]=o,e[32]=P,e[33]=z,e[34]=L):L=e[34];let I;e[35]!==c?(I=c&&a.jsxs(Rn,{onClick:c,children:[a.jsx(Es,{className:"size-3.5"}),"Duplicate this session"]}),e[35]=c,e[36]=I):I=e[36];let M;e[37]!==f||e[38]!==v?(M=f&&(N||S)&&a.jsxs(a.Fragment,{children:[a.jsx(va,{}),N&&a.jsxs(Rn,{onClick:()=>d6(v),children:[a.jsx(xx,{className:"size-3.5"}),"Open project in editor"]}),S&&a.jsxs(Rn,{onClick:()=>f6(v),children:[a.jsx(wc,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[37]=f,e[38]=v,e[39]=M):M=e[39];let F;e[40]!==u?(F=u&&!p&&xt("terminal")&&a.jsxs(Rn,{onClick:u,children:[a.jsx(_a,{className:"size-3.5"}),"Open terminal in project"]}),e[40]=u,e[41]=F):F=e[41];let U;e[42]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(va,{}),e[42]=U):U=e[42];let O;e[43]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(Yr,{className:"size-3.5"}),e[43]=O):O=e[43];let D;e[44]!==E?(D=a.jsxs(Rn,{onClick:E,children:[O,"View all sessions in this project"]}),e[44]=E,e[45]=D):D=e[45];let B;e[46]!==L||e[47]!==I||e[48]!==M||e[49]!==F||e[50]!==D?(B=a.jsxs(_m,{className:"min-w-56",children:[L,I,M,F,U,D]}),e[46]=L,e[47]=I,e[48]=M,e[49]=F,e[50]=D,e[51]=B):B=e[51];let q;return e[52]!==R||e[53]!==B?(q=a.jsxs(Nm,{children:[R,B]}),e[52]=R,e[53]=B,e[54]=q):q=e[54],q}function Qpe(n){return n.thinking.length>0}const tl="Could not reach the server";async function Hu(n,e){try{return await Ce(n,e)}catch{return null}}function ehe(){const n=V.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),[r,o]=y.useState(null),i=y.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(i.current=!0,()=>{i.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),y.useEffect(l,c);let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=async()=>{const _=await Hu("/api/shares");if(!(_!=null&&_.ok))return;const N=await _.json().catch(rhe);i.current&&Array.isArray(N)&&s(N)},n[3]=u):u=n[3];const d=u;let f,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{d()},m=[d],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 _=>{o(null);const N=await Hu("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:_})});if(!(N!=null&&N.ok))return i.current&&o(await Tl(N,tl)),null;const S=await N.json().catch(she);if(!(S!=null&&S.passphrase)||!S.share)return i.current&&o(tl),null;const C=S.share;return i.current&&s(E=>[...E.filter(T=>T.sessionId!==C.sessionId),C]),S.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async _=>{o(null);const N=await Hu(`/api/shares/${encodeURIComponent(_)}/regenerate`,{method:"POST"});if(!(N!=null&&N.ok))return i.current&&o(await Tl(N,tl)),null;const S=await N.json().catch(nhe);return S!=null&&S.passphrase?(d(),S.passphrase):(i.current&&o(tl),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async _=>{o(null);const N=await Hu(`/api/shares/${encodeURIComponent(_)}`,{method:"DELETE"});if(!(N!=null&&N.ok)){i.current&&o(await Tl(N,tl));return}i.current&&s(S=>S.filter(C=>C.sessionId!==_))},n[8]=b):b=n[8];const w=b;let v;n[9]!==t?(v=async()=>{const _=t.map(the);for(const N of _)await w(N)},n[9]=t,n[10]=v):v=n[10];const j=v;let k;return n[11]!==r||n[12]!==j||n[13]!==t?(k={shares:t,error:r,refresh:d,create:h,regenerate:x,revoke:w,revokeAll:j},n[11]=r,n[12]=j,n[13]=t,n[14]=k):k=n[14],k}function the(n){return n.sessionId}function nhe(){return null}function she(){return null}function rhe(){return null}const ohe=5e3,ihe="••••";function ahe(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function lhe({sessionId:n}){const{config:{networkAccessDisabled:e}}=Sn(),{shares:t,error:s,refresh:r,create:o,regenerate:i,revoke:l}=ehe(),{activeDeviceId:c,activeDevice:u}=Si(),[d,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(!1),[x,b]=so(),[w,v]=so(),j=t.find(C=>C.sessionId===n)??null,k=c!==Ot,_=k&&!u?null:jee(n,u);y.useEffect(()=>p(null),[n]),y.useEffect(()=>{if(!d)return;r();const C=setInterval(()=>void r(),ohe);return()=>clearInterval(C)},[d,r]);async function N(C){g(!0);try{await C()}finally{g(!1)}}const S=k?u&&!u.tls&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Guests sign in over HTTPS only, and ",u.name," is connected over plain HTTP. Connect to it through an HTTPS address for this link to work."]}):e&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return a.jsxs($c,{open:d,onOpenChange:C=>{f(C),C||p(null)},children:[a.jsx(Rc,{render:a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":j?"Session is shared":"Share session",className:G(j&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:a.jsx(j8,{"data-icon":"inline-start"})}),a.jsx(Oc,{align:"end",sideOffset:6,className:"w-80 p-3",children:j?a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:_??"…"}),a.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",disabled:!_,onClick:()=>_&&b(_),children:x?a.jsx(nn,{"data-icon":"inline-start"}):a.jsx(Es,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:m??ihe}),a.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:h,onClick:()=>N(async()=>{p(await i(n))}),children:a.jsx(Fn,{"data-icon":"inline-start"})})]}),m?a.jsx(Q,{variant:"secondary",size:"xs",disabled:!_,onClick:()=>_&&v(`${_}
|
|
464
464
|
Passphrase: ${m}`),children:w?"Copied":"Copy link & passphrase"}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"The passphrase is only shown once. Regenerate to get a new one."}),S,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:ahe(j.guests)}),a.jsx(Q,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:h,onClick:()=>N(async()=>{await l(n),p(null)}),children:"Stop sharing"})]})]}):a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with the link and passphrase can read and join this session."}),S,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsx(Q,{size:"xs",disabled:h,onClick:()=>N(async()=>{p(await o(n))}),children:"Enable sharing"})]})})]})}function Jb(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 Zs(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Ao(n){return typeof n=="string"?n:void 0}function _o(n){return n?Jb(Zs(n.utilization),Ao(n.resets_at)):void 0}function MI(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:Zs(n.monthly_limit),usedCredits:Zs(n.used_credits),utilization:Zs(n.utilization)}}function che(n){return{fiveHour:_o(Rt(n.five_hour)),sevenDay:_o(Rt(n.seven_day)),sevenDayOpus:_o(Rt(n.seven_day_opus)),sevenDaySonnet:_o(Rt(n.seven_day_sonnet)),extraUsage:MI(Rt(n.extra_usage)),subscriptionType:Ao(n.subscriptionType)}}function uhe(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),r={fiveHour:_o(Rt(t==null?void 0:t.five_hour)),sevenDay:_o(Rt(t==null?void 0:t.seven_day)),sevenDayOpus:_o(Rt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:_o(Rt(t==null?void 0:t.seven_day_sonnet)),extraUsage:MI(Rt(t==null?void 0:t.extra_usage)),subscriptionType:Ao(e==null?void 0:e.subscription_type)??Ao(s==null?void 0:s.subscriptionType)};return r.fiveHour||r.sevenDay||r.extraUsage||r.subscriptionType?r:null}function dhe(n){const e=Zs(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function fhe(n,e){const t=Zs(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function hj(n,e){if(n)return Jb(Zs(n.usedPercent),dhe(n.resetsAt),fhe(n.windowDurationMins,e))}const mhe={free:"Free",go:"Go",plus:"Plus",pro:"Pro (More)",prolite:"Pro",promax:"Pro (Max)",team:"Team",business:"Business",ent26:"Enterprise",enterprise:"Enterprise",edu:"Edu",edu_plus:"Edu Plus",edu_pro:"Edu Pro"};function phe(n){var d,f,m;if(n.available!==!0)return null;const e=Rt((d=Rt(n.rateLimits))==null?void 0:d.rateLimits),t=Rt((f=Rt(n.account))==null?void 0:f.account),s=Rt((m=Rt(n.usage))==null?void 0:m.summary),r=Rt(e==null?void 0:e.credits),o=hj(Rt(e==null?void 0:e.primary),"Primary"),i=hj(Rt(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=Zs(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0),u=Ao(e==null?void 0:e.planType)??Ao(t==null?void 0:t.planType);return!o&&!i&&c===void 0?null:{fiveHour:o,sevenDay:i,subscriptionType:u?mhe[u]??u:void 0,lifetimeTokens:c,creditBalance:Ao(r==null?void 0:r.balance),creditsUnlimited:(r==null?void 0:r.unlimited)===!0}}function gj(n,e){if(!n)return;const t=Zs(n.remainingPercentage),s=Zs(n.usedRequests),r=Zs(n.entitlementRequests);let o;return t!==void 0?o=100-t:n.isUnlimitedEntitlement===!0||r===-1?o=0:s!==void 0&&r!==void 0&&r>0&&(o=s/r*100),Jb(o,Ao(n.resetDate),e)}function hhe(n){var s;if(n.available!==!0)return null;const e=Rt((s=Rt(n.quota))==null?void 0:s.quotaSnapshots),t=gj(Rt(e==null?void 0:e.chat),"Chat")??gj(Rt(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const ghe={acp:{endpoint:"/api/acp/runtime",read:()=>({})},claude:{endpoint:"/api/claude/runtime",read:uhe,legacy:{endpoint:"/api/usage",read:che}},codex:{endpoint:"/api/codex/runtime",read:phe},copilot:{endpoint:"/api/copilot/runtime",read:hhe}};function xhe(n){return ghe[n]}const bhe=300*1e3;function vhe(n=Wo){const e=Nn("viewUsage"),[t,s]=y.useState(null),[r,o]=y.useState(!1),[i,l]=y.useState(!1),c=y.useRef(0),u=y.useRef(null),d=y.useCallback(async()=>{var h;if(!e)return;const f=++c.current;(h=u.current)==null||h.abort();const m=new AbortController;u.current=m;const p=()=>c.current===f&&!m.signal.aborted;o(!0);try{const g=xhe(n);let x=await Ce(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await Ce(g.legacy.endpoint,{signal:m.signal}),b=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const w=await x.json();if(!p())return;const v=b(w);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(u.current=null,o(!1))}},[n,e]);return y.useEffect(()=>{var m;if(s(null),l(!1),!e){o(!1),c.current+=1,(m=u.current)==null||m.abort(),u.current=null;return}d();const f=setInterval(d,bhe);return()=>{var p;clearInterval(f),c.current+=1,(p=u.current)==null||p.abort(),u.current=null}},[n,e,d]),{usage:e?t:null,loading:e&&r,available:e&&i,refresh:d}}function zI(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const DI={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function yhe(n){var u;const e=V.c(31),{usage:t}=n;let s,r,o;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 d=[];t.fiveHour&&d.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&d.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&d.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&d.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?Bf(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=a.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&&a.jsx(Fe,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(r=a.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=r):r=e[18],o=d.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,b=zI(h.pct);return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:h.label}),a.jsxs("span",{className:G("font-semibold",DI[b]),children:[h.pct.toFixed(1),"%"]})]}),a.jsx(qc,{value:Math.min(h.pct,100)}),x!=null&&a.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]=r,e[9]=o}else s=e[7],r=e[8],o=e[9];let i;e[19]!==t.extraUsage?(i=((u=t.extraUsage)==null?void 0:u.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(tn,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=i):i=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(tn,{}),t.lifetimeTokens!=null&&a.jsxs("div",{children:["Lifetime: ",vt(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?a.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?a.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]!==r||e[27]!==o||e[28]!==i||e[29]!==l?(c=a.jsxs("div",{className:s,children:[r,o,i,l]}),e[25]=s,e[26]=r,e[27]=o,e[28]=i,e[29]=l,e[30]=c):c=e[30],c}function whe(n){var j,k;const e=V.c(22),{agentKind:t}=n,s=t===void 0?Wo:t,{usage:r,loading:o,available:i,refresh:l}=vhe(s);if(!i||!r)return null;const c=((j=r.fiveHour)==null?void 0:j.utilization)??((k=r.sevenDay)==null?void 0:k.utilization);if(c==null)return null;let u;e[0]!==r.agentKind?(u=r.agentKind?Bf(r.agentKind):"agent",e[0]=r.agentKind,e[1]=u):u=e[1];const d=`Refresh ${u} usage`;let f;e[2]!==o||e[3]!==l||e[4]!==d?(f=a.jsx(Q,{type:"button",variant:"ghost",size:"xs","aria-label":d,onClick:l,disabled:o,className:"mr-1 font-mono"}),e[2]=o,e[3]=l,e[4]=d,e[5]=f):f=e[5];const m=DI[zI(c)],p=o&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=G("tabular-nums",m,p),e[6]=m,e[7]=p,e[8]=h):h=e[8];let g;e[9]!==c?(g=c.toFixed(0),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==h||e[12]!==g?(x=a.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let b;e[14]!==f||e[15]!==x?(b=a.jsx(Zt,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==r?(w=a.jsx(Yt,{side:"bottom",className:"p-3",children:a.jsx(yhe,{usage:r})}),e[17]=r,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=a.jsxs(Gt,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function She(n){const e=V.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,r]=y.useState(t),[o,i]=y.useState(0);let l;e[1]!==n?(l=()=>{const m=new AbortController;r(jhe);const p=Intl.DateTimeFormat().resolvedOptions().timeZone;return Ce(`/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();r({summary:g,loading:!1,error:null})}).catch(h=>{m.signal.aborted||r(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]!==o?(c=[n,o],e[3]=n,e[4]=o,e[5]=c):c=e[5],y.useEffect(l,c);let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(khe),e[6]=u):u=e[6];const d=u;let f;return e[7]!==s?(f={...s,refresh:d},e[7]=s,e[8]=f):f=e[8],f}function khe(n){return n+1}function jhe(n){return{...n,loading:!0,error:null}}function Nhe(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const Che=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function _he(n,e){const t=Nhe(e);return t.length===0||Che.has(t)?null:n.get(t)??null}function Ehe(n,e){const t=n.longContextThresholdTokens,s=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens,r=t!==null&&s>t;return function(i,l,c){return i<=0?0:c===null||t===null?i*l:n.longContextPricing==="wholeRequest"?i*(r?c:l):i<=t?i*l:t*l+(i-t)*c}}function The(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function Ahe(n,e,t,s=null){const r=_he(n,e);if(r===null)return null;const o=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),i=t.cacheCreationTokens-o,l=Ehe(r,t),c=s==="fast"?r.fastCostMultiplier:1;return{uncachedInputUsd:c*l(t.uncachedInputTokens,r.inputCostPerToken,r.inputCostPerTokenAboveThreshold),cachedInputUsd:c*l(t.cachedInputTokens,r.cacheReadCostPerToken,r.cacheReadCostPerTokenAboveThreshold),cacheCreationUsd:c*(l(i,r.cacheCreationCostPerToken,r.cacheCreationCostPerTokenAboveThreshold)+o*r.cacheCreation1hCostPerToken),outputUsd:c*l(t.outputTokens,r.outputCostPerToken,r.outputCostPerTokenAboveThreshold)}}function Ihe(n,e,t,s,r=null){const o=Ahe(n,e,t,r);return o===null?{costUsd:0,costSource:"unpriced"}:{costUsd:The(o),costSource:"modelPriced"}}function Qb(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function Phe(n,e,t){if(!e)return 0;const{costUsd:s,costSource:r}=Ihe(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 r==="unpriced"?0:s}const $he=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],ta=w5.map(n=>({key:n,label:Cn(n).displayName,color:EM(n)}));function Rhe(n,e){const t=[],r=Date.parse(`${e}T00:00:00Z`);for(let o=Date.parse(`${n}T00:00:00Z`);o<=r;o+=864e5)t.push(new Date(o).toISOString().slice(0,10));return t}function xj(){return Object.fromEntries(ta.map(({key:n})=>[n,{costUsd:0,tokens:0}]))}function Ohe(n){const e=new Map;for(const r of Rhe(n.sinceDay,n.untilDay))e.set(r,{day:r,byProvider:xj(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:xj(),days:[],models:[]};for(const r of n.buckets){const o=Qb(r.totals);s.costUsd+=r.costUsd,s.tokens+=o,s.cacheSavingsUsd+=r.cacheSavingsUsd,s.byProvider[r.provider].costUsd+=r.costUsd,s.byProvider[r.provider].tokens+=o;const i=e.get(r.day);i&&(i.byProvider[r.provider].costUsd+=r.costUsd,i.byProvider[r.provider].tokens+=o,i.costUsd+=r.costUsd,i.tokens+=o);const l=`${r.provider}:${r.model}`;let c=t.get(l);c||(c={provider:r.provider,model:r.model,costUsd:0,tokens:0,unpriced:!0},t.set(l,c)),c.costUsd+=r.costUsd,c.tokens+=o,r.costSource!=="unpriced"&&(c.unpriced=!1)}return s.days=[...e.values()],s.models=[...t.values()].sort((r,o)=>o.costUsd-r.costUsd||o.tokens-r.tokens),s}function bj(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const ng=720,sg=180,Lhe=18;function Mhe(n){const e=V.c(41),{days:t,metric:s}=n,[r,o]=y.useState(null);let i;e[0]!==s?(i=N=>s==="cost"?N.costUsd:N.tokens,e[0]=s,e[1]=i):i=e[1];const l=i;let c;if(e[2]!==t||e[3]!==l){let N;e[5]!==l?(N=S=>l(S),e[5]=l,e[6]=N):N=e[6],c=Math.max(...t.map(N)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const u=c;if(u<=0){let N;return e[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=N):N=e[7],N}const d=sg-Lhe,f=ng/t.length,m=Math.max(2,Math.min(28,f-2)),p=r!==null?t[r]:null;let h;e[8]!==p||e[9]!==s||e[10]!==l?(h=p&&a.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 z-10 flex justify-center",children:a.jsxs("div",{className:"rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-xs",children:[a.jsx("span",{className:"font-medium",children:bj(p.day)}),ta.map(N=>{const{key:S,label:C,color:E}=N,T=p.byProvider[S];return l(T)<=0?null:a.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:E}}),C,": ",s==="cost"?gs(T.costUsd):vt(T.tokens)]},S)}),a.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?gs(p.costUsd):vt(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),b=a.jsx("line",{x1:0,y1:d,x2:ng,y2:d,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==r||e[17]!==u||e[18]!==f||e[19]!==l){let N;e[21]!==m||e[22]!==r||e[23]!==u||e[24]!==f||e[25]!==l?(N=(S,C)=>{const E=C*f+(f-m)/2;let T=d;const $=r===C;return a.jsxs("g",{onMouseEnter:()=>o(C),children:[a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"transparent"}),$&&a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"var(--foreground)",opacity:.05,rx:2}),ta.map(A=>{const{key:R,color:P}=A,z=l(S.byProvider[R]);if(z<=0)return null;const L=z/u*(d-6);return T=T-L,a.jsx("rect",{x:E,y:T,width:m,height:Math.max(1,L-1.5),rx:1.5,fill:P,opacity:$?1:.85},R)})]},S.day)},e[21]=m,e[22]=r,e[23]=u,e[24]=f,e[25]=l,e[26]=N):N=e[26],w=t.map(N),e[14]=m,e[15]=t,e[16]=r,e[17]=u,e[18]=f,e[19]=l,e[20]=w}else w=e[20];let v;if(e[27]!==t||e[28]!==f){let N;e[30]!==t.length||e[31]!==f?(N=(S,C)=>C===0||C===t.length-1||t.length>10&&C%7===0&&C<t.length-3?a.jsx("text",{x:C*f+f/2,y:sg-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:bj(S.day)},S.day):null,e[30]=t.length,e[31]=f,e[32]=N):N=e[32],v=t.map(N),e[27]=t,e[28]=f,e[29]=v}else v=e[29];let j;e[33]!==g||e[34]!==w||e[35]!==v?(j=a.jsxs("svg",{viewBox:`0 0 ${ng} ${sg}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,w,v]}),e[33]=g,e[34]=w,e[35]=v,e[36]=j):j=e[36];let k;e[37]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("div",{className:"mt-1 flex items-center gap-4",children:ta.map(zhe)}),e[37]=k):k=e[37];let _;return e[38]!==h||e[39]!==j?(_=a.jsxs("div",{className:"relative",children:[h,j,k]}),e[38]=h,e[39]=j,e[40]=_):_=e[40],_}function zhe(n){const{key:e,label:t,color:s}=n;return a.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:s}}),t]},e)}function rg(n){const e=V.c(7),{label:t,value:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function Dhe(n){const e=V.c(68),{days:t}=n,{summary:s,loading:r,error:o,refresh:i}=She(t),[l,c]=y.useState("cost");let u;e[0]!==s?(u=s?Ohe(s):null,e[0]=s,e[1]=u):u=e[1];const d=u;if(o){let U;e[2]!==i?(U=a.jsx(Q,{variant:"outline",size:"sm",onClick:i,children:"Retry"}),e[2]=i,e[3]=U):U=e[3];let O;return e[4]!==o||e[5]!==U?(O=a.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[o,U]}),e[4]=o,e[5]=U,e[6]=O):O=e[6],O}if(!d||!s){let U;return e[7]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"})," Scanning transcripts…"]}),e[7]=U):U=e[7],U}const f=r&&"opacity-60";let m;e[8]!==f?(m=G("flex flex-col gap-5",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==d.costUsd||e[11]!==d.tokens||e[12]!==l?(p=l==="cost"?gs(d.costUsd):vt(d.tokens),e[10]=d.costUsd,e[11]=d.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=a.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=a.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.distinctSessions," sessions · ",g]}),e[16]=s.distinctSessions,e[17]=g,e[18]=x):x=e[18];let b;e[19]!==h||e[20]!==x?(b=a.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=b):b=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let v;e[23]!==l?(v=a.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(U=>a.jsx(Q,{variant:l===U?"secondary":"ghost",size:"xs",onClick:()=>c(U),children:U==="cost"?"Cost":"Tokens"},U))}),e[23]=l,e[24]=v):v=e[24];let j;e[25]!==d.byProvider||e[26]!==l?(j=ta.map(U=>{const{key:O,label:D}=U,B=d.byProvider[O];return B.costUsd===0&&B.tokens===0?null:a.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[D,": ",l==="cost"?gs(B.costUsd):vt(B.tokens)]},O)}),e[25]=d.byProvider,e[26]=l,e[27]=j):j=e[27];let k;e[28]!==v||e[29]!==j?(k=a.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,j]}),e[28]=v,e[29]=j,e[30]=k):k=e[30];let _;e[31]!==k||e[32]!==b?(_=a.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,k]}),e[31]=k,e[32]=b,e[33]=_):_=e[33];let N;e[34]!==d.days||e[35]!==l?(N=a.jsx(Mhe,{days:d.days,metric:l}),e[34]=d.days,e[35]=l,e[36]=N):N=e[36];let S;e[37]!==d.tokens?(S=vt(d.tokens),e[37]=d.tokens,e[38]=S):S=e[38];let C;e[39]!==S?(C=a.jsx(rg,{label:"Processed tokens",value:S}),e[39]=S,e[40]=C):C=e[40];let E;e[41]!==d.cacheSavingsUsd?(E=gs(d.cacheSavingsUsd),e[41]=d.cacheSavingsUsd,e[42]=E):E=e[42];let T;e[43]!==E?(T=a.jsx(rg,{label:"Cache savings",value:E}),e[43]=E,e[44]=T):T=e[44];const $=String(s.scannedFiles);let A;e[45]!==$?(A=a.jsx(rg,{label:"Files scanned",value:$}),e[45]=$,e[46]=A):A=e[46];let R;e[47]!==C||e[48]!==T||e[49]!==A?(R=a.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[C,T,A]}),e[47]=C,e[48]=T,e[49]=A,e[50]=R):R=e[50];let P;e[51]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx("thead",{children:a.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=P):P=e[51];let z;if(e[52]!==d.costUsd||e[53]!==d.models){let U;e[55]!==d.costUsd?(U=O=>{var D;return a.jsxs("tr",{className:"border-b border-border/50",children:[a.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(D=ta.find(B=>B.key===O.provider))==null?void 0:D.color}}),O.model]})}),a.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:O.unpriced?"—":gs(O.costUsd)}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:d.costUsd>0&&!O.unpriced?`${(O.costUsd/d.costUsd*100).toFixed(1)}%`:"—"}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:vt(O.tokens)})]},`${O.provider}:${O.model}`)},e[55]=d.costUsd,e[56]=U):U=e[56],z=d.models.map(U),e[52]=d.costUsd,e[53]=d.models,e[54]=z}else z=e[54];let L;e[57]!==z?(L=a.jsxs("table",{className:"w-full text-sm",children:[P,a.jsx("tbody",{children:z})]}),e[57]=z,e[58]=L):L=e[58];const I=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let M;e[59]!==I?(M=a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",I," ","— not what a subscription bills."]}),e[59]=I,e[60]=M):M=e[60];let F;return e[61]!==_||e[62]!==N||e[63]!==R||e[64]!==L||e[65]!==M||e[66]!==m?(F=a.jsxs("div",{className:m,children:[_,N,R,L,M]}),e[61]=_,e[62]=N,e[63]=R,e[64]=L,e[65]=M,e[66]=m,e[67]=F):F=e[67],F}function Fhe(n){const e=V.c(15),{open:t,onOpenChange:s}=n,[r,o]=y.useState(30);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsxs("div",{children:[a.jsx(or,{children:"API usage"}),a.jsx(ir,{children:"What this machine's agent usage would cost at raw API prices."})]}),e[0]=i):i=e[0];let l;e[1]!==r?(l=$he.map(m=>a.jsx(Q,{variant:r===m.days?"secondary":"ghost",size:"xs",onClick:()=>o(m.days),children:m.label},m.days)),e[1]=r,e[2]=l):l=e[2];let c;e[3]!==l?(c=a.jsx(ao,{children:a.jsxs("div",{className:"flex items-center justify-between gap-4 pr-6",children:[i,a.jsx("div",{className:"flex rounded-md border p-0.5",children:l})]})}),e[3]=l,e[4]=c):c=e[4];let u;e[5]!==r||e[6]!==t?(u=t&&a.jsx(Dhe,{days:r}),e[5]=r,e[6]=t,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs(rr,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==s||e[12]!==t||e[13]!==d?(f=a.jsx(sr,{open:t,onOpenChange:s,children:d}),e[11]=s,e[12]=t,e[13]=d,e[14]=f):f=e[14],f}const Uhe=15e3;function Bhe(){y.useEffect(()=>{async function n(){var s,r;try{const o=await Ce("/api/notifications?limit=100");if(!o.ok)return;const i=await o.json();if(!Array.isArray(i.notifications))return;(r=(s=Ag()).onInboxRead)==null||r.call(s,i.notifications)}catch{}}n();const e=window.setInterval(()=>void n(),Uhe),t=()=>void n();return window.addEventListener("focus",t),()=>{window.clearInterval(e),window.removeEventListener("focus",t)}},[])}async function Whe(n,e){try{return(await is("/api/archive-sessions",{sessionIds:n,archived:e})).ok}catch{return!1}}function FI(){const n=ar(),e=n==null?void 0:n.setArchived,t=n==null?void 0:n.refresh,s=y.useCallback(async(r,o,i)=>{if(e==null||e(r,o),!await Whe([...r],o)){e==null||e(r,!o),Kn.error(o?"Could not archive session":"Could not restore session");return}t==null||t(),i&&Kn(i,{action:{label:"Undo",onClick:()=>{s(r,!o,null)}}})},[e,t]);return s}function UI(n,e,t){const s=V.c(13),r=ar(),o=FI();if(!r||!t)return null;let i;s[0]!==r||s[1]!==n?(i=r.isArchived(n),s[0]=r,s[1]=n,s[2]=i):i=s[2];const l=i,c=l?"Restore from archive":"Archive session",u=l?Cf:Ns,d=e&&!l?"Stop the session before archiving it":void 0;let f;s[3]!==o||s[4]!==l||s[5]!==n?(f=()=>{o([n],!l,l?"Session restored":"Session archived")},s[3]=o,s[4]=l,s[5]=n,s[6]=f):f=s[6];let m;return s[7]!==l||s[8]!==c||s[9]!==u||s[10]!==d||s[11]!==f?(m={archived:l,label:c,icon:u,disabledReason:d,toggle:f},s[7]=l,s[8]=c,s[9]=u,s[10]=d,s[11]=f,s[12]=m):m=s[12],m}const qhe=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,Vhe=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,og=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,Hhe=[new RegExp(`${og}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${og}'([^']*)'`),new RegExp(`${og}(\\S+)`)];function Khe(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(Array.isArray(e)){const i=e.filter(l=>typeof l=="string");return[i.join(" "),...i]}const t=n.source;if(typeof t!="string")return[];const s=[],r=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*"((?:\\.|[^"\\])*)"/g;for(const i of t.matchAll(r))try{s.push(JSON.parse(`"${i[1]}"`))}catch{}const o=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*`([^`]*)`/g;for(const i of t.matchAll(o))s.push(i[1]);return s}function Ghe(n){return Khe(n).find(e=>Vhe.test(e))??null}function Zhe(n){for(const e of Hhe){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function Yhe(){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,r,o,i){const l=qhe.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:Zhe(r),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(r),toolCallId:o,timestamp:i})}}}function Xhe(n){const e=Yhe();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const r=Ghe(s.input);r&&e.record(s.result,r,s.id,s.timestamp)}return e.pullRequests}function Jhe(...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 ti="flex h-8 items-center px-0.5",Qhe=y.memo(function(e){var me;const t=V.c(123),{showSidebar:s,sidebarRendered:r,sidebarShortcut:o,killing:i,creatingSession:l,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d,onBackToMain:f,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x,onLogout:b,onOpenMainView:w}=e,v=r===void 0?s:r,{config:j}=Sn(),{networkUrl:k,defaultAgentKind:_}=j,{session:N,sessionSource:S,isLive:C,permissions:E,actions:T}=jt(),$=ar(),{AccountControl:A,SessionHeaderActions:R}=$r(),P=Nn("viewUsage");Bhe();const[z,L]=y.useState(!1),[I,M]=y.useState(!1),[F,U]=so(),O=N==null?void 0:N.turns;let D;t[0]!==($==null?void 0:$.sessions)||t[1]!==(N==null?void 0:N.sessionId)?(D=(me=$==null?void 0:$.sessions.find(je=>je.sessionId===(N==null?void 0:N.sessionId)))==null?void 0:me.pullRequests,t[0]=$==null?void 0:$.sessions,t[1]=N==null?void 0:N.sessionId,t[2]=D):D=t[2];const B=D;let q;t[3]!==B||t[4]!==O?(q=Jhe(Xhe(O??[]),B),t[3]=B,t[4]=O,t[5]=q):q=t[5];const W=q,H=UI((N==null?void 0:N.sessionId)??"",C,E.archive);let K;t[6]!==_||t[7]!==S?(K=S?S.agentKind??un(S.dirName):_,t[6]=_,t[7]=S,t[8]=K):K=t[8];const Z=K;let Y;t[9]!==S?(Y=S?$o(S.fileName)!==null:!1,t[9]=S,t[10]=Y):Y=t[10];const J=Y;let ee;t[11]!==U||t[12]!==N||t[13]!==(S==null?void 0:S.agentKind)||t[14]!==(S==null?void 0:S.dirName)?(ee=function(){if(!N)return;const Xe=(S==null?void 0:S.agentKind)??un((S==null?void 0:S.dirName)??null);U(Cx(Xe,N.sessionId,N.cwd))},t[11]=U,t[12]=N,t[13]=S==null?void 0:S.agentKind,t[14]=S==null?void 0:S.dirName,t[15]=ee):ee=t[15];const te=ee;let se;t[16]!==k?(se=function(){k&&Pf(k).then(ege)},t[16]=k,t[17]=se):se=t[17];const X=se;let ne,ae;t[18]===Symbol.for("react.memo_cache_sentinel")?(ae=a.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),ne=a.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]=ne,t[19]=ae):(ne=t[18],ae=t[19]);const ie=!v&&"window-inset-start";let re;t[20]!==ie?(re=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",ie),t[20]=ie,t[21]=re):re=t[21];let de;t[22]!==h||t[23]!==s||t[24]!==o?(de=!s&&a.jsx(vj,{icon:C8,label:`Show sidebar (${o})`,onClick:h}),t[22]=h,t[23]=s,t[24]=o,t[25]=de):de=t[25];let ce;t[26]!==J||t[27]!==f||t[28]!==N?(ce=N&&J&&f&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:f,className:G(fs,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[a.jsx(it,{className:"size-3 rotate-180"}),"Main"]}),t[26]=J,t[27]=f,t[28]=N,t[29]=ce):ce=t[29];let oe;t[30]!==F||t[31]!==l||t[32]!==te||t[33]!==C||t[34]!==u||t[35]!==c||t[36]!==d||t[37]!==W||t[38]!==N||t[39]!==S?(oe=N&&a.jsx(Ype,{session:N,sessionSource:S,isLive:C,pullRequests:W,copied:F,creatingSession:l,onCopyResume:te,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d}),t[30]=F,t[31]=l,t[32]=te,t[33]=C,t[34]=u,t[35]=c,t[36]=d,t[37]=W,t[38]=N,t[39]=S,t[40]=oe):oe=t[40];let fe;t[41]!==J||t[42]!==N?(fe=N&&!J&&a.jsx(Npe,{sessionId:N.sessionId}),t[41]=J,t[42]=N,t[43]=fe):fe=t[43];let ue;t[44]!==m||t[45]!==N||t[46]!==p?(ue=N&&m&&(p??0)>0&&a.jsxs(Q,{variant:"ghost",size:"xs",className:G(fs,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[a.jsx(B4,{className:"size-3"}),"Workflows",a.jsx(Fe,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[44]=m,t[45]=N,t[46]=p,t[47]=ue):ue=t[47];let le;t[48]!==re||t[49]!==de||t[50]!==ce||t[51]!==oe||t[52]!==fe||t[53]!==ue?(le=a.jsxs("div",{className:re,children:[de,ce,oe,fe,ue]}),t[48]=re,t[49]=de,t[50]=ce,t[51]=oe,t[52]=fe,t[53]=ue,t[54]=le):le=t[54];let pe;t[55]===Symbol.for("react.memo_cache_sentinel")?(pe=G(fs,ti,"empty:hidden"),t[55]=pe):pe=t[55];let ge,be;t[56]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx("div",{className:pe,children:a.jsx(Rpe,{onReview:()=>M(!0)})}),be=G(fs,ti,"empty:hidden"),t[56]=ge,t[57]=be):(ge=t[56],be=t[57]);let ve;t[58]!==Z?(ve=a.jsx("div",{className:be,children:a.jsx(whe,{agentKind:Z})}),t[58]=Z,t[59]=ve):ve=t[59];let Se;t[60]===Symbol.for("react.memo_cache_sentinel")?(Se=a.jsx("div",{className:G(fs,ti,"empty:hidden"),children:a.jsx(Xb,{})}),t[60]=Se):Se=t[60];let we;t[61]!==Z||t[62]!==N?(we=N&&bn(Z).sharing&&xt("share")&&a.jsx("div",{className:G(fs,ti),children:a.jsx(lhe,{sessionId:N.sessionId})}),t[61]=Z,t[62]=N,t[63]=we):we=t[63];let Ee;t[64]!==R||t[65]!==J||t[66]!==N?(Ee=N&&!J&&R&&a.jsx("div",{className:G(fs,ti,"empty:hidden"),children:a.jsx(R,{sessionId:N.sessionId})}),t[64]=R,t[65]=J,t[66]=N,t[67]=Ee):Ee=t[67];let $e;t[68]!==H||t[69]!==J||t[70]!==N?($e=N&&!J&&H&&a.jsx(vj,{icon:H.icon,label:H.label,disabledReason:H.disabledReason,onClick:H.toggle}),t[68]=H,t[69]=J,t[70]=N,t[71]=$e):$e=t[71];let Be;t[72]===Symbol.for("react.memo_cache_sentinel")?(Be=G(fs,ti),t[72]=Be):Be=t[72];let qe;t[73]===Symbol.for("react.memo_cache_sentinel")?(qe=a.jsx(Rc,{render:a.jsx(Q,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:a.jsx(q4,{"data-icon":"inline-start"})}),t[73]=qe):qe=t[73];let ze;t[74]!==T||t[75]!==J||t[76]!==E.send||t[77]!==N?(ze=N&&!J&&E.send&&T.handleProviderHandoff&&a.jsxs(a.Fragment,{children:[a.jsx(qr,{children:a.jsxs(hn,{onClick:T.handleProviderHandoff,children:[a.jsx(W4,{}),"Continue with another provider…"]})}),a.jsx(Il,{})]}),t[74]=T,t[75]=J,t[76]=E.send,t[77]=N,t[78]=ze):ze=t[78];let Ie;t[79]!==P?(Ie=P&&a.jsxs(hn,{onClick:()=>L(!0),children:[a.jsx(_8,{}),"Usage & cost…"]}),t[79]=P,t[80]=Ie):Ie=t[80];let Me;t[81]===Symbol.for("react.memo_cache_sentinel")?(Me=a.jsxs(hn,{onClick:()=>M(!0),children:[a.jsx(wg,{}),"Server monitor…"]}),t[81]=Me):Me=t[81];let Ue;t[82]!==X||t[83]!==k?(Ue=k&&a.jsxs(hn,{onClick:X,children:[a.jsx(sa,{className:"text-success"}),"Copy network URL",a.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:k})]}),t[82]=X,t[83]=k,t[84]=Ue):Ue=t[84];let De;t[85]!==Ie||t[86]!==Ue?(De=a.jsxs(qr,{children:[Ie,Me,Ue]}),t[85]=Ie,t[86]=Ue,t[87]=De):De=t[87];let Ke;t[88]===Symbol.for("react.memo_cache_sentinel")?(Ke=a.jsx(Il,{}),t[88]=Ke):Ke=t[88];let Ne;t[89]===Symbol.for("react.memo_cache_sentinel")?(Ne=a.jsx(E8,{}),t[89]=Ne):Ne=t[89];let Ae;t[90]!==x?(Ae=a.jsx(qr,{children:a.jsxs(hn,{onClick:x,children:[Ne,"Settings"]})}),t[90]=x,t[91]=Ae):Ae=t[91];let Qe;t[92]!==i||t[93]!==g?(Qe=xt("killAny")&&a.jsxs(a.Fragment,{children:[a.jsx(Il,{}),a.jsx(qr,{children:a.jsxs(hn,{variant:"destructive",onClick:g,disabled:i,children:[a.jsx(N8,{}),i?"Stopping processes…":"Stop all agent processes"]})})]}),t[92]=i,t[93]=g,t[94]=Qe):Qe=t[94];let Je;t[95]!==ze||t[96]!==De||t[97]!==Ae||t[98]!==Qe?(Je=a.jsx("div",{className:Be,children:a.jsxs($c,{children:[qe,a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-64",children:[ze,De,Ke,Ae,Qe]})]})}),t[95]=ze,t[96]=De,t[97]=Ae,t[98]=Qe,t[99]=Je):Je=t[99];let ke;t[100]!==A||t[101]!==b||t[102]!==w?(ke=A&&a.jsx("div",{className:G(fs,ti,"empty:hidden"),children:a.jsx(A,{onLogout:b,onOpenMainView:w})}),t[100]=A,t[101]=b,t[102]=w,t[103]=ke):ke=t[103];let We;t[104]!==ve||t[105]!==we||t[106]!==Ee||t[107]!==$e||t[108]!==Je||t[109]!==ke?(We=a.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[ge,ve,Se,we,Ee,$e,Je,ke]}),t[104]=ve,t[105]=we,t[106]=Ee,t[107]=$e,t[108]=Je,t[109]=ke,t[110]=We):We=t[110];let ye;t[111]!==le||t[112]!==We?(ye=a.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:[le,We]}),t[111]=le,t[112]=We,t[113]=ye):ye=t[113];let Re;t[114]!==P||t[115]!==z?(Re=P&&a.jsx(Fhe,{open:z,onOpenChange:L}),t[114]=P,t[115]=z,t[116]=Re):Re=t[116];let Ve;t[117]!==I?(Ve=a.jsx(Hpe,{open:I,onOpenChange:M}),t[117]=I,t[118]=Ve):Ve=t[118];let He;return t[119]!==ye||t[120]!==Re||t[121]!==Ve?(He=a.jsxs(a.Fragment,{children:[ae,ne,ye,Re,Ve]}),t[119]=ye,t[120]=Re,t[121]=Ve,t[122]=He):He=t[122],He});function vj(n){const e=V.c(23),{icon:t,label:s,onClick:r,disabledReason:o}=n;if(o){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=G(fs,"size-8 shrink-0"),e[0]=m):m=e[0];let p;e[1]!==t?(p=a.jsx(t,{"data-icon":"inline-start"}),e[1]=t,e[2]=p):p=e[2];let h;e[3]!==s||e[4]!==p?(h=a.jsx(Q,{variant:"ghost",size:"icon-sm",disabled:!0,"aria-label":s,className:m,children:p}),e[3]=s,e[4]=p,e[5]=h):h=e[5];let g;return e[6]!==o||e[7]!==h?(g=a.jsx(vd,{reason:o,children:h}),e[6]=o,e[7]=h,e[8]=g):g=e[8],g}let i;e[9]===Symbol.for("react.memo_cache_sentinel")?(i=G(fs,"size-8 shrink-0"),e[9]=i):i=e[9];let l;e[10]!==s||e[11]!==r?(l=a.jsx(Q,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":s,className:i}),e[10]=s,e[11]=r,e[12]=l):l=e[12];let c;e[13]!==t?(c=a.jsx(t,{"data-icon":"inline-start"}),e[13]=t,e[14]=c):c=e[14];let u;e[15]!==l||e[16]!==c?(u=a.jsx(Zt,{render:l,children:c}),e[15]=l,e[16]=c,e[17]=u):u=e[17];let d;e[18]!==s?(d=a.jsx(Yt,{side:"bottom",children:s}),e[18]=s,e[19]=d):d=e[19];let f;return e[20]!==u||e[21]!==d?(f=a.jsxs(Gt,{children:[u,d]}),e[20]=u,e[21]=d,e[22]=f):f=e[22],f}function ege(n){n&&Kn.success("Copied network URL")}const tge=y.memo(function(e){const t=V.c(13),{onToggleSidebar:s,onGoHome:r,onOpenCommandPalette:o,sidebarShortcut:i,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let u;t[1]!==r?(u=a.jsx(Dh,{icon:Na,label:"Home",onClick:r,size:"default"}),t[1]=r,t[2]=u):u=t[2];const d=`Search (${l})`;let f;t[3]!==o||t[4]!==d?(f=a.jsx(Dh,{icon:ss,label:d,onClick:o,size:"default"}),t[3]=o,t[4]=d,t[5]=f):f=t[5];const m=`Hide sidebar (${i})`;let p;t[6]!==s||t[7]!==m?(p=a.jsx(Dh,{icon:T8,label:m,onClick:s,size:"default"}),t[6]=s,t[7]=m,t[8]=p):p=t[8];let h;return t[9]!==u||t[10]!==f||t[11]!==p?(h=a.jsxs("div",{className:"electron-drag window-inset-start flex h-12 shrink-0 items-center gap-1 px-2",children:[c,u,f,p]}),t[9]=u,t[10]=f,t[11]=p,t[12]=h):h=t[12],h});function nge(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(P8,{"data-slot":"resizable-panel-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function yj(n){const e=V.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=a.jsx(I8,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function sge(n){const e=V.c(12);let t,s,r;e[0]!==n?({withHandle:r,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),e[4]=t,e[5]=o):o=e[5];let i;e[6]!==r?(i=r&&a.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=r,e[7]=i):i=e[7];let l;return e[8]!==s||e[9]!==o||e[10]!==i?(l=a.jsx(A8,{"data-slot":"resizable-handle",className:o,...s,children:i}),e[8]=s,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const BI=y.createContext(null);function WI(n){const e=V.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(BI.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function ev(){const n=y.useContext(BI);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function qI(n){const e=V.c(18),{title:t,icon:s,active:r,onClick:o,children:i}=n,l=r&&"bg-sidebar-primary text-sidebar-primary-foreground hover:bg-sidebar-primary/90 hover:text-sidebar-primary-foreground";let c;e[0]!==l?(c=G("relative rounded-md",l),e[0]=l,e[1]=c):c=e[1];let u;e[2]!==r||e[3]!==o||e[4]!==c||e[5]!==t?(u=a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t,"aria-pressed":r,onClick:o,className:c}),e[2]=r,e[3]=o,e[4]=c,e[5]=t,e[6]=u):u=e[6];let d;e[7]!==s?(d=a.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=d):d=e[8];let f;e[9]!==i||e[10]!==u||e[11]!==d?(f=a.jsxs(Zt,{render:u,children:[d,i]}),e[9]=i,e[10]=u,e[11]=d,e[12]=f):f=e[12];let m;e[13]!==t?(m=a.jsx(Yt,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==f||e[16]!==m?(p=a.jsxs(Gt,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function tv(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function rge(n){const e=V.c(25),{panels:t,context:s,activePanelId:r,onTogglePanel:o,actions:i}=n;let l;e[0]!==i?(l=i===void 0?[]:i,e[0]=i,e[1]=l):l=e[1];const c=l;let u,d,f,m,p,h;if(e[2]!==c||e[3]!==r||e[4]!==s||e[5]!==o||e[6]!==t){h=Symbol.for("react.early_return_sentinel");e:{const x=tv(t,s);if(x.length===0&&c.length===0){h=null;break e}u="Workspace panels",d="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(oge),e[13]=c,e[14]=f):f=e[14],m=c.length>0&&x.length>0&&a.jsx("div",{"aria-hidden":!0,className:"my-1 h-px w-6 bg-sidebar-border"});let b;e[15]!==r||e[16]!==s||e[17]!==o?(b=w=>{var _;const v=w.id===r,j=(_=w.badge)==null?void 0:_.call(w,s),k=w.indicator;return a.jsx(qI,{title:w.title,icon:w.icon,active:v,onClick:()=>o(w.id),children:k?a.jsx(k,{...w.indicatorProps,context:s,active:v}):j!=null&&a.jsx(Fe,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:j})},w.id)},e[15]=r,e[16]=s,e[17]=o,e[18]=b):b=e[18],p=x.map(b)}e[2]=c,e[3]=r,e[4]=s,e[5]=o,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=m,e[11]=p,e[12]=h}else u=e[7],d=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]!==u||e[20]!==d||e[21]!==f||e[22]!==m||e[23]!==p?(g=a.jsxs("aside",{"aria-label":u,className:d,children:[f,m,p]}),e[19]=u,e[20]=d,e[21]=f,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function oge(n){return a.jsx(qI,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function VI(n){const e=V.c(20),{panels:t,context:s,activePanelId:r,onClosePanel:o,active:i}=n,l=i===void 0?!0:i;let c;e[0]!==r?(c=()=>new Set([r]),e[0]=r,e[1]=c):c=e[1];const[u,d]=y.useState(c);let f,m;e[2]!==r?(f=()=>{d(g=>{if(g.has(r))return g;const x=new Set(g);return x.add(r),x})},m=[r],e[2]=r,e[3]=f,e[4]=m):(f=e[3],m=e[4]),y.useEffect(f,m);let p;if(e[5]!==r||e[6]!==s||e[7]!==l||e[8]!==o||e[9]!==t||e[10]!==u){let g;e[12]!==r||e[13]!==s||e[14]!==l||e[15]!==o||e[16]!==u?(g=x=>{const b=x.id===r,w=b&&l;if(!b&&(!x.keepAlive||!u.has(x.id)))return null;const v=x.component;return a.jsx("div",{className:G("absolute inset-0 min-h-0",!w&&"hidden"),"aria-hidden":!w,children:a.jsx(v,{...x.componentProps,context:s,active:w,closePanel:o})},x.id)},e[12]=r,e[13]=s,e[14]=l,e[15]=o,e[16]=u,e[17]=g):g=e[17],p=t.map(g),e[5]=r,e[6]=s,e[7]=l,e[8]=o,e[9]=t,e[10]=u,e[11]=p}else p=e[11];let h;return e[18]!==p?(h=a.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-canvas",children:p}),e[18]=p,e[19]=h):h=e[19],h}function ige(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 age(n){const e=V.c(23),{children:t,panels:s,context:r,activePanel:o,services:i,onClosePanel:l,onTogglePanel:c,actions:u}=n;let d;e[0]!==o?(d=o?ige(o.defaultSize):"100%",e[0]=o,e[1]=d):d=e[1];let f;e[2]!==t||e[3]!==d?(f=a.jsx(yj,{defaultSize:d,minSize:"320px",children:t}),e[2]=t,e[3]=d,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==r||e[7]!==l||e[8]!==s||e[9]!==i?(m=o&&a.jsxs(a.Fragment,{children:[a.jsx(sge,{withHandle:!0}),a.jsx(yj,{defaultSize:o.defaultSize??"36%",minSize:o.minSize??"300px",maxSize:o.maxSize??"70%",children:a.jsx(WI,{value:i,children:a.jsx(VI,{panels:s,context:r,activePanelId:o.id,onClosePanel:l})})})]}),e[5]=o,e[6]=r,e[7]=l,e[8]=s,e[9]=i,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=a.jsxs(nge,{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=(o==null?void 0:o.id)??null;let g;e[14]!==u||e[15]!==r||e[16]!==c||e[17]!==s||e[18]!==h?(g=a.jsx(rge,{panels:s,context:r,activePanelId:h,onTogglePanel:c,actions:u}),e[14]=u,e[15]=r,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=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function HI(n){const e=V.c(7),[t]=y.useState(cge),s=y.useSyncExternalStore(t.subscribe,t.getSnapshot,lge);let r,o;e[0]!==t||e[1]!==n?(r=()=>{if(n)return t.start(),()=>t.stop()},o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),y.useEffect(r,o);let i;return e[4]!==t||e[5]!==s?(i={client:t,...s},e[4]=t,e[5]=s,e[6]=i):i=e[6],i}function lge(){return Jg}function cge(){return new GV}function Gr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function dn(n,e=""){return typeof n=="string"?n:e}const uge=new Set(["open","custom","closed","done"]),dge=new Set(["urgent","high","normal","low"]);class fge extends Error{constructor(t,s,r){super(r);Ge(this,"status");Ge(this,"code");this.status=t,this.code=s}}function wj(n){return typeof n=="number"?String(n):dn(n)}function ni(n){const e=typeof n=="string"?Number(n):n;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function mge(n){const e=Gr(n);return e&&e.hidden!==!0&&dn(e.name)||null}function pge(n){return new fge(502,"invalid_response",`ClickUp returned an invalid ${n} response`)}function hge(n){const e=Gr(n);if(!e||typeof e.id!="number")return null;const t=dn(e.username)||dn(e.email);return{id:e.id,username:t,initials:dn(e.initials)||t.slice(0,2).toUpperCase(),color:dn(e.color)||null}}function gge(n){const e=Gr(n);if(!e)return null;const t=dn(e.status);if(!t)return null;const s=dn(e.type);return{name:t,type:uge.has(s)?s:"custom",color:dn(e.color,"#d3d3d3"),order:typeof e.orderindex=="number"?e.orderindex:0}}function xge(n){const e=Gr(n),t=dn(e==null?void 0:e.name);return t?{name:t,background:dn(e==null?void 0:e.tag_bg)||null}:null}function bge(n){var t;const e=dn((t=Gr(n))==null?void 0:t.priority);return dge.has(e)?e:null}function vge(n){var i;const e=Gr(n);if(!e)return null;const t=dn(e.id),s=gge(e.status),r=Gr(e.list);if(!t||!s||!r)return null;const o=dn(e.custom_id);return{id:t,customId:o||null,name:dn(e.name,"Untitled task"),description:dn(e.markdown_description)||dn(e.description),status:s,priority:bge(e.priority),url:dn(e.url)||`https://app.clickup.com/t/${t}`,assignees:Array.isArray(e.assignees)?e.assignees.map(hge).filter(l=>l!==null):[],tags:Array.isArray(e.tags)?e.tags.map(xge).filter(l=>l!==null):[],parentId:dn(e.parent)||null,listId:wj(r.id),listName:dn(r.name,"List"),folderName:mge(e.folder),spaceId:wj((i=Gr(e.space))==null?void 0:i.id),createdAt:ni(e.date_created)??0,updatedAt:ni(e.date_updated)??ni(e.date_created)??0,dueAt:ni(e.due_date),startAt:ni(e.start_date),closedAt:ni(e.date_closed)??ni(e.date_done)}}function yge(n){const e=Gr(n);if(!e||!Array.isArray(e.tasks))throw pge("task list");return{tasks:e.tasks.map(vge).filter(t=>t!==null),lastPage:e.last_page!==!1}}const wge="absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",Sge="absolute -right-0.5 -top-0.5 size-3 p-0 text-[8px]",kge=new Set(["cogpit.github","cogpit.vercel","cogpit.clickup"]),jge=new Set(["action_required","failure","startup_failure","timed_out"]),Nge=new Set(["BUILDING","INITIALIZING","QUEUED"]),Cge=new Set(["BLOCKED","CANCELED","ERROR"]);function xf(n,e,t="default"){return n?{text:String(n),label:e,variant:t}:null}function _ge(n,e){var r;const t=n.filter(o=>o.status!=="completed").length;if(t)return xf(t,`${t} active GitHub Actions run${t===1?"":"s"}`);if((r=n[0])!=null&&r.conclusion&&jge.has(n[0].conclusion))return{text:"!",label:"Latest GitHub Actions run failed",variant:"destructive",compact:!0};const s=e.filter(o=>(o.state==="open"||o.state==="draft")&&o.reviewRequested).length;return xf(s,`${s} pull request${s===1?"":"s"} waiting for your review`,"secondary")}function Ege(n){const e=n.filter(t=>Nge.has(t.state)).length;return e?xf(e,`${e} active Vercel deployment${e===1?"":"s"}`):n[0]&&Cge.has(n[0].state)?{text:"!",label:"Latest Vercel deployment failed",variant:"destructive",compact:!0}:null}function Tge(n){const e=new Date;e.setHours(0,0,0,0);const t=n.filter(s=>s.status.type!=="closed"&&s.dueAt!==null&&s.dueAt<e.getTime()).length;return xf(t,`${t} overdue ClickUp task${t===1?"":"s"}`,"destructive")}class Sj extends Error{}function Age(n){let e=[],t=[],s=-1/0;return async(r,o)=>{let i=0;async function l(d){const f=await r({protocol:1,type:"request",id:`indicator-${++i}`,method:"integrations.request",params:d});if(o.throwIfAborted(),!f.ok)throw new Sj("Integration unavailable");return f.data}if(n==="cogpit.vercel"){const d=await l({integration:"vercel",operation:"deployments",limit:20});return Ege(d.deployments)}if(n==="cogpit.github"){const d=await Promise.allSettled([l({integration:"github",operation:"actions",limit:20}),Date.now()-s>=3e4?l({integration:"github",operation:"pulls",limit:30}):Promise.resolve(null)]);o.throwIfAborted();for(const p of d)if(p.status==="rejected"&&!(p.reason instanceof Sj))throw p.reason;const[f,m]=d;return f.status==="fulfilled"&&(e=f.value.runs),m.status==="fulfilled"&&m.value!==null&&(t=m.value.pulls,s=Date.now()),_ge(e,t)}const c=await r({protocol:1,type:"request",id:"indicator-status",method:"connections.status",params:{handle:"clickup"}});if(o.throwIfAborted(),!c.configured||!c.selected.workspace)return null;const u=new Map;for(let d=0;d<3;d++){const f=yge(await r({protocol:1,type:"request",id:`indicator-page-${d}`,method:"connections.request",params:{handle:"clickup",operationId:"mine",args:{page:d}}}));o.throwIfAborted();for(const m of f.tasks)u.set(m.id,m);if(f.lastPage)break}return Tge([...u.values()])}}function Ige({client:n,pluginId:e,projectId:t,workspacePath:s,activation:r,registryRevision:o,enabled:i=!0}){const l=JSON.stringify([e,t,s,r,o,i]),[c,u]=y.useState(null);y.useEffect(()=>{if(!i||!r||!kge.has(e)||e!=="cogpit.clickup"&&(!t||!s))return;const f=new AbortController,m=Age(e),p=e==="cogpit.clickup"?6e4:1e4,h=Array.from(crypto.getRandomValues(new Uint8Array(16)),k=>k.toString(16).padStart(2,"0")).join("");let g,x=null,b=!1;function w(){const k=x;x=null,k&&n.revokeLease(k).catch(()=>{})}async function v(){if(b||f.signal.aborted)return;if(document.visibilityState==="hidden"){g=setTimeout(()=>{v()},p);return}b=!0;const k=new AbortController,_=Date.now()+2e4;let N=setTimeout(()=>{k.abort(),w()},2e4);const S=AbortSignal.any([f.signal,k.signal]);try{const C=await n.lease(e,t,h,S,s);x=C.id,S.throwIfAborted();const E=Math.min(_,C.expiresAt)-Date.now();if(E<=0)throw new Error("Plugin lease expired");clearTimeout(N),N=setTimeout(()=>{k.abort(),w()},E);const T=await m($=>(S.throwIfAborted(),n.call(C.id,$,S)),S);S.throwIfAborted(),u({client:n,identity:l,indicator:T})}catch{f.signal.aborted||u({client:n,identity:l,indicator:null})}finally{clearTimeout(N),w(),b=!1,f.signal.aborted||(g=setTimeout(()=>{v()},p))}}function j(){document.visibilityState==="visible"&&!b&&(clearTimeout(g),v())}return v(),document.addEventListener("visibilitychange",j),()=>{f.abort(),clearTimeout(g),document.removeEventListener("visibilitychange",j),w()}},[n,e,t,s,r,o,i,l]);const d=(c==null?void 0:c.client)===n&&c.identity===l?c.indicator:null;return d?a.jsx(Fe,{variant:d.variant,className:d.compact?Sge:wge,"aria-label":d.label,children:d.text}):null}function Pge(n){const e=V.c(8),t=y.useRef(null),[s,r]=y.useState(null);let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>()=>{var m;(m=t.current)==null||m.finish(!1)},i=[],e[0]=o,e[1]=i):(o=e[0],i=e[1]),y.useEffect(o,i);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(m,p)=>{p.throwIfAborted();const h=new URL(m);return m.length>2048||h.protocol!=="https:"||h.username||h.password?Promise.reject(Object.assign(new Error("Only HTTPS links without credentials are supported"),{code:"INVALID_REQUEST"})):t.current?Promise.reject(Object.assign(new Error("A link is already awaiting review"),{code:"RATE_LIMITED"})):new Promise((g,x)=>{const b=()=>w.finish(!1),w={url:h.href,finish(v){t.current===w&&(t.current=null,p.removeEventListener("abort",b),r(null),v&&!p.aborted?g():x(Object.assign(new Error("Opening the link was canceled"),{code:"CANCELED"})))}};t.current=w,p.addEventListener("abort",b,{once:!0}),r(w)})},e[2]=l):l=e[2];const c=l;let u;e[3]!==s||e[4]!==n?(u=s?a.jsx(sr,{open:!0,onOpenChange:m=>{var p;m||(p=t.current)==null||p.finish(!1)},children:a.jsxs(rr,{children:[a.jsxs(or,{children:["Open link from ",n,"?"]}),a.jsx(ir,{children:"This opens a website outside Cogpit."}),a.jsx("p",{className:"max-h-48 overflow-auto break-all rounded-md bg-muted p-3 text-sm",dir:"ltr",children:s==null?void 0:s.url}),a.jsxs(Rx,{children:[a.jsx(Q,{variant:"outline",onClick:()=>{var m;return(m=t.current)==null?void 0:m.finish(!1)},children:"Cancel"}),a.jsx(Q,{onClick:()=>{!s||t.current!==s||(window.open(s.url,"_blank","noopener,noreferrer"),s.finish(!0))},children:"Open website"})]})]})}):null,e[3]=s,e[4]=n,e[5]=u):u=e[5];const d=u;let f;return e[6]!==d?(f={openExternal:c,dialog:d},e[6]=d,e[7]=f):f=e[7],f}function $ge(n){const e=V.c(20),t=J0();let s;e[0]!==n.activation||e[1]!==n.plugin.id||e[2]!==n.plugin.selectedDigest||e[3]!==n.registryRevision?(s=JSON.stringify([n.activation,n.registryRevision,n.plugin.id,n.plugin.selectedDigest]),e[0]=n.activation,e[1]=n.plugin.id,e[2]=n.plugin.selectedDigest,e[3]=n.registryRevision,e[4]=s):s=e[4];const r=s;if(!n.activation||!n.plugin.enabled||t)return null;let o;e[5]!==n?(o=n.openSettings&&n.plugin.manifest.permissions.connections.length>0&&a.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>{var m;return(m=n.openSettings)==null?void 0:m.call(n,n.plugin.id)},children:"Connections"}),e[5]=n,e[6]=o):o=e[6];const i=`Close ${n.title??n.plugin.manifest.name}`;let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Mt,{className:"size-4"}),e[7]=l):l=e[7];let c;e[8]!==n.closePanel||e[9]!==i?(c=a.jsx(Q,{size:"icon-sm",variant:"ghost","aria-label":i,onClick:n.closePanel,children:l}),e[8]=n.closePanel,e[9]=i,e[10]=c):c=e[10];let u;e[11]!==o||e[12]!==c?(u=a.jsxs("div",{className:"flex items-center justify-end gap-1 border-b px-2 py-1",children:[o,c]}),e[11]=o,e[12]=c,e[13]=u):u=e[13];let d;e[14]!==r||e[15]!==n?(d=a.jsx("div",{className:"min-h-0 flex-1",children:a.jsx(Rge,{...n},r)}),e[14]=r,e[15]=n,e[16]=d):d=e[16];let f;return e[17]!==u||e[18]!==d?(f=a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[u,d]}),e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Rge(n){var p,h,g,x,b,w;const e=V.c(36);let t;e[0]!==n.context.projectPath||e[1]!==((p=n.project)==null?void 0:p.id)||e[2]!==((h=n.project)==null?void 0:h.name)?(t=JSON.stringify([(g=n.project)==null?void 0:g.id,(x=n.project)==null?void 0:x.name,n.context.projectPath]),e[0]=n.context.projectPath,e[1]=(b=n.project)==null?void 0:b.id,e[2]=(w=n.project)==null?void 0:w.name,e[3]=t):t=e[3];const s=t;let r;e[4]!==s||e[5]!==n.context.projectPath||e[6]!==n.project?(r={key:s,project:n.project,path:n.context.projectPath},e[4]=s,e[5]=n.context.projectPath,e[6]=n.project,e[7]=r):r=e[7];const o=r;let i;e[8]!==o?(i=[o],e[8]=o,e[9]=i):i=e[9];let l;e[10]!==s?(l=[s],e[10]=s,e[11]=l):l=e[11];let c;e[12]!==i||e[13]!==l?(c={entries:i,recent:l},e[12]=i,e[13]=l,e[14]=c):c=e[14];const[u,d]=y.useState(c);let f=u.entries;if(u.recent.at(-1)!==s){let v;if(e[15]!==u.recent||e[16]!==s){let k;e[18]!==s?(k=_=>_!==s,e[18]=s,e[19]=k):k=e[19],v=[...u.recent.filter(k),s].slice(-3),e[15]=u.recent,e[16]=s,e[17]=v}else v=e[17];const j=v;if(e[20]!==u.entries||e[21]!==o||e[22]!==s||e[23]!==j){let k;e[25]!==j?(k=N=>j.includes(N.key),e[25]=j,e[26]=k):k=e[26],f=u.entries.filter(k);let _;e[27]!==s?(_=N=>N.key===s,e[27]=s,e[28]=_):_=e[28],f.some(_)||(f=[...f,o]),e[20]=u.entries,e[21]=o,e[22]=s,e[23]=j,e[24]=f}else f=e[24];d({entries:f,recent:j})}let m;if(e[29]!==f||e[30]!==s||e[31]!==n){let v;e[33]!==s||e[34]!==n?(v=j=>a.jsx("div",{className:"h-full min-h-0",hidden:j.key!==s,children:a.jsx(Oge,{...n,epoch:j.key,project:j.project,context:{...n.context,projectPath:j.path},active:n.active&&j.key===s})},j.key),e[33]=s,e[34]=n,e[35]=v):v=e[35],m=f.map(v),e[29]=f,e[30]=s,e[31]=n,e[32]=m}else m=e[32];return m}function Oge(n){var ce,oe,fe;const e=V.c(73),{client:t,plugin:s,project:r,active:o,title:i,epoch:l,context:c}=n,u=WE(),{openExternal:d,dialog:f}=Pge(s.manifest.name),[m]=y.useState(Mge),p=y.useRef(o),h=y.useRef(c.composePrompt),g=y.useRef(c.openSession),x=y.useRef(null);let b;e[0]!==((ce=c.session)==null?void 0:ce.sessionId)||e[1]!==c.sessionChangeKey?(b=JSON.stringify([(oe=c.session)==null?void 0:oe.sessionId,c.sessionChangeKey]),e[0]=(fe=c.session)==null?void 0:fe.sessionId,e[1]=c.sessionChangeKey,e[2]=b):b=e[2];const w=b,[v,j]=y.useState(null),[k,_]=y.useState(null);let N,S;e[3]!==o?(N=()=>{var ue;p.current=o,(ue=x.current)==null||ue.setActive(o)},S=[o],e[3]=o,e[4]=N,e[5]=S):(N=e[4],S=e[5]),y.useLayoutEffect(N,S);let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{var ue;(ue=x.current)==null||ue.resetSession()},e[6]=C):C=e[6];let E;e[7]!==w?(E=[w],e[7]=w,e[8]=E):E=e[8],y.useLayoutEffect(C,E);let T,$;e[9]!==c.composePrompt?(T=()=>{h.current=c.composePrompt},$=[c.composePrompt],e[9]=c.composePrompt,e[10]=T,e[11]=$):(T=e[10],$=e[11]),y.useLayoutEffect(T,$);let A,R;e[12]!==c.openSession?(A=()=>{g.current=c.openSession},R=[c.openSession],e[12]=c.openSession,e[13]=A,e[14]=R):(A=e[13],R=e[14]),y.useLayoutEffect(A,R);const P=s.id,z=s.selectedDigest,L=(r==null?void 0:r.id)??null;let I;e[15]!==c.composePrompt||e[16]!==s.manifest.permissions.composer?(I=s.manifest.permissions.composer.includes("append")&&!!c.composePrompt,e[15]=c.composePrompt,e[16]=s.manifest.permissions.composer,e[17]=I):I=e[17];const M=I;let F;e[18]!==c.openSession||e[19]!==s.manifest.permissions.navigation?(F=s.manifest.permissions.navigation.includes("session")&&!!c.openSession,e[18]=c.openSession,e[19]=s.manifest.permissions.navigation,e[20]=F):F=e[20];const U=F,O=r?c.projectPath:null;let D;e[21]!==s.manifest.permissions.navigation?(D=s.manifest.permissions.navigation.includes("external"),e[21]=s.manifest.permissions.navigation,e[22]=D):D=e[22];const B=D,q=s.manifest.permissions.context.includes("session.identity")&&t.sessionHandle&&O?c.sessionAddress??null:null,W=(q==null?void 0:q.dirName)??null,H=(q==null?void 0:q.fileName)??null,[K,Z]=y.useState(null);let Y,J;e[23]!==t||e[24]!==W||e[25]!==H||e[26]!==v?(Y=()=>{if(!v||!W||!H)return;const ue=new AbortController;return t.sessionHandle(v.leaseId,{dirName:W,fileName:H},ue.signal).then(le=>{ue.signal.aborted||Z({leaseId:v.leaseId,dirName:W,fileName:H,handle:le})}).catch(Lge),()=>ue.abort()},J=[t,v,W,H],e[23]=t,e[24]=W,e[25]=H,e[26]=v,e[27]=Y,e[28]=J):(Y=e[27],J=e[28]),y.useEffect(Y,J);const ee=K&&v&&K.leaseId===v.leaseId&&K.dirName===W&&K.fileName===H?K.handle:null;let te;e[29]!==M||e[30]!==B||e[31]!==U||e[32]!==t||e[33]!==m||e[34]!==z||e[35]!==d||e[36]!==P||e[37]!==L||e[38]!==O?(te=()=>{const ue=UE({client:t,pluginId:P,digest:z,projectId:L,workspacePath:O,contextEpoch:m,active:p.current,...M?{appendDraft:le=>{var pe;return(pe=h.current)==null?void 0:pe.call(h,le)}}:{},...U?{openSession:(le,pe)=>{var ge;return(ge=g.current)==null?void 0:ge.call(g,le,pe)}}:{},...B?{openExternal:d}:{},onLoaded:(le,pe)=>j({payload:le,leaseId:pe,runtime:ue}),onError:le=>_(le.message)});return x.current=ue,()=>{ue.dispose(),x.current=null}},e[29]=M,e[30]=B,e[31]=U,e[32]=t,e[33]=m,e[34]=z,e[35]=d,e[36]=P,e[37]=L,e[38]=O,e[39]=te):te=e[39];let se;if(e[40]!==M||e[41]!==B||e[42]!==U||e[43]!==t||e[44]!==m||e[45]!==z||e[46]!==l||e[47]!==d||e[48]!==P||e[49]!==L||e[50]!==O?(se=[t,P,z,L,l,m,M,B,d,U,O],e[40]=M,e[41]=B,e[42]=U,e[43]=t,e[44]=m,e[45]=z,e[46]=l,e[47]=d,e[48]=P,e[49]=L,e[50]=O,e[51]=se):se=e[51],y.useLayoutEffect(te,se),k){let ue;return e[52]!==k?(ue=a.jsx("p",{role:"alert",className:"p-4 text-sm text-destructive",children:k}),e[52]=k,e[53]=ue):ue=e[53],ue}if(!v){let ue;return e[54]===Symbol.for("react.memo_cache_sentinel")?(ue=a.jsx("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:"Loading plugin…"}),e[54]=ue):ue=e[54],ue}const X=v.payload,ne=`${l}:${v.leaseId}`;let ae;e[55]!==o||e[56]!==ee||e[57]!==s.manifest||e[58]!==u||e[59]!==r?(ae=BE(s.manifest,r,o,u,ee),e[55]=o,e[56]=ee,e[57]=s.manifest,e[58]=u,e[59]=r,e[60]=ae):ae=e[60];const ie=i??s.manifest.name;let re;e[61]!==o||e[62]!==z||e[63]!==v.payload||e[64]!==v.runtime.execute||e[65]!==v.runtime.fail||e[66]!==ne||e[67]!==ae||e[68]!==ie?(re=a.jsx(FE,{payload:X,digest:z,activationKey:ne,context:ae,active:o,title:ie,execute:v.runtime.execute,onError:v.runtime.fail}),e[61]=o,e[62]=z,e[63]=v.payload,e[64]=v.runtime.execute,e[65]=v.runtime.fail,e[66]=ne,e[67]=ae,e[68]=ie,e[69]=re):re=e[69];let de;return e[70]!==f||e[71]!==re?(de=a.jsxs(a.Fragment,{children:[re,f]}),e[70]=f,e[71]=re,e[72]=de):de=e[72],de}function Lge(){}function Mge(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),zge).join("")}function zge(n){return n.toString(16).padStart(2,"0")}function Dge(n,e,t){const s=V.c(16);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r={summary:null,loading:!1,error:null},s[0]=r):r=s[0];const[o,i]=y.useState(r),[l,c]=y.useState(0);let u,d;s[1]!==n||s[2]!==e?(u=()=>{i({summary:null,loading:!!(n&&e),error:null})},d=[n,e],s[1]=n,s[2]=e,s[3]=u,s[4]=d):(u=s[3],d=s[4]),y.useEffect(u,d);let f;s[5]!==n||s[6]!==e?(f=()=>{if(!n||!e)return;const x=new AbortController;i(Uge);const b=new URLSearchParams({dirName:n,fileName:e});return Ce(`/api/usage-cost/session?${b}`,{signal:x.signal}).then(async w=>{if(!w.ok)throw new Error(`Cost scan failed (${w.status})`);const v=await w.json();i({summary:v,loading:!1,error:null})}).catch(w=>{x.signal.aborted||i(v=>({...v,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(Fge),s[13]=p):p=s[13];const h=p;let g;return s[14]!==o?(g={...o,refresh:h},s[14]=o,s[15]=g):g=s[15],g}function Fge(n){return n+1}function Uge(n){return{...n,loading:!0,error:null}}function Bge(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 Wge(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 qge(){const n=V.c(3);let e,t;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-24"}),a.jsx(Gn,{className:"h-10 w-32"}),a.jsx(Gn,{className:"h-3 w-44"})]}),t=a.jsx(Gn,{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=a.jsxs("div",{className:"flex flex-col gap-5 pt-2",role:"status","aria-label":"Reading session cost",children:[e,t,a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx(Gn,{className:"h-8 w-full"}),a.jsx(Gn,{className:"h-8 w-full"}),a.jsx(Gn,{className:"h-8 w-full"})]})]}),n[2]=s):s=n[2],s}function Vge(n){const e=V.c(10),{message:t,retry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(yf,{}),o=a.jsx(Xt,{children:"Cost unavailable"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(_t,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsxs(Q,{variant:"outline",size:"xs",onClick:s,className:"mt-2",children:[l,"Retry"]}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(kt,{variant:"destructive",className:"mt-2",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function Ku(n){const e=V.c(7),{label:t,value:s}=n;let r;e[0]!==t?(r=a.jsx("dt",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("dd",{className:"truncate text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function Hge(n){const e=V.c(22),{row:t,totalCost:s}=n,r=s>0?t.costUsd/s*100:0;let o;e[0]!==t.label?(o=a.jsx(XE,{children:t.label}),e[0]=t.label,e[1]=o):o=e[1];let i;e[2]!==t.costUsd?(i=a.jsx(JE,{children:()=>gs(t.costUsd)}),e[2]=t.costUsd,e[3]=i):i=e[3];let l;e[4]!==r||e[5]!==o||e[6]!==i?(l=a.jsxs(qc,{value:r,children:[o,i]}),e[4]=r,e[5]=o,e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.tokens?(c=t.tokens>0?vt(t.tokens):"Reported by provider",e[8]=t.tokens,e[9]=c):c=e[9];let u;e[10]!==c?(u=a.jsx("span",{children:c}),e[10]=c,e[11]=u):u=e[11];let d;e[12]!==r?(d=r>0?`${r.toFixed(1)}%`:"—",e[12]=r,e[13]=d):d=e[13];let f;e[14]!==d?(f=a.jsx("span",{children:d}),e[14]=d,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==l||e[20]!==m?(p=a.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 Kge(n){const e=V.c(8),{summary:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.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 r;if(e[1]!==t.costUsd||e[2]!==t.models){let i;e[4]!==t.costUsd?(i=l=>{const c=t.costUsd>0?l.costUsd/t.costUsd*100:0;return a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsxs(qc,{value:c,children:[a.jsx(XE,{title:l.model,children:lo(l.model)}),a.jsx(JE,{children:()=>l.costSource==="unpriced"?"Unpriced":gs(l.costUsd)})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground tabular-nums",children:[a.jsxs("span",{children:[l.records," ",l.records===1?"call":"calls"]}),a.jsxs("span",{children:[vt(Qb(l.totals))," tokens"]})]})]},l.model)},e[4]=t.costUsd,e[5]=i):i=e[5],r=t.models.map(i),e[1]=t.costUsd,e[2]=t.models,e[3]=r}else r=e[3];let o;return e[6]!==r?(o=a.jsxs("section",{"aria-labelledby":"cost-models-heading",className:"flex flex-col gap-3",children:[s,a.jsx("div",{className:"flex flex-col gap-3",children:r})]}),e[6]=r,e[7]=o):o=e[7],o}function Gge(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 Zge(n){const e=V.c(5),{rows:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.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 r;e[1]!==t?(r=t.map(Yge),e[1]=t,e[2]=r):r=e[2];let o;return e[3]!==r?(o=a.jsxs("section",{"aria-labelledby":"cost-calls-heading",className:"flex flex-col gap-2",children:[s,a.jsx("ol",{className:"flex flex-col gap-0.5",children:r})]}),e[3]=r,e[4]=o):o=e[4],o}function Yge(n){return a.jsxs("li",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-muted/50",children:[a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:["Call ",n.call," · ",lo(n.model)]}),n.isSubagent&&a.jsx(Fe,{variant:"outline",children:"Agent"}),a.jsx("span",{className:"shrink-0 font-mono text-xs text-foreground tabular-nums",children:gs(n.costUsd)})]},`${n.timestamp}:${n.call}`)}function Xge(n){const e=V.c(74),{summary:t}=n;let s;e[0]!==t.provider?(s=y5(t.provider),e[0]=t.provider,e[1]=s):s=e[1];const r=s;let o,i,l,c,u,d;if(e[2]!==r||e[3]!==t){const g=Qb(t.totals),x=Wge(t);let b;e[10]!==t.calls?(b=Gge(t.calls),e[10]=t.calls,e[11]=b):b=e[11],d=b;const w=t.providerReportedRecords+t.modelPricedRecords>0;o="flex flex-col gap-5 pt-2";let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("p",{id:"session-cost-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API equivalent"}),e[12]=v):v=e[12];let j;e[13]!==r?(j=a.jsx(r,{"aria-hidden":"true"}),e[13]=r,e[14]=j):j=e[14];let k;e[15]!==t.provider?(k=Cn(t.provider),e[15]=t.provider,e[16]=k):k=e[16];let _;e[17]!==k.displayName||e[18]!==j?(_=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,a.jsxs(Fe,{variant:"outline",children:[j,k.displayName]})]}),e[17]=k.displayName,e[18]=j,e[19]=_):_=e[19];let N;e[20]!==w||e[21]!==t.costUsd?(N=w?gs(t.costUsd):"—",e[20]=w,e[21]=t.costUsd,e[22]=N):N=e[22];let S;e[23]!==N?(S=a.jsx("span",{className:"text-4xl font-semibold tracking-tight text-foreground tabular-nums",children:N}),e[23]=N,e[24]=S):S=e[24];const C=t.unpricedRecords>0?"secondary":"outline";let E;e[25]!==t?(E=Bge(t),e[25]=t,e[26]=E):E=e[26];let T;e[27]!==C||e[28]!==E?(T=a.jsx(Fe,{variant:C,children:E}),e[27]=C,e[28]=E,e[29]=T):T=e[29];let $;e[30]!==S||e[31]!==T?($=a.jsxs("div",{className:"flex items-end justify-between gap-3",children:[S,T]}),e[30]=S,e[31]=T,e[32]=$):$=e[32];const A=t.records===1?"model call":"model calls",R=t.includedSubagents>0?` · ${t.includedSubagents} agent ${t.includedSubagents===1?"transcript":"transcripts"}`:"";let P;e[33]!==t.records||e[34]!==A||e[35]!==R?(P=a.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records," ",A,R]}),e[33]=t.records,e[34]=A,e[35]=R,e[36]=P):P=e[36],e[37]!==_||e[38]!==$||e[39]!==P?(i=a.jsxs("section",{"aria-labelledby":"session-cost-heading",className:"flex flex-col gap-2",children:[_,$,P]}),e[37]=_,e[38]=$,e[39]=P,e[40]=i):i=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(tn,{}),e[41]=l):l=e[41];const z=vt(g);let L;e[42]!==z?(L=a.jsx(Ku,{label:"Processed tokens",value:z}),e[42]=z,e[43]=L):L=e[43];let I;e[44]!==t.cacheSavingsUsd?(I=gs(t.cacheSavingsUsd),e[44]=t.cacheSavingsUsd,e[45]=I):I=e[45];let M;e[46]!==I?(M=a.jsx(Ku,{label:"Cache savings",value:I}),e[46]=I,e[47]=M):M=e[47];let F;e[48]!==t.totals.cachedInputTokens?(F=vt(t.totals.cachedInputTokens),e[48]=t.totals.cachedInputTokens,e[49]=F):F=e[49];let U;e[50]!==F?(U=a.jsx(Ku,{label:"Cached input",value:F}),e[50]=F,e[51]=U):U=e[51];let O;e[52]!==t.totals.reasoningTokens?(O=vt(t.totals.reasoningTokens),e[52]=t.totals.reasoningTokens,e[53]=O):O=e[53];let D;e[54]!==O?(D=a.jsx(Ku,{label:"Reasoning",value:O}),e[54]=O,e[55]=D):D=e[55],e[56]!==L||e[57]!==M||e[58]!==U||e[59]!==D?(c=a.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[L,M,U,D]}),e[56]=L,e[57]=M,e[58]=U,e[59]=D,e[60]=c):c=e[60],u=x.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(tn,{}),a.jsxs("section",{"aria-labelledby":"cost-breakdown-heading",className:"flex flex-col gap-3",children:[a.jsx("h3",{id:"cost-breakdown-heading",className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Cost by token type"}),a.jsx("div",{className:"flex flex-col gap-4",children:x.map(B=>a.jsx(Hge,{row:B,totalCost:t.costUsd},B.label))})]})]}),e[2]=r,e[3]=t,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u,e[9]=d}else o=e[4],i=e[5],l=e[6],c=e[7],u=e[8],d=e[9];let f;e[61]!==t?(f=t.models.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(tn,{}),a.jsx(Kge,{summary:t})]}),e[61]=t,e[62]=f):f=e[62];let m;e[63]!==d?(m=d.length>=2&&a.jsxs(a.Fragment,{children:[a.jsx(tn,{}),a.jsx(Zge,{rows:d})]}),e[63]=d,e[64]=m):m=e[64];let p;e[65]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsxs(kt,{children:[a.jsx(yf,{}),a.jsx(Xt,{children:"How this is calculated"}),a.jsx(_t,{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]!==o||e[67]!==i||e[68]!==l||e[69]!==c||e[70]!==u||e[71]!==f||e[72]!==m?(h=a.jsxs("div",{className:o,children:[i,l,c,u,f,m,p]}),e[66]=o,e[67]=i,e[68]=l,e[69]=c,e[70]=u,e[71]=f,e[72]=m,e[73]=h):h=e[73],h}function Jge(n){const e=V.c(7),{dirName:t,fileName:s,revision:r}=n,{summary:o,loading:i,error:l,refresh:c}=Dge(t,s,r);if(l){let d;return e[0]!==l||e[1]!==c?(d=a.jsx(Vge,{message:l,retry:c}),e[0]=l,e[1]=c,e[2]=d):d=e[2],d}if(!o){if(i){let f;return e[3]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(qge,{}),e[3]=f):f=e[3],f}let d;return e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(Ln,{className:"mt-2 min-h-52",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx($8,{})}),a.jsx(zn,{children:"No transcript cost yet"}),a.jsx(Dn,{children:"Cost appears after the first model response is written."})]})}),e[4]=d):d=e[4],d}let u;return e[5]!==o?(u=a.jsx(Xge,{summary:o}),e[5]=o,e[6]=u):u=e[6],u}function Qge(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 e1e(n){const e=V.c(14),{turns:t,onJumpToTurn:s}=n;let r;e[0]!==t?(r=Qge(t),e[0]=t,e[1]=r):r=e[1];const o=r;if(o.length===0)return null;let i;e[2]!==o.length?(i=a.jsxs(Hc,{children:["Errors (",o.length,")"]}),e[2]=o.length,e[3]=i):i=e[3];let l;if(e[4]!==o||e[5]!==s){let d;e[7]!==s?(d=(f,m)=>a.jsxs(Q,{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:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"font-medium text-destructive",children:f.toolName}),a.jsxs("span",{className:"text-muted-foreground",children:["Turn ",f.turnIndex+1]})]}),a.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]=d):d=e[8],l=o.map(d),e[4]=o,e[5]=s,e[6]=l}else l=e[6];let c;e[9]!==l?(c=a.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 u;return e[11]!==i||e[12]!==c?(u=a.jsxs("section",{children:[i,c]}),e[11]=i,e[12]=c,e[13]=u):u=e[13],u}function kj(n){const e=V.c(44),{agentId:t,subagentType:s,agentName:r,preview:o,isViewing:i,isBackground:l,status:c,durationMs:u,toolUseCount:d,depth:f,disabled:m,onClick:p,onStop:h}=n,g=f===void 0?0:f;let x;e[0]!==t||e[1]!==r||e[2]!==s?(x=r||Bb(t,s),e[0]=t,e[1]=r,e[2]=s,e[3]=x):x=e[3];const b=x;let w;e[4]!==u?(w=u==null?null:u<1e3?`${u}ms`:`${(u/1e3).toFixed(u>=1e4?0:1)}s`,e[4]=u,e[5]=w):w=e[5];const v=w;let j;e[6]!==c?(j=c==="running"?a.jsx(St,{className:"size-3 shrink-0 animate-spin text-success","data-icon":"inline-start"}):c==="done"?a.jsx(Pr,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}):c==="failed"?a.jsx(Bo,{className:"size-3 shrink-0 text-destructive","data-icon":"inline-start"}):a.jsx(px,{className:"size-2.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),e[6]=c,e[7]=j):j=e[7];const k=j,_=g===1&&"pl-4",N=g>=2&&"pl-8",S=i?"bg-accent":"hover:bg-muted/40";let C;e[8]!==_||e[9]!==N||e[10]!==S?(C=G("motion-list-item flex w-full items-start border-b border-border text-left transition-colors last:border-b-0",_,N,S),e[8]=_,e[9]=N,e[10]=S,e[11]=C):C=e[11];let E;e[12]!==b?(E=a.jsx(Fe,{variant:"outline",children:b}),e[12]=b,e[13]=E):E=e[13];let T;e[14]!==l?(T=l&&a.jsx(Fe,{variant:"outline",children:"Background"}),e[14]=l,e[15]=T):T=e[15];let $;e[16]!==i?($=i&&a.jsx(Fe,{children:"Viewing"}),e[16]=i,e[17]=$):$=e[17];const A=c==="running"?"active":c;let R;e[18]!==A?(R=a.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-muted-foreground",children:A}),e[18]=A,e[19]=R):R=e[19];let P;e[20]!==k||e[21]!==T||e[22]!==$||e[23]!==R||e[24]!==E?(P=a.jsxs("div",{className:"flex items-center gap-1.5",children:[k,E,T,$,R]}),e[20]=k,e[21]=T,e[22]=$,e[23]=R,e[24]=E,e[25]=P):P=e[25];let z;e[26]!==o?(z=o&&a.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground",children:o}),e[26]=o,e[27]=z):z=e[27];let L;e[28]!==v||e[29]!==d?(L=(v||d!=null)&&a.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[v&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(kd,{className:"size-2.5","data-icon":"inline-start"}),v]}),d!=null&&a.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[a.jsx(Sf,{className:"size-2.5","data-icon":"inline-start"}),d," tools"]})]}),e[28]=v,e[29]=d,e[30]=L):L=e[30];let I;e[31]!==m||e[32]!==p||e[33]!==P||e[34]!==z||e[35]!==L?(I=a.jsxs(Q,{type:"button",variant:"ghost",onClick:p,disabled:m,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,z,L]}),e[31]=m,e[32]=p,e[33]=P,e[34]=z,e[35]=L,e[36]=I):I=e[36];let M;e[37]!==b||e[38]!==h?(M=h&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",className:"m-1",onClick:h,"aria-label":`Stop ${b}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[37]=b,e[38]=h,e[39]=M):M=e[39];let F;return e[40]!==I||e[41]!==M||e[42]!==C?(F=a.jsxs("div",{className:C,children:[I,M]}),e[40]=I,e[41]=M,e[42]=C,e[43]=F):F=e[43],F}function t1e(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 U1(n){return n.split(`
|
|
@@ -466,20 +466,20 @@ Passphrase: ${m}`),children:w?"Copied":"Copy link & passphrase"}):a.jsx("p",{cla
|
|
|
466
466
|
`&&(t+=l),o++;continue}}if(i===s){s="";continue}if(!s&&(i==="'"||i==='"')){s=i;continue}if(s!=="'"){if(i==="`"||i==="$"&&/[('"{]/.test(l??""))return null;(i==="$"||!s&&/[*?[{}~]/.test(i))&&(r=!1)}t+=i}return s?null:{value:t,start:e,end:o,literal:r}}function y1e(n){const e=[];let t=[],s=0,r=0;const o=()=>({commands:[...e,{words:t,end:n.length,pipeline:s}],complete:!1});for(let i=0;i<n.length;){const l=n[i];if(l==="\\"&&n[i+1]===`
|
|
467
467
|
`){i+=2;continue}if(l==="#"){const d=n.indexOf(`
|
|
468
468
|
`,i);e.push({words:t,end:i,pipeline:s}),t.length>0&&r===0&&s++,t=[],i=d<0?n.length:d;continue}if(/[^\S\n]/.test(l)){i++;continue}if(/[;&|()\n]/.test(l)){const d=n[i+1],f=l==="|"&&d!=="|";if(l==="("&&r++,l===")"&&r--,r<0)return o();e.push({words:t,end:i,pipeline:s}),r===0&&!f&&l!=="("&&l!==")"&&(l!==`
|
|
469
|
-
`||t.length>0)&&s++,t=[],i+=(l==="&"||l==="|")&&(d===l||f&&d==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(i)))return o();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(i));if(c){for(i+=c[0].length;/[^\S\n]/.test(n[i]??"");)i++;const d=jj(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=jj(n,i);if(!u||u.end===i)return o();t.push(u),i=u.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:r===0}}const yl="agent-browser",w1e=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),S1e=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),k1e=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),j1e=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,N1e=/^[A-Za-z_][A-Za-z_\d]*=/;function KI(n){return n.slice(n.lastIndexOf("/")+1)}function C1e(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(N1e.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||j1e.test(o.value))return null;const i=KI(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=w1e.get(i);if(!l)return t;for(t++;(r=n[t])!=null&&r.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function _1e(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=h1e,i=null;for(let l=0;l<r.length;l++){const c=r[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(i!==null)return null;const u=c.value==="--session"?r[++l]:c;if(o=c.value==="--session"?u==null?void 0:u.value:c.value.slice(10),!o||!b1e(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:yl+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function E1e(n){var l;const{commands:e,complete:t}=y1e(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(yl)));if(!t)return{invocations:s,ambiguous:r||n.includes(yl)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(yl))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=C1e(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=KI(c[f].value);if(m!==yl){!(S1e.has(m)||m==="git"&&k1e.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=_1e(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function T1e(n){return E1e(n).invocations}const Nj=120,A1e=/(?:^|[._])exec_command$/;function I1e(n){return n==="Bash"||A1e.test(n)}function P1e(n){return Use(n).filter(e=>I1e(e.name)).map(e=>ro(e.input))}function $1e(n){for(const e of P1e(n)){const[t]=T1e(e);if(t===void 0||v1e(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>Nj?`${s.slice(0,Nj-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function R1e(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 r=s.length-1;r>=0;r--){const o=$1e(s[r]);if(o)return o}}return null}const Cj=1e4,O1e=y.lazy(()=>nt(()=>import("./ProjectFilesPanel-CPHWyVwU.js"),__vite__mapDeps([32,1,33,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),L1e=y.lazy(()=>nt(()=>import("./WorktreePanel-ASvzuwqm.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),M1e=y.lazy(()=>nt(()=>import("./CrewPanel-DvHboAAW.js"),__vite__mapDeps([35,1,28,2,3,4])).then(n=>({default:n.CrewPanel}))),z1e=y.lazy(()=>nt(()=>import("./index-D262IRnL.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function Am(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(Pn,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function D1e(n){const e=V.c(6),{context:t,closePanel:s}=n,r=ev(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Am,{}),e[0]=i):i=e[0];let l;return e[1]!==s||e[2]!==o||e[3]!==r.addProjectContext||e[4]!==r.projectFilesRequest?(l=a.jsx(y.Suspense,{fallback:i,children:a.jsx(O1e,{cwd:o,onClose:s,onAddToPrompt:r.addProjectContext,openRequest:r.projectFilesRequest},o)}),e[1]=s,e[2]=o,e[3]=r.addProjectContext,e[4]=r.projectFilesRequest,e[5]=l):l=e[5],l}function F1e(n){const e=V.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=a.jsx(cfe,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function U1e(){const n=V.c(7),e=ev();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=a.jsx(p1e,{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 B1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(z1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function W1e(n){var u;const e=V.c(8),{context:t}=n,[,s]=y.useState(0);let r;e[0]!==t.session?(r=Date.parse(((u=R1e(t.session))==null?void 0:u.timestamp)??""),e[0]=t.session,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==s?(i=()=>{const d=o+Cj-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(q1e),d);return()=>clearTimeout(f)},e[2]=o,e[3]=s,e[4]=i):i=e[4];let l;if(e[5]!==o?(l=[o],e[5]=o,e[6]=l):l=e[6],y.useEffect(i,l),Number.isNaN(o)||Date.now()-o>=Cj)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.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"}),e[7]=c):c=e[7],c}function q1e(n){return n+1}function V1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(M1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function H1e(n){const e=V.c(5),{context:t}=n,s=t.crew;if(!s)return null;if(s.needsYou>0){const i=`${s.needsYou} ${s.needsYou===1?"session needs":"sessions need"} you`;let l;return e[0]!==s.needsYou||e[1]!==i?(l=a.jsx("span",{role:"status","aria-label":i,className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-warning px-1 text-[9px] font-semibold text-warning-foreground",children:s.needsYou}),e[0]=s.needsYou,e[1]=i,e[2]=l):l=e[2],l}if(s.working===0)return null;const r=`${s.working} ${s.working===1?"session":"sessions"} working`;let o;return e[3]!==r?(o=a.jsx("span",{role:"status","aria-label":r,className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-success ring-2 ring-success/30"}),e[3]=r,e[4]=o):o=e[4],o}function K1e(n){const e=V.c(8),{closePanel:t}=n,s=ev();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Am,{}),e[0]=r):r=e[0];let o;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?(o=a.jsx(y.Suspense,{fallback:r,children:a.jsx(L1e,{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]=o):o=e[7],o}const G1e={id:ii,workspacePanels:[{id:"crew",title:"Crew",icon:rx,component:V1e,indicator:H1e,order:1,defaultSize:"30%",minSize:"340px",maxSize:"60%",when:n=>!!n.crew},{id:"worktrees",title:"Worktrees",icon:Zr,component:K1e,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:R8,component:D1e,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:sa,component:B1e,indicator:W1e,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canUseBrowser},{id:"file-changes",title:"File changes",icon:yc,component:F1e,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:O8,component:U1e,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},Z1e=cpe([G1e]),_j={"cogpit.github":b4,"cogpit.clickup":z8,"cogpit.vercel":M8,"cogpit.cloudflare":L8};function Y1e(n){const e=V.c(6);let t,s;e[0]!==n?({runtime:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;return e[3]!==t||e[4]!==s?(r=s?a.jsx($ge,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function X1e(n){var o;const e=V.c(3),{runtime:t,context:s}=n;let r;return e[0]!==s||e[1]!==t?(r=t?a.jsx(Ige,{client:t.client,pluginId:t.plugin.id,projectId:((o=t.project)==null?void 0:o.id)??null,workspacePath:t.project?s.projectPath:null,activation:t.activation,registryRevision:t.registryRevision}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function J1e({client:n,status:e,activation:t,project:s,legacyPanels:r=Z1e,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||VE())return i;const l=new Set(i.map(u=>u.id)),c=vo();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&T0(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=bo(u.id,d.id);if(l.has(f)||d.when==="project-selected"&&!s)continue;l.add(f);const m={client:n,plugin:u,activation:t,registryRevision:e.store.revision,project:s,title:d.title,openSettings:o};i.push({id:f,pluginId:u.id,localId:d.id,title:d.title,icon:_j[u.id]??vx,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,..._j[u.id]?{indicator:X1e,indicatorProps:{runtime:m}}:{},component:Y1e,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function GI(n){const e=V.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=J0();let c;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==s?(c={client:t,status:s,activation:r,projectPath:o},e[0]=r,e[1]=t,e[2]=o,e[3]=s,e[4]=c):c=e[4];const{project:u,resolving:d}=qE(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=J1e({client:t,status:s,activation:f,project:u,openSettings:i}),e[5]=t,e[6]=i,e[7]=u,e[8]=s,e[9]=f,e[10]=m):m=e[10],m}function Im(n){const e=V.c(7),{floating:t,children:s}=n,r=y.useRef(null);let o,i;if(e[0]!==t?(o=()=>{const c=r.current,u=c==null?void 0:c.parentElement;if(!t||!c||!u)return;const d=u.style.getPropertyValue("--session-footer-height"),f=()=>u.style.setProperty("--session-footer-height",`${c.getBoundingClientRect().height}px`);f();const m=new ResizeObserver(f);return m.observe(c),()=>{m.disconnect(),d?u.style.setProperty("--session-footer-height",d):u.style.removeProperty("--session-footer-height")}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useLayoutEffect(o,i),t){let c;return e[3]!==s?(c=a.jsx("div",{ref:r,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-canvas via-canvas/70 to-transparent pt-4",children:a.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[3]=s,e[4]=c):c=e[4],c}let l;return e[5]!==s?(l=a.jsx("div",{className:"flex w-full shrink-0 justify-center",children:a.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[5]=s,e[6]=l):l=e[6],l}function wa(n){const e=V.c(13),{projectPath:t,fallback:s,className:r}=n,[o,i]=y.useState(null);if(!t||o===t){let m;return e[0]!==s?(m=a.jsx(a.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=Af(l),e[2]=l,e[3]=c):c=e[3];let u;e[4]!==t?(u=()=>i(t),e[4]=t,e[5]=u):u=e[5];let d;e[6]!==r?(d=G("size-3.5 shrink-0 rounded-[3px] object-contain",r),e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==u||e[11]!==d?(f=a.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:u,className:d},t),e[8]=t,e[9]=c,e[10]=u,e[11]=d,e[12]=f):f=e[12],f}function ZI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function YI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("ol",{"data-slot":"breadcrumb-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function W1(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("li",{"data-slot":"breadcrumb-item",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function XI(n){const e=V.c(10);let t,s,r,o;if(e[0]!==n){const{className:c,render:u,...d}=n;t=u,o=h4,s="a",r=p4({className:G("transition-colors hover:text-foreground",c)},d),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o}else t=e[1],s=e[2],r=e[3],o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={slot:"breadcrumb-link"},e[5]=i):i=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==r?(l={defaultTagName:s,props:r,render:t,state:i},e[6]=t,e[7]=s,e[8]=r,e[9]=l):l=e[9],o(l)}function JI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("font-normal text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function QI(n){const e=V.c(12);let t,s,r;e[0]!==n?({children:t,className:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(it,{}),e[6]=t,e[7]=i):i=e[7];let l;return e[8]!==r||e[9]!==o||e[10]!==i?(l=a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:o,...r,children:i}),e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const Q1e=1e3,exe=255;function txe(n){for(const e of n){const t=e.codePointAt(0)??0;if(t<32||t===127)return!0}return!1}function nxe(n){return n.trim()===""?"Enter a folder name":n!==n.trim()?"A folder name cannot start or end with a space":n==="."||n===".."?`"${n}" is not a folder name`:n.includes("/")||n.includes("\\")?"A folder name cannot contain / or \\":txe(n)?"A folder name cannot contain control characters":new TextEncoder().encode(n).length>exe?"That folder name is too long":null}function Ej(n,e){return n instanceof Error&&n.message?n.message:e}function sxe({hostName:n,projectPaths:e,onStart:t,onBack:s}){var D;const[r,o]=y.useState({path:null,request:0}),i=`${r.request}:${r.path??""}`,[l,c]=y.useState(null),[u,d]=y.useState(""),[f,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,j]=y.useState(!1),k=y.useRef(null),_=y.useRef(null),N=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>{const B=new AbortController;return npe(r.path,B.signal).then(q=>c({request:i,listing:q})).catch(q=>{B.signal.aborted||c({request:i,error:Ej(q,"This folder could not be read")})}),()=>B.abort()},[i,r.path]);const C=(l==null?void 0:l.request)!==i,E=l&&"listing"in l?l.listing:null,T=!C&&l&&"error"in l?l.error:null,$=C?null:(E==null?void 0:E.path)??null,A=u.trim().toLowerCase(),R=(E==null?void 0:E.folders.filter(B=>B.name.toLowerCase().includes(A)))??[],P=R.some(B=>B.path===f)?f:((D=R[0])==null?void 0:D.path)??"",z=E==null?void 0:E.path;y.useEffect(()=>{var q,W;const B=N.current;B&&(B.scrollLeft=B.scrollWidth),S.current&&!((q=k.current)!=null&&q.contains(document.activeElement))&&((W=_.current)==null||W.focus()),S.current=!1},[z]);function L(B){var q;S.current=((q=k.current)==null?void 0:q.contains(document.activeElement))??!1,o(W=>({path:B,request:W.request+1})),d(""),h(!1),x(""),w(null)}function I(){$&&t($)}function M(B){B.key==="Enter"&&(B.metaKey||B.ctrlKey)&&!p?(B.preventDefault(),I()):B.key==="Backspace"&&B.target===_.current&&u===""&&(E!=null&&E.parent)&&!C&&(B.preventDefault(),L(E.parent))}function F(){var B;h(!1),x(""),w(null),(B=_.current)==null||B.focus()}async function U(B){var H;B.preventDefault();const q=g.trim(),W=nxe(q);if(W){w(W);return}if(!(!$||v)){j(!0);try{const K=await spe($,q);L(K),(H=_.current)==null||H.focus()}catch(K){w(Ej(K,"The folder could not be made"))}finally{j(!1)}}}const O=n?`Folders on ${n}`:"Folders";return a.jsxs("div",{ref:k,onKeyDownCapture:M,className:"flex min-h-0 flex-col bg-popover text-popover-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 in-data-[slot=dialog-content]:pr-12",children:[a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Back to projects",children:a.jsx(yx,{})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:O}),E&&E.path!==E.root&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>L(null),"aria-label":"Go to the projects root",title:E.root,children:a.jsx(D8,{})})]}),E&&a.jsx(rxe,{path:E.path,top:E.confined?E.root:null,listRef:N,onOpen:L}),a.jsxs(Ic,{shouldFilter:!1,label:"Filter folders",value:P,onValueChange:m,className:"rounded-none p-0",children:[a.jsx(a0,{ref:_,autoFocus:!0,placeholder:"Filter folders...",value:u,onValueChange:d}),a.jsx(Pc,{className:"box-content max-h-72 p-1","aria-busy":C,children:T!==null?a.jsx(oxe,{message:T,onRetry:()=>L(r.path),onRoot:r.path===null?void 0:()=>L(null)}):E===null?a.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"}),"Loading folders…"]}):R.length===0?a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Yr,{})}),a.jsx(zn,{children:A?"No folder matches":"No folders here"}),a.jsx(Dn,{children:A?"Try another name.":"Start a session right here, or make a new folder."})]})}):a.jsxs(xi,{className:G("p-0 transition-opacity",C&&"opacity-50"),children:[R.map(B=>a.jsxs(To,{value:B.path,onSelect:()=>L(B.path),onMouseDown:q=>q.preventDefault(),className:"motion-list-item h-auto gap-3 px-3 py-2",children:[a.jsx(ra,{className:"size-4 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:B.name}),e.has(B.path)&&a.jsx(Fe,{variant:"secondary",children:"Project"}),a.jsx(it,{className:"size-4 shrink-0 text-muted-foreground"})]},B.path)),E.truncated&&a.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Q1e.toLocaleString()," folders."]})]})})]}),a.jsxs("div",{className:"flex flex-col gap-1.5 border-t p-2",children:[p?a.jsxs("form",{onSubmit:B=>void U(B),className:"flex items-center gap-2",children:[a.jsx(On,{autoFocus:!0,"aria-label":"New folder name",placeholder:"New folder name",value:g,disabled:v,"aria-invalid":b?!0:void 0,onChange:B=>{x(B.target.value),w(null)},onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),F())}}),a.jsxs(Q,{type:"submit",size:"sm",disabled:v||!$||g.trim()==="",children:[v&&a.jsx(Pn,{"data-icon":"inline-start",className:"size-4"}),"Create"]}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:F,children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",disabled:!$,onClick:()=>h(!0),children:[a.jsx(V4,{"data-icon":"inline-start"}),"New folder"]}),a.jsx(Q,{type:"button",size:"sm",className:"ml-auto",disabled:!$,onClick:I,"aria-keyshortcuts":"Meta+Enter Control+Enter",children:"Start session here"})]}),b&&a.jsx("p",{role:"alert",className:"px-1 text-xs text-destructive",children:b})]})]})}function rxe(n){const e=V.c(19),{path:t,top:s,listRef:r,onOpen:o}=n;let i,l,c,u,d,f;if(e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==s){const h=rpe(t,s);l=ZI,f="border-b px-3 py-1.5",i=YI,c=r,u="no-scrollbar flex-nowrap gap-1 overflow-x-auto text-xs",d=h.map((g,x)=>a.jsxs(y.Fragment,{children:[x>0&&a.jsx(QI,{}),a.jsx(W1,{className:"shrink-0",children:x===h.length-1?a.jsx(JI,{children:g.label}):a.jsx(XI,{render:a.jsx("button",{type:"button",onClick:()=>o(g.path)}),children:g.label})})]},g.path)),e[0]=r,e[1]=o,e[2]=t,e[3]=s,e[4]=i,e[5]=l,e[6]=c,e[7]=u,e[8]=d,e[9]=f}else i=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9];let m;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==d?(m=a.jsx(i,{ref:c,className:u,children:d}),e[10]=i,e[11]=c,e[12]=u,e[13]=d,e[14]=m):m=e[14];let p;return e[15]!==l||e[16]!==f||e[17]!==m?(p=a.jsx(l,{className:f,children:m}),e[15]=l,e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function oxe(n){const e=V.c(14),{message:t,onRetry:s,onRoot:r}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Yn,{variant:"icon",children:a.jsx(Sr,{})}),i=a.jsx(zn,{children:"This folder could not be opened"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let l;e[2]!==t?(l=a.jsxs(Mn,{children:[o,i,a.jsx(Dn,{children:t})]}),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==s?(c=a.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Try again"}),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r?(u=r&&a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Go to the projects root"}),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs("div",{className:"flex gap-2",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=a.jsxs(Ln,{className:"border-0 py-8",children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function ixe(){const n=V.c(7),e=Nn("manageDevices");let t;n[0]!==e?(t={enabled:e},n[0]=e,n[1]=t):t=n[1];const{activeDevice:s}=Si(t);let r;n[2]!==s?(r=!s&&Ef(),n[2]=s,n[3]=r):r=n[3];const o=r,[i,l]=y.useState(null);let c,u;return n[4]!==o?(c=()=>{if(!o)return;const d=new AbortController;return Ce("/api/hello",{signal:d.signal}).then(zs).then(f=>{typeof(f==null?void 0:f.name)=="string"&&f.name&&l(f.name)}).catch(axe),()=>d.abort()},u=[o],n[4]=o,n[5]=c,n[6]=u):(c=n[5],u=n[6]),y.useEffect(c,u),(s==null?void 0:s.name)??(o?i:null)}function axe(){}function Tj(n){return n.replace(/[\\/]+$/,"")||n}function e7(n){const e=n.map(s=>({...s,worktrees:[]})),t=new Map;for(const s of e){const r=Tj(s.path);!Cr(s.path)&&!t.has(r)&&t.set(r,s)}return e.filter((s,r)=>{const o=Cr(s.path),i=o&&t.get(Tj(o.parentPath));return i?(i.worktrees.push(n[r]),!1):!0})}const q1=HN("project-custom-names"),lxe=q1.rename;function nv(){const n=V.c(2),e=y.useSyncExternalStore(q1.subscribe,q1.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:lxe},n[0]=e,n[1]=t):t=n[1],t}const Aj="browse-folders";function wl(n){return n.replace(/[\\/]+$/,"")||n}function cxe(n){const e=V.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=y.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n)return;const l=new AbortController;return Ce("/api/projects",{signal:l.signal}).then(uxe).then(r).catch(()=>{l.signal.aborted||r([])}),()=>l.abort()},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),y.useEffect(o,i),s}async function uxe(n){return n.ok?await n.json():[]}function dxe(n){var B;const e=V.c(58),{projects:t,onNewSession:s,onNewFolder:r,defaultAgentKind:o,currentPath:i,initialView:l,children:c}=n,u=l===void 0?"projects":l,[d,f]=y.useState(u),[m,p]=y.useState(""),[h,g]=y.useState(null),{names:x}=nv(),b=ixe();let w;if(e[0]!==m||e[1]!==x||e[2]!==t){e:{const q=e7(t);if(!m){w=q;break e}const W=m.toLowerCase();w=q.filter(H=>{var K;return H.path.toLowerCase().includes(W)||H.shortName.toLowerCase().includes(W)||H.dirName.toLowerCase().includes(W)||((K=x[H.dirName])==null?void 0:K.toLowerCase().includes(W))})}e[0]=m,e[1]=x,e[2]=t,e[3]=w}else w=e[3];const v=w;let j,k;e[4]!==m||e[5]!==t?(j=m.trim(),k=(j.startsWith("/")||/^[a-z]:[\\/]/i.test(j)||j.startsWith("\\\\"))&&!t.some(W=>wl(W.path)===wl(j)),e[4]=m,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]);const _=k;let N;e[8]!==i?(N=i?wl(((B=Cr(i))==null?void 0:B.parentPath)??i):null,e[8]=i,e[9]=N):N=e[9];const S=N;let C;e[10]!==_||e[11]!==j?(C=_?[`folder:${j}`]:[],e[10]=_,e[11]=j,e[12]=C):C=e[12];let E;e[13]!==v||e[14]!==C?(E=[...C,...v.map(mxe),Aj],e[13]=v,e[14]=C,e[15]=E):E=e[15];const T=E,$=h!==null&&T.includes(h)?h:T[0];if(d==="folders"){let q;e[16]!==t?(q=new Set(t.map(fxe)),e[16]=t,e[17]=q):q=e[17];let W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=()=>f("projects"),e[18]=W):W=e[18];let H;return e[19]!==b||e[20]!==r||e[21]!==q?(H=a.jsx(sxe,{hostName:b,projectPaths:q,onStart:r,onBack:W}),e[19]=b,e[20]=r,e[21]=q,e[22]=H):H=e[22],H}let A;e[23]!==m?(A=a.jsx(a0,{autoFocus:!0,placeholder:"Search projects, paste a folder path, or browse",value:m,onValueChange:p}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==_||e[26]!==v.length?(R=v.length===0&&!_&&a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Yr,{})}),a.jsx(zn,{children:"No projects found"}),a.jsx(Dn,{children:"Try another name, paste an absolute path, or browse the folders."})]})}),e[25]=_,e[26]=v.length,e[27]=R):R=e[27];let P;e[28]!==_||e[29]!==o||e[30]!==j||e[31]!==r?(P=_&&a.jsxs(To,{value:`folder:${j}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>r(j),children:[a.jsx(V4,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),a.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[j," · ",NM(o)]})]})]}),e[28]=_,e[29]=o,e[30]=j,e[31]=r,e[32]=P):P=e[32];let z;if(e[33]!==S||e[34]!==v||e[35]!==s||e[36]!==x){let q;e[38]!==S||e[39]!==s||e[40]!==x?(q=W=>{const H=x[W.dirName],K=jc(W.path);return a.jsxs(To,{value:`project:${W.dirName}`,"data-checked":S!==null&&wl(W.path)===S,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>s(W.dirName,W.path),children:[a.jsx(wa,{projectPath:W.path,fallback:a.jsx(Yr,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-medium",children:H||K}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[H&&a.jsx("span",{className:"mr-1.5",children:K}),W.sessionCount," session",W.sessionCount!==1?"s":"",W.lastModified&&a.jsxs(a.Fragment,{children:[" · ",new Date(W.lastModified).toLocaleDateString()]})]})]})]},W.dirName)},e[38]=S,e[39]=s,e[40]=x,e[41]=q):q=e[41],z=v.map(q),e[33]=S,e[34]=v,e[35]=s,e[36]=x,e[37]=z}else z=e[37];let L;e[42]!==z||e[43]!==P?(L=a.jsxs(xi,{className:"p-0",children:[P,z]}),e[42]=z,e[43]=P,e[44]=L):L=e[44];let I,M;e[45]===Symbol.for("react.memo_cache_sentinel")?(I=()=>f("folders"),M=a.jsx(wc,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),e[45]=I,e[46]=M):(I=e[45],M=e[46]);const F=b?`Browse folders on ${b}…`:"Browse folders…";let U;e[47]!==F?(U=a.jsx(xi,{className:"sticky -bottom-1 border-t bg-popover p-0 py-1",children:a.jsxs(To,{value:Aj,className:"h-auto gap-3 px-3 py-2.5",onSelect:I,children:[M,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:F})]})}),e[47]=F,e[48]=U):U=e[48];let O;e[49]!==L||e[50]!==U||e[51]!==R?(O=a.jsxs(Pc,{className:"box-content max-h-80 p-1",children:[R,L,U]}),e[49]=L,e[50]=U,e[51]=R,e[52]=O):O=e[52];let D;return e[53]!==c||e[54]!==$||e[55]!==O||e[56]!==A?(D=a.jsxs(Ic,{shouldFilter:!1,value:$,onValueChange:g,className:"rounded-none p-0",children:[A,O,c]}),e[53]=c,e[54]=$,e[55]=O,e[56]=A,e[57]=D):D=e[57],D}function fxe(n){return wl(n.path)}function mxe(n){return`project:${n.dirName}`}function t7(n){const e=V.c(13),{projectPath:t,switcher:s}=n;let r;e[0]!==t?(r=t?Er(t):null,e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==t||e[4]!==s?(i=o?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx(pxe,{name:o,projectPath:t,switcher:s}),"?"]}):"What should we build?",e[2]=o,e[3]=t,e[4]=s,e[5]=i):i=e[5];let l;e[6]!==i?(l=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t?(c=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:jc(t)}),e[8]=t,e[9]=c):c=e[9];let u;return e[10]!==l||e[11]!==c?(u=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[l,c]}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function pxe(n){const e=V.c(24),{name:t,projectPath:s,switcher:r}=n,{onNewSession:o,onNewFolder:i,defaultAgentKind:l}=r,[c,u]=y.useState(!1),d=cxe(c);let f;e[0]!==s?(f=a.jsx(wa,{projectPath:s,fallback:null,className:"size-5"}),e[0]=s,e[1]=f):f=e[1];let m;e[2]!==t?(m=a.jsx("span",{className:"truncate underline decoration-dotted decoration-muted-foreground/50 underline-offset-[6px] transition-colors group-hover/project:decoration-foreground/70 group-data-popup-open/project:decoration-foreground/70",children:t}),e[2]=t,e[3]=m):m=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Ea,{className:"size-4 shrink-0 text-muted-foreground transition-colors group-hover/project:text-foreground group-data-popup-open/project:text-foreground","aria-hidden":"true"}),e[4]=p):p=e[4];let h;e[5]!==f||e[6]!==m?(h=a.jsxs(Tc,{title:"Switch project",className:"group/project -mx-1 inline-flex max-w-full items-center gap-1.5 rounded-lg px-1.5 align-baseline outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[f,m,p]}),e[5]=f,e[6]=m,e[7]=h):h=e[7];let g;e[8]!==o?(g=(k,_)=>{u(!1),o(k,_)},e[8]=o,e[9]=g):g=e[9];let x;e[10]!==i?(x=k=>{u(!1),i(k)},e[10]=i,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{children:"Switch where this session starts"}),e[12]=b):b=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-[11px] text-muted-foreground",children:[b,a.jsx("kbd",{className:"font-mono",children:ea("newSession")})]}),e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==s||e[16]!==d||e[17]!==g||e[18]!==x?(v=a.jsx(Xx,{align:"center",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(dxe,{projects:d,currentPath:s,defaultAgentKind:l,onNewSession:g,onNewFolder:x,children:w})}),e[14]=l,e[15]=s,e[16]=d,e[17]=g,e[18]=x,e[19]=v):v=e[19];let j;return e[20]!==c||e[21]!==v||e[22]!==h?(j=a.jsxs(Ec,{open:c,onOpenChange:u,children:[h,v]}),e[20]=c,e[21]=v,e[22]=h,e[23]=j):j=e[23],j}function sv(n){const e=V.c(56),{children:t,sessionLabel:s,customName:r,onDuplicate:o,onDelete:i,onRename:l,onArchive:c,onUnarchive:u,archiveDisabled:d}=n,f=d===void 0?!1:d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),[x,b]=y.useState(""),w=y.useRef(null);let v;e[0]!==r?(v=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=w.current)==null?void 0:H.select()})},e[0]=r,e[1]=v):v=e[1];const j=v;let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("div",{className:"w-full"}),e[2]=k):k=e[2];let _;e[3]!==t?(_=a.jsx(Cm,{render:k,children:t}),e[3]=t,e[4]=_):_=e[4];let N;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==j?(N=(l||o||c||u)&&a.jsxs(fi,{children:[l&&a.jsxs(Rn,{onClick:j,children:[a.jsx(wr,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs(Rn,{onClick:o,children:[a.jsx(Es,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs(Rn,{onClick:u,children:[a.jsx(Cf,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs(Rn,{onClick:c,disabled:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=o,e[8]=l,e[9]=u,e[10]=j,e[11]=N):N=e[11];let S;e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==u?(S=i&&a.jsxs(a.Fragment,{children:[(o||l||c||u)&&a.jsx(va,{}),a.jsx(fi,{children:a.jsxs(Rn,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(kf,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==N||e[19]!==S?(C=a.jsxs(_m,{className:"min-w-44",children:[N,S]}),e[18]=N,e[19]=S,e[20]=C):C=e[20];let E;e[21]!==_||e[22]!==C?(E=a.jsxs(Nm,{children:[_,C]}),e[21]=_,e[22]=C,e[23]=E):E=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(lb,{children:"Delete session?"}),e[24]=T):T=e[24];let $;e[25]!==s?($=a.jsxs(ib,{children:[T,a.jsxs(cb,{children:["This will permanently delete"," ",a.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=a.jsx(db,{size:"sm",children:"Cancel"}),e[27]=A):A=e[27];let R;e[28]!==i?(R=a.jsxs(ab,{children:[A,a.jsx(ub,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=R):R=e[29];let P;e[30]!==$||e[31]!==R?(P=a.jsxs(ob,{children:[$,R]}),e[30]=$,e[31]=R,e[32]=P):P=e[32];let z;e[33]!==m||e[34]!==P?(z=a.jsx(rb,{open:m,onOpenChange:p,children:P}),e[33]=m,e[34]=P,e[35]=z):z=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsxs(ao,{children:[a.jsx(or,{className:"text-foreground",children:"Rename session"}),a.jsx(ir,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=L):L=e[36];let I;e[37]!==l||e[38]!==x?(I=W=>{W.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=I):I=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(mn,{htmlFor:"session-rename",children:"Session name"}),e[40]=M):M=e[40];let F;e[41]===Symbol.for("react.memo_cache_sentinel")?(F=W=>b(W.target.value),e[41]=F):F=e[41];let U;e[42]!==x||e[43]!==s?(U=a.jsxs(fn,{children:[M,a.jsx(On,{id:"session-rename",ref:w,value:x,onChange:F,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=U):U=e[44];let O;e[45]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsxs(Rx,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[45]=O):O=e[45];let D;e[46]!==I||e[47]!==U?(D=a.jsxs(rr,{className:"sm:max-w-md",children:[L,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:I,children:[U,O]})]}),e[46]=I,e[47]=U,e[48]=D):D=e[48];let B;e[49]!==h||e[50]!==D?(B=a.jsx(sr,{open:h,onOpenChange:g,children:D}),e[49]=h,e[50]=D,e[51]=B):B=e[51];let q;return e[52]!==z||e[53]!==B||e[54]!==E?(q=a.jsxs(a.Fragment,{children:[E,z,B]}),e[52]=z,e[53]=B,e[54]=E,e[55]=q):q=e[55],q}function V1(n,e){return Object.freeze({canInteract:n,canOwn:e,send:n,stop:n,answer:n,configure:n,mcp:n,undo:n,archive:e,delete:e})}const lg=V1(!1,!1),hxe={unknown:lg,none:lg,view:lg,interact:V1(!0,!1),own:V1(!0,!0)};function Sa(n){return hxe[n]}function Pm(){const n=V.c(3),{enforcesSessionAccess:e}=PN(),t=e===!1?"own":"unknown";let s;return n[0]!==e||n[1]!==t?(s=r=>Sa(e!==null&&r?r.level:t),n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function n7(n){const e=V.c(16),{value:t,onChange:s,placeholder:r,loading:o}=n,i=o===void 0?!1:o;let l;e[0]!==i?(l=a.jsx(Ar,{children:i?a.jsx(St,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(ss,{"aria-hidden":"true"})}),e[0]=i,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 u;e[4]!==i||e[5]!==r||e[6]!==c||e[7]!==t?(u=a.jsx(Go,{type:"search","aria-busy":i,"aria-label":r,value:t,onChange:c,placeholder:r}),e[4]=i,e[5]=r,e[6]=c,e[7]=t,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==t?(d=t&&a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(Mt,{})})}),e[9]=s,e[10]=t,e[11]=d):d=e[11];let f;return e[12]!==l||e[13]!==u||e[14]!==d?(f=a.jsxs(Ko,{className:"w-full sm:max-w-sm",children:[l,u,d]}),e[12]=l,e[13]=u,e[14]=d,e[15]=f):f=e[15],f}function s7(n){const e=V.c(10),{message:t,onRetry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(er,{"aria-hidden":"true"}),o=a.jsx(Xt,{children:"Could not load this data"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(_t,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(Hr,{children:a.jsxs(Q,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(kt,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function r7(n){const e=V.c(5),{count:t,includeMessagePlaceholder:s}=n,r=t===void 0?4:t,o=s===void 0?!1:s;let i;if(e[0]!==r||e[1]!==o){let l;e[3]!==o?(l=(c,u)=>a.jsxs("div",{children:[u>0&&a.jsx(tn,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx(Gn,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-40 max-w-full"}),o&&a.jsx(Gn,{className:"h-3 w-72 max-w-full"}),a.jsx(Gn,{className:"h-3 w-52 max-w-full"})]}),a.jsx(Gn,{className:"hidden h-5 w-20 sm:block"})]})]},u),e[3]=o,e[4]=l):l=e[4],i=a.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:r},l)}),e[0]=r,e[1]=o,e[2]=i}else i=e[2];return i}function o7(n){const e=V.c(3),{access:t}=n,{SessionBadges:s}=$r();let r;return e[0]!==s||e[1]!==t?(r=s?a.jsx(s,{access:t}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const Hs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},gxe=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,xxe=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,bxe=/(?:^|\s)#(\d+)(?=\s|$)/,vxe=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Gu(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function yxe(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 i7(n){const e=n.trim();if(!e)return null;const t=gxe.exec(e);if(t){const l=Gu(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=xxe.exec(e);if(s){const l=Gu(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=bxe.exec(e);if(r){const l=Gu(r[1]);if(l===null)return null;const c=`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`;return{number:l,repoHint:yxe(c)}}const o=vxe.exec(e);if(!o)return null;const i=Gu(o[1]);return i===null?null:{number:i,repoHint:null}}function Ij(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function wxe(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(r=>r.replace(/[^a-z0-9]/g,"")===s)}function Sxe(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Ij(n.repo,s):Ij(n.repo,s)?!0:t.some(r=>wxe(r,s)):!0}function a7(n,e,t=[]){var o;const s=i7(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>Sxe(l,s,i)))??!1}const r=e.trim().toLowerCase();return r?[...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(i=>i==null?void 0:i.toLowerCase().includes(r)):!0}const kxe=120*1e3;function l7(n){return n?Date.now()-new Date(n).getTime()<kxe:!1}function c7(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Bs(s,70):Bs(n.sessionId,16)}function Pj(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function jxe(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Pj(t)===Pj(e)?null:Bs(t,220)}function Nxe(n,e){return a7(n,e)}function Cxe(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Js(t):null}function _xe(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(`
|
|
470
|
-
`)}function Exe(n){var t;const e=n.cwd?(t=Cr(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:F8,label:e,title:n.cwd}:n.gitBranch?{icon:Zr,label:n.gitBranch}:null}function Txe(n,e){return n.agentStatus==="deferred"?"attention":e?Qc(n.agentStatus)?"idle":"working":null}function Axe(n){const e=V.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=r):r=e[0],r}if(s){const r=Qc(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=Jc(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]=o):o=e[5];const i=o;let l;e[6]!==t.agentStatus?(l=wm(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=r?"bg-success/60":"bg-current";let u;e[8]!==c?(u=G("size-1.5 rounded-full",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==u?(d=a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:u}),e[10]=u,e[11]=d):d=e[11];let f;return e[12]!==i||e[13]!==l||e[14]!==d?(f=a.jsxs(Fe,{variant:"secondary",className:l,children:[d,i]}),e[12]=i,e[13]=l,e[14]=d,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let r;e[16]!==t.agentTerminalReason?(r=Rb(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Fe,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function cg(n){const e=V.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=G("flex items-center gap-1",r),e[0]=r,e[1]=i):i=e[1];let l;e[2]!==t?(l=a.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==s?(c=a.jsxs("span",{className:i,title:s,children:[l,o]}),e[4]=o,e[5]=i,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function Ixe(n){const e=V.c(103),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=l7(o),l=Txe(t,i),e[0]=o,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]);const c=l,u=t.teamName?t.agentName:void 0;let d,f,m,p,h,g,x,b,w,v,j,k,_,N,S;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const I=Exe(t);let M;e[26]!==o||e[27]!==t.timestamp?(M=Cxe(t.timestamp,o),e[26]=o,e[27]=t.timestamp,e[28]=M):M=e[28];const F=M,U=t.turnCount??0;let O,D;e[29]!==s||e[30]!==t?(D=c7(t,s),O=jxe(t,D),e[29]=s,e[30]=t,e[31]=O,e[32]=D):(O=e[31],D=e[32]);const B=O;x="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",m=r,e[33]!==t?(p=_xe(t),e[33]=t,e[34]=p):p=e[34],h="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 q;e[35]===Symbol.for("react.memo_cache_sentinel")?(q=a.jsx(bg,{className:"size-4"}),e[35]=q):q=e[35];let W;e[36]!==c?(W=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Hs[c])}),e[36]=c,e[37]=W):W=e[37],e[38]!==W?(g=a.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:[q,W]}),e[38]=W,e[39]=g):g=e[39],N="flex min-w-0 flex-1 flex-col gap-1";let H;e[40]!==D?(H=a.jsx("span",{className:"truncate text-sm font-medium",children:D}),e[40]=D,e[41]=H):H=e[41];let K;e[42]!==u?(K=u&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",children:[a.jsx(mi,{"data-icon":"inline-start"}),Bs(u,18)]}),e[42]=u,e[43]=K):K=e[43];let Z;e[44]!==t.branchedFrom?(Z=t.branchedFrom&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(bx,{"data-icon":"inline-start"}),"branch"]}),e[44]=t.branchedFrom,e[45]=Z):Z=e[45];let Y;e[46]!==i||e[47]!==t?(Y=a.jsx(Axe,{session:t,live:i}),e[46]=i,e[47]=t,e[48]=Y):Y=e[48];let J;e[49]!==o?(J=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:_r(o)}),e[49]=o,e[50]=J):J=e[50];let ee;e[51]!==Y||e[52]!==J?(ee=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Y,J]}),e[51]=Y,e[52]=J,e[53]=ee):ee=e[53],e[54]!==H||e[55]!==K||e[56]!==Z||e[57]!==ee?(S=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[H,K,Z,ee]}),e[54]=H,e[55]=K,e[56]=Z,e[57]=ee,e[58]=S):S=e[58],e[59]!==B?(d=B&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:B}),e[59]=B,e[60]=d):d=e[60],b="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[61]!==t.access?(w=a.jsx(o7,{access:t.access}),e[61]=t.access,e[62]=w):w=e[62],e[63]!==t.model?(v=t.model&&a.jsx(Fe,{variant:"outline",children:lo(t.model)}),e[63]=t.model,e[64]=v):v=e[64],e[65]!==U?(j=U>0&&a.jsxs(cg,{icon:bg,children:[U," ",U===1?"turn":"turns"]}),e[65]=U,e[66]=j):j=e[66],e[67]!==F?(k=F&&a.jsx(cg,{icon:Po,title:"First prompt to last activity",children:F}),e[67]=F,e[68]=k):k=e[68],_=I&&a.jsx(cg,{icon:I.icon,className:"max-w-40 truncate",title:I.title,children:Bs(I.label,22)}),e[4]=s,e[5]=c,e[6]=o,e[7]=i,e[8]=r,e[9]=t,e[10]=u,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=j,e[22]=k,e[23]=_,e[24]=N,e[25]=S}else d=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],j=e[21],k=e[22],_=e[23],N=e[24],S=e[25];let C;e[69]!==t.size?(C=kN(t.size),e[69]=t.size,e[70]=C):C=e[70];let E;e[71]!==C?(E=a.jsx("span",{children:C}),e[71]=C,e[72]=E):E=e[72];let T;e[73]!==E||e[74]!==b||e[75]!==w||e[76]!==v||e[77]!==j||e[78]!==k||e[79]!==_?(T=a.jsxs("span",{className:b,children:[w,v,j,k,_,E]}),e[73]=E,e[74]=b,e[75]=w,e[76]=v,e[77]=j,e[78]=k,e[79]=_,e[80]=T):T=e[80];let $;e[81]!==d||e[82]!==T||e[83]!==N||e[84]!==S?($=a.jsxs("span",{className:N,children:[S,d,T]}),e[81]=d,e[82]=T,e[83]=N,e[84]=S,e[85]=$):$=e[85];let A;e[86]!==f||e[87]!==m||e[88]!==p||e[89]!==h||e[90]!==g||e[91]!==$?(A=a.jsxs("button",{type:f,onClick:m,title:p,className:h,children:[g,$]}),e[86]=f,e[87]=m,e[88]=p,e[89]=h,e[90]=g,e[91]=$,e[92]=A):A=e[92];let R;e[93]!==t.matchedPullRequestNumber||e[94]!==t.pullRequests?(R=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),e[93]=t.matchedPullRequestNumber,e[94]=t.pullRequests,e[95]=R):R=e[95];let P;e[96]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(it,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[96]=P):P=e[96];let z;e[97]!==R?(z=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[R,P]}),e[97]=R,e[98]=z):z=e[98];let L;return e[99]!==x||e[100]!==A||e[101]!==z?(L=a.jsxs("div",{className:x,children:[A,z]}),e[99]=x,e[100]=A,e[101]=z,e[102]=L):L=e[102],L}function Pxe(n){const e=V.c(63),{selectedProject:t,filterEmpty:s,sessions:r,sessionsTotal:o,sessionsLoading:i,searchLoading:l,searchFilter:c,setSearchFilter:u,filteredSessions:d,fetchError:f,onSelectSession:m,onNewSession:p,creatingSession:h,onDuplicateSession:g,onDeleteSession:x,onBack:b,onRetryFetch:w,loadMoreSessions:v}=n,{names:j,rename:k}=Ff(),_=Pm();let N;e[0]!==t.path?(N=Er(t.path),e[0]=t.path,e[1]=N):N=e[1];const S=N;let C;e[2]!==b?(C=a.jsx(W1,{children:a.jsx(XI,{render:a.jsx("button",{type:"button",onClick:b}),children:"Projects"})}),e[2]=b,e[3]=C):C=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(QI,{}),e[4]=E):E=e[4];let T;e[5]!==S?(T=a.jsx(W1,{className:"min-w-0",children:a.jsx(JI,{className:"truncate",children:S})}),e[5]=S,e[6]=T):T=e[6];let $;e[7]!==C||e[8]!==T?($=a.jsx(ZI,{children:a.jsxs(YI,{children:[C,E,T]})}),e[7]=C,e[8]=T,e[9]=$):$=e[9];let A;e[10]!==S?(A=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:S}),e[10]=S,e[11]=A):A=e[11];let R;e[12]!==o?(R=a.jsx(Fe,{variant:"secondary",children:o}),e[12]=o,e[13]=R):R=e[13];let P;e[14]!==A||e[15]!==R?(P=a.jsxs("div",{className:"flex items-center gap-2",children:[A,R]}),e[14]=A,e[15]=R,e[16]=P):P=e[16];let z;e[17]!==t.path?(z=jc(t.path),e[17]=t.path,e[18]=z):z=e[18];let L;e[19]!==z?(L=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:z}),e[19]=z,e[20]=L):L=e[20];let I;e[21]!==L||e[22]!==P?(I=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[P,L]}),e[21]=L,e[22]=P,e[23]=I):I=e[23];let M;e[24]!==c||e[25]!==l||e[26]!==u?(M=a.jsx(n7,{value:c,onChange:u,placeholder:"Search sessions or PRs...",loading:l}),e[24]=c,e[25]=l,e[26]=u,e[27]=M):M=e[27];let F;e[28]!==h||e[29]!==p||e[30]!==t.dirName||e[31]!==t.path?(F=p&&a.jsxs(Q,{size:"sm",disabled:h,onClick:()=>p(t.dirName,t.path),children:[h?a.jsx(Pn,{"data-icon":"inline-start"}):a.jsx(kr,{"data-icon":"inline-start"}),"New Session"]}),e[28]=h,e[29]=p,e[30]=t.dirName,e[31]=t.path,e[32]=F):F=e[32];let U;e[33]!==M||e[34]!==F?(U=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,F]}),e[33]=M,e[34]=F,e[35]=U):U=e[35];let O;e[36]!==f||e[37]!==w?(O=f&&a.jsx(s7,{message:f,onRetry:w}),e[36]=f,e[37]=w,e[38]=O):O=e[38];let D;e[39]!==s||e[40]!==d||e[41]!==v||e[42]!==x||e[43]!==g||e[44]!==m||e[45]!==_||e[46]!==k||e[47]!==c||e[48]!==l||e[49]!==t.dirName||e[50]!==j||e[51]!==r||e[52]!==i||e[53]!==o?(D=(i||l)&&d.length===0?a.jsx(r7,{includeMessagePlaceholder:!0}):d.length===0?a.jsx($xe,{searchFilter:c,filterEmpty:s}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((W,H)=>a.jsxs(y.Fragment,{children:[H>0&&a.jsx(tn,{}),a.jsx(sv,{sessionLabel:c7(W),customName:j[W.sessionId],onRename:K=>k(W.sessionId,K),onDuplicate:g?()=>g(t.dirName,W.fileName):void 0,onDelete:x&&_(W.access).delete?()=>x(t.dirName,W.fileName):void 0,children:a.jsx(Ixe,{session:W,customName:j[W.sessionId],onSelect:()=>m(t.dirName,W.fileName)})})]},W.fileName))}),r.length<o&&!c&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(Q,{variant:"outline",size:"sm",disabled:i,onClick:v,children:[i&&a.jsx(Pn,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=s,e[40]=d,e[41]=v,e[42]=x,e[43]=g,e[44]=m,e[45]=_,e[46]=k,e[47]=c,e[48]=l,e[49]=t.dirName,e[50]=j,e[51]=r,e[52]=i,e[53]=o,e[54]=D):D=e[54];let B;e[55]!==U||e[56]!==O||e[57]!==D?(B=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[U,O,D]}),e[55]=U,e[56]=O,e[57]=D,e[58]=B):B=e[58];let q;return e[59]!==I||e[60]!==B||e[61]!==$?(q=a.jsx(Vc,{className:"h-full",children:a.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:[$,I,B]})}),e[59]=I,e[60]=B,e[61]=$,e[62]=q):q=e[62],q}function $xe(n){const e=V.c(8),{searchFilter:t,filterEmpty:s}=n;if(!t&&s)return s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Yn,{variant:"icon",children:a.jsx(vc,{})}),e[0]=r):r=e[0];const o=t?"No sessions match your search":"No sessions yet";let i;e[1]!==o?(i=a.jsx(zn,{children:o}),e[1]=o,e[2]=i):i=e[2];const l=t?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here.";let c;e[3]!==l?(c=a.jsx(Dn,{children:l}),e[3]=l,e[4]=c):c=e[4];let u;return e[5]!==i||e[6]!==c?(u=a.jsx(Ln,{className:"min-h-72 border",children:a.jsxs(Mn,{children:[r,i,c]})}),e[5]=i,e[6]=c,e[7]=u):u=e[7],u}function u7(n){const e=V.c(40),{children:t,projectLabel:s,customName:r,className:o,onRename:i,archivableCount:l,onArchiveIdle:c}=n,u=l===void 0?0:l,[d,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==r?(g=function(){p(r||""),f(!0),requestAnimationFrame(()=>{var M;return(M=h.current)==null?void 0:M.select()})},e[0]=r,e[1]=g):g=e[1];const x=g;let b;e[2]!==o?(b=G("w-full",o),e[2]=o,e[3]=b):b=e[3];let w;e[4]!==b?(w=a.jsx("div",{className:b}),e[4]=b,e[5]=w):w=e[5];let v;e[6]!==t||e[7]!==w?(v=a.jsx(Cm,{render:w,children:t}),e[6]=t,e[7]=w,e[8]=v):v=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(wr,{"data-icon":"inline-start"}),e[9]=j):j=e[9];let k;e[10]!==x?(k=a.jsx(fi,{children:a.jsxs(Rn,{onClick:x,children:[j,"Rename project"]})}),e[10]=x,e[11]=k):k=e[11];let _;e[12]!==u||e[13]!==c?(_=c&&a.jsxs(a.Fragment,{children:[a.jsx(va,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:c,disabled:u===0,children:[a.jsx(Ns,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs(_m,{className:"min-w-44",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==v||e[19]!==N?(S=a.jsxs(Nm,{children:[v,N]}),e[18]=v,e[19]=N,e[20]=S):S=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsxs(ao,{children:[a.jsx(or,{className:"text-foreground",children:"Rename project"}),a.jsx(ir,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=C):C=e[21];let E;e[22]!==i||e[23]!==m?(E=I=>{I.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(mn,{htmlFor:"project-rename",children:"Project name"}),e[25]=T):T=e[25];let $;e[26]===Symbol.for("react.memo_cache_sentinel")?($=I=>p(I.target.value),e[26]=$):$=e[26];let A;e[27]!==s||e[28]!==m?(A=a.jsxs(fn,{children:[T,a.jsx(On,{id:"project-rename",ref:h,value:m,onChange:$,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=A):A=e[29];let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsxs(Rx,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[30]=R):R=e[30];let P;e[31]!==E||e[32]!==A?(P=a.jsxs(rr,{className:"sm:max-w-md",children:[C,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:E,children:[A,R]})]}),e[31]=E,e[32]=A,e[33]=P):P=e[33];let z;e[34]!==d||e[35]!==P?(z=a.jsx(sr,{open:d,onOpenChange:f,children:P}),e[34]=d,e[35]=P,e[36]=z):z=e[36];let L;return e[37]!==S||e[38]!==z?(L=a.jsxs(a.Fragment,{children:[S,z]}),e[37]=S,e[38]=z,e[39]=L):L=e[39],L}function Rxe(n){const e=V.c(47),{projects:t,activeSessions:s,loading:r,refreshing:o,searchFilter:i,setSearchFilter:l,fetchError:c,selectedProjectDirName:u,onSelectProject:d,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const I of s)l7(I.lastModified)&&(m[I.dirName]=(m[I.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=nv();let x;e[2]!==t?(x=e7(t),e[2]=t,e[3]=x):x=e[3];const b=x;let w;e:{if(!i){w=b;break e}let I;if(e[4]!==h||e[5]!==b||e[6]!==i){const M=i.toLowerCase(),F=U=>{var O;return U.path.toLowerCase().includes(M)||U.shortName.toLowerCase().includes(M)||((O=h[U.dirName])==null?void 0:O.toLowerCase().includes(M))};I=b.filter(U=>F(U)||U.worktrees.some(F)),e[4]=h,e[5]=b,e[6]=i,e[7]=I}else I=e[7];w=I}const v=w;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[8]=j):j=e[8];let k;e[9]!==b.length?(k=a.jsxs("div",{className:"flex items-center gap-2",children:[j,a.jsx(Fe,{variant:"secondary",children:b.length})]}),e[9]=b.length,e[10]=k):k=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[11]=_):_=e[11];let N;e[12]!==k?(N=a.jsxs("header",{className:"flex flex-col gap-1",children:[k,_]}),e[12]=k,e[13]=N):N=e[13];let S;e[14]!==i||e[15]!==l?(S=a.jsx(n7,{value:i,onChange:l,placeholder:"Filter projects..."}),e[14]=i,e[15]=l,e[16]=S):S=e[16];const C=o&&"animate-spin";let E;e[17]!==C?(E=G(C),e[17]=C,e[18]=E):E=e[18];let T;e[19]!==E?(T=a.jsx(Fn,{"data-icon":"inline-start",className:E}),e[19]=E,e[20]=T):T=e[20];let $;e[21]!==f||e[22]!==o||e[23]!==T?($=a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[21]=f,e[22]=o,e[23]=T,e[24]=$):$=e[24];let A;e[25]!==$||e[26]!==S?(A=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,$]}),e[25]=$,e[26]=S,e[27]=A):A=e[27];let R;e[28]!==c||e[29]!==f||e[30]!==u?(R=c&&!u&&a.jsx(s7,{message:c,onRetry:f}),e[28]=c,e[29]=f,e[30]=u,e[31]=R):R=e[31];let P;e[32]!==p||e[33]!==v||e[34]!==r||e[35]!==d||e[36]!==h||e[37]!==g||e[38]!==i?(P=r?a.jsx(r7,{}):v.length===0?a.jsxs(Ln,{className:"min-h-72 border",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Yr,{})}),a.jsx(zn,{children:i?"No projects match your search":"No projects yet"}),a.jsx(Dn,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]}),!i&&a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:Oxe,children:[a.jsx(wc,{"data-icon":"inline-start"}),"Start in a folder"]})})]}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map((I,M)=>{const F=p[I.dirName]||0,U=h[I.dirName],O=CM(un(I.dirName));return a.jsxs(y.Fragment,{children:[M>0&&a.jsx(tn,{}),a.jsx(u7,{projectLabel:Er(I.path),customName:U,onRename:D=>g(I.dirName,D),children:a.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(I.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:a.jsx(wa,{projectPath:I.path,className:"size-4",fallback:a.jsx(Yr,{className:"size-4 text-muted-foreground"})})}),a.jsxs("span",{className:"min-w-0",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:U||Er(I.path)}),O&&a.jsx(Fe,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:O})]}),a.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[jc(I.path),I.worktrees.length>0&&a.jsxs(a.Fragment,{children:[" · ",I.worktrees.length," ",I.worktrees.length===1?"worktree":"worktrees"]})]})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[F>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),F," active"]}),a.jsxs("span",{className:"whitespace-nowrap",children:[I.sessionCount," ",I.sessionCount===1?"session":"sessions"]}),I.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:_r(I.lastModified)}),a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})}),I.worktrees.map(D=>a.jsx(Lxe,{worktree:D,customName:h[D.dirName],activeCount:p[D.dirName]||0,onSelect:()=>d==null?void 0:d(D.dirName)},D.dirName))]},I.dirName)})}),e[32]=p,e[33]=v,e[34]=r,e[35]=d,e[36]=h,e[37]=g,e[38]=i,e[39]=P):P=e[39];let z;e[40]!==A||e[41]!==R||e[42]!==P?(z=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,R,P]}),e[40]=A,e[41]=R,e[42]=P,e[43]=z):z=e[43];let L;return e[44]!==z||e[45]!==N?(L=a.jsx(Vc,{className:"h-full",children:a.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:[N,z]})}),e[44]=z,e[45]=N,e[46]=L):L=e[46],L}function Oxe(){return AI()}function Lxe(n){var b;const e=V.c(23),{worktree:t,customName:s,activeCount:r,onSelect:o}=n;let i;e[0]!==s||e[1]!==t.path?(i=s||((b=Cr(t.path))==null?void 0:b.worktreeName)||Er(t.path),e[0]=s,e[1]=t.path,e[2]=i):i=e[2];const l=i;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Zr,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[3]=c):c=e[3];let u;e[4]!==l?(u=a.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground group-hover:text-foreground",children:l}),e[4]=l,e[5]=u):u=e[5];let d;e[6]!==r?(d=r>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),r," active"]}),e[6]=r,e[7]=d):d=e[7];const f=t.sessionCount===1?"session":"sessions";let m;e[8]!==f||e[9]!==t.sessionCount?(m=a.jsxs("span",{className:"whitespace-nowrap",children:[t.sessionCount," ",f]}),e[8]=f,e[9]=t.sessionCount,e[10]=m):m=e[10];let p;e[11]!==t.lastModified?(p=t.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:_r(t.lastModified)}),e[11]=t.lastModified,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"}),e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==m||e[16]!==p?(g=a.jsxs("span",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[d,m,p,h]}),e[14]=d,e[15]=m,e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==o||e[19]!==u||e[20]!==g||e[21]!==t.path?(x=a.jsxs("button",{type:"button",onClick:o,title:t.path,className:"motion-list-item group flex w-full items-center gap-3 py-2 pl-15 pr-4 text-left text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[c,u,g]}),e[18]=o,e[19]=u,e[20]=g,e[21]=t.path,e[22]=x):x=e[22],x}const Mxe=250,zxe=400,$j={results:null,loading:!1,error:null};function d7(n,e,t){const s=y.useMemo(()=>i7(n),[n]),[r,o]=y.useState(0),[i,l]=y.useState($j);y.useEffect(()=>{if(!s){l($j);return}const d=new AbortController;l({results:null,loading:!0,error:null});let f=null;const m=async()=>{const h=new URLSearchParams({search:n.trim(),limit:"200"});t&&h.set("project",t);const g=Jr();try{const x=await Ce(zf(h,e),{signal:d.signal});if(!x.ok)throw new Error(`Search failed (${x.status})`);const b=await x.json();if(d.signal.aborted)return;const w=Number(x.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(w)&&w>0){f=setTimeout(()=>{m()},zxe);return}const v=Array.isArray(b)?b:[];la(v,g),l({results:v,loading:!1,error:null})}catch(x){if(d.signal.aborted)return;l({results:[],loading:!1,error:x instanceof Error?x.message:"Search failed"})}},p=setTimeout(()=>{m()},Mxe);return()=>{clearTimeout(p),f&&clearTimeout(f),d.abort()}},[e,t,s,n,r]);const c=y.useCallback(()=>o(d=>d+1),[]),u=s!==null;return y.useEffect(()=>{if(u)return Df(c)},[u,c]),{...i,active:u,refresh:c}}const Dxe=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){var se;const c=Mf(),u=(se=$r().sessionListFilter)==null?void 0:se.Empty,[d]=y.useState(()=>({projects:Zi(Ql.projects),activeSessions:Zi(td(c.key))})),[f,m]=y.useState(d.projects??[]),[p,h]=y.useState(d.activeSessions??[]),[g,x]=y.useState(d.projects===void 0),[b,w]=y.useState(!1),[v,j]=y.useState(null),[k,_]=y.useState(null),[N,S]=y.useState([]),[C,E]=y.useState(0),[T,$]=y.useState(1),[A,R]=y.useState(!1),[P,z]=y.useState(""),[L,I]=y.useState(null),M=y.useRef(0),F=y.useRef(null),U=y.useRef(null),O=y.useRef(c.key),D=y.useCallback(async()=>{try{const X=await Ce("/api/projects");if(!X.ok)throw new Error("Failed to fetch dashboard data");const ne=await X.json(),ae=Array.isArray(ne)?ne:[];m(ae),_l(Ql.projects,ae),j(null)}catch(X){j(X instanceof Error?X.message:"Failed to load data")}finally{x(!1)}},[]),B=y.useCallback(async()=>{var ae;(ae=U.current)==null||ae.abort();const X=new AbortController;U.current=X;const ne=Jr();try{const ie=await Ce(zf({},c),{signal:X.signal});if(!ie.ok)throw new Error("Failed to fetch dashboard data");const re=await ie.json();if(X.signal.aborted)return;const de=Array.isArray(re)?re:[];la(de,ne),h(de),_l(td(c.key),de),_(null)}catch(ie){if(X.signal.aborted)return;_(ie instanceof Error?ie.message:"Failed to load data")}},[c]);y.useEffect(()=>{D()},[D]),y.useEffect(()=>{O.current!==c.key&&(O.current=c.key,h(Zi(td(c.key))??[])),B()},[c,B]);async function q(){w(!0),await Promise.all([D(),B()]),w(!1)}const W=y.useCallback(async(X,ne=1,ae=!1)=>{var oe;const ie=++M.current;(oe=F.current)==null||oe.abort();const re=new AbortController;F.current=re;const de=()=>ie===M.current;R(!0),I(null);const ce=Jr();if(!ae){const fe=B9(X,c.key);fe?(S(fe.sessions),E(fe.total),$(1)):S([])}try{const fe=await Ce(El(`/api/sessions/${encodeURIComponent(X)}`,c,{page:String(ne),limit:"20"}),{signal:re.signal});if(!fe.ok)throw new Error(`Failed to load sessions (${fe.status})`);const ue=await fe.json();if(!de())return;const le=Array.isArray(ue.sessions)?ue.sessions:[],pe=typeof ue.total=="number"?ue.total:le.length;la(le,ce),S(ge=>ae?[...ge,...le]:le),E(pe),$(ne),ae||W9(X,c.key,{sessions:le,total:pe})}catch(fe){if(!de()||re.signal.aborted)return;I(fe instanceof Error?fe.message:"Failed to load sessions")}finally{de()&&(F.current=null,R(!1))}},[c]);y.useEffect(()=>{var X;if(!r){M.current+=1,(X=F.current)==null||X.abort(),F.current=null,S([]),E(0),$(1),R(!1);return}W(r)},[r,W]),y.useEffect(()=>{z("")},[r]),y.useEffect(()=>()=>{var X,ne;M.current+=1,(X=F.current)==null||X.abort(),(ne=U.current)==null||ne.abort()},[]),y.useEffect(()=>Df(()=>{B(),r&&W(r)}),[B,W,r]);const H=y.useMemo(()=>{if(!r)return null;const X=f.find(ae=>ae.dirName===r);if(X)return X;const ne=xs(r);return{dirName:r,path:ne,shortName:Er(ne),sessionCount:C,lastModified:null}},[r,f,C]),K=y.useCallback(()=>{o==null||o(null)},[o]),Z=y.useCallback(()=>{r&&W(r,T+1,!0)},[r,T,W]),Y=d7(r?P:"",c,r??void 0),J=y.useMemo(()=>P?N.filter(X=>Nxe(X,P)):N,[N,P]),ee=Y.results??J;async function te(X,ne){await(l==null?void 0:l(X,ne))&&(S(ae=>ae.filter(ie=>ie.fileName!==ne)),E(ae=>ae-1))}return H?a.jsx(Pxe,{selectedProject:H,filterEmpty:c.key!==null&&u?a.jsx(u,{className:"min-h-72 border"}):null,sessions:N,sessionsTotal:C,sessionsLoading:A,searchLoading:Y.loading,searchFilter:P,setSearchFilter:z,filteredSessions:ee,fetchError:Y.error??L,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:te,onBack:K,onRetryFetch:()=>{if(Y.error){Y.refresh();return}I(null),r&&W(r)},loadMoreSessions:Z}):a.jsx(Rxe,{projects:f,activeSessions:p,loading:g,refreshing:b,searchFilter:P,setSearchFilter:z,fetchError:v??k,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>void q()})}),Rj=768;function rv(){const n=V.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<Rj:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${Rj-1}px)`),i=l=>t(l.matches);return o.addEventListener("change",i),t(o.matches),()=>o.removeEventListener("change",i)},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}const f7=typeof navigator<"u"&&"vibrate"in navigator;function H1(){f7&&navigator.vibrate(10)}function Fxe(){f7&&navigator.vibrate(20)}function Uxe(n){return!!(n.teamName&&n.agentName)}function Bxe(n,e,t,s,r,o,i,l=()=>!0){const c=[],u=[];for(const d of Ia(n)){const f=p=>{l(d)&&c.push({session:d,reason:p})};if(s!=null&&s.has(d.sessionId)){f("permission");continue}if(r!=null&&r.has(d.sessionId)){f("question");continue}if(o!=null&&o.has(d.sessionId)){f("prompt");continue}if(i!=null&&i.has(d.sessionId)){f("plan");continue}if(d.agentStatus==="deferred"){f("deferred");continue}if(Uxe(d))continue;const m=Dx(d,e);if(d.agentStatus==="completed"||!m){t.has(d.sessionId)&&f("done");continue}if(d.agentStatus==="idle"){f("waiting");continue}(!d.agentStatus||$f.has(d.agentStatus))&&u.push(d)}return{needsYou:c,working:u}}function Wxe(n,e,t,s,r=()=>!0){const o=[...n.needsYou],i=[...n.working],l=new Map;for(const u of e){const d=t.get(u.sessionId);if(!(d!=null&&d.length))continue;const f=Ux(d,p=>{const h=s(p);return h.state==="needs-you"&&!r(p)?{state:"done"}:h}),m=o.findIndex(p=>p.session.sessionId===u.sessionId);if(f.needsYou>0)if(m>=0)o[m]={...o[m],crew:f};else{o.push({session:u,reason:"crew",crew:f});const p=i.indexOf(u);p>=0&&i.splice(p,1)}else f.working>0&&m<0&&!i.includes(u)&&(i.push(u),l.set(u.sessionId,f))}const c=u=>{var d;return u.reason==="crew"&&((d=u.crew)!=null&&d.longestWaitSince)?Date.parse(u.crew.longestWaitSince):Nr(u.session)};return o.sort((u,d)=>c(d)-c(u)),{needsYou:o,working:Ia(i),workingCrews:l}}function m7(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"}}const p7="aw:turnCounts",qxe=200,$m=new Map;try{const n=localStorage.getItem(p7);if(n){const e=JSON.parse(n);for(const[t,s]of e)$m.set(t,s)}}catch{}function Vxe(){try{const n=[...$m.entries()].slice(-qxe);localStorage.setItem(p7,JSON.stringify(n))}catch{}}function Hxe(n,e){$m.set(sn(n),e),Vxe()}function h7(n,e){const t=$m.get(sn(n));return Math.max(t??0,e??0)}function ov(n){const e=V.c(51),{session:t,proc:s,statusLabel:r,customName:o,worktreeName:i,projectLabel:l}=n,c=o||t.aiTitle,u=t.firstUserMessage,d=t.lastUserMessage&&t.lastUserMessage!==u?t.lastUserMessage:void 0,f=h7(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&a.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(ra,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==r?(h=r&&a.jsx("span",{className:G("font-medium",wm(t.agentStatus)),children:r}),e[4]=t.agentStatus,e[5]=r,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(tr,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Ns,{className:"size-3"}),Mx(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let b;e[13]!==u||e[14]!==d?(b=u&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:u})})]}),e[13]=u,e[14]=d,e[15]=b):b=e[15];let w;e[16]!==d?(w=d&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:d})})]}),e[16]=d,e[17]=w):w=e[17];let v;e[18]!==t.pullRequests?(v=a.jsx(su,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=v):v=e[19];let j;e[20]!==t.gitBranch||e[21]!==i?(j=t.gitBranch&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(Zr,{className:"size-2.5"}),i?`${t.gitBranch} · ${i}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=i,e[22]=j):j=e[22];let k;e[23]!==f?(k=f>0&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(vc,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=k):k=e[24];let _;e[25]!==t.size?(_=kN(t.size),e[25]=t.size,e[26]=_):_=e[26];let N;e[27]!==_?(N=a.jsx("span",{children:_}),e[27]=_,e[28]=N):N=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(U8,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const C=t.lastActivityAt||t.lastModified;let E;e[31]!==C?(E=_r(C),e[31]=C,e[32]=E):E=e[32];let T;e[33]!==E?(T=a.jsx("span",{children:E}),e[33]=E,e[34]=T):T=e[34];let $;e[35]!==k||e[36]!==N||e[37]!==S||e[38]!==T||e[39]!==j?($=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[j,k,N,S,T]}),e[35]=k,e[36]=N,e[37]=S,e[38]=T,e[39]=j,e[40]=$):$=e[40];let A;return e[41]!==m||e[42]!==$||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==b||e[48]!==w||e[49]!==v?(A=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,w,v,$]}),e[41]=m,e[42]=$,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=w,e[49]=v,e[50]=A):A=e[50],A}const Kxe=120;function iv(n){const e=V.c(7),t=y.useRef(null);let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},r=[],e[0]=s,e[1]=r):(s=e[0],r=e[1]),y.useEffect(s,r);let o;e[2]!==n?(o=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,Kxe))},e[2]=n,e[3]=o):o=e[3];const i=o;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 u;return e[5]!==i?(u={onHoverStart:i,onHoverEnd:c},e[5]=i,e[6]=u):u=e[6],u}const Gxe=6;function Zxe(n,e){var s;const t=(s=e.workingCrews)==null?void 0:s.get(n.sessionId);return t?`${t.working} in crew`:m7(n)}function Yxe(n){const e=V.c(7),{iso:t}=n,[,s]=y.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(Xxe),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2],y.useEffect(r,o);let i;e[3]!==t?(i=_r(t),e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==i?(l=a.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i}),e[5]=i,e[6]=l):l=e[6],l}function Xxe(n){return n+1}const Jxe={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"},crew:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"}};function Qxe({reason:n,crew:e}){const t=Jxe[n];return n==="crew"&&e?{...t,label:`${e.needsYou} waiting`}:t}const e0e={permission:Hs.attention,deferred:Hs.attention,waiting:Hs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success",crew:Hs.attention};function Oj(n){const e=V.c(77),{session:t,chip:s,dotClassName:r,cardClassName:o,since:i,isActiveSession:l,proc:c,killingPids:u,customName:d,projectLabel:f,compact:m,onSelect:p,onKill:h,onResume:g,onPrefetch:x}=n,b=m===void 0?!1:m;let w;e[0]!==c||e[1]!==t.dirName?(w=Ob(un(t.dirName),c),e[0]=c,e[1]=t.dirName,e[2]=w):w=e[2];const v=w;let j;e[3]!==s||e[4]!==v||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(j=v?"Read-only":Jc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=v,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=j):j=e[9];const k=j,_=!!g&&!v,{onHoverStart:N,onHoverEnd:S}=iv(x),C=b?"px-2.5 py-2":"border px-2 py-2",E=l&&!b&&"ring-1 ring-ring";let T;e[10]!==o||e[11]!==C||e[12]!==E?(T=G("group relative w-full rounded-md text-left transition-colors",C,o,E),e[10]=o,e[11]=C,e[12]=E,e[13]=T):T=e[13];let $;e[14]!==b||e[15]!==l?($=b&&l&&a.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=b,e[15]=l,e[16]=$):$=e[16];const A=_&&"pr-20";let R;e[17]!==A?(R=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[17]=A,e[18]=R):R=e[18];let P;e[19]!==S||e[20]!==N||e[21]!==p||e[22]!==R?(P=a.jsx("button",{type:"button","data-attention-session":!0,onClick:p,onMouseEnter:N,onMouseLeave:S,onFocus:N,onBlur:S,className:R}),e[19]=S,e[20]=N,e[21]=p,e[22]=R,e[23]=P):P=e[23];const z=b&&"ring-0";let L;e[24]!==r||e[25]!==z?(L=G("size-1.5 shrink-0 rounded-full",r,z),e[24]=r,e[25]=z,e[26]=L):L=e[26];let I;e[27]!==L?(I=a.jsx("span",{className:L,"aria-hidden":"true"}),e[27]=L,e[28]=I):I=e[28];let M;e[29]!==d||e[30]!==t?(M=pi(t,d),e[29]=d,e[30]=t,e[31]=M):M=e[31];let F;e[32]!==M?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:M}),e[32]=M,e[33]=F):F=e[33];const U=b?"text-muted-foreground":s.className;let O;e[34]!==U?(O=G("shrink-0",U),e[34]=U,e[35]=O):O=e[35];const D=v?"Read-only":s.label;let B;e[36]!==O||e[37]!==D?(B=a.jsx(Fe,{variant:"outline",className:O,children:D}),e[36]=O,e[37]=D,e[38]=B):B=e[38];let q;e[39]!==b||e[40]!==t.lastActivityAt||e[41]!==t.lastModified||e[42]!==i?(q=!b&&a.jsx(Yxe,{iso:i??(t.lastActivityAt||t.lastModified)}),e[39]=b,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=i,e[43]=q):q=e[43];let W;e[44]!==I||e[45]!==F||e[46]!==B||e[47]!==q?(W=a.jsxs("span",{className:"flex items-center gap-1.5",children:[I,F,B,q]}),e[44]=I,e[45]=F,e[46]=B,e[47]=q,e[48]=W):W=e[48];let H;e[49]!==f?(H=a.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[49]=f,e[50]=H):H=e[50];let K;e[51]!==P||e[52]!==W||e[53]!==H?(K=a.jsxs(Zt,{render:P,children:[W,H]}),e[51]=P,e[52]=W,e[53]=H,e[54]=K):K=e[54];let Z;e[55]!==d||e[56]!==c||e[57]!==t||e[58]!==k?(Z=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(ov,{session:t,proc:c,statusLabel:k,customName:d})}),e[55]=d,e[56]=c,e[57]=t,e[58]=k,e[59]=Z):Z=e[59];let Y;e[60]!==K||e[61]!==Z?(Y=a.jsxs(Gt,{children:[K,Z]}),e[60]=K,e[61]=Z,e[62]=Y):Y=e[62];let J;e[63]!==_||e[64]!==g?(J=_&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:g,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Resume"]}),e[63]=_,e[64]=g,e[65]=J):J=e[65];let ee;e[66]!==v||e[67]!==u||e[68]!==h||e[69]!==c?(ee=c&&h&&!v&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:se=>h(c.pid,se),disabled:u.has(c.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${c.pid}`,"aria-label":`Kill process ${c.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[66]=v,e[67]=u,e[68]=h,e[69]=c,e[70]=ee):ee=e[70];let te;return e[71]!==Y||e[72]!==J||e[73]!==ee||e[74]!==T||e[75]!==$?(te=a.jsxs("div",{className:T,children:[$,Y,J,ee]}),e[71]=Y,e[72]=J,e[73]=ee,e[74]=T,e[75]=$,e[76]=te):te=e[76],te}function t0e(n){const e=V.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=G("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r||e[7]!==c?(u=a.jsx("span",{className:c,children:r}),e[6]=r,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==o?(d=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,u,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function n0e(n){const e=V.c(28),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,m=Pm(),[p,h]=y.useState(!1);let g;e[0]!==t.working||e[1]!==p?(g=p?t.working:t.working.slice(0,Gxe),e[0]=t.working,e[1]=p,e[2]=g):g=e[2];const x=g,b=t.working.length-x.length;let w;e[3]!==l?(w=C=>l[C.dirName]||Lx(C.cwd||xs(C.dirName)),e[3]=l,e[4]=w):w=e[4];const v=w;let j;e[5]!==s||e[6]!==o||e[7]!==u||e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==r||e[12]!==v||e[13]!==i?(j=C=>{const E=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:E,proc:r.get(C.sessionId),killingPids:o,customName:i[C.sessionId],projectLabel:v(C),onSelect:()=>c(C.dirName,C.fileName),onKill:m(C.access).stop?u:void 0,onPrefetch:f&&!E?()=>f(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=o,e[7]=u,e[8]=f,e[9]=c,e[10]=m,e[11]=r,e[12]=v,e[13]=i,e[14]=j):j=e[14];const k=j;let _;e[15]!==t.needsYou||e[16]!==d||e[17]!==m||e[18]!==k?(_=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(t0e,{dotClassName:Hs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{var $;const{session:E,reason:T}=C;return a.jsx(Oj,{...k(E),chip:Qxe(C),since:T==="crew"?($=C.crew)==null?void 0:$.longestWaitSince:void 0,dotClassName:e0e[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onResume:T==="deferred"&&d&&m(E.access).send?()=>d(E.sessionId,E.cwd,E.dirName):void 0},`${E.dirName}/${E.fileName}`)})]}),e[15]=t.needsYou,e[16]=d,e[17]=m,e[18]=k,e[19]=_):_=e[19];let N;e[20]!==t||e[21]!==b||e[22]!==k||e[23]!==x?(N=t.working.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between px-1",children:[a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),a.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:x.map(C=>a.jsx(Oj,{...k(C),chip:{label:Zxe(C,t),className:""},dotClassName:Hs.working,cardClassName:"hover:bg-accent/50",compact:!0},`${C.dirName}/${C.fileName}`))}),b>0&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(!0),className:"justify-start",children:[a.jsx(Et,{"data-icon":"inline-start"}),"Show ",b," more"]})]}),e[20]=t,e[21]=b,e[22]=k,e[23]=x,e[24]=N):N=e[24];let S;return e[25]!==_||e[26]!==N?(S=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[_,N]}),e[25]=_,e[26]=N,e[27]=S):S=e[27],S}function s0e(n){const e=V.c(49),{loading:t,isMobile:s,searchQuery:r,searchLoading:o,showArchived:i,archivedCount:l,groupCrews:c,onToggleGroupCrews:u,onSearchQueryChange:d,onToggleShowArchived:f,onRefresh:m}=n,p=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let h;e[0]!==d?(h=F=>d(F.target.value),e[0]=d,e[1]=h):h=e[1];let g;e[2]!==o||e[3]!==r||e[4]!==h?(g=a.jsx(Go,{type:"search",value:r,onChange:h,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":o}),e[2]=o,e[3]=r,e[4]=h,e[5]=g):g=e[5];let x;e[6]!==o?(x=a.jsx(Ar,{align:"inline-start",children:o?a.jsx(St,{className:"animate-spin"}):a.jsx(ss,{})}),e[6]=o,e[7]=x):x=e[7];let b;e[8]!==d||e[9]!==r?(b=r&&a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>d(""),"aria-label":"Clear session search",children:a.jsx(Mt,{"data-icon":"inline-start"})})}),e[8]=d,e[9]=r,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==x||e[13]!==b?(w=a.jsxs(Ko,{children:[g,x,b]}),e[11]=g,e[12]=x,e[13]=b,e[14]=w):w=e[14];let v;e[15]!==c||e[16]!==s||e[17]!==u?(v=u&&a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:"ghost",size:s?"icon-sm":"icon-xs",onClick:u,"aria-pressed":c,"aria-label":c?"List spawned sessions on their own":"Group spawned sessions",className:G(c&&"bg-accent text-accent-foreground")}),children:a.jsx(D4,{"data-icon":"inline-start"})}),a.jsx(Yt,{side:"bottom",children:c?"Sessions another session started are listed under it":"Group spawned sessions under the session that started them"})]}),e[15]=c,e[16]=s,e[17]=u,e[18]=v):v=e[18];const j=s?"icon-sm":"icon-xs",k=i?"Hide archived sessions":"Show archived sessions",_=i&&"bg-accent text-accent-foreground";let N;e[19]!==_?(N=G(_),e[19]=_,e[20]=N):N=e[20];let S;e[21]!==f||e[22]!==i||e[23]!==N||e[24]!==j||e[25]!==k?(S=a.jsx(Q,{variant:"ghost",size:j,onClick:f,"aria-pressed":i,"aria-label":k,className:N}),e[21]=f,e[22]=i,e[23]=N,e[24]=j,e[25]=k,e[26]=S):S=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Ns,{"data-icon":"inline-start"}),e[27]=C):C=e[27];let E;e[28]!==S?(E=a.jsx(Zt,{render:S,children:C}),e[28]=S,e[29]=E):E=e[29];const T=i?"Hide archived":"Show archived";let $;e[30]!==p||e[31]!==T?($=a.jsxs(Yt,{side:"bottom",children:[T," · ",p]}),e[30]=p,e[31]=T,e[32]=$):$=e[32];let A;e[33]!==E||e[34]!==$?(A=a.jsxs(Gt,{children:[E,$]}),e[33]=E,e[34]=$,e[35]=A):A=e[35];const R=s?"icon-sm":"icon-xs",P=t&&"animate-spin";let z;e[36]!==P?(z=G(P),e[36]=P,e[37]=z):z=e[37];let L;e[38]!==z?(L=a.jsx(Fn,{"data-icon":"inline-start",className:z}),e[38]=z,e[39]=L):L=e[39];let I;e[40]!==m||e[41]!==R||e[42]!==L?(I=a.jsx(Q,{variant:"ghost",size:R,onClick:m,"aria-label":"Refresh sessions",children:L}),e[40]=m,e[41]=R,e[42]=L,e[43]=I):I=e[43];let M;return e[44]!==A||e[45]!==I||e[46]!==w||e[47]!==v?(M=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[w,v,A,I]}),e[44]=A,e[45]=I,e[46]=w,e[47]=v,e[48]=M):M=e[48],M}const r0e=["first","second","third","fourth","fifth"];function o0e(n){const e=V.c(33),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,filterEmpty:d,onShowArchived:f,onRetry:m}=n,p=c===void 0?null:c,h=d===void 0?null:d,g=!!h;let x;e[0]!==p||e[1]!==l||e[2]!==r||e[3]!==s||e[4]!==g?(x=a0e({showEmpty:s,searching:r,focusedProject:p,hiddenArchivedCount:l,filtered:g}),e[0]=p,e[1]=l,e[2]=r,e[3]=s,e[4]=g,e[5]=x):x=e[5];const b=x;let w;e[6]!==t||e[7]!==m?(w=t&&a.jsxs(kt,{variant:"destructive",children:[a.jsx(er,{}),a.jsx(Xt,{children:"Could not load sessions"}),a.jsx(_t,{className:"truncate",children:t}),a.jsx(Hr,{children:a.jsx(Q,{variant:"outline",size:"xs",onClick:m,children:"Retry"})})]}),e[6]=t,e[7]=m,e[8]=w):w=e[8];let v;e[9]!==b||e[10]!==l||e[11]!==f?(v=b==="archived"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ns,{})}),a.jsx(zn,{children:"Everything is archived"}),a.jsx(Dn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]}),e[9]=b,e[10]=l,e[11]=f,e[12]=v):v=e[12];let j;e[13]!==b||e[14]!==p||e[15]!==l||e[16]!==u||e[17]!==f||e[18]!==r?(j=b==="focused"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(wg,{})}),a.jsx(zn,{children:r?`No matching sessions in ${p}`:`No sessions in ${p}`}),a.jsx(Dn,{children:l0e(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(jd,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(Q,{variant:"ghost",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[13]=b,e[14]=p,e[15]=l,e[16]=u,e[17]=f,e[18]=r,e[19]=j):j=e[19];const k=b==="filtered"&&h;let _;e[20]!==b||e[21]!==r?(_=b==="plain"&&a.jsx(Ln,{className:"min-h-56 px-4 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(wg,{})}),a.jsx(zn,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(Dn,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[20]=b,e[21]=r,e[22]=_):_=e[22];let N;e[23]!==o||e[24]!==i?(N=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:r0e.map(i0e)}),e[23]=o,e[24]=i,e[25]=N):N=e[25];let S;return e[26]!==N||e[27]!==w||e[28]!==v||e[29]!==j||e[30]!==k||e[31]!==_?(S=a.jsxs(a.Fragment,{children:[w,v,j,k,_,N]}),e[26]=N,e[27]=w,e[28]=v,e[29]=j,e[30]=k,e[31]=_,e[32]=S):S=e[32],S}function i0e(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Gn,{className:"size-2 shrink-0 rounded-full"}),a.jsx(Gn,{className:"h-4 flex-1"}),a.jsx(Gn,{className:"h-4 w-10"})]},n)}function a0e({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s,filtered:r}){return n?t!==null?"focused":!e&&s>0?"archived":!e&&r?"filtered":"plain":null}function l0e(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const ug=864e5;function c0e(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function u0e(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=c0e(e);return t>=s?"Today":t>=s-ug?"Yesterday":t>=s-6*ug?"Last 7 days":t>=s-29*ug?"Last 30 days":"Older"}const d0e=6,f0e={permission:"permission",question:"question",input:"input",plan:"plan",deferred:"deferred"},Lj={"needs-you":0,working:1,done:2};function m0e(n){const e=V.c(39),{host:t,members:s,counts:r,statusOf:o,open:i,onToggle:l,sessionNames:c,activeSessionKey:u,onSelectSession:d}=n,[f,m]=y.useState(!1);let p;if(e[0]!==u||e[1]!==r.needsYou||e[2]!==r.size||e[3]!==r.working||e[4]!==t||e[5]!==s||e[6]!==d||e[7]!==l||e[8]!==i||e[9]!==c||e[10]!==f||e[11]!==o){const h=new Map([t,...s].map(p0e)),g=I=>!I.crew||I.crew.parentId===t.sessionId||!h.has(I.crew.parentId);let x;e[13]!==g||e[14]!==o?(x=I=>g(I)||o(I).state==="needs-you",e[13]=g,e[14]=o,e[15]=x):x=e[15];const b=s.filter(x);let w;e[16]!==o?(w=(I,M)=>Lj[o(I).state]-Lj[o(M).state]||(o(I).state==="done"?Nr(M)-Nr(I):0),e[16]=o,e[17]=w):w=e[17];const v=[...b].sort(w);let j;e[18]!==o?(j=I=>o(I).state==="done",e[18]=o,e[19]=j):j=e[19];const k=v.filter(j),_=f?[]:k.slice(d0e),N=v.filter(I=>!_.includes(I)),S=`Crew of ${r.size}${r.needsYou?`, ${r.needsYou} need you`:""}${r.working?`, ${r.working} working`:""}`,C=i?`Hide crew: ${S}`:`Show crew: ${S}`,E=i&&"rotate-90";let T;e[20]!==E?(T=G("size-3 shrink-0 transition-transform duration-150",E),e[20]=E,e[21]=T):T=e[21];let $;e[22]!==T?($=a.jsx(it,{className:T,"aria-hidden":"true"}),e[22]=T,e[23]=$):$=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx("span",{className:"font-medium text-foreground",children:"Crew"}),e[24]=A):A=e[24];let R;e[25]!==r.size?(R=a.jsxs("span",{className:"tabular-nums",children:["· ",r.size]}),e[25]=r.size,e[26]=R):R=e[26];let P;e[27]!==r.needsYou?(P=r.needsYou>0&&a.jsxs("span",{className:"tabular-nums text-warning",children:["· ",r.needsYou," need you"]}),e[27]=r.needsYou,e[28]=P):P=e[28];let z;e[29]!==r.working?(z=r.working>0&&a.jsxs("span",{className:"tabular-nums",children:["· ",r.working," working"]}),e[29]=r.working,e[30]=z):z=e[30];let L;e[31]!==l||e[32]!==i||e[33]!==R||e[34]!==P||e[35]!==z||e[36]!==C||e[37]!==$?(L=a.jsxs("button",{type:"button",onClick:l,"aria-expanded":i,"aria-label":C,className:"flex w-full items-center gap-1.5 rounded-sm py-0.5 text-left text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[$,A,R,P,z]}),e[31]=l,e[32]=i,e[33]=R,e[34]=P,e[35]=z,e[36]=C,e[37]=$,e[38]=L):L=e[38],p=a.jsxs("div",{"data-crew-fold":!0,className:"mx-3 mb-2 ml-[26px] border-t border-border/60 pt-1.5",children:[L,i&&a.jsxs("ul",{className:"mt-1 ml-1.5 flex flex-col gap-px border-l border-border/70 pl-1.5",children:[N.map(I=>{var H;const M=o(I),F=R9(I.sessionId,s),U=I.crew?h.get(I.crew.parentId):void 0,O=u===`${I.dirName}/${I.fileName}`,D=Pd(I,{customName:c[I.sessionId],parent:U??t}),B=g0e(I,M),W=(!g(I)&&U?` · via ${Pd(U,{customName:c[U.sessionId],parent:h.get(((H=U.crew)==null?void 0:H.parentId)??"")??t})}`:"")||(F>0?` · ${F} ${F===1?"session":"sessions"}`:"");return a.jsx("li",{children:a.jsxs("button",{type:"button","data-crew-member":I.sessionId,"aria-current":O?"true":void 0,"aria-label":`${D}${W}, ${B}`,onClick:()=>d(I.dirName,I.fileName),className:G("flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",O&&"bg-accent"),children:[a.jsx("span",{className:G("size-1.5 shrink-0 rounded-full",h0e(M)),"aria-hidden":"true"}),a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[D,W&&a.jsx("span",{className:"text-muted-foreground/70",children:W})]}),a.jsx("span",{className:G("shrink-0 text-[11px] tabular-nums",M.state==="needs-you"?"text-warning":"text-muted-foreground/80"),children:B})]})},I.sessionId)}),_.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>m(!0),className:"rounded-sm px-1.5 py-1 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:["Show ",_.length," more done"]})})]})]}),e[0]=u,e[1]=r.needsYou,e[2]=r.size,e[3]=r.working,e[4]=t,e[5]=s,e[6]=d,e[7]=l,e[8]=i,e[9]=c,e[10]=f,e[11]=o,e[12]=p}else p=e[12];return p}function p0e(n){return[n.sessionId,n]}function h0e({state:n}){return n==="needs-you"?Hs.attention:n==="working"?Hs.working:"bg-muted-foreground/50"}function g0e(n,{state:e,need:t}){var o;const s=_r(n.lastActivityAt||n.lastModified);if(e==="needs-you")return`${f0e[t??"input"]} · ${s}`;if(e==="working")return m7(n);const r=(o=n.pullRequests)==null?void 0:o.at(-1);return r?`#${r.number} · ${s}`:s}const x0e={};function b0e(n){var Lr,_n;const e=V.c(172),{session:t,projectLabel:s,projectPath:r,showProject:o,isActiveSession:i,proc:l,killingPids:c,isNewlyCompleted:u,customName:d,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N,crew:S,lineage:C,sessionNames:E,activeSessionKey:T}=n,$=E===void 0?x0e:E,A=T===void 0?null:T,{isLive:R,isRunning:P,isNativeIdle:z,isDeferred:L,isReadOnly:I,isTeammate:M,isArchived:F,statusLabel:U,dotState:O,justFinished:D}=Lb(t,l,u),[B,q]=y.useState(!1);let W;e[0]!==d||e[1]!==t?(W=_N(t,d),e[0]=d,e[1]=t,e[2]=W):W=e[2];const H=W,K=j9(t,d),Z=o&&!C?s:void 0,Y=v0e(S==null?void 0:S.counts,O),J=S!==void 0&&Date.parse(S.activityAt)>Nr(t),ee=t.lastUserMessage||t.firstUserMessage,te=!!ee&&ee!==H,se=h7(t.sessionId,t.turnCount);let X;e[3]!==t.archivedReason?(X=Mx(t.archivedReason),e[3]=t.archivedReason,e[4]=X):X=e[4];const ne=X,ae=F?j&&{label:"Restore from archive",icon:Cf,run:()=>j(t)}:v&&!P&&{label:"Archive session",icon:Ns,run:()=>v(t)},ie=L&&!!N&&!I,re=!!m&&!!h,de=!!t.matchedPullRequestNumber||!!((Lr=t.pullRequests)!=null&&Lr.length),ce=ie||re||de;let oe;e[5]!==i||e[6]!==_||e[7]!==t.dirName||e[8]!==t.fileName?(oe=_&&!i?()=>_(t.dirName,t.fileName):void 0,e[5]=i,e[6]=_,e[7]=t.dirName,e[8]=t.fileName,e[9]=oe):oe=e[9];const{onHoverStart:fe,onHoverEnd:ue}=iv(oe);let le;e[10]!==N||e[11]!==B||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(le=()=>{!N||B||(q(!0),N(t.sessionId,t.cwd,t.dirName),setTimeout(()=>q(!1),3e3))},e[10]=N,e[11]=B,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=le):le=e[15];const pe=le,ge=!0,be=F||void 0,ve=G("motion-list-item group relative flex flex-col rounded-lg border transition-colors",y0e(i,D),F&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let Se;e[16]!==C?(Se=C&&a.jsxs("button",{type:"button","data-crew-lineage":!0,onClick:C.onOpenParent,"aria-label":`Open ${C.parentTitle}, which started this session`,className:"flex min-w-0 items-center gap-1.5 rounded-t-lg px-3 pl-[26px] pt-2.5 text-left text-[11px] leading-tight outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(mx,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":"true"}),a.jsx("span",{className:"truncate text-foreground/90",children:C.parentTitle}),C.rootTitle&&a.jsxs("span",{className:"truncate text-muted-foreground",children:["· ",C.rootTitle]})]}),e[16]=C,e[17]=Se):Se=e[17];let we;e[18]!==g||e[19]!==t.dirName||e[20]!==t.fileName?(we=()=>g(t.dirName,t.fileName),e[18]=g,e[19]=t.dirName,e[20]=t.fileName,e[21]=we):we=e[21];const Ee=i?"true":void 0,$e=C?"pt-1":"pt-2.5",Be=ce||S?"pb-1.5":"pb-2.5";let qe;e[22]!==$e||e[23]!==Be?(qe=G("flex w-full flex-col gap-1.5 rounded-lg px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",$e,Be),e[22]=$e,e[23]=Be,e[24]=qe):qe=e[24];let ze;e[25]!==ue||e[26]!==fe||e[27]!==we||e[28]!==Ee||e[29]!==qe?(ze=a.jsx("button",{type:"button","data-live-session":!0,onClick:we,onMouseEnter:fe,onMouseLeave:ue,onFocus:fe,onBlur:ue,"aria-current":Ee,className:qe}),e[25]=ue,e[26]=fe,e[27]=we,e[28]=Ee,e[29]=qe,e[30]=ze):ze=e[30];let Ie;e[31]!==Z||e[32]!==r?(Ie=Z&&a.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[a.jsx(wa,{projectPath:r,fallback:a.jsx(ra,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:Z})]}),e[31]=Z,e[32]=r,e[33]=Ie):Ie=e[33];let Me;e[34]!==Y?(Me=Y&&a.jsx("span",{"data-status-dot":Y,className:G("size-1.5 rounded-full",Hs[Y])}),e[34]=Y,e[35]=Me):Me=e[35];let Ue;e[36]!==Me?(Ue=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:Me}),e[36]=Me,e[37]=Ue):Ue=e[37];const De=K?"text-muted-foreground":"font-medium text-foreground";let Ke;e[38]!==De?(Ke=G("line-clamp-2 flex-1 text-sm leading-snug",De),e[38]=De,e[39]=Ke):Ke=e[39];let Ne;e[40]!==H||e[41]!==Ke?(Ne=a.jsx("span",{className:Ke,children:H}),e[40]=H,e[41]=Ke,e[42]=Ne):Ne=e[42];let Ae;e[43]!==Ue||e[44]!==Ne?(Ae=a.jsxs("span",{className:"flex items-start gap-2",children:[Ue,Ne]}),e[43]=Ue,e[44]=Ne,e[45]=Ae):Ae=e[45];let Qe;e[46]!==ee||e[47]!==te?(Qe=te&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:ee}),e[46]=ee,e[47]=te,e[48]=Qe):Qe=e[48];let Je;e[49]!==L||e[50]!==R||e[51]!==z||e[52]!==t.agentStatus||e[53]!==U?(Je=R&&!L&&U&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G(z?"text-success":wm(t.agentStatus)),children:U}),e[49]=L,e[50]=R,e[51]=z,e[52]=t.agentStatus,e[53]=U,e[54]=Je):Je=e[54];let ke;e[55]!==L?(ke=L&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[55]=L,e[56]=ke):ke=e[56];let We;e[57]!==H||e[58]!==M||e[59]!==t.agentName?(We=M&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),H!==t.agentName?t.agentName:"Agent"]}),e[57]=H,e[58]=M,e[59]=t.agentName,e[60]=We):We=e[60];let ye;e[61]!==t.access?(ye=a.jsx(o7,{access:t.access}),e[61]=t.access,e[62]=ye):ye=e[62];let Re;e[63]!==f?(Re=f&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Zr,{"data-icon":"inline-start"}),f]}),e[63]=f,e[64]=Re):Re=e[64];let Ve;e[65]!==t.gitBranch||e[66]!==f?(Ve=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(Zr,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[65]=t.gitBranch,e[66]=f,e[67]=Ve):Ve=e[67];let He;e[68]!==se?(He=se>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(vc,{className:"size-3 shrink-0","aria-hidden":"true"}),se," ",se===1?"turn":"turns"]}),e[68]=se,e[69]=He):He=e[69];let me;e[70]!==ne||e[71]!==F?(me=F&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ns,{className:"size-3 shrink-0","aria-label":ne,role:"img"}),"Archived"]}),e[70]=ne,e[71]=F,e[72]=me):me=e[72];let je;e[73]!==S||e[74]!==J||e[75]!==t?(je=J?a.jsxs("span",{"data-crew-activity":!0,className:G("ml-auto tabular-nums",EN({...t,lastActivityAt:S.activityAt})&&"text-success"),children:["crew active ",_r(S.activityAt)]}):a.jsx("span",{className:"ml-auto tabular-nums",children:_r(t.lastActivityAt||t.lastModified)}),e[73]=S,e[74]=J,e[75]=t,e[76]=je):je=e[76];let Xe;e[77]!==Je||e[78]!==ke||e[79]!==We||e[80]!==ye||e[81]!==Re||e[82]!==Ve||e[83]!==He||e[84]!==me||e[85]!==je?(Xe=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Je,ke,We,ye,Re,Ve,He,me,je]}),e[77]=Je,e[78]=ke,e[79]=We,e[80]=ye,e[81]=Re,e[82]=Ve,e[83]=He,e[84]=me,e[85]=je,e[86]=Xe):Xe=e[86];let tt;e[87]!==ze||e[88]!==Ie||e[89]!==Ae||e[90]!==Qe||e[91]!==Xe?(tt=a.jsxs(Zt,{render:ze,children:[Ie,Ae,Qe,Xe]}),e[87]=ze,e[88]=Ie,e[89]=Ae,e[90]=Qe,e[91]=Xe,e[92]=tt):tt=e[92];const dt=Z?void 0:s;let zt;e[93]!==d||e[94]!==l||e[95]!==t||e[96]!==U||e[97]!==dt||e[98]!==f?(zt=a.jsx(Yt,{side:"right",className:"max-w-[320px]",children:a.jsx(ov,{session:t,proc:l,statusLabel:U,customName:d,worktreeName:f,projectLabel:dt})}),e[93]=d,e[94]=l,e[95]=t,e[96]=U,e[97]=dt,e[98]=f,e[99]=zt):zt=e[99];let st;e[100]!==tt||e[101]!==zt?(st=a.jsxs(Gt,{children:[tt,zt]}),e[100]=tt,e[101]=zt,e[102]=st):st=e[102];let Tt;e[103]!==ie||e[104]!==pe||e[105]!==ce||e[106]!==re||e[107]!==h||e[108]!==B||e[109]!==t.matchedPullRequestNumber||e[110]!==t.pullRequests||e[111]!==m||e[112]!==p?(Tt=ce&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),re&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[a.jsx(tr,{"data-icon":"inline-start"}),m,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!p&&"rotate-90")})]}),ie&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:pe,disabled:B,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Resume"]})]}),e[103]=ie,e[104]=pe,e[105]=ce,e[106]=re,e[107]=h,e[108]=B,e[109]=t.matchedPullRequestNumber,e[110]=t.pullRequests,e[111]=m,e[112]=p,e[113]=Tt):Tt=e[113];let At;e[114]!==A||e[115]!==S||e[116]!==g||e[117]!==t||e[118]!==$?(At=S&&a.jsx(m0e,{host:t,members:S.members,counts:S.counts,statusOf:S.statusOf,open:S.open,onToggle:S.onToggle,sessionNames:$,activeSessionKey:A,onSelectSession:g}),e[114]=A,e[115]=S,e[116]=g,e[117]=t,e[118]=$,e[119]=At):At=e[119];let Qt;e[120]!==ae||e[121]!==S?(Qt=ae&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ae.run,className:G("absolute right-1.5 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",S?"top-1.5":"bottom-1.5"),title:ae.label,"aria-label":ae.label,children:a.jsx(ae.icon,{"data-icon":"inline-start"})}),e[120]=ae,e[121]=S,e[122]=Qt):Qt=e[122];let It;e[123]!==S||e[124]!==F||e[125]!==I||e[126]!==P||e[127]!==c||e[128]!==x||e[129]!==l?(It=l&&x&&P&&!F&&!I&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Is=>x(l.pid,Is),disabled:c.has(l.pid),className:G("absolute right-1.5 bg-popover text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",S?"top-1.5":"bottom-1.5"),title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[123]=S,e[124]=F,e[125]=I,e[126]=P,e[127]=c,e[128]=x,e[129]=l,e[130]=It):It=e[130];let Qn;e[131]!==Se||e[132]!==st||e[133]!==Tt||e[134]!==At||e[135]!==Qt||e[136]!==It||e[137]!==be||e[138]!==ve?(Qn=a.jsxs("div",{"data-session-card":ge,"data-archived":be,className:ve,children:[Se,st,Tt,At,Qt,It]}),e[131]=Se,e[132]=st,e[133]=Tt,e[134]=At,e[135]=Qt,e[136]=It,e[137]=be,e[138]=ve,e[139]=Qn):Qn=e[139];const kn=Qn;if(b||w||k||v||j){let Is;e[140]!==t.firstUserMessage||e[141]!==t.sessionId||e[142]!==t.slug?(Is=t.slug||((_n=t.firstUserMessage)==null?void 0:_n.slice(0,30))||t.sessionId.slice(0,12),e[140]=t.firstUserMessage,e[141]=t.sessionId,e[142]=t.slug,e[143]=Is):Is=e[143];let Ps;e[144]!==b||e[145]!==t.dirName||e[146]!==t.fileName?(Ps=b?()=>b(t.dirName,t.fileName):void 0,e[144]=b,e[145]=t.dirName,e[146]=t.fileName,e[147]=Ps):Ps=e[147];let ur;e[148]!==w||e[149]!==t?(ur=w?()=>w(t):void 0,e[148]=w,e[149]=t,e[150]=ur):ur=e[150];let dr;e[151]!==k||e[152]!==t.sessionId?(dr=k?ji=>k(t.sessionId,ji):void 0,e[151]=k,e[152]=t.sessionId,e[153]=dr):dr=e[153];let us;e[154]!==F||e[155]!==v||e[156]!==t?(us=v&&!F?()=>v(t):void 0,e[154]=F,e[155]=v,e[156]=t,e[157]=us):us=e[157];let $s;e[158]!==F||e[159]!==j||e[160]!==t?($s=j&&F?()=>j(t):void 0,e[158]=F,e[159]=j,e[160]=t,e[161]=$s):$s=e[161];let ki;return e[162]!==kn||e[163]!==d||e[164]!==P||e[165]!==Is||e[166]!==Ps||e[167]!==ur||e[168]!==dr||e[169]!==us||e[170]!==$s?(ki=a.jsx(sv,{sessionLabel:Is,customName:d,onDuplicate:Ps,onDelete:ur,onRename:dr,onArchive:us,onUnarchive:$s,archiveDisabled:P,children:kn}),e[162]=kn,e[163]=d,e[164]=P,e[165]=Is,e[166]=Ps,e[167]=ur,e[168]=dr,e[169]=us,e[170]=$s,e[171]=ki):ki=e[171],ki}return kn}function v0e(n,e){return n?n.needsYou>0||e==="attention"?"attention":n.working>0?"working":e:e}function y0e(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 bg-card hover:border-border hover:bg-accent"}function w0e(n){var ue;const e=V.c(87),{session:t,isActiveSession:s,proc:r,killingPids:o,isNewlyCompleted:i,customName:l,worktreeName:c,teammateCount:u,teammatesCollapsed:d,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:w,onPrefetchSession:v,onResumeSession:j}=n,{isLive:k,isRunning:_,isNativeIdle:N,isDeferred:S,isReadOnly:C,isTeammate:E,isArchived:T,statusLabel:$,dotState:A,justFinished:R}=Lb(t,r,i),[P,z]=y.useState(!1);let L;e[0]!==t.archivedReason?(L=Mx(t.archivedReason),e[0]=t.archivedReason,e[1]=L):L=e[1];const I=L;let M;e[2]!==l||e[3]!==t?(M=pi(t,l),e[2]=l,e[3]=t,e[4]=M):M=e[4];const F=M,U=T?b&&{label:"Restore from archive",icon:Cf,run:()=>b(t)}:x&&!_&&{label:"Archive session",icon:Ns,run:()=>x(t)};let O;e[5]!==s||e[6]!==v||e[7]!==t.dirName||e[8]!==t.fileName?(O=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[5]=s,e[6]=v,e[7]=t.dirName,e[8]=t.fileName,e[9]=O):O=e[9];const{onHoverStart:D,onHoverEnd:B}=iv(O);let q;e[10]!==j||e[11]!==P||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(q=le=>{le.stopPropagation(),!(!j||P)&&(z(!0),j(t.sessionId,t.cwd,t.dirName),setTimeout(()=>z(!1),3e3))},e[10]=j,e[11]=P,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=q):q=e[15];const W=q,H=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",S0e(s,R),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Z;e[20]!==B||e[21]!==D||e[22]!==K?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:D,onMouseLeave:B,onFocus:D,onBlur:B,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[20]=B,e[21]=D,e[22]=K,e[23]=Z):Z=e[23];let Y;e[24]!==F?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:F}),e[24]=F,e[25]=Y):Y=e[25];let J;e[26]!==S?(J=S&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=J):J=e[27];let ee;e[28]!==c?(ee=c&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Zr,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=ee):ee=e[29];let te;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==$||e[34]!==c?(te=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(ov,{session:t,proc:r,statusLabel:$,customName:l,worktreeName:c})}),e[30]=l,e[31]=r,e[32]=t,e[33]=$,e[34]=c,e[35]=te):te=e[35];let se;e[36]!==f||e[37]!==u||e[38]!==d?(se=!!u&&f&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:d?"Show team agents":"Hide team agents","aria-label":d?`Show ${u} team agents`:`Hide ${u} team agents`,"aria-expanded":!d,children:[a.jsx(tr,{"data-icon":"inline-start"}),u,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=se):se=e[39];let X;e[40]!==W||e[41]!==S||e[42]!==C||e[43]!==j||e[44]!==P?(X=S&&j&&!C&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:W,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Resume"]}),e[40]=W,e[41]=S,e[42]=C,e[43]=j,e[44]=P,e[45]=X):X=e[45];let ne;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(ne=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=ne):ne=e[48];let ae;e[49]!==I||e[50]!==T?(ae=T&&a.jsx(Ns,{className:"size-3 shrink-0 text-muted-foreground","aria-label":I,role:"img"}),e[49]=I,e[50]=T,e[51]=ae):ae=e[51];const ie=t.lastActivityAt||t.lastModified;let re;e[52]!==ie?(re=_r(ie),e[52]=ie,e[53]=re):re=e[53];let de;e[54]!==re?(de=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:re}),e[54]=re,e[55]=de):de=e[55];let ce;e[56]!==U?(ce=U&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:le=>{le.stopPropagation(),U.run()},className:"absolute right-0 top-0 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:U.label,"aria-label":U.label,children:a.jsx(U.icon,{"data-icon":"inline-start"})}),e[56]=U,e[57]=ce):ce=e[57];let oe;e[58]!==T||e[59]!==C||e[60]!==_||e[61]!==o||e[62]!==p||e[63]!==r?(oe=r&&p&&_&&!T&&!C&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:le=>p(r.pid,le),disabled:o.has(r.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${r.pid}`,"aria-label":`Kill process ${r.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[58]=T,e[59]=C,e[60]=_,e[61]=o,e[62]=p,e[63]=r,e[64]=oe):oe=e[64];const fe=a.jsxs("div",{className:H,"data-archived":T||void 0,children:[a.jsxs(Gt,{children:[a.jsxs(Zt,{render:Z,children:[a.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:A&&a.jsx("span",{"data-status-dot":A,className:G("size-1.5 rounded-full",Hs[A])})}),Y,E&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),F!==t.agentName?t.agentName:"Agent"]}),k&&!S&&$&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&wm(t.agentStatus)),children:$}),J,ee]}),te]}),se,X,ne,ae,de,ce,oe]});if(h||g||w||x||b){let le;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(le=t.slug||((ue=t.firstUserMessage)==null?void 0:ue.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=le):le=e[68];let pe;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(pe=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=pe):pe=e[72];let ge;e[73]!==g||e[74]!==t?(ge=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=ge):ge=e[75];let be;e[76]!==w||e[77]!==t.sessionId?(be=w?we=>w(t.sessionId,we):void 0,e[76]=w,e[77]=t.sessionId,e[78]=be):be=e[78];let ve;e[79]!==T||e[80]!==x||e[81]!==t?(ve=x&&!T?()=>x(t):void 0,e[79]=T,e[80]=x,e[81]=t,e[82]=ve):ve=e[82];let Se;return e[83]!==T||e[84]!==b||e[85]!==t?(Se=b&&T?()=>b(t):void 0,e[83]=T,e[84]=b,e[85]=t,e[86]=Se):Se=e[86],a.jsx(sv,{sessionLabel:le,customName:l,onDuplicate:pe,onDelete:ge,onRename:be,onArchive:ve,onUnarchive:Se,archiveDisabled:_,children:fe})}return fe}function S0e(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}const k0e={state:"done"};function j0e(n){const e=V.c(84),{sessions:t,pendingSession:s,older:r,showProject:o,groupCrews:i,lineageSessions:l,memberStatusOf:c,activeSessionKey:u,procBySession:d,killingPids:f,newlyCompleted:m,sessionNames:p,projectNames:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N}=n,S=i===void 0?!0:i,C=c===void 0?C0e:c,E=Pm();let T,$,A,R;if(e[0]!==S||e[1]!==t){T=S?Fx(t):{topLevel:t,crewOf:new Map},$=N9(T.topLevel);const ue=be=>{const ve=T.crewOf.get(be.sessionId);return ve?zy(be,ve):be.lastActivityAt||be.lastModified},le=new Map($.topLevelSessions.map(be=>[{...be,lastActivityAt:ue(be)},be]));R=Ia([...le.keys()]).map(be=>le.get(be));const pe=Date.now(),ge=R.map(be=>u0e(ue(be),pe));A=ge.map((be,ve)=>be===ge[ve-1]?null:be),e[0]=S,e[1]=t,e[2]=T,e[3]=$,e[4]=A,e[5]=R}else T=e[2],$=e[3],A=e[4],R=e[5];const P=A;let z;e[6]!==T.crewOf||e[7]!==P||e[8]!==$.teammatesByLead||e[9]!==R?(z={topLevelSessions:R,teammatesByLead:$.teammatesByLead,crewOf:T.crewOf,shelves:P},e[6]=T.crewOf,e[7]=P,e[8]=$.teammatesByLead,e[9]=R,e[10]=z):z=e[10];const{topLevelSessions:L,teammatesByLead:I,crewOf:M,shelves:F}=z;let U,O;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=sn("live-sessions-open-crews"),O=[],e[11]=U,e[12]=O):(U=e[11],O=e[12]);const[D,B]=jr(U,O);let q;e[13]!==D?(q=Array.isArray(D)?D:[],e[13]=D,e[14]=q):q=e[14];let W;e[15]!==q?(W=new Set(q),e[15]=q,e[16]=W):W=e[16];const H=W;let K;e[17]!==D||e[18]!==B?(K=ue=>{const le=Array.isArray(D)?D:[];B(le.includes(ue)?le.filter(pe=>pe!==ue):[...le,ue])},e[17]=D,e[18]=B,e[19]=K):K=e[19];const Z=K;let Y;e[20]!==l?(Y=l??[],e[20]=l,e[21]=Y):Y=e[21];let J;e[22]!==t||e[23]!==Y?(J=new Map([...Y,...t].map(N0e)),e[22]=t,e[23]=Y,e[24]=J):J=e[24];const ee=J;let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=new Set,e[25]=te):te=e[25];const[se,X]=y.useState(te);let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=ue=>{X(le=>{const pe=new Set(le);return pe.has(ue)?pe.delete(ue):pe.add(ue),pe})},e[26]=ne):ne=e[26];const ae=ne;let ie;e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==v||e[31]!==w||e[32]!==b||e[33]!==x||e[34]!==_||e[35]!==k||e[36]!==N||e[37]!==g||e[38]!==j||e[39]!==E||e[40]!==d||e[41]!==p?(ie=ue=>{const le=E(ue.access);return{session:ue,isActiveSession:u===dg(ue),proc:d.get(ue.sessionId),killingPids:f,isNewlyCompleted:m.has(ue.sessionId),customName:p[ue.sessionId],onSelectSession:g,onKill:le.stop?x:void 0,onDuplicateSession:b,onDeleteSession:le.delete?w:void 0,onArchiveSession:le.archive?v:void 0,onUnarchiveSession:le.archive?j:void 0,onRenameSession:k,onPrefetchSession:_,onResumeSession:le.send?N:void 0}},e[27]=u,e[28]=f,e[29]=m,e[30]=v,e[31]=w,e[32]=b,e[33]=x,e[34]=_,e[35]=k,e[36]=N,e[37]=g,e[38]=j,e[39]=E,e[40]=d,e[41]=p,e[42]=ie):ie=e[42];const re=ie;let de;e[43]!==s?(de=s&&a.jsx(T0e,{firstMessage:s.firstMessage}),e[43]=s,e[44]=de):de=e[44];let ce;if(e[45]!==u||e[46]!==se||e[47]!==M||e[48]!==ee||e[49]!==C||e[50]!==g||e[51]!==H||e[52]!==h||e[53]!==re||e[54]!==p||e[55]!==F||e[56]!==o||e[57]!==I||e[58]!==Z||e[59]!==L){let ue;e[61]!==u||e[62]!==se||e[63]!==M||e[64]!==ee||e[65]!==C||e[66]!==g||e[67]!==H||e[68]!==h||e[69]!==re||e[70]!==p||e[71]!==F||e[72]!==o||e[73]!==I||e[74]!==Z?(ue=(le,pe)=>{const ge=dg(le),be=le.cwd??xs(le.dirName),ve=Cr(be),Se=h[le.dirName]??Nl(le),we=I.get(le.sessionId),Ee=se.has(le.sessionId),$e=F[pe],Be=M.get(le.sessionId),qe=Be&&{members:Be,counts:Ux(Be,C),statusOf:C,activityAt:zy(le,Be),open:H.has(le.sessionId),onToggle:()=>Z(le.sessionId)},ze=a.jsx(b0e,{...re(le),worktreeName:ve==null?void 0:ve.worktreeName,projectLabel:Se,projectPath:(ve==null?void 0:ve.parentPath)??be,showProject:o,teammateCount:we==null?void 0:we.length,teammatesCollapsed:we?Ee:void 0,onToggleTeammates:we?()=>ae(le.sessionId):void 0,crew:qe,lineage:_0e(le,ee,p,g),sessionNames:p,activeSessionKey:u});return a.jsxs(y.Fragment,{children:[$e&&a.jsx(E0e,{label:$e}),we&&!Ee?a.jsxs("div",{className:"flex flex-col gap-px",children:[ze,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:we.map(Ie=>a.jsx(w0e,{...re(Ie)},dg(Ie)))})]}):ze]},ge)},e[61]=u,e[62]=se,e[63]=M,e[64]=ee,e[65]=C,e[66]=g,e[67]=H,e[68]=h,e[69]=re,e[70]=p,e[71]=F,e[72]=o,e[73]=I,e[74]=Z,e[75]=ue):ue=e[75],ce=L.map(ue),e[45]=u,e[46]=se,e[47]=M,e[48]=ee,e[49]=C,e[50]=g,e[51]=H,e[52]=h,e[53]=re,e[54]=p,e[55]=F,e[56]=o,e[57]=I,e[58]=Z,e[59]=L,e[60]=ce}else ce=e[60];let oe;e[76]!==r.canLoad||e[77]!==r.load||e[78]!==r.loading?(oe=r.canLoad&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(z4,{"data-icon":"inline-start"}),"Load older sessions"]}),e[76]=r.canLoad,e[77]=r.load,e[78]=r.loading,e[79]=oe):oe=e[79];let fe;return e[80]!==de||e[81]!==ce||e[82]!==oe?(fe=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[de,ce,oe]}),e[80]=de,e[81]=ce,e[82]=oe,e[83]=fe):fe=e[83],fe}function N0e(n){return[n.sessionId,n]}function C0e(){return k0e}function _0e(n,e,t,s){const r=n.crew;if(!r)return;const o=$d(r.parentId,e,t)??r.parentTitle??"Another session",i=r.rootId===r.parentId?void 0:$d(r.rootId,e,t)??r.rootTitle,l=e.get(r.parentId);return{parentTitle:o,...i&&i!==o&&{rootTitle:i},onOpenParent:l?()=>s(l.dirName,l.fileName):()=>void cm(r.parentId)}}function E0e(n){const e=V.c(2),{label:t}=n;let s;return e[0]!==t?(s=a.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function T0e(n){const e=V.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(St,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const r=t||"New session";let o;return e[1]!==r?(o=a.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:r})]}),e[1]=r,e[2]=o):o=e[2],o}function dg(n){return`${n.dirName}/${n.fileName}`}function wo(n,e){return`${n} ${n===1?e:`${e}s`}`}function A0e(n){if(!n)return"No sessions listed";const e=wo(n.total,"session"),t=n.live>0?`${e}, ${n.live} live`:e,s=[n.crews>0&&wo(n.crews,"crew"),n.worktrees>0&&wo(n.worktrees,"worktree")].filter(Boolean);return[t,...s].join(" · ")}function Mj(n){const e=V.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=G("flex shrink-0 items-center gap-1 font-medium text-warning",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=i):i=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==o?(l=a.jsxs("span",{className:o,"aria-label":s,children:[i,t]}),e[3]=t,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function I0e(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function P0e(n){const e=V.c(72),{options:t,value:s,focused:r,totalSessions:o,crewCount:i,onChange:l,onNewSession:c,creatingSession:u,onRenameProject:d,archivableCount:f,onArchiveIdle:m}=n,p=i===void 0?0:i,[h,g]=y.useState(!1),x=(r==null?void 0:r.customName)??s;let b;e[0]!==p||e[1]!==r||e[2]!==t.length||e[3]!==o||e[4]!==s?(b=s===null?`${wo(t.length,"project")}, ${wo(o,"session")}${p>0?` · ${wo(p,"crew")}`:""}`:A0e(r),e[0]=p,e[1]=r,e[2]=t.length,e[3]=o,e[4]=s,e[5]=b):b=e[5];const w=b,v=I0e(t,s);let j;e[6]!==l?(j=ee=>{l(ee),g(!1)},e[6]=l,e[7]=j):j=e[7];const k=j,_=s===null?"Choose a project to focus on":`Focused on ${x}. Change project`;let N;e[8]!==(r==null?void 0:r.cwd)||e[9]!==s?(N=s===null?a.jsx(jd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(wa,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(ra,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[8]=r==null?void 0:r.cwd,e[9]=s,e[10]=N):N=e[10];const S=s===null?"All projects":x;let C;e[11]!==S?(C=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:S}),e[11]=S,e[12]=C):C=e[12];let E;e[13]!==w?(E=a.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:w}),e[13]=w,e[14]=E):E=e[14];let T;e[15]!==C||e[16]!==E?(T=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,E]}),e[15]=C,e[16]=E,e[17]=T):T=e[17];let $;e[18]!==v?($=v>0&&a.jsx(Mj,{count:v,label:v===1?"1 session in another project is waiting for you":`${v} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[18]=v,e[19]=$):$=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(Ea,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[20]=A):A=e[20];let R;e[21]!==$||e[22]!==_||e[23]!==N||e[24]!==T?(R=a.jsxs(Tc,{"aria-label":_,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[N,T,$,A]}),e[21]=$,e[22]=_,e[23]=N,e[24]=T,e[25]=R):R=e[25];const P=R;let z;e[26]!==f||e[27]!==r||e[28]!==m||e[29]!==d||e[30]!==P?(z=r&&d?a.jsx(u7,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:f,onArchiveIdle:m,onRename:ee=>d(r.dirName,ee),children:P}):P,e[26]=f,e[27]=r,e[28]=m,e[29]=d,e[30]=P,e[31]=z):z=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(a0,{placeholder:"Find a project",autoFocus:!0}),e[32]=L):L=e[32];let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx(Ez,{children:"No project matches."}),e[33]=I):I=e[33];const M=s===null;let F;e[34]!==k?(F=()=>k(null),e[34]=k,e[35]=F):F=e[35];let U,O;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(jd,{className:"text-muted-foreground","aria-hidden":"true"}),O=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[36]=U,e[37]=O):(U=e[36],O=e[37]);let D;e[38]!==o?(D=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[38]=o,e[39]=D):D=e[39];let B;e[40]!==M||e[41]!==F||e[42]!==D?(B=a.jsx(xi,{children:a.jsxs(To,{value:"all-projects","data-checked":M,onSelect:F,className:"gap-2.5",children:[U,O,D]})}),e[40]=M,e[41]=F,e[42]=D,e[43]=B):B=e[43];let q;if(e[44]!==t||e[45]!==k||e[46]!==s){let ee;e[48]!==k||e[49]!==s?(ee=te=>a.jsxs(To,{value:te.key,keywords:te.customName?[te.customName]:void 0,"data-checked":s===te.key,onSelect:()=>k(te.key),className:"gap-2.5",children:[a.jsx(wa,{projectPath:te.cwd??null,fallback:a.jsx(ra,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsx("span",{className:"truncate",children:te.customName??te.key}),te.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:te.key})]}),te.needsYou>0&&a.jsx(Mj,{count:te.needsYou,label:`${wo(te.needsYou,"session")} waiting for you`,className:"text-xs"}),te.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":wo(te.live,"live session"),children:[a.jsx(Sm,{className:"size-1.5","aria-hidden":"true"}),te.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:te.total})]},te.key),e[48]=k,e[49]=s,e[50]=ee):ee=e[50],q=t.map(ee),e[44]=t,e[45]=k,e[46]=s,e[47]=q}else q=e[47];let W;e[51]!==q?(W=a.jsx(xi,{heading:"Projects",children:q}),e[51]=q,e[52]=W):W=e[52];let H;e[53]!==B||e[54]!==W?(H=a.jsx(Xx,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(Ic,{children:[L,a.jsxs(Pc,{children:[I,B,W]})]})}),e[53]=B,e[54]=W,e[55]=H):H=e[55];let K;e[56]!==h||e[57]!==z||e[58]!==H?(K=a.jsxs(Ec,{open:h,onOpenChange:g,children:[z,H]}),e[56]=h,e[57]=z,e[58]=H,e[59]=K):K=e[59];let Z;e[60]!==u||e[61]!==r||e[62]!==x||e[63]!==c?(Z=r&&c&&a.jsx(Q,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:u,onClick:()=>c(r.dirName,r.cwd),"aria-label":`New session in ${x}`,children:u?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(kr,{"data-icon":"inline-start"})}),e[60]=u,e[61]=r,e[62]=x,e[63]=c,e[64]=Z):Z=e[64];let Y;e[65]!==u||e[66]!==c?(Y=c&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",disabled:u,onClick:$0e,"aria-label":"Start a session in a folder",title:"Start a session in a folder",children:a.jsx(wc,{"data-icon":"inline-start"})}),e[65]=u,e[66]=c,e[67]=Y):Y=e[67];let J;return e[68]!==K||e[69]!==Z||e[70]!==Y?(J=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[K,Z,Y]}),e[68]=K,e[69]=Z,e[70]=Y,e[71]=J):J=e[71],J}function $0e(){return AI()}function R0e(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function O0e(n){const e=Cr(n.cwd??xs(n.dirName));if(!e)return{dirName:n.dirName,cwd:n.cwd};const{parentPath:t}=e;return{dirName:vs(n.dirName).dirName.encode(t),cwd:t}}function L0e(n){const e=n.map(t=>{var s;return(s=Cr(t.cwd??xs(t.dirName)))==null?void 0:s.worktreeName});return new Set(e.filter(Boolean)).size}function M0e(n,e,t,s,r=new Map){return[...T9(n).entries()].map(([o,i])=>{const l=C9(i),c=O0e(l);return{key:o,customName:t[c.dirName],...c,dirNames:[...new Set(i.map(u=>u.dirName))],total:i.length,live:R0e(i,e),needsYou:i.filter(u=>s.has(u.sessionId)).length,worktrees:L0e(i),crews:i.filter(u=>r.has(u.sessionId)).length}})}function zj(n,e,t=!1){if(e===null)return n;if(!t)return n.filter(i=>Nl(i)===e);const{topLevel:s,crewOf:r}=Fx(n),o=new Set;for(const i of s)if(Nl(i)===e){o.add(i);for(const l of r.get(i.sessionId)??[])o.add(l)}for(const i of r.values())for(const l of i)Nl(l)===e&&o.add(l);return n.filter(i=>o.has(i))}function z0e(n,e){if(e.length===0)return n;const t=new Set(n.map(r=>r.sessionId)),s=e.filter(r=>!t.has(r.sessionId));return s.length===0?n:Ia([...n,...s])}const Dj={key:null,sessions:[],loading:!1,loaded:!1};function D0e(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function F0e(n,e,t){const s=V.c(14),r=n?`${e?"a":"l"}:${t.key??""}:${n.key}`:null,[o,i]=y.useState(Dj),l=o.key===r?o:Dj;let c;s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==n?(c=async()=>{if(r===null||!n)return;i(g=>g.key===r?{...g,loading:!0}:{key:r,sessions:[],loading:!0,loaded:!1});const h=Jr();try{const x=(await Promise.all(D0e(n,e).map(async b=>{const w=await Ce(zf(b,t));if(!w.ok)throw new Error(`Could not load older sessions (${w.status})`);const v=await w.json();return Array.isArray(v)?v:[]}))).flat();la(x,h),i(b=>b.key===r?{key:r,sessions:x,loading:!1,loaded:!0}:b)}catch(g){const x=g;i(b=>b.key===r?{...b,loading:!1}:b),Kn.error(x instanceof Error?x.message:"Could not load older sessions")}},s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=c):c=s[4];const u=c,{loaded:d}=l;let f,m;s[5]!==u||s[6]!==d?(f=()=>{if(d)return Df(()=>void u())},m=[d,u],s[5]=u,s[6]=d,s[7]=f,s[8]=m):(f=s[7],m=s[8]),y.useEffect(f,m);let p;return s[9]!==l.loading||s[10]!==l.sessions||s[11]!==u||s[12]!==d?(p={sessions:l.sessions,loading:l.loading,loaded:d,load:u},s[9]=l.loading,s[10]=l.sessions,s[11]=u,s[12]=d,s[13]=p):p=s[13],p}const U0e={key:"all"},B0e=y.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:r,onNewSession:o,creatingSession:i,pendingSession:l,refreshRef:c,onPrefetchSession:u}){const{names:d,rename:f}=Ff(),{names:m,rename:p}=nv(),h=sb(),g=Nn("terminal"),x=Nn("killAny"),b=Pm(),w=Mf(),{Control:v,Empty:j}=$r().sessionListFilter??{},{sessions:k,procBySession:_,newlyCompleted:N,loading:S,error:C,refresh:E,removeSession:T,acknowledgeCompleted:$,showArchived:A,setShowArchived:R,setSearchActive:P,archivedCount:z}=Kx(),{awaitingPermission:L,awaitingQuestion:I,awaitingElicitation:M,awaitingDialog:F,awaitingPlan:U}=Spe(),O=y.useMemo(()=>new Set([...M,...F]),[M,F]),[D,B]=y.useState(new Set),[q,W]=y.useState(""),[H,K]=jr(sn("live-sessions-project-scope"),null),[Z,Y]=jr(sn("live-sessions-group-crews"),!0),J=Z!==!1,ee=!!q.trim(),te=J&&!ee,se=A||ee;y.useEffect(()=>(P(ee),()=>P(!1)),[ee,P]);const X=y.useRef(new Set),ne=y.useRef(!1),ae=y.useCallback((ye,Re)=>{if(!ne.current)return;const Ve=setTimeout(()=>{X.current.delete(Ve),ne.current&&ye()},Re);X.current.add(Ve)},[]);y.useEffect(()=>{const ye=X.current;return ne.current=!0,()=>{ne.current=!1;for(const Re of ye)clearTimeout(Re);ye.clear()}},[]),y.useEffect(()=>{if(c)return c.current=E,()=>{c.current===E&&(c.current=null)}},[E,c]);const ie=rv(),re=d7(q,w),de=y.useMemo(()=>E9(k,se),[k,se]),ce=se?0:z,oe=y.useMemo(()=>({awaitingPermission:L,awaitingQuestion:I,awaitingPrompt:O,awaitingPlan:U}),[L,I,O,U]),fe=y.useCallback(ye=>TN(ye,_,oe),[_,oe]),ue=y.useMemo(()=>Fx(de),[de]),le=y.useMemo(()=>{const ye=Ve=>b(Ve.access).canInteract,Re=Bxe(ue.topLevel,_,N,L,I,O,U,ye);return Wxe(Re,ue.topLevel,ue.crewOf,fe,ye)},[ue,_,N,L,I,O,U,b,fe]),pe=y.useMemo(()=>new Set(le.needsYou.map(ye=>ye.session.sessionId)),[le]),ge=J?ue.topLevel:de,be=y.useMemo(()=>M0e(ge,_,m,pe,ue.crewOf),[ge,_,m,pe,ue.crewOf]),ve=H===null?null:be.find(ye=>ye.key===H)??null,Se=(ve==null?void 0:ve.customName)??H,we=F0e(H===null?U0e:ve,se,w),Ee=y.useMemo(()=>z0e(zj(de,H,te),we.sessions),[de,H,te,we.sessions]),$e=y.useMemo(()=>ee?Ee.filter(ye=>{const Re=d[ye.sessionId],Ve=m[ye.dirName];return a7(ye,q,[Re,Ve])}):Ee,[Ee,ee,q,d,m]),Be=y.useMemo(()=>re.results?zj(re.results,H,te):$e,[re.results,H,te,$e]),qe=le.needsYou.length>0||le.working.length>0,ze=!ee&&qe&&H===null,Ie=y.useMemo(()=>H===null?[]:Ee.filter(ye=>!ye.archived&&b(ye.access).archive&&!zx(ye,_.get(ye.sessionId))),[H,Ee,_,b]),Me=H===null||l!=null&&Lx(l.cwd||xs(l.dirName))===H,Ue=y.useRef(!1);y.useEffect(()=>{if(Ue.current||!u||k.length===0)return;Ue.current=!0;const ye=Ia(k).slice(0,3),Re=globalThis,Ve=()=>{for(const je of ye)u(je.dirName,je.fileName)};let He=null,me=null;return typeof Re.requestIdleCallback=="function"?He=Re.requestIdleCallback(Ve,{timeout:1500}):me=setTimeout(Ve,300),()=>{He!=null&&typeof Re.cancelIdleCallback=="function"&&Re.cancelIdleCallback(He),me!=null&&clearTimeout(me)}},[k,u]);const De=y.useCallback(async(ye,Re)=>{Re.stopPropagation(),B(Ve=>new Set(Ve).add(ye));try{if(!(await Ce("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:ye})})).ok)throw new Error("Could not stop session");ae(E,1500)}catch{Kn.error("Could not stop session")}ae(()=>{B(Ve=>{const He=new Set(Ve);return He.delete(ye),He})},2e3)},[E,ae]);y.useEffect(()=>{const ye=k.find(Re=>`${Re.dirName}/${Re.fileName}`===e);ye&&N.has(ye.sessionId)&&$(ye.sessionId)},[e,k,N,$]);const Ke=y.useCallback(async ye=>{await(r==null?void 0:r(ye.dirName,ye.fileName))&&T(ye.sessionId)},[r,T]),Ne=FI(),Ae=y.useCallback(ye=>{Ne([ye.sessionId],!0,`Archived “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Qe=y.useCallback(ye=>{Ne([ye.sessionId],!1,`Restored “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Je=y.useCallback(ye=>{if(ye.length===0)return;const Re=ye.map(Ve=>Ve.sessionId);Ne(Re,!0,`Archived ${Re.length} ${Re.length===1?"session":"sessions"}`)},[Ne]),ke=y.useCallback((ye,Re,Ve)=>{const{command:He,args:me}=dR(un(Ve),ye),je=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:je,name:`Resume ${ye.slice(0,8)}`,command:He,args:me,cwd:Re??void 0,metadata:{type:"terminal"}}),ae(E,3e3)},[h,E,ae]),We={activeSessionKey:e,procBySession:_,killingPids:D,newlyCompleted:N,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onDuplicateSession:s,onDeleteSession:r?Ke:void 0,onArchiveSession:Ae,onUnarchiveSession:Qe,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?ke:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(s0e,{loading:S,isMobile:ie,searchQuery:q,searchLoading:re.loading,showArchived:A,archivedCount:z,groupCrews:J,onToggleGroupCrews:()=>Y(!J),onSearchQueryChange:W,onToggleShowArchived:()=>R(!A),onRefresh:()=>{Fxe(),E()}}),v&&a.jsx(v,{}),a.jsx(P0e,{options:be,value:H,focused:ve,totalSessions:ge.length,crewCount:J?ue.crewOf.size:0,onChange:K,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:Ie.length,onArchiveIdle:()=>Je(Ie)}),a.jsx(Vc,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(o0e,{fetchError:re.error??C,showEmpty:Be.length===0&&!(l&&Me)&&!S&&!re.loading&&!C&&!re.error,searching:ee,loading:S||re.loading,sessionCount:re.active?Be.length:de.length,hiddenArchivedCount:ce,focusedProject:Se,onShowAllProjects:()=>K(null),filterEmpty:w.key!==null&&j?a.jsx(j,{className:"min-h-56 px-4 py-8"}):null,onShowArchived:()=>R(!0),onRetry:re.error?re.refresh:E}),ze&&a.jsx(n0e,{groups:le,activeSessionKey:e,procBySession:_,killingPids:D,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onResumeSession:g?ke:void 0,onPrefetchSession:u}),a.jsx(j0e,{...We,sessions:Be,pendingSession:Me?l:null,showProject:H===null,groupCrews:te,lineageSessions:de,memberStatusOf:fe,older:{canLoad:(H===null||!!ve)&&!we.loaded&&!ee,loading:we.loading,load:we.load}})]})})]})}),W0e=y.memo(function(e){const t=V.c(16),{activeSessionKey:s,onSelectSession:r,onNewSession:o,creatingSession:i,isMobile:l,onDuplicateSession:c,onDeleteSession:u,pendingSession:d,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==i||t[4]!==f||t[5]!==u||t[6]!==c||t[7]!==o||t[8]!==m||t[9]!==r||t[10]!==d?(x=a.jsx(B0e,{activeSessionKey:s,onSelectSession:r,onDuplicateSession:c,onDeleteSession:u,onNewSession:o,creatingSession:i,pendingSession:d,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=i,t[4]=f,t[5]=u,t[6]=c,t[7]=o,t[8]=m,t[9]=r,t[10]=d,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=a.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),q0e=y.lazy(()=>nt(()=>import("./MissionHome-CZpQbWs3.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.MissionHome})));function Rm(n){const e=V.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pn,{className:"size-4"}),e[0]=s):s=e[0];let r;return e[1]!==t?(r=a.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]=r):r=e[2],r}function g7(n){const e=V.c(12),{navigation:t,mobile:s,header:r}=n,o=s===void 0?!1:s,{sessionSource:i}=jt(),l=i?`${i.dirName}/${i.fileName}`:null;let c;return e[0]!==l||e[1]!==r||e[2]!==o||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=a.jsx(W0e,{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:o,header:r}),e[0]=l,e[1]=r,e[2]=o,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 V0e(n){const e=V.c(8),{navigation:t}=n,{state:s}=Sn();let r;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?(r=a.jsx(Dxe,{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]=r):r=e[7],r}function bf(n){const e=V.c(7),{navigation:t,showProjectHistory:s}=n,r=s===void 0?!1:s,{state:o,config:i}=Sn(),[l,c]=y.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Rm,{label:"Loading Mission Control…"}),e[0]=u):u=e[0];let d;return e[1]!==l||e[2]!==i||e[3]!==t||e[4]!==r||e[5]!==o?(d=a.jsx(y.Suspense,{fallback:u,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:l||r&&o.dashboardProject?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-4 pt-12",children:a.jsxs(Q,{variant:"ghost",size:"sm",onClick:()=>{t.onSelectProject(null),c(!1)},children:[a.jsx(yx,{"data-icon":"inline-start"})," Mission Control"]})}),a.jsx(V0e,{navigation:t})]}):a.jsx(q0e,{onOpenSession:t.actions.handleDashboardSelect,onBrowseProjects:()=>c(!0),start:{defaultAgentKind:i.defaultAgentKind,model:t.newSessionModel,onStart:t.onStartNewSessionWith}})})}),e[1]=l,e[2]=i,e[3]=t,e[4]=r,e[5]=o,e[6]=d):d=e[6],d}function x7(n){const e=V.c(8),{view:t,onClose:s}=n,{Component:r}=t,o=`Loading ${t.label}…`;let i;e[0]!==o?(i=a.jsx(Rm,{label:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==r||e[3]!==s?(l=a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(r,{onClose:s})}),e[2]=r,e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l?(c=a.jsx(y.Suspense,{fallback:i,children:l}),e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function H0e({mainView:n,hasSession:e,pendingDirName:t,extensionViewAvailable:s}){return n==="config"?"config":n==="mission"?"mission":n==="extension"&&s?"extension":e?"session":t?"pending":"dashboard"}function K0e({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function b7({path:n,text:e,startLine:t,endLine:s,comment:r}){if(!e)return`@${n}`;const o=e.includes("```")?"````":"```",i=t===s?`line ${t}`:`lines ${t}-${s}`;return`${r?`Review request: ${r}
|
|
469
|
+
`||t.length>0)&&s++,t=[],i+=(l==="&"||l==="|")&&(d===l||f&&d==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(i)))return o();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(i));if(c){for(i+=c[0].length;/[^\S\n]/.test(n[i]??"");)i++;const d=jj(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=jj(n,i);if(!u||u.end===i)return o();t.push(u),i=u.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:r===0}}const yl="agent-browser",w1e=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),S1e=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),k1e=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),j1e=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,N1e=/^[A-Za-z_][A-Za-z_\d]*=/;function KI(n){return n.slice(n.lastIndexOf("/")+1)}function C1e(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(N1e.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||j1e.test(o.value))return null;const i=KI(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=w1e.get(i);if(!l)return t;for(t++;(r=n[t])!=null&&r.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function _1e(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=h1e,i=null;for(let l=0;l<r.length;l++){const c=r[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(i!==null)return null;const u=c.value==="--session"?r[++l]:c;if(o=c.value==="--session"?u==null?void 0:u.value:c.value.slice(10),!o||!b1e(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:yl+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function E1e(n){var l;const{commands:e,complete:t}=y1e(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(yl)));if(!t)return{invocations:s,ambiguous:r||n.includes(yl)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(yl))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=C1e(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=KI(c[f].value);if(m!==yl){!(S1e.has(m)||m==="git"&&k1e.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=_1e(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function T1e(n){return E1e(n).invocations}const Nj=120,A1e=/(?:^|[._])exec_command$/;function I1e(n){return n==="Bash"||A1e.test(n)}function P1e(n){return Use(n).filter(e=>I1e(e.name)).map(e=>ro(e.input))}function $1e(n){for(const e of P1e(n)){const[t]=T1e(e);if(t===void 0||v1e(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>Nj?`${s.slice(0,Nj-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function R1e(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 r=s.length-1;r>=0;r--){const o=$1e(s[r]);if(o)return o}}return null}const Cj=1e4,O1e=y.lazy(()=>nt(()=>import("./ProjectFilesPanel-BsbpTgWK.js"),__vite__mapDeps([32,1,33,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),L1e=y.lazy(()=>nt(()=>import("./WorktreePanel-BFve9bpC.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),M1e=y.lazy(()=>nt(()=>import("./CrewPanel-BxPl5D7h.js"),__vite__mapDeps([35,1,28,2,3,4])).then(n=>({default:n.CrewPanel}))),z1e=y.lazy(()=>nt(()=>import("./index-DmMg-zf3.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function Am(){const n=V.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(Pn,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function D1e(n){const e=V.c(6),{context:t,closePanel:s}=n,r=ev(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Am,{}),e[0]=i):i=e[0];let l;return e[1]!==s||e[2]!==o||e[3]!==r.addProjectContext||e[4]!==r.projectFilesRequest?(l=a.jsx(y.Suspense,{fallback:i,children:a.jsx(O1e,{cwd:o,onClose:s,onAddToPrompt:r.addProjectContext,openRequest:r.projectFilesRequest},o)}),e[1]=s,e[2]=o,e[3]=r.addProjectContext,e[4]=r.projectFilesRequest,e[5]=l):l=e[5],l}function F1e(n){const e=V.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=a.jsx(cfe,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function U1e(){const n=V.c(7),e=ev();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=a.jsx(p1e,{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 B1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(z1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function W1e(n){var u;const e=V.c(8),{context:t}=n,[,s]=y.useState(0);let r;e[0]!==t.session?(r=Date.parse(((u=R1e(t.session))==null?void 0:u.timestamp)??""),e[0]=t.session,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==s?(i=()=>{const d=o+Cj-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(q1e),d);return()=>clearTimeout(f)},e[2]=o,e[3]=s,e[4]=i):i=e[4];let l;if(e[5]!==o?(l=[o],e[5]=o,e[6]=l):l=e[6],y.useEffect(i,l),Number.isNaN(o)||Date.now()-o>=Cj)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.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"}),e[7]=c):c=e[7],c}function q1e(n){return n+1}function V1e(n){const e=V.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Am,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(M1e,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function H1e(n){const e=V.c(5),{context:t}=n,s=t.crew;if(!s)return null;if(s.needsYou>0){const i=`${s.needsYou} ${s.needsYou===1?"session needs":"sessions need"} you`;let l;return e[0]!==s.needsYou||e[1]!==i?(l=a.jsx("span",{role:"status","aria-label":i,className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-warning px-1 text-[9px] font-semibold text-warning-foreground",children:s.needsYou}),e[0]=s.needsYou,e[1]=i,e[2]=l):l=e[2],l}if(s.working===0)return null;const r=`${s.working} ${s.working===1?"session":"sessions"} working`;let o;return e[3]!==r?(o=a.jsx("span",{role:"status","aria-label":r,className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-success ring-2 ring-success/30"}),e[3]=r,e[4]=o):o=e[4],o}function K1e(n){const e=V.c(8),{closePanel:t}=n,s=ev();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Am,{}),e[0]=r):r=e[0];let o;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?(o=a.jsx(y.Suspense,{fallback:r,children:a.jsx(L1e,{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]=o):o=e[7],o}const G1e={id:ii,workspacePanels:[{id:"crew",title:"Crew",icon:rx,component:V1e,indicator:H1e,order:1,defaultSize:"30%",minSize:"340px",maxSize:"60%",when:n=>!!n.crew},{id:"worktrees",title:"Worktrees",icon:Zr,component:K1e,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:R8,component:D1e,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:sa,component:B1e,indicator:W1e,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canUseBrowser},{id:"file-changes",title:"File changes",icon:yc,component:F1e,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:O8,component:U1e,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},Z1e=cpe([G1e]),_j={"cogpit.github":b4,"cogpit.clickup":z8,"cogpit.vercel":M8,"cogpit.cloudflare":L8};function Y1e(n){const e=V.c(6);let t,s;e[0]!==n?({runtime:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;return e[3]!==t||e[4]!==s?(r=s?a.jsx($ge,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function X1e(n){var o;const e=V.c(3),{runtime:t,context:s}=n;let r;return e[0]!==s||e[1]!==t?(r=t?a.jsx(Ige,{client:t.client,pluginId:t.plugin.id,projectId:((o=t.project)==null?void 0:o.id)??null,workspacePath:t.project?s.projectPath:null,activation:t.activation,registryRevision:t.registryRevision}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function J1e({client:n,status:e,activation:t,project:s,legacyPanels:r=Z1e,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||VE())return i;const l=new Set(i.map(u=>u.id)),c=vo();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&T0(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=bo(u.id,d.id);if(l.has(f)||d.when==="project-selected"&&!s)continue;l.add(f);const m={client:n,plugin:u,activation:t,registryRevision:e.store.revision,project:s,title:d.title,openSettings:o};i.push({id:f,pluginId:u.id,localId:d.id,title:d.title,icon:_j[u.id]??vx,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,..._j[u.id]?{indicator:X1e,indicatorProps:{runtime:m}}:{},component:Y1e,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function GI(n){const e=V.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=J0();let c;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==s?(c={client:t,status:s,activation:r,projectPath:o},e[0]=r,e[1]=t,e[2]=o,e[3]=s,e[4]=c):c=e[4];const{project:u,resolving:d}=qE(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=J1e({client:t,status:s,activation:f,project:u,openSettings:i}),e[5]=t,e[6]=i,e[7]=u,e[8]=s,e[9]=f,e[10]=m):m=e[10],m}function Im(n){const e=V.c(7),{floating:t,children:s}=n,r=y.useRef(null);let o,i;if(e[0]!==t?(o=()=>{const c=r.current,u=c==null?void 0:c.parentElement;if(!t||!c||!u)return;const d=u.style.getPropertyValue("--session-footer-height"),f=()=>u.style.setProperty("--session-footer-height",`${c.getBoundingClientRect().height}px`);f();const m=new ResizeObserver(f);return m.observe(c),()=>{m.disconnect(),d?u.style.setProperty("--session-footer-height",d):u.style.removeProperty("--session-footer-height")}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useLayoutEffect(o,i),t){let c;return e[3]!==s?(c=a.jsx("div",{ref:r,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-canvas via-canvas/70 to-transparent pt-4",children:a.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[3]=s,e[4]=c):c=e[4],c}let l;return e[5]!==s?(l=a.jsx("div",{className:"flex w-full shrink-0 justify-center",children:a.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[5]=s,e[6]=l):l=e[6],l}function wa(n){const e=V.c(13),{projectPath:t,fallback:s,className:r}=n,[o,i]=y.useState(null);if(!t||o===t){let m;return e[0]!==s?(m=a.jsx(a.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=Af(l),e[2]=l,e[3]=c):c=e[3];let u;e[4]!==t?(u=()=>i(t),e[4]=t,e[5]=u):u=e[5];let d;e[6]!==r?(d=G("size-3.5 shrink-0 rounded-[3px] object-contain",r),e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==u||e[11]!==d?(f=a.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:u,className:d},t),e[8]=t,e[9]=c,e[10]=u,e[11]=d,e[12]=f):f=e[12],f}function ZI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function YI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("ol",{"data-slot":"breadcrumb-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function W1(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("li",{"data-slot":"breadcrumb-item",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function XI(n){const e=V.c(10);let t,s,r,o;if(e[0]!==n){const{className:c,render:u,...d}=n;t=u,o=h4,s="a",r=p4({className:G("transition-colors hover:text-foreground",c)},d),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o}else t=e[1],s=e[2],r=e[3],o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={slot:"breadcrumb-link"},e[5]=i):i=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==r?(l={defaultTagName:s,props:r,render:t,state:i},e[6]=t,e[7]=s,e[8]=r,e[9]=l):l=e[9],o(l)}function JI(n){const e=V.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("font-normal text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function QI(n){const e=V.c(12);let t,s,r;e[0]!==n?({children:t,className:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(it,{}),e[6]=t,e[7]=i):i=e[7];let l;return e[8]!==r||e[9]!==o||e[10]!==i?(l=a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:o,...r,children:i}),e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const Q1e=1e3,exe=255;function txe(n){for(const e of n){const t=e.codePointAt(0)??0;if(t<32||t===127)return!0}return!1}function nxe(n){return n.trim()===""?"Enter a folder name":n!==n.trim()?"A folder name cannot start or end with a space":n==="."||n===".."?`"${n}" is not a folder name`:n.includes("/")||n.includes("\\")?"A folder name cannot contain / or \\":txe(n)?"A folder name cannot contain control characters":new TextEncoder().encode(n).length>exe?"That folder name is too long":null}function Ej(n,e){return n instanceof Error&&n.message?n.message:e}function sxe({hostName:n,projectPaths:e,onStart:t,onBack:s}){var D;const[r,o]=y.useState({path:null,request:0}),i=`${r.request}:${r.path??""}`,[l,c]=y.useState(null),[u,d]=y.useState(""),[f,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,j]=y.useState(!1),k=y.useRef(null),_=y.useRef(null),N=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>{const B=new AbortController;return npe(r.path,B.signal).then(q=>c({request:i,listing:q})).catch(q=>{B.signal.aborted||c({request:i,error:Ej(q,"This folder could not be read")})}),()=>B.abort()},[i,r.path]);const C=(l==null?void 0:l.request)!==i,E=l&&"listing"in l?l.listing:null,T=!C&&l&&"error"in l?l.error:null,$=C?null:(E==null?void 0:E.path)??null,A=u.trim().toLowerCase(),R=(E==null?void 0:E.folders.filter(B=>B.name.toLowerCase().includes(A)))??[],P=R.some(B=>B.path===f)?f:((D=R[0])==null?void 0:D.path)??"",z=E==null?void 0:E.path;y.useEffect(()=>{var q,W;const B=N.current;B&&(B.scrollLeft=B.scrollWidth),S.current&&!((q=k.current)!=null&&q.contains(document.activeElement))&&((W=_.current)==null||W.focus()),S.current=!1},[z]);function L(B){var q;S.current=((q=k.current)==null?void 0:q.contains(document.activeElement))??!1,o(W=>({path:B,request:W.request+1})),d(""),h(!1),x(""),w(null)}function I(){$&&t($)}function M(B){B.key==="Enter"&&(B.metaKey||B.ctrlKey)&&!p?(B.preventDefault(),I()):B.key==="Backspace"&&B.target===_.current&&u===""&&(E!=null&&E.parent)&&!C&&(B.preventDefault(),L(E.parent))}function F(){var B;h(!1),x(""),w(null),(B=_.current)==null||B.focus()}async function U(B){var H;B.preventDefault();const q=g.trim(),W=nxe(q);if(W){w(W);return}if(!(!$||v)){j(!0);try{const K=await spe($,q);L(K),(H=_.current)==null||H.focus()}catch(K){w(Ej(K,"The folder could not be made"))}finally{j(!1)}}}const O=n?`Folders on ${n}`:"Folders";return a.jsxs("div",{ref:k,onKeyDownCapture:M,className:"flex min-h-0 flex-col bg-popover text-popover-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 in-data-[slot=dialog-content]:pr-12",children:[a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Back to projects",children:a.jsx(yx,{})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:O}),E&&E.path!==E.root&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>L(null),"aria-label":"Go to the projects root",title:E.root,children:a.jsx(D8,{})})]}),E&&a.jsx(rxe,{path:E.path,top:E.confined?E.root:null,listRef:N,onOpen:L}),a.jsxs(Ic,{shouldFilter:!1,label:"Filter folders",value:P,onValueChange:m,className:"rounded-none p-0",children:[a.jsx(a0,{ref:_,autoFocus:!0,placeholder:"Filter folders...",value:u,onValueChange:d}),a.jsx(Pc,{className:"box-content max-h-72 p-1","aria-busy":C,children:T!==null?a.jsx(oxe,{message:T,onRetry:()=>L(r.path),onRoot:r.path===null?void 0:()=>L(null)}):E===null?a.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"}),"Loading folders…"]}):R.length===0?a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Yr,{})}),a.jsx(zn,{children:A?"No folder matches":"No folders here"}),a.jsx(Dn,{children:A?"Try another name.":"Start a session right here, or make a new folder."})]})}):a.jsxs(xi,{className:G("p-0 transition-opacity",C&&"opacity-50"),children:[R.map(B=>a.jsxs(To,{value:B.path,onSelect:()=>L(B.path),onMouseDown:q=>q.preventDefault(),className:"motion-list-item h-auto gap-3 px-3 py-2",children:[a.jsx(ra,{className:"size-4 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:B.name}),e.has(B.path)&&a.jsx(Fe,{variant:"secondary",children:"Project"}),a.jsx(it,{className:"size-4 shrink-0 text-muted-foreground"})]},B.path)),E.truncated&&a.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Q1e.toLocaleString()," folders."]})]})})]}),a.jsxs("div",{className:"flex flex-col gap-1.5 border-t p-2",children:[p?a.jsxs("form",{onSubmit:B=>void U(B),className:"flex items-center gap-2",children:[a.jsx(On,{autoFocus:!0,"aria-label":"New folder name",placeholder:"New folder name",value:g,disabled:v,"aria-invalid":b?!0:void 0,onChange:B=>{x(B.target.value),w(null)},onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),F())}}),a.jsxs(Q,{type:"submit",size:"sm",disabled:v||!$||g.trim()==="",children:[v&&a.jsx(Pn,{"data-icon":"inline-start",className:"size-4"}),"Create"]}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:F,children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Q,{type:"button",variant:"ghost",size:"sm",disabled:!$,onClick:()=>h(!0),children:[a.jsx(V4,{"data-icon":"inline-start"}),"New folder"]}),a.jsx(Q,{type:"button",size:"sm",className:"ml-auto",disabled:!$,onClick:I,"aria-keyshortcuts":"Meta+Enter Control+Enter",children:"Start session here"})]}),b&&a.jsx("p",{role:"alert",className:"px-1 text-xs text-destructive",children:b})]})]})}function rxe(n){const e=V.c(19),{path:t,top:s,listRef:r,onOpen:o}=n;let i,l,c,u,d,f;if(e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==s){const h=rpe(t,s);l=ZI,f="border-b px-3 py-1.5",i=YI,c=r,u="no-scrollbar flex-nowrap gap-1 overflow-x-auto text-xs",d=h.map((g,x)=>a.jsxs(y.Fragment,{children:[x>0&&a.jsx(QI,{}),a.jsx(W1,{className:"shrink-0",children:x===h.length-1?a.jsx(JI,{children:g.label}):a.jsx(XI,{render:a.jsx("button",{type:"button",onClick:()=>o(g.path)}),children:g.label})})]},g.path)),e[0]=r,e[1]=o,e[2]=t,e[3]=s,e[4]=i,e[5]=l,e[6]=c,e[7]=u,e[8]=d,e[9]=f}else i=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9];let m;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==d?(m=a.jsx(i,{ref:c,className:u,children:d}),e[10]=i,e[11]=c,e[12]=u,e[13]=d,e[14]=m):m=e[14];let p;return e[15]!==l||e[16]!==f||e[17]!==m?(p=a.jsx(l,{className:f,children:m}),e[15]=l,e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function oxe(n){const e=V.c(14),{message:t,onRetry:s,onRoot:r}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Yn,{variant:"icon",children:a.jsx(Sr,{})}),i=a.jsx(zn,{children:"This folder could not be opened"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let l;e[2]!==t?(l=a.jsxs(Mn,{children:[o,i,a.jsx(Dn,{children:t})]}),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==s?(c=a.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Try again"}),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r?(u=r&&a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Go to the projects root"}),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs("div",{className:"flex gap-2",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=a.jsxs(Ln,{className:"border-0 py-8",children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function ixe(){const n=V.c(7),e=Nn("manageDevices");let t;n[0]!==e?(t={enabled:e},n[0]=e,n[1]=t):t=n[1];const{activeDevice:s}=Si(t);let r;n[2]!==s?(r=!s&&Ef(),n[2]=s,n[3]=r):r=n[3];const o=r,[i,l]=y.useState(null);let c,u;return n[4]!==o?(c=()=>{if(!o)return;const d=new AbortController;return Ce("/api/hello",{signal:d.signal}).then(zs).then(f=>{typeof(f==null?void 0:f.name)=="string"&&f.name&&l(f.name)}).catch(axe),()=>d.abort()},u=[o],n[4]=o,n[5]=c,n[6]=u):(c=n[5],u=n[6]),y.useEffect(c,u),(s==null?void 0:s.name)??(o?i:null)}function axe(){}function Tj(n){return n.replace(/[\\/]+$/,"")||n}function e7(n){const e=n.map(s=>({...s,worktrees:[]})),t=new Map;for(const s of e){const r=Tj(s.path);!Cr(s.path)&&!t.has(r)&&t.set(r,s)}return e.filter((s,r)=>{const o=Cr(s.path),i=o&&t.get(Tj(o.parentPath));return i?(i.worktrees.push(n[r]),!1):!0})}const q1=HN("project-custom-names"),lxe=q1.rename;function nv(){const n=V.c(2),e=y.useSyncExternalStore(q1.subscribe,q1.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:lxe},n[0]=e,n[1]=t):t=n[1],t}const Aj="browse-folders";function wl(n){return n.replace(/[\\/]+$/,"")||n}function cxe(n){const e=V.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=y.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n)return;const l=new AbortController;return Ce("/api/projects",{signal:l.signal}).then(uxe).then(r).catch(()=>{l.signal.aborted||r([])}),()=>l.abort()},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),y.useEffect(o,i),s}async function uxe(n){return n.ok?await n.json():[]}function dxe(n){var B;const e=V.c(58),{projects:t,onNewSession:s,onNewFolder:r,defaultAgentKind:o,currentPath:i,initialView:l,children:c}=n,u=l===void 0?"projects":l,[d,f]=y.useState(u),[m,p]=y.useState(""),[h,g]=y.useState(null),{names:x}=nv(),b=ixe();let w;if(e[0]!==m||e[1]!==x||e[2]!==t){e:{const q=e7(t);if(!m){w=q;break e}const W=m.toLowerCase();w=q.filter(H=>{var K;return H.path.toLowerCase().includes(W)||H.shortName.toLowerCase().includes(W)||H.dirName.toLowerCase().includes(W)||((K=x[H.dirName])==null?void 0:K.toLowerCase().includes(W))})}e[0]=m,e[1]=x,e[2]=t,e[3]=w}else w=e[3];const v=w;let j,k;e[4]!==m||e[5]!==t?(j=m.trim(),k=(j.startsWith("/")||/^[a-z]:[\\/]/i.test(j)||j.startsWith("\\\\"))&&!t.some(W=>wl(W.path)===wl(j)),e[4]=m,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]);const _=k;let N;e[8]!==i?(N=i?wl(((B=Cr(i))==null?void 0:B.parentPath)??i):null,e[8]=i,e[9]=N):N=e[9];const S=N;let C;e[10]!==_||e[11]!==j?(C=_?[`folder:${j}`]:[],e[10]=_,e[11]=j,e[12]=C):C=e[12];let E;e[13]!==v||e[14]!==C?(E=[...C,...v.map(mxe),Aj],e[13]=v,e[14]=C,e[15]=E):E=e[15];const T=E,$=h!==null&&T.includes(h)?h:T[0];if(d==="folders"){let q;e[16]!==t?(q=new Set(t.map(fxe)),e[16]=t,e[17]=q):q=e[17];let W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=()=>f("projects"),e[18]=W):W=e[18];let H;return e[19]!==b||e[20]!==r||e[21]!==q?(H=a.jsx(sxe,{hostName:b,projectPaths:q,onStart:r,onBack:W}),e[19]=b,e[20]=r,e[21]=q,e[22]=H):H=e[22],H}let A;e[23]!==m?(A=a.jsx(a0,{autoFocus:!0,placeholder:"Search projects, paste a folder path, or browse",value:m,onValueChange:p}),e[23]=m,e[24]=A):A=e[24];let R;e[25]!==_||e[26]!==v.length?(R=v.length===0&&!_&&a.jsx(Ln,{className:"border-0 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Yr,{})}),a.jsx(zn,{children:"No projects found"}),a.jsx(Dn,{children:"Try another name, paste an absolute path, or browse the folders."})]})}),e[25]=_,e[26]=v.length,e[27]=R):R=e[27];let P;e[28]!==_||e[29]!==o||e[30]!==j||e[31]!==r?(P=_&&a.jsxs(To,{value:`folder:${j}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>r(j),children:[a.jsx(V4,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),a.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[j," · ",NM(o)]})]})]}),e[28]=_,e[29]=o,e[30]=j,e[31]=r,e[32]=P):P=e[32];let z;if(e[33]!==S||e[34]!==v||e[35]!==s||e[36]!==x){let q;e[38]!==S||e[39]!==s||e[40]!==x?(q=W=>{const H=x[W.dirName],K=jc(W.path);return a.jsxs(To,{value:`project:${W.dirName}`,"data-checked":S!==null&&wl(W.path)===S,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>s(W.dirName,W.path),children:[a.jsx(wa,{projectPath:W.path,fallback:a.jsx(Yr,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-medium",children:H||K}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[H&&a.jsx("span",{className:"mr-1.5",children:K}),W.sessionCount," session",W.sessionCount!==1?"s":"",W.lastModified&&a.jsxs(a.Fragment,{children:[" · ",new Date(W.lastModified).toLocaleDateString()]})]})]})]},W.dirName)},e[38]=S,e[39]=s,e[40]=x,e[41]=q):q=e[41],z=v.map(q),e[33]=S,e[34]=v,e[35]=s,e[36]=x,e[37]=z}else z=e[37];let L;e[42]!==z||e[43]!==P?(L=a.jsxs(xi,{className:"p-0",children:[P,z]}),e[42]=z,e[43]=P,e[44]=L):L=e[44];let I,M;e[45]===Symbol.for("react.memo_cache_sentinel")?(I=()=>f("folders"),M=a.jsx(wc,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),e[45]=I,e[46]=M):(I=e[45],M=e[46]);const F=b?`Browse folders on ${b}…`:"Browse folders…";let U;e[47]!==F?(U=a.jsx(xi,{className:"sticky -bottom-1 border-t bg-popover p-0 py-1",children:a.jsxs(To,{value:Aj,className:"h-auto gap-3 px-3 py-2.5",onSelect:I,children:[M,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:F})]})}),e[47]=F,e[48]=U):U=e[48];let O;e[49]!==L||e[50]!==U||e[51]!==R?(O=a.jsxs(Pc,{className:"box-content max-h-80 p-1",children:[R,L,U]}),e[49]=L,e[50]=U,e[51]=R,e[52]=O):O=e[52];let D;return e[53]!==c||e[54]!==$||e[55]!==O||e[56]!==A?(D=a.jsxs(Ic,{shouldFilter:!1,value:$,onValueChange:g,className:"rounded-none p-0",children:[A,O,c]}),e[53]=c,e[54]=$,e[55]=O,e[56]=A,e[57]=D):D=e[57],D}function fxe(n){return wl(n.path)}function mxe(n){return`project:${n.dirName}`}function t7(n){const e=V.c(13),{projectPath:t,switcher:s}=n;let r;e[0]!==t?(r=t?Er(t):null,e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==t||e[4]!==s?(i=o?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx(pxe,{name:o,projectPath:t,switcher:s}),"?"]}):"What should we build?",e[2]=o,e[3]=t,e[4]=s,e[5]=i):i=e[5];let l;e[6]!==i?(l=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t?(c=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:jc(t)}),e[8]=t,e[9]=c):c=e[9];let u;return e[10]!==l||e[11]!==c?(u=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[l,c]}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function pxe(n){const e=V.c(24),{name:t,projectPath:s,switcher:r}=n,{onNewSession:o,onNewFolder:i,defaultAgentKind:l}=r,[c,u]=y.useState(!1),d=cxe(c);let f;e[0]!==s?(f=a.jsx(wa,{projectPath:s,fallback:null,className:"size-5"}),e[0]=s,e[1]=f):f=e[1];let m;e[2]!==t?(m=a.jsx("span",{className:"truncate underline decoration-dotted decoration-muted-foreground/50 underline-offset-[6px] transition-colors group-hover/project:decoration-foreground/70 group-data-popup-open/project:decoration-foreground/70",children:t}),e[2]=t,e[3]=m):m=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Ea,{className:"size-4 shrink-0 text-muted-foreground transition-colors group-hover/project:text-foreground group-data-popup-open/project:text-foreground","aria-hidden":"true"}),e[4]=p):p=e[4];let h;e[5]!==f||e[6]!==m?(h=a.jsxs(Tc,{title:"Switch project",className:"group/project -mx-1 inline-flex max-w-full items-center gap-1.5 rounded-lg px-1.5 align-baseline outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[f,m,p]}),e[5]=f,e[6]=m,e[7]=h):h=e[7];let g;e[8]!==o?(g=(k,_)=>{u(!1),o(k,_)},e[8]=o,e[9]=g):g=e[9];let x;e[10]!==i?(x=k=>{u(!1),i(k)},e[10]=i,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{children:"Switch where this session starts"}),e[12]=b):b=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-[11px] text-muted-foreground",children:[b,a.jsx("kbd",{className:"font-mono",children:ea("newSession")})]}),e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==s||e[16]!==d||e[17]!==g||e[18]!==x?(v=a.jsx(Xx,{align:"center",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(dxe,{projects:d,currentPath:s,defaultAgentKind:l,onNewSession:g,onNewFolder:x,children:w})}),e[14]=l,e[15]=s,e[16]=d,e[17]=g,e[18]=x,e[19]=v):v=e[19];let j;return e[20]!==c||e[21]!==v||e[22]!==h?(j=a.jsxs(Ec,{open:c,onOpenChange:u,children:[h,v]}),e[20]=c,e[21]=v,e[22]=h,e[23]=j):j=e[23],j}function sv(n){const e=V.c(56),{children:t,sessionLabel:s,customName:r,onDuplicate:o,onDelete:i,onRename:l,onArchive:c,onUnarchive:u,archiveDisabled:d}=n,f=d===void 0?!1:d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),[x,b]=y.useState(""),w=y.useRef(null);let v;e[0]!==r?(v=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=w.current)==null?void 0:H.select()})},e[0]=r,e[1]=v):v=e[1];const j=v;let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("div",{className:"w-full"}),e[2]=k):k=e[2];let _;e[3]!==t?(_=a.jsx(Cm,{render:k,children:t}),e[3]=t,e[4]=_):_=e[4];let N;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==j?(N=(l||o||c||u)&&a.jsxs(fi,{children:[l&&a.jsxs(Rn,{onClick:j,children:[a.jsx(wr,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs(Rn,{onClick:o,children:[a.jsx(Es,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs(Rn,{onClick:u,children:[a.jsx(Cf,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs(Rn,{onClick:c,disabled:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=o,e[8]=l,e[9]=u,e[10]=j,e[11]=N):N=e[11];let S;e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==u?(S=i&&a.jsxs(a.Fragment,{children:[(o||l||c||u)&&a.jsx(va,{}),a.jsx(fi,{children:a.jsxs(Rn,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(kf,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==N||e[19]!==S?(C=a.jsxs(_m,{className:"min-w-44",children:[N,S]}),e[18]=N,e[19]=S,e[20]=C):C=e[20];let E;e[21]!==_||e[22]!==C?(E=a.jsxs(Nm,{children:[_,C]}),e[21]=_,e[22]=C,e[23]=E):E=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(lb,{children:"Delete session?"}),e[24]=T):T=e[24];let $;e[25]!==s?($=a.jsxs(ib,{children:[T,a.jsxs(cb,{children:["This will permanently delete"," ",a.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=a.jsx(db,{size:"sm",children:"Cancel"}),e[27]=A):A=e[27];let R;e[28]!==i?(R=a.jsxs(ab,{children:[A,a.jsx(ub,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=R):R=e[29];let P;e[30]!==$||e[31]!==R?(P=a.jsxs(ob,{children:[$,R]}),e[30]=$,e[31]=R,e[32]=P):P=e[32];let z;e[33]!==m||e[34]!==P?(z=a.jsx(rb,{open:m,onOpenChange:p,children:P}),e[33]=m,e[34]=P,e[35]=z):z=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsxs(ao,{children:[a.jsx(or,{className:"text-foreground",children:"Rename session"}),a.jsx(ir,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=L):L=e[36];let I;e[37]!==l||e[38]!==x?(I=W=>{W.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=I):I=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(mn,{htmlFor:"session-rename",children:"Session name"}),e[40]=M):M=e[40];let F;e[41]===Symbol.for("react.memo_cache_sentinel")?(F=W=>b(W.target.value),e[41]=F):F=e[41];let U;e[42]!==x||e[43]!==s?(U=a.jsxs(fn,{children:[M,a.jsx(On,{id:"session-rename",ref:w,value:x,onChange:F,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=U):U=e[44];let O;e[45]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsxs(Rx,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[45]=O):O=e[45];let D;e[46]!==I||e[47]!==U?(D=a.jsxs(rr,{className:"sm:max-w-md",children:[L,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:I,children:[U,O]})]}),e[46]=I,e[47]=U,e[48]=D):D=e[48];let B;e[49]!==h||e[50]!==D?(B=a.jsx(sr,{open:h,onOpenChange:g,children:D}),e[49]=h,e[50]=D,e[51]=B):B=e[51];let q;return e[52]!==z||e[53]!==B||e[54]!==E?(q=a.jsxs(a.Fragment,{children:[E,z,B]}),e[52]=z,e[53]=B,e[54]=E,e[55]=q):q=e[55],q}function V1(n,e){return Object.freeze({canInteract:n,canOwn:e,send:n,stop:n,answer:n,configure:n,mcp:n,undo:n,archive:e,delete:e})}const lg=V1(!1,!1),hxe={unknown:lg,none:lg,view:lg,interact:V1(!0,!1),own:V1(!0,!0)};function Sa(n){return hxe[n]}function Pm(){const n=V.c(3),{enforcesSessionAccess:e}=PN(),t=e===!1?"own":"unknown";let s;return n[0]!==e||n[1]!==t?(s=r=>Sa(e!==null&&r?r.level:t),n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function n7(n){const e=V.c(16),{value:t,onChange:s,placeholder:r,loading:o}=n,i=o===void 0?!1:o;let l;e[0]!==i?(l=a.jsx(Ar,{children:i?a.jsx(St,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(ss,{"aria-hidden":"true"})}),e[0]=i,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 u;e[4]!==i||e[5]!==r||e[6]!==c||e[7]!==t?(u=a.jsx(Go,{type:"search","aria-busy":i,"aria-label":r,value:t,onChange:c,placeholder:r}),e[4]=i,e[5]=r,e[6]=c,e[7]=t,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==t?(d=t&&a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(Mt,{})})}),e[9]=s,e[10]=t,e[11]=d):d=e[11];let f;return e[12]!==l||e[13]!==u||e[14]!==d?(f=a.jsxs(Ko,{className:"w-full sm:max-w-sm",children:[l,u,d]}),e[12]=l,e[13]=u,e[14]=d,e[15]=f):f=e[15],f}function s7(n){const e=V.c(10),{message:t,onRetry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(er,{"aria-hidden":"true"}),o=a.jsx(Xt,{children:"Could not load this data"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(_t,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(Hr,{children:a.jsxs(Q,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(kt,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function r7(n){const e=V.c(5),{count:t,includeMessagePlaceholder:s}=n,r=t===void 0?4:t,o=s===void 0?!1:s;let i;if(e[0]!==r||e[1]!==o){let l;e[3]!==o?(l=(c,u)=>a.jsxs("div",{children:[u>0&&a.jsx(tn,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx(Gn,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-40 max-w-full"}),o&&a.jsx(Gn,{className:"h-3 w-72 max-w-full"}),a.jsx(Gn,{className:"h-3 w-52 max-w-full"})]}),a.jsx(Gn,{className:"hidden h-5 w-20 sm:block"})]})]},u),e[3]=o,e[4]=l):l=e[4],i=a.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:r},l)}),e[0]=r,e[1]=o,e[2]=i}else i=e[2];return i}function o7(n){const e=V.c(3),{access:t}=n,{SessionBadges:s}=$r();let r;return e[0]!==s||e[1]!==t?(r=s?a.jsx(s,{access:t}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const Hs={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},gxe=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,xxe=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,bxe=/(?:^|\s)#(\d+)(?=\s|$)/,vxe=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Gu(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function yxe(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 i7(n){const e=n.trim();if(!e)return null;const t=gxe.exec(e);if(t){const l=Gu(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=xxe.exec(e);if(s){const l=Gu(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=bxe.exec(e);if(r){const l=Gu(r[1]);if(l===null)return null;const c=`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`;return{number:l,repoHint:yxe(c)}}const o=vxe.exec(e);if(!o)return null;const i=Gu(o[1]);return i===null?null:{number:i,repoHint:null}}function Ij(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function wxe(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(r=>r.replace(/[^a-z0-9]/g,"")===s)}function Sxe(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?Ij(n.repo,s):Ij(n.repo,s)?!0:t.some(r=>wxe(r,s)):!0}function a7(n,e,t=[]){var o;const s=i7(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>Sxe(l,s,i)))??!1}const r=e.trim().toLowerCase();return r?[...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(i=>i==null?void 0:i.toLowerCase().includes(r)):!0}const kxe=120*1e3;function l7(n){return n?Date.now()-new Date(n).getTime()<kxe:!1}function c7(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Bs(s,70):Bs(n.sessionId,16)}function Pj(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function jxe(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||Pj(t)===Pj(e)?null:Bs(t,220)}function Nxe(n,e){return a7(n,e)}function Cxe(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?Js(t):null}function _xe(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(`
|
|
470
|
+
`)}function Exe(n){var t;const e=n.cwd?(t=Cr(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:F8,label:e,title:n.cwd}:n.gitBranch?{icon:Zr,label:n.gitBranch}:null}function Txe(n,e){return n.agentStatus==="deferred"?"attention":e?Qc(n.agentStatus)?"idle":"working":null}function Axe(n){const e=V.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=r):r=e[0],r}if(s){const r=Qc(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=Jc(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]=o):o=e[5];const i=o;let l;e[6]!==t.agentStatus?(l=wm(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=r?"bg-success/60":"bg-current";let u;e[8]!==c?(u=G("size-1.5 rounded-full",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==u?(d=a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:u}),e[10]=u,e[11]=d):d=e[11];let f;return e[12]!==i||e[13]!==l||e[14]!==d?(f=a.jsxs(Fe,{variant:"secondary",className:l,children:[d,i]}),e[12]=i,e[13]=l,e[14]=d,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let r;e[16]!==t.agentTerminalReason?(r=Rb(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Fe,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function cg(n){const e=V.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=G("flex items-center gap-1",r),e[0]=r,e[1]=i):i=e[1];let l;e[2]!==t?(l=a.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==s?(c=a.jsxs("span",{className:i,title:s,children:[l,o]}),e[4]=o,e[5]=i,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function Ixe(n){const e=V.c(103),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=l7(o),l=Txe(t,i),e[0]=o,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]);const c=l,u=t.teamName?t.agentName:void 0;let d,f,m,p,h,g,x,b,w,v,j,k,_,N,S;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const I=Exe(t);let M;e[26]!==o||e[27]!==t.timestamp?(M=Cxe(t.timestamp,o),e[26]=o,e[27]=t.timestamp,e[28]=M):M=e[28];const F=M,U=t.turnCount??0;let O,D;e[29]!==s||e[30]!==t?(D=c7(t,s),O=jxe(t,D),e[29]=s,e[30]=t,e[31]=O,e[32]=D):(O=e[31],D=e[32]);const B=O;x="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",m=r,e[33]!==t?(p=_xe(t),e[33]=t,e[34]=p):p=e[34],h="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 q;e[35]===Symbol.for("react.memo_cache_sentinel")?(q=a.jsx(bg,{className:"size-4"}),e[35]=q):q=e[35];let W;e[36]!==c?(W=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Hs[c])}),e[36]=c,e[37]=W):W=e[37],e[38]!==W?(g=a.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:[q,W]}),e[38]=W,e[39]=g):g=e[39],N="flex min-w-0 flex-1 flex-col gap-1";let H;e[40]!==D?(H=a.jsx("span",{className:"truncate text-sm font-medium",children:D}),e[40]=D,e[41]=H):H=e[41];let K;e[42]!==u?(K=u&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",children:[a.jsx(mi,{"data-icon":"inline-start"}),Bs(u,18)]}),e[42]=u,e[43]=K):K=e[43];let Z;e[44]!==t.branchedFrom?(Z=t.branchedFrom&&a.jsxs(Fe,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(bx,{"data-icon":"inline-start"}),"branch"]}),e[44]=t.branchedFrom,e[45]=Z):Z=e[45];let Y;e[46]!==i||e[47]!==t?(Y=a.jsx(Axe,{session:t,live:i}),e[46]=i,e[47]=t,e[48]=Y):Y=e[48];let J;e[49]!==o?(J=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:_r(o)}),e[49]=o,e[50]=J):J=e[50];let ee;e[51]!==Y||e[52]!==J?(ee=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Y,J]}),e[51]=Y,e[52]=J,e[53]=ee):ee=e[53],e[54]!==H||e[55]!==K||e[56]!==Z||e[57]!==ee?(S=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[H,K,Z,ee]}),e[54]=H,e[55]=K,e[56]=Z,e[57]=ee,e[58]=S):S=e[58],e[59]!==B?(d=B&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:B}),e[59]=B,e[60]=d):d=e[60],b="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[61]!==t.access?(w=a.jsx(o7,{access:t.access}),e[61]=t.access,e[62]=w):w=e[62],e[63]!==t.model?(v=t.model&&a.jsx(Fe,{variant:"outline",children:lo(t.model)}),e[63]=t.model,e[64]=v):v=e[64],e[65]!==U?(j=U>0&&a.jsxs(cg,{icon:bg,children:[U," ",U===1?"turn":"turns"]}),e[65]=U,e[66]=j):j=e[66],e[67]!==F?(k=F&&a.jsx(cg,{icon:Po,title:"First prompt to last activity",children:F}),e[67]=F,e[68]=k):k=e[68],_=I&&a.jsx(cg,{icon:I.icon,className:"max-w-40 truncate",title:I.title,children:Bs(I.label,22)}),e[4]=s,e[5]=c,e[6]=o,e[7]=i,e[8]=r,e[9]=t,e[10]=u,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=j,e[22]=k,e[23]=_,e[24]=N,e[25]=S}else d=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],j=e[21],k=e[22],_=e[23],N=e[24],S=e[25];let C;e[69]!==t.size?(C=kN(t.size),e[69]=t.size,e[70]=C):C=e[70];let E;e[71]!==C?(E=a.jsx("span",{children:C}),e[71]=C,e[72]=E):E=e[72];let T;e[73]!==E||e[74]!==b||e[75]!==w||e[76]!==v||e[77]!==j||e[78]!==k||e[79]!==_?(T=a.jsxs("span",{className:b,children:[w,v,j,k,_,E]}),e[73]=E,e[74]=b,e[75]=w,e[76]=v,e[77]=j,e[78]=k,e[79]=_,e[80]=T):T=e[80];let $;e[81]!==d||e[82]!==T||e[83]!==N||e[84]!==S?($=a.jsxs("span",{className:N,children:[S,d,T]}),e[81]=d,e[82]=T,e[83]=N,e[84]=S,e[85]=$):$=e[85];let A;e[86]!==f||e[87]!==m||e[88]!==p||e[89]!==h||e[90]!==g||e[91]!==$?(A=a.jsxs("button",{type:f,onClick:m,title:p,className:h,children:[g,$]}),e[86]=f,e[87]=m,e[88]=p,e[89]=h,e[90]=g,e[91]=$,e[92]=A):A=e[92];let R;e[93]!==t.matchedPullRequestNumber||e[94]!==t.pullRequests?(R=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),e[93]=t.matchedPullRequestNumber,e[94]=t.pullRequests,e[95]=R):R=e[95];let P;e[96]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(it,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[96]=P):P=e[96];let z;e[97]!==R?(z=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[R,P]}),e[97]=R,e[98]=z):z=e[98];let L;return e[99]!==x||e[100]!==A||e[101]!==z?(L=a.jsxs("div",{className:x,children:[A,z]}),e[99]=x,e[100]=A,e[101]=z,e[102]=L):L=e[102],L}function Pxe(n){const e=V.c(63),{selectedProject:t,filterEmpty:s,sessions:r,sessionsTotal:o,sessionsLoading:i,searchLoading:l,searchFilter:c,setSearchFilter:u,filteredSessions:d,fetchError:f,onSelectSession:m,onNewSession:p,creatingSession:h,onDuplicateSession:g,onDeleteSession:x,onBack:b,onRetryFetch:w,loadMoreSessions:v}=n,{names:j,rename:k}=Ff(),_=Pm();let N;e[0]!==t.path?(N=Er(t.path),e[0]=t.path,e[1]=N):N=e[1];const S=N;let C;e[2]!==b?(C=a.jsx(W1,{children:a.jsx(XI,{render:a.jsx("button",{type:"button",onClick:b}),children:"Projects"})}),e[2]=b,e[3]=C):C=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(QI,{}),e[4]=E):E=e[4];let T;e[5]!==S?(T=a.jsx(W1,{className:"min-w-0",children:a.jsx(JI,{className:"truncate",children:S})}),e[5]=S,e[6]=T):T=e[6];let $;e[7]!==C||e[8]!==T?($=a.jsx(ZI,{children:a.jsxs(YI,{children:[C,E,T]})}),e[7]=C,e[8]=T,e[9]=$):$=e[9];let A;e[10]!==S?(A=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:S}),e[10]=S,e[11]=A):A=e[11];let R;e[12]!==o?(R=a.jsx(Fe,{variant:"secondary",children:o}),e[12]=o,e[13]=R):R=e[13];let P;e[14]!==A||e[15]!==R?(P=a.jsxs("div",{className:"flex items-center gap-2",children:[A,R]}),e[14]=A,e[15]=R,e[16]=P):P=e[16];let z;e[17]!==t.path?(z=jc(t.path),e[17]=t.path,e[18]=z):z=e[18];let L;e[19]!==z?(L=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:z}),e[19]=z,e[20]=L):L=e[20];let I;e[21]!==L||e[22]!==P?(I=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[P,L]}),e[21]=L,e[22]=P,e[23]=I):I=e[23];let M;e[24]!==c||e[25]!==l||e[26]!==u?(M=a.jsx(n7,{value:c,onChange:u,placeholder:"Search sessions or PRs...",loading:l}),e[24]=c,e[25]=l,e[26]=u,e[27]=M):M=e[27];let F;e[28]!==h||e[29]!==p||e[30]!==t.dirName||e[31]!==t.path?(F=p&&a.jsxs(Q,{size:"sm",disabled:h,onClick:()=>p(t.dirName,t.path),children:[h?a.jsx(Pn,{"data-icon":"inline-start"}):a.jsx(kr,{"data-icon":"inline-start"}),"New Session"]}),e[28]=h,e[29]=p,e[30]=t.dirName,e[31]=t.path,e[32]=F):F=e[32];let U;e[33]!==M||e[34]!==F?(U=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,F]}),e[33]=M,e[34]=F,e[35]=U):U=e[35];let O;e[36]!==f||e[37]!==w?(O=f&&a.jsx(s7,{message:f,onRetry:w}),e[36]=f,e[37]=w,e[38]=O):O=e[38];let D;e[39]!==s||e[40]!==d||e[41]!==v||e[42]!==x||e[43]!==g||e[44]!==m||e[45]!==_||e[46]!==k||e[47]!==c||e[48]!==l||e[49]!==t.dirName||e[50]!==j||e[51]!==r||e[52]!==i||e[53]!==o?(D=(i||l)&&d.length===0?a.jsx(r7,{includeMessagePlaceholder:!0}):d.length===0?a.jsx($xe,{searchFilter:c,filterEmpty:s}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((W,H)=>a.jsxs(y.Fragment,{children:[H>0&&a.jsx(tn,{}),a.jsx(sv,{sessionLabel:c7(W),customName:j[W.sessionId],onRename:K=>k(W.sessionId,K),onDuplicate:g?()=>g(t.dirName,W.fileName):void 0,onDelete:x&&_(W.access).delete?()=>x(t.dirName,W.fileName):void 0,children:a.jsx(Ixe,{session:W,customName:j[W.sessionId],onSelect:()=>m(t.dirName,W.fileName)})})]},W.fileName))}),r.length<o&&!c&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(Q,{variant:"outline",size:"sm",disabled:i,onClick:v,children:[i&&a.jsx(Pn,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=s,e[40]=d,e[41]=v,e[42]=x,e[43]=g,e[44]=m,e[45]=_,e[46]=k,e[47]=c,e[48]=l,e[49]=t.dirName,e[50]=j,e[51]=r,e[52]=i,e[53]=o,e[54]=D):D=e[54];let B;e[55]!==U||e[56]!==O||e[57]!==D?(B=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[U,O,D]}),e[55]=U,e[56]=O,e[57]=D,e[58]=B):B=e[58];let q;return e[59]!==I||e[60]!==B||e[61]!==$?(q=a.jsx(Vc,{className:"h-full",children:a.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:[$,I,B]})}),e[59]=I,e[60]=B,e[61]=$,e[62]=q):q=e[62],q}function $xe(n){const e=V.c(8),{searchFilter:t,filterEmpty:s}=n;if(!t&&s)return s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Yn,{variant:"icon",children:a.jsx(vc,{})}),e[0]=r):r=e[0];const o=t?"No sessions match your search":"No sessions yet";let i;e[1]!==o?(i=a.jsx(zn,{children:o}),e[1]=o,e[2]=i):i=e[2];const l=t?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here.";let c;e[3]!==l?(c=a.jsx(Dn,{children:l}),e[3]=l,e[4]=c):c=e[4];let u;return e[5]!==i||e[6]!==c?(u=a.jsx(Ln,{className:"min-h-72 border",children:a.jsxs(Mn,{children:[r,i,c]})}),e[5]=i,e[6]=c,e[7]=u):u=e[7],u}function u7(n){const e=V.c(40),{children:t,projectLabel:s,customName:r,className:o,onRename:i,archivableCount:l,onArchiveIdle:c}=n,u=l===void 0?0:l,[d,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==r?(g=function(){p(r||""),f(!0),requestAnimationFrame(()=>{var M;return(M=h.current)==null?void 0:M.select()})},e[0]=r,e[1]=g):g=e[1];const x=g;let b;e[2]!==o?(b=G("w-full",o),e[2]=o,e[3]=b):b=e[3];let w;e[4]!==b?(w=a.jsx("div",{className:b}),e[4]=b,e[5]=w):w=e[5];let v;e[6]!==t||e[7]!==w?(v=a.jsx(Cm,{render:w,children:t}),e[6]=t,e[7]=w,e[8]=v):v=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(wr,{"data-icon":"inline-start"}),e[9]=j):j=e[9];let k;e[10]!==x?(k=a.jsx(fi,{children:a.jsxs(Rn,{onClick:x,children:[j,"Rename project"]})}),e[10]=x,e[11]=k):k=e[11];let _;e[12]!==u||e[13]!==c?(_=c&&a.jsxs(a.Fragment,{children:[a.jsx(va,{}),a.jsx(fi,{children:a.jsxs(Rn,{onClick:c,disabled:u===0,children:[a.jsx(Ns,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=_):_=e[14];let N;e[15]!==k||e[16]!==_?(N=a.jsxs(_m,{className:"min-w-44",children:[k,_]}),e[15]=k,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==v||e[19]!==N?(S=a.jsxs(Nm,{children:[v,N]}),e[18]=v,e[19]=N,e[20]=S):S=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsxs(ao,{children:[a.jsx(or,{className:"text-foreground",children:"Rename project"}),a.jsx(ir,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=C):C=e[21];let E;e[22]!==i||e[23]!==m?(E=I=>{I.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=E):E=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(mn,{htmlFor:"project-rename",children:"Project name"}),e[25]=T):T=e[25];let $;e[26]===Symbol.for("react.memo_cache_sentinel")?($=I=>p(I.target.value),e[26]=$):$=e[26];let A;e[27]!==s||e[28]!==m?(A=a.jsxs(fn,{children:[T,a.jsx(On,{id:"project-rename",ref:h,value:m,onChange:$,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=A):A=e[29];let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsxs(Rx,{children:[a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(Q,{type:"submit",size:"sm",children:"Save"})]}),e[30]=R):R=e[30];let P;e[31]!==E||e[32]!==A?(P=a.jsxs(rr,{className:"sm:max-w-md",children:[C,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:E,children:[A,R]})]}),e[31]=E,e[32]=A,e[33]=P):P=e[33];let z;e[34]!==d||e[35]!==P?(z=a.jsx(sr,{open:d,onOpenChange:f,children:P}),e[34]=d,e[35]=P,e[36]=z):z=e[36];let L;return e[37]!==S||e[38]!==z?(L=a.jsxs(a.Fragment,{children:[S,z]}),e[37]=S,e[38]=z,e[39]=L):L=e[39],L}function Rxe(n){const e=V.c(47),{projects:t,activeSessions:s,loading:r,refreshing:o,searchFilter:i,setSearchFilter:l,fetchError:c,selectedProjectDirName:u,onSelectProject:d,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const I of s)l7(I.lastModified)&&(m[I.dirName]=(m[I.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=nv();let x;e[2]!==t?(x=e7(t),e[2]=t,e[3]=x):x=e[3];const b=x;let w;e:{if(!i){w=b;break e}let I;if(e[4]!==h||e[5]!==b||e[6]!==i){const M=i.toLowerCase(),F=U=>{var O;return U.path.toLowerCase().includes(M)||U.shortName.toLowerCase().includes(M)||((O=h[U.dirName])==null?void 0:O.toLowerCase().includes(M))};I=b.filter(U=>F(U)||U.worktrees.some(F)),e[4]=h,e[5]=b,e[6]=i,e[7]=I}else I=e[7];w=I}const v=w;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[8]=j):j=e[8];let k;e[9]!==b.length?(k=a.jsxs("div",{className:"flex items-center gap-2",children:[j,a.jsx(Fe,{variant:"secondary",children:b.length})]}),e[9]=b.length,e[10]=k):k=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[11]=_):_=e[11];let N;e[12]!==k?(N=a.jsxs("header",{className:"flex flex-col gap-1",children:[k,_]}),e[12]=k,e[13]=N):N=e[13];let S;e[14]!==i||e[15]!==l?(S=a.jsx(n7,{value:i,onChange:l,placeholder:"Filter projects..."}),e[14]=i,e[15]=l,e[16]=S):S=e[16];const C=o&&"animate-spin";let E;e[17]!==C?(E=G(C),e[17]=C,e[18]=E):E=e[18];let T;e[19]!==E?(T=a.jsx(Fn,{"data-icon":"inline-start",className:E}),e[19]=E,e[20]=T):T=e[20];let $;e[21]!==f||e[22]!==o||e[23]!==T?($=a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[21]=f,e[22]=o,e[23]=T,e[24]=$):$=e[24];let A;e[25]!==$||e[26]!==S?(A=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,$]}),e[25]=$,e[26]=S,e[27]=A):A=e[27];let R;e[28]!==c||e[29]!==f||e[30]!==u?(R=c&&!u&&a.jsx(s7,{message:c,onRetry:f}),e[28]=c,e[29]=f,e[30]=u,e[31]=R):R=e[31];let P;e[32]!==p||e[33]!==v||e[34]!==r||e[35]!==d||e[36]!==h||e[37]!==g||e[38]!==i?(P=r?a.jsx(r7,{}):v.length===0?a.jsxs(Ln,{className:"min-h-72 border",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Yr,{})}),a.jsx(zn,{children:i?"No projects match your search":"No projects yet"}),a.jsx(Dn,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]}),!i&&a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:Oxe,children:[a.jsx(wc,{"data-icon":"inline-start"}),"Start in a folder"]})})]}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map((I,M)=>{const F=p[I.dirName]||0,U=h[I.dirName],O=CM(un(I.dirName));return a.jsxs(y.Fragment,{children:[M>0&&a.jsx(tn,{}),a.jsx(u7,{projectLabel:Er(I.path),customName:U,onRename:D=>g(I.dirName,D),children:a.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(I.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:a.jsx(wa,{projectPath:I.path,className:"size-4",fallback:a.jsx(Yr,{className:"size-4 text-muted-foreground"})})}),a.jsxs("span",{className:"min-w-0",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:U||Er(I.path)}),O&&a.jsx(Fe,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:O})]}),a.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[jc(I.path),I.worktrees.length>0&&a.jsxs(a.Fragment,{children:[" · ",I.worktrees.length," ",I.worktrees.length===1?"worktree":"worktrees"]})]})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[F>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),F," active"]}),a.jsxs("span",{className:"whitespace-nowrap",children:[I.sessionCount," ",I.sessionCount===1?"session":"sessions"]}),I.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:_r(I.lastModified)}),a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})}),I.worktrees.map(D=>a.jsx(Lxe,{worktree:D,customName:h[D.dirName],activeCount:p[D.dirName]||0,onSelect:()=>d==null?void 0:d(D.dirName)},D.dirName))]},I.dirName)})}),e[32]=p,e[33]=v,e[34]=r,e[35]=d,e[36]=h,e[37]=g,e[38]=i,e[39]=P):P=e[39];let z;e[40]!==A||e[41]!==R||e[42]!==P?(z=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[A,R,P]}),e[40]=A,e[41]=R,e[42]=P,e[43]=z):z=e[43];let L;return e[44]!==z||e[45]!==N?(L=a.jsx(Vc,{className:"h-full",children:a.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:[N,z]})}),e[44]=z,e[45]=N,e[46]=L):L=e[46],L}function Oxe(){return AI()}function Lxe(n){var b;const e=V.c(23),{worktree:t,customName:s,activeCount:r,onSelect:o}=n;let i;e[0]!==s||e[1]!==t.path?(i=s||((b=Cr(t.path))==null?void 0:b.worktreeName)||Er(t.path),e[0]=s,e[1]=t.path,e[2]=i):i=e[2];const l=i;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Zr,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[3]=c):c=e[3];let u;e[4]!==l?(u=a.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground group-hover:text-foreground",children:l}),e[4]=l,e[5]=u):u=e[5];let d;e[6]!==r?(d=r>0&&a.jsxs(Fe,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),r," active"]}),e[6]=r,e[7]=d):d=e[7];const f=t.sessionCount===1?"session":"sessions";let m;e[8]!==f||e[9]!==t.sessionCount?(m=a.jsxs("span",{className:"whitespace-nowrap",children:[t.sessionCount," ",f]}),e[8]=f,e[9]=t.sessionCount,e[10]=m):m=e[10];let p;e[11]!==t.lastModified?(p=t.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:_r(t.lastModified)}),e[11]=t.lastModified,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"}),e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==m||e[16]!==p?(g=a.jsxs("span",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[d,m,p,h]}),e[14]=d,e[15]=m,e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==o||e[19]!==u||e[20]!==g||e[21]!==t.path?(x=a.jsxs("button",{type:"button",onClick:o,title:t.path,className:"motion-list-item group flex w-full items-center gap-3 py-2 pl-15 pr-4 text-left text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[c,u,g]}),e[18]=o,e[19]=u,e[20]=g,e[21]=t.path,e[22]=x):x=e[22],x}const Mxe=250,zxe=400,$j={results:null,loading:!1,error:null};function d7(n,e,t){const s=y.useMemo(()=>i7(n),[n]),[r,o]=y.useState(0),[i,l]=y.useState($j);y.useEffect(()=>{if(!s){l($j);return}const d=new AbortController;l({results:null,loading:!0,error:null});let f=null;const m=async()=>{const h=new URLSearchParams({search:n.trim(),limit:"200"});t&&h.set("project",t);const g=Jr();try{const x=await Ce(zf(h,e),{signal:d.signal});if(!x.ok)throw new Error(`Search failed (${x.status})`);const b=await x.json();if(d.signal.aborted)return;const w=Number(x.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(w)&&w>0){f=setTimeout(()=>{m()},zxe);return}const v=Array.isArray(b)?b:[];la(v,g),l({results:v,loading:!1,error:null})}catch(x){if(d.signal.aborted)return;l({results:[],loading:!1,error:x instanceof Error?x.message:"Search failed"})}},p=setTimeout(()=>{m()},Mxe);return()=>{clearTimeout(p),f&&clearTimeout(f),d.abort()}},[e,t,s,n,r]);const c=y.useCallback(()=>o(d=>d+1),[]),u=s!==null;return y.useEffect(()=>{if(u)return Df(c)},[u,c]),{...i,active:u,refresh:c}}const Dxe=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){var se;const c=Mf(),u=(se=$r().sessionListFilter)==null?void 0:se.Empty,[d]=y.useState(()=>({projects:Zi(Ql.projects),activeSessions:Zi(td(c.key))})),[f,m]=y.useState(d.projects??[]),[p,h]=y.useState(d.activeSessions??[]),[g,x]=y.useState(d.projects===void 0),[b,w]=y.useState(!1),[v,j]=y.useState(null),[k,_]=y.useState(null),[N,S]=y.useState([]),[C,E]=y.useState(0),[T,$]=y.useState(1),[A,R]=y.useState(!1),[P,z]=y.useState(""),[L,I]=y.useState(null),M=y.useRef(0),F=y.useRef(null),U=y.useRef(null),O=y.useRef(c.key),D=y.useCallback(async()=>{try{const X=await Ce("/api/projects");if(!X.ok)throw new Error("Failed to fetch dashboard data");const ne=await X.json(),ae=Array.isArray(ne)?ne:[];m(ae),_l(Ql.projects,ae),j(null)}catch(X){j(X instanceof Error?X.message:"Failed to load data")}finally{x(!1)}},[]),B=y.useCallback(async()=>{var ae;(ae=U.current)==null||ae.abort();const X=new AbortController;U.current=X;const ne=Jr();try{const ie=await Ce(zf({},c),{signal:X.signal});if(!ie.ok)throw new Error("Failed to fetch dashboard data");const re=await ie.json();if(X.signal.aborted)return;const de=Array.isArray(re)?re:[];la(de,ne),h(de),_l(td(c.key),de),_(null)}catch(ie){if(X.signal.aborted)return;_(ie instanceof Error?ie.message:"Failed to load data")}},[c]);y.useEffect(()=>{D()},[D]),y.useEffect(()=>{O.current!==c.key&&(O.current=c.key,h(Zi(td(c.key))??[])),B()},[c,B]);async function q(){w(!0),await Promise.all([D(),B()]),w(!1)}const W=y.useCallback(async(X,ne=1,ae=!1)=>{var oe;const ie=++M.current;(oe=F.current)==null||oe.abort();const re=new AbortController;F.current=re;const de=()=>ie===M.current;R(!0),I(null);const ce=Jr();if(!ae){const fe=B9(X,c.key);fe?(S(fe.sessions),E(fe.total),$(1)):S([])}try{const fe=await Ce(El(`/api/sessions/${encodeURIComponent(X)}`,c,{page:String(ne),limit:"20"}),{signal:re.signal});if(!fe.ok)throw new Error(`Failed to load sessions (${fe.status})`);const ue=await fe.json();if(!de())return;const le=Array.isArray(ue.sessions)?ue.sessions:[],pe=typeof ue.total=="number"?ue.total:le.length;la(le,ce),S(ge=>ae?[...ge,...le]:le),E(pe),$(ne),ae||W9(X,c.key,{sessions:le,total:pe})}catch(fe){if(!de()||re.signal.aborted)return;I(fe instanceof Error?fe.message:"Failed to load sessions")}finally{de()&&(F.current=null,R(!1))}},[c]);y.useEffect(()=>{var X;if(!r){M.current+=1,(X=F.current)==null||X.abort(),F.current=null,S([]),E(0),$(1),R(!1);return}W(r)},[r,W]),y.useEffect(()=>{z("")},[r]),y.useEffect(()=>()=>{var X,ne;M.current+=1,(X=F.current)==null||X.abort(),(ne=U.current)==null||ne.abort()},[]),y.useEffect(()=>Df(()=>{B(),r&&W(r)}),[B,W,r]);const H=y.useMemo(()=>{if(!r)return null;const X=f.find(ae=>ae.dirName===r);if(X)return X;const ne=xs(r);return{dirName:r,path:ne,shortName:Er(ne),sessionCount:C,lastModified:null}},[r,f,C]),K=y.useCallback(()=>{o==null||o(null)},[o]),Z=y.useCallback(()=>{r&&W(r,T+1,!0)},[r,T,W]),Y=d7(r?P:"",c,r??void 0),J=y.useMemo(()=>P?N.filter(X=>Nxe(X,P)):N,[N,P]),ee=Y.results??J;async function te(X,ne){await(l==null?void 0:l(X,ne))&&(S(ae=>ae.filter(ie=>ie.fileName!==ne)),E(ae=>ae-1))}return H?a.jsx(Pxe,{selectedProject:H,filterEmpty:c.key!==null&&u?a.jsx(u,{className:"min-h-72 border"}):null,sessions:N,sessionsTotal:C,sessionsLoading:A,searchLoading:Y.loading,searchFilter:P,setSearchFilter:z,filteredSessions:ee,fetchError:Y.error??L,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:te,onBack:K,onRetryFetch:()=>{if(Y.error){Y.refresh();return}I(null),r&&W(r)},loadMoreSessions:Z}):a.jsx(Rxe,{projects:f,activeSessions:p,loading:g,refreshing:b,searchFilter:P,setSearchFilter:z,fetchError:v??k,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>void q()})}),Rj=768;function rv(){const n=V.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<Rj:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${Rj-1}px)`),i=l=>t(l.matches);return o.addEventListener("change",i),t(o.matches),()=>o.removeEventListener("change",i)},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}const f7=typeof navigator<"u"&&"vibrate"in navigator;function H1(){f7&&navigator.vibrate(10)}function Fxe(){f7&&navigator.vibrate(20)}function Uxe(n){return!!(n.teamName&&n.agentName)}function Bxe(n,e,t,s,r,o,i,l=()=>!0){const c=[],u=[];for(const d of Ia(n)){const f=p=>{l(d)&&c.push({session:d,reason:p})};if(s!=null&&s.has(d.sessionId)){f("permission");continue}if(r!=null&&r.has(d.sessionId)){f("question");continue}if(o!=null&&o.has(d.sessionId)){f("prompt");continue}if(i!=null&&i.has(d.sessionId)){f("plan");continue}if(d.agentStatus==="deferred"){f("deferred");continue}if(Uxe(d))continue;const m=Dx(d,e);if(d.agentStatus==="completed"||!m){t.has(d.sessionId)&&f("done");continue}if(d.agentStatus==="idle"){f("waiting");continue}(!d.agentStatus||$f.has(d.agentStatus))&&u.push(d)}return{needsYou:c,working:u}}function Wxe(n,e,t,s,r=()=>!0){const o=[...n.needsYou],i=[...n.working],l=new Map;for(const u of e){const d=t.get(u.sessionId);if(!(d!=null&&d.length))continue;const f=Ux(d,p=>{const h=s(p);return h.state==="needs-you"&&!r(p)?{state:"done"}:h}),m=o.findIndex(p=>p.session.sessionId===u.sessionId);if(f.needsYou>0)if(m>=0)o[m]={...o[m],crew:f};else{o.push({session:u,reason:"crew",crew:f});const p=i.indexOf(u);p>=0&&i.splice(p,1)}else f.working>0&&m<0&&!i.includes(u)&&(i.push(u),l.set(u.sessionId,f))}const c=u=>{var d;return u.reason==="crew"&&((d=u.crew)!=null&&d.longestWaitSince)?Date.parse(u.crew.longestWaitSince):Nr(u.session)};return o.sort((u,d)=>c(d)-c(u)),{needsYou:o,working:Ia(i),workingCrews:l}}function m7(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"}}const p7="aw:turnCounts",qxe=200,$m=new Map;try{const n=localStorage.getItem(p7);if(n){const e=JSON.parse(n);for(const[t,s]of e)$m.set(t,s)}}catch{}function Vxe(){try{const n=[...$m.entries()].slice(-qxe);localStorage.setItem(p7,JSON.stringify(n))}catch{}}function Hxe(n,e){$m.set(sn(n),e),Vxe()}function h7(n,e){const t=$m.get(sn(n));return Math.max(t??0,e??0)}function ov(n){const e=V.c(51),{session:t,proc:s,statusLabel:r,customName:o,worktreeName:i,projectLabel:l}=n,c=o||t.aiTitle,u=t.firstUserMessage,d=t.lastUserMessage&&t.lastUserMessage!==u?t.lastUserMessage:void 0,f=h7(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&a.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(ra,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==r?(h=r&&a.jsx("span",{className:G("font-medium",wm(t.agentStatus)),children:r}),e[4]=t.agentStatus,e[5]=r,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(tr,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Ns,{className:"size-3"}),Mx(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let b;e[13]!==u||e[14]!==d?(b=u&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:u})})]}),e[13]=u,e[14]=d,e[15]=b):b=e[15];let w;e[16]!==d?(w=d&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:d})})]}),e[16]=d,e[17]=w):w=e[17];let v;e[18]!==t.pullRequests?(v=a.jsx(su,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=v):v=e[19];let j;e[20]!==t.gitBranch||e[21]!==i?(j=t.gitBranch&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(Zr,{className:"size-2.5"}),i?`${t.gitBranch} · ${i}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=i,e[22]=j):j=e[22];let k;e[23]!==f?(k=f>0&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(vc,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=k):k=e[24];let _;e[25]!==t.size?(_=kN(t.size),e[25]=t.size,e[26]=_):_=e[26];let N;e[27]!==_?(N=a.jsx("span",{children:_}),e[27]=_,e[28]=N):N=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(U8,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const C=t.lastActivityAt||t.lastModified;let E;e[31]!==C?(E=_r(C),e[31]=C,e[32]=E):E=e[32];let T;e[33]!==E?(T=a.jsx("span",{children:E}),e[33]=E,e[34]=T):T=e[34];let $;e[35]!==k||e[36]!==N||e[37]!==S||e[38]!==T||e[39]!==j?($=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[j,k,N,S,T]}),e[35]=k,e[36]=N,e[37]=S,e[38]=T,e[39]=j,e[40]=$):$=e[40];let A;return e[41]!==m||e[42]!==$||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==b||e[48]!==w||e[49]!==v?(A=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,w,v,$]}),e[41]=m,e[42]=$,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=w,e[49]=v,e[50]=A):A=e[50],A}const Kxe=120;function iv(n){const e=V.c(7),t=y.useRef(null);let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},r=[],e[0]=s,e[1]=r):(s=e[0],r=e[1]),y.useEffect(s,r);let o;e[2]!==n?(o=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,Kxe))},e[2]=n,e[3]=o):o=e[3];const i=o;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 u;return e[5]!==i?(u={onHoverStart:i,onHoverEnd:c},e[5]=i,e[6]=u):u=e[6],u}const Gxe=6;function Zxe(n,e){var s;const t=(s=e.workingCrews)==null?void 0:s.get(n.sessionId);return t?`${t.working} in crew`:m7(n)}function Yxe(n){const e=V.c(7),{iso:t}=n,[,s]=y.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(Xxe),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2],y.useEffect(r,o);let i;e[3]!==t?(i=_r(t),e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==i?(l=a.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i}),e[5]=i,e[6]=l):l=e[6],l}function Xxe(n){return n+1}const Jxe={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"},crew:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"}};function Qxe({reason:n,crew:e}){const t=Jxe[n];return n==="crew"&&e?{...t,label:`${e.needsYou} waiting`}:t}const e0e={permission:Hs.attention,deferred:Hs.attention,waiting:Hs.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success",crew:Hs.attention};function Oj(n){const e=V.c(77),{session:t,chip:s,dotClassName:r,cardClassName:o,since:i,isActiveSession:l,proc:c,killingPids:u,customName:d,projectLabel:f,compact:m,onSelect:p,onKill:h,onResume:g,onPrefetch:x}=n,b=m===void 0?!1:m;let w;e[0]!==c||e[1]!==t.dirName?(w=Ob(un(t.dirName),c),e[0]=c,e[1]=t.dirName,e[2]=w):w=e[2];const v=w;let j;e[3]!==s||e[4]!==v||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(j=v?"Read-only":Jc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=v,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=j):j=e[9];const k=j,_=!!g&&!v,{onHoverStart:N,onHoverEnd:S}=iv(x),C=b?"px-2.5 py-2":"border px-2 py-2",E=l&&!b&&"ring-1 ring-ring";let T;e[10]!==o||e[11]!==C||e[12]!==E?(T=G("group relative w-full rounded-md text-left transition-colors",C,o,E),e[10]=o,e[11]=C,e[12]=E,e[13]=T):T=e[13];let $;e[14]!==b||e[15]!==l?($=b&&l&&a.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=b,e[15]=l,e[16]=$):$=e[16];const A=_&&"pr-20";let R;e[17]!==A?(R=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[17]=A,e[18]=R):R=e[18];let P;e[19]!==S||e[20]!==N||e[21]!==p||e[22]!==R?(P=a.jsx("button",{type:"button","data-attention-session":!0,onClick:p,onMouseEnter:N,onMouseLeave:S,onFocus:N,onBlur:S,className:R}),e[19]=S,e[20]=N,e[21]=p,e[22]=R,e[23]=P):P=e[23];const z=b&&"ring-0";let L;e[24]!==r||e[25]!==z?(L=G("size-1.5 shrink-0 rounded-full",r,z),e[24]=r,e[25]=z,e[26]=L):L=e[26];let I;e[27]!==L?(I=a.jsx("span",{className:L,"aria-hidden":"true"}),e[27]=L,e[28]=I):I=e[28];let M;e[29]!==d||e[30]!==t?(M=pi(t,d),e[29]=d,e[30]=t,e[31]=M):M=e[31];let F;e[32]!==M?(F=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:M}),e[32]=M,e[33]=F):F=e[33];const U=b?"text-muted-foreground":s.className;let O;e[34]!==U?(O=G("shrink-0",U),e[34]=U,e[35]=O):O=e[35];const D=v?"Read-only":s.label;let B;e[36]!==O||e[37]!==D?(B=a.jsx(Fe,{variant:"outline",className:O,children:D}),e[36]=O,e[37]=D,e[38]=B):B=e[38];let q;e[39]!==b||e[40]!==t.lastActivityAt||e[41]!==t.lastModified||e[42]!==i?(q=!b&&a.jsx(Yxe,{iso:i??(t.lastActivityAt||t.lastModified)}),e[39]=b,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=i,e[43]=q):q=e[43];let W;e[44]!==I||e[45]!==F||e[46]!==B||e[47]!==q?(W=a.jsxs("span",{className:"flex items-center gap-1.5",children:[I,F,B,q]}),e[44]=I,e[45]=F,e[46]=B,e[47]=q,e[48]=W):W=e[48];let H;e[49]!==f?(H=a.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[49]=f,e[50]=H):H=e[50];let K;e[51]!==P||e[52]!==W||e[53]!==H?(K=a.jsxs(Zt,{render:P,children:[W,H]}),e[51]=P,e[52]=W,e[53]=H,e[54]=K):K=e[54];let Z;e[55]!==d||e[56]!==c||e[57]!==t||e[58]!==k?(Z=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(ov,{session:t,proc:c,statusLabel:k,customName:d})}),e[55]=d,e[56]=c,e[57]=t,e[58]=k,e[59]=Z):Z=e[59];let Y;e[60]!==K||e[61]!==Z?(Y=a.jsxs(Gt,{children:[K,Z]}),e[60]=K,e[61]=Z,e[62]=Y):Y=e[62];let J;e[63]!==_||e[64]!==g?(J=_&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:g,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Resume"]}),e[63]=_,e[64]=g,e[65]=J):J=e[65];let ee;e[66]!==v||e[67]!==u||e[68]!==h||e[69]!==c?(ee=c&&h&&!v&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:se=>h(c.pid,se),disabled:u.has(c.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${c.pid}`,"aria-label":`Kill process ${c.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[66]=v,e[67]=u,e[68]=h,e[69]=c,e[70]=ee):ee=e[70];let te;return e[71]!==Y||e[72]!==J||e[73]!==ee||e[74]!==T||e[75]!==$?(te=a.jsxs("div",{className:T,children:[$,Y,J,ee]}),e[71]=Y,e[72]=J,e[73]=ee,e[74]=T,e[75]=$,e[76]=te):te=e[76],te}function t0e(n){const e=V.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=G("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r||e[7]!==c?(u=a.jsx("span",{className:c,children:r}),e[6]=r,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==o?(d=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,u,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function n0e(n){const e=V.c(28),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,m=Pm(),[p,h]=y.useState(!1);let g;e[0]!==t.working||e[1]!==p?(g=p?t.working:t.working.slice(0,Gxe),e[0]=t.working,e[1]=p,e[2]=g):g=e[2];const x=g,b=t.working.length-x.length;let w;e[3]!==l?(w=C=>l[C.dirName]||Lx(C.cwd||xs(C.dirName)),e[3]=l,e[4]=w):w=e[4];const v=w;let j;e[5]!==s||e[6]!==o||e[7]!==u||e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==r||e[12]!==v||e[13]!==i?(j=C=>{const E=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:E,proc:r.get(C.sessionId),killingPids:o,customName:i[C.sessionId],projectLabel:v(C),onSelect:()=>c(C.dirName,C.fileName),onKill:m(C.access).stop?u:void 0,onPrefetch:f&&!E?()=>f(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=o,e[7]=u,e[8]=f,e[9]=c,e[10]=m,e[11]=r,e[12]=v,e[13]=i,e[14]=j):j=e[14];const k=j;let _;e[15]!==t.needsYou||e[16]!==d||e[17]!==m||e[18]!==k?(_=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(t0e,{dotClassName:Hs.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{var $;const{session:E,reason:T}=C;return a.jsx(Oj,{...k(E),chip:Qxe(C),since:T==="crew"?($=C.crew)==null?void 0:$.longestWaitSince:void 0,dotClassName:e0e[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onResume:T==="deferred"&&d&&m(E.access).send?()=>d(E.sessionId,E.cwd,E.dirName):void 0},`${E.dirName}/${E.fileName}`)})]}),e[15]=t.needsYou,e[16]=d,e[17]=m,e[18]=k,e[19]=_):_=e[19];let N;e[20]!==t||e[21]!==b||e[22]!==k||e[23]!==x?(N=t.working.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between px-1",children:[a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),a.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:x.map(C=>a.jsx(Oj,{...k(C),chip:{label:Zxe(C,t),className:""},dotClassName:Hs.working,cardClassName:"hover:bg-accent/50",compact:!0},`${C.dirName}/${C.fileName}`))}),b>0&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(!0),className:"justify-start",children:[a.jsx(Et,{"data-icon":"inline-start"}),"Show ",b," more"]})]}),e[20]=t,e[21]=b,e[22]=k,e[23]=x,e[24]=N):N=e[24];let S;return e[25]!==_||e[26]!==N?(S=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[_,N]}),e[25]=_,e[26]=N,e[27]=S):S=e[27],S}function s0e(n){const e=V.c(49),{loading:t,isMobile:s,searchQuery:r,searchLoading:o,showArchived:i,archivedCount:l,groupCrews:c,onToggleGroupCrews:u,onSearchQueryChange:d,onToggleShowArchived:f,onRefresh:m}=n,p=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let h;e[0]!==d?(h=F=>d(F.target.value),e[0]=d,e[1]=h):h=e[1];let g;e[2]!==o||e[3]!==r||e[4]!==h?(g=a.jsx(Go,{type:"search",value:r,onChange:h,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":o}),e[2]=o,e[3]=r,e[4]=h,e[5]=g):g=e[5];let x;e[6]!==o?(x=a.jsx(Ar,{align:"inline-start",children:o?a.jsx(St,{className:"animate-spin"}):a.jsx(ss,{})}),e[6]=o,e[7]=x):x=e[7];let b;e[8]!==d||e[9]!==r?(b=r&&a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>d(""),"aria-label":"Clear session search",children:a.jsx(Mt,{"data-icon":"inline-start"})})}),e[8]=d,e[9]=r,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==x||e[13]!==b?(w=a.jsxs(Ko,{children:[g,x,b]}),e[11]=g,e[12]=x,e[13]=b,e[14]=w):w=e[14];let v;e[15]!==c||e[16]!==s||e[17]!==u?(v=u&&a.jsxs(Gt,{children:[a.jsx(Zt,{render:a.jsx(Q,{variant:"ghost",size:s?"icon-sm":"icon-xs",onClick:u,"aria-pressed":c,"aria-label":c?"List spawned sessions on their own":"Group spawned sessions",className:G(c&&"bg-accent text-accent-foreground")}),children:a.jsx(D4,{"data-icon":"inline-start"})}),a.jsx(Yt,{side:"bottom",children:c?"Sessions another session started are listed under it":"Group spawned sessions under the session that started them"})]}),e[15]=c,e[16]=s,e[17]=u,e[18]=v):v=e[18];const j=s?"icon-sm":"icon-xs",k=i?"Hide archived sessions":"Show archived sessions",_=i&&"bg-accent text-accent-foreground";let N;e[19]!==_?(N=G(_),e[19]=_,e[20]=N):N=e[20];let S;e[21]!==f||e[22]!==i||e[23]!==N||e[24]!==j||e[25]!==k?(S=a.jsx(Q,{variant:"ghost",size:j,onClick:f,"aria-pressed":i,"aria-label":k,className:N}),e[21]=f,e[22]=i,e[23]=N,e[24]=j,e[25]=k,e[26]=S):S=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Ns,{"data-icon":"inline-start"}),e[27]=C):C=e[27];let E;e[28]!==S?(E=a.jsx(Zt,{render:S,children:C}),e[28]=S,e[29]=E):E=e[29];const T=i?"Hide archived":"Show archived";let $;e[30]!==p||e[31]!==T?($=a.jsxs(Yt,{side:"bottom",children:[T," · ",p]}),e[30]=p,e[31]=T,e[32]=$):$=e[32];let A;e[33]!==E||e[34]!==$?(A=a.jsxs(Gt,{children:[E,$]}),e[33]=E,e[34]=$,e[35]=A):A=e[35];const R=s?"icon-sm":"icon-xs",P=t&&"animate-spin";let z;e[36]!==P?(z=G(P),e[36]=P,e[37]=z):z=e[37];let L;e[38]!==z?(L=a.jsx(Fn,{"data-icon":"inline-start",className:z}),e[38]=z,e[39]=L):L=e[39];let I;e[40]!==m||e[41]!==R||e[42]!==L?(I=a.jsx(Q,{variant:"ghost",size:R,onClick:m,"aria-label":"Refresh sessions",children:L}),e[40]=m,e[41]=R,e[42]=L,e[43]=I):I=e[43];let M;return e[44]!==A||e[45]!==I||e[46]!==w||e[47]!==v?(M=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[w,v,A,I]}),e[44]=A,e[45]=I,e[46]=w,e[47]=v,e[48]=M):M=e[48],M}const r0e=["first","second","third","fourth","fifth"];function o0e(n){const e=V.c(33),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,filterEmpty:d,onShowArchived:f,onRetry:m}=n,p=c===void 0?null:c,h=d===void 0?null:d,g=!!h;let x;e[0]!==p||e[1]!==l||e[2]!==r||e[3]!==s||e[4]!==g?(x=a0e({showEmpty:s,searching:r,focusedProject:p,hiddenArchivedCount:l,filtered:g}),e[0]=p,e[1]=l,e[2]=r,e[3]=s,e[4]=g,e[5]=x):x=e[5];const b=x;let w;e[6]!==t||e[7]!==m?(w=t&&a.jsxs(kt,{variant:"destructive",children:[a.jsx(er,{}),a.jsx(Xt,{children:"Could not load sessions"}),a.jsx(_t,{className:"truncate",children:t}),a.jsx(Hr,{children:a.jsx(Q,{variant:"outline",size:"xs",onClick:m,children:"Retry"})})]}),e[6]=t,e[7]=m,e[8]=w):w=e[8];let v;e[9]!==b||e[10]!==l||e[11]!==f?(v=b==="archived"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(Ns,{})}),a.jsx(zn,{children:"Everything is archived"}),a.jsx(Dn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(Q,{variant:"outline",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]}),e[9]=b,e[10]=l,e[11]=f,e[12]=v):v=e[12];let j;e[13]!==b||e[14]!==p||e[15]!==l||e[16]!==u||e[17]!==f||e[18]!==r?(j=b==="focused"&&a.jsxs(Ln,{className:"min-h-56 px-4 py-8",children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(wg,{})}),a.jsx(zn,{children:r?`No matching sessions in ${p}`:`No sessions in ${p}`}),a.jsx(Dn,{children:l0e(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(Q,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(jd,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(Q,{variant:"ghost",size:"sm",onClick:f,children:[a.jsx(Ns,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[13]=b,e[14]=p,e[15]=l,e[16]=u,e[17]=f,e[18]=r,e[19]=j):j=e[19];const k=b==="filtered"&&h;let _;e[20]!==b||e[21]!==r?(_=b==="plain"&&a.jsx(Ln,{className:"min-h-56 px-4 py-8",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(wg,{})}),a.jsx(zn,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(Dn,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[20]=b,e[21]=r,e[22]=_):_=e[22];let N;e[23]!==o||e[24]!==i?(N=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:r0e.map(i0e)}),e[23]=o,e[24]=i,e[25]=N):N=e[25];let S;return e[26]!==N||e[27]!==w||e[28]!==v||e[29]!==j||e[30]!==k||e[31]!==_?(S=a.jsxs(a.Fragment,{children:[w,v,j,k,_,N]}),e[26]=N,e[27]=w,e[28]=v,e[29]=j,e[30]=k,e[31]=_,e[32]=S):S=e[32],S}function i0e(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Gn,{className:"size-2 shrink-0 rounded-full"}),a.jsx(Gn,{className:"h-4 flex-1"}),a.jsx(Gn,{className:"h-4 w-10"})]},n)}function a0e({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s,filtered:r}){return n?t!==null?"focused":!e&&s>0?"archived":!e&&r?"filtered":"plain":null}function l0e(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const ug=864e5;function c0e(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function u0e(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=c0e(e);return t>=s?"Today":t>=s-ug?"Yesterday":t>=s-6*ug?"Last 7 days":t>=s-29*ug?"Last 30 days":"Older"}const d0e=6,f0e={permission:"permission",question:"question",input:"input",plan:"plan",deferred:"deferred"},Lj={"needs-you":0,working:1,done:2};function m0e(n){const e=V.c(39),{host:t,members:s,counts:r,statusOf:o,open:i,onToggle:l,sessionNames:c,activeSessionKey:u,onSelectSession:d}=n,[f,m]=y.useState(!1);let p;if(e[0]!==u||e[1]!==r.needsYou||e[2]!==r.size||e[3]!==r.working||e[4]!==t||e[5]!==s||e[6]!==d||e[7]!==l||e[8]!==i||e[9]!==c||e[10]!==f||e[11]!==o){const h=new Map([t,...s].map(p0e)),g=I=>!I.crew||I.crew.parentId===t.sessionId||!h.has(I.crew.parentId);let x;e[13]!==g||e[14]!==o?(x=I=>g(I)||o(I).state==="needs-you",e[13]=g,e[14]=o,e[15]=x):x=e[15];const b=s.filter(x);let w;e[16]!==o?(w=(I,M)=>Lj[o(I).state]-Lj[o(M).state]||(o(I).state==="done"?Nr(M)-Nr(I):0),e[16]=o,e[17]=w):w=e[17];const v=[...b].sort(w);let j;e[18]!==o?(j=I=>o(I).state==="done",e[18]=o,e[19]=j):j=e[19];const k=v.filter(j),_=f?[]:k.slice(d0e),N=v.filter(I=>!_.includes(I)),S=`Crew of ${r.size}${r.needsYou?`, ${r.needsYou} need you`:""}${r.working?`, ${r.working} working`:""}`,C=i?`Hide crew: ${S}`:`Show crew: ${S}`,E=i&&"rotate-90";let T;e[20]!==E?(T=G("size-3 shrink-0 transition-transform duration-150",E),e[20]=E,e[21]=T):T=e[21];let $;e[22]!==T?($=a.jsx(it,{className:T,"aria-hidden":"true"}),e[22]=T,e[23]=$):$=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx("span",{className:"font-medium text-foreground",children:"Crew"}),e[24]=A):A=e[24];let R;e[25]!==r.size?(R=a.jsxs("span",{className:"tabular-nums",children:["· ",r.size]}),e[25]=r.size,e[26]=R):R=e[26];let P;e[27]!==r.needsYou?(P=r.needsYou>0&&a.jsxs("span",{className:"tabular-nums text-warning",children:["· ",r.needsYou," need you"]}),e[27]=r.needsYou,e[28]=P):P=e[28];let z;e[29]!==r.working?(z=r.working>0&&a.jsxs("span",{className:"tabular-nums",children:["· ",r.working," working"]}),e[29]=r.working,e[30]=z):z=e[30];let L;e[31]!==l||e[32]!==i||e[33]!==R||e[34]!==P||e[35]!==z||e[36]!==C||e[37]!==$?(L=a.jsxs("button",{type:"button",onClick:l,"aria-expanded":i,"aria-label":C,className:"flex w-full items-center gap-1.5 rounded-sm py-0.5 text-left text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[$,A,R,P,z]}),e[31]=l,e[32]=i,e[33]=R,e[34]=P,e[35]=z,e[36]=C,e[37]=$,e[38]=L):L=e[38],p=a.jsxs("div",{"data-crew-fold":!0,className:"mx-3 mb-2 ml-[26px] border-t border-border/60 pt-1.5",children:[L,i&&a.jsxs("ul",{className:"mt-1 ml-1.5 flex flex-col gap-px border-l border-border/70 pl-1.5",children:[N.map(I=>{var H;const M=o(I),F=R9(I.sessionId,s),U=I.crew?h.get(I.crew.parentId):void 0,O=u===`${I.dirName}/${I.fileName}`,D=Pd(I,{customName:c[I.sessionId],parent:U??t}),B=g0e(I,M),W=(!g(I)&&U?` · via ${Pd(U,{customName:c[U.sessionId],parent:h.get(((H=U.crew)==null?void 0:H.parentId)??"")??t})}`:"")||(F>0?` · ${F} ${F===1?"session":"sessions"}`:"");return a.jsx("li",{children:a.jsxs("button",{type:"button","data-crew-member":I.sessionId,"aria-current":O?"true":void 0,"aria-label":`${D}${W}, ${B}`,onClick:()=>d(I.dirName,I.fileName),className:G("flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",O&&"bg-accent"),children:[a.jsx("span",{className:G("size-1.5 shrink-0 rounded-full",h0e(M)),"aria-hidden":"true"}),a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[D,W&&a.jsx("span",{className:"text-muted-foreground/70",children:W})]}),a.jsx("span",{className:G("shrink-0 text-[11px] tabular-nums",M.state==="needs-you"?"text-warning":"text-muted-foreground/80"),children:B})]})},I.sessionId)}),_.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>m(!0),className:"rounded-sm px-1.5 py-1 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:["Show ",_.length," more done"]})})]})]}),e[0]=u,e[1]=r.needsYou,e[2]=r.size,e[3]=r.working,e[4]=t,e[5]=s,e[6]=d,e[7]=l,e[8]=i,e[9]=c,e[10]=f,e[11]=o,e[12]=p}else p=e[12];return p}function p0e(n){return[n.sessionId,n]}function h0e({state:n}){return n==="needs-you"?Hs.attention:n==="working"?Hs.working:"bg-muted-foreground/50"}function g0e(n,{state:e,need:t}){var o;const s=_r(n.lastActivityAt||n.lastModified);if(e==="needs-you")return`${f0e[t??"input"]} · ${s}`;if(e==="working")return m7(n);const r=(o=n.pullRequests)==null?void 0:o.at(-1);return r?`#${r.number} · ${s}`:s}const x0e={};function b0e(n){var Lr,_n;const e=V.c(172),{session:t,projectLabel:s,projectPath:r,showProject:o,isActiveSession:i,proc:l,killingPids:c,isNewlyCompleted:u,customName:d,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N,crew:S,lineage:C,sessionNames:E,activeSessionKey:T}=n,$=E===void 0?x0e:E,A=T===void 0?null:T,{isLive:R,isRunning:P,isNativeIdle:z,isDeferred:L,isReadOnly:I,isTeammate:M,isArchived:F,statusLabel:U,dotState:O,justFinished:D}=Lb(t,l,u),[B,q]=y.useState(!1);let W;e[0]!==d||e[1]!==t?(W=_N(t,d),e[0]=d,e[1]=t,e[2]=W):W=e[2];const H=W,K=j9(t,d),Z=o&&!C?s:void 0,Y=v0e(S==null?void 0:S.counts,O),J=S!==void 0&&Date.parse(S.activityAt)>Nr(t),ee=t.lastUserMessage||t.firstUserMessage,te=!!ee&&ee!==H,se=h7(t.sessionId,t.turnCount);let X;e[3]!==t.archivedReason?(X=Mx(t.archivedReason),e[3]=t.archivedReason,e[4]=X):X=e[4];const ne=X,ae=F?j&&{label:"Restore from archive",icon:Cf,run:()=>j(t)}:v&&!P&&{label:"Archive session",icon:Ns,run:()=>v(t)},ie=L&&!!N&&!I,re=!!m&&!!h,de=!!t.matchedPullRequestNumber||!!((Lr=t.pullRequests)!=null&&Lr.length),ce=ie||re||de;let oe;e[5]!==i||e[6]!==_||e[7]!==t.dirName||e[8]!==t.fileName?(oe=_&&!i?()=>_(t.dirName,t.fileName):void 0,e[5]=i,e[6]=_,e[7]=t.dirName,e[8]=t.fileName,e[9]=oe):oe=e[9];const{onHoverStart:fe,onHoverEnd:ue}=iv(oe);let le;e[10]!==N||e[11]!==B||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(le=()=>{!N||B||(q(!0),N(t.sessionId,t.cwd,t.dirName),setTimeout(()=>q(!1),3e3))},e[10]=N,e[11]=B,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=le):le=e[15];const pe=le,ge=!0,be=F||void 0,ve=G("motion-list-item group relative flex flex-col rounded-lg border transition-colors",y0e(i,D),F&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let Se;e[16]!==C?(Se=C&&a.jsxs("button",{type:"button","data-crew-lineage":!0,onClick:C.onOpenParent,"aria-label":`Open ${C.parentTitle}, which started this session`,className:"flex min-w-0 items-center gap-1.5 rounded-t-lg px-3 pl-[26px] pt-2.5 text-left text-[11px] leading-tight outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(mx,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":"true"}),a.jsx("span",{className:"truncate text-foreground/90",children:C.parentTitle}),C.rootTitle&&a.jsxs("span",{className:"truncate text-muted-foreground",children:["· ",C.rootTitle]})]}),e[16]=C,e[17]=Se):Se=e[17];let we;e[18]!==g||e[19]!==t.dirName||e[20]!==t.fileName?(we=()=>g(t.dirName,t.fileName),e[18]=g,e[19]=t.dirName,e[20]=t.fileName,e[21]=we):we=e[21];const Ee=i?"true":void 0,$e=C?"pt-1":"pt-2.5",Be=ce||S?"pb-1.5":"pb-2.5";let qe;e[22]!==$e||e[23]!==Be?(qe=G("flex w-full flex-col gap-1.5 rounded-lg px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",$e,Be),e[22]=$e,e[23]=Be,e[24]=qe):qe=e[24];let ze;e[25]!==ue||e[26]!==fe||e[27]!==we||e[28]!==Ee||e[29]!==qe?(ze=a.jsx("button",{type:"button","data-live-session":!0,onClick:we,onMouseEnter:fe,onMouseLeave:ue,onFocus:fe,onBlur:ue,"aria-current":Ee,className:qe}),e[25]=ue,e[26]=fe,e[27]=we,e[28]=Ee,e[29]=qe,e[30]=ze):ze=e[30];let Ie;e[31]!==Z||e[32]!==r?(Ie=Z&&a.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[a.jsx(wa,{projectPath:r,fallback:a.jsx(ra,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:Z})]}),e[31]=Z,e[32]=r,e[33]=Ie):Ie=e[33];let Me;e[34]!==Y?(Me=Y&&a.jsx("span",{"data-status-dot":Y,className:G("size-1.5 rounded-full",Hs[Y])}),e[34]=Y,e[35]=Me):Me=e[35];let Ue;e[36]!==Me?(Ue=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:Me}),e[36]=Me,e[37]=Ue):Ue=e[37];const De=K?"text-muted-foreground":"font-medium text-foreground";let Ke;e[38]!==De?(Ke=G("line-clamp-2 flex-1 text-sm leading-snug",De),e[38]=De,e[39]=Ke):Ke=e[39];let Ne;e[40]!==H||e[41]!==Ke?(Ne=a.jsx("span",{className:Ke,children:H}),e[40]=H,e[41]=Ke,e[42]=Ne):Ne=e[42];let Ae;e[43]!==Ue||e[44]!==Ne?(Ae=a.jsxs("span",{className:"flex items-start gap-2",children:[Ue,Ne]}),e[43]=Ue,e[44]=Ne,e[45]=Ae):Ae=e[45];let Qe;e[46]!==ee||e[47]!==te?(Qe=te&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:ee}),e[46]=ee,e[47]=te,e[48]=Qe):Qe=e[48];let Je;e[49]!==L||e[50]!==R||e[51]!==z||e[52]!==t.agentStatus||e[53]!==U?(Je=R&&!L&&U&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G(z?"text-success":wm(t.agentStatus)),children:U}),e[49]=L,e[50]=R,e[51]=z,e[52]=t.agentStatus,e[53]=U,e[54]=Je):Je=e[54];let ke;e[55]!==L?(ke=L&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[55]=L,e[56]=ke):ke=e[56];let We;e[57]!==H||e[58]!==M||e[59]!==t.agentName?(We=M&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),H!==t.agentName?t.agentName:"Agent"]}),e[57]=H,e[58]=M,e[59]=t.agentName,e[60]=We):We=e[60];let ye;e[61]!==t.access?(ye=a.jsx(o7,{access:t.access}),e[61]=t.access,e[62]=ye):ye=e[62];let Re;e[63]!==f?(Re=f&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Zr,{"data-icon":"inline-start"}),f]}),e[63]=f,e[64]=Re):Re=e[64];let Ve;e[65]!==t.gitBranch||e[66]!==f?(Ve=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(Zr,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[65]=t.gitBranch,e[66]=f,e[67]=Ve):Ve=e[67];let He;e[68]!==se?(He=se>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(vc,{className:"size-3 shrink-0","aria-hidden":"true"}),se," ",se===1?"turn":"turns"]}),e[68]=se,e[69]=He):He=e[69];let me;e[70]!==ne||e[71]!==F?(me=F&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ns,{className:"size-3 shrink-0","aria-label":ne,role:"img"}),"Archived"]}),e[70]=ne,e[71]=F,e[72]=me):me=e[72];let je;e[73]!==S||e[74]!==J||e[75]!==t?(je=J?a.jsxs("span",{"data-crew-activity":!0,className:G("ml-auto tabular-nums",EN({...t,lastActivityAt:S.activityAt})&&"text-success"),children:["crew active ",_r(S.activityAt)]}):a.jsx("span",{className:"ml-auto tabular-nums",children:_r(t.lastActivityAt||t.lastModified)}),e[73]=S,e[74]=J,e[75]=t,e[76]=je):je=e[76];let Xe;e[77]!==Je||e[78]!==ke||e[79]!==We||e[80]!==ye||e[81]!==Re||e[82]!==Ve||e[83]!==He||e[84]!==me||e[85]!==je?(Xe=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Je,ke,We,ye,Re,Ve,He,me,je]}),e[77]=Je,e[78]=ke,e[79]=We,e[80]=ye,e[81]=Re,e[82]=Ve,e[83]=He,e[84]=me,e[85]=je,e[86]=Xe):Xe=e[86];let tt;e[87]!==ze||e[88]!==Ie||e[89]!==Ae||e[90]!==Qe||e[91]!==Xe?(tt=a.jsxs(Zt,{render:ze,children:[Ie,Ae,Qe,Xe]}),e[87]=ze,e[88]=Ie,e[89]=Ae,e[90]=Qe,e[91]=Xe,e[92]=tt):tt=e[92];const dt=Z?void 0:s;let zt;e[93]!==d||e[94]!==l||e[95]!==t||e[96]!==U||e[97]!==dt||e[98]!==f?(zt=a.jsx(Yt,{side:"right",className:"max-w-[320px]",children:a.jsx(ov,{session:t,proc:l,statusLabel:U,customName:d,worktreeName:f,projectLabel:dt})}),e[93]=d,e[94]=l,e[95]=t,e[96]=U,e[97]=dt,e[98]=f,e[99]=zt):zt=e[99];let st;e[100]!==tt||e[101]!==zt?(st=a.jsxs(Gt,{children:[tt,zt]}),e[100]=tt,e[101]=zt,e[102]=st):st=e[102];let Tt;e[103]!==ie||e[104]!==pe||e[105]!==ce||e[106]!==re||e[107]!==h||e[108]!==B||e[109]!==t.matchedPullRequestNumber||e[110]!==t.pullRequests||e[111]!==m||e[112]!==p?(Tt=ce&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:2,compact:!0}),re&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[a.jsx(tr,{"data-icon":"inline-start"}),m,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!p&&"rotate-90")})]}),ie&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:pe,disabled:B,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Resume"]})]}),e[103]=ie,e[104]=pe,e[105]=ce,e[106]=re,e[107]=h,e[108]=B,e[109]=t.matchedPullRequestNumber,e[110]=t.pullRequests,e[111]=m,e[112]=p,e[113]=Tt):Tt=e[113];let At;e[114]!==A||e[115]!==S||e[116]!==g||e[117]!==t||e[118]!==$?(At=S&&a.jsx(m0e,{host:t,members:S.members,counts:S.counts,statusOf:S.statusOf,open:S.open,onToggle:S.onToggle,sessionNames:$,activeSessionKey:A,onSelectSession:g}),e[114]=A,e[115]=S,e[116]=g,e[117]=t,e[118]=$,e[119]=At):At=e[119];let Qt;e[120]!==ae||e[121]!==S?(Qt=ae&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:ae.run,className:G("absolute right-1.5 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",S?"top-1.5":"bottom-1.5"),title:ae.label,"aria-label":ae.label,children:a.jsx(ae.icon,{"data-icon":"inline-start"})}),e[120]=ae,e[121]=S,e[122]=Qt):Qt=e[122];let It;e[123]!==S||e[124]!==F||e[125]!==I||e[126]!==P||e[127]!==c||e[128]!==x||e[129]!==l?(It=l&&x&&P&&!F&&!I&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:Is=>x(l.pid,Is),disabled:c.has(l.pid),className:G("absolute right-1.5 bg-popover text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",S?"top-1.5":"bottom-1.5"),title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[123]=S,e[124]=F,e[125]=I,e[126]=P,e[127]=c,e[128]=x,e[129]=l,e[130]=It):It=e[130];let Qn;e[131]!==Se||e[132]!==st||e[133]!==Tt||e[134]!==At||e[135]!==Qt||e[136]!==It||e[137]!==be||e[138]!==ve?(Qn=a.jsxs("div",{"data-session-card":ge,"data-archived":be,className:ve,children:[Se,st,Tt,At,Qt,It]}),e[131]=Se,e[132]=st,e[133]=Tt,e[134]=At,e[135]=Qt,e[136]=It,e[137]=be,e[138]=ve,e[139]=Qn):Qn=e[139];const kn=Qn;if(b||w||k||v||j){let Is;e[140]!==t.firstUserMessage||e[141]!==t.sessionId||e[142]!==t.slug?(Is=t.slug||((_n=t.firstUserMessage)==null?void 0:_n.slice(0,30))||t.sessionId.slice(0,12),e[140]=t.firstUserMessage,e[141]=t.sessionId,e[142]=t.slug,e[143]=Is):Is=e[143];let Ps;e[144]!==b||e[145]!==t.dirName||e[146]!==t.fileName?(Ps=b?()=>b(t.dirName,t.fileName):void 0,e[144]=b,e[145]=t.dirName,e[146]=t.fileName,e[147]=Ps):Ps=e[147];let ur;e[148]!==w||e[149]!==t?(ur=w?()=>w(t):void 0,e[148]=w,e[149]=t,e[150]=ur):ur=e[150];let dr;e[151]!==k||e[152]!==t.sessionId?(dr=k?ji=>k(t.sessionId,ji):void 0,e[151]=k,e[152]=t.sessionId,e[153]=dr):dr=e[153];let us;e[154]!==F||e[155]!==v||e[156]!==t?(us=v&&!F?()=>v(t):void 0,e[154]=F,e[155]=v,e[156]=t,e[157]=us):us=e[157];let $s;e[158]!==F||e[159]!==j||e[160]!==t?($s=j&&F?()=>j(t):void 0,e[158]=F,e[159]=j,e[160]=t,e[161]=$s):$s=e[161];let ki;return e[162]!==kn||e[163]!==d||e[164]!==P||e[165]!==Is||e[166]!==Ps||e[167]!==ur||e[168]!==dr||e[169]!==us||e[170]!==$s?(ki=a.jsx(sv,{sessionLabel:Is,customName:d,onDuplicate:Ps,onDelete:ur,onRename:dr,onArchive:us,onUnarchive:$s,archiveDisabled:P,children:kn}),e[162]=kn,e[163]=d,e[164]=P,e[165]=Is,e[166]=Ps,e[167]=ur,e[168]=dr,e[169]=us,e[170]=$s,e[171]=ki):ki=e[171],ki}return kn}function v0e(n,e){return n?n.needsYou>0||e==="attention"?"attention":n.working>0?"working":e:e}function y0e(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 bg-card hover:border-border hover:bg-accent"}function w0e(n){var ue;const e=V.c(87),{session:t,isActiveSession:s,proc:r,killingPids:o,isNewlyCompleted:i,customName:l,worktreeName:c,teammateCount:u,teammatesCollapsed:d,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:w,onPrefetchSession:v,onResumeSession:j}=n,{isLive:k,isRunning:_,isNativeIdle:N,isDeferred:S,isReadOnly:C,isTeammate:E,isArchived:T,statusLabel:$,dotState:A,justFinished:R}=Lb(t,r,i),[P,z]=y.useState(!1);let L;e[0]!==t.archivedReason?(L=Mx(t.archivedReason),e[0]=t.archivedReason,e[1]=L):L=e[1];const I=L;let M;e[2]!==l||e[3]!==t?(M=pi(t,l),e[2]=l,e[3]=t,e[4]=M):M=e[4];const F=M,U=T?b&&{label:"Restore from archive",icon:Cf,run:()=>b(t)}:x&&!_&&{label:"Archive session",icon:Ns,run:()=>x(t)};let O;e[5]!==s||e[6]!==v||e[7]!==t.dirName||e[8]!==t.fileName?(O=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[5]=s,e[6]=v,e[7]=t.dirName,e[8]=t.fileName,e[9]=O):O=e[9];const{onHoverStart:D,onHoverEnd:B}=iv(O);let q;e[10]!==j||e[11]!==P||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(q=le=>{le.stopPropagation(),!(!j||P)&&(z(!0),j(t.sessionId,t.cwd,t.dirName),setTimeout(()=>z(!1),3e3))},e[10]=j,e[11]=P,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=q):q=e[15];const W=q,H=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",S0e(s,R),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Z;e[20]!==B||e[21]!==D||e[22]!==K?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:D,onMouseLeave:B,onFocus:D,onBlur:B,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[20]=B,e[21]=D,e[22]=K,e[23]=Z):Z=e[23];let Y;e[24]!==F?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:F}),e[24]=F,e[25]=Y):Y=e[25];let J;e[26]!==S?(J=S&&a.jsx(Fe,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=J):J=e[27];let ee;e[28]!==c?(ee=c&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(Zr,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=ee):ee=e[29];let te;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==$||e[34]!==c?(te=a.jsx(Yt,{side:"right",className:"max-w-[280px]",children:a.jsx(ov,{session:t,proc:r,statusLabel:$,customName:l,worktreeName:c})}),e[30]=l,e[31]=r,e[32]=t,e[33]=$,e[34]=c,e[35]=te):te=e[35];let se;e[36]!==f||e[37]!==u||e[38]!==d?(se=!!u&&f&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:d?"Show team agents":"Hide team agents","aria-label":d?`Show ${u} team agents`:`Hide ${u} team agents`,"aria-expanded":!d,children:[a.jsx(tr,{"data-icon":"inline-start"}),u,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=se):se=e[39];let X;e[40]!==W||e[41]!==S||e[42]!==C||e[43]!==j||e[44]!==P?(X=S&&j&&!C&&a.jsxs(Q,{type:"button",variant:"outline",size:"xs",onClick:W,disabled:P,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(Ca,{"data-icon":"inline-start"}),"Resume"]}),e[40]=W,e[41]=S,e[42]=C,e[43]=j,e[44]=P,e[45]=X):X=e[45];let ne;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(ne=t.matchedPullRequestNumber?a.jsxs(Fe,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(su,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=ne):ne=e[48];let ae;e[49]!==I||e[50]!==T?(ae=T&&a.jsx(Ns,{className:"size-3 shrink-0 text-muted-foreground","aria-label":I,role:"img"}),e[49]=I,e[50]=T,e[51]=ae):ae=e[51];const ie=t.lastActivityAt||t.lastModified;let re;e[52]!==ie?(re=_r(ie),e[52]=ie,e[53]=re):re=e[53];let de;e[54]!==re?(de=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:re}),e[54]=re,e[55]=de):de=e[55];let ce;e[56]!==U?(ce=U&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:le=>{le.stopPropagation(),U.run()},className:"absolute right-0 top-0 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:U.label,"aria-label":U.label,children:a.jsx(U.icon,{"data-icon":"inline-start"})}),e[56]=U,e[57]=ce):ce=e[57];let oe;e[58]!==T||e[59]!==C||e[60]!==_||e[61]!==o||e[62]!==p||e[63]!==r?(oe=r&&p&&_&&!T&&!C&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-xs",onClick:le=>p(r.pid,le),disabled:o.has(r.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${r.pid}`,"aria-label":`Kill process ${r.pid}`,children:a.jsx(Mt,{"data-icon":"inline-start"})}),e[58]=T,e[59]=C,e[60]=_,e[61]=o,e[62]=p,e[63]=r,e[64]=oe):oe=e[64];const fe=a.jsxs("div",{className:H,"data-archived":T||void 0,children:[a.jsxs(Gt,{children:[a.jsxs(Zt,{render:Z,children:[a.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:A&&a.jsx("span",{"data-status-dot":A,className:G("size-1.5 rounded-full",Hs[A])})}),Y,E&&a.jsxs(Fe,{variant:"outline",children:[a.jsx(mi,{"data-icon":"inline-start"}),F!==t.agentName?t.agentName:"Agent"]}),k&&!S&&$&&a.jsx(Fe,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&wm(t.agentStatus)),children:$}),J,ee]}),te]}),se,X,ne,ae,de,ce,oe]});if(h||g||w||x||b){let le;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(le=t.slug||((ue=t.firstUserMessage)==null?void 0:ue.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=le):le=e[68];let pe;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(pe=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=pe):pe=e[72];let ge;e[73]!==g||e[74]!==t?(ge=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=ge):ge=e[75];let be;e[76]!==w||e[77]!==t.sessionId?(be=w?we=>w(t.sessionId,we):void 0,e[76]=w,e[77]=t.sessionId,e[78]=be):be=e[78];let ve;e[79]!==T||e[80]!==x||e[81]!==t?(ve=x&&!T?()=>x(t):void 0,e[79]=T,e[80]=x,e[81]=t,e[82]=ve):ve=e[82];let Se;return e[83]!==T||e[84]!==b||e[85]!==t?(Se=b&&T?()=>b(t):void 0,e[83]=T,e[84]=b,e[85]=t,e[86]=Se):Se=e[86],a.jsx(sv,{sessionLabel:le,customName:l,onDuplicate:pe,onDelete:ge,onRename:be,onArchive:ve,onUnarchive:Se,archiveDisabled:_,children:fe})}return fe}function S0e(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}const k0e={state:"done"};function j0e(n){const e=V.c(84),{sessions:t,pendingSession:s,older:r,showProject:o,groupCrews:i,lineageSessions:l,memberStatusOf:c,activeSessionKey:u,procBySession:d,killingPids:f,newlyCompleted:m,sessionNames:p,projectNames:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:j,onRenameSession:k,onPrefetchSession:_,onResumeSession:N}=n,S=i===void 0?!0:i,C=c===void 0?C0e:c,E=Pm();let T,$,A,R;if(e[0]!==S||e[1]!==t){T=S?Fx(t):{topLevel:t,crewOf:new Map},$=N9(T.topLevel);const ue=be=>{const ve=T.crewOf.get(be.sessionId);return ve?zy(be,ve):be.lastActivityAt||be.lastModified},le=new Map($.topLevelSessions.map(be=>[{...be,lastActivityAt:ue(be)},be]));R=Ia([...le.keys()]).map(be=>le.get(be));const pe=Date.now(),ge=R.map(be=>u0e(ue(be),pe));A=ge.map((be,ve)=>be===ge[ve-1]?null:be),e[0]=S,e[1]=t,e[2]=T,e[3]=$,e[4]=A,e[5]=R}else T=e[2],$=e[3],A=e[4],R=e[5];const P=A;let z;e[6]!==T.crewOf||e[7]!==P||e[8]!==$.teammatesByLead||e[9]!==R?(z={topLevelSessions:R,teammatesByLead:$.teammatesByLead,crewOf:T.crewOf,shelves:P},e[6]=T.crewOf,e[7]=P,e[8]=$.teammatesByLead,e[9]=R,e[10]=z):z=e[10];const{topLevelSessions:L,teammatesByLead:I,crewOf:M,shelves:F}=z;let U,O;e[11]===Symbol.for("react.memo_cache_sentinel")?(U=sn("live-sessions-open-crews"),O=[],e[11]=U,e[12]=O):(U=e[11],O=e[12]);const[D,B]=jr(U,O);let q;e[13]!==D?(q=Array.isArray(D)?D:[],e[13]=D,e[14]=q):q=e[14];let W;e[15]!==q?(W=new Set(q),e[15]=q,e[16]=W):W=e[16];const H=W;let K;e[17]!==D||e[18]!==B?(K=ue=>{const le=Array.isArray(D)?D:[];B(le.includes(ue)?le.filter(pe=>pe!==ue):[...le,ue])},e[17]=D,e[18]=B,e[19]=K):K=e[19];const Z=K;let Y;e[20]!==l?(Y=l??[],e[20]=l,e[21]=Y):Y=e[21];let J;e[22]!==t||e[23]!==Y?(J=new Map([...Y,...t].map(N0e)),e[22]=t,e[23]=Y,e[24]=J):J=e[24];const ee=J;let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=new Set,e[25]=te):te=e[25];const[se,X]=y.useState(te);let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=ue=>{X(le=>{const pe=new Set(le);return pe.has(ue)?pe.delete(ue):pe.add(ue),pe})},e[26]=ne):ne=e[26];const ae=ne;let ie;e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==v||e[31]!==w||e[32]!==b||e[33]!==x||e[34]!==_||e[35]!==k||e[36]!==N||e[37]!==g||e[38]!==j||e[39]!==E||e[40]!==d||e[41]!==p?(ie=ue=>{const le=E(ue.access);return{session:ue,isActiveSession:u===dg(ue),proc:d.get(ue.sessionId),killingPids:f,isNewlyCompleted:m.has(ue.sessionId),customName:p[ue.sessionId],onSelectSession:g,onKill:le.stop?x:void 0,onDuplicateSession:b,onDeleteSession:le.delete?w:void 0,onArchiveSession:le.archive?v:void 0,onUnarchiveSession:le.archive?j:void 0,onRenameSession:k,onPrefetchSession:_,onResumeSession:le.send?N:void 0}},e[27]=u,e[28]=f,e[29]=m,e[30]=v,e[31]=w,e[32]=b,e[33]=x,e[34]=_,e[35]=k,e[36]=N,e[37]=g,e[38]=j,e[39]=E,e[40]=d,e[41]=p,e[42]=ie):ie=e[42];const re=ie;let de;e[43]!==s?(de=s&&a.jsx(T0e,{firstMessage:s.firstMessage}),e[43]=s,e[44]=de):de=e[44];let ce;if(e[45]!==u||e[46]!==se||e[47]!==M||e[48]!==ee||e[49]!==C||e[50]!==g||e[51]!==H||e[52]!==h||e[53]!==re||e[54]!==p||e[55]!==F||e[56]!==o||e[57]!==I||e[58]!==Z||e[59]!==L){let ue;e[61]!==u||e[62]!==se||e[63]!==M||e[64]!==ee||e[65]!==C||e[66]!==g||e[67]!==H||e[68]!==h||e[69]!==re||e[70]!==p||e[71]!==F||e[72]!==o||e[73]!==I||e[74]!==Z?(ue=(le,pe)=>{const ge=dg(le),be=le.cwd??xs(le.dirName),ve=Cr(be),Se=h[le.dirName]??Nl(le),we=I.get(le.sessionId),Ee=se.has(le.sessionId),$e=F[pe],Be=M.get(le.sessionId),qe=Be&&{members:Be,counts:Ux(Be,C),statusOf:C,activityAt:zy(le,Be),open:H.has(le.sessionId),onToggle:()=>Z(le.sessionId)},ze=a.jsx(b0e,{...re(le),worktreeName:ve==null?void 0:ve.worktreeName,projectLabel:Se,projectPath:(ve==null?void 0:ve.parentPath)??be,showProject:o,teammateCount:we==null?void 0:we.length,teammatesCollapsed:we?Ee:void 0,onToggleTeammates:we?()=>ae(le.sessionId):void 0,crew:qe,lineage:_0e(le,ee,p,g),sessionNames:p,activeSessionKey:u});return a.jsxs(y.Fragment,{children:[$e&&a.jsx(E0e,{label:$e}),we&&!Ee?a.jsxs("div",{className:"flex flex-col gap-px",children:[ze,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:we.map(Ie=>a.jsx(w0e,{...re(Ie)},dg(Ie)))})]}):ze]},ge)},e[61]=u,e[62]=se,e[63]=M,e[64]=ee,e[65]=C,e[66]=g,e[67]=H,e[68]=h,e[69]=re,e[70]=p,e[71]=F,e[72]=o,e[73]=I,e[74]=Z,e[75]=ue):ue=e[75],ce=L.map(ue),e[45]=u,e[46]=se,e[47]=M,e[48]=ee,e[49]=C,e[50]=g,e[51]=H,e[52]=h,e[53]=re,e[54]=p,e[55]=F,e[56]=o,e[57]=I,e[58]=Z,e[59]=L,e[60]=ce}else ce=e[60];let oe;e[76]!==r.canLoad||e[77]!==r.load||e[78]!==r.loading?(oe=r.canLoad&&a.jsxs(Q,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(z4,{"data-icon":"inline-start"}),"Load older sessions"]}),e[76]=r.canLoad,e[77]=r.load,e[78]=r.loading,e[79]=oe):oe=e[79];let fe;return e[80]!==de||e[81]!==ce||e[82]!==oe?(fe=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[de,ce,oe]}),e[80]=de,e[81]=ce,e[82]=oe,e[83]=fe):fe=e[83],fe}function N0e(n){return[n.sessionId,n]}function C0e(){return k0e}function _0e(n,e,t,s){const r=n.crew;if(!r)return;const o=$d(r.parentId,e,t)??r.parentTitle??"Another session",i=r.rootId===r.parentId?void 0:$d(r.rootId,e,t)??r.rootTitle,l=e.get(r.parentId);return{parentTitle:o,...i&&i!==o&&{rootTitle:i},onOpenParent:l?()=>s(l.dirName,l.fileName):()=>void cm(r.parentId)}}function E0e(n){const e=V.c(2),{label:t}=n;let s;return e[0]!==t?(s=a.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function T0e(n){const e=V.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(St,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const r=t||"New session";let o;return e[1]!==r?(o=a.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:r})]}),e[1]=r,e[2]=o):o=e[2],o}function dg(n){return`${n.dirName}/${n.fileName}`}function wo(n,e){return`${n} ${n===1?e:`${e}s`}`}function A0e(n){if(!n)return"No sessions listed";const e=wo(n.total,"session"),t=n.live>0?`${e}, ${n.live} live`:e,s=[n.crews>0&&wo(n.crews,"crew"),n.worktrees>0&&wo(n.worktrees,"worktree")].filter(Boolean);return[t,...s].join(" · ")}function Mj(n){const e=V.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=G("flex shrink-0 items-center gap-1 font-medium text-warning",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=i):i=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==o?(l=a.jsxs("span",{className:o,"aria-label":s,children:[i,t]}),e[3]=t,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function I0e(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function P0e(n){const e=V.c(72),{options:t,value:s,focused:r,totalSessions:o,crewCount:i,onChange:l,onNewSession:c,creatingSession:u,onRenameProject:d,archivableCount:f,onArchiveIdle:m}=n,p=i===void 0?0:i,[h,g]=y.useState(!1),x=(r==null?void 0:r.customName)??s;let b;e[0]!==p||e[1]!==r||e[2]!==t.length||e[3]!==o||e[4]!==s?(b=s===null?`${wo(t.length,"project")}, ${wo(o,"session")}${p>0?` · ${wo(p,"crew")}`:""}`:A0e(r),e[0]=p,e[1]=r,e[2]=t.length,e[3]=o,e[4]=s,e[5]=b):b=e[5];const w=b,v=I0e(t,s);let j;e[6]!==l?(j=ee=>{l(ee),g(!1)},e[6]=l,e[7]=j):j=e[7];const k=j,_=s===null?"Choose a project to focus on":`Focused on ${x}. Change project`;let N;e[8]!==(r==null?void 0:r.cwd)||e[9]!==s?(N=s===null?a.jsx(jd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(wa,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(ra,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[8]=r==null?void 0:r.cwd,e[9]=s,e[10]=N):N=e[10];const S=s===null?"All projects":x;let C;e[11]!==S?(C=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:S}),e[11]=S,e[12]=C):C=e[12];let E;e[13]!==w?(E=a.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:w}),e[13]=w,e[14]=E):E=e[14];let T;e[15]!==C||e[16]!==E?(T=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,E]}),e[15]=C,e[16]=E,e[17]=T):T=e[17];let $;e[18]!==v?($=v>0&&a.jsx(Mj,{count:v,label:v===1?"1 session in another project is waiting for you":`${v} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[18]=v,e[19]=$):$=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(Ea,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[20]=A):A=e[20];let R;e[21]!==$||e[22]!==_||e[23]!==N||e[24]!==T?(R=a.jsxs(Tc,{"aria-label":_,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[N,T,$,A]}),e[21]=$,e[22]=_,e[23]=N,e[24]=T,e[25]=R):R=e[25];const P=R;let z;e[26]!==f||e[27]!==r||e[28]!==m||e[29]!==d||e[30]!==P?(z=r&&d?a.jsx(u7,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:f,onArchiveIdle:m,onRename:ee=>d(r.dirName,ee),children:P}):P,e[26]=f,e[27]=r,e[28]=m,e[29]=d,e[30]=P,e[31]=z):z=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(a0,{placeholder:"Find a project",autoFocus:!0}),e[32]=L):L=e[32];let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx(Ez,{children:"No project matches."}),e[33]=I):I=e[33];const M=s===null;let F;e[34]!==k?(F=()=>k(null),e[34]=k,e[35]=F):F=e[35];let U,O;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(jd,{className:"text-muted-foreground","aria-hidden":"true"}),O=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[36]=U,e[37]=O):(U=e[36],O=e[37]);let D;e[38]!==o?(D=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[38]=o,e[39]=D):D=e[39];let B;e[40]!==M||e[41]!==F||e[42]!==D?(B=a.jsx(xi,{children:a.jsxs(To,{value:"all-projects","data-checked":M,onSelect:F,className:"gap-2.5",children:[U,O,D]})}),e[40]=M,e[41]=F,e[42]=D,e[43]=B):B=e[43];let q;if(e[44]!==t||e[45]!==k||e[46]!==s){let ee;e[48]!==k||e[49]!==s?(ee=te=>a.jsxs(To,{value:te.key,keywords:te.customName?[te.customName]:void 0,"data-checked":s===te.key,onSelect:()=>k(te.key),className:"gap-2.5",children:[a.jsx(wa,{projectPath:te.cwd??null,fallback:a.jsx(ra,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsx("span",{className:"truncate",children:te.customName??te.key}),te.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:te.key})]}),te.needsYou>0&&a.jsx(Mj,{count:te.needsYou,label:`${wo(te.needsYou,"session")} waiting for you`,className:"text-xs"}),te.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":wo(te.live,"live session"),children:[a.jsx(Sm,{className:"size-1.5","aria-hidden":"true"}),te.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:te.total})]},te.key),e[48]=k,e[49]=s,e[50]=ee):ee=e[50],q=t.map(ee),e[44]=t,e[45]=k,e[46]=s,e[47]=q}else q=e[47];let W;e[51]!==q?(W=a.jsx(xi,{heading:"Projects",children:q}),e[51]=q,e[52]=W):W=e[52];let H;e[53]!==B||e[54]!==W?(H=a.jsx(Xx,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(Ic,{children:[L,a.jsxs(Pc,{children:[I,B,W]})]})}),e[53]=B,e[54]=W,e[55]=H):H=e[55];let K;e[56]!==h||e[57]!==z||e[58]!==H?(K=a.jsxs(Ec,{open:h,onOpenChange:g,children:[z,H]}),e[56]=h,e[57]=z,e[58]=H,e[59]=K):K=e[59];let Z;e[60]!==u||e[61]!==r||e[62]!==x||e[63]!==c?(Z=r&&c&&a.jsx(Q,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:u,onClick:()=>c(r.dirName,r.cwd),"aria-label":`New session in ${x}`,children:u?a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(kr,{"data-icon":"inline-start"})}),e[60]=u,e[61]=r,e[62]=x,e[63]=c,e[64]=Z):Z=e[64];let Y;e[65]!==u||e[66]!==c?(Y=c&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",disabled:u,onClick:$0e,"aria-label":"Start a session in a folder",title:"Start a session in a folder",children:a.jsx(wc,{"data-icon":"inline-start"})}),e[65]=u,e[66]=c,e[67]=Y):Y=e[67];let J;return e[68]!==K||e[69]!==Z||e[70]!==Y?(J=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[K,Z,Y]}),e[68]=K,e[69]=Z,e[70]=Y,e[71]=J):J=e[71],J}function $0e(){return AI()}function R0e(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function O0e(n){const e=Cr(n.cwd??xs(n.dirName));if(!e)return{dirName:n.dirName,cwd:n.cwd};const{parentPath:t}=e;return{dirName:vs(n.dirName).dirName.encode(t),cwd:t}}function L0e(n){const e=n.map(t=>{var s;return(s=Cr(t.cwd??xs(t.dirName)))==null?void 0:s.worktreeName});return new Set(e.filter(Boolean)).size}function M0e(n,e,t,s,r=new Map){return[...T9(n).entries()].map(([o,i])=>{const l=C9(i),c=O0e(l);return{key:o,customName:t[c.dirName],...c,dirNames:[...new Set(i.map(u=>u.dirName))],total:i.length,live:R0e(i,e),needsYou:i.filter(u=>s.has(u.sessionId)).length,worktrees:L0e(i),crews:i.filter(u=>r.has(u.sessionId)).length}})}function zj(n,e,t=!1){if(e===null)return n;if(!t)return n.filter(i=>Nl(i)===e);const{topLevel:s,crewOf:r}=Fx(n),o=new Set;for(const i of s)if(Nl(i)===e){o.add(i);for(const l of r.get(i.sessionId)??[])o.add(l)}for(const i of r.values())for(const l of i)Nl(l)===e&&o.add(l);return n.filter(i=>o.has(i))}function z0e(n,e){if(e.length===0)return n;const t=new Set(n.map(r=>r.sessionId)),s=e.filter(r=>!t.has(r.sessionId));return s.length===0?n:Ia([...n,...s])}const Dj={key:null,sessions:[],loading:!1,loaded:!1};function D0e(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function F0e(n,e,t){const s=V.c(14),r=n?`${e?"a":"l"}:${t.key??""}:${n.key}`:null,[o,i]=y.useState(Dj),l=o.key===r?o:Dj;let c;s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==n?(c=async()=>{if(r===null||!n)return;i(g=>g.key===r?{...g,loading:!0}:{key:r,sessions:[],loading:!0,loaded:!1});const h=Jr();try{const x=(await Promise.all(D0e(n,e).map(async b=>{const w=await Ce(zf(b,t));if(!w.ok)throw new Error(`Could not load older sessions (${w.status})`);const v=await w.json();return Array.isArray(v)?v:[]}))).flat();la(x,h),i(b=>b.key===r?{key:r,sessions:x,loading:!1,loaded:!0}:b)}catch(g){const x=g;i(b=>b.key===r?{...b,loading:!1}:b),Kn.error(x instanceof Error?x.message:"Could not load older sessions")}},s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=c):c=s[4];const u=c,{loaded:d}=l;let f,m;s[5]!==u||s[6]!==d?(f=()=>{if(d)return Df(()=>void u())},m=[d,u],s[5]=u,s[6]=d,s[7]=f,s[8]=m):(f=s[7],m=s[8]),y.useEffect(f,m);let p;return s[9]!==l.loading||s[10]!==l.sessions||s[11]!==u||s[12]!==d?(p={sessions:l.sessions,loading:l.loading,loaded:d,load:u},s[9]=l.loading,s[10]=l.sessions,s[11]=u,s[12]=d,s[13]=p):p=s[13],p}const U0e={key:"all"},B0e=y.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:r,onNewSession:o,creatingSession:i,pendingSession:l,refreshRef:c,onPrefetchSession:u}){const{names:d,rename:f}=Ff(),{names:m,rename:p}=nv(),h=sb(),g=Nn("terminal"),x=Nn("killAny"),b=Pm(),w=Mf(),{Control:v,Empty:j}=$r().sessionListFilter??{},{sessions:k,procBySession:_,newlyCompleted:N,loading:S,error:C,refresh:E,removeSession:T,acknowledgeCompleted:$,showArchived:A,setShowArchived:R,setSearchActive:P,archivedCount:z}=Kx(),{awaitingPermission:L,awaitingQuestion:I,awaitingElicitation:M,awaitingDialog:F,awaitingPlan:U}=Spe(),O=y.useMemo(()=>new Set([...M,...F]),[M,F]),[D,B]=y.useState(new Set),[q,W]=y.useState(""),[H,K]=jr(sn("live-sessions-project-scope"),null),[Z,Y]=jr(sn("live-sessions-group-crews"),!0),J=Z!==!1,ee=!!q.trim(),te=J&&!ee,se=A||ee;y.useEffect(()=>(P(ee),()=>P(!1)),[ee,P]);const X=y.useRef(new Set),ne=y.useRef(!1),ae=y.useCallback((ye,Re)=>{if(!ne.current)return;const Ve=setTimeout(()=>{X.current.delete(Ve),ne.current&&ye()},Re);X.current.add(Ve)},[]);y.useEffect(()=>{const ye=X.current;return ne.current=!0,()=>{ne.current=!1;for(const Re of ye)clearTimeout(Re);ye.clear()}},[]),y.useEffect(()=>{if(c)return c.current=E,()=>{c.current===E&&(c.current=null)}},[E,c]);const ie=rv(),re=d7(q,w),de=y.useMemo(()=>E9(k,se),[k,se]),ce=se?0:z,oe=y.useMemo(()=>({awaitingPermission:L,awaitingQuestion:I,awaitingPrompt:O,awaitingPlan:U}),[L,I,O,U]),fe=y.useCallback(ye=>TN(ye,_,oe),[_,oe]),ue=y.useMemo(()=>Fx(de),[de]),le=y.useMemo(()=>{const ye=Ve=>b(Ve.access).canInteract,Re=Bxe(ue.topLevel,_,N,L,I,O,U,ye);return Wxe(Re,ue.topLevel,ue.crewOf,fe,ye)},[ue,_,N,L,I,O,U,b,fe]),pe=y.useMemo(()=>new Set(le.needsYou.map(ye=>ye.session.sessionId)),[le]),ge=J?ue.topLevel:de,be=y.useMemo(()=>M0e(ge,_,m,pe,ue.crewOf),[ge,_,m,pe,ue.crewOf]),ve=H===null?null:be.find(ye=>ye.key===H)??null,Se=(ve==null?void 0:ve.customName)??H,we=F0e(H===null?U0e:ve,se,w),Ee=y.useMemo(()=>z0e(zj(de,H,te),we.sessions),[de,H,te,we.sessions]),$e=y.useMemo(()=>ee?Ee.filter(ye=>{const Re=d[ye.sessionId],Ve=m[ye.dirName];return a7(ye,q,[Re,Ve])}):Ee,[Ee,ee,q,d,m]),Be=y.useMemo(()=>re.results?zj(re.results,H,te):$e,[re.results,H,te,$e]),qe=le.needsYou.length>0||le.working.length>0,ze=!ee&&qe&&H===null,Ie=y.useMemo(()=>H===null?[]:Ee.filter(ye=>!ye.archived&&b(ye.access).archive&&!zx(ye,_.get(ye.sessionId))),[H,Ee,_,b]),Me=H===null||l!=null&&Lx(l.cwd||xs(l.dirName))===H,Ue=y.useRef(!1);y.useEffect(()=>{if(Ue.current||!u||k.length===0)return;Ue.current=!0;const ye=Ia(k).slice(0,3),Re=globalThis,Ve=()=>{for(const je of ye)u(je.dirName,je.fileName)};let He=null,me=null;return typeof Re.requestIdleCallback=="function"?He=Re.requestIdleCallback(Ve,{timeout:1500}):me=setTimeout(Ve,300),()=>{He!=null&&typeof Re.cancelIdleCallback=="function"&&Re.cancelIdleCallback(He),me!=null&&clearTimeout(me)}},[k,u]);const De=y.useCallback(async(ye,Re)=>{Re.stopPropagation(),B(Ve=>new Set(Ve).add(ye));try{if(!(await Ce("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:ye})})).ok)throw new Error("Could not stop session");ae(E,1500)}catch{Kn.error("Could not stop session")}ae(()=>{B(Ve=>{const He=new Set(Ve);return He.delete(ye),He})},2e3)},[E,ae]);y.useEffect(()=>{const ye=k.find(Re=>`${Re.dirName}/${Re.fileName}`===e);ye&&N.has(ye.sessionId)&&$(ye.sessionId)},[e,k,N,$]);const Ke=y.useCallback(async ye=>{await(r==null?void 0:r(ye.dirName,ye.fileName))&&T(ye.sessionId)},[r,T]),Ne=FI(),Ae=y.useCallback(ye=>{Ne([ye.sessionId],!0,`Archived “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Qe=y.useCallback(ye=>{Ne([ye.sessionId],!1,`Restored “${pi(ye,d[ye.sessionId])}”`)},[Ne,d]),Je=y.useCallback(ye=>{if(ye.length===0)return;const Re=ye.map(Ve=>Ve.sessionId);Ne(Re,!0,`Archived ${Re.length} ${Re.length===1?"session":"sessions"}`)},[Ne]),ke=y.useCallback((ye,Re,Ve)=>{const{command:He,args:me}=dR(un(Ve),ye),je=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:je,name:`Resume ${ye.slice(0,8)}`,command:He,args:me,cwd:Re??void 0,metadata:{type:"terminal"}}),ae(E,3e3)},[h,E,ae]),We={activeSessionKey:e,procBySession:_,killingPids:D,newlyCompleted:N,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onDuplicateSession:s,onDeleteSession:r?Ke:void 0,onArchiveSession:Ae,onUnarchiveSession:Qe,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?ke:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(s0e,{loading:S,isMobile:ie,searchQuery:q,searchLoading:re.loading,showArchived:A,archivedCount:z,groupCrews:J,onToggleGroupCrews:()=>Y(!J),onSearchQueryChange:W,onToggleShowArchived:()=>R(!A),onRefresh:()=>{Fxe(),E()}}),v&&a.jsx(v,{}),a.jsx(P0e,{options:be,value:H,focused:ve,totalSessions:ge.length,crewCount:J?ue.crewOf.size:0,onChange:K,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:Ie.length,onArchiveIdle:()=>Je(Ie)}),a.jsx(Vc,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(o0e,{fetchError:re.error??C,showEmpty:Be.length===0&&!(l&&Me)&&!S&&!re.loading&&!C&&!re.error,searching:ee,loading:S||re.loading,sessionCount:re.active?Be.length:de.length,hiddenArchivedCount:ce,focusedProject:Se,onShowAllProjects:()=>K(null),filterEmpty:w.key!==null&&j?a.jsx(j,{className:"min-h-56 px-4 py-8"}):null,onShowArchived:()=>R(!0),onRetry:re.error?re.refresh:E}),ze&&a.jsx(n0e,{groups:le,activeSessionKey:e,procBySession:_,killingPids:D,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?De:void 0,onResumeSession:g?ke:void 0,onPrefetchSession:u}),a.jsx(j0e,{...We,sessions:Be,pendingSession:Me?l:null,showProject:H===null,groupCrews:te,lineageSessions:de,memberStatusOf:fe,older:{canLoad:(H===null||!!ve)&&!we.loaded&&!ee,loading:we.loading,load:we.load}})]})})]})}),W0e=y.memo(function(e){const t=V.c(16),{activeSessionKey:s,onSelectSession:r,onNewSession:o,creatingSession:i,isMobile:l,onDuplicateSession:c,onDeleteSession:u,pendingSession:d,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==i||t[4]!==f||t[5]!==u||t[6]!==c||t[7]!==o||t[8]!==m||t[9]!==r||t[10]!==d?(x=a.jsx(B0e,{activeSessionKey:s,onSelectSession:r,onDuplicateSession:c,onDeleteSession:u,onNewSession:o,creatingSession:i,pendingSession:d,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=i,t[4]=f,t[5]=u,t[6]=c,t[7]=o,t[8]=m,t[9]=r,t[10]=d,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=a.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),q0e=y.lazy(()=>nt(()=>import("./MissionHome-zp7VebSO.js"),__vite__mapDeps([37,1,2,3,4])).then(n=>({default:n.MissionHome})));function Rm(n){const e=V.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pn,{className:"size-4"}),e[0]=s):s=e[0];let r;return e[1]!==t?(r=a.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]=r):r=e[2],r}function g7(n){const e=V.c(12),{navigation:t,mobile:s,header:r}=n,o=s===void 0?!1:s,{sessionSource:i}=jt(),l=i?`${i.dirName}/${i.fileName}`:null;let c;return e[0]!==l||e[1]!==r||e[2]!==o||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=a.jsx(W0e,{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:o,header:r}),e[0]=l,e[1]=r,e[2]=o,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 V0e(n){const e=V.c(8),{navigation:t}=n,{state:s}=Sn();let r;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?(r=a.jsx(Dxe,{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]=r):r=e[7],r}function bf(n){const e=V.c(7),{navigation:t,showProjectHistory:s}=n,r=s===void 0?!1:s,{state:o,config:i}=Sn(),[l,c]=y.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Rm,{label:"Loading Mission Control…"}),e[0]=u):u=e[0];let d;return e[1]!==l||e[2]!==i||e[3]!==t||e[4]!==r||e[5]!==o?(d=a.jsx(y.Suspense,{fallback:u,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:l||r&&o.dashboardProject?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-4 pt-12",children:a.jsxs(Q,{variant:"ghost",size:"sm",onClick:()=>{t.onSelectProject(null),c(!1)},children:[a.jsx(yx,{"data-icon":"inline-start"})," Mission Control"]})}),a.jsx(V0e,{navigation:t})]}):a.jsx(q0e,{onOpenSession:t.actions.handleDashboardSelect,onBrowseProjects:()=>c(!0),start:{defaultAgentKind:i.defaultAgentKind,model:t.newSessionModel,onStart:t.onStartNewSessionWith}})})}),e[1]=l,e[2]=i,e[3]=t,e[4]=r,e[5]=o,e[6]=d):d=e[6],d}function x7(n){const e=V.c(8),{view:t,onClose:s}=n,{Component:r}=t,o=`Loading ${t.label}…`;let i;e[0]!==o?(i=a.jsx(Rm,{label:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==r||e[3]!==s?(l=a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(r,{onClose:s})}),e[2]=r,e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l?(c=a.jsx(y.Suspense,{fallback:i,children:l}),e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function H0e({mainView:n,hasSession:e,pendingDirName:t,extensionViewAvailable:s}){return n==="config"?"config":n==="mission"?"mission":n==="extension"&&s?"extension":e?"session":t?"pending":"dashboard"}function K0e({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function b7({path:n,text:e,startLine:t,endLine:s,comment:r}){if(!e)return`@${n}`;const o=e.includes("```")?"````":"```",i=t===s?`line ${t}`:`lines ${t}-${s}`;return`${r?`Review request: ${r}
|
|
471
471
|
`:""}${n} (${i})
|
|
472
472
|
${o}
|
|
473
473
|
${e}
|
|
474
|
-
${o}`}const G0e=y.lazy(()=>nt(()=>import("./ConfigBrowser-
|
|
474
|
+
${o}`}const G0e=y.lazy(()=>nt(()=>import("./ConfigBrowser-CRwh8BXq.js"),__vite__mapDeps([38,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser}))),Z0e=y.lazy(()=>nt(()=>import("./PreviewPanel-_pKuUaps.js"),__vite__mapDeps([39,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),Y0e=y.lazy(()=>nt(()=>import("./PluginsDialog-CBOyfoUX.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.PluginsDialog})));function X0e(n){const e=V.c(20),{sessionView:t,floatingChrome:s}=n,{session:r}=jt();if(!r)return null;let o;e[0]!==t.teamMembersBar?(o=t.teamMembersBar&&a.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=o):o=e[1];const i=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==i?(l=a.jsx(Tm,{searchInputRef:t.searchInputRef,hasTodos:i,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]=i,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&a.jsx(gA,{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 u;e[12]!==t.activeComposer||e[13]!==c?(u=a.jsxs(Im,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=u):u=e[14];let d;return e[15]!==s||e[16]!==o||e[17]!==l||e[18]!==u?(d=a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,o,l,u]})}),e[15]=s,e[16]=o,e[17]=l,e[18]=u,e[19]=d):d=e[19],d}function J0e(n){const e=V.c(41),{navigation:t,sessionView:s,project:r,view:o,extensionView:i,floatingChrome:l}=n,{state:c,config:u}=Sn(),{session:d,sessionSource:f}=jt();let m,p;if(e[0]!==(d==null?void 0:d.cwd)||e[1]!==f||e[2]!==c.configFilePath||e[3]!==c.dashboardProject||e[4]!==c.pendingCwd||e[5]!==c.pendingDirName||e[6]!==o){p=Symbol.for("react.early_return_sentinel");e:if(m=c.pendingCwd??(c.pendingDirName?xs(c.pendingDirName):null),o==="config"){let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Rm,{label:"Loading configuration…"}),e[9]=g):g=e[9];const x=a.jsx(G0e,{projectPath:K0e({sessionCwd:d==null?void 0:d.cwd,pendingPath:m,sessionDirPath:f!=null&&f.dirName?xs(f.dirName):null,dashboardProjectPath:c.dashboardProject?xs(c.dashboardProject):null}),initialFilePath:c.configFilePath});let b;e[10]!==x?(b=a.jsx(y.Suspense,{fallback:g,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:x})}),e[10]=x,e[11]=b):b=e[11],p=b;break e}e[0]=d==null?void 0:d.cwd,e[1]=f,e[2]=c.configFilePath,e[3]=c.dashboardProject,e[4]=c.pendingCwd,e[5]=c.pendingDirName,e[6]=o,e[7]=m,e[8]=p}else m=e[7],p=e[8];if(p!==Symbol.for("react.early_return_sentinel"))return p;if(o==="mission"){let g;return e[12]!==t?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(bf,{navigation:t})}),e[12]=t,e[13]=g):g=e[13],g}if(o==="extension"&&i){let g;return e[14]!==i||e[15]!==t.panels.closeMainView?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:a.jsx(x7,{view:i,onClose:t.panels.closeMainView})}),e[14]=i,e[15]=t.panels.closeMainView,e[16]=g):g=e[16],g}if(o==="session"){let g;return e[17]!==l||e[18]!==s?(g=a.jsx(X0e,{sessionView:s,floatingChrome:l}),e[17]=l,e[18]=s,e[19]=g):g=e[19],g}if(o==="pending"){const g=s.pendingTurns.length>0,x=qo()?"Only on the machine running this session":void 0;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=kb()?void 0:x,e[20]=b):b=e[20];const w=b,v=!g&&"justify-center gap-4";let j;e[21]!==v?(j=G("flex min-h-0 min-w-0 flex-1 flex-col",v),e[21]=v,e[22]=j):j=e[22];let k;e[23]!==u||e[24]!==g||e[25]!==t||e[26]!==m||e[27]!==s.pendingTurns?(k=g?a.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:a.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):a.jsx(t7,{projectPath:m,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:u.defaultAgentKind}}),e[23]=u,e[24]=g,e[25]=t,e[26]=m,e[27]=s.pendingTurns,e[28]=k):k=e[28];let _;e[29]!==s.pendingComposer?(_=a.jsx(Im,{children:s.pendingComposer}),e[29]=s.pendingComposer,e[30]=_):_=e[30];let N;e[31]!==g||e[32]!==r?(N=!g&&a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[xt("terminal")&&a.jsx(vd,{reason:x,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!x,onClick:r.onOpenTerminal,children:[a.jsx(_a,{"data-icon":"inline-start"}),"Terminal"]})}),xt("hostFiles")&&a.jsxs(a.Fragment,{children:[a.jsx(vd,{reason:w,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!w,onClick:()=>d6(r.pendingProject),children:[a.jsx(xx,{"data-icon":"inline-start"}),"Open in editor"]})}),a.jsx(vd,{reason:x,children:a.jsxs(Q,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>f6(r.pendingProject),children:[a.jsx(wc,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[31]=g,e[32]=r,e[33]=N):N=e[33];let S;return e[34]!==j||e[35]!==k||e[36]!==_||e[37]!==N?(S=a.jsxs("div",{className:j,children:[k,_,N]}),e[34]=j,e[35]=k,e[36]=_,e[37]=N,e[38]=S):S=e[38],S}let h;return e[39]!==t?(h=a.jsx(bf,{navigation:t,showProjectHistory:!0}),e[39]=t,e[40]=h):h=e[40],h}function Q0e(n){const e=V.c(129),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=Sn(),{session:c,sessionSource:u}=jt(),d=OI((c==null?void 0:c.sessionId)??null),[f,m]=y.useState(ebe),[p,h]=y.useState();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=Ue=>{h(Ue),m(!0)},e[0]=g):g=e[0];const x=g;let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=xt("configWrite"),e[1]=b):b=e[1];const w=HI(b),v=r.currentCwd??null;let j;e[2]!==w||e[3]!==v?(j={...w,projectPath:v,openSettings:x},e[2]=w,e[3]=v,e[4]=j):j=e[4];const k=GI(j),_=FN(i.mainView==="extension"?i.extensionViewId:null);let N;e[5]!==s.chatInputRef?(N=function(De){var Ne,Ae,Qe;const Ke=((Ne=s.chatInputRef.current)==null?void 0:Ne.getText().trimEnd())??"";(Ae=s.chatInputRef.current)==null||Ae.setText(Ke?`${Ke}
|
|
475
475
|
|
|
476
476
|
${De}
|
|
477
477
|
`:`${De}
|
|
478
|
-
`),(Qe=s.chatInputRef.current)==null||Qe.focus()},e[5]=s.chatInputRef,e[6]=N):N=e[6];const S=N;let C;e[7]!==S?(C=function(De){const{path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}=De;S(b7({path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}))},e[7]=S,e[8]=C):C=e[8];const E=C,T=i.mainView,$=!!c,A=_!==null;let R;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==$||e[12]!==A?(R=H0e({mainView:T,hasSession:$,pendingDirName:i.pendingDirName,extensionViewAvailable:A}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=$,e[12]=A,e[13]=R):R=e[13];const P=R,z=t.panels.handleToggleSidebar,L=t.actions.handleGoHome,I=o.onOpenCommandPalette;let M,F;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=ea("toggleSidebar"),F=ea("commandPalette"),e[14]=M,e[15]=F):(M=e[14],F=e[15]);let U;e[16]!==o.onOpenCommandPalette||e[17]!==t.actions.handleGoHome||e[18]!==t.panels.handleToggleSidebar?(U=a.jsx(tge,{onToggleSidebar:z,onGoHome:L,onOpenCommandPalette:I,sidebarShortcut:M,commandPaletteShortcut:F}),e[16]=o.onOpenCommandPalette,e[17]=t.actions.handleGoHome,e[18]=t.panels.handleToggleSidebar,e[19]=U):U=e[19];const O=U,D=P==="mission"||P==="dashboard"&&!i.dashboardProject;let B;e[20]===Symbol.for("react.memo_cache_sentinel")?(B=new Set,e[20]=B):B=e[20];const q=y.useRef(B),W=t.panels.openWorkspacePanel;let H,K;e[21]!==D||e[22]!==d||e[23]!==W?(H=()=>{D||!d||q.current.has(d.rootId)||(q.current.add(d.rootId),W(Lt.crew))},K=[D,d,W],e[21]=D,e[22]=d,e[23]=W,e[24]=H,e[25]=K):(H=e[24],K=e[25]),y.useEffect(H,K);const Z=t.panels.showSidebar&&i.mainView!=="config"&&!D;let Y,J,ee;e[26]!==S||e[27]!==D||e[28]!==t.handlers.handleLoadSessionScrollAware||e[29]!==t.panels.activeWorkspacePanel||e[30]!==d||e[31]!==r.currentCwd||e[32]!==r.hasFileChanges||e[33]!==r.supportsWorktrees||e[34]!==c||e[35]!==u||e[36]!==i.mainView||e[37]!==i.sessionChangeKey||e[38]!==k?(Y={session:c,sessionAddress:u?{dirName:u.dirName,fileName:u.fileName}:null,sessionChangeKey:i.sessionChangeKey,projectPath:r.currentCwd??null,hasFileChanges:r.hasFileChanges,canAccessHostFiles:xt("hostFiles"),canUseBrowser:xt("browser"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:S,crew:d},ee=tv(k,Y),J=i.mainView==="sessions"&&!D?$I(t.panels.activeWorkspacePanel,ee):null,e[26]=S,e[27]=D,e[28]=t.handlers.handleLoadSessionScrollAware,e[29]=t.panels.activeWorkspacePanel,e[30]=d,e[31]=r.currentCwd,e[32]=r.hasFileChanges,e[33]=r.supportsWorktrees,e[34]=c,e[35]=u,e[36]=i.mainView,e[37]=i.sessionChangeKey,e[38]=k,e[39]=Y,e[40]=J,e[41]=ee):(Y=e[39],J=e[40],ee=e[41]);const te=J,se=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let X;e[42]!==t.panels||e[43]!==r?(X=function(De){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(De)},e[42]=t.panels,e[43]=r,e[44]=X):X=e[44];const ne=X;let ae;e[45]!==t.actions||e[46]!==t.panels?(ae=function(De){t.actions.handleDashboardSelect(De.dirName,`${De.sessionId}.jsonl`),t.panels.closeWorkspacePanel()},e[45]=t.actions,e[46]=t.panels,e[47]=ae):ae=e[47];const ie=ae,re=t.panels.showSidebar;let de;e[48]===Symbol.for("react.memo_cache_sentinel")?(de=ea("toggleSidebar"),e[48]=de):de=e[48];let ce;e[49]!==o.killing||e[50]!==o.onKillAll||e[51]!==o.onLogout||e[52]!==l.openConfigDialog||e[53]!==t.creatingSession||e[54]!==t.handlers.handleDuplicateSession||e[55]!==t.onStartNewSession||e[56]!==t.panels.handleToggleSidebar||e[57]!==t.panels.openMainView||e[58]!==t.panels.showSidebar||e[59]!==r.onOpenTerminal||e[60]!==s.onBackToMain||e[61]!==s.onShowWorkflows||e[62]!==s.workflowCount||e[63]!==Z?(ce=a.jsx(Qhe,{showSidebar:re,sidebarRendered:Z,sidebarShortcut:de,killing:o.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:r.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:o.onKillAll,onOpenSettings:l.openConfigDialog,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView}),e[49]=o.killing,e[50]=o.onKillAll,e[51]=o.onLogout,e[52]=l.openConfigDialog,e[53]=t.creatingSession,e[54]=t.handlers.handleDuplicateSession,e[55]=t.onStartNewSession,e[56]=t.panels.handleToggleSidebar,e[57]=t.panels.openMainView,e[58]=t.panels.showSidebar,e[59]=r.onOpenTerminal,e[60]=s.onBackToMain,e[61]=s.onShowWorkflows,e[62]=s.workflowCount,e[63]=Z,e[64]=ce):ce=e[64];const oe=ce,fe=r.currentCwd??null;let ue;e[65]!==t||e[66]!==O||e[67]!==Z?(ue=Z&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(g7,{navigation:t,header:O})}),e[65]=t,e[66]=O,e[67]=Z,e[68]=ue):ue=e[68];const le=te??null,pe=r.projectFilesRoot??r.currentCwd??null;let ge;e[69]!==E||e[70]!==t.actions.handleJumpToTurn||e[71]!==t.handlers.handleLoadSessionScrollAware||e[72]!==ie||e[73]!==r.backgroundAgents||e[74]!==r.processPanel.handleServersChanged||e[75]!==r.processPanel.handleToggleServer||e[76]!==r.projectFilesRequest||e[77]!==r.worktrees||e[78]!==s.searchInputRef||e[79]!==pe||e[80]!==se?(ge={projectFilesRoot:pe,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:E,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:se,openWorktreeSession:ie},e[69]=E,e[70]=t.actions.handleJumpToTurn,e[71]=t.handlers.handleLoadSessionScrollAware,e[72]=ie,e[73]=r.backgroundAgents,e[74]=r.processPanel.handleServersChanged,e[75]=r.processPanel.handleToggleServer,e[76]=r.projectFilesRequest,e[77]=r.worktrees,e[78]=s.searchInputRef,e[79]=pe,e[80]=se,e[81]=ge):ge=e[81];let be;e[82]!==D||e[83]!==t.panels.handleToggleMission?(be={id:"mission-control",title:"Mission Control",icon:H4,active:D,onSelect:t.panels.handleToggleMission},e[82]=D,e[83]=t.panels.handleToggleMission,e[84]=be):be=e[84];let ve;e[85]!==t.panels.handleToggleConfig||e[86]!==f||e[87]!==i.mainView?(ve=xt("configWrite")?[{id:"plugins",title:"Plugins",icon:vx,active:f,onSelect:()=>m(!0)},{id:"config",title:"Config",icon:K4,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[85]=t.panels.handleToggleConfig,e[86]=f,e[87]=i.mainView,e[88]=ve):ve=e[88];let Se;e[89]!==be||e[90]!==ve?(Se=[be,...ve],e[89]=be,e[90]=ve,e[91]=Se):Se=e[91];const we=P!=="session"&&oe;let Ee;e[92]!==_||e[93]!==oe||e[94]!==t||e[95]!==r||e[96]!==s||e[97]!==P?(Ee=a.jsx(J0e,{navigation:t,sessionView:s,project:r,view:P,extensionView:_,floatingChrome:oe}),e[92]=_,e[93]=oe,e[94]=t,e[95]=r,e[96]=s,e[97]=P,e[98]=Ee):Ee=e[98];let $e;e[99]!==we||e[100]!==Ee?($e=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[we,Ee]}),e[99]=we,e[100]=Ee,e[101]=$e):$e=e[101];let Be;e[102]!==t.panels.closeWorkspacePanel||e[103]!==Y||e[104]!==le||e[105]!==ge||e[106]!==Se||e[107]!==$e||e[108]!==ne||e[109]!==ee?(Be=a.jsx(age,{panels:ee,context:Y,activePanel:le,services:ge,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:ne,actions:Se,children:$e}),e[102]=t.panels.closeWorkspacePanel,e[103]=Y,e[104]=le,e[105]=ge,e[106]=Se,e[107]=$e,e[108]=ne,e[109]=ee,e[110]=Be):Be=e[110];let qe;e[111]!==r.currentCwd||e[112]!==r.onCloseRightWorkspace||e[113]!==r.showPreview?(qe=r.showPreview&&r.currentCwd&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Z0e,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[111]=r.currentCwd,e[112]=r.onCloseRightWorkspace,e[113]=r.showPreview,e[114]=qe):qe=e[114];let ze;e[115]!==p||e[116]!==f||e[117]!==r.currentCwd||e[118]!==w?(ze=f&&xt("configWrite")&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Y0e,{client:w.client,state:w,currentPath:r.currentCwd??null,initialPluginId:p,onClose:()=>{m(!1),h(void 0)}})}),e[115]=p,e[116]=f,e[117]=r.currentCwd,e[118]=w,e[119]=ze):ze=e[119];let Ie;e[120]!==ue||e[121]!==Be||e[122]!==qe||e[123]!==ze?(Ie=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[ue,Be,qe,ze]}),e[120]=ue,e[121]=Be,e[122]=qe,e[123]=ze,e[124]=Ie):Ie=e[124];let Me;return e[125]!==w||e[126]!==fe||e[127]!==Ie?(Me=a.jsx(HE,{runtime:w,workspacePath:fe,children:Ie}),e[125]=w,e[126]=fe,e[127]=Ie,e[128]=Me):Me=e[128],Me}function ebe(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function tbe(n){const e=V.c(15),{navigation:t,sessionView:s,project:r,chrome:o}=n;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(vA,{}),l=a.jsx(bA,{}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let c;e[2]!==o||e[3]!==t||e[4]!==r||e[5]!==s?(c=a.jsx(Q0e,{navigation:t,sessionView:s,project:r,chrome:o}),e[2]=o,e[3]=t,e[4]=r,e[5]=s,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==t||e[9]!==r?(u=a.jsx(hpe,{navigation:t,project:r,chrome:o}),e[7]=o,e[8]=t,e[9]=r,e[10]=u):u=e[10];let d;return e[11]!==o.backgroundServers||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[o.backgroundServers,i,l,c,u]}),e[11]=o.backgroundServers,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}const nbe=[{id:"sessions",label:"Sessions",icon:Yr},{id:"chat",label:"Chat",icon:vc},{id:"workspace",label:"Workspace",icon:B8}],sbe=y.memo(function(e){const t=V.c(6),{activeTab:s,onTabChange:r}=e,{isLive:o}=jt();let i;t[0]!==s||t[1]!==o||t[2]!==r?(i=nbe.map(c=>{const u=c.icon,d=s===c.id;return a.jsx("button",{type:"button","aria-current":d?"page":void 0,"aria-label":c.label,title:c.label,onClick:()=>{H1(),r(c.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:a.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",d?"scale-100 bg-accent":"scale-95"),children:[a.jsx(u,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&!d&&a.jsx(Sm,{"aria-label":"Session is live",className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},c.id)}),t[0]=s,t[1]=o,t[2]=r,t[3]=i):i=t[3];let l;return t[4]!==i?(l=a.jsx("nav",{className:"flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]","aria-label":"Navigation",children:i}),t[4]=i,t[5]=l):l=t[5],l});function rbe(n){const e=V.c(77),{session:t,sessionSource:s,isSubAgentView:r,isLive:o,canArchive:i,onProviderHandoff:l,claudeRawMessages:c,headerAccessory:u,creatingSession:d,onNewSession:f,onDuplicateSession:m,onBackToMain:p,onShowFileChanges:h,hasFileChanges:g,onShowWorkflows:x,workflowCount:b,onSearch:w,expandAll:v,onToggleExpandAll:j}=n,k=UI(t.sessionId,o,i);let _;e[0]!==f||e[1]!==t.cwd||e[2]!==s?(_=()=>{s&&f(s.dirName,t.cwd)},e[0]=f,e[1]=t.cwd,e[2]=s,e[3]=_):_=e[3];const N=_;let S;e[4]!==r||e[5]!==p?(S=r&&p&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:p,"aria-label":"Back to main agent",children:a.jsx(ux,{"data-icon":"inline-start"})}),e[4]=r,e[5]=p,e[6]=S):S=e[6];let C,E;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Xb,{compact:!0}),E=a.jsx(tn,{orientation:"vertical",className:"h-4"}),e[7]=C,e[8]=E):(C=e[7],E=e[8]);let T;e[9]!==c?(T=a.jsx(dA,{rawMessages:c,warnOnly:!0}),e[9]=c,e[10]=T):T=e[10];let $;e[11]!==t.cwd?($=t.cwd?Er(t.cwd):"Session",e[11]=t.cwd,e[12]=$):$=e[12];let A;e[13]!==$?(A=a.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:$}),e[13]=$,e[14]=A):A=e[14];let R;e[15]!==o?(R=o&&a.jsx(Sm,{"aria-label":"Session is live"}),e[15]=o,e[16]=R):R=e[16];let P;e[17]!==A||e[18]!==R?(P=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1.5",children:[A,R]}),e[17]=A,e[18]=R,e[19]=P):P=e[19];let z;e[20]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Rc,{render:a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(q4,{"data-icon":"inline-start"})}),e[20]=z):z=e[20];let L;e[21]!==t.cwd?(L=t.cwd?Er(t.cwd):"Current session",e[21]=t.cwd,e[22]=L):L=e[22];let I;e[23]!==L?(I=a.jsx("span",{className:"truncate text-foreground",children:L}),e[23]=L,e[24]=I):I=e[24];let M;e[25]!==t.gitBranch||e[26]!==t.model?(M=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[25]=t.gitBranch,e[26]=t.model,e[27]=M):M=e[27];let F;e[28]!==M?(F=a.jsx("span",{className:"truncate font-normal",children:M}),e[28]=M,e[29]=F):F=e[29];let U;e[30]!==I||e[31]!==F?(U=a.jsxs(P5,{className:"flex flex-col gap-0.5",children:[I,F]}),e[30]=I,e[31]=F,e[32]=U):U=e[32];let O;e[33]!==d||e[34]!==N||e[35]!==s?(O=s&&a.jsxs(hn,{onClick:N,disabled:d,children:[d?a.jsx(Pn,{}):a.jsx(kr,{}),a.jsx("span",{children:"New session"})]}),e[33]=d,e[34]=N,e[35]=s,e[36]=O):O=e[36];let D;e[37]!==m?(D=m&&a.jsxs(hn,{onClick:m,children:[a.jsx(Es,{}),a.jsx("span",{children:"Duplicate session"})]}),e[37]=m,e[38]=D):D=e[38];let B;e[39]!==r||e[40]!==l?(B=l&&!r&&a.jsxs(hn,{onClick:l,children:[a.jsx(W4,{}),a.jsx("span",{children:"Continue with another provider…"})]}),e[39]=r,e[40]=l,e[41]=B):B=e[41];let q;e[42]!==k||e[43]!==r?(q=k&&!r&&a.jsxs(hn,{onClick:k.toggle,disabled:!!k.disabledReason,children:[a.jsx(k.icon,{}),a.jsxs("span",{className:"flex flex-col",children:[k.label,k.disabledReason&&a.jsx("span",{className:"text-xs text-muted-foreground",children:k.disabledReason})]})]}),e[42]=k,e[43]=r,e[44]=q):q=e[44];let W;e[45]!==U||e[46]!==O||e[47]!==D||e[48]!==B||e[49]!==q?(W=a.jsxs(qr,{children:[U,O,D,B,q]}),e[45]=U,e[46]=O,e[47]=D,e[48]=B,e[49]=q,e[50]=W):W=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx(Il,{}),e[51]=H):H=e[51];let K;e[52]!==w?(K=w&&a.jsxs(hn,{onClick:w,children:[a.jsx(ss,{}),a.jsx("span",{children:"Search conversation"})]}),e[52]=w,e[53]=K):K=e[53];let Z;e[54]!==v||e[55]!==j?(Z=j&&a.jsxs(hn,{onClick:j,children:[v?a.jsx(Nf,{}):a.jsx(Ea,{}),a.jsx("span",{children:v?"Collapse tool calls":"Expand tool calls"})]}),e[54]=v,e[55]=j,e[56]=Z):Z=e[56];let Y;e[57]!==g||e[58]!==h?(Y=g&&h&&a.jsxs(hn,{onClick:h,children:[a.jsx(yc,{}),a.jsx("span",{children:"File changes"})]}),e[57]=g,e[58]=h,e[59]=Y):Y=e[59];let J;e[60]!==x||e[61]!==b?(J=x&&(b??0)>0&&a.jsxs(hn,{onClick:x,children:[a.jsx(B4,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Fe,{variant:"secondary",children:b})]}),e[60]=x,e[61]=b,e[62]=J):J=e[62];let ee;e[63]!==K||e[64]!==Z||e[65]!==Y||e[66]!==J?(ee=a.jsxs(qr,{children:[K,Z,Y,J]}),e[63]=K,e[64]=Z,e[65]=Y,e[66]=J,e[67]=ee):ee=e[67];let te;e[68]!==W||e[69]!==ee?(te=a.jsxs($c,{children:[z,a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-72",children:[W,H,ee]})]}),e[68]=W,e[69]=ee,e[70]=te):te=e[70];let se;return e[71]!==u||e[72]!==S||e[73]!==te||e[74]!==T||e[75]!==P?(se=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[S,C,E,T,P,u,te]}),e[71]=u,e[72]=S,e[73]=te,e[74]=T,e[75]=P,e[76]=se):se=e[76],se}const obe=y.memo(function(e){const t=V.c(14),{isMobile:s}=Sn(),{session:r,sessionSource:o,isLive:i,permissions:l,actions:c}=jt();if(!s||!r)return null;let u;t[0]!==o?(u=o?$o(o.fileName):null,t[0]=o,t[1]=u):u=t[1];const d=u;let f;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(f=ia(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=f):f=t[4];const m=f,p=d!==null,h=l.send&&d===null?c.handleProviderHandoff:void 0;let g;return t[5]!==m||t[6]!==i||t[7]!==l.archive||t[8]!==e||t[9]!==r||t[10]!==o||t[11]!==p||t[12]!==h?(g=a.jsx(rbe,{...e,session:r,sessionSource:o,isSubAgentView:p,isLive:i,canArchive:l.archive,onProviderHandoff:h,claudeRawMessages:m}),t[5]=m,t[6]=i,t[7]=l.archive,t[8]=e,t[9]=r,t[10]=o,t[11]=p,t[12]=h,t[13]=g):g=t[13],g}),ibe=50;function abe({onSwipeLeft:n,onSwipeRight:e}){const t=y.useRef(null),s=y.useRef(null),r=y.useRef(n),o=y.useRef(e);return r.current=n,o.current=e,y.useEffect(()=>{const i=t.current;if(!i)return;function l(u){const d=u.touches[0];s.current={x:d.clientX,y:d.clientY}}function c(u){var p,h;if(!s.current)return;const d=u.changedTouches[0],f=d.clientX-s.current.x,m=d.clientY-s.current.y;s.current=null,!(Math.abs(f)<ibe||Math.abs(f)<Math.abs(m))&&(f>0?(p=o.current)==null||p.call(o):(h=r.current)==null||h.call(r))}return i.addEventListener("touchstart",l,{passive:!0}),i.addEventListener("touchend",c,{passive:!0}),()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",c)}},[]),t}const Fj=["sessions","chat","workspace"];function Uj(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function lbe(n){var P;const e=V.c(46),{panels:t,context:s,activePanelId:r,active:o,onSelectPanel:i,onClosePanel:l,actions:c,actionContent:u}=n;let d;e[0]!==c?(d=c===void 0?[]:c,e[0]=c,e[1]=d):d=e[1];const f=d;let m,p,h,g,x,b,w,v;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=tv(t,s);let z;e[16]!==r?(z=U=>U.id===r,e[16]=r,e[17]=z):z=e[17],h=p.find(z);let L;e[18]!==f?(L=f.find(ube),e[18]=f,e[19]=L):L=e[19],m=L,v=(m==null?void 0:m.title)??(h==null?void 0:h.title);let I;e[20]!==s.projectPath?(I=(P=s.projectPath)==null?void 0:P.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=I):I=e[21];const M=I;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const F=v?a.jsxs(a.Fragment,{children:[a.jsx(Q,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(yx,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:v}),a.jsx(Q,{variant:"outline",onClick:l,children:"Switch"})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[a.jsx("h1",{className:"text-base font-medium",children:"Workspace"}),M&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s.projectPath??void 0,children:M})]});e[22]!==F?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:F}),e[22]=F,e[23]=b):b=e[23],w=!v&&a.jsx("div",{className:"mobile-scroll min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("nav",{"aria-label":"Workspace tools",className:"grid grid-cols-2 gap-2",children:[p.map(U=>{var q;const O=U.icon,D=U.indicator,B=(q=U.badge)==null?void 0:q.call(U,s);return a.jsxs(Q,{variant:"outline","aria-label":U.title,className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:()=>i(U.id),children:[a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsxs("span",{className:"relative",children:[a.jsx(O,{"data-icon":"inline-start"}),D&&a.jsx(D,{context:s,active:!1})]}),B!=null&&a.jsx(Fe,{variant:"secondary",children:B})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:U.title}),a.jsx(it,{"data-icon":"inline-end"})]})]},U.id)}),f.map(cbe)]})}),e[2]=f,e[3]=r,e[4]=s,e[5]=l,e[6]=i,e[7]=t,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b,e[14]=w,e[15]=v}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],w=e[14],v=e[15];const j=v?"relative min-h-0 flex-1":"hidden",k=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",_=m&&u;let N;e[24]!==k||e[25]!==_?(N=a.jsx(vI,{fallbackMessage:"Couldn't open this workspace tool",children:_},k),e[24]=k,e[25]=_,e[26]=N):N=e[26];const S=m?"hidden":"h-full min-h-0",C=(h==null?void 0:h.id)??"",E=o&&!m;let T;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==C||e[31]!==E?(T=a.jsx(VI,{panels:p,context:s,activePanelId:C,active:E,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=C,e[31]=E,e[32]=T):T=e[32];let $;e[33]!==S||e[34]!==T?($=a.jsx("div",{className:S,children:T}),e[33]=S,e[34]=T,e[35]=$):$=e[35];let A;e[36]!==N||e[37]!==$||e[38]!==j?(A=a.jsxs("div",{className:j,children:[N,$]}),e[36]=N,e[37]=$,e[38]=j,e[39]=A):A=e[39];let R;return e[40]!==A||e[41]!==g||e[42]!==x||e[43]!==b||e[44]!==w?(R=a.jsxs("section",{"aria-label":g,className:x,children:[b,w,A]}),e[40]=A,e[41]=g,e[42]=x,e[43]=b,e[44]=w,e[45]=R):R=e[45],R}function cbe(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(Q,{variant:"outline",className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:r,children:[a.jsx(s,{"data-icon":"inline-start"}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:t}),a.jsx(it,{"data-icon":"inline-end"})]})]},e)}function ube(n){return n.active}const dbe=y.lazy(()=>nt(()=>import("./PluginsDialog-DusZU8fA.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),fbe=y.lazy(()=>nt(()=>import("./ConfigBrowser-B6jQRpcW.js"),__vite__mapDeps([38,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser})));function mbe(n){var ce;const e=V.c(94),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=Sn(),{session:l,sessionSource:c}=jt(),u=OI((l==null?void 0:l.sessionId)??null),d=Nn("hostFiles"),f=Nn("browser"),m=Nn("configWrite"),[p,h]=y.useState(pbe),[g,x]=y.useState();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=oe=>{x(oe),h(!0)},e[0]=b):b=e[0];const w=b,v=HI(m),j=r.currentCwd??null;let k;e[1]!==v||e[2]!==j?(k={...v,projectPath:j,openSettings:w},e[1]=v,e[2]=j,e[3]=k):k=e[3];const _=GI(k),[N,S]=y.useState(null),{panels:C}=t,E=C.activeWorkspacePanel===null?N:null,T=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let $;e[4]!==C?($=function(){S(null),C.closeWorkspacePanel()},e[4]=C,e[5]=$):$=e[5];const A=$;let R;e[6]!==C?(R=function(fe){C.closeWorkspacePanel(),S(fe)},e[6]=C,e[7]=R):R=e[7];const P=R;let z;e[8]!==t.actions||e[9]!==s.chatInputRef?(z=function(fe){const ue=s.chatInputRef.current,le=(ue==null?void 0:ue.getText().trimEnd())??"";ue==null||ue.setText(le?`${le}
|
|
478
|
+
`),(Qe=s.chatInputRef.current)==null||Qe.focus()},e[5]=s.chatInputRef,e[6]=N):N=e[6];const S=N;let C;e[7]!==S?(C=function(De){const{path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}=De;S(b7({path:Ke,text:Ne,startLine:Ae,endLine:Qe,comment:Je}))},e[7]=S,e[8]=C):C=e[8];const E=C,T=i.mainView,$=!!c,A=_!==null;let R;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==$||e[12]!==A?(R=H0e({mainView:T,hasSession:$,pendingDirName:i.pendingDirName,extensionViewAvailable:A}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=$,e[12]=A,e[13]=R):R=e[13];const P=R,z=t.panels.handleToggleSidebar,L=t.actions.handleGoHome,I=o.onOpenCommandPalette;let M,F;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=ea("toggleSidebar"),F=ea("commandPalette"),e[14]=M,e[15]=F):(M=e[14],F=e[15]);let U;e[16]!==o.onOpenCommandPalette||e[17]!==t.actions.handleGoHome||e[18]!==t.panels.handleToggleSidebar?(U=a.jsx(tge,{onToggleSidebar:z,onGoHome:L,onOpenCommandPalette:I,sidebarShortcut:M,commandPaletteShortcut:F}),e[16]=o.onOpenCommandPalette,e[17]=t.actions.handleGoHome,e[18]=t.panels.handleToggleSidebar,e[19]=U):U=e[19];const O=U,D=P==="mission"||P==="dashboard"&&!i.dashboardProject;let B;e[20]===Symbol.for("react.memo_cache_sentinel")?(B=new Set,e[20]=B):B=e[20];const q=y.useRef(B),W=t.panels.openWorkspacePanel;let H,K;e[21]!==D||e[22]!==d||e[23]!==W?(H=()=>{D||!d||q.current.has(d.rootId)||(q.current.add(d.rootId),W(Lt.crew))},K=[D,d,W],e[21]=D,e[22]=d,e[23]=W,e[24]=H,e[25]=K):(H=e[24],K=e[25]),y.useEffect(H,K);const Z=t.panels.showSidebar&&i.mainView!=="config"&&!D;let Y,J,ee;e[26]!==S||e[27]!==D||e[28]!==t.handlers.handleLoadSessionScrollAware||e[29]!==t.panels.activeWorkspacePanel||e[30]!==d||e[31]!==r.currentCwd||e[32]!==r.hasFileChanges||e[33]!==r.supportsWorktrees||e[34]!==c||e[35]!==u||e[36]!==i.mainView||e[37]!==i.sessionChangeKey||e[38]!==k?(Y={session:c,sessionAddress:u?{dirName:u.dirName,fileName:u.fileName}:null,sessionChangeKey:i.sessionChangeKey,projectPath:r.currentCwd??null,hasFileChanges:r.hasFileChanges,canAccessHostFiles:xt("hostFiles"),canUseBrowser:xt("browser"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:S,crew:d},ee=tv(k,Y),J=i.mainView==="sessions"&&!D?$I(t.panels.activeWorkspacePanel,ee):null,e[26]=S,e[27]=D,e[28]=t.handlers.handleLoadSessionScrollAware,e[29]=t.panels.activeWorkspacePanel,e[30]=d,e[31]=r.currentCwd,e[32]=r.hasFileChanges,e[33]=r.supportsWorktrees,e[34]=c,e[35]=u,e[36]=i.mainView,e[37]=i.sessionChangeKey,e[38]=k,e[39]=Y,e[40]=J,e[41]=ee):(Y=e[39],J=e[40],ee=e[41]);const te=J,se=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let X;e[42]!==t.panels||e[43]!==r?(X=function(De){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(De)},e[42]=t.panels,e[43]=r,e[44]=X):X=e[44];const ne=X;let ae;e[45]!==t.actions||e[46]!==t.panels?(ae=function(De){t.actions.handleDashboardSelect(De.dirName,`${De.sessionId}.jsonl`),t.panels.closeWorkspacePanel()},e[45]=t.actions,e[46]=t.panels,e[47]=ae):ae=e[47];const ie=ae,re=t.panels.showSidebar;let de;e[48]===Symbol.for("react.memo_cache_sentinel")?(de=ea("toggleSidebar"),e[48]=de):de=e[48];let ce;e[49]!==o.killing||e[50]!==o.onKillAll||e[51]!==o.onLogout||e[52]!==l.openConfigDialog||e[53]!==t.creatingSession||e[54]!==t.handlers.handleDuplicateSession||e[55]!==t.onStartNewSession||e[56]!==t.panels.handleToggleSidebar||e[57]!==t.panels.openMainView||e[58]!==t.panels.showSidebar||e[59]!==r.onOpenTerminal||e[60]!==s.onBackToMain||e[61]!==s.onShowWorkflows||e[62]!==s.workflowCount||e[63]!==Z?(ce=a.jsx(Qhe,{showSidebar:re,sidebarRendered:Z,sidebarShortcut:de,killing:o.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:r.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:o.onKillAll,onOpenSettings:l.openConfigDialog,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView}),e[49]=o.killing,e[50]=o.onKillAll,e[51]=o.onLogout,e[52]=l.openConfigDialog,e[53]=t.creatingSession,e[54]=t.handlers.handleDuplicateSession,e[55]=t.onStartNewSession,e[56]=t.panels.handleToggleSidebar,e[57]=t.panels.openMainView,e[58]=t.panels.showSidebar,e[59]=r.onOpenTerminal,e[60]=s.onBackToMain,e[61]=s.onShowWorkflows,e[62]=s.workflowCount,e[63]=Z,e[64]=ce):ce=e[64];const oe=ce,fe=r.currentCwd??null;let ue;e[65]!==t||e[66]!==O||e[67]!==Z?(ue=Z&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(g7,{navigation:t,header:O})}),e[65]=t,e[66]=O,e[67]=Z,e[68]=ue):ue=e[68];const le=te??null,pe=r.projectFilesRoot??r.currentCwd??null;let ge;e[69]!==E||e[70]!==t.actions.handleJumpToTurn||e[71]!==t.handlers.handleLoadSessionScrollAware||e[72]!==ie||e[73]!==r.backgroundAgents||e[74]!==r.processPanel.handleServersChanged||e[75]!==r.processPanel.handleToggleServer||e[76]!==r.projectFilesRequest||e[77]!==r.worktrees||e[78]!==s.searchInputRef||e[79]!==pe||e[80]!==se?(ge={projectFilesRoot:pe,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:E,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:se,openWorktreeSession:ie},e[69]=E,e[70]=t.actions.handleJumpToTurn,e[71]=t.handlers.handleLoadSessionScrollAware,e[72]=ie,e[73]=r.backgroundAgents,e[74]=r.processPanel.handleServersChanged,e[75]=r.processPanel.handleToggleServer,e[76]=r.projectFilesRequest,e[77]=r.worktrees,e[78]=s.searchInputRef,e[79]=pe,e[80]=se,e[81]=ge):ge=e[81];let be;e[82]!==D||e[83]!==t.panels.handleToggleMission?(be={id:"mission-control",title:"Mission Control",icon:H4,active:D,onSelect:t.panels.handleToggleMission},e[82]=D,e[83]=t.panels.handleToggleMission,e[84]=be):be=e[84];let ve;e[85]!==t.panels.handleToggleConfig||e[86]!==f||e[87]!==i.mainView?(ve=xt("configWrite")?[{id:"plugins",title:"Plugins",icon:vx,active:f,onSelect:()=>m(!0)},{id:"config",title:"Config",icon:K4,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[85]=t.panels.handleToggleConfig,e[86]=f,e[87]=i.mainView,e[88]=ve):ve=e[88];let Se;e[89]!==be||e[90]!==ve?(Se=[be,...ve],e[89]=be,e[90]=ve,e[91]=Se):Se=e[91];const we=P!=="session"&&oe;let Ee;e[92]!==_||e[93]!==oe||e[94]!==t||e[95]!==r||e[96]!==s||e[97]!==P?(Ee=a.jsx(J0e,{navigation:t,sessionView:s,project:r,view:P,extensionView:_,floatingChrome:oe}),e[92]=_,e[93]=oe,e[94]=t,e[95]=r,e[96]=s,e[97]=P,e[98]=Ee):Ee=e[98];let $e;e[99]!==we||e[100]!==Ee?($e=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[we,Ee]}),e[99]=we,e[100]=Ee,e[101]=$e):$e=e[101];let Be;e[102]!==t.panels.closeWorkspacePanel||e[103]!==Y||e[104]!==le||e[105]!==ge||e[106]!==Se||e[107]!==$e||e[108]!==ne||e[109]!==ee?(Be=a.jsx(age,{panels:ee,context:Y,activePanel:le,services:ge,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:ne,actions:Se,children:$e}),e[102]=t.panels.closeWorkspacePanel,e[103]=Y,e[104]=le,e[105]=ge,e[106]=Se,e[107]=$e,e[108]=ne,e[109]=ee,e[110]=Be):Be=e[110];let qe;e[111]!==r.currentCwd||e[112]!==r.onCloseRightWorkspace||e[113]!==r.showPreview?(qe=r.showPreview&&r.currentCwd&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Z0e,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[111]=r.currentCwd,e[112]=r.onCloseRightWorkspace,e[113]=r.showPreview,e[114]=qe):qe=e[114];let ze;e[115]!==p||e[116]!==f||e[117]!==r.currentCwd||e[118]!==w?(ze=f&&xt("configWrite")&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Y0e,{client:w.client,state:w,currentPath:r.currentCwd??null,initialPluginId:p,onClose:()=>{m(!1),h(void 0)}})}),e[115]=p,e[116]=f,e[117]=r.currentCwd,e[118]=w,e[119]=ze):ze=e[119];let Ie;e[120]!==ue||e[121]!==Be||e[122]!==qe||e[123]!==ze?(Ie=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[ue,Be,qe,ze]}),e[120]=ue,e[121]=Be,e[122]=qe,e[123]=ze,e[124]=Ie):Ie=e[124];let Me;return e[125]!==w||e[126]!==fe||e[127]!==Ie?(Me=a.jsx(HE,{runtime:w,workspacePath:fe,children:Ie}),e[125]=w,e[126]=fe,e[127]=Ie,e[128]=Me):Me=e[128],Me}function ebe(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function tbe(n){const e=V.c(15),{navigation:t,sessionView:s,project:r,chrome:o}=n;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(vA,{}),l=a.jsx(bA,{}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let c;e[2]!==o||e[3]!==t||e[4]!==r||e[5]!==s?(c=a.jsx(Q0e,{navigation:t,sessionView:s,project:r,chrome:o}),e[2]=o,e[3]=t,e[4]=r,e[5]=s,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==t||e[9]!==r?(u=a.jsx(hpe,{navigation:t,project:r,chrome:o}),e[7]=o,e[8]=t,e[9]=r,e[10]=u):u=e[10];let d;return e[11]!==o.backgroundServers||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[o.backgroundServers,i,l,c,u]}),e[11]=o.backgroundServers,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}const nbe=[{id:"sessions",label:"Sessions",icon:Yr},{id:"chat",label:"Chat",icon:vc},{id:"workspace",label:"Workspace",icon:B8}],sbe=y.memo(function(e){const t=V.c(6),{activeTab:s,onTabChange:r}=e,{isLive:o}=jt();let i;t[0]!==s||t[1]!==o||t[2]!==r?(i=nbe.map(c=>{const u=c.icon,d=s===c.id;return a.jsx("button",{type:"button","aria-current":d?"page":void 0,"aria-label":c.label,title:c.label,onClick:()=>{H1(),r(c.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:a.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",d?"scale-100 bg-accent":"scale-95"),children:[a.jsx(u,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&!d&&a.jsx(Sm,{"aria-label":"Session is live",className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},c.id)}),t[0]=s,t[1]=o,t[2]=r,t[3]=i):i=t[3];let l;return t[4]!==i?(l=a.jsx("nav",{className:"flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]","aria-label":"Navigation",children:i}),t[4]=i,t[5]=l):l=t[5],l});function rbe(n){const e=V.c(77),{session:t,sessionSource:s,isSubAgentView:r,isLive:o,canArchive:i,onProviderHandoff:l,claudeRawMessages:c,headerAccessory:u,creatingSession:d,onNewSession:f,onDuplicateSession:m,onBackToMain:p,onShowFileChanges:h,hasFileChanges:g,onShowWorkflows:x,workflowCount:b,onSearch:w,expandAll:v,onToggleExpandAll:j}=n,k=UI(t.sessionId,o,i);let _;e[0]!==f||e[1]!==t.cwd||e[2]!==s?(_=()=>{s&&f(s.dirName,t.cwd)},e[0]=f,e[1]=t.cwd,e[2]=s,e[3]=_):_=e[3];const N=_;let S;e[4]!==r||e[5]!==p?(S=r&&p&&a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm",onClick:p,"aria-label":"Back to main agent",children:a.jsx(ux,{"data-icon":"inline-start"})}),e[4]=r,e[5]=p,e[6]=S):S=e[6];let C,E;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(Xb,{compact:!0}),E=a.jsx(tn,{orientation:"vertical",className:"h-4"}),e[7]=C,e[8]=E):(C=e[7],E=e[8]);let T;e[9]!==c?(T=a.jsx(dA,{rawMessages:c,warnOnly:!0}),e[9]=c,e[10]=T):T=e[10];let $;e[11]!==t.cwd?($=t.cwd?Er(t.cwd):"Session",e[11]=t.cwd,e[12]=$):$=e[12];let A;e[13]!==$?(A=a.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:$}),e[13]=$,e[14]=A):A=e[14];let R;e[15]!==o?(R=o&&a.jsx(Sm,{"aria-label":"Session is live"}),e[15]=o,e[16]=R):R=e[16];let P;e[17]!==A||e[18]!==R?(P=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1.5",children:[A,R]}),e[17]=A,e[18]=R,e[19]=P):P=e[19];let z;e[20]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Rc,{render:a.jsx(Q,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(q4,{"data-icon":"inline-start"})}),e[20]=z):z=e[20];let L;e[21]!==t.cwd?(L=t.cwd?Er(t.cwd):"Current session",e[21]=t.cwd,e[22]=L):L=e[22];let I;e[23]!==L?(I=a.jsx("span",{className:"truncate text-foreground",children:L}),e[23]=L,e[24]=I):I=e[24];let M;e[25]!==t.gitBranch||e[26]!==t.model?(M=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[25]=t.gitBranch,e[26]=t.model,e[27]=M):M=e[27];let F;e[28]!==M?(F=a.jsx("span",{className:"truncate font-normal",children:M}),e[28]=M,e[29]=F):F=e[29];let U;e[30]!==I||e[31]!==F?(U=a.jsxs(P5,{className:"flex flex-col gap-0.5",children:[I,F]}),e[30]=I,e[31]=F,e[32]=U):U=e[32];let O;e[33]!==d||e[34]!==N||e[35]!==s?(O=s&&a.jsxs(hn,{onClick:N,disabled:d,children:[d?a.jsx(Pn,{}):a.jsx(kr,{}),a.jsx("span",{children:"New session"})]}),e[33]=d,e[34]=N,e[35]=s,e[36]=O):O=e[36];let D;e[37]!==m?(D=m&&a.jsxs(hn,{onClick:m,children:[a.jsx(Es,{}),a.jsx("span",{children:"Duplicate session"})]}),e[37]=m,e[38]=D):D=e[38];let B;e[39]!==r||e[40]!==l?(B=l&&!r&&a.jsxs(hn,{onClick:l,children:[a.jsx(W4,{}),a.jsx("span",{children:"Continue with another provider…"})]}),e[39]=r,e[40]=l,e[41]=B):B=e[41];let q;e[42]!==k||e[43]!==r?(q=k&&!r&&a.jsxs(hn,{onClick:k.toggle,disabled:!!k.disabledReason,children:[a.jsx(k.icon,{}),a.jsxs("span",{className:"flex flex-col",children:[k.label,k.disabledReason&&a.jsx("span",{className:"text-xs text-muted-foreground",children:k.disabledReason})]})]}),e[42]=k,e[43]=r,e[44]=q):q=e[44];let W;e[45]!==U||e[46]!==O||e[47]!==D||e[48]!==B||e[49]!==q?(W=a.jsxs(qr,{children:[U,O,D,B,q]}),e[45]=U,e[46]=O,e[47]=D,e[48]=B,e[49]=q,e[50]=W):W=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx(Il,{}),e[51]=H):H=e[51];let K;e[52]!==w?(K=w&&a.jsxs(hn,{onClick:w,children:[a.jsx(ss,{}),a.jsx("span",{children:"Search conversation"})]}),e[52]=w,e[53]=K):K=e[53];let Z;e[54]!==v||e[55]!==j?(Z=j&&a.jsxs(hn,{onClick:j,children:[v?a.jsx(Nf,{}):a.jsx(Ea,{}),a.jsx("span",{children:v?"Collapse tool calls":"Expand tool calls"})]}),e[54]=v,e[55]=j,e[56]=Z):Z=e[56];let Y;e[57]!==g||e[58]!==h?(Y=g&&h&&a.jsxs(hn,{onClick:h,children:[a.jsx(yc,{}),a.jsx("span",{children:"File changes"})]}),e[57]=g,e[58]=h,e[59]=Y):Y=e[59];let J;e[60]!==x||e[61]!==b?(J=x&&(b??0)>0&&a.jsxs(hn,{onClick:x,children:[a.jsx(B4,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Fe,{variant:"secondary",children:b})]}),e[60]=x,e[61]=b,e[62]=J):J=e[62];let ee;e[63]!==K||e[64]!==Z||e[65]!==Y||e[66]!==J?(ee=a.jsxs(qr,{children:[K,Z,Y,J]}),e[63]=K,e[64]=Z,e[65]=Y,e[66]=J,e[67]=ee):ee=e[67];let te;e[68]!==W||e[69]!==ee?(te=a.jsxs($c,{children:[z,a.jsxs(Oc,{align:"end",sideOffset:6,className:"w-72",children:[W,H,ee]})]}),e[68]=W,e[69]=ee,e[70]=te):te=e[70];let se;return e[71]!==u||e[72]!==S||e[73]!==te||e[74]!==T||e[75]!==P?(se=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[S,C,E,T,P,u,te]}),e[71]=u,e[72]=S,e[73]=te,e[74]=T,e[75]=P,e[76]=se):se=e[76],se}const obe=y.memo(function(e){const t=V.c(14),{isMobile:s}=Sn(),{session:r,sessionSource:o,isLive:i,permissions:l,actions:c}=jt();if(!s||!r)return null;let u;t[0]!==o?(u=o?$o(o.fileName):null,t[0]=o,t[1]=u):u=t[1];const d=u;let f;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(f=ia(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=f):f=t[4];const m=f,p=d!==null,h=l.send&&d===null?c.handleProviderHandoff:void 0;let g;return t[5]!==m||t[6]!==i||t[7]!==l.archive||t[8]!==e||t[9]!==r||t[10]!==o||t[11]!==p||t[12]!==h?(g=a.jsx(rbe,{...e,session:r,sessionSource:o,isSubAgentView:p,isLive:i,canArchive:l.archive,onProviderHandoff:h,claudeRawMessages:m}),t[5]=m,t[6]=i,t[7]=l.archive,t[8]=e,t[9]=r,t[10]=o,t[11]=p,t[12]=h,t[13]=g):g=t[13],g}),ibe=50;function abe({onSwipeLeft:n,onSwipeRight:e}){const t=y.useRef(null),s=y.useRef(null),r=y.useRef(n),o=y.useRef(e);return r.current=n,o.current=e,y.useEffect(()=>{const i=t.current;if(!i)return;function l(u){const d=u.touches[0];s.current={x:d.clientX,y:d.clientY}}function c(u){var p,h;if(!s.current)return;const d=u.changedTouches[0],f=d.clientX-s.current.x,m=d.clientY-s.current.y;s.current=null,!(Math.abs(f)<ibe||Math.abs(f)<Math.abs(m))&&(f>0?(p=o.current)==null||p.call(o):(h=r.current)==null||h.call(r))}return i.addEventListener("touchstart",l,{passive:!0}),i.addEventListener("touchend",c,{passive:!0}),()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",c)}},[]),t}const Fj=["sessions","chat","workspace"];function Uj(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function lbe(n){var P;const e=V.c(46),{panels:t,context:s,activePanelId:r,active:o,onSelectPanel:i,onClosePanel:l,actions:c,actionContent:u}=n;let d;e[0]!==c?(d=c===void 0?[]:c,e[0]=c,e[1]=d):d=e[1];const f=d;let m,p,h,g,x,b,w,v;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=tv(t,s);let z;e[16]!==r?(z=U=>U.id===r,e[16]=r,e[17]=z):z=e[17],h=p.find(z);let L;e[18]!==f?(L=f.find(ube),e[18]=f,e[19]=L):L=e[19],m=L,v=(m==null?void 0:m.title)??(h==null?void 0:h.title);let I;e[20]!==s.projectPath?(I=(P=s.projectPath)==null?void 0:P.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=I):I=e[21];const M=I;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const F=v?a.jsxs(a.Fragment,{children:[a.jsx(Q,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(yx,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:v}),a.jsx(Q,{variant:"outline",onClick:l,children:"Switch"})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[a.jsx("h1",{className:"text-base font-medium",children:"Workspace"}),M&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s.projectPath??void 0,children:M})]});e[22]!==F?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:F}),e[22]=F,e[23]=b):b=e[23],w=!v&&a.jsx("div",{className:"mobile-scroll min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("nav",{"aria-label":"Workspace tools",className:"grid grid-cols-2 gap-2",children:[p.map(U=>{var q;const O=U.icon,D=U.indicator,B=(q=U.badge)==null?void 0:q.call(U,s);return a.jsxs(Q,{variant:"outline","aria-label":U.title,className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:()=>i(U.id),children:[a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsxs("span",{className:"relative",children:[a.jsx(O,{"data-icon":"inline-start"}),D&&a.jsx(D,{context:s,active:!1})]}),B!=null&&a.jsx(Fe,{variant:"secondary",children:B})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:U.title}),a.jsx(it,{"data-icon":"inline-end"})]})]},U.id)}),f.map(cbe)]})}),e[2]=f,e[3]=r,e[4]=s,e[5]=l,e[6]=i,e[7]=t,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b,e[14]=w,e[15]=v}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],w=e[14],v=e[15];const j=v?"relative min-h-0 flex-1":"hidden",k=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",_=m&&u;let N;e[24]!==k||e[25]!==_?(N=a.jsx(vI,{fallbackMessage:"Couldn't open this workspace tool",children:_},k),e[24]=k,e[25]=_,e[26]=N):N=e[26];const S=m?"hidden":"h-full min-h-0",C=(h==null?void 0:h.id)??"",E=o&&!m;let T;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==C||e[31]!==E?(T=a.jsx(VI,{panels:p,context:s,activePanelId:C,active:E,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=C,e[31]=E,e[32]=T):T=e[32];let $;e[33]!==S||e[34]!==T?($=a.jsx("div",{className:S,children:T}),e[33]=S,e[34]=T,e[35]=$):$=e[35];let A;e[36]!==N||e[37]!==$||e[38]!==j?(A=a.jsxs("div",{className:j,children:[N,$]}),e[36]=N,e[37]=$,e[38]=j,e[39]=A):A=e[39];let R;return e[40]!==A||e[41]!==g||e[42]!==x||e[43]!==b||e[44]!==w?(R=a.jsxs("section",{"aria-label":g,className:x,children:[b,w,A]}),e[40]=A,e[41]=g,e[42]=x,e[43]=b,e[44]=w,e[45]=R):R=e[45],R}function cbe(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(Q,{variant:"outline",className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:r,children:[a.jsx(s,{"data-icon":"inline-start"}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:t}),a.jsx(it,{"data-icon":"inline-end"})]})]},e)}function ube(n){return n.active}const dbe=y.lazy(()=>nt(()=>import("./PluginsDialog-CBOyfoUX.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),fbe=y.lazy(()=>nt(()=>import("./ConfigBrowser-CRwh8BXq.js"),__vite__mapDeps([38,1,2,33,3,4])).then(n=>({default:n.ConfigBrowser})));function mbe(n){var ce;const e=V.c(94),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=Sn(),{session:l,sessionSource:c}=jt(),u=OI((l==null?void 0:l.sessionId)??null),d=Nn("hostFiles"),f=Nn("browser"),m=Nn("configWrite"),[p,h]=y.useState(pbe),[g,x]=y.useState();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=oe=>{x(oe),h(!0)},e[0]=b):b=e[0];const w=b,v=HI(m),j=r.currentCwd??null;let k;e[1]!==v||e[2]!==j?(k={...v,projectPath:j,openSettings:w},e[1]=v,e[2]=j,e[3]=k):k=e[3];const _=GI(k),[N,S]=y.useState(null),{panels:C}=t,E=C.activeWorkspacePanel===null?N:null,T=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let $;e[4]!==C?($=function(){S(null),C.closeWorkspacePanel()},e[4]=C,e[5]=$):$=e[5];const A=$;let R;e[6]!==C?(R=function(fe){C.closeWorkspacePanel(),S(fe)},e[6]=C,e[7]=R):R=e[7];const P=R;let z;e[8]!==t.actions||e[9]!==s.chatInputRef?(z=function(fe){const ue=s.chatInputRef.current,le=(ue==null?void 0:ue.getText().trimEnd())??"";ue==null||ue.setText(le?`${le}
|
|
479
479
|
|
|
480
480
|
${fe}
|
|
481
481
|
`:`${fe}
|
|
482
|
-
`),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>ue==null?void 0:ue.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=z):z=e[10];const L=z;let I;e[11]!==c?(I=c?{dirName:c.dirName,fileName:c.fileName}:null,e[11]=c,e[12]=I):I=e[12];const M=r.currentCwd??null;let F;e[13]!==d||e[14]!==f||e[15]!==L||e[16]!==t.handlers.handleLoadSessionScrollAware||e[17]!==u||e[18]!==r.hasFileChanges||e[19]!==r.supportsWorktrees||e[20]!==l||e[21]!==i.sessionChangeKey||e[22]!==I||e[23]!==M?(F={session:l,sessionAddress:I,sessionChangeKey:i.sessionChangeKey,projectPath:M,hasFileChanges:r.hasFileChanges,canAccessHostFiles:d,canUseBrowser:f,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:L,crew:u},e[13]=d,e[14]=f,e[15]=L,e[16]=t.handlers.handleLoadSessionScrollAware,e[17]=u,e[18]=r.hasFileChanges,e[19]=r.supportsWorktrees,e[20]=l,e[21]=i.sessionChangeKey,e[22]=I,e[23]=M,e[24]=F):F=e[24];const U=F,O=r.currentCwd??null,D=r.projectFilesRoot??r.currentCwd??null;let B;e[25]!==L?(B=oe=>L(b7(oe)),e[25]=L,e[26]=B):B=e[26];let q;e[27]!==t.actions||e[28]!==r.processPanel?(q=(...oe)=>{const fe=oe;r.processPanel.handleToggleServer(...fe),t.actions.handleMobileTabChange("chat")},e[27]=t.actions,e[28]=r.processPanel,e[29]=q):q=e[29];let W;e[30]!==t.actions?(W=oe=>{t.actions.handleDashboardSelect(oe.dirName,`${oe.sessionId}.jsonl`)},e[30]=t.actions,e[31]=W):W=e[31];let H;e[32]!==t.handlers.handleLoadSessionScrollAware||e[33]!==t.handlers.handleMobileJumpToTurn||e[34]!==r.backgroundAgents||e[35]!==r.processPanel.handleServersChanged||e[36]!==r.projectFilesRequest||e[37]!==r.worktrees||e[38]!==s.searchInputRef||e[39]!==D||e[40]!==B||e[41]!==q||e[42]!==W||e[43]!==T?(H={projectFilesRoot:D,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:B,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:q,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:T,openWorktreeSession:W},e[32]=t.handlers.handleLoadSessionScrollAware,e[33]=t.handlers.handleMobileJumpToTurn,e[34]=r.backgroundAgents,e[35]=r.processPanel.handleServersChanged,e[36]=r.projectFilesRequest,e[37]=r.worktrees,e[38]=s.searchInputRef,e[39]=D,e[40]=B,e[41]=q,e[42]=W,e[43]=T,e[44]=H):H=e[44];let K;e[45]!==C.activeWorkspacePanel||e[46]!==_?(K=((ce=$I(C.activeWorkspacePanel,_))==null?void 0:ce.id)??C.activeWorkspacePanel,e[45]=C.activeWorkspacePanel,e[46]=_,e[47]=K):K=e[47];let Z;e[48]!==C?(Z=oe=>{S(null),C.openWorkspacePanel(oe)},e[48]=C,e[49]=Z):Z=e[49];let Y;e[50]!==m?(Y=m?[{id:"plugins",title:"Plugins",icon:vx,active:!1,onSelect:()=>h(!0)}]:[],e[50]=m,e[51]=Y):Y=e[51];const J=E==="mission";let ee;e[52]!==P?(ee=()=>P("mission"),e[52]=P,e[53]=ee):ee=e[53];let te;e[54]!==J||e[55]!==ee?(te={id:"mission",title:"Mission Control",icon:H4,active:J,onSelect:ee},e[54]=J,e[55]=ee,e[56]=te):te=e[56];let se;e[57]!==m||e[58]!==P||e[59]!==E?(se=m?[{id:"config",title:"Config",icon:K4,active:E==="config",onSelect:()=>P("config")}]:[],e[57]=m,e[58]=P,e[59]=E,e[60]=se):se=e[60];let X;e[61]!==Y||e[62]!==te||e[63]!==se?(X=[...Y,te,...se],e[61]=Y,e[62]=te,e[63]=se,e[64]=X):X=e[64];let ne;e[65]!==m||e[66]!==t||e[67]!==r.currentCwd||e[68]!==E||e[69]!==i.configFilePath?(ne=E==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(bf,{navigation:t})}):E==="config"&&m?a.jsx(y.Suspense,{fallback:a.jsx(Rm,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(fbe,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[65]=m,e[66]=t,e[67]=r.currentCwd,e[68]=E,e[69]=i.configFilePath,e[70]=ne):ne=e[70];let ae;e[71]!==o||e[72]!==A||e[73]!==U||e[74]!==K||e[75]!==Z||e[76]!==X||e[77]!==ne||e[78]!==_?(ae=a.jsx(lbe,{panels:_,context:U,activePanelId:K,active:o,onSelectPanel:Z,onClosePanel:A,actions:X,actionContent:ne}),e[71]=o,e[72]=A,e[73]=U,e[74]=K,e[75]=Z,e[76]=X,e[77]=ne,e[78]=_,e[79]=ae):ae=e[79];let ie;e[80]!==m||e[81]!==g||e[82]!==p||e[83]!==r.currentCwd||e[84]!==v?(ie=p&&m&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(dbe,{client:v.client,state:v,currentPath:r.currentCwd??null,initialPluginId:g,onClose:()=>{h(!1),x(void 0)}})}),e[80]=m,e[81]=g,e[82]=p,e[83]=r.currentCwd,e[84]=v,e[85]=ie):ie=e[85];let re;e[86]!==H||e[87]!==ae||e[88]!==ie?(re=a.jsxs(WI,{value:H,children:[ae,ie]}),e[86]=H,e[87]=ae,e[88]=ie,e[89]=re):re=e[89];let de;return e[90]!==v||e[91]!==O||e[92]!==re?(de=a.jsx(HE,{runtime:v,workspacePath:O,children:re}),e[90]=v,e[91]=O,e[92]=re,e[93]=de):de=e[93],de}function pbe(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const hbe=y.lazy(()=>nt(()=>import("./MobileFileChanges-DERAdWVc.js"),__vite__mapDeps([41,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function gbe(n){const e=V.c(79),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=Sn(),{session:c}=jt(),[u,d]=y.useState(!1),{AccountControl:f}=$r(),m=FN(i.mainView==="extension"?i.extensionViewId:null),p=i.mobileTab==="workspace"||(m==null?void 0:m.locksSwipe)===!0;let h;e[0]!==t.actions||e[1]!==i.mobileTab||e[2]!==p?(h={onSwipeLeft:()=>{if(p)return;const K=Uj(Fj,i.mobileTab,1);K&&(H1(),t.actions.handleMobileTabChange(K))},onSwipeRight:()=>{if(p)return;const K=Uj(Fj,i.mobileTab,-1);K&&(H1(),t.actions.handleMobileTabChange(K))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=p,e[3]=h):h=e[3];const g=abe(h);let x;e[4]!==f||e[5]!==o.onLogout||e[6]!==t.panels?(x=f&&a.jsx(f,{mobile:!0,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView,className:"ml-auto"}),e[4]=f,e[5]=o.onLogout,e[6]=t.panels,e[7]=x):x=e[7];const b=x;let w;e[8]!==m||e[9]!==t.actions||e[10]!==t.panels?(w=K=>{d(!1),m&&t.panels.closeMainView(),t.actions.handleMobileTabChange(K)},e[8]=m,e[9]=t.actions,e[10]=t.panels,e[11]=w):w=e[11];const v=w,j=o.backgroundServers;let k,_;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(vA,{}),_=a.jsx(bA,{}),e[12]=k,e[13]=_):(k=e[12],_=e[13]);let N;e[14]!==b||e[15]!==c||e[16]!==i.mobileTab?(N=!(i.mobileTab==="chat"&&c)&&a.jsxs("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:[a.jsx(Xb,{compact:!0}),b]}),e[14]=b,e[15]=c,e[16]=i.mobileTab,e[17]=N):N=e[17];let S;e[18]!==t||e[19]!==i.mobileTab?(S=i.mobileTab==="sessions"&&a.jsx(g7,{navigation:t,mobile:!0}),e[18]=t,e[19]=i.mobileTab,e[20]=S):S=e[20];const C=i.mobileTab!=="chat",E=i.mobileTab!=="chat",T=i.mobileTab!=="chat"&&"invisible pointer-events-none";let $;e[21]!==T?($=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",T),e[21]=T,e[22]=$):$=e[22];let A;e[23]!==o||e[24]!==b||e[25]!==t||e[26]!==r||e[27]!==u||e[28]!==s?(A=a.jsx(xbe,{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:b,searchOpen:u,onSearchOpenChange:d}),e[23]=o,e[24]=b,e[25]=t,e[26]=r,e[27]=u,e[28]=s,e[29]=A):A=e[29];let R;e[30]!==E||e[31]!==$||e[32]!==A||e[33]!==C?(R=a.jsx("div",{"aria-hidden":C,inert:E,className:$,children:A}),e[30]=E,e[31]=$,e[32]=A,e[33]=C,e[34]=R):R=e[34];const P=i.mobileTab!=="workspace",z=i.mobileTab!=="workspace",L=i.mobileTab!=="workspace"&&"hidden";let I;e[35]!==L?(I=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",L),e[35]=L,e[36]=I):I=e[36];const M=i.mobileTab==="workspace";let F;e[37]!==o||e[38]!==t||e[39]!==r||e[40]!==s||e[41]!==M?(F=a.jsx(mbe,{navigation:t,sessionView:s,project:r,chrome:o,active:M}),e[37]=o,e[38]=t,e[39]=r,e[40]=s,e[41]=M,e[42]=F):F=e[42];let U;e[43]!==P||e[44]!==z||e[45]!==I||e[46]!==F?(U=a.jsx("div",{"aria-hidden":P,inert:z,className:I,children:F}),e[43]=P,e[44]=z,e[45]=I,e[46]=F,e[47]=U):U=e[47];let O;e[48]!==m||e[49]!==t.panels?(O=m&&a.jsx("div",{className:"absolute inset-0 z-10 flex min-h-0 min-w-0 flex-col bg-canvas",children:a.jsx(x7,{view:m,onClose:t.panels.closeMainView})}),e[48]=m,e[49]=t.panels,e[50]=O):O=e[50];let D;e[51]!==g||e[52]!==R||e[53]!==U||e[54]!==O||e[55]!==S?(D=a.jsxs("main",{ref:g,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[S,R,U,O]}),e[51]=g,e[52]=R,e[53]=U,e[54]=O,e[55]=S,e[56]=D):D=e[56];let B;e[57]!==v||e[58]!==i.mobileTab?(B=a.jsx(sbe,{activeTab:i.mobileTab,onTabChange:v}),e[57]=v,e[58]=i.mobileTab,e[59]=B):B=e[59];let q;e[60]!==l.defaultAgentKind||e[61]!==t.onStartNewFolder||e[62]!==t.onStartNewSession?(q=a.jsx(II,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:l.defaultAgentKind}),e[60]=l.defaultAgentKind,e[61]=t.onStartNewFolder,e[62]=t.onStartNewSession,e[63]=q):q=e[63];let W;e[64]!==o||e[65]!==r||e[66]!==c||e[67]!==i.sessionChangeKey?(W=c&&r.hasFileChanges&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(hbe,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:c,sessionChangeKey:i.sessionChangeKey})}),e[64]=o,e[65]=r,e[66]=c,e[67]=i.sessionChangeKey,e[68]=W):W=e[68];let H;return e[69]!==o.backgroundServers||e[70]!==o.branchModal||e[71]!==o.undoDialog||e[72]!==o.workflowsPanel||e[73]!==D||e[74]!==B||e[75]!==q||e[76]!==W||e[77]!==N?(H=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[j,k,_,N,D,o.workflowsPanel,B,o.undoDialog,o.branchModal,q,W]}),e[69]=o.backgroundServers,e[70]=o.branchModal,e[71]=o.undoDialog,e[72]=o.workflowsPanel,e[73]=D,e[74]=B,e[75]=q,e[76]=W,e[77]=N,e[78]=H):H=e[78],H}function xbe(n){const e=V.c(23),{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:i,searchOpen:l,onSearchOpenChange:c}=n,{state:u,config:d}=Sn(),{session:f,isSubAgentView:m}=jt();let p;e[0]!==o||e[1]!==d||e[2]!==i||e[3]!==m||e[4]!==t||e[5]!==c||e[6]!==r||e[7]!==l||e[8]!==f||e[9]!==s||e[10]!==u.expandAll||e[11]!==u.pendingDirName?(p=f?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(obe,{headerAccessory:i,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:m?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>c(!0),expandAll:u.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(Tm,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:l,onMobileSearchClose:()=>c(!1)})]}):u.pendingDirName?a.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?a.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[a.jsx(t7,{projectPath:s.pendingPath??null,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:d.defaultAgentKind}}),xt("terminal")&&a.jsxs(Q,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(_a,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(bf,{navigation:t}),e[0]=o,e[1]=d,e[2]=i,e[3]=m,e[4]=t,e[5]=c,e[6]=r,e[7]=l,e[8]=f,e[9]=s,e[10]=u.expandAll,e[11]=u.pendingDirName,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==s||e[15]!==u.pendingDirName?(h=(f||u.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,f?s.activeComposer:s.pendingComposer]}),e[13]=f,e[14]=s,e[15]=u.pendingDirName,e[16]=h):h=e[16];let g;e[17]!==o.processPanel||e[18]!==h?(g=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,h]}),e[17]=o.processPanel,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function bbe(n){const e=V.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=Sn(),{session:d}=jt();let f;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==r||e[7]!==d||e[8]!==t?(f=a.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(Tm,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(Im,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(Ln,{className:"max-w-md",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:s?a.jsx(Sr,{}):a.jsx(St,{className:"animate-spin"})}),a.jsx(zn,{children:s?"Unable to open session":"Opening session"}),a.jsx(Dn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=o,e[1]=i,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=r,e[7]=d,e[8]=t,e[9]=f):f=e[9],f}function vbe(){let n=ui;const e=new Set;return{snapshot:()=>n,subscribe(t){return e.add(t),()=>{e.delete(t)}},publish(t){if(t!==n){n=t;for(const s of e)s()}}}}const ybe=5;function v7(){const n=cn(),e=Zn();return e===null?n:`${n}:${e}`}function Zu(n,e){return`${v7()}:${n}/${e}`}class wbe{constructor(){Ge(this,"cache",new Map)}get(e,t){const s=Zu(e,t),r=this.cache.get(s);return r&&(r.lastAccessed=Date.now()),r}set(e,t,s,r,o,i,l,c){const u=Zu(e,t);!this.cache.has(u)&&this.cache.size>=ybe&&this.evictLRU(),this.cache.set(u,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:r,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:o,hasMore:i,lastAccessed:Date.now()})}update(e,t,s){const r=Zu(e,t),o=this.cache.get(r);o&&(s.parsed!==void 0&&(o.parsed=s.parsed),s.olderTurns!==void 0&&(o.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(o.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(o.hasMore=s.hasMore),s.lastAccessed!==void 0&&(o.lastAccessed=s.lastAccessed),s.source&&(o.source={...o.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(Zu(e,t)):this.evictLRU()}evictSession(e){const t=`${v7()}:`;for(const[s,{source:r}]of this.cache)s.startsWith(t)&&Nx(r.dirName,r.fileName)===e&&this.cache.delete(s)}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,r]of this.cache)r.lastAccessed<t&&(t=r.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const js=new wbe,Bj={},Sbe=1e4;function y7(n,e,t,s,r,o){const[i,l]=y.useState(!1),[c,u]=y.useState("disconnected"),[d,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(Bj),[x,b]=y.useState(null),[w,v]=y.useState(null),[j]=y.useState(vbe),k=y.useRef(""),_=y.useRef(null),N=y.useRef(ui),S=y.useRef("disconnected"),C=y.useRef(e);C.current=e;const E=y.useRef(r);E.current=r;const T=y.useRef(t);T.current=t;const $=y.useRef(s);$.current=s;const A=y.useRef(o??null);A.current=o??null;const R=y.useRef(!1),P=y.useRef(0),z=(n==null?void 0:n.dirName)??null,L=(n==null?void 0:n.fileName)??null,I=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(I).byteLength;return y.useEffect(()=>{if(k.current=I,!I){_.current=null,l(!1);return}const F=A.current;if(F){_.current=F;return}T.current(I).then(U=>{_.current=oa(U,Xr(n==null?void 0:n.dirName).instanceId)})},[I,n==null?void 0:n.dirName]),y.useEffect(()=>{if(b(null),v(null),!z||!L){l(!1),u("disconnected");return}u("connecting");const F=`/api/watch/${encodeURIComponent(z)}/${encodeURIComponent(L)}?offset=${M}`,U=nb(F),O=U.source;let D=null;const B=(ce=3e4)=>{D&&clearTimeout(D),D=setTimeout(()=>{l(!1),f(!1)},ce)};let q="",W=M,H=!1,K=!1,Z=!1,Y=null;const J=()=>{Z=!1,Y=null,_.current&&C.current(_.current)},ee=()=>{Z||(Z=!0,Y=requestAnimationFrame(J))};let te=!1,se=null,X=null;const ne=()=>{te=!1,se=null,j.publish(N.current)},ae=()=>{te||(te=!0,se=requestAnimationFrame(ne))},ie=ce=>{ce!==N.current&&(N.current=ce,ae(),ce.length>0&&!X&&(X=setInterval(()=>{const oe=Ele(N.current);oe!==N.current&&(N.current=oe,ae()),N.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},re=()=>{ie(ui),g(Bj)},de=()=>{if(K||H||!q)return;const ce=q;q="",H=!0;const oe=_.current,fe=oe?$.current(oe,ce):T.current(k.current);let ue=!1;fe.then(le=>{const pe=oa(le,Xr(z).instanceId);K||(_.current=pe,z&&L&&js.update(z,L,{parsed:pe,source:{rawText:k.current,watchOffset:W}}),ee())},le=>{if(console.error("[useLiveSession] worker parse failed:",le),K)return;ue=!0,q=ce+q;const pe=Date.now();E.current&&pe-P.current>=Sbe&&(P.current=pe,E.current())}).catch(le=>{console.error("[useLiveSession] live update failed:",le)}).finally(()=>{H=!1,!K&&!ue&&q&&de()})};return O.onopen=()=>{var ce;if(S.current!=="connected"){const oe=R.current;R.current=!1,S.current="connected",u("connected"),oe&&((ce=E.current)==null||ce.call(E))}},O.onmessage=ce=>{try{S.current!=="connected"&&(S.current="connected",u("connected"));const oe=JSON.parse(ce.data);if(oe.type==="init")oe.recentlyActive?(l(!0),B(5e3)):B();else if(oe.type==="compacting")oe.active&&(l(!0),re(),B()),f(oe.active===!0);else if(oe.type==="subagent_activity")l(!0),B();else if(oe.type==="runtime_activity")l(!0),B();else if(oe.type==="stream_snapshot")l(!0),B(),ie(Nle(oe.messages??[]));else if(oe.type==="stream_delta")l(!0),B(),p(null),b(null),v(null),ie(Cle(N.current,oe.events??[]));else if(oe.type==="rate_limit")v(oe.block??null);else if(oe.type==="agent_progress")l(!0),B(),g(fe=>({...fe,[oe.toolUseId]:oe.summary}));else if(oe.type==="prompt_suggestion")b(typeof oe.suggestion=="string"?oe.suggestion:null);else if(oe.type==="turn_error")p(typeof oe.message=="string"?oe.message:"The turn failed");else if(oe.type==="stream_clear")re(),f(!1);else if(oe.type==="lines"){if(typeof oe.skippedBytes=="number"&&(W+=oe.skippedBytes),oe.lines.length===0)return;l(!0),f(!1),B(),ie(_le(N.current,oe.lines));const fe=oe.lines.join(`
|
|
482
|
+
`),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>ue==null?void 0:ue.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=z):z=e[10];const L=z;let I;e[11]!==c?(I=c?{dirName:c.dirName,fileName:c.fileName}:null,e[11]=c,e[12]=I):I=e[12];const M=r.currentCwd??null;let F;e[13]!==d||e[14]!==f||e[15]!==L||e[16]!==t.handlers.handleLoadSessionScrollAware||e[17]!==u||e[18]!==r.hasFileChanges||e[19]!==r.supportsWorktrees||e[20]!==l||e[21]!==i.sessionChangeKey||e[22]!==I||e[23]!==M?(F={session:l,sessionAddress:I,sessionChangeKey:i.sessionChangeKey,projectPath:M,hasFileChanges:r.hasFileChanges,canAccessHostFiles:d,canUseBrowser:f,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:L,crew:u},e[13]=d,e[14]=f,e[15]=L,e[16]=t.handlers.handleLoadSessionScrollAware,e[17]=u,e[18]=r.hasFileChanges,e[19]=r.supportsWorktrees,e[20]=l,e[21]=i.sessionChangeKey,e[22]=I,e[23]=M,e[24]=F):F=e[24];const U=F,O=r.currentCwd??null,D=r.projectFilesRoot??r.currentCwd??null;let B;e[25]!==L?(B=oe=>L(b7(oe)),e[25]=L,e[26]=B):B=e[26];let q;e[27]!==t.actions||e[28]!==r.processPanel?(q=(...oe)=>{const fe=oe;r.processPanel.handleToggleServer(...fe),t.actions.handleMobileTabChange("chat")},e[27]=t.actions,e[28]=r.processPanel,e[29]=q):q=e[29];let W;e[30]!==t.actions?(W=oe=>{t.actions.handleDashboardSelect(oe.dirName,`${oe.sessionId}.jsonl`)},e[30]=t.actions,e[31]=W):W=e[31];let H;e[32]!==t.handlers.handleLoadSessionScrollAware||e[33]!==t.handlers.handleMobileJumpToTurn||e[34]!==r.backgroundAgents||e[35]!==r.processPanel.handleServersChanged||e[36]!==r.projectFilesRequest||e[37]!==r.worktrees||e[38]!==s.searchInputRef||e[39]!==D||e[40]!==B||e[41]!==q||e[42]!==W||e[43]!==T?(H={projectFilesRoot:D,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:B,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:q,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:T,openWorktreeSession:W},e[32]=t.handlers.handleLoadSessionScrollAware,e[33]=t.handlers.handleMobileJumpToTurn,e[34]=r.backgroundAgents,e[35]=r.processPanel.handleServersChanged,e[36]=r.projectFilesRequest,e[37]=r.worktrees,e[38]=s.searchInputRef,e[39]=D,e[40]=B,e[41]=q,e[42]=W,e[43]=T,e[44]=H):H=e[44];let K;e[45]!==C.activeWorkspacePanel||e[46]!==_?(K=((ce=$I(C.activeWorkspacePanel,_))==null?void 0:ce.id)??C.activeWorkspacePanel,e[45]=C.activeWorkspacePanel,e[46]=_,e[47]=K):K=e[47];let Z;e[48]!==C?(Z=oe=>{S(null),C.openWorkspacePanel(oe)},e[48]=C,e[49]=Z):Z=e[49];let Y;e[50]!==m?(Y=m?[{id:"plugins",title:"Plugins",icon:vx,active:!1,onSelect:()=>h(!0)}]:[],e[50]=m,e[51]=Y):Y=e[51];const J=E==="mission";let ee;e[52]!==P?(ee=()=>P("mission"),e[52]=P,e[53]=ee):ee=e[53];let te;e[54]!==J||e[55]!==ee?(te={id:"mission",title:"Mission Control",icon:H4,active:J,onSelect:ee},e[54]=J,e[55]=ee,e[56]=te):te=e[56];let se;e[57]!==m||e[58]!==P||e[59]!==E?(se=m?[{id:"config",title:"Config",icon:K4,active:E==="config",onSelect:()=>P("config")}]:[],e[57]=m,e[58]=P,e[59]=E,e[60]=se):se=e[60];let X;e[61]!==Y||e[62]!==te||e[63]!==se?(X=[...Y,te,...se],e[61]=Y,e[62]=te,e[63]=se,e[64]=X):X=e[64];let ne;e[65]!==m||e[66]!==t||e[67]!==r.currentCwd||e[68]!==E||e[69]!==i.configFilePath?(ne=E==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(bf,{navigation:t})}):E==="config"&&m?a.jsx(y.Suspense,{fallback:a.jsx(Rm,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(fbe,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[65]=m,e[66]=t,e[67]=r.currentCwd,e[68]=E,e[69]=i.configFilePath,e[70]=ne):ne=e[70];let ae;e[71]!==o||e[72]!==A||e[73]!==U||e[74]!==K||e[75]!==Z||e[76]!==X||e[77]!==ne||e[78]!==_?(ae=a.jsx(lbe,{panels:_,context:U,activePanelId:K,active:o,onSelectPanel:Z,onClosePanel:A,actions:X,actionContent:ne}),e[71]=o,e[72]=A,e[73]=U,e[74]=K,e[75]=Z,e[76]=X,e[77]=ne,e[78]=_,e[79]=ae):ae=e[79];let ie;e[80]!==m||e[81]!==g||e[82]!==p||e[83]!==r.currentCwd||e[84]!==v?(ie=p&&m&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(dbe,{client:v.client,state:v,currentPath:r.currentCwd??null,initialPluginId:g,onClose:()=>{h(!1),x(void 0)}})}),e[80]=m,e[81]=g,e[82]=p,e[83]=r.currentCwd,e[84]=v,e[85]=ie):ie=e[85];let re;e[86]!==H||e[87]!==ae||e[88]!==ie?(re=a.jsxs(WI,{value:H,children:[ae,ie]}),e[86]=H,e[87]=ae,e[88]=ie,e[89]=re):re=e[89];let de;return e[90]!==v||e[91]!==O||e[92]!==re?(de=a.jsx(HE,{runtime:v,workspacePath:O,children:re}),e[90]=v,e[91]=O,e[92]=re,e[93]=de):de=e[93],de}function pbe(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const hbe=y.lazy(()=>nt(()=>import("./MobileFileChanges-O-SvMq9F.js"),__vite__mapDeps([41,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function gbe(n){const e=V.c(79),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=Sn(),{session:c}=jt(),[u,d]=y.useState(!1),{AccountControl:f}=$r(),m=FN(i.mainView==="extension"?i.extensionViewId:null),p=i.mobileTab==="workspace"||(m==null?void 0:m.locksSwipe)===!0;let h;e[0]!==t.actions||e[1]!==i.mobileTab||e[2]!==p?(h={onSwipeLeft:()=>{if(p)return;const K=Uj(Fj,i.mobileTab,1);K&&(H1(),t.actions.handleMobileTabChange(K))},onSwipeRight:()=>{if(p)return;const K=Uj(Fj,i.mobileTab,-1);K&&(H1(),t.actions.handleMobileTabChange(K))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=p,e[3]=h):h=e[3];const g=abe(h);let x;e[4]!==f||e[5]!==o.onLogout||e[6]!==t.panels?(x=f&&a.jsx(f,{mobile:!0,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView,className:"ml-auto"}),e[4]=f,e[5]=o.onLogout,e[6]=t.panels,e[7]=x):x=e[7];const b=x;let w;e[8]!==m||e[9]!==t.actions||e[10]!==t.panels?(w=K=>{d(!1),m&&t.panels.closeMainView(),t.actions.handleMobileTabChange(K)},e[8]=m,e[9]=t.actions,e[10]=t.panels,e[11]=w):w=e[11];const v=w,j=o.backgroundServers;let k,_;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(vA,{}),_=a.jsx(bA,{}),e[12]=k,e[13]=_):(k=e[12],_=e[13]);let N;e[14]!==b||e[15]!==c||e[16]!==i.mobileTab?(N=!(i.mobileTab==="chat"&&c)&&a.jsxs("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:[a.jsx(Xb,{compact:!0}),b]}),e[14]=b,e[15]=c,e[16]=i.mobileTab,e[17]=N):N=e[17];let S;e[18]!==t||e[19]!==i.mobileTab?(S=i.mobileTab==="sessions"&&a.jsx(g7,{navigation:t,mobile:!0}),e[18]=t,e[19]=i.mobileTab,e[20]=S):S=e[20];const C=i.mobileTab!=="chat",E=i.mobileTab!=="chat",T=i.mobileTab!=="chat"&&"invisible pointer-events-none";let $;e[21]!==T?($=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",T),e[21]=T,e[22]=$):$=e[22];let A;e[23]!==o||e[24]!==b||e[25]!==t||e[26]!==r||e[27]!==u||e[28]!==s?(A=a.jsx(xbe,{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:b,searchOpen:u,onSearchOpenChange:d}),e[23]=o,e[24]=b,e[25]=t,e[26]=r,e[27]=u,e[28]=s,e[29]=A):A=e[29];let R;e[30]!==E||e[31]!==$||e[32]!==A||e[33]!==C?(R=a.jsx("div",{"aria-hidden":C,inert:E,className:$,children:A}),e[30]=E,e[31]=$,e[32]=A,e[33]=C,e[34]=R):R=e[34];const P=i.mobileTab!=="workspace",z=i.mobileTab!=="workspace",L=i.mobileTab!=="workspace"&&"hidden";let I;e[35]!==L?(I=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",L),e[35]=L,e[36]=I):I=e[36];const M=i.mobileTab==="workspace";let F;e[37]!==o||e[38]!==t||e[39]!==r||e[40]!==s||e[41]!==M?(F=a.jsx(mbe,{navigation:t,sessionView:s,project:r,chrome:o,active:M}),e[37]=o,e[38]=t,e[39]=r,e[40]=s,e[41]=M,e[42]=F):F=e[42];let U;e[43]!==P||e[44]!==z||e[45]!==I||e[46]!==F?(U=a.jsx("div",{"aria-hidden":P,inert:z,className:I,children:F}),e[43]=P,e[44]=z,e[45]=I,e[46]=F,e[47]=U):U=e[47];let O;e[48]!==m||e[49]!==t.panels?(O=m&&a.jsx("div",{className:"absolute inset-0 z-10 flex min-h-0 min-w-0 flex-col bg-canvas",children:a.jsx(x7,{view:m,onClose:t.panels.closeMainView})}),e[48]=m,e[49]=t.panels,e[50]=O):O=e[50];let D;e[51]!==g||e[52]!==R||e[53]!==U||e[54]!==O||e[55]!==S?(D=a.jsxs("main",{ref:g,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[S,R,U,O]}),e[51]=g,e[52]=R,e[53]=U,e[54]=O,e[55]=S,e[56]=D):D=e[56];let B;e[57]!==v||e[58]!==i.mobileTab?(B=a.jsx(sbe,{activeTab:i.mobileTab,onTabChange:v}),e[57]=v,e[58]=i.mobileTab,e[59]=B):B=e[59];let q;e[60]!==l.defaultAgentKind||e[61]!==t.onStartNewFolder||e[62]!==t.onStartNewSession?(q=a.jsx(II,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:l.defaultAgentKind}),e[60]=l.defaultAgentKind,e[61]=t.onStartNewFolder,e[62]=t.onStartNewSession,e[63]=q):q=e[63];let W;e[64]!==o||e[65]!==r||e[66]!==c||e[67]!==i.sessionChangeKey?(W=c&&r.hasFileChanges&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(hbe,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:c,sessionChangeKey:i.sessionChangeKey})}),e[64]=o,e[65]=r,e[66]=c,e[67]=i.sessionChangeKey,e[68]=W):W=e[68];let H;return e[69]!==o.backgroundServers||e[70]!==o.branchModal||e[71]!==o.undoDialog||e[72]!==o.workflowsPanel||e[73]!==D||e[74]!==B||e[75]!==q||e[76]!==W||e[77]!==N?(H=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[j,k,_,N,D,o.workflowsPanel,B,o.undoDialog,o.branchModal,q,W]}),e[69]=o.backgroundServers,e[70]=o.branchModal,e[71]=o.undoDialog,e[72]=o.workflowsPanel,e[73]=D,e[74]=B,e[75]=q,e[76]=W,e[77]=N,e[78]=H):H=e[78],H}function xbe(n){const e=V.c(23),{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:i,searchOpen:l,onSearchOpenChange:c}=n,{state:u,config:d}=Sn(),{session:f,isSubAgentView:m}=jt();let p;e[0]!==o||e[1]!==d||e[2]!==i||e[3]!==m||e[4]!==t||e[5]!==c||e[6]!==r||e[7]!==l||e[8]!==f||e[9]!==s||e[10]!==u.expandAll||e[11]!==u.pendingDirName?(p=f?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(obe,{headerAccessory:i,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:m?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>c(!0),expandAll:u.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(Tm,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:l,onMobileSearchClose:()=>c(!1)})]}):u.pendingDirName?a.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?a.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[a.jsx(t7,{projectPath:s.pendingPath??null,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:d.defaultAgentKind}}),xt("terminal")&&a.jsxs(Q,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(_a,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(bf,{navigation:t}),e[0]=o,e[1]=d,e[2]=i,e[3]=m,e[4]=t,e[5]=c,e[6]=r,e[7]=l,e[8]=f,e[9]=s,e[10]=u.expandAll,e[11]=u.pendingDirName,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==s||e[15]!==u.pendingDirName?(h=(f||u.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,f?s.activeComposer:s.pendingComposer]}),e[13]=f,e[14]=s,e[15]=u.pendingDirName,e[16]=h):h=e[16];let g;e[17]!==o.processPanel||e[18]!==h?(g=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,h]}),e[17]=o.processPanel,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function bbe(n){const e=V.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=Sn(),{session:d}=jt();let f;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==r||e[7]!==d||e[8]!==t?(f=a.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(Tm,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(Im,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(Ln,{className:"max-w-md",children:a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:s?a.jsx(Sr,{}):a.jsx(St,{className:"animate-spin"})}),a.jsx(zn,{children:s?"Unable to open session":"Opening session"}),a.jsx(Dn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=o,e[1]=i,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=r,e[7]=d,e[8]=t,e[9]=f):f=e[9],f}function vbe(){let n=ui;const e=new Set;return{snapshot:()=>n,subscribe(t){return e.add(t),()=>{e.delete(t)}},publish(t){if(t!==n){n=t;for(const s of e)s()}}}}const ybe=5;function v7(){const n=cn(),e=Zn();return e===null?n:`${n}:${e}`}function Zu(n,e){return`${v7()}:${n}/${e}`}class wbe{constructor(){Ge(this,"cache",new Map)}get(e,t){const s=Zu(e,t),r=this.cache.get(s);return r&&(r.lastAccessed=Date.now()),r}set(e,t,s,r,o,i,l,c){const u=Zu(e,t);!this.cache.has(u)&&this.cache.size>=ybe&&this.evictLRU(),this.cache.set(u,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:r,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:o,hasMore:i,lastAccessed:Date.now()})}update(e,t,s){const r=Zu(e,t),o=this.cache.get(r);o&&(s.parsed!==void 0&&(o.parsed=s.parsed),s.olderTurns!==void 0&&(o.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(o.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(o.hasMore=s.hasMore),s.lastAccessed!==void 0&&(o.lastAccessed=s.lastAccessed),s.source&&(o.source={...o.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(Zu(e,t)):this.evictLRU()}evictSession(e){const t=`${v7()}:`;for(const[s,{source:r}]of this.cache)s.startsWith(t)&&Nx(r.dirName,r.fileName)===e&&this.cache.delete(s)}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,r]of this.cache)r.lastAccessed<t&&(t=r.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const js=new wbe,Bj={},Sbe=1e4;function y7(n,e,t,s,r,o){const[i,l]=y.useState(!1),[c,u]=y.useState("disconnected"),[d,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(Bj),[x,b]=y.useState(null),[w,v]=y.useState(null),[j]=y.useState(vbe),k=y.useRef(""),_=y.useRef(null),N=y.useRef(ui),S=y.useRef("disconnected"),C=y.useRef(e);C.current=e;const E=y.useRef(r);E.current=r;const T=y.useRef(t);T.current=t;const $=y.useRef(s);$.current=s;const A=y.useRef(o??null);A.current=o??null;const R=y.useRef(!1),P=y.useRef(0),z=(n==null?void 0:n.dirName)??null,L=(n==null?void 0:n.fileName)??null,I=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode(I).byteLength;return y.useEffect(()=>{if(k.current=I,!I){_.current=null,l(!1);return}const F=A.current;if(F){_.current=F;return}T.current(I).then(U=>{_.current=oa(U,Xr(n==null?void 0:n.dirName).instanceId)})},[I,n==null?void 0:n.dirName]),y.useEffect(()=>{if(b(null),v(null),!z||!L){l(!1),u("disconnected");return}u("connecting");const F=`/api/watch/${encodeURIComponent(z)}/${encodeURIComponent(L)}?offset=${M}`,U=nb(F),O=U.source;let D=null;const B=(ce=3e4)=>{D&&clearTimeout(D),D=setTimeout(()=>{l(!1),f(!1)},ce)};let q="",W=M,H=!1,K=!1,Z=!1,Y=null;const J=()=>{Z=!1,Y=null,_.current&&C.current(_.current)},ee=()=>{Z||(Z=!0,Y=requestAnimationFrame(J))};let te=!1,se=null,X=null;const ne=()=>{te=!1,se=null,j.publish(N.current)},ae=()=>{te||(te=!0,se=requestAnimationFrame(ne))},ie=ce=>{ce!==N.current&&(N.current=ce,ae(),ce.length>0&&!X&&(X=setInterval(()=>{const oe=Ele(N.current);oe!==N.current&&(N.current=oe,ae()),N.current.length===0&&X&&(clearInterval(X),X=null)},5e3)))},re=()=>{ie(ui),g(Bj)},de=()=>{if(K||H||!q)return;const ce=q;q="",H=!0;const oe=_.current,fe=oe?$.current(oe,ce):T.current(k.current);let ue=!1;fe.then(le=>{const pe=oa(le,Xr(z).instanceId);K||(_.current=pe,z&&L&&js.update(z,L,{parsed:pe,source:{rawText:k.current,watchOffset:W}}),ee())},le=>{if(console.error("[useLiveSession] worker parse failed:",le),K)return;ue=!0,q=ce+q;const pe=Date.now();E.current&&pe-P.current>=Sbe&&(P.current=pe,E.current())}).catch(le=>{console.error("[useLiveSession] live update failed:",le)}).finally(()=>{H=!1,!K&&!ue&&q&&de()})};return O.onopen=()=>{var ce;if(S.current!=="connected"){const oe=R.current;R.current=!1,S.current="connected",u("connected"),oe&&((ce=E.current)==null||ce.call(E))}},O.onmessage=ce=>{try{S.current!=="connected"&&(S.current="connected",u("connected"));const oe=JSON.parse(ce.data);if(oe.type==="init")oe.recentlyActive?(l(!0),B(5e3)):B();else if(oe.type==="compacting")oe.active&&(l(!0),re(),B()),f(oe.active===!0);else if(oe.type==="subagent_activity")l(!0),B();else if(oe.type==="runtime_activity")l(!0),B();else if(oe.type==="stream_snapshot")l(!0),B(),ie(Nle(oe.messages??[]));else if(oe.type==="stream_delta")l(!0),B(),p(null),b(null),v(null),ie(Cle(N.current,oe.events??[]));else if(oe.type==="rate_limit")v(oe.block??null);else if(oe.type==="agent_progress")l(!0),B(),g(fe=>({...fe,[oe.toolUseId]:oe.summary}));else if(oe.type==="prompt_suggestion")b(typeof oe.suggestion=="string"?oe.suggestion:null);else if(oe.type==="turn_error")p(typeof oe.message=="string"?oe.message:"The turn failed");else if(oe.type==="stream_clear")re(),f(!1);else if(oe.type==="lines"){if(typeof oe.skippedBytes=="number"&&(W+=oe.skippedBytes),oe.lines.length===0)return;l(!0),f(!1),B(),ie(_le(N.current,oe.lines));const fe=oe.lines.join(`
|
|
483
483
|
`)+`
|
|
484
484
|
`;W+=new TextEncoder().encode(fe).byteLength,k.current+=fe,q+=fe,de()}}catch(oe){console.error("[useLiveSession] Error processing SSE message:",oe)}},O.onerror=()=>{l(!1),f(!1),R.current=S.current==="connected",S.current="disconnected",u("disconnected"),re()},()=>{K=!0,U.close(),l(!1),S.current="disconnected",u("disconnected"),D&&clearTimeout(D),Y!==null&&cancelAnimationFrame(Y),se!==null&&cancelAnimationFrame(se),X&&clearInterval(X),N.current=ui,j.publish(ui)}},[z,L,I,M,j]),{isLive:i,sseState:c,isCompacting:d,streamingOverlayStore:j,turnError:m,agentProgress:h,promptSuggestion:x,rateLimit:w}}const kbe=3e4;function w7(n,e,t){const s=V.c(12);let r;s[0]!==t?(r=t===void 0?{}:t,s[0]=t,s[1]=r):r=s[1];const{onLost:o,staleAfterMs:i}=r,l=i===void 0?kbe:i,[c,u]=y.useState(!1),d=y.useRef(e),f=y.useRef(o);let m,p;s[2]!==o||s[3]!==e?(m=()=>{d.current=e,f.current=o},p=[e,o],s[2]=o,s[3]=e,s[4]=m,s[5]=p):(m=s[4],p=s[5]),y.useEffect(m,p);let h,g;s[6]!==l||s[7]!==n?(h=()=>{if(!n){u(!1);return}let b=!0,w=null;const v=nb(n,{onLost:()=>{var _;return(_=f.current)==null?void 0:_.call(f)}}),j=v.source;u(!1);const k=()=>{w&&clearTimeout(w),w=setTimeout(()=>{b&&u(!1)},l)};return j.onmessage=_=>{if(b)try{const N=JSON.parse(_.data);N.type==="init"?k():N.type==="update"&&(u(!0),k(),d.current())}catch{}},j.onerror=()=>{b&&u(!1)},()=>{b=!1,v.close(),w&&clearTimeout(w)}},g=[n,l],s[6]=l,s[7]=n,s[8]=h,s[9]=g):(h=s[8],g=s[9]),y.useEffect(h,g);let x;return s[10]!==c?(x={isLive:c},s[10]=c,s[11]=x):x=s[11],x}function jbe(n,e,t){const s=V.c(2),r=n?`/api/team-watch/${encodeURIComponent(n)}`:null;let o;return s[0]!==t?(o={onLost:t},s[0]=t,s[1]=o):o=s[1],w7(r,e,o)}function Nbe(n,e){const[t,s]=y.useState(null),r=y.useRef(null),o=(()=>{if(!n)return null;let c,u=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(c=d[1],u=d[2]):c=n.replace(".jsonl","");const f=new URLSearchParams({leadSessionId:c});return u&&f.set("subagentFile",u),e&&f.set("dirName",e),f.toString()})();r.current=o;const i=y.useCallback(async()=>{const c=r.current;if(c)try{const u=await Ce(`/api/session-team?${c}`);if(!u.ok){s(null);return}const d=await u.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);y.useEffect(()=>{if(!n){s(null);return}i()},[n,i]);const l=y.useCallback(()=>s(null),[]);return jbe((t==null?void 0:t.teamName)??null,i,l),t}function Cbe(n,e,t,s){let r=null;return n&&e&&(r=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(r=r+`/${encodeURIComponent(t)}`)),w7(r,s)}function _be(n,e,t=!0){const[s,r]=y.useState([]),[o,i]=y.useState(!1),l=y.useRef(0),c=!!n&&!!e,u=y.useCallback(async()=>{const m=++l.current;if(!c){r([]);return}try{const p=await Ce(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&r([]);return}const h=await p.json();m===l.current&&r(Array.isArray(h)?h:[])}catch{m===l.current&&r([])}finally{m===l.current&&i(!1)}},[c,n,e]);y.useEffect(()=>{if(!c){r([]),i(!1);return}i(!0),u()},[c,u]);const d=c&&(t||s.length>0),{isLive:f}=Cbe(d?n:null,d?e:null,null,u);return{workflows:s,loading:o,isLive:f,refetch:u}}function Ebe(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 K1(n,e){const t=await n.json().catch(()=>({}));return{message:typeof t.error=="string"&&t.error?t.error:e,code:typeof t.code=="string"?t.code:null}}async function Wj(n){if(n.status!==202)return null;const e=await n.clone().json().catch(()=>null);return(e==null?void 0:e.receipt)??null}async function S7(n,e){const{model:t,agentKind:s,errorFallback:r,onModelRejected:o}=e,i=m=>typeof r=="function"?r(m):r;let c=await n(s==="copilot"?t||"auto":t||void 0),u=c.ok?null:await K1(c,i(c)),d=!1,f=await Wj(c);return f&&s==="codex"&&t&&(d=!0,Tbe(f,n,e)),!c.ok&&s==="codex"&&t&&Ebe(u==null?void 0:u.message)&&(o==null||o(t),c=await n(void 0),u=c.ok?null:await K1(c,i(c)),f=await Wj(c)),{res:c,errorMessage:(u==null?void 0:u.message)??null,errorCode:(u==null?void 0:u.code)??null,observingReceipt:d,receipt:f}}function Tbe(n,e,t){var u;const s=If(n.sessionId);let r=!1,o=()=>{};const i=()=>{var d,f;r||(r=!0,clearTimeout(l),o(),(d=t.signal)==null||d.removeEventListener("abort",i),(f=t.onReceiptSettled)==null||f.call(t))},l=setTimeout(i,1440*60*1e3),c=()=>{var m,p,h;if(r)return;const d=s.snapshot();if((m=t.signal)!=null&&m.aborted||d.error==="Account or device changed"||/Queue unavailable \((401|403|404)\)/.test(d.error??"")){i();return}if(d.freshness!=="current")return;const f=d.commands.find(g=>g.id===n.id);!f||!["failed","completed","cancelled","unknown"].includes(f.state)||(i(),!(f.state!=="failed"||f.errorCode!=="MODEL_REJECTED"||f.delivery||f.turnId||((p=d.conversation)==null?void 0:p.revision)!==n.bindingRevision||d.conversation.binding.sessionId!==n.sessionId)&&((h=t.onModelRejected)==null||h.call(t,t.model),e(void 0).then(async g=>{var x;g.ok||(x=t.onDeliveryError)==null||x.call(t,(await K1(g,"The default model could not accept the message")).message)}).catch(g=>{var x;(x=t.onDeliveryError)==null||x.call(t,g instanceof Error?g.message:"Fallback delivery could not be confirmed")})))};o=s.subscribe(c),(u=t.signal)==null||u.addEventListener("abort",i,{once:!0}),c()}const Abe=[];function Ibe({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:r,model:o,effort:i,contextWindowTokens:l,fastMode:c,ultracode:u,settingsChange:d=Abe,onSettingsChangeSent:f,mcpConfig:m,onModelRejected:p,readOnly:h=!1,onCreateSession:g}){const[x,b]=y.useState("idle"),[w,v]=y.useState(),[j,k]=y.useState([]),_=y.useRef(null),N=y.useRef(new Set),S=y.useRef(null),C=y.useRef(!1),E=n!=null&&n.fileName?Ed(n.fileName):null,T=e||E,$=n?un(n.dirName):null,A=y.useCallback(()=>{var F;for(const U of N.current)U.abort();N.current.clear(),(F=_.current)==null||F.abort(),_.current=null,C.current=!1,b("idle"),v(void 0),k([])},[]);y.useEffect(()=>{var F;S.current!==T&&(C.current?(C.current=!1,(F=_.current)==null||F.abort(),_.current=null,b("idle"),v(void 0)):A(),S.current=T)},[T,A]),y.useEffect(()=>{const F=N.current;return()=>{var U;for(const O of F)O.abort();(U=_.current)==null||U.abort()}},[]),y.useEffect(()=>{h&&A()},[h,A]);const R=y.useCallback(async(F,U)=>{if(h)return!1;if(!T&&g){k(D=>[...D,F]),b("connected"),v(void 0),C.current=!0,r==null||r();try{if(!await g(F,U))return C.current=!1,b("idle"),k([]),!0;b("idle")}catch(D){C.current=!1,v(D instanceof Error?D.message:"Failed to create session"),b("error"),k([])}return!0}if(!T)return!0;k(D=>[...D,F]),b("connected"),v(void 0),r==null||r();const O=new AbortController;N.current.add(O),_.current=O;try{const D={sessionId:T,message:F,images:U||void 0,cwd:t||void 0,permissions:s,effort:i||void 0,contextWindowTokens:l,fastMode:c||d.includes("fastMode")?c:void 0,ultracode:u||d.includes("ultracode")?u:void 0,mcpConfig:m||void 0,settingsChange:d.length>0?d:void 0},{res:B,errorMessage:q,observingReceipt:W,receipt:H}=await S7(K=>ZE("/api/send-message",{...D,model:K},O.signal),{model:o,agentKind:$,errorFallback:K=>`Request failed (${K.status})`,onModelRejected:p,signal:O.signal,onReceiptSettled:()=>N.current.delete(O),onDeliveryError:K=>{_.current===O&&(v(K),b("error"))}});return W||N.current.delete(O),H&&zR(H)&&k(K=>{const Z=K.lastIndexOf(F);return Z<0?K:K.filter((Y,J)=>J!==Z)}),_.current===O&&(B.ok?b("idle"):(v(q||`Request failed (${B.status})`),b("error"),k(K=>K.slice(0,-1)))),B.ok&&d.length>0&&(f==null||f()),B.ok&&!kR(B)}catch(D){return N.current.delete(O),D instanceof Error&&D.name==="AbortError"?!0:(_.current===O&&(v(D instanceof Error?D.message:"Unknown error"),b("error"),k(B=>B.slice(0,-1))),!1)}},[T,$,t,s,r,o,i,l,c,u,d,f,m,p,h,g]),P=y.useCallback(()=>{A()},[A]),z=y.useCallback(()=>{!T||h||Ce("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:T})}).catch(()=>{})},[T,h]),L=y.useCallback(()=>{var F;(F=_.current)==null||F.abort(),_.current=null,z(),b("idle"),k([])},[z]),I=L,M=y.useCallback((F=1)=>{k(U=>U.slice(F))},[]);return{status:x,error:w,pendingMessages:j,sendMessage:R,disconnect:P,interrupt:L,stopAgent:I,consumePending:M,isConnected:x==="connected"}}const Wi={expandAll:!1,expandToolPayloads:!1},Pbe={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Wi,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",extensionViewId:null,configFilePath:null,mobileTab:"sessions",dashboardProject:null};function qj(n,e,t,s){const r=xI(e,t,s);return r===n.turns?n:{...n,turns:r}}function Yu(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function $be(n,e){var t,s;switch(e.type){case"LOAD_SESSION":case"FINALIZE_SESSION":case"INIT_PENDING_SESSION":{const r=e.type==="INIT_PENDING_SESSION";return{...n,...Yu(r?null:e.session),sessionSource:r?null:e.source,pendingDirName:r?e.dirName:null,pendingCwd:r?e.cwd??null:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Wi,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab}}case"GO_HOME":case"CLOSE_SESSION":{const r=e.type==="GO_HOME";return{...n,...Yu(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Wi,mainView:r?"sessions":n.mainView,currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile&&(r||n.mobileTab==="chat")?"sessions":n.mobileTab}}case"SWITCH_TEAM_MEMBER":return{...n,...Yu(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...Wi,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,...Wi};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,...Wi}:{...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:qj(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:qj(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...Yu(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 r=n.mobileTab;return!e.hasSession&&r==="chat"&&(r="sessions"),r!==n.mobileTab?{...n,mobileTab:r}: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"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"};case"OPEN_EXTENSION_VIEW":return{...n,mainView:"extension",extensionViewId:e.id};case"CLOSE_EXTENSION_VIEW":return{...n,mainView:"sessions",extensionViewId:null};default:return n}}function k7(){return y.useReducer($be,Pbe)}function Vj(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function j7({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:r}){const o=y.useRef(null),i=y.useRef(!0),l=y.useRef(!1),c=y.useRef(0),u=y.useRef(!1),d=y.useRef(!1),f=y.useRef(0),m=y.useRef(0),p=y.useRef(0),h=y.useMemo(()=>(n==null?void 0:n.turns.flatMap(O=>O.contentBlocks.flatMap(D=>D.kind==="queued_prompt"?[{id:JSON.stringify([D.timestamp??"",D.content]),content:D.content}]:[])))??[],[n==null?void 0:n.turns]),g=y.useRef(null),x=y.useRef(!1),[b,w]=y.useState(!1),[v,j]=y.useState(null),k=y.useCallback(()=>{c.current++,u.current=!1,i.current=!1,l.current=!1},[]),_=y.useCallback(()=>{i.current=!0;const O=c.current;requestAnimationFrame(()=>{if(O!==c.current||!i.current)return;const D=o.current;D&&(D.scrollTop=D.scrollHeight,f.current=D.scrollTop,m.current=D.scrollHeight)})},[]),N=y.useCallback(()=>{const O=++c.current;i.current=!0,l.current=!1,Vj(()=>{if(O!==c.current)return;const D=o.current;D&&(D.scrollTop=D.scrollHeight,f.current=D.scrollTop,m.current=D.scrollHeight)})},[]),S=y.useCallback(()=>{x.current=!0},[]),C=y.useRef(!1),E=y.useCallback(()=>{const O=o.current;if(!O)return;const D=O.scrollHeight-O.scrollTop-O.clientHeight>10;D!==C.current&&(C.current=D,w(D))},[]),[T,$]=y.useState(null);y.useEffect(()=>{if(!T)return;let O=0;const D=new ResizeObserver(()=>{cancelAnimationFrame(O),O=requestAnimationFrame(()=>{const B=o.current;B&&i.current&&(B.scrollTop=B.scrollHeight,f.current=B.scrollTop,m.current=B.scrollHeight),E()})});return D.observe(T,{box:"border-box"}),()=>{D.disconnect(),cancelAnimationFrame(O)}},[T,E]);const A=y.useCallback(()=>{const O=o.current;if(!O)return;const D=O.scrollHeight-O.scrollTop-O.clientHeight;D>2&&(m.current===0||O.scrollHeight===m.current&&O.scrollTop<f.current)?k():D<=2&&(u.current||d.current&&O.scrollTop>f.current)&&(i.current=!0,u.current=!1),f.current=O.scrollTop,m.current=O.scrollHeight,E()},[k,E]);y.useEffect(()=>{const O=o.current;if(!T||!O)return;let D=0;const B=()=>{u.current=!0,O.scrollHeight-O.scrollTop-O.clientHeight<=2&&(i.current=!0,u.current=!1)},q=J=>{J.deltaY<0?k():J.deltaY>0&&B()},W=()=>{d.current=!0},H=()=>{d.current=!1},K=J=>{var ee;D=((ee=J.touches[0])==null?void 0:ee.clientY)??0},Z=J=>{var te;const ee=((te=J.touches[0])==null?void 0:te.clientY)??D;ee>D?k():ee<D&&B(),D=ee},Y=J=>{J.target instanceof Element&&J.target.closest("input, textarea, select, [contenteditable=true]")||(["ArrowUp","PageUp","Home"].includes(J.key)||J.key===" "&&J.shiftKey?k():["ArrowDown","PageDown","End"," "].includes(J.key)&&B())};return O.addEventListener("wheel",q,{passive:!0}),O.addEventListener("touchstart",K,{passive:!0}),O.addEventListener("touchmove",Z,{passive:!0}),O.addEventListener("keydown",Y),O.addEventListener("pointerdown",W),document.addEventListener("pointerup",H),()=>{O.removeEventListener("wheel",q),O.removeEventListener("touchstart",K),O.removeEventListener("touchmove",Z),O.removeEventListener("keydown",Y),O.removeEventListener("pointerdown",W),document.removeEventListener("pointerup",H)}},[T,k]);const R=y.useCallback(O=>{p.current=O},[]),P=y.useRef(r);y.useEffect(()=>{if(r===P.current)return;P.current=r;const O=x.current;x.current=!1;const D=++c.current,B=()=>{if(D!==c.current)return;const W=o.current;W&&(O?(W.scrollTop=0,i.current=!1):(W.scrollTop=W.scrollHeight,i.current=!0),f.current=W.scrollTop,m.current=W.scrollHeight,l.current=!1)};Vj(B);const q=setTimeout(()=>{B(),j(r)},150);return()=>clearTimeout(q)},[r]);const z=t.length;y.useEffect(()=>{z>0&&(l.current=!0,_())},[z,_]),y.useEffect(()=>{const O=(n==null?void 0:n.sessionId)??null,D=g.current,B=new Set(h.map(H=>H.id));if(!D||D.sessionId!==O){g.current={sessionId:O,ids:B};return}const q=h.filter(H=>!D.ids.has(H.id));if(g.current={sessionId:O,ids:B},q.length===0||z===0)return;let W=0;for(const H of q){const K=t[W];(K===H.content||(K==null?void 0:K.trim())===""&&H.content.length>0)&&W++}W>0&&s(W)},[n==null?void 0:n.sessionId,h,t,z,s]);const L=(n==null?void 0:n.turns.length)??0;y.useEffect(()=>{if(L===0)return;const O=L-p.current;O>0&&(z>0&&s(Math.min(O,z)),(l.current||i.current)&&(_(),l.current=!1)),p.current=L},[L,z,s,_]);const I=n==null?void 0:n.turns.at(-1),M=(I==null?void 0:I.toolCalls.length)??0,F=(I==null?void 0:I.assistantText.length)??0;y.useEffect(()=>{if(!n||!e)return;if(i.current){const D=o.current;D&&(D.scrollTop=D.scrollHeight,f.current=D.scrollTop,m.current=D.scrollHeight)}const O=requestAnimationFrame(E);return()=>cancelAnimationFrame(O)},[L,M,F,e,E]);const U=v===r;return y.useMemo(()=>({chatScrollRef:o,observeChatContent:$,canScrollDown:b,initialScrollDone:U,handleScroll:A,scrollToBottomInstant:N,requestScrollToTop:S,resetTurnCount:R}),[$,b,U,A,N,S,R])}async function N7(n,e,t,s,{background:r=!1}={}){const o=await Ce(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`,{background:r});if(!o.ok)throw new Error(`Failed to load ${s} (${o.status})`);const i=await o.json(),l=new Set(i.headerLines),c=i.tailLines.filter(f=>!l.has(f)),u=[...i.headerLines,...c].join(`
|
|
485
485
|
`);return{parsed:oa(await t(u),Xr(n).instanceId),source:{dirName:n,fileName:e,rawText:u,agentKind:un(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function ka(n,e,t,s,r={}){const o=js.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=cn(),l=Zn(),{parsed:c,source:u,byteOffset:d,hasMore:f}=await N7(n,e,t,s,r);if(cn()!==i||Zn()!==l)return{parsed:c,source:u};const m=js.get(n,e);return m?{parsed:m.parsed,source:m.source}:(js.set(n,e,c,u.rawText,d,f,u.agentKind,u.watchOffset),{parsed:c,source:u})}async function C7(n,e,t,s){js.evict(n,e);const r=cn(),o=Zn(),{parsed:i,source:l,byteOffset:c,hasMore:u}=await N7(n,e,t,s);return cn()===r&&Zn()===o&&js.set(n,e,i,l.rawText,c,u,l.agentKind,l.watchOffset),{parsed:i,source:l}}function Rbe({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:r,resetTurnCount:o,workerParse:i,onBeforeSwitch:l}){const[c,u]=y.useState(null),d=y.useCallback((w,v)=>{u(null),y.startTransition(()=>{n({type:"LOAD_SESSION",session:w,source:v,isMobile:e})}),o(w.turns.length),Hxe(w.sessionId,w.turns.length),r()},[n,e,o,r]),f=y.useCallback(async(w,v)=>{l==null||l(),u(null);try{const{parsed:j,source:k}=await ka(w,v,i,"session");d(j,k)}catch(j){u(j instanceof Error?j.message:"Failed to load session")}},[d,i,l]),m=y.useCallback(async w=>{if(s){l==null||l(),u(null),n({type:"SET_LOADING_MEMBER",name:w.name});try{const v=await Ce(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(w.name)}`);if(!v.ok)throw new Error(`Failed to find session for ${w.name}`);const{dirName:j,fileName:k}=await v.json(),{parsed:_,source:N}=await ka(j,k,i,`session for ${w.name}`);y.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:_,source:N,memberName:w.name})}),o(_.turns.length),r()}catch(v){u(v instanceof Error?v.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,o,r,i,l]),p=y.useCallback(()=>u(null),[]),h=y.useCallback(()=>{y.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=y.useCallback(()=>{y.startTransition(()=>{n({type:"CLOSE_SESSION",isMobile:e})})},[n,e]),x=y.useCallback((w,v)=>{n({type:"JUMP_TO_TURN",index:w,toolCallId:v})},[n]),b=y.useCallback(w=>{w!==t&&n({type:"SET_MOBILE_TAB",tab:w})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:d,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleCloseSession:g,handleJumpToTurn:x,handleMobileTabChange:b}}const Obe=/^\/preview\/([^/]+)\/?$/;function av(n){const e=Obe.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function G1(){const n=_x();return n?`${n}/`:"/"}function _7(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function Lbe(n,e){return uR(n,e)}function Mbe(n){const e=_x();return n.sessionSource?ha(n.sessionSource.dirName,n.sessionSource.fileName):n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:G1()}function Hj(n){const e=_7(n),t=av(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 zbe({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:r,workerParse:o}){const[i,l]=y.useState(null),c=y.useRef(0),u=y.useRef(window.location.pathname),d=y.useRef(!1),f=y.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await Ce(`/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 ka(h.dirName,h.fileName,o,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),r()}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=Lbe(m.dirName,m.sessionId);let h;try{h=await ka(m.dirName,p,o,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=G1();window.history.replaceState(null,"",g),u.current=g,Va(Kt(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),r()}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=G1();window.history.replaceState(null,"",p),u.current=p,Va(Kt(),p)}}finally{c.current--}},[e,t,s,r,o]);return y.useEffect(()=>{if(d.current)return;d.current=!0,Va(Kt(),window.location.pathname);const m=Hj(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),y.useEffect(()=>{if(c.current>0||av(_7(window.location.pathname)))return;const m=Mbe(n);m!==u.current&&(window.history.pushState(null,"",m),u.current=m,Va(Kt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),y.useEffect(()=>{const m=()=>{const p=Hj(window.location.pathname);u.current=window.location.pathname,Va(Kt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:i}}const Dbe=400;function Kj(){return Array.from(document.querySelectorAll("[data-live-session]"))}function Fbe(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 Gj(n){n.focus({preventScroll:!0});const e=Fbe(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 Ube(n){const e=V.c(20),{isMobile:t,searchInputRef:s,chatInputRef:r,dispatch:o,onToggleSidebar:i,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:u,onOpenProjectSwitcher:d,onOpenThemeSelector:f,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:b,onNavigateToSession:w,onCommitNavigation:v}=n;let j,k;e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==v||e[4]!==x||e[5]!==b||e[6]!==w||e[7]!==u||e[8]!==d||e[9]!==m||e[10]!==f||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==i||e[17]!==s?(j=()=>{if(t)return;let _=!1,N=!1,S=null;const C=function(A){var L,I;const R=nj("missionControl");if(R){if(A.key===R){A.repeat||(_=!0,N=A.shiftKey||A.altKey||(R==="Meta"?A.ctrlKey:A.metaKey));return}_&&(N=!0),S=null}if(on("commandPalette",A)){A.preventDefault(),u==null||u();return}if(on("integratedTerminal",A)){if(!xt("terminal"))return;A.preventDefault(),p();return}if(on("preview",A)){A.preventDefault(),h();return}if(on("projectFiles",A)){if(!xt("hostFiles"))return;A.preventDefault(),g();return}if(on("expandAll",A)){A.preventDefault(),o({type:"SET_EXPAND_ALL",value:!0});return}if(on("expandToolPayloads",A)){A.preventDefault(),o({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(on("toggleSidebar",A)){A.preventDefault(),i();return}if(on("toggleStats",A)){A.preventDefault(),l();return}if(on("missionControl",A)){A.preventDefault(),c();return}if(on("newSession",A)&&(A.preventDefault(),d()),on("themeSelector",A)&&(A.preventDefault(),f()),on("systemTerminal",A)){if(!xt("terminal"))return;A.preventDefault(),m()}if(A.key==="Escape"&&(o({type:"SET_SEARCH_QUERY",value:""}),(L=s.current)==null||L.blur()),(A.metaKey||A.ctrlKey)&&A.shiftKey&&A.code.startsWith("Digit")){const M=parseInt(A.code.charAt(5),10);if(M>=1&&M<=9){A.preventDefault();const U=Kj()[M-1];U&&(Gj(U),U.click())}}const P=on("recentSessionForward",A);if(P||on("recentSessionBack",A)){A.preventDefault();const M=P?b():x();M&&w(M.dirName,M.fileName)}on("focusComposer",A)&&!kI(document.activeElement)&&(A.preventDefault(),(I=r.current)==null||I.focus());const z=on("nextLiveSession",A);if(z||on("prevLiveSession",A)){A.preventDefault();const M=Kj();if(M.length===0)return;const F=M.findIndex(Bbe);let U;F===-1?U=z?0:M.length-1:U=Math.max(0,Math.min(M.length-1,F+(z?1:-1))),Gj(M[U])}},E=function(A){const R=nj("missionControl");if(R&&A.key===R&&_){const P=!N;if(_=!1,N=!1,P){const z=Date.now();S!==null&&z-S<=Dbe?(S=null,A.preventDefault(),c()):S=z}else S=null}A.key==="Control"&&(v==null||v())},T=function(){_=!1,N=!1,S=null};return window.addEventListener("keydown",C),window.addEventListener("keyup",E),window.addEventListener("blur",T),()=>{window.removeEventListener("keydown",C),window.removeEventListener("keyup",E),window.removeEventListener("blur",T)}},k=[t,s,r,o,i,l,c,u,d,f,m,p,h,g,x,b,w,v],e[0]=r,e[1]=o,e[2]=t,e[3]=v,e[4]=x,e[5]=b,e[6]=w,e[7]=u,e[8]=d,e[9]=m,e[10]=f,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=i,e[17]=s,e[18]=j,e[19]=k):(j=e[18],k=e[19]),y.useEffect(j,k)}function Bbe(n){return n===document.activeElement}function E7(){const n=V.c(7),[e,t]=y.useState(XL),[s,r]=y.useState(null);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=f=>{JL(f),t(f),r(null)},n[0]=o):o=n[0];const i=o,l=s??e;let c,u;n[1]!==l?(c=()=>QL(l),u=[l],n[1]=l,n[2]=c,n[3]=u):(c=n[2],u=n[3]),y.useEffect(c,u);let d;return n[4]!==l||n[5]!==e?(d={theme:e,activeTheme:l,setTheme:i,setPreview:r},n[4]=l,n[5]=e,n[6]=d):d=n[6],d}const Wbe="cogpit-session-history",Z1=50;function T7(){return sn(Wbe)}function qbe(){try{const n=localStorage.getItem(T7());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,Z1)}catch{}return[]}function fg(n){try{localStorage.setItem(T7(),JSON.stringify(n))}catch{}}function Vbe(){const n=V.c(7);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=qbe(),n[0]=e):e=n[0];const t=y.useRef(e),s=y.useRef(0),r=y.useRef(!1);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=(x,b)=>{if(r.current){r.current=!1;return}const w=`${x}/${b}`;t.current=t.current.filter(v=>`${v.dirName}/${v.fileName}`!==w),t.current.unshift({dirName:x,fileName:b}),t.current.length>Z1&&(t.current.length=Z1),s.current=0,fg(t.current)},n[1]=o):o=n[1];const i=o;let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{if(t.current.length<=1)return null;const x=(s.current+1)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[2]=l):l=n[2];const c=l;let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(t.current.length<=1)return null;const x=(s.current-1+t.current.length)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[3]=u):u=n[3];const d=u;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(s.current===0){r.current=!1;return}const x=t.current[s.current];x&&(t.current.splice(s.current,1),t.current.unshift(x),fg(t.current)),s.current=0,r.current=!1},n[4]=f):f=n[4];const m=f;let p;n[5]===Symbol.for("react.memo_cache_sentinel")?(p=x=>{const b=t.current.filter(w=>Nx(w.dirName,w.fileName)!==x);b.length!==t.current.length&&(t.current=b,s.current=0,fg(b))},n[5]=p):p=n[5];const h=p;let g;return n[6]===Symbol.for("react.memo_cache_sentinel")?(g={push:i,goBack:c,goForward:d,commitNavigation:m,forget:h},n[6]=g):g=n[6],g}const Hbe="You no longer have access to this session",Kbe="You don't have access to this session";function Gbe(n){const e=V.c(7),{openSessionId:t,leave:s,forgetVisits:r}=n,{removeSession:o}=Kx();let i,l;e[0]!==r||e[1]!==s||e[2]!==t||e[3]!==o?(i=()=>{const u=function(p){js.evictSession(p),q9(p),fO(p),o(p),r(p),qN(),p===t&&s()},d=CR((m,p)=>{const h=lO(m)?Hbe:Kbe;u(m),!(p&&m!==t)&&ER(m).then(g=>{g||Kn.error(h,{id:`session-access-lost:${m}`})})}),f=TR(u);return()=>{d(),f()}},l=[t,s,r,o],e[0]=r,e[1]=s,e[2]=t,e[3]=o,e[4]=i,e[5]=l):(i=e[4],l=e[5]),y.useEffect(i,l);let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[6]=c):c=e[6],y.useEffect(Zbe,c)}function Zbe(){return uN(Ybe)}function Ybe(){return qN()}const Zj={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},Xbe="cogpit:permissions";function A7(){return sn(Xbe)}function Yj(){try{const n=localStorage.getItem(A7());if(n){const e=JSON.parse(n);return{mode:e.mode||Zj.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return Zj}function Jbe(n){localStorage.setItem(A7(),JSON.stringify(n))}function I7(n,e){const t=v5(n);return(t.find(s=>s.value===e)??t[0]).value}function Xj(n,e){return{...e,mode:I7(n,e.mode),...!bn(n).toolPermissionRules&&{allowedTools:[],disallowedTools:[]}}}function Qbe(n){const e=V.c(25),t=n===void 0?Wo:n,[s,r]=y.useState(Yj),[o,i]=y.useState(Yj);let l;e[0]!==t||e[1]!==s?(l=Xj(t,s),e[0]=t,e[1]=s,e[2]=l):l=e[2];const c=l;let u;e[3]!==t||e[4]!==o?(u=Xj(t,o),e[3]=t,e[4]=o,e[5]=u):u=e[5];const d=u,f=y.useRef(!0);let m,p;e[6]!==s?(m=()=>{if(f.current){f.current=!1;return}Jbe(s)},p=[s],e[6]=s,e[7]=m,e[8]=p):(m=e[7],p=e[8]),y.useEffect(m,p);let h;e[9]!==d.allowedTools||e[10]!==d.disallowedTools||e[11]!==d.mode||e[12]!==c.allowedTools||e[13]!==c.disallowedTools||e[14]!==c.mode?(h=c.mode!==d.mode||JSON.stringify(c.allowedTools)!==JSON.stringify(d.allowedTools)||JSON.stringify(c.disallowedTools)!==JSON.stringify(d.disallowedTools),e[9]=d.allowedTools,e[10]=d.disallowedTools,e[11]=d.mode,e[12]=c.allowedTools,e[13]=c.disallowedTools,e[14]=c.mode,e[15]=h):h=e[15];const g=h;let x;e[16]!==t?(x=k=>{r(_=>({..._,mode:I7(t,k)}))},e[16]=t,e[17]=x):x=e[17];const b=x;let w;e[18]!==c?(w=()=>{i(c)},e[18]=c,e[19]=w):w=e[19];const v=w;let j;return e[20]!==c||e[21]!==g||e[22]!==v||e[23]!==b?(j={config:c,hasPendingChanges:g,setMode:b,markApplied:v},e[20]=c,e[21]=g,e[22]=v,e[23]=b,e[24]=j):j=e[24],j}const eve=2e3;function tve(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function nve(n){const[e,t]=y.useState([]),[s,r]=y.useState(null),[o,i]=y.useState(new Set);y.useEffect(()=>{if(!n){t([]),r(null);return}let u=!1;const d=async()=>{if(!u)try{const h=await Ce(`/api/permissions/${encodeURIComponent(n)}`);if(u)return;if(h.ok){const g=await h.json();if(u)return;t(b=>tve(b,g.permissions)?b:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;r(b=>JSON.stringify(b)===JSON.stringify(x)?b:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&d()},m=()=>{document.visibilityState==="visible"&&d()};f();const p=setInterval(f,eve);return document.addEventListener("visibilitychange",m),()=>{u=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=y.useCallback(async(u,d)=>{if(n){i(f=>new Set(f).add(u));try{await RI(n,u,d)&&t(f=>f.filter(m=>m.requestId!==u))}finally{i(f=>{const m=new Set(f);return m.delete(u),m})}}},[n]),c=y.useCallback(async u=>{if(n)try{await xpe(n,u)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:o,respond:l,respondAll:c}}async function sve(n,e){const t=await is(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{eventId:e});return t.ok?await t.json():null}async function rve(n,e,t){const s=await is(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{eventId:e,mode:t}),r=await s.json().catch(()=>null);return!s.ok||(r==null?void 0:r.outcome)!=="success"?{ok:!1,error:(r==null?void 0:r.error)||`Copilot rewind failed${r!=null&&r.outcome?`: ${r.outcome}`:""}`}:{ok:!0}}function ove(n){return n.file_path??n.path??""}function P7(n){const e=[];for(const t of n.toolCalls){if(t.isError||t.awaitingReview||jde(t))continue;const s=ove(t.input);if(s){if(t.name==="Edit"){const r=t.input.old_string,o=t.input.new_string;r!==void 0&&o!==void 0&&e.push({type:"Edit",filePath:s,oldString:r,newString:o,replaceAll:t.input.replace_all??!1})}else if(t.name==="Write"){const r=t.input.content;r!==void 0&&e.push({type:"Write",filePath:s,content:r})}}}return e}function ive(n,e){return{index:e,id:n.id,userMessage:Da(n.userMessage),toolCalls:P7(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function vf(n,e,t){const s=[];for(let r=e;r>t;r--){const o=n[r];if(!o)continue;const i=P7(o);for(let l=i.length-1;l>=0;l--){const c=i[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:r}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:r}))}}return s}function ave(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 Bl(n,e){const t=[],s=e!==void 0?e+1:n.length;for(let r=0;r<s;r++){const o=n[r];o&&t.push(...ave(o.toolCalls,o.index))}return t}function $7(n,e,t,s,r){var c;const o=[];for(let u=e+1;u<n.length;u++){const d=n[u];d&&o.push(ive(d,u))}const i=((c=o[0])==null?void 0:c.userMessage)||"Untitled branch",l=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,...r!==void 0?{branchPointTurnId:r}:{},label:l,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}const lve=-2;function cve(n,e){const t=new Map(e.map((o,i)=>[o.id,i]));let s=!1;const r=n.map(o=>{const{branchPointTurnId:i}=o;if(i===void 0)return o;const l=i===null?-1:t.get(i)??lve;return l===o.branchPointTurnIndex?o:(s=!0,{...o,branchPointTurnIndex:l})});return s?r:n}function uve(n){return(n.childBranches??[]).map(e=>{if(typeof e.branchPointTurnId!="string")return e;const t=n.turns.findIndex(s=>s.id===e.branchPointTurnId);return t<0?e:{...e,branchPointTurnIndex:n.branchPointTurnIndex+1+t}})}function R7(n,e){const t=[],s=[];for(const r of n)r.branchPointTurnIndex>e?s.push(r):t.push(r);return{retained:t,scooped:s}}function dve(n,e,t){const s=e+t,r=[],o=[];for(const i of n)i.branchPointTurnIndex<=s?r.push(i):o.push(i);return{restored:r,remaining:o}}function fve(n){const e=new Set(n.map(t=>t.filePath));return{fileCount:e.size,filePaths:[...e],operationCount:n.length}}function mve(n){return{sessionId:n,branches:[],activeBranchId:null}}function Xu(n,e){return{...fve(n),turnCount:e}}function pve(n,e,t){return o6(n6(un(t)),n,e)}function hve(n,e,t,s,r,o){var c,u;const i=n6(un(o)),l=Fse(i,n);if(l){const d=e?l.findLastIndex(m=>m.id===e.id):-1;if(d>=0)return{cutoffLine:((c=l[d+1])==null?void 0:c.line)??n.length,branchPointTurnId:l[d].id};const f=t?l.findIndex(m=>m.id===t.id):-1;if(f>=0)return{cutoffLine:l[f].line,branchPointTurnId:((u=l[f-1])==null?void 0:u.id)??null}}return yb(i,n).length>r?null:{cutoffLine:o6(i,n,s),branchPointTurnId:void 0}}class Ki extends Error{constructor(){super("abort")}}const O7="Unable to locate the selected turn in the current session file";function L7(n,e,t,s,r){const o=hve(t,n.turns[s-1],n.turns[s],s,n.turns.length,e.dirName);if(!o)throw r(O7),new Ki;return o}async function gve(n,e,t,s,r,o,i){var v;const l=n.targetTurnIndex,c=vf(e.turns,e.turns.length-1,l),u=l+1,d=r.split(`
|
|
@@ -489,10 +489,10 @@ ${fe}
|
|
|
489
489
|
`).filter(Boolean).length},state:h})}const vve=[];function z7(n,e,t,s=!0){const[r,o]=y.useState(null),[i,l]=y.useState(null),[c,u]=y.useState(!1),[d,f]=y.useState(null),m=y.useRef(null),p=y.useRef(0);y.useEffect(()=>{if(p.current+=1,!s||!n){o(null),l(null),f(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!ia(e==null?void 0:e.dirName).redo){o(null);return}const A=n.sessionId,R=new AbortController;return Ce(`/api/undo-state/${encodeURIComponent(A)}`,{signal:R.signal}).then(P=>P.ok?P.json():null).then(P=>{m.current===A&&o(P??null)}).catch(P=>{P instanceof Error&&P.name==="AbortError"||m.current===A&&o(null)}),()=>R.abort()},[s,n==null?void 0:n.sessionId]);const h=y.useCallback(async A=>{try{const R=await Ce("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:A.operations,session:{dirName:A.sessionSource.dirName,fileName:A.sessionSource.fileName,mutation:A.sessionMutation},state:A.state,checkpoint:A.checkpoint})}),P=await R.json().catch(()=>null);if(!R.ok)throw f((P==null?void 0:P.error)||"Undo transaction failed"),new Ki;o(A.state)}catch(R){throw R instanceof Ki?R:(f(String(R)),new Ki)}},[]),g=(r==null?void 0:r.branches)??vve,x=n==null?void 0:n.turns,b=y.useMemo(()=>x?cve(g,x):g,[g,x]),{canRedo:w,redoTurnCount:v,redoBranch:j}=y.useMemo(()=>{if(!n||b.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let A=b.length-1;A>=0;A--){const R=b[A];if(R.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:R.turns.length,redoBranch:R}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,b]),k=y.useMemo(()=>{if(!j||j.jsonlLines.length===0)return[];try{return xm(j.jsonlLines.join(`
|
|
490
490
|
`)).turns}catch{return[]}},[j]),_=y.useCallback(A=>b.filter(R=>R.branchPointTurnIndex===A),[b]),N=y.useCallback(A=>{if(!s||!n)return;const R=A-1;if(R>=n.turns.length-1||R<-1)return;if(ia(e==null?void 0:e.dirName).nativeRewind){const z=n.turns[A];if(!z)return;const L=n.sessionId,I=++p.current,M=()=>p.current===I&&m.current===L,F=z.id.includes("@")?z.id.slice(z.id.lastIndexOf("@")+1):z.id,U=n.turns.length-A;sve(n.sessionId,F).then(O=>{var q;if(!M())return;const D=((q=O==null?void 0:O.files)==null?void 0:q.map(({path:W})=>W).filter(W=>typeof W=="string"))??[],B=O!=null&&O.available?O.fileCount??D.length:0;l({type:"undo",summary:{turnCount:U,fileCount:B,filePaths:D,operationCount:B},targetTurnIndex:R,nativeRewind:{eventId:F,mode:"conversation",filesAvailable:!!(O!=null&&O.available&&B>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:U,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:R,nativeRewind:{eventId:F,mode:"conversation"}})});return}const P=vf(n.turns,n.turns.length-1,R);l({type:"undo",summary:Xu(P,n.turns.length-1-R),targetTurnIndex:R})},[s,n,e==null?void 0:e.dirName]),S=y.useCallback(()=>{if(!s||!w||!j||!n)return;const A=Bl(j.turns);l({type:"redo",summary:Xu(A,j.turns.length),targetTurnIndex:j.branchPointTurnIndex+j.turns.length,branchId:j.id})},[s,w,j,n]),C=y.useCallback(A=>{if(!s||!w||!j||!n)return;const R=A+1,P=Bl(j.turns,A);l({type:"redo",summary:Xu(P,R),targetTurnIndex:j.branchPointTurnIndex+R,branchId:j.id,redoUpToArchiveIndex:A})},[s,w,j,n]),E=y.useCallback((A,R)=>{if(!s||!n)return;const P=b.find(M=>M.id===A);if(!P)return;const z=R??P.turns.length-1,L=n.turns.length>P.branchPointTurnIndex+1?vf(n.turns,n.turns.length-1,P.branchPointTurnIndex):[],I=Bl(P.turns,z);l({type:"branch-switch",summary:Xu([...L,...I],z+1),targetTurnIndex:P.branchPointTurnIndex,branchId:A,branchTurnIndex:z})},[s,n,b]),T=y.useCallback(async(A=!1)=>{if(!s||!i||!n||!e){l(null);return}u(!0),f(null);try{if(i.nativeRewind){const L=A&&i.nativeRewind.filesAvailable?"conversation-and-files":"conversation",I=await rve(n.sessionId,i.nativeRewind.eventId,L);if(!I.ok){f(I.error);return}await t(),l(null);return}const R={...r??mve(n.sessionId),branches:b},P=await Ce(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!P.ok){f("Failed to read session file");return}const z=await P.text();if(i.type==="undo")await gve(i,n,e,R,z,h,f);else if(i.type==="redo"){const L=b.find(I=>I.id===i.branchId);if(!L){l(null);return}await xve(i,e,R,L,z,h)}else if(i.type==="branch-switch"){const L=b.find(I=>I.id===i.branchId);if(!L){l(null);return}await bve(n,e,R,L,z,i,h,f)}try{await Ce("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(R){if(!(R instanceof Ki))throw R}finally{u(!1)}},[s,i,n,e,r,b,h,t]),$=y.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:r,canRedo:w,redoTurnCount:v,redoGhostTurns:k,branches:b,branchesAtTurn:_,requestUndo:N,requestRedoAll:S,requestRedoUpTo:C,requestBranchSwitch:E,confirmState:i,confirmApply:T,confirmCancel:$,isApplying:c,applyError:d}}async function yve(n){try{const t=await(await Ur("/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 wve(n){const e=await Ce("/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:lR(t==null?void 0:t.mode,Wo),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function Sve(){const n=V.c(26),[e,t]=y.useState(!0),[s,r]=y.useState(null),[o,i]=y.useState(null),[l,c]=y.useState(Wo),[u,d]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(!1),[g,x]=y.useState(0),b=y.useRef(null);let w;n[0]===Symbol.for("react.memo_cache_sentinel")?(w=D=>{i(D.claudeDir),c(D.defaultAgentKind),Zse(D.useBuiltInEditor)},n[0]=w):w=n[0];const v=w;let j;n[1]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{var q;(q=b.current)==null||q.abort();const D=new AbortController;b.current=D;const B=await yve(D.signal);D.signal.aborted||b.current!==D||(m(B.url),h(B.disabled))},n[1]=j):j=n[1];const k=j;let _,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(_=()=>()=>{var D;(D=b.current)==null||D.abort()},N=[],n[2]=_,n[3]=N):(_=n[2],N=n[3]),y.useEffect(_,N);let S;n[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{const D=new AbortController;return t(!0),r(null),wve(D.signal).then(v).catch(B=>{B instanceof Error&&B.name==="AbortError"||(i(null),r(B instanceof Error?B.message:"Failed to load configuration"))}).finally(()=>{D.signal.aborted||t(!1)}),()=>D.abort()},n[4]=S):S=n[4];let C;n[5]!==g?(C=[v,g],n[5]=g,n[6]=C):C=n[6],y.useEffect(S,C);let E,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const D=()=>x(Nve);return window.addEventListener("cogpit-auth-changed",D),()=>window.removeEventListener("cogpit-auth-changed",D)},T=[],n[7]=E,n[8]=T):(E=n[7],T=n[8]),y.useEffect(E,T);let $;n[9]===Symbol.for("react.memo_cache_sentinel")?($=()=>{k()},n[9]=$):$=n[9];let A;n[10]!==o?(A=[o,k],n[10]=o,n[11]=A):A=n[11],y.useEffect($,A);let R;n[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>d(!1),n[12]=R):R=n[12];const P=R;let z;n[13]!==o?(z=D=>{if(d(!1),D!==o){i(D),window.location.reload();return}x(jve),k()},n[13]=o,n[14]=z):z=n[14];const L=z;let I;n[15]===Symbol.for("react.memo_cache_sentinel")?(I=()=>d(!0),n[15]=I):I=n[15];const M=I;let F;n[16]===Symbol.for("react.memo_cache_sentinel")?(F=()=>x(kve),n[16]=F):F=n[16];const U=F;let O;return n[17]!==o||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==L||n[22]!==p||n[23]!==f||n[24]!==u?(O={configLoading:e,configError:s,claudeDir:o,defaultAgentKind:l,setClaudeDir:i,showConfigDialog:u,openConfigDialog:M,handleCloseConfigDialog:P,handleConfigSaved:L,retryConfig:U,networkUrl:f,networkAccessDisabled:p},n[17]=o,n[18]=s,n[19]=e,n[20]=l,n[21]=L,n[22]=p,n[23]=f,n[24]=u,n[25]=O):O=n[25],O}function kve(n){return n+1}function jve(n){return n+1}function Nve(n){return n+1}const Jj={authenticated:!0,edition:"personal",user:null,capabilities:Tx},yd={authenticated:!1,edition:null,user:null,capabilities:Ta,checked:!1},Cve=Object.keys(Tx);function Qj(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Cve.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function _ve(n,e){const t={};for(const[s,r]of Object.entries(e))t[s]=r===!0&&n[s]!==!1;return{...Ta,...t}}function Eve(n){const e=n==null?void 0:n.capabilities;return!n||!e||typeof e.browser=="boolean"?n:{...n,capabilities:{...e,browser:e.hostFiles===!0}}}async function e4(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?Eve(await t.json()):null}catch{return null}}async function Tve(n){try{const e=await Ce("/api/hello",{signal:n});if(!e.ok)return null;const t=await e.json();return nN(t.edition)?t.edition:"personal"}catch{return null}}function Di(n,e){return Cl(n,e),mR((e==null?void 0:e.id)??null),n?{...n,checked:!0}:yd}function Ave(n){const e=V.c(11),[t,s]=y.useState(yd),[r,o]=y.useState(0),i=y.useRef(null),l=y.useRef(!1);let c;e[0]!==n?(c=()=>{var N;if((N=i.current)==null||N.abort(),n===null){l.current=!1,Cl(null),s(yd);return}const b=l.current;l.current=!1,Cl(null),s(S=>b?{...S,capabilities:Ta,checked:!1}:yd);const w=new AbortController;i.current=w;const v=qo(),j=e4(Ur,w.signal),k=v?Tve(w.signal):Promise.resolve(n),_=v?e4(Ce,w.signal):Promise.resolve(null);return Promise.all([j,k,_]).then(S=>{const[C,E,T]=S;if(w.signal.aborted)return;const $=Qj(C,n)?C:n==="personal"?Jj:null;if(v&&($!=null&&$.gate)){Xs(Ot);return}if(!$||E===null){s(Di(null,null));return}if(!v){s(Di($,$.user));return}const A=Qj(T,E)?T:E==="personal"?Jj:null;if(!A){s(Di(null,null));return}s(Di({authenticated:A.authenticated,edition:A.edition,user:A.user,capabilities:_ve($.capabilities,A.capabilities),...A.enforcesSessionAccess&&{enforcesSessionAccess:!0},...A.gate&&{gate:A.gate}},$.user))}).catch(()=>{w.signal.aborted||s(Di(null,null))}),()=>{w.abort(),i.current===w&&(i.current=null)}},e[0]=n,e[1]=c):c=e[1];let u;e[2]!==n||e[3]!==r?(u=[n,r],e[2]=n,e[3]=r,e[4]=u):u=e[4],y.useEffect(c,u);let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{var b;(b=i.current)==null||b.abort(),l.current=!0,Cl(null),s($ve),o(Pve)},e[5]=d):d=e[5];const f=d;let m,p;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const b=()=>{var v;(v=i.current)==null||v.abort(),l.current=!1,s(Di(null,null)),o(Ive)},w=v=>{var _;const j=Kt();if(j===Ot)return;const k=(_=v.detail)==null?void 0:_.deviceId;k&&k!==j||f()};return window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-devices-changed",w),()=>{window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-devices-changed",w)}},p=[f],e[6]=m,e[7]=p):(m=e[6],p=e[7]),y.useEffect(m,p);const h=t.checked&&!t.gate;let g,x;return e[8]!==h?(g=()=>{if(h)return bR(f)},x=[h,f],e[8]=h,e[9]=g,e[10]=x):(g=e[9],x=e[10]),y.useEffect(g,x),t}function Ive(n){return n+1}function Pve(n){return n+1}function $ve(n){return{...n,capabilities:Ta,checked:!1}}const Rve=3e4;function Ove(n){const[e,t]=y.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=y.useRef(0),r=y.useCallback(async()=>{if(!n)return;const i=++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 Ce(`/api/worktrees/${encodeURIComponent(n)}`);if(i!==s.current)return;if(l.ok){const c=await l.json();if(i!==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(i!==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}r();const i=setInterval(()=>void r(),Rve);return()=>{clearInterval(i),s.current+=1}},[n,r]);const o=e.dirName===n?e:{worktrees:[],loading:n!==null,error:null};return{worktrees:o.worktrees,loading:o.loading,error:o.error,refetch:r}}function Lve(){const n=V.c(3),[e,t]=y.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await Ce("/api/kill-all",{method:"POST"})}catch{}setTimeout(()=>t(!1),1500)},n[0]=s):s=n[0];const r=s;let o;return n[1]!==e?(o={killing:e,handleKillAll:r},n[1]=e,n[2]=o):o=n[2],o}function Mve(n,e){return n?`${n}.jsonl`:e??null}async function D7(n){await U7(n);try{const e=await Ce(`/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 zve=300,Wl=new Map,Sl=new Map;function Dve(n,e,t){const s=(Sl.get(n)??Promise.resolve(!0)).then(async()=>{try{return(await is(`/api/session-config/${encodeURIComponent(e)}`,t,{method:"PUT"})).ok}catch{return!1}});return Sl.set(n,s),s.then(()=>{Sl.get(n)===s&&Sl.delete(n)}),s}function Fve(){let n;return{stored:new Promise(t=>{n=t}),answer:n}}function F7(n,e,t){clearTimeout(t.timer),Wl.delete(n);const s=Dve(n,e,t.patch);return s.then(t.answer),s}async function U7(n){const e=sn(n),t=Wl.get(e);await(t?F7(e,n,t):Sl.get(e))}function Y1(n,e){const t=sn(n),s=Wl.get(t);s&&clearTimeout(s.timer);const{stored:r,answer:o}=s??Fve(),i={patch:s?{...s.patch,...e}:e,stored:r,answer:o,timer:setTimeout(()=>{sn(n)===t?F7(t,n,i):(Wl.delete(t),i.answer(!1))},zve)};return Wl.set(t,i),r}function X1(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function t4(n){const e=await D7(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function mg(n,e){Y1(n,{mcpServers:e})}async function Uve(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function n4(n,e){try{const t=await Ce(n,{signal:e});if(e.aborted)return null;const s=await Uve(t);return e.aborted?null:s}catch{return null}}async function s4(n,e,t){const s=X1(t);if(s.size===0)return[];if(n){const r=await t4(n);if(r)return r.filter(o=>s.has(o))}if(e&&n!==e){const r=await t4(e);if(r)return r.filter(o=>s.has(o))}return[...s]}function Bve(n,e,t,s=!0){const[r,o]=y.useState([]),[i,l]=y.useState({}),[c,u]=y.useState([]),[d,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,b=y.useRef(x);b.current=x;const w=y.useRef(void 0);y.useEffect(()=>{var S,C;if(!s||!n){(S=h.current)==null||S.abort(),w.current=void 0,o([]),l({}),u([]),f(!1),p(!1);return}const N=new AbortController;return(C=h.current)==null||C.abort(),o([]),l({}),u([]),f(!0),p(!1),w.current=n,n4(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,N.signal).then(async E=>{if(N.signal.aborted||w.current!==n||!E)return;o(E.servers),l(E.configs);const T=await s4(b.current,g.current,E.servers);N.signal.aborted||w.current!==n||u(T)}).finally(()=>{N.signal.aborted||w.current!==n||(f(!1),p(!0))}),()=>N.abort()},[n,s]),y.useEffect(()=>()=>{var N;return(N=h.current)==null?void 0:N.abort()},[]),y.useEffect(()=>{if(r.length===0||!x)return;let N=!1;return s4(x,e,r).then(S=>{N||b.current!==x||u(S)}),()=>{N=!0}},[x]);const v=y.useCallback(N=>{u(S=>{const C=S.includes(N)?S.filter(E=>E!==N):[...S,N];return b.current&&mg(b.current,C),C})},[]),j=y.useCallback(N=>{u(()=>(b.current&&mg(b.current,N),N))},[]),k=y.useCallback(()=>{var S;if(!s||!n)return;(S=h.current)==null||S.abort();const N=new AbortController;h.current=N,f(!0),n4(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,N.signal).then(C=>{if(N.signal.aborted||w.current!==n||!C)return;o(C.servers),l(C.configs);const E=X1(C.servers);u(T=>{const $=T.filter(A=>E.has(A));return b.current&&mg(b.current,$),$})}).finally(()=>{N.signal.aborted||h.current!==N||f(!1)})},[n,s]),_=y.useMemo(()=>{if(r.length===0)return null;const N=X1(r);if(c.length===N.size&&N.size>0&&c.every(E=>N.has(E))||!c.every(E=>i[E]))return null;const C=Object.fromEntries(c.map(E=>[E,i[E]]));return JSON.stringify({mcpServers:C})},[c,i,r]);return{servers:r,selectedServers:c,mcpConfigJson:_,loading:d,loaded:m,toggleServer:v,setSelection:j,refresh:k}}function Wve(n){var s,r;const e=V.c(12);let t;e:{if(!n){t=null;break e}let o=null,i;if(e[0]!==o||e[1]!==n.turns){const p=new Map;let h=0;for(const g of n.turns)for(const x of g.toolCalls){if(x.name==="TodoWrite"){const b=x.input;Array.isArray(b.todos)&&(o=b.todos);continue}if(x.name==="TaskCreate"){const b=x.input;h=h+1;const v=((r=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:r[1])??String(h);p.set(v,{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,w=String(b.taskId??"");if(!w)continue;if(b.status==="deleted"){p.delete(w);continue}const v=p.get(w)??{id:w,content:b.subject||b.description||`Task ${w}`,activeForm:b.activeForm||b.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...v,content:b.subject||b.description||v.content,activeForm:b.activeForm||v.activeForm,status:b.status||v.status,owner:b.owner??v.owner,blockedBy:b.addBlockedBy?[...new Set([...v.blockedBy??[],...b.addBlockedBy])]:v.blockedBy})}}i=p.size>0?[...p.values()]:o,e[0]=o,e[1]=n.turns,e[2]=i,e[3]=o}else i=e[2],o=e[3];const l=i;if(!l||l.length===0){t=null;break e}let c;e[4]!==l?(c=l.filter(Vve),e[4]=l,e[5]=c):c=e[5];const u=c.length;let d;e[6]!==l?(d=l.find(qve)??null,e[6]=l,e[7]=d):d=e[7];const f=d;let m;e[8]!==u||e[9]!==f||e[10]!==l?(m={todos:l,completed:u,total:l.length,inProgress:f},e[8]=u,e[9]=f,e[10]=l,e[11]=m):m=e[11],t=m}return t}function qve(n){return n.status==="in_progress"}function Vve(n){return n.status==="completed"}const Hve=[];function Kve(n){const e=V.c(2),[t,s]=y.useState(null);let r;return e[0]!==n?(r=async i=>{if(n)try{const l=await Ce(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(!l.ok)return;const c=await l.json();if(!i())return;s(u=>(u==null?void 0:u.cwd)===n&&JSON.stringify(u.agents)===JSON.stringify(c)?u:{cwd:n,agents:c})}catch{}},e[0]=n,e[1]=r):r=e[1],Oa(n?r:null,5e3),t&&t.cwd===n?t.agents:Hve}function Gve(n,e){const t=V.c(8),s=e===void 0?!0:e;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];const[o,i]=y.useState(r),[l,c]=y.useState(!1),u=y.useRef(void 0);let d,f;t[1]!==n||t[2]!==s?(d=()=>{if(!s){u.current=void 0,i([]),c(!1);return}if(u.current===n)return;u.current=n,c(!0);const p=n?`?cwd=${encodeURIComponent(n)}`:"";Ce(`/api/slash-suggestions${p}`).then(Zve).then(h=>i(h.suggestions||[])).catch(()=>i([])).finally(()=>c(!1))},f=[n,s],t[1]=n,t[2]=s,t[3]=d,t[4]=f):(d=t[3],f=t[4]),y.useEffect(d,f);let m;return t[5]!==l||t[6]!==o?(m={suggestions:o,loading:l},t[5]=l,t[6]=o,t[7]=m):m=t[7],m}function Zve(n){return n.json()}function r4(n,e){const t=V.c(6),[s,r]=jr(n,e),o=typeof s=="boolean"?s:e;let i;t[0]!==e||t[1]!==r?(i=u=>{r(d=>typeof u=="function"?u(typeof d=="boolean"?d:e):u)},t[0]=e,t[1]=r,t[2]=i):i=t[2];const l=i;let c;return t[3]!==l||t[4]!==o?(c=[o,l],t[3]=l,t[4]=o,t[5]=c):c=t[5],c}const o4={config:{type:"CLOSE_CONFIG"},mission:{type:"CLOSE_MISSION"},extension:{type:"CLOSE_EXTENSION_VIEW"}};function i4(){if(typeof window>"u")return Lt.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return Lt.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return Lt.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return Lt.fileChanges}function Yve(n,e){const t=V.c(53),[s,r]=r4("panel-sidebar-visible",!0),[o,i]=r4("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=i4(),t[0]=l):l=t[0];const[c,u]=jr("workspace-panel-active",l);let d;t[1]!==c?(d=typeof c=="string"||c===null?c:i4(),t[1]=c,t[2]=d):d=t[2];const f=d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),{mainView:x}=n;let b;t[3]!==r||t[4]!==s?(b=()=>{y.startTransition(()=>r(!s))},t[3]=r,t[4]=s,t[5]=b):b=t[5];const w=b;let v;t[6]!==e||t[7]!==x||t[8]!==u?(v=se=>{y.startTransition(()=>{const X=x!=="sessions";X&&e(o4[x]),u(ne=>X||cj(ne)!==cj(se)?se:null)})},t[6]=e,t[7]=x,t[8]=u,t[9]=v):v=t[9];const j=v;let k;t[10]!==e||t[11]!==x||t[12]!==u?(k=se=>{y.startTransition(()=>{x!=="sessions"&&e(o4[x]),u(se)})},t[10]=e,t[11]=x,t[12]=u,t[13]=k):k=t[13];const _=k;let N;t[14]!==u?(N=()=>{y.startTransition(()=>u(null))},t[14]=u,t[15]=N):N=t[15];const S=N;let C;t[16]!==e||t[17]!==x?(C=()=>{const se=x==="config";y.startTransition(()=>{e({type:se?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=x,t[18]=C):C=t[18];const E=C;let T;t[19]!==e||t[20]!==x?(T=()=>{const se=x==="mission";y.startTransition(()=>{e({type:se?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=x,t[21]=T):T=t[21];const $=T;let A;t[22]!==e?(A=se=>{y.startTransition(()=>e({type:"OPEN_EXTENSION_VIEW",id:se}))},t[22]=e,t[23]=A):A=t[23];const R=A;let P;t[24]!==e?(P=()=>{y.startTransition(()=>e({type:"CLOSE_EXTENSION_VIEW"}))},t[24]=e,t[25]=P):P=t[25];const z=P,L=Hx();let I;t[26]===Symbol.for("react.memo_cache_sentinel")?(I=new Set,t[26]=I):I=t[26];const M=y.useRef(I),F=y.useRef(!1);let U,O;t[27]!==L||t[28]!==R?(U=()=>{var X;if(F.current)return;const se=M.current;for(const ne of L)if(!se.has(ne.id)&&(se.add(ne.id),(X=ne.openOnStart)!=null&&X.call(ne))){F.current=!0,R(ne.id);return}},O=[L,R],t[27]=L,t[28]=R,t[29]=U,t[30]=O):(U=t[29],O=t[30]),y.useEffect(U,O);let D;t[31]!==e?(D=se=>{y.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:se})})},t[31]=e,t[32]=D):D=t[32];const B=D;let q;t[33]===Symbol.for("react.memo_cache_sentinel")?(q=()=>p(!0),t[33]=q):q=t[33];const W=q;let H;t[34]===Symbol.for("react.memo_cache_sentinel")?(H=()=>p(!1),t[34]=H):H=t[34];const K=H;let Z;t[35]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>g(Xve),t[35]=Z):Z=t[35];const Y=Z;let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=()=>g(!1),t[36]=J):J=t[36];const ee=J;let te;return t[37]!==f||t[38]!==z||t[39]!==S||t[40]!==B||t[41]!==E||t[42]!==$||t[43]!==w||t[44]!==R||t[45]!==_||t[46]!==i||t[47]!==m||t[48]!==s||t[49]!==h||t[50]!==o||t[51]!==j?(te={showSidebar:s,showWorkflows:o,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:w,toggleWorkspacePanel:j,openWorkspacePanel:_,closeWorkspacePanel:S,handleToggleConfig:E,handleToggleMission:$,openMainView:R,closeMainView:z,handleEditConfig:B,handleOpenProjectSwitcher:W,handleCloseProjectSwitcher:K,handleToggleThemeSelector:Y,handleCloseThemeSelector:ee,setShowWorkflows:i},t[37]=f,t[38]=z,t[39]=S,t[40]=B,t[41]=E,t[42]=$,t[43]=w,t[44]=R,t[45]=_,t[46]=i,t[47]=m,t[48]=s,t[49]=h,t[50]=o,t[51]=j,t[52]=te):te=t[52],te}function Xve(n){return!n}async function Jve(n,e){let t;try{t=await is("/api/delete-session",{dirName:n,fileName:e})}catch{return Kn.error("Could not delete session"),!1}return t.ok||t.status===404?!0:(Kn.error(await Tl(t,"Could not delete session")),!1)}function Qve(n){var ee;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:r,markPermissionsApplied:o,hasPermsPendingChanges:i,permissionsConfig:l,settingsChange:c,onSettingsChangeSent:u,selectedModel:d,selectedEffort:f,fastMode:m,ultracode:p,mcpConfig:h,scrollRequestScrollToTop:g,handleDashboardSelect:x,workerParse:b,canInteract:w}=n,v=y.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:te,fileName:se}=e.sessionSource;try{const{parsed:X,source:ne}=await C7(te,se,b,"session");t({type:"RELOAD_SESSION_CONTENT",session:X,source:ne})}catch{}},[e.sessionSource,t,b]),[j,k]=y.useState(null),_=y.useCallback(te=>k(te),[]),N=y.useCallback(()=>k(null),[]),S=y.useCallback(async te=>{try{const se=await Ce("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)});if(!se.ok)return;const X=await se.json();WN(X.sessionId);const{parsed:ne,source:ae}=await ka(X.dirName,X.fileName,b,"session");t({type:"LOAD_SESSION",session:ne,source:ae,isMobile:s})}catch{}},[t,s,b]),C=y.useCallback((te,se)=>S({dirName:te,fileName:se}),[S]),E=y.useCallback(()=>{e.sessionSource&&C(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,C]),T=y.useCallback((te,se)=>{const X=Jve(te,se),ne=cR(te,se);return ne?_R(ne,X):X},[]),$=y.useCallback(async te=>{var ae,ie;if(!e.sessionSource)return;const{dirName:se,fileName:X}=e.sessionSource,ne=(ie=(ae=e.session)==null?void 0:ae.turns[te])==null?void 0:ie.id;await S({dirName:se,fileName:X,turnIndex:te,turnUuid:ne})},[e.sessionSource,e.session,S]),A=y.useCallback((te,se)=>{r(te,se),t({type:"SET_MOBILE_TAB",tab:"chat"})},[r,t]),[R,P]=y.useState({}),z=y.useRef(d);z.current=d;const L=y.useRef(f);L.current=f;const I=y.useRef(h);I.current=h;const M=y.useRef(m);M.current=m;const F=y.useRef(p);F.current=p;const U=y.useRef(l);U.current=l;const O=y.useRef(c);O.current=c;const D=y.useRef(u);D.current=u;const B=((ee=e.session)==null?void 0:ee.sessionId)??null,q=y.useRef(null);y.useEffect(()=>{B!==q.current&&(q.current=B,B&&P(te=>B in te?te:{...te,[B]:{model:z.current,effort:L.current,fastMode:M.current,ultracode:F.current,mcpConfig:I.current}}))},[B]);const W=B?R[B]:void 0,H=h!==((W==null?void 0:W.mcpConfig)??null),K=W!=null&&(d!==W.model||f!==W.effort||m!==W.fastMode||p!==W.ultracode||i||H),Z=y.useCallback(async()=>{var oe,fe;if(!B||!w)return;const te=z.current,se=L.current,X=M.current,ne=F.current,ae=I.current,ie=U.current,re=O.current,de=D.current,ce=((oe=e.sessionSource)==null?void 0:oe.agentKind)??un(((fe=e.sessionSource)==null?void 0:fe.dirName)??null);bn(ce).settingsApply==="live"&&(await Ce(`/api/claude/settings/${encodeURIComponent(B)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:te,effort:se,fastMode:X,ultracode:ne,mcpConfig:ae,...ie&&{permissionMode:ie.mode,allowedTools:ie.allowedTools,disallowedTools:ie.disallowedTools},...re.length>0&&{settingsChange:re}})})).ok&&re.length>0&&de(),P(ue=>({...ue,[B]:{model:te,effort:se,fastMode:X,ultracode:ne,mcpConfig:ae}})),o()},[B,w,e.sessionSource,o]),Y=y.useCallback(async()=>{if(!(!B||!w))try{await Ce("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:B})})}catch{}},[B,w]),J=y.useCallback((te,se)=>{$o(se)&&g(),x(te,se)},[g,x]);return{reloadSession:v,branchModalTurn:j,setBranchModalTurn:k,handleOpenBranches:_,handleCloseBranchModal:N,handleDuplicateSessionByPath:C,handleDuplicateSession:E,handleDeleteSession:T,handleBranchFromHere:$,handleMobileJumpToTurn:A,hasSettingsChanges:K,handleApplySettings:Z,handleStopSession:Y,handleLoadSessionScrollAware:J}}const eye=6e4;function B7(){const n=y.useRef(null);y.useEffect(()=>{const s=new Map;let r=0,o,i=!1;const l=f=>{const m=s.get(f);if(m)return s.delete(f),clearTimeout(m.timer),m},c=f=>{var m;for(const p of[...s.keys()])(m=l(p))==null||m.reject(f)},u=f=>{o.terminate(),c(f),i||(o=d())},d=()=>{const f=new Worker(new URL("/assets/session-parser.worker-3tFlB6dy.js",import.meta.url),{type:"module"});return f.onmessage=m=>{const p=m.data,h=l(p.id);h&&(p.type==="result"?h.resolve(p.session):h.reject(new Error(p.error)))},f.onerror=m=>u(new Error(`Worker error: ${m.message}`)),f.onmessageerror=()=>u(new Error("Worker sent a message that could not be read")),f};return o=d(),n.current=f=>new Promise((m,p)=>{const h=r++,g=setTimeout(()=>u(new Error("Worker did not answer")),eye);s.set(h,{resolve:m,reject:p,timer:g});try{o.postMessage({...f,id:h})}catch(x){l(h),p(x instanceof Error?x:new Error(String(x)))}}),()=>{i=!0,n.current=null,o.terminate(),c(new Error("Worker terminated"))}},[]);const e=y.useCallback(s=>{const r=n.current;return r?r({type:"parse",text:s}):Promise.resolve().then(()=>xm(s))},[]),t=y.useCallback((s,r)=>{const o=n.current;return o?o({type:"append",existing:s,newText:r}):Promise.resolve().then(()=>Kse(s,r))},[]);return{parse:e,append:t}}const tye=30;function W7({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:r}){const[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(""),d=y.useRef(null),f=`${n??""}::${e??""}::${t}`;return y.useEffect(()=>{u.current=f,d.current=null,c(!1);const p=n&&e?js.get(n,e):void 0;i((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&r(p.olderTurns)},[f,n,e,t,r]),{loadMore:y.useCallback(async()=>{if(!n||!e||d.current)return 0;const p=`${n}::${e}::${t}`,h=js.get(n,e);if(!(h!=null&&h.hasMore))return u.current===p&&i(!1),0;const g=Symbol("paging-flight");d.current=g,c(!0);try{const x=await Ce(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${tye}`);if(!x.ok)return 0;const b=await x.json(),w=b.lines.length>0&&b.hasMore;if(u.current===p&&i(w),b.lines.length===0)return js.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),j=b.lines.filter(N=>!v.has(N)),k=await s([...b.headerLines,...j].join(`
|
|
491
491
|
`)),_=xI(h.olderTurns,k.turns,h.source.agentKind);return js.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset,olderTurns:_}),u.current!==p?0:(r(_),k.turns.length)}finally{d.current===g&&(d.current=null,u.current===p&&c(!1))}},[n,e,t,s,r]),hasMore:o,isLoadingOlder:l}}function nye(n){const e=V.c(48),{agentKind:t,session:s,sessionSource:r,pendingDirName:o,isLive:i}=n,l=t??Wo,[c,u]=y.useState(""),[d,f]=y.useState(""),[m,p]=y.useState(null),[h,g]=y.useState(!1),[x,b]=y.useState(!1),w=(r==null?void 0:r.dirName)??o;let v;e[0]!==w?(v=Xr(w),e[0]=w,e[1]=v):v=e[1];const{options:j,fastTier:k,imageInput:_,normalizeEffort:N}=m5(l,c,v.instanceId),S=c||(s==null?void 0:s.model);let C;e[2]!==l||e[3]!==S?(C=t9(l,S),e[2]=l,e[3]=S,e[4]=C):C=e[4];const E=C,T=x&&E;let $;e[5]!==N||e[6]!==d?($=N(d),e[5]=N,e[6]=d,e[7]=$):$=e[7];const A=$,R=!!k,P=R&&h,[z,L]=y.useState(null),I=y.useRef(null),M=(r==null?void 0:r.fileName)??null,F=y.useRef(M);let U,O;e[8]!==M?(U=()=>{const ie=F.current;F.current=M,!(ie===null||ie===M)&&(b(!1),p(null))},O=[M],e[8]=M,e[9]=U,e[10]=O):(U=e[9],O=e[10]),y.useEffect(U,O);let D,B;e[11]!==o?(D=()=>{o&&(b(!1),p(null))},B=[o],e[11]=o,e[12]=D,e[13]=B):(D=e[12],B=e[13]),y.useEffect(D,B);let q;e[14]!==l?(q=ie=>{u(re=>re===ie?"":re),L(`${ie} is unavailable for this account. Cogpit retried the turn with ${Cn(l).displayName}'s default model.`)},e[14]=l,e[15]=q):q=e[15];const W=q;let H;e[16]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{L(null)},e[16]=H):H=e[16];const K=H;let Z,Y;e[17]!==j||e[18]!==o||e[19]!==c||e[20]!==r?(Z=()=>{c&&(!r&&!o||j.some(ie=>ie.value===c)||u(""))},Y=[j,c,r,o],e[17]=j,e[18]=o,e[19]=c,e[20]=r,e[21]=Z,e[22]=Y):(Z=e[21],Y=e[22]),y.useEffect(Z,Y);let J,ee;e[23]!==z?(J=()=>{if(!z)return;const ie=setTimeout(()=>L(null),12e3);return()=>clearTimeout(ie)},ee=[z],e[23]=z,e[24]=J,e[25]=ee):(J=e[24],ee=e[25]),y.useEffect(J,ee);const te=s==null?void 0:s.rawMessages;let se,X;e[26]!==l||e[27]!==i||e[28]!==te?(se=()=>{if(!i||!te||!bn(l).modelFallbackNotices)return;let ie;for(let fe=te.length-1;fe>=0;fe=fe-1,fe){const ue=te[fe];if(ue.type==="system"&&ue.subtype==="model_refusal_fallback"){ie=ue;break}}if(!ie)return;const re=typeof ie.uuid=="string"?ie.uuid:`${String(ie.original_model)}:${String(ie.fallback_model)}:${String(ie.request_id)}`;if(I.current===re)return;I.current=re;const de=typeof ie.original_model=="string"?ie.original_model:"Fable",ce=typeof ie.fallback_model=="string"?ie.fallback_model:"Opus",oe=typeof ie.api_refusal_explanation=="string"?` ${ie.api_refusal_explanation}`:"";L(`${de} could not handle this request, so Claude continued with ${ce}.${oe}`)},X=[i,te,l],e[26]=l,e[27]=i,e[28]=te,e[29]=se,e[30]=X):(se=e[29],X=e[30]),y.useEffect(se,X);let ne;e[31]!==l?(ne=bn(l),e[31]=l,e[32]=ne):ne=e[32];let ae;return e[33]!==m||e[34]!==A||e[35]!==P||e[36]!==R||e[37]!==h||e[38]!==W||e[39]!==_||e[40]!==z||e[41]!==d||e[42]!==c||e[43]!==ne.configurableContextWindow||e[44]!==T||e[45]!==E||e[46]!==x?(ae={contextWindowTokens:m,setContextWindowTokens:p,contextWindowAvailable:ne.configurableContextWindow,selectedModel:c,setSelectedModel:u,selectedEffort:d,setSelectedEffort:f,fastModeEnabled:h,ultracodeEnabled:x,effectiveEffort:A,fastModeAvailable:R,fastModeActive:P,setFastModeEnabled:g,ultracodeAvailable:E,ultracodeActive:T,setUltracodeEnabled:b,imageInputAvailable:_,modelFallbackNotice:z,dismissModelFallbackNotice:K,handleModelRejected:W},e[33]=m,e[34]=A,e[35]=P,e[36]=R,e[37]=h,e[38]=W,e[39]=_,e[40]=z,e[41]=d,e[42]=c,e[43]=ne.configurableContextWindow,e[44]=T,e[45]=E,e[46]=x,e[47]=ae):ae=e[47],ae}const na=["permissionMode","model","effort","contextWindowTokens","fastMode","ultracode"];function sye(n){return na.some(e=>e===n)}function rye(n){return JSON.stringify(n,[...na])}function nl(n,e){return na.filter(t=>n[t]!==e[t])}function Ju(n,e){const t={};for(const s of e)Object.assign(t,{[s]:n[s]});return t}function oye(n,e){return{model:n.model??e.model,effort:n.effort??e.effort,contextWindowTokens:n.contextWindowTokens??null,fastMode:n.fastMode??e.fastMode,ultracode:n.ultracode??e.ultracode,permissionMode:n.permissionMode??e.permissionMode}}function iye({sessionKey:n,sessionId:e,values:t,access:s,onHydrate:r}){const[o,i]=y.useState(null),l=y.useRef(null),c=y.useRef(0),u=y.useRef(r);u.current=r;const d=y.useRef(t);d.current=t;const f=y.useRef(s);f.current=s;const m=y.useCallback((w,v)=>{const j=l.current;if((j==null?void 0:j.key)!==w||!Sa(f.current).configure)return;const k=nl(j.values,v);if(k.length===0)return;const _=Ju(v,k);l.current={key:w,values:v},Y1(w,_).then(N=>{N&&i(S=>(S==null?void 0:S.key)===w?{key:w,values:{...S.values,..._}}:S)})},[]),p=y.useCallback(w=>{var _;const v=++c.current,j=d.current,k=((_=l.current)==null?void 0:_.key)===w?l.current.values:null;D7(w).then(N=>{if(v!==c.current||N===null)return;const S=d.current,C=Sa(f.current).configure;if(!na.some(A=>N[A]!==void 0)){if(l.current={key:w,values:S},i({key:w,values:S}),!C)return;const A=f.current==="own"?na:na.filter(R=>R!=="permissionMode");Y1(w,Ju(S,A));return}const E=oye(N,k??S),T=k?[...new Set([...nl(k,j),...nl(j,S)])]:[],$={...E,...Ju(S,T)};(!k||nl(S,$).length>0)&&u.current({...N,...Ju(S,T)}),l.current={key:w,values:E},i({key:w,values:E}),m(w,$)})},[m]);y.useEffect(()=>{var w;if(((w=l.current)==null?void 0:w.key)!==n&&(l.current=null),!!n)return p(n),()=>{c.current+=1}},[n,s,p]),y.useEffect(()=>{if(!n)return;const w=()=>p(n),v=e?lte(e,w):void 0;let j=document.visibilityState==="hidden";function k(){j&&(j=!1,w())}function _(){document.visibilityState==="hidden"?j=!0:k()}return document.addEventListener("visibilitychange",_),window.addEventListener("focus",k),()=>{v==null||v(),document.removeEventListener("visibilitychange",_),window.removeEventListener("focus",k)}},[n,e,p]);const h=rye(t);y.useEffect(()=>{n&&m(n,d.current)},[h,n,m]);const g=(o==null?void 0:o.key)===n?nl(o.values,t).join():"",x=y.useMemo(()=>g.split(",").filter(sye),[g]),b=y.useCallback(()=>{n&&U7(n)},[n]);return{picked:x,settlePicked:b}}function aye(n){const[e,t]=y.useState(new Map),[s,r]=y.useState(null),[o,i]=y.useState(!0),l=y.useRef(new Map),c=y.useRef(null);y.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:o}),x!==b){const w=x?l.current.get(x):null;w?(r(w.activeId),i(w.collapsed)):(r(null),i(!0))}c.current=x},[n]);const u=y.useCallback(()=>i(x=>!x),[]),d=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.set(x.id,x),w}),r(x.id),i(!1)},[]),f=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.delete(x),r(v=>{if(v!==x)return v;const j=[...w.keys()];return j.length>0?j[j.length-1]:null}),w})},[]),m=y.useCallback(x=>{r(x),i(!1)},[]),p=y.useCallback((x,b)=>{t(w=>{const v=w.get(x);if(!v||v.status===b)return w;const j=new Map(w);return j.set(x,{...v,status:b}),j})},[]),h=y.useCallback(x=>{t(b=>{let w=!1;const v=new Map(b),j=new Set(x.map(k=>k.id));for(const[k,_]of v)_.type==="task"&&!j.has(k)&&(v.delete(k),w=!0);for(const k of x){const _=v.get(k.id);_?(_.name!==k.title||_.outputPath!==k.outputPath)&&(v.set(k.id,{..._,name:k.title,outputPath:k.outputPath}),w=!0):(v.set(k.id,{id:k.id,name:k.title,type:"task",status:"running",outputPath:k.outputPath}),w=!0)}return w?v:b})},[]),g=y.useCallback((x,b,w)=>{b&&w&&t(v=>{if(v.has(x))return v;const j=new Map(v);return j.set(x,{id:x,name:w,type:"task",status:"running",outputPath:b}),j}),r(v=>v===x?(i(!0),v):(i(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:o,toggleCollapse:u,addProcess:d,removeProcess:f,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function lye(n){const e=V.c(52),{sessionId:t,sessionCwd:s,pendingPath:r,sessionDirName:o,pendingDirName:i,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:u,openWorkspacePanel:d,closeWorkspacePanel:f}=n,m=aye(t),[p,h]=y.useState(null),[g,x]=y.useState(0),b=y.useRef(0),w=s??r??void 0,v=!!(w&&(p==null?void 0:p.kind)==="preview"&&p.cwd===w),j=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(w??null)?p:null;let k;e[0]!==i||e[1]!==r?(k={path:r,dirName:i},e[0]=i,e[1]=r,e[2]=k):k=e[2];const _=k;let N;e[3]!==l||e[4]!==i||e[5]!==r||e[6]!==s||e[7]!==o?(N=()=>({path:s??r??void 0,dirName:o??i??l??void 0}),e[3]=l,e[4]=i,e[5]=r,e[6]=s,e[7]=o,e[8]=N):N=e[8];const S=N;let C;e[9]!==S?(C=()=>{L1(S())},e[9]=S,e[10]=C):C=e[10];const E=C;let T;e[11]!==S?(T=J=>{L1({...S(),command:"claude /mcp"})},e[11]=S,e[12]=T):T=e[12];const $=T;let A;e[13]!==r||e[14]!==m||e[15]!==s?(A=()=>{const ee=[...m.processes.values()].filter(dye).at(-1);if(!ee){(s??r)&&x(uye);return}m.activeProcessId===ee.id&&!m.collapsed?m.toggleCollapse():m.setActive(ee.id)},e[13]=r,e[14]=m,e[15]=s,e[16]=A):A=e[16];const R=A;let P;e[17]!==r||e[18]!==s?(P=()=>{(s??r)&&x(cye)},e[17]=r,e[18]=s,e[19]=P):P=e[19];const z=P;let L;e[20]!==f||e[21]!==w||e[22]!==v?(L=()=>{w&&y.startTransition(()=>{f(),h(v?null:{kind:"preview",cwd:w})})},e[20]=f,e[21]=w,e[22]=v,e[23]=L):L=e[23];const I=L;let M;e[24]!==u||e[25]!==f||e[26]!==w||e[27]!==d?(M=()=>{if(w){if(u===Lt.projectFiles){f();return}y.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),d(Lt.projectFiles)})}},e[24]=u,e[25]=f,e[26]=w,e[27]=d,e[28]=M):M=e[28];const F=M;let U;e[29]!==w||e[30]!==d||e[31]!==c?(U=J=>{if(!c)return!1;const ee=Xse(J,w);if(!ee)return!1;b.current=b.current+1;const te=b.current;return y.startTransition(()=>h({kind:"project-files",root:ee.root,anchorCwd:w??null,request:ee.file?{file:ee.file,mode:ee.mode,line:ee.line,token:te}:null})),d(Lt.projectFiles),!0},e[29]=w,e[30]=d,e[31]=c,e[32]=U):U=e[32];const O=U;let D,B;e[33]!==O?(D=()=>Yse(O),B=[O],e[33]=O,e[34]=D,e[35]=B):(D=e[34],B=e[35]),y.useEffect(D,B);let q;e[36]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{y.startTransition(()=>h(null))},e[36]=q):q=e[36];const W=q,H=!!(w&&u===Lt.projectFiles),K=j==null?void 0:j.root,Z=(j==null?void 0:j.request)??null;let Y;return e[37]!==w||e[38]!==$||e[39]!==z||e[40]!==E||e[41]!==R||e[42]!==I||e[43]!==F||e[44]!==g||e[45]!==_||e[46]!==m||e[47]!==v||e[48]!==H||e[49]!==K||e[50]!==Z?(Y={processPanel:m,currentCwd:w,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:Z,launchTerminalRequest:g,pendingProject:_,handleOpenTerminal:E,handleMcpAuth:$,handleToggleIntegratedTerminal:R,handleNewIntegratedTerminal:z,handleTogglePreview:I,handleToggleProjectFiles:F,closeRightWorkspace:W},e[37]=w,e[38]=$,e[39]=z,e[40]=E,e[41]=R,e[42]=I,e[43]=F,e[44]=g,e[45]=_,e[46]=m,e[47]=v,e[48]=H,e[49]=K,e[50]=Z,e[51]=Y):Y=e[51],Y}function cye(n){return n+1}function uye(n){return n+1}function dye(n){return n.type==="terminal"}function fye(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
492
|
-
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const mye={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function q7(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:un(n.dirName)}}function pye(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...mye},rawMessages:[],agentKind:un(n.dirName)}}function V7(n,e){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:oa(xm(n),Xr(e).instanceId)}}catch{return null}}async function hye(n,e,t=3,s=100,r=!0){if(r){const o=V7(n.initialContent,n.dirName);if(o)return o}for(let o=0;o<t;o++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const i=await Ce(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(i.ok){const l=await i.text();if(l.trim())try{return{rawText:l,parsed:oa(xm(l),Xr(n.dirName).instanceId)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function gye(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await hye(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:q7(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function xye(n,e,t,s,r){const o=V7(n.initialContent,n.dirName),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??pye(n),c=q7(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),gye(n,e,t,i),n.sessionId}function bye(n){return n.access?n.access.mine:!0}async function vye(n,e,t,s){const r=Jr(),o=await Ce(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json();la(i.sessions??[],r);const l=t-3e4,c=e.trim(),u=(i.sessions??[]).filter(f=>{const m=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(m)&&m>=l&&bye(f)}),d=u.find(f=>{var m,p;return((m=f.firstUserMessage)==null?void 0:m.trim())===c||((p=f.lastUserMessage)==null?void 0:p.trim())===c})??u[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function yye({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:r,onModelRejected:o,model:i,effort:l,contextWindowTokens:c,fastMode:u,ultracode:d,mcpConfig:f}){const[m,p]=y.useState(!1),[h,g]=y.useState(null),[x,b]=y.useState(!1),w=y.useRef(null),v=y.useRef(null),j=y.useRef(null),k=y.useCallback((C,E)=>{v.current=C,j.current=E??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:C,cwd:E,isMobile:t})},[e,t]),_=y.useCallback(async(C,E)=>{var I;const T=v.current;if(!T)return null;const $=un(T),A=j.current;(I=w.current)==null||I.abort();const R=new AbortController;w.current=R,p(!0),g(null),r==null||r(C);const P=Date.now(),z=fye(C);async function L(M){v.current=null,j.current=null,WN(M.sessionId);const F=await xye(M,R,e,t,s);return z&&F&&KN(F,z),F}try{const M=Cn($),{capabilities:F}=M,U={dirName:T,cwd:M.dirName.lossy?A??void 0:void 0,message:C,images:E,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:F.ultracode&&d?!0:void 0,name:F.namedSessions&&z||void 0,worktreeName:F.worktrees&&x?s9(C):void 0,mcpConfig:F.mcp&&f||void 0},{res:O,errorMessage:D,errorCode:B}=await S7(q=>Ce("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...U,model:q}),signal:R.signal}),{model:i,agentKind:$,errorFallback:"Unknown error",onModelRejected:o});if(!O.ok){if($==="codex"&&B!=="SESSION_UNCONFIRMED"){const q=await vye(T,C,P,R);if(q)return await L(q)}return g(D||`Failed to create session (${O.status})`),null}return await L(await O.json())}catch(M){return R.signal.aborted||g(M instanceof Error?M.message:"Failed to create session"),null}finally{R.signal.aborted||p(!1)}},[n,i,l,c,u,d,f,x,e,t,s,r,o]),N=y.useCallback(()=>g(null),[]),S=y.useCallback(()=>{var C;(C=w.current)==null||C.abort(),w.current=null,v.current=null,j.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:N,handleNewSession:k,createAndSend:_,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function wye(n){const e=V.c(41),{permissionsConfig:t,dispatch:s,isMobile:r,defaultAgentKind:o,pendingDirName:i,pendingCwd:l,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p,onModelRejected:h}=n,g=y.useRef(null),x=y.useRef(null),[b,w]=y.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=W=>{var H;(H=g.current)==null||H.call(g,W),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},300),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},2e3)},e[0]=v):v=e[0];let j;e[1]!==d||e[2]!==s||e[3]!==u||e[4]!==f||e[5]!==r||e[6]!==p||e[7]!==c||e[8]!==h||e[9]!==t||e[10]!==m?(j={permissionsConfig:t,dispatch:s,isMobile:r,onSessionFinalized:v,onCreateStarted:w,onModelRejected:h,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p},e[1]=d,e[2]=s,e[3]=u,e[4]=f,e[5]=r,e[6]=p,e[7]=c,e[8]=h,e[9]=t,e[10]=m,e[11]=j):j=e[11];const k=yye(j),_=k.handleNewSession,[N,S]=y.useState(null);let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[12]=C):C=e[12];const E=y.useRef(C),T=Sye;let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=async W=>{if(pu===null)return null;const H=E.current;if(H.has(W))return H.get(W)??null;const K=fR(await T(),W,pu);return H.set(W,K),K},e[13]=$):$=e[13];const A=$;let R;e[14]!==_?(R=async(W,H)=>{var J;const K=H??((J=(await T()).find(ee=>ee.dirName===W))==null?void 0:J.path)??null;if(!K){S(null),_(W);return}if(Xr(W).instanceId!=="default"){S({discoveredDirName:null,cwd:K}),_(W,K);return}const Z=un(W)===pu?pu:null,Y=Z?Gm(Z,K):await A(K);S({discoveredDirName:Y,cwd:K}),_(Z&&Y?Y:W,K)},e[14]=_,e[15]=R):R=e[15];const P=R;let z;e[16]!==o||e[17]!==P?(z=W=>{const H=Gm(o,W);P(H,W)},e[16]=o,e[17]=P,e[18]=z):z=e[18];const L=z;let I;e[19]!==_||e[20]!==N?(I=W=>{if(!N)return;const H=Gm(W,N.cwd,N.discoveredDirName??void 0);_(H,N.cwd)},e[19]=_,e[20]=N,e[21]=I):I=e[21];const M=I;let F;e:{if(!k.creatingSession||!i){F=null;break e}const W=b??void 0;let H;e[22]!==l||e[23]!==i||e[24]!==W?(H={dirName:i,cwd:l,firstMessage:W},e[22]=l,e[23]=i,e[24]=W,e[25]=H):H=e[25],F=H}const U=F;let O,D;e[26]!==i?(D=()=>{i||(w(null),S(null))},O=[i],e[26]=i,e[27]=O,e[28]=D):(O=e[27],D=e[28]),y.useEffect(D,O);const B=N?M:void 0;let q;return e[29]!==L||e[30]!==P||e[31]!==k.cancelCreation||e[32]!==k.clearCreateError||e[33]!==k.createAndSend||e[34]!==k.createError||e[35]!==k.creatingSession||e[36]!==k.setWorktreeEnabled||e[37]!==k.worktreeEnabled||e[38]!==U||e[39]!==B?(q={creatingSession:k.creatingSession,createError:k.createError,clearCreateError:k.clearCreateError,createAndSend:k.createAndSend,cancelCreation:k.cancelCreation,worktreeEnabled:k.worktreeEnabled,setWorktreeEnabled:k.setWorktreeEnabled,sessionFinalizedRef:g,liveSessionsRefreshRef:x,pendingSessionInfo:U,pendingAgentKindChange:B,handleStartNewSession:P,handleStartNewFolder:L},e[29]=L,e[30]=P,e[31]=k.cancelCreation,e[32]=k.clearCreateError,e[33]=k.createAndSend,e[34]=k.createError,e[35]=k.creatingSession,e[36]=k.setWorktreeEnabled,e[37]=k.worktreeEnabled,e[38]=U,e[39]=B,e[40]=q):q=e[40],q}async function Sye(){try{const n=await Ce("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const pg=new Set;function kye(n,e){const t=cn(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function jye(n,e,t){const s=kye(n,e);if(!pg.has(s)&&!js.get(n,e)){pg.add(s);try{await ka(n,e,t,"session prefetch",{background:!0})}catch{}finally{pg.delete(s)}}}function Nye({onAuthenticated:n,setupRequired:e=!1}){const[t,s]=y.useState(null),[r,o]=y.useState(""),[i,l]=y.useState(""),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),h=t==="account",{LoginNotice:g}=$r();y.useEffect(()=>{let w=!1;return pN().then(v=>{w||s(v)}),()=>{w=!0}},[]);const x=y.useCallback(async w=>{if(w.preventDefault(),!(!i.trim()||h&&!r.trim())){p(!0),f(null);try{const v=await fetch("/api/auth/verify",h?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:r.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),j=await v.json();v.ok&&j.valid?(Tf(),l(""),o(""),n()):f(j.error||(h?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{p(!1)}}},[h,n,i,r]),b=m||!i.trim()||h&&!r.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:x,className:"w-full max-w-sm",children:a.jsxs(Ds,{children:[a.jsxs(xr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(W8,{className:"size-4"})}),a.jsx(br,{children:"Sign in to Cogpit"}),a.jsx(vr,{children:h?"Sign in with your account to continue.":"Enter the server password to continue."})]}),t===null?a.jsx(Fs,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(Fs,{className:"flex flex-col gap-4",children:[e&&a.jsxs(kt,{children:[a.jsx(yf,{"aria-hidden":"true"}),a.jsx(_t,{children:"This server has no accounts yet."})]}),a.jsxs(Aa,{children:[h&&a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-username",children:"Username"}),a.jsx(On,{id:"login-username",type:"text",value:r,onChange:w=>o(w.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-password",children:"Password"}),a.jsxs(Ko,{children:[a.jsx(Go,{id:"login-password",type:c?"text":"password",value:i,onChange:w=>l(w.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!h}),a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>u(w=>!w),"aria-label":c?"Hide password":"Show password",children:c?a.jsx(fx,{}):a.jsx(Na,{})})})]})]})]}),h&&g&&a.jsx(g,{}),d&&a.jsxs(kt,{variant:"destructive",children:[a.jsx(Sr,{"aria-hidden":"true"}),a.jsx(Xt,{children:"Sign in failed"}),a.jsx(_t,{children:d})]})]}),a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:b,children:[m&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}function Cye(){const n=V.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ef(),n[0]=e):e=n[0];const t=e,[s,r]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(0);let d,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let $=!1;return mN().then(A=>{$||r(A)}),()=>{$=!0}},f=[],n[1]=d,n[2]=f):(d=n[1],f=n[2]),y.useEffect(d,f);const m=t?!0:s===null?null:s.signIn==="account";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){i(!0),c(!0);return}let $=!1;const A=u.current;return RR().then(R=>{!$&&u.current===A&&(i(R),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.signIn)?(g=()=>{let $=!1;const A=()=>{const R=u.current=u.current+1,P=()=>{$||u.current!==R||(i(!1),c(!0))};if(t||(s==null?void 0:s.signIn)==="account"){P();return}Ty().then(z=>{$||u.current!==R||(r(z),z.signIn==="account"&&P())})};return window.addEventListener("cogpit-auth-required",A),()=>{$=!0,window.removeEventListener("cogpit-auth-required",A)}},n[6]=s==null?void 0:s.signIn,n[7]=g):g=n[7];const x=s==null?void 0:s.signIn;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{r(await Ty())},n[11]=j):j=n[11];const k=j;let _;n[12]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{V9(),u.current=u.current+1,i(!1),c(!0),OR().finally(_ye)},n[12]=_):_=n[12];const N=_,S=(s==null?void 0:s.edition)??null,C=l&&s!==null,E=(s==null?void 0:s.setupRequired)===!0;let T;return n[13]!==o||n[14]!==S||n[15]!==C||n[16]!==E?(T={isRemote:t,edition:S,authChecked:C,authenticated:o,setupRequired:E,handleAuthenticated:v,refreshServerState:k,logout:N},n[13]=o,n[14]=S,n[15]=C,n[16]=E,n[17]=T):T=n[17],T}function _ye(){window.dispatchEvent(new Event("cogpit-auth-changed"))}function Eye(n){const e=V.c(18),{onRestored:t,onLogout:s}=n,{activeDevice:r,activeDeviceId:o}=Si();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=qo(),e[0]=i):i=e[0];const l=i,c=l?(r==null?void 0:r.name)??o:"This server";let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Yn,{variant:"icon",children:a.jsx(lx,{className:"text-destructive"})}),e[1]=u):u=e[1];let d;e[2]!==c?(d=a.jsxs(zn,{children:[c," isn’t available to your account right now"]}),e[2]=c,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Dn,{children:"Its administrator can let you back in. Check again once they have."}),e[4]=f):f=e[4];let m;e[5]!==d?(m=a.jsxs(Mn,{children:[u,d,f]}),e[5]=d,e[6]=m):m=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Fn,{"data-icon":"inline-start"}),e[7]=p):p=e[7];let h;e[8]!==t?(h=a.jsxs(Q,{size:"sm",onClick:t,children:[p,"Check again"]}),e[8]=t,e[9]=h):h=e[9];let g;e[10]!==s?(g=l?a.jsxs(Q,{variant:"outline",size:"sm",onClick:Tye,children:[a.jsx(yg,{"data-icon":"inline-start"}),"Switch to this machine"]}):a.jsxs(Q,{variant:"outline",size:"sm",onClick:s,children:[a.jsx(q8,{"data-icon":"inline-start"}),"Sign out"]}),e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h||e[13]!==g?(x=a.jsxs(_c,{className:"flex-row justify-center",children:[h,g]}),e[12]=h,e[13]=g,e[14]=x):x=e[14];let b;return e[15]!==m||e[16]!==x?(b=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[m,x]})}),e[15]=m,e[16]=x,e[17]=b):b=e[17],b}function Tye(){return Xs(Ot)}function Aye(n){const e=V.c(4),{onRetry:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(V8,{className:"text-destructive"})}),a.jsx(zn,{children:"Cogpit couldn’t finish loading"}),a.jsx(Dn,{children:"Part of this server’s interface didn’t download. Check your connection and try again."})]}),e[0]=s):s=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fn,{"data-icon":"inline-start"}),e[1]=r):r=e[1];let o;return e[2]!==t?(o=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[s,a.jsx(_c,{className:"flex-row justify-center",children:a.jsxs(Q,{size:"sm",onClick:t,children:[r,"Retry"]})})]})}),e[2]=t,e[3]=o):o=e[3],o}const J1="cogpit:edition-ui-reloaded";let hg=null;function Iye(){return hg??(hg=nt(()=>import("./edition-ui-DZ5m565z.js"),__vite__mapDeps([42,1,2,29,3,4])).then(n=>n.default,n=>{throw hg=null,n})),hg}function Pye(){try{if(sessionStorage.getItem(J1)!==null)return!1;sessionStorage.setItem(J1,"1")}catch{return!1}return window.location.reload(),!0}function H7(){try{sessionStorage.removeItem(J1)}catch{}}async function $ye(n,e){let t;try{t=await Iye()}catch{return e&&Pye()?"reloading":"failed"}return H7(),(t==null?void 0:t.edition)===n?t:null}async function K7(n,e,t){G9();const s=await $ye(n,t);s!=="reloading"&&(s==="failed"&&e?(H7(),Y9()):s===null||s==="failed"?Z9():K9(s))}async function Rye(n,{required:e=!1}={}){if(n==="personal")return;const t=ec();t==="installed"||t==="loading"||t==="failed"||await K7(n,e,!0)}async function Oye(n){ec()==="failed"&&await K7(n,!0,!1)}function a4(n){return n==="personal"?null:n}function Lye(n,e){const t=V.c(16),s=y.useSyncExternalStore(Vx,ec,ec);let r;t[0]!==n?(r=a4(n),t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==e||t[3]!==o?(i=o??a4(e),t[2]=e,t[3]=o,t[4]=i):i=t[4];const l=i,c=o!==null;let u,d;t[5]!==c||t[6]!==l?(u=()=>{l!==null&&Rye(l,{required:c})},d=[l,c],t[5]=c,t[6]=l,t[7]=u,t[8]=d):(u=t[7],d=t[8]),y.useEffect(u,d);let f;t[9]!==l?(f=()=>{l!==null&&Oye(l)},t[9]=l,t[10]=f):f=t[10];const m=f,p=s==="installed"||s==="unavailable",h=o===null||p,g=l===null||p,x=c&&s==="failed";let b;return t[11]!==m||t[12]!==h||t[13]!==g||t[14]!==x?(b={serverReady:h,ready:g,failed:x,retry:m},t[11]=m,t[12]=h,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}const G7={level:"own"},l4={level:"unknown"},Mye={none:{level:"none"},view:{level:"view"},interact:{level:"interact"},own:G7};function zye(n){const e=V.c(5),{enforcesSessionAccess:t}=PN(),s=t?n:null;let r;e[0]!==s?(r=()=>s?aO(s):void 0,e[0]=s,e[1]=r):r=e[1];const o=r,i=y.useSyncExternalStore(cO,o,o);let l,c;return e[2]!==s?(l=()=>s?mO(s):void 0,c=[s],e[2]=s,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c),t===null?l4:s?i?Mye[i]:l4:G7}function Dye({level:n}){return n==="unknown"?{kind:"checking"}:n==="none"?{kind:"no-access"}:Sa(n).canInteract?null:{kind:"view-only"}}function Fye(n){const e=V.c(8),{reason:t}=n;switch(t.kind){case"subagent":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:mi,children:"Viewing sub-agent session (read-only)"}),e[0]=s):s=e[0],s}case"external":{let s;e[1]!==t.agentKind?(s=TM(t.agentKind),e[1]=t.agentKind,e[2]=s):s=e[2];let r;return e[3]!==s?(r=a.jsx(wd,{icon:mi,status:!0,children:s}),e[3]=s,e[4]=r):r=e[4],r}case"no-access":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:K8,status:!0,children:"You don't have access to this session"}),e[5]=s):s=e[5],s}case"checking":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(c4,{icon:H8,children:"Checking access…"}),e[6]=s):s=e[6],s}case"view-only":{let s;return e[7]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(c4,{icon:Na,children:a.jsx(Uye,{})}),e[7]=s):s=e[7],s}}}function Uye(){const n=V.c(3),{ReadOnlyNote:e}=$r(),{session:t}=jt();let s;return n[0]!==e||n[1]!==t?(s=e&&t?a.jsx(e,{sessionId:t.sessionId}):"View only",n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function c4(n){const e=V.c(4),{icon:t,children:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Bye,{}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==t?(o=a.jsxs("div",{className:"shrink-0",children:[r,a.jsx(wd,{icon:t,status:!0,children:s})]}),e[1]=s,e[2]=t,e[3]=o):o=e[3],o}function Bye(){const n=V.c(7),{pendingInteraction:e,permissionRequests:t}=jt(),s=(e==null?void 0:e.type)==="plan"?e:null;if(!s&&t.length===0)return null;let r;n[0]!==s?(r=s&&a.jsx($5,{allowedPrompts:s.allowedPrompts,summary:s.summary,planContent:s.planContent}),n[0]=s,n[1]=r):r=n[1];let o;n[2]!==t?(o=t.length>0&&a.jsx("div",{className:"mb-2 overflow-hidden rounded-xl border border-warning/40 bg-popover",children:a.jsx(R5,{requests:t})}),n[2]=t,n[3]=o):o=n[3];let i;return n[4]!==r||n[5]!==o?(i=a.jsxs("div",{className:"px-3 pt-2",children:[r,o]}),n[4]=r,n[5]=o,n[6]=i):i=n[6],i}function wd(n){const e=V.c(8),{icon:t,status:s,children:r}=n,i=(s===void 0?!1:s)?"status":void 0;let l;e[0]!==t?(l=a.jsx(t,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==r?(c=a.jsx("span",{className:"text-xs text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==l||e[6]!==c?(u=a.jsxs("div",{role:i,className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[l,c]}),e[4]=i,e[5]=l,e[6]=c,e[7]=u):u=e[7],u}const Wye=y.lazy(()=>nt(()=>import("./index-BFA_YkUM.js"),__vite__mapDeps([43,1,2,3,4])).then(n=>({default:n.BranchModal}))),qye=y.lazy(()=>nt(()=>import("./WorkflowsPanel-B6whBEyJ.js"),__vite__mapDeps([44,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function Vye(){window.location.reload()}function Hye(){var qv,Vv,Hv,Kv,Gv,Zv,Yv,Xv,Jv,Qv,ey,ty,ny,sy,ry,oy,iy,ay,ly,cy,uy,dy,fy,my,py,hy;const n=av(window.location.pathname),e=Sve(),t=Cye(),s=Ave(t.edition),r=Lye(t.edition,s.edition),o=$r(),i=s.checked&&(s.edition==="personal"||s.user!==null),l=i&&s.capabilities.configWrite,c=i&&s.capabilities.hostFiles,u=i&&s.capabilities.terminal,d=rv(),f=E7(),[m,p]=k7(),{procBySession:h}=Kx(),{parse:g,append:x}=B7(),b=y.useCallback(Oe=>{p({type:"SET_OLDER_TURNS",turns:Oe})},[p]),w=y.useCallback((Oe,ct)=>{jye(Oe,ct,g)},[g]),v=W7({dirName:((qv=m.sessionSource)==null?void 0:qv.dirName)??null,fileName:((Vv=m.sessionSource)==null?void 0:Vv.fileName)??null,sessionChangeKey:m.sessionChangeKey,workerParse:g,onOlderTurns:b}),{loadMore:j}=v,k=!!m.searchQuery&&v.hasMore,_=((Hv=m.session)==null?void 0:Hv.turns.length)??0;y.useEffect(()=>{k&&j()},[k,j,_]);const N=Yve(m,p),S=y.useRef(null),C=y.useRef(null),[E,T]=y.useState(!1),[$,A]=y.useState(!1),R=y.useCallback(()=>p({type:"TOGGLE_EXPAND_ALL"}),[p]),P=y.useCallback(()=>T(!0),[]),z=y.useCallback(()=>{var Oe;return(Oe=C.current)==null?void 0:Oe.focus()},[]),L=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!0}),[p]),I=y.useCallback(()=>p({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[p]),M=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!1}),[p]),F=N.toggleWorkspacePanel,U=y.useCallback(()=>F(Lt.sessionInfo),[F]),O=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p]),D=m.pendingCwd??(m.pendingDirName?xs(m.pendingDirName):null),B=((Kv=m.sessionSource)==null?void 0:Kv.agentKind)??un(((Gv=m.sessionSource)==null?void 0:Gv.dirName)??m.pendingDirName??null),q=(Zv=m.session)!=null&&Zv.sessionId?h.get(m.session.sessionId):void 0,W=bn(B),H=Ob(B,q),K=zye(((Yv=m.session)==null?void 0:Yv.sessionId)??null),Z=Sa(K.level),Y=W.worktrees,J=W.mcp&&l&&Z.mcp,ee=Gve(l?((Xv=m.session)==null?void 0:Xv.cwd)??D??void 0:void 0,l&&W.slashCommands),te=y.useCallback(Oe=>{if(!l)return;const ct=ee.suggestions.find(rn=>rn.name===Oe);y.startTransition(()=>{p({type:"OPEN_CONFIG",filePath:ct==null?void 0:ct.filePath})})},[l,p,ee.suggestions]),se=y.useCallback(async(Oe,ct)=>{if(!l)return null;const rn=ee.suggestions.find(zr=>zr.name===Oe);if(!(rn!=null&&rn.filePath))return null;try{const zr=await Ce("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:rn.filePath,args:ct||""})});return zr.ok?(await zr.json()).content??null:null}catch{return null}},[l,ee.suggestions]),X=N.openWorkspacePanel,ne=y.useCallback(Oe=>{X(Oe),d&&p({type:"SET_MOBILE_TAB",tab:"workspace"})},[X,d,p]),ae=y.useCallback(()=>ne(Lt.crew),[ne]),ie=N.activeWorkspacePanel===Lt.crew&&(!d||m.mobileTab==="workspace"),{processPanel:re,currentCwd:de,showPreview:ce,showProjectFiles:oe,projectFilesRoot:fe,projectFilesRequest:ue,launchTerminalRequest:le,pendingProject:pe,handleOpenTerminal:ge,handleMcpAuth:be,handleToggleIntegratedTerminal:ve,handleNewIntegratedTerminal:Se,handleTogglePreview:we,handleToggleProjectFiles:Ee,closeRightWorkspace:$e}=lye({sessionId:(Jv=m.session)==null?void 0:Jv.sessionId,sessionCwd:(Qv=m.session)==null?void 0:Qv.cwd,pendingPath:D,sessionDirName:(ey=m.sessionSource)==null?void 0:ey.dirName,pendingDirName:m.pendingDirName,dashboardProject:m.dashboardProject,supportsFileWorkspace:c,activeWorkspacePanel:N.activeWorkspacePanel,openWorkspacePanel:ne,closeWorkspacePanel:N.closeWorkspacePanel}),Be=Wve(m.session??null),[qe,ze]=y.useState(!1),Ie=((ty=m.sessionSource)==null?void 0:ty.dirName)??m.pendingDirName??m.dashboardProject??null,{activeWorkspacePanel:Me,closeWorkspacePanel:Ue,showWorkflows:De}=N,Ke=Ove(i&&Y&&m.mainView==="sessions"&&Me===Lt.worktrees?Ie:null),Ne=y.useMemo(()=>{const Oe=m.session;return Oe?Oe.turns.some(ct=>mf(ct.toolCalls,Oe.cwd)||ct.subAgentActivity.some(rn=>mf(rn.toolCalls,Oe.cwd))):!1},[m.session]),Ae=y.useMemo(()=>{if(!m.session||!W.workflows)return 0;let Oe=0;for(const ct of m.session.turns)for(const rn of ct.toolCalls)rn.name==="Workflow"&&Oe++;return Oe},[m.session,W.workflows]),Qe=Ae>0,Je=y.useMemo(()=>{const Oe=m.sessionSource;return!Oe||!W.workflows||$o(Oe.fileName)?{dirName:null,sessionId:null}:{dirName:Oe.dirName,sessionId:Ed(Oe.fileName)}},[m.sessionSource,W.workflows]),ke=_be(Je.dirName,Je.sessionId,Qe),We=Qe||ke.workflows.length>0,ye=ke.workflows.length||Ae,Re=N.setShowWorkflows,Ve=y.useCallback(()=>Re(!0),[Re]),[He,me]=y.useState(!1);y.useEffect(()=>{if(!c)return;const Oe=()=>{d?me(!0):X(Lt.fileChanges)};return window.addEventListener(gc,Oe),()=>window.removeEventListener(gc,Oe)},[c,X,d]);const je=y.useMemo(()=>m.session?i6(m.session):null,[m.session]),Xe=y.useRef(null),{isLive:tt,sseState:dt,isCompacting:zt,streamingOverlayStore:st,turnError:Tt,agentProgress:At,promptSuggestion:Qt,rateLimit:It}=y7(m.sessionSource,Oe=>{y.startTransition(()=>{p({type:"UPDATE_SESSION",session:Oe})})},g,x,()=>{var Oe;return(Oe=Xe.current)==null?void 0:Oe.call(Xe)},m.session),Qn=Kve(((ny=m.session)==null?void 0:ny.cwd)??null),kn=Qbe(B),Lr=kn.setMode,_n=nve(H?null:((sy=m.session)==null?void 0:sy.sessionId)??null),Is=H?null:_n.plan??je,{contextWindowTokens:Ps,setContextWindowTokens:ur,contextWindowAvailable:dr,selectedModel:us,setSelectedModel:$s,selectedEffort:ki,setSelectedEffort:ji,fastModeEnabled:X7,ultracodeEnabled:J7,effectiveEffort:Ua,fastModeAvailable:Q7,fastModeActive:ru,setFastModeEnabled:Om,ultracodeAvailable:eP,ultracodeActive:ou,setUltracodeEnabled:Lm,imageInputAvailable:lv,modelFallbackNotice:tP,dismissModelFallbackNotice:cv,handleModelRejected:uv}=nye({agentKind:B,session:m.session,sessionSource:m.sessionSource,pendingDirName:m.pendingDirName,isLive:tt}),dv=Mve((ry=m.session)==null?void 0:ry.sessionId,(oy=m.sessionSource)==null?void 0:oy.fileName),Ba=iye({sessionKey:dv,sessionId:((iy=m.session)==null?void 0:iy.sessionId)??null,access:K.level,values:{model:us,effort:ki,contextWindowTokens:Ps,fastMode:X7,ultracode:J7,permissionMode:kn.config.mode},onHydrate:y.useCallback(Oe=>{ur(Oe.contextWindowTokens??null),Oe.model!==void 0&&$s(Oe.model),Oe.effort!==void 0&&ji(Oe.effort),Oe.fastMode!==void 0&&Om(Oe.fastMode),Oe.ultracode!==void 0&&Lm(Oe.ultracode),Oe.permissionMode&&Lr(Oe.permissionMode)},[ur,$s,ji,Om,Lm,Lr])}),fv=Ba.picked.includes("permissionMode")?kn.config:void 0,ds=Bve(J?de:void 0,J?Ie??void 0:void 0,J?dv??void 0:void 0,J);y.useEffect(()=>{!Y&&Me===Lt.worktrees&&Ue()},[Y,Me,Ue]),y.useEffect(()=>{De&&!We&&Re(!1)},[De,We,Re]);const{creatingSession:mv,createError:pv,clearCreateError:nP,createAndSend:sP,cancelCreation:hv,worktreeEnabled:rP,setWorktreeEnabled:oP,sessionFinalizedRef:iu,liveSessionsRefreshRef:gv,pendingSessionInfo:xv,pendingAgentKindChange:iP,handleStartNewSession:au,handleStartNewFolder:bv}=wye({permissionsConfig:kn.config,dispatch:p,isMobile:d,defaultAgentKind:e.defaultAgentKind,pendingDirName:m.pendingDirName,pendingCwd:m.pendingCwd,onModelRejected:uv,model:us,effort:Ua,contextWindowTokens:dr?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:J?ds.mcpConfigJson:null}),Dt=Ibe({sessionSource:m.sessionSource,parsedSessionId:((ay=m.session)==null?void 0:ay.sessionId)??null,cwd:(ly=m.session)==null?void 0:ly.cwd,permissions:fv,onPermissionsApplied:kn.markApplied,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,model:us,effort:Ua,contextWindowTokens:dr?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:J?ds.mcpConfigJson:null,onModelRejected:uv,readOnly:H||!Z.send,onCreateSession:m.pendingDirName?sP:void 0}),[Mm,vv]=y.useState(null),yv=y.useCallback(async(Oe,ct,rn)=>{await au(Oe,ct),vv(rn)},[au]),wv=Dt.sendMessage;y.useEffect(()=>{!Mm||!m.pendingDirName||(vv(null),wv(Mm))},[Mm,m.pendingDirName,wv]);const Sv={selectedModel:us,onModelChange:$s,selectedEffort:Ua,onEffortChange:ji},En=Nbe(W.agentTeams?((cy=m.sessionSource)==null?void 0:cy.fileName)??null:null,((uy=m.sessionSource)==null?void 0:uy.dirName)??null);y.useEffect(()=>{En!=null&&En.currentMemberName?p({type:"SET_CURRENT_MEMBER_NAME",name:En.currentMemberName}):En||p({type:"SET_CURRENT_MEMBER_NAME",name:null})},[En==null?void 0:En.currentMemberName,En,p]),y.useEffect(()=>{d&&p({type:"GUARD_MOBILE_TAB",hasSession:!!m.session||!!m.pendingDirName})},[m.session,m.pendingDirName,m.mobileTab,d,p]);const fr=j7({session:m.session,isLive:tt,pendingMessages:Dt.pendingMessages,consumePending:Dt.consumePending,sessionChangeKey:m.sessionChangeKey}),kv=fr.chatScrollRef,jv=fr.resetTurnCount,Nv=fr.scrollToBottomInstant,aP=y.useCallback(Oe=>{ze(Oe),requestAnimationFrame(()=>{const ct=kv.current;ct&&ct.scrollTo({top:ct.scrollTop+(Oe?64:-64),behavior:"smooth"})})},[kv]);y.useLayoutEffect(()=>{const Oe=ct=>{jv(0),Nv()};return iu.current=Oe,()=>{iu.current===Oe&&(iu.current=null)}},[jv,Nv,iu]);const lP=y.useCallback(()=>{Dt.disconnect(),hv()},[Dt.disconnect,hv]),ys=Rbe({dispatch:p,isMobile:d,mobileTab:m.mobileTab,teamContext:En,scrollToBottomInstant:fr.scrollToBottomInstant,resetTurnCount:fr.resetTurnCount,workerParse:g,onBeforeSwitch:lP}),cP=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"GO_HOME",isMobile:d}),p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p,d]),{previewLoadError:uP}=zbe({state:m,dispatch:p,isMobile:d,resetTurnCount:fr.resetTurnCount,scrollToBottomInstant:fr.scrollToBottomInstant,workerParse:g}),Wa=Vbe();Gbe({openSessionId:(m.sessionSource&&Nx(m.sessionSource.dirName,m.sessionSource.fileName))??((dy=m.session)==null?void 0:dy.sessionId)??null,leave:ys.handleCloseSession,forgetVisits:Wa.forget});const Cv=Wa.push;y.useEffect(()=>{m.sessionSource&&Cv(m.sessionSource.dirName,m.sessionSource.fileName)},[m.sessionSource,Cv]);const Vt=Qve({state:{session:m.session,sessionSource:m.sessionSource},dispatch:p,isMobile:d,handleJumpToTurn:ys.handleJumpToTurn,markPermissionsApplied:kn.markApplied,hasPermsPendingChanges:kn.hasPendingChanges,permissionsConfig:fv,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,selectedModel:us,selectedEffort:Ua,fastMode:ru,ultracode:ou,mcpConfig:J?ds.mcpConfigJson:null,scrollRequestScrollToTop:fr.requestScrollToTop,handleDashboardSelect:ys.handleDashboardSelect,workerParse:g,canInteract:Z.canInteract}),{hasSettingsChanges:_v,handleApplySettings:Ev}=Vt,Tv=J&&ds.mcpConfigJson!==null,Av=y.useRef(!1);y.useEffect(()=>{var rn;const Oe=ds.loaded&&!Av.current;Av.current=ds.loaded;const ct=(rn=m.session)==null?void 0:rn.sessionId;Oe&&ct&&Tv&&_v&&Ev()},[ds.loaded,Tv,_v,Ev,(fy=m.session)==null?void 0:fy.sessionId]),y.useLayoutEffect(()=>(Xe.current=Vt.reloadSession,()=>{Xe.current===Vt.reloadSession&&(Xe.current=null)}),[Vt.reloadSession]);const Mr=z7(m.session,m.sessionSource,Vt.reloadSession,c&&Z.undo),lu=Mr.requestBranchSwitch,cu=Vt.setBranchModalTurn,dP=y.useCallback((Oe,ct)=>{lu(Oe,ct),cu(null)},[lu,cu]),fP=y.useCallback(Oe=>{lu(Oe),cu(null)},[lu,cu]);Ube({isMobile:d,searchInputRef:S,chatInputRef:C,dispatch:p,onToggleSidebar:N.handleToggleSidebar,onToggleRightSidebar:U,onToggleMissionControl:N.handleToggleMission,onOpenCommandPalette:P,onOpenProjectSwitcher:N.handleOpenProjectSwitcher,onOpenThemeSelector:N.handleToggleThemeSelector,onOpenTerminal:ge,onToggleIntegratedTerminal:ve,onTogglePreview:we,onToggleProjectFiles:Ee,onHistoryBack:Wa.goBack,onHistoryForward:Wa.goForward,onNavigateToSession:ys.handleDashboardSelect,onCommitNavigation:Wa.commitNavigation});const{killing:mP,handleKillAll:pP}=Lve(),uo=m.sessionSource?$o(m.sessionSource.fileName):null,hP=uo!==null&&!!(En!=null&&En.currentMemberName),zm=uo!==null&&!hP,uu=ys.handleDashboardSelect,Iv=y.useCallback(()=>{!m.sessionSource||!uo||uu(m.sessionSource.dirName,uo.parentFileName)},[m.sessionSource,uo,uu]);y.useEffect(()=>{const Oe=ct=>{const{agentId:rn}=ct.detail??{};if(!rn||!m.sessionSource||!W.subagentTranscripts)return;const zr=uo?uo.parentSessionId:Ed(m.sessionSource.fileName);uu(m.sessionSource.dirName,`${zr}/subagents/agent-${rn}.jsonl`)};return window.addEventListener(hf,Oe),()=>window.removeEventListener(hf,Oe)},[m.sessionSource,uo,uu,W.subagentTranscripts]);const[gP,Pv]=y.useState(null),xP=Vt.branchModalTurn!==null,Ni=Vt.branchModalTurn??gP;y.useEffect(()=>{Vt.branchModalTurn!==null&&Pv(Vt.branchModalTurn)},[Vt.branchModalTurn]);const $v=Ni!==null?Mr.branchesAtTurn(Ni):[];let Ci=null;zm?Ci={kind:"subagent"}:H?Ci={kind:"external",agentKind:B}:Ci=Dye(K);const Dm=Ci&&a.jsx(Fye,{reason:Ci}),fo=((my=m.session)==null?void 0:my.sessionId)??null,_i=fo!==null&&Ci===null&&m.mainView==="sessions"&&(!d||m.mobileTab==="chat"),[bP,Fm]=y.useState(null);y.useEffect(()=>{Fm(null)},[fo,_i]);const Rv=y.useCallback(()=>{_i&&Fm(fo)},[fo,_i]),vP=y.useCallback(Oe=>{Fm(ct=>Oe?fo:ct===fo?null:ct)},[fo]),yP=ys.loadError||pv||null;let Um;ys.loadError?Um=ys.clearLoadError:pv&&(Um=nP);const wP=!!(m.session&&m.sessionSource&&dt==="disconnected"),Bm=y.useMemo(()=>({state:m,dispatch:p,config:e,theme:f,isMobile:d}),[m.activeTurnIndex,m.activeToolCallId,m.searchQuery,m.expandAll,m.expandToolPayloads,m.mainView,m.extensionViewId,m.mobileTab,m.dashboardProject,m.pendingDirName,m.pendingCwd,m.currentMemberName,m.loadingMember,m.configFilePath,m.sessionChangeKey,p,e,f,d]),Wm=y.useMemo(()=>({session:m.session,sessionSource:m.sessionSource,isLive:tt,sseState:dt,isCompacting:zt,turnError:Tt,promptSuggestion:Qt,rateLimit:It,undoRedo:Mr,pendingInteraction:Is,permissionRequests:_n.requests,permissionResponding:_n.responding,respondPermission:_n.respond,respondAllPermissions:_n.respondAll,isSubAgentView:zm,permissions:Z,slashSuggestions:ee.suggestions,slashSuggestionsLoading:ee.loading,actions:{handleStopSession:Vt.handleStopSession,handleEditConfig:l?N.handleEditConfig:void 0,handleEditCommand:l?te:void 0,handleExpandCommand:l?se:void 0,handleOpenBranches:Vt.handleOpenBranches,handleBranchFromHere:Vt.handleBranchFromHere,handleToggleExpandAll:R,handleLoadSession:Vt.handleLoadSessionScrollAware,handleProviderHandoff:_i?Rv:void 0}}),[m.session,m.sessionSource,tt,dt,zt,Tt,Qt,It,Mr,Is,zm,Z,_n.requests,_n.responding,_n.respond,_n.respondAll,ee.suggestions,ee.loading,Vt.handleStopSession,l,N.handleEditConfig,te,se,Vt.handleOpenBranches,Vt.handleBranchFromHere,R,Vt.handleLoadSessionScrollAware,_i,Rv]),qm=y.useMemo(()=>({chat:{status:Dt.status,error:Dt.error,pendingMessages:Dt.pendingMessages,isConnected:Dt.isConnected,sendMessage:Dt.sendMessage,interrupt:Dt.interrupt,stopAgent:Dt.stopAgent,consumePending:Dt.consumePending},scroll:fr}),[Dt.status,Dt.error,Dt.pendingMessages,Dt.isConnected,Dt.sendMessage,Dt.interrupt,Dt.stopAgent,Dt.consumePending,fr]),qa=!!m.pendingDirName&&!m.session;if(y.useEffect(()=>{if(!qa||d)return;const Oe=requestAnimationFrame(()=>{var ct;return(ct=C.current)==null?void 0:ct.focus()});return()=>cancelAnimationFrame(Oe)},[qa,d,m.pendingDirName]),r.failed)return a.jsx(Aye,{onRetry:r.retry});if(!t.authChecked||!r.serverReady)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Checking authentication",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated){const Oe=o.SetupScreen;return t.setupRequired&&Oe?a.jsx(Oe,{onAuthenticated:t.handleAuthenticated,onSetupClosed:t.refreshServerState}):a.jsx(Nye,{onAuthenticated:t.handleAuthenticated,setupRequired:t.setupRequired})}if(!i||!r.ready)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading identity",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(s.gate){const Oe=o.GateScreen??Eye;return a.jsxs(a.Fragment,{children:[a.jsx(Oe,{gate:s.gate,onRestored:Vye,onLogout:t.logout}),a.jsx(t2,{activeError:null,modelFallbackNotice:null,dismissModelFallbackNotice:cv,connectionLost:!1,theme:f.activeTheme})]})}if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(er,{className:"text-destructive"})}),a.jsx(zn,{children:"Failed to connect"}),a.jsx(Dn,{children:e.configError})]}),a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return l?a.jsx(Xte,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const Vm=a.jsx(t2,{activeError:yP,clearActiveError:Um,modelFallbackNotice:tP,dismissModelFallbackNotice:cv,connectionLost:wP,theme:f.activeTheme}),Ov=c?a.jsx(Bte,{state:Mr.confirmState,isApplying:Mr.isApplying,applyError:Mr.applyError,onConfirm:Mr.confirmApply,onCancel:Mr.confirmCancel}):null,SP=Ni!==null&&m.session?m.session.turns.slice(Ni):[],Lv=c&&Ni!==null&&$v.length>0&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Wye,{open:xP,branches:$v,branchPointTurnIndex:Ni,currentTurns:SP,onClose:Vt.handleCloseBranchModal,onCloseComplete:()=>Pv(null),onRedoToTurn:dP,onRedoEntireBranch:fP})}),Mv=u&&a.jsx(Ite,{processes:re.processes,activeProcessId:re.activeProcessId,collapsed:re.collapsed,onSetActive:re.setActive,onRemove:re.removeProcess,onToggleCollapse:re.toggleCollapse,onRequestTerminal:xt("terminal")?Se:void 0,onAddTerminalContext:Oe=>{var gy,xy,by;const ct=Oe.trim();if(!ct)return;const rn=ct.includes("```")?"````":"```",zr=`${rn}terminal
|
|
492
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const mye={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function q7(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:un(n.dirName)}}function pye(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...mye},rawMessages:[],agentKind:un(n.dirName)}}function V7(n,e){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:oa(xm(n),Xr(e).instanceId)}}catch{return null}}async function hye(n,e,t=3,s=100,r=!0){if(r){const o=V7(n.initialContent,n.dirName);if(o)return o}for(let o=0;o<t;o++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const i=await Ce(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(i.ok){const l=await i.text();if(l.trim())try{return{rawText:l,parsed:oa(xm(l),Xr(n.dirName).instanceId)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function gye(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await hye(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:q7(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function xye(n,e,t,s,r){const o=V7(n.initialContent,n.dirName),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??pye(n),c=q7(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),gye(n,e,t,i),n.sessionId}function bye(n){return n.access?n.access.mine:!0}async function vye(n,e,t,s){const r=Jr(),o=await Ce(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json();la(i.sessions??[],r);const l=t-3e4,c=e.trim(),u=(i.sessions??[]).filter(f=>{const m=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(m)&&m>=l&&bye(f)}),d=u.find(f=>{var m,p;return((m=f.firstUserMessage)==null?void 0:m.trim())===c||((p=f.lastUserMessage)==null?void 0:p.trim())===c})??u[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function yye({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:r,onModelRejected:o,model:i,effort:l,contextWindowTokens:c,fastMode:u,ultracode:d,mcpConfig:f}){const[m,p]=y.useState(!1),[h,g]=y.useState(null),[x,b]=y.useState(!1),w=y.useRef(null),v=y.useRef(null),j=y.useRef(null),k=y.useCallback((C,E)=>{v.current=C,j.current=E??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:C,cwd:E,isMobile:t})},[e,t]),_=y.useCallback(async(C,E)=>{var I;const T=v.current;if(!T)return null;const $=un(T),A=j.current;(I=w.current)==null||I.abort();const R=new AbortController;w.current=R,p(!0),g(null),r==null||r(C);const P=Date.now(),z=fye(C);async function L(M){v.current=null,j.current=null,WN(M.sessionId);const F=await xye(M,R,e,t,s);return z&&F&&KN(F,z),F}try{const M=Cn($),{capabilities:F}=M,U={dirName:T,cwd:M.dirName.lossy?A??void 0:void 0,message:C,images:E,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:F.ultracode&&d?!0:void 0,name:F.namedSessions&&z||void 0,worktreeName:F.worktrees&&x?s9(C):void 0,mcpConfig:F.mcp&&f||void 0},{res:O,errorMessage:D,errorCode:B}=await S7(q=>Ce("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...U,model:q}),signal:R.signal}),{model:i,agentKind:$,errorFallback:"Unknown error",onModelRejected:o});if(!O.ok){if($==="codex"&&B!=="SESSION_UNCONFIRMED"){const q=await vye(T,C,P,R);if(q)return await L(q)}return g(D||`Failed to create session (${O.status})`),null}return await L(await O.json())}catch(M){return R.signal.aborted||g(M instanceof Error?M.message:"Failed to create session"),null}finally{R.signal.aborted||p(!1)}},[n,i,l,c,u,d,f,x,e,t,s,r,o]),N=y.useCallback(()=>g(null),[]),S=y.useCallback(()=>{var C;(C=w.current)==null||C.abort(),w.current=null,v.current=null,j.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:N,handleNewSession:k,createAndSend:_,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function wye(n){const e=V.c(41),{permissionsConfig:t,dispatch:s,isMobile:r,defaultAgentKind:o,pendingDirName:i,pendingCwd:l,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p,onModelRejected:h}=n,g=y.useRef(null),x=y.useRef(null),[b,w]=y.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=W=>{var H;(H=g.current)==null||H.call(g,W),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},300),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},2e3)},e[0]=v):v=e[0];let j;e[1]!==d||e[2]!==s||e[3]!==u||e[4]!==f||e[5]!==r||e[6]!==p||e[7]!==c||e[8]!==h||e[9]!==t||e[10]!==m?(j={permissionsConfig:t,dispatch:s,isMobile:r,onSessionFinalized:v,onCreateStarted:w,onModelRejected:h,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p},e[1]=d,e[2]=s,e[3]=u,e[4]=f,e[5]=r,e[6]=p,e[7]=c,e[8]=h,e[9]=t,e[10]=m,e[11]=j):j=e[11];const k=yye(j),_=k.handleNewSession,[N,S]=y.useState(null);let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[12]=C):C=e[12];const E=y.useRef(C),T=Sye;let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=async W=>{if(pu===null)return null;const H=E.current;if(H.has(W))return H.get(W)??null;const K=fR(await T(),W,pu);return H.set(W,K),K},e[13]=$):$=e[13];const A=$;let R;e[14]!==_?(R=async(W,H)=>{var J;const K=H??((J=(await T()).find(ee=>ee.dirName===W))==null?void 0:J.path)??null;if(!K){S(null),_(W);return}if(Xr(W).instanceId!=="default"){S({discoveredDirName:null,cwd:K}),_(W,K);return}const Z=un(W)===pu?pu:null,Y=Z?Gm(Z,K):await A(K);S({discoveredDirName:Y,cwd:K}),_(Z&&Y?Y:W,K)},e[14]=_,e[15]=R):R=e[15];const P=R;let z;e[16]!==o||e[17]!==P?(z=W=>{const H=Gm(o,W);P(H,W)},e[16]=o,e[17]=P,e[18]=z):z=e[18];const L=z;let I;e[19]!==_||e[20]!==N?(I=W=>{if(!N)return;const H=Gm(W,N.cwd,N.discoveredDirName??void 0);_(H,N.cwd)},e[19]=_,e[20]=N,e[21]=I):I=e[21];const M=I;let F;e:{if(!k.creatingSession||!i){F=null;break e}const W=b??void 0;let H;e[22]!==l||e[23]!==i||e[24]!==W?(H={dirName:i,cwd:l,firstMessage:W},e[22]=l,e[23]=i,e[24]=W,e[25]=H):H=e[25],F=H}const U=F;let O,D;e[26]!==i?(D=()=>{i||(w(null),S(null))},O=[i],e[26]=i,e[27]=O,e[28]=D):(O=e[27],D=e[28]),y.useEffect(D,O);const B=N?M:void 0;let q;return e[29]!==L||e[30]!==P||e[31]!==k.cancelCreation||e[32]!==k.clearCreateError||e[33]!==k.createAndSend||e[34]!==k.createError||e[35]!==k.creatingSession||e[36]!==k.setWorktreeEnabled||e[37]!==k.worktreeEnabled||e[38]!==U||e[39]!==B?(q={creatingSession:k.creatingSession,createError:k.createError,clearCreateError:k.clearCreateError,createAndSend:k.createAndSend,cancelCreation:k.cancelCreation,worktreeEnabled:k.worktreeEnabled,setWorktreeEnabled:k.setWorktreeEnabled,sessionFinalizedRef:g,liveSessionsRefreshRef:x,pendingSessionInfo:U,pendingAgentKindChange:B,handleStartNewSession:P,handleStartNewFolder:L},e[29]=L,e[30]=P,e[31]=k.cancelCreation,e[32]=k.clearCreateError,e[33]=k.createAndSend,e[34]=k.createError,e[35]=k.creatingSession,e[36]=k.setWorktreeEnabled,e[37]=k.worktreeEnabled,e[38]=U,e[39]=B,e[40]=q):q=e[40],q}async function Sye(){try{const n=await Ce("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const pg=new Set;function kye(n,e){const t=cn(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function jye(n,e,t){const s=kye(n,e);if(!pg.has(s)&&!js.get(n,e)){pg.add(s);try{await ka(n,e,t,"session prefetch",{background:!0})}catch{}finally{pg.delete(s)}}}function Nye({onAuthenticated:n,setupRequired:e=!1}){const[t,s]=y.useState(null),[r,o]=y.useState(""),[i,l]=y.useState(""),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),h=t==="account",{LoginNotice:g}=$r();y.useEffect(()=>{let w=!1;return pN().then(v=>{w||s(v)}),()=>{w=!0}},[]);const x=y.useCallback(async w=>{if(w.preventDefault(),!(!i.trim()||h&&!r.trim())){p(!0),f(null);try{const v=await fetch("/api/auth/verify",h?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:r.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),j=await v.json();v.ok&&j.valid?(Tf(),l(""),o(""),n()):f(j.error||(h?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{p(!1)}}},[h,n,i,r]),b=m||!i.trim()||h&&!r.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:x,className:"w-full max-w-sm",children:a.jsxs(Ds,{children:[a.jsxs(xr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(W8,{className:"size-4"})}),a.jsx(br,{children:"Sign in to Cogpit"}),a.jsx(vr,{children:h?"Sign in with your account to continue.":"Enter the server password to continue."})]}),t===null?a.jsx(Fs,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(Fs,{className:"flex flex-col gap-4",children:[e&&a.jsxs(kt,{children:[a.jsx(yf,{"aria-hidden":"true"}),a.jsx(_t,{children:"This server has no accounts yet."})]}),a.jsxs(Aa,{children:[h&&a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-username",children:"Username"}),a.jsx(On,{id:"login-username",type:"text",value:r,onChange:w=>o(w.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"login-password",children:"Password"}),a.jsxs(Ko,{children:[a.jsx(Go,{id:"login-password",type:c?"text":"password",value:i,onChange:w=>l(w.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!h}),a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>u(w=>!w),"aria-label":c?"Hide password":"Show password",children:c?a.jsx(fx,{}):a.jsx(Na,{})})})]})]})]}),h&&g&&a.jsx(g,{}),d&&a.jsxs(kt,{variant:"destructive",children:[a.jsx(Sr,{"aria-hidden":"true"}),a.jsx(Xt,{children:"Sign in failed"}),a.jsx(_t,{children:d})]})]}),a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:b,children:[m&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}function Cye(){const n=V.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=Ef(),n[0]=e):e=n[0];const t=e,[s,r]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(0);let d,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let $=!1;return mN().then(A=>{$||r(A)}),()=>{$=!0}},f=[],n[1]=d,n[2]=f):(d=n[1],f=n[2]),y.useEffect(d,f);const m=t?!0:s===null?null:s.signIn==="account";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){i(!0),c(!0);return}let $=!1;const A=u.current;return RR().then(R=>{!$&&u.current===A&&(i(R),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.signIn)?(g=()=>{let $=!1;const A=()=>{const R=u.current=u.current+1,P=()=>{$||u.current!==R||(i(!1),c(!0))};if(t||(s==null?void 0:s.signIn)==="account"){P();return}Ty().then(z=>{$||u.current!==R||(r(z),z.signIn==="account"&&P())})};return window.addEventListener("cogpit-auth-required",A),()=>{$=!0,window.removeEventListener("cogpit-auth-required",A)}},n[6]=s==null?void 0:s.signIn,n[7]=g):g=n[7];const x=s==null?void 0:s.signIn;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let j;n[11]===Symbol.for("react.memo_cache_sentinel")?(j=async()=>{r(await Ty())},n[11]=j):j=n[11];const k=j;let _;n[12]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{V9(),u.current=u.current+1,i(!1),c(!0),OR().finally(_ye)},n[12]=_):_=n[12];const N=_,S=(s==null?void 0:s.edition)??null,C=l&&s!==null,E=(s==null?void 0:s.setupRequired)===!0;let T;return n[13]!==o||n[14]!==S||n[15]!==C||n[16]!==E?(T={isRemote:t,edition:S,authChecked:C,authenticated:o,setupRequired:E,handleAuthenticated:v,refreshServerState:k,logout:N},n[13]=o,n[14]=S,n[15]=C,n[16]=E,n[17]=T):T=n[17],T}function _ye(){window.dispatchEvent(new Event("cogpit-auth-changed"))}function Eye(n){const e=V.c(18),{onRestored:t,onLogout:s}=n,{activeDevice:r,activeDeviceId:o}=Si();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=qo(),e[0]=i):i=e[0];const l=i,c=l?(r==null?void 0:r.name)??o:"This server";let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Yn,{variant:"icon",children:a.jsx(lx,{className:"text-destructive"})}),e[1]=u):u=e[1];let d;e[2]!==c?(d=a.jsxs(zn,{children:[c," isn’t available to your account right now"]}),e[2]=c,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Dn,{children:"Its administrator can let you back in. Check again once they have."}),e[4]=f):f=e[4];let m;e[5]!==d?(m=a.jsxs(Mn,{children:[u,d,f]}),e[5]=d,e[6]=m):m=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Fn,{"data-icon":"inline-start"}),e[7]=p):p=e[7];let h;e[8]!==t?(h=a.jsxs(Q,{size:"sm",onClick:t,children:[p,"Check again"]}),e[8]=t,e[9]=h):h=e[9];let g;e[10]!==s?(g=l?a.jsxs(Q,{variant:"outline",size:"sm",onClick:Tye,children:[a.jsx(yg,{"data-icon":"inline-start"}),"Switch to this machine"]}):a.jsxs(Q,{variant:"outline",size:"sm",onClick:s,children:[a.jsx(q8,{"data-icon":"inline-start"}),"Sign out"]}),e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h||e[13]!==g?(x=a.jsxs(_c,{className:"flex-row justify-center",children:[h,g]}),e[12]=h,e[13]=g,e[14]=x):x=e[14];let b;return e[15]!==m||e[16]!==x?(b=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[m,x]})}),e[15]=m,e[16]=x,e[17]=b):b=e[17],b}function Tye(){return Xs(Ot)}function Aye(n){const e=V.c(4),{onRetry:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(V8,{className:"text-destructive"})}),a.jsx(zn,{children:"Cogpit couldn’t finish loading"}),a.jsx(Dn,{children:"Part of this server’s interface didn’t download. Check your connection and try again."})]}),e[0]=s):s=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fn,{"data-icon":"inline-start"}),e[1]=r):r=e[1];let o;return e[2]!==t?(o=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[s,a.jsx(_c,{className:"flex-row justify-center",children:a.jsxs(Q,{size:"sm",onClick:t,children:[r,"Retry"]})})]})}),e[2]=t,e[3]=o):o=e[3],o}const J1="cogpit:edition-ui-reloaded";let hg=null;function Iye(){return hg??(hg=nt(()=>import("./edition-ui-CFxEM3WF.js"),__vite__mapDeps([42,1,2,29,3,4])).then(n=>n.default,n=>{throw hg=null,n})),hg}function Pye(){try{if(sessionStorage.getItem(J1)!==null)return!1;sessionStorage.setItem(J1,"1")}catch{return!1}return window.location.reload(),!0}function H7(){try{sessionStorage.removeItem(J1)}catch{}}async function $ye(n,e){let t;try{t=await Iye()}catch{return e&&Pye()?"reloading":"failed"}return H7(),(t==null?void 0:t.edition)===n?t:null}async function K7(n,e,t){G9();const s=await $ye(n,t);s!=="reloading"&&(s==="failed"&&e?(H7(),Y9()):s===null||s==="failed"?Z9():K9(s))}async function Rye(n,{required:e=!1}={}){if(n==="personal")return;const t=ec();t==="installed"||t==="loading"||t==="failed"||await K7(n,e,!0)}async function Oye(n){ec()==="failed"&&await K7(n,!0,!1)}function a4(n){return n==="personal"?null:n}function Lye(n,e){const t=V.c(16),s=y.useSyncExternalStore(Vx,ec,ec);let r;t[0]!==n?(r=a4(n),t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==e||t[3]!==o?(i=o??a4(e),t[2]=e,t[3]=o,t[4]=i):i=t[4];const l=i,c=o!==null;let u,d;t[5]!==c||t[6]!==l?(u=()=>{l!==null&&Rye(l,{required:c})},d=[l,c],t[5]=c,t[6]=l,t[7]=u,t[8]=d):(u=t[7],d=t[8]),y.useEffect(u,d);let f;t[9]!==l?(f=()=>{l!==null&&Oye(l)},t[9]=l,t[10]=f):f=t[10];const m=f,p=s==="installed"||s==="unavailable",h=o===null||p,g=l===null||p,x=c&&s==="failed";let b;return t[11]!==m||t[12]!==h||t[13]!==g||t[14]!==x?(b={serverReady:h,ready:g,failed:x,retry:m},t[11]=m,t[12]=h,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}const G7={level:"own"},l4={level:"unknown"},Mye={none:{level:"none"},view:{level:"view"},interact:{level:"interact"},own:G7};function zye(n){const e=V.c(5),{enforcesSessionAccess:t}=PN(),s=t?n:null;let r;e[0]!==s?(r=()=>s?aO(s):void 0,e[0]=s,e[1]=r):r=e[1];const o=r,i=y.useSyncExternalStore(cO,o,o);let l,c;return e[2]!==s?(l=()=>s?mO(s):void 0,c=[s],e[2]=s,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c),t===null?l4:s?i?Mye[i]:l4:G7}function Dye({level:n}){return n==="unknown"?{kind:"checking"}:n==="none"?{kind:"no-access"}:Sa(n).canInteract?null:{kind:"view-only"}}function Fye(n){const e=V.c(8),{reason:t}=n;switch(t.kind){case"subagent":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:mi,children:"Viewing sub-agent session (read-only)"}),e[0]=s):s=e[0],s}case"external":{let s;e[1]!==t.agentKind?(s=TM(t.agentKind),e[1]=t.agentKind,e[2]=s):s=e[2];let r;return e[3]!==s?(r=a.jsx(wd,{icon:mi,status:!0,children:s}),e[3]=s,e[4]=r):r=e[4],r}case"no-access":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(wd,{icon:K8,status:!0,children:"You don't have access to this session"}),e[5]=s):s=e[5],s}case"checking":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(c4,{icon:H8,children:"Checking access…"}),e[6]=s):s=e[6],s}case"view-only":{let s;return e[7]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(c4,{icon:Na,children:a.jsx(Uye,{})}),e[7]=s):s=e[7],s}}}function Uye(){const n=V.c(3),{ReadOnlyNote:e}=$r(),{session:t}=jt();let s;return n[0]!==e||n[1]!==t?(s=e&&t?a.jsx(e,{sessionId:t.sessionId}):"View only",n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function c4(n){const e=V.c(4),{icon:t,children:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Bye,{}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==t?(o=a.jsxs("div",{className:"shrink-0",children:[r,a.jsx(wd,{icon:t,status:!0,children:s})]}),e[1]=s,e[2]=t,e[3]=o):o=e[3],o}function Bye(){const n=V.c(7),{pendingInteraction:e,permissionRequests:t}=jt(),s=(e==null?void 0:e.type)==="plan"?e:null;if(!s&&t.length===0)return null;let r;n[0]!==s?(r=s&&a.jsx($5,{allowedPrompts:s.allowedPrompts,summary:s.summary,planContent:s.planContent}),n[0]=s,n[1]=r):r=n[1];let o;n[2]!==t?(o=t.length>0&&a.jsx("div",{className:"mb-2 overflow-hidden rounded-xl border border-warning/40 bg-popover",children:a.jsx(R5,{requests:t})}),n[2]=t,n[3]=o):o=n[3];let i;return n[4]!==r||n[5]!==o?(i=a.jsxs("div",{className:"px-3 pt-2",children:[r,o]}),n[4]=r,n[5]=o,n[6]=i):i=n[6],i}function wd(n){const e=V.c(8),{icon:t,status:s,children:r}=n,i=(s===void 0?!1:s)?"status":void 0;let l;e[0]!==t?(l=a.jsx(t,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==r?(c=a.jsx("span",{className:"text-xs text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==l||e[6]!==c?(u=a.jsxs("div",{role:i,className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[l,c]}),e[4]=i,e[5]=l,e[6]=c,e[7]=u):u=e[7],u}const Wye=y.lazy(()=>nt(()=>import("./index-By5-_P50.js"),__vite__mapDeps([43,1,2,3,4])).then(n=>({default:n.BranchModal}))),qye=y.lazy(()=>nt(()=>import("./WorkflowsPanel-aOz1o3kA.js"),__vite__mapDeps([44,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function Vye(){window.location.reload()}function Hye(){var qv,Vv,Hv,Kv,Gv,Zv,Yv,Xv,Jv,Qv,ey,ty,ny,sy,ry,oy,iy,ay,ly,cy,uy,dy,fy,my,py,hy;const n=av(window.location.pathname),e=Sve(),t=Cye(),s=Ave(t.edition),r=Lye(t.edition,s.edition),o=$r(),i=s.checked&&(s.edition==="personal"||s.user!==null),l=i&&s.capabilities.configWrite,c=i&&s.capabilities.hostFiles,u=i&&s.capabilities.terminal,d=rv(),f=E7(),[m,p]=k7(),{procBySession:h}=Kx(),{parse:g,append:x}=B7(),b=y.useCallback(Oe=>{p({type:"SET_OLDER_TURNS",turns:Oe})},[p]),w=y.useCallback((Oe,ct)=>{jye(Oe,ct,g)},[g]),v=W7({dirName:((qv=m.sessionSource)==null?void 0:qv.dirName)??null,fileName:((Vv=m.sessionSource)==null?void 0:Vv.fileName)??null,sessionChangeKey:m.sessionChangeKey,workerParse:g,onOlderTurns:b}),{loadMore:j}=v,k=!!m.searchQuery&&v.hasMore,_=((Hv=m.session)==null?void 0:Hv.turns.length)??0;y.useEffect(()=>{k&&j()},[k,j,_]);const N=Yve(m,p),S=y.useRef(null),C=y.useRef(null),[E,T]=y.useState(!1),[$,A]=y.useState(!1),R=y.useCallback(()=>p({type:"TOGGLE_EXPAND_ALL"}),[p]),P=y.useCallback(()=>T(!0),[]),z=y.useCallback(()=>{var Oe;return(Oe=C.current)==null?void 0:Oe.focus()},[]),L=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!0}),[p]),I=y.useCallback(()=>p({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[p]),M=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!1}),[p]),F=N.toggleWorkspacePanel,U=y.useCallback(()=>F(Lt.sessionInfo),[F]),O=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p]),D=m.pendingCwd??(m.pendingDirName?xs(m.pendingDirName):null),B=((Kv=m.sessionSource)==null?void 0:Kv.agentKind)??un(((Gv=m.sessionSource)==null?void 0:Gv.dirName)??m.pendingDirName??null),q=(Zv=m.session)!=null&&Zv.sessionId?h.get(m.session.sessionId):void 0,W=bn(B),H=Ob(B,q),K=zye(((Yv=m.session)==null?void 0:Yv.sessionId)??null),Z=Sa(K.level),Y=W.worktrees,J=W.mcp&&l&&Z.mcp,ee=Gve(l?((Xv=m.session)==null?void 0:Xv.cwd)??D??void 0:void 0,l&&W.slashCommands),te=y.useCallback(Oe=>{if(!l)return;const ct=ee.suggestions.find(rn=>rn.name===Oe);y.startTransition(()=>{p({type:"OPEN_CONFIG",filePath:ct==null?void 0:ct.filePath})})},[l,p,ee.suggestions]),se=y.useCallback(async(Oe,ct)=>{if(!l)return null;const rn=ee.suggestions.find(zr=>zr.name===Oe);if(!(rn!=null&&rn.filePath))return null;try{const zr=await Ce("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:rn.filePath,args:ct||""})});return zr.ok?(await zr.json()).content??null:null}catch{return null}},[l,ee.suggestions]),X=N.openWorkspacePanel,ne=y.useCallback(Oe=>{X(Oe),d&&p({type:"SET_MOBILE_TAB",tab:"workspace"})},[X,d,p]),ae=y.useCallback(()=>ne(Lt.crew),[ne]),ie=N.activeWorkspacePanel===Lt.crew&&(!d||m.mobileTab==="workspace"),{processPanel:re,currentCwd:de,showPreview:ce,showProjectFiles:oe,projectFilesRoot:fe,projectFilesRequest:ue,launchTerminalRequest:le,pendingProject:pe,handleOpenTerminal:ge,handleMcpAuth:be,handleToggleIntegratedTerminal:ve,handleNewIntegratedTerminal:Se,handleTogglePreview:we,handleToggleProjectFiles:Ee,closeRightWorkspace:$e}=lye({sessionId:(Jv=m.session)==null?void 0:Jv.sessionId,sessionCwd:(Qv=m.session)==null?void 0:Qv.cwd,pendingPath:D,sessionDirName:(ey=m.sessionSource)==null?void 0:ey.dirName,pendingDirName:m.pendingDirName,dashboardProject:m.dashboardProject,supportsFileWorkspace:c,activeWorkspacePanel:N.activeWorkspacePanel,openWorkspacePanel:ne,closeWorkspacePanel:N.closeWorkspacePanel}),Be=Wve(m.session??null),[qe,ze]=y.useState(!1),Ie=((ty=m.sessionSource)==null?void 0:ty.dirName)??m.pendingDirName??m.dashboardProject??null,{activeWorkspacePanel:Me,closeWorkspacePanel:Ue,showWorkflows:De}=N,Ke=Ove(i&&Y&&m.mainView==="sessions"&&Me===Lt.worktrees?Ie:null),Ne=y.useMemo(()=>{const Oe=m.session;return Oe?Oe.turns.some(ct=>mf(ct.toolCalls,Oe.cwd)||ct.subAgentActivity.some(rn=>mf(rn.toolCalls,Oe.cwd))):!1},[m.session]),Ae=y.useMemo(()=>{if(!m.session||!W.workflows)return 0;let Oe=0;for(const ct of m.session.turns)for(const rn of ct.toolCalls)rn.name==="Workflow"&&Oe++;return Oe},[m.session,W.workflows]),Qe=Ae>0,Je=y.useMemo(()=>{const Oe=m.sessionSource;return!Oe||!W.workflows||$o(Oe.fileName)?{dirName:null,sessionId:null}:{dirName:Oe.dirName,sessionId:Ed(Oe.fileName)}},[m.sessionSource,W.workflows]),ke=_be(Je.dirName,Je.sessionId,Qe),We=Qe||ke.workflows.length>0,ye=ke.workflows.length||Ae,Re=N.setShowWorkflows,Ve=y.useCallback(()=>Re(!0),[Re]),[He,me]=y.useState(!1);y.useEffect(()=>{if(!c)return;const Oe=()=>{d?me(!0):X(Lt.fileChanges)};return window.addEventListener(gc,Oe),()=>window.removeEventListener(gc,Oe)},[c,X,d]);const je=y.useMemo(()=>m.session?i6(m.session):null,[m.session]),Xe=y.useRef(null),{isLive:tt,sseState:dt,isCompacting:zt,streamingOverlayStore:st,turnError:Tt,agentProgress:At,promptSuggestion:Qt,rateLimit:It}=y7(m.sessionSource,Oe=>{y.startTransition(()=>{p({type:"UPDATE_SESSION",session:Oe})})},g,x,()=>{var Oe;return(Oe=Xe.current)==null?void 0:Oe.call(Xe)},m.session),Qn=Kve(((ny=m.session)==null?void 0:ny.cwd)??null),kn=Qbe(B),Lr=kn.setMode,_n=nve(H?null:((sy=m.session)==null?void 0:sy.sessionId)??null),Is=H?null:_n.plan??je,{contextWindowTokens:Ps,setContextWindowTokens:ur,contextWindowAvailable:dr,selectedModel:us,setSelectedModel:$s,selectedEffort:ki,setSelectedEffort:ji,fastModeEnabled:X7,ultracodeEnabled:J7,effectiveEffort:Ua,fastModeAvailable:Q7,fastModeActive:ru,setFastModeEnabled:Om,ultracodeAvailable:eP,ultracodeActive:ou,setUltracodeEnabled:Lm,imageInputAvailable:lv,modelFallbackNotice:tP,dismissModelFallbackNotice:cv,handleModelRejected:uv}=nye({agentKind:B,session:m.session,sessionSource:m.sessionSource,pendingDirName:m.pendingDirName,isLive:tt}),dv=Mve((ry=m.session)==null?void 0:ry.sessionId,(oy=m.sessionSource)==null?void 0:oy.fileName),Ba=iye({sessionKey:dv,sessionId:((iy=m.session)==null?void 0:iy.sessionId)??null,access:K.level,values:{model:us,effort:ki,contextWindowTokens:Ps,fastMode:X7,ultracode:J7,permissionMode:kn.config.mode},onHydrate:y.useCallback(Oe=>{ur(Oe.contextWindowTokens??null),Oe.model!==void 0&&$s(Oe.model),Oe.effort!==void 0&&ji(Oe.effort),Oe.fastMode!==void 0&&Om(Oe.fastMode),Oe.ultracode!==void 0&&Lm(Oe.ultracode),Oe.permissionMode&&Lr(Oe.permissionMode)},[ur,$s,ji,Om,Lm,Lr])}),fv=Ba.picked.includes("permissionMode")?kn.config:void 0,ds=Bve(J?de:void 0,J?Ie??void 0:void 0,J?dv??void 0:void 0,J);y.useEffect(()=>{!Y&&Me===Lt.worktrees&&Ue()},[Y,Me,Ue]),y.useEffect(()=>{De&&!We&&Re(!1)},[De,We,Re]);const{creatingSession:mv,createError:pv,clearCreateError:nP,createAndSend:sP,cancelCreation:hv,worktreeEnabled:rP,setWorktreeEnabled:oP,sessionFinalizedRef:iu,liveSessionsRefreshRef:gv,pendingSessionInfo:xv,pendingAgentKindChange:iP,handleStartNewSession:au,handleStartNewFolder:bv}=wye({permissionsConfig:kn.config,dispatch:p,isMobile:d,defaultAgentKind:e.defaultAgentKind,pendingDirName:m.pendingDirName,pendingCwd:m.pendingCwd,onModelRejected:uv,model:us,effort:Ua,contextWindowTokens:dr?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:J?ds.mcpConfigJson:null}),Dt=Ibe({sessionSource:m.sessionSource,parsedSessionId:((ay=m.session)==null?void 0:ay.sessionId)??null,cwd:(ly=m.session)==null?void 0:ly.cwd,permissions:fv,onPermissionsApplied:kn.markApplied,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,model:us,effort:Ua,contextWindowTokens:dr?Ps:void 0,fastMode:ru,ultracode:ou,mcpConfig:J?ds.mcpConfigJson:null,onModelRejected:uv,readOnly:H||!Z.send,onCreateSession:m.pendingDirName?sP:void 0}),[Mm,vv]=y.useState(null),yv=y.useCallback(async(Oe,ct,rn)=>{await au(Oe,ct),vv(rn)},[au]),wv=Dt.sendMessage;y.useEffect(()=>{!Mm||!m.pendingDirName||(vv(null),wv(Mm))},[Mm,m.pendingDirName,wv]);const Sv={selectedModel:us,onModelChange:$s,selectedEffort:Ua,onEffortChange:ji},En=Nbe(W.agentTeams?((cy=m.sessionSource)==null?void 0:cy.fileName)??null:null,((uy=m.sessionSource)==null?void 0:uy.dirName)??null);y.useEffect(()=>{En!=null&&En.currentMemberName?p({type:"SET_CURRENT_MEMBER_NAME",name:En.currentMemberName}):En||p({type:"SET_CURRENT_MEMBER_NAME",name:null})},[En==null?void 0:En.currentMemberName,En,p]),y.useEffect(()=>{d&&p({type:"GUARD_MOBILE_TAB",hasSession:!!m.session||!!m.pendingDirName})},[m.session,m.pendingDirName,m.mobileTab,d,p]);const fr=j7({session:m.session,isLive:tt,pendingMessages:Dt.pendingMessages,consumePending:Dt.consumePending,sessionChangeKey:m.sessionChangeKey}),kv=fr.chatScrollRef,jv=fr.resetTurnCount,Nv=fr.scrollToBottomInstant,aP=y.useCallback(Oe=>{ze(Oe),requestAnimationFrame(()=>{const ct=kv.current;ct&&ct.scrollTo({top:ct.scrollTop+(Oe?64:-64),behavior:"smooth"})})},[kv]);y.useLayoutEffect(()=>{const Oe=ct=>{jv(0),Nv()};return iu.current=Oe,()=>{iu.current===Oe&&(iu.current=null)}},[jv,Nv,iu]);const lP=y.useCallback(()=>{Dt.disconnect(),hv()},[Dt.disconnect,hv]),ys=Rbe({dispatch:p,isMobile:d,mobileTab:m.mobileTab,teamContext:En,scrollToBottomInstant:fr.scrollToBottomInstant,resetTurnCount:fr.resetTurnCount,workerParse:g,onBeforeSwitch:lP}),cP=y.useCallback(Oe=>{y.startTransition(()=>{p({type:"GO_HOME",isMobile:d}),p({type:"SET_DASHBOARD_PROJECT",dirName:Oe})})},[p,d]),{previewLoadError:uP}=zbe({state:m,dispatch:p,isMobile:d,resetTurnCount:fr.resetTurnCount,scrollToBottomInstant:fr.scrollToBottomInstant,workerParse:g}),Wa=Vbe();Gbe({openSessionId:(m.sessionSource&&Nx(m.sessionSource.dirName,m.sessionSource.fileName))??((dy=m.session)==null?void 0:dy.sessionId)??null,leave:ys.handleCloseSession,forgetVisits:Wa.forget});const Cv=Wa.push;y.useEffect(()=>{m.sessionSource&&Cv(m.sessionSource.dirName,m.sessionSource.fileName)},[m.sessionSource,Cv]);const Vt=Qve({state:{session:m.session,sessionSource:m.sessionSource},dispatch:p,isMobile:d,handleJumpToTurn:ys.handleJumpToTurn,markPermissionsApplied:kn.markApplied,hasPermsPendingChanges:kn.hasPendingChanges,permissionsConfig:fv,settingsChange:Ba.picked,onSettingsChangeSent:Ba.settlePicked,selectedModel:us,selectedEffort:Ua,fastMode:ru,ultracode:ou,mcpConfig:J?ds.mcpConfigJson:null,scrollRequestScrollToTop:fr.requestScrollToTop,handleDashboardSelect:ys.handleDashboardSelect,workerParse:g,canInteract:Z.canInteract}),{hasSettingsChanges:_v,handleApplySettings:Ev}=Vt,Tv=J&&ds.mcpConfigJson!==null,Av=y.useRef(!1);y.useEffect(()=>{var rn;const Oe=ds.loaded&&!Av.current;Av.current=ds.loaded;const ct=(rn=m.session)==null?void 0:rn.sessionId;Oe&&ct&&Tv&&_v&&Ev()},[ds.loaded,Tv,_v,Ev,(fy=m.session)==null?void 0:fy.sessionId]),y.useLayoutEffect(()=>(Xe.current=Vt.reloadSession,()=>{Xe.current===Vt.reloadSession&&(Xe.current=null)}),[Vt.reloadSession]);const Mr=z7(m.session,m.sessionSource,Vt.reloadSession,c&&Z.undo),lu=Mr.requestBranchSwitch,cu=Vt.setBranchModalTurn,dP=y.useCallback((Oe,ct)=>{lu(Oe,ct),cu(null)},[lu,cu]),fP=y.useCallback(Oe=>{lu(Oe),cu(null)},[lu,cu]);Ube({isMobile:d,searchInputRef:S,chatInputRef:C,dispatch:p,onToggleSidebar:N.handleToggleSidebar,onToggleRightSidebar:U,onToggleMissionControl:N.handleToggleMission,onOpenCommandPalette:P,onOpenProjectSwitcher:N.handleOpenProjectSwitcher,onOpenThemeSelector:N.handleToggleThemeSelector,onOpenTerminal:ge,onToggleIntegratedTerminal:ve,onTogglePreview:we,onToggleProjectFiles:Ee,onHistoryBack:Wa.goBack,onHistoryForward:Wa.goForward,onNavigateToSession:ys.handleDashboardSelect,onCommitNavigation:Wa.commitNavigation});const{killing:mP,handleKillAll:pP}=Lve(),uo=m.sessionSource?$o(m.sessionSource.fileName):null,hP=uo!==null&&!!(En!=null&&En.currentMemberName),zm=uo!==null&&!hP,uu=ys.handleDashboardSelect,Iv=y.useCallback(()=>{!m.sessionSource||!uo||uu(m.sessionSource.dirName,uo.parentFileName)},[m.sessionSource,uo,uu]);y.useEffect(()=>{const Oe=ct=>{const{agentId:rn}=ct.detail??{};if(!rn||!m.sessionSource||!W.subagentTranscripts)return;const zr=uo?uo.parentSessionId:Ed(m.sessionSource.fileName);uu(m.sessionSource.dirName,`${zr}/subagents/agent-${rn}.jsonl`)};return window.addEventListener(hf,Oe),()=>window.removeEventListener(hf,Oe)},[m.sessionSource,uo,uu,W.subagentTranscripts]);const[gP,Pv]=y.useState(null),xP=Vt.branchModalTurn!==null,Ni=Vt.branchModalTurn??gP;y.useEffect(()=>{Vt.branchModalTurn!==null&&Pv(Vt.branchModalTurn)},[Vt.branchModalTurn]);const $v=Ni!==null?Mr.branchesAtTurn(Ni):[];let Ci=null;zm?Ci={kind:"subagent"}:H?Ci={kind:"external",agentKind:B}:Ci=Dye(K);const Dm=Ci&&a.jsx(Fye,{reason:Ci}),fo=((my=m.session)==null?void 0:my.sessionId)??null,_i=fo!==null&&Ci===null&&m.mainView==="sessions"&&(!d||m.mobileTab==="chat"),[bP,Fm]=y.useState(null);y.useEffect(()=>{Fm(null)},[fo,_i]);const Rv=y.useCallback(()=>{_i&&Fm(fo)},[fo,_i]),vP=y.useCallback(Oe=>{Fm(ct=>Oe?fo:ct===fo?null:ct)},[fo]),yP=ys.loadError||pv||null;let Um;ys.loadError?Um=ys.clearLoadError:pv&&(Um=nP);const wP=!!(m.session&&m.sessionSource&&dt==="disconnected"),Bm=y.useMemo(()=>({state:m,dispatch:p,config:e,theme:f,isMobile:d}),[m.activeTurnIndex,m.activeToolCallId,m.searchQuery,m.expandAll,m.expandToolPayloads,m.mainView,m.extensionViewId,m.mobileTab,m.dashboardProject,m.pendingDirName,m.pendingCwd,m.currentMemberName,m.loadingMember,m.configFilePath,m.sessionChangeKey,p,e,f,d]),Wm=y.useMemo(()=>({session:m.session,sessionSource:m.sessionSource,isLive:tt,sseState:dt,isCompacting:zt,turnError:Tt,promptSuggestion:Qt,rateLimit:It,undoRedo:Mr,pendingInteraction:Is,permissionRequests:_n.requests,permissionResponding:_n.responding,respondPermission:_n.respond,respondAllPermissions:_n.respondAll,isSubAgentView:zm,permissions:Z,slashSuggestions:ee.suggestions,slashSuggestionsLoading:ee.loading,actions:{handleStopSession:Vt.handleStopSession,handleEditConfig:l?N.handleEditConfig:void 0,handleEditCommand:l?te:void 0,handleExpandCommand:l?se:void 0,handleOpenBranches:Vt.handleOpenBranches,handleBranchFromHere:Vt.handleBranchFromHere,handleToggleExpandAll:R,handleLoadSession:Vt.handleLoadSessionScrollAware,handleProviderHandoff:_i?Rv:void 0}}),[m.session,m.sessionSource,tt,dt,zt,Tt,Qt,It,Mr,Is,zm,Z,_n.requests,_n.responding,_n.respond,_n.respondAll,ee.suggestions,ee.loading,Vt.handleStopSession,l,N.handleEditConfig,te,se,Vt.handleOpenBranches,Vt.handleBranchFromHere,R,Vt.handleLoadSessionScrollAware,_i,Rv]),qm=y.useMemo(()=>({chat:{status:Dt.status,error:Dt.error,pendingMessages:Dt.pendingMessages,isConnected:Dt.isConnected,sendMessage:Dt.sendMessage,interrupt:Dt.interrupt,stopAgent:Dt.stopAgent,consumePending:Dt.consumePending},scroll:fr}),[Dt.status,Dt.error,Dt.pendingMessages,Dt.isConnected,Dt.sendMessage,Dt.interrupt,Dt.stopAgent,Dt.consumePending,fr]),qa=!!m.pendingDirName&&!m.session;if(y.useEffect(()=>{if(!qa||d)return;const Oe=requestAnimationFrame(()=>{var ct;return(ct=C.current)==null?void 0:ct.focus()});return()=>cancelAnimationFrame(Oe)},[qa,d,m.pendingDirName]),r.failed)return a.jsx(Aye,{onRetry:r.retry});if(!t.authChecked||!r.serverReady)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Checking authentication",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated){const Oe=o.SetupScreen;return t.setupRequired&&Oe?a.jsx(Oe,{onAuthenticated:t.handleAuthenticated,onSetupClosed:t.refreshServerState}):a.jsx(Nye,{onAuthenticated:t.handleAuthenticated,setupRequired:t.setupRequired})}if(!i||!r.ready)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading identity",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(s.gate){const Oe=o.GateScreen??Eye;return a.jsxs(a.Fragment,{children:[a.jsx(Oe,{gate:s.gate,onRestored:Vye,onLogout:t.logout}),a.jsx(t2,{activeError:null,modelFallbackNotice:null,dismissModelFallbackNotice:cv,connectionLost:!1,theme:f.activeTheme})]})}if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading",children:a.jsx(St,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Ln,{children:[a.jsxs(Mn,{children:[a.jsx(Yn,{variant:"icon",children:a.jsx(er,{className:"text-destructive"})}),a.jsx(zn,{children:"Failed to connect"}),a.jsx(Dn,{children:e.configError})]}),a.jsx(_c,{children:a.jsxs(Q,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return l?a.jsx(Xte,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const Vm=a.jsx(t2,{activeError:yP,clearActiveError:Um,modelFallbackNotice:tP,dismissModelFallbackNotice:cv,connectionLost:wP,theme:f.activeTheme}),Ov=c?a.jsx(Bte,{state:Mr.confirmState,isApplying:Mr.isApplying,applyError:Mr.applyError,onConfirm:Mr.confirmApply,onCancel:Mr.confirmCancel}):null,SP=Ni!==null&&m.session?m.session.turns.slice(Ni):[],Lv=c&&Ni!==null&&$v.length>0&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Wye,{open:xP,branches:$v,branchPointTurnIndex:Ni,currentTurns:SP,onClose:Vt.handleCloseBranchModal,onCloseComplete:()=>Pv(null),onRedoToTurn:dP,onRedoEntireBranch:fP})}),Mv=u&&a.jsx(Ite,{processes:re.processes,activeProcessId:re.activeProcessId,collapsed:re.collapsed,onSetActive:re.setActive,onRemove:re.removeProcess,onToggleCollapse:re.toggleCollapse,onRequestTerminal:xt("terminal")?Se:void 0,onAddTerminalContext:Oe=>{var gy,xy,by;const ct=Oe.trim();if(!ct)return;const rn=ct.includes("```")?"````":"```",zr=`${rn}terminal
|
|
493
493
|
${ct}
|
|
494
494
|
${rn}`,Hm=((gy=C.current)==null?void 0:gy.getText().trimEnd())??"";(xy=C.current)==null||xy.setText(Hm?`${Hm}
|
|
495
495
|
|
|
496
496
|
${zr}
|
|
497
497
|
`:`${zr}
|
|
498
|
-
`),(by=C.current)==null||by.focus()},onUpdateStatus:re.updateProcessStatus,projectDir:de,onProcessStarted:re.addProcess,mobile:d}),zv=En&&a.jsx(tz,{teamName:En.config.name||En.teamName,members:En.config.members,currentMemberName:m.currentMemberName,loadingMember:m.loadingMember,onMemberClick:ys.handleTeamMemberSwitch}),Dv=We&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(qye,{open:N.showWorkflows,onOpenChange:N.setShowWorkflows,dirName:Je.dirName,sessionId:Je.sessionId,workflows:ke.workflows,isLive:ke.isLive,canStop:Z.stop,onRefetchList:ke.refetch},`${Je.dirName??""}:${Je.sessionId??""}`)}),du=W.goals?m.session:null,Fv=Oe=>{var ct;return a.jsx(XM,{mobile:d,agentKind:B,onAgentKindChange:qa?iP:void 0,selectedModel:us,onModelChange:$s,selectedEffort:Ua,onEffortChange:ji,contextWindowTokens:Ps,onContextWindowTokensChange:dr?ur:void 0,fastModeEnabled:ru,onFastModeEnabledChange:Q7?Om:void 0,isNewSession:qa,worktreeEnabled:rP,onWorktreeEnabledChange:qa&&Y?oP:void 0,ultracodeEnabled:ou,onUltracodeEnabledChange:eP?Lm:void 0,onApplySettings:Vt.handleApplySettings,activeModelId:(ct=m.session)==null?void 0:ct.model,mcpServers:J?ds.servers:void 0,selectedMcpServers:J?ds.selectedServers:void 0,onToggleMcpServer:J?ds.toggleServer:void 0,onSetMcpServers:J?ds.setSelection:void 0,onRefreshMcpServers:J?ds.refresh:void 0,mcpLoading:J?ds.loading:void 0,onMcpAuth:J?be:void 0,permissionMode:kn.config.mode,onPermissionModeChange:kn.setMode,mobileExtra:Oe&&du?a.jsx(gk,{}):void 0,trailingExtra:Oe&&du?a.jsx(gk,{}):void 0})},kP=Fv(!0),jP=Fv(!1),NP=a.jsxs("div",{className:G("shrink-0",d&&"bg-background"),children:[a.jsx(rte,{sessionId:H?null:((py=m.session)==null?void 0:py.sessionId)??null}),a.jsx(Bee,{}),a.jsx(x1,{ref:C,allowImages:lv,agentKind:B,projectCwd:de,footer:kP})]}),Uv=a.jsx(bL,{sessionId:((hy=m.session)==null?void 0:hy.sessionId)??null,readOnly:H||!Z.send,onOpen:ys.handleDashboardSelect,handoffOpen:_i&&bP===fo,onHandoffOpenChange:vP,crewOpen:ie,onOpenCrew:ae,children:NP}),fu=du?a.jsx(Uee,{agentKind:B,session:du,onSendCommand:Dt.sendMessage,children:Uv}):Uv,CP=a.jsx("div",{className:G("shrink-0",d&&"bg-background"),children:a.jsx(x1,{ref:C,allowImages:lv,agentKind:B,projectCwd:de,footer:jP})}),Bv=Dt.pendingMessages.length>0?[a.jsx(hA,{sessionId:null,pendingMessages:Dt.pendingMessages,canManage:!1,isMobile:d},"queued")]:[],_P=d?m.mobileTab==="workspace"&&N.activeWorkspacePanel===Lt.sessionInfo:N.activeWorkspacePanel===Lt.sessionInfo,Wv=m.session&&!_P&&a.jsx("div",{className:"hidden",children:a.jsx(dT,{cwd:m.session.cwd,turns:m.session.turns,onServersChanged:re.handleServersChanged})});return n?a.jsxs(bd,{value:Bm,children:[a.jsx(_h,{children:a.jsx(id,{value:Wm,chatValue:qm,children:a.jsx(Hh,{store:st,agentProgress:At,children:a.jsx(bbe,{sessionId:n,loadError:uP,searchInputRef:S,activeComposer:Dm||CP,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore})})})}),Vm]}):d?a.jsxs(bd,{value:Bm,children:[a.jsx(_h,{enabled:u,children:a.jsx(id,{value:Wm,chatValue:qm,children:a.jsx(Hh,{store:st,agentProgress:At,children:a.jsx(gbe,{navigation:{panels:N,actions:ys,handlers:Vt,creatingSession:mv,pendingSession:xv,onStartNewSession:au,onStartNewSessionWith:yv,newSessionModel:Sv,onStartNewFolder:bv,onSelectProject:O,liveSessionsRefreshRef:gv,onPrefetchSession:w},sessionView:{chatInputRef:C,searchInputRef:S,teamMembersBar:zv,activeComposer:Dm||fu,pendingComposer:fu,pendingTurns:Bv,todoProgress:Be&&a.jsx(gA,{progress:Be}),hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Iv,onShowWorkflows:Ve,onToggleExpandAll:R,workflowCount:ye,pendingPath:D},project:{currentCwd:de,supportsWorktrees:Y,worktrees:Ke,projectFilesRoot:fe,projectFilesRequest:ue,processPanel:re,backgroundAgents:Qn,hasFileChanges:c&&Ne,onOpenTerminal:ge},chrome:{backgroundServers:Wv,processPanel:Mv,workflowsPanel:Dv,undoDialog:Ov,branchModal:Lv,fileChangesOpen:He,onFileChangesOpenChange:me,onLogout:t.logout}})})})}),Vm]}):a.jsxs(bd,{value:Bm,children:[a.jsx(_h,{enabled:u,children:a.jsx(id,{value:Wm,chatValue:qm,children:a.jsx(Hh,{store:st,agentProgress:At,children:a.jsx(tbe,{navigation:{panels:N,actions:ys,handlers:Vt,creatingSession:mv,pendingSession:xv,onStartNewSession:au,onStartNewSessionWith:yv,newSessionModel:Sv,onStartNewFolder:bv,onSelectProject:O,onOpenPaletteProject:cP,liveSessionsRefreshRef:gv,onPrefetchSession:w},sessionView:{searchInputRef:S,chatInputRef:C,teamMembersBar:zv,activeComposer:Dm||fu,pendingComposer:fu,pendingTurns:Bv,todoProgress:Be,todosExpanded:qe,onTodosExpandedChange:aP,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Iv,onShowWorkflows:Ve,workflowCount:ye},project:{processPanel:re,worktrees:Ke,backgroundAgents:Qn,supportsWorktrees:Y,hasFileChanges:c&&Ne,currentCwd:de,showPreview:ce,showProjectFiles:c&&oe,projectFilesRoot:fe,projectFilesRequest:ue,launchTerminalRequest:le,pendingProject:pe,onOpenTerminal:ge,onTogglePreview:we,onToggleProjectFiles:Ee,onCloseRightWorkspace:$e},chrome:{backgroundServers:Wv,processPanel:Mv,workflowsPanel:Dv,undoDialog:Ov,branchModal:Lv,killing:mP,onKillAll:pP,commandPaletteOpen:E,onCommandPaletteOpenChange:T,onOpenCommandPalette:P,onFocusComposer:z,onExpandAll:L,onExpandToolPayloads:I,onCollapseAll:M,keyboardShortcutsOpen:$,onKeyboardShortcutsOpenChange:A,onLogout:t.logout}})})})}),Vm]})}const Z7={unreachable:{title:"Remote device unavailable",description:n=>`Can’t reach ${n}. Cogpit will keep retrying.`},"bad-password":{title:"Device credentials need attention",description:n=>`${n} rejected the stored password. Update it in Devices.`},refused:{title:"Device not admitting this account",description:n=>`${n} is not admitting this account right now. Cogpit will keep retrying.`}};function Kye(n,e){return n.kind==="refused"&&n.detail?`${n.detail} Cogpit will keep retrying.`:Z7[n.kind].description(e)}const Gye=new Map(Object.entries({DEVICE_AUTH_FAILED:"bad-password",DEVICE_REFUSED:"refused"}));function Zye(n){return{kind:Gye.get(n??"")??"unreachable"}}function Yye(n){return n.ok?null:n.reachable&&n.authState==="bad-password"?{kind:"bad-password"}:n.code==="DEVICE_REFUSED"?{kind:"refused",detail:n.error}:{kind:"unreachable"}}function Xye(){var w;const[n,e]=y.useState(Kt),[t,s]=y.useState(()=>Qu(Kt())),[r,o]=y.useState(Zn),[i,l]=y.useState(0),[c,u]=y.useState(null),[d,f]=y.useState(!1),{devices:m,testDevice:p}=Si();y.useEffect(()=>{const v=()=>{const j=Kt();e(k=>k===j?k:j),s(Qu(j))};return window.addEventListener("cogpit-device-changed",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("cogpit-device-changed",v),window.removeEventListener("popstate",v)}},[]),y.useEffect(()=>{const v=j=>{const k=j.detail;(k==null?void 0:k.deviceId)===Kt()&&s(Qu(k.deviceId))};return window.addEventListener("cogpit-device-scope-changed",v),()=>window.removeEventListener("cogpit-device-scope-changed",v)},[]),y.useEffect(()=>{const v=()=>o(Zn());return window.addEventListener("cogpit-identity-changed",v),()=>window.removeEventListener("cogpit-identity-changed",v)},[]),y.useEffect(()=>(window.__cogpitRevealSession=za,()=>{delete window.__cogpitRevealSession}),[]),y.useEffect(()=>{const v=j=>{const k=[Ot,...m.map(C=>C.id)],_=Kt();let N;const S=Lme(j);if(S!==null)N=k[S-1];else if(Mme(j)){const C=k.indexOf(_);N=k[(C+1)%k.length]}!N||N===_||(j.preventDefault(),Xs(N))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[m]),y.useEffect(()=>{u(null),f(!1)},[n,t]);const h=y.useCallback(async()=>{const v=cn(),j=()=>cn()===v;f(!0);try{const k=Yye(await p(n));if(!j())return;u(k),k===null&&l(_=>_+1)}finally{j()&&f(!1)}},[n,p]),g=c==null?void 0:c.kind;y.useEffect(()=>{const v=j=>{const k=j.detail;if(!(k!=null&&k.deviceId)||k.deviceId!==Kt())return;const _=Zye(k.reason);_.kind!==g&&(u(_),_.kind==="refused"&&h())};return window.addEventListener("cogpit-device-unreachable",v),()=>window.removeEventListener("cogpit-device-unreachable",v)},[g,h]);const x=c!==null&&c.kind!=="bad-password";y.useEffect(()=>{if(!x)return;const v=setInterval(()=>void h(),1e4);return()=>clearInterval(v)},[x,h]);const b=((w=m.find(v=>v.id===n))==null?void 0:w.name)??n;return a.jsxs(a.Fragment,{children:[c&&n!==Ot&&a.jsxs(kt,{role:"status",className:"fixed inset-x-3 top-3 z-40 mx-auto max-w-2xl border-warning/40 bg-popover shadow-md",children:[a.jsx(G8,{"data-icon":"inline-start",className:"text-warning"}),a.jsx(Xt,{children:Z7[c.kind].title}),a.jsx(_t,{children:Kye(c,b)}),a.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[x&&a.jsxs(Q,{variant:"outline",size:"xs",onClick:()=>void h(),disabled:d,children:[d&&a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),d?"Retrying":"Retry now"]}),a.jsx(Q,{variant:"outline",size:"xs",onClick:()=>Xs(Ot),children:"Switch to this machine"})]})]}),a.jsx(gO,{children:a.jsx(wpe,{children:a.jsx(Hye,{})})},`${n}:${t}:${i}:${r??""}`)]})}const u4="Invalid link or passphrase.";function Jye(n,e){return n===401?u4: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||u4}function Qye({sessionId:n,onAuthenticated:e}){const[t,s]=y.useState(""),[r,o]=y.useState(!1),[i,l]=y.useState(null),[c,u]=y.useState(!1),d=y.useCallback(async f=>{if(f.preventDefault(),!!t.trim()){u(!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(Jye(m.status,p.error))}catch{l("Failed to connect to server")}finally{u(!1)}}},[e,t,n]);return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:d,className:"w-full max-w-sm",children:a.jsxs(Ds,{children:[a.jsxs(xr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(tr,{className:"size-4"})}),a.jsx(br,{children:"Join this session"}),a.jsx(vr,{children:"Enter the passphrase you were given to join the shared session."})]}),a.jsxs(Fs,{className:"flex flex-col gap-4",children:[a.jsx(Aa,{children:a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"share-passphrase",children:"Passphrase"}),a.jsxs(Ko,{children:[a.jsx(Go,{id:"share-passphrase",type:r?"text":"password",value:t,onChange:f=>s(f.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>o(f=>!f),"aria-label":r?"Hide passphrase":"Show passphrase",children:r?a.jsx(fx,{}):a.jsx(Na,{})})})]})]})}),i&&a.jsxs(kt,{variant:"destructive",children:[a.jsx(Sr,{"aria-hidden":"true"}),a.jsx(Xt,{children:"Could not join"}),a.jsx(_t,{children:i})]})]}),a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function e2e(){const n=V.c(9),[e,t]=y.useState("idle"),[s,r]=y.useState();let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],n[0]=o):o=n[0];const[i,l]=y.useState(o);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>(l(w=>[...w,x]),t("connected"),r(void 0),gee(x,b).then(w=>{if(w.ok){t("idle");return}r(`Request failed (${w.status})`),t("error"),l(r2e)}).catch(w=>{r(w instanceof Error?w.message:"Unknown error"),t("error"),l(s2e)}).then(n2e)),n[1]=c):c=n[1];const u=c;let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{xee().catch(t2e),t("idle"),l([])},n[2]=d):d=n[2];const f=d;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const b=x===void 0?1:x;l(w=>w.slice(b))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==i||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:i,isConnected:h,sendMessage:u,interrupt:f,stopAgent:f,consumePending:p},n[4]=s,n[5]=i,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function t2e(){}function n2e(){return!0}function s2e(n){return n.slice(0,-1)}function r2e(n){return n.slice(0,-1)}const o2e=2e3;function i2e(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function a2e(){const n=V.c(10);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,n[1]=r):r=n[1];const[o,i]=y.useState(r);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async h=>{const g=await wee();!h()||g===null||s(x=>i2e(x,g)?x:g)},n[2]=l):l=n[2],Oa(l,o2e);let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=(h,g)=>{i(x=>new Set(x).add(h)),vee(h,g).then(x=>{x&&s(b=>b.filter(w=>w.requestId!==h))}).finally(()=>{i(x=>{const b=new Set(x);return b.delete(h),b})})},n[3]=u):u=n[3];const d=u;let f;n[4]!==t?(f=h=>{for(const g of t)d(g.requestId,h)},n[4]=t,n[5]=f):f=n[5];const m=f;let p;return n[6]!==t||n[7]!==m||n[8]!==o?(p={requests:t,responding:o,respond:d,respondAll:m},n[6]=t,n[7]=m,n[8]=o,n[9]=p):p=n[9],p}const l2e={edition:"personal",user:null,capabilities:Ta};function c2e(n){var be,ve;const e=V.c(78),{info:t,children:s}=n,r=rv(),o=E7(),[i,l]=k7(),{parse:c,append:u}=B7(),[d,f]=y.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],y.useEffect(m2e,m);const p=e2e(),h=a2e();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==r||e[5]!==c?(g=async()=>{try{const{parsed:Se,source:we}=await C7(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:Se,source:we,isMobile:r}),f("ready")}catch{f("failed")}},e[1]=l,e[2]=t.dirName,e[3]=t.fileName,e[4]=r,e[5]=c,e[6]=g):g=e[6];const x=g,b=y.useRef(!1);let w,v;e[7]!==x?(w=()=>{b.current||(b.current=!0,x())},v=[x],e[7]=x,e[8]=w,e[9]=v):(w=e[8],v=e[9]),y.useEffect(w,v);let j;e[10]!==l?(j=Se=>{l({type:"UPDATE_SESSION",session:Se})},e[10]=l,e[11]=j):j=e[11];const k=j,{isLive:_,sseState:N,isCompacting:S,turnError:C}=y7(i.sessionSource,k,c,u,void 0,i.session);let E;e[12]!==l?(E=Se=>{l({type:"SET_OLDER_TURNS",turns:Se})},e[12]=l,e[13]=E):E=e[13];const T=E,$=((be=i.sessionSource)==null?void 0:be.dirName)??null,A=((ve=i.sessionSource)==null?void 0:ve.fileName)??null;let R;e[14]!==T||e[15]!==i.sessionChangeKey||e[16]!==$||e[17]!==A||e[18]!==c?(R={dirName:$,fileName:A,sessionChangeKey:i.sessionChangeKey,workerParse:c,onOlderTurns:T},e[14]=T,e[15]=i.sessionChangeKey,e[16]=$,e[17]=A,e[18]=c,e[19]=R):R=e[19];const P=W7(R);let z;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==_||e[23]!==i.session||e[24]!==i.sessionChangeKey?(z={session:i.session,isLive:_,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:i.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=_,e[23]=i.session,e[24]=i.sessionChangeKey,e[25]=z):z=e[25];const L=j7(z),I=z7(i.session,i.sessionSource,x,!1);let M;e[26]!==i.session?(M=i.session?i6(i.session):null,e[26]=i.session,e[27]=M):M=e[27];const F=M;let U;e[28]!==l?(U=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=U):U=e[29];const O=U,D=d2e,B=u2e;let q;e[30]!==t.dirName?(q=un(t.dirName),e[30]=t.dirName,e[31]=q):q=e[31];let W;e[32]!==q?(W={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:q,setClaudeDir:B,showConfigDialog:!1,openConfigDialog:B,handleCloseConfigDialog:B,handleConfigSaved:B,retryConfig:B,networkUrl:null,networkAccessDisabled:!1},e[32]=q,e[33]=W):W=e[33];let H;e[34]!==l||e[35]!==r||e[36]!==i||e[37]!==W||e[38]!==o?(H={state:i,dispatch:l,config:W,theme:o,isMobile:r},e[34]=l,e[35]=r,e[36]=i,e[37]=W,e[38]=o,e[39]=H):H=e[39];const K=H,Z=i.session,Y=i.sessionSource,J=h.requests,ee=h.responding,te=h.respond,se=h.respondAll;let X,ne;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=Sa("interact"),ne=[],e[40]=X,e[41]=ne):(X=e[40],ne=e[41]);let ae;e[42]!==O?(ae={handleStopSession:D,handleOpenBranches:B,handleBranchFromHere:B,handleToggleExpandAll:O,handleLoadSession:B},e[42]=O,e[43]=ae):ae=e[43];let ie;e[44]!==S||e[45]!==_||e[46]!==F||e[47]!==h.requests||e[48]!==h.respond||e[49]!==h.respondAll||e[50]!==h.responding||e[51]!==N||e[52]!==i.session||e[53]!==i.sessionSource||e[54]!==ae||e[55]!==C||e[56]!==I?(ie={session:Z,sessionSource:Y,isLive:_,sseState:N,isCompacting:S,turnError:C,undoRedo:I,pendingInteraction:F,permissionRequests:J,permissionResponding:ee,respondPermission:te,respondAllPermissions:se,isSubAgentView:!1,permissions:X,slashSuggestions:ne,slashSuggestionsLoading:!1,promptSuggestion:null,rateLimit:null,actions:ae},e[44]=S,e[45]=_,e[46]=F,e[47]=h.requests,e[48]=h.respond,e[49]=h.respondAll,e[50]=h.responding,e[51]=N,e[52]=i.session,e[53]=i.sessionSource,e[54]=ae,e[55]=C,e[56]=I,e[57]=ie):ie=e[57];const re=ie;let de;e[58]!==p||e[59]!==L?(de={chat:p,scroll:L},e[58]=p,e[59]=L,e[60]=de):de=e[60];const ce=de;let oe;e[61]!==P?(oe=()=>{P.loadMore()},e[61]=P,e[62]=oe):oe=e[62];let fe;e[63]!==d||e[64]!==P.hasMore||e[65]!==P.isLoadingOlder||e[66]!==oe?(fe={loadState:d,hasMore:P.hasMore,isLoadingOlder:P.isLoadingOlder,loadMore:oe},e[63]=d,e[64]=P.hasMore,e[65]=P.isLoadingOlder,e[66]=oe,e[67]=fe):fe=e[67];const ue=fe;let le;e[68]!==s||e[69]!==ue?(le=s(ue),e[68]=s,e[69]=ue,e[70]=le):le=e[70];let pe;e[71]!==ce||e[72]!==re||e[73]!==le?(pe=a.jsx(id,{value:re,chatValue:ce,children:le}),e[71]=ce,e[72]=re,e[73]=le,e[74]=pe):pe=e[74];let ge;return e[75]!==K||e[76]!==pe?(ge=a.jsx(bd,{value:K,children:pe}),e[75]=K,e[76]=pe,e[77]=ge):ge=e[77],ge}function u2e(){}async function d2e(){await bee().catch(f2e)}function f2e(){}function m2e(){Cl(l2e)}function p2e(n){const e=V.c(6),{info:t}=n,s=y.useRef(null);let r;e[0]!==t.provider||e[1]!==t.title?(r=i=>a.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[a.jsx(tr,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),a.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:t.title}),a.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:"Guest view"})]}),i.loadState==="failed"?a.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:a.jsxs(kt,{variant:"destructive",className:"max-w-sm",children:[a.jsx(Sr,{"aria-hidden":"true"}),a.jsx(Xt,{children:"Session unavailable"}),a.jsx(_t,{children:"This conversation could not be loaded. It may have been deleted on the host."})]})}):i.loadState==="loading"?a.jsx("div",{className:"flex flex-1 items-center justify-center",role:"status","aria-label":"Loading shared session",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})}):a.jsxs(a.Fragment,{children:[a.jsx(Tm,{searchInputRef:s,hasMore:i.hasMore,isLoadingOlder:i.isLoadingOlder,onLoadMore:i.loadMore}),a.jsx(Im,{children:a.jsx(x1,{agentKind:t.provider,projectCwd:null})})]})]}),e[0]=t.provider,e[1]=t.title,e[2]=r):r=e[2];let o;return e[3]!==t||e[4]!==r?(o=a.jsx(c2e,{info:t,children:r}),e[3]=t,e[4]=r,e[5]=o):o=e[5],o}function gg(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function h2e(){const n=V.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=GE(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[r,o]=y.useState(s);let i;n[2]===Symbol.for("react.memo_cache_sentinel")?(i=async()=>{o({kind:"probing"});const p=await hee();o(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=i):i=n[2];const l=i;let c,u;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},u=[l,t],n[3]=c,n[4]=u):(c=n[3],u=n[4]),y.useEffect(c,u);let d,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const p=()=>{o(g2e)};return window.addEventListener(g1,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(g1,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=d,n[6]=f):(d=n[5],f=n[6]),y.useEffect(d,f),r.kind==="ready"){let p;return n[7]!==r.info?(p=a.jsx(p2e,{info:r.info}),n[7]=r.info,n[8]=p):p=n[8],p}if(r.kind==="login"&&t){let p;return n[9]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Qye,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(r.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(gg,{children:a.jsx(Ds,{children:a.jsxs(xr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(Z8,{className:"size-4"})}),a.jsx(br,{children:"Sharing has ended"}),a.jsx(vr,{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(r.kind==="error"){let p,h;n[11]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Sr,{"aria-hidden":"true"}),h=a.jsx(Xt,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==r.message?(g=a.jsxs(kt,{variant:"destructive",children:[p,h,a.jsx(_t,{children:r.message})]}),n[13]=r.message,n[14]=g):g=n[14];let x;n[15]===Symbol.for("react.memo_cache_sentinel")?(x=t&&a.jsx(Q,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=x):x=n[15];let b;return n[16]!==g?(b=a.jsxs(gg,{children:[g,x]}),n[16]=g,n[17]=b):b=n[17],b}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(gg,{children:a.jsx(Ds,{children:a.jsxs(Fs,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[a.jsx(tr,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),a.jsx(Pn,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function g2e(n){return n.kind==="ready"?{kind:"ended"}:n}class x2e extends y.Component{constructor(){super(...arguments);Ge(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 a.jsx("main",{className:"flex h-dvh items-center justify-center bg-canvas p-6 text-foreground",children:a.jsxs(Ds,{className:"w-full max-w-lg text-center",children:[a.jsxs(xr,{className:"justify-items-center",children:[a.jsx(er,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),a.jsx(br,{children:a.jsx("h1",{children:"Cogpit hit a render error"})}),a.jsx(vr,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),a.jsx(Fs,{children:a.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})}),a.jsx(um,{className:"justify-center",children:a.jsxs(Q,{onClick:()=>window.location.reload(),children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Y7=document.getElementById("root");if(!Y7)throw new Error("Root element not found");PP.createRoot(Y7).render(a.jsx(y.StrictMode,{children:a.jsx(x2e,{children:lm(window.location.pathname)?a.jsx(h2e,{}):a.jsx(Xye,{})})}));export{_r as $,kt as A,Q as B,fn as C,sr as D,dm as E,cfe as F,Eo as G,b1 as H,Ar as I,G as J,Em as K,Ln as L,Mn as M,Yn as N,zn as O,dxe as P,Dn as Q,sn as R,qM as S,sT as T,Ce as U,Gc as V,x6 as W,tre as X,Nn as Y,Fe as Z,N2e as _,VM as a,Js as a$,vn as a0,rs as a1,ba as a2,ofe as a3,yn as a4,rb as a5,ob as a6,ib as a7,Dte as a8,lb as a9,f6 as aA,Pf as aB,Uf as aC,Mde as aD,fee as aE,As as aF,A1 as aG,$1 as aH,Wb as aI,Or as aJ,Wc as aK,Rx as aL,nz as aM,sz as aN,S6 as aO,jr as aP,Fa as aQ,xr as aR,br as aS,Fs as aT,um as aU,Ds as aV,xm as aW,Wx as aX,Y6 as aY,so as aZ,vt as a_,cb as aa,ab,db as ac,ub as ad,Kn as ae,ea as af,Rme as ag,Pn as ah,xi as ai,To as aj,Tz as ak,T2e as al,Ic as am,a0 as an,Pc as ao,Ez as ap,sb as aq,Mf as ar,e7 as as,qo as at,xt as au,kb as av,Jr as aw,zf as ax,la as ay,d6 as az,HM as b,hl as b$,Xt as b0,vr as b1,Wte as b2,qc as b3,Cbe as b4,Sm as b5,mn as b6,aa as b7,ehe as b8,Cn as b9,nv as bA,Pm as bB,pi as bC,Hs as bD,TN as bE,$d as bF,Nl as bG,cm as bH,Cr as bI,Oa as bJ,is as bK,pie as bL,kie as bM,W2e as bN,iA as bO,q2e as bP,V2e as bQ,_2e as bR,Pd as bS,y5 as bT,Zt as bU,Yt as bV,Gt as bW,lo as bX,ar as bY,iT as bZ,aT as b_,j2e as ba,On as bb,Tl as bc,Kte as bd,HI as be,Sc as bf,nt as bg,fT as bh,wa as bi,XM as bj,un as bk,Er as bl,Gm as bm,Tc as bn,Xx as bo,Ec as bp,i9 as bq,Yee as br,Hee as bs,Fx as bt,zy as bu,Ux as bv,Nr as bw,Kx as bx,Spe as by,Ff as bz,WM as c,Eye as c$,gl as c0,Jee as c1,za as c2,ha as c3,E2e as c4,Nm as c5,Cm as c6,_m as c7,fi as c8,H2e as c9,hM as cA,k2e as cB,R1e as cC,_x as cD,Hr as cE,Dme as cF,xs as cG,Lx as cH,CM as cI,qN as cJ,Rc as cK,P5 as cL,hn as cM,Oc as cN,qr as cO,$c as cP,gs as cQ,Yoe as cR,Il as cS,Goe as cT,zme as cU,Zoe as cV,Hoe as cW,Koe as cX,Voe as cY,PN as cZ,Q9 as c_,Rn as ca,va as cb,Lte as cc,Gn as cd,l9 as ce,a9 as cf,FE as cg,HQ as ch,SN as ci,vN as cj,Cg as ck,yN as cl,wN as cm,bN as cn,Zw as co,A2e as cp,vo as cq,T0 as cr,J0 as cs,qE as ct,B2e as cu,Ex as cv,zs as cw,tN as cx,_c as cy,h1e as cz,zM as d,Xs as d0,Ot as d1,Rf as d2,Rd as d3,V9 as d4,C2e as d5,jt as d6,Dh as d7,K2e as e,$me as f,G2e as g,rr as h,ao as i,or as j,ir as k,tn as l,Ko as m,Go as n,X2e as o,_t as p,Vc as q,Y2e as r,J2e as s,Q2e as t,Z2e as u,cxe as v,on as w,fR as x,Si as y,Aa as z};
|
|
498
|
+
`),(by=C.current)==null||by.focus()},onUpdateStatus:re.updateProcessStatus,projectDir:de,onProcessStarted:re.addProcess,mobile:d}),zv=En&&a.jsx(tz,{teamName:En.config.name||En.teamName,members:En.config.members,currentMemberName:m.currentMemberName,loadingMember:m.loadingMember,onMemberClick:ys.handleTeamMemberSwitch}),Dv=We&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(qye,{open:N.showWorkflows,onOpenChange:N.setShowWorkflows,dirName:Je.dirName,sessionId:Je.sessionId,workflows:ke.workflows,isLive:ke.isLive,canStop:Z.stop,onRefetchList:ke.refetch},`${Je.dirName??""}:${Je.sessionId??""}`)}),du=W.goals?m.session:null,Fv=Oe=>{var ct;return a.jsx(XM,{mobile:d,agentKind:B,onAgentKindChange:qa?iP:void 0,selectedModel:us,onModelChange:$s,selectedEffort:Ua,onEffortChange:ji,contextWindowTokens:Ps,onContextWindowTokensChange:dr?ur:void 0,fastModeEnabled:ru,onFastModeEnabledChange:Q7?Om:void 0,isNewSession:qa,worktreeEnabled:rP,onWorktreeEnabledChange:qa&&Y?oP:void 0,ultracodeEnabled:ou,onUltracodeEnabledChange:eP?Lm:void 0,onApplySettings:Vt.handleApplySettings,activeModelId:(ct=m.session)==null?void 0:ct.model,mcpServers:J?ds.servers:void 0,selectedMcpServers:J?ds.selectedServers:void 0,onToggleMcpServer:J?ds.toggleServer:void 0,onSetMcpServers:J?ds.setSelection:void 0,onRefreshMcpServers:J?ds.refresh:void 0,mcpLoading:J?ds.loading:void 0,onMcpAuth:J?be:void 0,permissionMode:kn.config.mode,onPermissionModeChange:kn.setMode,mobileExtra:Oe&&du?a.jsx(gk,{}):void 0,trailingExtra:Oe&&du?a.jsx(gk,{}):void 0})},kP=Fv(!0),jP=Fv(!1),NP=a.jsxs("div",{className:G("shrink-0",d&&"bg-background"),children:[a.jsx(rte,{sessionId:H?null:((py=m.session)==null?void 0:py.sessionId)??null}),a.jsx(Bee,{}),a.jsx(x1,{ref:C,allowImages:lv,agentKind:B,projectCwd:de,footer:kP})]}),Uv=a.jsx(bL,{sessionId:((hy=m.session)==null?void 0:hy.sessionId)??null,readOnly:H||!Z.send,onOpen:ys.handleDashboardSelect,handoffOpen:_i&&bP===fo,onHandoffOpenChange:vP,crewOpen:ie,onOpenCrew:ae,children:NP}),fu=du?a.jsx(Uee,{agentKind:B,session:du,onSendCommand:Dt.sendMessage,children:Uv}):Uv,CP=a.jsx("div",{className:G("shrink-0",d&&"bg-background"),children:a.jsx(x1,{ref:C,allowImages:lv,agentKind:B,projectCwd:de,footer:jP})}),Bv=Dt.pendingMessages.length>0?[a.jsx(hA,{sessionId:null,pendingMessages:Dt.pendingMessages,canManage:!1,isMobile:d},"queued")]:[],_P=d?m.mobileTab==="workspace"&&N.activeWorkspacePanel===Lt.sessionInfo:N.activeWorkspacePanel===Lt.sessionInfo,Wv=m.session&&!_P&&a.jsx("div",{className:"hidden",children:a.jsx(dT,{cwd:m.session.cwd,turns:m.session.turns,onServersChanged:re.handleServersChanged})});return n?a.jsxs(bd,{value:Bm,children:[a.jsx(_h,{children:a.jsx(id,{value:Wm,chatValue:qm,children:a.jsx(Hh,{store:st,agentProgress:At,children:a.jsx(bbe,{sessionId:n,loadError:uP,searchInputRef:S,activeComposer:Dm||CP,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore})})})}),Vm]}):d?a.jsxs(bd,{value:Bm,children:[a.jsx(_h,{enabled:u,children:a.jsx(id,{value:Wm,chatValue:qm,children:a.jsx(Hh,{store:st,agentProgress:At,children:a.jsx(gbe,{navigation:{panels:N,actions:ys,handlers:Vt,creatingSession:mv,pendingSession:xv,onStartNewSession:au,onStartNewSessionWith:yv,newSessionModel:Sv,onStartNewFolder:bv,onSelectProject:O,liveSessionsRefreshRef:gv,onPrefetchSession:w},sessionView:{chatInputRef:C,searchInputRef:S,teamMembersBar:zv,activeComposer:Dm||fu,pendingComposer:fu,pendingTurns:Bv,todoProgress:Be&&a.jsx(gA,{progress:Be}),hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Iv,onShowWorkflows:Ve,onToggleExpandAll:R,workflowCount:ye,pendingPath:D},project:{currentCwd:de,supportsWorktrees:Y,worktrees:Ke,projectFilesRoot:fe,projectFilesRequest:ue,processPanel:re,backgroundAgents:Qn,hasFileChanges:c&&Ne,onOpenTerminal:ge},chrome:{backgroundServers:Wv,processPanel:Mv,workflowsPanel:Dv,undoDialog:Ov,branchModal:Lv,fileChangesOpen:He,onFileChangesOpenChange:me,onLogout:t.logout}})})})}),Vm]}):a.jsxs(bd,{value:Bm,children:[a.jsx(_h,{enabled:u,children:a.jsx(id,{value:Wm,chatValue:qm,children:a.jsx(Hh,{store:st,agentProgress:At,children:a.jsx(tbe,{navigation:{panels:N,actions:ys,handlers:Vt,creatingSession:mv,pendingSession:xv,onStartNewSession:au,onStartNewSessionWith:yv,newSessionModel:Sv,onStartNewFolder:bv,onSelectProject:O,onOpenPaletteProject:cP,liveSessionsRefreshRef:gv,onPrefetchSession:w},sessionView:{searchInputRef:S,chatInputRef:C,teamMembersBar:zv,activeComposer:Dm||fu,pendingComposer:fu,pendingTurns:Bv,todoProgress:Be,todosExpanded:qe,onTodosExpandedChange:aP,hasMoreTurns:v.hasMore,isLoadingOlderTurns:v.isLoadingOlder,onLoadMoreTurns:v.loadMore,onBackToMain:Iv,onShowWorkflows:Ve,workflowCount:ye},project:{processPanel:re,worktrees:Ke,backgroundAgents:Qn,supportsWorktrees:Y,hasFileChanges:c&&Ne,currentCwd:de,showPreview:ce,showProjectFiles:c&&oe,projectFilesRoot:fe,projectFilesRequest:ue,launchTerminalRequest:le,pendingProject:pe,onOpenTerminal:ge,onTogglePreview:we,onToggleProjectFiles:Ee,onCloseRightWorkspace:$e},chrome:{backgroundServers:Wv,processPanel:Mv,workflowsPanel:Dv,undoDialog:Ov,branchModal:Lv,killing:mP,onKillAll:pP,commandPaletteOpen:E,onCommandPaletteOpenChange:T,onOpenCommandPalette:P,onFocusComposer:z,onExpandAll:L,onExpandToolPayloads:I,onCollapseAll:M,keyboardShortcutsOpen:$,onKeyboardShortcutsOpenChange:A,onLogout:t.logout}})})})}),Vm]})}const Z7={unreachable:{title:"Remote device unavailable",description:n=>`Can’t reach ${n}. Cogpit will keep retrying.`},"bad-password":{title:"Device credentials need attention",description:n=>`${n} rejected the stored password. Update it in Devices.`},refused:{title:"Device not admitting this account",description:n=>`${n} is not admitting this account right now. Cogpit will keep retrying.`}};function Kye(n,e){return n.kind==="refused"&&n.detail?`${n.detail} Cogpit will keep retrying.`:Z7[n.kind].description(e)}const Gye=new Map(Object.entries({DEVICE_AUTH_FAILED:"bad-password",DEVICE_REFUSED:"refused"}));function Zye(n){return{kind:Gye.get(n??"")??"unreachable"}}function Yye(n){return n.ok?null:n.reachable&&n.authState==="bad-password"?{kind:"bad-password"}:n.code==="DEVICE_REFUSED"?{kind:"refused",detail:n.error}:{kind:"unreachable"}}function Xye(){var w;const[n,e]=y.useState(Kt),[t,s]=y.useState(()=>Qu(Kt())),[r,o]=y.useState(Zn),[i,l]=y.useState(0),[c,u]=y.useState(null),[d,f]=y.useState(!1),{devices:m,testDevice:p}=Si();y.useEffect(()=>{const v=()=>{const j=Kt();e(k=>k===j?k:j),s(Qu(j))};return window.addEventListener("cogpit-device-changed",v),window.addEventListener("popstate",v),()=>{window.removeEventListener("cogpit-device-changed",v),window.removeEventListener("popstate",v)}},[]),y.useEffect(()=>{const v=j=>{const k=j.detail;(k==null?void 0:k.deviceId)===Kt()&&s(Qu(k.deviceId))};return window.addEventListener("cogpit-device-scope-changed",v),()=>window.removeEventListener("cogpit-device-scope-changed",v)},[]),y.useEffect(()=>{const v=()=>o(Zn());return window.addEventListener("cogpit-identity-changed",v),()=>window.removeEventListener("cogpit-identity-changed",v)},[]),y.useEffect(()=>(window.__cogpitRevealSession=za,()=>{delete window.__cogpitRevealSession}),[]),y.useEffect(()=>{const v=j=>{const k=[Ot,...m.map(C=>C.id)],_=Kt();let N;const S=Lme(j);if(S!==null)N=k[S-1];else if(Mme(j)){const C=k.indexOf(_);N=k[(C+1)%k.length]}!N||N===_||(j.preventDefault(),Xs(N))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[m]),y.useEffect(()=>{u(null),f(!1)},[n,t]);const h=y.useCallback(async()=>{const v=cn(),j=()=>cn()===v;f(!0);try{const k=Yye(await p(n));if(!j())return;u(k),k===null&&l(_=>_+1)}finally{j()&&f(!1)}},[n,p]),g=c==null?void 0:c.kind;y.useEffect(()=>{const v=j=>{const k=j.detail;if(!(k!=null&&k.deviceId)||k.deviceId!==Kt())return;const _=Zye(k.reason);_.kind!==g&&(u(_),_.kind==="refused"&&h())};return window.addEventListener("cogpit-device-unreachable",v),()=>window.removeEventListener("cogpit-device-unreachable",v)},[g,h]);const x=c!==null&&c.kind!=="bad-password";y.useEffect(()=>{if(!x)return;const v=setInterval(()=>void h(),1e4);return()=>clearInterval(v)},[x,h]);const b=((w=m.find(v=>v.id===n))==null?void 0:w.name)??n;return a.jsxs(a.Fragment,{children:[c&&n!==Ot&&a.jsxs(kt,{role:"status",className:"fixed inset-x-3 top-3 z-40 mx-auto max-w-2xl border-warning/40 bg-popover shadow-md",children:[a.jsx(G8,{"data-icon":"inline-start",className:"text-warning"}),a.jsx(Xt,{children:Z7[c.kind].title}),a.jsx(_t,{children:Kye(c,b)}),a.jsxs("div",{className:"col-start-2 mt-2 flex flex-wrap gap-2",children:[x&&a.jsxs(Q,{variant:"outline",size:"xs",onClick:()=>void h(),disabled:d,children:[d&&a.jsx(St,{"data-icon":"inline-start",className:"animate-spin"}),d?"Retrying":"Retry now"]}),a.jsx(Q,{variant:"outline",size:"xs",onClick:()=>Xs(Ot),children:"Switch to this machine"})]})]}),a.jsx(gO,{children:a.jsx(wpe,{children:a.jsx(Hye,{})})},`${n}:${t}:${i}:${r??""}`)]})}const u4="Invalid link or passphrase.";function Jye(n,e){return n===401?u4: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||u4}function Qye({sessionId:n,onAuthenticated:e}){const[t,s]=y.useState(""),[r,o]=y.useState(!1),[i,l]=y.useState(null),[c,u]=y.useState(!1),d=y.useCallback(async f=>{if(f.preventDefault(),!!t.trim()){u(!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(Jye(m.status,p.error))}catch{l("Failed to connect to server")}finally{u(!1)}}},[e,t,n]);return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:d,className:"w-full max-w-sm",children:a.jsxs(Ds,{children:[a.jsxs(xr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(tr,{className:"size-4"})}),a.jsx(br,{children:"Join this session"}),a.jsx(vr,{children:"Enter the passphrase you were given to join the shared session."})]}),a.jsxs(Fs,{className:"flex flex-col gap-4",children:[a.jsx(Aa,{children:a.jsxs(fn,{children:[a.jsx(mn,{htmlFor:"share-passphrase",children:"Passphrase"}),a.jsxs(Ko,{children:[a.jsx(Go,{id:"share-passphrase",type:r?"text":"password",value:t,onChange:f=>s(f.target.value),placeholder:"copper-lantern-drift-92",autoComplete:"current-password",autoFocus:!0}),a.jsx(Ar,{align:"inline-end",children:a.jsx(dm,{size:"icon-xs",onClick:()=>o(f=>!f),"aria-label":r?"Hide passphrase":"Show passphrase",children:r?a.jsx(fx,{}):a.jsx(Na,{})})})]})]})}),i&&a.jsxs(kt,{variant:"destructive",children:[a.jsx(Sr,{"aria-hidden":"true"}),a.jsx(Xt,{children:"Could not join"}),a.jsx(_t,{children:i})]})]}),a.jsx(um,{children:a.jsxs(Q,{type:"submit",className:"w-full",disabled:c||!t.trim(),children:[c&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})})})}function e2e(){const n=V.c(9),[e,t]=y.useState("idle"),[s,r]=y.useState();let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],n[0]=o):o=n[0];const[i,l]=y.useState(o);let c;n[1]===Symbol.for("react.memo_cache_sentinel")?(c=(x,b)=>(l(w=>[...w,x]),t("connected"),r(void 0),gee(x,b).then(w=>{if(w.ok){t("idle");return}r(`Request failed (${w.status})`),t("error"),l(r2e)}).catch(w=>{r(w instanceof Error?w.message:"Unknown error"),t("error"),l(s2e)}).then(n2e)),n[1]=c):c=n[1];const u=c;let d;n[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{xee().catch(t2e),t("idle"),l([])},n[2]=d):d=n[2];const f=d;let m;n[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const b=x===void 0?1:x;l(w=>w.slice(b))},n[3]=m):m=n[3];const p=m,h=e==="connected";let g;return n[4]!==s||n[5]!==i||n[6]!==e||n[7]!==h?(g={status:e,error:s,pendingMessages:i,isConnected:h,sendMessage:u,interrupt:f,stopAgent:f,consumePending:p},n[4]=s,n[5]=i,n[6]=e,n[7]=h,n[8]=g):g=n[8],g}function t2e(){}function n2e(){return!0}function s2e(n){return n.slice(0,-1)}function r2e(n){return n.slice(0,-1)}const o2e=2e3;function i2e(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function a2e(){const n=V.c(10);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e);let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,n[1]=r):r=n[1];const[o,i]=y.useState(r);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async h=>{const g=await wee();!h()||g===null||s(x=>i2e(x,g)?x:g)},n[2]=l):l=n[2],Oa(l,o2e);let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=(h,g)=>{i(x=>new Set(x).add(h)),vee(h,g).then(x=>{x&&s(b=>b.filter(w=>w.requestId!==h))}).finally(()=>{i(x=>{const b=new Set(x);return b.delete(h),b})})},n[3]=u):u=n[3];const d=u;let f;n[4]!==t?(f=h=>{for(const g of t)d(g.requestId,h)},n[4]=t,n[5]=f):f=n[5];const m=f;let p;return n[6]!==t||n[7]!==m||n[8]!==o?(p={requests:t,responding:o,respond:d,respondAll:m},n[6]=t,n[7]=m,n[8]=o,n[9]=p):p=n[9],p}const l2e={edition:"personal",user:null,capabilities:Ta};function c2e(n){var be,ve;const e=V.c(78),{info:t,children:s}=n,r=rv(),o=E7(),[i,l]=k7(),{parse:c,append:u}=B7(),[d,f]=y.useState("loading");let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0],y.useEffect(m2e,m);const p=e2e(),h=a2e();let g;e[1]!==l||e[2]!==t.dirName||e[3]!==t.fileName||e[4]!==r||e[5]!==c?(g=async()=>{try{const{parsed:Se,source:we}=await C7(t.dirName,t.fileName,c,"shared session");l({type:"LOAD_SESSION",session:Se,source:we,isMobile:r}),f("ready")}catch{f("failed")}},e[1]=l,e[2]=t.dirName,e[3]=t.fileName,e[4]=r,e[5]=c,e[6]=g):g=e[6];const x=g,b=y.useRef(!1);let w,v;e[7]!==x?(w=()=>{b.current||(b.current=!0,x())},v=[x],e[7]=x,e[8]=w,e[9]=v):(w=e[8],v=e[9]),y.useEffect(w,v);let j;e[10]!==l?(j=Se=>{l({type:"UPDATE_SESSION",session:Se})},e[10]=l,e[11]=j):j=e[11];const k=j,{isLive:_,sseState:N,isCompacting:S,turnError:C}=y7(i.sessionSource,k,c,u,void 0,i.session);let E;e[12]!==l?(E=Se=>{l({type:"SET_OLDER_TURNS",turns:Se})},e[12]=l,e[13]=E):E=e[13];const T=E,$=((be=i.sessionSource)==null?void 0:be.dirName)??null,A=((ve=i.sessionSource)==null?void 0:ve.fileName)??null;let R;e[14]!==T||e[15]!==i.sessionChangeKey||e[16]!==$||e[17]!==A||e[18]!==c?(R={dirName:$,fileName:A,sessionChangeKey:i.sessionChangeKey,workerParse:c,onOlderTurns:T},e[14]=T,e[15]=i.sessionChangeKey,e[16]=$,e[17]=A,e[18]=c,e[19]=R):R=e[19];const P=W7(R);let z;e[20]!==p.consumePending||e[21]!==p.pendingMessages||e[22]!==_||e[23]!==i.session||e[24]!==i.sessionChangeKey?(z={session:i.session,isLive:_,pendingMessages:p.pendingMessages,consumePending:p.consumePending,sessionChangeKey:i.sessionChangeKey},e[20]=p.consumePending,e[21]=p.pendingMessages,e[22]=_,e[23]=i.session,e[24]=i.sessionChangeKey,e[25]=z):z=e[25];const L=j7(z),I=z7(i.session,i.sessionSource,x,!1);let M;e[26]!==i.session?(M=i.session?i6(i.session):null,e[26]=i.session,e[27]=M):M=e[27];const F=M;let U;e[28]!==l?(U=()=>{l({type:"TOGGLE_EXPAND_ALL"})},e[28]=l,e[29]=U):U=e[29];const O=U,D=d2e,B=u2e;let q;e[30]!==t.dirName?(q=un(t.dirName),e[30]=t.dirName,e[31]=q):q=e[31];let W;e[32]!==q?(W={configLoading:!1,configError:null,claudeDir:null,defaultAgentKind:q,setClaudeDir:B,showConfigDialog:!1,openConfigDialog:B,handleCloseConfigDialog:B,handleConfigSaved:B,retryConfig:B,networkUrl:null,networkAccessDisabled:!1},e[32]=q,e[33]=W):W=e[33];let H;e[34]!==l||e[35]!==r||e[36]!==i||e[37]!==W||e[38]!==o?(H={state:i,dispatch:l,config:W,theme:o,isMobile:r},e[34]=l,e[35]=r,e[36]=i,e[37]=W,e[38]=o,e[39]=H):H=e[39];const K=H,Z=i.session,Y=i.sessionSource,J=h.requests,ee=h.responding,te=h.respond,se=h.respondAll;let X,ne;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=Sa("interact"),ne=[],e[40]=X,e[41]=ne):(X=e[40],ne=e[41]);let ae;e[42]!==O?(ae={handleStopSession:D,handleOpenBranches:B,handleBranchFromHere:B,handleToggleExpandAll:O,handleLoadSession:B},e[42]=O,e[43]=ae):ae=e[43];let ie;e[44]!==S||e[45]!==_||e[46]!==F||e[47]!==h.requests||e[48]!==h.respond||e[49]!==h.respondAll||e[50]!==h.responding||e[51]!==N||e[52]!==i.session||e[53]!==i.sessionSource||e[54]!==ae||e[55]!==C||e[56]!==I?(ie={session:Z,sessionSource:Y,isLive:_,sseState:N,isCompacting:S,turnError:C,undoRedo:I,pendingInteraction:F,permissionRequests:J,permissionResponding:ee,respondPermission:te,respondAllPermissions:se,isSubAgentView:!1,permissions:X,slashSuggestions:ne,slashSuggestionsLoading:!1,promptSuggestion:null,rateLimit:null,actions:ae},e[44]=S,e[45]=_,e[46]=F,e[47]=h.requests,e[48]=h.respond,e[49]=h.respondAll,e[50]=h.responding,e[51]=N,e[52]=i.session,e[53]=i.sessionSource,e[54]=ae,e[55]=C,e[56]=I,e[57]=ie):ie=e[57];const re=ie;let de;e[58]!==p||e[59]!==L?(de={chat:p,scroll:L},e[58]=p,e[59]=L,e[60]=de):de=e[60];const ce=de;let oe;e[61]!==P?(oe=()=>{P.loadMore()},e[61]=P,e[62]=oe):oe=e[62];let fe;e[63]!==d||e[64]!==P.hasMore||e[65]!==P.isLoadingOlder||e[66]!==oe?(fe={loadState:d,hasMore:P.hasMore,isLoadingOlder:P.isLoadingOlder,loadMore:oe},e[63]=d,e[64]=P.hasMore,e[65]=P.isLoadingOlder,e[66]=oe,e[67]=fe):fe=e[67];const ue=fe;let le;e[68]!==s||e[69]!==ue?(le=s(ue),e[68]=s,e[69]=ue,e[70]=le):le=e[70];let pe;e[71]!==ce||e[72]!==re||e[73]!==le?(pe=a.jsx(id,{value:re,chatValue:ce,children:le}),e[71]=ce,e[72]=re,e[73]=le,e[74]=pe):pe=e[74];let ge;return e[75]!==K||e[76]!==pe?(ge=a.jsx(bd,{value:K,children:pe}),e[75]=K,e[76]=pe,e[77]=ge):ge=e[77],ge}function u2e(){}async function d2e(){await bee().catch(f2e)}function f2e(){}function m2e(){Cl(l2e)}function p2e(n){const e=V.c(6),{info:t}=n,s=y.useRef(null);let r;e[0]!==t.provider||e[1]!==t.title?(r=i=>a.jsxs("div",{className:"flex h-dvh min-h-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2",children:[a.jsx(tr,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),a.jsx("h1",{className:"truncate text-sm font-medium text-foreground",children:t.title}),a.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:"Guest view"})]}),i.loadState==="failed"?a.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:a.jsxs(kt,{variant:"destructive",className:"max-w-sm",children:[a.jsx(Sr,{"aria-hidden":"true"}),a.jsx(Xt,{children:"Session unavailable"}),a.jsx(_t,{children:"This conversation could not be loaded. It may have been deleted on the host."})]})}):i.loadState==="loading"?a.jsx("div",{className:"flex flex-1 items-center justify-center",role:"status","aria-label":"Loading shared session",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})}):a.jsxs(a.Fragment,{children:[a.jsx(Tm,{searchInputRef:s,hasMore:i.hasMore,isLoadingOlder:i.isLoadingOlder,onLoadMore:i.loadMore}),a.jsx(Im,{children:a.jsx(x1,{agentKind:t.provider,projectCwd:null})})]})]}),e[0]=t.provider,e[1]=t.title,e[2]=r):r=e[2];let o;return e[3]!==t||e[4]!==r?(o=a.jsx(c2e,{info:t,children:r}),e[3]=t,e[4]=r,e[5]=o):o=e[5],o}function gg(n){const e=V.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("div",{className:"w-full max-w-sm",children:t})}),e[0]=t,e[1]=s):s=e[1],s}function h2e(){const n=V.c(19);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=GE(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[r,o]=y.useState(s);let i;n[2]===Symbol.for("react.memo_cache_sentinel")?(i=async()=>{o({kind:"probing"});const p=await hee();o(p.status==="ok"?{kind:"ready",info:p.info}:p.status==="unauthenticated"?{kind:"login"}:{kind:"error",message:p.message})},n[2]=i):i=n[2];const l=i;let c,u;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{t&&l()},u=[l,t],n[3]=c,n[4]=u):(c=n[3],u=n[4]),y.useEffect(c,u);let d,f;if(n[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const p=()=>{o(g2e)};return window.addEventListener(g1,p),window.addEventListener("cogpit-auth-required",p),()=>{window.removeEventListener(g1,p),window.removeEventListener("cogpit-auth-required",p)}},f=[],n[5]=d,n[6]=f):(d=n[5],f=n[6]),y.useEffect(d,f),r.kind==="ready"){let p;return n[7]!==r.info?(p=a.jsx(p2e,{info:r.info}),n[7]=r.info,n[8]=p):p=n[8],p}if(r.kind==="login"&&t){let p;return n[9]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Qye,{sessionId:t,onAuthenticated:()=>void l()}),n[9]=p):p=n[9],p}if(r.kind==="ended"){let p;return n[10]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(gg,{children:a.jsx(Ds,{children:a.jsxs(xr,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(Z8,{className:"size-4"})}),a.jsx(br,{children:"Sharing has ended"}),a.jsx(vr,{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(r.kind==="error"){let p,h;n[11]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Sr,{"aria-hidden":"true"}),h=a.jsx(Xt,{children:"Could not open this session"}),n[11]=p,n[12]=h):(p=n[11],h=n[12]);let g;n[13]!==r.message?(g=a.jsxs(kt,{variant:"destructive",children:[p,h,a.jsx(_t,{children:r.message})]}),n[13]=r.message,n[14]=g):g=n[14];let x;n[15]===Symbol.for("react.memo_cache_sentinel")?(x=t&&a.jsx(Q,{className:"mt-3 w-full",onClick:()=>void l(),children:"Try again"}),n[15]=x):x=n[15];let b;return n[16]!==g?(b=a.jsxs(gg,{children:[g,x]}),n[16]=g,n[17]=b):b=n[17],b}let m;return n[18]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(gg,{children:a.jsx(Ds,{children:a.jsxs(Fs,{className:"flex min-h-24 items-center justify-center gap-2",role:"status","aria-label":"Opening shared session",children:[a.jsx(tr,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),a.jsx(Pn,{className:"size-5 text-muted-foreground"})]})})}),n[18]=m):m=n[18],m}function g2e(n){return n.kind==="ready"?{kind:"ended"}:n}class x2e extends y.Component{constructor(){super(...arguments);Ge(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 a.jsx("main",{className:"flex h-dvh items-center justify-center bg-canvas p-6 text-foreground",children:a.jsxs(Ds,{className:"w-full max-w-lg text-center",children:[a.jsxs(xr,{className:"justify-items-center",children:[a.jsx(er,{"aria-hidden":"true",className:"mb-2 size-8 text-destructive"}),a.jsx(br,{children:a.jsx("h1",{children:"Cogpit hit a render error"})}),a.jsx(vr,{children:"Reload the app to recover. Your sessions and project files are unchanged."})]}),a.jsx(Fs,{children:a.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})}),a.jsx(um,{className:"justify-center",children:a.jsxs(Q,{onClick:()=>window.location.reload(),children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Reload Cogpit"]})})]})})}}const Y7=document.getElementById("root");if(!Y7)throw new Error("Root element not found");PP.createRoot(Y7).render(a.jsx(y.StrictMode,{children:a.jsx(x2e,{children:lm(window.location.pathname)?a.jsx(h2e,{}):a.jsx(Xye,{})})}));export{_r as $,kt as A,Q as B,fn as C,sr as D,dm as E,cfe as F,Eo as G,b1 as H,Ar as I,G as J,Em as K,Ln as L,Mn as M,Yn as N,zn as O,dxe as P,Dn as Q,sn as R,qM as S,sT as T,Ce as U,Gc as V,x6 as W,tre as X,Nn as Y,Fe as Z,N2e as _,VM as a,Js as a$,vn as a0,rs as a1,ba as a2,ofe as a3,yn as a4,rb as a5,ob as a6,ib as a7,Dte as a8,lb as a9,f6 as aA,Pf as aB,Uf as aC,Mde as aD,fee as aE,As as aF,A1 as aG,$1 as aH,Wb as aI,Or as aJ,Wc as aK,Rx as aL,nz as aM,sz as aN,S6 as aO,jr as aP,Fa as aQ,xr as aR,br as aS,Fs as aT,um as aU,Ds as aV,xm as aW,Wx as aX,Y6 as aY,so as aZ,vt as a_,cb as aa,ab,db as ac,ub as ad,Kn as ae,ea as af,Rme as ag,Pn as ah,xi as ai,To as aj,Tz as ak,T2e as al,Ic as am,a0 as an,Pc as ao,Ez as ap,sb as aq,Mf as ar,e7 as as,qo as at,xt as au,kb as av,Jr as aw,zf as ax,la as ay,d6 as az,HM as b,Tl as b$,Xt as b0,vr as b1,Wte as b2,qc as b3,Cbe as b4,Sm as b5,wa as b6,XM as b7,un as b8,Er as b9,is as bA,pie as bB,kie as bC,W2e as bD,iA as bE,mn as bF,q2e as bG,V2e as bH,_2e as bI,aa as bJ,Pd as bK,y5 as bL,Zt as bM,Yt as bN,Gt as bO,lo as bP,ar as bQ,iT as bR,aT as bS,hl as bT,gl as bU,Jee as bV,za as bW,ha as bX,ehe as bY,Cn as bZ,j2e as b_,Gm as ba,Tc as bb,Xx as bc,Ec as bd,On as be,fT as bf,i9 as bg,Yee as bh,Hee as bi,Fx as bj,zy as bk,Ux as bl,Nr as bm,Kx as bn,Spe as bo,Ff as bp,nv as bq,Pm as br,pi as bs,Hs as bt,TN as bu,$d as bv,Nl as bw,cm as bx,Cr as by,Oa as bz,WM as c,Eye as c$,Kte as c0,HI as c1,Sc as c2,nt as c3,E2e as c4,Nm as c5,Cm as c6,_m as c7,fi as c8,H2e as c9,hM as cA,k2e as cB,R1e as cC,_x as cD,Hr as cE,Dme as cF,xs as cG,Lx as cH,CM as cI,qN as cJ,Rc as cK,P5 as cL,hn as cM,Oc as cN,qr as cO,$c as cP,gs as cQ,Yoe as cR,Il as cS,Goe as cT,zme as cU,Zoe as cV,Hoe as cW,Koe as cX,Voe as cY,PN as cZ,Q9 as c_,Rn as ca,va as cb,Lte as cc,Gn as cd,l9 as ce,a9 as cf,FE as cg,HQ as ch,SN as ci,vN as cj,Cg as ck,yN as cl,wN as cm,bN as cn,Zw as co,A2e as cp,vo as cq,T0 as cr,J0 as cs,qE as ct,B2e as cu,Ex as cv,zs as cw,tN as cx,_c as cy,h1e as cz,zM as d,Xs as d0,Ot as d1,Rf as d2,Rd as d3,V9 as d4,C2e as d5,jt as d6,Dh as d7,K2e as e,$me as f,G2e as g,rr as h,ao as i,or as j,ir as k,tn as l,Ko as m,Go as n,X2e as o,_t as p,Vc as q,Y2e as r,J2e as s,Q2e as t,Z2e as u,cxe as v,on as w,fR as x,Si as y,Aa as z};
|