@aalis/plugin-webui-client 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/LICENSE +235 -0
  2. package/README.md +21 -0
  3. package/dist/assets/AuthorityPage-COZ1GZ_n.js +12 -0
  4. package/dist/assets/DynamicPage-DJFDEG6E.js +19 -0
  5. package/dist/assets/FilesPage-CBCBRbIG.js +16 -0
  6. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  7. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  8. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  9. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  10. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  11. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  12. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  13. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  14. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  15. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  16. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  17. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  18. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  19. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  20. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  21. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  22. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  23. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  24. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  25. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  26. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  27. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  28. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  29. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  30. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  31. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  32. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  33. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  34. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  35. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  36. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  37. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  38. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  39. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  40. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  41. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  42. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  43. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  44. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  45. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  46. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  47. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  48. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  49. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  50. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  51. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  52. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  53. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  54. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  55. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  56. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  57. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  58. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  59. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  60. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  61. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  62. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  63. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  64. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  65. package/dist/assets/LogPage-C_Z3RA5T.js +1 -0
  66. package/dist/assets/MarketplacePage-HGIvPE-L.js +23 -0
  67. package/dist/assets/PlatformPage-BU3sDCdV.js +6 -0
  68. package/dist/assets/PluginConfigPage-B-xh_pwj.js +23 -0
  69. package/dist/assets/SchemaForm-YVQZ6Keg.js +1 -0
  70. package/dist/assets/SessionsPage-DOl-b2K7.js +1 -0
  71. package/dist/assets/arc-B9dZH4Mz.js +1 -0
  72. package/dist/assets/architectureDiagram-3BPJPVTR-_XZszVRW.js +36 -0
  73. package/dist/assets/blockDiagram-GPEHLZMM-DjTNIZAV.js +132 -0
  74. package/dist/assets/c4Diagram-AAUBKEIU-DAcjskYi.js +10 -0
  75. package/dist/assets/channel-CWs0Ph4z.js +1 -0
  76. package/dist/assets/chunk-2J33WTMH-CHFaIVIG.js +1 -0
  77. package/dist/assets/chunk-4BX2VUAB-BLsTiY6G.js +1 -0
  78. package/dist/assets/chunk-55IACEB6-BUHj8uJ5.js +1 -0
  79. package/dist/assets/chunk-727SXJPM-BJxPkPIn.js +206 -0
  80. package/dist/assets/chunk-AQP2D5EJ-D9XSGH7X.js +231 -0
  81. package/dist/assets/chunk-FMBD7UC4-14mizF84.js +15 -0
  82. package/dist/assets/chunk-ND2GUHAM-DHAQxCCH.js +1 -0
  83. package/dist/assets/chunk-QZHKN3VN-BRYJuaKF.js +1 -0
  84. package/dist/assets/classDiagram-4FO5ZUOK-BGMWGMFm.js +1 -0
  85. package/dist/assets/classDiagram-v2-Q7XG4LA2-BGMWGMFm.js +1 -0
  86. package/dist/assets/clock-CuE2gSPG.js +6 -0
  87. package/dist/assets/cose-bilkent-S5V4N54A---ynUpZp.js +1 -0
  88. package/dist/assets/cytoscape-fcose-DXAQNCkb.js +1 -0
  89. package/dist/assets/cytoscape.esm-LDYqcvCF.js +331 -0
  90. package/dist/assets/dagre-BM42HDAG-B_veAgHZ.js +4 -0
  91. package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  92. package/dist/assets/diagram-2AECGRRQ-2Kvvu1DV.js +43 -0
  93. package/dist/assets/diagram-5GNKFQAL-BcLJ0vOW.js +10 -0
  94. package/dist/assets/diagram-KO2AKTUF-DgvS7EhJ.js +3 -0
  95. package/dist/assets/diagram-LMA3HP47-Dobv6LjS.js +24 -0
  96. package/dist/assets/diagram-OG6HWLK6-kbRFWXPw.js +24 -0
  97. package/dist/assets/erDiagram-TEJ5UH35-B6ilVUKl.js +85 -0
  98. package/dist/assets/flowDiagram-I6XJVG4X-DWyEuHCU.js +162 -0
  99. package/dist/assets/ganttDiagram-6RSMTGT7-CmgqK4-P.js +292 -0
  100. package/dist/assets/gitGraphDiagram-PVQCEYII-DuexqjAc.js +106 -0
  101. package/dist/assets/globe-bFIW3FVE.js +6 -0
  102. package/dist/assets/graph-CAnANduQ.js +1 -0
  103. package/dist/assets/highlight-BPWJwfct.css +9 -0
  104. package/dist/assets/highlight-DJvvuuwd.js +5 -0
  105. package/dist/assets/index-CaU2rCNv.css +1 -0
  106. package/dist/assets/index-D4hgfekH.js +207 -0
  107. package/dist/assets/infoDiagram-5YYISTIA-CzWWvYqm.js +2 -0
  108. package/dist/assets/init-Gi6I4Gst.js +1 -0
  109. package/dist/assets/ishikawaDiagram-YF4QCWOH-CwACduTX.js +70 -0
  110. package/dist/assets/journeyDiagram-JHISSGLW-fT0SRS58.js +139 -0
  111. package/dist/assets/kanban-definition-UN3LZRKU-DVqDYGqT.js +89 -0
  112. package/dist/assets/katex-Bq6vt64r.js +265 -0
  113. package/dist/assets/katex-CIHdCL6t.css +1 -0
  114. package/dist/assets/layout-DGIYPm2g.js +1 -0
  115. package/dist/assets/linear-CZgp6Fzk.js +1 -0
  116. package/dist/assets/markdown-BCywGHw2.js +35 -0
  117. package/dist/assets/mermaid.core-BbMB3jno.js +309 -0
  118. package/dist/assets/mindmap-definition-RKZ34NQL-Blj-hhKO.js +96 -0
  119. package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  120. package/dist/assets/pieDiagram-4H26LBE5-C-QBAE8E.js +30 -0
  121. package/dist/assets/quadrantDiagram-W4KKPZXB-DLNCWkpV.js +7 -0
  122. package/dist/assets/react-vendor-BPQixOLZ.js +49 -0
  123. package/dist/assets/requirementDiagram-4Y6WPE33-Db7mnSho.js +84 -0
  124. package/dist/assets/sankeyDiagram-5OEKKPKP-Dys1xLTB.js +40 -0
  125. package/dist/assets/sequenceDiagram-3UESZ5HK-BXuxkY9a.js +162 -0
  126. package/dist/assets/stateDiagram-AJRCARHV-Bf7MYv4Z.js +1 -0
  127. package/dist/assets/stateDiagram-v2-BHNVJYJU-D-_B0BoL.js +1 -0
  128. package/dist/assets/timeline-definition-PNZ67QCA-CO_HyU4B.js +120 -0
  129. package/dist/assets/vennDiagram-CIIHVFJN-BFm2iq_q.js +34 -0
  130. package/dist/assets/wardley-L42UT6IY-DwPang7i.js +173 -0
  131. package/dist/assets/wardleyDiagram-YWT4CUSO-B_OPLFkw.js +78 -0
  132. package/dist/assets/xychartDiagram-2RQKCTM6-I4OX9JOH.js +7 -0
  133. package/dist/index.html +19 -0
  134. package/package.json +43 -0
