@aalis/plugin-webui-client 0.9.1 → 0.10.0

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.
Files changed (64) hide show
  1. package/dist/assets/AuthorityPage-GbF3xg8H.js +16 -0
  2. package/dist/assets/{DynamicPage-BCvX1Tg2.js → DynamicPage-GeSfxddk.js} +1 -1
  3. package/dist/assets/{FilesPage-BMbRlFyJ.js → FilesPage-B5C5zWo5.js} +1 -1
  4. package/dist/assets/MarketplacePage-DKs-PwSt.js +6 -0
  5. package/dist/assets/{PlatformPage-BKcwv7lV.js → PlatformPage-U3Xx3yvM.js} +1 -1
  6. package/dist/assets/{PluginConfigPage-BEBeoZAt.js → PluginConfigPage-Ci_WRMHk.js} +1 -1
  7. package/dist/assets/{SessionsPage-D0IEwawu.js → SessionsPage-AmYhJ75Q.js} +1 -1
  8. package/dist/assets/{arc-DgCAVqQG.js → arc-DAUQCUxy.js} +1 -1
  9. package/dist/assets/{architectureDiagram-3BPJPVTR-DUOdsOu6.js → architectureDiagram-3BPJPVTR-dq-zfwZp.js} +1 -1
  10. package/dist/assets/{blockDiagram-GPEHLZMM-CPiBvpQw.js → blockDiagram-GPEHLZMM-DEMq0qb2.js} +1 -1
  11. package/dist/assets/{c4Diagram-AAUBKEIU-AGYD57MB.js → c4Diagram-AAUBKEIU-CwB1zAbW.js} +1 -1
  12. package/dist/assets/channel-kaxpMS0k.js +1 -0
  13. package/dist/assets/{chunk-2J33WTMH-BBTl70Nc.js → chunk-2J33WTMH-9OXRlLBg.js} +1 -1
  14. package/dist/assets/{chunk-4BX2VUAB-v3JqMQa_.js → chunk-4BX2VUAB-HzQmwn3M.js} +1 -1
  15. package/dist/assets/{chunk-55IACEB6-WyRWVyR6.js → chunk-55IACEB6-DraZNS76.js} +1 -1
  16. package/dist/assets/{chunk-727SXJPM-DF4uMHuP.js → chunk-727SXJPM-Cs0FCref.js} +1 -1
  17. package/dist/assets/{chunk-AQP2D5EJ-D7DNAmXA.js → chunk-AQP2D5EJ-DtANEAYx.js} +1 -1
  18. package/dist/assets/{chunk-FMBD7UC4-X7y55wG9.js → chunk-FMBD7UC4-C6aipBu7.js} +1 -1
  19. package/dist/assets/{chunk-ND2GUHAM-CNQXwR6Z.js → chunk-ND2GUHAM-BLOj0kQ3.js} +1 -1
  20. package/dist/assets/{chunk-QZHKN3VN-Dsy2pHYy.js → chunk-QZHKN3VN-5Vi8brX2.js} +1 -1
  21. package/dist/assets/classDiagram-4FO5ZUOK-B8NX94jI.js +1 -0
  22. package/dist/assets/classDiagram-v2-Q7XG4LA2-B8NX94jI.js +1 -0
  23. package/dist/assets/{clock-CexFGsrk.js → clock-ChZ95JZD.js} +1 -1
  24. package/dist/assets/{cose-bilkent-S5V4N54A-CS9csD8f.js → cose-bilkent-S5V4N54A-yeJ_9DnK.js} +1 -1
  25. package/dist/assets/{dagre-BM42HDAG-nXs84lFQ.js → dagre-BM42HDAG-D6s4-9TX.js} +1 -1
  26. package/dist/assets/{diagram-2AECGRRQ-Bf4JvWP3.js → diagram-2AECGRRQ-pq6EwjXz.js} +1 -1
  27. package/dist/assets/{diagram-5GNKFQAL-BQxWQN2V.js → diagram-5GNKFQAL-CEAvTn_s.js} +1 -1
  28. package/dist/assets/{diagram-KO2AKTUF-ZoXRYwP-.js → diagram-KO2AKTUF-dqURbX4F.js} +1 -1
  29. package/dist/assets/{diagram-LMA3HP47-D2nzytQD.js → diagram-LMA3HP47-DXmUzg2O.js} +1 -1
  30. package/dist/assets/{diagram-OG6HWLK6-CgJOhe8X.js → diagram-OG6HWLK6-CJWJiQGO.js} +1 -1
  31. package/dist/assets/{erDiagram-TEJ5UH35-C0D4Nnw0.js → erDiagram-TEJ5UH35-D1ZEPbEZ.js} +1 -1
  32. package/dist/assets/{flowDiagram-I6XJVG4X-C7ut3eEd.js → flowDiagram-I6XJVG4X-BTEcDPXo.js} +1 -1
  33. package/dist/assets/{ganttDiagram-6RSMTGT7-BPEjzmiT.js → ganttDiagram-6RSMTGT7-DWcwiv0T.js} +1 -1
  34. package/dist/assets/{gitGraphDiagram-PVQCEYII-DDbVQ4yz.js → gitGraphDiagram-PVQCEYII-CzSr3JTx.js} +1 -1
  35. package/dist/assets/{globe-CBbp1Q3e.js → globe-iNYeYXM9.js} +1 -1
  36. package/dist/assets/{index-BWwjYl1J.js → index-D56FVdMY.js} +42 -42
  37. package/dist/assets/{infoDiagram-5YYISTIA-DX6o6Sjl.js → infoDiagram-5YYISTIA-BrJvNyiN.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-YF4QCWOH-CR6ZrpjX.js → ishikawaDiagram-YF4QCWOH-CLLORvW4.js} +1 -1
  39. package/dist/assets/{journeyDiagram-JHISSGLW-BdXEYMYU.js → journeyDiagram-JHISSGLW-DJERFHoN.js} +1 -1
  40. package/dist/assets/{kanban-definition-UN3LZRKU-CeqFrbgR.js → kanban-definition-UN3LZRKU-nfSKPg95.js} +1 -1
  41. package/dist/assets/{linear-B8t65nmv.js → linear-svZpQC-M.js} +1 -1
  42. package/dist/assets/{markdown-BCywGHw2.js → markdown-B2G8c9k5.js} +21 -21
  43. package/dist/assets/{mermaid.core-DVy3DGpO.js → mermaid.core-BK17wB8Y.js} +4 -4
  44. package/dist/assets/{mindmap-definition-RKZ34NQL-Bdabu17v.js → mindmap-definition-RKZ34NQL-BbKyklJL.js} +1 -1
  45. package/dist/assets/{pieDiagram-4H26LBE5-DPex3q00.js → pieDiagram-4H26LBE5-BdVEjZ3k.js} +1 -1
  46. package/dist/assets/{quadrantDiagram-W4KKPZXB-CR_GIvz-.js → quadrantDiagram-W4KKPZXB-pwCe-4m9.js} +1 -1
  47. package/dist/assets/{requirementDiagram-4Y6WPE33-sFRdxxH-.js → requirementDiagram-4Y6WPE33-CBHbb4_y.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-5OEKKPKP-OJ_uPF8c.js → sankeyDiagram-5OEKKPKP-DnxugXFe.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-3UESZ5HK-erRyzaXX.js → sequenceDiagram-3UESZ5HK-CXqwCzG2.js} +1 -1
  50. package/dist/assets/{stateDiagram-AJRCARHV-KRb4NAf8.js → stateDiagram-AJRCARHV-Byw3Daq8.js} +1 -1
  51. package/dist/assets/stateDiagram-v2-BHNVJYJU-ClKN4qlq.js +1 -0
  52. package/dist/assets/{timeline-definition-PNZ67QCA-Dy8PzD_z.js → timeline-definition-PNZ67QCA-spYDyHEq.js} +1 -1
  53. package/dist/assets/{vennDiagram-CIIHVFJN-C3R-BuRH.js → vennDiagram-CIIHVFJN-Cg2-3zjD.js} +1 -1
  54. package/dist/assets/{wardley-L42UT6IY-BfNNTOAt.js → wardley-L42UT6IY-ER1LeunS.js} +1 -1
  55. package/dist/assets/{wardleyDiagram-YWT4CUSO-CgkF-vOW.js → wardleyDiagram-YWT4CUSO-qaTMbUZm.js} +1 -1
  56. package/dist/assets/{xychartDiagram-2RQKCTM6-ZFy5dgDQ.js → xychartDiagram-2RQKCTM6-D4K0NriZ.js} +1 -1
  57. package/dist/index.html +2 -2
  58. package/package.json +5 -4
  59. package/dist/assets/AuthorityPage-jj192bfx.js +0 -16
  60. package/dist/assets/MarketplacePage-ClOWoNMz.js +0 -6
  61. package/dist/assets/channel-Bq_prj9O.js +0 -1
  62. package/dist/assets/classDiagram-4FO5ZUOK-CP72yHy9.js +0 -1
  63. package/dist/assets/classDiagram-v2-Q7XG4LA2-CP72yHy9.js +0 -1
  64. package/dist/assets/stateDiagram-v2-BHNVJYJU-D6wFUac9.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DVy3DGpO.js","assets/react-vendor-BPQixOLZ.js","assets/PluginConfigPage-BEBeoZAt.js","assets/SchemaForm-YVQZ6Keg.js","assets/ConfirmDialog-DbV-E1Nd.js","assets/highlight-DJvvuuwd.js","assets/highlight-BPWJwfct.css","assets/katex-Bq6vt64r.js","assets/katex-CIHdCL6t.css","assets/markdown-BCywGHw2.js","assets/MarketplacePage-ClOWoNMz.js","assets/clock-CexFGsrk.js","assets/PlatformPage-BKcwv7lV.js","assets/globe-CBbp1Q3e.js","assets/AuthorityPage-jj192bfx.js","assets/LogPage-C_Z3RA5T.js","assets/SessionsPage-D0IEwawu.js","assets/FilesPage-BMbRlFyJ.js","assets/DynamicPage-BCvX1Tg2.js","assets/cytoscape.esm-LDYqcvCF.js","assets/cytoscape-fcose-DXAQNCkb.js"])))=>i.map(i=>d[i]);
