@bkm016/basalt 0.1.13 → 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 (245) hide show
  1. package/README.md +3 -2
  2. package/{chunk-bng72094.js → chunk-03wzwnn6.js} +1 -1
  3. package/{chunk-9e8vhzy7.js → chunk-0crbhhna.js} +1 -1
  4. package/{chunk-h9zxqeqr.js → chunk-0rasqm8y.js} +2 -2
  5. package/{chunk-0x9netvr.js → chunk-1w4nh5t6.js} +1 -1
  6. package/{chunk-dk6fgprw.js → chunk-2eaehpp6.js} +1 -1
  7. package/{chunk-6sea12mw.js → chunk-30dxcr91.js} +1 -1
  8. package/{chunk-2zbj8ny6.js → chunk-343jsm46.js} +2 -2
  9. package/chunk-38g4jd6v.js +5 -0
  10. package/{chunk-zx75vnw8.js → chunk-39mh7h58.js} +22 -22
  11. package/chunk-44b9yx79.js +2 -0
  12. package/{chunk-r1jn77q6.js → chunk-4f6p4n7k.js} +2 -2
  13. package/{chunk-sgz87ht5.js → chunk-4w8j6n7z.js} +1 -1
  14. package/{chunk-szj85dqe.js → chunk-4yxd2kg1.js} +2 -2
  15. package/{chunk-bp61xdsc.js → chunk-59hg9a84.js} +1 -1
  16. package/{chunk-yy1f9jxc.js → chunk-5n1qra6k.js} +429 -310
  17. package/{chunk-bq54argx.js → chunk-62ebm0bn.js} +1 -1
  18. package/{chunk-6d9r9p91.js → chunk-6ef085c1.js} +4 -4
  19. package/{chunk-zk91579b.js → chunk-6hx9y86d.js} +2 -2
  20. package/chunk-73t051r6.js +2 -0
  21. package/{chunk-pryvvs96.js → chunk-7mgkpn94.js} +22 -22
  22. package/{chunk-2q56egb8.js → chunk-81x8r8w4.js} +1 -1
  23. package/{chunk-rn3jwyh1.js → chunk-8np9b2y8.js} +2 -2
  24. package/{chunk-1q6e3mj7.js → chunk-9ew8cap5.js} +2 -2
  25. package/chunk-9v3b7jjv.js +2 -0
  26. package/{chunk-tjg0gcks.js → chunk-9vam83py.js} +1 -1
  27. package/{chunk-ct77cdg7.js → chunk-9xjecw6c.js} +1 -1
  28. package/{chunk-8cgz8xv7.js → chunk-b2wpj81x.js} +2 -2
  29. package/{chunk-302n9g7p.js → chunk-bjvv3403.js} +1 -1
  30. package/{chunk-tfhze1vq.js → chunk-c8g9jjqs.js} +2 -2
  31. package/{chunk-0a7ft50x.js → chunk-cs91rmbf.js} +8 -8
  32. package/{chunk-gpnqmtbk.js → chunk-edcf97ka.js} +1 -1
  33. package/{chunk-74wwdx3y.js → chunk-en7z6ne5.js} +2 -2
  34. package/{chunk-f0h2bv11.js → chunk-evnqkyt7.js} +10 -10
  35. package/{chunk-4rnmxtpx.js → chunk-ge38dhv9.js} +2 -2
  36. package/chunk-hggam3je.js +2 -0
  37. package/{chunk-mf04h0yy.js → chunk-k38jaz6c.js} +4 -4
  38. package/{chunk-jjtt9aq8.js → chunk-kcn05erf.js} +3 -3
  39. package/{chunk-y23dpz5e.js → chunk-m5km74eq.js} +2 -2
  40. package/{chunk-095adzn5.js → chunk-mfb3dgs8.js} +2 -2
  41. package/{chunk-0nedq669.js → chunk-mh4bjtfs.js} +3 -3
  42. package/{chunk-bja7p3em.js → chunk-p886jr17.js} +13 -13
  43. package/{chunk-xvm0y99b.js → chunk-pdt65s31.js} +2 -2
  44. package/{chunk-ymg7mtcx.js → chunk-pjgt1bdx.js} +2 -2
  45. package/{chunk-959z9efn.js → chunk-pyj6avd5.js} +2 -2
  46. package/chunk-qd2enpr2.js +3 -0
  47. package/{chunk-tnj2kqb8.js → chunk-qe76naq9.js} +1 -1
  48. package/{chunk-z0c8ek0j.js → chunk-qjnx4fsn.js} +2 -2
  49. package/{chunk-2tf7qfbx.js → chunk-qs161f2q.js} +2 -2
  50. package/{chunk-nbjnwd54.js → chunk-rghqprav.js} +1 -1
  51. package/{chunk-7chv3knf.js → chunk-t33bm5aa.js} +1 -1
  52. package/chunk-tszctb17.js +482 -0
  53. package/chunk-vd5332ps.js +2 -0
  54. package/{chunk-22az84sh.js → chunk-w55cnj0f.js} +2 -2
  55. package/{chunk-4k9t9jvx.js → chunk-wnd3y4c0.js} +1 -1
  56. package/{chunk-snz19yc2.js → chunk-xafx1p7z.js} +2 -2
  57. package/{chunk-15ve3nmv.js → chunk-xf7zw32f.js} +12 -12
  58. package/{chunk-kbpbrr11.js → chunk-xq74x4gc.js} +2 -2
  59. package/{chunk-mdkfm1ak.js → chunk-y0274xr2.js} +3 -3
  60. package/{chunk-y4pvhes1.js → chunk-z9p6s986.js} +6 -6
  61. package/{chunk-41das1ty.js → chunk-zcwz44db.js} +1 -1
  62. package/{chunk-77c2cqp2.js → chunk-zhyzhekt.js} +1 -1
  63. package/compiled.js +12 -12
  64. package/package.json +1 -1
  65. package/ui-test-worker.js +51 -51
  66. package/web/chunk-00swes3c.js +1 -0
  67. package/web/{chunk-s935z8er.js → chunk-01nbc18z.js} +2 -2
  68. package/web/chunk-0e995hjg.js +1 -0
  69. package/web/{chunk-16jc5m0f.js → chunk-17wwzrp4.js} +1 -1
  70. package/web/{chunk-8j4tzff5.js → chunk-1bhpfsvr.js} +3 -3
  71. package/web/{chunk-qb8mbptk.js → chunk-1v6hhgc6.js} +1 -1
  72. package/web/chunk-1y387f45.js +1 -0
  73. package/web/{chunk-ddg8rz82.js → chunk-251yw6f2.js} +1 -1
  74. package/web/{chunk-mykrm8ba.js → chunk-25sn840r.js} +2 -2
  75. package/web/{chunk-b4gcpsbg.js → chunk-27cntdyk.js} +5 -5
  76. package/web/chunk-2tm4xe0j.js +2 -0
  77. package/web/chunk-3egthz5k.js +2 -0
  78. package/web/{chunk-p7pa02k9.js → chunk-3f8fjee5.js} +2 -2
  79. package/web/chunk-3fjzgpaw.js +1 -0
  80. package/web/{chunk-zqcg6frm.js → chunk-3hy2gsgf.js} +1 -1
  81. package/web/chunk-3mgzqbc8.js +1 -0
  82. package/web/chunk-3yvanftw.js +1 -0
  83. package/web/{chunk-xk1vkcj4.js → chunk-3zs2v6b4.js} +4 -4
  84. package/web/{chunk-9k7fkx80.js → chunk-43194184.js} +1 -1
  85. package/web/{chunk-vk7ch6fh.js → chunk-43bczb21.js} +2 -2
  86. package/web/{chunk-0rhx7qb8.js → chunk-4m9mgdaa.js} +1 -1
  87. package/web/{chunk-jpem3qvs.js → chunk-4q2jtvwn.js} +5 -5
  88. package/web/{chunk-w28dn4dw.js → chunk-4tbhxtnm.js} +1 -1
  89. package/web/{chunk-q4vy3dkk.js → chunk-50vgq2nk.js} +2 -2
  90. package/web/{chunk-atppv8fk.js → chunk-57b8j192.js} +1 -1
  91. package/web/{chunk-h6k1x096.js → chunk-5d9veaef.js} +2 -2
  92. package/web/chunk-5fzmk43v.js +1 -0
  93. package/web/{chunk-97t3ngqf.js → chunk-5rwg3qqd.js} +7 -7
  94. package/web/{chunk-xe121vg7.js → chunk-62gj74fq.js} +1 -1
  95. package/web/chunk-64h7k870.js +1 -0
  96. package/web/{chunk-3p9w8sg5.js → chunk-65ay0j1t.js} +3 -3
  97. package/web/{chunk-mkxeenph.js → chunk-66164wmv.js} +1 -1
  98. package/web/chunk-6ehecat3.js +1 -0
  99. package/web/{chunk-a6g3nqp0.js → chunk-6s1vjny7.js} +2 -2
  100. package/web/{chunk-ga07tv37.js → chunk-6x1hfjb9.js} +1 -1
  101. package/web/{chunk-dmha2y9c.js → chunk-6xfbh4z5.js} +18 -18
  102. package/web/chunk-73941p08.js +1 -0
  103. package/web/{chunk-t82sngk9.js → chunk-7frnjms9.js} +7 -7
  104. package/web/chunk-7jh6zxg3.js +1 -0
  105. package/web/chunk-7mgwejn4.js +1 -0
  106. package/web/chunk-7qq1ypvj.js +1 -0
  107. package/web/{chunk-awkdw9rw.js → chunk-7wzszsf5.js} +2 -2
  108. package/web/{chunk-c57f714b.js → chunk-7zfqppsx.js} +2 -2
  109. package/web/{chunk-wpxtkxjt.js → chunk-8nm0mghm.js} +2 -2
  110. package/web/{chunk-980zhtht.js → chunk-8qzsxg1q.js} +1 -1
  111. package/web/chunk-8zg89764.js +1 -0
  112. package/web/{chunk-sq75q603.js → chunk-937ndmh1.js} +6 -6
  113. package/web/chunk-95gbcs8j.js +1 -0
  114. package/web/{chunk-eqxy6535.js → chunk-a205cj09.js} +2 -2
  115. package/web/chunk-at0xtfhy.js +1 -0
  116. package/web/{chunk-jh3k7xex.js → chunk-aw6wg8fe.js} +3 -3
  117. package/web/{chunk-g0be12na.js → chunk-b323qea5.js} +1 -1
  118. package/web/{chunk-3ctmehg4.js → chunk-bcx7xges.js} +1 -1
  119. package/web/{chunk-ke8dffnk.js → chunk-bzdn9sxz.js} +2 -2
  120. package/web/{chunk-w4tfad6c.js → chunk-cq1f20k6.js} +1 -1
  121. package/web/{chunk-zb61mf0a.js → chunk-dde64qjd.js} +1 -1
  122. package/web/{chunk-a9er7a7c.js → chunk-dgepxev9.js} +19 -19
  123. package/web/{chunk-6rsr2cyw.js → chunk-djnq1w1e.js} +8 -8
  124. package/web/{chunk-2y1avvqj.js → chunk-ea6b8b50.js} +3 -3
  125. package/web/{chunk-xxmaqj1m.js → chunk-ed5xfgxb.js} +2 -2
  126. package/web/{chunk-0jbf73pr.js → chunk-ehz9m6g4.js} +3 -3
  127. package/web/chunk-evp6t44y.js +8 -0
  128. package/web/chunk-eyg28s83.js +1 -0
  129. package/web/{chunk-mnf4ngj9.js → chunk-fttdbcqv.js} +2 -2
  130. package/web/chunk-g7bcntpm.js +1 -0
  131. package/web/chunk-g9bqacq1.js +1 -0
  132. package/web/chunk-gh8kjzdj.js +1 -0
  133. package/web/{chunk-2sef2wft.js → chunk-hbwxtbq3.js} +2 -2
  134. package/web/{chunk-6e87m0nm.js → chunk-hdtvrh0f.js} +2 -2
  135. package/web/chunk-j031r08w.js +1 -0
  136. package/web/{chunk-zh7193nq.js → chunk-jab2p5zv.js} +2 -2
  137. package/web/{chunk-2x7vmhm0.js → chunk-jca9xbe0.js} +3 -3
  138. package/web/{chunk-jccz14ye.js → chunk-jdx7qp2w.js} +2 -2
  139. package/web/chunk-jpf8x9tm.js +1 -0
  140. package/web/{chunk-5cwxhhae.js → chunk-jx3z63tq.js} +2 -2
  141. package/web/chunk-jy448465.js +1142 -0
  142. package/web/chunk-jy8zat04.js +1 -0
  143. package/web/{chunk-b9jry5a3.js → chunk-k3ah0513.js} +1 -1
  144. package/web/{chunk-qq6m2my8.js → chunk-k4qrqmdk.js} +2 -2
  145. package/web/chunk-k8s7kye3.js +1 -0
  146. package/web/chunk-k9zn1n6d.js +1 -0
  147. package/web/{chunk-v4cqc9f9.js → chunk-ksnsfqrn.js} +1 -1
  148. package/web/{chunk-cr04125j.js → chunk-kxr473dw.js} +12 -12
  149. package/web/{chunk-3wpxymxa.js → chunk-m5psa69k.js} +3 -3
  150. package/web/chunk-md9j949p.js +1 -0
  151. package/web/{chunk-4py9sndw.js → chunk-mss6eg27.js} +6 -6
  152. package/web/{chunk-3jjksgze.js → chunk-mv9q8jrm.js} +1 -1
  153. package/web/{chunk-ze6azq7z.js → chunk-n0ezfa12.js} +4 -4
  154. package/web/chunk-nbcpbqq4.js +1 -0
  155. package/web/{chunk-qq06x2ce.js → chunk-p1bb9xp8.js} +2 -2
  156. package/web/{chunk-14vmr99v.js → chunk-pa82db2e.js} +3 -3
  157. package/web/{chunk-frnh4zqf.js → chunk-pafw34vg.js} +2 -2
  158. package/web/{chunk-1xm9x7d6.js → chunk-pdmcr6d4.js} +2 -2
  159. package/web/{chunk-ct90yf8z.js → chunk-pf65cank.js} +2 -2
  160. package/web/{chunk-jh33m2mq.js → chunk-phj4pcx4.js} +3 -3
  161. package/web/{chunk-fnvgdvrg.js → chunk-pma5pats.js} +4 -4
  162. package/web/{chunk-g7hqafb8.js → chunk-pmghe7rh.js} +1 -1
  163. package/web/{chunk-xcyqd7cn.js → chunk-ppfhtyxt.js} +1 -1
  164. package/web/chunk-pze2v3v1.js +2 -0
  165. package/web/{chunk-e57h40qa.js → chunk-q6j2e8a1.js} +2 -2
  166. package/web/chunk-q6jf3zc1.js +1 -0
  167. package/web/{chunk-9wz8jne3.js → chunk-qdn3hmfy.js} +1 -1
  168. package/web/{chunk-cr05dttm.js → chunk-qdsg8wp0.js} +1 -1
  169. package/web/{chunk-yn4t5s9r.js → chunk-qf2kb7zj.js} +1 -1
  170. package/web/{chunk-eqndhs21.js → chunk-qv1w36ja.js} +2 -2
  171. package/web/{chunk-k0cg4n2k.js → chunk-s0xy00v5.js} +2 -2
  172. package/web/{chunk-zxrbbbtp.js → chunk-s6bc73n3.js} +2 -2
  173. package/web/{chunk-qh62nkem.js → chunk-sd3cdqcm.js} +2 -2
  174. package/web/chunk-sdtesqbb.js +1 -0
  175. package/web/chunk-t0z8ygx4.js +1 -0
  176. package/web/chunk-t2v01k4z.js +1 -0
  177. package/web/{chunk-c6m4vfn5.js → chunk-t5ke9cyg.js} +68 -68
  178. package/web/{chunk-5ym5ffd5.js → chunk-t72z2ww3.js} +2 -2
  179. package/web/{chunk-0rvwj2wh.js → chunk-t78qm9gs.js} +2 -2
  180. package/web/{chunk-xvm66b7v.js → chunk-te15yhn5.js} +4 -4
  181. package/web/{chunk-et1rsgmp.js → chunk-tvaxyhh0.js} +2 -2
  182. package/web/{chunk-pzg25qqe.js → chunk-vvvd3grf.js} +2 -2
  183. package/web/{chunk-ss96cz1f.js → chunk-vwv6pqy7.js} +1 -1
  184. package/web/{chunk-p6e2vr51.js → chunk-vypfy030.js} +6 -6
  185. package/web/chunk-w7cyrbk2.js +1 -0
  186. package/web/chunk-w9nkvcjr.js +1 -0
  187. package/web/{chunk-20jxvmbw.js → chunk-wfgrdabk.js} +1 -1
  188. package/web/chunk-x2f8bwd2.js +1 -0
  189. package/web/chunk-xq8x7dvr.js +1 -0
  190. package/web/chunk-xtss82z2.js +1 -0
  191. package/web/{chunk-ba9qy65y.js → chunk-yeh77fvq.js} +1 -1
  192. package/web/{chunk-y9waq403.js → chunk-ymtq18z6.js} +2 -2
  193. package/web/{chunk-h1k2kqbs.js → chunk-yzmrbssn.js} +4 -4
  194. package/web/{chunk-ct7z7bea.js → chunk-z5h046zm.js} +3 -3
  195. package/web/{chunk-qbmtah1x.js → chunk-zf4b8jb9.js} +1 -1
  196. package/web/index.html +1 -1
  197. package/web/sw.js +17 -1
  198. package/chunk-1dbfmejf.js +0 -2
  199. package/chunk-4w9zqv0k.js +0 -2
  200. package/chunk-6f4ht2hw.js +0 -2
  201. package/chunk-edbq461k.js +0 -5
  202. package/chunk-m71pj3g1.js +0 -2
  203. package/chunk-n22vd4at.js +0 -2
  204. package/chunk-sgrrxsnz.js +0 -482
  205. package/chunk-ydzag81d.js +0 -3
  206. package/web/chunk-12qf1r6m.js +0 -1
  207. package/web/chunk-1m6fx2h7.js +0 -2
  208. package/web/chunk-2n5xbnrt.js +0 -1
  209. package/web/chunk-36s08nye.js +0 -1
  210. package/web/chunk-4swea9sn.js +0 -1
  211. package/web/chunk-4zz5a483.js +0 -1
  212. package/web/chunk-6y55gk1n.js +0 -1
  213. package/web/chunk-7aep7k4v.js +0 -1
  214. package/web/chunk-8tgavnwx.js +0 -1
  215. package/web/chunk-a00vg115.js +0 -1
  216. package/web/chunk-a4gbxnm3.js +0 -1
  217. package/web/chunk-bq6mep6p.js +0 -2
  218. package/web/chunk-bwy3e58v.js +0 -1
  219. package/web/chunk-de29pe57.js +0 -1
  220. package/web/chunk-eeesa5q1.js +0 -1
  221. package/web/chunk-f7jpakwh.js +0 -1
  222. package/web/chunk-fp62avjh.js +0 -1
  223. package/web/chunk-gr163fex.js +0 -1
  224. package/web/chunk-gx340asc.js +0 -1
  225. package/web/chunk-gxtz10wf.js +0 -1
  226. package/web/chunk-k9qnvx86.js +0 -2
  227. package/web/chunk-kcnj0gan.js +0 -1
  228. package/web/chunk-kpp5xqsb.js +0 -1
  229. package/web/chunk-m33yted6.js +0 -1
  230. package/web/chunk-me5jqqn6.js +0 -1
  231. package/web/chunk-mzqqwbmr.js +0 -1
  232. package/web/chunk-mzzaet63.js +0 -1
  233. package/web/chunk-q34as3v6.js +0 -1
  234. package/web/chunk-q6c8p73w.js +0 -1
  235. package/web/chunk-qn93we3a.js +0 -1
  236. package/web/chunk-r1f1egve.js +0 -1
  237. package/web/chunk-tt9410zw.js +0 -8
  238. package/web/chunk-ve8gy05p.js +0 -1142
  239. package/web/chunk-vg1ebkce.js +0 -1
  240. package/web/chunk-vnt34mkb.js +0 -1
  241. package/web/chunk-xh4xn1az.js +0 -1
  242. package/web/chunk-xrk5ewsn.js +0 -1
  243. package/web/chunk-xzwxcxb4.js +0 -1
  244. package/web/chunk-ydhnkws0.js +0 -1
  245. package/web/chunk-ys2tns0p.js +0 -1
