@aalis/plugin-webui-client 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/assets/AuthorityPage-C21ovg99.js +12 -0
  2. package/dist/assets/{DynamicPage-Btwp6tND.js → DynamicPage-BjVDU5B_.js} +1 -1
  3. package/dist/assets/{FilesPage-Co_hAqZL.js → FilesPage-BGZJtahO.js} +1 -1
  4. package/dist/assets/MarketplacePage-9fRwgBeV.js +18 -0
  5. package/dist/assets/{PlatformPage-BHvObjEh.js → PlatformPage-Cj0TiG1T.js} +1 -1
  6. package/dist/assets/{PluginConfigPage-BHKSlJpz.js → PluginConfigPage-C3ik4uHI.js} +1 -1
  7. package/dist/assets/{SessionsPage-BM_ZInO9.js → SessionsPage-MeiGuGtS.js} +1 -1
  8. package/dist/assets/{arc-D6pe4Hbz.js → arc-BwVjnPVb.js} +1 -1
  9. package/dist/assets/{architectureDiagram-3BPJPVTR-CwoqzY-x.js → architectureDiagram-3BPJPVTR-DEZLwiAK.js} +1 -1
  10. package/dist/assets/{blockDiagram-GPEHLZMM-Irsp4tTR.js → blockDiagram-GPEHLZMM-CZ-Ur4Do.js} +1 -1
  11. package/dist/assets/{c4Diagram-AAUBKEIU-CBEYi4cc.js → c4Diagram-AAUBKEIU-BrWPxX4f.js} +1 -1
  12. package/dist/assets/channel-C9SCdcK6.js +1 -0
  13. package/dist/assets/{chunk-2J33WTMH-C0BXcLLA.js → chunk-2J33WTMH-DX8VUhe0.js} +1 -1
  14. package/dist/assets/{chunk-4BX2VUAB-g2_kd4Jk.js → chunk-4BX2VUAB-O0Ahe-nx.js} +1 -1
  15. package/dist/assets/{chunk-55IACEB6-7Gvl0Bkc.js → chunk-55IACEB6-CBqrnhNz.js} +1 -1
  16. package/dist/assets/{chunk-727SXJPM-B6zCFbQ8.js → chunk-727SXJPM-Dooc2RYO.js} +1 -1
  17. package/dist/assets/{chunk-AQP2D5EJ-j5PrmMkv.js → chunk-AQP2D5EJ-DYpwwwje.js} +1 -1
  18. package/dist/assets/{chunk-FMBD7UC4-COJ16id3.js → chunk-FMBD7UC4-BGqxhWb0.js} +1 -1
  19. package/dist/assets/{chunk-ND2GUHAM-BuUYHFRS.js → chunk-ND2GUHAM-D277WP9X.js} +1 -1
  20. package/dist/assets/{chunk-QZHKN3VN-ZjgqnbA7.js → chunk-QZHKN3VN-CT8yoXC6.js} +1 -1
  21. package/dist/assets/classDiagram-4FO5ZUOK-DOVv21Jy.js +1 -0
  22. package/dist/assets/classDiagram-v2-Q7XG4LA2-DOVv21Jy.js +1 -0
  23. package/dist/assets/{clock-DwR8n9tr.js → clock-CM3-4qHr.js} +1 -1
  24. package/dist/assets/{cose-bilkent-S5V4N54A-cReoleHO.js → cose-bilkent-S5V4N54A-f2K2cI69.js} +1 -1
  25. package/dist/assets/{dagre-BM42HDAG-C5LVDRy-.js → dagre-BM42HDAG-DVM7tUDZ.js} +1 -1
  26. package/dist/assets/{diagram-2AECGRRQ-DJOINugO.js → diagram-2AECGRRQ-CnuaCaac.js} +1 -1
  27. package/dist/assets/{diagram-5GNKFQAL-C8TVmed8.js → diagram-5GNKFQAL-CnJvWU3Y.js} +1 -1
  28. package/dist/assets/{diagram-KO2AKTUF-DR6Lpt-U.js → diagram-KO2AKTUF-BLptaDQU.js} +1 -1
  29. package/dist/assets/{diagram-LMA3HP47-CAEsJvxV.js → diagram-LMA3HP47-DwMqgSJr.js} +1 -1
  30. package/dist/assets/{diagram-OG6HWLK6-DNlFytdX.js → diagram-OG6HWLK6-D3oRIeFt.js} +1 -1
  31. package/dist/assets/{erDiagram-TEJ5UH35-dTcBWcN8.js → erDiagram-TEJ5UH35-CNcQqYpF.js} +1 -1
  32. package/dist/assets/{flowDiagram-I6XJVG4X-SW6akebO.js → flowDiagram-I6XJVG4X-DjKDuqZi.js} +1 -1
  33. package/dist/assets/{ganttDiagram-6RSMTGT7-B71E4ziX.js → ganttDiagram-6RSMTGT7-D_SfkzXd.js} +1 -1
  34. package/dist/assets/{gitGraphDiagram-PVQCEYII-G5JbRXuE.js → gitGraphDiagram-PVQCEYII-DZXOY3n1.js} +1 -1
  35. package/dist/assets/{globe-Oit0H-sq.js → globe-ZjSUDGkM.js} +1 -1
  36. package/dist/assets/{index-BMsEuqd2.js → index-BtvzdAkg.js} +3 -3
  37. package/dist/assets/{infoDiagram-5YYISTIA-D7RpU2L_.js → infoDiagram-5YYISTIA-BtZu2HFx.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-YF4QCWOH-CLlHnGiA.js → ishikawaDiagram-YF4QCWOH-DE9OWNCV.js} +1 -1
  39. package/dist/assets/{journeyDiagram-JHISSGLW-BWXhFrMd.js → journeyDiagram-JHISSGLW-CxCNcl7b.js} +1 -1
  40. package/dist/assets/{kanban-definition-UN3LZRKU-DjLAo6uR.js → kanban-definition-UN3LZRKU-BffFNUsp.js} +1 -1
  41. package/dist/assets/{linear-DpLQBdv5.js → linear-DUpLrJcH.js} +1 -1
  42. package/dist/assets/{mermaid.core-CWJzgNYH.js → mermaid.core-C4yLb7RL.js} +4 -4
  43. package/dist/assets/{mindmap-definition-RKZ34NQL-CJ4SQsGL.js → mindmap-definition-RKZ34NQL-DksewSBD.js} +1 -1
  44. package/dist/assets/{pieDiagram-4H26LBE5-CboKAR99.js → pieDiagram-4H26LBE5-Ds7OlWF6.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-W4KKPZXB-BTldUqBZ.js → quadrantDiagram-W4KKPZXB-UgAvx7yF.js} +1 -1
  46. package/dist/assets/{requirementDiagram-4Y6WPE33-C7aQ4LbM.js → requirementDiagram-4Y6WPE33-B5Sw7FP8.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-5OEKKPKP-BMHf3LL5.js → sankeyDiagram-5OEKKPKP-DxGWLNGd.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-3UESZ5HK-cfTljl81.js → sequenceDiagram-3UESZ5HK-CHqT38WG.js} +1 -1
  49. package/dist/assets/{stateDiagram-AJRCARHV-Cps0x7Iw.js → stateDiagram-AJRCARHV-DsYWHqWu.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-BHNVJYJU-BjG2G_-k.js → stateDiagram-v2-BHNVJYJU-21wlVsrt.js} +1 -1
  51. package/dist/assets/{timeline-definition-PNZ67QCA-Dp4N6YCQ.js → timeline-definition-PNZ67QCA-BKKFXrRi.js} +1 -1
  52. package/dist/assets/{vennDiagram-CIIHVFJN-DmrsUzs9.js → vennDiagram-CIIHVFJN-BzHfDvxM.js} +1 -1
  53. package/dist/assets/{wardley-L42UT6IY-DNaqJg7q.js → wardley-L42UT6IY-DYWHt89G.js} +1 -1
  54. package/dist/assets/{wardleyDiagram-YWT4CUSO-C8gGZC7a.js → wardleyDiagram-YWT4CUSO-CUhBHZtC.js} +1 -1
  55. package/dist/assets/{xychartDiagram-2RQKCTM6-C_FbZJcp.js → xychartDiagram-2RQKCTM6-D5YhbInB.js} +1 -1
  56. package/dist/index.html +1 -1
  57. package/package.json +9 -9
  58. package/dist/assets/AuthorityPage-BodQ2Fvh.js +0 -12
  59. package/dist/assets/MarketplacePage-B0lQ5lTU.js +0 -23
  60. package/dist/assets/channel-hakHuzxv.js +0 -1
  61. package/dist/assets/classDiagram-4FO5ZUOK-DroIm4A8.js +0 -1
  62. package/dist/assets/classDiagram-v2-Q7XG4LA2-DroIm4A8.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-CWJzgNYH.js","assets/react-vendor-BPQixOLZ.js","assets/PluginConfigPage-BHKSlJpz.js","assets/SchemaForm-YVQZ6Keg.js","assets/highlight-DJvvuuwd.js","assets/highlight-BPWJwfct.css","assets/katex-Bq6vt64r.js","assets/katex-CIHdCL6t.css","assets/markdown-BCywGHw2.js","assets/MarketplacePage-B0lQ5lTU.js","assets/clock-DwR8n9tr.js","assets/PlatformPage-BHvObjEh.js","assets/globe-Oit0H-sq.js","assets/AuthorityPage-BodQ2Fvh.js","assets/LogPage-C_Z3RA5T.js","assets/SessionsPage-BM_ZInO9.js","assets/FilesPage-Co_hAqZL.js","assets/DynamicPage-Btwp6tND.js","assets/cytoscape.esm-LDYqcvCF.js","assets/cytoscape-fcose-DXAQNCkb.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-C4yLb7RL.js","assets/react-vendor-BPQixOLZ.js","assets/PluginConfigPage-C3ik4uHI.js","assets/SchemaForm-YVQZ6Keg.js","assets/highlight-DJvvuuwd.js","assets/highlight-BPWJwfct.css","assets/katex-Bq6vt64r.js","assets/katex-CIHdCL6t.css","assets/markdown-BCywGHw2.js","assets/MarketplacePage-9fRwgBeV.js","assets/clock-CM3-4qHr.js","assets/PlatformPage-Cj0TiG1T.js","assets/globe-ZjSUDGkM.js","assets/AuthorityPage-C21ovg99.js","assets/LogPage-C_Z3RA5T.js","assets/SessionsPage-MeiGuGtS.js","assets/FilesPage-BGZJtahO.js","assets/DynamicPage-BjVDU5B_.js","assets/cytoscape.esm-LDYqcvCF.js","assets/cytoscape-fcose-DXAQNCkb.js"])))=>i.map(i=>d[i]);