@@ -0,0 +1 @@
1
+ import{r,j as l}from"./react-vendor-BPQixOLZ.js";const T=40,H=40;function b({logs:t,onLoadOlder:a}){const[i,m]=r.useState(null),[x,v]=r.useState(new Set),o=r.useRef(null),f=r.useRef(!0),u=r.useRef(!1),c=r.useRef(null),h=r.useRef(null),p=r.useRef(0),g=i?t.filter(e=>e.level===i):t;r.useEffect(()=>{var s,n;const e=o.current;if(e){if(c.current){const{prevScrollHeight:d,prevScrollTop:N}=c.current,E=e.scrollHeight-d;e.scrollTop=N+E,c.current=null,h.current=((s=t[0])==null?void 0:s.seq)??null,p.current=t.length;return}f.current&&t.length>p.current&&(e.scrollTop=e.scrollHeight),h.current=((n=t[0])==null?void 0:n.seq)??null,p.current=t.length}},[t]);const R=r.useCallback(()=>{const e=o.current;if(!e)return;const{scrollTop:s,scrollHeight:n,clientHeight:d}=e;f.current=n-s-d<T,s<H&&a&&!u.current&&t.length>0&&(u.current=!0,c.current={prevScrollHeight:n,prevScrollTop:s},a().catch(()=>{}).finally(()=>{u.current=!1}))},[a,t.length]),S=e=>{v(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n})},j=["debug","info","warn","error"];return l.jsxs("div",{className:"page-logs",children:[l.jsxs("div",{className:"log-controls",children:[j.map(e=>l.jsx("button",{className:`log-filter ${i===e?"active":""}`,onClick:()=>m(s=>s===e?null:e),children:e.toUpperCase()},e)),l.jsx("span",{className:"log-hint",children:"点击单行展开/折叠完整内容"})]}),l.jsxs("div",{className:"log-list",ref:o,onScroll:R,children:[g.map(e=>{const s=x.has(e.seq);return l.jsxs("div",{className:`log-entry ${s?"expanded":""}`,onClick:()=>S(e.seq),style:{contentVisibility:"auto",containIntrinsicSize:"28px"},children:[l.jsx("span",{className:"log-time",title:e.timestamp,children:e.timestamp.slice(11,23)}),l.jsx("span",{className:`log-level ${e.level}`,children:e.level.toUpperCase().padEnd(5)}),l.jsx("span",{className:"log-scope",children:e.scope}),l.jsx("span",{className:"log-msg",title:s?"":e.message,children:e.message})]},e.seq)}),g.length===0&&l.jsx("div",{className:"empty-hint",style:{padding:16},children:"暂无日志"})]})]})}export{b as LogPage};
@@ -0,0 +1,23 @@
1
+ import{r as s,j as a}from"./react-vendor-BPQixOLZ.js";import{c as q,a as S,T as k,D as H}from"./index-D4hgfekH.js";import{C as K}from"./clock-CuE2gSPG.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Q=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],X=q("scale",Q);/**
7
+ * @license lucide-react v1.7.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Z=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],ee=q("star",Z),_={relevance:"默认排序",downloads:"下载量",updated:"最近更新",score:"综合评分"},F={all:"全部来源",official:"仅官方",community:"仅社区"},I={all:"全部状态",installed:"已安装",available:"未安装"},R={all:"全部类型",plugin:"功能插件",api:"API 契约",client:"前端"};function ae(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function te(n){if(!n)return"";const f=Date.parse(n);if(Number.isNaN(f))return"";const r=Math.max(0,(Date.now()-f)/1e3),m=[[31536e3,"年"],[2592e3,"个月"],[86400,"天"],[3600,"小时"],[60,"分钟"]];for(const[p,j]of m)if(r>=p)return`${Math.floor(r/p)} ${j}前`;return"刚刚"}function oe({plugins:n,onRefresh:f}){const[r,m]=s.useState(null),[p,j]=s.useState(null),[v,P]=s.useState([]),[N,O]=s.useState(!1),[$,B]=s.useState(!1),[C,A]=s.useState(null),[L,M]=s.useState(""),[u,U]=s.useState("relevance"),[w,W]=s.useState("all"),[b,J]=s.useState("all"),[g,V]=s.useState("plugin"),c=e=>{j(e),setTimeout(()=>j(null),2500)},T=s.useCallback(async()=>{O(!0),A(null);try{const e=await S("/api/marketplace?q=");P(e.packages??[]),e.warning&&A(e.warning)}catch{c("无法加载插件市场")}O(!1),B(!0)},[]);s.useEffect(()=>{T()},[T]);const z=s.useMemo(()=>new Set(n.map(e=>e.name)),[n]),D=s.useMemo(()=>{const e=L.trim().toLowerCase(),l=v.map(t=>({...t,installed:t.installed||z.has(t.name)})).filter(t=>!(g!=="all"&&(t.category??"plugin")!==g||w==="official"&&!t.official||w==="community"&&t.official||b==="installed"&&!t.installed||b==="available"&&t.installed||e&&!`${t.name} ${t.description} ${(t.keywords??[]).join(" ")} ${t.author??""}`.toLowerCase().includes(e)));return u==="relevance"?l:l.sort((t,i)=>u==="downloads"?(i.downloads??0)-(t.downloads??0):u==="score"?(i.score??0)-(t.score??0):u==="updated"?Date.parse(i.updated??"0")-Date.parse(t.updated??"0"):0)},[v,z,L,u,w,b,g]),G=async(e,l)=>{var x,o,E;let t="";try{const{manifest:h}=await S(`/api/marketplace/manifest?name=${encodeURIComponent(e)}`),d=h==null?void 0:h.service;if(d){const y=[];(x=d.required)!=null&&x.length&&y.push(`需要服务: ${d.required.join(", ")}`),(o=d.optional)!=null&&o.length&&y.push(`可选服务: ${d.optional.join(", ")}`),(E=d.provides)!=null&&E.length&&y.push(`提供服务: ${d.provides.join(", ")}`),y.length&&(t=`
12
+
13
+ 该插件声明:
14
+ ${y.join(`
15
+ `)}`)}}catch{}const i=l?"官方插件":"第三方社区插件";if(window.confirm(`将从 npm 安装${i}「${e}」。${t}
16
+
17
+ 安装后它会以你授予的能力运行(可在权限页查看其依赖与权限)。请确认来源可信。
18
+
19
+ 继续安装?`)){m(e);try{const h=await S("/api/marketplace/install",{method:"POST",body:JSON.stringify({name:e})});h.ok?(c(`${e} 安装成功,正在重启...`),f()):c(h.error??"安装失败")}catch{c("安装失败")}m(null)}},Y=async e=>{if(window.confirm(`确定卸载「${e}」?
20
+
21
+ 将删除其代码目录并清除残留配置。不可恢复,但可从市场重新安装。
22
+
23
+ 继续卸载?`)){m(e);try{const l=await S("/api/marketplace/uninstall",{method:"POST",body:JSON.stringify({name:e})});l.ok?(c(l.message??`${e} 已卸载`),f()):c(l.error??"卸载失败")}catch{c("卸载失败")}m(null)}};return a.jsxs("div",{className:"page-content page-marketplace",children:[p&&a.jsx("div",{className:"toast",children:p}),a.jsxs("div",{className:"section-label",children:["插件市场",$&&a.jsxs("span",{className:"market-count",children:["显示 ",D.length," / 共 ",v.length]})]}),a.jsxs("div",{className:"market-filter-row",children:[a.jsx("input",{className:"config-edit-input",style:{flex:1,minWidth:180},placeholder:"搜索插件(名称 / 描述 / 关键词 / 作者)",value:L,onChange:e=>M(e.target.value)}),a.jsx("select",{className:"config-edit-input",value:g,onChange:e=>V(e.target.value),title:"组件类型",children:Object.keys(R).map(e=>a.jsx("option",{value:e,children:R[e]},e))}),a.jsx("select",{className:"config-edit-input",value:w,onChange:e=>W(e.target.value),children:Object.keys(F).map(e=>a.jsx("option",{value:e,children:F[e]},e))}),a.jsx("select",{className:"config-edit-input",value:b,onChange:e=>J(e.target.value),children:Object.keys(I).map(e=>a.jsx("option",{value:e,children:I[e]},e))}),a.jsx("select",{className:"config-edit-input",value:u,onChange:e=>U(e.target.value),title:"排序",children:Object.keys(_).map(e=>a.jsx("option",{value:e,children:_[e]},e))}),a.jsx("button",{className:"btn-sm",onClick:()=>T(),disabled:N,children:N?"加载中...":"刷新"})]}),!$&&N&&a.jsxs("div",{className:"empty-hint",style:{padding:16},children:["正在从 npm 加载带 ",a.jsx("code",{children:"aalis-plugin"})," 标签的插件…"]}),C&&a.jsx("div",{className:"empty-hint",style:{padding:12,color:"var(--warning, #ffb300)"},children:C}),$&&D.length===0&&!N&&!C&&a.jsx("div",{className:"empty-hint",style:{padding:16},children:v.length===0?"未找到任何插件":"无匹配项 —— 试试调整搜索词或筛选条件"}),a.jsx("div",{className:"marketplace-grid",children:D.map(e=>{var t,i,x;const l=((t=e.links)==null?void 0:t.homepage)||((i=e.links)==null?void 0:i.repository)||((x=e.links)==null?void 0:x.npm);return a.jsxs("div",{className:"marketplace-card",children:[a.jsxs("div",{className:"marketplace-card-info",children:[l?a.jsx("a",{className:"marketplace-card-name",href:l,target:"_blank",rel:"noreferrer",children:e.name}):a.jsx("span",{className:"marketplace-card-name",children:e.name}),a.jsxs("span",{className:"marketplace-card-version",children:["v",e.version]}),a.jsx("span",{className:`badge ${e.official?"official":"community"}`,children:e.official?"官方":"社区"}),e.category&&e.category!=="plugin"&&a.jsx("span",{className:"badge",title:"组件类别",children:e.category==="api"?"API 契约":"前端"}),e.insecure&&a.jsxs("span",{className:"badge",style:{background:"var(--danger)",color:"#fff",display:"inline-flex",alignItems:"center",gap:3},title:"npm 标记为不安全包,谨慎安装",children:[a.jsx(k,{size:11})," 不安全"]}),e.author&&a.jsxs("span",{className:"marketplace-card-author",children:["by ",e.author]}),e.installed&&a.jsx("span",{className:"badge active",children:"已安装"})]}),a.jsx("div",{className:"marketplace-card-desc",children:e.description||"(无描述)"}),e.keywords&&e.keywords.length>0&&a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:e.keywords.slice(0,6).map(o=>a.jsx("button",{type:"button",className:"market-kw",title:`按 “${o}” 筛选`,onClick:()=>M(o),children:o},o))}),a.jsxs("div",{className:"market-meta",children:[e.downloads!=null&&a.jsxs("span",{className:"market-meta-item",title:"近一月下载量",children:[a.jsx(H,{size:12})," ",ae(e.downloads),"/月"]}),e.updated&&a.jsxs("span",{className:"market-meta-item",title:new Date(e.updated).toLocaleString(),children:[a.jsx(K,{size:12})," ",te(e.updated)]}),e.score!=null&&a.jsxs("span",{className:"market-meta-item",style:{color:"var(--warning)"},title:e.scoreDetail?`质量 ${((e.scoreDetail.quality??0)*100).toFixed(0)}% · 人气 ${((e.scoreDetail.popularity??0)*100).toFixed(0)}% · 维护 ${((e.scoreDetail.maintenance??0)*100).toFixed(0)}%`:`综合评分 ${(e.score*100).toFixed(0)}%`,children:[a.jsx(ee,{size:12})," ",(e.score*5).toFixed(1)]}),e.license&&a.jsxs("span",{className:"market-meta-item",title:"许可证",children:[a.jsx(X,{size:12})," ",e.license]})]}),a.jsxs("div",{style:{marginTop:8},children:[!e.installed&&a.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>G(e.name,e.official),disabled:r===e.name,children:r===e.name?"安装中...":"安装"}),e.installed&&e.removable&&a.jsx("button",{className:"btn btn-sm",style:{color:"var(--danger)"},onClick:()=>Y(e.name),disabled:r===e.name,title:"卸载插件(删包 + 清配置)",children:r===e.name?"处理中...":"卸载"})]})]},e.name)})})]})}export{oe as MarketplacePage};
@@ -0,0 +1,6 @@
1
+ import{r as c,j as e}from"./react-vendor-BPQixOLZ.js";import{c as p,a as h}from"./index-D4hgfekH.js";import{G as x}from"./globe-bFIW3FVE.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const j=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],f=p("plug",j);function k(){const[t,n]=c.useState([]),[i,d]=c.useState(!0),l=c.useCallback(async()=>{d(!0);try{const a=await h("/api/platforms");n(a.platforms??[])}catch{n([])}d(!1)},[]);c.useEffect(()=>{l();const a=setInterval(l,5e3);return()=>clearInterval(a)},[l]);const o=t.reduce((a,s)=>a+s.connections.length,0),m=t.reduce((a,s)=>a+s.connections.filter(r=>r.status==="online").length,0);return e.jsxs("div",{className:"page-content page-platforms",children:[e.jsx("div",{className:"section-label",children:"概览"}),e.jsxs("div",{className:"overview-grid",children:[e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(f,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"适配器"}),e.jsx("div",{className:"overview-card-value",children:t.length})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(x,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"连接数"}),e.jsxs("div",{className:"overview-card-value",children:[m," / ",o]})]})]})]}),e.jsxs("div",{className:"section-label",style:{display:"flex",alignItems:"center",gap:8},children:["适配器列表",e.jsx("button",{className:"btn-sm",onClick:l,disabled:i,children:i?"刷新中...":"刷新"})]}),t.length===0&&!i&&e.jsx("div",{className:"empty-hint",children:"暂无平台适配器。请启用并配置平台适配器插件。"}),t.map(a=>e.jsxs("div",{className:"platform-card",children:[e.jsxs("div",{className:"platform-card-header",children:[e.jsx("span",{className:"platform-card-name",children:a.adapterName}),e.jsx("span",{className:"platform-card-id",children:a.platform})]}),a.connections.length===0?e.jsx("div",{className:"platform-no-connections",children:"无活跃连接"}):e.jsx("div",{className:"platform-connections",children:a.connections.map(s=>e.jsxs("div",{className:"platform-connection",children:[e.jsx("span",{className:`platform-status-dot ${s.status}`}),e.jsx("span",{className:"platform-conn-id",children:s.selfId??s.id}),e.jsx("span",{className:`platform-conn-status ${s.status}`,children:s.status==="online"?"在线":s.status==="connecting"?"连接中":"离线"}),s.detail&&Object.keys(s.detail).length>0&&e.jsx("span",{className:"platform-conn-detail",children:Object.entries(s.detail).map(([r,v])=>`${r}: ${String(v)}`).join(", ")})]},s.id))})]},a.contextId))]})}export{k as PlatformPage};
@@ -0,0 +1,23 @@
1
+ import{r as d,j as e}from"./react-vendor-BPQixOLZ.js";import{c as _,a as S,T as Ae}from"./index-D4hgfekH.js";import{b as K,S as ye,f as Ne,u as Re}from"./SchemaForm-YVQZ6Keg.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ge=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Je=_("link-2",Ge);/**
7
+ * @license lucide-react v1.7.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Ke=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ze=_("loader-circle",Ke);/**
12
+ * @license lucide-react v1.7.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const He=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],We=_("radio",He);/**
17
+ * @license lucide-react v1.7.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Qe=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],Xe=_("workflow",Qe);function Z({label:f,value:r,depth:u=0,secret:O,description:v,defaultValue:y}){const[p,I]=d.useState(u<1);if(Array.isArray(r))return r.length===0?e.jsxs("div",{className:"config-item",style:{paddingLeft:u*12},children:[e.jsxs("span",{className:"key",children:[e.jsx("code",{className:"field-key",children:f}),v&&e.jsxs("span",{className:"field-hint",children:[" / ",v]})]}),e.jsx("span",{className:"val",children:"(空)"})]}):e.jsxs("div",{className:"config-nested",style:{paddingLeft:u*12},children:[e.jsxs("div",{className:"config-nested-header",onClick:()=>I(h=>!h),children:[e.jsx("span",{className:`config-block-toggle ${p?"open":""}`,children:"▶"}),e.jsxs("span",{className:"key",children:[e.jsx("code",{className:"field-key",children:f}),v&&e.jsxs("span",{className:"field-hint",children:[" / ",v]})]}),e.jsxs("span",{className:"config-nested-count",children:[r.length," 项"]})]}),p&&e.jsx("div",{className:"config-nested-body",children:r.map((h,b)=>e.jsx(Z,{label:`#${b+1}`,value:h,depth:u+1,secret:O},b))})]});if(r==null||typeof r!="object"){const h=O||typeof r=="string"&&/(apiKey|password|secret|token)(?![a-zA-Z])/i.test(f),b=r==null,w=b&&y!==void 0&&y!==null,k=b?w?typeof y=="object"?JSON.stringify(y):String(y):"-":String(r),M=h&&k.length>4?k.slice(0,4)+"••••••":k;return e.jsxs("div",{className:"config-item",style:{paddingLeft:u*12},children:[e.jsxs("span",{className:"key",children:[e.jsx("code",{className:"field-key",children:f}),v&&e.jsxs("span",{className:"field-hint",children:[" / ",v]})]}),e.jsxs("span",{className:"val",title:h?"••••••":k,children:[M,w&&e.jsx("span",{className:"field-hint",children:" (默认)"})]})]})}const z=Object.entries(r);return e.jsxs("div",{className:"config-nested",style:{paddingLeft:u*12},children:[e.jsxs("div",{className:"config-nested-header",onClick:()=>I(h=>!h),children:[e.jsx("span",{className:`config-block-toggle ${p?"open":""}`,children:"▶"}),e.jsx("span",{className:"key",children:f}),e.jsxs("span",{className:"config-nested-count",children:[z.length," 项"]})]}),p&&e.jsx("div",{className:"config-nested-body",children:z.map(([h,b])=>e.jsx(Z,{label:h,value:b,depth:u+1,secret:O},h))})]})}function ts({plugins:f,config:r,onRefresh:u,onConfigSaved:O,onRestart:v}){const[y,p]=d.useState(new Set),I=d.useRef(f),[z,h]=d.useState(null),[b,w]=d.useState({}),[k,M]=d.useState({}),[D,H]=d.useState({}),[F,W]=d.useState(void 0),[Q,X]=d.useState(null),[Y,V]=d.useState(!1),[ve,Se]=d.useState(new Set),[q,ee]=d.useState(""),[ke,Ce]=d.useState(new Set),[se,B]=d.useState(null),[U,A]=d.useState("");d.useEffect(()=>{I.current!==f&&y.size>0&&p(new Set),I.current=f},[f,y]);const P=s=>p(t=>new Set(t).add(s)),C=s=>y.has(s),j=s=>{X(s),setTimeout(()=>X(null),2500)},we=async s=>{if(s.core)return;P(s.instanceId);const t=s.state==="disabled"?"enable":"disable",i=await S(`/api/plugins/${encodeURIComponent(s.instanceId)}/${t}`,{method:"POST"});i.ok?(j(`${s.instanceId} 已${t==="enable"?"启用":"禁用"}`),u()):(j(i.error??"未知错误"),p(l=>{const x=new Set(l);return x.delete(s.instanceId),x}))},$e=s=>{const t=s.config??{};s.configSchema?M(K(s.configSchema,t)):w(Ne(t)),h(s.instanceId)},ne=d.useCallback(async s=>{if(!D[s])try{const t=await S(`/api/models/${encodeURIComponent(s)}`),i=t.providers&&t.providers.length>0?t.providers.map(l=>({label:`${l.provider} / ${l.model}`,value:l.value})):(t.models??[]).map(l=>({label:l,value:l}));H(l=>({...l,[s]:i}))}catch{H(t=>({...t,[s]:[]}))}},[D]),ae=d.useCallback(async()=>{if(!F)try{const s=await S("/api/llm-providers");W(s.providers??[])}catch{W([])}},[F]),te=s=>{const t=s.defaultConfig??{};s.configSchema?M(K(s.configSchema,t)):w(Ne(t))},ie=async(s,t)=>{const i=t?k:Re(b);P(s),await S(`/api/plugins/${encodeURIComponent(s)}/config`,{method:"PUT",body:JSON.stringify({config:i})}),j(`${s} 配置已更新,正在重载…`),h(null),u()},ce=async s=>{const t=U.trim();if(!t)return;P(s);const i=await S(`/api/plugins/${encodeURIComponent(s)}/instances`,{method:"POST",body:JSON.stringify({suffix:t})});i.ok?(j(`已创建实例 ${i.instanceId}`),B(null),A(""),u()):(j(i.error??"创建失败"),p(l=>{const x=new Set(l);return x.delete(s),x}))},Le=async s=>{if(!confirm(`确定删除实例 "${s}"?配置将一并移除。`))return;P(s);const t=await S(`/api/plugins/${encodeURIComponent(s)}/instance`,{method:"DELETE"});t.ok?(j(`已删除实例 ${s}`),u()):(j(t.error??"删除失败"),p(i=>{const l=new Set(i);return l.delete(s),l}))},Oe=new Set(["@aalis/core","@aalis/plugin-package-manager","@aalis/plugin-webui-server","@aalis/plugin-webui-client"]),Ie=s=>Oe.has(s)||/-api$/.test(s.replace(/^@[^/]+\//,"")),Me=async s=>{if(!confirm(`确定卸载插件「${s.displayName??s.name}」(${s.name})?
22
+
23
+ 将删除其代码目录并清除残留配置。不可恢复,但可从插件市场重新安装。`))return;P(s.instanceId);const t=await S("/api/marketplace/uninstall",{method:"POST",body:JSON.stringify({name:s.name})});t.ok?(j(t.message??`${s.name} 已卸载`),u()):(j(t.error??"卸载失败"),p(i=>{const l=new Set(i);return l.delete(s.instanceId),l}))},Pe=s=>s.instanceId!==s.name,Te={active:"运行中",disabled:"已禁用",pending:"等待中",disposed:"已释放",error:"运行错误"},Ee={active:"active",disabled:"disposed",pending:"pending",error:"error"},ze=s=>{Se(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},[le,R]=d.useState(!1),[oe,re]=d.useState({}),$=r&&r._schema?r._schema:void 0;d.useEffect(()=>{r&&$&&re(K($,r))},[r,$]);const De=async()=>{V(!0);const s=await S("/api/config",{method:"PUT",body:JSON.stringify(oe)});V(!1),s.ok?(R(!1),O(),s.restart?v():j("全局配置已保存")):j(s.error??"未知错误")};return e.jsxs("div",{className:"page-content page-plugin-config",children:[Q&&e.jsx("div",{className:"toast",children:Q}),e.jsxs("div",{className:"config-header-row",children:[e.jsx("div",{className:"section-label",style:{marginBottom:0},children:"全局配置"}),e.jsx("div",{style:{display:"flex",gap:6},children:le?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-primary btn-sm",onClick:De,disabled:Y,children:Y?"保存中...":"保存"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>R(!1),children:"取消"})]}):e.jsx("button",{className:"btn btn-sm",onClick:()=>R(!0),children:"编辑"})})]}),r&&$&&e.jsx("div",{className:"config-block",style:{marginTop:8,marginBottom:20},children:e.jsx("div",{className:"config-block-body",style:{paddingTop:10},children:le?e.jsx(ye,{schema:$,draft:oe,onChange:re,modelCache:D,onFetchModels:ne,llmProviders:F,onFetchLLMProviders:ae}):e.jsx(e.Fragment,{children:Object.entries($).map(([s,t])=>{const i=r[s],l=t,x=l.description||l.label;return e.jsxs("div",{className:"config-item",children:[e.jsxs("span",{className:"key",children:[e.jsx("code",{className:"field-key",children:s}),x&&e.jsxs("span",{className:"field-hint",children:[" / ",x]})]}),e.jsx("span",{className:"val",children:l.type==="boolean"?i?"✓ 开启":"✗ 关闭":i===""||i==null?"(空)":String(i)})]},s)})})})}),e.jsx("div",{className:"section-label",style:{marginBottom:0},children:"插件管理"}),e.jsxs("div",{className:"plugin-search-row",children:[e.jsx("input",{className:"plugin-search-input",placeholder:"搜索插件 / 工具名 / 指令名...",value:q,onChange:s=>ee(s.target.value)}),q&&e.jsx("button",{className:"plugin-search-clear",onClick:()=>ee(""),children:"✕"})]}),f.length===0&&e.jsx("div",{className:"empty-hint",children:"无插件"}),(()=>{const s=q.toLowerCase(),t=s?f.filter(c=>c.name.toLowerCase().includes(s)||c.instanceId.toLowerCase().includes(s)||c.displayName&&c.displayName.toLowerCase().includes(s)||c.provides.some(o=>o.toLowerCase().includes(s))||(c.tools??[]).some(o=>o.toLowerCase().includes(s))||(c.commands??[]).some(o=>o.toLowerCase().includes(s))):f,i={},l=["系统","LLM 模型","智能体","存储","嵌入模型","向量存储","工具","界面","适配器","自动化","其他"];for(const c of t){const o=c.name,N=c.core?"系统":/^(@aalis\/)?plugin-(openai|deepseek|ollama)$/.test(o)?"LLM 模型":/^(@aalis\/)?plugin-agent/.test(o)||/^(@aalis\/)?plugin-persona$/.test(o)?"智能体":/^(@aalis\/)?plugin-memory-/.test(o)?"存储":/^(@aalis\/)?plugin-embedding-/.test(o)?"嵌入模型":/^(@aalis\/)?plugin-vectorstore-/.test(o)?"向量存储":/^(@aalis\/)?plugin-(tool-|tools-|websearch-)/.test(o)?"工具":/^(@aalis\/)?plugin-(webui-|cli)/.test(o)?"界面":/^(@aalis\/)?plugin-adapter-/.test(o)?"适配器":/^(@aalis\/)?plugin-(scheduler|skills)$/.test(o)?"自动化":/^(@aalis\/)?plugin-(commands|authority)$/.test(o)?"系统":"其他";i[c.instanceId]=N}const x=new Map;for(const c of l)x.set(c,[]);for(const c of t){const o=i[c.instanceId]||"其他";x.get(o).push(c)}const Fe=c=>{Ce(o=>{const N=new Set(o);return N.has(c)?N.delete(c):N.add(c),N})};return Array.from(x.entries()).filter(([,c])=>c.length>0).map(([c,o])=>{const N=ke.has(c);return e.jsxs("div",{className:"plugin-category",children:[e.jsxs("div",{className:"plugin-category-header",onClick:()=>Fe(c),children:[e.jsx("span",{className:`config-block-toggle ${N?"":"open"}`,children:"▶"}),e.jsx("span",{className:"plugin-category-name",children:c}),e.jsx("span",{className:"plugin-category-count",children:o.length})]}),!N&&o.map(n=>{var he,ge,fe,ue,xe,pe,be;const g=n.instanceId,_e=z===g,T=ve.has(g),L=Pe(n),de=L?g.slice(n.name.length+1):void 0,me=n.extends&&(((he=n.extends.events)==null?void 0:he.length)||((ge=n.extends.hooks)==null?void 0:ge.length)||n.extends.mixins&&Object.keys(n.extends.mixins).length),G=me||n.config&&Object.keys(n.config).length>0||!!n.configSchema,J=!!n.configSchema;return e.jsxs("div",{className:`plugin-card ${n.state==="disabled"?"disabled":""} ${n.state==="error"?"errored":""}`,style:{position:"relative"},children:[C(g)&&e.jsxs("div",{className:"plugin-reload-overlay",children:[e.jsx(Ze,{size:20,className:"plugin-reload-spinner"}),e.jsx("span",{children:"重载中…"})]}),e.jsxs("div",{className:"plugin-card-header",children:[e.jsxs("div",{className:"plugin-card-info",style:{cursor:G?"pointer":"default"},onClick:()=>G&&ze(g),children:[G&&e.jsx("span",{className:`config-block-toggle ${T?"open":""}`,children:"▶"}),e.jsxs("span",{className:"plugin-card-name",children:[n.displayName??n.name,n.displayName&&e.jsx("span",{className:"plugin-card-module-name",children:n.name}),de&&e.jsxs("span",{className:"plugin-instance-suffix",children:[":",de]})]}),e.jsx("span",{className:`badge ${Ee[n.state]??"pending"}`,children:Te[n.state]??n.state}),n.core&&e.jsx("span",{className:"badge core-badge",children:"核心"}),n.reusable&&!L&&e.jsx("span",{className:"badge",style:{background:"#7c5cfc",color:"#fff",fontSize:10},children:"多实例"}),n.provides.length>0&&e.jsx("span",{className:"plugin-provides-inline",children:n.provides.map(a=>e.jsx("span",{className:"provides-chip",children:a},a))})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[L&&e.jsx("button",{className:"btn btn-sm",style:{color:"#e55",fontSize:11},onClick:()=>Le(g),disabled:C(g),children:"删除"}),!L&&!n.core&&!Ie(n.name)&&e.jsx("button",{className:"btn btn-sm",style:{color:"#e55",fontSize:11},onClick:()=>Me(n),disabled:C(g),title:"卸载插件(删包 + 清配置)",children:"卸载"}),n.reusable&&!L&&e.jsx("button",{className:"btn btn-sm",style:{fontSize:11},onClick:()=>{B(se===n.name?null:n.name),A("")},children:"+ 实例"}),e.jsxs("label",{className:`toggle-switch ${n.core?"core-locked":""}`,children:[e.jsx("input",{type:"checkbox",checked:n.state!=="disabled",onChange:()=>we(n),disabled:n.core||C(g)}),e.jsx("span",{className:"toggle-slider"})]})]})]}),se===n.name&&!L&&e.jsxs("div",{className:"plugin-new-instance-row",style:{display:"flex",gap:6,padding:"6px 12px",alignItems:"center"},children:[e.jsxs("span",{style:{fontSize:12,opacity:.7},children:[n.name,":"]}),e.jsx("input",{style:{flex:1,fontSize:12},className:"plugin-search-input",placeholder:"输入实例后缀(如 vision)",value:U,onChange:a=>A(a.target.value),onKeyDown:a=>a.key==="Enter"&&ce(n.name)}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>ce(n.name),disabled:!U.trim()||C(n.name),children:"创建"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>B(null),children:"取消"})]}),n.state==="error"&&n.error&&e.jsxs("div",{className:"plugin-error-msg",children:[e.jsx(Ae,{size:14})," ",n.error]}),T&&n.provides.length>0&&e.jsx("div",{className:"plugin-card-provides",children:n.provides.map(a=>e.jsx("span",{className:"tool-chip",children:a},a))}),T&&((((fe=n.requiredServices)==null?void 0:fe.length)??0)>0||(((ue=n.optionalServices)==null?void 0:ue.length)??0)>0||(((xe=n.capabilities)==null?void 0:xe.length)??0)>0)&&e.jsxs("div",{className:"plugin-card-caps",children:[(n.requiredServices??[]).map(a=>e.jsxs("span",{className:"cap-chip dep-required",title:"必需依赖的服务",children:["需 ",a]},`req-${a}`)),(n.optionalServices??[]).map(a=>e.jsxs("span",{className:"cap-chip dep-optional",title:"可选依赖的服务",children:["可选 ",a]},`opt-${a}`)),(n.capabilities??[]).map(a=>e.jsx("span",{className:`cap-chip ${a==="safety:dangerous"?"cap-danger":"cap-sensitive"}`,title:"触达的敏感能力",children:a==="safety:dangerous"?"⚠ 高危操作":a},`cap-${a}`))]}),T&&me&&e.jsxs("div",{className:"plugin-card-extends",children:[e.jsx("span",{className:"extends-label",children:"扩展 Core:"}),(pe=n.extends.events)==null?void 0:pe.map(a=>e.jsxs("span",{className:"extends-chip event",children:[e.jsx(We,{size:12})," ",a]},`e-${a}`)),(be=n.extends.hooks)==null?void 0:be.map(a=>e.jsxs("span",{className:"extends-chip hook",children:[e.jsx(Xe,{size:12})," ",a]},`h-${a}`)),n.extends.mixins&&Object.entries(n.extends.mixins).map(([a,E])=>E.map(m=>e.jsxs("span",{className:"extends-chip mixin",children:[e.jsx(Je,{size:12})," ctx.",m,"()"]},`m-${a}-${m}`)))]}),T&&(n.config&&Object.keys(n.config).length>0||J)&&e.jsx("div",{className:"plugin-card-config",children:_e?J?e.jsxs(e.Fragment,{children:[e.jsx(ye,{schema:n.configSchema,draft:k,onChange:M,modelCache:D,onFetchModels:ne,llmProviders:F,onFetchLLMProviders:ae}),e.jsxs("div",{className:"config-edit-actions",children:[e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>ie(g,!0),disabled:C(g),children:"保存"}),n.defaultConfig&&Object.keys(n.defaultConfig).length>0&&e.jsx("button",{className:"btn btn-warn btn-sm",onClick:()=>te(n),children:"恢复默认"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>h(null),children:"取消"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"config-edit-form",children:Object.keys(b).map(a=>e.jsxs("div",{className:"config-edit-row",children:[e.jsx("label",{className:"config-edit-label",children:a}),e.jsx("input",{className:"config-edit-input",type:/(apiKey|password|secret|token)(?![a-zA-Z])/i.test(a)?"password":"text",value:b[a],onChange:E=>w(m=>({...m,[a]:E.target.value}))})]},a))}),e.jsxs("div",{className:"config-edit-actions",children:[e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>ie(g,!1),disabled:C(g),children:"保存"}),n.defaultConfig&&Object.keys(n.defaultConfig).length>0&&e.jsx("button",{className:"btn btn-warn btn-sm",onClick:()=>te(n),children:"恢复默认"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>h(null),children:"取消"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"config-block-body",style:{paddingTop:6},children:(J?Object.keys(n.configSchema).map(a=>[a,n.config[a]]):Object.entries(n.config)).map(([a,E])=>{var je;const m=(je=n.configSchema)==null?void 0:je[a],qe=m&&"secret"in m?m.secret:void 0,Be=m&&"description"in m?m.description:m&&"label"in m?m.label:void 0,Ue=m&&"default"in m?m.default:void 0;return e.jsx(Z,{label:a,value:E,secret:qe,description:Be,defaultValue:Ue},a)})}),e.jsx("button",{className:"btn btn-sm",onClick:()=>$e(n),children:"编辑配置"})]})})]},g)})]},c)})})()]})}export{ts as PluginConfigPage};
@@ -0,0 +1 @@
1
+ import{j as e,r as S}from"./react-vendor-BPQixOLZ.js";function I({value:s,onChange:d,className:a}){const o=s==null||s===""?"":String(s),[t,i]=S.useState(o),x=S.useRef(o);return S.useEffect(()=>{const r=s==null||s===""?"":String(s);if(r!==x.current){x.current=r;const n=t===""?"":Number(t);if(String(n)!==t)return;i(r)}},[s]),e.jsx("input",{className:a,type:"text",inputMode:"decimal",value:t,onChange:r=>{const n=r.target.value;i(n),n===""||n==="-"?d(""):(!n.endsWith(".")&&!n.endsWith("0")&&!isNaN(Number(n))||!n.endsWith(".")&&!isNaN(Number(n)))&&d(Number(n))},onBlur:r=>{const n=r.target.value;if(n===""||n==="-")d(""),i("");else{const y=Number(n);isNaN(y)?i(x.current):(d(y),x.current=String(y))}}})}function k(s,d=""){const a={};for(const[o,t]of Object.entries(s)){const i=d?`${d}.${o}`:o;t&&typeof t=="object"&&!Array.isArray(t)?Object.assign(a,k(t,i)):a[i]=t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}return a}function E(s){const d={};for(const[a,o]of Object.entries(s)){const t=a.split(".");let i=d;for(let r=0;r<t.length-1;r++)(!(t[r]in i)||typeof i[t[r]]!="object")&&(i[t[r]]={}),i=i[t[r]];const x=t[t.length-1];try{i[x]=JSON.parse(o)}catch{i[x]=o}}return d}function w(s){return"type"in s&&s.type!=="array"}function A(s){return"type"in s&&s.type==="array"}function K(s,d){const a={};for(const[o,t]of Object.entries(s))if(A(t)){const i=d[o];a[o]=Array.isArray(i)?i:t.default??[]}else if(w(t))a[o]=d[o]??t.default??(t.type==="number"?0:t.type==="boolean"?!1:t.type==="multiselect"?[]:"");else{const i={},x=d[o]??{};for(const[r,n]of Object.entries(t.fields))i[r]=x[r]??n.default??(n.type==="number"?0:n.type==="boolean"?!1:n.type==="multiselect"?[]:"");a[o]=i}for(const[o,t]of Object.entries(d))o in a||(a[o]=t);return a}function z({value:s,onChange:d,llmProviders:a,onFetchLLMProviders:o}){S.useEffect(()=>{a||o()},[]);const t=s&&typeof s=="object"?s:{},i=t.provider??"",x=t.model??"",r=i&&x?`${i}/${x}`:"",[n,y]=S.useState("idle"),[m,p]=S.useState(""),b=async()=>{if(i){y("loading"),p("刷新中…");try{const c=await fetch(`/api/llm-providers/${encodeURIComponent(i)}/refresh`,{method:"POST"}),u=await c.json().catch(()=>({}));if(!c.ok){y("error"),p((u==null?void 0:u.error)??`HTTP ${c.status}`);return}o();const f=Array.isArray(u.added)?u.added.length:0,g=Array.isArray(u.removed)?u.removed.length:0;y("ok"),p(f||g?`+${f} / -${g}`:`共 ${u.total??0} 个`),setTimeout(()=>y("idle"),3e3)}catch(c){y("error"),p(c.message)}}},j=[];for(const c of a??[]){const u=c.label??c.contextId;for(const f of c.models){const g=f.capabilities.length>0?` [${f.capabilities.join(",")}]`:"";j.push({key:`${c.contextId}/${f.id}`,provider:c.contextId,model:f.id,label:`${u} / ${f.id}${g}`})}}return r&&!j.some(c=>c.key===r)&&j.unshift({key:r,provider:i,model:x,label:`${i} / ${x} (已离线)`}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[e.jsxs("select",{className:"config-edit-input",style:{flex:"1 1 320px",minWidth:0},value:r,onChange:c=>{const u=c.target.value;if(!u){d(void 0);return}const f=j.find(g=>g.key===u);f&&d({provider:f.provider,model:f.model})},children:[e.jsx("option",{value:"",children:"— 继承默认 —"}),j.map(c=>e.jsx("option",{value:c.key,children:c.label},c.key))]}),e.jsx("button",{type:"button",className:"config-edit-btn",style:{fontSize:11,padding:"2px 8px"},onClick:b,disabled:!i||n==="loading",title:i?`重新探测 ${i} 的远端模型列表(仅对动态发现型 provider 如 Ollama 生效)`:"先选模型后才能刷新对应 provider",children:n==="loading"?"⟳":"⟳ 刷新"}),m&&e.jsx("span",{style:{fontSize:11,color:n==="error"?"#c62828":n==="ok"?"#2e7d32":"#666"},children:m})]})}function $({field:s,fieldKey:d,value:a,onChange:o,modelCache:t,onFetchModels:i,llmProviders:x,onFetchLLMProviders:r}){var y;if(s.type==="boolean")return e.jsxs("label",{className:"config-edit-label",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:!!a,onChange:m=>o(m.target.checked)}),s.label]});if(s.type==="multiselect"){const m=Array.isArray(a)?a:[],p=s.dynamicOptions,b=p?t[p]:void 0;S.useEffect(()=>{p&&!t[p]&&i(p)},[p]);const j=s.options??[],c=b??[],u=[...j];for(const l of c)u.some(N=>String(N.value)===String(l.value))||u.push(l);for(const l of m)u.some(N=>String(N.value)===l)||u.push({label:l,value:l});const f=l=>{const N=m.includes(l)?m.filter(O=>O!==l):[...m,l];o(N)},[g,v]=S.useState(""),h=()=>{const l=g.replace(/^[\r\n\t]+|[\r\n\t]+$/g,"");l&&!m.includes(l)&&o([...m,l]),v("")};return e.jsxs("div",{className:"multiselect-group",children:[u.map(l=>e.jsxs("label",{className:"multiselect-item",children:[e.jsx("input",{type:"checkbox",checked:m.includes(String(l.value)),onChange:()=>f(String(l.value))}),l.label]},String(l.value))),s.allowCustom&&e.jsxs("div",{style:{display:"flex",gap:4,marginTop:4},children:[e.jsx("input",{className:"config-edit-input",style:{flex:1,fontSize:12},type:"text",placeholder:"手动输入...",value:g,onChange:l=>v(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),h())}}),e.jsx("button",{className:"config-edit-btn",style:{fontSize:11,padding:"2px 8px"},onClick:h,children:"添加"})]})]})}if(s.type==="llm-ref")return e.jsx(z,{value:a,onChange:o,llmProviders:x,onFetchLLMProviders:r});if(s.type==="select"||s.type==="string"&&((y=s.options)!=null&&y.length||s.dynamicOptions)){const m=s.dynamicOptions,p=m?t[m]:void 0;S.useEffect(()=>{m&&!t[m]&&i(m)},[m]);const b=s.options??[],j=p??[],c=[...b];for(const f of j)c.some(g=>String(g.value)===String(f.value))||c.push(f);const u=String(a??"");return u&&!c.some(f=>String(f.value)===u)&&c.unshift({label:u,value:u}),e.jsxs("select",{className:"config-edit-input",value:u,onChange:f=>o(f.target.value),children:[c.length===0&&e.jsx("option",{value:"",children:"加载中..."}),c.map(f=>e.jsx("option",{value:String(f.value),children:f.label},String(f.value)))]})}if(s.type==="number")return e.jsx(I,{className:"config-edit-input",value:a,onChange:o});if(s.type==="textarea")return e.jsx("textarea",{className:"config-edit-input config-textarea",value:String(a??""),onChange:m=>o(m.target.value),rows:3});const n=s.secret||/(apiKey|password|secret|token)(?![a-zA-Z])/i.test(d);return e.jsx("input",{className:"config-edit-input",type:n?"password":"text",value:String(a??""),onChange:m=>o(m.target.value)})}function L({schema:s,draft:d,onChange:a,modelCache:o,onFetchModels:t,llmProviders:i,onFetchLLMProviders:x}){return e.jsx("div",{className:"config-edit-form",children:Object.entries(s).map(([r,n])=>{if(w(n)){const p=n.description||n.label;return e.jsxs("div",{className:"config-edit-row",children:[e.jsxs("label",{className:"config-edit-label",title:n.description,children:[e.jsx("code",{className:"field-key",children:r}),p&&e.jsxs("span",{className:"field-hint",children:[" / ",p]}),n.required&&e.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),e.jsx($,{field:n,fieldKey:r,value:d[r],onChange:b=>a({...d,[r]:b}),modelCache:o,onFetchModels:t,llmProviders:i,onFetchLLMProviders:x??(()=>{})})]},r)}if(A(n)){const p=Array.isArray(d[r])?d[r]:[],b=g=>a({...d,[r]:g}),j=n.items??{};n.items||console.warn(`[SchemaForm] 数组字段 "${r}" 缺少 items 定义,添加按钮将创建空对象`);const c=()=>{const g={};for(const[v,h]of Object.entries(j))h.default!==void 0?g[v]=h.default:h.required&&(g[v]=h.type==="number"?0:h.type==="boolean"?!1:"");b([...p,g])},u=g=>{b(p.filter((v,h)=>h!==g))},f=(g,v,h)=>{const l=p.map((N,O)=>O===g?{...N,[v]:h}:N);b(l)};return e.jsxs("div",{className:"config-edit-group",children:[e.jsxs("div",{className:"config-edit-group-label",style:{display:"flex",alignItems:"center",gap:8},children:[n.label,e.jsx("button",{className:"config-edit-btn",style:{fontSize:12,padding:"2px 8px"},onClick:c,children:"+ 添加"})]}),n.description&&e.jsx("span",{className:"config-edit-hint",style:{marginBottom:8,display:"block"},children:n.description}),p.length===0&&e.jsx("div",{style:{color:"#888",fontSize:13,padding:"4px 0"},children:'暂无条目,点击"添加"新建'}),p.map((g,v)=>e.jsxs("div",{className:"config-edit-array-item",style:{border:"1px solid var(--border, #333)",borderRadius:6,padding:"8px 12px",marginBottom:8,position:"relative"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[e.jsxs("span",{style:{fontSize:12,color:"#888"},children:["#",v+1]}),e.jsx("button",{className:"config-edit-btn",style:{fontSize:11,padding:"1px 6px",color:"#ef4444"},onClick:()=>u(v),children:"删除"})]}),Object.entries(j).map(([h,l])=>{const N=l.description||l.label;return e.jsxs("div",{className:"config-edit-row",children:[e.jsxs("label",{className:"config-edit-label",title:l.description,children:[e.jsx("code",{className:"field-key",children:h}),N&&e.jsxs("span",{className:"field-hint",children:[" / ",N]}),l.required&&e.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),e.jsx($,{field:l,fieldKey:h,value:g[h],onChange:O=>f(v,h,O),modelCache:o,onFetchModels:t,llmProviders:i,onFetchLLMProviders:x??(()=>{})})]},h)})]},v))]},r)}const y=n,m=d[r]??{};return e.jsxs("div",{className:"config-edit-group",children:[y.label&&e.jsx("div",{className:"config-edit-group-label",children:y.label}),y.description&&e.jsx("span",{className:"config-edit-hint",style:{marginBottom:8,display:"block"},children:y.description}),Object.entries(y.fields).map(([p,b])=>{const j=b.description||b.label;return e.jsxs("div",{className:"config-edit-row",children:[e.jsxs("label",{className:"config-edit-label",title:b.description,children:[e.jsx("code",{className:"field-key",children:p}),j&&e.jsxs("span",{className:"field-hint",children:[" / ",j]}),b.required&&e.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),e.jsx($,{field:b,fieldKey:p,value:m[p],onChange:c=>a({...d,[r]:{...m,[p]:c}}),modelCache:o,onFetchModels:t,llmProviders:i,onFetchLLMProviders:x??(()=>{})})]},p)})]},r)})})}export{L as S,K as b,k as f,E as u};
@@ -0,0 +1 @@
1
+ import{r as p,j as e}from"./react-vendor-BPQixOLZ.js";import{p as S,b as xe,B as V,M as R,R as z,d as B,e as M,W as pe}from"./index-D4hgfekH.js";import{M as F}from"./markdown-BCywGHw2.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";function ge(s,g){const[v,l]=p.useState({segments:[],isStreaming:!1,done:!1}),c=p.useRef(null),d=!!(s&&(g==="active"||g==="waiting"));p.useEffect(()=>{if(!d||!s){l({segments:[],isStreaming:!1,done:!1});return}const f=location.protocol==="https:"?"wss:":"ws:",h=new WebSocket(`${f}//${location.host}/ws`);return c.current=h,h.onopen=()=>{h.send(JSON.stringify({type:"subscribe_session",sessionId:s}))},h.onmessage=r=>{try{const i=JSON.parse(r.data);if(i.type==="stream_resume"){let j=[];if(Array.isArray(i.segments)&&i.segments.length>0)j=i.segments;else{const o=i.reasoningContent??"",u=i.content??"";o&&j.push({type:"reasoning_text",content:o}),u&&j.push({type:"text",content:u})}l({segments:j,isStreaming:!i.done,done:!!i.done})}else i.type==="stream"?i.done?l(j=>({...j,isStreaming:!1,done:!0})):l(j=>{const o=[...j.segments],u=(N,E)=>{const D=o[o.length-1];D&&D.type===N?o[o.length-1]={type:N,content:D.content+E}:o.push({type:N,content:E})};return i.reasoningDelta&&u("reasoning_text",i.reasoningDelta),i.contentDelta&&u("text",i.contentDelta),{...j,segments:o,isStreaming:!0}}):i.type==="tool_call"?l(j=>{const o=[...j.segments];if(i.toolPhase==="start")o.push({type:"tool_call",name:i.toolName,args:i.toolArgs??{},startTime:Date.now()});else if(i.toolPhase==="end"&&i.toolResult!==void 0){const u=o.findLastIndex(N=>N.type==="tool_call"&&N.name===i.toolName&&N.result==null);if(u>=0){const N=o[u];o[u]={...N,result:i.toolResult,endTime:Date.now()}}}return{...j,segments:o,isStreaming:!0}}):i.type==="message"&&l(j=>({...j,done:!0,isStreaming:!1}))}catch{}},h.onclose=()=>{c.current=null},()=>{h.close(),c.current=null}},[s,d]);const b=p.useCallback(()=>{l({segments:[],isStreaming:!1,done:!1})},[]);return[v,b]}const Y={active:"进行中",waiting:"等待中",completed:"已完成",error:"错误",archived:"已归档"},q={active:"#4caf50",waiting:"#ff9800",completed:"#2196f3",error:"#f44336",archived:"#888"};function X(s,g){return s?s.length>g?s.slice(0,g)+"…":s:""}function K(s){return new Date(s).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Q(s){const g=[];for(const v of s)g.push(v.session.id),g.push(...Q(v.children));return g}function je({config:s,resolvedConfig:g,inheritedConfig:v,options:l,onSave:c,onCancel:d}){var L,A,G;const b={...s},f=typeof s.model=="string"?s.model:void 0,h=typeof s.llmProvider=="string"?s.llmProvider:void 0;if(f){const t=h??((L=s.llm)==null?void 0:L.provider);t&&(b.llm={provider:t,model:f})}delete b.model,delete b.llmProvider;const[r,i]=p.useState(b),j=g||{},o=v||{},u=(t,x)=>{i(n=>({...n,[t]:x}))},N=t=>{var x,n;return(x=r.enabledToolGroups)!=null&&x.includes(t)?"explicit":(n=o.enabledToolGroups)!=null&&n.includes(t)&&!r.enabledToolGroups?"inherited":"off"},E=t=>{if(N(t)==="inherited"){const n=[...o.enabledToolGroups||[]];u("enabledToolGroups",n.filter(C=>C!==t))}else{const n=r.enabledToolGroups||o.enabledToolGroups||[],C=n.includes(t)?n.filter(_=>_!==t):[...n,t];u("enabledToolGroups",C.length>0?C:void 0)}},D=()=>{i(t=>{const{enabledToolGroups:x,...n}=t;return n})};if(!l)return e.jsx("div",{className:"session-config-editor",children:e.jsx("span",{className:"session-config-loading",children:"加载配置选项…"})});const k=(t,x)=>!r[t]&&x?` (继承: ${x})`:"",w=(A=r.llm)!=null&&A.provider&&((G=r.llm)!=null&&G.model)?`${r.llm.provider}/${r.llm.model}`:"",I=l.models.filter(t=>!!t.provider).map(t=>({key:`${t.provider}/${t.id}`,provider:t.provider,model:t.id,label:`${t.provider} / ${t.id}${t.capabilities.length>0?` [${t.capabilities.join(",")}]`:""}`}));w&&!I.some(t=>t.key===w)&&I.unshift({key:w,provider:r.llm.provider,model:r.llm.model,label:`${r.llm.provider} / ${r.llm.model} (已离线)`});const T=o.llm?`${o.llm.provider} / ${o.llm.model}`:void 0;return e.jsxs("div",{className:"session-config-editor",onClick:t=>t.stopPropagation(),children:[e.jsxs("label",{className:"session-config-field",children:[e.jsxs("span",{children:["模型",!r.llm&&T?` (继承: ${T})`:""]}),e.jsxs("select",{value:w,onChange:t=>{const x=t.target.value;if(!x){u("llm",void 0);return}const n=I.find(C=>C.key===x);n&&u("llm",{provider:n.provider,model:n.model})},children:[e.jsx("option",{value:"",children:T?`继承 (${T})`:"继承默认"}),I.map(t=>e.jsx("option",{value:t.key,children:t.label},t.key))]})]}),e.jsxs("label",{className:"session-config-field",children:[e.jsxs("span",{children:["人设",k("persona",o.persona)]}),e.jsxs("select",{value:r.persona||"",onChange:t=>u("persona",t.target.value||void 0),children:[e.jsx("option",{value:"",children:o.persona?`继承 (${o.persona})`:"继承默认"}),l.personas.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),l.toolGroups.length>0&&e.jsxs("div",{className:"session-config-field",children:[e.jsxs("span",{children:["工具分组",r.enabledToolGroups?"":" (继承)"]}),e.jsxs("div",{className:"session-config-chips",children:[l.toolGroups.map(t=>{const x=N(t.name);return e.jsx("button",{className:`session-config-chip ${x==="explicit"?"active":x==="inherited"?"active inherited":""}`,onClick:()=>E(t.name),title:`${t.name}${x==="inherited"?" (继承)":x==="explicit"?" (已覆盖)":""}`,children:t.label||t.name},t.name)}),r.enabledToolGroups&&e.jsx("button",{className:"session-config-chip reset",onClick:D,title:"恢复为继承",children:"↺ 重置"})]})]}),e.jsxs("label",{className:"session-config-field",children:[e.jsx("span",{children:"额外提示"}),e.jsx("textarea",{rows:2,value:r.systemPromptExtra||"",onChange:t=>u("systemPromptExtra",t.target.value||void 0),placeholder:"追加到系统提示之后…"})]}),e.jsxs("label",{className:"session-config-field",children:[e.jsx("span",{children:"工具迭代上限"}),e.jsx("input",{type:"number",min:0,max:50,value:r.maxToolIterations??"",onChange:t=>u("maxToolIterations",t.target.value?Number(t.target.value):void 0),placeholder:o.maxToolIterations?`继承 (${o.maxToolIterations})`:"默认"})]}),e.jsxs("div",{className:"session-config-toggles",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:r.disableOutputFormat??j.disableOutputFormat??!1,onChange:t=>u("disableOutputFormat",t.target.checked||void 0)}),e.jsxs("span",{children:["禁用结构化输出",r.disableOutputFormat===void 0&&o.disableOutputFormat?" (继承)":""]})]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:r.clientSideJsonRendering??j.clientSideJsonRendering??!1,onChange:t=>u("clientSideJsonRendering",t.target.checked||void 0)}),e.jsxs("span",{children:["客户端 JSON 渲染",r.clientSideJsonRendering===void 0&&o.clientSideJsonRendering?" (继承)":""]})]})]}),e.jsxs("div",{className:"session-config-actions",children:[e.jsx("button",{className:"session-config-btn save",onClick:()=>c(r),children:"保存"}),e.jsx("button",{className:"session-config-btn cancel",onClick:d,children:"取消"})]})]})}function Se({pluginName:s,activeSessionId:g,onSwitchSession:v,onStartNewChat:l,refreshSignal:c}){const[d,b]=p.useState([]),[f,h]=p.useState(null),[r,i]=p.useState(null),[j,o]=p.useState(!1),[u,N]=p.useState(null),[E,D]=p.useState(!1),[k,w]=p.useState(new Set),[I,T]=p.useState(null),[L,A]=p.useState(""),[G,t]=p.useState(null),[x,n]=p.useState(null),[C,_]=p.useState(null),[W,O]=p.useState(null),[U,m]=p.useState(null),$=p.useCallback(()=>{S(s,"getSessionTree").then(a=>{Array.isArray(a)&&b(a)}).catch(()=>N("无法加载会话树"))},[s]);p.useEffect(()=>{$();const a=setInterval($,3e4);return()=>clearInterval(a)},[$]),p.useEffect(()=>{c&&($(),x&&Promise.all([S(s,"getResolvedConfig",{sessionId:x,platform:"webui"}),S(s,"getInheritedDefaults",{sessionId:x,platform:"webui"})]).then(([a,y])=>{a&&O(a),y&&m(y)}).catch(()=>{}))},[c]);const H=p.useCallback(a=>{h(a),o(!0),S(s,"getSessionDetail",{id:a}).then(y=>i(y)).catch(()=>i(null)).finally(()=>o(!1))},[s]),se=async()=>{try{await S(s,"createSession",{}),$()}catch{}},te=async a=>{try{await S(s,"createSession",{parentId:a}),$()}catch{}},ne=async a=>{if(!L.trim()){T(null);return}try{await S(s,"renameSession",{id:a,title:L.trim()}),$()}catch{}T(null)},le=async a=>{try{await S(s,"archiveSession",{id:a}),$()}catch{}},ie=async a=>{try{const y=a===g;await S(s,"deleteSession",{id:a}),$(),f===a&&(h(null),i(null)),y&&l&&l()}catch{}t(null)},ae=async a=>{if(x===a){n(null),O(null),m(null);return}n(a),O(null),m(null);try{const[y,P,J]=await Promise.all([C?Promise.resolve(C):S(s,"getConfigOptions"),S(s,"getResolvedConfig",{sessionId:a,platform:"webui"}),S(s,"getInheritedDefaults",{sessionId:a,platform:"webui"})]);y&&!C&&_(y),P&&O(P),J&&m(J)}catch{}},re=async(a,y)=>{try{await S(s,"updateSessionConfig",{id:a,config:y}),$(),n(null)}catch(P){const J=P instanceof Error?P.message:String(P);alert(`保存会话配置失败:${J}`)}},oe=a=>{w(y=>{const P=new Set(y);return P.has(a)?P.delete(a):P.add(a),P})},ce=()=>{const a=Q(d);w(new Set(a))},de=()=>w(new Set),he=async()=>{if(k.size!==0)try{await S(s,"batchArchive",{ids:[...k]}),w(new Set),$()}catch{}},me=async()=>{if(k.size!==0&&confirm(`确认删除选中的 ${k.size} 个会话?此操作不可恢复。`))try{await S(s,"batchDelete",{ids:[...k]}),w(new Set),f&&k.has(f)&&(h(null),i(null)),$()}catch{}},ue=()=>{D(!1),w(new Set)};return u?e.jsx("div",{className:"tree-page-error",children:u}):e.jsxs("div",{className:"session-tree-page",children:[e.jsxs("div",{className:"tree-visual-panel",children:[e.jsxs("div",{className:"tree-visual-header",children:[e.jsx("h3",{children:"会话"}),e.jsx("div",{className:"tree-header-actions",children:E?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"tree-batch-btn",onClick:ce,title:"全选",children:"全选"}),e.jsx("button",{className:"tree-batch-btn",onClick:de,title:"取消全选",children:"取消"}),e.jsxs("button",{className:"tree-batch-btn archive",onClick:he,disabled:k.size===0,children:["归档 (",k.size,")"]}),e.jsxs("button",{className:"tree-batch-btn danger",onClick:me,disabled:k.size===0,children:["删除 (",k.size,")"]}),e.jsx("button",{className:"tree-batch-btn",onClick:ue,children:"退出批量"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"tree-action-btn",onClick:se,title:"新建会话",children:"+"}),e.jsx("button",{className:"tree-action-btn",onClick:()=>D(!0),title:"批量管理",children:"☐"}),e.jsx("button",{className:"tree-refresh-btn",onClick:$,children:"⟳"})]})})]}),e.jsx("div",{className:"tree-visual-body",children:d.length===0?e.jsx("div",{className:"tree-empty",children:"暂无会话"}):d.map(a=>e.jsx(Z,{node:a,selectedId:f,activeSessionId:g,onSelect:H,depth:0,batchMode:E,selected:k,onToggleSelect:oe,onCreateChild:te,onRename:(y,P)=>{T(y),A(P)},onArchive:le,onDelete:y=>t(y),onOpenConfig:ae,editingId:I,editTitle:L,onEditTitleChange:A,onCommitRename:ne,onCancelEdit:()=>T(null),configEditingId:x,configOptions:C,resolvedConfig:W,inheritedConfig:U,onSaveConfig:re,onCancelConfig:()=>n(null)},a.session.id))})]}),e.jsx("div",{className:"tree-detail-panel",children:f?j?e.jsx("div",{className:"tree-detail-placeholder",children:"加载中…"}):r?e.jsx(fe,{detail:r,onSwitchSession:v,onRefresh:()=>H(r.session.id)}):e.jsx("div",{className:"tree-detail-placeholder",children:"无法加载会话信息"}):e.jsx("div",{className:"tree-detail-placeholder",children:"点击左侧会话节点查看详情"})}),G&&e.jsx("div",{className:"delete-confirm-overlay",onClick:()=>t(null),children:e.jsxs("div",{className:"delete-confirm-dialog",onClick:a=>a.stopPropagation(),children:[e.jsx("p",{children:"确定要删除此会话吗?子会话也会被一并删除,此操作无法撤销。"}),e.jsxs("div",{className:"delete-confirm-actions",children:[e.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>ie(G),children:"删除"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>t(null),children:"取消"})]})]})})]})}function Z({node:s,selectedId:g,activeSessionId:v,onSelect:l,depth:c,batchMode:d,selected:b,onToggleSelect:f,onCreateChild:h,onRename:r,onArchive:i,onDelete:j,onOpenConfig:o,editingId:u,editTitle:N,onEditTitleChange:E,onCommitRename:D,onCancelEdit:k,configEditingId:w,configOptions:I,resolvedConfig:T,inheritedConfig:L,onSaveConfig:A,onCancelConfig:G}){const[t,x]=p.useState(!0),n=s.session,C=s.children.length>0,_=n.id===g,W=n.id===v,O=u===n.id,U=b.has(n.id);return e.jsxs("div",{className:"tree-node-group",children:[e.jsxs("div",{className:`tree-node ${_?"selected":""} ${W?"active-chat":""} status-${n.status}`,style:{marginLeft:c*24},onClick:()=>d?f(n.id):l(n.id),children:[d&&e.jsx("input",{type:"checkbox",className:"tree-node-checkbox",checked:U,onChange:()=>f(n.id),onClick:m=>m.stopPropagation()}),e.jsx("button",{className:"tree-node-toggle",onClick:m=>{m.stopPropagation(),x(!t)},style:{visibility:C?"visible":"hidden"},children:t?"▾":"▸"}),e.jsx("span",{className:"tree-node-status",style:{background:q[n.status]||"#888"}}),e.jsx("div",{className:"tree-node-info",children:O?e.jsx("input",{className:"tree-node-rename-input",value:N,onChange:m=>E(m.target.value),onBlur:()=>D(n.id),onKeyDown:m=>{m.key==="Enter"&&D(n.id),m.key==="Escape"&&k()},onClick:m=>m.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tree-node-title",children:n.title||n.name}),e.jsxs("span",{className:"tree-node-meta",children:[Y[n.status]||n.status,n.createdBy&&n.createdBy!=="user"&&` · ${n.createdBy}`,` · ${K(n.createdAt)}`]})]})}),C&&e.jsx("span",{className:"tree-node-badge",children:s.children.length}),!d&&e.jsxs("div",{className:"tree-node-actions",onClick:m=>m.stopPropagation(),children:[e.jsx("button",{className:"tree-node-action-btn",title:"新建子会话",onClick:()=>h(n.id),children:"➕"}),e.jsx("button",{className:"tree-node-action-btn",title:"配置",onClick:()=>o(n.id),children:"⚙"}),e.jsx("button",{className:"tree-node-action-btn",title:"重命名",onClick:()=>r(n.id,n.title||n.name),children:"✎"}),n.status==="active"&&e.jsx("button",{className:"tree-node-action-btn",title:"归档",onClick:()=>i(n.id),children:"▪"}),e.jsx("button",{className:"tree-node-action-btn danger",title:"删除",onClick:()=>j(n.id),children:"✕"})]})]}),w===n.id&&e.jsx("div",{style:{marginLeft:c*24+24},children:e.jsx(je,{config:n.config||{},resolvedConfig:T,inheritedConfig:L,options:I,onSave:m=>A(n.id,m),onCancel:G})}),C&&t&&e.jsx("div",{className:"tree-node-children",children:s.children.map(m=>e.jsxs("div",{className:"tree-child-wrapper",children:[m.session.inputContext&&e.jsxs("div",{className:"tree-flow-label",style:{marginLeft:(c+1)*24},children:[e.jsx("span",{className:"tree-flow-arrow",children:"↓"}),e.jsx("span",{className:"tree-flow-text",children:X(m.session.inputContext,80)})]}),e.jsx(Z,{node:m,selectedId:g,activeSessionId:v,onSelect:l,depth:c+1,batchMode:d,selected:b,onToggleSelect:f,onCreateChild:h,onRename:r,onArchive:i,onDelete:j,onOpenConfig:o,editingId:u,editTitle:N,onEditTitleChange:E,onCommitRename:D,onCancelEdit:k,configEditingId:w,configOptions:I,resolvedConfig:T,inheritedConfig:L,onSaveConfig:A,onCancelConfig:G}),m.session.result&&e.jsxs("div",{className:"tree-flow-label result",style:{marginLeft:(c+1)*24},children:[e.jsx("span",{className:"tree-flow-arrow",children:"↑"}),e.jsx("span",{className:"tree-flow-text",children:X(m.session.result,80)})]})]},m.session.id))})]})}function fe({detail:s,onSwitchSession:g,onRefresh:v}){const l=s.session,c=xe(s.messages),[d,b]=ge(l.id,l.status);return p.useEffect(()=>{d.done&&(b(),v==null||v())},[d.done,b,v]),e.jsxs("div",{className:"session-detail",children:[e.jsxs("div",{className:"session-detail-header",children:[e.jsx("h3",{children:l.title||l.name}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[g&&e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>g(l.id),children:"进入对话"}),e.jsx("span",{className:"session-detail-status",style:{color:q[l.status]},children:Y[l.status]})]})]}),e.jsxs("div",{className:"session-detail-meta",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"ID:"})," ",l.id]}),e.jsxs("div",{children:[e.jsx("strong",{children:"创建时间:"})," ",new Date(l.createdAt).toLocaleString("zh-CN")]}),l.parentId&&e.jsxs("div",{children:[e.jsx("strong",{children:"父会话:"})," ",l.parentId]}),l.createdBy&&e.jsxs("div",{children:[e.jsx("strong",{children:"创建者:"})," ",l.createdBy]}),l.children.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:"子会话数:"})," ",l.children.length]})]}),l.inputContext&&e.jsxs("div",{className:"session-detail-context",children:[e.jsx("div",{className:"context-label",children:"来自父会话的指令"}),e.jsx("div",{className:"context-content",children:l.inputContext})]}),l.result&&e.jsxs("div",{className:"session-detail-result",children:[e.jsx("div",{className:"context-label",children:"给父会话的结果"}),e.jsx("div",{className:"context-content",children:l.result})]}),e.jsxs("div",{className:"session-detail-messages",children:[e.jsxs("h4",{children:["消息记录 (",s.messages.length,")"]}),c.length===0&&!d.isStreaming?e.jsx("div",{className:"no-messages",children:"暂无消息记录"}):e.jsxs("div",{className:"message-list",children:[c.map((f,h)=>e.jsx(ve,{msg:f},h)),d.isStreaming&&d.segments.length>0&&e.jsxs("div",{className:"detail-message assistant streaming",children:[e.jsxs("div",{className:"detail-msg-role",children:["助手 ",e.jsx("span",{className:"streaming-indicator",children:"●"})]}),e.jsx("div",{className:"detail-msg-content detail-msg-md",children:(()=>{const f=[];let h=0;for(;h<d.segments.length;){const r=d.segments[h];if(r.type==="reasoning_text"){let i="";for(;h<d.segments.length&&d.segments[h].type==="reasoning_text";)i+=d.segments[h].content,h++;i&&f.push(e.jsxs("details",{className:"thinking-block",open:!0,children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(V,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(F,{remarkPlugins:B,rehypePlugins:z,components:R,children:M(i)})})]},`r-${h}`));continue}f.push(e.jsx(ee,{seg:r},h)),h++}return f})()})]})]})]})]})}function ee({seg:s}){return s.type==="text"||s.type==="reasoning_text"?s.content?e.jsx("div",{className:"detail-text-segment",children:e.jsx(F,{remarkPlugins:B,rehypePlugins:z,components:R,children:M(s.content)})}):null:e.jsxs("details",{className:"tool-call-block",children:[e.jsxs("summary",{className:"tool-call-summary",children:[e.jsx(pe,{size:14})," ",s.name,s.result==null?" …":""]}),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(s.args,null,2)})]}),s.result!=null&&e.jsxs("div",{className:"tool-call-result",children:[e.jsx("strong",{children:"结果"}),e.jsx("pre",{children:s.result})]})]})]})}function ve({msg:s}){const g=s.role==="user"?"用户":"助手";if(s.role==="user")return e.jsxs("div",{className:`detail-message ${s.role}`,children:[e.jsx("div",{className:"detail-msg-role",children:g}),e.jsx("div",{className:"detail-msg-content",children:s.content}),s.timestamp>0&&e.jsx("div",{className:"detail-msg-time",children:K(s.timestamp)})]});if(s.role==="assistant"&&s.segments&&s.segments.length>0){const l=[];let c=0;for(;c<s.segments.length;){const d=s.segments[c];if(d.type==="reasoning_text"){let b="";for(;c<s.segments.length&&s.segments[c].type==="reasoning_text";)b+=s.segments[c].content,c++;b&&l.push(e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(V,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(F,{remarkPlugins:B,rehypePlugins:z,components:R,children:M(b)})})]},`r-${c}`));continue}l.push(e.jsx(ee,{seg:d},c)),c++}return e.jsxs("div",{className:`detail-message ${s.role}`,children:[e.jsx("div",{className:"detail-msg-role",children:g}),e.jsx("div",{className:"detail-msg-content detail-msg-md",children:l}),s.timestamp>0&&e.jsx("div",{className:"detail-msg-time",children:K(s.timestamp)})]})}const v=s.role==="assistant"&&s.reasoningContent?e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(V,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(F,{remarkPlugins:B,rehypePlugins:z,components:R,children:M(s.reasoningContent)})})]}):null;return e.jsxs("div",{className:`detail-message ${s.role}`,children:[e.jsx("div",{className:"detail-msg-role",children:g}),v,e.jsx("div",{className:"detail-msg-content detail-msg-md",children:e.jsx(F,{remarkPlugins:B,rehypePlugins:z,components:R,children:M(s.content)})}),s.timestamp>0&&e.jsx("div",{className:"detail-msg-time",children:K(s.timestamp)})]})}export{Se as SessionsPage};
@@ -0,0 +1 @@
1
+ import{a0 as ln,a1 as an,a2 as H,a3 as q,a4 as B,a5 as un,a6 as y,a7 as tn,a8 as L,a9 as _,aa as rn,ab as o,ac as on,ad as sn,ae as fn}from"./mermaid.core-BbMB3jno.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(on(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<an)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
@@ -0,0 +1,36 @@
1
+ import{_ as f,I as ht,Y as gt,l as K,b as ut,a as pt,p as mt,q as yt,g as wt,s as kt,z as xt,F as bt,D as vt,G as $t,c as J,ak as Z,al as N,i as Et,d as St,x as Dt,am as Tt,an as At}from"./mermaid.core-BbMB3jno.js";import{p as Ct}from"./chunk-4BX2VUAB-BLsTiY6G.js";import{p as Bt}from"./wardley-L42UT6IY-DwPang7i.js";import{c as tt}from"./cytoscape.esm-LDYqcvCF.js";import{f as It}from"./cytoscape-fcose-DXAQNCkb.js";import"./index-D4hgfekH.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var W={L:"left",R:"right",T:"top",B:"bottom"},Q={L:f(e=>`${e},${e/2} 0,${e} 0,0`,"L"),R:f(e=>`0,${e/2} ${e},0 ${e},${e}`,"R"),T:f(e=>`0,0 ${e},0 ${e/2},${e}`,"T"),B:f(e=>`${e/2},0 ${e},${e} 0,${e}`,"B")},X={L:f((e,t)=>e-t+2,"L"),R:f((e,t)=>e-2,"R"),T:f((e,t)=>e-t+2,"T"),B:f((e,t)=>e-2,"B")},Lt=f(function(e){return T(e)?e==="L"?"R":"L":e==="T"?"B":"T"},"getOppositeArchitectureDirection"),U=f(function(e){const t=e;return t==="L"||t==="R"||t==="T"||t==="B"},"isArchitectureDirection"),T=f(function(e){const t=e;return t==="L"||t==="R"},"isArchitectureDirectionX"),z=f(function(e){const t=e;return t==="T"||t==="B"},"isArchitectureDirectionY"),V=f(function(e,t){const i=T(e)&&z(t),r=z(e)&&T(t);return i||r},"isArchitectureDirectionXY"),jt=f(function(e){const t=e[0],i=e[1],r=T(t)&&z(i),n=z(t)&&T(i);return r||n},"isArchitecturePairXY"),zt=f(function(e){return e!=="LL"&&e!=="RR"&&e!=="TT"&&e!=="BB"},"isValidArchitectureDirectionPair"),_=f(function(e,t){const i=`${e}${t}`;return zt(i)?i:void 0},"getArchitectureDirectionPair"),Ft=f(function([e,t],i){const r=i[0],n=i[1];return T(r)?z(n)?[e+(r==="L"?-1:1),t+(n==="T"?1:-1)]:[e+(r==="L"?-1:1),t]:T(n)?[e+(n==="L"?1:-1),t+(r==="T"?1:-1)]:[e,t+(r==="T"?1:-1)]},"shiftPositionByArchitectureDirectionPair"),Pt=f(function(e){return e==="LT"||e==="TL"?[1,1]:e==="BL"||e==="LB"?[1,-1]:e==="BR"||e==="RB"?[-1,-1]:[-1,1]},"getArchitectureDirectionXYFactors"),Yt=f(function(e,t){return V(e,t)?"bend":T(e)?"horizontal":"vertical"},"getArchitectureDirectionAlignment"),Rt=f(function(e){return e.type==="service"},"isArchitectureService"),Xt=f(function(e){return e.type==="junction"},"isArchitectureJunction"),et=f(e=>e.data(),"edgeData"),P=f(e=>e.data(),"nodeData"),Ot=$t.architecture,Y,it=(Y=class{constructor(){this.nodes={},this.groups={},this.edges=[],this.registeredIds={},this.elements={},this.diagramId="",this.setAccTitle=ut,this.getAccTitle=pt,this.setDiagramTitle=mt,this.getDiagramTitle=yt,this.getAccDescription=wt,this.setAccDescription=kt,this.clear()}setDiagramId(t){this.diagramId=t}getDiagramId(){return this.diagramId}clear(){this.nodes={},this.groups={},this.edges=[],this.registeredIds={},this.dataStructures=void 0,this.elements={},this.diagramId="",xt()}addService({id:t,icon:i,in:r,title:n,iconText:c}){if(this.registeredIds[t]!==void 0)throw new Error(`The service id [${t}] is already in use by another ${this.registeredIds[t]}`);if(r!==void 0){if(t===r)throw new Error(`The service [${t}] cannot be placed within itself`);if(this.registeredIds[r]===void 0)throw new Error(`The service [${t}]'s parent does not exist. Please make sure the parent is created before this service`);if(this.registeredIds[r]==="node")throw new Error(`The service [${t}]'s parent is not a group`)}this.registeredIds[t]="node",this.nodes[t]={id:t,type:"service",icon:i,iconText:c,title:n,edges:[],in:r}}getServices(){return Object.values(this.nodes).filter(Rt)}addJunction({id:t,in:i}){if(this.registeredIds[t]!==void 0)throw new Error(`The junction id [${t}] is already in use by another ${this.registeredIds[t]}`);if(i!==void 0){if(t===i)throw new Error(`The junction [${t}] cannot be placed within itself`);if(this.registeredIds[i]===void 0)throw new Error(`The junction [${t}]'s parent does not exist. Please make sure the parent is created before this junction`);if(this.registeredIds[i]==="node")throw new Error(`The junction [${t}]'s parent is not a group`)}this.registeredIds[t]="node",this.nodes[t]={id:t,type:"junction",edges:[],in:i}}getJunctions(){return Object.values(this.nodes).filter(Xt)}getNodes(){return Object.values(this.nodes)}getNode(t){return this.nodes[t]??null}addGroup({id:t,icon:i,in:r,title:n}){var c,u,d;if(((c=this.registeredIds)==null?void 0:c[t])!==void 0)throw new Error(`The group id [${t}] is already in use by another ${this.registeredIds[t]}`);if(r!==void 0){if(t===r)throw new Error(`The group [${t}] cannot be placed within itself`);if(((u=this.registeredIds)==null?void 0:u[r])===void 0)throw new Error(`The group [${t}]'s parent does not exist. Please make sure the parent is created before this group`);if(((d=this.registeredIds)==null?void 0:d[r])==="node")throw new Error(`The group [${t}]'s parent is not a group`)}this.registeredIds[t]="group",this.groups[t]={id:t,icon:i,title:n,in:r}}getGroups(){return Object.values(this.groups)}addEdge({lhsId:t,rhsId:i,lhsDir:r,rhsDir:n,lhsInto:c,rhsInto:u,lhsGroup:d,rhsGroup:l,title:s}){if(!U(r))throw new Error(`Invalid direction given for left hand side of edge ${t}--${i}. Expected (L,R,T,B) got ${String(r)}`);if(!U(n))throw new Error(`Invalid direction given for right hand side of edge ${t}--${i}. Expected (L,R,T,B) got ${String(n)}`);if(this.nodes[t]===void 0&&this.groups[t]===void 0)throw new Error(`The left-hand id [${t}] does not yet exist. Please create the service/group before declaring an edge to it.`);if(this.nodes[i]===void 0&&this.groups[i]===void 0)throw new Error(`The right-hand id [${i}] does not yet exist. Please create the service/group before declaring an edge to it.`);const o=this.nodes[t].in,a=this.nodes[i].in;if(d&&o&&a&&o==a)throw new Error(`The left-hand id [${t}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);if(l&&o&&a&&o==a)throw new Error(`The right-hand id [${i}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);const g={lhsId:t,lhsDir:r,lhsInto:c,lhsGroup:d,rhsId:i,rhsDir:n,rhsInto:u,rhsGroup:l,title:s};this.edges.push(g),this.nodes[t]&&this.nodes[i]&&(this.nodes[t].edges.push(this.edges[this.edges.length-1]),this.nodes[i].edges.push(this.edges[this.edges.length-1]))}getEdges(){return this.edges}getDataStructures(){if(this.dataStructures===void 0){const t={},i=Object.entries(this.nodes).reduce((l,[s,o])=>(l[s]=o.edges.reduce((a,g)=>{var p,k;const h=(p=this.getNode(g.lhsId))==null?void 0:p.in,y=(k=this.getNode(g.rhsId))==null?void 0:k.in;if(h&&y&&h!==y){const w=Yt(g.lhsDir,g.rhsDir);w!=="bend"&&(t[h]??(t[h]={}),t[h][y]=w,t[y]??(t[y]={}),t[y][h]=w)}if(g.lhsId===s){const w=_(g.lhsDir,g.rhsDir);w&&(a[w]=g.rhsId)}else{const w=_(g.rhsDir,g.lhsDir);w&&(a[w]=g.lhsId)}return a},{}),l),{}),r=Object.keys(i)[0],n={[r]:1},c=Object.keys(i).reduce((l,s)=>s===r?l:{...l,[s]:1},{}),u=f(l=>{const s={[l]:[0,0]},o=[l];for(;o.length>0;){const a=o.shift();if(a){n[a]=1,delete c[a];const g=i[a],[h,y]=s[a];Object.entries(g).forEach(([p,k])=>{n[k]||(s[k]=Ft([h,y],p),o.push(k))})}}return s},"BFS"),d=[u(r)];for(;Object.keys(c).length>0;)d.push(u(Object.keys(c)[0]));this.dataStructures={adjList:i,spatialMaps:d,groupAlignments:t}}return this.dataStructures}setElementForId(t,i){this.elements[t]=i}getElementById(t){return this.elements[t]}getConfig(){return bt({...Ot,...vt().architecture})}getConfigField(t){return this.getConfig()[t]}},f(Y,"ArchitectureDB"),Y),Mt=f((e,t)=>{Ct(e,t),e.groups.map(i=>t.addGroup(i)),e.services.map(i=>t.addService({...i,type:"service"})),e.junctions.map(i=>t.addJunction({...i,type:"junction"})),e.edges.map(i=>t.addEdge(i))},"populateDb"),rt={parser:{yy:void 0},parse:f(async e=>{var r;const t=await Bt("architecture",e);K.debug(t);const i=(r=rt.parser)==null?void 0:r.yy;if(!(i instanceof it))throw new Error("parser.parser?.yy was not a ArchitectureDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Mt(t,i)},"parse")},Gt=f(e=>`
2
+ .edge {
3
+ stroke-width: ${e.archEdgeWidth};
4
+ stroke: ${e.archEdgeColor};
5
+ fill: none;
6
+ }
7
+
8
+ .arrow {
9
+ fill: ${e.archEdgeArrowColor};
10
+ }
11
+
12
+ .node-bkg {
13
+ fill: none;
14
+ stroke: ${e.archGroupBorderColor};
15
+ stroke-width: ${e.archGroupBorderWidth};
16
+ stroke-dasharray: 8;
17
+ }
18
+ .node-icon-text {
19
+ display: flex;
20
+ align-items: center;
21
+ }
22
+
23
+ .node-icon-text > div {
24
+ color: #fff;
25
+ margin: 1px;
26
+ height: fit-content;
27
+ text-align: center;
28
+ overflow: hidden;
29
+ display: -webkit-box;
30
+ -webkit-box-orient: vertical;
31
+ }
32
+ `,"getStyles"),Nt=Gt,F=f(e=>`<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/>${e}</g>`,"wrapIcon"),R={prefix:"mermaid-architecture",height:80,width:80,icons:{database:{body:F('<path id="b" data-name="4" d="m20,57.86c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="c" data-name="3" d="m20,45.95c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="d" data-name="2" d="m20,34.05c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse id="e" data-name="1" cx="40" cy="22.14" rx="20" ry="7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="20" y1="57.86" x2="20" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="60" y1="57.86" x2="60" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},server:{body:F('<rect x="17.5" y="17.5" width="45" height="45" rx="2" ry="2" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="32.5" x2="62.5" y2="32.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="47.5" x2="62.5" y2="47.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><g><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g>')},disk:{body:F('<rect x="20" y="15" width="40" height="50" rx="1" ry="1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="14" ry="14.58" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="4" ry="4.17" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m37.51,42.52l-4.83,13.22c-.26.71-1.1,1.02-1.76.64l-4.18-2.42c-.66-.38-.81-1.26-.33-1.84l9.01-10.8c.88-1.05,2.56-.08,2.09,1.2Z" style="fill: #fff; stroke-width: 0px;"/>')},internet:{body:F('<circle cx="40" cy="40" r="22.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="40" y1="17.5" x2="40" y2="62.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="40" x2="62.5" y2="40" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m39.99,17.51c-15.28,11.1-15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m40.01,17.51c15.28,11.1,15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="30.1" x2="60.25" y2="30.1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="49.9" x2="60.25" y2="49.9" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},cloud:{body:F('<path d="m65,47.5c0,2.76-2.24,5-5,5H20c-2.76,0-5-2.24-5-5,0-1.87,1.03-3.51,2.56-4.36-.04-.21-.06-.42-.06-.64,0-2.6,2.48-4.74,5.65-4.97,1.65-4.51,6.34-7.76,11.85-7.76.86,0,1.69.08,2.5.23,2.09-1.57,4.69-2.5,7.5-2.5,6.1,0,11.19,4.38,12.28,10.17,2.14.56,3.72,2.51,3.72,4.83,0,.03,0,.07-.01.1,2.29.46,4.01,2.48,4.01,4.9Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},unknown:At,blank:{body:F("")}}},_t=f(async function(e,t,i,r){const n=i.getConfigField("padding"),c=i.getConfigField("iconSize"),u=c/2,d=c/6,l=d/2;await Promise.all(t.edges().map(async s=>{var A,j;const{source:o,sourceDir:a,sourceArrow:g,sourceGroup:h,target:y,targetDir:p,targetArrow:k,targetGroup:w,label:$}=et(s);let{x:m,y:b}=s[0].sourceEndpoint();const{x:E,y:B}=s[0].midpoint();let{x:v,y:S}=s[0].targetEndpoint();const x=n+4;if(h&&(T(a)?m+=a==="L"?-x:x:b+=a==="T"?-x:x+18),w&&(T(p)?v+=p==="L"?-x:x:S+=p==="T"?-x:x+18),!h&&((A=i.getNode(o))==null?void 0:A.type)==="junction"&&(T(a)?m+=a==="L"?u:-u:b+=a==="T"?u:-u),!w&&((j=i.getNode(y))==null?void 0:j.type)==="junction"&&(T(p)?v+=p==="L"?u:-u:S+=p==="T"?u:-u),s[0]._private.rscratch){const L=e.insert("g");if(L.insert("path").attr("d",`M ${m},${b} L ${E},${B} L${v},${S} `).attr("class","edge").attr("id",`${r}-${Dt(o,y,{prefix:"L"})}`),g){const I=T(a)?X[a](m,d):m-l,D=z(a)?X[a](b,d):b-l;L.insert("polygon").attr("points",Q[a](d)).attr("transform",`translate(${I},${D})`).attr("class","arrow")}if(k){const I=T(p)?X[p](v,d):v-l,D=z(p)?X[p](S,d):S-l;L.insert("polygon").attr("points",Q[p](d)).attr("transform",`translate(${I},${D})`).attr("class","arrow")}if($){const I=V(a,p)?"XY":T(a)?"X":"Y";let D=0;I==="X"?D=Math.abs(m-v):I==="Y"?D=Math.abs(b-S)/1.5:D=Math.abs(m-v)/2;const C=L.append("g");if(await Z(C,$,{useHtmlLabels:!1,width:D,classes:"architecture-service-label"},J()),C.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle"),I==="X")C.attr("transform","translate("+E+", "+B+")");else if(I==="Y")C.attr("transform","translate("+E+", "+B+") rotate(-90)");else if(I==="XY"){const O=_(a,p);if(O&&jt(O)){const q=C.node().getBoundingClientRect(),[M,G]=Pt(O);C.attr("dominant-baseline","auto").attr("transform",`rotate(${-1*M*G*45})`);const H=C.node().getBoundingClientRect();C.attr("transform",`
33
+ translate(${E}, ${B-q.height/2})
34
+ translate(${M*H.width/2}, ${G*H.height/2})
35
+ rotate(${-1*M*G*45}, 0, ${q.height/2})
36
+ `)}}}}}))},"drawEdges"),Jt=f(async function(e,t,i,r){const c=i.getConfigField("padding")*.75,u=i.getConfigField("fontSize"),l=i.getConfigField("iconSize")/2;await Promise.all(t.nodes().map(async s=>{const o=P(s);if(o.type==="group"){const{h:a,w:g,x1:h,y1:y}=s.boundingBox(),p=e.append("rect");p.attr("id",`${r}-group-${o.id}`).attr("x",h+l).attr("y",y+l).attr("width",g).attr("height",a).attr("class","node-bkg");const k=e.append("g");let w=h,$=y;if(o.icon){const m=k.append("g");m.html(`<g>${await N(o.icon,{height:c,width:c,fallbackPrefix:R.prefix})}</g>`),m.attr("transform","translate("+(w+l+1)+", "+($+l+1)+")"),w+=c,$+=u/2-1-2}if(o.label){const m=k.append("g");await Z(m,o.label,{useHtmlLabels:!1,width:g,classes:"architecture-service-label"},J()),m.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","start").attr("text-anchor","start"),m.attr("transform","translate("+(w+l+4)+", "+($+l+2)+")")}i.setElementForId(o.id,p)}}))},"drawGroups"),Zt=f(async function(e,t,i,r){const n=J();for(const c of i){const u=t.append("g"),d=e.getConfigField("iconSize");if(c.title){const a=u.append("g");await Z(a,c.title,{useHtmlLabels:!1,width:d*1.5,classes:"architecture-service-label"},n),a.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle"),a.attr("transform","translate("+d/2+", "+d+")")}const l=u.append("g");if(c.icon)l.html(`<g>${await N(c.icon,{height:d,width:d,fallbackPrefix:R.prefix})}</g>`);else if(c.iconText){l.html(`<g>${await N("blank",{height:d,width:d,fallbackPrefix:R.prefix})}</g>`);const h=l.append("g").append("foreignObject").attr("width",d).attr("height",d).append("div").attr("class","node-icon-text").attr("style",`height: ${d}px;`).append("div").html(Et(c.iconText,n)),y=parseInt(window.getComputedStyle(h.node(),null).getPropertyValue("font-size").replace(/\D/g,""))??16;h.attr("style",`-webkit-line-clamp: ${Math.floor((d-2)/y)};`)}else l.append("path").attr("class","node-bkg").attr("id",`${r}-node-${c.id}`).attr("d",`M0,${d} V5 Q0,0 5,0 H${d-5} Q${d},0 ${d},5 V${d} Z`);u.attr("id",`${r}-service-${c.id}`).attr("class","architecture-service");const{width:s,height:o}=u.node().getBBox();c.width=s,c.height=o,e.setElementForId(c.id,u)}return 0},"drawServices"),Vt=f(function(e,t,i,r){i.forEach(n=>{const c=t.append("g"),u=e.getConfigField("iconSize");c.append("g").append("rect").attr("id",`${r}-node-${n.id}`).attr("fill-opacity","0").attr("width",u).attr("height",u),c.attr("class","architecture-junction");const{width:l,height:s}=c._groups[0][0].getBBox();c.width=l,c.height=s,e.setElementForId(n.id,c)})},"drawJunctions");Tt([{name:R.prefix,icons:R}]);tt.use(It);function st(e,t,i){e.forEach(r=>{t.add({group:"nodes",data:{type:"service",id:r.id,icon:r.icon,label:r.title,parent:r.in,width:i.getConfigField("iconSize"),height:i.getConfigField("iconSize")},classes:"node-service"})})}f(st,"addServices");function ot(e,t,i){e.forEach(r=>{t.add({group:"nodes",data:{type:"junction",id:r.id,parent:r.in,width:i.getConfigField("iconSize"),height:i.getConfigField("iconSize")},classes:"node-junction"})})}f(ot,"addJunctions");function nt(e,t){t.nodes().map(i=>{const r=P(i);if(r.type==="group")return;r.x=i.position().x,r.y=i.position().y,e.getElementById(r.id).attr("transform","translate("+(r.x||0)+","+(r.y||0)+")")})}f(nt,"positionNodes");function at(e,t){e.forEach(i=>{t.add({group:"nodes",data:{type:"group",id:i.id,icon:i.icon,label:i.title,parent:i.in},classes:"node-group"})})}f(at,"addGroups");function ct(e,t){e.forEach(i=>{const{lhsId:r,rhsId:n,lhsInto:c,lhsGroup:u,rhsInto:d,lhsDir:l,rhsDir:s,rhsGroup:o,title:a}=i,g=V(i.lhsDir,i.rhsDir)?"segments":"straight",h={id:`${r}-${n}`,label:a,source:r,sourceDir:l,sourceArrow:c,sourceGroup:u,sourceEndpoint:l==="L"?"0 50%":l==="R"?"100% 50%":l==="T"?"50% 0":"50% 100%",target:n,targetDir:s,targetArrow:d,targetGroup:o,targetEndpoint:s==="L"?"0 50%":s==="R"?"100% 50%":s==="T"?"50% 0":"50% 100%"};t.add({group:"edges",data:h,classes:g})})}f(ct,"addEdges");function lt(e,t,i){const r=f((d,l)=>Object.entries(d).reduce((s,[o,a])=>{var y;let g=0;const h=Object.entries(a);if(h.length===1)return s[o]=h[0][1],s;for(let p=0;p<h.length-1;p++)for(let k=p+1;k<h.length;k++){const[w,$]=h[p],[m,b]=h[k];if(((y=i[w])==null?void 0:y[m])===l)s[o]??(s[o]=[]),s[o]=[...s[o],...$,...b];else if(w==="default"||m==="default")s[o]??(s[o]=[]),s[o]=[...s[o],...$,...b];else{const B=`${o}-${g++}`;s[B]=$;const v=`${o}-${g++}`;s[v]=b}}return s},{}),"flattenAlignments"),n=t.map(d=>{const l={},s={};return Object.entries(d).forEach(([o,[a,g]])=>{var y,p,k;const h=((y=e.getNode(o))==null?void 0:y.in)??"default";l[g]??(l[g]={}),(p=l[g])[h]??(p[h]=[]),l[g][h].push(o),s[a]??(s[a]={}),(k=s[a])[h]??(k[h]=[]),s[a][h].push(o)}),{horiz:Object.values(r(l,"horizontal")).filter(o=>o.length>1),vert:Object.values(r(s,"vertical")).filter(o=>o.length>1)}}),[c,u]=n.reduce(([d,l],{horiz:s,vert:o})=>[[...d,...s],[...l,...o]],[[],[]]);return{horizontal:c,vertical:u}}f(lt,"getAlignments");function dt(e,t){const i=[],r=f(c=>`${c[0]},${c[1]}`,"posToStr"),n=f(c=>c.split(",").map(u=>parseInt(u)),"strToPos");return e.forEach(c=>{const u=Object.fromEntries(Object.entries(c).map(([o,a])=>[r(a),o])),d=[r([0,0])],l={},s={L:[-1,0],R:[1,0],T:[0,1],B:[0,-1]};for(;d.length>0;){const o=d.shift();if(o){l[o]=1;const a=u[o];if(a){const g=n(o);Object.entries(s).forEach(([h,y])=>{const p=r([g[0]+y[0],g[1]+y[1]]),k=u[p];k&&!l[p]&&(d.push(p),i.push({[W[h]]:k,[W[Lt(h)]]:a,gap:1.5*t.getConfigField("iconSize")}))})}}}}),i}f(dt,"getRelativeConstraints");function ft(e,t,i,r,n,{spatialMaps:c,groupAlignments:u}){return new Promise(d=>{const l=St("body").append("div").attr("id","cy").attr("style","display:none"),s=tt({container:document.getElementById("cy"),style:[{selector:"edge",style:{"curve-style":"straight","source-endpoint":"data(sourceEndpoint)","target-endpoint":"data(targetEndpoint)"}},{selector:"edge[label]",style:{label:"data(label)"}},{selector:"edge.segments",style:{"curve-style":"segments","segment-weights":"0","segment-distances":[.5],"edge-distances":"endpoints","source-endpoint":"data(sourceEndpoint)","target-endpoint":"data(targetEndpoint)"}},{selector:"node",style:{"compound-sizing-wrt-labels":"include"}},{selector:"node[label]",style:{"text-valign":"bottom","text-halign":"center","font-size":`${n.getConfigField("fontSize")}px`}},{selector:".node-service",style:{label:"data(label)",width:"data(width)",height:"data(height)"}},{selector:".node-junction",style:{width:"data(width)",height:"data(height)"}},{selector:".node-group",style:{padding:`${n.getConfigField("padding")}px`}}],layout:{name:"grid",boundingBox:{x1:0,x2:100,y1:0,y2:100}}});l.remove(),at(i,s),st(e,s,n),ot(t,s,n),ct(r,s);const o=lt(n,c,u),a=dt(c,n),g=n.getConfigField("iconSize"),h=n.getConfigField("idealEdgeLengthMultiplier")*g,y=.5*g,p=n.getConfigField("edgeElasticity"),k=s.layout({name:"fcose",quality:"proof",randomize:n.getConfigField("randomize"),nodeSeparation:n.getConfigField("nodeSeparation"),numIter:n.getConfigField("numIter"),styleEnabled:!1,animate:!1,nodeDimensionsIncludeLabels:!1,idealEdgeLength(w){const[$,m]=w.connectedNodes(),{parent:b}=P($),{parent:E}=P(m);return b===E?h:y},edgeElasticity(w){const[$,m]=w.connectedNodes(),{parent:b}=P($),{parent:E}=P(m);return b===E?p:.001},alignmentConstraint:o,relativePlacementConstraint:a});k.one("layoutstop",()=>{var $;function w(m,b,E,B){let v,S;const{x,y:A}=m,{x:j,y:L}=b;S=(B-A+(x-E)*(A-L)/(x-j))/Math.sqrt(1+Math.pow((A-L)/(x-j),2)),v=Math.sqrt(Math.pow(B-A,2)+Math.pow(E-x,2)-Math.pow(S,2));const I=Math.sqrt(Math.pow(j-x,2)+Math.pow(L-A,2));v=v/I;let D=(j-x)*(B-A)-(L-A)*(E-x);switch(!0){case D>=0:D=1;break;case D<0:D=-1;break}let C=(j-x)*(E-x)+(L-A)*(B-A);switch(!0){case C>=0:C=1;break;case C<0:C=-1;break}return S=Math.abs(S)*D,v=v*C,{distances:S,weights:v}}f(w,"getSegmentWeights"),s.startBatch();for(const m of Object.values(s.edges()))if(($=m.data)!=null&&$.call(m)){const{x:b,y:E}=m.source().position(),{x:B,y:v}=m.target().position();if(b!==B&&E!==v){const S=m.sourceEndpoint(),x=m.targetEndpoint(),{sourceDir:A}=et(m),[j,L]=z(A)?[S.x,x.y]:[x.x,S.y],{weights:I,distances:D}=w(S,x,j,L);m.style("segment-distances",D),m.style("segment-weights",I)}}s.endBatch(),k.run()}),k.run(),s.ready(w=>{K.info("Ready",w),d(s)})})}f(ft,"layoutArchitecture");var qt=f(async(e,t,i,r)=>{const n=r.db;n.setDiagramId(t);const c=n.getServices(),u=n.getJunctions(),d=n.getGroups(),l=n.getEdges(),s=n.getDataStructures(),o=ht(t),a=o.append("g");a.attr("class","architecture-edges");const g=o.append("g");g.attr("class","architecture-services");const h=o.append("g");h.attr("class","architecture-groups"),await Zt(n,g,c,t),Vt(n,g,u,t);const y=await ft(c,u,d,l,n,s);await _t(a,y,n,t),await Jt(h,y,n,t),nt(n,y),gt(void 0,o,n.getConfigField("padding"),n.getConfigField("useMaxWidth"))},"draw"),Ht={draw:qt},ne={parser:rt,get db(){return new it},renderer:Ht,styles:Nt};export{ne as diagram};