@@ -1 +1 @@
1
- import{h,o,i,r,m,e,n,y,s,te,st,Te,oe,ne,je,Ke,Q,Z}from"./chunk-ve8gy05p.js";import{$r,Br,Fr}from"./chunk-1m6fx2h7.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(st,{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:"全局"}]},...$r(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(Br,{label:"搜索 MCP 服务器",placeholder:"搜索服务器",value:c,onChange:D}),e("div",{className:v("settings.groupBox"),children:!M?e(Fr,{}):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,zn,p,Hn}from"./chunk-c6m4vfn5.js";import{Ce}from"./chunk-ve8gy05p.js";var o=Ce(Hn(),1);var an=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"),Vr=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"};an(s,r).lower()},"drawBackgroundRect"),lo=t((s,e)=>{let r=e.text.replace(zn," "),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"),Aa=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"),Ra=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"),La=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
- export{an,Vr,lo,Aa,Ra,tt,La,Ft};
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
+ 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-c6m4vfn5.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,Mr,s,K,pn,ot,ie,tr,Z}from"./chunk-ve8gy05p.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(pn,{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(tr,{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(Mr)===d.roomID}catch{return!1}}),[x,X]=r(Date.now);o(()=>{c(d)},[d]),o(()=>{if(!C)return;try{if(sessionStorage.getItem(Mr)===d.roomID)sessionStorage.removeItem(Mr)}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};