@bkm016/basalt 0.1.14 → 0.1.15

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 (126) hide show
  1. package/{chunk-nysatg77.js → chunk-5n1qra6k.js} +45 -43
  2. package/{chunk-xk3t5ves.js → chunk-tszctb17.js} +130 -130
  3. package/compiled.js +1 -1
  4. package/package.json +1 -1
  5. package/ui-test-worker.js +1 -1
  6. package/web/chunk-00swes3c.js +1 -0
  7. package/web/{chunk-vg346gxc.js → chunk-01nbc18z.js} +1 -1
  8. package/web/chunk-0e995hjg.js +1 -0
  9. package/web/{chunk-y3tb6410.js → chunk-1bhpfsvr.js} +1 -1
  10. package/web/{chunk-w5q7978e.js → chunk-1v6hhgc6.js} +1 -1
  11. package/web/{chunk-qcdej581.js → chunk-251yw6f2.js} +1 -1
  12. package/web/{chunk-vpegzgzb.js → chunk-27cntdyk.js} +1 -1
  13. package/web/{chunk-kk5rw81s.js → chunk-2tm4xe0j.js} +1 -1
  14. package/web/{chunk-4qehf2xx.js → chunk-3egthz5k.js} +1 -1
  15. package/web/{chunk-tdzh6nsz.js → chunk-3f8fjee5.js} +1 -1
  16. package/web/chunk-3fjzgpaw.js +1 -0
  17. package/web/{chunk-d3hyf9yd.js → chunk-3hy2gsgf.js} +1 -1
  18. package/web/chunk-3mgzqbc8.js +1 -0
  19. package/web/chunk-3yvanftw.js +1 -0
  20. package/web/{chunk-ffywf5w5.js → chunk-3zs2v6b4.js} +1 -1
  21. package/web/{chunk-zx3h7v72.js → chunk-43194184.js} +1 -1
  22. package/web/{chunk-9h0f3gar.js → chunk-43bczb21.js} +1 -1
  23. package/web/{chunk-jzge034r.js → chunk-4m9mgdaa.js} +1 -1
  24. package/web/{chunk-2gvz70wr.js → chunk-4q2jtvwn.js} +1 -1
  25. package/web/{chunk-rjakb64x.js → chunk-4tbhxtnm.js} +1 -1
  26. package/web/{chunk-wspk8qbg.js → chunk-50vgq2nk.js} +1 -1
  27. package/web/{chunk-zkq1xknc.js → chunk-57b8j192.js} +1 -1
  28. package/web/{chunk-410qdvmv.js → chunk-5fzmk43v.js} +1 -1
  29. package/web/{chunk-we4mhfmq.js → chunk-5rwg3qqd.js} +1 -1
  30. package/web/{chunk-54mgncq3.js → chunk-62gj74fq.js} +1 -1
  31. package/web/chunk-64h7k870.js +1 -0
  32. package/web/{chunk-797bh7z6.js → chunk-65ay0j1t.js} +1 -1
  33. package/web/{chunk-y6mcxfm0.js → chunk-66164wmv.js} +1 -1
  34. package/web/{chunk-sgkevxdf.js → chunk-6s1vjny7.js} +1 -1
  35. package/web/{chunk-tjd8qp87.js → chunk-6x1hfjb9.js} +1 -1
  36. package/web/{chunk-zpzvz973.js → chunk-6xfbh4z5.js} +1 -1
  37. package/web/{chunk-3rxhs9qm.js → chunk-7frnjms9.js} +1 -1
  38. package/web/chunk-7jh6zxg3.js +1 -0
  39. package/web/chunk-7mgwejn4.js +1 -0
  40. package/web/{chunk-2c7kxr4v.js → chunk-8nm0mghm.js} +1 -1
  41. package/web/{chunk-ahn2frbt.js → chunk-8qzsxg1q.js} +1 -1
  42. package/web/{chunk-vxm7n7w6.js → chunk-937ndmh1.js} +1 -1
  43. package/web/chunk-95gbcs8j.js +1 -0
  44. package/web/{chunk-faskbfjf.js → chunk-aw6wg8fe.js} +1 -1
  45. package/web/{chunk-ppa21760.js → chunk-b323qea5.js} +1 -1
  46. package/web/{chunk-npw1s1h2.js → chunk-bcx7xges.js} +1 -1
  47. package/web/{chunk-k9fyqrhp.js → chunk-bzdn9sxz.js} +1 -1
  48. package/web/{chunk-c7fqrs8j.js → chunk-cq1f20k6.js} +1 -1
  49. package/web/{chunk-feanedhx.js → chunk-dde64qjd.js} +1 -1
  50. package/web/{chunk-p4pqtybm.js → chunk-dgepxev9.js} +2 -2
  51. package/web/{chunk-nfpff7yf.js → chunk-djnq1w1e.js} +2 -2
  52. package/web/{chunk-snaepr87.js → chunk-ea6b8b50.js} +1 -1
  53. package/web/{chunk-qftcdcps.js → chunk-ed5xfgxb.js} +1 -1
  54. package/web/{chunk-783s8jds.js → chunk-ehz9m6g4.js} +1 -1
  55. package/web/chunk-evp6t44y.js +8 -0
  56. package/web/chunk-eyg28s83.js +1 -0
  57. package/web/{chunk-r8p741qj.js → chunk-fttdbcqv.js} +1 -1
  58. package/web/chunk-g9bqacq1.js +1 -0
  59. package/web/chunk-gh8kjzdj.js +1 -0
  60. package/web/{chunk-ve9dz857.js → chunk-jab2p5zv.js} +1 -1
  61. package/web/{chunk-ysw5fs45.js → chunk-jca9xbe0.js} +1 -1
  62. package/web/chunk-jpf8x9tm.js +1 -0
  63. package/web/{chunk-3haw3wcw.js → chunk-jx3z63tq.js} +1 -1
  64. package/web/{chunk-ty2rmwda.js → chunk-jy448465.js} +89 -89
  65. package/web/{chunk-51b8n5e1.js → chunk-k3ah0513.js} +1 -1
  66. package/web/{chunk-dwtatme7.js → chunk-ksnsfqrn.js} +1 -1
  67. package/web/{chunk-ex8rmqn1.js → chunk-kxr473dw.js} +1 -1
  68. package/web/{chunk-wkhj4hsw.js → chunk-m5psa69k.js} +1 -1
  69. package/web/{chunk-8ttp8fh3.js → chunk-mss6eg27.js} +1 -1
  70. package/web/{chunk-g3szt4c4.js → chunk-mv9q8jrm.js} +1 -1
  71. package/web/{chunk-59g6rrew.js → chunk-n0ezfa12.js} +1 -1
  72. package/web/{chunk-mvm68qtt.js → chunk-p1bb9xp8.js} +1 -1
  73. package/web/{chunk-mv7jgmnb.js → chunk-pa82db2e.js} +1 -1
  74. package/web/{chunk-7hpqrfgg.js → chunk-pdmcr6d4.js} +1 -1
  75. package/web/{chunk-8sr9w61v.js → chunk-phj4pcx4.js} +1 -1
  76. package/web/{chunk-xhqvzmfj.js → chunk-pma5pats.js} +1 -1
  77. package/web/{chunk-ptpkv0te.js → chunk-pmghe7rh.js} +1 -1
  78. package/web/{chunk-s45g7fp6.js → chunk-ppfhtyxt.js} +1 -1
  79. package/web/chunk-pze2v3v1.js +2 -0
  80. package/web/{chunk-mn2wv9ye.js → chunk-q6j2e8a1.js} +1 -1
  81. package/web/chunk-q6jf3zc1.js +1 -0
  82. package/web/{chunk-xf1hnpme.js → chunk-qdn3hmfy.js} +1 -1
  83. package/web/{chunk-s2ps0ct5.js → chunk-qdsg8wp0.js} +1 -1
  84. package/web/{chunk-32dh0hft.js → chunk-qf2kb7zj.js} +1 -1
  85. package/web/{chunk-7kywe73f.js → chunk-s6bc73n3.js} +1 -1
  86. package/web/chunk-sdtesqbb.js +1 -0
  87. package/web/chunk-t0z8ygx4.js +1 -0
  88. package/web/{chunk-bahccwb9.js → chunk-t2v01k4z.js} +1 -1
  89. package/web/{chunk-zsat72qd.js → chunk-t5ke9cyg.js} +2 -2
  90. package/web/{chunk-j6wcszxq.js → chunk-t72z2ww3.js} +1 -1
  91. package/web/{chunk-ya696bfe.js → chunk-t78qm9gs.js} +1 -1
  92. package/web/{chunk-aknsydan.js → chunk-te15yhn5.js} +1 -1
  93. package/web/{chunk-2gsf89vs.js → chunk-tvaxyhh0.js} +1 -1
  94. package/web/{chunk-9vr6hpmk.js → chunk-vypfy030.js} +1 -1
  95. package/web/chunk-w7cyrbk2.js +1 -0
  96. package/web/{chunk-fx3d48e6.js → chunk-w9nkvcjr.js} +1 -1
  97. package/web/chunk-x2f8bwd2.js +1 -0
  98. package/web/chunk-xq8x7dvr.js +1 -0
  99. package/web/{chunk-p79c7aak.js → chunk-yeh77fvq.js} +1 -1
  100. package/web/{chunk-kpmd893m.js → chunk-ymtq18z6.js} +1 -1
  101. package/web/{chunk-s70aj1v5.js → chunk-yzmrbssn.js} +1 -1
  102. package/web/{chunk-988e9wx6.js → chunk-z5h046zm.js} +1 -1
  103. package/web/{chunk-78m018ya.js → chunk-zf4b8jb9.js} +1 -1
  104. package/web/index.html +1 -1
  105. package/web/sw.js +17 -1
  106. package/web/chunk-15g9pnzy.js +0 -1
  107. package/web/chunk-19tkjg9w.js +0 -1
  108. package/web/chunk-26sp6jre.js +0 -1
  109. package/web/chunk-2s3my1jn.js +0 -1
  110. package/web/chunk-6481wt3t.js +0 -1
  111. package/web/chunk-6m8hq6ph.js +0 -1
  112. package/web/chunk-9vrp249f.js +0 -2
  113. package/web/chunk-dcegr80c.js +0 -1
  114. package/web/chunk-gr1tjqbd.js +0 -1
  115. package/web/chunk-jge7nn3s.js +0 -1
  116. package/web/chunk-kg3tksv7.js +0 -1
  117. package/web/chunk-nk7jkpam.js +0 -1
  118. package/web/chunk-nmvt1rn3.js +0 -1
  119. package/web/chunk-nzzxv84v.js +0 -8
  120. package/web/chunk-rcexbkjj.js +0 -1
  121. package/web/chunk-say8bvkc.js +0 -1
  122. package/web/chunk-sjffrcq9.js +0 -1
  123. package/web/chunk-tncc9e57.js +0 -1
  124. package/web/chunk-v22hp18w.js +0 -1
  125. package/web/chunk-xq70hgre.js +0 -1
  126. package/web/chunk-zkv025s5.js +0 -1
