codesesh 0.4.0 → 0.4.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.
@@ -65,4 +65,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
65
65
 
66
66
  `);return n.trim()?n:Zb(e)}function fx(e){let t=Ab(e.inputValue);if(e.status===`completed`){let e=Mb(t.content);if(e.trim())return qb(e)}return Zb(e)}function px(e){let t=Ab(Ab(e.state).arguments),n=kb(t.agent_type),r=kb(e.nickname),i=[kb(t.model),kb(t.reasoning_effort)].filter(Boolean).join(`-`);return[[n,r].filter(Boolean).join(` - `),i].filter(Boolean).join(` `)}function mx(e){let t=Ab(e.state);return kb(t.prompt)||kb(Ab(t.arguments).message)||``}function hx(e){let t=kb(e.nickname);return e.role===`assistant`&&t?`AGENT (${t})`:e.role===`user`?`USER`:e.role===`tool`?`TOOL`:`AGENT`}function gx(e,t){if(t.toLowerCase()!==`cursor`)return e;let n=[];for(let t of e){if(t.role!==`tool`){n.push({...t,parts:[...t.parts]});continue}let e=n.at(-1);if(e?.role===`assistant`){e.parts.push(...t.parts);continue}n.push({...t,parts:[...t.parts]})}return n}function _x(e){let t=e.state||{},n=t.status,r=n===`running`||n===`error`||n===`completed`?n:`completed`,i=t.output??t.result??``,a=t.error??``,o=wb(t.input??t.arguments??{}),s=t.metadata??{};return{status:r,command:Ob(o),inputValue:o,outputValue:i,errorValue:a,metadataValue:s,inputText:Cb(o)}}function vx(e,t){let n=(t.command||t.inputText||`{}`).replace(/\s+/g,` `).trim(),r=n.length>72?`${n.slice(0,72)}...`:n;return{Icon:Hr,title:Yb(e),secondaryText:r?`(${r})`:void 0,details:[],expandable:!0,showInputPreview:!0,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}function yx(e,t,n){let r=jb(Ab(t.inputValue).name);return{...n,Icon:Gr,title:jb(e.tool)||`skill`,secondaryText:r||void 0,expandable:!1,showInputPreview:!1}}function bx(e,t){let n=vx(e,t),r=(e.tool||``).toLowerCase(),i=Ab(t.inputValue),a=Qb(t.inputValue);if(r===`read`)return{...n,Icon:Er,title:`read`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:tx(t.outputValue),language:ip(a),isCode:!0}};if(r===`edit`){let e=ix(a,Mb(i.old_string),Mb(i.new_string));return{...n,Icon:Pr,title:`edit`,secondaryText:a||void 0,showInputPreview:!1,outputContent:e.length>0?{kind:`structured-diff`,blocks:e}:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}return r===`write`?{...n,Icon:Vr,title:`write`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:fx(t),language:ip(a),isCode:!0}}:{...n,title:Yb(e)}}function xx(e,t){let n=vx(e,t),r=(e.tool||``).toLowerCase(),i=Ab(t.inputValue);if(r===`glob`){let r=jb(i.pattern);return{...n,Icon:Fr,title:e.tool||`glob`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}if(r===`grep`){let r=[jb(i.path),jb(i.pattern)].filter(Boolean).join(` · `);return{...n,Icon:Fr,title:e.tool||`grep`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}if(r===`bash`){let r=jb(i.description),a=jb(i.command),o=r?`${r}${a?` (${a})`:``}`:a?`(${a})`:void 0;return{...n,Icon:Hr,title:e.tool||`bash`,secondaryText:o,showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}if(r===`read`){let r=Qb(t.inputValue);return{...n,Icon:Er,title:e.tool||`read`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:tx(t.outputValue),language:ip(r),isCode:!0}}}if(r===`edit`){let r=Qb(t.inputValue);return{...n,Icon:Pr,title:e.tool||`edit`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:dx(t),language:`diff`,isCode:!0}}}if(r===`write`){let r=Qb(t.inputValue),i=t.status===`completed`;return{...n,Icon:Vr,title:e.tool||`write`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:fx(t),language:ip(r),isCode:i}}}return r===`skill`?yx(e,t,n):n}function Sx(e,t){let n=vx(e,t),r=(e.tool||``).toLowerCase(),i=Ab(t.inputValue);if(r===`glob`){let r=jb(i.pattern);return{...n,Icon:Fr,title:e.title||`glob`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}if(r===`grep`){let r=[jb(i.path),jb(i.pattern)].filter(Boolean).join(` · `);return{...n,Icon:Fr,title:e.title||`grep`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}if(r===`shell`){let r=jb(i.command);return{...n,Icon:Hr,title:e.title||`bash`,secondaryText:r?`(${r})`:void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}if(r===`readfile`){let r=Qb(t.inputValue);return{...n,Icon:Er,title:e.title||`read`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:tx(t.outputValue),language:ip(r),isCode:!0}}}if(r===`strreplacefile`){let r=Qb(t.inputValue),i=ux(t,r);return{...n,Icon:Pr,title:e.title||`edit`,secondaryText:r||void 0,showInputPreview:!1,outputContent:i.length>0?{kind:`structured-diff`,blocks:i}:{kind:`plain`,text:dx(t),language:`diff`,isCode:!0}}}if(r===`writefile`){let r=Qb(t.inputValue);return{...n,Icon:Vr,title:e.title||`write`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:fx(t),language:ip(r),isCode:t.status===`completed`}}}return n}function Cx(e,t){let n=vx(e,t),r=(e.tool||``).toLowerCase();if(r===`skill`)return yx(e,t,n);if(r===`exec_command`){let e=Gf(t.inputValue,Zb(t),ip);return{...n,Icon:Hr,title:`bash`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:e.outputAnalysis.text,language:e.outputAnalysis.language,isCode:e.outputAnalysis.isCode}}}if(r===`write_stdin`){let e=Kf(t.inputValue,Zb(t),ip);return{...n,Icon:Hr,title:`bash`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:e.outputAnalysis.text,language:e.outputAnalysis.language,isCode:e.outputAnalysis.isCode}}}if(r===`request_user_input`){let e=qf(t.inputValue,Zb(t));return{...n,Icon:Mr,title:`ask`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:e.outputContent}}if(r===`patch`){let r=gf(t.inputValue),i=vf(r);return{...n,Icon:Pr,title:Yb(e,`patch`),secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:xf(r,Zb(t),ip)}}if(r===`subagent`){let r=mx(e),i=Zb(t);return{...n,Icon:Dr,title:px(e)||Yb(e,`subagent`),secondaryText:void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:r||i,language:`markdown`,isCode:!1}}}return n}function wx(e,t){let n=vx(e,t),r=(e.tool||``).toLowerCase(),i=Ab(t.inputValue),a=Qb(t.inputValue);if(r===`read_file_v2`){let e=nx(t.outputValue);return{...n,Icon:Er,title:`read`,secondaryText:a||void 0,details:e===`No output captured.`?[{label:`Lines`,value:jb($b(t.outputValue).totalLinesInFile)}]:[],showInputPreview:!1,outputContent:{kind:`plain`,text:e,language:ip(a),isCode:e!==`No output captured.`}}}if(r===`edit_file_v2`){let e=qb(Mb(i.streamingContent));return{...n,Icon:Pr,title:`edit`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:e||Zb(t),language:e?`diff`:`text`,isCode:!!e}}}if(r===`ripgrep_raw_search`){let e=jb(i.pattern),r=[jb(i.path),e].filter(Boolean).join(` · `);return{...n,Icon:Fr,title:`grep`,secondaryText:r||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}if(r===`glob_file_search`){let e=jb(i.globPattern),r=[jb(i.targetDirectory),e].filter(Boolean).join(` · `);return{...n,Icon:Fr,title:`glob`,secondaryText:r||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:rx(t.outputValue),language:`text`,isCode:!1}}}if(r===`run_terminal_command_v2`){let e=jb(i.command),r=jb(i.commandDescription),a=r?`${r}${e?` (${e})`:``}`:e?`(${e})`:void 0;return{...n,Icon:Hr,title:`bash`,secondaryText:a,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:Zb(t),language:`text`,isCode:!1}}}return{...n,title:Yb(e)}}function Tx(e,t,n){let r=e.toLowerCase();return r===`opencode`?xx(t,n):r===`codex`?Cx(t,n):r===`kimi`?Sx(t,n):r===`claudecode`?bx(t,n):r===`cursor`?wx(t,n):vx(t,n)}function Ex(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Dx(e){if(typeof e==`number`&&e<=0)return`Unknown time`;let t=null;if(typeof e==`number`){let n=e<10**12?e*1e3:e;t=new Date(n)}else if(typeof e==`string`&&e.trim()){let n=Number(e);t=!Number.isNaN(n)&&n>0?new Date(n<10**12?n*1e3:n):new Date(e)}return!t||Number.isNaN(t.getTime())?`Unknown time`:t.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!0})}function Ox({session:e,highlightQuery:t}){let n=(e.slug||``).split(`/`)[0]||Ln.getDefaultAgentKey()||`claudecode`,r=(0,S.useMemo)(()=>gx(e.messages,n),[e.messages,n]),i=(0,S.useMemo)(()=>r.filter(e=>cf(e)),[r]),{toolAnchorIds:a,summary:o}=(0,S.useMemo)(()=>Ub(i),[i]),s=(0,S.useMemo)(()=>Zf(i),[i]),[c,l]=(0,S.useState)(()=>new Set(s.filterIds)),u=(0,S.useMemo)(()=>[...s.filterIds].toSorted().join(`|`),[s.filterIds]),d=(0,S.useMemo)(()=>tp(i,c),[i,c]);return(0,S.useEffect)(()=>{l(new Set(s.filterIds))},[u,s.filterIds]),i.length===0?(0,Z.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前会话暂无可展示的消息内容。`}):(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-8 px-2 md:px-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:[(0,Z.jsx)(Px,{summary:typeof e.summary_files==`string`?e.summary_files:void 0}),(0,Z.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:items-start`,children:[(0,Z.jsx)(Ax,{toc:s,fileChangeSummary:o,baseDirectory:e.directory,selectedFilters:c,onToggle:e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}),(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:d.length>0?d.map(({msg:e,blocks:r},i)=>(0,Z.jsx)(Fx,{msg:e,blocks:r,toolAnchorIds:a,formatTokens:Ex,sessionAgentKey:n,highlightQuery:t},i)):(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前筛选条件下暂无可展示的消息内容。`})})]})]})}var kx=[{id:`user`,label:`User`},{id:`agent_message`,label:`Agent Responses`},{id:`thinking`,label:`Thinking`},{id:`plan`,label:`Plans`},{id:`tools_all`,label:`Tools`}];function Ax({toc:e,fileChangeSummary:t,baseDirectory:n,selectedFilters:r,onToggle:i}){let a=r.has(`tools_all`);return(0,Z.jsx)(`aside`,{className:`lg:sticky lg:top-4`,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,Z.jsx)(Lr,{className:`size-3.5 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`Session TOC`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 p-3`,children:[kx.filter(({id:t})=>e.counts[t]>0).map(({id:t,label:n})=>(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:r.has(t),onChange:()=>i(t),className:`size-3.5 rounded border-[var(--console-border-strong)] accent-[var(--console-accent-strong)]`}),(0,Z.jsx)(`span`,{className:`console-mono min-w-0 flex-1 text-xs text-[var(--console-text)]`,children:n}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.counts[t]})]},t)),e.tools.length>0?(0,Z.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] pt-2`,children:e.tools.map(e=>(0,Z.jsxs)(`label`,{className:ga(`flex items-center gap-3 rounded-sm px-2 py-2 transition-colors`,a?`cursor-pointer hover:bg-[var(--console-surface-muted)]`:`cursor-not-allowed opacity-50`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:a&&r.has(e.id),disabled:!a,onChange:()=>i(e.id),className:`size-3.5 rounded border-[var(--console-border-strong)] accent-[var(--console-accent-strong)]`}),(0,Z.jsx)(`span`,{className:`console-mono min-w-0 flex-1 text-xs text-[var(--console-muted)]`,children:e.label}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]},e.id))}):null]})]}),(0,Z.jsx)(jx,{summary:t,baseDirectory:n})]})})}function jx({summary:e,baseDirectory:t}){let n=[{key:`read`,label:`Read`,Icon:Fr,items:e.read},{key:`edit`,label:`Edit`,Icon:Pr,items:e.edit},{key:`write`,label:`Write`,Icon:Vr,items:e.write},{key:`delete`,label:`Delete`,Icon:Nr,items:e.delete}].filter(e=>e.items.length>0);return n.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,Z.jsx)(Ir,{className:`size-3.5 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`File Tracker`})]}),(0,Z.jsx)(`div`,{className:`space-y-3 p-3`,children:n.map(({key:e,label:n,Icon:r,items:i})=>(0,Z.jsx)(Mx,{label:n,Icon:r,items:i,baseDirectory:t},e))})]})}function Mx({label:e,Icon:t,items:n,baseDirectory:r}){let[i,a]=(0,S.useState)(!1);return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa]`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(t,{className:`size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`console-mono min-w-0 flex-1 text-[11px] font-semibold uppercase tracking-[0.12em] text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:n.length}),i?(0,Z.jsx)(Ar,{className:`size-3.5 shrink-0 text-[var(--console-muted)]`}):(0,Z.jsx)(kr,{className:`size-3.5 shrink-0 text-[var(--console-muted)]`})]}),i?(0,Z.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] p-2`,children:n.map(e=>(0,Z.jsx)(Nx,{item:e,baseDirectory:r},`${e.path}:${e.latestAnchorId}`))}):null]})}function Nx({item:e,baseDirectory:t}){let[n,r]=(0,S.useState)(0);function i(t){let n=e.anchors.length;if(n===0)return;let i=(t%n+n)%n;r(i);let a=e.anchors[i];a&&Gb(a.anchorId)}return(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`button`,{type:`button`,title:e.path,onClick:()=>i(n),className:`min-w-0 flex-1 text-left`,children:(0,Z.jsx)(`span`,{className:`console-mono block break-all text-xs text-[var(--console-text)]`,children:Wb(e.path,t)})}),e.anchors.length>1?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Previous ${e.path}`,onClick:()=>i(n-1),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] transition-colors hover:bg-white`,children:(0,Z.jsx)(Ar,{className:`size-3`})}),(0,Z.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[n+1,`/`,e.anchors.length]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Next ${e.path}`,onClick:()=>i(n+1),className:`rounded-sm border border-[var(--console-border)] p-1 text-[var(--console-muted)] transition-colors hover:bg-white`,children:(0,Z.jsx)(kr,{className:`size-3`})})]}):(0,Z.jsx)(`button`,{type:`button`,title:`Jump to tool call`,onClick:()=>i(0),className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:e.count})]})}function Px({summary:e,defaultExpanded:t=!1}){let n=typeof e==`string`?e.trim():``,[r,i]=(0,S.useState)(t);return n?(0,Z.jsxs)(`section`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>i(e=>!e),children:[(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:[(0,Z.jsx)(Ir,{className:`size-3.5 text-[var(--console-accent)]`}),`Session Summary`]}),r?(0,Z.jsx)(Ar,{className:`size-3.5 text-[var(--console-muted)]`}):(0,Z.jsx)(kr,{className:`size-3.5 text-[var(--console-muted)]`})]}),r?(0,Z.jsx)(`div`,{className:`border-t border-[var(--console-border)] px-4 py-4`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,Z.jsx)(rf,{text:n})})}):null]}):null}function Fx({msg:e,blocks:t,toolAnchorIds:n,formatTokens:r,sessionAgentKey:i,highlightQuery:a}){let o=e.role===`user`,s=df(e,i),c=t||sf(e.parts),l=()=>{let e=i.toLowerCase(),t=Ln.getAgentName(e),n=Ln.agents[e]?.icon;return(0,Z.jsx)(Z.Fragment,{children:n?(0,Z.jsx)(`img`,{src:n,alt:t,className:`size-4 rounded-sm object-cover`}):(0,Z.jsx)(Dr,{className:`size-4 text-[var(--console-muted)]`})})},u=e.mode?e.mode.toUpperCase():null,d=e.model||null,f=hx(e),p=Dx(e.time_created);return(0,Z.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:o?(0,Z.jsx)(Wr,{className:`size-4 text-[var(--console-muted)]`}):l()})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-sm font-bold tracking-wide text-[var(--console-text)]`,children:f}),(0,Z.jsx)(`time`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:p}),u&&(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:u}),d&&(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:d})]}),s?(0,Z.jsx)(Ix,{}):c.map((e,t)=>e.type===`reasoning`?(0,Z.jsx)(Lx,{parts:e.parts,highlightQuery:a},t):e.type===`plan`?(0,Z.jsx)(zx,{parts:e.parts,highlightQuery:a},t):e.type===`tool`?(0,Z.jsx)(Rx,{parts:e.parts,toolAnchorIds:n,sessionAgentKey:i,highlightQuery:a},t):(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:e.parts.map((e,t)=>(0,Z.jsx)(Sb,{text:af(e.text),highlightQuery:a},t))})},t)),!o&&(e.tokens||e.cost)&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.tokens?.input?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`INPUT `,r(e.tokens.input)]}):null,e.tokens?.output?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`OUTPUT `,r(e.tokens.output)]}):null,e.tokens?.reasoning?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`REASONING `,r(e.tokens.reasoning)]}):null,e.cost?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`COST $`,e.cost.toFixed(4)]}):null]})]})]})})}function Ix(){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-start gap-2`,children:(0,Z.jsx)(`div`,{className:`w-full rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] md:w-[560px]`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Br,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:`abort`})})]})})})})}function Lx({parts:e,highlightQuery:t}){let[n,r]=(0,S.useState)(!1),i=e.map(e=>af(e.text)).filter(Boolean).join(`