2
- import{j as e,r as a,c as Hs}from"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import{r as Vs,b as Js,a as Gs,c as Ks,M as _e}from"./markdown-BCywGHw2.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const d of i)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(i){const d={};return i.integrity&&(d.integrity=i.integrity),i.referrerPolicy&&(d.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?d.credentials="include":i.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(i){if(i.ep)return;i.ep=!0;const d=n(i);fetch(i.href,d)}})();const Us="modulepreload",Ys=function(t){return"/"+t},as={},he=function(s,n,r){let i=Promise.resolve();if(n&&n.length>0){let u=function(l){return Promise.all(l.map(p=>Promise.resolve(p).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));i=u(n.map(l=>{if(l=Ys(l),l in as)return;as[l]=!0;const p=l.endsWith(".css"),x=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${x}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":Us,p||(g.as="script"),g.crossOrigin="",g.href=l,m&&g.setAttribute("nonce",m),document.head.appendChild(g),p)return new Promise((k,c)=>{g.addEventListener("load",k),g.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${l}`)))})}))}function d(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return i.then(u=>{for(const h of u||[])h.status==="rejected"&&d(h.reason);return s().catch(d)})},fs="aalis:activeSessionId";function Xs(){try{return window.localStorage.getItem(fs)||"__new_chat__"}catch{return"__new_chat__"}}let Ye=Xs();const Xe=new Set;function oe(){return Ye}function He(t){if(Ye!==t){Ye=t;try{window.localStorage.setItem(fs,t)}catch{}for(const s of Xe)s(t)}}function Zs(t){return Xe.add(t),()=>Xe.delete(t)}function ps(t){return t!==401?!1:(window.location.replace("/"),!0)}async function te(t,s){const n=await fetch(t,{headers:{"Content-Type":"application/json"},...s});if(ps(n.status))throw new Error("会话已失效,正在跳转登录");return n.json()}async function de(t,s,n={}){const r=await fetch(`/api/page-action/${encodeURIComponent(t)}/${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(ps(r.status))throw new Error("会话已失效,正在跳转登录");const i=await r.json();if(!r.ok)throw new Error(i.error||"请求失败");return i.data}function je(t){return t?t.startsWith("http://")||t.startsWith("https://")?`/api/proxy/image?url=${encodeURIComponent(t)}`:t:""}function Qs(){return e.jsxs("svg",{width:"20",height:"20",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:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}function et(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"9",cy:"21",r:"1"}),e.jsx("circle",{cx:"20",cy:"21",r:"1"}),e.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]})}function st(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function tt(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14,2 14,8 20,8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"9"})]})}function nt(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function at(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})})}function rt(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function ot(t){const s=a.useRef(t);s.current=t;const n=a.useRef(null),[r,i]=a.useState(!1),d=a.useRef(oe());a.useEffect(()=>{let m,l,p=!1;function x(){if(p)return;const g=location.protocol==="https:"?"wss:":"ws:";m=new WebSocket(`${g}//${location.host}/ws`),n.current=m,m.onopen=()=>{p||(i(!0),m.send(JSON.stringify({type:"subscribe_logs"})),m.send(JSON.stringify({type:"subscribe_session",sessionId:oe()})),d.current=oe())},m.onclose=()=>{p||(i(!1),l=setTimeout(x,3e3))},m.onmessage=k=>{var c,L,E,C,S,G,v,q,F,Y,Z,b,D;try{const f=JSON.parse(k.data),y=s.current;f.type==="stream"?(y.onStream(f.contentDelta,f.reasoningDelta,f.done,f.toolLimitReached),f.toolCallProgress&&((c=y.onToolCallProgress)==null||c.call(y,f.toolCallProgress)),f.done&&((L=y.onToolCallProgressClear)==null||L.call(y))):f.type==="message"&&(f.content||(E=f.attachments)!=null&&E.length)?y.onMessage(f.content??"",f.reasoningContent,f.segments,f.attachments,f.modelInfo):f.type==="tool_call"&&f.toolName?y.onToolCall(f.toolName,f.toolArgs??{},f.toolPhase,f.toolResult):f.type==="log"&&f.log?y.onLog(f.log):f.type==="state_changed"?(C=y.onStateChanged)==null||C.call(y):f.type==="restarting"?(S=y.onRestarting)==null||S.call(y):f.type==="reload"?(G=y.onReload)==null||G.call(y):f.type==="sessions_changed"?(v=y.onSessionsChanged)==null||v.call(y):f.type==="todo_updated"&&f.todoItems?(q=y.onTodoUpdated)==null||q.call(y,f.todoItems):f.type==="stream_resume"?(F=y.onStreamResume)==null||F.call(y,f.content??"",f.reasoningContent??"",f.segments??[],!!f.done,f.toolCallsProgress):f.type==="confirm"&&f.content?(Y=y.onConfirm)==null||Y.call(y,f.content):f.type==="token_usage"&&f.tokenUsage?(Z=y.onTokenUsage)==null||Z.call(y,f.tokenUsage):f.type==="compressing"&&f.sessionId?(b=y.onCompressing)==null||b.call(y,f.sessionId,f.content??"start"):f.type==="history_changed"&&f.sessionId?(D=y.onHistoryChanged)==null||D.call(y,f.sessionId):f.type==="page_refresh"&&window.dispatchEvent(new CustomEvent("aalis:page-refresh",{detail:{pluginName:f.pluginName}}))}catch{}}}return x(),()=>{p=!0,clearTimeout(l),m==null||m.close()}},[]),a.useEffect(()=>Zs(l=>{const p=n.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&(p.send(JSON.stringify({type:"unsubscribe_session",sessionId:d.current})),p.send(JSON.stringify({type:"subscribe_session",sessionId:l})),d.current=l)}),[]);const u=a.useCallback((m,l)=>{var p;if(((p=n.current)==null?void 0:p.readyState)===WebSocket.OPEN){const x={type:"message",content:m,sessionId:oe()};l&&l.length>0&&(x.attachments=l),n.current.send(JSON.stringify(x))}},[]),h=a.useCallback(m=>{var l;((l=n.current)==null?void 0:l.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(m))},[]);return{send:u,sendRaw:h,connected:r}}function it(){const t=new Date,s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`会话 ${s}-${n} ${r}:${i}`}function lt(t){const s=[];let n=t.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^)]+\)\]\n--- 文件内容 ---[\s\S]*?--- 文件内容结束 ---/g,(r,i)=>(s.push(i.trim()),""));return n=n.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^,\n)]+[,\n][\s\S]*?\)\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]-]+?) - [^\]]+\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]]+?)\s*(?:\(ID:[^)]+\))?\]/g,(r,i)=>(s.push(i.trim()),"")),{displayContent:n.trim(),fileNames:s}}function ct(t){var r,i,d,u;const s=[];let n=0;for(;n<t.length;){const h=t[n];if(h.role==="user"){const m=h.content??"",l=Array.isArray((r=h.metadata)==null?void 0:r.fileNames)?h.metadata.fileNames:null,{displayContent:p,fileNames:x}=lt(m),g=(l??x).filter(Boolean);s.push({role:"user",content:p,fileNames:g.length>0?g:void 0,timestamp:h.timestamp??0}),n++;continue}if(h.role==="system"){h.kind==="event-marker"&&s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="notice"){s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="assistant"){const m=[],l=[];let p=h.timestamp??0,x="",g=!1,k;for(;n<t.length&&(t[n].role==="assistant"||t[n].role==="tool");){const C=t[n];if(C.role==="assistant"){const S=(i=C.metadata)==null?void 0:i.modelInfo;S&&(k=S)}if(C.role==="assistant"&&C.segments&&C.segments.length>0){g=!0,m.length=0,l.length=0;for(const S of C.segments)m.push(S);p=C.timestamp??p,n++;continue}if(C.role==="assistant"&&C.toolCalls&&C.toolCalls.length>0){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&m.push({type:"text",content:C.content});for(const S of C.toolCalls){let G={};try{G=JSON.parse(S.function.arguments)}catch{}m.push({type:"tool_call",name:S.function.name,args:G})}p=C.timestamp??p,n++}else if(C.role==="tool"&&C.toolCallId){for(let S=m.length-1;S>=0;S--){const G=m[S];if(G.type==="tool_call"&&G.result===void 0){G.result=C.content??"";break}}n++}else if(C.role==="assistant"){if(n===t.length-1||((d=t[n+1])==null?void 0:d.role)==="user"||((u=t[n+1])==null?void 0:u.role)==="system"){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),x=C.content??"",p=C.timestamp??p,n++;break}C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&m.push({type:"text",content:C.content}),p=C.timestamp??p,n++}else break}let c;g?c=m:(c=[...l,...m],x&&c.push({type:"text",content:x}));let L="",E="";for(const C of c)C.type==="reasoning_text"?L+=C.content:C.type==="text"&&(E+=C.content);s.push({role:"assistant",content:E||x||h.content||"",segments:c.length>0?c:void 0,reasoningContent:L||void 0,timestamp:p,modelInfo:k});continue}n++}return s}function dt(t){const[s,n]=a.useState([]),[r,i]=a.useState(oe()),[d,u]=a.useState([]),[h,m]=a.useState(!1),l=a.useRef(!1),p=a.useRef(new Map),x=a.useMemo(()=>{const b=t.find(D=>D.key==="sessions");return(b==null?void 0:b.plugin)??null},[t]),g=a.useRef(x);g.current=x;const k=a.useRef(r);k.current=r;const c=a.useRef(d);c.current=d;const L=a.useRef(s);L.current=s;const E=a.useMemo(()=>x?s.length===0||!s.some(b=>b.id===r):!1,[x,s,r]),C=a.useMemo(()=>{const b=s.find(D=>D.id===r);return(b==null?void 0:b.title)||(b==null?void 0:b.displayTitle)||(b==null?void 0:b.name)||""},[s,r]),S=a.useCallback(()=>{const b=g.current;b&&de(b,"listSessions").then(D=>{Array.isArray(D)&&n(D)}).catch(()=>{})},[]),G=a.useCallback(()=>{c.current.length>0&&p.current.set(k.current,c.current);const b="__new_chat__";i(b),He(b),u([]),m(!1),l.current=!1},[]),v=a.useCallback(async b=>{const D=g.current;if(!D)return null;const f=it();try{const y=await de(D,"createSession",{name:f,...b?{parentId:b}:{}});if(!(y!=null&&y.id))return null;const V=y.id;return n(J=>{if(J.some(_=>_.id===V))return J;const ae={id:V,name:y.name||f,title:y.title,displayTitle:y.title||y.name||f,status:"active",children:[],childCount:0,parentId:b,createdAt:Date.now()};return[...J,ae]}),b&&n(J=>J.map(ae=>ae.id===b?{...ae,children:[...ae.children,V],childCount:ae.childCount+1}:ae)),c.current.length>0&&p.current.set(k.current,c.current),i(V),He(V),u([]),m(!1),l.current=!1,de(D,"listSessions").then(J=>{Array.isArray(J)&&n(J)}).catch(()=>{}),V}catch{return null}},[]),q=a.useCallback(async()=>!g.current||L.current.some(f=>f.id===k.current)?k.current:await v()||k.current,[v]),F=a.useCallback((b,D)=>{de(D,"getSessionDetail",{id:b}).then(f=>{if(f!=null&&f.messages&&k.current===b){const y=ct(f.messages);if(l.current){for(;y.length>0&&y[y.length-1].role==="assistant";)y.pop();const V=c.current,J=V[V.length-1];J&&J.role==="assistant"&&y.push(J)}u(y),p.current.set(b,y)}}).catch(()=>{})},[]),Y=a.useCallback(b=>{const D=b===k.current;if(D&&c.current.length>0)return;!D&&c.current.length>0&&p.current.set(k.current,c.current),i(b),He(b),m(!1),l.current=!1;const f=g.current,y=p.current.get(b);u(y??[]),!y&&f&&F(b,f),S()},[F,S]),Z=a.useCallback(b=>{if(b!==k.current)return;const D=g.current;D&&(p.current.delete(b),F(b,D))},[F]);return a.useEffect(()=>{x&&de(x,"listSessions").then(b=>{if(!Array.isArray(b))return;n(b);const D=oe();D&&D!=="__new_chat__"&&b.some(f=>f.id===D)&&(i(D),F(D,x))}).catch(()=>{})},[x,F]),{pluginName:x,sessionList:s,activeSessionId:r,activeSessionTitle:C,isNewChat:E,messages:d,setMessages:u,refresh:S,startNewChat:G,createSession:v,ensureSession:q,switchSession:Y,handleHistoryChanged:Z,loading:h,setLoading:m,streamingRef:l}}/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BK17wB8Y.js","assets/react-vendor-BPQixOLZ.js","assets/PluginConfigPage-Ci_WRMHk.js","assets/SchemaForm-YVQZ6Keg.js","assets/ConfirmDialog-DbV-E1Nd.js","assets/highlight-DJvvuuwd.js","assets/highlight-BPWJwfct.css","assets/katex-Bq6vt64r.js","assets/katex-CIHdCL6t.css","assets/markdown-B2G8c9k5.js","assets/MarketplacePage-DKs-PwSt.js","assets/clock-ChZ95JZD.js","assets/PlatformPage-U3Xx3yvM.js","assets/globe-iNYeYXM9.js","assets/AuthorityPage-GbF3xg8H.js","assets/LogPage-C_Z3RA5T.js","assets/SessionsPage-AmYhJ75Q.js","assets/FilesPage-B5C5zWo5.js","assets/DynamicPage-GeSfxddk.js","assets/cytoscape.esm-LDYqcvCF.js","assets/cytoscape-fcose-DXAQNCkb.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,r as a,c as Hs}from"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import{r as Vs,b as Js,a as Gs,c as Ks,d as Us,M as _e}from"./markdown-B2G8c9k5.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const d of i)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(i){const d={};return i.integrity&&(d.integrity=i.integrity),i.referrerPolicy&&(d.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?d.credentials="include":i.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(i){if(i.ep)return;i.ep=!0;const d=n(i);fetch(i.href,d)}})();const Ys="modulepreload",Xs=function(t){return"/"+t},as={},he=function(s,n,r){let i=Promise.resolve();if(n&&n.length>0){let u=function(l){return Promise.all(l.map(p=>Promise.resolve(p).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));i=u(n.map(l=>{if(l=Xs(l),l in as)return;as[l]=!0;const p=l.endsWith(".css"),x=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${x}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":Ys,p||(g.as="script"),g.crossOrigin="",g.href=l,m&&g.setAttribute("nonce",m),document.head.appendChild(g),p)return new Promise((k,c)=>{g.addEventListener("load",k),g.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${l}`)))})}))}function d(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return i.then(u=>{for(const h of u||[])h.status==="rejected"&&d(h.reason);return s().catch(d)})},fs="aalis:activeSessionId";function Zs(){try{return window.localStorage.getItem(fs)||"__new_chat__"}catch{return"__new_chat__"}}let Ye=Zs();const Xe=new Set;function oe(){return Ye}function He(t){if(Ye!==t){Ye=t;try{window.localStorage.setItem(fs,t)}catch{}for(const s of Xe)s(t)}}function Qs(t){return Xe.add(t),()=>Xe.delete(t)}function ps(t){return t!==401?!1:(window.location.replace("/"),!0)}async function te(t,s){const n=await fetch(t,{headers:{"Content-Type":"application/json"},...s});if(ps(n.status))throw new Error("会话已失效,正在跳转登录");return n.json()}async function de(t,s,n={}){const r=await fetch(`/api/page-action/${encodeURIComponent(t)}/${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(ps(r.status))throw new Error("会话已失效,正在跳转登录");const i=await r.json();if(!r.ok)throw new Error(i.error||"请求失败");return i.data}function je(t){return t?t.startsWith("http://")||t.startsWith("https://")?`/api/proxy/image?url=${encodeURIComponent(t)}`:t:""}function et(){return e.jsxs("svg",{width:"20",height:"20",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:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}function st(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"9",cy:"21",r:"1"}),e.jsx("circle",{cx:"20",cy:"21",r:"1"}),e.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]})}function tt(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function nt(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14,2 14,8 20,8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"9"})]})}function at(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function rt(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})})}function ot(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function it(t){const s=a.useRef(t);s.current=t;const n=a.useRef(null),[r,i]=a.useState(!1),d=a.useRef(oe());a.useEffect(()=>{let m,l,p=!1;function x(){if(p)return;const g=location.protocol==="https:"?"wss:":"ws:";m=new WebSocket(`${g}//${location.host}/ws`),n.current=m,m.onopen=()=>{p||(i(!0),m.send(JSON.stringify({type:"subscribe_logs"})),m.send(JSON.stringify({type:"subscribe_session",sessionId:oe()})),d.current=oe())},m.onclose=()=>{p||(i(!1),l=setTimeout(x,3e3))},m.onmessage=k=>{var c,L,E,C,S,G,v,B,F,Y,Z,b,D;try{const f=JSON.parse(k.data),y=s.current;f.type==="stream"?(y.onStream(f.contentDelta,f.reasoningDelta,f.done,f.toolLimitReached),f.toolCallProgress&&((c=y.onToolCallProgress)==null||c.call(y,f.toolCallProgress)),f.done&&((L=y.onToolCallProgressClear)==null||L.call(y))):f.type==="message"&&(f.content||(E=f.attachments)!=null&&E.length)?y.onMessage(f.content??"",f.reasoningContent,f.segments,f.attachments,f.modelInfo):f.type==="tool_call"&&f.toolName?y.onToolCall(f.toolName,f.toolArgs??{},f.toolPhase,f.toolResult):f.type==="log"&&f.log?y.onLog(f.log):f.type==="state_changed"?(C=y.onStateChanged)==null||C.call(y):f.type==="restarting"?(S=y.onRestarting)==null||S.call(y):f.type==="reload"?(G=y.onReload)==null||G.call(y):f.type==="sessions_changed"?(v=y.onSessionsChanged)==null||v.call(y):f.type==="todo_updated"&&f.todoItems?(B=y.onTodoUpdated)==null||B.call(y,f.todoItems):f.type==="stream_resume"?(F=y.onStreamResume)==null||F.call(y,f.content??"",f.reasoningContent??"",f.segments??[],!!f.done,f.toolCallsProgress):f.type==="confirm"&&f.content?(Y=y.onConfirm)==null||Y.call(y,f.content):f.type==="token_usage"&&f.tokenUsage?(Z=y.onTokenUsage)==null||Z.call(y,f.tokenUsage):f.type==="compressing"&&f.sessionId?(b=y.onCompressing)==null||b.call(y,f.sessionId,f.content??"start"):f.type==="history_changed"&&f.sessionId?(D=y.onHistoryChanged)==null||D.call(y,f.sessionId):f.type==="page_refresh"&&window.dispatchEvent(new CustomEvent("aalis:page-refresh",{detail:{pluginName:f.pluginName}}))}catch{}}}return x(),()=>{p=!0,clearTimeout(l),m==null||m.close()}},[]),a.useEffect(()=>Qs(l=>{const p=n.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&(p.send(JSON.stringify({type:"unsubscribe_session",sessionId:d.current})),p.send(JSON.stringify({type:"subscribe_session",sessionId:l})),d.current=l)}),[]);const u=a.useCallback((m,l)=>{var p;if(((p=n.current)==null?void 0:p.readyState)===WebSocket.OPEN){const x={type:"message",content:m,sessionId:oe()};l&&l.length>0&&(x.attachments=l),n.current.send(JSON.stringify(x))}},[]),h=a.useCallback(m=>{var l;((l=n.current)==null?void 0:l.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(m))},[]);return{send:u,sendRaw:h,connected:r}}function lt(){const t=new Date,s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`会话 ${s}-${n} ${r}:${i}`}function ct(t){const s=[];let n=t.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^)]+\)\]\n--- 文件内容 ---[\s\S]*?--- 文件内容结束 ---/g,(r,i)=>(s.push(i.trim()),""));return n=n.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^,\n)]+[,\n][\s\S]*?\)\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]-]+?) - [^\]]+\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]]+?)\s*(?:\(ID:[^)]+\))?\]/g,(r,i)=>(s.push(i.trim()),"")),{displayContent:n.trim(),fileNames:s}}function dt(t){var r,i,d,u;const s=[];let n=0;for(;n<t.length;){const h=t[n];if(h.role==="user"){const m=h.content??"",l=Array.isArray((r=h.metadata)==null?void 0:r.fileNames)?h.metadata.fileNames:null,{displayContent:p,fileNames:x}=ct(m),g=(l??x).filter(Boolean);s.push({role:"user",content:p,fileNames:g.length>0?g:void 0,timestamp:h.timestamp??0}),n++;continue}if(h.role==="system"){h.kind==="event-marker"&&s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="notice"){s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="assistant"){const m=[],l=[];let p=h.timestamp??0,x="",g=!1,k;for(;n<t.length&&(t[n].role==="assistant"||t[n].role==="tool");){const C=t[n];if(C.role==="assistant"){const S=(i=C.metadata)==null?void 0:i.modelInfo;S&&(k=S)}if(C.role==="assistant"&&C.segments&&C.segments.length>0){g=!0,m.length=0,l.length=0;for(const S of C.segments)m.push(S);p=C.timestamp??p,n++;continue}if(C.role==="assistant"&&C.toolCalls&&C.toolCalls.length>0){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&m.push({type:"text",content:C.content});for(const S of C.toolCalls){let G={};try{G=JSON.parse(S.function.arguments)}catch{}m.push({type:"tool_call",name:S.function.name,args:G})}p=C.timestamp??p,n++}else if(C.role==="tool"&&C.toolCallId){for(let S=m.length-1;S>=0;S--){const G=m[S];if(G.type==="tool_call"&&G.result===void 0){G.result=C.content??"";break}}n++}else if(C.role==="assistant"){if(n===t.length-1||((d=t[n+1])==null?void 0:d.role)==="user"||((u=t[n+1])==null?void 0:u.role)==="system"){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),x=C.content??"",p=C.timestamp??p,n++;break}C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&m.push({type:"text",content:C.content}),p=C.timestamp??p,n++}else break}let c;g?c=m:(c=[...l,...m],x&&c.push({type:"text",content:x}));let L="",E="";for(const C of c)C.type==="reasoning_text"?L+=C.content:C.type==="text"&&(E+=C.content);s.push({role:"assistant",content:E||x||h.content||"",segments:c.length>0?c:void 0,reasoningContent:L||void 0,timestamp:p,modelInfo:k});continue}n++}return s}function ut(t){const[s,n]=a.useState([]),[r,i]=a.useState(oe()),[d,u]=a.useState([]),[h,m]=a.useState(!1),l=a.useRef(!1),p=a.useRef(new Map),x=a.useMemo(()=>{const b=t.find(D=>D.key==="sessions");return(b==null?void 0:b.plugin)??null},[t]),g=a.useRef(x);g.current=x;const k=a.useRef(r);k.current=r;const c=a.useRef(d);c.current=d;const L=a.useRef(s);L.current=s;const E=a.useMemo(()=>x?s.length===0||!s.some(b=>b.id===r):!1,[x,s,r]),C=a.useMemo(()=>{const b=s.find(D=>D.id===r);return(b==null?void 0:b.title)||(b==null?void 0:b.displayTitle)||(b==null?void 0:b.name)||""},[s,r]),S=a.useCallback(()=>{const b=g.current;b&&de(b,"listSessions").then(D=>{Array.isArray(D)&&n(D)}).catch(()=>{})},[]),G=a.useCallback(()=>{c.current.length>0&&p.current.set(k.current,c.current);const b="__new_chat__";i(b),He(b),u([]),m(!1),l.current=!1},[]),v=a.useCallback(async b=>{const D=g.current;if(!D)return null;const f=lt();try{const y=await de(D,"createSession",{name:f,...b?{parentId:b}:{}});if(!(y!=null&&y.id))return null;const V=y.id;return n(J=>{if(J.some(_=>_.id===V))return J;const ae={id:V,name:y.name||f,title:y.title,displayTitle:y.title||y.name||f,status:"active",children:[],childCount:0,parentId:b,createdAt:Date.now()};return[...J,ae]}),b&&n(J=>J.map(ae=>ae.id===b?{...ae,children:[...ae.children,V],childCount:ae.childCount+1}:ae)),c.current.length>0&&p.current.set(k.current,c.current),i(V),He(V),u([]),m(!1),l.current=!1,de(D,"listSessions").then(J=>{Array.isArray(J)&&n(J)}).catch(()=>{}),V}catch{return null}},[]),B=a.useCallback(async()=>!g.current||L.current.some(f=>f.id===k.current)?k.current:await v()||k.current,[v]),F=a.useCallback((b,D)=>{de(D,"getSessionDetail",{id:b}).then(f=>{if(f!=null&&f.messages&&k.current===b){const y=dt(f.messages);if(l.current){for(;y.length>0&&y[y.length-1].role==="assistant";)y.pop();const V=c.current,J=V[V.length-1];J&&J.role==="assistant"&&y.push(J)}u(y),p.current.set(b,y)}}).catch(()=>{})},[]),Y=a.useCallback(b=>{const D=b===k.current;if(D&&c.current.length>0)return;!D&&c.current.length>0&&p.current.set(k.current,c.current),i(b),He(b),m(!1),l.current=!1;const f=g.current,y=p.current.get(b);u(y??[]),!y&&f&&F(b,f),S()},[F,S]),Z=a.useCallback(b=>{if(b!==k.current)return;const D=g.current;D&&(p.current.delete(b),F(b,D))},[F]);return a.useEffect(()=>{x&&de(x,"listSessions").then(b=>{if(!Array.isArray(b))return;n(b);const D=oe();D&&D!=="__new_chat__"&&b.some(f=>f.id===D)&&(i(D),F(D,x))}).catch(()=>{})},[x,F]),{pluginName:x,sessionList:s,activeSessionId:r,activeSessionTitle:C,isNewChat:E,messages:d,setMessages:u,refresh:S,startNewChat:G,createSession:v,ensureSession:B,switchSession:Y,handleHistoryChanged:Z,loading:h,setLoading:m,streamingRef:l}}/**
3
3
  * @license lucide-react v1.7.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -9,17 +9,17 @@ import{j as e,r as a,c as Hs}from"./react-vendor-BPQixOLZ.js";import"./highlight
9
9
  *
10
10
  * This source code is licensed under the ISC license.
11
11
  * See the LICENSE file in the root directory of this source tree.
12
- */const ut=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
12
+ */const ht=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
13
13
  * @license lucide-react v1.7.0 - ISC
14
14
  *
15
15
  * This source code is licensed under the ISC license.
16
16
  * See the LICENSE file in the root directory of this source tree.
17
- */const ht=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
17
+ */const mt=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
18
18
  * @license lucide-react v1.7.0 - ISC
19
19
  *
20
20
  * This source code is licensed under the ISC license.
21
21
  * See the LICENSE file in the root directory of this source tree.
22
- */const rs=t=>{const s=ht(t);return s.charAt(0).toUpperCase()+s.slice(1)};/**
22
+ */const rs=t=>{const s=mt(t);return s.charAt(0).toUpperCase()+s.slice(1)};/**
23
23
  * @license lucide-react v1.7.0 - ISC
24
24
  *
25
25
  * This source code is licensed under the ISC license.
@@ -29,139 +29,139 @@ import{j as e,r as a,c as Hs}from"./react-vendor-BPQixOLZ.js";import"./highlight
29
29
  *
30
30
  * This source code is licensed under the ISC license.
31
31
  * See the LICENSE file in the root directory of this source tree.
32
- */const mt=t=>{for(const s in t)if(s.startsWith("aria-")||s==="role"||s==="title")return!0;return!1},ft=a.createContext({}),pt=()=>a.useContext(ft),xt=a.forwardRef(({color:t,size:s,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:d,iconNode:u,...h},m)=>{const{size:l=24,strokeWidth:p=2,absoluteStrokeWidth:x=!1,color:g="currentColor",className:k=""}=pt()??{},c=r??x?Number(n??p)*24/Number(s??l):n??p;return a.createElement("svg",{ref:m,...Ve,width:s??l??Ve.width,height:s??l??Ve.height,stroke:t??g,strokeWidth:c,className:xs("lucide",k,i),...!d&&!mt(h)&&{"aria-hidden":"true"},...h},[...u.map(([L,E])=>a.createElement(L,E)),...Array.isArray(d)?d:[d]])});/**
32
+ */const ft=t=>{for(const s in t)if(s.startsWith("aria-")||s==="role"||s==="title")return!0;return!1},pt=a.createContext({}),xt=()=>a.useContext(pt),gt=a.forwardRef(({color:t,size:s,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:d,iconNode:u,...h},m)=>{const{size:l=24,strokeWidth:p=2,absoluteStrokeWidth:x=!1,color:g="currentColor",className:k=""}=xt()??{},c=r??x?Number(n??p)*24/Number(s??l):n??p;return a.createElement("svg",{ref:m,...Ve,width:s??l??Ve.width,height:s??l??Ve.height,stroke:t??g,strokeWidth:c,className:xs("lucide",k,i),...!d&&!ft(h)&&{"aria-hidden":"true"},...h},[...u.map(([L,E])=>a.createElement(L,E)),...Array.isArray(d)?d:[d]])});/**
33
33
  * @license lucide-react v1.7.0 - ISC
34
34
  *
35
35
  * This source code is licensed under the ISC license.
36
36
  * See the LICENSE file in the root directory of this source tree.
37
- */const H=(t,s)=>{const n=a.forwardRef(({className:r,...i},d)=>a.createElement(xt,{ref:d,iconNode:s,className:xs(`lucide-${ut(rs(t))}`,`lucide-${t}`,r),...i}));return n.displayName=rs(t),n};/**
37
+ */const H=(t,s)=>{const n=a.forwardRef(({className:r,...i},d)=>a.createElement(gt,{ref:d,iconNode:s,className:xs(`lucide-${ht(rs(t))}`,`lucide-${t}`,r),...i}));return n.displayName=rs(t),n};/**
38
38
  * @license lucide-react v1.7.0 - ISC
39
39
  *
40
40
  * This source code is licensed under the ISC license.
41
41
  * See the LICENSE file in the root directory of this source tree.
42
- */const gt=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],gs=H("archive",gt);/**
42
+ */const jt=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],gs=H("archive",jt);/**
43
43
  * @license lucide-react v1.7.0 - ISC
44
44
  *
45
45
  * This source code is licensed under the ISC license.
46
46
  * See the LICENSE file in the root directory of this source tree.
47
- */const jt=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],vt=H("bot",jt);/**
47
+ */const vt=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],yt=H("bot",vt);/**
48
48
  * @license lucide-react v1.7.0 - ISC
49
49
  *
50
50
  * This source code is licensed under the ISC license.
51
51
  * See the LICENSE file in the root directory of this source tree.
52
- */const yt=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],os=H("brain-circuit",yt);/**
52
+ */const wt=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],os=H("brain-circuit",wt);/**
53
53
  * @license lucide-react v1.7.0 - ISC
54
54
  *
55
55
  * This source code is licensed under the ISC license.
56
56
  * See the LICENSE file in the root directory of this source tree.
57
- */const wt=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],js=H("chevron-down",wt);/**
57
+ */const Nt=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],js=H("chevron-down",Nt);/**
58
58
  * @license lucide-react v1.7.0 - ISC
59
59
  *
60
60
  * This source code is licensed under the ISC license.
61
61
  * See the LICENSE file in the root directory of this source tree.
62
- */const Nt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],vs=H("chevron-right",Nt);/**
62
+ */const kt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],vs=H("chevron-right",kt);/**
63
63
  * @license lucide-react v1.7.0 - ISC
64
64
  *
65
65
  * This source code is licensed under the ISC license.
66
66
  * See the LICENSE file in the root directory of this source tree.
67
- */const kt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ys=H("circle-check",kt);/**
67
+ */const bt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ys=H("circle-check",bt);/**
68
68
  * @license lucide-react v1.7.0 - ISC
69
69
  *
70
70
  * This source code is licensed under the ISC license.
71
71
  * See the LICENSE file in the root directory of this source tree.
72
- */const bt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ct=H("circle",bt);/**
72
+ */const Ct=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],St=H("circle",Ct);/**
73
73
  * @license lucide-react v1.7.0 - ISC
74
74
  *
75
75
  * This source code is licensed under the ISC license.
76
76
  * See the LICENSE file in the root directory of this source tree.
77
- */const St=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],_t=H("command",St);/**
77
+ */const _t=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],$t=H("command",_t);/**
78
78
  * @license lucide-react v1.7.0 - ISC
79
79
  *
80
80
  * This source code is licensed under the ISC license.
81
81
  * See the LICENSE file in the root directory of this source tree.
82
- */const $t=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],It=H("download",$t);/**
82
+ */const It=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Mt=H("download",It);/**
83
83
  * @license lucide-react v1.7.0 - ISC
84
84
  *
85
85
  * This source code is licensed under the ISC license.
86
86
  * See the LICENSE file in the root directory of this source tree.
87
- */const Mt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ze=H("file-text",Mt);/**
87
+ */const Tt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ze=H("file-text",Tt);/**
88
88
  * @license lucide-react v1.7.0 - ISC
89
89
  *
90
90
  * This source code is licensed under the ISC license.
91
91
  * See the LICENSE file in the root directory of this source tree.
92
- */const Tt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Et=H("file",Tt);/**
92
+ */const Et=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Lt=H("file",Et);/**
93
93
  * @license lucide-react v1.7.0 - ISC
94
94
  *
95
95
  * This source code is licensed under the ISC license.
96
96
  * See the LICENSE file in the root directory of this source tree.
97
- */const Lt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Rt=H("folder-open",Lt);/**
97
+ */const Rt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Dt=H("folder-open",Rt);/**
98
98
  * @license lucide-react v1.7.0 - ISC
99
99
  *
100
100
  * This source code is licensed under the ISC license.
101
101
  * See the LICENSE file in the root directory of this source tree.
102
- */const Dt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Je=H("history",Dt);/**
102
+ */const Pt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Je=H("history",Pt);/**
103
103
  * @license lucide-react v1.7.0 - ISC
104
104
  *
105
105
  * This source code is licensed under the ISC license.
106
106
  * See the LICENSE file in the root directory of this source tree.
107
- */const Pt=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],At=H("list-todo",Pt);/**
107
+ */const At=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],zt=H("list-todo",At);/**
108
108
  * @license lucide-react v1.7.0 - ISC
109
109
  *
110
110
  * This source code is licensed under the ISC license.
111
111
  * See the LICENSE file in the root directory of this source tree.
112
- */const zt=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Qe=H("loader",zt);/**
112
+ */const Ot=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Qe=H("loader",Ot);/**
113
113
  * @license lucide-react v1.7.0 - ISC
114
114
  *
115
115
  * This source code is licensed under the ISC license.
116
116
  * See the LICENSE file in the root directory of this source tree.
117
- */const Ot=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],is=H("message-square",Ot);/**
117
+ */const Ft=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],is=H("message-square",Ft);/**
118
118
  * @license lucide-react v1.7.0 - ISC
119
119
  *
120
120
  * This source code is licensed under the ISC license.
121
121
  * See the LICENSE file in the root directory of this source tree.
122
- */const Ft=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],ws=H("paperclip",Ft);/**
122
+ */const Wt=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],ws=H("paperclip",Wt);/**
123
123
  * @license lucide-react v1.7.0 - ISC
124
124
  *
125
125
  * This source code is licensed under the ISC license.
126
126
  * See the LICENSE file in the root directory of this source tree.
127
- */const Wt=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],qt=H("refresh-cw",Wt);/**
127
+ */const Bt=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],qt=H("refresh-cw",Bt);/**
128
128
  * @license lucide-react v1.7.0 - ISC
129
129
  *
130
130
  * This source code is licensed under the ISC license.
131
131
  * See the LICENSE file in the root directory of this source tree.
132
- */const Bt=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Ht=H("sparkles",Bt);/**
132
+ */const Ht=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Vt=H("sparkles",Ht);/**
133
133
  * @license lucide-react v1.7.0 - ISC
134
134
  *
135
135
  * This source code is licensed under the ISC license.
136
136
  * See the LICENSE file in the root directory of this source tree.
137
- */const Vt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Jt=H("square",Vt);/**
137
+ */const Jt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Gt=H("square",Jt);/**
138
138
  * @license lucide-react v1.7.0 - ISC
139
139
  *
140
140
  * This source code is licensed under the ISC license.
141
141
  * See the LICENSE file in the root directory of this source tree.
142
- */const Gt=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Kt=H("trash-2",Gt);/**
142
+ */const Kt=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Ut=H("trash-2",Kt);/**
143
143
  * @license lucide-react v1.7.0 - ISC
144
144
  *
145
145
  * This source code is licensed under the ISC license.
146
146
  * See the LICENSE file in the root directory of this source tree.
147
- */const Ut=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],De=H("triangle-alert",Ut);/**
147
+ */const Yt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],De=H("triangle-alert",Yt);/**
148
148
  * @license lucide-react v1.7.0 - ISC
149
149
  *
150
150
  * This source code is licensed under the ISC license.
151
151
  * See the LICENSE file in the root directory of this source tree.
152
- */const Yt=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ss=H("wrench",Yt);/**
152
+ */const Xt=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ss=H("wrench",Xt);/**
153
153
  * @license lucide-react v1.7.0 - ISC
154
154
  *
155
155
  * This source code is licensed under the ISC license.
156
156
  * See the LICENSE file in the root directory of this source tree.
157
- */const Xt=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ns=H("x",Xt);/**
157
+ */const Zt=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ns=H("x",Zt);/**
158
158
  * @license lucide-react v1.7.0 - ISC
159
159
  *
160
160
  * This source code is licensed under the ISC license.
161
161
  * See the LICENSE file in the root directory of this source tree.
162
- */const Zt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ks=H("zap",Zt);function Ge({name:t,info:s,onPreferChanged:n}){var g;const[r,i]=a.useState(!1),d=s.providers,u=d.length>0,h=d.length>1,m=s.preferred??((g=d[0])==null?void 0:g.contextId)??"",l=d.find(k=>k.contextId===m),p=async k=>{if(!r){i(!0);try{await te(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"POST",body:JSON.stringify({contextId:k})}),n==null||n()}finally{i(!1)}}},x=async()=>{if(!r){i(!0);try{await te(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"DELETE"}),n==null||n()}finally{i(!1)}}};return e.jsxs("div",{className:"service-slot-card",children:[e.jsxs("div",{className:"service-slot-header",children:[e.jsx("span",{className:"service-slot-name",children:t}),e.jsxs("div",{className:"service-slot-header-badges",children:[s.preferred&&e.jsx("span",{className:"service-winner-badge preferred",children:"偏好"}),e.jsx("span",{className:`badge ${u?"active":"error"}`,children:u?h?`${d.length} 个提供者`:"就绪":"未就绪"})]})]}),u?h?e.jsxs("div",{className:"service-slot-select-row",children:[e.jsx("span",{className:"service-slot-label",children:"活跃提供者"}),e.jsx("select",{className:"service-select",value:m,disabled:r,onChange:k=>p(k.target.value),children:d.map(k=>{const c=k.displayName||k.label||k.contextId,L=c!==k.contextId?`${c} · p${k.priority} (${k.contextId})`:`${k.contextId} · p${k.priority}`;return e.jsx("option",{value:k.contextId,children:L},k.contextId)})}),s.preferred&&e.jsx("button",{type:"button",className:"service-clear-prefer",onClick:x,disabled:r,title:"清除偏好,恢复 priority 默认顺序",children:"恢复默认"})]}):e.jsxs("div",{className:"service-slot-single",children:[e.jsx("span",{className:"service-slot-label",children:"提供者"}),e.jsxs("span",{className:"service-slot-provider-name",children:[(l==null?void 0:l.displayName)||(l==null?void 0:l.label)||(l==null?void 0:l.contextId),((l==null?void 0:l.displayName)||(l==null?void 0:l.label))&&e.jsxs("span",{className:"service-slot-context-id",children:[" ",l==null?void 0:l.contextId]})]})]}):e.jsx("div",{className:"service-slot-single",children:e.jsx("span",{className:"empty-hint",children:"无提供者"})})]})}function Qt({status:t,connected:s,plugins:n,servicesData:r,onRefreshServices:i}){var G;const d=n.filter(v=>v.state==="active").length,u=n.filter(v=>v.state==="error").length,h=n.length,[m,l]=a.useState([]),[p,x]=a.useState([]),[g,k]=a.useState([]);a.useEffect(()=>{te("/api/tool-groups").then(v=>l(v.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{te("/api/service-groups").then(v=>x(v.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{te("/api/llm-models").then(v=>k(v.models??[])).catch(()=>{})},[n]);const c=r?Object.entries(r):[],L=p.map(v=>({label:v.label,entries:c.filter(([q])=>v.services.includes(q))})),E=L.some(v=>v.entries.length>0),C=new Set(p.flatMap(v=>v.services)),S=c.filter(([v])=>!C.has(v));return e.jsxs("div",{className:"page-content page-dashboard",children:[e.jsx("div",{className:"section-label",children:"概览"}),e.jsxs("div",{className:"overview-grid",children:[e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx("span",{className:`status-dot-lg ${s?"online":"offline"}`})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"连接状态"}),e.jsx("div",{className:"overview-card-value",children:s?"已连接":"离线"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(Ht,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"应用名称"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.name)??"-"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(ks,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"活跃插件"}),e.jsxs("div",{className:"overview-card-value",children:[d," / ",h]})]})]}),u>0&&e.jsxs("div",{className:"overview-card overview-card-error",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(De,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"错误插件"}),e.jsx("div",{className:"overview-card-value",children:u})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(ss,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册工具"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.tools.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(_t,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册指令"}),e.jsx("div",{className:"overview-card-value",children:((G=t==null?void 0:t.commands)==null?void 0:G.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(vt,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"可用模型"}),e.jsx("div",{className:"overview-card-value",children:g.length})]})]})]}),E?e.jsxs(e.Fragment,{children:[L.map(v=>v.entries.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:v.label}),e.jsx("div",{className:"services-grid",children:v.entries.map(([q,F])=>e.jsx(Ge,{name:q,info:F,onPreferChanged:i},q))})]},v.label)),S.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:"其他"}),e.jsx("div",{className:"services-grid",children:S.map(([v,q])=>e.jsx(Ge,{name:v,info:q,onPreferChanged:i},v))})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-label",children:"服务"}),e.jsxs("div",{className:"services-grid",children:[c.length===0&&e.jsx("div",{className:"empty-hint",children:"加载中..."}),c.map(([v,q])=>e.jsx(Ge,{name:v,info:q,onPreferChanged:i},v))]})]}),e.jsx("div",{className:"section-label",children:"工具分组"}),m.length>0?e.jsx("div",{className:"tool-groups-grid",children:m.map(v=>{const q=v.contributingPlugins??[],F=[v.pluginName,...q.filter(Y=>Y!==v.pluginName)];return e.jsxs("div",{className:"tool-group-card",children:[e.jsxs("div",{className:"tool-group-header",children:[e.jsx("span",{className:"tool-group-name",children:v.label}),e.jsxs("span",{className:"tool-group-count",children:[v.toolCount," 工具"]})]}),v.description&&e.jsx("div",{className:"tool-group-desc",children:v.description}),e.jsxs("div",{className:"tool-group-meta",children:[e.jsx("span",{className:"tool-group-id",children:v.name}),e.jsx("span",{className:"tool-group-plugin",title:F.join(", "),children:F.join(" · ")})]})]},v.name)})}):e.jsx("div",{className:"tools-grid",children:!t||t.tools.length===0?e.jsx("div",{className:"empty-hint",children:"无工具"}):t.tools.map(v=>e.jsx("span",{className:"tool-chip",children:v},v))}),e.jsx("div",{className:"section-label",children:"已注册指令"}),e.jsx("div",{className:"tools-grid",children:!t||!t.commands||t.commands.length===0?e.jsx("div",{className:"empty-hint",children:"无指令"}):t.commands.map(v=>e.jsxs("span",{className:"tool-chip cmd-chip",title:v.description,children:["/",v.name]},v.name))})]})}function ls(t){const n=t.trim().split("|"),r=n[0].trim()===""?1:0,i=n[n.length-1].trim()===""?n.length-1:n.length;return Math.max(0,i-r)}function en(t,s){const n=t.trim(),r=n.startsWith("|")?"|":"",i=n.endsWith("|")?"|":"",u=n.slice(r.length,i?n.length-1:void 0).split("|").map(h=>h.trim()).filter(h=>/^:?-+:?$/.test(h));for(;u.length<s;)u.push("---");return u.length=s,r+u.join("|")+i}function sn(t){return/^\|?[ \t]*:?-+:?[ \t]*(\|[ \t]*:?-+:?[ \t]*)*\|?\s*$/.test(t)}function tn(t){return t&&t.split(/(```[\s\S]*?```|`[^`\n]*`)/g).map((n,r)=>{if(r%2===1)return n;const i=n.split(`
163
- `),d=[];for(let u=0;u<i.length;u++){const h=i[u];if(u>0&&sn(h)){const m=i[u-1];if(m.includes("|")&&m.trim()){const l=ls(m),p=ls(h);if(l>0&&p>0&&l!==p){d.push(en(h,l));continue}}}d.push(h)}return d.join(`
164
- `)}).join("")}function $e(t){return t=tn(t),t.split(/(```[\s\S]*?```|`[^`]*`)/g).map((n,r)=>(r%2===1||(n=n.replace(/\\\[([\s\S]*?)\\\]/g,(d,u)=>`$$${u.replace(/\|/g,"\\vert ")}$$`),n=n.replace(/\\\((.*?)\\\)/g,(d,u)=>`$${u.replace(/\|/g,"\\vert ")}$`),n=n.replace(/\$\$([\s\S]+?)\$\$/g,(d,u)=>u.includes(`
162
+ */const Qt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ks=H("zap",Qt);function Ge({name:t,info:s,onPreferChanged:n}){var g;const[r,i]=a.useState(!1),d=s.providers,u=d.length>0,h=d.length>1,m=s.preferred??((g=d[0])==null?void 0:g.contextId)??"",l=d.find(k=>k.contextId===m),p=async k=>{if(!r){i(!0);try{await te(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"POST",body:JSON.stringify({contextId:k})}),n==null||n()}finally{i(!1)}}},x=async()=>{if(!r){i(!0);try{await te(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"DELETE"}),n==null||n()}finally{i(!1)}}};return e.jsxs("div",{className:"service-slot-card",children:[e.jsxs("div",{className:"service-slot-header",children:[e.jsx("span",{className:"service-slot-name",children:t}),e.jsxs("div",{className:"service-slot-header-badges",children:[s.preferred&&e.jsx("span",{className:"service-winner-badge preferred",children:"偏好"}),e.jsx("span",{className:`badge ${u?"active":"error"}`,children:u?h?`${d.length} 个提供者`:"就绪":"未就绪"})]})]}),u?h?e.jsxs("div",{className:"service-slot-select-row",children:[e.jsx("span",{className:"service-slot-label",children:"活跃提供者"}),e.jsx("select",{className:"service-select",value:m,disabled:r,onChange:k=>p(k.target.value),children:d.map(k=>{const c=k.displayName||k.label||k.contextId,L=c!==k.contextId?`${c} · p${k.priority} (${k.contextId})`:`${k.contextId} · p${k.priority}`;return e.jsx("option",{value:k.contextId,children:L},k.contextId)})}),s.preferred&&e.jsx("button",{type:"button",className:"service-clear-prefer",onClick:x,disabled:r,title:"清除偏好,恢复 priority 默认顺序",children:"恢复默认"})]}):e.jsxs("div",{className:"service-slot-single",children:[e.jsx("span",{className:"service-slot-label",children:"提供者"}),e.jsxs("span",{className:"service-slot-provider-name",children:[(l==null?void 0:l.displayName)||(l==null?void 0:l.label)||(l==null?void 0:l.contextId),((l==null?void 0:l.displayName)||(l==null?void 0:l.label))&&e.jsxs("span",{className:"service-slot-context-id",children:[" ",l==null?void 0:l.contextId]})]})]}):e.jsx("div",{className:"service-slot-single",children:e.jsx("span",{className:"empty-hint",children:"无提供者"})})]})}function en({status:t,connected:s,plugins:n,servicesData:r,onRefreshServices:i}){var G;const d=n.filter(v=>v.state==="active").length,u=n.filter(v=>v.state==="error").length,h=n.length,[m,l]=a.useState([]),[p,x]=a.useState([]),[g,k]=a.useState([]);a.useEffect(()=>{te("/api/tool-groups").then(v=>l(v.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{te("/api/service-groups").then(v=>x(v.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{te("/api/llm-models").then(v=>k(v.models??[])).catch(()=>{})},[n]);const c=r?Object.entries(r):[],L=p.map(v=>({label:v.label,entries:c.filter(([B])=>v.services.includes(B))})),E=L.some(v=>v.entries.length>0),C=new Set(p.flatMap(v=>v.services)),S=c.filter(([v])=>!C.has(v));return e.jsxs("div",{className:"page-content page-dashboard",children:[e.jsx("div",{className:"section-label",children:"概览"}),e.jsxs("div",{className:"overview-grid",children:[e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx("span",{className:`status-dot-lg ${s?"online":"offline"}`})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"连接状态"}),e.jsx("div",{className:"overview-card-value",children:s?"已连接":"离线"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(Vt,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"应用名称"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.name)??"-"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(ks,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"活跃插件"}),e.jsxs("div",{className:"overview-card-value",children:[d," / ",h]})]})]}),u>0&&e.jsxs("div",{className:"overview-card overview-card-error",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(De,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"错误插件"}),e.jsx("div",{className:"overview-card-value",children:u})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(ss,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册工具"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.tools.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx($t,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册指令"}),e.jsx("div",{className:"overview-card-value",children:((G=t==null?void 0:t.commands)==null?void 0:G.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(yt,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"可用模型"}),e.jsx("div",{className:"overview-card-value",children:g.length})]})]})]}),E?e.jsxs(e.Fragment,{children:[L.map(v=>v.entries.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:v.label}),e.jsx("div",{className:"services-grid",children:v.entries.map(([B,F])=>e.jsx(Ge,{name:B,info:F,onPreferChanged:i},B))})]},v.label)),S.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:"其他"}),e.jsx("div",{className:"services-grid",children:S.map(([v,B])=>e.jsx(Ge,{name:v,info:B,onPreferChanged:i},v))})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-label",children:"服务"}),e.jsxs("div",{className:"services-grid",children:[c.length===0&&e.jsx("div",{className:"empty-hint",children:"加载中..."}),c.map(([v,B])=>e.jsx(Ge,{name:v,info:B,onPreferChanged:i},v))]})]}),e.jsx("div",{className:"section-label",children:"工具分组"}),m.length>0?e.jsx("div",{className:"tool-groups-grid",children:m.map(v=>{const B=v.contributingPlugins??[],F=[v.pluginName,...B.filter(Y=>Y!==v.pluginName)];return e.jsxs("div",{className:"tool-group-card",children:[e.jsxs("div",{className:"tool-group-header",children:[e.jsx("span",{className:"tool-group-name",children:v.label}),e.jsxs("span",{className:"tool-group-count",children:[v.toolCount," 工具"]})]}),v.description&&e.jsx("div",{className:"tool-group-desc",children:v.description}),e.jsxs("div",{className:"tool-group-meta",children:[e.jsx("span",{className:"tool-group-id",children:v.name}),e.jsx("span",{className:"tool-group-plugin",title:F.join(", "),children:F.join(" · ")})]})]},v.name)})}):e.jsx("div",{className:"tools-grid",children:!t||t.tools.length===0?e.jsx("div",{className:"empty-hint",children:"无工具"}):t.tools.map(v=>e.jsx("span",{className:"tool-chip",children:v},v))}),e.jsx("div",{className:"section-label",children:"已注册指令"}),e.jsx("div",{className:"tools-grid",children:!t||!t.commands||t.commands.length===0?e.jsx("div",{className:"empty-hint",children:"无指令"}):t.commands.map(v=>e.jsxs("span",{className:"tool-chip cmd-chip",title:v.description,children:["/",v.name]},v.name))})]})}function ls(t){const n=t.trim().split("|"),r=n[0].trim()===""?1:0,i=n[n.length-1].trim()===""?n.length-1:n.length;return Math.max(0,i-r)}function sn(t,s){const n=t.trim(),r=n.startsWith("|")?"|":"",i=n.endsWith("|")?"|":"",u=n.slice(r.length,i?n.length-1:void 0).split("|").map(h=>h.trim()).filter(h=>/^:?-+:?$/.test(h));for(;u.length<s;)u.push("---");return u.length=s,r+u.join("|")+i}function tn(t){return/^\|?[ \t]*:?-+:?[ \t]*(\|[ \t]*:?-+:?[ \t]*)*\|?\s*$/.test(t)}function nn(t){return t&&t.split(/(```[\s\S]*?```|`[^`\n]*`)/g).map((n,r)=>{if(r%2===1)return n;const i=n.split(`
163
+ `),d=[];for(let u=0;u<i.length;u++){const h=i[u];if(u>0&&tn(h)){const m=i[u-1];if(m.includes("|")&&m.trim()){const l=ls(m),p=ls(h);if(l>0&&p>0&&l!==p){d.push(sn(h,l));continue}}}d.push(h)}return d.join(`
164
+ `)}).join("")}function $e(t){return t=nn(t),t.split(/(```[\s\S]*?```|`[^`]*`)/g).map((n,r)=>(r%2===1||(n=n.replace(/\\\[([\s\S]*?)\\\]/g,(d,u)=>`$$${u.replace(/\|/g,"\\vert ")}$$`),n=n.replace(/\\\((.*?)\\\)/g,(d,u)=>`$${u.replace(/\|/g,"\\vert ")}$`),n=n.replace(/\$\$([\s\S]+?)\$\$/g,(d,u)=>u.includes(`
165
165
  `)?`
166
166
 
167
167
  $$
@@ -175,28 +175,28 @@ $$
175
175
  ${h}
176
176
  $$
177
177
 
178
- `}))),n)).join("")}function nn(t){if(!t||!Number.isFinite(t))return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=new Date,r=m=>m.toString().padStart(2,"0"),i=`${r(s.getHours())}:${r(s.getMinutes())}`,d=s.getFullYear()===n.getFullYear();if(d&&s.getMonth()===n.getMonth()&&s.getDate()===n.getDate())return i;const h=`${s.getMonth()+1}-${s.getDate()} ${i}`;return d?h:`${s.getFullYear()}-${h}`}let Ke=null;function an(){return Ke||(Ke=he(()=>import("./mermaid.core-DVy3DGpO.js").then(t=>t.bm),__vite__mapDeps([0,1])).then(t=>{var r;const s=t.default,n=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)").matches);return s.initialize({startOnLoad:!1,theme:n?"dark":"default",securityLevel:"strict",fontFamily:"inherit"}),s})),Ke}function cs(t){if(!(typeof document>"u"))for(const s of[`#${t}`,`#d${t}`,`#${t}-temp`])document.querySelectorAll(s).forEach(n=>n.remove())}let rn=0;function on({chart:t}){const[s,n]=a.useState(null),[r,i]=a.useState(null),d=a.useRef(`mermaid-${++rn}`);return a.useEffect(()=>{let u=!1;const h=d.current,m=t.trim();if(!m){n(null),i(null);return}return an().then(async l=>(await l.parse(m),l.render(h,m))).then(({svg:l})=>{u||(n(l),i(null))}).catch(l=>{if(cs(h),u)return;const p=l instanceof Error?l.message:String(l);i(p),n(null)}),()=>{u=!0,cs(h)}},[t]),r?e.jsxs("div",{className:"mermaid-block mermaid-block-error",children:[e.jsxs("div",{className:"mermaid-error-banner",children:["⚠ Mermaid 渲染失败:",r]}),e.jsx("pre",{children:e.jsx("code",{className:"language-mermaid",children:t})})]}):s?e.jsx("div",{className:"mermaid-block",dangerouslySetInnerHTML:{__html:s}}):e.jsx("pre",{className:"mermaid-block mermaid-block-loading",children:e.jsx("code",{className:"language-mermaid",children:t})})}const ln=a.memo(on),Ie=[Gs,Ks],cn={strict:"ignore",throwOnError:!1,errorColor:"inherit",output:"htmlAndMathml"},Me=[Vs,[Js,cn]];function dn({className:t,children:s,...n}){const r=/language-(\w+)/.exec(t??"");if((r==null?void 0:r[1])==="mermaid"){const d=Array.isArray(s)?s.join(""):String(s??"");return e.jsx(ln,{chart:d.replace(/\n$/,"")})}return e.jsx("code",{className:t,...n,children:s})}const Te={code:dn};function un(t){if(t===0)return"—";const s=["B","KB","MB","GB"];let n=0,r=t;for(;r>=1024&&n<s.length-1;)r/=1024,n++;return`${r.toFixed(n===0?0:1)} ${s[n]}`}function hn(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function mn({open:t,onClose:s,sessionId:n}){const[r,i]=a.useState([]),[d,u]=a.useState(!1),[h,m]=a.useState(null),[l,p]=a.useState(null),x=a.useCallback(async()=>{if(!n||n==="__new_chat__"){i([]);return}u(!0),m(null);try{const c=await te(`/api/uploaded-files?sessionId=${encodeURIComponent(n)}`);if(c.error)throw new Error(c.error);i(c.files||[])}catch(c){m(c instanceof Error?c.message:String(c)),i([])}finally{u(!1)}},[n]);a.useEffect(()=>{t&&x()},[t,x]);const g=a.useCallback(async c=>{if(window.confirm(`确定删除文件 "${c.name}"?删除后无法恢复。`)){p(c.id);try{const E=await fetch("/api/uploaded-files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:c.sessionId,fileId:c.id})}),C=await E.json();if(!E.ok||C.error)throw new Error(C.error||`HTTP ${E.status}`);await x()}catch(E){window.alert(`删除失败:${E instanceof Error?E.message:String(E)}`)}finally{p(null)}}},[x]),k=a.useCallback(c=>{const L=`/api/uploaded-files/download?sessionId=${encodeURIComponent(c.sessionId)}&fileId=${encodeURIComponent(c.id)}`;window.open(L,"_blank")},[]);return t?e.jsxs("div",{className:"uploaded-files-drawer",children:[e.jsxs("div",{className:"uploaded-files-drawer-header",children:[e.jsx("span",{className:"uploaded-files-drawer-title",children:"已上传的文件"}),e.jsxs("div",{className:"uploaded-files-drawer-actions",children:[e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:x,title:"刷新",disabled:d,children:e.jsx(qt,{size:14,className:d?"spin":""})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:s,title:"关闭",children:e.jsx(Ns,{size:14})})]})]}),e.jsxs("div",{className:"uploaded-files-drawer-body",children:[h&&e.jsxs("div",{className:"uploaded-files-drawer-error",children:["加载失败:",h]}),!h&&r.length===0&&!d&&e.jsx("div",{className:"uploaded-files-drawer-empty",children:"当前会话没有已上传的文件"}),r.map(c=>e.jsxs("div",{className:"uploaded-files-drawer-item",children:[e.jsx(Et,{size:16,className:"uploaded-files-drawer-icon"}),e.jsxs("div",{className:"uploaded-files-drawer-info",children:[e.jsx("div",{className:"uploaded-files-drawer-name",title:c.name,children:c.name}),e.jsxs("div",{className:"uploaded-files-drawer-meta",children:[un(c.size)," · ",c.mimeType," · ",hn(c.uploadedAt)]}),e.jsxs("div",{className:"uploaded-files-drawer-id",title:c.id,children:["ID: ",c.id]})]}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:()=>k(c),title:"下载",children:e.jsx(It,{size:14})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn danger",onClick:()=>g(c),disabled:l===c.id,title:"删除",children:e.jsx(Kt,{size:14})})]},c.id))]})]}):null}function ds(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>s(r.result),r.onerror=n,r.readAsDataURL(t)})}const fn=a.memo(a.forwardRef(function({loading:s,connected:n,canUpload:r,canUploadImage:i,canUploadFile:d,acceptAttr:u,onSend:h,onAbort:m},l){const[p,x]=a.useState(""),[g,k]=a.useState([]),[c,L]=a.useState([]),E=a.useRef([]),C=a.useRef(null),S=a.useRef(null),G=a.useCallback(()=>{const _=C.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]),v=a.useCallback(async _=>{const T=[],A=[],z=[];for(const U of Array.from(_))if(U.type.startsWith("image/")&&i){if(U.size>10*1024*1024)continue;const Q=await ds(U);T.push(Q),z.push("image")}else if(d){if(U.size>20*1024*1024)continue;const Q=await ds(U);A.push({name:U.name,data:Q,mimeType:U.type||void 0}),z.push("file")}T.length>0&&k(U=>[...U,...T]),A.length>0&&L(U=>[...U,...A]),z.length>0&&(E.current=[...E.current,...z])},[i,d]);a.useImperativeHandle(l,()=>({addFiles:v}),[v]);const q=a.useCallback(async()=>{await h(p,c,g,E.current),x(""),k([]),L([]),E.current=[],C.current&&(C.current.style.height="auto")},[p,c,g,h]),F=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),q())},Y=async _=>{_.target.files&&await v(_.target.files),_.target.value=""},Z=async _=>{var z;if(!i)return;const T=(z=_.clipboardData)==null?void 0:z.items;if(!T)return;const A=[];for(const U of Array.from(T)){if(!U.type.startsWith("image/"))continue;const Q=U.getAsFile();Q&&A.push(Q)}A.length>0&&await v(A)},b=_=>{k(z=>z.filter((U,Q)=>Q!==_));const T=[...E.current];let A=0;for(let z=0;z<T.length;z++)if(T[z]==="image"){if(A===_){T.splice(z,1);break}A++}E.current=T},D=_=>{L(z=>z.filter((U,Q)=>Q!==_));const T=[...E.current];let A=0;for(let z=0;z<T.length;z++)if(T[z]==="file"){if(A===_){T.splice(z,1);break}A++}E.current=T},f=E.current,y=new Array(g.length),V=new Array(c.length);{let _=0,T=0;for(let A=0;A<f.length;A++)f[A]==="image"?(_<y.length&&(y[_]=A+1),_++):f[A]==="file"&&(T<V.length&&(V[T]=A+1),T++)}const J=!!(p.trim()||g.length>0||c.length>0),ae=s&&!J;return e.jsxs(e.Fragment,{children:[g.length>0&&e.jsx("div",{className:"pending-images",children:g.map((_,T)=>e.jsxs("div",{className:"pending-image-item",children:[e.jsx("img",{src:_,alt:`pending-${T}`}),e.jsx("button",{className:"pending-image-remove",onClick:()=>b(T),children:"×"}),y[T]>0&&e.jsxs("span",{className:"pending-order-badge",children:["#",y[T]]})]},T))}),c.length>0&&e.jsx("div",{className:"pending-files",children:c.map((_,T)=>e.jsxs("div",{className:"pending-file-item",children:[V[T]>0&&e.jsxs("span",{className:"pending-file-order",children:["#",V[T]]}),e.jsx("span",{className:"pending-file-icon",children:e.jsx(Ze,{size:14})}),e.jsx("span",{className:"pending-file-name",children:_.name}),e.jsx("button",{className:"pending-file-remove",onClick:()=>D(T),children:"×"})]},T))}),e.jsxs("div",{className:"input-area",children:[e.jsx("input",{ref:S,type:"file",accept:u,multiple:!0,style:{display:"none"},onChange:Y}),r&&e.jsx("button",{className:"upload-btn",onClick:()=>{var _;return(_=S.current)==null?void 0:_.click()},disabled:!n,title:i&&d?"上传图片或文件":i?"上传图片":"上传文件",children:e.jsx(ws,{size:18})}),e.jsx("textarea",{ref:C,value:p,onChange:_=>{x(_.target.value),G()},onKeyDown:F,onPaste:Z,placeholder:"输入消息... (Enter 发送, Shift+Enter 换行)",disabled:!n,rows:1}),ae?e.jsx("button",{className:"send-btn stop-mode",onClick:m,title:"停止生成",children:e.jsx(Jt,{size:16})}):e.jsx("button",{className:"send-btn",onClick:()=>{q()},disabled:!n||!J,children:"↑"})]})]})}));function pn({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());if(a.useEffect(()=>{if(s||!t)return;const d=setInterval(()=>r(Date.now()),100);return()=>clearInterval(d)},[t,s]),!t)return null;const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"tool-call-timer",children:[i.toFixed(1),"s"]})}function us({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());a.useEffect(()=>{if(s)return;let d;const u=()=>{r(Date.now()),d=requestAnimationFrame(u)};return d=requestAnimationFrame(u),()=>cancelAnimationFrame(d)},[s]);const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"compress-timer",children:[i.toFixed(1),"s"]})}function xn({seg:t,index:s}){return e.jsxs("details",{className:"tool-call-block",children:[e.jsxs("summary",{className:"tool-call-summary",children:[e.jsx(ss,{size:14})," ",t.name,t.result==null?" …":"",e.jsx(pn,{startTime:t.startTime,endTime:t.endTime})]}),e.jsxs("div",{className:"tool-call-content",children:[e.jsxs("div",{className:"tool-call-args",children:[e.jsx("strong",{children:"参数"}),e.jsx("pre",{children:JSON.stringify(t.args,null,2)})]}),t.result!=null&&e.jsxs("div",{className:"tool-call-result",children:[e.jsx("strong",{children:"结果"}),e.jsx("pre",{children:t.result})]})]})]},s)}const gn=[".txt",".md",".csv",".json",".xml",".html",".htm",".css",".js",".ts",".yaml",".yml",".ini",".cfg",".conf",".log",".sh",".py",".java",".c",".cpp",".h",".rs",".go",".rb",".php",".sql",".pdf",".docx"],jn=gn.join(",")+",text/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document";function vn(t){const s=t.trim();if(!s.startsWith("{"))return null;try{const n=JSON.parse(s);return typeof n!="object"||n===null||Array.isArray(n)?null:n}catch{return null}}function yn(t){const s=t.trim();if(!s.startsWith("{"))return null;const n=[];let r=1;const i=()=>{for(;r<s.length&&/[\s,]/.test(s[r]);)r++};for(;r<s.length&&(i(),!(r>=s.length||s[r]==="}"||s[r]!=='"'));){r++;let d="",u=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length)d+=s[r+1],r+=2;else if(s[r]==='"'){u=!0,r++;break}else d+=s[r],r++;if(!u){n.push({key:d,keyDone:!1,value:"",valueDone:!1,valueType:"unknown"});break}if(i(),r>=s.length||s[r]!==":"){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(r++,i(),r>=s.length){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(s[r]==='"'){r++;let h="",m=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length){const l=s[r+1];h+=l==="n"?`
179
- `:l==="t"?" ":l==='"'?'"':l==="\\"?"\\":l,r+=2}else if(s[r]==='"'){m=!0,r++;break}else h+=s[r],r++;n.push({key:d,keyDone:!0,value:h,valueDone:m,valueType:"string"})}else if(s[r]==="{"||s[r]==="["){const h=s[r],m=h==="{"?"}":"]";let l=1;const p=r;r++;let x=!1;for(;r<s.length&&l>0;)x?s[r]==="\\"?r++:s[r]==='"'&&(x=!1):s[r]==='"'?x=!0:s[r]===h?l++:s[r]===m&&l--,r++;n.push({key:d,keyDone:!0,value:s.slice(p,r),valueDone:l===0,valueType:h==="{"?"object":"array"})}else{let h="";for(;r<s.length&&!/[,\s}]/.test(s[r]);)h+=s[r],r++;const m=r<s.length&&/[,}]/.test(s[r]),l=/^(true|false)$/.test(h)?"boolean":h==="null"?"null":"number";n.push({key:d,keyDone:!0,value:h,valueDone:m,valueType:l})}}return n.length>0?n:null}const bs={mood:"心情",state:"状态",desire:"发言欲望",current_action:"当前动作",think:"思考",message:"回复",response:"回复",reply:"回复",content:"内容",analysis:"分析",file_analysis:"文件分析",image_analysis:"图片分析"},Cs=new Set(["message","response","reply","content","answer","text","msg"]);function wn({label:t,data:s}){const[n,r]=a.useState(!0);return e.jsxs("div",{className:"json-field json-field-group",children:[e.jsxs("div",{className:"json-field-header json-field-toggle",onClick:()=>r(!n),children:[n?e.jsx(js,{size:14}):e.jsx(vs,{size:14}),e.jsx("span",{className:"json-field-label",children:t})]}),n&&e.jsx("div",{className:"json-field-children",children:Object.entries(s).map(([i,d])=>e.jsx(Ss,{fieldKey:i,value:d},i))})]})}function Ss({fieldKey:t,value:s}){const n=bs[t]||t;if(s==null||s==="")return null;if(typeof s=="object"&&!Array.isArray(s))return e.jsx(wn,{label:n,data:s});if(Array.isArray(s))return e.jsxs("div",{className:"json-field",children:[e.jsx("span",{className:"json-field-label",children:n}),e.jsx("span",{className:"json-field-value",children:s.map(String).join(", ")})]});const r=String(s),i=Cs.has(t);return e.jsxs("div",{className:`json-field${i?" json-field-reply":""}`,children:[e.jsx("span",{className:"json-field-label",children:n}),i?e.jsx("div",{className:"json-field-value json-field-value-md",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(r)})}):e.jsx("span",{className:"json-field-value",children:r})]})}function Nn({data:t}){return e.jsx("div",{className:"json-message-view",children:Object.entries(t).map(([s,n])=>e.jsx(Ss,{fieldKey:s,value:n},s))})}function kn({fields:t}){return e.jsx("div",{className:"json-message-view",children:t.map((s,n)=>{const i=n===t.length-1&&(!s.valueDone||!s.keyDone),d=s.keyDone&&bs[s.key]||s.key,u=s.keyDone&&Cs.has(s.key);return e.jsxs("div",{className:`json-field${u?" json-field-reply":""}`,children:[e.jsxs("span",{className:`json-field-label${s.keyDone?"":" json-field-partial"}`,children:[d,!s.keyDone&&i&&e.jsx("span",{className:"streaming-cursor"})]}),s.keyDone&&(u&&s.value?e.jsxs("div",{className:"json-field-value json-field-value-md",children:[e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s.value)}),i&&e.jsx("span",{className:"streaming-cursor"})]}):e.jsxs("span",{className:"json-field-value",children:[s.value,i&&e.jsx("span",{className:"streaming-cursor"})]}))]},n)})})}const Ue=a.memo(function({content:s}){const n=vn(s);if(n)return e.jsx(Nn,{data:n});if(s.trim().startsWith("{")){const i=yn(s);return i?e.jsx(kn,{fields:i}):null}return e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s)})});function bn(t){if(!t)return"";const s=[];return t.image&&s.push("image/*"),t.file&&s.push(jn),s.push("audio/*"),s.push("video/*"),s.join(",")}function Cn({status:t}){switch(t){case"completed":return e.jsx(ys,{size:14,className:"todo-icon todo-icon-done"});case"in-progress":return e.jsx(Qe,{size:14,className:"todo-icon todo-icon-active"});default:return e.jsx(Ct,{size:14,className:"todo-icon todo-icon-pending"})}}function Sn({items:t,onClear:s,loading:n}){const[r,i]=a.useState(!0),d=t.filter(l=>l.status==="completed").length,u=t.length,h=d===u,m=!h&&n;return e.jsxs("div",{className:`todo-bar ${h?"todo-bar-done":""}`,children:[e.jsxs("div",{className:"todo-bar-header",onClick:()=>i(!r),children:[e.jsx(At,{size:15,className:"todo-bar-icon"}),e.jsx("span",{className:"todo-bar-title",children:"任务计划"}),e.jsxs("span",{className:"todo-bar-count",children:[d,"/",u]}),e.jsx("div",{className:"todo-bar-progress",children:e.jsx("div",{className:"todo-bar-progress-fill",style:{width:`${u>0?d/u*100:0}%`}})}),e.jsx("button",{className:"todo-bar-toggle",title:r?"收起":"展开",children:r?e.jsx(js,{size:14}):e.jsx(vs,{size:14})}),e.jsx("button",{className:"todo-bar-clear",onClick:l=>{l.stopPropagation(),m||s()},disabled:m,title:m?"任务执行中,无法清除":"清除计划",children:e.jsx(Ns,{size:14})})]}),r&&e.jsx("div",{className:"todo-bar-list",children:t.map(l=>e.jsxs("div",{className:`todo-item todo-item-${l.status}`,children:[e.jsx(Cn,{status:l.status}),e.jsx("span",{className:"todo-item-title",children:l.title})]},l.id))})]})}const es="aalis:open-lightbox";function hs(t){window.dispatchEvent(new CustomEvent(es,{detail:t}))}const _n=a.memo(function({msg:s,senderName:n,isLast:r,isGenerating:i,onAbort:d,checkpoint:u,rolledBack:h,onRollback:m,onRollbackWithChat:l,toolCallsProgress:p}){return s.role==="system"?e.jsxs("div",{className:"system-event-separator",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(gs,{size:12})," ",s.content]}),e.jsx("span",{className:"system-event-line"})]}):e.jsxs("div",{className:`message-group ${s.role}`,children:[e.jsxs("div",{className:"message-sender",children:[e.jsx("span",{className:"message-sender-name",children:s.role==="user"?"You":n}),s.timestamp?e.jsx("span",{className:"message-time",title:new Date(s.timestamp).toLocaleString(),children:nn(s.timestamp)}):null,s.role==="assistant"&&s.modelInfo&&(s.modelInfo.model||s.modelInfo.completionTokens!=null)?e.jsxs("span",{className:"message-model-badge",title:[s.modelInfo.provider&&s.modelInfo.model?`${s.modelInfo.provider} / ${s.modelInfo.model}`:s.modelInfo.model,s.modelInfo.completionTokens!=null?`本次生成 ${s.modelInfo.completionTokens} tok`:null,s.modelInfo.promptTokens!=null?`上下文 ${s.modelInfo.promptTokens} tok`:null,s.modelInfo.elapsedMs!=null?`耗时 ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:null].filter(Boolean).join(" · "),children:[s.modelInfo.model??"",s.modelInfo.completionTokens!=null?` · ${(s.modelInfo.completionTokens/1e3).toFixed(1)}k`:"",s.modelInfo.elapsedMs!=null?` · ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:""]}):null]}),s.role==="user"&&s.images&&s.images.length>0&&e.jsx("div",{className:"message-images",children:s.images.map((x,g)=>e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(x),alt:`attached-${g}`,className:"message-image",onClick:()=>hs(je(x))})},g))}),s.role==="user"&&s.fileNames&&s.fileNames.length>0&&e.jsx("div",{className:"message-files",children:s.fileNames.map((x,g)=>e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",x]},g))}),s.role==="assistant"&&s.attachments&&s.attachments.length>0&&e.jsx("div",{className:"message-images",children:s.attachments.map((x,g)=>x.kind==="image"?e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(x.data),alt:x.name??`attachment-${g}`,className:"message-image",onClick:()=>hs(je(x.data))})},`a-${g}`):x.kind==="video"?e.jsx("video",{controls:!0,src:je(x.data),className:"message-image"},`a-${g}`):x.kind==="audio"?e.jsx("audio",{controls:!0,src:je(x.data)},`a-${g}`):e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",x.name??"attachment"]},`a-${g}`))}),s.role==="assistant"&&s.segments&&s.segments.length>0?e.jsx("div",{className:"message-bubble",children:(()=>{const x=[];let g=0;for(;g<s.segments.length;){const k=s.segments[g];if(k.type==="reasoning_text"){const c=[];for(;g<s.segments.length&&s.segments[g].type==="reasoning_text";)c.push(s.segments[g]),g++;const L=c.filter(E=>E.type==="reasoning_text").map(E=>E.content).join("");L&&x.push(e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(os,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(L)})})]},`r-${g}`));continue}if(k.type==="text"){k.content&&x.push(e.jsx(Ue,{content:k.content},`t-${g}`)),g++;continue}x.push(e.jsx(xn,{seg:k,index:g},`tc-${g}`)),g++}return x})()}):s.role==="assistant"&&s.reasoningContent?e.jsxs(e.Fragment,{children:[e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(os,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s.reasoningContent)})})]}),e.jsx("div",{className:"message-bubble",children:e.jsx(Ue,{content:s.content})})]}):e.jsx("div",{className:"message-bubble",children:s.role==="assistant"?e.jsx(Ue,{content:s.content}):s.content}),s.role==="assistant"&&p&&p.size>0&&e.jsx("div",{className:"tool-call-progress-bubble",children:[...p.entries()].sort((x,g)=>x[0]-g[0]).map(([x,g])=>e.jsx(_s,{name:g.name,charsAccumulated:g.charsAccumulated,startedAt:g.startedAt},`pending-${x}`))}),r&&i&&s.role==="assistant"&&e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"}),s.role==="assistant"&&u&&!i&&(h?e.jsxs("span",{className:"checkpoint-rolled-back",children:[e.jsx(Je,{size:12})," 此次修改已回滚"]}):e.jsxs("div",{className:"checkpoint-rollback-actions",children:[u.fileCount>0&&e.jsxs("button",{className:"checkpoint-rollback-btn",onClick:()=>m==null?void 0:m(u),title:`仅回滚本回合的 ${u.fileCount} 个文件改动(保留对话)${u.execUsed?`
178
+ `}))),n)).join("")}function an(t){if(!t||!Number.isFinite(t))return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=new Date,r=m=>m.toString().padStart(2,"0"),i=`${r(s.getHours())}:${r(s.getMinutes())}`,d=s.getFullYear()===n.getFullYear();if(d&&s.getMonth()===n.getMonth()&&s.getDate()===n.getDate())return i;const h=`${s.getMonth()+1}-${s.getDate()} ${i}`;return d?h:`${s.getFullYear()}-${h}`}let Ke=null;function rn(){return Ke||(Ke=he(()=>import("./mermaid.core-BK17wB8Y.js").then(t=>t.bm),__vite__mapDeps([0,1])).then(t=>{var r;const s=t.default,n=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)").matches);return s.initialize({startOnLoad:!1,theme:n?"dark":"default",securityLevel:"strict",fontFamily:"inherit"}),s})),Ke}function cs(t){if(!(typeof document>"u"))for(const s of[`#${t}`,`#d${t}`,`#${t}-temp`])document.querySelectorAll(s).forEach(n=>n.remove())}let on=0;function ln({chart:t}){const[s,n]=a.useState(null),[r,i]=a.useState(null),d=a.useRef(`mermaid-${++on}`);return a.useEffect(()=>{let u=!1;const h=d.current,m=t.trim();if(!m){n(null),i(null);return}return rn().then(async l=>(await l.parse(m),l.render(h,m))).then(({svg:l})=>{u||(n(l),i(null))}).catch(l=>{if(cs(h),u)return;const p=l instanceof Error?l.message:String(l);i(p),n(null)}),()=>{u=!0,cs(h)}},[t]),r?e.jsxs("div",{className:"mermaid-block mermaid-block-error",children:[e.jsxs("div",{className:"mermaid-error-banner",children:["⚠ Mermaid 渲染失败:",r]}),e.jsx("pre",{children:e.jsx("code",{className:"language-mermaid",children:t})})]}):s?e.jsx("div",{className:"mermaid-block",dangerouslySetInnerHTML:{__html:s}}):e.jsx("pre",{className:"mermaid-block mermaid-block-loading",children:e.jsx("code",{className:"language-mermaid",children:t})})}const cn=a.memo(ln),Ie=[Gs,Ks,Us],dn={strict:"ignore",throwOnError:!1,errorColor:"inherit",output:"htmlAndMathml"},Me=[Vs,[Js,dn]];function un({className:t,children:s,...n}){const r=/language-(\w+)/.exec(t??"");if((r==null?void 0:r[1])==="mermaid"){const d=Array.isArray(s)?s.join(""):String(s??"");return e.jsx(cn,{chart:d.replace(/\n$/,"")})}return e.jsx("code",{className:t,...n,children:s})}const Te={code:un};function hn(t){if(t===0)return"—";const s=["B","KB","MB","GB"];let n=0,r=t;for(;r>=1024&&n<s.length-1;)r/=1024,n++;return`${r.toFixed(n===0?0:1)} ${s[n]}`}function mn(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function fn({open:t,onClose:s,sessionId:n}){const[r,i]=a.useState([]),[d,u]=a.useState(!1),[h,m]=a.useState(null),[l,p]=a.useState(null),x=a.useCallback(async()=>{if(!n||n==="__new_chat__"){i([]);return}u(!0),m(null);try{const c=await te(`/api/uploaded-files?sessionId=${encodeURIComponent(n)}`);if(c.error)throw new Error(c.error);i(c.files||[])}catch(c){m(c instanceof Error?c.message:String(c)),i([])}finally{u(!1)}},[n]);a.useEffect(()=>{t&&x()},[t,x]);const g=a.useCallback(async c=>{if(window.confirm(`确定删除文件 "${c.name}"?删除后无法恢复。`)){p(c.id);try{const E=await fetch("/api/uploaded-files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:c.sessionId,fileId:c.id})}),C=await E.json();if(!E.ok||C.error)throw new Error(C.error||`HTTP ${E.status}`);await x()}catch(E){window.alert(`删除失败:${E instanceof Error?E.message:String(E)}`)}finally{p(null)}}},[x]),k=a.useCallback(c=>{const L=`/api/uploaded-files/download?sessionId=${encodeURIComponent(c.sessionId)}&fileId=${encodeURIComponent(c.id)}`;window.open(L,"_blank")},[]);return t?e.jsxs("div",{className:"uploaded-files-drawer",children:[e.jsxs("div",{className:"uploaded-files-drawer-header",children:[e.jsx("span",{className:"uploaded-files-drawer-title",children:"已上传的文件"}),e.jsxs("div",{className:"uploaded-files-drawer-actions",children:[e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:x,title:"刷新",disabled:d,children:e.jsx(qt,{size:14,className:d?"spin":""})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:s,title:"关闭",children:e.jsx(Ns,{size:14})})]})]}),e.jsxs("div",{className:"uploaded-files-drawer-body",children:[h&&e.jsxs("div",{className:"uploaded-files-drawer-error",children:["加载失败:",h]}),!h&&r.length===0&&!d&&e.jsx("div",{className:"uploaded-files-drawer-empty",children:"当前会话没有已上传的文件"}),r.map(c=>e.jsxs("div",{className:"uploaded-files-drawer-item",children:[e.jsx(Lt,{size:16,className:"uploaded-files-drawer-icon"}),e.jsxs("div",{className:"uploaded-files-drawer-info",children:[e.jsx("div",{className:"uploaded-files-drawer-name",title:c.name,children:c.name}),e.jsxs("div",{className:"uploaded-files-drawer-meta",children:[hn(c.size)," · ",c.mimeType," · ",mn(c.uploadedAt)]}),e.jsxs("div",{className:"uploaded-files-drawer-id",title:c.id,children:["ID: ",c.id]})]}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:()=>k(c),title:"下载",children:e.jsx(Mt,{size:14})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn danger",onClick:()=>g(c),disabled:l===c.id,title:"删除",children:e.jsx(Ut,{size:14})})]},c.id))]})]}):null}function ds(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>s(r.result),r.onerror=n,r.readAsDataURL(t)})}const pn=a.memo(a.forwardRef(function({loading:s,connected:n,canUpload:r,canUploadImage:i,canUploadFile:d,acceptAttr:u,onSend:h,onAbort:m},l){const[p,x]=a.useState(""),[g,k]=a.useState([]),[c,L]=a.useState([]),E=a.useRef([]),C=a.useRef(null),S=a.useRef(null),G=a.useCallback(()=>{const _=C.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]),v=a.useCallback(async _=>{const T=[],A=[],z=[];for(const K of Array.from(_))if(K.type.startsWith("image/")&&i){if(K.size>10*1024*1024)continue;const Q=await ds(K);T.push(Q),z.push("image")}else if(d){if(K.size>20*1024*1024)continue;const Q=await ds(K);A.push({name:K.name,data:Q,mimeType:K.type||void 0}),z.push("file")}T.length>0&&k(K=>[...K,...T]),A.length>0&&L(K=>[...K,...A]),z.length>0&&(E.current=[...E.current,...z])},[i,d]);a.useImperativeHandle(l,()=>({addFiles:v}),[v]);const B=a.useCallback(async()=>{await h(p,c,g,E.current),x(""),k([]),L([]),E.current=[],C.current&&(C.current.style.height="auto")},[p,c,g,h]),F=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),B())},Y=async _=>{_.target.files&&await v(_.target.files),_.target.value=""},Z=async _=>{var z;if(!i)return;const T=(z=_.clipboardData)==null?void 0:z.items;if(!T)return;const A=[];for(const K of Array.from(T)){if(!K.type.startsWith("image/"))continue;const Q=K.getAsFile();Q&&A.push(Q)}A.length>0&&await v(A)},b=_=>{k(z=>z.filter((K,Q)=>Q!==_));const T=[...E.current];let A=0;for(let z=0;z<T.length;z++)if(T[z]==="image"){if(A===_){T.splice(z,1);break}A++}E.current=T},D=_=>{L(z=>z.filter((K,Q)=>Q!==_));const T=[...E.current];let A=0;for(let z=0;z<T.length;z++)if(T[z]==="file"){if(A===_){T.splice(z,1);break}A++}E.current=T},f=E.current,y=new Array(g.length),V=new Array(c.length);{let _=0,T=0;for(let A=0;A<f.length;A++)f[A]==="image"?(_<y.length&&(y[_]=A+1),_++):f[A]==="file"&&(T<V.length&&(V[T]=A+1),T++)}const J=!!(p.trim()||g.length>0||c.length>0),ae=s&&!J;return e.jsxs(e.Fragment,{children:[g.length>0&&e.jsx("div",{className:"pending-images",children:g.map((_,T)=>e.jsxs("div",{className:"pending-image-item",children:[e.jsx("img",{src:_,alt:`pending-${T}`}),e.jsx("button",{className:"pending-image-remove",onClick:()=>b(T),children:"×"}),y[T]>0&&e.jsxs("span",{className:"pending-order-badge",children:["#",y[T]]})]},T))}),c.length>0&&e.jsx("div",{className:"pending-files",children:c.map((_,T)=>e.jsxs("div",{className:"pending-file-item",children:[V[T]>0&&e.jsxs("span",{className:"pending-file-order",children:["#",V[T]]}),e.jsx("span",{className:"pending-file-icon",children:e.jsx(Ze,{size:14})}),e.jsx("span",{className:"pending-file-name",children:_.name}),e.jsx("button",{className:"pending-file-remove",onClick:()=>D(T),children:"×"})]},T))}),e.jsxs("div",{className:"input-area",children:[e.jsx("input",{ref:S,type:"file",accept:u,multiple:!0,style:{display:"none"},onChange:Y}),r&&e.jsx("button",{className:"upload-btn",onClick:()=>{var _;return(_=S.current)==null?void 0:_.click()},disabled:!n,title:i&&d?"上传图片或文件":i?"上传图片":"上传文件",children:e.jsx(ws,{size:18})}),e.jsx("textarea",{ref:C,value:p,onChange:_=>{x(_.target.value),G()},onKeyDown:F,onPaste:Z,placeholder:"输入消息... (Enter 发送, Shift+Enter 换行)",disabled:!n,rows:1}),ae?e.jsx("button",{className:"send-btn stop-mode",onClick:m,title:"停止生成",children:e.jsx(Gt,{size:16})}):e.jsx("button",{className:"send-btn",onClick:()=>{B()},disabled:!n||!J,children:"↑"})]})]})}));function xn({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());if(a.useEffect(()=>{if(s||!t)return;const d=setInterval(()=>r(Date.now()),100);return()=>clearInterval(d)},[t,s]),!t)return null;const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"tool-call-timer",children:[i.toFixed(1),"s"]})}function us({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());a.useEffect(()=>{if(s)return;let d;const u=()=>{r(Date.now()),d=requestAnimationFrame(u)};return d=requestAnimationFrame(u),()=>cancelAnimationFrame(d)},[s]);const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"compress-timer",children:[i.toFixed(1),"s"]})}function gn({seg:t,index:s}){return e.jsxs("details",{className:"tool-call-block",children:[e.jsxs("summary",{className:"tool-call-summary",children:[e.jsx(ss,{size:14})," ",t.name,t.result==null?" …":"",e.jsx(xn,{startTime:t.startTime,endTime:t.endTime})]}),e.jsxs("div",{className:"tool-call-content",children:[e.jsxs("div",{className:"tool-call-args",children:[e.jsx("strong",{children:"参数"}),e.jsx("pre",{children:JSON.stringify(t.args,null,2)})]}),t.result!=null&&e.jsxs("div",{className:"tool-call-result",children:[e.jsx("strong",{children:"结果"}),e.jsx("pre",{children:t.result})]})]})]},s)}const jn=[".txt",".md",".csv",".json",".xml",".html",".htm",".css",".js",".ts",".yaml",".yml",".ini",".cfg",".conf",".log",".sh",".py",".java",".c",".cpp",".h",".rs",".go",".rb",".php",".sql",".pdf",".docx"],vn=jn.join(",")+",text/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document";function yn(t){const s=t.trim();if(!s.startsWith("{"))return null;try{const n=JSON.parse(s);return typeof n!="object"||n===null||Array.isArray(n)?null:n}catch{return null}}function wn(t){const s=t.trim();if(!s.startsWith("{"))return null;const n=[];let r=1;const i=()=>{for(;r<s.length&&/[\s,]/.test(s[r]);)r++};for(;r<s.length&&(i(),!(r>=s.length||s[r]==="}"||s[r]!=='"'));){r++;let d="",u=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length)d+=s[r+1],r+=2;else if(s[r]==='"'){u=!0,r++;break}else d+=s[r],r++;if(!u){n.push({key:d,keyDone:!1,value:"",valueDone:!1,valueType:"unknown"});break}if(i(),r>=s.length||s[r]!==":"){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(r++,i(),r>=s.length){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(s[r]==='"'){r++;let h="",m=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length){const l=s[r+1];h+=l==="n"?`
179
+ `:l==="t"?" ":l==='"'?'"':l==="\\"?"\\":l,r+=2}else if(s[r]==='"'){m=!0,r++;break}else h+=s[r],r++;n.push({key:d,keyDone:!0,value:h,valueDone:m,valueType:"string"})}else if(s[r]==="{"||s[r]==="["){const h=s[r],m=h==="{"?"}":"]";let l=1;const p=r;r++;let x=!1;for(;r<s.length&&l>0;)x?s[r]==="\\"?r++:s[r]==='"'&&(x=!1):s[r]==='"'?x=!0:s[r]===h?l++:s[r]===m&&l--,r++;n.push({key:d,keyDone:!0,value:s.slice(p,r),valueDone:l===0,valueType:h==="{"?"object":"array"})}else{let h="";for(;r<s.length&&!/[,\s}]/.test(s[r]);)h+=s[r],r++;const m=r<s.length&&/[,}]/.test(s[r]),l=/^(true|false)$/.test(h)?"boolean":h==="null"?"null":"number";n.push({key:d,keyDone:!0,value:h,valueDone:m,valueType:l})}}return n.length>0?n:null}const bs={mood:"心情",state:"状态",desire:"发言欲望",current_action:"当前动作",think:"思考",message:"回复",response:"回复",reply:"回复",content:"内容",analysis:"分析",file_analysis:"文件分析",image_analysis:"图片分析"},Cs=new Set(["message","response","reply","content","answer","text","msg"]);function Nn({label:t,data:s}){const[n,r]=a.useState(!0);return e.jsxs("div",{className:"json-field json-field-group",children:[e.jsxs("div",{className:"json-field-header json-field-toggle",onClick:()=>r(!n),children:[n?e.jsx(js,{size:14}):e.jsx(vs,{size:14}),e.jsx("span",{className:"json-field-label",children:t})]}),n&&e.jsx("div",{className:"json-field-children",children:Object.entries(s).map(([i,d])=>e.jsx(Ss,{fieldKey:i,value:d},i))})]})}function Ss({fieldKey:t,value:s}){const n=bs[t]||t;if(s==null||s==="")return null;if(typeof s=="object"&&!Array.isArray(s))return e.jsx(Nn,{label:n,data:s});if(Array.isArray(s))return e.jsxs("div",{className:"json-field",children:[e.jsx("span",{className:"json-field-label",children:n}),e.jsx("span",{className:"json-field-value",children:s.map(String).join(", ")})]});const r=String(s),i=Cs.has(t);return e.jsxs("div",{className:`json-field${i?" json-field-reply":""}`,children:[e.jsx("span",{className:"json-field-label",children:n}),i?e.jsx("div",{className:"json-field-value json-field-value-md",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(r)})}):e.jsx("span",{className:"json-field-value",children:r})]})}function kn({data:t}){return e.jsx("div",{className:"json-message-view",children:Object.entries(t).map(([s,n])=>e.jsx(Ss,{fieldKey:s,value:n},s))})}function bn({fields:t}){return e.jsx("div",{className:"json-message-view",children:t.map((s,n)=>{const i=n===t.length-1&&(!s.valueDone||!s.keyDone),d=s.keyDone&&bs[s.key]||s.key,u=s.keyDone&&Cs.has(s.key);return e.jsxs("div",{className:`json-field${u?" json-field-reply":""}`,children:[e.jsxs("span",{className:`json-field-label${s.keyDone?"":" json-field-partial"}`,children:[d,!s.keyDone&&i&&e.jsx("span",{className:"streaming-cursor"})]}),s.keyDone&&(u&&s.value?e.jsxs("div",{className:"json-field-value json-field-value-md",children:[e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s.value)}),i&&e.jsx("span",{className:"streaming-cursor"})]}):e.jsxs("span",{className:"json-field-value",children:[s.value,i&&e.jsx("span",{className:"streaming-cursor"})]}))]},n)})})}const Ue=a.memo(function({content:s}){const n=yn(s);if(n)return e.jsx(kn,{data:n});if(s.trim().startsWith("{")){const i=wn(s);return i?e.jsx(bn,{fields:i}):null}return e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s)})});function Cn(t){if(!t)return"";const s=[];return t.image&&s.push("image/*"),t.file&&s.push(vn),s.push("audio/*"),s.push("video/*"),s.join(",")}function Sn({status:t}){switch(t){case"completed":return e.jsx(ys,{size:14,className:"todo-icon todo-icon-done"});case"in-progress":return e.jsx(Qe,{size:14,className:"todo-icon todo-icon-active"});default:return e.jsx(St,{size:14,className:"todo-icon todo-icon-pending"})}}function _n({items:t,onClear:s,loading:n}){const[r,i]=a.useState(!0),d=t.filter(l=>l.status==="completed").length,u=t.length,h=d===u,m=!h&&n;return e.jsxs("div",{className:`todo-bar ${h?"todo-bar-done":""}`,children:[e.jsxs("div",{className:"todo-bar-header",onClick:()=>i(!r),children:[e.jsx(zt,{size:15,className:"todo-bar-icon"}),e.jsx("span",{className:"todo-bar-title",children:"任务计划"}),e.jsxs("span",{className:"todo-bar-count",children:[d,"/",u]}),e.jsx("div",{className:"todo-bar-progress",children:e.jsx("div",{className:"todo-bar-progress-fill",style:{width:`${u>0?d/u*100:0}%`}})}),e.jsx("button",{className:"todo-bar-toggle",title:r?"收起":"展开",children:r?e.jsx(js,{size:14}):e.jsx(vs,{size:14})}),e.jsx("button",{className:"todo-bar-clear",onClick:l=>{l.stopPropagation(),m||s()},disabled:m,title:m?"任务执行中,无法清除":"清除计划",children:e.jsx(Ns,{size:14})})]}),r&&e.jsx("div",{className:"todo-bar-list",children:t.map(l=>e.jsxs("div",{className:`todo-item todo-item-${l.status}`,children:[e.jsx(Sn,{status:l.status}),e.jsx("span",{className:"todo-item-title",children:l.title})]},l.id))})]})}const es="aalis:open-lightbox";function hs(t){window.dispatchEvent(new CustomEvent(es,{detail:t}))}const $n=a.memo(function({msg:s,senderName:n,isLast:r,isGenerating:i,onAbort:d,checkpoint:u,rolledBack:h,onRollback:m,onRollbackWithChat:l,toolCallsProgress:p}){return s.role==="system"?e.jsxs("div",{className:"system-event-separator",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(gs,{size:12})," ",s.content]}),e.jsx("span",{className:"system-event-line"})]}):e.jsxs("div",{className:`message-group ${s.role}`,children:[e.jsxs("div",{className:"message-sender",children:[e.jsx("span",{className:"message-sender-name",children:s.role==="user"?"You":n}),s.timestamp?e.jsx("span",{className:"message-time",title:new Date(s.timestamp).toLocaleString(),children:an(s.timestamp)}):null,s.role==="assistant"&&s.modelInfo&&(s.modelInfo.model||s.modelInfo.completionTokens!=null)?e.jsxs("span",{className:"message-model-badge",title:[s.modelInfo.provider&&s.modelInfo.model?`${s.modelInfo.provider} / ${s.modelInfo.model}`:s.modelInfo.model,s.modelInfo.completionTokens!=null?`本次生成 ${s.modelInfo.completionTokens} tok`:null,s.modelInfo.promptTokens!=null?`上下文 ${s.modelInfo.promptTokens} tok`:null,s.modelInfo.elapsedMs!=null?`耗时 ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:null].filter(Boolean).join(" · "),children:[s.modelInfo.model??"",s.modelInfo.completionTokens!=null?` · ${(s.modelInfo.completionTokens/1e3).toFixed(1)}k`:"",s.modelInfo.elapsedMs!=null?` · ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:""]}):null]}),s.role==="user"&&s.images&&s.images.length>0&&e.jsx("div",{className:"message-images",children:s.images.map((x,g)=>e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(x),alt:`attached-${g}`,className:"message-image",onClick:()=>hs(je(x))})},g))}),s.role==="user"&&s.fileNames&&s.fileNames.length>0&&e.jsx("div",{className:"message-files",children:s.fileNames.map((x,g)=>e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",x]},g))}),s.role==="assistant"&&s.attachments&&s.attachments.length>0&&e.jsx("div",{className:"message-images",children:s.attachments.map((x,g)=>x.kind==="image"?e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(x.data),alt:x.name??`attachment-${g}`,className:"message-image",onClick:()=>hs(je(x.data))})},`a-${g}`):x.kind==="video"?e.jsx("video",{controls:!0,src:je(x.data),className:"message-image"},`a-${g}`):x.kind==="audio"?e.jsx("audio",{controls:!0,src:je(x.data)},`a-${g}`):e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",x.name??"attachment"]},`a-${g}`))}),s.role==="assistant"&&s.segments&&s.segments.length>0?e.jsx("div",{className:"message-bubble",children:(()=>{const x=[];let g=0;for(;g<s.segments.length;){const k=s.segments[g];if(k.type==="reasoning_text"){const c=[];for(;g<s.segments.length&&s.segments[g].type==="reasoning_text";)c.push(s.segments[g]),g++;const L=c.filter(E=>E.type==="reasoning_text").map(E=>E.content).join("");L&&x.push(e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(os,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(L)})})]},`r-${g}`));continue}if(k.type==="text"){k.content&&x.push(e.jsx(Ue,{content:k.content},`t-${g}`)),g++;continue}x.push(e.jsx(gn,{seg:k,index:g},`tc-${g}`)),g++}return x})()}):s.role==="assistant"&&s.reasoningContent?e.jsxs(e.Fragment,{children:[e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(os,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s.reasoningContent)})})]}),e.jsx("div",{className:"message-bubble",children:e.jsx(Ue,{content:s.content})})]}):e.jsx("div",{className:"message-bubble",children:s.role==="assistant"?e.jsx(Ue,{content:s.content}):s.content}),s.role==="assistant"&&p&&p.size>0&&e.jsx("div",{className:"tool-call-progress-bubble",children:[...p.entries()].sort((x,g)=>x[0]-g[0]).map(([x,g])=>e.jsx(_s,{name:g.name,charsAccumulated:g.charsAccumulated,startedAt:g.startedAt},`pending-${x}`))}),r&&i&&s.role==="assistant"&&e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"}),s.role==="assistant"&&u&&!i&&(h?e.jsxs("span",{className:"checkpoint-rolled-back",children:[e.jsx(Je,{size:12})," 此次修改已回滚"]}):e.jsxs("div",{className:"checkpoint-rollback-actions",children:[u.fileCount>0&&e.jsxs("button",{className:"checkpoint-rollback-btn",onClick:()=>m==null?void 0:m(u),title:`仅回滚本回合的 ${u.fileCount} 个文件改动(保留对话)${u.execUsed?`
180
180
  注意:本回合调用过 exec/shell,命令副作用无法回滚`:""}`,children:[e.jsx(Je,{size:12})," 回滚文件改动",u.execUsed&&e.jsxs("span",{className:"checkpoint-warn",children:[e.jsx(De,{size:11})," exec"]})]}),e.jsxs("button",{className:"checkpoint-rollback-btn",onClick:()=>l==null?void 0:l(u),title:`回滚本轮对话(含 ${u.fileCount} 处文件改动):删除本轮的用户提问、回复和工具调用记录,并恢复文件${u.execUsed?`
181
- 注意:本回合调用过 exec/shell,命令副作用无法回滚`:""}`,children:[e.jsx(Je,{size:12})," 回滚本轮对话(含文件)",u.execUsed&&e.jsxs("span",{className:"checkpoint-warn",children:[e.jsx(De,{size:11})," exec"]})]})]}))]})});function _s({name:t,charsAccumulated:s,startedAt:n}){const[r,i]=a.useState(Date.now()-n);a.useEffect(()=>{const u=window.setInterval(()=>i(Date.now()-n),100);return()=>window.clearInterval(u)},[n]);const d=(r/1e3).toFixed(1);return e.jsx("div",{className:"tool-call-block tool-call-block-pending","aria-live":"polite",children:e.jsxs("div",{className:"tool-call-summary",children:[e.jsx("span",{className:"tool-call-progress-icon",children:e.jsx(ss,{size:14})}),e.jsx("span",{children:t||"正在生成…"}),e.jsxs("span",{className:"tool-call-progress-meta",children:[s," 字符 · ",d,"s"]})]})})}function $n({messages:t,loading:s,connected:n,status:r,onSend:i,onAbort:d,width:u,sessionTitle:h,onNewSession:m,todoItems:l,onClearTodos:p,toolLimitReached:x,onContinueTools:g,toolCallsProgress:k,tokenUsage:c,compressingStatus:L,onCompress:E}){const C=a.useRef(null),S=a.useRef(null),G=a.useRef(null),v=a.useRef(!1),[q,F]=a.useState([]),[Y,Z]=a.useState(new Set),b=a.useRef(s);a.useEffect(()=>{let j=!1;async function R(){try{const B=oe();if(!B||B==="__new_chat__"){j||F([]);return}const W=await de("@aalis/plugin-checkpoint","listTurns",{sessionId:B});!j&&Array.isArray(W)&&F(W)}catch{}}return b.current&&!s?R():t.length===0?F([]):R(),b.current=s,()=>{j=!0}},[s,h,t.length]);const D=a.useMemo(()=>j=>{for(const R of q){const B=R.startedAt-1e3,W=(R.endedAt??R.startedAt+6e4)+5e3;if(j>=B&&j<=W)return R}},[q]),f=a.useCallback(async j=>{const R=j.filesPreview.slice(0,3).join(`
182
- `),B=j.fileCount>j.filesPreview.length?`
181
+ 注意:本回合调用过 exec/shell,命令副作用无法回滚`:""}`,children:[e.jsx(Je,{size:12})," 回滚本轮对话(含文件)",u.execUsed&&e.jsxs("span",{className:"checkpoint-warn",children:[e.jsx(De,{size:11})," exec"]})]})]}))]})});function _s({name:t,charsAccumulated:s,startedAt:n}){const[r,i]=a.useState(Date.now()-n);a.useEffect(()=>{const u=window.setInterval(()=>i(Date.now()-n),100);return()=>window.clearInterval(u)},[n]);const d=(r/1e3).toFixed(1);return e.jsx("div",{className:"tool-call-block tool-call-block-pending","aria-live":"polite",children:e.jsxs("div",{className:"tool-call-summary",children:[e.jsx("span",{className:"tool-call-progress-icon",children:e.jsx(ss,{size:14})}),e.jsx("span",{children:t||"正在生成…"}),e.jsxs("span",{className:"tool-call-progress-meta",children:[s," 字符 · ",d,"s"]})]})})}function In({messages:t,loading:s,connected:n,status:r,onSend:i,onAbort:d,width:u,sessionTitle:h,onNewSession:m,todoItems:l,onClearTodos:p,toolLimitReached:x,onContinueTools:g,toolCallsProgress:k,tokenUsage:c,compressingStatus:L,onCompress:E}){const C=a.useRef(null),S=a.useRef(null),G=a.useRef(null),v=a.useRef(!1),[B,F]=a.useState([]),[Y,Z]=a.useState(new Set),b=a.useRef(s);a.useEffect(()=>{let j=!1;async function R(){try{const q=oe();if(!q||q==="__new_chat__"){j||F([]);return}const W=await de("@aalis/plugin-checkpoint","listTurns",{sessionId:q});!j&&Array.isArray(W)&&F(W)}catch{}}return b.current&&!s?R():t.length===0?F([]):R(),b.current=s,()=>{j=!0}},[s,h,t.length]);const D=a.useMemo(()=>j=>{for(const R of B){const q=R.startedAt-1e3,W=(R.endedAt??R.startedAt+6e4)+5e3;if(j>=q&&j<=W)return R}},[B]),f=a.useCallback(async j=>{const R=j.filesPreview.slice(0,3).join(`
182
+ `),q=j.fileCount>j.filesPreview.length?`
183
183
  ... 共 ${j.fileCount} 个文件`:"",W=j.execUsed?`
184
184
 
185
185
  ⚠ 本回合调用过 exec/shell,命令的副作用无法回滚!`:"";if(window.confirm(`将回滚此回合的文件改动:
186
186
 
187
- ${R}${B}${W}
187
+ ${R}${q}${W}
188
188
 
189
189
  确定继续?`))try{const ee=await de("@aalis/plugin-checkpoint","rollback",{sessionId:oe(),turnId:j.turnId}),X=`回滚完成:恢复 ${ee.restored.length} 个,删除 ${ee.deleted.length} 个`;ee.errors.length>0?window.alert(`${X}
190
190
  失败 ${ee.errors.length} 个(如有新建文件在不可删除的根下,需手动删除):
191
191
  `+ee.errors.map(le=>`${le.uri}: ${le.reason}`).join(`
192
192
  `)):window.alert(X),Z(le=>new Set([...le,j.turnId]))}catch(ee){window.alert(`回滚失败:${ee.message}`)}},[]),y=a.useCallback(async j=>{const R=j.filesPreview.slice(0,3).join(`
193
- `),B=j.fileCount>j.filesPreview.length?`
193
+ `),q=j.fileCount>j.filesPreview.length?`
194
194
  ... 共 ${j.fileCount} 个文件`:"",W=j.execUsed?`
195
195
 
196
196
  ⚠ 本回合调用过 exec/shell,命令的副作用无法回滚!`:"",me=j.fileCount>0?`
197
197
 
198
198
  同时恢复以下文件:
199
- ${R}${B}`:"";if(window.confirm(`将回滚本轮对话:
199
+ ${R}${q}`:"";if(window.confirm(`将回滚本轮对话:
200
200
 
201
201
  · 删除本轮的用户提问、AI 回复和工具调用记录
202
202
  · 清除对应的向量记忆条目${me}${W}
@@ -204,4 +204,4 @@ ${R}${B}`:"";if(window.confirm(`将回滚本轮对话:
204
204
  此操作不可撤销。确定继续?`))try{const X=await de("@aalis/plugin-checkpoint","rollbackWithChat",{sessionId:oe(),turnId:j.turnId}),le=[];X.chatDeleted&&le.push(`删除 ${X.deletedMessages} 条消息`),j.fileCount>0&&le.push(`恢复 ${X.restored.length} 个文件,删除 ${X.deleted.length} 个新建文件`);const Oe=le.length>0?`回滚完成:${le.join(";")}`:"回滚完成";X.errors.length>0&&window.alert(`${Oe}
205
205
  失败 ${X.errors.length} 项:
206
206
  `+X.errors.map(ge=>`${ge.uri||"(memory)"}: ${ge.reason}`).join(`
207
- `)),Z(ge=>new Set([...ge,j.turnId]))}catch(X){window.alert(`回滚失败:${X.message}`)}},[]),V=a.useRef(null),J=a.useRef(!1),[ae,_]=a.useState(!1),T=a.useRef(0),[A,z]=a.useState(!1),[U,Q]=a.useState(!1),[xe,ue]=a.useState(null),ve=a.useRef(0),ye=a.useRef(0);a.useEffect(()=>{const j=B=>{const W=B.detail;typeof W=="string"&&ue(W)},R=B=>{B.key==="Escape"&&ue(null)};return window.addEventListener(es,j),window.addEventListener("keydown",R),()=>{window.removeEventListener(es,j),window.removeEventListener("keydown",R)}},[]);const re=r==null?void 0:r.uploadCapabilities,we=(re==null?void 0:re.image)??!1,Ne=(re==null?void 0:re.file)??!1,ke=we||Ne,Pe=bn(re);a.useEffect(()=>{L==="start"?(ve.current=Date.now(),ye.current=0):(L==="done"||L==="error")&&(ye.current=Date.now())},[L]),a.useEffect(()=>{const j=G.current;if(!j)return;const R=()=>{const{scrollTop:B,scrollHeight:W,clientHeight:me}=j;v.current=W-B-me>200,J.current=!0,V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{J.current=!1},300)};return j.addEventListener("scroll",R,{passive:!0}),()=>j.removeEventListener("scroll",R)},[]),a.useEffect(()=>{const j=G.current;if(!j)return;const R=new ResizeObserver(()=>{var B;!v.current&&!J.current&&((B=S.current)==null||B.scrollIntoView({behavior:s?"instant":"smooth"}))});return R.observe(j),()=>R.disconnect()},[t.length]),a.useEffect(()=>{var j;!v.current&&!J.current&&((j=S.current)==null||j.scrollIntoView({behavior:"smooth"}))},[t]);const Ae=a.useCallback((j,R,B,W)=>i(j,R,B,W),[i]),be=j=>{j.preventDefault(),j.stopPropagation(),T.current++,ke&&j.dataTransfer.types.includes("Files")&&_(!0)},Ce=j=>{j.preventDefault(),j.stopPropagation(),T.current--,T.current<=0&&(T.current=0,_(!1))},Ee=j=>{j.preventDefault(),j.stopPropagation()},ze=async j=>{var R;j.preventDefault(),j.stopPropagation(),T.current=0,_(!1),!(!ke||!j.dataTransfer.files.length)&&await((R=C.current)==null?void 0:R.addFiles(j.dataTransfer.files))},ie=t[t.length-1],Le=(ie==null?void 0:ie.role)==="assistant"&&s;return e.jsxs("div",{className:`chat-panel${ae?" drag-over":""}`,style:{width:u},onDragEnter:be,onDragLeave:Ce,onDragOver:Ee,onDrop:ze,children:[ae&&e.jsx("div",{className:"drag-overlay",children:e.jsxs("div",{className:"drag-overlay-content",children:[e.jsx(ws,{size:16})," 松开以上传文件"]})}),e.jsxs("div",{className:"chat-panel-header",children:[e.jsxs("span",{className:"chat-panel-title",children:[e.jsx(is,{size:16})," ",h||(r==null?void 0:r.name)||"Aalis"]}),e.jsxs("div",{className:"chat-panel-header-actions",children:[e.jsxs("div",{className:"token-usage-badge",onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),children:[e.jsx(ks,{size:12}),e.jsx("span",{className:`token-usage-number${c&&c.usageRatio>.85?" warn":c&&c.usageRatio>.7?" caution":""}`,children:c?c.used.toLocaleString():"--"}),A&&e.jsxs("div",{className:"token-usage-panel",children:[e.jsx("div",{className:"token-panel-title",children:"Token 使用情况"}),c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"token-panel-bar",children:e.jsx("div",{className:`token-panel-bar-fill${c.usageRatio>.85?" warn":c.usageRatio>.7?" caution":""}`,style:{width:`${Math.min(100,c.usageRatio*100)}%`}})}),e.jsxs("div",{className:"token-panel-ratio",children:[(c.usageRatio*100).toFixed(1),"% 已使用"]}),e.jsxs("div",{className:"token-panel-rows",children:[e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"上下文窗口"}),e.jsx("span",{children:c.contextWindow.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-section-header",children:["系统提示词 ",e.jsx("span",{className:"token-panel-section-total",children:c.breakdown.system.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"人设 / Persona"}),e.jsx("span",{children:c.breakdown.persona.toLocaleString()})]}),c.breakdown.memorySummary>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"对话摘要"}),e.jsx("span",{children:c.breakdown.memorySummary.toLocaleString()})]}),c.breakdown.memoryVector>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"向量记忆"}),e.jsx("span",{children:c.breakdown.memoryVector.toLocaleString()})]}),c.breakdown.skills>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"技能描述"}),e.jsx("span",{children:c.breakdown.skills.toLocaleString()})]}),c.breakdown.platform>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"平台提示"}),e.jsx("span",{children:c.breakdown.platform.toLocaleString()})]}),c.breakdown.subtask>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"子任务上下文"}),e.jsx("span",{children:c.breakdown.subtask.toLocaleString()})]}),c.breakdown.systemOther>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"其他系统提示"}),e.jsx("span",{children:c.breakdown.systemOther.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"历史消息"}),e.jsx("span",{children:c.breakdown.history.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具结果"}),e.jsx("span",{children:c.breakdown.toolResults.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具定义"}),e.jsx("span",{children:c.breakdown.toolDefs.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"回复保留量"}),e.jsx("span",{children:c.breakdown.reservedForReply.toLocaleString()})]})]}),E&&e.jsx("button",{className:"token-panel-compress-btn",onClick:j=>{j.stopPropagation(),E()},disabled:L==="start",children:L==="start"?e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:12,className:"compress-spinner"})," 压缩中…"]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{size:12})," 压缩对话"]})})]}):e.jsx("div",{className:"token-panel-empty",children:"发送消息后将显示 Token 用量统计"})]})]}),m&&e.jsx("button",{className:"chat-panel-new-btn",onClick:m,title:"新对话",children:"+"}),e.jsx("button",{className:"chat-panel-new-btn",onClick:()=>Q(j=>!j),title:"已上传的文件","aria-label":"已上传的文件",children:e.jsx(Rt,{size:14})})]})]}),e.jsx(mn,{open:U,onClose:()=>Q(!1),sessionId:oe()}),e.jsxs("div",{className:"messages",ref:G,children:[t.length===0&&e.jsxs("div",{className:"empty",children:[e.jsx("div",{className:"empty-icon",children:e.jsx(is,{size:40})}),"开始和 ",(r==null?void 0:r.name)??"Aalis"," 对话吧"]}),t.map((j,R)=>{const B=R===t.length-1;return e.jsx(_n,{msg:j,senderName:(r==null?void 0:r.name)??"Aalis",isLast:B,isGenerating:Le,onAbort:d,checkpoint:j.role==="assistant"?D(j.timestamp):void 0,rolledBack:j.role==="assistant"?(()=>{const W=D(j.timestamp);return W?Y.has(W.turnId):!1})():!1,onRollback:f,onRollbackWithChat:y,toolCallsProgress:B&&j.role==="assistant"&&Le?k:void 0},R)}),s&&(!ie||ie.role!=="assistant")&&e.jsxs("div",{className:"message-group assistant",children:[e.jsx("div",{className:"message-sender",children:(r==null?void 0:r.name)??"Aalis"}),e.jsx("div",{className:"message-bubble",children:k&&k.size>0?[...k.entries()].sort((j,R)=>j[0]-R[0]).map(([j,R])=>e.jsx(_s,{name:R.name,charsAccumulated:R.charsAccumulated,startedAt:R.startedAt},`pending-${j}`)):e.jsxs("div",{className:"typing-indicator",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"})]}),x&&!s&&e.jsxs("div",{className:"tool-limit-bar",children:[e.jsx("span",{className:"tool-limit-text",children:"⚠ 工具调用次数已达上限"}),e.jsxs("div",{className:"tool-limit-actions",children:[g&&e.jsx("button",{className:"tool-limit-btn continue",onClick:g,children:"继续迭代"}),e.jsx("span",{className:"tool-limit-hint",children:"或输入新内容引导模型"})]})]}),L==="start"&&e.jsxs("div",{className:"system-event-separator compressing",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(Qe,{size:12,className:"compress-spinner"})," 压缩对话中 ",e.jsx(us,{startTime:ve.current})]}),e.jsx("span",{className:"system-event-line"})]}),L==="done"&&e.jsxs("div",{className:"system-event-separator compress-done",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(ys,{size:12})," 已压缩对话 ",e.jsx(us,{startTime:ve.current,endTime:ye.current})]}),e.jsx("span",{className:"system-event-line"})]}),L==="error"&&e.jsxs("div",{className:"system-event-separator compress-error",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(De,{size:12})," 压缩失败"]}),e.jsx("span",{className:"system-event-line"})]}),e.jsx("div",{ref:S})]}),l&&l.length>0&&p&&e.jsx(Sn,{items:l,onClear:p,loading:s}),e.jsx(fn,{ref:C,loading:s,connected:n,canUpload:ke,canUploadImage:we,canUploadFile:Ne,acceptAttr:Pe,onSend:Ae,onAbort:d}),xe&&e.jsxs("div",{className:"image-lightbox",onClick:()=>ue(null),children:[e.jsx("img",{src:xe,alt:"预览",className:"image-lightbox-content",onClick:j=>j.stopPropagation()}),e.jsx("button",{type:"button",className:"image-lightbox-close",onClick:()=>ue(null),"aria-label":"关闭",children:"×"})]})]})}const In=a.lazy(()=>he(()=>import("./PluginConfigPage-BEBeoZAt.js"),__vite__mapDeps([2,1,3,4,5,6,7,8,9])).then(t=>({default:t.PluginConfigPage}))),Mn=a.lazy(()=>he(()=>import("./MarketplacePage-ClOWoNMz.js"),__vite__mapDeps([10,1,4,11,5,6,7,8,9])).then(t=>({default:t.MarketplacePage}))),Tn=a.lazy(()=>he(()=>import("./PlatformPage-BKcwv7lV.js"),__vite__mapDeps([12,1,13,5,6,7,8,9])).then(t=>({default:t.PlatformPage}))),En=a.lazy(()=>he(()=>import("./AuthorityPage-jj192bfx.js"),__vite__mapDeps([14,1,11,5,6,7,8,9])).then(t=>({default:t.AuthorityPage}))),Ln=a.lazy(()=>he(()=>import("./LogPage-C_Z3RA5T.js"),__vite__mapDeps([15,1])).then(t=>({default:t.LogPage}))),Rn=a.lazy(()=>he(()=>import("./SessionsPage-D0IEwawu.js"),__vite__mapDeps([16,1,9,7,8,5,6])).then(t=>({default:t.SessionsPage}))),Dn=a.lazy(()=>he(()=>import("./FilesPage-BMbRlFyJ.js"),__vite__mapDeps([17,1,5,6,7,8,9])).then(t=>({default:t.FilesPage}))),Pn=a.lazy(()=>he(()=>import("./DynamicPage-BCvX1Tg2.js"),__vite__mapDeps([18,1,3,19,20,13,11,9,7,8,5,6])).then(t=>({default:t.DynamicPage}))),ms=2e3;function An(){var ns;const[t,s]=a.useState(()=>location.hash.replace("#","")||"dashboard"),[n,r]=a.useState(null),[i,d]=a.useState([]);a.useEffect(()=>{location.hash=t},[t]),a.useEffect(()=>{n&&!n.has(t)&&s("dashboard")},[n,t]);const[u,h]=a.useState([]),[m,l]=a.useState(null),[p,x]=a.useState(null),[g,k]=a.useState(null),[c,L]=a.useState([]),[E,C]=a.useState(null),S=dt(i),{messages:G,setMessages:v,loading:q,setLoading:F,streamingRef:Y}=S,Z=a.useRef({pending:[],raf:0}),[b,D]=a.useState(0),[f,y]=a.useState([]),[V,J]=a.useState(()=>{if(typeof window>"u")return 420;const o=Number(window.localStorage.getItem("aalis:chatWidth"));return Number.isFinite(o)&&o>=280?o:420});a.useEffect(()=>{try{window.localStorage.setItem("aalis:chatWidth",String(V))}catch{}},[V]),a.useEffect(()=>{const o=document.querySelector(".app-layout");if(!o||typeof ResizeObserver>"u")return;const w=360,N=240,M=()=>{var se;const $=o.clientWidth,O=((se=document.querySelector(".nav-rail"))==null?void 0:se.getBoundingClientRect().width)??56,P=Math.max(N,$-O-w);J(K=>Math.min(Math.max(K,N),P))},I=new ResizeObserver(M);return I.observe(o),()=>I.disconnect()},[]);const[ae,_]=a.useState(!1),[T,A]=a.useState(new Map),[z,U]=a.useState(!1),[Q,xe]=a.useState(!1),[ue,ve]=a.useState(!1),[ye,re]=a.useState("正在重启…"),[we,Ne]=a.useState(!1),[ke,Pe]=a.useState(null),[Ae,be]=a.useState(null),Ce=(o,w)=>{const N=o?[...o]:[],M=N[N.length-1];return w.type==="text"&&M&&M.type==="text"?N[N.length-1]={type:"text",content:M.content+w.content}:w.type==="reasoning_text"&&M&&M.type==="reasoning_text"?N[N.length-1]={type:"reasoning_text",content:M.content+w.content}:N.push(w),N},Ee=o=>{let w="",N="";for(const M of o??[])M.type==="text"?w+=M.content:M.type==="reasoning_text"&&(N+=M.content);return{content:w,reasoning:N}},ze=a.useCallback((o,w,N,M,I)=>{Z.current.raf&&(cancelAnimationFrame(Z.current.raf),Z.current.raf=0),Z.current.pending=[],v($=>{const O=$[$.length-1],P=N&&N.length>0?N:w?[{type:"reasoning_text",content:w},{type:"text",content:o}]:[{type:"text",content:o}];return O&&O.role==="assistant"&&Y.current?(Y.current=!1,[...$.slice(0,-1),{...O,content:o,reasoningContent:w??O.reasoningContent,segments:P,attachments:M??O.attachments,modelInfo:I??O.modelInfo}]):(Y.current=!1,[...$,{role:"assistant",content:o,reasoningContent:w,segments:P,attachments:M,modelInfo:I,timestamp:Date.now()}])}),F(!1)},[]),ie=a.useCallback(()=>{const o=Z.current;if(o.raf&&(cancelAnimationFrame(o.raf),o.raf=0),o.pending.length===0)return;const w=o.pending;o.pending=[],v(N=>{const M=N[N.length-1];if(M&&M.role==="assistant"&&Y.current){let P=M.segments??[];for(const ne of w)P=Ce(P,{type:ne.kind==="content"?"text":"reasoning_text",content:ne.text});const{content:se,reasoning:K}=Ee(P);return[...N.slice(0,-1),{...M,content:se,reasoningContent:K||void 0,segments:P}]}Y.current=!0;let I=[];for(const P of w)I=Ce(I,{type:P.kind==="content"?"text":"reasoning_text",content:P.text});const{content:$,reasoning:O}=Ee(I);return[...N,{role:"assistant",content:$,reasoningContent:O||void 0,segments:I,timestamp:Date.now()}]})},[v,Y]),Le=a.useCallback((o,w,N,M)=>{if(N){ie(),F(!1),_(!!M),A(new Map);return}(o||w)&&A($=>$.size===0?$:new Map);const I=Z.current;w&&I.pending.push({kind:"reasoning",text:w}),o&&I.pending.push({kind:"content",text:o}),!I.raf&&(I.raf=requestAnimationFrame(ie))},[ie,F]),j=a.useCallback(o=>{h(w=>{if(w.length>0&&w[w.length-1].seq>=o.seq&&w.some(M=>M.seq===o.seq))return w;const N=[...w,o];return N.length>ms?N.slice(-ms):N})},[]),R=a.useCallback(async()=>{const o=u[0];if(!o)return 0;try{const w=await te(`/api/logs/range?before=${o.seq}&limit=200`);return!w||w.length===0?0:(h(N=>{const M=new Set(N.map($=>$.seq));return[...w.filter($=>!M.has($.seq)),...N]}),w.length)}catch{return 0}},[u]),B=a.useCallback((o,w,N,M)=>{ie(),N==="start"&&A(I=>I.size===0?I:new Map),v(I=>{const $=I[I.length-1];if(N==="start"){const O=Date.now();if($&&$.role==="assistant"){const P=Ce($.segments,{type:"tool_call",name:o,args:w,startTime:O});return[...I.slice(0,-1),{...$,segments:P}]}return Y.current=!0,[...I,{role:"assistant",content:"",segments:[{type:"tool_call",name:o,args:w,startTime:O}],timestamp:Date.now()}]}if($&&$.role==="assistant"&&$.segments){const O=Date.now(),P=[...$.segments];for(let se=P.length-1;se>=0;se--){const K=P[se];if(K.type==="tool_call"&&K.name===o&&K.result==null)return P[se]={...K,result:M,endTime:O},[...I.slice(0,-1),{...$,segments:P}]}}return I})},[ie]),W=a.useCallback(()=>{te("/api/plugins").then(o=>L(o.plugins??[])).catch(()=>{})},[]),me=a.useCallback(()=>{te("/api/config").then(k).catch(()=>{})},[]),ee=a.useCallback(()=>{te("/api/services").then(o=>C(o.services??null)).catch(()=>{})},[]),X=a.useCallback(()=>{te("/api/pages").then(o=>{d(o),r(new Set(o.map(w=>w.key)))}).catch(()=>{})},[]),le=a.useCallback(()=>{W(),ee(),X(),S.refresh(),te("/api/status").then(l).catch(()=>{})},[W,ee,X,S.refresh]),Oe=a.useCallback(()=>{U(!0),xe(!1),re("正在重启…")},[]),ge=a.useCallback(()=>{ve(!0),re("正在切换前端,即将刷新…")},[]),$s=a.useCallback(()=>{S.refresh(),D(o=>o+1)},[S.refresh]),Is=a.useCallback(o=>{y(o)},[]),Ms=a.useCallback((o,w,N,M,I)=>{v($=>{let O=N&&N.length>0?N:[];O.length===0&&(w&&O.push({type:"reasoning_text",content:w}),o&&O.push({type:"text",content:o}));const P=$[$.length-1];return P&&P.role==="assistant"?[...$.slice(0,-1),{...P,content:o,reasoningContent:w||P.reasoningContent,segments:O}]:[...$,{role:"assistant",content:o,reasoningContent:w||void 0,segments:O,timestamp:Date.now()}]}),M||(Y.current=!0,F(!0)),I&&I.length>0?A(new Map(I.map($=>[$.index,{name:$.name,charsAccumulated:$.charsAccumulated,startedAt:$.startedAt}]))):A($=>$.size===0?$:new Map)},[]),Ts=a.useCallback(o=>{A(w=>{const N=new Map(w),M=N.get(o.index);return N.set(o.index,{name:o.name,charsAccumulated:o.charsAccumulated,startedAt:(M==null?void 0:M.startedAt)??Date.now()}),N})},[]),Es=a.useCallback(()=>{A(o=>o.size===0?o:new Map)},[]),Ls=a.useCallback(o=>{Ne(!0),v(w=>[...w,{role:"assistant",content:o,segments:[{type:"text",content:o}],timestamp:Date.now()}])},[]),Rs=a.useCallback(o=>{Pe(o)},[]),Ds=a.useCallback((o,w)=>{o===oe()&&(be(w),w==="done"?(v(N=>[...N,{role:"system",content:"对话已压缩",timestamp:Date.now()}]),setTimeout(()=>be(null),1500)):w==="error"&&setTimeout(()=>be(null),3e3))},[]),{send:Se,sendRaw:Re,connected:fe}=ot({onMessage:ze,onStream:Le,onLog:j,onToolCall:B,onStateChanged:le,onRestarting:Oe,onReload:ge,onSessionsChanged:$s,onTodoUpdated:Is,onStreamResume:Ms,onConfirm:Ls,onTokenUsage:Rs,onCompressing:Ds,onHistoryChanged:S.handleHistoryChanged,onToolCallProgress:Ts,onToolCallProgressClear:Es}),Ps=a.useCallback(()=>{Re({type:"compress",sessionId:oe()})},[Re]);a.useEffect(()=>{z&&!fe&&(xe(!0),re("等待服务器重启…"))},[z,fe]),a.useEffect(()=>{if(z&&Q&&fe){re("服务器已就绪,即将刷新…");const o=setTimeout(()=>window.location.reload(),800);return()=>clearTimeout(o)}},[z,Q,fe]),a.useEffect(()=>{if(ue){const o=setTimeout(()=>window.location.reload(),1500);return()=>clearTimeout(o)}},[ue]),a.useEffect(()=>{te("/api/status").then(l).catch(()=>{}),te("/api/auth/status").then(o=>x(o.authed&&o.identity?{identity:o.identity,isOwner:!0}:null)).catch(()=>{}),me(),W(),ee(),X(),S.refresh(),te("/api/logs/tail?limit=200").then(h).catch(()=>{})},[W,me,ee,X,S.refresh]),a.useEffect(()=>{const o=S.activeSessionId;if(!o||o==="__new_chat__"){y([]);return}de("@aalis/plugin-todo-list","getTodos",{sessionId:o}).then(w=>y(w??[])).catch(()=>y([]))},[S.activeSessionId]),a.useEffect(()=>{const o=setInterval(()=>{te("/api/status").then(l).catch(()=>{}),W(),ee(),X(),S.refresh()},3e4);return()=>clearInterval(o)},[W,ee,X,S.refresh]);const Fe=a.useCallback(()=>{Re({type:"abort",sessionId:oe()}),F(!1),_(!1),Y.current=!1},[Re]),As=a.useCallback(()=>{v(o=>[...o,{role:"user",content:"[请继续执行未完成的工具调用]",timestamp:Date.now()}]),Se("[请继续执行未完成的工具调用]"),_(!1),F(!0)},[Se]),zs=a.useCallback(()=>{const o=S.activeSessionId;!o||o==="__new_chat__"||(de("@aalis/plugin-todo-list","clearTodos",{sessionId:o}).catch(()=>{}),y([]))},[S.activeSessionId]),Os=a.useCallback(async(o,w,N,M)=>{const I=o.trim();if(we){if(!I)return;Ne(!1),v(K=>[...K,{role:"user",content:I,timestamp:Date.now()}]),Se(I);return}if(q&&Fe(),!I&&N.length===0&&w.length===0)return;await S.ensureSession();const $=N.length>0?[...N]:void 0,O=[];let P=0,se=0;if(M.length>0){for(const K of M)if(K==="image"&&P<N.length)O.push({kind:"image",data:N[P++]});else if(K==="file"&&se<w.length){const ne=w[se++],pe=ne.mimeType??"",Be=pe.startsWith("audio/")?"audio":pe.startsWith("video/")?"video":"file";O.push({kind:Be,data:ne.data,mimeType:pe,name:ne.name})}}for(;P<N.length;)O.push({kind:"image",data:N[P++]});for(;se<w.length;){const K=w[se++],ne=K.mimeType??"",pe=ne.startsWith("audio/")?"audio":ne.startsWith("video/")?"video":"file";O.push({kind:pe,data:K.data,mimeType:ne,name:K.name})}v(K=>[...K,{role:"user",content:I,images:$,fileNames:w.map(ne=>ne.name),timestamp:Date.now()}]),_(!1),F(!0),Se(I,O.length>0?O:void 0)},[we,q,Se,Fe,S]),We={dashboard:e.jsx(Qs,{}),marketplace:e.jsx(et,{}),"plugin-config":e.jsx(st,{}),platforms:e.jsx(nt,{}),authority:e.jsx(at,{}),files:e.jsx(rt,{}),logs:e.jsx(tt,{})},Fs=e.jsxs("svg",{width:"20",height:"20",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:"2"}),e.jsx("path",{d:"M9 3v18M3 9h18"})]}),Ws=(o,w)=>We[o]?We[o]:w&&w.trimStart().startsWith("<svg")?e.jsx("span",{className:"nav-item-svg",dangerouslySetInnerHTML:{__html:w}}):Fs,ts=a.useMemo(()=>n?i.filter(o=>n.has(o.key)).map(o=>({key:o.key,label:o.label,pluginDisplayName:o.pluginDisplayName,icon:Ws(o.key,o.icon),order:o.order??99})).sort((o,w)=>o.order-w.order):Object.entries(We).map(([o,w],N)=>({key:o,label:o,icon:w,order:(N+1)*10})),[n,i]),qs=(o,w)=>{switch(o){case"dashboard":return e.jsx(Qt,{status:m,connected:fe,plugins:c,servicesData:E,onRefreshServices:ee});case"marketplace":return e.jsx(Mn,{plugins:c,onRefresh:W});case"plugin-config":return e.jsx(In,{plugins:c,config:g,onRefresh:W,onConfigSaved:me,onRestart:()=>{U(!0),xe(!1),re("正在重启…")}});case"platforms":return e.jsx(Tn,{});case"authority":return e.jsx(En,{});case"logs":return e.jsx(Ln,{logs:u,onLoadOlder:R});case"files":return e.jsx(Dn,{});case"sessions":return e.jsx(Rn,{pluginName:w,activeSessionId:S.activeSessionId,onSwitchSession:N=>{S.switchSession(N)},onStartNewChat:()=>S.startNewChat(),refreshSignal:b});default:return null}},ce=i.find(o=>o.key===t),qe=ce!=null&&ce.content?ce:void 0;return e.jsxs("div",{className:"app-layout",children:[e.jsxs("nav",{className:"nav-rail",children:[e.jsxs("div",{className:"nav-rail-top",children:[e.jsx("div",{className:"nav-logo",children:"A"}),ts.map(o=>e.jsxs("button",{className:`nav-item ${t===o.key?"active":""}`,onClick:()=>s(o.key),children:[e.jsx("span",{className:"nav-item-icon",children:o.icon}),e.jsx("span",{className:"nav-item-label",children:o.label})]},o.key))]}),e.jsx("div",{className:"nav-rail-bottom",children:e.jsx("div",{className:`nav-status ${fe?"online":"offline"}`,title:fe?"已连接":"离线"})})]}),e.jsxs("main",{className:"content-area",children:[e.jsxs("div",{className:"content-header",children:[e.jsx("span",{className:"content-title",children:(ns=ts.find(o=>o.key===t))==null?void 0:ns.label}),p&&e.jsxs("span",{className:"content-user",title:`${p.identity.platform}:${p.identity.userId}`,children:[e.jsxs("span",{style:{fontSize:12,opacity:.7},children:[p.identity.platform,":",p.identity.userId]}),p.isOwner&&e.jsx("span",{className:"content-user-level",children:"owner"}),e.jsx("button",{className:"btn-sm",onClick:async()=>{await fetch("/api/auth/logout",{method:"POST"}),window.location.reload()},children:"退出"})]})]}),e.jsx("div",{className:"content-body",children:e.jsxs(a.Suspense,{fallback:e.jsx("div",{className:"empty-hint",style:{padding:24},children:"加载中…"}),children:[qe&&e.jsx(Pn,{page:qe}),!qe&&(ce==null?void 0:ce.renderer)&&(qs(ce.renderer,ce.plugin)||e.jsxs("div",{className:"empty-hint",style:{padding:24},children:["此客户端不支持渲染器「",ce.renderer,"」"]}))]})})]}),e.jsx("div",{className:"resize-handle",onMouseDown:o=>{var pe;o.preventDefault();const w=o.clientX,N=V,M=((pe=document.querySelector(".app-layout"))==null?void 0:pe.clientWidth)??window.innerWidth,I=document.querySelector(".nav-rail"),$=(I==null?void 0:I.getBoundingClientRect().width)??56,O=360,P=280,se=Math.max(P,M-$-O);document.body.classList.add("is-dragging-chat");const K=Be=>{const Bs=N-(Be.clientX-w);J(Math.max(P,Math.min(se,Bs)))},ne=()=>{document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",ne),document.body.style.cursor="",document.body.style.userSelect="",document.body.classList.remove("is-dragging-chat")};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",K),document.addEventListener("mouseup",ne)}}),e.jsx("div",{className:"chat-column",style:{width:V},children:e.jsx($n,{messages:G,loading:q,connected:fe,status:m,onSend:Os,onAbort:Fe,width:V,sessionTitle:S.isNewChat?"新对话":S.activeSessionTitle,onNewSession:S.pluginName?()=>S.startNewChat():void 0,todoItems:f,onClearTodos:zs,toolLimitReached:ae,onContinueTools:As,toolCallsProgress:T,tokenUsage:ke,compressingStatus:Ae,onCompress:Ps})}),(z||ue)&&e.jsx("div",{className:"restart-overlay",children:e.jsxs("div",{className:"restart-dialog",children:[e.jsx("div",{className:"restart-spinner"}),e.jsx("h3",{children:ue?"切换前端":"正在重启…"}),e.jsx("p",{className:"restart-desc",children:ye})]})})]})}Hs.createRoot(document.getElementById("root")).render(e.jsx(An,{}));export{os as B,vs as C,It as D,Rt as F,Te as M,Me as R,Ht as S,De as T,ss as W,Ns as X,he as _,te as a,ct as b,H as c,Ie as d,$e as e,qt as f,Et as g,Kt as h,de as p};
207
+ `)),Z(ge=>new Set([...ge,j.turnId]))}catch(X){window.alert(`回滚失败:${X.message}`)}},[]),V=a.useRef(null),J=a.useRef(!1),[ae,_]=a.useState(!1),T=a.useRef(0),[A,z]=a.useState(!1),[K,Q]=a.useState(!1),[xe,ue]=a.useState(null),ve=a.useRef(0),ye=a.useRef(0);a.useEffect(()=>{const j=q=>{const W=q.detail;typeof W=="string"&&ue(W)},R=q=>{q.key==="Escape"&&ue(null)};return window.addEventListener(es,j),window.addEventListener("keydown",R),()=>{window.removeEventListener(es,j),window.removeEventListener("keydown",R)}},[]);const re=r==null?void 0:r.uploadCapabilities,we=(re==null?void 0:re.image)??!1,Ne=(re==null?void 0:re.file)??!1,ke=we||Ne,Pe=Cn(re);a.useEffect(()=>{L==="start"?(ve.current=Date.now(),ye.current=0):(L==="done"||L==="error")&&(ye.current=Date.now())},[L]),a.useEffect(()=>{const j=G.current;if(!j)return;const R=()=>{const{scrollTop:q,scrollHeight:W,clientHeight:me}=j;v.current=W-q-me>200,J.current=!0,V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{J.current=!1},300)};return j.addEventListener("scroll",R,{passive:!0}),()=>j.removeEventListener("scroll",R)},[]),a.useEffect(()=>{const j=G.current;if(!j)return;const R=new ResizeObserver(()=>{var q;!v.current&&!J.current&&((q=S.current)==null||q.scrollIntoView({behavior:s?"instant":"smooth"}))});return R.observe(j),()=>R.disconnect()},[t.length]),a.useEffect(()=>{var j;!v.current&&!J.current&&((j=S.current)==null||j.scrollIntoView({behavior:"smooth"}))},[t]);const Ae=a.useCallback((j,R,q,W)=>i(j,R,q,W),[i]),be=j=>{j.preventDefault(),j.stopPropagation(),T.current++,ke&&j.dataTransfer.types.includes("Files")&&_(!0)},Ce=j=>{j.preventDefault(),j.stopPropagation(),T.current--,T.current<=0&&(T.current=0,_(!1))},Ee=j=>{j.preventDefault(),j.stopPropagation()},ze=async j=>{var R;j.preventDefault(),j.stopPropagation(),T.current=0,_(!1),!(!ke||!j.dataTransfer.files.length)&&await((R=C.current)==null?void 0:R.addFiles(j.dataTransfer.files))},ie=t[t.length-1],Le=(ie==null?void 0:ie.role)==="assistant"&&s;return e.jsxs("div",{className:`chat-panel${ae?" drag-over":""}`,style:{width:u},onDragEnter:be,onDragLeave:Ce,onDragOver:Ee,onDrop:ze,children:[ae&&e.jsx("div",{className:"drag-overlay",children:e.jsxs("div",{className:"drag-overlay-content",children:[e.jsx(ws,{size:16})," 松开以上传文件"]})}),e.jsxs("div",{className:"chat-panel-header",children:[e.jsxs("span",{className:"chat-panel-title",children:[e.jsx(is,{size:16})," ",h||(r==null?void 0:r.name)||"Aalis"]}),e.jsxs("div",{className:"chat-panel-header-actions",children:[e.jsxs("div",{className:"token-usage-badge",onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),children:[e.jsx(ks,{size:12}),e.jsx("span",{className:`token-usage-number${c&&c.usageRatio>.85?" warn":c&&c.usageRatio>.7?" caution":""}`,children:c?c.used.toLocaleString():"--"}),A&&e.jsxs("div",{className:"token-usage-panel",children:[e.jsx("div",{className:"token-panel-title",children:"Token 使用情况"}),c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"token-panel-bar",children:e.jsx("div",{className:`token-panel-bar-fill${c.usageRatio>.85?" warn":c.usageRatio>.7?" caution":""}`,style:{width:`${Math.min(100,c.usageRatio*100)}%`}})}),e.jsxs("div",{className:"token-panel-ratio",children:[(c.usageRatio*100).toFixed(1),"% 已使用"]}),e.jsxs("div",{className:"token-panel-rows",children:[e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"上下文窗口"}),e.jsx("span",{children:c.contextWindow.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-section-header",children:["系统提示词 ",e.jsx("span",{className:"token-panel-section-total",children:c.breakdown.system.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"人设 / Persona"}),e.jsx("span",{children:c.breakdown.persona.toLocaleString()})]}),c.breakdown.memorySummary>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"对话摘要"}),e.jsx("span",{children:c.breakdown.memorySummary.toLocaleString()})]}),c.breakdown.memoryVector>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"向量记忆"}),e.jsx("span",{children:c.breakdown.memoryVector.toLocaleString()})]}),c.breakdown.skills>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"技能描述"}),e.jsx("span",{children:c.breakdown.skills.toLocaleString()})]}),c.breakdown.platform>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"平台提示"}),e.jsx("span",{children:c.breakdown.platform.toLocaleString()})]}),c.breakdown.subtask>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"子任务上下文"}),e.jsx("span",{children:c.breakdown.subtask.toLocaleString()})]}),c.breakdown.systemOther>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"其他系统提示"}),e.jsx("span",{children:c.breakdown.systemOther.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"历史消息"}),e.jsx("span",{children:c.breakdown.history.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具结果"}),e.jsx("span",{children:c.breakdown.toolResults.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具定义"}),e.jsx("span",{children:c.breakdown.toolDefs.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"回复保留量"}),e.jsx("span",{children:c.breakdown.reservedForReply.toLocaleString()})]})]}),E&&e.jsx("button",{className:"token-panel-compress-btn",onClick:j=>{j.stopPropagation(),E()},disabled:L==="start",children:L==="start"?e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:12,className:"compress-spinner"})," 压缩中…"]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{size:12})," 压缩对话"]})})]}):e.jsx("div",{className:"token-panel-empty",children:"发送消息后将显示 Token 用量统计"})]})]}),m&&e.jsx("button",{className:"chat-panel-new-btn",onClick:m,title:"新对话",children:"+"}),e.jsx("button",{className:"chat-panel-new-btn",onClick:()=>Q(j=>!j),title:"已上传的文件","aria-label":"已上传的文件",children:e.jsx(Dt,{size:14})})]})]}),e.jsx(fn,{open:K,onClose:()=>Q(!1),sessionId:oe()}),e.jsxs("div",{className:"messages",ref:G,children:[t.length===0&&e.jsxs("div",{className:"empty",children:[e.jsx("div",{className:"empty-icon",children:e.jsx(is,{size:40})}),"开始和 ",(r==null?void 0:r.name)??"Aalis"," 对话吧"]}),t.map((j,R)=>{const q=R===t.length-1;return e.jsx($n,{msg:j,senderName:(r==null?void 0:r.name)??"Aalis",isLast:q,isGenerating:Le,onAbort:d,checkpoint:j.role==="assistant"?D(j.timestamp):void 0,rolledBack:j.role==="assistant"?(()=>{const W=D(j.timestamp);return W?Y.has(W.turnId):!1})():!1,onRollback:f,onRollbackWithChat:y,toolCallsProgress:q&&j.role==="assistant"&&Le?k:void 0},R)}),s&&(!ie||ie.role!=="assistant")&&e.jsxs("div",{className:"message-group assistant",children:[e.jsx("div",{className:"message-sender",children:(r==null?void 0:r.name)??"Aalis"}),e.jsx("div",{className:"message-bubble",children:k&&k.size>0?[...k.entries()].sort((j,R)=>j[0]-R[0]).map(([j,R])=>e.jsx(_s,{name:R.name,charsAccumulated:R.charsAccumulated,startedAt:R.startedAt},`pending-${j}`)):e.jsxs("div",{className:"typing-indicator",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"})]}),x&&!s&&e.jsxs("div",{className:"tool-limit-bar",children:[e.jsx("span",{className:"tool-limit-text",children:"⚠ 工具调用次数已达上限"}),e.jsxs("div",{className:"tool-limit-actions",children:[g&&e.jsx("button",{className:"tool-limit-btn continue",onClick:g,children:"继续迭代"}),e.jsx("span",{className:"tool-limit-hint",children:"或输入新内容引导模型"})]})]}),L==="start"&&e.jsxs("div",{className:"system-event-separator compressing",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(Qe,{size:12,className:"compress-spinner"})," 压缩对话中 ",e.jsx(us,{startTime:ve.current})]}),e.jsx("span",{className:"system-event-line"})]}),L==="done"&&e.jsxs("div",{className:"system-event-separator compress-done",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(ys,{size:12})," 已压缩对话 ",e.jsx(us,{startTime:ve.current,endTime:ye.current})]}),e.jsx("span",{className:"system-event-line"})]}),L==="error"&&e.jsxs("div",{className:"system-event-separator compress-error",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(De,{size:12})," 压缩失败"]}),e.jsx("span",{className:"system-event-line"})]}),e.jsx("div",{ref:S})]}),l&&l.length>0&&p&&e.jsx(_n,{items:l,onClear:p,loading:s}),e.jsx(pn,{ref:C,loading:s,connected:n,canUpload:ke,canUploadImage:we,canUploadFile:Ne,acceptAttr:Pe,onSend:Ae,onAbort:d}),xe&&e.jsxs("div",{className:"image-lightbox",onClick:()=>ue(null),children:[e.jsx("img",{src:xe,alt:"预览",className:"image-lightbox-content",onClick:j=>j.stopPropagation()}),e.jsx("button",{type:"button",className:"image-lightbox-close",onClick:()=>ue(null),"aria-label":"关闭",children:"×"})]})]})}const Mn=a.lazy(()=>he(()=>import("./PluginConfigPage-Ci_WRMHk.js"),__vite__mapDeps([2,1,3,4,5,6,7,8,9])).then(t=>({default:t.PluginConfigPage}))),Tn=a.lazy(()=>he(()=>import("./MarketplacePage-DKs-PwSt.js"),__vite__mapDeps([10,1,4,11,5,6,7,8,9])).then(t=>({default:t.MarketplacePage}))),En=a.lazy(()=>he(()=>import("./PlatformPage-U3Xx3yvM.js"),__vite__mapDeps([12,1,13,5,6,7,8,9])).then(t=>({default:t.PlatformPage}))),Ln=a.lazy(()=>he(()=>import("./AuthorityPage-GbF3xg8H.js"),__vite__mapDeps([14,1,11,5,6,7,8,9])).then(t=>({default:t.AuthorityPage}))),Rn=a.lazy(()=>he(()=>import("./LogPage-C_Z3RA5T.js"),__vite__mapDeps([15,1])).then(t=>({default:t.LogPage}))),Dn=a.lazy(()=>he(()=>import("./SessionsPage-AmYhJ75Q.js"),__vite__mapDeps([16,1,9,7,8,5,6])).then(t=>({default:t.SessionsPage}))),Pn=a.lazy(()=>he(()=>import("./FilesPage-B5C5zWo5.js"),__vite__mapDeps([17,1,5,6,7,8,9])).then(t=>({default:t.FilesPage}))),An=a.lazy(()=>he(()=>import("./DynamicPage-GeSfxddk.js"),__vite__mapDeps([18,1,3,19,20,13,11,9,7,8,5,6])).then(t=>({default:t.DynamicPage}))),ms=2e3;function zn(){var ns;const[t,s]=a.useState(()=>location.hash.replace("#","")||"dashboard"),[n,r]=a.useState(null),[i,d]=a.useState([]);a.useEffect(()=>{location.hash=t},[t]),a.useEffect(()=>{n&&!n.has(t)&&s("dashboard")},[n,t]);const[u,h]=a.useState([]),[m,l]=a.useState(null),[p,x]=a.useState(null),[g,k]=a.useState(null),[c,L]=a.useState([]),[E,C]=a.useState(null),S=ut(i),{messages:G,setMessages:v,loading:B,setLoading:F,streamingRef:Y}=S,Z=a.useRef({pending:[],raf:0}),[b,D]=a.useState(0),[f,y]=a.useState([]),[V,J]=a.useState(()=>{if(typeof window>"u")return 420;const o=Number(window.localStorage.getItem("aalis:chatWidth"));return Number.isFinite(o)&&o>=280?o:420});a.useEffect(()=>{try{window.localStorage.setItem("aalis:chatWidth",String(V))}catch{}},[V]),a.useEffect(()=>{const o=document.querySelector(".app-layout");if(!o||typeof ResizeObserver>"u")return;const w=360,N=240,M=()=>{var se;const $=o.clientWidth,O=((se=document.querySelector(".nav-rail"))==null?void 0:se.getBoundingClientRect().width)??56,P=Math.max(N,$-O-w);J(U=>Math.min(Math.max(U,N),P))},I=new ResizeObserver(M);return I.observe(o),()=>I.disconnect()},[]);const[ae,_]=a.useState(!1),[T,A]=a.useState(new Map),[z,K]=a.useState(!1),[Q,xe]=a.useState(!1),[ue,ve]=a.useState(!1),[ye,re]=a.useState("正在重启…"),[we,Ne]=a.useState(!1),[ke,Pe]=a.useState(null),[Ae,be]=a.useState(null),Ce=(o,w)=>{const N=o?[...o]:[],M=N[N.length-1];return w.type==="text"&&M&&M.type==="text"?N[N.length-1]={type:"text",content:M.content+w.content}:w.type==="reasoning_text"&&M&&M.type==="reasoning_text"?N[N.length-1]={type:"reasoning_text",content:M.content+w.content}:N.push(w),N},Ee=o=>{let w="",N="";for(const M of o??[])M.type==="text"?w+=M.content:M.type==="reasoning_text"&&(N+=M.content);return{content:w,reasoning:N}},ze=a.useCallback((o,w,N,M,I)=>{Z.current.raf&&(cancelAnimationFrame(Z.current.raf),Z.current.raf=0),Z.current.pending=[],v($=>{const O=$[$.length-1],P=N&&N.length>0?N:w?[{type:"reasoning_text",content:w},{type:"text",content:o}]:[{type:"text",content:o}];return O&&O.role==="assistant"&&Y.current?(Y.current=!1,[...$.slice(0,-1),{...O,content:o,reasoningContent:w??O.reasoningContent,segments:P,attachments:M??O.attachments,modelInfo:I??O.modelInfo}]):(Y.current=!1,[...$,{role:"assistant",content:o,reasoningContent:w,segments:P,attachments:M,modelInfo:I,timestamp:Date.now()}])}),F(!1)},[]),ie=a.useCallback(()=>{const o=Z.current;if(o.raf&&(cancelAnimationFrame(o.raf),o.raf=0),o.pending.length===0)return;const w=o.pending;o.pending=[],v(N=>{const M=N[N.length-1];if(M&&M.role==="assistant"&&Y.current){let P=M.segments??[];for(const ne of w)P=Ce(P,{type:ne.kind==="content"?"text":"reasoning_text",content:ne.text});const{content:se,reasoning:U}=Ee(P);return[...N.slice(0,-1),{...M,content:se,reasoningContent:U||void 0,segments:P}]}Y.current=!0;let I=[];for(const P of w)I=Ce(I,{type:P.kind==="content"?"text":"reasoning_text",content:P.text});const{content:$,reasoning:O}=Ee(I);return[...N,{role:"assistant",content:$,reasoningContent:O||void 0,segments:I,timestamp:Date.now()}]})},[v,Y]),Le=a.useCallback((o,w,N,M)=>{if(N){ie(),F(!1),_(!!M),A(new Map);return}(o||w)&&A($=>$.size===0?$:new Map);const I=Z.current;w&&I.pending.push({kind:"reasoning",text:w}),o&&I.pending.push({kind:"content",text:o}),!I.raf&&(I.raf=requestAnimationFrame(ie))},[ie,F]),j=a.useCallback(o=>{h(w=>{if(w.length>0&&w[w.length-1].seq>=o.seq&&w.some(M=>M.seq===o.seq))return w;const N=[...w,o];return N.length>ms?N.slice(-ms):N})},[]),R=a.useCallback(async()=>{const o=u[0];if(!o)return 0;try{const w=await te(`/api/logs/range?before=${o.seq}&limit=200`);return!w||w.length===0?0:(h(N=>{const M=new Set(N.map($=>$.seq));return[...w.filter($=>!M.has($.seq)),...N]}),w.length)}catch{return 0}},[u]),q=a.useCallback((o,w,N,M)=>{ie(),N==="start"&&A(I=>I.size===0?I:new Map),v(I=>{const $=I[I.length-1];if(N==="start"){const O=Date.now();if($&&$.role==="assistant"){const P=Ce($.segments,{type:"tool_call",name:o,args:w,startTime:O});return[...I.slice(0,-1),{...$,segments:P}]}return Y.current=!0,[...I,{role:"assistant",content:"",segments:[{type:"tool_call",name:o,args:w,startTime:O}],timestamp:Date.now()}]}if($&&$.role==="assistant"&&$.segments){const O=Date.now(),P=[...$.segments];for(let se=P.length-1;se>=0;se--){const U=P[se];if(U.type==="tool_call"&&U.name===o&&U.result==null)return P[se]={...U,result:M,endTime:O},[...I.slice(0,-1),{...$,segments:P}]}}return I})},[ie]),W=a.useCallback(()=>{te("/api/plugins").then(o=>L(o.plugins??[])).catch(()=>{})},[]),me=a.useCallback(()=>{te("/api/config").then(k).catch(()=>{})},[]),ee=a.useCallback(()=>{te("/api/services").then(o=>C(o.services??null)).catch(()=>{})},[]),X=a.useCallback(()=>{te("/api/pages").then(o=>{d(o),r(new Set(o.map(w=>w.key)))}).catch(()=>{})},[]),le=a.useCallback(()=>{W(),ee(),X(),S.refresh(),te("/api/status").then(l).catch(()=>{})},[W,ee,X,S.refresh]),Oe=a.useCallback(()=>{K(!0),xe(!1),re("正在重启…")},[]),ge=a.useCallback(()=>{ve(!0),re("正在切换前端,即将刷新…")},[]),$s=a.useCallback(()=>{S.refresh(),D(o=>o+1)},[S.refresh]),Is=a.useCallback(o=>{y(o)},[]),Ms=a.useCallback((o,w,N,M,I)=>{v($=>{let O=N&&N.length>0?N:[];O.length===0&&(w&&O.push({type:"reasoning_text",content:w}),o&&O.push({type:"text",content:o}));const P=$[$.length-1];return P&&P.role==="assistant"?[...$.slice(0,-1),{...P,content:o,reasoningContent:w||P.reasoningContent,segments:O}]:[...$,{role:"assistant",content:o,reasoningContent:w||void 0,segments:O,timestamp:Date.now()}]}),M||(Y.current=!0,F(!0)),I&&I.length>0?A(new Map(I.map($=>[$.index,{name:$.name,charsAccumulated:$.charsAccumulated,startedAt:$.startedAt}]))):A($=>$.size===0?$:new Map)},[]),Ts=a.useCallback(o=>{A(w=>{const N=new Map(w),M=N.get(o.index);return N.set(o.index,{name:o.name,charsAccumulated:o.charsAccumulated,startedAt:(M==null?void 0:M.startedAt)??Date.now()}),N})},[]),Es=a.useCallback(()=>{A(o=>o.size===0?o:new Map)},[]),Ls=a.useCallback(o=>{Ne(!0),v(w=>[...w,{role:"assistant",content:o,segments:[{type:"text",content:o}],timestamp:Date.now()}])},[]),Rs=a.useCallback(o=>{Pe(o)},[]),Ds=a.useCallback((o,w)=>{o===oe()&&(be(w),w==="done"?(v(N=>[...N,{role:"system",content:"对话已压缩",timestamp:Date.now()}]),setTimeout(()=>be(null),1500)):w==="error"&&setTimeout(()=>be(null),3e3))},[]),{send:Se,sendRaw:Re,connected:fe}=it({onMessage:ze,onStream:Le,onLog:j,onToolCall:q,onStateChanged:le,onRestarting:Oe,onReload:ge,onSessionsChanged:$s,onTodoUpdated:Is,onStreamResume:Ms,onConfirm:Ls,onTokenUsage:Rs,onCompressing:Ds,onHistoryChanged:S.handleHistoryChanged,onToolCallProgress:Ts,onToolCallProgressClear:Es}),Ps=a.useCallback(()=>{Re({type:"compress",sessionId:oe()})},[Re]);a.useEffect(()=>{z&&!fe&&(xe(!0),re("等待服务器重启…"))},[z,fe]),a.useEffect(()=>{if(z&&Q&&fe){re("服务器已就绪,即将刷新…");const o=setTimeout(()=>window.location.reload(),800);return()=>clearTimeout(o)}},[z,Q,fe]),a.useEffect(()=>{if(ue){const o=setTimeout(()=>window.location.reload(),1500);return()=>clearTimeout(o)}},[ue]),a.useEffect(()=>{te("/api/status").then(l).catch(()=>{}),te("/api/auth/status").then(o=>x(o.authed&&o.identity?{identity:o.identity,isOwner:!0}:null)).catch(()=>{}),me(),W(),ee(),X(),S.refresh(),te("/api/logs/tail?limit=200").then(h).catch(()=>{})},[W,me,ee,X,S.refresh]),a.useEffect(()=>{const o=S.activeSessionId;if(!o||o==="__new_chat__"){y([]);return}de("@aalis/plugin-todo-list","getTodos",{sessionId:o}).then(w=>y(w??[])).catch(()=>y([]))},[S.activeSessionId]),a.useEffect(()=>{const o=setInterval(()=>{te("/api/status").then(l).catch(()=>{}),W(),ee(),X(),S.refresh()},3e4);return()=>clearInterval(o)},[W,ee,X,S.refresh]);const Fe=a.useCallback(()=>{Re({type:"abort",sessionId:oe()}),F(!1),_(!1),Y.current=!1},[Re]),As=a.useCallback(()=>{v(o=>[...o,{role:"user",content:"[请继续执行未完成的工具调用]",timestamp:Date.now()}]),Se("[请继续执行未完成的工具调用]"),_(!1),F(!0)},[Se]),zs=a.useCallback(()=>{const o=S.activeSessionId;!o||o==="__new_chat__"||(de("@aalis/plugin-todo-list","clearTodos",{sessionId:o}).catch(()=>{}),y([]))},[S.activeSessionId]),Os=a.useCallback(async(o,w,N,M)=>{const I=o.trim();if(we){if(!I)return;Ne(!1),v(U=>[...U,{role:"user",content:I,timestamp:Date.now()}]),Se(I);return}if(B&&Fe(),!I&&N.length===0&&w.length===0)return;await S.ensureSession();const $=N.length>0?[...N]:void 0,O=[];let P=0,se=0;if(M.length>0){for(const U of M)if(U==="image"&&P<N.length)O.push({kind:"image",data:N[P++]});else if(U==="file"&&se<w.length){const ne=w[se++],pe=ne.mimeType??"",qe=pe.startsWith("audio/")?"audio":pe.startsWith("video/")?"video":"file";O.push({kind:qe,data:ne.data,mimeType:pe,name:ne.name})}}for(;P<N.length;)O.push({kind:"image",data:N[P++]});for(;se<w.length;){const U=w[se++],ne=U.mimeType??"",pe=ne.startsWith("audio/")?"audio":ne.startsWith("video/")?"video":"file";O.push({kind:pe,data:U.data,mimeType:ne,name:U.name})}v(U=>[...U,{role:"user",content:I,images:$,fileNames:w.map(ne=>ne.name),timestamp:Date.now()}]),_(!1),F(!0),Se(I,O.length>0?O:void 0)},[we,B,Se,Fe,S]),We={dashboard:e.jsx(et,{}),marketplace:e.jsx(st,{}),"plugin-config":e.jsx(tt,{}),platforms:e.jsx(at,{}),authority:e.jsx(rt,{}),files:e.jsx(ot,{}),logs:e.jsx(nt,{})},Fs=e.jsxs("svg",{width:"20",height:"20",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:"2"}),e.jsx("path",{d:"M9 3v18M3 9h18"})]}),Ws=(o,w)=>We[o]?We[o]:w&&w.trimStart().startsWith("<svg")?e.jsx("span",{className:"nav-item-svg",dangerouslySetInnerHTML:{__html:w}}):Fs,ts=a.useMemo(()=>n?i.filter(o=>n.has(o.key)).map(o=>({key:o.key,label:o.label,pluginDisplayName:o.pluginDisplayName,icon:Ws(o.key,o.icon),order:o.order??99})).sort((o,w)=>o.order-w.order):Object.entries(We).map(([o,w],N)=>({key:o,label:o,icon:w,order:(N+1)*10})),[n,i]),Bs=(o,w)=>{switch(o){case"dashboard":return e.jsx(en,{status:m,connected:fe,plugins:c,servicesData:E,onRefreshServices:ee});case"marketplace":return e.jsx(Tn,{plugins:c,onRefresh:W,onRestart:N=>{K(!0),xe(!1),re(N)}});case"plugin-config":return e.jsx(Mn,{plugins:c,config:g,onRefresh:W,onConfigSaved:me,onRestart:()=>{K(!0),xe(!1),re("正在重启…")}});case"platforms":return e.jsx(En,{});case"authority":return e.jsx(Ln,{});case"logs":return e.jsx(Rn,{logs:u,onLoadOlder:R});case"files":return e.jsx(Pn,{});case"sessions":return e.jsx(Dn,{pluginName:w,activeSessionId:S.activeSessionId,onSwitchSession:N=>{S.switchSession(N)},onStartNewChat:()=>S.startNewChat(),refreshSignal:b});default:return null}},ce=i.find(o=>o.key===t),Be=ce!=null&&ce.content?ce:void 0;return e.jsxs("div",{className:"app-layout",children:[e.jsxs("nav",{className:"nav-rail",children:[e.jsxs("div",{className:"nav-rail-top",children:[e.jsx("div",{className:"nav-logo",children:"A"}),ts.map(o=>e.jsxs("button",{className:`nav-item ${t===o.key?"active":""}`,onClick:()=>s(o.key),children:[e.jsx("span",{className:"nav-item-icon",children:o.icon}),e.jsx("span",{className:"nav-item-label",children:o.label})]},o.key))]}),e.jsx("div",{className:"nav-rail-bottom",children:e.jsx("div",{className:`nav-status ${fe?"online":"offline"}`,title:fe?"已连接":"离线"})})]}),e.jsxs("main",{className:"content-area",children:[e.jsxs("div",{className:"content-header",children:[e.jsx("span",{className:"content-title",children:(ns=ts.find(o=>o.key===t))==null?void 0:ns.label}),p&&e.jsxs("span",{className:"content-user",title:`${p.identity.platform}:${p.identity.userId}`,children:[e.jsxs("span",{style:{fontSize:12,opacity:.7},children:[p.identity.platform,":",p.identity.userId]}),p.isOwner&&e.jsx("span",{className:"content-user-level",children:"owner"}),e.jsx("button",{className:"btn-sm",onClick:async()=>{await fetch("/api/auth/logout",{method:"POST"}),window.location.reload()},children:"退出"})]})]}),e.jsx("div",{className:"content-body",children:e.jsxs(a.Suspense,{fallback:e.jsx("div",{className:"empty-hint",style:{padding:24},children:"加载中…"}),children:[Be&&e.jsx(An,{page:Be}),!Be&&(ce==null?void 0:ce.renderer)&&(Bs(ce.renderer,ce.plugin)||e.jsxs("div",{className:"empty-hint",style:{padding:24},children:["此客户端不支持渲染器「",ce.renderer,"」"]}))]})})]}),e.jsx("div",{className:"resize-handle",onMouseDown:o=>{var pe;o.preventDefault();const w=o.clientX,N=V,M=((pe=document.querySelector(".app-layout"))==null?void 0:pe.clientWidth)??window.innerWidth,I=document.querySelector(".nav-rail"),$=(I==null?void 0:I.getBoundingClientRect().width)??56,O=360,P=280,se=Math.max(P,M-$-O);document.body.classList.add("is-dragging-chat");const U=qe=>{const qs=N-(qe.clientX-w);J(Math.max(P,Math.min(se,qs)))},ne=()=>{document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",ne),document.body.style.cursor="",document.body.style.userSelect="",document.body.classList.remove("is-dragging-chat")};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",U),document.addEventListener("mouseup",ne)}}),e.jsx("div",{className:"chat-column",style:{width:V},children:e.jsx(In,{messages:G,loading:B,connected:fe,status:m,onSend:Os,onAbort:Fe,width:V,sessionTitle:S.isNewChat?"新对话":S.activeSessionTitle,onNewSession:S.pluginName?()=>S.startNewChat():void 0,todoItems:f,onClearTodos:zs,toolLimitReached:ae,onContinueTools:As,toolCallsProgress:T,tokenUsage:ke,compressingStatus:Ae,onCompress:Ps})}),(z||ue)&&e.jsx("div",{className:"restart-overlay",children:e.jsxs("div",{className:"restart-dialog",children:[e.jsx("div",{className:"restart-spinner"}),e.jsx("h3",{children:ue?"切换前端":"正在重启…"}),e.jsx("p",{className:"restart-desc",children:ye})]})})]})}Hs.createRoot(document.getElementById("root")).render(e.jsx(zn,{}));export{os as B,vs as C,Mt as D,Dt as F,Te as M,Me as R,Vt as S,De as T,ss as W,Ns as X,he as _,te as a,dt as b,H as c,Ie as d,$e as e,qt as f,Lt as g,Ut as h,de as p};