@versot/vaguspi 0.1.4 → 0.1.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,19 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-V9zrDr2c.js","assets/vendor-CkEpMl6t.js"])))=>i.map(i=>d[i]);
2
- var er=Object.defineProperty;var tr=(n,r,t)=>r in n?er(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t;var Be=(n,r,t)=>tr(n,typeof r!="symbol"?r+"":r,t);import{j as e,r as a,R as en,a as tn,c as nr}from"./vendor-CkEpMl6t.js";import{u as U,a as Qe,b as nn,L as rr,D as or,h as sr,J as ir,T as lr,A as ar}from"./settings-V9zrDr2c.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();const dr="modulepreload",cr=function(n){return"/"+n},qt={},rn=function(r,t,o){let s=Promise.resolve();if(t&&t.length>0){let l=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),g=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=l(t.map(u=>{if(u=cr(u),u in qt)return;qt[u]=!0;const f=u.endsWith(".css"),m=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${m}`))return;const x=document.createElement("link");if(x.rel=f?"stylesheet":dr,f||(x.as="script"),x.crossOrigin="",x.href=u,g&&x.setAttribute("nonce",g),document.head.appendChild(x),f)return new Promise((h,j)=>{x.addEventListener("load",h),x.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return r().catch(i)})},fe="background 0.15s, color 0.15s";function on(n){const r=new Date(n).getTime();if(Number.isNaN(r))return"";const t=Math.max(0,Math.round((Date.now()-r)/6e4));if(t<1)return"now";if(t<60)return`${t}m`;const o=Math.round(t/60);return o<24?`${o}h`:`${Math.round(o/24)}d`}function sn(n){const r=n.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]??n}function kt(n,r){return e.jsx("div",{style:{display:"grid",gridTemplateRows:n?"1fr":"0fr",transition:"grid-template-rows 0.2s ease"},children:e.jsx("div",{style:{overflow:"hidden",minHeight:0},children:r})})}function vt({size:n=14,color:r}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",style:{flexShrink:0,color:r},children:e.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})})}function ur(n){const r=U(),[t,o]=a.useState(!1),s=a.useMemo(()=>n.archivedProjects.filter(i=>i.sessions.length>0).toSorted((i,l)=>l.sessions[0].modified.localeCompare(i.sessions[0].modified)),[n.archivedProjects]);return n.archivedProjects.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>o(i=>!i),onContextMenu:i=>{n.onSectionContextMenu&&(i.preventDefault(),n.onSectionContextMenu(i))},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.88em",fontWeight:500,color:r.color.muted,marginTop:8,transition:fe},onMouseEnter:i=>{i.currentTarget.style.background=r.color.sidebarHover},onMouseLeave:i=>{i.currentTarget.style.background="transparent"},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{flexShrink:0},children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"}),e.jsx("path",{d:"M12 13v3"})]}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:"已归档"}),e.jsx("span",{style:{fontSize:"0.75em",color:r.color.muted,background:r.color.sidebarHover,borderRadius:8,padding:"1px 7px"},children:n.archivedProjects.length}),e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,transform:t?"rotate(0)":"rotate(-90deg)",transition:"transform 0.15s ease"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]}),kt(t,e.jsx("div",{style:{paddingLeft:6},children:s.map(({cwd:i,dirKey:l,sessions:c})=>{const g=!n.collapsed.has(`arch:${i}`);return e.jsxs("div",{style:{marginBottom:1},children:[e.jsxs("div",{onClick:()=>n.onToggleProject(`arch:${i}`),onContextMenu:u=>n.onProjectContextMenu(u,i,l),style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.9em",fontWeight:500,color:r.color.muted,opacity:.85,transition:fe},onMouseEnter:u=>{u.currentTarget.style.background=r.color.sidebarHover,u.currentTarget.style.opacity="1"},onMouseLeave:u=>{u.currentTarget.style.background="transparent",u.currentTarget.style.opacity="0.85"},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{flexShrink:0},children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"})]}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:sn(i)}),e.jsx("span",{style:{fontSize:"0.75em",color:r.color.muted,flexShrink:0},children:c.length}),e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,transform:g?"rotate(0)":"rotate(-90deg)",transition:"transform 0.15s ease"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]}),kt(g,e.jsx("div",{style:{paddingLeft:30},children:c.map(u=>e.jsxs("div",{onClick:()=>n.onOpenSession(u.path),onContextMenu:f=>n.onSessionContextMenu(f,u,!0),onMouseEnter:f=>f.currentTarget.style.background=r.color.sidebarHover,onMouseLeave:f=>f.currentTarget.style.background="transparent",style:{display:"flex",alignItems:"center",gap:7,padding:"6px 10px",borderRadius:10,cursor:"pointer",userSelect:"none",fontSize:"0.89em",color:r.color.muted,overflow:"hidden",whiteSpace:"nowrap",transition:fe},children:[e.jsx(vt,{}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1},children:(u.name??u.firstMessage.slice(0,40))||"(空会话)"}),n.busyPaths.has(u.path)&&e.jsx("span",{title:"工作中",style:{width:7,height:7,borderRadius:"50%",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",animation:"vagus-pulse 1.2s ease-in-out infinite",flexShrink:0,display:"inline-block"}}),e.jsx("span",{style:{fontSize:"0.79em",color:r.color.muted,flexShrink:0},children:on(u.modified)})]},u.id))}))]},i)})}))]})}const Te="#6366f1",Ye="#8b5cf6",Nt="0 0 0 2px rgba(99,102,241,0.4)";function pt({text:n,style:r}){const t=a.useRef(null),[o,s]=a.useState(!1),i=a.useRef(0),l=32;return e.jsx("span",{ref:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0,...r},onMouseEnter:()=>{requestAnimationFrame(()=>{const g=t.current,u=g==null?void 0:g.firstChild;if(!g||!u)return;const f=u.offsetWidth;i.current=f,f-g.clientWidth>2&&s(!0)})},onMouseLeave:()=>s(!1),children:o?e.jsxs("span",{style:{display:"inline-block",whiteSpace:"nowrap",animation:`vagus-marquee ${((i.current+l)/30).toFixed(2)}s linear infinite`},children:[e.jsx("span",{style:{paddingRight:l},children:n}),e.jsx("span",{style:{paddingRight:l},children:n})]}):e.jsx("span",{style:{display:"inline-block",whiteSpace:"nowrap"},children:n})})}function Vt({sessions:n,activePath:r,onNewSession:t,onOpenSession:o,onOpenSettings:s,onOpenPlugins:i,onRenameSession:l,onDeleteSession:c,onArchiveSession:g,onClearAllArchived:u,onCollapsedChange:f,onRestoreSession:m,onDeleteArchivedSession:x,onTogglePin:h,pinnedSessions:j=new Set,archivedProjects:S=[],onArchiveProject:k,onUnarchiveProject:p,onDeleteProject:v,busyPaths:T=new Set,pendingDialogPaths:L=new Set}){const I=U(),{theme:O}=Qe(),K="vagus.sidebar.collapsedProjects",[_,M]=a.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem(K)??"[]"))}catch{return new Set}}),[D,$]=a.useState(null),[re,J]=a.useState(),[ee,te]=a.useState(""),q=a.useMemo(()=>{const y=new Map;for(const P of n){const z=y.get(P.cwd)??[];z.push(P),y.set(P.cwd,z)}return[...y.entries()].toSorted((P,z)=>z[1][0].modified.localeCompare(P[1][0].modified)).map(([P,z])=>[P,z.toSorted((N,Y)=>Number(j.has(Y.path))-Number(j.has(N.path))||Y.modified.localeCompare(N.modified))])},[n,j]),b=y=>{M(P=>{const z=new Set(P);z.has(y)?z.delete(y):z.add(y);try{localStorage.setItem(K,JSON.stringify([...z]))}catch{}return z})},F=(y,P,z=!1)=>{y.preventDefault(),$({x:y.clientX,y:y.clientY,kind:"session",session:P,archived:z})},H=(y,P)=>{y.preventDefault(),$({x:y.clientX,y:y.clientY,kind:"project",cwd:P})},A=()=>$(null);a.useEffect(()=>{if(!D)return;const y=z=>{z.target.closest("[data-context-menu]")||A()},P=z=>{z.key==="Escape"&&A()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",P)}},[D]);const oe=y=>{J(y.path),te(y.name??y.firstMessage.slice(0,40)),$(null)},X={display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderRadius:7,cursor:"pointer",userSelect:"none",fontSize:"0.89em",color:I.color.fg,transition:"background 0.15s"},we=y=>{const P=ee.trim();J(void 0),P&&l&&l(y,P)},Se=n.find(y=>y.path===r),Ae=Se==null?void 0:Se.cwd,ze=280,ue=48,Ie="vagus.sidebar.collapsed",[Fe,Re]=a.useState(()=>{try{return localStorage.getItem(Ie)==="1"}catch{return!1}}),Ce=y=>{Re(y),f==null||f(y);try{localStorage.setItem(Ie,y?"1":"0")}catch{}},Me=O==="light"?"rgba(99,102,241,0.10)":"rgba(99,102,241,0.16)",le={display:"flex",alignItems:"center",gap:8,height:40,padding:"0 14px",borderRadius:12,background:`linear-gradient(135deg, ${Te}, ${Ye})`,border:"none",color:"#fff",fontSize:"0.96em",fontWeight:600,cursor:"pointer",userSelect:"none",transition:"filter 0.15s, box-shadow 0.15s, transform 0.15s",boxShadow:"0 2px 10px rgba(99,102,241,0.35)",width:"100%",outline:"none"};return e.jsx("aside",{style:{width:Fe?ue:ze,flexShrink:0,borderRight:`1px solid ${I.color.border}`,background:I.color.sidebarBg,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",position:"relative",transition:"width 0.18s ease"},children:Fe?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:"none",height:54,display:"flex",alignItems:"center",justifyContent:"center",borderBottom:`1px solid ${I.color.border}`},children:e.jsx("button",{title:"展开侧栏",onClick:()=>Ce(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:8,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:fe,outline:"none"},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})})}),e.jsxs("div",{style:{flex:"none",padding:"14px 8px 4px",display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[e.jsx("button",{title:"新对话",onClick:t,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:9,border:"none",cursor:"pointer",outline:"none",background:`linear-gradient(135deg, ${Te}, ${Ye})`,color:"#fff",boxShadow:"0 2px 10px rgba(99,102,241,0.35)"},children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"})})}),e.jsx("button",{title:"插件",onClick:i,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:9,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:fe,outline:"none"},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-3 3a5 5 0 0 0-.5 7.5z"}),e.jsx("path",{d:"M14 10a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l3-3a5 5 0 0 0 .5-7.5z"})]})})]}),e.jsx("div",{style:{flex:1}}),e.jsx("div",{style:{flex:"none",borderTop:`1px solid ${I.color.border}`,padding:8,display:"flex",justifyContent:"center"},children:e.jsx("button",{title:"设置",onClick:s,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:9,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:fe,outline:"none"},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{flex:"none",height:54,display:"flex",alignItems:"center",gap:8,padding:"0 16px",borderBottom:`1px solid ${I.color.border}`},children:[e.jsx("span",{style:{width:26,height:26,borderRadius:7,background:`linear-gradient(135deg,${Te},${Ye})`,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"0.93em",fontWeight:700,flexShrink:0,boxShadow:"0 2px 6px rgba(99,102,241,0.4)"},children:"◈"}),e.jsx("span",{style:{fontSize:"1.05em",fontWeight:700,color:I.color.fg},children:"vagusPI"}),e.jsx("span",{style:{flex:1}}),e.jsx("button",{title:"收起侧栏",onClick:()=>Ce(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:8,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:fe,outline:"none",flexShrink:0},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})})]}),e.jsxs("div",{style:{flex:"none",padding:"14px 16px 4px",display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("button",{style:le,onClick:t,onMouseEnter:y=>{y.currentTarget.style.filter="brightness(1.08)",y.currentTarget.style.boxShadow="0 4px 16px rgba(99,102,241,0.45)"},onMouseLeave:y=>{y.currentTarget.style.filter="none",y.currentTarget.style.boxShadow="0 2px 10px rgba(99,102,241,0.35)"},onMouseDown:y=>{y.currentTarget.style.transform="scale(0.98)"},onMouseUp:y=>{y.currentTarget.style.transform="scale(1)"},onFocus:y=>{y.currentTarget.style.boxShadow=`${Nt}, 0 2px 10px rgba(99,102,241,0.35)`},onBlur:y=>{y.currentTarget.style.boxShadow="0 2px 10px rgba(99,102,241,0.35)"},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"})}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:"新对话"}),e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M12 8v8M8 12h8"})]})]}),e.jsxs("button",{onClick:i,onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",width:"100%",border:"none",background:"transparent",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.93em",color:I.color.muted,transition:fe,outline:"none"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-3 3a5 5 0 0 0-.5 7.5z"}),e.jsx("path",{d:"M14 10a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l3-3a5 5 0 0 0 .5-7.5z"})]}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:"插件"})]})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"4px 8px 8px"},children:[e.jsx("div",{style:{fontSize:"0.79em",fontWeight:600,color:I.color.muted,textTransform:"uppercase",letterSpacing:"0.08em",padding:"12px 10px 6px"},children:"项目"}),q.length===0&&e.jsx("div",{style:{fontSize:"0.85em",color:I.color.muted,padding:"8px 10px",lineHeight:1.5},children:'暂无会话 — 点击"新对话"开始。'}),q.map(([y,P])=>{const z=!_.has(y),N=Ae===y;return e.jsxs("div",{style:{marginBottom:2},children:[e.jsxs("div",{onClick:()=>b(y),onContextMenu:Y=>H(Y,y),style:{position:"relative",display:"flex",alignItems:"center",gap:8,padding:"7px 8px",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.96em",fontWeight:500,color:I.color.fg,background:N?I.color.sidebarHover:"transparent",transition:fe},onMouseEnter:Y=>{N||(Y.currentTarget.style.background=I.color.sidebarHover)},onMouseLeave:Y=>{N||(Y.currentTarget.style.background="transparent")},children:[N&&e.jsx("span",{style:{position:"absolute",left:0,top:8,bottom:8,width:3,borderRadius:3,background:`linear-gradient(180deg,${Te},${Ye})`}}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{flexShrink:0,color:N?Te:I.color.muted},children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"})}),e.jsx(pt,{text:sn(y),style:{flex:1}}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,color:I.color.muted,transform:z?"rotate(0)":"rotate(-90deg)",transition:"transform 0.15s ease"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]}),kt(z,e.jsx("div",{style:{paddingLeft:30},children:P.map(Y=>{const he=Y.path===r,ye=re===Y.path;return e.jsxs("div",{className:"vagus-session-row",onClick:()=>o(Y.path),onContextMenu:G=>F(G,Y),onMouseEnter:G=>{he||(G.currentTarget.style.background=I.color.sidebarHover)},onMouseLeave:G=>{he||(G.currentTarget.style.background="transparent")},style:{position:"relative",display:"flex",alignItems:"center",gap:7,padding:"6px 10px",borderRadius:10,cursor:"pointer",userSelect:"none",fontSize:"0.91em",color:he?I.color.fg:I.color.muted,fontWeight:he?500:400,background:he?Me:"transparent",overflow:"hidden",whiteSpace:"nowrap",transition:fe},children:[he&&e.jsx("span",{style:{position:"absolute",left:0,top:8,bottom:8,width:3,borderRadius:3,background:`linear-gradient(180deg,${Te},${Ye})`}}),e.jsx(vt,{color:he?Te:void 0}),ye?e.jsx("input",{autoFocus:!0,value:ee,onChange:G=>te(G.target.value),onBlur:G=>{G.currentTarget.style.boxShadow="none",we(Y.path)},onKeyDown:G=>{G.key==="Enter"&&we(Y.path),G.key==="Escape"&&J(void 0)},onClick:G=>G.stopPropagation(),onFocus:G=>{G.currentTarget.style.boxShadow=Nt},style:{flex:1,minWidth:0,fontSize:"0.89em",padding:"2px 6px",background:I.color.bg,border:`1px solid ${I.color.border}`,borderRadius:6,color:I.color.fg,outline:"none"}}):e.jsx(pt,{text:(Y.name??Y.firstMessage.slice(0,40))||"(空会话)"}),e.jsx("span",{style:{width:14,display:"inline-flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:j.has(Y.path)&&e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{color:Te},children:e.jsx("path",{d:"M12 17l-5.88 3.09.87-6.02L2.6 9.43l6.44-.94L12 2.5l2.96 5.99 6.44.94-4.39 4.64.87 6.02z"})})}),e.jsx("span",{style:{width:12,display:"inline-flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:(T.has(Y.path)||L.has(Y.path))&&e.jsx("span",{title:"工作中",style:{width:7,height:7,borderRadius:"50%",background:I.color.primary,animation:"vagus-pulse 1.2s ease-in-out infinite",display:"inline-block"}})}),e.jsx("span",{className:"vagus-row-time",style:{fontSize:"0.79em",color:I.color.muted,flexShrink:0},children:on(Y.modified)})]},Y.id)})}))]},y)}),q.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:"0.79em",fontWeight:600,color:I.color.muted,textTransform:"uppercase",letterSpacing:"0.08em",padding:"16px 10px 6px"},children:"最近"}),e.jsx("div",{style:{paddingLeft:0},children:n.slice(0,5).map(y=>e.jsxs("div",{onClick:()=>o(y.path),onContextMenu:P=>F(P,y),onMouseEnter:P=>P.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:P=>P.currentTarget.style.background="transparent",style:{display:"flex",alignItems:"center",gap:7,padding:"6px 10px",borderRadius:10,cursor:"pointer",userSelect:"none",fontSize:"0.91em",color:I.color.muted,overflow:"hidden",whiteSpace:"nowrap",transition:fe},children:[e.jsx(vt,{}),e.jsx(pt,{text:y.name??y.firstMessage.slice(0,40)})]},y.id))})]}),e.jsx(ur,{archivedProjects:S,busyPaths:T,collapsed:_,onToggleProject:b,onOpenSession:o,onSessionContextMenu:(y,P,z)=>F(y,P,z),onProjectContextMenu:(y,P,z)=>{y.preventDefault(),$({x:y.clientX,y:y.clientY,kind:"archived",cwd:P,dirKey:z})},onSectionContextMenu:y=>$({x:y.clientX,y:y.clientY,kind:"archivedAll"})})]}),e.jsx("div",{style:{flex:"none",borderTop:`1px solid ${I.color.border}`,padding:8,background:I.color.sidebarBg},children:e.jsxs("button",{onClick:s,onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",width:"100%",border:"none",background:"transparent",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.93em",color:I.color.muted,transition:fe},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:"设置"})]})}),D&&e.jsxs("div",{"data-context-menu":!0,style:{position:"fixed",left:D.x,top:D.y,zIndex:1e3,minWidth:140,background:I.color.surface,border:`1px solid ${I.color.border}`,borderRadius:10,boxShadow:"0 12px 40px rgba(0,0,0,0.2)",padding:4},children:[D.kind==="session"&&!D.archived&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>oe(D.session),style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M4 20h4l10-10a2.83 2.83 0 0 0-4-4L4 16v4z"})}),"重命名"]}),h&&e.jsxs("div",{onClick:()=>{$(null),h(D.session.path)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:j.has(D.session.path)?"#6366f1":"none",stroke:j.has(D.session.path)?"#6366f1":"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 17l-5.88 3.09.87-6.02L2.6 9.43l6.44-.94L12 2.5l2.96 5.99 6.44.94-4.39 4.64.87 6.02z"})}),"置顶"]}),g&&e.jsxs("div",{onClick:()=>{$(null),g(D.session.path)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"})]}),"归档"]})]}),D.kind==="session"&&D.archived&&e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{onClick:()=>{$(null),m(D.session.path)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),"恢复"]}),x&&e.jsxs("div",{onClick:()=>{$(null),x(D.session.path)},style:{...X,color:"#E5484D"},onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"})}),"删除"]})]}),D.kind==="project"&&k&&e.jsxs("div",{onClick:()=>{$(null),k(D.cwd)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"})]}),"归档项目"]}),D.kind==="archivedAll"&&e.jsxs("div",{onClick:()=>{$(null),u==null||u()},style:{...X,color:"#E5484D"},onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),e.jsx("path",{d:"M10 11v6M14 11v6"})]}),"清空全部归档"]}),D.kind==="archived"&&e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{onClick:()=>{$(null),p(D.dirKey)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"}),e.jsx("path",{d:"M12 13v3"})]}),"恢复项目"]}),v&&e.jsxs("div",{onClick:()=>{$(null),v(D.dirKey)},style:{...X,color:"#E5484D"},onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"})}),"彻底删除"]})]})]})]})})}function jt(n,r){switch(n){case"extension":return r.color.success;case"skill":return r.color.warning;case"template":return r.color.accent;default:return r.color.primary}}const fr={builtin:"pi 原生指令",extension:"工具指令",skill:"Skills",template:"模板"};function hr({commands:n,onPick:r}){const t=U(),[o,s]=a.useState(""),i=o.toLowerCase().replace(/^\//,""),l=n.filter(m=>m.name.toLowerCase().includes(i)||m.description.toLowerCase().includes(i)),c=["builtin","extension","skill","template"],g={position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},u={width:480,maxHeight:"70vh",background:t.color.bg,border:`1px solid ${t.color.border}`,borderRadius:16,boxShadow:"0 24px 64px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column",overflow:"hidden"},f={display:"flex",alignItems:"center",gap:10,height:36,padding:"0 10px",borderRadius:8,cursor:"pointer",fontSize:"0.89em",color:t.color.fg};return e.jsx("div",{style:g,onMouseDown:m=>{m.target===m.currentTarget&&r(null)},children:e.jsxs("div",{style:u,onMouseDown:m=>m.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"14px 16px 10px",borderBottom:`1px solid ${t.color.border}`,flexShrink:0},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:t.color.muted},children:[e.jsx("path",{d:"M4 17l6-6-6-6"}),e.jsx("path",{d:"M12 19h8"})]}),e.jsx("input",{autoFocus:!0,value:o,onChange:m=>s(m.target.value),onKeyDown:m=>{m.key==="Escape"&&r(null)},placeholder:"输入 / 命令…",style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"0.96em",color:t.color.fg,fontFamily:"inherit"}}),e.jsxs("span",{style:{fontSize:"0.72em",color:t.color.muted,flexShrink:0},children:[l.length," 项"]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,minHeight:160},children:l.length===0?e.jsx("div",{style:{padding:"16px 10px",color:t.color.muted,fontSize:"0.86em"},children:"(没有匹配的命令)"}):c.flatMap(m=>{const x=l.filter(h=>h.type===m);return x.length===0?[]:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.4,textTransform:"uppercase",color:t.color.muted},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:jt(m,t),flexShrink:0}}),fr[m]]},m),...x.map(h=>e.jsxs("div",{onClick:()=>r(`/${h.name}`),style:f,onMouseEnter:j=>{j.currentTarget.style.background=t.color.surface},onMouseLeave:j=>{j.currentTarget.style.background="transparent"},children:[e.jsxs("span",{style:{color:jt(m,t),fontWeight:600,flexShrink:0,fontSize:"0.86em"},children:["/",h.name]}),e.jsx("span",{style:{color:t.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.description})]},`${m}:${h.name}`))]})})]})})}function Ut(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(Math.round(n))}function pr({value:n,onChange:r,onSubmit:t,usage:o,providers:s,onSwitchModel:i,onSetThinking:l,thinkingLevel:c="off",permissionMode:g,onTogglePermission:u,attachments:f=[],fileAttachments:m=[],onAttach:x,onRemoveAttachment:h,onCommand:j,commands:S=[],onPickCommand:k,onRefreshCommands:p,focusSignal:v,busy:T=!1,hasPendingDialog:L=!1,onRestoreDialog:I,onStop:O,selectedModel:K,queuedMessages:_=[]}){var He,Ze,qe;const M=U(),[D,$]=a.useState(!1),[re,J]=a.useState(!1),[ee,te]=a.useState(0),[q,b]=a.useState(!1);a.useEffect(()=>{if(_.length===0){b(!1);return}const C=window.setTimeout(()=>b(!0),300);return()=>window.clearTimeout(C)},[_.length]),a.useEffect(()=>{const C=X.current;C&&(C.style.height="auto",C.style.height=`${Math.min(C.scrollHeight,200)}px`)},[n]);const[F,H]=a.useState(!1),[A,oe]=a.useState(!1),X=a.useRef(null),we=a.useRef(null),Se=a.useRef(null),Ae=a.useRef(null),ze=a.useRef(null);a.useEffect(()=>{var C;v&&v>0&&((C=X.current)==null||C.focus())},[v]),a.useEffect(()=>{if(!D)return;const C=Q=>{var de,We;const ne=Q.target;(de=Ae.current)!=null&&de.contains(ne)||(We=Se.current)!=null&&We.contains(ne)||$(!1)},B=Q=>{Q.key==="Escape"&&$(!1)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",B)}},[D]),a.useEffect(()=>{if(!F)return;const C=Q=>{var de;const ne=Q.target;(de=ze.current)!=null&&de.contains(ne)||H(!1)},B=Q=>{Q.key==="Escape"&&H(!1)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",B)}},[F]);const ue=a.useMemo(()=>{for(const C of s){const B=C.models.find(Q=>(o==null?void 0:o.activeProvider)===C.id&&Q.id===(o==null?void 0:o.model));if(B)return{provider:C,model:B}}},[s,o==null?void 0:o.activeProvider,o==null?void 0:o.model]),Ie=(ue==null?void 0:ue.model.contextWindow)??1e6,Fe=((He=ue==null?void 0:ue.model.input)==null?void 0:He.includes("image"))??!0,Re=((Ze=o==null?void 0:o.contextUsage)==null?void 0:Ze.tokens)??null,Ce=Re!==null,Me=Re??0,le=Math.min(1,Me/Ie),y=o==null?void 0:o.latestCacheHitRate,P=7,z=2*Math.PI*P,N=z*(1-le),Y={width:34,height:34,borderRadius:10,border:"none",background:"transparent",color:M.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},he={display:"flex",alignItems:"center",gap:5,fontSize:"0.89em",color:M.color.muted,padding:"5px 10px",borderRadius:8,cursor:"pointer",background:"transparent",border:"none",fontFamily:"inherit"},ye={position:"absolute",bottom:42,left:0,zIndex:50,minWidth:190,background:M.color.bg,border:`1px solid ${M.color.border}`,borderRadius:12,boxShadow:"0 12px 40px rgba(0,0,0,0.14)",padding:4},G=()=>{t()},xe=re&&n.startsWith("/"),$e=xe?n.slice(1).split(/\s+/)[0]??"":"",ae=xe?S.filter(C=>C.name.toLowerCase().includes($e.toLowerCase())):[];a.useEffect(()=>{ee>=ae.length&&te(Math.max(0,ae.length-1))},[ae.length]);const De=C=>{const B=n.slice($e.length+1),Q=`/${C} ${B.replace(/^\s+/,"")}`;r(Q),J(!1),k==null||k(C)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",position:"relative"},onMouseDown:C=>{C.target.closest("button, input, textarea, select, [contenteditable], [role='button']")||C.preventDefault()},children:[q&&_.length>0&&e.jsxs("div",{style:{marginBottom:8,display:"flex",flexDirection:"column",gap:5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.78em",fontWeight:600,letterSpacing:.3,color:M.color.muted},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#8b5cf6",display:"inline-block",animation:"vagus-pulse 1.2s ease-in-out infinite",flexShrink:0}}),"排队中 · ",_.length," 条"]}),_.map((C,B)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,height:30,padding:"0 12px 0 8px",borderRadius:9,background:"rgba(99,102,241,0.07)",border:"1px solid rgba(99,102,241,0.18)",fontSize:"0.86em",color:M.color.fg},children:[e.jsx("span",{style:{fontSize:"0.7em",fontWeight:700,color:"#6366f1",background:"rgba(99,102,241,0.12)",width:18,height:18,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontVariantNumeric:"tabular-nums"},children:B+1}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.text})]},C.id))]}),(f.length>0||m.length>0)&&e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8,alignItems:"center"},children:[f.map((C,B)=>e.jsxs("div",{style:{position:"relative"},children:[e.jsx("img",{src:C.dataUrl,alt:C.name??"",style:{width:48,height:48,objectFit:"cover",borderRadius:8,border:`1px solid ${M.color.border}`}}),e.jsx("button",{onClick:()=>h==null?void 0:h(B),title:"移除",style:{position:"absolute",top:-5,right:-5,width:16,height:16,borderRadius:"50%",border:"none",background:"#E5484D",color:"#fff",fontSize:"0.71em",lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]},B)),m.map((C,B)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,height:26,padding:"0 8px",borderRadius:8,background:M.color.surface,border:`1px solid ${M.color.border}`,fontSize:"0.82em",color:M.color.muted},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"}),e.jsx("path",{d:"M14 2v6h6"})]}),C.name,e.jsx("button",{onClick:()=>h==null?void 0:h(B+f.length),style:{width:14,height:14,borderRadius:"50%",border:"none",background:"transparent",color:M.color.muted,cursor:"pointer",fontSize:"0.79em",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:"✕"})]},C.name))]}),xe&&ae.length>0&&e.jsx("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",left:4,right:4,zIndex:60,background:M.color.bg,border:`1px solid ${M.color.border}`,borderRadius:12,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",maxHeight:300,overflowY:"auto",padding:4},children:ae.map((C,B)=>e.jsxs("button",{onClick:()=>De(C.name),onMouseEnter:()=>te(B),style:{display:"flex",alignItems:"center",gap:10,width:"100%",height:34,padding:"0 10px",border:"none",borderRadius:8,cursor:"pointer",textAlign:"left",fontFamily:"inherit",fontSize:"0.88em",background:B===ee?M.color.surface:"transparent",color:M.color.fg},children:[e.jsxs("span",{style:{color:jt(C.type,M),fontWeight:600,flexShrink:0,fontSize:"0.84em"},children:["/",C.name]}),e.jsx("span",{style:{color:M.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.description})]},`${C.type}:${C.name}`))}),e.jsx("textarea",{ref:X,value:n,onChange:C=>{r(C.target.value),re&&!C.target.value.startsWith("/")&&J(!1)},onKeyDown:C=>{if(C.key==="Tab"){if(xe&&ae.length>0){C.preventDefault();const B=ae[ee];B&&De(B.name)}return}if(C.key==="Enter"&&!C.shiftKey){if(C.nativeEvent.isComposing)return;if(xe&&ae.length>0){C.preventDefault();const B=ae[ee];B&&De(B.name);return}C.preventDefault(),G()}if(C.key==="Escape"){if(xe){J(!1),C.preventDefault();return}r("")}xe&&(C.key==="ArrowDown"&&(C.preventDefault(),te(B=>Math.min(B+1,ae.length-1))),C.key==="ArrowUp"&&(C.preventDefault(),te(B=>Math.max(B-1,0)))),C.key==="/"&&!C.shiftKey&&!C.ctrlKey&&!C.metaKey&&!C.altKey&&C.currentTarget.selectionStart===0&&(J(!0),p==null||p())},onPaste:C=>{var ne;const B=(ne=C.clipboardData)==null?void 0:ne.items;if(!B)return;const Q=[];for(const de of Array.from(B))if(de.kind==="file"&&de.type.startsWith("image/")){const We=de.getAsFile();We&&Q.push(We)}Q.length>0&&(C.preventDefault(),x==null||x(Q))},rows:1,style:{width:"100%",minHeight:34,maxHeight:200,overflow:"auto",overflowX:"hidden",background:"transparent",border:"none",outline:"none",resize:"none",fontFamily:M.font.sans,fontSize:"1.04em",lineHeight:1.5,color:M.color.fg,padding:"2px 0 6px",scrollbarWidth:"none",msOverflowStyle:"none"}}),e.jsx("style",{children:"textarea::-webkit-scrollbar{display:none}"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:6},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{ref:Se,title:"添加上下文",style:Y,onClick:()=>{$(C=>!C),H(!1)},children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}),D&&e.jsx("div",{ref:Ae,style:ye,onMouseDown:C=>C.stopPropagation(),children:[{icon:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),label:"添加附件",title:Fe?void 0:"当前模型不支持图片,仅可添加文本文件",action:()=>{var C;return(C=we.current)==null?void 0:C.click()}},{icon:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("path",{d:"M4 17l6-6-6-6"}),e.jsx("path",{d:"M12 19h8"})]}),label:"使用 / 选择命令或能力",action:()=>j==null?void 0:j()}].map(C=>e.jsxs("button",{title:C.title,onClick:()=>{$(!1),C.action()},style:{display:"flex",alignItems:"center",gap:10,width:"100%",height:34,padding:"0 10px",border:"none",background:"transparent",borderRadius:8,fontSize:"0.89em",color:M.color.fg,cursor:"pointer",textAlign:"left"},onMouseEnter:B=>{B.currentTarget.style.background=M.color.surface},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:[e.jsx("span",{style:{color:M.color.muted,display:"flex"},children:C.icon}),C.label]},C.label))}),e.jsx("input",{ref:we,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:C=>{const B=Array.from(C.target.files??[]);B.length>0&&(x==null||x(B)),C.target.value=""}})]}),e.jsx("div",{style:{flex:1}}),o&&e.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>oe(!0),onMouseLeave:()=>oe(!1),children:[e.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:42}}),e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 4px",borderRadius:9,cursor:"default"},children:e.jsxs("svg",{width:18,height:18,viewBox:"0 0 18 18",style:{flexShrink:0},children:[e.jsx("circle",{cx:"9",cy:"9",r:P,fill:"none",stroke:M.color.border,strokeWidth:"2.5"}),e.jsx("circle",{cx:"9",cy:"9",r:P,fill:"none",stroke:le>.9?"#E5484D":le>.7?"#B7791F":M.color.primary,strokeWidth:"2.5",strokeLinecap:"round",strokeDasharray:`${z} ${z}`,strokeDashoffset:N,transform:"rotate(-90 9 9)"})]})}),A&&e.jsxs("div",{style:{position:"absolute",bottom:34,right:0,zIndex:60,width:280,background:M.color.bg,border:`1px solid ${M.color.border}`,borderRadius:12,padding:"12px 14px",boxShadow:"0 10px 32px rgba(0,0,0,0.14)",fontSize:"0.82em",color:M.color.fg,display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{color:M.color.muted},children:"上下文容量"}),e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:o?Ce?`${Ut(Me)} / ${Ut(Ie)} (${(le*100).toFixed(2)}%)`:"未知 · 待下次响应":"—"})]}),e.jsx("div",{style:{height:6,borderRadius:3,background:M.color.border,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:Ce?`${le*100}%`:"0%",background:le>.9?"#E5484D":le>.7?"#B7791F":M.color.primary,transition:"width 0.3s"}})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{color:M.color.muted},children:"缓存命中率"}),e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:y!==void 0?`${y.toFixed(1)}%`:"—"})]})]})]}),e.jsxs("div",{ref:ze,style:{position:"relative"},children:[e.jsxs("button",{style:he,onClick:()=>{H(C=>!C),$(!1)},title:"切换模型",children:[((qe=o==null?void 0:o.model)==null?void 0:qe.split("/").pop())??K??"选择模型",e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),F&&e.jsxs("div",{style:{...ye,left:"auto",right:0,width:250,maxHeight:320,overflowY:"auto"},onMouseDown:C=>C.stopPropagation(),children:[s.length===0&&e.jsx("div",{style:{padding:"10px 12px",fontSize:"0.86em",color:M.color.muted},children:"暂无已配置模型"}),s.map(C=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.4,textTransform:"uppercase",color:M.color.muted},children:C.id}),C.models.map(B=>{const Q=(o==null?void 0:o.activeProvider)===C.id&&(o==null?void 0:o.model)===B.id;return e.jsxs("button",{onClick:()=>{i(C.id,B.id),H(!1)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:32,padding:"0 10px",border:"none",background:Q?M.color.surface:"transparent",borderRadius:8,fontSize:"0.89em",color:M.color.fg,cursor:"pointer",textAlign:"left"},onMouseEnter:ne=>{Q||(ne.currentTarget.style.background=M.color.surface)},onMouseLeave:ne=>{Q||(ne.currentTarget.style.background="transparent")},children:[e.jsx("span",{style:{fontSize:"0.79em",color:M.color.muted,flexShrink:0},children:"◆"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.name??B.id}),Q&&e.jsx("span",{style:{fontSize:"0.79em",color:M.color.primary},children:"✓"})]},B.id)})]},C.id))]})]}),e.jsxs("button",{onClick:()=>l(c==="off"?"high":"off"),title:c==="off"?"开启思考模式":"关闭思考模式",style:{display:"flex",alignItems:"center",gap:6,height:30,padding:"0 10px 0 8px",borderRadius:9,border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:"0.88em",background:c==="off"?"transparent":"rgba(99,102,241,0.10)",color:c==="off"?M.color.muted:"#6366f1",fontWeight:c==="off"?400:600,transition:"all 0.15s"},children:[e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:e.jsx("path",{d:"M12 4.5a2.5 2.5 0 0 0-4.96-.46 2.5 2.5 0 0 0-1.98 3 2.5 2.5 0 0 0-1.32 4.24 3 3 0 0 0 .34 5.58 2.5 2.5 0 0 0 2.96 3.08A2.5 2.5 0 0 0 12 19.5a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 12 4.5z"})}),c==="off"?"思考关闭":"思考中"]}),e.jsx("button",{onClick:L?I:T?O:G,title:L?"恢复待处理的弹窗":T?"停止":"发送",style:{width:38,height:38,borderRadius:"50%",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:L?M.color.warning:T?"#E8833D":"linear-gradient(135deg,#6366f1,#8b5cf6)",color:"#fff",boxShadow:L||T?"none":"0 4px 14px rgba(99,102,241,0.35)",transition:"transform 0.15s, box-shadow 0.15s"},children:L?e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}):T?e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}):e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]})]})}function gr({projects:n,value:r,onChange:t,onNewProject:o}){const s=U(),[i,l]=a.useState(!1),[c,g]=a.useState(""),u=a.useRef(null),f=a.useRef(null);a.useEffect(()=>{if(!i)return;const v=L=>{var O,K;const I=L.target;(O=f.current)!=null&&O.contains(I)||(K=u.current)!=null&&K.contains(I)||l(!1)},T=L=>{L.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",T)}},[i]);const m=n.find(v=>v.id===r),x=r?r.split(/[\\/]/).filter(Boolean).pop()??r:void 0,h=(m==null?void 0:m.name)??x??"选择项目",j=n.filter(v=>v.name.toLowerCase().includes(c.toLowerCase())),S=r!==void 0,k={display:"inline-flex",alignItems:"center",gap:6,background:S?"rgba(99,102,241,0.08)":s.color.surface,color:S?"#6366f1":s.color.muted,fontSize:"0.89em",fontWeight:S?600:500,padding:"6px 10px 6px 8px",borderRadius:9,cursor:"pointer",border:`1px solid ${S?"rgba(99,102,241,0.4)":s.color.border}`,marginBottom:-1,zIndex:2,position:"relative",transition:"background 0.15s, border-color 0.15s, color 0.15s"},p={position:"absolute",bottom:36,left:0,zIndex:20,width:325,height:275,background:s.color.bg,border:`1px solid ${s.color.border}`,borderRadius:16,boxShadow:"0 16px 48px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.05)",display:i?"flex":"none",flexDirection:"column",overflow:"hidden"};return e.jsxs("div",{style:{position:"relative",alignSelf:"flex-start",zIndex:10},children:[e.jsxs("div",{ref:u,style:k,onClick:v=>{v.stopPropagation(),l(T=>!T)},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"})}),e.jsx("span",{children:h}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:i?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),e.jsxs("div",{ref:f,style:p,onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 14px 8px",flexShrink:0},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:s.color.muted},children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{value:c,onChange:v=>g(v.target.value),placeholder:"搜索项目",style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"0.93em",color:s.color.fg}})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 6px",minHeight:0},children:j.map(v=>{const T=v.id===r;return e.jsxs("div",{onClick:()=>{t(v.id),l(!1)},style:{display:"flex",alignItems:"center",gap:10,height:36,padding:"0 10px",borderRadius:9,cursor:"pointer",fontSize:"0.93em",color:s.color.fg,background:T?s.color.surface:"transparent",opacity:v.available===!1?.45:1},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{flexShrink:0,color:s.color.muted},children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"})}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.name})]},v.id)})}),e.jsx("div",{style:{borderTop:`1px solid ${s.color.border}`,flexShrink:0,padding:4},children:e.jsxs("button",{onClick:()=>{o(),l(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"0 10px",height:36,width:"100%",border:"none",background:"transparent",borderRadius:8,fontSize:"0.93em",color:s.color.fg,cursor:"pointer"},children:[e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:s.color.muted},children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),"新建项目"]})})]})]})}const ln="vagus.picker.lastDir",an="vagus.picker.recent";function dn(){try{const n=localStorage.getItem(an);return(n?JSON.parse(n):[]).slice(0,8)}catch{return[]}}function xr(n){try{const r=dn().filter(t=>t!==n);r.unshift(n),localStorage.setItem(an,JSON.stringify(r.slice(0,8))),localStorage.setItem(ln,n)}catch{}}const mr={Desktop:"🖥️",Downloads:"📥",Documents:"📄",Pictures:"🖼️",Music:"🎵",Videos:"🎬",Home:"🏠",Root:"💿"};function yr({listDir:n,roots:r,onPick:t}){const o=U(),[s,i]=a.useState(()=>{const b=localStorage.getItem(ln);return b&&b.length>0?b:"~"}),[l,c]=a.useState([]),[g,u]=a.useState(null),[f,m]=a.useState(!0),[x,h]=a.useState(null),[j,S]=a.useState(!1),[k,p]=a.useState(""),[v,T]=a.useState({places:[],drives:[]}),[L]=a.useState(dn);a.useEffect(()=>{r().then(b=>T(b)).catch(()=>{})},[]),a.useEffect(()=>{m(!0),h(null),u(null),n(s).then(b=>{i(b.path),c(b.entries)}).catch(b=>h(String(b))).finally(()=>m(!1))},[s]),a.useEffect(()=>{const b=F=>{F.key==="Enter"&&!j&&D(),F.key==="Escape"&&t(null)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[j,s]);const I=/^[A-Za-z]:[\\/]/.test(s),O=a.useMemo(()=>s.split(/[\\/]+/).filter(Boolean),[s]);function K(b){if(I){const F=O[0];return b===0?`${F}\\`:`${F}\\${O.slice(1,b+1).join("\\")}`}return`/${O.slice(0,b+1).join("/")}`}function _(b){if(/^[A-Za-z]:[\\/]?$/.test(b))return b;const F=b.replace(/[\\/][^\\/]+$/,"");return F.length===0?"/":I&&F.length===2&&F.endsWith(":")?`${F}\\`:F}function M(b){S(!1),i(b)}function D(){const b=g??s;b&&(xr(b),t(b))}function $(){const b=k.trim();b?M(b):S(!1)}const re=_(s),J=re===s,ee={position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},te={width:640,maxHeight:"72vh",background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,boxShadow:"0 24px 64px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column",overflow:"hidden"},q={width:30,height:30,borderRadius:8,border:"none",background:"transparent",color:o.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0};return e.jsx("div",{style:ee,onMouseDown:b=>{b.target===b.currentTarget&&t(null)},children:e.jsxs("div",{style:te,onMouseDown:b=>b.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px 8px",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.96em",fontWeight:600,color:o.color.fg},children:"选择项目文件夹"}),e.jsx("button",{style:q,onClick:()=>t(null),title:"关闭",children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"0 16px 10px",flexShrink:0},children:[e.jsx("button",{style:{...q,opacity:J?.35:1,cursor:J?"default":"pointer"},disabled:J,onClick:()=>M(re),title:"上一级",children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),j?e.jsx("form",{style:{flex:1,display:"flex"},onSubmit:b=>{b.preventDefault(),$()},children:e.jsx("input",{autoFocus:!0,value:k,onChange:b=>p(b.target.value),onBlur:()=>S(!1),placeholder:"输入路径(如 ~/projects/app)",style:{flex:1,height:30,border:`1px solid ${o.color.border}`,borderRadius:8,outline:"none",padding:"0 10px",fontSize:"0.89em",background:o.color.surface,color:o.color.fg,fontFamily:"inherit"}})}):e.jsxs("div",{style:{flex:1,height:30,display:"flex",alignItems:"center",gap:2,padding:"0 10px",borderRadius:8,background:o.color.surface,border:`1px solid ${o.color.border}`,fontSize:"0.89em",color:o.color.fg,cursor:"text",overflow:"hidden",whiteSpace:"nowrap"},onClick:()=>{p(s),S(!0)},title:s,children:[e.jsx("span",{style:{color:o.color.muted,flexShrink:0},children:I?O[0]:"/"}),O.slice(I?1:0).map((b,F)=>{const H=I?F+1:F,A=H===O.length-1;return e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:2,flexShrink:0},children:[e.jsx("span",{style:{color:o.color.muted,fontSize:"0.71em"},children:"▸"}),e.jsx("span",{style:{color:A?o.color.fg:o.color.muted,fontWeight:A?500:400,cursor:A?"default":"pointer",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis"},onClick:oe=>{A||(oe.stopPropagation(),M(K(H)))},children:b})]},`${b}-${F}`)})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,borderTop:`1px solid ${o.color.border}`},children:[e.jsxs("aside",{style:{width:150,flexShrink:0,borderRight:`1px solid ${o.color.border}`,padding:"6px 4px",overflowY:"auto",display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{padding:"6px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.5,textTransform:"uppercase",color:o.color.muted},children:"位置"}),v.places.map(b=>e.jsxs("button",{onClick:()=>M(b.path),title:b.path,style:{display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px",borderRadius:8,border:"none",background:s===b.path?o.color.surface:"transparent",cursor:"pointer",fontSize:"0.89em",color:o.color.fg,textAlign:"left",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.93em",flexShrink:0},children:mr[b.name]??"📁"}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.name})]},b.path)),v.drives.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.5,textTransform:"uppercase",color:o.color.muted},children:"驱动器"}),v.drives.map(b=>e.jsxs("button",{onClick:()=>M(b.path),title:b.path,style:{display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px",borderRadius:8,border:"none",background:s===b.path?o.color.surface:"transparent",cursor:"pointer",fontSize:"0.89em",color:o.color.fg,textAlign:"left",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.93em",flexShrink:0},children:"💽"}),e.jsx("span",{children:b.name})]},b.path))]}),L.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.5,textTransform:"uppercase",color:o.color.muted},children:"最近"}),L.map(b=>e.jsxs("button",{onClick:()=>M(b),title:b,style:{display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px",borderRadius:8,border:"none",background:"transparent",cursor:"pointer",fontSize:"0.89em",color:o.color.fg,textAlign:"left",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.93em",flexShrink:0},children:"⭐"}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.split(/[\\/]/).filter(Boolean).pop()??b})]},b))]})]}),e.jsx("div",{style:{flex:1,minWidth:0,overflowY:"auto",padding:10,display:"flex",flexDirection:"column"},children:f?e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:o.color.muted,fontSize:"0.93em"},children:"加载中…"}):x?e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:"#E5484D",fontSize:"0.93em"},children:x}):l.length===0?e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:o.color.muted,fontSize:"0.93em"},children:"(空文件夹)"}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:4},children:l.map(b=>e.jsxs("div",{onClick:()=>b.isDirectory&&u(b.path),onDoubleClick:()=>b.isDirectory&&M(b.path),title:b.path,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,padding:"10px 4px",borderRadius:10,cursor:b.isDirectory?"pointer":"default",background:g===b.path?o.color.surface:"transparent",userSelect:"none",overflow:"hidden"},children:[e.jsx("span",{style:{fontSize:26,lineHeight:1},children:b.isDirectory?"📁":"📄"}),e.jsx("span",{style:{fontSize:"0.82em",color:b.isDirectory?o.color.fg:o.color.muted,textAlign:"center",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.name})]},b.path))})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"10px 16px",borderTop:`1px solid ${o.color.border}`,flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.82em",color:o.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:s,children:s}),e.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[e.jsx("button",{onClick:()=>t(null),style:{height:30,padding:"0 16px",borderRadius:8,border:`1px solid ${o.color.border}`,background:"transparent",color:o.color.muted,fontSize:"0.89em",cursor:"pointer"},children:"取消"}),e.jsxs("button",{onClick:D,disabled:!s,style:{height:30,padding:"0 16px",borderRadius:8,border:"none",background:"#3A3A3A",color:"#fff",fontSize:"0.89em",cursor:"pointer",fontWeight:500},children:["选择",g?` “${g.split(/[\\/]/).filter(Boolean).pop()??g}”`:"此文件夹"]})]})]})]})})}function ie(n,r){switch(r.type){case"clear":return[];case"toolCallStarted":return[...n,{id:r.id,kind:"tool",toolCallId:r.toolCallId,name:r.name,args:r.args,status:"running",collapsed:!0}];case"toolCallFinished":{const t=[...n];for(let o=t.length-1;o>=0;o--){const s=t[o];if(!(!s||s.kind!=="tool"||s.toolCallId!==r.toolCallId)){t[o]={...s,status:r.isError?"failed":"succeeded",result:r.result,...r.diff!==void 0?{diff:r.diff}:{},...r.patch!==void 0?{patch:r.patch}:{},collapsed:!0};break}}return t}case"thinkingDelta":{const t=n[n.length-1];if(t&&t.kind==="thinking"){const o=[...n];return o[o.length-1]={...t,text:`${t.text}${r.text}`,collapsed:!1},o}return[...n,{id:r.id,kind:"thinking",text:r.text}]}case"thinkingDone":return n;case"collapseAll":return n.map(t=>t.kind==="thinking"||t.kind==="tool"?{...t,collapsed:!0}:t);case"setCollapse":{const t=new Set(r.ids);return n.map(o=>!t.has(o.id)||o.kind!=="thinking"&&o.kind!=="tool"?o:{...o,collapsed:r.collapsed})}case"toggleCollapse":return n.map(t=>t.id!==r.id||t.kind!=="thinking"&&t.kind!=="tool"?t:{...t,collapsed:!t.collapsed});case"turnEnd":{const t=[...n];for(let o=t.length-1;o>=0;o--){const s=t[o];if(!(!s||s.kind!=="thinking"&&s.kind!=="tool")){t[o]={...s,turnDurationMs:Math.max(0,r.endedAt-r.startedAt)};break}}return t}case"historyLoaded":{const t=[];let o;for(let s=0;s<r.messages.length;s++){const i=r.messages[s],l=r.id+1+s*10,c=[];if(i.role==="user"&&!i.toolCalls&&(o=void 0,c.push({id:l+100,kind:"user",text:i.text,...i.images&&i.images.length>0?{images:i.images}:{}})),i.thinking&&(c.push({id:l,kind:"thinking",text:i.thinking,collapsed:!0}),o=t.length+c.length-1),i.toolCalls)for(let g=0;g<i.toolCalls.length;g++){const u=i.toolCalls[g];c.push({id:l+1+g,kind:"tool",toolCallId:u.id||`hist-${s}-${g}`,name:u.name,args:u.args,status:u.isError===!0?"failed":"succeeded",result:u.result,...u.diff!==void 0?{diff:u.diff}:{},...u.patch!==void 0?{patch:u.patch}:{},collapsed:!0}),o=t.length+c.length-1}if(i.role==="assistant"&&c.push({id:l+100,kind:"assistant",text:i.text}),i.role==="system"&&c.push({id:l+100,kind:"system",text:i.text}),t.push(...c),i.turnDurationMs!==void 0&&o!==void 0){const g=t[o];g&&(g.kind==="thinking"||g.kind==="tool")&&(t[o]={...g,turnDurationMs:i.turnDurationMs})}}return t}case"prependHistory":{const t=[];let o;for(let s=0;s<r.messages.length;s++){const i=r.messages[s],l=-(r.id+1+s*10),c=[];if(i.role==="user"&&!i.toolCalls&&(o=void 0,c.push({id:l+100,kind:"user",text:i.text,...i.images&&i.images.length>0?{images:i.images}:{}})),i.thinking&&(c.push({id:l,kind:"thinking",text:i.thinking,collapsed:!0}),o=t.length+c.length-1),i.toolCalls)for(let g=0;g<i.toolCalls.length;g++){const u=i.toolCalls[g];c.push({id:l+1+g,kind:"tool",toolCallId:u.id||`hist-${s}-${g}`,name:u.name,args:u.args,status:u.isError===!0?"failed":"succeeded",result:u.result,...u.diff!==void 0?{diff:u.diff}:{},...u.patch!==void 0?{patch:u.patch}:{},collapsed:!0}),o=t.length+c.length-1}if(i.role==="assistant"&&c.push({id:l+100,kind:"assistant",text:i.text}),i.role==="system"&&c.push({id:l+100,kind:"system",text:i.text}),t.push(...c),i.turnDurationMs!==void 0&&o!==void 0){const g=t[o];g&&(g.kind==="thinking"||g.kind==="tool")&&(t[o]={...g,turnDurationMs:i.turnDurationMs})}}return[...t,...n]}case"userMessageEntryId":return n.map(t=>t.id!==r.id||t.kind!=="user"?t:{...t,entryId:r.entryId});case"userMessage":return[...n,{id:r.id,kind:"user",text:r.text,...r.skillTag?{skillTag:r.skillTag}:{},...r.images&&r.images.length>0?{images:r.images}:{}}];case"assistantDelta":{const t=n[n.length-1];if(t&&t.kind==="assistant"){const o=[...n];return o[o.length-1]={...t,text:`${t.text}${r.text}`},o}return[...n,{id:r.id,kind:"assistant",text:r.text}]}case"system":return[...n,{id:r.id,kind:"system",text:r.text}];case"removeMessage":return n.filter(t=>t.id!==r.id)}}const Kt=/^(#{1,6})\s+(.*)$/,st=/^```(\w*)\s*$/,Yt=/^\s*(---+|\*\*\*+|___+)\s*$/,Je=/^\s*>\s?(.*)$/,it=/^(\s*)([-*+]|\d+\.)\s+(.*)$/,gt=/^\s*\|(.+)\|\s*$/,Jt=/^[\s:|:-]+$/;function cn(n){var s;const r=n.replace(/\r\n/g,`
3
- `).split(`
4
- `),t=[];let o=0;for(;o<r.length;){const i=r[o]??"",l=i.match(st);if(l){const f=l[1]??"",m=[];for(o+=1;o<r.length;){if(st.test(r[o]??"")){o+=1;break}m.push(r[o]??""),o+=1}t.push({type:"code",lang:f,text:m.join(`
5
- `)});continue}const c=i.match(Kt);if(c){t.push({type:"heading",level:c[1].length,content:ge(c[2]??"")}),o+=1;continue}if(Yt.test(i)){t.push({type:"hr"}),o+=1;continue}if(Je.test(i)){const f=[];for(;o<r.length&&Je.test(r[o]??"");)f.push((r[o]??"").replace(Je,"$1")),o+=1;t.push({type:"quote",content:cn(f.join(`
6
- `))});continue}const g=i.match(it);if(g){const f=/\d+\./.test(g[2]??""),m=[],x=(g[1]??"").length;for(;o<r.length;){const h=(s=r[o])==null?void 0:s.match(it),j=((h==null?void 0:h[1])??"").length,S=h!=null&&/\d+\./.test(h[2]??"");if(!h||j!==x||S!==f)break;const p=[(h[3]??"").trim()];for(;o+1<r.length;){const v=r[o+1]??"";if(v.length>0&&!/^\s*$/.test(v)&&!it.test(v)&&!Je.test(v)&&!st.test(v))p.push(v.replace(/^\s+/,"")),o+=1;else break}m.push(ge(p.join(" "))),o+=1}t.push({type:"list",ordered:f,items:m});continue}if(gt.test(i)){const f=Xt(i),m=r[o+1]??"";if(f.length>1&&Jt.test(m)&&m.includes("-")){const x=f.map(j=>ge(j)),h=[];for(o+=2;o<r.length&&gt.test(r[o]??"");)h.push(Xt(r[o]??"").map(j=>ge(j))),o+=1;t.push({type:"table",headers:x,rows:h});continue}}if(/^\s*$/.test(i)){o+=1;continue}const u=[i.trim()];for(o+=1;o<r.length;){const f=r[o]??"";if(/^\s*$/.test(f)||Kt.test(f)||st.test(f)||Yt.test(f)||Je.test(f)||it.test(f)||gt.test(f)&&(r[o+1]??"").includes("-")&&Jt.test(r[o+1]??""))break;u.push(f.trim()),o+=1}t.push({type:"paragraph",content:ge(u.join(" "))})}return t}function Xt(n){return n.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}const br=/^(https?|mailto):/i;function ge(n){const r=/(`[^`\n]+`)|(\*\*(?=\S).+?\*\*(?!\*))|(__[^_\n]+__)|(\*(?=\S)[^*\n]+?\*)|(_[^_\n\s][^_\n]*_)|(~~[^~\n]+~~)|(\[[^\]\n]+\]\([^)\n\s]+\))/g,t=[];let o=0,s;for(;(s=r.exec(n))!==null;){s.index>o&&t.push({kind:"text",text:n.slice(o,s.index)}),o=r.lastIndex;const[i,l,c,g,u,f,m,x]=s;if(l!==void 0)t.push({kind:"code",text:l.slice(1,-1)});else if(c!==void 0)t.push({kind:"bold",children:ge(c.slice(2,-2))});else if(g!==void 0)t.push({kind:"bold",children:ge(g.slice(2,-2))});else if(u!==void 0)t.push({kind:"italic",children:ge(u.slice(1,-1))});else if(f!==void 0)t.push({kind:"italic",children:ge(f.slice(1,-1))});else if(m!==void 0)t.push({kind:"strike",children:ge(m.slice(2,-2))});else if(x!==void 0){const h=x.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);if(h){const j=h[2]??"";t.push(br.test(j)?{kind:"link",href:j,children:ge(h[1]??"")}:{kind:"text",text:i})}else t.push({kind:"text",text:i})}}return o<n.length&&t.push({kind:"text",text:n.slice(o)}),t}const kr="rgba(79, 140, 255, 0.08)",vr="rgba(79, 140, 255, 0.18)",Xe=new Map,jr=4e3;function wr(n,r){const t=`${n.length}:${n}`,o=Xe.get(t);if(o)return o;const s=sr(n,r);if(Xe.size>=jr){const i=Xe.keys().next().value;i!==void 0&&Xe.delete(i)}return Xe.set(t,s),s}function me({nodes:n}){const r=U();return e.jsx(e.Fragment,{children:n.map((t,o)=>{switch(t.kind){case"text":return e.jsx(en.Fragment,{children:t.text},o);case"code":return e.jsx("code",{style:{fontFamily:r.font.mono,fontSize:"0.85em",background:kr,border:`1px solid ${vr}`,borderRadius:4,padding:"0.1em 0.35em",color:r.color.accent,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:t.text},o);case"bold":return e.jsx("strong",{style:{fontWeight:700},children:e.jsx(me,{nodes:t.children})},o);case"italic":return e.jsx("em",{children:e.jsx(me,{nodes:t.children})},o);case"strike":return e.jsx("s",{style:{opacity:.6},children:e.jsx(me,{nodes:t.children})},o);case"link":return e.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",style:{color:r.color.accent,textDecoration:"underline"},children:e.jsx(me,{nodes:t.children})},o)}})})}const Ge={margin:"0 0 10px"};function Sr({text:n,lang:r}){const{theme:t}=Qe(),o=nn(),[s,i]=a.useState(!1),l=t==="light"?rr:or,c=n.split(`
7
- `),g=async()=>{try{await navigator.clipboard.writeText(n)}catch{const u=document.createElement("textarea");u.value=n,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}i(!0),window.setTimeout(()=>i(!1),1600)};return e.jsxs("div",{style:{margin:Ge.margin,background:l.bg,border:`1px solid ${l.border}`,borderRadius:8,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 10px 5px 14px",borderBottom:`1px solid ${l.border}`,background:"linear-gradient(90deg, rgba(99,102,241,0.08), rgba(99,102,241,0.02))"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",flexShrink:0}}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78em",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",color:l.text,opacity:.75},children:r||"code"})]}),e.jsxs("button",{onClick:()=>void g(),onMouseEnter:u=>{u.currentTarget.style.opacity="1",u.currentTarget.style.background="rgba(99,102,241,0.12)",u.currentTarget.style.borderColor="rgba(99,102,241,0.45)",u.currentTarget.style.color="#6366f1"},onMouseLeave:u=>{u.currentTarget.style.opacity="0.85",u.currentTarget.style.background="transparent",u.currentTarget.style.borderColor=l.border,u.currentTarget.style.color=s?"#16a34a":l.text},style:{display:"flex",alignItems:"center",gap:5,background:"transparent",border:`1px solid ${l.border}`,color:s?"#16a34a":l.text,borderRadius:6,padding:"3px 9px",fontSize:"0.76em",cursor:"pointer",opacity:.85,transition:"all 0.15s",flexShrink:0,fontFamily:"inherit"},children:[s?e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),s?"已复制":"复制"]})]}),e.jsx("pre",{style:{margin:0,padding:"10px 14px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:o.codeFontSize,lineHeight:1.6,overflowX:o.wrapLongLines?"hidden":"auto",color:l.text,whiteSpace:o.wrapLongLines?"pre-wrap":"pre"},children:c.map((u,f)=>e.jsxs("div",{style:{display:"flex",minHeight:"1.6em"},children:[o.showLineNumbers&&e.jsx("span",{style:{width:30,flexShrink:0,textAlign:"right",marginRight:14,color:l.text,opacity:.35,userSelect:"none",fontVariantNumeric:"tabular-nums"},children:f+1}),e.jsx("span",{style:{whiteSpace:o.wrapLongLines?"pre-wrap":"pre",minWidth:0},children:wr(u,l).map((m,x)=>m.color!==void 0?e.jsx("span",{style:{color:m.color},children:m.text},x):e.jsx(en.Fragment,{children:m.text},x))})]},f))})]})}function Ir({block:n}){const{tokens:r}=Qe();switch(n.type){case"code":return e.jsx(Sr,{text:n.text,lang:n.lang});case"paragraph":return e.jsx("p",{style:Ge,children:e.jsx(me,{nodes:n.content})});case"heading":return e.jsx("div",{style:{margin:"14px 0 8px",fontWeight:700,fontSize:n.level===1?20:n.level===2?17:15,color:r.color.fg},children:e.jsx(me,{nodes:n.content})});case"list":return e.jsx("div",{style:Ge,children:n.items.map((t,o)=>n.ordered?e.jsxs("div",{style:{display:"flex",gap:8,padding:"2px 0"},children:[e.jsxs("span",{style:{color:r.color.muted,minWidth:22,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[o+1,"."]}),e.jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:e.jsx(me,{nodes:t})})]},o):e.jsxs("div",{style:{display:"flex",gap:8,padding:"2px 0"},children:[e.jsx("span",{style:{color:r.color.primary,minWidth:14},children:"•"}),e.jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:e.jsx(me,{nodes:t})})]},o))});case"quote":return e.jsx("blockquote",{style:{margin:Ge.margin,padding:"2px 0 2px 12px",borderLeft:`3px solid ${r.color.primary}`,color:r.color.muted},children:e.jsx(un,{blocks:n.content})});case"table":return e.jsx("div",{style:{margin:Ge.margin,overflowX:"auto"},children:e.jsxs("table",{style:{borderCollapse:"collapse",fontSize:13,border:`1px solid ${r.color.border}`,borderRadius:6},children:[e.jsx("thead",{children:e.jsx("tr",{children:n.headers.map((t,o)=>e.jsx("th",{style:{border:`1px solid ${r.color.border}`,padding:"6px 10px",background:r.color.surface,fontWeight:600,textAlign:"left"},children:e.jsx(me,{nodes:t})},o))})}),e.jsx("tbody",{children:n.rows.map((t,o)=>e.jsx("tr",{children:t.map((s,i)=>e.jsx("td",{style:{border:`1px solid ${r.color.border}`,padding:"5px 10px"},children:e.jsx(me,{nodes:s})},i))},o))})]})});case"hr":return e.jsx("hr",{style:{border:"none",borderTop:`1px solid ${r.color.border}`,margin:"14px 0"}})}}function un({blocks:n}){return e.jsx(e.Fragment,{children:n.map((r,t)=>e.jsx(Ir,{block:r},t))})}function Cr({text:n}){const r=a.useMemo(()=>cn(n),[n]);return e.jsx("div",{style:{overflowWrap:"anywhere",wordBreak:"break-word",minWidth:0},children:e.jsx(un,{blocks:r})})}const Mr=720,xt="#6366f1",Er="#8b5cf6";function Tr({text:n}){const r=U(),t=/剩余\s*([\d.]+)\s*K/.exec(n);return e.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"4px 0"},children:e.jsxs("div",{style:{maxWidth:Mr,width:"100%",display:"flex",alignItems:"center",gap:8,position:"relative",overflow:"hidden",background:"linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.02))",border:"1px solid rgba(99,102,241,0.14)",borderRadius:10,padding:"8px 12px 8px 16px"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,bottom:0,width:3,background:`linear-gradient(180deg, ${xt}, ${Er})`}}),e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:xt,strokeWidth:"2",style:{flexShrink:0},children:e.jsx("path",{d:"M4 9h6V3M20 15h-6v6M20 9h-6V3M4 15h6v6"})}),e.jsxs("span",{style:{color:r.color.muted,fontSize:"0.85em",lineHeight:1.5},children:[e.jsx("span",{style:{color:xt,fontWeight:600},children:"前文已摘要"}),t?e.jsxs("span",{style:{opacity:.75},children:[" · 剩余 ",t[1],"K 上下文"]}):null]})]})})}function Fr(n){let r;try{const t=JSON.parse(n);r=typeof t.file_path=="string"?t.file_path:typeof t.path=="string"?t.path:void 0}catch{}if(!r){const t=n.match(/"file_path"\s*:\s*"([^"]+)"|"path"\s*:\s*"([^"]+)"/);r=t?t[1]??t[2]:void 0}return r?Le(r):"未知文件"}function Le(n){return n.replace(/\\/g,"/").replace(/^\/mnt\/([a-zA-Z])\//,(r,t)=>`${t.toUpperCase()}:/`)}function Rr(n){let r=0,t=0;for(const o of n.split(`
8
- `)){const s=o[0];s==="+"?r+=1:s==="-"&&(t+=1)}return{added:r,removed:t}}function Dr(n){const r=[];for(const t of n)t.kind!=="tool"||!t.diff||!t.toolCallId||r.push({file:Fr(t.args),toolCallId:t.toolCallId,diff:t.diff,patch:t.patch,...Rr(t.diff)});return r}const Wr=/<skill\s+name="([^"]+)"[^>]*>\s*(?:References are relative to[^\n]*\n\n)?([\s\S]*?)<\/skill>/g;function Br({parts:n}){const r=U();return e.jsx(e.Fragment,{children:n.map((t,o)=>t.type==="skill"?e.jsxs("span",{title:`skill: ${t.name}`,style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:6,fontSize:"0.85em",background:"rgba(210,153,34,0.10)",border:"1px solid rgba(210,153,34,0.30)",color:r.color.warning,fontFamily:r.font.mono},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20V5.5a.5.5 0 0 0-.5-.5H6.5A2.5 2.5 0 0 0 4 7.5v12z"}),e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 0 6.5 22H20v-5"}),e.jsx("path",{d:"M12 6.5l.8 1.9 1.9.8-1.9.8-.8 1.9-.8-1.9-1.9-.8 1.9-.8z"})]}),t.name]},o):e.jsx("span",{children:t.text},o))})}function Lr(n){const r=n.text??"";if(n.skillTag){const o=r.replace(/^\/skill:[^\s]*\s*/,"");return{skillTag:n.skillTag,args:o,copyText:r.trim()}}const t=/<skill\s+name="([^"]+)"[^>]*>[\s\S]*?<\/skill>\s*([\s\S]*)$/.exec(r);if(t){const o=(t[2]??"").replace(/^\s*\n\s*/,"").trim();return{skillTag:t[1],args:o,copyText:`/skill:${t[1]}${o?" "+o:""}`}}return{args:r,copyText:r}}function Ar(n){const r=[];let t=0,o;const s=new RegExp(Wr.source,"g");for(;(o=s.exec(n))!==null;)o.index>t&&r.push({type:"text",text:n.slice(t,o.index)}),r.push({type:"skill",name:o[1]}),t=o.index+o[0].length;return t<n.length&&r.push({type:"text",text:n.slice(t)}),r.length>0?e.jsx(Br,{parts:r}):e.jsx(e.Fragment,{children:n})}function zr({text:n}){const r=U();return e.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"4px 0"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",borderRadius:999,border:"1px solid rgba(99,102,241,0.18)",background:"linear-gradient(135deg, rgba(99,102,241,0.07), rgba(139,92,246,0.03))",color:r.color.muted,fontSize:"0.85em"},children:[e.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:"2px solid rgba(99,102,241,0.25)",borderTopColor:"#6366f1",animation:"vagus-spin 0.8s linear infinite",display:"inline-block",flexShrink:0}}),n]})})}const mt=1e3;function fn(n){const r=[];let t=[],o=[],s=new Set;const i=()=>{t.length>0&&r.push({kind:"work",work:t});for(const c of o)r.push({kind:"item",item:c});const l=Dr(t);if(l.length>0){const c=new Map;for(const f of l){const m=c.get(f.file)??{file:f.file,added:0,removed:0};m.added+=f.added,m.removed+=f.removed,f.diff&&(m.diff=m.diff?`${m.diff}
9
- ${f.diff}`:f.diff),f.patch&&(m.patch=m.patch?`${m.patch}
10
- ${f.patch}`:f.patch),c.set(f.file,m)}const g=l[l.length-1].toolCallId,u=[...c.values()].map(f=>({...f,turnToolCallId:g}));r.push({kind:"turnSummary",files:u})}t=[],o=[],s=new Set};for(let l=0;l<n.length;l++){const c=n[l];if(c.kind==="thinking"||c.kind==="tool"){if(c.kind==="thinking"){if(s.has(c.text))continue;s.add(c.text)}t.push(c)}else if(c.kind==="assistant"){let g=!0,u=t.length>0;for(let f=l+1;f<n.length;f++){const m=n[f];if(m.kind==="user"||m.kind==="system")break;if(m.kind==="thinking"||m.kind==="tool"){u=!0,g=!1;break}if(m.kind==="assistant"){g=!1;break}}g||!u?o.push(c):t.push(c)}else i(),r.push({kind:"item",item:c})}return i(),r}function $r(n){const r=[];let t=new Set;for(const o of n)if(o.kind==="user")t=new Set,r.push(o);else if(o.kind==="thinking"){if(t.has(o.text))continue;t.add(o.text),r.push(o)}else r.push(o);return r}function Hr({item:n,onToggleCard:r,onCopy:t,onEditSubmit:o,showCopy:s,onFork:i}){const l=U(),[c,g]=a.useState(!1);if(n.kind==="user")return e.jsx(Or,{item:n,onCopy:t,onEditSubmit:o,onFork:i});if(n.kind==="assistant"){const u=()=>{const f=n.text;t?t(f):navigator.clipboard.writeText(f),g(!0),setTimeout(()=>g(!1),1800)};return e.jsx("div",{style:{display:"flex",justifyContent:"flex-start"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,maxWidth:mt,minWidth:0},children:[e.jsx("div",{style:{overflowWrap:"anywhere",wordBreak:"break-word",fontSize:"1em",lineHeight:1.65,color:l.color.fg},children:e.jsx(Cr,{text:n.text})}),s&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",minHeight:20},children:e.jsx("button",{onClick:u,title:c?"已复制":"复制回答",style:{width:26,height:26,borderRadius:6,border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit",color:c?"#16a34a":l.color.muted,transition:"color 0.15s",opacity:.4},onMouseEnter:f=>{f.currentTarget.style.opacity="1"},onMouseLeave:f=>{f.currentTarget.style.opacity="0.4"},children:c?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})})]})})}return n.kind==="thinking"?e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",maxWidth:mt,width:"100%"},children:e.jsx(Ur,{item:n,onToggle:()=>r==null?void 0:r(n.id)})}):n.kind==="tool"?e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",maxWidth:mt,width:"100%"},children:e.jsx(Kr,{item:n,onToggle:()=>r==null?void 0:r(n.id)})}):n.text.startsWith("◌ 前文已摘要")||n.text.startsWith("◔ 分支摘要")?e.jsx(Tr,{text:n.text}):n.text.startsWith("正在压缩")?e.jsx(zr,{text:n.text}):e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("span",{style:{color:l.color.muted,fontSize:"0.86em"},children:n.text})})}const wt=a.memo(Hr,(n,r)=>n.item===r.item),Pr={width:26,height:26,borderRadius:6,border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit"};function Or({item:n,onCopy:r,onEditSubmit:t,onFork:o}){const s=U(),i=Lr(n),[l,c]=a.useState(!1),[g,u]=a.useState(i.copyText),[f,m]=a.useState(!1),[x,h]=a.useState(null),j=a.useRef(null);a.useEffect(()=>{var p;l&&((p=j.current)==null||p.focus())},[l]),a.useEffect(()=>{if(x===null)return;const p=v=>{v.key==="Escape"&&h(null)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[x]);const S=()=>{r==null||r(i.copyText),m(!0),window.setTimeout(()=>m(!1),1600)},k=p=>({...Pr,color:p});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,maxWidth:"100%"},children:[l?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{ref:j,value:g,onChange:p=>u(p.target.value),rows:3,style:{width:"100%",maxWidth:520,minHeight:64,background:s.color.bg,border:"1px solid #6366f1",borderRadius:12,padding:"8px 10px",fontSize:"0.95em",lineHeight:1.5,color:s.color.fg,outline:"none",resize:"vertical",fontFamily:"inherit"}}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:()=>{c(!1),u(i.copyText)},style:{height:30,padding:"0 12px",borderRadius:8,border:`1px solid ${s.color.border}`,background:"transparent",color:s.color.muted,fontSize:"0.86em",cursor:"pointer",fontFamily:"inherit"},children:"取消"}),e.jsx("button",{onClick:()=>{g.trim()&&(t==null||t(g.trim())),c(!1)},style:{height:30,padding:"0 14px",borderRadius:8,border:"none",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",color:"#fff",fontSize:"0.86em",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"发送"})]})]}):e.jsxs(e.Fragment,{children:[n.images&&n.images.length>0&&e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",justifyContent:"flex-end",maxWidth:"70%"},children:n.images.map((p,v)=>e.jsx("img",{src:p.dataUrl,alt:"附件",style:{width:80,height:80,borderRadius:8,border:`1px solid ${s.color.border}`,objectFit:"cover",background:s.color.bg,cursor:"zoom-in"},onClick:()=>h(p.dataUrl),title:"点击查看大图"},v))}),e.jsx("div",{style:{background:s.color.surface,border:`1px solid ${s.color.border}`,borderRadius:"14px 14px 4px 14px",padding:"10px 14px",maxWidth:"70%",color:s.color.fg,whiteSpace:"pre-wrap",wordBreak:"break-word",fontSize:"1em",lineHeight:1.55},children:i.skillTag?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:6,fontSize:"0.85em",background:"rgba(210,153,34,0.10)",border:"1px solid rgba(210,153,34,0.30)",color:s.color.warning,fontFamily:s.font.mono},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20V5.5a.5.5 0 0 0-.5-.5H6.5A2.5 2.5 0 0 0 4 7.5v12z"}),e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 0 6.5 22H20v-5"}),e.jsx("path",{d:"M12 6.5l.8 1.9 1.9.8-1.9.8-.8 1.9-.8-1.9-1.9-.8 1.9-.8z"})]}),i.skillTag]}),e.jsx("span",{children:i.args})]}):n.text&&/<skill\s/.test(n.text)?Ar(n.text):i.args}),(r||t||o)&&e.jsxs("div",{style:{display:"flex",gap:4},children:[o&&e.jsx("button",{onClick:()=>o(n.id,n.text,i.copyText),title:"从此处派生新对话(创建新会话保留到此为止的上下文)",style:{...k(s.color.muted),opacity:.5,transition:"opacity 0.15s, color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.opacity="1"},onMouseLeave:p=>{p.currentTarget.style.opacity="0.5"},children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("path",{d:"M6 3v12a4 4 0 0 0 4 4h4"}),e.jsx("path",{d:"M14 19l3-3-3-3"}),e.jsx("path",{d:"M6 3a3 3 0 1 0 0 6 3 3 0 0 0 0-6z"})]})}),r&&e.jsx("button",{onClick:S,title:f?"已复制":"复制",style:{...k(f?"#16a34a":s.color.muted),transition:"color 0.15s"},children:f?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),t&&e.jsx("button",{onClick:()=>{u(i.copyText),c(!0)},title:"编辑",style:k(s.color.muted),children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M4 20h4l10-10a2.83 2.83 0 0 0-4-4L4 16v4z"})})})]})]}),x!==null&&tn.createPortal(e.jsx("div",{onClick:()=>h(null),style:{position:"fixed",inset:0,zIndex:300,background:"rgba(0,0,0,0.78)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out"},children:e.jsx("img",{src:x,alt:"查看大图",onClick:p=>p.stopPropagation(),style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:10,boxShadow:"0 12px 48px rgba(0,0,0,0.5)"}})}),document.body)]})}function _r(n){const r=n/1e3;if(r<1)return`${Math.round(n)}ms`;if(r<60)return r<10?`${r.toFixed(1)}s`:`${Math.round(r)}s`;const t=Math.floor(r/60),o=Math.round(r%60);return o===0?`${t}m`:`${t}m ${o}s`}function qr({stampedMs:n,startMs:r}){const[,t]=a.useState(0),o=n>0;a.useEffect(()=>{if(o)return;const i=window.setInterval(()=>t(l=>l+1),250);return()=>window.clearInterval(i)},[o]);const s=o?n:r!==void 0?Math.max(0,Date.now()-r):0;return s<=0?null:e.jsx(e.Fragment,{children:_r(s)})}function Nr({work:n,onToggleItem:r,live:t,startMs:o,attached:s,attachedAnchor:i}){const l=U(),[c,g]=a.useState(!1),u=a.useRef(!1),f=a.useRef(!1);if(a.useEffect(()=>{t?(u.current=!0,f.current||g(!0)):u.current&&(u.current=!1,g(!1),f.current=!1)},[t]),n.length===0)return null;const m=n.filter(p=>p.kind==="tool").length,x=n.filter(p=>p.kind==="thinking").length,h=n.reduce((p,v)=>Math.max(p,v.kind==="thinking"||v.kind==="tool"?v.turnDurationMs??0:0),0),j=h>0||o!==void 0,k=m>0?`${m} 个工具`+(x>0?` · ${x} 次思考`:""):x>0?`${x} 次思考`:"";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("button",{onClick:()=>{g(p=>{const v=!p;return v||(f.current=!0),v})},title:c?"收起工作内容":"展开工作内容",style:{display:"flex",alignItems:"center",gap:6,width:"fit-content",textAlign:"left",border:"none",background:"transparent",padding:"2px 0",cursor:"pointer",color:l.color.muted,fontSize:"0.89em"},children:[e.jsx("span",{style:{fontSize:"0.71em",color:l.color.muted,flexShrink:0,transition:"transform 0.15s",transform:c?"rotate(90deg)":"rotate(0deg)"},children:"▶"}),e.jsx("span",{style:{color:"#6366f1",fontWeight:600},children:"工作内容"}),e.jsxs("span",{style:{color:l.color.muted},children:[k,k!==""&&j&&" · ",e.jsx(qr,{stampedMs:h,startMs:o})]})]}),c&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:2},children:n.map((p,v)=>e.jsxs("div",{style:{display:"contents"},children:[e.jsx(wt,{item:p,onToggleCard:()=>r(p.id)}),s&&v===i&&s]},`w${p.id}`))})]})}const Vr=a.memo(Nr,(n,r)=>n.live===r.live&&n.startMs===r.startMs&&n.attachedAnchor===r.attachedAnchor&&n.attached===r.attached&&n.work.length===r.work.length&&n.work.every((t,o)=>t===r.work[o]));function Ur({item:n,onToggle:r}){const t=U(),o=n.collapsed===!0;return e.jsxs("button",{onClick:r,title:o?"展开思考":"收起思考",style:{display:"block",width:"100%",textAlign:"left",border:"1px solid rgba(99,102,241,0.2)",borderRadius:8,background:"linear-gradient(135deg, rgba(99,102,241,0.07), rgba(139,92,246,0.04))",padding:"8px 12px",cursor:"pointer",color:t.color.fg},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:t.color.muted,fontSize:"0.86em"},children:o?"▶":"▼"}),e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#6366f1",strokeWidth:"1.8",style:{flexShrink:0},children:e.jsx("path",{d:"M12 4.5a2.5 2.5 0 0 0-4.96-.46 2.5 2.5 0 0 0-1.98 3 2.5 2.5 0 0 0-1.32 4.24 3 3 0 0 0 .34 5.58 2.5 2.5 0 0 0 2.96 3.08A2.5 2.5 0 0 0 12 19.5a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 12 4.5z"})}),e.jsx("span",{style:{color:"#6366f1",fontSize:"0.88em",fontWeight:600,letterSpacing:"0.02em"},children:"思考"}),e.jsxs("span",{style:{marginLeft:"auto",color:t.color.muted,fontSize:"0.79em"},children:[n.text.length," chars"]})]}),!o&&e.jsx("div",{style:{marginTop:6,color:t.color.muted,fontSize:"0.86em",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:260,overflowY:"auto"},children:n.text})]})}function Kr({item:n,onToggle:r}){const t=U(),o=n.collapsed===!0,s=n.status==="succeeded"?t.color.success:n.status==="failed"?t.color.error:t.color.warning;return e.jsxs("div",{style:{border:"1px solid rgba(99,102,241,0.18)",borderRadius:8,background:"linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.03))",padding:"8px 12px",display:"flex",flexDirection:"column",gap:4,minWidth:"100%"},children:[e.jsxs("button",{onClick:r,title:o?"展开详情":"收起详情",style:{display:"flex",alignItems:"center",gap:8,background:"none",border:"none",padding:0,cursor:"pointer",color:"inherit",textAlign:"left"},children:[e.jsx("span",{style:{color:t.color.muted,fontSize:"0.86em"},children:o?"▶":"▼"}),e.jsx("span",{style:{color:s,fontSize:"0.86em"},children:"⚙"}),e.jsx("span",{style:{color:"#6366f1",fontSize:"0.93em",fontWeight:600,flexShrink:0},children:n.name}),n.args&&e.jsx("span",{style:{color:t.color.muted,fontSize:"0.79em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:n.args}),e.jsx("span",{style:{marginLeft:"auto",width:72,flexShrink:0,textAlign:"right",whiteSpace:"nowrap",fontSize:"0.86em",color:s,fontWeight:600},children:n.status==="running"?"● running":n.status==="succeeded"?"✓ done":"✗ failed"})]}),!o&&e.jsx(e.Fragment,{children:n.diff?e.jsx(hn,{diff:n.diff,t,full:!0,maxHeight:400}):n.result&&e.jsx("pre",{style:{background:t.color.bg,border:`1px solid ${t.color.border}`,borderRadius:6,padding:"8px 10px",margin:0,maxHeight:240,overflow:"auto",fontSize:"0.79em",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",color:t.color.muted},children:n.result})})]})}function Yr(n){const r=n.split(`
11
- `);return r.some(o=>o.startsWith("--- ")||o.startsWith("diff --git"))?Xr(r):Jr(r)}function Jr(n){const r=[];let t=[],o=null;for(const s of n){const i=s[0]??"",l=s.indexOf(" ",1),c=l===-1?"":s.slice(1,l).trim(),g=l===-1?s.slice(1):s.slice(l+1);if(g.trim()==="...")continue;const u=i==="+"||i==="-"?"change":"context";u!==o&&(t.length>0&&o&&r.push({kind:o,lines:t}),t=[],o=u),t.push({marker:i,lineNum:c,content:g})}return t.length>0&&o&&r.push({kind:o,lines:t}),r}function Xr(n){const r=[];let t=[],o=null,s=0,i=0;const l=()=>{t.length>0&&o&&r.push({kind:o,lines:t}),t=[],o=null};for(const c of n){if(c.startsWith("--- ")||c.startsWith("+++ ")||c.startsWith("diff --git")||c.startsWith("index ")||c.startsWith("\\"))continue;const g=c.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(g){l(),s=Number(g[1])-1,i=Number(g[2])-1;continue}const u=c[0]??"",f=u===" "||u==="+"||u==="-"?c.slice(1):c,m=u==="+"||u==="-"?"change":"context";m!==o&&(l(),o=m);let x="";u==="+"?(i++,x=String(i)):u==="-"?(s++,x=String(s)):(s++,i++,x=String(i)),t.push({marker:u,lineNum:x,content:f})}return l(),r}function hn({diff:n,t:r,maxHeight:t,full:o}){const{theme:s}=Qe(),i=s==="dark",l=a.useMemo(()=>Yr(n),[n]),c=i?{addBg:"rgba(34,197,94,0.15)",addFg:"#4ade80",addEdge:"#4ade80",delBg:"rgba(239,68,68,0.15)",delFg:"#f87171",delEdge:"#f87171",foldBg:"rgba(255,255,255,0.05)",foldFg:"#9ca3af",text:r.color.fg,numFg:"#6b7280",border:r.color.border}:{addBg:"#f0fdf4",addFg:"#16a34a",addEdge:"#16a34a",delBg:"#fef2f2",delFg:"#ef4444",delEdge:"#ef4444",foldBg:"#f3f4f6",foldFg:"#6b7280",text:"#1f2937",numFg:"#9ca3af",border:"#e5e7eb"},g=(f,m,x)=>{const h=f.marker==="+",j=f.marker==="-",S=h?c.addBg:j?c.delBg:"transparent",k=h?c.addEdge:j?c.delEdge:"transparent",p=h?c.addFg:j?c.delFg:c.numFg;return e.jsxs("div",{style:{display:"flex",whiteSpace:"pre",background:S,minWidth:"100%",borderLeft:`3px solid ${k}`,lineHeight:"26px",minHeight:26,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",color:c.text},children:[e.jsx("span",{style:{flexShrink:0,width:50,textAlign:"right",paddingRight:10,userSelect:"none",color:p},children:f.lineNum}),e.jsx("span",{style:{flexShrink:0,width:18,textAlign:"center",userSelect:"none",color:p},children:f.marker===" "?" ":f.marker}),e.jsx("span",{style:{whiteSpace:"pre",background:S},children:f.content})]},`${x}-${m}`)},u=(f,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",padding:"2px 10px",background:c.foldBg,borderRadius:6,margin:"2px 0",color:c.foldFg,fontSize:"0.75em",fontFamily:"system-ui, -apple-system, sans-serif",userSelect:"none"},children:[f," unmodified lines"]},m);return e.jsx("div",{style:{background:i?r.color.bg:"#ffffff",border:`1px solid ${c.border}`,borderRadius:8,margin:0,maxHeight:t??"none",overflowX:"auto",overflowY:t!==void 0?"auto":"hidden",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",lineHeight:"26px"},children:e.jsxs("div",{style:{width:"max-content",minWidth:"100%"},children:[l.map((f,m)=>{if(f.kind==="change")return e.jsx("div",{children:f.lines.map((x,h)=>g(x,h,`s${m}`))},`s${m}`);if(o)return null;if(!o&&f.lines.length>2){const x=[f.lines[0],f.lines[f.lines.length-1]],h=f.lines.length-2;return e.jsxs("div",{children:[g(x[0],0,`s${m}-a`),u(h,`s${m}-f`),g(x[1],1,`s${m}-b`)]},`s${m}`)}return e.jsx("div",{children:f.lines.map((x,h)=>g(x,h,`s${m}-c`))},`s${m}`)}),l.length===0&&e.jsx("div",{style:{padding:"8px 10px",color:c.numFg,fontSize:"0.85em",fontFamily:"system-ui, sans-serif"},children:"(无 diff)"})]})})}function Gr({ext:n,muted:r,accent:t}){return n==="py"?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M14.5 3.5c3.4.4 4.7 2 4.7 4.2v3.2c0 1.7-1.3 2.8-2.8 2.8h-4.2c-2.3 0-4 1.7-4 4v3.4c0 2 1 3.4 3.9 3.4h3.3",stroke:"#3776ab",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.5 20.5c-3.4-.4-4.7-2-4.7-4.2v-3.2c0-1.7 1.3-2.8 2.8-2.8h4.2c2.3 0 4-1.7 4-4V3",stroke:"#ffd43b",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"})]}):n==="md"?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M5 3.5h14a1.5 1.5 0 0 1 1.5 1.5v14a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 19V5A1.5 1.5 0 0 1 5 3.5z",stroke:t,strokeWidth:"1.5"}),e.jsx("path",{d:"M7.5 15.5v-6l2.5 2.5 2.5-2.5v6",stroke:t,strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14.5 15.5V10M14.5 12h3.5M14.5 15.5h3.5",stroke:t,strokeWidth:"1.6",strokeLinecap:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M7 3h7l5 5v13H7z",stroke:r,strokeWidth:"1.6",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 3v5h5",stroke:r,strokeWidth:"1.6",strokeLinejoin:"round"})]})}const Qr=a.memo(function({files:r,onOpenFile:t,onRevertAll:o,reverting:s,onExpand:i}){const l=U(),[c,g]=a.useState(!1);if(r.length===0)return null;const u=r.reduce((x,h)=>x+h.added,0),f=r.reduce((x,h)=>x+h.removed,0),m={height:22,padding:"0 10px",borderRadius:5,border:`1px solid ${l.color.border}`,background:l.color.surface,color:l.color.muted,fontSize:"0.72em",fontWeight:600,cursor:"pointer",fontFamily:"inherit",flexShrink:0,transition:"background 0.15s, color 0.15s, border-color 0.15s"};return e.jsxs("div",{style:{border:`1px solid ${l.color.border}`,borderRadius:8,overflow:"hidden",background:l.color.bg,fontFamily:"inherit"},children:[e.jsxs("div",{onClick:()=>{g(x=>{const h=!x;return i==null||i(h),h})},style:{display:"flex",alignItems:"center",gap:8,padding:"7px 12px",background:l.color.surface,cursor:"pointer",borderBottom:c?`1px solid ${l.color.border}`:"none",userSelect:"none"},children:[e.jsx("span",{style:{color:l.color.muted,fontSize:"0.7em",flexShrink:0,transition:"transform 0.15s",transform:c?"rotate(90deg)":"none"},children:"▶"}),e.jsxs("span",{style:{color:l.color.fg,fontSize:"0.85em",fontWeight:600,flexShrink:0},children:[r.length," 个文件已更改"]}),e.jsxs("span",{style:{color:l.color.success,fontSize:"0.8em",fontWeight:600,flexShrink:0},children:["+",u]}),e.jsxs("span",{style:{color:l.color.error,fontSize:"0.8em",fontWeight:600,flexShrink:0},children:["-",f]}),e.jsx("span",{style:{flex:1}}),e.jsx("button",{onClick:x=>{x.stopPropagation(),o()},disabled:s,title:"撤销本轮的全部更改",style:{background:"none",border:"none",cursor:s?"wait":"pointer",color:l.color.muted,fontSize:"0.78em",fontWeight:600,fontFamily:"inherit",padding:"2px 6px",borderRadius:4,flexShrink:0,opacity:s?.55:1,transition:"color 0.15s, background 0.15s"},onMouseEnter:x=>{x.currentTarget.style.background=l.color.sidebarHover,x.currentTarget.style.color=l.color.fg},onMouseLeave:x=>{x.currentTarget.style.background="none",x.currentTarget.style.color=l.color.muted},children:s?"撤销中…":"撤销"})]}),e.jsx("div",{style:{display:"grid",gridTemplateRows:c?"1fr":"0fr",transition:"grid-template-rows 0.22s ease"},children:e.jsx("div",{style:{overflow:"hidden",minHeight:0},children:e.jsx("div",{style:{padding:"3px 0",display:"flex",flexDirection:"column"},children:r.map(x=>{const h=x.file.lastIndexOf("/"),j=h>=0?x.file.slice(0,h+1):"",S=h>=0?x.file.slice(h+1):x.file,k=S.toLowerCase(),p=k.endsWith(".py")?"py":k.endsWith(".md")?"md":"other";return e.jsxs("div",{onClick:()=>t(x.file,r),title:"在右侧面板查看本轮的 diff",style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"transparent",cursor:"pointer"},onMouseEnter:v=>{v.currentTarget.style.background=l.color.sidebarHover},onMouseLeave:v=>{v.currentTarget.style.background="transparent"},children:[e.jsx(Gr,{ext:p,muted:l.color.muted,accent:l.color.accent}),e.jsxs("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.8em"},children:[e.jsx("span",{style:{color:l.color.fg,fontWeight:600},children:S}),j&&e.jsxs("span",{style:{color:l.color.muted},children:[" ",j]})]}),e.jsxs("span",{style:{color:l.color.success,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["+",x.added]}),e.jsxs("span",{style:{color:l.color.error,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["-",x.removed]}),e.jsx("button",{onClick:v=>{v.stopPropagation(),t(x.file,r)},title:"在右侧面板查看本轮的 diff",style:m,onMouseEnter:v=>{v.currentTarget.style.background=l.color.sidebarHover,v.currentTarget.style.color=l.color.fg},onMouseLeave:v=>{v.currentTarget.style.background=l.color.surface,v.currentTarget.style.color=l.color.muted},children:"审查"})]},x.file)})})})})]})},(n,r)=>{if(n.files.length!==r.files.length)return!1;for(let t=0;t<n.files.length;t++){const o=n.files[t],s=r.files[t];if(o.file!==s.file||o.added!==s.added||o.removed!==s.removed||o.turnToolCallId!==s.turnToolCallId)return!1}return!0}),_e="__welcome__";function at(){return{items:[],busy:!1,queued:[],thinkingLevel:void 0,info:void 0,historyHasMore:!1,historyTotal:0,historyStartIndex:0}}function lt(n){return n.activeId??_e}function je(n,r,t){const o=n.slots[r]??at(),s=t(o);return s===o?n:{...n,slots:{...n.slots,[r]:s}}}function Zr(n,r){switch(r.type){case"activate":return{...n,activeId:r.sessionId};case"clearActive":return{...n,activeId:void 0};case"loadHistory":return je(n,r.sessionId,t=>({...at(),items:ie([],{type:"historyLoaded",id:r.id,messages:r.messages}),info:t.info,thinkingLevel:t.thinkingLevel,historyHasMore:r.hasMore??!1,historyTotal:r.total??r.messages.length,historyStartIndex:r.startIndex??Math.max(0,(r.total??r.messages.length)-r.messages.length)}));case"prependHistory":return je(n,r.sessionId,t=>({...t,items:ie(t.items,{type:"prependHistory",id:r.id,messages:r.messages}),historyHasMore:r.hasMore,historyTotal:r.total,historyStartIndex:r.startIndex}));case"localSystem":return je(n,lt(n),t=>({...t,items:ie(t.items,{type:"system",id:r.id,text:r.text})}));case"removeMessage":return je(n,lt(n),t=>({...t,items:ie(t.items,{type:"removeMessage",id:r.id})}));case"userMessage":return je(n,r.sessionId,t=>({...t,items:ie(t.items,{type:"userMessage",id:r.id,text:r.text,...r.skillTag?{skillTag:r.skillTag}:{},...r.images&&r.images.length>0?{images:r.images}:{}})}));case"setInfo":return je(n,r.sessionId,t=>({...t,info:r.info,thinkingLevel:r.thinkingLevel??t.thinkingLevel}));case"toggleCollapse":return je(n,lt(n),t=>({...t,items:ie(t.items,{type:"toggleCollapse",id:r.id})}));case"forceIdle":return je(n,lt(n),t=>t.busy||t.turnStart!==void 0?{...t,busy:!1,turnStart:void 0}:t);case"moveWelcome":{const t=n.slots[_e];if(!t||t.items.length===0)return n;const o=n.slots[r.sessionId]??at(),s={...n.slots};return s[r.sessionId]={...o,items:[...o.items,...t.items],thinkingLevel:o.thinkingLevel??t.thinkingLevel},delete s[_e],{...n,slots:s}}case"applyEvent":{const{sessionId:t,id:o,event:s}=r;return je(n,t,i=>eo(i,o,s))}}}function eo(n,r,t){switch(t.type){case"session.turn":if(t.kind==="start")return{...n,busy:!0,turnStart:Date.now()};if(n.turnStart!==void 0){const o=ie(n.items,{type:"turnEnd",startedAt:n.turnStart,endedAt:Date.now()});return{...n,busy:!1,turnStart:void 0,items:o}}return{...n,busy:!1,turnStart:void 0};case"session.message":if(t.kind==="text_delta")return{...n,items:ie(n.items,{type:"assistantDelta",id:r,text:t.text})};if(t.kind==="text_done")return{...n,items:ie(n.items,{type:"collapseAll"})};if(t.kind==="user_queued"){const o=t.images;return{...n,items:ie(n.items,{type:"userMessage",id:r,text:t.text,...o&&o.length>0?{images:o}:{}})}}return t.kind==="error"?{...n,items:ie(n.items,{type:"system",id:r,text:`⚠ ${t.text}`})}:n;case"session.thinking":return t.kind==="delta"?{...n,items:ie(n.items,{type:"thinkingDelta",id:r,text:t.text})}:{...n,items:ie(n.items,{type:"thinkingDone",id:r})};case"session.tool_call":return{...n,items:ie(n.items,{type:"toolCallStarted",id:r,toolCallId:t.toolCallId,name:t.name,args:t.args})};case"session.tool_result":return{...n,items:ie(n.items,{type:"toolCallFinished",toolCallId:t.toolCallId,result:t.result,isError:t.isError,...t.diff!==void 0?{diff:t.diff}:{},...t.patch!==void 0?{patch:t.patch}:{}})};case"session.queue_update":{const o=t.steering??[],s=new Map;let i=0;for(const c of n.queued)s.set(c.text,c.id),c.id>i&&(i=c.id);let l=i+1;return{...n,queued:o.map(c=>({id:s.get(c)??l++,text:c}))}}case"session.subagent":{const o=t.kind,s=t.agentType?`[${t.agentType}] `:"";let i="";if(o==="created"||o==="started")i=`🧩 子代理 ${s}开始:${t.description??t.agentId??""}`;else if(o==="completed")i=`✅ 子代理 ${s}完成:${(t.result??"").slice(0,500)}`;else if(o==="failed")i=`❌ 子代理 ${s}失败:${t.error??t.result??""}`;else if(o==="steered")i=`📮 子代理 ${s}收到指示:${t.description??""}`;else if(o==="compacted")i=`🧹 子代理 ${s}已压缩上下文`;else return n;return{...n,items:ie(n.items,{type:"system",id:r,text:i})}}default:return n}}function to(){const[n,r]=a.useReducer(Zr,{activeId:void 0,slots:{}}),t=n.slots[n.activeId??_e]??at();return{state:n,dispatch:r,active:t}}const Gt=n=>1-Math.pow(1-n,3);function no(n,r){const t=a.useRef(null),o=a.useRef(!0),s=a.useRef(!1),i=a.useRef(!1),l=a.useRef(0),c=a.useRef(0),[g,u]=a.useState(!1);a.useEffect(()=>{const k=t.current;if(!k)return;const p=()=>{const v=k.scrollHeight-k.scrollTop-k.clientHeight<60;o.current=v,u(!v),i.current||(k.scrollTop<l.current?s.current=!0:v&&(s.current=!1)),l.current=k.scrollTop};return k.addEventListener("scroll",p,{passive:!0}),p(),()=>k.removeEventListener("scroll",p)},[r]),a.useEffect(()=>{c.current=0,s.current=!1;let k=0,p=0;return k=requestAnimationFrame(()=>{S(!1),p=requestAnimationFrame(()=>S(!1))}),()=>{cancelAnimationFrame(k),cancelAnimationFrame(p)}},[r]),a.useEffect(()=>{const k=c.current;c.current=n,n>k&&!s.current&&o.current&&(k===0?requestAnimationFrame(()=>{S(!1),requestAnimationFrame(()=>S(!1))}):S(!1))},[n]);const f=()=>{s.current||o.current&&S(!1)},m=(k=!0)=>{s.current||S(k)},x=(k=!0,p)=>{if(s.current=!1,p!==void 0&&p>0){const v=t.current;if(!v)return;const T=v.scrollTop;i.current=!0;const L=performance.now(),I=O=>{const K=Math.min(1,(O-L)/p),_=v.scrollHeight-v.clientHeight;v.scrollTop=T+(_-T)*Gt(K),K<1?requestAnimationFrame(I):requestAnimationFrame(()=>{i.current=!1})};requestAnimationFrame(I)}else S(k)},h=(k,p=500)=>{const v=t.current;if(!v||k===0)return;const T=v.scrollTop,L=Math.max(0,T+k);i.current=!0;const I=performance.now(),O=K=>{const _=Math.min(1,(K-I)/p);v.scrollTop=T+(L-T)*Gt(_),_<1?requestAnimationFrame(O):requestAnimationFrame(()=>{i.current=!1})};requestAnimationFrame(O)},j=()=>{c.current=0},S=k=>{const p=t.current;if(p){i.current=!0,o.current=!0;try{k?p.scrollTo({top:p.scrollHeight,behavior:"smooth"}):p.scrollTop=p.scrollHeight}finally{requestAnimationFrame(()=>{i.current=!1})}}};return{scrollRef:t,nearBottomRef:o,scrollLockedRef:s,lastItemCountRef:c,showBottomBtn:g,followStream:f,scrollToBottom:m,forceScrollToBottom:x,animatedScrollBy:h,resetSnap:j}}function ro(){const[n,r]=a.useState(""),[t,o]=a.useState([]),[s,i]=a.useState([]);return{input:n,setInput:r,attachments:t,fileAttachments:s,attachFiles:u=>{const f=[],m=[];let x=0;for(const h of u)if(h.type.startsWith("image/")){x++;const j=new FileReader;j.addEventListener("load",()=>{f.push({dataUrl:String(j.result),mimeType:h.type,name:h.name}),x-=1,x===0&&(o(S=>[...S,...f]),i(S=>[...S,...m]))}),j.readAsDataURL(h)}else{x++;const j=new FileReader;j.addEventListener("load",()=>{m.push({name:h.name,content:String(j.result)}),x-=1,x===0&&(o(S=>[...S,...f]),i(S=>[...S,...m]))}),j.readAsText(h)}x===0&&(o(h=>[...h,...f]),i(h=>[...h,...m]))},removeAttachment:u=>{const f=t.length;u<f?o(m=>m.filter((x,h)=>h!==u)):i(m=>m.filter((x,h)=>h!==u-f))},submit:u=>{const f=n.trim();if(!f&&t.length===0&&s.length===0)return;r("");const m=t;o([]);const x=s.map(j=>`<file name="${j.name}">
12
- ${j.content}
13
- </file>`).join(`
14
- `),h=[f,x].filter(Boolean).join(`
15
-
16
- `);i([]),u(h,m)}}}class oo{constructor({url:r,onOpen:t,onClose:o}){Be(this,"ws");Be(this,"listeners",new Set);Be(this,"onOpen");Be(this,"onClose");Be(this,"pendingFrames",[]);Be(this,"opened",!1);this.onOpen=t,this.onClose=o,this.ws=new WebSocket(r),this.ws.addEventListener("open",()=>{var s;this.opened=!0;for(const i of this.pendingFrames)this.ws.send(JSON.stringify(i));this.pendingFrames.length=0,(s=this.onOpen)==null||s.call(this)}),this.ws.addEventListener("message",s=>{try{const i=JSON.parse(String(s.data));for(const l of this.listeners)l(i)}catch{}}),this.ws.addEventListener("close",s=>{var i;(i=this.onClose)==null||i.call(this,s.code,s.reason)})}send(r){this.opened||this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(r)):this.pendingFrames.push(r)}onFrame(r){return this.listeners.add(r),()=>this.listeners.delete(r)}close(){this.ws.close(),this.listeners.clear()}}const so=`ws://${location.host}`;function io(n){const[r,t]=a.useState(null),o=a.useRef(null),s=a.useRef(()=>{}),i=a.useCallback(l=>{s.current=l},[]);return a.useEffect(()=>{const l=n??new oo({url:so,onOpen:()=>{}}),c=new ir(l);t(c),o.current=c;const g=c.onEvent(u=>{s.current(u)});return()=>{g(),l.close()}},[n]),{client:r,registerOnEvent:i,clientRef:o}}function lo(n,r,t,o){const[s,i]=a.useState([]),l=a.useCallback(async j=>{try{const S=await j.request("project.archived",{});Array.isArray(S)&&i(S)}catch{}},[]),c=a.useCallback(j=>{i(S=>S.filter(k=>k.dirKey!==j))},[]),g=a.useCallback(j=>{i(S=>S.map(k=>({...k,sessions:k.sessions.filter(p=>p.path!==j)})).filter(k=>k.sessions.length>0))},[]),u=a.useCallback(async j=>{if(n)try{await n.request("project.archive",{cwd:j}),l(n),r(n)}catch{}},[n,l,r]),f=a.useCallback(async j=>{if(n)try{await n.request("project.unarchive",{dirKey:j}),c(j),l(n),r(n)}catch{}},[n,l,r,c]),m=a.useCallback(async(j,S,k)=>{n&&t("彻底删除项目","将永久删除该归档会话文件,不可恢复。","彻底删除",()=>{(async()=>{try{await n.request("project.delete",{dirKey:j}),i(p=>p.filter(v=>v.dirKey!==j)),k&&S.find(p=>p.path===k)&&o(k),r(n)}catch{}})()})},[n,t,o,r]),x=a.useCallback(async j=>{n&&t("删除归档会话","将永久删除该归档会话,不可恢复。","删除",()=>{(async()=>{try{await n.request("session.deleteArchived",{sessionFile:j}),i(S=>S.map(k=>({...k,sessions:k.sessions.filter(p=>p.path!==j)})).filter(k=>k.sessions.length>0)),l(n)}catch{}})()})},[n,t,l]),h=a.useCallback(()=>{n&&t("清空全部归档",`将永久删除全部 ${s.length} 个归档项目的会话文件,不可恢复。`,"全部删除",()=>{(async()=>{try{await Promise.allSettled(s.map(j=>n.request("project.delete",{dirKey:j.dirKey}))),i([]),l(n)}catch{}})()})},[n,t,s,l]);return{archivedProjects:s,syncArchived:l,archiveProject:u,unarchiveProject:f,deleteProject:m,deleteArchivedSession:x,removeArchivedProject:c,removeArchivedSession:g,clearAllArchived:h}}function ao({items:n,scrollRef:r,activeId:t}){const o=U(),s=a.useMemo(()=>{const f=[];let m=0,x="";for(const h of n)h.kind==="user"?(f.push({msgIndex:m,question:h.text,answer:""}),x="",m++):h.kind==="assistant"&&(x=h.text,f.length>0&&(f[f.length-1].answer=x));return f},[n]),[i,l]=a.useState(null),[c,g]=a.useState(-1),u=a.useRef(null);return a.useEffect(()=>{const f=u.current;f&&(f.scrollTop=f.scrollHeight)},[t]),s.length===0?null:e.jsxs("div",{ref:u,className:"vagus-nav-scroll",style:{position:"absolute",left:6,top:"50%",transform:"translateY(-50%)",width:24,maxHeight:300,overflowY:"auto",pointerEvents:"auto",zIndex:5,display:"flex",flexDirection:"column",padding:"2px 0"},children:[s.map(({msgIndex:f,question:m,answer:x},h)=>{const j=c===-1?99:Math.abs(h-c),S=j===0?26:j===1?19:13,k=j===0?"#6366f1":j===1?"rgba(99,102,241,0.55)":o.color.border;return e.jsx("div",{onMouseDown:p=>p.preventDefault(),onMouseEnter:p=>{g(h),l({index:f,question:m,answer:x,x:p.clientX,y:p.clientY})},onMouseLeave:()=>{g(-1),l(null)},onClick:p=>{var L;p.preventDefault(),p.stopPropagation();const v=document.activeElement;v instanceof HTMLElement&&v.blur();const T=(L=r.current)==null?void 0:L.querySelector(`[data-msg-index="${f}"]`);T&&T.scrollIntoView({behavior:"smooth",block:"start"})},style:{height:15,flexShrink:0,display:"flex",alignItems:"center",cursor:"pointer",pointerEvents:"auto"},children:e.jsx("div",{style:{width:S,height:3,borderRadius:2,background:k,transition:"width 0.15s, background 0.15s",flexShrink:0}})},f)}),i&&tn.createPortal(e.jsxs("div",{style:{position:"fixed",left:i.x+18,top:Math.max(8,Math.min(i.y-12,window.innerHeight-80)),zIndex:1e3,pointerEvents:"none",background:o.color.surface,border:`1px solid ${o.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:"0.78em",color:o.color.fg,maxWidth:300,lineHeight:1.5,boxShadow:"0 8px 24px rgba(0,0,0,0.15)"},children:[e.jsx("div",{style:{wordBreak:"break-word"},children:i.question.length>60?`${i.question.slice(0,60)}…`:i.question||"(空消息)"}),e.jsx("div",{style:{marginTop:6,color:o.color.muted,wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:i.answer.replace(/\s+/g," ")||"(暂无回答)"})]}),document.body)]})}function pn(n){const r=U(),{theme:t}=Qe(),[o,s]=a.useState(!1),i=n.variant==="welcome",l=t==="light"?"#ffffff":r.color.surface;return e.jsx("div",{className:"vagus-input-card",style:{background:l,border:`1px solid ${i&&o?"rgba(99,102,241,0.55)":r.color.border}`,borderRadius:i?22:18,boxShadow:i?o?"0 8px 40px rgba(99,102,241,0.12), 0 0 0 4px rgba(99,102,241,0.08)":"0 6px 28px rgba(0,0,0,0.05)":void 0,transition:"border-color 0.2s ease, box-shadow 0.2s ease",animation:i&&!o?"vagus-breath 3s ease-in-out infinite":void 0,display:"flex",flexDirection:"column",padding:i?"20px 24px 14px":"14px 18px 10px"},onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseDown:c=>{c.target.closest("button, input, textarea, select, [contenteditable], [role='button']")||c.preventDefault()},children:e.jsx(pr,{value:n.value,onChange:n.onChange,onSubmit:n.onSubmit,usage:n.usage,providers:n.providers,onSwitchModel:n.onSwitchModel,onSetThinking:n.onSetThinking,thinkingLevel:n.thinkingLevel,permissionMode:n.permissionMode,onTogglePermission:n.onTogglePermission,attachments:n.attachments,fileAttachments:n.fileAttachments,onAttach:n.onAttach,onRemoveAttachment:n.onRemoveAttachment,busy:n.busy,onStop:n.onStop,selectedModel:n.selectedModel,onCommand:n.onCommand,commands:n.commands,onPickCommand:n.onPickCommand,onRefreshCommands:n.onRefreshCommands,focusSignal:n.focusSignal,hasPendingDialog:n.hasPendingDialog,onRestoreDialog:n.onRestoreDialog,queuedMessages:n.queuedMessages})})}const co={confirm:"确认",select:"请选择",input:"输入"};function Qt({card:n,onRespond:r}){var f;const t=U(),{event:o}=n,[s,i]=a.useState(""),l=a.useRef(null);a.useEffect(()=>{var m;o.method==="input"&&n.status==="pending"&&((m=l.current)==null||m.focus())},[o.method,n.status]);const c=n.result?n.result.cancelled?"已取消":n.result.confirmed?"已确认":n.result.value??"":"",g=n.status==="answered",u={height:34,padding:"0 14px",borderRadius:9,fontSize:"0.9em",cursor:g?"default":"pointer",fontFamily:"inherit"};return e.jsxs("div",{style:{maxWidth:520,margin:"10px 0 6px",background:g?t.color.bg:t.color.surface,border:`1px solid ${g?t.color.border:t.color.primary}`,borderRadius:14,padding:"14px 16px",boxShadow:g?"none":"0 2px 12px rgba(0,0,0,0.12)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:g?8:10},children:[e.jsx("span",{style:{fontSize:"0.72em",fontWeight:700,letterSpacing:"0.04em",padding:"2px 8px",borderRadius:999,background:g?"transparent":t.color.primary,color:g?t.color.muted:"#fff",border:g?`1px solid ${t.color.border}`:"none"},children:o.method.toUpperCase()}),e.jsx("span",{style:{fontSize:"0.95em",fontWeight:600,color:t.color.fg},children:o.title??co[o.method]??o.method})]}),o.message&&e.jsx("div",{style:{fontSize:"0.92em",color:t.color.fg,lineHeight:1.6,whiteSpace:"pre-wrap",marginBottom:g?0:12},children:o.message}),g?e.jsxs("div",{style:{fontSize:"0.88em",color:t.color.muted,background:t.color.bg,border:`1px solid ${t.color.border}`,borderRadius:8,padding:"6px 10px",display:"inline-block"},children:["你的回答:",c||"—"]}):o.method==="select"?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,maxHeight:300,overflowY:"auto",marginBottom:4},children:[(o.options??[]).map(m=>e.jsx("button",{onClick:()=>r({value:m}),style:{...u,width:"100%",textAlign:"left",height:38,padding:"0 14px",border:`1px solid ${t.color.border}`,background:"transparent",color:t.color.fg},onMouseEnter:x=>{x.currentTarget.style.background=t.color.bg},onMouseLeave:x=>{x.currentTarget.style.background="transparent"},children:m},m)),((f=o.options)==null?void 0:f.length)===0&&e.jsx("div",{style:{fontSize:"0.86em",color:t.color.muted,padding:"12px 4px"},children:"(没有可用选项)"})]}):o.method==="input"?e.jsx("div",{style:{marginBottom:4},children:e.jsx("input",{ref:l,value:s,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&r({value:s})},placeholder:o.placeholder??"输入…",style:{width:"100%",height:38,padding:"0 12px",borderRadius:9,border:`1px solid ${t.color.border}`,background:t.color.bg,color:t.color.fg,fontSize:"0.92em",outline:"none",fontFamily:"inherit"}})}):null,!g&&e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:6},children:[e.jsx("button",{onClick:()=>r({cancelled:!0}),style:{...u,border:`1px solid ${t.color.border}`,background:"transparent",color:t.color.fg},children:"取消"}),o.method==="confirm"&&e.jsx("button",{onClick:()=>r({confirmed:!0}),style:{...u,border:"none",background:t.color.primary,color:"#fff",fontWeight:600},children:"确认"}),o.method==="input"&&e.jsx("button",{onClick:()=>r({value:s}),disabled:s.trim().length===0,style:{...u,border:"none",background:t.color.primary,color:"#fff",fontWeight:600,opacity:s.trim().length===0?.4:1,cursor:s.trim().length===0?"not-allowed":"pointer"},children:"确定"})]})]})}function uo(n){const r=U(),{items:t,busy:o,turnStartTs:s,autoscroll:i}=n,{scrollRef:l,showBottomBtn:c}=i,g=n.uiCards??[],u=g.filter(k=>k.status==="pending").map(k=>k.event.id).join(","),[f,m]=a.useState("");a.useEffect(()=>{if(u.length>0&&u!==f){m(u);const k=l.current;if(!k)return;const p=k.querySelectorAll('[data-uicard-status="pending"]'),v=p[p.length-1];if(!v)return;const T=k.getBoundingClientRect(),L=v.getBoundingClientRect(),I=L.bottom-T.bottom;if(I<=0&&L.top>=T.top)return;const O=72,K=I>0?I+O:L.top-T.top-O;i.animatedScrollBy(K,750)}},[u,i]),a.useEffect(()=>{const k=l.current,p=n.onLoadMore;if(!k||!p)return;const v=()=>{k.scrollTop<200&&!n.loadingMore&&p()};return k.addEventListener("scroll",v,{passive:!0}),()=>k.removeEventListener("scroll",v)});const x=a.useRef(0),h=a.useRef(0);a.useLayoutEffect(()=>{const k=l.current;if(!k)return;const p=x.current,v=t.length>h.current;if(h.current=t.length,v&&p>0&&k.scrollTop<400){const T=k.scrollHeight-p;T>300&&(k.scrollTop+=T)}x.current=k.scrollHeight});const j=a.useMemo(()=>fn($r(t)),[t]),S=a.useMemo(()=>{const k=new Map,p=new Map;let v=0,T=-1,L=-1;for(let _=0;_<j.length;_++){const M=j[_];if(M.kind==="item"&&M.item.kind==="user"){v++;continue}if(M.kind==="work"){T=_,p.has(v)||p.set(v,_);for(const D of M.work)D.kind==="tool"&&D.toolCallId&&k.set(D.toolCallId,_);M.work.some(D=>D.kind==="tool")&&(L=_)}}const I=new Map,O=new Set;for(const _ of g){const M=_.event;let D=M.toolCallId?k.get(M.toolCallId):void 0;if(D===void 0&&(D=M.turn===void 0?void 0:p.get(M.turn)),D===void 0&&(D=L>=0?L:T>=0?T:void 0),D!==void 0){const $=I.get(D)??[];$.push(_),I.set(D,$),O.add(_.event.id)}}const K=g.filter(_=>!O.has(_.event.id));return{byIdx:I,unmatched:K}},[j,g]);return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,position:"relative"},children:[e.jsxs("header",{style:{flexShrink:0,display:"flex",alignItems:"center",gap:10,height:54,padding:"0 24px",background:r.color.bg,borderBottom:`1px solid ${r.color.border}`},children:[n.sessionName?e.jsx("span",{style:{fontSize:"0.92em",fontWeight:600,color:r.color.fg,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"38%"},children:n.sessionName}):null,n.sessionName&&n.sessionCwd?e.jsx("span",{style:{color:r.color.border,flexShrink:0,fontSize:"0.85em"},children:"|"}):null,n.sessionCwd?e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,color:r.color.muted,fontSize:"0.85em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",style:{flexShrink:0},children:[e.jsx("path",{d:"M7 3h7l5 5v13H7z",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 3v5h5",strokeLinejoin:"round"})]}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:n.sessionCwd})]}):null]}),e.jsx("main",{ref:l,style:{flex:1,overflowY:"auto",minHeight:0,padding:"28px 0"},children:e.jsxs("div",{style:{maxWidth:n.wide?1280:1050,margin:"0 auto",padding:"0 28px",display:"flex",flexDirection:"column",gap:6},children:[n.loadingMore&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,justifyContent:"center",padding:"10px 0",color:r.color.muted,fontSize:"0.82em"},children:[e.jsx("span",{style:{width:12,height:12,borderRadius:"50%",border:`2px solid ${r.color.border}`,borderTopColor:r.color.primary,animation:"vagus-spin 0.8s linear infinite",display:"inline-block"}}),"加载更早消息…"]}),t.length===0&&(n.showLoading?e.jsx("div",{style:{color:r.color.muted,fontSize:"1em",textAlign:"center",marginTop:40},children:"加载会话…"}):n.sessionLoading?null:e.jsx("div",{style:{color:r.color.muted,fontSize:"1em",textAlign:"center",marginTop:40},children:"已连接 · 输入消息开始新会话"})),(()=>{var _;let k=-1;for(let M=t.length-1;M>=0;M--)if(t[M].kind==="user"){k=M;break}let p;for(let M=t.length-1;M>k;M--){const D=t[M];if(D.kind==="thinking"||D.kind==="tool"){p=D;break}}const v=o&&p!==void 0?j.find(M=>M.kind==="work"&&M.work.some(D=>D.id===(p==null?void 0:p.id))):void 0,T=[];let L=0,I=0;const O={contentVisibility:"auto",containIntrinsicSize:"auto 120px"},K=new Set;{let M;for(const D of j)D.kind==="item"?D.item.kind==="assistant"?M=D.item.id:D.item.kind==="user"&&M!==void 0&&(K.add(M),M=void 0):(D.kind==="work"||D.kind==="turnSummary")&&(M!==void 0&&K.add(M),M=void 0);M!==void 0&&K.add(M)}for(const M of j){if(M.kind==="item"){const D=M.item;D.kind==="user"?T.push(e.jsx("div",{"data-msg-index":I++,style:{maxWidth:"100%",...O},children:e.jsx(wt,{item:D,onToggleCard:n.onToggleCard,onCopy:n.copyMessage,onEditSubmit:n.editSubmit,onFork:n.onFork})},`g${L}`)):T.push(e.jsx("div",{style:O,children:e.jsx(wt,{item:D,onToggleCard:n.onToggleCard,onCopy:n.copyMessage,onEditSubmit:n.editSubmit,onFork:n.onFork,showCopy:D.kind==="assistant"&&K.has(D.id)&&!o})},`g${L}`))}else if(M.kind==="turnSummary")T.push(e.jsx("div",{style:O,children:e.jsx(Qr,{files:M.files,onOpenFile:n.onOpenFile,onRevertAll:()=>n.onRevertAll(M.files.map(D=>D.file)),onExpand:D=>{D&&n.autoscroll.forceScrollToBottom(!0,400)}})},`t${L}`));else{const{work:D}=M,$=((_=D[0])==null?void 0:_.id)??L,re=M===v,J=S.byIdx.get(L)??[],ee=J.length>0?J.map((q,b)=>e.jsx("div",{"data-uicard-id":q.event.id,"data-uicard-status":q.status,children:e.jsx(Qt,{card:q,onRespond:F=>{var H;return(H=n.onUiCardRespond)==null?void 0:H.call(n,q,F)}})},`uicardwrap-${q.event.id??b}`)):void 0;let te=-1;if(J.length>0){for(let q=M.work.length-1;q>=0;q--)if(M.work[q].kind==="tool"){te=q;break}}T.push(e.jsx("div",{style:O,children:e.jsx(Vr,{work:D,onToggleItem:q=>n.onToggleCard(q),live:re,startMs:s,attached:ee,attachedAnchor:te>=0?te:void 0})},`w${$}`))}L++}return e.jsx(e.Fragment,{children:T})})(),S.unmatched.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.unmatched.map((k,p)=>e.jsx("div",{"data-uicard-id":k.event.id,"data-uicard-status":k.status,children:e.jsx(Qt,{card:k,onRespond:v=>{var T;return(T=n.onUiCardRespond)==null?void 0:T.call(n,k,v)}})},`uicardwrap-${k.event.id??p}`))}),o&&t.length>0&&t[t.length-1].kind==="user"&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 0",color:r.color.muted,fontSize:"0.88em"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",animation:"vagus-pulse 1.2s ease-in-out infinite",display:"inline-block"}}),"等待响应…"]}),e.jsx("div",{})]})}),e.jsx(ao,{items:t,scrollRef:l,activeId:n.activeId}),c&&e.jsx("button",{onClick:()=>i.forceScrollToBottom(),title:"回到底部",style:{position:"absolute",right:18,bottom:96,zIndex:6,width:36,height:36,borderRadius:"50%",background:r.color.surface,border:`1px solid ${r.color.border}`,color:r.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",transition:"background 0.15s, color 0.15s",fontFamily:"inherit"},onMouseEnter:k=>{k.currentTarget.style.background=r.color.sidebarHover,k.currentTarget.style.color=r.color.fg},onMouseLeave:k=>{k.currentTarget.style.background=r.color.surface,k.currentTarget.style.color=r.color.muted},children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})}),e.jsx("div",{style:{padding:"10px 28px 10px",background:r.color.bg,flexShrink:0},children:e.jsxs("div",{style:{maxWidth:n.wide?1180:960,margin:"0 auto"},children:[(()=>{const k=Object.entries(n.aboveEditorStatuses??{}).filter(([,v])=>v.length>0),p=Object.entries(n.aboveEditorWidgets??{}).filter(([,v])=>v.lines.length>0);return k.length===0&&p.length===0?null:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:[k.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"},children:k.map(([v,T])=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 12px",borderRadius:999,background:r.color.surface,border:`1px solid ${r.color.border}`,fontSize:"0.8em",color:r.color.fg},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:r.color.primary}}),e.jsx("span",{style:{color:r.color.muted,fontWeight:600},children:v}),e.jsx("span",{children:T})]},v))}),p.map(([v,T])=>e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 10px",fontSize:"0.8em",color:r.color.muted,alignItems:"center"},children:T.lines.map((L,I)=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:L},I))},v))]})})(),e.jsx(pn,{...n.inputCard,variant:"chat"})]})})]})}function fo(n){const r=U();return e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,justifyContent:"center"},children:e.jsxs("div",{style:{width:"100%",maxWidth:n.wide?900:760,margin:"0 auto",padding:"32px 28px",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:22,userSelect:"none"},children:[e.jsx("div",{style:{width:46,height:46,borderRadius:14,background:"linear-gradient(135deg,#6366f1,#8b5cf6)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:21,fontWeight:700,boxShadow:"0 6px 24px rgba(99,102,241,0.35)"},children:"◈"}),e.jsx("div",{style:{fontSize:"1.4em",fontWeight:700,color:r.color.fg,marginTop:12,letterSpacing:"-0.01em"},children:"vagusPI"}),e.jsx("div",{style:{fontSize:"0.92em",color:r.color.muted,marginTop:5},children:"你的编码智能体工作台 —— 发送第一条消息开始新的对话"})]}),e.jsx(gr,{projects:n.projects,value:n.activeProject,onChange:n.onSelectProject,onNewProject:n.onNewProject}),e.jsxs("div",{style:{marginTop:10},children:[(()=>{const t=Object.entries(n.aboveEditorStatuses??{}).filter(([,s])=>s.length>0),o=Object.entries(n.aboveEditorWidgets??{}).filter(([,s])=>s.lines.length>0);return t.length===0&&o.length===0?null:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:[t.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"},children:t.map(([s,i])=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 12px",borderRadius:999,background:r.color.surface,border:`1px solid ${r.color.border}`,fontSize:"0.8em",color:r.color.fg},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:r.color.primary}}),e.jsx("span",{style:{color:r.color.muted,fontWeight:600},children:s}),e.jsx("span",{children:i})]},s))}),o.map(([s,i])=>e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 10px",fontSize:"0.8em",color:r.color.muted,alignItems:"center",justifyContent:"center"},children:i.lines.map((l,c)=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:l},c))},s))]})})(),e.jsx(pn,{...n.inputCard,variant:"welcome"})]})]})})}function ho({state:n,onClose:r}){const t=U();return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center"},onMouseDown:o=>{o.target===o.currentTarget&&r()},children:e.jsxs("div",{style:{width:380,maxWidth:"calc(100vw - 48px)",background:t.color.surface,border:`1px solid ${t.color.border}`,borderRadius:16,padding:"20px 22px",boxShadow:"0 24px 80px rgba(0,0,0,0.35)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,fontSize:"1.02em",fontWeight:600,color:"#E5484D"},children:[e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"})}),n.title]}),e.jsx("div",{style:{fontSize:"0.92em",color:t.color.muted,margin:"12px 0 22px",lineHeight:1.6},children:n.message}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:r,style:{height:34,padding:"0 16px",borderRadius:9,border:`1px solid ${t.color.border}`,background:"transparent",color:t.color.fg,fontSize:"0.9em",cursor:"pointer",fontFamily:"inherit"},children:"取消"}),e.jsx("button",{onClick:()=>{const o=n.onConfirm;r(),o()},style:{height:34,padding:"0 16px",borderRadius:9,border:"none",background:"#E5484D",color:"#fff",fontSize:"0.9em",fontWeight:600,cursor:"pointer",fontFamily:"inherit",boxShadow:"0 2px 10px rgba(229,72,77,0.35)"},children:n.confirmLabel})]})]})})}function po(n){const r=U(),{tabs:t,activeId:o,collapsed:s,onActivate:i,onClose:l,onToggleCollapse:c,render:g,width:u=380,onWidthChange:f}=n,m=14,[x,h]=a.useState(!1),j=a.useRef(null),S=p=>{if(s)return;p.preventDefault(),j.current={startX:p.clientX,startW:u},h(!0);const v=L=>{if(!j.current)return;const I=j.current.startX-L.clientX,O=Math.min(900,Math.max(260,j.current.startW+I));f==null||f(O)},T=()=>{j.current=null,h(!1),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",T)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",T)},k=t.find(p=>p.id===o)??t[0]??null;return e.jsx("aside",{style:{width:s?m:u,flexShrink:0,minWidth:0,borderLeft:`1px solid ${r.color.border}`,background:r.color.bg,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",transition:"width 0.3s cubic-bezier(0.25, 1, 0.5, 1)"},children:s?e.jsx("div",{onClick:c,title:"展开右侧面板",style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",userSelect:"none",background:r.color.surface,color:"#6366f1",transition:"background 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="rgba(99,102,241,0.1)"},onMouseLeave:p=>{p.currentTarget.style.background=r.color.surface},children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}):e.jsxs("div",{style:{flex:1,display:"flex",minHeight:0},children:[e.jsx("div",{onMouseDown:S,title:"拖动调整宽度",style:{width:4,flexShrink:0,cursor:"col-resize",background:x?"rgba(99,102,241,0.25)":"transparent",transition:"background 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="rgba(99,102,241,0.15)"},onMouseLeave:p=>{p.currentTarget.style.background=x?"rgba(99,102,241,0.25)":"transparent"}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,padding:"0 6px",background:r.color.bg,borderBottom:`1px solid ${r.color.border}`,flexShrink:0,height:54,overflowX:"auto",scrollbarWidth:"none"},children:[t.map(p=>{const v=k!==null&&p.id===k.id;return e.jsxs("div",{onClick:()=>i(p.id),style:{display:"flex",alignItems:"center",gap:6,height:36,padding:"0 14px 0 20px",borderRadius:9,background:v?r.color.surface:"transparent",cursor:"pointer",userSelect:"none",flexShrink:0,maxWidth:220,transition:"background 0.15s"},onMouseEnter:T=>{v||(T.currentTarget.style.background=r.color.surface)},onMouseLeave:T=>{v||(T.currentTarget.style.background="transparent")},children:[p.icon,e.jsx("span",{style:{fontSize:"0.9em",fontWeight:v?600:500,color:v?r.color.fg:r.color.muted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.label}),e.jsx("button",{onClick:T=>{T.stopPropagation(),l(p.id)},title:`关闭 ${p.label}`,style:{width:17,height:17,borderRadius:5,border:"none",background:"transparent",color:r.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,fontFamily:"inherit",opacity:v?.85:.45,transition:"background 0.15s, color 0.15s, opacity 0.15s"},onMouseEnter:T=>{T.currentTarget.style.background=r.color.sidebarHover,T.currentTarget.style.color=r.color.fg,T.currentTarget.style.opacity="1"},onMouseLeave:T=>{T.currentTarget.style.background="transparent",T.currentTarget.style.color=r.color.muted,T.currentTarget.style.opacity=v?"0.8":"0.4"},children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.6",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]},p.id)}),e.jsx("div",{style:{flex:1}})]}),e.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden",background:r.color.bg},children:k?g(k):e.jsx("div",{style:{height:"100%"}})})]}),e.jsx("div",{onClick:c,title:"收起右侧面板",style:{width:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:r.color.surface,borderLeft:`1px solid ${r.color.border}`,cursor:"pointer",userSelect:"none",color:r.color.muted,transition:"background 0.15s, color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="rgba(99,102,241,0.12)",p.currentTarget.style.color="#6366f1"},onMouseLeave:p=>{p.currentTarget.style.background=r.color.surface,p.currentTarget.style.color=r.color.muted},children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})})]})})}const Zt={id:"diff",label:"审阅",icon:e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 12l3 3 3-6 4 9 3-5 2 2"})})};function go({items:n,selected:r,turnId:t,expandedFiles:o,onOpenChange:s}){const i=U(),l=a.useMemo(()=>{if(!t)return[];const x=fn(n);for(let h=x.length-1;h>=0;h--){const j=x[h];if(j.kind==="turnSummary"&&j.files.some(S=>S.turnToolCallId===t))return j.files}return[]},[t,n]),[c,g]=a.useState(()=>{const x=new Set;if(o!==void 0)for(const h of o)l.some(j=>Le(j.file)===Le(h))&&x.add(h);else l.length>0&&x.add(l[0].file);return x}),u=x=>[...c].some(h=>Le(h)===Le(x)),f=x=>{const h=new Set(c);u(x)?h.delete([...h].find(j=>Le(j)===Le(x))):h.add(x),g(h),s==null||s(h.size>0?[...h]:void 0)},m=e.jsx("div",{style:{height:"100%"}});return l.length===0?m:e.jsx("div",{style:{display:"flex",flexDirection:"column",padding:"6px 0"},children:l.map((x,h)=>{const j=x.file.lastIndexOf("/"),S=j>=0?x.file.slice(0,j+1):"",k=j>=0?x.file.slice(j+1):x.file,p=u(x.file),v=xo(x.diff??"");return e.jsxs("div",{style:{borderBottom:h<l.length-1?`1px solid ${i.color.border}20`:"none"},children:[e.jsxs("div",{onClick:()=>f(x.file),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",cursor:"pointer",userSelect:"none",background:h%2===1?i.color.surface:"transparent"},onMouseEnter:T=>{T.currentTarget.style.background=i.color.sidebarHover},onMouseLeave:T=>{T.currentTarget.style.background=h%2===1?i.color.surface:"transparent"},children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:i.color.success,strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:"transform 0.15s",transform:p?"rotate(90deg)":"none"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsxs("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.8em"},children:[e.jsx("span",{style:{color:i.color.muted},children:S}),e.jsx("span",{style:{color:i.color.fg,fontWeight:700},children:k})]}),e.jsxs("span",{style:{color:i.color.success,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["+",v.added]}),e.jsxs("span",{style:{color:i.color.error,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["-",v.removed]})]}),e.jsx("div",{style:{display:"grid",gridTemplateRows:p?"1fr":"0fr",transition:"grid-template-rows 0.22s ease"},children:e.jsx("div",{style:{overflow:"hidden",minHeight:0},children:e.jsx("div",{style:{padding:"2px 8px 8px",background:i.color.bg},children:x.diff?e.jsx(hn,{diff:x.diff,t:i}):e.jsx("div",{style:{color:i.color.muted,fontSize:"0.78em",padding:6},children:"该轮无 diff"})})})})]},x.file)})})}function xo(n){let r=0,t=0;for(const o of n.split(`
17
- `))o.startsWith("+")&&!o.startsWith("+++")?r+=1:o.startsWith("-")&&!o.startsWith("---")&&(t+=1);return{added:r,removed:t}}const mo={id:"widget",label:"面板",icon:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18M3 12h18"})]})};function yo({widgets:n}){const r=U(),t=Object.entries(n).filter(([,o])=>o.lines.length>0);return t.length===0?e.jsx("div",{style:{padding:"16px 18px",fontSize:"0.86em",color:r.color.muted},children:"(没有活动的面板)"}):e.jsx("div",{style:{padding:"10px 14px",display:"flex",flexDirection:"column",gap:10,fontFamily:r.font.mono,fontSize:"0.82em",lineHeight:1.6,color:r.color.fg},children:t.map(([o,s])=>e.jsx("div",{style:{background:r.color.bg,border:`1px solid ${r.color.border}`,borderRadius:10,padding:"8px 10px"},children:s.lines.map((i,l)=>e.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i},l))},o))})}const yt="cubic-bezier(0.25, 1, 0.5, 1)";function bo({state:n}){const r=U(),t=n==="ok"?r.color.success:n==="partial"?r.color.warning:r.color.error,o=n==="ok"?["M20 6L9 17l-5-5"]:n==="partial"?["M12 9v4","M12 17h.01","M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"]:["M18 6L6 18","M6 6l12 12"];return e.jsx("div",{style:{width:44,height:44,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:`${t}1f`,color:t},children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:o.map(s=>e.jsx("path",{d:s},s))})})}function ko({result:n}){const r=U(),t=n.file.lastIndexOf("/"),o=t>=0?n.file.slice(0,t+1):"",s=t>=0?n.file.slice(t+1):n.file;return e.jsxs("div",{style:{padding:"7px 10px",borderRadius:8,background:n.ok?"transparent":`${r.color.error}0d`,fontFamily:"inherit"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.82em"},children:[e.jsx("span",{style:{color:r.color.muted},children:o}),e.jsx("span",{style:{color:r.color.fg,fontWeight:500},children:s})]}),n.ok?e.jsx("span",{style:{flexShrink:0,color:r.color.success,fontSize:"0.72em",fontWeight:600,whiteSpace:"nowrap"},children:"✓ 已回退"}):e.jsx("span",{style:{flexShrink:0,color:r.color.error,fontSize:"0.72em",fontWeight:600,whiteSpace:"nowrap"},children:"✗ 回退失败"})]}),!n.ok&&n.error&&e.jsx("div",{style:{marginTop:4,color:r.color.error,fontSize:"0.7em",lineHeight:1.5,whiteSpace:"normal",wordBreak:"break-word"},children:n.error})]})}function vo({report:n,onClose:r}){const t=U(),[o,s]=a.useState(!1),i=n.results.filter(h=>h.ok).length,l=n.results.length-i,c=l===0?"ok":i===0?"fail":"partial",g=new Map;for(const h of n.results){const j=g.get(h.file);g.set(h.file,{ok:((j==null?void 0:j.ok)??!0)&&h.ok,error:h.ok?j==null?void 0:j.error:h.error??(j==null?void 0:j.error)})}const u=[...g.entries()].map(([h,j])=>({file:h,...j}));a.useEffect(()=>{const h=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(h)},[]),a.useEffect(()=>{const h=j=>{j.key==="Escape"&&r()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[r]);const f=c==="ok"?t.color.success:c==="partial"?t.color.warning:t.color.error,m=c==="ok"?`已回退 ${i} 个文件`:c==="partial"?"回退部分失败":"回退失败",x=c==="ok"?"所有改动已还原到编辑前状态":c==="partial"?`成功 ${i} 个 · 失败 ${l} 个`:l===1?"1 个文件未还原":`${l} 个文件未还原`;return e.jsx("div",{onClick:r,style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.45)",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",opacity:o?1:0,transition:`opacity 0.25s ${yt}`,fontFamily:t.font.sans},children:e.jsxs("div",{onClick:h=>h.stopPropagation(),style:{width:500,maxWidth:"calc(100vw - 40px)",background:t.color.surface,border:`1px solid ${t.color.border}`,borderRadius:14,boxShadow:"0 24px 60px rgba(0, 0, 0, 0.45)",padding:"20px 22px 18px",opacity:o?1:0,transform:o?"none":"translateY(10px) scale(0.97)",transition:`opacity 0.3s ${yt}, transform 0.3s ${yt}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx(bo,{state:c}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:t.color.fg,fontSize:"1.02em",fontWeight:700},children:m}),e.jsx("button",{onClick:r,"aria-label":"关闭",style:{marginLeft:"auto",width:26,height:26,borderRadius:7,border:"none",background:"transparent",color:t.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit",flexShrink:0,transition:"background 0.15s, color 0.15s"},onMouseEnter:h=>{h.currentTarget.style.background=t.color.bg,h.currentTarget.style.color=t.color.fg},onMouseLeave:h=>{h.currentTarget.style.background="transparent",h.currentTarget.style.color=t.color.muted},children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]}),e.jsx("div",{style:{color:t.color.muted,fontSize:"0.82em",marginTop:2},children:x}),e.jsx("div",{style:{height:2,background:`linear-gradient(90deg, ${f}, transparent)`,borderRadius:2,marginTop:10,opacity:.5}})]})]}),u.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2,marginTop:14,maxHeight:240,overflowY:"auto"},children:u.map(h=>e.jsx(ko,{result:h},h.file))}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:18},children:e.jsx("button",{onClick:r,style:{height:32,padding:"0 18px",borderRadius:8,border:"none",background:`linear-gradient(135deg, ${t.color.primary}, #6366f1)`,color:"#fff",fontSize:"0.84em",fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"filter 0.15s"},onMouseEnter:h=>{h.currentTarget.style.filter="brightness(1.1)"},onMouseLeave:h=>{h.currentTarget.style.filter="none"},children:"关闭"})})]})})}function jo(n){const{activeId:r,hasEdits:t}=n,[o,s]=a.useState([]),[i,l]=a.useState(void 0),[c,g]=a.useState(!1),[u,f]=a.useState(420),[m,x]=a.useState(new Set),[h,j]=a.useState(void 0),[S,k]=a.useState(void 0),[p,v]=a.useState(void 0),[T,L]=a.useState(!1),I="vagus.rightPanel.v1",O="vagus.rightPanel.review.v1",K=b=>{try{const F=localStorage.getItem(O),A=(F?JSON.parse(F):{})[b];return{turnId:A==null?void 0:A.turnId,selected:A==null?void 0:A.selected,open:A==null?void 0:A.open}}catch{return{}}},_=(b,F,H,A)=>{try{const oe=localStorage.getItem(O),X=oe?JSON.parse(oe):{};X[b]={turnId:F,selected:H,open:A},localStorage.setItem(O,JSON.stringify(X))}catch{}},M=b=>{try{const F=localStorage.getItem(I),A=(F?JSON.parse(F):{})[b];return{collapsed:(A==null?void 0:A.collapsed)===!0,width:(A==null?void 0:A.width)??420,activeTab:A==null?void 0:A.activeTab,diffClosed:(A==null?void 0:A.diffClosed)===!0,has:A!==void 0}}catch{return{collapsed:!0,width:420,has:!1}}},D=(b,F)=>{try{const H=localStorage.getItem(I),A=H?JSON.parse(H):{};A[b]=F,localStorage.setItem(I,JSON.stringify(A))}catch{}},$="vagus.rightPanel.handled.v2",re=b=>{try{const F=localStorage.getItem($),H=F?JSON.parse(F):{};return new Set(Array.isArray(H[b])?H[b]:[])}catch{return new Set}},J=(b,F)=>{try{const H=localStorage.getItem($),A=H?JSON.parse(H):{};A[b]=[...F],localStorage.setItem($,JSON.stringify(A))}catch{}};a.useLayoutEffect(()=>{if(!r)return;const b=M(r);f(b.width),g(b.has?b.collapsed:!0),b.activeTab!==void 0&&l(b.activeTab),L(b.diffClosed===!0);const F=K(r);k(F.turnId||void 0),v(Array.isArray(F.open)?F.open:void 0),F.selected&&j(F.selected),x(re(r))},[r]),a.useEffect(()=>{r&&D(r,{collapsed:c,width:u,activeTab:i,diffClosed:T})},[c,u,i,T,r]),a.useEffect(()=>{r&&J(r,m)},[m,r]),a.useEffect(()=>{t?T||(s(b=>b.some(F=>F.id==="diff")?b:[...b,Zt]),l(b=>b??"diff")):(s(b=>b.some(F=>F.id==="diff")?b.filter(F=>F.id!=="diff"):b),l(b=>b==="diff"?void 0:b))},[t,T]);const ee=a.useCallback((b,F)=>{var A;L(!1),j(b);const H=(A=F==null?void 0:F[0])==null?void 0:A.turnToolCallId;k(H),v([b]),r&&_(r,H,b,[b]),g(!1),s(oe=>oe.some(X=>X.id==="diff")?oe:[...oe,Zt]),l("diff")},[r]),te=a.useCallback(b=>{b==="diff"&&L(!0),s(F=>F.filter(H=>H.id!==b)),l(F=>F===b?void 0:F)},[]),q=a.useCallback(b=>{v(b),r&&S&&_(r,S,h??(b==null?void 0:b[0])??"",b??[])},[r,S,h]);return{rightTabs:o,rightTabId:i,rightCollapsed:c,rightPanelWidth:u,handledFiles:m,diffSelection:h,reviewTurnId:S,reviewOpen:p,setRightTabs:s,setRightTabId:l,setRightCollapsed:g,setRightPanelWidth:f,setHandledFiles:x,setDiffSelection:j,setReviewOpen:q,openFileDiff:ee,closeRightTab:te}}function wo(n){const{client:r,registerOnEvent:t,dispatch:o,nextId:s,activeId:i,autoscroll:l,followAnswerRef:c,effects:g}=n,u=()=>{c!=null&&c.current&&(c.current=!1,l.scrollToBottom(!0))},f=a.useRef({sessionId:"",text:"",raf:null}),m=()=>{const S=f.current;if(!S.text)return;const k=S.text,p=S.sessionId;S.text="",S.raf=null,o({type:"applyEvent",sessionId:p,id:s(),event:{type:"session.message",sessionId:p,kind:"text_delta",text:k}}),u(),l.followStream()},x=(S,k)=>{const p=f.current;p.sessionId!==S&&(p.raf!==null&&cancelAnimationFrame(p.raf),p.text="",p.sessionId=S),p.text+=k,p.raf===null&&(p.raf=requestAnimationFrame(m))},h=()=>{const S=f.current;S.raf!==null&&(cancelAnimationFrame(S.raf),S.raf=null),S.text&&m()};t(S=>{var v,T,L;const k=r;if(!k)return;const p=i!==void 0&&S.sessionId===i;switch(S.type){case"session.created":g.fetchSessionInfo(k,S.sessionId,{updateActivePath:!1}),g.refreshHistory(k);return;case"session.turn":S.kind==="end"&&h(),o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S}),p&&S.kind==="end"&&(g.fetchSessionInfo(k,S.sessionId),g.refreshHistory(k),k.request("usage.stats",{}).then(I=>g.setUsageStats(I)).catch(()=>{}));return;case"session.message":if(S.kind==="user_queued"&&/<skill\s+name="/.test(S.text)){const I=(v=/<skill\s+name="([^"]+)"/.exec(S.text))==null?void 0:v[1],O=(T=g.shiftSkillText)==null?void 0:T.call(g);o({type:"userMessage",sessionId:S.sessionId,id:s(),text:O??S.text,...I?{skillTag:I}:{}})}else S.kind==="text_delta"?x(S.sessionId,S.text):S.kind==="text_done"?(h(),o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S})):o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S});p&&(S.kind==="user_queued"||S.kind==="error")&&l.scrollToBottom(!1);return;case"session.thinking":o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S}),p&&S.kind==="delta"&&(u(),l.followStream());return;case"session.tool_call":case"session.tool_result":o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S}),p&&S.type==="session.tool_call"&&g.fetchSessionInfo(k,S.sessionId);return;case"session.queue_update":o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S});return;default:S.type==="ui.request"&&((L=g.onUiRequest)==null||L.call(g,S));return}})}function So(n){const[r,t]=a.useState([]),o=a.useCallback(async()=>{if(n)try{const c=await n.request("models.config");Array.isArray(c)&&t(c)}catch{}},[n]),s=a.useCallback(async c=>{if(n)try{await n.request("models.save",{providers:c}),o()}catch{}},[n,o]),i=a.useCallback(async c=>{if(!n)return{ok:!1};try{return await n.request("models.test",c)}catch{return{ok:!1}}},[n]),l=a.useMemo(()=>r.filter(c=>c.enabled!==!1),[r]);return{modelsConfig:r,enabledProviders:l,refreshModels:o,saveModels:s,testModel:i}}const Io=a.lazy(()=>rn(()=>import("./settings-V9zrDr2c.js").then(n=>n.i),__vite__mapDeps([0,1])).then(n=>({default:n.SettingsView}))),Co=a.lazy(()=>rn(()=>import("./settings-V9zrDr2c.js").then(n=>n.i),__vite__mapDeps([0,1])).then(n=>({default:n.PluginsView}))),Mo=n=>{navigator.clipboard.writeText(n).catch(()=>{})},bt=n=>n.trim().replace(/\s+/g," "),Oe=[{type:"builtin",name:"compact",description:"压缩上下文,摘要历史对话,腾出上下文空间"},{type:"builtin",name:"reload",description:"重新加载扩展、技能、提示词(装包后让 agent 感知新能力)"}];function Eo({transport:n}){var Ot,_t;const r=U(),{client:t,registerOnEvent:o}=io(n),{state:s,dispatch:i,active:l}=to(),c=no(l.items.length,s.activeId),g=ro(),u=l.items.some(d=>d.kind==="tool"&&d.diff!==void 0),[f,m]=a.useState(null),{rightTabs:x,rightTabId:h,rightCollapsed:j,rightPanelWidth:S,diffSelection:k,reviewTurnId:p,reviewOpen:v,setRightTabs:T,setRightTabId:L,setRightCollapsed:I,setRightPanelWidth:O,setReviewOpen:K,openFileDiff:_,closeRightTab:M}=jo({activeId:s.activeId,hasEdits:u}),D=a.useRef(0),$=()=>++D.current,re=a.useRef(0),J=a.useRef(0),ee=a.useRef(void 0),te=d=>{re.current++;const w=re.current;ee.current!==void 0&&clearTimeout(ee.current),ee.current=setTimeout(()=>{ee.current=void 0,t&&Rt(t,d,w)},80)},[q,b]=a.useState([]),[F,H]=a.useState(),[A,oe]=a.useState(!1),[X,we]=a.useState(!1),[Se,Ae]=a.useState("appearance"),[ze,ue]=a.useState(null),[Ie,Fe]=a.useState(new Set),[Re,Ce]=a.useState(null),[Me,le]=a.useState({}),y=Me[s.activeId??""]??Me.global??[],[P,z]=a.useState(null),N=a.useRef(null),[Y,he]=a.useState({}),[ye,G]=a.useState({}),xe=a.useRef([]),$e=a.useMemo(()=>{const d={};for(const[w,E]of Object.entries(ye))E.lines.length>0&&(!E.sessionId||E.sessionId===s.activeId)&&(d[w]={lines:E.lines});return d},[ye,s.activeId]),ae=a.useMemo(()=>{const d={};for(const[w,E]of Object.entries(ye))E.placement==="aboveEditor"&&E.lines.length>0&&(!E.sessionId||E.sessionId===s.activeId)&&(d[w]={lines:E.lines});return d},[ye,s.activeId]);a.useEffect(()=>{Object.keys($e).length>0?(T(w=>w.some(E=>E.id==="widget")?w:[...w,mo]),L(w=>w??"widget")):(T(w=>w.some(E=>E.id==="widget")?w.filter(E=>E.id!=="widget"):w),L(w=>w==="widget"?void 0:w))},[$e]);const[De,He]=a.useState(),[Ze,qe]=a.useState(!1),[C,B]=a.useState(Oe),[Q,ne]=a.useState(0),de=a.useRef(!1);a.useEffect(()=>{if(A||X){de.current=!0;return}de.current&&(de.current=!1,ne(d=>d+1))},[A,X]);const[We,St]=a.useState(!1),[xn,mn]=a.useState("ask"),[Ee,dt]=a.useState(void 0),[et,It]=a.useState(!1),[yn,tt]=a.useState(!1),[Ct,Mt]=a.useState(null),[Et,Tt]=a.useState(!1),Ne=a.useRef(new Map),ct="vagus.lastSession",Ft=a.useRef(!1),Ve=So(t),ut=a.useCallback((d,w,E,R)=>{Ce({title:d,message:w,confirmLabel:E,onConfirm:R})},[]),{modelsConfig:bn,enabledProviders:Ue}=Ve;a.useEffect(()=>{if(!s.activeId&&!Ee&&Ue.length>0&&Ue[0].models.length>0){const d=Ue[0];dt({providerId:d.id,modelId:d.models[0].id})}},[s.activeId,Ee,Ue]);const se=a.useCallback(async d=>{try{const w=await d.request("session.history",{});if(Array.isArray(w)){const E=w;b(E);for(const R of E)R.id&&R.path&&Ne.current.set(R.id,R.path)}}catch{}},[]),pe=lo(t,se,ut,d=>{F===d&&(i({type:"activate",sessionId:void 0}),H(void 0))}),{archivedProjects:kn}=pe;a.useEffect(()=>{if(!et){tt(!1);return}const d=window.setTimeout(()=>tt(!0),300);return()=>window.clearTimeout(d)},[et]);const Ke=(d,w,E)=>{d.request("session.info",{sessionId:w}).then(R=>{var Z;const W=R;W!=null&&W.sessionFile&&(Ne.current.set(w,W.sessionFile),(E==null?void 0:E.updateActivePath)!==!1&&H(W.sessionFile)),typeof((Z=W==null?void 0:W.contextUsage)==null?void 0:Z.tokens)=="number"&&Mt(null),i({type:"setInfo",sessionId:w,info:W,thinkingLevel:W==null?void 0:W.thinkingLevel})}).catch(()=>{})},Rt=async(d,w,E)=>{const R=E??++re.current,W=new Map;for(const V of q)W.set(V.path,V.id);const Z=W.get(w),ce=Z?s.slots[Z]:void 0;if(Z&&ce&&ce.items.length>0){H(w),c.resetSnap(),i({type:"activate",sessionId:Z}),Ke(d,Z),se(d),ne(V=>V+1);return}J.current++,It(!0),i({type:"clearActive"}),tt(!0);try{H(w);const V=await d.request("session.open",{sessionFile:w,limit:200}),ke=V.sessionId;if(R!==re.current){const Pe=s.slots[ke];(!Pe||Pe.items.length===0)&&i({type:"loadHistory",sessionId:ke,id:$(),messages:V.messages,hasMore:V.hasMore,total:V.total,startIndex:V.startIndex});return}const nt=s.slots[ke];(!nt||nt.items.length===0)&&i({type:"loadHistory",sessionId:ke,id:$(),messages:V.messages,hasMore:V.hasMore,total:V.total,startIndex:V.startIndex}),c.resetSnap(),i({type:"activate",sessionId:ke}),V.sessionFile&&H(V.sessionFile),Ke(d,ke),se(d),ne(Pe=>Pe+1)}catch(V){i({type:"localSystem",id:$(),text:`无法打开会话: ${V instanceof Error?V.message:String(V)}`})}finally{J.current--,J.current<=0&&(J.current=0,It(!1),tt(!1))}},ft=a.useRef(!1),[vn,Dt]=a.useState(!1),jn=a.useCallback(async()=>{if(!t||!s.activeId||ft.current)return;const d=s.activeId,w=s.slots[d];if(!(w!=null&&w.historyHasMore)||!w.historyStartIndex||w.items.length===0)return;ft.current=!0,Dt(!0);const E=Ne.current.get(d)??F;try{const R=await t.request("session.page",{sessionFile:E,limit:200,beforeIndex:w.historyStartIndex});i({type:"prependHistory",sessionId:d,id:$(),messages:R.messages,hasMore:R.hasMore,total:R.total,startIndex:R.startIndex})}catch{}finally{ft.current=!1,Dt(!1)}},[t,s.activeId,s.slots,F]),Wt=a.useRef(!0);a.useEffect(()=>{if(Wt.current){Wt.current=!1;return}try{F?localStorage.setItem(ct,F):localStorage.removeItem(ct)}catch{}},[F]),a.useEffect(()=>{if(!t||Ft.current)return;Ft.current=!0;let d;try{d=localStorage.getItem(ct)??void 0}catch{d=void 0}d&&(async()=>{try{await Rt(t,d)}catch{}})()},[t]);const wn=d=>{switch(d){case"compact":return Vn(),!0;case"reload":return z({text:"正在重新加载扩展与技能…",type:"info"}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>z(null),2500),t&&s.activeId&&t.request("session.reload",{sessionId:s.activeId}).then(()=>{ht(),z({text:"✅ 已重新加载扩展与技能",type:"info"}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>z(null),2500)}).catch(w=>{z({text:`reload 失败:${w instanceof Error?w.message:String(w)}`,type:"error"}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>z(null),4e3)}),!0;default:return!1}},Bt=(d,w)=>{d.trim().startsWith("/skill:")&&xe.current.push(d.trim()),t&&(async()=>{var E;try{const R=d.split(/\s+/)[0]??"";if(R.startsWith("/")&&wn(R.slice(1)))return;let W=s.activeId;if(!W||W===_e){if(W=(await t.request("session.create",{cwd:De??void 0})).sessionId,(E=s.slots[_e])!=null&&E.items.length&&i({type:"moveWelcome",sessionId:W}),i({type:"activate",sessionId:W}),Ke(t,W),Ee){try{await t.request("session.model.set",{sessionId:W,providerId:Ee.providerId,modelId:Ee.modelId})}catch{}dt(void 0)}se(t)}await t.request("session.prompt",{sessionId:W,text:d,images:w}),se(t)}catch(R){i({type:"forceIdle"}),i({type:"localSystem",id:$(),text:`error: ${R instanceof Error?R.message:String(R)}`})}})()},Sn=d=>{Bt(d,[])},Lt=a.useRef(()=>{}),In=a.useCallback((d,w,E)=>{ut("派生新会话",`从这条消息开始创建一条新的会话,原会话保持不变。
18
- 新会话只包含到此为止的上下文。`,"确认派生",()=>{Lt.current(w,E)})},[ut]),Cn=a.useCallback(async(d,w)=>{const E=t,R=s.activeId;if(!(!E||!R)){z({text:"正在派生新会话…",type:"info"}),N.current&&clearTimeout(N.current);try{const W=await E.request("session.forkPoints",{sessionId:R}),Z=(W??[]).findLast(ve=>bt(ve.text)===bt(d));if(!Z){const ve=(W??[]).slice(0,3).map(ot=>JSON.stringify(ot.text.slice(0,60))).join(", ");z({text:`未找到匹配的派生点 (${(W??[]).length} 个点,样本: ${ve})`,type:"error"}),console.log("[fork] match failed. user text:",JSON.stringify(d),"| normText:",bt(d)),console.log("[fork] first 3 fork points:",(W??[]).slice(0,3).map(ot=>({id:ot.entryId,text:ot.text.slice(0,80)})));return}const ce=await E.request("session.fork",{sessionId:R,entryId:Z.entryId});if(!(ce!=null&&ce.sessionId)){z({text:"派生失败:daemon 未返回新会话",type:"error"});return}const V=q.find(ve=>ve.id===R||ve.path===F),ke=(V==null?void 0:V.name)||(V==null?void 0:V.firstMessage)||"新会话",nt=q.filter(ve=>(ve.name||ve.firstMessage||"").startsWith(ke)).length,Pe=`${ke} (${nt+1})`;try{await E.request("session.renameFile",{sessionFile:ce.sessionFile,name:Pe})}catch{}se(E);const rt=await E.request("session.open",{sessionFile:ce.sessionFile,limit:200});i({type:"loadHistory",sessionId:ce.sessionId,id:$(),messages:rt.messages,hasMore:rt.hasMore,total:rt.total,startIndex:rt.startIndex}),i({type:"activate",sessionId:ce.sessionId}),H(ce.sessionFile),se(E),c.resetSnap(),g.setInput(w),z({text:"✅ 新会话已派生,可编辑消息后发送",type:"info"}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>z(null),2500)}catch(W){console.log("[fork] failed:",String(W)),z({text:`派生失败:${W instanceof Error?W.message:String(W)}`,type:"error"}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>z(null),4e3)}}},[t,s.activeId,i,se,H,c,q,F,z,N,g]);Lt.current=Cn;const Mn=a.useCallback(async d=>{if(!(!t||!s.activeId||d.length===0))try{const w=await t.request("tool.revertBatch",{sessionId:s.activeId,files:d}),E=((w==null?void 0:w.results)??[]).map(R=>({file:R.file,toolCallId:R.file,ok:R.ok,error:R.error}));m({results:E})}catch(w){console.log("[frontend revertBatch catch]",String(w)),m({results:d.map(E=>({file:E,toolCallId:E,ok:!1,error:w instanceof Error?w.message:String(w)}))})}},[t,s.activeId,m]),En=()=>{c.resetSnap(),i({type:"activate",sessionId:void 0}),H(void 0),ne(d=>d+1)},Tn=async(d,w)=>{if(t)try{await t.request("session.renameFile",{sessionFile:d,name:w}),se(t)}catch{}},Fn=async d=>{if(t)try{const w=q.find(E=>E.path===d);await t.request("session.delete",{sessionFile:d,sessionId:w==null?void 0:w.id}),F===d&&(i({type:"activate",sessionId:void 0}),H(void 0)),se(t)}catch{}},Rn=async d=>{if(t)try{await t.request("session.archive",{sessionFile:d}),b(w=>w.filter(E=>E.path!==d)),F===d&&(i({type:"activate",sessionId:void 0}),H(void 0)),se(t),pe.syncArchived(t)}catch{}},Dn=async d=>{if(t)try{await t.request("session.restore",{sessionFile:d}),pe.removeArchivedSession(d),se(t),pe.syncArchived(t)}catch{}},Wn=async d=>{if(t)try{const w=Ie.has(d);await t.request("session.pin",{sessionFile:d,pinned:!w}),Fe(E=>{const R=new Set(E);return w?R.delete(d):R.add(d),R}),se(t)}catch{}},Bn=a.useMemo(()=>{const d=new Set,w=[];for(const E of q){if(d.has(E.cwd))continue;d.add(E.cwd);const R=E.cwd.replace(/\\/g,"/").split("/").filter(Boolean);w.push({id:E.cwd,name:R[R.length-1]??E.cwd,available:!0})}return w},[q]),Ln=a.useMemo(()=>{const d=new Set;for(const[w,E]of Object.entries(s.slots))if(E.busy){const R=Ne.current.get(w);R&&d.add(R)}return d},[s.slots]),An=((Ot=l.info)==null?void 0:Ot.model)??(Ee==null?void 0:Ee.modelId),zn=d=>{if(d.method==="widgetLines"){G(E=>{const R=d.widgetKey??"";if(!R)return E;const W={...E};if(!d.lines||d.lines.length===0)delete W[R];else{const Z=Array.isArray(d.lines)?d.lines:String(d.lines??"").split(`
19
- `);W[R]={lines:Z,placement:d.placement??"aboveEditor",sessionId:d.sessionId}}return W});return}if(d.method==="setStatus"){he(E=>{const R=d.statusKey??"";if(!R)return E;const W={...E};return d.statusText==null?delete W[R]:W[R]=d.statusText,W});return}if(d.method==="notify"){z({text:d.message??d.title??"",type:d.notifyType??"info"}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>z(null),3500);return}if(!t)return;const w=d.sessionId??"global";le(E=>({...E,[w]:[...E[w]??[],{event:d,sessionId:d.sessionId,status:"pending"}]}))},At=a.useRef(!1),$n=(d,w)=>{const E=d.sessionId??"global";le(R=>({...R,[E]:(R[E]??[]).map(W=>W.event.id===d.event.id?{...W,status:"answered",result:w}:W)})),At.current=!0,t==null||t.request("ui.respond",{id:d.event.id,...w}).catch(()=>{})};wo({client:t,registerOnEvent:o,followAnswerRef:At,dispatch:i,nextId:$,activeId:s.activeId,autoscroll:c,effects:{fetchSessionInfo:Ke,refreshHistory:se,setUsageStats:ue,onUiRequest:zn,shiftSkillText:()=>xe.current.shift()}}),a.useEffect(()=>{t&&(t.request("ping").then(()=>{}).catch(()=>{}),Ve.refreshModels(),t.request("usage.stats",{}).then(d=>ue(d)).catch(()=>{}),t.request("session.pins").then(d=>{Array.isArray(d)&&Fe(new Set(d))}).catch(()=>{}),t.request("ui.widgets",{}).then(d=>{const w=d;if(w){const E={};for(const[R,W]of Object.entries(w))W!=null&&W.lines&&W.lines.length>0&&(E[R]={lines:W.lines,placement:W.placement==="belowEditor"?"belowEditor":"aboveEditor",sessionId:W.sessionId});G(E)}}).catch(()=>{}),t.request("ui.pending",{}).then(d=>{const w=d;if(w&&w.length>0){const E={};for(const R of w){const W=R.request,Z=W.sessionId??"global";E[Z]=[...E[Z]??[],{event:W,sessionId:W.sessionId,status:"pending"}]}le(E)}}).catch(()=>{}),t.request("ui.history",{}).then(d=>{const w=d;w&&le(E=>{const R={...E};for(const[W,Z]of Object.entries(w)){const ce=Z.map(V=>({event:V.request,sessionId:V.request.sessionId,status:"answered",result:V.result}));R[W]=[...R[W]??[],...ce]}return R})}).catch(()=>{}),pe.syncArchived(t),se(t))},[t]),a.useEffect(()=>{const d=w=>{if(w.target.closest("textarea, input, button, [role='menu'], [role='menuitem'], [contenteditable]"))return;const R=document.activeElement;R instanceof HTMLElement&&R.blur()};return document.addEventListener("mousedown",d,!0),()=>document.removeEventListener("mousedown",d,!0)},[]);const Hn=d=>{He(d),localStorage.setItem("vagus.activeProject",d)};a.useEffect(()=>{const d=localStorage.getItem("vagus.activeProject");d&&He(d)},[]);const Pn=async d=>{if(qe(!1),!(!d||!t)){He(d),localStorage.setItem("vagus.activeProject",d);try{const w=await t.request("session.create",{cwd:d});i({type:"activate",sessionId:w.sessionId}),se(t),ne(E=>E+1)}catch{}}},On=async(d,w)=>{if(dt({providerId:d,modelId:w}),s.activeId&&i({type:"setInfo",sessionId:s.activeId,info:l.info?{...l.info,model:w,activeProvider:d}:void 0}),!(!t||!s.activeId))try{await t.request("session.model.set",{sessionId:s.activeId,providerId:d,modelId:w})}catch{}},_n=()=>{!t||!s.activeId||t.request("session.abort",{sessionId:s.activeId}).catch(()=>{})},qn=()=>{!t||!s.activeId||t.request("session.abortCompaction",{sessionId:s.activeId}).catch(()=>{})},Nn=async d=>{if(s.activeId&&i({type:"setInfo",sessionId:s.activeId,info:l.info,thinkingLevel:d}),!(!t||!s.activeId))try{await t.request("session.thinking.set",{sessionId:s.activeId,level:d})}catch{}},Vn=async()=>{if(!t||!s.activeId)return;const d=s.activeId,w=$();Tt(!0),i({type:"localSystem",id:w,text:"正在压缩上下文…"});try{const E=await t.request("session.compact",{sessionId:d});i({type:"removeMessage",id:w});const R=E==null?void 0:E.estimatedTokensAfter,W=typeof R=="number"&&R>0?`${(R/1e3).toFixed(1)}K`:"";Mt(typeof R=="number"?R:null),i({type:"localSystem",id:$(),text:`◌ 前文已摘要${W?` · 剩余 ${W} 上下文`:""}`}),Ke(t,d),t.request("usage.stats",{}).then(Z=>ue(Z)).catch(()=>{})}catch(E){i({type:"removeMessage",id:w});const R=E instanceof Error?E.message:String(E),W=R.includes("Nothing to compact")||R.includes("Already compacted")?"上下文还没大到需要压缩(会话内容太少,或刚刚已经压缩过)":`压缩失败:${R}`;i({type:"localSystem",id:$(),text:W})}finally{Tt(!1)}},Un=async()=>t?await t.request("project.roots",{}):{places:[],drives:[]},Kn=async d=>t?await t.request("project.listDir",{dir:d}):{path:d,entries:[]},zt=async()=>{if(!t)return Oe;try{const d=await t.request("commands.list",{sessionId:s.activeId??void 0});return[...Oe,...(d.extensions??[]).map(w=>({type:"extension",name:w.name,description:w.description??""})),...(d.templates??[]).map(w=>({type:"template",name:w.name,description:w.description??""})),...(d.skills??[]).map(w=>({type:"skill",name:`skill:${w.name}`,description:w.description??""}))]}catch{return Oe}};a.useEffect(()=>{t&&zt().then(B).catch(()=>B(Oe))},[t,s.activeId]);const ht=()=>{zt().then(B).catch(()=>B(Oe))},Yn=d=>{St(!1),d&&g.setInput(w=>`${w}${d} `)},$t={value:g.input,onChange:g.setInput,onSubmit:()=>g.submit((d,w)=>{c.forceScrollToBottom(!1,750),Bt(d,w)}),usage:l.info?Ct!==null?{...l.info,contextUsage:{tokens:Ct,contextWindow:((_t=l.info.contextUsage)==null?void 0:_t.contextWindow)??1e6,percent:null}}:l.info:null,providers:Ue,onSwitchModel:(d,w)=>void On(d,w),onSetThinking:d=>void Nn(d),thinkingLevel:l.thinkingLevel??"low",permissionMode:xn,onTogglePermission:()=>mn(d=>d==="ask"?"auto":"ask"),attachments:g.attachments,fileAttachments:g.fileAttachments,onAttach:g.attachFiles,onRemoveAttachment:g.removeAttachment,busy:l.busy||Et,onStop:Et?qn:_n,hasPendingDialog:y.some(d=>d.status==="pending"),selectedModel:An,onCommand:()=>{ht(),St(!0)},onRefreshCommands:ht,commands:C,onPickCommand:()=>{},focusSignal:Q,queuedMessages:l.queued},[Ht,Jn]=a.useState(!1),Pt={sessions:q,activePath:F,onNewSession:En,onCollapsedChange:Jn,onClearAllArchived:()=>pe.clearAllArchived(),onOpenSession:te,onOpenSettings:()=>oe(!0),onOpenPlugins:()=>we(!0),onRenameSession:Tn,onDeleteSession:Fn,onArchiveSession:Rn,onRestoreSession:Dn,onDeleteArchivedSession:pe.deleteArchivedSession,onTogglePin:Wn,pinnedSessions:Ie,archivedProjects:kn,onArchiveProject:async d=>{b(w=>w.filter(E=>E.cwd!==d)),await pe.archiveProject(d)},onUnarchiveProject:async d=>{pe.removeArchivedProject(d),await pe.unarchiveProject(d)},onDeleteProject:d=>pe.deleteProject(d,q,F),busyPaths:Ln,pendingDialogPaths:new Set(Object.entries(Me).filter(([,d])=>d.some(w=>w.status==="pending")).map(([d])=>Ne.current.get(d)).filter(d=>!!d))},{uiFontSize:Xn}=nn(),Gn=!s.activeId&&!A&&!et,be=q.find(d=>d.path===F),Qn=(be==null?void 0:be.name)??(be==null?void 0:be.firstMessage)??"",Zn=be==null?void 0:be.cwd;return e.jsxs("div",{style:{height:"100dvh",margin:0,display:"flex",overflow:"hidden",background:r.color.bg,color:r.color.fg,fontFamily:r.font.sans,fontSize:Xn},children:[A?e.jsx(a.Suspense,{fallback:null,children:e.jsx(Io,{providers:bn,usageStats:ze,onClose:()=>oe(!1),onSave:Ve.saveModels,onRefresh:Ve.refreshModels,onTest:Ve.testModel,cat:Se,onCatChange:Ae,projectCwd:De,request:(d,w)=>t.request(d,w),onProbe:async d=>t?await t.request("models.probe",d):{ok:!1}})}):X?e.jsx(a.Suspense,{fallback:null,children:e.jsx(Co,{request:(d,w)=>t.request(d,w),onClose:()=>we(!1),t:r})}):Gn?e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"row",minWidth:0},children:[e.jsx(Vt,{...Pt}),e.jsx(fo,{wide:Ht,activeProject:De,projects:Bn,onSelectProject:Hn,onNewProject:()=>qe(!0),inputCard:$t,aboveEditorWidgets:ae,aboveEditorStatuses:Y})]}):e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"row",minWidth:0},children:[e.jsx(Vt,{...Pt}),e.jsx(uo,{wide:Ht,items:l.items,busy:l.busy,turnStartTs:l.turnStart,sessionLoading:et,showLoading:yn,autoscroll:c,sessionName:Qn,sessionCwd:Zn,activeId:s.activeId,onToggleCard:d=>i({type:"toggleCollapse",id:d}),copyMessage:Mo,editSubmit:Sn,onFork:In,inputCard:$t,uiCards:y,onUiCardRespond:$n,onLoadMore:jn,loadingMore:vn,aboveEditorWidgets:ae,aboveEditorStatuses:Y,onOpenFile:_,onRevertAll:d=>void Mn(d)}),e.jsx(po,{tabs:x,activeId:h,collapsed:j,onActivate:d=>L(d),onClose:d=>M(d),onToggleCollapse:()=>I(d=>!d),width:S,onWidthChange:O,render:d=>d.id==="diff"?e.jsx(go,{items:l.items,selected:k,turnId:p,expandedFiles:v,onOpenChange:w=>K(w)},`${s.activeId}-${p??"none"}`):d.id==="widget"?e.jsx(yo,{widgets:$e}):null})]}),Ze&&e.jsx(yr,{listDir:Kn,roots:Un,onPick:d=>void Pn(d)}),We&&e.jsx(hr,{commands:C,onPick:Yn}),Re&&e.jsx(ho,{state:Re,onClose:()=>Ce(null)}),P&&e.jsxs("div",{style:{position:"fixed",bottom:24,left:"50%",transform:"translateX(-50%)",zIndex:10001,display:"flex",alignItems:"flex-start",gap:9,padding:"10px 16px",borderRadius:12,background:r.color.surface,border:`1px solid ${r.color.border}`,boxShadow:"0 12px 40px rgba(0,0,0,0.25)",fontSize:"0.88em",color:r.color.fg,animation:"vagus-toast-in 0.2s ease",maxWidth:"min(90vw, 560px)"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",flexShrink:0,marginTop:5,background:P.type==="error"?"#E5484D":P.type==="warning"?"#B7791F":r.color.primary}}),e.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:P.text})]}),f&&e.jsx(vo,{report:f,onClose:()=>m(null)})]})}function To(){return e.jsx(lr,{children:e.jsx(ar,{children:e.jsx(Eo,{})})})}const gn=document.getElementById("root");if(!gn)throw new Error("missing #root element — index.html is malformed");nr.createRoot(gn).render(e.jsx(To,{}));