@@ -0,0 +1 @@
1
+ import"./chunk-t5ke9cyg.js";import"./chunk-bzdn9sxz.js";import{$o}from"./chunk-27cntdyk.js";import"./chunk-1v6hhgc6.js";import"./chunk-pze2v3v1.js";import"./chunk-66164wmv.js";import"./chunk-k3ah0513.js";export{$o as diagram};
@@ -0,0 +1 @@
1
+ import{Ti}from"./chunk-dgepxev9.js";export{Ti as createRadarServices};
@@ -1,2 +1,2 @@
1
- import{t,a,x,l,M,P,Tt,Et,To,bt,en,Eo,Xn,Me,Ao,eo,At,to,tn,Qn}from"./chunk-zsat72qd.js";import{re}from"./chunk-tdzh6nsz.js";import{_}from"./chunk-ty2rmwda.js";function fa(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),u=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:u,rootGroups:n}}t(fa,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await P(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function ha(e,r,n){let i=await Et(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(ha,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new re({multigraph:!0,compound:!0}),s=[...r.edges],o=l(),u=fa(e),{edgeLabels:d,nodes:c}=u,g=new Map,b=new Map(r.nodes.map((f)=>[f.id,f])),E=r.direction,h=e.node()!=null;await Promise.all(r.nodes.map(async(f)=>{if(f.isGroup){if(h){let w=n.unwrapGroupLabels&&f.labelType!=="markdown";await L(c,f,w?Number.POSITIVE_INFINITY:void 0)}i.setNode(f.id,{...f})}else{if(h){let w=await ha(c,f,{config:o,dir:D(f,b,E)});g.set(f.id,w)}i.setNode(f.id,{...f})}}));for(let f of s){if(h&&eo(f))await At(d,f);if(i.setEdge(f.start,f.end,{...f},f.id),!r.edges.some((v)=>v.id===f.id))r.edges.push(f)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:f}=await (_("ahn2frbt"),import("./chunk-ahn2frbt.js"));f(e,r)}return{graph:i,groups:u,nodeElements:g}}t(S,"createGraphWithElements");var W=new Map,m=new Map,k=new Map,U=t(()=>{m.clear(),k.clear(),W.clear()},"clear"),p=t((e,r)=>{let n=m.get(r)||[];return a.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Z=t((e,r)=>{let n=m.get(r)||[];if(a.info("Descendants of ",r," is ",n),a.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return a.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||p(e.v,r)||p(e.w,r)||n.includes(e.w)},"edgeInCluster"),R=t((e,r,n,i)=>{a.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);a.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)R(o,r,n,i);else{let u=r.node(o);if(a.info("cp ",o," to ",i," with parent ",e),n.setNode(o,u),i!==r.parent(o))a.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)a.debug("Setting parent",o,e),n.setParent(o,e);else a.info("In copy ",e,"root",i,"data",r.node(e),i),a.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let d=r.edges(o);a.debug("Copying Edges",d),d.forEach((c)=>{a.info("Edge",c);let g=r.edge(c.v,c.w,c.name);a.info("Edge data",g,i);try{if(Z(c,i))a.info("Copying as ",c.v,c.w,g,c.name),n.setEdge(c.v,c.w,g,c.name),a.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else a.info("Skipping copy of edge ",c.v,"-->",c.w," rootId: ",i," clusterId:",e)}catch(b){a.error(b)}})}a.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)k.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),I=t((e,r,n)=>{let i=e.edges().filter((c)=>c.v===r||c.w===r),s=e.edges().filter((c)=>c.v===n||c.w===n),o=i.map((c)=>({v:c.v===r?n:c.v,w:c.w===r?r:c.w})),u=s.map((c)=>({v:c.v,w:c.w}));return o.filter((c)=>u.some((g)=>c.v===g.v&&c.w===g.w))},"findCommonEdges"),Un=t((e,r,n)=>{let i=r.children(e);if(a.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let u=Un(o,r,n),d=I(r,n,u);if(u)if(d.length>0)s=u;else return u}return s},"findNonClusterChild"),y=t((e)=>{if(!W.has(e))return e;if(!W.get(e).externalConnections)return e;if(W.has(e))return W.get(e).id;return e},"getAnchorId"),co=t((e,r)=>{if(!e||r>10){a.debug("Opting out, no graph ");return}else a.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)a.debug("Cluster identified",n," Replacement id in edges: ",Un(n,e,n)),m.set(n,T(n,e)),W.set(n,{id:Un(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)a.debug("Cluster identified",n,m),s.forEach((o)=>{let u=p(o.v,n),d=p(o.w,n);if(u^d)a.debug("Edge: ",o," leaves cluster ",n),a.debug("Descendants of XXX ",n,": ",m.get(n)),W.get(n).externalConnections=!0});else a.debug("Not a cluster ",n,m)});for(let n of W.keys()){let i=W.get(n).id,s=e.parent(i);if(s!==n&&W.has(s)&&!W.get(s).externalConnections)W.get(n).id=s;let o=e.edges().some((u)=>u.v===n);if(i&&W.get(n)?.externalConnections&&o&&X(e,i,n)){let u=ee(e,n,e.parent(i));if(u)W.get(n).id=u}}e.edges().forEach(function(n){let i=e.edge(n);a.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),a.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(a.debug("Fix XXX",W,"ids:",n.v,n.w,"Translating: ",W.get(n.v)," --- ",W.get(n.w)),W.get(n.v)||W.get(n.w)){if(a.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=y(n.v),o=y(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let u=e.parent(s);W.get(u).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let u=e.parent(o);W.get(u).externalConnections=!0,i.toCluster=n.w}a.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),B(e,0),a.trace(W)},"adjustClustersAndEdges"),B=t((e,r)=>{if(r>10){a.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){a.debug("Done, no node has children",e.nodes());return}a.debug("Nodes = ",n,r);for(let s of n)if(a.debug("Extracting node",s,W,W.has(s)&&!W.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!W.has(s))a.debug("Not a cluster",s,r);else if(!W.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){a.debug("Cluster without external connections, without a parent and with children",s,r);let u=e.graph().rankdir==="TB"?"LR":"TB";if(W.get(s)?.clusterData?.dir)u=W.get(s).clusterData.dir,a.debug("Fixing dir",W.get(s).clusterData.dir,u);let d=new re({multigraph:!0,compound:!0}).setGraph({rankdir:u,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});R(s,e,d,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:W.get(s).clusterData,label:W.get(s).label,graph:d})}else a.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!W.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),a.debug(W);n=e.nodes(),a.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(a.debug(" Now next level",s,o),o?.clusterNode)B(o.graph,r+1)}},"extractor"),A=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=A(e,s);n=[...n,...o]}),n},"sorter"),ga=t((e)=>A(e,e.children()),"sortNodesByHierarchy"),X=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=W.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),ee=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||p(s,n))continue;let o=Un(s,e,r);if(!o)continue;if(!X(e,o,r))return o}return null},"findSafeAnchorNode");function ur({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let u=r??O;return t(async function(c,g,b,E){let h=g.select("g");(b?.insertMarkers??Qn)(h,c.markers,c.type,c.diagramId),G();let f={element:h,helpers:b,options:E};f.preparedLayout=await e?.(c,f);let w=await u(c,f),v=await n(c,f),C={...f,measure:w};if(i)await i(c,C,v);else await F(c,C,o);await s?.(c,C,v)},"render")}t(ur,"createCommonLayoutRenderer");function G(){To(),Ao(),Eo(),U()}t(G,"clearLayoutRenderState");async function O(e,{element:r},n){return await S(r,e,n)}t(O,"defaultMeasureLayout");async function F(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let u of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(u,r))continue;await j(s,u,r,n)}let o=z(e.nodes);for(let u of e.edges){if(J(u,n))continue;await V(s,u,o,e,n,r)}}t(F,"paintLayoutData");async function j(e,r,n,i){if(r.clusterNode)bt(r);else if(H(r,n,i))await en(e.clusters,r);else bt(r)}t(j,"paintLayoutNode");function H(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(H,"shouldPaintAsCluster");function z(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(z,"buildNodeLookup");function J(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(J,"shouldSkipPaintEdge");async function V(e,r,n,i,s,o){let u=tn(e.edgePaths,{...r},s.clusterDb??new Map,i.type,N(r.start,r,n,o,s),N(r.end,r,n,o,s),i.diagramId,Y(r,s),i.layoutAlgorithm);if(eo(r)){if(!Xn.has(r.id))await At(e.edgeLabels,r);q(r,u)}}t(V,"paintLayoutEdge");function N(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(N,"getRenderedNode");function Y(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(Y,"shouldSkipIntersect");function q(e,r){let n=r?.updatedPath??r?.originalPath,i=x(),{subGraphTitleTotalMargin:s}=Tt({flowchart:i.flowchart??{}});if(e.label){let o=Xn.get(e.id),{x:u,y:d}=to(e,r);o.attr("transform",`translate(${u}, ${d+s/2})`)}for(let[o,u]of[["startLeft",e.startLabelLeft],["startRight",e.startLabelRight],["endLeft",e.endLabelLeft],["endRight",e.endLabelRight]])if(u){let{x:d,y:c}=K(e,o,n);Me.get(e.id)[o].attr("transform",`translate(${d}, ${c})`)}}t(q,"positionRenderedEdgeLabel");var te={startLeft:"start_left",startRight:"start_right",endLeft:"end_left",endRight:"end_right"};function K(e,r,n){let i=e.terminalLabelCenters?.[r];if(i)return{...i};if(!n)return{x:e.x,y:e.y};let s=r.startsWith("start")?e.arrowTypeStart:e.arrowTypeEnd;return M.calcTerminalLabelPosition(s?10:0,te[r],n)}t(K,"terminalLabelTranslate");
1
+ import{t,a,x,l,M,P,Tt,Et,To,bt,en,Eo,Xn,Me,Ao,eo,At,to,tn,Qn}from"./chunk-t5ke9cyg.js";import{re}from"./chunk-3f8fjee5.js";import{_}from"./chunk-jy448465.js";function fa(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),u=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:u,rootGroups:n}}t(fa,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await P(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function ha(e,r,n){let i=await Et(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(ha,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new re({multigraph:!0,compound:!0}),s=[...r.edges],o=l(),u=fa(e),{edgeLabels:d,nodes:c}=u,g=new Map,b=new Map(r.nodes.map((f)=>[f.id,f])),E=r.direction,h=e.node()!=null;await Promise.all(r.nodes.map(async(f)=>{if(f.isGroup){if(h){let w=n.unwrapGroupLabels&&f.labelType!=="markdown";await L(c,f,w?Number.POSITIVE_INFINITY:void 0)}i.setNode(f.id,{...f})}else{if(h){let w=await ha(c,f,{config:o,dir:D(f,b,E)});g.set(f.id,w)}i.setNode(f.id,{...f})}}));for(let f of s){if(h&&eo(f))await At(d,f);if(i.setEdge(f.start,f.end,{...f},f.id),!r.edges.some((v)=>v.id===f.id))r.edges.push(f)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:f}=await (_("8qzsxg1q"),import("./chunk-8qzsxg1q.js"));f(e,r)}return{graph:i,groups:u,nodeElements:g}}t(S,"createGraphWithElements");var W=new Map,m=new Map,k=new Map,U=t(()=>{m.clear(),k.clear(),W.clear()},"clear"),p=t((e,r)=>{let n=m.get(r)||[];return a.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),Z=t((e,r)=>{let n=m.get(r)||[];if(a.info("Descendants of ",r," is ",n),a.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return a.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||p(e.v,r)||p(e.w,r)||n.includes(e.w)},"edgeInCluster"),R=t((e,r,n,i)=>{a.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);a.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)R(o,r,n,i);else{let u=r.node(o);if(a.info("cp ",o," to ",i," with parent ",e),n.setNode(o,u),i!==r.parent(o))a.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)a.debug("Setting parent",o,e),n.setParent(o,e);else a.info("In copy ",e,"root",i,"data",r.node(e),i),a.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let d=r.edges(o);a.debug("Copying Edges",d),d.forEach((c)=>{a.info("Edge",c);let g=r.edge(c.v,c.w,c.name);a.info("Edge data",g,i);try{if(Z(c,i))a.info("Copying as ",c.v,c.w,g,c.name),n.setEdge(c.v,c.w,g,c.name),a.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else a.info("Skipping copy of edge ",c.v,"-->",c.w," rootId: ",i," clusterId:",e)}catch(b){a.error(b)}})}a.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)k.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),I=t((e,r,n)=>{let i=e.edges().filter((c)=>c.v===r||c.w===r),s=e.edges().filter((c)=>c.v===n||c.w===n),o=i.map((c)=>({v:c.v===r?n:c.v,w:c.w===r?r:c.w})),u=s.map((c)=>({v:c.v,w:c.w}));return o.filter((c)=>u.some((g)=>c.v===g.v&&c.w===g.w))},"findCommonEdges"),Un=t((e,r,n)=>{let i=r.children(e);if(a.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let u=Un(o,r,n),d=I(r,n,u);if(u)if(d.length>0)s=u;else return u}return s},"findNonClusterChild"),y=t((e)=>{if(!W.has(e))return e;if(!W.get(e).externalConnections)return e;if(W.has(e))return W.get(e).id;return e},"getAnchorId"),co=t((e,r)=>{if(!e||r>10){a.debug("Opting out, no graph ");return}else a.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)a.debug("Cluster identified",n," Replacement id in edges: ",Un(n,e,n)),m.set(n,T(n,e)),W.set(n,{id:Un(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)a.debug("Cluster identified",n,m),s.forEach((o)=>{let u=p(o.v,n),d=p(o.w,n);if(u^d)a.debug("Edge: ",o," leaves cluster ",n),a.debug("Descendants of XXX ",n,": ",m.get(n)),W.get(n).externalConnections=!0});else a.debug("Not a cluster ",n,m)});for(let n of W.keys()){let i=W.get(n).id,s=e.parent(i);if(s!==n&&W.has(s)&&!W.get(s).externalConnections)W.get(n).id=s;let o=e.edges().some((u)=>u.v===n);if(i&&W.get(n)?.externalConnections&&o&&X(e,i,n)){let u=ee(e,n,e.parent(i));if(u)W.get(n).id=u}}e.edges().forEach(function(n){let i=e.edge(n);a.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),a.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(a.debug("Fix XXX",W,"ids:",n.v,n.w,"Translating: ",W.get(n.v)," --- ",W.get(n.w)),W.get(n.v)||W.get(n.w)){if(a.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=y(n.v),o=y(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let u=e.parent(s);W.get(u).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let u=e.parent(o);W.get(u).externalConnections=!0,i.toCluster=n.w}a.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),B(e,0),a.trace(W)},"adjustClustersAndEdges"),B=t((e,r)=>{if(r>10){a.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){a.debug("Done, no node has children",e.nodes());return}a.debug("Nodes = ",n,r);for(let s of n)if(a.debug("Extracting node",s,W,W.has(s)&&!W.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!W.has(s))a.debug("Not a cluster",s,r);else if(!W.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){a.debug("Cluster without external connections, without a parent and with children",s,r);let u=e.graph().rankdir==="TB"?"LR":"TB";if(W.get(s)?.clusterData?.dir)u=W.get(s).clusterData.dir,a.debug("Fixing dir",W.get(s).clusterData.dir,u);let d=new re({multigraph:!0,compound:!0}).setGraph({rankdir:u,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});R(s,e,d,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:W.get(s).clusterData,label:W.get(s).label,graph:d})}else a.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!W.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),a.debug(W);n=e.nodes(),a.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(a.debug(" Now next level",s,o),o?.clusterNode)B(o.graph,r+1)}},"extractor"),A=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=A(e,s);n=[...n,...o]}),n},"sorter"),ga=t((e)=>A(e,e.children()),"sortNodesByHierarchy"),X=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=W.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),ee=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||p(s,n))continue;let o=Un(s,e,r);if(!o)continue;if(!X(e,o,r))return o}return null},"findSafeAnchorNode");function ur({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let u=r??O;return t(async function(c,g,b,E){let h=g.select("g");(b?.insertMarkers??Qn)(h,c.markers,c.type,c.diagramId),G();let f={element:h,helpers:b,options:E};f.preparedLayout=await e?.(c,f);let w=await u(c,f),v=await n(c,f),C={...f,measure:w};if(i)await i(c,C,v);else await F(c,C,o);await s?.(c,C,v)},"render")}t(ur,"createCommonLayoutRenderer");function G(){To(),Ao(),Eo(),U()}t(G,"clearLayoutRenderState");async function O(e,{element:r},n){return await S(r,e,n)}t(O,"defaultMeasureLayout");async function F(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let u of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(u,r))continue;await j(s,u,r,n)}let o=z(e.nodes);for(let u of e.edges){if(J(u,n))continue;await V(s,u,o,e,n,r)}}t(F,"paintLayoutData");async function j(e,r,n,i){if(r.clusterNode)bt(r);else if(H(r,n,i))await en(e.clusters,r);else bt(r)}t(j,"paintLayoutNode");function H(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(H,"shouldPaintAsCluster");function z(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(z,"buildNodeLookup");function J(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(J,"shouldSkipPaintEdge");async function V(e,r,n,i,s,o){let u=tn(e.edgePaths,{...r},s.clusterDb??new Map,i.type,N(r.start,r,n,o,s),N(r.end,r,n,o,s),i.diagramId,Y(r,s),i.layoutAlgorithm);if(eo(r)){if(!Xn.has(r.id))await At(e.edgeLabels,r);q(r,u)}}t(V,"paintLayoutEdge");function N(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(N,"getRenderedNode");function Y(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(Y,"shouldSkipIntersect");function q(e,r){let n=r?.updatedPath??r?.originalPath,i=x(),{subGraphTitleTotalMargin:s}=Tt({flowchart:i.flowchart??{}});if(e.label){let o=Xn.get(e.id),{x:u,y:d}=to(e,r);o.attr("transform",`translate(${u}, ${d+s/2})`)}for(let[o,u]of[["startLeft",e.startLabelLeft],["startRight",e.startLabelRight],["endLeft",e.endLabelLeft],["endRight",e.endLabelRight]])if(u){let{x:d,y:c}=K(e,o,n);Me.get(e.id)[o].attr("transform",`translate(${d}, ${c})`)}}t(q,"positionRenderedEdgeLabel");var te={startLeft:"start_left",startRight:"start_right",endLeft:"end_left",endRight:"end_right"};function K(e,r,n){let i=e.terminalLabelCenters?.[r];if(i)return{...i};if(!n)return{x:e.x,y:e.y};let s=r.startsWith("start")?e.arrowTypeStart:e.arrowTypeEnd;return M.calcTerminalLabelPosition(s?10:0,te[r],n)}t(K,"terminalLabelTranslate");
2
2
  export{fa,ha,W,Un,co,ga,ur};
@@ -1 +1 @@
1
- import{t}from"./chunk-zsat72qd.js";var c=1;function i(){if(typeof globalThis>"u")return;return globalThis}t(i,"getCaptureGlobal");function p(){return Boolean(i()?.mermaidCaptureSizes)}t(p,"shouldCaptureSizes");function u(){if(typeof location>"u")return"browser-dev";return`${location.pathname}${location.search}`}t(u,"capturedFromLocation");function d(n,r){let o=i();if(!o)return;let e=r.node(),s=((e&&"ownerSVGElement"in e?e.ownerSVGElement:null)??e)?.id??"(unknown)";o.mermaidCapturedSizes??=[];let a={svgId:s,sizes:n};o.mermaidCapturedSizes.push(a),o.mermaidLastCapturedSizes=a}t(d,"emitCapturedSizes");function m(n,r){let o=[];for(let e of r.nodes){if(e.isGroup)continue;o.push({id:e.id,width:e.width??0,height:e.height??0})}if(o.length===0)return;d({metadata:{captureVersion:c,capturedAt:new Date().toISOString(),capturedFrom:u()},nodes:o},n)}t(m,"captureNodeSizes");export{m as captureNodeSizes};
1
+ import{t}from"./chunk-t5ke9cyg.js";var c=1;function i(){if(typeof globalThis>"u")return;return globalThis}t(i,"getCaptureGlobal");function p(){return Boolean(i()?.mermaidCaptureSizes)}t(p,"shouldCaptureSizes");function u(){if(typeof location>"u")return"browser-dev";return`${location.pathname}${location.search}`}t(u,"capturedFromLocation");function d(n,r){let o=i();if(!o)return;let e=r.node(),s=((e&&"ownerSVGElement"in e?e.ownerSVGElement:null)??e)?.id??"(unknown)";o.mermaidCapturedSizes??=[];let a={svgId:s,sizes:n};o.mermaidCapturedSizes.push(a),o.mermaidLastCapturedSizes=a}t(d,"emitCapturedSizes");function m(n,r){let o=[];for(let e of r.nodes){if(e.isGroup)continue;o.push({id:e.id,width:e.width??0,height:e.height??0})}if(o.length===0)return;d({metadata:{captureVersion:c,capturedAt:new Date().toISOString(),capturedFrom:u()},nodes:o},n)}t(m,"captureNodeSizes");export{m as captureNodeSizes};
@@ -1,4 +1,4 @@
1
- import{h,o,i,r,e,n,y,xt,oe,Z}from"./chunk-ty2rmwda.js";var pn=2,gn=1,ys=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let s=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(s._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,a=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(a.getPropertyValue("height")),c=Math.max(0,parseInt(a.getPropertyValue("width"))),d=window.getComputedStyle(this._terminal.element),u={top:parseInt(d.getPropertyValue("padding-top")),bottom:parseInt(d.getPropertyValue("padding-bottom")),right:parseInt(d.getPropertyValue("padding-right")),left:parseInt(d.getPropertyValue("padding-left"))},f=u.top+u.bottom,p=u.right+u.left,_=l-f,m=c-p-s;return{cols:Math.max(pn,Math.floor(m/t.css.cell.width)),rows:Math.max(gn,Math.floor(_/t.css.cell.height))}}};var{defineProperty:Er,getOwnPropertyDescriptor:mn}=Object,vn=(t,s)=>{for(var a in s)Er(t,a,{get:s[a],enumerable:!0})},te=(t,s,a,l)=>{for(var c=l>1?void 0:l?mn(s,a):s,d=t.length-1,u;d>=0;d--)(u=t[d])&&(c=(l?u(s,a,c):u(c))||c);return l&&c&&Er(s,a,c),c},M=(t,s)=>(a,l)=>s(a,l,t),Cs="Terminal input",Ii={get:()=>Cs,set:(t)=>Cs=t},xs="Too much output to announce, navigate to rows manually to read",Ni={get:()=>xs,set:(t)=>xs=t};function Sn(t){return t.replace(/\r?\n/g,"\r")}function bn(t,s){return s?"\x1B[200~"+t+"\x1B[201~":t}function wn(t,s){t.clipboardData&&t.clipboardData.setData("text/plain",s.selectionText),t.preventDefault()}function yn(t,s,a,l){if(t.stopPropagation(),t.clipboardData){let c=t.clipboardData.getData("text/plain");Dr(c,s,a,l)}}function Dr(t,s,a,l){t=Sn(t),t=bn(t,a.decPrivateModes.bracketedPasteMode&&l.rawOptions.ignoreBracketedPasteMode!==!0),a.triggerDataEvent(t,!0),s.value=""}function Br(t,s,a){let l=a.getBoundingClientRect(),c=t.clientX-l.left-10,d=t.clientY-l.top-10;s.style.width="20px",s.style.height="20px",s.style.left=`${c}px`,s.style.top=`${d}px`,s.style.zIndex="1000",s.focus()}function ks(t,s,a,l,c){Br(t,s,a),c&&l.rightClickSelect(t),s.value=l.selectionText,s.select()}function Ze(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function _i(t,s=0,a=t.length){let l="";for(let c=s;c<a;++c){let d=t[c];d>65535?(d-=65536,l+=String.fromCharCode((d>>10)+55296)+String.fromCharCode(d%1024+56320)):l+=String.fromCharCode(d)}return l}var Cn=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,s){let a=t.length;if(!a)return 0;let l=0,c=0;if(this._interim){let d=t.charCodeAt(c++);56320<=d&&d<=57343?s[l++]=(this._interim-55296)*1024+d-56320+65536:(s[l++]=this._interim,s[l++]=d),this._interim=0}for(let d=c;d<a;++d){let u=t.charCodeAt(d);if(55296<=u&&u<=56319){if(++d>=a)return this._interim=u,l;let f=t.charCodeAt(d);56320<=f&&f<=57343?s[l++]=(u-55296)*1024+f-56320+65536:(s[l++]=u,s[l++]=f);continue}u!==65279&&(s[l++]=u)}return l}},xn=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,s){let a=t.length;if(!a)return 0;let l=0,c,d,u,f,p=0,_=0;if(this.interim[0]){let S=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let v=0,w;for(;(w=this.interim[++v]&63)&&v<4;)b<<=6,b|=w;let R=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,P=R-v;for(;_<P;){if(_>=a)return 0;if(w=t[_++],(w&192)!==128){_--,S=!0;break}else this.interim[v++]=w,b<<=6,b|=w&63}S||(R===2?b<128?_--:s[l++]=b:R===3?b<2048||b>=55296&&b<=57343||b===65279||(s[l++]=b):b<65536||b>1114111||(s[l++]=b)),this.interim.fill(0)}let m=a-4,g=_;for(;g<a;){for(;g<m&&!((c=t[g])&128)&&!((d=t[g+1])&128)&&!((u=t[g+2])&128)&&!((f=t[g+3])&128);)s[l++]=c,s[l++]=d,s[l++]=u,s[l++]=f,g+=4;if(c=t[g++],c<128)s[l++]=c;else if((c&224)===192){if(g>=a)return this.interim[0]=c,l;if(d=t[g++],(d&192)!==128){g--;continue}if(p=(c&31)<<6|d&63,p<128){g--;continue}s[l++]=p}else if((c&240)===224){if(g>=a)return this.interim[0]=c,l;if(d=t[g++],(d&192)!==128){g--;continue}if(g>=a)return this.interim[0]=c,this.interim[1]=d,l;if(u=t[g++],(u&192)!==128){g--;continue}if(p=(c&15)<<12|(d&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;s[l++]=p}else if((c&248)===240){if(g>=a)return this.interim[0]=c,l;if(d=t[g++],(d&192)!==128){g--;continue}if(g>=a)return this.interim[0]=c,this.interim[1]=d,l;if(u=t[g++],(u&192)!==128){g--;continue}if(g>=a)return this.interim[0]=c,this.interim[1]=d,this.interim[2]=u,l;if(f=t[g++],(f&192)!==128){g--;continue}if(p=(c&7)<<18|(d&63)<<12|(u&63)<<6|f&63,p<65536||p>1114111)continue;s[l++]=p}}return l}},Rr="",Qe=" ",zt=class t{constructor(){this.fg=0,this.bg=0,this.extended=new ri}static toColorRGB(s){return[s>>>16&255,s>>>8&255,s&255]}static fromColorRGB(s){return(s[0]&255)<<16|(s[1]&255)<<8|s[2]&255}clone(){let s=new t;return s.fg=this.fg,s.bg=this.bg,s.extended=this.extended.clone(),s}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ri=class t{constructor(s=0,a=0){this._ext=0,this._urlId=0,this._ext=s,this._urlId=a}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(s){this._ext=s}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(s){this._ext&=-469762049,this._ext|=s<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(s){this._ext&=-67108864,this._ext|=s&67108863}get urlId(){return this._urlId}set urlId(s){this._urlId=s}get underlineVariantOffset(){let s=(this._ext&3758096384)>>29;return s<0?s^4294967288:s}set underlineVariantOffset(s){this._ext&=536870911,this._ext|=s<<29&3758096384}clone(){return new t(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Me=class t extends zt{constructor(){super(...arguments);this.content=0,this.fg=0,this.bg=0,this.extended=new ri,this.combinedData=""}static fromCharData(s){let a=new t;return a.setFromCharData(s),a}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ze(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(s){this.fg=s[0],this.bg=0;let a=!1;if(s[1].length>2)a=!0;else if(s[1].length===2){let l=s[1].charCodeAt(0);if(55296<=l&&l<=56319){let c=s[1].charCodeAt(1);56320<=c&&c<=57343?this.content=(l-55296)*1024+c-56320+65536|s[2]<<22:a=!0}else a=!0}else this.content=s[1].charCodeAt(0)|s[2]<<22;a&&(this.combinedData=s[1],this.content=2097152|s[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Es="di$target",Hi="di$dependencies",bi=new Map;function kn(t){return t[Hi]||[]}function pe(t){if(bi.has(t))return bi.get(t);let s=function(a,l,c){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");En(s,a,c)};return s._id=t,bi.set(t,s),s}function En(t,s,a){s[Es]===s?s[Hi].push({id:t,index:a}):(s[Hi]=[{id:t,index:a}],s[Es]=s)}var Se=pe("BufferService"),Lr=pe("CoreMouseService"),dt=pe("CoreService"),Dn=pe("CharsetService"),us=pe("InstantiationService"),Mr=pe("LogService"),be=pe("OptionsService"),Tr=pe("OscLinkService"),Bn=pe("UnicodeService"),Ft=pe("DecorationService"),Wi=class{constructor(t,s,a){this._bufferService=t,this._optionsService=s,this._oscLinkService=a}provideLinks(t,s){let a=this._bufferService.buffer.lines.get(t-1);if(!a){s(void 0);return}let l=[],c=this._optionsService.rawOptions.linkHandler,d=new Me,u=a.getTrimmedLength(),f=-1,p=-1,_=!1;for(let m=0;m<u;m++)if(!(p===-1&&!a.hasContent(m))){if(a.loadCell(m,d),d.hasExtendedAttrs()&&d.extended.urlId)if(p===-1){p=m,f=d.extended.urlId;continue}else _=d.extended.urlId!==f;else p!==-1&&(_=!0);if(_||p!==-1&&m===u-1){let g=this._oscLinkService.getLinkData(f)?.uri;if(g){let S={start:{x:p+1,y:t},end:{x:m+(!_&&m===u-1?1:0),y:t}},b=!1;if(!c?.allowNonHttpProtocols)try{let v=new URL(g);["http:","https:"].includes(v.protocol)||(b=!0)}catch{b=!0}b||l.push({text:g,range:S,activate:(v,w)=>c?c.activate(v,w,S):Rn(v,w),hover:(v,w)=>c?.hover?.(v,w,S),leave:(v,w)=>c?.leave?.(v,w,S)})}_=!1,d.hasExtendedAttrs()&&d.extended.urlId?(p=m,f=d.extended.urlId):(p=-1,f=-1)}}s(l)}};Wi=te([M(0,Se),M(1,be),M(2,Tr)],Wi);function Rn(t,s){if(confirm(`Do you want to navigate to ${s}?
1
+ import{h,o,i,r,e,n,y,xt,oe,Z}from"./chunk-jy448465.js";var pn=2,gn=1,ys=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let s=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(s._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,a=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(a.getPropertyValue("height")),c=Math.max(0,parseInt(a.getPropertyValue("width"))),d=window.getComputedStyle(this._terminal.element),u={top:parseInt(d.getPropertyValue("padding-top")),bottom:parseInt(d.getPropertyValue("padding-bottom")),right:parseInt(d.getPropertyValue("padding-right")),left:parseInt(d.getPropertyValue("padding-left"))},f=u.top+u.bottom,p=u.right+u.left,_=l-f,m=c-p-s;return{cols:Math.max(pn,Math.floor(m/t.css.cell.width)),rows:Math.max(gn,Math.floor(_/t.css.cell.height))}}};var{defineProperty:Er,getOwnPropertyDescriptor:mn}=Object,vn=(t,s)=>{for(var a in s)Er(t,a,{get:s[a],enumerable:!0})},te=(t,s,a,l)=>{for(var c=l>1?void 0:l?mn(s,a):s,d=t.length-1,u;d>=0;d--)(u=t[d])&&(c=(l?u(s,a,c):u(c))||c);return l&&c&&Er(s,a,c),c},M=(t,s)=>(a,l)=>s(a,l,t),Cs="Terminal input",Ii={get:()=>Cs,set:(t)=>Cs=t},xs="Too much output to announce, navigate to rows manually to read",Ni={get:()=>xs,set:(t)=>xs=t};function Sn(t){return t.replace(/\r?\n/g,"\r")}function bn(t,s){return s?"\x1B[200~"+t+"\x1B[201~":t}function wn(t,s){t.clipboardData&&t.clipboardData.setData("text/plain",s.selectionText),t.preventDefault()}function yn(t,s,a,l){if(t.stopPropagation(),t.clipboardData){let c=t.clipboardData.getData("text/plain");Dr(c,s,a,l)}}function Dr(t,s,a,l){t=Sn(t),t=bn(t,a.decPrivateModes.bracketedPasteMode&&l.rawOptions.ignoreBracketedPasteMode!==!0),a.triggerDataEvent(t,!0),s.value=""}function Br(t,s,a){let l=a.getBoundingClientRect(),c=t.clientX-l.left-10,d=t.clientY-l.top-10;s.style.width="20px",s.style.height="20px",s.style.left=`${c}px`,s.style.top=`${d}px`,s.style.zIndex="1000",s.focus()}function ks(t,s,a,l,c){Br(t,s,a),c&&l.rightClickSelect(t),s.value=l.selectionText,s.select()}function Ze(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function _i(t,s=0,a=t.length){let l="";for(let c=s;c<a;++c){let d=t[c];d>65535?(d-=65536,l+=String.fromCharCode((d>>10)+55296)+String.fromCharCode(d%1024+56320)):l+=String.fromCharCode(d)}return l}var Cn=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,s){let a=t.length;if(!a)return 0;let l=0,c=0;if(this._interim){let d=t.charCodeAt(c++);56320<=d&&d<=57343?s[l++]=(this._interim-55296)*1024+d-56320+65536:(s[l++]=this._interim,s[l++]=d),this._interim=0}for(let d=c;d<a;++d){let u=t.charCodeAt(d);if(55296<=u&&u<=56319){if(++d>=a)return this._interim=u,l;let f=t.charCodeAt(d);56320<=f&&f<=57343?s[l++]=(u-55296)*1024+f-56320+65536:(s[l++]=u,s[l++]=f);continue}u!==65279&&(s[l++]=u)}return l}},xn=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,s){let a=t.length;if(!a)return 0;let l=0,c,d,u,f,p=0,_=0;if(this.interim[0]){let S=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let v=0,w;for(;(w=this.interim[++v]&63)&&v<4;)b<<=6,b|=w;let R=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,P=R-v;for(;_<P;){if(_>=a)return 0;if(w=t[_++],(w&192)!==128){_--,S=!0;break}else this.interim[v++]=w,b<<=6,b|=w&63}S||(R===2?b<128?_--:s[l++]=b:R===3?b<2048||b>=55296&&b<=57343||b===65279||(s[l++]=b):b<65536||b>1114111||(s[l++]=b)),this.interim.fill(0)}let m=a-4,g=_;for(;g<a;){for(;g<m&&!((c=t[g])&128)&&!((d=t[g+1])&128)&&!((u=t[g+2])&128)&&!((f=t[g+3])&128);)s[l++]=c,s[l++]=d,s[l++]=u,s[l++]=f,g+=4;if(c=t[g++],c<128)s[l++]=c;else if((c&224)===192){if(g>=a)return this.interim[0]=c,l;if(d=t[g++],(d&192)!==128){g--;continue}if(p=(c&31)<<6|d&63,p<128){g--;continue}s[l++]=p}else if((c&240)===224){if(g>=a)return this.interim[0]=c,l;if(d=t[g++],(d&192)!==128){g--;continue}if(g>=a)return this.interim[0]=c,this.interim[1]=d,l;if(u=t[g++],(u&192)!==128){g--;continue}if(p=(c&15)<<12|(d&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;s[l++]=p}else if((c&248)===240){if(g>=a)return this.interim[0]=c,l;if(d=t[g++],(d&192)!==128){g--;continue}if(g>=a)return this.interim[0]=c,this.interim[1]=d,l;if(u=t[g++],(u&192)!==128){g--;continue}if(g>=a)return this.interim[0]=c,this.interim[1]=d,this.interim[2]=u,l;if(f=t[g++],(f&192)!==128){g--;continue}if(p=(c&7)<<18|(d&63)<<12|(u&63)<<6|f&63,p<65536||p>1114111)continue;s[l++]=p}}return l}},Rr="",Qe=" ",zt=class t{constructor(){this.fg=0,this.bg=0,this.extended=new ri}static toColorRGB(s){return[s>>>16&255,s>>>8&255,s&255]}static fromColorRGB(s){return(s[0]&255)<<16|(s[1]&255)<<8|s[2]&255}clone(){let s=new t;return s.fg=this.fg,s.bg=this.bg,s.extended=this.extended.clone(),s}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ri=class t{constructor(s=0,a=0){this._ext=0,this._urlId=0,this._ext=s,this._urlId=a}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(s){this._ext=s}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(s){this._ext&=-469762049,this._ext|=s<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(s){this._ext&=-67108864,this._ext|=s&67108863}get urlId(){return this._urlId}set urlId(s){this._urlId=s}get underlineVariantOffset(){let s=(this._ext&3758096384)>>29;return s<0?s^4294967288:s}set underlineVariantOffset(s){this._ext&=536870911,this._ext|=s<<29&3758096384}clone(){return new t(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Me=class t extends zt{constructor(){super(...arguments);this.content=0,this.fg=0,this.bg=0,this.extended=new ri,this.combinedData=""}static fromCharData(s){let a=new t;return a.setFromCharData(s),a}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ze(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(s){this.fg=s[0],this.bg=0;let a=!1;if(s[1].length>2)a=!0;else if(s[1].length===2){let l=s[1].charCodeAt(0);if(55296<=l&&l<=56319){let c=s[1].charCodeAt(1);56320<=c&&c<=57343?this.content=(l-55296)*1024+c-56320+65536|s[2]<<22:a=!0}else a=!0}else this.content=s[1].charCodeAt(0)|s[2]<<22;a&&(this.combinedData=s[1],this.content=2097152|s[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Es="di$target",Hi="di$dependencies",bi=new Map;function kn(t){return t[Hi]||[]}function pe(t){if(bi.has(t))return bi.get(t);let s=function(a,l,c){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");En(s,a,c)};return s._id=t,bi.set(t,s),s}function En(t,s,a){s[Es]===s?s[Hi].push({id:t,index:a}):(s[Hi]=[{id:t,index:a}],s[Es]=s)}var Se=pe("BufferService"),Lr=pe("CoreMouseService"),dt=pe("CoreService"),Dn=pe("CharsetService"),us=pe("InstantiationService"),Mr=pe("LogService"),be=pe("OptionsService"),Tr=pe("OscLinkService"),Bn=pe("UnicodeService"),Ft=pe("DecorationService"),Wi=class{constructor(t,s,a){this._bufferService=t,this._optionsService=s,this._oscLinkService=a}provideLinks(t,s){let a=this._bufferService.buffer.lines.get(t-1);if(!a){s(void 0);return}let l=[],c=this._optionsService.rawOptions.linkHandler,d=new Me,u=a.getTrimmedLength(),f=-1,p=-1,_=!1;for(let m=0;m<u;m++)if(!(p===-1&&!a.hasContent(m))){if(a.loadCell(m,d),d.hasExtendedAttrs()&&d.extended.urlId)if(p===-1){p=m,f=d.extended.urlId;continue}else _=d.extended.urlId!==f;else p!==-1&&(_=!0);if(_||p!==-1&&m===u-1){let g=this._oscLinkService.getLinkData(f)?.uri;if(g){let S={start:{x:p+1,y:t},end:{x:m+(!_&&m===u-1?1:0),y:t}},b=!1;if(!c?.allowNonHttpProtocols)try{let v=new URL(g);["http:","https:"].includes(v.protocol)||(b=!0)}catch{b=!0}b||l.push({text:g,range:S,activate:(v,w)=>c?c.activate(v,w,S):Rn(v,w),hover:(v,w)=>c?.hover?.(v,w,S),leave:(v,w)=>c?.leave?.(v,w,S)})}_=!1,d.hasExtendedAttrs()&&d.extended.urlId?(p=m,f=d.extended.urlId):(p=-1,f=-1)}}s(l)}};Wi=te([M(0,Se),M(1,be),M(2,Tr)],Wi);function Rn(t,s){if(confirm(`Do you want to navigate to ${s}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let a=window.open();if(a){try{a.opener=null}catch{}a.location.href=s}else console.warn("Opening link blocked as opener could not be cleared")}}var fi=pe("CharSizeService"),Ue=pe("CoreBrowserService"),_s=pe("MouseService"),Ke=pe("RenderService"),Ln=pe("SelectionService"),Pr=pe("CharacterJoinerService"),pt=pe("ThemeService"),Ar=pe("LinkProviderService"),Mn=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Ds.isErrorNoTelemetry(t)?new Ds(t.message+`
4
4
 
@@ -0,0 +1 @@
1
+ import{Oi}from"./chunk-dgepxev9.js";export{Oi as createEventModelingServices};
@@ -1,3 +1,3 @@
1
- import{H}from"./chunk-p79c7aak.js";import{t,a,N,x,O,C,S,E,T,A,L,R,l,Sr,p,Mn,ta,j}from"./chunk-zsat72qd.js";import{jr,J}from"./chunk-p4pqtybm.js";var _="position frame",G="frame positioned",F="position relation",V="relation positioned",pe=t(function(e){a.debug("options str",e)},"setOptions"),ve=t(function(){return{}},"getOptions"),be=t(function(){X(),C()},"clear");function X(){M={}}t(X,"reset");var we=N.eventmodeling,ye=t(()=>j({...we,...x().eventmodeling}),"getConfig"),M={};function Y(){let e=Pe,{ast:i}=M,n=I();if(!i)throw Error("No data for EventModel");return i.frames.forEach((r,o)=>{let s=te(r,i.dataEntities,n);e=P(e,{$kind:_,index:o,frame:r,textProps:s});let c=void 0;if(se(r))a.debug("source frame",r.sourceFrames),c=i.frames.filter((m)=>r.sourceFrames.some((u)=>u.$refText===m.name)),c.forEach((m)=>{e=P(e,{$kind:F,index:o,frame:r,sourceFrame:m})});else e=P(e,{$kind:F,index:o,frame:r})}),e={...e,sortedSwimlanesArray:W(e.swimlanes)},e}t(Y,"getState");function z(e){M.ast=void 0;let i=new Set;for(let n of e.frames){if(i.has(n.name)){let r=n.$cstNode?.range.start.line,o=r===void 0?"":` on line ${r+1}`;throw Error(`Duplicate event modeling frame ID "${n.name}"${o}`)}i.add(n.name)}M.ast=e}t(z,"setAst");var d={swimlaneMinHeight:70,swimlanePadding:15,swimlaneGap:10,boxPadding:10,boxOverlap:90,boxDefaultY:0,boxMinWidth:80,boxMaxWidth:450,boxMinHeight:80,boxMaxHeight:750,contentStartX:250,textMaxWidth:430,boxTextFontWeight:"bold",boxTextPadding:10,swimlaneTextFontWeight:"bold",labelUiAutomation:"UI/Automation",labelUiAutomationPrefix:"UI/A: ",labelCommandReadModel:"Command/Read Model",labelCommandReadModelPrefix:"C/RM: ",labelEvents:"Events",labelEventsPrefix:"Stream: "};function I(){return d}t(I,"getDiagramProps");var Pe={boxes:[],swimlanes:{},relations:[],maxR:0,sortedSwimlanesArray:[]};function K(e){let i=e.split(".");if(i.length===2)return i[0];return}t(K,"extractNamespace");function q(e){let i=e.split(".");if(i.length===2)return i[1];return e}t(q,"extractName");function Q(e,i){if(!i||i.length===0)return;return Object.values(e).find((n)=>n.namespace===i)}t(Q,"findSwimlaneByNamespace");function y(e,i,n){return Math.max(i,...Object.keys(e).filter((r)=>{let o=Number.parseInt(r);return o>i&&o<n}).map((r)=>Number.parseInt(r)))+1}t(y,"findNextAvailableIndex");function Z(e,i){let n=K(e.entityIdentifier),r=Q(i,n);switch(e.modelEntityType){case"ui":case"pcr":case"processor":if(r)return{index:r.index,label:r.namespace||d.labelUiAutomation};else if(n)return{index:y(i,0,100),label:d.labelUiAutomationPrefix+n};return{index:0,label:d.labelUiAutomation};case"rmo":case"readmodel":case"cmd":case"command":if(r)return{index:r.index,label:r.namespace||d.labelCommandReadModel};else if(n)return{index:y(i,100,200),label:d.labelCommandReadModelPrefix+n};return{index:100,label:d.labelCommandReadModel};case"evt":case"event":default:if(r)return{index:r.index,label:r.namespace||d.labelEvents};else if(n)return{index:y(i,200,300),label:d.labelEventsPrefix+n};return{index:200,label:d.labelEvents}}}t(Z,"calculateSwimlaneProps");function ee(e){let{themeVariables:i}=x();switch(e.modelEntityType){case"ui":return{fill:i.emUiFill??"white",stroke:i.emUiStroke??"#dbdada"};case"pcr":case"processor":return{fill:i.emProcessorFill??"#edb3f6",stroke:i.emProcessorStroke??"#b88cbf"};case"rmo":case"readmodel":return{fill:i.emReadModelFill??"#d3f1a2",stroke:i.emReadModelStroke??"#a3b732"};case"cmd":case"command":return{fill:i.emCommandFill??"#bcd6fe",stroke:i.emCommandStroke??"#679ac3"};case"evt":case"event":return{fill:i.emEventFill??"#ffb778",stroke:i.emEventStroke??"#c19a0f"};default:return{fill:"red",stroke:"black"}}}t(ee,"calculateEntityVisualProps");function te(e,i,n){let r=x(),o=O(q(e.entityIdentifier)??"",r),s,c={fontSize:16,fontWeight:700,fontFamily:'"trebuchet ms", verdana, arial, sans-serif',joinWith:"<br/>"},u=`<b>${Mn(o,n.textMaxWidth,c)}</b>`;if(e.dataInlineValue)s=e.dataInlineValue,s=s.substring(s.indexOf("{")+1),s=s.substring(0,s.lastIndexOf("}")-1),s=O(s,r),s=Mn(s,n.textMaxWidth,c),s=s.replaceAll(" ","&nbsp;");if(e.dataReference){let w=i.find((k)=>k.name===e.dataReference?.$refText);if(w)s=w.dataBlockValue,s=s.substring(s.indexOf(`{
1
+ import{H}from"./chunk-yeh77fvq.js";import{t,a,N,x,O,C,S,E,T,A,L,R,l,Sr,p,Mn,ta,j}from"./chunk-t5ke9cyg.js";import{jr,J}from"./chunk-dgepxev9.js";var _="position frame",G="frame positioned",F="position relation",V="relation positioned",pe=t(function(e){a.debug("options str",e)},"setOptions"),ve=t(function(){return{}},"getOptions"),be=t(function(){X(),C()},"clear");function X(){M={}}t(X,"reset");var we=N.eventmodeling,ye=t(()=>j({...we,...x().eventmodeling}),"getConfig"),M={};function Y(){let e=Pe,{ast:i}=M,n=I();if(!i)throw Error("No data for EventModel");return i.frames.forEach((r,o)=>{let s=te(r,i.dataEntities,n);e=P(e,{$kind:_,index:o,frame:r,textProps:s});let c=void 0;if(se(r))a.debug("source frame",r.sourceFrames),c=i.frames.filter((m)=>r.sourceFrames.some((u)=>u.$refText===m.name)),c.forEach((m)=>{e=P(e,{$kind:F,index:o,frame:r,sourceFrame:m})});else e=P(e,{$kind:F,index:o,frame:r})}),e={...e,sortedSwimlanesArray:W(e.swimlanes)},e}t(Y,"getState");function z(e){M.ast=void 0;let i=new Set;for(let n of e.frames){if(i.has(n.name)){let r=n.$cstNode?.range.start.line,o=r===void 0?"":` on line ${r+1}`;throw Error(`Duplicate event modeling frame ID "${n.name}"${o}`)}i.add(n.name)}M.ast=e}t(z,"setAst");var d={swimlaneMinHeight:70,swimlanePadding:15,swimlaneGap:10,boxPadding:10,boxOverlap:90,boxDefaultY:0,boxMinWidth:80,boxMaxWidth:450,boxMinHeight:80,boxMaxHeight:750,contentStartX:250,textMaxWidth:430,boxTextFontWeight:"bold",boxTextPadding:10,swimlaneTextFontWeight:"bold",labelUiAutomation:"UI/Automation",labelUiAutomationPrefix:"UI/A: ",labelCommandReadModel:"Command/Read Model",labelCommandReadModelPrefix:"C/RM: ",labelEvents:"Events",labelEventsPrefix:"Stream: "};function I(){return d}t(I,"getDiagramProps");var Pe={boxes:[],swimlanes:{},relations:[],maxR:0,sortedSwimlanesArray:[]};function K(e){let i=e.split(".");if(i.length===2)return i[0];return}t(K,"extractNamespace");function q(e){let i=e.split(".");if(i.length===2)return i[1];return e}t(q,"extractName");function Q(e,i){if(!i||i.length===0)return;return Object.values(e).find((n)=>n.namespace===i)}t(Q,"findSwimlaneByNamespace");function y(e,i,n){return Math.max(i,...Object.keys(e).filter((r)=>{let o=Number.parseInt(r);return o>i&&o<n}).map((r)=>Number.parseInt(r)))+1}t(y,"findNextAvailableIndex");function Z(e,i){let n=K(e.entityIdentifier),r=Q(i,n);switch(e.modelEntityType){case"ui":case"pcr":case"processor":if(r)return{index:r.index,label:r.namespace||d.labelUiAutomation};else if(n)return{index:y(i,0,100),label:d.labelUiAutomationPrefix+n};return{index:0,label:d.labelUiAutomation};case"rmo":case"readmodel":case"cmd":case"command":if(r)return{index:r.index,label:r.namespace||d.labelCommandReadModel};else if(n)return{index:y(i,100,200),label:d.labelCommandReadModelPrefix+n};return{index:100,label:d.labelCommandReadModel};case"evt":case"event":default:if(r)return{index:r.index,label:r.namespace||d.labelEvents};else if(n)return{index:y(i,200,300),label:d.labelEventsPrefix+n};return{index:200,label:d.labelEvents}}}t(Z,"calculateSwimlaneProps");function ee(e){let{themeVariables:i}=x();switch(e.modelEntityType){case"ui":return{fill:i.emUiFill??"white",stroke:i.emUiStroke??"#dbdada"};case"pcr":case"processor":return{fill:i.emProcessorFill??"#edb3f6",stroke:i.emProcessorStroke??"#b88cbf"};case"rmo":case"readmodel":return{fill:i.emReadModelFill??"#d3f1a2",stroke:i.emReadModelStroke??"#a3b732"};case"cmd":case"command":return{fill:i.emCommandFill??"#bcd6fe",stroke:i.emCommandStroke??"#679ac3"};case"evt":case"event":return{fill:i.emEventFill??"#ffb778",stroke:i.emEventStroke??"#c19a0f"};default:return{fill:"red",stroke:"black"}}}t(ee,"calculateEntityVisualProps");function te(e,i,n){let r=x(),o=O(q(e.entityIdentifier)??"",r),s,c={fontSize:16,fontWeight:700,fontFamily:'"trebuchet ms", verdana, arial, sans-serif',joinWith:"<br/>"},u=`<b>${Mn(o,n.textMaxWidth,c)}</b>`;if(e.dataInlineValue)s=e.dataInlineValue,s=s.substring(s.indexOf("{")+1),s=s.substring(0,s.lastIndexOf("}")-1),s=O(s,r),s=Mn(s,n.textMaxWidth,c),s=s.replaceAll(" ","&nbsp;");if(e.dataReference){let w=i.find((k)=>k.name===e.dataReference?.$refText);if(w)s=w.dataBlockValue,s=s.substring(s.indexOf(`{
2
2
  `)+2),s=s.substring(0,s.lastIndexOf("}")-1),s=O(s,r),s=Mn(s,n.textMaxWidth,c),s=s.replaceAll(" ","&nbsp;"),s+="<br/>"}let f=s!==void 0;if(f)u+=`<br/><br/><code style="text-align: left; display: block;max-width:${n.textMaxWidth}px">${s}</code>`;let h={fontSize:c.fontSize,fontWeight:c.fontWeight,fontFamily:c.fontFamily},g=ta(u,h),b=f?g.width/3:g.width,v={content:u,width:b,height:g.height};return a.debug(`[${e.name}] ${e.entityIdentifier} text`,v),v}t(te,"calculateTextProps");function ne(e,i){let n=i,r=ee(n.frame),o={width:n.textProps.width+2*d.boxTextPadding,height:n.textProps.height+2*d.boxTextPadding};return[{$kind:G,frame:n.frame,index:n.index,visual:r,dimension:o,textProps:n.textProps}]}t(ne,"decidePositionFrame");function ie(e,i,n){if(i===void 0)return d.contentStartX;if(i.index===e.index&&e.r)return e.r+d.boxPadding;if(n===void 0)return d.contentStartX;return n.r-d.boxOverlap+d.boxPadding}t(ie,"calculateX");function re(e,i){let n=[...e.map((r)=>r.r),i];return Math.max(...n)}t(re,"calculateMaxRight");function W(e){return Object.values(e).sort((i,n)=>i.index-n.index)}t(W,"sortedSwimlanesArray");function ae(e,i){let n=i,r=Z(n.frame,e.swimlanes),o;if(r.index in e.swimlanes)o=e.swimlanes[r.index];else o={index:r.index,label:r.label,r:0,y:r.index*d.swimlaneMinHeight+d.swimlaneGap,height:d.swimlaneMinHeight,maxHeight:d.swimlaneMinHeight};let s=e.boxes.length>0?e.boxes[e.boxes.length-1]:void 0,c=e.previousSwimlaneNumber!==void 0?e.swimlanes[e.previousSwimlaneNumber]:void 0,m={width:Math.max(d.boxMinWidth,Math.min(d.boxMaxWidth,n.dimension.width))+2*d.boxPadding,height:Math.max(d.boxMinHeight,Math.min(d.boxMaxHeight,n.dimension.height))+2*d.boxPadding},u=ie(o,c,s),f=u+m.width+d.boxPadding,h=re(Object.values(e.swimlanes),f);o.r=u+m.width,o.maxHeight=Math.max(o.maxHeight,m.height),o.height=Math.max(d.swimlaneMinHeight,o.maxHeight)+2*d.swimlanePadding;let g={x:u,y:d.swimlanePadding+o.y,r:f,dimension:m,leftSibling:!1,swimlane:o,visual:n.visual,text:n.textProps.content,frame:n.frame,index:n.index},b={...e,boxes:[...e.boxes,g],swimlanes:{...e.swimlanes,[`${o.index}`]:o},previousSwimlaneNumber:r.index,previousFrame:n.frame,maxR:h},v=W(b.swimlanes);if(v.length>0)v[0].y=0;for(let w=1;w<v.length;w++){let k=v[w],U=v[w-1];k.y=U.y+U.height+d.swimlaneGap}return b}t(ae,"evolveFramePositioned");function oe(e,i){if(e===0&&i.sourceFrames.length===0)return!0;return!1}t(oe,"isFirstFrame");function se(e){return e.sourceFrames!==void 0&&e.sourceFrames!==null&&e.sourceFrames.length>0}t(se,"hasSourceFrame");function B(e,i){if(i===void 0||i===null)return;return e.find((n)=>n.frame.name===i.name)}t(B,"findBoxByFrame");function de(e,i,n){if(n<0)return;for(let r=n;r>=0;r--){let o=e[r];if(o.swimlane.index!==i)return o}return}t(de,"findBoxByLineIndex");function le(e,i){let n=i;if(oe(n.index,n.frame))return[];let r=B(e.boxes,n.frame);if(r===void 0)throw Error(`Target box not found for frame ${n.frame.name}`);let o;if(n.sourceFrame)o=B(e.boxes,n.sourceFrame);else{if(jr(n.frame))return[];o=de(e.boxes,r.swimlane.index,n.index-1)}if(o===void 0)return[];return[{$kind:V,frame:n.frame,index:n.index,sourceBox:o,targetBox:r}]}t(le,"decidePositionRelation");function ce(e,i){let n=i,r={visual:{fill:"none",stroke:"#000"},source:{x:n.sourceBox.x,y:n.sourceBox.y},target:{x:n.targetBox.x,y:n.targetBox.y},sourceBox:n.sourceBox,targetBox:n.targetBox};return{...e,relations:[...e.relations,r]}}t(ce,"evolveRelationPositioned");var Se={[_]:ne,[F]:le},Me={[G]:ae,[V]:ce};function me(e,i){let n=Se[i.$kind];if(n===void 0||n===null)return[];let r=n(e,i);return a.debug("decided events",r),r}t(me,"decide");function ue(e,i){let n=i.reduce((r,o)=>{let s=Me[o.$kind];if(s===void 0||s===null)return r;return s(r,o)},e);return a.debug("evolve events",{state:e,newState:n,events:i}),n}t(ue,"evolve");function P(e,i){let n=me(e,i);return ue(e,n)}t(P,"dispatch");var D={getConfig:ye,preserveCommentsWhenParsing:!0,setOptions:pe,getOptions:ve,clear:be,setAccTitle:S,getAccTitle:E,getAccDescription:A,setAccDescription:T,setDiagramTitle:L,getDiagramTitle:R,setAst:z,getDiagramProps:I,getState:Y},ke={parse:t(async(e)=>{let i=await J("eventmodeling",e);a.debug(i),D.setAst(i),H(i,D)},"parse")},Fe=l(),Be=Fe?.eventmodeling;function xe(e,i){return(n)=>{let r=n.swimlane.y+i.swimlanePadding,o=e.append("g").attr("class","em-box");o.append("rect").attr("x",n.x).attr("y",r).attr("rx","3").attr("width",n.dimension.width).attr("height",n.dimension.height).attr("stroke",n.visual.stroke).attr("fill",n.visual.fill),o.append("foreignObject").attr("x",n.x+i.boxPadding).attr("y",r+10).attr("width",n.dimension.width-2*i.boxPadding).attr("height",n.dimension.height-2*i.boxPadding).append("xhtml:div").style("display","table").style("height","100%").style("width","100%").append("span").style("display","table-cell").style("text-align","center").style("vertical-align","middle").html(n.text)}}t(xe,"renderD3Box");function fe(e,i){return e>i}t(fe,"dirUpwards");function ge(e,i,n,r){return(o)=>{let s=o.sourceBox.swimlane.y+i.swimlanePadding,c=o.targetBox.swimlane.y+i.swimlanePadding,m=fe(s,c),u=o.sourceBox.x+o.sourceBox.dimension.width*2/3,f=o.targetBox.x+o.targetBox.dimension.width/3,h,g;if(a.debug(`rendering relation up=${m} for `,{sourceBox:o.sourceBox,targetBox:o.targetBox}),m)h=s,g=c+o.targetBox.dimension.height;else h=s+o.sourceBox.dimension.height,g=c;let b=r.emRelationStroke??o.visual.stroke;e.append("path").attr("class","em-relation").attr("fill",o.visual.fill).attr("stroke",b).attr("stroke-width","1").attr("marker-end",`url(#${n})`).attr("d",`M${u} ${h} L${f} ${g}`)}}t(ge,"renderD3Relation");function he(e,i,n,r){return(o)=>{let s=e.append("g").attr("class","em-swimlane"),c=r.emSwimlaneBackgroundOdd??"rgb(250,250,250)",m=r.emSwimlaneBackgroundStroke??"rgb(240,240,240)";s.append("rect").attr("x",0).attr("y",o.y).attr("rx","3").attr("width",i+n.swimlanePadding).attr("height",o.height).attr("fill",c).attr("stroke",m),s.append("text").attr("font-weight",n.swimlaneTextFontWeight).attr("x",30).attr("y",o.y+30).text(o.label)}}t(he,"renderD3Swimlane");var Ee=t(function(e,i,n,r){if(a.debug("in eventmodeling renderer",e+`
3
3
  `,"id:",i,n),!Be)throw Error("EventModeling config not found");let o=r.db,{themeVariables:s,eventmodeling:c}=l(),m=p(`[id="${i}"]`),u=o.getDiagramProps(),f=o.getState(),h=`em-arrowhead-${i}`,g=s.emArrowhead??"#000000";f.sortedSwimlanesArray.forEach(he(m,f.maxR,u,s)),f.boxes.forEach(xe(m,u)),f.relations.forEach(ge(m,u,h,s)),m.append("defs").append("marker").attr("id",h).attr("markerWidth","10").attr("markerHeight","7").attr("refX","10").attr("refY","3.5").attr("orient","auto").append("polygon").attr("points","0 0, 10 3.5, 0 7").attr("fill",g),Sr(void 0,m,c?.padding??30,c?.useMaxWidth)},"draw"),Ae={draw:Ee},$e=t((e)=>"","getStyles"),Re=$e,Ue={parser:ke,db:D,renderer:Ae,styles:Re};export{Ue as diagram};
@@ -1 +1 @@
1
- import{h,o,G,i,r,m,e,n,y,an,nr,ze,On,Ie,fn,oe,Q,sa,Ro,la}from"./chunk-ty2rmwda.js";function de(d){let{Button:b,confirm:L,PageLayout:x,Switch:_,cn:F,style:z}=y(),{connection:f,onOpen:O}=d,[D,p]=r([]),[w,H]=r([]),[q,J]=r([]),[I,T]=r(),[B,U]=r([]),[A,V]=r(!0),[k,N]=r(),[C,R]=r(),[W,P]=r(!1),[K,c]=r({}),s=i(0),E=h(async()=>{let t=++s.current;try{let[a,l,u,g]=await Promise.all([f.request("/api/automations"),f.request("/api/projects").catch(()=>[]),f.request("/api/info").catch(()=>{return}),f.request("/api/models").catch(()=>({models:[]}))]),te=[...new Set(a.flatMap((v)=>v.lastSessionID?[v.lastSessionID]:[]))],ne=(await Promise.all(te.map(async(v)=>f.request(`/api/sessions/${encodeURIComponent(v)}`).catch((j)=>{if(j instanceof Error&&"status"in j&&j.status===404)return;throw j})))).filter((v)=>v!==void 0);if(t!==s.current)return;if(p(a.sort((v,j)=>v.created-j.created)),H(l),J(ne),T(u),g?.models)U(g.models.map((v)=>v.id));N(void 0)}catch(a){if(t===s.current)N(a instanceof Error?a.message:"加载失败")}finally{if(t===s.current)V(!1)}},[f]);o(()=>(E(),()=>{s.current++}),[E]);let S=(t)=>{R(t),P(!0)},Y=async(t)=>{c((a)=>({...a,[t.id]:!0}));try{let a=await f.request(`/api/automations/${t.id}/run`,{method:"POST"});O(a.id)}catch(a){N(a instanceof Error?a.message:"运行失败")}finally{c((a)=>({...a,[t.id]:!1}))}},Z=async(t)=>{if(!await L({title:`删除自动化「${t.name}」?`,description:"已经跑出来的会话会保留。",action:"删除",danger:!0}))return;try{await f.request(`/api/automations/${t.id}`,{method:"DELETE"}),p((l)=>l.filter((u)=>u.id!==t.id))}catch(l){N(l instanceof Error?l.message:"删除失败")}},ee=async(t,a)=>{try{let l=await f.request(`/api/automations/${t.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})});p((u)=>u.map((g)=>g.id===t.id?l:g))}catch(l){N(l instanceof Error?l.message:"状态切换失败")}};return n(x,{title:"自动化",description:n(m,{children:["到点自动开一个新会话执行提示词,跑完的结果在会话里查看。",I?.timezone&&n("span",{className:"text-faint",children:["按服务器时区 ",I.timezone,"。"]})]}),actions:n(b,{variant:"primary",onClick:()=>S(null),children:[e(oe,{className:"size-4"}),"新建"]}),children:[k&&e("div",{className:"mb-4 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:k}),A?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载自动化…"}):D.length===0?n("div",{className:z("surface.emptyDashed","animate-fade"),children:[e("div",{className:"grid size-11 place-items-center rounded-xl bg-raised text-dim",children:e(an,{className:"size-5"})}),n("div",{children:[e("p",{className:"text-[15px] font-medium",children:"还没有自动化"}),e("p",{className:"mt-1 text-sm text-dim",children:"比如「每个工作日 9 点总结昨天的提交」。"})]}),n(b,{size:"sm",onClick:()=>S(null),className:"mt-1",children:[e(oe,{className:"size-3.5"}),"新建自动化"]})]}):e("ul",{className:"flex animate-fade flex-col gap-3",children:D.map((t)=>{let a=t.projectID?w.find((g)=>g.id===t.projectID):void 0,l=t.lastSessionID?q.find((g)=>g.id===t.lastSessionID):void 0,u=Boolean(K[t.id]);return e("li",{children:n("article",{className:z("surface.card","group p-4 transition-[border-color,box-shadow] duration-200 hover:border-line-strong hover:shadow-composer"),children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:F("min-w-0 flex-1 transition-opacity duration-200",!t.enabled&&"opacity-55"),children:[e("h2",{className:"truncate text-[15px] font-medium",children:t.name}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-[13px] text-dim",children:[n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(an,{}),Ro(t.schedule)]}),n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[a?e(ze,{}):e(On,{}),a?a.name:"聊天"]}),t.enabled&&t.nextRun!==null&&n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(nr,{}),"下次 ",la(t.nextRun)]})]})]}),e(_,{checked:t.enabled,label:t.enabled?"停用":"启用",onCheckedChange:(g)=>ee(t,g),className:"mt-0.5"})]}),e("p",{className:F("mt-3 line-clamp-2 text-sm leading-6 whitespace-pre-wrap text-faint transition-opacity duration-200",!t.enabled&&"opacity-55"),children:t.prompt}),n("div",{className:"mt-3 -mb-1 flex items-center gap-1",children:[n(b,{size:"sm",onClick:()=>Y(t),disabled:u,children:[e(fn,{className:"size-3.5"}),u?"正在启动…":"立即运行"]}),n(b,{size:"sm",variant:"ghost",onClick:()=>S(t),children:[e(Ie,{className:"size-3.5"}),"编辑"]}),n(b,{size:"sm",variant:"danger-ghost",onClick:()=>Z(t),children:[e(Q,{className:"size-3.5"}),"删除"]}),e("div",{className:"flex-1"}),t.lastRun!==null&&n("button",{type:"button",disabled:!l,onClick:()=>l&&O(l.id),className:"rounded-md px-1.5 py-1 text-[13px] text-faint transition-colors enabled:hover:bg-raised enabled:hover:text-ink",children:["上次运行 ",la(t.lastRun),l?.archivedAt!=null?" · 已归档":"",!l?" · 会话已删除":""]})]})]})},t.id)})}),C!==void 0&&e(se,{open:W,onOpenChange:P,automation:C??void 0,projects:w,models:B,timezone:I?.timezone,onSaved:(t)=>{p((a)=>{let l=a.findIndex((u)=>u.id===t.id);if(l>=0){let u=[...a];return u[l]=t,u}return[...a,t].sort((u,g)=>u.created-g.created)}),P(!1)},connection:f},C?.id??"new")]})}var M="custom",X="chat";function se(d){let{Button:b,Dialog:L,Field:x,Form:_,FormError:F,Input:z,Select:f,Textarea:O}=y(),D=G(),p=d.automation,[w,H]=r(p?.name??""),[q,J]=r(p?.prompt??""),[I,T]=r(p?.schedule??sa[0]?.cron??"0 9 * * *"),[B,U]=r(()=>!sa.some((c)=>c.cron===I)),[A,V]=r(p?.projectID??X),[k,N]=r(p?.model??""),[C,R]=r(!1),[W,P]=r();async function K(c){c.preventDefault(),R(!0),P(void 0);try{let s=A===X?void 0:A,E={name:w,prompt:q,schedule:I,model:k||void 0},S;if(p)S=await d.connection.request(`/api/automations/${p.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s??null})});else S=await d.connection.request("/api/automations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s})});d.onSaved(S)}catch(s){P(s instanceof Error?s.message:"保存失败")}finally{R(!1)}}return e(L,{open:d.open,onOpenChange:d.onOpenChange,title:d.automation?"编辑自动化":"新建自动化",size:"lg",footer:n(m,{children:[e("div",{className:"flex-1 max-sm:hidden"}),e(b,{onClick:()=>d.onOpenChange(!1),children:"取消"}),e(b,{type:"submit",form:D,variant:"primary",disabled:C,children:C?"正在保存…":d.automation?"保存":"创建"})]}),children:n(_,{id:D,onSubmit:K,children:[e(x,{label:"名称",children:(c)=>e(z,{id:c,autoFocus:!p,required:!0,value:w,onChange:(s)=>H(s.target.value),placeholder:"例如:每日提交总结"})}),e(x,{label:"提示词",hint:"没人盯着运行,写清楚要做什么、结果怎么汇报。",children:(c)=>e(O,{id:c,required:!0,value:q,onChange:(s)=>J(s.target.value),rows:5,placeholder:"总结昨天到现在的 git 提交,按模块分组,列出需要我关注的改动。"})}),n("div",{className:"grid gap-x-3 gap-y-4 sm:grid-cols-2",children:[e(x,{label:"时间",children:(c)=>e(f,{id:c,value:B?M:I,onValueChange:(s)=>{if(U(s===M),s!==M)T(s)},groups:[{options:sa.map((s)=>({value:s.cron,label:s.label}))},{options:[{value:M,label:"自定义(cron)"}]}]})}),e(x,{label:"在哪里运行",children:(c)=>e(f,{id:c,value:A,onValueChange:V,groups:[{options:[{value:X,label:"聊天",description:"不绑定目录",icon:e(On,{})}]},...d.projects.length?[{label:"项目",options:d.projects.map((s)=>({value:s.id,label:s.name,icon:e(ze,{})}))}]:[]]})})]}),B&&e(x,{label:"cron 表达式",hint:`分 时 日 月 周,例如 30 8 * * 1-5 是工作日 8:30。${d.timezone?`按 ${d.timezone} 时间。`:""}`,children:(c)=>e(z,{id:c,required:!0,value:I,onChange:(s)=>T(s.target.value),spellCheck:!1,className:"font-mono"})}),d.models.length>0&&e(x,{label:"模型",children:(c)=>e(f,{id:c,value:k||"default",onValueChange:(s)=>N(s==="default"?"":s),groups:[{options:[{value:"default",label:"默认模型"},...d.models.map((s)=>({value:s,label:s}))]}]})}),e(F,{children:W})]})})}export{de as AutomationsPage};
1
+ import{h,o,G,i,r,m,e,n,y,an,nr,ze,On,Ie,fn,oe,Q,sa,Ro,la}from"./chunk-jy448465.js";function de(d){let{Button:b,confirm:L,PageLayout:x,Switch:_,cn:F,style:z}=y(),{connection:f,onOpen:O}=d,[D,p]=r([]),[w,H]=r([]),[q,J]=r([]),[I,T]=r(),[B,U]=r([]),[A,V]=r(!0),[k,N]=r(),[C,R]=r(),[W,P]=r(!1),[K,c]=r({}),s=i(0),E=h(async()=>{let t=++s.current;try{let[a,l,u,g]=await Promise.all([f.request("/api/automations"),f.request("/api/projects").catch(()=>[]),f.request("/api/info").catch(()=>{return}),f.request("/api/models").catch(()=>({models:[]}))]),te=[...new Set(a.flatMap((v)=>v.lastSessionID?[v.lastSessionID]:[]))],ne=(await Promise.all(te.map(async(v)=>f.request(`/api/sessions/${encodeURIComponent(v)}`).catch((j)=>{if(j instanceof Error&&"status"in j&&j.status===404)return;throw j})))).filter((v)=>v!==void 0);if(t!==s.current)return;if(p(a.sort((v,j)=>v.created-j.created)),H(l),J(ne),T(u),g?.models)U(g.models.map((v)=>v.id));N(void 0)}catch(a){if(t===s.current)N(a instanceof Error?a.message:"加载失败")}finally{if(t===s.current)V(!1)}},[f]);o(()=>(E(),()=>{s.current++}),[E]);let S=(t)=>{R(t),P(!0)},Y=async(t)=>{c((a)=>({...a,[t.id]:!0}));try{let a=await f.request(`/api/automations/${t.id}/run`,{method:"POST"});O(a.id)}catch(a){N(a instanceof Error?a.message:"运行失败")}finally{c((a)=>({...a,[t.id]:!1}))}},Z=async(t)=>{if(!await L({title:`删除自动化「${t.name}」?`,description:"已经跑出来的会话会保留。",action:"删除",danger:!0}))return;try{await f.request(`/api/automations/${t.id}`,{method:"DELETE"}),p((l)=>l.filter((u)=>u.id!==t.id))}catch(l){N(l instanceof Error?l.message:"删除失败")}},ee=async(t,a)=>{try{let l=await f.request(`/api/automations/${t.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})});p((u)=>u.map((g)=>g.id===t.id?l:g))}catch(l){N(l instanceof Error?l.message:"状态切换失败")}};return n(x,{title:"自动化",description:n(m,{children:["到点自动开一个新会话执行提示词,跑完的结果在会话里查看。",I?.timezone&&n("span",{className:"text-faint",children:["按服务器时区 ",I.timezone,"。"]})]}),actions:n(b,{variant:"primary",onClick:()=>S(null),children:[e(oe,{className:"size-4"}),"新建"]}),children:[k&&e("div",{className:"mb-4 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:k}),A?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载自动化…"}):D.length===0?n("div",{className:z("surface.emptyDashed","animate-fade"),children:[e("div",{className:"grid size-11 place-items-center rounded-xl bg-raised text-dim",children:e(an,{className:"size-5"})}),n("div",{children:[e("p",{className:"text-[15px] font-medium",children:"还没有自动化"}),e("p",{className:"mt-1 text-sm text-dim",children:"比如「每个工作日 9 点总结昨天的提交」。"})]}),n(b,{size:"sm",onClick:()=>S(null),className:"mt-1",children:[e(oe,{className:"size-3.5"}),"新建自动化"]})]}):e("ul",{className:"flex animate-fade flex-col gap-3",children:D.map((t)=>{let a=t.projectID?w.find((g)=>g.id===t.projectID):void 0,l=t.lastSessionID?q.find((g)=>g.id===t.lastSessionID):void 0,u=Boolean(K[t.id]);return e("li",{children:n("article",{className:z("surface.card","group p-4 transition-[border-color,box-shadow] duration-200 hover:border-line-strong hover:shadow-composer"),children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:F("min-w-0 flex-1 transition-opacity duration-200",!t.enabled&&"opacity-55"),children:[e("h2",{className:"truncate text-[15px] font-medium",children:t.name}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-[13px] text-dim",children:[n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(an,{}),Ro(t.schedule)]}),n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[a?e(ze,{}):e(On,{}),a?a.name:"聊天"]}),t.enabled&&t.nextRun!==null&&n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(nr,{}),"下次 ",la(t.nextRun)]})]})]}),e(_,{checked:t.enabled,label:t.enabled?"停用":"启用",onCheckedChange:(g)=>ee(t,g),className:"mt-0.5"})]}),e("p",{className:F("mt-3 line-clamp-2 text-sm leading-6 whitespace-pre-wrap text-faint transition-opacity duration-200",!t.enabled&&"opacity-55"),children:t.prompt}),n("div",{className:"mt-3 -mb-1 flex items-center gap-1",children:[n(b,{size:"sm",onClick:()=>Y(t),disabled:u,children:[e(fn,{className:"size-3.5"}),u?"正在启动…":"立即运行"]}),n(b,{size:"sm",variant:"ghost",onClick:()=>S(t),children:[e(Ie,{className:"size-3.5"}),"编辑"]}),n(b,{size:"sm",variant:"danger-ghost",onClick:()=>Z(t),children:[e(Q,{className:"size-3.5"}),"删除"]}),e("div",{className:"flex-1"}),t.lastRun!==null&&n("button",{type:"button",disabled:!l,onClick:()=>l&&O(l.id),className:"rounded-md px-1.5 py-1 text-[13px] text-faint transition-colors enabled:hover:bg-raised enabled:hover:text-ink",children:["上次运行 ",la(t.lastRun),l?.archivedAt!=null?" · 已归档":"",!l?" · 会话已删除":""]})]})]})},t.id)})}),C!==void 0&&e(se,{open:W,onOpenChange:P,automation:C??void 0,projects:w,models:B,timezone:I?.timezone,onSaved:(t)=>{p((a)=>{let l=a.findIndex((u)=>u.id===t.id);if(l>=0){let u=[...a];return u[l]=t,u}return[...a,t].sort((u,g)=>u.created-g.created)}),P(!1)},connection:f},C?.id??"new")]})}var M="custom",X="chat";function se(d){let{Button:b,Dialog:L,Field:x,Form:_,FormError:F,Input:z,Select:f,Textarea:O}=y(),D=G(),p=d.automation,[w,H]=r(p?.name??""),[q,J]=r(p?.prompt??""),[I,T]=r(p?.schedule??sa[0]?.cron??"0 9 * * *"),[B,U]=r(()=>!sa.some((c)=>c.cron===I)),[A,V]=r(p?.projectID??X),[k,N]=r(p?.model??""),[C,R]=r(!1),[W,P]=r();async function K(c){c.preventDefault(),R(!0),P(void 0);try{let s=A===X?void 0:A,E={name:w,prompt:q,schedule:I,model:k||void 0},S;if(p)S=await d.connection.request(`/api/automations/${p.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s??null})});else S=await d.connection.request("/api/automations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s})});d.onSaved(S)}catch(s){P(s instanceof Error?s.message:"保存失败")}finally{R(!1)}}return e(L,{open:d.open,onOpenChange:d.onOpenChange,title:d.automation?"编辑自动化":"新建自动化",size:"lg",footer:n(m,{children:[e("div",{className:"flex-1 max-sm:hidden"}),e(b,{onClick:()=>d.onOpenChange(!1),children:"取消"}),e(b,{type:"submit",form:D,variant:"primary",disabled:C,children:C?"正在保存…":d.automation?"保存":"创建"})]}),children:n(_,{id:D,onSubmit:K,children:[e(x,{label:"名称",children:(c)=>e(z,{id:c,autoFocus:!p,required:!0,value:w,onChange:(s)=>H(s.target.value),placeholder:"例如:每日提交总结"})}),e(x,{label:"提示词",hint:"没人盯着运行,写清楚要做什么、结果怎么汇报。",children:(c)=>e(O,{id:c,required:!0,value:q,onChange:(s)=>J(s.target.value),rows:5,placeholder:"总结昨天到现在的 git 提交,按模块分组,列出需要我关注的改动。"})}),n("div",{className:"grid gap-x-3 gap-y-4 sm:grid-cols-2",children:[e(x,{label:"时间",children:(c)=>e(f,{id:c,value:B?M:I,onValueChange:(s)=>{if(U(s===M),s!==M)T(s)},groups:[{options:sa.map((s)=>({value:s.cron,label:s.label}))},{options:[{value:M,label:"自定义(cron)"}]}]})}),e(x,{label:"在哪里运行",children:(c)=>e(f,{id:c,value:A,onValueChange:V,groups:[{options:[{value:X,label:"聊天",description:"不绑定目录",icon:e(On,{})}]},...d.projects.length?[{label:"项目",options:d.projects.map((s)=>({value:s.id,label:s.name,icon:e(ze,{})}))}]:[]]})})]}),B&&e(x,{label:"cron 表达式",hint:`分 时 日 月 周,例如 30 8 * * 1-5 是工作日 8:30。${d.timezone?`按 ${d.timezone} 时间。`:""}`,children:(c)=>e(z,{id:c,required:!0,value:I,onChange:(s)=>T(s.target.value),spellCheck:!1,className:"font-mono"})}),d.models.length>0&&e(x,{label:"模型",children:(c)=>e(f,{id:c,value:k||"default",onValueChange:(s)=>N(s==="default"?"":s),groups:[{options:[{value:"default",label:"默认模型"},...d.models.map((s)=>({value:s,label:s}))]}]})}),e(F,{children:W})]})})}export{de as AutomationsPage};
@@ -1 +1 @@
1
- import{h,o,i,r,m,e,n,y,s,te,lt,Te,oe,ne,je,Ke,Q,Z}from"./chunk-ty2rmwda.js";import{Fr,zr,Ur}from"./chunk-kk5rw81s.js";var ke=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],ye=s("rotate-cw",ke);function Ce(t){let p=[],g="",S,v=!1;for(let f=0;f<t.length;f++){let c=t.charAt(f);if(S)if(c===S)S=void 0;else if(c==="\\"&&S==='"'&&f+1<t.length)g+=t[++f];else g+=c;else if(c==='"'||c==="'")S=c,v=!0;else if(c==="\\"&&f+1<t.length)g+=t[++f],v=!0;else if(/\s/.test(c)){if(v||g)p.push(g);g="",v=!1}else g+=c,v=!0}if(v||g)p.push(g);return p}function fe(t){return t.map((p)=>p===""||/[\s"'\\]/.test(p)?`"${p.replace(/(["\\])/g,"\\$1")}"`:p).join(" ")}var $e={connected:{label:"已连接",dot:"bg-success"},idle:{label:"待连接",dot:"bg-faint"},disabled:{label:"已停用",dot:"bg-faint"},failed:{label:"连接失败",dot:"bg-danger"},needs_auth:{label:"需要认证",dot:"bg-warning"}};function ge(t){if(t==="project")return"项目";if(t==="file")return".mcp.json";return"全局"}function pe(t){return t.type==="local"?fe(t.command):t.url}function he({info:t,tools:p=!1}){let g=$e[t.status.status];return n("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-dim",children:[e("span",{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${g.dot}`}),e("span",{className:p?void 0:"hidden @md/panel:inline",children:g.label}),p&&t.status.status==="connected"&&n("span",{className:"text-faint",children:[t.toolCount," 个工具"]})]})}function xe(t){let{Button:p,CopyButton:g,DetailChip:S,DetailList:v,DetailRow:f,DetailTitle:c,Dialog:D,Switch:M,Tooltip:V,cn:d,confirm:Y,useTheme:I}=y();I();let{info:u,connection:E}=t,k=t.projectID?`?projectID=${encodeURIComponent(t.projectID)}`:"",[B,ee]=r(),[le,F]=r(),[T,P]=r(!1),J=u.status.status==="connected",j=u.status.status==="needs_auth",U=u.status.status==="failed",L=u.config.type==="remote"&&Boolean(u.config.oauth),R=u.scope==="file";o(()=>{function l(N){if(N&&N!==u.name)return;E.request(`/api/mcp/${encodeURIComponent(u.name)}/connect${k}`,{method:"POST"}).then((re)=>t.onChanged(re)).catch(()=>{})}function ie(N){if(N.data?.type==="mcp-oauth-success")l(N.data.name)}function de(N){if(N.key==="basalt-mcp-oauth-event"&&N.newValue)try{let re=JSON.parse(N.newValue);l(re.name)}catch(re){}}window.addEventListener("message",ie),window.addEventListener("storage",de);let q;if("BroadcastChannel"in window)q=new BroadcastChannel("basalt-mcp-oauth"),q.onmessage=(N)=>{if(N.data?.type==="mcp-oauth-success")l(N.data.name)};return()=>{window.removeEventListener("message",ie),window.removeEventListener("storage",de),q?.close()}},[E,u.name,k,t]),o(()=>{if(u.status.status!=="connected")return;E.request(`/api/mcp/${encodeURIComponent(u.name)}/tools${k}`).then((l)=>{if(Array.isArray(l))ee(l),F(void 0)}).catch((l)=>{F(l instanceof Error?l.message:"获取工具失败")})},[E,u.name,k,u.status.status]);async function ae(l){P(!0);try{let ie=await E.request(`/api/mcp/${encodeURIComponent(u.name)}/${l}${k}`,{method:"POST"});t.onChanged(ie)}catch{}finally{P(!1)}}async function se(){P(!0);try{let l=u.status.status==="needs_auth"?u.status.authorizationUrl:void 0;if(!l)l=(await E.request(`/api/mcp/${encodeURIComponent(u.name)}/oauth/authorize${k}`,{method:"POST"})).authorizationUrl;if(l)window.open(l,"_blank","width=600,height=700")}catch(l){F(l instanceof Error?l.message:"获取授权链接失败")}finally{P(!1)}}async function _(){P(!0);try{let l=await E.request(`/api/mcp/${encodeURIComponent(u.name)}/oauth/clear${k}`,{method:"POST"});t.onChanged(l)}finally{P(!1)}}async function a(){if(!await Y({title:`删除 ${u.name}?`,description:"删除后将断开连接并不再向会话提供其工具。",action:"删除",danger:!0}))return;P(!0);try{await E.request(`/api/mcp/${encodeURIComponent(u.name)}${k}`,{method:"DELETE"}),t.onChanged(),t.onClose()}finally{P(!1)}}let C=u.config,x=pe(C),W="error"in u.status?u.status.error:void 0,z=C.enabled===!1,ce=!z&&!j;return e(D,{open:!0,onOpenChange:(l)=>{if(!l&&!T)t.onClose()},title:e(c,{icon:C.type==="local"?e(Ke,{}):e(Te,{}),name:u.name,meta:[C.type==="local"?"本地命令":"远程服务",ge(u.scope),L&&"OAuth 2.0"]}),size:"lg",footer:n("div",{className:"flex w-full items-center justify-between gap-2 max-sm:[&>*]:flex-none",children:[n("div",{className:"inline-flex items-center gap-2.5 text-[13px] text-dim",children:[!R&&e(M,{label:`启用 ${u.name}`,checked:!z,disabled:T||t.toggling,onCheckedChange:t.onToggle}),e(he,{info:u,tools:!0})]}),n("div",{className:"flex items-center gap-1.5",children:[L&&e(p,{type:"button",variant:"ghost",size:"sm",onClick:_,disabled:T,children:"清除凭据"}),!R&&e(V,{label:"删除服务器",children:e(p,{type:"button",variant:"danger-ghost",size:"icon","aria-label":"删除服务器",onClick:a,disabled:T,children:e(Q,{className:"size-4"})})}),ce&&e(V,{label:"终止服务进程并重新启动,让更新后的代码生效",children:e(p,{type:"button",variant:"ghost",size:"icon","aria-label":"重启",onClick:()=>ae("restart"),disabled:T,children:e(ye,{className:d("size-4",T&&"animate-spin")})})}),ce&&e(p,{type:"button",size:"sm",onClick:()=>ae(J?"disconnect":"connect"),disabled:T,children:J?"断开连接":"连接"}),!R&&n(p,{type:"button",size:"sm",onClick:t.onEdit,disabled:T,children:[e(je,{className:"size-3.5"}),e("span",{children:"编辑配置"})]})]})]}),children:n(v,{children:[n(f,{label:C.type==="local"?"命令":"地址",children:[e("span",{className:"min-w-0 font-mono text-[12px] text-dim leading-5.5 [overflow-wrap:anywhere]",children:x}),e(g,{text:x,label:"复制",size:"icon-xs",className:"shrink-0 text-faint hover:text-ink"})]}),j&&n(f,{label:"授权",children:[e("span",{className:"text-dim leading-7",children:"需要完成 OAuth 授权后才能使用,令牌会自动保存。"}),e(p,{type:"button",variant:"primary",size:"sm",onClick:se,disabled:T,children:"前往授权"})]}),U&&e(f,{label:"错误",children:e("p",{className:"min-w-0 font-mono text-[11.5px] text-danger leading-5 [overflow-wrap:anywhere]",children:W})}),e(f,{label:"工具",children:le?e("span",{className:"text-danger",children:le}):!J?e("span",{className:"text-faint",children:"连接后列出工具"}):!B?e("span",{role:"status",className:"text-faint",children:"正在获取"}):B.length===0?e("span",{className:"text-faint",children:"服务器没有声明任何工具"}):B.map((l)=>e(S,{mono:!0,title:l.description,children:l.name},l.name))})]})})}var Pe=/^[A-Za-z0-9_-]{1,64}$/;function K(t){return e("span",{className:"truncate text-xs text-faint",children:t.children})}function Ne(t){let{pairs:p,onChange:g,InputComponent:S}=t,v=(f,c)=>g(p.map((D,M)=>M===f?{...D,...c}:D));return n("div",{className:"space-y-2",children:[n("div",{className:"flex min-h-7 items-center gap-2",children:[e("span",{className:"shrink-0 text-[13px] font-medium text-dim",children:t.label}),e(K,{children:t.tip}),n("button",{type:"button",className:"ml-auto inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-lg px-2 text-xs font-medium text-dim transition-colors hover:bg-raised hover:text-ink",onClick:()=>g([...p,{key:"",value:"",saved:!1}]),children:[e(oe,{className:"size-3.5"}),"添加"]})]}),p.map((f,c)=>n("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(S,{"aria-label":`${t.keyLabel} ${c+1}`,placeholder:t.keyLabel,value:f.key,readOnly:f.saved,onChange:(D)=>v(c,{key:D.target.value}),className:"min-w-0 flex-[2] font-mono text-xs"}),e(S,{"aria-label":`${t.keyLabel} ${f.key||c+1} 的值`,type:"password",autoComplete:"off",placeholder:f.saved?"已保存,留空保持不变":"值",value:f.value,onChange:(D)=>v(c,{value:D.target.value}),className:"min-w-0 flex-[3] font-mono text-xs"}),e("button",{type:"button","aria-label":`删除 ${f.key||"该项"}`,className:"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-danger/10 hover:text-danger",onClick:()=>g(p.filter((D,M)=>M!==c)),children:e(Z,{className:"size-4"})})]},c))]})}function we(t){return Object.keys(t??{}).map((p)=>({key:p,value:"",saved:!0}))}function Ie(t){let{Button:p,Segmented:g,Dialog:S,Form:v,Field:f,Input:c,Switch:D,style:M,useTheme:V}=y();V();let{existing:d}=t,[Y,I]=r(d?.config.type??"local"),[u,E]=r(d?.name??""),[k,B]=r(d?.config.type==="local"?fe(d.config.command):""),[ee,le]=r(d?.config.type==="remote"?d.config.url:""),[F,T]=r(we(d?.config.type==="local"?d.config.environment:void 0)),[P,J]=r(we(d?.config.type==="remote"?d.config.headers:void 0)),j=d?.config.type==="remote"?d.config.oauth:void 0,[U,L]=r(Boolean(j)),[R,ae]=r(typeof j==="object"&&j.clientId?j.clientId:""),[se,_]=r(""),[a,C]=r(typeof j==="object"&&j.scope?j.scope:""),[x,W]=r(d?.config.defer??"default"),[z,ce]=r(d?.config.timeout!==void 0?String(d.config.timeout):""),[l,ie]=r(d?.config.defer!==void 0||d?.config.timeout!==void 0),[de,q]=r(),[N,re]=r(!1);async function Se(b){b.preventDefault(),q(void 0);let w=u.trim();if(!d&&!Pe.test(w)){q("名称只能包含英文字母、数字、下划线与中划线,长度 1-64");return}if(!d&&t.taken.includes(w)){q("同名服务器已存在");return}let ue=z.trim()?Number.parseInt(z.trim(),10):void 0;if(ue!==void 0&&(!Number.isFinite(ue)||ue<=0)){q("超时时间须为大于 0 的毫秒数");return}let be;if(Y==="local"){let H=Ce(k.trim());if(!H.length){q("请输入启动命令");return}let G={};for(let A of F){let O=A.key.trim();if(!O)continue;if(!A.saved||A.value)G[O]=A.value}be={type:"local",command:H,environment:Object.keys(G).length?G:void 0,enabled:d?d.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ue}}else{let H=ee.trim();try{let O=new URL(H);if(O.protocol!=="http:"&&O.protocol!=="https:")throw Error("bad protocol")}catch{q("请输入合法的 HTTP 或 HTTPS 地址");return}let G={};for(let O of P){let me=O.key.trim();if(!me)continue;if(!O.saved||O.value)G[me]=O.value}let A;if(U){let O=R.trim(),me=se.trim(),ve=a.trim();if(O||me||ve)A={clientId:O||void 0,clientSecret:me||void 0,scope:ve||void 0};else A=!0}else A=!1;be={type:"remote",url:H,headers:Object.keys(G).length?G:void 0,oauth:A,enabled:d?d.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ue}}re(!0);try{let H=d?.name??w,G=d?d.projectID:t.projectID,A=G?`?projectID=${encodeURIComponent(G)}`:"";await t.connection.request(`/api/mcp/${encodeURIComponent(H)}${A}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(be)}),t.onSaved()}catch(H){q(H instanceof Error?H.message:"保存失败")}finally{re(!1)}}return e(S,{open:!0,onOpenChange:(b)=>{if(!b&&!N)t.onClose()},title:d?`编辑 ${d.name}`:"添加 MCP 服务器",size:"lg",footer:n("div",{className:"flex w-full justify-end gap-2.5",children:[e(p,{type:"button",variant:"ghost",onClick:t.onClose,disabled:N,className:"min-w-20",children:"取消"}),e(p,{type:"submit",form:"mcp-server-form",variant:"primary",disabled:N,className:"min-w-24",children:N?"保存中...":"保存"})]}),children:n(v,{id:"mcp-server-form",onSubmit:Se,children:[e(g,{value:Y,onChange:(b)=>I(b),className:"w-full [&>button]:flex-1",options:[{value:"local",label:"本地(标准输入输出)"},{value:"remote",label:"远程(HTTP / SSE)"}]}),!d&&e(f,{label:"名称",aside:e(K,{children:"唯一标识,如 postgres"}),children:(b)=>e(c,{id:b,value:u,onChange:(w)=>E(w.target.value),placeholder:"postgres",className:"font-mono text-xs"})}),Y==="local"?n(m,{children:[e(f,{label:"启动命令",aside:e(K,{children:"完整命令及参数"}),children:(b)=>e(c,{id:b,value:k,onChange:(w)=>B(w.target.value),placeholder:"npx -y @modelcontextprotocol/server-postgres ...",className:"font-mono text-xs"})}),e(Ne,{label:"环境变量",tip:"启动进程时注入",keyLabel:"变量名",pairs:F,onChange:T,InputComponent:c})]}):n(m,{children:[e(f,{label:"服务地址",aside:e(K,{children:"HTTP / HTTPS 端点"}),children:(b)=>e(c,{id:b,value:ee,onChange:(w)=>le(w.target.value),placeholder:"https://example.com/mcp",className:"font-mono text-xs"})}),e(Ne,{label:"请求头",tip:"随每次请求发送",keyLabel:"头字段",pairs:P,onChange:J,InputComponent:c}),n("div",{className:"flex items-center justify-between gap-4",children:[n("div",{className:"min-w-0",children:[e("span",{className:"block text-[13px] font-medium text-dim",children:"OAuth 2.0 认证"}),e("span",{className:"block truncate text-xs text-faint",children:"自动发现授权端点,使用 PKCE 并刷新令牌"})]}),e(D,{checked:U,onCheckedChange:L,label:"启用 OAuth 2.0"})]}),U&&n(m,{children:[e(f,{label:"Client ID",aside:e(K,{children:"留空自动动态注册(DCR)"}),children:(b)=>e(c,{id:b,value:R,onChange:(w)=>ae(w.target.value),placeholder:"留空自动动态注册",className:"font-mono text-xs"})}),e(f,{label:"Client Secret",aside:e(K,{children:"留空保持不变"}),children:(b)=>e(c,{id:b,type:"password",autoComplete:"off",value:se,onChange:(w)=>_(w.target.value),placeholder:"••••••••",className:"font-mono text-xs"})}),e(f,{label:"Scope",aside:e(K,{children:"选填授权范围"}),children:(b)=>e(c,{id:b,value:a,onChange:(w)=>C(w.target.value),placeholder:"repo read:org",className:"font-mono text-xs"})})]})]}),n("div",{className:"space-y-3 border-t border-line/60 pt-3",children:[n("button",{type:"button","aria-expanded":l,className:"flex w-full cursor-pointer items-center gap-1.5 text-[13px] font-medium text-dim transition-colors hover:text-ink",onClick:()=>ie(!l),children:[e(lt,{className:`size-3.5 transition-transform ${l?"rotate-90":""}`}),"高级设置",e("span",{className:"truncate text-xs font-normal text-faint",children:"加载时机、超时"})]}),l&&n("div",{className:"grid grid-cols-2 gap-3 max-sm:grid-cols-1",children:[e(f,{label:"加载时机",aside:e(K,{children:"延迟 = 按需加载"}),children:()=>e(g,{value:x,onChange:(b)=>W(b),className:"w-full [&>button]:flex-1",options:[{value:"default",label:"默认"},{value:"defer",label:"延迟"},{value:"always",label:"常驻"}]})}),e(f,{label:"超时(毫秒)",aside:e(K,{children:"留空用默认"}),children:(b)=>e(c,{id:b,value:z,onChange:(w)=>ce(w.target.value),placeholder:"默认",className:"font-mono text-xs"})})]})]}),de&&n("div",{role:"alert",className:M("callout.base",M("callout.danger"),"px-3 py-2.5 text-xs"),children:[e(te,{className:"mt-0.5 size-3.5 shrink-0"}),e("span",{className:"min-w-0 break-words",children:de})]})]})})}var X="global";function at({connection:t}){let{Button:p,Select:g,CatalogRow:S,style:v,useTheme:f}=y();f();let[c,D]=r(""),[M,V]=r(),[d,Y]=r([]),[I,u]=r(X),[E,k]=r(),[B,ee]=r(!1),[le,F]=r(),[T,P]=r(!1),J=i(!1),[j,U]=r(),L=i(0),R=h(async()=>{let a=++L.current;ee(!0);try{let C=I===X?"":`?projectID=${encodeURIComponent(I)}`,[x,W]=await Promise.all([t.request(`/api/mcp${C}`),t.request("/api/mcp/projects")]);if(a!==L.current)return;if(V(x),Y(W),I!==X&&!W.some((z)=>z.id===I))u(X);k(void 0)}catch(C){if(a===L.current)k(C instanceof Error?C.message:"读取失败")}finally{if(a===L.current)ee(!1)}},[t,I]);o(()=>(R(),()=>{L.current++}),[R]);async function ae(a,C){if(J.current)return;J.current=!0,P(!0);let x=L.current;try{let W=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"",z=await t.request(`/api/mcp/${encodeURIComponent(a.name)}${W}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({...a.config,enabled:C})});if(x===L.current)V((ce)=>ce?.map((l)=>l.name===z.name&&l.projectID===z.projectID?z:l))}finally{J.current=!1,P(!1)}}let se=M?.filter((a)=>`${a.name} ${pe(a.config)}`.toLowerCase().includes(c.trim().toLowerCase())),_=M?.find((a)=>a.name===le);return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[e("h2",{className:v("settings.groupTitle"),children:"MCP 服务器"}),e("p",{className:v("settings.groupDesc"),children:"外部工具与数据源管理"})]}),n("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e(g,{value:I,disabled:B,onValueChange:(a)=>{F(void 0),U(void 0),V(void 0),u(a)},groups:[{options:[{value:X,label:"全局"}]},...Fr(d)],className:"w-44"}),e(p,{variant:"ghost",disabled:B,onClick:R,className:"h-9 px-2.5 text-xs",children:e(ne,{className:`size-3.5 ${B?"animate-spin":""}`})}),n(p,{variant:"secondary",onClick:()=>U({}),className:"h-9 px-2.5 text-xs",children:[e(oe,{className:"size-3.5 mr-1"}),"添加服务器"]})]})]}),E&&n("div",{role:"alert",className:v("callout.base",v("callout.danger"),"mb-3 flex-wrap items-center justify-between"),children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法读取 MCP 服务器:",E]}),e(p,{disabled:B,onClick:R,children:"重试"})]}),e(zr,{label:"搜索 MCP 服务器",placeholder:"搜索服务器",value:c,onChange:D}),e("div",{className:v("settings.groupBox"),children:!M?e(Ur,{}):se?.length===0?e("p",{className:"p-4 text-sm text-dim",children:"没有匹配的 MCP 服务器"}):e("ul",{className:"divide-y divide-line",children:se?.map((a)=>{let C=a.config.enabled===!1,x=a.scope==="file";return e("li",{children:e(S,{name:a.name,selectLabel:`查看 ${a.name}`,onSelect:()=>F(a.name),title:x?"来自项目的 .mcp.json,配置只读,可查看工具与重启":void 0,description:e("span",{className:"font-mono text-[11px]",children:pe(a.config)}),icon:a.config.type==="local"?e(Ke,{}):e(Te,{}),inactive:C,aside:n(m,{children:[e("span",{className:v("control.badge"),children:ge(a.scope)}),e(he,{info:a})]}),toggle:x?void 0:{checked:!C,label:`启用服务器 ${a.name}`,disabled:T||B,onCheckedChange:(W)=>ae(a,W)}})},a.name)})})})]}),_&&!j&&e(xe,{connection:t,info:_,toggling:T,onToggle:(a)=>ae(_,a),projectID:I===X?void 0:I,onClose:()=>F(void 0),onEdit:()=>U({info:_}),onChanged:(a)=>a?V((C)=>C?.map((x)=>x.name===a.name?a:x)):R()},`${_.projectID}:${_.name}`),j&&e(Ie,{connection:t,projectID:I===X?void 0:I,existing:j.info,taken:(M??[]).filter((a)=>a.scope===(I===X?"global":"project")).map((a)=>a.name),onClose:()=>U(void 0),onSaved:()=>{U(void 0),R()}})]})}export{at as McpSection};
1
+ import{h,o,i,r,m,e,n,y,s,te,lt,Te,oe,ne,je,Ke,Q,Z}from"./chunk-jy448465.js";import{Fr,zr,Ur}from"./chunk-2tm4xe0j.js";var ke=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],ye=s("rotate-cw",ke);function Ce(t){let p=[],g="",S,v=!1;for(let f=0;f<t.length;f++){let c=t.charAt(f);if(S)if(c===S)S=void 0;else if(c==="\\"&&S==='"'&&f+1<t.length)g+=t[++f];else g+=c;else if(c==='"'||c==="'")S=c,v=!0;else if(c==="\\"&&f+1<t.length)g+=t[++f],v=!0;else if(/\s/.test(c)){if(v||g)p.push(g);g="",v=!1}else g+=c,v=!0}if(v||g)p.push(g);return p}function fe(t){return t.map((p)=>p===""||/[\s"'\\]/.test(p)?`"${p.replace(/(["\\])/g,"\\$1")}"`:p).join(" ")}var $e={connected:{label:"已连接",dot:"bg-success"},idle:{label:"待连接",dot:"bg-faint"},disabled:{label:"已停用",dot:"bg-faint"},failed:{label:"连接失败",dot:"bg-danger"},needs_auth:{label:"需要认证",dot:"bg-warning"}};function ge(t){if(t==="project")return"项目";if(t==="file")return".mcp.json";return"全局"}function pe(t){return t.type==="local"?fe(t.command):t.url}function he({info:t,tools:p=!1}){let g=$e[t.status.status];return n("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-dim",children:[e("span",{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${g.dot}`}),e("span",{className:p?void 0:"hidden @md/panel:inline",children:g.label}),p&&t.status.status==="connected"&&n("span",{className:"text-faint",children:[t.toolCount," 个工具"]})]})}function xe(t){let{Button:p,CopyButton:g,DetailChip:S,DetailList:v,DetailRow:f,DetailTitle:c,Dialog:D,Switch:M,Tooltip:V,cn:d,confirm:Y,useTheme:I}=y();I();let{info:u,connection:E}=t,k=t.projectID?`?projectID=${encodeURIComponent(t.projectID)}`:"",[B,ee]=r(),[le,F]=r(),[T,P]=r(!1),J=u.status.status==="connected",j=u.status.status==="needs_auth",U=u.status.status==="failed",L=u.config.type==="remote"&&Boolean(u.config.oauth),R=u.scope==="file";o(()=>{function l(N){if(N&&N!==u.name)return;E.request(`/api/mcp/${encodeURIComponent(u.name)}/connect${k}`,{method:"POST"}).then((re)=>t.onChanged(re)).catch(()=>{})}function ie(N){if(N.data?.type==="mcp-oauth-success")l(N.data.name)}function de(N){if(N.key==="basalt-mcp-oauth-event"&&N.newValue)try{let re=JSON.parse(N.newValue);l(re.name)}catch(re){}}window.addEventListener("message",ie),window.addEventListener("storage",de);let q;if("BroadcastChannel"in window)q=new BroadcastChannel("basalt-mcp-oauth"),q.onmessage=(N)=>{if(N.data?.type==="mcp-oauth-success")l(N.data.name)};return()=>{window.removeEventListener("message",ie),window.removeEventListener("storage",de),q?.close()}},[E,u.name,k,t]),o(()=>{if(u.status.status!=="connected")return;E.request(`/api/mcp/${encodeURIComponent(u.name)}/tools${k}`).then((l)=>{if(Array.isArray(l))ee(l),F(void 0)}).catch((l)=>{F(l instanceof Error?l.message:"获取工具失败")})},[E,u.name,k,u.status.status]);async function ae(l){P(!0);try{let ie=await E.request(`/api/mcp/${encodeURIComponent(u.name)}/${l}${k}`,{method:"POST"});t.onChanged(ie)}catch{}finally{P(!1)}}async function se(){P(!0);try{let l=u.status.status==="needs_auth"?u.status.authorizationUrl:void 0;if(!l)l=(await E.request(`/api/mcp/${encodeURIComponent(u.name)}/oauth/authorize${k}`,{method:"POST"})).authorizationUrl;if(l)window.open(l,"_blank","width=600,height=700")}catch(l){F(l instanceof Error?l.message:"获取授权链接失败")}finally{P(!1)}}async function _(){P(!0);try{let l=await E.request(`/api/mcp/${encodeURIComponent(u.name)}/oauth/clear${k}`,{method:"POST"});t.onChanged(l)}finally{P(!1)}}async function a(){if(!await Y({title:`删除 ${u.name}?`,description:"删除后将断开连接并不再向会话提供其工具。",action:"删除",danger:!0}))return;P(!0);try{await E.request(`/api/mcp/${encodeURIComponent(u.name)}${k}`,{method:"DELETE"}),t.onChanged(),t.onClose()}finally{P(!1)}}let C=u.config,x=pe(C),W="error"in u.status?u.status.error:void 0,z=C.enabled===!1,ce=!z&&!j;return e(D,{open:!0,onOpenChange:(l)=>{if(!l&&!T)t.onClose()},title:e(c,{icon:C.type==="local"?e(Ke,{}):e(Te,{}),name:u.name,meta:[C.type==="local"?"本地命令":"远程服务",ge(u.scope),L&&"OAuth 2.0"]}),size:"lg",footer:n("div",{className:"flex w-full items-center justify-between gap-2 max-sm:[&>*]:flex-none",children:[n("div",{className:"inline-flex items-center gap-2.5 text-[13px] text-dim",children:[!R&&e(M,{label:`启用 ${u.name}`,checked:!z,disabled:T||t.toggling,onCheckedChange:t.onToggle}),e(he,{info:u,tools:!0})]}),n("div",{className:"flex items-center gap-1.5",children:[L&&e(p,{type:"button",variant:"ghost",size:"sm",onClick:_,disabled:T,children:"清除凭据"}),!R&&e(V,{label:"删除服务器",children:e(p,{type:"button",variant:"danger-ghost",size:"icon","aria-label":"删除服务器",onClick:a,disabled:T,children:e(Q,{className:"size-4"})})}),ce&&e(V,{label:"终止服务进程并重新启动,让更新后的代码生效",children:e(p,{type:"button",variant:"ghost",size:"icon","aria-label":"重启",onClick:()=>ae("restart"),disabled:T,children:e(ye,{className:d("size-4",T&&"animate-spin")})})}),ce&&e(p,{type:"button",size:"sm",onClick:()=>ae(J?"disconnect":"connect"),disabled:T,children:J?"断开连接":"连接"}),!R&&n(p,{type:"button",size:"sm",onClick:t.onEdit,disabled:T,children:[e(je,{className:"size-3.5"}),e("span",{children:"编辑配置"})]})]})]}),children:n(v,{children:[n(f,{label:C.type==="local"?"命令":"地址",children:[e("span",{className:"min-w-0 font-mono text-[12px] text-dim leading-5.5 [overflow-wrap:anywhere]",children:x}),e(g,{text:x,label:"复制",size:"icon-xs",className:"shrink-0 text-faint hover:text-ink"})]}),j&&n(f,{label:"授权",children:[e("span",{className:"text-dim leading-7",children:"需要完成 OAuth 授权后才能使用,令牌会自动保存。"}),e(p,{type:"button",variant:"primary",size:"sm",onClick:se,disabled:T,children:"前往授权"})]}),U&&e(f,{label:"错误",children:e("p",{className:"min-w-0 font-mono text-[11.5px] text-danger leading-5 [overflow-wrap:anywhere]",children:W})}),e(f,{label:"工具",children:le?e("span",{className:"text-danger",children:le}):!J?e("span",{className:"text-faint",children:"连接后列出工具"}):!B?e("span",{role:"status",className:"text-faint",children:"正在获取"}):B.length===0?e("span",{className:"text-faint",children:"服务器没有声明任何工具"}):B.map((l)=>e(S,{mono:!0,title:l.description,children:l.name},l.name))})]})})}var Pe=/^[A-Za-z0-9_-]{1,64}$/;function K(t){return e("span",{className:"truncate text-xs text-faint",children:t.children})}function Ne(t){let{pairs:p,onChange:g,InputComponent:S}=t,v=(f,c)=>g(p.map((D,M)=>M===f?{...D,...c}:D));return n("div",{className:"space-y-2",children:[n("div",{className:"flex min-h-7 items-center gap-2",children:[e("span",{className:"shrink-0 text-[13px] font-medium text-dim",children:t.label}),e(K,{children:t.tip}),n("button",{type:"button",className:"ml-auto inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-lg px-2 text-xs font-medium text-dim transition-colors hover:bg-raised hover:text-ink",onClick:()=>g([...p,{key:"",value:"",saved:!1}]),children:[e(oe,{className:"size-3.5"}),"添加"]})]}),p.map((f,c)=>n("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(S,{"aria-label":`${t.keyLabel} ${c+1}`,placeholder:t.keyLabel,value:f.key,readOnly:f.saved,onChange:(D)=>v(c,{key:D.target.value}),className:"min-w-0 flex-[2] font-mono text-xs"}),e(S,{"aria-label":`${t.keyLabel} ${f.key||c+1} 的值`,type:"password",autoComplete:"off",placeholder:f.saved?"已保存,留空保持不变":"值",value:f.value,onChange:(D)=>v(c,{value:D.target.value}),className:"min-w-0 flex-[3] font-mono text-xs"}),e("button",{type:"button","aria-label":`删除 ${f.key||"该项"}`,className:"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-danger/10 hover:text-danger",onClick:()=>g(p.filter((D,M)=>M!==c)),children:e(Z,{className:"size-4"})})]},c))]})}function we(t){return Object.keys(t??{}).map((p)=>({key:p,value:"",saved:!0}))}function Ie(t){let{Button:p,Segmented:g,Dialog:S,Form:v,Field:f,Input:c,Switch:D,style:M,useTheme:V}=y();V();let{existing:d}=t,[Y,I]=r(d?.config.type??"local"),[u,E]=r(d?.name??""),[k,B]=r(d?.config.type==="local"?fe(d.config.command):""),[ee,le]=r(d?.config.type==="remote"?d.config.url:""),[F,T]=r(we(d?.config.type==="local"?d.config.environment:void 0)),[P,J]=r(we(d?.config.type==="remote"?d.config.headers:void 0)),j=d?.config.type==="remote"?d.config.oauth:void 0,[U,L]=r(Boolean(j)),[R,ae]=r(typeof j==="object"&&j.clientId?j.clientId:""),[se,_]=r(""),[a,C]=r(typeof j==="object"&&j.scope?j.scope:""),[x,W]=r(d?.config.defer??"default"),[z,ce]=r(d?.config.timeout!==void 0?String(d.config.timeout):""),[l,ie]=r(d?.config.defer!==void 0||d?.config.timeout!==void 0),[de,q]=r(),[N,re]=r(!1);async function Se(b){b.preventDefault(),q(void 0);let w=u.trim();if(!d&&!Pe.test(w)){q("名称只能包含英文字母、数字、下划线与中划线,长度 1-64");return}if(!d&&t.taken.includes(w)){q("同名服务器已存在");return}let ue=z.trim()?Number.parseInt(z.trim(),10):void 0;if(ue!==void 0&&(!Number.isFinite(ue)||ue<=0)){q("超时时间须为大于 0 的毫秒数");return}let be;if(Y==="local"){let H=Ce(k.trim());if(!H.length){q("请输入启动命令");return}let G={};for(let A of F){let O=A.key.trim();if(!O)continue;if(!A.saved||A.value)G[O]=A.value}be={type:"local",command:H,environment:Object.keys(G).length?G:void 0,enabled:d?d.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ue}}else{let H=ee.trim();try{let O=new URL(H);if(O.protocol!=="http:"&&O.protocol!=="https:")throw Error("bad protocol")}catch{q("请输入合法的 HTTP 或 HTTPS 地址");return}let G={};for(let O of P){let me=O.key.trim();if(!me)continue;if(!O.saved||O.value)G[me]=O.value}let A;if(U){let O=R.trim(),me=se.trim(),ve=a.trim();if(O||me||ve)A={clientId:O||void 0,clientSecret:me||void 0,scope:ve||void 0};else A=!0}else A=!1;be={type:"remote",url:H,headers:Object.keys(G).length?G:void 0,oauth:A,enabled:d?d.config.enabled:!0,defer:x==="default"?void 0:x,timeout:ue}}re(!0);try{let H=d?.name??w,G=d?d.projectID:t.projectID,A=G?`?projectID=${encodeURIComponent(G)}`:"";await t.connection.request(`/api/mcp/${encodeURIComponent(H)}${A}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(be)}),t.onSaved()}catch(H){q(H instanceof Error?H.message:"保存失败")}finally{re(!1)}}return e(S,{open:!0,onOpenChange:(b)=>{if(!b&&!N)t.onClose()},title:d?`编辑 ${d.name}`:"添加 MCP 服务器",size:"lg",footer:n("div",{className:"flex w-full justify-end gap-2.5",children:[e(p,{type:"button",variant:"ghost",onClick:t.onClose,disabled:N,className:"min-w-20",children:"取消"}),e(p,{type:"submit",form:"mcp-server-form",variant:"primary",disabled:N,className:"min-w-24",children:N?"保存中...":"保存"})]}),children:n(v,{id:"mcp-server-form",onSubmit:Se,children:[e(g,{value:Y,onChange:(b)=>I(b),className:"w-full [&>button]:flex-1",options:[{value:"local",label:"本地(标准输入输出)"},{value:"remote",label:"远程(HTTP / SSE)"}]}),!d&&e(f,{label:"名称",aside:e(K,{children:"唯一标识,如 postgres"}),children:(b)=>e(c,{id:b,value:u,onChange:(w)=>E(w.target.value),placeholder:"postgres",className:"font-mono text-xs"})}),Y==="local"?n(m,{children:[e(f,{label:"启动命令",aside:e(K,{children:"完整命令及参数"}),children:(b)=>e(c,{id:b,value:k,onChange:(w)=>B(w.target.value),placeholder:"npx -y @modelcontextprotocol/server-postgres ...",className:"font-mono text-xs"})}),e(Ne,{label:"环境变量",tip:"启动进程时注入",keyLabel:"变量名",pairs:F,onChange:T,InputComponent:c})]}):n(m,{children:[e(f,{label:"服务地址",aside:e(K,{children:"HTTP / HTTPS 端点"}),children:(b)=>e(c,{id:b,value:ee,onChange:(w)=>le(w.target.value),placeholder:"https://example.com/mcp",className:"font-mono text-xs"})}),e(Ne,{label:"请求头",tip:"随每次请求发送",keyLabel:"头字段",pairs:P,onChange:J,InputComponent:c}),n("div",{className:"flex items-center justify-between gap-4",children:[n("div",{className:"min-w-0",children:[e("span",{className:"block text-[13px] font-medium text-dim",children:"OAuth 2.0 认证"}),e("span",{className:"block truncate text-xs text-faint",children:"自动发现授权端点,使用 PKCE 并刷新令牌"})]}),e(D,{checked:U,onCheckedChange:L,label:"启用 OAuth 2.0"})]}),U&&n(m,{children:[e(f,{label:"Client ID",aside:e(K,{children:"留空自动动态注册(DCR)"}),children:(b)=>e(c,{id:b,value:R,onChange:(w)=>ae(w.target.value),placeholder:"留空自动动态注册",className:"font-mono text-xs"})}),e(f,{label:"Client Secret",aside:e(K,{children:"留空保持不变"}),children:(b)=>e(c,{id:b,type:"password",autoComplete:"off",value:se,onChange:(w)=>_(w.target.value),placeholder:"••••••••",className:"font-mono text-xs"})}),e(f,{label:"Scope",aside:e(K,{children:"选填授权范围"}),children:(b)=>e(c,{id:b,value:a,onChange:(w)=>C(w.target.value),placeholder:"repo read:org",className:"font-mono text-xs"})})]})]}),n("div",{className:"space-y-3 border-t border-line/60 pt-3",children:[n("button",{type:"button","aria-expanded":l,className:"flex w-full cursor-pointer items-center gap-1.5 text-[13px] font-medium text-dim transition-colors hover:text-ink",onClick:()=>ie(!l),children:[e(lt,{className:`size-3.5 transition-transform ${l?"rotate-90":""}`}),"高级设置",e("span",{className:"truncate text-xs font-normal text-faint",children:"加载时机、超时"})]}),l&&n("div",{className:"grid grid-cols-2 gap-3 max-sm:grid-cols-1",children:[e(f,{label:"加载时机",aside:e(K,{children:"延迟 = 按需加载"}),children:()=>e(g,{value:x,onChange:(b)=>W(b),className:"w-full [&>button]:flex-1",options:[{value:"default",label:"默认"},{value:"defer",label:"延迟"},{value:"always",label:"常驻"}]})}),e(f,{label:"超时(毫秒)",aside:e(K,{children:"留空用默认"}),children:(b)=>e(c,{id:b,value:z,onChange:(w)=>ce(w.target.value),placeholder:"默认",className:"font-mono text-xs"})})]})]}),de&&n("div",{role:"alert",className:M("callout.base",M("callout.danger"),"px-3 py-2.5 text-xs"),children:[e(te,{className:"mt-0.5 size-3.5 shrink-0"}),e("span",{className:"min-w-0 break-words",children:de})]})]})})}var X="global";function at({connection:t}){let{Button:p,Select:g,CatalogRow:S,style:v,useTheme:f}=y();f();let[c,D]=r(""),[M,V]=r(),[d,Y]=r([]),[I,u]=r(X),[E,k]=r(),[B,ee]=r(!1),[le,F]=r(),[T,P]=r(!1),J=i(!1),[j,U]=r(),L=i(0),R=h(async()=>{let a=++L.current;ee(!0);try{let C=I===X?"":`?projectID=${encodeURIComponent(I)}`,[x,W]=await Promise.all([t.request(`/api/mcp${C}`),t.request("/api/mcp/projects")]);if(a!==L.current)return;if(V(x),Y(W),I!==X&&!W.some((z)=>z.id===I))u(X);k(void 0)}catch(C){if(a===L.current)k(C instanceof Error?C.message:"读取失败")}finally{if(a===L.current)ee(!1)}},[t,I]);o(()=>(R(),()=>{L.current++}),[R]);async function ae(a,C){if(J.current)return;J.current=!0,P(!0);let x=L.current;try{let W=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"",z=await t.request(`/api/mcp/${encodeURIComponent(a.name)}${W}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({...a.config,enabled:C})});if(x===L.current)V((ce)=>ce?.map((l)=>l.name===z.name&&l.projectID===z.projectID?z:l))}finally{J.current=!1,P(!1)}}let se=M?.filter((a)=>`${a.name} ${pe(a.config)}`.toLowerCase().includes(c.trim().toLowerCase())),_=M?.find((a)=>a.name===le);return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[e("h2",{className:v("settings.groupTitle"),children:"MCP 服务器"}),e("p",{className:v("settings.groupDesc"),children:"外部工具与数据源管理"})]}),n("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e(g,{value:I,disabled:B,onValueChange:(a)=>{F(void 0),U(void 0),V(void 0),u(a)},groups:[{options:[{value:X,label:"全局"}]},...Fr(d)],className:"w-44"}),e(p,{variant:"ghost",disabled:B,onClick:R,className:"h-9 px-2.5 text-xs",children:e(ne,{className:`size-3.5 ${B?"animate-spin":""}`})}),n(p,{variant:"secondary",onClick:()=>U({}),className:"h-9 px-2.5 text-xs",children:[e(oe,{className:"size-3.5 mr-1"}),"添加服务器"]})]})]}),E&&n("div",{role:"alert",className:v("callout.base",v("callout.danger"),"mb-3 flex-wrap items-center justify-between"),children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法读取 MCP 服务器:",E]}),e(p,{disabled:B,onClick:R,children:"重试"})]}),e(zr,{label:"搜索 MCP 服务器",placeholder:"搜索服务器",value:c,onChange:D}),e("div",{className:v("settings.groupBox"),children:!M?e(Ur,{}):se?.length===0?e("p",{className:"p-4 text-sm text-dim",children:"没有匹配的 MCP 服务器"}):e("ul",{className:"divide-y divide-line",children:se?.map((a)=>{let C=a.config.enabled===!1,x=a.scope==="file";return e("li",{children:e(S,{name:a.name,selectLabel:`查看 ${a.name}`,onSelect:()=>F(a.name),title:x?"来自项目的 .mcp.json,配置只读,可查看工具与重启":void 0,description:e("span",{className:"font-mono text-[11px]",children:pe(a.config)}),icon:a.config.type==="local"?e(Ke,{}):e(Te,{}),inactive:C,aside:n(m,{children:[e("span",{className:v("control.badge"),children:ge(a.scope)}),e(he,{info:a})]}),toggle:x?void 0:{checked:!C,label:`启用服务器 ${a.name}`,disabled:T||B,onCheckedChange:(W)=>ae(a,W)}})},a.name)})})})]}),_&&!j&&e(xe,{connection:t,info:_,toggling:T,onToggle:(a)=>ae(_,a),projectID:I===X?void 0:I,onClose:()=>F(void 0),onEdit:()=>U({info:_}),onChanged:(a)=>a?V((C)=>C?.map((x)=>x.name===a.name?a:x)):R()},`${_.projectID}:${_.name}`),j&&e(Ie,{connection:t,projectID:I===X?void 0:I,existing:j.info,taken:(M??[]).filter((a)=>a.scope===(I===X?"global":"project")).map((a)=>a.name),onClose:()=>U(void 0),onSaved:()=>{U(void 0),R()}})]})}export{at as McpSection};
@@ -1,2 +1,2 @@
1
- import{t,jn,p,Zn}from"./chunk-zsat72qd.js";import{Ce}from"./chunk-ty2rmwda.js";var o=Ce(Zn(),1);var on=t((s,e)=>{let r=s.append("rect");if(r.attr("x",e.x),r.attr("y",e.y),r.attr("fill",e.fill),r.attr("stroke",e.stroke),r.attr("width",e.width),r.attr("height",e.height),e.name)r.attr("name",e.name);if(e.rx)r.attr("rx",e.rx);if(e.ry)r.attr("ry",e.ry);if(e.attrs!==void 0)for(let a in e.attrs)r.attr(a,e.attrs[a]);if(e.class)r.attr("class",e.class);return r},"drawRect"),Gr=t((s,e)=>{let r={x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,stroke:e.stroke,class:"rect"};on(s,r).lower()},"drawBackgroundRect"),uo=t((s,e)=>{let r=e.text.replace(jn," "),a=s.append("text");if(a.attr("x",e.x),a.attr("y",e.y),a.attr("class","legend"),a.style("text-anchor",e.anchor),e.class)a.attr("class",e.class);let i=a.append("tspan");return i.attr("x",e.x+e.textMargin*2),i.text(r),a},"drawText"),La=t((s,e,r,a)=>{let i=s.append("image");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",n)},"drawImage"),Ia=t((s,e,r,a)=>{let i=s.append("use");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",`#${n}`)},"drawEmbeddedImage"),tt=t(()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),"getNoteRect"),Da=t(()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0}),"getTextObj"),Ft=t(()=>{let s=p(".mermaidTooltip");if(s.empty())s=p("body").append("div").attr("class","mermaidTooltip").style("opacity",0).style("position","absolute").style("text-align","center").style("max-width","200px").style("padding","2px").style("font-size","12px").style("background","#ffffde").style("border","1px solid #333").style("border-radius","2px").style("pointer-events","none").style("z-index","100");return s},"createTooltip");
1
+ import{t,jn,p,Zn}from"./chunk-t5ke9cyg.js";import{Ce}from"./chunk-jy448465.js";var o=Ce(Zn(),1);var on=t((s,e)=>{let r=s.append("rect");if(r.attr("x",e.x),r.attr("y",e.y),r.attr("fill",e.fill),r.attr("stroke",e.stroke),r.attr("width",e.width),r.attr("height",e.height),e.name)r.attr("name",e.name);if(e.rx)r.attr("rx",e.rx);if(e.ry)r.attr("ry",e.ry);if(e.attrs!==void 0)for(let a in e.attrs)r.attr(a,e.attrs[a]);if(e.class)r.attr("class",e.class);return r},"drawRect"),Gr=t((s,e)=>{let r={x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,stroke:e.stroke,class:"rect"};on(s,r).lower()},"drawBackgroundRect"),uo=t((s,e)=>{let r=e.text.replace(jn," "),a=s.append("text");if(a.attr("x",e.x),a.attr("y",e.y),a.attr("class","legend"),a.style("text-anchor",e.anchor),e.class)a.attr("class",e.class);let i=a.append("tspan");return i.attr("x",e.x+e.textMargin*2),i.text(r),a},"drawText"),La=t((s,e,r,a)=>{let i=s.append("image");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",n)},"drawImage"),Ia=t((s,e,r,a)=>{let i=s.append("use");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",`#${n}`)},"drawEmbeddedImage"),tt=t(()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),"getNoteRect"),Da=t(()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0}),"getTextObj"),Ft=t(()=>{let s=p(".mermaidTooltip");if(s.empty())s=p("body").append("div").attr("class","mermaidTooltip").style("opacity",0).style("position","absolute").style("text-align","center").style("max-width","200px").style("padding","2px").style("font-size","12px").style("background","#ffffde").style("border","1px solid #333").style("border-radius","2px").style("pointer-events","none").style("z-index","100");return s},"createTooltip");
2
2
  export{on,Gr,uo,La,Ia,tt,Da,Ft};
@@ -1,4 +1,4 @@
1
- import{t,a,we,x,O,F,C,l,V}from"./chunk-zsat72qd.js";var D="",E="",W="",_=[],A=new Map,y=t((e)=>O(e,l()),"sanitizeText"),b=t((e)=>{switch(e.type){case"terminal":return{...e,value:y(e.value)};case"nonterminal":return{...e,name:y(e.name)};case"sequence":return{...e,elements:e.elements.map(b)};case"choice":return{...e,alternatives:e.alternatives.map(b)};case"optional":return{...e,element:b(e.element)};case"repetition":return{...e,element:b(e.element),separator:e.separator?b(e.separator):void 0};case"special":return{...e,text:y(e.text)}}},"sanitizeAstNode"),G=t(()=>{D="",E="",W="",_.length=0,A.clear(),C(),a.debug("[Railroad] Database cleared")},"clear"),L=t((e)=>{D=y(e),a.debug("[Railroad] Title set:",e)},"setTitle"),I=t(()=>D,"getTitle"),U=t((e)=>{let n={...e,name:y(e.name),definition:b(e.definition),comment:e.comment?y(e.comment):void 0};if(a.debug("[Railroad] Adding rule:",n.name),A.has(n.name))a.warn(`[Railroad] Rule '${n.name}' is already defined. Overwriting.`);_.push(n),A.set(n.name,n)},"addRule"),j=t(()=>_,"getRules"),K=t((e)=>A.get(e),"getRule"),J=t((e)=>{E=y(e).replace(/^\s+/g,""),a.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),Q=t(()=>E,"getAccTitle"),Z=t((e)=>{W=y(e).replace(/\n\s+/g,`
1
+ import{t,a,we,x,O,F,C,l,V}from"./chunk-t5ke9cyg.js";var D="",E="",W="",_=[],A=new Map,y=t((e)=>O(e,l()),"sanitizeText"),b=t((e)=>{switch(e.type){case"terminal":return{...e,value:y(e.value)};case"nonterminal":return{...e,name:y(e.name)};case"sequence":return{...e,elements:e.elements.map(b)};case"choice":return{...e,alternatives:e.alternatives.map(b)};case"optional":return{...e,element:b(e.element)};case"repetition":return{...e,element:b(e.element),separator:e.separator?b(e.separator):void 0};case"special":return{...e,text:y(e.text)}}},"sanitizeAstNode"),G=t(()=>{D="",E="",W="",_.length=0,A.clear(),C(),a.debug("[Railroad] Database cleared")},"clear"),L=t((e)=>{D=y(e),a.debug("[Railroad] Title set:",e)},"setTitle"),I=t(()=>D,"getTitle"),U=t((e)=>{let n={...e,name:y(e.name),definition:b(e.definition),comment:e.comment?y(e.comment):void 0};if(a.debug("[Railroad] Adding rule:",n.name),A.has(n.name))a.warn(`[Railroad] Rule '${n.name}' is already defined. Overwriting.`);_.push(n),A.set(n.name,n)},"addRule"),j=t(()=>_,"getRules"),K=t((e)=>A.get(e),"getRule"),J=t((e)=>{E=y(e).replace(/^\s+/g,""),a.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),Q=t(()=>E,"getAccTitle"),Z=t((e)=>{W=y(e).replace(/\n\s+/g,`
2
2
  `),a.debug("[Railroad] Accessibility description set:",e)},"setAccDescription"),te=t(()=>W,"getAccDescription"),re=L,ie=I,ee={clear:G,setTitle:L,getTitle:I,addRule:U,getRules:j,getRule:K,setAccTitle:J,getAccTitle:Q,setAccDescription:Z,getAccDescription:te,setDiagramTitle:re,getDiagramTitle:ie},T={compactMode:!1,padding:10,verticalSeparation:8,horizontalSeparation:10,arcRadius:10,fontSize:14,fontFamily:"monospace",terminalFill:"#FFFFC0",terminalStroke:"#000000",terminalTextColor:"#000000",nonTerminalFill:"#FFFFFF",nonTerminalStroke:"#000000",nonTerminalTextColor:"#000000",lineColor:"#000000",strokeWidth:2,markerFill:"#000000",commentFill:"#E8E8E8",commentStroke:"#888888",commentTextColor:"#666666",specialFill:"#F0E0FF",specialStroke:"#8800CC",ruleNameColor:"#000066",showMarkers:!0,markerRadius:5},ne=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$|^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\([\d\s%+,./-]+\)$|^[a-z]+$/i,ae=/^[\w "',.-]+$/,oe=new Set(["compactMode","padding","verticalSeparation","horizontalSeparation","arcRadius","fontSize","fontFamily","terminalFill","terminalStroke","terminalTextColor","nonTerminalFill","nonTerminalStroke","nonTerminalTextColor","lineColor","strokeWidth","markerFill","commentFill","commentStroke","commentTextColor","specialFill","specialStroke","ruleNameColor","showMarkers","markerRadius"]),X=t((e)=>{if(!e)return!1;return Object.keys(e).every((n)=>n==="railroad"||oe.has(n))},"isRailroadStyleOptions"),le=t((e)=>{if(!e)return{};if("railroad"in e&&e.railroad)return e.railroad;return X(e)?e:{}},"extractRailroadOverrides"),se=t((e)=>{if(!e||X(e))return{};let{railroad:n,svgId:s,theme:i,look:r,...o}=e;return o},"extractThemeOverrides"),u=t((e,n)=>{if(typeof e!=="string")return n;let s=e.trim();return ne.test(s)?s:n},"sanitizeColorValue"),H=t((e,n)=>{if(typeof e!=="string")return n;let s=e.trim();return ae.test(s)?s:n},"sanitizeFontFamilyValue"),z=t((e,n)=>{let s=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(s)&&s>=0?s:n},"sanitizeNumberValue"),de=t((e)=>{let n=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)&&n>0?n:void 0},"parseThemeFontSize"),ce=t((e)=>{let n=H(e.fontFamily,T.fontFamily),s=de(e.fontSize)??T.fontSize;return{...T,fontFamily:n,fontSize:s,terminalFill:u(e.secondBkg??e.secondaryColor,T.terminalFill),terminalStroke:u(e.secondaryBorderColor??e.lineColor,T.terminalStroke),terminalTextColor:u(e.secondaryTextColor??e.textColor,T.terminalTextColor),nonTerminalFill:u(e.mainBkg??e.background,T.nonTerminalFill),nonTerminalStroke:u(e.primaryBorderColor??e.lineColor,T.nonTerminalStroke),nonTerminalTextColor:u(e.primaryTextColor??e.textColor,T.nonTerminalTextColor),lineColor:u(e.lineColor,T.lineColor),markerFill:u(e.lineColor,T.markerFill),commentFill:u(e.labelBackground??e.tertiaryColor,T.commentFill),commentStroke:u(e.tertiaryBorderColor??e.lineColor,T.commentStroke),commentTextColor:u(e.tertiaryTextColor??e.textColor,T.commentTextColor),specialFill:u(e.tertiaryColor??e.secondaryColor,T.specialFill),specialStroke:u(e.tertiaryBorderColor??e.secondaryBorderColor,T.specialStroke),ruleNameColor:u(e.titleColor??e.textColor,T.ruleNameColor)}},"buildThemeDefaults"),B=t((e)=>{let n=x(),s={...we(),...n.themeVariables??{},...se(e)},i=ce(s),r={...n.railroad??{},...le(e)};return{compactMode:r.compactMode??i.compactMode,padding:z(r.padding,i.padding),verticalSeparation:z(r.verticalSeparation,i.verticalSeparation),horizontalSeparation:z(r.horizontalSeparation,i.horizontalSeparation),arcRadius:z(r.arcRadius,i.arcRadius),fontSize:z(r.fontSize,i.fontSize),fontFamily:H(r.fontFamily,i.fontFamily),terminalFill:u(r.terminalFill,i.terminalFill),terminalStroke:u(r.terminalStroke,i.terminalStroke),terminalTextColor:u(r.terminalTextColor,i.terminalTextColor),nonTerminalFill:u(r.nonTerminalFill,i.nonTerminalFill),nonTerminalStroke:u(r.nonTerminalStroke,i.nonTerminalStroke),nonTerminalTextColor:u(r.nonTerminalTextColor,i.nonTerminalTextColor),lineColor:u(r.lineColor,i.lineColor),strokeWidth:z(r.strokeWidth,i.strokeWidth),markerFill:u(r.markerFill,i.markerFill),commentFill:u(r.commentFill,i.commentFill),commentStroke:u(r.commentStroke,i.commentStroke),commentTextColor:u(r.commentTextColor,i.commentTextColor),specialFill:u(r.specialFill,i.specialFill),specialStroke:u(r.specialStroke,i.specialStroke),ruleNameColor:u(r.ruleNameColor,i.ruleNameColor),showMarkers:r.showMarkers??i.showMarkers,markerRadius:z(r.markerRadius,i.markerRadius)}},"buildRailroadStyleOptions"),Dt=t((e)=>{let{fontFamily:n,fontSize:s,terminalFill:i,terminalStroke:r,terminalTextColor:o,nonTerminalFill:g,nonTerminalStroke:m,nonTerminalTextColor:d,lineColor:f,strokeWidth:p,markerFill:h,commentFill:v,commentStroke:c,commentTextColor:w,specialFill:N,specialStroke:R,ruleNameColor:S}=B(e);return`
3
3
  .railroad-diagram {
4
4
  font-family: ${n};
@@ -1 +1 @@
1
- import{o,i,r,it,m,e,n,y,Or,s,K,mn,ot,ie,rr,Z}from"./chunk-ty2rmwda.js";var ke=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],L=s("at-sign",ke);var Ce=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],pe=s("file-code-2",Ce);var we=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ue=s("maximize-2",we);var Me=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],te=s("notebook-pen",Me);var Ie=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],xe=s("user",Ie);var w={approve:{label:"通过",text:"text-success",ring:"ring-success/80",soft:"bg-success/12 text-success"},reject:{label:"反对",text:"text-danger",ring:"ring-danger/80",soft:"bg-danger/12 text-danger"},abstain:{label:"弃权",text:"text-dim",ring:"ring-line-strong",soft:"bg-raised text-dim"},pending:{label:"未表态",text:"text-faint",ring:"ring-line",soft:"bg-raised text-faint"}},ze={thinking:"思考中",reading:"查阅中",speaking:"发言中",idle:"等待中",error:"出错",aborted:"已中止"},F={success:"text-success",warning:"text-warning",danger:"text-danger",neutral:"text-faint"},ne={success:"bg-success",warning:"bg-warning",danger:"bg-danger",neutral:"bg-faint"};function V(t){return t==="thinking"||t==="reading"||t==="speaking"}function W(t){let u=V(t.status);return{busy:u,text:u&&t.activeTool?t.activeTool:ze[t.status]}}function se(t){let u=t.members.filter((b)=>b.verdict==="approve").length,f=t.members.filter((b)=>b.verdict==="reject").length;if(t.state==="running"){if(t.phase==="research")return{tone:"warning",label:"调研中"};if(t.phase==="opening")return{tone:"warning",label:"开场表态"};return{tone:"warning",label:"群聊交流"}}if(t.state==="consensus"){if(u===t.members.length)return{tone:"success",label:"全票通过"};if(f===t.members.length)return{tone:"danger",label:"全票反对"};if(f>u)return{tone:"danger",label:"共识:反对"};return{tone:"success",label:"共识:通过"}}if(t.state==="diverged")return{tone:"warning",label:"存在分歧"};if(t.state==="error")return{tone:"danger",label:"失败"};return{tone:"neutral",label:"已中止"}}function G(t){let u=Math.max(1,Math.round(t/1000));if(u<60)return`${u}s`;return`${Math.floor(u/60)}m ${String(u%60).padStart(2,"0")}s`}var De={research:"调研",opening:"开场表态",discussion:"群聊交流"};function J(t){let{cn:u}=y(),{room:f}=t,b=se(f),g=f.state==="running",v=f.research?["research","opening","discussion"]:["opening","discussion"],a=g?v.indexOf(f.phase==="closed"?"discussion":f.phase??"discussion"):-1,h=[...v.map((d,p)=>({key:d,label:De[d],done:!g||p<a,active:p===a})),{key:"closed",label:g?"结论":b.label,done:!g,active:!1}];return e("ol",{className:u("flex min-w-0 gap-1",t.className),children:h.map((d,p)=>{let c=p===h.length-1&&!g;return n("li",{className:"min-w-0 flex-1",children:[e("span",{className:u("block h-[3px] rounded-full transition-colors duration-300",c?ne[b.tone]:d.active?"bg-accent animate-pulse":d.done?"bg-line-strong":"bg-line/60")}),e("span",{className:u("mt-1.5 block truncate text-[11px]",c?u("font-medium",F[b.tone]):d.active?"font-medium text-ink":d.done?"text-dim":"text-faint"),children:d.label})]},d.key)})})}function ge(t){let{Collapsible:u,CollapsibleContent:f,Composer:b,Markdown:g,ModelIcon:v,ScrollArea:a,SessionView:h,cn:d,confirm:p}=y(),{room:c,onClose:C}=t,[M,x]=r(!1),[X,D]=r(""),[R,H]=r(!1),[_,E]=r(),[S,B]=r(!1),[N,I]=r(!0),[T,z]=r(),ae=i(!1);ae.current=T!==void 0;let[U,Y]=r(),[oe,A]=r(!1),re=i(!1);re.current=U!==void 0;let le=(l)=>{A(!1),Y(l)},ce=i(null),Q=i(null),P=c.state==="running",j=se(c),be=new Map(c.members.map((l)=>[l.id,l]));o(()=>{let l=(de)=>{if(de.key!=="Escape"||de.defaultPrevented||ae.current)return;if(re.current)A(!0);else x(!0)},k=document.body.style.overflow;return document.body.style.overflow="hidden",window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l),document.body.style.overflow=k}},[]);let me=c.messages.length;o(()=>{let l=Q.current;if(!l||!N||me===0)return;l.scrollTo({top:l.scrollHeight,behavior:"smooth"})},[me,N]);let ve=async(l)=>{await t.onPost(l),I(!0)},he=async()=>{if(R)return;if(!await p({title:"中止理事会?",description:"所有成员会立即停止,已有发言保留。",action:"中止",danger:!0}))return;H(!0),E(void 0);try{await t.onAbort()}catch(k){E(k instanceof Error?k.message:"中止理事会失败")}finally{H(!1)}},ee=(l)=>{Y(void 0),D((k)=>k.includes(`@${l}`)?k:`${k?`${k.trimEnd()} `:""}@${l} `),requestAnimationFrame(()=>ce.current?.focus())},Ne=c.members.filter((l)=>l.verdict==="approve").length,ye=c.members.filter((l)=>l.verdict==="reject").length,q=c.members.find((l)=>l.id===T),O=c.members.find((l)=>l.id===U);return it(n("div",{role:"dialog","aria-modal":"true","aria-label":`理事会:${c.topic}`,onAnimationEnd:(l)=>{if(M&&l.target===l.currentTarget)C()},className:d("fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] text-ink",M?"pointer-events-none animate-dialog-out":"animate-dialog-in"),children:[n(u,{open:S,onOpenChange:B,className:"shrink-0 border-b border-line px-4 pt-3 pb-3 sm:px-6",children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-3 text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-[0.2em] text-dim",children:"COUNCIL"}),e("span",{className:"tabular-nums",children:G(t.elapsedMs)}),n("span",{className:"tabular-nums",children:[c.messages.length," 条发言"]})]}),n("button",{type:"button","aria-expanded":S,onClick:()=>B((l)=>!l),className:"mt-0.5 flex max-w-full cursor-pointer items-start gap-1.5 text-left md:items-center",children:[e("h2",{className:"line-clamp-2 text-[15px] leading-snug font-semibold md:truncate md:text-lg",children:c.topic}),e(ie,{className:d("mt-0.5 size-4 shrink-0 text-faint transition-transform duration-300 ease-out-quint md:mt-0",!S&&"-rotate-90")})]})]}),n("div",{className:"flex shrink-0 items-center gap-1",children:[n("span",{className:d("inline-flex items-center gap-1.5 rounded-full border border-line px-2.5 py-1 text-xs font-medium",F[j.tone]),children:[e("span",{className:d("size-1.5 rounded-full",ne[j.tone],P&&"animate-pulse")}),j.label]}),e("button",{type:"button","aria-label":"关闭理事会页面",title:"关闭(Esc)",onClick:()=>x(!0),className:"ml-1 inline-flex size-10 -mr-2 cursor-pointer items-center justify-center rounded-full text-faint transition-colors hover:bg-raised hover:text-ink md:size-8 md:mr-0",children:e(Z,{className:"size-4"})})]})]}),e(f,{children:e("div",{className:"mt-2 max-h-[40dvh] overflow-y-auto overscroll-contain rounded-xl bg-panel px-3.5 py-2.5 text-[13px] leading-relaxed text-dim md:max-h-48",children:e(g,{text:c.brief})})}),e(J,{room:c,className:"mt-3"})]}),n("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[e("div",{className:"flex shrink-0 gap-2 overflow-x-auto overscroll-x-contain border-b border-line px-4 py-2.5 [scrollbar-width:none] md:hidden",children:c.members.map((l)=>e(Se,{member:l,onSelect:()=>z(l.id)},l.id))}),n("aside",{className:"hidden w-72 shrink-0 flex-col gap-2 overflow-y-auto border-r border-line p-4 md:flex",children:[n("div",{className:"flex items-center justify-between text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-wide",children:"席位"}),n("span",{className:"tabular-nums",children:[e("span",{className:"text-success",children:Ne})," / ",e("span",{className:"text-danger",children:ye})," /"," ",c.members.length]})]}),c.members.map((l)=>e(Re,{member:l,viewing:l.id===U,onMention:()=>ee(l.name),onOpen:()=>l.id===U?A(!0):le(l.id)},l.id))]}),O&&n("main",{onAnimationEnd:(l)=>{if(!oe||l.target!==l.currentTarget)return;A(!1),Y(void 0)},className:d("flex min-h-0 min-w-0 flex-1 flex-col",oe?"pointer-events-none animate-overlay-out":"animate-fade"),children:[n("div",{className:"flex shrink-0 items-center gap-2 border-b border-line px-3 py-2 sm:px-4",children:[n("button",{type:"button",onClick:()=>A(!0),className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-2 text-[13px] text-dim transition-colors hover:bg-raised hover:text-ink",children:[e(mn,{className:"size-4"}),"群聊"]}),e("span",{className:"text-line-strong",children:"/"}),n("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 text-[13px] font-medium",children:[e(v,{modelID:O.model,className:"size-4 shrink-0",size:16}),n("span",{className:"truncate",children:[O.name," 的推理过程"]})]}),e("button",{type:"button","aria-label":"在完整页面打开",title:"在完整页面打开",onClick:()=>t.onOpenMember(O.childSessionID),className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-raised hover:text-ink",children:e(ot,{className:"size-4"})})]}),e(h,{sessionID:O.childSessionID},O.childSessionID)]}),n("main",{className:d("min-h-0 min-w-0 flex-1 flex-col animate-fade",O?"hidden":"flex"),children:[e(a,{viewportRef:Q,onScrollCapture:(l)=>{let k=Q.current;if(!k||l.target!==k)return;I(k.scrollHeight-k.scrollTop-k.clientHeight<80)},children:n("div",{className:"mx-auto w-full max-w-3xl px-4 py-4 sm:px-6 md:py-5",children:[c.messages.length===0?n("div",{className:"flex flex-col items-center justify-center gap-3 py-24 text-center text-faint",children:[P?e(K,{className:"size-5 animate-spin"}):null,e("p",{className:"text-sm",children:P?c.phase==="research"?"成员正在各自调研,笔记不会进入群聊":"成员正在独立准备开场观点,彼此不可见":"这场理事会没有产生发言"})]}):e("ol",{className:"space-y-5",children:c.messages.map((l)=>e(Te,{message:l,membersByID:be,onMention:()=>ee(l.senderName)},l.floor))}),c.summary&&!P&&n("section",{className:"mt-8 rounded-2xl border border-line bg-panel px-4 py-3",children:[n("h3",{className:d("text-xs font-semibold",F[j.tone]),children:["结论:",j.label]}),e("div",{className:"mt-1.5 text-[13px] leading-relaxed text-dim",children:e(g,{text:c.summary})})]})]})}),e("div",{className:"shrink-0 px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-6 md:pb-4",children:n("div",{className:"mx-auto w-full max-w-3xl",children:[_&&e("p",{role:"status",className:"px-1 pb-2 text-[13px] text-danger",children:_}),e(b,{draftKey:`council:${c.roomID}`,placeholder:P?"插话,@ 某位成员会点名要求其回应":"理事会已结束,插话会重新唤醒成员",busy:P,allowAttachments:!1,text:X,onTextChange:D,inputRef:ce,onSend:ve,onAbort:()=>void he()})]})})]})]}),q&&e(Oe,{member:q,onClose:()=>z(void 0),onMention:()=>{z(void 0),ee(q.name)},onOpen:()=>{z(void 0),le(q.id)}})]}),document.body)}function Se(t){let{ModelIcon:u,cn:f}=y(),{member:b}=t,g=w[b.verdict]??w.pending,{busy:v}=W(b);return n("button",{type:"button",onClick:t.onSelect,"aria-label":`${b.name},${g.label},查看详情`,className:"flex h-11 max-w-[11rem] shrink-0 cursor-pointer items-center gap-2 rounded-full border border-line bg-panel/60 pr-3.5 pl-1.5 active:bg-raised",children:[n("span",{className:f("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",g.ring),children:[e(u,{modelID:b.model,className:"size-4",size:16}),v&&e(K,{className:"absolute -right-1 -bottom-1 size-3.5 animate-spin rounded-full bg-bg text-accent"})]}),n("span",{className:"min-w-0 text-left leading-tight",children:[e("span",{className:"block truncate text-[13px] font-medium",children:b.name}),e("span",{className:f("block text-[11px]",g.text),children:g.label})]})]})}function Oe(t){let{Button:u,Dialog:f,Markdown:b,ModelIcon:g,cn:v}=y(),{member:a}=t,h=w[a.verdict]??w.pending,d=W(a);return e(f,{open:!0,onOpenChange:(p)=>!p&&t.onClose(),title:n("span",{className:"flex min-w-0 items-center gap-2.5",children:[e("span",{className:v("flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",h.ring),children:e(g,{modelID:a.model,className:"size-4",size:16})}),e("span",{className:"min-w-0 truncate",children:a.name}),e("span",{className:v("shrink-0 rounded px-1.5 py-px text-[11px] font-medium",h.soft),children:h.label})]}),description:a.model,footer:n(m,{children:[n(u,{variant:"secondary",onClick:t.onMention,children:[e(L,{className:"size-4"}),"点名"]}),n(u,{variant:"secondary",onClick:t.onOpen,children:[e(ot,{className:"size-4"}),"查看推理"]})]}),children:n("div",{className:"space-y-3 pb-1",children:[n("div",{className:"flex items-center gap-3 text-[13px]",children:[n("span",{className:v("flex min-w-0 flex-1 items-center gap-1.5",d.busy?"text-accent":"text-dim"),children:[d.busy&&e(K,{className:"size-3.5 shrink-0 animate-spin"}),e("span",{className:"truncate",children:d.text})]}),n("span",{className:"shrink-0 text-faint tabular-nums",children:["发言 ",a.turns??0," 次"]})]}),a.notes?n("section",{children:[n("h3",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-faint",children:[e(te,{className:"size-3.5"}),"调研笔记"]}),e("div",{className:"rounded-xl bg-bg/60 px-3.5 py-2.5 text-[13px] leading-relaxed text-dim",children:e(b,{text:a.notes})})]}):e("p",{className:"text-[13px] text-faint",children:"没有调研笔记"})]})})}function Re(t){let{Collapsible:u,CollapsibleContent:f,Markdown:b,ModelIcon:g,cn:v}=y(),{member:a}=t,[h,d]=r(!1),p=w[a.verdict]??w.pending,{busy:c,text:C}=W(a);return n(u,{open:h,onOpenChange:d,className:v("relative shrink-0 rounded-xl border p-2.5 transition-colors",t.viewing?"border-line-strong bg-raised/60":"border-line bg-panel/60 hover:bg-raised/40"),children:[e("button",{type:"button","aria-label":t.viewing?"返回群聊":`查看 ${a.name} 的推理过程`,"aria-pressed":t.viewing,title:t.viewing?"返回群聊":"查看推理与工具调用",onClick:t.onOpen,className:"absolute inset-0 cursor-pointer rounded-xl"}),n("div",{className:"pointer-events-none relative flex items-center gap-2.5",children:[e("span",{className:v("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",p.ring),children:e(g,{modelID:a.model,className:"size-4",size:16})}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"truncate text-[13px] font-medium",title:a.model,children:a.name}),e("span",{className:v("shrink-0 rounded px-1 text-[10.5px] font-medium",p.soft),children:p.label})]}),n("div",{className:v("flex min-w-0 items-center gap-1 text-[11px]",c?"text-accent":"text-faint"),children:[c&&e(K,{className:"size-3 shrink-0 animate-spin"}),e("span",{className:"truncate",children:C})]})]})]}),n("div",{className:"pointer-events-none relative mt-2 flex items-center gap-1 text-[11px] text-faint",children:[n("span",{className:"tabular-nums",children:["发言 ",a.turns??0," 次"]}),e("span",{className:"ml-auto"}),a.notes&&n("button",{type:"button","aria-expanded":h,onClick:()=>d((M)=>!M),className:v("pointer-events-auto inline-flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 hover:bg-raised hover:text-ink",h&&"text-ink"),children:[e(te,{className:"size-3"}),"笔记"]}),e("button",{type:"button","aria-label":`@ ${a.name}`,title:`@ ${a.name}`,onClick:t.onMention,className:"pointer-events-auto inline-flex cursor-pointer items-center rounded p-1 hover:bg-raised hover:text-ink",children:e(L,{className:"size-3"})})]}),a.notes&&e(f,{children:e("div",{className:"relative mt-2 max-h-56 overflow-y-auto rounded-lg bg-bg/60 px-2.5 py-2 text-xs leading-relaxed text-dim",children:e(b,{text:a.notes})})})]})}function Te(t){let{Code:u,Collapsible:f,CollapsibleContent:b,Markdown:g,cn:v}=y(),{message:a}=t,[h,d]=r(!1),p=a.senderID==="user"||a.senderID==="host",c=a.verdict&&a.verdict!=="pending"?w[a.verdict]:void 0,C=a.evidences??[],M=(a.mentions??[]).map((x)=>t.membersByID.get(x)).filter((x)=>x!==void 0);return n("li",{id:`council-floor-${a.floor}`,className:"group flex gap-3 animate-fade",children:[e(fe,{message:a,isHuman:p,className:"mt-0.5 hidden size-8 md:flex"}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs",children:[e(fe,{message:a,isHuman:p,className:"flex size-6 md:hidden"}),e("span",{className:"font-semibold text-ink",title:a.senderModel,children:a.senderName}),n("a",{href:`#council-floor-${a.floor}`,className:"font-mono text-[11px] text-faint hover:text-dim",onClick:(x)=>x.preventDefault(),children:["#",a.floor]}),c&&e("span",{className:v("rounded px-1.5 py-px text-[10.5px] font-medium",c.soft),children:c.label}),!p&&n("button",{type:"button",onClick:t.onMention,className:"ml-auto inline-flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-[11px] text-faint transition-opacity hover:bg-raised hover:text-ink focus-visible:opacity-100 md:px-1.5 md:py-0.5 md:opacity-0 md:group-hover:opacity-100",children:[e(L,{className:"size-3"}),"回复"]})]}),(a.replyToFloor||M.length>0)&&n("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-faint",children:[a.replyToFloor&&n("button",{type:"button",onClick:()=>document.getElementById(`council-floor-${a.replyToFloor}`)?.scrollIntoView({block:"center",behavior:"smooth"}),className:"inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-md bg-raised/70 px-1.5 py-0.5 hover:text-ink",children:[e(rr,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0 text-dim",children:["#",a.replyToFloor," ",a.replyToName]}),a.replyToPreview&&e("span",{className:"truncate",children:a.replyToPreview})]}),M.map((x)=>n("span",{className:"inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-accent",children:[e(L,{className:"size-3"}),x.name]},x.id))]}),e("div",{className:"mt-1.5 break-words text-[14px] leading-relaxed text-ink/90 md:text-[13.5px] [&_p]:my-1.5 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:e(g,{text:a.text})}),C.length>0&&n(f,{open:h,onOpenChange:d,className:"mt-2",children:[n("button",{type:"button","aria-expanded":h,onClick:()=>d((x)=>!x),className:"inline-flex max-w-full cursor-pointer items-center gap-1 text-[11px] text-faint hover:text-ink",children:[e(pe,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0",children:["查阅 ",C.length," 处"]}),!h&&e("span",{className:"truncate font-mono",children:C.map((x)=>x.label).join(",")}),e(ie,{className:v("size-3 shrink-0 transition-transform duration-300 ease-out-quint",!h&&"-rotate-90")})]}),e(b,{children:e("div",{className:"mt-1.5 space-y-1.5",children:C.map((x)=>n("div",{className:"overflow-hidden rounded-lg border border-line bg-panel text-xs",children:[e("div",{className:"truncate border-b border-line/70 px-2.5 py-1 font-mono text-[11px] text-dim",children:x.label}),x.snippet&&e(u,{code:x.snippet,lang:x.lang||"ts",className:"max-h-40 overflow-auto px-2.5 py-1.5 text-[11.5px]"})]},`${x.tool}:${x.label}:${x.snippet?.slice(0,32)??""}`))})})]})]})]})}function fe(t){let{ModelIcon:u,cn:f}=y();return e("span",{className:f("shrink-0 items-center justify-center rounded-full",t.isHuman?"bg-accent/12 text-accent":"bg-raised",t.className),children:t.message.senderModel?e(u,{modelID:t.message.senderModel,className:"size-4",size:16}):e(xe,{className:"size-4"})})}function rt(t){let{ModelIcon:u,cn:f,useTheme:b}=y();b();let{connection:g,sessionID:v,payload:a,onOpen:h}=t,d=a,[p,c]=r(d),[C,M]=r(()=>{try{return sessionStorage.getItem(Or)===d.roomID}catch{return!1}}),[x,X]=r(Date.now);o(()=>{c(d)},[d]),o(()=>{if(!C)return;try{if(sessionStorage.getItem(Or)===d.roomID)sessionStorage.removeItem(Or)}catch{}},[C,d.roomID]);let D=p.state==="running",R=`/api/sessions/${encodeURIComponent(v)}/council/${encodeURIComponent(p.roomID)}`;o(()=>{if(!D)return;let N=!1,T=setInterval(()=>{if(g.request(R).then((z)=>{if(!N&&z&&typeof z==="object"&&"roomID"in z)c(z)}).catch(()=>{}),!N)X(Date.now())},1200);return()=>{N=!0,clearInterval(T)}},[g,R,D]);let H=async(N)=>{let I=await g.request(`${R}/post`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:N})});c(I)},_=async()=>{let N=await g.request(`${R}/kill`,{method:"POST"});c(N)},E=(D?x:p.updatedAt)-p.createdAt,S=p.messages.at(-1),B=p.members.filter((N)=>V(N.status)).length;return n(m,{children:[n("button",{type:"button","aria-label":`进入理事会:${p.topic}`,onClick:()=>M(!0),className:"group relative my-2 block w-full cursor-pointer overflow-hidden rounded-2xl border border-line bg-panel text-left transition-colors hover:border-line-strong animate-fade",children:[n("div",{className:"px-4 pt-3.5",children:[n("div",{className:"flex items-center gap-1.5 text-[11px] text-faint",children:[e("span",{className:"font-medium text-dim",children:"理事会"}),e("span",{"aria-hidden":!0,children:"·"}),e("span",{className:"tabular-nums",children:G(E)}),n("span",{className:"ml-auto tabular-nums",children:[p.members.length," 位成员"]})]}),e("h4",{className:"mt-1 line-clamp-2 text-sm font-semibold text-ink md:truncate",title:p.topic,children:p.topic})]}),e(J,{room:p,className:"mt-3 px-4"}),e("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 px-4",children:p.members.map((N)=>{let I=w[N.verdict]??w.pending,T=V(N.status);return n("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",title:N.model,children:[n("span",{className:f("relative flex size-6 shrink-0 items-center justify-center rounded-full bg-raised ring-2",I.ring),children:[e(u,{modelID:N.model,className:"size-3.5",size:14}),T&&e(K,{className:"absolute -right-1 -bottom-1 size-3 animate-spin rounded-full bg-panel text-accent"})]}),e("span",{className:"truncate text-dim",children:N.name}),e("span",{className:f("shrink-0 text-[11px]",I.text),children:I.label})]},N.id)})}),n("div",{className:"mt-3 flex items-center gap-2 border-t border-line/70 px-4 py-2.5 text-xs",children:[S?n(m,{children:[e("span",{className:"shrink-0 font-medium text-dim",children:S.senderName}),e("span",{className:"min-w-0 flex-1 truncate text-faint",children:S.text.replace(/\s+/g," ")})]}):e("span",{className:"min-w-0 flex-1 truncate text-faint",children:D?`${B} 位成员正在${p.phase==="research"?"调研":"思考"}…`:"没有发言"}),n("span",{className:"inline-flex shrink-0 items-center gap-1 text-faint transition-colors group-hover:text-ink",children:[p.messages.length>0&&n("span",{className:"tabular-nums",children:[p.messages.length," 条"]}),e(ue,{className:"size-3.5"})]})]})]}),C&&e(ge,{room:p,elapsedMs:E,onClose:()=>M(!1),onOpenMember:h,onPost:H,onAbort:_})]})}export{rt as CouncilCard};
1
+ import{o,i,r,it,m,e,n,y,Or,s,K,mn,ot,ie,rr,Z}from"./chunk-jy448465.js";var ke=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],L=s("at-sign",ke);var Ce=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],pe=s("file-code-2",Ce);var we=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ue=s("maximize-2",we);var Me=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],te=s("notebook-pen",Me);var Ie=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],xe=s("user",Ie);var w={approve:{label:"通过",text:"text-success",ring:"ring-success/80",soft:"bg-success/12 text-success"},reject:{label:"反对",text:"text-danger",ring:"ring-danger/80",soft:"bg-danger/12 text-danger"},abstain:{label:"弃权",text:"text-dim",ring:"ring-line-strong",soft:"bg-raised text-dim"},pending:{label:"未表态",text:"text-faint",ring:"ring-line",soft:"bg-raised text-faint"}},ze={thinking:"思考中",reading:"查阅中",speaking:"发言中",idle:"等待中",error:"出错",aborted:"已中止"},F={success:"text-success",warning:"text-warning",danger:"text-danger",neutral:"text-faint"},ne={success:"bg-success",warning:"bg-warning",danger:"bg-danger",neutral:"bg-faint"};function V(t){return t==="thinking"||t==="reading"||t==="speaking"}function W(t){let u=V(t.status);return{busy:u,text:u&&t.activeTool?t.activeTool:ze[t.status]}}function se(t){let u=t.members.filter((b)=>b.verdict==="approve").length,f=t.members.filter((b)=>b.verdict==="reject").length;if(t.state==="running"){if(t.phase==="research")return{tone:"warning",label:"调研中"};if(t.phase==="opening")return{tone:"warning",label:"开场表态"};return{tone:"warning",label:"群聊交流"}}if(t.state==="consensus"){if(u===t.members.length)return{tone:"success",label:"全票通过"};if(f===t.members.length)return{tone:"danger",label:"全票反对"};if(f>u)return{tone:"danger",label:"共识:反对"};return{tone:"success",label:"共识:通过"}}if(t.state==="diverged")return{tone:"warning",label:"存在分歧"};if(t.state==="error")return{tone:"danger",label:"失败"};return{tone:"neutral",label:"已中止"}}function G(t){let u=Math.max(1,Math.round(t/1000));if(u<60)return`${u}s`;return`${Math.floor(u/60)}m ${String(u%60).padStart(2,"0")}s`}var De={research:"调研",opening:"开场表态",discussion:"群聊交流"};function J(t){let{cn:u}=y(),{room:f}=t,b=se(f),g=f.state==="running",v=f.research?["research","opening","discussion"]:["opening","discussion"],a=g?v.indexOf(f.phase==="closed"?"discussion":f.phase??"discussion"):-1,h=[...v.map((d,p)=>({key:d,label:De[d],done:!g||p<a,active:p===a})),{key:"closed",label:g?"结论":b.label,done:!g,active:!1}];return e("ol",{className:u("flex min-w-0 gap-1",t.className),children:h.map((d,p)=>{let c=p===h.length-1&&!g;return n("li",{className:"min-w-0 flex-1",children:[e("span",{className:u("block h-[3px] rounded-full transition-colors duration-300",c?ne[b.tone]:d.active?"bg-accent animate-pulse":d.done?"bg-line-strong":"bg-line/60")}),e("span",{className:u("mt-1.5 block truncate text-[11px]",c?u("font-medium",F[b.tone]):d.active?"font-medium text-ink":d.done?"text-dim":"text-faint"),children:d.label})]},d.key)})})}function ge(t){let{Collapsible:u,CollapsibleContent:f,Composer:b,Markdown:g,ModelIcon:v,ScrollArea:a,SessionView:h,cn:d,confirm:p}=y(),{room:c,onClose:C}=t,[M,x]=r(!1),[X,D]=r(""),[R,H]=r(!1),[_,E]=r(),[S,B]=r(!1),[N,I]=r(!0),[T,z]=r(),ae=i(!1);ae.current=T!==void 0;let[U,Y]=r(),[oe,A]=r(!1),re=i(!1);re.current=U!==void 0;let le=(l)=>{A(!1),Y(l)},ce=i(null),Q=i(null),P=c.state==="running",j=se(c),be=new Map(c.members.map((l)=>[l.id,l]));o(()=>{let l=(de)=>{if(de.key!=="Escape"||de.defaultPrevented||ae.current)return;if(re.current)A(!0);else x(!0)},k=document.body.style.overflow;return document.body.style.overflow="hidden",window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l),document.body.style.overflow=k}},[]);let me=c.messages.length;o(()=>{let l=Q.current;if(!l||!N||me===0)return;l.scrollTo({top:l.scrollHeight,behavior:"smooth"})},[me,N]);let ve=async(l)=>{await t.onPost(l),I(!0)},he=async()=>{if(R)return;if(!await p({title:"中止理事会?",description:"所有成员会立即停止,已有发言保留。",action:"中止",danger:!0}))return;H(!0),E(void 0);try{await t.onAbort()}catch(k){E(k instanceof Error?k.message:"中止理事会失败")}finally{H(!1)}},ee=(l)=>{Y(void 0),D((k)=>k.includes(`@${l}`)?k:`${k?`${k.trimEnd()} `:""}@${l} `),requestAnimationFrame(()=>ce.current?.focus())},Ne=c.members.filter((l)=>l.verdict==="approve").length,ye=c.members.filter((l)=>l.verdict==="reject").length,q=c.members.find((l)=>l.id===T),O=c.members.find((l)=>l.id===U);return it(n("div",{role:"dialog","aria-modal":"true","aria-label":`理事会:${c.topic}`,onAnimationEnd:(l)=>{if(M&&l.target===l.currentTarget)C()},className:d("fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] text-ink",M?"pointer-events-none animate-dialog-out":"animate-dialog-in"),children:[n(u,{open:S,onOpenChange:B,className:"shrink-0 border-b border-line px-4 pt-3 pb-3 sm:px-6",children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-3 text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-[0.2em] text-dim",children:"COUNCIL"}),e("span",{className:"tabular-nums",children:G(t.elapsedMs)}),n("span",{className:"tabular-nums",children:[c.messages.length," 条发言"]})]}),n("button",{type:"button","aria-expanded":S,onClick:()=>B((l)=>!l),className:"mt-0.5 flex max-w-full cursor-pointer items-start gap-1.5 text-left md:items-center",children:[e("h2",{className:"line-clamp-2 text-[15px] leading-snug font-semibold md:truncate md:text-lg",children:c.topic}),e(ie,{className:d("mt-0.5 size-4 shrink-0 text-faint transition-transform duration-300 ease-out-quint md:mt-0",!S&&"-rotate-90")})]})]}),n("div",{className:"flex shrink-0 items-center gap-1",children:[n("span",{className:d("inline-flex items-center gap-1.5 rounded-full border border-line px-2.5 py-1 text-xs font-medium",F[j.tone]),children:[e("span",{className:d("size-1.5 rounded-full",ne[j.tone],P&&"animate-pulse")}),j.label]}),e("button",{type:"button","aria-label":"关闭理事会页面",title:"关闭(Esc)",onClick:()=>x(!0),className:"ml-1 inline-flex size-10 -mr-2 cursor-pointer items-center justify-center rounded-full text-faint transition-colors hover:bg-raised hover:text-ink md:size-8 md:mr-0",children:e(Z,{className:"size-4"})})]})]}),e(f,{children:e("div",{className:"mt-2 max-h-[40dvh] overflow-y-auto overscroll-contain rounded-xl bg-panel px-3.5 py-2.5 text-[13px] leading-relaxed text-dim md:max-h-48",children:e(g,{text:c.brief})})}),e(J,{room:c,className:"mt-3"})]}),n("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[e("div",{className:"flex shrink-0 gap-2 overflow-x-auto overscroll-x-contain border-b border-line px-4 py-2.5 [scrollbar-width:none] md:hidden",children:c.members.map((l)=>e(Se,{member:l,onSelect:()=>z(l.id)},l.id))}),n("aside",{className:"hidden w-72 shrink-0 flex-col gap-2 overflow-y-auto border-r border-line p-4 md:flex",children:[n("div",{className:"flex items-center justify-between text-[11px] text-faint",children:[e("span",{className:"font-medium tracking-wide",children:"席位"}),n("span",{className:"tabular-nums",children:[e("span",{className:"text-success",children:Ne})," / ",e("span",{className:"text-danger",children:ye})," /"," ",c.members.length]})]}),c.members.map((l)=>e(Re,{member:l,viewing:l.id===U,onMention:()=>ee(l.name),onOpen:()=>l.id===U?A(!0):le(l.id)},l.id))]}),O&&n("main",{onAnimationEnd:(l)=>{if(!oe||l.target!==l.currentTarget)return;A(!1),Y(void 0)},className:d("flex min-h-0 min-w-0 flex-1 flex-col",oe?"pointer-events-none animate-overlay-out":"animate-fade"),children:[n("div",{className:"flex shrink-0 items-center gap-2 border-b border-line px-3 py-2 sm:px-4",children:[n("button",{type:"button",onClick:()=>A(!0),className:"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-2 text-[13px] text-dim transition-colors hover:bg-raised hover:text-ink",children:[e(mn,{className:"size-4"}),"群聊"]}),e("span",{className:"text-line-strong",children:"/"}),n("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 text-[13px] font-medium",children:[e(v,{modelID:O.model,className:"size-4 shrink-0",size:16}),n("span",{className:"truncate",children:[O.name," 的推理过程"]})]}),e("button",{type:"button","aria-label":"在完整页面打开",title:"在完整页面打开",onClick:()=>t.onOpenMember(O.childSessionID),className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-raised hover:text-ink",children:e(ot,{className:"size-4"})})]}),e(h,{sessionID:O.childSessionID},O.childSessionID)]}),n("main",{className:d("min-h-0 min-w-0 flex-1 flex-col animate-fade",O?"hidden":"flex"),children:[e(a,{viewportRef:Q,onScrollCapture:(l)=>{let k=Q.current;if(!k||l.target!==k)return;I(k.scrollHeight-k.scrollTop-k.clientHeight<80)},children:n("div",{className:"mx-auto w-full max-w-3xl px-4 py-4 sm:px-6 md:py-5",children:[c.messages.length===0?n("div",{className:"flex flex-col items-center justify-center gap-3 py-24 text-center text-faint",children:[P?e(K,{className:"size-5 animate-spin"}):null,e("p",{className:"text-sm",children:P?c.phase==="research"?"成员正在各自调研,笔记不会进入群聊":"成员正在独立准备开场观点,彼此不可见":"这场理事会没有产生发言"})]}):e("ol",{className:"space-y-5",children:c.messages.map((l)=>e(Te,{message:l,membersByID:be,onMention:()=>ee(l.senderName)},l.floor))}),c.summary&&!P&&n("section",{className:"mt-8 rounded-2xl border border-line bg-panel px-4 py-3",children:[n("h3",{className:d("text-xs font-semibold",F[j.tone]),children:["结论:",j.label]}),e("div",{className:"mt-1.5 text-[13px] leading-relaxed text-dim",children:e(g,{text:c.summary})})]})]})}),e("div",{className:"shrink-0 px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-6 md:pb-4",children:n("div",{className:"mx-auto w-full max-w-3xl",children:[_&&e("p",{role:"status",className:"px-1 pb-2 text-[13px] text-danger",children:_}),e(b,{draftKey:`council:${c.roomID}`,placeholder:P?"插话,@ 某位成员会点名要求其回应":"理事会已结束,插话会重新唤醒成员",busy:P,allowAttachments:!1,text:X,onTextChange:D,inputRef:ce,onSend:ve,onAbort:()=>void he()})]})})]})]}),q&&e(Oe,{member:q,onClose:()=>z(void 0),onMention:()=>{z(void 0),ee(q.name)},onOpen:()=>{z(void 0),le(q.id)}})]}),document.body)}function Se(t){let{ModelIcon:u,cn:f}=y(),{member:b}=t,g=w[b.verdict]??w.pending,{busy:v}=W(b);return n("button",{type:"button",onClick:t.onSelect,"aria-label":`${b.name},${g.label},查看详情`,className:"flex h-11 max-w-[11rem] shrink-0 cursor-pointer items-center gap-2 rounded-full border border-line bg-panel/60 pr-3.5 pl-1.5 active:bg-raised",children:[n("span",{className:f("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",g.ring),children:[e(u,{modelID:b.model,className:"size-4",size:16}),v&&e(K,{className:"absolute -right-1 -bottom-1 size-3.5 animate-spin rounded-full bg-bg text-accent"})]}),n("span",{className:"min-w-0 text-left leading-tight",children:[e("span",{className:"block truncate text-[13px] font-medium",children:b.name}),e("span",{className:f("block text-[11px]",g.text),children:g.label})]})]})}function Oe(t){let{Button:u,Dialog:f,Markdown:b,ModelIcon:g,cn:v}=y(),{member:a}=t,h=w[a.verdict]??w.pending,d=W(a);return e(f,{open:!0,onOpenChange:(p)=>!p&&t.onClose(),title:n("span",{className:"flex min-w-0 items-center gap-2.5",children:[e("span",{className:v("flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",h.ring),children:e(g,{modelID:a.model,className:"size-4",size:16})}),e("span",{className:"min-w-0 truncate",children:a.name}),e("span",{className:v("shrink-0 rounded px-1.5 py-px text-[11px] font-medium",h.soft),children:h.label})]}),description:a.model,footer:n(m,{children:[n(u,{variant:"secondary",onClick:t.onMention,children:[e(L,{className:"size-4"}),"点名"]}),n(u,{variant:"secondary",onClick:t.onOpen,children:[e(ot,{className:"size-4"}),"查看推理"]})]}),children:n("div",{className:"space-y-3 pb-1",children:[n("div",{className:"flex items-center gap-3 text-[13px]",children:[n("span",{className:v("flex min-w-0 flex-1 items-center gap-1.5",d.busy?"text-accent":"text-dim"),children:[d.busy&&e(K,{className:"size-3.5 shrink-0 animate-spin"}),e("span",{className:"truncate",children:d.text})]}),n("span",{className:"shrink-0 text-faint tabular-nums",children:["发言 ",a.turns??0," 次"]})]}),a.notes?n("section",{children:[n("h3",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-faint",children:[e(te,{className:"size-3.5"}),"调研笔记"]}),e("div",{className:"rounded-xl bg-bg/60 px-3.5 py-2.5 text-[13px] leading-relaxed text-dim",children:e(b,{text:a.notes})})]}):e("p",{className:"text-[13px] text-faint",children:"没有调研笔记"})]})})}function Re(t){let{Collapsible:u,CollapsibleContent:f,Markdown:b,ModelIcon:g,cn:v}=y(),{member:a}=t,[h,d]=r(!1),p=w[a.verdict]??w.pending,{busy:c,text:C}=W(a);return n(u,{open:h,onOpenChange:d,className:v("relative shrink-0 rounded-xl border p-2.5 transition-colors",t.viewing?"border-line-strong bg-raised/60":"border-line bg-panel/60 hover:bg-raised/40"),children:[e("button",{type:"button","aria-label":t.viewing?"返回群聊":`查看 ${a.name} 的推理过程`,"aria-pressed":t.viewing,title:t.viewing?"返回群聊":"查看推理与工具调用",onClick:t.onOpen,className:"absolute inset-0 cursor-pointer rounded-xl"}),n("div",{className:"pointer-events-none relative flex items-center gap-2.5",children:[e("span",{className:v("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-raised ring-2",p.ring),children:e(g,{modelID:a.model,className:"size-4",size:16})}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"truncate text-[13px] font-medium",title:a.model,children:a.name}),e("span",{className:v("shrink-0 rounded px-1 text-[10.5px] font-medium",p.soft),children:p.label})]}),n("div",{className:v("flex min-w-0 items-center gap-1 text-[11px]",c?"text-accent":"text-faint"),children:[c&&e(K,{className:"size-3 shrink-0 animate-spin"}),e("span",{className:"truncate",children:C})]})]})]}),n("div",{className:"pointer-events-none relative mt-2 flex items-center gap-1 text-[11px] text-faint",children:[n("span",{className:"tabular-nums",children:["发言 ",a.turns??0," 次"]}),e("span",{className:"ml-auto"}),a.notes&&n("button",{type:"button","aria-expanded":h,onClick:()=>d((M)=>!M),className:v("pointer-events-auto inline-flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 hover:bg-raised hover:text-ink",h&&"text-ink"),children:[e(te,{className:"size-3"}),"笔记"]}),e("button",{type:"button","aria-label":`@ ${a.name}`,title:`@ ${a.name}`,onClick:t.onMention,className:"pointer-events-auto inline-flex cursor-pointer items-center rounded p-1 hover:bg-raised hover:text-ink",children:e(L,{className:"size-3"})})]}),a.notes&&e(f,{children:e("div",{className:"relative mt-2 max-h-56 overflow-y-auto rounded-lg bg-bg/60 px-2.5 py-2 text-xs leading-relaxed text-dim",children:e(b,{text:a.notes})})})]})}function Te(t){let{Code:u,Collapsible:f,CollapsibleContent:b,Markdown:g,cn:v}=y(),{message:a}=t,[h,d]=r(!1),p=a.senderID==="user"||a.senderID==="host",c=a.verdict&&a.verdict!=="pending"?w[a.verdict]:void 0,C=a.evidences??[],M=(a.mentions??[]).map((x)=>t.membersByID.get(x)).filter((x)=>x!==void 0);return n("li",{id:`council-floor-${a.floor}`,className:"group flex gap-3 animate-fade",children:[e(fe,{message:a,isHuman:p,className:"mt-0.5 hidden size-8 md:flex"}),n("div",{className:"min-w-0 flex-1",children:[n("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs",children:[e(fe,{message:a,isHuman:p,className:"flex size-6 md:hidden"}),e("span",{className:"font-semibold text-ink",title:a.senderModel,children:a.senderName}),n("a",{href:`#council-floor-${a.floor}`,className:"font-mono text-[11px] text-faint hover:text-dim",onClick:(x)=>x.preventDefault(),children:["#",a.floor]}),c&&e("span",{className:v("rounded px-1.5 py-px text-[10.5px] font-medium",c.soft),children:c.label}),!p&&n("button",{type:"button",onClick:t.onMention,className:"ml-auto inline-flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-[11px] text-faint transition-opacity hover:bg-raised hover:text-ink focus-visible:opacity-100 md:px-1.5 md:py-0.5 md:opacity-0 md:group-hover:opacity-100",children:[e(L,{className:"size-3"}),"回复"]})]}),(a.replyToFloor||M.length>0)&&n("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-faint",children:[a.replyToFloor&&n("button",{type:"button",onClick:()=>document.getElementById(`council-floor-${a.replyToFloor}`)?.scrollIntoView({block:"center",behavior:"smooth"}),className:"inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-md bg-raised/70 px-1.5 py-0.5 hover:text-ink",children:[e(rr,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0 text-dim",children:["#",a.replyToFloor," ",a.replyToName]}),a.replyToPreview&&e("span",{className:"truncate",children:a.replyToPreview})]}),M.map((x)=>n("span",{className:"inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-accent",children:[e(L,{className:"size-3"}),x.name]},x.id))]}),e("div",{className:"mt-1.5 break-words text-[14px] leading-relaxed text-ink/90 md:text-[13.5px] [&_p]:my-1.5 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:e(g,{text:a.text})}),C.length>0&&n(f,{open:h,onOpenChange:d,className:"mt-2",children:[n("button",{type:"button","aria-expanded":h,onClick:()=>d((x)=>!x),className:"inline-flex max-w-full cursor-pointer items-center gap-1 text-[11px] text-faint hover:text-ink",children:[e(pe,{className:"size-3 shrink-0"}),n("span",{className:"shrink-0",children:["查阅 ",C.length," 处"]}),!h&&e("span",{className:"truncate font-mono",children:C.map((x)=>x.label).join(",")}),e(ie,{className:v("size-3 shrink-0 transition-transform duration-300 ease-out-quint",!h&&"-rotate-90")})]}),e(b,{children:e("div",{className:"mt-1.5 space-y-1.5",children:C.map((x)=>n("div",{className:"overflow-hidden rounded-lg border border-line bg-panel text-xs",children:[e("div",{className:"truncate border-b border-line/70 px-2.5 py-1 font-mono text-[11px] text-dim",children:x.label}),x.snippet&&e(u,{code:x.snippet,lang:x.lang||"ts",className:"max-h-40 overflow-auto px-2.5 py-1.5 text-[11.5px]"})]},`${x.tool}:${x.label}:${x.snippet?.slice(0,32)??""}`))})})]})]})]})}function fe(t){let{ModelIcon:u,cn:f}=y();return e("span",{className:f("shrink-0 items-center justify-center rounded-full",t.isHuman?"bg-accent/12 text-accent":"bg-raised",t.className),children:t.message.senderModel?e(u,{modelID:t.message.senderModel,className:"size-4",size:16}):e(xe,{className:"size-4"})})}function rt(t){let{ModelIcon:u,cn:f,useTheme:b}=y();b();let{connection:g,sessionID:v,payload:a,onOpen:h}=t,d=a,[p,c]=r(d),[C,M]=r(()=>{try{return sessionStorage.getItem(Or)===d.roomID}catch{return!1}}),[x,X]=r(Date.now);o(()=>{c(d)},[d]),o(()=>{if(!C)return;try{if(sessionStorage.getItem(Or)===d.roomID)sessionStorage.removeItem(Or)}catch{}},[C,d.roomID]);let D=p.state==="running",R=`/api/sessions/${encodeURIComponent(v)}/council/${encodeURIComponent(p.roomID)}`;o(()=>{if(!D)return;let N=!1,T=setInterval(()=>{if(g.request(R).then((z)=>{if(!N&&z&&typeof z==="object"&&"roomID"in z)c(z)}).catch(()=>{}),!N)X(Date.now())},1200);return()=>{N=!0,clearInterval(T)}},[g,R,D]);let H=async(N)=>{let I=await g.request(`${R}/post`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:N})});c(I)},_=async()=>{let N=await g.request(`${R}/kill`,{method:"POST"});c(N)},E=(D?x:p.updatedAt)-p.createdAt,S=p.messages.at(-1),B=p.members.filter((N)=>V(N.status)).length;return n(m,{children:[n("button",{type:"button","aria-label":`进入理事会:${p.topic}`,onClick:()=>M(!0),className:"group relative my-2 block w-full cursor-pointer overflow-hidden rounded-2xl border border-line bg-panel text-left transition-colors hover:border-line-strong animate-fade",children:[n("div",{className:"px-4 pt-3.5",children:[n("div",{className:"flex items-center gap-1.5 text-[11px] text-faint",children:[e("span",{className:"font-medium text-dim",children:"理事会"}),e("span",{"aria-hidden":!0,children:"·"}),e("span",{className:"tabular-nums",children:G(E)}),n("span",{className:"ml-auto tabular-nums",children:[p.members.length," 位成员"]})]}),e("h4",{className:"mt-1 line-clamp-2 text-sm font-semibold text-ink md:truncate",title:p.topic,children:p.topic})]}),e(J,{room:p,className:"mt-3 px-4"}),e("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 px-4",children:p.members.map((N)=>{let I=w[N.verdict]??w.pending,T=V(N.status);return n("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",title:N.model,children:[n("span",{className:f("relative flex size-6 shrink-0 items-center justify-center rounded-full bg-raised ring-2",I.ring),children:[e(u,{modelID:N.model,className:"size-3.5",size:14}),T&&e(K,{className:"absolute -right-1 -bottom-1 size-3 animate-spin rounded-full bg-panel text-accent"})]}),e("span",{className:"truncate text-dim",children:N.name}),e("span",{className:f("shrink-0 text-[11px]",I.text),children:I.label})]},N.id)})}),n("div",{className:"mt-3 flex items-center gap-2 border-t border-line/70 px-4 py-2.5 text-xs",children:[S?n(m,{children:[e("span",{className:"shrink-0 font-medium text-dim",children:S.senderName}),e("span",{className:"min-w-0 flex-1 truncate text-faint",children:S.text.replace(/\s+/g," ")})]}):e("span",{className:"min-w-0 flex-1 truncate text-faint",children:D?`${B} 位成员正在${p.phase==="research"?"调研":"思考"}…`:"没有发言"}),n("span",{className:"inline-flex shrink-0 items-center gap-1 text-faint transition-colors group-hover:text-ink",children:[p.messages.length>0&&n("span",{className:"tabular-nums",children:[p.messages.length," 条"]}),e(ue,{className:"size-3.5"})]})]})]}),C&&e(ge,{room:p,elapsedMs:E,onClose:()=>M(!1),onOpenMember:h,onPost:H,onAbort:_})]})}export{rt as CouncilCard};