67
67
 
68
- `);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-thinking-border)] bg-[var(--console-thinking-bg)]`,children:[(0,Z.jsxs)(`div`,{className:`flex cursor-pointer items-center justify-between bg-[var(--console-surface-muted)] px-3 py-2`,onClick:()=>r(!n),children:[(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-2 text-xs font-medium text-[var(--console-muted)]`,children:[(0,Z.jsx)(Rr,{className:`size-3.5`}),`Thinking`]}),(0,Z.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:n?(0,Z.jsx)(Ar,{className:`w-4 h-4`}):(0,Z.jsx)(kr,{className:`w-4 h-4`})})]}),n&&(0,Z.jsx)(`div`,{className:`border-t border-dashed border-[var(--console-thinking-border)] px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`console-mono whitespace-pre-wrap text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(i,t)})})]})}function Rx({parts:e,toolAnchorIds:t,sessionAgentKey:n,highlightQuery:r}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,i)=>(0,Z.jsx)(Vx,{tool:e,anchorId:t.get(e),sessionAgentKey:n,highlightQuery:r},i))})})}function zx({parts:e,highlightQuery:t}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,n)=>(0,Z.jsx)(Bx,{part:e,highlightQuery:t},n))})}function Bx({part:e,highlightQuery:t}){let[n,r]=(0,S.useState)(!1),i=Cf(e),a=i.approvalStatus===`fail`?vb.error:vb.completed,o=a.icon;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${i.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:i.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>r(!n),children:[(0,Z.jsx)(Or,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:n?(0,Z.jsx)(Ar,{className:`size-3.5`}):(0,Z.jsx)(kr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Or,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${a.className}`,children:[(0,Z.jsx)(o,{className:`size-3`}),a.label]})]}),i.expandable&&n?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:i.contentLabel})}),(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,Z.jsx)(Sb,{text:i.contentMarkdown,highlightQuery:t})})})]}):null]})}function Vx({tool:e,anchorId:t,sessionAgentKey:n,highlightQuery:r}){let[i,a]=(0,S.useState)(!1),o=_x(e),s=Tx(n,e,o),c=vb[o.status],l=c.icon,u=s.Icon;return(0,Z.jsxs)(`div`,{id:t,className:`scroll-mt-6 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${s.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:s.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>a(!i),children:[(0,Z.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:s.title}),s.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(s.secondaryText,r)}):null]}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:i?(0,Z.jsx)(Ar,{className:`size-3.5`}):(0,Z.jsx)(kr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:s.title}),s.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(s.secondaryText,r)}):null]})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${c.className}`,children:[(0,Z.jsx)(l,{className:`size-3 ${o.status===`running`?`animate-spin`:``}`}),c.label]})]}),s.expandable&&i?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Output`})}),(0,Z.jsxs)(`div`,{className:`space-y-3 p-3`,children:[s.details.length>0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:s.details.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,Z.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] font-semibold uppercase tracking-wide text-[var(--console-muted)] md:w-24`,children:e.label}),(0,Z.jsx)(`span`,{className:`console-mono whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-text)]`,children:xb(e.value,r)})]},`${e.label}:${e.value}`))})}):null,(0,Z.jsx)(_b,{outputContent:s.outputContent})]}),s.showInputPreview?(0,Z.jsxs)(`div`,{className:`border-t border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Input Preview`}),(0,Z.jsx)(`pre`,{className:`console-mono mt-1 max-h-[200px] overflow-x-auto whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(o.inputText||`{}`,r)})]}):null]}):null]})}var Hx=[{id:`1`,roleWidth:`w-14`,timeWidth:`w-20`,bodyWidths:[`w-full`,`w-10/12`,`w-7/12`]},{id:`2`,roleWidth:`w-16`,timeWidth:`w-24`,bodyWidths:[`w-9/12`,`w-7/12`]},{id:`3`,roleWidth:`w-14`,timeWidth:`w-16`,bodyWidths:[`w-full`,`w-11/12`,`w-8/12`,`w-5/12`]},{id:`4`,roleWidth:`w-16`,timeWidth:`w-20`,bodyWidths:[`w-10/12`,`w-8/12`]},{id:`5`,roleWidth:`w-14`,timeWidth:`w-24`,bodyWidths:[`w-full`,`w-10/12`,`w-9/12`]}];function Ux({className:e}){return(0,Z.jsx)(`div`,{className:`rounded-sm bg-[var(--console-border)] ${e}`})}function Wx(){return(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-8 px-2 md:px-4`,children:[(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-8`,children:Hx.map(e=>(0,Z.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,Z.jsx)(`div`,{className:`size-3.5 rounded-sm bg-[var(--console-border-strong)] animate-pulse`})})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Ux,{className:`${e.roleWidth} h-3 animate-pulse`}),(0,Z.jsx)(Ux,{className:`${e.timeWidth} h-2.5 animate-pulse`})]}),(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.bodyWidths.map(t=>(0,Z.jsx)(Ux,{className:`${t} h-3 animate-pulse`},`${e.id}-${t}`))})})]})]})},e.id))}),(0,Z.jsx)(`div`,{className:`min-h-24 flex-1 rounded-sm border border-[var(--console-border)] bg-white/60 animate-pulse`})]})}function Gx({active:e,onToggle:t,className:n=``}){return(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":e?`取消收藏会话`:`收藏会话`,title:e?`取消收藏`:`收藏`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border transition-colors ${n} ${e?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] opacity-70 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] hover:opacity-100`}`,children:(0,Z.jsx)(Ur,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function Kx(e){return e.toLocaleString(`en-US`)}function qx(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function Jx(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Yx({label:e,value:t,hint:n}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function Xx({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function Zx({code:e,title:t,description:n,aside:r,iconSrc:i,iconAlt:a}){return(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border-strong)] bg-white p-5 md:p-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Z.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:e}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:a||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,Z.jsx)(`h2`,{className:`console-mono text-2xl leading-tight font-semibold tracking-tight text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-sm border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`STATUS NOTE`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function Qx({agentItems:e}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Known Agents`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${e.key}`,className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 transition-colors duration-200 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-accent)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function $x({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Sessions`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=t(e.agentKey,e.id);return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(vn,{to:`/${e.fullPath}`,className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` ·`,` `,Jx(e.time_updated||e.time_created)]})]}),(0,Z.jsx)(Gx,{active:r,onToggle:()=>n(e)})]})},e.id)})})]})}function eS({type:e,sessions:t,agentItems:n,activeAgentKey:r,attemptedAgentKey:i,attemptedSessionSlug:a,isBookmarked:o,onToggleBookmark:s}){let c=t.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),l=c.slice(0,5),u=t.reduce((e,t)=>e+t.stats.message_count,0),d=t.reduce((e,t)=>e+qx(t.stats),0),f=c[0]?.time_updated||c[0]?.time_created;if(e===`missing-agent`){let e=`/${i||`unknown`}${a?`/${a}`:``}`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(Zx,{code:`404 / AGENT`,title:`This agent isn't on the roster.`,description:`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`,aside:`Choose one of the available agents to continue.`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(Xx,{label:`Requested Agent`,value:i||`unknown`}),(0,Z.jsx)(Xx,{label:`Requested Path`,value:e}),a?(0,Z.jsx)(Xx,{label:`Requested Session`,value:a}):null]}),(0,Z.jsx)(Qx,{agentItems:n})]})}if(e===`missing-session`){let e=r||Ln.getDefaultAgentKey()||`claudecode`,t=Ln.agents[e],n=t?.name||e,i=t?.icon,c=a||`unknown-session`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(Zx,{code:`404 / SESSION`,title:`This session isn't in the index.`,description:`${n} is available, but the session you're looking for does not exist in the current index. The slug may be incorrect, or the record may never have been part of this dataset.`,aside:`We checked the current path, but nothing matched. The session list on the left is still available.`,iconSrc:i,iconAlt:n}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:`Agent`}),(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,Z.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,Z.jsx)(Xx,{label:`Session`,value:c})]}),(0,Z.jsx)($x,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}if(e===`global`)return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(Yx,{label:`Total Sessions`,value:Kx(t.length)}),(0,Z.jsx)(Yx,{label:`Total Messages`,value:Kx(u)}),(0,Z.jsx)(Yx,{label:`Latest Activity`,value:Jx(f),hint:f?new Date(f).toLocaleString(`zh-CN`):void 0})]}),(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agents`}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:n.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${e.key}`,className:`flex items-center gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]}),(0,Z.jsx)($x,{sessions:l,isBookmarked:o,onToggleBookmark:s})]});let p=r?Ln.agents[r]:null,m=p?p.name:`Unknown Agent`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[p?(0,Z.jsx)(`img`,{src:p.icon,alt:m,className:`size-6 object-contain`}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:m}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Select a session from the left to view details`})]})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(Yx,{label:`Sessions`,value:Kx(t.length)}),(0,Z.jsx)(Yx,{label:`Messages`,value:Kx(u)}),(0,Z.jsx)(Yx,{label:`Tokens`,value:Kx(d)})]}),(0,Z.jsx)($x,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}var tS=`codesesh:bookmarks:v1`;function nS(e){return typeof e==`object`&&!!e}function rS(e){return nS(e)?typeof e.message_count==`number`&&typeof e.total_input_tokens==`number`&&typeof e.total_output_tokens==`number`&&typeof e.total_cost==`number`&&(e.total_tokens==null||typeof e.total_tokens==`number`):!1}function iS(e){return nS(e)?typeof e.sessionId==`string`&&typeof e.agentKey==`string`&&typeof e.fullPath==`string`&&typeof e.title==`string`&&typeof e.directory==`string`&&typeof e.time_created==`number`&&(e.time_updated==null||typeof e.time_updated==`number`)&&(e.bookmarked_at==null||typeof e.bookmarked_at==`number`)&&rS(e.stats):!1}function aS(e,t){return`${e}:${t}`}function oS(e,t){return{sessionId:e.id,agentKey:t,fullPath:e.slug,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats,bookmarked_at:Date.now()}}function sS(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(tS);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(iS).toSorted(lS):[]}catch{return[]}}function cS(){typeof window>`u`||window.localStorage.removeItem(tS)}function lS(e,t){let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n}function uS(e,t){if(e.length===0||t.length===0)return e;let n=new Map(t.map(e=>{let t=oS(e,e.slug.split(`/`)[0]?.toLowerCase()??`unknown`);return[aS(t.agentKey,t.sessionId),t]})),r=!1,i=e.map(e=>{let t=n.get(aS(e.agentKey,e.sessionId));return!t||t.fullPath===e.fullPath&&t.title===e.title&&t.directory===e.directory&&t.time_created===e.time_created&&t.time_updated===e.time_updated&&t.stats.message_count===e.stats.message_count&&t.stats.total_input_tokens===e.stats.total_input_tokens&&t.stats.total_output_tokens===e.stats.total_output_tokens&&t.stats.total_cost===e.stats.total_cost&&t.stats.total_tokens===e.stats.total_tokens?e:(r=!0,{...t,bookmarked_at:e.bookmarked_at})});return r?i.toSorted(lS):e}function dS(e){return e.toLocaleString(`en-US`)}function fS(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:dS(e)}function pS(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function mS({label:e,value:t,hint:n}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function hS(e){return e.length>=10?e.slice(5):e}function gS({buckets:e}){let[t,n]=(0,S.useState)(null),r=(0,S.useMemo)(()=>Math.max(1,...e.map(e=>e.sessions)),[e]),i=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]),a=(0,S.useMemo)(()=>{if(e.length===0)return new Set;let t=Math.min(6,e.length);if(t===1)return new Set([0]);let n=new Set;for(let r=0;r<t;r+=1)n.add(Math.round(r*(e.length-1)/(t-1)));return n},[e.length]);return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Activity`}),(0,Z.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Session activity · last `,e.length,` days`]})]}),(0,Z.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${dS(t.sessions)} sessions · ${dS(t.messages)} msgs`:`${dS(i)} in range`})]}),(0,Z.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.sessions>0?Math.max(Math.round(e.sessions/r*128),4):2,a=`${e.date} · ${e.sessions} sessions · ${e.messages} msgs`,o=t?.date===e.date;return(0,Z.jsx)(`div`,{title:a,onMouseEnter:()=>n(e),className:`flex-1 cursor-default rounded-t-[1px] transition-opacity ${e.sessions>0?`bg-[var(--console-accent)]`:`bg-[var(--console-surface-muted)]`} ${o?`opacity-70`:`opacity-100`}`,style:{height:`${i}px`}},e.date)})}),(0,Z.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,Z.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?hS(e.date):``},e.date))})]})}var _S={input:`#4A9EFF`,output:`#7C5CFF`,cache_read:`#3FB68B`,cache_create:`#E8A23B`},vS={input:`Input`,output:`Output`,cache_read:`Cache Read`,cache_create:`Cache Create`};function yS({buckets:e}){let[t,n]=(0,S.useState)(null),r=(0,S.useMemo)(()=>Math.max(1,...e.map(e=>e.input+e.output+e.cache_read+e.cache_create)),[e]),i=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.input+t.output+t.cache_read+t.cache_create,0),[e]),a=(0,S.useMemo)(()=>{if(e.length===0)return new Set;let t=Math.min(6,e.length);if(t===1)return new Set([0]);let n=new Set;for(let r=0;r<t;r+=1)n.add(Math.round(r*(e.length-1)/(t-1)));return n},[e.length]);return i===0?null:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Token Activity`}),(0,Z.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Token breakdown · last `,e.length,` days`]})]}),(0,Z.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${fS(t.input+t.output+t.cache_read+t.cache_create)} total`:`${fS(i)} in range`})]}),t?(0,Z.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,Z.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:_S[e]}}),vS[e],`: `,fS(t[e])]},e))}):(0,Z.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,Z.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:_S[e]}}),vS[e]]},e))}),(0,Z.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.input+e.output+e.cache_read+e.cache_create,a=i>0?Math.max(Math.round(i/r*128),4):2,o=t?.date===e.date,s=i>0?[{key:`input`,value:e.input},{key:`output`,value:e.output},{key:`cache_read`,value:e.cache_read},{key:`cache_create`,value:e.cache_create}]:[];return(0,Z.jsx)(`div`,{onMouseEnter:()=>n(e),className:`flex flex-1 cursor-default flex-col justify-end overflow-hidden rounded-t-[1px] transition-opacity ${o?`opacity-70`:`opacity-100`}`,style:{height:`${a}px`},children:i>0?s.map(e=>{let t=Math.max(Math.round(e.value/i*a),0);return t===0?null:(0,Z.jsx)(`div`,{style:{height:`${t}px`,backgroundColor:_S[e.key]}},e.key)}):(0,Z.jsx)(`div`,{className:`h-full bg-[var(--console-surface-muted)]`})},e.date)})}),(0,Z.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,Z.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?hS(e.date):``},e.date))})]})}var bS=[`#4A9EFF`,`#7C5CFF`,`#3FB68B`,`#E8A23B`,`#E5484D`,`#5BCEDA`,`#F472B6`,`#A78BFA`,`#FB923C`,`#6EE7B7`];function xS(e,t,n,r,i){let a={x:e+n*Math.cos(r),y:t+n*Math.sin(r)},o={x:e+n*Math.cos(i),y:t+n*Math.sin(i)},s=+(i-r>Math.PI);return`M ${a.x} ${a.y} A ${n} ${n} 0 ${s} 1 ${o.x} ${o.y}`}function SS({entries:e}){let[t,n]=(0,S.useState)(null),r=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.tokens,0),[e]);if(e.length===0||r===0)return(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No model data yet`});let i=.02,a=-Math.PI/2,o=e.map((e,t)=>{let n=e.tokens/r,o=a+i/2,s=a+n*Math.PI*2-i/2;return a+=n*Math.PI*2,{entry:e,startAngle:o,endAngle:s,fraction:n,color:bS[t%bS.length]}}),s=t===null?null:e[t];return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Model Distribution`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` models`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,Z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Z.jsx)(`svg`,{width:160,height:160,viewBox:`0 0 160 160`,onMouseLeave:()=>n(null),children:o.map((e,r)=>{if(e.fraction<.003)return null;let i=e.fraction>.997,a=t===r;if(i)return(0,Z.jsx)(`g`,{onMouseEnter:()=>n(r),children:(0,Z.jsx)(`circle`,{cx:80,cy:80,r:70,fill:`none`,stroke:e.color,strokeWidth:25,opacity:a?.8:1})},e.entry.model);let o=xS(80,80,70,e.startAngle,e.endAngle),s=xS(80,80,45,e.endAngle,e.startAngle),c={x:80+70*Math.cos(e.endAngle),y:80+70*Math.sin(e.endAngle)},l={x:80+45*Math.cos(e.endAngle),y:80+45*Math.sin(e.endAngle)},u={x:80+45*Math.cos(e.startAngle),y:80+45*Math.sin(e.startAngle)};return(0,Z.jsx)(`path`,{d:`${o} L ${c.x} ${c.y} L ${l.x} ${l.y} ${s} L ${u.x} ${u.y} Z`,fill:e.color,opacity:a?.8:1,className:`cursor-default transition-opacity`,onMouseEnter:()=>n(r)},e.entry.model)})}),s?(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:[(0,Z.jsxs)(`span`,{className:`console-mono text-xs font-semibold text-[var(--console-text)]`,children:[(s.tokens/r*100).toFixed(1),`%`]}),(0,Z.jsx)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:fS(s.tokens)})]}):(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-xs font-semibold text-[var(--console-text)]`,children:fS(r)}),(0,Z.jsx)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:`tokens`})]})]}),(0,Z.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-1.5`,children:o.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,onMouseEnter:()=>n(t),onMouseLeave:()=>n(null),children:[(0,Z.jsx)(`span`,{className:`inline-block size-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,Z.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.entry.model}),(0,Z.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[(e.fraction*100).toFixed(1),`%`]})]},e.entry.model))})]})]})}function CS({perAgent:e}){let t=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]);return t===0||e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No agent data yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agent Distribution`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` agents`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=t>0?e.sessions/t*100:0;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${e.name.toLowerCase()}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon?(0,Z.jsx)(`img`,{src:e.icon,alt:e.displayName,className:`size-4 object-contain`}):null,(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.displayName}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[dS(e.sessions),` · `,n.toFixed(1),`%`]})]}),(0,Z.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,Z.jsx)(`div`,{className:`h-full bg-[var(--console-accent)]`,style:{width:`${n}%`}})}),(0,Z.jsxs)(`div`,{className:`console-mono mt-1 flex gap-3 text-[10px] text-[var(--console-muted)]`,children:[(0,Z.jsxs)(`span`,{children:[dS(e.messages),` msgs`]}),(0,Z.jsxs)(`span`,{children:[fS(e.tokens),` tokens`]})]})]})},e.name)})})]})}function wS({sessions:e,onToggleBookmark:t}){return e.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Bookmarked Sessions`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=Ln.agents[e.agentKey],r=e.time_updated??e.time_created;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(vn,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,Z.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` · `,pS(r)]})]})]}),(0,Z.jsx)(Gx,{active:!0,onToggle:()=>t(e)})]})},aS(e.agentKey,e.sessionId))})})]})}function TS({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Activity`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=e.agentName.toLowerCase(),i=Ln.agents[r],a=e.time_updated??e.time_created,o=t(r,e.id);return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(vn,{to:`/${e.slug}`,className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i?.icon?(0,Z.jsx)(`img`,{src:i.icon,alt:i.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,Z.jsx)(`p`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:pS(a)})]}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.slug]})]}),(0,Z.jsx)(Gx,{active:o,onToggle:()=>n(e,r)})]})},e.id)})})]})}function ES({data:e,bookmarkedSessions:t,isBookmarked:n,onToggleBookmark:r}){let{totals:i,perAgent:a,dailyActivity:o,dailyTokenActivity:s,modelDistribution:c,recentSessions:l}=e;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,Z.jsx)(mS,{label:`Total Sessions`,value:dS(i.sessions)}),(0,Z.jsx)(mS,{label:`Total Messages`,value:dS(i.messages)}),(0,Z.jsx)(mS,{label:`Total Tokens`,value:fS(i.tokens)}),(0,Z.jsx)(mS,{label:`Latest Activity`,value:pS(i.latestActivity),hint:i.latestActivity?new Date(i.latestActivity).toLocaleString(`zh-CN`):void 0})]}),(0,Z.jsx)(gS,{buckets:o}),(0,Z.jsx)(yS,{buckets:s}),(0,Z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Z.jsx)(SS,{entries:c}),(0,Z.jsx)(CS,{perAgent:a})]}),(0,Z.jsx)(TS,{sessions:l,isBookmarked:n,onToggleBookmark:r}),(0,Z.jsx)(wS,{sessions:t,onToggleBookmark:e=>r(e)})]})}var DS=class extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-2 text-sm font-semibold text-[var(--console-error)]`,children:`Something went wrong`}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function OS(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function kS(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function AS(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(t==null)return`All time`;let i=kS(t),a=kS(n??Date.now());return r?`Last ${r}d · ${i} → ${a}`:`${i} → ${a}`}function jS(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function MS(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`).replaceAll(`&lt;mark&gt;`,`<mark>`).replaceAll(`&lt;/mark&gt;`,`</mark>`)}var NS=`codesesh.shortcuts-hint-dismissed`,PS=[{title:`Navigation`,items:[{keys:`j / k`,description:`Move through sessions or search results`},{keys:`Enter`,description:`Open the current selection`},{keys:`g / G`,description:`Jump to the first or last item`}]},{title:`Search`,items:[{keys:`/`,description:`Focus the search box`},{keys:`Esc`,description:`Exit search or close the current detail view`}]},{title:`Groups`,items:[{keys:`h / l`,description:`Collapse or expand the selected session group`},{keys:`?`,description:`Open this shortcuts panel`}]}];function FS(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function IS(){let e=it(),[t,n]=(0,S.useState)([]),[r,i]=(0,S.useState)([]),[a,o]=(0,S.useState)([]),[s,c]=(0,S.useState)(!0),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(null),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(null),[x,C]=(0,S.useState)(null),[w,T]=(0,S.useState)(``),[E,D]=(0,S.useState)(``),[O,ee]=(0,S.useState)([]),[te,ne]=(0,S.useState)(!1),[k,A]=(0,S.useState)(null),[re,ie]=(0,S.useState)(0),[j,M]=(0,S.useState)(!1),[ae,oe]=(0,S.useState)(!0),se=(0,S.useRef)(null),N=(0,S.useRef)(new Map),P=(0,S.useRef)(new Map);(0,S.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let e=await Rn();C(e);let[t,r,a,s]=await Promise.all([zn(),Bn(),Hn(e.window.days).catch(e=>(console.error(`Failed to load dashboard:`,e),null)),Wn()]);n(t),i(r.sessions),o(s.bookmarks),a&&b(a)}catch(e){console.error(`Failed to load data:`,e),u(`Failed to load data. Is the CLI server running?`)}finally{c(!1)}})(),()=>e.abort()},[]);let F=tt(),ce=(0,S.useMemo)(()=>new Set(t.map(e=>e.name.toLowerCase())),[t]),le=(0,S.useMemo)(()=>new Map(t.map(e=>[e.name.toLowerCase(),e.displayName])),[t]),ue=E.length>0,I=(0,S.useMemo)(()=>OS(F.pathname,ce),[F.pathname,ce]),de=ue?E:typeof F.state==`object`&&F.state!==null&&`searchQuery`in F.state&&typeof F.state.searchQuery==`string`?F.state.searchQuery:``,fe=(0,S.useMemo)(()=>{let e={};for(let n of t)e[n.name]=[];for(let t of r){let n=t.slug.split(`/`)[0]?.toLowerCase();n&&e[n]&&e[n].push(t)}for(let t of Object.keys(e))e[t].sort((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created));return e},[r,t]);(0,S.useEffect)(()=>{let e=!1;return o(t=>{let n=uS(t,r);return n===t?t:(Kn(n.map(({bookmarked_at:e,...t})=>t)).catch(t=>{e||console.error(`Failed to sync bookmark snapshots:`,t)}),n)}),()=>{e=!0}},[r]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{let t=sS();if(t.length!==0)try{let n=await Kn(t.map(({bookmarked_at:e,...t})=>t));if(e)return;o(n.bookmarks),cS()}catch(t){e||console.error(`Failed to migrate legacy bookmarks:`,t)}})(),()=>{e=!0}},[]);let pe=(0,S.useMemo)(()=>new Set(a.map(e=>aS(e.agentKey,e.sessionId))),[a]);function me(e,t){return pe.has(aS(e,t))}function he(e){let t=aS(e.agentKey,e.sessionId),n=pe.has(t),r=a;o(n?r.filter(e=>aS(e.agentKey,e.sessionId)!==t):[...r,e].toSorted((e,t)=>{let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n})),(n?qn(e.agentKey,e.sessionId):Gn({agentKey:e.agentKey,sessionId:e.sessionId,fullPath:e.fullPath,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats})).catch(e=>{console.error(`Failed to toggle bookmark:`,e),o(r)})}function ge(e,t){he(oS(e,t))}let L=I.activeAgentKey,_e=(0,S.useMemo)(()=>L?fe[L]??[]:[],[L,fe]),ve=(0,S.useMemo)(()=>a.toSorted((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created)),[a]),ye=(0,S.useMemo)(()=>{let e=new Map;for(let t of _e){let n=t.directory??``,r=n?n.replace(/\/+$/,``).split(`/`).at(-1)??n:`(unknown)`,i=r===`(unknown)`?`__unknown__`:r;e.has(i)||e.set(i,{key:i,label:r,sessions:[]}),e.get(i).sessions.push(t)}return[...e.values()].sort((e,t)=>{if(e.key===`__unknown__`)return 1;if(t.key===`__unknown__`)return-1;let n=Math.max(...e.sessions.map(e=>e.time_updated??e.time_created));return Math.max(...t.sessions.map(e=>e.time_updated??e.time_created))-n})},[_e]),[be,xe]=(0,S.useState)(new Set);(0,S.useEffect)(()=>{xe(new Set)},[L]);function Se(e){xe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let Ce=(0,S.useMemo)(()=>ye.flatMap(e=>be.has(e.key)?e.sessions.map(t=>({session:t,groupKey:e.key})):[]),[be,ye]),we=I.mode===`session`?`${I.activeAgentKey}/${I.activeSessionSlug}`:``,Te=(0,S.useEffectEvent)(async e=>{try{let[t,r,a,o]=await Promise.all([zn(),Bn(),Hn(x?.window.days).catch(e=>(console.error(`Failed to refresh dashboard:`,e),null)),E?Un(E).catch(e=>(console.error(`Failed to refresh search results:`,e),{results:[]})):Promise.resolve(null)]);if(n(t),i(r.sessions),a&&b(a),o&&ee(o.results),I.mode===`session`)try{f(await Vn(I.activeAgentKey,I.activeSessionSlug)),g(null)}catch{f(null),g(`Session not found`)}e.newSessions>0?v(`发现 ${e.newSessions} 个新会话,列表已自动刷新`):e.updatedSessions>0&&v(`会话内容已同步`)}catch(e){console.error(`Failed to sync live session update:`,e)}});(0,S.useEffect)(()=>{if(!E){ee([]),ne(!1);return}let e=!1;return ne(!0),Un(E).then(t=>{e||ee(t.results)}).catch(t=>{e||(console.error(`Failed to load search results:`,t),ee([]))}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[E]),(0,S.useEffect)(()=>{if(I.mode!==`session`){f(null),g(null);return}let e=new AbortController;return m(!0),g(null),(async()=>{try{f(await Vn(I.activeAgentKey,I.activeSessionSlug))}catch{g(`Session not found`),f(null)}finally{m(!1)}})(),()=>e.abort()},[we,I.activeAgentKey,I.activeSessionSlug,I.mode]),(0,S.useEffect)(()=>Jn(e=>{Te(e)}),[]),(0,S.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>{v(null)},3500);return()=>{window.clearTimeout(e)}},[_]),(0,S.useEffect)(()=>{try{oe(window.localStorage.getItem(NS)===`1`)}catch{oe(!0)}},[]),(0,S.useEffect)(()=>{if(ue){ie(e=>O.length===0?0:Math.min(e,O.length-1));return}if(I.mode===`session`){A(I.activeSessionSlug);return}if(I.mode===`agent`){A(e=>e??Ce[0]?.session.id??null);return}A(null)},[ue,O.length,I.mode,I.activeSessionSlug,Ce]),(0,S.useEffect)(()=>{if(I.mode!==`session`)return;let e=ye.find(e=>e.sessions.some(e=>e.id===I.activeSessionSlug));e&&xe(t=>{if(t.has(e.key))return t;let n=new Set(t);return n.add(e.key),n})},[ye,I.activeSessionSlug,I.mode]),(0,S.useEffect)(()=>{k&&N.current.get(k)?.scrollIntoView({block:`nearest`})},[k]),(0,S.useEffect)(()=>{if(!ue)return;let e=O[re];if(!e)return;let t=`${e.agentName}/${e.session.id}`;P.current.get(t)?.scrollIntoView({block:`nearest`})},[ue,O,re]);let Ee=(0,S.useMemo)(()=>r.map(e=>{let t=e.slug.split(`/`)[0]?.toLowerCase()||`unknown`;return{...e,agentKey:t,sessionSlug:e.id,fullPath:e.slug}}),[r]),De=(0,S.useMemo)(()=>t.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[t]),Oe=(0,S.useMemo)(()=>t.find(e=>e.name.toLowerCase()===L)??null,[L,t]),ke=`CodeSesh`,Ae=`Select an agent to browse sessions`;if(I.mode===`root`&&(ke=ue?`Search`:`Dashboard`,Ae=ue?te?`Searching for "${E}"`:`${O.length} matches for "${E}"`:y?`${y.totals.sessions.toLocaleString(`en-US`)} total sessions across ${y.perAgent.length} agents`:`Aggregated view across all agents`),ue&&I.mode!==`root`&&(ke=`Search`,Ae=te?`Searching for "${E}"`:`${O.length} matches for "${E}"`),I.mode===`agent`&&L&&(ke=Oe?.displayName??L,Ae=`${_e.length} sessions`),I.mode===`session`){if(h)ke=`Session Not Found`,Ae=`Requested /${L}/${I.activeSessionSlug}`;else if(d){ke=d.title||`Conversation`;let e=d.time_updated??d.time_created;Ae=`ID: #${d.id.slice(0,8)} · Updated ${jS(e)}`}}I.mode===`missingAgent`&&(ke=`Agent Not Found`,Ae=`Requested /${I.attemptedKey}`),I.mode===`missingSession`&&(ke=`Session Not Found`,Ae=`Session not found in /${L}`);let je=(0,S.useMemo)(()=>{if(ue)return[{label:`Search`}];let e={label:`Dashboard`,to:I.mode===`root`?void 0:`/`};if(I.mode===`root`)return[{label:`Dashboard`}];if(I.mode===`missingAgent`)return[e,{label:I.attemptedKey}];let t=Oe?.displayName??L??`Unknown Agent`,n={label:t,to:I.mode===`session`?`/${L}`:void 0};return I.mode===`agent`?[e,{label:t}]:I.mode===`missingSession`?[e,n,{label:I.attemptedSessionSlug}]:I.mode===`session`?[e,n,{label:d?.title||I.activeSessionSlug||`Conversation`}]:[e,{label:`Invalid Route`}]},[Oe,L,ue,d?.title,I]),Me;Me=s?(0,Z.jsx)(Wx,{}):ue?(0,Z.jsx)(LS,{query:E,loading:te,results:O,agentNameMap:le,onOpenResult:()=>D(``),selectedIndex:re,registerResultRef:(e,t)=>{t?P.current.set(e,t):P.current.delete(e)}}):l?(0,Z.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:l}):I.mode===`root`?y?(0,Z.jsx)(ES,{data:y,bookmarkedSessions:ve,isBookmarked:me,onToggleBookmark:(e,t)=>{if(`agentName`in e){ge(e,t??e.agentName.toLowerCase());return}he(e)}}):(0,Z.jsx)(eS,{type:`global`,sessions:Ee,agentItems:De,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):I.mode===`agent`&&L?(0,Z.jsx)(eS,{type:`agent`,sessions:Ee.filter(e=>e.agentKey===L),agentItems:De,activeAgentKey:L,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):I.mode===`session`?p?(0,Z.jsx)(Wx,{}):h||!d?(0,Z.jsx)(eS,{type:`missing-session`,sessions:Ee.filter(e=>e.agentKey===I.activeAgentKey),agentItems:De,activeAgentKey:I.activeAgentKey,attemptedSessionSlug:I.activeSessionSlug,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):(0,Z.jsx)(Ox,{session:d,highlightQuery:de}):I.mode===`missingAgent`?(0,Z.jsx)(eS,{type:`missing-agent`,sessions:Ee,agentItems:De,attemptedAgentKey:I.attemptedKey,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):(0,Z.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`});function Ne(){D(w.trim())}function Pe(){oe(!0);try{window.localStorage.setItem(NS,`1`)}catch{}}let Fe=(0,S.useEffectEvent)(t=>{if(t.defaultPrevented||t.metaKey||t.ctrlKey||t.altKey||t.isComposing)return;let n=t.target,r=FS(n),i=t.key;if(j){i===`Escape`&&(t.preventDefault(),M(!1));return}if(r){i===`Escape`&&(t.preventDefault(),n instanceof HTMLElement&&n.blur());return}if(i===`?`){t.preventDefault(),M(!0),Pe();return}if(i===`/`){t.preventDefault(),Pe(),se.current?.focus(),se.current?.select();return}if(i===`Escape`){if(t.preventDefault(),E){D(``),T(``);return}I.mode===`session`&&I.activeAgentKey&&e(`/${I.activeAgentKey}`);return}if(ue){if(O.length===0)return;if(i===`j`){t.preventDefault(),Pe(),ie(e=>Math.min(e+1,O.length-1));return}if(i===`k`){t.preventDefault(),Pe(),ie(e=>Math.max(e-1,0));return}if(i===`g`){t.preventDefault(),Pe(),ie(0);return}if(i===`G`){t.preventDefault(),Pe(),ie(O.length-1);return}if(i===`Enter`){let n=O[re];if(!n)return;t.preventDefault(),Pe(),D(``),e(`/${n.agentName.toLowerCase()}/${n.session.id}`,{state:{searchQuery:E}})}return}if(!L||ye.length===0)return;let a=e=>{let t=e===`start`?ye[0]:ye.at(-1);if(!t)return;xe(e=>{let n=new Set(e);return n.add(t.key),n});let n=e===`start`?t.sessions[0]:t.sessions.at(-1);n&&A(n.id)},o=e=>{if(Pe(),Ce.length===0){a(e>=0?`start`:`end`);return}let t=Ce.findIndex(e=>e.session.id===k),n=t>=0?t:e>=0?-1:Ce.length;A(Ce[Math.max(0,Math.min(n+e,Ce.length-1))]?.session.id??null)};if(i===`j`){t.preventDefault(),o(1);return}if(i===`k`){t.preventDefault(),o(-1);return}if(i===`g`){t.preventDefault(),Pe(),a(`start`);return}if(i===`G`){t.preventDefault(),Pe(),a(`end`);return}if(i===`Enter`){let n=Ce.find(e=>e.session.id===k);if(!n)return;t.preventDefault(),Pe(),e(`/${L}/${n.session.id}`);return}if(i===`l`){let e=Ce.find(e=>e.session.id===k)??(ye[0]?{session:ye[0].sessions[0],groupKey:ye[0].key}:null);if(!e)return;t.preventDefault(),Pe(),xe(t=>{let n=new Set(t);return n.add(e.groupKey),n}),A(e.session.id);return}if(i===`h`){let e=Ce.find(e=>e.session.id===k);if(!e)return;t.preventDefault(),Pe(),xe(t=>{let n=new Set(t);return n.delete(e.groupKey),n});let n=ye.findIndex(t=>t.key===e.groupKey),r=ye[n-1]??ye[n+1]??null;A((r?Ce.find(e=>e.groupKey===r.key)?.session??r.sessions[0]:null)?.id??null)}});return(0,S.useEffect)(()=>(window.addEventListener(`keydown`,Fe),()=>window.removeEventListener(`keydown`,Fe)),[]),(0,Z.jsxs)(`div`,{className:`console-ui h-screen overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,Z.jsx)(`header`,{className:`h-14 shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`grid h-full grid-cols-[auto_1fr_auto] items-center gap-4 px-4`,children:[(0,Z.jsxs)(vn,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,Z.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,Z.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]}),(0,Z.jsxs)(`form`,{className:`mx-auto flex w-full max-w-[560px] items-center justify-center gap-2`,onSubmit:e=>{e.preventDefault(),Ne()},children:[(0,Z.jsx)(`label`,{className:`flex min-w-0 flex-1 items-center rounded-sm border border-[var(--console-border)] bg-white px-2 py-1`,children:(0,Z.jsx)(`input`,{ref:se,value:w,onChange:e=>T(e.target.value),placeholder:`Search sessions /`,className:`console-mono w-full min-w-0 bg-transparent text-xs text-[var(--console-text)] outline-none placeholder:text-[var(--console-muted)]`})}),(0,Z.jsx)(`button`,{type:`submit`,className:`console-mono rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] px-3 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Search`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{M(!0),Pe()},className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-[var(--console-surface-muted)]`,title:`Show keyboard shortcuts`,children:`? Shortcuts`}),AS(x)?(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)]`,title:`Time window applied to agent counts, dashboard, and session list`,children:AS(x)}):null,(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-muted)]`,children:[`v`,`0.4.0`]})]})]})}),(0,Z.jsxs)(`div`,{className:`flex h-[calc(100vh-56px)] min-h-0`,children:[(0,Z.jsx)(`aside`,{className:`hidden w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] lg:flex`,children:(0,Z.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`NAVIGATION`}),(0,Z.jsxs)(`ul`,{className:`space-y-1`,children:[(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${I.mode===`root`?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,Z.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`Dashboard`,className:`size-3.5 rounded-[2px]`}),(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:`Dashboard`})]})}),t.map(e=>{let t=e.name.toLowerCase(),n=t===L,r=Ln.agents[t];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${t}`,className:`ml-4 flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[r?.icon&&(0,Z.jsx)(`img`,{src:r.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.name)}),t.length===0&&!s&&(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No agents found`})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BOOKMARKS`}),ve.length===0?(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No bookmarks yet`}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:ve.map(e=>{let t=I.mode===`session`&&I.activeAgentKey===e.agentKey&&I.activeSessionSlug===e.sessionId,n=Ln.agents[e.agentKey];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border px-2 py-1.5 transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,Z.jsxs)(vn,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,Z.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 block text-xs`,children:e.title}),(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 line-clamp-1 block text-[10px] text-[var(--console-muted)]`,children:n?.name??e.agentKey})]})]}),(0,Z.jsx)(Gx,{active:!0,onToggle:()=>he(e)})]})},aS(e.agentKey,e.sessionId))})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:[`SESSIONS`,L?(0,Z.jsx)(`span`,{className:`ml-2 text-[10px] font-normal text-[var(--console-muted)]`,children:`Navigate j k · Open Enter`}):null]}),L?_e.length===0?(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:ye.map(e=>{let t=be.has(e.key);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{onClick:()=>Se(e.key),className:`console-mono flex w-full items-center gap-1.5 rounded-sm px-2 py-1 text-left text-xs text-[var(--console-muted)] hover:bg-[var(--console-surface-muted)]`,title:e.key===`__unknown__`?void 0:e.key,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px]`,children:t?`▼`:`▶`}),(0,Z.jsx)(`span`,{className:`line-clamp-1 font-semibold`,children:e.label}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px]`,children:e.sessions.length})]}),t&&(0,Z.jsx)(`ul`,{className:`mt-0.5 space-y-0.5 pl-3`,children:e.sessions.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`relative flex items-start gap-2 rounded-sm border px-2 py-1.5 text-xs transition-colors ${I.mode===`session`&&I.activeSessionSlug===e.id?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)] before:absolute before:bottom-0 before:left-0 before:top-0 before:w-0.5 before:bg-[var(--console-accent)]`:k===e.id?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,Z.jsx)(vn,{ref:t=>{t?N.current.set(e.id,t):N.current.delete(e.id)},to:`/${L}/${e.id}`,title:e.title,className:`console-mono line-clamp-1 min-w-0 flex-1`,children:e.title}),(0,Z.jsx)(Gx,{active:me(L,e.id),onToggle:()=>ge(e,L),className:`relative z-10`})]})},e.id))})]},e.key)})}):(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`})]})]})}),(0,Z.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`console-mono mb-2 flex flex-wrap items-center gap-1 text-[11px] text-[var(--console-muted)]`,children:je.map((e,t)=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.to?(0,Z.jsx)(vn,{to:e.to,className:`transition-colors hover:text-[var(--console-text)]`,children:e.label}):(0,Z.jsx)(`span`,{className:`text-[var(--console-text)]`,children:e.label}),t<je.length-1?(0,Z.jsx)(`span`,{children:`/`}):null]},`${e.label}-${t}`))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] font-bold uppercase text-[var(--console-muted)]`,children:I.mode===`session`?`Session`:I.mode===`root`?`Dashboard`:`Landing`}),(0,Z.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:ke})]}),(0,Z.jsx)(`p`,{className:`console-mono mt-1 text-xs text-[var(--console-muted)]`,children:Ae}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[ae?null:(0,Z.jsxs)(`div`,{className:`console-mono inline-flex items-center gap-2 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:[(0,Z.jsx)(`span`,{children:`Keyboard navigation available`}),(0,Z.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-white px-1`,children:`?`}),(0,Z.jsx)(`button`,{type:`button`,onClick:Pe,className:`text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,"aria-label":`Dismiss keyboard shortcuts hint`,children:`×`})]}),!ue&&I.mode===`session`?(0,Z.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:`Esc back`}):null]}),_?(0,Z.jsx)(`p`,{className:`console-mono mt-2 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:_}):null]})}),(0,Z.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,Z.jsx)(DS,{children:Me})})]})]}),j?(0,Z.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4`,onClick:()=>M(!1),children:(0,Z.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,className:`w-full max-w-2xl rounded-sm border border-[var(--console-border-strong)] bg-white p-5 shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`Keyboard Shortcuts`}),(0,Z.jsx)(`h2`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:`Navigate without leaving the keyboard`})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(!1),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Esc`})]}),(0,Z.jsx)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:PS.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-4`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-3`,children:e.items.map(e=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-text)]`,children:e.keys}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-[var(--console-muted)]`,children:e.description})]},e.keys))})]},e.title))})]})}):null]})}function LS({query:e,loading:t,results:n,agentNameMap:r,onOpenResult:i,selectedIndex:a,registerResultRef:o}){return t?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,Z.jsxs)(`div`,{className:`animate-pulse rounded-sm border border-[var(--console-border)] bg-white/80 p-4`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-32 rounded bg-[var(--console-surface-muted)]`}),(0,Z.jsx)(`div`,{className:`mt-3 h-4 w-2/3 rounded bg-[var(--console-surface-muted)]`}),(0,Z.jsx)(`div`,{className:`mt-2 h-3 w-full rounded bg-[var(--console-surface-muted)]`}),(0,Z.jsx)(`div`,{className:`mt-1 h-3 w-5/6 rounded bg-[var(--console-surface-muted)]`})]},t))}):n.length===0?(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/80 p-6`,children:[(0,Z.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:`No matches`}),(0,Z.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]})]}):(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Z.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),n.map((t,n)=>{let s=t.agentName.toLowerCase(),c=r.get(s)??t.agentName,l=`${t.agentName}/${t.session.id}`;return(0,Z.jsxs)(vn,{ref:e=>o(l,e),to:`/${s}/${t.session.id}`,state:{searchQuery:e},onClick:i,className:`rounded-sm border bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white ${n===a?`border-[var(--console-border-strong)]`:`border-[var(--console-border)]`}`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:c}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:t.session.directory})]}),(0,Z.jsx)(`h2`,{className:`console-mono mt-3 text-sm font-semibold text-[var(--console-text)]`,children:t.session.title}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xs leading-6 text-[var(--console-muted)] [&_mark]:bg-[var(--console-accent)] [&_mark]:px-0.5 [&_mark]:text-white`,dangerouslySetInnerHTML:{__html:MS(t.snippet||t.session.title)}})]},l)})]})}In.createRoot(document.getElementById(`root`)).render((0,Z.jsx)(S.StrictMode,{children:(0,Z.jsx)(hn,{children:(0,Z.jsx)(IS,{})})}));
68
+ `);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-thinking-border)] bg-[var(--console-thinking-bg)]`,children:[(0,Z.jsxs)(`div`,{className:`flex cursor-pointer items-center justify-between bg-[var(--console-surface-muted)] px-3 py-2`,onClick:()=>r(!n),children:[(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-2 text-xs font-medium text-[var(--console-muted)]`,children:[(0,Z.jsx)(Rr,{className:`size-3.5`}),`Thinking`]}),(0,Z.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:n?(0,Z.jsx)(Ar,{className:`w-4 h-4`}):(0,Z.jsx)(kr,{className:`w-4 h-4`})})]}),n&&(0,Z.jsx)(`div`,{className:`border-t border-dashed border-[var(--console-thinking-border)] px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`console-mono whitespace-pre-wrap text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(i,t)})})]})}function Rx({parts:e,toolAnchorIds:t,sessionAgentKey:n,highlightQuery:r}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,i)=>(0,Z.jsx)(Vx,{tool:e,anchorId:t.get(e),sessionAgentKey:n,highlightQuery:r},i))})})}function zx({parts:e,highlightQuery:t}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,n)=>(0,Z.jsx)(Bx,{part:e,highlightQuery:t},n))})}function Bx({part:e,highlightQuery:t}){let[n,r]=(0,S.useState)(!1),i=Cf(e),a=i.approvalStatus===`fail`?vb.error:vb.completed,o=a.icon;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${i.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:i.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>r(!n),children:[(0,Z.jsx)(Or,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:n?(0,Z.jsx)(Ar,{className:`size-3.5`}):(0,Z.jsx)(kr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Or,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:i.title})})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${a.className}`,children:[(0,Z.jsx)(o,{className:`size-3`}),a.label]})]}),i.expandable&&n?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:i.contentLabel})}),(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,Z.jsx)(Sb,{text:i.contentMarkdown,highlightQuery:t})})})]}):null]})}function Vx({tool:e,anchorId:t,sessionAgentKey:n,highlightQuery:r}){let[i,a]=(0,S.useState)(!1),o=_x(e),s=Tx(n,e,o),c=vb[o.status],l=c.icon,u=s.Icon;return(0,Z.jsxs)(`div`,{id:t,className:`scroll-mt-6 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${s.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:s.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>a(!i),children:[(0,Z.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:s.title}),s.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(s.secondaryText,r)}):null]}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:i?(0,Z.jsx)(Ar,{className:`size-3.5`}):(0,Z.jsx)(kr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:s.title}),s.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(s.secondaryText,r)}):null]})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${c.className}`,children:[(0,Z.jsx)(l,{className:`size-3 ${o.status===`running`?`animate-spin`:``}`}),c.label]})]}),s.expandable&&i?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Output`})}),(0,Z.jsxs)(`div`,{className:`space-y-3 p-3`,children:[s.details.length>0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:s.details.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,Z.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] font-semibold uppercase tracking-wide text-[var(--console-muted)] md:w-24`,children:e.label}),(0,Z.jsx)(`span`,{className:`console-mono whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-text)]`,children:xb(e.value,r)})]},`${e.label}:${e.value}`))})}):null,(0,Z.jsx)(_b,{outputContent:s.outputContent})]}),s.showInputPreview?(0,Z.jsxs)(`div`,{className:`border-t border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Input Preview`}),(0,Z.jsx)(`pre`,{className:`console-mono mt-1 max-h-[200px] overflow-x-auto whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:xb(o.inputText||`{}`,r)})]}):null]}):null]})}var Hx=[{id:`1`,roleWidth:`w-14`,timeWidth:`w-20`,bodyWidths:[`w-full`,`w-10/12`,`w-7/12`]},{id:`2`,roleWidth:`w-16`,timeWidth:`w-24`,bodyWidths:[`w-9/12`,`w-7/12`]},{id:`3`,roleWidth:`w-14`,timeWidth:`w-16`,bodyWidths:[`w-full`,`w-11/12`,`w-8/12`,`w-5/12`]},{id:`4`,roleWidth:`w-16`,timeWidth:`w-20`,bodyWidths:[`w-10/12`,`w-8/12`]},{id:`5`,roleWidth:`w-14`,timeWidth:`w-24`,bodyWidths:[`w-full`,`w-10/12`,`w-9/12`]}];function Ux({className:e}){return(0,Z.jsx)(`div`,{className:`rounded-sm bg-[var(--console-border)] ${e}`})}function Wx(){return(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-8 px-2 md:px-4`,children:[(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-8`,children:Hx.map(e=>(0,Z.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,Z.jsx)(`div`,{className:`size-3.5 rounded-sm bg-[var(--console-border-strong)] animate-pulse`})})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(Ux,{className:`${e.roleWidth} h-3 animate-pulse`}),(0,Z.jsx)(Ux,{className:`${e.timeWidth} h-2.5 animate-pulse`})]}),(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.bodyWidths.map(t=>(0,Z.jsx)(Ux,{className:`${t} h-3 animate-pulse`},`${e.id}-${t}`))})})]})]})},e.id))}),(0,Z.jsx)(`div`,{className:`min-h-24 flex-1 rounded-sm border border-[var(--console-border)] bg-white/60 animate-pulse`})]})}function Gx({active:e,onToggle:t,className:n=``}){return(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":e?`取消收藏会话`:`收藏会话`,title:e?`取消收藏`:`收藏`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border transition-colors ${n} ${e?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] opacity-70 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] hover:opacity-100`}`,children:(0,Z.jsx)(Ur,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function Kx(e){return e.toLocaleString(`en-US`)}function qx(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function Jx(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Yx({label:e,value:t,hint:n}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function Xx({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function Zx({code:e,title:t,description:n,aside:r,iconSrc:i,iconAlt:a}){return(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border-strong)] bg-white p-5 md:p-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Z.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:e}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:a||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,Z.jsx)(`h2`,{className:`console-mono text-2xl leading-tight font-semibold tracking-tight text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-sm border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`STATUS NOTE`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function Qx({agentItems:e}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Known Agents`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${e.key}`,className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 transition-colors duration-200 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-accent)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function $x({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Sessions`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=t(e.agentKey,e.id);return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(vn,{to:`/${e.fullPath}`,className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` ·`,` `,Jx(e.time_updated||e.time_created)]})]}),(0,Z.jsx)(Gx,{active:r,onToggle:()=>n(e)})]})},e.id)})})]})}function eS({type:e,sessions:t,agentItems:n,activeAgentKey:r,attemptedAgentKey:i,attemptedSessionSlug:a,isBookmarked:o,onToggleBookmark:s}){let c=t.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),l=c.slice(0,5),u=t.reduce((e,t)=>e+t.stats.message_count,0),d=t.reduce((e,t)=>e+qx(t.stats),0),f=c[0]?.time_updated||c[0]?.time_created;if(e===`missing-agent`){let e=`/${i||`unknown`}${a?`/${a}`:``}`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(Zx,{code:`404 / AGENT`,title:`This agent isn't on the roster.`,description:`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`,aside:`Choose one of the available agents to continue.`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(Xx,{label:`Requested Agent`,value:i||`unknown`}),(0,Z.jsx)(Xx,{label:`Requested Path`,value:e}),a?(0,Z.jsx)(Xx,{label:`Requested Session`,value:a}):null]}),(0,Z.jsx)(Qx,{agentItems:n})]})}if(e===`missing-session`){let e=r||Ln.getDefaultAgentKey()||`claudecode`,t=Ln.agents[e],n=t?.name||e,i=t?.icon,c=a||`unknown-session`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(Zx,{code:`404 / SESSION`,title:`This session isn't in the index.`,description:`${n} is available, but the session you're looking for does not exist in the current index. The slug may be incorrect, or the record may never have been part of this dataset.`,aside:`We checked the current path, but nothing matched. The session list on the left is still available.`,iconSrc:i,iconAlt:n}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:`Agent`}),(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,Z.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,Z.jsx)(Xx,{label:`Session`,value:c})]}),(0,Z.jsx)($x,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}if(e===`global`)return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(Yx,{label:`Total Sessions`,value:Kx(t.length)}),(0,Z.jsx)(Yx,{label:`Total Messages`,value:Kx(u)}),(0,Z.jsx)(Yx,{label:`Latest Activity`,value:Jx(f),hint:f?new Date(f).toLocaleString(`zh-CN`):void 0})]}),(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agents`}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:n.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${e.key}`,className:`flex items-center gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]}),(0,Z.jsx)($x,{sessions:l,isBookmarked:o,onToggleBookmark:s})]});let p=r?Ln.agents[r]:null,m=p?p.name:`Unknown Agent`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[p?(0,Z.jsx)(`img`,{src:p.icon,alt:m,className:`size-6 object-contain`}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:m}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Select a session from the left to view details`})]})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(Yx,{label:`Sessions`,value:Kx(t.length)}),(0,Z.jsx)(Yx,{label:`Messages`,value:Kx(u)}),(0,Z.jsx)(Yx,{label:`Tokens`,value:Kx(d)})]}),(0,Z.jsx)($x,{sessions:l,isBookmarked:o,onToggleBookmark:s})]})}var tS=`codesesh:bookmarks:v1`;function nS(e){return typeof e==`object`&&!!e}function rS(e){return nS(e)?typeof e.message_count==`number`&&typeof e.total_input_tokens==`number`&&typeof e.total_output_tokens==`number`&&typeof e.total_cost==`number`&&(e.total_tokens==null||typeof e.total_tokens==`number`):!1}function iS(e){return nS(e)?typeof e.sessionId==`string`&&typeof e.agentKey==`string`&&typeof e.fullPath==`string`&&typeof e.title==`string`&&typeof e.directory==`string`&&typeof e.time_created==`number`&&(e.time_updated==null||typeof e.time_updated==`number`)&&(e.bookmarked_at==null||typeof e.bookmarked_at==`number`)&&rS(e.stats):!1}function aS(e,t){return`${e}:${t}`}function oS(e,t){return{sessionId:e.id,agentKey:t,fullPath:e.slug,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats,bookmarked_at:Date.now()}}function sS(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(tS);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(iS).toSorted(lS):[]}catch{return[]}}function cS(){typeof window>`u`||window.localStorage.removeItem(tS)}function lS(e,t){let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n}function uS(e,t){if(e.length===0||t.length===0)return e;let n=new Map(t.map(e=>{let t=oS(e,e.slug.split(`/`)[0]?.toLowerCase()??`unknown`);return[aS(t.agentKey,t.sessionId),t]})),r=!1,i=e.map(e=>{let t=n.get(aS(e.agentKey,e.sessionId));return!t||t.fullPath===e.fullPath&&t.title===e.title&&t.directory===e.directory&&t.time_created===e.time_created&&t.time_updated===e.time_updated&&t.stats.message_count===e.stats.message_count&&t.stats.total_input_tokens===e.stats.total_input_tokens&&t.stats.total_output_tokens===e.stats.total_output_tokens&&t.stats.total_cost===e.stats.total_cost&&t.stats.total_tokens===e.stats.total_tokens?e:(r=!0,{...t,bookmarked_at:e.bookmarked_at})});return r?i.toSorted(lS):e}function dS(e){return e.toLocaleString(`en-US`)}function fS(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:dS(e)}function pS(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function mS({label:e,value:t,hint:n}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function hS(e){return e.length>=10?e.slice(5):e}function gS({buckets:e}){let[t,n]=(0,S.useState)(null),r=(0,S.useMemo)(()=>Math.max(1,...e.map(e=>e.sessions)),[e]),i=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]),a=(0,S.useMemo)(()=>{if(e.length===0)return new Set;let t=Math.min(6,e.length);if(t===1)return new Set([0]);let n=new Set;for(let r=0;r<t;r+=1)n.add(Math.round(r*(e.length-1)/(t-1)));return n},[e.length]);return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Activity`}),(0,Z.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Session activity · last `,e.length,` days`]})]}),(0,Z.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${dS(t.sessions)} sessions · ${dS(t.messages)} msgs`:`${dS(i)} in range`})]}),(0,Z.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.sessions>0?Math.max(Math.round(e.sessions/r*128),4):2,a=`${e.date} · ${e.sessions} sessions · ${e.messages} msgs`,o=t?.date===e.date;return(0,Z.jsx)(`div`,{title:a,onMouseEnter:()=>n(e),className:`flex-1 cursor-default rounded-t-[1px] transition-opacity ${e.sessions>0?`bg-[var(--console-accent)]`:`bg-[var(--console-surface-muted)]`} ${o?`opacity-70`:`opacity-100`}`,style:{height:`${i}px`}},e.date)})}),(0,Z.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,Z.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?hS(e.date):``},e.date))})]})}var _S={input:`#4A9EFF`,output:`#7C5CFF`,cache_read:`#3FB68B`,cache_create:`#E8A23B`},vS={input:`Input`,output:`Output`,cache_read:`Cache Read`,cache_create:`Cache Create`};function yS({buckets:e}){let[t,n]=(0,S.useState)(null),r=(0,S.useMemo)(()=>Math.max(1,...e.map(e=>e.input+e.output+e.cache_read+e.cache_create)),[e]),i=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.input+t.output+t.cache_read+t.cache_create,0),[e]),a=(0,S.useMemo)(()=>{if(e.length===0)return new Set;let t=Math.min(6,e.length);if(t===1)return new Set([0]);let n=new Set;for(let r=0;r<t;r+=1)n.add(Math.round(r*(e.length-1)/(t-1)));return n},[e.length]);return i===0?null:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Daily Token Activity`}),(0,Z.jsxs)(`p`,{className:`console-mono mt-1 text-[11px] text-[var(--console-muted)]`,children:[`Token breakdown · last `,e.length,` days`]})]}),(0,Z.jsx)(`span`,{className:`console-mono text-right text-[11px] text-[var(--console-muted)]`,children:t?`${t.date} · ${fS(t.input+t.output+t.cache_read+t.cache_create)} total`:`${fS(i)} in range`})]}),t?(0,Z.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,Z.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:_S[e]}}),vS[e],`: `,fS(t[e])]},e))}):(0,Z.jsx)(`div`,{className:`mb-2 flex gap-4`,children:[`input`,`output`,`cache_read`,`cache_create`].map(e=>(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-1.5 text-[10px] text-[var(--console-muted)]`,children:[(0,Z.jsx)(`span`,{className:`inline-block size-2 rounded-full`,style:{backgroundColor:_S[e]}}),vS[e]]},e))}),(0,Z.jsx)(`div`,{className:`flex h-32 items-end gap-[2px]`,onMouseLeave:()=>n(null),children:e.map(e=>{let i=e.input+e.output+e.cache_read+e.cache_create,a=i>0?Math.max(Math.round(i/r*128),4):2,o=t?.date===e.date,s=i>0?[{key:`input`,value:e.input},{key:`output`,value:e.output},{key:`cache_read`,value:e.cache_read},{key:`cache_create`,value:e.cache_create}]:[];return(0,Z.jsx)(`div`,{onMouseEnter:()=>n(e),className:`flex flex-1 cursor-default flex-col justify-end overflow-hidden rounded-t-[1px] transition-opacity ${o?`opacity-70`:`opacity-100`}`,style:{height:`${a}px`},children:i>0?s.map(e=>{let t=Math.max(Math.round(e.value/i*a),0);return t===0?null:(0,Z.jsx)(`div`,{style:{height:`${t}px`,backgroundColor:_S[e.key]}},e.key)}):(0,Z.jsx)(`div`,{className:`h-full bg-[var(--console-surface-muted)]`})},e.date)})}),(0,Z.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((e,t)=>(0,Z.jsx)(`span`,{className:`flex-1 text-center`,children:a.has(t)?hS(e.date):``},e.date))})]})}var bS=[`#4A9EFF`,`#7C5CFF`,`#3FB68B`,`#E8A23B`,`#E5484D`,`#5BCEDA`,`#F472B6`,`#A78BFA`,`#FB923C`,`#6EE7B7`];function xS(e,t,n,r,i){let a={x:e+n*Math.cos(r),y:t+n*Math.sin(r)},o={x:e+n*Math.cos(i),y:t+n*Math.sin(i)},s=+(i-r>Math.PI);return`M ${a.x} ${a.y} A ${n} ${n} 0 ${s} 1 ${o.x} ${o.y}`}function SS({entries:e}){let[t,n]=(0,S.useState)(null),r=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.tokens,0),[e]);if(e.length===0||r===0)return(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No model data yet`});let i=.02,a=-Math.PI/2,o=e.map((e,t)=>{let n=e.tokens/r,o=a+i/2,s=a+n*Math.PI*2-i/2;return a+=n*Math.PI*2,{entry:e,startAngle:o,endAngle:s,fraction:n,color:bS[t%bS.length]}}),s=t===null?null:e[t];return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Model Distribution`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` models`]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,Z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Z.jsx)(`svg`,{width:160,height:160,viewBox:`0 0 160 160`,onMouseLeave:()=>n(null),children:o.map((e,r)=>{if(e.fraction<.003)return null;let i=e.fraction>.997,a=t===r;if(i)return(0,Z.jsx)(`g`,{onMouseEnter:()=>n(r),children:(0,Z.jsx)(`circle`,{cx:80,cy:80,r:70,fill:`none`,stroke:e.color,strokeWidth:25,opacity:a?.8:1})},e.entry.model);let o=xS(80,80,70,e.startAngle,e.endAngle),s=xS(80,80,45,e.endAngle,e.startAngle),c={x:80+70*Math.cos(e.endAngle),y:80+70*Math.sin(e.endAngle)},l={x:80+45*Math.cos(e.endAngle),y:80+45*Math.sin(e.endAngle)},u={x:80+45*Math.cos(e.startAngle),y:80+45*Math.sin(e.startAngle)};return(0,Z.jsx)(`path`,{d:`${o} L ${c.x} ${c.y} L ${l.x} ${l.y} ${s} L ${u.x} ${u.y} Z`,fill:e.color,opacity:a?.8:1,className:`cursor-default transition-opacity`,onMouseEnter:()=>n(r)},e.entry.model)})}),s?(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:[(0,Z.jsxs)(`span`,{className:`console-mono text-xs font-semibold text-[var(--console-text)]`,children:[(s.tokens/r*100).toFixed(1),`%`]}),(0,Z.jsx)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:fS(s.tokens)})]}):(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-xs font-semibold text-[var(--console-text)]`,children:fS(r)}),(0,Z.jsx)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:`tokens`})]})]}),(0,Z.jsx)(`ul`,{className:`min-w-0 flex-1 space-y-1.5`,children:o.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,onMouseEnter:()=>n(t),onMouseLeave:()=>n(null),children:[(0,Z.jsx)(`span`,{className:`inline-block size-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,Z.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-xs text-[var(--console-text)]`,children:e.entry.model}),(0,Z.jsxs)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:[(e.fraction*100).toFixed(1),`%`]})]},e.entry.model))})]})]})}function CS({perAgent:e}){let t=(0,S.useMemo)(()=>e.reduce((e,t)=>e+t.sessions,0),[e]);return t===0||e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No agent data yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agent Distribution`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` agents`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=t>0?e.sessions/t*100:0;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${e.name.toLowerCase()}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon?(0,Z.jsx)(`img`,{src:e.icon,alt:e.displayName,className:`size-4 object-contain`}):null,(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.displayName}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[dS(e.sessions),` · `,n.toFixed(1),`%`]})]}),(0,Z.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-sm bg-[var(--console-surface-muted)]`,children:(0,Z.jsx)(`div`,{className:`h-full bg-[var(--console-accent)]`,style:{width:`${n}%`}})}),(0,Z.jsxs)(`div`,{className:`console-mono mt-1 flex gap-3 text-[10px] text-[var(--console-muted)]`,children:[(0,Z.jsxs)(`span`,{children:[dS(e.messages),` msgs`]}),(0,Z.jsxs)(`span`,{children:[fS(e.tokens),` tokens`]})]})]})},e.name)})})]})}function wS({sessions:e,onToggleBookmark:t}){return e.length===0?null:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Bookmarked Sessions`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let n=Ln.agents[e.agentKey],r=e.time_updated??e.time_created;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(vn,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,Z.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` · `,pS(r)]})]})]}),(0,Z.jsx)(Gx,{active:!0,onToggle:()=>t(e)})]})},aS(e.agentKey,e.sessionId))})})]})}function TS({sessions:e,isBookmarked:t,onToggleBookmark:n}){return e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Activity`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>{let r=e.agentName.toLowerCase(),i=Ln.agents[r],a=e.time_updated??e.time_created,o=t(r,e.id);return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsxs)(vn,{to:`/${e.slug}`,className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i?.icon?(0,Z.jsx)(`img`,{src:i.icon,alt:i.name,className:`size-3.5 shrink-0 object-contain`}):null,(0,Z.jsx)(`p`,{className:`line-clamp-1 flex-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] text-[var(--console-muted)]`,children:pS(a)})]}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.slug]})]}),(0,Z.jsx)(Gx,{active:o,onToggle:()=>n(e,r)})]})},e.id)})})]})}function ES({data:e,bookmarkedSessions:t,isBookmarked:n,onToggleBookmark:r}){let{totals:i,perAgent:a,dailyActivity:o,dailyTokenActivity:s,modelDistribution:c,recentSessions:l}=e;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,Z.jsx)(mS,{label:`Total Sessions`,value:dS(i.sessions)}),(0,Z.jsx)(mS,{label:`Total Messages`,value:dS(i.messages)}),(0,Z.jsx)(mS,{label:`Total Tokens`,value:fS(i.tokens)}),(0,Z.jsx)(mS,{label:`Latest Activity`,value:pS(i.latestActivity),hint:i.latestActivity?new Date(i.latestActivity).toLocaleString(`zh-CN`):void 0})]}),(0,Z.jsx)(gS,{buckets:o}),(0,Z.jsx)(yS,{buckets:s}),(0,Z.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Z.jsx)(SS,{entries:c}),(0,Z.jsx)(CS,{perAgent:a})]}),(0,Z.jsx)(TS,{sessions:l,isBookmarked:n,onToggleBookmark:r}),(0,Z.jsx)(wS,{sessions:t,onToggleBookmark:e=>r(e)})]})}var DS=class extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-2 text-sm font-semibold text-[var(--console-error)]`,children:`Something went wrong`}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function OS(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function kS(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function AS(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(t==null)return`All time`;let i=kS(t),a=kS(n??Date.now());return r?`Last ${r}d · ${i} → ${a}`:`${i} → ${a}`}function jS(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function MS(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&#39;`).replaceAll(`&lt;mark&gt;`,`<mark>`).replaceAll(`&lt;/mark&gt;`,`</mark>`)}var NS=`codesesh.shortcuts-hint-dismissed`,PS=[{title:`Navigation`,items:[{keys:`j / k`,description:`Move through sessions or search results`},{keys:`Enter`,description:`Open the current selection`},{keys:`g / G`,description:`Jump to the first or last item`}]},{title:`Search`,items:[{keys:`/`,description:`Focus the search box`},{keys:`Esc`,description:`Exit search or close the current detail view`}]},{title:`Groups`,items:[{keys:`h / l`,description:`Collapse or expand the selected session group`},{keys:`?`,description:`Open this shortcuts panel`}]}];function FS(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function IS(){let e=it(),[t,n]=(0,S.useState)([]),[r,i]=(0,S.useState)([]),[a,o]=(0,S.useState)([]),[s,c]=(0,S.useState)(!0),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(null),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(null),[x,C]=(0,S.useState)(null),[w,T]=(0,S.useState)(``),[E,D]=(0,S.useState)(``),[O,ee]=(0,S.useState)([]),[te,ne]=(0,S.useState)(!1),[k,A]=(0,S.useState)(null),[re,ie]=(0,S.useState)(0),[j,M]=(0,S.useState)(!1),[ae,oe]=(0,S.useState)(!0),se=(0,S.useRef)(null),N=(0,S.useRef)(new Map),P=(0,S.useRef)(new Map);(0,S.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let e=await Rn();C(e);let[t,r,a,s]=await Promise.all([zn(),Bn(),Hn(e.window.days).catch(e=>(console.error(`Failed to load dashboard:`,e),null)),Wn()]);n(t),i(r.sessions),o(s.bookmarks),a&&b(a)}catch(e){console.error(`Failed to load data:`,e),u(`Failed to load data. Is the CLI server running?`)}finally{c(!1)}})(),()=>e.abort()},[]);let F=tt(),ce=(0,S.useMemo)(()=>new Set(t.map(e=>e.name.toLowerCase())),[t]),le=(0,S.useMemo)(()=>new Map(t.map(e=>[e.name.toLowerCase(),e.displayName])),[t]),ue=E.length>0,I=(0,S.useMemo)(()=>OS(F.pathname,ce),[F.pathname,ce]),de=ue?E:typeof F.state==`object`&&F.state!==null&&`searchQuery`in F.state&&typeof F.state.searchQuery==`string`?F.state.searchQuery:``,fe=(0,S.useMemo)(()=>{let e={};for(let n of t)e[n.name]=[];for(let t of r){let n=t.slug.split(`/`)[0]?.toLowerCase();n&&e[n]&&e[n].push(t)}for(let t of Object.keys(e))e[t].sort((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created));return e},[r,t]);(0,S.useEffect)(()=>{let e=!1;return o(t=>{let n=uS(t,r);return n===t?t:(Kn(n.map(({bookmarked_at:e,...t})=>t)).catch(t=>{e||console.error(`Failed to sync bookmark snapshots:`,t)}),n)}),()=>{e=!0}},[r]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{let t=sS();if(t.length!==0)try{let n=await Kn(t.map(({bookmarked_at:e,...t})=>t));if(e)return;o(n.bookmarks),cS()}catch(t){e||console.error(`Failed to migrate legacy bookmarks:`,t)}})(),()=>{e=!0}},[]);let pe=(0,S.useMemo)(()=>new Set(a.map(e=>aS(e.agentKey,e.sessionId))),[a]);function me(e,t){return pe.has(aS(e,t))}function he(e){let t=aS(e.agentKey,e.sessionId),n=pe.has(t),r=a;o(n?r.filter(e=>aS(e.agentKey,e.sessionId)!==t):[...r,e].toSorted((e,t)=>{let n=e.time_updated??e.time_created;return(t.time_updated??t.time_created)-n})),(n?qn(e.agentKey,e.sessionId):Gn({agentKey:e.agentKey,sessionId:e.sessionId,fullPath:e.fullPath,title:e.title,directory:e.directory,time_created:e.time_created,time_updated:e.time_updated,stats:e.stats})).catch(e=>{console.error(`Failed to toggle bookmark:`,e),o(r)})}function ge(e,t){he(oS(e,t))}let L=I.activeAgentKey,_e=(0,S.useMemo)(()=>L?fe[L]??[]:[],[L,fe]),ve=(0,S.useMemo)(()=>a.toSorted((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created)),[a]),ye=(0,S.useMemo)(()=>{let e=new Map;for(let t of _e){let n=t.directory??``,r=n?n.replace(/\/+$/,``).split(`/`).at(-1)??n:`(unknown)`,i=r===`(unknown)`?`__unknown__`:r;e.has(i)||e.set(i,{key:i,label:r,sessions:[]}),e.get(i).sessions.push(t)}return[...e.values()].sort((e,t)=>{if(e.key===`__unknown__`)return 1;if(t.key===`__unknown__`)return-1;let n=Math.max(...e.sessions.map(e=>e.time_updated??e.time_created));return Math.max(...t.sessions.map(e=>e.time_updated??e.time_created))-n})},[_e]),[be,xe]=(0,S.useState)(new Set);(0,S.useEffect)(()=>{xe(new Set)},[L]);function Se(e){xe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let Ce=(0,S.useMemo)(()=>ye.flatMap(e=>be.has(e.key)?e.sessions.map(t=>({session:t,groupKey:e.key})):[]),[be,ye]),we=I.mode===`session`?`${I.activeAgentKey}/${I.activeSessionSlug}`:``,Te=(0,S.useEffectEvent)(async e=>{try{let[t,r,a,o]=await Promise.all([zn(),Bn(),Hn(x?.window.days).catch(e=>(console.error(`Failed to refresh dashboard:`,e),null)),E?Un(E).catch(e=>(console.error(`Failed to refresh search results:`,e),{results:[]})):Promise.resolve(null)]);if(n(t),i(r.sessions),a&&b(a),o&&ee(o.results),I.mode===`session`)try{f(await Vn(I.activeAgentKey,I.activeSessionSlug)),g(null)}catch{f(null),g(`Session not found`)}e.newSessions>0?v(`发现 ${e.newSessions} 个新会话,列表已自动刷新`):e.updatedSessions>0&&v(`会话内容已同步`)}catch(e){console.error(`Failed to sync live session update:`,e)}});(0,S.useEffect)(()=>{if(!E){ee([]),ne(!1);return}let e=!1;return ne(!0),Un(E).then(t=>{e||ee(t.results)}).catch(t=>{e||(console.error(`Failed to load search results:`,t),ee([]))}).finally(()=>{e||ne(!1)}),()=>{e=!0}},[E]),(0,S.useEffect)(()=>{if(I.mode!==`session`){f(null),g(null);return}let e=new AbortController;return m(!0),g(null),(async()=>{try{f(await Vn(I.activeAgentKey,I.activeSessionSlug))}catch{g(`Session not found`),f(null)}finally{m(!1)}})(),()=>e.abort()},[we,I.activeAgentKey,I.activeSessionSlug,I.mode]),(0,S.useEffect)(()=>Jn(e=>{Te(e)}),[]),(0,S.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>{v(null)},3500);return()=>{window.clearTimeout(e)}},[_]),(0,S.useEffect)(()=>{try{oe(window.localStorage.getItem(NS)===`1`)}catch{oe(!0)}},[]),(0,S.useEffect)(()=>{if(ue){ie(e=>O.length===0?0:Math.min(e,O.length-1));return}if(I.mode===`session`){A(I.activeSessionSlug);return}if(I.mode===`agent`){A(e=>e??Ce[0]?.session.id??null);return}A(null)},[ue,O.length,I.mode,I.activeSessionSlug,Ce]),(0,S.useEffect)(()=>{if(I.mode!==`session`)return;let e=ye.find(e=>e.sessions.some(e=>e.id===I.activeSessionSlug));e&&xe(t=>{if(t.has(e.key))return t;let n=new Set(t);return n.add(e.key),n})},[ye,I.activeSessionSlug,I.mode]),(0,S.useEffect)(()=>{k&&N.current.get(k)?.scrollIntoView({block:`nearest`})},[k]),(0,S.useEffect)(()=>{if(!ue)return;let e=O[re];if(!e)return;let t=`${e.agentName}/${e.session.id}`;P.current.get(t)?.scrollIntoView({block:`nearest`})},[ue,O,re]);let Ee=(0,S.useMemo)(()=>r.map(e=>{let t=e.slug.split(`/`)[0]?.toLowerCase()||`unknown`;return{...e,agentKey:t,sessionSlug:e.id,fullPath:e.slug}}),[r]),De=(0,S.useMemo)(()=>t.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[t]),Oe=(0,S.useMemo)(()=>t.find(e=>e.name.toLowerCase()===L)??null,[L,t]),ke=`CodeSesh`,Ae=`Select an agent to browse sessions`;if(I.mode===`root`&&(ke=ue?`Search`:`Dashboard`,Ae=ue?te?`Searching for "${E}"`:`${O.length} matches for "${E}"`:y?`${y.totals.sessions.toLocaleString(`en-US`)} total sessions across ${y.perAgent.length} agents`:`Aggregated view across all agents`),ue&&I.mode!==`root`&&(ke=`Search`,Ae=te?`Searching for "${E}"`:`${O.length} matches for "${E}"`),I.mode===`agent`&&L&&(ke=Oe?.displayName??L,Ae=`${_e.length} sessions`),I.mode===`session`){if(h)ke=`Session Not Found`,Ae=`Requested /${L}/${I.activeSessionSlug}`;else if(d){ke=d.title||`Conversation`;let e=d.time_updated??d.time_created;Ae=`ID: #${d.id.slice(0,8)} · Updated ${jS(e)}`}}I.mode===`missingAgent`&&(ke=`Agent Not Found`,Ae=`Requested /${I.attemptedKey}`),I.mode===`missingSession`&&(ke=`Session Not Found`,Ae=`Session not found in /${L}`);let je=(0,S.useMemo)(()=>{if(ue)return[{label:`Search`}];let e={label:`Dashboard`,to:I.mode===`root`?void 0:`/`};if(I.mode===`root`)return[{label:`Dashboard`}];if(I.mode===`missingAgent`)return[e,{label:I.attemptedKey}];let t=Oe?.displayName??L??`Unknown Agent`,n={label:t,to:I.mode===`session`?`/${L}`:void 0};return I.mode===`agent`?[e,{label:t}]:I.mode===`missingSession`?[e,n,{label:I.attemptedSessionSlug}]:I.mode===`session`?[e,n,{label:d?.title||I.activeSessionSlug||`Conversation`}]:[e,{label:`Invalid Route`}]},[Oe,L,ue,d?.title,I]),Me;Me=s?(0,Z.jsx)(Wx,{}):ue?(0,Z.jsx)(LS,{query:E,loading:te,results:O,agentNameMap:le,onOpenResult:()=>D(``),selectedIndex:re,registerResultRef:(e,t)=>{t?P.current.set(e,t):P.current.delete(e)}}):l?(0,Z.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:l}):I.mode===`root`?y?(0,Z.jsx)(ES,{data:y,bookmarkedSessions:ve,isBookmarked:me,onToggleBookmark:(e,t)=>{if(`agentName`in e){ge(e,t??e.agentName.toLowerCase());return}he(e)}}):(0,Z.jsx)(eS,{type:`global`,sessions:Ee,agentItems:De,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):I.mode===`agent`&&L?(0,Z.jsx)(eS,{type:`agent`,sessions:Ee.filter(e=>e.agentKey===L),agentItems:De,activeAgentKey:L,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):I.mode===`session`?p?(0,Z.jsx)(Wx,{}):h||!d?(0,Z.jsx)(eS,{type:`missing-session`,sessions:Ee.filter(e=>e.agentKey===I.activeAgentKey),agentItems:De,activeAgentKey:I.activeAgentKey,attemptedSessionSlug:I.activeSessionSlug,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):(0,Z.jsx)(Ox,{session:d,highlightQuery:de}):I.mode===`missingAgent`?(0,Z.jsx)(eS,{type:`missing-agent`,sessions:Ee,agentItems:De,attemptedAgentKey:I.attemptedKey,isBookmarked:me,onToggleBookmark:e=>ge(e,e.agentKey)}):(0,Z.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`});function Ne(){D(w.trim())}function Pe(){oe(!0);try{window.localStorage.setItem(NS,`1`)}catch{}}let Fe=(0,S.useEffectEvent)(t=>{if(t.defaultPrevented||t.metaKey||t.ctrlKey||t.altKey||t.isComposing)return;let n=t.target,r=FS(n),i=t.key;if(j){i===`Escape`&&(t.preventDefault(),M(!1));return}if(r){i===`Escape`&&(t.preventDefault(),n instanceof HTMLElement&&n.blur());return}if(i===`?`){t.preventDefault(),M(!0),Pe();return}if(i===`/`){t.preventDefault(),Pe(),se.current?.focus(),se.current?.select();return}if(i===`Escape`){if(t.preventDefault(),E){D(``),T(``);return}I.mode===`session`&&I.activeAgentKey&&e(`/${I.activeAgentKey}`);return}if(ue){if(O.length===0)return;if(i===`j`){t.preventDefault(),Pe(),ie(e=>Math.min(e+1,O.length-1));return}if(i===`k`){t.preventDefault(),Pe(),ie(e=>Math.max(e-1,0));return}if(i===`g`){t.preventDefault(),Pe(),ie(0);return}if(i===`G`){t.preventDefault(),Pe(),ie(O.length-1);return}if(i===`Enter`){let n=O[re];if(!n)return;t.preventDefault(),Pe(),D(``),e(`/${n.agentName.toLowerCase()}/${n.session.id}`,{state:{searchQuery:E}})}return}if(!L||ye.length===0)return;let a=e=>{let t=e===`start`?ye[0]:ye.at(-1);if(!t)return;xe(e=>{let n=new Set(e);return n.add(t.key),n});let n=e===`start`?t.sessions[0]:t.sessions.at(-1);n&&A(n.id)},o=e=>{if(Pe(),Ce.length===0){a(e>=0?`start`:`end`);return}let t=Ce.findIndex(e=>e.session.id===k),n=t>=0?t:e>=0?-1:Ce.length;A(Ce[Math.max(0,Math.min(n+e,Ce.length-1))]?.session.id??null)};if(i===`j`){t.preventDefault(),o(1);return}if(i===`k`){t.preventDefault(),o(-1);return}if(i===`g`){t.preventDefault(),Pe(),a(`start`);return}if(i===`G`){t.preventDefault(),Pe(),a(`end`);return}if(i===`Enter`){let n=Ce.find(e=>e.session.id===k);if(!n)return;t.preventDefault(),Pe(),e(`/${L}/${n.session.id}`);return}if(i===`l`){let e=Ce.find(e=>e.session.id===k)??(ye[0]?{session:ye[0].sessions[0],groupKey:ye[0].key}:null);if(!e)return;t.preventDefault(),Pe(),xe(t=>{let n=new Set(t);return n.add(e.groupKey),n}),A(e.session.id);return}if(i===`h`){let e=Ce.find(e=>e.session.id===k);if(!e)return;t.preventDefault(),Pe(),xe(t=>{let n=new Set(t);return n.delete(e.groupKey),n});let n=ye.findIndex(t=>t.key===e.groupKey),r=ye[n-1]??ye[n+1]??null;A((r?Ce.find(e=>e.groupKey===r.key)?.session??r.sessions[0]:null)?.id??null)}});return(0,S.useEffect)(()=>(window.addEventListener(`keydown`,Fe),()=>window.removeEventListener(`keydown`,Fe)),[]),(0,Z.jsxs)(`div`,{className:`console-ui h-screen overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,Z.jsx)(`header`,{className:`h-14 shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`grid h-full grid-cols-[auto_1fr_auto] items-center gap-4 px-4`,children:[(0,Z.jsxs)(vn,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,Z.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,Z.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]}),(0,Z.jsxs)(`form`,{className:`mx-auto flex w-full max-w-[560px] items-center justify-center gap-2`,onSubmit:e=>{e.preventDefault(),Ne()},children:[(0,Z.jsx)(`label`,{className:`flex min-w-0 flex-1 items-center rounded-sm border border-[var(--console-border)] bg-white px-2 py-1`,children:(0,Z.jsx)(`input`,{ref:se,value:w,onChange:e=>T(e.target.value),placeholder:`Search sessions /`,className:`console-mono w-full min-w-0 bg-transparent text-xs text-[var(--console-text)] outline-none placeholder:text-[var(--console-muted)]`})}),(0,Z.jsx)(`button`,{type:`submit`,className:`console-mono rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] px-3 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Search`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{M(!0),Pe()},className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-[var(--console-surface-muted)]`,title:`Show keyboard shortcuts`,children:`? Shortcuts`}),AS(x)?(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-white px-2 py-1 text-xs text-[var(--console-text)]`,title:`Time window applied to agent counts, dashboard, and session list`,children:AS(x)}):null,(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-muted)]`,children:[`v`,`0.4.1`]})]})]})}),(0,Z.jsxs)(`div`,{className:`flex h-[calc(100vh-56px)] min-h-0`,children:[(0,Z.jsx)(`aside`,{className:`hidden w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] lg:flex`,children:(0,Z.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`NAVIGATION`}),(0,Z.jsxs)(`ul`,{className:`space-y-1`,children:[(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${I.mode===`root`?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,Z.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`Dashboard`,className:`size-3.5 rounded-[2px]`}),(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:`Dashboard`})]})}),t.map(e=>{let t=e.name.toLowerCase(),n=t===L,r=Ln.agents[t];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(vn,{to:`/${t}`,className:`ml-4 flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[r?.icon&&(0,Z.jsx)(`img`,{src:r.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.name)}),t.length===0&&!s&&(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No agents found`})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`BOOKMARKS`}),ve.length===0?(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No bookmarks yet`}):(0,Z.jsx)(`ul`,{className:`space-y-1`,children:ve.map(e=>{let t=I.mode===`session`&&I.activeAgentKey===e.agentKey&&I.activeSessionSlug===e.sessionId,n=Ln.agents[e.agentKey];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border px-2 py-1.5 transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,Z.jsxs)(vn,{to:`/${e.fullPath}`,className:`flex min-w-0 flex-1 items-start gap-2`,children:[n?.icon?(0,Z.jsx)(`img`,{src:n.icon,alt:n.name,className:`mt-0.5 size-3.5 shrink-0 object-contain`}):null,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 block text-xs`,children:e.title}),(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 line-clamp-1 block text-[10px] text-[var(--console-muted)]`,children:n?.name??e.agentKey})]})]}),(0,Z.jsx)(Gx,{active:!0,onToggle:()=>he(e)})]})},aS(e.agentKey,e.sessionId))})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:[`SESSIONS`,L?(0,Z.jsx)(`span`,{className:`ml-2 text-[10px] font-normal text-[var(--console-muted)]`,children:`Navigate j k · Open Enter`}):null]}),L?_e.length===0?(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:ye.map(e=>{let t=be.has(e.key);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{onClick:()=>Se(e.key),className:`console-mono flex w-full items-center gap-1.5 rounded-sm px-2 py-1 text-left text-xs text-[var(--console-muted)] hover:bg-[var(--console-surface-muted)]`,title:e.key===`__unknown__`?void 0:e.key,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px]`,children:t?`▼`:`▶`}),(0,Z.jsx)(`span`,{className:`line-clamp-1 font-semibold`,children:e.label}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px]`,children:e.sessions.length})]}),t&&(0,Z.jsx)(`ul`,{className:`mt-0.5 space-y-0.5 pl-3`,children:e.sessions.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`div`,{className:`relative flex items-start gap-2 rounded-sm border px-2 py-1.5 text-xs transition-colors ${I.mode===`session`&&I.activeSessionSlug===e.id?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)] before:absolute before:bottom-0 before:left-0 before:top-0 before:w-0.5 before:bg-[var(--console-accent)]`:k===e.id?`border-[var(--console-border)] bg-[var(--console-surface-muted)] text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[(0,Z.jsx)(vn,{ref:t=>{t?N.current.set(e.id,t):N.current.delete(e.id)},to:`/${L}/${e.id}`,title:e.title,className:`console-mono line-clamp-1 min-w-0 flex-1`,children:e.title}),(0,Z.jsx)(Gx,{active:me(L,e.id),onToggle:()=>ge(e,L),className:`relative z-10`})]})},e.id))})]},e.key)})}):(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`})]})]})}),(0,Z.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`console-mono mb-2 flex flex-wrap items-center gap-1 text-[11px] text-[var(--console-muted)]`,children:je.map((e,t)=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.to?(0,Z.jsx)(vn,{to:e.to,className:`transition-colors hover:text-[var(--console-text)]`,children:e.label}):(0,Z.jsx)(`span`,{className:`text-[var(--console-text)]`,children:e.label}),t<je.length-1?(0,Z.jsx)(`span`,{children:`/`}):null]},`${e.label}-${t}`))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] font-bold uppercase text-[var(--console-muted)]`,children:I.mode===`session`?`Session`:I.mode===`root`?`Dashboard`:`Landing`}),(0,Z.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:ke})]}),(0,Z.jsx)(`p`,{className:`console-mono mt-1 text-xs text-[var(--console-muted)]`,children:Ae}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[ae?null:(0,Z.jsxs)(`div`,{className:`console-mono inline-flex items-center gap-2 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:[(0,Z.jsx)(`span`,{children:`Keyboard navigation available`}),(0,Z.jsx)(`span`,{className:`rounded-sm border border-[var(--console-border)] bg-white px-1`,children:`?`}),(0,Z.jsx)(`button`,{type:`button`,onClick:Pe,className:`text-[var(--console-muted)] transition-colors hover:text-[var(--console-text)]`,"aria-label":`Dismiss keyboard shortcuts hint`,children:`×`})]}),!ue&&I.mode===`session`?(0,Z.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:`Esc back`}):null]}),_?(0,Z.jsx)(`p`,{className:`console-mono mt-2 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-text)]`,children:_}):null]})}),(0,Z.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,Z.jsx)(DS,{children:Me})})]})]}),j?(0,Z.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/35 px-4`,onClick:()=>M(!1),children:(0,Z.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,className:`w-full max-w-2xl rounded-sm border border-[var(--console-border-strong)] bg-white p-5 shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`Keyboard Shortcuts`}),(0,Z.jsx)(`h2`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:`Navigate without leaving the keyboard`})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(!1),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] transition-colors hover:bg-white`,children:`Esc`})]}),(0,Z.jsx)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:PS.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-4`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:e.title}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-3`,children:e.items.map(e=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-text)]`,children:e.keys}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-[var(--console-muted)]`,children:e.description})]},e.keys))})]},e.title))})]})}):null]})}function LS({query:e,loading:t,results:n,agentNameMap:r,onOpenResult:i,selectedIndex:a,registerResultRef:o}){return t?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,Z.jsxs)(`div`,{className:`animate-pulse rounded-sm border border-[var(--console-border)] bg-white/80 p-4`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-32 rounded bg-[var(--console-surface-muted)]`}),(0,Z.jsx)(`div`,{className:`mt-3 h-4 w-2/3 rounded bg-[var(--console-surface-muted)]`}),(0,Z.jsx)(`div`,{className:`mt-2 h-3 w-full rounded bg-[var(--console-surface-muted)]`}),(0,Z.jsx)(`div`,{className:`mt-1 h-3 w-5/6 rounded bg-[var(--console-surface-muted)]`})]},t))}):n.length===0?(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white/80 p-6`,children:[(0,Z.jsx)(`h2`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:`No matches`}),(0,Z.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]})]}):(0,Z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Z.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),n.map((t,n)=>{let s=t.agentName.toLowerCase(),c=r.get(s)??t.agentName,l=`${t.agentName}/${t.session.id}`;return(0,Z.jsxs)(vn,{ref:e=>o(l,e),to:`/${s}/${t.session.id}`,state:{searchQuery:e},onClick:i,className:`rounded-sm border bg-white/85 p-4 transition-colors hover:border-[var(--console-border-strong)] hover:bg-white ${n===a?`border-[var(--console-border-strong)]`:`border-[var(--console-border)]`}`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:c}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:t.session.directory})]}),(0,Z.jsx)(`h2`,{className:`console-mono mt-3 text-sm font-semibold text-[var(--console-text)]`,children:t.session.title}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xs leading-6 text-[var(--console-muted)] [&_mark]:bg-[var(--console-accent)] [&_mark]:px-0.5 [&_mark]:text-white`,dangerouslySetInnerHTML:{__html:MS(t.snippet||t.session.title)}})]},l)})]})}In.createRoot(document.getElementById(`root`)).render((0,Z.jsx)(S.StrictMode,{children:(0,Z.jsx)(hn,{children:(0,Z.jsx)(IS,{})})}));
@@ -9,7 +9,7 @@
9
9
  />
10
10
  <link rel="icon" type="image/svg+xml" href="/logo.svg?v=3" />
11
11
  <title>CodeSesh</title>
12
- <script type="module" crossorigin src="/assets/index-DJuE5oTj.js"></script>
12
+ <script type="module" crossorigin src="/assets/index-B78jpjIp.js"></script>
13
13
  <link rel="stylesheet" crossorigin href="/assets/index-gSYgPU_H.css">
14
14
  </head>
15
15
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codesesh",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "One place to see every AI coding session you've ever had. Unify Claude Code, Cursor, Kimi, Codex, and OpenCode sessions in a single, beautiful Web UI.",
5
5
  "keywords": [
6
6
  "ai",
@@ -54,6 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@hono/node-server": "^1.14.0",
57
+ "better-sqlite3": "^11.10.0",
57
58
  "chokidar": "^5.0.0",
58
59
  "citty": "^0.1.6",
59
60
  "consola": "^3.4.2",