nextclaw 0.18.5 → 0.18.6

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.
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,m as s,n as c,p as l,u}from"./i18n-BnNAQpVM.js";import{At as d,Ft as f,Gt as p,H as m,It as h,Mt as g,Ot as _,Pt as v,_t as y,at as b,b as x,bt as S,g as C,h as w,it as T,jt as E,kt as ee,m as te,mt as ne,n as re,ot as ie,p as ae,r as oe,rt as se,st as ce,y as le,yt as ue,zt as de}from"./api-C51456xV.js";import{a as fe,i as pe,n as me,o as he,r as ge,t as _e}from"./dialog-BHcaU6NE.js";import{t as D}from"./createLucideIcon-C_GFKVuW.js";import{b as ve,c as ye,d as be,f as xe,g as Se,h as Ce,l as we,m as Te,n as Ee,s as De,u as Oe,v as ke,y as Ae}from"./theme-provider-dHqcWU-j.js";import{n as je,t as Me}from"./search-DZSNKEGp.js";import{t as Ne}from"./book-open-B4mOKdz8.js";import{D as Pe,O as Fe,_ as Ie,b as Le,c as Re,d as ze,f as Be,g as Ve,h as He,i as Ue,k as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as Xe,s as Ze,t as Qe,u as $e,v as et,y as tt}from"./select-DRDejPLk.js";import{t as nt}from"./external-link-DP2IJ7AM.js";import{t as rt}from"./folder-BPwc278w.js";import{n as it,t as at}from"./logos-BcELLmYh.js";import{t as ot}from"./loader-circle-C6gg2m2a.js";import{t as st}from"./plus-BptLViq1.js";import{t as ct}from"./refresh-ccw-CeG203yU.js";import{t as lt}from"./settings-DjvNMJde.js";import{t as ut}from"./sparkles-CyDTgTM4.js";import{t as dt}from"./trash-2-C1cdqL6V.js";import{t as ft}from"./x-BjMO7v8q.js";import{i as pt}from"./doc-browser-context-Dib9sS83.js";import{n as mt}from"./doc-browser-CwgI7ipB.js";import{n as ht}from"./use-viewport-layout-D-pjxsyz.js";import{m as gt}from"./use-config-DFja1sda.js";import{a as _t,c as vt,i as yt,n as bt,o as xt,r as St,s as Ct,t as wt}from"./popover-B8msg2FQ.js";import{t as Tt}from"./logo-badge-uB4SwANR.js";import{a as Et,c as Dt,i as Ot,l as kt,n as At,o as jt,r as Mt,s as Nt,t as Pt}from"./tooltip-C6VPreZ7.js";import{t as Ft}from"./skeleton-5Mg6vZHN.js";var It=D(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Lt=D(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Rt=D(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),zt=D(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Bt=D(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Vt=D(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ht=D(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ut=D(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),Wt=D(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),Gt=D(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Kt=D(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),qt=D(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),Jt=D(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),Yt=D(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Xt=D(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Zt=D(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Qt=D(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),$t=D(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),en=D(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),tn=D(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),nn=D(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),rn=D(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),an=D(`HeartPulse`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}],[`path`,{d:`M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`1uw2ng`}]]),on=D(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),sn=D(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),cn=D(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ln=D(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),un=D(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),dn=D(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),fn=D(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),pn=D(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),mn=D(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),O=l();function hn({isProjectFirstView:e,onSelectMode:t}){return(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,O.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:u(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:o(`chatSidebarViewTime`)}),(0,O.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:u(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:o(`chatSidebarViewProject`)})]})}var gn={wx:`weixin`,lark:`feishu`},_n={heartbeat:{icon:`heartbeat`},cron:{icon:`cron`}},vn={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function yn(e){return e?.trim().toLowerCase()??``}function bn(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function xn(e,t){let n=yn(e);if(!n||n===`native`)return null;let r=t.find(e=>yn(e.value)===n);return r?.label.trim()?r.label.trim():bn(n)}function Sn(e,t){let n=yn(e);return!n||n===`native`?null:t.find(e=>yn(e.value)===n)??null}function Cn(e){let t=yn(e);if(!t)return null;let n=gn[t]??t;return at(n)?n:null}function wn(e,t){let n=Cn(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=_n[yn(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=yn(e.sessionType),a=Sn(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let s=vn[i];return s?{icon:null,label:o(s)}:{icon:null,label:a?.label?.trim()||xn(e.sessionType,t)}}var Tn=`app://`;function En(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Dn(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Tn))return t;let n=En(t.slice(6));return n?`/${n}`:null}function On({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,O.jsx)(kn,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Dn(e.src);return(0,O.jsx)(Tt,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:u(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,O.jsx)(Ae,{className:u(`h-3 w-3 text-gray-500`,t)})})}return e.icon===`heartbeat`?(0,O.jsx)(an,{className:u(`h-3.5 w-3.5`,t)}):(0,O.jsx)(ve,{className:u(`h-3.5 w-3.5`,t)})}function kn({channel:e,className:t}){return(0,O.jsx)(Tt,{name:e,src:at(e),className:u(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,O.jsx)(Ae,{className:`h-3 w-3 text-gray-500`})})}function An(e){let{option:t,onSelect:n}=e,r=t.ready===!1?t.reasonMessage?.trim()||o(`statusSetup`):null;return(0,O.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-2xl px-3 py-2.5 text-left transition-colors hover:bg-gray-50`,children:(0,O.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[t.icon?.src?(0,O.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,O.jsx)(On,{icon:{kind:`runtime-image`,src:t.icon.src,alt:t.icon.alt??null,name:t.label}})}):null,(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:t.label}),(0,O.jsxs)(`span`,{className:u(`inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium`,t.ready===!1?`text-amber-700`:`text-emerald-600`),children:[(0,O.jsx)(`span`,{className:u(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?o(`statusSetup`):o(`statusReady`)]})]}),r?(0,O.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:r}):null]})]})})})}var k=e(s(),1);function jn(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Mn(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[s,c]=(0,k.useState)(null),l=(0,k.useMemo)(()=>jn(n,r),[n,r]),u=r.length>1;return(0,O.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${o(`chatSidebarNewTask`)} · ${e.projectName}`;return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-0.5`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(`div`,{className:`truncate text-[11px] font-medium uppercase tracking-wider text-gray-500`,title:e.projectRoot,children:e.projectName}),(0,O.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400`,children:e.items.length})]}),u?(0,O.jsxs)(wt,{open:s===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,"aria-label":t,title:t,children:(0,O.jsx)(st,{className:`h-3.5 w-3.5`})})}),(0,O.jsxs)(bt,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:o(`chatSessionTypeLabel`)}),(0,O.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,O.jsx)(An,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,O.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,onClick:()=>a(l,e.projectRoot),"aria-label":t,title:t,children:(0,O.jsx)(st,{className:`h-3.5 w-3.5`})})]}),(0,O.jsx)(`div`,{className:`space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}var Nn=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Pn(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Fn(e){let t=e.trim();return t?t.slice(0,1).toUpperCase():`A`}function In({agentId:e,displayName:t,avatarUrl:n,className:r}){let i=t?.trim()||e,[a,o]=Nn[Pn(e)%Nn.length]??Nn[0];return n?.trim()?(0,O.jsx)(`img`,{src:n,alt:t?.trim()||e,className:u(`rounded-full object-cover`,r)}):(0,O.jsx)(`div`,{className:u(`rounded-full flex items-center justify-center font-semibold`,a,o,r),"aria-label":t?.trim()||e,children:Fn(i)})}function Ln({status:e,className:t}){let n=o(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,O.jsxs)(`span`,{className:u(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,t),title:n,"aria-label":n,children:[(0,O.jsx)(ot,{className:`h-3 w-3 animate-spin`}),(0,O.jsx)(`span`,{className:`sr-only`,children:n})]})}function Rn({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(ee,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:o(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e.key}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(d,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void i(),disabled:n,"aria-label":o(`save`),children:(0,O.jsx)(We,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(d,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:a,disabled:n,"aria-label":o(`cancel`),children:(0,O.jsx)(ft,{className:`h-3.5 w-3.5`})})]})]})]})}function zn({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:s,agentLabel:l,agentAvatarUrl:d,childSessionCount:f=0,onSelect:p,onOpenChildSessions:m,onStartEditing:h}){let g=t?`text-gray-700`:`text-gray-500`,_=s?.trim()??``;return(0,O.jsxs)(`div`,{className:`group/session relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:p,className:`w-full text-left`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-1.5 pr-8`,children:[(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[_&&_.toLowerCase()!==`main`?(0,O.jsx)(In,{agentId:_,displayName:l,avatarUrl:d,className:`h-5 w-5 shrink-0`}):null,(0,O.jsx)(`span`,{className:`truncate font-medium`,children:a}),i.label?(0,O.jsx)(`span`,{className:u(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,t?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:i.label}):null,i.icon?(0,O.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,O.jsx)(On,{icon:i.icon,className:g})}):null]}),(0,O.jsxs)(`span`,{className:`inline-flex shrink-0 items-center justify-end gap-1.5`,children:[n?(0,O.jsx)(`span`,{"aria-label":o(`chatSessionUnread`),className:`h-2 w-2 rounded-full bg-primary`}):null,(0,O.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,children:r?(0,O.jsx)(Ln,{status:r}):null})]})]}),(0,O.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-400 truncate`,children:(0,O.jsxs)(`span`,{children:[l?.trim()?`${l} · `:``,e.messageCount,` · `,c(e.updatedAt)]})})]}),f>0&&m?(0,O.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m()},className:u(`absolute right-7 top-0 inline-flex h-7 items-center gap-1 rounded-lg px-1.5 text-[10px] font-medium text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":o(`chatSessionOpenChildSessions`),title:o(`chatSessionOpenChildSessions`),children:[(0,O.jsx)(rn,{className:`h-3.5 w-3.5`}),(0,O.jsx)(`span`,{children:f})]}):null,(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h()},className:u(`absolute right-0 top-0 inline-flex h-7 w-7 items-center justify-center rounded-lg text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":o(`edit`),children:(0,O.jsx)(un,{className:`h-3.5 w-3.5`})})]})}function Bn({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l,isEditing:d,draftLabel:f,isSaving:p,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,O.jsx)(`div`,{className:u(`w-full rounded-xl px-3 py-2 text-left transition-all text-[13px]`,t?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:d?(0,O.jsx)(Rn,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,O.jsx)(zn,{session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,onSelect:m,childSessionCount:l,onOpenChildSessions:h,onStartEditing:g})})}var Vn=[{icon:Ce,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:ke,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:ve,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function Hn({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,O.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,O.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,O.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,O.jsx)(Ae,{className:`h-8 w-8 text-primary`})}),(0,O.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:o(`chatWelcomeTitle`)}),(0,O.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:o(`chatWelcomeSubtitle`)}),(0,O.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,O.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:o(`chatDraftAgentTitle`)}),(0,O.jsxs)(Qe,{value:n,onValueChange:r,children:[(0,O.jsxs)(Ue,{"aria-label":o(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,O.jsx)(`span`,{className:`sr-only`,children:o(`chatDraftAgentTitle`)}),(0,O.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,O.jsx)(In,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,O.jsx)(qe,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,O.jsx)(Xe,{value:e.id,className:`rounded-lg pr-10`,children:(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(In,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,O.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,O.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:Vn.map(t=>{let n=t.icon;return(0,O.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,O.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,O.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,O.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:o(t.titleKey)}),(0,O.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:o(t.descKey)})]},t.titleKey)})})]})})}var Un=e=>`[data-item-index="${e}"]`;function Wn(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??Un;(0,k.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function Gn(){let e=(0,k.useRef)(null),[t,n]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function A(...e){return n(r(e))}var Kn=k.forwardRef(({className:e,type:t,...n},r)=>(0,O.jsx)(`input`,{type:t,className:A(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Kn.displayName=`ChatInput`;var qn=Ct,Jn=vt,Yn=yt,Xn=k.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,O.jsx)(xt,{children:(0,O.jsx)(_t,{ref:i,sideOffset:t,align:n,className:A(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));Xn.displayName=_t.displayName;var Zn=Ke,Qn=Ze,$n=tt,er=k.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsxs)(et,{ref:r,className:A(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,O.jsx)(Re,{asChild:!0,children:(0,O.jsx)(Fe,{className:`h-4 w-4 opacity-50`})})]}));er.displayName=et.displayName;var tr=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(Ve,{ref:n,className:A(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,O.jsx)(Pe,{className:`h-4 w-4`})}));tr.displayName=Ve.displayName;var nr=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(He,{ref:n,className:A(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,O.jsx)(Fe,{className:`h-4 w-4`})}));nr.displayName=He.displayName;var rr=k.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,O.jsx)(Ye,{children:(0,O.jsxs)(Je,{ref:i,className:A(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,O.jsx)(tr,{}),(0,O.jsx)(Le,{className:A(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,O.jsx)(nr,{})]})}));rr.displayName=Je.displayName;var ir=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(Be,{ref:n,className:A(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));ir.displayName=Be.displayName;var ar=k.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsxs)(Ge,{ref:r,className:A(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,O.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,O.jsx)($e,{children:(0,O.jsx)(We,{className:`h-4 w-4`})})}),(0,O.jsx)(ze,{children:t})]}));ar.displayName=Ge.displayName;var or=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(Ie,{ref:n,className:A(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));or.displayName=Ie.displayName;var sr=Nt,cr=Dt,lr=kt,ur=k.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,O.jsx)(jt,{children:(0,O.jsx)(Et,{ref:r,sideOffset:t,className:A(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));ur.displayName=Et.displayName;var dr={Popover:qn,PopoverAnchor:Yn,PopoverContent:Xn,PopoverTrigger:Jn,Input:Kn,Select:Zn,SelectContent:rr,SelectGroup:Qn,SelectItem:ar,SelectLabel:ir,SelectSeparator:or,SelectTrigger:er,SelectValue:$n,Tooltip:cr,TooltipContent:ur,TooltipProvider:sr,TooltipTrigger:lr},fr=680,pr=.82,mr=560;function hr(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=dr,{elementRef:i,width:a}=Gn(),o=(0,k.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onSetActiveIndex:h}=e,g=(0,k.useMemo)(()=>{if(a)return Math.min(a>mr?a*pr:a,fr)},[a]);return Wn({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,O.jsxs)(t,{open:s,onOpenChange:m,children:[(0,O.jsx)(n,{asChild:!0,children:(0,O.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,O.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:g?{width:`${g}px`}:void 0,children:(0,O.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,O.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,O.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,O.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,O.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,O.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>h(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,O.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,O.jsx)(`div`,{className:`min-w-0 p-2.5`,children:d?(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,O.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,O.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,O.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,O.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,O.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,O.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var gr=E(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),_r=k.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,O.jsx)(`button`,{className:A(gr({variant:t,size:n,className:e})),ref:i,...r}));_r.displayName=`ChatButton`;var vr=120;function yr(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=vr?t:`${t.slice(0,vr-1)}…`}function br(){return(0,O.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function xr({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,onSend:l,onStop:u}){let{Popover:d,PopoverContent:f,PopoverTrigger:p,Tooltip:m,TooltipContent:h,TooltipProvider:g,TooltipTrigger:_}=dr,v=e?.trim()??``,y=v?yr(v):``,b=t?.trim()||`Details`;return(0,O.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[v?(0,O.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,O.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,O.jsx)(`span`,{className:`block truncate`,title:v,children:y})}),(0,O.jsxs)(d,{children:[(0,O.jsx)(p,{asChild:!0,children:(0,O.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:b})}),(0,O.jsxs)(f,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,O.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:b}),(0,O.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:v})]})]})]}):null,(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:n?r?(0,O.jsx)(_r,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void u(),disabled:a,children:(0,O.jsx)(br,{})}):(0,O.jsx)(g,{children:(0,O.jsxs)(m,{children:[(0,O.jsx)(_,{asChild:!0,children:(0,O.jsx)(`span`,{children:(0,O.jsx)(_r,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,O.jsx)(br,{})})})}),(0,O.jsx)(h,{side:`top`,children:(0,O.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,O.jsx)(_r,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void l(),disabled:i,children:(0,O.jsx)(Lt,{className:`h-5 w-5`})})})]})}function Sr(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function Cr(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=dr,{picker:a}=e,o=(0,k.useRef)(null),s=(0,k.useId)(),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(0),f=(0,k.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,k.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,k.useMemo)(()=>h?h.flatMap(e=>e.options):Sr(a.options,c),[h,a.options,c]);(0,k.useEffect)(()=>{d(0)},[c]),(0,k.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),Wn({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,O.jsxs)(n,{children:[(0,O.jsx)(i,{asChild:!0,children:(0,O.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,O.jsx)(ke,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:a.title}),p>0?(0,O.jsx)(`span`,{className:`ml-0.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary`,children:p}):null]})}),(0,O.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,O.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,O.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(Me,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,O.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,O.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,O.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,O.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,O.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,O.jsxs)(`div`,{children:[e.label?(0,O.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,O.jsxs)(`button`,{type:`button`,id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onClick:()=>_(e.key),onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,O.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,O.jsx)(dn,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,O.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,O.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,O.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,O.jsx)(`span`,{className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,O.jsx)(We,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,O.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,O.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,O.jsx)(nt,{className:`h-3 w-3`})]})}):null]})]})}function wr({icon:e}){return e===`sparkles`?(0,O.jsx)(ut,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,O.jsx)(Rt,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Tr({icon:e}){return e===`paperclip`?(0,O.jsx)(ln,{className:`h-4 w-4`}):(0,O.jsx)(wr,{icon:e})}function Er(e){return e===`model`?`min-w-[220px]`:e===`session-type`?`min-w-[140px]`:e===`thinking`?`min-w-[150px]`:``}function Dr(e){return e===`model`?`w-[320px]`:e===`session-type`?`w-[220px]`:e===`thinking`?`w-[180px]`:``}function Or({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=dr,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0);return(0,O.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,O.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-3 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 ${Er(e.key)}`,children:e.selectedLabel?(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,O.jsx)(wr,{icon:e.icon}),(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700`,children:e.selectedLabel})]}):e.loading?(0,O.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,O.jsx)(c,{placeholder:e.placeholder})}),(0,O.jsxs)(n,{className:Dr(e.key),children:[u?null:e.loading?(0,O.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,O.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,O.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,O.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,O.jsxs)(`div`,{children:[t>0?(0,O.jsx)(o,{}):null,(0,O.jsxs)(r,{children:[e.label?(0,O.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,O.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,O.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function kr(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=dr;return(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.skillPicker?(0,O.jsx)(Cr,{picker:e.skillPicker}):null,e.selects.map(e=>(0,O.jsx)(Or,{item:e},e.key)),e.accessories?.map(e=>{let a=(0,O.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,O.jsx)(Tr,{icon:e.icon}),e.iconOnly?null:(0,O.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,O.jsx)(r,{children:(0,O.jsxs)(t,{children:[(0,O.jsx)(i,{asChild:!0,children:e.disabled?(0,O.jsx)(`span`,{className:`inline-flex`,children:a}):a}),(0,O.jsx)(n,{side:`top`,children:(0,O.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,O.jsx)(`div`,{children:a},e.key)})]}),(0,O.jsx)(xr,{...e.actions})]})}var Ar=(0,k.createContext)(null);function jr(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function Mr(){let e=(0,k.useContext)(Ar);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function j(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Nr(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Pr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Fr=Pr&&`documentMode`in document?document.documentMode:null,Ir=Pr&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Lr=Pr&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Rr=!(!Pr||!(`InputEvent`in window)||Fr)&&`getTargetRanges`in new window.InputEvent(`input`),zr=Pr&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Br=Pr&&/Android/.test(navigator.userAgent),Vr=Pr&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Br,Hr=Pr&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ur=Pr&&Br&&Hr,Wr=Pr&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ir&&!Hr,Gr=0,Kr=1,qr=2,Jr=1,Yr=2,Xr=3,Zr=4,Qr=5,$r=6,ei=Vr||zr||Wr?`\xA0`:`​`,ti=`
1
+ import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,m as s,n as c,p as l,u}from"./i18n-BnNAQpVM.js";import{At as d,Ft as f,Gt as p,H as m,It as h,Mt as g,Ot as _,Pt as v,_t as y,at as b,b as x,bt as S,g as C,h as w,it as T,jt as E,kt as ee,m as te,mt as ne,n as re,ot as ie,p as ae,r as oe,rt as se,st as ce,y as le,yt as ue,zt as de}from"./api-C51456xV.js";import{a as fe,i as pe,n as me,o as he,r as ge,t as _e}from"./dialog-BHcaU6NE.js";import{t as D}from"./createLucideIcon-C_GFKVuW.js";import{b as ve,c as ye,d as be,f as xe,g as Se,h as Ce,l as we,m as Te,n as Ee,s as De,u as Oe,v as ke,y as Ae}from"./theme-provider-dHqcWU-j.js";import{n as je,t as Me}from"./search-DZSNKEGp.js";import{t as Ne}from"./book-open-B4mOKdz8.js";import{D as Pe,O as Fe,_ as Ie,b as Le,c as Re,d as ze,f as Be,g as Ve,h as He,i as Ue,k as We,l as Ge,m as Ke,n as qe,o as Je,p as Ye,r as Xe,s as Ze,t as Qe,u as $e,v as et,y as tt}from"./select-DRDejPLk.js";import{t as nt}from"./external-link-DP2IJ7AM.js";import{t as rt}from"./folder-BPwc278w.js";import{n as it,t as at}from"./logos-BcELLmYh.js";import{t as ot}from"./loader-circle-C6gg2m2a.js";import{t as st}from"./plus-BptLViq1.js";import{t as ct}from"./refresh-ccw-CeG203yU.js";import{t as lt}from"./settings-DjvNMJde.js";import{t as ut}from"./sparkles-CyDTgTM4.js";import{t as dt}from"./trash-2-C1cdqL6V.js";import{t as ft}from"./x-BjMO7v8q.js";import{i as pt}from"./doc-browser-context-Dib9sS83.js";import{n as mt}from"./doc-browser-CwgI7ipB.js";import{n as ht}from"./use-viewport-layout-D-pjxsyz.js";import{m as gt}from"./use-config-DFja1sda.js";import{a as _t,c as vt,i as yt,n as bt,o as xt,r as St,s as Ct,t as wt}from"./popover-B8msg2FQ.js";import{t as Tt}from"./logo-badge-uB4SwANR.js";import{a as Et,c as Dt,i as Ot,l as kt,n as At,o as jt,r as Mt,s as Nt,t as Pt}from"./tooltip-C6VPreZ7.js";import{t as Ft}from"./skeleton-5Mg6vZHN.js";var It=D(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Lt=D(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Rt=D(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),zt=D(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Bt=D(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Vt=D(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ht=D(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ut=D(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),Wt=D(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),Gt=D(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Kt=D(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),qt=D(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),Jt=D(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),Yt=D(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Xt=D(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Zt=D(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Qt=D(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),$t=D(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),en=D(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),tn=D(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),nn=D(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),rn=D(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),an=D(`HeartPulse`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}],[`path`,{d:`M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`1uw2ng`}]]),on=D(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),sn=D(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),cn=D(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ln=D(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),un=D(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),dn=D(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),fn=D(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),pn=D(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),mn=D(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),O=l();function hn({isProjectFirstView:e,onSelectMode:t}){return(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,O.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:u(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:o(`chatSidebarViewTime`)}),(0,O.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:u(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:o(`chatSidebarViewProject`)})]})}var gn={wx:`weixin`,lark:`feishu`},_n={heartbeat:{icon:`heartbeat`},cron:{icon:`cron`}},vn={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function yn(e){return e?.trim().toLowerCase()??``}function bn(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function xn(e,t){let n=yn(e);if(!n||n===`native`)return null;let r=t.find(e=>yn(e.value)===n);return r?.label.trim()?r.label.trim():bn(n)}function Sn(e,t){let n=yn(e);return!n||n===`native`?null:t.find(e=>yn(e.value)===n)??null}function Cn(e){let t=yn(e);if(!t)return null;let n=gn[t]??t;return at(n)?n:null}function wn(e,t){let n=Cn(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=_n[yn(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=yn(e.sessionType),a=Sn(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let s=vn[i];return s?{icon:null,label:o(s)}:{icon:null,label:a?.label?.trim()||xn(e.sessionType,t)}}var Tn=`app://`;function En(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Dn(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Tn))return t;let n=En(t.slice(6));return n?`/${n}`:null}function On({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,O.jsx)(kn,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Dn(e.src);return(0,O.jsx)(Tt,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:u(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,O.jsx)(Ae,{className:u(`h-3 w-3 text-gray-500`,t)})})}return e.icon===`heartbeat`?(0,O.jsx)(an,{className:u(`h-3.5 w-3.5`,t)}):(0,O.jsx)(ve,{className:u(`h-3.5 w-3.5`,t)})}function kn({channel:e,className:t}){return(0,O.jsx)(Tt,{name:e,src:at(e),className:u(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,O.jsx)(Ae,{className:`h-3 w-3 text-gray-500`})})}function An(e){let{option:t,onSelect:n}=e,r=t.ready===!1?t.reasonMessage?.trim()||o(`statusSetup`):null;return(0,O.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-2xl px-3 py-2.5 text-left transition-colors hover:bg-gray-50`,children:(0,O.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[t.icon?.src?(0,O.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,O.jsx)(On,{icon:{kind:`runtime-image`,src:t.icon.src,alt:t.icon.alt??null,name:t.label}})}):(0,O.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5 text-gray-400`,children:(0,O.jsx)(Ae,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:t.label}),(0,O.jsxs)(`span`,{className:u(`inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium`,t.ready===!1?`text-amber-700`:`text-emerald-600`),children:[(0,O.jsx)(`span`,{className:u(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?o(`statusSetup`):o(`statusReady`)]})]}),r?(0,O.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:r}):null]})]})})})}var k=e(s(),1);function jn(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Mn(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[s,c]=(0,k.useState)(null),l=(0,k.useMemo)(()=>jn(n,r),[n,r]),u=r.length>1;return(0,O.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${o(`chatSidebarNewTask`)} · ${e.projectName}`;return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-0.5`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(`div`,{className:`truncate text-[11px] font-medium uppercase tracking-wider text-gray-500`,title:e.projectRoot,children:e.projectName}),(0,O.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400`,children:e.items.length})]}),u?(0,O.jsxs)(wt,{open:s===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,"aria-label":t,title:t,children:(0,O.jsx)(st,{className:`h-3.5 w-3.5`})})}),(0,O.jsxs)(bt,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:o(`chatSessionTypeLabel`)}),(0,O.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,O.jsx)(An,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,O.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,onClick:()=>a(l,e.projectRoot),"aria-label":t,title:t,children:(0,O.jsx)(st,{className:`h-3.5 w-3.5`})})]}),(0,O.jsx)(`div`,{className:`space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}var Nn=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Pn(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Fn(e){let t=e.trim();return t?t.slice(0,1).toUpperCase():`A`}function In({agentId:e,displayName:t,avatarUrl:n,className:r}){let i=t?.trim()||e,[a,o]=Nn[Pn(e)%Nn.length]??Nn[0];return n?.trim()?(0,O.jsx)(`img`,{src:n,alt:t?.trim()||e,className:u(`rounded-full object-cover`,r)}):(0,O.jsx)(`div`,{className:u(`rounded-full flex items-center justify-center font-semibold`,a,o,r),"aria-label":t?.trim()||e,children:Fn(i)})}function Ln({status:e,className:t}){let n=o(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,O.jsxs)(`span`,{className:u(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,t),title:n,"aria-label":n,children:[(0,O.jsx)(ot,{className:`h-3 w-3 animate-spin`}),(0,O.jsx)(`span`,{className:`sr-only`,children:n})]})}function Rn({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(ee,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:o(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e.key}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(d,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void i(),disabled:n,"aria-label":o(`save`),children:(0,O.jsx)(We,{className:`h-3.5 w-3.5`})}),(0,O.jsx)(d,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:a,disabled:n,"aria-label":o(`cancel`),children:(0,O.jsx)(ft,{className:`h-3.5 w-3.5`})})]})]})]})}function zn({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:s,agentLabel:l,agentAvatarUrl:d,childSessionCount:f=0,onSelect:p,onOpenChildSessions:m,onStartEditing:h}){let g=t?`text-gray-700`:`text-gray-500`,_=s?.trim()??``;return(0,O.jsxs)(`div`,{className:`group/session relative`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:p,className:`w-full text-left`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-1.5 pr-8`,children:[(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[_&&_.toLowerCase()!==`main`?(0,O.jsx)(In,{agentId:_,displayName:l,avatarUrl:d,className:`h-5 w-5 shrink-0`}):null,(0,O.jsx)(`span`,{className:`truncate font-medium`,children:a}),i.label?(0,O.jsx)(`span`,{className:u(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,t?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:i.label}):null,i.icon?(0,O.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,O.jsx)(On,{icon:i.icon,className:g})}):null]}),(0,O.jsxs)(`span`,{className:`inline-flex shrink-0 items-center justify-end gap-1.5`,children:[n?(0,O.jsx)(`span`,{"aria-label":o(`chatSessionUnread`),className:`h-2 w-2 rounded-full bg-primary`}):null,(0,O.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,children:r?(0,O.jsx)(Ln,{status:r}):null})]})]}),(0,O.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-400 truncate`,children:(0,O.jsxs)(`span`,{children:[l?.trim()?`${l} · `:``,e.messageCount,` · `,c(e.updatedAt)]})})]}),f>0&&m?(0,O.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m()},className:u(`absolute right-7 top-0 inline-flex h-7 items-center gap-1 rounded-lg px-1.5 text-[10px] font-medium text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":o(`chatSessionOpenChildSessions`),title:o(`chatSessionOpenChildSessions`),children:[(0,O.jsx)(rn,{className:`h-3.5 w-3.5`}),(0,O.jsx)(`span`,{children:f})]}):null,(0,O.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h()},className:u(`absolute right-0 top-0 inline-flex h-7 w-7 items-center justify-center rounded-lg text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":o(`edit`),children:(0,O.jsx)(un,{className:`h-3.5 w-3.5`})})]})}function Bn({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l,isEditing:d,draftLabel:f,isSaving:p,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,O.jsx)(`div`,{className:u(`w-full rounded-xl px-3 py-2 text-left transition-all text-[13px]`,t?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:d?(0,O.jsx)(Rn,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,O.jsx)(zn,{session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,onSelect:m,childSessionCount:l,onOpenChildSessions:h,onStartEditing:g})})}var Vn=[{icon:Ce,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:ke,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:ve,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function Hn({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,O.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,O.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,O.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,O.jsx)(Ae,{className:`h-8 w-8 text-primary`})}),(0,O.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:o(`chatWelcomeTitle`)}),(0,O.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:o(`chatWelcomeSubtitle`)}),(0,O.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,O.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:o(`chatDraftAgentTitle`)}),(0,O.jsxs)(Qe,{value:n,onValueChange:r,children:[(0,O.jsxs)(Ue,{"aria-label":o(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,O.jsx)(`span`,{className:`sr-only`,children:o(`chatDraftAgentTitle`)}),(0,O.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,O.jsx)(In,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,O.jsx)(qe,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,O.jsx)(Xe,{value:e.id,className:`rounded-lg pr-10`,children:(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(In,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,O.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,O.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:Vn.map(t=>{let n=t.icon;return(0,O.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,O.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,O.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,O.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:o(t.titleKey)}),(0,O.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:o(t.descKey)})]},t.titleKey)})})]})})}var Un=e=>`[data-item-index="${e}"]`;function Wn(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??Un;(0,k.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function Gn(){let e=(0,k.useRef)(null),[t,n]=(0,k.useState)(null);return(0,k.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function A(...e){return n(r(e))}var Kn=k.forwardRef(({className:e,type:t,...n},r)=>(0,O.jsx)(`input`,{type:t,className:A(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Kn.displayName=`ChatInput`;var qn=Ct,Jn=vt,Yn=yt,Xn=k.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,O.jsx)(xt,{children:(0,O.jsx)(_t,{ref:i,sideOffset:t,align:n,className:A(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));Xn.displayName=_t.displayName;var Zn=Ke,Qn=Ze,$n=tt,er=k.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsxs)(et,{ref:r,className:A(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,O.jsx)(Re,{asChild:!0,children:(0,O.jsx)(Fe,{className:`h-4 w-4 opacity-50`})})]}));er.displayName=et.displayName;var tr=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(Ve,{ref:n,className:A(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,O.jsx)(Pe,{className:`h-4 w-4`})}));tr.displayName=Ve.displayName;var nr=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(He,{ref:n,className:A(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,O.jsx)(Fe,{className:`h-4 w-4`})}));nr.displayName=He.displayName;var rr=k.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,O.jsx)(Ye,{children:(0,O.jsxs)(Je,{ref:i,className:A(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,O.jsx)(tr,{}),(0,O.jsx)(Le,{className:A(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,O.jsx)(nr,{})]})}));rr.displayName=Je.displayName;var ir=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(Be,{ref:n,className:A(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));ir.displayName=Be.displayName;var ar=k.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsxs)(Ge,{ref:r,className:A(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,O.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,O.jsx)($e,{children:(0,O.jsx)(We,{className:`h-4 w-4`})})}),(0,O.jsx)(ze,{children:t})]}));ar.displayName=Ge.displayName;var or=k.forwardRef(({className:e,...t},n)=>(0,O.jsx)(Ie,{ref:n,className:A(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));or.displayName=Ie.displayName;var sr=Nt,cr=Dt,lr=kt,ur=k.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,O.jsx)(jt,{children:(0,O.jsx)(Et,{ref:r,sideOffset:t,className:A(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));ur.displayName=Et.displayName;var dr={Popover:qn,PopoverAnchor:Yn,PopoverContent:Xn,PopoverTrigger:Jn,Input:Kn,Select:Zn,SelectContent:rr,SelectGroup:Qn,SelectItem:ar,SelectLabel:ir,SelectSeparator:or,SelectTrigger:er,SelectValue:$n,Tooltip:cr,TooltipContent:ur,TooltipProvider:sr,TooltipTrigger:lr},fr=680,pr=.82,mr=560;function hr(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=dr,{elementRef:i,width:a}=Gn(),o=(0,k.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onSetActiveIndex:h}=e,g=(0,k.useMemo)(()=>{if(a)return Math.min(a>mr?a*pr:a,fr)},[a]);return Wn({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,O.jsxs)(t,{open:s,onOpenChange:m,children:[(0,O.jsx)(n,{asChild:!0,children:(0,O.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,O.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:g?{width:`${g}px`}:void 0,children:(0,O.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,O.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,O.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,O.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,O.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,O.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>h(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,O.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,O.jsx)(`div`,{className:`min-w-0 p-2.5`,children:d?(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,O.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,O.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,O.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,O.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,O.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,O.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var gr=E(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),_r=k.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,O.jsx)(`button`,{className:A(gr({variant:t,size:n,className:e})),ref:i,...r}));_r.displayName=`ChatButton`;var vr=120;function yr(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=vr?t:`${t.slice(0,vr-1)}…`}function br(){return(0,O.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function xr({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,onSend:l,onStop:u}){let{Popover:d,PopoverContent:f,PopoverTrigger:p,Tooltip:m,TooltipContent:h,TooltipProvider:g,TooltipTrigger:_}=dr,v=e?.trim()??``,y=v?yr(v):``,b=t?.trim()||`Details`;return(0,O.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[v?(0,O.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,O.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,O.jsx)(`span`,{className:`block truncate`,title:v,children:y})}),(0,O.jsxs)(d,{children:[(0,O.jsx)(p,{asChild:!0,children:(0,O.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:b})}),(0,O.jsxs)(f,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,O.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:b}),(0,O.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:v})]})]})]}):null,(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:n?r?(0,O.jsx)(_r,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void u(),disabled:a,children:(0,O.jsx)(br,{})}):(0,O.jsx)(g,{children:(0,O.jsxs)(m,{children:[(0,O.jsx)(_,{asChild:!0,children:(0,O.jsx)(`span`,{children:(0,O.jsx)(_r,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,O.jsx)(br,{})})})}),(0,O.jsx)(h,{side:`top`,children:(0,O.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,O.jsx)(_r,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void l(),disabled:i,children:(0,O.jsx)(Lt,{className:`h-5 w-5`})})})]})}function Sr(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function Cr(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=dr,{picker:a}=e,o=(0,k.useRef)(null),s=(0,k.useId)(),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(0),f=(0,k.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,k.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,k.useMemo)(()=>h?h.flatMap(e=>e.options):Sr(a.options,c),[h,a.options,c]);(0,k.useEffect)(()=>{d(0)},[c]),(0,k.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),Wn({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,O.jsxs)(n,{children:[(0,O.jsx)(i,{asChild:!0,children:(0,O.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,O.jsx)(ke,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{children:a.title}),p>0?(0,O.jsx)(`span`,{className:`ml-0.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary`,children:p}):null]})}),(0,O.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,O.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,O.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(Me,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,O.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,O.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,O.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,O.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,O.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,O.jsxs)(`div`,{children:[e.label?(0,O.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,O.jsxs)(`button`,{type:`button`,id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onClick:()=>_(e.key),onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,O.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,O.jsx)(dn,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,O.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,O.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,O.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,O.jsx)(`span`,{className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,O.jsx)(We,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,O.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,O.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,O.jsx)(nt,{className:`h-3 w-3`})]})}):null]})]})}function wr({icon:e}){return e===`sparkles`?(0,O.jsx)(ut,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,O.jsx)(Rt,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Tr({icon:e}){return e===`paperclip`?(0,O.jsx)(ln,{className:`h-4 w-4`}):(0,O.jsx)(wr,{icon:e})}function Er(e){return e===`model`?`min-w-[220px]`:e===`session-type`?`min-w-[140px]`:e===`thinking`?`min-w-[150px]`:``}function Dr(e){return e===`model`?`w-[320px]`:e===`session-type`?`w-[220px]`:e===`thinking`?`w-[180px]`:``}function Or({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=dr,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0);return(0,O.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,O.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-3 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 ${Er(e.key)}`,children:e.selectedLabel?(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,O.jsx)(wr,{icon:e.icon}),(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700`,children:e.selectedLabel})]}):e.loading?(0,O.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,O.jsx)(c,{placeholder:e.placeholder})}),(0,O.jsxs)(n,{className:Dr(e.key),children:[u?null:e.loading?(0,O.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,O.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,O.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,O.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,O.jsxs)(`div`,{children:[t>0?(0,O.jsx)(o,{}):null,(0,O.jsxs)(r,{children:[e.label?(0,O.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,O.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,O.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,O.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,O.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function kr(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=dr;return(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.skillPicker?(0,O.jsx)(Cr,{picker:e.skillPicker}):null,e.selects.map(e=>(0,O.jsx)(Or,{item:e},e.key)),e.accessories?.map(e=>{let a=(0,O.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,O.jsx)(Tr,{icon:e.icon}),e.iconOnly?null:(0,O.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,O.jsx)(r,{children:(0,O.jsxs)(t,{children:[(0,O.jsx)(i,{asChild:!0,children:e.disabled?(0,O.jsx)(`span`,{className:`inline-flex`,children:a}):a}),(0,O.jsx)(n,{side:`top`,children:(0,O.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,O.jsx)(`div`,{children:a},e.key)})]}),(0,O.jsx)(xr,{...e.actions})]})}var Ar=(0,k.createContext)(null);function jr(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function Mr(){let e=(0,k.useContext)(Ar);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function j(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Nr(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Pr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Fr=Pr&&`documentMode`in document?document.documentMode:null,Ir=Pr&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Lr=Pr&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Rr=!(!Pr||!(`InputEvent`in window)||Fr)&&`getTargetRanges`in new window.InputEvent(`input`),zr=Pr&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Br=Pr&&/Android/.test(navigator.userAgent),Vr=Pr&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Br,Hr=Pr&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ur=Pr&&Br&&Hr,Wr=Pr&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ir&&!Hr,Gr=0,Kr=1,qr=2,Jr=1,Yr=2,Xr=3,Zr=4,Qr=5,$r=6,ei=Vr||zr||Wr?`\xA0`:`​`,ti=`
2
2
 
3
3
  `,ni=Lr?`\xA0`:ei,ri={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},ii={directionless:1,unmergeable:2},ai={center:2,end:6,justify:4,left:1,right:3,start:5},oi={[Yr]:`center`,[$r]:`end`,[Zr]:`justify`,[Jr]:`left`,[Xr]:`right`,[Qr]:`start`},si={normal:0,segmented:2,token:1},ci={[Gr]:`normal`,[qr]:`segmented`,[Kr]:`token`},li=`$config`;function ui(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(L(o)&&ui(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var di=!1,fi=0;function pi(e){fi=e.timeStamp}function mi(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&ul(e,n)!==void 0}function hi(e,t,n){let r=Ql(Wl(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&Cl(t,o,i,a,!1)}function gi(e,t,n){if(P(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return $c(t)&&n.isAttached()}function _i(e,t,n,r){for(let i=e;i&&!pu(i);i=Rl(i)){let e=ul(i,t);if(e!==void 0){let t=cl(e,n);if(t)return R(t)||!eu(i)?void 0:[i,t]}else if(i===r)return[r,hl(n)]}}function vi(e,t,n){di=!0;let r=performance.now()-fi>100;try{hc(e,()=>{let i=F()||function(e){return e.getEditorState().read(()=>{let e=F();return e===null?null:e.clone()})}(e),a=new Map,o=e.getRootElement(),s=e._editorState,c=e._blockCursorElement,l=!1,u=``;for(let n=0;n<t.length;n++){let d=t[n],f=d.type,p=d.target,m=_i(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&N(g)&&$c(p)&&gi(i,p,g)&&hi(p,g,e);else if(f===`childList`){l=!0;let t=d.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=ll(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!mi(r,a,e)){if(Lr){let e=(eu(r)?r.innerText:null)||r.nodeValue;e&&(u+=e)}a.removeChild(r)}}let n=d.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(mi(r,p,e)||c===r)&&(p.appendChild(r),t++)}r!==t&&a.set(h,g)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let d=n.takeRecords();if(d.length>0){for(let t=0;t<d.length;t++){let n=d[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||mi(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&gl(i),Lr&&Il(e)&&i.insertRawText(u))})}finally{di=!1}}function yi(e){let t=e._observer;t!==null&&vi(e,t.takeRecords(),t)}function bi(e){(function(e){fi===0&&Wl(e).addEventListener(`textInput`,pi,!0)})(e),e._observer=new MutationObserver((t,n)=>{vi(e,t,n)})}var xi=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Oi).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Si(e,t){return new xi(e,t)}function Ci(e){let t=new Map,n=new Set;for(let r=typeof e==`function`?e:e.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){let{ownNodeConfig:e}=hu(r);if(e&&e.stateConfigs)for(let r of e.stateConfigs){let e;`stateConfig`in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}var wi=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState;this.size=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return Di(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=Di(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function Ti(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new wi(t,Ei(t));return t.__state=n,n}function Ei(e){return e.__state?e.__state.sharedNodeState:Hc(ou(),e.getType()).sharedNodeState}function Di(e){if(e)for(let t in e)return e}function Oi(e){return e}function ki(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function Ai(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function ji(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function Mi(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=new Set;return!(e&&ki(n,e,t)||t&&ki(n,t,e)||e&&Ai(n,e,t)||t&&Ai(n,t,e))}(c,l))}function Ni(e,t){let n=e.mergeWithSibling(t),r=I()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function Pi(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&N(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(Mi(t,r)){r=Ni(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&N(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(Mi(r,n)){r=Ni(r,n);break}break}n.remove()}}else r.remove()}function Fi(e){return Ii(e.anchor),Ii(e.focus),e}function Ii(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),N(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!L(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi=``,Ji=null,Yi=null,Xi=!1,Zi=!1;function Qi(e,t){let n=Ui.get(e);if(t!==null){let n=ga(e);n.parentNode===t&&t.removeChild(n)}if(Wi.has(e)||Ri._keyToDOMMap.delete(e),L(n)){let e=ua(n,Ui);$i(e,0,e.length-1,null)}n!==void 0&&Nl(Ki,zi,Bi,n,`destroyed`)}function $i(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&Qi(t,r)}}function ea(e,t){e.setProperty(`text-align`,t)}var ta=`40px`;function na(e,t){let n=Li.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}if(t===0)return void e.style.setProperty(`padding-inline-start`,``);let r=getComputedStyle(Ri._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||ta;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function ra(e,t){let n=e.style;t===0?ea(n,``):t===1?ea(n,`left`):t===2?ea(n,`center`):t===3?ea(n,`right`):t===4?ea(n,`justify`):t===5?ea(n,`start`):t===6&&ea(n,`end`)}function ia(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Sc(e))return null;let n=e.getParentOrThrow();return Sc(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function aa(e,t){let n=Wi.get(e);n===void 0&&j(60);let r=n.createDOM(Li,Ri);if(function(e,t,n){let r=n._keyToDOMMap;(function(e,t,n){let r=`__lexicalKey_${t._key}`;e[r]=n})(t,n,e),r.set(e,t)}(e,r,Ri),N(n)?r.setAttribute(`data-lexical-text`,`true`):R(n)&&r.setAttribute(`data-lexical-decorator`,`true`),L(n)){let e=n.__indent,t=n.__size;if(ia(r,n),e!==0&&na(r,e),t!==0){let e=t-1;oa(ua(n,Wi),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&ra(r,i),n.isInline()||ca(null,n,r)}else{let t=n.getTextContent();if(R(n)){let t=n.decorate(Ri,Li);t!==null&&fa(e,t),r.contentEditable=`false`}qi+=t}return t!==null&&t.insertChild(r),Nl(Ki,zi,Bi,n,`created`),r}function oa(e,t,n,r,i){let a=qi;qi=``;let o=n;for(;o<=r;++o){aa(e[o],i);let t=Wi.get(e[o]);t!==null&&N(t)?Ji===null&&(Ji=t.getFormat(),Yi=t.getStyle()):L(t)&&o<r&&!t.isInline()&&(qi+=ti)}i.element.__lexicalTextContent=qi,qi=a+qi}function sa(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return Jo(e)?`line-break`:R(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function ca(e,t,n){let r=sa(e,Ui),i=sa(t,Wi);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function la(e,t,n){var r;Ji=null,Yi=null,function(e,t,n){let r=qi,i=e.__size,a=t.__size;qi=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)da(n,o);else{let e=ga(n),t=aa(r,null);try{o.replaceChild(t,e)}catch(i){if(typeof i==`object`&&i){let a=`${i.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw Error(a)}throw i}Qi(n,null)}let i=Wi.get(r);N(i)&&Ji===null&&(Ji=i.getFormat(),Yi=i.getStyle())}else{let r=ua(e,Ui),s=ua(t,Wi);if(r.length!==i&&j(227),s.length!==a&&j(228),i===0)a!==0&&oa(s,0,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&n.element.__lexicalLineBreak==null;$i(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else (function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f];if(e===r)u=pa(da(r,a.element)),d++,f++;else{if(l===void 0&&(l=ma(n,f)),c===void 0)c=ma(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=pa(ga(e)),Qi(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=Ll(Ri,r);e!==u&&a.withBefore(u).insertChild(e),u=pa(da(r,a.element)),d++,f++}else aa(r,a.withBefore(u)),f++}let i=Wi.get(r);i!==null&&N(i)?Ji===null&&(Ji=i.getFormat(),Yi=i.getStyle()):L(i)&&f<=s&&!i.isInline()&&(qi+=ti)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:Ri.getElementByKey(e);oa(n,0,f,s,a.withBefore(t))}else m&&!p&&$i(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=qi,qi=r+qi}(e,t,t.getDOMSlot(n)),r=t,Ji==null||Ji===r.__textFormat||Zi||r.setTextFormat(Ji),function(e){Yi==null||Yi===e.__textStyle||Zi||e.setTextStyle(Yi)}(t)}function ua(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t.get(r);e===void 0&&j(101),n.push(r),r=e.__next}return n}function da(e,t){let n=Ui.get(e),r=Wi.get(e);n!==void 0&&r!==void 0||j(61);let i=Xi||Hi.has(e)||Vi.has(e),a=Ll(Ri,e);if(n===r&&!i){let e;if(L(n)){let t=a.__lexicalTextContent;typeof t==`string`?e=t:(e=n.getTextContent(),a.__lexicalTextContent=e)}else e=n.getTextContent();return qi+=e,a}if(n!==r&&i&&Nl(Ki,zi,Bi,r,`updated`),r.updateDOM(n,a,Li)){let n=aa(e,null);return t===null&&j(62),t.replaceChild(n,a),Qi(e,null),n}if(L(n)){L(r)||j(334,e);let t=r.__indent;(Xi||t!==n.__indent)&&na(a,t);let o=r.__format;if((Xi||o!==n.__format)&&ra(a,o),i)la(n,r,a),Sc(r)||r.isInline()||ca(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),qi+=t}if((Xi||r.__dir!==n.__dir)&&(ia(a,r),Sc(r)&&!Xi))for(let e of r.getChildren())L(e)&&ia(Ll(Ri,e.getKey()),e)}else{let t=r.getTextContent();if(R(r)){let t=r.decorate(Ri,Li);t!==null&&fa(e,t)}qi+=t}if(!Zi&&Sc(r)&&r.__cachedText!==qi){let e=r.getWritable();e.__cachedText=qi,r=e}return a}function fa(e,t){let n=Ri._pendingDecorators,r=Ri._decorators;if(n===null){if(r[e]===t)return;n=fl(Ri)}n[e]=t}function pa(e){let t=e.nextSibling;return t!==null&&t===Ri._blockCursorElement&&(t=t.nextSibling),t}function ma(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function ha(e,t,n,r,i,a){qi=``,Xi=r===2,Ri=n,Li=n._config,zi=n._nodes,Bi=Ri._listeners.mutation,Vi=i,Hi=a,Ui=e._nodeMap,Wi=t._nodeMap,Zi=t._readOnly,Gi=new Map(n._keyToDOMMap);let o=new Map;return Ki=o,da(`root`,null),Ri=void 0,zi=void 0,Vi=void 0,Hi=void 0,Ui=void 0,Wi=void 0,Li=void 0,Gi=void 0,Ki=void 0,o}function ga(e){let t=Gi.get(e);return t===void 0&&j(75,e),t}function M(e){return{type:e}}var _a=M(`SELECTION_CHANGE_COMMAND`),va=M(`CLICK_COMMAND`),ya=M(`BEFORE_INPUT_COMMAND`),ba=M(`INPUT_COMMAND`),xa=M(`COMPOSITION_START_COMMAND`),Sa=M(`COMPOSITION_END_COMMAND`),Ca=M(`DELETE_CHARACTER_COMMAND`),wa=M(`INSERT_LINE_BREAK_COMMAND`),Ta=M(`INSERT_PARAGRAPH_COMMAND`),Ea=M(`CONTROLLED_TEXT_INSERTION_COMMAND`),Da=M(`PASTE_COMMAND`),Oa=M(`REMOVE_TEXT_COMMAND`),ka=M(`DELETE_WORD_COMMAND`),Aa=M(`DELETE_LINE_COMMAND`),ja=M(`FORMAT_TEXT_COMMAND`),Ma=M(`UNDO_COMMAND`),Na=M(`REDO_COMMAND`),Pa=M(`KEYDOWN_COMMAND`),Fa=M(`KEY_ARROW_RIGHT_COMMAND`),Ia=M(`MOVE_TO_END`),La=M(`KEY_ARROW_LEFT_COMMAND`),Ra=M(`MOVE_TO_START`),za=M(`KEY_ARROW_UP_COMMAND`),Ba=M(`KEY_ARROW_DOWN_COMMAND`),Va=M(`KEY_ENTER_COMMAND`),Ha=M(`KEY_SPACE_COMMAND`),Ua=M(`KEY_BACKSPACE_COMMAND`),Wa=M(`KEY_ESCAPE_COMMAND`),Ga=M(`KEY_DELETE_COMMAND`),Ka=M(`KEY_TAB_COMMAND`),qa=M(`DROP_COMMAND`),Ja=M(`DRAGSTART_COMMAND`),Ya=M(`DRAGOVER_COMMAND`),Xa=M(`DRAGEND_COMMAND`),Za=M(`COPY_COMMAND`),Qa=M(`CUT_COMMAND`),$a=M(`SELECT_ALL_COMMAND`),eo=M(`FOCUS_COMMAND`),to=M(`BLUR_COMMAND`),no=M(`KEY_MODIFIER_COMMAND`),ro=Object.freeze({}),io=[[`keydown`,function(e,t){ao=e.timeStamp,oo=e.key,!t.isComposing()&&B(t,Pa,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;tu(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&hc(t,()=>{Gc(n)||(po=!0)})}],[`compositionstart`,function(e,t){B(t,xa,e)}],[`compositionend`,function(e,t){Lr?ho=!0:zr||!Vr&&!Wr?B(t,Sa,e):(go=!0,_o=e.data)}],[`input`,function(e,t){e.stopPropagation(),hc(t,()=>{t.dispatchCommand(ba,e)},{event:e}),co=null}],[`click`,function(e,t){hc(t,()=>{let n=F(),r=Ql(Wl(t)),i=Is();if(r){if(P(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!Sc(a)&&ml().getChildrenSize()===1&&a.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(e.detail===3&&!n.isCollapsed()&&a!==n.focus.getNode()){let e=_u(a,e=>L(e)&&!e.isInline());L(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(eu(n)||$c(n))&&gl(Fs(i,r,t,e))}}B(t,va,e)})}],[`cut`,ro],[`copy`,ro],[`dragstart`,ro],[`dragover`,ro],[`dragend`,ro],[`paste`,ro],[`focus`,ro],[`blur`,ro],[`drop`,ro]];Rr&&io.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||Lr&&Il(t)||n!==`insertCompositionText`&&B(t,ya,e)}(e,t)]);var ao=0,oo=null,so=0,co=null,lo=new WeakMap,uo=new WeakMap,fo=!1,po=!1,mo=!1,ho=!1,go=!1,_o=``,vo=null,yo=[0,``,0,`root`,0];function bo(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=I(),l=Ql(Wl(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!N(s)||(!i&&(!Rr||so<r+50)||s.isDirty()&&p<2||vl(n))&&a.offset!==o.offset&&!s.isComposing()||Qc(s)||s.isDirty()&&p>1||(i||!Rr)&&f!==null&&!s.isComposing()&&u!==tl(f)||l!==null&&t!==null&&(!t.collapsed||t.startContainer!==l.anchorNode||t.startOffset!==l.anchorOffset)||!s.isComposing()&&(s.getFormat()!==e.format||s.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=Zc(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(N(t)||L(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,s)}function xo(e,t){return $c(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function So(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;fo&&(fo=!1,xo(r,i)&&xo(a,o)&&!vo)||hc(t,()=>{if(!n)return void gl(null);if(!qc(t,r,a))return;let s=F();if(vo&&P(s)&&s.isCollapsed()){let e=s.anchor,t=vo.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=vo.clone(),gl(s))}if(vo=null,P(s)){let n=s.anchor,r=n.getNode();if(s.isCollapsed()){e.type===`Range`&&e.anchorNode===e.focusNode&&(s.dirty=!0);let i=Wl(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=yo,f=ml(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)Co(s,o,c);else if(n.type===`text`)N(r)||j(141),wo(s,r);else if(n.type===`element`&&!p){L(r)||j(259);let e=n.getNode();e.isEmpty()?function(e,t){Co(e,t.getTextFormat(),t.getTextStyle())}(s,e):Co(s,s.format,``)}}else{let e=n.key,t=s.focus.key,r=s.getNodes(),a=r.length,c=s.isBackward(),l=c?o:i,u=c?i:o,d=c?t:e,f=c?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(N(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}s.format=m?p:0}}B(t,_a,void 0)})}function Co(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function wo(e,t){Co(e,t.getFormat(),t.getStyle())}function To(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Eo(e){let t=e.inputType,n=To(e),r=I(),i=F();if(t===`deleteContentBackward`){if(i===null){let e=Is();if(!P(e))return!0;gl(e.clone())}if(P(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,oo===`MediaLast`&&a<ao+30&&r.isComposing()&&t){if(ol(null),ao=0,setTimeout(()=>{hc(r,()=>{ol(null)})},30),P(i)){let e=i.anchor.getNode();e.markDirty(),N(e)||j(142),wo(i,e)}}else{ol(null),e.preventDefault();let n=i.anchor.getNode(),a=n.getTextContent(),o=n.canInsertTextAfter(),s=i.anchor.offset===0&&i.focus.offset===a.length,c=Ur&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!R(Fl(i.anchor,!0))),!c){B(r,Ca,!0);let e=F();Ur&&P(e)&&e.isCollapsed()&&(vo=e,setTimeout(()=>vo=null))}}return!0}}var a;if(!P(i))return!0;let o=e.data;co!==null&&Sl(!1,r,co),i.dirty&&co===null||!i.isCollapsed()||Sc(i.anchor.getNode())||n===null||i.applyDOMRange(n),co=null;let s=i.anchor,c=i.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
4
4
  `)e.preventDefault(),B(r,wa,!1);else if(o===ti)e.preventDefault(),B(r,Ta,void 0);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),i.insertRawText(t)}else o!=null&&bo(i,n,o,e.timeStamp,!0)?(e.preventDefault(),B(r,Ea,o)):co=o;return so=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:B(r,Ea,e);break;case`insertFromComposition`:ol(null),B(r,Ea,e);break;case`insertLineBreak`:ol(null),B(r,wa,!1);break;case`insertParagraph`:ol(null),mo&&!zr?(mo=!1,B(r,wa,!1)):B(r,Ta,void 0);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:B(r,Da,e);break;case`deleteByComposition`:(function(e,t){return e!==t||L(e)||L(t)||!Zc(e)||!Zc(t)})(l,u)&&B(r,Oa,e);break;case`deleteByDrag`:case`deleteByCut`:B(r,Oa,e);break;case`deleteContent`:B(r,Ca,!1);break;case`deleteWordBackward`:B(r,ka,!0);break;case`deleteWordForward`:B(r,ka,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:B(r,Aa,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:B(r,Aa,!1);break;case`formatStrikeThrough`:B(r,ja,`strikethrough`);break;case`formatBold`:B(r,ja,`bold`);break;case`formatItalic`:B(r,ja,`italic`);break;case`formatUnderline`:B(r,ja,`underline`);break;case`historyUndo`:B(r,Ma,void 0);break;case`historyRedo`:B(r,Na,void 0)}return!0}function Do(e){if(eu(e.target)&&Gc(e.target))return!0;let t=I(),n=F(),r=e.data,i=To(e);if(r!=null&&P(n)&&bo(n,i,r,e.timeStamp,!1)){ho&&=(Ao(t,r),!1);let i=n.anchor.getNode(),a=Ql(Wl(t));if(a===null)return!0;let o=n.isBackward(),s=o?n.anchor.offset:n.focus.offset,c=o?n.focus.offset:n.anchor.offset;Rr&&!n.isCollapsed()&&N(i)&&a.anchorNode!==null&&i.getTextContent().slice(0,s)+r+i.getTextContent().slice(s+c)===xl(a.anchorNode)||B(t,Ea,r);let l=r.length;Lr&&l>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(n.anchor.offset-=l),Ur&&t.isComposing()&&(ao=0,ol(null))}else Sl(!1,t,r===null?void 0:r),ho&&=(Ao(t,r||void 0),!1);return function(){ec(),yi(I())}(),!0}function Oo(e){let t=I(),n=F();if(P(n)&&!t.isComposing()){let r=n.anchor,i=n.anchor.getNode();ol(r.key),Bl(Uo),(e.timeStamp<ao+30||r.type===`element`||!n.isCollapsed()||i.getFormat()!==n.format||N(i)&&i.getStyle()!==n.style)&&B(t,Ea,ni)}return!0}function ko(e){return Ao(I(),e.data),Bl(Wo),!0}function Ao(e,t){let n=e._compositionKey;if(ol(null),n!==null&&t!=null){if(t===``){let t=cl(n),r=tl(e.getElementByKey(n));if(r!==null&&r.nodeValue!==null&&N(t)){let n=Ql(Wl(e)),i=null,a=null;n!==null&&n.anchorNode===r&&(i=n.anchorOffset,a=n.focusOffset),Cl(t,r.nodeValue,i,a,!0)}return}if(t[t.length-1]===`
@@ -54,5 +54,5 @@ import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,m as s,n as c,p as l,u}f
54
54
 
55
55
  `):void 0}function xk(e){let t=$(e.sessionId),n=$(e.title),r=$(e.sessionType),i=$(e.lifecycle),a=$(e.parentSessionId),o=$(e.createdAt),s=[t?`Session ID: ${t}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,n?`Title: ${n}`:null,r?`Session Type: ${r}`:null,i?`Lifecycle: ${i}`:null,a?`Parent Session ID: ${a}`:null,o?`Created At: ${o}`:null].filter(e=>!!e);return s.length>0?s.join(`
56
56
 
57
- `):void 0}function Sk(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`&&r!==`sessions_spawn`)return null;let s=mk(o);if(s){let e=$(s.status)?.toLowerCase(),t=vk(s,a),o=bk(s),c=$(s.sessionId),l=gO({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...$(s.title)?{label:s.title.trim()}:{},...$(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:_k(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:e===`completed`?{kind:`result`,name:r,detail:t,input:_k(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:{kind:`result`,name:r,detail:t,input:_k(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=hk(o);if(!c)return null;let l=yk(c,a),u=xk(c),d=$(c.sessionId),f=gO({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...$(c.title)?{label:c.title.trim()}:{},...$(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:_k(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function Ck(e,t){let n=nO(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function wk(e,t){let n=e.mimeType.startsWith(`image/`),r=aO(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function Tk(e,t){let n=e.toolInvocation,r=sO(n.result,t);if(r)return r;let i=Sk({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:cO(i,t)};let a=lO({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=fk({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),s=o?.summary??HD(n.parsedArgs??n.args),c=o?void 0:dO(n.args,n.parsedArgs),l=typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:BD(n.result).trim(),u=!n.error&&oO(n.result),d=(!o?.fileOperation||!!n.error)&&!u,f=gO(n);return{type:`tool-card`,card:cO({kind:a.kind,name:n.toolName,...f?{agentId:f}:{},detail:s,...c?{input:c}:{},text:d&&l?l:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel,...o?.fileOperation?{fileOperation:o.fileOperation}:{}},t)}}function Ek(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:BD(e)}}function Dk(e){return e.type===`text`&&typeof e.text==`string`}function Ok(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function kk(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function Ak(e){return e.type!==`tool-invocation`||typeof e.toolInvocation!=`object`||e.toolInvocation===null||Array.isArray(e.toolInvocation)?!1:`toolName`in e.toolInvocation&&typeof e.toolInvocation.toolName==`string`}function jk(e){return Dk(e.part)?tO(e.part,e.inlineTokens):Ok(e.part)?Ck(e.part,e.texts):kk(e.part)?wk(e.part,e.texts):Ak(e.part)?Tk(e.part,e.texts):Ek(e.part,e.texts)}function Mk(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function Nk(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function Pk(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function Fk(e,t){return{id:e.id,role:Pk(e.role),roleLabel:Nk(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(Mk(e)),status:e.meta?.status,parts:e.parts.map(n=>jk({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var Ik=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function Lk(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Rk(e){return Lk(e)}function zk(e){let t=Lk(e);if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return t;let r=n.split(/[\\/]/).filter(Boolean);return r[r.length-1]??n}function Bk(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function Vk(e){let t=Bk(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function Hk(e){let t=e.trim().replace(/\\/g,`/`);return t?/^[A-Za-z]:\//.test(t)?{prefix:t.slice(0,2),segments:t.slice(3).split(`/`).filter(Boolean)}:t.startsWith(`/`)?{prefix:`/`,segments:t.slice(1).split(`/`).filter(Boolean)}:{prefix:null,segments:t.split(`/`).filter(Boolean)}:{prefix:null,segments:[]}}function Uk(e){let t=Vk(e.path),n=Vk(e.sessionProjectRoot);if(!t||!n)return null;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.split(`/`).filter(Boolean);if(t===n)return[];let r=n.endsWith(`/`)?n:`${n}/`;return t.startsWith(r)?t.slice(r.length).split(`/`).filter(Boolean):null}function Wk(e){let{labels:t,leading:n=null}=e,r=t.map((e,n)=>({key:`${n}:${e}`,label:e,kind:n===t.length-1?`file`:`directory`,isCurrent:n===t.length-1}));return n?[n,...r]:r}function Gk(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function Kk(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?Uk({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=zk(i)??i.trim();c=Wk({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=Hk(o);c=Wk({labels:t,leading:e?{key:`root:${e}`,label:e,kind:`root`,isCurrent:t.length===0}:null})}return c.length===0&&(c=[{key:`file:unknown`,label:o||`file`,kind:`file`,isCurrent:!0}]),{fullPath:o,locationLabel:Gk({line:n,column:t}),truncated:a,segments:c}}var qk=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function Jk(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function Yk(e){return`${se}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function Xk(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Zk(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function Qk(e){let t=Zk(e);return t?Xk(t.preferred_model)??Xk(t.preferredModel)??Xk(t.model):null}function $k(e){let t=Zk(e);if(!t)return null;let n=Xk(t.preferred_thinking)??Xk(t.thinking)??Xk(t.thinking_level)??Xk(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return qk.has(r)?r:null}function eA(e){let t=Zk(e);return t?Xk(t.label):null}function tA(e){let t=Zk(e);return t?Rk(t.project_root??t.projectRoot):null}function nA(e){let t=Zk(e);return t?Xk(t.ui_last_read_at):null}function rA(e){let t=Zk(e);return t?Xk(t.runtime)??Xk(t.session_type)??Xk(t.sessionType)??`native`:`native`}function iA(e){let t=Zk(e);return t?Xk(t.parent_session_id)??Xk(t.parentSessionId):null}function aA(e){let t=Zk(e);return t?Xk(t.spawned_by_request_id)??Xk(t.spawnedByRequestId):null}function oA(e){let t=Zk(e);return t?t.child_session_promoted===!0:!1}function sA(e){if(e===`heartbeat`)return{type:`heartbeat`};if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function cA(e){return e.state===`cancelled`?Ik.CANCELLED:e.state===`result`?Ik.RESULT:e.state===`partial-call`?Ik.PARTIAL_CALL:Ik.CALL}function lA(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.assetUri){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:Yk(n.assetUri),...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:cA(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:Jk(n.args),result:n.result}})}return t}function uA(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function dA(e){return{id:e.id,role:uA(e.role),parts:lA(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function fA(e){let t=eA(e),n=Qk(e),r=$k(e),i=tA(e),a=nA(e),o=Xk(e.lastMessageAt),s=zk(i),c=sA(e.sessionId),l=iA(e),u=aA(e),d=oA(e);return{key:e.sessionId,createdAt:e.updatedAt,updatedAt:e.updatedAt,...o?{lastMessageAt:o}:{},...a?{readAt:a}:{},...typeof e.agentId==`string`&&e.agentId.trim().length>0?{agentId:e.agentId.trim()}:{},...t?{label:t}:{},...c,...n?{preferredModel:n}:{},...r?{preferredThinking:r}:{},...i?{projectRoot:i}:{},...s?{projectName:s}:{},sessionType:rA(e),sessionTypeMutable:!1,isChildSession:!!l,...d?{isPromotedChildSession:d}:{},...l?{parentSessionId:l}:{},...u?{spawnedByRequestId:u}:{},messageCount:e.messageCount}}function pA(e){return e.map(fA)}function mA(){return`ncp-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function hA(){return h({queryKey:[`agents`],queryFn:ie,staleTime:3e4})}function gA(){let e=de();return f({mutationFn:({data:e})=>T(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),v.success(o(`configSavedApplied`))},onError:e=>{v.error(o(`configSaveFailed`)+`: `+e.message)}})}function _A(){let e=de();return f({mutationFn:({agentId:e,data:t})=>ce(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),v.success(o(`configSavedApplied`))},onError:e=>{v.error(o(`configSaveFailed`)+`: `+e.message)}})}function vA(){let e=de();return f({mutationFn:({agentId:e})=>b(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),v.success(o(`configSavedApplied`))},onError:e=>{v.error(o(`configSaveFailed`)+`: `+e.message)}})}function yA(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function bA(e){let t=e?.trim()??``,n=WA(e=>e.snapshot.availableAgents??[]),r=hA(),i=(0,k.useMemo)(()=>yA(n,r.data?.agents??[]),[r.data?.agents,n]);return(0,k.useMemo)(()=>{if(!t)return null;let e=i.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[i,t])}function xA({agentId:e,className:t}){let n=bA(e);return n?(0,O.jsx)(In,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var SA=new WeakMap;function CA(e){return{roleLabels:{user:o(`chatRoleUser`),assistant:o(`chatRoleAssistant`),tool:o(`chatRoleTool`),system:o(`chatRoleSystem`),fallback:o(`chatRoleMessage`)},reasoningLabel:o(`chatReasoning`),toolCallLabel:o(`chatToolCall`),toolResultLabel:o(`chatToolResult`),toolInputLabel:o(`chatToolInput`),toolNoOutputLabel:o(`chatToolNoOutput`),toolOutputLabel:o(`chatToolOutput`),toolStatusPreparingLabel:o(`chatToolStatusPreparing`),toolStatusRunningLabel:o(`chatToolStatusRunning`),toolStatusCompletedLabel:o(`chatToolStatusCompleted`),toolStatusFailedLabel:o(`chatToolStatusFailed`),toolStatusCancelledLabel:o(`chatToolStatusCancelled`),imageAttachmentLabel:o(`chatImageAttachment`),fileAttachmentLabel:o(`chatFileAttachment`),unknownPartLabel:o(`chatUnknownPart`)}}function wA(e){return{copyCodeLabel:o(`chatCodeCopy`),copiedCodeLabel:o(`chatCodeCopied`),copyMessageLabel:o(`chatMessageCopy`),copiedMessageLabel:o(`chatMessageCopied`),typingLabel:o(`chatTyping`),attachmentOpenLabel:o(`chatAttachmentOpen`),attachmentAttachedLabel:o(`chatAttachmentAttached`),attachmentCategoryLabels:{archive:o(`chatAttachmentCategoryArchive`),audio:o(`chatAttachmentCategoryAudio`),code:o(`chatAttachmentCategoryCode`),data:o(`chatAttachmentCategoryData`),document:o(`chatAttachmentCategoryDocument`),generic:o(`chatAttachmentCategoryGeneric`),image:o(`chatAttachmentCategoryImage`),pdf:o(`chatAttachmentCategoryPdf`),sheet:o(`chatAttachmentCategorySheet`),video:o(`chatAttachmentCategoryVideo`)}}}function TA({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=mt(),o=(0,k.useMemo)(()=>CA(a),[a]),s=(0,k.useMemo)(()=>e.map(e=>{let t=SA.get(e);if(t&&t.language===a)return t.viewModel;let n=dA(e),r=Fk({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:YD(e.metadata)},parts:n.parts},{formatTimestamp:e=>c(e,a),texts:o});return SA.set(e,{language:a,viewModel:r}),r}),[a,e,o]);return(0,O.jsx)(sE,{messages:s,isSending:t,hasAssistantDraft:(0,k.useMemo)(()=>s.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[s]),className:n,texts:(0,k.useMemo)(()=>wA(a),[a]),onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,O.jsx)(xA,{agentId:e,className:`h-4 w-4 shrink-0`})})}function EA(){let e=de();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{te(e,await le(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),v.success(i??o(`configSavedApplied`))}catch(e){throw v.error(o(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function DA(){let e=EA();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=o(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){Z.getState().setSnapshot({pendingProjectRoot:r,pendingProjectRootSessionKey:i}),v.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function OA({icon:e,label:t,onClick:n,disabled:r=!1,destructive:i=!1}){return(0,O.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,i?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:r,children:[(0,O.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,O.jsx)(`span`,{children:t})]})}function kA(e){return h({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>re({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var AA=k.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsx)(`div`,{ref:r,className:u(`overflow-auto`,e),...n,children:t}));AA.displayName=`ScrollArea`;function jA({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:s,pathLabel:c,pathPlaceholder:l,confirmLabel:u,hint:f}){let[p,m]=(0,k.useState)(``),[h,g]=(0,k.useState)(null),[v,y]=(0,k.useState)(``);(0,k.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;m(n??``),g(n),y(``)},[t,e]);let b=kA({path:h,enabled:e});(0,k.useEffect)(()=>{!e||!b.data||p.trim().length===0&&m(b.data.currentPath)},[b.data,p,e]);let x=p.trim(),S=x.length===0||n,C=(0,k.useMemo)(()=>b.error?b.error instanceof Error?b.error.message:String(b.error):null,[b.error]),w=v.trim().toLowerCase(),T=(0,k.useMemo)(()=>{let e=b.data?.entries??[];return w.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(w)||n.includes(w)})},[b.data?.entries,w]),E=e=>{g(e),y(``),e&&m(e)};return(0,O.jsx)(_e,{open:e,onOpenChange:e=>{n||r(e)},children:(0,O.jsxs)(me,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,O.jsxs)(fe,{children:[(0,O.jsx)(he,{children:a}),s?(0,O.jsx)(ge,{children:s}):null]}),(0,O.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!S&&i(x)},children:[(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(_,{htmlFor:`server-path-picker-input`,children:c}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(ee,{id:`server-path-picker-input`,value:p,onChange:e=>m(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,O.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>E(x||null),disabled:n,children:o(`openPath`)})]})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,O.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(b.data?.homePath??null),disabled:n||b.isLoading,children:[(0,O.jsx)(on,{className:`mr-1 h-4 w-4`}),o(`homeDirectory`)]}),(0,O.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(b.data?.parentPath??null),disabled:!b.data?.parentPath||n||b.isLoading,children:[(0,O.jsx)(tn,{className:`mr-1 h-4 w-4`}),o(`parentDirectory`)]}),(0,O.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{b.refetch()},disabled:n||b.isLoading,children:[(0,O.jsx)(ct,{className:`mr-1 h-4 w-4`}),o(`chatRefresh`)]})]}),(0,O.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,O.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:o(`currentDirectory`)}),(0,O.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:b.data?.breadcrumbs.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>E(e.path),disabled:n,children:e.label}),t<b.data.breadcrumbs.length-1?(0,O.jsx)(zt,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,O.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(Me,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,O.jsx)(ee,{value:v,onChange:e=>y(e.target.value),placeholder:o(`pathPickerSearchPlaceholder`),disabled:n||b.isLoading,className:`pl-9`})]})}),(0,O.jsx)(AA,{className:`min-h-0 flex-1 px-2 py-2`,children:b.isLoading?(0,O.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`loading`)}):C?(0,O.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[o(`pathBrowseFailed`),`: `,C]}):b.data&&T.length>0?(0,O.jsx)(`div`,{className:`space-y-1`,children:T.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>E(e.path),disabled:n,children:[(0,O.jsx)(rt,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):b.data&&b.data.entries.length>0?(0,O.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`pathPickerSearchEmpty`)}):(0,O.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`emptyDirectory`)})})]}),f?(0,O.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:f}):null,(0,O.jsxs)(pe,{children:[(0,O.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:o(`cancel`)}),(0,O.jsx)(d,{type:`submit`,disabled:S,children:n?o(`saving`):u})]})]})]})})}function MA({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,O.jsx)(jA,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:o(`chatSessionProjectDialogTitle`),description:o(`chatSessionProjectDialogDescription`),pathLabel:o(`chatSessionProjectPathLabel`),pathPlaceholder:o(`chatSessionProjectPathPlaceholder`),confirmLabel:o(`chatSessionSetProject`),hint:o(`chatSessionProjectUpdateHint`)})}function NA({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,onOpenChildSessions:a,onDeleteSession:s}){let c=DA(),[l,u]=(0,k.useState)(!1),[f,p]=(0,k.useState)(!1),[m,h]=(0,k.useState)(!1),g=n||m,_=async n=>{let r=t;h(!0);try{await c({sessionKey:e,projectRoot:n,persistToServer:r}),p(!1),u(!1)}finally{h(!1)}};return(0,O.jsxs)(O.Fragment,{children:[i>0&&a?(0,O.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`rounded-lg shrink-0 text-gray-400 hover:text-gray-700`,"aria-label":o(`chatSessionOpenChildSessions`),title:o(`chatSessionOpenChildSessions`),onClick:a,disabled:g,children:(0,O.jsx)(rn,{className:`h-4 w-4`})}):null,(0,O.jsxs)(wt,{open:l,onOpenChange:u,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{variant:`ghost`,size:`icon`,className:`rounded-lg shrink-0 text-gray-400 hover:text-gray-700`,"aria-label":o(`chatSessionMoreActions`),disabled:g,children:(0,O.jsx)(Ht,{className:`h-4 w-4`})})}),(0,O.jsx)(bt,{align:`end`,className:`w-56 p-2`,children:(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(OA,{icon:$t,label:o(`chatSessionSetProject`),onClick:()=>{u(!1),p(!0)},disabled:g}),(0,O.jsx)(OA,{icon:dt,label:o(`chatDeleteSession`),onClick:()=>{u(!1),s()},disabled:!t||g,destructive:!0})]})})]}),(0,O.jsx)(MA,{open:f,currentProjectRoot:r,isSaving:m,onOpenChange:p,onSave:_})]})}function PA({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=DA(),[a,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(!1),[u,d]=(0,k.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),l(!1),s(!1)}finally{d(!1)}};return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(wt,{open:a,onOpenChange:s,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-gray-200 bg-gray-100/90 px-2 py-0.5 text-[11px] font-medium text-gray-600 transition-colors hover:border-gray-300 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":o(`chatSessionSetProject`),disabled:u,children:(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)($t,{className:`h-3.5 w-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:`truncate`,children:t}),(0,O.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,O.jsxs)(bt,{align:`start`,className:`w-72 p-2`,children:[(0,O.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,O.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-500`,children:t}),n?(0,O.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(OA,{icon:un,label:o(`chatSessionSetProject`),onClick:()=>{s(!1),l(!0)},disabled:u}),(0,O.jsx)(OA,{icon:nn,label:o(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,O.jsx)(MA,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}function FA({parentSessionLabel:e,onGoToParentSession:t}){if(!e)return null;let n=e.trim();return(0,O.jsx)(`div`,{className:`border-b border-gray-200/60 bg-white/75 px-4 py-2 backdrop-blur-sm sm:px-5`,children:(0,O.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,children:[(0,O.jsx)(je,{className:`h-3.5 w-3.5`}),(0,O.jsxs)(`span`,{children:[o(`chatBackToParent`),n?` · ${n}`:``]})]})})}function IA({snapshot:e,childSessionCount:t,layoutMode:n,normalizedAgentId:r,sessionHeaderTitle:i,shouldShowHeaderAgentAvatar:a,shouldShowSessionHeader:s,onBackToList:c,onOpenChildSessions:l,onDeleteSession:d}){let f=n===`mobile`;return(0,O.jsxs)(`div`,{className:u(`border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-all duration-200`,f?`px-3 sm:px-3`:`px-4 sm:px-5`,s?`opacity-100`:`h-0 py-0 opacity-0 border-b-0`,s&&(f?`pb-2 pt-2`:`py-3`)),style:f&&s?{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.5rem)`}:void 0,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[f&&c?(0,O.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":o(`chat`),children:(0,O.jsx)(je,{className:`h-4 w-4`})}):null,a?(0,O.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,O.jsx)(In,{agentId:r,displayName:e.agentDisplayName,avatarUrl:e.agentAvatarUrl,className:`h-5 w-5`})}):null,(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:i}),e.sessionTypeLabel?(0,O.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:[e.sessionTypeIcon?.src?(0,O.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center`,children:(0,O.jsx)(On,{icon:{kind:`runtime-image`,src:e.sessionTypeIcon.src,alt:e.sessionTypeIcon.alt??null,name:e.sessionTypeLabel}})}):null,e.sessionTypeLabel]}):null,e.sessionProjectName?(0,O.jsx)(PA,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,O.jsx)(NA,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,onOpenChildSessions:l,onDeleteSession:d}):null]})}var LA=`native`;function RA(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:LA}function zA(e,t=LA){return RA(e?.runtime?.trim()||e?.engine?.trim()||t)}function BA(e,t){return e===`native`?o(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function VA(e){let t=new Map;for(let n of e){let e=RA(n.value);t.set(e,{value:e,label:n.label?.trim()||BA(e),icon:n.icon??null,ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(LA,{value:LA,label:BA(LA),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function HA(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,k.useMemo)(()=>VA(i?.options??[]),[i?.options]),s=(0,k.useMemo)(()=>{let e=[...a],n=RA(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:BA(n),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[a,t?.sessionType]),c=(0,k.useMemo)(()=>RA(i?.defaultType??`native`),[i?.defaultType]),l=(0,k.useRef)(null),u=(0,k.useMemo)(()=>RA(t?.sessionType??n??c),[c,n,t?.sessionType]),d=(0,k.useMemo)(()=>s.find(e=>e.value===u)??null,[u,s]);(0,k.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=RA(n);(e.length===0||l.current===i||l.current===null&&i===`native`)&&(l.current=c,i!==c&&r(c))},[c,n,t,r]);let f=!t||!!t.sessionTypeMutable,p=(0,k.useMemo)(()=>new Set(a.map(e=>e.value)),[a]);return{sessionTypeOptions:s,selectedSessionTypeOption:d,defaultSessionType:c,selectedSessionType:u,canEditSessionType:f,sessionTypeUnavailable:(0,k.useMemo)(()=>t&&!p.has(RA(t.sessionType))?!0:d?.ready===!1,[p,t,d?.ready]),sessionTypeUnavailableMessage:(0,k.useMemo)(()=>t&&!p.has(RA(t.sessionType))?`${BA(u)} ${o(`chatSessionTypeUnavailableSuffix`)}`:d?.ready===!1?d.reasonMessage?.trim()||`${d.label} setup required`:null,[p,t,u,d])}}var UA={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,sessionTypeIcon:null,sessionKey:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,availableAgents:[],sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null},WA=S(e=>({snapshot:UA,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))})),GA=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function KA(){return(0,O.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,O.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,O.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsx)(Ft,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,O.jsx)(`div`,{className:`space-y-5`,children:GA.map(e=>(0,O.jsx)(`div`,{className:u(`flex w-full`,e.alignmentClassName),children:(0,O.jsx)(Ft,{"data-testid":`chat-conversation-skeleton-bubble`,className:u(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,O.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(Ft,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,O.jsx)(Ft,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,O.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,O.jsx)(Ft,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,O.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,O.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,O.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,O.jsx)(Ft,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(Ft,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,O.jsx)(Ft,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,O.jsx)(Ft,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,O.jsx)(Ft,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function qA({shouldShowProviderHint:e,sessionTypeUnavailable:t,sessionTypeUnavailableMessage:n,onGoToProviders:r}){return(0,O.jsxs)(O.Fragment,{children:[e?(0,O.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,O.jsx)(`span`,{className:`text-xs text-amber-800`,children:o(`chatModelNoOptions`)}),(0,O.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:o(`chatGoConfigureProvider`)})]}):null,t&&n?.trim()?(0,O.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,O.jsx)(`span`,{className:`text-xs text-amber-800`,children:n})}):null]})}function JA({snapshot:e,availableAgents:t,hideEmptyHint:n,showWelcome:r,threadRef:i,onScroll:a,onCreateSession:s,onSelectAgent:c,onToolAction:l,onFileOpen:u}){return(0,O.jsx)(`div`,{ref:i,onScroll:a,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:r?(0,O.jsx)(Hn,{onCreateSession:s,agents:t,selectedAgentId:e.agentId??`main`,onSelectAgent:c}):n?null:e.messages.length===0?(0,O.jsx)(`div`,{className:`px-4 py-4 text-sm text-gray-500 sm:px-5 sm:py-5`,children:o(`chatNoMessages`)}):(0,O.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,O.jsx)(TA,{messages:e.messages,isSending:e.isSending&&e.isAwaitingAssistantOutput,onToolAction:l,onFileOpen:u},e.sessionKey??`draft`)})})}function YA(e,t,n){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0:!1}function XA({layoutMode:e=`desktop`,onBackToList:t}){let n=oD(),r=Z(e=>e.snapshot.defaultSessionType),i=WA(e=>e.snapshot),a=(0,k.useRef)(null),s=i.threadRef??a,c=i.childSessionTabs.filter(e=>e.parentSessionKey===i.sessionKey),l=i.workspaceFileTabs.filter(e=>e.parentSessionKey===i.sessionKey),u=YA(i,c,l),d=!!(i.sessionKey||i.sessionTypeLabel),f=i.sessionDisplayName||(i.canDeleteSession&&i.sessionKey?i.sessionKey:null)||o(`chatSidebarNewTask`),p=i.agentId?.trim()??``,m=p.length>0&&p.toLowerCase()!==`main`,h=!i.canDeleteSession&&i.messages.length===0&&!i.isSending,g=i.modelOptions.length>0,_=i.isProviderStateResolved&&!g,v=i.isHistoryLoading&&i.messages.length===0&&!i.isSending&&!i.isAwaitingAssistantOutput,y=i.availableAgents??[],b=e=>y.find(t=>t.id===e)??null,x=()=>{let e=zA(b(i.agentId??`main`),r);n.chatSessionListManager.createSession(e)},S=e=>{n.chatSessionListManager.setSelectedAgentId(e),n.chatInputManager.setPendingSessionType(zA(b(e),r))},C=e=>{n.chatThreadManager.openFilePreview(e)},w=()=>{i.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:i.sessionKey,activeChildSessionKey:c[0]?.sessionKey??null})},{onScroll:T}=$w({scrollRef:s,resetKey:i.sessionKey,isLoading:i.isHistoryLoading,hasContent:i.messages.length>0,contentVersion:i.messages[i.messages.length-1]??null});return i.isProviderStateResolved?(0,O.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(FA,{parentSessionLabel:i.parentSessionKey?i.parentSessionLabel??null:null,onGoToParentSession:n.chatThreadManager.goToParentSession}),(0,O.jsx)(IA,{snapshot:i,childSessionCount:c.length,layoutMode:e,normalizedAgentId:p,sessionHeaderTitle:f,shouldShowHeaderAgentAvatar:m,shouldShowSessionHeader:d,onBackToList:t,onOpenChildSessions:w,onDeleteSession:n.chatThreadManager.deleteSession}),(0,O.jsx)(qA,{shouldShowProviderHint:_,sessionTypeUnavailable:i.sessionTypeUnavailable,sessionTypeUnavailableMessage:i.sessionTypeUnavailableMessage??null,onGoToProviders:n.chatThreadManager.goToProviders}),(0,O.jsx)(JA,{snapshot:i,availableAgents:y,hideEmptyHint:v,showWelcome:h,threadRef:s,onScroll:T,onCreateSession:x,onSelectAgent:S,onToolAction:n.chatThreadManager.openSessionFromToolAction,onFileOpen:C}),(0,O.jsx)(FD,{})]}),u?(0,O.jsx)(DM,{childSessionTabs:c,activeChildSessionKey:i.activeChildSessionKey??null,workspaceFileTabs:l,activeWorkspaceFileKey:i.activeWorkspaceFileKey??null,sessionProjectRoot:i.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`,onSelectSession:n.chatThreadManager.selectChildSessionDetail,onSelectFile:n.chatThreadManager.selectWorkspaceFile,onCloseFile:n.chatThreadManager.closeWorkspaceFile,onClose:n.chatThreadManager.closeWorkspacePanel,onBackToParent:n.chatThreadManager.goToParentSession,onToolAction:n.chatThreadManager.openSessionFromToolAction,onFileOpen:C}):null]}):(0,O.jsx)(KA,{})}var ZA={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function QA({status:e,className:t}){let n=ZA[e],r=o(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,O.jsx)(Mt,{delayDuration:250,children:(0,O.jsxs)(Pt,{children:[(0,O.jsx)(Ot,{asChild:!0,children:(0,O.jsx)(`span`,{role:`status`,"aria-label":r,className:u(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,O.jsx)(ot,{className:u(`h-3 w-3 animate-spin`,n.dotClass)}):(0,O.jsx)(`span`,{className:u(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,O.jsx)(At,{side:`bottom`,className:`text-xs`,children:r})]})})}function $A(){let e=EA();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:o(`configSavedApplied`)})}}function ej(){let e=$A(),[t,n]=(0,k.useState)(null),[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function tj(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function nj(e){return e.trim().toLowerCase()}function rj(e,t){let n=nj(t);return n?[e.key,tj(e),e.projectRoot??``,e.projectName??``].map(nj).some(e=>e.includes(n)):!0}function ij(e,t){let n=e?.trim();if(!n)return!1;let r=t?.trim();return r?n.localeCompare(r)>0:!1}function aj(e){let{active:t,readAt:n,runStatus:r,lastMessageAt:i}=e;return t||r===`running`?!1:ij(i,n)}var oj={selectedSessionKey:null,draftSessionKey:mA(),selectedAgentId:`main`,query:``,listMode:`time-first`};function sj(e){return t=>e(e=>({snapshot:{...e.snapshot,...t}}))}function cj(e){return(t,n)=>e(e=>{let r=t.trim(),i=n?.trim();if(!r||!i)return e;let a=e.optimisticReadAtBySessionKey[r];return a&&a.localeCompare(i)>=0?e:{...e,optimisticReadAtBySessionKey:{...e.optimisticReadAtBySessionKey,[r]:i}}})}var lj=S(e=>({snapshot:oj,optimisticReadAtBySessionKey:{},setSnapshot:sj(e),markSessionRead:cj(e)}));function uj(e,t){return e.filter(e=>rj(e,t))}function dj(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function fj(e={}){let t=lj(e=>e.snapshot.query),n=gt({limit:e.limit??200}),r=(0,k.useMemo)(()=>{let e=n.data?.sessions??[],r=uj(pA(e).filter(dj),t),i=new Map(e.map(e=>[e.sessionId,e]));return r.map(e=>({session:e,runStatus:i.get(e.key)?.status===`running`?`running`:void 0}))},[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function pj(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,O.jsx)(Bn,{session:g,active:y,showUnreadDot:aj({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:wn(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function mj(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function hj(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:r,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:s,onQueryChange:c}=e;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`px-4 pb-3`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(d,{variant:`primary`,className:u(`min-w-0 rounded-xl`,r.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{a(!1),s(n)},children:[(0,O.jsx)(st,{className:`mr-2 h-4 w-4`}),o(`chatSidebarNewTask`)]}),r.length>0?(0,O.jsxs)(wt,{open:i,onOpenChange:a,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":o(`chatSessionTypeLabel`),children:(0,O.jsx)(Fe,{className:`h-4 w-4`})})}),(0,O.jsxs)(bt,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:o(`chatSessionTypeLabel`)}),(0,O.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,O.jsx)(An,{option:e,onSelect:()=>{s(e.value),a(!1)}},e.value))})]})]}):null]})}),(0,O.jsx)(`div`,{className:`px-4 pb-3`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(Me,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,O.jsx)(ee,{value:t,onChange:e=>c(e.target.value),placeholder:o(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function gj(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:c,onQueryChange:l}=e,u=mj({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),f=u.length>1;return(0,O.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,O.jsx)(Me,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,O.jsx)(ee,{value:t,onChange:e=>l(e.target.value),placeholder:o(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),f?(0,O.jsxs)(wt,{open:a,onOpenChange:s,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":o(`chatSidebarNewTask`),children:(0,O.jsx)(st,{className:`h-4 w-4`})})}),(0,O.jsxs)(bt,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:o(`chatSidebarNewTask`)}),(0,O.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,O.jsx)(An,{option:e,onSelect:()=>{c(e.value),s(!1)}},e.value))})]})]}):(0,O.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":o(`chatSidebarNewTask`),onClick:()=>c(n),children:(0,O.jsx)(st,{className:`h-4 w-4`})})]})})}function _j(e){return new Date(e.session.updatedAt).getTime()}function vj(e){return[...e].sort((e,t)=>_j(t)-_j(e))}function yj(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],s=[],c=[],l=[];for(let t of e){let{session:e}=t,o=new Date(e.updatedAt).getTime();o>=n?a.push(t):o>=r?s.push(t):o>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:o(`chatSidebarToday`),items:a}),s.length>0&&u.push({label:o(`chatSidebarYesterday`),items:s}),c.length>0&&u.push({label:o(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:o(`chatSidebarOlder`),items:l}),u}function bj(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=_j(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||zk(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:vj(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function xj(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var Sj=[{target:`/cron`,label:()=>o(`chatSidebarScheduledTasks`),icon:ve},{target:`/skills`,label:()=>o(`chatSidebarSkills`),icon:ke},{target:`/agents`,label:()=>o(`agentsPageTitle`),icon:Ae}];function Cj(e,t,n){let r=lj(e=>e.optimisticReadAtBySessionKey);return(0,k.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function wj({variant:e=`desktop`}){let n=e===`mobile`,r=oD(),i=pt(),[a,s]=(0,k.useState)(!1),c=Z(e=>e.snapshot),l=lj(e=>e.snapshot),d=y(),f=hA(),{isLoading:p,items:m}=fj(),{language:h,setLanguage:g}=mt(),{theme:_,setTheme:v}=Ee(),b=o(be.find(e=>e.value===_)?.labelKey??`themeWarm`),x=t.find(e=>e.value===h)?.label??h,S=(0,k.useMemo)(()=>new Map((f.data?.agents??[]).map(e=>[e.id,e])),[f.data?.agents]),C=(0,k.useMemo)(()=>vj(m),[m]),w=(0,k.useMemo)(()=>{let e=new Map;for(let t of m){let n=t.session.parentSessionId?.trim();if(!n)continue;let r=e.get(n)??[];r.push(t),e.set(n,r)}for(let t of e.values())t.sort((e,t)=>_j(t)-_j(e));return e},[m]),T=(0,k.useMemo)(()=>yj(C),[C]),E=(0,k.useMemo)(()=>bj(C),[C]),ee=c.defaultSessionType||`native`,te=(0,k.useMemo)(()=>c.sessionTypeOptions.filter(e=>e.value!==ee),[ee,c.sessionTypeOptions]),ne=l.listMode===`project-first`,re=Cj(m,l.selectedSessionKey,r.chatSessionListManager.markSessionRead),{editingSessionKey:ie,draftLabel:ae,savingSessionKey:oe,setDraftLabel:se,startEditingSessionLabel:ce,cancelEditingSessionLabel:le,saveSessionLabel:ue}=ej(),de=e=>{h!==e&&(g(e),window.location.reload())},fe=e=>(0,O.jsx)(pj,{item:e,selectedSessionKey:l.selectedSessionKey,optimisticReadAtBySessionKey:re,agentsById:S,childSessionsByParentKey:w,editingSessionKey:ie,draftLabel:ae,savingSessionKey:oe,sessionTitle:xj,onSelectSession:r.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>r.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ce,onDraftLabelChange:se,onSaveSessionLabel:ue,onCancelEditingSessionLabel:le},e.session.key);return(0,O.jsxs)(`aside`,{className:u(`flex h-full min-h-0 flex-col bg-secondary`,n?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[n?null:(0,O.jsx)(`div`,{className:`px-5 pt-5 pb-3`,children:(0,O.jsx)(Oe,{className:`flex items-center gap-2.5 min-w-0`,suffix:(0,O.jsx)(QA,{status:d.connectionStatus})})}),n?(0,O.jsx)(gj,{query:l.query,defaultSessionType:ee,sessionTypeOptions:c.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:r.chatSessionListManager.createSession,onQueryChange:r.chatSessionListManager.setQuery}):(0,O.jsx)(hj,{query:l.query,defaultSessionType:ee,sessionTypeOptions:c.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:r.chatSessionListManager.createSession,onQueryChange:r.chatSessionListManager.setQuery}),n?null:(0,O.jsx)(`div`,{className:`px-3 pb-2`,children:(0,O.jsx)(`ul`,{className:`space-y-0.5`,children:Sj.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsx)(ye,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),n?null:(0,O.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,O.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:o(`chatSidebarTaskRecords`)}),(0,O.jsx)(hn,{isProjectFirstView:ne,onSelectMode:r.chatSessionListManager.setListMode})]}),(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:p?(0,O.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:o(`sessionsLoading`)}):ne?E.length===0?(0,O.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,O.jsx)(sn,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500`,children:o(`chatSidebarProjectViewEmpty`)})]}):(0,O.jsx)(Mn,{groups:E,defaultSessionType:ee,sessionTypeOptions:c.sessionTypeOptions,renderSessionItem:fe,onCreateSession:r.chatSessionListManager.createSession}):T.length===0?(0,O.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,O.jsx)(sn,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500`,children:o(`sessionsEmpty`)})]}):(0,O.jsx)(`div`,{className:`space-y-3`,children:T.map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,O.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(fe)})]},e.label))})}),n?null:(0,O.jsxs)(`div`,{className:`px-3 py-3 border-t border-gray-200/60 space-y-0.5`,children:[(0,O.jsx)(ye,{to:`/settings`,label:o(`settings`),icon:lt,density:`compact`}),(0,O.jsx)(De,{onClick:()=>i.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:Ne,label:o(`docBrowserHelp`),density:`compact`}),(0,O.jsx)(we,{value:_,onValueChange:e=>v(e),icon:Te,label:o(`theme`),valueLabel:b,density:`compact`,children:be.map(e=>(0,O.jsx)(Xe,{value:e.value,className:`text-xs`,children:o(e.labelKey)},e.value))}),(0,O.jsx)(we,{value:h,onValueChange:e=>de(e),icon:Se,label:o(`language`),valueLabel:x,density:`compact`,children:t.map(e=>(0,O.jsx)(Xe,{value:e.value,className:`text-xs`,children:e.label},e.value))})]})]})}function Tj({tone:e=`neutral`,value:t}){return(0,O.jsx)(`span`,{className:u(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function Ej({breadcrumb:e}){return(0,O.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,O.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,O.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,O.jsxs)(k.Fragment,{children:[(0,O.jsxs)(`span`,{className:u(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,O.jsx)(en,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,O.jsx)(Gt,{className:`h-3 w-3 shrink-0`}):null,(0,O.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,O.jsx)(zt,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,O.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,O.jsx)(Tj,{value:e.locationLabel}):null,e.truncated?(0,O.jsx)(Tj,{tone:`warning`,value:o(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function Dj(e){let t=e.path?.trim()??``;return h({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>oe({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function Oj(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function kj(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:CO({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function Aj(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=DO({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function jj({text:e,tone:t=`muted`}){return(0,O.jsx)(`div`,{className:u(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function Mj({diffBlock:e}){return e?(0,O.jsx)(Nj,{block:e}):(0,O.jsx)(jj,{text:o(`chatWorkspaceDiffEmpty`)})}function Nj({block:e}){return(0,O.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,O.jsx)(wT,{block:e,layout:`workspace`})})}function Pj({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,O.jsx)(jj,{text:o(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,O.jsx)(jj,{text:o(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,O.jsx)(jj,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,O.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,O.jsx)(mw,{text:i,role:`assistant`,texts:{copyCodeLabel:o(`chatCodeCopy`),copiedCodeLabel:o(`chatCodeCopied`)},onFileOpen:e})}):t?(0,O.jsx)(Nj,{block:t}):(0,O.jsx)(jj,{text:o(`chatWorkspacePreviewEmpty`)})}function Fj({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=Dj({path:e.path,basePath:t,enabled:r}),a=(0,k.useMemo)(()=>e.viewMode===`diff`?Aj(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=Oj({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,k.useMemo)(()=>!r||!o?null:kj({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,O.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,O.jsx)(Ej,{breadcrumb:(0,k.useMemo)(()=>Kk({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,O.jsx)(Mj,{diffBlock:a}):(0,O.jsx)(Pj,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}function Ij(e,t){return e.label?.trim()?e.label.trim():t?tj(t):e.sessionKey}function Lj(e){let t=gt({limit:200}),n=(0,k.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,k.useMemo)(()=>{let e=pA(n);return new Map(e.map(e=>[e.key,e]))},[n]),i=(0,k.useMemo)(()=>new Map(n.map(e=>[e.sessionId,e])),[n]);return(0,k.useMemo)(()=>e.map(e=>{let t=r.get(e.sessionKey)??null,n=i.get(e.sessionKey)??null,a=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:Ij(e,t),agentId:a,updatedAt:t?.updatedAt??null,lastMessageAt:t?.lastMessageAt??null,readAt:t?.readAt??null,runStatus:n?.status===`running`?`running`:void 0,sessionTypeLabel:t?.sessionType?BA(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,i,e])}function Rj(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
57
+ `):void 0}function Sk(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`&&r!==`sessions_spawn`)return null;let s=mk(o);if(s){let e=$(s.status)?.toLowerCase(),t=vk(s,a),o=bk(s),c=$(s.sessionId),l=gO({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...$(s.title)?{label:s.title.trim()}:{},...$(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:_k(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:e===`completed`?{kind:`result`,name:r,detail:t,input:_k(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:{kind:`result`,name:r,detail:t,input:_k(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=hk(o);if(!c)return null;let l=yk(c,a),u=xk(c),d=$(c.sessionId),f=gO({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...$(c.title)?{label:c.title.trim()}:{},...$(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:_k(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function Ck(e,t){let n=nO(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function wk(e,t){let n=e.mimeType.startsWith(`image/`),r=aO(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function Tk(e,t){let n=e.toolInvocation,r=sO(n.result,t);if(r)return r;let i=Sk({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:cO(i,t)};let a=lO({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=fk({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),s=o?.summary??HD(n.parsedArgs??n.args),c=o?void 0:dO(n.args,n.parsedArgs),l=typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:BD(n.result).trim(),u=!n.error&&oO(n.result),d=(!o?.fileOperation||!!n.error)&&!u,f=gO(n);return{type:`tool-card`,card:cO({kind:a.kind,name:n.toolName,...f?{agentId:f}:{},detail:s,...c?{input:c}:{},text:d&&l?l:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel,...o?.fileOperation?{fileOperation:o.fileOperation}:{}},t)}}function Ek(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:BD(e)}}function Dk(e){return e.type===`text`&&typeof e.text==`string`}function Ok(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function kk(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function Ak(e){return e.type!==`tool-invocation`||typeof e.toolInvocation!=`object`||e.toolInvocation===null||Array.isArray(e.toolInvocation)?!1:`toolName`in e.toolInvocation&&typeof e.toolInvocation.toolName==`string`}function jk(e){return Dk(e.part)?tO(e.part,e.inlineTokens):Ok(e.part)?Ck(e.part,e.texts):kk(e.part)?wk(e.part,e.texts):Ak(e.part)?Tk(e.part,e.texts):Ek(e.part,e.texts)}function Mk(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function Nk(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function Pk(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function Fk(e,t){return{id:e.id,role:Pk(e.role),roleLabel:Nk(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(Mk(e)),status:e.meta?.status,parts:e.parts.map(n=>jk({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var Ik=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function Lk(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Rk(e){return Lk(e)}function zk(e){let t=Lk(e);if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return t;let r=n.split(/[\\/]/).filter(Boolean);return r[r.length-1]??n}function Bk(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function Vk(e){let t=Bk(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function Hk(e){let t=e.trim().replace(/\\/g,`/`);return t?/^[A-Za-z]:\//.test(t)?{prefix:t.slice(0,2),segments:t.slice(3).split(`/`).filter(Boolean)}:t.startsWith(`/`)?{prefix:`/`,segments:t.slice(1).split(`/`).filter(Boolean)}:{prefix:null,segments:t.split(`/`).filter(Boolean)}:{prefix:null,segments:[]}}function Uk(e){let t=Vk(e.path),n=Vk(e.sessionProjectRoot);if(!t||!n)return null;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.split(`/`).filter(Boolean);if(t===n)return[];let r=n.endsWith(`/`)?n:`${n}/`;return t.startsWith(r)?t.slice(r.length).split(`/`).filter(Boolean):null}function Wk(e){let{labels:t,leading:n=null}=e,r=t.map((e,n)=>({key:`${n}:${e}`,label:e,kind:n===t.length-1?`file`:`directory`,isCurrent:n===t.length-1}));return n?[n,...r]:r}function Gk(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function Kk(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?Uk({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=zk(i)??i.trim();c=Wk({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=Hk(o);c=Wk({labels:t,leading:e?{key:`root:${e}`,label:e,kind:`root`,isCurrent:t.length===0}:null})}return c.length===0&&(c=[{key:`file:unknown`,label:o||`file`,kind:`file`,isCurrent:!0}]),{fullPath:o,locationLabel:Gk({line:n,column:t}),truncated:a,segments:c}}var qk=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function Jk(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function Yk(e){return`${se}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function Xk(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Zk(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function Qk(e){let t=Zk(e);return t?Xk(t.preferred_model)??Xk(t.preferredModel)??Xk(t.model):null}function $k(e){let t=Zk(e);if(!t)return null;let n=Xk(t.preferred_thinking)??Xk(t.thinking)??Xk(t.thinking_level)??Xk(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return qk.has(r)?r:null}function eA(e){let t=Zk(e);return t?Xk(t.label):null}function tA(e){let t=Zk(e);return t?Rk(t.project_root??t.projectRoot):null}function nA(e){let t=Zk(e);return t?Xk(t.ui_last_read_at):null}function rA(e){let t=Zk(e);return t?Xk(t.runtime)??Xk(t.session_type)??Xk(t.sessionType)??`native`:`native`}function iA(e){let t=Zk(e);return t?Xk(t.parent_session_id)??Xk(t.parentSessionId):null}function aA(e){let t=Zk(e);return t?Xk(t.spawned_by_request_id)??Xk(t.spawnedByRequestId):null}function oA(e){let t=Zk(e);return t?t.child_session_promoted===!0:!1}function sA(e){if(e===`heartbeat`)return{type:`heartbeat`};if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function cA(e){return e.state===`cancelled`?Ik.CANCELLED:e.state===`result`?Ik.RESULT:e.state===`partial-call`?Ik.PARTIAL_CALL:Ik.CALL}function lA(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.assetUri){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:Yk(n.assetUri),...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:cA(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:Jk(n.args),result:n.result}})}return t}function uA(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function dA(e){return{id:e.id,role:uA(e.role),parts:lA(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function fA(e){let t=eA(e),n=Qk(e),r=$k(e),i=tA(e),a=nA(e),o=Xk(e.lastMessageAt),s=zk(i),c=sA(e.sessionId),l=iA(e),u=aA(e),d=oA(e);return{key:e.sessionId,createdAt:e.updatedAt,updatedAt:e.updatedAt,...o?{lastMessageAt:o}:{},...a?{readAt:a}:{},...typeof e.agentId==`string`&&e.agentId.trim().length>0?{agentId:e.agentId.trim()}:{},...t?{label:t}:{},...c,...n?{preferredModel:n}:{},...r?{preferredThinking:r}:{},...i?{projectRoot:i}:{},...s?{projectName:s}:{},sessionType:rA(e),sessionTypeMutable:!1,isChildSession:!!l,...d?{isPromotedChildSession:d}:{},...l?{parentSessionId:l}:{},...u?{spawnedByRequestId:u}:{},messageCount:e.messageCount}}function pA(e){return e.map(fA)}function mA(){return`ncp-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function hA(){return h({queryKey:[`agents`],queryFn:ie,staleTime:3e4})}function gA(){let e=de();return f({mutationFn:({data:e})=>T(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),v.success(o(`configSavedApplied`))},onError:e=>{v.error(o(`configSaveFailed`)+`: `+e.message)}})}function _A(){let e=de();return f({mutationFn:({agentId:e,data:t})=>ce(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),v.success(o(`configSavedApplied`))},onError:e=>{v.error(o(`configSaveFailed`)+`: `+e.message)}})}function vA(){let e=de();return f({mutationFn:({agentId:e})=>b(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),v.success(o(`configSavedApplied`))},onError:e=>{v.error(o(`configSaveFailed`)+`: `+e.message)}})}function yA(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function bA(e){let t=e?.trim()??``,n=WA(e=>e.snapshot.availableAgents??[]),r=hA(),i=(0,k.useMemo)(()=>yA(n,r.data?.agents??[]),[r.data?.agents,n]);return(0,k.useMemo)(()=>{if(!t)return null;let e=i.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[i,t])}function xA({agentId:e,className:t}){let n=bA(e);return n?(0,O.jsx)(In,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var SA=new WeakMap;function CA(e){return{roleLabels:{user:o(`chatRoleUser`),assistant:o(`chatRoleAssistant`),tool:o(`chatRoleTool`),system:o(`chatRoleSystem`),fallback:o(`chatRoleMessage`)},reasoningLabel:o(`chatReasoning`),toolCallLabel:o(`chatToolCall`),toolResultLabel:o(`chatToolResult`),toolInputLabel:o(`chatToolInput`),toolNoOutputLabel:o(`chatToolNoOutput`),toolOutputLabel:o(`chatToolOutput`),toolStatusPreparingLabel:o(`chatToolStatusPreparing`),toolStatusRunningLabel:o(`chatToolStatusRunning`),toolStatusCompletedLabel:o(`chatToolStatusCompleted`),toolStatusFailedLabel:o(`chatToolStatusFailed`),toolStatusCancelledLabel:o(`chatToolStatusCancelled`),imageAttachmentLabel:o(`chatImageAttachment`),fileAttachmentLabel:o(`chatFileAttachment`),unknownPartLabel:o(`chatUnknownPart`)}}function wA(e){return{copyCodeLabel:o(`chatCodeCopy`),copiedCodeLabel:o(`chatCodeCopied`),copyMessageLabel:o(`chatMessageCopy`),copiedMessageLabel:o(`chatMessageCopied`),typingLabel:o(`chatTyping`),attachmentOpenLabel:o(`chatAttachmentOpen`),attachmentAttachedLabel:o(`chatAttachmentAttached`),attachmentCategoryLabels:{archive:o(`chatAttachmentCategoryArchive`),audio:o(`chatAttachmentCategoryAudio`),code:o(`chatAttachmentCategoryCode`),data:o(`chatAttachmentCategoryData`),document:o(`chatAttachmentCategoryDocument`),generic:o(`chatAttachmentCategoryGeneric`),image:o(`chatAttachmentCategoryImage`),pdf:o(`chatAttachmentCategoryPdf`),sheet:o(`chatAttachmentCategorySheet`),video:o(`chatAttachmentCategoryVideo`)}}}function TA({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=mt(),o=(0,k.useMemo)(()=>CA(a),[a]),s=(0,k.useMemo)(()=>e.map(e=>{let t=SA.get(e);if(t&&t.language===a)return t.viewModel;let n=dA(e),r=Fk({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:YD(e.metadata)},parts:n.parts},{formatTimestamp:e=>c(e,a),texts:o});return SA.set(e,{language:a,viewModel:r}),r}),[a,e,o]);return(0,O.jsx)(sE,{messages:s,isSending:t,hasAssistantDraft:(0,k.useMemo)(()=>s.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[s]),className:n,texts:(0,k.useMemo)(()=>wA(a),[a]),onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,O.jsx)(xA,{agentId:e,className:`h-4 w-4 shrink-0`})})}function EA(){let e=de();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{te(e,await le(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),v.success(i??o(`configSavedApplied`))}catch(e){throw v.error(o(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function DA(){let e=EA();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=o(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){Z.getState().setSnapshot({pendingProjectRoot:r,pendingProjectRootSessionKey:i}),v.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function OA({icon:e,label:t,onClick:n,disabled:r=!1,destructive:i=!1}){return(0,O.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,i?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:r,children:[(0,O.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,O.jsx)(`span`,{children:t})]})}function kA(e){return h({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>re({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var AA=k.forwardRef(({className:e,children:t,...n},r)=>(0,O.jsx)(`div`,{ref:r,className:u(`overflow-auto`,e),...n,children:t}));AA.displayName=`ScrollArea`;function jA({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:s,pathLabel:c,pathPlaceholder:l,confirmLabel:u,hint:f}){let[p,m]=(0,k.useState)(``),[h,g]=(0,k.useState)(null),[v,y]=(0,k.useState)(``);(0,k.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;m(n??``),g(n),y(``)},[t,e]);let b=kA({path:h,enabled:e});(0,k.useEffect)(()=>{!e||!b.data||p.trim().length===0&&m(b.data.currentPath)},[b.data,p,e]);let x=p.trim(),S=x.length===0||n,C=(0,k.useMemo)(()=>b.error?b.error instanceof Error?b.error.message:String(b.error):null,[b.error]),w=v.trim().toLowerCase(),T=(0,k.useMemo)(()=>{let e=b.data?.entries??[];return w.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(w)||n.includes(w)})},[b.data?.entries,w]),E=e=>{g(e),y(``),e&&m(e)};return(0,O.jsx)(_e,{open:e,onOpenChange:e=>{n||r(e)},children:(0,O.jsxs)(me,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,O.jsxs)(fe,{children:[(0,O.jsx)(he,{children:a}),s?(0,O.jsx)(ge,{children:s}):null]}),(0,O.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!S&&i(x)},children:[(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(_,{htmlFor:`server-path-picker-input`,children:c}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(ee,{id:`server-path-picker-input`,value:p,onChange:e=>m(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,O.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>E(x||null),disabled:n,children:o(`openPath`)})]})]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,O.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(b.data?.homePath??null),disabled:n||b.isLoading,children:[(0,O.jsx)(on,{className:`mr-1 h-4 w-4`}),o(`homeDirectory`)]}),(0,O.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(b.data?.parentPath??null),disabled:!b.data?.parentPath||n||b.isLoading,children:[(0,O.jsx)(tn,{className:`mr-1 h-4 w-4`}),o(`parentDirectory`)]}),(0,O.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{b.refetch()},disabled:n||b.isLoading,children:[(0,O.jsx)(ct,{className:`mr-1 h-4 w-4`}),o(`chatRefresh`)]})]}),(0,O.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,O.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:o(`currentDirectory`)}),(0,O.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:b.data?.breadcrumbs.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>E(e.path),disabled:n,children:e.label}),t<b.data.breadcrumbs.length-1?(0,O.jsx)(zt,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,O.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(Me,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,O.jsx)(ee,{value:v,onChange:e=>y(e.target.value),placeholder:o(`pathPickerSearchPlaceholder`),disabled:n||b.isLoading,className:`pl-9`})]})}),(0,O.jsx)(AA,{className:`min-h-0 flex-1 px-2 py-2`,children:b.isLoading?(0,O.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`loading`)}):C?(0,O.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[o(`pathBrowseFailed`),`: `,C]}):b.data&&T.length>0?(0,O.jsx)(`div`,{className:`space-y-1`,children:T.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>E(e.path),disabled:n,children:[(0,O.jsx)(rt,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):b.data&&b.data.entries.length>0?(0,O.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`pathPickerSearchEmpty`)}):(0,O.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`emptyDirectory`)})})]}),f?(0,O.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:f}):null,(0,O.jsxs)(pe,{children:[(0,O.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:o(`cancel`)}),(0,O.jsx)(d,{type:`submit`,disabled:S,children:n?o(`saving`):u})]})]})]})})}function MA({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,O.jsx)(jA,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:o(`chatSessionProjectDialogTitle`),description:o(`chatSessionProjectDialogDescription`),pathLabel:o(`chatSessionProjectPathLabel`),pathPlaceholder:o(`chatSessionProjectPathPlaceholder`),confirmLabel:o(`chatSessionSetProject`),hint:o(`chatSessionProjectUpdateHint`)})}function NA({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,onOpenChildSessions:a,onDeleteSession:s}){let c=DA(),[l,u]=(0,k.useState)(!1),[f,p]=(0,k.useState)(!1),[m,h]=(0,k.useState)(!1),g=n||m,_=async n=>{let r=t;h(!0);try{await c({sessionKey:e,projectRoot:n,persistToServer:r}),p(!1),u(!1)}finally{h(!1)}};return(0,O.jsxs)(O.Fragment,{children:[i>0&&a?(0,O.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`rounded-lg shrink-0 text-gray-400 hover:text-gray-700`,"aria-label":o(`chatSessionOpenChildSessions`),title:o(`chatSessionOpenChildSessions`),onClick:a,disabled:g,children:(0,O.jsx)(rn,{className:`h-4 w-4`})}):null,(0,O.jsxs)(wt,{open:l,onOpenChange:u,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{variant:`ghost`,size:`icon`,className:`rounded-lg shrink-0 text-gray-400 hover:text-gray-700`,"aria-label":o(`chatSessionMoreActions`),disabled:g,children:(0,O.jsx)(Ht,{className:`h-4 w-4`})})}),(0,O.jsx)(bt,{align:`end`,className:`w-56 p-2`,children:(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(OA,{icon:$t,label:o(`chatSessionSetProject`),onClick:()=>{u(!1),p(!0)},disabled:g}),(0,O.jsx)(OA,{icon:dt,label:o(`chatDeleteSession`),onClick:()=>{u(!1),s()},disabled:!t||g,destructive:!0})]})})]}),(0,O.jsx)(MA,{open:f,currentProjectRoot:r,isSaving:m,onOpenChange:p,onSave:_})]})}function PA({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=DA(),[a,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(!1),[u,d]=(0,k.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),l(!1),s(!1)}finally{d(!1)}};return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(wt,{open:a,onOpenChange:s,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-gray-200 bg-gray-100/90 px-2 py-0.5 text-[11px] font-medium text-gray-600 transition-colors hover:border-gray-300 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":o(`chatSessionSetProject`),disabled:u,children:(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)($t,{className:`h-3.5 w-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:`truncate`,children:t}),(0,O.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,O.jsxs)(bt,{align:`start`,className:`w-72 p-2`,children:[(0,O.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,O.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-500`,children:t}),n?(0,O.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(OA,{icon:un,label:o(`chatSessionSetProject`),onClick:()=>{s(!1),l(!0)},disabled:u}),(0,O.jsx)(OA,{icon:nn,label:o(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,O.jsx)(MA,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}function FA({parentSessionLabel:e,onGoToParentSession:t}){if(!e)return null;let n=e.trim();return(0,O.jsx)(`div`,{className:`border-b border-gray-200/60 bg-white/75 px-4 py-2 backdrop-blur-sm sm:px-5`,children:(0,O.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,children:[(0,O.jsx)(je,{className:`h-3.5 w-3.5`}),(0,O.jsxs)(`span`,{children:[o(`chatBackToParent`),n?` · ${n}`:``]})]})})}function IA({snapshot:e,childSessionCount:t,layoutMode:n,normalizedAgentId:r,sessionHeaderTitle:i,shouldShowHeaderAgentAvatar:a,shouldShowSessionHeader:s,onBackToList:c,onOpenChildSessions:l,onDeleteSession:d}){let f=n===`mobile`;return(0,O.jsxs)(`div`,{className:u(`border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-all duration-200`,f?`px-3 sm:px-3`:`px-4 sm:px-5`,s?`opacity-100`:`h-0 py-0 opacity-0 border-b-0`,s&&(f?`pb-2 pt-2`:`py-3`)),style:f&&s?{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.5rem)`}:void 0,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[f&&c?(0,O.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":o(`chat`),children:(0,O.jsx)(je,{className:`h-4 w-4`})}):null,a?(0,O.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,O.jsx)(In,{agentId:r,displayName:e.agentDisplayName,avatarUrl:e.agentAvatarUrl,className:`h-5 w-5`})}):null,(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:i}),e.sessionTypeLabel?(0,O.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:[e.sessionTypeIcon?.src?(0,O.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center`,children:(0,O.jsx)(On,{icon:{kind:`runtime-image`,src:e.sessionTypeIcon.src,alt:e.sessionTypeIcon.alt??null,name:e.sessionTypeLabel}})}):null,e.sessionTypeLabel]}):null,e.sessionProjectName?(0,O.jsx)(PA,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,O.jsx)(NA,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,onOpenChildSessions:l,onDeleteSession:d}):null]})}var LA=`native`;function RA(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:LA}function zA(e,t=LA){return RA(e?.runtime?.trim()||e?.engine?.trim()||t)}function BA(e,t){return e===`native`?o(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function VA(e){let t=new Map;for(let n of e){let e=RA(n.value);t.set(e,{value:e,label:n.label?.trim()||BA(e),icon:n.icon??null,ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(LA,{value:LA,label:BA(LA),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function HA(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,k.useMemo)(()=>VA(i?.options??[]),[i?.options]),s=(0,k.useMemo)(()=>{let e=[...a],n=RA(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:BA(n),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[a,t?.sessionType]),c=(0,k.useMemo)(()=>RA(i?.defaultType??`native`),[i?.defaultType]),l=(0,k.useRef)(null),u=(0,k.useMemo)(()=>RA(t?.sessionType??n??c),[c,n,t?.sessionType]),d=(0,k.useMemo)(()=>s.find(e=>e.value===u)??null,[u,s]);(0,k.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=RA(n);(e.length===0||l.current===i||l.current===null&&i===`native`)&&(l.current=c,i!==c&&r(c))},[c,n,t,r]);let f=!t||!!t.sessionTypeMutable,p=(0,k.useMemo)(()=>new Set(a.map(e=>e.value)),[a]);return{sessionTypeOptions:s,selectedSessionTypeOption:d,defaultSessionType:c,selectedSessionType:u,canEditSessionType:f,sessionTypeUnavailable:(0,k.useMemo)(()=>t&&!p.has(RA(t.sessionType))?!0:d?.ready===!1,[p,t,d?.ready]),sessionTypeUnavailableMessage:(0,k.useMemo)(()=>t&&!p.has(RA(t.sessionType))?`${BA(u)} ${o(`chatSessionTypeUnavailableSuffix`)}`:d?.ready===!1?d.reasonMessage?.trim()||`${d.label} setup required`:null,[p,t,u,d])}}var UA={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,sessionTypeIcon:null,sessionKey:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,availableAgents:[],sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null},WA=S(e=>({snapshot:UA,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))})),GA=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function KA(){return(0,O.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,O.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,O.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsx)(Ft,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,O.jsx)(`div`,{className:`space-y-5`,children:GA.map(e=>(0,O.jsx)(`div`,{className:u(`flex w-full`,e.alignmentClassName),children:(0,O.jsx)(Ft,{"data-testid":`chat-conversation-skeleton-bubble`,className:u(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,O.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(Ft,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,O.jsx)(Ft,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,O.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,O.jsx)(Ft,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,O.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,O.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,O.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,O.jsx)(Ft,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(Ft,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,O.jsx)(Ft,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,O.jsx)(Ft,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,O.jsx)(Ft,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function qA({shouldShowProviderHint:e,sessionTypeUnavailable:t,sessionTypeUnavailableMessage:n,onGoToProviders:r}){return(0,O.jsxs)(O.Fragment,{children:[e?(0,O.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,O.jsx)(`span`,{className:`text-xs text-amber-800`,children:o(`chatModelNoOptions`)}),(0,O.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:o(`chatGoConfigureProvider`)})]}):null,t&&n?.trim()?(0,O.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,O.jsx)(`span`,{className:`text-xs text-amber-800`,children:n})}):null]})}function JA({snapshot:e,availableAgents:t,hideEmptyHint:n,showWelcome:r,threadRef:i,onScroll:a,onCreateSession:s,onSelectAgent:c,onToolAction:l,onFileOpen:u}){return(0,O.jsx)(`div`,{ref:i,onScroll:a,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:r?(0,O.jsx)(Hn,{onCreateSession:s,agents:t,selectedAgentId:e.agentId??`main`,onSelectAgent:c}):n?null:e.messages.length===0?(0,O.jsx)(`div`,{className:`px-4 py-4 text-sm text-gray-500 sm:px-5 sm:py-5`,children:o(`chatNoMessages`)}):(0,O.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,O.jsx)(TA,{messages:e.messages,isSending:e.isSending&&e.isAwaitingAssistantOutput,onToolAction:l,onFileOpen:u},e.sessionKey??`draft`)})})}function YA(e,t,n){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0:!1}function XA({layoutMode:e=`desktop`,onBackToList:t}){let n=oD(),r=Z(e=>e.snapshot.defaultSessionType),i=WA(e=>e.snapshot),a=(0,k.useRef)(null),s=i.threadRef??a,c=i.childSessionTabs.filter(e=>e.parentSessionKey===i.sessionKey),l=i.workspaceFileTabs.filter(e=>e.parentSessionKey===i.sessionKey),u=YA(i,c,l),d=!!(i.sessionKey||i.sessionTypeLabel),f=i.sessionDisplayName||(i.canDeleteSession&&i.sessionKey?i.sessionKey:null)||o(`chatSidebarNewTask`),p=i.agentId?.trim()??``,m=p.length>0&&p.toLowerCase()!==`main`,h=!i.canDeleteSession&&i.messages.length===0&&!i.isSending,g=i.modelOptions.length>0,_=i.isProviderStateResolved&&!g,v=i.isHistoryLoading&&i.messages.length===0&&!i.isSending&&!i.isAwaitingAssistantOutput,y=i.availableAgents??[],b=e=>y.find(t=>t.id===e)??null,x=()=>{let t=zA(b(i.agentId??`main`),r),a=n.chatSessionListManager.createSession(t);e===`mobile`&&n.chatUiManager.goToSession(a)},S=e=>{n.chatSessionListManager.setSelectedAgentId(e),n.chatInputManager.setPendingSessionType(zA(b(e),r))},C=e=>{n.chatThreadManager.openFilePreview(e)},w=()=>{i.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:i.sessionKey,activeChildSessionKey:c[0]?.sessionKey??null})},{onScroll:T}=$w({scrollRef:s,resetKey:i.sessionKey,isLoading:i.isHistoryLoading,hasContent:i.messages.length>0,contentVersion:i.messages[i.messages.length-1]??null});return i.isProviderStateResolved?(0,O.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(FA,{parentSessionLabel:i.parentSessionKey?i.parentSessionLabel??null:null,onGoToParentSession:n.chatThreadManager.goToParentSession}),(0,O.jsx)(IA,{snapshot:i,childSessionCount:c.length,layoutMode:e,normalizedAgentId:p,sessionHeaderTitle:f,shouldShowHeaderAgentAvatar:m,shouldShowSessionHeader:d,onBackToList:t,onOpenChildSessions:w,onDeleteSession:n.chatThreadManager.deleteSession}),(0,O.jsx)(qA,{shouldShowProviderHint:_,sessionTypeUnavailable:i.sessionTypeUnavailable,sessionTypeUnavailableMessage:i.sessionTypeUnavailableMessage??null,onGoToProviders:n.chatThreadManager.goToProviders}),(0,O.jsx)(JA,{snapshot:i,availableAgents:y,hideEmptyHint:v,showWelcome:h,threadRef:s,onScroll:T,onCreateSession:x,onSelectAgent:S,onToolAction:n.chatThreadManager.openSessionFromToolAction,onFileOpen:C}),(0,O.jsx)(FD,{})]}),u?(0,O.jsx)(DM,{childSessionTabs:c,activeChildSessionKey:i.activeChildSessionKey??null,workspaceFileTabs:l,activeWorkspaceFileKey:i.activeWorkspaceFileKey??null,sessionProjectRoot:i.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`,onSelectSession:n.chatThreadManager.selectChildSessionDetail,onSelectFile:n.chatThreadManager.selectWorkspaceFile,onCloseFile:n.chatThreadManager.closeWorkspaceFile,onClose:n.chatThreadManager.closeWorkspacePanel,onBackToParent:n.chatThreadManager.goToParentSession,onToolAction:n.chatThreadManager.openSessionFromToolAction,onFileOpen:C}):null]}):(0,O.jsx)(KA,{})}var ZA={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function QA({status:e,className:t}){let n=ZA[e],r=o(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,O.jsx)(Mt,{delayDuration:250,children:(0,O.jsxs)(Pt,{children:[(0,O.jsx)(Ot,{asChild:!0,children:(0,O.jsx)(`span`,{role:`status`,"aria-label":r,className:u(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,O.jsx)(ot,{className:u(`h-3 w-3 animate-spin`,n.dotClass)}):(0,O.jsx)(`span`,{className:u(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,O.jsx)(At,{side:`bottom`,className:`text-xs`,children:r})]})})}function $A(){let e=EA();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:o(`configSavedApplied`)})}}function ej(){let e=$A(),[t,n]=(0,k.useState)(null),[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function tj(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function nj(e){return e.trim().toLowerCase()}function rj(e,t){let n=nj(t);return n?[e.key,tj(e),e.projectRoot??``,e.projectName??``].map(nj).some(e=>e.includes(n)):!0}function ij(e,t){let n=e?.trim();if(!n)return!1;let r=t?.trim();return r?n.localeCompare(r)>0:!1}function aj(e){let{active:t,readAt:n,runStatus:r,lastMessageAt:i}=e;return t||r===`running`?!1:ij(i,n)}var oj={selectedSessionKey:null,draftSessionKey:mA(),selectedAgentId:`main`,query:``,listMode:`time-first`};function sj(e){return t=>e(e=>({snapshot:{...e.snapshot,...t}}))}function cj(e){return(t,n)=>e(e=>{let r=t.trim(),i=n?.trim();if(!r||!i)return e;let a=e.optimisticReadAtBySessionKey[r];return a&&a.localeCompare(i)>=0?e:{...e,optimisticReadAtBySessionKey:{...e.optimisticReadAtBySessionKey,[r]:i}}})}var lj=S(e=>({snapshot:oj,optimisticReadAtBySessionKey:{},setSnapshot:sj(e),markSessionRead:cj(e)}));function uj(e,t){return e.filter(e=>rj(e,t))}function dj(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function fj(e={}){let t=lj(e=>e.snapshot.query),n=gt({limit:e.limit??200}),r=(0,k.useMemo)(()=>{let e=n.data?.sessions??[],r=uj(pA(e).filter(dj),t),i=new Map(e.map(e=>[e.sessionId,e]));return r.map(e=>({session:e,runStatus:i.get(e.key)?.status===`running`?`running`:void 0}))},[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function pj(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,O.jsx)(Bn,{session:g,active:y,showUnreadDot:aj({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:wn(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function mj(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function hj(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:r,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:s,onQueryChange:c}=e;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`px-4 pb-3`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(d,{variant:`primary`,className:u(`min-w-0 rounded-xl`,r.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{a(!1),s(n)},children:[(0,O.jsx)(st,{className:`mr-2 h-4 w-4`}),o(`chatSidebarNewTask`)]}),r.length>0?(0,O.jsxs)(wt,{open:i,onOpenChange:a,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":o(`chatSessionTypeLabel`),children:(0,O.jsx)(Fe,{className:`h-4 w-4`})})}),(0,O.jsxs)(bt,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:o(`chatSessionTypeLabel`)}),(0,O.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,O.jsx)(An,{option:e,onSelect:()=>{s(e.value),a(!1)}},e.value))})]})]}):null]})}),(0,O.jsx)(`div`,{className:`px-4 pb-3`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(Me,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,O.jsx)(ee,{value:t,onChange:e=>c(e.target.value),placeholder:o(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function gj(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:c,onQueryChange:l}=e,u=mj({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),f=u.length>1;return(0,O.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,O.jsx)(Me,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,O.jsx)(ee,{value:t,onChange:e=>l(e.target.value),placeholder:o(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),f?(0,O.jsxs)(wt,{open:a,onOpenChange:s,children:[(0,O.jsx)(St,{asChild:!0,children:(0,O.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":o(`chatSidebarNewTask`),children:(0,O.jsx)(st,{className:`h-4 w-4`})})}),(0,O.jsxs)(bt,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:o(`chatSidebarNewTask`)}),(0,O.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,O.jsx)(An,{option:e,onSelect:()=>{c(e.value),s(!1)}},e.value))})]})]}):(0,O.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":o(`chatSidebarNewTask`),onClick:()=>c(n),children:(0,O.jsx)(st,{className:`h-4 w-4`})})]})})}function _j(e){return new Date(e.session.updatedAt).getTime()}function vj(e){return[...e].sort((e,t)=>_j(t)-_j(e))}function yj(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],s=[],c=[],l=[];for(let t of e){let{session:e}=t,o=new Date(e.updatedAt).getTime();o>=n?a.push(t):o>=r?s.push(t):o>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:o(`chatSidebarToday`),items:a}),s.length>0&&u.push({label:o(`chatSidebarYesterday`),items:s}),c.length>0&&u.push({label:o(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:o(`chatSidebarOlder`),items:l}),u}function bj(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=_j(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||zk(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:vj(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function xj(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var Sj=[{target:`/cron`,label:()=>o(`chatSidebarScheduledTasks`),icon:ve},{target:`/skills`,label:()=>o(`chatSidebarSkills`),icon:ke},{target:`/agents`,label:()=>o(`agentsPageTitle`),icon:Ae}];function Cj(e,t,n){let r=lj(e=>e.optimisticReadAtBySessionKey);return(0,k.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function wj({variant:e=`desktop`}){let n=e===`mobile`,r=oD(),i=pt(),[a,s]=(0,k.useState)(!1),c=Z(e=>e.snapshot),l=lj(e=>e.snapshot),d=y(),f=hA(),{isLoading:p,items:m}=fj(),{language:h,setLanguage:g}=mt(),{theme:_,setTheme:v}=Ee(),b=o(be.find(e=>e.value===_)?.labelKey??`themeWarm`),x=t.find(e=>e.value===h)?.label??h,S=(0,k.useMemo)(()=>new Map((f.data?.agents??[]).map(e=>[e.id,e])),[f.data?.agents]),C=(0,k.useMemo)(()=>vj(m),[m]),w=(0,k.useMemo)(()=>{let e=new Map;for(let t of m){let n=t.session.parentSessionId?.trim();if(!n)continue;let r=e.get(n)??[];r.push(t),e.set(n,r)}for(let t of e.values())t.sort((e,t)=>_j(t)-_j(e));return e},[m]),T=(0,k.useMemo)(()=>yj(C),[C]),E=(0,k.useMemo)(()=>bj(C),[C]),ee=c.defaultSessionType||`native`,te=(0,k.useMemo)(()=>c.sessionTypeOptions.filter(e=>e.value!==ee),[ee,c.sessionTypeOptions]),ne=l.listMode===`project-first`,re=Cj(m,l.selectedSessionKey,r.chatSessionListManager.markSessionRead),{editingSessionKey:ie,draftLabel:ae,savingSessionKey:oe,setDraftLabel:se,startEditingSessionLabel:ce,cancelEditingSessionLabel:le,saveSessionLabel:ue}=ej(),de=e=>{h!==e&&(g(e),window.location.reload())},fe=e=>(0,O.jsx)(pj,{item:e,selectedSessionKey:l.selectedSessionKey,optimisticReadAtBySessionKey:re,agentsById:S,childSessionsByParentKey:w,editingSessionKey:ie,draftLabel:ae,savingSessionKey:oe,sessionTitle:xj,onSelectSession:r.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>r.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ce,onDraftLabelChange:se,onSaveSessionLabel:ue,onCancelEditingSessionLabel:le},e.session.key),pe=(e,t)=>{let i=typeof t==`string`?r.chatSessionListManager.createSession(e,t):r.chatSessionListManager.createSession(e);n&&r.chatUiManager.goToSession(i)};return(0,O.jsxs)(`aside`,{className:u(`flex h-full min-h-0 flex-col bg-secondary`,n?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[n?null:(0,O.jsx)(`div`,{className:`px-5 pt-5 pb-3`,children:(0,O.jsx)(Oe,{className:`flex items-center gap-2.5 min-w-0`,suffix:(0,O.jsx)(QA,{status:d.connectionStatus})})}),n?(0,O.jsx)(gj,{query:l.query,defaultSessionType:ee,sessionTypeOptions:c.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:pe,onQueryChange:r.chatSessionListManager.setQuery}):(0,O.jsx)(hj,{query:l.query,defaultSessionType:ee,sessionTypeOptions:c.sessionTypeOptions,nonDefaultSessionTypeOptions:te,isCreateMenuOpen:a,onCreateMenuOpenChange:s,onCreateSession:pe,onQueryChange:r.chatSessionListManager.setQuery}),n?null:(0,O.jsx)(`div`,{className:`px-3 pb-2`,children:(0,O.jsx)(`ul`,{className:`space-y-0.5`,children:Sj.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsx)(ye,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),n?null:(0,O.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,O.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:o(`chatSidebarTaskRecords`)}),(0,O.jsx)(hn,{isProjectFirstView:ne,onSelectMode:r.chatSessionListManager.setListMode})]}),(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:p?(0,O.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:o(`sessionsLoading`)}):ne?E.length===0?(0,O.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,O.jsx)(sn,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500`,children:o(`chatSidebarProjectViewEmpty`)})]}):(0,O.jsx)(Mn,{groups:E,defaultSessionType:ee,sessionTypeOptions:c.sessionTypeOptions,renderSessionItem:fe,onCreateSession:pe}):T.length===0?(0,O.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,O.jsx)(sn,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500`,children:o(`sessionsEmpty`)})]}):(0,O.jsx)(`div`,{className:`space-y-3`,children:T.map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,O.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(fe)})]},e.label))})}),n?null:(0,O.jsxs)(`div`,{className:`px-3 py-3 border-t border-gray-200/60 space-y-0.5`,children:[(0,O.jsx)(ye,{to:`/settings`,label:o(`settings`),icon:lt,density:`compact`}),(0,O.jsx)(De,{onClick:()=>i.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:Ne,label:o(`docBrowserHelp`),density:`compact`}),(0,O.jsx)(we,{value:_,onValueChange:e=>v(e),icon:Te,label:o(`theme`),valueLabel:b,density:`compact`,children:be.map(e=>(0,O.jsx)(Xe,{value:e.value,className:`text-xs`,children:o(e.labelKey)},e.value))}),(0,O.jsx)(we,{value:h,onValueChange:e=>de(e),icon:Se,label:o(`language`),valueLabel:x,density:`compact`,children:t.map(e=>(0,O.jsx)(Xe,{value:e.value,className:`text-xs`,children:e.label},e.value))})]})]})}function Tj({tone:e=`neutral`,value:t}){return(0,O.jsx)(`span`,{className:u(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function Ej({breadcrumb:e}){return(0,O.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,O.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,O.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,O.jsxs)(k.Fragment,{children:[(0,O.jsxs)(`span`,{className:u(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,O.jsx)(en,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,O.jsx)(Gt,{className:`h-3 w-3 shrink-0`}):null,(0,O.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,O.jsx)(zt,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,O.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,O.jsx)(Tj,{value:e.locationLabel}):null,e.truncated?(0,O.jsx)(Tj,{tone:`warning`,value:o(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function Dj(e){let t=e.path?.trim()??``;return h({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>oe({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function Oj(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function kj(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:CO({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function Aj(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=DO({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function jj({text:e,tone:t=`muted`}){return(0,O.jsx)(`div`,{className:u(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function Mj({diffBlock:e}){return e?(0,O.jsx)(Nj,{block:e}):(0,O.jsx)(jj,{text:o(`chatWorkspaceDiffEmpty`)})}function Nj({block:e}){return(0,O.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,O.jsx)(wT,{block:e,layout:`workspace`})})}function Pj({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,O.jsx)(jj,{text:o(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,O.jsx)(jj,{text:o(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,O.jsx)(jj,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,O.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,O.jsx)(mw,{text:i,role:`assistant`,texts:{copyCodeLabel:o(`chatCodeCopy`),copiedCodeLabel:o(`chatCodeCopied`)},onFileOpen:e})}):t?(0,O.jsx)(Nj,{block:t}):(0,O.jsx)(jj,{text:o(`chatWorkspacePreviewEmpty`)})}function Fj({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=Dj({path:e.path,basePath:t,enabled:r}),a=(0,k.useMemo)(()=>e.viewMode===`diff`?Aj(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=Oj({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,k.useMemo)(()=>!r||!o?null:kj({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,O.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,O.jsx)(Ej,{breadcrumb:(0,k.useMemo)(()=>Kk({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,O.jsx)(Mj,{diffBlock:a}):(0,O.jsx)(Pj,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}function Ij(e,t){return e.label?.trim()?e.label.trim():t?tj(t):e.sessionKey}function Lj(e){let t=gt({limit:200}),n=(0,k.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,k.useMemo)(()=>{let e=pA(n);return new Map(e.map(e=>[e.key,e]))},[n]),i=(0,k.useMemo)(()=>new Map(n.map(e=>[e.sessionId,e])),[n]);return(0,k.useMemo)(()=>e.map(e=>{let t=r.get(e.sessionKey)??null,n=i.get(e.sessionKey)??null,a=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:Ij(e,t),agentId:a,updatedAt:t?.updatedAt??null,lastMessageAt:t?.lastMessageAt??null,readAt:t?.readAt??null,runStatus:n?.status===`running`?`running`:void 0,sessionTypeLabel:t?.sessionType?BA(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,i,e])}function Rj(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
58
58
  `)}}async function*zj(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=Bj(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=Bj(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function Bj(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=Rj(e);t&&i.push(t)}if(t&&r.trim()){let e=Rj(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var Vj=`/ncp/agent`,Hj=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function Uj(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function Wj(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function Gj(e){let t=(e??`/ncp/agent`).trim();if(!t)return Vj;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function Kj(e){try{return(await e.text()).trim()}catch{return``}}function qj(e){if(Zj(e))return e.ncpError;if(Yj(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:$j(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function Jj(e,t={}){return new Hj(e,t.alreadyPublished??!1)}function Yj(e){return Xj(e)&&typeof e.code==`string`&&typeof e.message==`string`}function Xj(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Zj(e){return e instanceof Hj}var Qj={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function $j(e){if(!e)return`runtime-error`;let t=Qj[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function eM(e){let t=nM(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function tM(e){let t=nM(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=$j(n),i=Xj(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function nM(e){try{let t=JSON.parse(e);return Xj(t)?t:null}catch{return null}}var rM=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],iM=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=Uj(e.baseUrl),this.basePath=Gj(e.basePath),this.fetchImpl=Wj(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:rM,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:X.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted(),await this.jsonRequest({path:`/send`,method:`POST`,body:e})}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await Kj(n)}`)}catch(e){if(t.signal.aborted)return;let n=qj(e);throw this.publish({type:X.EndpointError,payload:n}),Jj(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async jsonRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP request failed with HTTP ${n.status}: ${await Kj(n)}`)}catch(e){if(t.signal.aborted)return;if(Zj(e))throw e;let n=qj(e);throw this.publish({type:X.EndpointError,payload:n}),Jj(n)}finally{this.activeControllers.delete(t)}}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await Kj(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of zj(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(Zj(e))throw e;let n=qj(e);throw this.publish({type:X.EndpointError,payload:n}),Jj(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=eM(e.data);if(!t){this.publish({type:X.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=tM(e.data);throw this.publish({type:X.EndpointError,payload:t}),Jj(t,{alreadyPublished:!0})}}};function aM(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function oM(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function sM(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function cM(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw ue.reportTransportFailure(oM(n)),sM(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${aM(e)}: ${oM(n)}`,n)}}}var lM=300,uM=`ncp agent unavailable during startup`;function dM(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function fM(e){return e?.trim().toLowerCase().includes(uM)??!1}function pM(){return new iM({baseUrl:se,basePath:`/api/ncp/agent`,fetchImpl:cM()})}async function mM(e,t,n=lM){t.throwIfAborted();try{let r=await C(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`}}catch(e){if(t.throwIfAborted(),!dM(e))throw e;return{messages:[],status:`idle`}}}function hM(e,t){let n=(0,k.useRef)(null),r=(0,k.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,k.useEffect)(()=>{r(e)},[e,r])}function gM(e,t={}){let[n]=(0,k.useState)(()=>pM()),r=ne(),[i,a]=(0,k.useState)(0),o=t.messageLimit??lM,s=IE({sessionId:e,client:n,loadSeed:(0,k.useCallback)((e,t)=>mM(e,t,o),[i,o])}),c=s.hydrateError?.message??s.snapshot.error?.message??null;return hM(r.phase===`ready`&&fM(c)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),s}function _M(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function vM(e){let{activeChildSessionKey:t,activeWorkspaceFileKey:n,childSessionTabs:r,workspaceFileTabs:i}=e;if(n){let e=i.find(e=>e.key===n);if(e)return{kind:`file`,file:e}}if(t){let e=r.find(e=>e.sessionKey===t);if(e)return{kind:`child-session`,tab:e}}return r[0]?{kind:`child-session`,tab:r[0]}:i[0]?{kind:`file`,file:i[0]}:null}function yM({agentId:e,kind:t}){return t===`file`?(0,O.jsx)(Gt,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,O.jsx)(xA,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,O.jsx)(sn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function bM({tab:e}){return(0,O.jsx)(Mt,{delayDuration:250,children:(0,O.jsxs)(Pt,{children:[(0,O.jsx)(Ot,{asChild:!0,children:(0,O.jsxs)(`div`,{className:u(`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,e.active?`border-b-primary bg-white text-gray-900`:`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[(0,O.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,O.jsx)(yM,{kind:e.kind,agentId:e.agentId}),(0,O.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-medium`,children:e.title}),e.kind===`file`&&e.viewMode===`diff`?(0,O.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:o(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,O.jsx)(`span`,{"aria-label":o(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null]}),e.onClose?(0,O.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onClose?.()},className:u(`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,e.active?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":o(`chatWorkspaceCloseFile`),children:(0,O.jsx)(ft,{className:`h-3 w-3`})}):null]})}),(0,O.jsx)(At,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function xM({tabs:e}){return(0,O.jsx)(`div`,{"data-testid":`workspace-tabs-bar`,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/70 bg-gray-50/85`,children:(0,O.jsx)(`div`,{"data-testid":`workspace-tabs-scroll`,className:`flex min-w-max items-stretch`,children:e.map(e=>(0,O.jsx)(bM,{tab:e},e.key))})})}function SM({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=gM(e),i=r.visibleMessages,a=(0,k.useRef)(null),{onScroll:s}=$w({scrollRef:a,resetKey:e,isLoading:r.isHydrating,hasContent:i.length>0,contentVersion:i[i.length-1]??null,stickyThresholdPx:20});return(0,O.jsx)(`div`,{ref:a,onScroll:s,className:`h-full overflow-y-auto custom-scrollbar`,children:r.isHydrating?(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,O.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),o(`chatChildSessionLoading`)]}):r.hydrateError?(0,O.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:r.hydrateError.message}):i.length===0&&!r.isRunning?(0,O.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:o(`chatChildSessionEmpty`)}):(0,O.jsx)(`div`,{className:`px-4 py-5`,children:(0,O.jsx)(TA,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function CM({value:e}){return(0,O.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,O.jsx)(`span`,{className:`truncate`,children:e})})}function wM({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,O.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[t.length>0?(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,O.jsx)(CM,{value:e},e))}):null,e.projectRoot?(0,O.jsx)(`div`,{title:e.projectRoot,className:`truncate rounded border border-gray-200 bg-gray-50 px-2 py-1.5 font-mono text-[11px] text-gray-500`,children:e.projectRoot}):null]})}function TM({tab:e}){return(0,O.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[e.agentId?(0,O.jsx)(xA,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,O.jsx)(Qt,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,O.jsx)(wM,{tab:e})]})}function EM(e){let{resolvedChildTabs:t,workspaceFileTabs:n,activeSelection:r,optimisticReadAtBySessionKey:i,onSelectSession:a,onSelectFile:o,onCloseFile:s}=e,c=t.map(e=>{let t=i[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:r?.kind===`child-session`&&r.tab.sessionKey===e.sessionKey,showUnreadDot:aj({active:r?.kind===`child-session`&&r.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>a(e.sessionKey)}}),l=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:_M(e),tooltip:e.path,viewMode:e.viewMode,active:r?.kind===`file`&&r.file.key===e.key,onSelect:()=>o(e.key),onClose:()=>s(e.key)}));return[...c,...l]}function DM({childSessionTabs:e,activeChildSessionKey:t,workspaceFileTabs:n,activeWorkspaceFileKey:r,sessionProjectRoot:i,displayMode:a=`docked`,onSelectSession:s,onSelectFile:c,onCloseFile:l,onClose:d,onBackToParent:f,onToolAction:p,onFileOpen:m}){let h=oD(),g=Lj(e),_=lj(e=>e.optimisticReadAtBySessionKey),v=vM({activeChildSessionKey:t,activeWorkspaceFileKey:r,childSessionTabs:g,workspaceFileTabs:n}),y=g.some(e=>!!e.parentSessionKey);(0,k.useEffect)(()=>{if(v?.kind!==`child-session`)return;let e=v.tab.lastMessageAt?.trim()??null;e&&h.chatSessionListManager.markSessionRead(v.tab.sessionKey,e,v.tab.readAt??null)},[v,h]);let b=(0,k.useMemo)(()=>EM({resolvedChildTabs:g,workspaceFileTabs:n,activeSelection:v,optimisticReadAtBySessionKey:_,onSelectSession:s,onSelectFile:c,onCloseFile:l}),[v,l,c,s,_,g,n]);return v?(0,O.jsx)(`aside`,{className:u(a===`overlay`?`fixed inset-0 z-40 flex bg-white`:`hidden shrink-0 border-l border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex md:w-[26rem] lg:w-[30rem] xl:w-[34rem]`),children:(0,O.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-4 py-2.5`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:f,className:u(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!y&&`pointer-events-none opacity-0`),children:[(0,O.jsx)(je,{className:`h-3.5 w-3.5`}),(0,O.jsx)(`span`,{children:o(`chatBackToParent`)})]}),(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded-full border border-gray-200/80 p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":o(`chatWorkspaceClosePanel`),children:(0,O.jsx)(ft,{className:`h-4 w-4`})})]}),(0,O.jsx)(xM,{tabs:b}),(0,O.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:v.kind===`child-session`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(TM,{tab:v.tab}),(0,O.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,O.jsx)(SM,{sessionKey:v.tab.sessionKey,onToolAction:p,onFileOpen:m})})]}):(0,O.jsx)(Fj,{file:v.file,sessionProjectRoot:i,onFileOpen:m})})]})}):null}function OM(){return h({queryKey:[`ncp-session-types`],queryFn:m,staleTime:1e4,retry:!1})}function kM(e){let t=e.trim();return t.length>0?t:null}function AM(e){return e??null}var jM=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=lj.getState().snapshot,n=WA.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:kM(e.selectedModel),preferredThinking:AM(e.selectedThinkingLevel)}})},this.enqueue=e=>{this.queued=e,!this.inFlight&&this.startFlush()},this.startFlush=()=>{this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})},this.flush=async()=>{for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}}},MM=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new jM(le),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=gD(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:dD(e),selectedSkills:fD(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:dD(e),selectedSkills:fD(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Z.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Z.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Z.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(uD(n))},this.setComposerNodes=e=>{let t=Z.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let{snapshot:t}=Z.getState(),n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=hD(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=hD(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Z.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Z.getState().snapshot,t=lj.getState().snapshot,n=WA.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=_D(e.composerNodes,i);if(ED({snapshot:e,hasSendableDraft:a.some(e=>e.type!==`text`||e.text.trim().length>0),isRuntimeBlocked:ue.isChatInteractionBlocked()}))return;let{selectedSkills:o,composerNodes:s}=e,c=n.sessionKey??t.selectedSessionKey??this.sessionListManager.ensureDraftSession(e.selectedSessionType);this.setComposerNodes(lD()),await this.streamActionsManager.sendMessage({message:r,sessionKey:c,agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:o,attachments:i,parts:a,restoreDraftOnError:!0,composerNodes:s}),this.sessionListManager.promoteRootDraftSessionRoute(c)},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Z.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Z.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Z.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=RA(e);Z.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let{snapshot:t}=Z.getState(),{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(mD(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),bD.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{xD.remember(e)},this.selectSkills=e=>{let t=Z.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let{snapshot:t}=Z.getState(),n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Z.getState().setSnapshot({selectedThinkingLevel:i})}}},NM=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.syncDraftThreadState=e=>{WA.getState().setSnapshot({sessionKey:e,sessionDisplayName:void 0,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=lj.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=lj.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&lj.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=lj.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&lj.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=lj.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&lj.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(lj.getState().markSessionRead(r,i),le(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=Rk(t),s=mA();return this.streamActionsManager.resetStreamState(),lj.getState().setSnapshot({selectedSessionKey:null,draftSessionKey:s}),this.syncDraftThreadState(s),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:o?s:null}),this.uiManager.goToChatRoot(),s},this.ensureDraftSession=e=>{let{snapshot:t}=lj.getState();if(t.selectedSessionKey)return t.selectedSessionKey;let n=typeof e==`string`&&e.trim().length>0?e.trim():null;return this.syncDraftThreadState(t.draftSessionKey),n&&Z.getState().setSnapshot({pendingSessionType:n}),t.draftSessionKey},this.promoteRootDraftSessionRoute=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=lj.getState(),{sessionKey:r}=WA.getState().snapshot;n.selectedSessionKey!==null||n.draftSessionKey!==t||r!==t||!this.uiManager.isAtChatRoot()||this.uiManager.goToSession(t,{replace:!0})},this.selectSession=e=>{WA.getState().setSnapshot({workspacePanelParentKey:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e)},this.setQuery=e=>{let t=lj.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&lj.getState().setSnapshot({query:n})}}},PM=async()=>{},FM=()=>{},IM=class{constructor(){this.actions={sendMessage:PM,stopCurrentRun:PM,resumeRun:PM,resetStreamState:FM,applyHistoryMessages:FM},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},LM=`sid_`;function RM(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${LM}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function zM(e){if(!e.startsWith(LM))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function BM(e){if(!e)return null;let t=zM(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function VM(e){return`/chat/${RM(e)}`}var HM=async e=>!1,UM=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:HM},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`,this.goToSession=(e,t)=>{this.navigateTo(VM(e),t)}}},WM=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=WA.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&WA.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{lj.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),WA.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null})},this.resolveWorkspaceParentSessionKey=()=>WA.getState().snapshot.sessionKey?.trim()||(lj.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null;return{key:`${r??`draft`}::${e.viewMode}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,line:e.line??null,column:e.column??null,rawText:e.rawText??null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=WA.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=lj.getState();t!==e&&this.uiManager.goToSession(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.openChildSessionPanel=e=>{let t=e.parentSessionKey.trim();if(!t)return;let n=e.activeChildSessionKey?.trim()||null;WA.getState().setSnapshot({workspacePanelParentKey:t,activeChildSessionKey:n,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t)},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(WA.getState().setSnapshot({workspacePanelParentKey:t,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null}),this.ensureWorkspaceParentRoute(t))},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||lj.getState().snapshot.selectedSessionKey||null;if(t){this.openChildSessionPanel({parentSessionKey:t,activeChildSessionKey:e.sessionId});return}}WA.getState().setSnapshot({workspacePanelParentKey:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=WA.getState().snapshot;n.some(e=>e.sessionKey===t)&&WA.getState().setSnapshot({activeChildSessionKey:t,activeWorkspaceFileKey:null})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=WA.getState().snapshot;n.some(e=>e.key===t)&&WA.getState().setSnapshot({activeWorkspaceFileKey:t,activeChildSessionKey:null})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=WA.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a={workspaceFileTabs:i.filter(e=>e.key!==t)};r===t&&(a.activeWorkspaceFileKey=null),WA.getState().setSnapshot(a)},this.closeWorkspacePanel=()=>{WA.getState().setSnapshot({workspacePanelParentKey:null,activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.closeChildSessionDetail=()=>{this.closeWorkspacePanel()},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=WA.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeWorkspacePanel(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>ht.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=lj.getState();if(e&&await this.uiManager.confirm({title:o(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:o(`delete`)})){WA.getState().setSnapshot({isDeletePending:!0});try{await w(e),ae(g,e),g.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{WA.getState().setSnapshot({isDeletePending:!1})}}}}},GM=class{constructor(){this.chatUiManager=new UM,this.chatStreamActionsManager=new IM,this.chatSessionListManager=new NM(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new MM(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new WM(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager)}};function KM(e){return e?.trim().toLowerCase()||`native`}function qM(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function JM(e,t){return typeof t==`string`&&e.includes(t)}function YM(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function XM(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function ZM(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:XM({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>qM(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function QM(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:XM({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>JM(t,e),firstAvailableValue:YM(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function $M(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=KM(r),o,s=-1/0;for(let e of t){if(e.key===n||KM(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function eN(e){let{sessions:t,selectedSessionKey:n,sessionType:r}=e;return $M({sessions:t,selectedSessionKey:n,sessionType:r,readPreference:e=>e.preferredModel?.trim()||void 0})}function tN(e){let{sessions:t,selectedSessionKey:n,sessionType:r}=e;return $M({sessions:t,selectedSessionKey:n,sessionType:r,readPreference:e=>e.preferredThinking??void 0})}function nN(e){let{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:a,resolveValue:o}=e,s=(0,k.useRef)(void 0),c=(0,k.useRef)(o);(0,k.useEffect)(()=>{c.current=o},[o]),(0,k.useEffect)(()=>{let e=s.current!==r;if(!t){a(n),s.current=r;return}a(t=>c.current({currentValue:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!r&&!i})),s.current=r},[n,t,i,r,a])}function rN(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;nN({isPreferenceAvailable:t.length>0,emptyValue:``,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>ZM({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function iN(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;nN({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>QM({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}export{Z as A,_A as C,Rk as D,zk as E,mn as F,un as I,on as L,VE as M,Ln as N,UD as O,In as P,vA as S,fA as T,zA as _,GM as a,hA as b,fM as c,lj as d,tj as f,RA as g,VA as h,iN as i,aD as j,JD as k,gM as l,XA as m,tN as n,BM as o,rj as p,rN as r,OM as s,eN as t,wj as u,BA as v,pA as w,gA as x,HA as y};