2
2
  import{j as e,r as a,c as qs}from"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import{r as Bs,b as Hs,a as Vs,c as Js,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 Gs="modulepreload",Ks=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(g=>Promise.resolve(g).then(j=>({status:"fulfilled",value:j}),j=>({status:"rejected",reason:j}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),x=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));i=u(n.map(l=>{if(l=Ks(l),l in as)return;as[l]=!0;const g=l.endsWith(".css"),j=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${j}`))return;const v=document.createElement("link");if(v.rel=g?"stylesheet":Gs,g||(v.as="script"),v.crossOrigin="",v.href=l,x&&v.setAttribute("nonce",x),document.head.appendChild(v),g)return new Promise((w,c)=>{v.addEventListener("load",w),v.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${l}`)))})}))}function d(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return i.then(u=>{for(const f of u||[])f.status==="rejected"&&d(f.reason);return s().catch(d)})},ms="aalis:activeSessionId";function Us(){try{return window.localStorage.getItem(ms)||"__new_chat__"}catch{return"__new_chat__"}}let Ye=Us();const Xe=new Set;function oe(){return Ye}function He(t){if(Ye!==t){Ye=t;try{window.localStorage.setItem(ms,t)}catch{}for(const s of Xe)s(t)}}function Ys(t){return Xe.add(t),()=>Xe.delete(t)}async function Q(t,s){return(await fetch(t,{headers:{"Content-Type":"application/json"},...s})).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)}),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 Xs(){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 Zs(){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 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("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 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("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 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("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 tt(){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 nt(){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 at(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 x,l,g=!1;function j(){if(g)return;const v=location.protocol==="https:"?"wss:":"ws:";x=new WebSocket(`${v}//${location.host}/ws`),n.current=x,x.onopen=()=>{g||(i(!0),x.send(JSON.stringify({type:"subscribe_logs"})),x.send(JSON.stringify({type:"subscribe_session",sessionId:oe()})),d.current=oe())},x.onclose=()=>{g||(i(!1),l=setTimeout(j,3e3))},x.onmessage=w=>{var c,L,I,C,S,G,P,Z,q,U,Y,k,m;try{const h=JSON.parse(w.data),p=s.current;h.type==="stream"?(p.onStream(h.contentDelta,h.reasoningDelta,h.done,h.toolLimitReached),h.toolCallProgress&&((c=p.onToolCallProgress)==null||c.call(p,h.toolCallProgress)),h.done&&((L=p.onToolCallProgressClear)==null||L.call(p))):h.type==="message"&&(h.content||(I=h.attachments)!=null&&I.length)?p.onMessage(h.content??"",h.reasoningContent,h.segments,h.attachments,h.modelInfo):h.type==="tool_call"&&h.toolName?p.onToolCall(h.toolName,h.toolArgs??{},h.toolPhase,h.toolResult):h.type==="log"&&h.log?p.onLog(h.log):h.type==="state_changed"?(C=p.onStateChanged)==null||C.call(p):h.type==="restarting"?(S=p.onRestarting)==null||S.call(p):h.type==="reload"?(G=p.onReload)==null||G.call(p):h.type==="sessions_changed"?(P=p.onSessionsChanged)==null||P.call(p):h.type==="todo_updated"&&h.todoItems?(Z=p.onTodoUpdated)==null||Z.call(p,h.todoItems):h.type==="stream_resume"?(q=p.onStreamResume)==null||q.call(p,h.content??"",h.reasoningContent??"",h.segments??[],!!h.done,h.toolCallsProgress):h.type==="confirm"&&h.content?(U=p.onConfirm)==null||U.call(p,h.content):h.type==="token_usage"&&h.tokenUsage?(Y=p.onTokenUsage)==null||Y.call(p,h.tokenUsage):h.type==="compressing"&&h.sessionId?(k=p.onCompressing)==null||k.call(p,h.sessionId,h.content??"start"):h.type==="history_changed"&&h.sessionId?(m=p.onHistoryChanged)==null||m.call(p,h.sessionId):h.type==="page_refresh"&&window.dispatchEvent(new CustomEvent("aalis:page-refresh",{detail:{pluginName:h.pluginName}}))}catch{}}}return j(),()=>{g=!0,clearTimeout(l),x==null||x.close()}},[]),a.useEffect(()=>Ys(l=>{const g=n.current;(g==null?void 0:g.readyState)===WebSocket.OPEN&&(g.send(JSON.stringify({type:"unsubscribe_session",sessionId:d.current})),g.send(JSON.stringify({type:"subscribe_session",sessionId:l})),d.current=l)}),[]);const u=a.useCallback((x,l)=>{var g;if(((g=n.current)==null?void 0:g.readyState)===WebSocket.OPEN){const j={type:"message",content:x,sessionId:oe()};l&&l.length>0&&(j.attachments=l),n.current.send(JSON.stringify(j))}},[]),f=a.useCallback(x=>{var l;((l=n.current)==null?void 0:l.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(x))},[]);return{send:u,sendRaw:f,connected:r}}function rt(){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 ot(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 it(t){var r,i,d,u;const s=[];let n=0;for(;n<t.length;){const f=t[n];if(f.role==="user"){const x=f.content??"",l=Array.isArray((r=f.metadata)==null?void 0:r.fileNames)?f.metadata.fileNames:null,{displayContent:g,fileNames:j}=ot(x),v=(l??j).filter(Boolean);s.push({role:"user",content:g,fileNames:v.length>0?v:void 0,timestamp:f.timestamp??0}),n++;continue}if(f.role==="system"){f.kind==="event-marker"&&s.push({role:"system",content:f.content??"",timestamp:f.timestamp??0}),n++;continue}if(f.role==="notice"){s.push({role:"system",content:f.content??"",timestamp:f.timestamp??0}),n++;continue}if(f.role==="assistant"){const x=[],l=[];let g=f.timestamp??0,j="",v=!1,w;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&&(w=S)}if(C.role==="assistant"&&C.segments&&C.segments.length>0){v=!0,x.length=0,l.length=0;for(const S of C.segments)x.push(S);g=C.timestamp??g,n++;continue}if(C.role==="assistant"&&C.toolCalls&&C.toolCalls.length>0){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&x.push({type:"text",content:C.content});for(const S of C.toolCalls){let G={};try{G=JSON.parse(S.function.arguments)}catch{}x.push({type:"tool_call",name:S.function.name,args:G})}g=C.timestamp??g,n++}else if(C.role==="tool"&&C.toolCallId){for(let S=x.length-1;S>=0;S--){const G=x[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}),j=C.content??"",g=C.timestamp??g,n++;break}C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&x.push({type:"text",content:C.content}),g=C.timestamp??g,n++}else break}let c;v?c=x:(c=[...l,...x],j&&c.push({type:"text",content:j}));let L="",I="";for(const C of c)C.type==="reasoning_text"?L+=C.content:C.type==="text"&&(I+=C.content);s.push({role:"assistant",content:I||j||f.content||"",segments:c.length>0?c:void 0,reasoningContent:L||void 0,timestamp:g,modelInfo:w});continue}n++}return s}function lt(t){const[s,n]=a.useState([]),[r,i]=a.useState(oe()),[d,u]=a.useState([]),[f,x]=a.useState(!1),l=a.useRef(!1),g=a.useRef(new Map),j=a.useMemo(()=>{const k=t.find(m=>m.key==="sessions");return(k==null?void 0:k.plugin)??null},[t]),v=a.useRef(j);v.current=j;const w=a.useRef(r);w.current=r;const c=a.useRef(d);c.current=d;const L=a.useRef(s);L.current=s;const I=a.useMemo(()=>j?s.length===0||!s.some(k=>k.id===r):!1,[j,s,r]),C=a.useMemo(()=>{const k=s.find(m=>m.id===r);return(k==null?void 0:k.title)||(k==null?void 0:k.displayTitle)||(k==null?void 0:k.name)||""},[s,r]),S=a.useCallback(()=>{const k=v.current;k&&de(k,"listSessions").then(m=>{Array.isArray(m)&&n(m)}).catch(()=>{})},[]),G=a.useCallback(()=>{c.current.length>0&&g.current.set(w.current,c.current);const k="__new_chat__";i(k),He(k),u([]),x(!1),l.current=!1},[]),P=a.useCallback(async k=>{const m=v.current;if(!m)return null;const h=rt();try{const p=await de(m,"createSession",{name:h,...k?{parentId:k}:{}});if(!(p!=null&&p.id))return null;const W=p.id;return n(V=>{if(V.some(_=>_.id===W))return V;const ae={id:W,name:p.name||h,title:p.title,displayTitle:p.title||p.name||h,status:"active",children:[],childCount:0,parentId:k,createdAt:Date.now()};return[...V,ae]}),k&&n(V=>V.map(ae=>ae.id===k?{...ae,children:[...ae.children,W],childCount:ae.childCount+1}:ae)),c.current.length>0&&g.current.set(w.current,c.current),i(W),He(W),u([]),x(!1),l.current=!1,de(m,"listSessions").then(V=>{Array.isArray(V)&&n(V)}).catch(()=>{}),W}catch{return null}},[]),Z=a.useCallback(async()=>!v.current||L.current.some(h=>h.id===w.current)?w.current:await P()||w.current,[P]),q=a.useCallback((k,m)=>{de(m,"getSessionDetail",{id:k}).then(h=>{if(h!=null&&h.messages&&w.current===k){const p=it(h.messages);if(l.current){for(;p.length>0&&p[p.length-1].role==="assistant";)p.pop();const W=c.current,V=W[W.length-1];V&&V.role==="assistant"&&p.push(V)}u(p),g.current.set(k,p)}}).catch(()=>{})},[]),U=a.useCallback(k=>{const m=k===w.current;if(m&&c.current.length>0)return;!m&&c.current.length>0&&g.current.set(w.current,c.current),i(k),He(k),x(!1),l.current=!1;const h=v.current,p=g.current.get(k);u(p??[]),!p&&h&&q(k,h),S()},[q,S]),Y=a.useCallback(k=>{if(k!==w.current)return;const m=v.current;m&&(g.current.delete(k),q(k,m))},[q]);return a.useEffect(()=>{j&&de(j,"listSessions").then(k=>{if(!Array.isArray(k))return;n(k);const m=oe();m&&m!=="__new_chat__"&&k.some(h=>h.id===m)&&(i(m),q(m,j))}).catch(()=>{})},[j,q]),{pluginName:j,sessionList:s,activeSessionId:r,activeSessionTitle:C,isNewChat:I,messages:d,setMessages:u,refresh:S,startNewChat:G,createSession:P,ensureSession:Z,switchSession:U,handleHistoryChanged:Y,loading:f,setLoading:x,streamingRef:l}}/**
3
3
  * @license lucide-react v1.7.0 - ISC
4
4
  *
@@ -175,7 +175,7 @@ $$
175
175
  ${f}
176
176
  $$
177
177
 
178
- `}))),n)).join("")}function sn(t){if(!t||!Number.isFinite(t))return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=new Date,r=x=>x.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 f=`${s.getMonth()+1}-${s.getDate()} ${i}`;return d?f:`${s.getFullYear()}-${f}`}let Ke=null;function tn(){return Ke||(Ke=he(()=>import("./mermaid.core-CWJzgNYH.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:"loose",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 nn=0;function an({chart:t}){const[s,n]=a.useState(null),[r,i]=a.useState(null),d=a.useRef(`mermaid-${++nn}`);return a.useEffect(()=>{let u=!1;const f=d.current,x=t.trim();if(!x){n(null),i(null);return}return tn().then(async l=>(await l.parse(x),l.render(f,x))).then(({svg:l})=>{u||(n(l),i(null))}).catch(l=>{if(cs(f),u)return;const g=l instanceof Error?l.message:String(l);i(g),n(null)}),()=>{u=!0,cs(f)}},[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 rn=a.memo(an),Te=[Vs,Js],on={strict:"ignore",throwOnError:!1,errorColor:"inherit",output:"htmlAndMathml"},Ie=[Bs,[Hs,on]];function ln({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(rn,{chart:d.replace(/\n$/,"")})}return e.jsx("code",{className:t,...n,children:s})}const Me={code:ln};function cn(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 dn(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function un({open:t,onClose:s,sessionId:n}){const[r,i]=a.useState([]),[d,u]=a.useState(!1),[f,x]=a.useState(null),[l,g]=a.useState(null),j=a.useCallback(async()=>{if(!n||n==="__new_chat__"){i([]);return}u(!0),x(null);try{const c=await Q(`/api/uploaded-files?sessionId=${encodeURIComponent(n)}`);if(c.error)throw new Error(c.error);i(c.files||[])}catch(c){x(c instanceof Error?c.message:String(c)),i([])}finally{u(!1)}},[n]);a.useEffect(()=>{t&&j()},[t,j]);const v=a.useCallback(async c=>{if(window.confirm(`确定删除文件 "${c.name}"?删除后无法恢复。`)){g(c.id);try{const I=await fetch("/api/uploaded-files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:c.sessionId,fileId:c.id})}),C=await I.json();if(!I.ok||C.error)throw new Error(C.error||`HTTP ${I.status}`);await j()}catch(I){window.alert(`删除失败:${I instanceof Error?I.message:String(I)}`)}finally{g(null)}}},[j]),w=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:j,title:"刷新",disabled:d,children:e.jsx(Ft,{size:14,className:d?"spin":""})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:s,title:"关闭",children:e.jsx(ys,{size:14})})]})]}),e.jsxs("div",{className:"uploaded-files-drawer-body",children:[f&&e.jsxs("div",{className:"uploaded-files-drawer-error",children:["加载失败:",f]}),!f&&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(It,{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:[cn(c.size)," · ",c.mimeType," · ",dn(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:()=>w(c),title:"下载",children:e.jsx(_t,{size:14})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn danger",onClick:()=>v(c),disabled:l===c.id,title:"删除",children:e.jsx(Jt,{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 hn=a.memo(a.forwardRef(function({loading:s,connected:n,canUpload:r,canUploadImage:i,canUploadFile:d,acceptAttr:u,onSend:f,onAbort:x},l){const[g,j]=a.useState(""),[v,w]=a.useState([]),[c,L]=a.useState([]),I=a.useRef([]),C=a.useRef(null),S=a.useRef(null),G=a.useCallback(()=>{const _=C.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]),P=a.useCallback(async _=>{const M=[],A=[],z=[];for(const K of Array.from(_))if(K.type.startsWith("image/")&&i){if(K.size>10*1024*1024)continue;const ee=await ds(K);M.push(ee),z.push("image")}else if(d){if(K.size>20*1024*1024)continue;const ee=await ds(K);A.push({name:K.name,data:ee,mimeType:K.type||void 0}),z.push("file")}M.length>0&&w(K=>[...K,...M]),A.length>0&&L(K=>[...K,...A]),z.length>0&&(I.current=[...I.current,...z])},[i,d]);a.useImperativeHandle(l,()=>({addFiles:P}),[P]);const Z=a.useCallback(async()=>{await f(g,c,v,I.current),j(""),w([]),L([]),I.current=[],C.current&&(C.current.style.height="auto")},[g,c,v,f]),q=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Z())},U=async _=>{_.target.files&&await P(_.target.files),_.target.value=""},Y=async _=>{var z;if(!i)return;const M=(z=_.clipboardData)==null?void 0:z.items;if(!M)return;const A=[];for(const K of Array.from(M)){if(!K.type.startsWith("image/"))continue;const ee=K.getAsFile();ee&&A.push(ee)}A.length>0&&await P(A)},k=_=>{w(z=>z.filter((K,ee)=>ee!==_));const M=[...I.current];let A=0;for(let z=0;z<M.length;z++)if(M[z]==="image"){if(A===_){M.splice(z,1);break}A++}I.current=M},m=_=>{L(z=>z.filter((K,ee)=>ee!==_));const M=[...I.current];let A=0;for(let z=0;z<M.length;z++)if(M[z]==="file"){if(A===_){M.splice(z,1);break}A++}I.current=M},h=I.current,p=new Array(v.length),W=new Array(c.length);{let _=0,M=0;for(let A=0;A<h.length;A++)h[A]==="image"?(_<p.length&&(p[_]=A+1),_++):h[A]==="file"&&(M<W.length&&(W[M]=A+1),M++)}const V=!!(g.trim()||v.length>0||c.length>0),ae=s&&!V;return e.jsxs(e.Fragment,{children:[v.length>0&&e.jsx("div",{className:"pending-images",children:v.map((_,M)=>e.jsxs("div",{className:"pending-image-item",children:[e.jsx("img",{src:_,alt:`pending-${M}`}),e.jsx("button",{className:"pending-image-remove",onClick:()=>k(M),children:"×"}),p[M]>0&&e.jsxs("span",{className:"pending-order-badge",children:["#",p[M]]})]},M))}),c.length>0&&e.jsx("div",{className:"pending-files",children:c.map((_,M)=>e.jsxs("div",{className:"pending-file-item",children:[W[M]>0&&e.jsxs("span",{className:"pending-file-order",children:["#",W[M]]}),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:()=>m(M),children:"×"})]},M))}),e.jsxs("div",{className:"input-area",children:[e.jsx("input",{ref:S,type:"file",accept:u,multiple:!0,style:{display:"none"},onChange:U}),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(vs,{size:18})}),e.jsx("textarea",{ref:C,value:g,onChange:_=>{j(_.target.value),G()},onKeyDown:q,onPaste:Y,placeholder:"输入消息... (Enter 发送, Shift+Enter 换行)",disabled:!n,rows:1}),ae?e.jsx("button",{className:"send-btn stop-mode",onClick:x,title:"停止生成",children:e.jsx(Ht,{size:16})}):e.jsx("button",{className:"send-btn",onClick:()=>{Z()},disabled:!n||!V,children:"↑"})]})]})}));function mn({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 fn({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(mn,{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 pn=[".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"],xn=pn.join(",")+",text/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document";function gn(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 jn(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 f="",x=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length){const l=s[r+1];f+=l==="n"?`
178
+ `}))),n)).join("")}function sn(t){if(!t||!Number.isFinite(t))return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=new Date,r=x=>x.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 f=`${s.getMonth()+1}-${s.getDate()} ${i}`;return d?f:`${s.getFullYear()}-${f}`}let Ke=null;function tn(){return Ke||(Ke=he(()=>import("./mermaid.core-C4yLb7RL.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:"loose",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 nn=0;function an({chart:t}){const[s,n]=a.useState(null),[r,i]=a.useState(null),d=a.useRef(`mermaid-${++nn}`);return a.useEffect(()=>{let u=!1;const f=d.current,x=t.trim();if(!x){n(null),i(null);return}return tn().then(async l=>(await l.parse(x),l.render(f,x))).then(({svg:l})=>{u||(n(l),i(null))}).catch(l=>{if(cs(f),u)return;const g=l instanceof Error?l.message:String(l);i(g),n(null)}),()=>{u=!0,cs(f)}},[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 rn=a.memo(an),Te=[Vs,Js],on={strict:"ignore",throwOnError:!1,errorColor:"inherit",output:"htmlAndMathml"},Ie=[Bs,[Hs,on]];function ln({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(rn,{chart:d.replace(/\n$/,"")})}return e.jsx("code",{className:t,...n,children:s})}const Me={code:ln};function cn(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 dn(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function un({open:t,onClose:s,sessionId:n}){const[r,i]=a.useState([]),[d,u]=a.useState(!1),[f,x]=a.useState(null),[l,g]=a.useState(null),j=a.useCallback(async()=>{if(!n||n==="__new_chat__"){i([]);return}u(!0),x(null);try{const c=await Q(`/api/uploaded-files?sessionId=${encodeURIComponent(n)}`);if(c.error)throw new Error(c.error);i(c.files||[])}catch(c){x(c instanceof Error?c.message:String(c)),i([])}finally{u(!1)}},[n]);a.useEffect(()=>{t&&j()},[t,j]);const v=a.useCallback(async c=>{if(window.confirm(`确定删除文件 "${c.name}"?删除后无法恢复。`)){g(c.id);try{const I=await fetch("/api/uploaded-files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:c.sessionId,fileId:c.id})}),C=await I.json();if(!I.ok||C.error)throw new Error(C.error||`HTTP ${I.status}`);await j()}catch(I){window.alert(`删除失败:${I instanceof Error?I.message:String(I)}`)}finally{g(null)}}},[j]),w=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:j,title:"刷新",disabled:d,children:e.jsx(Ft,{size:14,className:d?"spin":""})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:s,title:"关闭",children:e.jsx(ys,{size:14})})]})]}),e.jsxs("div",{className:"uploaded-files-drawer-body",children:[f&&e.jsxs("div",{className:"uploaded-files-drawer-error",children:["加载失败:",f]}),!f&&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(It,{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:[cn(c.size)," · ",c.mimeType," · ",dn(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:()=>w(c),title:"下载",children:e.jsx(_t,{size:14})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn danger",onClick:()=>v(c),disabled:l===c.id,title:"删除",children:e.jsx(Jt,{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 hn=a.memo(a.forwardRef(function({loading:s,connected:n,canUpload:r,canUploadImage:i,canUploadFile:d,acceptAttr:u,onSend:f,onAbort:x},l){const[g,j]=a.useState(""),[v,w]=a.useState([]),[c,L]=a.useState([]),I=a.useRef([]),C=a.useRef(null),S=a.useRef(null),G=a.useCallback(()=>{const _=C.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]),P=a.useCallback(async _=>{const M=[],A=[],z=[];for(const K of Array.from(_))if(K.type.startsWith("image/")&&i){if(K.size>10*1024*1024)continue;const ee=await ds(K);M.push(ee),z.push("image")}else if(d){if(K.size>20*1024*1024)continue;const ee=await ds(K);A.push({name:K.name,data:ee,mimeType:K.type||void 0}),z.push("file")}M.length>0&&w(K=>[...K,...M]),A.length>0&&L(K=>[...K,...A]),z.length>0&&(I.current=[...I.current,...z])},[i,d]);a.useImperativeHandle(l,()=>({addFiles:P}),[P]);const Z=a.useCallback(async()=>{await f(g,c,v,I.current),j(""),w([]),L([]),I.current=[],C.current&&(C.current.style.height="auto")},[g,c,v,f]),q=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Z())},U=async _=>{_.target.files&&await P(_.target.files),_.target.value=""},Y=async _=>{var z;if(!i)return;const M=(z=_.clipboardData)==null?void 0:z.items;if(!M)return;const A=[];for(const K of Array.from(M)){if(!K.type.startsWith("image/"))continue;const ee=K.getAsFile();ee&&A.push(ee)}A.length>0&&await P(A)},k=_=>{w(z=>z.filter((K,ee)=>ee!==_));const M=[...I.current];let A=0;for(let z=0;z<M.length;z++)if(M[z]==="image"){if(A===_){M.splice(z,1);break}A++}I.current=M},m=_=>{L(z=>z.filter((K,ee)=>ee!==_));const M=[...I.current];let A=0;for(let z=0;z<M.length;z++)if(M[z]==="file"){if(A===_){M.splice(z,1);break}A++}I.current=M},h=I.current,p=new Array(v.length),W=new Array(c.length);{let _=0,M=0;for(let A=0;A<h.length;A++)h[A]==="image"?(_<p.length&&(p[_]=A+1),_++):h[A]==="file"&&(M<W.length&&(W[M]=A+1),M++)}const V=!!(g.trim()||v.length>0||c.length>0),ae=s&&!V;return e.jsxs(e.Fragment,{children:[v.length>0&&e.jsx("div",{className:"pending-images",children:v.map((_,M)=>e.jsxs("div",{className:"pending-image-item",children:[e.jsx("img",{src:_,alt:`pending-${M}`}),e.jsx("button",{className:"pending-image-remove",onClick:()=>k(M),children:"×"}),p[M]>0&&e.jsxs("span",{className:"pending-order-badge",children:["#",p[M]]})]},M))}),c.length>0&&e.jsx("div",{className:"pending-files",children:c.map((_,M)=>e.jsxs("div",{className:"pending-file-item",children:[W[M]>0&&e.jsxs("span",{className:"pending-file-order",children:["#",W[M]]}),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:()=>m(M),children:"×"})]},M))}),e.jsxs("div",{className:"input-area",children:[e.jsx("input",{ref:S,type:"file",accept:u,multiple:!0,style:{display:"none"},onChange:U}),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(vs,{size:18})}),e.jsx("textarea",{ref:C,value:g,onChange:_=>{j(_.target.value),G()},onKeyDown:q,onPaste:Y,placeholder:"输入消息... (Enter 发送, Shift+Enter 换行)",disabled:!n,rows:1}),ae?e.jsx("button",{className:"send-btn stop-mode",onClick:x,title:"停止生成",children:e.jsx(Ht,{size:16})}):e.jsx("button",{className:"send-btn",onClick:()=>{Z()},disabled:!n||!V,children:"↑"})]})]})}));function mn({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 fn({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(mn,{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 pn=[".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"],xn=pn.join(",")+",text/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document";function gn(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 jn(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 f="",x=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length){const l=s[r+1];f+=l==="n"?`
179
179
  `:l==="t"?" ":l==='"'?'"':l==="\\"?"\\":l,r+=2}else if(s[r]==='"'){x=!0,r++;break}else f+=s[r],r++;n.push({key:d,keyDone:!0,value:f,valueDone:x,valueType:"string"})}else if(s[r]==="{"||s[r]==="["){const f=s[r],x=f==="{"?"}":"]";let l=1;const g=r;r++;let j=!1;for(;r<s.length&&l>0;)j?s[r]==="\\"?r++:s[r]==='"'&&(j=!1):s[r]==='"'?j=!0:s[r]===f?l++:s[r]===x&&l--,r++;n.push({key:d,keyDone:!0,value:s.slice(g,r),valueDone:l===0,valueType:f==="{"?"object":"array"})}else{let f="";for(;r<s.length&&!/[,\s}]/.test(s[r]);)f+=s[r],r++;const x=r<s.length&&/[,}]/.test(s[r]),l=/^(true|false)$/.test(f)?"boolean":f==="null"?"null":"number";n.push({key:d,keyDone:!0,value:f,valueDone:x,valueType:l})}}return n.length>0?n:null}const ws={mood:"心情",state:"状态",desire:"发言欲望",current_action:"当前动作",think:"思考",message:"回复",response:"回复",reply:"回复",content:"内容",analysis:"分析",file_analysis:"文件分析",image_analysis:"图片分析"},ks=new Set(["message","response","reply","content","answer","text","msg"]);function vn({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(xs,{size:14}):e.jsx(gs,{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(bs,{fieldKey:i,value:d},i))})]})}function bs({fieldKey:t,value:s}){const n=ws[t]||t;if(s==null||s==="")return null;if(typeof s=="object"&&!Array.isArray(s))return e.jsx(vn,{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=ks.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:Te,rehypePlugins:Ie,components:Me,children:$e(r)})}):e.jsx("span",{className:"json-field-value",children:r})]})}function yn({data:t}){return e.jsx("div",{className:"json-message-view",children:Object.entries(t).map(([s,n])=>e.jsx(bs,{fieldKey:s,value:n},s))})}function Nn({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&&ws[s.key]||s.key,u=s.keyDone&&ks.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:Te,rehypePlugins:Ie,components:Me,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=gn(s);if(n)return e.jsx(yn,{data:n});if(s.trim().startsWith("{")){const i=jn(s);return i?e.jsx(Nn,{fields:i}):null}return e.jsx(_e,{remarkPlugins:Te,rehypePlugins:Ie,components:Me,children:$e(s)})});function wn(t){if(!t)return"";const s=[];return t.image&&s.push("image/*"),t.file&&s.push(xn),s.push("audio/*"),s.push("video/*"),s.join(",")}function kn({status:t}){switch(t){case"completed":return e.jsx(js,{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(kt,{size:14,className:"todo-icon todo-icon-pending"})}}function bn({items:t,onClear:s,loading:n}){const[r,i]=a.useState(!0),d=t.filter(l=>l.status==="completed").length,u=t.length,f=d===u,x=!f&&n;return e.jsxs("div",{className:`todo-bar ${f?"todo-bar-done":""}`,children:[e.jsxs("div",{className:"todo-bar-header",onClick:()=>i(!r),children:[e.jsx(Dt,{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(xs,{size:14}):e.jsx(gs,{size:14})}),e.jsx("button",{className:"todo-bar-clear",onClick:l=>{l.stopPropagation(),x||s()},disabled:x,title:x?"任务执行中,无法清除":"清除计划",children:e.jsx(ys,{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(kn,{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 Cn=a.memo(function({msg:s,senderName:n,isLast:r,isGenerating:i,onAbort:d,checkpoint:u,rolledBack:f,onRollback:x,onRollbackWithChat:l,toolCallsProgress:g}){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(ps,{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:sn(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((j,v)=>e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(j),alt:`attached-${v}`,className:"message-image",onClick:()=>hs(je(j))})},v))}),s.role==="user"&&s.fileNames&&s.fileNames.length>0&&e.jsx("div",{className:"message-files",children:s.fileNames.map((j,v)=>e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",j]},v))}),s.role==="assistant"&&s.attachments&&s.attachments.length>0&&e.jsx("div",{className:"message-images",children:s.attachments.map((j,v)=>j.kind==="image"?e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(j.data),alt:j.name??`attachment-${v}`,className:"message-image",onClick:()=>hs(je(j.data))})},`a-${v}`):j.kind==="video"?e.jsx("video",{controls:!0,src:je(j.data),className:"message-image"},`a-${v}`):j.kind==="audio"?e.jsx("audio",{controls:!0,src:je(j.data)},`a-${v}`):e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",j.name??"attachment"]},`a-${v}`))}),s.role==="assistant"&&s.segments&&s.segments.length>0?e.jsx("div",{className:"message-bubble",children:(()=>{const j=[];let v=0;for(;v<s.segments.length;){const w=s.segments[v];if(w.type==="reasoning_text"){const c=[];for(;v<s.segments.length&&s.segments[v].type==="reasoning_text";)c.push(s.segments[v]),v++;const L=c.filter(I=>I.type==="reasoning_text").map(I=>I.content).join("");L&&j.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:Te,rehypePlugins:Ie,components:Me,children:$e(L)})})]},`r-${v}`));continue}if(w.type==="text"){w.content&&j.push(e.jsx(Ue,{content:w.content},`t-${v}`)),v++;continue}j.push(e.jsx(fn,{seg:w,index:v},`tc-${v}`)),v++}return j})()}):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:Te,rehypePlugins:Ie,components:Me,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"&&g&&g.size>0&&e.jsx("div",{className:"tool-call-progress-bubble",children:[...g.entries()].sort((j,v)=>j[0]-v[0]).map(([j,v])=>e.jsx(Cs,{name:v.name,charsAccumulated:v.charsAccumulated,startedAt:v.startedAt},`pending-${j}`))}),r&&i&&s.role==="assistant"&&e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"}),s.role==="assistant"&&u&&!i&&(f?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:()=>x==null?void 0:x(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
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 Cs({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 Sn({messages:t,loading:s,connected:n,status:r,onSend:i,onAbort:d,width:u,sessionTitle:f,onNewSession:x,todoItems:l,onClearTodos:g,toolLimitReached:j,onContinueTools:v,toolCallsProgress:w,tokenUsage:c,compressingStatus:L,onCompress:I}){const C=a.useRef(null),S=a.useRef(null),G=a.useRef(null),P=a.useRef(!1),[Z,q]=a.useState([]),[U,Y]=a.useState(new Set),k=a.useRef(s);a.useEffect(()=>{let y=!1;async function R(){try{const B=oe();if(!B||B==="__new_chat__"){y||q([]);return}const F=await de("@aalis/plugin-checkpoint","listTurns",{sessionId:B});!y&&Array.isArray(F)&&q(F)}catch{}}return k.current&&!s?R():t.length===0?q([]):R(),k.current=s,()=>{y=!0}},[s,f,t.length]);const m=a.useMemo(()=>y=>{for(const R of Z){const B=R.startedAt-1e3,F=(R.endedAt??R.startedAt+6e4)+5e3;if(y>=B&&y<=F)return R}},[Z]),h=a.useCallback(async y=>{const R=y.filesPreview.slice(0,3).join(`
@@ -204,4 +204,4 @@ ${R}${B}`:"";if(window.confirm(`将回滚本轮对话:
204
204
  此操作不可撤销。确定继续?`))try{const X=await de("@aalis/plugin-checkpoint","rollbackWithChat",{sessionId:oe(),turnId:y.turnId}),le=[];X.chatDeleted&&le.push(`删除 ${X.deletedMessages} 条消息`),y.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
- `)),Y(ge=>new Set([...ge,y.turnId]))}catch(X){window.alert(`回滚失败:${X.message}`)}},[]),W=a.useRef(null),V=a.useRef(!1),[ae,_]=a.useState(!1),M=a.useRef(0),[A,z]=a.useState(!1),[K,ee]=a.useState(!1),[xe,ue]=a.useState(null),ve=a.useRef(0),ye=a.useRef(0);a.useEffect(()=>{const y=B=>{const F=B.detail;typeof F=="string"&&ue(F)},R=B=>{B.key==="Escape"&&ue(null)};return window.addEventListener(es,y),window.addEventListener("keydown",R),()=>{window.removeEventListener(es,y),window.removeEventListener("keydown",R)}},[]);const re=r==null?void 0:r.uploadCapabilities,Ne=(re==null?void 0:re.image)??!1,we=(re==null?void 0:re.file)??!1,ke=Ne||we,Pe=wn(re);a.useEffect(()=>{L==="start"?(ve.current=Date.now(),ye.current=0):(L==="done"||L==="error")&&(ye.current=Date.now())},[L]),a.useEffect(()=>{const y=G.current;if(!y)return;const R=()=>{const{scrollTop:B,scrollHeight:F,clientHeight:me}=y;P.current=F-B-me>200,V.current=!0,W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{V.current=!1},300)};return y.addEventListener("scroll",R,{passive:!0}),()=>y.removeEventListener("scroll",R)},[]),a.useEffect(()=>{const y=G.current;if(!y)return;const R=new ResizeObserver(()=>{var B;!P.current&&!V.current&&((B=S.current)==null||B.scrollIntoView({behavior:s?"instant":"smooth"}))});return R.observe(y),()=>R.disconnect()},[t.length]),a.useEffect(()=>{var y;!P.current&&!V.current&&((y=S.current)==null||y.scrollIntoView({behavior:"smooth"}))},[t]);const Ae=a.useCallback((y,R,B,F)=>i(y,R,B,F),[i]),be=y=>{y.preventDefault(),y.stopPropagation(),M.current++,ke&&y.dataTransfer.types.includes("Files")&&_(!0)},Ce=y=>{y.preventDefault(),y.stopPropagation(),M.current--,M.current<=0&&(M.current=0,_(!1))},Ee=y=>{y.preventDefault(),y.stopPropagation()},ze=async y=>{var R;y.preventDefault(),y.stopPropagation(),M.current=0,_(!1),!(!ke||!y.dataTransfer.files.length)&&await((R=C.current)==null?void 0:R.addFiles(y.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(vs,{size:16})," 松开以上传文件"]})}),e.jsxs("div",{className:"chat-panel-header",children:[e.jsxs("span",{className:"chat-panel-title",children:[e.jsx(is,{size:16})," ",f||(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(Ns,{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()})]})]}),I&&e.jsx("button",{className:"token-panel-compress-btn",onClick:y=>{y.stopPropagation(),I()},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(ps,{size:12})," 压缩对话"]})})]}):e.jsx("div",{className:"token-panel-empty",children:"发送消息后将显示 Token 用量统计"})]})]}),x&&e.jsx("button",{className:"chat-panel-new-btn",onClick:x,title:"新对话",children:"+"}),e.jsx("button",{className:"chat-panel-new-btn",onClick:()=>ee(y=>!y),title:"已上传的文件","aria-label":"已上传的文件",children:e.jsx(Et,{size:14})})]})]}),e.jsx(un,{open:K,onClose:()=>ee(!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((y,R)=>{const B=R===t.length-1;return e.jsx(Cn,{msg:y,senderName:(r==null?void 0:r.name)??"Aalis",isLast:B,isGenerating:Le,onAbort:d,checkpoint:y.role==="assistant"?m(y.timestamp):void 0,rolledBack:y.role==="assistant"?(()=>{const F=m(y.timestamp);return F?U.has(F.turnId):!1})():!1,onRollback:h,onRollbackWithChat:p,toolCallsProgress:B&&y.role==="assistant"&&Le?w: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:w&&w.size>0?[...w.entries()].sort((y,R)=>y[0]-R[0]).map(([y,R])=>e.jsx(Cs,{name:R.name,charsAccumulated:R.charsAccumulated,startedAt:R.startedAt},`pending-${y}`)):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:"■ 停止生成"})]}),j&&!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:[v&&e.jsx("button",{className:"tool-limit-btn continue",onClick:v,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(js,{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&&g&&e.jsx(bn,{items:l,onClear:g,loading:s}),e.jsx(hn,{ref:C,loading:s,connected:n,canUpload:ke,canUploadImage:Ne,canUploadFile:we,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:y=>y.stopPropagation()}),e.jsx("button",{type:"button",className:"image-lightbox-close",onClick:()=>ue(null),"aria-label":"关闭",children:"×"})]})]})}const _n=a.lazy(()=>he(()=>import("./PluginConfigPage-BHKSlJpz.js"),__vite__mapDeps([2,1,3,4,5,6,7,8])).then(t=>({default:t.PluginConfigPage}))),$n=a.lazy(()=>he(()=>import("./MarketplacePage-B0lQ5lTU.js"),__vite__mapDeps([9,1,10,4,5,6,7,8])).then(t=>({default:t.MarketplacePage}))),Tn=a.lazy(()=>he(()=>import("./PlatformPage-BHvObjEh.js"),__vite__mapDeps([11,1,12,4,5,6,7,8])).then(t=>({default:t.PlatformPage}))),In=a.lazy(()=>he(()=>import("./AuthorityPage-BodQ2Fvh.js"),__vite__mapDeps([13,1,10,4,5,6,7,8])).then(t=>({default:t.AuthorityPage}))),Mn=a.lazy(()=>he(()=>import("./LogPage-C_Z3RA5T.js"),__vite__mapDeps([14,1])).then(t=>({default:t.LogPage}))),En=a.lazy(()=>he(()=>import("./SessionsPage-BM_ZInO9.js"),__vite__mapDeps([15,1,8,6,7,4,5])).then(t=>({default:t.SessionsPage}))),Ln=a.lazy(()=>he(()=>import("./FilesPage-Co_hAqZL.js"),__vite__mapDeps([16,1,4,5,6,7,8])).then(t=>({default:t.FilesPage}))),Rn=a.lazy(()=>he(()=>import("./DynamicPage-Btwp6tND.js"),__vite__mapDeps([17,1,3,18,19,12,10,8,6,7,4,5])).then(t=>({default:t.DynamicPage})));function Dn(){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,f]=a.useState([]),[x,l]=a.useState(null),[g,j]=a.useState(null),[v,w]=a.useState(null),[c,L]=a.useState([]),[I,C]=a.useState(null),S=lt(i),{messages:G,setMessages:P,loading:Z,setLoading:q,streamingRef:U}=S,Y=a.useRef({pending:[],raf:0}),[k,m]=a.useState(0),[h,p]=a.useState([]),[W,V]=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(W))}catch{}},[W]),a.useEffect(()=>{const o=document.querySelector(".app-layout");if(!o||typeof ResizeObserver>"u")return;const N=360,b=240,E=()=>{var te;const $=o.clientWidth,O=((te=document.querySelector(".nav-rail"))==null?void 0:te.getBoundingClientRect().width)??56,D=Math.max(b,$-O-N);V(J=>Math.min(Math.max(J,b),D))},T=new ResizeObserver(E);return T.observe(o),()=>T.disconnect()},[]);const[ae,_]=a.useState(!1),[M,A]=a.useState(new Map),[z,K]=a.useState(!1),[ee,xe]=a.useState(!1),[ue,ve]=a.useState(!1),[ye,re]=a.useState("正在重启…"),[Ne,we]=a.useState(!1),[ke,Pe]=a.useState(null),[Ae,be]=a.useState(null),Ce=(o,N)=>{const b=o?[...o]:[],E=b[b.length-1];return N.type==="text"&&E&&E.type==="text"?b[b.length-1]={type:"text",content:E.content+N.content}:N.type==="reasoning_text"&&E&&E.type==="reasoning_text"?b[b.length-1]={type:"reasoning_text",content:E.content+N.content}:b.push(N),b},Ee=o=>{let N="",b="";for(const E of o??[])E.type==="text"?N+=E.content:E.type==="reasoning_text"&&(b+=E.content);return{content:N,reasoning:b}},ze=a.useCallback((o,N,b,E,T)=>{Y.current.raf&&(cancelAnimationFrame(Y.current.raf),Y.current.raf=0),Y.current.pending=[],P($=>{const O=$[$.length-1],D=b&&b.length>0?b:N?[{type:"reasoning_text",content:N},{type:"text",content:o}]:[{type:"text",content:o}];return O&&O.role==="assistant"&&U.current?(U.current=!1,[...$.slice(0,-1),{...O,content:o,reasoningContent:N??O.reasoningContent,segments:D,attachments:E??O.attachments,modelInfo:T??O.modelInfo}]):(U.current=!1,[...$,{role:"assistant",content:o,reasoningContent:N,segments:D,attachments:E,modelInfo:T,timestamp:Date.now()}])}),q(!1)},[]),ie=a.useCallback(()=>{const o=Y.current;if(o.raf&&(cancelAnimationFrame(o.raf),o.raf=0),o.pending.length===0)return;const N=o.pending;o.pending=[],P(b=>{const E=b[b.length-1];if(E&&E.role==="assistant"&&U.current){let D=E.segments??[];for(const ne of N)D=Ce(D,{type:ne.kind==="content"?"text":"reasoning_text",content:ne.text});const{content:te,reasoning:J}=Ee(D);return[...b.slice(0,-1),{...E,content:te,reasoningContent:J||void 0,segments:D}]}U.current=!0;let T=[];for(const D of N)T=Ce(T,{type:D.kind==="content"?"text":"reasoning_text",content:D.text});const{content:$,reasoning:O}=Ee(T);return[...b,{role:"assistant",content:$,reasoningContent:O||void 0,segments:T,timestamp:Date.now()}]})},[P,U]),Le=a.useCallback((o,N,b,E)=>{if(b){ie(),q(!1),_(!!E),A(new Map);return}(o||N)&&A($=>$.size===0?$:new Map);const T=Y.current;N&&T.pending.push({kind:"reasoning",text:N}),o&&T.pending.push({kind:"content",text:o}),!T.raf&&(T.raf=requestAnimationFrame(ie))},[ie,q]),y=a.useCallback(o=>{f(N=>N.length>0&&N[N.length-1].seq>=o.seq&&N.some(b=>b.seq===o.seq)?N:[...N,o])},[]),R=a.useCallback(async()=>{const o=u[0];if(!o)return 0;try{const N=await Q(`/api/logs/range?before=${o.seq}&limit=200`);return!N||N.length===0?0:(f(b=>{const E=new Set(b.map($=>$.seq));return[...N.filter($=>!E.has($.seq)),...b]}),N.length)}catch{return 0}},[u]),B=a.useCallback((o,N,b,E)=>{ie(),b==="start"&&A(T=>T.size===0?T:new Map),P(T=>{const $=T[T.length-1];if(b==="start"){const O=Date.now();if($&&$.role==="assistant"){const D=Ce($.segments,{type:"tool_call",name:o,args:N,startTime:O});return[...T.slice(0,-1),{...$,segments:D}]}return U.current=!0,[...T,{role:"assistant",content:"",segments:[{type:"tool_call",name:o,args:N,startTime:O}],timestamp:Date.now()}]}if($&&$.role==="assistant"&&$.segments){const O=Date.now(),D=[...$.segments];for(let te=D.length-1;te>=0;te--){const J=D[te];if(J.type==="tool_call"&&J.name===o&&J.result==null)return D[te]={...J,result:E,endTime:O},[...T.slice(0,-1),{...$,segments:D}]}}return T})},[ie]),F=a.useCallback(()=>{Q("/api/plugins").then(o=>L(o.plugins??[])).catch(()=>{})},[]),me=a.useCallback(()=>{Q("/api/config").then(w).catch(()=>{})},[]),se=a.useCallback(()=>{Q("/api/services").then(o=>C(o.services??null)).catch(()=>{})},[]),X=a.useCallback(()=>{Q("/api/pages").then(o=>{d(o),r(new Set(o.map(N=>N.key)))}).catch(()=>{})},[]),le=a.useCallback(()=>{F(),se(),X(),S.refresh(),Q("/api/status").then(l).catch(()=>{})},[F,se,X,S.refresh]),Oe=a.useCallback(()=>{K(!0),xe(!1),re("正在重启…")},[]),ge=a.useCallback(()=>{ve(!0),re("正在切换前端,即将刷新…")},[]),Ss=a.useCallback(()=>{S.refresh(),m(o=>o+1)},[S.refresh]),_s=a.useCallback(o=>{p(o)},[]),$s=a.useCallback((o,N,b,E,T)=>{P($=>{let O=b&&b.length>0?b:[];O.length===0&&(N&&O.push({type:"reasoning_text",content:N}),o&&O.push({type:"text",content:o}));const D=$[$.length-1];return D&&D.role==="assistant"?[...$.slice(0,-1),{...D,content:o,reasoningContent:N||D.reasoningContent,segments:O}]:[...$,{role:"assistant",content:o,reasoningContent:N||void 0,segments:O,timestamp:Date.now()}]}),E||(U.current=!0,q(!0)),T&&T.length>0?A(new Map(T.map($=>[$.index,{name:$.name,charsAccumulated:$.charsAccumulated,startedAt:$.startedAt}]))):A($=>$.size===0?$:new Map)},[]),Ts=a.useCallback(o=>{A(N=>{const b=new Map(N),E=b.get(o.index);return b.set(o.index,{name:o.name,charsAccumulated:o.charsAccumulated,startedAt:(E==null?void 0:E.startedAt)??Date.now()}),b})},[]),Is=a.useCallback(()=>{A(o=>o.size===0?o:new Map)},[]),Ms=a.useCallback(o=>{we(!0),P(N=>[...N,{role:"assistant",content:o,segments:[{type:"text",content:o}],timestamp:Date.now()}])},[]),Es=a.useCallback(o=>{Pe(o)},[]),Ls=a.useCallback((o,N)=>{o===oe()&&(be(N),N==="done"?(P(b=>[...b,{role:"system",content:"对话已压缩",timestamp:Date.now()}]),setTimeout(()=>be(null),1500)):N==="error"&&setTimeout(()=>be(null),3e3))},[]),{send:Se,sendRaw:Re,connected:fe}=at({onMessage:ze,onStream:Le,onLog:y,onToolCall:B,onStateChanged:le,onRestarting:Oe,onReload:ge,onSessionsChanged:Ss,onTodoUpdated:_s,onStreamResume:$s,onConfirm:Ms,onTokenUsage:Es,onCompressing:Ls,onHistoryChanged:S.handleHistoryChanged,onToolCallProgress:Ts,onToolCallProgressClear:Is}),Rs=a.useCallback(()=>{Re({type:"compress",sessionId:oe()})},[Re]);a.useEffect(()=>{z&&!fe&&(xe(!0),re("等待服务器重启…"))},[z,fe]),a.useEffect(()=>{if(z&&ee&&fe){re("服务器已就绪,即将刷新…");const o=setTimeout(()=>window.location.reload(),800);return()=>clearTimeout(o)}},[z,ee,fe]),a.useEffect(()=>{if(ue){const o=setTimeout(()=>window.location.reload(),1500);return()=>clearTimeout(o)}},[ue]),a.useEffect(()=>{Q("/api/status").then(l).catch(()=>{}),Q("/api/auth/me").then(j).catch(()=>{}),me(),F(),se(),X(),S.refresh(),Q("/api/logs/tail?limit=200").then(f).catch(()=>{})},[F,me,se,X,S.refresh]),a.useEffect(()=>{const o=S.activeSessionId;if(!o||o==="__new_chat__"){p([]);return}de("@aalis/plugin-todo-list","getTodos",{sessionId:o}).then(N=>p(N??[])).catch(()=>p([]))},[S.activeSessionId]),a.useEffect(()=>{const o=setInterval(()=>{Q("/api/status").then(l).catch(()=>{}),F(),se(),X(),S.refresh()},3e4);return()=>clearInterval(o)},[F,se,X,S.refresh]);const Fe=a.useCallback(()=>{Re({type:"abort",sessionId:oe()}),q(!1),_(!1),U.current=!1},[Re]),Ds=a.useCallback(()=>{P(o=>[...o,{role:"user",content:"[请继续执行未完成的工具调用]",timestamp:Date.now()}]),Se("[请继续执行未完成的工具调用]"),_(!1),q(!0)},[Se]),Ps=a.useCallback(()=>{const o=S.activeSessionId;!o||o==="__new_chat__"||(de("@aalis/plugin-todo-list","clearTodos",{sessionId:o}).catch(()=>{}),p([]))},[S.activeSessionId]),As=a.useCallback(async(o,N,b,E)=>{const T=o.trim();if(Ne){if(!T)return;we(!1),P(J=>[...J,{role:"user",content:T,timestamp:Date.now()}]),Se(T);return}if(Z&&Fe(),!T&&b.length===0&&N.length===0)return;await S.ensureSession();const $=b.length>0?[...b]:void 0,O=[];let D=0,te=0;if(E.length>0){for(const J of E)if(J==="image"&&D<b.length)O.push({kind:"image",data:b[D++]});else if(J==="file"&&te<N.length){const ne=N[te++],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(;D<b.length;)O.push({kind:"image",data:b[D++]});for(;te<N.length;){const J=N[te++],ne=J.mimeType??"",pe=ne.startsWith("audio/")?"audio":ne.startsWith("video/")?"video":"file";O.push({kind:pe,data:J.data,mimeType:ne,name:J.name})}P(J=>[...J,{role:"user",content:T,images:$,fileNames:N.map(ne=>ne.name),timestamp:Date.now()}]),_(!1),q(!0),Se(T,O.length>0?O:void 0)},[Ne,Z,Se,Fe,S]),We={dashboard:e.jsx(Xs,{}),marketplace:e.jsx(Zs,{}),"plugin-config":e.jsx(Qs,{}),platforms:e.jsx(st,{}),authority:e.jsx(tt,{}),files:e.jsx(nt,{}),logs:e.jsx(et,{})},zs=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"})]}),Os=(o,N)=>We[o]?We[o]:N&&N.trimStart().startsWith("<svg")?e.jsx("span",{className:"nav-item-svg",dangerouslySetInnerHTML:{__html:N}}):zs,ts=a.useMemo(()=>n?i.filter(o=>n.has(o.key)).map(o=>({key:o.key,label:o.label,pluginDisplayName:o.pluginDisplayName,icon:Os(o.key,o.icon),order:o.order??99})).sort((o,N)=>o.order-N.order):Object.entries(We).map(([o,N],b)=>({key:o,label:o,icon:N,order:(b+1)*10})),[n,i]),Fs=(o,N)=>{switch(o){case"dashboard":return e.jsx(Xt,{status:x,connected:fe,plugins:c,servicesData:I,onRefreshServices:se});case"marketplace":return e.jsx($n,{plugins:c,onRefresh:F});case"plugin-config":return e.jsx(_n,{plugins:c,config:v,onRefresh:F,onConfigSaved:me,onRestart:()=>{K(!0),xe(!1),re("正在重启…")}});case"platforms":return e.jsx(Tn,{});case"authority":return e.jsx(In,{});case"logs":return e.jsx(Mn,{logs:u,onLoadOlder:R});case"files":return e.jsx(Ln,{});case"sessions":return e.jsx(En,{pluginName:N,activeSessionId:S.activeSessionId,onSwitchSession:b=>{S.switchSession(b)},onStartNewChat:()=>S.startNewChat(),refreshSignal:k});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}),g&&e.jsxs("span",{className:"content-user",title:`${g.identity.platform}:${g.identity.userId}`,children:[g.identity.userId,g.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(Rn,{page:qe}),!qe&&(ce==null?void 0:ce.renderer)&&(Fs(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 N=o.clientX,b=W,E=((pe=document.querySelector(".app-layout"))==null?void 0:pe.clientWidth)??window.innerWidth,T=document.querySelector(".nav-rail"),$=(T==null?void 0:T.getBoundingClientRect().width)??56,O=360,D=280,te=Math.max(D,E-$-O);document.body.classList.add("is-dragging-chat");const J=Be=>{const Ws=b-(Be.clientX-N);V(Math.max(D,Math.min(te,Ws)))},ne=()=>{document.removeEventListener("mousemove",J),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",J),document.addEventListener("mouseup",ne)}}),e.jsx("div",{className:"chat-column",style:{width:W},children:e.jsx(Sn,{messages:G,loading:Z,connected:fe,status:x,onSend:As,onAbort:Fe,width:W,sessionTitle:S.isNewChat?"新对话":S.activeSessionTitle,onNewSession:S.pluginName?()=>S.startNewChat():void 0,todoItems:h,onClearTodos:Ps,toolLimitReached:ae,onContinueTools:Ds,toolCallsProgress:M,tokenUsage:ke,compressingStatus:Ae,onCompress:Rs})}),(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})]})})]})}qs.createRoot(document.getElementById("root")).render(e.jsx(Dn,{}));export{os as B,Ct as C,_t as D,Et as F,Me as M,Ie as R,qt as S,De as T,ss as W,ys as X,he as _,Q as a,it as b,H as c,Te as d,$e as e,gs as f,Ft as g,It as h,Jt as i,de as p};
207
+ `)),Y(ge=>new Set([...ge,y.turnId]))}catch(X){window.alert(`回滚失败:${X.message}`)}},[]),W=a.useRef(null),V=a.useRef(!1),[ae,_]=a.useState(!1),M=a.useRef(0),[A,z]=a.useState(!1),[K,ee]=a.useState(!1),[xe,ue]=a.useState(null),ve=a.useRef(0),ye=a.useRef(0);a.useEffect(()=>{const y=B=>{const F=B.detail;typeof F=="string"&&ue(F)},R=B=>{B.key==="Escape"&&ue(null)};return window.addEventListener(es,y),window.addEventListener("keydown",R),()=>{window.removeEventListener(es,y),window.removeEventListener("keydown",R)}},[]);const re=r==null?void 0:r.uploadCapabilities,Ne=(re==null?void 0:re.image)??!1,we=(re==null?void 0:re.file)??!1,ke=Ne||we,Pe=wn(re);a.useEffect(()=>{L==="start"?(ve.current=Date.now(),ye.current=0):(L==="done"||L==="error")&&(ye.current=Date.now())},[L]),a.useEffect(()=>{const y=G.current;if(!y)return;const R=()=>{const{scrollTop:B,scrollHeight:F,clientHeight:me}=y;P.current=F-B-me>200,V.current=!0,W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{V.current=!1},300)};return y.addEventListener("scroll",R,{passive:!0}),()=>y.removeEventListener("scroll",R)},[]),a.useEffect(()=>{const y=G.current;if(!y)return;const R=new ResizeObserver(()=>{var B;!P.current&&!V.current&&((B=S.current)==null||B.scrollIntoView({behavior:s?"instant":"smooth"}))});return R.observe(y),()=>R.disconnect()},[t.length]),a.useEffect(()=>{var y;!P.current&&!V.current&&((y=S.current)==null||y.scrollIntoView({behavior:"smooth"}))},[t]);const Ae=a.useCallback((y,R,B,F)=>i(y,R,B,F),[i]),be=y=>{y.preventDefault(),y.stopPropagation(),M.current++,ke&&y.dataTransfer.types.includes("Files")&&_(!0)},Ce=y=>{y.preventDefault(),y.stopPropagation(),M.current--,M.current<=0&&(M.current=0,_(!1))},Ee=y=>{y.preventDefault(),y.stopPropagation()},ze=async y=>{var R;y.preventDefault(),y.stopPropagation(),M.current=0,_(!1),!(!ke||!y.dataTransfer.files.length)&&await((R=C.current)==null?void 0:R.addFiles(y.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(vs,{size:16})," 松开以上传文件"]})}),e.jsxs("div",{className:"chat-panel-header",children:[e.jsxs("span",{className:"chat-panel-title",children:[e.jsx(is,{size:16})," ",f||(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(Ns,{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()})]})]}),I&&e.jsx("button",{className:"token-panel-compress-btn",onClick:y=>{y.stopPropagation(),I()},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(ps,{size:12})," 压缩对话"]})})]}):e.jsx("div",{className:"token-panel-empty",children:"发送消息后将显示 Token 用量统计"})]})]}),x&&e.jsx("button",{className:"chat-panel-new-btn",onClick:x,title:"新对话",children:"+"}),e.jsx("button",{className:"chat-panel-new-btn",onClick:()=>ee(y=>!y),title:"已上传的文件","aria-label":"已上传的文件",children:e.jsx(Et,{size:14})})]})]}),e.jsx(un,{open:K,onClose:()=>ee(!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((y,R)=>{const B=R===t.length-1;return e.jsx(Cn,{msg:y,senderName:(r==null?void 0:r.name)??"Aalis",isLast:B,isGenerating:Le,onAbort:d,checkpoint:y.role==="assistant"?m(y.timestamp):void 0,rolledBack:y.role==="assistant"?(()=>{const F=m(y.timestamp);return F?U.has(F.turnId):!1})():!1,onRollback:h,onRollbackWithChat:p,toolCallsProgress:B&&y.role==="assistant"&&Le?w: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:w&&w.size>0?[...w.entries()].sort((y,R)=>y[0]-R[0]).map(([y,R])=>e.jsx(Cs,{name:R.name,charsAccumulated:R.charsAccumulated,startedAt:R.startedAt},`pending-${y}`)):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:"■ 停止生成"})]}),j&&!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:[v&&e.jsx("button",{className:"tool-limit-btn continue",onClick:v,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(js,{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&&g&&e.jsx(bn,{items:l,onClear:g,loading:s}),e.jsx(hn,{ref:C,loading:s,connected:n,canUpload:ke,canUploadImage:Ne,canUploadFile:we,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:y=>y.stopPropagation()}),e.jsx("button",{type:"button",className:"image-lightbox-close",onClick:()=>ue(null),"aria-label":"关闭",children:"×"})]})]})}const _n=a.lazy(()=>he(()=>import("./PluginConfigPage-C3ik4uHI.js"),__vite__mapDeps([2,1,3,4,5,6,7,8])).then(t=>({default:t.PluginConfigPage}))),$n=a.lazy(()=>he(()=>import("./MarketplacePage-9fRwgBeV.js"),__vite__mapDeps([9,1,10,4,5,6,7,8])).then(t=>({default:t.MarketplacePage}))),Tn=a.lazy(()=>he(()=>import("./PlatformPage-Cj0TiG1T.js"),__vite__mapDeps([11,1,12,4,5,6,7,8])).then(t=>({default:t.PlatformPage}))),In=a.lazy(()=>he(()=>import("./AuthorityPage-C21ovg99.js"),__vite__mapDeps([13,1,10,4,5,6,7,8])).then(t=>({default:t.AuthorityPage}))),Mn=a.lazy(()=>he(()=>import("./LogPage-C_Z3RA5T.js"),__vite__mapDeps([14,1])).then(t=>({default:t.LogPage}))),En=a.lazy(()=>he(()=>import("./SessionsPage-MeiGuGtS.js"),__vite__mapDeps([15,1,8,6,7,4,5])).then(t=>({default:t.SessionsPage}))),Ln=a.lazy(()=>he(()=>import("./FilesPage-BGZJtahO.js"),__vite__mapDeps([16,1,4,5,6,7,8])).then(t=>({default:t.FilesPage}))),Rn=a.lazy(()=>he(()=>import("./DynamicPage-BjVDU5B_.js"),__vite__mapDeps([17,1,3,18,19,12,10,8,6,7,4,5])).then(t=>({default:t.DynamicPage})));function Dn(){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,f]=a.useState([]),[x,l]=a.useState(null),[g,j]=a.useState(null),[v,w]=a.useState(null),[c,L]=a.useState([]),[I,C]=a.useState(null),S=lt(i),{messages:G,setMessages:P,loading:Z,setLoading:q,streamingRef:U}=S,Y=a.useRef({pending:[],raf:0}),[k,m]=a.useState(0),[h,p]=a.useState([]),[W,V]=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(W))}catch{}},[W]),a.useEffect(()=>{const o=document.querySelector(".app-layout");if(!o||typeof ResizeObserver>"u")return;const N=360,b=240,E=()=>{var te;const $=o.clientWidth,O=((te=document.querySelector(".nav-rail"))==null?void 0:te.getBoundingClientRect().width)??56,D=Math.max(b,$-O-N);V(J=>Math.min(Math.max(J,b),D))},T=new ResizeObserver(E);return T.observe(o),()=>T.disconnect()},[]);const[ae,_]=a.useState(!1),[M,A]=a.useState(new Map),[z,K]=a.useState(!1),[ee,xe]=a.useState(!1),[ue,ve]=a.useState(!1),[ye,re]=a.useState("正在重启…"),[Ne,we]=a.useState(!1),[ke,Pe]=a.useState(null),[Ae,be]=a.useState(null),Ce=(o,N)=>{const b=o?[...o]:[],E=b[b.length-1];return N.type==="text"&&E&&E.type==="text"?b[b.length-1]={type:"text",content:E.content+N.content}:N.type==="reasoning_text"&&E&&E.type==="reasoning_text"?b[b.length-1]={type:"reasoning_text",content:E.content+N.content}:b.push(N),b},Ee=o=>{let N="",b="";for(const E of o??[])E.type==="text"?N+=E.content:E.type==="reasoning_text"&&(b+=E.content);return{content:N,reasoning:b}},ze=a.useCallback((o,N,b,E,T)=>{Y.current.raf&&(cancelAnimationFrame(Y.current.raf),Y.current.raf=0),Y.current.pending=[],P($=>{const O=$[$.length-1],D=b&&b.length>0?b:N?[{type:"reasoning_text",content:N},{type:"text",content:o}]:[{type:"text",content:o}];return O&&O.role==="assistant"&&U.current?(U.current=!1,[...$.slice(0,-1),{...O,content:o,reasoningContent:N??O.reasoningContent,segments:D,attachments:E??O.attachments,modelInfo:T??O.modelInfo}]):(U.current=!1,[...$,{role:"assistant",content:o,reasoningContent:N,segments:D,attachments:E,modelInfo:T,timestamp:Date.now()}])}),q(!1)},[]),ie=a.useCallback(()=>{const o=Y.current;if(o.raf&&(cancelAnimationFrame(o.raf),o.raf=0),o.pending.length===0)return;const N=o.pending;o.pending=[],P(b=>{const E=b[b.length-1];if(E&&E.role==="assistant"&&U.current){let D=E.segments??[];for(const ne of N)D=Ce(D,{type:ne.kind==="content"?"text":"reasoning_text",content:ne.text});const{content:te,reasoning:J}=Ee(D);return[...b.slice(0,-1),{...E,content:te,reasoningContent:J||void 0,segments:D}]}U.current=!0;let T=[];for(const D of N)T=Ce(T,{type:D.kind==="content"?"text":"reasoning_text",content:D.text});const{content:$,reasoning:O}=Ee(T);return[...b,{role:"assistant",content:$,reasoningContent:O||void 0,segments:T,timestamp:Date.now()}]})},[P,U]),Le=a.useCallback((o,N,b,E)=>{if(b){ie(),q(!1),_(!!E),A(new Map);return}(o||N)&&A($=>$.size===0?$:new Map);const T=Y.current;N&&T.pending.push({kind:"reasoning",text:N}),o&&T.pending.push({kind:"content",text:o}),!T.raf&&(T.raf=requestAnimationFrame(ie))},[ie,q]),y=a.useCallback(o=>{f(N=>N.length>0&&N[N.length-1].seq>=o.seq&&N.some(b=>b.seq===o.seq)?N:[...N,o])},[]),R=a.useCallback(async()=>{const o=u[0];if(!o)return 0;try{const N=await Q(`/api/logs/range?before=${o.seq}&limit=200`);return!N||N.length===0?0:(f(b=>{const E=new Set(b.map($=>$.seq));return[...N.filter($=>!E.has($.seq)),...b]}),N.length)}catch{return 0}},[u]),B=a.useCallback((o,N,b,E)=>{ie(),b==="start"&&A(T=>T.size===0?T:new Map),P(T=>{const $=T[T.length-1];if(b==="start"){const O=Date.now();if($&&$.role==="assistant"){const D=Ce($.segments,{type:"tool_call",name:o,args:N,startTime:O});return[...T.slice(0,-1),{...$,segments:D}]}return U.current=!0,[...T,{role:"assistant",content:"",segments:[{type:"tool_call",name:o,args:N,startTime:O}],timestamp:Date.now()}]}if($&&$.role==="assistant"&&$.segments){const O=Date.now(),D=[...$.segments];for(let te=D.length-1;te>=0;te--){const J=D[te];if(J.type==="tool_call"&&J.name===o&&J.result==null)return D[te]={...J,result:E,endTime:O},[...T.slice(0,-1),{...$,segments:D}]}}return T})},[ie]),F=a.useCallback(()=>{Q("/api/plugins").then(o=>L(o.plugins??[])).catch(()=>{})},[]),me=a.useCallback(()=>{Q("/api/config").then(w).catch(()=>{})},[]),se=a.useCallback(()=>{Q("/api/services").then(o=>C(o.services??null)).catch(()=>{})},[]),X=a.useCallback(()=>{Q("/api/pages").then(o=>{d(o),r(new Set(o.map(N=>N.key)))}).catch(()=>{})},[]),le=a.useCallback(()=>{F(),se(),X(),S.refresh(),Q("/api/status").then(l).catch(()=>{})},[F,se,X,S.refresh]),Oe=a.useCallback(()=>{K(!0),xe(!1),re("正在重启…")},[]),ge=a.useCallback(()=>{ve(!0),re("正在切换前端,即将刷新…")},[]),Ss=a.useCallback(()=>{S.refresh(),m(o=>o+1)},[S.refresh]),_s=a.useCallback(o=>{p(o)},[]),$s=a.useCallback((o,N,b,E,T)=>{P($=>{let O=b&&b.length>0?b:[];O.length===0&&(N&&O.push({type:"reasoning_text",content:N}),o&&O.push({type:"text",content:o}));const D=$[$.length-1];return D&&D.role==="assistant"?[...$.slice(0,-1),{...D,content:o,reasoningContent:N||D.reasoningContent,segments:O}]:[...$,{role:"assistant",content:o,reasoningContent:N||void 0,segments:O,timestamp:Date.now()}]}),E||(U.current=!0,q(!0)),T&&T.length>0?A(new Map(T.map($=>[$.index,{name:$.name,charsAccumulated:$.charsAccumulated,startedAt:$.startedAt}]))):A($=>$.size===0?$:new Map)},[]),Ts=a.useCallback(o=>{A(N=>{const b=new Map(N),E=b.get(o.index);return b.set(o.index,{name:o.name,charsAccumulated:o.charsAccumulated,startedAt:(E==null?void 0:E.startedAt)??Date.now()}),b})},[]),Is=a.useCallback(()=>{A(o=>o.size===0?o:new Map)},[]),Ms=a.useCallback(o=>{we(!0),P(N=>[...N,{role:"assistant",content:o,segments:[{type:"text",content:o}],timestamp:Date.now()}])},[]),Es=a.useCallback(o=>{Pe(o)},[]),Ls=a.useCallback((o,N)=>{o===oe()&&(be(N),N==="done"?(P(b=>[...b,{role:"system",content:"对话已压缩",timestamp:Date.now()}]),setTimeout(()=>be(null),1500)):N==="error"&&setTimeout(()=>be(null),3e3))},[]),{send:Se,sendRaw:Re,connected:fe}=at({onMessage:ze,onStream:Le,onLog:y,onToolCall:B,onStateChanged:le,onRestarting:Oe,onReload:ge,onSessionsChanged:Ss,onTodoUpdated:_s,onStreamResume:$s,onConfirm:Ms,onTokenUsage:Es,onCompressing:Ls,onHistoryChanged:S.handleHistoryChanged,onToolCallProgress:Ts,onToolCallProgressClear:Is}),Rs=a.useCallback(()=>{Re({type:"compress",sessionId:oe()})},[Re]);a.useEffect(()=>{z&&!fe&&(xe(!0),re("等待服务器重启…"))},[z,fe]),a.useEffect(()=>{if(z&&ee&&fe){re("服务器已就绪,即将刷新…");const o=setTimeout(()=>window.location.reload(),800);return()=>clearTimeout(o)}},[z,ee,fe]),a.useEffect(()=>{if(ue){const o=setTimeout(()=>window.location.reload(),1500);return()=>clearTimeout(o)}},[ue]),a.useEffect(()=>{Q("/api/status").then(l).catch(()=>{}),Q("/api/auth/me").then(j).catch(()=>{}),me(),F(),se(),X(),S.refresh(),Q("/api/logs/tail?limit=200").then(f).catch(()=>{})},[F,me,se,X,S.refresh]),a.useEffect(()=>{const o=S.activeSessionId;if(!o||o==="__new_chat__"){p([]);return}de("@aalis/plugin-todo-list","getTodos",{sessionId:o}).then(N=>p(N??[])).catch(()=>p([]))},[S.activeSessionId]),a.useEffect(()=>{const o=setInterval(()=>{Q("/api/status").then(l).catch(()=>{}),F(),se(),X(),S.refresh()},3e4);return()=>clearInterval(o)},[F,se,X,S.refresh]);const Fe=a.useCallback(()=>{Re({type:"abort",sessionId:oe()}),q(!1),_(!1),U.current=!1},[Re]),Ds=a.useCallback(()=>{P(o=>[...o,{role:"user",content:"[请继续执行未完成的工具调用]",timestamp:Date.now()}]),Se("[请继续执行未完成的工具调用]"),_(!1),q(!0)},[Se]),Ps=a.useCallback(()=>{const o=S.activeSessionId;!o||o==="__new_chat__"||(de("@aalis/plugin-todo-list","clearTodos",{sessionId:o}).catch(()=>{}),p([]))},[S.activeSessionId]),As=a.useCallback(async(o,N,b,E)=>{const T=o.trim();if(Ne){if(!T)return;we(!1),P(J=>[...J,{role:"user",content:T,timestamp:Date.now()}]),Se(T);return}if(Z&&Fe(),!T&&b.length===0&&N.length===0)return;await S.ensureSession();const $=b.length>0?[...b]:void 0,O=[];let D=0,te=0;if(E.length>0){for(const J of E)if(J==="image"&&D<b.length)O.push({kind:"image",data:b[D++]});else if(J==="file"&&te<N.length){const ne=N[te++],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(;D<b.length;)O.push({kind:"image",data:b[D++]});for(;te<N.length;){const J=N[te++],ne=J.mimeType??"",pe=ne.startsWith("audio/")?"audio":ne.startsWith("video/")?"video":"file";O.push({kind:pe,data:J.data,mimeType:ne,name:J.name})}P(J=>[...J,{role:"user",content:T,images:$,fileNames:N.map(ne=>ne.name),timestamp:Date.now()}]),_(!1),q(!0),Se(T,O.length>0?O:void 0)},[Ne,Z,Se,Fe,S]),We={dashboard:e.jsx(Xs,{}),marketplace:e.jsx(Zs,{}),"plugin-config":e.jsx(Qs,{}),platforms:e.jsx(st,{}),authority:e.jsx(tt,{}),files:e.jsx(nt,{}),logs:e.jsx(et,{})},zs=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"})]}),Os=(o,N)=>We[o]?We[o]:N&&N.trimStart().startsWith("<svg")?e.jsx("span",{className:"nav-item-svg",dangerouslySetInnerHTML:{__html:N}}):zs,ts=a.useMemo(()=>n?i.filter(o=>n.has(o.key)).map(o=>({key:o.key,label:o.label,pluginDisplayName:o.pluginDisplayName,icon:Os(o.key,o.icon),order:o.order??99})).sort((o,N)=>o.order-N.order):Object.entries(We).map(([o,N],b)=>({key:o,label:o,icon:N,order:(b+1)*10})),[n,i]),Fs=(o,N)=>{switch(o){case"dashboard":return e.jsx(Xt,{status:x,connected:fe,plugins:c,servicesData:I,onRefreshServices:se});case"marketplace":return e.jsx($n,{plugins:c,onRefresh:F});case"plugin-config":return e.jsx(_n,{plugins:c,config:v,onRefresh:F,onConfigSaved:me,onRestart:()=>{K(!0),xe(!1),re("正在重启…")}});case"platforms":return e.jsx(Tn,{});case"authority":return e.jsx(In,{});case"logs":return e.jsx(Mn,{logs:u,onLoadOlder:R});case"files":return e.jsx(Ln,{});case"sessions":return e.jsx(En,{pluginName:N,activeSessionId:S.activeSessionId,onSwitchSession:b=>{S.switchSession(b)},onStartNewChat:()=>S.startNewChat(),refreshSignal:k});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}),g&&e.jsxs("span",{className:"content-user",title:`${g.identity.platform}:${g.identity.userId}`,children:[g.identity.userId,g.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(Rn,{page:qe}),!qe&&(ce==null?void 0:ce.renderer)&&(Fs(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 N=o.clientX,b=W,E=((pe=document.querySelector(".app-layout"))==null?void 0:pe.clientWidth)??window.innerWidth,T=document.querySelector(".nav-rail"),$=(T==null?void 0:T.getBoundingClientRect().width)??56,O=360,D=280,te=Math.max(D,E-$-O);document.body.classList.add("is-dragging-chat");const J=Be=>{const Ws=b-(Be.clientX-N);V(Math.max(D,Math.min(te,Ws)))},ne=()=>{document.removeEventListener("mousemove",J),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",J),document.addEventListener("mouseup",ne)}}),e.jsx("div",{className:"chat-column",style:{width:W},children:e.jsx(Sn,{messages:G,loading:Z,connected:fe,status:x,onSend:As,onAbort:Fe,width:W,sessionTitle:S.isNewChat?"新对话":S.activeSessionTitle,onNewSession:S.pluginName?()=>S.startNewChat():void 0,todoItems:h,onClearTodos:Ps,toolLimitReached:ae,onContinueTools:Ds,toolCallsProgress:M,tokenUsage:ke,compressingStatus:Ae,onCompress:Rs})}),(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})]})})]})}qs.createRoot(document.getElementById("root")).render(e.jsx(Dn,{}));export{os as B,Ct as C,_t as D,Et as F,Me as M,Ie as R,qt as S,De as T,ss as W,ys as X,he as _,Q as a,it as b,H as c,Te as d,$e as e,gs as f,Ft as g,It as h,Jt as i,de as p};
@@ -1,2 +1,2 @@
1
- import{_ as a,l as o,I as i,e as n}from"./mermaid.core-CWJzgNYH.js";import{p}from"./wardley-L42UT6IY-DNaqJg7q.js";import"./index-BMsEuqd2.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var g={parse:a(async r=>{const e=await p("info",r);o.debug(e)},"parse")},m={version:"11.15.0"},v=a(()=>m.version,"getVersion"),d={getVersion:v},c=a((r,e,s)=>{o.debug(`rendering info diagram
1
+ import{_ as a,l as o,I as i,e as n}from"./mermaid.core-C4yLb7RL.js";import{p}from"./wardley-L42UT6IY-DYWHt89G.js";import"./index-BtvzdAkg.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var g={parse:a(async r=>{const e=await p("info",r);o.debug(e)},"parse")},m={version:"11.15.0"},v=a(()=>m.version,"getVersion"),d={getVersion:v},c=a((r,e,s)=>{o.debug(`rendering info diagram
2
2
  `+r);const t=i(e);n(t,100,400,!0),t.append("g").append("text").attr("x",100).attr("y",40).attr("class","version").attr("font-size",32).style("text-anchor","middle").text(`v${s}`)},"draw"),l={draw:c},z={parser:g,db:d,renderer:l};export{z as diagram};
@@ -1,4 +1,4 @@
1
- import{_ as o,c as ot,N as ut,I as dt,ap as yt,z as pt,k as ft,p as it,a as gt,b as kt,g as mt,s as wt,q as _t,e as bt}from"./mermaid.core-CWJzgNYH.js";import"./index-BMsEuqd2.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var tt=(function(){var e=o(function(M,t,s,i){for(s=s||{},i=M.length;i--;s[M[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],p=[1,20],d=[1,18],m=[1,19],c=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],B={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,u,f,n,v){var w=n.length-1;switch(f){case 6:case 7:return u;case 15:u.addNode(n[w-1].length,n[w].trim());break;case 16:u.addNode(0,n[w].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:p,7:d,10:17,11:m},e(c,[2,18],{14:[1,21]}),e(c,[2,16]),e(c,[2,17]),{6:p,7:d,10:22,11:m},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(c,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],u=[],f=[null],n=[],v=this.table,w="",I=0,S=0,L=2,E=1,R=n.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(C.yy[z]=this.yy[z]);b.setInput(t,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var T=b.yylloc;n.push(T);var D=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function F(N){i.length=i.length-2*N,f.length=f.length-N,n.length=n.length-N}o(F,"popStack");function j(){var N;return N=u.pop()||b.lex()||E,typeof N!="number"&&(N instanceof Array&&(u=N,N=u.pop()),N=s.symbols_[N]||N),N}o(j,"lex");for(var A,W,P,K,H={},X,V,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?P=this.defaultActions[W]:((A===null||typeof A>"u")&&(A=j()),P=v[W]&&v[W][A]),typeof P>"u"||!P.length||!P[0]){var Q="";Y=[];for(X in v[W])this.terminals_[X]&&X>L&&Y.push("'"+this.terminals_[X]+"'");b.showPosition?Q="Parse error on line "+(I+1)+`:
1
+ import{_ as o,c as ot,N as ut,I as dt,ap as yt,z as pt,k as ft,p as it,a as gt,b as kt,g as mt,s as wt,q as _t,e as bt}from"./mermaid.core-C4yLb7RL.js";import"./index-BtvzdAkg.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var tt=(function(){var e=o(function(M,t,s,i){for(s=s||{},i=M.length;i--;s[M[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],p=[1,20],d=[1,18],m=[1,19],c=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],B={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,u,f,n,v){var w=n.length-1;switch(f){case 6:case 7:return u;case 15:u.addNode(n[w-1].length,n[w].trim());break;case 16:u.addNode(0,n[w].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:p,7:d,10:17,11:m},e(c,[2,18],{14:[1,21]}),e(c,[2,16]),e(c,[2,17]),{6:p,7:d,10:22,11:m},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(c,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],u=[],f=[null],n=[],v=this.table,w="",I=0,S=0,L=2,E=1,R=n.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(C.yy[z]=this.yy[z]);b.setInput(t,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var T=b.yylloc;n.push(T);var D=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function F(N){i.length=i.length-2*N,f.length=f.length-N,n.length=n.length-N}o(F,"popStack");function j(){var N;return N=u.pop()||b.lex()||E,typeof N!="number"&&(N instanceof Array&&(u=N,N=u.pop()),N=s.symbols_[N]||N),N}o(j,"lex");for(var A,W,P,K,H={},X,V,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?P=this.defaultActions[W]:((A===null||typeof A>"u")&&(A=j()),P=v[W]&&v[W][A]),typeof P>"u"||!P.length||!P[0]){var Q="";Y=[];for(X in v[W])this.terminals_[X]&&X>L&&Y.push("'"+this.terminals_[X]+"'");b.showPosition?Q="Parse error on line "+(I+1)+`:
2
2
  `+b.showPosition()+`
3
3
  Expecting `+Y.join(", ")+", got '"+(this.terminals_[A]||A)+"'":Q="Parse error on line "+(I+1)+": Unexpected "+(A==E?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(Q,{text:b.match,token:this.terminals_[A]||A,line:b.yylineno,loc:T,expected:Y})}if(P[0]instanceof Array&&P.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+A);switch(P[0]){case 1:i.push(A),f.push(b.yytext),n.push(b.yylloc),i.push(P[1]),A=null,S=b.yyleng,w=b.yytext,I=b.yylineno,T=b.yylloc;break;case 2:if(V=this.productions_[P[1]][1],H.$=f[f.length-V],H._$={first_line:n[n.length-(V||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(V||1)].first_column,last_column:n[n.length-1].last_column},D&&(H._$.range=[n[n.length-(V||1)].range[0],n[n.length-1].range[1]]),K=this.performAction.apply(H,[w,S,I,C.yy,P[1],f,n].concat(R)),typeof K<"u")return K;V&&(i=i.slice(0,-1*V*2),f=f.slice(0,-1*V),n=n.slice(0,-1*V)),i.push(this.productions_[P[1]][0]),f.push(H.$),n.push(H._$),et=v[i[i.length-2]][i[i.length-1]],i.push(et);break;case 3:return!0}}return!0},"parse")},O=(function(){var M={EOF:1,parseError:o(function(s,i){if(this.yy.parser)this.yy.parser.parseError(s,i);else throw new Error(s)},"parseError"),setInput:o(function(t,s){return this.yy=s||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:o(function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var s=t.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:o(function(t){var s=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var u=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var f=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===u.length?this.yylloc.first_column:0)+u[u.length-i.length].length-i[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[f[0],f[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:o(function(){return this._more=!0,this},"more"),reject:o(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:o(function(t){this.unput(this.match.slice(t))},"less"),pastInput:o(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:o(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:o(function(){var t=this.pastInput(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+`
@@ -1,4 +1,4 @@
1
- import{g as gt}from"./chunk-FMBD7UC4-COJ16id3.js";import{a as mt,g as lt,h as xt,d as kt}from"./chunk-ND2GUHAM-BuUYHFRS.js";import{g as _t,s as vt,a as bt,b as wt,q as Tt,p as St,_ as s,c as R,d as X,e as $t,z as Mt}from"./mermaid.core-CWJzgNYH.js";import{d as it}from"./arc-D6pe4Hbz.js";import"./index-BMsEuqd2.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var U=(function(){var t=s(function(h,r,n,l){for(n=n||{},l=h.length;l--;n[h[l]]=r);return n},"o"),e=[6,8,10,11,12,14,16,17,18],a=[1,9],f=[1,10],i=[1,11],u=[1,12],p=[1,13],o=[1,14],g={trace:s(function(){},"trace"),yy:{},symbols_:{error:2,start:3,journey:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,title:11,acc_title:12,acc_title_value:13,acc_descr:14,acc_descr_value:15,acc_descr_multiline_value:16,section:17,taskName:18,taskData:19,$accept:0,$end:1},terminals_:{2:"error",4:"journey",6:"EOF",8:"SPACE",10:"NEWLINE",11:"title",12:"acc_title",13:"acc_title_value",14:"acc_descr",15:"acc_descr_value",16:"acc_descr_multiline_value",17:"section",18:"taskName",19:"taskData"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,2],[9,2],[9,1],[9,1],[9,2]],performAction:s(function(r,n,l,y,d,c,v){var k=c.length-1;switch(d){case 1:return c[k-1];case 2:this.$=[];break;case 3:c[k-1].push(c[k]),this.$=c[k-1];break;case 4:case 5:this.$=c[k];break;case 6:case 7:this.$=[];break;case 8:y.setDiagramTitle(c[k].substr(6)),this.$=c[k].substr(6);break;case 9:this.$=c[k].trim(),y.setAccTitle(this.$);break;case 10:case 11:this.$=c[k].trim(),y.setAccDescription(this.$);break;case 12:y.addSection(c[k].substr(8)),this.$=c[k].substr(8);break;case 13:y.addTask(c[k-1],c[k]),this.$="task";break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},t(e,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:a,12:f,14:i,16:u,17:p,18:o},t(e,[2,7],{1:[2,1]}),t(e,[2,3]),{9:15,11:a,12:f,14:i,16:u,17:p,18:o},t(e,[2,5]),t(e,[2,6]),t(e,[2,8]),{13:[1,16]},{15:[1,17]},t(e,[2,11]),t(e,[2,12]),{19:[1,18]},t(e,[2,4]),t(e,[2,9]),t(e,[2,10]),t(e,[2,13])],defaultActions:{},parseError:s(function(r,n){if(n.recoverable)this.trace(r);else{var l=new Error(r);throw l.hash=n,l}},"parseError"),parse:s(function(r){var n=this,l=[0],y=[],d=[null],c=[],v=this.table,k="",C=0,Q=0,yt=2,D=1,dt=c.slice.call(arguments,1),_=Object.create(this.lexer),I={yy:{}};for(var O in this.yy)Object.prototype.hasOwnProperty.call(this.yy,O)&&(I.yy[O]=this.yy[O]);_.setInput(r,I.yy),I.yy.lexer=_,I.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var Y=_.yylloc;c.push(Y);var ft=_.options&&_.options.ranges;typeof I.yy.parseError=="function"?this.parseError=I.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pt(w){l.length=l.length-2*w,d.length=d.length-w,c.length=c.length-w}s(pt,"popStack");function tt(){var w;return w=y.pop()||_.lex()||D,typeof w!="number"&&(w instanceof Array&&(y=w,w=y.pop()),w=n.symbols_[w]||w),w}s(tt,"lex");for(var b,A,T,q,F={},N,M,et,z;;){if(A=l[l.length-1],this.defaultActions[A]?T=this.defaultActions[A]:((b===null||typeof b>"u")&&(b=tt()),T=v[A]&&v[A][b]),typeof T>"u"||!T.length||!T[0]){var H="";z=[];for(N in v[A])this.terminals_[N]&&N>yt&&z.push("'"+this.terminals_[N]+"'");_.showPosition?H="Parse error on line "+(C+1)+`:
1
+ import{g as gt}from"./chunk-FMBD7UC4-BGqxhWb0.js";import{a as mt,g as lt,h as xt,d as kt}from"./chunk-ND2GUHAM-D277WP9X.js";import{g as _t,s as vt,a as bt,b as wt,q as Tt,p as St,_ as s,c as R,d as X,e as $t,z as Mt}from"./mermaid.core-C4yLb7RL.js";import{d as it}from"./arc-BwVjnPVb.js";import"./index-BtvzdAkg.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var U=(function(){var t=s(function(h,r,n,l){for(n=n||{},l=h.length;l--;n[h[l]]=r);return n},"o"),e=[6,8,10,11,12,14,16,17,18],a=[1,9],f=[1,10],i=[1,11],u=[1,12],p=[1,13],o=[1,14],g={trace:s(function(){},"trace"),yy:{},symbols_:{error:2,start:3,journey:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,title:11,acc_title:12,acc_title_value:13,acc_descr:14,acc_descr_value:15,acc_descr_multiline_value:16,section:17,taskName:18,taskData:19,$accept:0,$end:1},terminals_:{2:"error",4:"journey",6:"EOF",8:"SPACE",10:"NEWLINE",11:"title",12:"acc_title",13:"acc_title_value",14:"acc_descr",15:"acc_descr_value",16:"acc_descr_multiline_value",17:"section",18:"taskName",19:"taskData"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,2],[9,2],[9,1],[9,1],[9,2]],performAction:s(function(r,n,l,y,d,c,v){var k=c.length-1;switch(d){case 1:return c[k-1];case 2:this.$=[];break;case 3:c[k-1].push(c[k]),this.$=c[k-1];break;case 4:case 5:this.$=c[k];break;case 6:case 7:this.$=[];break;case 8:y.setDiagramTitle(c[k].substr(6)),this.$=c[k].substr(6);break;case 9:this.$=c[k].trim(),y.setAccTitle(this.$);break;case 10:case 11:this.$=c[k].trim(),y.setAccDescription(this.$);break;case 12:y.addSection(c[k].substr(8)),this.$=c[k].substr(8);break;case 13:y.addTask(c[k-1],c[k]),this.$="task";break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},t(e,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:a,12:f,14:i,16:u,17:p,18:o},t(e,[2,7],{1:[2,1]}),t(e,[2,3]),{9:15,11:a,12:f,14:i,16:u,17:p,18:o},t(e,[2,5]),t(e,[2,6]),t(e,[2,8]),{13:[1,16]},{15:[1,17]},t(e,[2,11]),t(e,[2,12]),{19:[1,18]},t(e,[2,4]),t(e,[2,9]),t(e,[2,10]),t(e,[2,13])],defaultActions:{},parseError:s(function(r,n){if(n.recoverable)this.trace(r);else{var l=new Error(r);throw l.hash=n,l}},"parseError"),parse:s(function(r){var n=this,l=[0],y=[],d=[null],c=[],v=this.table,k="",C=0,Q=0,yt=2,D=1,dt=c.slice.call(arguments,1),_=Object.create(this.lexer),I={yy:{}};for(var O in this.yy)Object.prototype.hasOwnProperty.call(this.yy,O)&&(I.yy[O]=this.yy[O]);_.setInput(r,I.yy),I.yy.lexer=_,I.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var Y=_.yylloc;c.push(Y);var ft=_.options&&_.options.ranges;typeof I.yy.parseError=="function"?this.parseError=I.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pt(w){l.length=l.length-2*w,d.length=d.length-w,c.length=c.length-w}s(pt,"popStack");function tt(){var w;return w=y.pop()||_.lex()||D,typeof w!="number"&&(w instanceof Array&&(y=w,w=y.pop()),w=n.symbols_[w]||w),w}s(tt,"lex");for(var b,A,T,q,F={},N,M,et,z;;){if(A=l[l.length-1],this.defaultActions[A]?T=this.defaultActions[A]:((b===null||typeof b>"u")&&(b=tt()),T=v[A]&&v[A][b]),typeof T>"u"||!T.length||!T[0]){var H="";z=[];for(N in v[A])this.terminals_[N]&&N>yt&&z.push("'"+this.terminals_[N]+"'");_.showPosition?H="Parse error on line "+(C+1)+`:
2
2
  `+_.showPosition()+`
3
3
  Expecting `+z.join(", ")+", got '"+(this.terminals_[b]||b)+"'":H="Parse error on line "+(C+1)+": Unexpected "+(b==D?"end of input":"'"+(this.terminals_[b]||b)+"'"),this.parseError(H,{text:_.match,token:this.terminals_[b]||b,line:_.yylineno,loc:Y,expected:z})}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+A+", token: "+b);switch(T[0]){case 1:l.push(b),d.push(_.yytext),c.push(_.yylloc),l.push(T[1]),b=null,Q=_.yyleng,k=_.yytext,C=_.yylineno,Y=_.yylloc;break;case 2:if(M=this.productions_[T[1]][1],F.$=d[d.length-M],F._$={first_line:c[c.length-(M||1)].first_line,last_line:c[c.length-1].last_line,first_column:c[c.length-(M||1)].first_column,last_column:c[c.length-1].last_column},ft&&(F._$.range=[c[c.length-(M||1)].range[0],c[c.length-1].range[1]]),q=this.performAction.apply(F,[k,Q,C,I.yy,T[1],d,c].concat(dt)),typeof q<"u")return q;M&&(l=l.slice(0,-1*M*2),d=d.slice(0,-1*M),c=c.slice(0,-1*M)),l.push(this.productions_[T[1]][0]),d.push(F.$),c.push(F._$),et=v[l[l.length-2]][l[l.length-1]],l.push(et);break;case 3:return!0}}return!0},"parse")},m=(function(){var h={EOF:1,parseError:s(function(n,l){if(this.yy.parser)this.yy.parser.parseError(n,l);else throw new Error(n)},"parseError"),setInput:s(function(r,n){return this.yy=n||this.yy||{},this._input=r,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:s(function(){var r=this._input[0];this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r;var n=r.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),r},"input"),unput:s(function(r){var n=r.length,l=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var y=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),l.length-1&&(this.yylineno-=l.length-1);var d=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:l?(l.length===y.length?this.yylloc.first_column:0)+y[y.length-l.length].length-l[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[d[0],d[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},"unput"),more:s(function(){return this._more=!0,this},"more"),reject:s(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:s(function(r){this.unput(this.match.slice(r))},"less"),pastInput:s(function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:s(function(){var r=this.match;return r.length<20&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:s(function(){var r=this.pastInput(),n=new Array(r.length+1).join("-");return r+this.upcomingInput()+`
@@ -1,4 +1,4 @@
1
- import{_ as c,l as te,c as W,I as fe,af as ye,ag as be,ah as me,Y as _e,G as K,i as F,t as ke,J as Ee,V as Se,W as le,X as ce}from"./mermaid.core-CWJzgNYH.js";import{g as Ne}from"./chunk-FMBD7UC4-COJ16id3.js";import"./index-BMsEuqd2.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var $=(function(){var t=c(function(_,s,n,a){for(n=n||{},a=_.length;a--;n[_[a]]=s);return n},"o"),g=[1,4],d=[1,13],r=[1,12],p=[1,15],k=[1,16],f=[1,20],h=[1,19],L=[6,7,8],C=[1,26],w=[1,24],N=[1,25],i=[6,7,11],M=[1,31],x=[6,7,11,24],P=[1,6,13,16,17,20,23],U=[1,35],j=[1,36],A=[1,6,7,11,13,16,17,20,23],H=[1,38],V={trace:c(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,KANBAN:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,shapeData:15,ICON:16,CLASS:17,nodeWithId:18,nodeWithoutId:19,NODE_DSTART:20,NODE_DESCR:21,NODE_DEND:22,NODE_ID:23,SHAPE_DATA:24,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"KANBAN",11:"EOF",13:"SPACELIST",16:"ICON",17:"CLASS",20:"NODE_DSTART",21:"NODE_DESCR",22:"NODE_DEND",23:"NODE_ID",24:"SHAPE_DATA"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,3],[12,2],[12,2],[12,2],[12,1],[12,2],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[19,3],[18,1],[18,4],[15,2],[15,1]],performAction:c(function(s,n,a,o,u,e,B){var l=e.length-1;switch(u){case 6:case 7:return o;case 8:o.getLogger().trace("Stop NL ");break;case 9:o.getLogger().trace("Stop EOF ");break;case 11:o.getLogger().trace("Stop NL2 ");break;case 12:o.getLogger().trace("Stop EOF2 ");break;case 15:o.getLogger().info("Node: ",e[l-1].id),o.addNode(e[l-2].length,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 16:o.getLogger().info("Node: ",e[l].id),o.addNode(e[l-1].length,e[l].id,e[l].descr,e[l].type);break;case 17:o.getLogger().trace("Icon: ",e[l]),o.decorateNode({icon:e[l]});break;case 18:case 23:o.decorateNode({class:e[l]});break;case 19:o.getLogger().trace("SPACELIST");break;case 20:o.getLogger().trace("Node: ",e[l-1].id),o.addNode(0,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 21:o.getLogger().trace("Node: ",e[l].id),o.addNode(0,e[l].id,e[l].descr,e[l].type);break;case 22:o.decorateNode({icon:e[l]});break;case 27:o.getLogger().trace("node found ..",e[l-2]),this.$={id:e[l-1],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 28:this.$={id:e[l],descr:e[l],type:0};break;case 29:o.getLogger().trace("node found ..",e[l-3]),this.$={id:e[l-3],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 30:this.$=e[l-1]+e[l];break;case 31:this.$=e[l];break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:g},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:g},{6:d,7:[1,10],9:9,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(L,[2,3]),{1:[2,2]},t(L,[2,4]),t(L,[2,5]),{1:[2,6],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:d,9:22,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:C,7:w,10:23,11:N},t(i,[2,24],{18:17,19:18,14:27,16:[1,28],17:[1,29],20:f,23:h}),t(i,[2,19]),t(i,[2,21],{15:30,24:M}),t(i,[2,22]),t(i,[2,23]),t(x,[2,25]),t(x,[2,26]),t(x,[2,28],{20:[1,32]}),{21:[1,33]},{6:C,7:w,10:34,11:N},{1:[2,7],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(P,[2,14],{7:U,11:j}),t(A,[2,8]),t(A,[2,9]),t(A,[2,10]),t(i,[2,16],{15:37,24:M}),t(i,[2,17]),t(i,[2,18]),t(i,[2,20],{24:H}),t(x,[2,31]),{21:[1,39]},{22:[1,40]},t(P,[2,13],{7:U,11:j}),t(A,[2,11]),t(A,[2,12]),t(i,[2,15],{24:H}),t(x,[2,30]),{22:[1,41]},t(x,[2,27]),t(x,[2,29])],defaultActions:{2:[2,1],6:[2,2]},parseError:c(function(s,n){if(n.recoverable)this.trace(s);else{var a=new Error(s);throw a.hash=n,a}},"parseError"),parse:c(function(s){var n=this,a=[0],o=[],u=[null],e=[],B=this.table,l="",z=0,ie=0,ue=2,re=1,ge=e.slice.call(arguments,1),m=Object.create(this.lexer),T={yy:{}};for(var J in this.yy)Object.prototype.hasOwnProperty.call(this.yy,J)&&(T.yy[J]=this.yy[J]);m.setInput(s,T.yy),T.yy.lexer=m,T.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var q=m.yylloc;e.push(q);var de=m.options&&m.options.ranges;typeof T.yy.parseError=="function"?this.parseError=T.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pe(S){a.length=a.length-2*S,u.length=u.length-S,e.length=e.length-S}c(pe,"popStack");function ae(){var S;return S=o.pop()||m.lex()||re,typeof S!="number"&&(S instanceof Array&&(o=S,S=o.pop()),S=n.symbols_[S]||S),S}c(ae,"lex");for(var E,R,v,Q,G={},X,I,oe,Y;;){if(R=a[a.length-1],this.defaultActions[R]?v=this.defaultActions[R]:((E===null||typeof E>"u")&&(E=ae()),v=B[R]&&B[R][E]),typeof v>"u"||!v.length||!v[0]){var Z="";Y=[];for(X in B[R])this.terminals_[X]&&X>ue&&Y.push("'"+this.terminals_[X]+"'");m.showPosition?Z="Parse error on line "+(z+1)+`:
1
+ import{_ as c,l as te,c as W,I as fe,af as ye,ag as be,ah as me,Y as _e,G as K,i as F,t as ke,J as Ee,V as Se,W as le,X as ce}from"./mermaid.core-C4yLb7RL.js";import{g as Ne}from"./chunk-FMBD7UC4-BGqxhWb0.js";import"./index-BtvzdAkg.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var $=(function(){var t=c(function(_,s,n,a){for(n=n||{},a=_.length;a--;n[_[a]]=s);return n},"o"),g=[1,4],d=[1,13],r=[1,12],p=[1,15],k=[1,16],f=[1,20],h=[1,19],L=[6,7,8],C=[1,26],w=[1,24],N=[1,25],i=[6,7,11],M=[1,31],x=[6,7,11,24],P=[1,6,13,16,17,20,23],U=[1,35],j=[1,36],A=[1,6,7,11,13,16,17,20,23],H=[1,38],V={trace:c(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,KANBAN:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,shapeData:15,ICON:16,CLASS:17,nodeWithId:18,nodeWithoutId:19,NODE_DSTART:20,NODE_DESCR:21,NODE_DEND:22,NODE_ID:23,SHAPE_DATA:24,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"KANBAN",11:"EOF",13:"SPACELIST",16:"ICON",17:"CLASS",20:"NODE_DSTART",21:"NODE_DESCR",22:"NODE_DEND",23:"NODE_ID",24:"SHAPE_DATA"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,3],[12,2],[12,2],[12,2],[12,1],[12,2],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[19,3],[18,1],[18,4],[15,2],[15,1]],performAction:c(function(s,n,a,o,u,e,B){var l=e.length-1;switch(u){case 6:case 7:return o;case 8:o.getLogger().trace("Stop NL ");break;case 9:o.getLogger().trace("Stop EOF ");break;case 11:o.getLogger().trace("Stop NL2 ");break;case 12:o.getLogger().trace("Stop EOF2 ");break;case 15:o.getLogger().info("Node: ",e[l-1].id),o.addNode(e[l-2].length,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 16:o.getLogger().info("Node: ",e[l].id),o.addNode(e[l-1].length,e[l].id,e[l].descr,e[l].type);break;case 17:o.getLogger().trace("Icon: ",e[l]),o.decorateNode({icon:e[l]});break;case 18:case 23:o.decorateNode({class:e[l]});break;case 19:o.getLogger().trace("SPACELIST");break;case 20:o.getLogger().trace("Node: ",e[l-1].id),o.addNode(0,e[l-1].id,e[l-1].descr,e[l-1].type,e[l]);break;case 21:o.getLogger().trace("Node: ",e[l].id),o.addNode(0,e[l].id,e[l].descr,e[l].type);break;case 22:o.decorateNode({icon:e[l]});break;case 27:o.getLogger().trace("node found ..",e[l-2]),this.$={id:e[l-1],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 28:this.$={id:e[l],descr:e[l],type:0};break;case 29:o.getLogger().trace("node found ..",e[l-3]),this.$={id:e[l-3],descr:e[l-1],type:o.getType(e[l-2],e[l])};break;case 30:this.$=e[l-1]+e[l];break;case 31:this.$=e[l];break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:g},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:g},{6:d,7:[1,10],9:9,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(L,[2,3]),{1:[2,2]},t(L,[2,4]),t(L,[2,5]),{1:[2,6],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:d,9:22,12:11,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},{6:C,7:w,10:23,11:N},t(i,[2,24],{18:17,19:18,14:27,16:[1,28],17:[1,29],20:f,23:h}),t(i,[2,19]),t(i,[2,21],{15:30,24:M}),t(i,[2,22]),t(i,[2,23]),t(x,[2,25]),t(x,[2,26]),t(x,[2,28],{20:[1,32]}),{21:[1,33]},{6:C,7:w,10:34,11:N},{1:[2,7],6:d,12:21,13:r,14:14,16:p,17:k,18:17,19:18,20:f,23:h},t(P,[2,14],{7:U,11:j}),t(A,[2,8]),t(A,[2,9]),t(A,[2,10]),t(i,[2,16],{15:37,24:M}),t(i,[2,17]),t(i,[2,18]),t(i,[2,20],{24:H}),t(x,[2,31]),{21:[1,39]},{22:[1,40]},t(P,[2,13],{7:U,11:j}),t(A,[2,11]),t(A,[2,12]),t(i,[2,15],{24:H}),t(x,[2,30]),{22:[1,41]},t(x,[2,27]),t(x,[2,29])],defaultActions:{2:[2,1],6:[2,2]},parseError:c(function(s,n){if(n.recoverable)this.trace(s);else{var a=new Error(s);throw a.hash=n,a}},"parseError"),parse:c(function(s){var n=this,a=[0],o=[],u=[null],e=[],B=this.table,l="",z=0,ie=0,ue=2,re=1,ge=e.slice.call(arguments,1),m=Object.create(this.lexer),T={yy:{}};for(var J in this.yy)Object.prototype.hasOwnProperty.call(this.yy,J)&&(T.yy[J]=this.yy[J]);m.setInput(s,T.yy),T.yy.lexer=m,T.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var q=m.yylloc;e.push(q);var de=m.options&&m.options.ranges;typeof T.yy.parseError=="function"?this.parseError=T.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pe(S){a.length=a.length-2*S,u.length=u.length-S,e.length=e.length-S}c(pe,"popStack");function ae(){var S;return S=o.pop()||m.lex()||re,typeof S!="number"&&(S instanceof Array&&(o=S,S=o.pop()),S=n.symbols_[S]||S),S}c(ae,"lex");for(var E,R,v,Q,G={},X,I,oe,Y;;){if(R=a[a.length-1],this.defaultActions[R]?v=this.defaultActions[R]:((E===null||typeof E>"u")&&(E=ae()),v=B[R]&&B[R][E]),typeof v>"u"||!v.length||!v[0]){var Z="";Y=[];for(X in B[R])this.terminals_[X]&&X>ue&&Y.push("'"+this.terminals_[X]+"'");m.showPosition?Z="Parse error on line "+(z+1)+`:
2
2
  `+m.showPosition()+`
3
3
  Expecting `+Y.join(", ")+", got '"+(this.terminals_[E]||E)+"'":Z="Parse error on line "+(z+1)+": Unexpected "+(E==re?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(Z,{text:m.match,token:this.terminals_[E]||E,line:m.yylineno,loc:q,expected:Y})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+R+", token: "+E);switch(v[0]){case 1:a.push(E),u.push(m.yytext),e.push(m.yylloc),a.push(v[1]),E=null,ie=m.yyleng,l=m.yytext,z=m.yylineno,q=m.yylloc;break;case 2:if(I=this.productions_[v[1]][1],G.$=u[u.length-I],G._$={first_line:e[e.length-(I||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(I||1)].first_column,last_column:e[e.length-1].last_column},de&&(G._$.range=[e[e.length-(I||1)].range[0],e[e.length-1].range[1]]),Q=this.performAction.apply(G,[l,ie,z,T.yy,v[1],u,e].concat(ge)),typeof Q<"u")return Q;I&&(a=a.slice(0,-1*I*2),u=u.slice(0,-1*I),e=e.slice(0,-1*I)),a.push(this.productions_[v[1]][0]),u.push(G.$),e.push(G._$),oe=B[a[a.length-2]][a[a.length-1]],a.push(oe);break;case 3:return!0}}return!0},"parse")},y=(function(){var _={EOF:1,parseError:c(function(n,a){if(this.yy.parser)this.yy.parser.parseError(n,a);else throw new Error(n)},"parseError"),setInput:c(function(s,n){return this.yy=n||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:c(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var n=s.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:c(function(s){var n=s.length,a=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var o=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),a.length-1&&(this.yylineno-=a.length-1);var u=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:a?(a.length===o.length?this.yylloc.first_column:0)+o[o.length-a.length].length-a[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[u[0],u[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},"unput"),more:c(function(){return this._more=!0,this},"more"),reject:c(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:c(function(s){this.unput(this.match.slice(s))},"less"),pastInput:c(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:c(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:c(function(){var s=this.pastInput(),n=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
@@ -1 +1 @@
1
- import{b7 as j,b8 as p,b9 as w,ba as k,bb as q}from"./mermaid.core-CWJzgNYH.js";import{i as D}from"./init-Gi6I4Gst.js";import{e as g,f as F,a as z,b as B}from"./defaultLocale-DX6XiGOO.js";function M(n,r){return n==null||r==null?NaN:n<r?-1:n>r?1:n>=r?0:NaN}function I(n,r){return n==null||r==null?NaN:r<n?-1:r>n?1:r>=n?0:NaN}function R(n){let r,t,e;n.length!==2?(r=M,t=(o,c)=>M(n(o),c),e=(o,c)=>n(o)-c):(r=n===M||n===I?n:P,t=n,e=n);function u(o,c,i=0,h=o.length){if(i<h){if(r(c,c)!==0)return h;do{const l=i+h>>>1;t(o[l],c)<0?i=l+1:h=l}while(i<h)}return i}function f(o,c,i=0,h=o.length){if(i<h){if(r(c,c)!==0)return h;do{const l=i+h>>>1;t(o[l],c)<=0?i=l+1:h=l}while(i<h)}return i}function a(o,c,i=0,h=o.length){const l=u(o,c,i,h-1);return l>i&&e(o[l-1],c)>-e(o[l],c)?l-1:l}return{left:u,center:a,right:f}}function P(){return 0}function V(n){return n===null?NaN:+n}const $=R(M),x=$.right;R(V).center;const O=Math.sqrt(50),T=Math.sqrt(10),C=Math.sqrt(2);function v(n,r,t){const e=(r-n)/Math.max(0,t),u=Math.floor(Math.log10(e)),f=e/Math.pow(10,u),a=f>=O?10:f>=T?5:f>=C?2:1;let o,c,i;return u<0?(i=Math.pow(10,-u)/a,o=Math.round(n*i),c=Math.round(r*i),o/i<n&&++o,c/i>r&&--c,i=-i):(i=Math.pow(10,u)*a,o=Math.round(n/i),c=Math.round(r/i),o*i<n&&++o,c*i>r&&--c),c<o&&.5<=t&&t<2?v(n,r,t*2):[o,c,i]}function E(n,r,t){if(r=+r,n=+n,t=+t,!(t>0))return[];if(n===r)return[n];const e=r<n,[u,f,a]=e?v(r,n,t):v(n,r,t);if(!(f>=u))return[];const o=f-u+1,c=new Array(o);if(e)if(a<0)for(let i=0;i<o;++i)c[i]=(f-i)/-a;else for(let i=0;i<o;++i)c[i]=(f-i)*a;else if(a<0)for(let i=0;i<o;++i)c[i]=(u+i)/-a;else for(let i=0;i<o;++i)c[i]=(u+i)*a;return c}function y(n,r,t){return r=+r,n=+n,t=+t,v(n,r,t)[2]}function G(n,r,t){r=+r,n=+n,t=+t;const e=r<n,u=e?y(r,n,t):y(n,r,t);return(e?-1:1)*(u<0?1/-u:u)}function H(n,r){r||(r=[]);var t=n?Math.min(r.length,n.length):0,e=r.slice(),u;return function(f){for(u=0;u<t;++u)e[u]=n[u]*(1-f)+r[u]*f;return e}}function J(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function K(n,r){var t=r?r.length:0,e=n?Math.min(t,n.length):0,u=new Array(e),f=new Array(t),a;for(a=0;a<e;++a)u[a]=d(n[a],r[a]);for(;a<t;++a)f[a]=r[a];return function(o){for(a=0;a<e;++a)f[a]=u[a](o);return f}}function L(n,r){var t=new Date;return n=+n,r=+r,function(e){return t.setTime(n*(1-e)+r*e),t}}function Q(n,r){var t={},e={},u;(n===null||typeof n!="object")&&(n={}),(r===null||typeof r!="object")&&(r={});for(u in r)u in n?t[u]=d(n[u],r[u]):e[u]=r[u];return function(f){for(u in t)e[u]=t[u](f);return e}}function d(n,r){var t=typeof r,e;return r==null||t==="boolean"?j(r):(t==="number"?p:t==="string"?(e=w(r))?(r=e,k):q:r instanceof w?k:r instanceof Date?L:J(r)?H:Array.isArray(r)?K:typeof r.valueOf!="function"&&typeof r.toString!="function"||isNaN(r)?Q:p)(n,r)}function U(n,r){return n=+n,r=+r,function(t){return Math.round(n*(1-t)+r*t)}}function W(n){return Math.max(0,-g(Math.abs(n)))}function X(n,r){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(g(r)/3)))*3-g(Math.abs(n)))}function Y(n,r){return n=Math.abs(n),r=Math.abs(r)-n,Math.max(0,g(r)-g(n))+1}function Z(n){return function(){return n}}function _(n){return+n}var A=[0,1];function m(n){return n}function N(n,r){return(r-=n=+n)?function(t){return(t-n)/r}:Z(isNaN(r)?NaN:.5)}function b(n,r){var t;return n>r&&(t=n,n=r,r=t),function(e){return Math.max(n,Math.min(r,e))}}function nn(n,r,t){var e=n[0],u=n[1],f=r[0],a=r[1];return u<e?(e=N(u,e),f=t(a,f)):(e=N(e,u),f=t(f,a)),function(o){return f(e(o))}}function rn(n,r,t){var e=Math.min(n.length,r.length)-1,u=new Array(e),f=new Array(e),a=-1;for(n[e]<n[0]&&(n=n.slice().reverse(),r=r.slice().reverse());++a<e;)u[a]=N(n[a],n[a+1]),f[a]=t(r[a],r[a+1]);return function(o){var c=x(n,o,1,e)-1;return f[c](u[c](o))}}function en(n,r){return r.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function tn(){var n=A,r=A,t=d,e,u,f,a=m,o,c,i;function h(){var s=Math.min(n.length,r.length);return a!==m&&(a=b(n[0],n[s-1])),o=s>2?rn:nn,c=i=null,l}function l(s){return s==null||isNaN(s=+s)?f:(c||(c=o(n.map(e),r,t)))(e(a(s)))}return l.invert=function(s){return a(u((i||(i=o(r,n.map(e),p)))(s)))},l.domain=function(s){return arguments.length?(n=Array.from(s,_),h()):n.slice()},l.range=function(s){return arguments.length?(r=Array.from(s),h()):r.slice()},l.rangeRound=function(s){return r=Array.from(s),t=U,h()},l.clamp=function(s){return arguments.length?(a=s?!0:m,h()):a!==m},l.interpolate=function(s){return arguments.length?(t=s,h()):t},l.unknown=function(s){return arguments.length?(f=s,l):f},function(s,S){return e=s,u=S,h()}}function un(){return tn()(m,m)}function an(n,r,t,e){var u=G(n,r,t),f;switch(e=F(e??",f"),e.type){case"s":{var a=Math.max(Math.abs(n),Math.abs(r));return e.precision==null&&!isNaN(f=X(u,a))&&(e.precision=f),z(e,a)}case"":case"e":case"g":case"p":case"r":{e.precision==null&&!isNaN(f=Y(u,Math.max(Math.abs(n),Math.abs(r))))&&(e.precision=f-(e.type==="e"));break}case"f":case"%":{e.precision==null&&!isNaN(f=W(u))&&(e.precision=f-(e.type==="%")*2);break}}return B(e)}function on(n){var r=n.domain;return n.ticks=function(t){var e=r();return E(e[0],e[e.length-1],t??10)},n.tickFormat=function(t,e){var u=r();return an(u[0],u[u.length-1],t??10,e)},n.nice=function(t){t==null&&(t=10);var e=r(),u=0,f=e.length-1,a=e[u],o=e[f],c,i,h=10;for(o<a&&(i=a,a=o,o=i,i=u,u=f,f=i);h-- >0;){if(i=y(a,o,t),i===c)return e[u]=a,e[f]=o,r(e);if(i>0)a=Math.floor(a/i)*i,o=Math.ceil(o/i)*i;else if(i<0)a=Math.ceil(a*i)/i,o=Math.floor(o*i)/i;else break;c=i}return n},n}function fn(){var n=un();return n.copy=function(){return en(n,fn())},D.apply(n,arguments),on(n)}export{en as a,R as b,un as c,fn as l,G as t};
1
+ import{b7 as j,b8 as p,b9 as w,ba as k,bb as q}from"./mermaid.core-C4yLb7RL.js";import{i as D}from"./init-Gi6I4Gst.js";import{e as g,f as F,a as z,b as B}from"./defaultLocale-DX6XiGOO.js";function M(n,r){return n==null||r==null?NaN:n<r?-1:n>r?1:n>=r?0:NaN}function I(n,r){return n==null||r==null?NaN:r<n?-1:r>n?1:r>=n?0:NaN}function R(n){let r,t,e;n.length!==2?(r=M,t=(o,c)=>M(n(o),c),e=(o,c)=>n(o)-c):(r=n===M||n===I?n:P,t=n,e=n);function u(o,c,i=0,h=o.length){if(i<h){if(r(c,c)!==0)return h;do{const l=i+h>>>1;t(o[l],c)<0?i=l+1:h=l}while(i<h)}return i}function f(o,c,i=0,h=o.length){if(i<h){if(r(c,c)!==0)return h;do{const l=i+h>>>1;t(o[l],c)<=0?i=l+1:h=l}while(i<h)}return i}function a(o,c,i=0,h=o.length){const l=u(o,c,i,h-1);return l>i&&e(o[l-1],c)>-e(o[l],c)?l-1:l}return{left:u,center:a,right:f}}function P(){return 0}function V(n){return n===null?NaN:+n}const $=R(M),x=$.right;R(V).center;const O=Math.sqrt(50),T=Math.sqrt(10),C=Math.sqrt(2);function v(n,r,t){const e=(r-n)/Math.max(0,t),u=Math.floor(Math.log10(e)),f=e/Math.pow(10,u),a=f>=O?10:f>=T?5:f>=C?2:1;let o,c,i;return u<0?(i=Math.pow(10,-u)/a,o=Math.round(n*i),c=Math.round(r*i),o/i<n&&++o,c/i>r&&--c,i=-i):(i=Math.pow(10,u)*a,o=Math.round(n/i),c=Math.round(r/i),o*i<n&&++o,c*i>r&&--c),c<o&&.5<=t&&t<2?v(n,r,t*2):[o,c,i]}function E(n,r,t){if(r=+r,n=+n,t=+t,!(t>0))return[];if(n===r)return[n];const e=r<n,[u,f,a]=e?v(r,n,t):v(n,r,t);if(!(f>=u))return[];const o=f-u+1,c=new Array(o);if(e)if(a<0)for(let i=0;i<o;++i)c[i]=(f-i)/-a;else for(let i=0;i<o;++i)c[i]=(f-i)*a;else if(a<0)for(let i=0;i<o;++i)c[i]=(u+i)/-a;else for(let i=0;i<o;++i)c[i]=(u+i)*a;return c}function y(n,r,t){return r=+r,n=+n,t=+t,v(n,r,t)[2]}function G(n,r,t){r=+r,n=+n,t=+t;const e=r<n,u=e?y(r,n,t):y(n,r,t);return(e?-1:1)*(u<0?1/-u:u)}function H(n,r){r||(r=[]);var t=n?Math.min(r.length,n.length):0,e=r.slice(),u;return function(f){for(u=0;u<t;++u)e[u]=n[u]*(1-f)+r[u]*f;return e}}function J(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function K(n,r){var t=r?r.length:0,e=n?Math.min(t,n.length):0,u=new Array(e),f=new Array(t),a;for(a=0;a<e;++a)u[a]=d(n[a],r[a]);for(;a<t;++a)f[a]=r[a];return function(o){for(a=0;a<e;++a)f[a]=u[a](o);return f}}function L(n,r){var t=new Date;return n=+n,r=+r,function(e){return t.setTime(n*(1-e)+r*e),t}}function Q(n,r){var t={},e={},u;(n===null||typeof n!="object")&&(n={}),(r===null||typeof r!="object")&&(r={});for(u in r)u in n?t[u]=d(n[u],r[u]):e[u]=r[u];return function(f){for(u in t)e[u]=t[u](f);return e}}function d(n,r){var t=typeof r,e;return r==null||t==="boolean"?j(r):(t==="number"?p:t==="string"?(e=w(r))?(r=e,k):q:r instanceof w?k:r instanceof Date?L:J(r)?H:Array.isArray(r)?K:typeof r.valueOf!="function"&&typeof r.toString!="function"||isNaN(r)?Q:p)(n,r)}function U(n,r){return n=+n,r=+r,function(t){return Math.round(n*(1-t)+r*t)}}function W(n){return Math.max(0,-g(Math.abs(n)))}function X(n,r){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(g(r)/3)))*3-g(Math.abs(n)))}function Y(n,r){return n=Math.abs(n),r=Math.abs(r)-n,Math.max(0,g(r)-g(n))+1}function Z(n){return function(){return n}}function _(n){return+n}var A=[0,1];function m(n){return n}function N(n,r){return(r-=n=+n)?function(t){return(t-n)/r}:Z(isNaN(r)?NaN:.5)}function b(n,r){var t;return n>r&&(t=n,n=r,r=t),function(e){return Math.max(n,Math.min(r,e))}}function nn(n,r,t){var e=n[0],u=n[1],f=r[0],a=r[1];return u<e?(e=N(u,e),f=t(a,f)):(e=N(e,u),f=t(f,a)),function(o){return f(e(o))}}function rn(n,r,t){var e=Math.min(n.length,r.length)-1,u=new Array(e),f=new Array(e),a=-1;for(n[e]<n[0]&&(n=n.slice().reverse(),r=r.slice().reverse());++a<e;)u[a]=N(n[a],n[a+1]),f[a]=t(r[a],r[a+1]);return function(o){var c=x(n,o,1,e)-1;return f[c](u[c](o))}}function en(n,r){return r.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function tn(){var n=A,r=A,t=d,e,u,f,a=m,o,c,i;function h(){var s=Math.min(n.length,r.length);return a!==m&&(a=b(n[0],n[s-1])),o=s>2?rn:nn,c=i=null,l}function l(s){return s==null||isNaN(s=+s)?f:(c||(c=o(n.map(e),r,t)))(e(a(s)))}return l.invert=function(s){return a(u((i||(i=o(r,n.map(e),p)))(s)))},l.domain=function(s){return arguments.length?(n=Array.from(s,_),h()):n.slice()},l.range=function(s){return arguments.length?(r=Array.from(s),h()):r.slice()},l.rangeRound=function(s){return r=Array.from(s),t=U,h()},l.clamp=function(s){return arguments.length?(a=s?!0:m,h()):a!==m},l.interpolate=function(s){return arguments.length?(t=s,h()):t},l.unknown=function(s){return arguments.length?(f=s,l):f},function(s,S){return e=s,u=S,h()}}function un(){return tn()(m,m)}function an(n,r,t,e){var u=G(n,r,t),f;switch(e=F(e??",f"),e.type){case"s":{var a=Math.max(Math.abs(n),Math.abs(r));return e.precision==null&&!isNaN(f=X(u,a))&&(e.precision=f),z(e,a)}case"":case"e":case"g":case"p":case"r":{e.precision==null&&!isNaN(f=Y(u,Math.max(Math.abs(n),Math.abs(r))))&&(e.precision=f-(e.type==="e"));break}case"f":case"%":{e.precision==null&&!isNaN(f=W(u))&&(e.precision=f-(e.type==="%")*2);break}}return B(e)}function on(n){var r=n.domain;return n.ticks=function(t){var e=r();return E(e[0],e[e.length-1],t??10)},n.tickFormat=function(t,e){var u=r();return an(u[0],u[u.length-1],t??10,e)},n.nice=function(t){t==null&&(t=10);var e=r(),u=0,f=e.length-1,a=e[u],o=e[f],c,i,h=10;for(o<a&&(i=a,a=o,o=i,i=u,u=f,f=i);h-- >0;){if(i=y(a,o,t),i===c)return e[u]=a,e[f]=o,r(e);if(i>0)a=Math.floor(a/i)*i,o=Math.ceil(o/i)*i;else if(i<0)a=Math.ceil(a*i)/i,o=Math.floor(o*i)/i;else break;c=i}return n},n}function fn(){var n=un();return n.copy=function(){return en(n,fn())},D.apply(n,arguments),on(n)}export{en as a,R as b,un as c,fn as l,G as t};